\subsection{Answering a comparison}\label{sec:comparison}\label{sec:legal} Algorithm~\ref{alg:compare} gives the comparison procedure. Its main choice is delegated to \texttt{Select}, which encapsulates the key algorithmic result of this paper. \begin{algorithm}[H] \caption{\texttt{Compare}$(A,B)$: answer a comparison query.} \label{alg:overview-compare}\label{alg:compare} \DontPrintSemicolon \KwIn{Distinct item labels $A,B$ and the current adversary state.} \KwOut{An answer $A0$, degree at most $k$, and directed paths of at most $2^{k+1}$ vertices. Algorithm~\ref{alg:select} returns one of the following: \begin{enumerate} \item An answer retaining at least $1/2-1/(100k)$ of $V(D)$. \item A queried coordinate $x$ and a dyadic $c\in(\ell_x,r_x)$ with $f_x(c)>2^k$. \end{enumerate} The calculation is deterministic and uses only the graph and interval bounds within a distance of the queried coordinates depending only on $k$. \end{lemma} \begin{proof} See Appendices~\ref{sec:oracle} and~\ref{app:execution}. \end{proof} \begin{proof}[Proof idea for Lemma~\ref{lem:local-routines}] We sketch the enclosing-interval construction behind \texttt{Select}'s probability estimates. Pass through the vertices in topological order, changing one position at a time. Its permitted range is determined by the stored interval and the neighbors' positions. Split this range into $S$ equal pieces, choose one, and move the position to the same relative point in that piece. For example, choosing the second quarter of $(0,1)$ sends a position $u$ to $(1+u)/4$. Run this procedure on two copies of the position vector, starting one at all lower interval endpoints and the other at all upper endpoints. At each step, use the same piece number in both copies, each within its own permitted range. For the proof, also consider a position vector $X$, initially uniform in $K(D)$. At each update, choose a piece number independently and uniformly, and use it in all three vectors. The update preserves coordinatewise order, so $X$ stays between the two endpoint copies (Figure~\ref{fig:local-enclosure}). It also preserves the uniform distribution on $K(D)$: conditional on the other positions, it sends a uniform position into a uniformly chosen equal piece. This use of enclosing copies is related to sampling algorithms for linear extensions~\cite[Section~4.2]{talvitie-counting}. \begin{center} \begin{minipage}{\linewidth} \captionsetup{hypcap=false} \centering \begin{tikzpicture}[>=Latex,font=\small, enclosure/.style={accent,very thick}, position/.style={circle,fill=ink,inner sep=1.7pt}] \begin{scope} \node at (2.4,1.1) {Before updates}; \foreach \name/\row/\point in {x/.4/3.36,y/-.45/1.2}{ \node[left] at (-.15,\row) {$\name$}; \draw[enclosure] (0,\row)--(4.8,\row); \draw[enclosure] (0,\row-.09)--(0,\row+.09); \draw[enclosure] (4.8,\row-.09)--(4.8,\row+.09); \node[position] at (\point,\row) {}; } \draw[ink!45] (0,-1.05)--(4.8,-1.05); \node[below] at (0,-1.05) {$0$}; \node[below] at (4.8,-1.05) {$1$}; \end{scope} \draw[->,thick] (5.3,0)--(6.7,0); \node[align=center,font=\footnotesize] at (6,.5) {Shared\\updates}; \begin{scope}[shift={(7.4,0)}] \node at (2.4,1.1) {After updates}; \foreach \name/\row/\lo/\hi/\point in {x/.4/1.2/2.4/2.04,y/-.45/3.6/4.8/3.9}{ \node[left] at (-.15,\row) {$\name$}; \draw[ink!20] (0,\row)--(4.8,\row); \draw[enclosure] (\lo,\row)--(\hi,\row); \draw[enclosure] (\lo,\row-.09)--(\lo,\row+.09); \draw[enclosure] (\hi,\row-.09)--(\hi,\row+.09); \node[position] at (\point,\row) {}; } \draw[ink!45] (0,-1.05)--(4.8,-1.05); \node[below] at (0,-1.05) {$0$}; \node[below] at (4.8,-1.05) {$1$}; \node at (2.4,-1.8) {The intervals certify $X_x0$, a vertex $x$, and $c\in(\ell_x,r_x)$.} \ForEach{arc $y\to x$}{ $r_y\gets\min(r_y,c)$\; } \ForEach{arc $x\to z$}{ $\ell_z\gets\max(\ell_z,c)$\; } Delete $x$ and its incident arcs\; \texttt{Normalize}$(D)$\; \Return $D$\; \end{algorithm} \begin{algorithm}[H] \caption{\texttt{Normalize}$(D)$: propagate the interval bounds.} \label{alg:normalize} \DontPrintSemicolon \KwIn{An order-restriction DAG $D$.} \ForEach{vertex $x$ in topological order}{ $\ell_x\gets\max(\{\ell_x\}\cup\{\ell_y:y\to x\})$\; } \ForEach{vertex $x$ in reverse topological order}{ $r_x\gets\min(\{r_x\}\cup\{r_y:x\to y\})$\; } \end{algorithm} \Needspace{6\baselineskip} \begin{lemma}[Coordinate restriction]\label{lem:interior} Let $D$ be canonical with $V(D)>0$ and $c\in(\ell_x,r_x)$. Then \textnormal{\texttt{Restrict}}$(D,x,c)$ represents the section $X_x=c$ of $K(D)$, and \begin{equation}\label{eq:restriction-volume} V(\operatorname{Restrict}(D,x,c))=V(D)f_x(c)>0. \end{equation} \end{lemma} \begin{proof} See Appendix~\ref{app:geometry}. \end{proof} Algorithm~\ref{alg:refine} uses this operation in the tree. Figure~\ref{fig:overview-refine} illustrates a move into an existing child. \begin{algorithm}[H] \caption{\texttt{RefineAt}$(x,c)$: move an item into a child.} \label{alg:refine} \DontPrintSemicolon \KwIn{A free item $x$, an interior anchor $c$, and the current adversary state.} \KwOut{The updated state, with $x$ stored in a child of its former node.} $v\gets$ the node storing $x$\; $D_v\gets$ \texttt{Restrict}$(D_v,x,c)$\; \If{$v$ has no child anchored at $c$}{ Create a child of $v$ at $c$, with an empty order-restriction DAG\; } $u\gets$ the child of $v$ anchored at $c$\; Insert $x$ into $D_u$ as an isolated vertex with record $(x,0,1)$\; \end{algorithm} \begin{center} \begin{minipage}{\linewidth} \captionsetup{hypcap=false} \centering \begin{tikzpicture}[>=Latex,font=\small, group/.style={draw=ink!65,rounded corners=2pt,fill=pale}, item/.style={circle,draw=ink,fill=white,minimum size=6mm,inner sep=1pt}] \begin{scope}[shift={(-3.2,0)}] \node at (0,1.55) {Before refinement}; \draw[group] (-2.4,-.45) rectangle (2.4,1.2); \node[item] (ra) at (-1.5,.65) {$a$}; \node[item] (rx) at (0,.65) {$x$}; \node[item] (rb) at (1.5,.65) {$b$}; \draw[->,thick,accent] (ra)--(rx); \draw[->,thick,accent] (rx)--(rb); \fill (0,-.15) circle (2pt) node[right=4pt] {anchor $c$}; \draw[thick,ink!55] (0,-.15)--(0,-1); \draw[group] (-1.8,-2) rectangle (1.8,-1); \node at (0,-1.3) {Existing child at $c$}; \node at (0,-1.7) {$z$ free}; \end{scope} \draw[->,thick] (-.55,-.2)--(.55,-.2); \begin{scope}[shift={(3.2,0)}] \node at (0,1.55) {After fixing $X_x=c$}; \draw[group] (-2.4,-.45) rectangle (2.4,1.2); \node[item] at (-1.5,.65) {$a$}; \node[item] at (1.5,.65) {$b$}; \node at (0,.65) {$X_a=Latex,font=\small] \begin{scope} \node at (.5,1.38) {Before refinement}; \fill[pale] (0,0)--(0,1)--(1,1)--cycle; \draw[ink!55] (0,0)--(1,1)--(0,1); \draw[->] (0,0)--(1.12,0) node[right] {$X_A$}; \draw[->] (0,0)--(0,1.12) node[above] {$X_B$}; \draw[dashed,ink!60] (.25,0)--(.25,.25); \draw[accent,very thick] (.25,.25)--(.25,1); \node[below] at (.25,0) {$\frac14$}; \node[below left] at (0,0) {$0$}; \node[below] at (1,0) {$1$}; \node[left] at (0,1) {$1$}; \node at (.55,.83) {area $\frac12$}; \end{scope} \draw[->,thick] (1.2,.53)--(1.63,.53); \node[above] at (1.415,.56) {refine $A$}; \begin{scope}[shift={(1.9,0)}] \node at (.5,1.38) {After refinement}; \fill[pale] (0,.25) rectangle (1,1); \draw[ink!55] (0,.25)--(1,.25)--(1,1)--(0,1); \draw[->] (0,0)--(1.12,0) node[right] {$U_A$}; \draw[->] (0,0)--(0,1.12) node[above] {$X_B$}; \node[below left] at (0,0) {$0$}; \node[left] at (0,.25) {$\frac14$}; \node[below] at (1,0) {$1$}; \node[left] at (0,1) {$1$}; \node at (.5,.65) {area $\frac34$}; \end{scope} \end{tikzpicture} \caption{The highlighted section of the triangle has length $3/4$. Replacing the fixed parent coordinate by a fresh unit coordinate in the child gives the rectangle on the right. Its area is $3/2$ times the original area.} \label{fig:section-volume} \end{figure} We call the change \begin{equation}\label{eq:refinement-gain} g=\log\frac{Z_{\rm after}}{Z_{\rm before}}=\log f_x(c) \end{equation} the refinement's \emph{volume gain}. Lemma~\ref{lem:local-routines} guarantees that a refinement requested by \texttt{Select} gains more than $k$ in $\log Z$, whereas an answer loses at most $-\log(1/2-1/(100k))=1+O(1/k)$. Thus an inconclusive call to \texttt{Select} actually restores volume as it moves an item. Since $Z\le1$, these increases must be offset by losses from answers and repairs. \label{sec:refinement-volume} \subsubsection{Keeping the in-node DAGs small}\label{sec:repairs} To keep the DAGs within the bounds of Lemma~\ref{lem:local-routines}, Algorithm~\ref{alg:repair} maintains degree below $k$ and directed paths with fewer than \begin{equation}\label{eq:path-threshold} H=2^k \end{equation} vertices between comparisons. After one arc is inserted, the degree is at most $k$ and every directed path has fewer than $2H=2^{k+1}$ vertices. Further insertions could exceed these bounds, so \texttt{Repair} restores the stricter bounds before the next comparison. A repair selects items to move into children so that the parent's DAG again satisfies the degree and path-length bounds. Its routine \texttt{ChooseAnchor}$(D,x)$ chooses an interior position for the specified item $x$. Lemma~\ref{lem:anchor-selection} gives the guarantee needed for these choices. \begin{algorithm}[H] \caption{\texttt{Repair}$(v)$: restore the graph bounds after an answer.} \label{alg:repair} \DontPrintSemicolon \KwIn{The node $v$ at which the answer was determined.} \If{the graph at $v$ has a directed path on $H$ vertices}{ $L\gets$ the lexicographically first $H$-vertex path, in path order\; \ForEach{$x\in L$ in path order}{ $c\gets$ \texttt{ChooseAnchor}$(D_v,x)$\; \texttt{RefineAt}$(x,c)$\; } } \ElseIf{a vertex at $v$ has degree $k$}{ $x\gets$ the smallest label of degree $k$\; $c\gets$ \texttt{ChooseAnchor}$(D_v,x)$\; \texttt{RefineAt}$(x,c)$\; } \end{algorithm} One repair suffices: every new path on $H$ vertices contains the inserted arc, and only its endpoints can newly reach degree $k$. Either repair removes an endpoint of that arc, leaving a subgraph of the graph before the answer. \begin{lemma}[Anchor selection]\label{lem:anchor-selection} Under the assumptions on $D$ in Lemma~\ref{lem:local-routines}, for any vertex $x$, \textnormal{\texttt{ChooseAnchor}}$(D,x)$ returns a dyadic $c\in(\ell_x,r_x)$. The routine is deterministic and uses only a neighborhood of $x$ whose radius depends on $k$. Every position $c$ returned by \textnormal{\texttt{Select}} or \textnormal{\texttt{ChooseAnchor}}, written in reduced form as $c=(2i+1)/2^{m+1}$ with $m\ge0$, satisfies \begin{equation}\label{eq:tariff} \log f_x(c)\ge(1-1/k)m-4. \end{equation} \end{lemma} \begin{proof} See Appendices~\ref{sec:oracle} and~\ref{app:execution}. \end{proof} Since $m\ge0$, each repair move loses at most four in $\log Z$. For a path repair, the dependence on $m$ yields a stronger lower bound on the total change in $\log Z$. Section~\ref{sec:rare-refinements} uses this bound to limit the number of refinements.