Representation of DFAs and some simple algorithms on them.
- data DFA
- type Label = CUInt
- type State = CUInt
- initialize :: IO DFA
- finished :: DFA -> IO ()
- addInitialTransition :: DFA -> (Label, State) -> IO ()
- addTransition :: DFA -> (State, Label, State) -> IO ()
- setSatBit :: DFA -> State -> IO ()
- minimize :: DFA -> IO ()
- foldInitialTransitions :: DFA -> ((Label, State, Bool) -> b -> IO b) -> b -> IO b
- foldTransitions :: DFA -> ((State, Label, State, Bool) -> b -> IO b) -> b -> IO b
- numStates :: DFA -> IO CUInt
- numSymbols :: DFA -> IO CUInt
- writeDotToFile :: DFA -> FilePath -> (Label -> String) -> IO ()
Documentation
Initialisation
Create a new DFA
.
Construction
addInitialTransition :: DFA -> (Label, State) -> IO ()Source
Add an initial transition for the given Label
to the given
State
to DFA
.
addTransition :: DFA -> (State, Label, State) -> IO ()Source
Add a transition from the given State
on the given Label
to
the given State
to DFA
.
setSatBit :: DFA -> State -> IO ()Source
Set the bit associated with State
. Used to indicate finality,
acceptance, etc. The minimization algorithm will distinguish states
with different bits (that are otherwise bisimilar).
Traversal
foldInitialTransitions :: DFA -> ((Label, State, Bool) -> b -> IO b) -> b -> IO bSource
Traverse the initial transitions of DFA
by invoking the given
function on each of them.
DFAs aren't functorial (they're monomorphic), so we cannot use
Traversable
.
foldTransitions :: DFA -> ((State, Label, State, Bool) -> b -> IO b) -> b -> IO bSource
Traverse the transitions of DFA
by invoking the given function
on each of them.
DFAs aren't functorial (they're monomorphic), so we cannot use
Traversable
.
Inspection
numSymbols :: DFA -> IO CUIntSource
Returns the number of symbols that are actually present in DFA
.