• Keine Ergebnisse gefunden

( ∀ x ∈ Σ )[ x ∈ A ⇐⇒ f ( x ) ∈ B ] . A ≤ B ifthereisafunction f ∈ FP suchthatforeach Definethe polynomial-timemany-onereducibility ,denotedby ≤ ,asfollows: C beanycomplexityclass. Σ to Σ .Let FP denotethesetofpolynomial-timecomputabletotalfunctionsmapping

N/A
N/A
Protected

Academic year: 2022

Aktie "( ∀ x ∈ Σ )[ x ∈ A ⇐⇒ f ( x ) ∈ B ] . A ≤ B ifthereisafunction f ∈ FP suchthatforeach Definethe polynomial-timemany-onereducibility ,denotedby ≤ ,asfollows: C beanycomplexityclass. Σ to Σ .Let FP denotethesetofpolynomial-timecomputabletotalfunctionsmapping"

Copied!
99
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Definition

LetΣ ={0,1}be a fixed alphabet, and letA,B⊆Σ. LetFPdenote the set of polynomial-time computable total functions mapping fromΣtoΣ.

LetC be any complexity class.

1 Define thepolynomial-time many-one reducibility, denoted bypm, as follows:ApmBif there is a functionf ∈FPsuch that for each

(∀x ∈Σ) [x ∈A ⇐⇒ f(x)∈B].

(2)

Definition (continued)

2 A setBis≤pm-hard forCifApmBfor eachA∈ C.

3 A setBis≤pm-complete forCif

1 Bispm-hard forC(lower bound) and

2 B∈ C(upper bound).

4 Cis said to beclosed under thepm-reducibility (≤pm-closed, for short) if for any two setsAandB,

ifApmB andB∈ C, thenA∈ C.

(3)

Lemma

1 ApmB implies ApmB, yet in general it is not true that ApmA.

2 The relationpmis both reflexive and transitive, yet not antisymmetric.

3 P,NP, andPSPACEarepm-closed.

That is, upper bounds are inherited downward with respect topm.

4 If ApmB and A ispm-hard for some complexity classC, then B is

pm-hard for C.

That is, lower bounds are inherited upward with respect topm.

(4)

Lemma (continued)

5 LetC andDbe any complexity classes. IfCispm-closed and B is

pm-complete forD, then

D ⊆ C ⇐⇒ B∈ C.

In particular, if B isNP-complete, then

P=NP ⇐⇒ B∈P.

6 For each nontrivial set B ∈P(i.e.,∅ 6=B6= Σ) and for each set A∈P, A≤pmB. Thus, every nontrivial set inPispm-complete forP.

(5)

Proof: All these properties follow easily from the definitions.

As examples, we only show two selected properties:

3 We show thatPis≤pm-closed:

LetApmBviaf FP, wheref is computed by DPTMM running in timepIPol, and

letBPvia DPTMNrunning in timeq IPol.

To show thatA∈P, given inputx, simply computef(x)viaM,

runNon inputf(x), and

accept if and only ifN(f(x))accepts.

Note that|f(x)|is polynomial in|x|, and asp,q∈IPol, so isp(q).

(6)

6 To show that every nontrivial setBinPis≤pm-complete forP, choose

a stringbBand a stringb¯/B

(which is possible because∅ 6=B6= Σ).

LetAbe an arbitrary set inP.

Define the reduction

f(x) =

b ifxA b¯ ifx ∈/ A.

Clearly,f ∈FPandf witnesses thatApmB.

(7)

Definition

LetΣ ={0,1}be a fixed alphabet, and letA,B⊆Σ.

LetFLdenote the set of log-space computable total functions mapping fromΣtoΣ.

LetC be any complexity class.

1 Define thelog-space many-one reducibility, denoted bylogm , as follows: Alogm Bif there is a functionf ∈FLsuch that for each

(∀x ∈Σ) [x ∈A ⇐⇒ f(x)∈B].

(8)

Definition (continued)

2 A setBis≤logm -hard forCifAlogm B for eachA∈ C.

3 A setBis≤logm -complete forC if

1 Bislogm -hard forC(lower bound) and

2 B∈ C(upper bound).

4 Cis said to beclosed under thelogm -reducibility (≤logm -closed, for short) if for any two setsAandB,

ifAlogm BandB∈ C, thenA∈ C.

(9)

Theorem

Thelogm -reducibility is a transitive relation.

Proof: LetA,B, andCbe sets such that Alogm Bvia some reductionf ∈FLand Blogm Cvia some reductiong∈FL.

LetF be some DTM computingf in logarithmic space, and letGbe some DTM computinggin logarithmic space.

To show transitivity, construct a reductionh∈FLwitnessingAlogm C.

That is, construct a DTMH computinghin logarithmic space such that, for eachx ∈Σ,xAif and only ifh(x)∈C.

(10)

Showing the transitivity oflogm is not a trivial matter.

To see why,

first consider the naive approach for defining a DTMH that computes a reductionhwitnessingAlogm C, and

