Expand crashes on (x + 1)! / x!, an expression Simplify handles without trouble.
Measured
On master at d1c4a4dd (which is 21f0d16f plus #816; Expand's logic is untouched by that PR), net10.0/Release:
(x + 1)! / x! -> AngouriBugException: SmartExpandOver must be only called of non-sum expression
(x + 1)! -> (x + 1)!
x! / y! -> x! / y!
(x + 1)! / x! -> 1 + x // Simplify, for comparison
sin(x)! / x! -> sin(x)! / x!
So it is specific to a quotient whose numerator is a factorial of a sum: (x + 1)! alone is fine, x! / y! is fine, sin(x)! / x! is fine.
Where
TreeAnalyzer.SmartExpandOver asserts its argument is not a sum (Expansion.cs:97). Entity.Expand reaches it through Patterns.ExpandFactorialDivisions, which rewrites the quotient of factorials into a product of the terms that do not cancel — and the recursive call at Expansion.cs:101 then hands it a sum.
Why it matters
AngouriBugException is the library telling a caller that the library is broken, from a public method, on an expression that is perfectly ordinary — and it is thrown rather than returned, so a caller who wraps Expand over a corpus loses the whole run rather than one entry. Per AGENTS.md the honest failure here is to hand back the expression unexpanded.
How it was found
Writing a corpus for the rule-set registry tests in #816's follow-up: applying every registered rule set and every catalogue transformation to a factorial expression. The expression is not exotic; it simply had no test pointing at it.
A skipped regression test is included in that follow-up PR, referencing this issue.
Expandcrashes on(x + 1)! / x!, an expressionSimplifyhandles without trouble.Measured
On
masteratd1c4a4dd(which is21f0d16fplus #816;Expand's logic is untouched by that PR), net10.0/Release:So it is specific to a quotient whose numerator is a factorial of a sum:
(x + 1)!alone is fine,x! / y!is fine,sin(x)! / x!is fine.Where
TreeAnalyzer.SmartExpandOverasserts its argument is not a sum (Expansion.cs:97).Entity.Expandreaches it throughPatterns.ExpandFactorialDivisions, which rewrites the quotient of factorials into a product of the terms that do not cancel — and the recursive call atExpansion.cs:101then hands it a sum.Why it matters
AngouriBugExceptionis the library telling a caller that the library is broken, from a public method, on an expression that is perfectly ordinary — and it is thrown rather than returned, so a caller who wrapsExpandover a corpus loses the whole run rather than one entry. Per AGENTS.md the honest failure here is to hand back the expression unexpanded.How it was found
Writing a corpus for the rule-set registry tests in #816's follow-up: applying every registered rule set and every catalogue transformation to a factorial expression. The expression is not exotic; it simply had no test pointing at it.
A skipped regression test is included in that follow-up PR, referencing this issue.