Manuscript Offprint
arXiv:2611.04023Making Every Edit Count: Efficient Binary Edit Correction at the Gilbert-Varshamov Bound
Abstract
We construct binary codes that attain the classical Gilbert–Varshamov redundancy guarantee for a fixed number of edit errors, with deterministic polynomial-time construction, encoding, and decoding. For every fixed integer and all sufficiently large block lengths , our codes correct any combination of at most insertions, deletions, and substitutions in total, with redundancy at most . All algorithms run in polynomial time in for fixed , and decoding recovers the original information message. This realizes the classical counting guarantee algorithmically without enumerating the exponentially large space of binary words.
*Qualcomm Institute, University of California San Diego, San Diego, CA, USA. Email rgabrys@ucsd.edu. †Department of Computer Science, Technion—Israel Institute of Technology, Haifa, Israel and Fuzzy Dynamics, Bengaluru, India. Email shubhranshsinghvi2001@gmail.com. ‡Henry and Marilyn Taub Faculty of Computer Science, Technion—Israel Institute of Technology, Haifa, Israel. Email yaakobi@cs.technion.ac.il. – Author names are listed alphabetically.
1 Introduction
A handful of missing bits can create uncertainty far beyond the values of the bits that were lost. Deletions disturb the alignment between a transmitted message and the sequence that reaches the receiver, so that even the surviving symbols may no longer have identifiable positions. This loss of synchronization turns a seemingly modest error model into a fundamental challenge for reliable communication. Since the early 1960s, researchers have sought codes that overcome it with minimal redundancy and efficient algorithms. The history of deletion correction is marked by a striking tension. A nearly optimal solution for a single deletion emerged early, while extending that success to multiple deletions has demanded decades of new ideas.
The contrast with classical error correction explains the difficulty. A substitution changes a symbol's value but preserves its position. An erasure leaves a marked gap. In either case, the receiver retains the correspondence between transmitted and received coordinates, even though some values are wrong or unknown. Familiar algebraic codes exploit this correspondence through checks involving specified positions. An insertion or deletion disrupts this correspondence, forcing the decoder to account for uncertainty about alignment when interpreting such checks. Different alignments can make different original messages consistent with the same received sequence. The code must therefore control uncertainty about both symbol values and symbol positions, and classical techniques do not transfer automatically [HS21].
File synchronization brings this problem into everyday computing. Machines and cloud services must reconcile different versions of a file without retransmitting content they already share. Insertions and deletions shift that content, so matching portions may occur at different offsets. The widely used rsync utility addresses this challenge through hashing, combining rolling checksums with stronger hashes to identify matching blocks and reuse data already present at the receiver [TM96]. Improving such methods remains an active systems problem. SkySync, presented at FAST 2026, builds on rsync and related protocols to reduce the computational cost of cloud synchronization [ZLT+26]. Reducing communication creates a direct role for deletion-correcting codes. Ni, Tauz, Gabrys, and Dolecek incorporate codes that correct multiple deletions into an interactive synchronization protocol, reducing the communication needed to reconcile files when one is a subsequence of the other. Their results show how advances in deletion correction can translate into more efficient synchronization [NTGD25].
The same challenge underlies both DNA data storage and robust watermarking of AI-generated text. In DNA data storage, digital information is encoded in nucleotide sequences, and synthesis and sequencing can introduce insertions, deletions, and substitutions [HMG19]. A watermark intended to identify a text's source, in turn, must remain detectable when words are deleted, inserted, or changed. The 2024 SynthID-Text study evaluated watermarking in a live experiment involving nearly twenty million Gemini responses [DSG+24]. Golowich and Moitra make the coding connection explicit by constructing pseudorandom codes that tolerate insertions, deletions, and substitutions and using them to obtain text watermarks with provable robustness to editing under their stated assumptions [GM24]. These applications require information to remain recoverable or recognizable even when the sequence carrying it has changed.
The origins of the subject lie in the study of communication with synchronization errors. Sellers's work on bit loss and gain appeared in 1962, followed by Levenshtein's foundational combinatorial treatment in the mid-1960s. An early discovery connected this new problem to a construction designed for a different purpose. Varshamov and Tenengolts had introduced codes for correcting a single asymmetric error, and Levenshtein recognized that their weighted-checksum construction also corrects a single deletion. These codes achieve essentially the minimum possible redundancy for that task. The single-deletion acase thus offered an unusually encouraging starting point, with a compact construction, an efficient recovery procedure, and a guarantee close to the information-theoretic limit [Sel62, VT65, Lev66].
Yet extending this early success to multiple deletions proved far more difficult. Helberg codes offered an important generalization of the weighted-checksum approach, proposed by Helberg and Ferreira and later given a complete proof by Abdel-Ghaffar and colleagues. These codes correct multiple deletions, but at a substantial cost. Even for two deletions, their redundancy grows linearly in the length of the transmitted sequence. The construction thus extended the reach of the checksum method while losing the remarkable economy of its single-deletion counterpart. Obtaining explicit codes that combined efficient encoding and decoding with similarly small redundancy remained a central challenge for decades [HF02, APFC12, BGZ18].
The problem also prompted a broader information-theoretic question about how much information a channel can carry when synchronization itself is unreliable. Dobrushin's 1967 coding theorem provided an early foundation for studying channels in which an input symbol can generate a random output sequence, including no output at all. This stochastic viewpoint asks about reliable transmission under a specified random error process. The combinatorial viewpoint instead demands recovery from every error pattern within a prescribed budget. Both study the loss of alignment, but their guarantees are different, with high-probability recovery over a random channel in one case and protection against the worst allowed pattern in the other [Dob67].
The algorithmic side of synchronization has since become an important meeting point of coding theory and theoretical computer science. In 1999, Schulman and Zuckerman constructed codes with efficient encoding and decoding that protect a constant proportion of information against a constant proportion of insertions and deletions. Later, Haeupler and Shahrasbi introduced synchronization strings, a method of attaching robust positional information to a sequence. By helping the receiver recover alignment, this method allows techniques for ordinary symbol errors and erasures to be adapted to insertion/deletion channels. These developments show how identifying positions can itself be treated as a coding problem, rather than assumed to have been solved by the communication system [SZ99, HS21].
The connection with document exchange gives a complementary route to code construction. A short summary that lets a receiver recover an original file from a nearby version can serve as the redundancy of a code, provided the summary itself is protected appropriately. Haeupler's work develops this connection through efficient document-exchange protocols and derives systematic insertion/deletion-correcting codes from them. The relationship makes progress on communication-efficient reconciliation relevant to the design of codes for synchronization errors [Hae19].
Within this broader history, correcting a fixed number of deletions poses a particularly sharp challenge. The message grows longer while the number of errors stays small, so almost all of the transmitted symbols survive. The aim is to protect those messages with a vanishing fraction of redundant bits, while preserving efficient encoding and decoding. The classical single-deletion construction achieves precisely this kind of economy. Multiple deletions are harder to separate because several losses of alignment can interact, and a check that resolves one missing symbol need not distinguish all the possibilities created by several.
Brakensiek, Guruswami, and Zbarsky made a major advance by constructing efficient binary codes for any fixed number of deletions with the same qualitative dependence of redundancy on message length as in the single-deletion case. Multiple deletions could therefore be handled efficiently without a fundamentally larger growth in overhead, although substantial room remained to reduce the amount of redundancy. For two deletions, Guruswami and Håstad subsequently obtained explicit codes matching the leading redundancy of the classical greedy existence guarantee. Their construction builds on the single-deletion checksum by adding checks that distinguish the more complicated ambiguities created by a second deletion. These results illustrate the central algorithmic challenge.
Counting arguments can show that enough well-separated messages exist without revealing how to encode messages into such a set or recover them efficiently [BGZ18, GH21].
For a fixed number of errors, the classical Gilbert–Varshamov-type counting argument guarantees binary codes with redundancy at most , even when the errors may be any combination of insertions, deletions, and substitutions. The direct greedy construction, however, searches an exponentially large space.
Recent results highlight the remaining algorithmic challenge. Bui, Wang, and Vu give deterministic polynomial-time encoding and decoding for binary codes correcting such edits with redundancy . On the existential side, En Gad obtains the smaller redundancy for fixed . The classical Gilbert–Varshamov guarantee is therefore an algorithmic benchmark rather than the strongest known existence bound [BWV26, EG26].
Our focus is to turn the classical Gilbert–Varshamov guarantee into an efficient code construction. We ask the following question.
Problem 1. For every fixed , can one construct binary codes that correct any combination of at most insertions, deletions, and substitutions in total, with redundancy at most , using deterministic algorithms for construction, encoding, and decoding that run in polynomial time in ?
We answer this question affirmatively. To the best of our knowledge, this is the first binary code construction to attain the classical Gilbert–Varshamov guarantee up to an additive constant for every fixed , while supporting deterministic polynomial-time construction, encoding, and decoding. In particular, our result removes the additional term in the redundancy bound of Bui, Wang, and Vu [BWV26] and achieves constant additive overhead above .
Moreover, it provides a surprisingly simple solution to this longstanding construction problem. As we explain in the next section, the proof uses elementary counting and linear algebra. It combines counting solutions to affine binary systems, applying the method of conditional expectations, and encoding messages one bit at a time using additive lower bounds on the number of valid completions. These ideas also apply beyond the edit channel. Section 2.3 compares them with previous approaches and discusses extensions to more general error types.
This paper is organized as follows. Section 2 states the main result, reviews the Gilbert–Varshamov-type bound, and outlines the construction. Section 3 develops the affine representation of edit patterns and the counting procedure used throughout the proof. Section 4 gives the deterministic construction, encoding, and decoding algorithms and proves the main theorem. Section 5 illustrates the method with a worked example. Section 6 concludes with directions for further work.
2.1 Error model and the Gilbert–Varshamov bound
We focus on the adversarial worst-case regime with a fixed number of errors , independent of the block length . An edit is an insertion, deletion, or substitution of a single bit. For , let denote its error ball, consisting of all received words that can arise from after up to edits. A binary code corrects edits if the error balls associated with distinct codewords are pairwise disjoint. Its redundancy is .
Two distinct words are called confusable, or confusable neighbors, if
meaning that they can produce the same received word. A code corrects edits precisely when no two of its codewords are confusable.
Let be the maximum number of confusable neighbors of any word. A greedy construction repeatedly selects a remaining word as a codeword and removes it together with its confusable neighbors. Each selection removes at most words, so the resulting code satisfies
This Gilbert–Varshamov-type argument gives an achievable redundancy bound, but does not itself provide efficient encoding and decoding algorithms for a code attaining this bound.
Two distinct length- words are confusable precisely when their edit distance is at most . Counting sequences of at most edits gives
The greedy argument therefore guarantees a binary -edit-correcting code with redundancy at most . Although this bound guarantees the code size we seek to achieve, a direct implementation of the greedy construction requires enumerating and therefore takes exponential time in .
2.2 From random hashing to an efficient construction
In order to overcome this difficulty, we begin by first organizing candidate words by their syndromes under a linear transformation. Specifically, a binary matrix partitions the ambient space into syndrome classes, or cosets,
Call a word if none of its distinct confusable neighbors has the same syndrome. If every word in is separated, then the coset itself is a -edit-correcting code, described simply by the equations .
Unfortunately, this simple description does not necessarily yield high-rate codes. For instance, when , the coset is a linear code, and correcting even a single deletion limits its rate to at most . We instead settle for the much weaker requirement of finding a coset in which at least half the words are separated. As we show next, random hashing guarantees the existence of such a coset whose separated words form a code meeting the GV redundancy target, with at most one additional bit of redundancy relative to the full coset.
Let denote a uniformly random matrix and let be distinct vectors. Under this setting, , so a union bound gives
Averaging over the syndrome classes gives a coset with at least separated words. These words form a code with redundancy at most . Taking to ensure therefore achieves the GV redundancy target up to an additive constant.
The challenge and aim of this work is to realize this size guarantee efficiently. We accomplish this by way of the following three part roadmap:
-
Part 1: Construct the matrix (Section 4.1). Choose a full-row-rank matrix for which half of the words are separated.
-
Part 2: Identify the coset (Section 4.2). Find a coset and certify at least separated words within it.
-
Part 3: Index the codewords (Section 4.3). Map information messages injectively to a guaranteed subset of these words and recover each message from its codeword, in polynomial time for fixed .
All three parts can be implemented efficiently using the same counting idea, which we develop in Section 3.2.
Combining Parts 1–3 gives the following result.
Theorem 1 (Main result). For every fixed integer and all sufficiently large , there is a binary code that corrects any combination of at most insertions, deletions, and substitutions and has redundancy
The shared code parameters can be constructed deterministically in time polynomial in . Encoding and decoding, including recovery of the information message, are also deterministic and take time polynomial in for fixed .
2.3 Comparison with prior constructions and extensions
We now compare our construction with earlier algorithmic approaches. We begin with the recent work of Bui, Wang, and Vu, explaining how the constructions differ and why these differences lead to a simpler construction with smaller redundancy. We then relate our approach to syndrome compression, document exchange, and graph coloring, before discussing its extension to other error models.
Bui, Wang, and Vu [BWV26] use a technique they refer to as polynomial hashing to distinguish each payload from its confusable alternatives. Their encoder chooses a suitable hash for each payload and appends a protected tag identifying both the chosen hash and its value. Their entropy-recycling step uses the choice among suitable hashes to carry additional message bits, substantially reducing the redundancy of this representation.
Our construction changes how hashing is used. One binary matrix and one syndrome are fixed for the entire code. We encode messages directly into the separated words of that class, so no codeword needs to carry a payload-dependent seed or hash tag. The choice of the shared parameters is made once during code construction. Encoding then selects codewords using the same counting procedure. This removes the separate seed-selection, tag-protection, and entropy-recycling components from the encoder.
The hash family also matters. Once its seed is fixed, the polynomial hash of Bui, Wang, and Vu is itself binary linear. The distinction is therefore in the collision guarantee. Their bound includes a factor depending on the polynomial degree, which grows with the payload length. A uniformly random binary matrix has no such factor, allowing a shorter hash. Direct encoding into a fixed class also eliminates the overhead of protecting the tag. Together, these changes reduce the redundancy from to . Both constructions support deterministic polynomial-time encoding and decoding for fixed . Bui, Wang, and Vu additionally preserve most message bits unchanged in the codeword, a property our construction does not require [BWV26].
Our construction also differs from earlier approaches based on synchronization structure and compressed checks. Sima and Bruck [SB21] use synchronization patterns to divide a word into short blocks and protect their boundaries. Sima, Gabrys, and Bruck [SGB20a] instead use successive indicator representations and compress the resulting checks. Their general syndrome-compression method starts with a label that distinguishes each input from its competitors, then shortens it using a modulus chosen for that input. Both the modulus and the reduced label must be specified [SGB20b]. Our construction works directly with affine descriptions of the errors, avoiding the need to design and compress a separating label for each input.
Document exchange highlights another useful distinction. A short sketch must allow the receiver to reconstruct an arbitrary input from a nearby word [CJLW22, Hae19]. Our encoder has the freedom to map messages into a selected subset of words. The shared hash therefore need only separate enough words to support the desired number of messages. Efficiently identifying and encoding into that subset lets us exploit this freedom.
The requirement that a document-exchange sketch distinguish confusable inputs has a natural graph interpretation. Li, Gabrys, and Farnoud [LGF26] use distributed graph coloring to assign different labels to every pair of confusable words. Their method computes the label of an individual word efficiently while remaining consistent with a proper coloring of the whole graph. Our hash may leave some confusable words with the same label. We use only the separated words in one class and encode directly into that set. Their framework applies to more general confusion graphs, whereas our efficient implementation relies on a polynomial-size family of affine maps covering all confusable pairs. The size of such a family need not equal the graph's maximum degree.
This reliance on affine maps also identifies when the construction extends to other error models. The maps must cover every confusable pair and be enumerable in polynomial time. Under these conditions, the same argument gives deterministic polynomial-time construction and encoding for sufficiently large block lengths, with redundancy at most the base-two logarithm of the family size plus a constant. Efficient decoding additionally requires a polynomial-time procedure for enumerating the possible transmitted words consistent with a received word. The fixed syndrome then identifies the unique candidate for any valid transmission.
Adjacent transpositions provide a concrete example. Each fixed sequence of swaps is a permutation of coordinates and hence a linear map. If at most adjacent swaps are allowed, two confusable words differ by at most twice that number of swaps. For fixed , polynomially many such maps cover all confusable pairs, and the possible transmitted words can be enumerated by reversing the swaps. The method therefore gives the same redundancy guarantee as Theorem 1 for this error model, with deterministic polynomial-time encoding and decoding.
We now develop the affine representation of edit patterns and the counting procedure that make these constructions possible.
3 Preliminaries: Affine Error Patterns and A Counting Procedure
For a word , its length is denoted by , and denotes the substring from position through position . The empty word is denoted by . In particular, . For a word and a bit , denotes their concatenation. We write for the binary inner product.
3.1 Affine transformations
A map is affine if for a fixed matrix and vector over .
Fix an error pattern that maps length- binary words to length- binary words. The error pattern specifies the deleted positions, the positions and values of inserted bits, and the positions of substitutions. Each output coordinate is then a copied input bit, a complemented input bit, or a constant. Thus, over , its action has the form
where the output is a function of . Define the difference vector
Example 1. Let , and let delete the second input bit and append a one. Then
Here
The first three rows of retain input coordinates 1, 3, 4, while supplies the appended one. For instance, gives and . The same error pattern leaves 0111 unchanged, so its difference vector is zero.
In this setting, let index a family of affine error maps induced by length-preserving error patterns of at most edits and covering all confusable neighbors. We now develop a counting procedure that, for each , uses the affine representation of to efficiently count words satisfying prescribed affine constraints, without explicitly listing or testing those words individually.
3.2 The central counting procedure
For a fixed matrix , a collision witness is an input-error pattern pair such that is distinct from but has the same syndrome, i.e.,
For each word , let
be its number of collision witnesses. Observe that if and only if is separated. For a set of candidate words , we define the number of collision witnesses under the matrix w.r.t. the candidate set as follows:
Grouping the collision witnesses in (3) by error pattern gives
For each , the first term counts inputs in whose images have the same syndrome, including fixed points. The second term removes those fixed points, since implies .
If is specified by affine equations, each count in (5) is the number of solutions of an affine binary system. For a system in unknowns, the number of solutions is
Gaussian elimination determines consistency and rank.
Example 1 (continued). We illustrate the computation of in (5) using the family consisting only of the preceding error map, so within this example. Its difference vector is
For illustration, choose . Since , the syndrome class consists exactly of the words with . We first count words in whose images under the error map have the same syndrome. Membership in gives , while gives . These are the two rows of the system :
Here , so the first count is . Indeed, the equations force , leaving and free.
This count includes words left unchanged by the error map. To count these fixed points, we impose in place of . In addition to , this requires and ; the first coordinate of is already zero. Together with , these equations give
Now , so the fixed-point count is : the equations force , leaving only free. The two cardinalities in (5) are therefore 4 and 2, giving
Thus we obtain two collision witnesses without enumerating the words in S.
For each , one affine-system count evaluates , and a second evaluates . Thus such counts suffice to evaluate exactly. When is given by polynomially many affine equations, this takes polynomial time in and , without enumerating .
Next, we define a signed lower bound on the number of separated words under the matrix H w.r.t. the candidate set S as follows:
A separated word contributes 1, whereas a word with collision witnesses contributes . Therefore
and summing over yields
For fixed , the collision witness count depends only on , not on the candidate set containing it. Hence, for disjoint sets ,
This identity holds even when one of the terms is negative. This will later allow us to distribute the bound on the whole space among syndrome classes and, within a selected syndrome class, among prefix extensions.
The construction applies this additive signed lower bound as follows.
-
Choose the matrix. Construct with at most surviving collision witnesses, i.e. , guaranteeing that at least half of all words are separated.
-
Choose the syndrome. Partition into syndrome classes and find a class with , guaranteeing that at least half of all words are separated.
-
Index the codewords. Restrict the selected class by successive prefixes and use the additive signed bounds to encode message bits.
4 The construction
We now prove Theorem 1 by carrying out the three parts outlined above. We then combine their guarantees to establish the redundancy bound and efficient encoding/decoding.
4.1 Part 1: Choosing H
We now proceed with the first step: choosing . We construct it using the method of conditional expectations [AS16], one row at a time, choosing each row to separate at least half the collision witnesses surviving the preceding rows.
A parity-check row separates from precisely when
To choose the next row bit by bit, let contain the rows already chosen. Let count the surviving collision witnesses under , i.e., .
Fix the first bits of the next row to the next partially completed row, which we refer to as , and complete the remaining bits uniformly at random. For each surviving witness, there are two cases:
-
Nonzero difference suffix: survival probability 1/2. If , at least one remaining row bit controls the parity, making zero and one equally likely.
-
Zero difference suffix: the prefix decides. If , the remaining row bits have no effect. The witness survives exactly when .
Let count the witnesses with zero difference suffix and count those among them whose prefix parity is zero.
For each , let
Then, it follows that
and
Conditioned on the previously chosen rows G and the prefix p of the next row, the expected number of surviving witnesses is
Lemma 1 (Counting under a partial row). We can compute exactly and construct a row separating at least half the T surviving witnesses, both in deterministic polynomial time.
Proof. First compute using the counting procedure from Section 3.2, which requires at most affine-system counts. For each prefix , at most additional affine-system counts suffice to evaluate and , and hence . Specifically, for each error pattern , two counts evaluate its contribution to using , and two more evaluate its contribution to using . Since these sets are specified by polynomially many affine equations, each prefix evaluation takes time polynomial in and .
For , a uniformly random next bit gives
Consequently,
Computing both values and appending a minimizing bit never increases the expectation. Since , the completed row satisfies . Here is the actual survivor count, so at least half the witnesses are separated.
Completing the matrix Let and set , with . Initially there are at most witnesses. Apply Lemma 1 successively to choose rows. While witnesses remain, each new row is linearly independent of the preceding rows since a row in their span would separate no further witnesses. If no witnesses remain, extend the matrix to rank with independent rows. Adding rows cannot create a collision. Thus rank and the total number of surviving witnesses is
We have now constructed so that at least half of all words are separated. Part 2 locates a syndrome class containing at least separated words.
4.2 Part 2: Choosing the syndrome
Once is fixed, we choose a target syndrome whose class has a large guaranteed number of separated words. This is a one-time setup step and every encoded word will satisfy . We try all syndromes and choose the one with the smallest upper bound on the number of words that are not separated.
For a syndrome , the number of words in its class is
Every syndrome is attainable because H has full row rank.
Lemma 2 (Choosing a syndrome). We can find a syndrome with in deterministic polynomial time.
Proof. Since the candidate set is specified by polynomially many affine equations, the number of collision witnesses under w.r.t. the candidate set , , can be computed in polynomial time.
We choose
Since are disjoint cosets, using (11) from Part 1, gives
The second equality holds because each word belongs to exactly one syndrome class.
There are syndromes, so the minimizing choice satisfies . The exhaustive search over the choices for the syndromes is possible in polynomial time because there are
syndromes.
Since the chosen class has words, at least half are certified separated. We have now fixed the shared parameters and and certified enough separated words for message bits. Part 3 will index a subset of these words to encode messages efficiently and recover each message from its codeword.
4.3 Part 3: Indexing the codewords
Our encoder follows the classical enumerative-coding approach, which indexes codewords through their prefix-completion counts [Cov73, OR00, OR07, OR09]. In our setting, affine collision-witness counts yield efficiently computable signed lower bounds that are additive over the binary prefix tree. For completeness, we give a self-contained proof of the encoder and its inverse on the encoder image, working directly with these bounds.
Fix the matrix and write for the syndrome chosen in Part 2. The encoder builds a codeword one bit at a time. At each step, it uses lower bounds on the number of valid completions to determine how many messages to assign to each possible next bit. It never needs to list all the separated words.
For a prefix , let the set of the set of words in with prefix be denoted by , i.e.,
By convention, , where is the empty word.
Since the candidate set is specified by polynomially many affine equations, it's cardinality and the number of collision witnesses under w.r.t. the candidate set , , can be computed in polynomial time. Furthermore, since , the signed lower bound can also be computed in polynomial time.
Although may be negative, it is additive and partitioning the candidate set by the next bit of the prefix gives
At a complete word , the value of is if , and zero otherwise. Consequently, exactly when is separated and has syndrome ; in that case .
Set and interpret the -bit message as an integer . Part 2 guarantees , so there are enough certified separated words for all messages. Starting with the empty prefix , construct the codeword one bit at a time, using as the current index.
At each step, compute , the lower bound for separated words extending the prefix .
• If , append 0 to p.
• Otherwise, append 1 and replace m by
using the bound computed before appending the bit.
Indices below a positive use the zero branch. The remaining indices use the one branch, subtracting from the current index so that it indexes the remaining choices within the one branch. If , all indices use the one branch without changing the current index. Repeat until .
Example Suppose , , and . Indices use the zero branch. Our index takes the one branch and becomes : it is now the second index in that branch. If instead and , we take the one branch and leave unchanged.
Lemma 3 (Encoding and recovering messages). The construction maps K-bit messages injectively to separated words with syndrome . Encoding and inversion on its image both take time polynomial in n and M.
Proof. We maintain along the selected path. This holds initially by Part 2. On the zero branch it follows directly from . On the one branch, the new index is nonnegative and satisfies
where the final equality is (12).
At a complete word , we have , forcing and . The output is therefore separated and has syndrome .
To prove injectivity, suppose two distinct initial message indices produce the same codeword . Let and denote their current indices after the first bits have been chosen. Both runs follow the same sequence of prefixes, so each step subtracts the same quantity from both indices, possibly zero. Hence
At termination, both runs reach . Each final index is a nonnegative integer strictly less than , so . This gives
a contradiction. Therefore the encoder is injective.
To recover the message from a codeword in the image, start with and , and read its bits from left to right. Before appending each bit to , add to if the bit is 1 and leave unchanged if it is 0. These additions undo the subtractions made during encoding. Since encoding ends with index zero, the final sum is the original message index, written in bits.
Each traversal evaluates at most n times, and each evaluation can be computed in polynomial time. The running time is therefore polynomial in n and M, and hence in n for fixed t.
This encoding is generally nonsystematic: the message bits need not appear in designated codeword positions.
Proof of Theorem 1 Lemma 1 and the matrix completion argument in Part 1 construct a full-row-rank matrix with rows and
Lemma 2 then finds a syndrome satisfying
With these parameters, Lemma 3 gives an injective encoder for message bits, together with an efficient inverse on its image. Taking this image as , we obtain
since . By Lemma 3, every codeword is separated and has syndrome . In other words, no two codewords are confusable, and corrects edits.
It remains to describe recovery from an edited word. To decode a received word y obtained from a codeword by at most t edits, enumerate the length-n words within t edits of y and retain those satisfying . The transmitted word qualifies. Any distinct retained word would be confusable with it and have the same syndrome, contradicting separation. Thus this search uniquely recovers the transmitted word, and the inverse from Lemma 3 recovers its message. The candidate search takes time polynomial in for fixed . Together with the deterministic polynomial-time guarantees of Lemmas 1–3, this proves Theorem 1.
5 Example
We illustrate the three parts of Section 4 with and . Take to consist of the 8 single-bit substitutions, the two-bit substitutions, and the deletion-insertion patterns. Thus , and this family covers all confusable neighbors for one edit.
Consider the full-row-rank matrix
We verify that the above matrix separates more than 128 words directly by grouping witnesses by their difference . Equal syndromes imply . The kernel has dimension three, and its seven nonzero vectors are listed in the table below. All have Hamming weight at least four, so a collision cannot come from one or two substitutions. Only deletion-insertion patterns remain.
Suppose a deletion-insertion pattern deletes and inserts a bit at position of the resulting word . Within positions through , the input and output blocks satisfy
We call this a left shift of the interval . A right shift instead deletes and inserts at position , replacing the same input block with . Both operations leave every coordinate outside unchanged.
Now prescribe the difference . Since the two words agree outside , this interval must contain every nonzero coordinate of . For a left shift, the differences within the interval satisfy
Write for the interval length. There are two possible shift directions, left and right. For each direction, the inserted bit can be either 0 or 1. Each of these four choices uniquely determines the bits inside the interval and allows assignments to the bits outside it. Thus, the number of collision witnesses for this difference and interval is
For example, has its first and last nonzero coordinates at positions 3 and 8. The possible intervals are , , and . Since the interval length is , their respective contributions are
Thus this difference contributes witnesses. The same calculation for the other differences gives
| Difference | Interval lengths | Witnesses |
|---|---|---|
| 00101101 | 6, 7, 8 | |
| 01010111 | 7, 8 | |
| 01111010 | 6, 7, 7, 8 | |
| 10011001 | 8 | 4 |
| 10110100 | 6, 7, 8 | |
| 11001110 | 7, 8 | |
| 11100011 | 8 | 4 |
The two length-seven intervals in the third row are [1, 7] and [2, 8]. We count patterns separately, as required by . Summing,
This certifies that the above matrix separates more than 128 words. For this small example, rows suffice. The general procedure for choosing rows is proved in Lemma 1.
Take the nonzero syndrome . Its eight words are listed below. The last column records the message assignments from Part 3.
| Word | Separated? | Message |
|---|---|---|
| 00001101 | Yes | 00 |
| 00100000 | Yes | 01 |
| 01011010 | Yes | 10 |
| 01110111 | No | — |
| 10010100 | Yes | 11 |
| 10111001 | Yes | — |
| 11000011 | Yes | — |
| 11101110 | No | — |
We next determine which words in are separated and evaluate the corresponding signed lower bound. Since all eight words have syndrome , a word is separated precisely when none of the other seven words is confusable with it.
For distinct , the difference is a is one of the seven nonzero kernel vectors listed above, and therefore has Hamming weight at least four. Thus one or two substitutions cannot transform one word into another. The only remaining possibility for confusability is a deletion followed by an insertion. Equivalently, the two words must share a length-seven subsequence.
Comparing the one-deletion outputs of the eight words shows that the only confusable pair is 01110111 and 11101110. Their common output is
This is their only common one-deletion output, and it is obtained uniquely from each word. Hence there is exactly one collision witness in each direction: deleting the initial zero and appending a zero maps 01110111 to 11101110, while deleting the final zero and prepending a zero gives the reverse map. The other six words have no collision witnesses and are therefore separated.
Although there is only one unordered confusable pair, it contributes two witnesses, one with each word as its input. Consequently,
Each of the six separated words contributes 1 to the signed bound, and each of the two remaining words contributes 1 - 1 = 0. Therefore
In this class, the signed bound equals the actual number of separated words. Since
the class has sufficient capacity for the four two-bit messages. The prefix encoder below selects four of these six separated words, giving the message assignments in the table.
Set , so we encode the four message indices . At the first bit, the prefix counts are
Thus indices 0,1,2 take the zero branch, while index 3 takes the one branch and becomes 0. Continuing the prefix procedure gives the four assignments in the table. In particular, message 11 is encoded as 10010100.
To illustrate decoding, delete the first bit of 10010100, yielding . Among the nine distinct length-eight words obtained by inserting one bit into , only 10010100 satisfies . The inverse prefix procedure then recovers message 11.
6 Conclusion
We have given a deterministic construction of binary codes correcting any combination of at most insertions, deletions, and substitutions in total, with redundancy at most for every fixed and all sufficiently large . Construction, encoding, and decoding all run in polynomial time in for fixed , and decoding recovers the original information message. This realizes the classical Gilbert–Varshamov guarantee up to an additive constant without searching the exponentially large space of binary words.
A central point is that efficient encoding does not require exact counts of valid completions. Additive lower bounds suffice. Affine descriptions of the errors make these bounds computable through systems of binary linear equations, while conditional expectations provide deterministic choices of the shared code parameters. Together, these elementary tools turn a counting argument into an explicit construction. The approach also extends to error models with polynomial-size, efficiently enumerable affine descriptions of confusable pairs. Efficient decoding additionally requires efficient enumeration of the possible transmitted words consistent with a received word.
Several questions remain. Improving the running time and its dependence on the number of errors would help move these constructions toward practical use. For multiple edits, it also remains to close the gap between efficient constructions and the strongest known existence bounds. Whether the same counting approach can reach beyond the classical Gilbert–Varshamov guarantee is a natural direction for further work.
Acknowledgment of AI assistance
ChatGPT-6 Astra was used during the development of this work to assist with mathematical exploration. The authors take full responsibility for the correctness, originality, and integrity of the work.
References
[APFC12] Khaled A. S. Abdel-Ghaffar, Filip Palunčić, Hendrik C. Ferreira, and Willem A. Clarke. On Helberg's generalization of the Levenshtein code for multiple deletion/insertion error correction. IEEE Transactions on Information Theory, 58(3):1804–1808, March 2012.
[AS16] Noga Alon and Joel H. Spencer. The Probabilistic Method. John Wiley & Sons, Hoboken, NJ, fourth edition, 2016.
[BGZ18] Joshua Brakensiek, Venkatesan Guruswami, and Samuel Zbarsky. Efficient low-redundancy codes for correcting multiple deletions. IEEE Transactions on Information Theory, 64(5):3403–3410, May 2018.
[BWV26] Quan D. Bui, Shuche Wang, and Van Khu Vu. Binary codes correcting multiple edits via polynomial hashing and entropy recycling, 2026. arXiv:2610.15631.
[CJLW22] Kuan Cheng, Zhengzhong Jin, Xin Li, and Ke Wu. Deterministic document exchange protocols and almost optimal binary codes for edit errors. Journal of the ACM, 69(6):44:1–44:39, December 2022.
[Cov73] Thomas M. Cover. Enumerative source encoding. IEEE Transactions on Information Theory, 19(1):73–77, January 1973.
[Dob67] Roland L. Dobrushin. Shannon's theorems for channels with synchronization errors. Problems of Information Transmission, 3(4):11–26, 1967.
[DSG 24] Sumanth Dathathri, Abigail See, Sumedh Ghaisas, Po-Sen Huang, Rob McAdam, Johannes Welbl, Vandana Bachani, Alex Kaskasoli, Robert Stanforth, Tatiana Matejovicova, Jamie Hayes, Nidhi Vyas, Majd Al Merey, Jonah Brown-Cohen, Rudy Bunel, Borja Balle, Taylan Cemgil, Zahra Ahmed, Kitty Stacpoole, Ilia Shumailov, Ciprian Baetu, Sven Gowal, Demis Hassabis, and Pushmeet Kohli. Scalable watermarking for identifying large language model outputs. Nature, 634(8035):818–823, October 2024.
[EG26] Eyal En Gad. Polynomially larger deletion codes by linear hashing of substring counts, 2026. arXiv:2609.19493.
[GH21] Venkatesan Guruswami and Johan Håstad. Explicit two-deletion codes with redundancy matching the existential bound. IEEE Transactions on Information Theory, 67(10):6384–6394, October 2021.
[GM24] Noah Golowich and Ankur Moitra. Edit distance robust watermarks via indexing pseudorandom codes. In Advances in Neural Information Processing Systems, volume 37, pages 20645–20693. Curran Associates, Inc., 2024.
[Hae19] Bernhard Haeupler. Optimal document exchange and new codes for insertions and deletions. In Proceedings of the 60th IEEE Annual Symposium on Foundations of Computer Science (FOCS), pages 334–347, 2019.
[HF02] A. S. J. Helberg and Hendrik C. Ferreira. On multiple insertion/deletion correcting codes. IEEE Transactions on Information Theory, 48(1):305–308, January 2002.
[HMG19] Reinhard Heckel, Gediminas Mikutis, and Robert N. Grass. A characterization of the DNA data storage channel. Scientific Reports, 9(1), 2019. Article 9663.
[HS21] Bernhard Haeupler and Amirbehshad Shahrasbi. Synchronization strings: Codes for insertions and deletions approaching the Singleton bound. Journal of the ACM, 68(5):36:1–36:39, October 2021.
[Lev66] Vladimir I. Levenshtein. Binary codes capable of correcting deletions, insertions, and reversals. Soviet Physics Doklady, 10(8):707–710, February 1966.
[LGF26] Yuting Li, Ryan Gabrys, and Farzad Farnoud. Constructing low-redundancy codes via distributed graph coloring. IEEE Transactions on Information Theory, 72(10):7344–7358, October 2026.
[NTGD25] Haolun Michael Ni, Lev Tauz, Ryan Gabrys, and Lara Dolecek. Improved interactive protocol for synchronizing from deletions. In Proceedings of the IEEE International Symposium on Information Theory (ISIT), pages 1–6, June 2025. Full version: arXiv:2512.06606.
[OR00] Erik Ordentlich and Ron M. Roth. Two-dimensional weight-constrained codes through enumeration bounds. IEEE Transactions on Information Theory, 46(4):1292–1301, July 2000.
[OR07] Erik Ordentlich and Ron M. Roth. Capacity lower bounds and approximate enumerative coding for 2-D constraints. In Proceedings of the IEEE International Symposium on Information Theory (ISIT), pages 1681–1685, 2007.
[OR09] Erik Ordentlich and Ron M. Roth. Approximate enumerative coding for 2-D constraints through ratios of matrix products. In Proceedings of the IEEE International Symposium on Information Theory (ISIT), pages 1050–1054, 2009.
[SB21] Jin Sima and Jehoshua Bruck. On optimal k-deletion correcting codes. IEEE Transactions on Information Theory, 67(6):3360–3375, June 2021.
[Sel62] Frederick F. Sellers, Jr. Bit loss and gain correction code. IRE Transactions on Information Theory, 8(1):35–38, January 1962.
[SGB20a] Jin Sima, Ryan Gabrys, and Jehoshua Bruck. Optimal systematic t-deletion correcting codes. In Proceedings of the IEEE International Symposium on Information Theory (ISIT), pages 769–774, 2020.
[SGB20b] Jin Sima, Ryan Gabrys, and Jehoshua Bruck. Syndrome compression for optimal redundancy codes. In Proceedings of the IEEE International Symposium on Information Theory (ISIT), pages 751–756, 2020.
[SZ99] Leonard J. Schulman and David Zuckerman. Asymptotically good codes correcting insertions, deletions, and transpositions. IEEE Transactions on Information Theory, 45(7):2552–2557, November 1999.
[TM96] Andrew Tridgell and Paul Mackerras. The rsync algorithm. Technical Report TR-CS-96-05, Australian National University, Canberra, Australia, June 1996.
[VT65] Rom R. Varshamov and Grigory M. Tenengol'ts. Codes which correct single asymmetric errors. Automation and Remote Control, 26(2):286–290, 1965.
[ZLT 26] Zhihao Zhang, Huiba Li, Lu Tang, Guangtao Xue, Jiwu Shu, and Yiming Zhang. SkySync: Accelerating file synchronization with collaborative delta generation. In Proceedings of the 24th USENIX Conference on File and Storage Technologies (FAST), pages 461–476. USENIX Association, February 2026.