Theorem: Finset.mulEnergy_eq_sum_sq'
File: Mathlib/Combinatorics/Additive/Energy.lean

tactic: simp_rw [mulEnergy_eq_card_filter, sq, ← card_product]
state_before: α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ Eₘ[s, t] =
    ∑ a ∈ s * t,
      (filter
            (fun x =>
              match x with
              | (x, y) => x * y = a)
            (s ×ˢ t)).card ^
        2
state_after: α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t)).card =
    ∑ x ∈ s * t, (filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)).card

tactic: rw [← card_disjiUnion]
state_before: α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t)).card =
    ∑ x ∈ s * t, (filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)).card
state_after: α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t)).card =
    ((s * t).disjiUnion
        (fun x => filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t))
        ?h).card

case h
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (↑(s * t)).PairwiseDisjoint fun x =>
    filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)

tactic: swap
state_before: α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t)).card =
    ((s * t).disjiUnion
        (fun x => filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t))
        ?h).card

case h
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (↑(s * t)).PairwiseDisjoint fun x =>
    filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)
state_after: case h
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (↑(s * t)).PairwiseDisjoint fun x =>
    filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)

α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t)).card =
    ((s * t).disjiUnion
        (fun x => filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t))
        ?h).card

tactic: simp only [Set.PairwiseDisjoint, Set.Pairwise, coe_mul, ne_eq, disjoint_left, mem_product,
  mem_filter, not_and, and_imp, Prod.forall]
state_before: case h
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (↑(s * t)).PairwiseDisjoint fun x =>
    filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)
state_after: case h
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ ∀ ⦃x : α⦄,
    x ∈ ↑s * ↑t →
      ∀ ⦃y : α⦄,
        y ∈ ↑s * ↑t →
          ¬x = y →
            ∀ (a b a_1 b_1 : α),
              a ∈ s →
                b ∈ t →
                  a * b = x →
                    a_1 ∈ s → b_1 ∈ t → a_1 * b_1 = x → a ∈ s → b ∈ t → a * b = y → a_1 ∈ s → b_1 ∈ t → ¬a_1 * b_1 = y

tactic: aesop
state_before: case h
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ ∀ ⦃x : α⦄,
    x ∈ ↑s * ↑t →
      ∀ ⦃y : α⦄,
        y ∈ ↑s * ↑t →
          ¬x = y →
            ∀ (a b a_1 b_1 : α),
              a ∈ s →
                b ∈ t →
                  a * b = x →
                    a_1 ∈ s → b_1 ∈ t → a_1 * b_1 = x → a ∈ s → b ∈ t → a * b = y → a_1 ∈ s → b_1 ∈ t → ¬a_1 * b_1 = y
state_after: no goals

tactic: congr
state_before: α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ (filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t)).card =
    ((s * t).disjiUnion
        (fun x => filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t))
        ⋯).card
state_after: case e_s
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t) =
    (s * t).disjiUnion
      (fun x => filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)) ⋯

tactic: ext
state_before: case e_s
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
⊢ filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t) =
    (s * t).disjiUnion
      (fun x => filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)) ⋯
state_after: case e_s.a
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
a✝ : (α × α) × α × α
⊢ a✝ ∈ filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t) ↔
    a✝ ∈
      (s * t).disjiUnion
        (fun x => filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)) ⋯

tactic: simp only [mem_filter, mem_product, disjiUnion_eq_biUnion, mem_biUnion]
state_before: case e_s.a
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
a✝ : (α × α) × α × α
⊢ a✝ ∈ filter (fun x => x.1.1 * x.1.2 = x.2.1 * x.2.2) ((s ×ˢ t) ×ˢ s ×ˢ t) ↔
    a✝ ∈
      (s * t).disjiUnion
        (fun x => filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t) ×ˢ filter (fun x_1 => x_1.1 * x_1.2 = x) (s ×ˢ t)) ⋯
state_after: case e_s.a
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
a✝ : (α × α) × α × α
⊢ ((a✝.1.1 ∈ s ∧ a✝.1.2 ∈ t) ∧ a✝.2.1 ∈ s ∧ a✝.2.2 ∈ t) ∧ a✝.1.1 * a✝.1.2 = a✝.2.1 * a✝.2.2 ↔
    ∃ a ∈ s * t, ((a✝.1.1 ∈ s ∧ a✝.1.2 ∈ t) ∧ a✝.1.1 * a✝.1.2 = a) ∧ (a✝.2.1 ∈ s ∧ a✝.2.2 ∈ t) ∧ a✝.2.1 * a✝.2.2 = a

tactic: aesop (add unsafe mul_mem_mul)
state_before: case e_s.a
α : Type u_1
inst✝¹ : DecidableEq α
inst✝ : Mul α
s✝ s₁ s₂ t✝ t₁ t₂ s t : Finset α
a✝ : (α × α) × α × α
⊢ ((a✝.1.1 ∈ s ∧ a✝.1.2 ∈ t) ∧ a✝.2.1 ∈ s ∧ a✝.2.2 ∈ t) ∧ a✝.1.1 * a✝.1.2 = a✝.2.1 * a✝.2.2 ↔
    ∃ a ∈ s * t, ((a✝.1.1 ∈ s ∧ a✝.1.2 ∈ t) ∧ a✝.1.1 * a✝.1.2 = a) ∧ (a✝.2.1 ∈ s ∧ a✝.2.2 ∈ t) ∧ a✝.2.1 * a✝.2.2 = a
state_after: no goals