Merged
Conversation
kmukherji
approved these changes
Apr 6, 2026
Member
There was a problem hiding this comment.
Unless there's documentation on another file, this script needs some comments for an user to understand what's going on.
Collaborator
Author
There was a problem hiding this comment.
Updated example with comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for closed world predicates to PyReason. Predicates registered as closed-world have their unknown
[0,1]bounds treated as[0,0](false) during rule body satisfaction checks, enabling negation-as-failure style reasoning for a user-specified subset of predicates.Public API
Any clause in a rule body that references
hackerControlwill, at satisfaction-check time, treat unknown[0,1]bounds — or absence of the label entirely — as[0,0]. Known bounds are left untouched, so settinghackerControl(A)explicitly still behaves normally.pr.reset()clears the registered set;pr.reset_rules()andpr.reset_settings()leave it intact.Implementation
__closed_world_predicatesset inpyreason/pyreason.py, plumbed into eachInterpretation*class viaProgram.reason()as anumba.typed.List[Label].is_satisfied_node/is_satisfied_edgeininterpretation.py,interpretation_fp.py, andinterpretation_parallel.pygained a short-circuit branch: if the clause label is closed-world and the world bound is missing or[0,1], it's coerced to[0,0]before the containment check.Program.reason()assignedclosed_world_predicatestoInterpretationandInterpretationFPbut notInterpretationParallel, causing parallel mode to silently run with an empty closed-world set. Assignment added inpyreason/scripts/program/program.py.Tests
tests/unit/disable_jit/interpretations/test_minimized_predicates.py: JIT-disabled tests coveringis_satisfied_node/is_satisfied_edgedirectly for bothinterpretationandinterpretation_fpmodules. Exercises in-world[0,1], missing label, known bounds bypass, negative-query case, multiple closed-world predicates, and non-closed-world contrast.tests/api_tests/test_pyreason_state_management.pyaddsTestMinimizedPredicateApi: registration, idempotence, multi-predicate, and interactions withreset()/reset_rules()/reset_settings().tests/functional/test_circumscription.py: 8 scenarios × 3 modes (regular,fp,parallel). Every test depends on a~closed_world_pred(Y)clause actually firing, so circumscription must be working for the test to pass (not just present). Covers:[1,1]bypass[0,1]at each step)inconsistency_check,persistent,atom_tracesettings[0,1]and missing-from-world) in the same reasoning passTest plan
pytest tests/unit/disable_jit/interpretations/test_minimized_predicates.py -vpytest tests/api_tests/test_pyreason_state_management.py -vpytest tests/functional/test_circumscription.py -v(all cases green on regular + fp + parallel)python examples/circumscription_ex.pyruns without error🤖 Generated with Claude Code