Skip to content

Commit 421ffdc

Browse files
authored
feat: bump to 4.30.0-rc2 (#221)
* feat: bump to 4.30.0-rc2 * feat: update roadmap
1 parent 0b05999 commit 421ffdc

13 files changed

Lines changed: 65 additions & 41 deletions

File tree

CompPoly/Data/List/Lemmas.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ theorem append_getLast_dropLast {α : Type u} (l : List α) (h : l ≠ []) :
2525
| nil =>
2626
simp [dropLast, getLast]
2727
| cons hd' tl' =>
28-
simp only [dropLast_cons₂, getLast]
28+
simp only [dropLast_cons_cons, getLast]
2929
simp only [cons_append, cons.injEq, true_and]
3030
apply ih
3131

CompPoly/Data/Vector/Basic.lean

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import CompPoly.Data.List.Lemmas
88
import Mathlib.Algebra.BigOperators.Fin
99
import Mathlib.Algebra.Order.Star.Basic
1010
import Mathlib.Algebra.Order.Sub.Basic
11+
import Mathlib.Data.List.Fold
1112
import Mathlib.Data.Matrix.Mul
1213
import Mathlib.Tactic.Ring
1314

@@ -147,8 +148,17 @@ lemma dotProduct_cons [AddCommMonoid R] [Mul R] (a : R) (b : Vector R n) (c : R)
147148
rw [zipWith_cons]
148149
simp_rw [foldl_eq_toList_foldl]
149150
rw [cons_toList_eq_List_cons]
150-
rw [List.foldl_eq_of_comm' (hf:=by exact fun a b c ↦ add_right_comm a b c)]
151-
rw [@AddCommMonoid.add_comm]
151+
have h : ∀ (init : R) (L : List R),
152+
List.foldl (fun x1 x2 => x1 + x2) init L = init + List.foldl (fun x1 x2 => x1 + x2) 0 L := by
153+
intro init L
154+
induction L generalizing init with
155+
| nil => simp
156+
| cons x xs ih =>
157+
show List.foldl _ (init + x) xs = init + List.foldl _ (0 + x) xs
158+
rw [ih (init + x), ih (0 + x), _root_.zero_add, _root_.add_assoc]
159+
rw [List.foldl_cons]
160+
show List.foldl _ (0 + a * c) _ = _
161+
rw [_root_.zero_add, h]
152162

153163
/-- A matrix represented as iterated vectors in row-major order.
154164
`m` is the number of rows, and `n` is the number of columns -/

CompPoly/Fields/Binary/AdditiveNTT/NovelPolynomialBasis.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ lemma degree_Xⱼ (ℓ : ℕ) (h_ℓ : ℓ ≤ r) (j : Fin (2 ^ ℓ)) :
13311331
Nat.cast_pow, Nat.cast_ofNat, CharP.cast_eq_zero, hF₂.out]
13321332
-- ⊢ ↑(↑j >>> ↑i % 2) * 2 ^ ↑i = if ↑j >>> ↑i % 2 = 1 then 2 ^ ↑i else 0
13331333
by_cases h: (j.val >>> i.val) % 2 = 1
1334-
· simp only [h, Nat.cast_one, one_mul, ↓reduceIte]; rfl
1334+
· simp only [h, Nat.cast_one, one_mul, ↓reduceIte]
13351335
· simp only [h, if_false];
13361336
have h_0: (j.val >>> i.val) % 2 = 0 := by
13371337
exact Nat.mod_two_ne_one.mp h

CompPoly/Fields/Binary/BF128Ghash/Basic.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ def root : BF128Ghash := AdjoinRoot.root ghashPoly
189189
theorem root_satisfies_poly : root^128 + root^7 + root^2 + root + 1 = 0 := by
190190
unfold root ghashPoly
191191
have h := AdjoinRoot.eval₂_root ghashPoly
192-
simp only [ghashPoly, eval₂_add, eval₂_X, eval₂_one] at h
192+
unfold ghashPoly at h
193+
simp only [eval₂_add, eval₂_X, eval₂_one] at h
193194
erw [eval₂_pow, eval₂_X, eval₂_pow, eval₂_X, eval₂_pow, eval₂_X] at h
194195
exact h
195196

CompPoly/Fields/Binary/BF128Ghash/Prelude.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ lemma toPoly_one_shiftLeft {w : Nat} (n : Nat) (h : n < w) :
214214

215215
-- Main Proof
216216
lemma ghashPoly_eq_P_val : ghashPoly = toPoly P_val := by
217-
rw [ghashPoly, P_val]
217+
unfold ghashPoly P_val
218218
repeat rw [toPoly_xor]
219219
rw [toPoly_one_shiftLeft (h := by omega), toPoly_one_shiftLeft (h := by omega),
220220
toPoly_one_shiftLeft (h := by omega), toPoly_one_shiftLeft (h := by omega)]
@@ -443,7 +443,8 @@ private theorem toPoly_mulByP_Nat (x : B128) :
443443
rw [toPoly_ofNat_shiftLeft_to256 x 2 (by omega)]
444444
rw [toPoly_ofNat_shiftLeft_to256 x 7 (by omega)]
445445
rw [toPoly_ofNat_shiftLeft_to256 x 128 (by omega)]
446-
rw [← ghashPoly_eq_P_val, ghashPoly]
446+
rw [← ghashPoly_eq_P_val]
447+
unfold ghashPoly
447448
ring
448449

449450
/-- Soundness of the kernel-efficient square-step checker. -/

CompPoly/Fields/Binary/Tower/Abstract/Algebra.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ theorem towerAlgebraMap_assoc : ∀ r mid l : ℕ, (h_l_le_mid : l ≤ mid) →
168168
**Formalization of Cross-Level Algebra** : For any `k ≤ τ`, `BTField τ` is an
169169
algebra over `BTField k`.
170170
-/
171-
instance : AlgebraTower (BTField) where
171+
noncomputable instance : AlgebraTower (BTField) where
172172
algebraMap := towerAlgebraMap
173173
commutes' := by
174174
intro i j h r x

CompPoly/Fields/Binary/Tower/Support/LinearIndependentFin2.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ variable {v : ι → V} {s t : Set ι} {x y : V}
2626

2727
theorem linearIndependent_fin2' {f : Fin 2 → V} :
2828
LinearIndependent K f ↔ f 00 ∧ ∀ a : K, a • f 0 ≠ f 1 := by
29-
rw [linearIndependent_fin_succ', linearIndependent_unique_iff, Set.range_unique,
29+
rw [linearIndependent_finSucc', linearIndependent_unique_iff, Set.range_unique,
3030
Submodule.mem_span_singleton,
3131
not_exists]
3232
rw [show Fin.init f default = f 0 by rfl]

CompPoly/Multivariate/MvPolyEquiv/Instances.lean

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ lemma map_one : fromCMvPolynomial (1 : CMvPolynomial n R) = 1 := by
123123
· have finsupp_m_eq_one : CMvMonomial.ofFinsupp m = CMvMonomial.zero := by
124124
rw [g']
125125
unfold CMvMonomial.ofFinsupp CMvMonomial.zero
126-
ext i h
127-
simp only [Nat.zero_eq, Finsupp.coe_mk]
128-
grind
126+
ext i hi
127+
show (Vector.ofFn (⇑(0 : Fin n →₀ ℕ)))[i] = (Vector.replicate n 0)[i]
128+
simp only [Finsupp.coe_zero, Pi.zero_apply, Vector.getElem_ofFn, Vector.getElem_replicate]
129129
rw [finsupp_m_eq_one]
130130
have one_one_get₁ :
131131
({(CMvMonomial.zero, 1)} : Unlawful n R)[(@CMvMonomial.zero n)]?.getD 0 = One.one := by
@@ -387,7 +387,9 @@ lemma fromCMvPolynomial_C (r : R) :
387387
unfold C Lawful.C coeff Unlawful.C MonoR.C
388388
simp only [hr, ite_false]
389389
have ofFinsupp_zero : CMvMonomial.ofFinsupp (0 : Fin n →₀ ℕ) = CMvMonomial.zero := by
390-
unfold CMvMonomial.ofFinsupp CMvMonomial.zero; ext i hi; grind
390+
unfold CMvMonomial.ofFinsupp CMvMonomial.zero; ext i hi
391+
show (Vector.ofFn (⇑(0 : Fin n →₀ ℕ)))[i] = (Vector.replicate n 0)[i]
392+
simp only [Finsupp.coe_zero, Pi.zero_apply, Vector.getElem_ofFn, Vector.getElem_replicate]
391393
by_cases hm : (0 : Fin n →₀ ℕ) = m
392394
· subst hm; rw [if_pos rfl]
393395
erw [ExtTreeMap.getElem?_ofList_of_mem

CompPoly/Univariate/Raw/Proofs.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ theorem double_sum_eq [LawfulBEq R] (p q r : CPolynomial.Raw R) (n : ℕ) :
323323
= ∑ i ∈ Finset.range (n + 1),
324324
∑ j ∈ Finset.Ico i (n + 1),
325325
p.coeff i * q.coeff (j - i) * r.coeff (n - j) := by
326-
rw [ Finset.range_eq_Ico, Finset.sum_Ico_Ico_comm ]
326+
simp_rw [Finset.range_eq_Ico]
327+
rw [Finset.sum_Ico_Ico_comm]
327328
convert h_interchange using 2
328329
rw [ Finset.sum_Ico_eq_sum_range ]
329330
simp +decide [ Nat.sub_add_comm ( Finset.mem_range_succ_iff.mp ‹_› ) ]

ROADMAP.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ CompPoly aims to be the premier formally verified library for computable polynom
88

99
1. Zero `sorry`s in all shipped modules.
1010
1. Complete core API for `CPolynomial`, `CMvPolynomial`, `CMlPolynomial`, including evaluation + interpolation + conversions.
11-
1. At least one "fast path" implemented + proven correct (FFT/NTT multiplication OR fast multilinear transforms).
12-
<!-- 1. Benchmarks exist for core ops and are reproducible (CI integration optional for v1.0). -->
11+
1. At least one "fast path" implemented + proven correct (FFT/NTT multiplication OR fast multilinear transforms). *(radix-2 NTT / `NTTFast` univariate multiplication)*
12+
1. Benchmarks exist for core ops and are reproducible (`lake exe CompPolyBench`; CI runs benchmarks and uploads reports).
1313
<!-- 1. Property tests exist for core ops (eval, mul, interpolation). -->
1414
1. Proof ergonomics baseline: common operations (add, mul, eval) mostly simp/grind-driven, documented.
1515
1. At least one real integration example (ArkLib or RT extraction exemplar) demonstrating use as a dependency.
@@ -66,18 +66,21 @@ CompPoly aims to be the premier formally verified library for computable polynom
6666
- Optimized implementations of off-the-shelf available Field instances to enable performance, including for prime and other finite fields
6767

6868
2. **Polynomial multiplication**
69-
- Implement FFT/NTT-based multiplication (O(n log n) vs current O(n²))
70-
- Focus on NTT for finite field arithmetic
71-
- Maintain correctness proofs alongside optimizations
72-
73-
**Note**: [erdkocak](https://github.com/erdkocak) and [doran2728](https://github.com/doran2728) have communicated they will be working on this.
69+
- ✅ Radix-2 NTT domain, forward/inverse transforms, and reference fast multiply (`Univariate/NTT/`)
70+
- ✅ NTT-based `fastMulImpl` / `safeFastMul` / `withFallback` with full correctness proofs (`NTT/FastMul`)
71+
- ✅ Concrete NTT domains for BabyBear and KoalaBear (`NTT/BabyBear`, `NTT/KoalaBear`)
72+
- ✅ Low-product multiplication via NTT (`NTT/FastMulLow`)
73+
- ✅ Optimized `NTTFast` path: cached twiddle plans, DIF/radix-4 stages, paired forward transforms, refinement proofs vs `NTT` (`Univariate/NTTFast/`)
74+
- ✅ Pluggable multiply backends for batch algorithms (`BatchEval/Context`: `MulContext.ntt`, `MulContext.nttFast`)
75+
- 🔄 Additional concrete domains and field-specific tuning beyond BabyBear/KoalaBear
7476

7577
3. **Exponentiation optimization**
7678
- ✅ Replace repeated multiplication with repeated squaring
7779
- ✅ Reduce complexity from O(n) to O(log n) multiplications
7880

7981
4. **Evaluation optimizations**
80-
- Implement batch evaluation at multiple points
82+
- ✅ Batch evaluation at multiple points: naive, Horner, and subproduct-tree algorithms (`Univariate/BatchEval/`)
83+
- ✅ Subproduct-tree batch eval with configurable multiply/remainder backends (naive, NTT, NTTFast)
8184
- ✅ Add Horner's method where beneficial
8285
- Optimize for common ZK evaluation patterns
8386

@@ -86,7 +89,12 @@ CompPoly aims to be the premier formally verified library for computable polynom
8689
- ✅ Prove equivalence between fast and spec implementations
8790
- 🔄 Add performance guarantees and complexity proofs (done in comments, formal benchmarking still TODO)
8891

89-
6. **Bivariate polynomial operations**
92+
6. **Benchmarking**
93+
- ✅ Basic, reproducible evaluation benchmark executable (`lake exe CompPolyBench`; see `bench/README.md`)
94+
- ✅ CI build/run with artifact upload (GitHub Actions `lean_action_ci.yml`)
95+
- 🔄 Expand regression coverage and published performance baselines
96+
97+
7. **Bivariate polynomial operations**
9098
- Optimize the existing bivariate polynomial type `CPolynomial (CPolynomial R)` and evaluate whether a more specialized representation is beneficial
9199
- Efficient factorization algorithms for bivariate polynomials
92100
- Integration with existing `CMvPolynomial 2 R` with equivalence proofs

0 commit comments

Comments
 (0)