110 likes | 225 Views
Nondeterminism – Converting NFAs to DFAs. Lecture 9 Section 1.2 Mon, Sep 10, 2007. Definition of an NFA. For an NFA, define the transition function as : Q ( Q ), where = { }. Example. Let A = { x | x contains an even number of a ’s}.
E N D
Nondeterminism – Converting NFAs to DFAs Lecture 9 Section 1.2 Mon, Sep 10, 2007
Definition of an NFA • For an NFA, define the transition function as : Q(Q), where = {}.
Example • Let A = {x | x contains an even number of a’s}. • Let B = {x | x contains an even number of b’s}. • Describe for the NFA that accepts AB. • Do the computation for the string abaabb.
Equivalence of NFAs and DFAs • Theorem: For every NFA, there is a DFA that accepts the same language. • Constructive Proof: • For each state in the NFA, form its “-closure.”
The -Closure of a State • Given a state q, the -closure of q, denoted E(q), is the set of all states, including q itself, that can be reached using only -moves.
Equivalence of NFAs and DFAs • The set of states of the DFA is Q = (Q). • The initial state of the DFA is E(q0). • Define : • For any state S(Q) and any a, (S, a) = qSE((q, a)). • The final states of the DFA are those states that contain final states of the NFA.
Example • Let A = {x | x contains an even number of a’s}. • Let B = {x | x contains an even number of b’s}. • Construct a DFA from the NFA that accepts AB. • Do the computation for the string abaabb on the DFA.
Examples • Let = {a, b}. • Let A be the set of all strings containing ab followed eventually by aa. • Let B be the set of all strings containing ba followed eventually by bb.
Examples • Consider the language AB. • How is the string ababb processed? • Construct a DFA that accepts AB.
Examples • Let A be the set of all strings that • contain at least one a, and • contain no more than one b. • How is the string abbaaba processed? • Construct a DFA that accepts A*.
a, b b a a b b a a, b Examples • A DFA for A* is