Semifield
A semifield is a rig in which every non-zero element has a multiplicative inverse.
The following laws must hold for a semifield:
- Closure under addition (closure): for \(\forall x, y \in S\), \(x + y \in S\).
- Associativity of addition (associativity): for \(\forall x, y, z \in S\), \((x + y) + z = x + (y + z)\).
- Existence of a zero element: there exists \(\exists 0 \in S\) such that for \(\forall x \in S\), \(0 + x = x + 0 = x\).
- Commutativity of addition (commutative): for \(\forall x, y \in S\), \(x + y = y + x\).
- Closure under multiplication (closure): for \(\forall x, y \in S\), \(x * y \in S\).
- Associativity of multiplication (associativity): for \(\forall x, y, z \in S\), \((x * y) * z = x * (y * z)\).
- Distributivity (distributivity): 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 a multiplicative identity: \(\exists 1 \in S \quad \forall x \in S \quad x * 1 = 1 * x = x\).
- Existence of an inverse element: for any \(a \in F\), \(a \neq 0\), there exists an element \(a^{-1} \in F\) such that \(a \cdot a^{-1} = 1\).
Code
trait Semifield[A] extends Rig[A]:
extension (a: A)
def reciprocal: A
def div(x: A, y: A): A = times(x, y.reciprocal)
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 Semifield~A~{
+reciprocal(x: A) A
+div(x: A, y: A) A
}
Rig <|-- Semifield
References: