Skip to content

Conversation

@arnog
Copy link
Member

@arnog arnog commented Jan 31, 2026

Summary

Changes

Bug #24: forget() Doesn't Clear Assumed Values

After ce.assume(['Equal', 'x', 5]) and ce.forget('x'), the symbol now correctly evaluates to 'x' instead of persisting as 5.

Bug #25: Scoped Assumptions Don't Clean Up

Assumptions made inside pushScope()/popScope() blocks now properly clean up when the scope exits.

Implementation

  • Added _setCurrentContextValue() method to store values directly in the current context
  • Modified assumeEquality() to use scoped value storage
  • Added cleanup in forget() to delete values from all context frames

Test plan

  • Added test/compute-engine/bug-fixes.test.ts with tests for both bugs
  • All existing assumption tests pass
  • Full test suite passes (except pre-existing failures unrelated to these changes)

When ce.assume(['Equal', symbol, value]) is called, the symbol now
correctly evaluates to the assumed value. Previously, the symbol would
remain unevaluated even after the assumption was made.

Changes:
- Fixed assumeEquality to set the symbol value when it already has a
  definition (which happens when accessed via .unknowns)
- Updated BoxedSymbol.N() to check the evaluation context value for
  non-constant symbols, enabling correct comparison evaluation

Examples that now work:
- ce.box('one').evaluate().json → 1 (was: "one")
- ce.box(['Equal', 'one', 1]).evaluate() → True (was: unchanged)
- ce.box(['Equal', 'one', 0]).evaluate() → False

https://claude.ai/code/session_01Xx26gPU9ThyiypRqdLcmZQ
When inequality assumptions like `ce.assume(['Greater', 'x', 4])` are made,
comparisons can now use transitive reasoning to determine results.

For example, `x > 4` implies `x > 0`, so `['Greater', 'x', 0]` evaluates
to True instead of remaining symbolic.

Implementation:
- Added `getInequalityBoundsFromAssumptions()` to extract lower/upper bounds
  from normalized assumption forms like `Less(Add(Negate(x), k), 0)`
- Modified `cmp()` in compare.ts to use these bounds when comparing symbols

Examples that now work:
- ce.box(['Greater', 'x', 0]).evaluate() → True (when x > 4 assumed)
- ce.box(['Less', 'x', 0]).evaluate() → False
- ce.box('x').isGreater(0) → true
- ce.box('x').isPositive → true

https://claude.ai/code/session_01Xx26gPU9ThyiypRqdLcmZQ
)

Bug #24: forget() now clears assumed values from evaluation context
- After ce.assume(['Equal', 'x', 5]) and ce.forget('x'), x now correctly
  evaluates to 'x' instead of 5
- Added cleanup loop in forget() to delete values from all context frames

Bug #25: Scoped assumptions clean up on popScope()
- Assumptions made inside pushScope()/popScope() now properly clean up
- Added _setCurrentContextValue() method to store values in current context
- Modified assumeEquality() to use scoped value storage
- Values set by assumptions are automatically removed when scope exits

Files modified:
- src/compute-engine/index.ts - Added _setCurrentContextValue(), forget() cleanup
- src/compute-engine/global-types.ts - Added method signature
- src/compute-engine/assume.ts - Use scoped value storage
- test/compute-engine/bug-fixes.test.ts - Tests for both bugs
- CHANGELOG.md, requirements/TODO.md, requirements/DONE.md - Documentation

https://claude.ai/code/session_01Xx26gPU9ThyiypRqdLcmZQ
Resolved conflicts keeping our bug fixes (#24, #25) and task #19 implementation:
- assume.ts: Keep _setCurrentContextValue for scoped assumptions
- CHANGELOG.md: Include inequality evaluation feature
- DONE.md: Include tasks #19, #24, #25 documentation

https://claude.ai/code/session_01Xx26gPU9ThyiypRqdLcmZQ
@arnog arnog merged commit 73b6870 into main Jan 31, 2026
1 check failed
@arnog arnog deleted the claude/complete-task-18-NewVw branch January 31, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants