86
NP-Completeness Peter Lammich March 2, 2020 1 / 20

NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

NP-Completeness

Peter Lammich

March 2, 2020

1 / 20

Page 2: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Last Lecture

• Decision Problems: Language = accepted bit-strings

• Reduction: A ≤p B. Encode problem A as problem B• x ∈ LA ⇐⇒ f (x) ∈ LB• f computable in polynomial time• A not harder than B

• Certificate: extra information to verify membership in language• Sound and complete: (∃c. check(w , c)) ⇐⇒ w ∈ L• Example: solution of Boolean formula

• NP: problems with poly-time certificates• NP-hard: harder than any problem in NP• NP-complete = in NP + NP-hard

• How to show that problem is ...• ... in NP: show it has poly-time certificates• ... NP-hard: reduce another NP-hard problem to it

2 / 20

Page 3: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Last Lecture

• Decision Problems: Language = accepted bit-strings• Reduction: A ≤p B. Encode problem A as problem B

• x ∈ LA ⇐⇒ f (x) ∈ LB• f computable in polynomial time• A not harder than B

• Certificate: extra information to verify membership in language• Sound and complete: (∃c. check(w , c)) ⇐⇒ w ∈ L• Example: solution of Boolean formula

• NP: problems with poly-time certificates• NP-hard: harder than any problem in NP• NP-complete = in NP + NP-hard

• How to show that problem is ...• ... in NP: show it has poly-time certificates• ... NP-hard: reduce another NP-hard problem to it

2 / 20

Page 4: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Last Lecture

• Decision Problems: Language = accepted bit-strings• Reduction: A ≤p B. Encode problem A as problem B

• x ∈ LA ⇐⇒ f (x) ∈ LB• f computable in polynomial time• A not harder than B

• Certificate: extra information to verify membership in language• Sound and complete: (∃c. check(w , c)) ⇐⇒ w ∈ L• Example: solution of Boolean formula

• NP: problems with poly-time certificates• NP-hard: harder than any problem in NP• NP-complete = in NP + NP-hard

• How to show that problem is ...• ... in NP: show it has poly-time certificates• ... NP-hard: reduce another NP-hard problem to it

2 / 20

Page 5: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Last Lecture

• Decision Problems: Language = accepted bit-strings• Reduction: A ≤p B. Encode problem A as problem B

• x ∈ LA ⇐⇒ f (x) ∈ LB• f computable in polynomial time• A not harder than B

• Certificate: extra information to verify membership in language• Sound and complete: (∃c. check(w , c)) ⇐⇒ w ∈ L• Example: solution of Boolean formula

• NP: problems with poly-time certificates• NP-hard: harder than any problem in NP• NP-complete = in NP + NP-hard

• How to show that problem is ...• ... in NP: show it has poly-time certificates• ... NP-hard: reduce another NP-hard problem to it

2 / 20

Page 6: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Last Lecture

• Decision Problems: Language = accepted bit-strings• Reduction: A ≤p B. Encode problem A as problem B

• x ∈ LA ⇐⇒ f (x) ∈ LB• f computable in polynomial time• A not harder than B

• Certificate: extra information to verify membership in language• Sound and complete: (∃c. check(w , c)) ⇐⇒ w ∈ L• Example: solution of Boolean formula

• NP: problems with poly-time certificates• NP-hard: harder than any problem in NP• NP-complete = in NP + NP-hard

• How to show that problem is ...• ... in NP: show it has poly-time certificates• ... NP-hard: reduce another NP-hard problem to it

2 / 20

Page 7: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Circuit-SAT

• Given a combinational circuit with n gates, m ≤ 2n inputs, and oneoutput

• Let’s restrict gate types to AND, OR, NOT

• Can the inputs be driven such that the output goes to 1?• Circuit-SAT is in NP

• given the inputs, simulate the circuit and check the output• obviously polynomial time!

• Now: Circuit-SAT is NP-hard

• only sketch of proof• precise proof: lot’s of subtle technical details

3 / 20

Page 8: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Circuit-SAT

• Given a combinational circuit with n gates, m ≤ 2n inputs, and oneoutput

• Let’s restrict gate types to AND, OR, NOT

• Can the inputs be driven such that the output goes to 1?

• Circuit-SAT is in NP• given the inputs, simulate the circuit and check the output• obviously polynomial time!

• Now: Circuit-SAT is NP-hard

• only sketch of proof• precise proof: lot’s of subtle technical details

3 / 20

Page 9: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Circuit-SAT

• Given a combinational circuit with n gates, m ≤ 2n inputs, and oneoutput

• Let’s restrict gate types to AND, OR, NOT

• Can the inputs be driven such that the output goes to 1?• Circuit-SAT is in NP

• given the inputs, simulate the circuit and check the output• obviously polynomial time!

• Now: Circuit-SAT is NP-hard

• only sketch of proof• precise proof: lot’s of subtle technical details

3 / 20

Page 10: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Circuit-SAT

• Given a combinational circuit with n gates, m ≤ 2n inputs, and oneoutput

• Let’s restrict gate types to AND, OR, NOT

• Can the inputs be driven such that the output goes to 1?• Circuit-SAT is in NP

• given the inputs, simulate the circuit and check the output• obviously polynomial time!

• Now: Circuit-SAT is NP-hard

• only sketch of proof• precise proof: lot’s of subtle technical details

3 / 20

Page 11: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Circuit-SAT

• Given a combinational circuit with n gates, m ≤ 2n inputs, and oneoutput

• Let’s restrict gate types to AND, OR, NOT

• Can the inputs be driven such that the output goes to 1?• Circuit-SAT is in NP

• given the inputs, simulate the circuit and check the output• obviously polynomial time!

• Now: Circuit-SAT is NP-hard• only sketch of proof

• precise proof: lot’s of subtle technical details

3 / 20

Page 12: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Circuit-SAT

• Given a combinational circuit with n gates, m ≤ 2n inputs, and oneoutput

• Let’s restrict gate types to AND, OR, NOT

• Can the inputs be driven such that the output goes to 1?• Circuit-SAT is in NP

• given the inputs, simulate the circuit and check the output• obviously polynomial time!

• Now: Circuit-SAT is NP-hard• only sketch of proof• precise proof: lot’s of subtle technical details

3 / 20

Page 13: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT

• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit

• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1

• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 14: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit

• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1

• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 15: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit

• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1

• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 16: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit

• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1

• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 17: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit

• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1

• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 18: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit• with |w |k2 inputs and one output

• that simulates (|w | + |w |k2)k1 steps of check(w , ·)• Circuit-SAT checks if there are inputs that produce output 1

• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 19: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1

• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 20: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1

• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 21: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1• YES: the inputs correspond to valid certificate =⇒ w ∈ LA

• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 22: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 23: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Proof Sketch: Circuit-SAT is NP-hard

Reduce some arbitrary problem A ∈ NP to Circuit-SAT• A has poly-time certificates.

• check(w , c) function that runs in time < (|w | + |c|)k1

• any word w ∈ L has certificate c, with |c| < |w |k2

• To check w ∈ LA, we construct a circuit• with |w |k2 inputs and one output• that simulates (|w | + |w |k2)k1 steps of check(w , ·)

• Circuit-SAT checks if there are inputs that produce output 1• YES: the inputs correspond to valid certificate =⇒ w ∈ LA• NO: there is no valid certificate (within size bound) =⇒ w /∈ LA

• Now: How to construct such a circuit

4 / 20

Page 24: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Let’s Build a (simplistic) Computer!

• Ingredients:• n bits of memory• a control circuit C with n inputs, n outputs, and poly(n) gates

• Working mode: in each cycle:• feed the memory content to the inputs• and then update the memory with the outputs

• For n bits of memory, a circuit of size poly(n) is enough!• and can be constructed in poly(n) time

• How realistic is that?

• not very realistic! BUT• powerful enough to run programs• easy enough to be simulated by standard computer

• in poly(n) time per cycle!

5 / 20

Page 25: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Let’s Build a (simplistic) Computer!

• Ingredients:• n bits of memory• a control circuit C with n inputs, n outputs, and poly(n) gates

• Working mode: in each cycle:• feed the memory content to the inputs• and then update the memory with the outputs

• For n bits of memory, a circuit of size poly(n) is enough!• and can be constructed in poly(n) time

• How realistic is that?

• not very realistic! BUT• powerful enough to run programs• easy enough to be simulated by standard computer

• in poly(n) time per cycle!

5 / 20

Page 26: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Let’s Build a (simplistic) Computer!

• Ingredients:• n bits of memory• a control circuit C with n inputs, n outputs, and poly(n) gates

• Working mode: in each cycle:• feed the memory content to the inputs• and then update the memory with the outputs

• For n bits of memory, a circuit of size poly(n) is enough!• and can be constructed in poly(n) time

• How realistic is that?

• not very realistic! BUT• powerful enough to run programs• easy enough to be simulated by standard computer

• in poly(n) time per cycle!

5 / 20

Page 27: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Let’s Build a (simplistic) Computer!

• Ingredients:• n bits of memory• a control circuit C with n inputs, n outputs, and poly(n) gates

• Working mode: in each cycle:• feed the memory content to the inputs• and then update the memory with the outputs

• For n bits of memory, a circuit of size poly(n) is enough!• and can be constructed in poly(n) time

• How realistic is that?

• not very realistic! BUT• powerful enough to run programs• easy enough to be simulated by standard computer

• in poly(n) time per cycle!

5 / 20

Page 28: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Let’s Build a (simplistic) Computer!

• Ingredients:• n bits of memory• a control circuit C with n inputs, n outputs, and poly(n) gates

• Working mode: in each cycle:• feed the memory content to the inputs• and then update the memory with the outputs

• For n bits of memory, a circuit of size poly(n) is enough!• and can be constructed in poly(n) time

• How realistic is that?• not very realistic! BUT

• powerful enough to run programs• easy enough to be simulated by standard computer

• in poly(n) time per cycle!

5 / 20

Page 29: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Let’s Build a (simplistic) Computer!

• Ingredients:• n bits of memory• a control circuit C with n inputs, n outputs, and poly(n) gates

• Working mode: in each cycle:• feed the memory content to the inputs• and then update the memory with the outputs

• For n bits of memory, a circuit of size poly(n) is enough!• and can be constructed in poly(n) time

