|
| 1 | +/- |
| 2 | +Copyright (c) 2020 Yury Kudryashov. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Johannes Hölzl, Chris Hughes, Mario Carneiro, Yury Kudryashov |
| 5 | +-/ |
| 6 | +import algebra.group.prod |
| 7 | +import algebra.ring |
| 8 | + |
| 9 | +/-! |
| 10 | +# Semiring, ring etc structures on `R × S` |
| 11 | +
|
| 12 | +In this file we define two-binop (`semiring`, `ring` etc) structures on `R × S`. We also prove |
| 13 | +trivial `simp` lemmas, and define the following operations on `ring_hom`s: |
| 14 | +
|
| 15 | +* `fst R S : R × S →+* R`, `snd R S : R × S →+* R`: projections `prod.fst` and `prod.snd` |
| 16 | + as `ring_hom`s; |
| 17 | +* `f.prod g : `R →+* S × T`: sends `x` to `(f x, g x)`; |
| 18 | +* `f.prod_map g : `R × S → R' × S'`: `prod.map f g` as a `ring_hom`, |
| 19 | + sends `(x, y)` to `(f x, g y)`. |
| 20 | +-/ |
| 21 | + |
| 22 | +variables {R : Type*} {R' : Type*} {S : Type*} {S' : Type*} {T : Type*} {T' : Type*} |
| 23 | + |
| 24 | +namespace prod |
| 25 | + |
| 26 | +/-- Product of two semirings is a semiring. -/ |
| 27 | +instance [semiring R] [semiring S] : semiring (R × S) := |
| 28 | +{ zero_mul := λ a, mk.inj_iff.mpr ⟨zero_mul _, zero_mul _⟩, |
| 29 | + mul_zero := λ a, mk.inj_iff.mpr ⟨mul_zero _, mul_zero _⟩, |
| 30 | + left_distrib := λ a b c, mk.inj_iff.mpr ⟨left_distrib _ _ _, left_distrib _ _ _⟩, |
| 31 | + right_distrib := λ a b c, mk.inj_iff.mpr ⟨right_distrib _ _ _, right_distrib _ _ _⟩, |
| 32 | + .. prod.add_comm_monoid, .. prod.monoid } |
| 33 | + |
| 34 | +/-- Product of two commutative semirings is a commutative semiring. -/ |
| 35 | +instance [comm_semiring R] [comm_semiring S] : comm_semiring (R × S) := |
| 36 | +{ .. prod.semiring, .. prod.comm_monoid } |
| 37 | + |
| 38 | +/-- Product of two rings is a ring. -/ |
| 39 | +instance [ring R] [ring S] : ring (R × S) := |
| 40 | +{ .. prod.add_comm_group, .. prod.semiring } |
| 41 | + |
| 42 | +/-- Product of two commutative rings is a commutative ring. -/ |
| 43 | +instance [comm_ring R] [comm_ring S] : comm_ring (R × S) := |
| 44 | +{ .. prod.ring, .. prod.comm_monoid } |
| 45 | + |
| 46 | +/-- Product of two commutative rings is a nonzero commutative ring provided that the first |
| 47 | +ring is a nonzero ring. -/ |
| 48 | +instance [nonzero_comm_ring R] [comm_ring S] : nonzero_comm_ring (R × S) := |
| 49 | +{ zero_ne_one := mt (congr_arg prod.fst) zero_ne_one, |
| 50 | + .. prod.comm_ring } |
| 51 | + |
| 52 | +end prod |
| 53 | + |
| 54 | +namespace ring_hom |
| 55 | + |
| 56 | +variables (R S) [semiring R] [semiring S] |
| 57 | + |
| 58 | +/-- Given semirings `R`, `S`, the natural projection homomorphism from `R × S` to `R`.-/ |
| 59 | +def fst : R × S →+* R := { to_fun := prod.fst, .. monoid_hom.fst R S, .. add_monoid_hom.fst R S } |
| 60 | + |
| 61 | +/-- Given semirings `R`, `S`, the natural projection homomorphism from `R × S` to `S`.-/ |
| 62 | +def snd : R × S →+* S := { to_fun := prod.snd, .. monoid_hom.snd R S, .. add_monoid_hom.snd R S } |
| 63 | + |
| 64 | +variables {R S} |
| 65 | + |
| 66 | +@[simp] lemma coe_fst : ⇑(fst R S) = prod.fst := rfl |
| 67 | +@[simp] lemma coe_snd : ⇑(snd R S) = prod.snd := rfl |
| 68 | + |
| 69 | +section prod |
| 70 | + |
| 71 | +variables [semiring T] (f : R →+* S) (g : R →+* T) |
| 72 | + |
| 73 | +/-- Combine two ring homomorphisms `f : R →+* S`, `g : R →+* T` into `f.prod g : R →+* S × T` |
| 74 | +given by `(f.prod g) x = (f x, g x)` -/ |
| 75 | +protected def prod (f : R →+* S) (g : R →+* T) : R →+* S × T := |
| 76 | +{ to_fun := λ x, (f x, g x), |
| 77 | + .. monoid_hom.prod (f : R →* S) (g : R →* T), .. add_monoid_hom.prod (f : R →+ S) (g : R →+ T) } |
| 78 | + |
| 79 | +@[simp] lemma prod_apply (x) : f.prod g x = (f x, g x) := rfl |
| 80 | + |
| 81 | +@[simp] lemma fst_comp_prod : (fst S T).comp (f.prod g) = f := |
| 82 | +ext $ λ x, rfl |
| 83 | + |
| 84 | +@[simp] lemma snd_comp_prod : (snd S T).comp (f.prod g) = g := |
| 85 | +ext $ λ x, rfl |
| 86 | + |
| 87 | +lemma prod_unique (f : R →+* S × T) : |
| 88 | + ((fst S T).comp f).prod ((snd S T).comp f) = f := |
| 89 | +ext $ λ x, by simp only [prod_apply, coe_fst, coe_snd, comp_apply, prod.mk.eta] |
| 90 | + |
| 91 | +end prod |
| 92 | + |
| 93 | +section prod_map |
| 94 | + |
| 95 | +variables [semiring R'] [semiring S'] [semiring T] (f : R →+* R') (g : S →+* S') |
| 96 | + |
| 97 | +/-- `prod.map` as a `ring_hom`. -/ |
| 98 | +def prod_map : R × S →* R' × S' := (f.comp (fst R S)).prod (g.comp (snd R S)) |
| 99 | + |
| 100 | +lemma prod_map_def : prod_map f g = (f.comp (fst R S)).prod (g.comp (snd R S)) := rfl |
| 101 | + |
| 102 | +@[simp] |
| 103 | +lemma coe_prod_map : ⇑(prod_map f g) = prod.map f g := rfl |
| 104 | + |
| 105 | +lemma prod_comp_prod_map (f : T →* R) (g : T →* S) (f' : R →* R') (g' : S →* S') : |
| 106 | + (f'.prod_map g').comp (f.prod g) = (f'.comp f).prod (g'.comp g) := |
| 107 | +rfl |
| 108 | + |
| 109 | +end prod_map |
| 110 | + |
| 111 | +end ring_hom |
0 commit comments