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:
Caveat:
difference
is wrong, and will certainly be changed in the future.See also:
In the following example, we map every non empty word on $\{a, b\}$ to $2$ with the exception of words that are repetitions of $ab$ or of $ba$.
import vcsn
ctx = vcsn.context('lal_char, 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).shortest(len = 4)