Finite State Automata
Creating Deterministic Finite Automata (DFA)
In order to create a DFA, we have to perform the following:
- create a non-deterministic Finite Automata (NFA) out of the regular expression
- convert the NFA into a DFA
NFA Creation Rules
- -> Parallel Circuit
- -> Series Circuit
- -> Cycle
Conversion of an NFA into DFA
NFA is very easy to build but hard to interpret by a computer.
- We need to convert NFA to a DFA
- Subset construction is the algorithm that achieves this conversion
In the transition table of an NFA, each entry is a set of states. In the transition table of a DFA, each entry is at most one state. General idea behind the NFA-to-DFA conversion: each DFA state corresponds to a set of NFA states.
Subset Construction Algorithm
Algorithm: Subset Construction - USed to construct a DFA from an NFA
Input: An NFA "N"
Output: A DFA "D" accepting the same language
Method
Let be a state in and be a set of states, using the following operations.
- -closure(): set of NFA states reachable from NFA state on -transitions alone
- -closure(): set of NFA states reachable from some NFA state in on -transitions alone
- move(, ): set of NFA states to which there is a transition on input symbol from some NFA state in
Algorithm (MAIN)
add state T = Epsilon-closure(s0) unmarked to *Dstates*while exists unmarked state $T$ in *Dstates*mark Tfor each input symbol aU = Epsilon-closure(move(T, a))if U does not exist *Dstates* then add U to *Dstates* unmarked*Dtrans[T, a]* = U
-closure() is the start state of . A state of is accepting if it contains at least one accepting state in .
Algorithm (E-closure computation)
push all states in T onto stackinitialize Epsilon-closure(T) to Twhile stack is not emptypop t, the top element off the stackfor each state u with an edge form t to u labeled Eif u is not in Epsilon-closure(T)add u to Epsilon-closure(T)push u onto stack
Minimizing the number of states in DFA
Minimize the number of states of a DFA by finding all groups of states that can be distinguished by some input string. Each group of states that cannot be distinguished is then merged into a single state.
Algorithm: minimizing the number of states of a DFA.
Input: A DFA with a set of states
Output: A DFA accepting the same language as yet having as few states as possible
Method
- Construct an initial partition of the set of states with two groups:
- The accepting (i.e. final) states group
- All other states group
- Partition to
- If != , then = and repeat step 2. Otherwise go to step 4
- Create a single DFA M state from every group in
- Specify the accepting (i.e. final) states of DFA M. An accepting states in DFA M corresponds to a group in that contains an accepting state in DFA D
- Specify the initial state of DFA M. An initial state in DFA M corresponds to a group to a group in that contains an initial state in DFA D
Construct New Partition Procedure
For each group G of do begin. Partition G into subgroups such that two states S and T of G are in the same subgroup if and only if for each symbol in :
- both $ and T do not have transitions on $a$
- both S and T have transitions on to states in the same group
Replace G in by the set of all subgroups formed.