Repository navigation
feat(univariate): enumerate the polynomials of degree below n - #420
Conversation
`ofFn_mem_degreeLT` and `ofFn_coeff_of_mem_degreeLT` describe how `ofFn` interacts with `degreeLT`. They do not use any serialization API, so this commit moves them from `Univariate/Bytes.lean` to `Univariate/Linear.lean`, which defines `degreeLT`. Their statements, proofs and names do not change. `Univariate/Bytes.lean` imports `Univariate/Linear.lean`, so every module that used the lemmas still sees them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ofFnEquiv n` is the equivalence between the coefficient vectors `Fin n → R` and `↥(degreeLT n)`, through `ofFn` and `coeff`. Over a finite coefficient type, `instFintypeDegreeLT` makes `↥(degreeLT n)` a `Fintype` through this equivalence. The enumeration is executable and needs only `[Zero R] [BEq R] [LawfulBEq R] [Fintype R]`. `card_degreeLT` states that `↥(degreeLT n)` has `card R ^ n` elements, for every `Fintype` instance. The simp lemmas `ofFnEquiv_apply_val` and `ofFnEquiv_symm_apply` characterize the equivalence, whose body stays opaque downstream. Four lemmas in `ToPoly/Degree.lean` restate a quantifier over `↥(degreeLT n)` as a quantifier over Mathlib polynomials of degree below `n`: * `exists_degreeLT_toPoly_iff` * `forall_degreeLT_toPoly_iff` * `forall₂_degreeLT_toPoly_iff` * `exists_degreeLT_toPoly_iff_of_degree_lt` `toPoly` is noncomputable, so these lemmas serve only in proofs. They let a finite search over the enumeration prove a statement about all Mathlib polynomials below a degree bound. ArkLib's exact affine-combiner error evaluators can use them in this way. The test module `CompPolyTests.Univariate.ToPoly.Degree` evaluates the enumeration over `ZMod 5` with `#guard` in compiled code. It checks the counts `5 ^ n`, the single zero polynomial at `n = 0`, and searches for known polynomials. Its examples are kernel-checked theorems. Each one states that a search returns `true` exactly when the corresponding statement about Mathlib polynomials holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR SummaryMathematical FormalizationEnumeration and linear isomorphism. The core addition is the module
Quantifier transport lemmas. The file
These lemmas are intended for proofs only – they allow an executable predicate decided by a search over Refactoring
Documentation
Tests
No Statistics
Lean Declarations ✏️ Removed: 2 declaration(s)
✏️ Added: 20 declaration(s)
📋 **Additional Analysis**The diff is well-structured overall and follows most guidelines. The main issue is a redundant duplicate import block in the new test file. 📄 **Per-File Summaries**
Last updated: 2026-11-19 13:30 UTC. |
Build Timing Report
Incremental Rebuild Signal
Slowest Current Build Files (warm library build)Showing 1 slowest current targets from the warm library build log, with comparison against the baseline warm library build log when available.
|
State the cardinality theorem without equality assumptions and relate the coefficient equivalence to the linear map and vector codec. Check downstream cardinality reduction and scope the prime instance to the linear-factor test.
Move the CompPoly pin from `afb9b13` to `1a9ad0e`, the merge of Verified-zkEVM/CompPoly#420. That commit is the only change between the two revisions. It adds `instFintypeDegreeLT`, an executable enumeration of the polynomials of degree below `n`, to `CompPoly.Univariate.Linear`. It also adds four lemmas to `CompPoly.Univariate.ToPoly.Degree` that restate a quantifier over these polynomials as a quantifier over Mathlib polynomials. The evaluators in `AffineCombiner/Computable.lean` enumerate with `instFintypeDegreeLT`, and the proofs that relate them to the semantic predicates use three of these lemmas. CompPoly at `1a9ad0e` uses Lean v4.36.0 and the same Mathlib revision as ArkLib, so only the CompPoly entries of `lakefile.toml` and `lake-manifest.json` change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1548) * chore(deps): bump CompPoly to 1a9ad0e (Verified-zkEVM/CompPoly#420) Move the CompPoly pin from `afb9b13` to `1a9ad0e`, the merge of Verified-zkEVM/CompPoly#420. That commit is the only change between the two revisions. It adds `instFintypeDegreeLT`, an executable enumeration of the polynomials of degree below `n`, to `CompPoly.Univariate.Linear`. It also adds four lemmas to `CompPoly.Univariate.ToPoly.Degree` that restate a quantifier over these polynomials as a quantifier over Mathlib polynomials. The evaluators in `AffineCombiner/Computable.lean` enumerate with `instFintypeDegreeLT`, and the proofs that relate them to the semantic predicates use three of these lemmas. CompPoly at `1a9ad0e` uses Lean v4.36.0 and the same Mathlib revision as ArkLib, so only the CompPoly entries of `lakefile.toml` and `lake-manifest.json` change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(Probability): compute exact worst-case probabilities of finite event families `ArkLib/Data/Probability/MaxEventProbability.lean` defines `Probability.maxEventProbability`, the exact worst-case probability of a finite family of Boolean events, in `ℚ≥0`. It divides the largest event count in the family by the size of the challenge space. `ofReal_maxEventProbability_eq_iSup` proves that `ENNReal.ofReal` of its real cast is the `ENNReal` supremum of the counting probabilities. `ofReal_maxEventProbability_eq_iSup_of_iff` gives the same supremum for a propositional event that the Boolean event decides. The exact combiner-error evaluators in `AffineCombiner/Computable.lean` count with `maxEventProbability`. The acceptance tests evaluate `maxEventProbability` on a family with known value `3/4`, on an empty family, and on an empty challenge space. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(AffineCombiner): compute the combiner errors as exact rationals `AffineCombiner/Computable.lean` computes the affine, scalar, and equal-degree combiner errors as exact values in `ℚ≥0`: * `ReedSolomon.affineMcaErrorRat` * `ReedSolomon.scalarMcaErrorRat` * `ReedSolomon.equalDegreeMcaErrorRat` Each evaluator enumerates the received word pairs and the challenges, and counts with `Probability.maxEventProbability`. The evaluators search the CompPoly candidates of bounded degree. For a fixed candidate, the `Decidable` instances of `ReedSolomon.Computable.IsAffineExceptional`, `IsScalarExceptional`, and `IsEqualDegreeExceptional` search the witnesses of bounded degree. In the affine and scalar combiners, the candidate `P` and the second witness `G₀` determine the first witness `F₀ = P - L G₀` for the multiplier `L`, so these instances search `G₀` only. The `_iff` theorems identify the three predicates with the semantic predicates. The theorems `ofReal_affineMcaErrorRat`, `ofReal_scalarMcaErrorRat`, and `ofReal_equalDegreeMcaErrorRat` prove that `ENNReal.ofReal` of the real cast of each rational value is the semantic `ENNReal` error. The three proofs share `Probability.ofReal_maxEventProbability_eq_iSup_of_iff`. The module docstring states the cost of the search. Let `q` be the field size, `n` the domain size, and `d` the output degree bound. The affine and scalar evaluators examine up to `q^(2n+2d+3)` combinations of a word pair, a challenge, a candidate, and a witness. The equal-degree evaluator examines up to `q^(2n+3d+4)` combinations, because it searches both witnesses. Charge one unit for each field operation, equality test, natural-number operation, and evaluation of `domain`, as well as for each other primitive step, such as an array access, a list-cell allocation, or a closure call. Suppose the `Fintype` instances list the elements of `F` and `ι` in `O(q)` and `O(n)` steps. In this model, the running time is at most the number of combinations times a factor polynomial in `n` and `d`. Each search builds its whole enumeration before the first test. `Polynomial.degree_lt_succ_iff` in `ArkLib/ToMathlib/Polynomial/DegreeLT.lean` states that a polynomial has degree below `n + 1` exactly when it has degree at most `n`. The correctness proofs use it. It also replaces a private copy in `AffineCombiner/Probability.lean` and an inline proof in `ReedSolomon.lean`. The acceptance tests evaluate all three errors over `ZMod 2` and `ZMod 3`. For each combiner, the cases include degree zero, an empty domain, a threshold above the domain size, and positive loss. The scalar tests compare zero and one point of loss on the same two-point domain. They also check a nonzero error with positive loss on the full ternary domain. Other examples relate the rational values to uniform event probabilities and `mcaError`, and assert the axioms of the three bridges. The module docstrings of `AffineCombiner/Basic.lean` and `AffineCombiner/EqualDegree.lean` refer to the evaluators. The docstrings of `AffineCombiner/Basic.lean` also state the combined word at index `i` as `f i + L(domain i) g i`. They cite Section 1.1 of [CWYZ26] for the affine error. For the scalar error, they cite the definition of `ε_sc` at the start of Section 6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: describe the exact computable combiner errors The CWYZ26 paper page lists `AffineCombiner/Computable.lean` among its related modules and touchpoints. Its representation section names the three evaluators and their bridge theorems. The coding-theory and proximity-error conventions record `ℚ≥0` as the type of an exact computable combiner error. The proximity-error conventions also record how the scalar zero-loss value gives the affine-line `mcaError`. The probability conventions explain how `Probability.maxEventProbability` relates computable values to semantic `ENNReal` probabilities. The repository map lists `MaxEventProbability.lean` with the other finite-probability helpers. The KB page and the proximity-error conventions refer to the module docstring of `AffineCombiner/Computable.lean` for the cost of the search and do not repeat it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
CompPoly has a coefficient equivalence for polynomials of degree below
n. Finite searches also need an executable enumeration and a way to relate their results to Mathlib polynomials.Change
CompPoly.Univariate.LineardefinesofFnEquivfromFin n → Rto↥(degreeLT n). Its inverse isdegreeLTCoeffs, andofCoeffVector_eq_ofFnEquivrelates it to the fixed-width codec. The existingofFn_mem_degreeLTandofFn_coeff_of_mem_degreeLTlemmas move fromBytestoLinear, whichBytesalready imports. Their names and statements stay the same.instFintypeDegreeLTenumerates the subtype from coefficient functions using[Zero R] [BEq R] [LawfulBEq R] [Fintype R]. Atn = 0, the enumeration contains only the zero polynomial.card_degreeLTgives the cardinalityFintype.card R ^ nfor any enumeration of the subtype, using only[Zero R]and the twoFintypeinstances.CompPoly.Univariate.ToPoly.Degreeconnects bounded searches to Mathlib polynomials over[Semiring R] [BEq R] [LawfulBEq R].exists_degreeLT_toPoly_iffandforall_degreeLT_toPoly_ifftransport a single quantifier.forall₂_degreeLT_toPoly_ifftransports two universal quantifiers with separate degree bounds.exists_degreeLT_toPoly_iff_of_degree_ltlets the predicate supply the degree bound.ArkLib's exact combiner error evaluators will use this API in place of their local copy.
Tests and validation
A downstream
by decidetest checks the enumeration size overZMod 2. A second theorem checks that the cardinality agrees across two lawful equality instances. Compiled tests overZMod 5check counts, distinct polynomials, the zero bound, and searches that inspect polynomial values. The bridge examples prove that those decisions agree with the corresponding Mathlib propositions.lake build --wfailandlake test --wfailpass../scripts/lint-style.sh,./scripts/check-imports.sh, and the documentation integrity check pass.lake exe axiomsweep --checkpasses. This PR adds no admissions and leaves the axiom baseline unchanged.