Skip to content

Drop a radical root in back-substitution only where an interval shows it fails - #2521

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
big-root-modulus
Nov 19, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
big-root-modulus

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

An equation in a modulus is solved as a system in the real and imaginary parts of x. In Gröbner back-substitution, each root of the last equation is substituted into the others, and a root that leaves any of them a nonzero number is dropped. A root containing a radical is substituted by evaluating, and where the terms are large they cancel to whatever their hundred digits leave, which downcasting reads as a rational. For example, the root (-4·10^24 - sqrt(28·10^48)) / 6, substituted into its own quartic (terms near 1e96), left 13/10000. So these equations lost their real roots once the roots were near 10^23 or larger:

Input 2.8.0 master Now
(1 - 2y) + y abs(-2 - 3y) = 0 with y = 10^(-24) x { } { } { -10^24/3 sqrt(7) - 2·10^24/3 }
-2y + 3y^2 - 2 abs(-3 + 2y) = 0 with y = 10^(-24) x { } { } both roots

The check now treats an equation as failing at a root in two ways. If the equation, with the root substituted, is still a polynomial over Q, it is decided exactly, as before. If it is not, an interval has to show it isn't 0; when the interval doesn't, the root is kept, and every solution is still checked against the original system at the end.

Not fixed: roots near 10^30 are still lost, as on master. At that scale InnerSimplified evaluates the radicals to decimals beyond their hundred digits and downcasts the results to integers whose last digits were never computed (157145…000). So the narrowed equations are already wrong before this check runs. Fixing that would mean downcasting refuses to call a decimal an integer when its precision doesn't reach the units digit. That changes how numbers are created everywhere, so it is left for a separate decision (#1019).

Checks:

  • Unit tests: 21239 passed. MCP, Terminal, Interactive and F# tests pass. AOT is OK.
  • Harnesses: BoundCheck, RootCheck (596/596), CasBench (0 wrong), PropCheck, SimpSweep, RuleCheck, CanonCheck, Confluence and ModenovCorpus are clean or match their baselines.
  • The unscaled cross-checks are unchanged row for row.
  • The scale checks at x = 10^(-30) x drop from 11 answers differing in their roots on master to 5: the 2 log sums at 10^30 x (a separate defect), and 3 near 10^30 (above).
  • A trial merge with Search for a rational root whatever the scale of the coefficients #2520 passes the algebra and common tests (6661).

Found by solving generated equations with x written as 10^-30 x. No issue was filed.

🤖 Generated with Claude Code

… it fails

The Groebner back-substitution puts each root of the last equation into the others and drops a
root that leaves one a nonzero number. A root with a radical in it, or an equation holding one
assigned before, is put to a number by evaluating, and where the terms are large they cancel to
what their hundred digits leave, which downcasting reads as a rational: the root
(-4 10^24 - sqrt(28 10^48)) / 6 of its own quartic, with terms near 1e96, left 13/10000. So the
system for the parts of x in an equation in a modulus with roots near 10^23 or more dropped its
real roots, and 1 - 2x + x|-2 - 3x| = 0 with x written as 10^-24 x was { }. An equation that is
a polynomial over Q at the root is still decided exactly; one that is not is decided by an
interval, and a root it does not show to fail goes on.

Near 10^30 InnerSimplified itself evaluates the radicals into decimals past its digits and
downcasts them to integers, so the narrowed equations are wrong before this check is reached,
and roots are still lost there, as on master.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.91%. Comparing base (90593a8) to head (c10800b).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...Functions/Algebra/Groebner/GroebnerSystemSolver.cs 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2521      +/-   ##
==========================================
+ Coverage   86.89%   86.91%   +0.01%     
==========================================
  Files         340      340              
  Lines       73970    73992      +22     
  Branches    21548    21555       +7     
==========================================
+ Hits        64277    64310      +33     
+ Misses       5222     5212      -10     
+ Partials     4471     4470       -1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.42% <75.00%> (+0.01%) ⬆️
fsharp 32.79% <ø> (ø)
interactive 40.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...Functions/Algebra/Groebner/GroebnerSystemSolver.cs 79.41% <75.00%> (+1.38%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit 2aab628 into master Nov 19, 2026
37 of 38 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 19, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the big-root-modulus branch November 19, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant