34
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 most p(|x|) steps on input x.

L is in NP iff there is a language L ’ in P and a polynomial p so that :

Embed Size (px)

DESCRIPTION

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 most p (| x |) steps on input x. NP. - PowerPoint PPT Presentation

Citation preview

Page 1: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

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 most p(|x|) steps on input x.

Page 2: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

2

NP

L is in NP iff there is a language L’ in P and a polynomial p so that:

Page 3: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

3

Reductions

• A reduction r of L1 to L2 is a polynomial time computable map so that

x : x ∈ L1 iff r(x) ∈ L2

• We write L1 ≤ L2 if L1 reduces to L2.

• Intuition: Efficient software for L2 can also be used to efficiently solve L1.

Page 4: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

4

Properties of reductions

Transitivity:

L1 ≤ L2 ∧ L2 ≤ L3 ⇒ L1 ≤ L3

Downward closure of P:

L1 ≤ L2 ∧ L2 ∈ P ⇒ L1 ∈ P.

• Follows from Polynomial Church-Turing thesis.

Page 5: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

5

NP-hardness

• A language L is called NP-hard iff L’ ∈ NP: L’ ≤ L

• Intuition: Software for L is strong enough to be used to solve any simple search problem.

• Proposition: If some NP-hard language is in P, then P=NP.

Page 6: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

6

NPC

• A language L ∈ NP that is NP-hard is called NP-complete.

• NPC := the class of NP-complete problems.

• Proposition:

L ∈ NPC ⇒ [L ∈ P iff P=NP].

Page 7: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

7

•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 r(x) L2

•L is NP-hard means: L’ NP: L’ ≤ L

•L is in NPC means:

L NP and L is NP-hard

Page 8: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

8

How to establish NP-hardness

•Lemma: If L1 is NP-hard and L1 ≤ L2 then L2 is NP-hard.

Page 9: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

9

Boolean functions

•f: {false, true}n {false,true}

•Example: XOR(x1, x2) = x1 x2

•XOR(true , true) = false

•In this course 0=false, 1=true.

•XOR(1,1)=0

Page 10: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

10

How to represent Boolean functions on a computer

•Tables.

•Formulae.

Page 11: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

11

Tables

•More compact representation as Boolean String: “0110”.•A function f: {0,1}n {0,1} can be represented as a table using … ……..2n bits

Page 12: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

12

Boolean Formulae

•X1, X2, …, Xn are formulae.

•If f is a formula then f is a formula.

•If f1 and f2 are formulae then (f1) ∧ (f2) and (f1) ∨ (f2) are formulae.

•Sometimes we leave out parentheses….

Page 13: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

13

Formulae represent Boolean functions

•“(x1 ∧x2) ∨ (x2 ∧x1)” represents the function XOR.

•Sometimes formula-representation is much more compact than table representation. Sometimes not.

•It’s never much less compact.

Page 14: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

14

Two special classes of Boolean formulae

f(x1, x2) = x1 x2

• DNF: f(x1, x2) = (x1 ∧ ¬x2) ∨ (x2 ∧ ¬x1)

• CNF: f(x1, x2) = (¬x1 ∨ ¬x2) ∧ (x1 ∨ x2)

•A CNF is any conjunction of clauses (disjunctions of literals). A DNF is any disjunction of terms (conjunctions of literals).

•Any function on n variables can be described by a CNF (DNF) formula containing at most 2n clauses (terms), each containing at most n literals.

Page 15: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

15

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?•SAT: Given a CNF, is it true that it does not represent the constant-0 function?

•Input: (¬x1 ∨ ¬x2) ∧ (x1 ∨ x2)•Output: Yes.•Input: (¬x1 ∨ ¬x2) ∧ (x1 ∨ x2) ∧ (x1 ∨ ¬x2 ) ∧ (¬x1 ∨ x2)•Output: No.

Page 16: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

16

SAT

•SAT is in NP.

•Cook’s theorem (1972): SAT is NP-hard.

Page 17: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

17

Circuits

•A circuit C is a directed acyclic graph.•Nodes in C are called gates.

Types of gates:–Variable (or input) gates of indegree 0, labeled X1, X2, …Xn

–Constant gates of indegree 0, labeled 0,1–AND-, OR-gates of indegree 2,–NOT-, COPY-gates of indegree 1.–m distinguished gates are output gates.

The circuit C computes a Boolean function

C: {0,1}n {0,1}m

Page 18: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

18

A formula can be viewed as a special kind of circuit

f(X1, X2, X3) = ¬X1 ∨(X1 ∧ X2 ∧ X3)

¬

X1 X2

X3

X1

Page 19: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

19

A formula can be viewed as a special kind of circuit

f(X1, X2, X3) = ¬X1 ∨(X1 ∧ X2 ∧ X3)

¬

X1 X2

X3

Convention: For each j, at most gate is labeled Xj

Page 20: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

20

Are formulas and circuits in fact the same thing?

•Not quite!

•Given a circuit, we can write down an equivalent formula, but in may become much bigger.

•A circuit is allowed to reuse the result of a sub-computation without doing the computation again!

Page 21: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

21

Multi-output circuits

Any function f: {0,1}n {0,1}m is represented by some circuit.

Proof:

Any function f: {0,1}n {0,1} can be described by a Boolean formula.

•A formula can also be viewed as a circuit.

•Combine m such circuits.

Page 22: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

22

Cooks’ theorem: SAT is NP-hard

•Proof of Cook’s theorem:– CIRCUIT SAT is NP-hard.– CIRCUIT SAT reduces to SAT.– Hence, SAT is NP-hard.

Page 23: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

23

CIRCUIT SAT

•CIRCUIT SAT: Given a Boolean circuit, is there a way to assign truth values to the input gates, so that the output gate evaluates to true?

•Generalizes SAT, as CNFs are formulas and formulas are circuits.

Page 24: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

24

Example

X1 X2

X3

Input:

Output: Yes

¬

Page 25: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

25

Example

Output: No⋀

X1 X2

X3

Input:

¬

Page 26: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

26

Cooks’ theorem: SAT is NP-hard

•Proof of Cook’s theorem:– CIRCUIT SAT is NP-hard.– CIRCUIT SAT reduces to SAT.– Hence, SAT is NP-hard.

We first prove CIRCUIT SAT reduces to SAT

Page 27: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

27

Circuits vs. Turing Machines

•We consider Circuits also as computational devices themselves.

•Like Turing Machines, circuits C: {0,1}n {0,1} solve decision problems on {0,1}n.

•Unlike Turing machines, circuits takes inputs of a fixed input length n only.

Page 28: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

28

Theorem

•Given Turing Machine M running in time at most p(n)≥n on inputs of length n, where p is a polynomial.

•For every n, there is a circuit Cn with at most O(p(n)2) gates so that

∀x ∈ {0,1}n: Cn(x)=1 iff M accepts x.

•The map 1n Cn is polynomial time computable.

Page 29: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

29

Intuition behind proof

Page 30: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

30

Problem: Cycles!

Flip-Flop, stores one bit.

Page 31: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

31

The Tableau Method

Time 0

Time 1

Time t

s21

Can be replaced byacyclic Booleancircuit of size ≈ s

Page 32: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

32

Cell state vectors

•Given a Turing Machine computation, an integer t and an integer i let cti {0,1}s be a Boolean representation of the following information, a cell state vector:

–The symbol in cell i at time t–Whether or not the head is pointing to cell i at time t–If the head is pointing to cell i, what is the state of the finite control of the Turing machine at time t?

•The integer s depends only on the Turing machine (not the input to the computation, nor t,i).

•To make cti defined for all t, we let c(t+1)i = cti if the computation has already terminated at time t.

Page 33: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

33

Crucial Observation

•If we know the Turing machine and •ct-1,i-1, ct-1,i, ct-1, i+1, we also can determine ct,i.

•In other words, there is a Boolean function h depending only on the Turing machine so that ct,i = h(ct-1,i-1, ct-1,i, ct-1,i+1).

•A circuit D for h is the central building block in a circuit computing all cell state vectors for all times for a given input.

Page 34: L  is in  NP    iff there  is a  language L ’ in  P  and a  polynomial p  so  that :

342 t(n)

t(n)

x1 xn