Dom::RationalExpression – set of rational expressions with multiplicities

Dom::RationalExpression(A,S) creates a domain for rational expressions with multiplicities over the alphabet A and the component semi-ring S.

The domain element Dom::RationalExpression(A,S)(expression) represents the rational math- expression defined over the alphabet math given by its writing math. We adopt the following syntax : star(E), E+F, E*F, E^n denoting respectively the star of E, the sum of E and F, the product of E and F , and the product E*E...*E math times. Moreover, the writings math and math represent the basic rational math-expressions math and math, for each letter math in the alphabet math and scalar math in the semi-ring math. The internal structure of a rational math-expression is a sharp sturcture called ZPC structure. The user can display it with an appropriate method.

→ Examples

Creating the Type

Dom::RationalExpression(S)

RationalExpression(A,S)(expression)

Parameters:

A

an alphabet, i.e., a list of letters

S

a semiring, i.e., a domain of category Cat::SemiRing

expression

a string.

Superdomain

Dom::BaseDomain

Related Domains:

Dom::BooleanSemiRing, Dom::MaxMinSemiRing, Dom::MaxPlusSemiRing, Dom::MinMaxSemiRing, Dom::MinPlusSemiRing, Dom::SemiRing, Dom::WeightedAutomaton

Mathematical Methods

domtypeweight – data type of weights

(Dom::RationalExpression(S))::domtypeweight()

The data type of weights is given.

alphabet – alphabet of rational S-expressions

(Dom::RationalExpression(S))::alphabet()

The alphabet is given.

syntacticTree – syntactic tree of a rational S-expression

(Dom::RationalExpression(S))::syntacticTree(dom expression)

The syntactic tree of a rational math-expression is defined to be the table which encodes math.

firstTree – first tree of a rational S-expression

(Dom::RationalExpression(S))::firstTree(dom expression)

The first tree of the rational math-expression is returned.

lastTree – last tree of a rational S-expression

(Dom::RationalExpression(S))::lastTree(dom expression)

The last tree of the rational math-expression is displayed.

followLinks – follow links of a rational S-expression

(Dom::RationalExpression(S))::followLinks(dom expression)

The follow links of the rational math-expression are returned.

ZPCstructure – ZPCstructure of a rational S-expression

(Dom::RationalExpression(S))::ZPCstructure(dom wa)

The ZPCstructure of a rational math-expression is illustrated. It is defined to be both the syntactic, first, last trees and the follows links of the rational math-expression.

weight – weight of a word

(Dom::RationalExpression(S))::weight(dom expression, DOM_LIST u)

The weight of the word u given by a list [u1,u2,math,uk] in the rational math-expression math.

automaton – weighted position automaton corresponding to a rational S-expression

(Dom::RationalExpression(S))::automaton(dom expression)

The weighted position automaton of the rational math-expression is built from its ZPCstructure.

_plus – sum of rational S-expressions

(Dom::RationalExpression(S))::_plus(dom math, ...)

The sum math of rational math-expressions is defined to be the rational math-expression with math the weight of a word math if math is the weight of math for the rational math-expression math.

This method overloads the function _plus.

_mult – product of rational S-expressions

(Dom::RationalExpression(S))::_mult(dom math, ...)

The product math of rational math-expressions is defined to be the rational math-expression with the sum math the weight of a word math if math is the weight of the word math for the expression expression[i] for each decomposition math.

This method overloads the function _mult.

_power – Power of a rational S-expression

(Dom::RationalExpression(S))::_power(dom expression, Dom::Integer i)

The ith power math of the rational math-expression expression.

This method overloads the function _power.

star – star of a rational S-expression

(Dom::RationalExpression(S))::star(dom expression)

The star of a rational math-expression expression corresponds to the star of the rational noncommutative formal series associated to expression (if there exists).

nullWeight – weight of the empty word in a rational S-expression

(Dom::RationalExpression(S))::nullWeight(dom expression)

This method returns the weight of the empty word in the rational math-expression.

size – size of a rational S-expression

(Dom::RationalExpression(S))::size(dom expression)

The size of a rational math-expression is defined to be the number of nodes in its syntactic tree.

