WorksComputer Science
An Optimal Deterministic Adversary for Sorting
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 comparisons. The best previously known adversary forced 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 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, , while denotes the natural logarithm. The cases are immediate; assume , and put
The objective is an efficient deterministic adversary that forces almost 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 and 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 and at the same node, this rule can place on the left and on the right. That representation also commits to the cross-relations and . 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 , the corresponding dyadic subintervals are disjoint, so
This is Kraft’s inequality. Convexity of gives
Each query increases total depth by at most two. Thus at least 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 and 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 [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
we can retain all four items in one node, with just the indicated constraints and their consequences:

Figure 1. One group; no spatial separation yet
Each item has a tentative real position. An arrow means . 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 , with a fixed polynomial bound on the number of bit operations per comparison, that forces every correct comparison sorter to make
comparisons. The term tends to zero as .
Merge sort uses at most 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 in an open interval . Directed arrows between free items impose . 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 , the intervals and arrows define
Write . This is the volume of a constrained region, not generally the product of interval lengths. For example, two coordinates in give a square of area ; the constraint leaves a triangle of area .
Our auxiliary quantity is
Different nodes have separate coordinates, so their volumes multiply. A node with no free coordinates contributes . Initially there is only the root, all intervals are , and . 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 and , consider
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 .
An estimate with suffices. Answer if , and otherwise. The chosen region has at least of the old volume. When one representation is an anchor , use the same rule with a threshold event .
Subroutine 1: estimate On a suitably maintained graph, return a deterministic additive- 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 for a free item . Fix , remove from the parent’s free graph, and turn its incident arrows into interval restrictions on their other endpoints. For instance,
The strict comparisons remain true.
Then admit to the child anchored at , creating that child if necessary. If this is the child’s -th admission, give a fresh, independent coordinate in . Leave every old child coordinate, interval, arrow, and anchor unchanged.

Figure 2.3.
Here counts all admissions, including items that later move to grandchildren. If is the density of the parent coordinate at , this operation satisfies the exact identity
The parent loses one dimension by taking a section; the child gains one dimension of length . Thus total dimension remains .
For intuition, in the triangle , the section at has length , so . If a child at position already contains one item, fixing there and admitting it as the second item gives factor : 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 . 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- majority estimate with . No separate public-order safety test is needed.
Effective intervals
Propagate lower bounds along arrows and upper bounds against them. Writing when or a directed path leads from to , define
The interval is the coordinate’s effective interval. Store these tightened bounds permanently, including after arrows are removed. Along , both and .
Lemma 3.1 (Interior fixing). For an acyclic arrow graph, the feasible region has positive volume if and only if every . Every is feasible for , and fixing it leaves a positive-volume section in the remaining coordinates.
Proof. Necessity is immediate. For sufficiency, choose numbers increasing in a topological order, a listing in which every arrow points forward, and put
This expression increases with either endpoint and strictly with when . 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 at interior , only predecessors get smaller upper bounds and only successors get larger lower bounds. A predecessor still has upper bound at least , since . 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 is incomparable in the public transcript with every existing item in the child at . It may enter that child as an isolated coordinate, and (2) holds.
Proof. Choose a point in the positive-volume parent section at which every other free coordinate is distinct from and from all anchors. Move 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 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 .
Any new position of among the old child items is legal: comparisons among old labels are unchanged, there were no answered comparisons between and those child labels, and ’s relations to all outside blocks are the same as in the two surrounding orders.
Let be the parent section volume. By the definition of coordinate density, . Fixing replaces by ; the new independent child coordinate multiplies its volume by . 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 . These gains must not be discarded in the accounting.
A fixed rule for the anchor
Suppose a closed interval has density at least throughout. Choose the unique power of two such that
The cell lies inside ; its midpoint is strictly inside . Consequently
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 at two different powers 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 , a rational ratio , and rational . There is a computable radius with the following property.
Let be a positive-volume interval-and-arrow region whose graph has degree at most and height at most . In every component, suppose the largest effective width is at most times the smallest. For one or two queried coordinates, retain the induced graph within distance , together with the original effective intervals.
The resulting local probabilities approximate and to additive error at most . The same local region works for every threshold . It has at most
vertices. Its probabilities are calculated exactly using 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 has at most other comparable vertices and effective interval of width .
Its density satisfies . On
it satisfies . This window needs no probability calculation.
Given local cumulative probabilities accurate to , one can find dyadic , strictly inside the effective interval, with and
If the local region contains vertices, each endpoint requires at most bisections.
Appendix § 11 proves this lemma. Applied to the rounding rule, the quantile window gives
The central window gives , and hence
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 , each coordinate order occupies volume , where is the graph size. Thus the region’s volume is , 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 comparisons and refinements. Index the refinement events by ; one item can be refined several times. If event fixes at in a cell of length , assume
The ordinary window has ; the emergency central window has .
Theorem 5.1 (Rare refinements suffice). Suppose each comparison retains at least of , or loses nothing, and there are at most further private cuts, each retaining at least , where . Then
For , the last term means zero. In particular,
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 be the final number of items ever admitted to node , and the number remaining free there. For a child of , write . Every label visits a node at most once. Consequently
All coordinates at lie in : root intervals started in , and later admissions received with .
Define the group-size budget
For one original label visiting nodes of final sizes , its terms telescope to . Therefore
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 has ideal information cost , and a branch to an individual terminal item costs . Every full item path then has cost exactly . Thus
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 refinements at one parent, entering distinct children, contributes at least through its own refinement events to .
Proof. If the children’s final sizes are , then . The arithmetic–geometric mean inequality gives , or .
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 , cells and 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 in a parent of final size , put
There is one dyadic cell length at each scale number . At that length, at most cells fit in . Hence
Thus the weights satisfy Kraft’s inequality. The ideal description length is
For a literal prefix-free code on the finite set of used children, set . Their Kraft sum is at most one. Sort these integers increasingly and place consecutive dyadic intervals of lengths inside . 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 -th admission to a child, the refinement identity supplies a factor . Across its admissions this is , even if that child answers comparisons between arrivals. Therefore the total logarithmic refinement loss satisfies
Here , obtained by comparing with , and .
Set . Kraft gives
For , concavity of log, with weights , yields
Consequently
If , it already improves our desired upper bound. Otherwise, observe that
The average scale number, over refinement events, is therefore at most . A second use of concavity bounds all scale headers:
This and (11) cover both signs of . Substituting into (9) proves
One way to read this proof is , where 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 .
The endpoint is now a one-line estimate
When the transcript determines a total order, the free coordinates at a node must occur in one prescribed order. They all lie in . Thus
The second inequality uses one term of the exponential series. Multiplication over nodes uses . No multinomial calculation is needed.
Each comparison costs at most , and each private cut at most . For , their combined cost is at most , using for .
Starting at , add these costs, (12), and (13). The inequalities and prove (5). When , the endpoint estimate alone gives the stated weaker bound. Finally, with ,
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 , , and . Between queries, require degree below and height below . 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
The distance- ball contains at most vertices, so in particular each vertex has at most comparable vertices. Set
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 has . Impose the stronger bound , and remove the arrow. Since , every remaining assignment still satisfies .
How much is lost? Along the arrow, . The discarded part of ’s effective interval therefore has length at most . By the density upper bound, its probability is at most
The new interval is positive, because
A predecessor whose upper bound decreases still has lower bound at most ; propagation stays feasible.
Symmetrically, when , impose 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 cuts.
Width repair: separate a batch of very different scales
Suppose no edge cut applies, but one component’s largest width exceeds times its smallest width . Adjacent widths have ratio at most . Along a path from a minimum-width vertex to a maximum-width vertex, mark the first vertex reaching width , for . The marked widths lie in
Successive marked widths therefore differ by a factor at least
Any two marked vertices have distance greater than : a path of length at most would bound their width ratio by .
Refine these 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 . The chosen vertices’ widths are therefore unchanged until they are processed.
Their selected cell lengths belong to . The marked widths differ by more than a factor four, so the cell lengths differ. Distinct scales have distinct midpoints. Thus the batch enters distinct children.
Call these scale refinements. Each pays surcharge . 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 .
Graph repair: high degree or a long directed path
After width repair, the numerical theorem is available with the safe bounds , , .
If a vertex has degree at least , 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 vertices, mark consecutive vertices. Finish this marked batch before selecting another path:
Repair widths before each ordinary refinement.
If a marked item remains free, refine it using its quantile window.
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 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 and count ordinary and scale refinements. Then
High degree is paid for by already asked comparisons. A degree refinement deletes at least current edges. Deleted edges cannot be deleted again; every edge was introduced by an actual query at that node. Thus there are at most degree refinements.
Long paths and separated scales spend the tree budget. Each marked path sends items into different children. By Lemma 5.2, its refinement events contribute at least to . Different marked paths at one node use disjoint refinement events, so at most ordinary path refinements occur.
Each scale batch similarly contributes at least , and scale batches use disjoint refinement events. Hence
A path batch can overlap a scale batch. This causes no double charge in either separate estimate: each family uses its own application of . 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
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 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 , use
Compute , as above, and set
Then compute , , from (14), and the radius supplied by Theorem 4.1. Since , the same radius is sufficient for the quantile calculations. Let
be the corresponding neighborhood-size bound.
On a completed run with , (15) gives
Thus, as the selected stage tends to infinity, , , and . The coding bound (5) then gives . Runs with 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 .
During initialization, spend at most bit operations computing successive stages. Keep the largest fully computed stage satisfying
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 selected in this way tends to infinity.
Every local calculation then uses coordinates. Appendix § 13 uses 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 . A quantile search adds only 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 queries, (16) therefore gives
All coordinates lie in . The exact local table uses integers with
bits. Thus the arithmetic bit cost is polynomial as well. There are at most nodes and at most edge introductions. Stage descriptions have at most bits, by the initialization budget.
After 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 , triangle densities, and the refinement identity . 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 dimensions. Suppose a nonconstant linear coordinate ranges over , of width
. Its probability density satisfies
For every , it also satisfies
Proof. Use a linear change of variables making the first coordinate. Its constant volume factor cancels in densities. Write for section volume and for total volume.
Join the section at to feasible points with first coordinates approaching and . Convexity puts both cones inside the region. A section of a cone shrinks in its free directions by a common factor, so the two cone volumes tend to
Thus , proving (17). For the distribution is uniform and both assertions are immediate.
There is an interior with , or a sequence approaching this bound. For , join this section toward the upper endpoint. At , the scale factor tends to . Hence . Use the lower endpoint when and take limits if needed. This proves (18). □
This proof uses only convexity and the integral , not a general theorem about log-concave measures.
Why the relevant dimension is small
Lemma A.2 (Condition on the incomparable labels). Let have other comparable labels in the active graph and effective interval of width . Then
For another coordinate , or a fixed number , and any fixed interval of length ,
In the coordinate case , independence is not assumed.
Proof. Fix all coordinates incomparable with . For almost every feasible fixing, the remaining region is a positive-volume convex region on and its comparable labels, and the conditional law is uniform there.
Crucially, the available interval of is still . A new lower bound from a fixed outside label could reach only along a directed path from that label to ; 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 , then average over the fixed outside coordinates. This gives (19)–(20).
If is incomparable with , it was fixed in this conditioning, so the projection has width . The same is true for a fixed number .
If is a successor of , its upper endpoint is unchanged by fixing the outside labels: an outside upper bound propagating to would also make that outside label a successor of . Fix at a feasible value within of . By theorem 3.1, can then range over
of width at least , since . Thus the projection of the conditional region has width at least , on letting . For a predecessor, fix within of its unchanged lower endpoint and argue symmetrically. The upper part of theorem A.1, now for the linear coordinate , bounds its conditional density by . Integrate over and then over the outside coordinates to obtain (21).
Taking gives . 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 is log-concave if
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 be its unnormalized section volume at . Positivity follows from theorem 3.1. Take feasible assignments with , , and put in every coordinate. Both satisfy the strict arrows, although need not satisfy the original intervals.
Join the endpoints of an arrow in an undirected graph when
On any such edge, is nonzero and has the same sign at both ends. Otherwise strict increase of or would give the reverse inequality. At the sign is positive, so throughout its connected component. Swap on this component, and then add back to the second assignment. Both resulting assignments have coordinate at .
Within the swapped component, , 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 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
Section volume is continuous in the interior: moving 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 is within of the true cumulative probability at every threshold. Choose with
Then are strictly interior, and, with ,
Proof. The true cumulative values lie respectively in and . The local and full supports at are the same: the local region retains the effective interval and contains every restriction of a full feasible assignment. Thus are interior. The mass between them is at least , so some has .
Suppose . Then , and the secant slope of from to exceeds . Concavity implies, for in the support,
Integration gives , a contradiction. Reflecting the coordinate proves the same lower bound at . Log-concavity gives at least the smaller endpoint density throughout .
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 -dimensional local region. Its marked density is at most . Bisect the original effective interval, stopping when the reported cumulative value is within of the target or . Until success, bracket endpoints have cumulative difference greater than . After failures, their distance is , so the difference is at most . This is impossible for . 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 form an interval , where
Replace by , where is a fresh uniform number in . 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 in both experiments at a shared vertex. Restrict the full topological order to the neighborhood. Write for the absolute discrepancy between the two copies. If every incident edge is retained, then
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 vertices and eventually reaches a common fixed lower bound, whose discrepancy is zero.
Let be the minimum of the fresh values at and all its ancestors. The coefficient reaching the zero-discrepancy boundary is at least . The coefficients of all remaining old discrepancies sum to at most , and those old discrepancies occur within distance . Thus
Here is the undirected distance- ball. This expansion can follow whichever predecessor maximizes the discrepancy; bounds all possible choices.
One moment contracts
Put
Both the ball and the set of clocks defining contain at most vertices. A union bound gives
On the complementary event,
The last step uses . It follows that
Crucially, uses only fresh clocks from this sweep; it is independent of the whole vector of old discrepancies. Raise (23) to the integer power , bound a maximum by a sum, and use that independence:
This is the whole contraction argument. The large power 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
These are computable using integer comparisons with powers of two.
For a marked vertex , apply (24) at sweep only to vertices within distance of . Their required -balls lie in the preceding interior. The predecessor expansion uses at most predecessor edges followed by one incident edge, so all needed edges are retained. This explains the radius .
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 . Induction using (24) gives
For a nonnegative random variable , the inequality follows by integrating on that event. Apply it here:
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 comparable vertices. The dependent-difference estimate (21) therefore applies with the constant .
Outside the two exceptional events in (25), different signs of in the two experiments require
Use (21) at the endpoint of larger width. The interval for the difference has length at most , so its probability is at most . The two exceptional events have total probability at most . Thus sign disagreement has probability at most , 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- radius- neighborhood of two marks contains at most vertices. This completes the geometric part of Theorem 4.1.
Exact local calculation: which coordinate comes last?
The local problem has 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 of the local vertices, let be the volume of assignments to that respect their own intervals, the arrows with both endpoints in , and for all . Set .
For nonempty , almost every assignment has a unique largest coordinate. If it belongs to , there can be no arrow with . Call such a a sink of the induced graph on . Once is the largest value, every incoming arrow to holds automatically. The remaining assignments have volume . Therefore
where a term is zero when .
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
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 . At the largest endpoint, 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 , making them integers. At a segment’s left endpoint , store
These values start as integers. For , compute coefficients
The invariant is
It follows inductively from (27). If the segment length is the integer , the update to its right endpoint is
Thus all operations are integer additions and multiplications. At the end, the original unscaled volume is
There are at most subsets, coefficients per subset, summands per coefficient, and endpoint segments. Precompute outgoing-neighbor masks to test sinks, binomial coefficients, and the powers of each segment length. The total is arithmetic operations.
If original endpoints lie in , put . Expanding the deletion recurrence bounds
The entries therefore have
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 ,
so the area is . With the arrow , only can be last:
The recurrence is the elementary triangle calculation repeated over subsets and interval segments.
References
- [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]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]Richard P. Stanley. Two poset polytopes. Discrete & Computational Geometry 1, 9–23, 1986. doi:10.1007/BF02187680. Author’s copy.DOI
- [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.