Upload
others
View
9
Download
0
Embed Size (px)
Citation preview
COMPUTABILITY AND COMPLEXITY, 2020 FALL SEMESTER
Lec 02. Non-deterministic FiniteAutomata
Eunjung Kim
NONDETERMINISM
Figure 1.27, Sipser 2012.
Deterministic FA Nondeterministic FAeach state & symbol one leaving arc multiple arcs or none
labels Σ Σ ∪ {ε}computation history single path multiple paths
COMPUTABILITY & COMPLEXITY 1 / 15
NONDETERMINISM: COMPUTATION
TREE AND ε
Figure 1.27, Sipser 2012.
COMPUTABILITY & COMPLEXITY 2 / 15
EXAMPLES OF NFA
Figure 1.31, Sipser 2012.
Figure 1.32, Sipser 2012.
COMPUTABILITY & COMPLEXITY 3 / 15
EXAMPLES OF NFA
Figure 1.33, Sipser 2012.
Figure 1.36, Sipser 2012.
COMPUTABILITY & COMPLEXITY 4 / 15
FORMAL DEFINITION OF NFA
NONDETERMINISTIC FA IS A 5-TUPLE (Q,Σ,δ,q0,F )
Q a finite set called the states,
Σ a finite set called the alphabet,
δ a function from Q × Σε to 2Q called the transition function,
q0 ∈ Q the start state,
F ⊆ Q the set of accept states.
Write a formal description of this NFA.
COMPUTABILITY & COMPLEXITY 5 / 15
LANGUAGE RECOGNIZED BY NFA
NFA N ACCEPTS w IF
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 pathfor w = baaabaaaa. Is there anotherone?
COMPUTABILITY & COMPLEXITY 6 / 15
CLOSURE UNDER REGULAR OPERATION
UNION OPERATION
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
CLOSURE UNDER REGULAR OPERATION
CONCATENATION OPERATION
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
CLOSURE UNDER REGULAR OPERATION
KLEENE STAR OPERATION
Let A a languages recognized by NFA N. Then A∗ is recognized by someNFA.
COMPUTABILITY & COMPLEXITY 9 / 15
CLOSURE UNDER COMPLEMENTATION
COMPLEMENTATION OPERATION
Let A a languages recognized by NFA N. Then A, that is, Σ∗ − A isrecognized by some NFA.
COMPUTABILITY & COMPLEXITY 10 / 15
CLOSURE UNDER INTERSECTION
INTERSECTION OPERATION
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
EQUIVALENCE OF NFA AND DFA
NFA AND DFA OWN THE SAME COMPUTATIONAL POWER
For every NFA, there exists a deterministic finite automata recognizing thesame language.
Proof outline.Let N = (Q,Σ,δ,q0,F ) be an NFA.
We want to construct a DFA M = (Q′,Σ,δ′,q′0,F ′) such thatL(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 π′ inM, we build an accepting computation history π in N.
COMPUTABILITY & COMPLEXITY 12 / 15
PROOF: CONSTRUCTING DFA M
Idea: from a state q ∈ Q of NFA N, any other state q′ that can bereached by reading a string of k ε’s, k ≥ 0,can be aggregated with q asa single state.
Define ext(q) ⊆ N as the set of all states q′ of N such that there is adirected path from q to q′ in (the state diagram of) N each of whose arcscarries 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 ∈ Σ,
δ′(R,a) := ext(⋃r∈R
δ(r ,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 oneaccept state of N.
COMPUTABILITY & COMPLEXITY 13 / 15
PROOF: L(N) ⊆ L(M)
Let π = (q0,w = w0), . . . , (qi ,wi ), . . . , (qs,ws = ε) be an acceptingcomputation 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 leadingsymbol of wi in (qi ,wi ) is in Σ (not ε). Let it = s.
Let Q0 = q′0. Inductively for each i ∈ [t ], let
Qi = δ′(Qi−1, yi ).
Now we have a computation history for w = y1 · · · yt as follows
π′ = (Q0,w), (Q1, y2 · · · yt ), · · · (Qt , ε).
COMPUTABILITY & COMPLEXITY 14 / 15
PROOF: L(N) ⊆ L(M)
It remains to see Qt is an accept state of M, i.e. the subset Qt ⊆ Qcontains 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 isreachable from q0 by reading a number of ε’s.
From the partition using i0, . . . , it , qij is reachable from qij−1 by reading asingle symbol aij−1+1 ∈ Σ and additional ε’s. Henceqij ∈ ext(δ(qij−1 ,aij−1+1) ⊆ ext(δ(Qj−1,aij−1+1) = δ′(Qj−1,aij−1+1) = Qj .
COMPUTABILITY & COMPLEXITY 15 / 15
PROOF: L(M) ⊆ L(N)
Let π′ = (Q0,w = w0), . . . , (Qi ,wi ), . . . , (Qt ,wt = ε) be an acceptingcomputation history of M for w . By definition of computation historyQi = δ′(Qi−1, xi ), where xi ∈ Σ is the leading symbol of wi−1.
We construct an accepting computation history of N by following thesequence π′ backwardly.
Let qf ∈ Qt be an accept state of N.
Observe: for each q ∈ Qi ⊆ Q, there exists a state q′ ∈ Qi−1 such thatfrom q′ to q there is a computation history consisting of readying a stringconsisting of xi followed by ε’s.
Now starting from qf , we concatenate computation histories witnessedby the previous observation.
COMPUTABILITY & COMPLEXITY 16 / 15