# Chapter 7: Time Complexity

## Chapter 7.4, NP-Completeness

### Preliminaries

• Definition. A function f: Σ* → Σ* is a polynomial time computable function if some polynomial time Turing Machine M exists that halts with just f(w) on its tape, when started on input w.
• Definition. Language A is polynomial time mapping reducible or simply polynomial time reducible to language B, written A ≤P B, if a polynomial time computable function f: Σ* → Σ* exists where for every w, w ∈ A ⇔ f(w) ∈ B. The function f is called the polynomial time reduction of A to B.
• Theorem. If A ≤P B and B ∈ P, then A ∈ P.

### NP-Complete Problems

• Definition. A language B is NP-Complete if (1) B is in NP and (2) every A in NP is polynomial time reducible to B.
• Theorem. If B is in NPC and B ∈ P, then P = NP.
• Theorem. If B is in NPC and B ≤P C for C in NP, then C is in NPC.

### Satisfiability Problem

• SAT = {<Φ> | Φ is a satisfiable Boolean formula.}
• SAT was the first problem proved to be in NPC by Stephen Cook and Leonid Levin in 1971.
• Theorem. SAT ∈ P iff P = NP.

### 3SAT Problem

• 3SAT = {<Φ> | Φ is a satisfiable 3cnf formula}. Every clause is a 3cnf (conjunctive normal form) has exactly 3 literals.
• 3SAT is an NPC problem.
• How do you show that 3SAT is in NP?
• How do you show that there is a polynomial time reduction from SAT to 3SAT?

### Active Learning

• Convert ¬(a ∨ b) to 3SAT.
• Convert ¬(a ∨ b) ∨ ((¬ d ∨ e) ∧ f) to 3SAT.

### Useful Boolean Identities

• ¬(P ∨ Q) ≡ ¬P ∧ ¬Q
• ¬(P ∧ Q) ≡ ¬P ∨ ¬Q
• P ∨ (Q ∧ R) ≡ (P ∨ Q) ∧ (P ∨ R).
• P ∧ (Q ∨ R) ≡ (P ∧ Q) ∨ (P ∧ R).