Download presentation
Presentation is loading. Please wait.
Published byGervase Summers Modified over 8 years ago
1
Lecture 5 NFAs Topics: Induction review/PopQuiz NFAs Delta, delta hat Strings accepted, languages accepted Subset Construction June 5, 2015 CSCE 355 Foundations of Computation
2
– 2 – CSCE 355 Summer 2015 Last Time: Readings through 2.2 Induction Proofs format, Examples from HW, Pseudo Pop Quiz Review of Previous Lecture Ruby Simulation - dfa0.rb More Examples given DFA find L (Example 2.4) given L find DFA (Exercise 2.2.4) Given L1 and L2 and Machines M1 and M2 with L1 = L(M1) and L2 = L(M2) construct the DFA for L1 Union L2 New: Readings section 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
3
– 3 – CSCE 355 Summer 2015 Induction Revisited
4
– 4 – CSCE 355 Summer 2015 Induction HW
5
– 5 – CSCE 355 Summer 2015 Induction Pseudo Pop Quiz
6
– 6 – CSCE 355 Summer 2015 Dfa.rb implementation glitch def delta(state, inputChar) case case when state == 0 when state == 0 case case when inputChar == 'a' then return 1; when inputChar == 'a' then return 1; when inputChar == 'b' then return 3 when inputChar == 'b' then return 3 end end when state == 1 when state == 1 case case when inputChar == 'a' then return 2 when inputChar == 'a' then return 2 when inputChar == 'b' then return 0 when inputChar == 'b' then return 0 end end... else return 999 else return 999 end end pacolet> ruby dfa0.rb Enter the input string: ababxgaaa line=ababxgaaa delta(=0, char=a) = 1 delta(=1, char=b) = 0 delta(=0, char=a) = 1 delta(=1, char=b) = 0 delta(=0, char=x) = delta(=, char=g) = 999 delta(=999, char=a) = 999 Reject
7
– 7 – CSCE 355 Summer 2015 # foreach x in inp inp.each { |x| nextstate = delta(state, x) print "delta(=#{state}, char=#{x}) = #{nextstate}\n" state = nextstate } if acceptingState[state] == 1 then puts "Accept" else puts "Reject" end
8
– 8 – CSCE 355 Summer 2015 Example 2.4 revisited
9
– 9 – CSCE 355 Summer 2015 Uses of Finite Automata Recognize strings: lexical anlayzers Text processing Unix tools: lex, flex, grep
10
– 10 – CSCE 355 Summer 2015 Nondeterministic Finite Automata (NFAs) Nondeterminism – nextstate function not “determined” δ could map a state and an input into several states or none These could be viewed as “choices” for the nextstateFormally N = (Q, Σ, δ, q0, F) with everything defined as before except δ : Q x Σ 2 Q,
11
– 11 – CSCE 355 Summer 2015 Example: Tenth symbol from the right is ‘1’
12
– 12 – CSCE 355 Summer 2015 Example from Author’s website Process input 211
13
– 13 – CSCE 355 Summer 2015 Delta hat for NFAs Recursive definition Basis δ(q, ε ) = { q } Recursive assume w = xa Assume δ(q, x ) = { p 1, p 2, p 3 … p k } Then δ(q, x ) =
14
– 14 – CSCE 355 Summer 2015 String accepted by an NFA
15
– 15 – CSCE 355 Summer 2015 Language accepted by an NFA
16
– 16 – CSCE 355 Summer 2015 Mutual Induction proof L(N) = L L = { Third symbol from right is 1.} M Show L contains L(M) and show L(M) contains L Mutual Induction
17
– 17 – CSCE 355 Summer 2015 Subset Construction Constructing an equivalent DFA from and NFA What does equivalent mean? Why?
18
– 18 – CSCE 355 Summer 2015 Subset example from Figure 2.9
19
– 19 – CSCE 355 Summer 2015 Subset Example from Author’s website slides2.pdf
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.