Honors Theory of Computation, Spring'00.

HOMEWORK 5: SOLUTION

Out: April 5, 2000
Due: April 17, 2000

	==================================================	
	IMPORTANT:
	1) Answer each question within the page 
	limitation specified (use reasonable size handwriting,
	and leaving a 1-inch margin for grading).  
	If necessary, summarize your method or arguments.
	2) Be precise in your use of mathematical notations.
	Every sentence must be an English sentence, even if
	formulas are involved.
	3) This homework is available in postscript.
	==================================================	


GENERAL REMARKS:  Most students have no problem with
	these questions.  Often it is a "technical error"
	although you basically know how to do it.

(Q1) Problem 10.4.6 (p.237).
	This concerns $NP\cap co-NP$ and a notion
	called ``strong nondeterministic TM''.
	LIMIT: 1 page

	SOLUTION: 

	(==>) If L is accepted by a strong NP machine, M,
	we can construct two NP-machines, M1 and M2, which
	accepts L and co-L.  This proves L is in the intersection of
	NP and co-NP.

	Technical issues: some of you wanted to make M2
	accept L where M2 is supposed to be a co-NP machine.
	You could do this, but remember: M2 now has a funny
	notion of acceptance: M2(x) accepts iff all computation
	paths say YES.  You should NOT think of M2 as another
	NP-machine.
	
	(<==) If M1 and M2 are NP-machines that accept L and co-L,
	respectively, we only need to construct M as follows:
	simulate both M1 and M2 on any input x.  M only says YES
	if M1 accepts, and M only says NO if M2 does not accept.
	Otherwise M says "maybe".

(Q2) Let $n=65521$.  Give a certificate $C(n)$ (as in the text)
	for the fact that $n$ is prime.  Summarize what you did to
	find $C(n)$ (computer programs or hand calculators are allowed).
	LIMIT: 0.5 page

	SOLUTION: 
	Fun exercise, I hope.  
	Most people run a program to find a primitive 
	root $r$ of $n=65521$.  The prime numbers $q$ that divide
	$n$ are 2,3,5,7 and 13.
	The smallest such is $r= 17$.  Basically you need to check that
	$r^{n/q}\not\equiv 1 (mod n)$ for all primes $q$ that divide $n$.
	Then recursively prove that each $q$ is prime.

