Awali
Another Weighted Automata library
|
A priori, any character may appear in the alphabet list, and no error or warning will be sent. However, the use of characters (
, )
, +
, .
, or *
will result into weird output, or abort.
Besides the letters of the alphabet, expressions are written with the symbols \z
for the constant zero (denoting the empty language, or the zero series) and \e
for the constant one (denoting the empty word). Caveat: the empty string is not accepted for denoting the empty word, that is, for instance, cora cat ''
results in an error and the correct writing is cora cat '\e'
.
All expressions are necessarily reduced modulo the 'trivial identities':
0+E = E+0 = E 0.E = E.0 = E 1.E = E.1 = E
The elements of the weight semiring are written between < >. All expressions are then reduced modulo the 'weighted trivial identities':
<0>E = E<0> = 0 <1>E = E<1> = E <h>(<k>E<l>)<m> = <hk>E<lm>
and, if x
is a letter, <h>x<k> = <hk>x
.
(Note that the writing <h><k>E
is not syntactically correct.)
If the letters are integers, the product has to be marked with a dot (in order to distinguish from integers that are written by a sequence of digits).
A sequence of operators +
or .
is implicitely parenthezised from left to right and the corresponding parentheses are kept implicit in an output in text format. And the operator .
is kept implicit if the letters are characters (that is, of type char
). That is, ((a+b)+c)
is written a+b+c
and (a+(b+c))
a+(b+c)
, (a.(b.c))
is written a(bc)
etc.
The operators are ordered by precedence:
+ < . < * < <k>
where the last operation is the external multiplication by a coefficient k in the weight semiring. This implies for instance, and contrarily to the usual reading, that the expression ab*
denotes the language {a, ab, abb, abbb,...}
and that <2>a*
denotes the series \e + <2>a + <4>aa + ...
The parentheses that are made useless by the precedence ordering are suppressed in the output.