Skip to content
The Lumenary

Each worksheet prints cleanly on A4 or Letter. Answer keys are on a separate page.

The Lumenary · Advanced undergraduate

Computational complexity

Name: ______________________

Date: ______________________

You will learn to

  • Define running time, the classes P, NP and coNP, and place standard problems in them
  • Prove the inclusions P⊆NP⊆PSPACE⊆EXPTIME\mathrm{P} \subseteq \mathrm{NP} \subseteq \mathrm{PSPACE} \subseteq \mathrm{EXPTIME} and explain why P≠EXPTIME\mathrm{P} \ne \mathrm{EXPTIME} by the time hierarchy theorem
  • State the Cook–Levin theorem and explain the idea of its proof
  • Prove NP-completeness by polynomial-time reductions, including 3-SAT to independent set, vertex cover and clique
  • Explain what is known and unknown about P versus NP, and why cryptography rests on unproved hardness assumptions
  1. 1.

    Which of these is the definition of the class NP?

    • A.Decision problems whose "yes" instances have certificates of polynomial length that can be checked in polynomial time.
    • B.Decision problems that cannot be solved in polynomial time.
    • C.Decision problems whose "yes" and "no" answers both have short checkable certificates.
    • D.Decision problems solvable in exponential time.
  2. 2.

    Which of these problems are known to be in P? (Select all that apply.)

    • A.Is a given graph 2-colourable?
    • B.Is a given graph 3-colourable?
    • C.Is a given nn-digit number prime?
    • D.Does a given graph have a perfect matching?
    • E.Does a given graph have a Hamiltonian cycle?
  3. 3.

    Karp's reduction from 3-SAT to INDEPENDENT SET is applied to a 3-CNF formula with 77 clauses on 55 variables. How many vertices does the graph GφG_\varphi have?

  4. 4.

    In the reduction from SAT to 3-SAT, a clause (ℓ1∨ℓ2∨⋯∨ℓ7)(\ell_1 \vee \ell_2 \vee \cdots \vee \ell_7) with 77 literals is replaced by a chain of 3-literal clauses using fresh variables z1,z2,…z_1, z_2, \dots. How many 3-literal clauses does it become?

  5. 5.

    You want to prove that a new problem B∈NPB \in \mathrm{NP} is NP-complete. Which is enough?

    • A.Give a polynomial-time reduction 3-SAT≤pB\mathrm{3\text{-}SAT} \le_p B.
    • B.Give a polynomial-time reduction B≤p3-SATB \le_p \mathrm{3\text{-}SAT}.
    • C.Show that the best known algorithm for BB takes exponential time.
    • D.Show that BB has exponentially many candidate solutions.
  6. 6.

    In the proof of Theorem 5 (⇐\Leftarrow direction) we said: an independent set SS of size mm in GφG_\varphi contains exactly one vertex from each clause. Why?

    • A.Each clause's three vertices form a triangle, so SS has at most one of them; with mm clauses and ∣S∣=m|S| = m, it must have exactly one from each.
    • B.Because complementary literals are joined by edges.
    • C.Because φ\varphi is satisfiable.
    • D.Because every independent set of GφG_\varphi has exactly mm vertices.
  7. 7.

    Which of these statements are known theorems (not conjectures)? (Select all that apply.)

    • A.If some NP-complete problem is in P, then P=NP\mathrm{P} = \mathrm{NP}.
    • B.P≠EXPTIME\mathrm{P} \ne \mathrm{EXPTIME}.
    • C.If P=NP\mathrm{P} = \mathrm{NP} then NP=coNP\mathrm{NP} = \mathrm{coNP}.
    • D.If factoring can be done in polynomial time, then P=NP\mathrm{P} = \mathrm{NP}.
    • E.NP≠PSPACE\mathrm{NP} \ne \mathrm{PSPACE}.
  8. 8.

    The Lean file proves bruteForce_correct : bruteForce φ = true ↔ Satisfiable φ and length_allAssignments : (allAssignments n).length = 2 ^ n. Which conclusion do these two theorems justify?

    • A.SAT is decidable, by an algorithm proved correct that examines exactly 2n2^n assignments.
    • B.SAT is in P.
    • C.SAT requires exponential time.
    • D.Nothing: decide could prove satisfiability directly, so the theorems are vacuous.
  9. 9.

    Implement Karp's reduction. A 3-CNF formula is a list of clauses, each a tuple of three nonzero integers (vv for xvx_v, −v-v for ¬xv\neg x_v). Number the vertices 3i+j3i + j for the jj-th literal (j=0,1,2j = 0, 1, 2) of clause ii. Write karp_graph(formula) returning the set of edges as pairs (p, q) with p < q: the three edges inside each clause, and an edge between every two vertices whose literals are complementary.

    Computational — Practice

Code: Apache-2.0 · Content: CC BY-SA 4.0