@@ -651,6 +651,32 @@ end direct_sum
651
651
652
652
/-! ### Concrete instances -/
653
653
654
+ /-- A direct sum of copies of a `semiring` inherits the multiplication structure. -/
655
+ instance semiring.direct_sum_gmonoid {R : Type *} [add_monoid ι] [semiring R] :
656
+ direct_sum.gmonoid (λ i : ι, R) :=
657
+ { mul := λ i j, add_monoid_hom.mul,
658
+ one_mul := λ a, sigma.ext (zero_add _) (heq_of_eq (one_mul _)),
659
+ mul_one := λ a, sigma.ext (add_zero _) (heq_of_eq (mul_one _)),
660
+ mul_assoc := λ a b c, sigma.ext (add_assoc _ _ _) (heq_of_eq (mul_assoc _ _ _)),
661
+ one := 1 }
662
+
663
+ @[simp] lemma semiring.direct_sum_mul {R : Type *} [add_monoid ι] [semiring R] {i j} (x y : R) :
664
+ @direct_sum.ghas_mul.mul _ _ (λ _ : ι, R) _ _ _ i j x y = x * y := rfl
665
+
666
+ open_locale direct_sum
667
+
668
+ -- To check the lemma above does match
669
+ example {R : Type *} [add_monoid ι] [semiring R] (i j : ι) (a b : R) :
670
+ (direct_sum.of _ i a * direct_sum.of _ j b : ⨁ i, R) = direct_sum.of _ (i + j) (by exact a * b) :=
671
+ by rw [direct_sum.of_mul_of, semiring.direct_sum_mul]
672
+
673
+ /-- A direct sum of copies of a `comm_semiring` inherits the commutative multiplication structure.
674
+ -/
675
+ instance comm_semiring.direct_sum_gcomm_monoid {R : Type *} [add_comm_monoid ι] [comm_semiring R] :
676
+ direct_sum.gcomm_monoid (λ i : ι, R) :=
677
+ { mul_comm := λ a b, sigma.ext (add_comm _ _) (heq_of_eq (mul_comm _ _)),
678
+ .. semiring.direct_sum_gmonoid }
679
+
654
680
namespace submodule
655
681
656
682
variables {R A : Type *} [comm_semiring R]
0 commit comments