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

automaton.add(aut, algo="auto")

Build an automaton whose behavior is the sum of the behaviors of the input automata.

The algorithm has to be one of these:

  • "auto": default parameter, same as "standard" if parameters fit the standard preconditions, "general" otherwise.

  • "deterministic": deterministic sum of two deterministic automata.

  • "general": general addition or union, no additional preconditions.

  • "standard": standard addition.

Preconditions:

  • "determistic": both automata have to be determinism.

  • "standard": automaton has to be standard.

Postconditions:

  • "standard": the result automaton is standard.

If algo is "deterministic" and the weightset is Boolean, a more efficient algorithm based on the conjunction is used.

import vcsn ctx = vcsn.context('lal_char, b') aut = lambda e: ctx.expression(e).standard()

Examples

Sum of standard automata.

aut('a') + aut('b')
Image in a Jupyter notebook
aut('a').add(aut('b'), "general")
Image in a Jupyter notebook

Sum of non standard automata.

%%automaton -s a context = "lal_char, q" $ -> 0 1 -> 0 b 0 -> 1 a 1 -> $ <2>
Image in a Jupyter notebook
a+a
Image in a Jupyter notebook

Sum of deterministic automata.

aut('ab').add(aut('ac'), algo='deterministic')
Image in a Jupyter notebook