1 The Satisfiability Problem Cook’s Theorem: An NP-Complete Problem Restricted SAT: CSAT, 3SAT.

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Advertisements

Complexity Classes: P and NP
 2004 SDU Lecture17-P,NP, NPC.  2004 SDU 2 1.Decision problem and language decision problem decision problem and language 2.P and NP Definitions of.
1 More NP-Complete Problems NP-Hard Problems Tautology Problem Node Cover Knapsack.
The Theory of NP-Completeness
Complexity 25-1 Complexity Andrei Bulatov #P-Completeness.
1 L is in NP means: There is a language L’ in P and a polynomial p so that L 1 · L 2 means: For some polynomial time computable map r : 8 x: x 2 L 1 iff.
Computability and Complexity 14-1 Computability and Complexity Andrei Bulatov Cook’s Theorem.
1 Intractable Problems Time-Bounded Turing Machines Classes P and NP Polynomial-Time Reductions.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY Read sections 7.1 – 7.3 of the book for next time.
1 Polynomial Church-Turing thesis A decision problem can be solved in polynomial time by using a reasonable sequential model of computation if and only.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
1 Polynomial Time Reductions Polynomial Computable function : For any computes in polynomial time.
Restricted Satisfiability (SAT) Problem
NP-Complete Problems Problems in Computer Science are classified into
1 Decidability Turing Machines Coded as Binary Strings Diagonalizing over Turing Machines Problems as Languages Undecidable Problems.
Chapter 11: Limitations of Algorithmic Power
Restricted Satisfiability (SAT) Problem
1 Polynomial Space The classes PS and NPS Relationship to Other Classes Equivalence PS = NPS A PS-Complete Problem.
1 The Cook-Levin Theorem Zeph Grunschlag. 2 Announcements Last HW due Thursday Please give feedback about course at oracle.seas.columbia.edu/wces oracle.seas.columbia.edu/wces.
Properties of Context-Free Languages
1 L is in NP means: There is a language L’ in P and a polynomial p so that L 1 ≤ L 2 means: For some polynomial time computable map r : x: x L 1 iff r(x)
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
1 1. Draw the machine schema for a TM which when started with input 001 halts with abbb on the tape in our standard input format. 2. Suppose you have an.
Lecture 22 More NPC problems
Theory of Computation, Feodor F. Dragan, Kent State University 1 NP-Completeness P: is the set of decision problems (or languages) that are solvable in.
Computational Complexity Theory Lecture 2: Reductions, NP-completeness, Cook-Levin theorem Indian Institute of Science.
Theory of Computing Lecture 17 MAS 714 Hartmut Klauck.
MCS 312: NP Completeness and Approximation algorthms Instructor Neelima Gupta
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
Complexity 25-1 Complexity Andrei Bulatov Counting Problems.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
CSC401 – Analysis of Algorithms Chapter 13 NP-Completeness Objectives: Introduce the definitions of P and NP problems Introduce the definitions of NP-hard.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 P P := the class of decision problems (languages) decided by a Turing machine so that for some polynomial p and all x, the machine terminates after at.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
NP-completeness Section 7.4 Giorgi Japaridze Theory of Computability.
NP-completeness Class of hard problems. Jaruloj ChongstitvatanaNP-complete Problems2 Outline  Introduction  Problems and Languages Turing machines and.
CS 461 – Nov. 30 Section 7.5 How to show a problem is NP-complete –Show it’s in NP. –Show that it corresponds to another problem already known to be NP-complete.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
NP-Completness Turing Machine. Hard problems There are many many important problems for which no polynomial algorithms is known. We show that a polynomial-time.
1 Chapter 10 Intractable Problems Switzerland Lion Monument in Lucerne.
NPC.
NP-complete Languages
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong NP-complete.
Given this 3-SAT problem: (x1 or x2 or x3) AND (¬x1 or ¬x2 or ¬x2) AND (¬x3 or ¬x1 or x2) 1. Draw the graph that you would use if you want to solve this.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
Computability Examples. Reducibility. NP completeness. Homework: Find other examples of NP complete problems.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
1 SAT SAT: Given a Boolean function in CNF representation, is there a way to assign truth values to the variables so that the function evaluates to true?
More NP-Complete and NP-hard Problems
Intractable Problems Time-Bounded Turing Machines Classes P and NP
L is in NP means: There is a language L’ in P and a polynomial p so that L1 ≤ L2 means: For some polynomial time computable map r :  x: x  L1 iff.
Relationship to Other Classes
Richard Anderson Lecture 26 NP-Completeness
Intro to Theory of Computation
Intro to Theory of Computation
Intractable Problems Time-Bounded Turing Machines Classes P and NP
NP-Completeness Proofs
The Satisfiability Problem
Instructor: Aaron Roth
The Satisfiability Problem
Presentation transcript:

