Theorem: Fintype.all_card_le_rel_image_card_iff_exists_injective
File: Mathlib/Combinatorics/Hall/Basic.lean

tactic: let r' a := (Rel.image r {a}).toFinset
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
⊢ (∀ (A : Finset α), A.card ≤ card ↑(Rel.image r ↑A)) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), r x (f x)
state_after: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
⊢ (∀ (A : Finset α), A.card ≤ card ↑(Rel.image r ↑A)) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), r x (f x)

tactic: have h : ∀ A : Finset α, Fintype.card (Rel.image r A) = (A.biUnion r').card := by
  intro A
  rw [← Set.toFinset_card]
  apply congr_arg
  ext b
  simp [Rel.image, (Set.mem_toFinset)]
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
⊢ (∀ (A : Finset α), A.card ≤ card ↑(Rel.image r ↑A)) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), r x (f x)
state_after: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
h : ∀ (A : Finset α), card ↑(Rel.image r ↑A) = (A.biUnion r').card
⊢ (∀ (A : Finset α), A.card ≤ card ↑(Rel.image r ↑A)) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), r x (f x)

tactic: have h' : ∀ (f : α → β) (x), r x (f x) ↔ f x ∈ r' x := by simp [Rel.image, (Set.mem_toFinset)]
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
h : ∀ (A : Finset α), card ↑(Rel.image r ↑A) = (A.biUnion r').card
⊢ (∀ (A : Finset α), A.card ≤ card ↑(Rel.image r ↑A)) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), r x (f x)
state_after: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
h : ∀ (A : Finset α), card ↑(Rel.image r ↑A) = (A.biUnion r').card
h' : ∀ (f : α → β) (x : α), r x (f x) ↔ f x ∈ r' x
⊢ (∀ (A : Finset α), A.card ≤ card ↑(Rel.image r ↑A)) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), r x (f x)

tactic: simp only [h, h']
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
h : ∀ (A : Finset α), card ↑(Rel.image r ↑A) = (A.biUnion r').card
h' : ∀ (f : α → β) (x : α), r x (f x) ↔ f x ∈ r' x
⊢ (∀ (A : Finset α), A.card ≤ card ↑(Rel.image r ↑A)) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), r x (f x)
state_after: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
h : ∀ (A : Finset α), card ↑(Rel.image r ↑A) = (A.biUnion r').card
h' : ∀ (f : α → β) (x : α), r x (f x) ↔ f x ∈ r' x
⊢ (∀ (A : Finset α), A.card ≤ (A.biUnion r').card) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), f x ∈ r' x

tactic: apply Finset.all_card_le_biUnion_card_iff_exists_injective
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
h : ∀ (A : Finset α), card ↑(Rel.image r ↑A) = (A.biUnion r').card
h' : ∀ (f : α → β) (x : α), r x (f x) ↔ f x ∈ r' x
⊢ (∀ (A : Finset α), A.card ≤ (A.biUnion r').card) ↔ ∃ f, Function.Injective f ∧ ∀ (x : α), f x ∈ r' x
state_after: no goals

tactic: intro A
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
⊢ ∀ (A : Finset α), card ↑(Rel.image r ↑A) = (A.biUnion r').card
state_after: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
A : Finset α
⊢ card ↑(Rel.image r ↑A) = (A.biUnion r').card

tactic: rw [← Set.toFinset_card]
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
A : Finset α
⊢ card ↑(Rel.image r ↑A) = (A.biUnion r').card
state_after: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
A : Finset α
⊢ (Rel.image r ↑A).toFinset.card = (A.biUnion r').card

tactic: apply congr_arg
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
A : Finset α
⊢ (Rel.image r ↑A).toFinset.card = (A.biUnion r').card
state_after: case h
α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
A : Finset α
⊢ (Rel.image r ↑A).toFinset = A.biUnion r'

tactic: ext b
state_before: case h
α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
A : Finset α
⊢ (Rel.image r ↑A).toFinset = A.biUnion r'
state_after: case h.a
α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
A : Finset α
b : β
⊢ b ∈ (Rel.image r ↑A).toFinset ↔ b ∈ A.biUnion r'

tactic: simp [Rel.image, (Set.mem_toFinset)]
state_before: case h.a
α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
A : Finset α
b : β
⊢ b ∈ (Rel.image r ↑A).toFinset ↔ b ∈ A.biUnion r'
state_after: no goals

tactic: simp [Rel.image, (Set.mem_toFinset)]
state_before: α : Type u
β : Type v
inst✝¹ : DecidableEq β
r : α → β → Prop
inst✝ : (a : α) → Fintype ↑(Rel.image r {a})
r' : α → Finset β := fun a => (Rel.image r {a}).toFinset
h : ∀ (A : Finset α), card ↑(Rel.image r ↑A) = (A.biUnion r').card
⊢ ∀ (f : α → β) (x : α), r x (f x) ↔ f x ∈ r' x
state_after: no goals