op_1859_close_skew_r_eq_one
Let n > 1 be a natural number. If v and w are sequences of k points in {0,1}^n forming a close-skew system of radius 1, then k <= 2.
Statement
theorem op_1859_close_skew_r_eq_one {n k : ℕ} (hn : 1 < n)
(v w : Fin k → Fin n → Bool) (h : hamming_close_skew_system 1 v w) :
k ≤ 2- Formalizes
- arXiv:2611.20820 Sec. 5.7, Proposition 4.2
- Verified
- 18 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- hamming_close_skew_systemA pair of sequences of k points (v, w) in the n-dimensional Hamming space {0,1}^n forms a close-skew system of radius r if all pairs v_i,…
Read back from the Lean
For any natural numbers $n$ and $k$ such that $1 < n$, and any two sequences of $k$ boolean vectors of length $n$, $v$ and $w$ (of type $\text{Fin } k \to \text{Fin } n \to \text{Bool}$), if $(v, w)$ forms a hamming_close_skew_system with parameter $r = 1$, then $k \le 2$.
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 is proved by contradiction: assuming k > 2, there exist at least three distinct vectors v 0, v 1, and v 2. The skew and farness conditions force the vectors in the sequence v to be pairwise distinct, which together with the closeness bound d(v i, v j) ≤ 1 implies that all three pairwise distances between v 0, v 1, and v 2 must be exactly 1. However, an auxiliary parity lemma shows that two Boolean vectors each at Hamming distance 1 from a common vector cannot themselves be at distance 1, because their differing-coordinate set is the symmetric difference of two singletons (which has cardinality 0 or 2, never 1). This contradiction establishes that k ≤ 2.
The sets of coordinates where x differs from y and where y differs from z are singletons {a} and {b}, respectively.
By assumption, the Hamming distances between x and y and between y and z are both 1. By definition, the Hamming distance is the cardinality of the set of indices where the coordinates differ. Having cardinality 1 means each difference set is a singleton {a} and {b}.
uses
card_eq_one.mphave h1 : (univ.filter (fun i => x i ≠ y i)).card = 1 := hxy have h2 : (univ.filter (fun i => y i ≠ z i)).card = 1 := hyz obtain ⟨a, ha⟩ := card_eq_one.mp h1 obtain ⟨b, hb⟩ := card_eq_one.mp h2
The set of coordinates where x and z differ is the symmetric difference of the difference set for (x, y) and the difference set for (y, z).
By set extensionality, an index i is in the difference set between x and z if and only if x i ≠ z i. For any three Boolean values u, v, w, the relation u ≠ w holds if and only if exactly one of u ≠ v and v ≠ w holds, which is verified by exhaustively checking all truth assignments. This Boolean equivalence translates to membership in the symmetric difference of the two singletons.
uses
mem_symmDiff,mem_filter,mem_univ,true_andhave hdiff : univ.filter (fun i => x i ≠ z i) = symmDiff (univ.filter (fun i => x i ≠ y i)) (univ.filter (fun i => y i ≠ z i)) := by ext i rw [mem_symmDiff, mem_filter, mem_filter, mem_filter] simp only [mem_univ, true_and] have hbool : ∀ (u v w : Bool), (u ≠ w) ↔ ((u ≠ v ∧ ¬(v ≠ w)) ∨ (v ≠ w ∧ ¬(u ≠ v))) := by decide exact hbool (x i) (y i) (z i)
The Hamming distance between x and z equals the cardinality of the symmetric difference {a} ∆ {b}.
Unfolding the definition of Hamming distance, the number of differing coordinates between x and z is rewritten as the cardinality of the symmetric difference of {a} and {b}.
have hdist : hammingDist x z = (symmDiff ({a} : Finset ι) {b}).card := by dsimp [hammingDist] rw [hdiff, ha, hb] rw [hdist]
The Hamming distance between x and z cannot be 1.
We split into cases on whether a = b. If a = b, the symmetric difference {a} ∆ {a} is empty and has cardinality 0 ≠ 1. If a ≠ b, the singletons {a} and {b} are disjoint, so their symmetric difference is their union {a} ∪ {b}, which has cardinality 2 ≠ 1. Thus in neither case can the distance be 1.
uses
disjoint_singleton_left,symmDiff_eq_unionby_cases hab : a = b · subst hab simp · have hdisj : Disjoint ({a} : Finset ι) {b} := by rw [disjoint_singleton_left] simp [hab] rw [symmDiff_eq_union hdisj] simp [hab]
Assuming k > 2, there exist three strictly ordered indices i0 < i1 < i2 in Fin k, and the close-skew system hypotheses are unpacked.
We proceed by contradiction, assuming k > 2. By linear arithmetic, 0 < k, 1 < k, and 2 < k, yielding three distinct indices i0 = 0, i1 = 1, and i2 = 2 in Fin k with i0 < i1 < i2. We then unpack the close-skew condition into pairwise closeness (distance ≤ 1 between any v i and v j), farness (distance ≥ 2 between w i and v i), and skew closeness (distance ≤ 1 between w i and v j for j < i).
have _ := hn by_contra! hk have hi0 : 0 < k := by omega have hi1 : 1 < k := by omega have hi2 : 2 < k := by omega let i0 : Fin k := ⟨0, hi0⟩ let i1 : Fin k := ⟨1, hi1⟩ let i2 : Fin k := ⟨2, hi2⟩ have h01 : i0 < i1 := by simp [i0, i1] have h12 : i1 < i2 := by simp [i1, i2] have h02 : i0 < i2 := by simp [i0, i2] rcases h with ⟨hclose, hfar, hskew⟩
The vectors in the sequence v are pairwise distinct whenever j < i.
If v i = v j for some j < i, then the farness hypothesis yields d(w i, v j) = d(w i, v i) ≥ 2, directly contradicting the skew hypothesis d(w i, v j) ≤ 1.
have hne (i j : Fin k) (hij : j < i) : v i ≠ v j := by intro heq have h1 := hfar i have h2 := hskew i j hij rw [heq] at h1 omega
The pairwise Hamming distances between v i0, v i1, and v i2 are all equal to 1.
For each pair among {i0, i1, i2}, the closeness hypothesis bounds their distance above by 1. Because the indices are strictly ordered, the vectors are distinct, which implies their Hamming distance is strictly positive. Being an integer with 0 < d ≤ 1, each pairwise distance must be exactly 1.
uses
hammingDist_pos.mprhave hd01 : hammingDist (v i0) (v i1) = 1 := by have hle := hclose i0 i1 have hne' : v i0 ≠ v i1 := (hne i1 i0 h01).symm have hpos := hammingDist_pos.mpr hne' omega have hd12 : hammingDist (v i1) (v i2) = 1 := by have hle := hclose i1 i2 have hne' : v i1 ≠ v i2 := (hne i2 i1 h12).symm have hpos := hammingDist_pos.mpr hne' omega have hd02 : hammingDist (v i0) (v i2) = 1 := by have hle := hclose i0 i2 have hne' : v i0 ≠ v i2 := (hne i2 i0 h02).symm have hpos := hammingDist_pos.mpr hne' omega
A contradiction is reached, proving k ≤ 2.
Applying the auxiliary triangle lemma op_1859_close_skew_r_eq_one_triangle_ne_one to v i0, v i1, and v i2 with d(v i0, v i1) = 1 and d(v i1, v i2) = 1 implies d(v i0, v i2) ≠ 1, contradicting the established fact that d(v i0, v i2) = 1.
uses
op_1859_close_skew_r_eq_one_triangle_ne_onehave hcontra := op_1859_close_skew_r_eq_one_triangle_ne_one (v i0) (v i1) (v i2) hd01 hd12 exact hcontra hd02
card_eq_one.mp- A finite set has cardinality 1 only if it is a singleton set {a} for some element a.
mem_symmDiff- An element belongs to the symmetric difference s ∆ t if and only if it belongs to s but not t, or to t but not s.
mem_filter- An element a belongs to {x ∈ s | p x} if and only if a ∈ s and p a holds.
mem_univ- Every element of a finite type belongs to the universal finset univ.
true_and- For any proposition p, (True ∧ p) is equivalent to p.
disjoint_singleton_left- The singleton set {a} is disjoint from s if and only if a ∉ s.
symmDiff_eq_union- If two sets s and t are disjoint, their symmetric difference s ∆ t equals their union s ∪ t.
hammingDist_pos.mpr- If two sequences or functions are not equal, their Hamming distance is strictly positive.
op_1859_close_skew_r_eq_one_triangle_ne_one- For any three Boolean vectors x, y, z, if d(x, y) = 1 and d(y, z) = 1, then d(x, z) ≠ 1.
- The hypothesis `hn : 1 < n` is retained on line 35 (`have _ := hn`) but is not used in the proof, as the contradiction follows entirely from the close-skew constraints.
- Line 16 uses `decide` to prove the Boolean identity `(u ≠ w) ↔ ((u ≠ v ∧ ¬(v ≠ w)) ∨ (v ≠ w ∧ ¬(u ≠ v)))` via exhaustive evaluation over all $2^3 = 8$ truth values.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
open Finsetprivate theorem op_1859_close_skew_r_eq_one_triangle_ne_one {ι : Type*} [Fintype ι] [DecidableEq ι] (x y z : ι → Bool) (hxy : hammingDist x y = 1) (hyz : hammingDist y z = 1) : hammingDist x z ≠ 1 := by have h1 : (univ.filter (fun i => x i ≠ y i)).card = 1 := hxy have h2 : (univ.filter (fun i => y i ≠ z i)).card = 1 := hyz obtain ⟨a, ha⟩ := card_eq_one.mp h1 obtain ⟨b, hb⟩ := card_eq_one.mp h2 have hdiff : univ.filter (fun i => x i ≠ z i) = symmDiff (univ.filter (fun i => x i ≠ y i)) (univ.filter (fun i => y i ≠ z i)) := by ext i rw [mem_symmDiff, mem_filter, mem_filter, mem_filter] simp only [mem_univ, true_and] have hbool : ∀ (u v w : Bool), (u ≠ w) ↔ ((u ≠ v ∧ ¬(v ≠ w)) ∨ (v ≠ w ∧ ¬(u ≠ v))) := by decide exact hbool (x i) (y i) (z i) have hdist : hammingDist x z = (symmDiff ({a} : Finset ι) {b}).card := by dsimp [hammingDist] rw [hdiff, ha, hb] rw [hdist] by_cases hab : a = b · subst hab simp · have hdisj : Disjoint ({a} : Finset ι) {b} := by rw [disjoint_singleton_left] simp [hab] rw [symmDiff_eq_union hdisj] simp [hab]/-- The close-skew set-pair bound holds for radius r = 1. -/theorem op_1859_close_skew_r_eq_one {n k : ℕ} (hn : 1 < n) (v w : Fin k → Fin n → Bool) (h : hamming_close_skew_system 1 v w) : k ≤ 2 := by have _ := hn by_contra! hk have hi0 : 0 < k := by omega have hi1 : 1 < k := by omega have hi2 : 2 < k := by omega let i0 : Fin k := ⟨0, hi0⟩ let i1 : Fin k := ⟨1, hi1⟩ let i2 : Fin k := ⟨2, hi2⟩ have h01 : i0 < i1 := by simp [i0, i1] have h12 : i1 < i2 := by simp [i1, i2] have h02 : i0 < i2 := by simp [i0, i2] rcases h with ⟨hclose, hfar, hskew⟩ have hne (i j : Fin k) (hij : j < i) : v i ≠ v j := by intro heq have h1 := hfar i have h2 := hskew i j hij rw [heq] at h1 omega have hd01 : hammingDist (v i0) (v i1) = 1 := by have hle := hclose i0 i1 have hne' : v i0 ≠ v i1 := (hne i1 i0 h01).symm have hpos := hammingDist_pos.mpr hne' omega have hd12 : hammingDist (v i1) (v i2) = 1 := by have hle := hclose i1 i2 have hne' : v i1 ≠ v i2 := (hne i2 i1 h12).symm have hpos := hammingDist_pos.mpr hne' omega have hd02 : hammingDist (v i0) (v i2) = 1 := by have hle := hclose i0 i2 have hne' : v i0 ≠ v i2 := (hne i2 i0 h02).symm have hpos := hammingDist_pos.mpr hne' omega have hcontra := op_1859_close_skew_r_eq_one_triangle_ne_one (v i0) (v i1) (v i2) hd01 hd12 exact hcontra hd02