Documentation

CslibFrontier.Crypto.Protocols.FRI.Protocol

Multi-Round Smooth and 2-to-1 FRI as a Public-Coin Interactive Oracle Proof #

This module instantiates multi-round Fast Reed–Solomon Interactive Oracle Proofs of Proximity (FRI) with arbitrary per-round strict 2-smooth folding arities l⁽ⁱ⁾ = 2 ^ stepLog i ≥ 2 (FRISmoothParams, friSmoothIOP) together with the fixed 2-to-1 specialization (FRIParams, friIOP) ([BSBHR18], with fixed localization parameter in the full version ECCC TR17-134, Remark 3.1, p. 13; [BSCI+23], Section 8.2 on printed pp. 36–38 for round-dependent arities, with the fibers of Eq. (8.1), the interpolation map defined right after it, and its evaluation in Eq. (8.2) on printed p. 37, and the first-entries final anchor convention on printed p. 38) directly as a Cslib.Crypto.Protocols.BCS.PublicCoinIOP compatible with the Ben-Sasson–Chiesa–Spooner (BCS) random-oracle compiler ([BSCS16]).

Protocol layout #

Given params : FRISmoothParams F with initial coset size 2 ^ d, m folding rounds with per-round log-arities stepLog : Fin m → ℕ (1 ≤ stepLog i, cumulative log-reduction totalLog = ∑ i, stepLog i ≤ d), final Reed–Solomon dimension 1 ≤ kFinal ≤ 2 ^ (d - totalLog), and q independent query repetitions (and specializing to 2-to-1 FRIParams via FRIParams.toSmooth with stepLog := fun _ => 1 and friIOP_eq_friSmoothIOP):

Main definitions #

Main results #

References #

Binary FRIParams Parameters #

Public parameters for an (m + 1)-round 2-to-1 FRI protocol over a field F: initial multiplicative coset g * ⟨ω⟩ of size 2 ^ d, m ≤ d folding rounds, final Reed–Solomon dimension 1 ≤ kFinal ≤ 2 ^ (d - m), and q batched query repetitions.

  • d : ℕ

    Log-size of the initial multiplicative coset (|L_0| = 2 ^ d).

  • m : ℕ

    Number of 2-to-1 folding rounds (m ≤ d).

  • kFinal : ℕ

    Final Reed–Solomon dimension after m folding rounds (1 ≤ kFinal ≤ 2 ^ (d - m)).

  • q : ℕ

    Number of independent query starting indices sampled in the final round.

  • g : F

    Nonzero multiplicative coset offset.

  • ω : F

    Primitive 2 ^ d-th root of unity generating the initial evaluation subgroup.

  • hm : self.m ≤ self.d

    Folding rounds do not exceed the initial domain log-size.

  • hkPos : 1 ≤ self.kFinal

    The final Reed–Solomon dimension is at least 1.

  • hkLe : self.kFinal ≤ 2 ^ (self.d - self.m)

    The final Reed–Solomon dimension fits within the final domain 2 ^ (d - m).

  • hg : self.g ≠ 0

    The coset offset is nonzero.

  • h2 : 2 ≠ 0

    The field does not have characteristic 2.

  • hω : IsPrimitiveRoot self.ω (2 ^ self.d)

    ω is a primitive 2 ^ d-th root of unity.

@[reducible, inline]

Active domain size 2 ^ (d - i) at round i.

@[reducible, inline]

Reed–Solomon dimension kFinal * 2 ^ (m - i) at round i.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.FRI.FRIParams.eval {F : Type} [Field F] (params : FRIParams F) (i : ℕ) :
Fin (2 ^ (params.d - i)) → F

Coset evaluation map at round i.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Protocols.FRI.FRIParams.rsCode {F : Type} [Field F] (params : FRIParams F) (i : ℕ) :
Submodule F (Fin (2 ^ (params.d - i)) → F)

Round-i Reed–Solomon code RS[F, L_i, dim i].

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Protocols.FRI.FRIParams.initialCode {F : Type} [Field F] (params : FRIParams F) :

Initial Reed–Solomon code on OracleTable params.d F.

Proximity language of input words at Hamming distance at most e from initialCode.

Honest completeness relation: input word f₀ lies in initialCode.

@[reducible, inline]

Exact length of the committed-proof-oracle opening list issued by the FRI verifier via PublicCoinIOP.queries: kFinal + q * (3 * m + 2). This excludes the q scheduled input positions, with multiplicity, tracked by inputWordReads, and is the opening count that governs BCS Merkle verification cost.

@[reducible, inline]

Direct input-word read budget: q scheduled input positions, with multiplicity (listed by friInputQueries outside PublicCoinIOP.queries). Because friDecide can reject on answer-list length before accessing stmt, repetitions short-circuit on earlier failures, and query challenges may repeat indices, q is a schedule / upper-bound budget.

@[reducible, inline]

Combined word-query budget inputWordReads + proofOracleQueries = kFinal + q * (3 * m + 3), pairing the q scheduled input positions (with multiplicity) with the exact committed-proof-oracle opening list length proofOracleQueries ([BSBHR18], pp. 14:3–14:4).

theorem Cslib.Crypto.Protocols.FRI.FRIParams.totalWordQueries_eq {F : Type} [Field F] (params : FRIParams F) :
params.totalWordQueries = params.kFinal + params.q * (3 * params.m + 3)

Closed-form expression kFinal + q * (3 * m + 3) for totalWordQueries.

First kFinal evaluation points of the final coset L_m.

Injectivity of the kFinal anchor points of the final coset L_m.

theorem Cslib.Crypto.Protocols.FRI.FRIParams.dim_eq_two_mul_succ {F : Type} [Field F] (params : FRIParams F) {i : ℕ} (hi : i < params.m) :
params.dim i = 2 * params.dim (i + 1)

Each 2-to-1 folding round halves the Reed–Solomon code dimension.

theorem Cslib.Crypto.Protocols.FRI.FRIParams.domainSize_eq_two_mul_succ {F : Type} [Field F] (params : FRIParams F) {i : ℕ} (hi : i < params.d) :
params.domainSize i = 2 * params.domainSize (i + 1)

Each 2-to-1 folding round halves the evaluation domain size.

Cumulative Log-Arities & Smooth FRISmoothParams #

def Cslib.Crypto.Protocols.FRI.friCumLog {m : ℕ} (stepLog : Fin m → ℕ) :
ℕ → ℕ

Cumulative folding log-arity ∑_{k < i} stepLog k after the first i rounds (i ≤ m).

@[simp]
theorem Cslib.Crypto.Protocols.FRI.friCumLog_zero {m : ℕ} (stepLog : Fin m → ℕ) :
friCumLog stepLog 0 = 0

At round 0, the cumulative folding log-arity friCumLog stepLog 0 is 0.

theorem Cslib.Crypto.Protocols.FRI.friCumLog_succ_of_lt {m : ℕ} (stepLog : Fin m → ℕ) {i : ℕ} (hi : i < m) :
friCumLog stepLog (i + 1) = friCumLog stepLog i + stepLog ⟨i, hi⟩

One-step recurrence for friCumLog at i < m.

theorem Cslib.Crypto.Protocols.FRI.friCumLog_mono {m : ℕ} (stepLog : Fin m → ℕ) {i j : ℕ} (hij : i ≤ j) :
friCumLog stepLog i ≤ friCumLog stepLog j

