AFTD Auto-Formalizing Theoretical Domains

alpha_last_blocking_suffix_is_lexical

theoremverified

For a positive sequence, its last suffix that is not smaller than the sequence is lexical.

Statement

theorem alpha_last_blocking_suffix_is_lexical (c : List ℕ) (s : ℕ) (hpos : ∀ v ∈ c, 0 < v) (hs0 : 0 < s) (hs : s < c.length) (hbad : ¬ alpha_lexical_lt (c.drop s) c) (hlast : ∀ t : ℕ, s < t → t < c.length → alpha_lexical_lt (c.drop t) c) : alpha_is_lexical (c.drop s)
Source
Last-blocker reduction for OP-392, arXiv:2610.24758; alternating lexical order as in arXiv:0810.5205.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 6

The proof, explained

For a positive sequence c, a suffix c.drop s that is not strictly smaller than c under the alternating signed lexical order, but where all strictly longer-dropped suffixes are strictly smaller, is itself lexical. The proof verifies the three defining conditions of being lexical: non-emptiness, positivity, and that all proper suffixes are strictly smaller. Non-emptiness and positivity follow immediately from s < |c| and positivity of c. The critical suffix condition relies on a pseudo-transitivity property of the signed lexical order: if X <_lex C and D is not <_lex C, then X <_lex D. Taking X = c.drop (s + k), C = c, and D = c.drop s, the maximality of s ensures X <_lex C, which combined with the blocking condition on D yields X <_lex D.

  1. The signed cell of a sequence at any index beyond its length is zero.

    By definition, the signed cell at index j is either A[j] or -A[j] with default value 0 for out-of-bounds indices. Since j ≥ |A|, the entry evaluates to 0 via List.getD_eq_default, and both +0 and -0 equal 0.

    lines 3–4

    uses List.getD_eq_default

      unfold alpha_signed_cell
      rw [List.getD_eq_default _ _ h]; split_ifs <;> simp
  2. Agreement on signed cells before an index p and strict inequality at p implies strict lexical inequality.

    By definition, A <_lex B requires an index strictly less than max(|A|, |B|) where all earlier signed cells agree and A's signed cell is strictly smaller than B's. Taking p as the witness, if p ≥ max(|A|, |B|), then p ≥ |A| and p ≥ |B| by transitivity (le_trans) with le_max_left and le_max_right. Then alpha_lbs_signed_zero implies both signed cells at p are zero, giving 0 < 0, which contradicts irreflexivity of strict inequality (lt_irrefl). Hence p < max(|A|, |B|), establishing A <_lex B.

    lines 9–14

    uses alpha_lbs_signed_zero, le_trans, le_max_left, le_max_right, lt_irrefl

      refine ⟨p, ?_, heq, hlt⟩
      by_contra hp
      push Not at hp
      rw [alpha_lbs_signed_zero A p (le_trans (le_max_left _ _) hp),
        alpha_lbs_signed_zero B p (le_trans (le_max_right _ _) hp)] at hlt
      exact lt_irrefl _ hlt
  3. Extract the first discrepancy index p between X and C, and if D and C differ, identify their minimal index of discrepancy q.

    From X <_lex C, we obtain an index p where X and C agree on all indices j < p and X's signed cell at p is strictly less than C's. We then case-split on whether there exists an index where D and C have differing signed cells. In the case where they differ, we let q be the minimal such index using Nat.find. By Nat.find_spec, D and C differ at q, and by Nat.find_min, they agree on all indices j < q.

    lines 18–26

    uses Nat.find_spec, Nat.find_min

      classical
      obtain ⟨p, _, hpre, hp⟩ := hX
      by_cases hex : ∃ q, alpha_signed_cell D q ≠ alpha_signed_cell C q
      · have hq := Nat.find_spec hex
        have hqmin : ∀ j < Nat.find hex, alpha_signed_cell D j = alpha_signed_cell C j := by
          intro j hj
          by_contra hne
          exact Nat.find_min hex hj hne
        set q := Nat.find hex
  4. At the first discrepancy index q between D and C, C's signed cell is strictly smaller than D's.

    Since D and C differ at q, by lt_or_gt_of_ne either D's signed cell is strictly less than C's or vice versa. If D's signed cell at q were strictly less than C's, then because D and C agree on all j < q, alpha_lbs_lt_of_ne would imply D <_lex C, contradicting the hypothesis that D is not strictly lexically smaller than C. Hence C's signed cell at q must be strictly less than D's.

    lines 27–30

    uses lt_or_gt_of_ne, alpha_lbs_lt_of_ne

        have hgt : alpha_signed_cell C q < alpha_signed_cell D q := by
          rcases lt_or_gt_of_ne hq with h | h
          · exact absurd (alpha_lbs_lt_of_ne D C q hqmin h) hD
          · exact h
  5. If p < q, then X is strictly lexically smaller than D.

    By lt_trichotomy, we compare p and q. When p < q, for all j < p we have j < q by lt_trans, so X and D both match C at j, making them equal. At index p, since p < q, D's signed cell equals C's, so X's signed cell at p is strictly less than D's. Applying alpha_lbs_lt_of_ne at index p gives X <_lex D.

    lines 31–34

    uses lt_trichotomy, alpha_lbs_lt_of_ne, lt_trans

        rcases lt_trichotomy p q with h | h | h
        · apply alpha_lbs_lt_of_ne X D p
          · intro j hj; rw [hpre j hj, hqmin j (lt_trans hj h)]
          · rw [hqmin p h]; exact hp
  6. If p = q, then X is strictly lexically smaller than D.

    When p = q, for all j < q, X and D both match C at j and are therefore equal. At index q, X's signed cell is strictly less than C's, which is strictly less than D's; by transitivity (lt_trans), X's signed cell at q is strictly less than D's. Applying alpha_lbs_lt_of_ne at index q yields X <_lex D.

    lines 35–38

    uses alpha_lbs_lt_of_ne, lt_trans

        · rw [h] at hp hpre
          apply alpha_lbs_lt_of_ne X D q
          · intro j hj; rw [hpre j hj, hqmin j hj]
          · exact lt_trans hp hgt
  7. If q < p, then X is strictly lexically smaller than D.

    When q < p, for all j < q we have j < p by lt_trans, so X and D both match C at j and are equal. At index q, since q < p, X's signed cell equals C's, which is strictly less than D's. Applying alpha_lbs_lt_of_ne at index q gives X <_lex D.

    lines 39–41

    uses alpha_lbs_lt_of_ne, lt_trans

        · apply alpha_lbs_lt_of_ne X D q
          · intro j hj; rw [hpre j (lt_trans hj h), hqmin j hj]
          · rw [hpre q h]; exact hgt
  8. If D and C have identical signed cells everywhere, then X is strictly lexically smaller than D.

    When no index exists where D and C differ, their signed cells agree at every index. Replacing C with D, X and D agree at all j < p and X's signed cell at p is strictly less than D's. Applying alpha_lbs_lt_of_ne at index p establishes X <_lex D.

    lines 42–45

    uses alpha_lbs_lt_of_ne

      · push Not at hex
        apply alpha_lbs_lt_of_ne X D p
        · intro j hj; rw [hpre j hj, hex j]
        · rw [hex p]; exact hp
  9. The suffix c.drop s is non-empty.

    To show that c.drop s is lexical, we first show it is non-empty. Assuming for contradiction that c.drop s = [], taking lengths via congrArg List.length gives |c| - s = 0. Since s < |c| by hypothesis, this contradicts linear integer arithmetic.

    lines 48–51

    uses congrArg, List.length

      refine ⟨?_, ?_, ?_⟩
      · intro h
        have := congrArg List.length h
        simp at this; omega
  10. All elements of c.drop s are strictly positive.

    Any element of c.drop s belongs to the original list c by List.mem_of_mem_drop. Since every element of c is strictly positive by hypothesis, all elements of c.drop s are strictly positive.

    lines 52–53

    uses List.mem_of_mem_drop

      · intro v hv
        exact hpos v (List.mem_of_mem_drop hv)
  11. Every non-empty proper suffix of c.drop s is strictly lexically smaller than c.drop s.

    Let k satisfy 0 < k < |c.drop s| = |c| - s, using List.length_drop. The k-th suffix of c.drop s is c.drop (s + k) by List.drop_drop. Since s < s + k < |c|, the assumption that s is the last blocking suffix implies c.drop (s + k) <_lex c. Because c.drop s is not strictly lexically smaller than c, applying the pseudo-transitivity lemma alpha_lbs_lt_of_lt_of_not_lt with X = c.drop (s + k), C = c, and D = c.drop s yields c.drop (s + k) <_lex c.drop s.

    lines 54–57

    uses List.length_drop, List.drop_drop, alpha_lbs_lt_of_lt_of_not_lt

      · intro k hk hk0
        simp only [List.length_drop] at hk
        rw [List.drop_drop]
        exact alpha_lbs_lt_of_lt_of_not_lt _ _ _ (hlast (s + k) (by omega) (by omega)) hbad
