Edit Distance in l1: Matching Bounds up to Constants in the Exponent
Abstract
We determine the exponential scale of the least ℓ1 distortion of unit-cost edit distance on all strings of length at most d. For every sufficiently large d, uniformly over finite alphabets of size at least two, the distortion lies between and for absolute constants . The lower bound already holds on binary strings of one common length. Thus the order of logarithmic distortion is sharp up to absolute constants.
Introduction
We study how faithfully distances between strings can be represented by distances in . The distance on strings is ordinary edit distance: is the least number of single-symbol insertions, deletions and substitutions that transform into , with every operation costing one. An insertion or deletion changes the positions of an entire suffix. As a result, the distance depends on the best alignment of the two strings, and a useful representation must account for alignments over all scales.
For a finite alphabet and an integer , let be the set of all strings of length at most , including the empty string. The cap restricts the endpoints; intermediate strings in an edit script may have any length. Write for the real space of absolutely summable sequences and define
The infimum is over injective maps. It imposes no restriction on target dimension or on the cost of computing the map. Equivalently, an embedding has distortion at most when it can be rescaled so that every image distance lies between and .
Theorem 1.1. There are absolute constants and an integer such that, for every integer and every finite alphabet with ,
The lower bound is witnessed by a subset of binary strings of one common length at most . The same bounds hold for .
Logarithms are natural unless a base is specified. The constants and threshold in the theorem are independent of the alphabet, including when its size grows with . The conclusion determines the order of ; the constants in the exponent remain unspecified.
The earlier bounds
The single-symbol error model is classical. Levenshtein studied codes correcting insertions, deletions and substitutions [4], and Wagner and Fischer described edit scripts through increasing traces [10]. Their alignment language will be useful below: any lower bound must control every increasing matching of equal symbols, including matchings that cross the boundaries used to construct the strings.
Ostrovsky and Rabani [8] proved the upper scale in Theorem 1.1 for fixed-length binary strings by recursively comparing collections of overlapping substrings. They also noted extensions to larger alphabets and varying lengths. We use their fixed-length theorem and give complete reductions with constants uniform over all finite alphabets and with the empty string included.
For lower bounds, Andoni, Deza, Gupta, Indyk and Raskhodnikova [1] constructed binary subsets whose distortion approaches 3/2. Khot and Naor [2] obtained an lower bound by studying cuts and Fourier analysis of noisy shifts. Their insertion–deletion metric is within a factor of two of the convention used here. Krauthgamer and Rabani [3] then proved an lower bound for binary strings of length . The construction below reaches the scale of the Ostrovsky–Rabani exponent.
How the lower bound works
The construction joins a geometric fact about strings to an analytic fact about . At the geometric level, a word is a long list of rows. Each row contains a payload made of lower-level words, followed by a long marker consisting of a fresh symbol. The payload has fixed slots; each slot has its own alphabet tag, so different slots cannot match. The lower-level words depend on states. In each component, repeatedly adding one distinguished step cycles the state with a prime period; different components use different primes. Advancing every component by one state step shifts the row list by one, which costs only the deletion and insertion of one row.
Advancing the distinguished component behaves differently. We repeat that component in many separately tagged slots. For any proposed pair of rows, either those repeated slots remain separated or the row shift that aligns them leaves many of the other prime-period components separated. A global alignment can still send one source payload into several target rows. In that event, the matching skips a complete target marker: the source payload contains no copy of the marker symbol. The skipped markers for different payloads are disjoint. This turns the row comparison into a lower bound for arbitrary alignments.
The analytic comparison concerns the average image distance produced by a group displacement. Proposition 2.2 bounds the displacement in the distinguished component by the simultaneous step and the average component steps. The proof expresses a finite metric as a nonnegative sum of cut metrics, then expands each cut in Fourier characters. A character involving few components is detected by the simultaneous step: distinct prime denominators prevent its phase from being an integer. A character involving many components is detected by the sum of the component averages.
Relative to word length, the guaranteed pointwise separation decreases by a fixed factor at each level. Under the same normalization, the analytic inequality forces the allowed averaged image displacement to decrease much faster: after levels, the ratio between these two bounds is . Meanwhile, the logarithmic word length is . A delimiter code transfers the words to binary with a loss polynomial in , and choosing directly from the cap supplies a witness for every sufficiently large .
Section 2 proves the alignment facts and the prime-product displacement inequality. Section 3 builds the words and proves their separation and analytic recurrence together. Section 4 supplies the delimiter at the binary transfer and completes the parameter calculation. Section 5 derives the uniform upper bound by hashing the alphabet, padding to one binary length, and averaging over all hash maps.
The companion manuscripts on circle constructions [6] and tree constructions [7] give independent lower-bound mechanisms and additional binary coding results. No result from a companion manuscript is used; the upper bound uses the stated external theorem.
Alignments and a displacement inequality
The word construction will be measured first by insertion–deletion distance. Its advantage is that every possible comparison has a concrete description as an increasing matching. We then state the analytic inequality that will be applied at each level of the construction.
Distances from increasing matchings
Write for the minimum number of single-symbol insertions and deletions transforming into . An increasing matching is a list of pairs of equal-symbol positions, strictly increasing in both coordinates. Let be its maximum size. These are the classical trace and subsequence descriptions of string correction [10].
Lemma 2.1. For arbitrary finite strings, including the empty string,
For two strings of the same length , define their one-sided deficit by
A matching of size leaves exactly unmatched positions on each side.
Proof. An insertion–deletion script is an edit script, and replacing each substitution by one deletion and one insertion proves the two inequalities. Deleting the unmatched source positions in an increasing matching and inserting the unmatched target positions realizes its total loss . Conversely, the original positions that survive an insertion–deletion script form an increasing matching; its loss is at most the number of operations. Minimizing the loss gives the identity. The equal-length assertions follow directly.
The comparison to be proved
For a finite abelian group and a map , set
Every expectation over a finite set uses the uniform probability measure. The following proposition compares a shift in one component with a simultaneous shift and with shifts averaged inside the separate components. In the word construction, the simultaneous shift will move the row list by one; the component averages will be bounded at the preceding level.
Proposition 2.2 (Prime-product displacement inequality). Let be integers, let , and let be finite abelian groups. Suppose has order , where are distinct primes in . In , use the same notation for the element acting only in coordinate , and put . Then every and every integer satisfy
We prove the proposition after recording two elementary forms of the cut and Fourier methods. The cut representation is standard [5], Section 4. Its summability statement below permits an unrestricted sequence-space target.
Lemma 2.3 (Finite cut decomposition). Let be finite and . There are finite numbers , indexed by the nonempty proper subsets of , such that
Moreover,
where the right sum is over unordered pairs.
Proof. For all the sums are empty. Otherwise, for coordinate of , list its distinct values on as . Put
The consecutive gaps telescope:
Group all terms with the same cut by setting , initially allowing the value . Nonnegativity allows the coordinate series to be interchanged with the finite sum over unordered pairs. Hence
Each indexed cut separates at least one pair, so . The displayed equality proves that all the weights are finite and bounds their total. Summing the coordinate identity and grouping its nonnegative terms now gives (2.4).
Lemma 2.4 (Finite Fourier displacement identity). Let , where the integers are at least two. For , set
For every and ,
The squared sine is independent of the chosen integer representatives.
Proof. The geometric-series identity
shows, coordinate by coordinate, that the characters are orthonormal for the inner product . They form a basis because the function space has dimension . Thus , and the squared norm equals the sum of squared Fourier coefficients. Apply this to
and use .
Proof of Proposition 2.2. By Lemma 2.3, each displacement of is a nonnegative linear combination of displacements of Boolean cut maps. It is enough to prove (3) for one such map .
Let . Every shift in the desired inequality preserves every coset of . On a fixed coset, choose a representative and identify with that coset through . The cut becomes . For Boolean values, absolute difference equals squared difference. With , it remains to prove
where and is the th coordinate vector.
We compare the multipliers in Lemma 2.4 one frequency at a time. Fix , write and . When , the left multiplier vanishes. Assume therefore that . The left multiplier is at most four.
First suppose . Choose and put
For any , distinctness of the primes gives . Thus is not an integer. Since its denominator divides , its distance from the nearest integer satisfies
Concavity of sine on gives . Consequently the simultaneous-shift multiplier on the right of (6) is at least
which bounds the left multiplier. Now suppose . For each coordinate, the same geometric-series identity gives
The component terms on the right therefore have combined multiplier , again bounding the left. This case includes . Multiplication by and summation over proves (6). Averaging over the equal-size cosets gives the uniform average over . Finally, summing the nonnegative cut weights proves the proposition for .
The two cases explain the role of distinct periods. A low-support frequency pays for a nonintegral simultaneous phase; a high-support frequency pays for many component variations. The next section turns these two payments into an iterated obstruction.
Recursive words with incompatible displacements
We now build the words to which Proposition 2.2 will be applied. The row list must be long enough that its one-row shift remains inexpensive after multiplication by in that inequality. At the same time, it must be shorter than the product of many component periods, so that a row shift cannot cancel too many prime-period differences. The following choices provide both properties.
Fix a sufficiently large integer and set
Choose distinct primes in , and call their set . The prime number theorem gives for all sufficiently large ; the explicit interval estimate of Rosser and Schoenfeld [9] also gives this consequence. We use this one pool and the same parameters at every level.
The recursive family and its cheap steps
For every and , the construction supplies a finite abelian state group , a distinguished element of order , and a word map
It also supplies a finite list of pairs , where is a step and is its displacement budget. The word map itself need not be injective. Define
Proposition 3.1 (Recursive properties). The families can be chosen with
so that the following assertions hold.
Every listed step is cheap at every state:
Every nonzero distinguished shift is separated at every state:
If satisfies the averaged budgets for all , then
The first two assertions describe the geometry of the words. The third says that any map respecting the same cheap-step budgets has small average displacement in the separated direction. We prove the proposition by simultaneous induction on , constructing the word maps and the cheap-step lists together.
At level zero, take
The single symbols are distinct. Their insertion–deletion distance is two, so the first two assertions hold with and . The listed budgets give the third assertion with . The alphabet has symbols.
Suppose the families at level have been constructed. To build the family indexed by , enumerate the pool as with , and abbreviate
Set and , which has order .
For , the new word is a concatenation of rows, indexed by . Row begins with a payload of slots. Its first slots contain separately tagged copies of ; its remaining slots contain tagged copies of for , in that order. Each slot has its own tag, fixed across all rows and different from every other slot tag. The payload length is . Append a marker , where is absent from all payloads.
More formally, the new alphabet is the disjoint union of and one set for each slot carrying component . This also tags every lower-level marker, so none becomes the new symbol . The full length and alphabet bounds are
There are two kinds of cheap steps. First include the simultaneous step with budget . Row of the word at is row of the word at whenever . Deleting the first row and inserting one final row costs at most .
For the other steps, let and for , and put
The number is the fraction of the full word occupied by component ; markers occupy the other half. For each include its lift to coordinate with budget . The preceding level’s bound holds at every translated state . Editing the affected slots separately therefore costs at most . This proves (8).
Separation across row boundaries
We first isolate the matching argument supplied by the fresh markers. It will convert a comparison of every pair of payloads into a comparison of the full row lists.
Lemma 3.2 (Marked payloads). Let be integers, let be an alphabet, and let . For with , put
If and for every , then
In particular, implies .
Proof. Fix an increasing matching, with unmatched positions on each side. No source payload symbol can match a target marker. Let be the number of source payloads whose matches reach at least two target payloads.
A source payload whose matches lie in one target payload loses at least source positions. A payload with no matches loses positions. Summing over these payloads gives .
For each of the other payloads, choose a target marker between two of its matches, as in Figure 1. The entire marker is unmatched: a matched target position between the two chosen matches would have its source partner between their source partners, inside this source payload, where does not occur. The target matched spans of different source payloads are ordered and disjoint, so the chosen markers are distinct. Thus .

