You are on page 1of 16

CS340: Theory of Computation

Lecture 24
Some examples on the notion of context-free languages.
Eg.: A “ tw | #a pwq ă #b pwq ă #c pwqu Is A regular?

Let’s use pumping lemma to prove otherwise. Given k, choose z “ ak bk`1 ck`2 , z P A. Let
now, z “ uvwxy, s.t. vx ‰ ϵ, and |vwx| ď k.
We would have to break it into several cases. One of the several cases is: v contains only a’s
and y contains only b’s so v “ am , y “ bk ; 1 ď m ` l ď k.
Let i “ 3, we have thus the pumped string uv 3 wx3 y “ ak`2m bk`2l`1 ck`2 .
Since vx ‰ ϵ, we have either m ě 1, and l ě 1.
If m ě 1, then k ` 2m ě k ` 2, which would imply that uv 3 wx3 y R A.
If l ě 1, then k ` 2l ` 1 ě k ` 2, which would again imply, that uv 3 wx3 y R A.

Other cases follow (when v, y contain only c1 s, try to pump down).


A is not a CFL.

Eg.: A “ tan wwR an | n ě 0, w P ta, bu˚ u. Is A a CFL?

S Ñ aSa | C C Ñ aCa | bCb | ϵ


It can be thought of as the the grammar of wwR , padded with a’s.

Eg.: A “ tan bj an bj | n, j ě 0u. Is A a CFL?

Similar to proving that no grammar has ww represented. Take ak bk ak bk , and proceed accord-
ingly.

Eg.: A “ tan bn cj n ě ju. Is A not a CFL?

It is not a CFL. While enumeratig cases in the pumping lemma with z “ ak bk ck P A, let us
consider a single case, where v consists of b’s, and x consists of c’s. Take i “ 0, we would have
ak bk´m ck´l R A.

Eg.: A “ tai bj ak | k ą i ` ku. Is A a CFL?

Taking intuition from how an NPDA will handle this. We can start pushing a’s onto the stack,
and then pop while b’s come until the stack is empty. After which we start pushing onto the stack,
while reading b’s, and again start popping when a’s are encountered again. The stack must remain
not-empty after the starting.
S Ñ ABC A Ñ aAb | ϵ B Ñ bB | b C Ñ bCa | ϵ

Formal model of computation


Finite automata + infinite two-way tape with read/write functionality ñ Turing machine
The notion of computability is same as computability on a turing machine.
2

Deterministic Turing Machine

Q Read/write tape ...


(left to right)
$
Finite state
Input tape
as input

Finite-state automata + semi-infinite automata (infinite to the right and delimited on the left
with a marker $)
Head can move both left and right, and can read as well as write on the tape.
Infinitely many cells to the right of the finite input string, contain a special blank character \.

Operations of a Turing Machine


1. Start with the start state s and the head scanning the left end marker $.
2. Each step, read the symbol on the tape, under its head.
3. Depending on the symbol and the current state, write a new symbol on that tape cell.
4. Move its head left or right, and change to a new state.
5. Accept input by entering a special accept state.
6. Reject input by entering a special reject state.

Formal definition of Turing Machine

M “ pQ, Σ, Γ, $, \, δ, s, t, rq
Σ : finite input alphabet
Γ : finite tape alphabet Σ Ď Γ
\ P Γ ´ Σ : blank symbol
$P Γ ´ Σ : left end marker
s P Q : start state
t P Q : accept state
r P Q : reject state
δ : Q ˆ Γ Ñ Q ˆ Γ ˆ tL, Ru
δ is the transition function, and we have δpp, aq “ pq, b, loomo
d on q
P tL, Ru

Assumptions:
- @p P Q, Dq P Q s.t. δpp, $q “ δpq, $, Rq
1 1 1 1
- b P Γ, Dc, c P Γ and d, d P tL, Ru s.t. δpt, bq “ pt, c, dq and δpr, bq “ pr, c , d q. That is, once
M enters accept/reject state, it never leaves it.

Eg.: Construct a TM that accepts tan bn cn | n ě 0u


1. Start in s, and scan to the right to ensure that the input is of the form a˚ b˚ c˚ . (this
includes, writing to the tape, the same symbol read. Also, write an end marker to the end of the
tape %.)
2. Scan the input over rounds to match one a, b and c and erase these symbols.
3

Lecture 25
Configurations of a Turing Machine
Tape of M consists of a string y\w where y P Γ˚ . A configuration is P Q ˆ ty \w | ysinΓ˚ u ˆ N.
A configuration of TM: pp, z, nq, where p is state P Q, z is the current content on the tape,
and n ě 0 is the current position of the head on the tape.
Start configuration: ps, $ x\w , 0q
1
Next configuration relation: ÝÑ.
M

For an infinite string z, let zn , be the nth symbol in z, and snb pzq string obtained by substituting
zn with b.
#
1 pq, snb pzq, n ´ 1q if δpp, zn q “ pq, b, Lq
pp, z, nq ÝÑ
M pq, snb pzq, n ` 1q if δpp, zn q “ pq, b, Rq

˚ 1
α ÝÑ β be the reflexive-transitive closure of ÝÑ
M M
˚
Thus we have, M accepts x P Σ˚ , if ps, $ x\w , 0q ÝÑ pt, y, nq.
M
LpM q “ tx P Σ˚ | M accepts xu
˚
M rejects x P Σ˚ , if ps, $ x\w , 0q ÝÑ pr, y, nq.
M

M halts on input x P Σ˚ if it either accepts or rejects x.


M loops on input x P Σ˚ if it neither accepts nor rejects x.

Total Turing Machine: A Turing Machine that halts on all inputs is called a total TM.

A Ď Σ˚ is called recursive if A “ LpM q for a total TM.


A Ď Σ˚ is called recursively enumerable (r.e.) if A “ LpM q for a TM.

Eg.: tan bn cn | n ě 0u is recursive.

Eg.: A “ tww | w P ta, bu˚ u


A is recursive since we can define a total TM M , s.t. LpM q “ A.
Working of M on x:
- scan left to right till the first \- replace it with a right end marker %, and check that the
number of symbols in x is even.
- in each pass from right to left, M marks the first unmarked a, b as á, b́.
- in each pass from left to right M marks the first unmarked a, b as à, b̀.
1 1
Eg: Let the tape content for Γ “ ta, b, $, \, %, a‘ , b‘ , a , b u
4

$ aabbbaabbb \ \\
$ aabbbaabbb % \\
$ à à b̀ b̀ b̀ á á b́ b́ b́ % \ \
$ \ \ b̀ b̀ b̀ \ \ b́ b́ b́ % \ \

Recursive and recursively enumerable sets


Every recursive set is recursively enumerable.
Not every TM is equivalent to a total TM.

Recursive sets are closed under complementation.


Suppose A Ď Σ˚ is recursive. Then there exists a total TM s.t. LpM q “ A. Switch the accept
1 1
and reject states, resulting M : LpM q “ Σ ´ A.
This construction does not work for r.e. sets. Because, rejecting and not accepting is not the
1
same in a general TM. M will still loop on the strings M loops on. Such strings and neither
accepted nor rejected by either machines.

Claim: if both A, and Ā are r.e., then A is recursive.

Lecture 26
Proving the claim: if both A, and Ā are r.e., then A is recursive.

Let LpM1 q “ A and LpM2 q “ Ā. Construct M , that on input x runs both on M1 and M2 ,
simultaneously on two tracks of the tape. If M1 accepts, M accepts, and if M2 accepts then M
rejects.

if x P A ñ x P LpM1 q ñ M1 accepts ñ M accepts.


if x R A ñ x P LpM2 q ñ M2 accepts ñ M rejects.
This implies that M is a total TM.

Decidable / Semi-decidable
A property P is decidable, iff the set of all strings satisfying P is a recursive set.
P is decidable if tx | P pxqu is recursive.
A property P is semi-decidable, iff the set of all strings satisfying P is a r.e.
P is semi-decidable if tx | P pxqu is r.e.
5

Turing machines: Equivalent Models


Multiple tapes
For instance, a three-tape TM, is equivalent in expressive power to a one-tape TM. In each step,
the machine reads three symbols under its heads, and based on the current state, writes something
on the tape, moves the head and enters a new state.

The transition function is of the type δ : Q ˆ Γ˚ Ñ Q ˆ Γ˚ ˆ tL, Ru3 .


Now consider a machine N with an expanded tape, where each track contains the contents of
the tape of M . Also exactly one symbol on each track is marked used to represent which symbol
on which track is being read. Thus the tape symbols would be from Σ or would be $ or a triple
1 1
of the form pc, d, eq P tΓ Y Γ u3 , where Γ “ tĉ | c P Γu, where ĉ is the marked element of the track.

Two-way infinite tapes


Two way tapes do not add any power. Just fold the tape someplace and simulate it on the tracks
of a one-way infinite tape.

Two way stacks


A finite state machine with a two-way read only input head and two stacks is as powerful as a
Turing machine.

Universal Machines
An observation about the power of Turing machines: there exists Turing machines that can
simulate other Turing machines whose descriptions are presented as a part of the input. First
a encoding scheme needs to be fixed, so that the other machine can read and decode the en-
coded machine M . Consider the first line of the encoding representing the machine is as follows:
0n 10m 10k 10s 10t 10r 10u 10v 1. This might indicate that the machine has n states, from 0 to n ´ 1,
6

it has m tape symbols, represented 0 to m ´ 1, of which the first k represent the input symbols
and s, t, r are start, accept and reject states, and endmarker and blank symbol are u, v.
The remainder of the string may represent the various transition in δ. For eg. 0p 101 10q 10b 1,
which might encode the transition ppp, aq, pq, b, Lqq.
Te exact details of the encoding is not necessary, the only requirement is that it should be easy
enough to interpret.

Once we have the encoding of the TM, we can create a Universal Turing Machine U , s.t.
LpU q “ tM #x | x P LpM qu. In other words, given the encoding of the machine M , and the string
x over input alphabet, separated by a #, we can have, and U accepts M #x ðñ M accepts x.

How does U work?


1. Check if encoding of M and x are valid. If not, reject immediately.
2. U does a step by step simulation of M over x.
[This might work as follows, by having three tracks. The description of the machine is copied
on the top track and the input string on the middle track. The bottom track may remember the
current state of M and current position of the read/write head.]

Since the input alphabet of input machine M might be different from the input alphabet of
U , which might mean that a single symbol in x might be represented as a string of symbols in U
and vice versa. In general, to simulate each step of M , we might require many steps of U .

Working of the universal Turing machine


U takes as input an encoding of a TM M and a string x, and simulates M on x. It halts and
accepts if M halts and accepts. It halts and rejects if M halts and rejects, and it loops if M loops.

Instead of a blind simulation, can we do something better, can one build a TM which on input
M #x, halts and accepts if M halts and accepts, and halts and rejects, if either M halts and
rejects, or it loops?

Lecture 27
Consider the sets,
HP “ tM #x | M halts on xu
M P “ tM #x | x P LpM qu
We shall establish that HP, M P are r.e. but not recursive.

Technique of Diagonalization
It was used to show that there is not a one-to-one correspondence between 2N and N.
Suppose such a function f : N Ñ 2N , exists which is onto. Consider the infinite two-dimensional
matrix which is 1 at the position i, j if j P f piq and 0 otherwise.
7

0 1 2 3 4 ...
f p0q 1 0 0 1 1
f p1q 1 0 1 0 0
f p2q 0 0 0 1 1
...

We can construct a new set which does not appear on the list by complementing the main
diagonal.

Theorem: HP is not recursive.


This can be proved using Cantor’s diagonalization argument. For x P t0, 1u˚ let Mx denote
the Turing machine with input alphabet t0, 1u whose encoding over t0, 1u˚ . (If x is not a valid
encoding then we replace Mx with a trivial and fixed TM). In this way we get a list of Turing
machines Mϵ , M0 , M1 , M01 ..., containing all possible Turing machines with input alphabet t0, 1u
indexed by strings t0, 1u˚ . Assume that the universal machine can distinguish between Mx from
x for the purpose of simulation.

Now consider an infinite two-dimensional matrix indexed along the top by strings in t0, 1u˚
and down the left by the TMs in the list. The matrix contains an H in position x, y if Mx halts
on input y and an L if Mx loops on input y.

ϵ 0 1 00 01 ...
Mϵ H L L H H
M0 H L H L L
M1 L L L H H
...

The xth row of the matrix describes for each input string y whether or not Mx halts on y.
Suppose there exists a total TM K accepting the set HP ; i.e. a machine that for any given x and
y could determine the x, y entry of the above table. Thus on the input M #x, K halts and accepts
if M halts on x and K rejects if M loops on x.

Now, consider a machine N that on input t0, 1u˚ ,


1. constructs Mx #x from x and writes Mx #x on its tape.
2. runs K on the input Mx #x, accepting if K rejects and going into a trivial loop if K accepts.
Now that N is essentially complementing the diagonal of the above matrix, then for any
x P t0, 1u˚

N halts on x ðñ K rejects Mx #x (definition of N )


ðñ Mx loops on x (assumption about K)

This says that N ’s behaviour is different from Mx on at least one string, namely x. But since
the list was to contain all the Turing machines over the input alphabet t0, 1u, including N , which
means this is a contradiction.

Theorem: M P is not recursive.


8

Suppose there exists a total TM K, s.t. LpKq “ M P . Given a TM M and input x. To check
if M halts on x. Build a new TM NM that does the following. Similar to M , NM accepts if M
accepts or rejects. For all x P Σ˚ , NM accepts x iff M halts on x.
For any M and x to check if M halts on x. Construct NM and run K on input NM #x. By
1 1
assumption K is a total TM. But then we can construct a total K s.t. LpK q “ HP . This is a
contradiction.

Lecture 28-29
HP is not recursive, HP is r.e. M P is not recursive, M P is r.e. [HP , M P is not r.e.]

- Is it decidable if a TM M accepts ϵ?

- Is it decidable if a TM M , LpM q “ ϕ?

- Is it decidable if a TM M , LpM q “ Σ˚ ?

- Is it decidable if for a TM M , LpM q is regular?

- Is it decidable if for a TM M , LpM q is a CFL?

- Is it decidable if for a TM M , LpM q is recursive?

Is ϵ P LpMq?
Let there exist a total TM K such that given an input machine M , accepts if ϵ P LpM q and rejects
1
if not. We will show that if such a K exists then DK (another total TM) such that given M #x,
accepts if M halts on x and rejects otherwise (basically solves the halting problem) and hence we
will arrive at a contradiction.

Is it decidable if a TM M accepts ϵ?
Is tM | ϵ P LpM qu recursive?

Suppose D a total TM K that can decide if a given TM accepts ϵ, i.e. LpKq “ tM | ϵ P LpM qu.
1 1
Then we can construct a total TM K s.t. LpK q “ HP .
Given a TM M and x, to determine if M halts on x. Construct M1 that on input y works as
follows:
1. Erases its input y.
2. Writes x on the tape.
3. Runs M on input x. [M, x are hard-coded in M1 ]
4. Accepts if M halts on x.

if M halts on x, M1 accepts y for all input y.


#
Σ˚ if M halts on x
LpM1 q “
ϕ if M does not halt on x
9

Run K with input M1


if K accepts ñ ϵ P LpM1 q ñ LpM1 q “ Σ˚ ñ M halts on x
if K rejects ñ ϵ R LpM1 q ñ LpM1 q “ ϕ ñ M does not halt in x.

Some other questions


Consider these questions:
Is it decidable if a TM M , LpM q “ ϕ?
OR
Is tM | LpM q “ ϕu recursive?

Is it decidable if a TM M , LpM q “ Σ˚ ?
OR
Is tM | LpM q “ Σ˚ u?

Same constructions as above.

Is LpMq regular?
Is it decidable for a TM M if LpM q is regular? Or in other words: is tM | LpM q is regularu recur-
sive?

Choose a set A that is r.e. but not recursive. Eg.: A “ HP or A “ M P . Let N be a TM s.t.
LpN q “ A.
Suppose D a total TM K that can decide, given an arbitrary TM M , if LpM q is regular, then
1 1
using K, we can construct a total TM K s.t. LpK q “ HP (given M, x to determine if M halts
on x).
Construct a TM M2 (with multiple tracks) which on input y does the following:
1. Writes y on one of the tracks.
2. Writes x on a separate track.
3. Runs M on input x.
4. If M halts on x then M2 runs N on y (y is M2 original input). M2 accepts if N accepts y.
If M does not halt on x then M2 does not accept any string.
#
A if M halts on x
LpM2 q “
ϕ if M does not halt on x
Since A is neither recursive, nor a CFL, nor regular, and ϕ is all of those three things. If one
could decide whether a given TM accepts a recursive, CFL or regular set, then one could apply
this decision procedure to M2 and this would tell whether M halts on x.

Reduction
Given sets A Ď Σ˚ and B Ď Γ˚ , a (many-one) reduction of A to B is a computable function
σ : Σ˚ Ñ Γ˚ , such that @ x P Σ˚ x P A ðñ σpxq P B.
In other words strings in A must go to strings in B under σ, and strings not in A must go to
strings not in B under σ.
10

A function σ need not be one-one or onto. It must be totally and effectively computable. This
means σ must be computable by a total Turing machine, that on input x halts with σpxq written
on the tape.

When such a reduction exists, we say A is reducible to B via the map σ and we write A ďm B.
The subscript m represents many-one, and is used to distinguish it from other types of reducibility
relations.

The relation ďm of reducibility between languages is transitive.

Eg.: A “ tM #x | M halts on xu and B “ tM | ϵ P LpM qu and σ is the a computable map


M #x Ñ M1 .

Lecture 30-31
Consider the following theorems:
Theorem: If A ďm B, and B is r.e. then A is also r.e. Similarly, if A ďm B and A is not r.e.
then B is not r.e.
Theorem: If A ďm B, and B is recursive then A is also recursive. Similarly, if A ďm B and
A is not recursive then B is not recursive.

Proof :
1. Suppose A ďm B, over σ and B is r.e, therefore B “ LpM q for some TM M . Construct a
TM N s.t. LpN q “ A as follows:
On input x:
- Compute σpxq
- Run M on σpxq
- Accept if M accepts
N accepts x, iff σpxq accepts M iff σpxq P B iff x P A.
loooooooooomoooooooooon
Definition of A ďm B

2. Recall: A is recursive, if A is r.e and A r.e.


Suppose A ďm B over σ, then A ďm B via σ [follows from definition]. Thus if B is recursive
then both B and B are r.e. By part 1, both A and A are r.e ñ A is recursive.

Example: F IN “ tM | LpM q is finiteu is not r.e.

To show this, we shall give a reduction: F IN ďm HP . HP “ tM #x | M does not halt on xu.


From M #x construct a TM M1 “ σpM #xq, such that M does not halt on x iff M1 is finite.
M1 works on a input y as follows:
1. Erases the input y.
2. Writes x on the tape.
3. Runs M over x.
4. Accepts if M halts on x.
if M does not halt, M1 does not reaches step 4, does it does accept y.
M halts on x ñ LpM1 q “ Σ˚ ñ LpM1 q is infinite.
11

M doesn’t halt of x ñ LpM1 q “ ϕ ñ LpM1 q is finite.


Thus HP ďm F IN

Further F IN is not r.e. That is we have to show HP ďm M . By definition of ďm , we have


if A ďm B, then A ďm B. Suffices to show that HP ďm F IN , via some τ , i.e given some M, x
construct M2 “ τ pM #xq, s.t. M halts on x, iff LpM2 q is finite.
M2 works on input y as follows:
1. Save y on one of the tracks
2. Write x on one of the tracks
3. Simulate M on x for |y| steps (erase one symbol of y for each step of M on x.
4. Accept if M has not halted on |y|, otherwise reject.
if M does not halt on x ñ M2 halts and accepts y @y.
if M halts on x, then it halts after some n steps. M2 accepts y, if |y| ď n, rejects if |y| ě n.

M does not halts on x ñ LpM2 q “ Σ˚ ñ LpM2 q is infinite.


M halts on x ñ LpM2 q “ ty | |y| ă running time of M on xu ñ LpM2 q is finite.

Rice theorem
Theorem: Every non-trivial property of r.e. sets is undecidable.

A property of a r.e set is a function. That is P : t r.e. subsets of Σ˚ u Ñ tJ, Ku


For eg.: Emptiness: P pAq “ J if A “ ϕ, and P pAq “ K if A ‰ ϕ.
Question: For a property P of r.e. sets, is P decidable? The set has to have a finite represen-
tation.
Assumption: The r.e set is presented as a Turing machine whose language is the set.

Note: Property P is that of a set and not of a TM.

Non-trivial: The property of a set which is not universally T rue or F alse.


That is, there exists r.e. sets A, B such that P pAq “ J and P pBq “ K.

Proof of Rice Theorem: Let P be a non-trivial property of set. WLOG, let P pϕq “ K, and
P pAq “ J for some A, where A is r.e. Let K be a TM, s.t. LpM q “ A.
We will give a reduction HP ď tM | P pLpM qq “ Ju.
1
Given M and x, construct M “ σpM #xq, which on input y does the following:
1. Saves y on one of the tracks
2. Writes x on another track
3. Runs M on x.
1
4. If M halts on x, then K (TM whose language was A), is run on y, and M accepts if K
accepts. If M does not halt on x, step 3 does not terminates.
1
If M does not halt on x, then step 3 does not ends, and hence y P LpM q for all y.
1
If M halts on x, then y P LpM q ðñ y P LpKq “ A.

Thus we have,
1 1
M halts on x ñ LpM q “ A ñ P pLpM qq “ P pAq “ J.
12

1 1
M does not halt on x ñ LpM q “ ϕ ñ P pLpM qq “ P pϕq “ K.
Thus we have HP ď tM | P pLpM qq “ Ju ñ not recursive. Thus it is undecidable if LpM q
satisfies P .

Undecidable problems about CFLs


Consider the following decsion problems:
Membership Problem: Given a CFG G and a string x, is x P LpGq.
Decidable - CKY algorithm

Emptiness Problem: Given a CFG G, is LpGq “ ϕ


Decidable. Consider a CFG G “ pN, Σ, P, Sq. To decide whether LpGq is non-empty, we follow
an inductive procedure that marks a non-terminal if produces any string x P Σ˚ . After we are
done with the procedure, we can see whether S is marked or not.
At stage 0, mark all symbols in Σ, and at each successive stage mark a non-terminal A, if
A Ñ β P P , where all symbols in β are marked. Quit when for each production A Ñ β, either A
is marked or there is a unmarked symbol in β.
˚
It can be shown that A is marked in the procedure iff Dx P Σ˚ s.t. A Ý
Ñ x (use induction).
G

Universality Problem: Given a CFG G, is LpGq “ Σ˚


Undecidable: To establish this we make the following construction.

Valid Computation Histories


Configuration of a Turing Machine is a triple pq, γ, nq, where q is the current state of the
machine. y describes the content of the tape and n describes the location of the head.
Encoding Configurations: We can encode configurations as finite strings over the alphabet
Γ ˆ pQ Y t´uq

$ b1 b2 ... bk ... bm
- - - ... q ... -

and hence the start configuration looks like:

$ b1 b2 ... bn
s - - ... -

A valid computation history of M on x is a string

#α0 #α1 #...#αN #

α0 is the start configuration of M on x.


αN is a halting configuration (state is either the accept state t or reject state r).
1
αi`1 follows from one step from αi according to δ of M . Thus αi ÝÑ αi`1 .
M
Ť
∆ “ t#u Γ ˆ pQ Y t´uq, then,
V ALCOM P SpM, xq “ { valid computation histories of M on x } P ∆˚
13

V ALCOM P SpM, xq “ ϕ, iff M does not halt on x.

Hence V ALCOM P SpM, xq “ ∆˚ iff M does not x.

Lecture 32
We shall use the construct V ALCOM P S to give solution to the universality problem of CFLs.
Claim 1:V ALCOM P SpM, xq is a CFL.
Claim 2:We can construct CFG G for V ALCOM P SpM, xq from the description of M and x.
Observation: LpGq “ ∆˚ iff M does not halts on x. (established later)
Reduction: HP “ tG | G is a CFG and LpGq “ ∆˚ u

Condition for z P ∆˚ to be a valid computation history of M on x.

1. z must begin and end with a #. It must be of the form #α1 #α2 #...#αN #.

2. Each αi is a string of symbols of the form pa, ´q or pa, qq, where exactly one symbol of αi
has an element of Q on the bottom (second element of the tuple), and others have ´, and
only the leftmost has a $ on top.

3. α0 represents the start configuration of M .

4. A halt state, either t ot r must occur in z. That is αN is halting.


1
5. αi ÝÑ αi ` 1 for 0 ď i ă N ´ 1.
M

Let Ai “ tx P ∆˚ | x satisfies condition piq, 1 ď i ď 5u.


Ş Ť
V ALCOM P SpM, xq “ 1ďiď5 Ai ðñ V ALCOM P SpM, xq “ 1ďiď5 Ai .

Claim: A1 , A2 , A3 , A4 are regular sets.

• z must begin and end with #.


A1 is the regular set #∆˚ #

• For condition 2, it suffices to check that between every two #’s there is exactly one symbol
with q P Q on the bottom, and $, occurs on immediately after $ (except the last) and
nowhere else. A2 is a regular set.

• A3 is a regular set. A simple check.

• A4 is a regular set. Suffices to check whether t or r appear somewhere in the string.


1
• αi ÝÑ αi`1 . Claim is that A5 is a CFL.
M
14

$ a b a b a a b
- - - - q - - -

goes to

$ a b a a a a b
- - - p - - - -

if δpq, bq “ pp, a, Lq
Note: αi and αi`1 agree on most symbol except potentially once within a boundary of 3.
1
How to check α ÝÑ β? Check all 3 letter substrings of α and there corresponding substring v
M
of β (occurring at the same distance from #).
1
Thus, to check if α ÝÑ β does not hold, we to check whether their exists a substring of length
M
3 in α, such the corresponding substring in β is not consistent with δ.

Claim: A5 is a CFL. There exists a NPDA M , s.t. LpM q “ A5 .

Definition of M : Guess αi non-deterministically. Guess a length 3 substring u in αi , check


that the corresponding substring v in αi`1 , is not consistent (to identify the corresponding sub-
string, we use the stack to maintain the distance from #). And using a finite control, we establish
whether or not the substrings chosen remains consistent with the first one.
1
We saw that a series of #αi #αi`1 , we cannot check whether αi`1 ÐÝ αi .
M
However consider this #αi #αi`1 R . This can now be checked by a pushdown automata. Thus
R R
a series of the form: #α 0 #α1 #α
loooomoooon 2 #α3 #. One pushdown automata can check their consistency.
looooomooooon
Thus, this encoding can be checked by a 2 pushdown automata. Hence it is a intersection of 2 CFLs.

V ALCOM P S revpM, xq “ #α1 #α2 ...., D G1 , G2 CFGs s.t. G1 XG2 “ V ALCOM P S revpM, xq.

Eg.: Given M1 and M2 finite automatas sets, is LpM1 q “ LpM2 q?


Can be checked using Myhill-Nerode Theorem. There M{” is same upto isomorphic.

Eg.: Given tow CFGs G1 , G2 , is LpG1 q “ LpG2 q?


Consider A “ tG | LpGq “ Σ˚ u and B “ tG1 #G2 | LpG1 q “ LpG2 qu. We shall show A ďm B.
σ
Ñ G#Z, s.t. Z is some fixed (trivial) CFG s.t. LpZq “ Σ˚ .
Consider the reduction over G Ý
If LpGq “ Σ˚ ñ LpGq “ LpZq and otherwise we have LpGq ‰ Σ˚ ñ LpGq ‰ LpZq.

Eg.: Given G1 and G2 , is LpG1 q Ď LpG2 q?


C “ tG1 #G2 | LpG1 q Ď LpG2 qu. Again we shall establish A ďm C. Use the reduction over
Z#G Ð G.

Eg.: Given G1 and G2 , is LpG1 q X LpG2 q empty?


We shall establish HP ďm tG1 #G2 | LpG1 q X LpG2 q “ ϕu
Consider V ALCOM P S revpM, xq “ LpG1 q X LpG2 q.
σ 1
M #x ÝÑ“ G1 #G2 1
15

M does not halt on x ñ V ALCOM P S revpM, xq “ ϕ ñ LpG1 q X LpG2 q “ ϕ.


M halts on x ñ V ALCOM P S revpM, xq ‰ ϕ ñ LpG1 q X LpG2 q ‰ ϕ.

Eg.: G1 , G2 is LpG1 q X LpG2 q a CFL?


Same construction as if M halts on x ñ LpG1 q X LpG2 q “ V ALCOM P S revpM, xq that is
not a CFL.

You might also like