betaFeedback

WorksComputer Science

Tokenization: Hardness and Bicriteria Approximation Algorithms

Abstract

We study Binary Tokenization: given a corpus of binary strings over {0,1}\{0,1\} and a vocabulary budget KK, select at most KK substrings (called vocabulary) to minimize the total number of tokens needed to represent the corpus. The primitive symbols 00 and 11 are always available, and each document must be segmented separately. Letting nn denote the total corpus length and MM for the maximum document length, we prove that, for every fixed ε∈(0,1)\varepsilon\in(0,1), Binary Tokenization problem does not have polynomial-time n1−εn^{1-\varepsilon}-approximation algorithms unless P=NP\mathsf{P}=\mathsf{NP}. To complement the hardness result, we give a polynomial-time (γ,γ)(γ,γ)-bicriteria algorithm, with γ=Mlog⁡nγ= \sqrt{M}\log n: The algorithm outputs a vocabulary of size at most γKγK with number of tokens at most γOPTKγ{\rm OPT}_K, where OPTK{\rm OPT}_K is the optimal number of tokens under the original budget KK. We also study a storage-budget variant, in which the sum of the selected substrings' lengths is bounded by BB. For 2≤B<n2\le B<n, we obtain an (O(log⁡nlog⁡B),O(log⁡nlog⁡B))(O(\log n\log B),O(\log n\log B))-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 P=NPP = NP; 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 n1−εn^{1-\varepsilon} hardness of approximation for this problem for any 1>ε>01 > \varepsilon> 0, even over a binary alphabet, where nn denotes the total corpus length. Earlier work established only constant-factor inapproximability, ruling out polynomial-time approximation ratios below c=1.000002c = 1.000002 unless P=NPP = NP [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 nn and maximum document length MM, we provide polynomial-time (γ,γ)(\gamma,\gamma)-bicriteria algorithms, with γ=O(Mlog⁡n)\gamma= O(\sqrt{M \log n}), where KK is the vocabulary budget. Each algorithm selects at most γK\gamma K vocabulary entries and produces at most γOPT⁡K\gamma\operatorname{OPT}_K tokens, where OPT⁡K\operatorname{OPT}_K is the minimum token count under the original budget KK.

We also consider a storage-budget model, which requires ∑w∈V∣w∣≤B\sum_{w \in V} |w| \le B instead of bounding the number of vocabulary entries. For 2≤B<n2 \le B < n, we obtain a polynomial-time (O(log⁡nlog⁡B),O(log⁡nlog⁡B))(O(\log n \log B), O(\log n \log B))-bicriteria approximation for storage and token count, measured against the optimum with storage budget BB.

We would like to note that it is easy to get a n/log⁡nn/\log n-approximation algorithm: order the tokens by their frequency and take the top KK of them where KK is the budget on the cardinality of the vocabulary.

Preliminaries and model definitions

Binary Tokenization

Let s∈Σ+s \in\Sigma^{+} be a nonempty string of characters cc from a binary alphabet Σ\Sigma, we call it a document. A collection of documents form a corpus D={si}i=1d\mathcal{D} = \{s_i\}_{i=1}^{d} 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 W(D)={w:∣w∣≥2,w occurs within some si}\mathcal{W}(\mathcal{D}) = \{w : |w| \ge2, w \text{ occurs within some } s_i\} be a set of all possible tokens given D\mathcal{D}, n=∑i=1d∣si∣n = \sum_{i=1}^{d} |s_i| be the total length of the corpus and M=max⁡i∣si∣M = \max_i |s_i| be the length of the longest string.

For fixed V⊆WV \subseteq\mathcal{W}, let

Tok⁡(s,V)=min⁡{t:s=w1⋯wt, wj∈V∪Σ},T(D,V)=∑iTok⁡(si,V).\operatorname{Tok}(s,V) = \min\{t : s = w_1 \cdots w_t,\ w_j \in V \cup\Sigma\}, \qquad T(\mathcal{D},V) = \sum_i \operatorname{Tok}(s_i,V).

Definition 2.1 (Tokenization (Tok)). Given D\mathcal{D} and an integer K≥0K \ge0, minimize

OPT⁡K(D)=min⁡V⊆W(D)∣V∣≤KT(D,V).(1)\operatorname{OPT}_{K}(\mathcal{D}) = \min_{\substack{V \subseteq\mathcal{W}(\mathcal{D})\\ |V| \le K}} T(\mathcal{D},V). \tag*{(1)}

In the literature, this is also called Binary Direct Tokenization.

Definition 2.2 (Binary Tokenization with a storage budget). Let c(V)=∑w∈V∣w∣c(V) = \sum_{w \in V} |w|. Given D\mathcal{D} and an integer B≥0B \ge0, minimize

OPT⁡Bst(D)=min⁡V⊆W(D)c(V)≤BT(D,V).\operatorname{OPT}^{\mathrm{st}}_{B}(\mathcal{D}) = \min_{\substack{V \subseteq\mathcal{W}(\mathcal{D})\\ c(V) \le B}} T(\mathcal{D},V).

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 (α,β)(\alpha,\beta) bicriteria algorithm returns at most αK\alpha K entries and at most βOPT⁡K\beta\operatorname{OPT}_{K} tokens for cardinality, or storage at most αB\alpha B and at most βOPT⁡Bst\beta\operatorname{OPT}^{\mathrm{st}}_{B} tokens for storage. The comparison optimum always obeys the original budget. A standard approximation has α=1\alpha= 1. Let Hn=∑j=1n1/j≤1+ln⁡nH_n = \sum_{j=1}^{n} 1/j \le1 + \ln n. We use ϵ\epsilon for the empty word and ε\varepsilon for an approximation exponent.

With K=0K = 0 or B<2B < 2, primitives are exact. In the cardinality model, one string is trivial once K≥1K \ge1; a corpus is trivial when all its distinct nonprimitive documents fit. In storage, B≥nB \ge n permits buying all such documents. The interesting storage range is therefore 2≤B<n2 \le B < n. 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 G=(Q,E)G = (Q, E) be a simple undirected connected graph where QQ is the set of vertices and EE is the set of edges. Denote the size of the vertices to be w=∣Q∣w = |Q| and the size of the edges to be m=∣E∣m = |E|. Let τ(G)\tau(G) denote the minimum size of a vertex cover. For a budget Φ\Phi, The vertex cover decision problem outputs

  • YES: if τ(G)≤Φ\tau(G) \le\Phi.

  • NO: if τ(G)>Φ\tau(G) > \Phi.

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 AA be an alphabet and let X⊆A∗X \subseteq A^* be a set of words. A set Y⊆A∗Y \subseteq A^* is a generating set for XX if every word in XX can be written as a finite concatenation of words from YY. Equivalently,

X⊆Y∗.X \subseteq Y^*.

where Y∗Y^* denotes the set of all finite concatenations of elements of YY, including the empty word.

Definition 2.5 (Generating Rank). Let X⊆A∗X \subseteq A^* be a finite set of nonempty words over an alphabet AA. The rank of XX is the size of its smallest generating set, i.e.

rk⁡(X)=min⁡{∣Y∣:Y⊆A∗, X⊆Y∗}.\operatorname{rk}(X) = \min\{|Y| : Y \subseteq A^*,\ X \subseteq Y^*\}.

It is important to note that singleton letters in YY count toward ∣Y∣|Y|.

Definition 2.6 (Word Factorization (FAC)). Given a finite set of nonempty words X⊆A+X \subseteq A^+ over an alphabet AA and an integer B≥0B \ge0. The Word Factorization problem outputs

  • YES: if rk⁡(X)≤B\operatorname{rk}(X) \le B.

  • NO: if rk⁡(X)>B\operatorname{rk}(X) > B.

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 G=(Q,E)G = (Q, E) and budget Φ\Phi. Assign distinct singleton letters to each vertex of QQ. For each edge e=(ue,ve)e = (u_e, v_e), also assign 3 distinct edge-specific singleton letters cec_e, λe\lambda_e, ρe\rho_e. Let alphabet AA be the set consist of all these singleton letters. Note ∣A∣=w+3m|A| = w + 3m.

For each edge e=(ue,ve)e = (u_e, v_e) with edge specific singletons cec_e, λe\lambda_e, ρe\rho_e, we make a set of words

Xe={ueceve,ueceρe,λeceve,λeceρe}X_e = \{u_ec_ev_e, u_ec_e\rho_e, \lambda_ec_ev_e, \lambda_ec_e\rho_e\}

Let our total set of words be

XG=⋃e∈EXeX_G = \bigcup_{e \in E} X_e

Let B=3m+ΦB = 3m + \Phi. Let NN denote the length of XX, i.e. the sum of the lengths of all the words in XX. Here, N=12mN = 12m.

Note ∣A∣≤N|A| \le N because w≤2mw \le2m because each vertex is adjacent to at least one edge due to connectedness.

The following lemma provides a relation between rk⁡(XG)\operatorname{rk}(X_G) and τ(G)\tau(G).

Lemma 3.1 (rk⁡(XG)\operatorname{rk}(X_G), τ(G)\tau(G) identity). The source corpus satisfies

rk⁡(XG)=3m+τ(G).(2)\operatorname{rk}(X_G) = 3m + \tau(G). \tag*{(2)}

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

τ(G)≤Φ⇒rk⁡(XG)≤B,(3)\tau(G) \le\Phi\Rightarrow\operatorname{rk}(X_G) \le B, \tag*{(3)}
τ(G)>Φ⇒rk⁡(XG)>B.(4)\tau(G) > \Phi\Rightarrow\operatorname{rk}(X_G) > B. \tag*{(4)}

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 XGX_G 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 ε\varepsilon be the constant defined in Theorem 3.3. Define q:=⌈4/ε⌉q := \lceil4/\varepsilon\rceil, p:=N+2q+10p := N + 2q + 10, R:=pqR := p^q. We define RR here because we eventually want to repeat each letter in the FAC problem RR times in the final encoding.

The "building blocks" to the final binary encoding are the elements (a,j)∈A×{1,…,R}(a,j) \in A \times\{1,\ldots,R\}. As you can see, we are repeating each element a∈Aa \in A a total of RR times. For an element (a,j)(a,j), we call jj its "phase". For every (a,j)∈A×{1,…,R}(a,j) \in A \times\{1,\ldots,R\}, we want to assign it a unique binary string. Since there are ∣A∣⋅R|A| \cdot R number of such elements, we will need b=max⁡(1,⌈log⁡2(∣A∣⋅R)⌉)b = \max(1, \lceil\log_2(|A| \cdot R) \rceil) bits in the binary string. Choose any injective function z(a,j):A×{1,…,R}⟶{0,1}bz(a,j) : A \times\{1,\ldots,R\} \longrightarrow\{0,1\}^{b} 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 z=z1…zbz = z_1\ldots z_b of the function zz chosen above, we add delimiters and alternating internal padding to it as follow

C(z):=110z10z20…0zb0C(z) := 110z_10z_20\ldots0z_b0

Finally, we will define the unique "binary block" associated to element (a,j)(a,j) to be

Ba,j:=C(z(a,j))B_{a,j} := C(z(a,j))

Note each binary block has length l=2b+3l = 2b + 3.

Now we can define the binary encoding function hR:A+⟶{0,1}+h_R : A^+ \longrightarrow\{0,1\}^+. For a singleton letter a∈Aa \in A, we define the binary encoding to be the concatenation of all RR "repeats" of the Ba,jB_{a,j} blocks.

hR(a):=Ba,1Ba,2…Ba,Rh_R(a) := B_{a,1}B_{a,2}\ldots B_{a,R}

Note each encoding of a singleton letter has length RlRl. Now for a word x∈A+x \in A^+, x=a1…arx = a_1\ldots a_r, we just define its binary encoding to be the concatenation of the binary encoding of each of its singleton letters.

hR(x):=hR(a1)…hR(ar)=Ba1,1…Ba1,RBa2,1…Ba2,R…Bar,1…Bar,Rh_R(x) := h_R(a_1)\ldots h_R(a_r) = B_{a_1,1}\ldots B_{a_1,R}B_{a_2,1}\ldots B_{a_2,R}\ldots B_{a_r,1}\ldots B_{a_r,R}

Finally, we can now define the corpus of the tokenization problem.

DR:={hR(x):x∈XG}D_R := \{h_R(x) : x \in X_G\}

This corpus has d=4md = 4m distinct documents of length 3Rl3Rl and total length

n=NRl=12mRl(5)n = NRl = 12mRl \tag*{(5)}

Let the alphabet be Σ={0,1}\Sigma= \{0,1\}. Let K=B=3m+ΦK = B = 3m + \Phi.

Building off of Lemma 3.1, the following proposition relates τ(G)\tau(G) and OPTK(DR)OPT_K(D_R). Note that at this step, the choice of RR is not yet important.

Proposition 3.2. For every integer R≥1R \ge1, Transformation 1 satisfies

rk(XG)≤B⟹OPTK(DR)≤8m,(6)rk(X_G) \le B \Longrightarrow OPT_K(D_R) \le8m, \tag*{(6)}
rk(XG)>B⟹OPTK(DR)≥R+4m.(7)rk(X_G) > B \Longrightarrow OPT_K(D_R) \ge R + 4m. \tag*{(7)}

The proof is given in Appendix § 6.

Applying Lemma 3.1 with Proposition 3.2, we get

YES: τ(G)≤Φ⟹OPTK(DR)≤8m,(8)\textbf{YES: }\tau(G) \le\Phi\Longrightarrow OPT_K(D_R) \le8m, \tag*{(8)}
NO: τ(G)>Φ⟹OPTK(DR)≥R+4m.(9)\textbf{NO: }\tau(G) > \Phi\Longrightarrow OPT_K(D_R) \ge R + 4m. \tag*{(9)}

At last, we obtain the result for our main theorem.

Theorem 3.3 (hardness of approximation). For every fixed ε∈(0,1)\varepsilon\in(0,1), unless P=NP\mathrm{P} = \mathrm{NP}, there is no deterministic polynomial-time algorithm that returns, on every input, a vocabulary VV at most size KK satisfying

T(D,V)≤n1−εOPT⁡K(D),T(D,V) \le n^{1-\varepsilon}\operatorname{OPT}_{K}(D),

where nn 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 T(D,V)T(D,V) to within n1−εOPT⁡K(D)n^{1-\varepsilon}\operatorname{OPT}_{K}(D) with a vocabulary VV at most size KK. Take a nontrivial Vertex Cover instance and construct DRD_R as above. Run the algorithm at budget K=3m+ΦK = 3m + \Phi. Run the polynomial PathPiece [Gold+24] algorithm, which outputs the optimal segmentation given a vocabulary, on the output vocabulary to obtain T(DR,V)T(D_R,V).

Before we do further computation, let’s examine some relationships between parameters. Recall the definition of parameters qq, pp, RR, bb and NN and the fact that ∣A∣≤N|A| \le N. Due to the definition of pp, we have ∣A∣≤N≤p|A| \le N \le p and p≥3p \ge3, so we can obtain

b≤(q+1)log⁡2p+1≤(q+1)p+1(10)b \le(q+1)\log_{2}p + 1 \le(q+1)p + 1 \tag*{(10)}
l=2b+3≤(2q+2)p+5≤(2q+4)p<p2.(11)l = 2b + 3 \le(2q+2)p + 5 \le(2q+4)p < p^{2}. \tag*{(11)}

Combining equation (5) and equation (11), we get

n=NRl≤Rp3=pq+3(12)n = NRl \le Rp^{3} = p^{q+3} \tag*{(12)}

In a YES instance, we would have

T(DR,V)≤n1−εOPT⁡K(DR)(13)T(D_R,V) \le n^{1-\varepsilon}\operatorname{OPT}_{K}(D_R) \tag*{(13)}
≤n1−ε8m(14)\le n^{1-\varepsilon}8m \tag*{(14)}
≤(Rp3)1−εp(15)\le(Rp^{3})^{1-\varepsilon}p \tag*{(15)}
=R1−εp4−3ε<R(16)= R^{1-\varepsilon}p^{4-3\varepsilon} < R \tag*{(16)}

The second inequality is due to equation (8), the third inequality is due to equation (12) and the fact that 8m≤N≤p8m \le N \le p. To justify the last inequality,

Rε=pqε≥p4>p4−3εR^{\varepsilon} = p^{q\varepsilon} \ge p^{4} > p^{4-3\varepsilon}

.

In a NO instance, every feasible output satisfies T≥R+4m>RT \ge R + 4m > R by equation (9).