(Q3) Chernoff bounds are really a family of bounds based on a method.  
     LIMIT: 1 page
	(a) Show for any r.v. $X$ and real number $c$, and any $t>0$,

		$$Pr(X\ge c) \le E[e^{t(X-c)}]$$

	HINT: Use exactly the same argument as in beginning of
	of the proof of Lemma 11.9.

	SOLUTION:  
	$\Pr(X\ge c) = \Pr(X-c\ge 0) = \Pr(t(X-c)\ge 0) =\Pr(e^{t(X-c)} \ge 1)$
	$= Pr(e^{t(X-c)}\ge 1)\cdot 1 \le E[e^{t(X-c)}]$.
	

	(b) The trick in Chernoff bounds if to choose the
	$t$ which minimizes the expression $E[e^{t(X-c}]$.  
	Let us define

		$$m_X(c) = \min_{t>0} E[e^{t(X-c}].$$

	Determine $m_X(c)$ in case $X$ is a sum of $n$
	Bernoulli r.v.s $X_1, X_2,..., X_n$
	where $Pr(X_i=1)=p$ ($0 < p < 1$).
	HINT: Use calculus to determine $m_X(c)$.
	Differentiate the expression $f(t)=E[e^{t(X-c}]$ and
	equate to zero.

	SOLUTION:
	$E[e^{t(X-c)} = E[e^{tX_1}e^{tX_2}... e^{tX_n}] . e^{-tc}
	= E[e^{tX_1}]^n . e^{-tc}$ since the $X_i$'s are independent.
	Then

	$E[e^{tX_1}]^n . e^{-tc} = (e^{t.1}p + e^{t.0}(1-p))^n . e^{-tc}
	(e^{t}p + 1-p)^n . e^{-tc}.$ (Equation 1)

	Differentiating the last expression by $t$ and equating to $0$
	yields $n(pe^t + 1-p)^{n-1} .p.e^t.e^{tc} -
	 (p.e^t + 1-p)^n .c.e^{tc} =0$.  This gives
		$e^t = c(1-p)/((n-c)p)$.  Substituting into eqn(1)
	gives

		$m_X(c) = min_{t>0} E[e^{t(X-c)}]
		= (n^n.p^c.q^{n-c})/(c^c(n-c)^{n-c})$.

	(c) Conclude that 
		$$Pr(X \ge (1-\epsilon)np) \le
			\left( \frac{1}{1-\epsilon} \right)
			^ {(1-\epsilon)np}
			\left( \frac{1-p}{1-(1-\epsilon)p} \right)
			^ {n-(1+\epsilon)np}
		$$	

	SORRY, it is probably impossible to parse
	this formula, so we provide a postscript file for
	this homework: h5.ps

	SOLUTION:
	Taking $c=(1-\epsilon)np$ and substituting into $m_X(c)$ in (b)
	we obtain the desired result.


(Q4) Problems 11.5.14 and 11.5.15 (page 274):
	(a) BPP closed under union and intersection (1 page)
	(b) RP closed under union and intersection (1 page)
	(c) PP closed under complement and symmetric difference (1page)

     HINT: Use the (relaxed) definition of these computations in which
	a path of a computation tree of a BPP-, RP- or PP-machine
	is AT MOST (not EXACTLY EQUAL to) a polynomial of the input length.
	Also do Problem 11.5.13, but do not hand these in for grading.

	 
	SOLUTION:
	(a) Let $L_1, L_2$ be in $BPP$.

	(a1) We show that that $L=L_1\cap L_2$ is in $BPP$.
	Let $M_i$ be a BPP-machine for $L_i$ ($i=1,2$).
	Assume that for all input $x$, the probability
	that $M_i(x)=YES$ is either at least $3/4$ or at most $1/4$.
	Construct a probabilisitic machine M as follows:
	on input $x$, run $M_1(x)$ and $M_2(x)$.  Answer YES
	iff both $M_1$ and $M_2$ answers YES.
	It is easy to argue that $M$ is a BPP-machine for $L$:
	if $x\in L$ then the probability that $M(x)=YES$ is at
	least $9/16$, and otherwise, the probability is at most $1/4$.

	(a2) The union of $L_1$ and $L_2$ is in $BPP$ using
	the result of (a1) and the fact that $BPP$ is closed
	under complement.

	(b) Let $L_1, L_2$ be in $RP$.

	(b1) To show that that $L=L_1\cap L_2$ is in $RP$,
	the same construction of a machine $M$ as (a1) will do.

	(b2) To show that $L_1\cup L_2$ is in $RP$,
	a construction rather similar to (b2) will do.
	Basically, $M$ will answer NO iff both $M_1$ and $M_2$ answer NO.
	
	(c) Let $L_1, L_2$ be in $PP$.

	(c1) To show that $co-L_1$ is in $PP$, we basically
	take a $PP$-machine $M_1$ for $L_1$ and interchange YES and NO.
	There is a problem if the probability of YES is exactly 1/2.
	You need to do this trick:
	from the initial configuration, branch into 2 possibilities.
	One one branch, do the complement of $M_1$, as suggested above.
	On the other branch, make sure that the probability of
	accepting is $1/2 - (p(n)+1)^{-1}$ where $M_1$ always
	halt in $\le p(n)$ steps on inputs of size $n$.

	(c2) To show that $L_1\oplus L_2\in PP$:
	Let $M_i$ be $PP$-machines for $L_i$ ($i=1,2$).
	Construct $M$ from $M_1, M_2$ similarly to (a1).  However,
	answer YES iff $M_1$ and $M_2$ disagree
	(one says YES, other says NO).