\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{relsize}
\usepackage{tikz}
\newcounter{lecnum}
\usepackage{graphicx}
\graphicspath{./}
\usepackage{caption}
\usepackage{subcaption}
\newcommand{\abs}[1]{\lvert #1 \rvert}
\newcommand{\lecture}[4]{
   \newpage
   \setcounter{lecnum}{#1}
   \noindent

   \begin{center}
   \framebox{
      \vbox{\vspace{2mm}
    \hbox to 16cm { {\bf CS760 Topics in Computational Complexity
                        \hfill 2024-25 Sem I} }
       \vspace{4mm}
       \hbox to 16cm { {\Large \hfill Lecture #1: #2  \hfill} }
       \vspace{2mm}
       \hbox to 16cm { {\it Scribe: #4  \hfill  Lecturer: #3} }
      \vspace{2mm}}
   }
   \end{center}
   \vspace*{4mm}
}

\newtheorem{theorem}{Theorem}[lecnum]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}

% custom
\usepackage{enumitem}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage{commath}
\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\F}{\mathbb{F}}
\newcommand{\E}{\mathbb{E}}
\newcommand{\restr}[2]{\ensuremath{\left.#1\right|_{#2}}}
\newcommand{\aw}{\operatorname{aw}}

\begin{document}

\lecture{3}{09-08-2024}{Rohit Gurjar}{Navya, Aditya Agrawal}

\section{Decision and Search Problems}
A decision problem is characterized by a specific response to each $s \in \{0, 1\}^{\text{*}}$. Hence every decision problem can be represented by a function f of following kind

\[ f : \{0, 1\}^{*} \rightarrow  \{0, 1\} \]

Such a function can also be represented by a language over $\{0, 1\}^{\text{*}}$ which consists of only those elements which are mapped to 1. 
We can also represent this function using a infinitely large bit string by using a one - one and onto mapping from $\{0, 1\}^*$  to  $\mathbb{ N} $. (Onto will ensure that every infinitely large bit string is representing a unique function )



\textbf{Informally speaking}, we call a decision problem Q to be equivalent to a search problem P, if having a polynomial time algorithm for P implies a polynomial time algorithm and also vice-versa. (The definition of polynomial time is already defined in previous notes )

\section{Class NP}
\textbf{Note:} There are two ways two define the NP class. Out of them, only one is defined here. The other one and its equivalence to the one here is the subject matter of next lecture. 

We say that a language $L \in$ NP if there exists a turing machine (the verifier, call it $M$ for now) which runs in polynomial time and a polynomial $q \colon \mathbb{N} \rightarrow \mathbb{N}$ such that
$ x \in L $ iff $ \exists C \in \{0, 1\}^{\leq q(|x|)}$ s.t $M(x, C) = 1$.
By Turing Machine which runs in polynomial time, we mean that it runs in polynomial time over the input size where input size will include both $x$ and $C$.
%
 In other words, there exist a Turing machine such that for every valid $x$
  (and only for those), there exist a certificate which is polynomial in size of $x$ and 
  on which the Turing machine will halt with an approval in polynomial time.
  
   \emph{Remark:} It is not necessary for the machine to stop always in polynomial time. But more important is existence of polynomial size certificate which makes the machine to stop in polynomial time with acceptance. 
   Because we have the guarantee that there is a certificate on which the machine will stop in time $t(n)$,
   then we can create another machine that simulates the first one, but we make it stop in time $t(n)$ (if not certificate is not accepted so far, just reject it).  
   
%   Also this should be a \textbf{deterministic} Turing machine. 

\subsection{Examples of problems in NP}
\begin{enumerate}
    \item \textbf{Independent Set Problem} \\
    $\text{L} = \{ \langle G, k \rangle : \text{Graph } G \text{ has an independent set of size } k \}.$
    
     A valid certificate would be the indices of an independent set of size $k$. This is of course polynomially bounded in size of graph. And verifying it also will take polynomial time. Verifier will check if the size of set is indeed $k$ and if it is indeed independent. 

    \item \textbf{Traveling Salesman Problem} \\
    $\text{L} = \{ \langle G, \text{distance metric}, T \rangle : \text{Graph } G \text{ has tour covering all the vertices in length at most }   T \}$
    
     Certificate will be a sequence of vertices. Now whether it meet the required criteria or not can be checked in polynomial time.

\end{enumerate}

    
\subsection{Examples of problems which are not known to be in NP } 
	\begin{enumerate}
    \item \textbf{Boolean Circuit Satisfiability ( SAT Modified)} \\
    $\text{L} = \{ \langle \phi, k  \rangle  : \text{Number of satisfying assignments of }  \phi \text{ is at least } k  \}$
    
    Here the size of input is $\text{size}(\phi) + \log k$.  Simply providing the $k$ assignments won't work (because that will be exponential in the input size).   
    
    \item \textbf{MCSP } \\
    $\text{L} = \{ \langle \phi, k  \rangle  :$  there is a Boolean circuit with size  at most $  k $ which is equivalent to given circuit $\phi \}.$ 
    
        Not known to be in NP because we don't know how to check equivalence of two circuits in polynomial time. 
    \end{enumerate}



\section{Class co-NP}
    We now discuss another interesting class of problems known as \textbf{co-NP}. A problem is said to be in \textbf{co-NP} if the complement of the problem is in \textbf{NP}. In other words, there is an easily verifiable certificate for all the inputs for which the answer to the problem is NO.
    
    
    Some other interesting comments are as follows:
    \begin{itemize}
        \item All problems in P are in both \textbf{NP} and \textbf{co-NP}, simply because the verifier can ignore the proof and run his own P algorithm to check the answer for both the YES and NO cases.
        \item The converse is not true or rather we do not know at the moment. However, a problem being in both \textbf{NP} and \textbf{co-NP} gives a strong indication that the problem can be in \textbf{P}
    \end{itemize}

    \vspace{10pt}

  
 \begin{center}
    \begin{tikzpicture}
    % First two intersecting circles
    \draw[fill=red!30, opacity=0.6] (-1,0) circle (2);  % Circle A
    \draw[fill=blue!30, opacity=0.6] (1,0) circle (2);   % Circle B
    
    % Third circle inside the intersection
    \draw[fill=green!30, opacity=0.8] (0,0) circle (0.8);  % Circle C

    % Labels for the circles
    \node at (-2,1) {NP};
    \node at (2,1) {co-NP};
    \node at (0,-0.5) {P};
    
\end{tikzpicture}
 \end{center}
 
\subsection{Problems both in NP and co-NP}
\begin{itemize}
    \item \textbf{SLE} Problem - The System of Linear Equations Problem asks for whether given a system of linear equations, there exists an assignment of variables that satisfies all the linear equations.
    \begin{itemize}
        \item The problem is very clearly in \textbf{NP} as the certificate is simply the values of the variables which the verifier can verify in the equation by substituting in the equations (we  need to show that there is an assignment where values are polynomially bounded in size).
        \item The problem is also in co-NP as when there does not exist a satisfying assignment, the certificate can be the coefficients which the equations need to be multiplied and then added to lead to some sort of mathematical contradiction (i.e., $0=1$).
        
    \end{itemize}
    \item \textbf{Convex Optimization} - Given a convex function $f$ and domain $D$, we want $x \in D$ such that $\forall y \in D $ $f(x) \leq f(y)$. Rather is $x$ the minima of this convex function $f$? 
    The decision problem is: given $x $, is $x$ a minima of $f$?
    \begin{itemize}
        \item If the answer is YES, then the gradient can be given as the certificate, which should be zero.
        \item If the answer is NO, then another point $y$ can be given as the certificate such that $f(y) < f(x)$
        
    \end{itemize}
    \item \textbf{Graph Isomorphism} {$\langle G,H \rangle $, G and H are isomorphic}
    \begin{itemize}
        \item Though not really in \textbf{co-NP} there is sort of a game which the verifier can play to ensure that the answer can be extracted.
        \item It is in \textbf{NP} as if the answer is YES, then the permutation of vertices can be presented as the certificate.

        \item If answer is \textbf{NO}, then the verifier can play a sort of a game. They flip an unbiased coin to choose one of the graphs and then apply a random permutation to the vertices of the graphs and then supply this graph to the all powerful prover.
        \begin{itemize}
            \item If the graphs were indeed isomorphic, then the all powerful prover would not be able to tell from which initial graph this new graph has come since they both have an equal probability of having being picked.
            \item If the graphs were not isomorphic, then the prover knows for sure which graph this graph comes from.
        \end{itemize}
        \item Via this game, the verifier can verify the answer to this problem.
        \item It is now known that \textbf{Graph Isomorphism} is in class \textbf{QuasiP} -- 
        i.e., class of problems which have algorithms running in $O(n^{\log^c n})$ time for some $c \geq 1$.
    \end{itemize}

\end{itemize}
    
\subsection{Primality}
    The complexity of this problem was not known for a long time but in 2002, a \textbf{P} time algorithm was discovered by AKS. We study and look at ideas that might have led to this development by showing that Primality is both in \textbf{NP} and \textbf{co-NP}.\\ 

    \textbf{Primality Problem} - $\langle n \rangle $, $n$ is prime.
    \begin{itemize}
        \item If the answer is \textbf{NO}, then a factor of $n$ apart from $1$ and $n$ can be provided as a certificate.
        \item If the answer is \textbf{YES}, then things get interesting. We use ideas from number theory to provide a simple certificate.
    \end{itemize}

\begin{theorem}
    A number $p$ is prime iff there exists a number $z$ such that $z^{p-1} \equiv 1 \pmod p$ and $\forall r < p-1$, $z^r \not\equiv 1 \pmod p.$
\end{theorem}

Hence it seems like this number $z$ can be provided as a certificate for the same. Now, we run into a new problem. Even if we are given such a $z$ we cannot check for all $r < p-1$ whether $z^r \not\equiv 1$, as the number of choices for $r$ is not polynomially bounded in the input size. There is a clever workaround for this as well.
 
\begin{claim}
    If there exists $r < p-1$ such that $z^r \equiv 1 \pmod p $, then there exists $b < p-1$ such that $z^b \equiv 1 \pmod p$ and $b$ is a factor of $p-1$. 
    \label{cla:rdividesp-1}
\end{claim}
This is pretty simple to see. If $z^r \equiv 1 \pmod p$ and $z^{p-1} \equiv 1 \pmod p$ then $z^{\gcd(r, p-1)} \equiv 1 \pmod p$. We can simply choose $b$ to be $\gcd(r,p-1)$.

\begin{claim}
    It is sufficient to check the maximal factors of $p-1$ to verify whether there exists $r < p-1$ such that $z^r\equiv 1 \pmod p $.
\end{claim}
This is also simple to see. If such an $r$ does exist then by Claim~\ref{cla:rdividesp-1}, $z^b \equiv 1 \pmod p $ where $b=gcd(r,p-1)$. Now $b$ divides $p-1$. Let us denote $(p-1)/b$ as $c$ where $c \not= 1$. Hence we consider a prime factor of $c$ say $p_1$. Then $(p-1)/p_1$ is a maximal factor of $p-1$ and is a multiple of $b$. Hence if such an $r$ did exist, then atleast 1 maximal factor of $p-1$, say $q$ would also satisfy $z^q \equiv 1 \pmod p $. 

Now our task has simplified. The number $p-1$ has at most $O(\log p)$ prime factors so the number of maximal factors is also $O(\log p)$ in number for which this fact has to be checked. 

However, the verifier can't compute the prime factorization of $p-1$, so this also needs to be included in the certificate. But then we also need to check whether the prime factors provided are really prime or not recursively. It turns out the recursively built certificate remains polynomially bounded, the reader can do this as an exercise.

For example, see the certificate for a specific prime number here \url{https://www.theoremoftheday.org/LogicAndComputerScience/Pratt/TotDPratt.pdf}

    
\end{document}