Documentation

CslibFrontier.Crypto.Protocols.FRI.Folding

Reed–Solomon Coset Folding for FRI #

This module formalizes the multiplicative-coset domain hierarchy and Reed–Solomon folding operator underlying the Fast Reed–Solomon Interactive Oracle Proof of Proximity (FRI) [BSBHR18] and its proximity-gap soundness analysis [BSCI+23].

Given a multiplicative coset L = {g * ω ^ i | i : Fin (a * N)} generated by a primitive (a * N)-th root of unity ω and nonzero offset g in a field F with (a : F) ≠ 0, any word f : Fin (a * N) → F decomposes fiberwise via the a-point inverse discrete Fourier transform into a component words foldComp g ω f r : Fin N → F (r : Fin a) on the powered coset L ^ a = {g ^ a * (ω ^ a) ^ j | j : Fin N}. Folding f with a verifier challenge z : F forms the parameterized curve foldWord g ω f z = ∑ r, z ^ r • foldComp g ω f r.

For a = 2 (assuming (2 : F) ≠ 0), this reduces to the closed-form 2-to-1 FRI folding operator fold2 g ω f z = fold2Even g ω f + z • fold2Odd g ω f, linking Reed–Solomon folding directly to affine lines and parameterized curves for correlated-agreement proximity gaps.

Main definitions #

Main results #

References #

def Cslib.Crypto.Protocols.FRI.cosetPoint {F : Type u_1} [Field F] (g ω : F) (n : ℕ) :
Fin n → F

Evaluation points j ↦ g * ω ^ j of a multiplicative coset of size n.

def Cslib.Crypto.Protocols.FRI.cosetEval {F : Type u_1} [Field F] (g ω : F) (d i : ℕ) :
Fin (2 ^ (d - i)) → F

Round-i evaluation domain of the 2-to-1 FRI coset hierarchy starting from g * ⟨ω⟩ of size 2 ^ d: at round i, the domain has size 2 ^ (d - i) and maps j ↦ g^(2^i) * (ω^(2^i))^j.

theorem Cslib.Crypto.Protocols.FRI.cosetPoint_ne_zero {F : Type u_1} [Field F] {g ω : F} {n : ℕ} (hg : g ≠ 0) (hω : IsPrimitiveRoot ω n) (hn : n ≠ 0) (j : Fin n) :
cosetPoint g ω n j ≠ 0

Every point of a coset with nonzero offset and primitive n-th root of unity is nonzero.

theorem Cslib.Crypto.Protocols.FRI.cosetPoint_injective {F : Type u_1} [Field F] {g ω : F} {n : ℕ} (hg : g ≠ 0) (hω : IsPrimitiveRoot ω n) :

Distinct indices yield distinct evaluation points on a coset generated by a primitive n-th root of unity with nonzero offset.

theorem Cslib.Crypto.Protocols.FRI.cosetPoint_pow_eq {F : Type u_1} [Field F] (g ω : F) {a N : ℕ} (hN : 0 < N) (hω : IsPrimitiveRoot ω (a * N)) (j : Fin (a * N)) :
cosetPoint g ω (a * N) j ^ a = cosetPoint (g ^ a) (ω ^ a) N ⟨↑j % N, ⋯⟩

Raising a coset point of size a * N to the a-th power lands in the powered coset of size N at index j % N.

def Cslib.Crypto.Protocols.FRI.fiberIdx {a N : ℕ} (j : Fin N) (t : Fin a) :
Fin (a * N)

Fiber index (j, t) ↦ j + t * N inside Fin (a * N).

theorem Cslib.Crypto.Protocols.FRI.cosetPoint_fiberIdx {F : Type u_1} [Field F] (g ω : F) {a N : ℕ} (ha : 0 < a) (j : Fin N) (t : Fin a) :
cosetPoint g ω (a * N) (fiberIdx j t) = cosetPoint g ω (a * N) ⟨↑j, ⋯⟩ * (ω ^ N) ^ ↑t

The a-element fiber over j : Fin N consists of (cosetPoint g ω (a * N) ⟨j, _⟩) * (ω^N)^t.

theorem Cslib.Crypto.Protocols.FRI.isPrimitiveRoot_pow_two_pow {F : Type u_1} [Field F] {ω : F} {d i : ℕ} (hω : IsPrimitiveRoot ω (2 ^ d)) (hi : i ≤ d) :
IsPrimitiveRoot (ω ^ 2 ^ i) (2 ^ (d - i))

Squaring a primitive 2 ^ d-th root of unity i times produces a primitive 2 ^ (d - i)-th root of unity.

theorem Cslib.Crypto.Protocols.FRI.cosetEval_injective {F : Type u_1} [Field F] {g ω : F} {d i : ℕ} (hg : g ≠ 0) (hω : IsPrimitiveRoot ω (2 ^ d)) (hi : i ≤ d) :

Each level i ≤ d of the FRI coset hierarchy has distinct evaluation points.

theorem Cslib.Crypto.Protocols.FRI.cosetEval_ne_zero {F : Type u_1} [Field F] {g ω : F} {d i : ℕ} (hg : g ≠ 0) (hω : IsPrimitiveRoot ω (2 ^ d)) (hi : i ≤ d) (j : Fin (2 ^ (d - i))) :
cosetEval g ω d i j ≠ 0

Every point at level i ≤ d of the FRI coset hierarchy is nonzero.

theorem Cslib.Crypto.Protocols.FRI.cosetEval_pow_two_pow {F : Type u_1} [Field F] {g ω : F} {d i s : ℕ} (hω : IsPrimitiveRoot ω (2 ^ d)) (his : i + s ≤ d) (j : Fin (2 ^ (d - i))) :
cosetEval g ω d i j ^ 2 ^ s = cosetEval g ω d (i + s) ⟨↑j % 2 ^ (d - (i + s)), ⋯⟩

Raising a level-i coset point to the (2 ^ s)-th power maps onto level i + s.

theorem Cslib.Crypto.Protocols.FRI.cosetEval_sq {F : Type u_1} [Field F] {g ω : F} {d i : ℕ} (hω : IsPrimitiveRoot ω (2 ^ d)) (hi : i < d) (j : Fin (2 ^ (d - i))) :
cosetEval g ω d i j ^ 2 = cosetEval g ω d (i + 1) ⟨↑j % 2 ^ (d - (i + 1)), ⋯⟩

Squaring maps level i of the FRI coset hierarchy onto level i + 1.

theorem Cslib.Crypto.Protocols.FRI.cosetEval_add_half {F : Type u_1} [Field F] {g ω : F} {d i : ℕ} (hω : IsPrimitiveRoot ω (2 ^ d)) (hi : i < d) (j : Fin (2 ^ (d - (i + 1)))) :
cosetEval g ω d i ⟨↑j + 2 ^ (d - (i + 1)), ⋯⟩ = -cosetEval g ω d i ⟨↑j, ⋯⟩

Shifting an index in level i < d by half the domain size negates its coset point.

noncomputable def Cslib.Crypto.Protocols.FRI.polyComp {F : Type u_1} [Field F] (a : ℕ) (p : Polynomial F) (r : Fin a) :

The r-th residue component of p : F[X] modulo a: its t-th coefficient is p.coeff (a * t + r).

theorem Cslib.Crypto.Protocols.FRI.coeff_polyComp {F : Type u_1} [Field F] {a : ℕ} (ha : 0 < a) (p : Polynomial F) (r : Fin a) (t : ℕ) :
(polyComp a p r).coeff t = p.coeff (a * t + ↑r)
theorem Cslib.Crypto.Protocols.FRI.degree_polyComp_lt {F : Type u_1} [Field F] {a k : ℕ} (ha : 0 < a) {p : Polynomial F} (hp : p.degree < ↑(a * k)) (r : Fin a) :
(polyComp a p r).degree < ↑k

If deg(p) < a * k, each a-way component polyComp a p r has degree < k.

noncomputable def Cslib.Crypto.Protocols.FRI.reconstructPoly {F : Type u_1} [Field F] (a : ℕ) (ps : Fin a → Polynomial F) :

Reconstruct a polynomial from its a residue components via ∑ r : Fin a, X ^ r * (ps r).comp (X ^ a).

theorem Cslib.Crypto.Protocols.FRI.eval_reconstructPoly {F : Type u_1} [Field F] (a : ℕ) (ps : Fin a → Polynomial F) (x : F) :
Polynomial.eval x (reconstructPoly a ps) = ∑ r : Fin a, x ^ ↑r * Polynomial.eval (x ^ a) (ps r)
theorem Cslib.Crypto.Protocols.FRI.reconstructPoly_polyComp {F : Type u_1} [Field F] {a : ℕ} (ha : 0 < a) (p : Polynomial F) :

Exact decomposition identity: p = ∑ r : Fin a, X ^ r * (polyComp a p r).comp (X ^ a).

theorem Cslib.Crypto.Protocols.FRI.eval_eq_sum_eval_polyComp {F : Type u_1} [Field F] {a : ℕ} (ha : 0 < a) (p : Polynomial F) (x : F) :
Polynomial.eval x p = ∑ r : Fin a, x ^ ↑r * Polynomial.eval (x ^ a) (polyComp a p r)

Evaluating p at x decomposes as ∑ r : Fin a, x ^ r * (polyComp a p r).eval (x ^ a).

theorem Cslib.Crypto.Protocols.FRI.degree_reconstructPoly_lt {F : Type u_1} [Field F] {a k : ℕ} (ha : 0 < a) {ps : Fin a → Polynomial F} (hps : ∀ (r : Fin a), (ps r).degree < ↑k) :
(reconstructPoly a ps).degree < ↑(a * k)

If every component ps r has degree < k, then reconstructPoly a ps has degree < a * k.

noncomputable def Cslib.Crypto.Protocols.FRI.foldPoly {F : Type u_1} [Field F] (a : ℕ) (p : Polynomial F) (z : F) :

The a-to-1 folded polynomial foldPoly a p z = ∑ r : Fin a, C (z ^ r) * polyComp a p r.

theorem Cslib.Crypto.Protocols.FRI.degree_foldPoly_lt {F : Type u_1} [Field F] {a k : ℕ} (ha : 0 < a) {p : Polynomial F} (hp : p.degree < ↑(a * k)) (z : F) :
(foldPoly a p z).degree < ↑k

Folding preserves the reduced degree bound: deg(p) < a * k implies deg(foldPoly a p z) < k.

theorem Cslib.Crypto.Protocols.FRI.eval_foldPoly {F : Type u_1} [Field F] (a : ℕ) (p : Polynomial F) (z y : F) :
Polynomial.eval y (foldPoly a p z) = ∑ r : Fin a, z ^ ↑r * Polynomial.eval y (polyComp a p r)
def Cslib.Crypto.Protocols.FRI.foldFiberComp {F : Type u_1} [Field F] (g ω : F) {a N : ℕ} (ys : Fin a → F) (r : Fin a) (j : Fin N) :
F

The r-th fiberwise IDFT / interpolation coefficient of a single a-element fiber ys : Fin a → F above target index j : Fin N in the coset g * ⟨ω⟩ of size a * N ([BSCI+23], Section 8.2, printed p. 37: Eq. (8.1) defines the fiber, the paragraph immediately following it defines the interpolation map whose output is this coefficient vector, and Eq. (8.2) evaluates that vector at the challenge powers).

def Cslib.Crypto.Protocols.FRI.foldComp {F : Type u_1} [Field F] (g ω : F) {a N : ℕ} (f : Fin (a * N) → F) (r : Fin a) (j : Fin N) :
F

