CS计算机代考程序代写 AI algorithm Slide 1

Slide 1

Decidability of Languages That Do Not Ask Questions about Turing Machines
Chapter 22

Undecidable Languages That Do Not Ask Questions About TMs
Diophantine Equations, Hilbert’s 10th Problem

Post Correspondence Problem

Tiling problems

Context-free languages

Hilbert’s 10th Problem
A Diophantine system is a system of Diophantine equations such as:

4×3 + 7xy + 2z2 – 23x4z = 0

Hilbert’s 10th problem: given a Diophantine system, does it have an integer solution?

Tenth = { : w is a Diophantine system with integer solution}.

Tenth is not in D?

Proved in 1970 by Yuri Matiyasevich.

Restricted Diophantine Problems
Suppose all exponents are 1:

A farmer buys 100 animals for $100.00. The animals
include at least one cow, one pig, and one chicken, but
no other kind. If a cow costs $10.00, a pig costs $3.00,
and a chicken costs $0.50, how many of each did he
buy?

● Diophantine problems of degree 1 and Diophantine problems of a single variable of the form axk = c are efficiently solvable.

● The quadratic Diophantine problem is NP-complete.

● The general Diophantine problem is undecidable, so not
even an inefficient algorithm for it exists.

Emil Post (1940)

Consider the following blocks:

Assuming an unlimited supply of each block, does there exist a sequence of such blocks such that the strings on top and bottom are the same?

Solution:
Post Correspondence Problem
a
baa

ab
aa

bba
bb

a
baa

ab
aa

bba
bb

bba
bb

Consider two equal length, finite lists, X and Y, of strings over
some alphabet :

X = x1, x2, x3, …, xn
Y = y1, y2, y3, …, yn

Does there exist a finite sequence of integers i1, i2,…, ik such that

xi1xi2…xik = yi1yi2…yik ?
Post Correspondence Problem

PCP Example
Solution:
b
aab

abb
b

aba
a

baaa
baba

b
aab

aba
a

baaa
baba

PCP Example
No solution!
bb
abb

ab
a

aab
bba

PCP Example
Shortest solution has length 252!
bbab
b

abba
bb

b
bba

The Language PCP

= (x1, x2, x3, …, xn)(y1, y2, y3, …, yn)

The problem of determining whether a particular instance P of
the Post Correspondence Problem has a solution can be recast
as the problem of deciding the language:

PCP = {

: P has a solution}

The language PCP is in SD \ D.

PCP is in SD
Theorem. PCP is in SD.

Proof: Build a Turing Machine that tries all possible solutions of length 1, then all possible solutions of length 2, and so on.

PCP is not in D
Theorem. PCP is not in D.

Proof: Two reductions:
La ≤ MPCP
MPCP ≤ PCP

La = { : G unrestricted grammar, w  L(G)};

La is not in D

MPCP (modified PCP): defined in the same way except that any solution must start with the first block:

x1xi2…xik = y1yi2…yik

PCP is not in D
La ≤ MPCP

Given an instance of La, we construct an instance

of MPCP able to simulate derivations in G = (V, , R, S).

Using % and & new symbols, not in V, a derivation

S  x1  x2  …  w

is simulated as

%S  x1  x2  …  w&

PCP is not in D

:
start: copy the rest: , for c  V

end:

derivate: , for each rule α  β in R

It can be formally proved by induction on the length of the derivation that G can derive w iff P has a solution.

The idea is that any solution of P must start with the first block (it is an MPCP) and then the only way to continue is by the bottom string to catch up to the top by using blocks corresponding to rules of G.
c
c

%S
%

&
w&


β
α

PCP is not in D
Example:
G = ({S,A,B,a,b,c}, {a,b,c}, R, S), w = ac
R: S  ABc
S  ABSc
AB  BA
Bc  bc
BA  a
A  a
P:
c
c

%S
%

&
ac&


ABc
S

b
b

a
a

B
B

A
A

S
S

ABSc
S

BA
AB

bc
Bc

a
BA

a
A

PCP is not in D
For the derivation of w:

S  ABc  BAc  ac

P simulates:

%S  ABc  BAc  ac&

as follows:
c
c

%S
%

&
ac&

ABc
S

BA
AB

a
BA



c
c

PCP is not in D
MPCP ≤ PCP

Given an instance of MPCP, construct an instance of PCP.

Assume X = x1, x2, …, xn
Y = y1, y2, …, yn

Construct A = a0, a1, a2, …, an, an+1
B = b0, b1, b2, …, bn, bn+1

ai = xi with # after each symbol, for 1 ≤ i ≤ n
bi = yi with # before each symbol, for 1 ≤ i ≤ n

a0 = #a1 b0 = b1
an+1 = $ bn+1 = #$

PCP is not in D
Example:

:

:

a
ab

baa
aa

#a#
#a#b

a#
#a#b

b#a#a#
#a#a

