AFTD Auto-Formalizing Theoretical Domains

op2468_blackburn_stability_case_n_two

theoremverifiedoriginal

For length n = 2, let lambda = 1/2, c_2 = 1/4, and K_2 = 1. A code C in Finset (Fin 2 -> Fin q) is non-overlapping if no nonempty proper prefix of any codeword equals a suffix of any codeword. Let optimal_blackburn q be the set of codes B in Finset (Fin 2 -> Fin q) for which there exists I in Finset (Fin q) with 2 * I.card = q such that B is either the code of pairs with first symbol in I and second outside I, or first outside I and second in I. Let code_dist q C be the real infimum sInf of { ((symmDiff C B).card : ℝ) / (q : ℝ) ^ 2 | B ∈ optimal_blackburn q }, and max_dist q epsilon be the supremum sSup of { d | ∃ C : Finset (Fin 2 → Fin q), is_nonoverlapping q C ∧ (c_2 - epsilon) * (q : ℝ) ^ 2 ≤ C.card ∧ d = code_dist q C }. Let M epsilon be the limsup of max_dist (m * 2) epsilon as m tends to atTop. Then M epsilon / Real.sqrt epsilon tends to nhds K_2 as epsilon tends to 0 from above in nhdsWithin 0 (Set.Ioi 0).

Statement

theorem op2468_blackburn_stability_case_n_two :
    let n : ℕ := 2
    let lam : ℝ := (2 - 1 : ℝ) / 2
    let c_2 : ℝ := lam ^ (2 - 1) / (2 : ℝ)
    let K_2 : ℝ := 1
    let is_nonoverlapping (q : ℕ) (C : Finset (Fin 2 → Fin q)) : Prop :=
      ∀ u ∈ C, ∀ v ∈ C, ¬ ∃ (k : ℕ) (_ : 0 < k) (_ : k < 2),
        ∀ i : Fin k, u ⟨i.val, by omega⟩ = v ⟨2 - k + i.val, by omega⟩
    let optimal_blackburn (q : ℕ) : Set (Finset (Fin 2 → Fin q)) :=
      { B | ∃ (I : Finset (Fin q)), 2 * I.card = q ∧
        (B = Finset.filter (fun w => w ⟨0, by omega⟩ ∈ I ∧ w ⟨1, by omega⟩ ∉ I) Finset.univ ∨
         B = Finset.filter (fun w => w ⟨0, by omega⟩ ∉ I ∧ w ⟨1, by omega⟩ ∈ I) Finset.univ) }
    let code_dist (q : ℕ) (C : Finset (Fin 2 → Fin q)) : ℝ :=
      sInf { ((symmDiff C B).card : ℝ) / (q : ℝ) ^ 2 | B ∈ optimal_blackburn q }
    let max_dist (q : ℕ) (ε : ℝ) : ℝ :=
      sSup { d | ∃ C : Finset (Fin 2 → Fin q),
        is_nonoverlapping q C ∧ (c_2 - ε) * (q : ℝ) ^ 2 ≤ C.card ∧ d = code_dist q C }
    let M (ε : ℝ) : ℝ :=
      Filter.limsup (fun m : ℕ => max_dist (m * 2) ε) Filter.atTop
    Filter.Tendsto (fun ε => M ε / Real.sqrt ε) (nhdsWithin (0 : ℝ) (Set.Ioi 0)) (nhds K_2)
Related work
arXiv:2611.28776, A Proof of Blackburn's Conjecture on Non-Overlapping Codes
Verified
29 Nov 2026
Axioms
Classical.choiceQuot.soundpropext

Read back from the Lean

The theorem asserts that a stability bound for length-2 Blackburn codes converges to 1 as the defect parameter $\varepsilon$ approaches 0 from above. Specifically: 1. Let $n = 2$, $\lambda = (2 - 1)/2 = 1/2$, $c_2 = \lambda^{2-1} / 2 = 1/4$, and $K_2 = 1$. 2. For an alphabet size $q \in \mathbb{N}$ and a code $C \subseteq (\text{Fin } 2 \to \text{Fin } q)$ (a set of length-2 words over an alphabet of size $q$), $C$ is defined to be non-overlapping (is_nonoverlapping q C) if for all $u, v \in C$, there is no $k \in \mathbb{N}$ with $0 < k < 2$ (so $k = 1$) such that $u(i) = v(2 - k + i)$ for all $i \in \text{Fin } k$ (equivalently, $u(0) \neq v(1)$ for all $u, v \in C$). 3. For $q \in \mathbb{N}$, the family of optimal Blackburn codes optimal_blackburn q consists of all $B \subseteq (\text{Fin } 2 \to \text{Fin } q)$ for which there exists a subset $I \subseteq \text{Fin } q$ of size $|I| = q / 2$ (i.e., $2 |I| = q$) such that either: - $B = \{ w \in \text{Fin } 2 \to \text{Fin } q \mid w(0) \in I \wedge w(1) \notin I \}$, or - $B = \{ w \in \text{Fin } 2 \to \text{Fin } q \mid w(0) \notin I \wedge w(1) \in I \}$. 4. The normalized distance code_dist q C from a code $C$ to the family of optimal codes is the infimum over $B \in \text{optimal_blackburn}(q)$ of $\frac{|C \mathbin{\Delta} B|}{q^2}$, where $\mathbin{\Delta}$ denotes the symmetric difference of finsets. 5. For $q \in \mathbb{N}$ and $\varepsilon \in \mathbb{R}$, max_dist q ε is the supremum of code_dist q C over all non-overlapping codes $C \subseteq (\text{Fin } 2 \to \text{Fin } q)$ satisfying $|C| \ge (c_2 - \varepsilon) q^2 = (1/4 - \varepsilon) q^2$. 6. For $\varepsilon \in \mathbb{R}$, $M(\varepsilon) = \limsup_{m \to \infty} \text{max_dist}(2m, \varepsilon)$. 7. As $\varepsilon \to 0$ from the right (with respect to the filter nhdsWithin 0 (Set.Ioi 0)), the ratio $\frac{M(\varepsilon)}{\sqrt{\varepsilon}}$ tends to $K_2 = 1$ (with respect to nhds 1).

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The theorem establishes the sharp stability constant K_2 = 1 for optimal non-overlapping codes of length n = 2 over alphabets of even size q = 2m. For n = 2, non-overlapping codewords u, v must satisfy u(0) ≠ v(1), which forces their coordinate projection sets S0 and S1 to be disjoint, so |C| ≤ |S0||S1| ≤ m². Any code with |C| ≥ (1/4 - ε)(2m)² has marginal sizes within 2m√ε of m, placing it at normalized distance at most ε + √ε from an optimal Blackburn code B = I × Iᶜ with |I| = m. Conversely, a perturbed code S × Sᶜ with |S| = m + ⌊2m√ε⌋₊ achieves normalized distance at least (√ε - 1/(2m))(1 - √ε) from every optimal code. Taking m → ∞ sandwiches the asymptotic maximum distance M(ε) between √ε - ε and √ε + ε, so the squeeze theorem yields M(ε)/√ε → 1 = K_2 as ε → 0⁺.

  1. The set of length-2 words with first symbol in X and second in Y has cardinality |X| * |Y|.

    We rewrite the filter condition to the Cartesian product X × Y using Finset.card_product, and establish a bijection using Finset.card_nbij' by sending each word w to the pair (w(0), w(1)) and inverting via ![p.1, p.2].

    lines 1–19

    uses Finset.card_product, Finset.card_nbij'

    lemma in1283_card_prod {q : ℕ} (X Y : Finset (Fin q)) :
        (Finset.univ.filter (fun w : Fin 2 → Fin q => w 0 ∈ X ∧ w 1 ∈ Y)).card
          = X.card * Y.card := by
      rw [← Finset.card_product]
      refine Finset.card_nbij' (fun w => (w 0, w 1)) (fun p => ![p.1, p.2]) ?_ ?_ ?_ ?_
      · intro w hw
        simp only [Finset.coe_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq,
          Finset.coe_product, Set.mem_prod, Finset.mem_coe] at hw ⊢
        exact hw
      · intro p hp
        simp only [Finset.coe_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq,
          Finset.coe_product, Set.mem_prod, Finset.mem_coe] at hp ⊢
        simpa using hp
      · intro w _
        funext i
        fin_cases i <;> rfl
      · intro p _
        rfl
    
  2. The optimal Blackburn code B_1(I) = {w | w(0) ∈ I ∧ w(1) ∉ I} has cardinality |I| * (q - |I|).

    We express B_1(I) as the product set I × Iᶜ via in1283_card_prod, and rewrite the size of the complement Iᶜ as q - |I| using Finset.card_compl and Fintype.card_fin.

    lines 20–29

    uses in1283_card_prod, Finset.card_compl, Fintype.card_fin

    lemma in1283_card_B1 {q : ℕ} (I : Finset (Fin q)) :
        (Finset.univ.filter (fun w : Fin 2 → Fin q => w 0 ∈ I ∧ w 1 ∉ I)).card
          = I.card * (q - I.card) := by
      have h := in1283_card_prod I Iᶜ
      rw [Finset.card_compl, Fintype.card_fin] at h
      rw [← h]
      congr 1
      ext w
      simp
    
  3. The optimal Blackburn code B_2(I) = {w | w(0) ∉ I ∧ w(1) ∈ I} has cardinality (q - |I|) * |I|.

    Symmetrically to B_1, we apply in1283_card_prod to Iᶜ × I and simplify |Iᶜ| to q - |I| using Finset.card_compl and Fintype.card_fin.

    lines 30–39

    uses in1283_card_prod, Finset.card_compl, Fintype.card_fin

    lemma in1283_card_B2 {q : ℕ} (I : Finset (Fin q)) :
        (Finset.univ.filter (fun w : Fin 2 → Fin q => w 0 ∉ I ∧ w 1 ∈ I)).card
          = (q - I.card) * I.card := by
      have h := in1283_card_prod Iᶜ I
      rw [Finset.card_compl, Fintype.card_fin] at h
      rw [← h]
      congr 1
      ext w
      simp
    
  4. For any finite sets C and B, |C Δ B| + 2|C ∩ B| = |C| + |B|. automation

    We decompose the symmetric difference into the disjoint union of C \ B and B \ C using symmDiff_def, Finset.sup_eq_union, Finset.card_union_of_disjoint, and disjoint_sdiff_sdiff. Together with Finset.card_sdiff_add_card_inter and Finset.inter_comm, integer linear arithmetic (omega) closes the identity.

    lines 40–47

    uses symmDiff_def, Finset.sup_eq_union, Finset.card_union_of_disjoint, disjoint_sdiff_sdiff, Finset.card_sdiff_add_card_inter, Finset.inter_comm

    lemma in1283_symm {α : Type*} [DecidableEq α] (C B : Finset α) :
        (symmDiff C B).card + 2 * (C ∩ B).card = C.card + B.card := by
      rw [symmDiff_def, Finset.sup_eq_union, Finset.card_union_of_disjoint disjoint_sdiff_sdiff]
      have h1 := Finset.card_sdiff_add_card_inter C B
      have h2 := Finset.card_sdiff_add_card_inter B C
      rw [Finset.inter_comm] at h2
      omega
    
  5. If x + y ≤ 2m, m ≤ x, and c_C ≤ xy with c_C ≥ (1/4 - ε)(2m)², then x - m ≤ 2m√ε. automation

    Since y ≤ 2m - x, we have xy ≤ x(2m - x) via mul_le_mul_of_nonneg_left. Substituting the lower bound on c_C and expanding (2m√ε)² = 4εm² via Real.sq_sqrt yields (x - m)² ≤ (2m√ε)². Since x ≥ m, taking square roots gives x - m ≤ 2m√ε.

    lines 48–69

    uses Real.sq_sqrt, mul_le_mul_of_nonneg_left

    lemma in1283_dev (m : ℕ) (ε : ℝ) (hε : 0 < ε) (cC x y : ℕ) (hxy : x + y ≤ m * 2)
        (hC : cC ≤ x * y) (hmx : m ≤ x)
        (hcard : (1/4 - ε) * ((m*2 : ℕ) : ℝ)^2 ≤ cC) :
        ((x:ℝ) - m) ≤ 2 * Real.sqrt ε * m := by
      have hsq := Real.sq_sqrt hε.le
      have hxyR : (x:ℝ) + y ≤ m*2 := by exact_mod_cast hxy
      have hCR : (cC:ℝ) ≤ x*y := by exact_mod_cast hC
      have hmxR : (m:ℝ) ≤ x := by exact_mod_cast hmx
      push_cast at hcard
      have hy : (0:ℝ) ≤ y := by positivity
      have hx : (0:ℝ) ≤ x := by positivity
      have h4 : (2 * Real.sqrt ε * m) ^ 2 = 4 * ε * m ^ 2 := by
        calc (2 * Real.sqrt ε * m) ^ 2 = 4 * (Real.sqrt ε ^ 2) * m ^ 2 := by ring
          _ = 4 * ε * m ^ 2 := by rw [hsq]
      have hxy2 : (x:ℝ) * y ≤ x * (m * 2 - x) := by
        apply mul_le_mul_of_nonneg_left _ hx
        linarith
      have hsq' : ((x:ℝ) - m) ^ 2 ≤ (2 * Real.sqrt ε * m) ^ 2 := by
        rw [h4]; nlinarith
      have hpos : 0 ≤ 2 * Real.sqrt ε * m := by positivity
      nlinarith
    
  6. For a non-overlapping code C, the coordinate projections S0 and S1 are disjoint, |S0| + |S1| ≤ 2m, and |C| ≤ |S0| * |S1|.

    The non-overlapping condition means no codeword's first coordinate equals any codeword's second coordinate, so S0 and S1 are disjoint by Finset.disjoint_left. Their disjoint union embeds in the alphabet Fin(2m), giving |S0| + |S1| ≤ 2m via Finset.card_union_of_disjoint and Finset.card_le_univ. Since C ⊆ S0 × S1, |C| ≤ |S0| * |S1| follows from Finset.card_le_card and in1283_card_prod.

    lines 70–97

    uses Finset.disjoint_left, Finset.card_union_of_disjoint, Finset.card_le_univ, Finset.card_le_card, in1283_card_prod

    lemma in1283_upper (m : ℕ) (hm : 1 ≤ m) (ε : ℝ) (hε : 0 < ε)
        (C : Finset (Fin 2 → Fin (m*2)))
        (hdis : ∀ u ∈ C, ∀ v ∈ C, u 0 ≠ v 1)
        (hcard : (1/4 - ε) * ((m*2 : ℕ) : ℝ)^2 ≤ C.card) :
        ∃ B : Finset (Fin 2 → Fin (m*2)), (∃ I : Finset (Fin (m*2)), 2 * I.card = m*2 ∧
            (B = Finset.univ.filter (fun w => w 0 ∈ I ∧ w 1 ∉ I) ∨
             B = Finset.univ.filter (fun w => w 0 ∉ I ∧ w 1 ∈ I))) ∧
          ((symmDiff C B).card : ℝ) / ((m*2 : ℕ) : ℝ)^2 ≤ ε + Real.sqrt ε := by
      classical
      set S0 := C.image (fun w => w 0) with hS0
      set S1 := C.image (fun w => w 1) with hS1
      have hdisj : Disjoint S0 S1 := by
        rw [Finset.disjoint_left]
        intro x hx hx'
        simp only [S0, S1, Finset.mem_image] at hx hx'
        obtain ⟨u, hu, rfl⟩ := hx
        obtain ⟨v, hv, hv'⟩ := hx'
        exact hdis u hu v hv hv'.symm
      have hab : S0.card + S1.card ≤ m*2 := by
        rw [← Finset.card_union_of_disjoint hdisj]
        simpa using Finset.card_le_univ (S0 ∪ S1)
      have hCsub : C ⊆ Finset.univ.filter
          (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S0 ∧ w 1 ∈ S1) := by
        intro w hw
        simp only [Finset.mem_filter, Finset.mem_univ, true_and]
        exact ⟨Finset.mem_image_of_mem _ hw, Finset.mem_image_of_mem _ hw⟩
      have hCab : C.card ≤ S0.card * S1.card :=
        (Finset.card_le_card hCsub).trans (in1283_card_prod S0 S1).le
  7. If an optimal Blackburn code B of size m² satisfies |C \ B| ≤ E ≤ 2m²√ε, then |C Δ B| / (2m)² ≤ ε + √ε. automation

    From |C Δ B| + |C| = m² + 2|C \ B| (proved via in1283_symm and Finset.card_sdiff_add_card_inter) and |C| ≥ (1/4 - ε)(2m)², we bound |C Δ B| ≤ 4εm² + 2E ≤ 4(ε + √ε)m². Dividing by (2m)² using div_le_iff₀ and nonlinear arithmetic confirms the bound.

    lines 98–112

    uses Real.sqrt_nonneg, in1283_symm, Finset.card_sdiff_add_card_inter, div_le_iff₀

      have hs0 := Real.sqrt_nonneg ε
      have hmR : (1:ℝ) ≤ m := by exact_mod_cast hm
      have key : ∀ (B : Finset (Fin 2 → Fin (m*2))) (E : ℕ), B.card = m*m →
          (C \ B).card ≤ E → (E : ℝ) ≤ 2 * Real.sqrt ε * m * m →
          ((symmDiff C B).card : ℝ) / ((m*2 : ℕ) : ℝ)^2 ≤ ε + Real.sqrt ε := by
        intro B E hB hE hER
        have h1 := in1283_symm C B
        have h2 := Finset.card_sdiff_add_card_inter C B
        have h3 : (symmDiff C B).card + C.card = m*m + 2 * (C \ B).card := by omega
        have h3' : ((symmDiff C B).card : ℝ) + C.card = m*m + 2 * (C \ B).card := by
          exact_mod_cast h3
        have hE' : ((C \ B).card : ℝ) ≤ E := by exact_mod_cast hE
        rw [div_le_iff₀ (by positivity)]
        push_cast at hcard ⊢
        nlinarith
  8. When |S0| ≥ m, choosing I ⊆ S0 with |I| = m produces an optimal code B = I × Iᶜ with normalized distance ≤ ε + √ε.

    We choose I ⊆ S0 of size m via Finset.exists_subset_card_eq and set B = I × Iᶜ, which has size m² by in1283_card_B1. Any codeword in C \ B must have first coordinate in S0 \ I and second in S1, so |C \ B| ≤ (|S0| - m)|S1| via Finset.card_le_card, in1283_card_prod, and Finset.card_sdiff_of_subset. By in1283_dev, |S0| - m ≤ 2m√ε, and |S1| ≤ m, so |C \ B| ≤ 2m²√ε by mul_le_mul. The reduction key then yields the bound.

    lines 113–138

    uses Finset.exists_subset_card_eq, in1283_card_B1, Finset.card_le_card, in1283_card_prod, Finset.card_sdiff_of_subset, Finset.disjoint_left, in1283_dev, Nat.cast_mul, Nat.cast_sub, mul_le_mul

      by_cases ha : m ≤ S0.card
      · obtain ⟨I, hIS, hIc⟩ := Finset.exists_subset_card_eq ha
        refine ⟨_, ⟨I, by omega, Or.inl rfl⟩, ?_⟩
        apply key _ ((S0.card - m) * S1.card)
        · rw [in1283_card_B1, hIc, show m * 2 - m = m by omega]
        · refine (Finset.card_le_card (t := Finset.univ.filter
              (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S0 \ I ∧ w 1 ∈ S1)) ?_).trans
            (by rw [in1283_card_prod, Finset.card_sdiff_of_subset hIS, hIc])
          intro w hw
          simp only [Finset.mem_sdiff, Finset.mem_filter, Finset.mem_univ, true_and, not_and,
            not_not] at hw ⊢
          obtain ⟨hwC, hwB⟩ := hw
          have h0 : w 0 ∈ S0 := Finset.mem_image_of_mem _ hwC
          have h1 : w 1 ∈ S1 := Finset.mem_image_of_mem _ hwC
          have h1' : w 1 ∉ I := fun h => Finset.disjoint_left.1 hdisj (hIS h) h1
          exact ⟨⟨h0, fun h => h1' (hwB h)⟩, h1⟩
        · have hb : S1.card ≤ m := by omega
          have hx := in1283_dev m ε hε C.card S0.card S1.card hab hCab ha hcard
          rw [Nat.cast_mul, Nat.cast_sub ha]
          have hbR : (S1.card : ℝ) ≤ m := by exact_mod_cast hb
          have : (0:ℝ) ≤ S0.card - m := by
            have : (m:ℝ) ≤ S0.card := by exact_mod_cast ha
            linarith
          calc ((S0.card:ℝ) - m) * S1.card ≤ (2 * Real.sqrt ε * m) * m :=
                mul_le_mul hx hbR (by positivity) (by positivity)
            _ = _ := by ring
  9. When |S1| ≥ m, choosing I ⊆ S1 with |I| = m produces an optimal code B = Iᶜ × I with normalized distance ≤ ε + √ε.

    Symmetrically to Case 1, we select I ⊆ S1 of size m via Finset.exists_subset_card_eq and set B = Iᶜ × I, which has size m² by in1283_card_B2. The codewords C \ B lie in S0 × (S1 \ I), so |C \ B| ≤ |S0|(|S1| - m) ≤ 2m²√ε by in1283_dev, Nat.mul_comm, and mul_le_mul. The reduction key applies to complete this case.

    lines 139–166

    uses Finset.exists_subset_card_eq, in1283_card_B2, Finset.card_le_card, in1283_card_prod, Finset.card_sdiff_of_subset, Finset.disjoint_left, in1283_dev, Nat.mul_comm, Nat.cast_mul, Nat.cast_sub, mul_le_mul

      by_cases hb : m ≤ S1.card
      · obtain ⟨I, hIS, hIc⟩ := Finset.exists_subset_card_eq hb
        refine ⟨_, ⟨I, by omega, Or.inr rfl⟩, ?_⟩
        apply key _ (S0.card * (S1.card - m))
        · rw [in1283_card_B2, hIc, show m * 2 - m = m by omega]
        · refine (Finset.card_le_card (t := Finset.univ.filter
              (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S0 ∧ w 1 ∈ S1 \ I)) ?_).trans
            (by rw [in1283_card_prod, Finset.card_sdiff_of_subset hIS, hIc])
          intro w hw
          simp only [Finset.mem_sdiff, Finset.mem_filter, Finset.mem_univ, true_and,
            not_and] at hw ⊢
          obtain ⟨hwC, hwB⟩ := hw
          have h0 : w 0 ∈ S0 := Finset.mem_image_of_mem _ hwC
          have h1 : w 1 ∈ S1 := Finset.mem_image_of_mem _ hwC
          have h0' : w 0 ∉ I := fun h => Finset.disjoint_left.1 hdisj h0 (hIS h)
          exact ⟨h0, h1, hwB h0'⟩
        · have hx := in1283_dev m ε hε C.card S1.card S0.card (by omega)
            (by rw [Nat.mul_comm S1.card S0.card]; exact hCab) hb hcard
          rw [Nat.cast_mul, Nat.cast_sub hb]
          have haR : (S0.card : ℝ) ≤ m := by
            have : S0.card ≤ m := by omega
            exact_mod_cast this
          have : (0:ℝ) ≤ S1.card - m := by
            have : (m:ℝ) ≤ S1.card := by exact_mod_cast hb
            linarith
          calc (S0.card:ℝ) * (S1.card - m) ≤ m * (2 * Real.sqrt ε * m) :=
                mul_le_mul haR hx this (by positivity)
            _ = _ := by ring
  10. When |S0| < m and |S1| < m, C is completely contained in an optimal code B, so |C \ B| = 0 and the bound holds.

    Since S0 and S1 are disjoint, S0 ⊆ S1ᶜ by Finset.disjoint_left and Finset.mem_compl. We interpolate a set I of size m with S0 ⊆ I ⊆ S1ᶜ using Finset.exists_subsuperset_card_eq, Finset.card_compl, and Fintype.card_fin. Then C ⊆ I × Iᶜ = B, meaning C \ B = ∅ by Finset.sdiff_eq_empty_iff_subset and Finset.card_eq_zero. Applying the reduction key with E = 0 completes the proof of in1283_upper.

    lines 167–188

    uses Finset.mem_compl, Finset.disjoint_left, Finset.exists_subsuperset_card_eq, Finset.card_compl, Fintype.card_fin, in1283_card_B1, le_of_eq, Finset.card_eq_zero, Finset.sdiff_eq_empty_iff_subset

      · have hsub : S0 ⊆ S1ᶜ := by
          intro x hx
          rw [Finset.mem_compl]
          exact Finset.disjoint_left.1 hdisj hx
        obtain ⟨I, hI0, hI1, hIc⟩ := Finset.exists_subsuperset_card_eq hsub (n := m)
          (by omega) (by rw [Finset.card_compl, Fintype.card_fin]; omega)
        refine ⟨_, ⟨I, by omega, Or.inl rfl⟩, ?_⟩
        apply key _ 0
        · rw [in1283_card_B1, hIc, show m * 2 - m = m by omega]
        · apply le_of_eq
          rw [Finset.card_eq_zero, Finset.sdiff_eq_empty_iff_subset]
          intro w hw
          simp only [Finset.mem_filter, Finset.mem_univ, true_and]
          have h0 : w 0 ∈ S0 := Finset.mem_image_of_mem _ hw
          have h1 : w 1 ∈ S1 := Finset.mem_image_of_mem _ hw
          refine ⟨hI0 h0, fun h => ?_⟩
          have := hI1 h
          rw [Finset.mem_compl] at this
          exact this h1
        · push_cast
          positivity
    
  11. Construction of an extremal code candidate C = S × Sᶜ with |S| = m + x where x = ⌊2m√ε⌋₊.

    We define the integer offset x = ⌊2m√ε⌋₊, which satisfies x ≤ 2m√ε by Nat.floor_le, 2m√ε - 1 < x by Nat.sub_one_lt_floor, and x ≤ m because ε ≤ 1/16 implies √ε ≤ 1/4 by Real.sqrt_le_sqrt. We pick a subset S of size m + x using Finset.exists_subset_card_eq and form C = S × Sᶜ, which has cardinality (m + x)(m - x) by in1283_card_prod, Finset.card_compl, and Fintype.card_fin.

    lines 189–223

    uses Real.sqrt_nonneg, Real.sq_sqrt, Real.sqrt_sq, Real.sqrt_le_sqrt, Nat.floor_le, Nat.sub_one_lt_floor, Finset.exists_subset_card_eq, in1283_card_prod, Finset.card_compl, Fintype.card_fin, mul_le_mul

    lemma in1283_lower (m : ℕ) (hm : 1 ≤ m) (ε : ℝ) (hε : 0 < ε) (hε1 : ε ≤ 1/16) :
        ∃ C : Finset (Fin 2 → Fin (m*2)), (∀ u ∈ C, ∀ v ∈ C, u 0 ≠ v 1) ∧
          (1/4 - ε) * ((m*2 : ℕ) : ℝ)^2 ≤ C.card ∧
          ∀ B : Finset (Fin 2 → Fin (m*2)), (∃ I : Finset (Fin (m*2)), 2 * I.card = m*2 ∧
            (B = Finset.univ.filter (fun w => w 0 ∈ I ∧ w 1 ∉ I) ∨
             B = Finset.univ.filter (fun w => w 0 ∉ I ∧ w 1 ∈ I))) →
          (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε)
            ≤ ((symmDiff C B).card : ℝ) / ((m*2 : ℕ) : ℝ)^2 := by
      classical
      set x := ⌊2 * (m:ℝ) * Real.sqrt ε⌋₊ with hxdef
      have hs0 := Real.sqrt_nonneg ε
      have hsq := Real.sq_sqrt hε.le
      have hs14 : Real.sqrt ε ≤ 1/4 := by
        rw [show (1/4:ℝ) = Real.sqrt (1/16) by
          rw [show (1/16:ℝ) = (1/4)^2 by norm_num, Real.sqrt_sq (by norm_num)]]
        exact Real.sqrt_le_sqrt hε1
      have hmR : (1:ℝ) ≤ m := by exact_mod_cast hm
      have hxle : (x:ℝ) ≤ 2 * m * Real.sqrt ε := Nat.floor_le (by positivity)
      have hxge : 2 * m * Real.sqrt ε - 1 < x := Nat.sub_one_lt_floor _
      have hxm : x ≤ m := by
        have : (x:ℝ) ≤ m := by nlinarith
        exact_mod_cast this
      obtain ⟨S, -, hS⟩ := Finset.exists_subset_card_eq
        (s := (Finset.univ : Finset (Fin (m*2)))) (n := m + x) (by simp; omega)
      have hCc : (Finset.univ.filter (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S ∧ w 1 ∈ Sᶜ)).card
          = (m + x) * (m - x) := by
        rw [in1283_card_prod, Finset.card_compl, hS, Fintype.card_fin,
          show m * 2 - (m + x) = m - x by omega]
      have h4 : (2 * m * Real.sqrt ε) * (2 * m * Real.sqrt ε) = 4 * m ^ 2 * ε := by
        calc (2 * m * Real.sqrt ε) * (2 * m * Real.sqrt ε) = 4 * m ^ 2 * (Real.sqrt ε ^ 2) := by
              ring
          _ = 4 * m ^ 2 * ε := by rw [hsq]
      have hx0 : (0:ℝ) ≤ x := by positivity
      have hxx := mul_le_mul hxle hxle hx0 (by positivity)
      refine ⟨Finset.univ.filter (fun w => w 0 ∈ S ∧ w 1 ∈ Sᶜ), ?_, ?_, ?_⟩
  12. The constructed code C is non-overlapping and satisfies |C| ≥ (1/4 - ε)(2m)². automation

    Every codeword u ∈ C has u(0) ∈ S and u(1) ∉ S, so u(0) ≠ v(1) for any u, v ∈ C, verifying the non-overlapping property. Its cardinality is (m + x)(m - x) = m² - x²; since x² ≤ 4m²ε, we have |C| ≥ m² - 4m²ε = (1/4 - ε)(2m)², verified by nlinarith.

    lines 224–230

    uses Nat.cast_sub

      · intro u hu v hv he
        simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_compl] at hu hv
        exact hv.2 (he ▸ hu.1)
      · rw [hCc]
        push_cast [Nat.cast_sub hxm]
        nlinarith
      · rintro B ⟨I, hI, hB⟩
  13. For every optimal Blackburn code B, the intersection |C ∩ B| is at most m(m - x).

    Any optimal code B is of the form I × Iᶜ or Iᶜ × I for some I of size m, having cardinality m² by in1283_card_B1 or in1283_card_B2. In either case, the codewords in C ∩ B have first symbol in a set of size m and second symbol in Sᶜ of size m - x. By Finset.card_le_card and in1283_card_prod, |C ∩ B| ≤ m(m - x).

    lines 231–262

    uses in1283_card_B1, in1283_card_B2, Finset.card_le_card, in1283_card_prod, Finset.card_compl, Fintype.card_fin, in1283_symm, Nat.cast_sub, Nat.cast_mul

        have hIc : I.card = m := by omega
        set C := Finset.univ.filter (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S ∧ w 1 ∈ Sᶜ)
        have hBc : B.card = m * m := by
          rcases hB with rfl | rfl
          · rw [in1283_card_B1, hIc, show m * 2 - m = m by omega]
          · rw [in1283_card_B2, hIc, show m * 2 - m = m by omega]
        have hCB : (C ∩ B).card ≤ m * (m - x) := by
          rcases hB with rfl | rfl
          · refine (Finset.card_le_card (t := Finset.univ.filter
              (fun w : Fin 2 → Fin (m*2) => w 0 ∈ I ∧ w 1 ∈ Sᶜ)) ?_).trans ?_
            · intro w hw
              simp only [C, Finset.mem_inter, Finset.mem_filter, Finset.mem_univ, true_and] at hw ⊢
              exact ⟨hw.2.1, hw.1.2⟩
            · rw [in1283_card_prod, Finset.card_compl, hS, hIc, Fintype.card_fin,
                show m * 2 - (m + x) = m - x by omega]
          · refine (Finset.card_le_card (t := Finset.univ.filter
              (fun w : Fin 2 → Fin (m*2) => w 0 ∈ Iᶜ ∧ w 1 ∈ Sᶜ)) ?_).trans ?_
            · intro w hw
              simp only [C, Finset.mem_inter, Finset.mem_filter, Finset.mem_univ, true_and,
                Finset.mem_compl] at hw ⊢
              exact ⟨hw.2.1, hw.1.2⟩
            · rw [in1283_card_prod, Finset.card_compl, Finset.card_compl, hS, hIc,
                Fintype.card_fin, show m * 2 - (m + x) = m - x by omega,
                show m * 2 - m = m by omega]
        have hid := in1283_symm C B
        have hid' : ((symmDiff C B).card : ℝ) + 2 * (C ∩ B).card = C.card + B.card := by
          exact_mod_cast hid
        rw [hCc, hBc] at hid'
        push_cast [Nat.cast_sub hxm] at hid'
        have hCB' : ((C ∩ B).card : ℝ) ≤ m * (m - x) := by
          have : ((C ∩ B).card : ℝ) ≤ ((m * (m - x) : ℕ) : ℝ) := by exact_mod_cast hCB
          rwa [Nat.cast_mul, Nat.cast_sub hxm] at this
  14. The normalized distance |C Δ B| / (2m)² is at least (√ε - 1/(2m))(1 - √ε).

    Using |C Δ B| = |C| + |B| - 2|C ∩ B| ≥ (m² - x²) + m² - 2m(m - x) = x(2m - x), we substitute the lower bounds x > 2m√ε - 1 and 2m - x ≥ 2m(1 - √ε). Multiplying these via mul_le_mul and rewriting through le_div_iff₀ establishes that |C Δ B| / (2m)² ≥ (√ε - 1/(2m))(1 - √ε).

    lines 263–286

    uses le_div_iff₀, le_or_gt, mul_le_mul, mul_nonneg, mul_assoc, mul_nonpos_of_nonpos_of_nonneg

        have hm0 : (0:ℝ) < m := by linarith
        rw [le_div_iff₀ (by positivity)]
        have hL : (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε) * (((m * 2 : ℕ) : ℝ)) ^ 2
            = (2 * m * Real.sqrt ε - 1) * (1 - Real.sqrt ε) * (2 * m) := by
          push_cast
          field_simp
        rw [hL]
        have hD : (x:ℝ) * (2 * m - x) ≤ (symmDiff C B).card := by nlinarith
        have h2mx : 2 * m * (1 - Real.sqrt ε) ≤ 2 * m - x := by nlinarith
        have hxmR : (x:ℝ) ≤ m := by exact_mod_cast hxm
        rcases le_or_gt 0 (2 * m * Real.sqrt ε - 1) with hp | hn
        · have h5 := mul_le_mul hxge.le h2mx (by nlinarith) hx0
          calc (2 * m * Real.sqrt ε - 1) * (1 - Real.sqrt ε) * (2 * m)
              = (2 * m * Real.sqrt ε - 1) * (2 * m * (1 - Real.sqrt ε)) := by ring
            _ ≤ x * (2 * m - x) := h5
            _ ≤ _ := hD
        · have h6 : 0 ≤ (1 - Real.sqrt ε) * (2 * m) := by
            apply mul_nonneg <;> linarith
          have h7 : (2 * m * Real.sqrt ε - 1) * (1 - Real.sqrt ε) * (2 * m) ≤ 0 := by
            rw [mul_assoc]; exact mul_nonpos_of_nonpos_of_nonneg hn.le h6
          have h8 : 0 ≤ (x:ℝ) * (2 * m - x) := by
            apply mul_nonneg hx0; linarith
          linarith
    
  15. Introduce the parameters of the problem and evaluate the capacity constant c_2 = 1/4.

    We introduce the local variables representing n = 2, λ = 1/2, c_2 = (1/2)¹ / 2 = 1/4, the target constant K_2 = 1, and the definitions of non-overlapping codes, optimal codes, code distance, max distance, and asymptotic limit M(ε). We evaluate c_2 = 1/4 by arithmetic normalization.

    lines 287–309

    /-- The sharp stability modulus holds for length-2 non-overlapping codes with constant K_2 = 1. -/
    theorem op2468_blackburn_stability_case_n_two :
        let n : ℕ := 2
        let lam : ℝ := (2 - 1 : ℝ) / 2
        let c_2 : ℝ := lam ^ (2 - 1) / (2 : ℝ)
        let K_2 : ℝ := 1
        let is_nonoverlapping (q : ℕ) (C : Finset (Fin 2 → Fin q)) : Prop :=
          ∀ u ∈ C, ∀ v ∈ C, ¬ ∃ (k : ℕ) (_ : 0 < k) (_ : k < 2),
            ∀ i : Fin k, u ⟨i.val, by omega⟩ = v ⟨2 - k + i.val, by omega⟩
        let optimal_blackburn (q : ℕ) : Set (Finset (Fin 2 → Fin q)) :=
          { B | ∃ (I : Finset (Fin q)), 2 * I.card = q ∧
            (B = Finset.filter (fun w => w ⟨0, by omega⟩ ∈ I ∧ w ⟨1, by omega⟩ ∉ I) Finset.univ ∨
             B = Finset.filter (fun w => w ⟨0, by omega⟩ ∉ I ∧ w ⟨1, by omega⟩ ∈ I) Finset.univ) }
        let code_dist (q : ℕ) (C : Finset (Fin 2 → Fin q)) : ℝ :=
          sInf { ((symmDiff C B).card : ℝ) / (q : ℝ) ^ 2 | B ∈ optimal_blackburn q }
        let max_dist (q : ℕ) (ε : ℝ) : ℝ :=
          sSup { d | ∃ C : Finset (Fin 2 → Fin q),
            is_nonoverlapping q C ∧ (c_2 - ε) * (q : ℝ) ^ 2 ≤ C.card ∧ d = code_dist q C }
        let M (ε : ℝ) : ℝ :=
          Filter.limsup (fun m : ℕ => max_dist (m * 2) ε) Filter.atTop
        Filter.Tendsto (fun ε => M ε / Real.sqrt ε) (nhdsWithin (0 : ℝ) (Set.Ioi 0)) (nhds K_2) := by
      intro n lam c_2 K_2 is_nonoverlapping optimal_blackburn code_dist max_dist M
      have hc2 : c_2 = 1/4 := by simp only [c_2, lam]; norm_num
  16. Every valid non-overlapping code C satisfies code_dist(2m, C) ≤ ε + √ε.

    For length 2, the non-overlapping property simplifies to u(0) ≠ v(1) for all u, v ∈ C. Applying the upper bound lemma in1283_upper produces an optimal Blackburn code B with normalized symmetric difference at most ε + √ε. Since code_dist is the infimum over all optimal codes, csInf_le and le_trans establish code_dist(2m, C) ≤ ε + √ε.

    lines 310–334

    uses Real.sqrt_nonneg, Real.sq_sqrt, Real.sInf_nonneg, in1283_upper, le_trans, csInf_le

      have hMb : ∀ ε : ℝ, 0 < ε → ε ≤ 1/16 →
          Real.sqrt ε - ε ≤ M ε ∧ M ε ≤ Real.sqrt ε + ε := by
        intro ε hε hε1
        have hs0 := Real.sqrt_nonneg ε
        have hsq := Real.sq_sqrt hε.le
        have hcd0 : ∀ q (C : Finset (Fin 2 → Fin q)), 0 ≤ code_dist q C := by
          intro q C
          apply Real.sInf_nonneg
          rintro _ ⟨B, -, rfl⟩
          positivity
        have hup : ∀ m : ℕ, 1 ≤ m → ∀ d ∈ {d | ∃ C : Finset (Fin 2 → Fin (m*2)),
            is_nonoverlapping (m*2) C ∧ (c_2 - ε) * ((m*2 : ℕ) : ℝ) ^ 2 ≤ C.card ∧
              d = code_dist (m*2) C}, d ≤ ε + Real.sqrt ε := by
          rintro m hm _ ⟨C, hC, hcard, rfl⟩
          rw [hc2] at hcard
          have hdis : ∀ u ∈ C, ∀ v ∈ C, u 0 ≠ v 1 := by
            intro u hu v hv he
            apply hC u hu v hv
            refine ⟨1, by norm_num, by norm_num, fun i => ?_⟩
            fin_cases i
            simpa using he
          obtain ⟨B, hB, hle⟩ := in1283_upper m hm ε hε C hdis hcard
          refine le_trans (csInf_le ⟨0, ?_⟩ ⟨B, hB, rfl⟩) hle
          rintro _ ⟨B, -, rfl⟩
          positivity
  17. For all m ≥ 1, (√ε - 1/(2m))(1 - √ε) ≤ max_dist(2m, ε) ≤ ε + √ε.

    The code C constructed in in1283_lower is non-overlapping and large enough, with distance at least (√ε - 1/(2m))(1 - √ε) to every optimal code by le_csInf. Taking the supremum over all such codes using le_csSup and csSup_le establishes the two-sided bounds on max_dist(2m, ε).

    lines 335–360

    uses in1283_lower, Finset.exists_subset_card_eq, le_csInf, le_csSup, csSup_le

        have hmd : ∀ m : ℕ, 1 ≤ m →
            (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε) ≤ max_dist (m*2) ε ∧
            0 ≤ max_dist (m*2) ε ∧ max_dist (m*2) ε ≤ ε + Real.sqrt ε := by
          intro m hm
          obtain ⟨C, hC, hcard, hlb⟩ := in1283_lower m hm ε hε hε1
          have hC' : is_nonoverlapping (m*2) C := by
            rintro u hu v hv ⟨k, hk0, hk2, hk⟩
            obtain rfl : k = 1 := by omega
            exact hC u hu v hv (by simpa using hk ⟨0, by norm_num⟩)
          have hcard' : (c_2 - ε) * ((m*2 : ℕ) : ℝ) ^ 2 ≤ C.card := by rw [hc2]; exact hcard
          have hmem : code_dist (m*2) C ∈ {d | ∃ C : Finset (Fin 2 → Fin (m*2)),
              is_nonoverlapping (m*2) C ∧ (c_2 - ε) * ((m*2 : ℕ) : ℝ) ^ 2 ≤ C.card ∧
                d = code_dist (m*2) C} := ⟨C, hC', hcard', rfl⟩
          have hbdd : BddAbove {d | ∃ C : Finset (Fin 2 → Fin (m*2)),
              is_nonoverlapping (m*2) C ∧ (c_2 - ε) * ((m*2 : ℕ) : ℝ) ^ 2 ≤ C.card ∧
                d = code_dist (m*2) C} := ⟨ε + Real.sqrt ε, hup m hm⟩
          obtain ⟨I, -, hI⟩ := Finset.exists_subset_card_eq
            (s := (Finset.univ : Finset (Fin (m*2)))) (n := m) (by simp; omega)
          have hcdl : (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε) ≤ code_dist (m*2) C := by
            apply le_csInf
            · exact ⟨_, ⟨Finset.univ.filter (fun w => w 0 ∈ I ∧ w 1 ∉ I),
                ⟨I, by omega, Or.inl rfl⟩, rfl⟩⟩
            · rintro _ ⟨B, hB, rfl⟩
              exact hlb B hB
          refine ⟨hcdl.trans (le_csSup hbdd hmem), (hcd0 _ C).trans (le_csSup hbdd hmem),
            csSup_le ⟨_, hmem⟩ (hup m hm)⟩
  18. For any ε ∈ (0, 1/16], the asymptotic distance M(ε) satisfies √ε - ε ≤ M(ε) ≤ √ε + ε.

    The sequence max_dist(2m, ε) is bounded under Filter.atTop via Filter.isBoundedUnder_of_eventually_le and Filter.isCoboundedUnder_le_of_eventually_le. As m → ∞, 1/(2m) → 0 by tendsto_const_div_atTop_nhds_zero_nat, so the lower bound converges to √ε(1 - √ε) = √ε - ε. Taking limsup via Filter.limsup_le_limsup and Filter.limsup_le_of_le sandwiches M(ε) between √ε - ε and √ε + ε.

    lines 361–389

    uses Filter.eventually_atTop, Filter.isBoundedUnder_of_eventually_le, Filter.isCoboundedUnder_le_of_eventually_le, tendsto_const_div_atTop_nhds_zero_nat, sub_zero, div_div, Filter.limsup_le_limsup, mul_sub, mul_one, Real.mul_self_sqrt, Filter.limsup_le_of_le

        have hev : ∀ᶠ m : ℕ in Filter.atTop,
            (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε) ≤ max_dist (m*2) ε ∧
            0 ≤ max_dist (m*2) ε ∧ max_dist (m*2) ε ≤ ε + Real.sqrt ε :=
          Filter.eventually_atTop.2 ⟨1, fun m hm => hmd m hm⟩
        have hbu : Filter.IsBoundedUnder (· ≤ ·) Filter.atTop (fun m : ℕ => max_dist (m*2) ε) :=
          Filter.isBoundedUnder_of_eventually_le (hev.mono fun m h => h.2.2)
        have hcb : Filter.IsCoboundedUnder (· ≤ ·) Filter.atTop
            (fun m : ℕ => max_dist (m*2) ε) :=
          Filter.isCoboundedUnder_le_of_eventually_le Filter.atTop (hev.mono fun m h => h.2.1)
        have hg : Filter.Tendsto (fun m : ℕ => (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε))
            Filter.atTop (nhds (Real.sqrt ε * (1 - Real.sqrt ε))) := by
          have h0 : Filter.Tendsto (fun m : ℕ => (1/2 : ℝ) / (m : ℝ)) Filter.atTop (nhds 0) :=
            tendsto_const_div_atTop_nhds_zero_nat (1/2)
          have h1 := (h0.const_sub (Real.sqrt ε)).mul_const (1 - Real.sqrt ε)
          simp only [sub_zero] at h1
          refine h1.congr (fun m => ?_)
          congr 2
          rw [div_div]
        constructor
        · have hl := Filter.limsup_le_limsup (hev.mono fun m h => h.1)
            hg.isCoboundedUnder_le hbu
          rw [hg.limsup_eq] at hl
          have : Real.sqrt ε * (1 - Real.sqrt ε) = Real.sqrt ε - ε := by
            rw [mul_sub, mul_one, Real.mul_self_sqrt hε.le]
          rw [this] at hl
          exact hl
        · have := Filter.limsup_le_of_le hcb (hev.mono fun m h => h.2.2)
          show Filter.limsup (fun m : ℕ => max_dist (m * 2) ε) Filter.atTop ≤ Real.sqrt ε + ε
          linarith
  19. The normalized stability ratio M(ε) / √ε tends to K_2 = 1 as ε → 0⁺. automation

    Since √ε → 0 as ε → 0⁺ by Real.continuous_sqrt, dividing the bounds √ε - ε ≤ M(ε) ≤ √ε + ε by √ε > 0 (using Real.sqrt_pos, le_div_iff₀, and div_le_iff₀) shows 1 - √ε ≤ M(ε)/√ε ≤ 1 + √ε. Both bounding functions tend to 1, so the squeeze theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' concludes that M(ε) / √ε → 1 = K_2.

    lines 390–414

    uses Real.continuous_sqrt, nhdsWithin_le_nhds, self_mem_nhdsWithin, Iic_mem_nhds, tendsto_of_tendsto_of_tendsto_of_le_of_le', Real.sqrt_pos, Real.mul_self_sqrt, le_div_iff₀, div_le_iff₀

      have hlim : Filter.Tendsto (fun ε : ℝ => Real.sqrt ε) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by
        have := (Real.continuous_sqrt.tendsto 0).mono_left
          (nhdsWithin_le_nhds (s := Set.Ioi (0:ℝ)))
        simpa using this
      have hev : ∀ᶠ ε in nhdsWithin (0:ℝ) (Set.Ioi 0), 0 < ε ∧ ε ≤ 1/16 := by
        filter_upwards [self_mem_nhdsWithin,
          nhdsWithin_le_nhds (Iic_mem_nhds (by norm_num : (0:ℝ) < 1/16))] with ε h1 h2
        exact ⟨h1, h2⟩
      have h1 : Filter.Tendsto (fun ε : ℝ => 1 - Real.sqrt ε) (nhdsWithin 0 (Set.Ioi 0))
          (nhds 1) := by simpa using hlim.const_sub 1
      have h2 : Filter.Tendsto (fun ε : ℝ => 1 + Real.sqrt ε) (nhdsWithin 0 (Set.Ioi 0))
          (nhds 1) := by simpa using hlim.const_add 1
      refine tendsto_of_tendsto_of_tendsto_of_le_of_le' h1 h2 ?_ ?_
      · filter_upwards [hev] with ε hε
        obtain ⟨hl, -⟩ := hMb ε hε.1 hε.2
        have hs : 0 < Real.sqrt ε := Real.sqrt_pos.2 hε.1
        have hm := Real.mul_self_sqrt hε.1.le
        rw [le_div_iff₀ hs]
        nlinarith
      · filter_upwards [hev] with ε hε
        obtain ⟨-, hu⟩ := hMb ε hε.1 hε.2
        have hs : 0 < Real.sqrt ε := Real.sqrt_pos.2 hε.1
        have hm := Real.mul_self_sqrt hε.1.le
        rw [div_le_iff₀ hs]
        nlinarith
