Skip to content

Commit ff85de0

Browse files
ArkLib Agentclaude
andcommitted
feat: matching MCA lower bound for the zero code (epsMCA(bot,delta) >= (floor(delta*n)+1)/|F|)
Completes the exact characterization. Construction (slopeStack): k+1 active coords (k=floor(delta*n)) carry distinct slopes phi over the common-zero coords; each slope phi(i0) is a bad scalar (line vanishes off the active set and at i0, witness size n-k >= (1-delta)n, nondegenerate at i0). The k+1 distinct slopes (phi injective on A) give >= k+1 bad scalars, so epsMCA >= (k+1)/|F|. Needs floor(delta*n)+1 <= min(|iota|, |F|). With the upper bound this PINS epsMCA(bot,delta) exactly. Axiom-clean (no sorry), 3 build-iterations. Genuine novel construction (Verified-zkEVM#140/Verified-zkEVM#171). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6b6efdf commit ff85de0

1 file changed

Lines changed: 166 additions & 0 deletions

File tree

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
/-
2+
Copyright (c) 2026 ArkLib Contributors. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: ArkLib Contributors
5+
-/
6+
import ArkLib.Data.CodingTheory.ProximityGap.MCAZeroCodeExact
7+
8+
/-!
9+
# The matching MCA lower bound for the zero code: `ε_mca(⊥, δ) ≥ (⌊δ·n⌋ + 1)/|F|`
10+
11+
This is the construction that matches `MCAZeroCodeUpperBound`, completing the exact
12+
characterization `ε_mca(⊥, δ) = (⌊δn⌋+1)/|F|` whenever `⌊δn⌋+1 ≤ min(n, |F|)`.
13+
14+
**The optimal stack.** Pick a set `A ⊆ ι` of `k+1` coordinates (`k = ⌊δn⌋`) and a function `φ`
15+
injective on `A`. On `A` put `u₁ = 1`, `u₀ = -φ`; off `A` put `u₀ = u₁ = 0`. Then for each `i₀ ∈ A`
16+
the scalar `γ = φ i₀` is **bad**: the line `ℓ_γ` vanishes off `A` (the `n-(k+1)` common-zero
17+
coordinates) and at `i₀` (`-φ i₀ + φ i₀ = 0`), a witness set of size `n - k ≥ (1-δ)n`, and `i₀`
18+
is non-degenerate (`u₁ i₀ = 1 ≠ 0`). The `k+1` scalars `φ i₀` are distinct (`φ` injective on `A`),
19+
so the stack has `≥ k+1` bad scalars and `ε_mca(⊥, δ) ≥ (k+1)/|F|`.
20+
21+
## References
22+
- Matches `ProximityGap.MCAZeroCode.epsMCA_bot_le_floor_succ_div`.
23+
- Issue #140 / #171.
24+
-/
25+
26+
set_option linter.unusedSectionVars false
27+
28+
namespace ProximityGap.MCAZeroCode
29+
30+
open scoped NNReal ProbabilityTheory ENNReal
31+
open ProximityGap Code
32+
33+
section LowerBound
34+
35+
variable {ι : Type} [Fintype ι] [Nonempty ι] [DecidableEq ι]
36+
variable {F : Type} [Field F] [Fintype F] [DecidableEq F]
37+
38+
/-- The optimal lower-bound stack: on `A`, `u₀ = -φ` and `u₁ = 1`; off `A`, both `0`. -/
39+
noncomputable def slopeStack (A : Finset ι) (φ : ι → F) : WordStack F (Fin 2) ι :=
40+
fun k i => if k = 0 then (if i ∈ A then -(φ i) else 0) else (if i ∈ A then (1 : F) else 0)
41+
42+
@[simp] theorem slopeStack_zero (A : Finset ι) (φ : ι → F) (i : ι) :
43+
slopeStack A φ 0 i = (if i ∈ A then -(φ i) else 0) := by simp [slopeStack]
44+
45+
@[simp] theorem slopeStack_one (A : Finset ι) (φ : ι → F) (i : ι) :
46+
slopeStack A φ 1 i = (if i ∈ A then (1 : F) else 0) := by
47+
simp only [slopeStack]
48+
rw [if_neg (by decide : ¬ (1 : Fin 2) = 0)]
49+
50+
open Classical in
51+
/-- Each slope `φ i₀` (for `i₀ ∈ A`) is a bad scalar of the optimal stack, provided the witness set
52+
`(univ \ A) ∪ {i₀}` is large enough — guaranteed by `|A| ≤ δn + 1`. -/
53+
theorem mcaEvent_slopeStack {δ : ℝ≥0} {A : Finset ι} {φ : ι → F}
54+
(hAcard : ((A.card : ℝ)) ≤ (δ : ℝ) * (Fintype.card ι : ℝ) + 1)
55+
{i₀ : ι} (hi₀ : i₀ ∈ A) :
56+
mcaEvent (F := F) (Cbot : Set (ι → F)) δ (slopeStack A φ 0) (slopeStack A φ 1) (φ i₀) := by
57+
have hApos : 1 ≤ A.card := Finset.card_pos.mpr ⟨i₀, hi₀⟩
58+
have hAle : A.card ≤ Fintype.card ι := Finset.card_le_univ A
59+
refine ⟨Finset.univ \ (A.erase i₀), ?_, ⟨0, zero_mem_Cbot, ?_⟩, ?_⟩
60+
· -- `|univ \ (A.erase i₀)| = n - (|A|-1) ≥ (1-δ)n`.
61+
have hScard : (Finset.univ \ (A.erase i₀)).card = Fintype.card ι - (A.card - 1) := by
62+
rw [← Finset.compl_eq_univ_sdiff, Finset.card_compl, Finset.card_erase_of_mem hi₀]
63+
have key : ((1 - δ : ℝ≥0) : ℝ) * (Fintype.card ι : ℝ)
64+
≤ ((Finset.univ \ (A.erase i₀)).card : ℝ) := by
65+
rw [hScard, Nat.cast_sub (show A.card - 1 ≤ Fintype.card ι by omega), Nat.cast_sub hApos]
66+
by_cases hd : (δ : ℝ) ≤ 1
67+
· rw [NNReal.coe_sub (show δ ≤ 1 by exact_mod_cast hd)]
68+
push_cast
69+
nlinarith [hAcard]
70+
· push_neg at hd
71+
have hz : ((1 - δ : ℝ≥0) : ℝ) = 0 := by
72+
rw [NNReal.coe_eq_zero, tsub_eq_zero_iff_le]; exact_mod_cast hd.le
73+
rw [hz]
74+
have haa : (A.card : ℝ) ≤ (Fintype.card ι : ℝ) := by exact_mod_cast hAle
75+
push_cast; nlinarith [haa]
76+
rw [ge_iff_le, ← NNReal.coe_le_coe, NNReal.coe_mul, NNReal.coe_natCast]
77+
exact key
78+
· -- the line vanishes on the witness set
79+
intro i hi
80+
rw [Finset.mem_sdiff] at hi
81+
obtain ⟨_, hi2⟩ := hi
82+
rw [Finset.mem_erase, not_and] at hi2
83+
by_cases hiA : i ∈ A
84+
· have hii : i = i₀ := by by_contra hne; exact (hi2 hne) hiA
85+
subst hii
86+
simp [slopeStack_zero, slopeStack_one, hi₀]
87+
· simp [slopeStack_zero, slopeStack_one, hiA]
88+
· -- non-degeneracy at `i₀`
89+
rintro ⟨v₀, _hv₀, v₁, hv₁, hagree⟩
90+
have hv₁0 : v₁ = 0 := (mem_Cbot_iff v₁).mp hv₁
91+
have hi₀S : i₀ ∈ Finset.univ \ (A.erase i₀) := by
92+
rw [Finset.mem_sdiff]; exact ⟨Finset.mem_univ _, by simp⟩
93+
have hc := (hagree i₀ hi₀S).2
94+
rw [hv₁0] at hc
95+
simp only [Pi.zero_apply, slopeStack_one, if_pos hi₀] at hc
96+
exact absurd hc zero_ne_one
97+
98+
open Classical in
99+
/-- **MCA lower bound for the zero code:** `ε_mca(⊥, δ) ≥ (⌊δ·n⌋ + 1)/|F|`, whenever
100+
`⌊δn⌋ + 1 ≤ |ι|` and `⌊δn⌋ + 1 ≤ |F|`. With `epsMCA_bot_le_floor_succ_div` this pins
101+
`ε_mca(⊥, δ) = (⌊δn⌋+1)/|F|` exactly in this regime. -/
102+
theorem epsMCA_bot_ge_floor_succ_div {δ : ℝ≥0}
103+
(hkn : ⌊(δ : ℝ) * (Fintype.card ι : ℝ)⌋₊ + 1 ≤ Fintype.card ι)
104+
(hkF : ⌊(δ : ℝ) * (Fintype.card ι : ℝ)⌋₊ + 1 ≤ Fintype.card F) :
105+
((⌊(δ : ℝ) * (Fintype.card ι : ℝ)⌋₊ + 1 : ℕ) : ℝ≥0∞) / (Fintype.card F : ℝ≥0∞)
106+
≤ epsMCA (F := F) (A := F) (Cbot : Set (ι → F)) δ := by
107+
set k : ℕ := ⌊(δ : ℝ) * (Fintype.card ι : ℝ)⌋₊ with hk
108+
-- choose `A ⊆ ι` of size `k+1` and `φ` injective on `A`.
109+
obtain ⟨A, _hAsub, hAcard⟩ :=
110+
Finset.exists_subset_card_eq (s := (Finset.univ : Finset ι)) (n := k + 1)
111+
(by simpa [Finset.card_univ] using hkn)
112+
have hAcard_le : ((A.card : ℝ)) ≤ (δ : ℝ) * (Fintype.card ι : ℝ) + 1 := by
113+
rw [hAcard]; push_cast
114+
have := Nat.floor_le (show (0:ℝ) ≤ (δ:ℝ) * (Fintype.card ι:ℝ) by positivity)
115+
rw [← hk] at this; linarith
116+
obtain ⟨ψ⟩ : Nonempty ((A : Finset ι) ↪ F) := by
117+
apply Function.Embedding.nonempty_of_card_le
118+
rw [Fintype.card_coe, hAcard]; exact hkF
119+
let φ : ι → F := fun i => if h : i ∈ A then ψ ⟨i, h⟩ else 0
120+
have hφinj : Set.InjOn φ A := by
121+
intro i hi i' hi' heq
122+
have e1 : φ i = ψ ⟨i, hi⟩ := dif_pos hi
123+
have e2 : φ i' = ψ ⟨i', hi'⟩ := dif_pos hi'
124+
rw [e1, e2] at heq
125+
exact Subtype.ext_iff.mp (ψ.injective heq)
126+
-- the `k+1` distinct slopes `φ i₀` are all bad.
127+
have hsub : A.image φ ⊆
128+
Finset.filter (fun γ : F => mcaEvent (F := F) (Cbot : Set (ι → F)) δ
129+
(slopeStack A φ 0) (slopeStack A φ 1) γ) Finset.univ := by
130+
intro γ hγ
131+
rw [Finset.mem_image] at hγ
132+
obtain ⟨i₀, hi₀, rfl⟩ := hγ
133+
rw [Finset.mem_filter]
134+
exact ⟨Finset.mem_univ _, mcaEvent_slopeStack hAcard_le hi₀⟩
135+
have hcard_image : (A.image φ).card = k + 1 := by
136+
rw [Finset.card_image_of_injOn hφinj, hAcard]
137+
-- so the stack has `≥ k+1` bad scalars; average over `γ`.
138+
have hBge : (k + 1 : ℕ) ≤
139+
(Finset.filter (fun γ : F => mcaEvent (F := F) (Cbot : Set (ι → F)) δ
140+
(slopeStack A φ 0) (slopeStack A φ 1) γ) Finset.univ).card := by
141+
rw [← hcard_image]; exact Finset.card_le_card hsub
142+
-- `Pr_γ[mcaEvent] = |B|/|F| ≥ (k+1)/|F|`, and `≤ ε_mca`.
143+
have hprob : ((k + 1 : ℕ) : ℝ≥0∞) / (Fintype.card F : ℝ≥0∞)
144+
≤ Pr_{let γ ← $ᵖ F}[mcaEvent (F := F) (Cbot : Set (ι → F)) δ
145+
(slopeStack A φ 0) (slopeStack A φ 1) γ] := by
146+
rw [prob_uniform_eq_card_filter_div_card]
147+
have hcast : ((k + 1 : ℕ) : ℝ≥0∞) ≤
148+
(((Finset.filter (fun γ : F => mcaEvent (F := F) (Cbot : Set (ι → F)) δ
149+
(slopeStack A φ 0) (slopeStack A φ 1) γ) Finset.univ).card : ℕ) : ℝ≥0∞) := by
150+
exact_mod_cast hBge
151+
simp only [ENNReal.coe_natCast] at hcast ⊢
152+
gcongr
153+
refine le_trans hprob ?_
154+
unfold epsMCA
155+
exact le_iSup (fun u : WordStack F (Fin 2) ι =>
156+
Pr_{let γ ← $ᵖ F}[mcaEvent (F := F) (Cbot : Set (ι → F)) δ (u 0) (u 1) γ])
157+
(slopeStack A φ)
158+
159+
end LowerBound
160+
161+
/-! ## Source audit -/
162+
163+
#print axioms mcaEvent_slopeStack
164+
#print axioms epsMCA_bot_ge_floor_succ_div
165+
166+
end ProximityGap.MCAZeroCode

0 commit comments

Comments
 (0)