Theorem: Sym2.two_mul_card_image_offDiag
File: Mathlib/Data/Sym/Card.lean

tactic: rw [card_eq_sum_card_image (Quotient.mk' : α × α → _), sum_const_nat (Quotient.ind' _), mul_comm]
state_before: α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
⊢ 2 * Finset.card (image Quotient.mk' (offDiag s)) = Finset.card (offDiag s)

tactic: rintro ⟨x, y⟩ hxy
state_before: α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
⊢ ∀ (a : α × α),
    Quotient.mk'' a ∈ image Quotient.mk' (offDiag s) →
      Finset.card (filter (fun x => Quotient.mk' x = Quotient.mk'' a) (offDiag s)) = 2

tactic: simp_rw [mem_image, mem_offDiag] at hxy
state_before: case mk
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
hxy : Quotient.mk'' (x, y) ∈ image Quotient.mk' (offDiag s)
⊢ Finset.card (filter (fun x_1 => Quotient.mk' x_1 = Quotient.mk'' (x, y)) (offDiag s)) = 2

tactic: obtain ⟨a, ⟨ha₁, ha₂, ha⟩, h⟩ := hxy
state_before: case mk
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
hxy : ∃ a, (a.fst ∈ s ∧ a.snd ∈ s ∧ a.fst ≠ a.snd) ∧ Quotient.mk' a = Quotient.mk'' (x, y)
⊢ Finset.card (filter (fun x_1 => Quotient.mk' x_1 = Quotient.mk'' (x, y)) (offDiag s)) = 2

tactic: replace h := Quotient.eq.1 h
state_before: case mk.intro.intro.intro.intro
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
h : Quotient.mk' a = Quotient.mk'' (x, y)
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
⊢ Finset.card (filter (fun x_1 => Quotient.mk' x_1 = Quotient.mk'' (x, y)) (offDiag s)) = 2

tactic: obtain ⟨hx, hy, hxy⟩ : x ∈ s ∧ y ∈ s ∧ x ≠ y := by
  cases h <;> refine' ⟨‹_›, ‹_›, _⟩ <;> [exact ha; exact ha.symm]
state_before: case mk.intro.intro.intro.intro
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
⊢ Finset.card (filter (fun x_1 => Quotient.mk' x_1 = Quotient.mk'' (x, y)) (offDiag s)) = 2

tactic: have hxy' : y ≠ x := hxy.symm
state_before: case mk.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
⊢ Finset.card (filter (fun x_1 => Quotient.mk' x_1 = Quotient.mk'' (x, y)) (offDiag s)) = 2

tactic: have : (s.offDiag.filter fun z => ⟦z⟧ = ⟦(x, y)⟧) = ({(x, y), (y, x)} : Finset _) := by
  ext ⟨x₁, y₁⟩
  rw [mem_filter, mem_insert, mem_singleton, Sym2.eq_iff, Prod.mk.inj_iff, Prod.mk.inj_iff,
    and_iff_right_iff_imp]
  rintro (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩) <;> rw [mem_offDiag] <;> exact ⟨‹_›, ‹_›, ‹_›⟩
state_before: case mk.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
hxy' : y ≠ x
⊢ Finset.card (filter (fun x_1 => Quotient.mk' x_1 = Quotient.mk'' (x, y)) (offDiag s)) = 2

tactic: dsimp [Quotient.mk', Quotient.mk''_eq_mk]
state_before: case mk.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
hxy' : y ≠ x
this : filter (fun z => Quotient.mk (Rel.setoid α) z = Quotient.mk (Rel.setoid α) (x, y)) (offDiag s) = {(x, y), (y, x)}
⊢ Finset.card (filter (fun x_1 => Quotient.mk' x_1 = Quotient.mk'' (x, y)) (offDiag s)) = 2

tactic: rw [this, card_insert_of_not_mem, card_singleton]
state_before: case mk.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
hxy' : y ≠ x
this : filter (fun z => Quotient.mk (Rel.setoid α) z = Quotient.mk (Rel.setoid α) (x, y)) (offDiag s) = {(x, y), (y, x)}
⊢ Finset.card (filter (fun x_1 => Quotient.mk (Rel.setoid α) x_1 = Quotient.mk (Rel.setoid α) (x, y)) (offDiag s)) = 2

tactic: simp only [not_and, Prod.mk.inj_iff, mem_singleton]
state_before: case mk.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
hxy' : y ≠ x
this : filter (fun z => Quotient.mk (Rel.setoid α) z = Quotient.mk (Rel.setoid α) (x, y)) (offDiag s) = {(x, y), (y, x)}
⊢ ¬(x, y) ∈ {(y, x)}

tactic: exact fun _ => hxy'
state_before: case mk.intro.intro.intro.intro.intro.intro
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
hxy' : y ≠ x
this : filter (fun z => Quotient.mk (Rel.setoid α) z = Quotient.mk (Rel.setoid α) (x, y)) (offDiag s) = {(x, y), (y, x)}
⊢ x = y → ¬y = x

tactic: cases h <;> refine' ⟨‹_›, ‹_›, _⟩ <;> [exact ha; exact ha.symm]
state_before: α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
⊢ x ∈ s ∧ y ∈ s ∧ x ≠ y

tactic: ext ⟨x₁, y₁⟩
state_before: α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
hxy' : y ≠ x
⊢ filter (fun z => Quotient.mk (Rel.setoid α) z = Quotient.mk (Rel.setoid α) (x, y)) (offDiag s) = {(x, y), (y, x)}

tactic: rw [mem_filter, mem_insert, mem_singleton, Sym2.eq_iff, Prod.mk.inj_iff, Prod.mk.inj_iff,
  and_iff_right_iff_imp]
state_before: case a.mk
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
hxy' : y ≠ x
x₁ y₁ : α
⊢ (x₁, y₁) ∈ filter (fun z => Quotient.mk (Rel.setoid α) z = Quotient.mk (Rel.setoid α) (x, y)) (offDiag s) ↔
    (x₁, y₁) ∈ {(x, y), (y, x)}

tactic: rintro (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩) <;> rw [mem_offDiag] <;> exact ⟨‹_›, ‹_›, ‹_›⟩
state_before: case a.mk
α : Type u_1
β : Type ?u.73737
inst✝ : DecidableEq α
s : Finset α
x y : α
a : α × α
ha₁ : a.fst ∈ s
ha₂ : a.snd ∈ s
ha : a.fst ≠ a.snd
h : a ≈ (x, y)
hx : x ∈ s
hy : y ∈ s
hxy : x ≠ y
hxy' : y ≠ x
x₁ y₁ : α
⊢ x₁ = x ∧ y₁ = y ∨ x₁ = y ∧ y₁ = x → (x₁, y₁) ∈ offDiag s