length – length of a rational S-expression

(Dom::RationalExpression(S))::length(dom expression)

The length of a rational math-expression is defined to be the number of letters in it.

depth – depth of a rational S-expression

(Dom::RationalExpression(S))::depth(dom expression)

This method returns the depth of the rational math-expression.

areEqual – equality of rational S-expressions

(Dom::RationalExpression(S))::areEqual(dom math, dom math)

This method checks whether the rational math-expressions math and math are equal by testing the equivalence of their respective weighted automata.

Conversion Methods

changeCoeffRing – conversion of a rational S-expression to a rational expression over another semiring

(Dom::RationalExpression(S))::changeCoeffRing(dom expression, any T)

Tries to convert the rational math-expression expression into a rational expression over scalars of type T.

Example 1:

Let us consider the set of rational expressions defined over the alphabet {a,b} and whose scalars are taken in the set of rational numbers. First, we define the set of scalars and the alphabet:

Q:=Dom::Rational:

 

alphabet:=[a,b]:

 

Then the domain of corresponding rational Q-expressions is introduced:

QExp:=Dom::RationalExpression(alphabet,Q):

 

Now we show how to create a rational Q-expression:

exp1 := QExp("star(1/3*star(a)+1/6*star(b))*b")

math

Example 2:

The weight of a word is computed:

QExp::weight(exp1, [a, a, b, a, b, a, b])

math

Moreover, the weight of the empty word is given by:

QExp::nullWeight(exp1)

math

Example 3:

We can see the internal representation of a rational expression:

QExp::ZPCstructure(exp1)

math

Conversion of a rational expression into a weighted automaton is available:

QExp::automaton(exp1)

                    +-              -+      +-              -+  +-   -+

                    |  0, 2/3, 0, 0  |      |  0, 0, 1/3, 2  |  |  0  |

                    |                |      |                |  |     |

+-          -+      |  0, 5/3, 0, 0  |      |  0, 0, 1/3, 2  |  |  0  |

| 1, 0, 0, 0 |, a = |                |, b = |                |, |     |

+-          -+      |  0, 2/3, 0, 0  |      |  0, 0, 4/3, 2  |  |  0  |

                    |                |      |                |  |     |

                    |  0,  0,  0, 0  |      |  0, 0,  0,  0  |  |  1  |

                    +-              -+      +-              -+  +-   -+

 

Example 4:

Addition of rational expressions is possible. Then we define another rational Q-expression:

exp2 := QExp("star(1/2*star(a)+star(b))"):

 

The addition returns:

exp1 + exp2

math

The product of rational expressions is computed by:

exp1*exp2

math

The nth power of a rational expression:

exp2^2

math

The star operation:

QExp::star(exp1)

math

The size, the length or the depth of a rational expression can be computed:

QExp::size(exp1)

math

QExp::length(exp2)

math

QExp::depth(exp1)

math

Example 5:

Testing equality of rational expressions is also possible. Suppose that we want check a Jacobson's relation. Then we call just the appropriate method:

QExp::areEqual(QExp::star(exp1 + exp2), QExp::star(exp1)*QExp::star(exp2*QExp::star(exp1)))

math

We can also check the commutativity of the addition of rational expressions:

QExp::areEqual(exp1 + exp2, exp2 + exp1)

math

However, the product is not commutative:

QExp::areEqual(exp1*exp2, exp2*exp1)

math

Example 6:

Moreover, it is possible to realize explicit conversions. Here we are interested to get the same rational expression but defined over an other semiring which can make sense. To illustrate this, we consider a rational MinPlus expression over the same alphabet {a,b}:

M := Dom::MinPlusSemiRing:

 

MExp := Dom::RationalExpression(alphabet, M):

 

exp3 := MExp("2*star(a)+3*star(b)")

math

Now we try to generate the corresponding rational Boolean expression.

B := Dom::BooleanSemiRing:

 

exp4 := MExp::changeCoeffRing(exp3, B)

math

domtype(re4)

math

BExp := last(1):

 

MExp::weight(exp3, [a, a]);

math

BExp::weight(exp4, [a, a])

math

Changes in MuPAD 4.0

New Function.