Lecture 2
Non-deterministic finite automata
Definition
A non-deterministic finite automata (NFA) is M=(K,Σ,Δ,s,F), where
Configurations and yields are defined similarly to DFA.
M accepts w∈Σ∗ if (s,w)⊢M∗(q,e) for some q∈F.
For L(M)={w∈Σ∗:M 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.
state diagram of NFA
Insight | A Magic
We assume that NFA always makes the right guess.
Example
Construct an FA that accepts
L={w∈{a,b}∗∣ the second symbol from the end of w is b.}
Theorem
DFA is equvilent to NFA.
- ∀ DFA M′,∃ NFA M, s.t. L(M)=L(M′).
- ∀ NFA M,∃ 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.
∀ NFA M′=(K,Σ,Δ,s,F), we construct a DFA M′=(K′,Σ,δ,s′,F′), where
- K′=2K={Q∣Q⊆K}.
- F′={Q⊆K∣Q∩F=∅}.
- s′=E(s), where E(q)={p∈K∣(q,e)⊢M∗(p,e)}, ∀q∈K.
- ∀Q∈K′,a∈Σ, δ(Q,a)=q∈Q⋃p:(q,a,p)∈Δ⋃E(p).
Then we claim that ∀p,q∈K,w∈Σ∗,(p,w)⊢M∗(q,e) iff (E(p),w)⊢M′∗(Q,e), where q∈Q. (We can prove it by induction on ∣w∣)
Thus, DFA M′ accepts w ⇔ NFA M accepts w.
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⋅B.
Proof
Since A and B are regular, thus there exist NFAs MA=(KA,Σ,ΔA,sA,FA) and MB=(KB,Σ,ΔB,sB,FB) which accepts A and B respectively.
We construct an NFA M∘=(K∘,Σ,Δ∘,s∘,F∘), where
- K∘=KA∪KB.
- s∘=sA.
- F∘=FB.
- Δ∘=ΔA∪ΔB∪{(q,e,sB)∣q∈FA}.
Theorem
If A is regular, so is A∗.
最后更新:
2024.01.29 15:36:20 CST
创建日期:
2023.10.01 15:23:00 CST