Skip to content

feat(sparse-poly): Phase-2 review fixes and the Phase-3 conformance suite - #9399

Merged
kim-em merged 3 commits into
mainfrom
sparse-poly-conformance
Aug 23, 2026
Merged

feat(sparse-poly): Phase-2 review fixes and the Phase-3 conformance suite#9399
kim-em merged 3 commits into
mainfrom
sparse-poly-conformance

Conversation

@kim-em

@kim-em kim-em commented Aug 22, 2026

Copy link
Copy Markdown
Owner

This PR complete Phases 2 and 3 for hex-sparse-poly. An independent agent session performed the Phase-2 skeptical review (verdict pass-with-gaps) and its four gaps are fixed here: the pow_zero/pow_succ recurrences that fully characterise the binary powering, KernelTests probes for the rest of the SPEC's decide closure (add, mul, ofDense), removal of a vacuous foldl_max_le hypothesis, and the transported-laws placement note recorded for the Phase-4 SPEC write-back; the review token lands at status/hex-sparse-poly.scaffolding-reviewed. Along the way mul's kernel-facing specification now builds the pairwise products through the term Lists (Array.flatMap stalls kernel reduction, and the SPEC requires mul in the decide closure — the value is unchanged), and DecidableEq (ZMod64 p) moves from HexPolyFp to HexModArith, which is what lets the sparse conformance project pin only hex-mod-arith as the SPEC states. Phase 3 lands conformance/HexSparsePoly/Conformance.lean covering every SPEC operation with typical/edge/adversarial cases plus all the SPEC's invariant, round-trip-necessity, and cross-library differential checks; the shared fixtures module; the emit driver with a committed 120-record JSONL snapshot; the sparsepoly fixture schema in the shared emit helper and common.py; the SymPy sparse-ring oracle (51/51 checks green locally); and the ORACLES tuple. Bumps done_through to 3.

🤖 Prepared with Claude Code

@kim-em
kim-em force-pushed the sparse-poly-conformance branch from 05e2159 to acb2bcf Compare August 22, 2026 04:36
@kim-em
kim-em force-pushed the sparse-poly-conformance branch from acb2bcf to dc746be Compare August 22, 2026 05:17
@kim-em
kim-em force-pushed the sparse-poly-conformance branch from dc746be to a7909bd Compare August 23, 2026 12:38
@kim-em
kim-em force-pushed the sparse-poly-conformance branch from a7909bd to 64a496e Compare August 23, 2026 13:05
@kim-em
kim-em force-pushed the sparse-poly-conformance branch from 64a496e to 6dfa24b Compare August 23, 2026 13:28
@kim-em
kim-em force-pushed the sparse-poly-conformance branch from 6dfa24b to 8a54d8f Compare August 23, 2026 13:55
Kim Morrison and others added 2 commits August 23, 2026 14:19
…uite

Independent scaffolding review performed and its four gaps fixed
(pow_zero/pow_succ recurrences, full decide-closure KernelTests
coverage, foldl_max_le cleanup, CommRing placement noted for the
Phase-4 SPEC write-back); mul's kernel-facing specification routed
through the term Lists so it reduces under decide as the SPEC requires;
DecidableEq (ZMod64 p) promoted from HexPolyFp to HexModArith so the
sparse conformance pin list matches the SPEC. Phase 3 lands the core
conformance module with the SPEC's invariant, round-trip-necessity, and
differential cases, the emit driver with a committed JSONL snapshot,
the sparsepoly fixture schema, the SymPy sparse-ring oracle (51/51
green locally), and the run_oracles tuple. done_through: 3.

Progress: progress/20260822T042821Z_sparse-poly-conformance.md

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CvkL7tZHMnLN53fXCAjiq
…om factor-sweep staleness

Cost-model derivations for the bundled bench registrations (the
declared complexity of every setup_benchmark model):

- sparse add: one linear merge of the two term lists, O(t) in the
  common term count and independent of degree (exponents are only
  compared, never iterated), hence the degree-independence check.
- sparse mul (sort route): t^2 pairwise products then a mergeSort of
  the t^2 terms, O(t^2 log t^2) dominates; again degree-independent.
- mul selection: sort route as above; ExtTreeMap accumulation is
  t^2 tree inserts, O(t^2 log t) worst case; Johnson heap merge is
  O(s t log s) with a large constant. All three declared with their
  own models on low- and high-collision inputs.
- crossover: sparse side linear (add) and quadratic-with-sort (mul)
  in t at fixed degree; dense side constant in t at fixed degree, so
  the dense registrations declare constant models.
- evaluation: gap Horner does O(t) coefficient multiplies plus
  binary powering across exponent gaps, O(t log(n/t)) multiplies;
  dense Horner is linear in the degree, constant in t.
- substitution-power: substPow multiplies each stored exponent,
  O(t) and flat in k, the declared constant model in k.
- convert-gcd: linear, not quadratic; the sparse-remainder pair does
  a constant number of bounded-quotient divisions and the generic
  pair divides by a fixed degree-7 divisor, so the dense division
  work is O(n); conversion share registers the O(n) conversions
  alone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CvkL7tZHMnLN53fXCAjiq
@kim-em
kim-em force-pushed the sparse-poly-conformance branch from 8a54d8f to f5ba714 Compare August 23, 2026 14:19
@kim-em
kim-em changed the base branch from sparse-poly-eval to main August 23, 2026 14:20
@kim-em
kim-em enabled auto-merge (squash) August 23, 2026 14:20
@kim-em kim-em closed this Aug 23, 2026
auto-merge was automatically disabled August 23, 2026 14:22

Pull request was closed

@kim-em kim-em reopened this Aug 23, 2026
@kim-em
kim-em enabled auto-merge (squash) August 23, 2026 14:23
With python-flint installed, SymPy's QQ ground type is flint's fmpq,
whose numerator and denominator are fmpz rather than numbers.Rational,
and CPython's Fraction constructor rejects those; convert through int.
Reproduced with sympy 1.14.0 + python-flint and verified green there
and under the nix-shell sympy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014CvkL7tZHMnLN53fXCAjiq
@kim-em
kim-em merged commit 22ed283 into main Aug 23, 2026
1 check passed
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