l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · 

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

Next tactic:
simp only [dropWhile, true_iff]
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    

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

Next tactic:
intro h
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    

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

Next tactic:
by_contra
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    

Proof state:
case nil
α : Type u_1
p : α → Bool
n : ℕ
h : 0 < length []
a✝ : p (nthLe [] 0 h) = true
⊢ False

Next tactic:
rwa [length_nil, lt_self_iff_false] at h
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · 

Proof state:
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

Next tactic:
rw [dropWhile]
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    

Proof state:
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

Next tactic:
refine' ⟨fun h => _, fun h => _⟩
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · 

Proof state:
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

Next tactic:
intro _ H
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      

Proof state:
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

Next tactic:
rw [nthLe, get] at H
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      rw [nthLe, get] at H
      

Proof state:
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

Next tactic:
refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      rw [nthLe, get] at H
      refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
      

Proof state:
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

Next tactic:
rw [← h]
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      rw [nthLe, get] at H
      refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
      rw [← h]
      

Proof state:
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

Next tactic:
simp only [H]
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      rw [nthLe, get] at H
      refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
      rw [← h]
      simp only [H]
      

Proof state:
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

Next tactic:
exact List.IsSuffix.sublist (dropWhile_suffix p)
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      rw [nthLe, get] at H
      refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
      rw [← h]
      simp only [H]
      exact List.IsSuffix.sublist (dropWhile_suffix p)
    · 

Proof state:
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

Next tactic:
have := h (by simp only [length, Nat.succ_pos])
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      rw [nthLe, get] at H
      refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
      rw [← h]
      simp only [H]
      exact List.IsSuffix.sublist (dropWhile_suffix p)
    · have := h (by 

Proof state:
α : 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)

Next tactic:
simp only [length, Nat.succ_pos]
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      rw [nthLe, get] at H
      refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
      rw [← h]
      simp only [H]
      exact List.IsSuffix.sublist (dropWhile_suffix p)
    · have := h (by simp only [length, Nat.succ_pos])
      

Proof state:
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

Next tactic:
rw [nthLe, get] at this
@[simp]
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.nthLe 0 hl) := by
  cases' l with hd tl
  · simp only [dropWhile, true_iff]
    intro h
    by_contra
    rwa [length_nil, lt_self_iff_false] at h
  · rw [dropWhile]
    refine' ⟨fun h => _, fun h => _⟩
    · intro _ H
      rw [nthLe, get] at H
      refine' (cons_ne_self hd tl) (Sublist.antisymm _ (sublist_cons _ _))
      rw [← h]
      simp only [H]
      exact List.IsSuffix.sublist (dropWhile_suffix p)
    · have := h (by simp only [length, Nat.succ_pos])
      rw [nthLe, get] at this
      

Proof state:
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

Next tactic:
simp_rw [this]
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rdropWhile p l = l ↔ ∀ (hl : l ≠ []), ¬p (getLast l hl) = true

Next tactic:
simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ (∀ (hl : 0 < length (reverse l)), ¬p (nthLe (reverse l) 0 hl) = true) ↔
    ∀ (hl : l ≠ []), ¬p (get l { val := length l - 1, isLt := (_ : length l - 1 < length l) }) = true

Next tactic:
refine' ⟨fun h hl => _, fun h hl => _⟩
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
  refine' ⟨fun h hl => _, fun h hl => _⟩
  · 

Proof state:
case refine'_1
α : Type u_1
p : α → Bool
l : List α
n : ℕ
h : ∀ (hl : 0 < length (reverse l)), ¬p (nthLe (reverse l) 0 hl) = true
hl : l ≠ []
⊢ ¬p (get l { val := length l - 1, isLt := (_ : length l - 1 < length l) }) = true

Next tactic:
rw [← length_pos, ← length_reverse] at hl
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
  refine' ⟨fun h hl => _, fun h hl => _⟩
  · rw [← length_pos, ← length_reverse] at hl
    

Proof state:
case refine'_1
α : Type u_1
p : α → Bool
l : List α
n : ℕ
h : ∀ (hl : 0 < length (reverse l)), ¬p (nthLe (reverse l) 0 hl) = true
hl✝ : l ≠ []
hl : 0 < length (reverse l)
⊢ ¬p (get l { val := length l - 1, isLt := (_ : length l - 1 < length l) }) = true

Next tactic:
have := h hl
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
  refine' ⟨fun h hl => _, fun h hl => _⟩
  · rw [← length_pos, ← length_reverse] at hl
    have := h hl
    

Proof state:
case refine'_1
α : Type u_1
p : α → Bool
l : List α
n : ℕ
h : ∀ (hl : 0 < length (reverse l)), ¬p (nthLe (reverse l) 0 hl) = true
hl✝ : l ≠ []
hl : 0 < length (reverse l)
this : ¬p (nthLe (reverse l) 0 hl) = true
⊢ ¬p (get l { val := length l - 1, isLt := (_ : length l - 1 < length l) }) = true

