semirings and *-semirings of types in base/haskell-platform
Haskell
45
254 commits
updated May 21, 2024
Haskellers are usually familiar with monoids and semigroups. A monoid has an appending operation <> or mappend and an identity element mempty. A semigroup has an append <>, but does not require an mempty element.
A Semiring has two appending operations, 'plus' and 'times', and two respective identity elements, 'zero' and 'one'.
More formally, A semiring R is a set equipped with two binary relations + and *, such that:
A *-semiring (pron. "star-semiring") is any semiring with an additional operation 'star' (read as "asteration"), such that:
A derived operation called "aplus" can be defined in terms of star by:
As such, a minimal instance of the typeclass 'Star' requires only 'star' or 'aplus' to be defined.
semirings themselves are useful as a way to express that a type that supports a commutative and associative operation. Some examples:
*-semirings are useful in a number of applications; such as matrix algebra, regular expressions, kleene algebras, graph theory, tropical algebra, dataflow analysis, power series, and linear recurrence relations.
Some relevant (informal) reading material:
http://stedolan.net/research/semirings.pdf
http://r6.ca/blog/20110808T035622Z.html
https://byorgey.wordpress.com/2016/04/05/the-network-reliability-problem-and-star-semirings/
Some of the code in this library was lifted directly from the Haskell library 'semiring-num'.
Haskell
100.0%
semirings and *-semirings of types in base/haskell-platform
Haskell
45
254 commits
updated May 21, 2024
Haskellers are usually familiar with monoids and semigroups. A monoid has an appending operation <> or mappend and an identity element mempty. A semigroup has an append <>, but does not require an mempty element.
A Semiring has two appending operations, 'plus' and 'times', and two respective identity elements, 'zero' and 'one'.
More formally, A semiring R is a set equipped with two binary relations + and *, such that:
A *-semiring (pron. "star-semiring") is any semiring with an additional operation 'star' (read as "asteration"), such that:
A derived operation called "aplus" can be defined in terms of star by:
As such, a minimal instance of the typeclass 'Star' requires only 'star' or 'aplus' to be defined.
semirings themselves are useful as a way to express that a type that supports a commutative and associative operation. Some examples:
*-semirings are useful in a number of applications; such as matrix algebra, regular expressions, kleene algebras, graph theory, tropical algebra, dataflow analysis, power series, and linear recurrence relations.
Some relevant (informal) reading material:
http://stedolan.net/research/semirings.pdf
http://r6.ca/blog/20110808T035622Z.html
https://byorgey.wordpress.com/2016/04/05/the-network-reliability-problem-and-star-semirings/
Some of the code in this library was lifted directly from the Haskell library 'semiring-num'.
Haskell
100.0%