Commutative Ring Without Identity
A commutative ring is a ring without identity, commutative with respect to multiplication.
A commutative ring must satisfy all the laws of a ring:
- Additive closure (closure): for \(\forall x, y \in R\), \(x + y \in R\).
- Additive associativity (associativity): for \(\forall x, y, z \in R\), \((x + y) + z = x + (y + z)\).
- Existence of zero element: there exists \(\exists 0 \in R\) such that for \(\forall x \in R\), \(0 + x = x + 0 = x\)
- Additive invertibility: for \(\forall x \in R\) there exists \((-x)\) such that \(x + (-x) = (-x) + x = 0\)
- Additive commutativity (commutative): for \(\forall x, y \in R\), \(x + y = y + x\).
- Multiplicative closure (closure): for \(\forall x, y \in R\), \(x * y \in R\).
- Multiplicative associativity (associativity): for \(\forall x, y, z \in R\), \((x * y) * z = x * (y * z)\).
- Distributivity (distributivus, distributive law): for \(\forall x, y, z \in R\), \(x * (y + z) = x * y + x * z\) and \((x + y) * z = x * z + y * z\).
as well as the law of multiplicative commutativity:
- Multiplicative commutativity: for \(\forall x, y \in R\), \(x * y = y * x\).
Code
trait CommutativeRng[A] extends Rng[A], CSemiring[A]
Laws
Laws are inherited from the laws of a ring and a commutative semiring.
Diagram
classDiagram
class Semigroup~A~{
+combine(x: A, y: A) A
}
class Monoid~A~{
+empty() A
}
Semigroup <|-- Monoid
class CommutativeSemigroup~A~
Semigroup <|-- CommutativeSemigroup
class Group~A~{
+inverse(x: A) A
}
Monoid <|-- Group
class CommutativeMonoid~A~
Monoid <|-- CommutativeMonoid
CommutativeSemigroup <|-- CommutativeMonoid
class AbelianGroup~A~
Group <|-- AbelianGroup
CommutativeMonoid <|-- AbelianGroup
class Semiring~A~
CommutativeMonoid <|-- Semiring
class MultiplicativeSemigroup~A~{
+times(x: A, y: A) A
}
MultiplicativeSemigroup <|-- Semiring
Semigroup .. MultiplicativeSemigroup
class Rng~A~
AbelianGroup <|-- Rng
Semiring <|-- Rng
class CommutativeSemiring~A~
Semiring <|-- CommutativeSemiring
class CommutativeRng~A~
Rng <|-- CommutativeRng
CommutativeSemiring <|-- CommutativeRng
Implementation in Libraries
Implementation in Spire
CRing[A] provides commutative +, zero, -, commutative *, and one.
CRing[A] extends Ring[A] and MultiplicativeCMonoid[A].
import spire.algebra.CRing
import spire.math.Rational
CRing.plus(Rational(1, 2), Rational(1, 3))
// val res0: spire.math.Rational = 5/6
CRing.times(Rational(1, 2), Rational(1, 3))
// val res1: spire.math.Rational = 1/6
CRing.pow(Rational(1, 2), 3)
// val res2: spire.math.Rational = 1/8
CRing.negate(Rational(1, 2))
// val res3: spire.math.Rational = -1/2
CRing.minus(Rational(1, 2), Rational(1, 3))
// val res4: spire.math.Rational = 1/6
CRing.zero[Rational]
// val res5: spire.math.Rational = 0
CRing.one[Rational]
// val res6: spire.math.Rational = 1
References: