Dom::BooleanSemiRing – boolean semi-ring
Dom::BooleanSemiRing creates a domain for the semi-ring of booleans.
Creating Elements
BooleanSemiRing(n)
Parameters:
n: |
integer. |
Superdomain
Categories
Axioms
Ax::canonicalRep, Ax::normalRep
Related Domains:
Details:
The domain element Dom::BooleanSemiRing(n) represents the boolean constant for FALSE if , or for TRUE otherwise.
Entries
"zero" |
the boolean constant . |
"one" |
the boolean constant . |
Mathematical Methods
_plus – sum of booleans
Dom::BooleanSemiRing::_plus(dom , ...)
The sum of booleans is defined to be the boolean value if , the boolean value otherwise.
This method overloads the function _plus.
_mult – product of booleans
Dom::BooleanSemiRing::_mult(dom , ...)
The sum of booleans is defined to be the boolean value if , the boolean value otherwise.
This method overloads the function _mult.
_power – power of a boolean
Dom::BooleanSemiRing::_power(dom a, Dom::Integer n)
The n-th power of the boolean a.
This method overloads the function _power.
Conversion Methods
convert – conversion of an object into a boolean
Dom::BooleanSemiRing::convert(any x)
This method tries to convert x into a boolean. This is only possible if x is an integer.
convert_to – conversion of a boolean into another type
Dom::BooleanSemiRing::convert_to(dom a, any T)
Tries to convert a into type T. Currently, only a conversion into a type of scalars.
expr – convert a boolean into an integer
Dom::BooleanSemiRing::expr(dom a)
This method returns a integer such that generating a boolean from that integer would result in a.
This example shows the idempotency of the boolean semi-ring:
B:=Dom::BooleanSemiRing:
B(0) + B(0);
B(1) + B(1)
We can change the domain of scalars:
B::convert_to(B(1), Dom::Integer) + B::convert_to(B(1), Dom::Integer)