Telescoping Sums, Permutations, and First Occurrence Distributions

Abstract: Telescoping sums very naturally lead to probability distributions on ${\mathbb Z}^+$. But are these distributions typically cosmetic and devoid of motivation? In this paper we give three examples of "first occurrence" distributions, each defined by telescoping sums, and that each arise from concrete questions about the structure of permutations.

\section{Telescoping Series}  Telescoping sums are a delight.  While Euler and many others since have  produced magnificent proofs of the fact that
\[\zeta(2)=\sum_{n=1}^\infty\frac{1}{n^2}=\frac{\pi^2}{6},\]
the ``related" telescoping sum
\[\sum_{n=1}^\infty\frac{1}{n(n+1)}=\lr1-\frac{1}{2}\rr+\lr\frac{1}{2}-\frac{1}{3}\rr+\ldots\]
can be easily seen to telescope to 1.  Telescoping sums are also one of the few classes of infinite series for which one can go beyond the somewhat unsatisfactory Calculus 2 assertion that ``this series converges," by exhibiting convergence to a specific real number.  Questions involving telescoping sums are often to be found on the Putnam and other Exams \cite {ga}, where algebraic and trigonometric identities work in tandem with the underlying telescoping nature of the sum to produce stellar formulas for finite and infinite sums.  Telescoping series are those, in fact, for which the sum is revealed through an ``antiderivative" method akin to the one used when employing the Fundamental Theorem of Calculus.  In this note, we study the simplest type of infinite telescoping sum, namely
\begin{equation}\sum_{n=1}^\infty p_n=\sum_{n=1}^\infty (q_n-q_{n+1})=1,\end{equation}
due to our assumptions that $1=q_1\ge q_2\ge q_3\ldots\ge0$ and $\lim_{n\to\infty}q_n=0$.  Now (1) clearly defines a probability distribution on ${\mathbb Z}^+$, but making unmotivated choices such as $q_n=\frac{1}{3n^4-2n^2}$ would serve little purpose, however, so let us state our objective:  We wish to propose three probability distributions that each

(i)  are similar in form to familiar discrete distributions;

(ii) arise from the cycle (\cite{b}) or pattern containment (\cite{b}, \cite{k}) structure or random permutations; and

(iii) lead to open-ended sets of questions.

\noindent Let us go one step further, by asking

(iv) that there be events $A_n,n\ge1$ in some probability space so that $q_n=\p(A_n)$ with $A_{n+1}\subseteq A_n$ so that, as we shall see, $p_n,n\ge 1$ provides a model for {\it first occurrence distributions} of certain events.

The reader should note that discrete models, other than those provided by random permutations, could equally well have been used as launching pads for our discrete distributions, and s/he is invited to  come up with well-motivated first occurrence distributions along the lines of the ones in this paper.

\section{Discrete Distributions on ${\mathbb Z}^+$}  Our motivating distributions on ${\mathbb Z}^+$ are well-known ones that are studied in elementary probability texts such as \cite{r}:  The Zeta, the Poisson, and the Geometric.

The zeta distribution with parameter $k>1$ has associated probability mass function (pmf) given by
\[f(n)=\frac{1}{\zeta(k)}\cdot\frac{1}{n^k}, n=1, 2, \ldots,\]
where $\zeta(k)=\sum_{n=1}^\infty\frac{1}{n^k}$ is the Riemann zeta function.  Early uses of the zeta distribution were by Zipf and Pareto, the latter in the context of income distributions \cite{r}.  For this reason the zeta distribution is also known as the Zipf or discrete Pareto distribution.  In recent years \cite{clv}, the zeta distribution has been referred to as the power law distribution, and been been used to model vertex degrees in ``small world" networks, notably when $k\in(2,3)$.

The Poisson distribution with parameter $\l>0$, denoted by Po($\l$), is the distribution of a random variable $X$ with  pmf
\[f(x)=\frac{e^{-\l}\l^x}{x!}, x=0,1,\ldots.\]
First studied in the context of tallies of Prussian soldiers' deaths per year by kicks from horses, Po($np$) is a wonderful approximation for the Binomial distribution with parameters $n$ and $p$ when $p$ is small -- earning it the moniker of a ``rare event distribution."  The second, equivalent, way that Po($\l$) arises is as the count of events in time or space that satisfy some mild conditions \cite{r}.  It is also known that if $X\sim {\rm Po}(\l)$, then $\e(X)=\v(X)=\l$, and the so-called moment generating function (m.g.f.) of $X$ is
\[M_X(t)=\e\lr e^{tX}\rr=\exp\{\l(e^t-1)\}.\]

The geometric random variable counts the number of independent Bernoulli trials with success probability $p$ that need to be conducted in order to get the first success.  We have, for $x\ge 1$,
\[f(x)=(1-p)^{x-1}\cdot p;\ \e(X)=\frac{1}{p};\ \v(X)=\frac{1-p}{p^2}.\]

\section{Patterns and Cycles in Permutations}  The theory of pattern avoidance in permutations is now well-established and thriving, and a survey of the many results in that area may be found in the text by Kitaev\cite{k}.  One of the earliest and most fundamental results in the field is that the number of permutations of $[n]:=\{1,2,\ldots,n\}$ in which the longest increasing sequence is of length $\le2$, the so-called 123-avoiding permutations, is given by the Catalan numbers $C_n$, which, for $n\ge0$, are given by
\[C_n=\frac{1}{n+1}{{2n}\choose{n}}\sim \frac{C\cdot 4^n}{n^{3/2}}.\] So why are permutations in which the longest increasing sequence is of size 2 or less called 123-avoiding permutations?  Here is the reason:  We say that a permutation $\pi$ contains a subpermutation (usually called a pattern) $\rho$ of length $k$ if there exist indices $i_1<i_2<\ldots<i_k$ such that $\pi(i_1), \pi(i_2), \ldots\pi(i_k)$ are in the same relative order as $\rho$.  For example if $\rho=312$, then $\pi=54213$ contains $\rho$ with $(i_1,i_2,i_3)=(1, 3, 5)$, since $\pi(i_1), \pi(i_2),$ and $ \pi(i_3)$ are the largest, smallest, and middle terms of $\pi(i_1), \pi(i_2), \pi(i_3)$.  If $\pi$ does not contain $\rho$, we say that it {\it avoids} $\rho$.  Classical bijective techniques have been used to show  that the each of the $ijk$-avoiding permutations with $\{i,j,k\}=\{1,2,3\}$ are equinumerous, and, in fact the origins of the theory of pattern avoidance can be traced to the result of Knuth \cite{kn}, who proved that a permutation $\pi\in S_n$ could be sorted with a single stack if and only if it avoided the pattern 231.  The theory of pattern avoidance is now extraordinarily rich, and there is an Annual International Conference devoted to the latest research in the field; see, e.g., {\tt www.etsu.edu/cas/math/pp2014} for the webpage of the latest, twelfth, conference.

In contrast to permutation patterns, the study of the cycle decomposition of a permutation $\pi$ has a longer history; see \cite{b}.  In particular, we recall that any permutation can be decomposed uniquely into cycles, and the elementary Cauchy formula \cite{b} states that for $\sum_{k=1}^nkj_k=n$, the number of permutations on $[n]:=\{1,2,\ldots,n\}$ with $j_k$ cycles of length $k$ is given by
\[\frac{n!}{\prod_{k=1}^nk^{j_k}j_k!}.\]
In particular, there are $(n-1)!$ permutations on $[n]$ that are unicyclic.  Arratia and Tavar\'e \cite{at} contains a distinguished study of the cycle structure of random permutations.

\section{Three New Probability Distributions and Their Properties}

\noindent  1. THE TELESCOPING ZETA(2) DISTRIBUTION: There are $(n-1)!$ permutations on $[n]$ that are unicyclic.  Now if a permutation on $[n+1]$ is unicyclic, then its {\it reduction} to $[n]$ is also unicyclic.  For example, the permutation
\[{123456}\atop{452613},\]
written in ``two line notation," can be reduced, on eliminating the 6 in both the first and second rows and mapping 4 to 3 directly, as the unicyclic 5-permutation
\[{12345}\atop{45231};\]  a general definition of reduction can now be easily formulated.
Let $n\ge 1$ and consider $\pi\in S_{n+1}$.  On setting $A_n$ to be the event that the reduced permutation on $[n]$ is unicyclic, we have that $A_{n+1}\subseteq A_n$, and so $\p(A_n\cap A_{n+1}^C)=\p(A_n)-\p(A_{n+1})$.  It follows that
\[\frac{(n-1)!}{n!}-\frac{n!}{(n+1)!}=\frac{1}{n(n+1)}\]
is the probability that $\pi\in S_{n+1}$ has a unicyclic reduction but we have  $\pi(n+1)=n+1$, so that $\pi$ itself is not unicyclic, and has an $n$ cycle on $[n]$ followed by a 1-cycle on $\{n+1\}$. Given a random permutation in $S_n$, we let $X=1,2,\ldots,n$ be the largest $i\le n$ such that the reduction of $\pi$ to $[i]$ is unicyclic.  We then have
\begin{equation}p_i=\p(X=i)=\frac{1}{i}-\frac{1}{i+1}=\frac{1}{i(i+1)},\ i=1,2,\ldots,n-1,\end{equation}
with \[\p(X=n)=\frac{1}{n}.\]

\medskip

\noindent EXAMPLE:  For $n=4$ the chance $p_4$ that $\pi$ is unicyclic is $\frac{1}{4}$, as evidenced by the six permutations 2341, 2413, 3421, 3142, 4123, and 4312 respectively.  $p_3=\frac{1}{3}-\frac{1}{4}=\frac{1}{12}$, and this fact is verified by the two permutations 2314 and 3124.  The four permutations that yield $p_2=\frac{1}{6}$ are 2134, 2143, 2431, and 4132.  Finally, $p_1=\frac{1}{2}$ due to the twelve permutations 1234, 1243, 1324, 1342, 1423, 1432, 3241, 3214, 3412, 4213, 4231, and 4321.

Given an infinite sequence $X_1,X_2\ldots$ of i.i.d. uniform random variables, for some $n$, a second cycle {\it must} be introduced with probability 1, for some $n$, on the random sequence of order statistics $X_{(1)}<X_{(2)}<\ldots<X_{(n)},$ and we thus get the infinite probability distribution
\begin{equation}p_n=\frac{1}{n}-\frac{1}{n+1}=\frac{1}{n(n+1)}; n\ge 1.\end{equation}  This distribution has infinite mean, however, with $\e(X)\sim \log n$ for a permutation on $[n]$.

A question that we asked ourselves was whether the telescoping zeta distribution could arise via the theory of permutation patterns.  We came up with this scenario:  Returning to Equation (2) (or Equation (3)), we note that the probability distribution there can also be expressed, given a random permutation on $[n]$ and $i\le  n-1$, as
\[\rho_i=p_i=\frac{{n\choose {i+1}}(i-1)!(n-i-1)!}{n!}, 1\le i\le n-1; \rho_n=p_n=\frac{1}{n}\]
whose numerator we can interpret as follows:  (i) Choose any of the $(i-1)!$ unicyclic permutations on $[i]$; (ii) realize them using any of $i+1$ numbers, with the largest occupying the $(i+1)$st spot and the rest in the same relative order as that of the unicyclic permutation; and (iii) Arrange the rest of the numbers in any way possible.  We then have the first $i$ numbers being in an order-isomorphic cyclic form, the first $i+1$ numbers {\it not} yielding a cycle, and the last $n-i-1$ numbers being arbitrary.  But {\it $\rho_i$ does not yield the probability distribution of a random variable, since the various sample outcomes are not disjoint!}
Using $n=4$ as an example again, we find that the numerators of the $\rho$ ratios arise as in Table 1:
\begin{table}[h]
\caption{\label{Table 1.} Can Permutation Patterns give the telescoping zeta distribution?}
\begin{center}
\begin{tabular}{|c|c|c|c|c|c|c|}\hline\hline
$i$ & $\rho_i$ &Sample Points\\ \hline\hline
1 & $\frac{1}{2}$ & 1234, 1243, 1324, 1342, 1432, 1423, 2314, 2341, 2413, 2431, 3412, 3421 \\ \hline
2 & $\frac{1}{6}$ & 2134, 2143, 3142, 3241\\ \hline
3 & $\frac{1}{12}$ & {\bf 2314}, 3124\\ \hline
4 & $\frac{1}{4}$ & {\bf 2341, 2413, 3421, 3142}, 4123, 4312\\ \hline
None & {}& 3214, 4132, 4213, 4231, 4321\\ \hline
\end{tabular}
\end{center}
\end{table}
 We see that even though the sum of the $\rho_i$s is 1, this occurs due to double counting of five sample points and exclusion of five points.  The reader is invited to address this issue, for general values of $n$, as s/he sees fit!

