Theorem: List.dropWhile_eq_self_iff
File: Mathlib/Data/List/Rdrop.lean

tactic: cases' l with hd tl
state_before: α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ dropWhile p l = l ↔ ∀ (hl : 0 < length l), ¬p (nthLe l 0 hl) = true

tactic: simp only [dropWhile, true_iff]
state_before: case nil
α : Type u_1
p : α → Bool
n : ℕ
⊢ dropWhile p [] = [] ↔ ∀ (hl : 0 < length []), ¬p (nthLe [] 0 hl) = true

tactic: intro h
state_before: case nil
α : Type u_1
p : α → Bool
n : ℕ
⊢ ∀ (hl : 0 < length []), ¬p (nthLe [] 0 hl) = true

tactic: by_contra
state_before: case nil
α : Type u_1
p : α → Bool
n : ℕ
h : 0 < length []
⊢ ¬p (nthLe [] 0 h) = true

tactic: rwa [length_nil, lt_self_iff_false] at h
state_before: case nil
α : Type u_1
p : α → Bool
n : ℕ
h : 0 < length []
a✝ : p (nthLe [] 0 h) = true
⊢ False

tactic: rw [dropWhile]
state_before: case cons
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
⊢ dropWhile p (hd :: tl) = hd :: tl ↔ ∀ (hl : 0 < length (hd :: tl)), ¬p (nthLe (hd :: tl) 0 hl) = true

tactic: refine' ⟨fun h => _, fun h => _⟩
state_before: case cons
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
⊢ (match p hd with
      | true => dropWhile p tl
      | false => hd :: tl) =
      hd :: tl ↔
    ∀ (hl : 0 < length (hd :: tl)), ¬p (nthLe (hd :: tl) 0 hl) = true

tactic: intro _ H
state_before: case cons.refine'_1
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h :
  (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
⊢ ∀ (hl : 0 < length (hd :: tl)), ¬p (nthLe (hd :: tl) 0 hl) = true

tactic: rw [nthLe, get] at H
state_before: case cons.refine'_1
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h :
  (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
hl✝ : 0 < length (hd :: tl)
H : p (nthLe (hd :: tl) 0 hl✝) = true
⊢ False

tactic: refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
state_before: case cons.refine'_1
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h :
  (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
hl✝ : 0 < length (hd :: tl)
H : p hd = true
⊢ False

tactic: rw [← h]
state_before: case cons.refine'_1
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h :
  (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
hl✝ : 0 < length (hd :: tl)
H : p hd = true
⊢ hd :: tl <+ tl

tactic: simp only [H]
state_before: case cons.refine'_1
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h :
  (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
hl✝ : 0 < length (hd :: tl)
H : p hd = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) <+
    tl

tactic: exact List.isSuffix.sublist (dropWhile_suffix p)
state_before: case cons.refine'_1
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h :
  (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
hl✝ : 0 < length (hd :: tl)
H : p hd = true
⊢ dropWhile p tl <+ tl

tactic: have := h (by simp only [length, Nat.succ_pos])
state_before: case cons.refine'_2
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h : ∀ (hl : 0 < length (hd :: tl)), ¬p (nthLe (hd :: tl) 0 hl) = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl

tactic: rw [nthLe, get] at this
state_before: case cons.refine'_2
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h : ∀ (hl : 0 < length (hd :: tl)), ¬p (nthLe (hd :: tl) 0 hl) = true
this : ¬p (nthLe (hd :: tl) 0 (_ : 0 < Nat.succ (length tl))) = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl

tactic: simp_rw [this]
state_before: case cons.refine'_2
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h : ∀ (hl : 0 < length (hd :: tl)), ¬p (nthLe (hd :: tl) 0 hl) = true
this : ¬p hd = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl

tactic: simp only [length, Nat.succ_pos]
state_before: α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h : ∀ (hl : 0 < length (hd :: tl)), ¬p (nthLe (hd :: tl) 0 hl) = true
⊢ 0 < length (hd :: tl)