Dom::SemiRing – constructor of semirings
Dom::SemiRing(Coefficient=coefficient, ...) creates a semiring domain.
Details:
The domain representing a semiring is stated by: Dom::SemiRing(Coefficient=coefficient Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ).Its elements belong to coefficient and satisfy the property prop. The addition, zero and opposites can be specified with the options Plus, Zero, and Negate respectively. The multiplication, one, inverses and the division with Mult, One, Invert and Divide respectively.
For more complicated semirings, it is recommended to create a new domain which inherits from this one.
Creating Elements
Dom::SemiRing(Coefficient = coefficient, <Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ>)
Parameters:
coefficient: |
a set of elements, given as a domain, a set, or a list of domains and sets. |
prop: |
a property given by a type. |
plus: |
the addition of the semiring, given as a function. |
zero: |
the neutral element for the addition of the semiring which must verify the property (if it is a parameter) and, in this case, it must also be a coefficient. |
negate: |
opposites of the semiring, given as a function. |
mult: |
the multiplication of the semiring, given as a function. |
one: |
the neutral element for the multiplication of the semiring; it must verify the property (if it is a parameter) and, in this case, it must also be a coefficient. |
invert: |
inverses of the semiring, given as a function. |
divide: |
the division of the semiring, given as a function. |
star: |
the star of the semiring, given as a function. |
categ: |
a category inheriting from Cat::SemiRing. |
Superdomain
Categories
Axioms
Ax::canonicalRep, Ax::normalRep
Related Domains:
Entries
"zero" |
the neutral element for the addition of the semiring. |
"one" |
the neutral element for the multiplication of the semiring. |
Mathematical Methods
_plus – addition of semiring values
(Dom::SemiRing(Coefficient = coefficient, <Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ>))::_plus(dom , ...)
The operation realizes the addition of the semiring values .
This method overloads the function _plus.
_mult – multiplication of semiring values
(Dom::SemiRing(Coefficient = coefficient, <Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ>))::_mult(dom , ...)
The operation realizes the multiplication of the semiring values .
This method overloads the function _mult.
_negate – opposite of a semiring value
(Dom::SemiRing(Coefficient = coefficient, <Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ>))::_negate(dom , ...)
represents the opposite of a semiring value if it exists, FAIL otherwise.
This method overloads the function _negate.
_invert – inverse of a semiring value
(Dom::SemiRing(Coefficient = coefficient, <Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ>))::_invert(dom , ...)
represents the inverse of a semiring value if it exists, FAIL otherwise.
This method overloads the function _invert.
_divide – division of a semiring
(Dom::SemiRing(Coefficient = coefficient, <Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ>))::_divide(dom , ...)
The operation realizes the division of the semiring values .
This method overloads the function _divide.
_power – power of a semiring value
(Dom::SemiRing(Coefficient = coefficient, <Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ>))::_power(dom a, Dom::Integer n)
The nth power of a semiring value a.
This method overloads the function _power.
Conversion Methods
changeCoeffRing – conversion of a semiring value into another semiring value
(Dom::SemiRing(Coefficient = coefficient, <Prop = prop, Plus = plus, Zero = zero, Negate = negate, Mult = mult, One = one, Invert = invert, Divide = divide, Star = star, Categ = categ>))::changeCoeffRing(dom a, any T)
The conversion of a into a semiring T. Currently, only a conversion into a type of scalars.
This example shows how to create the boolean semiring:
Bplus := (x, y) -> (if bool(x = 1) or bool(y = 1) then
1
else
0
end_if) :
Bmult := (x, y) -> (if bool(x = 1) and bool(y = 1) then
1
else
0
end_if) :
Bstar := x -> 1 :
B := Dom::SemiRing(Coefficient = {0, 1}, Plus = Bplus, Zero = 0, Mult = Bmult, One = 1, Star = Bstar) :
B(1) + B(1) ;
We can overload Dom::Rational with a method star:
Q := Dom::Rational :
s := x -> (if x = 1 then
FAIL
else
1/(1 - x)
end_if) :
Qs := Dom::SemiRing(Coefficient = Q, Star = s, Categ = Cat::Field) :
Qs::star(Qs(1/2)) ;
Changes in MuPAD 3.1
New Function.