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
{{ message }}
Repository navigation
Incomplete Simplification (Factoring) and Equality Check #531
Unexpected behaviour or bug:
I have the following expression:
Entityexpr="a*c + a*d + b*c + b*d";
When I call Simplify() on it, it becomes the following:
a * (c + d) + b * c + b * d
I would expect it to be the reduced form ((a + b) * (c + d)). Normally this wouldn't be a problem, but testing for equality between these two fails unless they are both in their maximally expanded forms:
Entityexpr="a*c + a*d + b*c + b*d";Entityexpr2="(a + b) * (c + d)";Entityeq=newEntity.Equalsf(expr,expr2);eq=eq.Simplify();Console.WriteLine(eq);// Prints "a * (c + d) + b * c + b * d = (a + b) * (c + d)"expr2=expr2.Expand();eq=newEntity.Equalsf(expr,expr2);eq=eq.Simplify();Console.WriteLine(eq);// Prints "true"
We require this equality check to function properly, and (hopefully) fixing this simplification bug will make that work.
simplify(a*c + a*d + b*c + b*d) => (a + b) * (c + d)
simplify(a*c + a*d + b*c + b*d = (a + b) * (c + d)) => True
The cause of the first: the factoring rules only ever looked at two adjacent terms of the sum tree, so a sum of four was left half-factored at a*(c + d) + b*c + b*d. Collection now runs over the whole sum rather than pairwise, and the equality check falls out of it -- both sides reach the same form, so Equalsf(...).Simplify() is True without expanding by hand first.
Regression tests are in SimplificationRegressionTest.Issue531_TermsCollectOverTheWholeSum and Issue531_CollectionPreservesValue, the second of which checks the collected form is still the same expression rather than just a tidier-looking one.
Activity
Fix two Simplify hangs, an integration stack overflow, and incomplete…
Open up multiple angles, and integrate the squares of sine and cosine (…
Write out the issue links in comments rather than the shorthand (#689)
Rafael-SOWNet commentedon Aug 5, 2026
Both halves of this work on master now.
The cause of the first: the factoring rules only ever looked at two adjacent terms of the sum tree, so a sum of four was left half-factored at
a*(c + d) + b*c + b*d. Collection now runs over the whole sum rather than pairwise, and the equality check falls out of it -- both sides reach the same form, soEqualsf(...).Simplify()isTruewithout expanding by hand first.Regression tests are in
SimplificationRegressionTest.Issue531_TermsCollectOverTheWholeSumandIssue531_CollectionPreservesValue, the second of which checks the collected form is still the same expression rather than just a tidier-looking one.Closing.
Point AGENTS.md at work that is still open, and at keeping the harness (