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

In [1]:
import vcsn
In [2]:
%%automaton -s a
0 -> 0 a, b
0 -> 1 a
1 -> 1 a, b
%3 0 0 0->0 a, b 1 1 0->1 a 1->1 a, b

This automaton is not empty, but totally useless:

In [3]:
a.is_empty()
Out[3]:
False
In [4]:
a.is_useless()
Out[4]:
True

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

In [5]:
a.trim()
Out[5]:
%3
In [6]:
a.trim().is_empty()
Out[6]:
True

Caveat

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

In [7]:
%%automaton -s a
context = "lal_char, z"
$ -> 0
0 -> 1 a
0 -> 2 <-1>a
1 -> $
2 -> $
%3 I0 0 0 I0->0 F1 F2 1 1 0->1 a 2 2 0->2 ⟨-1⟩a 1->F1 2->F2
In [8]:
a.is_useless()
Out[8]:
False
In [9]:
a.shortest(10)
Out[9]:
$\emptyset$