then see why it fails.

For convenience, assume thatF andGeach have one read-only input tape,

one read-write working tape, and one write-only output tape.

(11)

In the naive approach, one would defineH to haveF’s input tape as its own input tape,

to haveG’s output tape as its own output tape, and to use the following three tapes as its own working tapes:

WT 1: the working tape ofF,

WT 2: the output tape ofF, which is identified with the input tape ofG, and

WT 3: the working tape of G.

To compute

h(x) =g(f(x)),

viewH on inputx as the “composition” ofF andGon inputx.

(12)

x

f(x)

h(x) = g(f(x))

log | |x

log | |x

log | |x

| |x

| |xc

output tape of work tape of

output tape of

work tape 3 of H

H output tape of F =

input tape of work tape of F

input tape of F input tape of H

work tape 1 of H

work tape 2 of H G

G

G

(13)

That is,H(x)starts by simulatingF(x), usinglog|x|space on WT 1 and writing the valuef(x)on WT 2.

Then,Hsimulates the computation ofG(f(x))on WT 3, writing the valueh(x) =g(f(x))on its output tape.

The problem with this naive approach, of course, is that in light of the known result

DSPACE(s)⊆DTIME(2ILin(s)),

the length of the output valuef(x)on WT 2 is not logarithmically bounded in|x|.In fact, there exists a constantc such that

|f(x)| ≤2c·log|x|=|x|c can be as large as polynomially in|x|.

(14)

To overcome this problem with the naive approach, recall that the complexity resourcespace can be reused, and consider the following simple idea:

Rather than storing the complete value of f(x)during the simulation, store just one bit of f(x)on WT 2, namely the bit that is currently scanned by G.

To this end,H needs two more working tapes, WT 4 and WT 5:

WT 4 is a counter that stores in binary the positioni currently scanned byG’s input head.

Sincei≤ |x|c, this is possible in⌈clog|x|⌉space.

The purpose of WT 5, an auxiliary counter, will be explained below.

(15)

log | |x

log | |x

log | |x

| |x

| |xc

work tape of work tape 3 of H

output tape of F = input tape of

work tape of F work tape 1 of H

work tape 2 of H

output tape of G

G

G h(x) = g(f(x)) output tape of H

log | |x log | |x

work tape 4 of

work tape 5 of H

H counter

auxiliary counter i

bit of f(x)

(16)

H on inputx works as follows:

Initially, the counter on WT 4 is set to one, sinceG’s input head initially scans the leftmost symbol of its input string.

All other working tapes are empty.

H(x)starts by simulating the computation ofF(x)on WT 1 until the first output bit off(x)is written on WT 2.

Interrupting the simulation ofF(x),

H now simulates the computation ofG(f(x))on WT 3 untilG needs to scan its next input bit.

(17)

Interrupting the simulation ofG(f(x))on WT 3, Hupdates the counter on WT 4 accordingly, deletes the first output bit off(x)from WT 2, continues the simulation ofF(x)on WT 1, and proceeds in this manner.

General situation:

WT 2 contains theithbit off(x), and WT 4 contains the numberi in binary.

Suppose the simulation ofG(f(x))has just been interrupted because H now needs to scan either the(i−1)st or the(i+1)stbit off(x).

Consider the following two cases.

(18)

Case 1: Hneeds to scan the(i+1)stbit off(x). Then,H

•continues the previously interrupted simulation ofF(x)on WT 1 until the(i+1)stbit off(x)is written on WT 2;

•increments the counter on WT 4 by one so that it now contains i+1 in binary, and proceeds with the simulation ofG(f(x)).

Case 2: Hneeds to scan the(i−1)stbit off(x).

•Since the(i−1)st bit off(x)is no longer available on WT 2, the computation ofF(x)must be simulated anew from scratch, reusing the same space on WT 1.

•A second counter on WT 5 is needed for counting the number of bits off(x)up to the(i−1)st bit.

•Initially, the counter on WT 5 is set to zero.

(19)

Step 1: H decrements the counter on WT 4, which currently contains the numberi >1 in binary, by one so that it now containsi−1, and it deletes theith output bit off(x)from WT 2;

Step 2: H simulates the computation ofF(x)on WT 1.

WheneverF attempts to write an output bit off(x)on WT 2, H does the following:

Case 2.1: WT 4 contains the numberj 6=0 in binary.

H decrements the counter on WT 4 by one so that it now containsj−1 in binary,

•it increments the counter on WT 5 by one so that it now containsij in binary, and

•continues the simulation ofF(x)without writing on WT 2.

(20)

Case 2.2: WT 4 contains 0.

•Since Subcase 2.1 occurredi−1 times, the counter on WT 5 currently containsi−1 in binary andF currently attempts to write the(i−1)stoutput bit off(x)on WT 2.

Hnow writes this bit on WT 2,

•copies the content of WT 5 to WT 4,

•interrupts the simulation ofF(x), and

•proceeds with the simulation ofG(f(x)).

(21)

