Вы находитесь на странице: 1из 22

Larry Bush

email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us


Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

Problem 1
A homomorphism is a function h from strings to strings such that for any two strings u and v, h(uv) = h(u)
h(v).(Note that h(w) =e is possible even if
.)

Problem 1 - a.)
Show that if L is a context-free language and

is a homomorphism, then h[L] is context-free.

ANSWER:
By definition, h(uv) = h(u)h(v) for all strings u and v.
h : E* -> E*
h is a function with a string over E as its input and a string over E as its output.
If L is a CFL, then there is a CFG that produces it.
Therefore, we will show that this grammer can be converted systematically into a grammer that produces
the language h[L], thereby proving that h[L] is CF which will prove the above statement.
Let G = (V, , R, S) be a CFG grammer that generates L.
where V is the set of variables for G,
S is the start variable for the grammer and is contained in V,
E contains a finite set of terminals, and
R is a set of production rules for G with each rule having a single variable on the left hand
side and a string of variables and terminals on the right hand side.
Convert G to Gh the Grammer that produces h[L]:
h[L] = the language produced by applying homomorphism h to L.
Let Gh = (Vh, , Rh, S) be a grammer that generates h[L].
In order to convert G to Gh,
1.
make all as and bs on the right hand side of the production rules in G into
Variables A and B.
2.
add the two production rules:
a. A -> aa
b. B -> a
Vh = V U { A, B}
Rh = R U (A -> aa, B -> a)
The resulting grammer is context free because the new production rules follows the rules of a context
free grammer (each rule having a single variable on the left hand side and a string of variables and
terminals on the right hand side), R follows the rules of a context free grammer and therefore, Rh,

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
which is the union of R and the two new rules, also follows the rules of context free grammers.
Therefore, this proves that h[L] is also CF.

Problem 1 - b.)

Use the above to prove

is not context-free.

ANSWER:
Consider a homomorphism h defined by :
.
And language:

By applying h to L we produce the language:


h[L] = { a(aa)1a(aa)2a...a(aa)na : n > 0 }
The description of this language can be simplified as follows:
Since

a) then:

the summation of 1 to n = n(n+1)/2 and


we know that there were (n+1) bs in the original language (each converted to a single

h[L]

=
=
=
=
=

{ (aa)n(n+1)/2a(n+1) : n > 0 }
{an(n+1)a(n+1) : n > 0 }
{a(n^2+n)a(n+1) : n > 0 }
{a(n^2+n)+(n+1) : n > 0 }
{ a(n^2+2n+1) : n > 0 }

h[L]

{ a(n+1)^2 : n > 0 }

If h[L] is a context-free language, then there is a number p (the pumping length) where, if S is any string in
L of length at least p, then S may be divided into 5 pieces, (S = uvxyz) where:
1.
2.
3.

for each i > 0, uvixyiz is contained in L


|vy| > 0, and
|vxy| < p

Proof:
Assume that L is context-free.
We know that if L is context-free, then any string s in L can be pumped and remain in L.
Therefore, we wish to find a string s, in L that cannot be pumped and still remain in L.
Let p be the pumping length given by the pumping lemma.
Let s = a(n+1)^2: where n = p

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

Our string s is in L because our string contains only as and is of length |a| = (n+1)^2
And n>1 because n = p
We know that s must exist if L is context free.
We will now show that s cannot be pumped for all relevent cases, so as to contradict the assumption that L
is context-free.
Since s consists of only as, we are not concerned with where in the string the pumped substrings v and y
are, nor are we concerned with which characters they contain because they may only contain as. (Also note
that one of them may also contain e.)
We are only concerned with how many as v and y contain so as to determine if s will still be in h[L]
when s is pumped.
If s is divided up in some manner into uvxyz,
s

aaaaaaa.......aaaaaaaa
u

then for each i > 0, uvixyiz the resulting string must still be in L
Due to condition 3, (which says that we can pump s by dividing it into uvxyz where |vxy| < p), uvxyz must
be divided up as follows:
1.
2.
3.

v and y contain as.


v contains as and y contains e.
v contains e and y contains as.

The 3 above cases produce essentially the same result because our main concern is how many as are
contained in v and y. We know by condition 3 that |vxy| < p. therefore, if v or y contain the empty string, it
is possible for the other to contain more as so long as the total length of vxy is less than or equal to p.
In its initial condition (uv1xy1z), the length of our string s is : |s| = (p+1)2 = p2 + 2p +1
because n = p
Rule 3 tells us that v and y together contain no more than p as. therefore, if s is pumped up to:
uv2xy2z
(i = 2)
then (at most) |s| = (p+1)2 + p = p2 + 2p +1 + p = p2 + 3p +1
However, this string is not in L because the next larger string in L is :
a(n+1)^2: where n = p+1
whose length is:
((p+1)+1)2 = (p + 2)2 = p2+4p+4

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
obviously

p2 + 3p +1 < p2+4p+4

thus the strings are not equal, and the length of vxy is not long enough to allow s to be pumped up to the
next string in h[L].
In fact the lenth of a(n+1)^2: where n = p is p2 + 2p +1
And the lenth of a(n+1)^2: where n = p+1 is p2+4p+4
So the size of v and y would have to be (p2+4p+4) (p2 + 2p +1) = 2p + 3.
Therefore, s could not possibly be pumped up once and stay in h[L].
Similarly (and redundantly) s cannot be pumped down to
uv0xy0z (i = 0)
because its length would be

p2 + 2p +1 - p
p2 + p +1

=
=

p2

which is greater than

(the lenth of a(n+1)^2 : where n = p-1).

Thus s cannot be pumped and h[L] is not a CFL.


The rule proved above states that :
if L is a context-free language and
This can be abbreviated as :

is a homomorphism, then h[L] is context-free.

CF(L) > CF(h[L])

Therefore, by the contrapositive proposition:

~CF(h[L]) > ~CF(L)


Therefore, L is not context free.

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

Problem 2
Show that for every pushdown automaton M, there exists an equivalent Turing Machine T, i.e. a TM T such
that L(M) = L(T).
ANSWER:
Any TM can be simulated with an equivalent 2 tape TM.
For any PDA an equivalent 2-tape TM can be constructed as follows.

Now we will show that a 4 tape TM can simulate a 3 PDA.


A 2-tape TM can simulate a PDA using the following setup.
-

The initial input w will be put on tape-1.


The reading of the input string on the PDA will be simulated on the TM by
reading tape-1 and moving to the right. This will be tracked by the tape-1 head.
Since a PDA can only pass over the input string once, no further tracking of this
by the TM is required.
For every e read in, the TM head should stay put.
The state changes will be simulated by equivilent states in the TM.
Use tape 2 as the stack. Any character pushed to the stack will be simulated in
the TM by writing that character to tape-2. That tapes head will always point to
the last-in character. Newly pushed characters will be written to the next space
to the right.
For any character popped from the stack in the pda, the TM should overwrite the
corresponding character on tape-2 and move head-2 to the left.
The tm should not terminate until it reaches the blank at the right of the input
string on tape 1.
The TM should also include a rule that only allows the TM to enter the accept
state when tape-2 is empty. This rule (really 2 rules working together) will
correspond to the rules in the pda that push the $ on the stack at the beginning of
the pda, and pop the $ off the stack at the end of the pda.

This explaination shows that a PDA can be simulated by a multi-tape TM.


We know that a multi-tape TM is equivalent to a single tape TM, therefore
a PDA can be simulated by a TM.

Basically, a PDA is a simple version of a TM.


example: a pda may accept aaaabbbb which is a string in L = {anbn : n>0}

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
In the following example, a PDA is simulated by an equivalent TM may accept it also,
L = {anbn : n>0}
then M =

M
q1

e,e->$
a,e->a

q2

e,e->e
q4

b,a->e

q3
e,$->e

then TM =
TM

0,1-> R
0,1->_ , R

_-> R

_-> L

1->_ , L

0,1->L

_-> R

qaccept

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

Problem 3
Show that the collection of Turing-acceptable languages is closed under the operations union,
concatenation, star, and intersection.
ANSWER:
Union
Let L1 and L2 represent arbitrary turing acceptable languages that are accepted (recognized but not
necessarily decided) by the Turing Machines TM1 and TM2 respectively.
To prove that L1 U L2 is closed for all turing acceptable languages we need to show that there is a
Turing Machine TM-Union that will decide the language L = L1 U L2 (the language defined by the
union of L1 and L2).
TM-Union can be constructed by creating a TM that non-deterministically chooses TM1 or TM2.
TM1 is defined as:
If TM1 = ( Q-1, , -1, -1, q1-1, q_accept-1, q_reject-1 )
And TM2 is defined as:
TM2 = ( Q-2, , -2, -2, q1-2, q_accept-2, q_reject-2 )
Then TM-Union is defined as:
TM2 = ( Q, , , , q0, q_accept, q_reject )
With
Q = Q-1 U Q-2 U {q0}
= -1 U -2
= -1 U -2 U { (q0, e) = (q1-1, e, S), (q0, e) = (q1-2, e, S) }
q_accept = q_accept-1 U q_accept-2
q_reject = q_reject-1 U q_reject-2
The TM behaves as follows. String w from L is input into TM-Union. The machine may proceed to
either TM1 or TM2. the computation of a nondeterministic TM I a tree whose branches correspond
to different possibilities for the mahcine. Therefore, although it chooses one path or the other, the
total computation is represented by a tree whose branches split whenever there is a nondeterministic
choice to be made. Therefore, the Tm continues with both TM1 and TM2. If one of those TMs
accept, then by definition the NM-Union accepts. However, due to the nondeterministic execution of
every branch of the TM-Union tree, TM-nion will accept L because L = L1 U L2 and L1 and are
accepted by TM1 and TM2 respectively, therefore, every input string w, fed to TM-Union is from L
and thus is from either L1 or L2, and thus is accepted by either TM1 or TM2, and consequently is
nondeterministically recognized by TM-Union.

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
Concatenation - L1 recognizable and L2 recognizable -> L1 L2 recognizable
Let L1 and L2 represent arbitrary turing acceptable languages that are accepted (recognized but not
necessarilly decided) by the Turing Machines TM1 and TM2 respectively.
To prove that L1 L2 is closed for all turing acceptable languages we need to show that there is a
Turing Machine TM-Union that will recognize the language L = L1 L2 (the language defined by the
concatonation of L1 and L2).
TM- can be constructed by creating a TM that non-deterministically splits the input string w (of
length p) into every possible combination of 2 pieces at point n where w1 consists of the first n
characters of w and w2 consits of the last p-n characters of w. Then, TM1 will be run on w1 and
TM2 will be run on w2. TM- will accept w if TM1 accepts w1 and TM2 accepts w2. Since the
correct non-deterministic splitting of w into w1-w2 will be recognized by TM-, then w will be
recognized by TM-.
This works because L (L = L1 L2) is a language whose strings (i.e. w) consist of a string from L1
(w1) concatonated to a string from L2 (w2). Therefore, we assume that w will be broken into w1
from L1 and w2 from L2. Then w1 will be run on TM1 and recognized, and w2 will be run on TM2
and recognized. The result is that w will be recognized by TM-.
The non-deterministic splitting of w is an important part of this machine description.
w of length p will be non-deterministically split into every possible 2 pieces at point n where w1
consists of the first n characters of w and w2 consits of the last p-n characters of w. (w1 and w2).
Note that this description allows for the possibility that w1 or w2 may be the empty string.
While many of these combinations will not be the w1-w2 strings contained in L1 and L2, and
therefore may not be recognized by TM-, one of these combinations will be w1-w2.
Implementation:
This setup can be simulated on a 2-tape TM.
Initially, a new set of transition functions would need to be added, nondeterministically split w into
w1 and w1. As it was being split, w1 would be copied onto tape 2 and that portion of tape 1 would be
overwritten with a marker.
Next, we need a set of 2-tape transition functions which allow the simultaneous application of any
TM-1 transition functions (on tape 1) and the application of any TM-2 transition functions (on tape
2).
Then we have TM- accept if both TM1 and TM2 accept and reject if either TM1 or TM2 reject.
To do this we would make q-accept(TM1) and q-accept(TM2) no longer accept states. Then we
would create a new accept state and a new transition function that connects the two previous accept
states to it.
This setup works because if L1 and L2 are recognized by TM1 and TM2, they will also be recognized
by TM-.

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

The TM behaves as follows.


1.
2.
3.
4.

5.

String w from L is input into TM- It is initially on tape 1.


The TM tape head 1 reads the string from left to right until the end.
TM tape head 1 reads p-n characters from w, writes them to tape 2 (right to left) and
overwrites those characters on tape 1.
the TM alternately runs one transition of TM-1 on tape 1 and one transition of TM2 on
tape 2. This is simulated on 2-tape TM by creating a set of 2-tape transition functions
which allow the application of any TM-1 transition functions to tape 1 and the
application of any TM-2 transition functions to tape 2.
the TM accepts if TM1 and TM2 enter the former accept states.

Note: This is done non-deterministically. Therefore, in effect, the TM tries this for every way that w
can be split. If it accepts for one of these tries, then the non-deterministic variation of a TM says that
it accepts.

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

Star
- If L1 is recognizable then L1* is recognizable
Let L1 represent an arbitrary turing acceptable language that is accepted (recognized but not
necessarilly decided) by the Turing Machine TM.
To prove that L1* is closed for all turing acceptable languages we need to show that there is a Turing
Machine TM-Star that will recognize the language L = L1* (the language defined by the star function
of L1).
Define Target Language
If L = L1*, then L can be any language that is created by the repeated concatonation of L1 to itself or
L may conatin e.
L = {e, L1, L1 L1, L1 L1 L1, }
TM-Star can be constructed by creating a TM that non-deterministically chooses to split the input
string w (of length p) a bunch of new strings. Then, TM1 will be run on each of the strings. If T1
accepts for each of the sub-strings then the original string w is accepted. One final addition, is that
TM-Star should also accept e (the empty string) even if the language L1 does not conatain it. To do
this, the initial state of TM-Star should be an accept state. The rest of the TM should proceed as just
described.
This works because L (L = L1*) is a language whose strings (i.e. w) consist of a set of strings from L1
(w1, w2, w3, , wn L1) concatonated together (w1w2w3wn). Therefore, we assume that w will
be non-deterministicaly broken into the appropriate w1w2w3wn set of strings from L1. Then w1
will be input and run on TM1 and recognize, w2 will be input and run on TM1 and recognized and so
on. The result is that w will be recognized by TM-Star.
Note also that TM-Star accepts w = e. this can be accomplished by and thought of as an initial state
in TM-Star that is an accept state. It can aso be conceptualized as follows. When TM-Star accepts
every sub-string that w was non-deterministically broken down into, TM-Star accepts. Therefore, if
w is e, then this criteria is satisfied immediately.
Implementation:
This setup can be simulated on a Multi-tape TM.
Initially, a new set of transition functions would need to be added, to non-deterministically split w
into w1, w2, w3, , wn L1. the initial string w would be on Tape 1. As it was being split, w2 would
be copied onto tape 2 and that portion of tape 1 would be overwritten with a marker. Subsequently,
w3 would be copied onto tape 2 and that portion of tape 1 would be overwritten with a marker. And
so on until wn is copied onto tape n and that portion of tape 1 is overwritten with a marker. (This is
most easily implemented by having the tape head 1 read all of the input string from left to right until
the end, then non-deterministically read wn from right to left, while writing it to tape n (right to left
also) and overwriting those characters on tape 1.
Next, we need a set of multi-tape transition functions which allow the simultaneous application of any
TM1 transition functions on tape 1, 2, 3 In other words, a given TM1 transition may be taking
place on tape-1 while a different TM1 transition is taking place on tamp-2, etc.

10

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
Then we have TM-Star accept if TM1 has accepted every string on tape-1 through tape-n and reject
if any of them have been rejected.
To do this we would make q-accept(TM1 no longer an accept state). Then we would create a new
accept state and a new transition function that connects each of the n previous accept states to the
new accept state. Note that the TM1 reject states remain intact, and therefore, TM-Star will reject if
any of the strings on tape-1 through n are rejected.

11

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
Intersection
Let L1 and L2 represent arbitrary turing acceptable languages that are accepted (recognized but not
necessarilly decided) by the Turing Machines TM1 and TM2 respectively.
To prove that L1 L2 is closed for all turing acceptable languages we need to show that there is a
Turing Machine TM- that will recognize the language L = L1 L2 (the language defined by the
intersection of L1 and L2).
TM- can be constructed by creating a TM that runs both TM1 and TM2 on input string w. this can
be thought of as a TM that alternately runs one transition of TM-1 and one transition of TM2. This
setup works because if L1 and L2 are recognized by TM1 and TM2, they will also be recognized by
TM-. TM- would recognize both L1 and L2 showing that the set of turing recognizable
languages are closed under intersection.
It also follows that TM- accepts if both TM1 and TM2 accept and rejects if either TM1 and TM2
reject. Although this is not required to prove closure for turing recognizable languages.
This setup can be simulated on 2-tape TM.
Initially, a new set of transition functions would need to be added, to copy the input string from tape
1 to tape 1.
Next, we need a set of 2-tape transition functions which allow the simultaneous application of any
TM-1 transition functions to tape 1 and the application of any TM-2 transition functions to tape 2.
If we wish to add the last part (TM- accepts if both TM1 and TM2 accept and rejects if either TM1
and TM2 reject), although this is not required to prove closure for turing recognizable languages, we
would make q-accept(TM1) and q-ccept(TM2) no longer accept states. Then we would create a new
accept state and a new transition function that connects the two previous accept states to it.
This setup works because if L1 and L2 are recognized by TM1 and TM2, they will also be recognized
by TM-.
The TM behaves as follows.
1.
2.
3.

4.

String w from L is input into TM-. It is initially on tape 1.


The TM tape head 1 reads the string from left to right as head 2 writes each character to
tape 2.
the TM alternately runs one transition of TM-1 on tape 1 and one transition of TM2 on tape
2. This is simulated on 2-tape TM by creating a set of 2-tape transition functions which
allow the application of any TM-1 transition functions to tape 1 and the application of any
TM-2 transition functions to tape 2.
the TM accepts if TM1 and TM2 enter the former accept states.

End Problem 3

12

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

Problem 4
Part 1. Show that 2-PDAs are more powerful than 1-PDAs; .
First we will show that a 2-pda can accept the language:
L = {anbncn : n > 1}
A 1-PDA can accept a CF language such as anbn . However, to generate or accept the non-CF
language L = {anbncn : n > 1} a context sensitive grammer or TM is needed because of the
complexity of the ordering of the elements.
However, a 2-PDA, which is essentially equivalent to a TM can also accept this language.
For example, if
L = {anbncn : n > 1}
then M =

M
e,e,e->$,$

a,e,e->a,e
q1

q0

a,e,e->a,e

q2

e,e,e->e,e
b,a,e->e,b

q3

e,e,e->e,e
q5

q4

c,e,b->e,e

e,$,$->e,e

The description requires a more complicated transition function because there are 2 stacks.
(input, pop stack-1, pop stack-2) (push stack-1, push stack-2)
The above 2-PDA works as follows.
1.
The first and transition function marks the bottom of stack 1 and stack 2.
The last transition function requires that the bottom of stack marker ($) is at the top of the stack in order for
the 2-PDA to accept the string.
The purpose of this is to require that both stacks are empty, so that the number of as, bs and cs are
properly counted.

13

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
2.
3.
4.
5.
6.

In order to pass from state q1 to state q2, the 2-PDA must read an a. This is to enforce the
requirement that n> 1
State q2 reads any number of as and pushes them to stack-1 so as to keep track of how many
there are.
State q3 reads bs, while at the same time popping an a off of stack-1 and pushing a b to
stack-2.
The point of this is to only allow the same number of as and bs be read.
State q4, reads cs and pops a b rom stack-2 for every b it reads.
The point of this is to only allow the same number of cs and bs be read.
When the string is completely read, and the bottom of stack symbol is at the top of both
stacks, the string is accepted.
Note that if the string is not of the form, L = {anbncn : n > 1} then it cannot be accepted.
Note also that it is possible for a string in L to proceed down the wrong path and not be
accepted. However, due to the non-deterministic nature of the 2-PDA, if there is a path that
the string could follow and be accepted, then it will be accepted non-deterministically.
This proves that a 2-PDA can accept L = {anbncn : n > 1}.

Next we will prove that L = {anbncn : n > 1} is not context free.


Let L = {anbncn : n > 1}
If L is a context-free language, then there is a number p (the pumping length) where, if s is any string in L
of length at least p, then s may be divided into 5 pieces, (s = uvxyz) where:
1.
2.
3.

for each i > 0, uvixyiz is contained in L


|vy| > 0, and
|vxy| < p

Proof:
Assume that L is context-free.
We know that if L is context-free, then any string s in L can be pumped and remain in L.
Therefore, we wish to find a string s, in L that cannot be pumped and still remain in L.
Let p be the pumping length given by the pumping lemma.
Let s = anbncn where n=p
We know s must exist if L is context free.
We will now show that s cannot be pumped for all relevent cases, so as to contradict the assumption that L
is context-free.

14

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
If s is divided up in some manner into uvxyz,
s

aa..aa bb.bb cccc


u

then for each i > 0, uvixyiz the resulting string must still be in L
Due to condition 3, (which says that we can pump s by dividing it into uvxyz where |vxy| < p), uvxyz must
be divided up in one of the following ways:
1.
2.

If both v and y contain only one type of alphabet symbol, v does not contain both as and bs
or both bs and cs, and the same holds for y. In this case the string uv2xy2z cannot contain the
same number of as, bs and cs. Therefore it cannot be a member of L.
If either v or y contain more than one type of alphabet symbol then uv2xy2z may contain the
same number of as, bs and cs, but they will not be in the correct order.

These two cases constitute a contradiction of the original assumption.


All of the above conditions hold whether u and z contain as and bs respectively or the empty string.
Thus s cannot be pumped and L is not a CFL.
We have shown that L is not CF. We know that any CFL can be accepted by some PDA. Therefore, if L is
not CF then L cannot be accepted by a 1-PDA. However, L can be accepted by a 2-PDA Therefore, a 2PDA is more powerful than a 1-PDA.

Part 2.

Show that 3-PDAs are not more powerful than 2-PDAs


First we will show that a 2-PDA can simulate a TM.
If we have a TM, we can construct a 2-PDA that behaves as follows:
-

The first stack contains the symbols on the tape of the TM that appear to the left
of the head.

The second stack contains the symbols on the tape of the TM that appear to the
right of the head.

The symbol pointed by the head appears at the top of the second stack.

For example:
If the input string is aaaaabbbbbccccc, then the TM tape will initially be:

15

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

TM
aaabbbccc
space # 123456789
^
Where the the head is initially pointing to space 1.
The equivalent 2-PDA stacks look like this:
2-PDA
Stack 1

Stack2
aaabbbccc

If the TM wants to mark off the first a :


TM
xaabbbccc
space # 123456789
^
It can be simulated by the 2-PDA as follows:
2-PDA
Stack 1
Stack2
x
aabbbccc
If the TM wants to search for a matching b :
TM
xaabbbccc
space # 123456789
^
It can be simulated by the 2-PDA as follows:
2-PDA
Stack 1
Stack2
xaa
bbbccc
Generically, any movement of the TM head can be simulated by a 2-PDA.
Any writing action of a TM can be simulated by a 2-PDA by popping and pushing (usually
popping from one stack and pushing the overwrite character to the other stack).
From this description, we can see that any standard TM may be simulated by a 2-PDA.

16

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
Now we will show that a 4 tape TM can simulate a 3 PDA.
A 4-tape TM can simulate a 3-PDA using the following setup.
-

The initial input w will be put on tape-1.

The reading of the input string on the 3-PDA will be simulated on the TM by
reading tape-1 and moving to the right. This will be tracked by the tape-1 head.
Since a PDA can only pass over the input string once, no further tracking of this
by the TM is required.

Any character pushed to stack-1 will be simulated in the TM by writing that


character to tape-2. That tapes head will always point to the last in character.
Newly pushed characters will be written to the next space over to the right.

Any character pushed to stack-2 will be simulated in the TM by writing that


character to tape-3. That tapes head will always point to the last in character.
Newly pushed characters will be written to the next space over to the right.

Any character pushed to stack-3 will be simulated in the TM by writing that


character to tape-4. That tapes head will always point to the last in character.
Newly pushed characters will be written to the next space over to the right.

This explaination shows that a 3-PDA can be simulated by a multi-tape TM.


We know that a multi-tape TM is equivalent to a single tape TM, therefore
A 3-PDA is euivilent in power to a 2-PDA.

17

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

Problem 5
Mbad :

Stage 1: The input is a polynomial p over variables x1, x2, , xk ;


Stage 2: Try all possible settings of variables {xi} to integer values ;
Stage 3: Evaluate p on all settings ;
Stage 4: If any of these settings evaluates to 0, accept, else reject.

1.
Mbad is not a description of a legitimate TM because stage 2 requires Mbad to try an infinite number
of settings. Because of that description, Mbad will never finish stage 2 and will never halt.
2.
If p was evaluated (stage 3) and accepted if equal to 0, in-line, (as each variable setting was
generated (tried)) then Mbad could accept and halt on input with integer roots (provided that a breadth first
search approach is used.).
Turing-Recoginizable
This algorithm is not turing recognizable. Running this would consist of encoding the polynomial, and
iterating through integer sets.
If the sets were evaluated in-line for each integer set then Mbad would be accept (for when the polynomial
evaluates to 0 for a given xi interger set.) and reject (when all possible integer sets have been tested.
However, even if Mbad evaluated in-line, it still would never reject. If Mbad cannot reject then it is not
decidable.
3.
Turing-Decidable
For Mbad to be a decider, it must be able to decide if any given string is in the language. The result of the
decision must be accept or reject. It must not loop. By loop we mean that the machine does not halt when
it works on an input (in this case an encoded polynomial).
Mbad is trying to find a root of the polynomial that consists of all integers. Some polynomials have an
integer root (aka intergral root) and some do not. In the event that the polynomial does not have an integer
root, Mbad is trying to determine that as well.
Accept Case:
The in-line version of Mbad would work on polynomials with an integer root, provided
that a breadth first search approach is used.
In-line Mbad does not specify how it searches the solution space (settings of xi) for this problem.
However, in order to facilitate termination for this case, it would be better to use a breadth first approach to
testing the setings of variables {xi}. A sub-loop structure in a typical programming language lends itself to
depth first searching. This is because, in-line Mbad would start of with all xi in an initial setting, (i.e. 0) and
test that setting. It would then run throught all variations on one variable (the inner-most sub-loop) before
iterating through the next variable. Since in-line Mbad will search the xi space forever, until it finds the
integer root, it is quite likely that it will not find the integer roots for solvable polynomials either. If, for
example, there are 5 xis, they will all be set to 0 and tested, then x1 will be iterated through to infinity.
Therefore, if the integer root is not of the form xi,0,0,0,0, then it will never be found using depth first
searching.

18

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg
Reject Case:
Since we know that some polynomials will have no integer root, it is obvious on the face
of it that in-line Mbad will loop forever trying to find it for those polynomials.
How long is forever?
There is no way to determine how long is sufficient to search for the integer root of a polynomial of this
complexity. (Matijasevics theorm says that calculating such bounds for multivariable polynomials is
impossible.) Therefore, there is no way to decern between a looping machine and one that will eventually
accept. Basically this means that it is not possible to devise a TM that will decide this language.
More specifically, the way Mbad is designed, it does not decide it. It provides no means for setting bounds
for searching.
Therefore, there is no way for in-line Mbad to terminate for all input.
Therefore, Mbad is not a legitimate TM .

19

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

Problem 6 Define a new type of a machine similar to the standard except that the transition function
has the form
where R means move to the right, and S means stay
put. Thus, at each step, the new machine can either move to the right, or stay in the same position in the
tape.

Explain why this machine variant is not equivalent to the standard version.

ANSWER:
This machine variant only accepts regular languages and is therefore much less
powerful than a standard TM. The variant only accepts regular lanuages because:
1.

the variant does not have the infinite memory of the TM, because, it can
only move to the right or stay put. Therefore, if it reads an a at a space
k, it may remember that by going to a certain state. Similarly, if it reads
a b at space k it may remember that by going to a different state.
However, this memory is finite. Its size is defined by the number of
states, which is finite, so as a result it is finite. This is the same as in an
FA.

2.

the variant can only read the input once through, in order, therefore, it
can have no algorithm to compare different parts other than in a onepass fashion. This is the same as in an FA.

What class of languages do these machines recognize? Explain.

ANSWER:
1.

2.

This machine variant recognizes Regular Languages because it acts like


an FA.
-

When the variant reads the tape from left to right, that is just
like an FA reading an input string.

When the variant stays put this is just like the nondeterministic e transition of an FA.

The memory of the variant is dependent on its finite number


of states just like an FA.

The first point above means that the machine variant is weaker than a
standard TM because a standard TM has infinite memory and the

20

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

variant does not. As a result, the variant cannot accept CFLs or Context
Sensitive languages because it cannot count.
Note: This model can use the present tape element to store a value (a character). In
fact, since it can stay put it can continue to overwrite this symbol with whatever
tape character it wants. This may appear to be more memory, however, once the
TM moves to the next input character on the tape this memory is un-retrievable. As
a result, this does not alter the finite nature of its memory. You might think that this
characteristic could allow the TM to count by writing a number to the space.
However, the tape alphabet is also finite by definition, therefore, any counting
ability derived from this would also be finite.
3.
Since the variant only reads through the input, it cannot compare previous
parts of the input string even in a mirrored push down fashion, therefore, it cannot
accept CFLs. Therefore, it must only emulate an FA. Therefore, it only accepts
regular languages.
For example the anbn CFL cannot be rcognized by this stripped down TM. Once it
reads ver the as it has no way to remember how many it read. (note that Q , and
are finite)
The following is an example of a regular language accepted by this machine variant
(it complies with the definition). Note that it never moves to the left.

a.

b.

L = (ab)* U a(ba)
TM
a->R

q2

q1
b->R

_->R

_->R
qaccept

This shows that the stripped down TM recognizes regular languages.

21

Larry Bush
email: bushl2@rpi.edu, Lawrence_Bush@dps.state.ny.us
Student ID: 660 220 742

Due:

October 23, 2001

Home Work 3 - Computability and Complexity (CSCI-6050)


Instructor: Prof. Goldberg

22

Вам также может понравиться