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:
In [1]:
import vcsn
In [2]:
a = vcsn.context('lal_char(ab), b').de_bruijn(1)
a
Out[2]:
Calling a.shortest()
is equivalent to a.shortest(1)
which is equivalent to a.shortest(1, 0)
: find the shortest word, whatever its length:
In [3]:
a.shortest()
Out[3]:
To get the first four words, use a.shortest(4)
(or a.shortest(len = 4)
):
In [4]:
a.shortest(4)
Out[4]:
The words with at most four letters:
In [5]:
a.shortest(len = 4)
Out[5]:
At most 10 words of at most 4 letters:
In [6]:
a.shortest(num = 10, len = 4)
Out[6]:
At most 10 words of at most 3 letters:
In [7]:
a.shortest(num = 10, len = 3)
Out[7]:
In [8]:
%%automaton -s bin
context = "lal_char(01), z"
$ -> 0
0 -> 0 0, 1
0 -> 1 1
1 -> $
1 -> 1 <2>0, <2>1
In [9]:
bin.shortest(len = 3)
Out[9]:
In [10]:
bin.shortest(num = 10)
Out[10]:
In [11]:
%%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 -> $
In [12]:
t.shortest(num = 10, len = 9)
Out[12]: