\part{Use this type of header for very long papers only}

\section{Introduction}

Many theorems concerning the existence of irreducible polynomials over a finite field of a special form have been proved. A discussion of such results can be found in~\cite{TuWa}. In this paper we will prove a function field analogue of a result of Maynard~\cite{May} concerning primes with missing digits. He proved that for large enough integers $b$, the primes have the expected asymptotic density inside those integers which can be written in base $b$ using only certain specified digits. We will prove the following natural analogue for polynomials in $\mathbb{F}_q[t]$.

\begin{theorem} \label{thm}
Let $\mathcal{R} \subset \mathbb{F}_q$ be a subset of size $s$ and assume that $s$ is less than $\sqrt{q}/2$. Suppose that $q \geq 500 $ and $ n \geq 100(\log q)^2 $. The number of irreducible, monic polynomials of degree $n$ with coefficients only from $\mathbb{F}_q \backslash \mathcal{R}$ (except possibly the leading 1) is given by
\[\frac{ q }{q-1}\frac{(q-s)^n}{n}\left( \Lambda + O\left( q^{-n^{1/2}/7} \right) \right),\]
where
\[ \Lambda = \begin{cases}
1 & \text{ if } 0 \in \mathcal{R} \\
1-\frac{1}{q-s} & \text{ if } 0 \notin \mathcal{R}.
\end{cases} \]
\end{theorem}

\begin{remark} Beyond stipulating that $s \leq \sqrt{q}$, the constraints on the sizes of $s,q$ and $n$ are somewhat artificial, and were chosen with the aim of producing a more presentable error term. A more complicated, but more widely applicable error term is presented at the end of section 4 from which the following two examples follow.
\end{remark}

\begin{example}
In the special case of $s=1$, we get an asymptotic formula for any $q \geq 17$. In particular, we show that the number of irreducible polynomials of degree $n$ with a single coefficient from $\mathbb{F}_{17}$ unavailable is asymptotic to $\Lambda\frac{16}{17}(16)^n/n$ as $n \rightarrow \infty$.
\end{example}

\begin{example}
An asymptotic formula still holds in the case of fixed $n$ and $q \rightarrow \infty$ provided that $s = o(q^{1/2}).$
\end{example}

As in the integer setting, we can take $s$ to be larger when the set $\mathcal{R}$ has additional structure. For example, in section 5 we will prove the following.

\begin{theorem} \label{thm2}
Suppose $\delta > 0$ and $p$ is a prime sufficiently large in terms of $\delta$. Then for any subset $\mathcal{R} = \{r, r+1, \ldots, r+s-1\} \subset \mathbb{F}_p$ of $s$ consecutive coefficients with $p-s > p^{3/4 + \delta}$, the number of irreducible, monic polynomials of degree $n$ with coefficients only from $\mathbb{F}_p \backslash \mathcal{R}$ (except possibly the leading 1) is given by
\[\frac{ p }{p-1}\frac{(p-s)^n}{n}\left( \Lambda + O\left(e^{-c n^{1/2}}\right)\right),\]
for some positive constant $c$ depending on $p$ and $\delta$.
\end{theorem}

The integer version of Theorem~\ref{thm} was proved in~\cite{May} under the assumption that the number of restricted digits $s$ satisfies $s \leq b^{1/4 -\delta}$ and the base $b$ is sufficiently large in terms of $\delta$. An analogue of Theorem~\ref{thm2} was proved under the assumption that $\mathcal{R} = \{0, 1, \ldots, s-1\}$ and $s \leq b - b^{3/4 + \delta}$. The proofs of Theorems~\ref{thm} and~\ref{thm2} will use the circle method over $\mathbb{F}_q[t]$ along the lines of~\cite{Ha} and~\cite{May}. Two features make our arguments substantially simpler. First, we may make use of Weil's Riemann hypothesis for curves over a finite field which gives very good control for exponential sums over irreducibles. Second, we don't have to deal with any technicalities which arise from the fact that sometimes digits are `carried' when rational integers are added. This doesn't happen with polynomials over a finite field.

For an overview of digit related results in the integers, see the recent work of Dietmann, Elsholtz and Shparlinski~\cite{DiElSh} which also contains a section on finite fields, improving an earlier result of  Dartyge, Mauduit and S\'{a}rk\"{o}zy~\cite{DaMaS}. See also~\cite{OpSh}, which contains an extensive list of references to related problems.

\section{Definitions and set up}

This section introduces some notation we will be using. Let $q$ be a prime power and $\mathbb{F}_q$ be the field with $q$ elements and characteristic $p$. Let $\mathcal{R}=\{r_1, \ldots, r_s\}\subset \mathbb{F}_q$ be a subset of \emph{forbidden} coefficients. We are interested in counting monic (sometimes called positive) irreducible polynomials in $\mathbb{F}_q[t]$ of degree $n$, all of whose coefficients, apart from possibly the leading 1, are in the set $\mathcal{R}^c:=\mathbb{F}_q \backslash \mathcal{R}$. The function field analogue of the real numbers is the completion of the field of fractions of $\mathbb{F}_q[t]$ with respect to the norm defined by
\[|f/g| = \begin{cases}
q^{\deg f - \deg g} & \text{ if } f\neq 0 \\
0 & \text{ otherwise .}
\end{cases}\]
This completion is naturally identified with the ring of formal Laurent series $\mathbb{F}_q((1/t))=\{ \; \sum_{i\leq j} x_i t^i \: : \: x_i \in \mathbb{F}_q, \: j \in \mathbb{Z} \; \}.$ The norm defined above is extended to $x = \sum_{ i \leq j } x_i t^i \in \mathbb{F}_q((1/t))$ by setting $|x| = q^j$ where $j$ is the largest index with $x_j \neq 0$. The subscript notation $x_i$ will be used again to refer to the coefficient of $t^i$ in $x$. The analogue of the real unit interval is $\mathbb{T}:=\{ \sum_{i < 0} x_i t^i \: : \: x_i \in \mathbb{F}_q \},$ and is a subring of $\mathbb{F}_q((1/t))$.
Define $\psi : \mathbb{F}_q \rightarrow \mathbb{C}^\times$ by
\[\psi(a) = \exp(2\pi i\text{tr}(a)/p)\]
where $\text{tr} : \mathbb{F}_q \rightarrow \mathbb{F}_p$ is the usual trace map. Define also the additive character $\textbf{e}_q : \mathbb{F}_q((1/t))\rightarrow \mathbb{C}^\times$ by \[\textbf{e}_q (x) = \psi(x_{-1}).\]
Fix a Haar measure on the additive group $\mathbb{T}$ normalised so that $\int_{\mathbb{T}}d x =1$. Then for all $a \in \mathbb{F}_q[t]$, we have
\[\int_{\mathbb{T}}\textbf{e}_q(a x)d x = \begin{cases} 1 & \text{ if } a = 0 \\ 0 & \text{ if } a \neq 0. \end{cases}\]
For $x \in \mathbb{T}$, define the sum over monic irreducible polynomials of degree $n$
\[ S(x) = \sum_{\deg p = n} \textbf{e}_q(p x).\] Let $\mathcal{M}_\mathcal{R}(n)$ be the set of monic polynomials of degree $n$ with non-leading coefficients taken from $\mathcal{R}^c$ and define
\[ S_\mathcal{R}(x) = \sum_{m \in \mathcal{M}_\mathcal{R}(n) } \textbf{e}_q(m x).\] So $S(x)$ and $S_\mathcal{R}(x)$ depend on $n$ even though this is not apparent from the notation. The main quantity of interest, the number of irreducible polynomials in $\mathcal{M}_\mathcal{R}(n)$, is then given by
\begin{equation}
N(\mathcal{R},n) = \int_{\mathbb{T}} S(x) \overline{S_\mathcal{R}(x)} dx.
\end{equation}
We will make use of the important fact that for each $x \in \mathbb{T}$, there exist unique $a, g \in \mathbb{F}_q[t]$ with $g$ monic, $a$ and $g$ coprime, and $|a| < |g| \leq q^{n/2}$ such that
\[ \left| x - \frac{a}{g} \right| < \frac{1}{q^{\deg g + n/2}}.\]
This fact is Lemma 3 from~\cite{Pol}. It implies that we can partition $\mathbb{T}$ into the so-called Farey arcs as
\[\mathbb{T} = \bigcup_{\substack{ |a|<|g| \leq q^{n/2} \\ (a,g)=1 }} \mathcal{F}\left(\frac{a}{g}\:,\:q^{\deg g + n/2}\right)\]
where $\mathcal{F}\left(\frac{a}{g}\:, \:\lambda\right) = \{ x \in \mathbb{T} \: : \: \big| \frac{a}{g} - x \big| < \frac{1}{\lambda} \}.$

As usual we let $\mu(f)$ denote the M\"{o}bius function, defined as $(-1)^k$ if $f$ is the product of $k$ distinct irreducibles and 0 otherwise. Let $\phi(f)$ be the size of the unit group $(\mathbb{F}_q[t]/(f))^\times$, that is $|f|\prod_{ \omega |f}(1-1/|\omega|)$, where the product is over all monic irreducibles dividing $f$. Finally, let $\pi(n)$ be the number of monic, irreducible polynomials of degree $n$ and recall the prime number theorem in the form $\sum_{d|n}d\pi(d) = q^n$.

\section{Lemmas}

The sum $S(x)$ was analysed in~\cite{Hay}. Our first lemma is Lemma 5 in~\cite{Pol} and is a consequence of Weil's Riemann Hypothesis for curves over a finite field.

\begin{lemma} \label{l1}
Let $a,g \in \mathbb{F}_q[t]$ be two polynomials with $(a,g)=1$ and $\gamma \in \mathbb{T}$, satisfying $|a|<|g| \leq q^{n/2}$ and $|\gamma|<1/q^{\deg g + n/2}$. We have
\[ S\left(\frac{a}{g}+\gamma \right)=\frac{\mu(g)}{\phi(g)}\pi(n) \textbf{e}_q(\gamma t^n)\textbf{1}_{|\gamma|<1/q^{n}}+E \]
with $|E| \leq q^{n-\frac{1}{2}[\frac{n}{2}]}$.
\end{lemma}

For a subset $A \subset \mathbb{F}_q$, define the Fourier coefficient $\widehat{\textbf{1}_{A}}(r) := \sum_{n \in A} \psi(nr).$ It turns out that the average value of $|S_\mathcal{R}(x)|$ can be written quite neatly in terms of the Fourier coefficients of the set $\mathcal{R}^c$.

\begin{lemma} \label{l2}
\[\int_{\mathbb{T}} |S_\mathcal{R}(x)|dx = \left(\sum_{r \in \mathbb{F}_q}|\widehat{\textbf{1}_{\mathcal{R}^c}}(r)|/q\right)^n. \]
\end{lemma}

\begin{proof}
First
\begin{align*}
S_\mathcal{R}(x) &= \sum_{m \in \mathcal{M}_\mathcal{R}(n) } \textbf{e}_q(m x) \\
&= \textbf{e}_q(x t^n) \prod_{i=0}^{n-1}\left(\sum_{n_i\in \mathcal{R}^c}\textbf{e}_q(x n_i t^i)\right) \\
&= \textbf{e}_q(x t^n) \prod_{i=0}^{n-1}\left(\sum_{n_i\in \mathcal{R}^c} \psi(n_i x_{-i-1})\right).\\
\end{align*}
Notice that $|S_\mathcal{R}(x)|$ only depends on the leading $n$ coefficients $(x_{-1}, \ldots, x_{-n})$ of $x$ and so, for each $a \in \mathbb{F}_q[t]$, $|S_\mathcal{R}(a/t^n+\gamma)|$ is constant in the range $|\gamma| < 1/q^n$, a set of measure $1/q^n$. Therefore,

\begin{align*}
\int_{\mathbb{T}}\big|S_{\mathcal{R}}(x)\big| d x & = \frac{1}{q^n}\sum_{\deg a < n}\big|S_{\mathcal{R}}\left(\frac{a}{t^n}\right)\big| \\
& = \frac{1}{q^n} \sum_{\deg a < n}\left|\prod_{i=0}^{n-1}\sum_{n_i \in \mathcal{R}^c}\psi(n_i a_{n-i-1})\right| \\
& = \frac{1}{q^n}\sum_{\deg a < n}\prod_{i=0}^{n-1}\left|\widehat{1_{\mathcal{R}^c}}(a_{n-i-1})\right| \\
& = \frac{1}{q^n}\left(\sum_{r\in \mathbb{F}_q}\left|\widehat{\textbf{1}_{\mathcal{R}^c}}(r)\right|\right)^n
\end{align*}
which completes the proof of the lemma.
\end{proof}

\begin{corollary}\label{c1}
\[\int_{\mathbb{T}} |S_\mathcal{R}(x)|dx \leq (\sqrt{s}+1 -2s/q)^n,\]
with equality in the case $s=1$.
\end{corollary}

\begin{proof}
Notice that
\begin{equation*}
\widehat{\textbf{1}_{\mathcal{R}^c}}(r) + \widehat{\textbf{1}_{\mathcal{R}}}(r) = \sum_{n \in \mathbb{F}_q}\psi(rn) =
\begin{cases}
q & \text{ if } r = 0 \\
0 & \text{ if } r \neq 0.
\end{cases}
\end{equation*}
And hence,
\[\sum_{r \in \mathbb{F}_q}|\widehat{\textbf{1}_{\mathcal{R}^c}}(r)| = \sum_{r \in \mathbb{F}_q\backslash 0 }|\widehat{\textbf{1}_{\mathcal{R}}}(r)| + |q-\widehat{\textbf{1}_{\mathcal{R}}}(0)| = \sum_{r \in \mathbb{F}_q}|\widehat{\textbf{1}_{\mathcal{R}}}(r)| + q-2s.\]
It therefore suffices to show that $\sum_{r \in \mathbb{F}_q}| \widehat{\textbf{\textbf{1}}_\mathcal{R}}(r)| \leq q\sqrt{s}$. By the Cauchy-Schwarz inequality,
\begin{align*}
\left( \sum_{r \in \mathbb{F}_q}|\widehat{\textbf{1}_\mathcal{R}}(r)| \right)^2 &\leq \left(\sum_{r \in \mathbb{F}_q} 1 \right)\left( \sum_{r \in \mathbb{F}_q} \left|\sum_{n \in \mathcal{R}}\psi(rn)\right|^2 \right) \\
& = q \sum_{r \in \mathbb{F}_q}\sum_{n_1, n_2 \in \mathcal{R}} \psi(r(n_1-n_2)).
\end{align*}
By swapping the order of summation we see that the total contribution from the terms with $n_1 \neq n_2$ is 0. The terms $n_1= n_2$ contribute $q^2s$ as required.
\end{proof}

The next lemma is similar to Lemma 7 from~\cite{Pol}.

\begin{lemma}  \label{l3}
Let $a, g \in \mathbb{F}_q[t]$ be coprime polynomials with $|a|<|g|$ and $g$ not a power of $t$ and let $d = \deg g > 0$. Then
\[\left| S_\mathcal{R}(a/g) \right| \leq (q-s)^{n-[\frac{n}{d}]}s^{[\frac{n}{d}]}.\]
\end{lemma}

\begin{proof}
Write $a/g = \sum_{i<0}x_i t^i$ and let $z$ be the number of non-zeros amongst the $x_i$ in the range $-n\leq i \leq -1$. Then, by our expression for $S_\mathcal{R}(a/q)$ from the start of the proof of Lemma~\ref{l2} we have that \[|S_\mathcal{R}(a/g)|=(q-s)^{n-z} \prod_{\substack{i=0 \\ x_{-i-1} \neq 0}}^{n-1}\left|\sum_{n_i \in \mathcal{R}}\psi(n_ix_{-i-1})\right| \leq (q-s)^{n-z}s^z\] by the triangle inequality. Since $q-s\geq s$, it suffices to show that $z \geq [\frac{n}{d}].$ We use proof by contradiction. Suppose $z \leq [\frac{n}{d}] -1.$ Then, by the pigeonhole principle, there is some string of at least $d$ consecutive zeros in $(x_{-n}, \ldots, x_{-1}).$ Hence, $|\{t^r a/g\}| \leq 1/q^{d+1}$ for some integer $r\geq 0$ where $\{x\} = \sum_{i<0}x_it^i$ denotes the fractional part of $x$. But this is a contradiction since $g$ does not divide $t^r a$ so we must have $|\{t^r a /g \}| \geq 1/q^{d}$.
\end{proof}

\begin{lemma}  \label{l4}
For $d \leq n/2$ we have
\[\sum_{\substack{ \deg a < \deg g \leq d \\ (a,g)=1 }}\left| S_\mathcal{R}\left(\frac{a}{g} \right) \right| \leq (q-s)^{n-2d}(q(1+\sqrt{s})-2s)^{2d}.\]
\end{lemma}

\begin{proof}
For any integer $Y$ and $x \in \mathbb{T}$, define \[S_\mathcal{R}^Y(x) = \sum_{m \in \mathcal{M}_\mathcal{R}(Y)}\textbf{e}_q(mx)\]
so that $S_\mathcal{R}(x) = S_\mathcal{R}^n(x).$
Then
\begin{align*}
\left|S_\mathcal{R}^n(x)\right| &= \left|\prod_{i=0}^{n-1}\sum_{n_i \in \mathcal{R}^c }\psi(n_ix_{-i-1}) \right| \\
&= \left|\prod_{i=0}^{Y-1}\sum_{n_i \in \mathcal{R}^c}\psi(n_ix_{-i-1}) \prod_{i=Y}^{n-1}\sum_{n_i \in \mathcal{R}^c}\psi(n_ix_{-i-1})\right| \\
&= \left|S_\mathcal{R}^Y(x)S_\mathcal{R}^{n-Y}(x t^Y)\right|.
\end{align*}
Applying this with $Y = 2d$ gives
\begin{align*}
\sum_{\substack{ \deg a < \deg g \leq d \\ (a,g)=1 }}\left| S_\mathcal{R}\left(\frac{a}{g} \right) \right| &= \sum_{\substack{ \deg a < \deg g \leq d \\ (a,g)=1 }}\left|S_\mathcal{R}^{2d}\left(\frac{a}{g}\right)S_\mathcal{R}^{n-2d}\left( \frac{t^{2d}a}{g}\right)\right| \\
&\leq \max_{\substack{ \deg a < \deg g \leq d \\ (a,g)=1 }}\left| S_\mathcal{R}^{n-2d}\left(\frac{t^{2d}a}{g}\right) \right| \sum_{\substack{ \deg a < \deg g \leq d \\ (a,g)=1 }}\left|S_\mathcal{R}^{2d}\left(\frac{a}{g}\right)\right| \\
&\leq (q-s)^{n-2d}\sum_{\substack{ \deg a < \deg g \leq d \\ (a,g)=1 }}\left|S_\mathcal{R}^{2d}\left(\frac{a}{g}\right)\right|,
\end{align*}
where we have used the trivial bound $|S_\mathcal{R}^{n-2d}(x)| \leq (q-s)^{n-2d}$. Notice that $S_\mathcal{R}^{2d}(a/g + \gamma )$ is constant in the range $|\gamma|<1/q^{2d}$ and recall that the Farey arcs $\mathcal{F}(a/g, q^{2d})$ are disjoint. Therefore
\[\frac{1}{q^{2d}}\sum_{\substack{ \deg a < \deg g \leq d \\ (a,g)=1 }}\left|S_\mathcal{R}^{2d}\left(\frac{a}{g}\right)\right| = \sum_{a,q}\int_{ \mathcal{F}(a/g, q^{2d})}\left|S_\mathcal{R}^{2d}\left(\frac{a}{g}+ \gamma\right)\right|d \gamma \leq (\sqrt{s}+1-2s/q)^{2d}\]
by Corollary~\ref{c1} where the sum is over all distinct fractions $a/q$ with $\deg g \leq d$.
\end{proof}

\begin{lemma}\label{l5}
Let $g \in \mathbb{F}_q[t]$. Then \[\frac{q^{\deg g}}{\phi(g)} = \prod_{\omega|g}\left(1-\frac{1}{q^{\deg \omega}}\right)^{-1} \leq (1+\log_q(\deg g))e.\]
\end{lemma}

\begin{proof}
Arrange the monic, irreducibles $\omega_1,\ldots,\omega_r$ dividing $g$ and the monic irreducibles $P_1,\ldots$ in $ \mathbb{F}_q[t] $ in order of degree (ordering those of the same degree arbitrarily). Then we must have that $ \deg P_i \leq \deg \omega_i $. Now, for some $ N $, we have that $ \sum_{P: \deg P \leq N-1} \deg P < \deg g \leq \sum_{P: \deg P \leq N} \deg P $. This implies that $g$ has at most $\pi(N)$ irreducible factors, and so, since $ \deg P_i \leq \deg \omega_i $ we have
\[ \prod_{\omega|g} (1-q^{-\deg \omega})^{-1}  \leq \prod_{P:\deg P \leq N} (1-q^{-\deg P})^{-1} . \]
Taking the logarithm of the right hand side, and using the fact that $ -\log(1-\frac{1}{x}) \leq \frac{1}{x-1} $ for $x>1$, and that $\sum_{d|r}d\pi(d) = q^r$ so $\pi(r)r \leq q^r -1$ we get
\[\sum_{P:\deg P \leq N} -\log(1-q^{-\deg P}) \leq \sum_{r \leq N} \frac{\pi(r)}{q^{r}-1} \leq \sum_{r \leq N} \frac{1}{r} \leq 1+ \log N.\]
Now $N$ is bounded in terms of $ \deg g $ as follows,
\[\deg g > \sum_{P: \deg P \leq N-1} \deg P = \sum_{r \leq N-1} \pi(r) r \geq \sum_{r | N-1} \pi(r) r = q^{N-1},\]
and hence $ N \leq 1+\log_q \deg g$.
Combining these inequalities gives the result.
\end{proof}

\section{Proof of Theorem~\ref{thm}}
Recall that our aim is to evaluate $N(\mathcal{R},n) = \int_{\mathbb{T}}S(x)\overline{S_\mathcal{R}(x)}d x$. Now each $x \in \mathbb{T}$ can be written as $a/g + \gamma$ for unique $a,g,\gamma$ as in Lemma~\ref{l1} which allows us to write
\[ N(\mathcal{R},n) = \int_{\mathbb{T}}\overline{S_\mathcal{R}(x)}\left(\frac{\mu(g)}{\phi(g)}\pi(n)\textbf{e}_q(\gamma t^n)\textbf{1}_{|\gamma| < 1/q^n} + E\right) dx,\]
where $|E|\leq q^{n-\frac{1}{2}[\frac{n}{2}]}$ uniformly. The error term is bounded by using Corollary~\ref{c1} as
\begin{equation}
\left| \int_{\mathbb{T}}\overline{S_\mathcal{R}(x)}E dx \right| \leq q^{n-\frac{1}{2}[\frac{n}{2}]} (\sqrt{s}+1-2s/q)^n.
\end{equation}
We can write what's left as
\[\int_{\mathbb{T}}\overline{S_\mathcal{R}(x)}\frac{\mu(g)}{\phi(g)}\pi(n)\textbf{e}_q(\gamma t^n)\textbf{1}_{|\gamma| < 1/q^n} dx = \sum_{a,g} \int_{\mathcal{F}(a/g,\: q^{ n })}\overline{S_\mathcal{R}\left(\frac{a}{g}+\gamma\right)}\frac{\mu(g)}{\phi(g)}\pi(n)\textbf{e}_q(\gamma t^n) d\gamma \]
where the sum is over all distinct fractions $a/g$ such that $\deg g \leq n/2$. These are the so-called major arcs.

Since $|\gamma| < 1/q^n$, from the definition we get
\[S_\mathcal{R}\left(\frac{a}{g} + \gamma \right) = \sum_{m \in \mathcal{M}_\mathcal{R}(n) }\mathbf{e}_q(am/g)\mathbf{e}_q(m\gamma) = \mathbf{e}_q(\gamma t^n)S_\mathcal{R}\left(\frac{a}{g}\right) \]
and therefore, since the integrand is constant on each of these major arcs which have measure $1/q^n$ the contribution becomes
\begin{equation}
\frac{\pi(n)}{q^n}\sum_{a,g} \overline{S_\mathcal{R} \left(\frac{a}{g} \right)}\frac{\mu(g)}{\phi(g)}.
\end{equation}

Let us first analyse the terms with $g=1$ and $g=t$, that is, look at
\[M=\frac{\pi(n)}{q^n}\left(S_\mathcal{R}(0)+\sum_{b \in \mathbb{F}_q\backslash 0}\overline{S_\mathcal{R} \left(\frac{b}{t} \right)}\frac{\mu(t)}{\phi(t)}\right).\]
The $g=1$ term gives $S_\mathcal{R}(0) = (q-s)^n$. Using our expression for $S_\mathcal{R}(b/t)$ from the start of the proof of Lemma~\ref{l2}, the terms $g=t$ are
\[\sum_{b \in \mathbb{F}_q\backslash 0} S_\mathcal{R}(b/t) = (q-s)^{n-1}\sum_{b \in \mathbb{F}_q\backslash 0 } \sum_{n \in \mathcal{R}^c } \mathbf{e}_q(\frac{n b}{t}) = -(q-s)^{n-1}\sum_{b \in \mathbb{F}_q\backslash 0 } \sum_{r \in \mathcal{R} } \psi(br).\]
Using
\[\sum_{b \in \mathbb{F}_q\backslash 0}\psi(br) =
\begin{cases}
q-1 &\text{ if } r=0 \\
-1 &\text{ if } r \neq 0
\end{cases}
\]
This becomes
\[\begin{cases}
-(q-s)^{n} & \text{ if } 0 \in \mathcal{R} \\
(q-s)^{n-1}s & \text{ if } 0 \notin \mathcal{R}.
\end{cases}\]
Hence, since $\mu(t) = -1$ and $\phi(t) = q-1$ we have
\begin{align*}
M &= \frac{\pi(n)}{q^n} \left( (q-s)^n -\frac{1}{q-1} \sum_{b \in \mathbb{F}_q\backslash 0}S_\mathcal{R}(b/t)\right) \\
& =  \frac{q\Lambda}{q-1}\pi(n)(1-s/q)^n,
\end{align*}
where
\[\Lambda = \begin{cases}
1 & \text{ if } 0 \in \mathcal{R} \\
1-\frac{1}{q-s} & \text{ if } 0 \notin \mathcal{R}.
\end{cases}\]
Using $\pi(n) \leq q^n/n$, the remaining terms in (4.2) are bounded by

\[\frac{1}{n}\sum_{\substack{ 1\leq \deg g \leq n/2 \\ g\neq t }}\frac{|\mu(g)|}{\phi(g)} \sum_{\substack{\deg a < \deg g \\ (a,g)=1 }}\left| S_\mathcal{R} \left(\frac{a}{g}\right)\right|.\]
Let $U$ be some parameter $1 \leq U \leq n/2$ to be specified shortly. Grouping the $g$ according to their degree and using Lemma~\ref{l3} for the terms with $d = \deg g \leq U $ and Lemmas~\ref{l4} and~\ref{l5} for the terms with $\deg g > U$ we get
\begin{align*}
&\sum_{\substack{1\leq  \deg g \leq n/2\\ g\neq t }}\frac{|\mu(g)|}{\phi(g)} \sum_{\substack{\deg a < \deg g \\ (a,g)=1 }}\left| S_\mathcal{R} \left(\frac{a}{g}\right)\right| \\
&\leq \sum_{1\leq d\leq U}q^d(q-s)^{n - [\frac{n}{d}]} s^{[\frac{n}{d}]} + e\sum_{ U  < d \leq n/2 }q^{-d}(q-s)^{n-2d}(q(1+\sqrt{s})-2s)^{2d}(1 + \log_q(d))\\
& =(q-s)^n \left( \sum_{1 \leq d\leq U} q^d\left(\frac{s}{q-s}\right)^{[\frac{n}{d}]}  + e\sum_{U < d \leq n/2} q^d\left(\frac{1+\sqrt{s}-2s/q}{q-s}\right)^{2d}(1 + \log_q(d)) \right) \\
& \ll (q-s)^n\left( n \left(q^U\left(\frac{s}{q-s}\right)^{n/U} + q^{U/2}\left(\frac{\sqrt{s}+1-2s/q}{q-s}\right)^{U} \right) \right)
\end{align*}
We have trivially bounded the first sum. The bound for the second sum follows after using $1+ \log_q(d) \leq n $ and bounding the resulting geometric sum using $s\leq \sqrt{q}/2$ so that
\[\frac{\sqrt{q}(\sqrt{s}+1-2s/q)}{q-s} \leq \frac{q/2+\sqrt{q}}{q-\sqrt{q}/2}<0.99\] for $q \geq 11$. Taking $U = (2n/5)^{1/2}$ and using $s \leq \sqrt{q}/2$ this becomes
\begin{align*}
&\ll(q-s)^n\left( n \left(q^{\sqrt{\frac{2}{5}n}}\left(\frac{q^{1/2}}{2q-q^{1/2}}\right)^{\sqrt{\frac{5}{2}n}} + q^{\sqrt{\frac{1}{10}n}}\left(\frac{q^{1/4}/\sqrt{2}+1}{q-q^{1/2}/2}\right)^{\sqrt{\frac{2}{5}n}} \right) \right) \\
&\ll n(q-s)^n q^{-n^{1/2}/(2\sqrt{10})},
\end{align*}
since $\sqrt{\frac{2}{5}}-\frac{1}{2}\sqrt{\frac{5}{2}} = -\frac{1}{2\sqrt{10}}$ and $\sqrt{\frac{1}{10}}-\frac{3}{4}\sqrt{\frac{2}{5}} = -\frac{1}{2\sqrt{10}}$. Combining this with our expression for the main term $M$ and error estimate (4.1) we get
\begin{equation}
N(\mathcal{R},n) =  \frac{ q }{q-1}\frac{(q-s)^n}{n}\left( \Lambda + O\left( n \mathcal{E} \right) \right)
\end{equation}
where
\begin{equation}
\mathcal{E} \ll q^{-n^{1/2}/(2\sqrt{10})} + \left(\frac{q^{3/4}(s^{1/2}+1)}{q-s}\right)^n.
\end{equation}
Since $s \leq \sqrt{q}/2$, we then have
\begin{equation}
\mathcal{E} \ll q^{-n^{1/2}/(2\sqrt{10})} + \left(\frac{q/\sqrt{2} + q^{3/4}}{q-\sqrt{q}/2}\right)^n.
\end{equation}
A calculation reveals that for $n \geq 100(\log q)^2$, the first expression is larger then the second when $q \geq 500$ and that both are $ \ll q^{-n^{1/2}/7}/n$ which completes the proof of Theorem~\ref{thm}.

\begin{remark}
The conditions on the sizes of $s$, $q$ and $n$ were made in order to simplify the statement of Theorem~\ref{thm} but (4.4) is also interesting for other choices. For example, when $n$ is fixed, we have that $\mathcal{E} \rightarrow 0 $ as $q \rightarrow \infty$ provided $s = o(q^{1/2}).$

Recall that in the special case $s=1$, we have equality in Corollary~\ref{c1}. Feeding this through the rest of the proof gives
\[\mathcal{E} \ll q^{-n^{1/2}/(2\sqrt{10})} + \left( \frac{q^{3/4}(2-2/q)}{q-1} \right)^n.\]
For $q\geq 17$, the expression in the brackets is less than 1 which proves $n\mathcal{E} \rightarrow 0$ as $n \rightarrow \infty$ in this case.
\end{remark}

\section{Proof of Theorem~\ref{thm2}}

Our proof of Theorem~\ref{thm2} is the same as Theorem~\ref{thm} except that we use modified versions of Corollary~\ref{c1} and Lemma~\ref{l3} which we will now prove. In this section, we assume that $p$ is a prime, $\mathcal{R} \subset \mathbb{F}_p$ is subset of consecutive coefficients and use the same notation already introduced.

\begin{corollary}\label{c2}
\[\int_{\mathbb{T}}|S_\mathcal{R}(x)|dx \leq (\log p + 1 - s/p)^n.\]
\end{corollary}

\begin{proof}
Write $\mathcal{R} = \{d, d+1, \ldots, d+s-1 \}$, then, if $r=0$, $|\widehat{\textbf{1}_{\mathcal{R}^c}}(r)| = p-s$, and if $r \neq 0$,
\[|\widehat{\textbf{1}_{\mathcal{R}^c}}(r)| = \left| \sum_{k=d}^{d+s-1}e^{2\pi i kr/p} \right| = \left|\frac{1-e^{2 \pi i sr/p}}{1-e^{2\pi i r/p}}\right| \leq \frac{1}{|\sin\pi r/p|}.\]
Therefore,
\[\sum_{r \in \mathbb{F}_p}|\widehat{\textbf{1}_{\mathcal{R}^c}}(r)| \leq p-s + \sum_{r=1}^{p-1}\frac{1}{|\sin \pi r/p|}< p-s+2\sum_{r=1}^{\frac{p-1}{2}}\frac{p}{2 r}<p-s+p\log p .\]
Now use Lemma~\ref{l2}.
\end{proof}

Consequently, the bound in Lemma~\ref{l4} is replaced by $(p-s)^{n-2n}(p(\log p + 1) - s)^{2n}.$

\begin{lemma}\label{l6}
Let $a, g \in \mathbb{F}_p[t]$ be coprime polynomials with $|a|<|g|$ and $g$ not a power of $t$ and let $d = \deg g > 0$. Then
\[\left| S_\mathcal{R}(a/g) \right| \leq (p-s)^{n}e^{-[\frac{n}{d}]\frac{1}{p^3}}.\]
\end{lemma}

\begin{proof}
As in the proof of Lemma~\ref{l3} we have \[|S_\mathcal{R}(a/g)|=(p-s)^{n-z} \prod_{\substack{i=0 \\ x_{-i-1} \neq 0}}^{n-1}\left|\sum_{n_i \in \mathcal{R}}e^{2\pi i(n_ix_{-i-1})/p}\right|.\]
For $x \in \mathbb{F}_p \backslash \{0\}$, we have
\[\left|e^{2 \pi i \frac{x}{p}n} + e^{2 \pi i \frac{x}{p}(n+1)}\right|^2 = 2+2\cos(\frac{2\pi x}{p}) < 4 e^{-2/p^2},\]
and therefore
\[\left|\sum_{n_i \in \mathcal{R}}e^{2\pi i(n_ix_{-i-1})/p}\right| \leq p-s-2+2e^{-1/p^2} \leq (p-s)e^{-1/p^3}.\]
Recalling from the proof of Lemma~\ref{l3} that $z \geq [n/d]$ completes the proof.
\end{proof}

Provided $p$ is large enough to ensure that $\frac{\sqrt{p}(\log p + 1 - s/p)}{p-s}<1$ (so the resulting geometric sum we saw earlier converges) we may just insert these new bounds into the proof of Theorem~\ref{thm} to get (4.3) with
\[\mathcal{E} \ll p^U e^{-[\frac{n}{U}]\frac{1}{p^3}} + \left(\frac{\sqrt{p}(\log p + 1 - s/p)}{p-s}\right)^{U} + \left(\frac{p^{3/4}(\log p + 1 - s/p)}{p-s}\right)^n \]
for some parameter $U$. Taking $U = cn^{1/2}$, and since we are assuming $p-s > p^{3/4+\delta}$, this proves Theorem~\ref{thm2} for some $c>0$ sufficiently small in terms of $p$ and $\delta$.

\section*{Acknowledgements}\label{ackref}
The author would like to thank his supervisor, Andrew Granville, for his encouragement and suggestions and Simon Myerson for his helpful comments. This work was supported by the Engineering and Physical Sciences Research Council EP/L015234/1 via the EPSRC Centre for Doctoral Training in Geometry and Number Theory (The London School of Geometry and Number Theory), University College London.


\section{Introduction}

The \textsc{AllSAT}{} problem is a variant of the \textsc{SAT}{} problem where we are interested in finding all the models (satisfying assignments) of the input formula. Applications of \textsc{AllSAT}{} to fields like model checking \cite{yadgar:09,grumberg:04,mcmillan:02} and data mining \cite{jabbour:13} have drawn attention to \textsc{AllSAT}{} solvers. The survey by Toda and Soh \cite{toda:16} summarizes the state-of-the-art in techniques used for solving \textsc{AllSAT}{} problems. Many ideas from \textsc{SAT}{} solvers are applicable to \textsc{AllSAT}{} solvers with few adaptations. For example, the basic idea behind \textsc{AllSAT}{} solvers based on blocking-clauses \cite{mcmillan:02} is to iteratively find a model using a conventional \textsc{SAT}{} solver and then add a clause that blocks that model, until no models are found. This intuitive idea serves as a base for other more advanced approaches to \textsc{AllSAT}{} solvers \cite{yu:06}. A technique that has proved effective in \textsc{SAT}{} solvers and is of particular importance for \textsc{AllSAT}{} problems is symmetry breaking in Boolean formulas \cite{sakallah:09}. Much research has been devoted to develop methods that prevent \textsc{SAT}{} solvers from exploring redundant search spaces in search for a satisfying assignment. The survey by Walsh \cite{walsh:12} provides a good overview of the current approaches and techniques used to deal with this problem. Extensions of symmetry breaking for \textsc{SAT}{} have been studied for different related problems like \textsc{MaxSAT}{} \cite{kopp:15} and \textsc{\#SAT}{} \cite{kopp:16}, and in the context of Answer Set Programming \cite{devriendt:16b}. \toolname{Shatter} \cite{aloul:06} is a tool that generates \emph{symmetry-breaking clauses} as a preprocessing step to solve Boolean formulas in order to simplify the search space for conventional \textsc{SAT}{} solvers. \toolname{Shatter} has become a popular preprocessing tool since it can be used on any CNF formula encoded in the popular DIMACS format and it has the desirable property that the size of the symmetry-breaking clauses it adds to the formula is linear in the number of variables of the original formula.

To study the effect of \toolname{Shatter}'s symmetry breaking approach in a clean application where symmetries can be formally defined and studied, we look at symmetry breaking for Ramsey-type problems in combinatorial computing. Ramsey-type problems are those related to conditions by which it is impossible to avoid prescribed substructures when partitioning the set of elements of a discrete object. Computational approaches to solve these kinds of problems have recently leveraged advances on \textsc{SAT}{} solvers \cite{heule:17}. In this paper we focus on graph 2-colorings, which are partitions of the set of edges of a graph into two sets. We say that a graph $F$ \emph{arrows} the pair of graphs $\left(G,H\right)$, written $F\rightarrow\left(G,H\right)$, when any 2-coloring of the edges of a graph $F$ yields a monochromatic $G$ in the first color or a monochromatic $H$ in the second color.

It is straightforward to see how 2-color arrowing problems can be encoded into Boolean satisfiability problems. In the case of finite Ramsey numbers, a description of this encoding appears in Zhang's chapter in the Handbook of Satisfiability \cite{zhang:09}. Boolean formulas arising from this encoding have a prominent place in complexity theory because they provide hard examples for resolution. The complexity of resolution of such formulas was studied by Krishnamurthy \cite{krishnamurthy:81}, Krajíček \cite{krajivcek:01}, and Pudlák \cite{pudlak:12}, among others.

On the one hand, determining the satisfiability of a Boolean formula encoding $F\not\rightarrow\left(G,H\right)$ (i.e., solving the \textsc{SAT}{} problem for this formula) can answer the question of whether $F$ arrows the pair $\left(G,H\right)$. On the other hand, finding all the assignments that satisfy the formula (i.e., solving the \textsc{AllSAT}{} problem for this formula) can be used to generate the complete set of colorings of the edges of $F$ witnessing $F\not\rightarrow\left(G,H\right)$. Generating these sets of colorings for one parameter $\left(G,H\right)$ is often used as a building block towards finding exact values for Ramsey numbers under different parameters. The ``gluing method'' used to establish $R\left(4,5\right)=25$ \cite{mckay:95}, which is still found embedded in more recent ideas \cite{codish:16}, is an example of such an application. Using \textsc{AllSAT}{} solvers for this purpose offloads the combinatorial search to standard tools that are being actively developed \cite{toda:16}, eliminating the need to craft specialized code. A shortcoming of generating these families through the method of encoding the negation of the arrowing property into a Boolean formula is that an \textsc{AllSAT}{} solver may generate many colorings that are essentially equivalent among them as it lists all possible models of the formula. The need to generate models that are distinct under some notion of equivalence is not unique to formulations of the arrowing predicate as a Boolean formula. Many symmetry breaking techniques have been developed for specific applications of \textsc{SAT}{}. A great example of a symmetry breaking technique specifically tailored for graph search is the use of \emph{canonizing sets} for small graph searches \cite{itzhakov:16}. Unfortunately, the need to embed these techniques into the Boolean encoding of the non-arrowing property may neglect the advantage of using general-purpose \textsc{AllSAT}{} solvers. To avoid this issue, one may be interested in using off-the-shelf symmetry breaking software that is domain independent.

Given Shatter's popularity, it may seem as a good tool to tackle the generation of irredundant sets of colorings for Ramsey-type problems. Nevertheless, in this paper we identify and discuss some drawbacks of using this approach without caution. One of these drawbacks stems from the fact that Shatter's main goal is to avoid adding symmetry-breaking clauses whose number of literals is quadratic in the number of variables while making it easier to find \emph{a} (not \emph{every}) satisfying assignment of the original formula should one exist. This is done at the expense of preserving the number of ``unique'' satisfying assignments of the original formula. Another drawback stems from the fact that \toolname{Shatter} works directly at the Boolean formula level to detect symmetries, so it has no access to domain-specific symmetries that are not carried over by the encoding. The issues presented in this work are not intended to discourage the use of \toolname{Shatter} as a preprocessing tool for \textsc{AllSAT}{} problems in combinatorial computing but to help researchers properly use this tool by avoiding these potential pitfalls. To this end, we provide strategies and additional tools to cope with the negative effects of using \toolname{Shatter} for \textsc{AllSAT}{}.

The rest of this paper is organized as follows. In Section~\ref{s:background} we review \toolname{Shatter}'s approach to symmetry breaking and give a brief background on Ramsey-type problems. In Sections~\ref{s:numberofmodels} and \ref{s:incompletesets} we address the problems of the number of satisfying assignments of the resulting formulas after preprocessing with \toolname{Shatter} and the generation of incomplete sets of colorings, respectively. Finally, Section~\ref{s:conclusions} adds some concluding remarks and directions for future work.

\section{Background and Definitions}
\label{s:background}

\toolname{Shatter} is a domain-independent preprocessing tool \cite{aloul:06} which is available online\footnote{\url{http://www.aloul.net/Tools/shatter/}} and works on Boolean formulas expressed in the standard DIMACS format, making it very convenient to integrate in any existing workflow. A fundamental construction in \toolname{Shatter}'s formulation of symmetry breaking predicates is a graph that encodes the relationship between clauses and literals of the input formula \cite{aloul:03}. This graph is defined as follows:

\begin{definition}
\label{d:gphi}
 For an input formula $\phi$, Shatter generates the vertex-colored graph $G_\phi$ whose vertex set is the union of the set of clauses of $\phi$ in one color, and the set of literals of $\phi$ in another color, and whose edge set is constructed according to the following rules\footnote{Because of unit propagation, we may assume without loss of generality that every clause in $\phi$ contains at least two variables. This is implemented as a preprocessing step in Shatter.}:
\begin{itemize}
 \item For every variable $x$ in the formula, an edge is added between literals $x$ and $\overline{x}$.
 \item For every clause $C$ in $\phi$ with more than two literals, an edge is added between $C$ and every literal in $C$.
 \item For every clause $C$ in $\phi$ with exactly two literals, an edge is added between the two literals.
\end{itemize}
\end{definition}

The symmetry breaking predicates added by \toolname{Shatter} come from the automorphisms of the graph $G_\phi$. Recall the automorphisms of a graph are the permutations of its vertices that leave its edge set unchanged, and that these form a group. In the case of vertex-colored graphs, these permutations respect the coloring in the sense that no vertex is mapped to a vertex of a different color. A bird's eye view of the process \toolname{Shatter} uses to break the symmetries of a Boolean formula $\phi$ is as follows:
\begin{inparaenum}[(a)]
\item the graph $G_\phi$ is generated as per the rules above,
\item the group of automorphisms of $G_\phi$ is found,
\item a subset of these automorphisms (in particular, \toolname{Shatter} uses the generators of the group, following \cite{crawford:96}) is used to generate symmetry breaking clauses that are added to $\phi$
\end{inparaenum}.

Let $\pi$ be a permutation in the automorphism group of $G_\phi$, and consider the restriction $\pi_\mathbf{x}$ of $\pi$ to the set of literal vertices of $G_\phi$. $\pi_\mathbf{x}$ is a permutation of the literals of $\phi$ because the color of the literal vertices is different from that of the clause vertices. Let $x_1,x_2,\ldots,x_n$ be an ordering of the variables of $\phi$ and let $E_k=\left(x_1\leftrightarrow\pi_\mathbf{x}\left(x_1\right)\right)\land\cdots\land\left(x_k\leftrightarrow\pi_\mathbf{x}\left(x_k\right)\right)$ with $E_0=\top$. Then the key observation behind lexicographical symmetry breaking is that
$$\phi\in\textsc{SAT}\Leftrightarrow\phi\land\left(\bigwedge\limits_{i=0}^{n-1}E_i\rightarrow\left(x_{i+1}\rightarrow \pi_\mathbf{x}\left(x_{i+1}\right)\right)\right)\in\textsc{SAT}$$
for if $\delta$ is a satisfying assignment of $\phi$, $\delta'=\delta\circ\pi_\mathbf{x}$ is a satisfying assignment of $\phi$ as well, and one of $\delta$ and $\delta'$ will precede the other in lexicographical order (considering the strings $\delta^*\left(x_1\right)\delta^*\left(x_2\right)\ldots\delta^*\left(x_n\right)$ for $\delta^*=\delta,\delta'$) thus satisfying the additional constraints. Following the same principle, one can prove that adding lexicographical constraints for other permutations in the automorphism group of $G_\phi$ will also preserve satisfiability while reducing the number of models of the resulting formula. Notice that this formulation of symmetry breaking adds $n$ expressions involving $E_i$ subexpressions, but $E_i$ itself has a literal count that is linear in $i$, so the number of literals added per automorphism is quadratic in the number of variables of $\phi$.

This set of rules corresponds to the most basic version of lexicographical symmetry breaking. \toolname{Shatter} implements several optimizations over this basic workflow which have desirable effects on determining the satisfiability of the input formula. In Sections \ref{s:numberofmodels} and \ref{s:incompletesets}, on the other hand, we study the effect of using this tool for an \textsc{AllSAT}{} application: reducing the number of models found through encodings of the non-arrowing property as a Boolean formula. We define the concepts from Ramsey theory that are relevant to our analysis in the following section.

\subsection{Ramsey Colorings}

For a graph $G$, let $V\left(G\right)$ and $E\left(G\right)$ be the set of vertices and edges of $G$, respectively. The order of a graph is the number of vertices of the graph. For two graphs $G$ and $H$, we denote by $\mathcal{S}\left(G,H\right)$ the set of (not necessarily induced) subgraph isomorphisms from $H$ to $G$. More formally, the set $\mathcal{S}\left(G,H\right)$ is the set of injective functions $s$ from $V\left(H\right)$ to $V\left(G\right)$ such that if $\left\{u,v\right\}\in E\left(H\right)$ then $\left\{s\left(u\right),s\left(v\right)\right\}\in E\left(G\right)$.

An edge coloring of $G$ is a function $\sigma$ from the set $E\left(G\right)$ to a finite set of colors. If the cardinality of the set of colors is $k$, the coloring is said to be a $k$-coloring. Two edge colorings of a graph $G$ are \emph{isomorphic} if one can be turned into the other by permuting the vertices of $G$, i.e., two colorings $\sigma_1$ and $\sigma_2$ are isomorphic if there exists a permutation $\pi$ of $V\left(G\right)$ such that for every edge $\left\{u,v\right\}\in E\left(G\right)$, $\sigma_1\left(\left\{\pi\left(u\right),\pi\left(v\right)\right\}\right)=\sigma_2\left(\left\{u,v\right\}\right)$. We define a ``deduplication'' operation $D$ on sets of colorings that preserves only one representative of each of the equivalence classes in the input set of colorings. Formally, for a set of colorings $A_G$ of a graph $G$, $D\left(A_G\right)$ is defined as a set of colorings such that $\sigma_1,\sigma_2\in D\left(A_G\right)$ implies $\sigma_1$ is not isomorphic to $\sigma_2$, and for every $\sigma\in A_G$ there exists a $\tilde{\sigma}\in D\left(A_G\right)$ such that $\sigma$ is isomorphic to $\tilde{\sigma}$. The choice of which representative is kept by this operation is not crucial to our application, so we can assume it is the minimum over some ordering of the colorings in $A_G$. A desirable property of $D\left(A_G\right)$ is that it can be used to recover the full set of colorings so it is an efficient way to store the entire set $A_G$.

For graphs $F$, $G$ and $H$, we say the graph $F$ arrows the pair $\left(G,H\right)$ if every 2-coloring of the edges of $F$ either contains a monochromatic $G$ in the first color or a monochromatic $H$ in the second color. We denote this property by $F\rightarrow\left(G,H\right)$. A 2-coloring of the edges of $F$ that contains no monochromatic $G$ in the first color and no monochromatic $H$ in the second color is said to \emph{witness} the fact that $F\not\rightarrow\left(G,H\right)$. The most classical example of arrowing is the fact that the edges of the complete graph on 6 vertices $K_6$ cannot be 2-colored in a way that avoids monochromatic triangles, so $K_6\rightarrow\left(K_3,K_3\right)$. The edges of $K_5$, on the other hand, can be colored as shown in Figure~\ref{f:k5example} avoiding monochromatic triangles, so $K_5\not\rightarrow\left(K_3,K_3\right)$. Several Ramsey-type problems can be expressed in terms of the arrowing property: the generalized Ramsey number $R\left(G,H\right)$ can be defined as the smallest natural number $N$ such that $K_N$ arrows the pair $\left(G,H\right)$\footnote{The ``classical'' Ramsey numbers are defined in terms of generalized Ramsey numbers as $R\left(n,m\right)=R\left(K_n,K_m\right)$ for positive integers $n$ and $m$.}, while the generalized (edge) Folkman number $F_e\left(G,H;n\right)$, which is another concept commonly studied in Ramsey theory, can be defined as the smallest order of a $K_n$-free graph that arrows the pair $\left(G,H\right)$. We define $\mathcal{C}\left(F;G,H\right)$ as the set of witness colorings of $F\not\rightarrow\left(G,H\right)$. Clearly, $\mathcal{C}\left(F;G,H\right)=\emptyset\Leftrightarrow F\rightarrow\left(G,H\right)$. We will call a set of colorings for parameters $F$, $G$ and $H$ \emph{complete}\footnote{Not to be confused with other uses of \emph{completeness} in the context of symmetry breaking for Boolean formulas. For instance, \cite{itzhakov:16} defines the concepts of \emph{sound} and \emph{complete} symmetry breaking predicates to compare the characteristics of different types symmetry breaking predicates, but in our context we have fixed the type of symmetry breaking predicate to lexicographical symmetry breaking.} if every isomorphism class in $\mathcal{C}\left(F;G,H\right)$ is represented in the set. For instance, $\mathcal{C}\left(F;G,H\right)$ itself is trivially complete, and $D\left(\mathcal{C}\left(F;G,H\right)\right)$ is complete by definition.

To use \textsc{AllSAT}{} solvers to generate graph 2-colorings, we exploit the fact that the Boolean domain contains two values $\top$ (\emph{true}) and $\bot$ (\emph{false}) and express the negation of the arrowing property in terms of Boolean formulas. Consider the Boolean formula $\phi\left(F;G,H\right)$ on $\left|E\left(F\right)\right|$ variables $x_{\left\{u,v\right\}}$ for $\left\{u,v\right\}\in E\left(F\right)$ defined as per equation~(\ref{e:nonarrowing}) in Figure~\ref{f:nonarrowing}. This formula essentially states that in every subgraph isomorphism from $G$ to $F$ at least one of the edges involved is ``colored'' \emph{true}, and in every subgraph isomorphism from $H$ to $F$ at least one of the edges involved is ``colored'' \emph{false}. If we define the set of colors as $\left\{\bot,\top\right\}$, then a model of $\phi\left(F;G,H\right)$ can easily be mapped to an edge coloring of $F$ that avoids monochromatic copies of $G$ and $H$ in the first and second color, respectively. It is also easy to see this mapping is one-to-one, i.e., to each model of $\phi\left(F;G,H\right)$ corresponds a coloring witnessing $F\not\rightarrow\left(G,H\right)$ and vice versa. Thus, $\phi\left(F;G,H\right)\in\textsc{SAT}\Leftrightarrow F\not\rightarrow\left(G,H\right)$. Furthermore, one can generate $\mathcal{C}\left(F;G,H\right)$ by using an \textsc{AllSAT}{} solver to list every model of $\phi\left(F;G,H\right)$. As mentioned before, an undesirable characteristic of this approach is that $\mathcal{C}\left(F;G,H\right)$ can be large and one is in general more interested in generating the smaller set $D\left(\mathcal{C}\left(F;G,H\right)\right)$ directly from the \textsc{SAT}{} formulation of $F\not\rightarrow\left(G,H\right)$.

\begin{figure*}
{\footnotesize
\begin{equation}
 \label{e:nonarrowing}
\phi\left(F;G,H\right)=\left(\bigwedge\limits_{s\in\mathcal{S}\left(F,G\right)}\bigvee\limits_{\left\{u,v\right\}\in E\left(G\right)}x_{\left\{s\left(u\right),s\left(v\right)\right\}}\right)\land\left(\bigwedge\limits_{s\in\mathcal{S}\left(F,H\right)}\bigvee\limits_{\left\{u,v\right\}\in E\left(H\right)}\overline{x_{\left\{s\left(u\right),s\left(v\right)\right\}}}\right)
\end{equation}}
\caption{The standard encoding for the non-arrowing property as a Boolean formula. Here, $\mathcal{S}\left(X,Y\right)$ denotes the set of non-induced subgraph isomorphisms from $X$ to $Y$ (see Section~\ref{s:background}).}
\label{f:nonarrowing}
\end{figure*}

\begin{figure}
\centering
 \includegraphics{k5example}
 \caption{A coloring of $K_5$ avoiding monochromatic triangles, thus witnessing $K_5\not\rightarrow\left(K_3,K_3\right)$. The two colors are represented by solid and dashed lines.}
 \label{f:k5example}
\end{figure}

\section{Number of Satisfying Assignments}
\label{s:numberofmodels}

One of the main improvements of \toolname{Shatter} \cite{aloul:06} over the original formulation of the symmetry breaking clauses \cite{crawford:96} explained in Section~\ref{s:background} is that \toolname{Shatter} adds symmetry-breaking clauses whose number of literals is linear in the number of variables of the input formula. This is done through a relaxation on the symmetry breaking constraints. This relaxation has an undesirable effect in the number of satisfying assignments of the resulting formula. To study this effect, we summarize some of the details behind \toolname{Shatter}'s relaxation of the symmetry breaking constraints.

Using additional equality variables $e_i\equiv\left(x_i\leftrightarrow\pi_\mathbf{x}\left(x_i\right)\right)$, one incurs in a quadratic increase on the length of the formula when adding lexicographical symmetry breaking clauses, as mentioned in Section~\ref{s:background}. \toolname{Shatter} avoids this by using ``chaining predicates''. For this, new variables $l_i\equiv\left(x_i\rightarrow\pi_\mathbf{x}\left(x_i\right)\right)$ (that is, $l_i$ is true if and only if $x_i$ is ``less than or equal to'' $\pi_\mathbf{x}\left(x_i\right)$) and $p_i$ are introduced, together with clauses $p_i\leftrightarrow\left(e_{i-1}\rightarrow\left(l_i\land p_{i+1}\right)\right)$, with $e_0=\top$ and $p_{n+1}=\top$. \toolname{Shatter} also replaces equality variables $e_i$ with ``greater than or equal to'' variables $g_i\equiv\left(\pi_\mathbf{x}\left(x_i\right)\rightarrow x_i\right)$, and relaxes the if and only if clauses for the $p_i$ variables to one way implications. The clauses added by \toolname{Shatter} are then the CNF equivalents of formulas of the form $p_i\rightarrow\left(g_{i-1}\rightarrow l_i\land p_{i+1}\right)$, with $g_0=\top$. It is easy to see these relaxations introduce satisfying assignments that do not satisfy the original symmetry breaking formulation. To get a better feel of how much of a ``blow-up'' in the number of satisfying assignments does this relaxation cause, consider the following lemmas about extensions of partial assignments of the Boolean expressions involved in these two formulations of symmetry breaking clauses. $S_k$ in Lemma~\ref{l:originalmodelcount} corresponds to the original lexicographical symmetry breaking clauses with chaining, while $T_k$ in Lemma~\ref{l:shattermodelcount} corresponds to the clauses added by Shatter.

\begin{lemma}
\label{l:originalmodelcount}
 Let $S_k=e_0\land\bigwedge\limits_{i=1}^{k}\left(p_i\leftrightarrow\left(e_{i-1}\rightarrow\left(l_i\land p_{i+1}\right)\right)\right)\land p_{k+1}$. Then a partial assignment of the variables $e_i$ and $l_i$ has at most one extension that satisfies $S_k$.
\end{lemma}

\begin{proof}
Let $S'_k=e_0\land\bigwedge\limits_{i=1}^{k}\left(p_i\leftrightarrow\left(e_{i-1}\rightarrow\left(l_i\land p_{i+1}\right)\right)\right)$, that is, $S'_k$ is $S_k$ without fixing $p_{k+1}$. Then $S_k=S'_k\land p_{k+1}$. We first prove by induction in $k$ that a partial assignment of the variables $e_i$ and $l_i$ has at most one extension that satisfies $S_k'$ once $p_{k+1}$ is assigned to a value. For $k=0$, this is trivially true since the value of $S'_0=e_0$ does not depend on the value of $p_1$. We now assume that this property holds for $S'_n$ and prove it for $S'_{n+1}$. Our induction hypothesis implies that for any assignment of the variables $e_i$ and $l_i$ for $i\leq n$, there is at most one assignment of the variables $p_i$, $i\leq n$ that satisfies $S'_n$ once $p_{n+1}$ is assigned to a value. Suppose we assign $p_{n+2}$ to a value, then since $p_{n+1}\leftrightarrow \left(e_{n-1}\rightarrow l_n\land p_{n+1}\right)$ is a subformula of $S'_{n+1}$ so $p_{n+1}$ is uniquely determined by the assignments of $e_{n-1}$, $l_n$ and $p_{n+2}$, which proves our claim. Since $S_k=S_k'\land p_{k+1}$, any satisfying assignment of $S_k$ must fix $p_{n+2}$ to $\top$ and the lemma follows.
\end{proof}

\begin{lemma}
\label{l:shattermodelcount}
 Let $T_k=g_0\land\bigwedge\limits_{i=1}^{k}\left(p_i\rightarrow\left(g_{i-1}\rightarrow\left(l_i\land p_{i+1}\right)\right)\right)\land p_{k+1}$. Let $\phi$ be a partial assignment that assigns the $m$ variables $g_i,g_{i+1},\ldots,g_{i+m-1}$ to $\bot$. Then, if $\phi$ can be extended to an assignment that satisfies $T_k$, it can be extended to at least $2^{m}-1$ assignments that satisfy $T_k$.
\end{lemma}

\begin{proof}
Since $\phi$ assigns $g_i$ to $\bot$, the subformula $p_{i+1}\rightarrow\left(g_i\rightarrow\left(l_{i+1}\land p_{i+2}\right)\right)$ simplifies to $p_{i+1}\rightarrow\top$, regardless of what $l_{i+1}$ and $p_{i+2}$ are assigned to. Then $p_i$ can be assigned to $\bot$ or $\top$ without falsifying $T_k$. Furthermore, $p_{i+1}\rightarrow\left(g_i\rightarrow\left(l_{i+1}\land p_{i+2}\right)\right)$ does not constrain $p_{i+2}$ if $g_i$ is assigned to $\bot$, and $p_{i+2}\rightarrow\left(g_{i+1}\rightarrow\left(l_{i+2}\land p_{i+3}\right)\right)$ simplifies to $p_{i+2}\rightarrow\top$ when $g_{i+1}$ is assigned to $\bot$, so $p_{i+2}$ can be assigned to $\bot$ or $\top$ as well. Following the same reasoning, all the variables $p_{i+1},p_{i+2},\ldots,p_{i+m}$ can be assigned to $\bot$ or $\top$ independently without falsifying $T_k$ except possibly for $p_{i+m}$ if $i+m=k+1$, yielding the desired result.
\end{proof}

The combination of these lemmas means that, in the worst case, the increase in the number of satisfying assignments due to Shatter's relaxations may be exponential in the number of $e_i$ or $g_i$ variables. While in the original lexicographical symmetry breaking formulation the number of $e_i$ variables is the same as the number of variables in the original formula, \toolname{Shatter} reduces the number of variables to consider by eliminating certain tautological subformulas from $T_k$, thus mitigating the effect of the increase in the number of models.

Another important detail in the analysis above is that the ``blow-up'' in the number of models of the formula enhanced with symmetry breaking clauses happens only at the $p_i$ variables: for a fixed assignment of the original variables of $\phi$ there are many possible assignments of the $p_i$ variables that would satisfy the formula output by Shatter. The projective model enumeration technique \cite{gebser:09} in the \toolname{clasp} solver \cite{gebser:12} is particularly useful to nullify this increase in the number of models. This technique allows for outputting models that are different modulo a subset of the variables. Thus combining projective model enumeration with the output of the formula preprocessed by \toolname{Shatter} restores the original goal of symmetry breaking which is reducing the number of satisfying assignments. The subset of variables that one would project to would of course be the original set of variables of the input formula.

In Section \ref{s:conclusions} we point at \toolname{BreakID} \cite{devriendt:16a}, another symmetry breaking tool, which avoids this issue altogether by using the original symmetry breaking predicates without relaxations. This tool is thus more appropriate for \textsc{AllSAT}{} applications where symmetry breaking is needed.

\subsection{An Example: $\phi\left(K_8;C_5,C_5\right)$}
\label{s:example}

To illustrate this issue we provide a concrete example. From finite Ramsey theory, we know that $R\left(C_5,C_5\right)=9$ \cite{chartrand:71}, where $C_5$ is the cycle of length 5 (see also \cite{radziszowski:94} for a comprehensive survey of what is known in finite Ramsey theory). This means that $\phi\left(K_9;C_5,C_5\right)\notin\textsc{SAT}$, but $\phi\left(K_8;C_5,C_5\right)\in\textsc{SAT}$, so we are interested in finding all edge colorings of the complete graph $K_8$ witnessing $R\left(C_5,C_5\right)>8$. $\phi\left(K_8;C_5,C_5\right)$ contains 28 variables (corresponding to $\genfrac{(}{)}{0pt}{}{8}{2}$ edges in $K_8$) and 1344 clauses, and there are 1190 models for that formula. From this information, we know that $\left|\mathcal{C}\left(K_8;C_5,C_5\right)\right|=1190$. After processing this formula with Shatter, the resulting formula with symmetry breaking clauses has 70 variables, 1499 clauses, and 824 models. On the other hand, using our own implementation of the chaining method without the relaxation outputs a formula with 165 variables, 1809 clauses, and 5 models. Using \toolname{nauty} \cite{mckay:14} to reduce any of these sets of colorings to pick just one representative from each equivalence class of colorings under isomorphism, we find that $\left|D\left(\mathcal{C}\left(K_8;C_5,C_5\right)\right)\right|=4$, so the chaining method without the relaxation outputs only one redundant coloring.

\section{Incomplete Sets of Colorings}
\label{s:incompletesets}

Perhaps more concerning than the increase in the number of colorings found by preprocessing the formula $\phi\left(F;G,H\right)$ is the fact that enumerating all models of the result of preprocessing $\phi\left(F;G,H\right)$ with \toolname{Shatter} may not yield a complete (according to our definition in Section~\ref{s:background}) set of colorings. On the other hand, there are parameters $F$, $G$, and $H$ for which preprocessing a formula $\phi\left(F;G,H\right)$ with \toolname{Shatter} does output a Boolean formula whose models can be used to build a complete set of colorings for the given parameters. One example was presented in Section~\ref{s:example}, where we were able to generate $D\left(\mathcal{C}\left(K_8;C_5,C_5\right)\right)$ from the models of $\phi\left(K_8;C_5,C_5\right)$ after preprocessing it with Shatter.

The fact that for certain parameters this method will work and for other parameters it will not warrants an investigation. In this section, we take a closer look at this phenomenon and present a sufficient condition under which a workflow that uses \toolname{Shatter} for symmetry breaking produces incomplete sets of colorings. This condition is the presence of \emph{free variables}, which are variables that do not appear in the CNF formula. This is possible in the context of CNF formulas in the DIMACS format because the specification\footnote{\url{ftp://dimacs.rutgers.edu/pub/challenge/satisfiability/doc/satformat.dvi}} states that ``it is not necessary that every variable appear in the instance.'' We study the effect of free variables in Lemma~\ref{l:freevars} and as an immediate consequence, we state a sufficient condition for $\phi\left(F;G,H\right)$ to produce incomplete sets of colorings in Theorem~\ref{t:incomplete}.

\begin{lemma}
 \label{l:freevars}
 Let $\phi$ be a Boolean formula. Then any satisfying assignment of the formula output by preprocessing $\phi$ with \toolname{Shatter} will assign any free variables in $\phi$ to $\bot$.
\end{lemma}

\begin{proof}
 Let $W$ be the set of free variables in $\phi$. The graph $G_\phi$ generated according to the rules summarized in Section~\ref{s:background} has 2 vertices for each free variable (one for the positive literal and one for the negative literal) and an edge between these two vertices. Then the matching on $2\left|W\right|$ vertices (i.e., the disjoint union of $\left|W\right|$ edges) is an induced subgraph of $G_\phi$. From graph theory, we know that the permutations $\left(x,\overline{x}\right)$ for $x\in W$ are generators of the automorphism group of $G_\phi$ (see, for instance, \cite{white:73}, Theorem 3-11). The rules applied by \toolname{Shatter} will turn these permutations into clauses of the form $\overline{x}\lor\overline{x}$ for $x\in W$, so each variable in $W$ will be assigned to $\bot$.
\end{proof}

The above proof is based on the rules presented in \cite{aloul:06} to generate the symmetry breaking clauses. In practice, version 0.3 of \toolname{Shatter}\footnote{\url{http://www.aloul.net/Tools/shatter/Shatter_Linux_v03.tar.gz}} seems to have an additional rule that assigns each free variable to its own color. This change is effective in eliminating permutations of the type $\left(x_i,x_j\right)\left(\overline{x_i},\overline{x_j}\right)$ for $x_i,x_j\in W$ from the set of generators of the automorphism group of $G_\phi$ (because $x_i$ and $x_j$ will now have different colors), yet it does not eliminate permutations of the type $\left(x,\overline{x}\right)$ which are the culprit of Lemma~\ref{l:freevars}. It is important to highlight the fact that the addition of single-clause variables (a clause $\overline{x}\lor\overline{x}$ is equivalent to $\overline{x}$) is not a flaw in the design of the symmetry breaking clauses in \toolname{Shatter} but a feature, as noted in Section 3  of \cite{aloul:02}. This is because processing permutations this way reflects the fact that free variables in the input formula can be fixed to any Boolean value, in this case $\bot$, which is advantageous when trying to determine the satisfiability of the input formula.

As an immediate consequence of Lemma~\ref{l:freevars}, we have the following theorem.

\begin{theorem}
\label{t:incomplete}
 Let $F$, $G$ and $H$ be graphs and suppose an edge $e\in E\left(F\right)$ does not participate in any subgraph isomorphism from $G$ to $F$ or from $H$ to $F$ (i.e., $e\notin\image\left(\sigma\right)$ for any $\sigma\in\mathcal{S}\left(F,G\right)\cup\mathcal{S}\left(F,H\right)$). Then, if $\mathcal{C}\left(F;G,H\right)$ is not empty, the set of colorings obtained from the models of $\phi\left(F;G,H\right)$ after preprocessing it with \toolname{Shatter} is incomplete.
\end{theorem}

\begin{proof}
 Let $\phi'\left(F;G,H\right)$ be the formula output by preprocessing $\phi\left(F;G,H\right)$ with Shatter. Because $e$ does not participate in any subgraph isomorphism from $G$ to $F$, or from $H$ to $F$, the variable $x_{e}$ is free in $\phi\left(F;G,H\right)$. By Lemma~\ref{l:freevars} it will be assigned to $\bot$ in any model of $\phi'\left(F;G,H\right)$. Let $m$ be a model of the formula $\phi'\left(F;G,H\right)$ and let $m'$ be the assignment obtained from $m$ by assigning $x_{e}$ to $\top$. Because $e$ is free in $\phi\left(F;G,H\right)$, the restriction of $m'$ to the variables of $\phi\left(F;G,H\right)$ (i.e., the restriction of $m'$ to the original variables) is a model of $\phi\left(F;G,H\right)$, but $m'$ itself is not a model $\phi'\left(F;G,H\right)$ thus the coloring corresponding to $m'$ will not be represented in the colorings obtained from the models of $\phi'\left(F;G,H\right)$.
\end{proof}

An obvious modification one can do to avoid this issue is to restrict the set of variables in equation~\ref{e:nonarrowing} in Figure~\ref{f:nonarrowing} to $x_e$ for edges $e\in E\left(F\right)$ that are actually involved in some subgraph isomorphism from $G$ to $F$ or from $H$ to $F$. Unfortunately, this does not guarantee the resulting formula will output a complete set of colorings. There are cases where the models of formulas encoding the non-arrowing property do not generate complete sets of colorings even when the formula does not have free variables. This indicates Theorem~\ref{t:incomplete} is not a necessary condition for this phenomenon to occur. Here we provide an example of such a formula, which is related to the example presented in Section \ref{s:example}: Let $K_{ex}$ be the graph obtained from $K_8$ by selecting one of its vertices and removing all but 2 edges incident to it (alternatively, this graph can be obtained by adding a vertex to $K_7$ and connecting it to two of the original vertices). The resulting graph is illustrated in Figure~\ref{f:notnecessary}. We are interested in obtaining all 2-colorings avoiding monochromatic $C_5$ in any of the colors. It is easy to see that $\phi\left(K_{ex};C_5,C_5\right)$ has no free variables: because the only vertex of degree less than 6 has degree 2, it participates in at least one cycle of length 5. Nevertheless, the models of the formula obtained from preprocessing $\phi\left(K_{ex},C_5,C_5\right)$ with \toolname{Shatter} represent 64 of the 90 possible isomorphism classes in $\mathcal{C}\left(K_{ex};C_5,C_5\right)$.

\begin{figure}
 \centering
 \includegraphics[width=4cm]{notnecessary.pdf}
 \caption{An illustration of the graph $K_{ex}$ in Section \ref{s:incompletesets}. The models of the formula output by \toolname{Shatter} on input $\phi\left(K_{ex};C_5,C_5\right)$ cannot be used to create a complete set of colorings witnessing $K_{ex}\not\rightarrow\left(C_5,C_5\right)$.}
 \label{f:notnecessary}
\end{figure}

\section{Conclusion and Related Work}
\label{s:conclusions}

We looked at the use of \toolname{Shatter}, a popular tool for symmetry breaking of CNF formulas, in the context of \textsc{AllSAT}{} problems. Specifically, we presented and discussed two issues related to applying \toolname{Shatter} to formulas encoding the non-arrowing property. The first issue was related to the number of satisfying assignments, showing that \toolname{Shatter} may incur in an increase in the number of models found. We also mentioned the projective enumeration feature in \toolname{clasp} as a tool to deal with this issue. The second issue we discussed was related to the completeness of the set of colorings generated from the Boolean formula after preprocessing with Shatter. We presented a sufficient condition for the set of colorings obtained this way to be incomplete. A direction for future work in this area is completing this analysis by providing necessary conditions.

While \toolname{Shatter} has been an influential tool in the field of symmetry breaking in Boolean formulas for over a decade, it is not the only tool available as a drop-in addition to existing workflows. Recently, \toolname{BreakID} \cite{devriendt:16a} has built upon the symmetry breaking techniques introduced by \toolname{Shatter} and has added some novel ideas like row interchangeability. Even though \toolname{BreakID} implements the same relaxations as \toolname{Shatter}, it does includes an option to no use these relaxations and is thus better suited for \textsc{AllSAT}{} applications since it will not introduce additional models.

\section*{Acknowledgments}

The author would like to thank Dr. Edith Hemaspaandra and Dr. Stanisław P. Radziszowski at the Rochester Institute of Technology, as well as the anonymous reviewers of the Thirty-Second AAAI Conference on Artificial Intelligence (AAAI-18) for their valuable comments and suggestions for improvements.