% Compile with pdflatex, bibtex, pdflatex, pdflatex (job name: contingency-kostka). \documentclass[11pt,reqno]{amsart} \usepackage[T1]{fontenc} \usepackage{lmodern,amsmath,amssymb,mathtools,booktabs,microtype} \usepackage[letterpaper,hmargin=1.07in,top=0.92in,bottom=0.94in]{geometry} \usepackage[hidelinks]{hyperref} \hypersetup{pdftitle={Counting contingency tables, Kostka numbers, and Littlewood-Richardson coefficients with unary data}} \newtheorem{theorem}{Theorem}[section] \newtheorem{proposition}[theorem]{Proposition} \newtheorem{lemma}[theorem]{Lemma} \theoremstyle{definition} \newtheorem{example}[theorem]{Example} \newcommand{\CT}{\operatorname{T}} \newcommand{\OP}{\operatorname{P}} \newcommand{\N}{\mathbb{Z}_{\geq 0}} \newcommand{\BT}{\operatorname{B}} \newcommand{\shP}{\mathsf{\#P}} \newcommand{\ord}{\mathsf{SetPartition}} \newcommand{\ctu}{\mathsf{ContingencyTable}} \newcommand{\btu}{\mathsf{BinaryTable}} \newcommand{\per}{\operatorname{per}} \newcommand{\red}{\leq_{\mathrm T}^{\mathrm p}} \linespread{1.035} \title[Contingency tables and multiplicities]{Counting contingency tables, Kostka numbers, and Littlewood--Richardson coefficients with unary inputs is $\shP$-complete} % An author and affiliation can be added here. \author{Greta Panova} \address{University of Southern California, Los Angeles, CA} \date{} \begin{document} \begin{abstract} We prove that counting contingency tables with prescribed unary margins is $\shP$-complete under polynomial-time Turing reductions for both cases of tables with nonnegative integer entries and entries in $\{0,1\}$. This proves a Conjecture of Pak and Panova. The methods involve modular arithmetic by repeating margins $p$-times and relating to the SETPARTITION problem. The congruences are proven using symmetric function techniques. We also realize each nonnegative table count as a single rectangular Kostka number, and then as a Littlewood--Richardson coefficient with a rectangular factor. Both coefficient problems are therefore $\shP$-complete for partitions given in unary making Kostka and Littlewood-Richardson coefficients strongly $\shP$-complete. For permutations in one-line notation, computing a Schubert structure constant is consequently $\shP$-hard even when all three permutations are Grassmannian with a common descent. \end{abstract} \maketitle \section{Introduction} Let $\CT(a,b)$ be the number of contingency tables with row sums $a=(a_1,\ldots,a_n)$ and column sums $b=(b_1,\ldots,b_m)$. Dyer, Kannan, and Mount proved that computing $\CT(a,b)$ is $\shP$-complete when the margins are input in binary (so input size is $O(\sum_i \log_2(a_i) + \sum_j \log_2(b_j) )$), even when $n=2$~\cite[Thm.~1]{DKM}. The distinction between binary and unary input already appears in this two-row case. If $a=(r,N-r)$, the first row determines the table, whence \[ \CT(a,b)=[z^r]\prod_{j=1}^{m}(1+z+\cdots+z^{b_j}). \] Truncating each multiplication at degree $r$ gives an exact algorithm polynomial in $m$ and $N$. This is polynomial time for unary margins. Miller and Harrison~\cite{MH} give polynomial-time exact algorithms for both nonnegative and binary tables when the largest column sum is bounded by a constant. They also raise the hardness question for $\{0,1\}$-tables. Pak and Panova conjectured that when the inputs are encoded in unary the computational problem is still $\shP$-complete for nonnegative tables, Kostka numbers, and Littlewood--Richardson coefficients~\cite[\S13.4, items~(1)--(3)]{Pak}, see also~\cite{Pan23}. Pak and Robichaux again describe the table problem as conjectural in 2025~\cite[p.~4]{PR}. Narayanan had proved hardness of both tableau coefficients with binary input~\cite{Narayanan}. Recent manuscripts of OpenAI give an exact uniform sampler for nonnegative tables~\cite{OAISample} and a randomized approximation scheme for counting tables with cell bounds~\cite{OAICount}. Write $\BT(a,b)$ for the number of contingency tables with entries in $\{0,1\}$, which are sometimes confusingly called \emph{binary contingency tables}. The input in both cases consists solely of the two lists of margins. \begin{theorem}\label{thm:main} Computing $\CT(a,b)$ and $\BT(a,b)$ is $\shP$-complete under deterministic polynomial-time Turing reductions when the margins $a=(a_1,\ldots,a_n)$ and $b=(b_1,\ldots,b_n)$ are given in unary. \end{theorem} A binary table is the incidence matrix between the two labeled vertex classes of a simple bipartite graph. Thus Theorem~\ref{thm:main} also proves $\shP$-completeness for counting labeled realizations of a prescribed bipartite degree sequence. The hardness comes from the $0$--$1$ permanent. We encode a perfect matching by assigning indivisible items to labeled bins. Repeating each margin a prime number $p$ of times lets us recover the assignment count modulo $p$ from one exact table count. A row of sum $d$ has generating function $h_d$ for nonnegative tables and $e_d$ for binary tables. A single specialization argument applies to both. The Chinese remainder theorem then recovers the integer assignment count. Here in Sections~\ref{sec:kostka} and~\ref{sec:lr} we show that computing Kostka numbers $K_{\lambda,\mu}$ and Littlewood-Richardson coefficients $c^\lambda_{\mu\nu}$ is $\shP$-complete when the inputs are in unary, namely $\lambda,\mu,\nu$ are given as Young diagrams and the input size is $O(|\lambda|)$. This also shows, see~\ref{sec:schubert}, that computing Schubert structure constants $C^w_{uv}$ is $\shP$-hard where the input is given by the permutations $w,u,v$, a question in~\cite{Pak}. This follows since $C^w_{uv}=c^{\lambda(w)}_{\lambda(u)\lambda(v)}$ when $u,v,w$ are Grassmannian with unique descent at $k$, and $\lambda(w):=(w_k-k,w_{k-1}-k+1,\ldots,w_1-1)$. \section{Tables and ordered set partitions}\label{sec:notation} Write $[k]=\{1,\ldots,k\}$. For $a\in\N^n$ and $b\in\N^m$ of common total $N$, set \[ \mathcal T(a,b)= \left\{ X\in\N^{n\times m} : \sum_j X_{ij}=a_i,\ \sum_i X_{ij}=b_j\right\}, \qquad \CT(a,b)=|\mathcal T(a,b)|. \] $\BT(a,b)$ is defined analogously with the restriction that $X\in\{0,1\}^{n\times m}$. Rows and columns are labeled, including those with equal margins. Unequal totals give zero. Zero margins can be deleted from a table instance, and total zero gives a single table. We therefore use positive margins below. A unary list occupies $O(N+n+m)$ symbols, including separators. For the same positive vectors define the \emph{ordered set partition count} \begin{equation}\label{eq:assignment} \OP(a,b)=\#\left\{ f:[n]\longrightarrow[m]: \sum_{i:\,f(i)=j}a_i=b_j\ \text{for all }j\right\}. \end{equation} This is the ordered set partition problem of Ikenmeyer, Pak, and Panova~\cite[\S3.3]{IPP}. The indices of the items distinguish them even if their weights agree. For example, $\CT((2,2),(1,3))=2$, whereas $\OP((2,2),(1,3))=0$ since neither bin can receive an odd total. For an integer $p\geq 1$, write $a^{[p]}$ for the vector of length $pn$ containing $p$ successive copies of each $a_i$. Thus $(2,3)^{[2]}=(2,2,3,3)$. We use $F\red G$ for a deterministic polynomial-time oracle reduction of a function $F$ to a function $G$. Such a reduction is \emph{nonadaptive} if the query instances can all be constructed before receiving any answers. \section{A congruence for repeated margins}\label{sec:congruence} \begin{theorem}\label{thm:congruence} Let $a,b$ be positive margin vectors of common total $N$, with $n$ row margins. Let $p$ be a prime larger than every $a_i$ and $b_j$. Put \[ T_p=\CT(a^{[p]},b^{[p]}),\qquad B_p=\BT(a^{[p]},b^{[p]}),\qquad A=\prod_{i=1}^n a_i. \] Both counts are divisible by $p^n$, and \begin{equation}\label{eq:transfer} (-1)^n A\,\frac{T_p}{p^n} \ \equiv\ \OP(a,b)\ \equiv\ (-1)^N A\,\frac{B_p}{p^n}\pmod p . \end{equation} \end{theorem} Let $h_d$ and $e_d$ be the complete homogeneous and elementary symmetric functions. In a finite alphabet, $h_d$ is the sum of all monomials of degree $d$, and $e_d$ is the sum of the squarefree ones. For $y=(y_1,\ldots,y_m)$, write $y^{[p]}$ for the alphabet with $p$ copies of each $y_j$. The following specialization accounts for the two signs in~\eqref{eq:transfer}. \begin{lemma}\label{lem:specialization} For $1\le d
0$, every monomial of $g_{a_i}(x^p)$
has an exponent at least $p$. All entries of $\beta$ are smaller than $p$,
so in extracting $[x^\beta]$ the terms from $g_{a_i}(x^p)$ do not contribute and we may replace each $g_{a_i}(x)^p$ by
$pW_{a_i}(x)$. Thus $p^n$ divides $C_p$ and
\begin{equation}\label{eq:divided}
C_p/p^n=[x^\beta]\prod_i W_{a_i}(x).
\end{equation}
Now let $F(x)$ be any integer polynomial symmetric in each block of $p$
variables. Identifying the variables of block $j$ with $y_j$ gives
\begin{equation}\label{eq:specialize}
[x^\beta]F(x)\equiv[y^{p b}]F(y^{[p]})\pmod p .
\end{equation}
Indeed, group monomials with the same multiset of exponents in each block.
If exponent $r$ occurs $k_r$ times in a block, the number of arrangements
in that block is $p!/\prod_r k_r!$. This is divisible by $p$ unless all
$p$ exponents agree. Symmetry gives equal coefficients for all arrangements,
so a contribution survives modulo $p$ only when the exponents in each
block are constant. For block sums $p b_j$, the unique such monomial is
$x^\beta$.
Let $\varepsilon_h(d)=1$ and $\varepsilon_e(d)=(-1)^{d-1}$. By
Lemma~\ref{lem:specialization}, $g_d(y^{[p]})^p/p$ vanishes modulo $p$.
Using the same lemma with $y_j^p$ in place of $y_j$ in the second term
of $W_d$ gives
\[
W_d(y^{[p]})\equiv-\frac{\varepsilon_g(d)}d\sum_j y_j^{p d}\pmod p .
\]
Equations~\eqref{eq:divided} and~\eqref{eq:specialize} now give
\[
\frac{C_p}{p^n}
\equiv\frac{(-1)^n\prod_i\varepsilon_g(a_i)}{A}
[y^{p b}]\prod_i\left(\sum_j y_j^{p a_i}\right)
=\frac{(-1)^n\prod_i\varepsilon_g(a_i)}{A}\,\OP(a,b)\pmod p .
\]
Choosing a term for item $i$ assigns its full weight to bin $j$.
The sign is $(-1)^n$ for $h$ and $(-1)^{n+\sum_i(a_i-1)}=(-1)^N$ for $e$.
\end{proof}
\begin{example}\label{ex:repeated}
For $a=(1,1,2)$ and $b=(2,2)$ there are two assignments, according to
which bin receives the item of weight $2$. For $p=3$ the replicated
table has nine rows and six columns. In six variables, extracting
$[x_1^2\cdots x_6^2]$ from $h_1^6h_2^3$ and $e_1^6e_2^3$ gives
$T_3=1{,}220{,}400$ and $B_3=707{,}400$. The signs in~\eqref{eq:transfer}
differ. Both normalized counts recover the two assignments, since
\[
-2\cdot45{,}200\equiv2\cdot26{,}200\equiv2\pmod 3 .
\]
\end{example}
\section{The complexity reduction}\label{sec:complexity}
For either choice of table oracle the reduction is
\begin{equation}\label{eq:reductions}
\per_{0,1}\ \red\ \ord_{\mathrm{unary}}\ \red\ \mathcal C,
\qquad
\mathcal C\in\{\ctu_{\mathrm{unary}},\btu_{\mathrm{unary}}\}.
\end{equation}
The first step is included to make the source of hardness explicit.
A related construction for higher-dimensional matchings appears
in~\cite[\S4.3]{IPP}.
\begin{proposition}\label{prop:matching}
The $0$--$1$ permanent reduces to counting ordered set partitions of unary weights. A single assignment count suffices.
\end{proposition}
\begin{proof}
View the matrix as the adjacency matrix of a bipartite graph $G=(L,R;E)$ with $q$ vertices in each class, indexed by $[q]$. Its permanent counts perfect matchings. The cases $q=0$ or of an isolated vertex have answers $1$ or $0$, respectively. Otherwise write $e=|E|$ and $d(v)=\deg(v)$.
Make one labeled bin for each edge. At every vertex create $d(v)$ labeled items, of which one is marked. For a radix $B=2e(q+1)+2$, interpret $(c_0,\ldots,c_4)$ as the integer $\sum_{k=0}^4 c_k B^k$. Assign the following weights, where $t=1$ denotes a marked item and $t=0$ an unmarked one.
\[
\begin{array}{ll}
\toprule
\text{Object} & \text{Digits of its weight or bin total}\\
\midrule
\text{Item at left vertex }i &(1,0,i,0,t)\\
\text{Item at right vertex }j &(0,1,0,j,1-t)\\
\text{Bin of edge }(i,j) &(1,1,i,j,1)\\
\bottomrule
\end{array}
\]
The total of each coordinate over all items is less than $B$, so equality of weights in a bin is coordinatewise equality. The first four coordinate sums over all items agree with the bin totals by counting edge incidences. The last coordinate sums to $q+(e-q)=e$ on the item side as well.
The first two coordinates force each bin to receive one left item and one right item. The next two force their vertices to be the endpoints of the edge. The last forces their marks to agree. Thus bins containing marked items form a perfect matching. Given a perfect matching, put the marked items in the corresponding bins and permute each vertex's remaining items arbitrarily among its other incident bins. This gives
\[
\OP(a,b)=\per(G)\prod_{v\in L\cup R}(d(v)-1)! .
\]
The factor is computable in polynomial time. There are $2e$ items and $e$ bins, all of weight less than $B^5$. The unary instance and the exact division therefore both have polynomial bit complexity.
\end{proof}
\begin{proposition}\label{prop:crt}
For $n$ items of total weight $N$, the ordered set partition count is recoverable from $n$ nonadaptive queries to either a nonnegative-table oracle or a binary-table oracle. Each query has unary length $O(N^2\log(2N))$.
\end{proposition}
\begin{proof}
Choose $n$ distinct primes $p>N$. It suffices to sieve through the $(N+n)$th prime. The bound $p_k=O(k\log(2k))$ for the $k$th prime~\cite[Thm.~3]{RosserSchoenfeld} and $n\le N$ show that we can take every $p=O(N\log(2N))$. For each prime, query the chosen oracle on $(a^{[p]},b^{[p]})$. These lists have unary length $O(pN)$, and~\eqref{eq:transfer} gives $\OP(a,b)$ modulo $p$ from the oracle's answer.
There are at most $m^n$ assignments. Since $m\le N$, the product of the chosen primes strictly exceeds $m^n$. The Chinese remainder theorem thus recovers the unique answer in $[0,m^n]$ with $O(n^2N^2)$ many operations from the pre-computed contingency table numbers. All arithmetic is on integers of polynomial bit length. In particular $B_p\le T_p\le(N+1)^{p^2nm}$, since the replicated table has $p^2nm$ entries, each at most $N$.
\end{proof}
\begin{proof}[Proof of Theorem~\ref{thm:main}]
Valiant's theorem gives $\shP$-hardness of the $0$--$1$ permanent~\cite{Valiant}. Composing Propositions~\ref{prop:matching} and~\ref{prop:crt} gives~\eqref{eq:reductions} and proves hardness. For membership in $\shP$, a verifier reads the $nm$ entries in row order, using $\lceil\log_2(N+1)\rceil$ bits per entry for $N>0$. For binary tables it reads one bit per cell. In either case it checks the entry bounds and all margins in polynomial time. Each table has a unique accepted encoding. Total zero and unequal totals are decided directly.
\end{proof}
\section{Rectangular Kostka numbers}\label{sec:kostka}
For a partition $\lambda$ and a weak composition $\eta$ of $|\lambda|$, let
$K_{\lambda,\eta}$ count the semistandard Young tableaux of shape $\lambda$
and content $\eta$. Such a tableau has $\eta_i$ entries equal to $i$, with rows
weakly increasing and columns strictly increasing. Write $\eta^\downarrow$
for the partition obtained by sorting the positive parts of $\eta$.
Symmetry of the Schur function gives
$K_{\lambda,\eta}=K_{\lambda,\eta^\downarrow}$~\cite[\S7.10]{Stanley}. The following construction is due to Kirillov~\cite{Kirillov2001}, we repeat it here for completeness.
\begin{theorem}\label{thm:rectangle}
Let $a=(a_1,\ldots,a_n)$ and $b=(b_1,\ldots,b_m)$ be positive margins
of common total $N$. For the rectangle $R=(N^n)$ and the content
\[
\eta=(b_1,\ldots,b_m, N-a_n,\ldots,N-a_1),
\]
we have $\CT(a,b)=K_{R,\eta^\downarrow}$.
\end{theorem}
\begin{proof}
The matrix Robinson--Schensted--Knuth correspondence~\cite{Knuth}
sends each table bijectively to a pair $(P,Q)$ of the same shape $\rho$,
where $P$ has content $b$ and $Q$ has content $a$.
The diagram $\rho$ has at most $N$ columns since it has $N$ boxes.
It has at most $n$ rows since the columns of $Q$ are strictly increasing.
Represent a tableau by the chain of diagrams formed by its entries at most
$k$, as $k$ increases. Each new label adds a horizontal strip, that is, at
most one box per column. Let $\alpha^k$ be the diagram of entries at most
$k$ in $Q$, and write $h_c(\alpha)$ for column $c$'s height, using zero for
an empty column. Start with the chain for $P$, ending at $\rho$. Append the
diagrams $\gamma^1,\ldots,\gamma^n$ defined by
\[
h_c(\gamma^t)=t+h_c(\alpha^{n-t})
\qquad (1\le c\le N,\quad 0\le t\le n).
\]
These are Young diagrams, with $\gamma^0=\rho$ and $\gamma^n=R$.
From $\gamma^{t-1}$ to $\gamma^t$ a column grows precisely when it did
not grow from $\alpha^{n-t}$ to $\alpha^{n-t+1}$. Thus the appended
strip has size $N-a_{n-t+1}$. The full chain gives a tableau of shape
$R$ and content $\eta$.
Conversely, split such a tableau's chain after its first $m$ labels to recover
$P$. At the $t$th subsequent step each column has height at least $t$,
since only $n-t$ steps remain to reach height $n$. Subtracting $t$ from
every column height of $\gamma^t$ therefore recovers a Young diagram
$\alpha^{n-t}$. In reverse order these diagrams grow by horizontal strips
of sizes $a_1,\ldots,a_n$, recovering $Q$. This inverts the construction.
Sorting the content gives the asserted equality.
\end{proof}
\begin{theorem}\label{thm:kostka-hard}
Computing $K_{\lambda,\mu}$ for partitions given in unary is
$\shP$-complete under deterministic polynomial-time Turing reductions,
even when $\lambda$ is a rectangle.
\end{theorem}
\begin{proof}
By Theorem~\ref{thm:rectangle}, an oracle for rectangular Kostka numbers
evaluates each table count with a single query of the same value. Both
partitions have size $nN\le N^2$, so they can be written in unary in
polynomial time. Hardness follows from Theorem~\ref{thm:main}.
For membership, guess one label per box using a fixed-width binary encoding
and verify the content and the row and column inequalities. With unary input
this takes polynomial time, and each tableau has exactly one accepting encoding.
\end{proof}
\section{Littlewood--Richardson coefficients}\label{sec:lr}
Write $c^\nu_{\alpha,\lambda}$ for the coefficient of $s_\nu$ in
$s_\alpha s_\lambda$. Equivalently, $c^\nu_{\alpha,\lambda}$ is the
coefficient of $s_\lambda$ in the skew Schur function $s_{\nu/\alpha}$.
We spell out the Kostka-to-Littlewood--Richardson reduction
of Narayanan~\cite[Lem.~2]{Narayanan} for an arbitrary number of rows.
\begin{proposition}\label{prop:lr}
Let $\lambda,\mu$ be partitions of $M>0$ and let $r=\ell(\mu)$.
Set $\nu_i=\sum_{j=i}^r\mu_j$ and $\alpha_i=\sum_{j=i+1}^r\mu_j$
for $1\le i\le r$, omitting the final zero in $\alpha$. Then
\[
K_{\lambda,\mu}=c^\nu_{\alpha,\lambda}.
\]
Moreover $|\nu|=\sum_{j=1}^r j\mu_j\le rM$.
\end{proposition}
\begin{proof}
Row $i$ of $\nu/\alpha$ occupies columns $\alpha_i+1,\ldots,\nu_i$.
Since $\alpha_i=\nu_{i+1}$ for $i