Return a subautomaton such that their states are in the input states set.
Postcondition:
See also:
import vcsn
%%automaton -s aut
context = "lal_char(a), b"
0 -> 1 a
1 -> 0 a
1 -> $
1 -> 2 a
3 -> 0 a
4 -> 3 a
0 -> 3 a
$ -> 0
3 -> 5 a
To keep only states $0, 1, 2 , 3$:
aut.filter([0, 1, 2, 3])
"Keeping" a non-existing state is not an error:
aut.filter([0, 1, 7])
Calls to filter
can be filtered:
a1 = aut.filter([0, 1, 2, 3, 4]).filter([0, 1, 3, 5])
a1
but it is less efficient than filtering on the intersection. This is on purpose: the outter automaton has a view on the filtered automaton.
a2 = aut.filter(list(set([0, 1, 2, 3, 4]) & set([0, 1, 3, 5])))
print(a1.info()['type'])
print(a2.info()['type'])
print(a1.is_isomorphic(a2))
We can filter a transposed automaton:
trans = aut.transpose()
trans
trans.filter([0, 1, 2, 3])