$
#$

PCP is not in D
has a solution iff has a solution

If has a solution, then it is of the form 1, i2, i3, …, ik.
Then has the solution 0, i2, i3, …, ik, n+1.

If has a solution, then it is of the form 0, i2, i3, …, ik, n+1.
Then has the solution 1, i2, i3, …, ik.

Example:

solution:

solution:
a
ab

baa
aa

#a#
#a#b

b#a#a#
#a#a

$
#$

A Tiling Problem
Given a finite set T of tiles of the form:

Is it possible to tile an arbitrary surface in the plane?

A Set of TilesThat Cannot Tile the Plane

Is the Tiling Language in D?
We can represent any set of tiles as a string. For example, we could
represent

as = (G W W W) (W W B G) (B G G W).

Let TILES = {: every finite surface on the plane can be tiled, according to the rules, with the tile set T}

Is the Tiling Language in D?
Theorem: TILES is in SD.

Proof: Lexicographically enumerate partial solutions.

Theorem: TILES is not in SD.

Proof (sketch): If TILES were in SD, then it would be in D.

But we show that it is not by reduction from H. We map an arbitrary Turing machine M into a set of tiles T:

● Each row of tiles corresponds to a configuration of M.
● The first row corresponds to M’s initial configuration when started on a blank tape.
● The next row corresponds to M’s next configuration, and so forth.
● There is always a next configuration of M and thus a next row in the
tiling iff M does not halt.
● T is in TILES iff there is always a next row.
● So if it were possible to semidecide whether T is in TILES it would
be possible to semidecide whether M fails to halt on . But H is
not in SD. So neither is TILES.
The Undecidability of the Tiling Language

1. Given a CFL L and a string s, is s  L?
2. Given a CFL L, is L = ?
3. Given a CFL L, is L = *?
4. Given CFLs L1 and L2, is L1 = L2?
5. Given CFLs L1 and L2, is L1  L2 ?
6. Given a CFL L, is L context-free?
7. Given a CFL L, is L regular?
8. Given two CFLs L1 and L2, is L1  L2 = ?
9. Given a CFL L, is L inherently ambiguous?
10. Given PDAs M1 and M2, is M2 a minimization of M1?
11. Given a CFG G, is G ambiguous?
Context-Free Languages

A configuration of a TM M is a 4 tuple:
( M’s current state,
the nonblank portion of the tape before the read head,
the character under the read head,
the nonblank portion of the tape after the read head).

A computation of M is a sequence of configurations:
C0, C1, …, Cn for some n  0 such that:

● C0 is the initial configuration of M,
● Cn is a halting configuration of M, and:
● C0 |-M C1 |-M C2 |-M … |-M Cn.
Reduction via Computation History

A computation history encodes a computation:

(s, , q, x)(q1, , a, z)( …. )( …. )(qn, r, s, t),
where qn  HM.

Example:

(s, , q, x)

(q1, aaabbbaa, a, bbbbccc)
(q2, aaabbbaaa, b, bbbccc)

Computation Histories

We show that CFGALL is not in D.

The proof is by reduction (R) from H:

R will build G to generate the language L# composed of:

all strings in *,
except any that represent a computation history of M on w.

Then:
If M halts on w, then there exists a computation history of M on w, so there will be a string that G will not generate; Oracle will accept.

If M does not halt on w, there are no computation histories of M on w so G generates * and Oracle will reject.

CFGALL = { : G cfg, L(G) = *} is not in D

It is easier for R to build a PDA than a grammar. So R will first build a PDA P, then convert P to a grammar.

For a string s to be a computation history of M on w:

It must be a syntactically valid computation history.

2. C0 must be a starting configuration.

3. The last configuration must be a halting configuration.

4. Each configuration after C0 must be derivable from the
previous one according to the rules in M.
Computation Histories as Strings

valid syntax can be checked with a regular expression
hardwire into P the initial configuration
hardwire into P the final configuration
P will nondeterministically check that a flaw exists.

Precisely, P will guess that a configuration is not derivable from the previous one and check that.

(q1, aaaa, b, aaaa)(q2, aaa, a, baaaa). Okay.
(q1, aaaa, b, aaaa)(q2, bbbb, a, bbbb). Not okay.

P has to use its stack to record the first configuration and then compare it to the second. But …
Computation Histories as Strings

The stack cannot be used to check that two strings are equal but it can be used to check that two strings are the reverse of each other (WWR is context-free, WW is not).

Consider modified computation histories:

For C1C2… computation history, the modified one is:

C1C2RC3C4R…

Consider the language B# of all strings except modified computation histories.

P will accept B#.
Modified Computation Histories

R() =
1. Construct

, where P accepts all strings in B#.
2. From P, construct a grammar G that generates L(P).
3. Return .

If Oracle exists, then C = Oracle(R()) decides H:
 H: M halts on w. There exists a computation
history of M on w. So there is a string that G does not
generate. Oracle rejects. C accepts.
 H: M does not halt on w, so there exists no
computation history of M on w. G generates *. Oracle
accepts. C rejects.

But no machine to decide H can exist, so neither does Oracle.
The Conclusion

CFG= = { : G1, G2 are cfgs, L(G1) = L(G2)}
Proof by reduction from: CFGALL = { : L(G) = *}:

R is a reduction from CFGALL to CFG= defined as follows:
R() =
1. Construct the description of a new grammar G#
that generates *.
2. Return .

If Oracle exists, then C = Oracle(R()) decides CFGALL:
● R is correct:
 CFGALL: G is equivalent to G#, which generates everything. Oracle accepts.
 CFGALL: G is not equivalent to G#, which
generates everything. Oracle rejects.

But no machine to decide CFGALL can exist, so neither does Oracle.

PDAMIN = {: M2 is a minimization of M1} is undecidable.
Recall that M2 is a minimization of M1 iff:
(L(M1) = L(M2))  M2 is minimal.

R() is a reduction from CFGALL to PDAMIN :
1. Invoke CFGtoPDAtopdown(G) to construct the description


of a PDA that accepts the language that G generates.
2. Write : P# is a PDA with a single state s that is both the
start state and an accepting state. Make a transition from s
back to itself on each input symbol. Never push anything onto
the stack. L(P#) = * and P# is minimal.
3. Return .

If Oracle exists, then C = Oracle(()) decides CFGALL:
 CFGALL: L(G) = *. So L(P) = *. Since L(P#) = *,
L(P) = L(P#). And P# is minimal. Thus P# is a minimization of P.
Oracle accepts.
 CFGALL: L(G)  *. So L(P)  *. But L(P#) = *. So
L(P)  L(P#). So Oracle rejects.
No machine to decide CFGALL can exist, so neither does Oracle.

= (x1, x2, x3, …, xn)( y1, y2, y3, …, yn),
where j (xj  + and yj  +)

Example:

(b, abb, aba, bbaaa)(bab, b, a, babaaa).
Reductions from PCP
i X Y
1 b bab
2 abb b
3 aba a
4 bbaaa babaaa

Gx: Sx  bSx1 Sx  b1
Sx  abbSx2 Sx  abb2
Sx  abaSx3 Sx  aba3
Sx  bbaaaSx4 Sx  bbaaa4
Gy: Sy  babSy1 Sy  bab1
Sy  bSy2 Sy  b2
Sy  aSy3 Sy  a3
Sy  babaaaSy4 Sy  babaaa4

Gx could generate:

b abb aba abb 2 3 2 1
From PCP to Grammar
i X Y
1 b bab
2 abb b
3 aba a
4 bbaaa babaaa

IntEmpty = { : L(G1)  L(G2) = }
PCP = {

: P has a solution}

R

(?Oracle) L2 = { : L(G1)  L(G2) = }

R(

) =
1. From P construct Gx and Gy.
2. Return .

If Oracle exists, then C = Oracle(R(

)) decides PCP:

 PCP: P has at least one solution. So both Gx and Gy
will generate some string:
w(i1, i2, …ik)R, where w = xi1xi2…xik = yi1yxi2…yik.
So L(G1)  L(G2)  . Oracle rejects, so C accepts.

 PCP: P has no solution. So there is no string that can
be generated by both Gx and Gy. So L(G1)  L(G2) = . Oracle
accepts, so C rejects.

But no machine to decide PCP can exist, so neither does Oracle.

CFGUNAMBIG = { : G is a CFG and G is ambiguous}
PCP = {

: P has a solution}

R

(?Oracle) CFGUNAMBIG = { : G is ambiguous}

R(

) =
1. From P construct Gx and Gy.
2. Construct G as follows:
2.1. Add to G all the rules of both Gx and Gy.
2.2. Add S and the two rules S  Sx and S  Sy.
3. Return .

G generates L(G1)  L(G2) by generating all the derivations that G1 can
produce plus all the ones that G2 can produce, except that each has a
prepended:

S  Sx or S  Sy.

CFGUNAMBIG = { : G is a CFG and G is ambiguous}
R(

) =
1. From P construct Gx and Gy.
2. Construct G as follows:
2.1. Add to G all the rules of both Gx and Gy.
2.2. Add S and the two rules S  Sx and S  Sy.
3. Return .

If Oracle exists, then C = Oracle(R(

)) decides PCP:

 PCP: P has a solution. Both Gx and Gy generate some string: w(i1, i2, …ik)R, where w = xi1xi2…xik = yi1yxi2…yik.
So G can generate that string in two different ways. G is
ambiguous. Oracle accepts.

 PCP: P has no solution. No string can be generated by
both Gx and Gy. Since both Gx and Gy are unambiguous, so is G.
Oracle rejects.

But no machine to decide PCP can exist, so neither does Oracle.