You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement type inference from assumptions (#21)
When assumptions are made, symbol types are now correctly inferred:
- Inequality assumptions (>, <, >=, <=) set the symbol's type to 'real'
- Equality assumptions infer the type from the value:
- Equal to integer → type 'integer'
- Equal to rational → type 'real'
- Equal to real → type 'real'
- Equal to complex → type 'number'
Implementation:
- Added inferTypeFromValue() function to promote specific types
(e.g., finite_integer → integer)
- Updated assumeEquality() to use inferTypeFromValue when updating types
- Updated assumeInequality() to set type 'real' even for auto-declared symbols
Examples:
ce.assume(ce.box(['Greater', 'x', 4]));
ce.box('x').type.toString(); // → 'real' (was: 'unknown')
ce.assume(ce.box(['Equal', 'one', 1]));
ce.box('one').type.toString(); // → 'integer' (was: 'unknown')
Files modified:
- src/compute-engine/assume.ts - Added inferTypeFromValue(), updated type inference
- test/compute-engine/assumptions.test.ts - Enabled 6 tests
- CHANGELOG.md, requirements/TODO.md, requirements/DONE.md - Documentation
https://claude.ai/code/session_01Xx26gPU9ThyiypRqdLcmZQ
0 commit comments