Since the computation ofG(f(x))on WT 3 can be done in logarithmic space,H(x)computes

h(x) =g(f(x))

in logarithmic space, soxAif and only ifh(x)C.

It follows thatAlogm C viah∈FL.

Thus,≤logm is transitive. ❑

Corollary

LandNLarelogm -closed.

(22)

Do the reducibilitieslogm andpmcoincide?

Do they coincide at least onP?

Viewing the relations≤logm and≤pm as sets of pairs, i.e.,

logm ={(A,B)

Alogm B} and

pm ={(A,B)

ApmB},

the inclusionFL⊆FPimmediately implies that ≤logm ⊆ ≤pm.

Whether or not the converse inclusion also is true is an open problem.

However, the following result says that ifLandPdiffer, then≤logm and

pm differ onP.

DefineA6≤logm Bto mean thatAlogm B is not true.

(23)

Theorem

IfL6=P, then there exist sets A and B inPsuch that ApmB, yet A6≤logm B.

Proof: To prove the contrapositive of the theorem’s assertion, suppose that ≤logm = ≤pm onP.

LetBbe a nontrivial set inL, i.e.,∅ 6=B6= Σ. LetAbe an arbitrary set inP.

By the sixth property of the previous lemma,ApmB.

SinceB∈LandLis≤logm -closed by the corollary above,A∈L.

SinceAis an arbitraryPset,P=L. ❑

(24)

Definition

Define the decision version of thegraph accessibility problemby

GAP =

hG,s,ti Gis a directed graph with verticessandt, and there is a directed path fromstot inG

 .

Example

GraphG:

x2

x4

x3

x5

x1

x6

hG,x1,xii ∈GAP

for eachi ∈ {1,2,3,4,6}

buthG,x1,x5i∈/ GAP.

(25)

Theorem

GAPislogm -complete forNL.

Proof: To show that GAP is inNL, define an NTMM accepting GAP in logarithmic space as follows.

Suppose thathG,x1,xNiis any given input, whereGis a directed graph represented by the list of its edges, andV(G) ={x1,x2, . . . ,xN}.

Starting withx1,M nondeterministically guesses a path inGtoxN. To this end,M stores the indices of the vertices on such a path in binary, and it always stores just two successive vertices.

(26)

In more detail, ifiandjare the binary numbers currently written onM’s working tape, thenMscans its input tape to check whether or not there is an edge(xi,xj)inE(G):

If so,M accepts the input in casej=N.

If(xi,xj)is an edge inE(G)andj6=N, thenM deletesion its working tape and guesses a new vertex, writing its indexk onto the working tape, and thus proceeds.

If(xi,xj)is not an edge inE(G), thenMrejects and halts without success on this computation path.

Note that there exists a pathαfromx1 toxN inGif and only if there exists a computation path ofM(hG,x1,xNi)on whichαis guessed.

(27)

Thus,MacceptshG,x1,xNiexactly ifhG,x1,xNi ∈GAP.

Note further thatMnever stores more than two vertex indices

simultaneously, and that the binary representation of each vertex index has length at most⌈logN⌉.

It follows that no more thanO(logn)tape cells onM’s working tape are used if the input size isn; soM works in logarithmic space.

Thus, GAP is inNL.

(28)

To proveNL-hardness of GAP, letAbe any set inNL, and letM be an NTM acceptingAin logarithmic space.

Without loss of generality, suppose thatMhas one input tape and

one working tape.

As in the proof of Savitch’s Theorem, assume that

STARTM(x)is the uniquely determined start configuration ofM on inputx, and

ACCEPTM is the uniquely determined accepting configuration of M on any input.

(29)

For any input string of lengthn, define the graphGM,nof all potential lognspace-bounded configurations ofM by:

V(GM,n) =

C C is a potential configuration ofM for which space≤ ⌈logn⌉is used onM’s working tape

;

E(GM,n) = {(C1,C2)

C1M C2},

where⊢M denotes the immediate successor relation ofM, i.e., configurationC2can be reached from configurationC1by one step ofM.

(30)

Note that by“potentiallognspace-bounded configuration”ofMwe mean

not only the configurations in the computation treeM(x)for some specific inputx,

but we meanevery syntactically correct configuration ofM on any input of lengthnwith no more than⌈logn⌉symbols written on the working tape, even if such a configuration is not reachable from STARTM(x)for somex.

Of course, for each fixed stringx ∈Σ of lengthn, the computation treeM(x)is an induced subgraph ofGM,n.

(31)

Note that every vertex ofGM,ncan be encoded byO(logn)symbols:

the current position ofM’s input head in binary requires⌈logn⌉

symbols,

the current inscription onM’s working tape has at most⌈logn⌉

symbols, and

one symbol encoding the current state ofM can be inserted into the string currently written onM’s working tape to indicate the current position of the working tape head.

Thus, exactly 2⌈logn⌉+1 tape cells are enough to encode every potentiallognspace-bounded configuration ofM.

(32)

For each stringx ∈Σ of lengthn, define thelogm -reductionf fromAto GAP by

