TOC Finite Automata
The computation power of this model is rather weak. Because it can only use a limited (finite) memory. But it is also useful in some applications.
DFA
+ Deterministic finite automata $DFA$
A deterministic finite automata (DFA) is a 5-tuple
is a finite set called states, is a finite set called alphabet, is the transition function, is the start state (also called initial state), and is the set of accept states (final states).
The transition function
Suppose
Each
The sequence of transitions can also be expressed as:
Remember, a DFA can be represented as a state graph. The features of the graph are listed:
- A state is in a circle.
- A transition is an arc from the current state to the next state.
- The input symbol required by a transition is the label of the arc.
- The initial state is pointed by an arrow.
- Each final state is double circled.
Example
Let
0 | 1 | |
---|---|---|
If
is the language of machine ; ; recognizes .
For example:
A language is regular if it is recognized by some DFA (Deterministic Finite Automaton).
NFA
+ Nondeterministic finite automata $NFA$.
An NFA (Nondeterministic Finite Automaton) is a 5-tuple
is the set of states; is the alphabet; is the transition function; is the start state; and is the set of final states.
Suppose
If
is a string in the language : - Then there exists a "way" to reach the final state;
- It's also possible to reach a non-final state.
But if
is not a string in the language : - Then there is no way to reach the final state.
Please pay attention to the quantifiers.
Different between DFA and NFA
The difference between a DFA and an NFA is the transition function
- DFA:
- NFA:
is the power set of .
This difference allows:
- One state to transition to zero, one, or multiple states by taking one input symbol.
Automatas can be further upgraded by a special transition.
+ $\epsilon-Move$
An
Such automata is defined.
+ NFA with $\epsilon-Move$
An NFA with ε-moves is the same as an NFA (without ε-moves) except the transition function:
Later, we will see that ε-moves allow us to recursively construct NFAs, which is... elegant.
Equivalence of DFA and NFA
Power
Let
- For all languages
, is recognized by some machines in if and only if it is recognized by some machines in .
Note: A computation model is a set of all machines of the same type.
+ Theorem
DFA, NFA, and NFA with
For convenience, we denote the ordering on the power by
+ Lemma
Next, we only need to show
It seems the content repeats the explanation for converting
The Intuition of the Proof:
- For every
, we can construct a DFA that recognizes the same language. - This is equivalent to the process of converting an NFA to an equivalent DFA.
+ Def: $\varepsilon$-closure
Let
The
represents the set of all states that can be reached starting from only using -transitions. - This closure includes
itself and any other states reachable via one or more -moves. - Alternative Name: The
-closure is sometimes referred to as the Kleene Star or Kleene Closure.
+ Def: $\upvarepsilon-Closure$ of a Set of States
Let
This means the
+ Def: **$a$-Move of a Set of States:**
Let
This describes all the states reachable by:
- First making an
-transition from any state in , and - Then taking all
-transitions from those resulting states.
NOTE:
Construction Algorithm
Let
such that:
States (
, the power set of . - Each state in
is a subset of the states in .
Transition Function (
- For each state
and symbol : - Find all states
reachable by an -move from some , considering -closures.
Start State (
, the -closure of the initial state of .
Final States (
. - A subset
of states is a final state in if it includes any final state of .
Ensures
Pseudocode
\begin{algorithm}
\caption{Convert NFA$_\varepsilon$ to DFA}
\begin{algorithmic}
\State \textbf{Input:} An NFA$_\varepsilon$ $N = (Q, \Sigma, \delta, q_0, F)$
\State \textbf{Output:} A DFA $D = (Q', \Sigma, \delta', q_0', F')$
\State $Q' \gets \{E(q_0)\}$, $E(q_0)$ is unmarked, and $\delta' \gets \emptyset$
\While{there exists an unmarked state $R \in Q'$}
\State Mark $R$
\For{each symbol $a \in \Sigma$}
\State $U \gets E(\delta(R, a))$
\If{$U \notin Q'$}
\State Add $U$ to $Q'$
\EndIf
\State Add $\delta'(R, a) = U$ to $\delta'$
\EndFor
\EndWhile
\State $q_0' \gets E(q_0)$
\State $F' \gets \{R \mid R \text{ has a final state in } F\}$
\State \Return $D \gets (Q', \Sigma, \delta', q_0', F')$
\end{algorithmic}
\end{algorithm}
Example
Let’s try to convert this
Initially
Suppose the unmarked states are red.
Step 1
Step 2
Step 3
Step 4
Step 5
Finally
Rename the states to make the DFA more readable and beautiful: