Repository navigation
Ask the e-graph whether two expressions are equal: MathS.AreEqual - #2447
Merged
Merged
Conversation
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>
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>
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>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #2447 +/- ##
==========================================
+ Coverage 86.92% 86.95% +0.03%
==========================================
Files 316 319 +3
Lines 70574 70760 +186
Branches 20613 20666 +53
==========================================
+ Hits 61345 61528 +183
+ Misses 4956 4953 -3
- Partials 4273 4279 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Closes #1251, in the shape agreed on the issue.
API
The answer is three-valued:
Equal,NotEqualorUnknown, with theBudgetOutcome, so a spent budget is never read as a negative.Equalcarries the weakest soundness it relied on, and for a conditional proof the steps that merged a class.NotEqualcarries a witness point.How it decides, in one budget ledger:
Complex. Two sides differ at a point when both are defined there and their interval enclosures are disjoint.weakest = Soundonly the rules declaringSoundrun.Unknown.Commutativity is Sound. For the query only, two steps reorder the operands of a sum and of a product. They don't group or fold anything, and they are not in any rule set, so
Simplifyis unchanged. They decline when an operand involves a matrix, a transpose, a set, a statement or a lambda. They also decline for the whole question when it writes a matrix operation (#2147). Names are read as numbers ofdomain, which the docs say.Catalogue and MCP. The catalogue entry is
are_equal, and the MCP tool isam_are_equal. Unlikeam_verify_equal, it never answers from sampling. Itsnot_equalcomes with a point you can check, and unknown is never reported as false. The terminal lists it innotOffered.Measured
The corpus is 83 true pairs from the simplification regression tests. Mean cost per query is from the prototype, against
Simplify(a - b) == 0.AreEqual, SoundAreEqual, SoundUnderAssumptionsThere was no NotEqual on a true pair and no Equal on a false one. All 12 Unknowns saturated inside the budget, so what limits them is the rules, which cannot expand or factorise.
Simplifyproves more of these pairs, but it has no NotEqual and no Unknown.Checks.
PublicApi.txt. There is no BREAKING-CHANGES entry, since no answer changes.Left open
provided, piecewise, a binder or a set can only come out Equal or Unknown.🤖 Generated with Claude Code