Theory of Computation
Homework 4
Due: 2014/12/9
Problem 1 Show that validity is coNP-complete.
Q
Problem 2 Recall that the Jacobi symbol is given by (a|m) = ki (a|pi ) for any odd
integer m = p1 p2 . . . pk , m > 1, and gcd(a, m) = 1. Show that (1|m) = (1

Theory of Computation
Homework 3
Problem 1. Suppose L1 is NP-complete, L2 is in NP and L1 is reducible
to L2, prove that L2 is NP-complete.
Problem 2. Define the language
,
, 1 | is a nondeterministic TM that accepts
within steps!
Prove that CNP is NP

Theory of Computation
Homework 2
Due: 2011/10/25
Problem 1. Given a Boolean expression
= (a b) (c (d e) (a f ) .
(a) Turn into a CNF.
(b) Illustrate a Boolean circuit for CNF.
Problem 2. If f (n) and g(n) are proper complexity functions, sketch proofs
th

Theory of Computation
Homework 1
Due: 2011/10/04
Problem 1. Two disjoint languages and are called recursively separable if
there exists a recursive language such that = and . Suppose
and are recursively separable languages. Show that if both and
are rec

Theory of Computation
Homework 5
Due: 2012/01/03
Problem 1. Show that if NP BPP then NP = RP. (Hints: It suffices to
show SAT RP.)
Problem 2. Show that BPP PSPACE.

Theory of Computation
Homework 4
Due: 2011/12/13
Problem 1. Please calculate 313716 and 77
mod 313716. (You need to
write down the steps explicitly. Providing merely the final result is not satisfactory.)
Problem 2. Show that NP = co-NP if there exist

Approximability
c
2011
Prof. Yuh-Dauh Lyuu, National Taiwan University
Page 629
And by the way
it is possible that P = NP.
Stephen Cook (1998)
c
2011
Prof. Yuh-Dauh Lyuu, National Taiwan University
Page 630
Tackling Intractable Problems
Many important p

Theory of Computation
Solutions for Homework 3
Problem 1. Suppose L1 is NP-complete, L2 is in NP and L1 is reducible
to L2, prove that L2 is NP-complete.
Proof.
Given L2 is in NP, it remains to show that every language L in
NP is reducible to L2.
Because

Theory of Computation
Mid-Term Examination on November 8, 2011
Fall Semester, 2011
Note: You may use any result proved in class.
Problem 1 (30 points) It is known that 3-COLORING is NP-complete.
Show that 6-COLORING is NP-complete. (You do not need to sho

Theory of Computation
Homework 5
Due: 2012/01/03
Problem 1. Show that if NP BPP then NP = RP. (Hints: It suffices to
show SAT RP.)
Proof.
As RP NP (see the slides), it suffices to show that NP RP.
We prove this claim by showing that if NP BPP, then SAT RP

Theory of Computation
Final-Term Examination on January 10, 2012
Fall Semester, 2011
Note: You may use any results proved in class.
Problem 1 (25 points). Prove that L is NP-complete if and only if its
is coNP-complete.
complement L
Solution.
Let L be a

The knapsack Problem
There is a set of n items.
Item i has value vi Z+ and weight wi Z+ .
We are given K Z+ and W Z+ .
knapsack asks if there exists a subset S cfw_1, 2, . . . , n
P
P
such that iS wi W and iS vi K.
We want to achieve the maximum sati

Large Deviations
Suppose you have a biased coin.
One side has probability 0.5 + to appear and the other
0.5 , for some 0 < < 0.5.
But you do not know which is which.
How to decide which side is the more likely sidewith
high confidence?
Answer: Flip t

Theory of Computation Lecture
Notes
Prof. Yuh-Dauh Lyuu
Dept. Computer Science & Information Engineering
and
Department of Finance
National Taiwan University
c
2011
Prof. Yuh-Dauh Lyuu, National Taiwan University
Page 1
Class Information
Papadimitriou. C

You Have an NP-Complete Problem (for Your Thesis)
From Propositions 27 (p. 242) and Proposition 30
(p. 245), it is the least likely to be in P.
Your options are:
Approximations.
Special cases.
Average performance.
Randomized algorithms.
Exponential

Theory of Computation
Homework 5
Due: 2015/1/06
Problem 1 Suppose that there are n jobs to be assigned to m machines. Let ti be the running
time for job i cfw_1 . . . n, A[i] = j mean that job i is assigned to machine j cfw_1 . . . m, and
P
T [j] = A[i]=j

Theory of Computation
homework 2
Due: 10/21/2014
Problem 1 Show that if L1 and L2 are recursively enumerable languages,
then so is L1 L2 .
Ans: Since L1 and L2 are RE languages, there must be a TM M1 accepting
L1 and a TM M2 accepting L2 . Now we construc

Theory of Computation
Homework 4
Due: 2014/12/09
Problem 1 Show that validity is coNP-complete.
Proof: To show that validity is coNP-complete, it needs to show that validity
coNP and L can be reduced to validity for all L coNP.
First, we can construct a

Theory of Computation
homework 2
Due: 10/21/2014
Problem 1 Show that if L1 and L2 are recursively enumerable languages,
then so is L1 L2 .
Problem 2 Show that the language
A = cfw_(M ; x) | M (x) = Yes
is undecidable.

Cantors Theorem
Theorem 7 The set of all subsets of N (2N ) is infinite and
not countable.
Suppose (2N ) is countable with f : N 2N being a
bijection.a
Consider the set B = cfw_k N : k f (k) N.
Suppose B = f (n) for some n N.
a Note
that f (k) is a sub

A P-Complete Problem
Theorem 32 (Ladner (1975) circuit value is
P-complete.
It is easy to see that circuit value P.
For any L P, we will construct a reduction R from L
to circuit value.
Given any input x, R(x) is a variable-free circuit such
that x L i

Space Complexity
Consider a k-string TM M with input x.
a
Assume non- is never written over by .
The purpose is not to artificially reduce the space
needs (see below).
If M halts in configuration
(H, w1 , u1 , w2 , u2 , . . . , wk , uk ),
then the spa

satisfiability (sat)
The length of a boolean expression is the length of the
string encoding it.
satisfiability (sat): Given a CNF , is it satisable?
Solvable in exponential time on a TM by the truth table
method.
Solvable in polynomial time on an NTM

Public-Key Cryptographya
Suppose only d is private to Bob, whereas e is public
knowledge.
Bob generates the (e, d) pair and publishes e.
Anybody like Alice can send E(e, x) to Bob.
Knowing d, Bob can recover x by D(d, E(e, x) = x.
The assumptions are

The Density Attack for primes
All numbers < n
Witnesses to
compositeness
of n
c
2014
Prof. Yuh-Dauh Lyuu, National Taiwan University
Page 468
The Density Attack for primes
1:
2:
3:
4:
5:
6:
Pick k cfw_1, . . . , n randomly;
if k | n and k = 1 and k = n th

knapsack Is NP-Completea
knapsack NP: Guess an S and check the constraints.
We shall reduce exact cover by 3-sets to knapsack,
in which vi = wi for all i and K = W .
The simplified knapsack now asks if a subset of
v1 , v2 , . . . , vn adds up to exactl

Comments on RP
In analogy to Proposition 36 (p. 326), a yes instance
of an RP problem has many certificates (witnesses).
There are no false positives.
If we associate nondeterministic steps with flipping fair
coins, then we can cast RP in the language

Zero-Knowledge Proof of 3 Colorabilitya
1: for i = 1, 2, . . . , | E |2 do
2:
Peggy chooses a random permutation of the 3-coloring ;
3:
Peggy samples encryption schemes randomly, commitsb them,
and sends (1), (2), . . . , (|V |) encrypted to Victor;
4:
Vi

Theory of Computation
Homework 5
Due: 2015/1/06
Problem 1 Suppose that there are n jobs to be assigned to m machines. Let ti be the running
time for job i cfw_1 . . . n, A[i] = j mean that job i is assigned to machine j cfw_1 . . . m, and
P
T [j] = A[i]=j