1 / 21

NFA vs. DFA

NFA vs. DFA. NFAs vs. DFAs. NFAs can be constructed from DFAs using transitions: Called NFA-  Suppose M 1 accepts L 1 , M 2 accepts L 2 Then an NFA can be constructed that accepts: L 1 U L 2 (union) L 1 L 2 (concatenation) L 1 * (Kleene star). Closure Properties of NFA- l s. l.

stevie
Download Presentation

NFA vs. DFA

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NFA vs. DFA NFA vs. DFA

  2. NFAs vs. DFAs • NFAs can be constructed from DFAs using transitions: • Called NFA- • Suppose M1 accepts L1, M2 accepts L2 • Then an NFA can be constructed that accepts: • L1 U L2 (union) • L1L2 (concatenation) • L1* (Kleene star) NFA vs. DFA

  3. Closure Properties of NFA-ls l l M1 l l M M2 l L(M)* L(M1) UL(M2) l l l M1 M2 L(M1) L(M2) NFA vs. DFA

  4. NFA to DFA Conversion NFA vs. DFA

  5. DFA vs NFA • Deterministic vs nondeterministic • For every nondeterministic automata, there is an equivalent deterministic automata • Finite acceptors are equivalent iff they both accept the same language L(M1) = L(M2) NFA vs. DFA

  6. DFA vs NFA • Deterministic vs nondeterministic • In DFA, label resultant state as a set of states • {q1, q2, q3,…} • For a set of |Q| states, there are exactly 2Q subsets • Finite number of states NFA vs. DFA

  7. Removing Nondeterminism • By simulating all moves of an NFA-λin parallel using a DFA. • λ-closure of a state is the set of states reachable using only the λ-transitions. NFA vs. DFA

  8. NFA-λ p2 λ p1 a p3 q1 λ λ p5 λ q2 a p4 NFA vs. DFA

  9. λ– Closure • Selected λ closures q1: {q1,q2} p1: {p1,p2,p3} q2: {q2} NFA vs. DFA

  10. Equivalence Construction • Given an NFA-λ M1, construct a DFA M2 such that L(M) = L(DM). • Observe that • A node of the DFA = Set of nodes of NFA-λ • Transition of the DFA = Transition among set of nodes of NFA- λ NFA vs. DFA

  11. Special States to Identify Start state of DFA = Final/Accepting state of DFA = All subsets of states of NFA-λ that contain an accepting state of the NFA-λ Dead state of DFA = NFA vs. DFA

  12. Example a b q1 a q0 λ a q2 c NFA vs. DFA

  13. Example • Identify λ-closures • q0: {q0} • q1: {q1} • q2: {q1,q2} NFA vs. DFA

  14. Example • Identify transitions • Start with λ-closure of start state • {q0}: Where can you go on each input? • a: {q0,q1,q2} • So, {q0,q1,q2} is a state in the DFA • b, c: Nowhere, so {Φ} is in the DFA • Next slide… • Next, do the same for {q0,q1,q2} and {Φ} • Find destinations from any node in the set for each of the three alphabet symbols • Subsequent slide… NFA vs. DFA

  15. {q0} {q0} All steps from {q0} {q0,q1,q2} a b c Φ NFA vs. DFA

  16. {q0} {q0,q1,q2} a b c Φ All steps from {q0,q1,q2} a b {q1} c {q1,q2} a,b,c NFA vs. DFA

  17. b {q1} a,c Φ All steps from {q1} and {q1,q2} c {q1} b {q1,q2} a Φ NFA vs. DFA

  18. Equivalent DFA a a {q0} {q0,q1,q2} c c {q1,q2} b b,c b b a,c {q1} Φ a a,b,c NFA vs. DFA

  19. NFA vs. DFA Theorem: Given any NFA N, then there exists a DFA D such that N is equivalent to D • Proven by constructing a general NFA and showing that the closure exists among the possible DFA states P(Q) • Every possible transition goes to an element of P(Q) NFA vs. DFA

  20. Limitations of Finite Automata • Obvious: Can only accept languages that can be represented in finite memory! • Can this language be represented with a FA? • L(M)=(aibi | i  n) • How about this one? • L(M)=(aibi | i > 0) NFA vs. DFA

  21. Exercise: Convert this NFA p2 λ p1 a p3 q1 λ λ p5 λ q2 a p4 NFA vs. DFA

More Related