Theorem: List.takeWhile_eq_takeWhileTR
File: Std/Data/List/Basic.lean

tactic: funext α p l
state_before: ⊢ @takeWhile = @takeWhileTR

tactic: simp [takeWhileTR]
state_before: case h.h.h
α : Type u_1
p : α → Bool
l : List α
⊢ takeWhile p l = takeWhileTR p l

tactic: suffices ∀ xs acc, l = acc.data ++ xs →
    takeWhileTR.go p l xs acc = acc.data ++ xs.takeWhile p from
  (this l #[] (by simp)).symm
state_before: case h.h.h
α : Type u_1
p : α → Bool
l : List α
⊢ takeWhile p l = takeWhileTR.go p l l #[]

tactic: intro xs
state_before: case h.h.h
α : Type u_1
p : α → Bool
l : List α
⊢ ∀ (xs : List α) (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs

tactic: simp
state_before: α : Type u_1
p : α → Bool
l : List α
this : ∀ (xs : List α) (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
⊢ l = #[].data ++ l

tactic: simp [takeWhile, takeWhileTR.go]
state_before: case h.h.h.nil
α : Type u_1
p : α → Bool
l : List α
acc : Array α
⊢ l = acc.data ++ [] → takeWhileTR.go p l [] acc = acc.data ++ takeWhile p []

tactic: simp [takeWhile, takeWhileTR.go]
state_before: case h.h.h.cons
α : Type u_1
p : α → Bool
l : List α
x : α
xs : List α
IH : ∀ (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
acc : Array α
⊢ l = acc.data ++ x :: xs → takeWhileTR.go p l (x :: xs) acc = acc.data ++ takeWhile p (x :: xs)

tactic: split <;> simp [*]
state_before: case h.h.h.cons
α : Type u_1
p : α → Bool
l : List α
x : α
xs : List α
IH : ∀ (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
acc : Array α
⊢ l = acc.data ++ x :: xs →
    (bif p x then takeWhileTR.go p l xs (Array.push acc x) else acc.data) =
      acc.data ++
        match p x with
        | true => x :: takeWhile p xs
        | false => []

tactic: intro h
state_before: case h.h.h.cons.h_1
α : Type u_1
p : α → Bool
l : List α
x : α
xs : List α
IH : ∀ (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
acc : Array α
x✝ : Bool
heq✝ : p x = true
⊢ l = acc.data ++ x :: xs → takeWhileTR.go p l xs (Array.push acc x) = acc.data ++ x :: takeWhile p xs

tactic: rw [IH]
state_before: case h.h.h.cons.h_1
α : Type u_1
p : α → Bool
l : List α
x : α
xs : List α
IH : ∀ (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
acc : Array α
x✝ : Bool
heq✝ : p x = true
h : l = acc.data ++ x :: xs
⊢ takeWhileTR.go p l xs (Array.push acc x) = acc.data ++ x :: takeWhile p xs

tactic: simp
state_before: case h.h.h.cons.h_1
α : Type u_1
p : α → Bool
l : List α
x : α
xs : List α
IH : ∀ (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
acc : Array α
x✝ : Bool
heq✝ : p x = true
h : l = acc.data ++ x :: xs
⊢ (Array.push acc x).data ++ takeWhile p xs = acc.data ++ x :: takeWhile p xs

case h.h.h.cons.h_1.a
α : Type u_1
p : α → Bool
l : List α
x : α
xs : List α
IH : ∀ (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
acc : Array α
x✝ : Bool
heq✝ : p x = true
h : l = acc.data ++ x :: xs
⊢ l = (Array.push acc x).data ++ xs

tactic: simp
state_before: case h.h.h.cons.h_1.a
α : Type u_1
p : α → Bool
l : List α
x : α
xs : List α
IH : ∀ (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
acc : Array α
x✝ : Bool
heq✝ : p x = true
h : l = acc.data ++ x :: xs
⊢ l = (Array.push acc x).data ++ xs

tactic: exact h
state_before: case h.h.h.cons.h_1.a
α : Type u_1
p : α → Bool
l : List α
x : α
xs : List α
IH : ∀ (acc : Array α), l = acc.data ++ xs → takeWhileTR.go p l xs acc = acc.data ++ takeWhile p xs
acc : Array α
x✝ : Bool
heq✝ : p x = true
h : l = acc.data ++ x :: xs
⊢ l = acc.data ++ x :: xs