Non Regular Language

Embed Size (px)

Citation preview

  • 7/31/2019 Non Regular Language

    1/25

    Nonregular Languages

    The language that cannot be expressed byany regular expression is called aNonregular language.

    The languages PALINDROME is theexamples of nonregular languages.

    Note: It is to be noted that a nonregular

    language, by Kleenes theorem, cant beaccepted by any FA or TG.

    1

  • 7/31/2019 Non Regular Language

    2/25

    Example

    Consider the language L = {, ab, aabb,aaabbb, } i.e. {anbn: n=0,1,2,3,}

    Suppose, it is required to prove that thislanguage is nonregular. Let, contrary, L bea regular language then by Kleenestheorem it must be accepted by an FA,say, F.

    2

  • 7/31/2019 Non Regular Language

    3/25

    Example contd

    Since every FA has finite number of states

    then the language L (being infinite)accepted by Fmust have words of lengthmore than the number of states. Which

    shows that, Fmust contain a circuit.

    For the sake of convenience suppose thatF has 10 states. Consider the word a9 b9from the language L and let the pathtraced by this word be shown as under

    3

  • 7/31/2019 Non Regular Language

    4/25

    Example Contd

    4

  • 7/31/2019 Non Regular Language

    5/25

    Example Contd

    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,

    5

  • 7/31/2019 Non Regular Language

    6/25

    Example Contd

    Moreover, there is another circuitgenerated by the states 9,10,9. Includingthe possibility of looping this circuit, F

    accepts the words a9(a4)m b9(b2 )n wherem, n=0,1,2,3,(m and n not being 0simultaneously).Which shows that F

    accepts words that are not belonging to L.

    6

  • 7/31/2019 Non Regular Language

    7/25

    Proof Contd

    Thus there is no FA which accepts thelanguage L. which shows, by Kleenestheorem, that the language L cant be

    expressed by any regular expression. Itmay be noted that apparently anbn seemsto be a regular expression of L, but in fact itis not. The observations made from this

    example, generalize the theorem (alsocalled the Pumping lemma) regarding theinfinite regular language as follows:

    7

  • 7/31/2019 Non Regular Language

    8/25

    Pumping Lemma

    Statement

    Let L be any infinite regular language (thathas infinite many words), defined over analphabet then there exist three strings x,

    y and z belonging to * (where y is not the

    null string) such that all the strings of theform xynz for n = 1,2,3, are the words in

    L.

    8

  • 7/31/2019 Non Regular Language

    9/25

    Pumping Lemma Contd

    Proof

    If L is a regular language, then according toKleenes theorem, there exists an FA, say, Fthat accepts this language.

    Now F, by definition, must have finite numberof states while the language has infinitelymany words, which shows that there is no

    restriction on the length of words in L, becauseif there were such restriction then the languagewould have finite many words.

    9

  • 7/31/2019 Non Regular Language

    10/25

    Pumping Lemma Contd

    Let w be a word in the language L, so that

    the length of word is greater than thenumber of states in F. In this case the pathgenerated by the word w, is such that it

    cannot visit a new state for each letter i.e.there is a circuitin this path.

    10

  • 7/31/2019 Non Regular Language

    11/25

    Pumping Lemma Contd

    The word w, in this case, may be divided

    into three parts.

    1. The substring which generates the pathfrom initial state to the state which is

    revisited first while reading the word w.This part can be called X and X can be anull string.

    11

  • 7/31/2019 Non Regular Language

    12/25

    Pumping Lemma Contd2. The substring which generates the circuit

    starting from the state which was lead by X.This part can be called as Y which cannot benull string.

    3. The substring which is the remaining part ofthe word after Y, call this part as Z. It may benoted that this part may be null string as the

    word may end after Y or Z part may itself bea circuit.

    12

  • 7/31/2019 Non Regular Language

    13/25

    Pumping Lemma Contd

    Thus the word may be written as w = xyzwhere x, y and z are the strings, also ycant be a null string. Now this is obvious

    that, looping the circuit successively, thewords xyyz, xyyyz, xyyyyz, will also beaccepted by this FA i.e. xynz, n=1,2,3, will be words in L.

    13

  • 7/31/2019 Non Regular Language

    14/25

    Pumping Lemma Contd

    Remark: In the above theorem, it is notaffected if the z-part has circuit. To provethe theorem it is only to find a circuit and

    then looping that circuit, is all that isneeded. While looping the circuit thevolume of the string y (or z) is pumped, so

    the theorem is also called the Pumpinglemma. Following are the examples

    14

  • 7/31/2019 Non Regular Language

    15/25

    Example

    Consider the following 6 states FA, say, Fwhich accepts an infinite language

    15

  • 7/31/2019 Non Regular Language

    16/25

    Example Contd

    Let the word w = bbbababa, belonging tothe language L, so that the length of word isgreater than 6 (the number of states in F).

    In this case the path generated by this wordis such that it cannot visit a new state foreach letter i.e. there is acircuit in this path.

    The word w, in this case, may be dividedinto three parts.

    16

  • 7/31/2019 Non Regular Language

    17/25

    Example Contd

    The substring which generates the pathfrom initial state to the state which isrevisited first while reading the word w.

    This can be called as part xand this maybe null string.

    The substring which generates the circuit

    starting from the start state which was leadby x, this part can be called as yand thiscannot be null string.

    17

  • 7/31/2019 Non Regular Language

    18/25

    Example Contd The substring which is the remaining part of the

    word after y, this part can be called as z. It maybe noted that this part may be null string as theword may end after y or z-part may itself be acircuit.

    Thus the word w may be written as w = xyz,where x, y, z are strings belonging to * and ycannot be null string.

    The state 2 is such that it is revisited first whilereading the word w. So the word w can bedecomposed, according to pumping lemma, asw = xyz = (b)(bba)(baba)

    18

  • 7/31/2019 Non Regular Language

    19/25

    Example Contd

    If y-part of w is continuously pumped, theresulting strings will be accepted by F andhence will be words in the language acceptedby F. Thus, by pumping lemma, the languageaccepted by F is regular.

    Remark: If the pumping lemma is applieddirectly on the language L = {an bn :n=0,1,2,3,}, it can be observed that for the

    word w = (aaa)(aaaabbbb)(bbb) where x = aaa, y = aaaabbbb and z = bbb

    19

  • 7/31/2019 Non Regular Language

    20/25

    Remarks Contd

    xyyz will contain as many number of as asthere are bs but this string will not belong to Lbecause the substring ab can occur at themost once in the words of L, while the string

    xyyz contains the substring ab twice.

    On the other hand if y-part consisting of onlyas or bs, then xyyz will contain number of as

    different from number of bs. This shows thatpumping lemma does not hold and hence thelanguage is not regular.

    20

  • 7/31/2019 Non Regular Language

    21/25

    Example

    Consider the language EQUAL, of strings,

    defined over = {a, b}, with number of asequal to number of bs, 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 } hasbeen proved nonregular.

    21

  • 7/31/2019 Non Regular Language

    22/25

    Example Contd

    Using the theorem that intersection of two

    regular languages is, regular; it can beproved that the EQUAL is not regular.

    Because if it is considered regular then thelanguage {an bn } will, being intersection ofregular languages, be regular language,

    which is impossible.

    22

  • 7/31/2019 Non Regular Language

    23/25

    Example contd

    23

    Following are the remarks regarding these examplesRemarks

    In the previous examples, languages are proved to

    be regular or nonregular using pumping lemma. Infact to prove a certain language to be regular, it is notneeded to use the full force of pumping lemma i.e. fora wordwith length greater than the number of states

    of the machine, decomposing the word into xyz andfor a language to be regular it is sufficient that xyyz isin L. The condition that xynz is in L for n>2, providesthat the language is infinite.

  • 7/31/2019 Non Regular Language

    24/25

    Example contd

    Consider the language PALINDROME and a

    word w = aba belonging to PALINDROME.Decomposing w = xyzwhere x=a, y=b, z=a. Itcan be observed that the strings of the formxynz for n=1,2,3, , belong toPALINDROME. Which shows that thepumping lemma holds for the languagePALINDROME (which is non regularlanguage). To overcome this drawback ofpumping lemma, a revised version ofpumping lemma is to be introduced.

    24

  • 7/31/2019 Non Regular Language

    25/25

    Assignment

    Describe the revised version of pumpinglemma with example

    Due date 11.12.2011

    25