CS355 - Theory of Computation Regular Expressions.

Slides:



Advertisements
Similar presentations
Properties of Regular Sets
Advertisements

Pumping Lemma Problem: Solution:
Lecture 9,10 Theory of AUTOMATA
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
CS355 – The Mathematics and Theory of Computer Science Reductions.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Mount Holyoke College 2 Nonregular languages? We now know: –Regular languages may be specified either.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
Courtesy Costas Busch - RPI1 More Applications of the Pumping Lemma.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
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.
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
1 Non-regular languages. 2 Regular languages Non-regular languages.
Extra on Regular Languages and Non-Regular Languages
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Introduction to CS Theory Lecture 3 – Regular Languages Piotr Faliszewski
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Closure.
January 9, 2015CS21 Lecture 31 CS21 Decidability and Tractability Lecture 3 January 9, 2015.
CS 3240 – Chapter 4.  Closure Properties  Algorithms for Elementary Questions:  Is a given word, w, in L?  Is L empty, finite or infinite?  Are L.
Formal Definition of Computation Let M = (Q, ∑, δ, q 0, F) be a finite automaton and let w = w 1 w w n be a string where each wi is a member of the.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
Non-Context-Free Languages Section 2.3 CSC 4170 Theory of Computation.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1 Chapter 1 Regular Languages Some slides are in courtesy.
Nonregular Languages How do you prove a language to be regular? How do you prove a language to be nonregular? A Pumping Lemma.
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.
Regular Languages Chapter 1 Giorgi Japaridze Theory of Computability.
CS 154 Formal Languages and Computability March 17 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
 2004 SDU Lecture8 NON-Context-free languages.  2004 SDU 2 Are all languages context free? Ans: No. # of PDAs on  < # of languages on  Pumping lemma:
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
Complexity and Computability Theory I Lecture #12 Instructor: Rina Zviel-Girshin Lea Epstein.
Dept. of Computer Science & IT, FUUAST Automata Theory 2 Automata Theory III Properties of Regular Languages 1.Closure 2.Union 3.Concatenation 4.Complement(Negation)
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Theory of Computation Automata Theory Dr. Ayman Srour.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
CSE 105 theory of computation
Foundations of Computing Science
Standard Representations of Regular Languages
PROPERTIES OF REGULAR LANGUAGES
FORMAL LANGUAGES AND AUTOMATA THEORY
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Regular Expression We shall build expressions from the symbols using simple operations include concatenation, union and kleen closure. Several intuitive.
CSE 105 theory of computation
COSC 3340: Introduction to Theory of Computation
Pumping Lemma September 29, 2006
CS21 Decidability and Tractability
Recap lecture 26 Example of nonregular language, pumping lemma version I, proof, examples,
Context-Free Languages
Chapter 1 Regular Language - 02
COSC 3340: Introduction to Theory of Computation
CS21 Decidability and Tractability
CSE 105 theory of computation
Recap lecture 25 Intersection of two regular languages is regular, examples, non regular languages, example.
CSCI 2670 Introduction to Theory of Computing
CSE 105 theory of computation
Presentation transcript:

CS355 - Theory of Computation Regular Expressions

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Regular Expressions In maths one can use operations + and × to build up expressions like: (12 + 5) × 2 (= 34) Similarly, can build regular operations to build expressions describing languages. An example is: (0 1)1* = a language!! In this case it is the language consisting of all strings starting with a 0 or 1 followed by zero or more 1’s (1 *).

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Regular Expressions We let R + represent RR* –In other words, R + has all strings that are one or more concatenation of strings from R i.e. RR* (01 + )* = {w | every 0 in w is followed by at least one 1}

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Regular Expressions Which of these are value languages for the regular expression: (00)*1(0 1)*? 0, 1, 010, 0010, , , No - must be at least one 1 1 Yes 010No – must be two 0’s 0010Yes Yes Yes Yes

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Regular Expressions In regular expression shorthand is used and concatenation symbol ( )is not used –(0 1)0* is shorthand for (0 1) 0* The precedence order in regular expressions is: star operation, concatenation and then union, unless parentheses are used to change the order.

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Regular Expressions The expression (0 1)* is the language consisting of all possible strings of 0’s and 1’s. If the alphabet Σ = {0,1}, we can write Σ as shorthand for (0 1). If Σ is any alphabet, the regular expression Σ describes the language of all strings of length 1. Σ* is the language of all strings over the alphabet. Σ*0 is the language that contains all strings ending in a 0. The language (0Σ*) (Σ*1) consists of all strings that either start with a 0 or end with a 1.

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Regular Expression A language is regular if some regular expression describes it.

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Nonregular Languages Finite automaton are powerful machines but they do have limitations. There are some languages that can not be recognised by any finite automaton. At first glance some languages may seem regular but are in fact nonregular and vice versa!!!

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Pumping Lemma Pumping Lemma is a technique used to show that if a language does not have a special property then it is not regular. The property states that all strings in the language can be “pumped” and still belong to that class A language can be pumped if any sufficiently long string, having length at least the pumping length, in the language can be broken into pieces that can be repeated to produce an even longer string in the language.

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Pumping Lemma Thus, if there is a pumping lemma for a given language class, any language in the class will contain an infinite set of finite strings all produced by a simple rule given by the lemma.

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Pumping Lemma - Theorem If A is a regular language, then there is a number p (the pumping length) where, if s is any string in A of length at least p, then s may be divided into three pieces, s = xyz, satisfying the following conditions: 1.For each i ≥ 0, xy i z A, 2.|y| > 0, and 3.|xy| ≤ p. x or z may be ε, but condition 2 does not allow y to be ε.

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Pumping Lemma to prove a language is not regular Assume language B is regular in order to obtain a contradiction. Use pumping lemma to guarantee existence of a pumping length p such that all strings of length p or greater in B can be pumped. Find a string in B that has length p or greater but that cannot be pumped. Finally, demonstrate that s cant be pumped by considering all ways of dividing s into x, y and z and for each such division, finding a value i where xy i z B. Let us look at examples of this.

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Limitations of the Pumping Lemma The Pumping Lemma can be used to prove that a language is not regular, however, it can’t be used to prove that a language is regular. Just because you can’t think up the right string does not mean that someone else cant.

Dr. A. Mooney, Dept. of Computer Science, NUI Maynooth Examples Examples. Think about: –Is L = {0 i x | i ≥ 0, x {0,1}* and |x| ≤ i} regular? –Is L = {0 i | i is prime} regular?