Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?

Slides:



Advertisements
Similar presentations
Theory Of Automata By Dr. MM Alam
Advertisements

Properties of Regular Languages
Lecture 9,10 Theory of AUTOMATA
Summary Showing regular Showing non-regular construct DFA, NFA
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.
Automata and Formal Languages Tim Sheard 1 Lecture 9 Reasoning with DFAs.
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
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.
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.
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.
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.
Homework 4 Solutions.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
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.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
1 Non-regular languages. 2 Regular languages Non-regular languages.
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.
Regular Languages A language is regular over  if it can be built from ;, {  }, and { a } for every a 2 , using operators union ( [ ), concatenation.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
1 Strings and Languages. 2 Review Sets and sequences Functions and relations Graphs Boolean logic:      Proof techniques: – Construction, Contradiction,
1 Let L= { w= u v : u  {a, b}*, v  {c, d}* and |u|= |v|} 1.Design a context-free grammar that generates L. 2.Use your grammar and the construction from.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Closure.
TK PrasadPumping Lemma1 Nonregularity Proofs. TK PrasadPumping Lemma2 Grand Unification Regular Languages: Grand Unification (Parallel Simulation) (Rabin.
Chapter 4 Pumping Lemma Properties of Regular Languages Decidable questions on Regular Languages.
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.
Properties of Regular Languages
Chapter 6 Properties of Regular Languages. 2 Regular Sets and Languages  Claim(1). The family of languages accepted by FSAs consists of precisely the.
Conversions & Pumping Lemma CPSC 388 Fall 2001 Ellen Walker Hiram College.
CS 203: Introduction to Formal Languages and Automata
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Regular Languages ภาษาปกติ. Jaruloj Chongstitvatana Outline Regular expressions Regular languages Equivalence between languages accepted by.
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
1 Find as many examples as you can of w, x, y, z so that w is accepted by this DFA, w = x y z, y ≠ ε, | x y | ≤ 7, and x y n z is in L for all n ≥ 0.
Cs466(Prasad)L11PLEG1 Examples Applying Pumping Lemma.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen.
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.
1 Closure E.g., we understand number systems partly by understanding closure properties: Naturals are closed under +, , but not -, . Integers are closed.
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.
1 Use the pumping theorem for context-free languages to prove that L= { a n b a n b a p : n, p ≥ 0, p ≥ n } is not context-free. Hint: For the pumping.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
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
PDAs Accept Context-Free Languages
Lecture 9 Theory of AUTOMATA
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Properties of Regular Languages
Infiniteness Test The Pumping Lemma Nonregular Languages
Deterministic PDAs - DPDAs
Properties of Regular Languages
Elementary Questions about Regular Languages
Non-regular languages
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
Chapter 4 Properties of Regular Languages
Non-Regular Languages
Recap lecture 25 Intersection of two regular languages is regular, examples, non regular languages, example.
CHAPTER 1 Regular Languages
Presentation transcript:

Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?

Limitations of FA Many languages are non-regular: {a n b n | n = 0,1,2,…} {0 i 2 | i  0,1,2,…} {0 p | p is a prime number } the set of all well-formed parentheses over the alphabet  ={(, )} the set of all palindromes over the alphabet  ={a, b} …...

Why Impossible? We want to prove that L = {a i b i | i = 0,1,2,…} is non-regular. Prove by contradiction: Assume that there is a DFA M that recognizes L. Let n be the total number of states in M. Consider the path followed by the input string a n b n in M: q π(0) q π(1) q π(n) q π(n+1) q π(2n) abb b …... aa

Why Impossible? Since M has only n states, there must be at least one state visited twice in the first n transitions. Let this state be visited at the i th and the j th steps, where j > i. By skipping the loop, a n-(j-i) b n should also be accepted, but this is contradictory since a n-(j-i) b n  L q π(0) q π(i) = q π(j) q π(2n)  F The path in M when reading a n b n

Another Example We want to prove that L = {1 k 2 | k > 0} is non- regular. Prove by contradiction: Assume that there is a DFA M that recognizes L. Let n be the total number of states in M. M should also accept the string 1 n 2 q π(0) q π(1) q π(2) qπ(n2)qπ(n2) 11 …... 11

Another Example Since n 2  n and M has only n states, there must be at least two equal states from q π(0) to q π( n 2 ). Let q π(i) = q π(j) be the first repeated state where j-i = m  n. By repeating the loop one more time, 1 (n 2 +m) is also accepted by M, which is a contradiction, since (n 2 +m) cannot be a square (the next square after n 2 is (n+1) 2 but n 2 +m < (n+1) 2 ). q π(0) q π(i) = q π(j) q π( n 2 )  F The path in M when reading 1 n 2 a loop of length m

Pumping Lemma L: regular language There exists a constant n s.t. every string z  L with |z|  n We can find z = uvw v   i.e. |v|  1 |uv|  n For all i  0, string uv i w also in L

Proof of Pumping Lemma If L is a regular language, there are DFAs that recognize L. Let n be the number of states in one such DFA (called M) recognizing L. If z is a word in L with |z| = k  n: where z(i) is the i th symbol of the string z. Since k  n and M has only n states, there must be at least one repeated states from q π(0) to q π(k). Let q π(i) be the first such repeated state. q π(0) q π(1) q π(2) q π(k) z(2)z(k) …... z(1)z(3)

Proof of Pumping Lemma Let u be the string obtained by traversing from q π(0) to q π(i), and v be the string obtained by traversing the loop once (|v|  1). In the traversal from q π(0) to q π(i) and then through the loop once back to q π(i), nothing except q π(i) repeats, so |uv|  n. By traversing the loop 0 or more times, we obtain uv i w where i  0. These strings should all be accepted by M since they can all reach q π(k) which is a final state in M. a path in M q π(0) q π(k)  F q π(i)

Using Pumping Lemma Use the proof of pumping lemma Suppose L is regular, then we can construct a DFA M that accepts L Suppose M has n states Carefully choose a string z where |z| = k  n

Using Pumping Lemma Claim that when accepting z, there must be at least one state visited twice in the first n transitions (by pigeonhole principle) Let the state be q i,0  i  n q π(0) = q 0 qiqi q π(k)  F The path in M when reading z

Using Pumping Lemma Claim that By skipping the loop or repeating the loop for certain times to generate new string z’ M does not accept z’ So contradiction occurs

Example of using pumping lemma Consider a language L: The set of all strings over {0,1} with number of ‘1’s is three times number of ‘0’s Show that L is non-regular

Example Assume L is regular Let n be the constant in the lemma Let z = 0 n 1 3n  L uvw = z = 0 p 0 q 0 n-p-q 1 3n, where |uv| = p+q  n, |v|=q  1

Example By Pumping Lemma, uv i w is also in L for all i 0 p 0 qi 0 n-p-q 1 3n  L for all i  0 For i=0, uv i w = 0 n-q 1 3n  L There is a contradiction

Example Suppose L is regular, then we can construct a DFA M that accepts L Suppose M has n states Let z = 0 n 1 3n  L When accepting z, there must be at least one state visited twice in the first n transitions Let the state be q i,where 0  i  n

Example The path when reading z can be illustrated by the following diagram: By skipping the loop, we have z ’ = 0 n-q 1 3n  L By the property of M, z’ should be accepted by M So by contradiction, there is no such M q π(0) = q 0 qiqi q π(k)  F 0p0p 0q0q 0 n-p-q 1 3n

Example We want to prove that L = {1 y | y is a prime} is non- regular. We can make use of the Pumping Lemma: If L is a regular language, it follows the Pumping Lemma. Let n be the constant in the lemma. Consider z=1 p where p is a prime and p  n. (The number of primes are infinite, so such a p exists.) According to the lemma, we can write z into uvw where |uv|  n and |v|  1 and uv i w  L for all i  0.

Example Let |v| = m. Consider the case when i = p+1. Then |uv i w| = p + pm = p (m+1), which is not a prime. So it is not true that uv i w is in L for all i  0. Therefore L is not a regular language.

Example We can also prove that L = {1 y | y is a prime} is non-regular by following the argument directly: Assume that there is a DFA M that recognizes L. Let n be the total number of states in M. We know that the number of primes are infinite, so there exists a prime p  n. q π(0) q π(1) q π(p-1) q π(p) 11 …... 11

Example Since p  n and M has only n states, there must be at least two equal states from q π(0) to q π(p). Let them be q π(i) and q π(j) where j-i = m > 0. By repeating the loop p+1 times, 1 (p-m) + (p+1)m = 1 p(m+1) is also accepted by M, which is a contradiction since p(m+1) is not a prime. q π(0) q π(p)  F a path in M A loop of length m q π(i) = q π(j)

Closure Properties Regular sets are said to be closed under an operation op if the application of op to a regular set will result in a regular set. For example, if the union of two regular sets will result in a regular set, regular sets are said to be closed under union.

Closure Properties Are regular sets closed under: Union ? Concatenation ? Kleene Closure ? Why?

Closure Properties Are regular sets closed under complementation? If A is a regular set over , is A’ =  *-A regular? Why? If A is regular, there exists a DFA M recognizing A. Given M, we can construct a DFA M’ for A’ by copying M to M’ except that all final states in M are changed to non-final, and all non-final states to final.

Closure Properties Are regular sets closed under intersection? If A and B are regular sets, is C = A  B regular? Why? C = A  B = A  B Since regular sets are closed under union and complementation, they are also closed under intersection.

Closure Properties (Summary) Regular sets are closed under: Union Concatenation Kleene Star Complementation Intersection Reversal