# Lecture 017 - Sharp-SAT

In order to solve SAT, last time we saw that if we know the probability $p$ that you plug a random string $s$ into SAT to get $SAT(s) = 1$, then we can solve SAT. But how do we know $p$? Today, we study approximating $p$. (This lecture is not at all about quantum)

## Sharp-SAT

### Variance and Expectation of Small $p$ Binomial

Sharp-SAT: We don't know how many $m$ there is satisfying $f$. We don't know the probability $p = \frac{m}{N}$

In summary, we need to find the bias of a coin with probability $p$ by flipping the coin. A fair guess is to just count the fraction of head or tail we get, there are a few problems

1. When the number of count is small (either head or tail), the fraction is very unstable. (We can't really count on the last digit of output if we want to be within 10%)
2. When the number of count is small, the percent error is very sensitive
3. In practice, you should try flipping coin geometrically (ie. 10 coins, 100 coins, 1000 coins, ...), and 10 coins become negligible when you flip 100 coins. Geometric number converges.

For small $p$, you have expectation $E[X] = np, Var(X) = np(1-p) \simeq np$. If we want $stdev \leq \epsilon E[X]$, we have

\begin{align*} Var(X)^2 \leq& \epsilon E[X]\\ \sqrt{np} \leq& \epsilon E[X]\\ \sqrt{np} \leq& \epsilon np\\ \frac{1}{\epsilon} \leq& \sqrt{np}\\ \frac{1}{\epsilon^2} \leq& np\\ n\geq& \frac{1}{\epsilon^2p}\\ \end{align*}

### ??

Last time, we can solve $SAT$ given that we know $p$. This time, we want to estimate $p$. We also saw each "combo" we rotate about $\theta = 2\sqrt{\frac{m}{N}} = 2\sqrt{p}$. And we need $O(\frac{1}{\sqrt{p}})$ many rotation to achieve our goal.

So, our goal is to figure out $p$ by figure out the mystery (but fixed) rotation $\theta$

To estimate $\theta \in (1 \pm \epsilon)\hat{\theta}$, what is $p$'s range we should estimate?

\begin{align*} \theta \in& (1 \pm \epsilon)\hat{\theta}\\ \theta^2/4 \in& (1 \pm \epsilon)^2\hat{\theta}^2/4\\ p \in& (1 \pm \epsilon)^2 \hat{p} \tag{by $\theta = 2\sqrt{p} \implies p = \frac{\theta^2}{4}$}\\ \end{align*}

If we want $p$ to be in bound $[(1-\epsilon)p, (1+\epsilon)p$, we need $O(\frac{(1/\epsilon^2)}{p})$. If we want $\theta$ to be in bound $[(1-\epsilon)\theta, (1+\epsilon)p$, we need $O(\frac{(1/\epsilon)}{\theta})$

In practice, you get $\theta \pm 10^{-d}$ (accurate up to 10 digits) with high confidence with use of $O(10^d)$ mystery rotations.

Table of Content