Skip to content

feat(hex-roots): add bench/HexRoots/Bench.lean and CI wiring#8747

Merged
kim-em merged 3 commits into
mainfrom
hexroots/bench
Jul 11, 2026
Merged

feat(hex-roots): add bench/HexRoots/Bench.lean and CI wiring#8747
kim-em merged 3 commits into
mainfrom
hexroots/bench

Conversation

@kim-em

@kim-em kim-em commented Jul 11, 2026

Copy link
Copy Markdown
Owner

This PR adds the Phase 4 benchmark root bench/HexRoots/Bench.lean (exe hexroots_bench) for the certified complex-root isolation library, and wires it into lakefile.lean, the CI HEX_EXE_TARGETS set, and the Bench verify step. It registers the SPEC API surface with textbook exact-dyadic-operation-count complexity models and adjacent cost-model derivation comments: taylor and the two atom-witness checks (witnessCheck, nkWitnessCheck) at O(n²); newtonSquare at O(n²); mahlerPrec at O(n·log‖p‖∞) reduced to O(n) over a fixed-height family; the refinement primitives Component.refine1 and Component.certify? on a mid-refinement component; the whole-polynomial drivers isolateAll? (target 32) and isolate (to the separationDepth floor) at O(n³); DyadicRootIsolation.refineTo? parametric in the target precision at O(t²); the RefinedIsolation.sameRoot identity test as a fixed microsecond benchmark; and the dual-route atom-certificate compare group (isolate under .nk, .pellet, .nkThenPellet) over a shared ∏(X−j) integer-root domain, joined on a strategy-invariant integer-grid projection of the isolation output.

Two deterministic input families key on the benchmark parameter (its degree): a seed-0xC0FFEE LCG dense family matching the conformance ci-tier fixtures (irrational distinct roots, used by taylor/mahlerPrec/the refinement primitives/the two drivers), and the Wilkinson-shaped linProdPoly product of distinct monic linears (integer roots, used by the witness/Newton registrations centred on root 1 and by the compare group, where the exact integer centres make the three strategies' digests agree). Helper defs not in the SPEC: lcgNext/seededCoeffs/seededPoly/linProdPoly/linearFactor (input families), taylorCentre/rootSquare/refinePoly (fixtures), midComponent (the certify?/refine1 fixture), refineAtom?/refinedAtom? (the refineTo?/sameRoot fixtures), the *Checksum/rootsDigest/gridBucket/bucketLe observables, and Hashable instances for ZPoly/DyadicSquare/Component/DyadicRootIsolation routing through the exact-rational observables.

Deviation from the canonical textbook complexity: the declared models are exact-dyadic-operation counts (per the SPEC complexity contract's "O(n²) exact-dyadic operations on B-bit values" phrasing); they do not fold in the working bit-length B = prec + n·log‖p‖∞, which grows with the parameter, so the scientific wall-time verdicts run inconclusive with a positive residual slope on this hardware and are reconciled on scheduled hardware, consistent with the other Phase 4 benches. mahlerPrec is declared O(n) because the seeded family holds ‖p‖∞ ≤ 10 fixed.

Verification on this machine (Lean 4.32.0-rc1): lake build hexroots_bench green; lake exe hexroots_bench list shows all 14 registrations; lake exe hexroots_bench verify passes all 14 in ~0.7 s wallclock (well under the 30 s soft warning and 360 s hard cap); python3 scripts/ci/check_benches_mathlib_free.py passes (no bench reaches Mathlib); compare over the three strategies reports "all functions agree on common params". Spot-checked isolateAll? timings stay under the 20 s per-call cap with no killed rows (58 ms at degree 8, 484 ms at degree 12, 4 s at degree 20; the full ladder runs in ~15 s), so no scientific settings were weakened to fit any budget.

🤖 Prepared with Claude Code

Kim Morrison and others added 3 commits July 11, 2026 17:59
Register the Phase 4 benchmark surface for the certified complex-root
isolation library: the exact Gaussian-dyadic primitives (taylor, the two
atom-witness checks, newtonSquare), mahlerPrec, the refinement primitives
(refine1, certify?), the whole-polynomial drivers (isolateAll? at target 32,
isolate to the separationDepth floor), refineTo?, and the sameRoot identity
test, plus the dual-route atom-certificate compare group (isolate under .nk,
.pellet, .nkThenPellet on a shared integer-root domain, joined on a
strategy-invariant integer-grid projection of the isolation output). Wire the
hexroots_bench exe into lakefile.lean, HEX_EXE_TARGETS, and the Bench verify
step.

Each setup_benchmark declares the textbook exact-dyadic-operation-count model
from the SPEC complexity contract with an adjacent derivation comment; the
declared models are op counts, not wall-time-with-bit-length models, so the
scientific wall-time verdicts and their reconciliation are a scheduled-hardware
concern as for the other Phase 4 benches. mahlerPrec is declared linear in
degree because the seeded family holds the coefficient height fixed, reducing
the O(n log||p||) contract to O(n) over the schedule.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SpYSH4swVcLJbN2Bn6NfSP
The 2^-8 grid put bucket boundaries within reach of non-integer
centres in principle; the compare family's roots are integers and
every certified centre is within its square's radius of a root, so
nearest-integer rounding is robustly strategy-invariant. Found by the
Codex review.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SpYSH4swVcLJbN2Bn6NfSP
scripts/check_phase4.py requires the cost-model derivation comment
adjacent to each setup_benchmark registration: each compare-group
registration now carries its own O(n^3) derivation (n rounds of O(n)
witness checks at O(n) exact-dyadic ops on the fixed-height
linProdPoly family).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SpYSH4swVcLJbN2Bn6NfSP
@kim-em kim-em merged commit b08a66c into main Jul 11, 2026
1 check passed
@kim-em kim-em deleted the hexroots/bench branch July 11, 2026 18:14
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