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_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ s.diag.card = s.card
state_after: α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ s.diag = image (fun a => (a, a)) s

tactic: ext ⟨a₁, a₂⟩
state_before: α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
⊢ s.diag = image (fun a => (a, a)) s
state_after: case a.mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂) ∈ s.diag ↔ (a₁, a₂) ∈ image (fun a => (a, a)) s

tactic: rw [mem_diag]
state_before: case a.mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂) ∈ s.diag ↔ (a₁, a₂) ∈ image (fun a => (a, a)) s
state_after: case a.mk
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2 ↔ (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_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2 ↔ (a₁, a₂) ∈ image (fun a => (a, a)) s
state_after: case a.mk.mp
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
⊢ ∃ a ∈ s, (a, a) = (a₁, a₂)

case a.mk.mpr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : ∃ a ∈ s, (a, a) = (a₁, a₂)
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2

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

tactic: apply card_image_of_injOn
state_before: α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : s.diag = image (fun a => (a, a)) s
⊢ (image (fun a => (a, a)) s).card = s.card
state_after: case H
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
this : s.diag = image (fun a => (a, a)) s
⊢ Set.InjOn (fun a => (a, a)) ↑s

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

tactic: use a₁
state_before: case a.mk.mp
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
⊢ ∃ a ∈ s, (a, a) = (a₁, a₂)
state_after: case h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
⊢ a₁ ∈ s ∧ (a₁, a₁) = (a₁, a₂)

tactic: simpa using h
state_before: case h
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
⊢ a₁ ∈ s ∧ (a₁, a₁) = (a₁, a₂)
state_after: no goals

tactic: rcases h with ⟨a, h1, h2⟩
state_before: case a.mk.mpr
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ : α
h : ∃ a ∈ s, (a, a) = (a₁, a₂)
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
state_after: case a.mk.mpr.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2

tactic: have h := Prod.mk.inj h2
state_before: case a.mk.mpr.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2
state_after: case a.mk.mpr.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
h : a = a₁ ∧ a = a₂
⊢ (a₁, a₂).1 ∈ s ∧ (a₁, a₂).1 = (a₁, a₂).2

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

tactic: use h1
state_before: case a.mk.mpr.intro.intro
α : Type u_1
β : Type u_2
γ : Type u_3
inst✝ : DecidableEq α
s t : Finset α
x : α × α
a₁ a₂ a : α
h1 : a ∈ s
h2 : (a, a) = (a₁, a₂)
h : a = a₁ ∧ a = a₂
⊢ (a, a).1 ∈ s ∧ (a, a).1 = (a, a).2
state_after: no goals