Next tactic:
rwa [nthLe, get_reverse'] at this
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
  refine' ⟨fun h hl => _, fun h hl => _⟩
  · rw [← length_pos, ← length_reverse] at hl
    have := h hl
    rwa [nthLe, get_reverse'] at this
  · 

Proof state:
case refine'_2
α : Type u_1
p : α → Bool
l : List α
n : ℕ
h : ∀ (hl : l ≠ []), ¬p (get l { val := length l - 1, isLt := (_ : length l - 1 < length l) }) = true
hl : 0 < length (reverse l)
⊢ ¬p (nthLe (reverse l) 0 hl) = true

Next tactic:
rw [length_reverse, length_pos] at hl
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
  refine' ⟨fun h hl => _, fun h hl => _⟩
  · rw [← length_pos, ← length_reverse] at hl
    have := h hl
    rwa [nthLe, get_reverse'] at this
  · rw [length_reverse, length_pos] at hl
    

Proof state:
case refine'_2
α : Type u_1
p : α → Bool
l : List α
n : ℕ
h : ∀ (hl : l ≠ []), ¬p (get l { val := length l - 1, isLt := (_ : length l - 1 < length l) }) = true
hl✝ : 0 < length (reverse l)
hl : l ≠ []
⊢ ¬p (nthLe (reverse l) 0 hl✝) = true

Next tactic:
have := h hl
@[simp]
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get]
  refine' ⟨fun h hl => _, fun h hl => _⟩
  · rw [← length_pos, ← length_reverse] at hl
    have := h hl
    rwa [nthLe, get_reverse'] at this
  · rw [length_reverse, length_pos] at hl
    have := h hl
    

Proof state:
case refine'_2
α : Type u_1
p : α → Bool
l : List α
n : ℕ
h : ∀ (hl : l ≠ []), ¬p (get l { val := length l - 1, isLt := (_ : length l - 1 < length l) }) = true
hl✝ : 0 < length (reverse l)
hl : l ≠ []
this : ¬p (get l { val := length l - 1, isLt := (_ : length l - 1 < length l) }) = true
⊢ ¬p (nthLe (reverse l) 0 hl✝) = true

Next tactic:
rwa [nthLe, get_reverse']
theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l := by
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ dropWhile p (dropWhile p l) = dropWhile p l

Next tactic:
simp only [dropWhile_eq_self_iff]
theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l := by
  simp only [dropWhile_eq_self_iff]
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ ∀ (hl : 0 < length (dropWhile p l)), ¬p (nthLe (dropWhile p l) 0 hl) = true

Next tactic:
exact fun h => dropWhile_nthLe_zero_not p l h
@[simp]
theorem rtakeWhile_nil : rtakeWhile p ([] : List α) = [] := by 

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rtakeWhile p [] = []

Next tactic:
simp [rtakeWhile, takeWhile]
theorem rtakeWhile_concat (x : α) :
    rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] := by
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
x : α
⊢ rtakeWhile p (l ++ [x]) = if p x = true then rtakeWhile p l ++ [x] else []

Next tactic:
simp only [rtakeWhile, takeWhile, reverse_append, reverse_singleton, singleton_append]
theorem rtakeWhile_concat (x : α) :
    rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] := by
  simp only [rtakeWhile, takeWhile, reverse_append, reverse_singleton, singleton_append]
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
x : α
⊢ reverse
      (match p x with
      | true => x :: takeWhile p (reverse l)
      | false => []) =
    if p x = true then reverse (takeWhile p (reverse l)) ++ [x] else []

Next tactic:
split_ifs with h
theorem rtakeWhile_concat (x : α) :
    rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] := by
  simp only [rtakeWhile, takeWhile, reverse_append, reverse_singleton, singleton_append]
  split_ifs with h <;> 

Proof state:
case pos
α : Type u_1
p : α → Bool
l : List α
n : ℕ
x : α
h : p x = true
⊢ reverse
      (match p x with
      | true => x :: takeWhile p (reverse l)
      | false => []) =
    reverse (takeWhile p (reverse l)) ++ [x]

Next tactic:
simp [h]
theorem rtakeWhile_concat (x : α) :
    rtakeWhile p (l ++ [x]) = if p x then rtakeWhile p l ++ [x] else [] := by
  simp only [rtakeWhile, takeWhile, reverse_append, reverse_singleton, singleton_append]
  split_ifs with h <;> 

Proof state:
case neg
α : Type u_1
p : α → Bool
l : List α
n : ℕ
x : α
h : ¬p x = true
⊢ reverse
      (match p x with
      | true => x :: takeWhile p (reverse l)
      | false => []) =
    []

Next tactic:
simp [h]
@[simp]
theorem rtakeWhile_concat_pos (x : α) (h : p x) :
    rtakeWhile p (l ++ [x]) = rtakeWhile p l ++ [x] := by 

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
x : α
h : p x = true
⊢ rtakeWhile p (l ++ [x]) = rtakeWhile p l ++ [x]

Next tactic:
rw [rtakeWhile_concat, if_pos h]
@[simp]
theorem rtakeWhile_concat_neg (x : α) (h : ¬p x) : rtakeWhile p (l ++ [x]) = [] := by
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
x : α
h : ¬p x = true
⊢ rtakeWhile p (l ++ [x]) = []

Next tactic:
rw [rtakeWhile_concat, if_neg h]
theorem rtakeWhile_suffix : l.rtakeWhile p <:+ l := by
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rtakeWhile p l <:+ l

Next tactic:
rw [← reverse_prefix, rtakeWhile, reverse_reverse]
theorem rtakeWhile_suffix : l.rtakeWhile p <:+ l := by
  rw [← reverse_prefix, rtakeWhile, reverse_reverse]
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ takeWhile p (reverse l) <+: reverse l

Next tactic:
exact takeWhile_prefix _
@[simp]
theorem rtakeWhile_eq_self_iff : rtakeWhile p l = l ↔ ∀ x ∈ l, p x := by
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rtakeWhile p l = l ↔ ∀ (x : α), x ∈ l → p x = true

Next tactic:
simp [rtakeWhile, reverse_eq_iff]
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (getLast l hl) = true

Next tactic:
induction' l using List.reverseRecOn with l a
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  induction' l using List.reverseRecOn with l a
  · 

Proof state:
case H0
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ rtakeWhile p [] = [] ↔ ∀ (hl : [] ≠ []), ¬p (getLast [] hl) = true

Next tactic:
simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  induction' l using List.reverseRecOn with l a
  · simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
    

Proof state:
case H0
α : Type u_1
p : α → Bool
l : List α
n : ℕ
⊢ ∀ (hl : [] ≠ []), ¬p (getLast [] hl) = true

Next tactic:
intro f
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  induction' l using List.reverseRecOn with l a
  · simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
    intro f; 

Proof state:
case H0
α : Type u_1
p : α → Bool
l : List α
n : ℕ
f : [] ≠ []
⊢ ¬p (getLast [] f) = true

Next tactic:
contradiction
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  induction' l using List.reverseRecOn with l a
  · simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
    intro f; contradiction
  · 

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

Next 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]
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  induction' l using List.reverseRecOn with l a
  · simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
    intro f; contradiction
  · 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]
    

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

