Theorem: List.forall_mem_pwFilter
File: .lake/packages/batteries/Batteries/Data/List/Pairwise.lean

tactic: refine ⟨?_, fun h b hb => h _ <| pwFilter_subset (R := R) _ hb⟩
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a : α
l : List α
⊢ (∀ (b : α), b ∈ pwFilter R l → R a b) ↔ ∀ (b : α), b ∈ l → R a b
state_after: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a : α
l : List α
⊢ (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b

tactic: induction l with
| nil => exact fun _ _ h => (not_mem_nil _ h).elim
| cons x l IH =>
  simp only [forall_mem_cons]
  if h : ∀ y ∈ pwFilter R l, R x y then
    simpa [pwFilter_cons_of_pos h] using fun r H => ⟨r, IH H⟩
  else
    refine pwFilter_cons_of_neg h ▸ fun H => ⟨?_, IH H⟩
    match e : find? (fun y => ¬R x y) (pwFilter R l) with
    | none => exact h.elim fun y hy => by simpa using find?_eq_none.1 e y hy
    | some k =>
      have := find?_some e
      apply (neg_trans (H k (mem_of_find?_eq_some e))).resolve_right
      rw [decide_eq_true_iff] at this; exact this
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a : α
l : List α
⊢ (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
state_after: no goals

tactic: exact fun _ _ h => (not_mem_nil _ h).elim
state_before: case nil
α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a : α
⊢ (∀ (b : α), b ∈ pwFilter R [] → R a b) → ∀ (b : α), b ∈ [] → R a b
state_after: no goals

tactic: simp only [forall_mem_cons]
state_before: case cons
α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
⊢ (∀ (b : α), b ∈ pwFilter R (x :: l) → R a b) → ∀ (b : α), b ∈ x :: l → R a b
state_after: case cons
α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
⊢ (∀ (b : α), b ∈ pwFilter R (x :: l) → R a b) → R a x ∧ ∀ (x : α), x ∈ l → R a x

tactic: if h : ∀ y ∈ pwFilter R l, R x y then
  simpa [pwFilter_cons_of_pos h] using fun r H => ⟨r, IH H⟩
else
  refine pwFilter_cons_of_neg h ▸ fun H => ⟨?_, IH H⟩
  match e : find? (fun y => ¬R x y) (pwFilter R l) with
  | none => exact h.elim fun y hy => by simpa using find?_eq_none.1 e y hy
  | some k =>
    have := find?_some e
    apply (neg_trans (H k (mem_of_find?_eq_some e))).resolve_right
    rw [decide_eq_true_iff] at this; exact this
state_before: case cons
α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
⊢ (∀ (b : α), b ∈ pwFilter R (x :: l) → R a b) → R a x ∧ ∀ (x : α), x ∈ l → R a x
state_after: no goals

tactic: simpa [pwFilter_cons_of_pos h] using fun r H => ⟨r, IH H⟩
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ∀ (y : α), y ∈ pwFilter R l → R x y
⊢ (∀ (b : α), b ∈ pwFilter R (x :: l) → R a b) → R a x ∧ ∀ (x : α), x ∈ l → R a x
state_after: no goals

tactic: refine pwFilter_cons_of_neg h ▸ fun H => ⟨?_, IH H⟩
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
⊢ (∀ (b : α), b ∈ pwFilter R (x :: l) → R a b) → R a x ∧ ∀ (x : α), x ∈ l → R a x
state_after: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
⊢ R a x

tactic: match e : find? (fun y => ¬R x y) (pwFilter R l) with
| none => exact h.elim fun y hy => by simpa using find?_eq_none.1 e y hy
| some k =>
  have := find?_some e
  apply (neg_trans (H k (mem_of_find?_eq_some e))).resolve_right
  rw [decide_eq_true_iff] at this; exact this
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
⊢ R a x
state_after: no goals

tactic: exact h.elim fun y hy => by simpa using find?_eq_none.1 e y hy
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
e : find? (fun y => decide ¬R x y) (pwFilter R l) = none
⊢ R a x
state_after: no goals

tactic: simpa using find?_eq_none.1 e y hy
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
e : find? (fun y => decide ¬R x y) (pwFilter R l) = none
y : α
hy : y ∈ pwFilter R l
⊢ R x y
state_after: no goals

tactic: have := find?_some e
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
k : α
e : find? (fun y => decide ¬R x y) (pwFilter R l) = some k
⊢ R a x
state_after: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
k : α
e : find? (fun y => decide ¬R x y) (pwFilter R l) = some k
this : (decide ¬R x k) = true
⊢ R a x

tactic: apply (neg_trans (H k (mem_of_find?_eq_some e))).resolve_right
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
k : α
e : find? (fun y => decide ¬R x y) (pwFilter R l) = some k
this : (decide ¬R x k) = true
⊢ R a x
state_after: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
k : α
e : find? (fun y => decide ¬R x y) (pwFilter R l) = some k
this : (decide ¬R x k) = true
⊢ ¬R x k

tactic: rw [decide_eq_true_iff] at this
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
k : α
e : find? (fun y => decide ¬R x y) (pwFilter R l) = some k
this : (decide ¬R x k) = true
⊢ ¬R x k
state_after: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
k : α
e : find? (fun y => decide ¬R x y) (pwFilter R l) = some k
this : ¬R x k
⊢ ¬R x k

tactic: exact this
state_before: α : Type u_1
R : α → α → Prop
inst✝ : DecidableRel R
neg_trans : ∀ {x y z : α}, R x z → R x y ∨ R y z
a x : α
l : List α
IH : (∀ (b : α), b ∈ pwFilter R l → R a b) → ∀ (b : α), b ∈ l → R a b
h : ¬∀ (y : α), y ∈ pwFilter R l → R x y
H : ∀ (b : α), b ∈ pwFilter R l → R a b
k : α
e : find? (fun y => decide ¬R x y) (pwFilter R l) = some k
this : ¬R x k
⊢ ¬R x k
state_after: no goals