Intro to Theory of Computation

Slides:



Advertisements
Similar presentations
Lecture 8 From NFA to Regular Language. Induction on k= # of states other than initial and final states K=0 a a* b a c d c*a(d+bc*a)*
Advertisements

8/27/2009 Sofya Raskhodnikova Intro to Theory of Computation L ECTURE 2 Theory of Computation Finite Automata Operations on languages Nondeterminism L2.1.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
NFAs Sipser 1.2 (pages 47–54). CS 311 Fall Recall… Last time we showed that the class of regular languages is closed under: –Complement –Union.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Lecture 3UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
Costas Busch - RPI1 Single Final State for NFAs. Costas Busch - RPI2 Any NFA can be converted to an equivalent NFA with a single final state.
Fall 2006Costas Busch - RPI1 Regular Expressions.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Regular.
Fall 2004COMP 3351 Single Final State for NFA. Fall 2004COMP 3352 Any NFA can be converted to an equivalent NFA with a single final state.
1 Single Final State for NFAs and DFAs. 2 Observation Any Finite Automaton (NFA or DFA) can be converted to an equivalent NFA with a single final state.
Lecture 7 Sept 22, 2011 Goals: closure properties regular expressions.
1 NFAs accept the Regular Languages. 2 Equivalence of Machines Definition: Machine is equivalent to machine if.
Fall 2006Costas Busch - RPI1 Properties of Regular Languages.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
1 Regular Languages Finite Automata eg. Supermarket automatic door: exit or entrance.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 A Single Final State for Finite Accepters. 2 Observation Any Finite Accepter (NFA or DFA) can be converted to an equivalent NFA with a single final.
Fall 2004COMP 3351 Regular Expressions. Fall 2004COMP 3352 Regular Expressions Regular expressions describe regular languages Example: describes the language.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
Lecture 5 Sept 06, 2012 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
CHAPTER 1 Regular Languages
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011.
CSCI 2670 Introduction to Theory of Computing September 13.
Regular Expressions Costas Busch - LSU.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
 2004 SDU Lecture4 Regular Expressions.  2004 SDU 2 Regular expressions A third way to view regular languages. Say that R is a regular expression if.
CSE 105 theory of computation
Properties of Regular Languages
CSE 105 theory of computation
Regular Expressions Sections:1.3 page 63 September 17, 2008
Single Final State for NFA
Intro to Theory of Computation
Intro to Theory of Computation
Intro to Theory of Computation
Intro to Theory of Computation
Closure Properties for Regular Languages
CSE322 PROPERTIES OF REGULAR LANGUAGES
Properties of Regular Languages
CS 154, Lecture 3: DFANFA, Regular Expressions.
COSC 3340: Introduction to Theory of Computation
4. Properties of Regular Languages
Intro to Theory of Computation
CSCI 2670 Introduction to Theory of Computing
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing
Closure Properties of Regular Languages
CS21 Decidability and Tractability
Intro to Theory of Computation
Language Recognition (12.4)
CS21 Decidability and Tractability
CSE 105 theory of computation
Chapter 1 Regular Language
CSCI 2670 Introduction to Theory of Computing
NFAs accept the Regular Languages
CSCI 2670 Introduction to Theory of Computing
COSC 3340: Introduction to Theory of Computation
Intro to Theory of Computation
Intro to Theory of Computation
Intro to Theory of Computation
Intro to Theory of Computation
CSCI 2670 Introduction to Theory of Computing
COSC 3340: Introduction to Theory of Computation
COSC 3340: Introduction to Theory of Computation
CSE 105 theory of computation
Presentation transcript:

Intro to Theory of Computation LECTURE 4 Last time: Equivalence of NFAs and DFAs Today: Closure properties of regular languages Equivalence of NFAs, DFAs and regular expressions CS 464 Sofya Raskhodnikova 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Operations on languages Regular Operations on languages Complement: A = { w | w  A } Union: A  B = { w | w  A or w  B } Union: A  B = { w | w  A or w  B } Intersection: A  B = { w | w  A and w  B } Reverse: AR = { w1 …wk | wk …w1  A } Concatenation: A  B = { vw | v  A and w  B } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w1 …wk | k ≥ 0 and each wi  A } Star: A* = { w1 …wk | k ≥ 0 and each wi  A } 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

I-clicker problem (frequency: AC) Let L be the set of words in English. Then 𝑳 ∩𝑳 𝑹 is The set of English words in alphabetical order, followed the same words in reverse alphabetical order. {𝑤∣𝑤 is an English word or an English word written backwords}. {𝑤∣𝑤 is an English word that is a palindrom}. None of the above. {madam, dad, but, tub, book}

