alphaFeedback

WorksComputer Science

An Optimal Deterministic Adversary for Sorting

AI contributions
  • OpenAI ChatGPT GPT 6 Astra
View details
Ancillary data
1 code link
View

Abstract

This paper describes an optimal deterministic, polynomial-time adversary for ordinary sorting. For any correct sorting algorithm, the adversary forces that algorithm to make (1−o(1))nlog⁡2n(1-o(1))n\log_2 n comparisons. The best previously known adversary forced 3764nlog⁡2n\frac{37}{64}n\log_2 n comparisons. The adversary recursively moves items into ordered subproblems, extending the classical framework in which items move down a binary tree.

Methodological disclosure

Except for the abstract, the text of this paper is AI-generated using GPT 6 Astra. The author is working on a clear, human-readable exposition.

The organizing idea Keep comparisons inside a group for as long as they remain inexpensive to handle. When necessary, fix a position in that group and continue the unresolved order in a child.

The paper first specifies the algorithm and its numerical subroutines. Sections § 4–§ 6 establish legality and the refinement bound; Sections § 7–§ 9 give the repairs and polynomial-time implementation. The appendices prove the numerical subroutines independently of sorting.

From Brodal’s tree to unfinished comparisons

There are nn distinct labelled keys. A sorting algorithm asks which of two keys is smaller. Its next question can depend on previous answers. An adversary answers the questions, always consistently with some strict total order. A sorter correct on every input can stop only when its comparison transcript determines that order uniquely.

Throughout, log⁡=log⁡2\log=\log_2, while ln⁡\ln denotes the natural logarithm. The cases n≤1n\le1 are immediate; assume n≥2n\ge2, and put

T=nlog⁡n.T=n\log n.

The objective is an efficient deterministic adversary that forces almost TT comparisons.

Brodal: a comparison makes a spatial commitment

The binary-tree adversary described by Brodal, Chaudhuri, and Radhakrishnan [1], and reviewed by Kaplan, Zamir, and Zwick [2], keeps items at nodes of a binary tree. In the basic same-node case, comparing AA and BB sends one to the left child and the other to the right. Dyadic intervals give an equivalent picture: halve the common interval and assign opposite halves.

After answering A<BA < B and C<DC < D at the same node, this rule can place A,CA,C on the left and B,DB,D on the right. That representation also commits to the cross-relations A<DA < D and C<BC < B. These extra commitments are the cost of a simple representation.

There is an elegant coding proof of its bound. Once sorting is complete, the occupied nodes are distinct leaves: an occupied ancestor and descendant, or two items at the same node, would leave an unresolved pair. The tree’s partial order contains all answered comparisons, so such an incomparable pair admits total orders in both directions consistent with the transcript. The root-to-leaf binary addresses are therefore prefix-free: no address begins with another complete address.

If their lengths are d1,…,dnd_1,\ldots,d_n, the corresponding dyadic subintervals are disjoint, so

∑i=1n2−di≤1.\sum_{i=1}^{n} 2^{-d_i} \le1.

This is Kraft’s inequality. Convexity of 2−x2^{-x} gives

2−1n∑idi≤1n∑i2−di≤1n,hence∑idi≥nlog⁡n.2^{-\frac{1}{n}\sum_i d_i} \le\frac{1}{n}\sum_i 2^{-d_i} \le\frac{1}{n}, \qquad\text{hence}\qquad\sum_i d_i \ge n\log n.

Each query increases total depth by at most two. Thus at least 12nlog⁡n\frac{1}{2}n\log n queries are needed. The tree and its prefix code make the proof transparent.

Kaplan–Zamir–Zwick: retain a pair before separating it

Kaplan, Zamir, and Zwick (KZZ) already postpone some spatial commitments. Their nodes can retain ordered pairs, together with carefully specified interval and intermediate-node states. Thus A<BA < B and C<DC < D can remain as two pairs without immediately imposing the cross-relations. Their rules eventually resolve interactions between such structures by moving items; their best adversary gives the coefficient 37/6437/64 [2].

The idea of going further is also present in their paper. Section 6 discusses continuous intervals and richer dependent structures, and asks whether maintaining suitable small dependencies could yield an efficient adversary with coefficient tending to one. The present construction follows that program. Its task is to make more general retained dependencies both computationally manageable and inexpensive to simplify.

The next step: keep an evolving graph inside a node

After

A<B,C<D,A<C,A < B,\qquad C < D,\qquad A < C,

we can retain all four items in one node, with just the indicated constraints and their consequences:

One group; no spatial separation yet

Figure 1. One group; no spatial separation yet

Each item has a tentative real position. An arrow A→BA \to B means XA<XBX_A < X_B. The adversary chooses answers by estimating what fraction of the allowed position assignments survives. When the graph becomes difficult to handle, it fixes one item’s position and moves that item’s unresolved order into a child.

The structure can retain more than a pair, but it does not retain arbitrary complexity indefinitely. Bounded degree, bounded directed-path length, and controlled interval widths are the conditions that make its calculations local.

Theorem 1.1 (Main result). There is one deterministic legal adversary, initialized using only nn, with a fixed polynomial bound on the number of bit operations per comparison, that forces every correct comparison sorter to make

(1−o(1))nlog⁡n(1-o(1))n\log n

comparisons. The term o(1)o(1) tends to zero as n→∞n \to\infty.

Merge sort uses at most n⌈log⁡n⌉n\lceil\log n\rceil comparisons, so the leading coefficient is optimal. The construction below has very large asymptotic thresholds; this is an existence result, not a claim of practical performance.

The algorithm before its proofs

What one node stores

A node is a group of items whose relative order is still being resolved there. Some items have a free real coordinate XxX_x in an open interval (ax,bx)(a_x,b_x). Directed arrows between free items impose Xx<XyX_x < X_y. Other items have already been assigned a fixed parent position and delegated to a child at that position. Call that position the child’s anchor. Each child has its own fresh coordinate system.

Every original item has exactly one free coordinate, at exactly one node. Its appearances at ancestors are fixed anchors, not additional free coordinates. Different children of one parent have distinct anchors.

At a node vv, the intervals and arrows define

Kv={X:ax<Xx<bx for all free x, Xu<Xw for every arrow u→w}.K_v=\{X:a_x<X_x<b_x\text{ for all free }x,\ X_u<X_w\text{ for every arrow }u\to w\}.

Write Vv=vol⁡(Kv)V_v=\operatorname{vol}(K_v). This is the volume of a constrained region, not generally the product of interval lengths. For example, two coordinates in (0,2)(0,2) give a square of area 44; the constraint XA<XBX_A<X_B leaves a triangle of area 22.

Our auxiliary quantity is

Z=∏vVv.(1)Z=\prod_v V_v. \tag*{(1)}

Different nodes have separate coordinates, so their volumes multiply. A node with no free coordinates contributes 11. Initially there is only the root, all nn intervals are (0,n)(0,n), and Z=nnZ=n^n. The adversary does not need to calculate the global product.

An answer restricts one node

To compare two original items, descend while they belong to the same child. At the first node where their representations differ, each is either a free coordinate or a child anchor. Different anchors decide the answer directly. Otherwise at least one coordinate is free.

For example, if the representations are XAX_A and XBX_B, consider

p=P(XA<XB)=vol⁡{X∈Kv:XA<XB}Vv.p=\mathbb{P}(X_A<X_B)=\frac{\operatorname{vol}\{X\in K_v:X_A<X_B\}}{V_v}.

The probability notation means a ratio of volumes. It introduces no random choice into the algorithm. Equality has zero volume, so the reverse answer has probability 1−p1-p.

An estimate p^\widehat{p} with ∣p^−p∣≤η<1/4|\widehat{p}-p|\leq\eta<1/4 suffices. Answer A<BA<B if p^≥1/2\widehat{p}\geq1/2, and B<AB<A otherwise. The chosen region has at least 1/2−η1/2-\eta of the old volume. When one representation is an anchor cc, use the same rule with a threshold event XA<cX_A<c.

Subroutine 1: estimate On a suitably maintained graph, return a deterministic additive-η\eta estimate of a comparison or threshold probability. Section 4 states the precise conditions; Appendices B and C prove the procedure.

A refinement fixes a position and renews its coordinate

Suppose we choose an interior feasible position cc for a free item xx. Fix Xx=cX_x=c, remove xx from the parent’s free graph, and turn its incident arrows into interval restrictions on their other endpoints. For instance,