Note T<RT < R and T>RT > R partitions the possibilities of being in the YES or NO case for the Vertex Cover decision problem. Therefore, testing the integer inequality T<RT < R 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 1≤K≤n1 \le K \le n. We write OPTK=OPTK(D)\mathrm{OPT}_K = \mathrm{OPT}_K(\mathcal{D}) and use the corpus parameters of § 2. Also, whenever tokens are mentioned, they refer to w∈Ww \in\mathcal{W}.

An occurrence of a word w∈Ww \in\mathcal{W} in a document s∈Ds \in\mathcal{D} is an interval (s,[i,j))(s,[i,j)) such that ww appears in positions i,…,j−1i,\ldots,j-1 in ss, and we say the interval covers [i,j)[i,j). Two occurrences (s1,[i1,j1))(s_1,[i_1,j_1)) and (s2,[i2,j2))(s_2,[i_2,j_2)) are disjoint if they lie in different documents, or if their intervals do not overlap. Let oa=∑b<a∣sb∣o_a = \sum_{b<a}|s_b| be the offset of document sas_a. We map each occurrence to its interval in corpus coordinates by

f((sa,[i,j)))=[oa+i,oa+j).f((s_a,[i,j))) = [o_a+i,o_a+j).

Therefore, each occurrence is identified with its global interval and denoted by II. For w∈Ww \in\mathcal{W}, define

Ow={f((sa,[i,j)))∣1≤a≤d,1≤i<j≤∣sa∣+1,sa[i]sa[i+1]⋯sa[j−1]=w}.\mathcal{O}_w = \left\{ f((s_a,[i,j))) \mathrel{\left| \begin{array}{l} 1 \le a \le d,\quad1 \le i < j \le|s_a|+1,\\ s_a[i]s_a[i+1]\cdots s_a[j-1] = w \end{array}\right.} \right\}.

Thus, Ow\mathcal{O}_w is the set of all occurrence intervals of ww in the corpus.

A bundle for ww is a nonempty subset Qw⊆OwQ_w \subseteq\mathcal{O}_w whose occurrences are pairwise disjoint. For a fixed parameter λ>0\lambda> 0, the cost of a bundle QwQ_w is:

c(Qw)=λ+∣Qw∣c(Q_w) = \lambda+ |Q_w|

That is, selecting a bundle incurs a fixed cost λ\lambda and a unit cost for each occurrence it contains. Given a set U⊆{1,…,n}U \subseteq\{1,\ldots,n\}, gain and density of a bundle QwQ_w is

gU(Qw)=∣U∩⋃I∈QwI∣,ρU(Qw)=gU(Qw)c(Qw)g_U(Q_w) = \left|U \cap\bigcup_{I \in Q_w} I\right|,\qquad\rho_U(Q_w) = \frac{g_U(Q_w)}{c(Q_w)}

We also allow a corpus position to be covered by a single character c∈Σc \in\Sigma and we call it a singleton, with cost, density and gain of 1.

A cover C=(CW,CΣ)C = (C_{\mathcal{W}}, C_\Sigma) 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:

c(C)=∑Q∈CWc(Q)+∣CΣ∣.c(C) = \sum_{Q \in C_{\mathcal{W}}} c(Q) + |C_\Sigma|.

For each ww, order its mw=∣Ow∣m_w = |\mathcal{O}_w| occurrences I1,…,ImwI_1,\ldots,I_{m_w} by increasing global start coordinate, writing Ii=[ai,bi)I_i = [a_i,b_i). For each interval IiI_i, define

pi=max⁡({0}∪{k<i:bk≤ai})p_i = \max\left(\{0\} \cup\{k < i : b_k \le a_i\}\right)

to be the index of the last occurrence that doesn’t overlap with IiI_i. For a fixed U⊆{1,…,n}U \subseteq\{1,\ldots,n\} and w∈Ww \in\mathcal{W}, let gi=∣U∩Ii∣g_i = |U \cap I_i|. Then, define Fw(i,j)F_w(i,j) to be the maximum total gain of exactly jj disjoint interval occurrences of ww among I1,…,IiI_1,\ldots,I_i. For every 0≤j≤i≤mw0 \le j \le i \le m_w:

Fw(i,j)=max⁡{∑Ik∈Qgk∣Q⊆{I1,…,Ii}, ∣Q∣=j,Q is pairwise disjoint}F_w(i,j) = \max\left\{\sum_{I_k \in Q} g_k \mathrel{\left| \begin{array}{l} Q \subseteq\{I_1,\ldots,I_i\},\ |Q| = j,\\ Q\ \text{is pairwise disjoint} \end{array}\right.}\right\}

We compute this value using a two dimension dynamic program, initialized as:

Fw(i,0)=0,Fw(0,j)=−∞(j>0).F_w(i,0)=0,\qquad F_w(0,j)=-\infty\quad(j>0).

Then, use

Fw(i,j)=max⁡{Fw(i−1,j),  gi+Fw(pi,j−1)}.F_w(i,j)=\max\{F_w(i-1,j),\;g_i+F_w(p_i,j-1)\}.

The first term excludes IiI_i and selects jj disjoint occurrences among the first i−1i-1 occurrences. The second term includes IiI_i and selects the remaining j−1j-1 occurrences among the first pip_i occurrences.

We can get the best-density bundle for ww by:

max⁡1≤j≤mwFw(mw,j)λ+j\max_{1\leq j\leq m_w}\frac{F_w(m_w,j)}{\lambda+j}

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 U={1,…,n}U=\{1,\ldots,n\}, the set of uncovered corpus positions. At each iteration, we run FixedWordBundle exhaustively for all w∈Ww\in\mathcal{W}, with gain computed in relation to UU, 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 UU and repeat until U=∅U=\varnothing. Since each iteration at least covers one position, this procedure ends after at most nn 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 C=(CW,CΣ)\mathcal{C} = (\mathcal{C}_{W}, \mathcal{C}_{\Sigma}) 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 C\mathcal{C} 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 1≤q≤M1 \le q \le M. For a word w∈Ww \in\mathcal{W} of length ℓ\ell, set rw=⌈ℓq⌉r_w = \lceil\frac{\ell}{q} \rceil and split ww from left to right into chunks of length rwr_w, with potentially shorter last chunk. Let Chunk⁡q(w)\operatorname{Chunk}_{q}(w) be the set of distinct chunks of length at least two of ww.

Let VgV_g be the set of distinct words represented by the bundles in the greedy cover C\mathcal{C}. We construct the output vocabulary as

V=⋃w∈VgChunk⁡q(w).V = \bigcup_{w \in V_g} \operatorname{Chunk}_{q}(w).

We can see that V⊆WV \subseteq\mathcal{W}.

Analysis

Theorem 3.4 (Substring-chunk bicriteria guarantee). Let D\mathcal{D} be a corpus with M=max⁡si∈D∣si∣M = \max_{s_i \in\mathcal{D}} |s_i| and W\mathcal{W} be a set of all possible tokens. For any cardinality budget K≥1K \ge1, max string size M≥1M \ge1 and any integer 1≤q≤M1 \le q \le M and a rational η>0\eta> 0, Algorithm 3 runs in deterministic polynomial time and returns a vocabulary V⊆WV \subseteq\mathcal{W} and valid segmentation of D\mathcal{D} satisfying

∣V∣≤(1+η)(1+ln⁡n)qKandT(D,V)≤(1+1η)(1+ln⁡n)hOPT⁡K|V| \le(1+\eta)(1+\ln n)qK \qquad\text{and}\qquad T(\mathcal{D},V) \le\left(1+\frac{1}{\eta}\right)(1+\ln n)h\operatorname{OPT}_{K}
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 h=q−1+⌈Mq⌉h=q-1+\left\lceil\frac{M}{q}\right\rceil.

Definition 3.5 (Segmentation cover). Let VV be a vocabulary and fix a segmentation P\mathcal{P} of D\mathcal{D} over V∪ΣV\cup\Sigma. For each w∈Vw\in V, let QwQ_w contain the occurrences of ww in P\mathcal{P}. These occurrences are pairwise disjoint, so every nonempty QwQ_w is a bundle.

Let

B={Qw:w∈V, Qw≠∅},\mathcal{B}=\{Q_w:w\in V,\ Q_w\ne\varnothing\},

and let S\mathcal{S} be the set of positions covered by singletons in P\mathcal{P}. The segmentation cover induced by P\mathcal{P} is the pair (B,S)(\mathcal{B},\mathcal{S}). We call B\mathcal{B} its bundle part and S\mathcal{S} its singleton part.

