1 / 12

CS 461 – Aug. 31

CS 461 – Aug. 31. Section 1.2 – Nondeterministic FAs How to trace input √ NFA design makes “union” operation easier Equivalence of NFAs and DFAs. NFA’s using “or”. Can you draw NFA for: { begin with 0 or end with 1 } ?. Old start 1. ε. New start. Old start 2. ε. Amazing fact.

Télécharger la présentation

CS 461 – Aug. 31

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. CS 461 – Aug. 31 Section 1.2 – Nondeterministic FAs • How to trace input √ • NFA design makes “union” operation easier • Equivalence of NFAs and DFAs

  2. NFA’s using “or” • Can you draw NFA for: { begin with 0 or end with 1 } ? Old start 1 ε New start Old start 2 ε

  3. Amazing fact • NFA = DFA • In other words, the two kinds of machines have the same power. • Proof idea: we can always convert a DFA into an NFA, or vice versa. Which do you think is easier to do?

  4. Formal NFA def’n • The essential difference with DFA is in the transition function: DFA δ: Q x Σ Q NFA δ: Q x Σε P(Q) • Thus, converting DFA  NFA is easy. We already satisfy the definition!

  5. NFA  DFA construction • When creating DFA, states will be all possible subsets of states from NFA. • This takes care of “all possible destinations.” • In practice we won’t need whole subset: only create states as you need them. • “empty set” can be our dead state. • DFA start state = NFA’s start state or anywhere you can begin for free. Happy state will be any subset containing NFA’s happy state. • Transitions: Please write as a table. Drawing would be too cluttered. When finished, can eliminate useless states.

  6. Example #1 • NFA transition table given to the right. • DFA start state is {1, 3}, or more simply 13. • DFA accept state would be anything containing 1. Could be 1, 12, 13, 123, but we may not need all these states.

  7. continued • The resulting DFA could require 2n states, but we should only create states as we need them. Let’s begin: If we’re in state 1 or 3, where do we go if we read an ‘a’ or a ‘b’? δ(13, a) = 1, but we can get to 3 for free. δ(13, b) = 2. We need to create a new state “2”. Continue the construction by considering transitions from state 2.

  8. NFA DFA answer Notice that the DFA is in fact deterministic: it has exactly one destination per transition. Also there is no column for ε.

  9. Example #2 • NFA transition table given to the right. • DFA start state is A. • DFA accept state would be anything containing D.

  10. continued Let’s begin. δ(A, 0) = A δ(A, 1) = AC We need new state AC. δ(AC, 0) = A δ(AC, 1) = ABC Continue from ABC…

  11. NFA DFA answer

  12. final thoughts • NFAs and DFAs have same computational power. • NFAs often have fewer states than corresponding DFA. • Typically, we want to design a DFA, but NFAs are good for combining 2+ DFAs. • After doing NFA  DFA construction, we may see that some states can be combined. • Later in chapter, we’ll see how to simplify FAs.

More Related