AFTD Auto-Formalizing Theoretical Domains

alpha_lexical_second_cell_lt_first

theoremverified

The second cell of any lexical sequence of length at least two is strictly smaller than its first cell.

Statement

theorem alpha_lexical_second_cell_lt_first (a : List ℕ)
 (ha : alpha_is_lexical a) (hlen : 2 ≤ a.length) : a.getD 1 0 < a.getD 0 0
Source
Elementary lexical cell bound for OP-392, arXiv:2610.24758.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 6

The proof, explained

The proof proceeds by contradiction. If the second cell were not strictly smaller than the first, it would have to equal it because every cell in a lexical sequence is bounded above by the first cell. Selecting the maximal index r ≥ 1 with a[r] = a[0], the next cell satisfies a[r + 1] < a[0]. This ensures that the suffix a.drop r matches a at index 0 but has a strictly smaller value at index 1, making a strictly less than a.drop r in the lexical order due to the alternating sign on odd indices. However, lexicality requires every proper suffix to be strictly smaller than a, resulting in a < a, an impossibility.

  1. Assuming for contradiction that the second cell is not strictly smaller than the first, the two cells must be equal: a[1] = a[0].

    Every cell in a lexical sequence is at most the first cell (by alpha_lexical_first_negative_step_exists_cell_le_first), so a[1] ≤ a[0] because the sequence has length at least 2. Supposing for contradiction that ¬(a[1] < a[0]), linear arithmetic implies a[1] = a[0].

    lines 2–5

    uses alpha_lexical_first_negative_step_exists_cell_le_first

     (ha : alpha_is_lexical a) (hlen : 2 ≤ a.length) : a.getD 1 0 < a.getD 0 0 := by  classical
      have hle := alpha_lexical_first_negative_step_exists_cell_le_first a ha 1 (by omega)
      by_contra hnot
      have heq : a.getD 1 0 = a.getD 0 0 := by omega
  2. There exists a maximal index r ≥ 1 within bounds such that a[r] = a[0].

    We define s as the finite set of indices k < a.length where a[k] = a[0]. Since 1 < a.length and a[1] = a[0], 1 belongs to s (by Finset.mem_filter and Finset.mem_range), so s is nonempty. Taking r to be the maximum of s (Finset.max'_mem), we have r < a.length and a[r] = a[0] (by Finset.mem_range.mp and Finset.mem_filter.mp). Since 1 ∈ s, Finset.le_max' gives r ≥ 1 > 0.

    lines 6–17

    uses Finset.mem_filter, Finset.mem_range, Finset.max'_mem, Finset.mem_range.mp, Finset.mem_filter.mp, Finset.le_max'

      let s : Finset ℕ := (Finset.range a.length).filter (fun k => a.getD k 0 = a.getD 0 0)
      have h1s : 1 ∈ s := by
        simp only [s, Finset.mem_filter, Finset.mem_range]
        exact ⟨by omega, heq⟩
      have hs : s.Nonempty := ⟨1, h1s⟩
      let r := s.max' hs
      have hrs : r ∈ s := Finset.max'_mem s hs
      have hrlen : r < a.length := Finset.mem_range.mp (Finset.mem_filter.mp hrs).1
      have hrval : a.getD r 0 = a.getD 0 0 := (Finset.mem_filter.mp hrs).2
      have hrpos : 0 < r := by
        have := Finset.le_max' s 1 h1s
        omega
  3. The cell immediately following r is strictly less than the first cell: a[r + 1] < a[0].

    The first cell is strictly positive (alpha_lexical_first_negative_step_exists_cell_pos). We split into two cases: if r + 1 < a.length, then a[r + 1] ≤ a[0] by alpha_lexical_first_negative_step_exists_cell_le_first; moreover a[r + 1] cannot equal a[0], otherwise r + 1 would be in s (Finset.mem_filter, Finset.mem_range), contradicting the maximality of r via Finset.le_max'. If instead r + 1 ≥ a.length, the cell defaults to 0 by List.getD_eq_default, which is strictly less than a[0] > 0.

    lines 18–32

    uses alpha_lexical_first_negative_step_exists_cell_pos, alpha_lexical_first_negative_step_exists_cell_le_first, Finset.mem_filter, Finset.mem_range, Finset.le_max', List.getD_eq_default

      have hfirstpos : 0 < a.getD 0 0 :=
        alpha_lexical_first_negative_step_exists_cell_pos a ha 0 (by omega)
      have hnext : a.getD (r + 1) 0 < a.getD 0 0 := by
        by_cases hrl : r + 1 < a.length
        · have hnextle := alpha_lexical_first_negative_step_exists_cell_le_first a ha (r+1) hrl
          have hne : a.getD (r+1) 0 ≠ a.getD 0 0 := by
            intro h
            have hmem : r+1 ∈ s := by
              simp only [s, Finset.mem_filter, Finset.mem_range]
              exact ⟨hrl, h⟩
            have := Finset.le_max' s (r+1) hmem
            omega
          omega
        · have hz : a.getD (r+1) 0 = 0 := List.getD_eq_default _ _ (by omega)
          omega
  4. The suffix a.drop r has 0-th cell equal to a[0] and 1st cell strictly less than a[1].

    The initial element of a.drop r is a[r] by alpha_lexical_first_negative_step_exists_getD_drop_zero, which equals a[0] because r ∈ s. The element at index 1 of a.drop r is a[r + 1] by alpha_lexical_first_negative_step_exists_getD_drop, which is strictly less than a[0] = a[1] by the previous step.

    lines 33–37

    uses alpha_lexical_first_negative_step_exists_getD_drop_zero, alpha_lexical_first_negative_step_exists_getD_drop

      have h0 : a.getD 0 0 = (a.drop r).getD 0 0 := by
        rw [alpha_lexical_first_negative_step_exists_getD_drop_zero, hrval]
      have h1 : (a.drop r).getD 1 0 < a.getD 1 0 := by
        rw [alpha_lexical_first_negative_step_exists_getD_drop, heq]
        exact hnext
  5. This implies a < a in the lexical order, which is a contradiction.

    Since a and a.drop r agree at index 0 and (a.drop r)[1] < a[1], the lemma alpha_lexical_first_negative_step_exists_lt_of_second_cell_gt (using lt_of_lt_of_le and le_max_left to verify the length requirement) gives a < a.drop r. On the other hand, the definition of a lexical sequence requires every proper suffix to be strictly smaller than a, so a.drop r < a. By transitivity (alpha_lexical_first_negative_step_exists_lt_trans), a < a, which means some signed cell is strictly less than itself, contradicting the irreflexivity of strict inequality (lt_irrefl).

    lines 38–44

    uses alpha_lexical_first_negative_step_exists_lt_of_second_cell_gt, lt_of_lt_of_le, le_max_left, alpha_lexical_first_negative_step_exists_lt_trans, lt_irrefl

      have hlt : alpha_lexical_lt a (a.drop r) :=
        alpha_lexical_first_negative_step_exists_lt_of_second_cell_gt a (a.drop r) h0 h1
          (lt_of_lt_of_le (by omega : 1 < a.length) (le_max_left _ _))
      have hback : alpha_lexical_lt (a.drop r) a := ha.2.2 r hrlen hrpos
      have hirr := alpha_lexical_first_negative_step_exists_lt_trans a (a.drop r) a hlt hback
      rcases hirr with ⟨j, _, _, hj⟩
      exact (lt_irrefl _ hj)
alpha_lexical_first_negative_step_exists_cell_le_first
For any lexical sequence a and any index k < a.length, the k-th cell is at most the first cell (a[k] ≤ a[0]).
alpha_lexical_first_negative_step_exists_cell_pos
Every valid cell a[k] (for k < a.length) of a lexical sequence a is strictly positive.
alpha_lexical_first_negative_step_exists_getD_drop
The j-th element of the dropped list a.drop k is the (k + j)-th element of a.
alpha_lexical_first_negative_step_exists_getD_drop_zero
The 0-th element of the dropped list a.drop k is the k-th element of a.
alpha_lexical_first_negative_step_exists_lt_of_second_cell_gt
If two sequences x and y agree at index 0 and y has a strictly smaller value at index 1 than x, then x is strictly smaller than y in the lexical order, provided max(x.length, y.length) > 1.
alpha_lexical_first_negative_step_exists_lt_trans
The lexical order is transitive: if x < y and y < z, then x < z.
Finset.le_max'
Every element in a finite set is less than or equal to the maximum of the set.
Finset.max'_mem
The maximum element of a nonempty finite set is an element of the set.
Finset.mem_filter
An element belongs to a filtered set filter(p, s) if and only if it belongs to s and satisfies p.
Finset.mem_filter.mp
If an element belongs to filter(p, s), then it belongs to s and satisfies p.
Finset.mem_range
A natural number m belongs to range(n) if and only if m < n.
Finset.mem_range.mp
If a natural number belongs to range(n), then it is strictly less than n.
le_max_left
Any element a is less than or equal to max(a, b).
List.getD_eq_default
Accessing an out-of-bounds index in a list returns the given default value.
lt_irrefl
Strict inequality is irreflexive: no element is strictly less than itself.
lt_of_lt_of_le
Transitivity of strict inequality with weak inequality: if a < b and b ≤ c, then a < c.

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

theorem alpha_lexical_second_cell_lt_first (a : List ℕ) (ha : alpha_is_lexical a) (hlen : 2 ≤ a.length) : a.getD 1 0 < a.getD 0 0 := by  classical  have hle := alpha_lexical_first_negative_step_exists_cell_le_first a ha 1 (by omega)  by_contra hnot  have heq : a.getD 1 0 = a.getD 0 0 := by omega  let s : Finset ℕ := (Finset.range a.length).filter (fun k => a.getD k 0 = a.getD 0 0)  have h1s : 1 ∈ s := by    simp only [s, Finset.mem_filter, Finset.mem_range]    exact ⟨by omega, heq⟩  have hs : s.Nonempty := ⟨1, h1s⟩  let r := s.max' hs  have hrs : r ∈ s := Finset.max'_mem s hs  have hrlen : r < a.length := Finset.mem_range.mp (Finset.mem_filter.mp hrs).1  have hrval : a.getD r 0 = a.getD 0 0 := (Finset.mem_filter.mp hrs).2  have hrpos : 0 < r := by    have := Finset.le_max' s 1 h1s    omega  have hfirstpos : 0 < a.getD 0 0 :=    alpha_lexical_first_negative_step_exists_cell_pos a ha 0 (by omega)  have hnext : a.getD (r + 1) 0 < a.getD 0 0 := by    by_cases hrl : r + 1 < a.length    · have hnextle := alpha_lexical_first_negative_step_exists_cell_le_first a ha (r+1) hrl      have hne : a.getD (r+1) 0 ≠ a.getD 0 0 := by        intro h        have hmem : r+1 ∈ s := by          simp only [s, Finset.mem_filter, Finset.mem_range]          exact ⟨hrl, h⟩        have := Finset.le_max' s (r+1) hmem        omega      omega    · have hz : a.getD (r+1) 0 = 0 := List.getD_eq_default _ _ (by omega)      omega  have h0 : a.getD 0 0 = (a.drop r).getD 0 0 := by    rw [alpha_lexical_first_negative_step_exists_getD_drop_zero, hrval]  have h1 : (a.drop r).getD 1 0 < a.getD 1 0 := by    rw [alpha_lexical_first_negative_step_exists_getD_drop, heq]    exact hnext  have hlt : alpha_lexical_lt a (a.drop r) :=    alpha_lexical_first_negative_step_exists_lt_of_second_cell_gt a (a.drop r) h0 h1      (lt_of_lt_of_le (by omega : 1 < a.length) (le_max_left _ _))  have hback : alpha_lexical_lt (a.drop r) a := ha.2.2 r hrlen hrpos  have hirr := alpha_lexical_first_negative_step_exists_lt_trans a (a.drop r) a hlt hback  rcases hirr with ⟨j, _, _, hj⟩  exact (lt_irrefl _ hj)
See it in the graphDiscuss this resultChallenge it