• Save
Theory of Computation: Lecture 33
Upcoming SlideShare
Loading in...5
×
 

Theory of Computation: Lecture 33

on

  • 1,950 views

1) Equivalence of NFAs and DFAs...

1) Equivalence of NFAs and DFAs
2) Epsilon closure
3) Regular expressions
4) Converting regular expressions to NFAs
5) Pigeon hole principle
6) Class home page is at http://vkedco.blogspot.com/2011/08/theory-of-computation-home.html

Statistics

Views

Total Views
1,950
Views on SlideShare
1,454
Embed Views
496

Actions

Likes
1
Downloads
0
Comments
0

39 Embeds 496

http://vkedco.blogspot.com 296
http://www.vkedco.blogspot.com 52
http://vkedco.blogspot.in 37
http://vkedco.blogspot.com.es 11
http://vkedco.blogspot.ca 9
http://vkedco.blogspot.sk 7
http://vkedco.blogspot.de 7
http://vkedco.blogspot.mx 6
http://vkedco.blogspot.com.ar 6
http://vkedco.blogspot.se 5
http://vkedco.blogspot.com.br 4
http://vkedco.blogspot.pt 4
http://vkedco.blogspot.co.uk 4
http://vkedco.blogspot.fr 4
http://vkedco.blogspot.com.au 4
http://vkedco.blogspot.co.il 4
http://vkedco.blogspot.co.at 3
http://vkedco.blogspot.gr 3
http://vkedco.blogspot.ro 3
http://vkedco.blogspot.dk 3
http://vkedco.blogspot.com.tr 2
http://vkedco.blogspot.it 2
http://vkedco.blogspot.co.nz 2
http://vkedco.blogspot.hu 2
http://www.vkedco.blogspot.kr 2
http://vkedco.blogspot.ru 1
http://vkedco.blogspot.sg 1
http://www.vkedco.blogspot.de 1
http://www.vkedco.blogspot.in 1
http://www.vkedco.blogspot.sg 1
http://vkedco.blogspot.kr 1
http://www.vkedco.blogspot.tw 1
http://vkedco.blogspot.cz 1
http://vkedco.blogspot.no 1
http://www.vkedco.blogspot.co.uk 1
http://vkedco.blogspot.be 1
http://vkedco.blogspot.ch 1
http://vkedco.blogspot.jp 1
http://vkedco.blogspot.tw 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Theory of Computation: Lecture 33 Theory of Computation: Lecture 33 Presentation Transcript

  • CS 5000: Theory of Computation Lecture 33 Vladimir Kulyukin Department of Computer Science Utah State Universitywww.youtube.com/vkedco
  • Outline ● Equivalence of NFAs and DFAs ● Epsilon Closures ● Regular Expressions ● Converting Regular Expressions to NFAs ● Pigeon Hole Principlewww.youtube.com/vkedco
  • Equivalence of NFAs and DFAswww.youtube.com/vkedco View slide
  • NFA vs. DFA ● NFAs are simpler to write, because, in general, have fewer states and allow for spontaneous transitions ● They are not more powerful than DFAs: they accept the same regular languages as DFAs ● For every NFA, one can construct a DFA that accepts the same languagewww.youtube.com/vkedco View slide
  • NFA  DFA Theorem : Let N be a NFA. Then there is a DFA D such that L( N ) = L( D ). Proof : Let N = ( Q N , ∑ , δ N , q N , FN ). Construct a new DFA D = ( QD , Σ , δ D , q D , FD ) where 1. QD = P( Q N ) ; 2. δ D ( R, a ) =  δ N ( r , a ) , R ∈ * QD , a ∈ Σ ; r∈ R 3. q D = δ * N ( q N , ε ); 4. FD = { R ∈ QD | R ∩ FN ≠ ∅ }. By construction, δ * D ( qD , x) ∈ FD iff δ * N ( qN , x) ∩ FN ≠ ∅ , ∀ x ∈ Σ * .www.youtube.com/vkedco
  • NFA  DFA The start state for the new DFA is qD = δ ( q N , ε ). So δ ( q D , ε ) = q D = δ ( q N , ε ). * N * D * N In many cases, q D = { q N }. However, when the NFA has the ε - transition from q N , the new DFA will have to include in its start states all the states that can be reached by ε .www.youtube.com/vkedco
  • ε-Closureswww.youtube.com/vkedco
  • Epsilon Closure: Definition ● When we deal with NFAs with ε-transitions, we have to keep track of where we can get to not only on symbols but also on ε (no input) ● ε-closure(q) = {p | there is a path from q to p consisting of only ε-transitions}www.youtube.com/vkedco
  • Example 1 0 2 1 ε ε q0 q1 q2 0 1 2 ε q0 {q0} {} {} {q1} q1 {} {q1} {} {q2} q2 {} {} {q2} {}www.youtube.com/vkedco
  • Example 1 1. ε − closure( q0 ) = { q0 , q1 , q2 }. 2. ε − closure( q1 ) = { q1 , q2 }. 3. δ ( q0 , ε ) = { q0 , q1 , q2 }. * 4. δ ( q0 ,0) = ε − closure(δ (δ * ( q0 , ε ) ,0) ) = ε − closure( δ ( { q0 , q1 , q2 } ,0) ) = ε − closure( δ ( q0 ,0) ∪ δ ( q1 ,0) ∪ δ ( q2 ,0) ) = ε − closure( { q0 } ∪ ∅ ∪ ∅ ) = ε − closure( { q0 } ) = { q0 , q1 , q2 }.www.youtube.com/vkedco
  • Equivalence of NFAs with NFAs with ε- transitions ● Theorem: If L is accepted by an NFA with ε- transitions, L is accepted by an NFA without ε- transitions ● Proof: Use ε-closure to get rid of ε-transitionswww.youtube.com/vkedco
  • Back to Example 1 Let s get rid of ε − transitions in Example 1. Let δ denote the new transition function that we obtain from δ . δ ( q 0 ,0) = ε − closure( δ ( q 0 ,0) ) = { q 0 , q1 , q 2 }. δ ( q 0 ,1) = ε − closure( δ ( q 0 ,1) ) = { q1 , q 2 }. δ ( q 0 ,2 ) = ε − closure( δ ( q 0 ,2) ) = { q 2 }. δ ( q1 ,0) = ε − closure( δ ( q1 ,0) ) = { }. δ ( q1 ,1) = ε − closure( δ ( q1 ,1) ) = { q1 , q 2 }. δ ( q1 ,2 ) = ε − closure( δ ( q1 ,2 ) ) = { q 2 }. δ ( q 2 ,0 ) = ε − closure( δ ( q 2 ,0 ) ) = { }. δ ( q 2 ,1) = ε − closure( δ ( q 2 ,1) ) = { }. δ ( q 2 ,2) = ε − closure( δ ( q 2 ,2) ) = { q 2 }. The final states are q 0 , q1 , q 2 .www.youtube.com/vkedco
  • Back to Example 1 0 1 2 0,1 1,2 q0 q1 q2 0,1,2www.youtube.com/vkedco
  • Conclusion If an NFA has ε-transitions, we can always get rid of them before constructing an equivalent DFAwww.youtube.com/vkedco
  • Regular Expressionswww.youtube.com/vkedco
  • Three Language Operations If L1 and L2 are the languages, L1 L2 = { x1 x 2 | x ∈ L1 and x 2 ∈ L2 }. If L is a language, the Kleene closure of L is L* = { x1 x 2 ...x n | n ≥ 0, x0≤ i ≤ n ∈ L}. If L is a language, then is L+ = { x1 x 2 ...x n | n ≥ 1, x1≤ i ≤ n ∈ L}.www.youtube.com/vkedco
  • Atomic Regular Expressions A regular expression is a string r that denotes the language L( r ) over some alphabet Σ . Three types of atomic regular expressions : 1. If a ∈ Σ , then L( a ) = { a} 2. L( ε ) = { ε } 3. L( ∅ ) = { }www.youtube.com/vkedco
  • Compound Regular Expressions Let r1 and r2 be regular expressions. 1. ( r1 + r2 ) is a regular expression. Then L( r1 + r2 ) = L( r1 ) ∪ L( r2 ). 2. ( r1 r2 ) is a regular expression. Then L( r1 r2 ) = L( r1 ) L( r2 ). 3. ( r ) is a regular expression. Then L ( r ) * ( ) = ( L( r ) ) . * *www.youtube.com/vkedco
  • Examples Regular expression = ab; L( ab ) = { ab}. Regular expression = ab + c; L( ab + c ) = { ab, c}. Regular expression = ba ; L( ba ) = { b, ba, baa, baaa,...} * * = {ba | n ≥ 0}. nwww.youtube.com/vkedco
  • Examples Regular expression | Language ( a + b) * ( ) L ( a + b ) = { a, b} . * * ( ab + ε ) L( ( ab + ε ) ) = { ab, ε }. ( a + b )( c + d ) { ac, ad , bc, bd }. ( abc ) L( ( abc ) ) = { ε , abc, abcabc, abcabcabc,...}. * * a *b * L( a *b * ) = { ε , a, b, aa, bb, abb, aaab,...}.www.youtube.com/vkedco
  • Converting Regular Expressions to NFAswww.youtube.com/vkedco
  • Atomic Reg Exps  NFAs a∈ Σ awww.youtube.com/vkedco
  • Atomic Reg Exps  NFAs ε εwww.youtube.com/vkedco
  • Atomic Reg Exps  NFAs ∅www.youtube.com/vkedco
  • Compound Reg Exps  NFAs ( r1 + r2 ) , where r1 , r2 are regular expressions r1 ε ε ε ε r2www.youtube.com/vkedco
  • Compound Reg Exps  NFAs ( r1 ) + , where r1 is regular expression ε ε r1 εwww.youtube.com/vkedco
  • Compound Reg Exps  Reg Languages ( r1 ) * ε ε r1 ε εwww.youtube.com/vkedco
  • Reg Exps  NFAsTheorem : If r is a regular expression, then there is an NFA N such that L( N ) = L( r ).Proof : We use induction on the number of operators in r.The base case is true forn = 0. Assume that the statement is true for k . Consider a regular expression q thathas k + 1 operators. Then q can be of the form ( r ) , ( r ) , r1 + r2 , r1 r2 .We know that * +r , r1 , and r2 have fewer than k + 1 operators. Thus, by the inductive hypothesis, thereare NFAs with the same languages. By construction, these regular expressions can becombined into larger NFAs with the same languages.www.youtube.com/vkedco
  • DFA  Reg Exps Theorem: If there is a DFA M then there is a regular expression R such that L(M) = L(R)www.youtube.com/vkedco
  • Equivalence Constructions NFA w/0 ε-trans NFA with ε-trans DFA Regular Expswww.youtube.com/vkedco
  • Pigeon Hole Principlewww.youtube.com/vkedco
  • Pigeon Hole Principle Formulation 1: If (n+1) pigeons fly through n holes, there is at least one hole through which at least two pigeons fly Formulation 2: If (n+1) objects are distributed among n sets, at least one set must contain at least two objects This principle is used in showing that some languages are not regularwww.youtube.com/vkedco
  • Pigeon Hole: Example 9 students take a test. Student X makes 7 errors. Each of the other students makes fewer errors. Did at least two students make the same number of errors?www.youtube.com/vkedco
  • Pigeon Hole: Example X 0 1 2 3 4 5 6 7 7 holes 8 studentswww.youtube.com/vkedco
  • Feedback Errors, comments to vladimir dot kulyukin at gmail dot comwww.youtube.com/vkedco
  • References & Reading Suggestions ● Davis, Weyuker, Sigal. Computability, Complexity, and Languages, 2nd Edition, Academic Press ● Brooks Webber. Formal Language: A Practical Introduction, Franklin, Beedle & Associates, Inc ● Hopcroft and Ullman. Introduction to Automata Theory, Languages, and Computation, Narosa Publishing Housewww.youtube.com/vkedco