open import Algebra.Group.Ab open import Algebra.Prelude open import Algebra.Group module Algebra.Ring.Base where
Ringsπ
The ring is one of the basic objects of study in algebra, which abstracts the best bits of the common algebraic structures: The integers , the rationals , the reals , and the complex numbers are all rings, as are the collections of polynomials with coefficients in any of those. Less familiar examples of rings include square matrices (with values in a ring) and the integral cohomology ring of a topological space: that these are so far from being βnumber-likeβ indicates the incredible generality of rings.
A ring is an abelian group , together with a distinguished point to be called the multiplicative unit, and a multiplication homomorphism , such that has as a left/right unit, and it is associative. That is: A ring is a monoid, but described βon an abelian groupβ rather than βon a setβ
record Ring β : Type (lsuc β) where no-eta-equality field group : AbGroup β
field 1R : R *-hom : Ab.Hom (group β group) group
The fact that _*_ is defined as a map out of the tensor product abelian group means that it is a bilinear map β meaning that multiplication and addition satisfy a distributivity equality, which is familiar from our example of before: . Since rings are not necessarily commutative, we note that the symmetric equation holds as well: .
_*_ : R β R β R x * y = *-hom .fst (x :, y) field *-idl : β {x} β 1R * x β‘ x *-idr : β {x} β x * 1R β‘ x *-assoc : β {x y z} β (x * y) * z β‘ x * (y * z) *-distribl : β {x y z} β x * (y + z) β‘ (x * y) + (x * z) *-distribl {x} {y} {z} = x * (y + z) β‘β¨β© *-hom .fst (x :, (y + z)) β‘β¨ ap (*-hom .fst) (sym t-fixl) β©β‘ *-hom .fst ((x :, y) :+ (x :, z)) β‘β¨ *-hom .snd .Group-hom.pres-β _ _ β©β‘ (x * y) + (x * z) β *-distribr : β {x y z} β (y + z) * x β‘ (y * x) + (z * x) *-distribr {x} {y} {z} = (y + z) * x β‘β¨β© *-hom .fst ((y + z) :, x) β‘β¨ ap (*-hom .fst) (sym t-fixr) β©β‘ *-hom .fst ((y :, x) :+ (z :, x)) β‘β¨ *-hom .snd .Group-hom.pres-β _ _ β©β‘ (y * x) + (z * x) β
The elementary descriptionπ
We give a more elementary description of rings, which is suitable for constructing values of the record type Ring above. This re-expresses the data included in the definition of a ring with the least amount of redundancy possible, in the most direct terms possible: A ring is a set, equipped with two binary operations and , such that distributes over on either side; is an abelian group; and is a monoid.
record make-ring {β} (R : Type β) : Type β where no-eta-equality field ring-is-set : is-set R -- R is an abelian group: 0R : R _+_ : R β R β R -_ : R β R +-idl : β {x} β 0R + x β‘ x +-invr : β {x} β x + (- x) β‘ 0R +-assoc : β {x y z} β (x + y) + z β‘ x + (y + z) +-comm : β {x y} β x + y β‘ y + x -- R is a monoid: 1R : R _*_ : R β R β R *-idl : β {x} β 1R * x β‘ x *-idr : β {x} β x * 1R β‘ x *-assoc : β {x y z} β (x * y) * z β‘ x * (y * z) -- Multiplication is bilinear: *-distribl : β {x y z} β x * (y + z) β‘ (x * y) + (x * z) *-distribr : β {x y z} β (y + z) * x β‘ (y * x) + (z * x)
This data is missing (by design, actually!) one condition which we would expect: . We exploit this to give our first example of a ring, the zero ring, which has carrier set the unit β the type with one object.
Despite the name, the zero ring is not the zero object in the category of rings: it is the terminal object. In the category of rings, the initial object is the ring , which is very far (infinitely far!) from having a single element. Itβs called the βzero ringβ because it has one element , which must be the additive identity, hence we call it . But itβs also the multiplicative identity, so we might also call the ring the One Ring, which would be objectively cooler.
Zero-ring : Ring lzero Zero-ring = from-make-ring {R = β€} $ record { ring-is-set = Ξ» _ _ _ _ _ _ β tt ; 0R = tt ; _+_ = Ξ» _ _ β tt ; -_ = Ξ» _ β tt ; +-idl = Ξ» _ β tt ; +-invr = Ξ» _ β tt ; +-assoc = Ξ» _ β tt ; +-comm = Ξ» _ β tt ; 1R = tt ; _*_ = Ξ» _ _ β tt ; *-idl = Ξ» _ β tt ; *-idr = Ξ» _ β tt ; *-assoc = Ξ» _ β tt ; *-distribl = Ξ» _ β tt ; *-distribr = Ξ» _ β tt }
Ring homomorphismsπ
There is a natural notion of ring homomorphism, which we get by smashing together that of monoid homomorphism (for the multiplicative part) and of group homomorphism; Every map of rings has an underlying map of groups which preserves the addition operation, and it must also preserve the multiplication.
record Ring-hom {β} (R S : Ring β) : Type β where no-eta-equality private module R = Ring R module S = Ring S field map : R.R β S.R pres-* : β x y β map (x R.* y) β‘ map x S.* map y pres-+ : β x y β map (x R.+ y) β‘ map x S.+ map y pres-1 : map R.1R β‘ S.1R group-hom : Ab.Hom R.group S.group group-hom = map , record { pres-β = pres-+ } open Group-hom (group-hom .snd) hiding (pres-β) renaming ( pres-id to pres-0 ; pres-inv to pres-neg ; pres-diff to pres-sub ) public open Ring-hom
It follows, by standard equational nonsense, that rings and ring homomorphisms form a precategory β for instance, we have .
Rings : β β β Precategory (lsuc β) β