l3lab/ntp-mathlib huggingface dataset:
/-- The multinomial theorem

  Proof is by induction on the number of summands.
-/
theorem sum_pow_of_commute [Semiring R] (x : α → R)
    (hc : (s : Set α).Pairwise fun i j => Commute (x i) (x j)) :
    ∀ n,
      s.sum x ^ n =
        ∑ k : s.sym n,
          k.1.1.multinomial *
            (k.1.1.map <| x).noncommProd
              (Multiset.map_set_pairwise <| hc.mono <| mem_sym_iff.1 k.2) := by
  induction' s using Finset.induction with a s ha ih
  · rw [sum_empty]
    rintro (_ | n)
      -- Porting note : Lean cannot infer this instance by itself
    · haveI : Subsingleton (Sym α 0) := Unique.instSubsingleton
      rw [_root_.pow_zero, Fintype.sum_subsingleton]
      swap
        -- Porting note : Lean cannot infer this instance by itself
      · have : Zero (Sym α 0) := Sym.instZeroSym
        exact ⟨0, by simp [eq_iff_true_of_subsingleton]⟩
      convert (@one_mul R _ _).symm
      dsimp only
      convert @Nat.cast_one R _
    · rw [_root_.pow_succ, zero_mul]
      -- Porting note : Lean cannot infer this instance by itself
      haveI : IsEmpty (Finset.sym (∅ : Finset α) (succ n)) := Finset.instIsEmpty
      apply (Fintype.sum_empty _).symm
  intro n; specialize ih (hc.mono <| s.subset_insert a)
  rw [sum_insert ha, (Commute.sum_right s _ _ _).add_pow, sum_range]; swap
  · exact fun _ hb => hc (mem_insert_self a s) (mem_insert_of_mem hb)
      (ne_of_mem_of_not_mem hb ha).symm
  · simp_rw [ih, mul_sum, sum_mul, sum_sigma', univ_sigma_univ]
    refine' (Fintype.sum_equiv (symInsertEquiv ha) _ _ fun m => _).symm
    rw [m.1.1.multinomial_filter_ne a]
    conv in m.1.1.map _ => 

Proof state:
α : Type u_1
inst✝¹ : DecidableEq α
s✝ : Finset α
R : Type u_2
inst✝ : Semiring R
x : α → R
a : α
s : Finset α
ha : a ∉ s
hc : Set.Pairwise ↑(insert a s) fun i j => Commute (x i) (x j)
n : ℕ
ih :
  ∀ (n : ℕ),
    Finset.sum s x ^ n =
      ∑ k : { x // x ∈ Finset.sym s n },
        ↑(Multiset.multinomial ↑↑k) *
          Multiset.noncommProd (Multiset.map x ↑↑k) (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑k} Commute)
m : { x // x ∈ Finset.sym (insert a s) n }
| Multiset.map x ↑↑m

Next tactic:
rw [← m.1.1.filter_add_not (a = ·), Multiset.map_add]
/-- The multinomial theorem

  Proof is by induction on the number of summands.
-/
theorem sum_pow_of_commute [Semiring R] (x : α → R)
    (hc : (s : Set α).Pairwise fun i j => Commute (x i) (x j)) :
    ∀ n,
      s.sum x ^ n =
        ∑ k : s.sym n,
          k.1.1.multinomial *
            (k.1.1.map <| x).noncommProd
              (Multiset.map_set_pairwise <| hc.mono <| mem_sym_iff.1 k.2) := by
  induction' s using Finset.induction with a s ha ih
  · rw [sum_empty]
    rintro (_ | n)
      -- Porting note : Lean cannot infer this instance by itself
    · haveI : Subsingleton (Sym α 0) := Unique.instSubsingleton
      rw [_root_.pow_zero, Fintype.sum_subsingleton]
      swap
        -- Porting note : Lean cannot infer this instance by itself
      · have : Zero (Sym α 0) := Sym.instZeroSym
        exact ⟨0, by simp [eq_iff_true_of_subsingleton]⟩
      convert (@one_mul R _ _).symm
      dsimp only
      convert @Nat.cast_one R _
    · rw [_root_.pow_succ, zero_mul]
      -- Porting note : Lean cannot infer this instance by itself
      haveI : IsEmpty (Finset.sym (∅ : Finset α) (succ n)) := Finset.instIsEmpty
      apply (Fintype.sum_empty _).symm
  intro n; specialize ih (hc.mono <| s.subset_insert a)
  rw [sum_insert ha, (Commute.sum_right s _ _ _).add_pow, sum_range]; swap
  · exact fun _ hb => hc (mem_insert_self a s) (mem_insert_of_mem hb)
      (ne_of_mem_of_not_mem hb ha).symm
  · simp_rw [ih, mul_sum, sum_mul, sum_sigma', univ_sigma_univ]
    refine' (Fintype.sum_equiv (symInsertEquiv ha) _ _ fun m => _).symm
    rw [m.1.1.multinomial_filter_ne a]
    conv in m.1.1.map _ => rw [← m.1.1.filter_add_not (a = ·), Multiset.map_add]
    

Proof state:
case insert
α : Type u_1
inst✝¹ : DecidableEq α
s✝ : Finset α
R : Type u_2
inst✝ : Semiring R
x : α → R
a : α
s : Finset α
ha : a ∉ s
hc : Set.Pairwise ↑(insert a s) fun i j => Commute (x i) (x j)
n : ℕ
ih :
  ∀ (n : ℕ),
    Finset.sum s x ^ n =
      ∑ k : { x // x ∈ Finset.sym s n },
        ↑(Multiset.multinomial ↑↑k) *
          Multiset.noncommProd (Multiset.map x ↑↑k) (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑k} Commute)
m : { x // x ∈ Finset.sym (insert a s) n }
⊢ ↑(Nat.choose (Multiset.card ↑↑m) (Multiset.count a ↑↑m) *
          Multiset.multinomial (Multiset.filter (fun x => a ≠ x) ↑↑m)) *
      Multiset.noncommProd
        (Multiset.map x (Multiset.filter (fun x => a = x) ↑↑m) +
          Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m))
        (_ :
          Set.Pairwise
            {x_1 |
              x_1 ∈
                Multiset.map x (Multiset.filter (fun x => a = x) ↑↑m) +
                  Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m)}
            Commute) =
    x a ^ ↑((symInsertEquiv ha) m).fst *
        (↑(Multiset.multinomial ↑↑((symInsertEquiv ha) m).snd) *
          Multiset.noncommProd (Multiset.map x ↑↑((symInsertEquiv ha) m).snd)
            (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑((symInsertEquiv ha) m).snd} Commute)) *
      ↑(Nat.choose n ↑((symInsertEquiv ha) m).fst)

Next tactic:
simp_rw [Multiset.noncommProd_add, m.1.1.filter_eq, Multiset.map_replicate, m.1.2]
/-- The multinomial theorem

  Proof is by induction on the number of summands.
-/
theorem sum_pow_of_commute [Semiring R] (x : α → R)
    (hc : (s : Set α).Pairwise fun i j => Commute (x i) (x j)) :
    ∀ n,
      s.sum x ^ n =
        ∑ k : s.sym n,
          k.1.1.multinomial *
            (k.1.1.map <| x).noncommProd
              (Multiset.map_set_pairwise <| hc.mono <| mem_sym_iff.1 k.2) := by
  induction' s using Finset.induction with a s ha ih
  · rw [sum_empty]
    rintro (_ | n)
      -- Porting note : Lean cannot infer this instance by itself
    · haveI : Subsingleton (Sym α 0) := Unique.instSubsingleton
      rw [_root_.pow_zero, Fintype.sum_subsingleton]
      swap
        -- Porting note : Lean cannot infer this instance by itself
      · have : Zero (Sym α 0) := Sym.instZeroSym
        exact ⟨0, by simp [eq_iff_true_of_subsingleton]⟩
      convert (@one_mul R _ _).symm
      dsimp only
      convert @Nat.cast_one R _
    · rw [_root_.pow_succ, zero_mul]
      -- Porting note : Lean cannot infer this instance by itself
      haveI : IsEmpty (Finset.sym (∅ : Finset α) (succ n)) := Finset.instIsEmpty
      apply (Fintype.sum_empty _).symm
  intro n; specialize ih (hc.mono <| s.subset_insert a)
  rw [sum_insert ha, (Commute.sum_right s _ _ _).add_pow, sum_range]; swap
  · exact fun _ hb => hc (mem_insert_self a s) (mem_insert_of_mem hb)
      (ne_of_mem_of_not_mem hb ha).symm
  · simp_rw [ih, mul_sum, sum_mul, sum_sigma', univ_sigma_univ]
    refine' (Fintype.sum_equiv (symInsertEquiv ha) _ _ fun m => _).symm
    rw [m.1.1.multinomial_filter_ne a]
    conv in m.1.1.map _ => rw [← m.1.1.filter_add_not (a = ·), Multiset.map_add]
    simp_rw [Multiset.noncommProd_add, m.1.1.filter_eq, Multiset.map_replicate, m.1.2]
    

Proof state:
case insert
α : Type u_1
inst✝¹ : DecidableEq α
s✝ : Finset α
R : Type u_2
inst✝ : Semiring R
x : α → R
a : α
s : Finset α
ha : a ∉ s
hc : Set.Pairwise ↑(insert a s) fun i j => Commute (x i) (x j)
n : ℕ
ih :
  ∀ (n : ℕ),
    Finset.sum s x ^ n =
      ∑ k : { x // x ∈ Finset.sym s n },
        ↑(Multiset.multinomial ↑↑k) *
          Multiset.noncommProd (Multiset.map x ↑↑k) (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑k} Commute)
m : { x // x ∈ Finset.sym (insert a s) n }
⊢ ↑(Nat.choose n (Multiset.count a ↑↑m) * Multiset.multinomial (Multiset.filter (fun x => a ≠ x) ↑↑m)) *
      (Multiset.noncommProd (Multiset.replicate (Multiset.count a ↑↑m) (x a))
          (_ : Set.Pairwise {x_1 | x_1 ∈ Multiset.replicate (Multiset.count a ↑↑m) (x a)} Commute) *
        Multiset.noncommProd (Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m))
          (_ : Set.Pairwise {x_1 | x_1 ∈ Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m)} Commute)) =
    x a ^ ↑((symInsertEquiv ha) m).fst *
        (↑(Multiset.multinomial ↑↑((symInsertEquiv ha) m).snd) *
          Multiset.noncommProd (Multiset.map x ↑↑((symInsertEquiv ha) m).snd)
            (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑((symInsertEquiv ha) m).snd} Commute)) *
      ↑(Nat.choose n ↑((symInsertEquiv ha) m).fst)

Next tactic:
rw [Multiset.noncommProd_eq_pow_card _ _ _ fun _ => Multiset.eq_of_mem_replicate]
/-- The multinomial theorem

  Proof is by induction on the number of summands.
-/
theorem sum_pow_of_commute [Semiring R] (x : α → R)
    (hc : (s : Set α).Pairwise fun i j => Commute (x i) (x j)) :
    ∀ n,
      s.sum x ^ n =
        ∑ k : s.sym n,
          k.1.1.multinomial *
            (k.1.1.map <| x).noncommProd
              (Multiset.map_set_pairwise <| hc.mono <| mem_sym_iff.1 k.2) := by
  induction' s using Finset.induction with a s ha ih
  · rw [sum_empty]
    rintro (_ | n)
      -- Porting note : Lean cannot infer this instance by itself
    · haveI : Subsingleton (Sym α 0) := Unique.instSubsingleton
      rw [_root_.pow_zero, Fintype.sum_subsingleton]
      swap
        -- Porting note : Lean cannot infer this instance by itself
      · have : Zero (Sym α 0) := Sym.instZeroSym
        exact ⟨0, by simp [eq_iff_true_of_subsingleton]⟩
      convert (@one_mul R _ _).symm
      dsimp only
      convert @Nat.cast_one R _
    · rw [_root_.pow_succ, zero_mul]
      -- Porting note : Lean cannot infer this instance by itself
      haveI : IsEmpty (Finset.sym (∅ : Finset α) (succ n)) := Finset.instIsEmpty
      apply (Fintype.sum_empty _).symm
  intro n; specialize ih (hc.mono <| s.subset_insert a)
  rw [sum_insert ha, (Commute.sum_right s _ _ _).add_pow, sum_range]; swap
  · exact fun _ hb => hc (mem_insert_self a s) (mem_insert_of_mem hb)
      (ne_of_mem_of_not_mem hb ha).symm
  · simp_rw [ih, mul_sum, sum_mul, sum_sigma', univ_sigma_univ]
    refine' (Fintype.sum_equiv (symInsertEquiv ha) _ _ fun m => _).symm
    rw [m.1.1.multinomial_filter_ne a]
    conv in m.1.1.map _ => rw [← m.1.1.filter_add_not (a = ·), Multiset.map_add]
    simp_rw [Multiset.noncommProd_add, m.1.1.filter_eq, Multiset.map_replicate, m.1.2]
    rw [Multiset.noncommProd_eq_pow_card _ _ _ fun _ => Multiset.eq_of_mem_replicate]
    

Proof state:
case insert
α : Type u_1
inst✝¹ : DecidableEq α
s✝ : Finset α
R : Type u_2
inst✝ : Semiring R
x : α → R
a : α
s : Finset α
ha : a ∉ s
hc : Set.Pairwise ↑(insert a s) fun i j => Commute (x i) (x j)
n : ℕ
ih :
  ∀ (n : ℕ),
    Finset.sum s x ^ n =
      ∑ k : { x // x ∈ Finset.sym s n },
        ↑(Multiset.multinomial ↑↑k) *
          Multiset.noncommProd (Multiset.map x ↑↑k) (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑k} Commute)
m : { x // x ∈ Finset.sym (insert a s) n }
⊢ ↑(Nat.choose n (Multiset.count a ↑↑m) * Multiset.multinomial (Multiset.filter (fun x => a ≠ x) ↑↑m)) *
      (x a ^ Multiset.card (Multiset.replicate (Multiset.count a ↑↑m) (x a)) *
        Multiset.noncommProd (Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m))
          (_ : Set.Pairwise {x_1 | x_1 ∈ Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m)} Commute)) =
    x a ^ ↑((symInsertEquiv ha) m).fst *
        (↑(Multiset.multinomial ↑↑((symInsertEquiv ha) m).snd) *
          Multiset.noncommProd (Multiset.map x ↑↑((symInsertEquiv ha) m).snd)
            (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑((symInsertEquiv ha) m).snd} Commute)) *
      ↑(Nat.choose n ↑((symInsertEquiv ha) m).fst)

