Lecture 2¶
Non-deterministic finite automata¶
Definition
A non-deterministic finite automata (NFA) is \(M = (K, \Sigma, \Delta, s, F)\), where
- \(K\) is a finite set of states.
- \(\Sigma\) is the input alphabet.
- \(s \in k\) is initial state.
- \(F \subseteq k\) is the set of final states.
-
\(\Delta\) is a transition relation.
\[ \Delta \subseteq (K \times (\Sigma \cup \{e\})) \times K \]
Configurations and yields are defined similarly to DFA.
\(M\) accepts \(w \in \Sigma^*\) if \((s, w) \vdash_M^* (q, e)\) for some \(q \in F\).
For \(L(M) = \{ w \in \Sigma^*: M \text{ accepts } w \}\), we say \(M\) accepts \(L(M)\).
The difference between DFA and NFA is that NFA allows
- more than one choice for next state.
- e-transition.
Insight | A Magic
We assume that NFA always makes the right guess.
Example
Construct an FA that accepts
Theorem
DFA is equvilent to NFA.
- \(\forall \text{ DFA } M', \exist \text{ NFA } M,\ s.t.\ L(M) = L(M').\)
- \(\forall \text{ NFA } M, \exist \text{ DFA } M',\ s.t.\ L(M) = L(M').\)
Proof
The first claim is trivial. For the second claim,
Idea DFA \(M'\) simulates "tree-like computation" of NFA \(M\).
\(\forall \text{ NFA } M' = (K, \Sigma, \Delta, s, F)\), we construct a DFA \(M' = (K', \Sigma, \delta, s', F')\), where
- \(K' = 2^K = \{Q | Q \subseteq K\}\).
- \(F' = \{Q \subseteq K | Q \cap F \neq \emptyset\}\).
- \(s' = E(s)\), where \(E(q) = \{p \in K | (q, e) \vdash_M^* (p, e) \}\), \(\forall q \in K\).
- \(\forall Q \in K', a \in \Sigma,\ \ \delta(Q, a) = \bigcup\limits_{q \in Q} \bigcup\limits_{p : (q, a, p) \in \Delta} E(p)\).
Then we claim that \(\forall p, q \in K, w \in \Sigma^*, (p, w) \vdash_M^* (q, e) \text{ iff } (E(p), w) \vdash_{M'}^* (Q, e), \text{ where } q \in Q\). (We can prove it by induction on \(|w|\))
Thus, DFA \(M'\) accepts \(w\) \(\Leftrightarrow\) NFA \(M\) accepts \(w\).
Example
NFA
DFA
Closure Property (Cont.)¶
Since the equivalence of NFA and DFA, so a language is regular if it's accepted by some NFA. Now we can prove the following theorem by NFA.
Theorem
If \(A\) and \(B\) are regular, so is \(A \cdot B\).
Proof
Since \(A\) and \(B\) are regular, thus there exist NFAs \(M_A = (K_A, \Sigma, \Delta_A, s_A, F_A)\) and \(M_B = (K_B, \Sigma, \Delta_B, s_B, F_B)\) which accepts \(A\) and \(B\) respectively.
We construct an NFA \(M_\circ = (K_\circ, \Sigma, \Delta_\circ, s_\circ, F_\circ)\), where
- \(K_\circ = K_A \cup K_B\).
- \(s_\circ = s_A\).
- \(F_\circ = F_B\).
- \(\Delta_\circ = \Delta_A \cup \Delta_B \cup \{(q, e, s_B) | q \in F_A\}\).
Theorem
If \(A\) is regular, so is \(A^*\).
创建日期: 2023.10.01 15:23:00 CST