Closure properties of the class of regular languages THEOREM. The class of regular languages is closed under all 6 operations. If A and B are regular, applying any of these operation yields a regular language. 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Sofya Raskhodnikova; based on slides by Nick Hopper Closure under reverse Theorem. The reverse of a regular language is also regular Proof: Let L be a regular language and M be a DFA that recognizes it. Construct an NFA 𝑴 ′ recognizing LR: Define 𝑴 ′ as M with the arrows reversed. Make the start state of M be the accept state in 𝑴 ′ . Make a new start state that goes to all accept states of M by ε-transitions. ε ε ε 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

New construction for A  B Construct an NFA M: L(MA)=A ε ε L(MB)=B 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Concatenation operation Concatenation: A  B = { vw | v  A and w  B } Theorem. If A and B are regular, A  B is also regular. Proof: Given DFAs M1 and M2, construct NFA by connecting all accept states in M1 to the start state in M2. ε L(M1)=A L(M2)=B ε 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Concatenation operation Concatenation: A  B = { vw | v  A and w  B } Theorem. If A and B are regular, A  B is also regular. Proof: Given DFAs M1 and M2, construct NFA by connecting all accept states in M1 to the start state in M2. Make all states in M1 non-accepting. ε L(M1)=A L(M2)=B ε 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Sofya Raskhodnikova; based on slides by Nick Hopper Star operation Star: A* = { w1 …wk | k ≥ 0 and each wi  A } Theorem. If A is regular, A* is also regular. ε ε L(M)=A ε 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

The class of regular languages is closed under Regular operations Union: A  B = { w | w  A or w  B } Union: A  B = { w | w  A or w  B } Concatenation: A  B = { vw | v  A and w  B } Star: A* = { w1 …wk | k ≥ 0 and each wi  A } Other operations Complement: A = { w | w  A } Intersection: A  B = { w | w  A and w  B } Reverse: AR = { w1 …wk | wk …w1  A } 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Sofya Raskhodnikova; based on slides by Nick Hopper Regular expressions In a regular expression, we can use Constants: ε ,  , a set Σ, members of Σ. Regular operations: *,  , ∪ Examples: 0*1* (01)* 0*1*(ε 0) L(R) = the language regular expression R describes = { w | w has a run of 0s followed by a run of 1s} = the set of all strings over the alphabet Σ={0,1} 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Sofya Raskhodnikova; based on slides by Nick Hopper Precedence *  ∪ EXAMPLE R1*R2  R3 = ( ( R1* ) R2 )  R3 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Sofya Raskhodnikova; based on slides by Nick Hopper Regular expressions: examples 1) 2) 3) { w | w has exactly one character 1 } 0*10* { w | w has length ≥ 3 and its 3rd symbol is 0 } (01)(01) 0 (01)* { w | every odd position of w is a 1 } (1(01))* (ε  1) 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Regular expressions to NFAs Theorem. Every regular expression has an equivalent NFA. Proof: Induction on the length of regular expression R. Base case: length 1 Inductive step: follows from closure of the class of regular languages under the regular operations. R = ε R =   R =  11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

I-clicker problem (frequency: AC) What should the induction hypothesis be? Suppose some regular expression of length 𝑘 can be converted an NFA, for some 𝑘∈ℕ. Suppose all regular expressions of length 𝑘 can be converted an NFA, for some 𝑘∈ℕ. Suppose all regular expressions of length at most k can be converted an NFA, for some 𝑘∈ℕ. None of the above. {madam, dad, but, tub, book}

Regular expression to NFA Transform (1(0  1))* to an NFA ε 1 1,0 ε 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

NFAs to regular expressions Theorem. Every NFA has an equivalent regular expression. Proof idea: Transform NFA to a regular expression by removing states and relabeling the arrows with regular expressions. 01*0 1 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

Sofya Raskhodnikova; based on slides by Nick Hopper Generalized NFAs Each transition is labeled with a regular expression Unique and distinct start and accept states No transitions to the start state No transitions from the accept state 11/19/2018 Sofya Raskhodnikova; based on slides by Nick Hopper

G accepts w if it finds q0q1…qk, w1…wk: wi is generated by R(qi,qi+1) Generalized NFAs a  b a*b a qs q qa G accepts w if it finds q0q1…qk, w1…wk: wi is generated by R(qi,qi+1) w = w1w2…wk q0=qs, qk=qa R(qs,q) = a*b R(qa,q) = Ø R(q,qs) = Ø