• How realistic is that?• not very realistic! BUT• powerful enough to run programs

• easy enough to be simulated by standard computer• in poly(n) time per cycle!

5 / 20

Page 30: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Let’s Build a (simplistic) Computer!

• Ingredients:• n bits of memory• a control circuit C with n inputs, n outputs, and poly(n) gates

• Working mode: in each cycle:• feed the memory content to the inputs• and then update the memory with the outputs

• For n bits of memory, a circuit of size poly(n) is enough!• and can be constructed in poly(n) time

• How realistic is that?• not very realistic! BUT• powerful enough to run programs• easy enough to be simulated by standard computer

• in poly(n) time per cycle!

5 / 20

Page 31: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Our Computer

input | program | PC | aux-memory Control Circuit

Clock

6 / 20

Page 32: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Simulating n cycles

• link together n − 1 copies of the control circuit• yields circuit with (n − 1)poly(n) = poly(n) gates• inputs of first copy: initial memory• outputs of last copy: memory after n cycles

• initializing some of the inputs• partially evaluate the circuit• only reduces number of gates• here: initialize program, PC, aux-memory.

• ignoring some outputs• only reduces number of gates• here: keep only the single bit that contains result

7 / 20

Page 33: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Simulating n cycles

• link together n − 1 copies of the control circuit• yields circuit with (n − 1)poly(n) = poly(n) gates• inputs of first copy: initial memory• outputs of last copy: memory after n cycles

• initializing some of the inputs• partially evaluate the circuit• only reduces number of gates• here: initialize program, PC, aux-memory.

• ignoring some outputs• only reduces number of gates• here: keep only the single bit that contains result

7 / 20

Page 34: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Simulating n cycles

• link together n − 1 copies of the control circuit• yields circuit with (n − 1)poly(n) = poly(n) gates• inputs of first copy: initial memory• outputs of last copy: memory after n cycles

• initializing some of the inputs• partially evaluate the circuit• only reduces number of gates• here: initialize program, PC, aux-memory.

• ignoring some outputs• only reduces number of gates• here: keep only the single bit that contains result

7 / 20

Page 35: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Circuit for n cyclesinitial memory

Control Circuit (copy 1)

Control Circuit (copy 2)

. . .

Control Circuit (copy n − 1)

memory after n cycles

8 / 20

Page 36: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Outlook

• We have an initial NP-complete problem• We now reduce it to other problems, to show that they are

NP-complete, too!• Circuit-SAT ≤p SAT ≤p 3SAT ≤p CLIQUE . . .

9 / 20

Page 37: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT

• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 38: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT

• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 39: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT

• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 40: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT• Introduce one variable per wire (input, output, internal)

• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 41: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 42: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is

• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 43: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)

• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 44: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)

• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 45: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!

• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)• can obviously be done in polynomial time

• constant work per gate and variable!

10 / 20

Page 46: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 47: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT• Is a Boolean formula with m operators and n variables satisfiable?

∃x1 . . . xn. x1 ∧ (x2 ∨ ¬x3) ∨ x4 . . .

• SAT is in NP: solution can be checked by evaluating formula.• obviously in polynomial time!

• SAT is NP-hard: show Circuit-SAT ≤p SAT• Introduce one variable per wire (input, output, internal)• SAT-formula: xo ∧ G1 ∧ . . . ∧ Gn

• where xo is variable for output, and for each gate, Gi is• AND-gate (in x1, x2, out x3): x3 ↔ (x1 ∧ x2)• OR-gate (in x1, x2, out x3): x3 ↔ (x1 ∨ x2)• Inverted input/output: Add a ¬!• where x1 ↔ x2 is short for (x1 ∧ x2) ∨ (¬x1 ∧ ¬x2)

• can obviously be done in polynomial time• constant work per gate and variable!

10 / 20

Page 48: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Circuit-SAT ≤p SAT

e∧ ¬x1 ↔ b ∨ c∧ x2 ↔ a ∧ x1

∧ x3 ↔ ¬d ∧ x1

∧ e ↔ x2 ∨ x3

11 / 20

Page 49: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT• Boolean formula in CNF, exactly 3 literals over different variables per

clause• E.g. (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3)

• Obviously 3SAT is in NP.• To prove it is NP-Hard: Show SAT ≤p 3SAT• Converting SAT formula to 3SAT

1 encode parse tree (same idea as for Circuit-SAT ≤p SAT)• one new variable yi per node ti .• for root node tr , add clause yr• for literals: use yi = xi• for node ti = AND(tj , tk), add clause yi ↔ yj ∧ yk• similar for OR, NOT

2 convert to CNF• Convert clauses xi ↔ . . . to CNF• e.g. xi ↔ xj ∧ xk to (¬x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (x1 ∨ ¬x2 ∨ ¬x3)

3 eliminate duplicates:• remove clauses that contain both, x and ¬x• remove duplicate literals from clause

4 fill clauses to 3 variablesa l1 ∨ l2 to (l1 ∨ l2 ∨ p) ∧ (l1 ∨ l2 ∨ ¬p) for fresh variable pb l1 to (l1 ∨ p) ∧ (l1 ∨ ¬p) for fresh variable p, then a)

12 / 20

