Skip to content

Commit 5f82deb

Browse files
committed
feat(Verified-zkEVM#140): expose zero-code lower guardrail
1 parent cbbbe69 commit 5f82deb

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

ArkLib/Data/CodingTheory/ProximityGap/MCAZeroCodeGuardrail.lean

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,40 @@ theorem inv_card_le_of_grandMCAChallenge_bot (ε_star : ℝ≥0)
154154
le_of_not_gt fun hε =>
155155
not_grandMCAChallenge_bot_of_lt_inv_card (ι := ι) (F := F) ε_star hε h
156156

157+
/-- **Zero-code lower witness from the exact value.** If the target `ε_star` is at least
158+
`1 / |F|`, then the zero code satisfies the MCA bound at radius `0`. -/
159+
def MCALowerWitness_bot_of_inv_card_le (ε_star : ℝ≥0)
160+
(hε : (1 : ENNReal) / (Fintype.card F : ENNReal) ≤ (ε_star : ENNReal)) :
161+
GrandChallenges.MCALowerWitness (F := F)
162+
(Cbot (ι := ι) (F := F) : Set (ι → F)) ε_star :=
163+
GrandChallenges.MCALowerWitness.ofLe
164+
(C := (Cbot (ι := ι) (F := F) : Set (ι → F))) (δ := 0) (by simp) <| by
165+
rw [epsMCA_bot_eq_inv_card]
166+
exact hε
167+
168+
/-- Existential form of `MCALowerWitness_bot_of_inv_card_le`, preserving the certified radius. -/
169+
theorem exists_MCALowerWitness_bot_of_inv_card_le (ε_star : ℝ≥0)
170+
(hε : (1 : ENNReal) / (Fintype.card F : ENNReal) ≤ (ε_star : ENNReal)) :
171+
∃ w : GrandChallenges.MCALowerWitness (F := F)
172+
(Cbot (ι := ι) (F := F) : Set (ι → F)) ε_star,
173+
w.δ = 0 :=
174+
⟨MCALowerWitness_bot_of_inv_card_le (ι := ι) (F := F) ε_star hε, rfl⟩
175+
176+
/-- `epsStar` specialization of the zero-code lower witness. -/
177+
noncomputable def MCALowerWitness_bot_epsStar_of_inv_card_le
178+
(hε : (1 : ENNReal) / (Fintype.card F : ENNReal) ≤ (epsStar : ENNReal)) :
179+
GrandChallenges.MCALowerWitness (F := F)
180+
(Cbot (ι := ι) (F := F) : Set (ι → F)) epsStar :=
181+
MCALowerWitness_bot_of_inv_card_le (ι := ι) (F := F) epsStar hε
182+
183+
/-- Existential `epsStar` specialization, preserving the certified radius `0`. -/
184+
theorem exists_MCALowerWitness_bot_epsStar_of_inv_card_le
185+
(hε : (1 : ENNReal) / (Fintype.card F : ENNReal) ≤ (epsStar : ENNReal)) :
186+
∃ w : GrandChallenges.MCALowerWitness (F := F)
187+
(Cbot (ι := ι) (F := F) : Set (ι → F)) epsStar,
188+
w.δ = 0 :=
189+
⟨MCALowerWitness_bot_epsStar_of_inv_card_le (ι := ι) (F := F) hε, rfl⟩
190+
157191
omit [DecidableEq F] in
158192
/-- Concrete `epsStar = 2^-128` specialization: if `|F| < 2^128`, then the formal threshold
159193
is below the exact zero-code MCA value `1 / |F|`. -/
@@ -183,6 +217,35 @@ theorem epsStar_lt_inv_card_of_card_lt_two_pow
183217
_ = (2 ^ (128 : ℕ) : ENNReal) := by norm_num [Nat.cast_pow]
184218
_ = (1 : ENNReal) * (2 ^ (128 : ℕ) : ENNReal) := by simp
185219

220+
omit [DecidableEq F] in
221+
/-- Concrete `epsStar = 2^-128` lower-witness specialization: if `2^128 ≤ |F|`, then the exact
222+
zero-code MCA value is within the formal threshold. -/
223+
theorem inv_card_le_epsStar_of_two_pow_le_card
224+
(hcard : 2 ^ (128 : ℕ) ≤ Fintype.card F) :
225+
(1 : ENNReal) / (Fintype.card F : ENNReal) ≤ (epsStar : ENNReal) := by
226+
set q := Fintype.card F with hq_def
227+
have heps : (epsStar : ENNReal) = (2 ^ (128 : ℕ) : ENNReal)⁻¹ := by
228+
rw [epsStar]
229+
push_cast
230+
rw [one_div]
231+
rw [heps]
232+
have hq0 : (q : ENNReal) ≠ 0 := by
233+
simp only [ne_eq, Nat.cast_eq_zero]
234+
rw [hq_def]
235+
exact Fintype.card_ne_zero
236+
have hqtop : (q : ENNReal) ≠ ⊤ := ENNReal.natCast_ne_top q
237+
rw [ENNReal.div_le_iff hq0 hqtop]
238+
have hpow_ne_zero : (2 ^ (128 : ℕ) : ENNReal) ≠ 0 := by positivity
239+
have hpow_ne_top : (2 ^ (128 : ℕ) : ENNReal) ≠ ⊤ := by finiteness
240+
rw [← ENNReal.div_eq_inv_mul]
241+
rw [ENNReal.le_div_iff_mul_le (Or.inl hpow_ne_zero) (Or.inl hpow_ne_top)]
242+
have hcast : ((2 ^ (128 : ℕ) : ℕ) : ENNReal) ≤ (q : ENNReal) := by
243+
exact_mod_cast (by simpa [hq_def] using hcard)
244+
calc
245+
(1 : ENNReal) * (2 ^ (128 : ℕ) : ENNReal)
246+
= ((2 ^ (128 : ℕ) : ℕ) : ENNReal) := by norm_num [Nat.cast_pow]
247+
_ ≤ (q : ENNReal) := hcast
248+
186249
/-- Field-size specialization of the zero-code upper witness at `epsStar`. -/
187250
noncomputable def MCAUpperWitness_bot_epsStar_of_card_lt_two_pow
188251
(hcard : Fintype.card F < 2 ^ (128 : ℕ)) :
@@ -199,6 +262,22 @@ theorem exists_MCAUpperWitness_bot_epsStar_of_card_lt_two_pow
199262
w.δ = 0 :=
200263
⟨MCAUpperWitness_bot_epsStar_of_card_lt_two_pow (ι := ι) (F := F) hcard, rfl⟩
201264

265+
/-- Field-size specialization of the zero-code lower witness at `epsStar`. -/
266+
noncomputable def MCALowerWitness_bot_epsStar_of_two_pow_le_card
267+
(hcard : 2 ^ (128 : ℕ) ≤ Fintype.card F) :
268+
GrandChallenges.MCALowerWitness (F := F)
269+
(Cbot (ι := ι) (F := F) : Set (ι → F)) epsStar :=
270+
MCALowerWitness_bot_epsStar_of_inv_card_le
271+
(ι := ι) (F := F) (inv_card_le_epsStar_of_two_pow_le_card (F := F) hcard)
272+
273+
/-- Existential field-size lower-witness specialization, preserving the certified radius `0`. -/
274+
theorem exists_MCALowerWitness_bot_epsStar_of_two_pow_le_card
275+
(hcard : 2 ^ (128 : ℕ) ≤ Fintype.card F) :
276+
∃ w : GrandChallenges.MCALowerWitness (F := F)
277+
(Cbot (ι := ι) (F := F) : Set (ι → F)) epsStar,
278+
w.δ = 0 :=
279+
⟨MCALowerWitness_bot_epsStar_of_two_pow_le_card (ι := ι) (F := F) hcard, rfl⟩
280+
202281
/-- Field-size specialization: any supplied zero-code MCA resolution at `epsStar` has threshold
203282
exactly `0`. -/
204283
theorem GrandMCAResolution_bot_deltaStar_eq_zero_of_card_lt_two_pow
@@ -258,9 +337,16 @@ end General
258337
#print axioms not_grandMCAChallenge_bot_epsStar_of_lt_inv_card
259338
#print axioms inv_card_le_of_GrandMCAResolution_bot
260339
#print axioms inv_card_le_of_grandMCAChallenge_bot
340+
#print axioms MCALowerWitness_bot_of_inv_card_le
341+
#print axioms exists_MCALowerWitness_bot_of_inv_card_le
342+
#print axioms MCALowerWitness_bot_epsStar_of_inv_card_le
343+
#print axioms exists_MCALowerWitness_bot_epsStar_of_inv_card_le
261344
#print axioms epsStar_lt_inv_card_of_card_lt_two_pow
345+
#print axioms inv_card_le_epsStar_of_two_pow_le_card
262346
#print axioms MCAUpperWitness_bot_epsStar_of_card_lt_two_pow
263347
#print axioms exists_MCAUpperWitness_bot_epsStar_of_card_lt_two_pow
348+
#print axioms MCALowerWitness_bot_epsStar_of_two_pow_le_card
349+
#print axioms exists_MCALowerWitness_bot_epsStar_of_two_pow_le_card
264350
#print axioms GrandMCAResolution_bot_deltaStar_eq_zero_of_card_lt_two_pow
265351
#print axioms not_GrandMCAResolution_bot_epsStar_of_card_lt_two_pow
266352
#print axioms not_grandMCAChallenge_bot_epsStar_of_card_lt_two_pow

0 commit comments

Comments
 (0)