Skip to content

Commit c9f1361

Browse files
author
Amelia Livingston
committed
perf(LinearAlgebra.TensorProduct.Basic): add TensorProduct.addMonoid (#11505)
We define `TensorProduct.addCommMonoid` in terms of `TensorProduct.addMonoid` to reduce unfolding.
1 parent 75784e0 commit c9f1361

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Mathlib/LinearAlgebra/TensorProduct/Basic.lean

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,18 @@ protected theorem add_smul (r s : R'') (x : M ⊗[R] N) : (r + s) • x = r •
333333
rw [ihx, ihy, add_add_add_comm]
334334
#align tensor_product.add_smul TensorProduct.add_smul
335335

336+
instance addMonoid : AddMonoid (M ⊗[R] N) :=
337+
{ TensorProduct.addZeroClass _ _ with
338+
toAddSemigroup := TensorProduct.addSemigroup _ _
339+
toZero := (TensorProduct.addZeroClass _ _).toZero
340+
nsmul := fun n v => n • v
341+
nsmul_zero := by simp [TensorProduct.zero_smul]
342+
nsmul_succ := by simp only [TensorProduct.one_smul, TensorProduct.add_smul, add_comm,
343+
forall_const] }
344+
336345
instance addCommMonoid : AddCommMonoid (M ⊗[R] N) :=
337-
{ TensorProduct.addCommSemigroup _ _,
338-
TensorProduct.addZeroClass _ _ with
339-
toAddSemigroup := TensorProduct.addSemigroup _ _
340-
toZero := (TensorProduct.addZeroClass _ _).toZero
341-
nsmul := fun n v => n • v
342-
nsmul_zero := by simp [TensorProduct.zero_smul]
343-
nsmul_succ := by simp only [TensorProduct.one_smul, TensorProduct.add_smul, add_comm,
344-
forall_const] }
346+
{ TensorProduct.addCommSemigroup _ _ with
347+
toAddMonoid := TensorProduct.addMonoid }
345348

346349
instance leftDistribMulAction : DistribMulAction R' (M ⊗[R] N) :=
347350
have : ∀ (r : R') (m : M) (n : N), r • m ⊗ₜ[R] n = (r • m) ⊗ₜ n := fun _ _ _ => rfl

0 commit comments

Comments
 (0)