automaton
.multiply(rhs, algo="auto")
This function is overloaded, it supports multiple different signatures:
automaton
.multiply(
aut
)
The product (i.e., the concatenation) of two automata.
Precondition:
In case of deterministic multiplication, the labelset of
aut
has to be free.
automaton
.multiply(
num
)
The repeated multiplication (concatenation) of an automaton with itself. Exponent
-1
denotes the infinity: the Kleene star.automaton
.multiply((
min
,
max
))
The sum of repeated multiplications of an automaton.
Precondition:
min
<=
max
An algo
parameter can be added to specify how the multiplication should be performed.
automaton
.multiply(
aut
,
algo
)
automaton
.multiply(
num
,
algo
)
automaton
.multiply((
min
,
max
)
,
algo)
The algorithm has to be one of these:
"auto"
: default parameter, same as"standard"
."deterministic"
: produces a deterministic result."general"
: introduces spontaneous transitions."standard"
: does not introduce spontaneous transitions.
Preconditions:
"deterministic"
: the labelset is free.
Postconditions:
"deterministic"
: the result is a deterministic automaton."standard"
: when applied to standard automata, the result is standard."general"
: the context of the result automaton is nullable.
Caveats:
"deterministic"
: the computation might not terminate on weighted automata. See automaton.determinize.
See also:
Examples
Simple Multiplication
Instead of a.multiply(b)
, you may write a * b
.
To force the execution of the general algorithm you can do it this way.
In order to satisfy any kind of input automaton, the general algorithm inserts a transition labelled by one
, from each final transition of the left hand side automaton to each initial transition of the right hand side one.
The general
algorithm introduces spontaneous transitions.
When applied to standard automata, the standard
multiplication yields a standard automaton.
The deterministic
version returns a deterministic automaton.
Repeated Multiplication
Instead of a.multiply(3)
, you may write a ** 3
. Beware that a * 3
actually denotes a.rweight(3)
.
Use the exponent -1 to mean infinity
. Alternatively, you may invoke a.star
instead of a ** -1
.
Sums of Repeated Multiplications
Instead of a.multiply((2, 4))
, you may write a ** (2, 4)
. Again, use exponent -1 to mean infinity.
In some cases applying proper to the result automaton of the general algorithm will give you the result of the standard algorithm.