Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
| Download
Views: 45854
Kernel: Python 3

automaton.shuffle(a1, ...)

The (accessible part of the) shuffle product of automata.

Preconditions:

  • all the labelsets are letterized

See also:

Examples

import vcsn

Boolean Automata

The shuffle product of automata computes the shuffling of their languages: all the possible interleavings.

std = lambda exp: vcsn.B.expression(exp).standard() a = std('abc') a
Image in a Jupyter notebook
a.shuffle(std('xyz'))
Image in a Jupyter notebook

Weighted automata

In the case of weighted automata, weights are "kept" with the letters.

c = vcsn.context('lal_char, seriesset<lal_char, z>') std = lambda exp: c.expression(exp).standard()
std('<A>a<B>b').shuffle(std('<X>x<Y>y'))
Image in a Jupyter notebook

Associativity

This operator is associative, and it is actually implemented as a variadic operator; a.shuffle(b, c) is not exactly the same as a.shuffle(b).shuffle(c): they are the same automata, but the former is labeled with 3-uples, not 2-tuples.

x = std('<x>a') y = std('<y>a') z = std('<z>a')
x.shuffle(y, z)
Image in a Jupyter notebook
x.shuffle(y).shuffle(z)
Image in a Jupyter notebook