5 - Non-Regularity
ucla | CS 181 | 2024-04-22 14:25
Table of Contents
First Non. Reg. Lang.
- Consider an automaton
with states. Suppose we have a binary string - 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
be the substring prior to the loop ( ) - Let
be the substring in the loop ($0{k+1}…0{p-1}$) - Let
be the substring after the loop ( )
- Let
- If
accepts , it accepts BUT .
Pumping Lemma
- Let
be a reg. lang., then s.t. every of length can be written as where are strings$ xy \le p$
- i.e., all sufficiently long strings in the language can be pumped
- a pumping length
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 loopContrapositive
$\forall p\space:\space \exists w\in L,\space w \ge p$ :$ xy \le p$
- then, this implies
is nonregular - this is NOT bidirectional i.e. some nonregular langs satisfy pumping langs
Examples
- consider the string
, then there are 2 cases: - case 1:
is the first 1 pumping down makes thee\ string no longer in the lang, thus lang is nonreg - case 2:
is in the string, then pumping down makes the number of 0s number of 1s, thus (we pumped out ) not in the lang is nonreg
- consider the string
- consider
$p^2\lt xy^2z = xyz + y =p^2+ y $ - note that adding a single symbol should make the number of 1s to be
chars long
- note that adding a single symbol should make the number of 1s to be
and since $ y \le p y =p$ s.t. $p^2\le xyz + y \le p^2 +p\lt p^2+2p+1=(p+1)^2$ - thus
is nonregular
- consider
- consider
- then
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 is nonregular
- consider
- consider
s.t. (the first part) - then pumping
up or down will lead to the first half of the string != the second half, thus not in the lang => L is nonreg
- consider
$L={w: w \in \mathbb{P}} \mathbb{P}=$primes)- consider
s.t. then consider s.t. $xyy^qz = xyz +q y =q+q y =q( y +1)$ - thus the size of this string is a composite number which can never be a prime number, thus the string
is nonreg
- consider
;- 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.,
- we can show ${0^1^}\setminus L={0^n1^n\space:\space n\in \mathbb Z^+}
L$ must be non-regular - proving this using P.L. is a little more complex, consider the string
where we don’t yet know the value of 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 ones and $p+\frac a{y } y a y a=p! p+p! 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
- we can show ${0^1^}\setminus L={0^n1^n\space:\space n\in \mathbb Z^+}
- reg langs closed under infinite union
- false
- subsets of reg langs are reg
- False:
- False:
- subsets of nonreg langs are nonreg
- False:
- False:
- 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
- True: bc if not true
- nonreg langs closed under intersection
- False: consider intersection of 2 nonreg langs that resultss in the set of the empty string e.g.
- False: consider intersection of 2 nonreg langs that resultss in the set of the empty string e.g.