@@ -60,7 +60,26 @@ def codeOfLinearCode (κ : Type*) [Fintype κ] (LC : LinearCode ι F) : Interlea
6060/--
6161The module of matrices whose rows belong to a linear code is in fact an interleaved code.
6262-/
63- lemma isInterleaved_codeOfLinearCode : (codeOfLinearCode κ LC).isInterleaved := by sorry
63+ lemma isInterleaved_codeOfLinearCode : (codeOfLinearCode κ LC).isInterleaved := by
64+ classical
65+ intro V hV i
66+ -- Define the submodule of matrices whose rows lie in LC
67+ let T : Submodule F (Matrix κ ι F) :=
68+ { carrier := {W : Matrix κ ι F | ∀ j, W j ∈ LC}
69+ zero_mem' := by
70+ -- 0-row is the zero codeword in LC
71+ exact fun j => by rw [Pi.zero_apply]; exact Submodule.zero_mem LC
72+ add_mem' := by
73+ intro A B hA hB j; simpa using (Submodule.add_mem LC (hA j) (hB j))
74+ smul_mem' := by
75+ intro a A hA j; simpa using (Submodule.smul_mem LC a (hA j)) }
76+ have hle : (matrixSubmoduleOfLinearCode κ LC) ≤ T := by
77+ -- The span of the generator set is contained in T
78+ refine Submodule.span_le.mpr ?_
79+ intro M hM; exact hM
80+ have hVT : V ∈ T := hle hV
81+ -- Conclude row membership
82+ exact hVT i
6483
6584def lawfulInterleavedCodeOfLinearCode (κ : Type *) [Fintype κ] (LC : LinearCode ι F) :
6685 LawfulInterleavedCode κ ι F := ⟨codeOfLinearCode κ LC, isInterleaved_codeOfLinearCode⟩
@@ -80,7 +99,7 @@ notation "Δ(" U "," V ")" => distCodewords U V
8099Minimal distance of an interleaved code.
81100-/
82101def minDist [DecidableEq F] (IC : MatrixSubmodule κ ι F) : ℕ :=
83- sInf { d : ℕ | ∃ U ∈ IC, ∃ V ∈ IC, distCodewords U V = d }
102+ sInf { d : ℕ | ∃ U ∈ IC, ∃ V ∈ IC, U ≠ V ∧ distCodewords U V = d }
84103
85104/--
86105`Δ IC` is the min distance of an interleaved code `IC`.
@@ -118,8 +137,210 @@ notation "Λᵢ(" U "," IC "," r ")" => relHammingBallInterleavedCode U IC r
118137The minimal distance of an interleaved code is the same as
119138the minimal distance of its underlying linear code.
120139-/
121- lemma minDist_eq_minDist [DecidableEq F] {IC : LawfulInterleavedCode κ ι F} :
122- Code.minDist (IC.1 .LC : Set (ι → F)) = minDist IC.1 .MF := by sorry
140+
141+ lemma rowSupport_subset_neqCols [DecidableEq F]
142+ (U V : Matrix κ ι F) (i : κ) :
143+ (Finset.univ.filter fun j : ι => U i j ≠ V i j) ⊆ Matrix.neqCols U V := by
144+ intro j hj
145+ have hj' : U i j ≠ V i j := (Finset.mem_filter.mp hj).2
146+ have hj'' : V i j ≠ U i j := by simpa [ne_comm] using hj'
147+ have hexists : ∃ i0 : κ, V i0 j ≠ U i0 j := ⟨i, hj''⟩
148+ simpa [Matrix.neqCols] using hexists
149+
150+ lemma support_eq_for_single_row_diff [DecidableEq F] [DecidableEq κ]
151+ {u v : ι → F} (i₀ : κ)
152+ (U V : Matrix κ ι F)
153+ (hU : ∀ i, U i = (if i = i₀ then u else 0 ))
154+ (hV : ∀ i, V i = (if i = i₀ then v else 0 )) :
155+ distCodewords U V = hammingDist u v := by
156+ classical
157+ -- Show both finset supports are equal by double inclusion
158+ -- Left-to-right: any differing column must be at row i₀
159+ apply le_antisymm
160+ · -- card(neqCols) ≤ card(support u≠v)
161+ have hsubset : Matrix.neqCols U V ⊆ (Finset.univ.filter fun j : ι => u j ≠ v j) := by
162+ intro j hj
163+ rcases (by simpa [Matrix.neqCols] using hj) with ⟨i, hi⟩
164+ by_cases hi0 : i = i₀
165+ · subst hi0
166+ have hvu : v j ≠ u j := by simpa [hU, hV] using hi
167+ have : u j ≠ v j := by simpa [ne_comm] using hvu
168+ simpa [Finset.mem_filter]
169+ · have : U i j = V i j := by simp [hU, hV, hi0]
170+ exact False.elim (hi (by simp [this]))
171+ have := Finset.card_mono hsubset
172+ simpa [distCodewords, hammingDist, Matrix.neqCols]
173+ · -- card(support u≠v) ≤ card(neqCols)
174+ have hsubset : (Finset.univ.filter fun j : ι => u j ≠ v j) ⊆ Matrix.neqCols U V := by
175+ intro j hj
176+ have : u j ≠ v j := (Finset.mem_filter.mp hj).2
177+ have : U i₀ j ≠ V i₀ j := by simpa [hU, hV] using this
178+ have : V i₀ j ≠ U i₀ j := by simpa [ne_comm] using this
179+ simpa [Matrix.neqCols] using ⟨i₀, this⟩
180+ have := Finset.card_mono hsubset
181+ simpa [distCodewords, hammingDist, Matrix.neqCols]
182+
183+
184+ lemma minDist_eq_minDist [DecidableEq F] [Nonempty κ] :
185+ Code.minDist (LC : Set (ι → F)) = minDist (matrixSubmoduleOfLinearCode κ LC) := by
186+ classical
187+ -- Abbreviations
188+ set C := (LC : Set (ι → F))
189+ set M := matrixSubmoduleOfLinearCode κ LC
190+ -- We prove both inequalities and conclude by antisymmetry on `≤` for naturals.
191+ apply le_antisymm
192+ · -- Lower bound: `Code.minDist C ≤ minDist M`.
193+ -- Split on whether there are any distinct base codewords.
194+ by_cases hC_nontriv : ∃ u ∈ C, ∃ v ∈ C, u ≠ v
195+ · -- Show that the witness set for `minDist M` is nonempty by constructing matrices
196+ -- from `u ≠ v`.
197+ rcases hC_nontriv with ⟨u, hu, v, hv, hne⟩
198+ classical
199+ obtain ⟨i₀⟩ := (inferInstance : Nonempty κ)
200+ let U0 : Matrix κ ι F := fun i j => if i = i₀ then u j else 0
201+ let V0 : Matrix κ ι F := fun i j => if i = i₀ then v j else 0
202+ -- U0,V0 are in the generator set, thus in the span M
203+ have h0mem : ∀ i, U0 i ∈ C := by
204+ intro i; by_cases h : i = i₀
205+ · subst h; simpa [U0]
206+ · have hz : (0 : ι → F) ∈ C := by simpa [C] using (Submodule.zero_mem LC : (0 : ι → F) ∈ LC)
207+ simpa [U0, h] using hz
208+ have h1mem : ∀ i, V0 i ∈ C := by
209+ intro i; by_cases h : i = i₀
210+ · subst h; simpa [V0]
211+ · have hz : (0 : ι → F) ∈ C := by simpa [C] using (Submodule.zero_mem LC : (0 : ι → F) ∈ LC)
212+ simpa [V0, h] using hz
213+ have hU0in : U0 ∈ M := by
214+ have : U0 ∈ {W : Matrix κ ι F | ∀ i, W i ∈ LC} := by simpa [C] using h0mem
215+ exact Submodule.subset_span this
216+ have hV0in : V0 ∈ M := by
217+ have : V0 ∈ {W : Matrix κ ι F | ∀ i, W i ∈ LC} := by simpa [C] using h1mem
218+ exact Submodule.subset_span this
219+ have hU0V0ne : U0 ≠ V0 := by
220+ intro hEq; apply hne; funext j
221+ simpa [U0, V0] using congrArg (fun f => f j) (congrArg (fun W => W i₀) hEq)
222+ -- Now apply lower-bound reasoning to all pairs in M and then `le_sInf_of_LB`
223+ have hLB : ∀ s ∈ {d : ℕ | ∃ U ∈ M, ∃ V ∈ M, U ≠ V ∧ distCodewords U V = d},
224+ Code.minDist C ≤ s := by
225+ intro s hs
226+ rcases hs with ⟨U, hU, V, hV, hNe', rfl⟩
227+ -- Pick a row where they differ
228+ have hex : ∃ i : κ, U i ≠ V i := by
229+ by_contra hAll; push_neg at hAll; exact hNe' (by funext i j; simp [hAll i])
230+ rcases hex with ⟨i, hi⟩
231+ -- Row-membership in the base code from `isInterleaved_codeOfLinearCode`
232+ have hUi : U i ∈ C := by
233+ -- `U ∈ M` implies every row in LC by construction
234+ have hrows := isInterleaved_codeOfLinearCode (κ := κ) (LC := LC)
235+ simpa [C] using hrows U hU i
236+ have hVi : V i ∈ C := by
237+ have hrows := isInterleaved_codeOfLinearCode (κ := κ) (LC := LC)
238+ simpa [C] using hrows V hV i
239+ -- minDist base ≤ row distance ≤ column distance
240+ have hbase_le : Code.minDist C ≤ hammingDist (U i) (V i) := by
241+ refine Nat.sInf_le ?_
242+ exact ⟨U i, hUi, V i, hVi, hi, rfl⟩
243+ have hrow_le_cols : hammingDist (U i) (V i) ≤ distCodewords U V := by
244+ simpa [hammingDist, distCodewords, Matrix.neqCols] using
245+ (Finset.card_mono (rowSupport_subset_neqCols (κ := κ) (ι := ι) U V i))
246+ exact le_trans hbase_le hrow_le_cols
247+ -- nonempty of S_M from constructed pair
248+ have hne : {d : ℕ | ∃ U ∈ M, ∃ V ∈ M, U ≠ V ∧ distCodewords U V = d}.Nonempty :=
249+ ⟨distCodewords U0 V0, ⟨U0, hU0in, V0, hV0in, hU0V0ne, rfl⟩⟩
250+ -- Conclude by lower-bound on sInf
251+ exact sInf.le_sInf_of_LB hne hLB
252+ · -- Base code has no distinct elements: `Code.minDist C = 0 ≤ minDist M`.
253+ have hC0 : Code.minDist C = 0 := by
254+ unfold Code.minDist
255+ have hemptyC : {d : ℕ | ∃ u ∈ C, ∃ v ∈ C, u ≠ v ∧ hammingDist u v = d} = (∅ : Set ℕ) := by
256+ apply Set.eq_empty_iff_forall_notMem.mpr
257+ intro d hd; rcases hd with ⟨u, hu, v, hv, hne, _⟩
258+ exact hC_nontriv ⟨u, hu, v, hv, hne⟩
259+ simp [hemptyC]
260+ simp [hC0, Nat.zero_le (minDist M)]
261+ · -- Upper bound: realize a base pair inside the interleaved code by differing in one row.
262+ -- It suffices to show `minDist M ≤ d` for each `d` realized by distinct base codewords.
263+ by_cases hC_nontriv : ∃ u ∈ C, ∃ v ∈ C, u ≠ v
264+ · -- Use `le_sInf_of_LB` with `i = minDist M` and the base-code set nonempty.
265+ have hLB : ∀ d ∈ {d : ℕ | ∃ u ∈ C, ∃ v ∈ C, u ≠ v ∧ hammingDist u v = d},
266+ minDist M ≤ d := by
267+ intro d hd
268+ rcases hd with ⟨u, hu, v, hv, hne, rfl⟩
269+ classical
270+ obtain ⟨i₀⟩ := (inferInstance : Nonempty κ)
271+ let U : Matrix κ ι F := fun i j => if i = i₀ then u j else 0
272+ let V : Matrix κ ι F := fun i j => if i = i₀ then v j else 0
273+ -- Membership in M via generators
274+ have hUrows : ∀ i, U i ∈ C := by
275+ intro i; by_cases h : i = i₀
276+ · subst h; simpa [U]
277+ · have hz : (0 : ι → F) ∈ C := by
278+ simpa [C] using (Submodule.zero_mem LC : (0 : ι → F) ∈ LC)
279+ simpa [U, h] using hz
280+ have hVrows : ∀ i, V i ∈ C := by
281+ intro i; by_cases h : i = i₀
282+ · subst h; simpa [V]
283+ · have hz : (0 : ι → F) ∈ C := by
284+ simpa [C] using (Submodule.zero_mem LC : (0 : ι → F) ∈ LC)
285+ simpa [V, h] using hz
286+ have hUin : U ∈ M := by
287+ have : U ∈ {W : Matrix κ ι F | ∀ i, W i ∈ LC} := by simpa [C] using hUrows
288+ exact Submodule.subset_span this
289+ have hVin : V ∈ M := by
290+ have : V ∈ {W : Matrix κ ι F | ∀ i, W i ∈ LC} := by simpa [C] using hVrows
291+ exact Submodule.subset_span this
292+ have hUVne : U ≠ V := by
293+ intro hEq; apply hne; funext j;
294+ simpa [U, V] using congrArg (fun f => f j) (congrArg (fun W => W i₀) hEq)
295+ -- Distance equality
296+ have hUdef : ∀ i, U i = (if i = i₀ then u else 0 ) := by
297+ intro i; by_cases h : i = i₀
298+ · subst h; funext j; simp [U]
299+ · funext j; simp [U, h]
300+ have hVdef : ∀ i, V i = (if i = i₀ then v else 0 ) := by
301+ intro i; by_cases h : i = i₀
302+ · subst h; funext j; simp [V]
303+ · funext j; simp [V, h]
304+ have hdist_eq : distCodewords U V = hammingDist u v :=
305+ support_eq_for_single_row_diff (κ := κ) (ι := ι) i₀ U V hUdef hVdef
306+ -- Conclude `minDist M ≤ distCodewords U V = hammingDist u v`
307+ refine Nat.sInf_le ?_
308+ exact ⟨U, hUin, V, hVin, hUVne, hdist_eq⟩
309+ -- Nonemptiness of the base set
310+ have hne : {d : ℕ | ∃ u ∈ C, ∃ v ∈ C, u ≠ v ∧ hammingDist u v = d}.Nonempty := by
311+ rcases hC_nontriv with ⟨u, hu, v, hv, hne⟩
312+ exact ⟨hammingDist u v, ⟨u, hu, v, hv, hne, rfl⟩⟩
313+ -- Apply lower-bound-to-sInf on the base set with i = minDist M
314+ exact sInf.le_sInf_of_LB hne hLB
315+ · -- Base code has no distinct elements: both min distances are 0.
316+ have hC0 : Code.minDist C = 0 := by
317+ unfold Code.minDist
318+ have hemptyC : {d : ℕ | ∃ u ∈ C, ∃ v ∈ C, u ≠ v ∧ hammingDist u v = d} = (∅ : Set ℕ) := by
319+ apply Set.eq_empty_iff_forall_notMem.mpr
320+ intro d hd; rcases hd with ⟨u, hu, v, hv, hne, _⟩
321+ exact hC_nontriv ⟨u, hu, v, hv, hne⟩
322+ simp [hemptyC]
323+ -- The witness set for M is empty as well
324+ have hemptyM : {d : ℕ | ∃ U ∈ M, ∃ V ∈ M, U ≠ V ∧ distCodewords U V = d} = (∅ : Set ℕ) := by
325+ apply Set.eq_empty_iff_forall_notMem.mpr
326+ intro d hd
327+ rcases hd with ⟨U, hU, V, hV, hne, _⟩
328+ have hrows := isInterleaved_codeOfLinearCode (κ := κ) (LC := LC)
329+ -- Since LC has no distinct elements, every element of LC is 0
330+ have hOnlyZero : ∀ x ∈ LC, x = (0 : ι → F) := by
331+ intro x hx; by_contra hx0
332+ exact hC_nontriv ⟨x,
333+ by simpa [C] using hx, 0 ,
334+ by simpa [C] using (Submodule.zero_mem LC),
335+ hx0⟩
336+ have hU0 : U = 0 := by
337+ funext i j; have : U i ∈ LC := hrows U hU i; simp [hOnlyZero _ this]
338+ have hV0 : V = 0 := by
339+ funext i j; have : V i ∈ LC := hrows V hV i; simp [hOnlyZero _ this]
340+ exact hne (by simp [hU0, hV0])
341+ have hM0 : minDist M = 0 := by
342+ unfold minDist; simp [hemptyM]
343+ simp [hM0, hC0]
123344
124345end InterleavedCode
125346
@@ -182,3 +403,128 @@ lemma probOfBadPts {deg : ℕ} {α : ι ↪ F} {e : ℕ} {U : Matrix κ ι F}
182403
183404end ProximityToRS
184405end
406+
407+ section GeneralInequalityAndCounterexample
408+
409+ open InterleavedCode
410+
411+ variable {F : Type *} [Semiring F] [DecidableEq F]
412+ {κ ι : Type *} [Fintype κ] [Fintype ι]
413+
414+ -- General inequality under nontriviality of the interleaved submodule
415+ lemma baseMinDist_le_minDist_of_nontrivialMF
416+ {IC : LawfulInterleavedCode κ ι F}
417+ (hNE : ∃ U ∈ IC.1 .MF, ∃ V ∈ IC.1 .MF, U ≠ V) :
418+ Code.minDist (IC.1 .LC : Set (ι → F)) ≤ InterleavedCode.minDist IC.1 .MF := by
419+ classical
420+ let S := {d : ℕ | ∃ U ∈ IC.1 .MF, ∃ V ∈ IC.1 .MF, U ≠ V ∧ InterleavedCode.distCodewords U V = d}
421+ -- Lower bound for each element of the witness set: base minDist ≤ Δ(U,V)
422+ have hLB : ∀ s ∈ S, Code.minDist (IC.1 .LC : Set (ι → F)) ≤ s := by
423+ intro s hs; rcases hs with ⟨U, hU, V, hV, hNe, rfl⟩
424+ -- pick a row where they differ
425+ have hex : ∃ i : κ, U i ≠ V i := by
426+ by_contra hAll; push_neg at hAll; exact hNe (by funext i j; simp [hAll i])
427+ rcases hex with ⟨i, hi⟩
428+ -- rows are in LC by lawfulness
429+ have hUi : U i ∈ IC.1 .LC := IC.2 U hU i
430+ have hVi : V i ∈ IC.1 .LC := IC.2 V hV i
431+ -- base ≤ row distance ≤ column distance
432+ have hbase_le : Code.minDist (IC.1 .LC : Set (ι → F)) ≤ hammingDist (U i) (V i) := by
433+ refine Nat.sInf_le ?_; exact ⟨U i, hUi, V i, hVi, hi, rfl⟩
434+ have hrow_le_cols : hammingDist (U i) (V i) ≤ InterleavedCode.distCodewords U V := by
435+ -- as finsets
436+ simpa [hammingDist, InterleavedCode.distCodewords, Matrix.neqCols] using
437+ (Finset.card_mono (rowSupport_subset_neqCols U V i))
438+ exact le_trans hbase_le hrow_le_cols
439+ -- Nonempty witness set
440+ have hneS : S.Nonempty := by
441+ rcases hNE with ⟨U, hU, V, hV, hNe⟩
442+ exact ⟨InterleavedCode.distCodewords U V, ⟨U, hU, V, hV, hNe, rfl⟩⟩
443+ -- Conclude base ≤ sInf = minDist
444+ simpa [InterleavedCode.minDist, Set.mem_setOf_eq] using (sInf.le_sInf_of_LB hneS hLB)
445+
446+
447+ def IC0 : InterleavedCode (Fin 1 ) (Fin 1 ) (ZMod 2 ) := { MF := ⊥, LC := ⊤ }
448+
449+ lemma IC0_isInterleaved : IC0.isInterleaved := by
450+ intro V _ i
451+ simp [IC0]
452+
453+ def LC0 : LawfulInterleavedCode (Fin 1 ) (Fin 1 ) (ZMod 2 ) := ⟨IC0, IC0_isInterleaved⟩
454+
455+ example :
456+ Code.minDist (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) ≠ InterleavedCode.minDist LC0.1 .MF := by
457+ -- Right-hand side: Δ(⊥) = 0 (no distinct matrices in ⊥)
458+ -- Compute minDist of ⊥ explicitly: witness set is empty
459+ have hMF : InterleavedCode.minDist LC0.1 .MF = 0 := by
460+ unfold InterleavedCode.minDist
461+ -- Show emptiness of the witness set
462+ have hempty : {d : ℕ | ∃ U ∈ LC0.1 .MF, ∃ V ∈ LC0.1 .MF,
463+ U ≠ V ∧ InterleavedCode.distCodewords U V = d} = (∅ : Set ℕ) := by
464+ apply Set.eq_empty_iff_forall_notMem.mpr
465+ intro d hd
466+ rcases hd with ⟨U, hU, V, hV, hne, _⟩
467+ have hU0 : U = 0 := by simpa [IC0] using hU
468+ have hV0 : V = 0 := by simpa [IC0] using hV
469+ exact hne (by simp [hU0, hV0])
470+ simp [hempty]
471+ -- Left-hand side: min distance of ⊤ on length-1 vectors over ZMod 2 is 1
472+ have hLC_le : Code.minDist (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) ≤ 1 := by
473+ -- Witness: u = 0, v = 1
474+ let u : Fin 1 → ZMod 2 := fun _ => 0
475+ let v : Fin 1 → ZMod 2 := fun _ => 1
476+ have hu : u ∈ (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) := by simp [LC0, IC0]
477+ have hv : v ∈ (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) := by simp [LC0, IC0]
478+ have hne : u ≠ v := by
479+ intro h
480+ have h0 : u 0 ≠ v 0 := by decide
481+ exact h0 (congrArg (fun f => f 0 ) h)
482+ -- minDist ≤ Δ₀(u,v) ≤ 1 via general bound
483+ have h₁ : Code.minDist (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) ≤ hammingDist u v := by
484+ refine Nat.sInf_le ?_;
485+ exact ⟨u, hu, v, hv, hne, rfl⟩
486+ have h₂' : hammingDist u v ≤ Fintype.card (Fin 1 ) := by
487+ simpa using (hammingDist_le_card_fintype (ι := Fin 1 ))
488+ have h₂ : hammingDist u v ≤ 1 := by
489+ simpa [Fintype.card_fin] using h₂'
490+ exact le_trans h₁ h₂
491+ -- Lower bound: every distinct pair in ⊤ differs in the only coordinate ⇒ distance ≥ 1
492+ have hLC_ge : 1 ≤ Code.minDist (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) := by
493+ -- Use the general `le_sInf_of_LB` with the witness set for Code.minDist
494+ let S := {d : ℕ | ∃ u ∈ (LC0.1 .LC : Set (Fin 1 → ZMod 2 )),
495+ ∃ v ∈ (LC0.1 .LC : Set (Fin 1 → ZMod 2 )),
496+ u ≠ v ∧ hammingDist u v = d}
497+ -- S is nonempty: same witness as above
498+ have hS_ne : S.Nonempty := by
499+ let u : Fin 1 → ZMod 2 := fun _ => 0
500+ let v : Fin 1 → ZMod 2 := fun _ => 1
501+ have hu : u ∈ (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) := by simp [LC0, IC0]
502+ have hv : v ∈ (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) := by simp [LC0, IC0]
503+ have hne : u ≠ v := by
504+ intro h
505+ have h0 : u 0 ≠ v 0 := by decide
506+ exact h0 (congrArg (fun f => f 0 ) h)
507+ exact ⟨hammingDist u v, ⟨u, hu, v, hv, hne, rfl⟩⟩
508+ -- Every element of S is ≥ 1
509+ have hLB : ∀ s ∈ S, 1 ≤ s := by
510+ intro s hs; rcases hs with ⟨u, hu, v, hv, hne, rfl⟩
511+ -- On Fin 1, distinct functions differ at 0, so distance is 1
512+ have h0neq : u 0 ≠ v 0 := by
513+ by_contra hEq
514+ apply hne; funext j; have : j = 0 := Fin.fin_one_eq_zero j; simp [this, hEq]
515+ have hmem : (0 : Fin 1 ) ∈ (Finset.univ.filter fun j : Fin 1 => u j ≠ v j) := by
516+ simp [h0neq]
517+ have hpos : 0 < (Finset.univ.filter (fun j : Fin 1 => u j ≠ v j)).card :=
518+ Finset.card_pos.mpr ⟨0 , hmem⟩
519+ have : 1 ≤ hammingDist u v := by
520+ simpa [hammingDist] using Nat.succ_le_of_lt hpos
521+ simpa using this
522+ -- Apply the helper lemma from Prelims
523+ have : 1 ≤ sInf S := sInf.le_sInf_of_LB hS_ne hLB
524+ simpa [Code.minDist, Set.mem_setOf_eq] using this
525+ -- Thus Code.minDist = 1, while Interleaved minDist = 0
526+ have hLC : Code.minDist (LC0.1 .LC : Set (Fin 1 → ZMod 2 )) = 1 := le_antisymm hLC_le hLC_ge
527+ -- Conclude inequality 1 ≠ 0
528+ simp [hLC, hMF]
529+
530+ end GeneralInequalityAndCounterexample
0 commit comments