Document Sample

Equivalent automata Two finite automata M1 and M2 are equivalent if CS 3813: Introduction to Formal Languages and Automata L(M1) = L(M2), Equivalence of NFAs and DFAs that is, if they both accept the same language. Sec 2.3 Equivalent DFAs Equivalent NFA and DFA a,b a,b a,b a a a a,b b b b λ a,b a,b a,b a,b a b a,b a a,b b a,b a,b b a a,b What language do they accept? What language do they accept? Equivalence of NFAs and DFAs Proof strategy • To show that any language accepted by a NFA is • We now show that DFAs and NFAs accept exactly the also accepted by some DFA, we describe an same set of languages. That is, nondeterminism does algorithm that takes any NFA and converts it into a not make a finite automaton any more powerful. DFA that accepts the same language • To show that NFAs and DFAs accept the same class of • The algorithm is called the “subset construction languages, we show two things: algorithm” – any language accepted by a DFA can also be accepted • We can use mathematical induction (on the length of by some NFA (this is easy to show -- how?) a string accepted by the automaton) to prove that the – any language accepted by a NFA can also be accepted DFA that is constructed accepts the same language by some DFA (this is more difficult to show -- it will as the NFA. (See theorem 2.2) take us the rest of class) • You don’t need to know the proof -- but you do need to remember the algorithm! 1 Steps of subset construction algorithm Subset construction algorithm • The initial state of the DFA is the set of all states • What does it do? Given a NFA, it constructs a the NFA can be in without reading any input. DFA that accepts the same language • For any state {qi,qj,…,qk} of the DFA and any input • What is the key idea? The equivalent DFA a, the next state of the DFA is the set of all states of simulates the NFA by keeping track of the the NFA that can result as next states if the NFA is possible states it could be in. Each state of the in any of the states qi,qj,…,qk when it reads a. This DFA corresponds to a subset of the set of states of includes states that can be reached by reading a the NFA -- hence, the name of the algorithm. followed by any number of λ-transitions. Use this • If the NFA has n states, the DFA can have as rule to keep adding new states and transitions until many as 2n states (why?), although it usually has it is no longer possible to do so. many less. • The accepting states of the DFA are those states that contain an accepting state of the NFA. Example a a λ {0,1} 0 1 b b a The start state of the DFA is the set of states the 2 b NFA can be in before reading any input. This b includes the start state of the NFA and any states that can be reached by a e-transition. Here is a NFA that we want to convert to an equivalent DFA. a a {0,1} b {0,1} b {1,2} {2} a {2} b For state {0,1}, we create a transition for each For state {2}, we create a transition for each possible input, a and b. In the process, we create possible input, a and b. In the process, we create state {2}. another state, {1,2}. 2 a b a b {0,1} a {1,2} {0,1} a {1,2} b b a {2} a {2} b b For state {1,2}, we create a transition for each possible input, a and b. At this point, a transition The last step is to mark the final states of the DFA. is defined for every state-input pair. Exercise Exercise 1 1 0 0 0 1 1 q0 q1 q2 q0 q1 q2 0,1 0,λ λ,1 0,1 Use the subset construction algorithm to convert Use the subset construction algorithm to convert this NFA to an equivalent DFA. this NFA to an equivalent DFA. Exercise Exercise a b a b q0 q1 q2 q0 a q1 a a b Use the subset construction algorithm to q2 λ convert this NFA to an equivalent DFA. c Use the subset construction algorithm to convert this NFA to an equivalent DFA. 3

DOCUMENT INFO

Shared By:

Categories:

Tags:

Stats:

views: | 72 |

posted: | 6/3/2011 |

language: | English |

pages: | 3 |

OTHER DOCS BY nyut545e2

How are you planning on using Docstoc?
BUSINESS
PERSONAL

By registering with docstoc.com you agree to our
privacy policy and
terms of service, and to receive content and offer notifications.

Docstoc is the premier online destination to start and grow small businesses. It hosts the best quality and widest selection of professional documents (over 20 million) and resources including expert videos, articles and productivity tools to make every small business better.

Search or Browse for any specific document or resource you need for your business. Or explore our curated resources for Starting a Business, Growing a Business or for Professional Development.

Feel free to Contact Us with any questions you might have.