0% found this document useful (0 votes)
12 views3 pages

Test2 Sol

The document discusses the NP-completeness of the TWO-CLIQUES problem, demonstrating that it is in NP and can be reduced from the known NP-complete problem CLIQUE. It also details the construction of a Boolean formula φ for a nondeterministic Turing machine's computation, specifically for the input '011', and outlines the components of φ including φcell, φstart, φmove, and φaccept. Finally, it proves that SAT is coNP-complete by showing that any language in coNP can be polynomially reduced to SAT.

Uploaded by

saeb2saeb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Test2 Sol

The document discusses the NP-completeness of the TWO-CLIQUES problem, demonstrating that it is in NP and can be reduced from the known NP-complete problem CLIQUE. It also details the construction of a Boolean formula φ for a nondeterministic Turing machine's computation, specifically for the input '011', and outlines the components of φ including φcell, φstart, φmove, and φaccept. Finally, it proves that SAT is coNP-complete by showing that any language in coNP can be polynomially reduced to SAT.

Uploaded by

saeb2saeb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CSC 363 — Solutions to Test #2, Winter 2010

1) [ 30 marks ] Recall that a clique in an undirected graph is a set of nodes in which every pair of nodes
is connected by an edge. The textbook defined the language CLIQUE as follows:

CLIQUE = { hG, ki | G is an undirected graph that contains a clique with k nodes }

The textbook proves that CLIQUE is NP-complete. Define the language TWO-CLIQUES as:

TWO-CLIQUES = { hG, ki | G is an undirected graph that contains two disjoint cliques of size k }

Prove that TWO-CLIQUES is NP-complete. Remember: You need to show two things to show that
a language is NP-complete.

We first need to show that TWO-CLIQUES is in NP. A polynomial time verifier for TWO-CLIQUES
takes hw, ci as input. It rejects if w does not have the form hG, ki. Otherwise, we can have it accept
if c is an encoding of two sets of nodes in G, the sets are both of size k, the two sets are disjoint, and
both sets define cliques in G (ie, for both sets, there is an edge connecting every pair of nodes in the
set), and otherwise it rejects. This can all be done easily in polynomial time.
Alternatively, one could show that TWO-CLIQUES is in NP by describing a nondeterministic Turing
Machine that decides it and that runs in polynomial time.
Next, we need to show that every language in NP can be reduced in polynomial time to TWO-
CLIQUES. We do this by showing that CLIQUE, which is known to be NP-complete, can be reduced
to TWO-CLIQUES, so all languages in NP can be reduced to TWO-CLIQUES using a reduction via
CLIQUE. We could reduce CLIQUE to TWO-CLIQUES in several ways; here is one.
The reduction maps hG, ki to hG0 , ki, where G0 is the graph consisting of all the nodes and edges of
G, along with another k nodes that are connected to each other, but not to any of the nodes from G.
This is easy to do in polynomial time.
We need to show that hG, ki is in CLIQUE iff hG0 , ki is in TWO-CLIQUES. For the forward direction,
if hG, ki is in CLIQUE, then there is a subset of k nodes of G that is a clique, in which case the same
subset of G0 is a clique, and the k nodes in G0 that are not in G also form a clique, so there are two
disjoint cliques of size k, and hence hG0 , ki is in TWO-CLIQUES. In the other direction, if hG0 , ki is
in TWO-CLIQUE, there are two disjoint cliques of size k in G0 . These two cliques can’t both be in
the k nodes of G0 that aren’t in G, and can’t be partly in G and partly out (since there are no edges
between these parts), so there must be a clique of size k in G, and hence hG, ki is in CLIQUE.

