alpha_lexical_no_odd_square_prefix
No lexical sequence begins with two copies of the same odd-length sequence.
Statement
theorem alpha_lexical_no_odd_square_prefix (u tail : List ℕ) (hodd : u.length % 2 = 1) : ¬ alpha_is_lexical (u ++ u ++ tail)- Source
- Helper for OP-392, arXiv:2610.24758; the odd-square exclusion is stated as Lemma 2.7 of DOI:10.1006/jcta.2000.3112.
- Verified
- 18 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 7
- alpha_is_lexicalA nonempty positive sequence strictly larger than all its proper nonempty suffixes.
- alpha_lexical_ltThe source alternating lexicographic order on positive integer sequences.
- alpha_signed_cellA cell of a positive sequence, with alternating signs and zero padding.
- alpha_lexical_first_negative_step_existsA lexical sequence with at least two cells has an elementary lexical successor at its first negative cell.
- alpha_lexical_lt_append_parityPrepending an even-length common sequence preserves alternating lexical order, while prepending an odd-length common sequence reverses it.
- LinearOrder.toTotalPreorderEvery
LinearOrderis aTotalPreorder. - TotalPreorderA total preorder: a preorder where
≤is total (complete). This is weaker thanLinearOrder— it does NOT require antisymmetry or…
The proof, explained
Suppose for contradiction that a lexical sequence begins with two copies of an odd-length sequence, u ++ u ++ tail. Because |u| is odd, prepending u reverses the lexical order between suffixes. Lexicality requires every non-empty suffix to be strictly smaller than the whole sequence; dropping the first copy of u gives u ++ tail < tail after parity reversal. If tail is empty, this forces u < [], which is impossible at the first element because all elements of u are strictly positive. If tail is non-empty, dropping both copies of u gives tail < u ++ u ++ tail, which mutually contradicts u ++ tail < tail by an inductive analysis of the first differing element (alpha_nosq_core).
For any list A and index j ≥ |A|, the signed cell alpha_signed_cell A j is 0.
By definition, the signed cell at index j is (-1)^j times the element with default value 0. For j ≥ |A|, List.getD_eq_default gives 0, and ±0 is 0.
uses
List.getD_eq_defaultunfold alpha_signed_cell rw [List.getD_eq_default _ _ h]; split_ifs <;> simp
If A is lexically less than B, their signed cells at the first differing index p satisfy cell(A, p) < cell(B, p).
By definition of the lexical order, there is some first differing index i with cell(A, i) < cell(B, i). Trichotomy between i and p shows that i < p contradicts equality before p, and p < i contradicts equality at p, so i = p.
uses
lt_trichotomy,ne_of_ltconstructor · rintro ⟨i, _, hpre, hlt⟩ rcases lt_trichotomy i p with h | h | h · exact absurd (heq i h) (ne_of_lt hlt) · exact h ▸ hlt · exact absurd (hpre p h) hne
Conversely, if cell(A, p) < cell(B, p) at the first differing index p, then A is lexically less than B.
The index p serves as the witness for lexical comparison. If p were at least max(|A|, |B|), both signed cells would equal 0 by alpha_nosq_signed_eq_zero_of_le, contradicting that they differ at p; hence p is within bounds.
uses
alpha_nosq_signed_eq_zero_of_le,le_trans,le_max_left,le_max_right· intro hlt refine ⟨p, ?_, heq, hlt⟩ by_contra hp push Not at hp apply hne rw [alpha_nosq_signed_eq_zero_of_le A p (le_trans (le_max_left _ _) hp), alpha_nosq_signed_eq_zero_of_le B p (le_trans (le_max_right _ _) hp)]
Appending a list X to u does not change the signed cell at any index j < |u|.
Because j < |u|, the element at index j in u ++ X is identical to the element in u by List.getD_append, so their signed cells match.
uses
List.getD_appendunfold alpha_signed_cell rw [List.getD_append _ _ _ _ hj]
If two lists have the same signed cell at index j, their elements at index j (with default 0) are equal.
The signed cells are either A[j] and B[j] or -A[j] and -B[j] depending on the parity of j; in both cases equality of the signed cells implies A[j] = B[j].
unfold alpha_signed_cell at h split_ifs at h <;> omega
Appending the odd-length prefix u reverses lexical order, and we proceed by strong induction on the length of t.
By alpha_lexical_lt_append_parity, prepending an odd-length sequence reverses the comparison: u ++ x < u ++ y ↔ y < x. We set up strong induction on the length of t.
uses
alpha_lexical_lt_append_parity,Nat.strong_induction_onhave hpar : ∀ x y : List ℕ, alpha_lexical_lt (u ++ x) (u ++ y) ↔ alpha_lexical_lt y x := by intro x y rw [alpha_lexical_lt_append_parity] simp [hodd] have hlen : 0 < u.length := by omega intro t induction hn : t.length using Nat.strong_induction_on generalizing t with | _ n ih =>
If t shares all signed cells with u up to index |u|, then |t| ≥ |u| and their elements agree at each index j < |u|.
By alpha_nosq_signed_inj, their elements agree. If t were shorter than j + 1 for some j < |u|, its element would default to 0, which contradicts that every element of u is strictly positive (hu).
uses
alpha_nosq_signed_inj,List.getD_eq_getElem,List.getElem_mem,List.getD_eq_defaultby_cases hall : ∀ j < u.length, alpha_signed_cell t j = alpha_signed_cell u j · -- t starts with u have hgt : ∀ j < u.length, j < t.length ∧ t.getD j 0 = u.getD j 0 := by intro j hj have hg := alpha_nosq_signed_inj _ _ _ (hall j hj) have hupos : 0 < u.getD j 0 := by rw [List.getD_eq_getElem _ _ hj]; exact hu _ (List.getElem_mem hj) refine ⟨?_, hg⟩ by_contra hc push Not at hc rw [List.getD_eq_default _ _ hc] at hg omega
The prefix of length |u| of t equals u, so t decomposes as u ++ t' where t' = t.drop |u|.
Using List.ext_getElem, the first |u| elements of t match u pointwise, so t.take |u| = u. Recombining prefix and suffix via List.take_append_drop yields t = u ++ t'.
uses
List.ext_getElem,List.length_take,List.getD_eq_getElem,List.getElem_take,List.take_append_drophave htake : t.take u.length = u := by apply List.ext_getElem · simp only [List.length_take] have := (hgt (u.length - 1) (by omega)).1 omega · intro j h1 h2 obtain ⟨ht, h⟩ := hgt j h2 rw [List.getD_eq_getElem _ _ ht, List.getD_eq_getElem _ _ h2] at h rw [List.getElem_take]; exact h set t' := t.drop u.length with ht' have htt : t = u ++ t' := by rw [← htake, List.take_append_drop]
When t = u ++ t', the induction hypothesis applied to t' yields the required mutual exclusions.
Since |u| > 0, t' is strictly shorter than t. Stripping the initial u from both sides reverses the inequalities by parity (hpar), reducing both branches to the induction hypothesis on t'.
uses
List.length_append,List.append_assochave hlt' : t'.length < n := by rw [← hn, htt, List.length_append]; omega obtain ⟨ih1, ih2⟩ := ih _ hlt' t' rfl rw [htt] simp only [List.append_assoc] constructor · intro h1 h2 rw [hpar] at h1 h2 exact ih2 h1 (by simpa [List.append_assoc] using h2) · intro h1 h2 rw [hpar] at h1 h2 exact ih1 h1 (by simpa [List.append_assoc] using h2)
When t differs from u before index |u|, let p < |u| be the minimal index of difference; then t and u agree before p, and any u ++ X matches u up to p.
We define p as the minimal difference index via Nat.find. By minimality, t and u have identical signed cells at all j < p. Because p < |u|, appending any tail X to u leaves the cells up to index p unchanged.
uses
Nat.find,Nat.find_spec,Nat.find_min,lt_trans,alpha_nosq_signed_append_left,lt_of_le_of_lt· push Not at hall classical let P : ℕ → Prop := fun p => p < u.length ∧ alpha_signed_cell t p ≠ alpha_signed_cell u p have hex : ∃ p, P p := hall let p := Nat.find hex have hp : P p := Nat.find_spec hex have hmin : ∀ j < p, alpha_signed_cell t j = alpha_signed_cell u j := by intro j hj by_contra hne exact Nat.find_min hex hj ⟨lt_trans hj hp.1, hne⟩ have hA : ∀ X : List ℕ, ∀ j ≤ p, alpha_signed_cell (u ++ X) j = alpha_signed_cell u j := fun X j hj => alpha_nosq_signed_append_left u X j (lt_of_le_of_lt hj hp.1)
The lexical comparisons between u ++ t, t, and u ++ u ++ t reduce to comparing cell values at index p, which mutually contradict by asymmetry of <.
By alpha_nosq_lt_iff_first_diff, each lexical comparison is determined by index p. Hence u ++ t < t is equivalent to cell(u, p) < cell(t, p), while t < u ++ u ++ t is equivalent to cell(t, p) < cell(u, p). These cannot both hold by lt_asymm.
uses
alpha_nosq_lt_iff_first_diff,le_rfl,List.append_assoc,lt_asymmhave k1 : alpha_lexical_lt (u ++ t) t ↔ alpha_signed_cell u p < alpha_signed_cell t p := by rw [alpha_nosq_lt_iff_first_diff _ _ p, hA t p le_rfl] · intro j hj; rw [hA t j hj.le, hmin j hj] · rw [hA t p le_rfl]; exact fun h => hp.2 h.symm have k2 : alpha_lexical_lt t (u ++ u ++ t) ↔ alpha_signed_cell t p < alpha_signed_cell u p := by rw [List.append_assoc, alpha_nosq_lt_iff_first_diff _ _ p, hA _ p le_rfl] · intro j hj; rw [hA _ j hj.le, hmin j hj] · rw [hA _ p le_rfl]; exact hp.2 have k3 : alpha_lexical_lt t (u ++ t) ↔ alpha_signed_cell t p < alpha_signed_cell u p := by rw [alpha_nosq_lt_iff_first_diff _ _ p, hA t p le_rfl] · intro j hj; rw [hA t j hj.le, hmin j hj] · rw [hA t p le_rfl]; exact hp.2 have k4 : alpha_lexical_lt (u ++ u ++ t) t ↔ alpha_signed_cell u p < alpha_signed_cell t p := by rw [List.append_assoc, alpha_nosq_lt_iff_first_diff _ _ p, hA _ p le_rfl] · intro j hj; rw [hA _ j hj.le, hmin j hj] · rw [hA _ p le_rfl]; exact fun h => hp.2 h.symm rw [k1, k2, k3, k4] exact ⟨fun h1 h2 => lt_asymm h1 h2, fun h1 h2 => lt_asymm h1 h2⟩
If u ++ u ++ tail is lexical, dropping the first copy of u yields u ++ tail < tail.
By lexicality, dropping the prefix u (length |u|) gives (u ++ u ++ tail).drop |u| < u ++ u ++ tail, which simplifies to u ++ tail < u ++ (u ++ tail). Because |u| is odd, parity reversal (alpha_lexical_lt_append_parity) turns this into u ++ tail < tail.
uses
alpha_lexical_lt_append_parity,List.append_assoc,List.drop_leftrintro ⟨_, hpos, hlex⟩ have hu : ∀ v ∈ u, 0 < v := fun v hv => hpos v (by simp [hv]) have hlen : 0 < u.length := by omega have hpar : ∀ x y : List ℕ, alpha_lexical_lt (u ++ x) (u ++ y) ↔ alpha_lexical_lt y x := by intro x y rw [alpha_lexical_lt_append_parity] simp [hodd] have F1 := hlex u.length (by simp; omega) hlen rw [List.append_assoc, List.drop_left, hpar] at F1
If tail is empty, u ++ tail < tail reduces to u < [], which is impossible.
When tail is empty, F1 becomes u < []. At index 0, the signed cell of u is u[0] > 0, while that of [] is 0. By alpha_nosq_lt_iff_first_diff, u < [] requires u[0] < 0, an arithmetic contradiction.
uses
List.append_nil,List.getD_eq_getElem,List.getElem_mem,alpha_nosq_lt_iff_first_diffrcases tail with _ | ⟨x, xs⟩ · rw [List.append_nil] at F1 have h0 : 0 < u.getD 0 0 := by rw [List.getD_eq_getElem _ _ hlen]; exact hu _ (List.getElem_mem hlen) have e1 : alpha_signed_cell u 0 = (u.getD 0 0 : ℤ) := by simp [alpha_signed_cell] have e2 : alpha_signed_cell ([] : List ℕ) 0 = 0 := by simp [alpha_signed_cell] rw [alpha_nosq_lt_iff_first_diff _ _ 0 (by intro j hj; omega) (by rw [e1, e2]; omega), e1, e2] at F1 omega
If tail is non-empty, dropping u ++ u yields a second comparison that contradicts F1 via alpha_nosq_core.
Dropping the prefix of length 2|u| produces tail < u ++ u ++ tail. Together with F1 (u ++ tail < tail), this contradicts the first clause of alpha_nosq_core applied to tail, completing the proof.
uses
List.append_assoc,alpha_nosq_core· have F2 := hlex (u.length + u.length) (by simp) (by omega) have hd : (u ++ u ++ (x :: xs)).drop (u.length + u.length) = x :: xs := by rw [List.append_assoc]; simp rw [hd] at F2 exact (alpha_nosq_core u hu hodd (x :: xs)).1 F1 F2
List.getD_eq_default- Accessing an element of a list at an index greater than or equal to its length with a default value returns that default value.
lt_trichotomy- For any two elements in a linear order, exactly one of a < b, a = b, or b < a holds.
ne_of_lt- If a < b in a preorder, then a ≠ b.
alpha_nosq_signed_eq_zero_of_le- For any list A and index j ≥ |A|, the signed cell of A at index j is zero.
le_trans- Inequality ≤ is transitive: if a ≤ b and b ≤ c, then a ≤ c.
le_max_left- Any value a is less than or equal to max(a, b).
le_max_right- Any value b is less than or equal to max(a, b).
List.getD_append- Accessing an element of l ++ l' at an index n < |l| yields the n-th element of l.
alpha_lexical_lt_append_parity- Prepending a list u preserves lexical comparison if |u| is even, and reverses it if |u| is odd.
Nat.strong_induction_on- Strong induction on natural numbers: to prove P(n), it suffices to prove P(n) assuming P(m) for all m < n.
alpha_nosq_signed_inj- If two lists have the same signed cell at index j, their default-extended elements at index j are equal.
List.getD_eq_getElem- Accessing an in-bounds element of a list with a default value returns the actual element at that index.
List.getElem_mem- An element accessed at an in-bounds index belongs to the list.
List.ext_getElem- Two lists are equal if they have the same length and their elements agree at every index.
List.length_take- The length of taking i elements from a list l is min(i, |l|).
List.getElem_take- The i-th element of the prefix of length j of a list is the original i-th element.
List.take_append_drop- Concatenating the prefix of length i with the suffix after dropping i elements reconstructs the original list.
List.length_append- The length of the concatenation of two lists is the sum of their lengths.
List.append_assoc- List concatenation is associative: (as ++ bs) ++ cs = as ++ (bs ++ cs).
Nat.find- Returns the least natural number satisfying a decidable predicate, given a witness that one exists.
Nat.find_spec- The number returned by Nat.find satisfies the predicate.
Nat.find_min- Any number strictly smaller than Nat.find does not satisfy the predicate.
lt_trans- Strict inequality < is transitive: if a < b and b < c, then a < c.
alpha_nosq_signed_append_left- For any index j < |u|, the signed cell of u ++ X at index j equals the signed cell of u at index j.
lt_of_le_of_lt- If a ≤ b and b < c, then a < c.
alpha_nosq_lt_iff_first_diff- If two lists agree on all signed cells before index p and differ at p, then A < B in lexical order if and only if cell(A, p) < cell(B, p).
le_rfl- Inequality ≤ is reflexive: a ≤ a for any a.
lt_asymm- Strict inequality is asymmetric: if a < b, then not b < a.
List.drop_left- Dropping |l₁| elements from l₁ ++ l₂ leaves l₂.
List.append_nil- Appending the empty list to any list leaves it unchanged.
alpha_nosq_core- For an odd-length list u of positive numbers and any list t, the conditions u ++ t < t and t < u ++ u ++ t are mutually contradictory, as are t < u ++ t and u ++ u ++ t < t.
- Prepending an odd-length sequence reverses the lexical order because the signs of the cells alternate at each index parity.
- Several arithmetic and boundary subgoals, such as verifying index bounds or ruling out zero values, are closed directly by the omega decision procedure.
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.
theorem alpha_nosq_signed_eq_zero_of_le (A : List ℕ) (j : ℕ) (h : A.length ≤ j) : alpha_signed_cell A j = 0 := by unfold alpha_signed_cell rw [List.getD_eq_default _ _ h]; split_ifs <;> simptheorem alpha_nosq_lt_iff_first_diff (A B : List ℕ) (p : ℕ) (heq : ∀ j < p, alpha_signed_cell A j = alpha_signed_cell B j) (hne : alpha_signed_cell A p ≠ alpha_signed_cell B p) : alpha_lexical_lt A B ↔ alpha_signed_cell A p < alpha_signed_cell B p := by constructor · rintro ⟨i, _, hpre, hlt⟩ rcases lt_trichotomy i p with h | h | h · exact absurd (heq i h) (ne_of_lt hlt) · exact h ▸ hlt · exact absurd (hpre p h) hne · intro hlt refine ⟨p, ?_, heq, hlt⟩ by_contra hp push Not at hp apply hne rw [alpha_nosq_signed_eq_zero_of_le A p (le_trans (le_max_left _ _) hp), alpha_nosq_signed_eq_zero_of_le B p (le_trans (le_max_right _ _) hp)]theorem alpha_nosq_signed_append_left (u X : List ℕ) (j : ℕ) (hj : j < u.length) : alpha_signed_cell (u ++ X) j = alpha_signed_cell u j := by unfold alpha_signed_cell rw [List.getD_append _ _ _ _ hj]theorem alpha_nosq_signed_inj (A B : List ℕ) (j : ℕ) (h : alpha_signed_cell A j = alpha_signed_cell B j) : A.getD j 0 = B.getD j 0 := by unfold alpha_signed_cell at h split_ifs at h <;> omegatheorem alpha_nosq_core (u : List ℕ) (hu : ∀ v ∈ u, 0 < v) (hodd : u.length % 2 = 1) : ∀ t : List ℕ, (alpha_lexical_lt (u ++ t) t → ¬ alpha_lexical_lt t (u ++ u ++ t)) ∧ (alpha_lexical_lt t (u ++ t) → ¬ alpha_lexical_lt (u ++ u ++ t) t) := by have hpar : ∀ x y : List ℕ, alpha_lexical_lt (u ++ x) (u ++ y) ↔ alpha_lexical_lt y x := by intro x y rw [alpha_lexical_lt_append_parity] simp [hodd] have hlen : 0 < u.length := by omega intro t induction hn : t.length using Nat.strong_induction_on generalizing t with | _ n ih => by_cases hall : ∀ j < u.length, alpha_signed_cell t j = alpha_signed_cell u j · -- t starts with u have hgt : ∀ j < u.length, j < t.length ∧ t.getD j 0 = u.getD j 0 := by intro j hj have hg := alpha_nosq_signed_inj _ _ _ (hall j hj) have hupos : 0 < u.getD j 0 := by rw [List.getD_eq_getElem _ _ hj]; exact hu _ (List.getElem_mem hj) refine ⟨?_, hg⟩ by_contra hc push Not at hc rw [List.getD_eq_default _ _ hc] at hg omega have htake : t.take u.length = u := by apply List.ext_getElem · simp only [List.length_take] have := (hgt (u.length - 1) (by omega)).1 omega · intro j h1 h2 obtain ⟨ht, h⟩ := hgt j h2 rw [List.getD_eq_getElem _ _ ht, List.getD_eq_getElem _ _ h2] at h rw [List.getElem_take]; exact h set t' := t.drop u.length with ht' have htt : t = u ++ t' := by rw [← htake, List.take_append_drop] have hlt' : t'.length < n := by rw [← hn, htt, List.length_append]; omega obtain ⟨ih1, ih2⟩ := ih _ hlt' t' rfl rw [htt] simp only [List.append_assoc] constructor · intro h1 h2 rw [hpar] at h1 h2 exact ih2 h1 (by simpa [List.append_assoc] using h2) · intro h1 h2 rw [hpar] at h1 h2 exact ih1 h1 (by simpa [List.append_assoc] using h2) · push Not at hall classical let P : ℕ → Prop := fun p => p < u.length ∧ alpha_signed_cell t p ≠ alpha_signed_cell u p have hex : ∃ p, P p := hall let p := Nat.find hex have hp : P p := Nat.find_spec hex have hmin : ∀ j < p, alpha_signed_cell t j = alpha_signed_cell u j := by intro j hj by_contra hne exact Nat.find_min hex hj ⟨lt_trans hj hp.1, hne⟩ have hA : ∀ X : List ℕ, ∀ j ≤ p, alpha_signed_cell (u ++ X) j = alpha_signed_cell u j := fun X j hj => alpha_nosq_signed_append_left u X j (lt_of_le_of_lt hj hp.1) have k1 : alpha_lexical_lt (u ++ t) t ↔ alpha_signed_cell u p < alpha_signed_cell t p := by rw [alpha_nosq_lt_iff_first_diff _ _ p, hA t p le_rfl] · intro j hj; rw [hA t j hj.le, hmin j hj] · rw [hA t p le_rfl]; exact fun h => hp.2 h.symm have k2 : alpha_lexical_lt t (u ++ u ++ t) ↔ alpha_signed_cell t p < alpha_signed_cell u p := by rw [List.append_assoc, alpha_nosq_lt_iff_first_diff _ _ p, hA _ p le_rfl] · intro j hj; rw [hA _ j hj.le, hmin j hj] · rw [hA _ p le_rfl]; exact hp.2 have k3 : alpha_lexical_lt t (u ++ t) ↔ alpha_signed_cell t p < alpha_signed_cell u p := by rw [alpha_nosq_lt_iff_first_diff _ _ p, hA t p le_rfl] · intro j hj; rw [hA t j hj.le, hmin j hj] · rw [hA t p le_rfl]; exact hp.2 have k4 : alpha_lexical_lt (u ++ u ++ t) t ↔ alpha_signed_cell u p < alpha_signed_cell t p := by rw [List.append_assoc, alpha_nosq_lt_iff_first_diff _ _ p, hA _ p le_rfl] · intro j hj; rw [hA _ j hj.le, hmin j hj] · rw [hA _ p le_rfl]; exact fun h => hp.2 h.symm rw [k1, k2, k3, k4] exact ⟨fun h1 h2 => lt_asymm h1 h2, fun h1 h2 => lt_asymm h1 h2⟩theorem alpha_lexical_no_odd_square_prefix (u tail : List ℕ) (hodd : u.length % 2 = 1) : ¬ alpha_is_lexical (u ++ u ++ tail) := by rintro ⟨_, hpos, hlex⟩ have hu : ∀ v ∈ u, 0 < v := fun v hv => hpos v (by simp [hv]) have hlen : 0 < u.length := by omega have hpar : ∀ x y : List ℕ, alpha_lexical_lt (u ++ x) (u ++ y) ↔ alpha_lexical_lt y x := by intro x y rw [alpha_lexical_lt_append_parity] simp [hodd] have F1 := hlex u.length (by simp; omega) hlen rw [List.append_assoc, List.drop_left, hpar] at F1 rcases tail with _ | ⟨x, xs⟩ · rw [List.append_nil] at F1 have h0 : 0 < u.getD 0 0 := by rw [List.getD_eq_getElem _ _ hlen]; exact hu _ (List.getElem_mem hlen) have e1 : alpha_signed_cell u 0 = (u.getD 0 0 : ℤ) := by simp [alpha_signed_cell] have e2 : alpha_signed_cell ([] : List ℕ) 0 = 0 := by simp [alpha_signed_cell] rw [alpha_nosq_lt_iff_first_diff _ _ 0 (by intro j hj; omega) (by rw [e1, e2]; omega), e1, e2] at F1 omega · have F2 := hlex (u.length + u.length) (by simp) (by omega) have hd : (u ++ u ++ (x :: xs)).drop (u.length + u.length) = x :: xs := by rw [List.append_assoc]; simp rw [hd] at F2 exact (alpha_nosq_core u hu hodd (x :: xs)).1 F1 F2