Next tactic:
refine' ⟨fun h => _ , fun h => _⟩
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  induction' l using List.reverseRecOn with l a
  · simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
    intro f; contradiction
  · 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]
    refine' ⟨fun h => _ , fun h => _⟩
    · 

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

Next tactic:
intro pa
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  induction' l using List.reverseRecOn with l a
  · simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
    intro f; contradiction
  · 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]
    refine' ⟨fun h => _ , fun h => _⟩
    · intro pa; 

Proof state:
case H1.refine'_1
α : Type u_1
p : α → Bool
l✝ : List α
n : ℕ
l : List α
a : α
a✝ : rtakeWhile p l = [] ↔ ∀ (hl : l ≠ []), ¬p (getLast l hl) = true
h :
  (match p a with
    | true => a :: takeWhile p (List.append [] (reverse l))
    | false => []) =
    []
pa : p a = true
⊢ False

Next tactic:
simp [pa] at h
@[simp]
theorem rtakeWhile_eq_nil_iff : rtakeWhile p l = [] ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
  induction' l using List.reverseRecOn with l a
  · simp only [rtakeWhile, takeWhile, reverse_nil, true_iff]
    intro f; contradiction
  · 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]
    refine' ⟨fun h => _ , fun h => _⟩
    · intro pa; simp [pa] at h
    · 

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

Next tactic:
simp [h]
theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x := by
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
x : α
hx : x ∈ rtakeWhile p l
⊢ p x = true

Next tactic:
rw [rtakeWhile, mem_reverse] at hx
theorem mem_rtakeWhile_imp {x : α} (hx : x ∈ rtakeWhile p l) : p x := by
  rw [rtakeWhile, mem_reverse] at hx
  

Proof state:
α : Type u_1
p : α → Bool
l : List α
n : ℕ
x : α
hx : x ∈ takeWhile p (reverse l)
⊢ p x = true

Next tactic:
exact mem_takeWhile_imp hx
lemma CompactIccSpace.mk' [TopologicalSpace α] [Preorder α]
    (h : ∀ {a b : α}, a ≤ b → IsCompact (Icc a b)) : CompactIccSpace α where
  isCompact_Icc {a b} := by_cases h $ fun hab => by 

Proof state:
α : Type u_1
inst✝¹ : TopologicalSpace α
inst✝ : Preorder α
h : ∀ {a b : α}, a ≤ b → IsCompact (Icc a b)
a b : α
hab : ¬a ≤ b
⊢ IsCompact (Icc a b)

Next tactic:
rw [Icc_eq_empty hab]
lemma CompactIccSpace.mk' [TopologicalSpace α] [Preorder α]
    (h : ∀ {a b : α}, a ≤ b → IsCompact (Icc a b)) : CompactIccSpace α where
  isCompact_Icc {a b} := by_cases h $ fun hab => by rw [Icc_eq_empty hab]; 

Proof state:
α : Type u_1
inst✝¹ : TopologicalSpace α
inst✝ : Preorder α
h : ∀ {a b : α}, a ≤ b → IsCompact (Icc a b)
a b : α
hab : ¬a ≤ b
⊢ IsCompact ∅

Next tactic:
exact isCompact_empty