Page 50: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT• Boolean formula in CNF, exactly 3 literals over different variables per

clause• E.g. (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3)

• Obviously 3SAT is in NP.

• To prove it is NP-Hard: Show SAT ≤p 3SAT• Converting SAT formula to 3SAT

1 encode parse tree (same idea as for Circuit-SAT ≤p SAT)• one new variable yi per node ti .• for root node tr , add clause yr• for literals: use yi = xi• for node ti = AND(tj , tk), add clause yi ↔ yj ∧ yk• similar for OR, NOT

2 convert to CNF• Convert clauses xi ↔ . . . to CNF• e.g. xi ↔ xj ∧ xk to (¬x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (x1 ∨ ¬x2 ∨ ¬x3)

3 eliminate duplicates:• remove clauses that contain both, x and ¬x• remove duplicate literals from clause

4 fill clauses to 3 variablesa l1 ∨ l2 to (l1 ∨ l2 ∨ p) ∧ (l1 ∨ l2 ∨ ¬p) for fresh variable pb l1 to (l1 ∨ p) ∧ (l1 ∨ ¬p) for fresh variable p, then a)

12 / 20

Page 51: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT• Boolean formula in CNF, exactly 3 literals over different variables per

clause• E.g. (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3)

• Obviously 3SAT is in NP.• To prove it is NP-Hard: Show SAT ≤p 3SAT

• Converting SAT formula to 3SAT

1 encode parse tree (same idea as for Circuit-SAT ≤p SAT)• one new variable yi per node ti .• for root node tr , add clause yr• for literals: use yi = xi• for node ti = AND(tj , tk), add clause yi ↔ yj ∧ yk• similar for OR, NOT

2 convert to CNF• Convert clauses xi ↔ . . . to CNF• e.g. xi ↔ xj ∧ xk to (¬x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (x1 ∨ ¬x2 ∨ ¬x3)

3 eliminate duplicates:• remove clauses that contain both, x and ¬x• remove duplicate literals from clause

4 fill clauses to 3 variablesa l1 ∨ l2 to (l1 ∨ l2 ∨ p) ∧ (l1 ∨ l2 ∨ ¬p) for fresh variable pb l1 to (l1 ∨ p) ∧ (l1 ∨ ¬p) for fresh variable p, then a)

12 / 20

Page 52: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT• Boolean formula in CNF, exactly 3 literals over different variables per

clause• E.g. (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3)

• Obviously 3SAT is in NP.• To prove it is NP-Hard: Show SAT ≤p 3SAT• Converting SAT formula to 3SAT

1 encode parse tree (same idea as for Circuit-SAT ≤p SAT)• one new variable yi per node ti .• for root node tr , add clause yr• for literals: use yi = xi• for node ti = AND(tj , tk), add clause yi ↔ yj ∧ yk• similar for OR, NOT

2 convert to CNF• Convert clauses xi ↔ . . . to CNF• e.g. xi ↔ xj ∧ xk to (¬x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (x1 ∨ ¬x2 ∨ ¬x3)

3 eliminate duplicates:• remove clauses that contain both, x and ¬x• remove duplicate literals from clause

4 fill clauses to 3 variablesa l1 ∨ l2 to (l1 ∨ l2 ∨ p) ∧ (l1 ∨ l2 ∨ ¬p) for fresh variable pb l1 to (l1 ∨ p) ∧ (l1 ∨ ¬p) for fresh variable p, then a)

12 / 20

Page 53: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT• Boolean formula in CNF, exactly 3 literals over different variables per

clause• E.g. (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3)

• Obviously 3SAT is in NP.• To prove it is NP-Hard: Show SAT ≤p 3SAT• Converting SAT formula to 3SAT

1 encode parse tree (same idea as for Circuit-SAT ≤p SAT)• one new variable yi per node ti .• for root node tr , add clause yr• for literals: use yi = xi• for node ti = AND(tj , tk), add clause yi ↔ yj ∧ yk• similar for OR, NOT

2 convert to CNF• Convert clauses xi ↔ . . . to CNF• e.g. xi ↔ xj ∧ xk to (¬x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (x1 ∨ ¬x2 ∨ ¬x3)

3 eliminate duplicates:• remove clauses that contain both, x and ¬x• remove duplicate literals from clause

4 fill clauses to 3 variablesa l1 ∨ l2 to (l1 ∨ l2 ∨ p) ∧ (l1 ∨ l2 ∨ ¬p) for fresh variable pb l1 to (l1 ∨ p) ∧ (l1 ∨ ¬p) for fresh variable p, then a)

12 / 20

Page 54: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT• Boolean formula in CNF, exactly 3 literals over different variables per

clause• E.g. (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3)

• Obviously 3SAT is in NP.• To prove it is NP-Hard: Show SAT ≤p 3SAT• Converting SAT formula to 3SAT

1 encode parse tree (same idea as for Circuit-SAT ≤p SAT)• one new variable yi per node ti .• for root node tr , add clause yr• for literals: use yi = xi• for node ti = AND(tj , tk), add clause yi ↔ yj ∧ yk• similar for OR, NOT

2 convert to CNF• Convert clauses xi ↔ . . . to CNF• e.g. xi ↔ xj ∧ xk to (¬x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (x1 ∨ ¬x2 ∨ ¬x3)

3 eliminate duplicates:• remove clauses that contain both, x and ¬x• remove duplicate literals from clause

4 fill clauses to 3 variablesa l1 ∨ l2 to (l1 ∨ l2 ∨ p) ∧ (l1 ∨ l2 ∨ ¬p) for fresh variable pb l1 to (l1 ∨ p) ∧ (l1 ∨ ¬p) for fresh variable p, then a)

12 / 20

Page 55: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT• Boolean formula in CNF, exactly 3 literals over different variables per

clause• E.g. (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3)

• Obviously 3SAT is in NP.• To prove it is NP-Hard: Show SAT ≤p 3SAT• Converting SAT formula to 3SAT

1 encode parse tree (same idea as for Circuit-SAT ≤p SAT)• one new variable yi per node ti .• for root node tr , add clause yr• for literals: use yi = xi• for node ti = AND(tj , tk), add clause yi ↔ yj ∧ yk• similar for OR, NOT

2 convert to CNF• Convert clauses xi ↔ . . . to CNF• e.g. xi ↔ xj ∧ xk to (¬x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (x1 ∨ ¬x2 ∨ ¬x3)

3 eliminate duplicates:• remove clauses that contain both, x and ¬x• remove duplicate literals from clause

4 fill clauses to 3 variablesa l1 ∨ l2 to (l1 ∨ l2 ∨ p) ∧ (l1 ∨ l2 ∨ ¬p) for fresh variable pb l1 to (l1 ∨ p) ∧ (l1 ∨ ¬p) for fresh variable p, then a)

12 / 20

Page 56: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT• Boolean formula in CNF, exactly 3 literals over different variables per

