Skip to content

Fix Bug 125 and 127#102

Merged
ColtonPayne merged 6 commits intomainfrom
fix-bug-125-127
Jan 30, 2026
Merged

Fix Bug 125 and 127#102
ColtonPayne merged 6 commits intomainfrom
fix-bug-125-127

Conversation

@ColtonPayne
Copy link
Collaborator

@ColtonPayne ColtonPayne commented Jan 28, 2026

Fix BUG-125 and BUG-127: Delta Bound Convergence with IPL Complements

Summary

This PR fixes two critical bugs in the delta_bound convergence calculation when Inverse Predicate Law (IPL) complements are involved:

Both bugs affected convergence detection in delta_bound mode, potentially causing premature convergence or incorrect convergence thresholds.

BUG-125: Wrong Variable Appended in _update_edge

Severity: CRITICAL
Location: interpretation.py:1649, interpretation_fp.py:1750
Impact:
Convergence tracking received the wrong bound, causing incorrect delta calculations. The complement's actual delta was completely missed and replaced with a duplicate of the original predicate's bound.

Note: This bug only affected _update_edge. The equivalent code in _update_node was already correct.


BUG-127: Delta Comparisons Use Wrong Previous Bounds

Severity: CRITICAL
Locations:

  • interpretation.py:1541-1546 (_update_node)
  • interpretation.py:1659-1668 (_update_edge)
  • interpretation_fp.py:1659-1664 (_update_node)
  • interpretation_fp.py:1761-1766 (_update_edge)

Issue:
When calculating deltas in delta_bound mode, all bounds in updated_bnds (including IPL complements) were compared against the original label's previous bound instead of each bound's own previous bound.

Impact:
Dramatically inflated or deflated convergence deltas for IPL complements, leading to incorrect convergence detection in delta_bound mode.


Files Modified

  • pyreason/scripts/interpretation/interpretation.py - Fixed both bugs
  • pyreason/scripts/interpretation/interpretation_fp.py - Fixed both bugs

Tests Added

Added comprehensive test cases to test_reason_update.py:

  1. test_update_node_ipl_complement_delta_bound_bug127 - Tests BUG-127 for nodes using infected/healthy predicates with two sequential updates
  2. test_update_edge_ipl_two_complements_bug125 - Tests BUG-125 with multiple IPL pairs (infected/healthy/recovered)

All tests:

  • Fail on old code:
    Here is a screenshot running the new tests from main:
Screenshot from 2026-01-28 09-49-34
  • Pass with updates to interpretation and interpretation_fp:
Screenshot from 2026-01-28 09-50-15

All existing tests continue to pass.

@dyumanaditya dyumanaditya self-requested a review January 29, 2026 17:50
Copy link
Contributor

@dyumanaditya dyumanaditya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good @ColtonPayne

@ColtonPayne ColtonPayne merged commit 25236cd into main Jan 30, 2026
3 checks passed
@ColtonPayne ColtonPayne deleted the fix-bug-125-127 branch February 2, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants