l3lab/ntp-mathlib huggingface dataset:
theorem mul_inl_eq_op_smul [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M]
    (x : tsze R M) (r : R) :
    x * inl r = op r • x :=
  ext rfl (by 

Proof state:
R : Type u
M : Type v
inst✝³ : Semiring R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Module Rᵐᵒᵖ M
x : tsze R M
r : R
⊢ snd (x * inl r) = snd (op r • x)

Next tactic:
dsimp
theorem mul_inl_eq_op_smul [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M]
    (x : tsze R M) (r : R) :
    x * inl r = op r • x :=
  ext rfl (by dsimp; 

Proof state:
R : Type u
M : Type v
inst✝³ : Semiring R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Module Rᵐᵒᵖ M
x : tsze R M
r : R
⊢ fst x • 0 + op r • snd x = op r • snd x

Next tactic:
rw [smul_zero, zero_add]
instance mulOneClass [Monoid R] [AddMonoid M] [DistribMulAction R M] [DistribMulAction Rᵐᵒᵖ M] :
    MulOneClass (tsze R M) :=
  { TrivSqZeroExt.one, TrivSqZeroExt.mul with
    one_mul := fun x =>
      ext (one_mul x.1) <|
        show (1 : R) • x.2 + op x.1 • (0 : M) = x.2 by 

Proof state:
R : Type u
M : Type v
inst✝³ : Monoid R
inst✝² : AddMonoid M
inst✝¹ : DistribMulAction R M
inst✝ : DistribMulAction Rᵐᵒᵖ M
src✝¹ : One (tsze R M) := one
src✝ : Mul (tsze R M) := mul
x : tsze R M
⊢ 1 • x.2 + op x.1 • 0 = x.2

Next tactic:
rw [one_smul, smul_zero, add_zero]
instance mulOneClass [Monoid R] [AddMonoid M] [DistribMulAction R M] [DistribMulAction Rᵐᵒᵖ M] :
    MulOneClass (tsze R M) :=
  { TrivSqZeroExt.one, TrivSqZeroExt.mul with
    one_mul := fun x =>
      ext (one_mul x.1) <|
        show (1 : R) • x.2 + op x.1 • (0 : M) = x.2 by rw [one_smul, smul_zero, add_zero]
    mul_one := fun x =>
      ext (mul_one x.1) <|
        show x.1 • (0 : M) + (1 : Rᵐᵒᵖ) • x.2 = x.2 by 

Proof state:
R : Type u
M : Type v
inst✝³ : Monoid R
inst✝² : AddMonoid M
inst✝¹ : DistribMulAction R M
inst✝ : DistribMulAction Rᵐᵒᵖ M
src✝¹ : One (tsze R M) := one
src✝ : Mul (tsze R M) := mul
x : tsze R M
⊢ x.1 • 0 + 1 • x.2 = x.2

Next tactic:
rw [smul_zero, zero_add, one_smul]
instance addMonoidWithOne [AddMonoidWithOne R] [AddMonoid M] : AddMonoidWithOne (tsze R M) :=
  { TrivSqZeroExt.addMonoid, TrivSqZeroExt.one with
    natCast := fun n => inl n
    natCast_zero := by 

Proof state:
R : Type u
M : Type v
inst✝¹ : AddMonoidWithOne R
inst✝ : AddMonoid M
src✝¹ : AddMonoid (tsze R M) := addMonoid
src✝ : One (tsze R M) := one
⊢ NatCast.natCast 0 = 0

Next tactic:
simp [Nat.cast]
instance addMonoidWithOne [AddMonoidWithOne R] [AddMonoid M] : AddMonoidWithOne (tsze R M) :=
  { TrivSqZeroExt.addMonoid, TrivSqZeroExt.one with
    natCast := fun n => inl n
    natCast_zero := by simp [Nat.cast]
    natCast_succ := fun _ => by 

Proof state:
R : Type u
M : Type v
inst✝¹ : AddMonoidWithOne R
inst✝ : AddMonoid M
src✝¹ : AddMonoid (tsze R M) := addMonoid
src✝ : One (tsze R M) := one
x✝ : ℕ
⊢ NatCast.natCast (x✝ + 1) = NatCast.natCast x✝ + 1

Next tactic:
ext
instance addMonoidWithOne [AddMonoidWithOne R] [AddMonoid M] : AddMonoidWithOne (tsze R M) :=
  { TrivSqZeroExt.addMonoid, TrivSqZeroExt.one with
    natCast := fun n => inl n
    natCast_zero := by simp [Nat.cast]
    natCast_succ := fun _ => by ext <;> 

Proof state:
case h1
R : Type u
M : Type v
inst✝¹ : AddMonoidWithOne R
inst✝ : AddMonoid M
src✝¹ : AddMonoid (tsze R M) := addMonoid
src✝ : One (tsze R M) := one
x✝ : ℕ
⊢ fst (NatCast.natCast (x✝ + 1)) = fst (NatCast.natCast x✝ + 1)

Next tactic:
simp [Nat.cast]
instance addMonoidWithOne [AddMonoidWithOne R] [AddMonoid M] : AddMonoidWithOne (tsze R M) :=
  { TrivSqZeroExt.addMonoid, TrivSqZeroExt.one with
    natCast := fun n => inl n
    natCast_zero := by simp [Nat.cast]
    natCast_succ := fun _ => by ext <;> 

Proof state:
case h2
R : Type u
M : Type v
inst✝¹ : AddMonoidWithOne R
inst✝ : AddMonoid M
src✝¹ : AddMonoid (tsze R M) := addMonoid
src✝ : One (tsze R M) := one
x✝ : ℕ
⊢ snd (NatCast.natCast (x✝ + 1)) = snd (NatCast.natCast x✝ + 1)

Next tactic:
simp [Nat.cast]
instance nonAssocSemiring [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] :
    NonAssocSemiring (tsze R M) :=
  { TrivSqZeroExt.addMonoidWithOne, TrivSqZeroExt.mulOneClass, TrivSqZeroExt.addCommMonoid with
    zero_mul := fun x =>
      ext (zero_mul x.1) <|
        show (0 : R) • x.2 + op x.1 • (0 : M) = 0 by rw [zero_smul, zero_add, smul_zero]
    mul_zero := fun x =>
      ext (mul_zero x.1) <|
        show x.1 • (0 : M) + (0 : Rᵐᵒᵖ) • x.2 = 0 by rw [smul_zero, zero_add, zero_smul]
    left_distrib := fun x₁ x₂ x₃ =>
      ext (mul_add x₁.1 x₂.1 x₃.1) <|
        show
          x₁.1 • (x₂.2 + x₃.2) + (op x₂.1 + op x₃.1) • x₁.2 =
            x₁.1 • x₂.2 + op x₂.1 • x₁.2 + (x₁.1 • x₃.2 + op x₃.1 • x₁.2)
          by 

Proof state:
R : Type u
M : Type v
inst✝³ : Semiring R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Module Rᵐᵒᵖ M
src✝² : AddMonoidWithOne (tsze R M) := addMonoidWithOne
src✝¹ : MulOneClass (tsze R M) := mulOneClass
src✝ : AddCommMonoid (tsze R M) := addCommMonoid
x₁ x₂ x₃ : tsze R M
⊢ x₁.1 • (x₂.2 + x₃.2) + (op x₂.1 + op x₃.1) • x₁.2 = x₁.1 • x₂.2 + op x₂.1 • x₁.2 + (x₁.1 • x₃.2 + op x₃.1 • x₁.2)

Next tactic:
simp_rw [smul_add, add_smul, add_add_add_comm]
instance nonAssocSemiring [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] :
    NonAssocSemiring (tsze R M) :=
  { TrivSqZeroExt.addMonoidWithOne, TrivSqZeroExt.mulOneClass, TrivSqZeroExt.addCommMonoid with
    zero_mul := fun x =>
      ext (zero_mul x.1) <|
        show (0 : R) • x.2 + op x.1 • (0 : M) = 0 by rw [zero_smul, zero_add, smul_zero]
    mul_zero := fun x =>
      ext (mul_zero x.1) <|
        show x.1 • (0 : M) + (0 : Rᵐᵒᵖ) • x.2 = 0 by rw [smul_zero, zero_add, zero_smul]
    left_distrib := fun x₁ x₂ x₃ =>
      ext (mul_add x₁.1 x₂.1 x₃.1) <|
        show
          x₁.1 • (x₂.2 + x₃.2) + (op x₂.1 + op x₃.1) • x₁.2 =
            x₁.1 • x₂.2 + op x₂.1 • x₁.2 + (x₁.1 • x₃.2 + op x₃.1 • x₁.2)
          by simp_rw [smul_add, add_smul, add_add_add_comm]
    right_distrib := fun x₁ x₂ x₃ =>
      ext (add_mul x₁.1 x₂.1 x₃.1) <|
        show
          (x₁.1 + x₂.1) • x₃.2 + op x₃.1 • (x₁.2 + x₂.2) =
            x₁.1 • x₃.2 + op x₃.1 • x₁.2 + (x₂.1 • x₃.2 + op x₃.1 • x₂.2)
          by 

Proof state:
R : Type u
M : Type v
inst✝³ : Semiring R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Module Rᵐᵒᵖ M
src✝² : AddMonoidWithOne (tsze R M) := addMonoidWithOne
src✝¹ : MulOneClass (tsze R M) := mulOneClass
src✝ : AddCommMonoid (tsze R M) := addCommMonoid
x₁ x₂ x₃ : tsze R M
⊢ (x₁.1 + x₂.1) • x₃.2 + op x₃.1 • (x₁.2 + x₂.2) = x₁.1 • x₃.2 + op x₃.1 • x₁.2 + (x₂.1 • x₃.2 + op x₃.1 • x₂.2)

Next tactic:
simp_rw [add_smul, smul_add, add_add_add_comm]
instance nonAssocSemiring [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] :
    NonAssocSemiring (tsze R M) :=
  { TrivSqZeroExt.addMonoidWithOne, TrivSqZeroExt.mulOneClass, TrivSqZeroExt.addCommMonoid with
    zero_mul := fun x =>
      ext (zero_mul x.1) <|
        show (0 : R) • x.2 + op x.1 • (0 : M) = 0 by 

Proof state:
R : Type u
M : Type v
inst✝³ : Semiring R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Module Rᵐᵒᵖ M
src✝² : AddMonoidWithOne (tsze R M) := addMonoidWithOne
src✝¹ : MulOneClass (tsze R M) := mulOneClass
src✝ : AddCommMonoid (tsze R M) := addCommMonoid
x : tsze R M
⊢ 0 • x.2 + op x.1 • 0 = 0

Next tactic:
rw [zero_smul, zero_add, smul_zero]
instance nonAssocSemiring [Semiring R] [AddCommMonoid M] [Module R M] [Module Rᵐᵒᵖ M] :
    NonAssocSemiring (tsze R M) :=
  { TrivSqZeroExt.addMonoidWithOne, TrivSqZeroExt.mulOneClass, TrivSqZeroExt.addCommMonoid with
    zero_mul := fun x =>
      ext (zero_mul x.1) <|
        show (0 : R) • x.2 + op x.1 • (0 : M) = 0 by rw [zero_smul, zero_add, smul_zero]
    mul_zero := fun x =>
      ext (mul_zero x.1) <|
        show x.1 • (0 : M) + (0 : Rᵐᵒᵖ) • x.2 = 0 by 

Proof state:
R : Type u
M : Type v
inst✝³ : Semiring R
inst✝² : AddCommMonoid M
inst✝¹ : Module R M
inst✝ : Module Rᵐᵒᵖ M
src✝² : AddMonoidWithOne (tsze R M) := addMonoidWithOne
src✝¹ : MulOneClass (tsze R M) := mulOneClass
src✝ : AddCommMonoid (tsze R M) := addCommMonoid
x : tsze R M
⊢ x.1 • 0 + 0 • x.2 = 0

Next tactic:
rw [smul_zero, zero_add, zero_smul]
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  

Proof state:
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n : ℕ
h : op (fst x) • snd x = fst x • snd x
⊢ snd (x ^ n) = n • fst x ^ Nat.pred n • snd x

Next tactic:
have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    

Proof state:
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n : ℕ
h : op (fst x) • snd x = fst x • snd x
⊢ ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x

Next tactic:
intro n
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    

Proof state:
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
n : ℕ
⊢ op (fst x ^ n) • snd x = fst x ^ n • snd x

Next tactic:
induction' n with n ih
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · 

Proof state:
case zero
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n : ℕ
h : op (fst x) • snd x = fst x • snd x
⊢ op (fst x ^ Nat.zero) • snd x = fst x ^ Nat.zero • snd x

Next tactic:
simp
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · 

Proof state:
case succ
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
n : ℕ
ih : op (fst x ^ n) • snd x = fst x ^ n • snd x
⊢ op (fst x ^ Nat.succ n) • snd x = fst x ^ Nat.succ n • snd x

Next tactic:
rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  

Proof state:
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
⊢ snd (x ^ n) = n • fst x ^ Nat.pred n • snd x

Next tactic:
simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  

Proof state:
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
⊢ List.sum (List.map (fun i => fst x ^ (Nat.pred n - i + i) • snd x) (List.range n)) = n • fst x ^ Nat.pred n • snd x

Next tactic:
match n with
  | 0 => rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
  | (Nat.succ n) =>
    simp_rw [Nat.pred_succ]
    refine' (List.sum_eq_card_nsmul _ (x.fst ^ n • x.snd) _).trans _
    · rintro m hm
      simp_rw [List.mem_map, List.mem_range] at hm
      obtain ⟨i, hi, rfl⟩ := hm
      rw [tsub_add_cancel_of_le (Nat.lt_succ_iff.mp hi)]
    · rw [List.length_map, List.length_range]
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  match n with
  | 0 => 

Proof state:
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
⊢ List.sum (List.map (fun i => fst x ^ (Nat.pred 0 - i + i) • snd x) (List.range 0)) = 0 • fst x ^ Nat.pred 0 • snd x

Next tactic:
rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  match n with
  | 0 => rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
  | (Nat.succ n) =>
    

Proof state:
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
n : ℕ
⊢ List.sum (List.map (fun i => fst x ^ (Nat.pred (Nat.succ n) - i + i) • snd x) (List.range (Nat.succ n))) =
    Nat.succ n • fst x ^ Nat.pred (Nat.succ n) • snd x

Next tactic:
simp_rw [Nat.pred_succ]
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  match n with
  | 0 => rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
  | (Nat.succ n) =>
    simp_rw [Nat.pred_succ]
    

Proof state:
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
n : ℕ
⊢ List.sum (List.map (fun i => fst x ^ (n - i + i) • snd x) (List.range (Nat.succ n))) = Nat.succ n • fst x ^ n • snd x

Next tactic:
refine' (List.sum_eq_card_nsmul _ (x.fst ^ n • x.snd) _).trans _
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  match n with
  | 0 => rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
  | (Nat.succ n) =>
    simp_rw [Nat.pred_succ]
    refine' (List.sum_eq_card_nsmul _ (x.fst ^ n • x.snd) _).trans _
    · 

Proof state:
case refine'_1
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
n : ℕ
⊢ ∀ x_1 ∈ List.map (fun i => fst x ^ (n - i + i) • snd x) (List.range (Nat.succ n)), x_1 = fst x ^ n • snd x

Next tactic:
rintro m hm
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  match n with
  | 0 => rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
  | (Nat.succ n) =>
    simp_rw [Nat.pred_succ]
    refine' (List.sum_eq_card_nsmul _ (x.fst ^ n • x.snd) _).trans _
    · rintro m hm
      

Proof state:
case refine'_1
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
n : ℕ
m : M
hm : m ∈ List.map (fun i => fst x ^ (n - i + i) • snd x) (List.range (Nat.succ n))
⊢ m = fst x ^ n • snd x

Next tactic:
simp_rw [List.mem_map, List.mem_range] at hm
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  match n with
  | 0 => rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
  | (Nat.succ n) =>
    simp_rw [Nat.pred_succ]
    refine' (List.sum_eq_card_nsmul _ (x.fst ^ n • x.snd) _).trans _
    · rintro m hm
      simp_rw [List.mem_map, List.mem_range] at hm
      

Proof state:
case refine'_1
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
n : ℕ
m : M
hm : ∃ a < Nat.succ n, fst x ^ (n - a + a) • snd x = m
⊢ m = fst x ^ n • snd x

Next tactic:
obtain ⟨i, hi, rfl⟩ := hm
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  match n with
  | 0 => rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
  | (Nat.succ n) =>
    simp_rw [Nat.pred_succ]
    refine' (List.sum_eq_card_nsmul _ (x.fst ^ n • x.snd) _).trans _
    · rintro m hm
      simp_rw [List.mem_map, List.mem_range] at hm
      obtain ⟨i, hi, rfl⟩ := hm
      

Proof state:
case refine'_1.intro.intro
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
n i : ℕ
hi : i < Nat.succ n
⊢ fst x ^ (n - i + i) • snd x = fst x ^ n • snd x

Next tactic:
rw [tsub_add_cancel_of_le (Nat.lt_succ_iff.mp hi)]
theorem snd_pow_of_smul_comm [Monoid R] [AddMonoid M] [DistribMulAction R M]
    [DistribMulAction Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M] (x : tsze R M) (n : ℕ)
    (h : op x.fst • x.snd = x.fst • x.snd) : snd (x ^ n) = n • x.fst ^ n.pred • x.snd := by
  have : ∀ n : ℕ, op (x.fst ^ n) • x.snd = x.fst ^ n • x.snd := by
    intro n
    induction' n with n ih
    · simp
    · rw [pow_succ', MulOpposite.op_mul, mul_smul, mul_smul, ← h,
        smul_comm (_ : R) (op x.fst) x.snd, ih]
  simp_rw [snd_pow_eq_sum, this, smul_smul, ← pow_add]
  match n with
  | 0 => rw [Nat.pred_zero, pow_zero, List.range_zero, zero_smul, List.map_nil, List.sum_nil]
  | (Nat.succ n) =>
    simp_rw [Nat.pred_succ]
    refine' (List.sum_eq_card_nsmul _ (x.fst ^ n • x.snd) _).trans _
    · rintro m hm
      simp_rw [List.mem_map, List.mem_range] at hm
      obtain ⟨i, hi, rfl⟩ := hm
      rw [tsub_add_cancel_of_le (Nat.lt_succ_iff.mp hi)]
    · 

Proof state:
case refine'_2
R : Type u
M : Type v
inst✝⁴ : Monoid R
inst✝³ : AddMonoid M
inst✝² : DistribMulAction R M
inst✝¹ : DistribMulAction Rᵐᵒᵖ M
inst✝ : SMulCommClass R Rᵐᵒᵖ M
x : tsze R M
n✝ : ℕ
h : op (fst x) • snd x = fst x • snd x
this : ∀ (n : ℕ), op (fst x ^ n) • snd x = fst x ^ n • snd x
n : ℕ
⊢ List.length (List.map (fun i => fst x ^ (n - i + i) • snd x) (List.range (Nat.succ n))) • fst x ^ n • snd x =
    Nat.succ n • fst x ^ n • snd x

Next tactic:
rw [List.length_map, List.length_range]
@[simp]
theorem inl_pow [Monoid R] [AddMonoid M] [DistribMulAction R M] [DistribMulAction Rᵐᵒᵖ M] (r : R)
    (n : ℕ) : (inl r ^ n : tsze R M) = inl (r ^ n) :=
  ext rfl <| by 

Proof state:
R : Type u
M : Type v
inst✝³ : Monoid R
inst✝² : AddMonoid M
inst✝¹ : DistribMulAction R M
inst✝ : DistribMulAction Rᵐᵒᵖ M
r : R
n : ℕ
⊢ snd (inl r ^ n) = snd (inl (r ^ n))

Next tactic:
simp [snd_pow_eq_sum]