Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 45897
Kernel: Python 3

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:

See also:

Examples

import vcsn ctx = vcsn.context('lal_char, q') def aut(e): return ctx.expression(e, 'none').standard()

Simple Multiplication

Instead of a.multiply(b), you may write a * b.

a = aut('<2>ab<3>'); a
Image in a Jupyter notebook
b = aut('<5>cd<7>'); b
Image in a Jupyter notebook
a * b
Image in a Jupyter notebook

To force the execution of the general algorithm you can do it this way.

a.multiply(b, "general")
Image in a Jupyter notebook

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.

a = vcsn.B.expression('a*+b').automaton(); a
Image in a Jupyter notebook

The general algorithm introduces spontaneous transitions.

a.multiply(a, 'general')
Image in a Jupyter notebook

When applied to standard automata, the standard multiplication yields a standard automaton.

a.multiply(a, 'standard')
Image in a Jupyter notebook

The deterministic version returns a deterministic automaton.

a.multiply(a, 'deterministic')
Image in a Jupyter notebook

Repeated Multiplication

Instead of a.multiply(3), you may write a ** 3. Beware that a * 3 actually denotes a.rweight(3).

aut('ab') ** 3
Image in a Jupyter notebook
aut('a*') * 3
Image in a Jupyter notebook

Use the exponent -1 to mean infinity. Alternatively, you may invoke a.star instead of a ** -1.

aut('ab') ** -1
Image in a Jupyter notebook
aut('ab').star()
Image in a Jupyter notebook

Sums of Repeated Multiplications

Instead of a.multiply((2, 4)), you may write a ** (2, 4). Again, use exponent -1 to mean infinity.

aut('ab') ** (2, 2)
Image in a Jupyter notebook
aut('ab') ** (2, 4)
Image in a Jupyter notebook
aut('ab') ** (2, -1)
Image in a Jupyter notebook
aut('ab') ** (-1, 3)
Image in a Jupyter notebook
aut('ab').multiply((-1, 3), "deterministic")
Image in a Jupyter notebook

In some cases applying proper to the result automaton of the general algorithm will give you the result of the standard algorithm.

aut('ab').multiply((-1, 3), "general")
Image in a Jupyter notebook
aut('ab').multiply((-1, 3), "general").proper()
Image in a Jupyter notebook