Theorem: List.reverseRecOn_concat
File: Mathlib/Data/List/Basic.lean

tactic: suffices ∀ ys (h : reverse (reverse xs) = ys),
    reverseRecOn (motive := motive) (xs ++ [x]) nil append_singleton =
      cast (by simp [(reverse_reverse _).symm.trans h])
        (append_singleton _ x (reverseRecOn (motive := motive) ys nil append_singleton)) by
  exact this _ (reverse_reverse xs)
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
⊢ reverseRecOn (xs ++ [x]) nil append_singleton = append_singleton xs x (reverseRecOn xs nil append_singleton)
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
⊢ ∀ (ys : List α) (h : xs.reverse.reverse = ys),
    reverseRecOn (xs ++ [x]) nil append_singleton =
      cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

tactic: intros ys hy
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
⊢ ∀ (ys : List α) (h : xs.reverse.reverse = ys),
    reverseRecOn (xs ++ [x]) nil append_singleton =
      cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
⊢ reverseRecOn (xs ++ [x]) nil append_singleton = cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

tactic: conv_lhs => unfold reverseRecOn
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
⊢ reverseRecOn (xs ++ [x]) nil append_singleton = cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
⊢ (match h : (xs ++ [x]).reverse with
    | [] => cast ⋯ nil
    | head :: tail => cast ⋯ (append_singleton tail.reverse head (reverseRecOn tail.reverse nil append_singleton))) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

tactic: split
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
⊢ (match h : (xs ++ [x]).reverse with
    | [] => cast ⋯ nil
    | head :: tail => cast ⋯ (append_singleton tail.reverse head (reverseRecOn tail.reverse nil append_singleton))) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: case h_1
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
heq✝ : (xs ++ [x]).reverse = []
⊢ cast ⋯ nil = cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

case h_2
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
heq✝ : (xs ++ [x]).reverse = head✝ :: tail✝
⊢ cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

tactic: next h => simp at h
state_before: case h_1
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
heq✝ : (xs ++ [x]).reverse = []
⊢ cast ⋯ nil = cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

case h_2
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
heq✝ : (xs ++ [x]).reverse = head✝ :: tail✝
⊢ cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: case h_2
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
heq✝ : (xs ++ [x]).reverse = head✝ :: tail✝
⊢ cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

tactic: next heq =>
  revert heq
  simp only [reverse_append, reverse_cons, reverse_nil, nil_append, singleton_append, cons.injEq]
  rintro ⟨rfl, rfl⟩
  subst ys
  rfl
state_before: case h_2
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
heq✝ : (xs ++ [x]).reverse = head✝ :: tail✝
⊢ cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: no goals

tactic: simp [(reverse_reverse _).symm.trans h]
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
h : xs.reverse.reverse = ys
⊢ motive (ys ++ [x]) = motive (xs ++ [x])
state_after: no goals

tactic: exact this _ (reverse_reverse xs)
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
this :
  ∀ (ys : List α) (h : xs.reverse.reverse = ys),
    reverseRecOn (xs ++ [x]) nil append_singleton =
      cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
⊢ reverseRecOn (xs ++ [x]) nil append_singleton = append_singleton xs x (reverseRecOn xs nil append_singleton)
state_after: no goals

tactic: simp at h
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
h : (xs ++ [x]).reverse = []
⊢ cast ⋯ nil = cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: no goals

tactic: revert heq
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
heq : (xs ++ [x]).reverse = head✝ :: tail✝
⊢ cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
⊢ ∀ (heq : (xs ++ [x]).reverse = head✝ :: tail✝),
    cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
      cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

tactic: simp only [reverse_append, reverse_cons, reverse_nil, nil_append, singleton_append, cons.injEq]
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
⊢ ∀ (heq : (xs ++ [x]).reverse = head✝ :: tail✝),
    cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
      cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
⊢ ∀ (heq : x = head✝ ∧ xs.reverse = tail✝),
    cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
      cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

tactic: rintro ⟨rfl, rfl⟩
state_before: ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
head✝ : α
tail✝ : List α
⊢ ∀ (heq : x = head✝ ∧ xs.reverse = tail✝),
    cast ⋯ (append_singleton tail✝.reverse head✝ (reverseRecOn tail✝.reverse nil append_singleton)) =
      cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: case intro
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
⊢ cast ⋯ (append_singleton xs.reverse.reverse x (reverseRecOn xs.reverse.reverse nil append_singleton)) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))

tactic: subst ys
state_before: case intro
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
ys : List α
hy : xs.reverse.reverse = ys
⊢ cast ⋯ (append_singleton xs.reverse.reverse x (reverseRecOn xs.reverse.reverse nil append_singleton)) =
    cast ⋯ (append_singleton ys x (reverseRecOn ys nil append_singleton))
state_after: case intro
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
⊢ cast ⋯ (append_singleton xs.reverse.reverse x (reverseRecOn xs.reverse.reverse nil append_singleton)) =
    cast ⋯ (append_singleton xs.reverse.reverse x (reverseRecOn xs.reverse.reverse nil append_singleton))

tactic: rfl
state_before: case intro
ι : Type u_1
α : Type u
β : Type v
γ : Type w
l₁ l₂ : List α
motive : List α → Sort u_2
x : α
xs : List α
nil : motive []
append_singleton : (l : List α) → (a : α) → motive l → motive (l ++ [a])
⊢ cast ⋯ (append_singleton xs.reverse.reverse x (reverseRecOn xs.reverse.reverse nil append_singleton)) =
    cast ⋯ (append_singleton xs.reverse.reverse x (reverseRecOn xs.reverse.reverse nil append_singleton))
state_after: no goals