Finset.card_product
The cardinality of the Cartesian product of two finite sets is the product of their cardinalities: |s × t| = |s| * |t|.
Finset.card_nbij'
Two finite sets have equal cardinality if there are explicit mappings between them that are inverse to each other on their domains.
in1283_card_prod
The set of length-2 words with first symbol in X and second in Y has cardinality |X| * |Y|.
Finset.card_compl
The cardinality of the complement of a subset s in a finite universe is the size of the universe minus |s|.
Fintype.card_fin
The cardinality of the finite type Fin n is n.
in1283_card_B1
The optimal Blackburn code B_1(I) = {w | w(0) ∈ I ∧ w(1) ∉ I} has cardinality |I| * (q - |I|).
in1283_card_B2
The optimal Blackburn code B_2(I) = {w | w(0) ∉ I ∧ w(1) ∈ I} has cardinality (q - |I|) * |I|.
symmDiff_def
The symmetric difference of two sets is the union of their mutual set differences: a Δ b = (a \ b) ∪ (b \ a).
Finset.sup_eq_union
For finite sets, the join operation is set union.
Finset.card_union_of_disjoint
The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
disjoint_sdiff_sdiff
The relative complements a \ b and b \ a are disjoint.
Finset.card_sdiff_add_card_inter
For any finite sets s and t, |s \ t| + |s ∩ t| = |s|.
Finset.inter_comm
Intersection of finite sets is commutative: s ∩ t = t ∩ s.
Real.sq_sqrt
For any non-negative real number x, the square of its square root is x.
mul_le_mul_of_nonneg_left
Multiplying an inequality on the left by a non-negative number preserves the inequality.
Finset.disjoint_left
Two finite sets are disjoint if and only if no element of the first belongs to the second.
Finset.card_le_univ
The cardinality of any finite subset of a finite type is at most the cardinality of the full type.
Finset.card_le_card
A subset has cardinality at most that of the superset: s ⊆ t implies |s| ≤ |t|.
Real.sqrt_nonneg
The square root of any real number is non-negative.
in1283_symm
For any finite sets C and B, |C Δ B| + 2|C ∩ B| = |C| + |B|.
div_le_iff₀
Dividing by a positive real preserves inequality direction: b / c ≤ a if and only if b ≤ a * c.
Finset.exists_subset_card_eq
If n ≤ |s|, there exists a subset of s of cardinality n.
Finset.card_sdiff_of_subset
If s ⊆ t, then |t \ s| = |t| - |s|.
in1283_dev
If x + y ≤ 2m, m ≤ x, and xy ≥ (1/4 - ε)(2m)², then x - m ≤ 2m√ε.
Nat.cast_mul
Coercion of a product of natural numbers into a ring equals the product of the coercions.
Nat.cast_sub
Coercion of a difference n - m of natural numbers with m ≤ n equals the difference of the coercions.
mul_le_mul
The product of non-negative inequalities is an inequality: if a ≤ b and c ≤ d with c, b non-negative, then ac ≤ bd.
Nat.mul_comm
Multiplication of natural numbers is commutative: n * m = m * n.
Finset.mem_compl
An element belongs to the complement of a finite set if and only if it does not belong to the set.
Finset.exists_subsuperset_card_eq
If s ⊆ t and |s| ≤ n ≤ |t|, there exists an intermediate subset u with s ⊆ u ⊆ t and |u| = n.
le_of_eq
Equality implies weak inequality.
Finset.card_eq_zero
A finite set has cardinality 0 if and only if it is empty.
Finset.sdiff_eq_empty_iff_subset
The set difference s \ t is empty if and only if s is a subset of t.
Real.sqrt_sq
For non-negative real x, √(x²) = x.
Real.sqrt_le_sqrt
The real square root function is monotone: x ≤ y implies √x ≤ √y.
Nat.floor_le
The floor of a non-negative real is at most the number itself: ⌊a⌋₊ ≤ a.
Nat.sub_one_lt_floor
For any real number a, a - 1 < ⌊a⌋₊.
le_or_gt
In a linear order, every two elements satisfy a ≤ b or b < a.
mul_nonneg
The product of two non-negative numbers is non-negative.
mul_assoc
Multiplication is associative: (a * b) * c = a * (b * c).
mul_nonpos_of_nonpos_of_nonneg
The product of a non-positive number and a non-negative number is non-positive.
le_div_iff₀
A lower bound to a quotient: for positive c, a ≤ b / c if and only if a * c ≤ b.
Real.sInf_nonneg
If every element of a set of real numbers is non-negative, its infimum is non-negative.
in1283_upper
Any length-2 non-overlapping code of size at least (1/4 - ε)(2m)² is within normalized distance ε + √ε from some optimal Blackburn code.
le_trans
Inequality is transitive: a ≤ b and b ≤ c imply a ≤ c.
csInf_le
The infimum of a set bounded below is less than or equal to any element of the set.
in1283_lower
For ε ≤ 1/16, there exists a length-2 non-overlapping code of size at least (1/4 - ε)(2m)² at normalized distance at least (√ε - 1/(2m))(1 - √ε) from every optimal Blackburn code.
le_csInf
If a real number a is a lower bound for a nonempty set, it is at most the infimum of the set.
le_csSup
Any element of a set bounded above is at most the supremum of the set.
csSup_le
If a is an upper bound for a nonempty set, the supremum of the set is at most a.
Filter.eventually_atTop
A predicate holds eventually along atTop on ℕ if and only if it holds for all sufficiently large n.
Filter.isBoundedUnder_of_eventually_le
A sequence is bounded under ≤ along a filter if it is eventually bounded above by a constant.
Filter.isCoboundedUnder_le_of_eventually_le
A sequence is cobounded under ≤ along a filter if it is eventually bounded below by a constant.
tendsto_const_div_atTop_nhds_zero_nat
For any constant C, C / n tends to 0 as n tends to infinity along atTop.
sub_zero
Subtracting zero leaves a number unchanged: a - 0 = a.
div_div
Iterated division satisfies (x / a) / b = x / (a * b).
Filter.limsup_le_limsup
If u ≤ v eventually along a filter, then limsup u ≤ limsup v.
mul_sub
Left distributivity of multiplication over subtraction: a * (b - c) = a * b - a * c.
mul_one
Multiplying by one leaves an element unchanged: a * 1 = a.
Real.mul_self_sqrt
For non-negative x, √x * √x = x.
Filter.limsup_le_of_le
If a sequence is eventually bounded above by a constant, its limsup is at most that constant.
Real.continuous_sqrt
The real square root function is continuous.
nhdsWithin_le_nhds
The neighborhood filter restricted to a subset is smaller than the ambient neighborhood filter.
self_mem_nhdsWithin
A set s is a neighborhood of a in the restricted topology on s.
Iic_mem_nhds
For b < a, the closed lower ray (-∞, a] is a neighborhood of b.
tendsto_of_tendsto_of_tendsto_of_le_of_le'
The squeeze theorem: if g ≤ f ≤ h eventually and g, h tend to the same limit, then f tends to that limit.
Real.sqrt_pos
For any real x, √x > 0 if and only if x > 0.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

