This program checks if a given deterministic finite automaton (DFA) has a synchronizing word, and if so, it outputs the shortest such word. A synchronizing word is a sequence of input symbols that, when applied to any state of the DFA, leads to a specific state. If the DFA is not synchronizing, the program outputs the string "automaton isn't synchronizing". The program uses the fact that shortest synchronizing word of a DFA is determined by the shortest path in that DFA's power automaton.
The input file must describe a valid DFA and follow this format:
- First Line: An integer
nrepresenting the number of states in the DFA. - Second Line: A string of
ksymbols representing the alphabet, with all symbols listed consecutively without spaces. - Third Line: A description of the transition function in the following format:
[list0, list1, ... listn-1], where eachlistiis ak-element list of tuples(c, m).cis aCharrepresenting a symbol from the alphabet, andmis an integer representing the target state (0 ton-1).- This means that the transition function sends state
ito statemusing symbolc(i.e.,transitionFunction(i, c) = m).
3 ab [[('a', 1), ('b',1)], [('a', 1), ('b', 2)], [('a', 0), ('b', 1)]]
- The DFA has 3 states (
0,1,2). - The alphabet consists of two symbols:
aandb. - The transition function is defined as:
- From state
0:aleads to1,bleads to1 - From state
1:aleads to1,bleads to2 - From state
2:aleads to0,bleads to1
- From state
- If the DFA has a synchronizing word, the program prints the shortest synchronizing word.
- If the DFA does not have a synchronizing word, the program prints
"automaton isn't synchronizing".
- The
mainfunction and file handling assume that states are numbered from0ton-1. However, the functions implemented to find the shortest synchronizing word only require that the type representing states is comparable.