Next tactic:
rw [Multiset.card_replicate, Nat.cast_mul, mul_assoc, Nat.cast_comm]
/-- The multinomial theorem

  Proof is by induction on the number of summands.
-/
theorem sum_pow_of_commute [Semiring R] (x : α → R)
    (hc : (s : Set α).Pairwise fun i j => Commute (x i) (x j)) :
    ∀ n,
      s.sum x ^ n =
        ∑ k : s.sym n,
          k.1.1.multinomial *
            (k.1.1.map <| x).noncommProd
              (Multiset.map_set_pairwise <| hc.mono <| mem_sym_iff.1 k.2) := by
  induction' s using Finset.induction with a s ha ih
  · rw [sum_empty]
    rintro (_ | n)
      -- Porting note : Lean cannot infer this instance by itself
    · haveI : Subsingleton (Sym α 0) := Unique.instSubsingleton
      rw [_root_.pow_zero, Fintype.sum_subsingleton]
      swap
        -- Porting note : Lean cannot infer this instance by itself
      · have : Zero (Sym α 0) := Sym.instZeroSym
        exact ⟨0, by simp [eq_iff_true_of_subsingleton]⟩
      convert (@one_mul R _ _).symm
      dsimp only
      convert @Nat.cast_one R _
    · rw [_root_.pow_succ, zero_mul]
      -- Porting note : Lean cannot infer this instance by itself
      haveI : IsEmpty (Finset.sym (∅ : Finset α) (succ n)) := Finset.instIsEmpty
      apply (Fintype.sum_empty _).symm
  intro n; specialize ih (hc.mono <| s.subset_insert a)
  rw [sum_insert ha, (Commute.sum_right s _ _ _).add_pow, sum_range]; swap
  · exact fun _ hb => hc (mem_insert_self a s) (mem_insert_of_mem hb)
      (ne_of_mem_of_not_mem hb ha).symm
  · simp_rw [ih, mul_sum, sum_mul, sum_sigma', univ_sigma_univ]
    refine' (Fintype.sum_equiv (symInsertEquiv ha) _ _ fun m => _).symm
    rw [m.1.1.multinomial_filter_ne a]
    conv in m.1.1.map _ => rw [← m.1.1.filter_add_not (a = ·), Multiset.map_add]
    simp_rw [Multiset.noncommProd_add, m.1.1.filter_eq, Multiset.map_replicate, m.1.2]
    rw [Multiset.noncommProd_eq_pow_card _ _ _ fun _ => Multiset.eq_of_mem_replicate]
    rw [Multiset.card_replicate, Nat.cast_mul, mul_assoc, Nat.cast_comm]
    

Proof state:
case insert
α : Type u_1
inst✝¹ : DecidableEq α
s✝ : Finset α
R : Type u_2
inst✝ : Semiring R
x : α → R
a : α
s : Finset α
ha : a ∉ s
hc : Set.Pairwise ↑(insert a s) fun i j => Commute (x i) (x j)
n : ℕ
ih :
  ∀ (n : ℕ),
    Finset.sum s x ^ n =
      ∑ k : { x // x ∈ Finset.sym s n },
        ↑(Multiset.multinomial ↑↑k) *
          Multiset.noncommProd (Multiset.map x ↑↑k) (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑k} Commute)
m : { x // x ∈ Finset.sym (insert a s) n }
⊢ ↑(Multiset.multinomial (Multiset.filter (fun x => a ≠ x) ↑↑m)) *
        (x a ^ Multiset.count a ↑↑m *
          Multiset.noncommProd (Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m))
            (_ : Set.Pairwise {x_1 | x_1 ∈ Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m)} Commute)) *
      ↑(Nat.choose n (Multiset.count a ↑↑m)) =
    x a ^ ↑((symInsertEquiv ha) m).fst *
        (↑(Multiset.multinomial ↑↑((symInsertEquiv ha) m).snd) *
          Multiset.noncommProd (Multiset.map x ↑↑((symInsertEquiv ha) m).snd)
            (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑((symInsertEquiv ha) m).snd} Commute)) *
      ↑(Nat.choose n ↑((symInsertEquiv ha) m).fst)

Next tactic:
congr 1
/-- The multinomial theorem

  Proof is by induction on the number of summands.
-/
theorem sum_pow_of_commute [Semiring R] (x : α → R)
    (hc : (s : Set α).Pairwise fun i j => Commute (x i) (x j)) :
    ∀ n,
      s.sum x ^ n =
        ∑ k : s.sym n,
          k.1.1.multinomial *
            (k.1.1.map <| x).noncommProd
              (Multiset.map_set_pairwise <| hc.mono <| mem_sym_iff.1 k.2) := by
  induction' s using Finset.induction with a s ha ih
  · rw [sum_empty]
    rintro (_ | n)
      -- Porting note : Lean cannot infer this instance by itself
    · haveI : Subsingleton (Sym α 0) := Unique.instSubsingleton
      rw [_root_.pow_zero, Fintype.sum_subsingleton]
      swap
        -- Porting note : Lean cannot infer this instance by itself
      · have : Zero (Sym α 0) := Sym.instZeroSym
        exact ⟨0, by simp [eq_iff_true_of_subsingleton]⟩
      convert (@one_mul R _ _).symm
      dsimp only
      convert @Nat.cast_one R _
    · rw [_root_.pow_succ, zero_mul]
      -- Porting note : Lean cannot infer this instance by itself
      haveI : IsEmpty (Finset.sym (∅ : Finset α) (succ n)) := Finset.instIsEmpty
      apply (Fintype.sum_empty _).symm
  intro n; specialize ih (hc.mono <| s.subset_insert a)
  rw [sum_insert ha, (Commute.sum_right s _ _ _).add_pow, sum_range]; swap
  · exact fun _ hb => hc (mem_insert_self a s) (mem_insert_of_mem hb)
      (ne_of_mem_of_not_mem hb ha).symm
  · simp_rw [ih, mul_sum, sum_mul, sum_sigma', univ_sigma_univ]
    refine' (Fintype.sum_equiv (symInsertEquiv ha) _ _ fun m => _).symm
    rw [m.1.1.multinomial_filter_ne a]
    conv in m.1.1.map _ => rw [← m.1.1.filter_add_not (a = ·), Multiset.map_add]
    simp_rw [Multiset.noncommProd_add, m.1.1.filter_eq, Multiset.map_replicate, m.1.2]
    rw [Multiset.noncommProd_eq_pow_card _ _ _ fun _ => Multiset.eq_of_mem_replicate]
    rw [Multiset.card_replicate, Nat.cast_mul, mul_assoc, Nat.cast_comm]
    congr 1; 

Proof state:
case insert.e_a
α : Type u_1
inst✝¹ : DecidableEq α
s✝ : Finset α
R : Type u_2
inst✝ : Semiring R
x : α → R
a : α
s : Finset α
ha : a ∉ s
hc : Set.Pairwise ↑(insert a s) fun i j => Commute (x i) (x j)
n : ℕ
ih :
  ∀ (n : ℕ),
    Finset.sum s x ^ n =
      ∑ k : { x // x ∈ Finset.sym s n },
        ↑(Multiset.multinomial ↑↑k) *
          Multiset.noncommProd (Multiset.map x ↑↑k) (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑k} Commute)
m : { x // x ∈ Finset.sym (insert a s) n }
⊢ ↑(Multiset.multinomial (Multiset.filter (fun x => a ≠ x) ↑↑m)) *
      (x a ^ Multiset.count a ↑↑m *
        Multiset.noncommProd (Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m))
          (_ : Set.Pairwise {x_1 | x_1 ∈ Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m)} Commute)) =
    x a ^ ↑((symInsertEquiv ha) m).fst *
      (↑(Multiset.multinomial ↑↑((symInsertEquiv ha) m).snd) *
        Multiset.noncommProd (Multiset.map x ↑↑((symInsertEquiv ha) m).snd)
          (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑((symInsertEquiv ha) m).snd} Commute))

Next tactic:
simp_rw [← mul_assoc, Nat.cast_comm]
/-- The multinomial theorem

  Proof is by induction on the number of summands.
-/
theorem sum_pow_of_commute [Semiring R] (x : α → R)
    (hc : (s : Set α).Pairwise fun i j => Commute (x i) (x j)) :
    ∀ n,
      s.sum x ^ n =
        ∑ k : s.sym n,
          k.1.1.multinomial *
            (k.1.1.map <| x).noncommProd
              (Multiset.map_set_pairwise <| hc.mono <| mem_sym_iff.1 k.2) := by
  induction' s using Finset.induction with a s ha ih
  · rw [sum_empty]
    rintro (_ | n)
      -- Porting note : Lean cannot infer this instance by itself
    · haveI : Subsingleton (Sym α 0) := Unique.instSubsingleton
      rw [_root_.pow_zero, Fintype.sum_subsingleton]
      swap
        -- Porting note : Lean cannot infer this instance by itself
      · have : Zero (Sym α 0) := Sym.instZeroSym
        exact ⟨0, by simp [eq_iff_true_of_subsingleton]⟩
      convert (@one_mul R _ _).symm
      dsimp only
      convert @Nat.cast_one R _
    · rw [_root_.pow_succ, zero_mul]
      -- Porting note : Lean cannot infer this instance by itself
      haveI : IsEmpty (Finset.sym (∅ : Finset α) (succ n)) := Finset.instIsEmpty
      apply (Fintype.sum_empty _).symm
  intro n; specialize ih (hc.mono <| s.subset_insert a)
  rw [sum_insert ha, (Commute.sum_right s _ _ _).add_pow, sum_range]; swap
  · exact fun _ hb => hc (mem_insert_self a s) (mem_insert_of_mem hb)
      (ne_of_mem_of_not_mem hb ha).symm
  · simp_rw [ih, mul_sum, sum_mul, sum_sigma', univ_sigma_univ]
    refine' (Fintype.sum_equiv (symInsertEquiv ha) _ _ fun m => _).symm
    rw [m.1.1.multinomial_filter_ne a]
    conv in m.1.1.map _ => rw [← m.1.1.filter_add_not (a = ·), Multiset.map_add]
    simp_rw [Multiset.noncommProd_add, m.1.1.filter_eq, Multiset.map_replicate, m.1.2]
    rw [Multiset.noncommProd_eq_pow_card _ _ _ fun _ => Multiset.eq_of_mem_replicate]
    rw [Multiset.card_replicate, Nat.cast_mul, mul_assoc, Nat.cast_comm]
    congr 1; simp_rw [← mul_assoc, Nat.cast_comm]; 

Proof state:
case insert.e_a
α : Type u_1
inst✝¹ : DecidableEq α
s✝ : Finset α
R : Type u_2
inst✝ : Semiring R
x : α → R
a : α
s : Finset α
ha : a ∉ s
hc : Set.Pairwise ↑(insert a s) fun i j => Commute (x i) (x j)
n : ℕ
ih :
  ∀ (n : ℕ),
    Finset.sum s x ^ n =
      ∑ k : { x // x ∈ Finset.sym s n },
        ↑(Multiset.multinomial ↑↑k) *
          Multiset.noncommProd (Multiset.map x ↑↑k) (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑k} Commute)
m : { x // x ∈ Finset.sym (insert a s) n }
⊢ x a ^ Multiset.count a ↑↑m * ↑(Multiset.multinomial (Multiset.filter (fun x => a ≠ x) ↑↑m)) *
      Multiset.noncommProd (Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m))
        (_ : Set.Pairwise {x_1 | x_1 ∈ Multiset.map x (Multiset.filter (fun a_1 => ¬a = a_1) ↑↑m)} Commute) =
    x a ^ ↑((symInsertEquiv ha) m).fst * ↑(Multiset.multinomial ↑↑((symInsertEquiv ha) m).snd) *
      Multiset.noncommProd (Multiset.map x ↑↑((symInsertEquiv ha) m).snd)
        (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑((symInsertEquiv ha) m).snd} Commute)

Next tactic:
rfl
theorem sum_pow [CommSemiring R] (x : α → R) (n : ℕ) :
    s.sum x ^ n = ∑ k in s.sym n, k.val.multinomial * (k.val.map x).prod := by
  

Proof state:
α : Type u_1
inst✝¹ : DecidableEq α
s : Finset α
R : Type u_2
inst✝ : CommSemiring R
x : α → R
n : ℕ
⊢ Finset.sum s x ^ n = ∑ k in Finset.sym s n, ↑(Multiset.multinomial ↑k) * Multiset.prod (Multiset.map x ↑k)

Next tactic:
conv_rhs => rw [← sum_coe_sort]
theorem sum_pow [CommSemiring R] (x : α → R) (n : ℕ) :
    s.sum x ^ n = ∑ k in s.sym n, k.val.multinomial * (k.val.map x).prod := by
  conv_rhs => 

Proof state:
α : Type u_1
inst✝¹ : DecidableEq α
s : Finset α
R : Type u_2
inst✝ : CommSemiring R
x : α → R
n : ℕ
| ∑ k in Finset.sym s n, ↑(Multiset.multinomial ↑k) * Multiset.prod (Multiset.map x ↑k)

Next tactic:
rw [← sum_coe_sort]
theorem sum_pow [CommSemiring R] (x : α → R) (n : ℕ) :
    s.sum x ^ n = ∑ k in s.sym n, k.val.multinomial * (k.val.map x).prod := by
  conv_rhs => rw [← sum_coe_sort]
  

