Theory of Computer Science
G. R¨oger
Spring Term 2019
University of Basel Computer Science
Exercise meeting 9 — Solutions
Exercise 9.1
Consider propositional formulaϕ=¬(A∨(¬B∧C)).
(a) Specify formulaχall as it is used in the polynomial reduction ofSATto3SAT. Solution:
Formula χall over {XA, XB, XC, X¬B, X(¬B∧C), X(A∨(¬B∧C)), X¬(A∨(¬B∧C))} is built from the following subformulas:
χA= (XA↔A) χB= (XB ↔B) χC= (XC↔C) χ¬B= (X¬B ↔ ¬XB)
χ(¬B∧C)= (X(¬B∧C)↔(X¬B∧XC))
χ(A∨(¬B∧C))= (X(A∨(¬B∧C))↔(XA∨X(¬B∧C))) χ¬(A∨(¬B∧C))= (X¬(A∨(¬B∧C))↔ ¬X(A∨(¬B∧C)))
Then
χall=χA∧χB∧χB∧χ¬B∧χ(¬B∧C)∧χ(A∨(¬B∧C))∧χ¬(A∨(¬B∧C)),
always using the logically equivalent CNF formula that results from replacing the abbre- viation ↔ with the corresponding formula, e.g. χ(A∨(¬B∧C)) ≡ (X(A∨(¬B∧C)) → (XA ∨ X(¬B∧C)))∧((XA ∨X(¬B∧C)) → X(A∨(¬B∧C))) ≡ (¬X(A∨(¬B∧C)) ∨(XA ∨X(¬B∧C)))∧ (¬(XA∨X(¬B∧C))∨X(A∨(¬B∧C))).
(b) I ={A7→F, B7→T, C 7→T} is a model ofϕ. Specify the corresponding model ofχall. Solution:
I0={XA7→F, XB7→T, XC7→T, X¬B 7→F, X(¬B∧C)7→F, X(A∨(¬B∧C))7→F, X¬(A∨(¬B∧C))7→T}
Exercise 9.2
The decision problemSAT(satisfiability) is defined as follows:
Given: a propositional logic formula ϕ Question: Isϕsatisfiable?
The general problemGenSAT(model generation) is defined as follows:
Given: a propositional logic formula ϕ
Output: a model forϕor a message that none exists
Show that if there is a polynomial algorithm for SAT then there is a polynomial algorithm for GenSAT.
1
Solution:
We specify an algorithm that solvesGenSAT. It uses transformations ψ[v 7→T] andψ[v 7→F]
that replace every occurrence ofv with a small valid (e.g.v∨ ¬v) and unsatisfiable (e.g.v∧ ¬v) formula, respectively. Then
• I0 is a model ofψ[v7→T] iffI with I(v) =T and I(v0) =I0(v0) forv06=v is a model ofψ and
• I0 is a model ofψ[v7→F] iffI withI(v) =F andI(v0) =I0(v0) forv06=v Moreover, ifψis satisfiable andψ[v7→T] is unsatisfiable thenψ[v7→F] is satisfiable.
The algorithm proceeds as follows:
Call the algorithm forSATon inputϕ. If it is unsatisfiable, output that it has no model.
Otherwise, we successively build a modelI forϕ, starting withϕ0:=ϕ, as follows:
While there is still an unassigned variablev, call theSATalgorithm forϕ0[v7→T]. If the answer is yes, setI(v) =T and continue withϕ0:=ϕ0[v7→T], otherwise setI(v) =F and continue with ϕ0:=ϕ0[v7→F].
Since the number of variables is bound by the size of ϕ, there is only a polynomial number of iterations. The size of the last formulaϕ0 is at most k times larger thanϕ for some constantk (k= 2 if we only count variable occurrences to determine the size). Hence, if every call toSATis possible in polynomial time then the overall runtime is polynomial.
2