-- Mathlib/.lake/packages/lean4/src/lean/Init/Data/List/Lex.lean
theorem lex_eq_true_iff_exists [BEq α] (lt : α → α → Bool) :
    lex l₁ l₂ lt = true ↔
      (l₁.isEqv (l₂.take l₁.length) (· == ·) ∧ l₁.length < l₂.length) ∨
        (∃ (i : Nat) (h₁ : i < l₁.length) (h₂ : i < l₂.length),
          (∀ j, (hj : j < i) →
            l₁[j]'(Nat.lt_trans hj h₁) == l₂[j]'(Nat.lt_trans hj h₂)) ∧ lt l₁[i] l₂[i])

Proof state:
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
i : Nat
h₁ : i + 1 < l₁.length + 1
h₂ : i + 1 < l₂.length + 1
w₁ : ∀ (j : Nat) (hj : j < i + 1), ((a :: l₁)[j] == (b :: l₂)[j]) = true
w₂ : lt (a :: l₁)[i + 1] (b :: l₂)[i + 1] = true
⊢ i < l₁.length

Tactic:
simpa using h₁

Result:
no goals

Proof state:
case cons.cons.mpr.inr.intro.intro.intro.intro.zero.h
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
h₁ : 0 < l₁.length + 1
h₂ : 0 < l₂.length + 1
w₁ : ∀ (j : Nat) (hj : j < 0), ((a :: l₁)[j] == (b :: l₂)[j]) = true
w₂ : lt (a :: l₁)[0] (b :: l₂)[0] = true
⊢ lt a b = true

Tactic:
simpa using w₂

Result:
no goals

Proof state:
case cons.cons.mp.inr.intro.inr.intro.intro.intro.intro.refine_2
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
hab : (a == b) = true
i : Nat
h₁ : i < l₁.length
h₂ : i < l₂.length
w₁ : ∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true
w₂ : lt l₁[i] l₂[i] = true
⊢ lt (a :: l₁)[i + 1] (b :: l₂)[i + 1] = true

Tactic:
simpa using w₂

Result:
no goals

Proof state:
case cons.nil
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
⊢ (a :: l₁).lex [] lt = true ↔
    ((a :: l₁).isEqv (take (a :: l₁).length []) fun x1 x2 => x1 == x2) = true ∧ (a :: l₁).length < [].length ∨
      ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), ((a :: l₁)[j] == [][j]) = true) ∧ lt (a :: l₁)[i] [][i] = true

Tactic:
simp [lex]

Result:
no goals

Proof state:
case cons.cons
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
⊢ lt a b = true ∨
      (a == b) = true ∧
        ((l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
          ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true) ↔
    ((a == b) = true ∧ (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true) ∧ l₁.length < l₂.length ∨
      ∃ i h h₂, (∀ (j : Nat) (hj : j < i), ((a :: l₁)[j] == (b :: l₂)[j]) = true) ∧ lt (a :: l₁)[i] (b :: l₂)[i] = true

Tactic:
constructor

Result:
case cons.cons.mp
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
⊢ lt a b = true ∨
      (a == b) = true ∧
        ((l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
          ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true) →
    ((a == b) = true ∧ (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true) ∧ l₁.length < l₂.length ∨
      ∃ i h h₂, (∀ (j : Nat) (hj : j < i), ((a :: l₁)[j] == (b :: l₂)[j]) = true) ∧ lt (a :: l₁)[i] (b :: l₂)[i] = true

case cons.cons.mpr
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
⊢ (((a == b) = true ∧ (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true) ∧ l₁.length < l₂.length ∨
      ∃ i h h₂,
        (∀ (j : Nat) (hj : j < i), ((a :: l₁)[j] == (b :: l₂)[j]) = true) ∧ lt (a :: l₁)[i] (b :: l₂)[i] = true) →
    lt a b = true ∨
      (a == b) = true ∧
        ((l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
          ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true)

Proof state:
case cons.cons.mp.inr.intro.inl.intro
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
hab : (a == b) = true
h₁ : (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true
h₂ : l₁.length < l₂.length
⊢ ((a == b) = true ∧ (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true) ∧ l₁.length < l₂.length ∨
    ∃ i h h₂, (∀ (j : Nat) (hj : j < i), ((a :: l₁)[j] == (b :: l₂)[j]) = true) ∧ lt (a :: l₁)[i] (b :: l₂)[i] = true

Tactic:
exact .inl ⟨⟨hab, h₁⟩, by simpa using h₂⟩

Result:
no goals

Proof state:
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
i : Nat
h₁ : i + 1 < l₁.length + 1
h₂ : i + 1 < l₂.length + 1
w₁ : ∀ (j : Nat) (hj : j < i + 1), ((a :: l₁)[j] == (b :: l₂)[j]) = true
w₂ : lt (a :: l₁)[i + 1] (b :: l₂)[i + 1] = true
j : Nat
hj : j < i
⊢ j + 1 < i + 1

Tactic:
simpa

Result:
no goals

Proof state:
α : Type u_1
inst✝ : BEq α
lt : α → α → Bool
a : α
l₁ : List α
ih :
  ∀ {l₂ : List α},
    l₁.lex l₂ lt = true ↔
      (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true ∧ l₁.length < l₂.length ∨
        ∃ i h₁ h₂, (∀ (j : Nat) (hj : j < i), (l₁[j] == l₂[j]) = true) ∧ lt l₁[i] l₂[i] = true
b : α
l₂ : List α
h₃ : l₁.length < l₂.length
h₁ : (a == b) = true
h₂ : (l₁.isEqv (take l₁.length l₂) fun x1 x2 => x1 == x2) = true
⊢ l₁.length < l₂.length

Tactic:
simpa using h₃

Result:
no goals