Skip to content

Reduce BKW dominance queries with exact structural prepasses - #123

Closed
PerAlexandersson wants to merge 1 commit into
mainfrom
bkw-exact-prepasses-20261203
Closed

PerAlexandersson wants to merge 1 commit into
mainfrom
bkw-exact-prepasses-20261203

Conversation

@PerAlexandersson

Copy link
Copy Markdown
Owner

Why

Automatic BKW dominance analysis can construct large multivariate formulas even when a short exact structural argument decides the input. On the existing benchmark set, a cubic pencil took 6.6 seconds in Z3, and a degree-eight pencil aborted during symbolic construction while attempting an 11,005,853,712-byte allocation.

This change runs additional exact reductions before elimination and reduces the formulas that remain. It advances #121 and builds on the rational-scaling fix and general pencil-level replay already on main in aac299d.

Changes

  • Recognize rotational symmetry after removing structural zero roots.
  • Add a sufficient trinomial certificate, with exact removal of exceptional parameter factors and a replay verifier.
  • Invert the parameter and uniformly scale characteristic roots to expose composed pencils covered by the existing degree-gap theorem. Record and verify the exact transformation.
  • Cancel common powers in pencil quotients before expanding real and imaginary parts; use direct closed-unit-disk predicates for linear and quadratic quotients, including singular boundary cases.
  • Reuse already-computed radial minors in the first-order discriminant fallback.
  • Bound the initial sparse-product reservation by operand sizes instead of eagerly reserving the Cartesian product.
  • Preserve upstream LevelConfirmed replay and distinguish an independent contradiction from an unavailable check. ParameterContradicts and LevelContradicts remain inconclusive, and positive replay verdicts require a SAT solver answer.
  • Add focused library/CLI regressions, benchmark filtering, and updated documentation.

The complete univariate quadratic-characteristic decision procedure in doc/quadratic-dominance.md is a reviewed mathematical and implementation note; that further algorithm is not implemented by this PR.

Measurements

Individual runs on the same host, Rust 1.82.0 and Z3 5.4.1, compared with aee68ce:

Input Earlier behavior Updated automatic route
t^3-(x+1)t^2+x*t-x SAT in 6,598 ms; 125 terms, degree 16 SAT in 15 ms; 93 terms, degree 12
t^4-x*t^2-1 Solver timeout at 2 s Exact rotational certificate, construction under 1 ms
t^5-x*t^4-1 Construction 21 ms, solver timeout at 2 s Exact trinomial certificate, construction under 1 ms
t^8-x*t^7-1 Aborted during the allocation above Exact trinomial certificate, construction under 1 ms

The initial optimized sweep completed all 21 cases: nine exact structural certificates and twelve solver answers in 10–32 ms. After integrating current main's broader level replay, a fresh sweep retained the same nine certificates and twelve answers in 10–91 ms, with no contradictory replay; the first cubic took 20 ms in that run. These are individual timings, not a uniform speedup claim.

The spectral result contract is unchanged: amplitudes, BKW nondegeneracy, and real-rootedness of every row are separate questions. Algebraic solver models keep their unreplayed status, and UNSAT remains solver-backed.

Validation

After reconciling with main at d652a0b:

  • 49 exact-stability unit tests and 9 integration tests passed with EXACT_STABILITY_Z3 enabled.
  • Focused root BKW integration tests: 23 passed, 4 existing expensive tests ignored; the new CLI solver regressions were enabled.
  • Strict exact-stability Clippy, formatting, rustdoc with warnings denied, locked metadata, and diff checks passed.
  • The 21-case automatic benchmark completed with no timeouts or contradictory replay.
  • Independent reviews checked the structural certificates and the merged replay logic.

Before integration, the 63 polytool-core doctests and 3 root doctests also passed. Broader strict Clippy encountered pre-existing warnings in crates/polytool-core/src/digest.rs, src/bin/polytool/bench_kernels.rs, and src/bin/polytool/oeis/evidence.rs; this PR leaves those files unchanged.

@PerAlexandersson

Copy link
Copy Markdown
Owner Author

Reviewed and ported to the workspace tree, which generates main. The PR will be closed when the next sync carries it to main; please do not merge it here.

Review. The mathematics checks out:

  • Trinomial scaling. σ = C^u D^v gives C(sᵈ − a·sᵐ + 1), and the sign in F matches.
  • Reference polynomial. Its dominant root is nonreal: for even d there are no real roots; for odd d there is a single real root in (−1, 0) and the moduli multiply to 1.
  • Reciprocal map. It is monic and polynomial, and preserves nonreality, multiplicities and modulus order.
  • Quadratic closed-disk predicate. Correct both by one Schur–Cohn step when |γ| < |α| and by the self-inversive case when |γ| = |α|.
  • First-order fallback. Reusing E_{k,0} = D_k is exact.

Two follow-ups in the port:

  • The MCP test bkw_dominance_decides_or_compiles used t⁴ − x³ as its even-gap example. Rotational symmetry now decides that input, so the test uses t⁴ + t² + t − x³, and the benchmark row is updated the same way. The MCP tests had not been run.
  • doc/quadratic-dominance.md named a not-yet-existing file as a path, which fails the doc-path check. It now names the module instead.

Benchmark (automatic compiler, Z3 5.4.1, 60 s): all 21 cases are decided, with no timeouts. Nine get exact certificates and twelve get solver answers in 10–30 ms. Every answer agrees with the earlier runs.

For future changes: main here is generated from the workspace tree by a sync script, so changes should start there.

PerAlexandersson added a commit that referenced this pull request Dec 3, 2026
Port of public polytool PR #123 ("Reduce BKW dominance queries with exact
structural prepasses", commit cb719f2) onto the workspace tree, so it
reaches public main through the regular sync.

- Rotational symmetry: a characteristic exponent gcd > 1 after structural
  zeros gives equal-modulus root orbits at every parameter.
- Trinomial certificate for t^d + B t^m + C (gcd(d, m) = 1, d >= 3) from
  the nonreal zeros of B^d - (-1)^(d(m+1)) C^(d-m) away from zeros of C,
  with an exact verifier.
- Reciprocal parameter with uniform root scaling exposes degree-gap
  certificates for further non-pencil inputs.
- Pencil quotients drop their common power of w; linear and quadratic
  quotients use direct closed-disk predicates; the first-order fallback
  reuses its radial minors; sparse products reserve by operand sizes.
- Replay distinguishes independent contradictions (ParameterContradicts,
  LevelContradicts; inconclusive) from unavailable checks; a positive
  verdict requires a sat answer.
- Docs: benchmark table, and a reviewed note on a complete univariate
  quadratic route (not implemented).

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

PerAlexandersson commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner Author

Released in public main 31f185e (31f185e). Public main is generated from the workspace tree, so this PR was ported there instead of being merged here.

  • The port keeps the structural prepasses: rotational symmetry, the trinomial certificate, the reciprocal transform, the quadratic disk predicate, and the fallback reuse.
  • It also fixes an MCP test and a documentation path.
  • Public CI (CI, Python, Documentation) is green at 31f185e.

Lean coverage of the new prepass steps is tracked in PerAlexandersson/RealRooted#2708. Thank you for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant