Regular Expressions Sections:1.3 page 63 September 17, 2008

Slides:



Advertisements
Similar presentations
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Advertisements

Regular expressions Regular languages Sipser 1.3 (pages 63-76)
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Regular expressions Regular languages Sipser 1.3 (pages 63-76)
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
CS 310 – Fall 2006 Pacific University CS310 Converting NFA to DFA Sections:1.2 Page 54 September 15, 2006.
CS 310 – Fall 2006 Pacific University CS310 Regular Expressions Sections:1.3 page 63 September 18, 2006 September 20, 2006.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
Lecture 3: Closure Properties & Regular Expressions Jim Hook Tim Sheard Portland State University.
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.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
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.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
Lecture 8 Sept 29, 2011 Regular expressions – examples Converting DFA to regular expression. (same works for NFA to r.e. conversion.) Converting R.E. to.
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 Non-Deterministic Automata Regular Expressions.
CS 310 – Fall 2006 Pacific University CS310 Homework 2 & JFLAP September 22, 2006.
Lecture 5UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 5.
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.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong DFA to regular.
Theory of Languages and Automata
Theory of Computation, Feodor F. Dragan, Kent State University 1 Regular expressions: definition An algebraic equivalent to finite automata. We can build.
Prof. Busch - LSU1 NFAs accept the Regular Languages.
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
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
Regular Expressions Chapter 6. Regular Languages Regular Language Regular Expression Finite State Machine L Accepts.
CSCI 2670 Introduction to Theory of Computing September 13.
Regular Expressions Section 1.3 (also 1.1, 1.2) CSC 4170 Theory of Computation.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
 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.
1 Introduction to the Theory of Computation Regular Expressions.
CSCI 2670 Introduction to Theory of Computing September 7, 2004.
CSCI 2670 Introduction to Theory of Computing September 11, 2007.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
Theory of Computation Automata Theory Dr. Ayman Srour.
Theory of Languages and Automata By: Mojtaba Khezrian.
Theory of Languages and Automata By: Mojtaba Khezrian.
WELCOME TO A JOURNEY TO CS419 Dr. Hussien Sharaf Dr. Mohammad Nassef Department of Computer Science, Faculty of Computers and Information, Cairo University.
CSE 105 theory of computation
Regular Expressions.
CSE 105 theory of computation
Single Final State for NFA
Intro to Theory of Computation
COT 4210 Lecture Notes - 3 By Njegos and Monika.
CS 154, Lecture 3: DFANFA, Regular Expressions.
Definitions Equivalence to Finite Automata
Definitions Equivalence to Finite Automata
NFAs, DFAs, and regular expressions
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
Pumping Lemma September 29, 2006
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Definitions Equivalence to Finite Automata
CSE 105 theory of computation
CSCI 2670 Introduction to Theory of Computing
CSC312 Automata Theory Kleene’s Theorem Lecture # 12
CHAPTER 1 Regular Languages
CSCI 2670 Introduction to Theory of Computing
CSCI 2670 Introduction to Theory of Computing
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:

Regular Expressions Sections:1.3 page 63 September 17, 2008 CS310 Regular Expressions Sections:1.3 page 63 September 17, 2008

Regular Expressions Use regular operations (Union, Concat, Kleene Star) and languages to create a regular expression R whose value is a language L(R) not unique in general order of operations: *, concat, U R = 0*10*, L(R)={w | w has exactly one 1}

Regular Expressions R = 0*10*, L(R)={w | w has exactly one 1} Many programming languages contain a Regular Expression library str =~ /0*10*/ # Perl anyone? ∑ is used to represent one symbol from the language

Exercise {w | (w starts with 0 and has odd length) or (w starts with 1 and has even length) } NFA? How do we write this as a RE?

Definition An expression R is Regular if: R= a, a є ∑ R= ε R=Ø R= R1 U R2 , R1 , R2 are regular R= R1R2 , R1 , R2 are regular R= R1* , R1 is regular Theorem: A language is regular if and only if some regular expression describes it Can be represented by an NFA

Proof Lemma (1.55): If L is described by a regular expression R, then there exists an NFA that accepts it Proof: For each type of regular expression, develop an NFA that accepts it. R= a, a є ∑ R= ε R=Ø R= R1 U R2 , R1 , R2 are regular R= R1R2 , R1 , R2 are regular R= R1* , R1 is regular

Example aa* U aba*b*

Exercise {w | every odd position of w is 1 } NFA? How do we write this?

Exercise {w | w does not contain 110 } NFA? How do we write this?

Exercise {w| w contains even # 0s or exactly two 1s} NFA? How do we write this?

Proof Lemma: If a language is regular, it is described by a regular expression Proof Idea: If a language is regular, there exists a DFA that accepts it. We need to convert a DFA to a regular expression. Steps: Convert DFA to GNFA Convert GNFA to Regular Expression GNFA?!

Generalized NFA NFA where the transitions may have regular expressions as labels rather than just ∑ or ε Reads blocks of symbols from the input Wait, why are we doing this? to build up the regular expression slowly from the DFA aa ab* ab U ba a* qstart ε (aa)* qaccept ab b

GNFA aa ab* ab U ba a* qstart ε (aa)* qaccept Special case of GNFA that we will use! ab b Start state transitions to every other state, no transitions to start state Single accept state, transition to it from every other state, no way out, Start state != accept state Except for the start and accept states, one arrow goes from every state to every other state (except the start state) and also from every state to itself.

DFA to GNFA 1 , 0 1 1 , 0 Add new start state with ε- transitions to old start state and Ø to every other state Ø means you never take the transition Replace multiple transitions in same direction with Union If no transition exists between states, add transitions with Ø labels (just as placeholders)

DFA to Regular Expression 5 State GNFA 3 State DFA 4 State GNFA 2 State GNFA 3 State GNFA 4 State GNFA 2 states How many transitions? What do the labels on the transitions look like? We can reduce the GNFA by one state at a time Regular Expression

GNFA to Regular Expression Each GNFA has at least 2 states (start and accept) To convert GNFA to Regular Expression: GNFA has k states, k >= 2 if k > 2 then Produce a GNFA with k-1 states repeat 1 (1*0*)* qaccept qstart

GNFA to k-1 States Pick any state in the machine that is not the start or accept state and remove it Fix up the transitions so the language remains the same (R1(R2)*R3) U R4 R4 R3 R1 This change needs to be made for every pair of states connected through the removed state Rip this out! R2

Example, NFA to Regular Expression a, b b