NP-Completeness
[71/58%]Sat is in NP.
Formulate the following puzzle as a Boolean formula , and solve it by determining whether is satisfiable:
With five games left in the regular season, the team mathematician reported to the manager of the baseball team A: "We can still make the playoffs if we can beat team , and in case team beats team then team beats team , and in case we lose to team then team also beats either team or team ." Later, among the remaining five games, each team won at least one game, but no team won all its remaining games, and there was no tie game. Did team A have any chance to make the playoffs? If so, how?
Formulate the following puzzle as a Boolean formula , and solve it by determining whether is satisfiable:
Three men named Lewis, Miller, and Nelson fill the positions of accountant, cashier, and manager in the leading department store in the City of NP. The following information about their jobs is known:
-
If Nelson is the cashier, Miller is the manager.
-
If Nelson is the manager, Miller is the accountant.
-
If Miller is not the cashier, Lewis is the manager.
-
If Lewis is the accountant, Nelson is the manager.
What is each man's job?
Hamiltonian Cycle (HC): Given a graph , determine whether has a Hamiltonian cycle.
HC is in NP.
(Knight's Tour) Find a tour of the chessboard by a knight which visits each square exactly once and comes back to the starting square.
| 3 | 6 | 33 | 40 | 27 | 44 | 29 | 46 |
|---|---|---|---|---|---|---|---|
| 34 | 37 | 2 | 5 | 32 | 47 | 26 | 43 |
| 7 | 4 | 39 | 36 | 41 | 28 | 45 | 30 |
| 38 | 35 | 8 | 1 | 48 | 31 | 42 | 25 |
| 9 | 64 | 13 | 56 | 17 | 24 | 49 | 58 |
| 14 | 55 | 10 | 61 | 52 | 57 | 18 | 21 |
| 63 | 12 | 53 | 16 | 23 | 20 | 59 | 50 |
| 54 | 15 | 62 | 11 | 60 | 51 | 22 | 19 |
| : Figure 7.1: A knight’s tour. |
Vertex Cover (VC): Given a graph and a positive integer , determine whether has a vertex cover of size at most .
VC is in NP.
Hitting Set (HS): Given subsets of a set and an integer , determine whether there is a subset of size such that for all .
HS is in NP.
Formulate the following logical puzzle as an instance of the problem HS and solve it by finding the correct subset.
Three women, Joan, Michelle, and Tracy, made the following statements about their ages.
Joan: "I am 92 years old. I am two years younger than Michelle. I am one year older than Tracy." Michelle: "I am not the youngest. I am three years different from Tracy. Tracy is 25 years old." Tracy: "I am younger than Joan. Joan is 23 years old. Michelle is three years older than Joan." If we know that, among three statements given by each person, exactly two are true. What are their ages?
IS is in NP.
(Eight-Queen Problem) Place eight queens in an chessboard without them attacking each another. (In the chess game, a queen attacks another piece if they are located in the same row, or in the same column, or in the same diagonal.)
3DM is in .
IP is in .
Formulate the following logical puzzle as an instance of the problem IP, and solve it by solving the corresponding system of inequalities.
Professor presented a colloquium talk in the Department of Complexity. When he started to talk, he noticed that the 15 people of the audience satisfy the following conditions:
-
There were more students than professors.
-
There were more male professors than male students.
-
There were more male students than female students.
-
There was at least one female professor.
Five minutes later, a person rushed into the room. However, the appearance of this person did not change the above four conditions. Is this person a man or a woman, a student or a professor?
Prime is in NP.
Prove that 683 is a prime.
For any set , let and . Show that if is in NP, then and are also in .
For any set , let .
Assume that there is a polynomial function such that implies . Show that if , then .
Show that if for some polynomial function and if , then .
A function is polynomial-time computable if there is a polynomial-time DTM that computes the function (i.e., on input , it halts in moves for some polynomial , with the string on the output tape). A function is polynomially honest if there is a polynomial function such that and for all . Assume that is polynomial-time computable and is polynomially honest.
Assume that is one-to-one and onto. Show that if , then and .
Show that if , then the following functions are polynomialtime computable:
where is the lexicographic ordering on .
Formulate the following puzzles as instances of problems in NP, and then solve the puzzles by finding the witnesses to the instances:
Six men, , and F, are the only members eligible for the offices of President, Vice-President, and Secretary in Club NP. The following preferences of these men are known:
-
A won’t be an officer unless E is President.
-
B won’t serve if he outranks C.
-
B won’t serve with F under any conditions.
-
C won’t serve with both E and F.
-
C won’t serve if F is President or B is Secretary.
-
D won’t serve with C or E unless he outranks them.
-
E won’t be Vice-President.
-
E won’t be Secretary if D is an officer.
-
E won’t serve with A unless F serves too.
-
F won’t serve unless either he or C is President.
How can the three offices be filled satisfying all above conditions?
Police arrested four men as the suspects of a murder case. They made the following statements when questioned:
John: "Nick did it." Nick: "Bill did it." Dan: "I didn't do it." Bill: "Nick lied when he said I did it."
If exactly one of them is the real murderer and exactly one of the above statements is true, who is the murderer?
Brown, Jones, and Smith are employed by the village of NP as fireman, policeman, and teacher, though not necessarily respectively. Someone in the village reported that:
-
Brown and the teacher are neighbors.
-
Jones and the teacher are neighbors.
-
Both Brown and Smith are neighbors of the fireman.
-
Both the policeman and the fireman are neighbors of Jones.
-
The men are all neighbors.
However, the truth of the matter is that only two of these statements are true. Can you determine the job which each man holds?
Both the Smiths and the Taylors have two young sons under eleven. The names of the boys, whose ages rounded off to the nearest year are all different, are Arthur, Bert, Carl, and David. Taking the ages of the boys only to the nearest year, the following statements are true:
-
Arthur is three years younger than his brother.
-
Bert is the oldest.
-
Carl is half as old as one of the Taylor boys.
-
David is five years older than the younger Smith boy.
-
The total ages of the boys in each family differ by the same amount today as they did five years ago.
How old is each boy, and what is each boy's family name?"
The threshold function is a Boolean function defined as follows:
Construct Boolean formulas , using operations , and variables , such that it computes the function .
Show that there exist Boolean formulas using operations , , variables , and some auxiliary variables , such that (i) the length of is bounded by for some constant , and (ii) an assignment satisfies if and only if assigns value 1 to at least variables in .
Prove that the following integers are primes: .
Show that the following problems are in NP:
Longest Path (LP): Given a graph and an integer , determine whether has a simple path of at least edges. (A path is simple if no vertex appears twice.)
Traveling Salesman Problem (TSP): Given a complete graph with a cost function , and an integer , determine whether there is a tour (i.e., a Hamiltonian cycle) of with the total edge cost bounded by .
Graph Isomorphism (GIso): Given two graphs and , determine whether is isomorphic to . (Two graphs and are isomorphic if , and there is a one-to-one, onto mapping such that if and only if . The function is called an isomorphism.)
Bounded PCP: Given a finite set of ordered pairs , of strings over an alphabet , and an integer (in the unary form ), determine whether there is a finite sequence of integers , with each and , such that
Bounded Tiling: Given a finite number of types of colored tiles and an integer (in the unary form ), determine whether it is possible to cover a square by colored tiles of these types, starting with a tile of type at the lower left corner. (See Exercise 6 of Section 5.6 for the details of the definition.)
Let be an integer matrix, and an -dimensional integer vector. Let be the maximum absolute value of integers in and , and .
Show that if is a square submatrix of , then , where denotes the determinant of matrix .
Show that if , then there exists a nonzero vector such that and the maximum absolute value of integers in is bounded by .
Assume that has an integer solution . Let denote the th row of the th component of , and the th dimensional unit vector (i.e., all components of is 0, except that the th component is 1). Let be a solution for that maximizes the number of elements in the following set:
Prove that the rank of is .
Use (c) above to prove Lemma 7.14.
HC .
IS.
GIso DGIso.
SAT CNF-SAT.
.
.
.
.
Prove that CNF-Sat 3Sat.
In this exercise, we study an alternative proof for Example 7.25. Let us replace conditions (1) and (2) by condition (3): For every , there is a triple such that (i) , and (ii) if then . Translate this condition into a Boolean formula over variables and show that is satisfiable if and only if has a threedimensional matching .
Construct the following reductions:
3SAT .
.
.
Consider the following variations of the problem 3Sat:
3Sat-Exactly-One: Given a 3-CNF , determine whether there is an assignment on variables in that assigns value TRUE to exactly one literal in each clause of .
3Sat-Not-All: Given a 3-CNF , determine whether there is an assignment on variables in that assigns value TRUE to either one or two literals (but not all three literals) in each clause of .
Show that 3Sat, 3Sat-Exact-One and 3Sat-Not-All are polynomial time equivalent under .
Consider the following problems: Subgraph Isomorphism (SGIso): Given two graphs and , determine whether there is a one-to-one mapping such that, for all , implies .
Graph Automorphism (GAuto): Given a graph , determine whether there is a one-to-one function other than the identity function such that, for all if and only if .
Prove all the polynomial-time reductions you can find among the three problems GIso, SGIso and GAuto.
Show that if , then all nonempty proper subsets of are NP-complete.
If is known to be -complete, is always -complete?
In the proof of Cook's theorem, we have used conditions (4.1) on ???-shaped windows over matrix to satisfy condition (4). Show that if we, instead, work with ???-shaped windows over matrix , then no conditions on these windows can satisfy condition (4). In other words, show that the following relation does not hold for any subset :
where denotes the th configuration corresponding to the assignments to variables .
Show that, in the proof of Cook's theorem, function is necessary. That is, no definition of subset can make the following true: is satisfiable if and only if .
In the proof of Cook's theorem, it is possible to remove condition (1), as long as we replace condition (4') by a new condition (4'') over six-square, ???-shaped windows. Find the subconditions over the six-square, ???-shaped windows that make equivalent to condition (4), without the assumption of condition (1).
A Boolean formula which is a product of literals is called an elementary product. A DNF (disjunctive normal form) is a sum of elementary products.
Prove that a DNF Boolean formula can be switched in polynomial time to a CNF formula (with possibly more variables) that preserves satisfiability.
Prove that if , then there is no polynomial-time algorithm that switches a CNF Boolean formula to a DNF formula, and preserves satisfiability.
Assume that and are two -complete sets. Show that and are not necessarily -complete, if . Is always -complete when ?
This exercise follows the notations defined in Exercise 3 of Section 7.1.
Show that there exists a polynomial-time computable, polynomially honest function such that its range is NPcomplete. [Hint: For any -complete set takes an instance of and a string as the input and decides whether is a witness to .]
Define . Show that there exists a polynomial-time computable, polynomially honest function such that is NP-complete. [Hint: Design a function like part (a), except that the problem is a minimization problem.]
Assume that . Let and be two sets that are complete for (i.e., and are NP-complete). Is necessarily in co-NP? Is necessarily co-NP-complete? Is it possible that is in ? Justify your answer.
Suppose that, in the proof of Cook's theorem, we drop condition (1) and replace condition by , which specifies some subconditions on five-square windows of one of the four shapes shown in Figure 7.11. Show that no such subconditions on the five-square windows can make (4) equivalent to .
Consider the alternative proof of Cook's theorem given in Example 7.33. Let be the set corresponding to the twelve windows of Figure 7.10; that is, if and only if is in one of the twelve forms in Figure 7.10, and satisfies the corresponding conditions given in the three cases. Show that if there exists a mapping such that if and only if , then is in .
In this exercise, we consider a different setting for the proof of Cook's theorem. Instead of attaching the state symbol to the tape symbol currently scanned by the tape head, we may define separate Boolean variables to represent the state and the position of the tape head. That is, in addition to variables (for only), we define, for each and each , a variable to mean that the state symbol of is , and for each pair , with , a variable to mean that, in the configuration , the tape head is scanning the th symbol. To prove Cook's theorem in this setting, then we need to define six Boolean functions , such that, for if and only if the condition below holds:
(1) For each is in exactly one state.
(2) For each , the head scans exactly one cell in .
(3) For each and each , the th cell of contains exactly one symbol.
(4) is the initial configuration of on input .
(5) is an accepting configuration.
(6) For each .
Assume that satisfy the condition that if and only if condition holds. Also let be
where if , and if . Find a counterexample to disprove that if and only if accepts . Find a new function satisfying that if and only if accepts .
Does the problem VC remain NP-complete if each edge is to be covered by exactly one vertex?
Prove that MCG is NP-complete.
Partition is NP-complete.
Knapsack is NP-complete.
BP is NP-complete.
Show that the following problem is NP-complete: Given positive integers , determine whether
SMT is NP-complete.
For each of the following problems, determine whether it is -complete or is in . If it is -complete, find a reduction from a known complete problem to it. If it is in , find a polynomial-time algorithm for it.
Given a graph , two vertices and in and a positive integer , determine whether there is a path between and of length less than or equal to .
Given a graph , two vertices and in and a positive integer , determine whether there is a path between and of length greater than or equal to .
Given a directed graph , determine whether has a cycle of an odd length.
Given a directed graph , determine whether has a cycle of an even length.
Given a graph , determine whether has a cycle of an odd length.
Given an edge-weighted complete graph , three subsets , of vertices and a positive integer , determine whether there is a subgraph of of weight that contains a spanning tree for each of and . (A spanning tree for a subset is a connected subgraph of on the vertex set that has no cycle.)
Given a graph and a positive integer , determine whether there is a subset of at most edges such that every vertex in is incident with at least one edge in .
Regular Expression Nonequivalence: Given two regular expressions and without the Kleene-star operation, determine whether .
Bounded PCP (see Exercise 7(d) of Section 7.1).
Bounded Tiling (see Exercise 7(e) of Section 7.1).
Prove that the following variations of the problem VC are -complete:
Planar VC: The problem VC restricted to planar graphs. (A planar graph is a graph that can be drawn on the two-dimensional plane such that no two edges cross each other at a non-vertex point.)
Cubic VC: The problem VC restricted to cubic graphs. (A cubic graph is a graph such that every vertex has degree three.)
Planar Connected-VC-4: Given a planar graph with each vertex in having degree at most 4 and an integer , determine whether there is a vertex cover of of size such that the induced subgraph on vertex set is connected.
Given a graph , determine whether has a vertex cover satisfying the following conditions:
-
The subgraph induced by has no isolated point.
-
Every vertex in is adjacent to a vertex not in .
The polar representation of a CNF is a bipartite graph , where is the set of all variables and is the set of all clauses in , and there is an edge in between and if and only if the variable appears in the clause (in the form of or ). Prove the following statements:
has a planar polar representation and it is satisfiable if and only if .
There exists a 3-CNF formula with a planar polar representation and three variables , and , such that is satisfiable if and only if .
There exists a 3-CNF formula with a planar polar representation and three variables , and , such that is satisfiable if and only if . [Hint: .]
The following problem, called Planar Polar-3Sat, is NPcomplete: Given a 3-CNF formula with a planar polar representation, determine whether is satisfiable or not. [Hint: Applying the fact that and to the construction.]
The nonpolar representation of a CNF is a graph , with the vertex set consisting of all literals and all clauses in , and the edge set consisting of all pairs over all variables in plus all literal-clause pairs such that occurs in . Prove the following statements:
If the nonpolar representation of a CNF formula is planar, then its polar representation must also be planar. However, the converse is not necessarily true.
The following problem, called Planar Nonpolar-3Sat, is NPcomplete: Given a 3-CNF formula with a planar nonpolar representation, determine whether is satisfiable or not.
A is a CNF such that each clause contains exactly literals and each variable occurs in at most clauses. The problem -Sat is the problem 3SaT restricted to -CNF's. Prove the following results:
For any , every -CNF is satisfiable.
For any , (2, )-SAT is polynomial-time solvable. (In fact, the problem 2Sat, which is the problem 3Sat restricted to CNF's with at most 2 literals in each clause, is polynomial-time solvable.)
-Sat is -complete.
Show that Min-VC is an NP-complete search problem.
TSP is NP-complete.
The problem -Approx-TSP is NP-complete for all .
The problem -Approx-VC is NP-complete for some .
For each , the problem -Approx-VC- is NP-complete for some .
For , -Approx-BST is NP-complete.
For each of the following search problems, formulate an appropriate decision version of it and show that the decision version and the search version are equivalent under polynomial-time Turing reduciblity.
Max-3Sat.
The optimization version of KNAPSACK.
LP (optimization version): Given a graph , find a longest simple path in .
Given a positive integer , find its largest prime factor.
For each of the following optimization problems, show that it is NPcomplete:
Given a directed graph, find a minimum subset of edges such that every directed cycle contains at least one edge in the subset.
Given a directed graph, find a minimum subset of vertices such that every directed cycle contains at least one vertex in the subset.
Given integers and , find , that maximize the value , subject to the following constraints:
Given a graph, find a wheel of the maximum size. (A wheel of size is a subgraph of vertices, in which vertices form a simple cycle and the other vertex is connected to all these vertices.)
Show that for each of the following optimization problems II, there exists an approximation ratio such that -Approx- is -complete.
Network SMT: Given a graph , an edge-weight function and a subset , find a connected subgraph with the minimum total edge weight that interconnects vertices in .
Connected-VC: Given a graph , find a minimum vertex cover such that the subgraph induced by is connected.
TSP with Triangle Inequality: Given a complete graph and an distance function that satisfies the triangle inequality, find a Hamiltonian cycle with the minimum total distance. (A distance function satisfies the triangle inequality if for any three vertices .)
TSP with -Distance: Given a complete graph and an edge-weight function , find a Hamiltonian cycle with the minimum total distance.
For a graph , its edge-square graph is a graph obtained from by replacing each edge by a copy of , called , and connecting both and to every vertex in .
Show that -Approx-LP is NP-complete for some .
Show that if the longest simple path in has length , then the longest simple path in has length at least . Moreover, given a path of length in , a path of length in can be found in polynomial-time.
Show that -Approx-LP is NP-complete for all .
Show that for each of the following optimization problems , there exists a constant such that -Approx- is -complete.
Vertex Coloring: Given a graph , find a coloring of (i.e., a function ) with the minimum number of colors such that no two adjacent vertices have the same color.
Edge Coloring: Given a graph , find a coloring of (i.e., a function ) with the minimum number of colors such that no two adjacent edges (edges with a common vertex) have the same color.