Dom::BooleanSemiRing – boolean semi-ring

Dom::BooleanSemiRing creates a domain for the semi-ring of booleans.

→ Examples

Creating Elements

BooleanSemiRing(n)

Parameters:

n

integer.

Superdomain

Dom::BaseDomain

Categories

Cat::SemiRing

Axioms

Ax::canonicalRep, Ax::normalRep

Related Domains:

Details:

The domain element Dom::BooleanSemiRing(n) represents the boolean constant math for FALSE if math, or math for TRUE otherwise.

Entries

"zero"

the boolean constant math.

"one"

the boolean constant math.

Mathematical Methods

_plus – sum of booleans

Dom::BooleanSemiRing::_plus(dom math, ...)

The sum math of booleans is defined to be the boolean value math if math, the boolean value math otherwise.

This method overloads the function _plus.

_mult – product of booleans

Dom::BooleanSemiRing::_mult(dom math, ...)

The sum math of booleans is defined to be the boolean value math if math, the boolean value math otherwise.

This method overloads the function _mult.

_power – power of a boolean

Dom::BooleanSemiRing::_power(dom a, Dom::Integer n)

The n-th power math 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.

Example 1:

This example shows the idempotency of the boolean semi-ring:

B:=Dom::BooleanSemiRing:

 

B(0) + B(0);

B(1) + B(1)

math

math

Example 2:

We can change the domain of scalars:

B::convert_to(B(1), Dom::Integer) + B::convert_to(B(1), Dom::Integer)

math