f(x) =hGM,n,STARTM(x),ACCEPTMi.

It follows that, for eachx ∈Σ,

xA ⇐⇒ M(x)has an accepting computation path

⇐⇒ f(x)∈GAP.

(33)

To show thatf ∈FL, consider the following deterministic algorithm computingf on inputx,|x|=n, in logarithmic space as follows:

Step 1: Mark the space 2⌈logn⌉+1.

Step 2: Systematically, one after the other in lexicographic order, generate all potentiallognspace-bounded configurations ofM whose encoding needs no more than the marked 2⌈logn⌉+1 tape cells.

Step 3: For each such configurationCgenerated:

1 check thatCis syntactically correct;

2 addCto the list of vertices ofGM,n;

(34)

3 simulateM onC for one step, generating potentiallogn space-bounded configurationsC1andC2withCM C1and CM C2;

4 fori∈ {1,2}, add(C,Ci)to the list of edges ofGM,n.

Step 4: When the construction of the graphGM,n is completed, output hGM,n,STARTM(x),ACCEPTMi.

Thus,f ∈FLwitnesses thatAlogm GAP. ❑

(35)

Definition

The boolean constantstrue andfalse, respectively, are represented by 1 and 0.

Letx1,x2, . . .be boolean variables, i.e.,xi ∈ {0,1}for eachi.

Boolean variables and constants are also calledatomic formulas.

Variables and their negations are calledliterals.

(36)

Boolean formulasare inductively defined as follows:

1 Every atomic formula is a formula.

2 Ifϕis a formula, then¬ϕis a formula.

3 Ifϕandψare formulas, thenϕψandϕψare formulas.

As a shorthand, we use ϕψto denote¬ϕψ,

ϕ ⇐⇒ ψto denoteψ)(¬ϕ∧ ¬ψ), _n

i=1

ϕi to denoteϕ1ϕ2∨ · · · ∨ϕn, and

^n

i=1

ϕi to denoteϕ1ϕ2∧ · · · ∧ϕn.

(37)

A boolean formulaϕis inconjunctive normal form(CNF, for short) if and only ifϕis of the form

ϕ(x1,x2, . . . ,xn) =

^m

i=1

ki

_

j=1

i,j

= ℓ1,1∨ · · · ∨ℓ1,k1

∧ · · · ∧ ℓm,1∨ · · · ∨ℓm,km , where theℓi,jare literals over{x1,x2, . . . ,xn}, and the disjuncts Wki

j=1i,j

of literals are said to be theclauses ofϕ.

A boolean formulaϕis ink-CNF if and only ifϕis in CNF and each clause ofϕhas at mostk literals.

Analogously:disjunctive normal form(DNF, for short) andk-DNF.

(38)

Definition

Theset of variables X(ϕ)occurring inϕis

X(ϕ) =













∅, ifϕ=trueorϕ=false, {x}, ifϕ=x,

X), ifϕ= (¬ϕ),

X1)∪X2), ifϕ= (ϕ1∨ϕ2)orϕ= (ϕ1∧ϕ2).

For a setX of variables, atruth assignment of X is a mapping T :X → {true,false},

assigning a truth valueT(x)to each variablexX.

(39)

Definition

A truth assignmentT satisfies a boolean formulaϕwith variable set X(ϕ)(denoted byT ϕ) if

1 ϕ=true,

2 ϕ=x andT(x) =true,

3 ϕ= (¬ϕ)andT does not satisfy ϕ (denoted byT),

4 ϕ= (ϕ1∨ϕ2)andT ϕ1orT ϕ2, or

5 ϕ= (ϕ1∧ϕ2)and we have bothT ϕ1andT ϕ2.

(40)

By evaluatingϕaccording toT, a truth valueT(ϕ)∈ {0,1}is assigned toϕ:T(ϕ) =0ifT 6ϕ, andT(ϕ) =1ifT ϕ. For example:

x y xy xy x y x ⇐⇒ y

0 0 0 0 1 1

0 1 1 0 1 0

1 0 1 0 0 0

1 1 1 1 1 1

Definition

Any two formulasϕandψ(with the same variables) are said to be (semantically) equivalent (denoted byϕ≡ψ) if and only if for each truth assignmentT, we haveT(ϕ) =T(ψ).

(41)

Table:Commonly Used Equivalences

ϕ1ϕ2 ϕ2ϕ1 Commutativity ϕ1ϕ2 ϕ2ϕ1

¬¬ϕ ϕ Double Negation

1ϕ2)ϕ3 ϕ12ϕ3) Associativity 1ϕ2)ϕ3 ϕ12ϕ3)

1ϕ2)ϕ3 1ϕ3)2ϕ3) Distributivity 1ϕ2)ϕ3 1ϕ3)2ϕ3)

(42)

Table:Commonly Used Equivalences

¬(ϕ1ϕ2) ≡ ¬ϕ1∧ ¬ϕ2 De Morgan’s Rules

¬(ϕ1ϕ2) ≡ ¬ϕ1∨ ¬ϕ2

ϕϕ ϕ Idempotence

ϕϕ ϕ

ϕ11ϕ2) ϕ1 Absorption Rules ϕ11ϕ2) ϕ1

(43)

Definition

Define the decision problems

SAT = n

ϕ ϕis a satisfiable boolean formula o,

k-SAT = n

ϕ ϕis a satisfiable boolean formula ink-CNF o

.

Example ˆ

ϕ(x1,x2,x3) = (¬x1x3)∧(¬x3∨ ¬x1)∧(x1x2)∧(¬x2x1) is in 2-CNF but not satisfiable, soϕˆ6∈2-SAT, because

x1must be set tofalseto satisfy the first two clauses, yet x1must be set totrueto satisfy the last two clauses.

(44)

Theorem

2-SATislogm -complete forNL.

Proof: To show that 2-SAT is inNL, let any boolean formula

ϕ(x1,x2, . . . ,xn)in 2-CNF be given; without loss of generality, suppose thatϕhasexactly two literals per clause.

Construct a directed graphGϕ fromϕ:

V(Gϕ) = {x1,x2, . . . ,xn} ∪ {¬x1,¬x2, . . . ,¬xn};

E(Gϕ) = {(α, β)

(¬α∨β)or(β∨ ¬α)is a clause inϕ}.

(45)

The edges inGϕ represent the implications inϕand their contrapositives.

That is, ifϕcontains a clause of the form(¬α∨β)for literalsαandβ, then

(¬α∨β) ≡ (α=⇒β)

≡ (¬β=⇒ ¬α)

≡ (β∨ ¬α).

By definition, every edge inGϕsatisfies the followingsymmetry:

If(α, β)is an edge ofGϕ, then so is(¬β,¬α).

(46)

Example

GraphGϕˆ constructed from the boolean formula ˆ

ϕ= (¬x1x3)∧(¬x3∨ ¬x1)∧(x1x2)∧(¬x2x1).

x1

¬x1

x3

¬x2

x2

¬x3

(47)

Recall thatϕˆis not satisfiable.

On the other hand, loosely identifying the vertices ofGϕˆwith the literals inϕ, there is a vertex in graphˆ Gϕˆ for which there exists a path from the vertex to its negation and back to the vertex.

For example, consider the cycle (x1,x3,¬x1,x2,x1).

As the following lemma shows, this property is not a coincidence.

Lemma

Letϕbe any boolean formula in2-CNF. Then,ϕis not satisfiable if and only if there exists a vertex x in Gϕ for which there is a path from x to

¬x and a path from¬x back to x in Gϕ.

(48)

Proof of Lemma. (⇐)Suppose for a contradiction that there exists a path inGϕ fromx to¬x and one from¬x back tox, for some

xV(Gϕ), and yet there exists a truth assignmenttsatisfyingϕ.

Consider the following two cases.

Case 1: t(x) = 1. Thent(¬x) =0. Thus, there exists an edge(α, β) on the path fromx to¬x such thatt(α) =1 andt(β) =0.

By construction ofGϕ, since(α, β)is an edge, there exists a clause of the form

(¬α∨β) or (β∨ ¬α) inϕ, which is not satisfied byt.

Hence,t does not satisfyϕ, a contradiction.

(49)

Case 2: t(x) = 0. Thent(¬x) =1.

By an analogous argument, there exists an edge(α, β)on the path from¬x tox corresponding to a clause of the form

(¬α∨β) or (β∨ ¬α) inϕthat is not satisfied byt.

Hence,t does not satisfyϕ, which again is a contradiction.

(50)

(⇒)Contraposition: If for no vertexx inGϕ there is a path of the form (x, . . . ,¬x, . . . ,x), thenϕis satisfiable. Indeed, under the hypothesis stated, a satisfying assignmenttforϕcan be constructed as follows:

while(there are still variables inϕnot assigned a truth value byt){ Step 1: Choose the first such variablex inϕand consider the

corresponding vertexx inGϕ.By hypothesis, forx, there exists no path fromx to¬x and back from¬x tox.

Step 2: For each vertexγ inGϕthat is reachable fromx (includingx itself), sett(γ) =1 andt(¬γ) =0, again loosely identifying the vertices ofGϕ with the literals inϕ.

}

(51)

Step 2 in the loop above is well-defined.

Why? What could go wrong? Bad cases that in fact cannot occur:

Case 1: Suppose there exist paths fromx to bothγ and¬γ in Step 2 of thewhileloop above. But thent would have to assign to both γ and¬γ the truth value 1, and to both¬γandγ the truth value 0.

However, this case cannot occur due to the symmetry ofGϕ: Then, there also must exist paths from bothγ and¬γ to¬x, since a path fromx toγ implies one from¬γ to¬x by symmetry, and hence there exists a path fromx to¬γand from¬γto¬x. Similarly, there must exist a path fromx to¬x viaγ.

Again by symmetry, a path fromx to¬x implies one from¬x tox, which is a contradiction to the choice ofx.