List.getD_eq_default
For any list l and default value d, accessing index n with |l| ≤ n returns d.
alpha_lbs_signed_zero
For any list A, its signed cell at any index j ≥ |A| is 0.
le_trans
Inequality ≤ is transitive: if a ≤ b and b ≤ c, then a ≤ c.
le_max_left
Any element a is less than or equal to max(a, b).
le_max_right
Any element b is less than or equal to max(a, b).
lt_irrefl
Strict inequality is irreflexive: no element is strictly less than itself.
Nat.find_spec
The minimal witness produced by Nat.find satisfies the given predicate.
Nat.find_min
No natural number strictly smaller than Nat.find satisfies the given predicate.
lt_or_gt_of_ne
In a linear order, two unequal elements satisfy a < b or b < a.
alpha_lbs_lt_of_ne
If lists A and B agree on signed cells at all indices j < p and A has a strictly smaller signed cell at p, then A is strictly lexically smaller than B.
lt_trichotomy
In a linear order, for any two elements exactly one holds: a < b, a = b, or b < a.
lt_trans
Strict inequality is transitive: if a < b and b < c, then a < c.
congrArg
Equal inputs to a function yield equal outputs.
List.length
The length function mapping a list to its number of elements.
List.mem_of_mem_drop
Any element in a dropped suffix of a list belongs to the original list.
List.length_drop
The length of a list after dropping i elements is the original length minus i.
List.drop_drop
Dropping i elements from a list with j elements already dropped is equivalent to dropping j + i elements from the original list.
alpha_lbs_lt_of_lt_of_not_lt
If X is strictly lexically smaller than C and D is not strictly lexically smaller than C, then X is strictly lexically smaller than D.

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_lbs_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_lbs_lt_of_ne (A B : List ℕ) (p : ℕ)    (heq : ∀ j < p, alpha_signed_cell A j = alpha_signed_cell B j)    (hlt : alpha_signed_cell A p < alpha_signed_cell B p) : alpha_lexical_lt A B := by  refine ⟨p, ?_, heq, hlt⟩  by_contra hp  push Not at hp  rw [alpha_lbs_signed_zero A p (le_trans (le_max_left _ _) hp),    alpha_lbs_signed_zero B p (le_trans (le_max_right _ _) hp)] at hlt  exact lt_irrefl _ hlttheorem alpha_lbs_lt_of_lt_of_not_lt (X C D : List ℕ) (hX : alpha_lexical_lt X C)    (hD : ¬ alpha_lexical_lt D C) : alpha_lexical_lt X D := by  classical  obtain ⟨p, _, hpre, hp⟩ := hX  by_cases hex : ∃ q, alpha_signed_cell D q ≠ alpha_signed_cell C q  · have hq := Nat.find_spec hex    have hqmin : ∀ j < Nat.find hex, alpha_signed_cell D j = alpha_signed_cell C j := by      intro j hj      by_contra hne      exact Nat.find_min hex hj hne    set q := Nat.find hex    have hgt : alpha_signed_cell C q < alpha_signed_cell D q := by      rcases lt_or_gt_of_ne hq with h | h      · exact absurd (alpha_lbs_lt_of_ne D C q hqmin h) hD      · exact h    rcases lt_trichotomy p q with h | h | h    · apply alpha_lbs_lt_of_ne X D p      · intro j hj; rw [hpre j hj, hqmin j (lt_trans hj h)]      · rw [hqmin p h]; exact hp    · rw [h] at hp hpre      apply alpha_lbs_lt_of_ne X D q      · intro j hj; rw [hpre j hj, hqmin j hj]      · exact lt_trans hp hgt    · apply alpha_lbs_lt_of_ne X D q      · intro j hj; rw [hpre j (lt_trans hj h), hqmin j hj]      · rw [hpre q h]; exact hgt  · push Not at hex    apply alpha_lbs_lt_of_ne X D p    · intro j hj; rw [hpre j hj, hex j]    · rw [hex p]; exact hptheorem alpha_last_blocking_suffix_is_lexical (c : List ℕ) (s : ℕ) (hpos : ∀ v ∈ c, 0 < v) (hs0 : 0 < s) (hs : s < c.length) (hbad : ¬ alpha_lexical_lt (c.drop s) c) (hlast : ∀ t : ℕ, s < t → t < c.length → alpha_lexical_lt (c.drop t) c) : alpha_is_lexical (c.drop s) := by  refine ⟨?_, ?_, ?_⟩  · intro h    have := congrArg List.length h    simp at this; omega  · intro v hv    exact hpos v (List.mem_of_mem_drop hv)  · intro k hk hk0    simp only [List.length_drop] at hk    rw [List.drop_drop]    exact alpha_lbs_lt_of_lt_of_not_lt _ _ _ (hlast (s + k) (by omega) (by omega)) hbad
See it in the graphDiscuss this resultChallenge it