Theorem: HallMarriageTheorem.hall_cond_of_erase
File: Mathlib/Combinatorics/Hall/Finite.lean

tactic: haveI := Classical.decEq ι
state_before: ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
ha : ∀ (s : Finset ι), Finset.Nonempty s → s ≠ univ → card s < card (Finset.biUnion s t)
s' : Finset ↑{x' | x' ≠ x}
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

tactic: specialize ha (s'.image fun z => z.1)
state_before: ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
ha : ∀ (s : Finset ι), Finset.Nonempty s → s ≠ univ → card s < card (Finset.biUnion s t)
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

tactic: rw [Nonempty.image_iff, Finset.card_image_of_injective s' Subtype.coe_injective] at ha
state_before: ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha :
  Finset.Nonempty (image (fun z => ↑z) s') →
    image (fun z => ↑z) s' ≠ univ → card (image (fun z => ↑z) s') < card (Finset.biUnion (image (fun z => ↑z) s') t)
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

tactic: by_cases he : s'.Nonempty
state_before: ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

tactic: have ha' : s'.card < (s'.biUnion fun x => t x).card := by
  convert ha he fun h => by simpa [← h] using mem_univ x using 2
  ext x
  simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
    exists_eq_right, Subtype.coe_mk]
state_before: case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

tactic: rw [← erase_biUnion]
state_before: case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

tactic: by_cases hb : a ∈ s'.biUnion fun x => t x
state_before: case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
⊢ card s' ≤ card (erase (Finset.biUnion s' fun x' => t ↑x') a)

tactic: convert ha he fun h => by simpa [← h] using mem_univ x using 2
state_before: ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
⊢ card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)

tactic: ext x
state_before: case h.e'_4.h.e'_2
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
⊢ (Finset.biUnion s' fun x_1 => t ↑x_1) = Finset.biUnion (image (fun z => ↑z) s') t

tactic: simp only [mem_image, mem_biUnion, exists_prop, SetCoe.exists, exists_and_right,
  exists_eq_right, Subtype.coe_mk]
state_before: case h.e'_4.h.e'_2.a
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x✝ : ι
a : α
s' : Finset ↑{x' | x' ≠ x✝}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
x : α
⊢ (x ∈ Finset.biUnion s' fun x => t ↑x) ↔ x ∈ Finset.biUnion (image (fun z => ↑z) s') t

tactic: simpa [← h] using mem_univ x
state_before: ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
h : image (fun z => ↑z) s' = univ
⊢ False

tactic: rw [card_erase_of_mem hb]
state_before: case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
hb : a ∈ Finset.biUnion s' fun x_1 => t ↑x_1
⊢ card s' ≤ card (erase (Finset.biUnion s' fun x' => t ↑x') a)

tactic: exact Nat.le_pred_of_lt ha'
state_before: case pos
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
hb : a ∈ Finset.biUnion s' fun x_1 => t ↑x_1
⊢ card s' ≤ card (Finset.biUnion s' fun x_1 => t ↑x_1) - 1

tactic: rw [erase_eq_of_not_mem hb]
state_before: case neg
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
hb : ¬a ∈ Finset.biUnion s' fun x_1 => t ↑x_1
⊢ card s' ≤ card (erase (Finset.biUnion s' fun x' => t ↑x') a)

tactic: exact Nat.le_of_lt ha'
state_before: case neg
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : Finset.Nonempty s'
ha' : card s' < card (Finset.biUnion s' fun x_1 => t ↑x_1)
hb : ¬a ∈ Finset.biUnion s' fun x_1 => t ↑x_1
⊢ card s' ≤ card (Finset.biUnion s' fun x_1 => t ↑x_1)

tactic: rw [nonempty_iff_ne_empty, not_not] at he
state_before: case neg
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : ¬Finset.Nonempty s'
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

tactic: subst s'
state_before: case neg
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
s' : Finset ↑{x' | x' ≠ x}
this : DecidableEq ι
ha : Finset.Nonempty s' → image (fun z => ↑z) s' ≠ univ → card s' < card (Finset.biUnion (image (fun z => ↑z) s') t)
he : s' = ∅
⊢ card s' ≤ card (Finset.biUnion s' fun x' => erase (t ↑x') a)

tactic: simp
state_before: case neg
ι : Type u
α : Type v
inst✝¹ : DecidableEq α
t : ι → Finset α
inst✝ : Fintype ι
x : ι
a : α
this : DecidableEq ι
ha : Finset.Nonempty ∅ → image (fun z => ↑z) ∅ ≠ univ → card ∅ < card (Finset.biUnion (image (fun z => ↑z) ∅) t)
⊢ card ∅ ≤ card (Finset.biUnion ∅ fun x' => erase (t ↑x') a)