\noindent 2. THE TELESCOPING POISSON DISTRIBUTION:
The probability that a random permutation on $[n]$ has its first ascent at positions $k, k+1$ is given, for $1\le k\le n-1$, by $\frac{k}{(k+1)!}$.  To see this, choose any one of the $k+1$ elements in positions 1 through $k+1$, except for the smallest, to occupy the $k+1$st position, and then arrange the other elements in a monotone decreasing fashion.  But, to reformulate this argument via telescoping series, we let $A_k$ be the event that the permutation restricted to the first $k$ integers is monotone decreasing, note that $A_{k+1}\subseteq A_k$ and that the probability $f(k)$ that the first ascent is at $k, k+1$ satisfies, for $k\le n-1$,
\[f(k)=\p(A_k\cap A_{k+1}^C)=\frac{1}{k!}-\frac{1}{(k+1)!}=\frac{k}{(k+1)!},\] as before.  The chance that the first ascent is at position $n$ is, of course, $\frac{1}{n!}$.  Letting $n\to\infty$, we get the discrete distribution on ${\mathbb Z}^+$ given by
\begin{equation}
f(x)=\frac{x}{(x+1)!}, x=1,2,\ldots,
\end{equation}
which is quite similar to the unit Poisson distribution on 0,1,... with mass function $f(x)=e^{-1}/x!$.
If $X$ is the corresponding first ascent random variable generated, e.g., by a sequence $\{X_n\}_{n=1}^\infty$ of i.i.d.~uniform random variables, then
\begin{eqnarray*}\e(X)&=&\sum_{x=1}^{\infty}x\times \frac{x}{(x+1)!}\\
&=&\sum_{x=1}^{\infty}\frac{1}{(x-1)!}-\sum_{x=1}^{\infty}\frac{1}{x!}+\sum_{x=1}^{\infty}\frac{1}{(x+1)!}\\
&=&e-(e-1)+(e-1-1)\\
&=&e-1,\end{eqnarray*}
and
\begin{eqnarray*}
\v(X)&=&\e(X^2)-(\e(X))^2\\
&=&(e+1)-(e-1)^2\\
&=&e(3-e),
\end{eqnarray*} since
\begin{eqnarray*}\e(X^2)&=&\sum_{x=1}^{\infty}x^2\times \frac{x}{(x+1)!}\\
&=&\sum_{x=2}^{\infty}\frac{1}{(x-2)!}+\sum_{x=1}^{\infty}\frac{x}{(x+1)!}\\
&=&e+1. \end{eqnarray*}
More generally, the m.g.f. of $X$ is given by
\begin{eqnarray*}\e(e^{tX})&=&\sum_{x=1}^{\infty}e^{tx}\times \frac{x}{(x+1)!}\\
&=&\sum_{x=1}^{\infty}\frac{e^{tx}}{x!}-\sum_{x=1}^{\infty}\frac{e^{tx}}{(x+1)!}\\
&=&\sum_{x=1}^{\infty}\frac{e^{tx}}{x!}-\frac{1}{e^t}\sum_{x=1}^{\infty}\frac{{(e^t)}^{x+1}}{(x+1)!}\\
&=&(e^{e^t}-1)-\frac{1}{e^t}(e^{e^t}-1-e^t)\\
&=&e^{-t}(1-e^{e^t}+e^{t+e^t}),
\end{eqnarray*}
compared to the m.g.f. $\exp\{e^t-1\}$ of the unit Poisson r.v.
A one parameter telescoping Poisson model may be defined through the formula
\[f(x)=\frac{\theta^x}{x!}-\frac{\theta^{x+1}}{(x+1)!}, x=0,1,2,\ldots; 0<\theta<1,\]
and justified through the use of monotonicity conditions for size-biased permutations.  The baseline case corresponds to $\theta=1$.  It is routine to verify, using inequalities such as $1-x\le e^{-x}$, that the above mass function assigns lower weight to $x=0$ than does the ${\rm Po}(\theta)$ variable and higher weight for any $x\ge2$.  Moreover, for $x=1$ the Poisson variable has greater mass if and only if $\theta>\ln 2$.  Furthermore, we have for the $\theta$-telescoping Poisson variable $X$,
\begin{eqnarray*}M_X(t)=\e(e^{tX})&=&\sum_{x=0}^{\infty}e^{tx}\times(\frac{\theta^x}{x!}-\frac{\theta^{x+1}}{(x+1)!})\\
&=&\sum_{x=0}^{\infty}\frac{(\theta e^t)^x}{x!}-e^{-t}\sum_{x=0}^{\infty}\frac{(\theta e^t)^{x+1}}{(x+1)!}\\
&=&e^{\theta e^t}(1-e^{-t})+e^{-t},
\end{eqnarray*}
from which it follows that
\[\e(X)=M^\prime(0)=e^{\theta}-1
\]
and
\[\v(X)=(2\theta-1)e^{\theta}+1-(e^{\theta}-1)^2=e^{\theta}(2\theta+1-e^{\theta}).\]
Distribution theory inevitably leads into questions of statistical inference for parametric families.  We  might, for example, ask for an estimate of $\theta$ based on a random sample $X_1,\ldots,X_n$ of size $n$.  It turns out that maximum likelihood estimates (``which value of $\theta$ is most likely to have created this data set?") are mathematically intractable and we have to resort to simulations.  A {\it method of moments} (MOM) estimate can easily be found, however.  Here we equate the sample mean $\bar{X}$ and $\e(X)$ to get $\bar{X}=\e(X)=e^{\theta}-1$, so that $\hat{\theta}=\ln(\bar{X}+1)$, where we must have $\bar{X}<e-1$ since $\theta<1$. But, this is not guaranteed, so we ask what is $\p(\bar{X}<e-1)$? We have
\[\p(\bar{X}<e-1)=\p(\frac{\bar{X}-\mu}{\sigma/\sqrt{n}}<\frac{(e-e^{\theta})\sqrt{n}}{e^{\theta/2}\sqrt{2\theta+1-e^{\theta}}}.\] Defining $k_\theta=\frac{e-e^{\theta}}{e^{\theta/2}\sqrt{2\theta+1-e^{\theta}}}$, we see that $k_\theta>0$ for any $\theta\in(0,1)$. The central limit theorem then implies, with $Z$ denoting the standard normal variable,  that $\p(\bar{X}<e-1)\approx \p(Z<\sqrt{n}k_\theta)\to1$ as $n\to\infty$.  Thus, the MOM estimate is reliable for large sample sizes.  In summary, the MOM estimator can be expressed as
\[ \hat{\theta}_{MOM} = \left\{
  \begin{array}{l l}
    \ln(\bar{X}+1) & \quad \text{if $\ln(\bar{X}+1)<1$}\\
    1 & \quad \text{if $\ln(\bar{X}+1)\geq1$}
  \end{array} \right.\]

\noindent 3. THE TELESCOPING GEOMETRIC DISTRIBUTION: The following is a very natural question:  in how many permutations, in which the longest increasing subsequence is of length 2, does the first ascent occur in positions $k, k+1$? Generalizing the numbers that bore his name, Catalan \cite{cata} proved the $k$-fold Catalan convolution formula
\[C_{n,k}:=\sum_{i_1+\ldots+i_k=n}\prod_{r=1}^kC_{i_r-1}=\frac{k}{2n-k}{{2n-k}\choose{n}},\]  and in \cite{cgg} it was proved that there are precisely $C_{n,k}$ permutations on $[n]$ with longest increasing subsequence of size 2 and for which the first ascent occurs at positions $k,k+1$.    Thus, for a randomly chosen 123-avoiding permutation on $[n]$, the distribution of the location of first ascent is given by
\[f(k)=\frac{C_{n,k}}{C_n}=k\frac{(2n-k-1)!(n+1)!}{(2n)!(n-k)!},\enspace k=1,2,\ldots,n,\]
which, for small $k$ and large $n$, may be approximated by
$f(x)=\frac{k}{2^{k+1}}.$
Accordingly, let us define the telescoping geometric-like distribution on ${\bf Z}^+=1,2,\ldots$ by
\[f(x)=\frac{x}{2^{x+1}}=\frac{x+1}{2^x}-\frac{x+2}{2^{x+1}}, x=1,2,\ldots.\]
We see that for a telescoping geometric random variable $X$,
\begin{eqnarray*}\e(X)&=&\sum_{x=1}^{\infty}x\times \frac{x}{2^{x+1}}\\
&=&\frac{1}{8}\sum_{x=1}^{\infty}x(x-1)\lr\frac{1}{2}\rr^{x-2}+\frac{1}{4}\sum_{x=1}^{\infty}x\lr\frac{1}{2}\rr^{x-1}\\
&=&\frac{1}{8}\times\frac{2}{(1-\frac{1}{2})^3}+\frac{1}{4}\times \frac{1}{(1-\frac{1}{2})^2}\\
&=&3.
\end{eqnarray*}
Together with the result from the previous section, we have, roughly speaking, that for a random permutation on a large $[n]$, we expect the first ascent to be at position $e-1\approx 1.718$, whereas this value increases to 3 for a random 123-avoiding permutation.
Moreover, it makes sense, as with the telescoping Poisson distribution, to define a telescoping $\theta$-analog of the above distribution defined by
\[
f(x)=\frac{(\theta-1)^2x}{\theta^{x+1}}=\frac{(\theta-1)x+1}{\theta^x}-\frac{(\theta-1)(x+1)+1}{\theta^{x+1}}, x=1,2,\dotsc, \theta>1,
\]
and with m.g.f. given by
\begin{eqnarray*}M(t)=\e(e^{tX})&=&\sum_{x=1}^{\infty}e^{tx}\times \frac{(\theta-1)^2x}{\theta^{x+1}}\\
&=&\frac{(\theta-1)^2e^t}{\theta^2}\sum_{x=1}^{\infty}x\lr\frac{e^t}{\theta}\rr^{x-1}\\
&=&\lr\frac{\theta-1}{\theta-e^t}\rr^2\cdot e^t,~\mbox{if}~\frac{e^t}{\theta}<1,~\mbox{i.e., if}~t<\ln\theta.
\end{eqnarray*}

Launching into inference, if $\theta$ is unknown, we can easily find its maximum likelihood estimate (MLE) by computing the likelihood function $\ell(\theta)$ and then maximizing in the standard fashion: \[
\ell(\theta)=\ell(X_1,\ldots,X_n,\theta)=\frac{(\theta-1)^{2n}\prod_{i=1}^{n}X_i}{\theta^{n+\sum_{i=1}^{n}X_i}},
\]
which yields
\[
\frac{\partial\log\ell(\theta)}{\partial\theta}=\frac{2n}{\theta-1}-\frac{n+\sum_{i=1}^{n}X_i}{\theta}.
\]
Setting $\frac{\partial\log\ell(\theta)}{\partial\theta}=0$, we have $$\frac{2n}{\theta-1}=\frac{n+\sum_{i=1}^{n}X_i}{\theta},$$
which yields the unusual MLE $\hat{\theta}=1+\frac{2}{\bar{X}-1}$.
\par For the method of moments estimation, we verify that
\[
\e(X)==M'(0)=\frac{2}{\theta-1}+1,\]
and setting $\bar{X}=\frac{2}{\hat{\theta}-1}+1$, we obtain the same MOM estimator $\hat{\theta}=1+\frac{2}{\bar{X}-1}$ as the MLE.

Finally we complete the standard undergraduate Mathematical Statistics agenda by testing simple hypotheses about $\theta$. Consider the null hypothesis $H_0:\theta=\theta_0$ versus the alternative hypothesis $H_1:\theta=\theta_1$. Assume that $\theta_1>\theta_0$.  By the Neyman Pearson theorem, the most powerful test rejects $H_0$ if the likelihood ratio $\frac{\ell(\theta_1)}{\ell(\theta_0)}>k$, where $k>0$ is a constant.  Below, as is customary, we let $k$ be a generic constant whose value changes from line to line:
Since
\[\frac{\ell(\theta_1)}{\ell(\theta_0)}=\lr\frac{\theta_1-1}{\theta_0-1}\rr^{2n}\lr\frac{\theta_0}{\theta_1}\rr^{n+\sum_{i=1}^{n}X_i},
\]
we reject $H_0$ if $$\lr\frac{\theta_1 -1}{\theta_0 -1}\rr^{2n}\lr\frac{\theta_0}{\theta_1}\rr^{n+\sum_{i=1}^{n}X_i}>k,$$
which simplifies, on taking logs, to
$$\lr n+\sum_{i=1}^{n}X_i\rr\log\lr\frac{\theta_0}{\theta_1}\rr>k.$$
Since $\theta_1>\theta_0$, we turn the above condition into $$n+\sum_{i=1}^{n}X_i<k,$$
or into the compact
$\bar{X}<k$.  $H_0$ is rejected for small values of $\bar{X}$, where the critical value is determined by the level of significance used.

\medskip

\noindent{\bf Summary.}  Telescoping sums very naturally lead to probability distributions on ${\mathbb Z}^+$.  But are these distributions typically cosmetic and devoid of motivation?  In this paper we give three examples of ``first occurrence" distributions, each defined by telescoping sums, and that each arise from concrete questions about the structure of permutations.


Quantum divide and conquer

Abstract: The divide-and-conquer framework, used extensively in classical algorithm design, recursively breaks a problem of size $n$ into smaller subproblems (say, $a$ copies of size $n/b$ each), along with some auxiliary work of cost $C^{\textrm{aux}}(n)$, to give a recurrence relation $$C(n) \leq a \, C(n/b) + C^{\textrm{aux}}(n)$$ for the classical complexity $C(n)$. We describe a quantum divide-and-conquer framework that, in certain cases, yields an analogous recurrence relation $$C_Q(n) \leq \sqrt{a} \, C_Q(n/b) + O(C^{\textrm{aux}}_Q(n))$$ that characterizes the quantum query complexity. We apply this framework to obtain near-optimal quantum query complexities for various string problems, such as (i) recognizing regular languages; (ii) decision versions of String Rotation and String Suffix; and natural parameterized versions of (iii) Longest Increasing Subsequence and (iv) Longest Common Subsequence.

\section{Introduction}
Classically, divide and conquer is a basic algorithmic framework that applies widely to many problems (see, e.g., \cite{quicksort_hoare_1962, multiplication_karatsuba_1963, fourier_cooley_tukey_1965, matrix_strassen_1969, matrix_coppersmith_winograd_1990, algorithms_cormen_2009, matrix_williams_2021}). This technique solves a problem by recursively solving smaller instances of the same problem together with some auxiliary problem.  In this paper, we develop a quantum analog of this framework that can provide quantum query complexity speedups relative to classical computation.

To motivate this investigation, consider a simple application of classical divide and conquer. Consider the problem of computing the $\OR$ function on $n$ bits. The classical deterministic query complexity of this problem is well known to be $n$, since an algorithm must read all $n$ bits in the worst case to check if any of the bits equals $1$. This upper bound is trivial since any query problem on $n$ bits can be solved by querying all $n$ bits, but to illustrate the quantum idea, we first consider re-deriving this classical upper bound using divide and conquer.

It is easy to see that for an $n$-bit string $x$, $\OR(x)=1$ if and only if either $\OR(x_\textrm{left})=1$ or $\OR(x_\textrm{right})=1$, where $x_\textrm{left}$ and $x_\textrm{right}$ are the left and right halves of $x$. Thus we have divided the original problem into two smaller instances of the same problem, and given solutions to the two smaller instances, no further queries need to be made to solve the larger instance. Letting $C(n)$ denote the classical query complexity of this problem, this argument yields the recurrence relation
\begin{equation}
    C(n) \leq 2\, C(n/2),
\end{equation}
which, noting $C(1) = 1$, solves to $C(n)\leq n$, as desired.

Now notice that the last step that combines the solutions of the smaller instances to solve the larger instance is also an $\OR$ function, but on $2$ bits, since $\OR(x)=\OR(x_\textrm{left}) \vee \OR(x_\textrm{right})$. We know that the quantum query complexity of the $\OR$ function on $n$ bits is $O(\sqrt{n})$ due to Grover's algorithm \cite{search_grover_1996}, so we might be tempted to say that the $\OR$ of 2 bits should be faster to compute, potentially even quadratically faster. Thus we might like to write the following recurrence relation for the quantum query complexity $Q(n)$ of computing the $\OR$ function:
\begin{equation}\label{eq:scarequotes}
    Q(n) \leq \text{``$\sqrt{2}$''} \, Q(n/2).
\end{equation}
Here the quotes around the ``$\sqrt{2}$'' convey that this is not really justified. First, the complexity of Grover's algorithm is not exactly $\sqrt{n}$, but only $\sqrt{n}$ up to a constant factor. Even if it were exactly $\sqrt{n}$, Grover's algorithm is a bounded-error algorithm, so if used as a subroutine that calls itself many times, the error will become unbounded very quickly. And of course, it does not make sense to imagine that the query complexity is a non-integer.

Even though we have just argued that \Cref{eq:scarequotes} is questionable, if we solve this recurrence anyway, we find $Q(n) \leq \sqrt{n}$.\footnote{This may be familiar to readers who know the quantum adversary method. However, our divide-and-conquer framework generalizes this phenomenon to a scenario that cannot be captured using adversary machinery alone, as discussed below.} Up to a multiplicative constant, this is the correct answer for the quantum query complexity of the $\OR$ function on $n$ bits!

This is not a coincidence. As we show in this paper, this can be seen as a simple instance of a quantum algorithmic framework that we call ``quantum divide and conquer.'' More generally, a classical divide-and-conquer algorithm typically yields a recurrence relation of the form
\begin{equation}\label{eq:classical_recurrence}
    C(n) \leq a\,C(n/b) + C^{\aux}(n),
\end{equation}
where $C^{\aux}(n)$ is the classical query complexity of the auxiliary problem.

The main conceptual takeaway of our paper is that, in many settings, the quantum query complexity equals (up to a multiplicative constant) the solution, $C_Q(n)$,
of the analogous recurrence relation,
\begin{equation}\label{eq:quantum_recurrence}
    C_Q(n) \leq \sqrt{a} \, C_Q(n/b) + C^{\aux}_Q(n),
\end{equation}
where the quantum query complexity of the auxiliary problem is $O(C^{\aux}_Q(n))$. We show that this framework easily recovers and improves non-trivial quantum speedups that were previously known. Furthermore, we show it yields previously unknown quantum speedups that do not seem to be achievable by standard applications of techniques such as Grover search~\cite{search_grover_1996}, amplitude amplification and estimation~\cite{amplitude_brassard_2002}, and quantum walk search~\cite{qwalk_elem_distictness_ambainis_2007}.

\subsection{Results}

We apply quantum divide and conquer to the following decision problems, which we have ordered in roughly increasing difficulty. In all of these  problems, we are given query access to a string $s\in\Sigma^a$ over some set $\Sigma$, i.e., query access to a function $f\colon \{1,\ldots,a\} \to \Sigma$, with $f(i) = s_i$.

\paragraph{Recognizing regular languages.} We recover the key algorithmic result in \cite{trichotomy_aaronson_2019} that is used to upper bound the quantum query complexity of recognizing star-free languages. (The latter result is, in turn, the key result used by \cite{trichotomy_aaronson_2019} to establish a quantum query complexity trichotomy for recognizing regular languages.) In particular, we show that $O(\sqrt{n\log n})$ quantum queries suffice to decide whether a string $x \in \{0,1,2\}^n$ contains a substring of the form $20^*2$, i.e., two $2$s on either side of an arbitrarily long string of $0$s. Having established our framework, the analysis is simpler than that of \cite{trichotomy_aaronson_2019}.

\paragraph{String Rotation and String Suffix.} Let $x\in \Sigma^n$ and $i\in \{1,\ldots,n\}$. In String Rotation, the problem is to decide whether the lexicographically minimal rotation of $x$ starts at $i$. In String Suffix, the problem is to decide whether the lexicographically minimal suffix of $x$ starts at $i$.
These problems are natural decision versions of problems studied in \cite{string_akmaljin_2022}. We obtain an $\tilde{O}(\sqrt{n})$ upper bound on the quantum query complexity for these problems, improving the previous best bound of $O(n^{1/2+o(1)})$, which follows from the algorithms of \cite{string_akmaljin_2022} for the search versions. Furthermore, the analysis is again simpler using our framework.

\paragraph{$k$-Increasing Subsequence ($k$-IS).} Given a string $x\in \Sigma^n$ over some ordered set $\Sigma$ and an integer $k\geq 1$, the $k$-IS problem asks us to decide whether $x$ has an increasing subsequence\footnote{Recall that a subsequence of a string is obtained by taking a subset of the elements without changing their order. Note that this is more general than a sub\emph{string}, in which the chosen elements must be consecutive.} of length at least $k$. We obtain a bound of $\tilde{O}(\sqrt{n})$ for any constant $k$. The $k$-IS problem is a natural parameterized version of Longest Increasing Subsequence (LIS), which is well-studied classically (see, e.g.,~\cite{lis_fredman_1975, lis_aldous_1999,lis_saks_2010,lcs_lis_rubinstein_2019}). We consider this version because the quantum query complexity of LIS is easily seen to be\footnote{This follows by reduction from a threshold function such as majority \cite{lower_bbcmw_2001}. Given a string $z \in \{0,1\}^n$, define $x \in \{0,1,\ldots,n\}^n$ such that $x_i = i z_i$ for all $i \in \{1,\ldots,n\}$. Then we can determine the Hamming weight $|z|$ of $z$ by classically querying $z_1$ and adding $z_1-1$ to the length of the LIS of $x$.} $\Omega(n)$, so we cannot hope for a quantum speedup without a bound on $k$. Somewhat surprisingly, any constant bound on $k$ allows for a quadratic speedup over classical algorithms.

\paragraph{$k$-Common Subsequence ($k$-CS).} Given two strings $x,y\in \Sigma^n$  over some set $\Sigma$ and integer $k\geq 1$, the $k$-CS problem asks us to decide whether $x$ and $y$ share a common subsequence of length at least $k$. We obtain a bound of $\tilde{O}(n^{2/3})$ for any constant $k$. The $k$-CS problem is a natural parametrized version of Longest Common Subsequence (LCS), which is well-studied classically (see, e.g., \cite{lcs_wagner_1974,lcs_landau_1998,algorithms_cormen_2009,lcs_asymmetric_andoni_2010,lcs_abboud_2015, lcs_lis_rubinstein_2019}). Again, we consider this version because the quantum query complexity of LCS is easily seen to be\footnote{This also follows by reduction from a threshold function such as majority. Given a string $z\in \{0,1\}^n$, define $x=1^n$. Then we can determine the Hamming weight $|z|$ of $z$ as the length of the longest common subsequence of $z$ and $x$.} $\Omega(n)$.

Note that LCS is closely connected to Edit Distance (ED), which asks us to compute the number of insertions, deletions, and substitutions required to convert $x$ into $y$. In fact, if substitutions were disallowed, the edit distance between $x$ and $y$ would equal $\ED(x,y) = 2n - 2\, \LCS(x,y)$ (a proof can be found in, e.g., \cite[Lemma 6]{lcs_akmal_2021}).

\paragraph{}All of our quantum query complexity upper bounds are tight up to logarithmic factors and represent quantum-over-classical speedups since the classical (randomized) query complexities of all problems considered are $\Omega(n)$.

\subsection{Techniques}
\label{sec:techniques}
To derive the quantum recurrence relation in \Cref{eq:quantum_recurrence}, we employ the quantum adversary method as an upper bound on quantum query complexity~\cite{reflections_reichardt_2011,stateconversion_lee_2011}. The adversary quantity $\adv(P(n))$ is a real number that can be associated with any query problem $P(n)$ of size $n$. For convenience, we write $\adv(n) \coloneqq \adv(P(n))$ when $P$ is clear from context. It is well-known that $\adv(n)$ is upper and lower bounded by the (two-sided bounded error) quantum query complexity, $Q(n)$, of $P(n)$ up to multiplicative constants.

If a problem can be expressed as the composition of smaller problems, then the adversary quantity of the larger problem can be expressed in terms of those of the smaller problems~\cite{reflections_reichardt_2011,stateconversion_lee_2011}.
For example, suppose $P(n)$ is the $\OR$ of $a$ copies of $P(n/b)$ together with another problem $P^{\aux}(n)$, corresponding to the auxiliary work performed in a divide-and-conquer algorithm. Then the composition theorem implies
\begin{equation}
    \adv(n)^2 \leq a\, \adv(n/b)^2 + \adv(P^{\aux}(n))^2.
\end{equation}
(For a more precise statement, see~\Cref{sec:framework}.)
Taking square roots\footnote{Note that while taking square roots gives a closer analogy with the classical recurrence, in some cases we can get a slightly tighter bound by instead directly solving the recurrence for $\adv(n)^2$.} and using the fact that $\adv(P^{\aux}(n))$ is bounded by $O(Q^{\aux}(n))$, where $Q^{\aux}(n) \coloneqq Q(P^{\aux}(n))$, we obtain precisely \Cref{eq:quantum_recurrence}, i.e.,
\begin{equation}\label{eq:quantum_recurrence_copy}
    \adv(n) \leq \sqrt{a}\, \adv(n/b) + O(Q^{\aux}(n)).
\end{equation}
We then bound $Q^{\aux}(n)$ by constructing an explicit quantum algorithm for the auxiliary work and bounding its quantum query complexity. Finally, we solve \Cref{eq:quantum_recurrence_copy} either directly or by appealing to the Master Theorem~\cite{master_theorem_bentley_haken_saxe_1980} to obtain a bound on $\adv(n)$ and hence a bound on $Q(n)$. Note that this bound is insensitive (up to a multiplicative constant) to the constant implicit in $O(Q^{\aux}(n))$, whereas it is highly sensitive to the constant in front of $\adv(n/b)$.

We emphasize that the recurrence in \Cref{eq:quantum_recurrence_copy} involves \emph{both} the adversary quantity and the quantum query complexity. At a high level, this is why the bound on $Q(n)$ resulting from solving \Cref{eq:quantum_recurrence_copy} does not follow directly from adversary techniques alone nor from quantum algorithmic techniques alone. Indeed, when we solve \Cref{eq:quantum_recurrence_copy} as a recurrence relation, we mix adversary and algorithmic techniques at each step of the recursion. In principle, it is possible to use \Cref{eq:quantum_recurrence_copy} to construct an explicit quantum algorithm for $P(n)$ because there is a constructive, complexity-preserving, and two-way correspondence between span programs---whose complexity is characterized by the adversary quantity---and quantum algorithms~\cite{span_reichardt_2009,span_cornelissen_2020, span_jeffery_2022}. However, this correspondence is involved.

This quantum divide-and-conquer framework allows us to use \emph{classical} divide-and-conquer thinking to come up with a classical recurrence relation that we can easily convert to a corresponding quantum recurrence relation in the form of \Cref{eq:quantum_recurrence_copy}. Bounding $Q(n)$ then reduces to bounding $Q^{\aux}(n)$, which can be easier than the original problem. In our applications to $k$-IS and $k$-CS, we bound $Q^{\aux}(n)$ by using quantum algorithms for the $i<k$ versions of these problems, whose query complexities we can bound inductively. Note that the base cases ($k=1$) of these problems are trivial, being equivalent to search and (bipartite) element distinctness, respectively.

The form of \Cref{eq:quantum_recurrence_copy} depends on the way we divide and conquer. Strikingly, in our application to $k$-CS, we find that an optimal (up to logarithmic factors) quantum query complexity can be derived by breaking the problem into \emph{seven} parts (so that $b=7$) but not fewer. Classically, the number of parts we break the problem into makes no difference as any choice leads to an $O(n)$ classical query complexity.

In the discussion above, we have assumed that the $\OR$ function relates $P(n)$ to $P(n/b)$ and $P^{\aux}(n)$. However, this is only to simplify our exposition. In fact, we can use quantum divide and conquer for \emph{any} function relating $P(n)$ to $P(n/b)$ and $P^{\aux}(n)$. Functions that we use to obtain quantum speedups include combinations of $\OR$ and $\AND$. In our application of quantum divide and conquer to $k$-CS, the function is a combination of $\SWITCH$ and $\OR$. While $\SWITCH$ alone yields no quantum speedup, our analysis relies on an adversary composition theorem that we prove, which allows us to preserve the speedup yielded by $\OR$. We remark that there are  many other functions that could yield quantum speedups, but which we have not yet considered in applications. Examples include $\EQUAL$ (which decides if the subproblems all return the same answer or not) and $\EXACT$ (which decides if exactly $2$ of $3$ subproblems return $1$)---see \cite[Table 1]{formulas_reichardt_2012}---and their combinations with $\OR$, $\AND$, and $\SWITCH$. We leave the consideration of such functions for future work.

\subsection{Related work}

The technique of using adversary composition theorems (and their relatives) to establish upper bounds on quantum query complexity has been applied in several previous works, beginning with the setting of formula evaluation~\cite{unbalanced_reichardt_2009, formulas_reichardt_2012}. In \cite{adversaryupper_kimmel_2013}, an adversary composition theorem is used to bound the quantum query complexity of a function $f$ given a bound on that of $f$ composed with itself $d$ times. More generally, the adversary quantity has been used to upper bound the quantum query complexity of problems including $k$-distinctness~\cite{kdist_belovs_2012}, triangle finding~\cite{span1_belovs_2012,triangle_lee_2017}, undirected $st$-connectivity~\cite{st_belovs_2012}, and learning symmetric juntas~\cite{juntas_belovs_2014}. In contrast to our work, these prior results typically bound the adversary quantity using only tools from the adversary world, such as span programs, semidefinite programming, and composition theorems, without constructing quantum algorithms to use as subroutines.

The first two application areas of quantum divide and conquer that we consider (recognizing regular languages and String Rotation and String Suffix) arise in \cite{trichotomy_aaronson_2019,string_akmaljin_2022} as discussed above. Turning to $k$-IS and $k$-CS, we first note that, despite the importance of these problems, there have been no significant works on their quantum complexities. Directly using Grover search~\cite{search_grover_1996} over all possible positions of a $1$-witness gives trivial $O(n)$ bounds as soon as $k\geq 2$. Directly using quantum walk search~\cite{qwalk_elem_distictness_ambainis_2007} also yields highly sub-optimal bounds of $O(n^{k/(k+1)})$ for $k$-IS and $O(n^{2k/(2k+1)})$ for $k$-CS.

Classically, LIS and LCS are typically solved using dynamic programming. There are many recent works on quantum speedups for dynamic programming, e.g., \cite{dp_ambainis_2019, dp_abboud_2019, dp_glos_2021,2d_grid_ambainis_2020, dp_klevickis_2022}. The main idea of these works is to \emph{classically} query a part of the input and to repeatedly use the result together with a quantum algorithm to solve many overlapping subproblems. However, we found it difficult to apply this idea to $k$-IS and $k$-CS.

Given the generality of the results in \cite{trichotomy_aaronson_2019} and the fact that we can recover some of its results, one might ask if the converse holds, i.e., if \cite{trichotomy_aaronson_2019} can recover our results on $k$-IS and $k$-CS. Indeed, the results of \cite{trichotomy_aaronson_2019} do apply\footnote{For example, $k$-IS can be expressed in first-order logic as $\bigvee_{a_1 < a_2 < \cdots < a_k} \exists i_1, \ldots, i_k (i_1 < \cdots < i_k) \bigwedge_{j=1}^k \pi_{a_j} (i_j)$ where $\pi_a(i)$ indicates that the $i$th element is $a$. Expressibility in first-order logic is equivalent to being in a star-free language, which can be recognized with quantum query complexity $\tilde{\Theta}(\sqrt{n})$ by \cite{trichotomy_aaronson_2019}.} to $k$-IS and $k$-CS when the set size $|\Sigma|$ is \emph{constant}. However, under that assumption, these problems can be easily solved by Grover search~\cite{search_grover_1996} and quantum minimum finding~\cite{minimum_finding_durr_hoyer_1996} using $O(\sqrt{n})$ queries. Moreover, $k$-CS becomes qualitatively easier when $|\Sigma|$ is constant as its complexity drops to $O(\sqrt{n})$, down from the $\tilde{\Theta}(n^{2/3})$ bound that we establish when $|\Sigma|$ is unbounded. Note that $\tilde{\Theta}(n^{2/3})$ is not in the trichotomy of \cite{trichotomy_aaronson_2019}, i.e., not one of $\Theta(1)$, $\tilde{\Theta}(\sqrt{n})$, or $\Theta(n)$.

\paragraph{Organization.} This paper is organized as follows. We first introduce background material and describe how to use the quantum divide-and-conquer framework for certain scenarios in~\Cref{sec:framework}. Then we apply the framework to four string problems in~\Cref{sec:applns}, obtaining near-optimal quantum query complexities for each. In particular, we consider recognizing regular languages in \Cref{subsec:regular}, String Rotation and String Suffix in \Cref{subsec:stringrot}, $k$-Increasing Subsequence in \Cref{subsec:kis}, and $k$-Common Subsequence in \Cref{subsec:kcs}. Finally, we conclude by presenting some open problems in~\Cref{sec:future}.

\section{Framework}\label{sec:framework}

In this section we introduce some notation and explain how to apply the quantum divide-and-conquer framework in specific scenarios.

Let $\mathbb{N}$ denote the positive integers. We reserve $m, n \in \mathbb{N}$ for positive integers and $\Sigma$ for a finite set. For $m\in \mathbb{N}$, we write $[m]\coloneqq \{1,\ldots,m\}$. For any two matrices $A$ and $B$ of the same size, $A \circ B$ denotes their entrywise product, also known as their Hadamard product. For any matrix $A$, let $(A)_{ij}$ denote the element in the $i$th row and $j$th column. For a function $f\colon D \to E$, let its Gram matrix $F$ be defined as $(F)_{xy} \coloneqq \delta_{f(x),f(y)}$ for all $x,y\in D$, where $\delta$ is the Kronecker delta function. For a length-$n$ string $x \in \Sigma^n$, we write $x[i]$ for the $i$th element of $x$ and $x[i \twodots j]$ for the substring of $x$ that ranges from its $i$th to $j$th elements (inclusive). We write $x(i\twodots j] \coloneqq x[i+1\twodots j]$ and $x[i\twodots j) \coloneqq x[i\twodots j-1]$. When $\Sigma$ is equipped with a total order, and $x\in \Sigma^m$ and $y\in \Sigma^n$, we write inequalities between $x$ and $y$ (e.g., $x\leq y$) to refer to inequalities with respect to the lexicographic order.

We write $Q(f)$ for $Q_{1/3}(f)$ (the quantum query complexity of $f$ with failure probability at most $1/3$).

A closely related quantity that is also used widely, and serves as both a lower and upper bound for the quantum query complexity of function computation, is the adversary quantity, $\adv (\cdot)$.

\begin{Definition}[Adversary quantity]\label{def:adv}
Let $D$, $E$, and $\Sigma$ be finite sets and $n\in \mathbb{N}$ with $D \subseteq \Sigma^n$. Let $f\colon D \to E$ be a function with Gram matrix $F$ and $\Delta = \{\Delta_1, \ldots, \Delta_n\}$ with $(\Delta_j)_{x, y \in D} = 1 - \delta_{x_j,y_j}$. Then the \emph{adversary quantity} for $f$ is
\begin{align*}
    \adv(f) := \max  \Big\{ \norm{\Gamma} : \forall j \in [n], \, \norm{\Gamma \circ \Delta_j} \leq 1 \Big\},
\end{align*}
where the maximization is over $|D| \times |D|$ real, symmetric matrices $\Gamma$ satisfying $\Gamma \circ F = 0$.
\end{Definition}

The following result connecting $\adv(\cdot)$ and $Q(\cdot)$ will be useful.

\begin{Theorem}[\cite{adversary_hoyer_2007,stateconversion_lee_2011}]\label{thm:adv-q}
Let $f\colon D \to E$ be a function. Then $Q(f) = \Theta(\adv(f))$.
\end{Theorem}

The adversary quantity for a composite function can be expressed in terms of the adversary quantities of its components. In this work, we specifically consider cases where (i) $g = f_1 \vee f_2$; (ii) $g = f_1 \wedge f_2$; or (iii) a $\SWITCH$ scenario on functions $f\colon D \to E$ and $\{g_s : D \to \{0, 1\} \mid s \in E\}$ defined as $h \coloneqq (\text{IF } f(x) = s) \text{ THEN } h(x) = g_{s}(x)$ for $s \in E$, $x \in D$.

\begin{restatable}[{Adversary composition for $\OR$ and $\AND$}]{Lemma}{lemAdversaryAndOr}
\label{lem:and-or}
Let $a,b \in \mathbb{N}$ and let $\Sigma$ be a finite set. Let $f_1 \colon \Sigma^a \to \{0,1\}$ and $f_2 \colon \Sigma^b \to \{0,1\}$. Let $g^\wedge, g^\vee \colon \Sigma^a \times \Sigma^b \to \{0,1\}$ be such that $g^\wedge(x,y) = f_1(x) \wedge f_2(y)$ and $g^\vee(x,y) = f_1(x) \vee f_2(y)$. Then $\adv(g^\wedge)^2 = \adv(g^\vee)^2 \leq \adv(f_1)^2 + \adv(f_2)^2$.
\end{restatable}

\Cref{lem:and-or} follows from \cite{stateconversion_lee_2011_v1,reflections_reichardt_2011}. For completeness, we provide a proof in \Cref{app:adv-composition}. Note that the lemma still holds if $f_1$ and $f_2$ share variables.\footnote{For example, if $h\colon \Sigma^a \to \{0,1\}$ with $h(x) \coloneqq g(x,x) = f_1(x) \wedge f_2(x)$, then $\adv(h)^2 \leq \adv(g)^2 \leq \adv(f_1)^2 + \adv(f_2)^2$.}

\begin{restatable}[Adversary composition for $\SWITCH$]{Lemma}{lemAdversarySwitch}\label{lem:adv-switch}
Let $a \in \mathbb{N}$ and let $\Sigma, \Lambda$ be finite sets. Let $f \colon \Sigma^a \to \Lambda$.
For $s\in \Lambda$, let $g_s \colon \Sigma^a \to \{0,1\}$. Define $h \colon \Sigma^a \to \{0,1\}$ by $h(x) = g_{f(x)}(x)$. Then
\begin{equation}
    \adv(h) \leq O(\adv(f)) + \max_{s\in \Lambda} \adv(g_s).
\end{equation}
\end{restatable}

See~\Cref{app:adv-composition} for a proof of \Cref{lem:adv-switch}.

A divide-and-conquer strategy for a problem of size $n$ typically involves dividing the problem into $a$ subproblems on smaller instances of size $n/b$ for $b > 1$ and combining the solutions by solving another auxiliary problem $P^{\aux}$. The classical cost for $P^{\aux}(n)$ is denoted $C^{\aux}(n)$. The classical cost of solving $P(n)$ is then described by the recurrence
\begin{align}
\label{eq:class_rec}
    C(n) \leq a \, C(n/b) + C^{\aux}(n).
\end{align}

The situation is more subtle in the quantum case. \Cref{eq:class_rec} bounds the cost of solving the size-$n$ problem by summing the costs of solving each subproblem and the auxiliary problem. However, our quantum recurrence relations come from adversary composition theorems, which impose restrictions on how the size-$n$ problem decomposes into subproblems and an auxiliary problem.

We consider decision problems that correspond to the computation of a Boolean function $f\colon \Sigma^n \to \{0, 1\}$, where $\Sigma$ is a finite set, and we have oracle access to an input $x\in \Sigma^n$. While the most general form of quantum divide and conquer can compute $f$ by breaking it into sub-functions and an auxiliary function (corresponding to the subproblems and an auxiliary problem) in many different ways, here we focus on two strategies.

\begin{enumerate}[label=\textbf{Strategy \arabic*.},ref=\arabic*,leftmargin=*]
    \item \label[strategy]{itm:strat1} $f$ is computed as an $\ANDOR$ formula involving an auxiliary function $f^{\aux}\colon \Sigma^n \to \{0,1\}$ and sub-functions $\{f_{i}\colon \Sigma^{n/b} \to \{0,1\} \mid i\in [a]\}$, where $a, b \in \mathbb{N}$.
    \item \label[strategy]{itm:strat2} $f$ is computed sequentially as follows: (1) Compute an auxiliary function $f^{\aux}\colon \Sigma^n \to \Lambda$, where $\Lambda$ is a finite set, to obtain some $s \in \Lambda$; (2) $s$ indicates a set of sub-functions $\bigl\{f_i^{(s)}: \Sigma^{n/b}\to \{0,1\} \mid i \in [a]\bigr\}$, where $a,b\in \mathbb{N}$, and a Boolean function $g^{(s)}\colon \{0,1\}^a \to \{0,1\}$, such that $f$ is computed as the function $g^{(s)} \circ \bigl(f_1^{(s)}, \ldots, f_a^{(s)}\bigr)\colon (\Sigma^{n/b})^a \to \{0,1\}$ defined by
    \begin{equation}
        g^{(s)} \circ \bigl(f_1^{(s)}, \ldots, f_a^{(s)}\bigr)(x^{(1)}, \ldots, x^{(a)}) \coloneqq g^{(s)}(f_1^{(s)}(x^{(1)}), \ldots, f_a^{(s)}(x^{(a)})).
    \end{equation}
\end{enumerate}

Using the adversary composition theorems stated previously, the next corollary shows how to obtain quantum recurrence relations for $\adv(f)$ when $f$ is computed  according to \Cref{itm:strat1} or \Cref{itm:strat2}.

\begin{Corollary}[Quantum divide-and-conquer strategies]\label{cor:strategies}
Let $f$, $f^{\aux}$, $\{f_i \mid i \in [a]\}$, $\bigl\{f_i^{(s)} \mid i \in [a], \, s\in \Lambda\bigr\}$, and $\{g^{(s)} \mid s\in \Lambda\}$ be as defined in \Cref{itm:strat1,itm:strat2}. Then
    \begin{alignat}{3}
        &\adv(f)^2 &&\leq \sum_{i=1}^a \adv(f_i)^2 + O\left(Q(f^{\aux})\right)^2 &&\quad \text{for \Cref{itm:strat1}}, \label{eq:strat1}\\
        &\adv(f) &&\leq O\bigl(Q(f^{\aux})\bigr) + \max_{s \in \Lambda} \adv\bigl( g^{(s)} \circ \bigl(f_1^{(s)}, \ldots, f_a^{(s)}\bigr)\bigr) &&\quad \text{for \Cref{itm:strat2}}. \label{eq:strat2}
    \end{alignat}
\end{Corollary}

\begin{proof}
For~\Cref{itm:strat1}, $f^{\aux}$ and $\{f_i \mid i\in [a]\}$ are all Boolean functions and $f$ is computed as an $\ANDOR$ formula of these functions. Therefore, we can directly apply \Cref{lem:and-or} to obtain
\begin{align}
\begin{aligned}
    \adv(f)^2 &\leq \adv(f_1)^2 + \cdots + \adv(f_a)^2 + \adv(f^{\aux})^2 \\
    &\leq \adv(f_1)^2 + \cdots + \adv(f_a)^2 + O(Q(f^{\aux}))^2 && \text{(using \Cref{thm:adv-q})}.
\end{aligned}
\end{align}

For~\Cref{itm:strat2}, $f^{\aux}\colon \Sigma^n \to \Lambda$ is first computed to give an $s\in \Lambda$. Then, $f$ is computed as $g^{(s)} \circ \bigl(f_1^{(s)} \ldots, f_a^{(s)}\bigr)$. Therefore, $f(x)$ can be expressed using $\SWITCH$ as
\begin{equation}
    f(x) = h_{f^{\aux}(x)}(x), \quad \text{where
    $h_s \coloneqq \bigl(g^{(s)} \circ \bigl(f_1^{(s)}, \ldots, f_a^{(s)}\bigr)\bigr)$ for all $s\in \Lambda$}.
\end{equation}
Therefore, we can directly apply \Cref{lem:adv-switch} to obtain
\begin{align}
    \adv(f) & \leq O(\adv(f^{\aux})) + \max_{s \in \Lambda} \adv\bigl(g^{(s)} \circ \bigl(f_1^{(s)}, \ldots, f_a^{(s)}\bigr)\bigr) \\
    & \leq O(Q(f^{\aux})) + \max_{s \in \Lambda} \adv\bigl(g^{(s)} \circ \bigl(f_1^{(s)}, \ldots, f_a^{(s)}\bigr)\bigr) &&\text{(using \Cref{thm:adv-q})}.
\end{align}
The corollary follows.
\end{proof}

While adversary composition theorems play a key role in decomposing the adversary quantity for $f$, one novel aspect of our framework lies in the switching from the adversary quantity $\adv(f^{\aux})$ to the quantum query complexity $Q(f^{\aux})$ when handling the auxiliary function. This switching means our framework employs both the adversary and quantum algorithms toolboxes.

We recall a few well-known quantum query complexity bounds that are used in subsequent sections, usually to bound the quantum query complexity of the auxiliary function $f^{\aux}$.

\begin{Theorem}[Quantum query complexity bounds]\label{thm:algorithms}
\label{thm:query-bounds}
Let $m, n \in \mathbb{N}$ with $m \leq n$ and consider functions $f\colon \Sigma \to \{0, 1\}$ and $g\colon D \to E$ for finite sets $\Sigma, D, E$.
\begin{itemize}[itemsep=0pt]
\item \emph{Unstructured search.} For the function $f$ with $|\Sigma| = n$, finding an $x$ such that  $f(x) = 1$ has quantum query complexity $O(\sqrt{n})$ \cite{search_grover_1996}.
\item \emph{Minimum finding.} Given an unsorted list $x = \{x_1, \ldots, x_n\}$, the quantum query complexity of finding the minimum (or maximum) element in the list is $O(\sqrt{n})$ \cite{minimum_finding_durr_hoyer_1996}.
\item \emph{String matching.} Given two strings $x, y$ with $|x| = n, |y| = m$, determining if $y$ is a substring of $x$ has quantum query complexity $\tilde{O}(\sqrt{m} + \sqrt{n})$ \cite{exact_string_matching_ramesh_vinay_2003}.
\item \emph{String comparison.} Given two strings $x, y \in \Sigma^n$ for an ordered set $\Sigma$, determining whether $x < y$ has quantum query complexity $O(\sqrt{n})$. This is because the problem reduces to minimum finding.
\item \emph{Bipartite element distinctness.} Given two strings $x, y$ such that $|x| = n, |y| = m$, and $m\leq n$, finding $i \in [n]$ and $j \in [m]$ such that $x_i = y_j$ has quantum query complexity $O(n^{2/3})$ \cite{qwalk_elem_distictness_ambainis_2007}.
\end{itemize}
\end{Theorem}

Finally, once we have the quantum recurrence relation for a problem along with a bound on the quantum query complexity of $f^{\aux}$, we use the Master Theorem to solve the recurrence to bound $\adv(f)$, and thereby $Q(f)$. This is just like in classical divide and conquer.

We state the Master Theorem below for convenience.
\begin{Theorem}[Master Theorem \cite{master_theorem_bentley_haken_saxe_1980}]\label{lemma:master_theorem}
Let $A\colon \mathbb{N} \to \mathbb{R}$, $a,b,c>0$, and $p\geq 0$. Suppose $A$ satisfies the recurrence
\begin{equation}
    A(n) = a \, A(n/b) + O(n^c\log^{p} n).
\end{equation}
Then
\begin{align}
    A(n) = \begin{cases}
  O(n^{\log_b{a}}) & \text{if $\log_b{a} > c$}, \\
  O(n^{\log_b{a}} \log^{p+1} n) & \text{if $\log_b{a} = c$}, \\
  O(n^{c} \log^{p} n) & \text{if $\log_b{a} < c$}.
\end{cases}
\end{align}
\end{Theorem}

\section{Applications}
\label{sec:applns}

In this section we apply the divide-and-conquer strategies described previously to various string problems. Note that we divide a problem on strings of length $n$ into subproblems on strings of length $n/b$ for $b > 1$. Without loss of generality, we assume that $n = b^r$ for some $r \in \mathbb{N}$ so that $n/b^k \in \mathbb{N}$ for all $k\in [r]$.\footnote{When $n\neq b^r$, we can divide into subproblems of sizes $\ceil{n/b}$ or $\floor{n/b}$ without affecting the validity of our arguments.}

\subsection{Recognizing regular languages}
\label{subsec:regular}

We first consider the problem of recognizing regular languages to demonstrate how quantum divide and conquer allows one to prove \cite[Theorem 18]{trichotomy_aaronson_2019}, without needing the intricacies of the original proof. In the following, we prove a special case of this result, mentioned in the abstract of \cite{trichotomy_aaronson_2019}, that captures its essence. We do not prove \cite[Theorem 18]{trichotomy_aaronson_2019} in its full generality only because that would require introducing significant terminology related to regular languages but would not offer further insight. Let $\Sigma = \{0,1,2\}$.
\begin{Problem*}[Recognizing $\Sigma^*20^*2\Sigma^*$]
Given query access to a string $x\in \Sigma^n$, decide if $x\in \Sigma^*20^*2\Sigma^*$, i.e., if $x$ contains a substring with two $2$s on either side of an arbitrarily long string of $0$s.
\end{Problem*}

\begin{Theorem}
The quantum query complexity of Recognizing $\Sigma^*20^*2\Sigma^*$ is $O(\sqrt{n\log(n)})$.
\end{Theorem}

\begin{proof}
We upper bound the quantum query complexity of the function $f_n\colon \{0,1,2\}^n \to \{0,1\}$ defined by $f_n(x) = 1$ iff $x\in \Sigma^* 2 0^* 2 \Sigma^*$.

Clearly, $x$ contains the expression $2 0^* 2$ if and only if the expression is contained (i) entirely in the left half of the string; or (ii) entirely in the right half of the string; or (iii) it is partly contained in the left half and partly in the right half of the string. Therefore, we have
\begin{equation}\label{eq:regular_recurrence}
    f_n(x) = f_{n/2}(x_\text{left}) \vee f_{n/2}(x_\text{right}) \vee g_n(x),
\end{equation}
where $g_n\colon \Sigma^n \to \{0,1\}$ is defined by
\begin{equation}
    g_n(x) = \begin{cases}
    1 & \text{if $x[i \twodots j]$ is of the form $20^*2$ for some $i \leq n/2 < j$,}\\
    0 & \text{otherwise.}
    \end{cases}
\end{equation}

Clearly, $g_n$ can be decided by the following algorithm using $O(\sqrt{n})$ queries:
\begin{defaultenumerate}
    \item Grover search for the maximal index $i \leq n/2$ such that $x_i=2$ and the minimal index $j > n/2$ such that $x_j = 2$. If either fails to exist, output $0$.
    \item Decide whether $x[i+1 \twodots j-1]$ equals $0^{j-i-1}$ by Grover search. Output $1$ if yes and $0$ if no.
\end{defaultenumerate}

Therefore, writing $a(n) \coloneqq \adv(f_n)$, observing that \Cref{eq:regular_recurrence} follows~\Cref{itm:strat1} and using \Cref{cor:strategies} gives $a(n)^2 \leq 2a(n/2)^2 + O(n)$, which solves to $a(n)^2 = O(n\log(n))$ by the Master Theorem (\cref{lemma:master_theorem}). Hence, $Q(f_n) = O(a(n)) = O(\sqrt{n\log(n)})$ by \Cref{thm:adv-q}.
\end{proof}

\subsection{String Rotation and String Suffix}
\label{subsec:stringrot}
Let $\Sigma$ be equipped with a total order in this subsection. We consider the following problems.

\begin{Problems*}[String Rotation and String Suffix] Let $n \in \mathbb{N}$ and $i\in [n]$. Given query access to a string $x\in \Sigma^n$, we define the following problems.
\begin{enumerate}
    \item Minimal String Rotation. Decide if $x[i\twodots n]x[1 \twodots i-1] \leq x[j\twodots n]x[1 \twodots j-1]$ for all $j\in [n]$.
    \item Minimal Suffix. Decide if $x[i\twodots n] < x[j\twodots n]$ for all $j\in [n] \setminus \{i\}$.
\end{enumerate}
\end{Problems*}

\begin{Remark*}
These problems are decision versions of the problems studied in \cite{string_akmaljin_2022}, which gives algorithms that output the positions of the minimal string rotation and minimal suffix.
\end{Remark*}

As observed in \cite{string_akmaljin_2022}, both problems reduce to the following problem.

\begin{Problem*}[Minimal Length-$l$ Substring] Let $n, l \in \mathbb{N}$ with $l\leq n$. Given query access to strings $x\in \Sigma^n$ and $y\in \Sigma^l$, decide if all length-$l$ substrings of $x$ are lexicographically at least $y$.
\end{Problem*}

We prove the following lemma by quantum divide and conquer.

\begin{Lemma}\label{lem:minimal_length_l}
The quantum query complexity of Minimal Length-$l$ Substring with $l=n/2$ is $\tilde{O}(\sqrt{n})$.
\end{Lemma}

\begin{proof}
We upper bound the quantum query complexity of the function $f_n \colon \Sigma^n\times \Sigma^{n/2} \to \{0,1\}$ defined by $f_n(x,y) = 1$ iff all length-$(n/2)$ substrings of $x$ are lexicographically at least $y$.

Observe that $f_n(x,y) = 1$ if and only if (a) all length-$(n/4)$ substrings contained in $x[1 \twodots \sfrac{3n}{4}]$ are lexicographically at least $y[1 \twodots \sfrac{n}{4}]$; and (b) all length-$(n/2)$ substrings that start with $y[1 \twodots \sfrac{n}{4}]$ are lexicographically at least $y$. Also observe that all length-$(n/4)$ substrings contained in  $x[1 \twodots \sfrac{3n}{4}]$ are either contained in $x[1 \twodots \sfrac{n}{2}]$ or contained in $x[\sfrac{n}{4}+1 \twodots \sfrac{3n}{4}]$. Therefore, we deduce that
\begin{align}\label{eq:lminimal_recurrence}
    f_n(x,y) &= \Bigl(f_{n/2}(x[1\twodots \sfrac{n}{2}], y[1 \twodots \sfrac{n}{4}]) \wedge f_{n/2}(x[\sfrac{n}{4}+1 \twodots \sfrac{3n}{4}], y[1 \twodots \sfrac{n}{4}])\Bigr) \wedge g_n(x,y),
\end{align}
where $g_n\colon \Sigma^n \times \Sigma^{n/2} \to \{0,1\}$ is defined by
\begin{equation}
\begin{aligned}
    g_n(x,y) &=
    \begin{cases}
    1 &\begin{aligned}[t]
    &\text{if all length-$(n/2)$ substrings in $x$ starting with $y[1 \twodots \sfrac{n}{4}]$}
    \\
    &\text{are lexicographically at least $y$ (or do not exist),}
    \end{aligned}
    \\
    0 &\text{otherwise.}
    \end{cases}
\end{aligned}
\end{equation}

We can show that $Q(g_n) = \tilde{O}(\sqrt{n})$ by considering an algorithm $\mathcal{A}$ described as follows.
\begin{defaultenumerate}
    \item Use the quantum string matching algorithm (see \Cref{thm:algorithms}) to find the \emph{first} and \emph{last} positions where $y[1\twodots \sfrac{n}{4}]$ starts in $x[1\twodots 1 + \sfrac{n}{2}) = x[1\twodots \sfrac{n}{2}]$. Call these two positions $u_1$ and $v_1$, respectively. This takes $\tilde{O}(\sqrt{n})$ queries. Similarly, use the quantum string matching algorithm to find the first and last positions where $y[1\twodots \sfrac{n}{4}]$ starts in $x[\sfrac{n}{4}+1\twodots 1 + \sfrac{3n}{4}) = x[\sfrac{n}{4}+1\twodots \sfrac{3n}{4}]$. Call these two positions $u_2$ and $v_2$, respectively. This takes another $\tilde{O}(\sqrt{n})$ queries.
    \item Use the quantum string comparison algorithm (see \Cref{thm:algorithms}) to decide whether all the length-$(n/2)$ substrings in $x$ starting at one of the positions in $\{u_1,v_1,u_2,v_2\}$ is lexicographically at least $y$. If yes, then output $1$; otherwise, output $0$. This takes $\tilde{O}(\sqrt{n})$ queries.
\end{defaultenumerate}
Clearly, $\mathcal{A}$ uses $\tilde{O}(\sqrt{n})$ queries. The correctness of $\mathcal{A}$ follows from \cite[Lemma 4.8]{string_akmaljin_2022}.\footnote{Set $``l" = n/2$, $``k"=n/4$, and $``a" \in \{1,n/4\}$ in \cite[Lemma 4.8]{string_akmaljin_2022}. We also remark that \cite[Lemma 4.8]{string_akmaljin_2022} is stated with ``\ldots let $J$ denote the set of answers in the Minimal Length-$k$ Substrings problem on the input string $s[a\twodots a+2k)$.'' By examining the proof, it can be seen that the lemma still holds with the quoted sentence replaced by ``\ldots let $y$ denote a fixed length-$k$ substring, let $J$ denote the set of starting points of $y$ in the input string $s[a\twodots a+2k)$.'' This is because \cite[Lemma 2.3]{string_akmaljin_2022} can still be applied in the latter case.}

Now, setting $a(n) \coloneqq \adv(f_n)$, observing that $Q(g_n) = \tilde{O}(\sqrt{n})$, and using~\Cref{cor:strategies} for~\Cref{itm:strat1} gives $a(n)^2 = 2a(n/2)^2 + \tilde{O}(n)$, which solves to $a(n)^2 = \tilde{O}(n)$ by the Master Theorem (\Cref{lemma:master_theorem}). Hence, $Q(f_n) = O(a(n)) = \tilde{O}(\sqrt{n})$ by \Cref{thm:adv-q}.
\end{proof}

\begin{Remark*} The analysis in \cite[Theorem 4.1]{string_akmaljin_2022} for Minimal Length-$l$ Substring would yield a looser bound of $O(n^{1/2+o(1)})$ for its quantum query complexity. That analysis is more involved because it splits the problem into a non-constant number of parts, $m$. This is because quantum algorithms are recursively applied to obtain a recurrence of the form $Q(n) \leq \tilde{O}(\sqrt{m}) \, Q(n/m) + \tilde{O}(\sqrt{mn})$, which, due to the $\tilde{O}(\sqrt{m})$ coefficient in front of the $Q(n/m)$, requires $m$ to be non-constant to solve to $Q(n) = O(n^{1/2+o(1)})$. In general, it can be difficult to split a problem into a non-constant number of parts by only relying on quantum algorithmic techniques (e.g., consider an $\ANDOR$ formula), so such an approach may not yield optimal upper bounds (even up to an $n^{o(1)}$ factor). We note that our analysis above is a quantum analogue of the \emph{classical} divide-and-conquer analysis in \cite[Start of Section~4.2]{string_akmaljin_2022}.
\end{Remark*}

\Cref{thm:rotation_suffix} below follows from \Cref{lem:minimal_length_l} and the chain of reductions described in \cite[Propositions 4.2--4.5 and Theorem 4.6]{string_akmaljin_2022}. We sketch a proof for completeness.

\begin{Theorem}\label{thm:rotation_suffix}
The quantum query complexities of Minimal String Rotation and Minimal Suffix are $\tilde{O}(\sqrt{n})$.
\end{Theorem}

\begin{proof}[Proof sketch]
Let $f_{2n}$ be defined as in the proof of \Cref{lem:minimal_length_l}. The theorem follows from two observations:
\begin{enumerate}
    \item Minimal String Rotation can be computed by $f_{2n}(xx, x[i \twodots n]x[1 \twodots i-1])$.
    \item Minimal Suffix can be computed by $f_{2n}(1x0^{n-1}, x[i \twodots n]0^{i-1})$, where $0$ is defined to be smaller than all elements in $\Sigma$ and $1$ is defined to be larger than all elements in $\Sigma$.\qedhere
\end{enumerate}
\end{proof}

\begin{Remark*}
The quantum query complexities of Maximal String Rotation and Maximal Suffix (defined in the obvious way) are also $\tilde{O}(\sqrt{n})$ because they  easily reduce to Minimal String Rotation and Minimal Suffix.
\end{Remark*}

\subsection{\texorpdfstring{$k$}{k}-Increasing Subsequence}
\label{subsec:kis}

Let $\Sigma$ be equipped with a total order and fix $k$ to be a constant in this subsection. We consider the following problem, which is a natural parametrized version of Longest Increasing Subsequence.

\begin{Problem*}[$k$-IS] Let $n\in \mathbb{N}$. Given query access to $x\in \Sigma^n$, decide if $x$ has a $k$-IS, i.e., if there exist integers $i_1 < i_2 < \cdots < i_k$ such that $x[i_1] < x[i_2] < \cdots < x[i_k]$.
\end{Problem*}

To solve $k$-IS, we solve a variant of it that we call $k$-Increasing Subsequence* ($k$-IS*), defined as follows. We consider  $k$-IS* because it is more susceptible to recursion.

\begin{Problem*}[$k$-IS*] Let $n\in \mathbb{N}$ and let $*$ denote an element outside $\Sigma$. Given query access to $x\in (\Sigma\cup \{*\})^n$, decide if $x$ has a $k$-IS*, i.e., if there exist integers $i_1 < i_2 < \cdots <i_k$ such that $x[i_1] < x[i_2] < \cdots < x[i_k]$ and $x[i_l]\neq *$ for all $l\in [k]$.
\end{Problem*}

We now prove the main theorem of this subsection.

\begin{Theorem}
The quantum query complexities of \textup{$k$-IS} and \textup{$k$-IS*} are both $O(\sqrt{n}\log^{3(k-1)/2}(n))$.
\end{Theorem}

\begin{proof}
Clearly, $k$-IS reduces to $k$-IS* without using additional queries. Therefore, it suffices to prove the theorem for $k$-IS*. We upper bound the quantum query complexity of the function $\LIS_{k,n}\colon \Sigma^n \to \{0,1\}$ defined by $\LIS_{k,n}(x) = 1$ iff $x$ contains a $k$-IS*.

We first introduce some definitions. Define $a_k(n)\coloneqq \adv(\LIS_{k,n})$. Define $\LIS_{(i,j),n}\colon \Sigma^n \to \{0,1\}$ by $\LIS_{(i,j),n}(x) = 1$ if and only if $x$ contains an $(i+j)$-IS* consisting of an $i$-IS*, $u_1 < u_2 < \cdots < u_i$, and a $j$-IS*,  $v_1 < v_2 < \cdots < v_j$, such that $u_i \leq n/2 < v_1$. For $j\in \mathbb{N}$, define $\textsf{min-last}_{j,n}\colon \Sigma^n \to \Sigma$ by $\textsf{min-last}_{j,n}(x) = \min_l x[l]$, where the minimization is over those $l\in [n]$ that are the last index of some $j$-IS* in $x$. Similarly, define $\textsf{max-first}_{j,n}\colon \Sigma^n \to \Sigma$ by $\textsf{max-first}_{j,n}(x) = \max_l x[l]$, where the maximization is over those $l\in [n]$ that are the first index of some $j$-IS* in $x$.

Observe that the increasing subsequence can be (i) contained entirely in the left half of $x$; or (ii) contained entirely in the right half of $x$; or (iii) partially contained in both halves with $i$ elements in the left and $k-i$ elements in the right for some $i \in [k-1]$. Therefore, we have
\begin{equation}
    \LIS_{k,n}(x) =  \LIS_{k,n/2}(x_\text{left}) \vee \LIS_{k,n/2}(x_\text{right}) \vee \bigvee_{i=1}^{k-1} \LIS_{(i,k-i),n}(x).
\end{equation}

Therefore, by \Cref{cor:strategies} for~\Cref{itm:strat1}, we obtain the quantum divide and conquer recurrence
\begin{equation}\label{eq:lis-recurrence}
    a_k(n)^2 \leq 2 a_k(n/2)^2 + \sum_{i=1}^{k-1} O(Q(\LIS_{(i,k-i),n})^2).
\end{equation}

Now,
\begin{equation}\label{eq:lis-combine}
    Q(\LIS_{(i,k-i),n}) \leq Q(\textsf{min-last}_{i,n/2}) +  Q(\textsf{max-first}_{k-i,n/2}),
\end{equation}
because $\LIS_{(i,k-i),n}(x)$ can be computed by computing $\textsf{min-last}_{i,n/2}(x_\text{left})$ and $\textsf{max-first}_{k-i,n/2}(x_\text{right})$ and checking that $\textsf{min-last}_{i,n/2}(x_\text{left})<\textsf{max-first}_{k-i,n/2}(x_\text{right})$.

Moreover, for any $j\in \mathbb{N}$, $\textsf{min-last}_{j,n}$ and $\textsf{max-first}_{j,n}$ can be computed by a ``randomized search'' that uses $O(\log(n))$ computations of $\LIS_{j,n}$ and Grover search, which is similar to the approach taken for quantum minimum finding~\cite{minimum_finding_durr_hoyer_1996}---see~\Cref{app:randomized-reduction} for a proof. Therefore, for all $j,n\in \mathbb{N}$, we can use \cref{thm:adv-q} to obtain
\begin{equation}\label{eq:lis-search}
    Q(\textsf{min-last}_{j,n}), Q(\textsf{max-first}_{j,n}) \leq O((a_j(n) + \sqrt{n}) \log(n)).
\end{equation}

Substituting the combination of \Cref{eq:lis-combine} and \Cref{eq:lis-search} into \Cref{eq:lis-recurrence} shows that, for $k\geq 2$, we have
\begin{equation}\label{eq:lis-recurrence-2}
    a_k(n)^2 \leq 2 a_k(n/2)^2 + O( a_{k-1}(n)^2\log^2(n)),
\end{equation}
where we used the fact that $k$ is constant and $\Omega(\sqrt{n}) \leq a_i(n) \leq O(a_{i+1}(n))$ for all $i\geq 1$, which follows by applying \Cref{thm:adv-q} to the observations that (i) $\LIS_{i,n}(x)= \LIS_{i+1,n+1}(0x)$ for all $x$, where $0\neq *$ is some element smaller than all elements in $\Sigma$, and (ii) computing $\LIS_{1,n}$ is equivalent to searching for a $*$.

Finally, we prove $a_k(n) = O(\sqrt{n}\log^{3(k-1)/2}(n))$ by induction on $k\geq 1$. The base case ($k=1$) follows by applying \Cref{thm:adv-q} to the observation that computing $\LIS_{1,n}$ is equivalent to searching for a $*$. For $k>1$, \Cref{eq:lis-recurrence-2} and the inductive hypothesis for the $(k-1)$-th case give
\begin{equation}\label{eq:lis-recurrence-3}
    a_k(n)^2 \leq 2 a_k(n/2)^2 + O(n\log^{3k-4}(n)),
\end{equation}
which solves to $a_k(n) = O(\sqrt{n}\log^{3(k-1)/2}(n))$, as required. The result follows from \Cref{thm:adv-q}.
\end{proof}

\subsection{\texorpdfstring{$k$}{k}-Common Subsequence}
\label{subsec:kcs}

As our last application, we consider a parameterized version of the Longest Common Subsequence (LCS) problem. We fix $k$ to be a constant in this subsection.

\begin{Problem*}[$k$-CS] Let $n\in \mathbb{N}$. Given query access to strings $x, y\in \Sigma^n$, decide if they share a $k$-common subsequence ($k$-CS), i.e., if there exist integers $i_1<i_2< \cdots <i_k$ and $j_1<j_2< \cdots <j_k$ with $x[i_l]=y[j_l]$ for all $l \in [k]$.
\end{Problem*}

The main theorem of this subsection is the following.

\begin{restatable}{Theorem}{theoremKCSMainClaim}\label{thm:kcs_main_claim}
The quantum query complexity of $k$-CS is $O(n^{2/3} \log^{k-1}(n))$.
\end{restatable}

Define $\LCS_{k,n}\colon \Sigma^n\times \Sigma^n \to \{0,1\}$ by $\LCS_{k,n}(x,y) = 1$ iff $x, y \in \Sigma^n$ share a $k$-CS. When $k = 1$ this problem is equivalent to the (bipartite) Element Distinctness problem \cite{collision_aaronson_shi_2004, qwalk_elem_distictness_ambainis_2007}. Aaronson and Shi showed that the quantum query complexity of Element Distinctness is at least $\Omega(n^{2/3})$ \cite{collision_aaronson_shi_2004}, while Ambainis proved the matching upper bound of $O(n^{2/3})$ \cite{qwalk_elem_distictness_ambainis_2007}. Since Element Distinctness reduces to $k$-CS (by prefixing $k-1$ common elements to the input strings of $k$-CS), we see that our theorem gives a tight bound on the quantum query complexity of $k$-CS up to logarithmic factors.

We start by introducing some terminology. For $x,y \in \Sigma^n$, we say that $(i,j) \in [n] \times [n]$ is a collision of $x$ and $y$ iff $x[i] = y[j]$ (see \Cref{fig:collision_types} for examples).

\begin{figure}[ht!]
\centering
\begin{subfigure}[t]{0.4\textwidth}
    \centering
    \includesvg[scale=0.5]{figures/compatible_collisions.svg}
    \caption{A diagram showing two collisions, $(4,2)$ and $(6,3)$, of some $6$-element strings $x$ and $y$. Since these collisions are compatible, together they form a $2$-CS of $x$ and $y$.}
    \label{subfig:compatible_collisions_a}
\end{subfigure}
\qquad
\begin{subfigure}[t]{0.4\textwidth}
    \centering
    \includesvg[scale=0.5]{figures/crossing_collisions.svg}
    \caption{A diagram showing two collisions, $(1,5)$ and $(2,3)$, of some $6$-element strings $x$ and $y$. As these collisions are incompatible, they cannot both be part of a $k$-CS for any $k$.}
    \label{subfig:compatible_collisions_b}
\end{subfigure}
\caption{Diagrams illustrating collisions of $6$-element strings.}
\label{fig:collision_types}
\end{figure}

We fix some constant $m \in \mathbb{N}$ which we call the splitting factor. Given inputs $x,y\in\Sigma^n$, we consider splitting $x$ and $y$ each into $m$ substrings of size $n/m$. We denote these substrings by
\begin{align}
    x^{(i)} \coloneqq x\left(\frac{i-1}{m}n\twodots \frac{i}{m}n\right] \quad \text{and} \quad y^{(i)} \coloneqq x\left(\frac{i-1}{m}n\twodots \frac{i}{m}n\right] \quad \text{for all $i \in [m]$}.
\end{align}

\begin{Definition}[Subproblems and signatures]
By a \emph{subproblem}, we refer to a tuple $(i,j)\in [m]\times[m]$. By the \emph{$(i,j)$-subproblem of $(x,y)\in \Sigma^n \times \Sigma^n$}, we refer to the tuple $(x^{(i)}, y^{(j)})$. To each $x,y\in \Sigma^n$ we associate an $m^2$-bit signature $\mathbf{s} \in \mathcal{S} \coloneqq \{0,1\}^{m^2}$ such that $\mathbf{s}_{i,j} = 1$ iff there is a collision between $x^{(i)}$ and $y^{(j)}$. Let $\sigma_n \colon \Sigma^n \times \Sigma^n \to \mathcal{S}$ be the function that, given input $(x,y)$, returns its signature.
\end{Definition}

It is clear that the signature can be computed by using Ambainis's algorithm for Element Distinctness~\cite{qwalk_elem_distictness_ambainis_2007} $m^2$ times, once for each subproblem. Since $m$ is a constant, we have the following.

\begin{Lemma}\label{lemma:adv_signature}
The quantum query complexity of $\sigma_n$ satisfies $Q(\sigma_n) = O(n^{2/3})$.
\end{Lemma}

\begin{Definition}[Compatible, relevant, and critical subproblems]\
\begin{enumerate}[(i),topsep=4pt]
    \item We say that two subproblems $(i_1, j_1)$ and $(i_2, j_2)$ are \emph{compatible} if ($i_1 < i_2$ and $j_1 < j_2$) or ($i_1 > i_2$ and $j_1 > j_2$).
    \item Given a signature $\mathbf{s}\in \mathcal{S}$, we say that the $(i,j)$ subproblem is \emph{$\mathbf{s}$-relevant} if $\mathbf{s}_{i,j} = 1$.
    \item Given a signature $\mathbf{s}\in \mathcal{S}$, we say that an $\mathbf{s}$-relevant subproblem $(i,j)$ is \emph{$\mathbf{s}$-critical} if none of the subproblems compatible with $(i,j)$ are $\mathbf{s}$-relevant.
\end{enumerate}
\end{Definition}

Observe that if subproblems $(i_1, j_1)$ and $(i_2, j_2)$ are compatible then, for any $x, y\in \Sigma^n$, the union of any $k_1$-CS of the $(i_1,j_1)$-subproblem of $(x,y)$ and any $k_2$-CS of the $(i_2,j_2)$-subproblem of $(x,y)$ is a $(k_1 + k_2)$-CS of $(x,y)$.
A key intuition of our approach is the following.
Given $x,y\in \Sigma^n$, to decide whether $x,y$ share a $k$-CS using divide and conquer, we might want to consider recursing on the $(i_1, j_1)$-subproblem of $(x,y)$. Assume that we have obtained the signature $\mathbf{s}$ of $(x,y)$, and we find that  subproblem $(i_1, j_1)$ is $\mathbf{s}$-relevant but not $\mathbf{s}$-critical, i.e., there exists an $\mathbf{s}$-relevant subproblem $(i_2, j_2)$ which is compatible with $(i_1, j_1)$. In this setting, finding even a $(k-1)$-CS of the $(i_1, j_1)$-subproblem of $(x,y)$ would suffice to conclude that $\LCS_{k,n}(x,y) = 1$, since the collision in the $(i_2, j_2)$-subproblem of $(x,y)$ can be combined with a $(k-1)$-CS in the $(i_1, j_1)$-subproblem of $(x,y)$ to give a $k$-CS of $(x,y)$. This suggests that we should only recurse on those subproblems that are critical according to the signature of $(x,y)$.

The above discussion motivates the following definition.

\begin{Definition}[Simple and composite $k$-CS]\label{def:simple_composite}
Let $x, y \in \Sigma^n$. We say that a $k$-CS of $(x, y)$ is \emph{simple} if it is also a $k$-CS of $(x^{(i)},y^{(j)})$ for some $i,j \in [m]$. A $k$-CS of $(x,y)$ which is not simple is called \emph{composite}.
\end{Definition}

\begin{figure}[ht!]
\centering
\begin{subfigure}[t]{0.45\textwidth}
    \includesvg[scale=0.55]{figures/simple_witness.svg}
    \caption{A diagram illustrating a $2$-CS of some $9$-element strings $x$ and $y$. When the splitting factor is $3$, this $2$-CS is a simple witness of $\LCS_{2,9}(x,y) = 1$, since it is also a $2$-CS of the $(2,1)$-subproblem of $(x,y)$.}
    \label{subfig:simple_witness}
\end{subfigure}
\hspace{2em}
\begin{subfigure}[t]{0.45\textwidth}
    \includesvg[scale=0.55]{figures/composite_witness.svg}
    \caption{A diagram illustrating a $3$-CS of some $9$-element strings $x$ and $y$. When the splitting factor is $3$, this $3$-CS is a composite witness of $\LCS_{3,9}(x,y) = 1$.}
    \label{subfig:composite_witness}
\end{subfigure}
\caption{Diagrams illustrating simple and composite witnesses for different choices of $k$ with respect to a splitting factor of $m = 3$.}
\label{fig:simple_and_composite_witnesses}
\end{figure}

We define $\LCSC{k}{n}\colon\Sigma^n\times \Sigma^n \to \{0,1\}$ by $\LCSC{k}{n}(x,y) = 1$ iff $x$ and $y$ share a composite $k$-CS (see \Cref{fig:simple_and_composite_witnesses}). Given a signature $\mathbf{s} \in \mathcal{S}$, define $h_{k,n}^{(\mathbf{s})} \colon \Sigma^n \times \Sigma^n \to \{0,1\}$ by $h_{k,n}^{(\mathbf{s})}(x,y) = 1$ iff there exists an $\mathbf{s}$-critical subproblem $(i, j)$ such that the $(i,j)$-subproblem of $(x,y)$ has a $k$-CS.

By the above discussion, we have the following proposition.

\begin{Proposition}\label{lemma:kcs_case_switch}
For all $x,y\in \Sigma^n$, we have
\begin{align}\label{eq:kcs_decomposition}
   \LCS_{k,n}(x,y) = \LCSC{k}{n}(x,y) \lor h_{k,n}^{(\sigma_n(x,y))}(x,y).
\end{align}
\end{Proposition}
\begin{proof}
If $x$ and $y$ do not share a $k$-CS, then both sides of the equation evaluate to false. If $x$ and $y$ share a composite $k$-CS then both sides of the equation evaluate to true.

Consider the remaining case when $x$ and $y$ share a simple $k$-CS but no composite $k$-CS. The left-hand side of \Cref{eq:kcs_decomposition} evaluates to true.  Let $\mathbf{s} \coloneqq \sigma_n(x,y)$ be the signature of $(x,y)$. Then, the right-hand side of \Cref{eq:kcs_decomposition} evaluates to $h_{k,n}^{(\mathbf{s})}(x,y)$. Since $x$ and $y$ share a simple $k$-CS, there exists a $k$-CS of $(x,y)$ which is also a $k$-CS of $(x^{(i)}, y^{(j)})$ for some $\mathbf{s}$-relevant subproblem $(i, j)$. Then $(i,j)$ must also be $\mathbf{s}$-critical, since otherwise there would be an $\mathbf{s}$-relevant subproblem $(i', j')$ compatible with $(i,j)$, which implies that the $(i,j)$- and $(i', j')$-subproblems of $(x,y)$ would together yield a composite $k$-CS of $(x,y)$, contradicting the case we are in. Therefore, $h_{k,n}^{(\mathbf{s})}(x,y)$ also evaluates to true as required.
\end{proof}

Let $a_k(n)$ denote the adversary quantity of $\LCS_{k,n}$. As $Q(\LCS_{k,n}) = \Theta(a_k(n))$ (\cref{thm:adv-q}), we can prove \Cref{thm:kcs_main_claim} by  upper bounding the adversary quantity $a_k(n)$ instead of the quantum query complexity $Q(\LCS_{k,n})$. As a first step we establish upper bounds on the adversary quantities and quantum query complexities of the functions on the right-hand side of \Cref{eq:kcs_decomposition}.

\begin{Lemma}\label{lem:upper_bound_adv_hkns}
For any signature $\mathbf{s}\in \mathcal{S}$, the adversary quantity of the function $h_{k,n}^{(\mathbf{s})}$ satisfies
\begin{align}
    \adv(h_{k,n}^{(\mathbf{s})}) \leq \sqrt{2m-1} \, a_k(n/m).
\end{align}
\end{Lemma}

\begin{Lemma}\label{lem:upper_bound_adv_fknc} The quantum query complexity of $\LCSC{k}{n}$ satisfies
\begin{align}
    Q(\LCSC{k}{n}) \leq O(a_{k-1}(n)\log{n}).
\end{align}
\end{Lemma}

We defer the proofs of \Cref{lem:upper_bound_adv_hkns,lem:upper_bound_adv_fknc} for now, and prove the following lemma assuming these results.

\begin{Lemma}\label{lemma:recurrence_of_kcs_adv}
For $k\geq 2$, the adversary quantity $a_{k}(n)$ of $\LCS_{k,n}$ satisfies the recurrence
\begin{align}
    a_k(n) \leq \sqrt{2m-1}\ a_k(n/m) + O(a_{k-1}(n) \log{n}).
\end{align}
\end{Lemma}
\begin{proof}
Recall that by \Cref{lemma:kcs_case_switch},
\begin{align}
\LCS_{k,n}(x,y) = \LCSC{k}{n}(x,y) \lor h_{k,n}^{(\sigma_n(x,y))}(x,y).
\end{align}
This Boolean expression is an $\OR$ where one of the components, $h_{k,n}$, is a $\SWITCH$ conditioned on the value of the signature function $\sigma_n(x,y)$. This involves both of our strategies discussed in~\Cref{sec:framework}. Therefore, by applying \Cref{cor:strategies},
\begin{align}
    a_k(n) = \adv(\LCS_{k,n}) &\leq O(Q(\LCSC{k}{n})) +
    O(Q(\sigma_n)) +
    \max_{\mathbf{s}\in\mathcal{S}}\{\adv(h_{k,n}^{(\mathbf{s})})\}. \\
    \intertext{By \Cref{lemma:adv_signature,lem:upper_bound_adv_hkns,lem:upper_bound_adv_fknc},}
    a_k(n) &\leq O(a_{k-1}(n)\log{n}) +  O(n^{2/3}) + \sqrt{2m-1} \, a_{k}(n/m) \\
    &\leq \sqrt{2m-1} \, a_{k}(n/m) + O(a_{k-1}(n)\log{n}),
\end{align}
where the last line follows since $a_1(n) \in \Theta(n^{2/3})$, and $a_{k-1}(n) = \Omega(n^{2/3})$ since Element Distinctness reduces to $(k-1)$-CS for $k\geq 2$ by prefixing $k-2$ common elements to the input strings for $(k-1)$-CS.
\end{proof}

The above recurrence allows us to prove our main theorem.
\begin{proof}[Proof of \Cref{thm:kcs_main_claim}]
We proceed by induction on $k\geq 1$. In the base case ($k=1$), the theorem holds since $1$-CS is equivalent to bipartite Element Distinctness, which has quantum query complexity $O(n^{2/3})$ \cite{qwalk_elem_distictness_ambainis_2007}. Assume that $k\geq 2$. By \cref{lemma:recurrence_of_kcs_adv} we have the following recurrence for the adversary quantity of $\LCS_{k,n}$:
\begin{align}
    a_k(n) &\leq \sqrt{2m-1} \, a_{k}(n/m) + O(a_{k-1}(n)\log{n}) \\
    &\leq \sqrt{2m-1} \, a_k(n/m) + O(n^{2/3}\log^{k-1}(n))
\end{align}
where the second inequality follows by our inductive hypothesis, $a_{k-1}(n) \leq O(n^{2/3} \log^{k-2}(n))$. The result follows from the Master Theorem (\Cref{lemma:master_theorem}) provided that $\log_m(\sqrt{2m-1}) < 2/3$. We achieve this by choosing $m = 7$.
\end{proof}

\begin{figure}[ht!]
\centering
\begin{subfigure}[t]{0.4\textwidth}
    \centering
    \includesvg[scale=1.6]{figures/graph_with_maximal_number_of_critical_edges.svg}
    \caption{For a splitting factor of $m = 5$, the maximum number of $\mathbf{s}$-critical subproblems for any signature $\mathbf{s}$ is 9. This diagram illustrates one signature $\mathbf{s}$ that attains this bound. Each edge $(i,j)$ corresponds to an $\mathbf{s}$-critical subproblem.}
    \label{subfig:assoc_graph_extremal_example}
\end{subfigure}
\qquad
\begin{subfigure}[t]{0.4\textwidth}
    \centering
    \includesvg[scale=1.6]{figures/graph_with_maximal_number_of_critical_edges2.svg}
    \caption{For each of the dotted edges $(i,j)$, the above graph already contains a solid edge $(p,q)$ of the same slope, i.e., with $i-j = p-q$. In fact, adding any more edges to the graph on the left will only decrease the number of $\mathbf{s}'$-critical subproblems for the resulting signature $\mathbf{s}'$.}
    \label{subfig:assoc_graph_extremal_example2}
\end{subfigure}
\caption{Diagrams illustrating an example of a signature $\mathbf{s}$ for which the number of $\mathbf{s}$-critical subproblems is maximal. Here, the splitting factor is $m = 5$ and we represent a signature $\mathbf{s}\in \mathcal{S} = \{0,1\}^{m^2}$ by the subgraph of $K_{m,m}$ that has edge $(i,j)$ iff $\mathbf{s}_{i,j} = 1$.}
\label{fig:extremal}
\end{figure}

We now prove \Cref{lem:upper_bound_adv_hkns,lem:upper_bound_adv_fknc}.

\begin{proof}[Proof of \Cref{lem:upper_bound_adv_hkns}.] Fix an arbitrary signature $\mathbf{s}\in \mathcal{S}$. Recall that the function $h_{k,n}^{(\mathbf{s})}(x,y)$ indicates whether there exists an $\mathbf{s}$-critical subproblem $(i,j)$ such that the $(i,j)$-subproblem of $(x,y)$ has a $k$-CS.
Let $R \coloneqq \{(i_l, j_l): l\in[r]\}$ denote the set of $\mathbf{s}$-critical subproblems. Then
\begin{align}
    h_{k,n}^{(\mathbf{s})}(x,y) = \bigvee_{l\in [r]} \LCS_{k, n/m}(x^{(i_l)}, y^{(j_l)}).
\end{align}
By the adversary composition lemma for $\OR$ (\Cref{lem:and-or}),
\begin{align}
    \adv(h_{k,n}^{(\mathbf{s})}) = \sqrt{r} \, a_k(n/m).
\end{align}

To conclude, it suffices to prove that $r \leq 2m-1$. To this end, to each subproblem $(i,j)$ we associate the (signed) slope $i-j$. Observe that there are only $2m-1$ possible slope values, namely $\{0, \pm1, \ldots, \pm (m-1)\}$. Now notice that if two distinct subproblems $(i,j)$ and $(i',j')$ have the same associated slope (i.e., $i-j = i'-j'$), then these subproblems are compatible (see \Cref{fig:extremal}). Therefore, for each slope, there can be at most one subproblem in $R$ since the subproblems in $R$ are $\mathbf{s}$-critical. Therefore, $r \leq 2m-1$.
\end{proof}

\begin{proof}[Proof of \Cref{lem:upper_bound_adv_fknc}.]
Label the vertices in the two parts of the complete bipartite graph $K_{m,m}$ by $u_i$ and $v_i$, respectively, for $i\in[m]$.

To any $k$-common subsequence $S$ of some $x$ and $y$, we assign a subgraph $G_S$ of $K_{m,m}$ that is obtained by removing all edges $(i,j)$ of $K_{m,m}$ for which $S$ does not contain a collision of $x^{(i)}$ and $y^{(j)}$. Then the graph $G_S$ has at least 2 edges if and only if $S$ is a composite $k$-CS; otherwise $G_S$ has a single edge only. We assign positive integer weights to the edges of $G_S$ by letting the weight of the edge $(u_i,v_j)$ be the number of collisions between the substrings $x^{(i)}$ and $y^{(j)}$ that are contained in $S$. Therefore, the total weight of $G_S$ is $k$ for any $k$-CS considered.

\begin{figure}[ht!]
\centering
\begin{subfigure}{0.9\textwidth}
    \centering
    \includesvg[scale=0.55]{figures/schematic_composite_witness_7way_split.svg}
     \caption{A schematic diagram illustrating a $10$-CS of some strings $x$ and $y$. The dotted lines break up the strings $x$ and $y$ into $m=7$ substrings of equal size.}
    \label{subfig:schematic_diagram_of_kcs}
\end{subfigure}\\
\vspace{1em}
\begin{subfigure}{0.9\textwidth}
    \centering
    \includesvg[scale=1.6]{figures/associated_graph.svg}
    \caption{A diagram showing the graph $G_S$ associated with the $10$-CS seen in the above diagram, assuming a splitting factor of $m=7$.}
    \label{subfig:graph_rep_of_kcs}
\end{subfigure}
\caption{Diagrams illustrating a $10$-CS $S$ of some pair of strings, as well as the associated subgraph $G_S$ of the complete bipartite graph $K_{m,m}$. Here, the splitting factor is $m = 7$.}
\label{fig:kcs_graph_representation}
\end{figure}

Placing the vertices of $G_S$ on a square grid (say, $u_i$ on $(i,1)$ and $v_j$ on $(j,0)$ of the Euclidean plane) and drawing the edges as the line segments between the corresponding vertices, we see that by the definition of a $k$-CS, the edges of $G_S$ meet only at vertices in this drawing (i.e., we have a planar embedding, see \Cref{subfig:graph_rep_of_kcs}). This means that we can make the edge set of $G_S$ a totally ordered set, by letting $(u_{i},v_{j}) \preceq (u_{i'},v_{j'})$ iff $i \leq i'$ and $j \leq j'$. Therefore, a unique minimal (i.e., leftmost) edge exists. Let $(u_{i^{*}},v_{j^{*}})$ be this edge. We claim that at least one of $u_{i^*}$ and $v_{j^*}$ has degree 1. To see this, we can assume without loss of generality that $i^* \leq j^*$, as an analogous argument works for the other case. Suppose now that $u_{i^*}$ has a neighbor other than $v_{j^*}$. Denoting this other neighbor by $v_{j'}$, the minimality of the edge $(u_{i^*},v_{j^*})$ implies $j^{*} < j'$. Consider the vertex $v_{j^*}$, and suppose that $v_{j^*}$ has another neighbor $u_{i'}$ for some $i'$ with $i^* < i'$. Observe that in this case the edges $(u_{i^*}, v_{j'})$ and $(u_{i'}, v_{j^*})$ would be crossing in our drawing, contradicting our observation that there exists a planar embedding of $G_S$ (see \Cref{subfig:graph_rep_of_kcs} for an illustration).

To summarize, to any $k$-CS $S$ we associate an edge-weighted undirected subgraph $G_S$ of $K_{m,m}$ that satisfies the following properties:
\begin{enumerate}[(i)]
    \item \label[property]{itm:weight} The weight of the edge $(u_i,v_j)$ in $G_S$ is the number of collisions of $x^{(i)}$ and $y^{(j)}$ that $S$ contains.
    \item \label[property]{itm:2edges} The graph $G_S$ has at least 2 edges if and only if $S$ is a composite $k$-CS.
    \item \label[property]{itm:uniqueleft} There is a unique leftmost edge $(u_{i^*},v_{j^*})$ of $G_S$.
    \item \label[property]{itm:degreeone} The leftmost edge of $G_S$ is such that at least one of the vertices it is incident on has degree 1.
\end{enumerate}

Let $f^{(i, j)}_{k,n}(x,y)$ denote the Boolean function that indicates if $x$ and $y$ have a composite $k$-CS for which $(i,j)$ is the leftmost edge of the associated graph $G_S$. By \Cref{itm:uniqueleft},
\begin{align}
    \LCSC{k}{n}(x,y) = \bigvee_{i,j\in[m]} f^{(i,j)}_{k,n}(x,y).
\end{align}
Therefore, an algorithm that decides $f^{(i,j)}_{k,n}(x,y)$ for every choice of $i,j \in [m]$ can decide $\LCSC{k}{n}(x,y)$. To conclude, we give a quantum algorithm that decides $f_{k,n}^{(i,j)}$ using $O(a_{k-1}(n) \log{n})$ queries, for any $i, j \in [m]$. As there are only $O(1)$ choices of $i,j\in[m]$ to consider (since $m$ is constant), an algorithm that iterates over each of these cases has the same asymptotic complexity.

Let $S$ be a witness of $f_{k,n}^{(i,j)}(x,y) = 1$ for some $i, j \in [m]$ and consider the associated graph $G_S$.
By \Cref{itm:degreeone} above, at least one of the vertices $u_{i}$ and $v_{j}$ has degree $1$ in $G_S$. Suppose that $v_j$ has degree $1$ (the other case can be treated analogously). Then by the properties of $G_S$ we observed earlier, we see that $S$ has the following structure (see \Cref{subfig:schematic_diagram_of_kcs} for an example):
\begin{enumerate}
    \item By \Cref{itm:2edges}, $G_S$ has at least 2 edges. Therefore by \Cref{itm:weight}, the weight  of $(u_i, v_j)$ is some $k_1 < k$.
    Therefore, $S$ contains $k_1 \in [k-1]$ collisions of $x^{(i)}[1\twodots p]$ and $y^{(j)}$, for some index $p \in [n/m]$.
    \item By \Cref{itm:degreeone}, and our assumption that $v_{j}$ has degree 1, $S$ does not contain any collisions between $y^{(j)}$ and any substring $x^{(i')}$ other than $x^{(i)}$. Therefore, none of the remaining $k-k_1$ collisions of $S$ involve $y^{(j)}$. In other words, the remaining $k-k_1$ collisions of $S$ are collisions of $x((\frac{i-1}{m}n + p)\twodots n]$ and $y(\frac{j}{m}n\twodots n]$.
\end{enumerate}
The following quantum query algorithm decides if a witness $S$ of the above structure exists, and returns false otherwise, using $O(a_{k-1}(n) \log{n})$ queries:
\begin{enumerate}
    \item By combining a binary search over the indices of $x^{(i)}$ with a query-optimal quantum algorithm for $k_1$-CS, identify the minimal $p \in [n/m]$ for which $x^{(i)}[1\twodots p]$ and $y^{(j)}$ have a $k_1$-CS. If no such $p$ has been found, return false. This can be done using $O(a_{k_1}(n) \log{n})$ queries.\footnote{Since the quantum algorithm for $k_1$-CS can be erroneous with bounded probability, one might naively expect an additional $\log\log(n)$ factor due to the need for error reduction since the algorithm for $k_1$-CS is called $O(\log(n))$ times in the binary search. However, \cite{noisybinary_feige_1994} shows that the $\log\log(n)$ factor can be removed by performing a variant of binary search.}
    \item Using a query-optimal algorithm for $(k-k_1)$-CS, decide if $x((\frac{i-1}{m}n+p)\twodots n]$ and $y(\frac{j}{m}n\twodots n]$ have a $(k-k_1)$-CS, and return the output. This can be done using $O(a_{k-k_1}(n))$ queries.
\end{enumerate}
As $1 \leq k_1\leq k-1$, and $a_l(\cdot)$ is a non-decreasing\footnote{Recall that $(l-1)$-CS reduces to $l$-CS by prefixing a common element to the input strings of $l$-CS.} function of $l$, the total query complexity of the above algorithm is
\begin{align}
    \oh{a_{k_1}(n)\log{n} + a_{k-k_1}(n)} &\leq \oh{a_{k-1}(n) \log{n}}.
\end{align}

To decide $f_{k,n}^{(i,j)}$, we run the above algorithm for every possible choice of $k_1 \in [k-1]$. Since we arbitrarily assumed it was $v_j$ that had degree 1, we run an analogous algorithm assuming that $u_i$ has degree 1. Overall this does not affect the asymptotic query complexity of deciding $f_{k,n}^{(i,j)}$, which is
\begin{equation}
    Q(f_{k,n}^{(i,j)}) \leq 2(k-1) \cdot O(a_{k-1}(n) \log{n}) \leq O(a_{k-1}(n) \log{n}).
\end{equation}
The lemma follows.
\end{proof}

\section{Open problems}
\label{sec:future}

We conclude by describing some open problems related to possible extensions of this work.

\begin{itemize}
    \item Can we apply quantum divide and conquer to search problems? For example, is there a quantum divide-and-conquer algorithm for minimum finding?
    \item Can we find applications of quantum divide and conquer using generalizations of the two strategies presented in \Cref{sec:framework} (i.e., using combining functions other than $\ANDOR$ formulas and $\SWITCH$, such as those discussed at the end of \Cref{sec:techniques})?
    \item Can we obtain super-quadratic speedups using quantum divide and conquer?
\end{itemize}

\section*{Acknowledgements}

We thank Saeed Seddighin for telling us about the problem of determining the quantum query complexity of $k$-Increasing Subsequence, which became the starting point for this work.

We acknowledge support from the Army Research Office (grant W911NF-20-1-0015); the Department of Energy, Office of Science, Office of Advanced Scientific Computing Research, Accelerated Research in Quantum Computing program; and the National Science Foundation (grants CCF-1813814 and DMR-1747426).

Quantum Physics (quant-ph); Data Structures and Algorithms (cs.DS)

Quantum divide and conquer