op_1859_close_skew_n_eq_r_succ
Let r >= 1 be a natural number. If v and w are sequences of k points in {0,1}^(r+1) forming a close-skew system of radius r, then k <= 2^r.
Statement
theorem op_1859_close_skew_n_eq_r_succ {r k : ℕ} (hr : 1 ≤ r)
(v w : Fin k → Fin (r + 1) → Bool) (h : hamming_close_skew_system r v w) :
k ≤ 2 ^ r- Formalizes
- arXiv:2611.20820 Sec. 5.7
- 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 all natural numbers $r$ and $k$, assuming $1 \le r$, and for any two families of boolean vectors $v, w : \text{Fin } k \to \text{Fin } (r + 1) \to \text{Bool}$, if $(v, w)$ forms a hamming_close_skew_system with parameter $r$, then $k \le 2^r$.
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 a double-counting and packing argument on the hypercube {0, 1}^(r+1). First, the close-skew conditions imply that the sequence of points v is injective. We then consider the set of points A = {v(i)} and the set of their coordinatewise boolean complements B = {¬v(i)}, each having cardinality k. Because any two points in v have Hamming distance at most r, while any point and its complement have Hamming distance r + 1, the sets A and B are disjoint. Their disjoint union A ∪ B has cardinality 2k and is contained in {0, 1}^(r+1) of total size 2^(r+1), yielding 2k ≤ 2^(r+1) = 2 · 2^r, which implies k ≤ 2^r.
Bitwise boolean negation of vectors is an injective operation.
To show that the bitwise negation function on {0, 1}^n is injective, suppose ¬x = ¬y. Applying functional equality coordinatewise at an arbitrary index i gives ¬x(i) = ¬y(i). Since boolean negation is an involution, this implies x(i) = y(i) for each coordinate i, and hence x = y by functional extensionality.
uses
congr_funintro x y h ext i have := congr_fun h i dsimp [op_1859_close_skew_n_eq_r_succ_notVec] at this simpa using this
The Hamming distance between any boolean vector of length n and its bitwise negation is n.
The Hamming distance between x and ¬x is the number of indices i where x(i) ≠ ¬x(i). Since a boolean value is never equal to its own negation, this inequality holds at every coordinate. Hence the set of differing indices is the entire universe {0, ..., n-1}, which has cardinality n.
uses
Finset.card_univ,Fintype.card_finchange (Finset.filter (fun i => x i ≠ op_1859_close_skew_n_eq_r_succ_notVec x i) Finset.univ).card = n have h_univ : (Finset.filter (fun i => x i ≠ op_1859_close_skew_n_eq_r_succ_notVec x i) Finset.univ) = Finset.univ := by ext i simp [op_1859_close_skew_n_eq_r_succ_notVec] rw [h_univ, Finset.card_univ, Fintype.card_fin]
The sequence of points v is injective.
Suppose v(i) = v(j) for indices i, j. By trichotomy, either i < j, i = j, or j < i. If i < j, the skew condition gives d(w(j), v(i)) ≤ r, while the far condition gives d(w(j), v(j)) ≥ r + 1. Substituting v(i) = v(j) yields r + 1 ≤ d(w(j), v(i)) ≤ r, a contradiction. The symmetric contradiction arises if j < i. Thus i = j must hold, proving injectivity.
uses
lt_trichotomyhave _ := hr have hinj : Function.Injective v := by intro i j hij rcases h with ⟨-, hfar, hskew⟩ rcases lt_trichotomy i j with hlt | heq | hgt · have h1 := hfar j have h2 := hskew j i hlt rw [← hij] at h1 omega · exact heq · have h1 := hfar i have h2 := hskew i j hgt rw [hij] at h1 omega
The set of points A = Im(v) and the set of their bitwise complements B = Im(¬ ∘ v) each have cardinality k.
Define A to be the image of v and B to be the image of the composite map ¬ ∘ v. Since v is injective, |A| = k. Since bitwise negation is also injective, their composition ¬ ∘ v is injective as well, which yields |B| = k.
uses
Finset.card_image_of_injective,op_1859_close_skew_n_eq_r_succ_notVec_injective,Finset.card_univ,Fintype.card_finlet A := Finset.image v (Finset.univ : Finset (Fin k)) let B := Finset.image (op_1859_close_skew_n_eq_r_succ_notVec ∘ v) (Finset.univ : Finset (Fin k)) have hA_card : A.card = k := by rw [Finset.card_image_of_injective _ hinj, Finset.card_univ, Fintype.card_fin] have hB_card : B.card = k := by have hinj2 : Function.Injective (op_1859_close_skew_n_eq_r_succ_notVec ∘ v) := op_1859_close_skew_n_eq_r_succ_notVec_injective.comp hinj rw [Finset.card_image_of_injective _ hinj2, Finset.card_univ, Fintype.card_fin]
The sets A and B are disjoint.
Suppose for contradiction that A and B share an element, so v(i) = ¬v(j) for some indices i and j. By the close condition of the system, any two points in v satisfy d(v(j), v(i)) ≤ r. But since v(i) = ¬v(j), the distance d(v(j), v(i)) equals d(v(j), ¬v(j)) = r + 1 by the helper lemma. This implies r + 1 ≤ r, a contradiction. Therefore, A and B are disjoint.
uses
Finset.disjoint_iff_ne,Finset.mem_image.mp,op_1859_close_skew_n_eq_r_succ_hammingDist_notVechave hdisj : Disjoint A B := by rw [Finset.disjoint_iff_ne] intro a ha b hb rcases Finset.mem_image.mp ha with ⟨i, -, rfl⟩ rcases Finset.mem_image.mp hb with ⟨j, -, rfl⟩ intro heq rcases h with ⟨hclose, -, -⟩ have hd := hclose j i have heq_dist : hammingDist (v j) (v i) = r + 1 := by rw [heq] dsimp [Function.comp] exact op_1859_close_skew_n_eq_r_succ_hammingDist_notVec (v j) omega
The number of points k is at most 2^r.
The union A ∪ B is a subset of the hypercube {0, 1}^(r+1), so its cardinality cannot exceed the total size of the space, 2^(r+1). Since A and B are disjoint sets each of size k, |A ∪ B| = k + k = 2k. Writing 2^(r+1) = 2 · 2^r = 2^r + 2^r, the inequality becomes 2k ≤ 2 · 2^r, which simplifies by linear arithmetic to k ≤ 2^r.
uses
Finset.card_le_univ,Finset.card_union_of_disjoint,pow_succ,mul_twohave h_union_le : (A ∪ B).card ≤ Fintype.card (Fin (r + 1) → Bool) := by exact Finset.card_le_univ (A ∪ B) rw [Finset.card_union_of_disjoint hdisj, hA_card, hB_card] at h_union_le have h_total : Fintype.card (Fin (r + 1) → Bool) = 2 ^ (r + 1) := by simp rw [h_total, pow_succ, mul_two] at h_union_le omega
congr_fun- Equal functions evaluate to equal values on any input: if f = g, then f(a) = g(a).
Finset.card_univ- The cardinality of the universal finset of a finite type equals the cardinality of the type.
Fintype.card_fin- The cardinality of Fin n is n.
lt_trichotomy- For any two elements a, b in a linear order, exactly one of a < b, a = b, or b < a holds.
Finset.card_image_of_injective- The image of a finite set under an injective function has the same cardinality as the original set.
op_1859_close_skew_n_eq_r_succ_notVec_injective- The bitwise negation function on vectors of booleans is injective.
Finset.disjoint_iff_ne- Two finite sets are disjoint if and only if no element of the first equals an element of the second.
Finset.mem_image.mp- If an element belongs to the image of a set under a function, it is the value of the function at some element of that set.
op_1859_close_skew_n_eq_r_succ_hammingDist_notVec- The Hamming distance between any boolean vector of length n and its bitwise negation is n.
Finset.card_le_univ- Any finite subset of a finite type has cardinality at most the cardinality of the type.
Finset.card_union_of_disjoint- The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
pow_succ- In a monoid, a^(n+1) = a^n * a.
mul_two- In a semiring, multiplying by 2 equals adding an element to itself: n * 2 = n + n.
- The theorem includes the hypothesis hr : 1 ≤ r, but it is not mathematically needed for the cardinality bound k ≤ 2^r and is discarded at the start of the proof via `have _ := hr`.
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.
def op_1859_close_skew_n_eq_r_succ_notVec {n : ℕ} (x : Fin n → Bool) : Fin n → Bool := fun a => !x atheorem op_1859_close_skew_n_eq_r_succ_notVec_injective {n : ℕ} : Function.Injective (op_1859_close_skew_n_eq_r_succ_notVec (n := n)) := by intro x y h ext i have := congr_fun h i dsimp [op_1859_close_skew_n_eq_r_succ_notVec] at this simpa using thistheorem op_1859_close_skew_n_eq_r_succ_hammingDist_notVec {n : ℕ} (x : Fin n → Bool) : hammingDist x (op_1859_close_skew_n_eq_r_succ_notVec x) = n := by change (Finset.filter (fun i => x i ≠ op_1859_close_skew_n_eq_r_succ_notVec x i) Finset.univ).card = n have h_univ : (Finset.filter (fun i => x i ≠ op_1859_close_skew_n_eq_r_succ_notVec x i) Finset.univ) = Finset.univ := by ext i simp [op_1859_close_skew_n_eq_r_succ_notVec] rw [h_univ, Finset.card_univ, Fintype.card_fin]/-- The close-skew set-pair bound holds in the codimension-one case n = r + 1. -/theorem op_1859_close_skew_n_eq_r_succ {r k : ℕ} (hr : 1 ≤ r) (v w : Fin k → Fin (r + 1) → Bool) (h : hamming_close_skew_system r v w) : k ≤ 2 ^ r := by have _ := hr have hinj : Function.Injective v := by intro i j hij rcases h with ⟨-, hfar, hskew⟩ rcases lt_trichotomy i j with hlt | heq | hgt · have h1 := hfar j have h2 := hskew j i hlt rw [← hij] at h1 omega · exact heq · have h1 := hfar i have h2 := hskew i j hgt rw [hij] at h1 omega let A := Finset.image v (Finset.univ : Finset (Fin k)) let B := Finset.image (op_1859_close_skew_n_eq_r_succ_notVec ∘ v) (Finset.univ : Finset (Fin k)) have hA_card : A.card = k := by rw [Finset.card_image_of_injective _ hinj, Finset.card_univ, Fintype.card_fin] have hB_card : B.card = k := by have hinj2 : Function.Injective (op_1859_close_skew_n_eq_r_succ_notVec ∘ v) := op_1859_close_skew_n_eq_r_succ_notVec_injective.comp hinj rw [Finset.card_image_of_injective _ hinj2, Finset.card_univ, Fintype.card_fin] have hdisj : Disjoint A B := by rw [Finset.disjoint_iff_ne] intro a ha b hb rcases Finset.mem_image.mp ha with ⟨i, -, rfl⟩ rcases Finset.mem_image.mp hb with ⟨j, -, rfl⟩ intro heq rcases h with ⟨hclose, -, -⟩ have hd := hclose j i have heq_dist : hammingDist (v j) (v i) = r + 1 := by rw [heq] dsimp [Function.comp] exact op_1859_close_skew_n_eq_r_succ_hammingDist_notVec (v j) omega have h_union_le : (A ∪ B).card ≤ Fintype.card (Fin (r + 1) → Bool) := by exact Finset.card_le_univ (A ∪ B) rw [Finset.card_union_of_disjoint hdisj, hA_card, hB_card] at h_union_le have h_total : Fintype.card (Fin (r + 1) → Bool) = 2 ^ (r + 1) := by simp rw [h_total, pow_succ, mul_two] at h_union_le omega