Theorem: Finset.diag_card
File: Mathlib/Data/Finset/Prod.lean

tactic: suffices diag s = s.image fun a => (a, a) by
  rw [this]
  apply card_image_of_injOn
  exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
state_before: α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ card (diag s) = card s

tactic: ext ⟨a₁, a₂⟩
state_before: α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ diag s = image (fun a => (a, a)) s

tactic: rw [mem_diag]
state_before: case a.mk
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂) ∈ diag s ↔ (a₁, a₂) ∈ image (fun a => (a, a)) s

tactic: constructor <;> intro h <;> rw [Finset.mem_image] at *
state_before: case a.mk
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂).fst ∈ s ∧ (a₁, a₂).fst = (a₁, a₂).snd ↔ (a₁, a₂) ∈ image (fun a => (a, a)) s

tactic: rw [this]
state_before: α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : diag s = image (fun a => (a, a)) s
⊢ card (diag s) = card s

tactic: apply card_image_of_injOn
state_before: α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : diag s = image (fun a => (a, a)) s
⊢ card (image (fun a => (a, a)) s) = card s

tactic: exact fun x1 _ x2 _ h3 => (Prod.mk.inj h3).1
state_before: case H
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : diag s = image (fun a => (a, a)) s
⊢ Set.InjOn (fun a => (a, a)) ↑s

tactic: use a₁
state_before: case a.mk.mp
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).fst ∈ s ∧ (a₁, a₂).fst = (a₁, a₂).snd
⊢ ∃ a, a ∈ s ∧ (a, a) = (a₁, a₂)

tactic: simpa using h
state_before: case a.mk.mp
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).fst ∈ s ∧ (a₁, a₂).fst = (a₁, a₂).snd
⊢ a₁ ∈ s ∧ (a₁, a₁) = (a₁, a₂)

tactic: rcases h with ⟨a, h1, h2⟩
state_before: case a.mk.mpr
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : ∃ a, a ∈ s ∧ (a, a) = (a₁, a₂)
⊢ (a₁, a₂).fst ∈ s ∧ (a₁, a₂).fst = (a₁, a₂).snd

tactic: have h := Prod.mk.inj h2
state_before: case a.mk.mpr.intro.intro
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
⊢ (a₁, a₂).fst ∈ s ∧ (a₁, a₂).fst = (a₁, a₂).snd

tactic: rw [← h.1, ← h.2]
state_before: case a.mk.mpr.intro.intro
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
h : a = a₁ ∧ a = a₂
⊢ (a₁, a₂).fst ∈ s ∧ (a₁, a₂).fst = (a₁, a₂).snd

tactic: use h1
state_before: case a.mk.mpr.intro.intro
α : Type u_1
β : Type ?u.109406
γ : Type ?u.109409
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
h : a = a₁ ∧ a = a₂
⊢ (a, a).fst ∈ s ∧ (a, a).fst = (a, a).snd