2) [ 45 marks total ] Part of the proof in the textbook that SAT is NP-complete shows that for any
language, A, in NP, which is decided by a nondeterministic Turing Machine, N , that runs in polyno-
mial time, there is a function that maps a string w to a string hφi that is an encoding of a Boolean
formula, φ, that is satisfiable iff N accepts w.
The proof shows that there is an algorithm to do this reduction in polynomial time, for some fixed
nondeterministic Turing Machine, N , which runs in some polynomial time bound — say nk + 2, for
some k, where n is the length of the input. The algorithm takes the string w as input and outputs
hφi. The formula φ that it creates has variables that describe the “tableau” for a computation of N
on input w that halts within nk + 2 steps (we’ll let this tableau be nk + 3 by nk + 5 in size). The
rows of the tableau are successive configurations of N , bounded by “#” symbols. The variable xi,j,s
is 1 iff cell (i, j) of the tableau contains symbol s, where s ∈ Q ∪ Γ ∪ {#}.
Recall that the formula φ has the form

φ = φcell ∧ φstart ∧ φmove ∧ φaccept

1
where φcell enforces that the variables describe a tableau with exactly one symbol in each cell, φstart
enforces that the first configuration is the correct start configuration for input w, φmove enforces
that each configure is followed by a possible successor configuration (same as the previous one if the
machine has halted), and φaccept enforces that the tableau contains an accepting configuration.
Suppose that the input alphabet of machine N is Σ = { 0, 1 }, the tape alphabet is Γ = { 0, 1, },
the state space is Q = { q0 , q1 , qaccept , qreject }, the start state is q0 , and the transition function,
δ : Q × Γ → Q × Γ × {L, R}, is as follows:
δ(q0 , 0) = { (q1 , 1, L), (q1 , 0, R) }, δ(q0 , 1) = { (q1 , 1, L) }, δ(q0 , ) = { (qreject , , L) }

δ(q1 , 1) = { (q1 , 1, R) }, δ(q1 , 0) = { (qreject , 0, R) }, δ(q1 , ) = { (qaccept , , L) }

For all the questions below, suppose that the input is w = 011, so that n = 3, and that k = 1, so
the tableau has 6 rows and 8 columns.

a) [ 12 marks ] Fill in the two tableaus below to represent two different accepting computations on
this input.

# q0 0 1 1 #
# q1 1 1 1 #
# 1 q1 1 1 #
# 1 1 q1 1 #
# 1 1 1 q1 #
# 1 1 qaccept 1 #

# q0 0 1 1 #
# 0 q1 1 1 #
# 0 1 q1 1 #
# 0 1 1 q1 #
# 0 1 qaccept 1 #
# 0 1 qaccept 1 #

b) [ 5 marks ] How many variables are there in the formula φ? Explain.


The tableau has 6 × 8 = 48 cells, each of which can contain #, or one of 4 states, or one of 3
symbols, for a total of 8 possibilities. There are therefore 48 × 8 = 384 variables, representing
the possibilities of each possible symbol being in each cell.
(Slightly different correct answers are also possible, provided they come with explanations indi-
cating a slightly different approach to how φ is constructed.)

c) [ 9 marks ] Write down the φstart part of φ for this input.


This part of φ must ensure that the initial configuration has the input string on the tape, the
tape head at the left, the state set to q0 , and the edges of the first row of the tableau set to #.
This can be done with the following formula:

x1,1,# ∧ x1,2,q0 ∧ x1,3,0 ∧ x1,4,1 ∧ x1,5,1 ∧ x1,6, ∧ x1,7, ∧ x1,8,#

2
d) [ 9 marks ] The φaccept part of φ is a disjunction (or) of literals. Write down three of these
literals, and say (and explain) how many literals are in this disjunction.
Here are three:
x1,2,q , x3,3,q , x4,7,q
accept accept accept
There are a total of 6 × 8 = 48 such literals, one for each cell, though one could omit the ones
on the edges that are always set to #, which would leave 6 × 6 = 36 literals.

e) [ 10 marks, +1 for each correct, −1 for each wrong, minimum 0 ] The φmove part of φ ensures
that every 2 × 3 “window” of the tableau is legal for the machine N . For each of the following
windows, circle “Yes” or “No” to indicate whether it is legal or not (no explanation is required):

# 0 1 1 1 q1
Legal? Yes No Legal? Yes No
# 0 1 1 1 1

q0 1 1 0 0 1
Legal? Yes No Legal? Yes No
q0 1 1 0 1 1

q1 0 1 # q0 1
Legal? Yes No Legal? Yes No
1 0 1 # q0 0

q0 0 1 q1 1 1
Legal? Yes No Legal? Yes No
1 q0 1 1 q1 1

1 q1 # q0
Legal? Yes No Legal? Yes No
qaccept 1 # q0

3) [ 25 marks ] The class coNP is defined to contain all languages whose complements are in NP — in
other words, L ∈ coNP iff L ∈ NP. A language L is defined to be coNP-complete if L is in coNP and
any other language in coNP is polynomial time reducible to L — in other words, L is coNP-complete
iff L ∈ coNP and for all L0 ∈ coNP, L0 ≤P L.
Prove that SAT is coNP-complete. You may use any parts of the proof that SAT is NP-complete
that are useful for proving this.

Since SAT is in NP, SAT is in coNP by definition.


Let A be any language in coNP. Then A is in NP, so the proof that SAT is NP-complete shows that
there is a polynomial time reduction, f , from A to SAT, such that for all w, w ∈ A iff f (w) ∈ SAT.
This implies that w ∈/ A iff f (w) ∈
/ SAT, and hence that w ∈ A iff f (w) ∈ SAT. This means that
f is also a polynomial time reduction of A to SAT, and since A was any language in coNP, SAT is
coNP-complete.

You might also like