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

tactic: cases' l with hd tl
state_before: α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ dropWhile p l = l ↔ ∀ (hl : 0 < l.length), ¬p (l.get ⟨0, hl⟩) = true
state_after: case nil
α : Type u_1
p : α → Bool
n : ℕ
⊢ dropWhile p [] = [] ↔ ∀ (hl : 0 < [].length), ¬p ([].get ⟨0, hl⟩) = true

case cons
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
⊢ dropWhile p (hd :: tl) = hd :: tl ↔ ∀ (hl : 0 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨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 ([].get ⟨0, hl⟩) = true
state_after: case nil
α : Type u_1
p : α → Bool
n : ℕ
⊢ ∀ (hl : 0 < [].length), ¬p ([].get ⟨0, hl⟩) = true

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

tactic: by_contra
state_before: case nil
α : Type u_1
p : α → Bool
n : ℕ
h : 0 < [].length
⊢ ¬p ([].get ⟨0, h⟩) = true
state_after: case nil
α : Type u_1
p : α → Bool
n : ℕ
h : 0 < [].length
a✝ : p ([].get ⟨0, h⟩) = true
⊢ False

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 ([].get ⟨0, h⟩) = true
⊢ False
state_after: no goals

tactic: rw [dropWhile]
state_before: case cons
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
⊢ dropWhile p (hd :: tl) = hd :: tl ↔ ∀ (hl : 0 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
state_after: 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 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨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 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
state_after: 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 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true

case cons.refine_2
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h : ∀ (hl : 0 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl

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 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
state_after: 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 < (hd :: tl).length
H : p ((hd :: tl).get ⟨0, hl✝⟩) = true
⊢ False

tactic: rw [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 < (hd :: tl).length
H : p ((hd :: tl).get ⟨0, hl✝⟩) = true
⊢ False
state_after: 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 < (hd :: tl).length
H : p hd = 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 < (hd :: tl).length
H : p hd = true
⊢ False
state_after: 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 < (hd :: tl).length
H : p hd = true
⊢ hd :: tl <+ tl

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 < (hd :: tl).length
H : p hd = true
⊢ hd :: tl <+ tl
state_after: 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 < (hd :: tl).length
H : p hd = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => 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 < (hd :: tl).length
H : p hd = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) <+
    tl
state_after: 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 < (hd :: tl).length
H : p hd = true
⊢ dropWhile p 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 < (hd :: tl).length
H : p hd = true
⊢ dropWhile p tl <+ tl
state_after: no goals

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 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
state_after: case cons.refine_2
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h : ∀ (hl : 0 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
this : ¬p ((hd :: tl).get ⟨0, ⋯⟩) = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl

tactic: rw [get] at this
state_before: case cons.refine_2
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h : ∀ (hl : 0 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
this : ¬p ((hd :: tl).get ⟨0, ⋯⟩) = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
state_after: case cons.refine_2
α : Type u_1
p : α → Bool
n : ℕ
hd : α
tl : List α
h : ∀ (hl : 0 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
this : ¬p hd = 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 < (hd :: tl).length), ¬p ((hd :: tl).get ⟨0, hl⟩) = true
this : ¬p hd = true
⊢ (match p hd with
    | true => dropWhile p tl
    | false => hd :: tl) =
    hd :: tl
state_after: no goals

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