XC<Xx<XD⟶XC<c<XD.X_C<X_x<X_D \quad\longrightarrow\quad X_C<c<X_D.

The strict comparisons remain true.

Then admit xx to the child anchored at cc, creating that child if necessary. If this is the child’s jj-th admission, give xx a fresh, independent coordinate in (0,j)(0,j). Leave every old child coordinate, interval, arrow, and anchor unchanged.

Diagram showing a parent interval with C to the left and D to the right of c, leading to a child at c containing old items and x with a fresh coordinate in (0, j)

Figure 2.3.

Here jj counts all admissions, including items that later move to grandchildren. If fx(c)f_x(c) is the density of the parent coordinate at cc, this operation satisfies the exact identity

ZafterZbefore=jfx(c).(2)\frac{Z_{\mathrm{after}}}{Z_{\mathrm{before}}}=j f_x(c). \tag*{(2)}

The parent loses one dimension by taking a section; the child gains one dimension of length jj. Thus total dimension remains nn.

For intuition, in the triangle 0<XA<XB<20<X_A<X_B<2, the section at XA=cX_A=c has length 2−c2-c, so fA(c)=(2−c)/2f_A(c)=(2-c)/2. If a child at position 11 already contains one item, fixing AA there and admitting it as the second item gives factor 2⋅(1/2)=12\cdot(1/2)=1: the child’s new freedom exactly pays for the parent restriction.

Subroutine 2: choose a position Find an interval on which the item’s density has a guaranteed lower bound, and select a prescribed dyadic midpoint inside it. The ordinary choice needs the local estimate; an emergency central-interval choice works before the width conditions are restored. The guarantees are stated in Section 4.

The two procedures

All choices and ties use fixed label order. The top-level algorithm is:

COMPARE(A, B):
    Descend through common children to the responsible node.
    If both representations are different anchors, return their order.
    Estimate one direction; choose the estimated larger side.
    Store its arrow or interval bound.
    RESTORE the conditions needed by the numerical subroutines.
    Return the chosen answer.

Its central private operation is:

REFINE(x, node, reason):
    Obtain a good interval by the method appropriate to the reason.
    Choose its prescribed dyadic midpoint c.
    Fix x at c; replace incident arrows by permanent interval bounds.
    Admit x as an isolated free coordinate to the child at c.

Subroutine 3: restore Cut a cheap problematic edge, or refine selected troublesome vertices. Restore the numerical hypotheses, preserve all public answers, and perform sufficiently few refinements. Section 6 specifies every rule and proves these promises.

The remainder discharges these contracts. Legality comes first. Then we prove that rare refinements are affordable before specifying which ones the algorithm makes.

Why the representation is legal

Reading an actual order

Choose a feasible point at every node, avoiding equalities between free coordinates and between a free coordinate and an anchor. These exceptional equalities have volume zero. Read positions from left to right; replace each child anchor by the order read recursively inside that child.

The invariant is:

Every order represented in this way respects every comparison already answered.

We do not require the converse. Private repairs may discard compatible orders. Their cost is accounted for through ZZ. A positive-volume state always represents at least one order, so the invariant proves legality.

An actual comparison restricts one node to a positive-volume side. It therefore preserves the invariant and imposes the requested order. An answer contradicting an earlier implied relation would have probability zero, and cannot be chosen by an additive-η\eta majority estimate with η<1/4\eta< 1/4. No separate public-order safety test is needed.

Effective intervals

Propagate lower bounds along arrows and upper bounds against them. Writing y⪯xy \preceq x when y=xy=x or a directed path leads from yy to xx, define

ℓx=max⁡y⪯xay,rx=min⁡y⪰xby,Wx=rx−ℓx.\ell_x = \max_{y \preceq x} a_y,\qquad r_x = \min_{y \succeq x} b_y,\qquad W_x = r_x-\ell_x.

The interval (ℓx,rx)(\ell_x,r_x) is the coordinate’s effective interval. Store these tightened bounds permanently, including after arrows are removed. Along x→yx \to y, both ℓx≤ℓy\ell_x \le\ell_y and rx≤ryr_x \le r_y.

Lemma 3.1 (Interior fixing). For an acyclic arrow graph, the feasible region has positive volume if and only if every Wx>0W_x > 0. Every c∈(ℓx,rx)c \in(\ell_x,r_x) is feasible for XxX_x, and fixing it leaves a positive-volume section in the remaining coordinates.

Proof. Necessity is immediate. For sufficiency, choose numbers 0<θx<10 < \theta_x < 1 increasing in a topological order, a listing in which every arrow points forward, and put

Xx=(1−θx)ℓx+θxrx.X_x = (1-\theta_x)\ell_x + \theta_x r_x.

This expression increases with either endpoint and strictly with θx\theta_x when Wx>0W_x > 0. All arrows are therefore strict, and a small open neighborhood is feasible. A topological order exists by repeatedly removing a vertex with no incoming arrow.

After fixing xx at interior cc, only predecessors get smaller upper bounds and only successors get larger lower bounds. A predecessor yy still has upper bound at least min⁡(ry,c)>ℓy\min(r_y,c) > \ell_y, since ℓy≤ℓx<c\ell_y \le\ell_x < c. The successor argument is symmetric. Apply the same positive-volume criterion to the remaining coordinates.

Lemma 3.2 (Legal admission and the refinement identity). An item fixed at an interior position cc is incomparable in the public transcript with every existing item in the child at cc. It may enter that child as an isolated coordinate, and (2) holds.

Proof. Choose a point in the positive-volume parent section Xx=cX_x = c at which every other free coordinate is distinct from cc and from all anchors. Move xx a little to the left, or a little to the right, keeping everything else fixed. Strict inequalities permit both changes. The two represented orders put xx immediately before or immediately after the entire old child block. Both respect the transcript. Thus no old item in that child has a publicly determined relation to xx.

Any new position of xx among the old child items is legal: comparisons among old labels are unchanged, there were no answered comparisons between xx and those child labels, and xx’s relations to all outside blocks are the same as in the two surrounding orders.

Let Sx(c)S_x(c) be the parent section volume. By the definition of coordinate density, fx(c)=Sx(c)/Vvf_x(c) = S_x(c)/V_v. Fixing replaces VvV_v by Sx(c)S_x(c); the new independent child coordinate multiplies its volume by jj. This proves (2).

A real point has probability zero, but its section has a well-defined lower-dimensional volume. The identity compares that section with the original volume and then restores the missing dimension. A density can exceed one; a refinement can increase ZZ. These gains must not be discarded in the accounting.

A fixed rule for the anchor

Suppose a closed interval I=[a,a+m]I = [a,a+m] has density at least 1/(βm)1/(\beta m) throughout. Choose the unique power of two bb such that

m4<b≤m2,k=⌊a/b⌋,c=(k+12)b.\frac{m}{4} < b \le\frac{m}{2}, \qquad k = \lfloor a/b \rfloor, \qquad c = (k+\tfrac{1}{2})b.

The cell [kb,(k+1)b][kb,(k+1)b] lies inside II; its midpoint is strictly inside II. Consequently

fx(c)≥14βb(3)f_x(c) \ge\frac{1}{4\beta b} \tag*{(3)}

Finding the scale uses the binary length of a rational number, not a search through arbitrarily fine grids.

One midpoint determines one cell and one scale: equality of (2k+1)2z−1(2k+1)2^{z-1} at two different powers 2z2^z would equate an odd integer with an even one. This uniqueness lets repeated choices reuse the same child, and lets us count all possible destinations.

A numerical theorem independent of sorting

This section’s objects are just an acyclic directed graph and intervals. It has no children, refinements, or sorting transcript. For the algorithms, endpoints and queried thresholds are dyadic rationals; the geometric facts apply also to arbitrary real endpoints.

The graph’s degree is the largest number of neighbors, ignoring arrow directions. Its height is the maximum number of vertices on a directed path. Components and distances also ignore directions. Two vertices are comparable if a directed path joins them in either direction.

Theorem 4.1 (Local interval probabilities). Fix integers d,h≥1d,h \ge1, a rational ratio R≥1R \ge1, and rational 0<ε<1/40 < \varepsilon< 1/4. There is a computable radius ρ=ρ(d,h,R,ε)\rho=\rho(d,h,R,\varepsilon) with the following property.

