Complexity and Computability Theory I

Slides:



Advertisements
Similar presentations
Complexity and Computability Theory I Lecture #4 Rina Zviel-Girshin Leah Epstein Winter
Advertisements

Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
1 Introduction to Computability Theory Discussion3: Uses of the Pumping Lemma Prof. Amos Israeli.
CS21 Decidability and Tractability
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.
1 Introduction to Computability Theory Lecture4: Non Regular Languages Prof. Amos Israeli.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
Automata and Formal Languages Tim Sheard 1 Lecture 8 Pumping Lemma & Distinguishability Jim Hook Tim Sheard Portland State University.
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.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
1 Introduction to Computability Theory Lecture4: Non Regular Languages Prof. Amos Israeli.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Limitations.
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 Non-regular languages (Pumping Lemma)
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.4: Nonregular Languages) David Martin With some.
1 Non-regular languages. 2 Regular languages Non-regular languages.
Today Chapter 1: RE = Regular Languages, nonregular languages RL pumping lemma Chapter 2: Context-Free Languages (CFLs)
Complexity and Computability Theory I Lecture #13 Instructor: Rina Zviel-Girshin Lea Epstein Yael Moses.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
Complexity and Computability Theory I Lecture #2 Rina Zviel-Girshin Leah Epstein Winter
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.
Complexity and Computability Theory I Lecture #8 Instructor: Rina Zviel-Girshin Lea Epstein.
CS355 - Theory of Computation Regular Expressions.
CSCI 2670 Introduction to Theory of Computing September 13.
CS 203: Introduction to Formal Languages and Automata
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.
Complexity and Computability Theory I Lecture #5 Rina Zviel-Girshin Leah Epstein Winter
CSE 105 Theory of Computation Alexander Tsiatas Spring 2012 Theory of Computation Lecture Slides by Alexander Tsiatas is licensed under a Creative Commons.
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.
1 Advanced Theory of Computation Finite Automata with output Pumping Lemma Theorem.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
CSE 105 theory of computation
Non-regular languages - The pumping lemma
Formal Language & Automata Theory
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
PROPERTIES OF REGULAR LANGUAGES
CSE 3813 Introduction to Formal Languages and Automata
Complexity and Computability Theory I
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Intro to Theory of Computation
Pumping Lemma for Regular Languages some languages are not regular!
COSC 3340: Introduction to Theory of Computation
Lecture5 Non-regular languages
Infiniteness Test The Pumping Lemma Nonregular Languages
Regular Expression We shall build expressions from the symbols using simple operations include concatenation, union and kleen closure. Several intuitive.
Introduction to Finite Automata
Elementary Questions about Regular Languages
Non-regular languages
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CS21 Decidability and Tractability
Chapter 1 Regular Language - 02
Recap lecture 25 Intersection of two regular languages is regular, examples, non regular languages, example.
CHAPTER 1 Regular Languages
COSC 3340: Introduction to Theory of Computation
CSCI 2670 Introduction to Theory of Computing
Presentation transcript:

Complexity and Computability Theory I Lecture #7 Instructor: Rina Zviel-Girshin Leah Epstein

Rina Zviel-Girshin @ASC Overview Nonregular languages The pumping lemma Examples Rina Zviel-Girshin @ASC

Are all languages regular? No. Most of the languages are not regular. Why? A finite automaton has limited memory. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Example The language L = {0n1n | n>0} is not regular. Two sequences of same length: first of 0's and second of 1's. It is not regular because when we reach substring of 1’s we have to remember the length of the 0’s substring. The length is remembered by states - one state for each letter. The length of 0's substring can be any number. A finite automaton has a finite number of states. So it can not remember the length of 0’s substring. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC The pumping lemma The central theorem concerning regular languages is the pumping lemma. It determines the basic nature of regular languages. A basic property of a regular language is in each word (except for a small finite set of words) there is a part which can be repeated and the resulting word - "pumped" word - is still in the language. The lemma that allows the "pumping" is called the pumping lemma. Rina Zviel-Girshin @ASC

Examples of automata and finite languages If L(A) is finite, and number of states in A is n, then the longest word in L is less than n in length.  Example: A: A has 3 states. The language of A is all words of length 2 or less. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Finite Languages If L is finite then L is regular. Proof idea: Build an automaton for every word w in L: A(w). Add qstart with -transitions to each q0 of A(w) The resulting automaton recognizes L. Rina Zviel-Girshin @ASC

