19
More Computational Complexity Shirley Moore CS4390/5390 Fall 2013 http://svmoore.pbworks.com/ August 29, 2013 1

More Computational Complexity Shirley Moore CS4390/5390 Fall 2013 August 29, 2013 1

Embed Size (px)

Citation preview

Page 1: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

1

More Computational Complexity

Shirley MooreCS4390/5390 Fall 2013

http://svmoore.pbworks.com/August 29, 2013

Page 2: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

2

Agenda

• Announcements (3 min)• Recap previous class (6 min)• Discuss Fortnow article (6 min)• Reducibility (20 min)• Proving NP-completeness (20 min)• Average-case complexity (20 min)• Wrap-up and homework assignment (5 min)

Page 3: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

3

Announcements

• Change in class location• Pre-course survey now available

Page 4: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

4

Recap from Tuesday

• Explain in your own words – what it means for a problem to be NP-complete– how one can show that a problem is NP-complete

Page 5: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

5

Discussion of Status of P vs NP1. Much of cryptography depends on integer factorization being hard.

a. trueb. false

2. If P = NP, then integer factorization is in P.a. trueb. false

3. If integer factorization is in P, then P = NP.a. trueb. falsec. We don’t know, but unlikely

4. If SAT3 is in P, then integer factorization is in P.a. trueb. falsec. We don’t know

Page 6: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

6

Status of P vs. NP (cont.)

5. Do you think P = NP? (no wrong answer!)a. Yesb. No

6. Do you think the P vs. NP problem will a. never be solved?b. be solved soon (i.e., in a few years)?c. be solved in your lifetime?d. be solved 100 years or more from now?

7. What else did you find of interest in the Fortnow article?

Page 7: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

Learning Outcomes from August 27

• After completing this lesson, you should be able to – Define the complexity classes P and NP– Define NP-complete– Discuss implications of computational complexity

for cryptography– Apply logical proof techniques in the context of

computational complexity

Page 8: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

8

Learning Outcomes

• After completing today’s lesson successfully, you will be able to– Define reducibility– Devise polynomial time reductions from one problem to

another– Explain how to use polynomial reduction as a strategy to prove

a problem is NP-complete– Explain the difference between worst-case and average-case

time complexity– Explain and give an example of a randomized algorithm– Discuss the relevance of average-case complexity analysis to

cryptography

Page 9: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

9

Reducibility

• A reduction is a way of converting one problem to a second problem, so that the solution to the second problem can be used to solve the first.

• If problem A is reducible to problem B, then solving problem A cannot be “harder” than solving problem B.

• A is polynomial time reducible to B if A can be converted to B in polynomial time.

• If B is in NP and an NP-complete problem A is polynomial time reducible to B, then B is NP-complete.

Page 10: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

10

Class Exercise 1

• Show that the Hamilton cycle problem and the Hamiltonian path problem for an undirected graph are polynomial time reducible to each other.

Page 11: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

11

SAT Problem• Satisfiability Problem (SAT): Given a set of clauses, is there an

assignment of truth values to the variable such that the set is satisfiable?– (v1, v2’, v3), (v2), (v1’, v3) Yes– (v1, v2’, v3), (v2), (v2’, v3’), (v1’, v3) No

• Recall definition of NP-complete: A problem L is NP-complete if and only if 1) L is in NP, and 2) every other problem in NP can be reduced to L in polynomial time.

• How can you show that SAT is NP-complete by working from the definition of NP-complete?

• After proving SAT is NP-complete, how can you show that another problem B is NP-complete? Then how can you show another problem C is NP-complete (Hint: you have a choice of two ways)?

Page 12: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

12

NP-Completeness of Hamiltonian Cycle

1. Show that Hamiltonian Cycle is in NP.2. Reduce a known NP-complete problem to

Hamiltonian Cycle in polynomial time.

Page 13: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

13

Class Exercise 2: NP-Completeness of Traveling Salesman Problem (TSP)

• Traveling Salesman Problem (TSP): Given n cities and distances d(i,j) between each pair of cities, does there exist a tour of length ≤ k that visits each city and returns to the starting point?

• Given that Hamiltonian Cycle is NP-complete, show that TSP is NP-complete.

• See www.math.uwaterloo.ca/tsp for more about TSP if you’re interested.

Page 14: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

14

Does guessing help?

• Can “guessing” a solution to a “hard” problem be a good strategy for finding a solution in a reasonable amount of time?

• Consider the following randomized algorithm for solving the Hamiltonian path problem:– Start from a random vertex and continue to pick the next vertex

randomly if there is a neighbor not yet visited. If there are no more unvisited neighbors, and then path isn’t Hamiltonian, pick a neighbor of the current vertex at random and rotate using that neighbor as a pivot (i.e., add an edge to that neighbor to the path and remove one of the existing path edges from the neighbor so as not for form a loop). Continue from the new end of the path.

• Example: Graph with nodes ABCDE and edges AD, DC, DE, CE, BC.

Page 15: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

15

Average-case Runtime for Randomized Hamiltonian Path Algorithm

• Gurevich and Shelah, “Expected computation time for Hamiltonian path problem”, SIAM J. Computing 16(3), June 1987.– For fixed p, the expected runtime of the algorithm

on a graph with n vertices and edge probability p is O(n).

Page 16: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

16

Average-case Complexity

• Average-case polynomial time: Algorithm for solving problem L on input distribution μ is always correct but may take superpolynomial time on some inputs.

• Heuristic polynomial time: Algorithm for solving problem L on input distribution μ always runs in polynomial time but may give incorrect answers on some inputs.

• Which of the above two types is the randomized Hamiltonian Cycle algorithm?

• All of cryptography is predicated on the existence of average-case intractable problems in NP.

• Need an average-case analog of the theory of NP-completeness.

Page 17: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

17

An Easy-to-Break NP-complete Cipher

• Abraham Lempel, “Crytology in Transition”, ACM Computing Surveys 11(4), Dec. 1979

• Demonstrated a cipher for which the problem of breaking its key is NP-complete even under chosen plaintext attack.

• However, given enough plaintext, the problem of breaking the key reduces, with probably approaching unity, to that of solving a linear system of n equations in n unknowns, where n is the number of key bits.

Page 18: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

18

Homework

1. Prove: If B is NP-complete, C is in NP, and B is polynomial time reducible to C, then C is NP-complete.

2. Consider the 3SAT problem, where the input size is the number of variables.

a. Devise an algorithm that solves the 3SAT problem correctly for all inputs. What is the complexity class of your algorithm?

b. Devise a randomized algorithm with polynomial runtime for the 3SAT problem. Your algorithm may produce incorrect results for some inputs. (Extra credit challenge: Can you bound the error for your algorithm?)

Page 19: More Computational Complexity Shirley Moore CS4390/5390 Fall 2013  August 29, 2013 1

19

Reflective Writing

1. Summarize in one to two sentences the main learning objectives we attempted to accomplish this week.

2. What did you learn this week that surprised you?

3. What was your muddiest point – i.e., what did you least understand?