| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
NumHask.Free.Carriers
Description
Concrete semiring carriers useful for demonstrating
StarSemiring.
These four carriers are the classic examples of the closed-semiring / algebraic-path-problem literature. They are still, fifty years on, the canonical trio plus the probabilistic addition:
- Boolean semiring — reachability / transitive closure (Warshall 1962).
- Min-plus semiring — shortest paths (Floyd 1962, Roy 1959, Warshall 1962).
- Field semiring — matrix inversion via the Neumann series.
- Viterbi semiring — maximum-probability paths.
The unification of path problems over semirings was introduced by Aho, Hopcroft and Ullman in /The Design and Analysis of Computer Algorithms/ (1974) and elaborated by Tarjan in "A Unified Approach to Path Problems" (JACM, 1981). A modern categorical treatment is given by Höfner and Möller in "Dijkstra, Floyd and Warshall Meet Kleene" (2012).
Boolean semiring
Boolean semiring for Warshall's transitive closure.
plus is ||, times is &&, star is constantly True.
>>>Warshall True + Warshall FalseWarshall True
Instances
| Eq Warshall Source # | |
| Ord Warshall Source # | |
Defined in NumHask.Free.Carriers | |
| Show Warshall Source # | |
| Additive Warshall Source # | |
| Idempotent Warshall Source # | |
Defined in NumHask.Free.Carriers | |
| Magma Warshall Source # | |
| CompleteJoinSemiLattice Warshall Source # | |
| JoinSemiLattice Warshall Source # | Boolean join-semilattice structure: join is |
| LowerBounded Warshall Source # | |
Defined in NumHask.Free.Carriers | |
| Multiplicative Warshall Source # | |
| Quantale Warshall Source # | Boolean quantale: join is disjunction, multiplication is conjunction. |
Defined in NumHask.Algebra.Quantale | |
| Residuated Warshall Source # | Boolean implication as the residual of conjunction.
|
| StarAutonomous Warshall Source # | Boolean negation as complement; |
| KleeneAlgebra Warshall Source # | |
Defined in NumHask.Free.Carriers | |
| StarSemiring Warshall Source # | Boolean star is constantly true.
|
Tropical semiring
Tropical (min-plus) semiring for Floyd–Warshall shortest paths.
Addition is min, multiplication is ordinary addition, the additive unit
is positive infinity, and the multiplicative unit is zero.
>>>MinPlus 3 + MinPlus 2 :: MinPlus DoubleMinPlus {getMinPlus = 2.0}
>>>MinPlus 3 * MinPlus 2 :: MinPlus DoubleMinPlus {getMinPlus = 5.0}
Constructors
| MinPlus | |
Fields
| |
Instances
| Eq a => Eq (MinPlus a) Source # | |
| Ord a => Ord (MinPlus a) Source # | |
| Show a => Show (MinPlus a) Source # | |
| Additive (MinPlus Double) Source # | |
| Idempotent (MinPlus Double) Source # | |
Defined in NumHask.Free.Carriers | |
| Magma (MinPlus Double) Source # | |
| CompleteJoinSemiLattice (MinPlus Double) Source # | |
| Ord a => JoinSemiLattice (MinPlus a) Source # | Tropical join-semilattice structure: join is |
| LowerBounded (MinPlus Double) Source # | |
| Multiplicative (MinPlus Double) Source # | |
| Quantale (MinPlus Double) Source # | Tropical (min-plus) quantale: join is minimum, bottom is positive infinity, multiplication is addition. |
Defined in NumHask.Algebra.Quantale | |
| Residuated (MinPlus Double) Source # | Tropical residual is truncated subtraction.
|
| StarAutonomous (MinPlus Double) Source # | Tropical linear negation is additive inverse; |
| KleeneAlgebra (MinPlus Double) Source # | |
Defined in NumHask.Free.Carriers | |
| 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'.
|
Field semiring
Field semiring for matrix inversion (I − A)⁻¹.
star is the closed Neumann series: star a = recip (1 − a).
Constructors
| FieldStar | |
Fields | |
Instances
Viterbi semiring
Viterbi semiring for maximum-probability paths.
plus is max, times is ordinary multiplication, the additive unit is
0 and the multiplicative unit is 1. The star of any value is 1,
because the empty path has probability 1 and no repeated path can improve
on that.
Constructors
| Viterbi | |
Fields
| |
Instances
| Eq a => Eq (Viterbi a) Source # | |
| Ord a => Ord (Viterbi a) Source # | |
| Show a => Show (Viterbi a) Source # | |
| Additive (Viterbi Double) Source # | |
| Idempotent (Viterbi Double) Source # | |
Defined in NumHask.Free.Carriers | |
| Magma (Viterbi Double) Source # | |
| Multiplicative (Viterbi Double) Source # | |
| KleeneAlgebra (Viterbi Double) Source # | |
Defined in NumHask.Free.Carriers | |
| StarSemiring (Viterbi Double) Source # | |