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 - expression defined over the alphabet given by its writing . 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 times. Moreover, the writings and represent the basic rational -expressions and , for each letter in the alphabet and scalar in the semi-ring . The internal structure of a rational -expression is a sharp sturcture called ZPC structure. The user can display it with an appropriate method.
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
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 -expression is defined to be the table which encodes .
firstTree – first tree of a rational S-expression
(Dom::RationalExpression(S))::firstTree(dom expression)
The first tree of the rational -expression is returned.
lastTree – last tree of a rational S-expression
(Dom::RationalExpression(S))::lastTree(dom expression)
The last tree of the rational -expression is displayed.
followLinks – follow links of a rational S-expression
(Dom::RationalExpression(S))::followLinks(dom expression)
The follow links of the rational -expression are returned.
ZPCstructure – ZPCstructure of a rational S-expression
(Dom::RationalExpression(S))::ZPCstructure(dom wa)
The ZPCstructure of a rational -expression is illustrated. It is defined to be both the syntactic, first, last trees and the follows links of the rational -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,,uk] in the rational -expression .
automaton – weighted position automaton corresponding to a rational S-expression
(Dom::RationalExpression(S))::automaton(dom expression)
The weighted position automaton of the rational -expression is built from its ZPCstructure.
_plus – sum of rational S-expressions
(Dom::RationalExpression(S))::_plus(dom , ...)
The sum of rational -expressions is defined to be the rational -expression with the weight of a word if is the weight of for the rational -expression .
This method overloads the function _plus.
_mult – product of rational S-expressions
(Dom::RationalExpression(S))::_mult(dom , ...)
The product of rational -expressions is defined to be the rational -expression with the sum the weight of a word if is the weight of the word for the expression expression[i] for each decomposition .
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 of the rational -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 -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 -expression.
size – size of a rational S-expression
(Dom::RationalExpression(S))::size(dom expression)
The size of a rational -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 -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 -expression.
areEqual – equality of rational S-expressions
(Dom::RationalExpression(S))::areEqual(dom , dom )
This method checks whether the rational -expressions and 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 -expression expression into a rational expression over scalars of type T.
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")
The weight of a word is computed:
QExp::weight(exp1, [a, a, b, a, b, a, b])
Moreover, the weight of the empty word is given by:
QExp::nullWeight(exp1)
We can see the internal representation of a rational expression:
QExp::ZPCstructure(exp1)
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 |
+- -+ +- -+ +- -+
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
The product of rational expressions is computed by:
exp1*exp2
The nth power of a rational expression:
exp2^2
The star operation:
QExp::star(exp1)
The size, the length or the depth of a rational expression can be computed:
QExp::size(exp1)
QExp::length(exp2)
QExp::depth(exp1)
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)))
We can also check the commutativity of the addition of rational expressions:
QExp::areEqual(exp1 + exp2, exp2 + exp1)
However, the product is not commutative:
QExp::areEqual(exp1*exp2, exp2*exp1)
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)")
Now we try to generate the corresponding rational Boolean expression.
B := Dom::BooleanSemiRing:
exp4 := MExp::changeCoeffRing(exp3, B)
domtype(re4)
BExp := last(1):
MExp::weight(exp3, [a, a]);
BExp::weight(exp4, [a, a])
Changes in MuPAD 4.0
New Function.