• No se han encontrado resultados

3.3 Contratos con la empresa “RHEINMETALL BORSIG A.G.

LAS ADQUISICIONES DE ARMAMENTO Y MATERIAL DE LOS MINISTERIOS MILITARES EN ALEMANIA ENTRE 1939 y

LICENCIAS DE FABRICACIÓN POR FIRMAR

I. 3.3 Contratos con la empresa “RHEINMETALL BORSIG A.G.

BOUNDED HALTING (BH)

Input:pM x1t, wherepMis a description of a DTMM; 1tis a string oftones andx0∗.

Question: Does there exist a certificatey0∗such thatMacceptsx yin time bounded byt?

BH belongs toNPsince a certificate is simply y0∗such that the DTM M

acceptsx yin at mosttsteps.

We now wish to show that any languageL∈NPis polynomially reducible to BH. LetL ∈NPandMbe a DTM forLgiven by the definition ofNP, with corresponding polynomialp(n). Now consider the function f(x)= pMx1p(|x|). Then f ∈FP, sincepM is independent ofx (it depends only on the language

L);x can be copied in linear time and the string 1p(|x|)can be written in time O(p(|x|)).

Moreover,xLif and only if there exists a certificatey0such thatx y

is accepted byMin timep(|x|). But by definition of BH this is true if and only if pM x1p(|x|)∈BH. ThusxL ⇐⇒ f(x)∈BH.

3.3 NP-completeness 47

This is an interesting theoretical result but of little practical use when trying to find other examples ofNP-complete languages. In order to do this we need to give a more natural example of anNP-complete language. For this reason we now give a proof of Cook’s Theorem.

Proof of Theorem 3.10: First note that SAT∈NP: a succinct certificate is a satisfying truth assignment. We need to show that for any languageL∈NPwe haveLmSAT.

LetL∈NPthen, by definition ofNP, there exists a DTMMand a polyno- mialp(n) such thatTM(n)≤ p(n) and on any inputx0:

(i) ifxLthen there existsy0∗such that|y| ≤ p(|x|) andM accepts the input stringx y;

(ii) ifxLthen for any stringy0∗,Mrejects the input stringx y. Our polynomial reduction fromLto SAT will take any possible inputx0

and construct an instance of SAT, say Sx, such that Sx is satisfiable if and only if xL. Using the definition ofNPthis is equivalent to saying thatSx is satisfiable if and only if there exists a certificate y0∗, with|y| ≤p(|x|), such thatMaccepts the inputx y.

Let the alphabet be = {σ0, . . . , σl} and the set of states be =

{γ0, . . . , γm}. We will suppose that the blank symbol∗isσ0, the initial state is

γ0and the accept state isγ1. We note that ifM acceptsx yin time p(n), for somey0, then the only tape squares which can ever possibly be scanned are those a distance at most p(n) from the starting square. Labelling the tape squares with the integers in the obvious way, with the starting square labelled by zero, we note that only the contents of tape squares−p(n), . . . ,p(n) can play a role in M’s computation.

Forx0∗we constructSxfrom seven collections of clauses involving the following variables:

sqi,j,t, sci,t and stk,t.

We think of these variables as having the following meanings (when they are true):

rsqi,j,t– ‘at timet squarei contains symbolσj’,

rsci,t– ‘at timetthe read-write head is scanning squarei’, rstk,t – ‘at timetthe machine is in stateγk’.

In order to construct the groups of clauses we will frequently wish to ensure that exactly one of a collection of variables, sayz1, . . . ,zs, is true. We use the

48 3 Non-deterministic computation

following notation to show how this can be achieved in CNF Unique(z1, . . . ,zs)= s i=1 zi ∧ 1≤i<js (zizj) .

It is easy to see that Unique(z1, . . . ,zs) is true if and only if exactly one of the variablesz1, . . . ,zsis true.

The different collections of clauses inSxensure that different aspects ofM’s computation are correct.

(i) The read–write head cannot be in two places at the same time.

At any timetexactly one tape square is scanned by the read–write head:

C1= p(n) t=0 Uniquescp(n),t, . . . ,scp(n),t .

(ii) Each square contains one symbol.

At any timeteach tape square contains exactly one symbol:

C2 = p(n) i=−p(n) p(n) t=0 Unique(sqi,0,t, . . . ,sqi,l,t).

(iii) The machine is always in a single state.

At any timetthe machineM is in a single state:

C3=

p(n)

t=0

Unique(st0,t, . . . ,stm,t).

(iv) The computation starts correctly.

At timet=0 the squares−p(n), . . . ,−1 are blank, the squares 0,1, . . . ,ncontain the stringx=σj0σj1· · ·σjn−1σjn and the squares n+1 up top(n) can contain anything (since any string in these squares could be a possible certificatey0∗). Moreover the starting position of the read–write head is at square zero and the initial state isγ0:

C4=sc0,0∧st0,0∧ n i=0 sqi,ji,0∧ −1 i=−p(n) sqi,0,0.

(v) The computation ends in acceptance.

At some timetp(n)Menters the accept stateγ1:

C5=

p(n)

t=0

3.3 NP-completeness 49

(vi) Only the symbol in the current square can change.

Only the symbol in the current square at timetcan be changed at time

t+1: C6 = p(n) i=−p(n) l j=0 p(n) t=0 (sci,t∨sqi,j,t∨sqi,j,t+1)∧(sci,t∨sqi,j,t∨sqi,j,t+1).

(vii) The transition function determines the computation.

If at timet the machine is in stateγk, the read–write head is scanning squarei, and this square contains symbolσjthen

δ(γk, σj)=(γp, σq,b)

describes the new state, the new symbol to write in squareiand whether the read–write head moves left or right. (We haveb= −1 if it moves left andb=1 if it moves right.)

C7= p(n) i=−p(n) l j=0 p(n) t=0 m k=0 (stk,t∨sci,t∨sqi,j,t)∨(stp,t+1∧sqi,q,t+1∧sci+b,t+1).

(Note that for simplicity we have not writtenC7in CNF, it would be trivial to

correct this.)

It is easy to see that if we defineSxto be the Boolean formula given by the conjunction of all the above collections of clauses we have an instance of SAT. Moreover it is not too difficult to check that the size ofSxis polynomial in the input size. (You can check that the number of variables inSxisO(p(n)2) and the total number of clauses isO(p(n)3).)

FurthermoreSxis clearly satisfiable if and only ifM acceptsx y, for some certificatey0∗, in time at most p(n). (Given a satisfying assignment forSx we can actually read off a good certificate: it will be described by the vari- ables corresponding to the contents of tape squaresn+1 up to p(n) at time

t =0.) 2

Although the proof of Cook’s theorem is rather involved, once we have this single ‘natural’ example of anNP-complete language we can proceed to show that many other languages areNP-complete, using Proposition 3.9. Indeed many thousands of languages associated to decision problems from many different areas are now known to beNP-complete.

Recall the decision problemk-SAT from the previous chapter.

k-SAT

Input: a Boolean formula f in CNF with at mostkliterals per clause. Question: is f satisfiable?

50 3 Non-deterministic computation

We know that 2-SAT belongs toP(this was Proposition 2.9) so how much more difficult can 3-SAT be?