(52)

Case 2: Suppose some vertexγ reachable fromx is to be assigned the truth value 1, but it had already been assigned the truth

value 0 bytin an earlierwhileloop.That is, suppose there exists a path fromx toγ andt(γ) =0. Again, we would be in trouble.

However, this case cannot occur either, since in that earlierwhile loop alsox would have been assigned the value 0:

t(γ) =0 impliest(¬γ) =1,

which in turn impliest(¬x) =1 because of the path from¬γ to¬x.

Hence,t(x) =0, which again contradicts the choice ofx.

(53)

By hypothesis, for each vertexx, there exists no path fromx to¬x and back from¬x tox. Hence, the above procedure for constructing a satisfying truth assignmenttterminates, since in eachwhileloop at least one variable is assigned a truth value.

It remains to show thatt indeed satisfiesϕ. Whenever some literal is assigned a truth value of 1, then every successor of the vertex corresponding to this literal is also assigned the truth value 1.

Analogously, every predecessor of a vertex for which the

corresponding literal gets the truth value 0 is also assigned the truth value 0. Thus, no clause ofϕyields an implication of the form

(1=⇒0)under the assignmentt, sot satisfiesϕ. ❑ Lemma

(54)

To complete the proof that 2-SAT is inNL, apply this lemma to show that thecomplement of 2-SAT is inNL.

SinceNL=coNLby an earlier corollary (of the result by Immerman and Szelepcs ´enyi), this shows that 2-SAT is inNL.

On inputϕ, anNLmachine for 2-SAT works as follows:

Guess a variablex and a path inGϕ fromx to¬x and from¬x back tox (storing only two successive vertex indices

simultaneously to make do with logarithmic space), and accept the inputϕif and only if such a path exists.

By the above lemma, this nondeterministic algorithm acceptsϕif and only ifϕis not satisfiable. Thus 2-SAT∈NL.

(55)

To prove that 2-SAT isNL-hard, we provide a≤m -reduction from the complement of a restricted version of the graph accessibility problem to 2-SAT, which we first show isNL-complete as well.

A graph is said to beacyclicif it does not contain any cycle.

DefineGAPacyclic: Given an acyclic graphGand two verticessandt inG, is it true that there exists a path fromstot?

Lemma

GAPacyclicislogm -complete forNL.

Sketch: Modify the proof that GAP is≤logm -complete forNLas follows:

We now use the induced subgraphM(x)ofGM,nforx,|x|=n.

We log the number of steps from STARTM(x)to configurationC.

(56)

To complete the proof of≤logm -hardness of 2-SAT forNL, since the≤logm -reducibility is transitive,

GAPacyclic is≤logm -complete forNL, and

GAPacyclic is≤logm -complete forNLas well due toNL=coNL, it is enough to show the following

Lemma

GAPacycliclogm 2-SAT.

Proof of Lemma. By the above comments, it suffices to define a reductionf ∈FLsuch that, for each inputx,

x 6∈GAPacyclic ⇐⇒ f(x)∈2-SAT. (1)

(57)

Letx =hG,v1,vnibe any given instance of acyclic, whereGis an acyclic directed graph withV(G) ={v1,v2, . . . ,vn}.

Construct the reductionf by

f(x) = ϕx(v1,v2, . . . ,vn) = v1∧ ¬vn∧ ^

(vi,vj)∈E(G)

(¬vivj).

Clearly,f ∈FL.Intuitively, a literalvi inϕx is true ⇐⇒ the vertexvi in Gis reachable fromv1. In particular,

satisfying the first clause inϕx means thatv1is reachable fromv1; satisfying the second clause inϕx means thatvnis not reachable fromv1;

satisfying each remaining clause inϕx means that if (vi,vj)∈E(G)andvi is reachable fromv1, then so isvj.

(58)

Hence,

x 6∈GAPacyclic ⇐⇒ there exists no path fromv1tovninG

⇐⇒ f(x) =ϕx(v1,v2, . . . ,vn)∈2-SAT.

Thus, (1) is true, and the lemma is proven. ❑ Lemma Since

2-SAT is inNLby our first lemma in this proof, and 2-SAT isNL-hard by our previous two lemmas,

the theorem is proven: 2-SAT is≤logm -complete inNL. ❑

(59)

Theorem (Cook 1971 & Levin 1973) SATispm-complete forNP.

Proof:

1 SAT∈NP: Given a boolean formulaϕwith variable setX,

1 guess nondeterministically a truth assignment T :X → {true,false},

2 check deterministically whetherT ϕand accept accordingly.

(60)

2 SAT isNP-hard: To showApmSAT for any NP setA(with

L(M) =Afor NPTMM), construct a boolean formulaFx such that:

xA ⇐⇒ f(x) =Fx ∈SAT. (2) Letx =x1x2· · ·xnbe the input string, wherexi ∈Σfor eachi.

SinceM= (Σ,Γ,Z, δ,✷,s0,F)works in, w.l.o.g., timeexactlyp(n), the tape head can move no further thanp(n)tape cells to the left or right.

