Return a (finite) approximation of the behavior of the automaton controled by the length of the words. In other words, compute the polynomial of the first accepted words (according to the shortlex order), and their associated weight.
Arguments:
num
the number of words to find (there might be fewer). None
stands for $\infty$ if len
is specified, 1 otherwise.len
the maximum length of the words to find. None
stands for $\infty$.Default values are handled as follows:
len = None | len = $\ell$ | |
num = None | $1, \infty$ | $\infty, \ell$ |
num = $n$ | $n, \infty$ | $n, \ell$ |
Preconditions:
See also:
import vcsn
a = vcsn.context('lal_char(ab), b').de_bruijn(1)
a
Calling a.shortest()
is equivalent to a.shortest(1)
which is equivalent to a.shortest(1, 0)
: find the shortest word, whatever its length:
a.shortest()
To get the first four words, use a.shortest(4)
(or a.shortest(len = 4)
):
a.shortest(4)
The words with at most four letters:
a.shortest(len=4)
At most 10 words of at most 4 letters:
a.shortest(num=10, len=4)
At most 10 words of at most 3 letters:
a.shortest(num=10, len=3)
The following automaton decodes binary numbers.
%%automaton -s bin
context = "lal_char(01), z"
$ -> 0
0 -> 0 0, 1
0 -> 1 1
1 -> $
1 -> 1 <2>0, <2>1
bin.shortest(len=3)
bin.shortest(num=10)
The following automaton maps words to words. The length of a multitape words is the largest length of its components: $\mathsf{len}(abc|x) = 3$.
%%automaton -s t
context = "lat<law<char>, law<char>>, q"
$ -> 0
0 -> 1 <1>one|un
0 -> 2 <2>two|deux
0 -> 3 <3>three|trois
1 -> 0 \e|\e
2 -> 0 \e|\e
3 -> 0 \e|\e
1 -> $
2 -> $
3 -> $
t.shortest(num=10, len=9)