1 The Satisfiability Problem Cook’s Theorem: An NP-Complete Problem Restricted SAT: CSAT, 3SAT

2 Boolean Expressions uBoolean, or propositional-logic expressions are built from variables and constants using the operators AND, OR, and NOT. wConstants are true and false, represented by 1 and 0, respectively. wWe’ll use concatenation (juxtaposition) for AND, + for OR, - for NOT, unlike the text.

3 Example: Boolean expression u(x+y)(-x + -y) is true only when variables x and y have opposite truth values. uNote: parentheses can be used at will, and are needed to modify the precedence order NOT (highest), AND, OR.

4 The Satisfiability Problem (SAT ) uStudy of boolean functions generally is concerned with the set of truth assignments (assignments of 0 or 1 to each of the variables) that make the function true. uNP-completeness needs only a simpler question (SAT): does there exist a truth assignment making the function true?

5 Example: SAT u(x+y)(-x + -y) is satisfiable. uThere are, in fact, two satisfying truth assignments: 1.x=0; y=1. 2.x=1; y=0. ux(-x) is not satisfiable.

6 SAT as a Language/Problem uAn instance of SAT is a boolean function. uMust be coded in a finite alphabet. uUse special symbols (, ), +, - as themselves. uRepresent the i-th variable by symbol x followed by integer i in binary.

7 Example: Encoding for SAT  (x+y)(-x + -y) would be encoded by the string (x1+x10)(-x1+-x10)

8 SAT is in NP uThere is a multitape NTM that can decide if a Boolean formula of length n is satisfiable. uThe NTM takes O(n 2 ) time along any path. uUse nondeterminism to guess a truth assignment on a second tape. uReplace all variables by guessed truth values. uEvaluate the formula for this assignment. uAccept if true.

9 Cook’s Theorem uSAT is NP-complete. wReally a stronger result: formulas may be in conjunctive normal form (CSAT) – later. uTo prove, we must show how to construct a polytime reduction from each language L in NP to SAT. uStart by assuming the most resticted possible form of NTM for L (next slide).

10 Assumptions About NTM for L 1.One tape only. 2.Head never moves left of the initial position. 3.States and tape symbols are disjoint. uKey Points: States can be named arbitrarily, and the constructions many-tapes-to-one and two-way- infinite-tape-to-one at most square the time.

11 More About the NTM M for L uLet p(n) be a polynomial time bound for M. uLet w be an input of length n to M.  If M accepts w, it does so through a sequence I 0 ⊦ I 1 ⊦ … ⊦ I p(n) of p(n)+1 ID’s. wAssume trivial move from a final state. uEach ID is of length at most p(n)+1, counting the state.

12 From ID Sequences to Boolean Functions uThe Boolean function that the transducer for L will construct from w will have (p(n)+1) 2 “variables.” uLet variable X ij represent the j-th position of the i-th ID in the accepting sequence for w, if there is one. wi and j each range from 0 to p(n).

13 Picture of Computation as an Array Initial ID X 00 X 01 … X 0p(n) X 10 X 11 … X 1p(n) I1I1 I p(n) X p(n)0 X p(n)1 … X p(n)p(n)

14 Intuition uFrom M and w we construct a boolean formula that forces the X’s to represent one of the possible ID sequences of NTM M with input w, if it is to be satisfiable. uIt is satisfiable iff some sequence leads to acceptance.

15 From ID’s to Boolean Variables uThe X ij ’s are not boolean variables; they are states and tape symbols of M. uHowever, we can represent the value of each X ij by a family of Boolean variables y ijA, for each possible state or tape symbol A. uy ijA is true if and only if X ij = A.

16 Points to Remember 1.The boolean function has components that depend on n. wThese must be of size polynomial in n. 2.Other pieces depend only on M. wNo matter how many states/symbols m has, these are of constant size. 3.Any logical formula about a set of variables whose size is independent of n can be written somehow.