Enumerate the relevant tape cells from−p(n)throughp(n).

Start configuration ofM(x):

input symbolsx1x2· · ·xn in tape cells 0 throughn−1, the head currently scans the tape cell with number 0, and the start state iss0.

(61)

· · · · · · x1 x2 · · · xn · · · · · ·

· · · p(n) · · · 1 0 1 · · · n1 n · · · p(n) · · ·

variables ofFx index range intended meaning statet,s 0tp(n) true ⇐⇒ in stept,

sZ M is in states

headt,i 0tp(n) true ⇐⇒ in stept,

−p(n)ip(n) M’s head scans celli

tapet,i,a 0tp(n) true ⇐⇒ in stept,

−p(n)ip(n) the symbolais in aΓ celliofM’s tape

(62)

Fx =ST1T2EC, where

S: correctstart of the computation ofM(x);

T1: correcttransitionfrom stept to stept+1 for those tape cells whose contents can be altered by the head ofM;

T2: correcttransitionfrom stept to stept+1 for those tape cells whose contents cannot be altered by the head ofM;

(63)

Fx =ST1T2EC, where

E: correctend of the computation ofM(x), i.e.,E is true if and only ifM(x)has an accepting computation path;

C: generalcorrectness, i.e.,

Cis true if and only if the following conditions hold:

in each steptofM(x), there existsexactly one statesZ such thatstatet,sis true, and there existsexactly onei such thatheadt,i is true;

in each steptofM(x)and for each cell numberi, there exists exactly oneaΓsuch thattapet,i,ais true.

(64)

Let the set of states and the working alphabet ofM be given by Z = {s0,s1, . . . ,sk},

Γ = {✷,a1,a2, . . . ,a}.

Define

C = ^

0≤t≤p(n)

[D(statet,s0,statet,s1, . . . ,statet,sk)∧

D(headt,−p(n),headt,−p(n)+1, . . . ,headt,p(n))∧

^

−p(n)≤i≤p(n)

D(tapet,i,,tapet,i,a1, . . . ,tapet,i,a)],

where the structure of the three subformulasDofC above is specified in the next lemma.

(65)

Lemma

For each m ≥1, there exists a boolean formula D in the variables v1,v2, . . . ,vm such that:

D(v1,v2, . . . ,vm)is true if and only ifexactlyone variable vi is true, and

the size of the formula D (i.e., the number of variable occurrences in D) is inO(m2).

Proof of Lemma. For fixedm≥1, define D(v1,v2, . . . ,vm) =

_m i=1

vi

!

| {z }

D

m−1^

j=1

^m k=j+1

¬(vjvk)

| {z }

D

.

(66)

SubformulasD andDofDsatisfy the following properties:

D(v1,v2, . . . ,vm)is true ⇐⇒ at leastone variablevi is true; (3)

D(v1,v2, . . . ,vm)is true ⇐⇒ at mostone variablevi is true. (4) Equation (3) is obvious. To see that also (4) is true, observe that the formulaD(v1,v2, . . . ,vm)has the following structure:

(¬v1∨ ¬v2) (¬v1∨ ¬v3) ∧ · · · ∧ (¬v1∨ ¬vm)

(¬v2∨ ¬v3) ∧ · · · ∧ (¬v2∨ ¬vm)

. .. ...

(¬vm1∨ ¬vm).

(3) and (4) together imply thatD(v1,v2, . . . ,vm)is true if and only if exactly onevi is true. Clearly, the size ofDis inO(m2). ❑ Lemma

(67)

LettingδdenoteM’s transition function andy ∈ {−1,0,1}representM moving its head to the left, to the right, or not at all, respectively, define

T1 = ^

t,s,i,a

statet,s∧headt,i∧tapet,i,a

=⇒

_

ˆsZ,aˆΓ,y ∈ {−1,0,1}

withs,ˆa,y)δ(s,a)

statet+1,ˆs∧headt+1,i+y ∧tapet+1,i,ˆa

and

T2 = ^

t,i,a

¬headt,i∧tapet,i,a

=⇒tapet+1,i,a .

(68)

Define

S = state0,s0∧head0,0

^−1

i=−p(n)

tape0,i,

n−1^

i=0

tape0,i,xi+1

p(n)^

i=n

tape0,i,

and

E = _

s∈F

statep(n),s.

(69)

We show:

xA ⇐⇒ f(x) =Fx ∈SAT.

(⇒)

xA ⇒ there exists an accepting computation pathαofM(x)

⇒ assigning truth values to every variable ofFx

according toα, associating with each variable its “intended meaning” according to our table, this truth assignment satisfies each subformulas ofFx

Fx ∈SAT

(70)

We show:

xA ⇐⇒ f(x) =Fx ∈SAT.

(⇐)

Fx ∈SAT ⇒ there exists a truth assigmentτ toFx’s variables satisfyingFx

⇒ according toτ, the variablesstatet,s,headt,i, and

