Lecture 19: Practice with Reductions 03 Dec 2013 In class exercise: 2SAT is in P Horn SAT is in P Prove that 2SAT U Horn is NP-Complete. What two things are needed? - 2SAT U Horn is in NP - Reduction from what to what? From 3SAT to 2SAT U Horn One solution: for every variable P, create a new variable notP Add for each variable P (P v notP) (~P v ~notP) Rewrite non-horn clauses by exchanging ~notP for P (P v Q v ~R) (~notP v ~notQ v ~R) ************************************************************** Next: prove that 0/1 integer programming is NP-complete. (0/1 programming: variables have value 0 or 1) Solution: In NP: guess & verify. Reduction: (P v Q v ~R) ----> P + Q + (1-R) >= 1 Prove that integer programming is NP-complete Solution: In NP: guess & verify. Reduction: For each variable P, add -P <= 0 P <= 1 ************************************************************** What is a Euler ciruit? - use every edge exactly once. - IFF graph is connected and every vertex has even degree. What is a Hamiltonian circuit? - use every vertex exactly once. What is a Hamiltonian path? - given graph G and vertices A and B, find a path from A to B that uses every vertex exactly once. In class exercise: prove that Hamiltonian Path and Hamiltonian Circuit are equally hard. How? 2 reductions: Hamiltonian Circuit --> Hamiltonian Path easy: choose any vertex A and solve Hamiltonian Path (A,A) Hamiltonian Path --> Hamiltonian Circuit given problem (A,B), add a new node C connected to A and B. Take Hamiltonian circuit for new graph, and eliminate the edges A-C-B Proof that Hamiltonian circuit is NP-complete. In NP: guess and verify. NOTE: this proof is NOT in the textbook; instead, the book goes through a series of reductions from other problems to Hamiltonian Circuit. ***Slides on Hamiltonian Circuit.*** ************************************************** Notes on last exam: will have 2 problems: - Using a reduction to prove a problem is NP hard - Using a reduction to prove a problem is in PTIME