Lemma 3.6 (segmentation cost). Let VV be a vocabulary with ∣V∣≤K|V|\le K and let P\mathcal{P} be the segmentation cover induced by segmentation of D\mathcal{D} over V∪ΣV\cup\Sigma using t=T(D,V)t=T(\mathcal{D},V) tokens. The cost of P\mathcal{P} is at most λK+t\lambda K+t.

Proof. Let P=(B,S)\mathcal{P}=(\mathcal{B},\mathcal{S}) where B\mathcal{B} is the bundle part and S\mathcal{S} is the singleton part of the segmentation cover. Define V′={w∣w∈V,Qw∈B}V'=\{w\mid w\in V,Q_w\in\mathcal{B}\} with k=∣V′∣≤∣V∣=Kk=|V'|\le|V|=K. Since each token in the segmentation either contributes one occurrence to a bundle or a singleton-covered position to S\mathcal{S}, we get:

∑w∈V′∣Qw∣+∣S∣=t.\sum_{w\in V'}|Q_w|+|\mathcal{S}|=t.

Consequently, the cost of the cover is:

c(P)=∑w∈V′c(Qw)+∣S∣=λk+∑w∈V′∣Qw∣+∣S∣=λk+t≤λK+t.c(\mathcal{P}) = \sum_{w \in V'} c(Q_w) + |\mathcal{S}| = \lambda k + \sum_{w \in V'} |Q_w| + |\mathcal{S}| = \lambda k + t \le\lambda K + t.

Lemma 3.7 (Greedy cost). Fix a positive rational λ\lambda. Let V∗V^* be an optimal budget vocabulary with ∣V∣≤K|V| \le K and let OPTK=T(D,V∗)\mathrm{OPT}_K = T(D,V^*). Let CC be the cost of the induced segmentation cover. The greedy algorithm returns a cover C=CW∪CΣC = C_W \cup C_\Sigma with a total R=∑(w,Q)∈CW∣Q∣+∣CΣ∣R = \sum_{(w,Q)\in C_W} |Q| + |C_\Sigma| selected occurrences with a cost of at most (1+ln⁡n)(λK+OPTK)(1+\ln n)(\lambda K+\mathrm{OPT}_K).

Proof. Consider a greedy iteration with r>0r > 0 uncovered positions and the segmentation cover induced by V∗V^* has cost CC. 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 rr. By averaging argument, at least one has cost per newly covered position ratio of at most Cr\frac{C}{r}. 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 Cr\frac{C}{r}.

Fix iteration ii, let rir_i be the number of uncovered positions before the selection and let ziz_i be the number of newly covered positions, and CiC_i the cost of the selection. Then

Cizi≤Cri⟹Ci≤Cziri≤C∑j=ri−zi+1ri1j\frac{C_i}{z_i} \le\frac{C}{r_i} \Longrightarrow C_i \le C\frac{z_i}{r_i} \le C\sum_{j=r_i-z_i+1}^{r_i}\frac{1}{j}

Each iteration covers at least one new position, so the algorithm terminates after L≤nL \le n iterations. Since r1=nr_1=n and for all ii, ri+1=ri−zir_{i+1}=r_i-z_i with rL+1=0r_{L+1}=0. Hence,

∑i=1LCi≤C∑i=1n1i≤C(1+ln⁡n)\sum_{i=1}^{L} C_i \le C\sum_{i=1}^{n}\frac{1}{i} \le C(1+\ln n)

By definition of the covering costs and RR and lemma 3.6, we get

c(C)=λ∣CW∣+R=∑i=1LCi≤(1+ln⁡n)C≤(1+ln⁡n)(λK+OPTK).(17)\begin{aligned} c(C) &= \lambda|C_W| + R \\ &= \sum_{i=1}^{L} C_i \\ &\le(1+\ln n)C \\ &\le(1+\ln n)(\lambda K+\mathrm{OPT}_K). \tag*{(17)} \end{aligned}

For a string w∈Σ∗w \in\Sigma^*, define

Sub⁡(w)={u∈Σ≥2∣∃x,y∈Σ∗:w=xuy}andSuf⁡(w)={u∈Σ+∣∃x∈Σ∗:w=xu}\operatorname{Sub}(w)=\{u\in\Sigma^{\ge2}\mid\exists x,y\in\Sigma^*:w=xuy\} \quad\text{and}\quad \operatorname{Suf}(w)=\{u\in\Sigma^+\mid\exists x\in\Sigma^*:w=xu\}

That is, Sub⁡(w)\operatorname{Sub}(w) is the set of all substrings of ww of length at least 2, and Suf⁡(w)\operatorname{Suf}(w) is the set of all nonempty suffixes of ww.

Lemma 3.8 (A vocabulary of suffixes). Fix q∈{2,…,M}q \in\{2,\ldots,M\}. For every word w∈Ww \in\mathcal{W} of length l≤Ml \le M, there exists a vocabulary Vw⊆Sub⁡(w)V_w \subseteq\operatorname{Sub}(w) such that ∣Vw∣≤q|V_w| \le q and every y∈Suf⁡(w)y \in\operatorname{Suf}(w) can be segmented into at most h=q−1+⌈Mq⌉h=q-1+\left\lceil\frac{M}{q}\right\rceil tokens from Vw∪ΣV_w \cup\Sigma.

Proof. Let VwV_w be the set of distinct chunks construction by chunk construction in 16. Then Vw⊆Sub⁡(w)V_w \subseteq\operatorname{Sub}(w), and ∣Vw∣≤q|V_w| \le q. Every chunk, therefore, is a token in Vw∪ΣV_w \cup\Sigma.

For every nonempty suffix y∈Suf⁡(w)y \in\operatorname{Suf}(w) consider two cases:

Case 1: yy begins at the start of a chunk. Then, yy consist of at most b≤qb \le q chunks from VwV_w. Since q≤hq \le h, this gives a segmentation using at most hh tokens.

Case 2: yy begins strictly inside a chunk. The portion of yy within this chunk has length at most r−1r-1, and can be segmented into at most r−1r-1 singletons. The rest of yy consist of at most q−1q-1 chunks, each a token in VwV_w. Thus, the total number of tokens adds up to at most:

(r−1)+(q−1)≤q−1+⌈Mq⌉=h.(r-1)+(q-1) \le q-1+\left\lceil\frac{M}{q}\right\rceil=h.

Therefore, every suffix of ww admits a segmentation into at most hh tokens from Vw∪ΣV_w \cup\Sigma.

:::

Lemma 3.9 (Cover to partition). Fix q∈{2,…,M}q \in\{2,\ldots,M\}. Let C=CW∪CΣC=\mathcal{C}_W\cup\mathcal{C}_\Sigma be a cover of D\mathcal{D}, where CW\mathcal{C}_W and CΣ\mathcal{C}_\Sigma are its bundle and the singleton parts, respectively. Let RR be its total number of the selected occurrence and VgV_g the distinct vocabulary. For each w∈Vgw \in V_g, let $V_w be the vocabulary given by lemma 3.8, and define

V=⋃w∈VgVw.V=\bigcup_{w\in V_g}V_w.

Then, CC admits a valid segmentation over V∪ΣV\cup\Sigma using at most hRhR tokens. Moreover, ∣V∣≤q∣Vg∣≤q∣CW∣|V|\le q|V_g|\le q|\mathcal{C}_W|.

Proof. Fix a document s∈Ds \in\mathcal{D}. Let xx be its first unprocessed position, initially 11. Since CC covers all positions of the corpus, there exists a selected occurrence interval I=[a,b)I=[a,b) such that a≤x<ba\le x<b. There are two cases:

Case 1: II belongs to a selected bundle I∈QwI\in Q_w for some Qw∈CWQ_w\in\mathcal{C}_W. Then, the substring sx…sb−1s_x\ldots s_{b-1} is a nonempty suffix of ww. By lemma 3.8, it can be segmented into at most hh tokens from Vw∪ΣV_w\cup\Sigma, and therefore, V∪ΣV\cup\Sigma.

Case 2: II is a selected singleton. Then, the substring sxs_x contributes exactly one token, which is at most hh.

Add the resulting tokens to the segmentation, set x=bx=b, and continue this process. Each step strictly increases xx, and the emitted substrings are consecutive and remain within ss. Coverage ensures that the process continues until x=∣s∣+1x=|s|+1, so these substrings partition ss.

We can also ensure that no occurrence interval is used twice in this process: after choosing I=[a,b)I=[a,b), any subsequent unprocessed position is at least bb.

Repeating this process for all documents, uses at most RR selected occurrence intervals, each contributing at most hh tokens, giving at most hRhR tokens.

Finally, each VwV_w contains at most qq chunks/tokens, so

∣V∣=∣⋃Qw∈CWVw∣≤∑Qw∈CW∣Vw∣≤q∣CW∣.|V|=\left|\bigcup_{Q_w\in\mathcal{C}_W}V_w\right|\le\sum_{Q_w\in\mathcal{C}_W}|V_w|\le q|\mathcal{C}_W|.

:::

Proof of Theorem 3.4. Let αn=(1+ln⁡n)\alpha_n=(1+\ln n). The greedy cost analysis gives:

λA+R≤αn(λK+OPT⁡K),\lambda A+R\le\alpha_n(\lambda K+\operatorname{OPT}_K),

Since 1≤OPT⁡K≤n1\le\operatorname{OPT}_K\le n, the guess t=OPT⁡Kt=\operatorname{OPT}_K is among those considered by the algorithm. At this guess, λ=OPT⁡KKη\lambda=\frac{\operatorname{OPT}_K}{K\eta}, so

λA+R≤αnOPT⁡K(1+1/η).\lambda A+R\le\alpha_n\operatorname{OPT}_K(1+1/\eta).

Thus, the acceptance condition holds at t=OPT⁡Kt=\operatorname{OPT}_K. Because the guesses are considered in increasing order, the first accepted guess t^\hat{t} satisfies t^≤OPT⁡K\hat{t}\le\operatorname{OPT}_K.

Let A=∣Vg∣A=|V_g| and RR be the occurrence counts of the accepted cover. The acceptance condition gives

λA+R≤αnt^(1+1η),λ=t^ηK.\lambda A+R\le\alpha_n\hat{t}\left(1+\frac{1}{\eta}\right),\qquad\lambda=\frac{\hat{t}}{\eta K}.

Therefore,

A≤αnt^(1+1η)t^ηK=(1+η)αnK,A\le\frac{\alpha_n\hat{t}\left(1+\frac{1}{\eta}\right)}{\frac{\hat{t}}{\eta K}}=(1+\eta)\alpha_nK,
R≤αnt^(1+1η)≤(1+1η)αnOPT⁡K.R\le\alpha_n\hat{t}\left(1+\frac{1}{\eta}\right)\le\left(1+\frac{1}{\eta}\right)\alpha_n\operatorname{OPT}_K.

By Lemma 3.9, the chunk vocabulary VV satisfies ∣V∣≤qA|V|\le qA and admits a valid segmentation using at most hRhR tokens. Consequently,

∣V∣≤(1+η)(1+ln⁡n)qK|V|\le(1+\eta)(1+\ln n)qK

and

T(D,V)≤(1+1η)(1+ln⁡n)hOPT⁡K.T(\mathcal{D},V)\le\left(1+\frac{1}{\eta}\right)(1+\ln n)h\operatorname{OPT}_K.

Every word in VV is a substring of a selected word and hence a substring of a corpus document. Since these words have length at least two, V⊆WV\subseteq W.

Remark 3.10. The Algorithm 3 achieves (γq,γq)(\gamma_q,\gamma_q)-bicriteria approximation by choosing η=hq\eta=\frac{h}{q} and q=⌈M⌉q=\lceil\sqrt{M}\rceil, making γq=O(Mlog⁡n)\gamma_q=O(\sqrt{M}\log n).

Runtime analysis of Algorithm 3: There are at most O(n2)O(n^2) words in WW. Enumerating words, creating their occurrence lists, and ordering them can be done in polynomial time. In each greedy iteration, for every word w∈Ww\in W, it takes O(n2)O(n^2) to compute Fw(mw,j)F_w(m_w,j) and a total of O(n4)O(n^4) 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 nn iterations, totaling to O(n5)O(n^5) overall. Any selected collection of bundle contains at O(n2)O(n^2) occurrences, making the chunk vocabulary construction and segmentation all be done in polynomial time.

Corollary 3.11. For 1≤K≤n1\le K\le n and M≥2M\ge2, we can achieve equal bicriteria factors

min⁡{1+12n/K, ln⁡nmin⁡1≤q≤M(2q−1+⌈M/q⌉)}.\min\left\{1+\frac{1}{2}\sqrt{n/K},\ \ln n\min_{1\le q\le M}\left(2q-1+\left\lceil M/q\right\rceil\right)\right\}.

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 DD be the corpus with total length nn. Let c(V)=∑w∈V∣w∣c(V)=\sum_{w\in V}|w|. For 2≤B<n2\le B<n, set DB=⌈log⁡2B⌉D_B=\lceil\log_2 B\rceil and any positive rational η\eta, there is a deterministic polynomial-time algorithm that returns a vocabulary and valid segmentation with

c(V)≤(1+η)ln⁡(n)DBB,T(D,V)≤(1+1/η)ln⁡nDBOPT⁡Bst.c(V)\le(1+\eta)\ln(n)D_BB,\qquad T(D,V)\le(1+1/\eta)\ln nD_B\operatorname{OPT}^{\mathrm{st}}_B.

In particular η=1\eta=1 gives equal factors 2ln⁡n⌈log⁡2B⌉=O(log⁡nlog⁡B)2\ln n\lceil\log_2 B\rceil=O(\log n\log B).

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 XGX_G.

Lemma A.1 (Min Generators). Let uu, vv, cc, λ\lambda, ρ\rho be five distinct letters, and consider

X={ucv,ucρ,λcv,λcρ}.X = \{ucv, uc\rho, \lambda cv, \lambda c\rho\}.

If one or both of uu and vv are available, then at least 3 extra generators are needed to generate XX.

If neither uu nor vv are available, at least 4 generators are needed to generate XX.

Proof. To simplify the argument, suppose we have both uu and vv available (note restricting to only one of uu, vv 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: λcρ\lambda c\rho is not a factor and λcρ\lambda c\rho is a factor.

In the first case, since λcρ\lambda c\rho 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 λcρ\lambda c\rho into exactly 2 factors, i.e. either {λc,ρ}\{\lambda c,\rho\} or {λ,cρ}\{\lambda,c\rho\}. Together with the current factors uu and vv from assumption, none of these 2 sets of factors can factorize the word ucvucv. We’ve reached a contradiction.

In the second case, since λcρ\lambda c\rho is a factor, we can choose 1 extra factor. To factorize the word ucvucv, we need another generator. This generator must contain cc and be a factor of ucvucv. The possibilities are cc, ucuc, cvcv, ucvucv. Together with the current factors uu, vv, λcρ\lambda c\rho from assumption, none of these factors can factorize λcv\lambda cv. We’ve reached a contradiction.

Hence, even with both uu and vv available, we need at least 3 extra generators.

Now suppose neither uu nor vv are available. Assume for the sake of contradiction that at most 3 generators suffice. Note at least 1 generator must start with uu and another start with λ\lambda. Also at least 1 generator must end with vv and another end with ρ\rho. Since we’re only allowed 3 generators, these generators must overlap. A factor that starts in {u,λ}\{u,\lambda\} and ends in {v,ρ}\{v,\rho\} 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 u,λu,\lambda and both final letters v,ρv,\rho. So by the logic in the last paragraph, we must have at least 1 generator starting with uu and another starting with λ\lambda, and at least 1 generator ending with vv and another ending with ρ\rho. 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 uu nor vv available, we need at least 4 generators.

Lemma 3.1. The source corpus satisfies

rk⁡(XG)=3m+τ(G).(18)\operatorname{rk}(X_G) = 3m + \tau(G). \tag*{(18)}

Proof. We’ll prove something stronger: any vertex cover UU yields a generating set of size 3m+∣U∣3m + \lvert U\rvert and a factorization of every source word into exactly two factors.

To prove rk⁡(XG)≤3m+∣U∣\operatorname{rk}(X_G) \le3m + \lvert U\rvert, first select all the singleton vertex in UU. Do the following to factorize Xe⊂XGX_e \subset X_G for any edge e=(ue,ve)e = (u_e, v_e). If ue∈Uu_e \in U, select in addition 3 generators cevec_e v_e, ceρec_e \rho_e, λe\lambda_e. Factorize the edge-corresponding XeX_e as ue∣ceveu_e\mid c_e v_e, ue∣ceρeu_e\mid c_e \rho_e, λe∣ceve\lambda_e\mid c_e v_e, λe∣ceρe\lambda_e\mid c_e \rho_e.

Otherwise, ve∈Uv_e \in U, then select in addition 3 generators ueceu_e c_e, λece\lambda_e c_e, ρe\rho_e. Factorize the edge-corresponding XeX_e as uece∣veu_e c_e\mid v_e, uece∣ρeu_e c_e\mid\rho_e, λece∣ve\lambda_e c_e\mid v_e, λece∣ρe\lambda_e c_e\mid\rho_e. The total generating set size is 3m+∣U∣3m + \lvert U\rvert, and the total number of factors is 8m8m.

To prove rk⁡(XG)≥3m+∣U∣\operatorname{rk}(X_G) \ge3m + \lvert U\rvert, take any generating set YY and remove any generators in it that is not used. Let

U={u∈Q∣the corresponding singleton letter u belongs to Y}.U = \{u \in Q \mid\text{the corresponding singleton letter } u \text{ belongs to } Y\}.

Note all other generators that are not in UU are edge specific by definition. Then we can partition the rest of the generators according to their corresponding edge. Let YeY_e be the set containing the edge specific generators of edge ee. Note

∣Y∣=∣U∣+∑e∈E∣Ye∣\lvert Y\rvert= \lvert U\rvert+ \sum_{e\in E} \lvert Y_e\rvert

For an edge ee, only YeY_e and the selected endpoint singleton letters can help generate the words of XeX_e. Lemma A.1 gives that ∣Ye∣≥3\lvert Y_e\rvert\ge3 for every edge, and ∣Ye∣≥4\lvert Y_e\rvert\ge4 when neither endpoint belongs to UU.

Let a(U)a(U) count the edges with no endpoint in UU. Then

∣Y∣≥∣U∣+3m+a(U).\lvert Y\rvert\ge\lvert U\rvert+ 3m + a(U).

Adding one endpoint for every uncovered edge gives a vertex cover of size ∣U∣+a(U)\lvert U\rvert+ a(U). Hence ∣U∣+a(U)≥τ(G)\lvert U\rvert+ a(U) \ge\tau(G), proving ∣Y∣≥τ(G)+3m\lvert Y\rvert\ge\tau(G) + 3m. 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 Ba,jB_{a,j} is recognizable in any concatenation of binary blocks.

Lemma B.1. In a concatenation of binary blocks Ba0,j0Ba1,j1⋯Bay,jyB_{a_0,j_0}B_{a_1,j_1}\cdots B_{a_y,j_y}, the occurrence of 11 marks the beginning of each block. Moreover, any occurrence of some binary block Ba,jB_{a,j} in the concatenation must be one of the Bai,jiB_{a_i,j_i}'s in the concatenation. Any occurrence Ba,jB_{a,j} is uniquely identifiable to have label (a,j)(a,j)

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 ll. Any full occurrence of a binary block therefore aligns with one of the concatenated blocks.

The block Ba,jB_{a,j} is uniquely identifiable because when we encoded the letter-phase pair (a,j)(a,j), 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 XX be a corpus of dd non-empty source words of a FAC instance. Let hR(X)h_R(X) be the encoded corpus of the corresponding Tok instance. Let VV be a vocabulary for the Tok instance. Suppose the segmentation of the Tok corpus with vocabulary VV only uses TT tokens in total. If

T<R+d,(19)T < R + d, \tag*{(19)}

then there exists some generating set Y⊂A+Y \subset A^+ with ∣Y∣≤∣V∣|Y| \le|V|. Consequently, rk⁡(X)≤∣V∣\operatorname{rk}(X) \le|V|.

Proof. Note we call the binary encoding of a source word a "document" in the Tok corpus. If document ii in the Tok corpus is tokenized to tit_i tokens, then it has ti−1t_i - 1 internal token boundaries. So the total number of internal boundaries in the whole corpus will be

∑i=1d(ti−1)=T−d.(20)\sum_{i=1}^{d}(t_i - 1) = T - d. \tag*{(20)}

Call a phase jj bad if any internal token boundary lies inside any block B∗,jB_{*,j} 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 T−d<RT-d<R bad phases.

Recall there are RR phases. So we can choose a good phase jj. A good phase is one that is not bad. From now on, we will only look at the phase jj parts of the Tok corpus. Delete from the corpus and vocabulary anything that is not phase jj. 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 jj.

From the updated corpus, we can still recover the whole source corpus XX because the deleted phases are merely repeats of the good phase jj. Moreover, we can derive a factorization of XX from the tokenization of the corpus. For each source word x∈Xx \in X, suppose its phase-jj-tokenization is as follows

hR(x)=t1…ts(21)h_R(x) = t_1 \ldots t_s \tag*{(21)}

where tit_i are tokens. Since our chosen phase jj is good, each tit_i is consist of complete phase-jj-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 hR(x)h_R(x) to have blocks

Ba0,j,Ba1,j,…Baν,j,(22)B_{a_0,j}, B_{a_1,j}, \ldots B_{a_\nu,j}, \tag*{(22)}

then we recover the source word xx to be

x=a0a1…aν(23)x = a_0a_1\ldots a_\nu \tag*{(23)}

Note s≤νs \le\nu because one token tit_i could contain multiple binary blocks. In addition, separating the word xx at the corresponding token boundaries in hR(x)h_R(x) provide a factorization of xx.

Now we say what the generating set should be. Say a phase-jj token tt contains binary blocks

t=Ba0,j,Ba1,j,…Baξ,j.t = B_{a_0,j}, B_{a_1,j}, \ldots B_{a_\xi,j}.

We want to "read off" the corresponding word that was mapped to this token tt. So we define the translation function π(t):=a0a1…aξ\pi(t) := a_0a_1\ldots a_\xi. This is doable because, for each binary block in token tt, one can first take its inverse of the one-to-one encoding function zz. Then one can output the first coordinate in that inverse. Let

Y:={π(t)∣t∈V}(24)Y := \{\pi(t) \mid t \in V\} \tag*{(24)}

The map π\pi is a function of the source-letter-spelling of its input token tt, so there is at most one image for each vocabulary entry. Hence, ∣Y∣≤∣V∣|Y| \le|V|. By the reasoning above, we know that YY factorizes XX, so it is a generating set of XX.

Proposition 3.2 For every integer R≥1R \ge1, Transformation 1 satisfies

rk⁡(XG)≤B⟹OPT⁡K(DR)≤8m,(25)\operatorname{rk}(X_G) \le B \Longrightarrow\operatorname{OPT}_K(D_R) \le8m, \tag*{(25)}
rk⁡(XG)>B⟹OPT⁡K(DR)≥R+4m.(26)\operatorname{rk}(X_G) > B \Longrightarrow\operatorname{OPT}_K(D_R) \ge R + 4m. \tag*{(26)}

Proof. Recall in Transformation 1, we set K=BK = B. If rk⁡(XG)≤B=3m+Φ\operatorname{rk}(X_G) \le B = 3m + \Phi, then the proof of Lemma 3.1 describes a generating set YY of at most 3m+Φ=B3m + \Phi= B words and exactly 8m8m factors in its factorization of XGX_G. We can simply set V:={hR(y)∣y∈Y}V := \{h_R(y) \mid y \in Y\}, and ∣V∣≤∣Y∣≤B=K|V| \le|Y| \le B = K. Then we tokenize the Tok corpus the same way as the factorization of XGX_G, substituting each factor y∈Yy \in Y with the corresponding token hR(y)h_R(y). Then we get a segmentation length of the Tok corpus of length 8m8m.

Suppose rk⁡(XG)>B=K\operatorname{rk}(X_G) > B = K. Recall d=4md = 4m. If some vocabulary VV of cardinality at most KK had a tokenization with fewer than R+4m=R+dR + 4m = R + d tokens, then Lemma B.2 would produce a generating set of size at most ∣V∣≤K=B|V| \le K = B, 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 BB, and replace the bundle cost by

c(Qw)=λ∣w∣+∣Qw∣.c(Q_w) = \lambda|w| + |Q_w|.

Every vocabulary of storage cost at most BB uses only such words. The dynamic program in Algorithm 1 remains unchanged, except that the density for a bundle of size jj is now

Fw(mw,j)λ∣w∣+j.\frac{F_w(m_w,j)}{\lambda|w|+j}.

Singletons retain cost 1.

Let V∗V^* be an optimal vocabulary with c(V∗)≤Bc(V^*) \le B. As in Lemma 3.6, its induced segmentation cover has cost at most

λc(V∗)+OPTBst≤λB+OPTBst.\lambda c(V^*) + \mathrm{OPT}^{st}_B \le\lambda B + \mathrm{OPT}^{st}_B.

Thus, the charging argument of Lemma 3.7 gives

λA+R≤αn(λB+OPTBst),αn=1+ln⁡n,\lambda A + R \le\alpha_n(\lambda B + \mathrm{OPT}^{st}_B), \qquad\alpha_n = 1 + \ln n,

where A=c(Vg)A = c(V_g) and RR is the total number of selected occurrences, including singletons. Here, each distinct word in VgV_g contributes its storage cost at least once to the selected bundles.

We next replace the chunk construction by a binary decomposition. For each w∈Vgw \in V_g, recursively split ww into two consecutive parts whose lengths differ by at most one, stopping at single characters. Let VwV_w be the set of distinct words of length at least two represented by nodes of this decomposition, including the root ww.

The decomposition has height at most ⌈log⁡2∣w∣⌉≤DB\lceil\log_2 |w| \rceil\le D_B. At each depth, the represented substrings are disjoint parts of ww, so their total length is at most ∣w∣|w|. Since only the first DBD_B depths can contain nonleaf nodes,

c(Vw)≤DB∣w∣.c(V_w) \le D_B |w|.

Moreover, every nonempty suffix of ww can be segmented into at most DBD_B tokens from Vw∪ΣV_w \cup\Sigma. 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 DBD_B contributes at most DBD_B tokens.

Set

V=⋃w∈VgVw.V = \bigcup_{w \in V_g} V_w.

Then

c(V)≤∑w∈Vgc(Vw)≤DBA.c(V) \le\sum_{w \in V_g} c(V_w) \le D_B A.

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 DBRD_B R tokens.

Finally, consider the guesses t=1,…,nt = 1,\ldots,n in increasing order, set λ=t/(ηB)\lambda= t/(\eta B), and accept the first cover satisfying

λA+R≤αnt(1+1/η).\lambda A + R \le\alpha_n t(1 + 1/\eta).

The greedy bound ensures that this condition holds at t=OPTBstt = \mathrm{OPT}^{\mathrm{st}}_{B}. Hence, the first accepted guess t^\hat{t} satisfies t^≤OPTBst\hat{t} \le\mathrm{OPT}^{\mathrm{st}}_{B}, and

A≤(1+η)αnB,R≤(1+1/η)αnOPTBst.A \le(1+\eta)\alpha_n B,\qquad R \le(1+1/\eta)\alpha_n \mathrm{OPT}^{\mathrm{st}}_{B}.

Combining these inequalities with the bounds above gives

c(V)≤(1+η)(1+ln⁡n)DBB,T(D,V)≤(1+1/η)(1+ln⁡n)DBOPTBst.c(V) \le(1+\eta)(1+\ln n)D_B B,\qquad T(D,V) \le(1+1/\eta)(1+\ln n)D_B \mathrm{OPT}^{\mathrm{st}}_{B}.

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 O(∣w∣)O(|w|) nodes and can also be constructed in polynomial time. Fixing a deterministic rule for ties makes the algorithm deterministic. Taking η=1\eta= 1 gives equal factors 2(1+ln⁡n)⌈log⁡2B⌉=O(log⁡nlog⁡B)2(1+\ln n)\lceil\log_2 B\rceil= O(\log n\log B). ∎

Index of Notation

Corpus and tokenization

Σ\Sigma, cc, ϵ\epsilon The binary alphabet Σ={0,1}\Sigma= \{0,1\}, a character c∈Σc \in\Sigma, and the empty word ϵ\epsilon.

A∗A^*, A+A^+, Σ≥1\Sigma^{\ge1} The set of finite words over AA, the set of nonempty words over AA, and the set of binary words of length at least two, respectively.

D\mathcal{D}, dd, sis_i The corpus, the number of documents, and the ii-th document. When a document ss is fixed, sis_i also denotes its ii-th character.

nn, MM The total corpus length n=∑i=1d∣si∣n = \sum_{i=1}^{d} |s_i| and the maximum document length M=max⁡1≤i≤d∣si∣M = \max_{1 \le i \le d} |s_i|.

W(D)\mathcal{W}(\mathcal{D}), W\mathcal{W}, ww, VV The set of distinct substrings of length at least two occurring within a document of D\mathcal{D}, abbreviated W\mathcal{W}. A candidate word is denoted by ww, and a selected vocabulary by V⊆WV \subseteq\mathcal{W}.

w1,…,wtw_1,\ldots,w_t The tokens of a segmentation s=w1⋯wts = w_1 \cdots w_t, where wj∈V∪Σw_j \in V \cup\Sigma and tt is its token count.

Tok⁡(s,V)\operatorname{Tok}(s,V), T(D,V)T(\mathcal{D},V) The minimum token count for ss over V∪ΣV \cup\Sigma, and the minimum total token count T(D,V)=∑i=1dTok⁡(si,V)T(\mathcal{D},V) = \sum_{i=1}^{d} \operatorname{Tok}(s_i,V).

KK, OPT⁡K(D)\operatorname{OPT}_K(\mathcal{D}) The vocabulary cardinality budget and the minimum of T(D,V)T(\mathcal{D},V) over all VV with ∣V∣≤K|V| \le K. We write OPT⁡K\operatorname{OPT}_K when the corpus is understood.

BB, c(V)c(V), OPT⁡Bst(D)\operatorname{OPT}^{\mathrm{st}}_B(\mathcal{D}) The storage budget, the spelling cost c(V)=∑w∈V∣w∣c(V) = \sum_{w \in V} |w|, and the minimum of T(D,V)T(\mathcal{D},V) over all VV with c(V)≤Bc(V) \le B.

α\alpha, β\beta The budget-augmentation factor and the token-count approximation factor, respectively.

HnH_n, αn\alpha_n The harmonic number Hn=∑j=1n1/jH_n = \sum_{j=1}^{n} 1/j and its upper bound αn=1+ln⁡n\alpha_n = 1 + \ln n.

qq In the single-string storage bound, q=min⁡{B,n−B}q = \min\{B,n-B\}.

Vertex cover and word factorization

G=(Q,E)G = (Q,E), ww, mm The source graph, with vertex set QQ, edge set EE, vertex count w=∣Q∣w = |Q|, and edge count m=∣E∣m = |E|.

τ(G)\tau(G), Φ\Phi The minimum size of a vertex cover of GG and the vertex-cover decision budget.

AA, XX, YY, Y∗Y^*, rk⁡(X)\operatorname{rk}(X) The source alphabet, a finite set of source words, a generating set, the set of finite concatenations of elements of YY, and the minimum size of a set YY satisfying X⊆Y∗X \subseteq Y^*.

e=(ue,ve)e = (u_e,v_e), cec_e, λe\lambda_e, ρe\rho_e The endpoints of edge ee, also used as singleton letters, and the three letters private to ee. Lemma A.1 writes these five letters as uu, vv, cc, λ\lambda, ρ\rho.

XeX_e, XGX_G The four source words associated with edge ee, and the full source corpus XG=⋃e∈EXeX_G = \bigcup_{e \in E} X_e. Specifically, Xe={ueceve,ueceρe,λeceve,λeceρe}X_e = \{u_ec_ev_e, u_ec_e\rho_e, \lambda_ec_ev_e, \lambda_ec_e\rho_e\}.

NN, BB The total source length N=∑x∈XG∣x∣=12mN = \sum_{x \in X_G} |x| = 12m and the generator budget B=3m+ΦB = 3m + \Phi. The reduction sets K=BK = B.

UU, YeY_e, a(U)a(U) In the rank proof, U⊆QU \subseteq Q consists of vertices whose singleton letters belong to YY, YeY_e consists of generators private to ee, and a(U)a(U) counts edges with neither endpoint in UU.

Binary encoding and decoding

ϵ\epsilon, qq, pp, RR The hardness exponent 0<ϵ<10 < \epsilon< 1, the amplification exponent q=⌈4/ϵ⌉q = \lceil4/\epsilon\rceil, the base p=N+2q+10p = N + 2q + 10, and the number of phases R=pqR = p^q. Proposition 3.2 allows any integer R≥1R \ge1. aa, jj, bb, z(a,j)z(a,j) A source letter, a phase j∈{1,…,R}j \in\{1,\ldots,R\}, the bit width of a label, and the distinct bb-bit label assigned to the pair (a,j)(a,j).

zz, ziz_i, C(z)C(z), Ba,jB_{a,j}, ll A label z=z1⋯zbz=z_1\cdots z_b, its ii-th bit, its padded encoding C(z)=110z10z20⋯zb0C(z)=110z_10z_20\cdots z_b0, the binary block Ba,j=C(z(a,j))B_{a,j}=C(z(a,j)), and the block length l=2b+3l=2b+3.

x=a1⋯arx=a_1\cdots a_r, hRh_R A source word of length rr and its encoding map. Each aa is replaced by hR(a)=Ba,1⋯Ba,Rh_R(a)=B_{a,1}\cdots B_{a,R}, and hR(x)=hR(a1)⋯hR(ar)h_R(x)=h_R(a_1)\cdots h_R(a_r).

hR(X)h_R(X), DRD_R The encoded corpus of a source set XX, and the particular corpus DR=hR(XG)D_R=h_R(X_G). It has d=4md=4m documents and total length n=NRln=NRl.

TT, tit_i, B∗,jB_{\ast,j} In the boundary count, TT is the number of tokens in the encoded corpus, tit_i is the number in document ii, and B∗,jB_{\ast,j} denotes a phase-jj block with arbitrary source letter. The total number of internal token boundaries is T−dT-d.

yy, ν\nu, ξ\xi 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, y∈Yy \in Y denotes a generator.

t1,…,tst_1,\ldots,t_s, π(t)\pi(t) In the decoding argument, t1,…,tst_1,\ldots,t_s are the tokens in the displayed phase projection. The map π(t)\pi(t) reads the source letters of the retained blocks of token tt, in order.

Occurrences, bundles, and greedy covering

I=(s,[i,j))I=(s,[i,j)) An occurrence covering positions i,…,j−1i,\ldots,j-1 of document ss. Subscripts on II, ii, jj, ss distinguish occurrences.

OwO_w, mwm_w The occurrences of ww in ss, all its occurrences in the corpus, and their number mw=∣Ow∣m_w=|O_w|.

QwQ_w, QQ, λ\lambda, c(Qw)c(Q_w) A nonempty bundle of pairwise disjoint occurrences of ww, also written QQ, its opening charge λ>0\lambda>0, and its cardinality-model cost c(Qw)=λ+∣Qw∣c(Q_w)=\lambda+|Q_w|.

P\mathcal{P}, B\mathcal{B}, SS A segmentation and the two parts of its induced cover: B\mathcal{B} is the family of nonempty word bundles and SS is the set of positions covered by singleton tokens. The induced cover is also written P=(B,S)\mathcal{P}=(\mathcal{B},S).

V′V', kk, tt, c(P)c(\mathcal{P}) The set of vocabulary words used by the segmentation, its size k=∣V′∣k=|V'|, the token count tt, and the induced cover cost c(P)=λk+tc(\mathcal{P})=\lambda k+t.

D\mathbf{D}, IiI_i, aia_i, bib_i, pip_i The concatenation D=s1⋯sd\mathbf{D}=s_1\cdots s_d used to index positions, the ii-th occurrence of a fixed word in start order, its interval Ii=[ai,bi)I_i=[a_i,b_i), and the last index k<ik<i with bk≤aib_k\leq a_i. If no such kk exists, pi=0p_i=0.

UU, gig_i The currently uncovered positions and the gain gi=∣U∩Ii∣g_i=|U\cap I_i| from selecting occurrence IiI_i.

Fw(i,j)F_w(i,j) The maximum number of newly covered positions obtainable by selecting exactly jj disjoint occurrences among I1,…,IiI_1,\ldots,I_i of word ww.

O\mathcal{O}, GG, PP, FF, mm In Algorithms 1–3, the occurrence lists, gain arrays, predecessor arrays, dynamic-programming table, and number of occurrences of the current word. For fixed ww, the entries O[w][i]\mathcal{O}[w][i], G[w][i]G[w][i], and P[w][i]P[w][i] correspond to IiI_i, gig_i, and pip_i, respectively.

ρ\rho, ρ∗\rho^\ast, j∗j^\ast, Q∗Q^\ast, w∗w^\ast, ⊥\perp The candidate density (newly covered positions per unit cost), best density, maximizing bundle size, best bundle, and its word. The sentinel w∗=⊥w^\ast=\perp selects the singleton alternative.

xx, JJ In Algorithm 2, the position chosen for a singleton and the set of positions newly covered in the current iteration.

C\mathcal{C}, Cw\mathcal{C}_w, CΣ\mathcal{C}_{\Sigma}, RR The greedy cover, its selected bundles, its selected singletons, and the total number of selected occurrences, including singletons: R=∑Q∈Cw∣Q∣+∣CΣ∣R=\sum_{Q\in\mathcal{C}_w}|Q|+|\mathcal{C}_{\Sigma}|.

V∗V^\ast, CC, c(C)c(C) An optimal vocabulary for budget KK, the cost of its induced comparison cover, and the cost of the greedy cover, respectively. rr, rir_i, ziz_i, CiC_i, LL In the greedy cost proof, rr is the number of uncovered positions. At iteration ii, rir_i is the number remaining before selection, ziz_i is the number newly covered, and CiC_i is the selection cost. The algorithm takes LL iterations.

Substring chunks and budget augmentation

Sub⁡(w)\operatorname{Sub}(w), Suf⁡(w)\operatorname{Suf}(w) The substrings of ww of length at least two and the nonempty suffixes of ww, respectively. In w=xuyw=xuy or w=xuw=xu, uu is the indicated substring or suffix.

qq, η\eta, hh, γq\gamma_q The maximum number of chunks per selected word, the positive rational tradeoff parameter, the suffix token bound h=q−1+⌈M/q⌉h=q-1+\lceil M/q\rceil, and the common bicriteria factor γq=(q+h)(1+ln⁡n)\gamma_q=(q+h)(1+\ln n) obtained when η=h/q\eta=h/q.

ll, rr, bb, VwV_w, yy In the chunk construction, l=∣w∣l=|w|, r=⌈l/q⌉r=\lceil l/q\rceil is the chunk length, b=⌈l/r⌉b=\lceil l/r\rceil is the number of chunks, VwV_w is the set of distinct chunks of length at least two, and yy is a nonempty suffix of ww.

xx, aa, bb In the cover-to-partition proof, xx is the first unprocessed position and [a,b)[a,b) is a selected interval containing xx. In Algorithm 3, a,ba,b are the endpoints of the current chunk.

tt, t^\hat{t}, λ\lambda In Algorithm 3, tt is the trial token count, t^\hat{t} is the first accepted trial, and λ=t/(Kη)\lambda=t/(K\eta). At output, tt denotes the token count of the returned segmentation.

VgV_g, AA, VV, P\mathcal{P} The set of distinct words selected by the greedy cover, its cardinality A=∣Vg∣A=|V_g|, the final chunk vocabulary V=⋃w∈VgVwV=\bigcup_{w\in V_g}V_w, and the output segmentation.

Storage-budget cover

DBD_B, WBW_B, OPT⁡B\operatorname{OPT}_B The parameter DB=⌈log⁡2B⌉D_B=\lceil\log_2 B\rceil, the candidate set WB={w∈W:∣w∣≤B}W_B=\{w\in W:|w|\le B\}, and the shorthand used in Appendix C for the storage optimum OPT⁡Bst\operatorname{OPT}^{\mathrm{st}}_B.

λ\lambda, c(Qw)c(Q_w) The per-unit spelling charge λ=t/(ηB)\lambda=t/(\eta B) for trial tt, and the bundle cost c(Qw)=λ∣w∣+∣Qw∣c(Q_w)=\lambda|w|+|Q_w|.

CWB\mathcal{C}_{W_B}, LL, RR The bundles selected in the storage model, their total spelling length L=∑Qw∈CWB∣w∣L=\sum_{Q_w\in\mathcal{C}_{W_B}}|w|, and the number of selected occurrences including singletons. A spelling contributes once per selected bundle, so the cover costs λL+R\lambda L+R.

References

  1. [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
  2. [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/.
  3. [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.
  4. [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.
  5. [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.

Paper details

vlnc:W_s8fz5r8g
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 11

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents