Homework 10 Answers

advertisement
Homework 10 Answers
5.1
If EQcfg were decidable, we can use it to decide ALLcfg. Here is how:
Construct grammar A that generates all strings of the given alphabet:
S-> AS|e
A-> a | b
assuming alphabet = {a, b}
Clearly S generates all the strings in {a, b}*
B is Turing machine that will use EQcfg to decide ALLcfg.
Assume EQcfg decidable. Then there is TM M that decides EQcfg.
B={
On input <C> which is encoded CFG, run
M on <C, A>
If M accepts <C, A>, then C generates all strings in the alphabet, so B accepts.
If M rejects <C, A>, then C does not generate all strings in the alphabet, so B rejects.
}
If M decides EQcfg, then B will decide ALLcfg. But ALLcfg is not decidable. Hence there is no
M that can decide EQcfg.
5.2
EQcfg is co-Turing-recognizable if the complement of EQcfg is recognizable.
The complement of EQcfg is { <C1, C2> | L(C1) =/= L(C2) }
Assume C1, C2 in Chomsky Normal Form (if not, convert them). In Chomsky Normal Form, a
string x will be derived in at most |x| steps. So, given an input string x, C1 and C2 can check all
the derivation of size |x| to decide whether x is derived from the CFG. Construct M to recognize
EQcfg:
M={
On input <C1, C1>, where C1, C2 are CFG’s, generate lexicographically all strings in
the given alphabet.
For each string x, derive all strings of size |x| with C1 and C2 and compare the results
with x.
If the CFG generates x, it will accepts x. Otherwise, it will reject x.
If C1 accepts and C2 rejects, M accepts <C1, C2> as complement to EQcfg.
If C1 rejects and C2 accepts, M also accepts <C1, C2>
If both C1 and C2 accepts or both rejects the same string x, continue on to the next string.
}
Clearly, M recognizes the complement of EQcfg. Hence EQcfg is co-Turing-recognizable.
5.4
A <m B and B is regular does not necessarily imply A is regular. See the following example:
A = { anbn | n >= 0 }, B = {an | n >= 0}
The function that maps A to B is
F={
Construct a Turing machine to recognize any input w = anbn and produce count of n.
If w is indeed in the format of anbn, n>=0, output a n.
Otherwise, output bn
}
Clearly anbn is in A iff an is in B. B is essentially a*, which is accepted by a DFA with one state.
Therefore B is regular, but A is not.
5.7
If A <m complement(A), then x is in A iff f(x) is in complement(A), which means x is in
complement(A) iff f(x) is in complement(complement(A))=A. This leads to
complement(A) <m A. Since A is recognizable, the complement(A) is also recognizable. Hence
A is decidable.
Another way to show this is to construct a TM that will recognize complement(A).
Given A<m complement(A), then there is a function f that maps x to w = f(x), and w belongs
to complement(A). In addition, A is recognizable by some TM M1.
Construct M2 = {
On input string w, generate string x lexicographically and apply f on x until f(x) = w
is found. Run M1 on x. If M1 accepts x, then M2 will accept w, which belongs to
complement(A).
}
Clearly, M2 recognizes complement(A). Hence, both A and complement(A) are recognizable
and A is then decidable.
5.9
If a language is Turing-recognizable, there is a TM M that will accept the language. Construct a
function F = {
On input string w for the particular language, output <M, w>, where M is TM that
accepts the language.
}
Cleary, if w is in L(M), <M, w> is recognized by Atm. If w is not in L(M), <M, w> is not
recognized by Atm.
With the above function for each chosen Turing-recognizable language, the language can be
Reduced to Atm.
Download