CompPoly aims to be the premier formally verified library for computable polynomial operations over finite fields, serving as the mathematical foundation for zero-knowledge circuit verification. We aim to provide efficient, proven-correct implementations of univariate, multivariate, and multilinear polynomial arithmetic that seamlessly integrate with the Lean 4/Mathlib ecosystem.
- Zero
sorrys in all shipped modules. - Complete core API for
CPolynomial,CMvPolynomial,CMlPolynomial, including evaluation + interpolation + conversions. - ✅ At least one "fast path" implemented + proven correct (FFT/NTT multiplication OR fast multilinear transforms). (radix-2 NTT /
NTTFastunivariate multiplication) - Benchmarks exist for core ops and are reproducible (
lake exe CompPolyBench; CI runs benchmarks and uploads reports).
- Proof ergonomics baseline: common operations (add, mul, eval) mostly simp/grind-driven, documented.
- At least one real integration example (ArkLib or RT extraction exemplar) demonstrating use as a dependency.
- Minimal docs: README + module docs sufficient for contributors.
- CI stability: all tests pass consistently.
Goal: Establish complete mathematical foundations and close critical gaps.
-
Theoretical completeness
- ✅ Implement
nodalandinterpolatefor Lagrange interpolation - ✅ Implement
AddCommGroup/Semiring/CommSemiring/Ring/CommRinginstances forCPolynomialandQuotientCPolynomial - ✅ Prove isomorphism between
CPolynomialand Mathlib'sPolynomial(ringEquivinUnivariate/ToPoly.lean); prove forQuotientCPolynomialas needed - ✅ Prove
CommSemiringforCMvPolynomialandpolyRingEquiv(ring isomorphism with Mathlib'sMvPolynomial (Fin n) R) - ✅ Complete remaining algebraic structures (
CommRing,Algebra, scalar action /SMulZeroClass)
- ✅ Implement
-
API completeness
- ✅ Add
monomialconstructors for univariate and multivariate polynomials - ✅ Implement monomial-order baseline (
MonomialOrder.degree,leadingMonomial,leadingCoeff,leadingTerm) - ✅
degreeLT,degreeLE: Bounded-degree submodules for univariate polynomials - ✅
mem_degreeLT,mem_degreeLE: Membership characterizations for bounded-degree polynomials - ✅
degreeLTEquiv: Linear equivalence for coefficient access - ✅
restrictDegree: Degree restrictions for multilinear extensions - ✅
vars: Variable set extraction - ✅
aeval,bind₁: Algebra evaluation and substitution - ✅
algebra,module: Algebra and module structures - ✅
degrees; ✅eval₂Hom: Degree utilities and evaluation homomorphisms - ✅
finSuccEquiv: Variable manipulation equivalences (forCMvPolynomial) - ✅
partialEvalFirst: Partial evaluation fixing the first variable, with its evaluation and per-variable degree-bound lemmas - ✅
isEmptyRingEquivforCMvPolynomial 0 R - ✅
smulZeroClass: Scalar multiplication with zero behavior - ✅
sumToIter: Iteration utility with reconstruction/API lemmas - ✅ Implement
rename/renameEquivfor variable renaming
- ✅ Add
-
Further data types
- ✅ Basic field definitions (currently in Arklib) ported into CompPoly (e.g. BabyBear, Goldilocks, BN254, BLS12_381, binary tower)
- ✅ computable field extensions with interface (
CompPoly/Fields/Extension/):F[X]/ffor an arbitrary monicfwithCommRing/Field,Algebra F (Ext P)(henceModule), a base embeddingofBase, the adjoined rootgenwithaeval gen poly = 0, a ring equivalence toAdjoinRoot, and cardinalityq ^ d. BinomialsX^d - Ware the special case viaBinomialParams.toExtensionParams, keepinggen ^ d = ofBase W. Irreducibility comes from a general Rabin criterion (CompPoly/Data/Polynomial/Rabin.lean), collapsed to two base-field exponentiations for binomials and discharged by kernel-checked certificates otherwise (CompPoly/Data/Polynomial/RabinCertificate.lean, generated byscripts/gen_rabin_certificate.py), at prime and composite degree — one coprimality certificate per prime factor ofd. Concrete instances: degree-4 over BabyBear, KoalaBear, and Hachi (2^32 - 99); non-binomial degree-5 (X^5 + X^2 - 1) and degree-6 (X^6 + X^3 + 1 = Φ₉, ~2^186) over KoalaBear, the latter identified with Mathlib'sGaloisFieldinKoalaBear/Ext6/GaloisField.lean.- Tower support (
AlgebraTower) is the main interface gap:F ⊂ Ext F 2 ⊂ Ext F 4does not yet compose. The blocker is notExtensionParams— it is generic over[Field F] [Fintype F], andExt Psupplies both, so a two-level type is well-formed today — but dischargingFact (Irreducible P'.poly)over anExtbase:reduce_mod_charneeds the base asZMod <numeral>and the certificate layer is built ontoPoly : List ℕ → (ZMod p)[X]. Withnative_decideforbidden this needs a certificate layer over a non-prime base - 🔄 Performance: after routing compilation through the
Ext.redreduction table (mul_eq_mulTbl,@[csimp]),mulmeasures ~25us at degree 4 and ~64us at degree 6, withinv~3.5ms and ~15ms (lake exe CompPolyBench --small) — a 3-8x gain over the specification, growing withdas theO(d^5)→O(d^3)change predicts. Still far off a native implementation. In priority order: takeExt.mulfromO(d^3)toO(d^2)with an allocation-free array loop (schoolbook convolution to2d - 1folded throughred, withredhoisted so it is built once perPrather than per multiplication); instantiate over theFastFieldMontgomery carrier instead ofZMod; replace Fermat inversion with a norm-based (Itoh–Tsujii) inverse — neitherExt.frobeniusnorExt.normexists yet, andΦ₉was chosen partly because its Frobenius (θ ↦ θ^2) is sparse - Rebase the GHASH Rabin specialization
(
irreducible_of_rabin_128_passed_over_GF2) onto the generalPolynomial.irreducible_of_rabinso the two soundness proofs do not need parallel maintenance - 64-bit-radix Montgomery layer, so
Hachigets aFastFieldbase
- Tower support (
- ✅ computable field extensions with interface (
- ✅ Polynomial-basis
GF(2^64)and its degree-3 extensionGF(2^192)(Fields/Binary/BF64/), a flat quotient by an irreducible degree-64 pentanomial rather than an iterated quadratic tower - ✅ Implement a specialized Bivariate polynomial type, e.g. as
CPolynomial (CPolynomial R)with specialized polynomial operations (that can then be optimized)
- ✅ Basic field definitions (currently in Arklib) ported into CompPoly (e.g. BabyBear, Goldilocks, BN254, BLS12_381, binary tower)
Success Criteria: Zero sorrys in core operations, all ring structures complete, clean build with no warnings, reasonable proof ergonomics.
Goal: Optimize critical operations for production use in ZK verification.
-
Fast field arithmetic
- ✅ Radix-generic Montgomery reduction shared by every fast prime field
(
Fields/Montgomery/Basic.lean) - ✅ Single-word
UInt32Montgomery carrier for 31-bit primes (Montgomery/Native32.lean,Montgomery/Native32Field.lean,Mont32Field), instantiated byBabyBear/Fast.leanandKoalaBear/Fast.lean - ✅ Eight-limb Montgomery carrier with CIOS multiplication for moduli below
2^255(Montgomery/Native64x8*.lean,Mont64x8Field), instantiated byBN254/Fast.lean,BLS12_381/Fast.lean, andBLS12_377/Fast.lean - ✅ Single-word
UInt64carriers for 64-bit and 31-bit primes outside the Montgomery bounds (Goldilocks/Fast.lean,Mersenne31/Fast.lean), reducing via the modulus identity rather than Montgomery residues - ✅ Checked binary-GCD inversion for the eight-limb fields
(
Montgomery/Native64x8Inv.lean, eprint 2020/972), benchmarked againstZModextended Euclid and Fermat infields-mont64x8-*-inv - 🔄 64-bit-radix Montgomery layer, so Goldilocks and Hachi (
2^32 - 99) gain aFastFieldbase;Mont32Fieldrequires modulus <2^31 - 🔄 Instantiate
Extension.Extover a Montgomery carrier rather thanZMod(see the extension performance notes under Phase 1)
- ✅ Radix-generic Montgomery reduction shared by every fast prime field
(
-
Polynomial multiplication
- ✅ Radix-2 NTT domain, forward/inverse transforms, and reference fast multiply (
Univariate/NTT/) - ✅ NTT-based
fastMulImpl/safeFastMul/withFallbackwith full correctness proofs (NTT/FastMul) - ✅ Concrete NTT domains for BabyBear and KoalaBear (
NTT/BabyBear,NTT/KoalaBear) - ✅ Low-product multiplication via NTT (
NTT/FastMulLow) - ✅ Optimized
NTTFastpath: cached twiddle plans, DIF/radix-4 stages, paired forward transforms, refinement proofs vsNTT(Univariate/NTTFast/) - ✅ Pluggable multiply backends for batch algorithms (
BatchEval/Context:MulContext.ntt,MulContext.nttFast) - 🔄 Additional concrete domains and field-specific tuning beyond BabyBear/KoalaBear
- ✅ Radix-2 NTT domain, forward/inverse transforms, and reference fast multiply (
-
Exponentiation optimization
- ✅ Replace repeated multiplication with repeated squaring
- ✅ Reduce complexity from O(n) to O(log n) multiplications
-
Evaluation optimizations
- ✅ Batch evaluation at multiple points: naive, Horner, and subproduct-tree algorithms (
Univariate/BatchEval/) - ✅ Subproduct-tree batch eval with configurable multiply/remainder backends (naive, NTT, NTTFast)
- ✅ Add Horner's method where beneficial
- ✅ Many-polynomial, one-shared-point evaluation — the common commitment-opening
shape — with correctness proofs (
Univariate/ManyEval/,Multilinear/ManyEval/) - 🔄 Optimize for further common ZK evaluation patterns
- ✅ Batch evaluation at multiple points: naive, Horner, and subproduct-tree algorithms (
-
Complete multilinear transform functions
- ✅ Complete documentation of zeta/Möbius transform formulas
- ✅ Prove equivalence between fast and spec implementations
- 🔄 Add performance guarantees and complexity proofs (done in comments, formal benchmarking still TODO)
-
Benchmarking
- ✅ Basic, reproducible evaluation benchmark executable (
lake exe CompPolyBench; seebench/README.md) - ✅ CI build/run with artifact upload (GitHub Actions
lean_action_ci.yml) - 🔄 Expand regression coverage and published performance baselines
- ✅ Basic, reproducible evaluation benchmark executable (
-
Bivariate polynomial operations
- ✅ Optimize the existing bivariate polynomial type
CPolynomial (CPolynomial R): Kronecker substitution (Bivariate/Kronecker.lean) turns a bivariate multiplication into a single univariate one (kroneckerPack_mul,kroneckerUnpack_mul), with linear-timekroneckerPackFast/kroneckerUnpackFastproved equal to the spec versions and NTT-backedkroneckerUnpack_withFallback. Benchmarked asbivariate-full-*. The nested representation was kept; no more specialized one proved necessary. - 🔄 Efficient factorization algorithms for bivariate polynomials. What exists
is linear-factor deflation rather than general factorization:
Bivariate/Factor.leandefinesdivByLinearY(the computable factor theorem, over anyCommRing) andBivariate/FactorMonic.leanprovesdivByLinearY_eq_divByMonic, tying it to general monic Euclidean division. Benchmarked asbivariate-deflate-*. - ✅ Integration with existing
CMvPolynomial 2 Rwith equivalence proofs
- ✅ Optimize the existing bivariate polynomial type
-
Error-correcting interpolation algorithms
- ✅ Reed-Solomon encoding through the forward NTT
(
Univariate/ReedSolomon/NTTEncode.lean):forwardImpl_eq_encodeandnttCodeword_eq_encodeidentify theO(n log n)transform withReedSolomon.encodeexactly, with no padding required - ✅ Unique decoding via Gao's key-equation decoder
(
ReedSolomon/GaoDecoder.lean, [Gao02]) withGaoCorrectness.lean:decode_sound,decode_eq_some,decode_eq_none_iff, anddecode_none_farness, which reads decoder refusal as a farness certificate - ✅ Implement Guruswami-Sudan list-decoding algorithm
(
Bivariate/GuruswamiSudan/), following the interpolation-and-root-finding decomposition of [GS99]: a backend-parametricCore/Contextwith dense, Lee-O'Sullivan ([LOS06]), approximant-basis (PM-Basis), and hybrid interpolation, plus Roth-Ruckenstein ([RR00]) and Alekhnovich ([Ale05]) root search, instantiated inImplementationsandExecutable - ✅ Proofs of correctness:
gsCore_sound,gsCore_complete_of_interpolate, andgsCore_complete_of_roots_all_valid_witnessesinCoreCorrectness.lean, stated against the context contracts so they hold for every backend - Berlekamp-Welch decoding. Gao's decoder already covers the same unique-decoding regime, so this is worth adding only as a cross-check, or if a downstream specification asks for it by name.
- Integration with FRI commitments and polynomial commitment schemes
- ✅ Reed-Solomon encoding through the forward NTT
(
-
Univariate root finding
- ✅ Backend-parametric root pipeline (
Univariate/Roots/): theBackend,Context, andSplitterinterfaces, candidate extraction / validation / deduplication (Extraction.lean),RootProduct.lean, andCorrectness.lean - ✅ Smooth multiplicative-subgroup refinement splitting for finite fields whose
multiplicative group admits a smooth schedule ([MOV92],
Roots/SmoothSubgroup/), benchmarked asunivariate-roots-finite-field-* - ✅ Shoup-style small-characteristic trace splitting ([vzGS92],
Roots/Shoup/) and bounded Las Vegas Cantor–Zassenhaus (Roots/LasVegas/, odd-char and char-2 trace branches with probability proofs) for fields without a smooth refinement schedule - 🔄 Named high-width binary-tower
SmallPrimeTraceContextinstances (32/64) and optional GF(2^{48})/GF(2^{72}) carriers for production char-2 benches
- ✅ Backend-parametric root pipeline (
-
Computable linear algebra
- ✅ Dense row-major matrices with row operations, RREF shape and semantics, and
kernel extraction, each with a
*Correctness.leancompanion (LinearAlgebra/Dense/) - ✅ In-place kernel solver (
Dense/KernelInPlace.lean) with correctness, used by the dense Guruswami-Sudan interpolation backend - ✅ Polynomial matrices with shifted degrees and row spans, plus
Mulders-Storjohann shifted row reduction ([MS03],
LinearAlgebra/PolynomialMatrix/). The fast variants are proved extensionally equal to the direct ones inMuldersStorjohannCorrectness/Fast.lean, so every correctness result transfers. - ✅ Order-basis (approximant) layer over polynomial matrices
(
PolynomialMatrix/Approximant/): modular key equations, the divide-and-conquer PM-Basis recursion with X-adic soundness and kernel-leaf completeness, and partial linearization, alongside supporting row selection, minimal weak-Popov forms, and Strassen multiplication used by the recursion.
- ✅ Dense row-major matrices with row operations, RREF shape and semantics, and
kernel extraction, each with a
Success Criteria: notable speedup for large polynomial operations, verified correctness, benchmarks demonstrating competitive performance with industry-standard implementations.
Goal: Turn CompPoly into an integration-ready, downstream-friendly library by adding interoperability layers, serialization, proof automation, and extraction compatibility.
-
Lowering / interop with LLZK / PrimeIR polynomial dialects
- Explore representing CompPoly structures in the MLIR pipeline
- Evaluate tradeoffs: “fast Lean code” vs “Lean spec + lowering to fast backend”
- Goal: enable verification of PrimeIR/LLZK polynomial implementations against CompPoly semantics
-
Serialization (bytes/JSON/protocol/hashing)
- Define serialization format(s) for polynomial types
- Compatibility with ArkLib protocol serialization needs
- Consider: to/from bytes, to/from JSON, canonical encoding for hashing
-
FFT-based interpolation variants (post-FFT/NTT)
- Implement FFT-based Lagrange interpolation when the evaluation domain is an FFT/NTT-friendly subgroup
- Add fast barycentric interpolation for repeated interpolation queries over a fixed set of nodes
- Provide
interpolateFFT/interpolateNTTAPIs that reuse precomputed twiddle factors and domain metadata - Prove equivalence to the spec (naive)
interpolateimplementation and document complexity (O(n log n)) - Include edge-case handling: non-power-of-two domains, zero-padding strategies, and domain mismatch errors
-
Proof ergonomics: simp/grind sets + tactics
- Identify rewrite bottlenecks when porting Mathlib poly proofs → CompPoly
- Build simp sets and grind sets for common operations
- Goal: “one-liner conversions” (or near) between spec polynomials and computable polynomials
-
Integration with ArkLib / Hax + Rust libraries (e.g. plonky3)
- Make CompPoly the canonical polynomial backend for ArkLib specs where applicable
- Add bridging lemmas and conversion utilities across representations (CompPoly ↔ Mathlib ↔ extracted Rust ↔ downstream libs)
- Document and implement invariants required for robust interop (canonical ordering, normalization, domain metadata)
- Ensure hax-extracted Rust polynomial structures can be mapped into CompPoly with minimal proof overhead
- Validate the integration with at least one downstream example (e.g. ArkLib protocol component or plonky3 polynomial routine)
Success criteria: CompPoly is integration-ready—it supports canonical serialization, has strong simp/grind-based proof ergonomics, includes a validated interop pathway with LLZK/PrimeIR-style representations, and demonstrates at least one end-to-end Rust extraction → Lean translation → refinement proof against CompPoly.
Goal: Ensure seamless integration, excellent developer experience, and production readiness.
-
Documentation & examples
- Comprehensive module-level documentation
- Usage examples for common ZK verification patterns
- Performance characteristics guide
- Best practices documentation
-
Performance benchmarking suite
- Property-based tests/proofs of correctness for all operations
- Performance benchmarks and regression tests
- Edge case coverage
-
Integration with ArkLib and other libraries
- Ensure all equivalences are proven and documented
- Add conversion utilities and compatibility layers
- Seamless integration with Verified-zkEVM ecosystem
-
Developer experience & community
- Consistent API design patterns
- Helpful error messages
- Type aliases for common use cases
- Advanced optimizations based on usage patterns
- Community feedback and refinements
Success Criteria: Excellent documentation, comprehensive test coverage, smooth integration with Arklib, active community adoption, etc.
- Mathematical completeness: Zero
sorrys in core operations, all ring structures proven, formal verification of correctness properties - Performance: Competitive with unverified implementations for large polynomials (target: within 2x of optimized C/Rust implementations for degree ≥ 10⁴)
- API completeness: Full feature parity with Mathlib's
PolynomialandMvPolynomialAPIs, plus ZK-specific extensions - Usability: Complete documentation with examples, clear integration guides, beginner-friendly tutorials
- Adoption: Seamless integration with Verified-zkEVM ecosystem, adoption by ZK protocol implementations, community contributions
- Research impact: Foundation for formally verified ZK systems, potential for academic publications on verified polynomial arithmetic
Last updated: August 2026