Jonathan R. Landers, 2026
This repository accompanies the manuscript Sorting as Gradient Flow on the Permutohedron. The paper treats sorting as directed motion through permutation space: adjacent swaps walk along edges of the permutohedron, comparison half-spaces shrink the set of feasible order types, and a continuous flow moves directly toward the sorted vertex
The continuous model begins with a quadratic measure of rank displacement, whose ambient gradient points straight toward the sorted state:
Solving this linear flow gives exact exponential contraction, so the farthest starting point determines the maximal time to reach a fixed Euclidean threshold
The permutohedron has
The decision-tree argument remains the computational proof that
Live project page: https://jonland82.github.io/sorting-as-gradient-flow/
Code repository: https://github.com/jonland82/sorting-as-gradient-flow
The GitHub Pages entry point is index.html. It gives an intuitive project-page version of the paper: the decision-tree lower bound supplies the information scale, the permutohedron supplies the geometry, and the paper's ambient gradient-flow formulation supplies the continuous relaxation that makes contraction visible.
-
sorting_as_gradient_flow.pdfLaTeX manuscript for the project. -
flattening_entropy.pdfIn-progress companion manuscript. It extends the sorting geometry story toward algorithms as geodesics and preprocessing as partial curvature or entropy removal.
sorting-as-gradient-flow_paper-figures.pyFigure-generation script for the manuscript.
Sorting starts with a factorial search space. For distinct inputs, there are
possible order types. A deterministic comparison sorter can be modeled by a binary decision tree, so a correct tree must have at least the factorial number of leaves. A binary tree of height h has at most that many leaves only if
and therefore
The paper places this familiar lower bound inside the geometry of the permutohedron. Let
be the sorted rank word. The permutohedron is
Its vertices are rank words. Adjacent transpositions are edges of the 1-skeleton, so adjacent-swap algorithms move locally from vertex to vertex. That local geometry resolves inversions one at a time and naturally gives the quadratic regime. The same quadratic potential used by the continuous flow decreases strictly under every inversion-removing adjacent swap.
General comparisons act differently. Comparisons occur between current positions, but their outcomes must be recorded in a common coordinate frame. If positions
Each outcome selects a half-space in fixed original-item coordinates. A sorting algorithm therefore does not merely walk the polytope; it repeatedly cuts the feasible candidate rank maps until one vertex remains. This is the geometric version of the decision-tree story: comparison information collapses the feasible set.
The continuous part of the paper introduces the potential
whose ambient Euclidean gradient flow is
The solution contracts exactly:
so that
This is the manuscript's central modeling move. It is not claimed to be the literal path of a discrete sorting algorithm; it is a relaxation that puts local walks, global comparison constraints, and straight-line rank-displacement contraction inside one frame.
For a Euclidean threshold
For every fixed
Equivalently,
To compare it with classical sorting, let
The classical bounds give
The relationship between constraint geometry and the ambient flow is especially simple. If a closed convex metric constraint
contains the sorted vertex
Thus the projected flow agrees with the ambient flow whenever the target remains feasible. Comparison half-spaces should be read as describing information reduction, while the Euclidean flow separately measures metric contraction. If a metric constraint excludes
The companion manuscript develops the broader idea that computational models induce geometries on state space. In that language, a lower bound is a geometric obstruction to flattening the problem inside the permitted model.
Counting sort is treated as a literal flattening in histogram coordinates. Comparison sorting carries flattening entropy
Ordered bucketization removes an exact multinomial block of entropy. If the bucket occupancies are
the flattening gain is
and the residual within-bucket comparison entropy is
Radix sorting appears as the iteration of this partial-flattening principle: each ordered pass removes another layer of residual entropy until the comparison problem has been trivialized.
The supporting proof_verification_suite/ provides reproducible checks for the paper's principal mathematical claims. Install its small scientific-Python dependency set and run every check from the repository root:
python -m pip install -r proof_verification_suite/requirements.txt
python proof_verification_suite/run_all.pyThe suite checks the decision-tree bound, permutohedron affine geometry, fixed-coordinate comparison histories, adjacent-swap potential descent, the exact gradient-flow solution and contraction law, reverse-permutation distance and diameter, subset-sum constraints, braid hyperplanes, and target-feasible tangent-cone projection. See proof_verification_suite/README.md for the claim-by-claim coverage table and commands for running individual scripts.
Symbolic identities are checked exactly. Exhaustive permutation checks cover explicitly documented finite ranges, while numerical optimization checks use a fixed random seed and floating-point tolerances. Those numerical experiments are diagnostics rather than formal proofs in arbitrary dimension, and the suite preserves the manuscript's distinction between comparison information and metric flow.
Archived materials are in old_draft/.