COMPUTABILITY AND COMPLEXITY, 2020 FALL SEMESTER
Lec 02. Non-deterministic Finite Automata
Eunjung Kim
Lec 02. Non-deterministic Finite Automata Eunjung Kim N - - PowerPoint PPT Presentation
C OMPUTABILITY AND C OMPLEXITY , 2020 F ALL SEMESTER Lec 02. Non-deterministic Finite Automata Eunjung Kim N ONDETERMINISM Figure 1.27, Sipser 2012. Deterministic FA Nondeterministic FA each state & symbol one leaving arc multiple arcs
COMPUTABILITY AND COMPLEXITY, 2020 FALL SEMESTER
Eunjung Kim
Figure 1.27, Sipser 2012.
Deterministic FA Nondeterministic FA each state & symbol
multiple arcs or none labels Σ Σ ∪ {ǫ} computation history single path multiple paths
COMPUTABILITY & COMPLEXITY
1 / 15
Figure 1.27, Sipser 2012.
COMPUTABILITY & COMPLEXITY
2 / 15
Figure 1.31, Sipser 2012. Figure 1.32, Sipser 2012.
COMPUTABILITY & COMPLEXITY
3 / 15
Figure 1.33, Sipser 2012. Figure 1.36, Sipser 2012.
COMPUTABILITY & COMPLEXITY
4 / 15
Q a finite set called the states, Σ a finite set called the alphabet,
q0 ∈ Q the start state, F ⊆ Q the set of accept states.
Write a formal description of this NFA.
COMPUTABILITY & COMPLEXITY
5 / 15
1 w can be written as y1, . . . , ym with yi ∈ Σǫ, 2 there exists a computation path ending in an accept state.
Write an accepting computation path for w = baaabaaaa. Is there another
COMPUTABILITY & COMPLEXITY
6 / 15
Let A1 and A2 be two languages recognized by NFA N1 and N2 respectively. Then A1 ∪ A2 is recognized by some NFA.
COMPUTABILITY & COMPLEXITY
7 / 15
Let A1 and A2 be two languages recognized by NFA N1 and N2 respectively. Then A1 ◦ A2 is recognized by some NFA.
COMPUTABILITY & COMPLEXITY
8 / 15
Let A a languages recognized by NFA N. Then A∗ is recognized by some NFA.
COMPUTABILITY & COMPLEXITY
9 / 15
Let A a languages recognized by NFA N. Then ¯ A, that is, Σ∗ − A is recognized by some NFA.
COMPUTABILITY & COMPLEXITY
10 / 15
Let A1 and A2 be two languages recognized by NFA N1 and N2 respectively. Then A1 ∩ A2 is recognized by some NFA.
COMPUTABILITY & COMPLEXITY
11 / 15
For every NFA, there exists a deterministic finite automata recognizing the same language. Proof outline. Let N = (Q, Σ,δ, q0, F) be an NFA. We want to construct a DFA M = (Q′, Σ,δ′, q′
0, F ′) such that
L(N) = L(M). Define Q′ := 2Q, i.e. the family of all subsets of Q. We shall define δ′, q′
0 ∈ 2Q and F ′ ⊆ 2Q,
...and for any w ∈ L(N) with an accepting computation history π in N, we demonstrate an accepting computation history π′ in M. ... and conversely, for any w with an accepting computation history π′ in M, we build an accepting computation history π in N.
COMPUTABILITY & COMPLEXITY
12 / 15
Idea: from a state q ∈ Q of NFA N, any other state q′ that can be reached by reading a string of k ǫ’s, k ≥ 0,can be aggregated with q as a single state. Define ext(q) ⊆ N as the set of all states q′ of N such that there is a directed path from q to q′ in (the state diagram of) N each of whose arcs carries the label ǫ. Extend the definition ext(X) :=
q∈X ext(q).
transition function δ′ from 2Q × Σ to 2Q: for every R ∈ 2Q (R is a subset of Q) and every symbol a ∈ Σ,
Define q′
0 := ext(q0) ∈ 2Q. Note that q′ 0 corresponds to a subset of Q.
Define F ′ ∈ 2Q as the family of all subsets of Q containing at least one accept state of N.
COMPUTABILITY & COMPLEXITY
13 / 15
Let π = (q0, w = w0), . . . , (qi, wi), . . . , (qs, ws = ǫ) be an accepting computation history of N for w, that is qi ∈ δ(qi−1, ai) for every i ∈ [s] and qs ∈ F, where wi = ai ◦ wi−1 with ai ∈ Σ ∪ {ǫ} for every i ∈ [s]. Let 0 ≤ i0 < · · · < it−1 < s be the indices in π such that the leading symbol of wi in (qi, wi) is in Σ (not ǫ). Let it = s. Let Q0 = q′
Qi = δ′(Qi−1, yi). Now we have a computation history for w = y1 · · · yt as follows
COMPUTABILITY & COMPLEXITY
14 / 15
It remains to see Qt is an accept state of M, i.e. the subset Qt ⊆ Q contains at least one accept state of N. It suffices to prove qij ∈ Qj for each 0 ≤ j ≤ t (this implies the above). By induction. Base case holds because Q0 = q′
0 = ext(q0) and qi0 is
reachable from q0 by reading a number of ǫ’s. From the partition using i0, . . . , it, qij is reachable from qij−1 by reading a single symbol aij−1+1 ∈ Σ and additional ǫ’s. Hence qij ∈ ext(δ(qij−1, aij−1+1) ⊆ ext(δ(Qj−1, aij−1+1) = δ′(Qj−1, aij−1+1) = Qj.
COMPUTABILITY & COMPLEXITY
15 / 15
Let π′ = (Q0, w = w0), . . . , (Qi, wi), . . . , (Qt, wt = ǫ) be an accepting computation history of M for w. By definition of computation history Qi = δ′(Qi−1, xi), where xi ∈ Σ is the leading symbol of wi−1. We construct an accepting computation history of N by following the sequence π′ backwardly. Let qf ∈ Qt be an accept state of N. Observe: for each q ∈ Qi ⊆ Q, there exists a state q′ ∈ Qi−1 such that from q′ to q there is a computation history consisting of readying a string consisting of xi followed by ǫ’s. Now starting from qf, we concatenate computation histories witnessed by the previous observation.
COMPUTABILITY & COMPLEXITY
16 / 15