| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
NumHask.Algebra.Ring
Description
Ring classes
Synopsis
- type Distributive a = (Additive a, Multiplicative a)
- type Ring a = (Distributive a, Subtractive a)
- class Distributive a => StarSemiring a where
- class (StarSemiring a, Idempotent a) => KleeneAlgebra a
- class Distributive a => InvolutiveRing a where
- adj :: a -> a
- two :: (Multiplicative a, Additive a) => a
Documentation
type Distributive a = (Additive a, Multiplicative a) Source #
\a b c -> a * (b + c) == a * b + a * c
\a b c -> (a + b) * c == a * c + b * c
\a -> zero * a == zero
\a -> a * zero == zero
The sneaking in of the Absorption laws here glosses over the possibility that the multiplicative zero element does not have to correspond with the additive unital zero.
type Ring a = (Distributive a, Subtractive a) Source #
A Ring is an abelian group under addition (Unital, Associative, Commutative, Invertible) and monoidal under multiplication (Unital, Associative), and where multiplication distributes over addition.
\a -> zero + a == a \a -> a + zero == a \a b c -> (a + b) + c == a + (b + c) \a b -> a + b == b + a \a -> a - a == zero \a -> negate a == zero - a \a -> negate a + a == zero \a -> a + negate a == zero \a -> one * a == a \a -> a * one == a \a b c -> (a * b) * c == a * (b * c) \a b c -> a * (b + c) == a * b + a * c \a b c -> (a + b) * c == a * c + b * c \a -> zero * a == zero \a -> a * zero == zero
class Distributive a => StarSemiring a where Source #
A StarSemiring is a semiring with a unary star operator satisfying the Conway equations:
\a -> star a == one + a * star a -- fixpoint \a b -> star (a * b) == one + a * star (b * a) * b -- product-star (sliding) \a b -> star (a + b) == star (star a * b) * star a -- sum-star (vanishing)
These three equations are the doctestable core; they are exactly the sliding and vanishing axioms of a traced category in semiring clothing.
Instances
| StarSemiring Bool Source # | |
| StarSemiring (MinPlus Double) Source # | Star is zero in a min-plus semiring: the cheapest repeated traversal is to stay put.
Conway equations for 'MinPlus Double'.
|
| StarSemiring a => StarSemiring (Wrapped a) Source # | |
class (StarSemiring a, Idempotent a) => KleeneAlgebra a Source #
A Kleene Algebra is a Star Semiring with idempotent addition.
Idempotent addition gives a natural order a <= b ⟺ a + b == b. In that order, Kozen's induction laws hold as derived facts:
a * x + x <= x ==> star a * x + x <= x x * a + x <= x ==> x * star a + x <= x
They are stated here as prose rather than class laws because they involve a partial order and Horn clauses, which do not fit the equational/doctest style of the Conway core.
Instances
| KleeneAlgebra Bool Source # | |
Defined in NumHask.Algebra.Ring | |
| KleeneAlgebra (MinPlus Double) Source # | |
Defined in NumHask.Algebra.Tropical | |
class Distributive a => InvolutiveRing a where Source #
Conway equations for Bool.
>>>let a = False; b = True in star (a * b) == one + a * star (b * a) * bTrue
>>>let a = False; b = True in star (a + b) == star (star a * b) * star aTrue
Involutive Ring
adj (a + b) ==> adj a + adj b adj (a * b) ==> adj a * adj b adj one ==> one adj (adj a) ==> a
Note: elements for which adj a == a are called "self-adjoint".
Minimal complete definition
Nothing