alpha_lexical_even_prefix_append_decrement
For a lexical sequence with an even-length nonempty lexical prefix and a following cell greater than one, appending one less than that cell to the prefix produces a lexical sequence.
Statement
theorem alpha_lexical_even_prefix_append_decrement (a : List ℕ) (i : ℕ) (ha : alpha_is_lexical a) (hi0 : 0 < i) (hi : i < a.length) (he : i % 2 = 0) (hc : 1 < a.getD i 0) (hp : alpha_is_lexical (a.take i)) : alpha_is_lexical (a.take i ++ [a.getD i 0 - 1])- Source
- Even-split factorization helper for OP-392, arXiv:2610.24758; alternating order and extensions as in arXiv:0810.5205.
- Verified
- 18 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 6
- 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.
- 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
To show that appending one less than cell a[i] to the even-length lexical prefix a.take i produces a lexical sequence, the proof first checks non-emptiness and positivity (using a[i] > 1). For any proper non-empty suffix at offset k, if k = i the suffix is the singleton [a[i] - 1], which is strictly smaller at index 0 because a[i] - 1 < a[i] ≤ a[0] by the lexicality of a. When k < i, the prefix's own lexicality provides a first differing cell q: if q < i - k the difference is within the prefix and is unaffected by the appended cell, while if q ≥ i - k, parity and signed-cell positivity force q = i - k to be even, whereupon comparing a.drop k with a yields a[i] ≤ a[i - k] and ensures the decremented cell is strictly smaller than a[i - k].
At any index at or beyond the length of a list, its signed cell evaluates to zero.
Unfolding the definition of signed cell, an index j ≥ |A| defaults to 0 via List.getD_eq_default. Whether the index is even (+0) or odd (-0), the signed cell simplifies to 0.
uses
List.getD_eq_defaultunfold alpha_signed_cell rw [List.getD_eq_default _ _ h]; split_ifs <;> simp
If A is strictly less than B in signed lexical order and they agree on all signed cells at indices j < L, then at index L the signed cell of A is at most that of B.
Let r be the first index where the signed cells of A and B differ, with A's signed cell strictly smaller than B's. By trichotomy on r and L via lt_trichotomy: if r < L, the difference contradicts the hypothesis that A and B agree up to L (via ne_of_lt); if r = L, the strict inequality implies a weak inequality; if L < r, A and B agree at L by definition of r, which also gives a weak inequality.
uses
lt_trichotomy,ne_of_ltobtain ⟨r, _, hpre, hr⟩ := hlt rcases lt_trichotomy r L with h | h | h · exact absurd (heq r h) (ne_of_lt hr) · exact h ▸ hr.le · exact (hpre L h).le
Two lists have identical signed cells at index j if and only if their underlying list elements at j are equal.
Unfolding alpha_signed_cell and splitting on the parity of j, the equality reduces either to A[j] = B[j] for even j or -A[j] = -B[j] for odd j, both of which are equivalent to A[j] = B[j] by integer arithmetic.
unfold alpha_signed_cell split_ifs <;> omega
At any even index j, the signed cell of a list equals its underlying element value as an integer.
Unfolding alpha_signed_cell, the condition j % 2 = 0 is satisfied, so the conditional evaluates directly to +A[j] via if_pos.
uses
if_posunfold alpha_signed_cell; rw [if_pos h]
Taking a prefix of length i preserves the list elements at all indices j < i.
Rewriting with List.getD_eq_getElem?_getD confirms that taking i elements leaves the element at index j < i identical to the original list's element.
uses
List.getD_eq_getElem?_getDsimp [List.getD_eq_getElem?_getD, hj]Dropping k elements shifts the index of every element by k.
Rewriting with List.getD_eq_getElem?_getD and List.getElem?_drop shows that element j of a dropped list equals element k + j of the original list.
uses
List.getD_eq_getElem?_getD,List.getElem?_dropsimp [List.getD_eq_getElem?_getD, List.getElem?_drop]The candidate list f = (a.take i) ++ [a[i] - 1] agrees with a at all indices j < i and takes value a[i] - 1 at index i.
Unpack the lexicality assumptions for a and its prefix. The prefix has length i. For any index j < i, accessing f returns the j-th element of the prefix via alpha_pdec_getD_append_left and alpha_pdec_getD_take, which matches a[j]. At index i, List.getD_append_right accesses the appended singleton, yielding a[i] - 1.
uses
alpha_pdec_getD_append_left,alpha_pdec_getD_take,List.getD_append_rightobtain ⟨_, hpos, hlex⟩ := ha obtain ⟨_, _, hplex⟩ := hp have hpl : (a.take i).length = i := by simp; omega -- cells of f have hfj : ∀ j < i, (a.take i ++ [a.getD i 0 - 1]).getD j 0 = a.getD j 0 := by intro j hj rw [alpha_pdec_getD_append_left _ _ _ (by omega), alpha_pdec_getD_take _ _ _ hj] have hfi : (a.take i ++ [a.getD i 0 - 1]).getD i 0 = a.getD i 0 - 1 := by rw [List.getD_append_right _ _ _ _ (by omega)]; simp [hpl]
The candidate list f is non-empty and all of its elements are strictly positive.
The length of f is i + 1 > 0, so f is non-empty. Every element of f belongs either to the prefix a.take i or to the appended singleton [a[i] - 1] via List.mem_append.mp. Elements from the prefix belong to a by List.mem_of_mem_take and are positive because a is lexical. The appended element a[i] - 1 is positive because a[i] > 1 by hypothesis.
uses
List.mem_append.mp,List.mem_of_mem_take,List.mem_singletonrefine ⟨by simp, ?_, ?_⟩ · intro v hv rcases List.mem_append.mp hv with hv | hv · exact hpos v (List.mem_of_mem_take hv) · rw [List.mem_singleton] at hv; subst hv; omega
For any non-empty proper suffix offset 0 < k < |f| = i + 1, express the suffix f.drop k as D ++ [a[i] - 1] where D = (a.take i).drop k, and note a.drop k <_{lex} a.
Simplify the bound k < i + 1 using List.length_append and List.length_singleton. Distribute dropping over concatenation via List.drop_append_of_le_length to write f.drop k as D ++ [a[i] - 1], where D has length i - k. For any offset j with k + j < i, D[j] matches a[k + j] by alpha_pdec_getD_drop and alpha_pdec_getD_take. Since a is lexical, its suffix a.drop k is strictly smaller than a in signed lexical order.
uses
List.length_append,List.length_singleton,List.drop_append_of_le_length,alpha_pdec_getD_drop,alpha_pdec_getD_take· intro k hk hk0 simp only [List.length_append, hpl, List.length_singleton] at hk have hdrop : (a.take i ++ [a.getD i 0 - 1]).drop k = (a.take i).drop k ++ [a.getD i 0 - 1] := List.drop_append_of_le_length (by omega) set D := (a.take i).drop k with hD have hDl : D.length = i - k := by simp [hD, hpl] have hDg : ∀ j, k + j < i → D.getD j 0 = a.getD (k + j) 0 := by intro j hj; rw [hD, alpha_pdec_getD_drop, alpha_pdec_getD_take _ _ _ hj] rw [hdrop] -- a's suffix at k agrees with D ++ a.drop i have hak : ∀ j, (a.drop k).getD j 0 = a.getD (k + j) 0 := alpha_pdec_getD_drop a k have hLk := hlex k (by omega) hk0
When k = i, the suffix f.drop i is strictly smaller than f in signed lexical order at index 0.
When k = i, D has length 0, so D is empty by List.length_eq_zero_iff, and the suffix is the singleton [a[i] - 1]. Since a.drop i <_{lex} a, lemma alpha_pdec_signed_le applied at index 0 gives a[i] ≤ a[0] (as index 0 is even via alpha_pdec_signed_even and Nat.add_zero). Because a[i] - 1 < a[i] ≤ a[0], the signed cell of the suffix at index 0 is strictly less than that of f, establishing f.drop i <_{lex} f.
uses
alpha_pdec_signed_le,Nat.add_zero,alpha_pdec_signed_even,List.length_eq_zero_iff,List.nil_append,List.getD_cons_zeroby_cases hki : k = i · subst hki -- compare [x] with f at cell 0 have h0 := alpha_pdec_signed_le _ _ 0 hLk (by intro j hj; omega) have ha0 : (a.drop k).getD 0 0 = a.getD k 0 := by rw [hak, Nat.add_zero] rw [alpha_pdec_signed_even _ _ (by norm_num), alpha_pdec_signed_even _ _ (by norm_num), ha0] at h0 have h0' : a.getD k 0 ≤ a.getD 0 0 := by exact_mod_cast h0 refine ⟨0, by simp, by intro j hj; omega, ?_⟩ have hD0 : D = [] := by rw [← List.length_eq_zero_iff, hDl]; simp rw [alpha_pdec_signed_even _ _ (by norm_num), alpha_pdec_signed_even _ _ (by norm_num), hfj 0 hi0, hD0] simp only [List.nil_append, List.getD_cons_zero] have : a.getD k 0 - 1 < a.getD 0 0 := by omega exact_mod_cast this
When k < i and the prefix suffix D differs from a.take i at an index q < i - k, f.drop k is strictly smaller than f at index q.
Lexicality of the prefix gives that D <_{lex} a.take i with first difference at some index q. If q < i - k = |D|, the difference occurs strictly before the end of D. Because q is within the bounds of both prefixes, appending further elements via alpha_pdec_getD_append_left affects neither the agreement for indices below q nor the signed cells at q. Thus f.drop k and f first differ at index q, inheriting D's strict inequality.
uses
alpha_pdec_signed_eq_iff,alpha_pdec_getD_append_left· have hki' : k < i := by omega obtain ⟨q, _, hpre, hq⟩ := hplex k (by omega) hk0 by_cases hqL : q < i - k · refine ⟨q, by simp; omega, ?_, ?_⟩ · intro j hj have := hpre j hj rw [alpha_pdec_signed_eq_iff] at this ⊢ rw [alpha_pdec_getD_append_left _ _ _ (by omega), alpha_pdec_getD_append_left _ _ _ (by omega)] exact this · have e1 : ∀ B : List ℕ, alpha_signed_cell (D ++ B) q = alpha_signed_cell D q := by intro B; unfold alpha_signed_cell rw [alpha_pdec_getD_append_left _ _ _ (by omega)] have e2 : ∀ B : List ℕ, alpha_signed_cell (a.take i ++ B) q = alpha_signed_cell (a.take i) q := by intro B; unfold alpha_signed_cell rw [alpha_pdec_getD_append_left _ _ _ (by omega)] rw [e1, e2]; exact hq
When k < i and the mismatch index satisfies q ≥ i - k, the mismatch index must be exactly q = i - k, and i - k must be even.
Since |D| = i - k ≤ q, D's signed cell at q is 0 by alpha_pdec_signed_zero. The index q must be strictly less than i, because if q ≥ i then both lists would have signed cell 0 at q, contradicting strict inequality via lt_irrefl. If q > i - k, then D and a.take i would agree at i - k; but at i - k, D is out of bounds (value 0 via List.getD_eq_default and le_of_eq) while a.take i has positive value a[i - k] > 0 by List.getD_eq_getElem and List.getElem_mem, a contradiction by alpha_pdec_signed_eq_iff. Hence q = i - k. Because D's signed cell at q is 0 and is strictly less than that of a.take i, the latter signed cell must be strictly positive, which forces i - k to be even (an odd index would yield a negative value).
uses
alpha_pdec_signed_zero,lt_irrefl,List.getD_eq_getElem,List.getElem_mem,alpha_pdec_signed_eq_iff,alpha_pdec_getD_take,List.getD_eq_default,le_of_eqhave hDlq : D.length ≤ q := by rw [hDl]; omega have hDz : alpha_signed_cell D q = 0 := alpha_pdec_signed_zero _ _ hDlq have hqi : q < i := by by_contra hcon have : alpha_signed_cell (a.take i) q = 0 := alpha_pdec_signed_zero _ _ (by rw [hpl]; omega) rw [hDz, this] at hq; exact lt_irrefl _ hq have hpq : 0 < a.getD q 0 := by rw [List.getD_eq_getElem _ _ (by omega)] exact hpos _ (List.getElem_mem _) have hqeq : q = i - k := by by_contra hne have hL := hpre (i - k) (by omega) rw [alpha_pdec_signed_eq_iff, alpha_pdec_getD_take _ _ _ (by omega), List.getD_eq_default _ _ (le_of_eq hDl)] at hL have : 0 < a.getD (i - k) 0 := by rw [List.getD_eq_getElem _ _ (by omega)] exact hpos _ (List.getElem_mem _) omega subst hqeq have heven : (i - k) % 2 = 0 := by rw [hDz] at hq unfold alpha_signed_cell at hq split_ifs at hq with hh · exact hh · omega
When k < i and q = i - k, f.drop k is strictly smaller than f in signed lexical order at index i - k, completing the proof.
Since a.drop k <_{lex} a and their signed cells agree at all j < i - k, lemma alpha_pdec_signed_le implies their signed cells at the even index i - k satisfy a[i] ≤ a[i - k]. For all j < i - k, f.drop k and f agree because D and a.take i agree. At index i - k, the cell of f.drop k is the appended element a[i] - 1 (via List.getD_append_right), while f has cell a[i - k]. Since i - k is even and a[i] - 1 < a[i] ≤ a[i - k], the signed cell of f.drop k at index i - k is strictly less than that of f, proving f.drop k <_{lex} f.
uses
alpha_pdec_signed_eq_iff,alpha_pdec_getD_take,alpha_pdec_signed_le,alpha_pdec_getD_append_left,List.getD_append_righthave hagree : ∀ j < i - k, alpha_signed_cell (a.drop k) j = alpha_signed_cell a j := by intro j hj have := hpre j hj rw [alpha_pdec_signed_eq_iff] at this ⊢ rw [hak, ← hDg j (by omega), this, alpha_pdec_getD_take _ _ _ (by omega)] have hle := alpha_pdec_signed_le _ _ (i - k) hLk hagree have hik : k + (i - k) = i := by omega simp only [alpha_signed_cell, heven, if_true, hak, hik] at hle refine ⟨i - k, by simp; omega, ?_, ?_⟩ · intro j hj have := hpre j hj rw [alpha_pdec_signed_eq_iff] at this ⊢ rw [alpha_pdec_getD_append_left _ _ _ (by omega), this, hfj j (by omega), alpha_pdec_getD_take _ _ _ (by omega)] · have g1 : (D ++ [a.getD i 0 - 1]).getD (i - k) 0 = a.getD i 0 - 1 := by rw [List.getD_append_right _ _ _ _ (by omega)]; simp [hDl] simp only [alpha_signed_cell, heven, if_true, g1, hfj (i - k) (by omega)] omega
List.getD_eq_default- For any index at or beyond the length of a list, the default-element lookup returns the default value.
lt_trichotomy- For any two elements in a linear order, either the first is strictly less than the second, they are equal, or the first is strictly greater than the second.
ne_of_lt- If a is strictly less than b, then a does not equal b.
if_pos- If a proposition c holds, then the conditional expression `if c then t else e` equals t.
List.getD_eq_getElem?_getD- Looking up an element with a default value is equivalent to defaulting on the optional element lookup.
List.getElem?_drop- The j-th element of a list dropped by i elements is the (i + j)-th element of the original list.
alpha_pdec_getD_append_left- For any index j strictly within the length of a list u, the j-th element of u ++ X equals the j-th element of u.
alpha_pdec_getD_take- For any index j strictly less than i, the j-th element of the prefix of length i equals the j-th element of the original list.
List.getD_append_right- For any index n at or beyond the length of l, the n-th element of l ++ l' is the (n - |l|)-th element of l'.
List.mem_append.mp- If an element belongs to the concatenation of two lists, it belongs to the first list or the second list.
List.mem_of_mem_take- Any element belonging to a prefix of a list also belongs to the original list.
List.mem_singleton- An element belongs to a singleton list if and only if it equals the sole element of that list.
List.length_append- The length of the concatenation of two lists is the sum of their lengths.
List.length_singleton- A singleton list containing one element has length 1.
List.drop_append_of_le_length- Dropping i elements from a concatenated list l₁ ++ l₂ when i is at most the length of l₁ equals dropping i elements from l₁ and appending l₂.
alpha_pdec_getD_drop- The j-th element of a list dropped by k elements is the (k + j)-th element of the original list.
alpha_pdec_signed_le- If list A is strictly smaller than B in signed lexical order and their signed cells agree at all indices below L, then at index L the signed cell of A is at most that of B.
Nat.add_zero- Adding zero to any natural number leaves it unchanged.
alpha_pdec_signed_even- At any even index j, the signed cell of a list equals its underlying element value as an integer.
List.length_eq_zero_iff- A list has length 0 if and only if it is the empty list.
List.nil_append- Prepending the empty list to any list yields the original list.
List.getD_cons_zero- The element at index 0 of a non-empty list is its head element.
alpha_pdec_signed_eq_iff- The signed cells of two lists at index j are equal if and only if their underlying list elements at index j are equal.
alpha_pdec_signed_zero- At any index at or beyond the length of a list, the signed cell evaluates to 0.
lt_irrefl- Strict inequality is irreflexive: no element is strictly less than itself.
List.getD_eq_getElem- For any index strictly within the bounds of a list, the default-element lookup returns the element at that index.
List.getElem_mem- Any element accessed at a valid index within bounds belongs to the list.
le_of_eq- Equality implies weak inequality: if a equals b, then a is less than or equal to b.
- The signed lexical comparison alternates signs by index parity (positive at even indices, negative at odd indices), so a smaller signed cell corresponds to a smaller element value at even positions but a larger element value at odd positions; the evenness of the prefix length ensures the decremented cell at position i - k retains its natural order.
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_pdec_signed_zero (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_pdec_signed_le (A B : List ℕ) (L : ℕ) (hlt : alpha_lexical_lt A B) (heq : ∀ j < L, alpha_signed_cell A j = alpha_signed_cell B j) : alpha_signed_cell A L ≤ alpha_signed_cell B L := by obtain ⟨r, _, hpre, hr⟩ := hlt rcases lt_trichotomy r L with h | h | h · exact absurd (heq r h) (ne_of_lt hr) · exact h ▸ hr.le · exact (hpre L h).letheorem alpha_pdec_signed_eq_iff (A B : List ℕ) (j : ℕ) : alpha_signed_cell A j = alpha_signed_cell B j ↔ A.getD j 0 = B.getD j 0 := by unfold alpha_signed_cell split_ifs <;> omegatheorem alpha_pdec_signed_even (A : List ℕ) (j : ℕ) (h : j % 2 = 0) : alpha_signed_cell A j = (A.getD j 0 : ℤ) := by unfold alpha_signed_cell; rw [if_pos h]theorem alpha_pdec_getD_take (a : List ℕ) (i j : ℕ) (hj : j < i) : (a.take i).getD j 0 = a.getD j 0 := by simp [List.getD_eq_getElem?_getD, hj]theorem alpha_pdec_getD_drop (a : List ℕ) (k j : ℕ) : (a.drop k).getD j 0 = a.getD (k + j) 0 := by simp [List.getD_eq_getElem?_getD, List.getElem?_drop]theorem alpha_pdec_getD_append_left (u X : List ℕ) (j : ℕ) (hj : j < u.length) : (u ++ X).getD j 0 = u.getD j 0 := List.getD_append _ _ _ _ hjtheorem alpha_lexical_even_prefix_append_decrement (a : List ℕ) (i : ℕ) (ha : alpha_is_lexical a) (hi0 : 0 < i) (hi : i < a.length) (he : i % 2 = 0) (hc : 1 < a.getD i 0) (hp : alpha_is_lexical (a.take i)) : alpha_is_lexical (a.take i ++ [a.getD i 0 - 1]) := by obtain ⟨_, hpos, hlex⟩ := ha obtain ⟨_, _, hplex⟩ := hp have hpl : (a.take i).length = i := by simp; omega -- cells of f have hfj : ∀ j < i, (a.take i ++ [a.getD i 0 - 1]).getD j 0 = a.getD j 0 := by intro j hj rw [alpha_pdec_getD_append_left _ _ _ (by omega), alpha_pdec_getD_take _ _ _ hj] have hfi : (a.take i ++ [a.getD i 0 - 1]).getD i 0 = a.getD i 0 - 1 := by rw [List.getD_append_right _ _ _ _ (by omega)]; simp [hpl] refine ⟨by simp, ?_, ?_⟩ · intro v hv rcases List.mem_append.mp hv with hv | hv · exact hpos v (List.mem_of_mem_take hv) · rw [List.mem_singleton] at hv; subst hv; omega · intro k hk hk0 simp only [List.length_append, hpl, List.length_singleton] at hk have hdrop : (a.take i ++ [a.getD i 0 - 1]).drop k = (a.take i).drop k ++ [a.getD i 0 - 1] := List.drop_append_of_le_length (by omega) set D := (a.take i).drop k with hD have hDl : D.length = i - k := by simp [hD, hpl] have hDg : ∀ j, k + j < i → D.getD j 0 = a.getD (k + j) 0 := by intro j hj; rw [hD, alpha_pdec_getD_drop, alpha_pdec_getD_take _ _ _ hj] rw [hdrop] -- a's suffix at k agrees with D ++ a.drop i have hak : ∀ j, (a.drop k).getD j 0 = a.getD (k + j) 0 := alpha_pdec_getD_drop a k have hLk := hlex k (by omega) hk0 by_cases hki : k = i · subst hki -- compare [x] with f at cell 0 have h0 := alpha_pdec_signed_le _ _ 0 hLk (by intro j hj; omega) have ha0 : (a.drop k).getD 0 0 = a.getD k 0 := by rw [hak, Nat.add_zero] rw [alpha_pdec_signed_even _ _ (by norm_num), alpha_pdec_signed_even _ _ (by norm_num), ha0] at h0 have h0' : a.getD k 0 ≤ a.getD 0 0 := by exact_mod_cast h0 refine ⟨0, by simp, by intro j hj; omega, ?_⟩ have hD0 : D = [] := by rw [← List.length_eq_zero_iff, hDl]; simp rw [alpha_pdec_signed_even _ _ (by norm_num), alpha_pdec_signed_even _ _ (by norm_num), hfj 0 hi0, hD0] simp only [List.nil_append, List.getD_cons_zero] have : a.getD k 0 - 1 < a.getD 0 0 := by omega exact_mod_cast this · have hki' : k < i := by omega obtain ⟨q, _, hpre, hq⟩ := hplex k (by omega) hk0 by_cases hqL : q < i - k · refine ⟨q, by simp; omega, ?_, ?_⟩ · intro j hj have := hpre j hj rw [alpha_pdec_signed_eq_iff] at this ⊢ rw [alpha_pdec_getD_append_left _ _ _ (by omega), alpha_pdec_getD_append_left _ _ _ (by omega)] exact this · have e1 : ∀ B : List ℕ, alpha_signed_cell (D ++ B) q = alpha_signed_cell D q := by intro B; unfold alpha_signed_cell rw [alpha_pdec_getD_append_left _ _ _ (by omega)] have e2 : ∀ B : List ℕ, alpha_signed_cell (a.take i ++ B) q = alpha_signed_cell (a.take i) q := by intro B; unfold alpha_signed_cell rw [alpha_pdec_getD_append_left _ _ _ (by omega)] rw [e1, e2]; exact hq · -- D is a proper prefix of the prefix; the decisive cell is L = i - k have hDlq : D.length ≤ q := by rw [hDl]; omega have hDz : alpha_signed_cell D q = 0 := alpha_pdec_signed_zero _ _ hDlq have hqi : q < i := by by_contra hcon have : alpha_signed_cell (a.take i) q = 0 := alpha_pdec_signed_zero _ _ (by rw [hpl]; omega) rw [hDz, this] at hq; exact lt_irrefl _ hq have hpq : 0 < a.getD q 0 := by rw [List.getD_eq_getElem _ _ (by omega)] exact hpos _ (List.getElem_mem _) have hqeq : q = i - k := by by_contra hne have hL := hpre (i - k) (by omega) rw [alpha_pdec_signed_eq_iff, alpha_pdec_getD_take _ _ _ (by omega), List.getD_eq_default _ _ (le_of_eq hDl)] at hL have : 0 < a.getD (i - k) 0 := by rw [List.getD_eq_getElem _ _ (by omega)] exact hpos _ (List.getElem_mem _) omega subst hqeq have heven : (i - k) % 2 = 0 := by rw [hDz] at hq unfold alpha_signed_cell at hq split_ifs at hq with hh · exact hh · omega -- a_i ≤ a_{i-k} from lexicality of a have hagree : ∀ j < i - k, alpha_signed_cell (a.drop k) j = alpha_signed_cell a j := by intro j hj have := hpre j hj rw [alpha_pdec_signed_eq_iff] at this ⊢ rw [hak, ← hDg j (by omega), this, alpha_pdec_getD_take _ _ _ (by omega)] have hle := alpha_pdec_signed_le _ _ (i - k) hLk hagree have hik : k + (i - k) = i := by omega simp only [alpha_signed_cell, heven, if_true, hak, hik] at hle refine ⟨i - k, by simp; omega, ?_, ?_⟩ · intro j hj have := hpre j hj rw [alpha_pdec_signed_eq_iff] at this ⊢ rw [alpha_pdec_getD_append_left _ _ _ (by omega), this, hfj j (by omega), alpha_pdec_getD_take _ _ _ (by omega)] · have g1 : (D ++ [a.getD i 0 - 1]).getD (i - k) 0 = a.getD i 0 - 1 := by rw [List.getD_append_right _ _ _ _ (by omega)]; simp [hDl] simp only [alpha_signed_cell, heven, if_true, g1, hfj (i - k) (by omega)] omega