1 / 42

Lecture 6 NFA Subset Construction & Epsilon Transitions

Lecture 6 NFA Subset Construction & Epsilon Transitions. CSCE 355 Foundations of Computation. Topics: Examples Subset Construction Author’s Website again Epsilon transitions Ruby - dfa1.rb. Sept 15, 2008. Last Time: Readings 2.3 HW Hints and Induction example Review Induction

yuki
Download Presentation

Lecture 6 NFA Subset Construction & Epsilon Transitions

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. Lecture 6NFA Subset Construction & Epsilon Transitions CSCE 355 Foundations of Computation Topics: • Examples Subset Construction • Author’s Website again • Epsilon transitions • Ruby - dfa1.rb Sept 15, 2008

  2. Last Time: Readings 2.3 • HW Hints and Induction example • Review • Induction • DFA for Union, revisit Example 2.4 • Pop Quiz • Uses of Finite automata • NFA • Delta-hat, a string accepted by an NFA, the language accepted • Subset construction converting NFA  equivalent DFA TEST 1 – Monday New: Readings section 2.2.3-2.4 • Examples Subset construction converting NFA equivalent DFA • Author’s Website Solutions Online

  3. NFA example Figure 2.9 • x • What does the p mean? • What does the *r mean? • What is δ(s, x) informally? • Page 56 Transition Table (NFA) 0 1 p q r 0,1

  4. Subset Construction example Figure 2.9 • Page 56 of text 0 1 p q r Equivalent DFA Table 0,1

  5. Subset Construction example Figure 2.9 • Page 56 of text 0 1 p q r Equivalent DFA Table 0,1

  6. Subset Construction Significance • Constructing an equivalent DFA from and NFA • What does equivalent mean? • Does equivalent mean have the same number of states? • Equivalent means  • Why convert? • What is better about an NFA? • What is better about a DFA? • We are interested in the power of these models? • Can an NFA recognize a language that a DFA can’t? • Can a DFA recognize a language that an NFA can’t?

  7. Exercise 2.2.9 Solutions Online • Author’s Website for Text • http://infolab.stanford.edu/~ullman/ialc.html • HW Solutions for starred (*) problems • http://infolab.stanford.edu/~ullman/ialcsols/sol2.html • 2.2.9 page 54 Prove If δ(q0, a) = δ(qf, a) for all a in Σ then for all w != ε we have δ(q0, w) = δ(qf, w) by induction on the length of w. • Basis • Assume • Then we need to show that • Dr. Ullman’s (Jeff’s) slides from CS 154 • http://infolab.stanford.edu/~ullman/ialc/jdu-slides.html

  8. Homework and Test 1 • HW 2 • Extra Credit • http://infolab.stanford.edu/~ullman/ialc/slides/slides1.pdf • HW 3 • 4a • 4b • 5 • 6 • HW 4 • Pop Quiz

  9. Subset Example from Author’s website slides2.pdf

  10. Mutual Induction Proof • Write up on back of Lecture Overview

  11. Consider our old friend from HW 2.2.5b:L = {w ε{0,1}* | the tenth symbol from the right end of w is a ‘1’ } • If we convert an NFA with n states to a DFA using the subset construction what is the max number states in the DFA? • Can we do better? • Subset construction an example of “lazy evaluation” – i.e. consider only states we can get to from q0 • DFA minimization is a topic for later 0,1 0,1 0,1 1 0,1 … 3 4 10 0 1 2 0,1

  12. Ruby: Strings and DFAs (dfa1.rb) # DFA1.rb on Handouts page Now consider how to generate all strings in Σ* of length 6 # Idea: generate them from a list of the strings of length n-1 # by concatenating onto each string w of length n-1 each a εΣ (a recursive definition) # lists of strings of length n-1 and n strnm1 = Array.new(); strn = Array.new(); strnm1 = ["a", "b"] print "strnm1 = #{strnm1}\n“

  13. [2,3,4,5, 6, 7, 8].each { |len| numstrings = 0 strnm1.each { |str| alphabet.each { |chr| x = chr + str strn[numstrings] = x numstrings = numstrings + 1 } } print "Strings of length #{len}:\n" strn.each { |str| print "#{str}\n" } strnm1 = strn strn = Array.new numstrings = 0 }

  14. Theorem 2.11 For NFA there is Eq. DFA

  15. Theorem 2.12 L is accepted by DFA if and only if L is accepted by NFA

  16. Epsilon (ε)-Transitions • Keyword Searching Example: for, format, font

  17. Epsilon Closure

  18. Equivalent NFA (without ε) for an NFA with ε Convert NFA with ε to an equivalent NFA without ε • Compute transitive closure of ε arcs • If p can reach state q by ε arcs and δ(r, a) contains p (there is a transition from r to q on input a) then add q to δ(r, a) i.e. add a transition from r to q on input a • xx

  19. References and Homework • Ruby pickaxe book Online • http://whytheluckystiff.net/ruby/pickaxe/ • Author’s Website for Text • http://infolab.stanford.edu/~ullman/ialc.html • Slides, HW, Exams

More Related