Let KK be a positive-volume interval-and-arrow region whose graph has degree at most dd and height at most hh. In every component, suppose the largest effective width is at most RR times the smallest. For one or two queried coordinates, retain the induced graph within distance ρ\rho, together with the original effective intervals.

The resulting local probabilities approximate P(Xx<c)\mathbb{P}(X_x<c) and P(Xx<Xy)\mathbb{P}(X_x<X_y) to additive error at most ε\varepsilon. The same local region works for every threshold cc. It has at most

b≤2(d+1)ρ+1b \le2(d+1)^{\rho+1}

vertices. Its probabilities are calculated exactly using O(b32b)O(b^{3}2^b) arithmetic operations on rational numbers. No minimum positive width is required.

The radius is independent of the total graph size. The local calculation is exact; using it in place of the full probability introduces the error. Appendix § 12 proves locality and gives explicit constants. Appendix § 13 gives the calculation.

Lemma 4.2 (Two density windows). Suppose xx has at most BB other comparable vertices and effective interval (ℓx,rx)(\ell_x,r_x) of width WW.

  1. Its density satisfies fx(t)≤(B+1)/Wf_x(t) \le(B+1)/W. On

Ix=[ℓx+W/4, rx−W/4]I_x=[\ell_x+W/4,\ r_x-W/4]

it satisfies fx(t)≥4−B/Wf_x(t) \ge4^{-B}/W. This window needs no probability calculation.

  1. Given local cumulative probabilities accurate to 1/321/32, one can find dyadic a<ba<b, strictly inside the effective interval, with m=b−am=b-a and

fx(t)≥116m(a≤t≤b).f_x(t) \ge\frac{1}{16m}\qquad(a\le t\le b).

If the local region contains b0b_0 vertices, each endpoint requires at most ⌈log⁡(32b0)⌉+1\lceil\log(32b_0)\rceil+1 bisections.

Appendix § 11 proves this lemma. Applied to the rounding rule, the quantile window gives

−log⁡fx(c)≤log⁡(64b).-\log f_x(c)\le\log(64b).

The central window gives W/8<b≤W/4W/8 < b \le W/4, and hence

−log⁡fx(c)≤log⁡(64b)+2B.-\log f_x(c) \le\log(64b) + 2B.

The central window is more expensive, but it is available even when width ratios prevent a local calculation. This avoids a circular repair rule.

Relation to linear extensions. When all intervals are (0,1)(0,1), each coordinate order occupies volume 1/m!1/m!, where mm is the graph size. Thus the region’s volume is e(G)/m!e(G)/m!, and comparison probabilities agree with those under a uniformly random linear extension [3]. With unequal intervals, different orders can have different volumes. The theorem concerns those interval-constrained probabilities. It is not a general deterministic counting theorem for linear extensions, nor a claim of a fully polynomial approximation scheme.

Why rare refinements are affordable: a coding proof

We now set aside the implementation of repairs. Consider any completed legal run using qq comparisons and PP refinements. Index the refinement events by i=1,…,Pi = 1,\ldots,P; one item can be refined several times. If event ii fixes xx at cc in a cell of length bb, assume

fx(c)≥164b 2γi,γi≥0,Γ=∑i=1Pγi.(4)f_x(c) \ge\frac{1}{64b\,2^{\gamma_i}}, \qquad\gamma_i \ge0, \qquad\Gamma= \sum_{i=1}^{P}\gamma_i. \tag*{(4)}

The ordinary window has γi=0\gamma_i = 0; the emergency central window has γi=2B\gamma_i = 2B.

Theorem 5.1 (Rare refinements suffice). Suppose each comparison retains at least 1/2−η1/2-\eta of ZZ, or loses nothing, and there are at most qq further private cuts, each retaining at least 1−η1-\eta, where 0<η≤1/320 < \eta\le1/32. Then

T≤(1+10η)q+Γ+10P+3n+2Plog⁡(2+TP).(5)\boxed{T \le(1+10\eta)q + \Gamma+ 10P + 3n + 2P\log\left(2+\frac{T}{P}\right).} \tag*{(5)}

For P=0P=0, the last term means zero. In particular,

η=o(1),P=o(T),Γ=o(T)⟹q≥(1−o(1))T.\eta= o(1), \qquad P = o(T), \qquad\Gamma= o(T) \quad\Longrightarrow\quad q \ge(1-o(1))T.

The proof’s meaning is that rare refinements have a small average cost. It does not require every refinement to be cheap. The coding argument pays for the many possible child destinations; the admission factorial pays for their repeated use.

The tree’s finite budget

Let svs_v be the final number of items ever admitted to node vv, and rvr_v the number remaining free there. For a child cc of vv, write kc=sck_c = s_c. Every label visits a node at most once. Consequently

sv=rv+∑c child of vkc,∑vrv=n,∑vsv=n+P,∑v,ckc=P.s_v = r_v + \sum_{c\text{ child of }v} k_c, \qquad\sum_v r_v = n, \qquad\sum_v s_v = n+P, \qquad\sum_{v,c} k_c = P.

All coordinates at vv lie in (0,sv)(0,s_v): root intervals started in (0,n)(0,n), and later admissions received (0,j)(0,j) with j≤svj \le s_v.

Define the group-size budget

B=∑v,ckclog⁡(sv/kc).(6)\mathcal{B} = \sum_{v,c} k_c \log(s_v/k_c). \tag*{(6)}

For one original label visiting nodes of final sizes n,s1,…,s∗n, s_1, \ldots, s_\ast, its terms telescope to log⁡(n/s∗)≤log⁡n\log(n/s_\ast) \le\log n. Therefore

B≤T.(7)\mathcal{B} \le T. \tag*{(7)}

This has a direct coding interpretation. Add a terminal leaf for each free item at its last node. A branch to a child of size kk has ideal information cost log⁡(s/k)\log(s/k), and a branch to an individual terminal item costs log⁡s\log s. Every full item path then has cost exactly log⁡n\log n. Thus

T=B+∑vrvlog⁡sv.T = \mathcal{B} + \sum_v r_v \log s_v.

These are fractional information costs, not a claim that a binary codeword has noninteger length.

Lemma 5.2 (Distinct destinations spend the budget). A batch of gg refinements at one parent, entering gg distinct children, contributes at least glog⁡gg \log g through its own refinement events to B\mathcal{B}.

Proof. If the children’s final sizes are k1,…,kgk_1, \ldots, k_g, then ∑iki≤s\sum_i k_i \le s. The arithmetic–geometric mean inequality gives ∏iki≤(s/g)g\prod_i k_i \le(s/g)^g, or ∑ilog⁡(s/ki)≥glog⁡g\sum_i \log(s/k_i) \ge g \log g.

Why the raw binary addresses need a header

In Brodal’s finished tree, leaf addresses are already prefix-free. Here children are anchored at midpoints of dyadic cells at many scales. Those cells can nest. For example, in a parent span [0,8][0, 8], cells [0,4][0, 4] and [0,2][0, 2] have addresses 0 and 00, and distinct anchors 2 and 1. These raw addresses are not prefix-free.

We must also describe the scale: where the address stops. This can be done with only a logarithmic overhead in the scale number. The following weights express that observation without integer rounding.

For a child with cell length bcb_c in a parent of final size ss, put

tc=⌊log⁡(s/bc)⌋,πc=bc/s(tc+1)(tc+2).(8)t_c = \left\lfloor\log(s/b_c) \right\rfloor,\qquad\pi_c = \frac{b_c/s}{(t_c+1)(t_c+2)}. \tag*{(8)}

There is one dyadic cell length at each scale number tt. At that length, at most s/bs/b cells fit in [0,s][0,s]. Hence

∑c:tc=tπc≤1(t+1)(t+2),∑cπc≤∑t≥0(1t+1−1t+2)=1.\sum_{c:t_c=t} \pi_c \le\frac{1}{(t+1)(t+2)},\qquad\sum_c \pi_c \le\sum_{t\ge0}\left(\frac{1}{t+1}-\frac{1}{t+2}\right)=1.

Thus the weights satisfy Kraft’s inequality. The ideal description length is

−log⁡πc=log⁡(s/bc)⏟location at this scale+log⁡((tc+1)(tc+2))⏟scale header.-\log\pi_c = \underbrace{\log(s/b_c)}_{\text{location at this scale}}+\underbrace{\log((t_c+1)(t_c+2))}_{\text{scale header}}.

