The Sumcheck protocol written in Lean 4 using CMvPolynomial.
- Fully Computable: Transcript generation is provided given a
CMvPolynomial, a claim, and challenge set. - Formalized Theorems: Notions of
completenessandsoundnessare machine-checked.
If the prover is honest, the verifier always accepts.
theorem perfect_completeness
{𝔽 : Type _} {n : ℕ}
[Field 𝔽] [Fintype 𝔽] [DecidableEq 𝔽]
(p : CPoly.CMvPolynomial n 𝔽) :
prob_over_challenges
(fun r => AcceptsEvent p (generate_honest_transcript p (honest_claim p) r))
= 1
Given a multivariate polynomial
the verifier accepts with probability exactly 1 over all challenge tuples
If the claim is false, the verifier accepts with low probability.
theorem soundness_dishonest
{𝔽 : Type _} {n : ℕ}
[Field 𝔽] [Fintype 𝔽] [DecidableEq 𝔽]
(claim : 𝔽)
(claim_p : CPoly.CMvPolynomial n 𝔽)
(adv : Adversary 𝔽 n)
(h : claim ≠ honest_claim (p := claim_p)) :
prob_over_challenges (E := AcceptsOnChallenges claim claim_p adv)
≤ n * (max_ind_degree claim_p) / field_size
If a prover claims a value
where
-
Reduction: a dishonest claim implies at least one "bad" round where the prover's polynomial
$\neq$ honest one. - Union bound: the acceptance probability is bounded by the sum over rounds.
-
Schwartz–Zippel: at each bad round, the probability of the verifier's random challenge hitting a root of the difference polynomial is at most
$d / |\mathbb{F}|$ (via Mathlib'sMvPolynomial.schwartz_zippel_sum_degreeOf).
The honest prover message at round
where Src/Prover.lean as honest_prover_message_at, which:
- Builds a substitution map
Fin n → CMvPolynomial 1 𝔽that replaces the first$i$ variables with constants (the challenges), the$(i{+}1)$ -th variable with the indeterminate$X_0$ , and the remaining variables with hypercube bits. - Evaluates
$p$ under this substitution viaeval₂Poly, producing a univariate polynomial. -
Sums these univariates over all
$\{0,1\}^{n-i-1}$ assignments usingsum_over_hypercube_recursive.
This project is released under the Apache License 2.0. See LICENSE for details.