Repository navigation
feat(ToMathlib): Lagrange interpolation on a coset of the roots of unity - #403
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR Summary
To be concise, the overview should present the formalization in terms of the new file and its theorems. No headers beyond what are relevant, but the mathematical content is central. Statistics
Lean Declarations ✏️ Added: 6 declaration(s)
📄 **Per-File Summaries**
Last updated: 2026-10-26 13:31 UTC. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
welcome to CompPoly @tcoratger ! :) |
dhsorens
left a comment
There was a problem hiding this comment.
Thanks, this is a useful result to have in one place, and the periodic folding is a nice general statement. The maths reads correctly to me.
A few changes are inline. The main one is the hypothesis on p in interpolate_coset_periodic.
Note that CI hasn't run on this yet: workflows on a first PR need a maintainer to approve them.
| theorem interpolate_coset_periodic {s ω : F} {p m : ℕ} (hω : IsPrimitiveRoot ω (p * m)) | ||
| (hs : s ≠ 0) (hm : 0 < m) (g : Fin p → F) : | ||
| interpolate univ (cosetPoints s ω (p * m)) (fun i => g ⟨i % p, Nat.mod_lt _ (by | ||
| rcases Nat.eq_zero_or_pos p with rfl | hp |
There was a problem hiding this comment.
Building the proof of 0 < p inside the statement makes this hard to read and awkward to apply. Could you take (hp : 0 < p) (or [NeZero p]) as a hypothesis and write ⟨i % p, Nat.mod_lt _ hp⟩? The p = 0 case is vacuous anyway, so this also removes the rcases on line 105.
| variable {F : Type*} [Field F] | ||
|
|
||
| /-- The points `s omega^i` of the coset `s mu_n`. -/ | ||
| def cosetPoints (s ω : F) (n : ℕ) : Fin n → F := fun i => s * ω ^ (i : ℕ) |
There was a problem hiding this comment.
These all land in namespace Polynomial (Polynomial.cosetPoints, Polynomial.nodal_coset, ...). Names that generic could collide with Mathlib later. Could they go under a more specific namespace, or get names that say "roots of unity"?
| rcases eq_or_ne Q 0 with h | h | ||
| · rw [h]; simpa using hp | ||
| · exact (natDegree_lt_iff_degree_lt h).mpr hQ | ||
| nlinarith |
There was a problem hiding this comment.
This is Q.natDegree * m < p * m from Q.natDegree < p and 0 < m, so Nat.mul_lt_mul_of_pos_right (or similar) closes it directly without nlinarith.
| nodal univ (cosetPoints s ω n) = X ^ n - C (s ^ n) := by | ||
| rw [X_pow_sub_C_eq_prod hω hn rfl, nodal_eq, | ||
| ← Fin.prod_univ_eq_prod_range (fun i => X - C (ω ^ i * s))] | ||
| simp [cosetPoints, mul_comm] |
There was a problem hiding this comment.
Please use simp only [...] here. Same for the bare simp on lines 91 and 106.
- Take `[NeZero p]` in the periodic folding and index with `Fin.ofNat p i`. - Rename the declarations after the roots-of-unity coset: `cosetPoints` -> `rootsOfUnityCoset`, `nodal_coset` -> `nodal_rootsOfUnityCoset`, `nodalWeight_coset`, `eval_basis_coset`, `interpolate_coset_periodic` likewise. - Close the degree bound with `Nat.mul_lt_mul_of_pos_right` instead of `nlinarith`. - Replace the bare `simp` calls with `simp only [...]`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review! All four points are addressed in 305f9e9.
|
|
merging - thanks @tcoratger ! |
lake build CompPoly.ToMathlib.Polynomial.CosetLagrangepasses.update-lib.shandcheck-imports.shpass.What it adds
For a primitive n-th root of unity omega and s != 0, the points x_i = s omega^i form the coset s mu_n.
Why
Plonky3's STARK verifier evaluates periodic columns this way, at O(p) cost instead of O(n).
The Lagrange constants are what its selectors use, unnormalized.
Plonky3-lean proves both against its transcription of p3-commit, for powers of two.
This is the general statement, for any n, staged where every downstream user can reach it.
References
plonky3/commit/src/domain.rs, for the folding.🤖 Generated with Claude Code