expression
.difference(
exp
)
¶expression
% exp
¶Restricting an expression to the words not accepted by the second. In other words:
$$ (\mathsf{E} \% \mathsf{F})(u) = \begin{cases} \mathsf{E}(u) & \text{if $\mathsf{F}(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')
exp = lambda e: ctx.expression(e)
e = exp('<2>[ab]{+}') % exp('(ab+ba)*')
e
e.shortest(len = 4)
The operator %
is also supported in the syntax of rational expressions:
exp('<2>[ab]{+}%(ab+ba)*')