Theorem: List.get_reverse_aux₂
File: Mathlib/Data/List/Basic.lean

tactic: have aux := get_reverse_aux₁ l (a :: r) 0
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
h1 : length (a :: l) - 1 - 0 < length (reverseAux (a :: l) r)
x✝ : 0 < length (a :: l)
⊢ get (reverseAux (a :: l) r) { val := length (a :: l) - 1 - 0, isLt := h1 } = get (a :: l) { val := 0, isLt := x✝ }

tactic: rw [zero_add] at aux
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
h1 : length (a :: l) - 1 - 0 < length (reverseAux (a :: l) r)
x✝ : 0 < length (a :: l)
aux :
  ∀ (h1 : 0 + length l < length (reverseAux l (a :: r))) (h2 : 0 < length (a :: r)),
    get (reverseAux l (a :: r)) { val := 0 + length l, isLt := h1 } = get (a :: r) { val := 0, isLt := h2 }
⊢ get (reverseAux (a :: l) r) { val := length (a :: l) - 1 - 0, isLt := h1 } = get (a :: l) { val := 0, isLt := x✝ }

tactic: exact aux _ (zero_lt_succ _)
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
h1 : length (a :: l) - 1 - 0 < length (reverseAux (a :: l) r)
x✝ : 0 < length (a :: l)
aux :
  ∀ (h1 : length l < length (reverseAux l (a :: r))) (h2 : 0 < length (a :: r)),
    get (reverseAux l (a :: r)) { val := length l, isLt := h1 } = get (a :: r) { val := 0, isLt := h2 }
⊢ get (reverseAux (a :: l) r) { val := length (a :: l) - 1 - 0, isLt := h1 } = get (a :: l) { val := 0, isLt := x✝ }

tactic: have aux := get_reverse_aux₂ l (a :: r) i
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
i : ℕ
h1 : length (a :: l) - 1 - (i + 1) < length (reverseAux (a :: l) r)
h2 : i + 1 < length (a :: l)
⊢ get (reverseAux (a :: l) r) { val := length (a :: l) - 1 - (i + 1), isLt := h1 } =
    get (a :: l) { val := i + 1, isLt := h2 }

tactic: have heq :=
  calc
    length (a :: l) - 1 - (i + 1) = length l - (1 + i) := by rw [add_comm]; rfl
    _ = length l - 1 - i := by rw [← tsub_add_eq_tsub_tsub]
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
i : ℕ
h1 : length (a :: l) - 1 - (i + 1) < length (reverseAux (a :: l) r)
h2 : i + 1 < length (a :: l)
aux :
  ∀ (h1 : length l - 1 - i < length (reverseAux l (a :: r))) (h2 : i < length l),
    get (reverseAux l (a :: r)) { val := length l - 1 - i, isLt := h1 } = get l { val := i, isLt := h2 }
⊢ get (reverseAux (a :: l) r) { val := length (a :: l) - 1 - (i + 1), isLt := h1 } =
    get (a :: l) { val := i + 1, isLt := h2 }

tactic: rw [← heq] at aux
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
i : ℕ
h1 : length (a :: l) - 1 - (i + 1) < length (reverseAux (a :: l) r)
h2 : i + 1 < length (a :: l)
aux :
  ∀ (h1 : length l - 1 - i < length (reverseAux l (a :: r))) (h2 : i < length l),
    get (reverseAux l (a :: r)) { val := length l - 1 - i, isLt := h1 } = get l { val := i, isLt := h2 }
heq : length (a :: l) - 1 - (i + 1) = length l - 1 - i
⊢ get (reverseAux (a :: l) r) { val := length (a :: l) - 1 - (i + 1), isLt := h1 } =
    get (a :: l) { val := i + 1, isLt := h2 }

tactic: apply aux
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
i : ℕ
h1 : length (a :: l) - 1 - (i + 1) < length (reverseAux (a :: l) r)
h2 : i + 1 < length (a :: l)
aux :
  ∀ (h1 : length (a :: l) - 1 - (i + 1) < length (reverseAux l (a :: r))) (h2 : i < length l),
    get (reverseAux l (a :: r)) { val := length (a :: l) - 1 - (i + 1), isLt := h1 } = get l { val := i, isLt := h2 }
heq : length (a :: l) - 1 - (i + 1) = length l - 1 - i
⊢ get (reverseAux (a :: l) r) { val := length (a :: l) - 1 - (i + 1), isLt := h1 } =
    get (a :: l) { val := i + 1, isLt := h2 }

tactic: rw [add_comm]
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
i : ℕ
h1 : length (a :: l) - 1 - (i + 1) < length (reverseAux (a :: l) r)
h2 : i + 1 < length (a :: l)
aux :
  ∀ (h1 : length l - 1 - i < length (reverseAux l (a :: r))) (h2 : i < length l),
    get (reverseAux l (a :: r)) { val := length l - 1 - i, isLt := h1 } = get l { val := i, isLt := h2 }
⊢ length (a :: l) - 1 - (i + 1) = length l - (1 + i)

tactic: rfl
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
i : ℕ
h1 : length (a :: l) - 1 - (i + 1) < length (reverseAux (a :: l) r)
h2 : i + 1 < length (a :: l)
aux :
  ∀ (h1 : length l - 1 - i < length (reverseAux l (a :: r))) (h2 : i < length l),
    get (reverseAux l (a :: r)) { val := length l - 1 - i, isLt := h1 } = get l { val := i, isLt := h2 }
⊢ length (a :: l) - 1 - (1 + i) = length l - (1 + i)

tactic: rw [← tsub_add_eq_tsub_tsub]
state_before: ι : Type ?u.95388
α : Type u
β : Type v
γ : Type w
δ : Type x
l₁ l₂ : List α
a : α
l r : List α
i : ℕ
h1 : length (a :: l) - 1 - (i + 1) < length (reverseAux (a :: l) r)
h2 : i + 1 < length (a :: l)
aux :
  ∀ (h1 : length l - 1 - i < length (reverseAux l (a :: r))) (h2 : i < length l),
    get (reverseAux l (a :: r)) { val := length l - 1 - i, isLt := h1 } = get l { val := i, isLt := h2 }
⊢ length l - (1 + i) = length l - 1 - i