@@ -189,13 +189,12 @@ def mulHom : (⨁ i, A i) →+ (⨁ i, A i) →+ ⨁ i, A i :=
189189instance instMul : Mul (⨁ i, A i) where
190190 mul := fun a b => mulHom A a b
191191
192- instance : NonUnitalNonAssocSemiring (⨁ i, A i) :=
193- { (inferInstance : AddCommMonoid _) with
194- zero_mul := fun _ => by simp only [Mul.mul, HMul.hMul, map_zero, AddMonoidHom.zero_apply]
195- mul_zero := fun _ => by simp only [Mul.mul, HMul.hMul, map_zero]
196- left_distrib := fun _ _ _ => by simp only [Mul.mul, HMul.hMul, map_add]
197- right_distrib := fun _ _ _ => by
198- simp only [Mul.mul, HMul.hMul, map_add, AddMonoidHom.add_apply] }
192+ instance : NonUnitalNonAssocSemiring (⨁ i, A i) where
193+ zero_mul := fun _ => by simp only [Mul.mul, HMul.hMul, map_zero, AddMonoidHom.zero_apply]
194+ mul_zero := fun _ => by simp only [Mul.mul, HMul.hMul, map_zero]
195+ left_distrib := fun _ _ _ => by simp only [Mul.mul, HMul.hMul, map_add]
196+ right_distrib := fun _ _ _ => by
197+ simp only [Mul.mul, HMul.hMul, map_add, AddMonoidHom.add_apply]
199198
200199variable {A}
201200
@@ -217,23 +216,20 @@ variable [∀ i, AddCommMonoid (A i)] [AddMonoid ι] [GSemiring A]
217216
218217open AddMonoidHom (flipHom coe_comp compHom flip_apply)
219218
220- set_option backward.privateInPublic true in
221219private nonrec theorem one_mul (x : ⨁ i, A i) : 1 * x = x := by
222220 suffices mulHom A One.one = AddMonoidHom.id (⨁ i, A i) from DFunLike.congr_fun this x
223221 apply addHom_ext; intro i xi
224222 simp only [One.one]
225223 rw [mulHom_of_of]
226224 exact of_eq_of_gradedMonoid_eq (one_mul <| GradedMonoid.mk i xi)
227225
228- set_option backward.privateInPublic true in
229226private nonrec theorem mul_one (x : ⨁ i, A i) : x * 1 = x := by
230227 suffices (mulHom A).flip One.one = AddMonoidHom.id (⨁ i, A i) from DFunLike.congr_fun this x
231228 apply addHom_ext; intro i xi
232229 simp only [One.one]
233230 rw [flip_apply, mulHom_of_of]
234231 exact of_eq_of_gradedMonoid_eq (mul_one <| GradedMonoid.mk i xi)
235232
236- set_option backward.privateInPublic true in
237233private theorem mul_assoc (a b c : ⨁ i, A i) : a * b * c = a * (b * c) := by
238234 -- (`fun a b c => a * b * c` as a bundled hom) = (`fun a b c => a * (b * c)` as a bundled hom)
239235 suffices AddMonoidHom.mulLeft₃ = AddMonoidHom.mulRight₃ by
@@ -248,20 +244,17 @@ private theorem mul_assoc (a b c : ⨁ i, A i) : a * b * c = a * (b * c) := by
248244instance instNatCast : NatCast (⨁ i, A i) where
249245 natCast := fun n => of _ _ (GSemiring.natCast n)
250246
251- set_option backward.privateInPublic true in
252- set_option backward.privateInPublic.warn false in
253247/-- The `Semiring` structure derived from `GSemiring A`. -/
254- instance semiring : Semiring (⨁ i, A i) :=
255- { (inferInstance : NonUnitalNonAssocSemiring _) with
256- one_mul := one_mul A
257- mul_one := mul_one A
258- mul_assoc := mul_assoc A
259- toNatCast := instNatCast _
260- natCast_zero := by simp only [NatCast.natCast, GSemiring.natCast_zero, map_zero]
261- natCast_succ := fun n => by
262- simp_rw [NatCast.natCast, GSemiring.natCast_succ]
263- rw [map_add]
264- rfl }
248+ instance semiring : Semiring (⨁ i, A i) where
249+ one_mul := private one_mul A
250+ mul_one := private mul_one A
251+ mul_assoc := private mul_assoc A
252+ toNatCast := instNatCast _
253+ natCast_zero := by simp only [NatCast.natCast, GSemiring.natCast_zero, map_zero]
254+ natCast_succ := fun n => by
255+ simp_rw [NatCast.natCast, GSemiring.natCast_succ]
256+ rw [map_add]
257+ rfl
265258
266259theorem ofPow {i} (a : A i) (n : ℕ) :
267260 of _ i a ^ n = of _ (n • i) (GradedMonoid.GMonoid.gnpow _ a) := by
@@ -297,10 +290,8 @@ theorem mul_eq_dfinsuppSum [∀ (i : ι) (x : A i), Decidable (x ≠ 0)] (a a' :
297290 dsimp only [DirectSum]
298291 rw [DFinsupp.sumAddHom_apply, AddMonoidHom.dfinsuppSum_apply]
299292 apply congrArg _
300- simp_rw [flip_apply]
301293 funext x
302- simp [AddMonoidHom.dfinsuppSum_apply, DFinsupp.sumAddHom_apply, DirectSum.gMulHom,
303- DirectSum.toAddMonoid]
294+ simp [AddMonoidHom.dfinsuppSum_apply, DFinsupp.sumAddHom_apply, DirectSum.toAddMonoid]
304295
305296/-- A heavily unfolded version of the definition of multiplication -/
306297theorem mul_eq_sum_support_ghas_mul [∀ (i : ι) (x : A i), Decidable (x ≠ 0 )] (a a' : ⨁ i, A i) :
@@ -315,20 +306,16 @@ section CommSemiring
315306
316307variable [∀ i, AddCommMonoid (A i)] [AddCommMonoid ι] [GCommSemiring A]
317308
318- set_option backward.privateInPublic true in
319309private theorem mul_comm (a b : ⨁ i, A i) : a * b = b * a := by
320310 suffices mulHom A = (mulHom A).flip by
321311 rw [← mulHom_apply, this, AddMonoidHom.flip_apply, mulHom_apply]
322312 apply addHom_ext; intro ai ax; apply addHom_ext; intro bi bx
323313 rw [AddMonoidHom.flip_apply, mulHom_of_of, mulHom_of_of]
324314 exact of_eq_of_gradedMonoid_eq (GCommSemiring.mul_comm ⟨ai, ax⟩ ⟨bi, bx⟩)
325315
326- set_option backward.privateInPublic true in
327- set_option backward.privateInPublic.warn false in
328316/-- The `CommSemiring` structure derived from `GCommSemiring A`. -/
329- instance commSemiring : CommSemiring (⨁ i, A i) :=
330- { DirectSum.semiring A with
331- mul_comm := mul_comm A }
317+ instance commSemiring : CommSemiring (⨁ i, A i) where
318+ mul_comm := private mul_comm A
332319
333320end CommSemiring
334321
@@ -337,9 +324,7 @@ section NonUnitalNonAssocRing
337324variable [∀ i, AddCommGroup (A i)] [Add ι] [GNonUnitalNonAssocSemiring A]
338325
339326/-- The `Ring` derived from `GSemiring A`. -/
340- instance nonAssocRing : NonUnitalNonAssocRing (⨁ i, A i) :=
341- { (inferInstance : NonUnitalNonAssocSemiring (⨁ i, A i)),
342- (inferInstance : AddCommGroup (⨁ i, A i)) with }
327+ instance nonAssocRing : NonUnitalNonAssocRing (⨁ i, A i) where
343328
344329end NonUnitalNonAssocRing
345330
@@ -349,13 +334,11 @@ variable [∀ i, AddCommGroup (A i)] [AddMonoid ι] [GRing A]
349334
350335-- Porting note: overspecified fields in ml4
351336/-- The `Ring` derived from `GSemiring A`. -/
352- instance ring : Ring (⨁ i, A i) :=
353- { DirectSum.semiring A,
354- (inferInstance : AddCommGroup (⨁ i, A i)) with
355- toIntCast.intCast := fun z => of A 0 <| (GRing.intCast z)
356- intCast_ofNat := fun _ => congrArg (of A 0 ) <| GRing.intCast_ofNat _
357- intCast_negSucc := fun _ =>
358- (congrArg (of A 0 ) <| GRing.intCast_negSucc_ofNat _).trans <| map_neg _ _ }
337+ instance ring : Ring (⨁ i, A i) where
338+ toIntCast.intCast z := of A 0 <| (GRing.intCast z)
339+ intCast_ofNat _ := congrArg (of A 0 ) <| GRing.intCast_ofNat _
340+ intCast_negSucc _ :=
341+ (congrArg (of A 0 ) <| GRing.intCast_negSucc_ofNat _).trans <| map_neg _ _
359342
360343end Ring
361344
@@ -364,9 +347,7 @@ section CommRing
364347variable [∀ i, AddCommGroup (A i)] [AddCommMonoid ι] [GCommRing A]
365348
366349/-- The `CommRing` derived from `GCommSemiring A`. -/
367- instance commRing : CommRing (⨁ i, A i) :=
368- { DirectSum.ring A,
369- DirectSum.commSemiring A with }
350+ instance commRing : CommRing (⨁ i, A i) where
370351
371352end CommRing
372353
@@ -610,26 +591,22 @@ variable (ι)
610591/-- A direct sum of copies of a `NonUnitalNonAssocSemiring` inherits the multiplication structure.
611592-/
612593instance NonUnitalNonAssocSemiring.directSumGNonUnitalNonAssocSemiring {R : Type *} [AddMonoid ι]
613- [NonUnitalNonAssocSemiring R] : DirectSum.GNonUnitalNonAssocSemiring fun _ : ι => R :=
614- { -- Porting note: removed Mul.gMul ι with and we seem ok
615- mul_zero := mul_zero
616- zero_mul := zero_mul
617- mul_add := mul_add
618- add_mul := add_mul }
594+ [NonUnitalNonAssocSemiring R] : DirectSum.GNonUnitalNonAssocSemiring fun _ : ι => R where
595+ mul_zero := mul_zero
596+ zero_mul := zero_mul
597+ mul_add := mul_add
598+ add_mul := add_mul
619599
620600/-- A direct sum of copies of a `Semiring` inherits the multiplication structure. -/
621601instance Semiring.directSumGSemiring {R : Type *} [AddMonoid ι] [Semiring R] :
622602 DirectSum.GSemiring fun _ : ι => R where
623- __ := NonUnitalNonAssocSemiring.directSumGNonUnitalNonAssocSemiring ι
624- __ := Monoid.gMonoid ι
625603 natCast n := n
626604 natCast_zero := Nat.cast_zero
627605 natCast_succ := Nat.cast_succ
628606
629607/-- A direct sum of copies of a `Ring` inherits the multiplication structure. -/
630608instance Ring.directSumGRing {R : Type *} [AddMonoid ι] [Ring R] :
631609 DirectSum.GRing fun _ : ι => R where
632- __ := Semiring.directSumGSemiring ι
633610 intCast z := z
634611 intCast_ofNat := Int.cast_natCast
635612 intCast_negSucc_ofNat := Int.cast_negSucc
@@ -644,13 +621,9 @@ example {R : Type*} [AddMonoid ι] [Semiring R] (i j : ι) (a b : R) :
644621/-- A direct sum of copies of a `CommSemiring` inherits the commutative multiplication structure. -/
645622instance CommSemiring.directSumGCommSemiring {R : Type *} [AddCommMonoid ι] [CommSemiring R] :
646623 DirectSum.GCommSemiring fun _ : ι => R where
647- __ := Semiring.directSumGSemiring ι
648- __ := CommMonoid.gCommMonoid ι
649624
650625/-- A direct sum of copies of a `CommRing` inherits the commutative multiplication structure. -/
651626instance CommRing.directSumGCommRing {R : Type *} [AddCommMonoid ι] [CommRing R] :
652627 DirectSum.GCommRing fun _ : ι => R where
653- __ := Ring.directSumGRing ι
654- __ := CommMonoid.gCommMonoid ι
655628
656629end Uniform
0 commit comments