17 Designing the Function uWe want the Boolean function that describes the X ij ’s to be satisfiable if and only if the NTM M accepts w. uFour conditions: 1.Unique: only one symbol per position. 2.Starts right: initial ID is q 0 w. 3.Moves right: each ID follows from the next by a move of M. 4.Finishes right: M accepts.

18 Unique uTake the AND over all i, j, Y, and Z of (-y ijY + -y ijZ ). uThat is, it is not possible for X ij to be both symbols Y and Z.

19 Starts Right uThe Boolean Function needs to assert that the first ID is the correct one with w = a 1 …a n as input. 1.X 00 = q 0. 2.X 0i = a i for i = 1,…, n. 3.X 0i = B (blank) for i = n+1,…, p(n). uFormula is the AND of y 0iZ for all i, where Z is the symbol in position i.

20 Finishes Right uSomewhere, there must be an accepting state. uForm the OR of Boolean variables y ijq, where i and j are arbitrary and q is an accepting state. uNote: differs from text.

21 Running Time So Far uUnique requires O(p 2 (n)) symbols be written. wParentheses, signs, propositional variables. uAlgorithm is easy, so it takes no more time than O(p 2 (n)). uStarts Right takes O(p(n)) time. uFinishes Right takes O(p 2 (n)) time. Variation over i and j Variation over symbols Y and Z is independent of n, so covered by constant.

22 Running Time – (2) uCaveat: Technically, the propositions that are output of the transducer must be coded in a fixed alphabet, e.g., x10011 rather than y ijA. uThus, the time and output length have an additional factor O(log n) because there are O(p 2 (n)) variables. uBut log factors do not affect polynomials

23 Moves Right uX ij = X i-1,j whenever the state is none of X i-1,j-1, X i-1,j, or X i-1,j+1. uFor each i and j, construct a formula that says (in propositional variables) the OR of “X ij = X i-1,j ” and all y i-1,k,A where A is a state symbol (k = i-1, i, or i+1). wNote: X ij = X i-1,j is the OR of y ijA.y i-1,jA for all symbols A. Works because Unique assures only one y ijX true.

24 Constraining the Next Symbol … A B C … B Easy case; must be B … A q C … ? ? ? Hard case; all three may depend on the move of M

25 Moves Right – (2) uIn the case where the state is nearby, we need to write an expression that: 1.Picks one of the possible moves of the NTM M. 2.Enforces the condition that when X i-1,j is the state, the values of X i,j-1, X i,j, and X i,j+1. are related to X i-1,j-1, X i-1,j, and X i-1,j+1 in a way that reflects the move.

26 Example: Moves Right Suppose δ (q, A) contains (p, B, L). Then one option for any i, j, and C is: C q A p C B If δ (q, A) contains (p, B, R), then an option for any i, j, and C is: C q A C B p

27 Moves Right – (3) uFor each possible move, express the constraints on the six X’s by a Boolean formula. uFor each i and j, take the OR over all possible moves. uTake the AND over all i and j. uSmall point: for edges (e.g., state at 0), assume invisible symbols are blank.

28 Running Time uWe have to generate O(p 2 (n)) Boolean formulas, but each is constructed from the moves of the NTM M, which is fixed in size, independent of the input w. uTakes time O(p 2 (n)) and generates an output of that length. wTimes log n, because variables must be coded in a fixed alphabet.

29 Cook’s Theorem – Finale uIn time O(p 2 (n) log n) the transducer produces a boolean formula, the AND of the four components: Unique, Starts, Finishes, and Moves Right. uIf M accepts w, the ID sequence gives us a satisfying truth assignment. uIf satisfiable, the truth values tell us an accepting computation of M.

30 Picture So Far uWe have one NP-complete problem: SAT. uIn the future, we shall do polytime reductions of SAT to other problems, thereby showing them NP-complete. uWhy? If we polytime reduce SAT to X, and X is in P, then so is SAT, and therefore so is all of NP.

31 Conjunctive Normal Form uA Boolean formula is in Conjunctive Normal Form (CNF) if it is the AND of clauses. uEach clause is the OR of literals. uA literal is either a variable or the negation of a variable. uProblem CSAT : is a Boolean formula in CNF satisfiable?

32 Example: CNF (x + -y + z)(-x)(-w + -x + y + z) (…

33 NP-Completeness of CSAT uThe proof of Cook’s theorem can be modified to produce a formula in CNF. uUnique is already the AND of clauses. uStarts Right is the AND of clauses, each with one variable. uFinishes Right is the OR of variables, i.e., a single clause.

34 NP-Completeness of CSAT – (2) uOnly Moves Right is a problem, and not much of a problem. uIt is the product of formulas for each i and j. uThose formulas are fixed, independent of n.

35 NP-Completeness of CSAT – (3) uYou can convert any formula to CNF. uIt may exponentiate the size of the formula and therefore take time to write down that is exponential in the size of the original formula, but these numbers are all fixed for a given NTM M and independent of n.

36 k-SAT uIf a boolean formula is in CNF and every clause consists of exactly k literals, we say the boolean formula is an instance of k-SAT. wSay the formula is in k-CNF. uExample: 3-SAT formula (x + y + z)(x + -y + z)(x + y + -z)(x + -y + -z)

37 k-SAT Facts uEvery boolean formula has an equivalent CNF formula. wBut the size of the CNF formula may be exponential in the size of the original. uNot every boolean formula has a k-SAT equivalent. u2SAT is in P; 3SAT is NP-complete.

38 Proof: 2SAT is in P (Sketch) uPick an assignment for some variable, say x = true. uAny clause with –x forces the other literal to be true. wExample: (-x + -y) forces y to be false. uKeep seeing what other truth values are forced by variables with known truth values.

39 Proof – (2) uOne of three things can happen: 1.You reach a contradiction (e.g., z is forced to be both true and false). 2.You reach a point where no more variables have their truth value forced, but some clauses are not yet made true. 3.You reach a satisfying truth assignment.

40 Proof – (3) uCase 1: (Contradiction) There can only be a satisfying assignment if you use the other truth value for x. wSimplify the formula by replacing x by this truth value and repeat the process. uCase 3: You found a satisfying assignment, so answer “yes.”

41 Proof – (4) uCase 2: (You force values for some variables, but other variables and clauses are not affected). wAdopt these truth values, eliminate the clauses that they satisfy, and repeat. uIn Cases 1 and 2 you have spent O(n 2 ) time and have reduced the length of the formula by > 1, so O(n 3 ) total.

42 3SAT uThis problem is NP-complete. uClearly it is in NP, since SAT is. uIt is not true that every Boolean formula can be converted to an equivalent 3-CNF formula, even if we exponentiate the size of the formula.

43 3SAT – (2) uBut we don’t need equivalence. uWe need to reduce every CNF formula F to some 3-CNF formula that is satisfiable if and only if F is. uReduction involves introducing new variables into long clauses, so we can split them apart.

44 Reduction of CSAT to 3SAT uLet (x 1 +…+x n ) be a clause in some CSAT instance, with n > 4. wNote: the x’s are literals, not variables; any of them could be negated variables. uIntroduce new variables y 1,…,y n-3 that appear in no other clause.

45 CSAT to 3SAT – (2) uReplace (x 1 +…+x n ) by (x 1 +x 2 +y 1 )(x 3 +y 2 + -y 1 ) … (x i +y i-1 + -y i-2 ) … (x n-2 +y n-3 + -y n-4 )(x n-1 +x n + -y n-3 ) uIf there is a satisfying assignment of the x’s for the CSAT instance, then one of the literals x i must be made true. uAssign y j = true if j < i-1 and y j = false for larger j.

46 CSAT to 3SAT – (3) uWe are not done. uWe also need to show that if the resulting 3SAT instance is satisfiable, then the original CSAT instance was satisfiable.

47 CSAT to 3SAT – (4) uSuppose (x 1 +x 2 +y 1 )(x 3 +y 2 + -y 1 ) … (x n-2 +y n-3 + -y n-4 )(x n-1 +x n + -y n-3 ) is satisfiable, but none of the x’s is true. uThe first clause forces y 1 = true. uThen the second clause forces y 2 = true. uAnd so on … all the y’s must be true. uBut then the last clause is false.

48 CSAT to 3SAT – (5) uThere is a little more to the reduction, for handling clauses of 1 or 2 literals. uReplace (x) by (x+y 1 +y 2 ) (x+y 1 + -y 2 ) (x+ -y 1 +y 2 ) (x+ -y 1 + -y 2 ). uReplace (w+x) by (w+x+y)(w+x+ -y). uRemember: the y’s are different variables for each CNF clause.

49 CSAT to 3SAT Running Time uThis reduction is surely polynomial. uIn fact it is linear in the length of the CSAT instance. uThus, we have polytime-reduced CSAT to 3SAT. uSince CSAT is NP-complete, so is 3SAT.