The r-th fiberwise IDFT component word of f : Fin (a * N) → F on the powered coset g^a * ⟨ω^a⟩ of size N.

def Cslib.Crypto.Protocols.FRI.foldFiber {F : Type u_1} [Field F] (g ω : F) {a N : ℕ} (ys : Fin a → F) (j : Fin N) (z : F) :
F

Local a-to-1 FRI folding formula evaluated on a single a-element fiber ys : Fin a → F above target index j : Fin N in the coset g * ⟨ω⟩ of size a * N with challenge z ([BSCI+23], Section 8.2, Eq. (8.2) on printed p. 37).

def Cslib.Crypto.Protocols.FRI.foldWord {F : Type u_1} [Field F] (g ω : F) {a N : ℕ} (f : Fin (a * N) → F) (z : F) :
Fin N → F

The a-to-1 FRI folding operator applied to a word f : Fin (a * N) → F at challenge z : F: evaluates the parameterized curve ∑ r : Fin a, z ^ r • foldComp g ω f r.

theorem Cslib.Crypto.Protocols.FRI.foldWord_apply_eq_foldFiber {F : Type u_1} [Field F] (g ω : F) {a N : ℕ} (f : Fin (a * N) → F) (z : F) (j : Fin N) :
foldWord g ω f z j = foldFiber g ω (fun (t : Fin a) => f (fiberIdx j t)) j z

foldWord evaluates pointwise via foldFiber on the a-element fiber over j.

theorem Cslib.Crypto.Protocols.FRI.foldWord_eq_sum_smul {F : Type u_1} [Field F] (g ω : F) {a N : ℕ} (f : Fin (a * N) → F) (z : F) :
foldWord g ω f z = ∑ r : Fin a, z ^ ↑r • foldComp g ω f r

foldWord g ω f z is the parameterized curve ∑ r : Fin a, z ^ r • foldComp g ω f r.

theorem Cslib.Crypto.Protocols.FRI.foldComp_eval {F : Type u_1} [Field F] {g ω : F} {a N : ℕ} (hg : g ≠ 0) (ha : ↑a ≠ 0) (hN : 0 < N) (hω : IsPrimitiveRoot ω (a * N)) (p : Polynomial F) (r : Fin a) (j : Fin N) :
foldComp g ω (fun (i : Fin (a * N)) => Polynomial.eval (cosetPoint g ω (a * N) i) p) r j = Polynomial.eval (cosetPoint (g ^ a) (ω ^ a) N j) (polyComp a p r)

foldComp commutes with polynomial evaluation: applying foldComp to the evaluations of p on g * ⟨ω⟩ yields the evaluations of polyComp a p r on g^a * ⟨ω^a⟩.

theorem Cslib.Crypto.Protocols.FRI.foldWord_eval {F : Type u_1} [Field F] {g ω : F} {a N : ℕ} (hg : g ≠ 0) (ha : ↑a ≠ 0) (hN : 0 < N) (hω : IsPrimitiveRoot ω (a * N)) (p : Polynomial F) (z : F) (j : Fin N) :
foldWord g ω (fun (i : Fin (a * N)) => Polynomial.eval (cosetPoint g ω (a * N) i) p) z j = Polynomial.eval (cosetPoint (g ^ a) (ω ^ a) N j) (foldPoly a p z)

foldWord commutes with polynomial evaluation: folding the evaluations of p yields the evaluations of foldPoly a p z on the powered coset.

theorem Cslib.Crypto.Protocols.FRI.foldWord_mem_reedSolomon {F : Type u_1} [Field F] {g ω : F} {a N k : ℕ} (hg : g ≠ 0) (ha : ↑a ≠ 0) (hN : 0 < N) (hω : IsPrimitiveRoot ω (a * N)) {f : Fin (a * N) → F} (hf : f ∈ Code.reedSolomon (cosetPoint g ω (a * N)) (a * k)) (z : F) :
foldWord g ω f z ∈ Code.reedSolomon (cosetPoint (g ^ a) (ω ^ a) N) k

