Theorem: Set.wellFoundedOn_iff
File: Mathlib/Order/WellFoundedSet.lean

tactic: have f : RelEmbedding (fun (a : s) (b : s) => r a b) fun a b : α => r a b ∧ a ∈ s ∧ b ∈ s :=
  ⟨⟨(↑), Subtype.coe_injective⟩, by simp⟩
state_before: ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t : Set α
x y : α
⊢ WellFoundedOn s r ↔ WellFounded fun a b => r a b ∧ a ∈ s ∧ b ∈ s

tactic: refine' ⟨fun h => _, f.wellFounded⟩
state_before: ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
⊢ WellFoundedOn s r ↔ WellFounded fun a b => r a b ∧ a ∈ s ∧ b ∈ s

tactic: rw [WellFounded.wellFounded_iff_has_min]
state_before: ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
h : WellFoundedOn s r
⊢ WellFounded fun a b => r a b ∧ a ∈ s ∧ b ∈ s

tactic: intro t ht
state_before: ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
h : WellFoundedOn s r
⊢ ∀ (s_1 : Set α), Set.Nonempty s_1 → ∃ m, m ∈ s_1 ∧ ∀ (x : α), x ∈ s_1 → ¬(r x m ∧ x ∈ s ∧ m ∈ s)

tactic: by_cases hst : (s ∩ t).Nonempty
state_before: ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t✝ : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
h : WellFoundedOn s r
t : Set α
ht : Set.Nonempty t
⊢ ∃ m, m ∈ t ∧ ∀ (x : α), x ∈ t → ¬(r x m ∧ x ∈ s ∧ m ∈ s)

tactic: simp
state_before: ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t : Set α
x y : α
⊢ ∀ {a b : ↑s},
    r (↑{ toFun := Subtype.val, inj' := (_ : Function.Injective fun a => ↑a) } a)
          (↑{ toFun := Subtype.val, inj' := (_ : Function.Injective fun a => ↑a) } b) ∧
        ↑{ toFun := Subtype.val, inj' := (_ : Function.Injective fun a => ↑a) } a ∈ s ∧
          ↑{ toFun := Subtype.val, inj' := (_ : Function.Injective fun a => ↑a) } b ∈ s ↔
      r ↑a ↑b

tactic: rw [← Subtype.preimage_coe_nonempty] at hst
state_before: case pos
ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t✝ : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
h : WellFoundedOn s r
t : Set α
ht : Set.Nonempty t
hst : Set.Nonempty (s ∩ t)
⊢ ∃ m, m ∈ t ∧ ∀ (x : α), x ∈ t → ¬(r x m ∧ x ∈ s ∧ m ∈ s)

tactic: rcases h.has_min (Subtype.val ⁻¹' t) hst with ⟨⟨m, ms⟩, mt, hm⟩
state_before: case pos
ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t✝ : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
h : WellFoundedOn s r
t : Set α
ht : Set.Nonempty t
hst : Set.Nonempty (Subtype.val ⁻¹' t)
⊢ ∃ m, m ∈ t ∧ ∀ (x : α), x ∈ t → ¬(r x m ∧ x ∈ s ∧ m ∈ s)

tactic: exact ⟨m, mt, fun x xt ⟨xm, xs, _⟩ => hm ⟨x, xs⟩ xt xm⟩
state_before: case pos.intro.mk.intro
ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t✝ : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
h : WellFoundedOn s r
t : Set α
ht : Set.Nonempty t
hst : Set.Nonempty (Subtype.val ⁻¹' t)
m : α
ms : m ∈ s
mt : { val := m, property := ms } ∈ Subtype.val ⁻¹' t
hm : ∀ (x : ↑s), x ∈ Subtype.val ⁻¹' t → ¬r ↑x ↑{ val := m, property := ms }
⊢ ∃ m, m ∈ t ∧ ∀ (x : α), x ∈ t → ¬(r x m ∧ x ∈ s ∧ m ∈ s)

tactic: rcases ht with ⟨m, mt⟩
state_before: case neg
ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t✝ : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
h : WellFoundedOn s r
t : Set α
ht : Set.Nonempty t
hst : ¬Set.Nonempty (s ∩ t)
⊢ ∃ m, m ∈ t ∧ ∀ (x : α), x ∈ t → ¬(r x m ∧ x ∈ s ∧ m ∈ s)

tactic: exact ⟨m, mt, fun x _ ⟨_, _, ms⟩ => hst ⟨m, ⟨ms, mt⟩⟩⟩
state_before: case neg.intro
ι : Type ?u.442
α : Type u_1
β : Type ?u.448
r r' : α → α → Prop
s t✝ : Set α
x y : α
f : (fun a b => r ↑a ↑b) ↪r fun a b => r a b ∧ a ∈ s ∧ b ∈ s
h : WellFoundedOn s r
t : Set α
hst : ¬Set.Nonempty (s ∩ t)
m : α
mt : m ∈ t
⊢ ∃ m, m ∈ t ∧ ∀ (x : α), x ∈ t → ¬(r x m ∧ x ∈ s ∧ m ∈ s)