[Previous] [Next] [Contents]

## `Dom::BooleanSemiRing` -- boolean semi-ring

#### Introduction

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

#### Details

- The domain element `Dom::BooleanSemiRing``(n)` represents the boolean constant 0 for FALSE if n=0, or 1 for TRUE otherwise.

#### Creating Elements

``Dom::BooleanSemiRing`(n)`

#### Parameters

`n` | - | integer.

#### Categories

`Cat::SemiRing`

#### Related Domains

``

#### Entries

zero

the boolean constant 0.

one

the boolean constant 1.

#### Method _plus: sum of booleans

- `_plus(dom a1...)`

- The sum `a1+a2+...+ak` of booleans is defined to be the boolean value 0 if `a1=a2=...=ak=0`, the boolean value 1 otherwise.
- This method overloads the function `_plus`.

#### Method _mult: product of booleans

- `_mult(dom a1...)`

- The sum `a1*a2*...*ak` of booleans is defined to be the boolean value 1 if `a1=a2=...=ak=1`, the boolean value 0 otherwise.
- This method overloads the function `_mult`.

#### Method _power: power of a boolean

- `_power(dom a,Dom::Integer n)`

- The nth power `a^n` of the boolean `a`.
- This method overloads the function `_power`.

#### Method convert: conversion of an object into a boolean

- `convert(any x)`

- This method tries to convert `x` into a boolean. This is only possible if `x` is an integer.

#### Method convert_to: conversion of a boolean into another type

- `convert_to(dom a, any T)`

- Tries to convert `a` into type `T`. Currently, only a conversion into a type of scalars.

#### Method expr: convert a boolean into an integer

- `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)

                                         0

                                         1

#### Example 2

We can change the domain of scalars:

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

                                         2

#### Super-Domain

`Dom::BaseDomain`

#### Axioms

`Ax::canonicalRep, Ax::normalRep`

#### Changes

- `Dom::BooleanSemiRing` is a new function

[Previous] [Next] [Contents]

MuPAD Combinat, an open source algebraic combinatorics package