WorksComputer Science
Tokenization: Hardness and Bicriteria Approximation Algorithms
Abstract
We study Binary Tokenization: given a corpus of binary strings over and a vocabulary budget , select at most substrings (called vocabulary) to minimize the total number of tokens needed to represent the corpus. The primitive symbols and are always available, and each document must be segmented separately. Letting denote the total corpus length and for the maximum document length, we prove that, for every fixed , Binary Tokenization problem does not have polynomial-time -approximation algorithms unless . To complement the hardness result, we give a polynomial-time -bicriteria algorithm, with : The algorithm outputs a vocabulary of size at most with number of tokens at most , where is the optimal number of tokens under the original budget . We also study a storage-budget variant, in which the sum of the selected substrings' lengths is bounded by . For , we obtain an -bicriteria approximation algorithm.
Introduction
Large language models typically process text as sequences of tokens drawn from a fixed vocabulary. The process of segmenting text into units, called tokenization, determines the representation on which the model operates. Tokenization is a fundamental determinant of LLM’s computational efficiency. Representing the same text with fewer tokens can reduce training and inference costs and allow more content to fit within a fixed context window; empirical studies show that tokenization can substantially affect these benefits as well as downstream performance. [Dagan+24]; [Ali+24]
Achieving shorter sequences, however, requires choosing an effective vocabulary: adding longer or more specialized tokens can improve compression, but enlarges the model’s embedding and output layers, increasing their memory and computational costs. [Dagan+24] This tradeoff motivates a basic optimization question underlying tokenization: given a limited vocabulary budget, which substrings should be selected to minimize the number of tokens needed to represent a corpus? Understanding the computational limits of this problem provides a theoretical foundation for an important efficiency objective in large language modeling.
We consider the optimization problem underlying this tradeoff. Given a corpus and a vocabulary budget, the goal is to select a shared set of substrings that minimizes the total number of tokens in the corpus. Each document must be partitioned into selected tokens, with individual characters always available. Although there are efficient algorithms for finding an optimal segmentation for a fixed vocabulary, choosing the vocabulary requires coordinating decisions across the entire corpus. A useful token may occur in many documents, and overlapping occurrences create competition among otherwise promising choices. Consequently, frequency alone does not capture the value of a vocabulary entry.
The computational complexity of tokenization has recently attracted increasing attention. Whittington, Bachmann, and Pimentel [8] proved that the decision versions of both direct tokenization, which selects a vocabulary, and bottom-up tokenization, which selects a sequence of pair merges, are NP-complete. Kastreva et al. [11] strengthened these results by establishing APX-hardness even over a binary alphabet, ruling out polynomial-time approximation schemes unless ; they also showed that direct tokenization remains NP-complete over a unary alphabet. On the algorithmic side, Lim et al. [9] formulated vocabulary selection as a partition-cover problem and introduced GreedTok, while Tempus et al. [Tem+26] developed ConvexTok using convex relaxations that provide instance-specific certificates of solution quality. Approximation guarantees have also been established for compression savings: Kozma and Voderholzer [10] proved that BPE achieves at least one-third of the optimal pair-encoding utility. These savings guarantees do not imply corresponding multiplicative approximations for minimizing the remaining token count.
Our main results establish polynomial-factor hardness of approximation for this problem for any , even over a binary alphabet, where denotes the total corpus length. Earlier work established only constant-factor inapproximability, ruling out polynomial-time approximation ratios below unless [11]. Motivated by this difficulty, we develop bicriteria approximation algorithms that allow a controlled increase in vocabulary size while bounding the token count relative to the optimum under the original budget. In particular, for a binary corpus of total length and maximum document length , we provide polynomial-time -bicriteria algorithms, with , where is the vocabulary budget. Each algorithm selects at most vocabulary entries and produces at most tokens, where is the minimum token count under the original budget .
We also consider a storage-budget model, which requires instead of bounding the number of vocabulary entries. For , we obtain a polynomial-time -bicriteria approximation for storage and token count, measured against the optimum with storage budget .
We would like to note that it is easy to get a -approximation algorithm: order the tokens by their frequency and take the top of them where is the budget on the cardinality of the vocabulary.
Preliminaries and model definitions
Binary Tokenization
Let be a nonempty string of characters from a binary alphabet , we call it a document. A collection of documents form a corpus that is used to train language models. However, this corpus is considered raw and as a preprocessing step for a language model, we segment it before feeding it for training. During segmentation, a corpus is transformed into sequence of tokens suitable as an input. Let be a set of all possible tokens given , be the total length of the corpus and be the length of the longest string.
For fixed , let
Definition 2.1 (Tokenization (Tok)). Given and an integer , minimize
In the literature, this is also called Binary Direct Tokenization.
Definition 2.2 (Binary Tokenization with a storage budget). Let . Given and an integer , minimize
The storage cost charges each distinct spelling once, without shared representation. It excludes the free primitive bits. The alphabet is binary in both definitions; the occurrence-cover arguments themselves also work over general finite alphabets.
An bicriteria algorithm returns at most entries and at most tokens for cardinality, or storage at most and at most tokens for storage. The comparison optimum always obeys the original budget. A standard approximation has . Let . We use for the empty word and for an approximation exponent.
With or , primitives are exact. In the cardinality model, one string is trivial once ; a corpus is trivial when all its distinct nonprimitive documents fit. In storage, permits buying all such documents. The interesting storage range is therefore . All complexity bounds use explicitly written corpus length, not succinct binary-encoded document multiplicities.
Relevant Definitions For Hardness Proof
In the hardness proof, we will use the Vertex Cover decision problem as the source of the hardness, then use the Word Factorization as an intermediate step to establish a hardness factor for the Binary Tokenization optimization problem. The relevant definitions are given below.
Definition 2.3 (Vertex Cover (VC)). Let be a simple undirected connected graph where is the set of vertices and is the set of edges. Denote the size of the vertices to be and the size of the edges to be . Let denote the minimum size of a vertex cover. For a budget , The vertex cover decision problem outputs
YES: if .
NO: if .
We will define the word factorization problem next. In this problem, one seeks to minimize a property of the given corpus called "rank". The rank counts the minimum number of generators needed to generate the corpus. It is analogous to the concepts of the dimension counting the size of a basis in linear algebra.
Definition 2.4 (Generating set). Let be an alphabet and let be a set of words. A set is a generating set for if every word in can be written as a finite concatenation of words from . Equivalently,
where denotes the set of all finite concatenations of elements of , including the empty word.
Definition 2.5 (Generating Rank). Let be a finite set of nonempty words over an alphabet . The rank of is the size of its smallest generating set, i.e.
It is important to note that singleton letters in count toward .
Definition 2.6 (Word Factorization (FAC)). Given a finite set of nonempty words over an alphabet and an integer . The Word Factorization problem outputs
YES: if .
NO: if .
Binary Tokenization
Hardness of approximation
We will use the NP-hardness of the Vertex Cover decision problem to produce a hardness of approximation gap for the Binary Tokenization optimization problem. Step one is to first reduce VC to FAC and prove a relationship between the objective values of the two problems. This reduction is adapted from the paper "Elementariness of a finite set of words is co-NP-complete" [1]. Step two is, through a binary encoding function, transform the FAC instance into a Binary Tokenization instance and prove a relationship between the objective values of these two instances. Lastly, we would combine the two relationships between objective values to obtain the hardness factor of the Binary Tokenization problem.
Reduction 1 (VC to FAC). Consider a vertex cover instance with graph and budget . Assign distinct singleton letters to each vertex of . For each edge , also assign 3 distinct edge-specific singleton letters , , . Let alphabet be the set consist of all these singleton letters. Note .
For each edge with edge specific singletons , , , we make a set of words
Let our total set of words be
Let . Let denote the length of , i.e. the sum of the lengths of all the words in . Here, .
Note because because each vertex is adjacent to at least one edge due to connectedness.
The following lemma provides a relation between and .
Lemma 3.1 (, identity). The source corpus satisfies
The proof of Lemma 3.1 is given in Appendix § 5.
The above lemma bridges the YES and NO instances of the two problems, we have
The idea of the remaining of the proof is that, even after the encoding, the resulting Binary Tokenization problem is still in essence the original Word Factorization problem because we will process each letter’s encoding as its own chunk, i.e. we avoid segmenting a letter’s encoding. We will give each letter its unique binary encoding, and we combine (in a slightly sophisticated way) these binary encoded letters according to the original corpus to form the binary encoded corpus. We want the Tokenization instance to segment the binary encoded corpus corresponding to the original letters, i.e. we want a segmentation where the token boundaries align with the boundaries of the binary encodings of the letters. To ensure the alignment of the boundaries, what we do is to repeat each binary encoded letter a large enough number of times. One of these repeats will not have misaligned boundaries, then we tokenize all other repeats the same way as the "good" repeat. Since the boundaries align, no letter has its binary encoding cut into pieces, then we can factorize the original letter corpus according to binary tokenization of the binary encoded corpus.
Instance Transformation 1 (FAC instance to Tok instance). Let the FAC instance be the one defined in Reduction 1. We will now encode it into a binary corpus. Let be the constant defined in Theorem 3.3. Define , , . We define here because we eventually want to repeat each letter in the FAC problem times in the final encoding.
The "building blocks" to the final binary encoding are the elements . As you can see, we are repeating each element a total of times. For an element , we call its "phase". For every , we want to assign it a unique binary string. Since there are number of such elements, we will need bits in the binary string. Choose any injective function to do the assignment. Such a function exists because, for example, one can naively enumerate the elements and assign to each element their enumeration.
For an output string of the function chosen above, we add delimiters and alternating internal padding to it as follow
Finally, we will define the unique "binary block" associated to element to be
Note each binary block has length .
Now we can define the binary encoding function . For a singleton letter , we define the binary encoding to be the concatenation of all "repeats" of the blocks.
Note each encoding of a singleton letter has length . Now for a word , , we just define its binary encoding to be the concatenation of the binary encoding of each of its singleton letters.
Finally, we can now define the corpus of the tokenization problem.
This corpus has distinct documents of length and total length
Let the alphabet be . Let .
Building off of Lemma 3.1, the following proposition relates and . Note that at this step, the choice of is not yet important.
Proposition 3.2. For every integer , Transformation 1 satisfies
The proof is given in Appendix § 6.
Applying Lemma 3.1 with Proposition 3.2, we get
At last, we obtain the result for our main theorem.
Theorem 3.3 (hardness of approximation). For every fixed , unless , there is no deterministic polynomial-time algorithm that returns, on every input, a vocabulary at most size satisfying
where is the total corpus length. This holds even when all documents are distinct binary strings of the same length.
Proof. Assume for the sake of contradiction, such approximation algorithm exists that approximates to within with a vocabulary at most size . Take a nontrivial Vertex Cover instance and construct as above. Run the algorithm at budget . Run the polynomial PathPiece [Gold+24] algorithm, which outputs the optimal segmentation given a vocabulary, on the output vocabulary to obtain .
Before we do further computation, let’s examine some relationships between parameters. Recall the definition of parameters , , , and and the fact that . Due to the definition of , we have and , so we can obtain
Combining equation (5) and equation (11), we get
In a YES instance, we would have
The second inequality is due to equation (8), the third inequality is due to equation (12) and the fact that . To justify the last inequality,
.
In a NO instance, every feasible output satisfies by equation (9).
Note and partitions the possibilities of being in the YES or NO case for the Vertex Cover decision problem. Therefore, testing the integer inequality decides Vertex Cover in polynomial time. We’ve reached a contradiction. Hence, we’ve proven Theorem 3.3.
Bicriteria approximation algorithms
In section 3.1, we showed the hardness of approximating the tokenization problem and its NP-hardness. The following results provide a polynomial time bicriteria approximation algorithms that bounds the vocabulary size and the tokenization cost within guaranteed multiplicative factors of the optimal solution, covering nontrivial cardinality range . We write and use the corpus parameters of § 2. Also, whenever tokens are mentioned, they refer to .
An occurrence of a word in a document is an interval such that appears in positions in , and we say the interval covers . Two occurrences and are disjoint if they lie in different documents, or if their intervals do not overlap. Let be the offset of document . We map each occurrence to its interval in corpus coordinates by
Therefore, each occurrence is identified with its global interval and denoted by . For , define
Thus, is the set of all occurrence intervals of in the corpus.
A bundle for is a nonempty subset whose occurrences are pairwise disjoint. For a fixed parameter , the cost of a bundle is:
That is, selecting a bundle incurs a fixed cost and a unit cost for each occurrence it contains. Given a set , gain and density of a bundle is
We also allow a corpus position to be covered by a single character and we call it a singleton, with cost, density and gain of 1.
A cover consists of a list of bundles and a list of singletons such that their union covers every corpus position. The cost of a cover is the sum of the costs of its listed bundles and singletons. That is:
For each , order its occurrences by increasing global start coordinate, writing . For each interval , define
to be the index of the last occurrence that doesn’t overlap with . For a fixed and , let . Then, define to be the maximum total gain of exactly disjoint interval occurrences of among . For every :
We compute this value using a two dimension dynamic program, initialized as:
Then, use
The first term excludes and selects disjoint occurrences among the first occurrences. The second term includes and selects the remaining occurrences among the first occurrences.
We can get the best-density bundle for by:
The algorithm 1 finds the best density and by backtracking, identifies a bundle with this density.
Algorithm 1: Fixed Word Best Bundle
Input: Ordered occurrence set O, Uncovered positions for each occurrence G, Predecessor indices P, λ > 0
Output: A maximum-density bundle Q and its density, or (∅, 0) if no bundle has positive gain
1 m ← len(O), F ← m × (m + 1) table initialized at −∞
2 for i ← 1 to m do
3 F(i, 0) ← 0
4 for i ← 1 to m do
5 for j ← 1 to i do
6 F(i, j) ← max{F(i − 1, j), G[i] + F(P[i], j − 1)}
7 ρ* ← 0 and j* ← 0
8 for j ← 1 to m do
9 ρ ← F(m,j)/(λ+j)
10 if ρ > ρ* then
11 ρ* ← ρ, j* ← j
12 Q ← ∅, j ← j*, i ← m
13 while j > 0 do
14 if F(i,j) > F(i-1,j) then
15 Q.append(O[i]), i ← P[i], j ← j − 1
16 else
17 i ← i − 1
Output: Q, ρ*
We, then, construct a greedy cover, starting with , the set of uncovered corpus positions. At each iteration, we run FixedWordBundle exhaustively for all , with gain computed in relation to , and select the max-density bundle. If the selected bundle’s density exceeds 1, we add this bundle to the cover. Otherwise, we add an uncovered position as a singleton. After each selection, we remove the newly covered positions from and repeat until . Since each iteration at least covers one position, this procedure ends after at most iterations. The
Algorithm 2: Greedy Bundle Cover
Input: The corpus $\mathcal{D}$, corpus size $n$, sorted occurrence list for each candidate words $\mathcal{O}$, Predecessor indices table $P$, $\lambda > 0$
1 $U \leftarrow \{1,\ldots,n\}, \mathcal{C}_{W} \leftarrow \varnothing, \mathcal{C}_{\Sigma} \leftarrow \varnothing, R \leftarrow 0, V \leftarrow \varnothing$
2 while $U \ne \varnothing$ do
3 $\rho^{*} \leftarrow 1, Q^{*} \leftarrow \varnothing, w^{*} \leftarrow \bot$
4 foreach $w \in \mathcal{W}$ do
5 for $i \leftarrow 0$ to $\operatorname{len}(\mathcal{O}[w])$ do
6 $G[w][i] \leftarrow |U \cap \mathcal{O}[w][i]|$
7 $Q,\rho \leftarrow \operatorname{FixedWordBestBundle}(\mathcal{O}[w],G[w],P[w],\lambda)$
8 if $\rho > \rho^{*}$ then
9 $\rho^{*} \leftarrow \rho,Q^{*} \leftarrow Q,w^{*} \leftarrow w$
10 if $w^{*} == \bot$ then
11 $x \leftarrow \min U$
12 $\mathcal{C}_{\Sigma}.\operatorname{append}(x),J \leftarrow \{x\},R \leftarrow R+1$
13 else
14 $J \leftarrow U \cap \left(\bigcup_{I\in Q^{*}} I\right)$
15 $\mathcal{C}_{W}.\operatorname{append}(Q^{*}),R \leftarrow R+\operatorname{len}(Q^{*}),V \leftarrow V \cup \{w^{*}\}$
16 $U \leftarrow U \setminus J$
Output: $\mathcal{C}_{W},\mathcal{C}_{\Sigma},R,V$
selected bundles and singletons form a cover of corpus. This process is described in algorithm 2.
Although occurrences within one bundle are pairwise disjoint, occurrences from different bundles may overlap. Thus, the greedy cover from algorithm 2 may not be a valid segmentation. We next show how to convert this cover into a valid segmentation and give an upper bound on its vocabulary size and token counts.
First, we define a chunk construction. Fix an integer . For a word of length , set and split from left to right into chunks of length , with potentially shorter last chunk. Let be the set of distinct chunks of length at least two of .
Let be the set of distinct words represented by the bundles in the greedy cover . We construct the output vocabulary as
We can see that .
Analysis
Theorem 3.4 (Substring-chunk bicriteria guarantee). Let be a corpus with and be a set of all possible tokens. For any cardinality budget , max string size and any integer and a rational , Algorithm 3 runs in deterministic polynomial time and returns a vocabulary and valid segmentation of satisfying
Algorithm 3: Final Algorithm
Input : corpus $\mathcal{D}$, list of candidate words $\mathcal{W},q$, vocabulary budget $K,\eta > 0$
Output: Vocabulary $V$, a segmentation $\mathcal{P}$ and its token count $T(\mathcal{D},V)$
1 $n \leftarrow \sum_{s \in \mathcal{D}} len(s)$
2 foreach $w \in \mathcal{W}$ do
3 $\mathcal{O}[w] \leftarrow$ occurrences of $w$ in $\mathcal{D}$
4 $\mathcal{O}[w].sorted$ based on starting point
5 for $i \leftarrow 1$ to $len(\mathcal{O}[w])$ do
6 $P[w][i] \leftarrow \max(\{0\} \cup \{k < i : \text{the endpoint of }\mathcal{O}[w][k] \le \text{ starting of }\mathcal{O}[w][i]\})$
7 for $t \leftarrow 1$ to $n$ do
8 $\lambda \leftarrow \frac{t}{K\eta}$
9 $\mathcal{C}_{\mathcal{W}},\mathcal{C}_{\Sigma},R,V_g \leftarrow \operatorname{GreedyBundleCover}(\mathcal{D},n,\mathcal{O},P,\lambda)$
10 $A \leftarrow len(V_g)$
11 if $\lambda A + R \le (1+\ln n)t(1+\frac{1}{\eta})$ then
12 break
13 $V \leftarrow \varnothing$
14 foreach $w \in V_g$ do
15 $V \leftarrow V \cup \operatorname{Chunk}(q,w)$
16 $\mathcal{P} \leftarrow \operatorname{MinTokenSegmentation}(\mathcal{D},V\cup\Sigma)$, $t \leftarrow len(\mathcal{P})$
Output: $V,\mathcal{P},t$
where .
Definition 3.5 (Segmentation cover). Let be a vocabulary and fix a segmentation of over . For each , let contain the occurrences of in . These occurrences are pairwise disjoint, so every nonempty is a bundle.
Let
and let be the set of positions covered by singletons in . The segmentation cover induced by is the pair . We call its bundle part and its singleton part.
Lemma 3.6 (segmentation cost). Let be a vocabulary with and let be the segmentation cover induced by segmentation of over using tokens. The cost of is at most .
Proof. Let where is the bundle part and is the singleton part of the segmentation cover. Define with . Since each token in the segmentation either contributes one occurrence to a bundle or a singleton-covered position to , we get:
Consequently, the cost of the cover is:
Lemma 3.7 (Greedy cost). Fix a positive rational . Let be an optimal budget vocabulary with and let . Let be the cost of the induced segmentation cover. The greedy algorithm returns a cover with a total selected occurrences with a cost of at most .
Proof. Consider a greedy iteration with uncovered positions and the segmentation cover induced by has cost . Since this cover comes from a segmentation, its bundles and singletons parts cover each of the remaining positions exactly once. Therefore, the sum of their newly covered position adds up to . By averaging argument, at least one has cost per newly covered position ratio of at most . The greedy algorithm maximizes density, the reciprocal of this ratio, so its selected bundle or singleton also has cost per newly covered position at most .
Fix iteration , let be the number of uncovered positions before the selection and let be the number of newly covered positions, and the cost of the selection. Then
Each iteration covers at least one new position, so the algorithm terminates after iterations. Since and for all , with . Hence,
By definition of the covering costs and and lemma 3.6, we get
For a string , define
That is, is the set of all substrings of of length at least 2, and is the set of all nonempty suffixes of .
Lemma 3.8 (A vocabulary of suffixes). Fix . For every word of length , there exists a vocabulary such that and every can be segmented into at most tokens from .
Proof. Let be the set of distinct chunks construction by chunk construction in 16. Then , and . Every chunk, therefore, is a token in .
For every nonempty suffix consider two cases:
Case 1: begins at the start of a chunk. Then, consist of at most chunks from . Since , this gives a segmentation using at most tokens.
Case 2: begins strictly inside a chunk. The portion of within this chunk has length at most , and can be segmented into at most singletons. The rest of consist of at most chunks, each a token in . Thus, the total number of tokens adds up to at most:
Therefore, every suffix of admits a segmentation into at most tokens from .
:::
Lemma 3.9 (Cover to partition). Fix . Let be a cover of , where and are its bundle and the singleton parts, respectively. Let be its total number of the selected occurrence and the distinct vocabulary. For each , let $V_w be the vocabulary given by lemma 3.8, and define
Then, admits a valid segmentation over using at most tokens. Moreover, .
Proof. Fix a document . Let be its first unprocessed position, initially . Since covers all positions of the corpus, there exists a selected occurrence interval such that . There are two cases:
Case 1: belongs to a selected bundle for some . Then, the substring is a nonempty suffix of . By lemma 3.8, it can be segmented into at most tokens from , and therefore, .
Case 2: is a selected singleton. Then, the substring contributes exactly one token, which is at most .
Add the resulting tokens to the segmentation, set , and continue this process. Each step strictly increases , and the emitted substrings are consecutive and remain within . Coverage ensures that the process continues until , so these substrings partition .
We can also ensure that no occurrence interval is used twice in this process: after choosing , any subsequent unprocessed position is at least .
Repeating this process for all documents, uses at most selected occurrence intervals, each contributing at most tokens, giving at most tokens.
Finally, each contains at most chunks/tokens, so
:::
Proof of Theorem 3.4. Let . The greedy cost analysis gives:
Since , the guess is among those considered by the algorithm. At this guess, , so
Thus, the acceptance condition holds at . Because the guesses are considered in increasing order, the first accepted guess satisfies .
Let and be the occurrence counts of the accepted cover. The acceptance condition gives
Therefore,
By Lemma 3.9, the chunk vocabulary satisfies and admits a valid segmentation using at most tokens. Consequently,
and
Every word in is a substring of a selected word and hence a substring of a corpus document. Since these words have length at least two, .
Remark 3.10. The Algorithm 3 achieves -bicriteria approximation by choosing and , making .
Runtime analysis of Algorithm 3: There are at most words in . Enumerating words, creating their occurrence lists, and ordering them can be done in polynomial time. In each greedy iteration, for every word , it takes to compute and a total of to find the best overall bundle across all words and all sizes. During each iteration, at least one previously uncovered position is covered with at most iterations, totaling to overall. Any selected collection of bundle contains at occurrences, making the chunk vocabulary construction and segmentation all be done in polynomial time.
Corollary 3.11. For and , we can achieve equal bicriteria factors
Storage Budget
The above approach inspired us to formulate the direct binary tokenization problem in term of total storage budget. This problem is defined in Definition 2.2. We show the following.
Theorem 3.12. Let be the corpus with total length . Let . For , set and any positive rational , there is a deterministic polynomial-time algorithm that returns a vocabulary and valid segmentation with
In particular gives equal factors .
Proof of this theorem is in Appendix § 7.
AI Disclosure. The authors used ChatGPT Astra to explore proof strategies, generate ideas, and refine arguments. The authors have independently verified all results and proofs and take full responsibility for the correctness and content of this paper.
References
Proof of Lemma 3.1
To prove Lemma 3.1, we need to first prove another lemma about a property of the corpus .
Lemma A.1 (Min Generators). Let , , , , be five distinct letters, and consider
If one or both of and are available, then at least 3 extra generators are needed to generate .
If neither nor are available, at least 4 generators are needed to generate .
Proof. To simplify the argument, suppose we have both and available (note restricting to only one of , being available would only increase the number of generators needed). Assume for the sake of contradiction, we only need 2 extra generators. We’ll discuss 2 cases: is not a factor and is a factor.
In the first case, since is not a factor, to factorize it, it needs at least 2 factors. Since we assume we only need 2 extra factors, we have to factorize into exactly 2 factors, i.e. either or . Together with the current factors and from assumption, none of these 2 sets of factors can factorize the word . We’ve reached a contradiction.
In the second case, since is a factor, we can choose 1 extra factor. To factorize the word , we need another generator. This generator must contain and be a factor of . The possibilities are , , , . Together with the current factors , , from assumption, none of these factors can factorize . We’ve reached a contradiction.
Hence, even with both and available, we need at least 3 extra generators.
Now suppose neither nor are available. Assume for the sake of contradiction that at most 3 generators suffice. Note at least 1 generator must start with and another start with . Also at least 1 generator must end with and another end with . Since we’re only allowed 3 generators, these generators must overlap. A factor that starts in and ends in must be one of the full length-three words.
Remove such a full-word generator and the unique source word equal to it. It cannot occur in any of the three remaining source words, since those words are distinct and have the same length. Thus at most two remaining generators must generate those three words. The three words still have both initial letters and both final letters . So by the logic in the last paragraph, we must have at least 1 generator starting with and another starting with , and at least 1 generator ending with and another ending with . Since we’re only allowed 2 generators here, we see that both generators are full length-three words. But two full length-three words cannot generate three full length-three words. We’ve reached a contradiction.
Hence, with neither nor available, we need at least 4 generators.
Lemma 3.1. The source corpus satisfies
Proof. We’ll prove something stronger: any vertex cover yields a generating set of size and a factorization of every source word into exactly two factors.
To prove , first select all the singleton vertex in . Do the following to factorize for any edge . If , select in addition 3 generators , , . Factorize the edge-corresponding as , , , .
Otherwise, , then select in addition 3 generators , , . Factorize the edge-corresponding as , , , . The total generating set size is , and the total number of factors is .
To prove , take any generating set and remove any generators in it that is not used. Let
Note all other generators that are not in are edge specific by definition. Then we can partition the rest of the generators according to their corresponding edge. Let be the set containing the edge specific generators of edge . Note
For an edge , only and the selected endpoint singleton letters can help generate the words of . Lemma A.1 gives that for every edge, and when neither endpoint belongs to .
Let count the edges with no endpoint in . Then
Adding one endpoint for every uncovered edge gives a vertex cover of size . Hence , proving . Together with the upper bound this proves the lemma.
Proof of Proposition 3.2
In this section, we’ll decode the encoded corpus to obtain the gap shown in Proposition 3.2. First, let’s prove a simple lemma that any block of is recognizable in any concatenation of binary blocks.
Lemma B.1. In a concatenation of binary blocks , the occurrence of 11 marks the beginning of each block. Moreover, any occurrence of some binary block in the concatenation must be one of the 's in the concatenation. Any occurrence is uniquely identifiable to have label
Proof. After the initial 11, the remaining binary string in a binary block has a 0 in every other place, and it starts and ends with a 0, so there are no occurrence of 11 in the remaining binary string. At the boundary of binary blocks, there’s a 0 from the preceding block and a 110 from the subsequent block, the only occurrence of 11 is at the beginning of the subsequent block. So the boundary does not produce any illegal occurrence of 11 either.
Every binary block begins with the 11 marker and has length . Any full occurrence of a binary block therefore aligns with one of the concatenated blocks.
The block is uniquely identifiable because when we encoded the letter-phase pair , we chose an injective function.
Now we specify the method of decoding.
The following lemma translates a vocabulary of a Tokenization corpus to a generating set of its corresponding source corpus.
Lemma B.2 (Tok to Fac). Let be a corpus of non-empty source words of a FAC instance. Let be the encoded corpus of the corresponding Tok instance. Let be a vocabulary for the Tok instance. Suppose the segmentation of the Tok corpus with vocabulary only uses tokens in total. If
then there exists some generating set with . Consequently, .
Proof. Note we call the binary encoding of a source word a "document" in the Tok corpus. If document in the Tok corpus is tokenized to tokens, then it has internal token boundaries. So the total number of internal boundaries in the whole corpus will be
Call a phase bad if any internal token boundary lies inside any block in any document. One internal boundary can only lie inside at most one block. If it coincides with a block boundary, it does not lie inside any block. Any one internal token boundary can mark at most one phase to be bad. So there are at most bad phases.
Recall there are phases. So we can choose a good phase . A good phase is one that is not bad. From now on, we will only look at the phase parts of the Tok corpus. Delete from the corpus and vocabulary anything that is not phase . This is achievable because Lemma B.1 tells us the binary blocks are uniquely recognizable. So we can recognize the blocks in the corpus and identify which blocks are phase .
From the updated corpus, we can still recover the whole source corpus because the deleted phases are merely repeats of the good phase . Moreover, we can derive a factorization of from the tokenization of the corpus. For each source word , suppose its phase--tokenization is as follows
where are tokens. Since our chosen phase is good, each is consist of complete phase--binary-blocks because no token boundary lies inside a binary block. By Lemma B.1, we can recognize these binary blocks. Say we recognize the above document to have blocks
then we recover the source word to be
Note because one token could contain multiple binary blocks. In addition, separating the word at the corresponding token boundaries in provide a factorization of .
Now we say what the generating set should be. Say a phase- token contains binary blocks
We want to "read off" the corresponding word that was mapped to this token . So we define the translation function . This is doable because, for each binary block in token , one can first take its inverse of the one-to-one encoding function . Then one can output the first coordinate in that inverse. Let
The map is a function of the source-letter-spelling of its input token , so there is at most one image for each vocabulary entry. Hence, . By the reasoning above, we know that factorizes , so it is a generating set of .
Proposition 3.2 For every integer , Transformation 1 satisfies
Proof. Recall in Transformation 1, we set . If , then the proof of Lemma 3.1 describes a generating set of at most words and exactly factors in its factorization of . We can simply set , and . Then we tokenize the Tok corpus the same way as the factorization of , substituting each factor with the corresponding token . Then we get a segmentation length of the Tok corpus of length .
Suppose . Recall . If some vocabulary of cardinality at most had a tokenization with fewer than tokens, then Lemma B.2 would produce a generating set of size at most , a contradiction. The lemma applies to every feasible vocabulary and every tokenization, including minimum-token ones. ∎
Proof of Theorem 3.12
Proof. Restrict the candidate words to those of length at most , and replace the bundle cost by
Every vocabulary of storage cost at most uses only such words. The dynamic program in Algorithm 1 remains unchanged, except that the density for a bundle of size is now
Singletons retain cost 1.
Let be an optimal vocabulary with . As in Lemma 3.6, its induced segmentation cover has cost at most
Thus, the charging argument of Lemma 3.7 gives
where and is the total number of selected occurrences, including singletons. Here, each distinct word in contributes its storage cost at least once to the selected bundles.
We next replace the chunk construction by a binary decomposition. For each , recursively split into two consecutive parts whose lengths differ by at most one, stopping at single characters. Let be the set of distinct words of length at least two represented by nodes of this decomposition, including the root .
The decomposition has height at most . At each depth, the represented substrings are disjoint parts of , so their total length is at most . Since only the first depths can contain nonleaf nodes,
Moreover, every nonempty suffix of can be segmented into at most tokens from . To see this, follow the path to the first character of the suffix. Whenever this path enters a left child, include the entire right child. Together with the first character, these nodes partition the suffix. The two bottom leaves, if both included, can be replaced by their parent. Consequently, a path of length at most contributes at most tokens.
Set
Then
Applying the same interval-selection procedure as in Lemma 3.9, with the suffix decomposition above in place of the chunk decomposition, gives a valid segmentation using at most tokens.
Finally, consider the guesses in increasing order, set , and accept the first cover satisfying
The greedy bound ensures that this condition holds at . Hence, the first accepted guess satisfies , and
Combining these inequalities with the bounds above gives
The modified bundle computation and the enumeration of guesses run in polynomial time by the same runtime analysis as Algorithm 3. Each binary decomposition has nodes and can also be constructed in polynomial time. Fixing a deterministic rule for ties makes the algorithm deterministic. Taking gives equal factors . ∎
Index of Notation
Corpus and tokenization
, , The binary alphabet , a character , and the empty word .
, , The set of finite words over , the set of nonempty words over , and the set of binary words of length at least two, respectively.
, , The corpus, the number of documents, and the -th document. When a document is fixed, also denotes its -th character.
, The total corpus length and the maximum document length .
, , , The set of distinct substrings of length at least two occurring within a document of , abbreviated . A candidate word is denoted by , and a selected vocabulary by .
The tokens of a segmentation , where and is its token count.
, The minimum token count for over , and the minimum total token count .
, The vocabulary cardinality budget and the minimum of over all with . We write when the corpus is understood.
, , The storage budget, the spelling cost , and the minimum of over all with .
, The budget-augmentation factor and the token-count approximation factor, respectively.
, The harmonic number and its upper bound .
In the single-string storage bound, .
Vertex cover and word factorization
, , The source graph, with vertex set , edge set , vertex count , and edge count .
, The minimum size of a vertex cover of and the vertex-cover decision budget.
, , , , The source alphabet, a finite set of source words, a generating set, the set of finite concatenations of elements of , and the minimum size of a set satisfying .
, , , The endpoints of edge , also used as singleton letters, and the three letters private to . Lemma A.1 writes these five letters as , , , , .
, The four source words associated with edge , and the full source corpus . Specifically, .
, The total source length and the generator budget . The reduction sets .
, , In the rank proof, consists of vertices whose singleton letters belong to , consists of generators private to , and counts edges with neither endpoint in .
Binary encoding and decoding
, , , The hardness exponent , the amplification exponent , the base , and the number of phases . Proposition 3.2 allows any integer . , , , A source letter, a phase , the bit width of a label, and the distinct -bit label assigned to the pair .
, , , , A label , its -th bit, its padded encoding , the binary block , and the block length .
, A source word of length and its encoding map. Each is replaced by , and .
, The encoded corpus of a source set , and the particular corpus . It has documents and total length .
, , In the boundary count, is the number of tokens in the encoded corpus, is the number in document , and denotes a phase- block with arbitrary source letter. The total number of internal token boundaries is .
, , In Appendix B, the final zero-based block indices in a concatenation of blocks, a projected document, and a projected token, respectively. In the proof of Proposition 3.2, denotes a generator.
, In the decoding argument, are the tokens in the displayed phase projection. The map reads the source letters of the retained blocks of token , in order.
Occurrences, bundles, and greedy covering
An occurrence covering positions of document . Subscripts on , , , distinguish occurrences.
, The occurrences of in , all its occurrences in the corpus, and their number .
, , , A nonempty bundle of pairwise disjoint occurrences of , also written , its opening charge , and its cardinality-model cost .
, , A segmentation and the two parts of its induced cover: is the family of nonempty word bundles and is the set of positions covered by singleton tokens. The induced cover is also written .
, , , The set of vocabulary words used by the segmentation, its size , the token count , and the induced cover cost .
, , , , The concatenation used to index positions, the -th occurrence of a fixed word in start order, its interval , and the last index with . If no such exists, .
, The currently uncovered positions and the gain from selecting occurrence .
The maximum number of newly covered positions obtainable by selecting exactly disjoint occurrences among of word .
, , , , In Algorithms 1–3, the occurrence lists, gain arrays, predecessor arrays, dynamic-programming table, and number of occurrences of the current word. For fixed , the entries , , and correspond to , , and , respectively.
, , , , , The candidate density (newly covered positions per unit cost), best density, maximizing bundle size, best bundle, and its word. The sentinel selects the singleton alternative.
, In Algorithm 2, the position chosen for a singleton and the set of positions newly covered in the current iteration.
, , , The greedy cover, its selected bundles, its selected singletons, and the total number of selected occurrences, including singletons: .
, , An optimal vocabulary for budget , the cost of its induced comparison cover, and the cost of the greedy cover, respectively. , , , , In the greedy cost proof, is the number of uncovered positions. At iteration , is the number remaining before selection, is the number newly covered, and is the selection cost. The algorithm takes iterations.
Substring chunks and budget augmentation
, The substrings of of length at least two and the nonempty suffixes of , respectively. In or , is the indicated substring or suffix.
, , , The maximum number of chunks per selected word, the positive rational tradeoff parameter, the suffix token bound , and the common bicriteria factor obtained when .
, , , , In the chunk construction, , is the chunk length, is the number of chunks, is the set of distinct chunks of length at least two, and is a nonempty suffix of .
, , In the cover-to-partition proof, is the first unprocessed position and is a selected interval containing . In Algorithm 3, are the endpoints of the current chunk.
, , In Algorithm 3, is the trial token count, is the first accepted trial, and . At output, denotes the token count of the returned segmentation.
, , , The set of distinct words selected by the greedy cover, its cardinality , the final chunk vocabulary , and the output segmentation.
Storage-budget cover
, , The parameter , the candidate set , and the shorthand used in Appendix C for the storage optimum .
, The per-unit spelling charge for trial , and the bundle cost .
, , The bundles selected in the storage model, their total spelling length , and the number of selected occurrences including singletons. A spelling contributes once per selected bundle, so the cover costs .
References
- [1]Jean Néraud. Elementariness of a finite set of words is co-NP-complete. RAIRO. Informatique théorique et applications, 24(5):459–470, 1990. https://www.numdam.org/item/ITA_1990__24_5_459_0/.DOI
- [8]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, 2025. https://aclanthology.org/2025.acl-long.1365/.
- [9]Jia Peng Lim, Shawn Tan, Davin Choo, and Hady W. Lauw. A Partition Cover Approach to Tokenization. arXiv preprint arXiv:2501.06246, 2025. https://arxiv.org/abs/2501.06246.
- [10]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, 2026. https://doi.org/10.4230/LIPIcs.ESA.2026.80.
- [11]Violeta Kastreva, Philip Whittington, Dennis Komm, Tiago Pimentel Tokenisation over Bounded Alphabets is Hard. In International Conference on Learning Representations (ICLR), 2026. https://arxiv.org/abs/2511.15709.