In [1]:
from dfa_parser import dfa_from_dict, dfa_to_dict
In [2]:
dfa_dict = {'accepts': {1},
'start': 0,
'transitions': {0: {'a': 0, 'b': 1}, 1: {'a': 1, 'b': 2}, 2: {'a': 2, 'b': 0}}}
In [3]:
dfa = dfa_from_dict(dfa_dict)
In [4]:
dfa.pretty_print()
In [5]:
dfa_to_dict(dfa)
Out[5]:
In [6]:
dfa.current_state
Out[6]:
In [7]:
dfa.input('a')
dfa.current_state
Out[7]:
In [8]:
dfa.pretty_print()
In [9]:
import dfa_grapher as dfg
In [14]:
dfg.draw_dfa(dfa, 'dfa_graph.png')
DFA sampler usage is given below, the class generates random strings until it finds an accepting or rejecting string.
In [11]:
from dfa_sampler import get_negative_input, get_positive_input
In [12]:
get_positive_input(dfa, 5)
Out[12]:
In [13]:
get_negative_input(dfa,5)
Out[13]:
In [ ]: