5 - Non-Regularity

ucla | CS 181 | 2024-04-22 14:25


Table of Contents

First Non. Reg. Lang.

  • L=0n1n : n1
  • Consider an automaton M with P states. Suppose we have a binary string w=0P1PL
  • By the P.P., this string must have a loop in the automaton.
  • Suppose the loop is on 0 (although there should be a loop on both).
    • Let x be the substring prior to the loop (00k)
    • Let y be the substring in the loop ($0{k+1}…0{p-1}$)
    • Let z be the substring after the loop (0p11p)
  • If M accepts xyz, it accepts xyyz BUT xyyzL.

Pumping Lemma

  • Let L be a reg. lang., then pN s.t. every wL of length p can be written as w=xyz where
    • x,y,z are strings
    • yε
    • $xy\le p$
    • xyizL, iN
  • i.e., all sufficiently long strings in the language can be pumped
  • a pumping length p is at least the number of states in the DFA(?), thus for strings valid to the lemma, they must visit at least 1 state more than once -> a loop

    Contrapositive

  • $\forall p\space:\space \exists w\in L,\spacew\ge p$
  • x,y,z:
    • w=xyz
    • yε
    • $xy\le p$
    • i : xyizL
  • then, this implies L is nonregular
  • this is NOT bidirectional i.e. some nonregular langs satisfy pumping langs

    Examples

  • L=10n1n
    • consider the string 10p1p, then there are 2 cases:
    • case 1: y is the first 1 pumping down makes thee\ string no longer in the lang, thus lang is nonreg
    • case 2: y is in the 0p string, then pumping down makes the number of 0s number of 1s, thus xz (we pumped out y) not in the lang L is nonreg
  • L=1n2
    • consider w=1p2
    • $p^2\ltxy^2z=xyz+y=p^2+y$
      • note that adding a single symbol should make the number of 1s to be (p+1)2=p2+2p+1 chars long
    • and since $y\le pwecansayintheedge(best)casey=p$
    • s.t. $p^2\lexyz+y\le p^2 +p\lt p^2+2p+1=(p+1)^2$
    • thus xy2zLL is nonregular
  • L=w:w=wR
    • consider w=0p10p
    • then y0p is fragile s.t. pumping up or down will make the number of 0s on the left be more or less than the number of 0s after the 1, which is not in the language, thus L is nonregular
  • L=ww:w0,1
    • consider w=0p10p1 s.t. y0p (the first part)
    • then pumping y up or down will lead to the first half of the string != the second half, thus not in the lang => L is nonreg
  • $L={w:w\in \mathbb{P}}(\mathbb{P}=$primes)
    • consider w=0q s.t. qP:qp
    • then consider w=xyyqz s.t. $xyy^qz=xyz+qy=q+qy=q(y+1)$
    • thus the size of this string is a composite number which can never be a prime number, thus the string xyyqzLL is nonreg
  • Σ=0,1,,9; L=wΣ: fractional part of PI starts with w
    • e.g. L=ε,1,14,141,1415,14159,
    • consider w=14159265358979 s.t. $w=p$
    • sps. xyiz is pumpable i , then it means that as we take i to the limit 3.xyiz3.xyyyy which is a rational number while π is not
    • thus i s.t. xyiz is not in the language => L is nonreg

      Proving non-regularity using closure properties

  • Instead of applying the contrapositive of the pumping lemma (P.L.), we can show with closure under regular operations that a language is regular or non-regular
  • e.g., L=0n1m : nm
    • we can show ${0^1^}\setminus L={0^n1^n\space:\space n\in \mathbb Z^+}isnonregular,andbcsetminusisaregularoperationundertheclosurepropertyofsetminus,L$ must be non-regular
    • proving this using P.L. is a little more complex, consider the string 0p1p+a where we don’t yet know the value of a such that the string is in thee language but can be pumped to prove nonregularity
    • consider $w=xyy^{\frac{a}{y}}z$ s.t. the number of 0s should equal thee number of 1s to prove nonregularity
    • then we can say that there are p+a ones and $p+\frac a{y}y0s,thusforthenumberofystobeintegervalues,wemutensureaisalwaysdiivisiblebyywhichmeansweshouldchoosea=p!thenwegetp+p!ones=p+\frac{p!}{y}y$ 0s
    • thus the number of 0s = num 1s is not in the lang, thus the lang is nonreg

      Common Pitfalls

  • reg langs closed under infinite union
    • false
  • subsets of reg langs are reg
    • False: LnonregΣ
  • subsets of nonreg langs are nonreg
    • False: 0n1n
  • nonreg langs are closed under complement
    • True: bc if not true the complement off a reg lang could be non reg which is not. possible bc LregLreg
  • nonreg langs closed under intersection
    • False: consider intersection of 2 nonreg langs that resultss in the set of the empty string e.g. 0n1n1n0n=ε