Section 7.2

Problems

[42/95%]
Show
LaTeX
Problem 7.13

Let

MODEXP⁡={⟨a,b,c,p⟩∣a,b,c, and p are positive binary integers  such that ab≡c( mod p)}. \begin{gathered} \operatorname {MODEXP}=\left\{ \langle a, b, c, p\rangle \mid a, b, c, \text{ and } p \text{ are positive binary integers } \\ \text{ such that } a^{b} \equiv c(\bmod p)\right\} . \end{gathered}

Show that MODEXP⁡∈P\operatorname {MODEXP} \in \mathrm{P}. (Note that the most obvious algorithm doesn't run in polynomial time. Hint: Try it first where bb is a power of 2.)

?
Problem 7.14

A permutation on the set {1,…,k}\left\{ 1, \ldots , k\right\} is a one-to-one, onto function on this set. When pp is a permutation, ptp^{t} means the composition of pp with itself tt times. Let

 PERM-POWER ={⟨p,q,t⟩∣p=qt where p and q are permutations  on {1,…,k} and t is a binary integer }. \begin{array}{r} \text{ PERM-POWER }=\left\{ \langle p, q, t\rangle \mid p=q^{t} \text{ where } p \text{ and } q \text{ are permutations } \\ \text{ on } \left\{ 1, \ldots , k\right\} \text{ and } t \text{ is a binary integer }\right\} . \end{array}

Show that PERM-POWER ∈P\in \mathrm{P}. (Note that the most obvious algorithm doesn't run within polynomial time. Hint: First try it where tt is a power of 2.)

?
Problem 7.15

Show that P is closed under the star operation. (Hint: Use dynamic programming. On input y=y1⋯yny=y_{1} \cdots y_{n} for yi∈Σy_{i} \in \Sigma, build a table indicating for each i≤ji \leq j whether the substring yi⋯yj∈A∗y_{i} \cdots y_{j} \in A^{*} for any A∈PA \in \mathrm{P}.)

?
Problem 7.16

ᴬ Show that NP is closed under the star operation.

?
Problem 7.17

Let UNARY-SSUM be the subset sum problem in which all numbers are represented in unary. Why does the NP-completeness proof for SUBSET-SUM fail to show UNARY-SSUM is NP-complete? Show that UNARY-SSUM ∈P\in \mathrm{P}.

?
Problem 7.18

Show that if P=NP\mathrm{P}=\mathrm{NP}, then every language A∈PA \in \mathrm{P}, except A=∅A=\emptyset and A=Σ∗A=\Sigma^{*}, is NP-complete.

?
Problem 7.19
  • Show that PRIMES ={m∣m is a prime number in binary }∈NP=\left\{ m \mid m\text{ is a prime number in binary }\right\} \in \mathrm{NP}. (Hint: For p>1p>1, the multiplicative group Zp∗={x∣x is relatively prime to p and 1≤x<p}Z_{p}^{*}=\left\{ x \mid x\text{ is relatively prime to }p\text{ and }1 \leq x<p\right\} is both cyclic and of order p−1p-1 iff pp is prime. You may use this fact without justifying it. The stronger statement PRIMES ∈P\in \mathrm{P} is now known to be true, but it is more difficult to prove.)
?
Problem 7.20

We generally believe that PATH is not NP-complete. Explain the reason behind this belief. Show that proving PATH is not NP-complete would prove P≠NP\mathrm{P} \neq \mathrm{NP}.

?
Problem 7.21

Let GG represent an undirected graph. Also let

\begin{aligned} \operatorname {SPATH}=\left\{ \langle G, a, b, k\rangle \mid & G \text{ contains a simple path of } \\ & \text{ length at most } k \text{ from } a \text{ to } b\right\} , \end{aligned}

and

LPATH⁡={⟨G,a,b,k⟩∣G contains a simple path of  length at least k from a to b}. \begin{array}{r} \operatorname {LPATH}=\left\{ \langle G, a, b, k\rangle \mid G \text{ contains a simple path of } \\ \text{ length at least } k \text{ from } a \text{ to } b\right\} . \end{array}
?
(a)

Show that SPATH ∈P\in \mathrm{P}.

(b)

Show that LPATH is NP-complete.

Problem 7.22

Let DOUBLE-SAT ={⟨ϕ⟩∣ϕ has at least two satisfying assignments }=\left\{ \langle \phi \rangle \mid \phi \text{ has at least two satisfying assignments }\right\}. Show that DOUBLE-SAT is NP-complete.

?
Problem 7.23

ᴬ Let HALF-CLIQUE ={⟨G⟩∣G is an undirected graph having a complete subgraph with at least m/2 nodes, where m is the number of nodes in G}=\left\{ \langle G\rangle \mid G \text{ is an undirected graph having a complete subgraph with at least } m / 2 \text{ nodes, where } m \text{ is the number of nodes in } G\right\}. Show that HALF-CLIQUE is NP-complete.

?
Problem 7.24

Let CNF⁡k={⟨ϕ⟩∣ϕ is a satisfiable cnf-formula where each variable appears in at most k places }\operatorname {CNF}_{k}=\left\{ \langle \phi \rangle \mid \phi \text{ is a satisfiable cnf-formula where each variable appears in at most }k\text{ places }\right\}.

?
(a)

Show that CNF⁡2∈P\operatorname {CNF}_{2} \in \mathrm{P}.

(b)

Show that CNF⁡3\operatorname {CNF}_{3} is NP-complete.

Problem 7.25

Let CNF⁡H={⟨ϕ⟩∣ϕ is a satisfiable cnf-formula where each clause contains any number of literals, but at most one negated literal}\operatorname {CNF}_{\mathrm{H}}=\left\{ \langle \phi \rangle \mid \phi \text{ is a satisfiable cnf-formula where each clause contains any number of literals, but at most one negated literal}\right\}. Show that CNF⁡H∈P\operatorname {CNF}_{\mathrm{H}} \in \mathrm{P}.

?
Problem 7.26

Let ϕ\phi be a 3cnf-formula. An ≠\neq-assignment to the variables of ϕ\phi is one where each clause contains two literals with unequal truth values. In other words, an ≠\neq-assignment satisfies ϕ\phi without assigning three true literals in any clause.

?
(a)

Show that the negation of any ≠\neq-assignment to ϕ\phi is also an ≠\neq-assignment.

(b)

Let ≠\neq SAT be the collection of 3 cnf-formulas that have an ≠\neq-assignment. Show that we obtain a polynomial time reduction from 3SAT to ≠\neq SAT by replacing each clause cic_{i}

(y1∨y2∨y3) \left(y_{1} \vee y_{2} \vee y_{3}\right)

with the two clauses

(y1∨y2∨zi) and (zi‾∨y3∨b), \left(y_{1} \vee y_{2} \vee z_{i}\right) \quad \text{ and } \quad \left(\overline{z_{i}} \vee y_{3} \vee b\right),

where ziz_{i} is a new variable for each clause cic_{i}, and bb is a single additional new variable.

(c)

Conclude that ≠SAT\neq S A T is NP-complete.

Problem 7.27

A cut in an undirected graph is a separation of the vertices VV into two disjoint subsets SS and TT. The size of a cut is the number of edges that have one endpoint in SS and the other in TT. Let

MAX-CUT⁡={⟨G,k⟩∣G has a cut of size k or more }. \operatorname {MAX-CUT}=\left\{ \langle G, k\rangle \mid G \text{ has a cut of size } k \text{ or more }\right\} .

Show that MAX-CUT is NP-complete. You may assume the result of Problem 7.26. (Hint: Show that ≠SAT≤P\neq S A T \leq_{\mathrm{P}} MAX-CUT. The variable gadget for variable xx is a collection of 3c3 c nodes labeled with xx and another 3c3 c nodes labeled with xˉ\bar{x}, where cc is the number of clauses. All nodes labeled xx are connected with all nodes labeled xˉ\bar{x}. The clause gadget is a triangle of three edges connecting three nodes labeled with the literals appearing in the clause. Do not use the same node in more than one clause gadget. Prove that this reduction works.)

?
Problem 7.28

You are given a box and a collection of cards as indicated in the following figure. Because of the pegs in the box and the notches in the cards, each card will fit in the box in either of two ways. Each card contains two columns of holes, some of which may not be punched out. The puzzle is solved by placing all the cards in the box so as to completely cover the bottom of the box (i.e., every hole position is blocked by at least one card that has no hole there). Let PUZZLE⁡={⟨c1,…,ck⟩∣each ci represents a card and this collection of cards has a solution}\operatorname {PUZZLE}=\left\{ \left\langle c_{1}, \ldots , c_{k}\right\rangle \mid \text{each } c_{i} \text{ represents a card and this collection of cards has a solution}\right\}. Show that PUZZLE is NP-complete.

?
Problem 7.29

A coloring of a graph is an assignment of colors to its nodes so that no two adjacent nodes are assigned the same color. Let

3COLOR⁡={⟨G⟩∣G is colorable with 3 colors }. \operatorname {3COLOR}=\left\{ \langle G\rangle \mid G \text{ is colorable with } 3 \text{ colors }\right\} .

Show that 3COLOR is NP-complete. (Hint: Use the following three subgraphs.)

?
Problem 7.30

Let SET-SPLITTING ={⟨S,C⟩∣S is a finite set and C={C1,…,Ck} is a collection of subsets of S, for some k>0, such that elements of S can be colored red or blue so that no Ci has all its elements colored with the same color}=\left\{ \langle S, C\rangle \mid S \text{ is a finite set and } C=\left\{ C_{1}, \ldots , C_{k}\right\} \text{ is a collection of subsets of } S, \text{ for some } k>0, \text{ such that elements of } S \text{ can be colored red or blue so that no } C_{i} \text{ has all its elements colored with the same color}\right\}. Show that SET-SPLITTING is NP-complete.

?
Problem 7.31

Consider the following scheduling problem. You are given a list of final exams F1,…,FkF_{1}, \ldots , F_{k} to be scheduled, and a list of students S1,…,SlS_{1}, \ldots , S_{l}. Each student is taking some specified subset of these exams. You must schedule these exams into slots so that no student is required to take two exams in the same slot. The problem is to determine if such a schedule exists that uses only hh slots. Formulate this problem as a language and show that this language is NP-complete.

?
Problem 7.32

This problem is inspired by the single-player game Minesweeper, generalized to an arbitrary graph. Let GG be an undirected graph, where each node either contains a single, hidden mine or is empty. The player chooses nodes, one by one. If the player chooses a node containing a mine, the player loses. If the player chooses an empty node, the player learns the number of neighboring nodes containing mines. (A neighboring node is one connected to the chosen node by an edge.) The player wins if and when all empty nodes have been so chosen. In the mine consistency problem, you are given a graph GG along with numbers labeling some of GG 's nodes. You must determine whether a placement of mines on the remaining nodes is possible, so that any node vv that is labeled mm has exactly mm neighboring nodes containing mines. Formulate this problem as a language and show that it is NP-complete.

?
Problem 7.33

ᴬ In the following solitaire game, you are given an m×mm \times m board. On each of its m2m^{2} positions lies either a blue stone, a red stone, or nothing at all. You play by removing stones from the board until each column contains only stones of a single color and each row contains at least one stone. You win if you achieve this objective. Winning may or may not be possible, depending upon the initial configuration. Let SOLITAIRE ={⟨G⟩∣G is a winnable game configuration }=\left\{ \langle G\rangle \mid G\text{ is a winnable game configuration }\right\}. Prove that SOLITAIRE is NP-complete.

?
Problem 7.34

Recall, in our discussion of the Church-Turing thesis, that we introduced the language D={⟨p⟩∣p is a polynomial in several variables having an integral root }D=\left\{ \langle p\rangle \mid p\text{ is a polynomial in several variables having an integral root }\right\}. We stated, but didn't prove, that DD is undecidable. In this problem, you are to prove a different property of DD-namely, that DD is NP-hard. A problem is NP-hard if all problems in NP are polynomial time reducible to it, even though it may not be in NP itself. So you must show that all problems in NP are polynomial time reducible to DD.

?
Problem 7.35

A subset of the nodes of a graph GG is a dominating set if every other node of GG is adjacent to some node in the subset. Let

 DOMINATING-SET ={⟨G,k⟩∣G has a dominating set with k nodes }. \text{ DOMINATING-SET }=\left\{ \langle G, k\rangle \mid G \text{ has a dominating set with } k \text{ nodes }\right\} .

Show that it is NP-complete by giving a reduction from VERTEX-COVER.

?
Problem 7.36
  • Show that the following problem is NP-complete. You are given a set of states Q={q0,q1,…,ql}Q=\left\{ q_{0}, q_{1}, \ldots , q_{l}\right\} and a collection of pairs {(s1,r1),…,(sk,rk)}\left\{ \left(s_{1}, r_{1}\right), \ldots ,\left(s_{k}, r_{k}\right)\right\} where the sis_{i} are distinct strings over Σ={0,1}\Sigma =\left\{ 0,1\right\}, and the rir_{i} are (not necessarily distinct) members of QQ. Determine whether a DFA M=(Q,Σ,δ,q0,F)M=\left(Q, \Sigma , \delta , q_{0}, F\right) exists where δ(q0,si)=ri\delta \left(q_{0}, s_{i}\right)=r_{i} for each ii. Here, δ(q,s)\delta (q, s) is the state that MM enters after reading ss, starting at state qq. (Note that FF is irrelevant here.)
?
Problem 7.37

Let U={⟨M,x,#t⟩∣NTM M accepts x within t steps on at least one branch}U=\left\{ \left\langle M, x, \#^{t}\right\rangle \mid \text{NTM } M \text{ accepts } x \text{ within } t \text{ steps on at least one branch}\right\}. Note that MM isn't required to halt on all branches. Show that UU is NP-complete.

?
Problem 7.38
  • Show that if P=NP\mathrm{P}=\mathrm{NP}, a polynomial time algorithm exists that produces a satisfying assignment when given a satisfiable Boolean formula. (Note: The algorithm you are asked to provide computes a function; but NP contains languages, not functions. The P = NP assumption implies that SAT is in P, so testing satisfiability is solvable in polynomial time. But the assumption doesn't say how this test is done, and the test may not reveal satisfying assignments. You must show that you can find them anyway. Hint: Use the satisfiability tester repeatedly to find the assignment bit-by-bit.)
?
Problem 7.39
  • Show that if P=NP\mathrm{P}=\mathrm{NP}, you can factor integers in polynomial time. (See the note in Problem 7.38.)
?
Problem 7.40

ᴬ Show that if P=NP\mathrm{P}=\mathrm{NP}, a polynomial time algorithm exists that takes an undirected graph as input and finds a largest clique contained in that graph. (See the note in Problem 7.38.)

?
Problem 7.41

In the proof of the Cook-Levin theorem, a window is a 2×32 \times 3 rectangle of cells. Show why the proof would have failed if we had used 2×22 \times 2 windows instead.

?
Problem 7.42
  • Consider the algorithm MINIMIZE, which takes a DFA MM as input and outputs DFA M′M^{\prime }. MINIMIZE = "On input ⟨M⟩\langle M\rangle, where M=(Q,Σ,δ,q0,A)M=\left(Q, \Sigma , \delta , q_{0}, A\right) is a DFA:
  1. Remove all states of MM that are unreachable from the start state. 2. Construct the following undirected graph GG whose nodes are the states of MM. 3. Place an edge in GG connecting every accept state with every nonaccept state. Add additional edges as follows. 4. Repeat until no new edges are added to GG : 5. For every pair of distinct states qq and rr of MM and every a∈Σa \in \Sigma : 6. Add the edge (q,r)(q, r) to GG if (δ(q,a),δ(r,a))(\delta (q, a), \delta (r, a)) is an edge of GG. 7. For each state qq, let [q][q] be the collection of states [q]={r∈Q∣ no edge joins q and r in G}[q]=\left\{ r \in Q \mid \text{ no edge joins }q\text{ and }r\text{ in }G\right\}. 8. Form a new DFA M′=(Q′,Σ,δ′,q0′,A′)M^{\prime }=\left(Q^{\prime }, \Sigma , \delta^{\prime }, q_{0}{ }^{\prime }, A^{\prime }\right) where Q′={[q]∣q∈Q}Q^{\prime }=\left\{ [q] \mid q \in Q\right\} (if [q]=[r][q]=[r], only one of them is in Q′Q^{\prime } ), δ′([q],a)=[δ(q,a)]\delta^{\prime }([q], a)=[\delta (q, a)] for every q∈Qq \in Q and a∈Σa \in \Sigma, q0′=[q0]q_{0}{ }^{\prime }=\left[q_{0}\right], and A′={[q]∣q∈A}A^{\prime }=\left\{ [q] \mid q \in A\right\}. 9. Output ⟨M′⟩\left\langle M^{\prime }\right\rangle."
?
(a)

Show that MM and M′M^{\prime } are equivalent.

(b)

Show that M′M^{\prime } is minimal-that is, no DFA with fewer states recognizes the same language. You may use the result of Problem 1.52 without proof.

(c)

Show that MINIMIZE operates in polynomial time.

Problem 7.43

For a cnf-formula ϕ\phi with mm variables and cc clauses, show that you can construct in polynomial time an NFA with O(cm)O(c m) states that accepts all nonsatisfying assignments, represented as Boolean strings of length mm. Conclude that P≠NP\mathrm{P} \neq \mathrm{NP} implies that NFAs cannot be minimized in polynomial time.

?
Problem 7.44
  • A 2cnf-formula is an AND of clauses, where each clause is an OR of at most two literals. Let 2SAT={⟨ϕ⟩∣ϕ is a satisfiable 2 cnf-formula }2 S A T=\left\{ \langle \phi \rangle \mid \phi \text{ is a satisfiable 2 cnf-formula }\right\}. Show that 2SAT∈P2 S A T \in \mathrm{P}.
?
Problem 7.45

Modify the algorithm for context-free language recognition in the proof of Theorem 7.16 to give a polynomial time algorithm that produces a parse tree for a string, given the string and a CFG, if that grammar generates the string.

?
Problem 7.46

Say that two Boolean formulas are equivalent if they have the same set of variables and are true on the same set of assignments to those variables (i.e., they describe the same Boolean function). A Boolean formula is minimal if no shorter Boolean formula is equivalent to it. Let MIN-FORMULA be the collection of minimal Boolean formulas. Show that if P=NP\mathrm{P}=\mathrm{NP}, then MIN-FORMULA ∈P\in \mathrm{P}.

?
Problem 7.47

The difference hierarchy DiP\mathrm{D}_{i} \mathrm{P} is defined recursively as

?
(a)

D1P=NP\mathrm{D}_{1} \mathrm{P}=\mathrm{NP} and

(b)

DiP={A∣A=B\C for B in NP and C in Di−1P}\mathrm{D}_{i} \mathrm{P}=\left\{ A \mid A=B \backslash C \text{ for } B \text{ in NP and } C \text{ in } \mathrm{D}_{i-1} \mathrm{P}\right\}. (Here B\C=B∩CˉB \backslash C=B \cap \bar{C}.)

For example, a language in D2P\mathrm{D}_{2} \mathrm{P} is the difference of two NP languages. Sometimes D2P\mathrm{D}_{2} \mathrm{P} is called DP (and may be written DP\mathrm{D}^{\mathrm{P}} ). Let

Z={⟨G1,k1,G2,k2⟩∣G1 has a k1-clique and G2 doesn’t have a k2-clique }.  Z=\left\{ \left\langle G_{1}, k_{1}, G_{2}, k_{2}\right\rangle \mid G_{1} \text{ has a } k_{1} \text{-clique and } G_{2} \text{ doesn't have a } k_{2} \text{-clique }\right\} \text{. }

Show that ZZ is complete for DP. In other words, show that ZZ is in DP and every language in DP is polynomial time reducible to ZZ.

Problem 7.48
  • Let MAX-CLIQUE ={⟨G,k⟩∣ a largest clique in G is of size exactly k}=\left\{ \langle G, k\rangle \mid \text{ a largest clique in }G\text{ is of size exactly }k\right\}. Use the result of Problem 7.47 to show that MAX-CLIQUE is DP-complete.
?
Problem 7.49
  • Let f:N⟶Nf: \mathcal{N} \longrightarrow \mathcal{N} be any function where f(n)=o(nlog⁡n)f(n)=o(n \log n). Show that TIME (f(n))(f(n)) contains only the regular languages.
?
Problem 7.50
  • Call a regular expression star-free if it does not contain any star operations. Then, let EQ⁡SF-REX ={⟨R,S⟩∣R and S are equivalent star-free regular expressions }\operatorname {EQ}_{\text{SF-REX }}=\left\{ \langle R, S\rangle \mid R\text{ and }S\text{ are equivalent star-free regular expressions }\right\}. Show that EQ⁡SF-REX \operatorname {EQ}_{\text{SF-REX }} is in coNP. Why does your argument fail for general regular expressions?
?
Problem 7.51
  • This problem investigates resolution, a method for proving the unsatisfiability of cnf-formulas. Let ϕ=C1∧C2∧⋯∧Cm\phi =C_{1} \wedge C_{2} \wedge \cdots \wedge C_{m} be a formula in cnf, where the CiC_{i} are its clauses. Let C={Ci∣Ci is a clause of ϕ}\mathcal{C}=\left\{ C_{i} \mid C_{i} \text{ is a clause of } \phi \right\}. In a resolution step, we take two clauses CaC_{a} and CbC_{b} in C\mathcal{C}, which both have some variable xx occurring positively in one of the clauses and negatively in the other. Thus, Ca=(x∨y1∨y2∨⋯∨yk)C_{a}=\left(x \vee y_{1} \vee y_{2} \vee \cdots \vee y_{k}\right) and Cb=(xˉ∨z1∨z2∨⋯∨zl)C_{b}=\left(\bar{x} \vee z_{1} \vee z_{2} \vee \cdots \vee z_{l}\right), where the yiy_{i} and ziz_{i} are literals. We form the new clause (y1∨y2∨⋯∨yk∨z1∨z2∨⋯∨zl)\left(y_{1} \vee y_{2} \vee \cdots \vee y_{k} \vee z_{1} \vee z_{2} \vee \cdots \vee z_{l}\right) and remove repeated literals. Add this new clause to C\mathcal{C}. Repeat the resolution steps until no additional clauses can be obtained. If the empty clause ( ) is in C\mathcal{C}, then declare ϕ\phi unsatisfiable. Say that resolution is sound if it never declares satisfiable formulas to be unsatisfiable. Say that resolution is complete if all unsatisfiable formulas are declared to be unsatisfiable.
?
(a)

Show that resolution is sound and complete.

(b)

Use part (a) to show that 2SAT∈P2 S A T \in \mathrm{P}.

Problem 7.52
  • Show that P is closed under homomorphism iff P=NP\mathrm{P}=\mathrm{NP}.
?
Problem 7.53
  • Let A⊆1∗A \subseteq 1^{*} be any unary language. Show that if AA is NP-complete, then P=NP\mathrm{P}=\mathrm{NP}. (Hint: Consider a polynomial time reduction ff from SAT to AA. For a formula ϕ\phi, let ϕ0100\phi_{0100} be the reduced formula where variables x1,x2,x3x_{1}, x_{2}, x_{3}, and x4x_{4} in ϕ\phi are set to the values 0,1,00,1,0, and 0, respectively. What happens when you apply ff to all of these exponentially many reduced formulas?)
?
Problem 7.54

In a directed graph, the indegree of a node is the number of incoming edges and the outdegree is the number of outgoing edges. Show that the following problem is NP-complete. Given an undirected graph GG and a designated subset CC of GG 's nodes, is it possible to convert GG to a directed graph by assigning directions to each of its edges so that every node in CC has indegree 0 or outdegree 0, and every other node in GG has indegree at least 1?

?