clause• E.g. (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (¬x1 ∨ ¬x2 ∨ x3)

• Obviously 3SAT is in NP.• To prove it is NP-Hard: Show SAT ≤p 3SAT• Converting SAT formula to 3SAT

1 encode parse tree (same idea as for Circuit-SAT ≤p SAT)• one new variable yi per node ti .• for root node tr , add clause yr• for literals: use yi = xi• for node ti = AND(tj , tk), add clause yi ↔ yj ∧ yk• similar for OR, NOT

2 convert to CNF• Convert clauses xi ↔ . . . to CNF• e.g. xi ↔ xj ∧ xk to (¬x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (x1 ∨ ¬x2 ∨ ¬x3)

3 eliminate duplicates:• remove clauses that contain both, x and ¬x• remove duplicate literals from clause

4 fill clauses to 3 variablesa l1 ∨ l2 to (l1 ∨ l2 ∨ p) ∧ (l1 ∨ l2 ∨ ¬p) for fresh variable pb l1 to (l1 ∨ p) ∧ (l1 ∨ ¬p) for fresh variable p, then a) 12 / 20

Page 57: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT ≤p 3SAT — Example

SAT Formula: ¬(x1 ∧ ¬x2) ∨ x3

Parse tree:∨

¬ x3

x1 ¬

x2

New variables y1, . . . , y4.

Formula for parse-tree:y1 ∧ (y1 ↔ y2 ∨ x3) ∧ (y2 ↔ ¬y3)∧ (y3 ↔ x1 ∧ y4) ∧ y4 ↔ ¬x2

convert to CNF: y1 ∧(¬y1 ∨y2 ∨x3)∧(y1 ∨ ¬y2) ∧ (y1 ∨ ¬x3) ∧ . . .

(no duplicates)

fill clauses to 3 variables(y1 ∨ p1 ∨ p2) ∧ (y1 ∨ p1 ∨ ¬p2)∧ (y1 ∨ ¬p1 ∨ p2) ∧ (y1 ∨ ¬p1 ∨ ¬p2)∧ (¬y1 ∨ y2 ∨ x3)∧ (y1 ∨ ¬y2 ∨ p3) ∧ (y1 ∨ ¬y2 ∨ p3)∧ . . .

13 / 20

Page 58: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT ≤p 3SAT — Example

SAT Formula: ¬(x1 ∧ ¬x2) ∨ x3Parse tree:

¬ x3

x1 ¬

x2

New variables y1, . . . , y4.

Formula for parse-tree:y1 ∧ (y1 ↔ y2 ∨ x3) ∧ (y2 ↔ ¬y3)∧ (y3 ↔ x1 ∧ y4) ∧ y4 ↔ ¬x2

convert to CNF: y1 ∧(¬y1 ∨y2 ∨x3)∧(y1 ∨ ¬y2) ∧ (y1 ∨ ¬x3) ∧ . . .

(no duplicates)

fill clauses to 3 variables(y1 ∨ p1 ∨ p2) ∧ (y1 ∨ p1 ∨ ¬p2)∧ (y1 ∨ ¬p1 ∨ p2) ∧ (y1 ∨ ¬p1 ∨ ¬p2)∧ (¬y1 ∨ y2 ∨ x3)∧ (y1 ∨ ¬y2 ∨ p3) ∧ (y1 ∨ ¬y2 ∨ p3)∧ . . .

13 / 20

Page 59: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT ≤p 3SAT — Example

SAT Formula: ¬(x1 ∧ ¬x2) ∨ x3Parse tree:

∨(y1)

¬(y2) x3

∧(y3)

x1 ¬(y4)

x2

New variables y1, . . . , y4.

Formula for parse-tree:y1 ∧ (y1 ↔ y2 ∨ x3) ∧ (y2 ↔ ¬y3)∧ (y3 ↔ x1 ∧ y4) ∧ y4 ↔ ¬x2

convert to CNF: y1 ∧(¬y1 ∨y2 ∨x3)∧(y1 ∨ ¬y2) ∧ (y1 ∨ ¬x3) ∧ . . .

(no duplicates)

fill clauses to 3 variables(y1 ∨ p1 ∨ p2) ∧ (y1 ∨ p1 ∨ ¬p2)∧ (y1 ∨ ¬p1 ∨ p2) ∧ (y1 ∨ ¬p1 ∨ ¬p2)∧ (¬y1 ∨ y2 ∨ x3)∧ (y1 ∨ ¬y2 ∨ p3) ∧ (y1 ∨ ¬y2 ∨ p3)∧ . . .

13 / 20

Page 60: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT ≤p 3SAT — Example

SAT Formula: ¬(x1 ∧ ¬x2) ∨ x3Parse tree:

∨(y1)

¬(y2) x3

∧(y3)

x1 ¬(y4)

x2

New variables y1, . . . , y4.

Formula for parse-tree:y1 ∧ (y1 ↔ y2 ∨ x3) ∧ (y2 ↔ ¬y3)∧ (y3 ↔ x1 ∧ y4) ∧ y4 ↔ ¬x2

convert to CNF: y1 ∧(¬y1 ∨y2 ∨x3)∧(y1 ∨ ¬y2) ∧ (y1 ∨ ¬x3) ∧ . . .

(no duplicates)

fill clauses to 3 variables(y1 ∨ p1 ∨ p2) ∧ (y1 ∨ p1 ∨ ¬p2)∧ (y1 ∨ ¬p1 ∨ p2) ∧ (y1 ∨ ¬p1 ∨ ¬p2)∧ (¬y1 ∨ y2 ∨ x3)∧ (y1 ∨ ¬y2 ∨ p3) ∧ (y1 ∨ ¬y2 ∨ p3)∧ . . .

13 / 20

Page 61: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT ≤p 3SAT — Example

SAT Formula: ¬(x1 ∧ ¬x2) ∨ x3Parse tree:

∨(y1)

¬(y2) x3

∧(y3)

x1 ¬(y4)

x2

New variables y1, . . . , y4.

Formula for parse-tree:y1 ∧ (y1 ↔ y2 ∨ x3) ∧ (y2 ↔ ¬y3)∧ (y3 ↔ x1 ∧ y4) ∧ y4 ↔ ¬x2

convert to CNF: y1 ∧(¬y1 ∨y2 ∨x3)∧(y1 ∨ ¬y2) ∧ (y1 ∨ ¬x3) ∧ . . .

(no duplicates)

fill clauses to 3 variables(y1 ∨ p1 ∨ p2) ∧ (y1 ∨ p1 ∨ ¬p2)∧ (y1 ∨ ¬p1 ∨ p2) ∧ (y1 ∨ ¬p1 ∨ ¬p2)∧ (¬y1 ∨ y2 ∨ x3)∧ (y1 ∨ ¬y2 ∨ p3) ∧ (y1 ∨ ¬y2 ∨ p3)∧ . . .

13 / 20

Page 62: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT ≤p 3SAT — Example

SAT Formula: ¬(x1 ∧ ¬x2) ∨ x3Parse tree:

∨(y1)

¬(y2) x3

∧(y3)

x1 ¬(y4)

x2

New variables y1, . . . , y4.

Formula for parse-tree:y1 ∧ (y1 ↔ y2 ∨ x3) ∧ (y2 ↔ ¬y3)∧ (y3 ↔ x1 ∧ y4) ∧ y4 ↔ ¬x2

convert to CNF: y1 ∧(¬y1 ∨y2 ∨x3)∧(y1 ∨ ¬y2) ∧ (y1 ∨ ¬x3) ∧ . . .

(no duplicates)

fill clauses to 3 variables(y1 ∨ p1 ∨ p2) ∧ (y1 ∨ p1 ∨ ¬p2)∧ (y1 ∨ ¬p1 ∨ p2) ∧ (y1 ∨ ¬p1 ∨ ¬p2)∧ (¬y1 ∨ y2 ∨ x3)∧ (y1 ∨ ¬y2 ∨ p3) ∧ (y1 ∨ ¬y2 ∨ p3)∧ . . .

13 / 20

Page 63: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

SAT ≤p 3SAT — Example

SAT Formula: ¬(x1 ∧ ¬x2) ∨ x3Parse tree:

∨(y1)

¬(y2) x3

∧(y3)

x1 ¬(y4)

x2

New variables y1, . . . , y4.

Formula for parse-tree:y1 ∧ (y1 ↔ y2 ∨ x3) ∧ (y2 ↔ ¬y3)∧ (y3 ↔ x1 ∧ y4) ∧ y4 ↔ ¬x2

convert to CNF: y1 ∧(¬y1 ∨y2 ∨x3)∧(y1 ∨ ¬y2) ∧ (y1 ∨ ¬x3) ∧ . . .

(no duplicates)

fill clauses to 3 variables(y1 ∨ p1 ∨ p2) ∧ (y1 ∨ p1 ∨ ¬p2)∧ (y1 ∨ ¬p1 ∨ p2) ∧ (y1 ∨ ¬p1 ∨ ¬p2)∧ (¬y1 ∨ y2 ∨ x3)∧ (y1 ∨ ¬y2 ∨ p3) ∧ (y1 ∨ ¬y2 ∨ p3)∧ . . .

13 / 20

Page 64: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Why 3SAT?

• 3-SAT is very restrictive compared to SAT

• Bad, if we want to reduce a problem to 3SAT• Need to encode problem to very restrictive form

• Good, if we want to reduce 3SAT to a problem• Only need to encode very special clauses to problem

14 / 20

Page 65: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Why 3SAT?

• 3-SAT is very restrictive compared to SAT• Bad, if we want to reduce a problem to 3SAT

• Need to encode problem to very restrictive form

• Good, if we want to reduce 3SAT to a problem• Only need to encode very special clauses to problem

14 / 20

Page 66: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Why 3SAT?

• 3-SAT is very restrictive compared to SAT• Bad, if we want to reduce a problem to 3SAT

• Need to encode problem to very restrictive form• Good, if we want to reduce 3SAT to a problem

• Only need to encode very special clauses to problem

14 / 20

Page 67: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE

• Given an undirected graph (V , E ).• We assume that E is symmetric, i.e., (u, v) ∈ E =⇒ (v , u) ∈ E

• A clique C is a set of pairwise connected nodes:• C ⊆ V and ∀u, v ∈ V .u 6= v =⇒ (u, v) ∈ E• n-clique: clique of size n

• Optimization problem: find a largest clique• Decision problem: is there a clique of size ≥ k?

15 / 20

Page 68: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE

• Given an undirected graph (V , E ).• We assume that E is symmetric, i.e., (u, v) ∈ E =⇒ (v , u) ∈ E

• A clique C is a set of pairwise connected nodes:• C ⊆ V and ∀u, v ∈ V .u 6= v =⇒ (u, v) ∈ E• n-clique: clique of size n

• Optimization problem: find a largest clique• Decision problem: is there a clique of size ≥ k?

15 / 20

Page 69: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE

• Given an undirected graph (V , E ).• We assume that E is symmetric, i.e., (u, v) ∈ E =⇒ (v , u) ∈ E

• A clique C is a set of pairwise connected nodes:• C ⊆ V and ∀u, v ∈ V .u 6= v =⇒ (u, v) ∈ E• n-clique: clique of size n

• Optimization problem: find a largest clique

• Decision problem: is there a clique of size ≥ k?

15 / 20

Page 70: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE

• Given an undirected graph (V , E ).• We assume that E is symmetric, i.e., (u, v) ∈ E =⇒ (v , u) ∈ E

• A clique C is a set of pairwise connected nodes:• C ⊆ V and ∀u, v ∈ V .u 6= v =⇒ (u, v) ∈ E• n-clique: clique of size n

• Optimization problem: find a largest clique• Decision problem: is there a clique of size ≥ k?

15 / 20

Page 71: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE examples

1

3

42

5

6

1

2

45

3

6

16 / 20

Page 72: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE examples

1

3

42

5

6

1

2

45

3

6

16 / 20

Page 73: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE examples

1

3

42

5

61

2

45

3

6

16 / 20

Page 74: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE examples

1

3

42

5

61

2

45

3

6

16 / 20

Page 75: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE is NP-complete

• Obviously in NP: Given set of nodes can easily be verified to be aclique

• NP-hard: Reduction from 3SAT

• given 3SAT problem (l11 ∨ l2

1 ∨ l31 ) ∧ . . . ∧ (l1

n ∨ l2n ∨ l3

n )• construct graph:

• one node per l ji : V = {uj

i | i ≤ n ∧ j ≤ 3}• edges between non-contradicting literals of different clauses:

E = {(uji , uj′

i′ ) | i 6= i ′ ∧ j ≤ 3 ∧ (uji , uj′

i′ ) not contradicting}• contradicting: literals of the form x , ¬x .

• claim: graph has n-clique, iff formula satisfiable!

17 / 20

Page 76: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE is NP-complete

• Obviously in NP: Given set of nodes can easily be verified to be aclique

• NP-hard: Reduction from 3SAT

• given 3SAT problem (l11 ∨ l2

1 ∨ l31 ) ∧ . . . ∧ (l1

n ∨ l2n ∨ l3

n )• construct graph:

• one node per l ji : V = {uj

i | i ≤ n ∧ j ≤ 3}• edges between non-contradicting literals of different clauses:

E = {(uji , uj′

i′ ) | i 6= i ′ ∧ j ≤ 3 ∧ (uji , uj′

i′ ) not contradicting}• contradicting: literals of the form x , ¬x .

• claim: graph has n-clique, iff formula satisfiable!

17 / 20

Page 77: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE is NP-complete

• Obviously in NP: Given set of nodes can easily be verified to be aclique

• NP-hard: Reduction from 3SAT• given 3SAT problem (l1

1 ∨ l21 ∨ l3

1 ) ∧ . . . ∧ (l1n ∨ l2

n ∨ l3n )

• construct graph:• one node per l j

i : V = {uji | i ≤ n ∧ j ≤ 3}

• edges between non-contradicting literals of different clauses:E = {(uj

i , uj′

i′ ) | i 6= i ′ ∧ j ≤ 3 ∧ (uji , uj′

i′ ) not contradicting}• contradicting: literals of the form x , ¬x .

• claim: graph has n-clique, iff formula satisfiable!

17 / 20

Page 78: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE is NP-complete

• Obviously in NP: Given set of nodes can easily be verified to be aclique

• NP-hard: Reduction from 3SAT• given 3SAT problem (l1

1 ∨ l21 ∨ l3

1 ) ∧ . . . ∧ (l1n ∨ l2

n ∨ l3n )

• construct graph:• one node per l j

i : V = {uji | i ≤ n ∧ j ≤ 3}

• edges between non-contradicting literals of different clauses:E = {(uj

i , uj′

i′ ) | i 6= i ′ ∧ j ≤ 3 ∧ (uji , uj′

i′ ) not contradicting}• contradicting: literals of the form x , ¬x .

• claim: graph has n-clique, iff formula satisfiable!

17 / 20

Page 79: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE is NP-complete

• Obviously in NP: Given set of nodes can easily be verified to be aclique

• NP-hard: Reduction from 3SAT• given 3SAT problem (l1

1 ∨ l21 ∨ l3

1 ) ∧ . . . ∧ (l1n ∨ l2

n ∨ l3n )

• construct graph:• one node per l j

i : V = {uji | i ≤ n ∧ j ≤ 3}

• edges between non-contradicting literals of different clauses:E = {(uj

i , uj′

i′ ) | i 6= i ′ ∧ j ≤ 3 ∧ (uji , uj′

i′ ) not contradicting}• contradicting: literals of the form x , ¬x .

• claim: graph has n-clique, iff formula satisfiable!

17 / 20

Page 80: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE is NP-complete

Formula: (l11 ∨ l2

1 ∨ l31 ) ∧ . . . ∧ (l1

n ∨ l2n ∨ l3

n )Edge (uj

i , uj′

i ′ ) iff i 6= i ′ and l ji , l j′

i ′ non-contr.

Assume solution to formula.• each clause has at least one satisfied literal. n satisfied literals.• each satisfied literal connected with all other satisfied literals of

different clauses• clique of size n

Assume clique of size n.• must involve literals of different clauses• which are non-contradictory• setting them to true yields solution

18 / 20

Page 81: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE is NP-complete

Formula: (l11 ∨ l2

1 ∨ l31 ) ∧ . . . ∧ (l1

n ∨ l2n ∨ l3

n )Edge (uj

i , uj′

i ′ ) iff i 6= i ′ and l ji , l j′

i ′ non-contr.Assume solution to formula.

• each clause has at least one satisfied literal. n satisfied literals.• each satisfied literal connected with all other satisfied literals of

different clauses• clique of size n

Assume clique of size n.• must involve literals of different clauses• which are non-contradictory• setting them to true yields solution

18 / 20

Page 82: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

CLIQUE is NP-complete

Formula: (l11 ∨ l2

1 ∨ l31 ) ∧ . . . ∧ (l1

n ∨ l2n ∨ l3

n )Edge (uj

i , uj′

i ′ ) iff i 6= i ′ and l ji , l j′

i ′ non-contr.Assume solution to formula.

• each clause has at least one satisfied literal. n satisfied literals.• each satisfied literal connected with all other satisfied literals of

different clauses• clique of size n

Assume clique of size n.• must involve literals of different clauses• which are non-contradictory• setting them to true yields solution

18 / 20

Page 83: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT ≤p CLIQUE Example

Formula: (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x2 ∨ x3)

x1 x2 ¬x3

¬x1x2x3

x1 x2 x3

Solution:

19 / 20

Page 84: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT ≤p CLIQUE Example

Formula: (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x2 ∨ x3)

x1 x2 ¬x3

¬x1x2x3

x1 x2 x3

Solution: x1 = >, x2 = >, x3 =?

19 / 20

Page 85: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

3SAT ≤p CLIQUE Example

Formula: (x1 ∨ x2 ∨ ¬x3) ∧ (¬x1 ∨ x2 ∨ x3) ∧ (x1 ∨ x2 ∨ x3)

x1 x2 ¬x3

¬x1x2x3

x1 x2 x3

Solution: x1 =?, x2 = >, x3 = ⊥

19 / 20

Page 86: NP-Completeness - University of Manchestersyllabus.cs.manchester.ac.uk/ugt/2019/COMP26120/2020slides/lect… · Last Lecture • Decision Problems: Language = accepted bit-strings

Conclusions

• NP and NP-complete problems• no poly-time algorithms known for NP-hard problems• if you encounter one: special case?, approximation?

• Prove that problem is NP-complete:• in NP: show poly-time certification• NP-hard: reduce other NP-hard problem to it

• Many realistic problems NP-hard• You’ll come across a few more in this lecture• Knapsack, Integer Linear Programming, ...

20 / 20