Proof state:
α : Type u_1
inst✝¹ : DecidableEq α
s : Finset α
R : Type u_2
inst✝ : CommSemiring R
x : α → R
n : ℕ
⊢ Finset.sum s x ^ n =
    ∑ i : { x // x ∈ Finset.sym s n }, ↑(Multiset.multinomial ↑↑i) * Multiset.prod (Multiset.map x ↑↑i)

Next tactic:
convert sum_pow_of_commute s x (fun _ _ _ _ _ => mul_comm _ _) n
theorem sum_pow [CommSemiring R] (x : α → R) (n : ℕ) :
    s.sum x ^ n = ∑ k in s.sym n, k.val.multinomial * (k.val.map x).prod := by
  conv_rhs => rw [← sum_coe_sort]
  convert sum_pow_of_commute s x (fun _ _ _ _ _ => mul_comm _ _) n
  

Proof state:
case h.e'_3.a.h.e'_6
α : Type u_1
inst✝¹ : DecidableEq α
s : Finset α
R : Type u_2
inst✝ : CommSemiring R
x : α → R
n : ℕ
x✝ : { x // x ∈ Finset.sym s n }
a✝ : x✝ ∈ univ
⊢ Multiset.prod (Multiset.map x ↑↑x✝) =
    Multiset.noncommProd (Multiset.map x ↑↑x✝) (_ : Set.Pairwise {b | b ∈ Multiset.map x ↑↑x✝} Commute)

Next tactic:
rw [Multiset.noncommProd_eq_prod]
@[to_additive]
theorem MeasurableSet.const_smul {G α : Type*} [Group G] [MulAction G α] [MeasurableSpace G]
    [MeasurableSpace α] [MeasurableSMul G α] {s : Set α} (hs : MeasurableSet s) (a : G) :
    MeasurableSet (a • s) := by
  

Proof state:
G : Type u_1
α : Type u_2
inst✝⁴ : Group G
inst✝³ : MulAction G α
inst✝² : MeasurableSpace G
inst✝¹ : MeasurableSpace α
inst✝ : MeasurableSMul G α
s : Set α
hs : MeasurableSet s
a : G
⊢ MeasurableSet (a • s)

Next tactic:
rw [← preimage_smul_inv]
@[to_additive]
theorem MeasurableSet.const_smul {G α : Type*} [Group G] [MulAction G α] [MeasurableSpace G]
    [MeasurableSpace α] [MeasurableSMul G α] {s : Set α} (hs : MeasurableSet s) (a : G) :
    MeasurableSet (a • s) := by
  rw [← preimage_smul_inv]
  

Proof state:
G : Type u_1
α : Type u_2
inst✝⁴ : Group G
inst✝³ : MulAction G α
inst✝² : MeasurableSpace G
inst✝¹ : MeasurableSpace α
inst✝ : MeasurableSMul G α
s : Set α
hs : MeasurableSet s
a : G
⊢ MeasurableSet ((fun x => a⁻¹ • x) ⁻¹' s)

Next tactic:
exact measurable_const_smul _ hs
theorem MeasurableSet.const_smul_of_ne_zero {G₀ α : Type*} [GroupWithZero G₀] [MulAction G₀ α]
    [MeasurableSpace G₀] [MeasurableSpace α] [MeasurableSMul G₀ α] {s : Set α}
    (hs : MeasurableSet s) {a : G₀} (ha : a ≠ 0) : MeasurableSet (a • s) := by
  

Proof state:
G₀ : Type u_1
α : Type u_2
inst✝⁴ : GroupWithZero G₀
inst✝³ : MulAction G₀ α
inst✝² : MeasurableSpace G₀
inst✝¹ : MeasurableSpace α
inst✝ : MeasurableSMul G₀ α
s : Set α
hs : MeasurableSet s
a : G₀
ha : a ≠ 0
⊢ MeasurableSet (a • s)

Next tactic:
rw [← preimage_smul_inv₀ ha]