Commit efbaaf7
Task 18 et al (#281)
* fix: implement value resolution from equality assumptions (#18)
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
* feat: implement inequality evaluation using assumptions (#19)
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
* fix: forget() and scoped assumptions now properly clear values (#24, #25)
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
* 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
* feat: implement tautology and contradiction detection for assumptions (#20)
ce.assume() now returns 'tautology' for redundant assumptions that are
already implied by existing assumptions, and 'contradiction' for
assumptions that conflict with existing ones.
Examples:
- ce.assume(['Greater', 'x', 0]) when x > 4 exists returns 'tautology'
- ce.assume(['Less', 'x', 0]) when x > 4 exists returns 'contradiction'
- ce.assume(['Equal', 'one', 1]) repeated returns 'tautology'
- ce.assume(['Less', 'one', 0]) when one=1 exists returns 'contradiction'
Implementation:
- Added bounds checking logic in assumeInequality() that extracts the
symbol from the inequality and checks against existing bounds
- Handles canonical form normalization (Greater(x,k) → Less(k,x))
- Correctly determines "effective" relationship based on operator and
which operand contains the symbol
https://claude.ai/code/session_01Xx26gPU9ThyiypRqdLcmZQ
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 73b6870 commit efbaaf7
5 files changed
Lines changed: 308 additions & 92 deletions
File tree
- requirements
- src/compute-engine
- test/compute-engine
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
36 | 71 | | |
37 | 72 | | |
38 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1184 | 1184 | | |
1185 | 1185 | | |
1186 | 1186 | | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
781 | | - | |
| 781 | + | |
782 | 782 | | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
| 783 | + | |
824 | 784 | | |
825 | 785 | | |
826 | 786 | | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
| 787 | + | |
831 | 788 | | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
| 789 | + | |
867 | 790 | | |
868 | 791 | | |
869 | 792 | | |
| |||
0 commit comments