lemma in1283_card_prod {q : ℕ} (X Y : Finset (Fin q)) :    (Finset.univ.filter (fun w : Fin 2 → Fin q => w 0 ∈ X ∧ w 1 ∈ Y)).card      = X.card * Y.card := by  rw [← Finset.card_product]  refine Finset.card_nbij' (fun w => (w 0, w 1)) (fun p => ![p.1, p.2]) ?_ ?_ ?_ ?_  · intro w hw    simp only [Finset.coe_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq,      Finset.coe_product, Set.mem_prod, Finset.mem_coe] at hw ⊢    exact hw  · intro p hp    simp only [Finset.coe_filter, Finset.mem_univ, true_and, Set.mem_ofPred_eq,      Finset.coe_product, Set.mem_prod, Finset.mem_coe] at hp ⊢    simpa using hp  · intro w _    funext i    fin_cases i <;> rfl  · intro p _    rfllemma in1283_card_B1 {q : ℕ} (I : Finset (Fin q)) :    (Finset.univ.filter (fun w : Fin 2 → Fin q => w 0 ∈ I ∧ w 1 ∉ I)).card      = I.card * (q - I.card) := by  have h := in1283_card_prod I Iᶜ  rw [Finset.card_compl, Fintype.card_fin] at h  rw [← h]  congr 1  ext w  simplemma in1283_card_B2 {q : ℕ} (I : Finset (Fin q)) :    (Finset.univ.filter (fun w : Fin 2 → Fin q => w 0 ∉ I ∧ w 1 ∈ I)).card      = (q - I.card) * I.card := by  have h := in1283_card_prod Iᶜ I  rw [Finset.card_compl, Fintype.card_fin] at h  rw [← h]  congr 1  ext w  simplemma in1283_symm {α : Type*} [DecidableEq α] (C B : Finset α) :    (symmDiff C B).card + 2 * (C ∩ B).card = C.card + B.card := by  rw [symmDiff_def, Finset.sup_eq_union, Finset.card_union_of_disjoint disjoint_sdiff_sdiff]  have h1 := Finset.card_sdiff_add_card_inter C B  have h2 := Finset.card_sdiff_add_card_inter B C  rw [Finset.inter_comm] at h2  omegalemma in1283_dev (m : ℕ) (ε : ℝ) (hε : 0 < ε) (cC x y : ℕ) (hxy : x + y ≤ m * 2)    (hC : cC ≤ x * y) (hmx : m ≤ x)    (hcard : (1/4 - ε) * ((m*2 : ℕ) : ℝ)^2 ≤ cC) :    ((x:ℝ) - m) ≤ 2 * Real.sqrt ε * m := by  have hsq := Real.sq_sqrt hε.le  have hxyR : (x:ℝ) + y ≤ m*2 := by exact_mod_cast hxy  have hCR : (cC:ℝ) ≤ x*y := by exact_mod_cast hC  have hmxR : (m:ℝ) ≤ x := by exact_mod_cast hmx  push_cast at hcard  have hy : (0:ℝ) ≤ y := by positivity  have hx : (0:ℝ) ≤ x := by positivity  have h4 : (2 * Real.sqrt ε * m) ^ 2 = 4 * ε * m ^ 2 := by    calc (2 * Real.sqrt ε * m) ^ 2 = 4 * (Real.sqrt ε ^ 2) * m ^ 2 := by ring      _ = 4 * ε * m ^ 2 := by rw [hsq]  have hxy2 : (x:ℝ) * y ≤ x * (m * 2 - x) := by    apply mul_le_mul_of_nonneg_left _ hx    linarith  have hsq' : ((x:ℝ) - m) ^ 2 ≤ (2 * Real.sqrt ε * m) ^ 2 := by    rw [h4]; nlinarith  have hpos : 0 ≤ 2 * Real.sqrt ε * m := by positivity  nlinarithlemma in1283_upper (m : ℕ) (hm : 1 ≤ m) (ε : ℝ) (hε : 0 < ε)    (C : Finset (Fin 2 → Fin (m*2)))    (hdis : ∀ u ∈ C, ∀ v ∈ C, u 0 ≠ v 1)    (hcard : (1/4 - ε) * ((m*2 : ℕ) : ℝ)^2 ≤ C.card) :    ∃ B : Finset (Fin 2 → Fin (m*2)), (∃ I : Finset (Fin (m*2)), 2 * I.card = m*2 ∧        (B = Finset.univ.filter (fun w => w 0 ∈ I ∧ w 1 ∉ I) ∨         B = Finset.univ.filter (fun w => w 0 ∉ I ∧ w 1 ∈ I))) ∧      ((symmDiff C B).card : ℝ) / ((m*2 : ℕ) : ℝ)^2 ≤ ε + Real.sqrt ε := by  classical  set S0 := C.image (fun w => w 0) with hS0  set S1 := C.image (fun w => w 1) with hS1  have hdisj : Disjoint S0 S1 := by    rw [Finset.disjoint_left]    intro x hx hx'    simp only [S0, S1, Finset.mem_image] at hx hx'    obtain ⟨u, hu, rfl⟩ := hx    obtain ⟨v, hv, hv'⟩ := hx'    exact hdis u hu v hv hv'.symm  have hab : S0.card + S1.card ≤ m*2 := by    rw [← Finset.card_union_of_disjoint hdisj]    simpa using Finset.card_le_univ (S0 ∪ S1)  have hCsub : C ⊆ Finset.univ.filter      (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S0 ∧ w 1 ∈ S1) := by    intro w hw    simp only [Finset.mem_filter, Finset.mem_univ, true_and]    exact ⟨Finset.mem_image_of_mem _ hw, Finset.mem_image_of_mem _ hw⟩  have hCab : C.card ≤ S0.card * S1.card :=    (Finset.card_le_card hCsub).trans (in1283_card_prod S0 S1).le  have hs0 := Real.sqrt_nonneg ε  have hmR : (1:ℝ) ≤ m := by exact_mod_cast hm  have key : ∀ (B : Finset (Fin 2 → Fin (m*2))) (E : ℕ), B.card = m*m →      (C \ B).card ≤ E → (E : ℝ) ≤ 2 * Real.sqrt ε * m * m →      ((symmDiff C B).card : ℝ) / ((m*2 : ℕ) : ℝ)^2 ≤ ε + Real.sqrt ε := by    intro B E hB hE hER    have h1 := in1283_symm C B    have h2 := Finset.card_sdiff_add_card_inter C B    have h3 : (symmDiff C B).card + C.card = m*m + 2 * (C \ B).card := by omega    have h3' : ((symmDiff C B).card : ℝ) + C.card = m*m + 2 * (C \ B).card := by      exact_mod_cast h3    have hE' : ((C \ B).card : ℝ) ≤ E := by exact_mod_cast hE    rw [div_le_iff₀ (by positivity)]    push_cast at hcard ⊢    nlinarith  by_cases ha : m ≤ S0.card  · obtain ⟨I, hIS, hIc⟩ := Finset.exists_subset_card_eq ha    refine ⟨_, ⟨I, by omega, Or.inl rfl⟩, ?_⟩    apply key _ ((S0.card - m) * S1.card)    · rw [in1283_card_B1, hIc, show m * 2 - m = m by omega]    · refine (Finset.card_le_card (t := Finset.univ.filter          (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S0 \ I ∧ w 1 ∈ S1)) ?_).trans        (by rw [in1283_card_prod, Finset.card_sdiff_of_subset hIS, hIc])      intro w hw      simp only [Finset.mem_sdiff, Finset.mem_filter, Finset.mem_univ, true_and, not_and,        not_not] at hw ⊢      obtain ⟨hwC, hwB⟩ := hw      have h0 : w 0 ∈ S0 := Finset.mem_image_of_mem _ hwC      have h1 : w 1 ∈ S1 := Finset.mem_image_of_mem _ hwC      have h1' : w 1 ∉ I := fun h => Finset.disjoint_left.1 hdisj (hIS h) h1      exact ⟨⟨h0, fun h => h1' (hwB h)⟩, h1⟩    · have hb : S1.card ≤ m := by omega      have hx := in1283_dev m ε hε C.card S0.card S1.card hab hCab ha hcard      rw [Nat.cast_mul, Nat.cast_sub ha]      have hbR : (S1.card : ℝ) ≤ m := by exact_mod_cast hb      have : (0:ℝ) ≤ S0.card - m := by        have : (m:ℝ) ≤ S0.card := by exact_mod_cast ha        linarith      calc ((S0.card:ℝ) - m) * S1.card ≤ (2 * Real.sqrt ε * m) * m :=            mul_le_mul hx hbR (by positivity) (by positivity)        _ = _ := by ring  by_cases hb : m ≤ S1.card  · obtain ⟨I, hIS, hIc⟩ := Finset.exists_subset_card_eq hb    refine ⟨_, ⟨I, by omega, Or.inr rfl⟩, ?_⟩    apply key _ (S0.card * (S1.card - m))    · rw [in1283_card_B2, hIc, show m * 2 - m = m by omega]    · refine (Finset.card_le_card (t := Finset.univ.filter          (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S0 ∧ w 1 ∈ S1 \ I)) ?_).trans        (by rw [in1283_card_prod, Finset.card_sdiff_of_subset hIS, hIc])      intro w hw      simp only [Finset.mem_sdiff, Finset.mem_filter, Finset.mem_univ, true_and,        not_and] at hw ⊢      obtain ⟨hwC, hwB⟩ := hw      have h0 : w 0 ∈ S0 := Finset.mem_image_of_mem _ hwC      have h1 : w 1 ∈ S1 := Finset.mem_image_of_mem _ hwC      have h0' : w 0 ∉ I := fun h => Finset.disjoint_left.1 hdisj h0 (hIS h)      exact ⟨h0, h1, hwB h0'⟩    · have hx := in1283_dev m ε hε C.card S1.card S0.card (by omega)        (by rw [Nat.mul_comm S1.card S0.card]; exact hCab) hb hcard      rw [Nat.cast_mul, Nat.cast_sub hb]      have haR : (S0.card : ℝ) ≤ m := by        have : S0.card ≤ m := by omega        exact_mod_cast this      have : (0:ℝ) ≤ S1.card - m := by        have : (m:ℝ) ≤ S1.card := by exact_mod_cast hb        linarith      calc (S0.card:ℝ) * (S1.card - m) ≤ m * (2 * Real.sqrt ε * m) :=            mul_le_mul haR hx this (by positivity)        _ = _ := by ring  · have hsub : S0 ⊆ S1ᶜ := by      intro x hx      rw [Finset.mem_compl]      exact Finset.disjoint_left.1 hdisj hx    obtain ⟨I, hI0, hI1, hIc⟩ := Finset.exists_subsuperset_card_eq hsub (n := m)      (by omega) (by rw [Finset.card_compl, Fintype.card_fin]; omega)    refine ⟨_, ⟨I, by omega, Or.inl rfl⟩, ?_⟩    apply key _ 0    · rw [in1283_card_B1, hIc, show m * 2 - m = m by omega]    · apply le_of_eq      rw [Finset.card_eq_zero, Finset.sdiff_eq_empty_iff_subset]      intro w hw      simp only [Finset.mem_filter, Finset.mem_univ, true_and]      have h0 : w 0 ∈ S0 := Finset.mem_image_of_mem _ hw      have h1 : w 1 ∈ S1 := Finset.mem_image_of_mem _ hw      refine ⟨hI0 h0, fun h => ?_⟩      have := hI1 h      rw [Finset.mem_compl] at this      exact this h1    · push_cast      positivitylemma in1283_lower (m : ℕ) (hm : 1 ≤ m) (ε : ℝ) (hε : 0 < ε) (hε1 : ε ≤ 1/16) :    ∃ C : Finset (Fin 2 → Fin (m*2)), (∀ u ∈ C, ∀ v ∈ C, u 0 ≠ v 1) ∧      (1/4 - ε) * ((m*2 : ℕ) : ℝ)^2 ≤ C.card ∧      ∀ B : Finset (Fin 2 → Fin (m*2)), (∃ I : Finset (Fin (m*2)), 2 * I.card = m*2 ∧        (B = Finset.univ.filter (fun w => w 0 ∈ I ∧ w 1 ∉ I) ∨         B = Finset.univ.filter (fun w => w 0 ∉ I ∧ w 1 ∈ I))) →      (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε)        ≤ ((symmDiff C B).card : ℝ) / ((m*2 : ℕ) : ℝ)^2 := by  classical  set x := ⌊2 * (m:ℝ) * Real.sqrt ε⌋₊ with hxdef  have hs0 := Real.sqrt_nonneg ε  have hsq := Real.sq_sqrt hε.le  have hs14 : Real.sqrt ε ≤ 1/4 := by    rw [show (1/4:ℝ) = Real.sqrt (1/16) by      rw [show (1/16:ℝ) = (1/4)^2 by norm_num, Real.sqrt_sq (by norm_num)]]    exact Real.sqrt_le_sqrt hε1  have hmR : (1:ℝ) ≤ m := by exact_mod_cast hm  have hxle : (x:ℝ) ≤ 2 * m * Real.sqrt ε := Nat.floor_le (by positivity)  have hxge : 2 * m * Real.sqrt ε - 1 < x := Nat.sub_one_lt_floor _  have hxm : x ≤ m := by    have : (x:ℝ) ≤ m := by nlinarith    exact_mod_cast this  obtain ⟨S, -, hS⟩ := Finset.exists_subset_card_eq    (s := (Finset.univ : Finset (Fin (m*2)))) (n := m + x) (by simp; omega)  have hCc : (Finset.univ.filter (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S ∧ w 1 ∈ Sᶜ)).card      = (m + x) * (m - x) := by    rw [in1283_card_prod, Finset.card_compl, hS, Fintype.card_fin,      show m * 2 - (m + x) = m - x by omega]  have h4 : (2 * m * Real.sqrt ε) * (2 * m * Real.sqrt ε) = 4 * m ^ 2 * ε := by    calc (2 * m * Real.sqrt ε) * (2 * m * Real.sqrt ε) = 4 * m ^ 2 * (Real.sqrt ε ^ 2) := by          ring      _ = 4 * m ^ 2 * ε := by rw [hsq]  have hx0 : (0:ℝ) ≤ x := by positivity  have hxx := mul_le_mul hxle hxle hx0 (by positivity)  refine ⟨Finset.univ.filter (fun w => w 0 ∈ S ∧ w 1 ∈ Sᶜ), ?_, ?_, ?_⟩  · intro u hu v hv he    simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_compl] at hu hv    exact hv.2 (he ▸ hu.1)  · rw [hCc]    push_cast [Nat.cast_sub hxm]    nlinarith  · rintro B ⟨I, hI, hB⟩    have hIc : I.card = m := by omega    set C := Finset.univ.filter (fun w : Fin 2 → Fin (m*2) => w 0 ∈ S ∧ w 1 ∈ Sᶜ)    have hBc : B.card = m * m := by      rcases hB with rfl | rfl      · rw [in1283_card_B1, hIc, show m * 2 - m = m by omega]      · rw [in1283_card_B2, hIc, show m * 2 - m = m by omega]    have hCB : (C ∩ B).card ≤ m * (m - x) := by      rcases hB with rfl | rfl      · refine (Finset.card_le_card (t := Finset.univ.filter          (fun w : Fin 2 → Fin (m*2) => w 0 ∈ I ∧ w 1 ∈ Sᶜ)) ?_).trans ?_        · intro w hw          simp only [C, Finset.mem_inter, Finset.mem_filter, Finset.mem_univ, true_and] at hw ⊢          exact ⟨hw.2.1, hw.1.2⟩        · rw [in1283_card_prod, Finset.card_compl, hS, hIc, Fintype.card_fin,            show m * 2 - (m + x) = m - x by omega]      · refine (Finset.card_le_card (t := Finset.univ.filter          (fun w : Fin 2 → Fin (m*2) => w 0 ∈ Iᶜ ∧ w 1 ∈ Sᶜ)) ?_).trans ?_        · intro w hw          simp only [C, Finset.mem_inter, Finset.mem_filter, Finset.mem_univ, true_and,            Finset.mem_compl] at hw ⊢          exact ⟨hw.2.1, hw.1.2⟩        · rw [in1283_card_prod, Finset.card_compl, Finset.card_compl, hS, hIc,            Fintype.card_fin, show m * 2 - (m + x) = m - x by omega,            show m * 2 - m = m by omega]    have hid := in1283_symm C B    have hid' : ((symmDiff C B).card : ℝ) + 2 * (C ∩ B).card = C.card + B.card := by      exact_mod_cast hid    rw [hCc, hBc] at hid'    push_cast [Nat.cast_sub hxm] at hid'    have hCB' : ((C ∩ B).card : ℝ) ≤ m * (m - x) := by      have : ((C ∩ B).card : ℝ) ≤ ((m * (m - x) : ℕ) : ℝ) := by exact_mod_cast hCB      rwa [Nat.cast_mul, Nat.cast_sub hxm] at this    have hm0 : (0:ℝ) < m := by linarith    rw [le_div_iff₀ (by positivity)]    have hL : (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε) * (((m * 2 : ℕ) : ℝ)) ^ 2        = (2 * m * Real.sqrt ε - 1) * (1 - Real.sqrt ε) * (2 * m) := by      push_cast      field_simp    rw [hL]    have hD : (x:ℝ) * (2 * m - x) ≤ (symmDiff C B).card := by nlinarith    have h2mx : 2 * m * (1 - Real.sqrt ε) ≤ 2 * m - x := by nlinarith    have hxmR : (x:ℝ) ≤ m := by exact_mod_cast hxm    rcases le_or_gt 0 (2 * m * Real.sqrt ε - 1) with hp | hn    · have h5 := mul_le_mul hxge.le h2mx (by nlinarith) hx0      calc (2 * m * Real.sqrt ε - 1) * (1 - Real.sqrt ε) * (2 * m)          = (2 * m * Real.sqrt ε - 1) * (2 * m * (1 - Real.sqrt ε)) := by ring        _ ≤ x * (2 * m - x) := h5        _ ≤ _ := hD    · have h6 : 0 ≤ (1 - Real.sqrt ε) * (2 * m) := by        apply mul_nonneg <;> linarith      have h7 : (2 * m * Real.sqrt ε - 1) * (1 - Real.sqrt ε) * (2 * m) ≤ 0 := by        rw [mul_assoc]; exact mul_nonpos_of_nonpos_of_nonneg hn.le h6      have h8 : 0 ≤ (x:ℝ) * (2 * m - x) := by        apply mul_nonneg hx0; linarith      linarith/-- The sharp stability modulus holds for length-2 non-overlapping codes with constant K_2 = 1. -/theorem op2468_blackburn_stability_case_n_two :    let n : ℕ := 2    let lam : ℝ := (2 - 1 : ℝ) / 2    let c_2 : ℝ := lam ^ (2 - 1) / (2 : ℝ)    let K_2 : ℝ := 1    let is_nonoverlapping (q : ℕ) (C : Finset (Fin 2 → Fin q)) : Prop :=      ∀ u ∈ C, ∀ v ∈ C, ¬ ∃ (k : ℕ) (_ : 0 < k) (_ : k < 2),        ∀ i : Fin k, u ⟨i.val, by omega⟩ = v ⟨2 - k + i.val, by omega⟩    let optimal_blackburn (q : ℕ) : Set (Finset (Fin 2 → Fin q)) :=      { B | ∃ (I : Finset (Fin q)), 2 * I.card = q ∧        (B = Finset.filter (fun w => w ⟨0, by omega⟩ ∈ I ∧ w ⟨1, by omega⟩ ∉ I) Finset.univ ∨         B = Finset.filter (fun w => w ⟨0, by omega⟩ ∉ I ∧ w ⟨1, by omega⟩ ∈ I) Finset.univ) }    let code_dist (q : ℕ) (C : Finset (Fin 2 → Fin q)) : ℝ :=      sInf { ((symmDiff C B).card : ℝ) / (q : ℝ) ^ 2 | B ∈ optimal_blackburn q }    let max_dist (q : ℕ) (ε : ℝ) : ℝ :=      sSup { d | ∃ C : Finset (Fin 2 → Fin q),        is_nonoverlapping q C ∧ (c_2 - ε) * (q : ℝ) ^ 2 ≤ C.card ∧ d = code_dist q C }    let M (ε : ℝ) : ℝ :=      Filter.limsup (fun m : ℕ => max_dist (m * 2) ε) Filter.atTop    Filter.Tendsto (fun ε => M ε / Real.sqrt ε) (nhdsWithin (0 : ℝ) (Set.Ioi 0)) (nhds K_2) := by  intro n lam c_2 K_2 is_nonoverlapping optimal_blackburn code_dist max_dist M  have hc2 : c_2 = 1/4 := by simp only [c_2, lam]; norm_num  have hMb : ∀ ε : ℝ, 0 < ε → ε ≤ 1/16 →      Real.sqrt ε - ε ≤ M ε ∧ M ε ≤ Real.sqrt ε + ε := by    intro ε hε hε1    have hs0 := Real.sqrt_nonneg ε    have hsq := Real.sq_sqrt hε.le    have hcd0 : ∀ q (C : Finset (Fin 2 → Fin q)), 0 ≤ code_dist q C := by      intro q C      apply Real.sInf_nonneg      rintro _ ⟨B, -, rfl⟩      positivity    have hup : ∀ m : ℕ, 1 ≤ m → ∀ d ∈ {d | ∃ C : Finset (Fin 2 → Fin (m*2)),        is_nonoverlapping (m*2) C ∧ (c_2 - ε) * ((m*2 : ℕ) : ℝ) ^ 2 ≤ C.card ∧          d = code_dist (m*2) C}, d ≤ ε + Real.sqrt ε := by      rintro m hm _ ⟨C, hC, hcard, rfl⟩      rw [hc2] at hcard      have hdis : ∀ u ∈ C, ∀ v ∈ C, u 0 ≠ v 1 := by        intro u hu v hv he        apply hC u hu v hv        refine ⟨1, by norm_num, by norm_num, fun i => ?_⟩        fin_cases i        simpa using he      obtain ⟨B, hB, hle⟩ := in1283_upper m hm ε hε C hdis hcard      refine le_trans (csInf_le ⟨0, ?_⟩ ⟨B, hB, rfl⟩) hle      rintro _ ⟨B, -, rfl⟩      positivity    have hmd : ∀ m : ℕ, 1 ≤ m →        (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε) ≤ max_dist (m*2) ε ∧        0 ≤ max_dist (m*2) ε ∧ max_dist (m*2) ε ≤ ε + Real.sqrt ε := by      intro m hm      obtain ⟨C, hC, hcard, hlb⟩ := in1283_lower m hm ε hε hε1      have hC' : is_nonoverlapping (m*2) C := by        rintro u hu v hv ⟨k, hk0, hk2, hk⟩        obtain rfl : k = 1 := by omega        exact hC u hu v hv (by simpa using hk ⟨0, by norm_num⟩)      have hcard' : (c_2 - ε) * ((m*2 : ℕ) : ℝ) ^ 2 ≤ C.card := by rw [hc2]; exact hcard      have hmem : code_dist (m*2) C ∈ {d | ∃ C : Finset (Fin 2 → Fin (m*2)),          is_nonoverlapping (m*2) C ∧ (c_2 - ε) * ((m*2 : ℕ) : ℝ) ^ 2 ≤ C.card ∧            d = code_dist (m*2) C} := ⟨C, hC', hcard', rfl⟩      have hbdd : BddAbove {d | ∃ C : Finset (Fin 2 → Fin (m*2)),          is_nonoverlapping (m*2) C ∧ (c_2 - ε) * ((m*2 : ℕ) : ℝ) ^ 2 ≤ C.card ∧            d = code_dist (m*2) C} := ⟨ε + Real.sqrt ε, hup m hm⟩      obtain ⟨I, -, hI⟩ := Finset.exists_subset_card_eq        (s := (Finset.univ : Finset (Fin (m*2)))) (n := m) (by simp; omega)      have hcdl : (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε) ≤ code_dist (m*2) C := by        apply le_csInf        · exact ⟨_, ⟨Finset.univ.filter (fun w => w 0 ∈ I ∧ w 1 ∉ I),            ⟨I, by omega, Or.inl rfl⟩, rfl⟩⟩        · rintro _ ⟨B, hB, rfl⟩          exact hlb B hB      refine ⟨hcdl.trans (le_csSup hbdd hmem), (hcd0 _ C).trans (le_csSup hbdd hmem),        csSup_le ⟨_, hmem⟩ (hup m hm)⟩    have hev : ∀ᶠ m : ℕ in Filter.atTop,        (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε) ≤ max_dist (m*2) ε ∧        0 ≤ max_dist (m*2) ε ∧ max_dist (m*2) ε ≤ ε + Real.sqrt ε :=      Filter.eventually_atTop.2 ⟨1, fun m hm => hmd m hm⟩    have hbu : Filter.IsBoundedUnder (· ≤ ·) Filter.atTop (fun m : ℕ => max_dist (m*2) ε) :=      Filter.isBoundedUnder_of_eventually_le (hev.mono fun m h => h.2.2)    have hcb : Filter.IsCoboundedUnder (· ≤ ·) Filter.atTop        (fun m : ℕ => max_dist (m*2) ε) :=      Filter.isCoboundedUnder_le_of_eventually_le Filter.atTop (hev.mono fun m h => h.2.1)    have hg : Filter.Tendsto (fun m : ℕ => (Real.sqrt ε - 1 / (2 * m)) * (1 - Real.sqrt ε))        Filter.atTop (nhds (Real.sqrt ε * (1 - Real.sqrt ε))) := by      have h0 : Filter.Tendsto (fun m : ℕ => (1/2 : ℝ) / (m : ℝ)) Filter.atTop (nhds 0) :=        tendsto_const_div_atTop_nhds_zero_nat (1/2)      have h1 := (h0.const_sub (Real.sqrt ε)).mul_const (1 - Real.sqrt ε)      simp only [sub_zero] at h1      refine h1.congr (fun m => ?_)      congr 2      rw [div_div]    constructor    · have hl := Filter.limsup_le_limsup (hev.mono fun m h => h.1)        hg.isCoboundedUnder_le hbu      rw [hg.limsup_eq] at hl      have : Real.sqrt ε * (1 - Real.sqrt ε) = Real.sqrt ε - ε := by        rw [mul_sub, mul_one, Real.mul_self_sqrt hε.le]      rw [this] at hl      exact hl    · have := Filter.limsup_le_of_le hcb (hev.mono fun m h => h.2.2)      show Filter.limsup (fun m : ℕ => max_dist (m * 2) ε) Filter.atTop ≤ Real.sqrt ε + ε      linarith  have hlim : Filter.Tendsto (fun ε : ℝ => Real.sqrt ε) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by    have := (Real.continuous_sqrt.tendsto 0).mono_left      (nhdsWithin_le_nhds (s := Set.Ioi (0:ℝ)))    simpa using this  have hev : ∀ᶠ ε in nhdsWithin (0:ℝ) (Set.Ioi 0), 0 < ε ∧ ε ≤ 1/16 := by    filter_upwards [self_mem_nhdsWithin,      nhdsWithin_le_nhds (Iic_mem_nhds (by norm_num : (0:ℝ) < 1/16))] with ε h1 h2    exact ⟨h1, h2⟩  have h1 : Filter.Tendsto (fun ε : ℝ => 1 - Real.sqrt ε) (nhdsWithin 0 (Set.Ioi 0))      (nhds 1) := by simpa using hlim.const_sub 1  have h2 : Filter.Tendsto (fun ε : ℝ => 1 + Real.sqrt ε) (nhdsWithin 0 (Set.Ioi 0))      (nhds 1) := by simpa using hlim.const_add 1  refine tendsto_of_tendsto_of_tendsto_of_le_of_le' h1 h2 ?_ ?_  · filter_upwards [hev] with ε hε    obtain ⟨hl, -⟩ := hMb ε hε.1 hε.2    have hs : 0 < Real.sqrt ε := Real.sqrt_pos.2 hε.1    have hm := Real.mul_self_sqrt hε.1.le    rw [le_div_iff₀ hs]    nlinarith  · filter_upwards [hev] with ε hε    obtain ⟨-, hu⟩ := hMb ε hε.1 hε.2    have hs : 0 < Real.sqrt ε := Real.sqrt_pos.2 hε.1    have hm := Real.mul_self_sqrt hε.1.le    rw [div_le_iff₀ hs]    nlinarith
See it in the graphDiscuss this resultChallenge it