Monotonicity of friCumLog in the round index.

theorem Cslib.Crypto.Protocols.FRI.friCumLog_eq_sum_fin {m : ℕ} (stepLog : Fin m → ℕ) :
friCumLog stepLog m = ∑ i : Fin m, stepLog i

Total cumulative log-arity friCumLog stepLog m equals the finite sum ∑ i, stepLog i.

theorem Cslib.Crypto.Protocols.FRI.friCumLog_const_one {m i : ℕ} :
i ≤ m → friCumLog (fun (x : Fin m) => 1) i = i

For the constant schedule stepLog = 1 (binary 2-to-1 folding), friCumLog is the identity.

Public parameters for an (m + 1)-round smooth FRI protocol over a field F with per-round strict 2-smooth folding arity l⁽ⁱ⁾ = 2 ^ stepLog i ≥ 2 ([BSCI+23], Section 8.2, printed p. 37): initial multiplicative coset g * ⟨ω⟩ of size 2 ^ d, m folding rounds with total log-reduction totalLog = ∑ i, stepLog i ≤ d, final Reed–Solomon dimension 1 ≤ kFinal ≤ 2 ^ (d - totalLog), and q batched query repetitions.

  • d : ℕ

    Log-size of the initial multiplicative coset (|L_0| = 2 ^ d).

  • m : ℕ

    Number of smooth folding rounds.

  • stepLog : Fin self.m → ℕ

    Per-round folding log-arity sᵢ (l⁽ⁱ⁾ = 2 ^ sᵢ ≥ 2).

  • kFinal : ℕ

    Final Reed–Solomon dimension after all m folding rounds.

  • q : ℕ

    Number of independent query starting indices sampled in the final round.

  • g : F

    Nonzero multiplicative coset offset.

  • ω : F

    Primitive 2 ^ d-th root of unity generating the initial evaluation subgroup.

  • hstepPos (i : Fin self.m) : 1 ≤ self.stepLog i

    Each folding round shrinks the domain strictly (l⁽ⁱ⁾ = 2 ^ stepLog i ≥ 2).

  • htotal : friCumLog self.stepLog self.m ≤ self.d

    Total folding log-reduction does not exceed the initial domain log-size.

  • hkPos : 1 ≤ self.kFinal

    The final Reed–Solomon dimension is at least 1.

  • hkLe : self.kFinal ≤ 2 ^ (self.d - friCumLog self.stepLog self.m)

    The final Reed–Solomon dimension fits within the final domain 2 ^ (d - totalLog).

  • hg : self.g ≠ 0

    The coset offset is nonzero.

  • h2 : 2 ≠ 0

    The field does not have characteristic 2 (sufficient for all 2 ^ s-to-1 folding).

  • hω : IsPrimitiveRoot self.ω (2 ^ self.d)

    ω is a primitive 2 ^ d-th root of unity.

@[reducible, inline]

Cumulative folding log-arity after the first i rounds (i ≤ m).

@[reducible, inline]

Total folding log-reduction ∑ i : Fin m, stepLog i across all m rounds.

@[reducible, inline]

Folding arity l⁽ⁱ⁾ = 2 ^ stepLog i of round i : Fin m.

@[reducible, inline]

Sum of per-round folding arities ∑ i : Fin m, l⁽ⁱ⁾.

@[reducible, inline]

First-round log-arity stepLog 0 (defaulting to 1 when m = 0).

@[reducible, inline]

Active domain size 2 ^ (d - cumLog i) at round i.

@[reducible, inline]

Reed–Solomon dimension kFinal * 2 ^ (totalLog - cumLog i) at round i.

@[reducible, inline]
abbrev Cslib.Crypto.Protocols.FRI.FRISmoothParams.eval {F : Type} [Field F] (params : FRISmoothParams F) (i : ℕ) :
Fin (2 ^ (params.d - params.cumLog i)) → F

Coset evaluation map at round i.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.Protocols.FRI.FRISmoothParams.rsCode {F : Type} [Field F] (params : FRISmoothParams F) (i : ℕ) :
Submodule F (Fin (2 ^ (params.d - params.cumLog i)) → F)

Round-i Reed–Solomon code RS[F, L_i, dim i].

@[reducible, inline]

Initial Reed–Solomon code on OracleTable params.d F.

Proximity language of input words at Hamming distance at most e from initialCode.

Honest completeness relation: input word f₀ lies in initialCode.

@[reducible, inline]

Committed-proof-oracle openings per query repetition: 1 round-0 entry, l⁽ⁱ⁾ + 1 entries per folding round i, and 1 final-round entry (aritySum + m + 2).

@[reducible, inline]

Exact length of the committed-proof-oracle opening list issued by the smooth FRI verifier via PublicCoinIOP.queries: kFinal + q * (aritySum + m + 2).

@[reducible, inline]

Direct input-word read budget: q scheduled input positions, with multiplicity (listed by friSmoothInputQueries outside PublicCoinIOP.queries). Because friSmoothDecide can reject on answer-list length before accessing stmt, repetitions short-circuit on earlier failures, and query challenges may repeat indices, q is a schedule / upper-bound budget.

@[reducible, inline]

Combined word-query budget inputWordReads + proofOracleQueries = kFinal + q * (aritySum + m + 3), pairing the q scheduled input positions (with multiplicity) with the exact committed-proof-oracle opening list length proofOracleQueries.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.totalWordQueries_eq {F : Type} [Field F] (params : FRISmoothParams F) :
params.totalWordQueries = params.kFinal + params.q * (params.aritySum + params.m + 3)

Closed-form expression kFinal + q * (aritySum + m + 3) for totalWordQueries.

First kFinal evaluation points of the final coset L_m.

Injectivity of the kFinal anchor points of the final coset L_m.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.cumLog_le_totalLog {F : Type} [Field F] (params : FRISmoothParams F) {i : ℕ} (hi : i ≤ params.m) :
params.cumLog i ≤ params.totalLog

Any prefix cumulative log-arity cumLog i (i ≤ m) is at most totalLog.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.cumLog_le_d {F : Type} [Field F] (params : FRISmoothParams F) {i : ℕ} (hi : i ≤ params.m) :
params.cumLog i ≤ params.d

Any prefix cumulative log-arity cumLog i (i ≤ m) is at most d.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.cumLog_succ {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) :
params.cumLog (↑i + 1) = params.cumLog ↑i + params.stepLog i

One-step recurrence for cumLog at folding round i : Fin params.m.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.cumLog_add_stepLog_le_d {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) :
params.cumLog ↑i + params.stepLog i ≤ params.d

Bound cumLog i + stepLog i ≤ d for every folding round i : Fin params.m.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.two_le_arity {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) :
2 ≤ params.arity i

Every smooth folding round has arity 2 ^ stepLog i ≥ 2.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.arity_cast_ne_zero {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) :
↑(params.arity i) ≠ 0

The cast of each round's smooth folding arity 2 ^ stepLog i into F is nonzero.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.domainSize_eq_arity_mul_succ {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) :
params.domainSize ↑i = params.arity i * params.domainSize (↑i + 1)

Folding round i shrinks the evaluation domain by a factor of arity i.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.dim_eq_arity_mul_succ {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) :
params.dim ↑i = params.arity i * params.dim (↑i + 1)

Folding round i shrinks the Reed–Solomon code dimension by a factor of arity i.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.dim_last {F : Type} [Field F] (params : FRISmoothParams F) :
params.dim params.m = params.kFinal

The final-round Reed–Solomon code dimension dim m equals kFinal.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.arity_sub_one_mul_domainSize {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) :
(params.arity i - 1) * params.domainSize (↑i + 1) = params.domainSize ↑i - params.domainSize (↑i + 1)

Per-round curve-degree weight identity: (l⁽ⁱ⁾ - 1) * n_{i+1} = nᵢ - n_{i+1}.

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.sum_arity_sub_one_mul_domainSize {F : Type} [Field F] (params : FRISmoothParams F) :
∑ i : Fin params.m, (params.arity i - 1) * params.domainSize (↑i + 1) = 2 ^ params.d - 2 ^ (params.d - params.totalLog)

Exact smooth curve-degree telescoping: summing (l⁽ⁱ⁾ - 1) * n_{i+1} across all m folding rounds telescopes exactly to 2 ^ d - 2 ^ (d - totalLog).

theorem Cslib.Crypto.Protocols.FRI.FRISmoothParams.arity_sub_one_mul_domainSize_le_first {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) :
(params.arity i - 1) * params.domainSize (↑i + 1) ≤ 2 ^ params.d - 2 ^ (params.d - params.firstStepLog)

Round-0 maximality across smooth folding rounds: every round's curve-degree budget (l⁽ⁱ⁾ - 1) * n_{i+1} is at most the round-0 budget 2 ^ d - 2 ^ (d - firstStepLog).

Embedding FRIParams into FRISmoothParams (toSmooth) #

@[reducible, inline]

Embed binary 2-to-1 FRIParams into FRISmoothParams via the constant folding schedule stepLog := fun _ => 1 (preserving d, m, kFinal, q, g, ω at reducible transparency).

@[simp]
theorem Cslib.Crypto.Protocols.FRI.FRIParams.toSmooth_cumLog {F : Type} [Field F] (params : FRIParams F) {i : ℕ} (hi : i ≤ params.m) :
params.toSmooth.cumLog i = i

Under toSmooth, cumulative folding log-arity at round i ≤ m is i.

Under toSmooth, total folding log-arity equals params.m.

@[simp]
theorem Cslib.Crypto.Protocols.FRI.FRIParams.toSmooth_arity {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) :
params.toSmooth.arity i = 2

Under toSmooth, every folding round has arity 2.

@[simp]

Under toSmooth, the sum of per-round arities equals 2 * params.m.

Under toSmooth, the first-round log-arity firstStepLog is 1.

@[simp]
theorem Cslib.Crypto.Protocols.FRI.FRIParams.toSmooth_domainSize {F : Type} [Field F] (params : FRIParams F) {i : ℕ} (hi : i ≤ params.m) :
params.toSmooth.domainSize i = params.domainSize i

Under toSmooth, round-i domain size matches params.domainSize i for i ≤ m.

@[simp]
theorem Cslib.Crypto.Protocols.FRI.FRIParams.toSmooth_dim {F : Type} [Field F] (params : FRIParams F) {i : ℕ} (hi : i ≤ params.m) :
params.toSmooth.dim i = params.dim i

Under toSmooth, round-i RS code dimension matches params.dim i for i ≤ m.

@[simp]

Under toSmooth, the initial Reed–Solomon code matches params.initialCode.

@[simp]

Under toSmooth, the proximity language at radius e matches params.proximityLang e.

@[simp]

Under toSmooth, the completeness relation matches params.completenessRel.

@[simp]

Under toSmooth, a single repetition takes 3 * params.m + 2 oracle openings.

@[simp]

Under toSmooth, total committed proof oracle openings match params.proofOracleQueries.

@[simp]

Under toSmooth, scheduled input word reads match params.inputWordReads.

@[simp]

Under toSmooth, combined word queries match params.totalWordQueries.

@[simp]

Under toSmooth, the final anchor points match params.finalAnchorPoints.

Verifier Challenge Alphabet (FRIChal) #

Public-coin verifier challenge for each round of friIOP: carries a folding scalar foldScalar : F (consumed in commit rounds 0, ..., m - 1) and a batch of q query starting positions queryIdxs : Fin q → Fin (2 ^ d) (consumed in the final round m).

  • foldScalar : F

    Folding challenge scalar used in commit rounds.

  • queryIdxs : Fin q → Fin (2 ^ d)

    Batch of q query starting indices used in the final round.

Instances For
    theorem Cslib.Crypto.Protocols.FRI.FRIChal.ext {F : Type} {d q : ℕ} {x y : FRIChal F d q} (foldScalar : x.foldScalar = y.foldScalar) (queryIdxs : x.queryIdxs = y.queryIdxs) :
    x = y
    def Cslib.Crypto.Protocols.FRI.FRIChal.equivProd (F : Type) (d q : ℕ) :
    FRIChal F d q ≃ F × (Fin q → Fin (2 ^ d))

    Equivalence between FRIChal F d q and F × (Fin q → Fin (2 ^ d)).

    @[instance_reducible]
    @[instance_reducible]

    Cardinality of the challenge space FRIChal F d q.

    Lagrange Interpolation on Final Anchor Points #

    def Cslib.Crypto.Protocols.FRI.evalLagrange {F : Type} [Field F] {k : ℕ} (pts vals : Fin k → F) (x : F) :
    F

    Computable Lagrange interpolation evaluation at x : F from nodes pts and values vals.

    theorem Cslib.Crypto.Protocols.FRI.evalLagrange_eq_eval_interpolate {F : Type} [Field F] {k : ℕ} (pts vals : Fin k → F) (x : F) :

    Bridge between the computable evaluator evalLagrange and Mathlib's Lagrange.interpolate, via Lagrange.eval_basis.

    theorem Cslib.Crypto.Protocols.FRI.evalLagrange_node {F : Type} [Field F] {k : ℕ} {pts : Fin k → F} (hpts : Function.Injective pts) (vals : Fin k → F) (s : Fin k) :
    evalLagrange pts vals (pts s) = vals s

    evalLagrange recovers vals s at every distinct interpolation node pts s.

    theorem Cslib.Crypto.Protocols.FRI.evalLagrange_mem_reedSolomon {F : Type} [Field F] {k n : ℕ} {pts : Fin k → F} (hpts : Function.Injective pts) (vals : Fin k → F) (α : Fin n → F) :
    (fun (j : Fin n) => evalLagrange pts vals (α j)) ∈ Code.reedSolomon α k

    Evaluating evalLagrange pts vals on any evaluation map α : Fin n → F always produces a Reed–Solomon codeword of dimension k for injective nodes pts : Fin k → F.

    theorem Cslib.Crypto.Protocols.FRI.evalLagrange_eq_of_mem_reedSolomon {F : Type} [Field F] {k n : ℕ} (hkn : k ≤ n) {α : Fin n → F} (hα : Function.Injective α) {f : Fin n → F} (hf : f ∈ Code.reedSolomon α k) (j : Fin n) :
    evalLagrange (fun (t : Fin k) => α ⟨↑t, ⋯⟩) (fun (t : Fin k) => f ⟨↑t, ⋯⟩) (α j) = f j

    Exact recovery for codewords of reedSolomon α k interpolated from the first k nodes of α.

    Oracle Padding and Honest FRI Prover Words #

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

    Pad a round-i word f : Fin (2 ^ (d - i)) → F with zeros to a depth-d OracleTable d F.

    def Cslib.Crypto.Protocols.FRI.restrictOracle {F : Type} {d i : ℕ} (π : BCS.OracleTable d F) :
    Fin (2 ^ (d - i)) → F

    Restrict a depth-d OracleTable d F to the active round-i domain Fin (2 ^ (d - i)).

    theorem Cslib.Crypto.Protocols.FRI.padOracle_apply_of_lt {F : Type} [Field F] {d i : ℕ} (f : Fin (2 ^ (d - i)) → F) (idx : Fin (2 ^ d)) (hlt : ↑idx < 2 ^ (d - i)) :
    padOracle f idx = f ⟨↑idx, hlt⟩

    Within the active prefix idx < 2 ^ (d - i), padOracle returns the entry of f.

    theorem Cslib.Crypto.Protocols.FRI.restrictOracle_padOracle {F : Type} [Field F] {d i : ℕ} (f : Fin (2 ^ (d - i)) → F) :

    Restricting a padded round-i word recovers the original word f.

    def Cslib.Crypto.Protocols.FRI.reindexDouble {d j : ℕ} (hj : j < d) (idx : Fin (2 * 2 ^ (d - (j + 1)))) :
    Fin (2 ^ (d - j))

    Helper embedding Fin (2 * 2 ^ (d - (j + 1))) → Fin (2 ^ (d - j)) for j < d.

    def Cslib.Crypto.Protocols.FRI.friSmoothHonestWord {F : Type} [Field F] (params : FRISmoothParams F) (f₀ : BCS.OracleTable params.d F) (j : ℕ) :
    j ≤ params.m → (Fin j → F) → Fin (2 ^ (params.d - params.cumLog j)) → F

    Iterated smooth honest FRI prover word at round j ≤ m, computed causally from the initial oracle f₀ and the first j folding scalars zs : Fin j → F using per-round arities l⁽ⁱ⁾ = 2 ^ stepLog i.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothHonestWord_succ_apply {F : Type} [Field F] (params : FRISmoothParams F) (f₀ : BCS.OracleTable params.d F) {j : ℕ} (hj : j + 1 ≤ params.m) (zs : Fin (j + 1) → F) (idx : Fin (2 ^ (params.d - params.cumLog (j + 1)))) :
    friSmoothHonestWord params f₀ (j + 1) hj zs idx = foldFiber (params.g ^ 2 ^ params.cumLog j) (params.ω ^ 2 ^ params.cumLog j) (fun (t : Fin (params.arity ⟨j, ⋯⟩)) => friSmoothHonestWord params f₀ j ⋯ (fun (k : Fin j) => zs k.castSucc) ⟨↑idx + ↑t * 2 ^ (params.d - params.cumLog (j + 1)), ⋯⟩) idx (zs (Fin.last j))

    Honest smooth folding satisfies the local l⁽ʲ⁾-to-1 fiber equation at every coordinate of round j + 1.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothHonestWord_mem_rsCode {F : Type} [Field F] (params : FRISmoothParams F) {f₀ : BCS.OracleTable params.d F} (hf₀ : f₀ ∈ params.initialCode) (j : ℕ) (hj : j ≤ params.m) (zs : Fin j → F) :
    friSmoothHonestWord params f₀ j hj zs ∈ params.rsCode j

    Reed–Solomon invariance of honest smooth FRI folding: if f₀ ∈ params.initialCode, then every honest prover round word friSmoothHonestWord params f₀ j hj zs lies in params.rsCode j.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothHonestWord_congr {F : Type} [Field F] (params : FRISmoothParams F) (f₀ : BCS.OracleTable params.d F) (j : ℕ) (hj : j ≤ params.m) {zs₁ zs₂ : Fin j → F} :
    (∀ (k : Fin j), zs₁ k = zs₂ k) → friSmoothHonestWord params f₀ j hj zs₁ = friSmoothHonestWord params f₀ j hj zs₂

    Prefix challenge independence: friSmoothHonestWord depends only on zs up to round j.

    def Cslib.Crypto.Protocols.FRI.friHonestWord {F : Type} [Field F] (params : FRIParams F) (f₀ : BCS.OracleTable params.d F) (j : ℕ) :
    j ≤ params.m → (Fin j → F) → Fin (2 ^ (params.d - j)) → F

    Iterated 2-to-1 honest FRI prover word at round j ≤ m, computed causally from the initial oracle f₀ and the first j folding scalars zs : Fin j → F.

    theorem Cslib.Crypto.Protocols.FRI.friHonestWord_succ_apply {F : Type} [Field F] (params : FRIParams F) (f₀ : BCS.OracleTable params.d F) {j : ℕ} (hj : j + 1 ≤ params.m) (zs : Fin (j + 1) → F) (idx : Fin (2 ^ (params.d - (j + 1)))) :
    friHonestWord params f₀ (j + 1) hj zs idx = fold2Fiber (friHonestWord params f₀ j ⋯ (fun (i : Fin j) => zs i.castSucc) ⟨↑idx, ⋯⟩) (friHonestWord params f₀ j ⋯ (fun (i : Fin j) => zs i.castSucc) ⟨↑idx + 2 ^ (params.d - (j + 1)), ⋯⟩) (params.eval j ⟨↑idx, ⋯⟩) (zs (Fin.last j))

    Honest folding satisfies the local 2-to-1 fiber equation at every coordinate of round j + 1.

    theorem Cslib.Crypto.Protocols.FRI.padOracle_friHonestWord_eq_smooth {F : Type} [Field F] (params : FRIParams F) (f₀ : BCS.OracleTable params.d F) (j : ℕ) (hj : j ≤ params.m) (zs : Fin j → F) :
    padOracle (friHonestWord params f₀ j hj zs) = padOracle (friSmoothHonestWord params.toSmooth f₀ j hj zs)

    The padded honest prover oracle tables of binary friHonestWord and smooth friSmoothHonestWord params.toSmooth coincide identically at every round j ≤ m.

    theorem Cslib.Crypto.Protocols.FRI.friHonestWord_mem_rsCode {F : Type} [Field F] (params : FRIParams F) {f₀ : BCS.OracleTable params.d F} (hf₀ : f₀ ∈ params.initialCode) (j : ℕ) (hj : j ≤ params.m) (zs : Fin j → F) :
    friHonestWord params f₀ j hj zs ∈ params.rsCode j

    Reed–Solomon invariance of honest FRI folding (corollary of friSmoothHonestWord_mem_rsCode): if f₀ ∈ params.initialCode, then every honest prover round word friHonestWord params f₀ j hj zs lies in params.rsCode j.

    theorem Cslib.Crypto.Protocols.FRI.friHonestWord_congr {F : Type} [Field F] (params : FRIParams F) (f₀ : BCS.OracleTable params.d F) (j : ℕ) (hj : j ≤ params.m) {zs₁ zs₂ : Fin j → F} :
    (∀ (i : Fin j), zs₁ i = zs₂ i) → friHonestWord params f₀ j hj zs₁ = friHonestWord params f₀ j hj zs₂

    Prefix challenge independence: friHonestWord depends only on zs up to round j.

    Smooth FRI Query Indices and Schedules #

    def Cslib.Crypto.Protocols.FRI.friSmoothFoldedFin {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ (params.d - params.cumLog (↑i + 1)))

    Active-domain folded index s % 2 ^ (d - cumLog (i + 1)) for smooth folding round i : Fin m.

    def Cslib.Crypto.Protocols.FRI.friSmoothFoldedIdx {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ params.d)

    Folded target index s % 2 ^ (d - cumLog (i + 1)) inside Fin (2 ^ d).

    def Cslib.Crypto.Protocols.FRI.friSmoothFiberIdx {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) (t : Fin (params.arity i)) :
    Fin (2 ^ params.d)

    Fiber index s % n_{i+1} + t * n_{i+1} inside Fin (2 ^ d) for t : Fin (params.arity i) at smooth folding round i : Fin m.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothFiberIdx_val_lt {F : Type} [Field F] (params : FRISmoothParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) (t : Fin (params.arity i)) :
    ↑(friSmoothFiberIdx params i s t) < 2 ^ (params.d - params.cumLog ↑i)

    Every smooth fiber query index lies inside Fin (2 ^ (d - cumLog i)).

    def Cslib.Crypto.Protocols.FRI.friSmoothFinalFin {F : Type} [Field F] (params : FRISmoothParams F) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ (params.d - params.totalLog))

    Final-round active index s % 2 ^ (d - totalLog) inside Fin (2 ^ (d - totalLog)).

    def Cslib.Crypto.Protocols.FRI.friSmoothFinalIdx {F : Type} [Field F] (params : FRISmoothParams F) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ params.d)

    Final-round query index s % 2 ^ (d - totalLog) inside Fin (2 ^ d).

    def Cslib.Crypto.Protocols.FRI.friSmoothHeaderQueries {F : Type} [Field F] (params : FRISmoothParams F) :
    List (Fin (params.m + 1) × Fin (2 ^ params.d))

    Header queries reading the first kFinal entries of the final oracle π_m.

    @[simp]

    The smooth header query schedule reads params.kFinal entries of the final oracle.

    def Cslib.Crypto.Protocols.FRI.friSmoothFoldQueriesList {F : Type} [Field F] (params : FRISmoothParams F) (s : Fin (2 ^ params.d)) :
    List (Fin params.m) → List (Fin (params.m + 1) × Fin (2 ^ params.d))

    Smooth folding-chain queries along a list of rounds rounds (opening all l⁽ⁱ⁾ fiber points in π_i and 1 folded point in π_{i + 1}) followed by the final-round check.

    theorem Cslib.Crypto.Protocols.FRI.length_friSmoothFoldQueriesList {F : Type} [Field F] (params : FRISmoothParams F) (s : Fin (2 ^ params.d)) (rounds : List (Fin params.m)) :
    (friSmoothFoldQueriesList params s rounds).length = (List.map (fun (i : Fin params.m) => params.arity i + 1) rounds).sum + 1

    Number of smooth folding-chain queries generated along rounds.

    def Cslib.Crypto.Protocols.FRI.friSmoothSingleQueries {F : Type} [Field F] (params : FRISmoothParams F) (s : Fin (2 ^ params.d)) :
    List (Fin (params.m + 1) × Fin (2 ^ params.d))

    All committed-proof-oracle queries for a single smooth query repetition starting at s.

    @[simp]

    A single smooth query repetition contains params.singleRepQueries proof-oracle openings.

    def Cslib.Crypto.Protocols.FRI.friSmoothRepQueriesList {F : Type} [Field F] (params : FRISmoothParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    List (Fin params.q) → List (Fin (params.m + 1) × Fin (2 ^ params.d))

    Concatenated smooth queries for a list of repetition indices reps : List (Fin q).

    theorem Cslib.Crypto.Protocols.FRI.length_friSmoothRepQueriesList {F : Type} [Field F] (params : FRISmoothParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (reps : List (Fin params.q)) :
    (friSmoothRepQueriesList params chals reps).length = reps.length * params.singleRepQueries

    Total length of concatenated smooth queries across reps.

    def Cslib.Crypto.Protocols.FRI.friSmoothQueries {F : Type} [Field F] (params : FRISmoothParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    List (Fin (params.m + 1) × Fin (2 ^ params.d))

    Full committed-proof-oracle opening list of the smooth FRI verifier: kFinal final-oracle interpolation anchors followed by q query repetitions.

    theorem Cslib.Crypto.Protocols.FRI.length_friSmoothQueries {F : Type} [Field F] (params : FRISmoothParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :

    Total length of friSmoothQueries matches params.proofOracleQueries.

    def Cslib.Crypto.Protocols.FRI.friSmoothInputQueries {F : Type} [Field F] (params : FRISmoothParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    List (Fin (2 ^ params.d))

    Schedule of q scheduled input positions, with multiplicity, at which stmt suffices to determine friSmoothDecide outside PublicCoinIOP.queries.

    theorem Cslib.Crypto.Protocols.FRI.length_friSmoothInputQueries {F : Type} [Field F] (params : FRISmoothParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :

    Total length of friSmoothInputQueries matches params.inputWordReads.

    Smooth FRI Final Codeword, Verifier Decisions, and friSmoothIOP #

    def Cslib.Crypto.Protocols.FRI.friSmoothFinalCodeword {F : Type} [Field F] (params : FRISmoothParams F) (πFinal : BCS.OracleTable params.d F) :
    Fin (2 ^ (params.d - params.totalLog)) → F

    Final-round Reed–Solomon codeword interpolated from the first kFinal entries of πFinal.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothFinalCodeword_mem_rsCode {F : Type} [Field F] (params : FRISmoothParams F) (πFinal : BCS.OracleTable params.d F) :
    friSmoothFinalCodeword params πFinal ∈ params.rsCode params.m

    For ANY arbitrary oracle table πFinal, friSmoothFinalCodeword params πFinal lies in params.rsCode params.m.

    def Cslib.Crypto.Protocols.FRI.friSmoothCheckFoldList {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) (headerVals : Fin params.kFinal → F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (s : Fin (2 ^ params.d)) :
    List (Fin params.m) → List F → Bool

    Check the smooth folding chain and final Lagrange equation against the flat answer list for a single repetition starting at s. Matching ans.drop (params.arity i) against yNext :: rest enforces params.arity i + 1 ≤ ans.length identically on malformed short lists.

    def Cslib.Crypto.Protocols.FRI.friSmoothCheckSingle {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) (stmt : BCS.OracleTable params.d F) (headerVals : Fin params.kFinal → F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (s : Fin (2 ^ params.d)) :
    List F → Bool

    Check a single smooth repetition's answer block: round-0 binding to stmt s plus all folding and final-codeword checks.

    def Cslib.Crypto.Protocols.FRI.friSmoothCheckRepsList {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) (stmt : BCS.OracleTable params.d F) (headerVals : Fin params.kFinal → F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    List (Fin params.q) → List F → Bool

    Check all smooth repetitions in reps by consuming fixed-size blocks of length params.singleRepQueries.

    def Cslib.Crypto.Protocols.FRI.friSmoothDecide {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (answers : List F) :

    Smooth FRI verifier decision procedure operating purely on stmt (determined by the q scheduled input positions, with multiplicity, in friSmoothInputQueries params chals), chals, and the flat list of params.proofOracleQueries queried prover-oracle answers.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothDecide_congr_inputQueries {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) {stmt₁ stmt₂ : BCS.OracleTable params.d F} (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (hagree : ∀ s ∈ friSmoothInputQueries params chals, stmt₁ s = stmt₂ s) (answers : List F) :
    friSmoothDecide params stmt₁ chals answers = friSmoothDecide params stmt₂ chals answers

    friSmoothDecide depends on the input word stmt only at the q scheduled input positions, with multiplicity, in friSmoothInputQueries params chals (params.inputWordReads = q budget).

    def Cslib.Crypto.Protocols.FRI.friSmoothIOP {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) :
    BCS.PublicCoinIOP (params.m + 1) params.d (BCS.OracleTable params.d F) Unit F (FRIChal F params.d params.q)

    Multi-round smooth 2^{sᵢ}-to-1 FRI as a PublicCoinIOP ([BSCI+23], Section 8.2, printed pp. 36–38):

    • m + 1 rounds over depth-d oracle tables OracleTable d F.
    • Honest prover sends padOracle (friSmoothHonestWord ...) using previous rounds' foldScalars.
    • Verifier opens params.proofOracleQueries = kFinal + q * (aritySum + m + 2) entries in the committed prover oracles, schedules params.inputWordReads = q input positions (with multiplicity) of stmt, and checks round-0 binding, all m l⁽ⁱ⁾-to-1 folding checks, and the final degree-< kFinal Lagrange-anchor check.
    theorem Cslib.Crypto.Protocols.FRI.length_friSmoothIOP_queries {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    ((friSmoothIOP params).queries stmt chals).length = params.proofOracleQueries

    Exact committed-proof-oracle opening count of friSmoothIOP: params.proofOracleQueries = kFinal + q * (aritySum + m + 2) for every statement and challenge vector.

    def Cslib.Crypto.Protocols.FRI.friSmoothSingleAccepts {F : Type} [Field F] (params : FRISmoothParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (oracles : Fin (params.m + 1) → BCS.OracleTable params.d F) (s : Fin (2 ^ params.d)) :

    Clean mathematical acceptance predicate for a single smooth FRI query repetition starting at s : Fin (2 ^ d): round-0 binding oracles 0 s = stmt s, all m l⁽ⁱ⁾-to-1 folding checks along the powering chain of s, and final-round agreement with friSmoothFinalCodeword.

    Smooth FRI Completeness and BCS-ROM Compilation #

    theorem Cslib.Crypto.Protocols.FRI.iopVerify_friSmoothIOP_eq_true_iff {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (oracles : Fin (params.m + 1) → BCS.OracleTable params.d F) :
    BCS.iopVerify (friSmoothIOP params) stmt chals oracles = true ↔ ∀ (a : Fin params.q), friSmoothSingleAccepts params stmt chals oracles ((chals (Fin.last params.m)).queryIdxs a)

    Exact characterization of smooth FRI IOP verification: iopVerify (friSmoothIOP params) accepts oracles on (stmt, chals) if and only if every queried starting position (chals (Fin.last m)).queryIdxs a satisfies friSmoothSingleAccepts.

    Perfect completeness of the smooth FRI IOP: for every codeword f₀ ∈ params.initialCode and every challenge vector chals, the smooth FRI verifier accepts the honest prover's tables.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothBCS_verify_prove_eq_true {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) (H : List Bool → List Bool → List Bool) (k : List Bool) {ℓ : ℕ} (hlen : ∀ (y : List Bool), (H k y).length = ℓ) (encSym : F → List Bool) (hFS : BCS.OracleTable params.d F → List (List Bool) → FRIChal F params.d params.q) {f₀ : BCS.OracleTable params.d F} (hf₀ : f₀ ∈ params.initialCode) :
    BCS.bcsVerify (friSmoothIOP params) H k encSym hFS f₀ (BCS.bcsProve (friSmoothIOP params) H k encSym hFS f₀ ()) = true

    Perfect deterministic BCS completeness for smooth FRI: for any fixed-length hash H k, Fiat–Shamir function hFS, and symbol encoding encSym, bcsVerify accepts bcsProve on every codeword f₀ ∈ params.initialCode.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothBCS_honestROMGame_eq_pure_true {F : Type} [Field F] [DecidableEq F] [Fintype F] (params : FRISmoothParams F) (encSym : F → List Bool) {f₀ : BCS.OracleTable params.d F} (hf₀ : f₀ ∈ params.initialCode) (σ : ℕ) :

    Perfect BCS ROM completeness for smooth FRI: in the lazy two-channel random-oracle model with any digest length σ, the honest BCS-FRI game outputs PMF.pure true for every codeword f₀ ∈ params.initialCode.

    theorem Cslib.Crypto.Protocols.FRI.isCostBounded_bcsMTCost_friSmoothVerifyROM {F : Type} [Field F] [DecidableEq F] (params : FRISmoothParams F) (encSym : F → List Bool) (stmt : BCS.OracleTable params.d F) (prf : BCS.BCSProof (params.m + 1) F) {L_path : ℕ} (hops : ∀ op ∈ prf.openings, op.path.length ≤ L_path) :

    Succinct verifier Merkle query cost bound for BCS-compiled smooth FRI: for any proof prf whose opening paths have length at most L_path, bcsVerifyROM makes at most params.proofOracleQueries * (L_path + 1) = (kFinal + q * (aritySum + m + 2)) * (L_path + 1) Merkle hash queries.

    Binary 2-to-1 FRI Query Schedules and friIOP #

    def Cslib.Crypto.Protocols.FRI.friFoldedFin {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ (params.d - (↑i + 1)))

    Active-domain folded index s % 2 ^ (d - (i + 1)) for folding round i : Fin m.

    def Cslib.Crypto.Protocols.FRI.friRoundPosIdx {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ params.d)

    Positive fiber index s % 2 ^ (d - (i + 1)) inside Fin (2 ^ d).

    def Cslib.Crypto.Protocols.FRI.friRoundNegIdx {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ params.d)

    Negative fiber index s % 2 ^ (d - (i + 1)) + 2 ^ (d - (i + 1)) inside Fin (2 ^ d).

    def Cslib.Crypto.Protocols.FRI.friRoundPosFin {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ (params.d - ↑i))

    Active-domain positive fiber index inside Fin (2 ^ (d - i)).

    def Cslib.Crypto.Protocols.FRI.friFinalFin {F : Type} [Field F] (params : FRIParams F) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ (params.d - params.m))

    Final-round active index s % 2 ^ (d - m) inside Fin (2 ^ (d - m)).

    def Cslib.Crypto.Protocols.FRI.friFinalIdx {F : Type} [Field F] (params : FRIParams F) (s : Fin (2 ^ params.d)) :
    Fin (2 ^ params.d)

    Final-round query index s % 2 ^ (d - m) inside Fin (2 ^ d).

    def Cslib.Crypto.Protocols.FRI.friHeaderQueries {F : Type} [Field F] (params : FRIParams F) :
    List (Fin (params.m + 1) × Fin (2 ^ params.d))

    Header queries reading the first kFinal entries of the final oracle π_m (derived directly from friSmoothHeaderQueries params.toSmooth).

    @[simp]

    The binary header query schedule reads params.kFinal entries of the final oracle.

    def Cslib.Crypto.Protocols.FRI.friFoldQueriesList {F : Type} [Field F] (params : FRIParams F) (s : Fin (2 ^ params.d)) :
    List (Fin params.m) → List (Fin (params.m + 1) × Fin (2 ^ params.d))

    Folding-chain queries along a list of rounds rounds followed by the final-round check (derived directly from friSmoothFoldQueriesList params.toSmooth).

    theorem Cslib.Crypto.Protocols.FRI.length_friFoldQueriesList {F : Type} [Field F] (params : FRIParams F) (s : Fin (2 ^ params.d)) (rounds : List (Fin params.m)) :
    (friFoldQueriesList params s rounds).length = 3 * rounds.length + 1

    Number of binary folding-chain queries generated along rounds (3 * rounds.length + 1).

    def Cslib.Crypto.Protocols.FRI.friSingleQueries {F : Type} [Field F] (params : FRIParams F) (s : Fin (2 ^ params.d)) :
    List (Fin (params.m + 1) × Fin (2 ^ params.d))

    All oracle queries for a single query repetition starting at s : Fin (2 ^ d) (derived directly from friSmoothSingleQueries params.toSmooth).

    @[simp]
    theorem Cslib.Crypto.Protocols.FRI.length_friSingleQueries {F : Type} [Field F] (params : FRIParams F) (s : Fin (2 ^ params.d)) :
    (friSingleQueries params s).length = 3 * params.m + 2

    A single binary query repetition contains 3 * params.m + 2 proof-oracle openings.

    def Cslib.Crypto.Protocols.FRI.friRepQueriesList {F : Type} [Field F] (params : FRIParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    List (Fin params.q) → List (Fin (params.m + 1) × Fin (2 ^ params.d))

    Concatenated queries for a list of repetition indices reps : List (Fin q) (derived directly from friSmoothRepQueriesList params.toSmooth).

    theorem Cslib.Crypto.Protocols.FRI.length_friRepQueriesList {F : Type} [Field F] (params : FRIParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (reps : List (Fin params.q)) :
    (friRepQueriesList params chals reps).length = reps.length * (3 * params.m + 2)

    Total length of concatenated binary queries across reps.

    def Cslib.Crypto.Protocols.FRI.friQueries {F : Type} [Field F] (params : FRIParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    List (Fin (params.m + 1) × Fin (2 ^ params.d))

    Full committed-proof-oracle opening list of the FRI verifier: kFinal final-oracle interpolation anchors followed by q query repetitions (derived directly from friSmoothQueries params.toSmooth). This excludes the q scheduled input positions, with multiplicity, tracked by friInputQueries.

    theorem Cslib.Crypto.Protocols.FRI.length_friQueries {F : Type} [Field F] (params : FRIParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    (friQueries params chals).length = params.proofOracleQueries

    Total length of friQueries matches params.proofOracleQueries.

    def Cslib.Crypto.Protocols.FRI.friInputQueries {F : Type} [Field F] (params : FRIParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    List (Fin (2 ^ params.d))

    Schedule of q scheduled input positions, with multiplicity, at which stmt suffices to determine friDecide outside PublicCoinIOP.queries (derived directly from friSmoothInputQueries params.toSmooth).

    theorem Cslib.Crypto.Protocols.FRI.length_friInputQueries {F : Type} [Field F] (params : FRIParams F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    (friInputQueries params chals).length = params.inputWordReads

    Total length of friInputQueries matches params.inputWordReads.

    def Cslib.Crypto.Protocols.FRI.friFinalCodeword {F : Type} [Field F] (params : FRIParams F) (πFinal : BCS.OracleTable params.d F) :
    Fin (2 ^ (params.d - params.m)) → F

    Final-round Reed–Solomon codeword interpolated from the first kFinal entries of πFinal.

    theorem Cslib.Crypto.Protocols.FRI.friFinalCodeword_mem_rsCode {F : Type} [Field F] (params : FRIParams F) (πFinal : BCS.OracleTable params.d F) :
    friFinalCodeword params πFinal ∈ params.rsCode params.m

    For ANY arbitrary oracle table πFinal, friFinalCodeword params πFinal lies in params.rsCode params.m.

    def Cslib.Crypto.Protocols.FRI.friCheckFoldList {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) (headerVals : Fin params.kFinal → F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (s : Fin (2 ^ params.d)) :
    List (Fin params.m) → List F → Bool

    Check the folding chain and final Lagrange equation against the answer list for a single repetition starting at s (derived directly from friSmoothCheckFoldList params.toSmooth).

    def Cslib.Crypto.Protocols.FRI.friCheckSingle {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) (stmt : BCS.OracleTable params.d F) (headerVals : Fin params.kFinal → F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (s : Fin (2 ^ params.d)) :
    List F → Bool

    Check a single repetition's answer block: round-0 binding to stmt s plus all folding and final-codeword checks (derived directly from friSmoothCheckSingle params.toSmooth).

    def Cslib.Crypto.Protocols.FRI.friCheckRepsList {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) (stmt : BCS.OracleTable params.d F) (headerVals : Fin params.kFinal → F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    List (Fin params.q) → List F → Bool

    Check all repetitions in reps by consuming fixed-size blocks of length 3 * m + 2 (derived directly from friSmoothCheckRepsList params.toSmooth).

    def Cslib.Crypto.Protocols.FRI.friDecide {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (answers : List F) :

    FRI verifier decision procedure operating purely on stmt (determined by the q scheduled input positions, with multiplicity, in friInputQueries params chals), chals, and the flat list of params.proofOracleQueries queried prover-oracle answers (derived directly from friSmoothDecide params.toSmooth).

    def Cslib.Crypto.Protocols.FRI.friIOP {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) :
    BCS.PublicCoinIOP (params.m + 1) params.d (BCS.OracleTable params.d F) Unit F (FRIChal F params.d params.q)

    Multi-round 2-to-1 FRI as a PublicCoinIOP:

    • m + 1 rounds over depth-d oracle tables OracleTable d F.
    • Honest prover sends padOracle (friHonestWord ...) using the previous rounds' foldScalars.
    • Verifier opens params.proofOracleQueries = kFinal + q * (3 * m + 2) entries in the committed prover oracles (via queries), schedules params.inputWordReads = q input positions, with multiplicity, of stmt (tracked by friInputQueries, for the combined word-query budget params.totalWordQueries = kFinal + q * (3 * m + 3)), and checks round-0 binding to stmt, all m folding checks, and the final degree-< kFinal Lagrange-anchor check.
    def Cslib.Crypto.Protocols.FRI.friSingleAccepts {F : Type} [Field F] (params : FRIParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (oracles : Fin (params.m + 1) → BCS.OracleTable params.d F) (s : Fin (2 ^ params.d)) :

    Clean mathematical acceptance predicate for a single query starting index s : Fin (2 ^ d): round-0 binding oracles 0 s = stmt s, all m 2-to-1 folding checks along the squaring chain of s, and final-round agreement with friFinalCodeword params (oracles (Fin.last m)).

    Binary-to-Smooth Bridges, Completeness, and BCS-ROM Compilation #

    theorem Cslib.Crypto.Protocols.FRI.friSmoothFoldedIdx_toSmooth {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :

    At params.toSmooth, the smooth folded target index friSmoothFoldedIdx equals the binary positive index friRoundPosIdx.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothFiberIdx_toSmooth_zero {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :
    friSmoothFiberIdx params.toSmooth i s ⟨0, ⋯⟩ = friRoundPosIdx params i s

    At params.toSmooth, fiber point 0 of friSmoothFiberIdx equals friRoundPosIdx.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothFiberIdx_toSmooth_one {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) (s : Fin (2 ^ params.d)) :
    friSmoothFiberIdx params.toSmooth i s ⟨1, ⋯⟩ = friRoundNegIdx params i s

    At params.toSmooth, fiber point 1 of friSmoothFiberIdx equals friRoundNegIdx.

    theorem Cslib.Crypto.Protocols.FRI.friSmoothFinalIdx_toSmooth {F : Type} [Field F] (params : FRIParams F) (s : Fin (2 ^ params.d)) :

    At params.toSmooth, the smooth final-domain index friSmoothFinalIdx equals friFinalIdx.

    theorem Cslib.Crypto.Protocols.FRI.eval_toSmooth_final {F : Type} [Field F] (params : FRIParams F) (s : Fin (2 ^ params.d)) :
    params.toSmooth.eval params.m (friSmoothFinalFin params.toSmooth s) = params.eval params.m (friFinalFin params s)

    At params.toSmooth, final-round domain evaluation coincides with FRIParams.eval.

    theorem Cslib.Crypto.Protocols.FRI.foldFiber_toSmooth_eq_fold2Fiber {F : Type} [Field F] (params : FRIParams F) (i : Fin params.m) (ys : Fin (params.toSmooth.arity i) → F) (s : Fin (2 ^ params.d)) (z : F) :
    foldFiber (params.g ^ 2 ^ params.toSmooth.cumLog ↑i) (params.ω ^ 2 ^ params.toSmooth.cumLog ↑i) ys (friSmoothFoldedFin params.toSmooth i s) z = fold2Fiber (ys ⟨0, ⋯⟩) (ys ⟨1, ⋯⟩) (params.eval (↑i) (friRoundPosFin params i s)) z

    At params.toSmooth, the general smooth fiber fold foldFiber coincides with binary fold2Fiber.

    Exact IOP equality: binary 2-to-1 friIOP params coincides identically with friSmoothIOP params.toSmooth across proveRound, queries, and decide.

    theorem Cslib.Crypto.Protocols.FRI.friSingleAccepts_iff_friSmoothSingleAccepts {F : Type} [Field F] (params : FRIParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (oracles : Fin (params.m + 1) → BCS.OracleTable params.d F) (s : Fin (2 ^ params.d)) :
    friSingleAccepts params stmt chals oracles s ↔ friSmoothSingleAccepts params.toSmooth stmt chals oracles s

    Exact equivalence between binary friSingleAccepts and smooth friSmoothSingleAccepts params.toSmooth.

    theorem Cslib.Crypto.Protocols.FRI.friDecide_congr_inputQueries {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) {stmt₁ stmt₂ : BCS.OracleTable params.d F} (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (hagree : ∀ s ∈ friInputQueries params chals, stmt₁ s = stmt₂ s) (answers : List F) :
    friDecide params stmt₁ chals answers = friDecide params stmt₂ chals answers

    friDecide depends on the input word stmt only at the q scheduled input positions, with multiplicity, in friInputQueries params chals (corollary of friSmoothDecide_congr_inputQueries).

    theorem Cslib.Crypto.Protocols.FRI.length_friIOP_queries {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) :
    ((friIOP params).queries stmt chals).length = params.proofOracleQueries

    Exact committed-proof-oracle opening count of friIOP: params.proofOracleQueries = kFinal + q * (3 * m + 2) for every statement and challenge vector (excluding the params.inputWordReads = q scheduled input positions, with multiplicity, tracked by friInputQueries).

    theorem Cslib.Crypto.Protocols.FRI.iopVerify_friIOP_eq_true_iff {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) (stmt : BCS.OracleTable params.d F) (chals : Fin (params.m + 1) → FRIChal F params.d params.q) (oracles : Fin (params.m + 1) → BCS.OracleTable params.d F) :
    BCS.iopVerify (friIOP params) stmt chals oracles = true ↔ ∀ (a : Fin params.q), friSingleAccepts params stmt chals oracles ((chals (Fin.last params.m)).queryIdxs a)

    Exact characterization of FRI IOP verification (corollary of iopVerify_friSmoothIOP_eq_true_iff): iopVerify (friIOP params) accepts oracles on (stmt, chals) if and only if every queried starting position (chals (Fin.last m)).queryIdxs a satisfies friSingleAccepts.

    Perfect completeness of the FRI IOP (corollary of friSmoothIOP_complete): for every codeword f₀ ∈ params.initialCode and every challenge vector chals, the FRI verifier accepts the honest prover's oracle tables.

    theorem Cslib.Crypto.Protocols.FRI.friBCS_verify_prove_eq_true {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) (H : List Bool → List Bool → List Bool) (k : List Bool) {ℓ : ℕ} (hlen : ∀ (y : List Bool), (H k y).length = ℓ) (encSym : F → List Bool) (hFS : BCS.OracleTable params.d F → List (List Bool) → FRIChal F params.d params.q) {f₀ : BCS.OracleTable params.d F} (hf₀ : f₀ ∈ params.initialCode) :
    BCS.bcsVerify (friIOP params) H k encSym hFS f₀ (BCS.bcsProve (friIOP params) H k encSym hFS f₀ ()) = true

    Perfect deterministic BCS completeness for FRI (corollary of friSmoothBCS_verify_prove_eq_true): for any hash function H k whose digests all have one length, any Fiat–Shamir function hFS, and any symbol encoding encSym, bcsVerify accepts bcsProve on every codeword f₀ ∈ params.initialCode.

    theorem Cslib.Crypto.Protocols.FRI.friBCS_honestROMGame_eq_pure_true {F : Type} [Field F] [DecidableEq F] [Fintype F] (params : FRIParams F) (encSym : F → List Bool) {f₀ : BCS.OracleTable params.d F} (hf₀ : f₀ ∈ params.initialCode) (σ : ℕ) :
    BCS.bcsHonestROMGame (friIOP params) encSym f₀ () σ = PMF.pure true

    Perfect BCS ROM completeness for FRI (corollary of friSmoothBCS_honestROMGame_eq_pure_true): in the lazy two-channel random-oracle model with any digest length σ, the honest BCS-FRI game outputs PMF.pure true for every codeword f₀ ∈ params.initialCode.

    theorem Cslib.Crypto.Protocols.FRI.isCostBounded_bcsMTCost_friVerifyROM {F : Type} [Field F] [DecidableEq F] (params : FRIParams F) (encSym : F → List Bool) (stmt : BCS.OracleTable params.d F) (prf : BCS.BCSProof (params.m + 1) F) {L_path : ℕ} (hops : ∀ op ∈ prf.openings, op.path.length ≤ L_path) :
    OracleComp.IsCostBounded BCS.bcsMTCost (BCS.bcsVerifyROM (friIOP params) encSym stmt prf) (params.proofOracleQueries * (L_path + 1))

    Succinct verifier Merkle query cost bound for BCS-compiled FRI (corollary of isCostBounded_bcsMTCost_friSmoothVerifyROM): for any proof prf whose opening paths have length at most L_path, bcsVerifyROM makes at most params.proofOracleQueries * (L_path + 1) = (kFinal + q * (3 * m + 2)) * (L_path + 1) Merkle hash queries.