Repository navigation
Commit f439c0e
Ask the e-graph whether two expressions are equal: MathS.AreEqual (#2447)
* Ask the e-graph whether two expressions are equal
MathS.AreEqual(left, right, budget, weakest = Sound, domain = Complex)
answers Equal, NotEqual or Unknown.
- NotEqual only with a witness: a point where the library's evaluation
and an enclosure of every subexpression say both sides are defined,
and enclosures of the two values are disjoint (doubles, then fifty
digits). The point is looked for first, so no proof is reported over
a point that refutes it.
- Equal only when both sides land in one e-class. Under weakest =
Sound only rules declaring Sound fire; under SoundUnderAssumptions
the conditional rules and the canonical-form pass join, the answer
names those that merged a class, and a proof the sound rules also
make is reported as Sound.
- Bounded in steps: a point tried, a match attempt, a node grown.
Saturation.Run reports each rule whose application merged two classes.
Part of #1251.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Reorder a sum or a product as a sound step when asking for equality
The e-graph neither sorts a commutative pair nor flattens a nested chain,
and the pass that does, CanonicalOrderExact, also groups like terms and
so declares SoundUnderAssumptions. x + y = y + x was therefore Unknown
to a caller asking for an unconditional proof.
Two oracle-only steps, declared Sound, flatten a Sumf chain or a Mulf
chain (differences and quotients stay operands) and rebuild it in
EntityOrder.Canonical order, grouping nothing. Commutativity and
associativity hold for numbers with no side condition, and a name is a
number of the domain asked. A chain is left alone where an operand holds
a matrix, a transpose, a set, a statement, a lambda or an application,
or where a link is read over a narrower codomain; a question with any
matrix or matrix operation in it gets neither step, since a name beside
a transpose may be a matrix (#2147). Simplify and every rule set are
untouched.
Records the public surface #1251 adds in PublicApi.txt, and points
CanonicalForm.md's "not a decision procedure for equality" at
MathS.AreEqual.
Part of #1251.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Offer MathS.AreEqual as a catalogue entry and an MCP tool
are_equal joins Core/Operations/Catalogue.cs: an operation offered by
name is an entry there.
The MCP server offers it as am_are_equal: left and right as strings, a
step budget (default 20000), domain (complex or real) and the weakest
soundness (sound or sound_under_assumptions). The answer states the
verdict, the justification, the assumptions, the witness and what the
budget did; unknown is "inconclusive" with equal null, never false. The
description sets it apart from am_verify_equal, which may answer from
sampling and believes a simplification.
The terminal lists it in OneShot.notOffered: its one-shot commands are
AngouriMathCLI's, and adding commands is #1019 item 16's question.
Part of #1251.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 5ec47ae commit f439c0e
15 files changed
Lines changed: 1178 additions & 8 deletions
File tree
- Sources
- AngouriMath
- Convenience
- Core
- Operations
- Transformations
- Docs/Contributing
- MCP
- AngouriMath.Mcp
- Terminal/AngouriMath.Terminal.Lib
- Tests
- McpUnitTests
- UnitTests
- Common
- Core
- Operations
- Transformations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1093 | 1093 | | |
1094 | 1094 | | |
1095 | 1095 | | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
160 | 170 | | |
161 | 171 | | |
162 | 172 | | |
| |||
244 | 254 | | |
245 | 255 | | |
246 | 256 | | |
247 | | - | |
| 257 | + | |
248 | 258 | | |
249 | 259 | | |
250 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 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 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
0 commit comments