Figure 1. Two matches from one source payload enclose an unmatched target marker. The arrows represent matched pairs; no alignment of other payload boundaries is assumed.
Combining the two estimates gives and hence . The latter is at least . This holds for every matching, including when , and proves (12). Finally . □
We apply the lemma to the words at and , where . Compare source payload with target payload and write . Their relative shifts are in component 1 and in component .
At least slots have a nonzero shift. If , all copies of component 1 do. Otherwise , since . Now , whereas the product of distinct primes from the pool is at least . Fewer than pool primes can therefore divide . Among components , at least have a nonzero shift.
In each such slot the induction hypothesis gives insertion–deletion distance at least . A matching of the two complete length- slot words therefore leaves at least source positions unmatched. Since the slot tags are disjoint, every matching between the two payloads restricts to a matching of the corresponding complete slot words. Its size is bounded by their LCS even if other source payloads use some positions of the same target slot. Thus every pair of payloads has one-sided deficit at least
We have . Lemma 3.2, with and marker length , gives . Dividing by (10),
This proves the pointwise separation (9).
The averaged analytic recurrence
Suppose meets the listed averaged budgets. We need the preceding level’s assertion for one component, but its hypotheses concern averages over that component’s entire state group. The right map is a direct sum over all settings of the other components.
For fixed , let and define
Here means that occupies coordinate , and the finite direct sum of sequence spaces is identified with . For every , additivity of the sum norm gives
The lifted step budgets therefore make satisfy all the preceding level’s hypotheses at once. The induction assertion yields
where is immediate. No individual slice of is required to satisfy those hypotheses.
Apply Proposition 2.2 to the factors and their distinguished elements. The simultaneous budget, component control and (11) give
This proves (3.5) and completes the simultaneous induction in Proposition 3.1.
The quotient measures the resulting obstruction to embedding the word image. Indeed, let have distortion , normalized so that $\mathbb{E}D(x,y)/D \le |f(x)-f(y)|_1 \le . Then satisfies the listed budgets by and (8). On the other hand, (9) and give
Thus pointwise word separation can be compared directly with averaged displacement. It remains to estimate this quotient and retain it when the growing alphabet is replaced by binary symbols.
Binary encoding and the lower bound
We replace each letter by a binary block of width logarithmic in the alphabet size. For insertion–deletion distance, the code below expands by at most its width and contracts by at most an absolute factor; hence transferring the preceding obstruction to binary words costs only the width times an absolute factor. The delimiter ensures that a code block whose bits all match consecutive positions must match one equal code block. We also prove the variable-length padding statement needed for the upper bound.
Lemma 4.1 (Binary delimiter code). Let have size , let , and put . Assign distinct labels to its letters. Let be the prefix followed, in order, by the two-bit words for . Extend by concatenation to all finite strings, with . Then
For an integer and , set . Then
Proof. We prove both lower bounds at once for and , where are arbitrary integers. The pattern occurs exactly at the start of a genuine letter block: zeros separate the label bits, every block ends in zero, and the added suffixes contain only zeros.
Fix an increasing bit matching. Let be its unmatched counts on the two sides and put . Call a genuine block good if all of its bits are matched and their partners occupy consecutive positions. On either one side, at most genuine blocks are not good. For the side, a block containing an unmatched bit can be charged to one such bit, with distinct charges for distinct blocks; this accounts for at most blocks. Any other non-good block has all its bits matched, but some two consecutive block positions have partners separated by a nonempty open interval in . Every bit in that interval is unmatched, since a partner would have to lie between consecutive positions in . Charge one bit in the interval. The intervals for distinct blocks are disjoint by monotonicity, so this accounts for at most more blocks. The argument includes skipped intervals containing whole blocks or padding. Interchanging the two strings gives the same bound on the side.
A good block begins with matched bits . Its consecutive partners therefore start at a genuine block boundary on the other side. There are exactly partners, so they form that entire block. The two blocks are equal and encode the same letter; the target block is itself good. The same argument in reverse shows that the good blocks on the two sides pair bijectively, in increasing order. They give a letter matching between and whose loss is the number of non-good genuine blocks, at most . Lemma 2.1 yields . Minimizing the bit loss proves the lower bounds, including empty strings and independently chosen zero suffixes.
For the unpadded upper bound, implement each letter insertion or deletion by bit operations. For the padded bound, put and . Transform the coded prefix while retaining its suffix, then adjust the suffix length:
The last inequality follows because one insertion or deletion changes length by one.
The quantitative obstruction
First bound the recurrence in Proposition 3.1. For sufficiently large , we have and
For the last inequality, . Since , solving (7) gives
The alphabet recurrence gives : the base case is immediate and . Hence . Fix a prime and apply Lemma 4.1 to the alphabet of , without padding. Write for the resulting concatenated code. Its width is , and all encoded words have the same length
for an absolute and all sufficiently large .
Proposition 4.2. For all sufficiently large , every embedding of
has distortion at least
for an absolute constant .
Proof. Let be an injective embedding of with distortion . Rescale it so that
and define . For every listed step , the code’s upper bound and (8) give, at each state,
Thus meets the averaged hypotheses of Proposition 3.1.
For , the lower bounds give, again at every state,
In particular, these designated pairs represent distinct words, although other state pairs may coincide. Averaging and using (3.5) and (4.3), we obtain
Since and , the logarithm of the last expression is . It is at least for all sufficiently large .
A witness for every sufficiently large cap
Set and fix small enough that . Choose
For sufficiently large , this depth is available and . (4.4) gives
so . After increasing the threshold on ,
Proposition 4.2 therefore proves the lower bound in (1.1) for binary strings. This direct choice of uses no estimate on gaps between successive lengths .
Finally, choose two letters in any finite alphabet of size at least two. Their strings form an isometric copy of binary edit distance. One inequality follows because every binary edit script is also a -script. For the reverse inequality, project all other letters to one of the chosen letters; each operation in a -script becomes at most one binary edit. Restricting an embedding to this subspace gives and completes the lower half of Theorem 1.1.
An upper bound uniform over finite alphabets
The upper proof uses one external embedding theorem. We state the normalized form needed here from Theorem 7, printed page 7, of the August 19, 2005 author manuscript of Ostrovsky and Rabani [8]. Their introduction also notes the larger-alphabet and varying-length extensions. The proof below supplies the complete uniform reduction from this fixed-length binary input.
Theorem 5.1 (Ostrovsky–Rabani, normalized form). There is an absolute constant such that, for every integer , there is a map satisfying
Here permits unit-cost substitutions as well as insertions and deletions.
On the finite domain, the minimum pairwise image-to-edit-distance ratio of an embedding is positive; division by that ratio makes the theorem noncontracting without changing distortion. Its asymptotic expression is written with natural logarithms, and increasing absorbs any finite set of small lengths : mapping each binary string to a distinct coordinate vector has distortion at most .
We reduce the alphabet to a number of labels depending only on , then use Lemma 4.1 to encode and pad to one binary length. A final direct sum over all label maps will turn the pairwise probability estimate into one embedding of the whole domain.
Proposition 5.2 (Uniform alphabet bound). There is an absolute constant such that, for every finite alphabet with ,
Moreover, and .
Proof. Fix and put . Choose a map by assigning independent uniform labels to the letters, and apply it letter by letter to strings. Equal original letters remain equal after relabeling, so every original increasing matching remains valid. Hence, for every outcome,
For a fixed pair , let be the set of letters appearing in either string. Since , the union bound gives
When is injective on this pair’s letters, equality of symbols is preserved in both directions. The available increasing matchings are then exactly the same, so
For the alphabet , use the delimiter code with , , and binary length . We have , so Theorem 5.1 applies. For every , the padded string has length . The metric comparisons, (4.2) and (5.3) give
On the event in (5.5), the reverse estimate is
Let be the finite set of all label maps, with probabilities . Define
This finite direct sum is an vector, and the sum norm gives the exact identity
Taking expectations in (22) and (23), using (20), yields
Thus is injective and has distortion at most . The empty string has image zero, since its padded code is ; its distance bounds are included in the same calculation.
For , and with absolute constants. Therefore
which proves (18), enlarging the absolute constant for finitely many initial values if necessary.
For , all distinct strings in have edit distance one, and is isometric. In general, every nonzero edit distance between strings of length at most lies between one and : substitute the common-length part and then insert or delete the remaining symbols. The same coordinate-vector map has distortion at most , giving . Distortion is always at least one.
Together with the binary witnesses of Section 4, this proves Theorem 1.1.
References
- [1]A. Andoni, M. Deza, A. Gupta, P. Indyk and S. Raskhodnikova. Lower bounds for embedding edit distance into normed spaces. In Proceedings of the Fourteenth Annual ACM–SIAM Symposium on Discrete Algorithms, pages 523–526, 2003. Author manuscript.
- [2]S. Khot and A. Naor. Nonembeddability theorems via Fourier analysis. Mathematische Annalen, 334(4):821–852, 2006. doi:10.1007/s00208-005-0745-0. Author final manuscript.DOI
- [3]R. Krauthgamer and Y. Rabani. Improved lower bounds for embeddings into L₁. SIAM Journal on Computing, 38(6):2487–2498, 2009. doi:10.1137/060660126.DOI
- [4]V. I. Levenshtein. Binary codes capable of correcting deletions, insertions, and reversals. Soviet Physics Doklady, 10(8):707–710, 1966. Russian original: Doklady Akademii Nauk SSSR, 163(4):845–848, 1965. Original publication record.
- [5]N. Linial, E. London and Y. Rabinovich. The geometry of graphs and some of its algorithmic applications. Combinatorica, 15(2):215–245, 1995. doi:10.1007/BF01200757.DOI
- [6]OpenAI. Finite-Circle Obstructions, Binary Codes, and Histogram Embeddings for Edit Distance. OpenAI Math Release preprint OAI:Finite-Circle-Obstructions-Binary-Codes-and-Histogram-Embeddings-for-Edit-Distance-September-27-2026, 2026.
- [7]OpenAI. Tree Constructions for the ℓ₁ Distortion of Binary Edit Distance. OpenAI Math Release preprint OAI:Tree-Constructions-for-the-l1-Distortion-of-Binary-Edit-Distance-September-27-2026, 2026.
- [8]R. Ostrovsky and Y. Rabani. Low distortion embeddings for edit distance. Journal of the ACM, 54(5), Article 23, 2007. doi:10.1145/1284320.1284322. Preliminary author manuscript dated August 19, 2005, Theorem 7, printed page 7.DOI
- [9]J. B. Rosser and L. Schoenfeld. Approximate formulas for some functions of prime numbers. Illinois Journal of Mathematics, 6(1):64–94, 1962. doi:10.1215/ijm/1255631807.DOI
- [10]R. A. Wagner and M. J. Fischer. The string-to-string correction problem. Journal of the ACM, 21(1):168–173, 1974. doi:10.1145/321796.321811.DOI