simple-dfa is an appilcation that feeds input to a DFA and produces the corresponding output.
Download the simple-dfa folder, open it in terminal and run make.
From the simple-dfa folder, run
./main dfa/[filename].dfa [inputs]
The format of [filename].dfa should be as follows.
number of states
states (one per line)
the start state
number of final states
final states (one per line)
number of transitions
transitions (one per line, each line in the form "current-state transition-symbol goal-state output-symbol")
For transitions on an empty symbol, an empty word/symbol may simply be denoted by empty in the .dfa file.
The src folder contains the DFA implementation.
main dfa/replace.dfa argvreplaces each occurrence of1 0 0by0 1 1in the binary vectorargv.
Complexity:O(|argv|).
main dfa/add1.dfa nfor a reversed binary vectorncomputesn+1in reversed binary.
Complexity:O(log n).
main dfa/sub1.dfa nfor a reversed binary vectorncomputesn-1in reversed binary.
Complexity:O(log n).
main dfa/multi.dfa nfor a reversed binary vectorncomputesi*nin reversed binary.
Complexity:O(log n).
main dfa/collatz.dfa nfor a reversed binary vectorncomputesn%2 ? 3*n+1 : n/2in reversed binary.
Complexity:O(log n).
main dfa/aba-count.dfa argvprintsa^nwherenis the number of occurrences ofa b ainargv.
Complexity:O(|argv|).
main dfa/add.dfa ab cd ef ...computes the sum of the reversed binary numbersace...andbdf...in reversed binary.
Complexity:O(|argv|).