tapet,i,aofFx can be sensibly interpreted as a sequence of configurationsK0,K1,. . .,Kp(n)ofM(x)along

some accepting computation path ofM(x)

xA

(71)

Finally, to showf ∈FP, note that:

The size ofFx is polynomial inn=|x|:

|Fx| ∈ O((p(n))3).

AnFPalgorithm computingf runs in time linear in|Fx|. ❑

(72)

Theorem

3-SATispm-complete forNP.

Proof: Membership inNPfor the restricted problem follows immediately from that for the general problem.

To prove that SAT≤pm3-SAT, define a reductionf mapping any given boolean formulaϕto a boolean formulaψin 3-CNF such that:

ϕis satisfiable ⇐⇒ ψis satisfiable. (5) Let

ϕ(x1,x2, . . . ,xn) =C1C2∧ · · · ∧Cm, where theCj are the clauses ofϕ.

(73)

The formulaψis constructed fromϕas follows.

The variables ofψareϕ’s variablesx1,x2, . . . ,xn and, for each clause Cj ofϕ, the variablesy1j,y2j, . . . ,yhj

j. Define

ψ=D1D2∧ · · · ∧Dm,

where each subformulaDjofψis constructed from the clauseCj ofϕ as follows.

Consider thejthclause ofϕ, and suppose thatCj= (z1z2∨ · · · ∨zk), where eachzi is a literal over{x1,x2, . . . ,xn}.

Distinguish the following four cases.

(74)

Case 1: k =1. Define

Dj = (z1∨y1jy2j)∧(z1∨ ¬y1j∨y2j)∧(z1y1j∨ ¬y2j)∧(z1∨ ¬y1j∨ ¬y2j).

Case 2: k =2. Define

Dj = (z1z2y1j)∧(z1z2∨ ¬y1j).

Case 3: k =3. DefineDj =Cj = (z1z2z3).

Case 4: k4. Define

Dj = (z1z2y1j)∧(¬y1jz3y2j)∧(¬y2jz4y3j)∧ · · · ∧ (¬yk−4jzk−2ykj−3)∧(¬yk−3jzk−1zk).

(75)

Observe that the reductionf is polynomial-time computable.

It remains to show that (5) is true.

(⇒)Lett be a truth assignment to the variablesx1,x2, . . . ,xnofϕ such thatt(ϕ) =1.

Extendtto a truth assignmentt of the variables ofψas follows.

Since fori 6=j, the subformulasDiandDj are disjoint with respect to they variables, it is enough to consider all subformulas ofψ

separately. Consider the subformulaDjfor any fixedj.

In Cases 1 through 3 above,talready satisfiesDj, sot can arbitrarily be extended tot.

(76)

Consider Case 4 above.

Letzi, where 1≤ik be the first literal inCj for whicht(zi) =1.

Such ani must exist, sincet satisfiesCj.

Ifi ∈ {1,2}, then sett(yj) =0 for eachℓwith 1≤ℓ≤k −3.

Ifi ∈ {k −1,k}, then sett(yj) =1 for eachℓwith 1≤ℓ≤k−3.

Otherwise, set

t(yj) =

1 if 1≤ℓ≤i−2 0 ifi−1≤ℓ≤k −3.

In each case,t satisfiesDj.

Hence,t(ψ) =1, soψis satisfiable.

(77)

(⇐)Lett be a satisfying truth assignment toψ.

Lettbe the restriction oft to the variablesx1,x2, . . . ,xnofϕ.

Hence,t(ϕ) =1, soϕis satisfiable, which proves (5) and the

theorem. ❑

(78)

Dominating Set

independent set

vertex cover

dominating set clique

(79)

Definition

LetGbe an undirected graph.

Aclique of Gis a subsetCV(G)such that for any two vertices x,yCwithx 6=y,

{x,y} ∈E(G).

Anindependent set of Gis a subsetIV(G)such that for any two verticesx,yIwithx 6=y,

{x,y} 6∈E(G).

(80)

Definition

LetGbe an undirected graph.

Avertex cover of Gis a subsetCV(G)such that for each edge {x,y} ∈E(G),

{x,y} ∩C6=∅.

Adominating set of Gis a subsetDV(G)such that for each xV(G)−Dthere exists a vertexyDsuch that

{x,y} ∈E.

(81)
(82)

Dominating Set

Definition

CLIQUE = {hG,ki

Ghas a clique of size≥k} INDEPENDENT SET = {hG,ki

Ghas an independent set of size≥k} VERTEX COVER = {hG,ki

Ghas a vertex cover of size≤k} DOMINATINGSET = {hG,ki

Ghas a dominating set of size≤k}

(83)

Lemma

For each graph G and for each subset UV(G), the following are equivalent:

1 U is a vertex cover of G.

2 U =V(G)−U is an independent set of G.

3 U =V(G)−U is a clique of the co-graph of G, which is defined as the graph with vertex set V(G)and edge set

{{u,v}

u,vV(G)and{u,v} 6∈E(G)}.

Referenzen