Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 6 NFA Subset Construction & Epsilon Transitions

Similar presentations


Presentation on theme: "Lecture 6 NFA Subset Construction & Epsilon Transitions"— Presentation transcript:

1 Lecture 6 NFA Subset Construction & Epsilon Transitions
CSCE 355 Foundations of Computation Lecture 6 NFA Subset Construction & Epsilon Transitions Topics: Examples Subset Construction Author’s Website again Epsilon transitions Ruby - dfa1.rb Sept 15, 2008

2 New: Readings section 2.2.3-2.4
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 Examples Subset construction converting NFA equivalent DFA Author’s Website Solutions Online

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

4 Subset Construction example Figure 2.9
Page 56 of text 1 p q r Equivalent DFA Table State\Input 1 { p } { p, q} { p } { p, r} *{ p, r} 0,1

5 Subset Construction example Figure 2.9
Page 56 of text 1 p q r Equivalent DFA Table State\Input 1 { p } { p, q} { p } { p, r} *{ p, r} 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 HW Solutions for starred (*) problems 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

8 Homework and Test 1 HW 2 Extra Credit HW 3 HW 4 Pop Quiz
HW 3 4a 4b 5 6 HW 4 Pop Quiz

9

10

11

12

13 Subset Example from Author’s website slides2.pdf

14 Mutual Induction Proof
Write up on back of Lecture Overview

15 Consider our old friend from HW 2. 2. 5b: L = {w ε {0,1}
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’ } 0,1 0,1 0,1 1 0,1 3 4 10 1 2 0,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

16 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“

17 [2,3,4,5, 6, 7, 8]. each { |len| numstrings = 0 strnm1
[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

18 Theorem 2.11 For NFA there is Eq. DFA

19 Theorem 2.12 L is accepted by DFA if and only if L is accepted by NFA

20 Epsilon (ε)-Transitions
Keyword Searching Example : for, format, font

21 Epsilon Closure

22 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

23 References and Homework
Ruby pickaxe book Online Author’s Website for Text Slides, HW, Exams

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42


Download ppt "Lecture 6 NFA Subset Construction & Epsilon Transitions"

Similar presentations


Ads by Google