Commutative Rig
A commutative rig is a rig with identity, commutative with respect to multiplication.
The following laws must hold for a commutative rig:
- Additive closure (closure): for \(\forall x, y \in S\), \(x + y \in S\).
- Additive associativity (associativity): for \(\forall x, y, z \in S\), \((x + y) + z = x + (y + z)\).
- Existence of zero element: there exists \(\exists 0 \in S\) such that for \(\forall x \in S\), \(0 + x = x + 0 = x\)
- Additive commutativity (commutative): for \(\forall x, y \in S\), \(x + y = y + x\).
- Multiplicative closure (closure): for \(\forall x, y \in S\), \(x * y \in S\).
- Multiplicative associativity (associativity): for \(\forall x, y, z \in S\), \((x * y) * z = x * (y * z)\).
- Distributivity (distributivus, distributive law): for \(\forall x, y, z \in S\), \(x * (y + z) = x * y + x * z\) and \((x + y) * z = x * z + y * z\).
- Multiplicative zero property: \(a * 0 = 0 * a = 0\)
- Existence of unit element: \(\exists 1 \in S \quad \forall x \in S \quad x * 1 = 1 * x = x\)
- Multiplicative commutativity: for \(\forall x, y \in R\), \(x * y = y * x\).
Code
trait CommutativeRig[A] extends Rig[A] with CommutativeSemiring[A]
Diagram
classDiagram
class Semigroup~A~{
+combine(x: A, y: A) A
}
class Monoid~A~{
+empty() A
}
Semigroup <|-- Monoid
class CommutativeSemigroup~A~
Semigroup <|-- CommutativeSemigroup
class CommutativeMonoid~A~
Monoid <|-- CommutativeMonoid
CommutativeSemigroup <|-- CommutativeMonoid
class Semiring~A~
CommutativeMonoid <|-- Semiring
class MultiplicativeSemigroup~A~{
+times(x: A, y: A) A
}
MultiplicativeSemigroup <|-- Semiring
Semigroup .. MultiplicativeSemigroup
class Rig~A~{
+one() A
}
Semiring <|-- Rig
class CommutativeSemiring~A~
Semiring <|-- CommutativeSemiring
class CommutativeRig~A~
Rig <|-- CommutativeRig
CommutativeSemiring <|-- CommutativeRig
References: