Theorem: Set.exists_intermediate_Set
File: Mathlib/Data/Set/Ncard.lean

tactic: cases' t.finite_or_infinite with ht ht
state_before: α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₁ : i + ncard s ≤ ncard t
h₂ : s ⊆ t
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + ncard s

tactic: rw [ht.ncard] at h₁
state_before: case inr
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₁ : i + ncard s ≤ ncard t
h₂ : s ⊆ t
ht : Set.Infinite t
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + ncard s

tactic: have h₁' := Nat.eq_zero_of_le_zero h₁
state_before: case inr
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₁ : i + ncard s ≤ 0
h₂ : s ⊆ t
ht : Set.Infinite t
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + ncard s

tactic: rw [add_eq_zero_iff] at h₁'
state_before: case inr
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₁ : i + ncard s ≤ 0
h₂ : s ⊆ t
ht : Set.Infinite t
h₁' : i + ncard s = 0
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + ncard s

tactic: refine' ⟨t, h₂, rfl.subset, _⟩
state_before: case inr
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₁ : i + ncard s ≤ 0
h₂ : s ⊆ t
ht : Set.Infinite t
h₁' : i = 0 ∧ ncard s = 0
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + ncard s

tactic: rw [h₁'.2, h₁'.1, ht.ncard, add_zero]
state_before: case inr
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₁ : i + ncard s ≤ 0
h₂ : s ⊆ t
ht : Set.Infinite t
h₁' : i = 0 ∧ ncard s = 0
⊢ ncard t = i + ncard s

tactic: rw [ncard_eq_toFinset_card _ (ht.subset h₂)] at h₁ ⊢
state_before: case inl
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₁ : i + ncard s ≤ ncard t
h₂ : s ⊆ t
ht : Set.Finite t
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + ncard s

tactic: rw [ncard_eq_toFinset_card t ht] at h₁
state_before: case inl
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₂ : s ⊆ t
ht : Set.Finite t
h₁ : i + Finset.card (Finite.toFinset (_ : Set.Finite s)) ≤ ncard t
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + Finset.card (Finite.toFinset (_ : Set.Finite s))

tactic: obtain ⟨r', hsr', hr't, hr'⟩ := Finset.exists_intermediate_set _ h₁ (by simpa)
state_before: case inl
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₂ : s ⊆ t
ht : Set.Finite t
h₁ : i + Finset.card (Finite.toFinset (_ : Set.Finite s)) ≤ Finset.card (Finite.toFinset ht)
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + Finset.card (Finite.toFinset (_ : Set.Finite s))

tactic: exact ⟨r', by simpa using hsr', by simpa using hr't, by rw [← hr', ncard_coe_Finset]⟩
state_before: case inl.intro.intro.intro
α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₂ : s ⊆ t
ht : Set.Finite t
h₁ : i + Finset.card (Finite.toFinset (_ : Set.Finite s)) ≤ Finset.card (Finite.toFinset ht)
r' : Finset α
hsr' : Finite.toFinset (_ : Set.Finite s) ⊆ r'
hr't : r' ⊆ Finite.toFinset ht
hr' : Finset.card r' = i + Finset.card (Finite.toFinset (_ : Set.Finite s))
⊢ ∃ r, s ⊆ r ∧ r ⊆ t ∧ ncard r = i + Finset.card (Finite.toFinset (_ : Set.Finite s))

tactic: simpa
state_before: α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₂ : s ⊆ t
ht : Set.Finite t
h₁ : i + Finset.card (Finite.toFinset (_ : Set.Finite s)) ≤ Finset.card (Finite.toFinset ht)
⊢ Finite.toFinset (_ : Set.Finite s) ⊆ Finite.toFinset ht

tactic: simpa using hsr'
state_before: α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₂ : s ⊆ t
ht : Set.Finite t
h₁ : i + Finset.card (Finite.toFinset (_ : Set.Finite s)) ≤ Finset.card (Finite.toFinset ht)
r' : Finset α
hsr' : Finite.toFinset (_ : Set.Finite s) ⊆ r'
hr't : r' ⊆ Finite.toFinset ht
hr' : Finset.card r' = i + Finset.card (Finite.toFinset (_ : Set.Finite s))
⊢ s ⊆ ↑r'

tactic: simpa using hr't
state_before: α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₂ : s ⊆ t
ht : Set.Finite t
h₁ : i + Finset.card (Finite.toFinset (_ : Set.Finite s)) ≤ Finset.card (Finite.toFinset ht)
r' : Finset α
hsr' : Finite.toFinset (_ : Set.Finite s) ⊆ r'
hr't : r' ⊆ Finite.toFinset ht
hr' : Finset.card r' = i + Finset.card (Finite.toFinset (_ : Set.Finite s))
⊢ ↑r' ⊆ t

tactic: rw [← hr', ncard_coe_Finset]
state_before: α : Type u_1
β : Type ?u.130854
s t : Set α
a b x y : α
f : α → β
i : ℕ
h₂ : s ⊆ t
ht : Set.Finite t
h₁ : i + Finset.card (Finite.toFinset (_ : Set.Finite s)) ≤ Finset.card (Finite.toFinset ht)
r' : Finset α
hsr' : Finite.toFinset (_ : Set.Finite s) ⊆ r'
hr't : r' ⊆ Finite.toFinset ht
hr' : Finset.card r' = i + Finset.card (Finite.toFinset (_ : Set.Finite s))
⊢ ncard ↑r' = i + Finset.card (Finite.toFinset (_ : Set.Finite s))