Examples of automata and infinite languages L= ab*c A: Each word in L has a path q0any number of loops on q1q2. Denote the path from q0 to q1 by x Denote the path from q1 to q1 by y Denote the path from q1 to q2 by z Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Examples (cont.) Each word in L has the following three parts: x – a substring on which A goes from q0 to q1 y – a substring on which A goes from q1 to q1 z – a substring on which A goes from q1 to q2  We can say that each word wL is xyz. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Examples (cont.) All the strings over the * We see that x and z can be . y is never . Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Pumping lemma If L is a regular language then there is a number n such that any string w  L of length at least n may be divided into three parts w=xyz such that: |y|>0 |xy| n for each i0 xyiz L Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Informally For each regular language there is a constant number n, such that any string of length more than n can be pumped. The pumped part is obviously should not be of length 0 (at least one letter). The parts before and after the "pumpable" part could be . The part we may pump is inside a prefix of length at most n. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Proof idea Any finite automaton without cycles can recognize only a finite language. An infinite language is created by automaton with loops. The infinite number of words is the result of repeating the loop any number of times. Each word in language L of length more than the number of states includes a path in a cycle (by the pigeonhole principle). Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Proof idea The part before the cycle is x. The cycle is y. The part after is z. The z part ends with an accepting state as the word is in L. The loop can be repeated any number of times and still go through z to an accepting state. Hence the y part can be pumped. We can repeat the cycle any number of times and still proceed through z to accepting state. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Formal Proof Let M be a DFA that recognizes L. Let n be the number of states of M. Let w be a string in L of length at least n. It has a prefix of length n. The sequence of states in automaton M that we went through while processing the prefix is q0 and one state for each letter read. After reading this prefix we have a sequence of n+1 length. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Formal Proof (cont.) As there are only n different states in automaton M at least one state has to be repeated while reading the prefix. Denote one of them r. The substring read before first appearance of r : x. The substring between first and second appearance: y. And the substring after second appearance of r till the end of the string: z. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Formal Proof (cont.) z ends with an accepting state f because the string is in L. y is the cycle in the automaton. y has at least length 1 because we move from state to state in the DFA only upon reading a letter. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Formal Proof (cont.) As there is a path from r to an accepting state f (z) there is a direct path q0 - r - f without going through the r cycle even once (xy0z=xz). On the other hand we can go through the cycle more than once and still get out from r to I (xyiz). There is no limit on a number of times we can do through the cycle. Q.E.D. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Usage of the lemma The main usage of pumping lemma is to prove that some language is not regular. The technique: Assume that the language is regular. Find a string w that has a length greater than n. Find a partition of w into x,y,z such that properties 1 and 2 of pumping lemma hold. Find an i such that xyiz is not in the language. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC L = {0m1m | m>0} Is L = {0m1m | m>0} regular? We will use pumping lemma to show that L is not regular. Assume to the contrary that L is regular. Let n be the pumping length given by the pumping lemma. We choose w= 0n1n . w is in L, |w|>n so by pumping lemma w can be divided into three parts w=xyz. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC L = {0n1n | n>0} x and y are both in prefix of length n and so are build of 0's. Denote the length of x by s and the length of y by t. Then : x=0s s0 y=0t t1,s+tn z=0n-s-t1n By pumping lemma if the language is regular then xyiz is in L for any i. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC L = {0n1n | n>0} Take i=2. The resulting word is xy2z = 0s02t0n-s-t1n = 0n+t1n . It is not in L as t1 and the number of 0 is greater than the number of 1. Thus we have a contradiction to the pumping lemma. That means: our assumption that L is regular is wrong. L is not regular language. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC L={an! | n0} Is L={an! | n0} regular? We will use pumping lemma to show that L is not regular. Assume to the contrary that L is regular. Let n’ be the pumping length given by the pumping lemma. We choose w= an! where n=max(n’,2) . w is in L, |w|>n’ so by pumping lemma w can be divided into three parts w=xyz. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC L={an! | n0} x and y are both in the prefix of length n and consist of a's only. Denote the length of x by s and the length of y by t. Then : x=as s>=0 y=at t>0,s+t<=n z=an!-t-s By pumping lemma if the language is regular then xyiz is in L for any i. Rina Zviel-Girshin @ASC

L={an! | n0} Take i=2. The resulting word is xy2z = an!+t . Now we proove that an!+t is not in L. We know that t>0 and n>=t that means n!+t <= n!+n < n!+(n+1) < n!*(n+1) = (n+1)! Thus we have a contradiction to the pumping lemma. That means: our assumption that L is regular is wrong. L is not regular language. Rina Zviel-Girshin @ASC

Rina Zviel-Girshin @ASC Any Questions? Rina Zviel-Girshin @ASC