Useful Classes to Design
As I am developing the solution to Homework 1 Problem 3 (NTD.py), I am realizing that it
will be useful to modularize the code with the following two classes:
class NFA:
def __init__(self,sig,q=set()):
self.sigma = sig
self.states = q
self.delta = {}
self.start = None
self.final = None
# getters and setters
# convert NFA to DFA
def convert_to_dfa(self):
pass
# to String method
def __str__(self):
pass
class DFA:
def __init__(self,sig,q=set()):
self.sigma = sig
self.states = q
self.delta = {}
self.start = None
self.final = None
# getters and setters
# add state s to DFA
def add_state(self,s):
pass
# add transition (f,c,t) to DFA
def add_transition(self,f,c,t):
pass
# to String method
def __str__(self):
pass
In subsequent homework problems, we can add more methods to implement other
Automata algorithms.