Reed–Solomon closure under folding: folding a codeword of reedSolomon (cosetPoint g ω (a * N)) (a * k) with any scalar z : F produces a codeword of reedSolomon (cosetPoint (g ^ a) (ω ^ a) N) k.

theorem Cslib.Crypto.Protocols.FRI.reconstruct_foldComp {F : Type u_1} [Field F] {g ω : F} {a N : ℕ} (hg : g ≠ 0) (ha : ↑a ≠ 0) (hN : 0 < N) (hω : IsPrimitiveRoot ω (a * N)) (f : Fin (a * N) → F) (j : Fin N) (t : Fin a) :
∑ r : Fin a, cosetPoint g ω (a * N) (fiberIdx j t) ^ ↑r * foldComp g ω f r j = f (fiberIdx j t)

Exact fiberwise reconstruction: any word f : Fin (a * N) → F is recovered pointwise on every fiber from its a IDFT components foldComp g ω f r.

def Cslib.Crypto.Protocols.FRI.pushWeight {a N : ℕ} (W : Fin (a * N) → ℕ) (j : Fin N) :

Push-forward of a coordinate weight function W : Fin (a * N) → ℕ across a-element fibers.

theorem Cslib.Crypto.Protocols.FRI.sum_pushWeight {a N : ℕ} (W : Fin (a * N) → ℕ) :
∑ j : Fin N, pushWeight W j = ∑ i : Fin (a * N), W i

Total weight is preserved by pushWeight: ∑ j, pushWeight W j = ∑ i, W i.

theorem Cslib.Crypto.Protocols.FRI.pushWeight_le {a N M : ℕ} {W : Fin (a * N) → ℕ} (hW : ∀ (i : Fin (a * N)), W i ≤ M) (j : Fin N) :
pushWeight W j ≤ a * M

Pointwise upper bound on pushWeight: if every coordinate has weight ≤ M, then every fiber has pushed-forward weight ≤ a * M.

theorem Cslib.Crypto.Protocols.FRI.exists_mem_reedSolomon_weighted_agree_lift {F : Type u_1} [Field F] {g ω : F} {a N k : ℕ} [DecidableEq F] (hg : g ≠ 0) (ha : ↑a ≠ 0) (hN : 0 < N) (hω : IsPrimitiveRoot ω (a * N)) (f : Fin (a * N) → F) (v : Fin a → Fin N → F) (hv : ∀ (r : Fin a), v r ∈ Code.reedSolomon (cosetPoint (g ^ a) (ω ^ a) N) k) (W : Fin (a * N) → ℕ) :
∃ c ∈ Code.reedSolomon (cosetPoint g ω (a * N)) (a * k), (∀ (j : Fin N), (∀ (r : Fin a), foldComp g ω f r j = v r j) → ∀ (t : Fin a), f (fiberIdx j t) = c (fiberIdx j t)) ∧ ∑ j : Fin N with ∀ (r : Fin a), foldComp g ω f r j = v r j, pushWeight W j ≤ ∑ i : Fin (a * N) with f i = c i, W i

Weighted correlated-agreement lifting across a-to-1 folding: for any word f and component codewords v r ∈ reedSolomon (cosetPoint (g^a) (ω^a) N) k, there exists a codeword c ∈ reedSolomon (cosetPoint g ω (a * N)) (a * k) agreeing with f on every fiber over the simultaneous agreement set {j | ∀ r, foldComp g ω f r j = v r j}, preserving all pushed-forward weights.

def Cslib.Crypto.Protocols.FRI.fold2Fiber {F : Type u_1} [Field F] (yPos yNeg xPos z : F) :
F

Local 2-to-1 FRI folding formula on a single negation pair (yPos, yNeg) at (xPos, -xPos) with folding scalar z.

theorem Cslib.Crypto.Protocols.FRI.fold2Fiber_swap {F : Type u_1} [Field F] (yPos yNeg xPos z : F) :
fold2Fiber yNeg yPos (-xPos) z = fold2Fiber yPos yNeg xPos z

Fiber-representative invariance: swapping (xPos, -xPos) and their evaluations (yPos, yNeg) yields the exact same 2-to-1 folded value.

def Cslib.Crypto.Protocols.FRI.fold2Even {F : Type u_1} [Field F] {N : ℕ} (f : Fin (2 * N) → F) (j : Fin N) :
F

Explicit even component word for 2-to-1 folding: j ↦ (f j + f (j + N)) / 2.

def Cslib.Crypto.Protocols.FRI.fold2Odd {F : Type u_1} [Field F] (g ω : F) {N : ℕ} (f : Fin (2 * N) → F) (j : Fin N) :
F

Explicit odd component word for 2-to-1 folding: j ↦ (f j - f (j + N)) / (2 * cosetPoint g ω (2 * N) j).

def Cslib.Crypto.Protocols.FRI.fold2 {F : Type u_1} [Field F] (g ω : F) {N : ℕ} (f : Fin (2 * N) → F) (z : F) (j : Fin N) :
F

Explicit 2-to-1 FRI folding operator on a coset of size 2 * N.

theorem Cslib.Crypto.Protocols.FRI.fold2_eq_line {F : Type u_1} [Field F] (g ω : F) {N : ℕ} (f : Fin (2 * N) → F) (z : F) :
fold2 g ω f z = fold2Even f + z • fold2Odd g ω f

fold2 is the exact affine line fold2Even f + z • fold2Odd g ω f.

theorem Cslib.Crypto.Protocols.FRI.fold2Even_eq_foldComp {F : Type u_1} [Field F] {g ω : F} {N : ℕ} (f : Fin (2 * N) → F) :

fold2Even agrees with foldComp at component 0 for a = 2.

theorem Cslib.Crypto.Protocols.FRI.fold2Odd_eq_foldComp {F : Type u_1} [Field F] {g ω : F} {N : ℕ} (hN : 0 < N) (hω : IsPrimitiveRoot ω (2 * N)) (f : Fin (2 * N) → F) :
fold2Odd g ω f = foldComp g ω f ⟨1, ⋯⟩

fold2Odd agrees with foldComp at component 1 for a = 2.

theorem Cslib.Crypto.Protocols.FRI.foldFiber_two_eq_fold2Fiber {F : Type u_1} [Field F] {g ω : F} {N : ℕ} (hN : 0 < N) (hω : IsPrimitiveRoot ω (2 * N)) (ys : Fin 2 → F) (j : Fin N) (z : F) :
foldFiber g ω ys j z = fold2Fiber (ys 0) (ys 1) (cosetPoint g ω (2 * N) ⟨↑j, ⋯⟩) z

At a = 2, the local a-to-1 fiber evaluator foldFiber coincides with fold2Fiber.

theorem Cslib.Crypto.Protocols.FRI.fold2_eq_foldWord {F : Type u_1} [Field F] {g ω : F} {N : ℕ} (hN : 0 < N) (hω : IsPrimitiveRoot ω (2 * N)) (f : Fin (2 * N) → F) (z : F) :
fold2 g ω f z = foldWord g ω f z

The explicit 2-to-1 folding operator fold2 coincides with foldWord at a = 2.

theorem Cslib.Crypto.Protocols.FRI.fold2_mem_reedSolomon {F : Type u_1} [Field F] {g ω : F} {N k : ℕ} (hg : g ≠ 0) (h2 : 2 ≠ 0) (hN : 0 < N) (hω : IsPrimitiveRoot ω (2 * N)) {f : Fin (2 * N) → F} (hf : f ∈ Code.reedSolomon (cosetPoint g ω (2 * N)) (2 * k)) (z : F) :
fold2 g ω f z ∈ Code.reedSolomon (cosetPoint (g ^ 2) (ω ^ 2) N) k

Reed–Solomon closure of 2-to-1 folding: folding a codeword of reedSolomon (cosetPoint g ω (2 * N)) (2 * k) produces a codeword of reedSolomon (cosetPoint (g ^ 2) (ω ^ 2) N) k.

theorem Cslib.Crypto.Protocols.FRI.exists_mem_reedSolomon_weighted_agree_lift_two {F : Type u_1} [Field F] {g ω : F} {N k : ℕ} [DecidableEq F] (hg : g ≠ 0) (h2 : 2 ≠ 0) (hN : 0 < N) (hω : IsPrimitiveRoot ω (2 * N)) (f : Fin (2 * N) → F) {v₀ v₁ : Fin N → F} (hv₀ : v₀ ∈ Code.reedSolomon (cosetPoint (g ^ 2) (ω ^ 2) N) k) (hv₁ : v₁ ∈ Code.reedSolomon (cosetPoint (g ^ 2) (ω ^ 2) N) k) (W : Fin (2 * N) → ℕ) :
∃ c ∈ Code.reedSolomon (cosetPoint g ω (2 * N)) (2 * k), ∑ j : Fin N with fold2Even f j = v₀ j ∧ fold2Odd g ω f j = v₁ j, (W ⟨↑j, ⋯⟩ + W ⟨↑j + N, ⋯⟩) ≤ ∑ i : Fin (2 * N) with f i = c i, W i

2-to-1 weighted correlated-agreement lifting: for any word f and codewords (v₀, v₁) ∈ RS(L², k)², there exists c ∈ RS(L, 2 * k) whose W-weighted agreement with f is at least the pushed-forward weight of {j | fold2Even f j = v₀ j ∧ fold2Odd g ω f j = v₁ j}.

theorem Cslib.Crypto.Protocols.FRI.weighted_agree_of_curve_many {F : Type u_1} {ι : Type u_2} [Field F] [Fintype ι] [DecidableEq F] {a : ℕ} (ha : 1 ≤ a) (W : ι → ℕ) (u v : Fin a → ι → F) (Z : Finset F) (B : ℕ) (hZ : (a - 1) * {i : ι | 0 < W i}.card < Z.card) (hgood : ∀ z ∈ Z, B < ∑ i : ι with ∑ r : Fin a, z ^ ↑r * u r i = ∑ r : Fin a, z ^ ↑r * v r i, W i) :
B < ∑ i : ι with ∀ (r : Fin a), u r i = v r i, W i

Integer-weighted curve union bound: given a ≥ 1, integer weights W : ι → ℕ, and two degree-(a - 1) curves u, v : Fin a → ι → F, if more than (a - 1) * |{i | 0 < W i}| scalars z ∈ Z achieve W-weighted agreement > B between ∑ r, z^r • u r and ∑ r, z^r • v r, then u and v agree simultaneously across all r : Fin a on a set of W-weight > B.

theorem Cslib.Crypto.Protocols.FRI.weighted_agree_of_line_many {F : Type u_1} {ι : Type u_2} [Field F] [Fintype ι] [DecidableEq F] (W : ι → ℕ) (u₀ u₁ v₀ v₁ : ι → F) (Z : Finset F) (B : ℕ) (hZ : Fintype.card ι < Z.card) (hgood : ∀ z ∈ Z, B < ∑ i : ι with (u₀ + z • u₁) i = (v₀ + z • v₁) i, W i) :
B < ∑ i : ι with u₀ i = v₀ i ∧ u₁ i = v₁ i, W i

Integer-weighted line union bound: if more than Fintype.card ι scalars z ∈ Z achieve W-weighted agreement > B between u₀ + z • u₁ and v₀ + z • v₁, then (u₀, u₁) agrees with (v₀, v₁) simultaneously on a set of W-weight > B.