10.3 - restricted satisfiability (sat) problem 2/19/07
Post on 20-Dec-2015
282 views
TRANSCRIPT
10.3 - Restricted Satisfiability (SAT)
Problem
2/19/07
Two Variations of SAT
• 3SAT a set of problems similar to SAT but the
Boolean expressions have a regular form: the logical AND of “clauses”, where each clause is the OR of three variables (could be negated variables)
• CSAT an intermediate step that is used to
show that SAT can be reduced to 3SAT
Purpose of Section 10.3
• To reduce SAT to 3SAT This can be accomplished by converting
each Boolean expression E in SAT to a new Boolean expression F in 3SAT
Hence, F is satisfiable iff E is satisfiable
Important Concepts
• Literal - a variable (could be negated)• Clause - logical OR of one or more
literals• CNF - Conjunctive Normal Form,
logical AND of clauses• Equivalent Boolean Expressions - two
Boolean expressions have the same result on any truth assignment to their variables
Notation for CNF
• OR () = Sum (+)• AND () = Product (* or juxtaposition)• Not = ¬
• Juxtaposition: no operator
Example
• Expression: (x ¬y) (¬x z)• CNF Notation: (x + ¬y)(¬x + z)
k-CNF
• k-Conjunctive Normal Form: an expression that contains a product of clauses. Each clause is the sum of exactly k distinct literals
Example: 2-CNF
• (x + ¬y)(y + ¬z)(z + ¬x)• Why is it 2-CNF?
Each of the clauses has exactly two literals
CSAT and kSAT
• CSAT is a Boolean expression in CNF that is satisfiable
• kSAT is a Boolean expression in k-CNF that is satisfiable
CSAT as a Decision Problem
• CSAT is the problem: Given a Boolean expression in CNF, is it
satisfiable?
• Note: we can also write kSAT as a decision problem: Given a Boolean expression in k-CNF, is
it satisfiable?
NP-Complete?
• CSAT, 3SAT, and kSAT for all k higher than 3 are NP-Complete
• 1SAT and 2SAT have linear-time algorithms
Reduction of SAT to CSAT
• Done in two parts: Part 1: “Push” the negations through the
Boolean expression so that variables are the only thing with negations With good data structure design takes linear
time Part 2: Write the Boolean expressions in
CNF form Done by introducing new variables Takes polynomial time
Helpful Rules for Part 1:
1. ¬(E F) => ¬(E) ¬(F)• One of DeMorgan’s Laws
2. ¬(E F) => ¬(E) ¬(F)• Another one of DeMorgan’s Laws
3. ¬(¬E)) => E• Law of Double Negation
Example
¬((¬(x + y))(¬x + y)) Start
¬(¬(x + y))+¬(¬x + y)
Rule 1
x + y + ¬(¬x + y) Rule 3
x + y + (¬(¬x)) ¬y Rule 2
x + y + x ¬y Rule 3
Theorem 10.12
• Every Boolean expression E is equivalent to an expression F in which the only negations occur in literals.
• Moreover, the length of F is linear in the number of symbols of E, and F can be constructed from E in polynomial time
Proof for Theorem 10.12
• Done using Induction• Accomplished by showing that for
expression E there is an equivalent expression F with ¬’s only in literals
• Also, must show that if E has n>=1 operators, then F has no more than 2n-1 operators
Length of F
• F does not have more than 1 pair of parentheses per operator
• The number of variables in an expression cannot exceed the number of operators by more than 1
• The length of F is linearly proportional to the length of E
• Also, the construction of F is simple and the time to construct F is proportional to the length
Basis:
• E has one operator Possible forms (for variables x, y)
¬x x y x y
E is already in the correct form! Therefore, E = F
Also note: F has at most twice the number of operators as E minus 1 holds
Induction:
• Assume true expressions w/fewer terms than E
• E must be in form: E1 E2
E1 E2
• There are equivalent F1 and F2
• E1 has a operators, E2 has b operators E has a + b + 1 operators
Induction (continued)
• F is formed using F1 and F2 F = F1 F2
F = F1 F2
• F1 has at most 2a-1 operators, F2 has 2b-1 operators F has at most 2a + 2b -1 operators
• F has no more than 2(a+b+1)-1 operators i.e., F has no more than twice the number of
operators of E minus 1
Induction (continued)
• E is of the form ¬E1
• There are three cases: E1 = ¬E2
E1 = E2 E3
E1 = E2 E3
Case 1: E1 = ¬E2
• By the law of double negation, E = E2.
• E2 has fewer operators than E There is an F for E2 that have ¬’s only in
literals
• The number of operators of F is at most twice the number in E2 minus 1 (and the same is true for E)
Case 2: E1 = E2 E3
• By DeMorgan’s Law: E= ¬(E2 E3) = ¬E2 ¬E3
• ¬E2 and ¬E1 have fewer operators than E There is F2 and F3 that have ¬’s only in literal F = F2 F3 = E
• ¬E2 has a+1 operators, ¬E3 has b+1 operators• F2 has at most 2(a+1)-1 operators, F3 has at
most 2(b+1)-1 operators• F has at most 2a+2b+3 operators,
(i.e., twice the number of operators of E minus 1)
Case 3: E1 = E2 E3
• Done using same argument as E1 = E2 E3
Theorem 10.13
• CSAT is NP-Complete• Proof:
Reduce SAT to CSAT in polynomial time Convert an instance of SAT into expression E
using Theorem 10.12 Convert E to CNF expression F in polynomial
time Show that F is satisfiable iff E is satisfiable
Basis:
• If E consists of 1 or 2 symbols, then it is a literal.
• A literal is a clause, therefore E is already in CNF
Induction:
• Assume: Every expression shorter than E can be
converted to a product of clauses Conversion takes at most cn2 time on
expressions of length n
• There are two cases: E = E1 E2
E = E1 E2
Case 1: E = E1 E2
• By the inductive hypothesis: All and only the satisfying assignments of
E1 can be extended to a satisfying assignment for F1
E2 can be extended to a satisfying assignment for F2
Assume: F1 and F2 are distinct variables Let F = F1 F2 where:
F1 F2 is a CNF expression if F1 and F2 are CNF expressions
• Need to show: Truth assignment T for E can be extended to a satisfying assignment for F iff T satisfies E
Case 1: If Part
• Suppose: T satisfies E Let: T1 be T restricted to apply to only
variables in E1
Let: T2 be T restricted to apply to only variables in E2
T1 and T2 can be extended to assignments S1 and S2 that satisfy F1 and F2
Let S agree with S1 and S2
S is an extension of T that satisfies F!
Case 1: Only-If Part
• Suppose: T has extension S that satisfies F Let: T1 be T restricted to apply to only variables in E1
Let: T2 be T restricted to apply to only variables in E2
Let: S1 be S restricted to the variables of F1
Let: S2 be S restricted to the variables of F2
Then: S1 is an extension of T1 and S2 is an extension of T2
F = F1 F2, then S1 satisfies F1 and S2 satisfies F2
T1 must satisfy E1 and T2 must satisfy E2 => T satisfies E!
Case 2: E = E1 E2
• By the inductive hypothesis: CNF expressions F1 and F2 have the properties: A truth assignment for E1 satisfies E1 iff it can
extended to a satisfying assignment for F1
A truth assignment for E2 satisfies E2 iff it can extended to a satisfying assignment for F2
F1 and F2 are disjoint except for those variables that appear in E
F1 and F2 are in CNF
• Note: A simple OR of F1 and F2 to construct F would not result in an expression in CNF. A more complicated construction will be needed
Case 2: Continued
• Suppose: (where gi and hi are clauses) F1 = g1 g2 … gp
F2 = h1 h2 … hp
• Let: (where y is a new variable) F = (y+g1) * (y+g2) *… * (y+gp) *
(¬y+h1) * (¬y+h2) *… * (¬y+hq)
• Show: A truth assignment T for E satisfies E iff T can be extended to a truth assignment S that satisfies F
Case 2: Only-If Part
• Assume: T satisfies E Let: T1 be T restricted to apply to only
variables in E1
Let: T2 be T restricted to apply to only variables in E2
E = E1 E2 then either: T satisfies E1 or T satisfies E2
W.L.O.G Assume: T satisfies E1
T1 can be extended to S1 which satisfies F1
Case 2: Only-If Part Cont.
• Construct S for T Rules for S will satisfy F
1) variables x in F, S(x) = S1(x)
2) S(y) = 0 (i.e., all clauses of F derived from F2 true)
3) variables x in F2 but not in F1, S(x) is T(x) if T(x) is defined (otherwise either 0 or 1)
• S makes all clauses derived from the g’s true by Rule 1
• S makes all clauses derived from the h’s true by Rule 2
• S satisfies F!
Case 2: If Part
• Suppose: Truth assignment T for E is extended to truth assignment S for F and S satisfies F
• T satisfies E whenever S satisfies F• Show: Time to construct F from E is
at most quadratic in n (where n is the length of E)
Case 2: If Part Cont.
• Takes linear (in size of E) time to: Splitting E into E1 and E2
Constructing F from F1 and F2
• Let: dn = upper bound on time to construct
E1 and E2 plus construction of F n = the length of E
Case 2: If Part Cont.
• T(n): (a recurrence equation) time to construct F from any E T(1) = T(2) ≤ e (for some constant e) T(n) ≤ dn + cmax0<i<n-1(T(i)+T(n-1-i))
For n≥3 where c is a constant such that it can be shown that T(n) ≤ cn2
• T(1) & T(2): If E has 1 or 2 symbols, no recursion and process takes time e
• Otherwise, conversion from E to F is: E to E1 and E2, F to F1 and F2 => takes dn 2 recursive conversions: E1 to F1 and E2 to F2
Case 2: If Part Cont.
• There is a constant c such that for all n, T(n) ≤ cn2
• Thus, the construction of F from E takes O(n2)!
Theorem 10.15
• 3SAT is NP-Complete• Proof:
3SAT is NP since SAT is NP Reduce CSAT to 3SAT
Proof:
• Given a CNF expression E = e1 … ek, replace each clause ei to create a new expression F• ei = (x), introduce new variables u and v
• Replace with (x+u+v)(x+u+ ¬v)(x+¬u+v)(x+¬u+¬v)
• ei = (x+y), introduce new variable z• Replace with (x+y+z)(x+y+¬z)
• ei = sum of 3 literals, no replacement needed• ei = (x1+…+xm) for some m>=4, introduce new
variables y1, …, ym-3
• Replace with (x1+x2+y1)(x3+¬y1+y2)(x4+¬y2+y3)…(xm-
2+¬ym-4+ym-3)(xm-1+xm+ym-3)
Proof Cont.
• Thus, each instance of E of CSAT can be reduced to an instance of F of 3SAT such that F is satisfiable iff E is satisfiable
• Construction time is linear in length of E
• Since CSAT is NP-Complete, 3SAT is NP-complete!