Recap lecture 25 Intersection of two regular languages is regular, examples, non regular languages, example.

Slides:



Advertisements
Similar presentations
Properties of Regular Languages
Advertisements

Theory Of Automata By Dr. MM Alam
Lecture 9,10 Theory of AUTOMATA
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.
CS 310 – Fall 2006 Pacific University CS310 Pumping Lemma Sections:1.4 page 77 September 27, 2006.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf of Monash University.
Homework 4 Solutions.
FSA Lecture 1 Finite State Machines. Creating a Automaton  Given a language L over an alphabet , design a deterministic finite automaton (DFA) M such.
Lecture # 5 Pumping Lemma & Grammar
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.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
1 Recap lecture 27 Pumping lemma version II, proof, examples, Myhill Nerode theorem, examples.
Lecture # 12. Nondeterministic Finite Automaton (NFA) Definition: An NFA is a TG with a unique start state and a property of having single letter as label.
1 Chomsky Hierarchy of Languages & Pushdown Automata (PDA) Lecture # 6-7 Muhammad Ahmad Jan.
CS355 - Theory of Computation Regular Expressions.
CS 203: Introduction to Formal Languages and Automata
CSC312 Automata Theory Nonregular Languages Chapter # 10 by Cohen
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.
Lecture # 17 Theory Of Automata By Dr. MM Alam 1.
1 Recap lecture 28 Examples of Myhill Nerode theorem, Quotient of a language, examples, Pseudo theorem: Quotient of a language is regular, prefixes of.
Lecture # 8 (Transition Graphs). Example Consider the language L of strings, defined over Σ={a, b}, having (containing) triple a or triple b. Consider.
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
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.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Recap lecture 5 Different notations of transition diagrams, languages of strings of even length, Odd length, starting with b, ending in a (with different.
Kleene’s Theorem and NFA
Pumping Lemma.
Lecture # 2.
Transition Graphs.
Non-regular languages
CSE 3813 Introduction to Formal Languages and Automata
Pushdown Automata.
Lecture 9 Theory of AUTOMATA
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Non-deterministic Finite Automata (NFA)
Properties of Regular Languages
Infiniteness Test The Pumping Lemma Nonregular Languages
Recap lecture 29 Example of prefixes of a language, Theorem: pref(Q in R) is regular, proof, example, Decidablity, deciding whether two languages are equivalent.
Kleene’s Theorem Muhammad Arif 12/6/2018.
Properties of Regular Languages
Non-regular languages
Pumping Lemma.
Chapter 4 Properties of Regular Languages
Recap lecture 6 Language of strings, beginning with and ending in different letters, Accepting all strings, accepting non-empty strings, accepting no string,
Nonregular languages & the pumping lemma
Recap lecture 26 Example of nonregular language, pumping lemma version I, proof, examples,
Recap Lecture 16 Examples of Kleene’s theorem part III (method 3), NFA, examples, avoiding loop using NFA, example, converting FA to NFA, examples, applying.
Lecture 5 Theory of AUTOMATA
ReCap Chomsky Normal Form, Theorem regarding CNF, examples of converting CFG to be in CNF, Example of an FA corresponding to Regular CFG, Left most and.
Recap lecture 10 Definition of GTG, examples of GTG accepting the languages of strings:containing aa or bb, beginning with and ending in same letters,
Recap Lecture-2 Kleene Star Closure, Plus operation, recursive definition of languages, INTEGER, EVEN, factorial, PALINDROME, {anbn}, languages of strings.
Recap lecture 42 Row language, nonterminals defined from summary table, productions defined by rows, rules for defining productions, all possible productions.
Recap lecture 18 NFA corresponding to union of FAs,example, NFA corresponding to concatenation of FAs,examples, NFA corresponding to closure of an FA,examples.
Recap lecture 37 New format for FAs, input TAPE, START, ACCEPT , REJECT, READ states Examples of New Format of FAs, PUSHDOWN STACK , PUSH and POP states,
Recap Lecture 17 converting NFA to FA (method 3), example, NFA and Kleene’s theorem method 1, examples, NFA and Kleene’s theorem method 2 , NFA corresponding.
Recap lecture 11 Proof of Kleene’s theorem part II (method with different steps), particular examples of TGs to determine corresponding REs.
Recap lecture 19 NFA corresponding to Closure of FA, Examples, Memory required to recognize a language, Example, Distinguishing one string from another,
RECAP Lecture 7 FA of EVEN EVEN, FA corresponding to finite languages(using both methods), Transition graphs.
Recap lecture 23 Mealy machines in terms of sequential circuit.
Recap Lecture 15 Examples of Kleene’s theorem part III (method 3), NFA, examples, avoiding loop using NFA, example, converting FA to NFA, examples, applying.
Recap lecture 20 Recap Theorem, Example, Finite Automaton with output, Moore machine, Examples.
Finite Automaton with output
Recap Lecture-2 Kleene Star Closure, Plus operation, recursive definition of languages, INTEGER, EVEN, factorial, PALINDROME, {anbn}, languages of strings.
Recap Lecture 4 Regular expression of EVEN-EVEN language, Difference between a* + b* and (a+b)*, Equivalent regular expressions; sum, product and closure.
Recap Lecture 3 RE, Recursive definition of RE, defining languages by RE, { x}*, { x}+, {a+b}*, Language of strings having exactly one aa, Language of.
LECTURE # 07.
CHAPTER 1 Regular Languages
Presentation transcript:

Recap lecture 25 Intersection of two regular languages is regular, examples, non regular languages, example

Task Build an FA corresponding to FA1  FA2 where FA1 FA2 y2+ y1- a,b X1– X2+ a,b y1- y2+

also r2 = (a+b)((a+b)(a+b))* or ((a+b)(a+b))*(a+b) and FA2 be Solution of the Task Let r1=(a+b)*a and the corresponding FA1 be also r2 = (a+b)((a+b)(a+b))* or ((a+b)(a+b))*(a+b) and FA2 be b a a X1– X2+ b a,b y1- y2+ a,b

New States after reading Solution continued … To construct an FA corresponding to L1  L2 b a a a,b X1– X2+ y1- y2+ a,b b Old States New States after reading a b z1-(x1,y1) (x2,y2) z2 (x1,y2)  z3

New States after reading Solution continued … Old States New States after reading a b z2+(x2,y2) (x2,y1) z4 (x1,y1)  z1 z3 (x1,y2) z4 (x2,y1) (x2,y2)  z2 (x1,y2)  z3 The corresponding transition diagram may be as follows

Solution continued … a z1- z2+ b a a b b a z3 z4 b

Example Consider the language L = {Λ, ab, aabb, aaabbb, …} i.e. {an bn : n=0,1,2,3,…} Suppose, it is required to prove that this language is nonregular. Let, contrary, L be a regular language then by Kleene’s theorem it must be accepted by an FA, say, F. Since every FA has finite number of states then the language L (being infinite) accepted by F must have words of length more than the number of states. Which shows that, F must contain a circuit.

Example continued … For the sake of convenience suppose that F has 10 states. Consider the word a9 b9 from the language L and let the path traced by this word be shown as under a b 1- 3 5 7 9+ a a a a b b b b a 2 4 6 8 10

Example continued … But, looping the circuit generated by the states 3,4,6,5,3 with a-edges once more, F also accepts the word a9+4 b9, while a13b9 is not a word in L. It may also be observed that, because of the circuit discussed above, F also accepts the words a9(a4 )m b9, m = 1,2,3, … Moreover, there is another circuit generated by the states 9,10,9. Including the possibility of looping this circuit, F accepts the words a9(a4 )m b9(b2 )n where m,n=0,1,2,3,…(m and n not being 0 simultaneously).Which shows that F accepts words that are not belonging to L.

Example continued … Similarly for finding FAs accepting other words from L, they will also accept the words which do not belong to L. Thus there is no FA which accepts the language L. which shows, by Kleene’s theorem, that the language L can’t be expressed by any regular expression. It may be noted that apparently anbn seems to be a regular expression of L, but in fact it is not. The observations made from this example, generalize the theorem ( also called the Pumping lemma) regarding the infinite regular language as follows

Pumping Lemma Statement: Let L be any infinite regular language ( that has infinite many words), defined over an alphabet  then there exist three strings x, y and z belonging to *( where y is not the null string) such that all the strings of the form xynz for n=1,2,3, … are the words in L. Proof: If L is a regular language, then according to Kleene’s theorem, there exists an FA, say, F that accepts this language. Now F, by definition, must have finite no of states while the language has infinitely many words, which shows that there is no restriction on the length of words in L, because if there were such restriction then the language would have finite many words.

Proof continued … Let w be a word in the language L, so that the length of word is greater than the number of states in F. In this case the path generated by the word w, is such that it cannot visit a new state for each letter i.e. there is a circuit in this path. The word w, in this case, may be divided into three parts The substring which generates the path from initial state to the state which is revisited first while reading the word w. This part can be called x and x can be a null string.

Proof continued … The substring which generates the circuit starting from the state which was lead by x. This part can be called as y which cannot be null string. The substring which is the remaining part of the word after y, call this part as z. It may be noted that this part may be null string as the word may end after y or z part may itself be a circuit. Thus the word may be written as w = xyz where x,y and z are the strings, also y can’t be a null string.

Proof continued … Now this is obvious that, looping the circuit successively, the words xyyz, xyyyz, xyyyyz, … will also be accepted by this FA i.e. xynz, n=1,2,3, … will be words in L. Remark: In the above theorem, it is not affected if the z-part has circuit. To prove the theorem it is only to find a circuit and then looping that circuit, is all that is needed. While looping the circuit the volume of the string y (or z) is pumped, so the theorem is also called the Pumping lemma. Following are the examples

Example Consider the following 5 states FA, say, F which accepts an infinite language Let the word w = bbbababa, belonging to the language L, so that the length of word is greater than 6 (the number of states in F). a 1- 4 2+ 5 b 3 6+ a,b

Example continued … In this case the path generated by this word is such that it cannot visit a new state for each letter i.e. there is a circuit in this path. The word w, in this case, may be divided into three parts. The substring which generates the path from initial state to the state which is revisited first while reading the word w. This can be called as part x and this may be null string.

Example continued … 2. The substring which generates the circuit starting from the start state which was lead by x, this part can be called as y and this cannot be null string. The substring which is the remaining part of the word after y, this part can be called as z. It may be noted that this part may be null string as the word may end after y or z-part may itself be a circuit. Thus the word w may be written as w = xyz, where x,y,z are strings belonging to * and y cannot be null string.

Example continued … The state 2 is such that it is revisited first while reading the word w. So the word w can be decomposed, according to pumping lemma, as w = xyz = (b)(bba)(baba) If y-part of w is continuously pumped, the resulting strings will be accepted by F and hence will be words in the language accepted by F. Thus, by pumping lemma, the language accepted by F is regular. Remark: If the pumping lemma is applied directly on the language L = {an bn : n=0,1,2,3,…}, it can be observed that for the word w = (aaa)(aaaabbbb)(bbb)

Remark continued … where x = aaa, y = aaaabbbb and z = bbb xyyz will contain as many number of a’s as there are b’s but this string will not belong to L because the substring ab can occur at the most once in the words of L, while the string xyyz contains the substring ab twice. On the other hand if y-part consisting of only a’s or b’s, then xyyz will contain number of a’s different from number of b’s. This shows that pumping lemma does not hold and hence the language is not regular.

Example Consider the language EQUAL, of strings, defined over Σ={a,b}, with number of a’s equal to number of b’s, i.e. EQUAL = {Λ ,ab,aabb,abab,baba,abba,…} From the definition of EQUAL, it is clear that {an bn } = a* b*  EQUAL Obviously a* b* defines a regular language while {an bn } has been proved nonregular.

Example continued … Using the theorem that intersection of two regular languages is, regular; it can be proved that the EQUAL is not regular. Because if it is considered regular then the language {an bn } will, being intersection of regular languages, be regular language, which is impossible. Following are the remarks regarding these examples

Remarks In the previous examples, languages are proved to be regular or nonregular using pumping lemma. In fact to prove a certain language to be regular, it is not needed to use the full force of pumping lemma i.e. for a word with length greater than the number of states of the machine, decomposing the word into xyz and for a language to be regular it is sufficient that xyyz is in L. The condition that xynz is in L for n>2, provides that the language is infinite.

Remarks continued … 2. Consider the language PALINDROME and a word w = aba belonging to PALINDROME. Decomposing w = xyz where x=a, y=b, z=a. It can be observed that the strings of the form xynz for n=1,2,3, …, belong to PALINDROME. Which shows that the pumping lemma holds for the language PALINDROME (which is non regular language). To overcome this drawback of pumping lemma, a revised version of pumping lemma is introduced as follows

Pumping Lemma version II Statement: Let L be an infinite language accepted by a finite automaton with N states, then for all words w in L that have langth more than N, there are strings x,y and z ( y being non-null string) and length(x) + length(y)  N s.t. w = xyz and all strings of the form xynz are in L for n = 1,2,3, … Proof: The lemma can be proved, considering the following examples

Example Consider the language PALINDROME which is obviously infinite language. It has already been shown that the PALINDROME satisfies pumping lemma version I (previous version). To check whether the new version of pumping lemma still holds in case of the PALINDROME, let the PALINDROME be a regular language and be accepted by an FA of 78 states. Consider the word w = a85ba85.

Example continued … Decompose w as xyz, where x,y and z are all strings consisting of a’s while y is non-null string, s.t. length(x) + length(y)  78, which shows that the substring xy is consisting of a’s and xyyz will become amore than 85ba85 which is not in PALINDROME. Hence pumping lemma version II is not satisfied for the language PALINDROME. Thus pumping lemma version II can’t be satisfied by any non regular language. Following is another example in this regard

Example Consider the language PRIME, of strings defined over Σ={a}, as {ap : p is prime}, i.e. PRIME = {aa, aaa, aaaaa, aaaaaaa, …} To prove this language to be nonregular, suppose contrary, i.e. PRIME is a regular language, then there exists an FA accepts the language PRIME. Let the number of states of this machine be 345 and choose a word w from PRIME with length more than 345, say, 347 i.e. the word w = a347

Example continued … Since this language is supposed to be regular, therefore according to pumping lemma xynz, for n = 1,2,3,… are all in PRIME. Consider n=348, then xy348z = xy347yz = xyzy347 As x,y and z consist of a’s, so the order of x, y, z does not matter. Now xyzy347 = a347 y347, y being not null string and consisting of a’s it can be written y = am, m=1,2,3,…,345.

Example continued … Thus xy348z = a347 (am)347 = a347(m+1) Now the number 347(m+1) may not remain PRIME for m = 1,2,3, …, 345. Which shows that the string xy348z is not in PRIME. Hence pumping lemma version II is not satisfied by the language PRIME. Thus PRIME is not regular.