import itertools
stateTransitions = [
('q0', 'q1', '0'),
('q1', 'q1', '0'),
('q1', 'q2', '1'),
('q2', 'q3', '0'),
]
DFA = Automaton(stateTransitions, initial_states=['q0'], final_states=['q3'])
list(islice(DFA.language(initial_states=['q1']), None, 10))
I am trying to determine outputs for an automaton from each of its states. For that I want to use
its language method(link), as it returns all words that are accepted by the automaton.
The documentation states that:
kwargs – will be passed on to the process
iterator. See process() for a
description.
process() takes, among others, an
initial_state as one of its named arguments.
Again, in it's documentation(link):
initial_state or initial_states – the initial state(s) in which the machine starts. Either specify a single one with initial_state or a list of them with initial_states. If both are given, initial_state will be appended to initial_states. If neither is specified, the initial states of the finite state machine are taken.
So if I understand correctly, by passing initial_state='q1' to the DFA.language() method, like in the code above, the automaton should output words, beginning from state 'q1', ignoring the previously set initial state 'q0' from its initializer.
This doesn't work however. The above code will always yield output beginning at 'q0'.
I did a bit of investigation and I think the reason for this is, that **kwargs from Automaton.language() is not passed correctly to the FSMProcessIterator, as it's mentioned in the docs. I am not good enough with the sage codebase or python to debug this however.
Did I do something wrong? If not, it'd be very kind if someone could confirm the issue.