For a literal prefix-free code on the finite set of used children, set ℓc=⌈−log⁡πc⌉\ell_c = \lceil-\log\pi_c\rceil. Their Kraft sum is at most one. Sort these integers increasingly and place consecutive dyadic intervals of lengths 2−ℓc2^{-\ell_c} inside [0,1][0,1]. Each new left endpoint is aligned because previous intervals were at least as long; the total length is at most one. Their disjoint binary addresses realize the code. The proof below uses the weights directly and saves the rounding bit. These proof weights depend on final sizes; the online adversary never needs to know them.

The factorial pays for reuse

At the jj-th admission to a child, the refinement identity supplies a factor jj. Across its kck_c admissions this is kc!k_c!, even if that child answers comparisons between arrivals. Therefore the total logarithmic refinement loss LrefL_{\mathrm{ref}} satisfies

Lref≤Γ+∑v,c(kclog⁡(64bc)−log⁡(kc!))≤Γ+8P+S,S=∑v,ckclog⁡(bc/kc).(9)\begin{aligned} L_{\mathrm{ref}} &\le\Gamma+\sum_{v,c}\left(k_c\log(64b_c)-\log(k_c!)\right)\\ &\le\Gamma+8P+S,\qquad S=\sum_{v,c}k_c\log(b_c/k_c). \tag*{(9)} \end{aligned}

Here k!≥(k/e)kk! \ge(k/e)^k, obtained by comparing ∑j=1kln⁡j\sum_{j=1}^{k}\ln j with ∫1kln⁡u du\int_1^k\ln u\,du, and 6+log⁡e<86+\log e<8.

Set wc=svπc=bc/((tc+1)(tc+2))w_c=s_v\pi_c=b_c/((t_c+1)(t_c+2)). Kraft gives

W:=∑v,cwc≤∑vsv=n+P.W:=\sum_{v,c}w_c\le\sum_v s_v=n+P.

For P>0P>0, concavity of log, with weights kc/Pk_c/P, yields

∑v,ckclog⁡(wc/kc)≤Plog⁡(W/P)≤Plog⁡(1+n/P)≤nlog⁡e.(10)\begin{aligned} \sum_{v,c}k_c\log(w_c/k_c)&\le P\log(W/P)\\ &\le P\log(1+n/P)\le n\log e. \tag*{(10)} \end{aligned}

Consequently

S≤nlog⁡e+∑v,ckclog⁡((tc+1)(tc+2)).(11)S\le n\log e+\sum_{v,c}k_c\log((t_c+1)(t_c+2)). \tag*{(11)}

If S<0S<0, it already improves our desired upper bound. Otherwise, observe that

∑v,ckctc≤∑v,ckclog⁡(sv/bc)=B−S≤T.\sum_{v,c}k_ct_c\le\sum_{v,c}k_c\log(s_v/b_c)=\mathcal{B}-S\le T.

The average scale number, over refinement events, is therefore at most T/PT/P. A second use of concavity bounds all scale headers:

∑v,ckclog⁡((tc+1)(tc+2))≤2Plog⁡(2+∑v,ckctcP)≤2Plog⁡(2+T/P).\sum_{v,c}k_c\log((t_c+1)(t_c+2))\le2P\log\left(2+\frac{\sum_{v,c}k_ct_c}{P}\right)\le2P\log(2+T/P).

This and (11) cover both signs of SS. Substituting into (9) proves

Lref≤Γ+8P+nlog⁡e+2Plog⁡(2+T/P).(12)L_{\mathrm{ref}}\le\Gamma+8P+n\log e+2P\log(2+T/P). \tag*{(12)}

One way to read this proof is S=B−AS=\mathcal{B}-\mathcal{A}, where A=∑kclog⁡(sv/bc)\mathcal{A}=\sum k_c\log(s_v/b_c) is the binary location information. The cost left after factorial recovery is the excess of group separation information over location information. Kraft bounds that excess by the short scale headers, plus O(n)O(n).

The endpoint is now a one-line estimate

When the transcript determines a total order, the rvr_v free coordinates at a node must occur in one prescribed order. They all lie in (0,sv)(0,s_v). Thus

Vv≤svrvrv!≤esv,log⁡Zfinal≤(n+P)log⁡e.(13)V_v\le\frac{s_v^{r_v}}{r_v!}\le e^{s_v},\qquad\log Z_{\mathrm{final}}\le(n+P)\log e. \tag*{(13)}

The second inequality uses one term of the exponential series. Multiplication over nodes uses ∑vsv=n+P\sum_v s_v=n+P. No multinomial calculation is needed.

Each comparison costs at most −log⁡(1/2−η)-\log(1/2-\eta), and each private cut at most −log⁡(1−η)-\log(1-\eta). For η≤1/32\eta\le1/32, their combined cost is at most (1+10η)q(1+10\eta)q, using −ln⁡(1−u)≤2u-\ln(1-u) \le2u for 0≤u≤1/20 \le u \le1/2.

Starting at log⁡Z=T\log Z=T, add these costs, (12), and (13). The inequalities 8+log⁡e<108+\log e<10 and 2log⁡e<32\log e<3 prove (5). When P=0P=0, the endpoint estimate alone gives the stated weaker bound. Finally, with p=P/Tp=P/T,

2Plog⁡(2+T/P)T=2plog⁡(2+1/p)⟶0as p↓0.\frac{2P\log(2+T/P)}{T}=2p\log(2+1/p)\longrightarrow0 \quad\text{as }p\downarrow0.

This proves Theorem 5.1 directly. There is no auxiliary parameter to send to zero later.

What the coding argument does, and what it still needs. It explains the cost of choosing and reusing child positions. Our current item paths are not themselves Brodal-style terminal codewords: several free items may remain at an internal node. The endpoint-volume estimate handles that residual freedom. The coding argument also does not calculate comparison probabilities; that is the separate task of the numerical theorem.

How to keep the graphs calculable

The numerical theorem asks for three properties: few neighbors, short directed paths, and controlled width ratios. The repair routine has two stages. First repair widths, so the numerical theorem can be used. Then remove excessive degree or height using the ordinary, inexpensive density window.

Fix integers DD, HH, J≥4J \ge4 and 0<η≤1/320 < \eta\le1/32. Between queries, require degree below DD and height below HH. One new arrow raises degree by at most one and joins at most two old directed paths. No repair adds an arrow. Thus throughout repairs we may use

d=D,h=2H,B=(d+1)h+1,C=B+1,σ=2B.d=D,\qquad h=2H,\qquad B=(d+1)^{h+1},\qquad C=B+1,\qquad\sigma=2B.

The distance-hh ball contains at most BB vertices, so in particular each vertex has at most BB comparable vertices. Set

L=max⁡{4,⌈C/η⌉},A=L2h+2,R=AJ.(14)L=\max\{4,\lceil C/\eta\rceil\},\qquad A=L^{2h+2},\qquad R=A^J. \tag*{(14)}

All propagation permanently stores the tightened intervals. Fixed label order resolves every choice of vertex, edge, or path.

Width repair: cut an edge when one side is much wider

Suppose an arrow u→vu\to v has Wu>LWvW_u>LW_v. Impose the stronger bound Xu<ℓvX_u<\ell_v, and remove the arrow. Since Xv>ℓvX_v>\ell_v, every remaining assignment still satisfies Xu<XvX_u<X_v.

How much is lost? Along the arrow, ru≤rvr_u\le r_v. The discarded part of uu’s effective interval therefore has length at most WvW_v. By the density upper bound, its probability is at most

CWvWu<η.\frac{CW_v}{W_u}<\eta.

The new interval is positive, because

ℓv−ℓu=Wu−Wv+(rv−ru)>0.\ell_v-\ell_u=W_u-W_v+(r_v-r_u)>0.

A predecessor whose upper bound decreases still has lower bound at most ℓu<ℓv\ell_u < \ell_v; propagation stays feasible.

Symmetrically, when Wv>LWuW_v > L W_u, impose Xv>ruX_v > r_u and remove the arrow. These are permanent interval bounds. A deleted arrow is replaced by a stronger restriction, not forgotten. Each such cut removes an edge introduced by a comparison, so the entire run has at most qq cuts.

Width repair: separate a batch of very different scales

Suppose no edge cut applies, but one component’s largest width exceeds RR times its smallest width ww. Adjacent widths have ratio at most LL. Along a path from a minimum-width vertex to a maximum-width vertex, mark the first vertex reaching width AiwA^i w, for i=0,…,J−1i = 0, \ldots, J - 1. The marked widths lie in

