Theorem: List.rtakeWhile_eq_nil_iff
File: Mathlib/Data/List/DropRight.lean

tactic: induction' l using List.reverseRecOn with l a
state_before: α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
state_after: case nil
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rtakeWhile p [] = [] ↔ ∀ (hl : [] ≠ []), ¬p ([].getLast hl) = true

case append_singleton
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
⊢ rtakeWhile p (l ++ [a]) = [] ↔ ∀ (hl : l ++ [a] ≠ []), ¬p ((l ++ [a]).getLast hl) = true

tactic: simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
state_before: case nil
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rtakeWhile p [] = [] ↔ ∀ (hl : [] ≠ []), ¬p ([].getLast hl) = true
state_after: case nil
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ ∀ (hl : [] ≠ []), ¬p ([].getLast hl) = true

tactic: intro f
state_before: case nil
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ ∀ (hl : [] ≠ []), ¬p ([].getLast hl) = true
state_after: case nil
α : Type u_1
p : α → Bool
l : List α
n : ℕ
f : [] ≠ []
⊢ ¬p ([].getLast f) = true

tactic: contradiction
state_before: case nil
α : Type u_1
p : α → Bool
l : List α
n : ℕ
f : [] ≠ []
⊢ ¬p ([].getLast f) = true
state_after: no goals

tactic: simp only [rtakeWhile, reverse_append, takeWhile, reverse_eq_nil_iff, getLast_append, ne_eq,
  append_eq_nil, and_false, not_false_eq_true, forall_true_left]
state_before: case append_singleton
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
⊢ rtakeWhile p (l ++ [a]) = [] ↔ ∀ (hl : l ++ [a] ≠ []), ¬p ((l ++ [a]).getLast hl) = true
state_after: case append_singleton
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
⊢ (match p a with
      | true => a :: takeWhile p ([].append l.reverse)
      | false => []) =
      [] ↔
    ¬p a = true

tactic: refine ⟨fun h => ?_ , fun h => ?_⟩
state_before: case append_singleton
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
⊢ (match p a with
      | true => a :: takeWhile p ([].append l.reverse)
      | false => []) =
      [] ↔
    ¬p a = true
state_after: case append_singleton.refine_1
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
h :
  (match p a with
    | true => a :: takeWhile p ([].append l.reverse)
    | false => []) =
    []
⊢ ¬p a = true

case append_singleton.refine_2
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
h : ¬p a = true
⊢ (match p a with
    | true => a :: takeWhile p ([].append l.reverse)
    | false => []) =
    []

tactic: intro pa
state_before: case append_singleton.refine_1
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
h :
  (match p a with
    | true => a :: takeWhile p ([].append l.reverse)
    | false => []) =
    []
⊢ ¬p a = true
state_after: case append_singleton.refine_1
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
h :
  (match p a with
    | true => a :: takeWhile p ([].append l.reverse)
    | false => []) =
    []
pa : p a = true
⊢ False

tactic: simp [pa] at h
state_before: case append_singleton.refine_1
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
h :
  (match p a with
    | true => a :: takeWhile p ([].append l.reverse)
    | false => []) =
    []
pa : p a = true
⊢ False
state_after: no goals

tactic: simp [h]
state_before: case append_singleton.refine_2
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (l.getLast hl) = true
h : ¬p a = true
⊢ (match p a with
    | true => a :: takeWhile p ([].append l.reverse)
    | false => []) =
    []
state_after: no goals