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

automaton.is_useless

Whether the automaton is useless, i.e., whether it has successful computations. Morally, should be equivalent to whether it accepts no words, but see below.

This is equivalent to testing whether the trim part is empty.

Caveat:

  • an non-useless automaton might still accept no words (see below).

See also:

Examples

import vcsn
%%automaton -s a 0 -> 0 a, b 0 -> 1 a 1 -> 1 a, b
Image in a Jupyter notebook

This automaton is not empty, but totally useless:

a.is_empty()
False
a.is_useless()
True

If we trim it, then it is empty (which is why it seems that there is no result):

a.trim()
Image in a Jupyter notebook
a.trim().is_empty()
True

Caveat

On some specific structures, automaton.is_useless returns false although the automaton accepts no words.

%%automaton -s a context = "lal_char, z" $ -> 0 0 -> 1 a 0 -> 2 <-1>a 1 -> $ 2 -> $
Image in a Jupyter notebook
a.is_useless()
False
a.shortest(10)

\emptyset