[Aiw,LAiw].[A^i w, LA^i w].

Successive marked widths therefore differ by a factor at least

A/L=L2h+1.A/L = L^{2h+1}.

Any two marked vertices have distance greater than 2h2h: a path of length at most 2h2h would bound their width ratio by L2hL^{2h}.

Refine these JJ vertices in increasing width, using the central interval and without interrupting the batch. Fixing a coordinate changes effective intervals only along directed paths to or from that coordinate, hence within distance hh. The chosen vertices’ widths are therefore unchanged until they are processed.

Their selected cell lengths belong to (W/8,W/4](W/8, W/4]. The marked widths differ by more than a factor four, so the cell lengths differ. Distinct scales have distinct midpoints. Thus the batch enters JJ distinct children.

Call these scale refinements. Each pays surcharge σ=2B\sigma= 2B. Their advantage is that they require no local probability calculation.

Repeat the two width rules, always giving the edge cut priority, until neither applies. Each cut deletes an edge, and each scale refinement removes a nonisolated vertex. The process terminates. Every remaining component then has width ratio at most RR.

Graph repair: high degree or a long directed path

After width repair, the numerical theorem is available with the safe bounds dd, hh, RR.

If a vertex has degree at least DD, refine it using its quantile window. Then repair widths again. This is an ordinary refinement, with zero surcharge.

Otherwise, if a directed path has at least HH vertices, mark HH consecutive vertices. Finish this marked batch before selecting another path:

  1. Repair widths before each ordinary refinement.

  2. If a marked item remains free, refine it using its quantile window.

  3. If an intervening width repair already refined it, skip it.

The marked items are pairwise comparable in the public transcript. Lemma 3.2 therefore forces their departures from this parent into HH distinct children, including departures caused by intervening scale repairs.

Continue until degree and height are below their thresholds. No repair adds an edge. A child admission adds only an isolated coordinate, with no change to its old distributions. It therefore requires no further child repair.

Why the order matters Width repair can operate without the local estimator. Once widths are controlled, ordinary refinement may use it. The algorithm never calls the estimator in order to repair the very condition needed to justify that call.

The complete restoration routine

The pseudocode hides no additional operation:

RESTORE(node):
    Repeat:
        Repair widths, giving edge cuts priority over scale batches.
        If a degree is at least D, ordinarily refine that item; continue.
        If there is an H-vertex directed path, finish its marked batch;
            continue.
        Return.

The four rules have two different purposes. Edge cuts remove negligible dependencies. Refinements remove a variable while returning freedom in a child. The following count shows why the costly operations are infrequent.

Why there cannot be too many refinements

Let NoN_o and NsN_s count ordinary and scale refinements. Then

P=No+Ns,Γ=σNs.P = N_o + N_s,\qquad\Gamma= \sigma N_s.

High degree is paid for by already asked comparisons. A degree refinement deletes at least DD current edges. Deleted edges cannot be deleted again; every edge was introduced by an actual query at that node. Thus there are at most q/Dq/D degree refinements.

Long paths and separated scales spend the tree budget. Each marked path sends HH items into different children. By Lemma 5.2, its refinement events contribute at least Hlog⁡HH \log H to BB. Different marked paths at one node use disjoint refinement events, so at most T/log⁡HT/\log H ordinary path refinements occur.

Each scale batch similarly contributes at least Jlog⁡JJ \log J, and scale batches use disjoint refinement events. Hence

No≤qD+Tlog⁡H,Ns≤Tlog⁡J.(15)N_o \le\frac{q}{D} + \frac{T}{\log H},\qquad N_s \le\frac{T}{\log J}. \tag*{(15)}

A path batch can overlap a scale batch. This causes no double charge in either separate estimate: each family uses its own application of B≤TB \le T. A marked item consumed by a scale repair is charged only for the refinement it actually makes.

A rough finite bound for implementation. We also have

P≤2q.(16)P \le2q. \tag*{(16)}

Charge each refinement to one incident edge endpoint at the node it leaves. Degree and scale refinements have such an endpoint when selected. For a marked path item, reserve an original incident path endpoint even if another repair removes that edge before the item moves. A label leaves a node only once, so an endpoint cannot be charged twice. There are at most 2q2q introduced endpoints in total.

This last estimate is not the asymptotic rarity argument. It is useful for bounding the amount of state and the number of binary digits created.

Choosing the parameters and proving polynomial time

First choose any fixed accuracy stage

For each integer k≥4k \ge4, use

D=k+4,H=2k,η=1100k.D = k + 4,\qquad H = 2^k,\qquad\eta= \frac{1}{100k}.

Compute BB, σ\sigma as above, and set

J=2kσ.J = 2^{k\sigma}.

Then compute LL, AA, RR from (14), and the radius ρk\rho_k supplied by Theorem 4.1. Since η<1/32\eta< 1/32, the same radius is sufficient for the quantile calculations. Let

bk=2(d+1)ρk+1b_k = 2(d+1)^{\rho_k+1}

be the corresponding neighborhood-size bound.

On a completed run with q≤2Tq \le2T, (15) gives

No≤3Tk,Ns≤Tkσ,P≤4Tk,Γ≤Tk.N_o \le\frac{3T}{k},\qquad N_s \le\frac{T}{k\sigma},\qquad P \le\frac{4T}{k},\qquad\Gamma\le\frac{T}{k}.

Thus, as the selected stage tends to infinity, η=o(1)\eta= o(1), P=o(T)P = o(T), and Γ=o(T)\Gamma= o(T). The coding bound (5) then gives q≥(1−o(1))Tq \ge(1-o(1))T. Runs with q>2Tq > 2T already exceed the target.

Make one algorithm, with one polynomial exponent

Allowing the running-time exponent to depend on a desired accuracy would not establish Theorem 1.1. We instead let the stage grow extremely slowly with nn.

During initialization, spend at most nn bit operations computing successive stages. Keep the largest fully computed stage satisfying

bk≤⌊log⁡(n+1)⌋.b_k \le\lfloor\log(n+1)\rfloor.

If none fits, answer using a fixed total order of the labels. Every fixed stage is a finite computation and eventually meets both the initialization and neighborhood budgets. Therefore the stage k(n)k(n) selected in this way tends to infinity.

Every local calculation then uses b≤log⁡(n+1)b \le\log(n+1) coordinates. Appendix § 13 uses O(b32b)O(b^3 2^b) arithmetic operations, which is a polynomial with a fixed exponent. Constructing a neighborhood, propagating intervals, and finding paths use ordinary polynomial-time graph operations.

Binary precision is also polynomial

All endpoints and anchors are dyadic rationals, meaning integers divided by powers of two. Suppose the current denominators divide 2Λ2^{\Lambda}. A quantile search adds only O(log⁡(b+1))O(\log(b+1)) binary digits; the grid rounding adds a constant number. A central-window refinement adds only a constant number. Propagation and cuts use existing bounds and add no digits.

Before q=O(nlog⁡n)q=O(n\log n) queries, (16) therefore gives

Λ=O(nlog⁡(n+1)log⁡log⁡(n+4)).\Lambda= O\bigl(n\log(n+1)\log\log(n+4)\bigr).

All coordinates lie in [0,n][0,n]. The exact local table uses integers with

O(b(Λ+log⁡(n+1)+log⁡(b+1)))O\bigl(b(\Lambda+\log(n+1)+\log(b+1))\bigr)

bits. Thus the arithmetic bit cost is polynomial as well. There are at most P+1P+1 nodes and at most qq edge introductions. Stage descriptions have at most nn bits, by the initialization budget.

After 2n⌈log⁡(n+1)⌉2n\lceil\log(n+1)\rceil queries, the adversary may freeze a total order compatible with its saved public comparison graph, found by topological sorting, and answer from it thereafter. This threshold is already beyond the lower bound. It prevents repeated gratuitous queries from enlarging the state indefinitely.

The representation proves legality, the rarity estimates and coding theorem prove the lower bound, and the local computation and precision bounds prove the fixed polynomial running time. This establishes Theorem 1.1.

Computational checks and related formalization

The exact local-volume recurrence of Appendix § 13 was compared with an independent rational implementation of the segment-assignment method on 630 seeded acyclic interval systems with one to seven vertices. The two implementations agree in every case, including infeasible systems and mixed dyadic precisions. A further 27 analytic checks cover independent boxes, chains, empty and cyclic cases, an unequal-interval comparison probability of 3/43/4, triangle densities, and the refinement identity jfx(c)j f_x(c). The accompanying source includes the script and its results. These finite checks verify the numerical implementation and selected identities; the locality and asymptotic guarantees follow from the proofs in this paper.

A related Lean 4 development is available in the sorting-adversary-proofs repository [4]. That development follows the earlier recursive integer-colour construction. The continuous-position formulation, prefix-code accounting, and exact-volume recurrence presented here are given as mathematical arguments; citing the repository does not assert a line-by-line formalization of this presentation.

Density windows from elementary geometry

Sections of a convex region

A region is convex if it contains the segment joining any two of its points. Our regions are convex because every defining condition is a linear inequality.

Lemma A.1 (The two-cone bound). Let a point be uniform in a positive-volume bounded convex region in mm dimensions. Suppose a nonconstant linear coordinate YY ranges over (L,U)(L,U), of width

W=U−LW = U - L. Its probability density gg satisfies

g(t)≤mW.(17)g(t) \le\frac{m}{W}. \tag*{(17)}

For every 0<θ≤1/20 < \theta\le1/2, it also satisfies

g(t)≥θm−1W(L+θW≤t≤U−θW).(18)g(t) \ge\frac{\theta^{m-1}}{W} \qquad(L + \theta W \le t \le U - \theta W). \tag*{(18)}

Proof. Use a linear change of variables making YY the first coordinate. Its constant volume factor cancels in densities. Write A(t)A(t) for section volume and V=∫LUA(t) dtV = \int_L^U A(t)\,\mathrm{d}t for total volume.

Join the section at tt to feasible points with first coordinates approaching LL and UU. Convexity puts both cones inside the region. A section of a cone shrinks in its m−1m - 1 free directions by a common factor, so the two cone volumes tend to

t−LmA(t)+U−tmA(t)=WmA(t).\frac{t-L}{m}A(t) + \frac{U-t}{m}A(t) = \frac{W}{m}A(t).

Thus V≥WA(t)/mV \ge WA(t)/m, proving (17). For m=1m = 1 the distribution is uniform and both assertions are immediate.

There is an interior t0t_0 with A(t0)≥V/WA(t_0) \ge V/W, or a sequence approaching this bound. For t≥t0t \ge t_0, join this section toward the upper endpoint. At tt, the scale factor tends to (U−t)/(U−t0)≥θ(U-t)/(U-t_0) \ge\theta. Hence A(t)≥θm−1A(t0)A(t) \ge\theta^{m-1}A(t_0). Use the lower endpoint when t≤t0t \le t_0 and take limits if needed. This proves (18). □

This proof uses only convexity and the integral ∫01um−1 du=1/m\int_0^1 u^{m-1}\,\mathrm{d}u = 1/m, not a general theorem about log-concave measures.

Why the relevant dimension is small

Lemma A.2 (Condition on the incomparable labels). Let xx have cc other comparable labels in the active graph and effective interval (ℓx,rx)(\ell_x, r_x) of width WxW_x. Then

fx(t)≤c+1Wx,(19)f_x(t) \le\frac{c+1}{W_x}, \tag*{(19)}
fx(t)≥4−cWx(ℓx+Wx/4≤t≤rx−Wx/4).(20)f_x(t) \ge\frac{4^{-c}}{W_x} \qquad(\ell_x + W_x/4 \le t \le r_x - W_x/4). \tag*{(20)}

For another coordinate XyX_y, or a fixed number YY, and any fixed interval II of length aa,

P(Xx−Y∈I)≤(c+1)aWx.(21)\mathbb{P}(X_x - Y \in I) \le\frac{(c+1)a}{W_x}. \tag*{(21)}

In the coordinate case Y=XyY = X_y, independence is not assumed.

Proof. Fix all coordinates incomparable with xx. For almost every feasible fixing, the remaining region is a positive-volume convex region on xx and its cc comparable labels, and the conditional law is uniform there.

Crucially, the available interval of xx is still (ℓx,rx)(\ell_x, r_x). A new lower bound from a fixed outside label could reach xx only along a directed path from that label to xx; a new upper bound would require the reverse path. Both contradict incomparability. This is also seen directly by propagating the new fixed bounds. Apply theorem A.1 in dimension c+1c + 1, then average over the fixed outside coordinates. This gives (19)–(20).

If yy is incomparable with xx, it was fixed in this conditioning, so the projection Xx−XyX_x-X_y has width WxW_x. The same is true for a fixed number YY.

If yy is a successor of xx, its upper endpoint ryr_y is unchanged by fixing the outside labels: an outside upper bound propagating to yy would also make that outside label a successor of xx. Fix yy at a feasible value within δ\delta of ryr_y. By theorem 3.1, xx can then range over

(ℓx,min⁡(rx,Xy)),(\ell_x,\min(r_x,X_y)),

of width at least Wx−δW_x-\delta, since ry≥rxr_y\ge r_x. Thus the projection Xx−XyX_x-X_y of the conditional region has width at least WxW_x, on letting δ↓0\delta\downarrow0. For a predecessor, fix yy within δ\delta of its unchanged lower endpoint and argue symmetrically. The upper part of theorem A.1, now for the linear coordinate Xx−XyX_x-X_y, bounds its conditional density by (c+1)/Wx(c+1)/W_x. Integrate over II and then over the outside coordinates to obtain (21).

Taking I=[−z,z]I=[-z,z] gives P(∣Xx−Xy∣≤z)≤2(c+1)z/Wx\mathbb{P}(|X_x-X_y|\le z)\le2(c+1)z/W_x. The claim is for a difference of coordinates or a fixed threshold. It does not assert the same bound for an arbitrary interval chosen as an arbitrary function of all other coordinates.

A useful interval between middle quantiles

We need one shape fact. A positive function ff is log-concave if

f((1−λ)a+λb)≥f(a)1−λf(b)λ(0≤λ≤1).f((1-\lambda)a+\lambda b)\ge f(a)^{1-\lambda}f(b)^\lambda\qquad(0\le\lambda\le1).

It has no downward valley between two values. The following specialized proof keeps the argument self-contained.

Lemma A.3 (Shape of a coordinate density). A coordinate density in our interval-and-arrow region is positive and continuous on its effective interval and is log-concave there.

Proof. Let S(t)S(t) be its unnormalized section volume at Xx=tX_x=t. Positivity follows from theorem 3.1. Take feasible assignments p,qp,q with px=t−δp_x=t-\delta, qx=t+δq_x=t+\delta, and put h=q−δh=q-\delta in every coordinate. Both p,hp,h satisfy the strict arrows, although hh need not satisfy the original intervals.

Join the endpoints of an arrow u→vu\to v in an undirected graph when

max⁡(pu,hu)≥min⁡(pv,hv).\max(p_u,h_u)\ge\min(p_v,h_v).

On any such edge, h−ph-p is nonzero and has the same sign at both ends. Otherwise strict increase of pp or hh would give the reverse inequality. At xx the sign is positive, so h>ph>p throughout its connected component. Swap p,hp,h on this component, and then add δ\delta back to the second assignment. Both resulting assignments have coordinate tt at xx.

Within the swapped component, au<pu<hu=qu−δ<bu−δa_u<p_u<h_u=q_u-\delta<b_u-\delta, so both outputs obey the original intervals. Across its boundary, either choice at either endpoint obeys the arrow by the definition of the component. Internal arrows are preserved as well.

The map is injective: subtract δ\delta from the second output. The unordered coordinate pairs are unchanged, so they reconstruct the same graph and component and tell us which swap to reverse. On each piece of its domain the map permutes coordinates and adds constants, preserving volume in the two sections. Hence

S(t−δ)S(t+δ)≤S(t)2.S(t-\delta)S(t+\delta)\le S(t)^2.

Section volume is continuous in the interior: moving tt changes feasibility only in finitely many slabs whose widths tend to zero, inside a bounded box. Iterating the midpoint inequality and using continuity gives log-concavity. Normalization by the fixed total volume preserves it.

Lemma A.4 (Middle mass gives a reliable interval). Suppose a local cumulative probability F^\widehat{F} is within 1/321/32 of the true cumulative probability FF at every threshold. Choose a,ba,b with

F^(a)∈[7/32,9/32],F^(b)∈[23/32,25/32].\widehat{F}(a) \in[7/32,9/32], \qquad\widehat{F}(b) \in[23/32,25/32].

Then a<ba < b are strictly interior, and, with m=b−am=b-a,

fX(t)≥116m(a≤t≤b).f_X(t) \ge\frac{1}{16m} \qquad(a \le t \le b).

Proof. The true cumulative values lie respectively in [3/16,5/16][3/16,5/16] and [11/16,13/16][11/16,13/16]. The local and full supports at xx are the same: the local region retains the effective interval and contains every restriction of a full feasible assignment. Thus a,ba,b are interior. The mass between them is at least 3/83/8, so some t∈[a,b]t \in[a,b] has fX(t)≥3/(8m)f_X(t) \ge3/(8m).

Suppose fX(a)<1/(16m)f_X(a) < 1/(16m). Then t>at>a, and the secant slope of ln⁡fX\ln f_X from aa to tt exceeds ln⁡6/m\ln6/m. Concavity implies, for u<au<a in the support,

fX(u)≤fX(a)exp⁡(−(a−u)ln⁡6/m).f_X(u) \le f_X(a)\exp\left(-(a-u)\ln6/m\right).

Integration gives F(a)≤mfX(a)/ln⁡6<1/(16ln⁡6)<3/16F(a) \le mf_X(a)/\ln6 < 1/(16\ln6) < 3/16, a contradiction. Reflecting the coordinate proves the same lower bound at bb. Log-concavity gives at least the smaller endpoint density throughout [a,b][a,b].

This argument needs no separate log-concavity theorem for cumulative probabilities or tails.

For the stated bisection bound in Lemma 4.2, apply theorem A.1 directly to the b0b_0-dimensional local region. Its marked density is at most b0/Wxb_0/W_x. Bisect the original effective interval, stopping when the reported cumulative value is within 1/321/32 of the target 1/41/4 or 3/43/4. Until success, bracket endpoints have cumulative difference greater than 1/161/16. After rr failures, their distance is Wx/2rW_x/2^r, so the difference is at most b0/2rb_0/2^r. This is impossible for r=⌈log⁡(32b0)⌉+1r=\lceil\log(32b_0)\rceil+1. Each bisection adds at most one binary fractional digit. This proves Lemma 4.2 in full.

Why distant constraints have a small effect

We prove Theorem 4.1 independently of the recursive adversary. The proof uses random variables to compare two distributions; the algorithm itself executes only the finite table of Appendix § 13.

There are two ingredients. First, repeatedly refreshing a coordinate from its permitted interval causes two copies of the system to draw closer. Second, the density bound shows that small coordinate errors rarely change a comparison sign.

Two stationary experiments with shared random numbers

Start one experiment uniformly in the full feasible region and another uniformly in the retained neighborhood. These are mathematical distributions, not samples that the algorithm has to produce. The two starting points may have any joint coupling.

Visit vertices in a topological order. With all other coordinates fixed, the permitted values of XxX_x form an interval (a,b)(a,b), where

a=max⁡{ℓx,Xy:y→x},b=min⁡{rx,Xz:x→z}.a=\max\{\ell_x, X_y:y\to x\}, \qquad b=\min\{r_x, X_z:x\to z\}.

Replace XxX_x by (1−Ux)a+Uxb(1-U_x)a+U_xb, where UxU_x is a fresh uniform number in (0,1)(0,1). This is precisely the coordinate’s conditional uniform distribution. Resampling from a conditional distribution preserves the joint uniform law, so each experiment remains in its own original uniform distribution after every update.

Use the same fresh UxU_x in both experiments at a shared vertex. Restrict the full topological order to the neighborhood. Write Δx\Delta_x for the absolute discrepancy between the two copies. If every incident edge is retained, then

Δxnew≤(1−Ux)max⁡y→xΔynew+Uxmax⁡x→zΔzold.(22)\Delta_x^{\mathrm{new}} \le(1-U_x)\max_{y\to x}\Delta_y^{\mathrm{new}} + U_x\max_{x\to z}\Delta_z^{\mathrm{old}}. \tag*{(22)}

An empty maximum is zero. Taking a maximum with a common lower bound, or a minimum with a common upper bound, cannot increase a discrepancy.

The predecessor terms refer to new values because the sweep is topological. Expand them backward within that sweep. A predecessor chain contains at most hh vertices and eventually reaches a common fixed lower bound, whose discrepancy is zero.

Let AxA_x be the minimum of the fresh 1−U1-U values at xx and all its ancestors. The coefficient reaching the zero-discrepancy boundary is at least AxhA_x^h. The coefficients of all remaining old discrepancies sum to at most 1−Axh1-A_x^h, and those old discrepancies occur within distance hh. Thus

Δxnew≤(1−Axh)max⁡y∈Bh(x)Δyold.(23)\boxed{\Delta_x^{\mathrm{new}} \le(1-A_x^h)\max_{y\in B_h(x)}\Delta_y^{\mathrm{old}}.} \tag*{(23)}

Here Bh(x)B_h(x) is the undirected distance-hh ball. This expansion can follow whichever predecessor maximizes the discrepancy; AxA_x bounds all possible choices.

One moment contracts

Put

M=(d+1)h+1,a=14M2,p=(4M2)h⌈log⁡(4M)⌉.M=(d+1)^{h+1},\qquad a=\frac{1}{4M^2},\qquad p=(4M^2)^h\lceil\log(4M)\rceil.

Both the ball and the set of clocks defining AxA_x contain at most MM vertices. A union bound gives

P(Ax<a)≤Ma=14M.\mathbb{P}(A_x<a)\le Ma=\frac{1}{4M}.

On the complementary event,

(1−Axh)p≤(1−ah)p≤e−pah≤14M.(1-A_x^h)^p\le(1-a^h)^p\le e^{-pa^h}\le\frac{1}{4M}.

The last step uses pah=⌈log⁡2(4M)⌉≥ln⁡(4M)pa^h=\lceil\log_2(4M)\rceil\ge\ln(4M). It follows that

E[(1−Axh)p]≤12M.\mathbb{E}\left[(1-A_x^h)^p\right]\le\frac{1}{2M}.

Crucially, AxA_x uses only fresh clocks from this sweep; it is independent of the whole vector of old discrepancies. Raise (23) to the integer power pp, bound a maximum by a sum, and use that independence:

E[(Δxnew)p]≤12M∑y∈Bh(x)E[(Δyold)p]≤12max⁡y∈Bh(x)E[(Δyold)p].(24)\begin{aligned} \mathbb{E}\left[(\Delta_x^{\mathrm{new}})^p\right]\le\frac{1}{2M}\sum_{y\in B_h(x)}\mathbb{E}\left[(\Delta_y^{\mathrm{old}})^p\right] \\ &\le\frac{1}{2}\max_{y\in B_h(x)}\mathbb{E}\left[(\Delta_y^{\mathrm{old}})^p\right]. \tag*{(24)} \end{aligned}

This is the whole contraction argument. The large power pp makes near-failures of contraction sufficiently rare to compensate for the possible neighbors.

Choose the radius so the boundary cannot interfere

Use the explicit constants

C=M+1,u=ε16C,C = M + 1,\qquad u = \frac{\varepsilon}{16C},
λ=⌈log⁡(R/u)⌉,μ=⌈log⁡(8/ε)⌉,\lambda= \lceil\log(R/u)\rceil,\qquad\mu= \lceil\log(8/\varepsilon)\rceil,
t=pλ+μ,ρ=ht.t = p\lambda+ \mu,\qquad\rho= ht.

These are computable using integer comparisons with powers of two.

For a marked vertex x∗x_\ast, apply (24) at sweep jj only to vertices within distance h(t−j)h(t-j) of x∗x_\ast. Their required hh-balls lie in the preceding interior. The predecessor expansion uses at most h−1h-1 predecessor edges followed by one incident edge, so all needed edges are retained. This explains the radius htht.

Both copies of an initially retained coordinate lie in its original effective interval. In the marked vertex’s original component, initial discrepancies are therefore at most RWx∗RW_{x_\ast}. Induction using (24) gives

E[Δx∗(t)p]≤2−t(RWx∗)p.\mathbb{E}[\Delta_{x_\ast}(t)^p] \le2^{-t}(RW_{x_\ast})^p.

For a nonnegative random variable YY, the inequality P(Y>a)≤E[Yp]/ap\mathbb{P}(Y>a) \le\mathbb{E}[Y^p]/a^p follows by integrating Yp≥apY^p \ge a^p on that event. Apply it here:

