A basic Python 3 project that scans a given word and returns if its valid or not based on a DFA defined by a text file
More specific, a dfa.txt
file is specifically given as input, which contains the necessary information to create an object that corresponds to a DFA.
In this example, the DFA diagram could be:
which means the dfa.txt
here should look like this:
where:
- 1st line indicates the number of states,
- 2nd line indicates the alphabet symbols,
- 3rd line indicates the starting state,
- 4th line indicates the ending state(s),
- and the rest of the line indicate the transfer function (where first character is the current state, second character is the current symbol being scanned and third symbol is the next state accessible)
so the output would be:
python3 main.py
- At this point, the information inside the
dfa.txt
file is to always be considered correct - The text file input examples given are
- the example as seen above (
dfa.txt
) - an automaton that accepts words with an even number of
0
s and1
s (dfa1.txt
) - an automaton that accepts words that end with
00
(dfa2.txt
) - an automaton that accepts word that either begin or end with
01
(dfa3.txt
)
- the example as seen above (
- Written in Sublime Text with the Anaconda package
- Tested with Python 3.5.2 on Lubuntu 16.04.6.