Manuscript Offprint
arXiv:2611.12348How Hard Is Tokenisation? Algorithms and Complexity Beyond NP-Hardness
Abstract
Given a collection of strings and a vocabulary budget, how well can we minimize its total token count, and how does the answer change with the tokenisation model? For binary direct tokenisation, previous work proved APX-hardness but left constant-factor approximability unresolved [1]. We rule out every polynomial-time approximation, for fixed , unless , even on distinct equal-length strings with . Here is the total input length and is the number of input strings. We complement this lower bound with a deterministic polynomial-time approximation algorithm and stronger bounds for selected vocabulary budgets. For the different objective of maximizing compression savings, GreedTok was shown to attain a constant fraction of the optimum on unrestricted alphabets [2]; we establish a deterministic EPTAS for direct savings on every fixed alphabet and analyze greedy selection by true marginal gains. For exact optimization, we give a binary direct algorithm running in poly() time, where is the total length of the distinct input strings and is the input encoding length. Finally, we resolve two unary merge-model hardness questions left by the bounded-alphabet study [1]: standard unary bottom-up tokenisation is APX-hard, and unary optimal pair encoding is strongly NP-complete, strengthening the previously known weak hardness.
Keywords: tokenisation, vocabulary optimisation, approximation algorithms, APX-hardness, exact exponential algorithms, parameterized complexity.
1 Introduction
This question depends on the rules used to construct a vocabulary and parse its strings. In direct tokenisation, a vocabulary is chosen first and every string is then segmented optimally. In bottom-up tokenisation, a sequence of merge rules changes the current parse. The resulting parse need not be the shortest parse over the words created by those rules. We study both models and show how their computational properties differ.
1.2 Previous and related work
Whittington et al. [5] proved NP-completeness of direct and bottom-up tokenisation. Kastreva et al. [1] established APX-hardness for binary instances and hardness for unary direct tokenisation. These results leave open the possibility of approximation algorithms for the token-count objective, even over a binary alphabet.
Lim et al. [6] formulated partition-cover tokenization and introduced GreedTok and the maximum-coverage relaxation GreedWMC. Baliga et al. [2] subsequently proved that GreedTok achieves at least 0.2752 of the optimum compression savings and established an inapproximability bound for savings over unrestricted alphabets. Their partition-cover savings objective is the same as when segmentations are optimal. Our fixed-alphabet approximation scheme concerns this savings objective, whereas our near-linear inapproximability and approximation concern the different multiplicative objective of final token count. The constant-factor guarantees for savings do not imply constant-factor guarantees for token count.
Kozma and Voderholzer [7] analysed the compression utility of byte-pair encoding and optimal pair encoding. Tempus et al. [8] developed ConvexTok through a linear-programming formulation, and Chehaidar et al. [9] studied static symbol-table selection with optimal parsing for a fixed table. We focus on worst-case guarantees for the stated combinatorial tokenisation models.
1.3 Informal problem definition
We are given a list of strings and a budget . In the direct model, the single characters are available for free and we may select at most additional words. Every input is split into the fewest possible vocabulary words. We minimize the total token count. We also study the equivalent exact objective of maximizing the number of characters saved by the tokenisation; the two objectives need not have the same approximation guarantees.
For bottom-up tokenisation, we select at most ordered pair-merge rules. Each rule is applied from left to right to all nonoverlapping occurrences in the current parses, and the strings are not resegmented afterward. Optimal pair encoding instead uses the merge rules to construct a vocabulary and then permits optimal segmentation with that vocabulary.
1.4 Our results
Our binary direct token-count lower bound strengthens the binary APX-hardness of Kastreva et al. [1]: no deterministic polynomial-time approximation is possible for any fixed , unless P = NP. In particular, the constant-factor approximation question has a negative answer. We complement this with a polynomial-time algorithm and budget-sensitive improvements.
For compression savings, Baliga et al. [2] proved a constant-factor guarantee for GreedTok and APX-hardness over unrestricted alphabets. In contrast, our direct-savings EPTAS applies when the alphabet is fixed. We also analyze a separate algorithm that selects token types using their true marginal savings under optimal segmentation.
Our exact algorithms use the structure of token occurrences in an optimal solution. They include a poly(I) algorithm for binary direct tokenisation, together with a faster unary algorithm and fixed-parameter results for several measures of input sharing. For merge-based tokenisation, we establish APX-hardness of standard unary bottom-up tokenisation, for which the earlier bounded-alphabet work had no hardness result, and strong NP-completeness of unary optimal pair encoding, strengthening its earlier weak NP-hardness [1].
2 Preliminaries and Tokenisation Models
Let be an explicitly represented list of independent nonempty strings over a finite alphabet . Repetitions are allowed; is the total unweighted input length. The mandatory vocabulary contains the single characters. A direct solution is a set of at most additional words, each of length at least two. Let denote the minimum number of vocabulary words whose concatenation is . We write and , with and . Thus , but a multiplicative approximation for one objective need not approximate the other multiplicatively.
A bottom-up solution consists of an ordered sequence of at most rules . Every rule is applied exhaustively from left to right on the current token parses of each input; merges never cross input boundaries. The final token count is that of the actual resulting parses. Unary tokens can equivalently be represented by their positive integer lengths, but input strings themselves are written explicitly. We use for the full encoding length and for the total length after duplicate input strings are removed, when appropriate. All logarithms in asymptotic bounds are base two unless stated otherwise.
2.1 DIRECT, bottom-up, and optimal pair encoding
For a dataset of unary strings, identify the token with its positive integer length . The three models share the mandatory character token and a budget of at most added token types or merge rules. DIRECT chooses up to literal types and uses a minimum-token parse. In standard bottom-up tokenisation, at most ordered pair-merge rules are executed exhaustively from left to right on the current parses, without resegmentation. In optimal pair encoding (OPE), binary concatenation rules generate a vocabulary and the strings are then segmented optimally using that vocabulary [1].
Write , and for the three optimal token counts. The models satisfy
These inequalities do not by themselves transfer hardness; the reductions below analyze the corresponding models separately. In all cases, the input strings are explicit and merges cannot cross string boundaries.
3 Polynomial-Time Approximation for Binary DIRECT
The first family of algorithms respects the exact optional vocabulary budget and includes both a uniform guarantee and refinements depending on and on the vocabulary deficit.
3.1 Notation and elementary bounds
An instance is an explicit list of binary strings, a nonnegative integer budget , and mandatory vocabulary . One may add at most arbitrary binary words and must parse every listed string using the resulting vocabulary. The objective is the sum of token counts. Empty strings may be deleted. Let be the total number of input characters, counting repeated copies; let be the number of nonempty strings counting multiplicity; and let be the number of distinct nonempty strings. Thus , and every feasible solution has cost at least . All logarithms are base two; set , . The bounds below concern ; an empty input is handled exactly.
3.2 Budget-dependent bounds
Selecting the largest whole-input gains yields cost at most . For , division by and give ratio at most . For distinct common-length inputs with , its exhibited cost is , hence ratio at most . For , set . All binary words of lengths two through number . Block parsing costs at most , so the ratio is at most when . Taking the better candidate gives . Large budgets use the exact whole-input shortcut. These bounds concern the same exact optional budget and are useful independently of the uniform grid bound.
3.3 General deterministic bound
Theorem 3.1. There is a deterministic algorithm for binary DIRECT whose approximation ratio is at most . Its running time is word-RAM operations, or under the conservative bit-operation bound. The polynomial exponent is independent of .
Proof. The proof combines a finite grid search for a small budget with a universal short-block vocabulary for a larger budget.
First handle exactly with the mandatory characters. If , choosing all distinct input strings of length at least two solves the instance exactly with cost . Every remaining case has , and .
Put . If , the character solution costs , so its ratio is at most . If and , return the character dictionary; its ratio is at most .
For the remaining cases set and . If escaped the character branch, then , which implies . Indeed, and . If , then
, so is impossible and . If , then , so ; the middle expression is four at and increases with . Thus a small positive budget not handled by the character branch reaches the grid branch. In particular, the universal-block branch below is used only when . The cutoff may be zero.
We use a grid rounding fact. In each input string, place grid points at positions , together with the final endpoint, removing duplicates. Let be the set of distinct substrings of length at least two between pairs of grid points in the same string. For any dictionary of at most optional words and any parse of cost , there is a dictionary of at most words from with cost at most . To see this, choose one used occurrence for each optional word type . If its closed interval contains at least two grid points, let the first and last give a core . Then with . This is a fixed factorization of the word, so it works for every occurrence of that type, even at other grid phases. Replace each token by its two character fringes and the one core token (if the core has length one it is mandatory). If fewer than two grid points lie in the interval, its length is less than , and characters suffice. Each original token is replaced by at most tokens, and each old optional type creates at most one optional core.
If , take . Whenever this grid branch is reached, either and the earlier cases imply with , or and the dichotomy above gives . Thus . The number of grid points over all listed strings is at most ; hence . Enumerate all subsets of of size at most , and return one of minimum segmentation cost. Dummy-padded sorted tuples bound the number of candidates by . Since , . Rounding an optimal solution therefore shows that the returned ratio is at most .
If , choose . Since , , and the dictionary containing every binary word of lengths has words. Parsing in blocks of length at most costs at most , giving ratio at most . One checks : for this follows from ; for , implies . Also , so . The ratio is therefore less than .
Every branch uses the original budget. The grid branch evaluates at most 2M dictionaries, each by polynomial-time segmentation DP; the character and exact branches are linear or polynomial, and the universal dictionary is polynomial in size. This establishes the theorem.
3.4 Vocabulary-deficit bounds
Theorem 3.2. Let . There is a deterministic algorithm for binary DIRECT with approximation ratio at most . It respects the exact budget and runs in word-RAM operations, or under the conservative bit-operation bound. Here counts distinct nonempty strings; repetitions are allowed and are counted in . No equal-length assumption is needed.
Proof. The empty instance, , and are exact. In the remaining cases , so , , and . Use .
For a distinct string with multiplicity , define its whole-word gain . Selecting the types with largest gains leaves the smallest gains omitted. Their sum is at most times the total gain, namely . The resulting whole-word/character parse costs at most . Since , its ratio is at most . A length-one type has zero gain and already parses with a mandatory character, so formal selection of such a type does not use more than K entries.
Set and . Use these three branches after the exact cases.
-
If , return the mandatory characters. Then , and .
-
If and , use the weighted whole-word solution above. Since , its ratio is less than .
-
Otherwise and . Thus . Use grid rounding on distinct input strings with spacing . The number of grid points satisfies , so the raw and distinct candidate counts are at most . Because and , . The number of dictionaries of size at most is at most . Fixed-core rounding gives ratio .
These cases cover every input and use at most optional words. In the grid case, , and the number of dictionaries is within the stated running time. Repeated copies share the same candidate words and do not increase this count. This proves the bound.
For , this recovers the previous result. More generally, for each fixed deficit , the guarantee is . Taking the better of this algorithm and the general grid algorithm gives ratio at most .
3.5 Uniform implementation bounds
The runtime bounds include reading the encoded corpus/list and budget. If arbitrarily many empty strings are permitted, their list metadata is not bounded by . With only nonempty listed strings, list metadata is .
For the general theorem, the branch order is: discard empty strings; solve the empty corpus, , and exactly; use characters when ; use characters also when and ; then, if , enumerate grid dictionaries with ; otherwise use all binary words of lengths . The small-budget dichotomy in the proof ensures any escaping the character branch satisfies the grid cutoff. Thus the universal-block branch is used only when . There is no exact arbitrary-substring enumeration.
In the general grid branch, there are raw grid intervals and distinct candidate words, each of length at most . Copying and trie-deduplicating the raw words costs . Find occurrences by comparing each distinct candidate against every possible corpus start, stopping at its own string boundary; this takes character comparisons. The resulting position DAG has optional and mandatory edges. For each selected dictionary, a forward shortest-path DP skips optional edges whose candidate identifiers were not selected and examines edges. At most dictionaries are evaluated, for total DP work. Candidate masks, storage of the best set, and one final predecessor pass fit within this bound. Hence the word-RAM running time is , with conservative bit-operation bound .
For the vocabulary-deficit theorem, the grid branch applies whenever the third-branch conditions hold, in particular ; is solved exactly. No separate exact search for is needed. In this branch, and , so at most dictionaries are evaluated.
For the sharper grid-branch runtime, let be the total length of distinct input strings. Differences between regular grid points are multiples of , contributing at most candidate lengths. Each string has at most one irregular final endpoint; differences from it to regular grid points add at most lengths. Summing over distinct strings gives . At a fixed corpus position and fixed length, the binary substring is unique. Since candidates are deduplicated, at most one candidate of that length can match there. Thus the optional occurrence graph has edges.
Build a binary trie from the raw candidate words, assigning one identifier per terminal. Aho-Corasick matching finds every candidate occurrence in time after trie construction. The alphabet is binary, so transitions have constant cost. The original construction has failure/output structures whose preprocessing is linear in total pattern length, and its scan makes fewer than state transitions on text of length ; emitting matches costs . For each of at most dictionaries, forward DP over position-DAG edges costs , totaling . Mask work and trie construction also fit this total because . Memory is for the trie and for the occurrence graph. The whole-word branch aggregates equal strings with a binary trie and sorts the weighted gains in time, within the stated bound.
Aho-Corasick matching finds all candidate occurrences in time linear in the total candidate length, the input length, and the number of matches [10]. Each reported match becomes one edge of the segmentation graph, as counted above.
4 Near-Linear Inapproximability
We prove hardness by encoding an instance of finite-word combinatorial rank as binary strings. We then show how a short tokenisation yields a solution to the original instance. The same construction gives the equal-length restriction.
4.1 Problem statement and result
An instance consists of a finite explicit list of nonempty strings over , and a nonnegative integer . The mandatory vocabulary is . A feasible optional vocabulary is any set of at most additional nonempty binary words; candidates need not be specified in the input. Its cost is . Binary DIRECT minimizes this cost. An optional word unused in every parse can be deleted, so restricting attention to input substrings would not change the optimum. Mandatory character tokens do not count against . Write for the total explicit number of binary characters.
The source problem is finite-word combinatorial rank. Given a finite set of explicit nonempty words over a finite, input-dependent alphabet and an integer , decide whether , where is an arbitrary set of nonempty words. No source alphabet generators are supplied for free, and there is no bound on the number of factors in a factorization. Néraud proved this bounded-rank decision problem NP-complete [11, Theorem 4.5]. This is combinatorial rank, distinct from free/code rank.
Theorem 4.1. For every fixed , a deterministic polynomial-time approximation for binary DIRECT would imply P = NP. This remains true jointly for distinct equal-length inputs and budget . These exclusions also imply the corresponding fixed-constant-factor exclusions.
4.2 Synchronizing binary encodings
Let be a source instance, , and let be the letters appearing in , so . Choose a positive block length , and set , . The applications below have , , and polynomially bounded . Encode each by , extending to words by concatenation. The encoded corpus length is .
For a length-h window in an encoded input, its phase is its starting position modulo L. Since , it meets at most two source-letter blocks. Its dominant source letter is the letter of the block containing at least half of its positions, with ties resolved in favor of the left block. The selected side is determined by the phase alone.
Lemma 4.2 (Synchronizing code). For every source corpus and every as above with , there is a deterministic polynomial-time constructible code such that any two length-h windows occurring in the encoded corpus with identical binary contents have the same phase and dominant source letter.
Proof. Initially choose independently and uniformly one bit for each . All occurrences of the same source letter use the same block. A window starting at phase reads source-bit identifiers. These are distinct: if the window crosses a block boundary, its left suffix and right prefix have total length , so even equal adjacent source letters use disjoint offsets.
Consider two windows whose contexts (phase, dominant source letter) differ. Equality of their contents imposes one equality constraint per position. Remove comparisons of an identifier with itself and form the resulting multigraph on source-bit variables. Each window contains distinct variables, so every vertex has degree at most two. Each nontrivial component is a path or a cycle, including a possible two-edge cycle from parallel edges. If there are non-loop comparisons, equality rank is at least : a path with edges has rank , while a cycle with edges has rank . Thus the collision probability is at most .
Different phases imply , because every paired identifier has a different offset. If phases agree but dominant letters differ, the dominant side is the same in both windows and has at least positions. At all these positions the source-letter identifiers differ, so . Each bad-context collision therefore has probability at most . There are at most occurring windows and fewer than pairs, so the expected number of bad collisions is at most .
We derandomize by conditional expectations. Enumerate bad-context pairs using their source-bit identifiers, phases, and dominant letters, and precompute the connected components of each equality graph. Under a partial bit assignment, an event has conditional probability zero if some component contains assigned bits of both values. Otherwise, a component with unassigned variables contributes if it has an assigned bit, and if it has no assigned bit. Multiplication gives the exact conditional probability. Assign the at most variables one at a time, each time choosing the bit that minimizes the conditional expected number of bad events. The expectation never increases; it starts below one, so the final integer number of bad events is zero.
There are at most events, each involving at most variables. Their probabilities are dyadic rationals with denominators dividing , so exact sums and updates have polynomial bit complexity. Even recomputing every event probability for every variable is polynomial in . This proves the lemma.
4.3 Decoding small-cost parses
Fix any code satisfying the synchronizing property above, with . The decoding argument uses only this property and ; it does not depend on the probabilistic construction or the specific choice . Let be the total number of tokens in any collection of valid parses of the encoded corpus using at most optional binary words beyond 0, 1.
Lemma 4.3 (Marker decoding). If
then .
Proof. Include every token boundary in every parse, including both endpoints of each string. There are boundary incidences. Each boundary coordinate forbids phases at circular distance at most modulo , at most phases. Also forbid phases within circular distance of zero, so markers stay inside code blocks. By (1), fewer than phases are forbidden. Choose an allowed phase .
Place a marker at offset t in every source-letter code block. Each marker is more than h positions from every token boundary and both endpoints of its source block. Its forward length-h window therefore lies wholly inside one token occurrence and one source-letter block. A token containing a marker is longer than h; neither mandatory one-character token can contain a marker.
We define one decoded source word per used binary token type. Let be a used optional word with a marker in one occurrence. Its first bits are identical in all occurrences; the synchronizing property implies that every occurrence starts at the same phase. Since the length is fixed, the relative marker positions are identical in all occurrences. At each such relative position, the forward -bit window is fixed by , lies inside one source block in each occurrence, and has the same phase. Synchronization therefore gives the same dominant source letter in all occurrences. The ordered marked letters define a single word decode().
A used word with no marker is decoded as the empty word. This is consistent: if any occurrence contains a marker, the common first-h-window argument forces every occurrence to have the same phase, and hence the same relative marker positions. In particular the mandatory tokens 0 and 1 decode to the empty word.
Take the nonempty decoded images of all used optional words and remove duplicates, obtaining with . Each encoded source-letter block has exactly one marker, every marker belongs to exactly one token occurrence, and concatenation preserves marker order. Thus the decoded images of the tokens in any parse of concatenate to . Hence and .
By contraposition, on a source NO instance, every parse using at most K optional words satisfies
This is a real-valued lower bound; it follows because (1) must fail.
If , encoding a generating dictionary gives a parse with at most tokens, since every source factor is nonempty. Thus .
4.4 Near-linear inapproximability
Fix , and choose the fixed integers , , . We may assume . If , add fresh letters as singleton source strings and replace by . Every new singleton forces its own one-letter generator. No generator containing a fresh letter can help an old string, so the new rank equals the old rank plus . This padding preserves YES/NO and makes the source length . The padding is constant for the fixed .
For the padded instance choose , , . The output is polynomial in since is fixed. For , . Since and ,
Also . Since , (2) implies that on a source NO instance
On YES instances, encoding the source generators gives . An -approximation returns a feasible solution of cost at most
because . Evaluate the returned dictionary's true cost by dynamic programming and compare with the integer threshold . Equations (7)–(8) distinguish YES and NO in deterministic polynomial time, contradicting NP-completeness unless P = NP. This proves the bound.
The theorem quantifies separately over each fixed . It does not provide one reduction excluding all sublinear factors simultaneously or establish hardness of a linear factor. No PCP approximation gap is needed: the source is an exact rank decision problem, and the target gap comes from the long encoding and marker decoder.
4.5 Equal-length inputs with budget one below corpus size
We prove the same inapproximability bounds when the binary corpus consists of distinct equal-length strings and . The source is Néraud's NP-complete simplifiability problem: given a finite set of nonempty words, decide whether . This is the complement of elementariness in Theorem 5.1 [11].
Let , choose a fresh letter , and set . The words of are distinct and all have length . They satisfy . For the upper bound, adjoin to a minimum generating set for . For the lower bound, any generating set for contains a nonempty word made only of 's, since it generates . Erase from every generator. The images generate , and at least one image is empty; after removing empty images and duplicates, at most nonempty generators remain. Thus . Therefore is simplifiable exactly when .
The synchronization property makes the letter code injective: if two appearing letters had the same codeword, their phase-zero length- windows would have identical bits but different dominant letters. Its concatenation extension therefore maps distinct source words to distinct binary strings, all of common length . Use this corpus as the input to the same Binary DIRECT reduction with optional-vocabulary budget ; the marker-decoding lemma gives the required NO-instance soundness.
Before the near-linear reduction, first use the existing fresh-singleton padding to raise the source character count to . For the constant-factor reduction, pad only if needed to meet its condition. In either case, adding fresh singleton words changes the source set size from to
and its simplifiability threshold from to , preserving the answer. Apply the uniform-length padding afterward. Its new source length is in the near-linear case (and at least 2 in the constant-factor case), so the relevant parameter bounds apply using this resulting length as . Both transformations have polynomial size. This proves the restricted corollary.
5 Compression Savings and Fixed-Alphabet Approximation Schemes
The objectives of minimizing token count and maximizing savings have the same exact optimal vocabularies, yet different multiplicative approximation properties. In particular, if , then , which need not be a constant-factor approximation to .
5.1 Compression-savings objective
Inputs are explicit independent strings over an alphabet of size , with positive integer weights encoded in binary. Every character is mandatory. A vocabulary contains at most optional literal types, and only actual substrings of length at least two are useful. Write , , and for full encoding length. DIRECT chooses a minimum-token parse; longest match (LM) repeatedly emits the longest matching available prefix. Let be weighted token count and its savings utility. In this section we maximize : a multiplicative savings guarantee is not a multiplicative token-count guarantee. Positions in different inputs remain separate, including equal inputs.
5.2 Occurrence coverage
The maximum-coverage relaxation and its greedy implementation were studied by Lim et al. [6]. We state the relation between coverage and the savings of a valid DIRECT parse explicitly; this is the step needed to convert a coverage guarantee into a guarantee for the original objective. An occurrence saves tokens and covers integer boundaries . Give each boundary weight . Let be the union weight of boundaries covered by all actual occurrences of selected types. It is a monotone submodular coverage function.
Lemma 5.1. For DIRECT, , and the factor two is sharp.
Proof. The boundaries saved by a parse belong to the covered union, proving the upper bound. On one input take an inclusion-minimal subfamily covering the same boundary union. Sort its intervals by start. Starts and ends are strictly increasing, since containment would make an interval redundant. If , the integer boundary sets of intervals and overlap or are consecutive. Their union then covers every boundary of interval , a contradiction. Thus . Odd intervals form a character-disjoint family, as do even intervals. Their total saving is at least the union size, so one family saves at least half. Fill gaps with characters and apply this per input, preserving weights. For , coverage is and utility .

Figure 1: Schematic illustration of two groups of nonoverlapping intervals from a minimal occurrence cover. Each group yields a feasible parse after unused positions are filled with character tokens.
Theorem 5.2. Coverage greedy achieves in deterministic polynomial time, over arbitrary alphabets and even a restricted supplied candidate pool.
Proof. For optimal -type coverage , the residual at step is at most the sum of the marginals of its at most types. A maximum marginal therefore removes at least . Iteration gives . As , the lemma proves the claim. Zero residual permits early stopping. There are polynomially many actual substring types and boundaries; bitset coverage and exact integer-weight comparisons are polynomial. Evaluate the returned dictionary by position dynamic programming. For utility is zero; may instead be optimized exactly.
5.3 True-marginal greedy
Unlike the occurrence-based scoring used by GreedTok [2, 6], the algorithm analysed here evaluates every candidate using its true increment in optimal DIRECT savings, recomputing the shortest parses after adding each candidate type.
Lemma 5.3. For any two DIRECT dictionaries , .
Proof. Fix optimal parses for . Discard from optional intervals contained in one optional interval. Their total saving is at most , because within a interval the disjoint discarded intervals save at most . For each type insert all its surviving intervals into , removing intersecting optional intervals and filling gaps with characters. This feasible parse proves that the marginal of is at least its surviving saving minus the removed saving. This remains true for , whose marginal is zero by optimality of . Each interval meets at most two surviving intervals: one may cross its left endpoint and one its right, and any other intersecting interval would be contained. Summing losses over types charges at most twice. Adding the discarded saving proves the inequality.
Theorem 5.4. Greedy using the true DIRECT marginal utility achieves of optimum, uniformly over .
Proof. At a dictionary , some available marginal is at least when this is positive; monotonicity gives the same inequality otherwise. For , iteration from zero yields . For , partition the optimal parse saving by its two types; the best singleton realizes at least half. For it is exact. Exhausted candidates give the optimum. Every true marginal is computed by an exact segmentation DP, so the algorithm is polynomial.
The coefficient three in the exchange inequality cannot be reduced universally. On a string of distinct characters allow intervals , , , and . Dictionary saves ; each of the three other singleton additions has zero marginal, while saves . This concerns a restricted pool and the inequality, not a tight unrestricted-greedy ratio.
5.4 Additive support structure
For any full segmentation , let be its weighted number of occurrences times . Expanding every token outside into characters proves . Thus utility is XOS (a maximum of nonnegative additive functions), monotone and subadditive. An optimal parse supplies a tight lower support. Submodularity does not follow; the exchange proof above is the stronger interval-specific information needed here.
5.5 Fixed-alphabet approximation schemes
We strengthen the savings guarantees using short literals and a deterministic, approximately lossless candidate pool. The result concerns savings, not the direct token-count ratio. In contrast to the unrestricted-alphabet inapproximability in Baliga et al. [2], our approximation scheme assumes that the alphabet size is fixed.
5.6 A pointwise PTAS for DIRECT and longest match
Fix rational , set and . If , enumerate all subsets of at most actual substring types and evaluate exactly under the relevant parser. For fixed this is polynomial. If , take every occurring type of lengths 2 through . Both parsers then use at most tokens on a length- input, and LM uses exactly that many. Thus . Every feasible per-input saving is at most , so positive weighted summation proves a PTAS. More generally the pointwise inequality proves a PTAS for any finite nonnegative, coordinatewise monotone, degree-one homogeneous aggregation of the per-input savings vector, provided attainable objective values have an exact polynomial comparator. This extension does not assert the EPTAS below for such .
5.7 A small deterministic pool for DIRECT
Discard empty and singleton inputs; let be remaining weighted length. For , some bigram has boundary coverage at least , where is weighted input count. Alternating its occurrence edges on each path gives disjoint bigrams saving half the coverage. Hence . For each literal type , let be the union of its occurrence character positions. Retain ranges of weight at least , with . There are at most ranges. Greedily select the position incident to most unhit retained ranges. If remain, weighted averaging gives a position incident to at least : indeed . Thus positions hit all retained ranges, deterministically.
Put . At every chosen position and every dyadic scale , use endpoints on within distance and within its input, where . Endpoints include valid terminal coordinates. Include every resulting substring of length at least two. There are intervals per scale: if then , and otherwise . The pool has size .
Lemma 5.5. This pool contains a dictionary of at most types with DIRECT utility at least .
Proof. Fix optimal parses. Removing all types with light ranges loses at most . Every other type has an occurrence containing a hit position . For its length choose , and round both occurrence endpoints inward on the grid. If nothing changes. Otherwise total loss is less than , so the retained interval has length at least two and saving at least . Record its fixed literal prefix and suffix offsets and use the same trimmed word inside every old occurrence. Equal types have equal retained literals. Since original token intervals were disjoint, the replacements plus characters are legal. Each surviving old type produces at most one new type, so budget is preserved; collisions only help. Savings are at least .
Enumerate at-most- subsets of the pool and evaluate by exact parsing. Writing its size as with parameter-only , use at to absorb the logarithmic power into . All substring, range-incidence, and exact-weight operations have absolute polynomial overhead in the full encoding, including rational accuracy bits. Loops can be capped at the actual positions and candidates.
Theorem 5.6. DIRECT utility has a deterministic approximation scheme in time , and an EPTAS for fixed alphabet.
Proof. The first assertion is the pool enumeration. For the second, use the universal dictionary when ; otherwise is bounded by , and maximize the parameter factor over this finite range.
The replacement argument proves no LM EPTAS: LM may ignore the displayed replacement parse. Neither scheme gives exact FPT in . There is no deterministic FPTAS for either binary utility model unless P = NP: on explicit unit-weight inputs take . Integral utility bounded by must then be optimal, contradicting exact hardness. Encoded large weights are not needed for this exclusion.
6 Subexponential Exact Algorithms
The next results exploit representative occurrences of chosen token types to reduce the search space for exact optimization. The bounds are measured in the total length of distinct input strings.
6.1 Model and encoding
An instance is an explicit list of binary strings, a nonnegative integer budget , and mandatory character vocabulary . All asymptotic logarithms are base two; integral estimates use natural logarithms. At most additional word types may be selected. Each listed string is parsed optimally, and the objective is the sum of token counts, including repeated entries with multiplicity. Empty strings have cost zero and are discarded.
Let be the number of distinct nonempty input strings and their total length counting each distinct string once. Let be the full input representation length, including strings, multiplicities or weights, and budget metadata. Search is measured in ; input reading and arithmetic are polynomial in . For an ordinary explicit corpus of expanded character count and polynomial metadata, .
Theorem 6.1 (Unconditional binary DIRECT). There is an exact deterministic algorithm with running time . For , the same algorithm also has a K-sensitive endpoint-enumeration bound . The exponent constants and polynomial exponent are absolute. For an ordinary explicitly expanded corpus the total time is . Unary instances have the sharper exact bound .
6.2 Canonical parses give disjoint representatives
Group identical nonempty inputs into distinct strings with positive multiplicities . For any dictionary , the corpus cost is , where is the minimum number of vocabulary tokens in a parse. One canonical optimum parse per distinct input suffices.
The empty corpus is solved with no optional words, and uses characters. If , selecting every distinct input of length at least two as a word makes each nonempty copy cost one token, which is optimal. The remaining case has .
Lemma 6.2 (Disjoint representatives). There is an optimal optional dictionary with one representative occurrence for each type, such that these intervals are pairwise disjoint and , . Every optional type may be taken to have length at least two and to occur as an input substring.
Proof. Choose one minimum-token parse of each distinct input under an optimal vocabulary and delete optional types unused by these fixed parses. This preserves the chosen parses and their weighted objective. For each remaining type choose one occurrence from its fixed parses. Token intervals within a parse are disjoint, and distinct inputs occupy disjoint portions of the flattened corpus, so the selected intervals are pairwise disjoint and have total length at most n. Each is a used substring; optional characters are redundant.
This chooses occurrences from one fixed parse collection. Arbitrary substring occurrences may overlap; the chosen token occurrences cannot.
6.3 Endpoint enumeration and exactness
Flatten the distinct inputs into character positions while retaining boundaries. For , enumerate every increasing -position set . Pair consecutive endpoints into inclusive intervals . Reject intervals crossing an input boundary. Read the interval contents, deduplicate equal words, and evaluate their set as an optional dictionary of size at most . Adjacent intervals are allowed when ; the inclusive intervals then share no character.
Evaluate each candidate by exact segmentation dynamic programming on each distinct input and weight by its multiplicity. Every candidate is feasible. Conversely, Lemma 6.2 supplies an optimal dictionary with disjoint inclusive representatives; sorting their endpoints yields an enumerated selection with exactly those interval contents. Thus the minimum evaluated cost is optimal.
The number of endpoint selections is . For , the binomial lower-tail bound through gives . For , use and monotonicity of to obtain the same asymptotic conclusion: . The constants are absolute. Endpoint generation, boundary tests, deterministic content deduplication, and exact segmentation take time per branch with an absolute polynomial exponent.
Weighted arithmetic is polynomial in . A depth-first enumeration avoids any exponential-space requirement. Check against first, so a large binary-encoded budget causes no loop proportional to its numeric value.
6.4 Binary counting gives a subexponential bound
The nontrivial branch has , where counts distinct strings. For , fewer than nonempty binary strings have length below . Therefore . For , if then ; otherwise the preceding inequality gives . Hence . Since is increasing, . Substitution into the endpoint bound proves the endpoint theorem. For ordinary expanded length , and , so the complete running time is . For encoded multiplicities or unusual metadata, the factor is retained; the theorem does not claim subexponential input-reading in alone.
6.5 Hall matching and a second exact search
Join a used optional type to each distinct input whose fixed canonical parse uses it.
Lemma 6.3 (Distinct-input representatives). This bipartite graph has a matching saturating all used optional types.
Proof. If a type set has fewer neighboring inputs than types, delete and add each whole input in as a word when it is not already mandatory or retained. The budget decreases because . Inputs outside retain their parses. Each input in now costs one token. All types of were used in these inputs, so their parses contain at least token occurrences across fewer than inputs. At least one affected input had more than one token; the positive multiplicities therefore make the change strictly improve the objective, a contradiction. Hall's theorem gives the matching.
Thus one may independently choose, for each distinct input, either no word or one length-at-least-two substring, then deduplicate, enforce the cap, and evaluate. If , the number of candidates is at most , by Jensen's inequality for the concave function on . This offers a second exact search; the endpoint search remains the stated universal bound.
6.6 Unary denomination sets
When all strings are powers of one character, optional words are determined by lengths . Lemma 6.2 gives an optimal distinct length set with and . Enumerate these increasing sets and evaluate each input length by the minimum-coin DP using denominations .
Let count all sets of integers at least two with sum at most . For , , . An increasing-set recursion visits each feasible set once, and every prefix is feasible; work per node is polynomial. The infinite product is only an analysis bound. This proves the unary result. Inputs are explicit; binary-encoded unary lengths are not treated as free expansions.
6.7 Structural parameters for exact algorithms
6.8 Cross-input sharing and private whole words
Let be the longest substring shared by two different distinct nonempty inputs, with when none exists. Group duplicate inputs into positive weights before computing ; repetition within one input does not count. Pairwise longest-common-substring dynamic programming computes in time.
Private types occurring in only one distinct input can be replaced by that whole input: remove all such selected types, add each affected whole input once, and parse it in one token. The number of additions is at most the number of removed types. This preserves an optimum. For a fixed shared dictionary, private whole inputs yield independent weighted gains.
6.9 Shared-type scope width
Call a length-at-least-two optional type shared when it occurs in at least two distinct inputs, and let be the number of actual shared types. Every other useful type is private. Replacing every used private type by its whole input, as in the private-word normalization, shows that some optimum consists of shared types and private whole inputs. Enumerate the shared subsets and, for each, select the best private whole-input gains after exact weighted segmentation. This gives another exact time bound .
Fix an order of distinct inputs and flatten their positions without permitting a token to cross an input boundary. For each shared type , let be its first occurrence start and its last occurrence end. At position put , .
Theorem 6.4 (Shared-type scope-width exact algorithm). For this supplied ordering, exact weighted DIRECT is solvable in time. After the polynomial shortcut, , so this is FPT in with absolute polynomial overhead. No bound in alone follows.
Proof. At each token boundary , keep a state : the minimum cost of a partial corpus parse, its number of distinct optional types used so far, and exactly those used shared types still in . A character edge adds its input weight. A shared-type occurrence edge adds that weight and increments only when its type is absent from . A private whole-input edge adds its input weight, increments once, and needs no mask bit because that whole word has only one occurrence in the distinct corpus; length-one inputs instead use their free character token. Project the updated shared mask onto at the edge's endpoint . Input-boundary edges cost zero. A previously used shared type no longer live cannot appear again, while a type first becoming live during a jumped-over interval has not been used. Thus the state simulates all feasible parse sequences and charges each type once. There are at most states and polynomially many occurrence transitions per state. Therefore the dynamic program has the stated running time.
For the decision version with a weighted total-token threshold, actual optional substrings have polynomially many candidates. A polynomial-size Boolean circuit unrolls exact segmentation and threshold comparison from activation variables. Padding an at-most- chosen set with ignored variables reduces the nontrivial branch to weight-exactly- circuit satisfiability, so decision DIRECT belongs to W[P]. This is an upper bound in parameterized complexity; it does not establish FPT or W-hardness for alone.
7 Unary Bottom-Up and Optimal Pair Encoding
We first establish APX-hardness of unary standard bottom-up tokenisation, then prove strong NP-completeness for unary optimal pair encoding (OPE). The difference is whether merge rules are executed on current parses or used only to build a vocabulary for a subsequent optimal parse. The definitions of both models were given in Section 2.
7.1 Hardness theorem and occurrence alignment
For unary input , we identify each token with its length. A rule merges all nonoverlapping occurrences of one adjacent pair, from left to right. We use at most rules, and the cost is the number of tokens in the parses they produce.
Theorem 7.1 (L-reduction from cubic Vertex Cover). Unary standard bottom-up token-count minimisation is APX-hard. More precisely, from a simple cubic graph we can build an explicitly represented unary dataset , a budget , and a baseline , in polynomial time, such that , where and is the minimum vertex-cover size. Every feasible bottom-up sequence with token cost can be decoded to a vertex cover satisfying , and .
Write for the 2-adic valuation of a positive integer . We use the following invariant: if is the largest power of two productively created by doubling, each current unary parse has form , . The prefix may be empty. For a non-doubling rule the operand of smaller valuation appears uniquely per parse, so the rule can act at most once on each individual string. A doubling replaces adjacent equal tokens in the prefix by and preserves the prescribed tail form.
Lemma 7.2 (Occurrence alignment). After at most productive bottom-up merge rules, every actual occurrence of a token of length begins at a position divisible by . In particular, if a string of length ends with a two-token parse , then and .
Proof. Contract maximal subtrees consisting only of power-of-two doublings in the merge tree of an actual token occurrence. Let be the largest contracted leaf length. By induction over the merge sequence, the largest pure-doubling leaf labels of consecutive current tokens are nonincreasing from left to right, and each actual occurrence begins at a multiple of its own largest such label. A non-doubling rule combines a left label at least as large as its right label and retains the left occurrence start; a doubling operates on the pure-power prefix and creates tokens aligned to multiples of . An actual token whose total length is a power of two cannot be created by merging operands of distinct 2-adic valuations, so the claimed dichotomy is exhaustive.
Each contracted internal merge-tree node is a non-doubling event. By the parse invariant, no such rule acts twice on the same string; hence a token formed after at most rules has at most non-doubling events and at most leaves. Its length is thus . Both and are powers of two, so divides , implying the desired alignment. The congruences for a final two-token parse follow by applying alignment to its right token.
7.2 Cubic vertex cover and twelve separated bands
Let be simple cubic with vertices, edges and minimum cover size . The source problem is APX-hard [12]. Subdivide every original edge into the path to form . Then , , . Indeed, a cover of extends by choosing one appropriate internal vertex per original edge. Conversely, if covers and , every edge of not covered by requires both internal vertices. Adding one endpoint of each uncovered original edge gives a cover with .
Properly colour with colours and orient every edge from its lower-coloured endpoint (colour ) to its higher-coloured endpoint (colour ). Use twelve exponent bands , , . Set and choose , . Give distinct vertex IDs in and edge IDs in . Define, for an original vertex of colour and an edge oriented from colour to ,
All atom coefficients lie in . Each atom occurs in at most six of the ordered triples , , . These triples encode respectively the edges , and of H. The real choice length associated with an original vertex v is ; the two internal vertices have and .
Their band pairs are precisely , and for . In contrast, the nonadjacent band pairs within triples are , and . Thus no real choice coincides with the sum of nonadjacent atoms of a triple.
7.3 Base lengths, explicit input, and canonical merges
Put , . The character length 1 is free. There are dummy choice lengths , one for each . Let , , . Construct the explicit dataset using copies of every non-character base anchor for , copies of each real-choice anchor , copies of every dummy anchor , and one copy of each of the triple-sum edge strings. All string lengths and repetitions are written in unary. Distinct categories have different digit supports in radix .
The construction gives , hence , while , . Every input length is polynomial in : the maximum anchor length is , and there are strings, giving explicit input size .
A common preamble of exactly rules constructs every member of . First double powers of two up to . Every parse is then the descending binary expansion of its length. For each band in increasing order and each non-power-of-two coefficient , merge when the second operand is nonzero. Smaller coefficients have been assembled first, so the rules assemble the corresponding suffixes and then the leading power-of-two. As , the rules do not cross band boundaries. After this preamble every base anchor is a singleton; each real and dummy anchor has its intended two-token parse; and every edge string has the corresponding three-atom parse.
For of cardinality , append the real choice rules for vertices of and different dummy rules. The resulting cost is , , where counts edges of not covered by . An incident choice rule reduces an edge triple from three tokens to two; overlapping incident rules cannot both act within the same triple.
7.4 Unrestricted helpers and the global lower bound
Call a token length normal if it belongs to , is a real choice, or is a dummy choice. All other non-character lengths are helpers. The radix construction implies that the only representations of an edge-string length as a sum of two normal lengths are its two intended incident-choice-plus-atom representations. Briefly, two single-band normal lengths cannot represent a three-digit target; a real choice plus a base can do so only by using the two intended adjacent bands; two real choices either overlap with excessive coefficient or occupy too many bands; and a dummy is too large.
The difficult step is to control two-token parses created by arbitrary additional helper lengths. Consider an edge string with no generated incident real choice, of length , , . Suppose its actual final parse consists of . If , then . Were normal, it would have to equal the left intended incident choice , contradicting the assumption. Charge this edge to the helper ; its leading digit pins its top atom.
If , let be the least power of two greater than . Then , , . Occurrence alignment gives . If is a helper, charge the edge to ; for fixed bottom band , its residue pins the bottom atom. Otherwise a normal cannot be a one-band base or a dummy. It must be a real choice whose lower atom equals and whose upper band is strictly between and . Its complement is then a helper satisfying . Charge the edge to ; its leading digit pins one of at most two possible top atoms per band.
For each fixed helper, there are at most two possible top atoms per band and one possible bottom atom per band. With twelve bands and at most six edge-string appearances per atom, a helper is charged for at most relevant two-token edge strings. A singleton edge string requires its own distinct edge-length helper. Allowing for two saved tokens on such singleton strings yields the conservative saving bound of 218 per distinct helper.
Consequently, if is the set of generated real-choice lengths and is the number of distinct helper lengths, the edge-string token count obeys .
7.5 Optimal value and L-reduction constants
Suppose an arbitrary feasible sequence generates real-choice lengths, dummy lengths and helper lengths, while omitting of the non-character base lengths. Since at most distinct non-character lengths are generated, . Each omitted base anchor costs at least one extra token per copy, and each omitted real or dummy choice anchor costs at least one extra token per copy. Combining the anchor bounds with the helper bound gives
Add one endpoint for every edge of left uncovered by , obtaining a vertex cover with . Conversely, choosing the real choices of a minimum vertex cover of in the canonical construction attains , so . Use the decoder for the subdivision step to obtain a cover of the original graph with , which is the L-reduction inequality with . Finally, the construction bounds , and cubic graphs satisfy . Substituting ,
, and yields . This gives the L-reduction with and . It follows that the problem has no PTAS unless P = NP. APX-hardness alone does not imply membership in APX.
7.6 Strong NP-completeness of unary OPE
The next reduction studies the merge-extracted-vocabulary version of OPE. It is distinct from the standard bottom-up execution model and requires its own hardness argument.
Theorem 7.3. The decision version of unary optimal pair encoding is strongly NP-complete on explicitly represented unary datasets. The reduction uses only polynomially bounded lengths, polynomially many explicitly repeated strings, and a linear merge budget in the source graph size.
7.7 Source problem and construction
We reduce from maximum -vertex coverage on bipartite graphs. Let , , , where , , and . For a set , let be the number of edges with at least one endpoint in , and define , . The decision problem asks whether , with . This problem is NP-complete: its NP-hardness is established by Joret and Vetta [13], and a vertex set is a polynomial certificate. The “at most ” version is equivalent by padding the chosen set.
Let be the smallest power of two strictly larger than , and put , . Define the fixed base lengths
The three parts are disjoint, , and is the number of non-character base words. Associate choice lengths with the vertices:
For every edge , define
All base, choice, and edge lengths are distinct across these categories; edge lengths are distinct for distinct edges. This follows from quotient and remainder modulo , using .
Set the repetition counts
The dataset consists of the following actual strings, not binary-encoded weights:
| String type | Length | Copies of each string |
|---|---|---|
| Base anchor | A | |
| Vertex anchor | or | C |
| Edge string | for | 1 |
Finally, choose
We will prove the exact identity
7.8 Excluding unintended two-token representations
Let the full set of potentially intended words be . This is not a restriction on the input vocabulary. The lower-bound argument below establishes the stated form for optimal solutions of the constructed instance.
Lemma 7.4. For every , the only unordered representations of as a sum of two elements of are . Moreover, .
Proof. The low elements of , those smaller than , are , , , , and all are at most . The high elements are and , for .
Two low elements sum to at most . Two high elements have sum congruent to , , or modulo , whereas has remainder , strictly between and . Thus precisely one summand is high.
If the high summand is , the other summand must be , and , since the low summand is smaller than . If the high summand is , then plus the low summand is at most ; again there is no carry into the quotient, and necessarily with low summand . These are precisely the two displayed decompositions. The same quotient-remainder description shows .
7.9 A globally valid exhaustive-merge construction
A valid addition chain for the desired lengths would not suffice here: in bottom-up tokenisation the rules must actually form the required adjacent pairs in every string simultaneously. The following construction establishes that stronger property.
Lemma 7.5 (Binary assembly). Start with the descending binary expansion of each integer , represented as a list of its distinct power-of-two summands. For each non-power-of-two , in increasing order, apply the rule , . Every such list becomes its single token . The statement also holds after multiplying all token lengths and rule operands by a common positive integer.
Proof. For a list with highest binary summand , its suffix represents . By induction on the highest binary summand, that suffix is assembled into using rules with output at most . No non-power rule involving is applied before output , so the suffix has finished before can participate in any rule. If , the list is now . Among rules with first operand , only the rule with output can act on this pair. It makes the whole list a singleton. If , the list was a singleton already. Scaling every length preserves all pair matches.
Lemma 7.6 (Base preamble). There is a sequence of exactly exhaustive left-to-right merges, creating precisely , that produces
Proof. First perform all doublings , starting at and ending at the largest power of two at most . All their outputs belong to : those below lie in , followed by , and the powers that are multiples of .
Successive left-to-right doubling gives the descending binary expansion of any input length. Every relevant length is less than . Since Q is a power of two, any power of two greater than pQ is at least ; therefore the doublings performed suffice for all relevant strings.
Next, for each non-power-of-two , in increasing order, perform . By Lemma 7.5, this assembles each right-hand binary block . It cannot cross the preceding token , which exceeds all operands in this stage.
Finally, for each non-power-of-two , in increasing order, perform , . The scaled form of Lemma 7.5 assembles the left block . These rules use only multiples of , so they cannot cross or interact with a right block .
The initial binary expansions have exactly the separated blocks just described, because and . This proves all asserted parses. Every non-character base length is created exactly once: powers of two in the first stage, non-power small lengths in the second, and non-power multiples of in the third. No other length is created. The total number of rules is therefore .
Fix any set of exactly vertices. After , append the rules for , for . They can be appended in any order. Each rule has a new output length, and is productive on its own vertex anchor.
Base anchors remain singletons. A selected vertex anchor becomes one token; an unselected anchor remains two. An edge starts at . If at least one endpoint is selected, the first applicable endpoint rule reduces it to two tokens. When both endpoints are selected, the other rule cannot subsequently apply, because the middle token B has been consumed. If neither endpoint is selected, the edge remains three tokens.
Thus the sequence has exactly rules and achieves
In particular, writing , we have .
7.10 The lower bound, even for unrestricted direct vocabularies
Consider an optimal direct vocabulary W containing the character 1 and at most K additional words. By (1) and the preceding construction, its total cost is at most H.
7.11 Every base word is forced
If some is absent from , all copies of its anchor need at least two tokens. Each of the other anchor types needs at least one. The base anchors alone then cost at least , a contradiction. Hence , and the base contribution is exactly .
7.12 Exactly k vertex words are forced
The base has already used of the additional-word budget, so at most choice lengths can be in . Let be their number. If , the vertex anchors cost at least . Even allowing every edge string to become a singleton, the overall cost would be at least , another contradiction. Thus .
These distinct non-character words exhaust the whole budget. Therefore for a set of exactly vertices. In particular, no spare helper length, edge length, or duplicate output can bypass the intended choices. This normal form was derived from an arbitrary optimum, not assumed.
7.13 Edge savings are bounded by coverage
Every edge needs at least two tokens because its full length is not in . By Lemma 7.4, an edge with neither endpoint in has no two-token representation at all, so it needs at least three. The resulting lower bound is . Combining this with (8) and (1) proves (7).
7.14 Complexity consequences and scope
By (7) and the definition of , . This proves the required reductions.
7.15 Polynomial explicit size
Since , we have . Every string length is less than . Also , , and . There are explicit dataset strings, so their total character count is , at most for a simple graph. The budget and the threshold are polynomially bounded as well. There is no exponential-length unary string hidden in a binary encoding.
7.16 Membership in NP
Let be the total explicit character count and the maximum input-string length. For bottom-up tokenisation, no-op rules may be deleted: any token that never appears cannot affect a later parse. Every remaining rule reduces the total token count by at least one, so a certificate requires at most productive rules. Its operands are words of length at most , and its action can be simulated in polynomial time.
For the OPE-type model, only words of length at most can be useful. All ancestors of a useful generated word also have length at most , since concatenation adds positive lengths. Keep the relevant generation dependencies, removing duplicate words and unused rules. This leaves at most additional unary words. Alternatively, if , all lengths can be generated with additions, making every input a singleton. For a guessed vocabulary , optimal segmentation is verified by the recurrence , (). Summing over all dataset entries verifies the target cost in polynomial time. This establishes NP membership and completes the proof of Theorem 7.3.
Corollary 7.7. Unless , neither optimisation problem has a deterministic fully polynomial-time approximation scheme on explicitly represented unary datasets.
Proof. For a nonempty dataset, the optimum is an integer at most its total explicit length . An FPTAS with would return a feasible integer cost less than OPT+1, hence exactly OPT, in polynomial time. This contradicts Theorem 7.3 unless .
The reduction does not establish APX-hardness or exclude a PTAS: the forcing terms may dominate the variable coverage contribution. It concerns datasets with repetitions, not one unary input string or a dataset with at most two distinct lengths. It does not establish approximation guarantees for unary OPE or standard bottom-up token count.
8 Conclusions and Open Problems
8.1 Conclusions
We have presented a joint account of optimization and hardness results for direct and unary merge-based tokenisation. The main contrast is that binary direct token count admits no -approximation under while admitting a polynomial-time approximation; maximizing the corresponding savings admits a fixed-alphabet EPTAS. Structural properties of optimal dictionaries further yield subexponential exact algorithms. The APX-hardness of unary bottom-up tokenisation and the strong NP-completeness of unary OPE show that the exact semantics of merges matter.
8.2 Open problems
Key questions include whether binary direct tokenisation is fixed-parameter tractable in vocabulary budget alone; whether binary standard bottom-up token count admits any constant-factor approximation; whether unary OPE admits a PTAS; and how closely the polynomial-time bounds for binary direct count can be matched without invoking ETH. Further work should distinguish exact global vocabulary selection from greedy merge-frequency heuristics and should investigate which of the structural exact algorithms extend to alternative parsing semantics.
AI disclosure. The authors used GPT-5.6 Sol during the preparation of this work to brainstorm and refine constructions, explore proof strategies, and discuss and check mathematical arguments. The model also assisted with proofreading and aspects of the literature review. All mathematical claims, proofs, and cited results were independently verified by the authors, who take full responsibility for the accuracy and content of the paper.
References
[1] Violeta Kastreva, Philip Whittington, Dennis Komm, and Tiago Pimentel. Tokenisation over bounded alphabets is hard. In International Conference on Learning Representations, 2026. URL https://proceedings.iclr.cc/paper_files/paper/2026/hash/3e15f03271a92e1dfd001050b7bc08df-Abstract-Conference.html.
[2] Kundan Baliga, Aiden Xie, and Aditya Byju. GreedTok is a constant-factor approximation for partition-cover tokenization, 2026. URL https://arxiv.org/abs/2611.07346. arXiv:2611.07346.
[3] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 1715–1725. Association for Computational Linguistics, 2016. doi: 10.18653/v1/P16-1162. URL https://aclanthology.org/P16-1162/.
[4] Taku Kudo and John Richardson. SentencePiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pages 66–71. Association for Computational Linguistics, 2018. doi: 10.18653/v1/D18-2012. URL https://aclanthology.org/D18-2012/.
[5] Philip Whittington, Gregor Bachmann, and Tiago Pimentel. Tokenisation is NP-complete. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 28133–28153. Association for Computational Linguistics, 2025. doi: 10.18653/v1/2025.acl-long.1365. URL https://aclanthology.org/2025.acl-long.1365/.
[6] Jia Peng Lim, Shawn Tan, XianJun Davin Choo, and Hady W. Lauw. A partition cover approach to tokenization. In Advances in Neural Information Processing Systems, volume 38, 2025. doi: 10.52202/085713-2237. URL https://papers.neurips.cc/paper_files/paper/2025/hash/605e59e78284907aa4fce5280838def3-Abstract-Conference.html.
[7] László Kozma and Johannes Voderholzer. Theoretical analysis of byte-pair encoding. In 34th Annual European Symposium on Algorithms (ESA 2026), volume 388 of Leibniz International Proceedings in Informatics (LIPIcs), pages 80:1–80:17. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2026. doi: 10.4230/LIPIcs.ESA.2026.80. URL https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ESA.2026.80.
[8] Jan Tempus, Philip Whittington, Craig W. Schmidt, Dennis Komm, and Tiago Pimentel. Tokenisation via convex relaxations, 2026. URL https://arxiv.org/abs/2605.22821. arXiv:2605.22821.
[9] Hedi Chehaidar, Mihail Stoian, Moritz Stargalla, and Andreas Kipf. OptFSST: Optimized FSST string compression, 2026. URL https://arxiv.org/abs/2607.11271. arXiv:2607.11271.
[10] Alfred V. Aho and Margaret J. Corasick. Efficient string matching: An aid to bibliographic search. Communications of the ACM, 18(6):333–340, 1975. doi: 10.1145/360825.360855. URL https://doi.org/10.1145/360825.360855.
[11] Jean Néraud. Elementariness of a finite set of words is co-NP-complete. RAIRO Theoretical Informatics and Applications, 24(5):459–470, 1990. doi: 10.1051/ita/1990240504591. URL https://www.numdam.org/item/ITA_1990__24_5_459_0/.
[12] Paola Alimonti and Viggo Kann. Some APX-completeness results for cubic graphs. Theoretical Computer Science, 237(1-2):123–134, 2000. doi: 10.1016/S0304-3975(98)00158-3.
[13] Gwenaël Joret and Adrian Vetta. Reducing the rank of a matroid. Discrete Mathematics & Theoretical Computer Science, 17(2):143–156, 2015. doi: 10.46298/dmtcs.2135.