P(Δx∗(t)>uWx∗)≤2−t(R/u)p≤2−μ≤ε/8.(25)\mathbb{P}(\Delta_{x_\ast}(t)>uW_{x_\ast}) \le2^{-t}(R/u)^p \le2^{-\mu} \le\varepsilon/8. \tag*{(25)}

For two marked vertices, use this estimate for each one’s component and width. The components may differ; independence of the two error events is unnecessary. An isolated coordinate can simply start at the same uniform value in both experiments.

From coordinate error to comparison error

Every mark has at most MM comparable vertices. The dependent-difference estimate (21) therefore applies with the constant C=M+1C=M+1.

Outside the two exceptional events in (25), different signs of Xx−XyX_x-X_y in the two experiments require

∣Xx−Xy∣≤u(Wx+Wy)≤2umax⁡(Wx,Wy).|X_x-X_y| \le u(W_x+W_y) \le2u\max(W_x,W_y).

Use (21) at the endpoint of larger width. The interval for the difference has length at most 4umax⁡(Wx,Wy)4u\max(W_x,W_y), so its probability is at most 4Cu=ε/44Cu=\varepsilon/4. The two exceptional events have total probability at most ε/4\varepsilon/4. Thus sign disagreement has probability at most ε/2\varepsilon/2, which is more than sufficient. A threshold comparison uses one exceptional event and a shorter interval.

Because both experiments preserve their original laws, a bound on disagreement is a bound on the difference of their probabilities. This proves locality.

The local region has positive volume: restricting any full feasible assignment gives a local one. Its marked effective support is unchanged, because the old effective interval is retained explicitly and every value in it occurs in some full assignment. A degree-dd radius-ρ\rho neighborhood of two marks contains at most 2(d+1)ρ+12(d+1)\rho+1 vertices. This completes the geometric part of Theorem 4.1.

Exact local calculation: which coordinate comes last?

The local problem has bb coordinates. We give a finite exact calculation that uses just subsets, polynomial integration, and integer arithmetic. It does not first count linear extensions.

A recurrence for every subset

For each subset SS of the local vertices, let FS(t)F_S(t) be the volume of assignments to SS that respect their own intervals, the arrows with both endpoints in SS, and Xx<tX_x < t for all x∈Sx \in S. Set F∅(t)=1F_{\varnothing}(t) = 1.

For nonempty SS, almost every assignment has a unique largest coordinate. If it belongs to vv, there can be no arrow v→wv \to w with w∈S∖{v}w \in S \setminus\{v\}. Call such a vv a sink of the induced graph on SS. Once Xv=uX_v = u is the largest value, every incoming arrow to vv holds automatically. The remaining assignments have volume FS∖{v}(u)F_{S\setminus\{v\}}(u). Therefore

FS(t)=∑v∈Sv a sink in S∫avmin⁡(t,bv)FS∖{v}(u) du,(26)F_S(t) = \sum_{\substack{v \in S \\ v\text{ a sink in }S}} \int_{a_v}^{\min(t,b_v)} F_{S\setminus\{v\}}(u)\,\mathrm{d}u, \tag*{(26)}

where a term is zero when t≤avt \le a_v.

Sort all interval endpoints. On an open segment between consecutive endpoints, the set of intervals containing that segment is fixed. Differentiating (26) on this segment gives

FS′(t)=∑v a sink in S(av,bv) contains the segmentFS∖{v}(t).(27)F'_S(t) = \sum_{\substack{v\text{ a sink in }S \\ (a_v,b_v)\text{ contains the segment}}} F_{S\setminus\{v\}}(t). \tag*{(27)}

This is the whole recurrence. At the smallest endpoint, every nonempty subset has volume zero. On each segment, compute the polynomials in increasing subset size and carry their values to the next segment. Their degrees are at most ∣S∣|S|. At the largest endpoint, FVF_V is the required full volume.

Computing all subsets avoids extra terminology or data structures: no downward-closed-set test and no transitive closure are required. Each subset is simply its own induced-graph problem.

An all-integer implementation

Scale all dyadic endpoints by 2Λ2^\Lambda, making them integers. At a segment’s left endpoint aa, store

QS=∣S∣!FS(a).Q_S = |S|! F_S(a).

These values start as integers. For r=∣S∣r = |S|, compute coefficients

CS,0=QS,C_{S,0} = Q_S,
CS,k=∑v a sink in Sv accepts this segmentCS∖{v},k−1,1≤k≤r.(28)C_{S,k} = \sum_{\substack{v\text{ a sink in }S \\ v\text{ accepts this segment}}} C_{S\setminus\{v\},k-1}, \qquad1 \le k \le r. \tag*{(28)}

The invariant is

CS,k=(r−k)!FS(k)(a+).C_{S,k} = (r-k)!F_S^{(k)}(a+).

It follows inductively from (27). If the segment length is the integer Δ\Delta, the update to its right endpoint is

QSnew=∑k=0r(rk)CS,kΔk.(29)Q_S^{\mathrm{new}} = \sum_{k=0}^{r} \binom{r}{k} C_{S,k}\Delta^k. \tag*{(29)}

Thus all operations are integer additions and multiplications. At the end, the original unscaled volume is

QVb! 2Λb.\frac{Q_V}{b!\,2^{\Lambda b}}.

There are at most 2b2^b subsets, bb coefficients per subset, bb summands per coefficient, and O(b)O(b) endpoint segments. Precompute outgoing-neighbor masks to test sinks, binomial coefficients, and the powers of each segment length. The total is O(b32b)O(b^3 2^b) arithmetic operations.

If original endpoints lie in [0,K][0,K], put N=max⁡{1,2ΛK}N=\max\{1,2^{\Lambda K}\}. Expanding the deletion recurrence bounds

0≤CS,k≤r!Nr−k,0≤QS≤r!Nr.0 \le C_{S,k} \le r!N^{r-k}, \qquad0 \le Q_S \le r!N^r.

The entries therefore have

O(b(Λ+log⁡(K+1)+log⁡(b+1)))O\bigl(b(\Lambda+\log(K+1)+\log(b+1))\bigr)

bits. This justifies the bit bound used in Section 8.

For a comparison numerator, add its arrow and repeat the table; a directed cycle gives zero. For a threshold numerator, shorten the marked coordinate’s upper interval bound and repeat. Use a common coordinate scale for numerator and denominator; it cancels in their ratio. For all thresholds use the same original local region as denominator. The estimates then form one actual cumulative distribution, as required for quantile bisection.

A small example

With two independent coordinates in (0,1)(0,1),

F{A}(t)=F{B}(t)=t,F{A,B}′(t)=2t,F_{\{A\}}(t)=F_{\{B\}}(t)=t,\qquad F'_{\{A,B\}}(t)=2t,

so the area is F{A,B}(1)=1F_{\{A,B\}}(1)=1. With the arrow A→BA\to B, only BB can be last:

F{A,B}′(t)=F{A}(t)=t,F{A,B}(1)=12.F'_{\{A,B\}}(t)=F_{\{A\}}(t)=t,\qquad F_{\{A,B\}}(1)=\frac{1}{2}.

The recurrence is the elementary triangle calculation repeated over subsets and interval segments.

References

  1. [1]Gerth Stølting Brodal, Shiva Chaudhuri, and Jaikumar Radhakrishnan. The randomized complexity of maintaining the minimum. Nordic Journal of Computing 3(4), 337–351, 1996. The binary adversary and its interval interpretation are reviewed in Section 2 and the introduction of [2].DOI
  2. [2]Haim Kaplan, Or Zamir, and Uri Zwick. A sort of an adversary. Proceedings of the Thirtieth Annual ACM–SIAM Symposium on Discrete Algorithms (SODA), 1291–1310, 2019. doi:10.1137/1.9781611975482.79. The discussion of continuous intervals and richer dependencies is in Section 6.DOI
  3. [3]Richard P. Stanley. Two poset polytopes. Discrete & Computational Geometry 1, 9–23, 1986. doi:10.1007/BF02187680. Author’s copy.DOI
  4. [4]Nicholas Nash. Sorting adversaries in Lean. Lean 4 source repository, 2026. https://github.com/nicknash/sorting-adversary-proofs. Source snapshot 15d93dd, accessed 7 November 2026.

Paper details

vlnc:W_rsnk3d82
v1 · latestHistory (1)

published · Fresh — published within the last 30 days

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Computer Science

OpenAI ChatGPT GPT 6 Astra · View statement →

Looking for related papers…
Contents