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

automaton.difference(aut)

automaton % aut

Restricting an automaton to the words not accepted by the second. In other words:

$$ (\mathcal{A} \% \mathcal{B})(u) = \begin{cases} \mathcal{A}(u) & \text{if $\mathcal{B}(u) \ne 0$} \ 0 & \text{otherwise} \end{cases} $$

Preconditions:

  • None

Caveat:

  • The name difference is wrong, and will certainly be changed in the future.

  • If the second argument is not Boolean, because we determinize it, the process might loop for ever.

See also:

Examples

In the following example, we map every non empty word on {a,b}\{a, b\} to 22 with the exception of words that are repetitions of abab or of baba.

import vcsn ctx = vcsn.context('lal, q') aut = lambda e: ctx.expression(e).automaton() a = aut('<2>[ab]{+}') b = aut('(ab+ba)*') vcsn.ipython.table([["a", "b"], [a, b]])
a b
a % b
Image in a Jupyter notebook
(a%b).shortest(len = 4)

2a2b2aa2bb2aaa2aab2aba2abb2baa2bab2bba2bbb2aaaa2aaab2aaba2aabb2abaa2abbb2baaa2babb2bbaa2bbab2bbba2bbbb\left\langle 2\right\rangle \mathit{a} \oplus \left\langle 2\right\rangle \mathit{b} \oplus \left\langle 2\right\rangle \mathit{aa} \oplus \left\langle 2\right\rangle \mathit{bb} \oplus \left\langle 2\right\rangle \mathit{aaa} \oplus \left\langle 2\right\rangle \mathit{aab} \oplus \left\langle 2\right\rangle \mathit{aba} \oplus \left\langle 2\right\rangle \mathit{abb} \oplus \left\langle 2\right\rangle \mathit{baa} \oplus \left\langle 2\right\rangle \mathit{bab} \oplus \left\langle 2\right\rangle \mathit{bba} \oplus \left\langle 2\right\rangle \mathit{bbb} \oplus \left\langle 2\right\rangle \mathit{aaaa} \oplus \left\langle 2\right\rangle \mathit{aaab} \oplus \left\langle 2\right\rangle \mathit{aaba} \oplus \left\langle 2\right\rangle \mathit{aabb} \oplus \left\langle 2\right\rangle \mathit{abaa} \oplus \left\langle 2\right\rangle \mathit{abbb} \oplus \left\langle 2\right\rangle \mathit{baaa} \oplus \left\langle 2\right\rangle \mathit{babb} \oplus \left\langle 2\right\rangle \mathit{bbaa} \oplus \left\langle 2\right\rangle \mathit{bbab} \oplus \left\langle 2\right\rangle \mathit{bbba} \oplus \left\langle 2\right\rangle \mathit{bbbb}