Toc Ass2
Toc Ass2
Toc Ass2
2
1. Prove that the language {x | x is the binary representation of 3n for some n ∈ N} is not regular.
2
Let L={x | x is the binary representation of 3n for some n ∈ N}
We claim that none of the strings in L are equivalent to each other. Hence, L has infinite
equivalent classes. Hence by Myhill Nerode, DFA for L isn’t possible. So, L is not regular.
2 2
To see this, let u=binary representation of 3n and v=binary representation of 3m for any
arbitrary m,n such that m 6= n.
2
Now, let w=binary representation of 3n . Now, wu belongs to L. Hence, for u and v to belong to
equivalent classes, wv should also belong to L. Now, we claim that wv can’t belong to L for any
v.
The length of the string w=n2 log2 3 and the length of string v=n2 log2 3. Hence the length of the
2 2
string wv=(n2 + m2 )log2 3. So, if wv is in L, then wv=binary representation of 3n +m , as no
2
other string can have this length in L. But wv=(binary representation of 3n ) followed by (binary
2 2 2
representation of 3m ) which can never be the binary representation of 3n +m . Hence, wv can’t
belong to L for any v.
Hence, we have infinite equivalent classes for L.
Hence, L is not regular.
2. Prove that the language {0m 1n | m 6= n} ⊆ {0, 1}∗ is not regular.
As a challenge, construct a clean proof using the pumping lemma only. However, no extra credit will be
given for this.
Prove its minimality by giving a string zq,q0 for each pair of distinct states q, q 0 ∈ Q such that exactly
one of δ(q, b 0 , zq,q0 ) is in A. (Proof of correctness of your automaton is not required.)
b zq,q0 ) and δ(q
The DFA is made in the diagram above, final states are circled and initial state has an arrow.
The states as given are s1 , s2 , s3 , s4 , s5 and s6 . A = {s2 , s5 }
q q0 zq,q0 δ(q,
b zq,q0 ) b 0 , zq,q0 )
δ(q
s1 s2 ”11” s1 s2
s1 s3 ”1001” s4 s5
s1 s4 ”1” s2 s4
s1 s5 ”11” s1 s5
s1 s6 ”1101” s2 s4
s2 s3 ”01” s5 s4
s2 s4 ”11” s2 s4
s2 s5 ”101” s2 s4
s2 s6 ”11” s2 s3
s3 s4 ”1” s5 s4
s3 s5 ”01” s4 s5
s3 s6 ”01” s4 s5
s4 s5 ”11” s1 s2
s4 s6 ”1” s5 s4
s5 s6 ”11” s5 s3
As we can clearly see from the table that only one of the column 4 or 5 have some state in A ( s2
or s5 ). Therefore the DFA made is minimal as we are able to provide some string for each pair
of state.
4. Let Lk ⊆ {0, 1}∗ be the language defined as Lk = {x | |x| ≥ k and the EXOR of the last k bits of x is 1}.
Prove that any DFA that recognizes Lk has at least 2k states. (By the way, observe that Lk is recognized
by an NFA with O(k) states.)
Let the DFA be (Q, Σ, δ, q0 , ), where we keep track of last k bits of the string processed by the
DFA. The state subspace therefore consists of all strings of length k. Q = 0, 1k . The transition
replaces the last bit, therefore on reading bit b, we remove the first bit from the state and append
b at the end. Formally, δ(y1 y2 ...yk , b) = y2 y3 y4 ...b. The final states are all strings such that their
xor is 1.
This motivation will help us prove the final claim. Now consider strings of length k as the
equivalent classes, which represent last k bits of the strings. Our claim: no two strings of length
k are equivalent with respect to the language Lk .
Proof
Let us assume that some string x and some string y where |x| = |y| = k are equivalent with
respect to Lk . Which means, for all z ∈ Σ∗ , xz ∈ Lk if and only if yz ∈ Lk . That is for all z,
either both xz and yz are in L, or neither are. Now let us assume x = x1 x2 ...xk and y = y1 y2 ...yk .
Let i be the first index of dissimilarity between, that is the smallest i|xi 6= yi . Now let there be
a string of length k − i of all 0s, now the new last k bits are x1 x2 ..xi 0...0 and x1 x2 ...yi 0...0, one
of these strings is 0 and one of them is 1. Which means only one of xz and yz is accepted by Lk .
Therefore we arrive at a contradiction. Hence, no two strings are equivalent, and the minimum
number of states the DFA has by Myhill-Nerode Theorem is number of substrings of size k,
which is 2k .
NOTE: We observe that no-where have we imposed the condition on length. For that we would
need to add another parameter to state (k − string, bool), this bool will be made 1 when we have
read k bits and the final states will only consist of states with bool = 1. This would increase the
number of states therefore the lower bound remains the same.
5. We all know that the set of strings over the alphabet {a, b} containing an equal number of occurrences
of ab and ba is regular. However, what if the alphabet is {a, b, c}? Prove that the language
is regular.
2. Recall the proof of the pumping lemma.
Basically we are starting from D1 and if we currently transiting in D2 means we have visited
q odd number of times because there is no transition to remain in D1 after reaching q. and if
transiting in D1 means we have visited q even number of times because either we have came back
from D2 or have not visited q even once. remove all accepting states from A1 and only consider
0
accepting states of A with slight modification around q guarantees us to accept the string only
if we have visited q odd number of times.
Property of infinite regular language and selection of a state q accordingly
Infinite regular language means that for every natural number n there exist a string w such that
|w|>n. So over a finite state space of size k consider a string in the language whose length equal
to k+1 there must be one state which would be visited twice by pigeon hole principle.
And since this string we considered is in the language we will definitely reach some final state.
So the state which is visited twice, Can be visited multiple times along the same loop as we did
in pumping lemma. Let’s name this state as q.
0
Formation of Lq for Odd and Lq for Even and their regularity
One can classify all the string that comes to this state q in set of even visits and odd visits and
can design separate languages for them. Let say as the hint suggests that Lq is the language
0
that accept those strings which visits q odd number of times and Lq is the one which accept the
strings only if the strings visits q even number of times.
As we have proven above that we can design a DFA accepting the strings which falls under the
0
definition of Lq simultaneously we can do the same for Lq by just changing the accepting states
as the following
0
Anew = (A U q - q) if q were accepting state in D1. else only A.
0
Hence this proves that both Lq and Lq is regular.
Final conclusion
0
Till now we have proven that such language like Lq and Lq exists for particular state and are
infinite regular.
Now consider the fact that regular languages are closed under complementation. Hence if we
consider regular language Lsub
q which would also be regular. Because
Lsub
q = L − L q = L ∩ Lcomplement
q . And hence it is regular because regular languages are closed
under intersection.
0
Now note the fact that any string which is part of Lq cannot be part of Lq by the definition
0
of these languages. Which suggest us that Lq would be subset of Lsubq because anything which
is not in Lq but present in L would lies inside Lsub
q . So that proves the fact that Lq
sub
is also
0
infinite regular language because we have proved above that Lq is infinite regular and super set
of infinite set is also infinite.
Here comes the final point that L was the original language which was regular and Lq and Lsub
q
the languages exists corresponding to it’s DFA state q which are two infinite regular language
from the above explanation.
Both these language have null intersection with each other and everything which is not in Lq
present in Lsub sub
q . Hence it is proved that there exist two language L1 = Lq and L2 = Lq which
satisfy the above claim of L = L1 ∪ L2 and L1 ∩ L2 = ∅.