{'fraction_non_alphanumeric': 0.04058846709575726, 'fraction_numerical': 0.010179955339550769, 'mean_word_length': 4.022097625329815, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Exponential inequalities for empirical unbounded context trees

In this paper we obtain non-uniform exponential upper bounds for the rate of convergence of a version of the algorithm Context, when the underlying tree is not necessarily bounded. The algorithm Context is a well-known tool to estimate the context tree of a Variable Length Markov Chain. As a consequence of the exponential bounds we obtain a strong consistency result. We generalize in this way several previous results in the field.


Introduction
In this paper we present an exponential bound for the rate of convergence of the algorithm Context for a class of unbounded variable memory models, taking values on a finite alphabet A. From this it follows a strong consistency result for the algorithm Context in this setting. Variable memory models were first introduced in the information theory literature by Rissanen [11] as a universal system for data compression. Originally called by Rissanen finite memory source or probabilistic tree, this class of models recently became popular in the statistics literature under the name of Variable Length Markov Chains (VLMC) [1].
The idea behind the notion of variable memory models is that the probabilistic definition of each symbol only depends on a finite part of the past and the length of this relevant portion is a function of the past itself. Following Rissanen we call context the minimal relevant part of each past. The set of all contexts satisfies the suffix property which means that no context is a proper suffix of another context. This property allows to represent the set of all contexts as a rooted labeled tree. With this representation the process is described by the tree of all contexts and a associated family of probability measures on A, indexed by the tree of contexts. Given a context, its associated probability measure gives the probability of the next symbol for any past having this context as a suffix. From now on the pair composed by the context tree and the associated family of probability measures will be called probabilistic context tree.
Rissanen not only introduced the notion of variable memory models but he also introduced the algorithm Context to estimate the probabilistic context tree. The way the algorithm Context works can be summarized as follows. Given a sample produced by a chain with variable memory, we start with a maximal tree of candidate contexts for the sample. The branches of this first tree are then pruned until we obtain a minimal tree of contexts well adapted to the sample. We associate to each context an estimated probability transition defined as the proportion of time the context appears in the sample followed by each one of the symbols in the alphabet. From Rissanen [11] to Galves et al. [10], passing by Ron et al. [12] and Bühlmann and Wyner [1], several variants of the algorithm Context have been presented in the literature. In all the variants the decision to prune a branch is taken by considering a cost function. A branch is pruned if the cost function assumes a value smaller than a given threshold. The estimated context tree is the smallest tree satisfying this condition. The estimated family of probability transitions is the one associated to the minimal tree of contexts.
In his seminal paper Rissanen proved the weak consistency of the algorithm Context in the case where the contexts have a bounded length, i.e. where the tree of contexts is finite. Bühlmann and Wyner [1] proved the weak consistency of the algorithm also in the finite case without assuming a priori known bound on the maximal length of the memory, but using a bound allowed to grow with the size of the sample. In both papers the cost function is defined using the log likelihood ratio test to compare two candidate trees and the main ingredient of the consistency proofs was the chi-square approximation to the log likelihood ratio test for Markov chains of fixed order. A different way to prove the consistency in the finite case was introduced in [10], using exponential inequalities for the estimated transition probabilities associated to the candidate contexts. As a consequence they obtain an exponential upper bound for the rate of convergence of their variant of the algorithm Context.
The unbounded case as far as we know was first considered by Ferrari and Wyner [8] who also proved a weak consistency result for the algorithm Context in this more general setting. The unbounded case was also considered by Csiszár and Talata [3] who introduced a different approach for the estimation of the probabilistic context tree using the Bayesian Information Criterion (BIC) as well as the Minimum Description Length Principle (MDL). We refer the reader to this last paper for a nice description of other approaches and results in this field, including the context tree maximizing algorithm by Willems et al. [14]. With exception of Weinberger et al. [13], the issue of the rate of convergence of the algorithm estimating the probabilistic context tree was not addressed in the literature until recently. Weinberger et al. proved in the bounded case that the probability that the estimated tree differs from the finite context tree generating the sample is summable as a function of the sample size. Duarte et al. in [6] extends the original weak consistency result by Rissanen [11] to the unbounded case. Assuming weaker hypothesis than [8], they showed that the on-line estimation of the context function decreases as the inverse of the sample size.
In the present paper we generalize the exponential inequality approach presented in [10] to obtain an exponential upper bound for the algorithm Context in the case of unbounded probabilistic context trees. Under suitable conditions, we prove that the truncated estimated context tree converges exponentially fast to the tree generating the sample, truncated at the same level. This improves all results known until now.
The paper is organized as follows. In section 2 we give the definitions and state the main results. Section 3 is devoted to the proof of an exponential bound for conditional probabilities, for unbounded probabilistic context trees. In section 4 we apply this exponential bound to estimate the rate of convergence of our version of the algorithm Context and to prove its consistency.

Definitions and results
In what follows A will represent a finite alphabet of size |A|. Given two integers m ≤ n, we will denote by w n m the sequence (w m , . . . , w n ) of symbols in A. The length of the sequence w n m is denoted by ℓ(w n m ) and is defined by ℓ(w n m ) = n−m+1. Any sequence w n m with m > n represents the empty string and is denoted by λ. The length of the empty string is ℓ(λ) = 0.
Given two finite sequences w and v, we will denote by vw the sequence of length ℓ(v) + ℓ(w) obtained by concatenating the two strings. In particular, λw = wλ = w. The concatenation of sequences is also extended to the case in which v denotes a semi-infinite sequence, that is v = v −1 −∞ . We say that the sequence s is a suffix of the sequence w if there exists a sequence u, with ℓ(u) ≥ 1, such that w = us. In this case we write s ≺ w. When s ≺ w or s = w we write s w. Given a sequence w we denote by suf(w) the largest suffix of w.
In the sequel A j will denote the set of all sequences of length j over A and A * represents the set of all finite sequences, that is Definition 2.1. A countable subset T of A * is a tree if no sequence s ∈ T is a suffix of another sequence w ∈ T . This property is called the suffix property.
We define the height of the tree T as In the case h(T ) < +∞ it follows that T has a finite number of sequences. In this case we say that T is bounded and we will denote by |T | the number of sequences in T . On the other hand, if h(T ) = +∞ then T has a countable number of sequences. In this case we say that the tree T is unbounded.
Given a tree T and an integer K we will denote by T | K the tree T truncated to level K, that is We will say that a tree is irreducible if no sequence can be replaced by a suffix without violating the suffix property. This notion was introduced in [3] and generalizes the concept of complete tree.
Consider a stationary stochastic chain (X t ) t∈Z over A. Given a sequence w ∈ A j we denote by p(w) = P(X j 1 = w) the stationary probability of the cylinder defined by the sequence w. If p(w) > 0 we write , for all a ∈ A, and no suffix of w satisfies this equation.
Definition 2.4. We say that the process (X t ) is compatible with the probabilistic context tree (T ,p) if the following conditions are satisfied 1. w ∈ T if and only if w is a context for the process (X t ).
2. For any w ∈ T and any a ∈ A,p(a|w) From now on we will assume that the probabilistic context tree (T , p) satisfies the following assumptions.
Assumption 2.6. Summability of the sequence (1 − α k ), k ≥ 0. In this case denote by For a probabilistic context tree satisfying Assumptions 2.5 and 2.6, the maximal coupling argument used in [7], or alternatively the perfect simulation scheme presented in [2], imply the uniqueness of the law of the chain compatible with it.
Given an integer k ≥ 1, we define We denote by In what follows we will assume that x 0 , x 1 , . . . , x n−1 is a sample of the stationary stochastic chain (X t ) compatible with the probabilistic context tree (T , p).
For any finite string w with ℓ(w) ≤ n, we denote by N n (w) the number of occurrences of the string in the sample; that is For any element a ∈ A , the empirical transition probabilityp n (a|w) is defined byp This definition ofp n (a|w) is convenient because it is asymptotically equivalent to Nn(wa) Nn(w·) and it avoids an extra definition in the case N n (w·) = 0. A variant of Rissanen's algorithm Context is defined as follows. First of all, let us define for any finite string w ∈ A * : ∆ n (w) = max a∈A |p n (a|w) −p n (a|suf(w))|.
The ∆ n (w) operator computes a distance between the empirical transition probabilities associated to the sequence w and the one associated to the sequence suf(w). Definition 2.8. Given δ > 0 and d < n, the tree estimated with the algorithm Context iŝ where A r 1 denotes the set of all sequences of length at most r. In the case It is easy to see thatT δ,d n is an irreducible tree. Moreover, the way we defined p n (·|·) in (2.7) associates a probability distribution to each sequence inT δ,d n . The main result in this article is the following Theorem 2.9. Let (T , p) be a probabilistic context tree satisfying Assumptions 2.5 and 2.6 and let (X t ) be a stationary stochastic chain compatible with (T , p). Then for any integer K, any d satisfying any δ < D d and any .
As a consequence we obtain the following strong consistency result.
Corollary 2.11. Under the conditions of Theorem 2.9 we havê T δ,d n | K = T | K , eventually almost surely as n → +∞.

Exponential inequalities for empirical probabilities
The main ingredient in the proof of Theorem 2.9 is the following exponential upper bound Theorem 3.1. For any finite sequence w, any symbol a ∈ A and any t > 0 the following inequality holds As a direct consequence of Theorem 3.1 we obtain the following corollary.
Corollary 3.3. For any finite sequence w with p(w) > 0, any symbol a ∈ A, any t > 0 and any n > |A|+1 tp(w) + ℓ(w) the following inequality holds where C is given by (3.2).
To prove Theorem 3.1 we need a mixture property for processes compatible with a probabilistic context tree (T , p) satisfying Assumptions 2.5 and 2.6. This is the content of the following lemma. such that for any i ≥ 1, any k > i, any j ≥ 1 and any finite sequence w j 1 , the following inequality holds Proof. First note that where A ∞ denotes the set of all semi-infinite sequences u 0 −∞ . The reader can find a proof of the inequalities above in [7,Proposition 3]. Using this fact and the condition of stationarity it is sufficient to prove that for any k ≥ 0, Note that for all pasts . Therefore, applying the loss of memory property proved in [2, Corollary 4.1] we have that where ρ m is defined as the probability of return to the origin at time m of the Markov chain on N starting at time zero at the origin and having transition probabilities This concludes the proof of (3.6). To prove (3.5), let (Z n ) be the Markov chain with probability transitions given by (3.7). By definition we have From this, using the inequality This concludes the proof of the lemma.
We are now ready to prove Theorem 3.1.

Proof of the main results
Proof of Theorem 2.9. Define Then, if d < n we have that The result follows from a succession of lemmas.
where C is given by (3.2).
Note that the fact w ∈ T implies that for any finite sequence u with p(u) > 0 and any symbol a ∈ A we have p(a|w) = p(a|uw). Hence, Using Corollary 3.3 we can bound above the right hand side of the last inequality by where C is given by (3.2).
For any n > 2(|A|+1) (D d −δ)ǫ d + d and for any w ∈T δ,d n with ℓ(w) < K we have that where C is given by (3.2).
Hence, we have that for any a ∈ A ∆ n (ūw) ≥ D d − |p n (a|suf(ūw)) − p(a|suf(ūw))| − |p n (a|ūw) − p(a|ūw)|. Therefore, As δ < D d and n > 2(|A|+1) (D d −δ)ǫ d + d we can use Corollary 3.3 to bound above the right hand side of this inequality by 4 |A| e 1 e exp −(n − d) where C is given by (3.2). This concludes the proof of the lemma. Now we can finish the proof of Theorem 2.9. We have that . Using the definition of O δ,d n and U δ,d n we have that Applying Lemma 4.1 and Lemma 4.2 we can bound above the last expression by where C is given by (3.2). We conclude the proof of Theorem 2.9.
Proof of Corollary 2.11. It follows from Theorem 2.9, using the first Borel-Cantelli Lemma and the fact that the bounds for the error estimation of the context tree are summable in n for a fixed d satisfying (2.10) and δ < D d .

Final remarks
The present paper presents an upper bound for the rate of convergence of a version of the algorithm Context, for unbounded context trees. This generalizes previous results obtained in [10] for the case of bounded variable memory processes. We obtain an exponential bound for the probability of incorrect estimation of the truncated context tree, when the estimator is given by Definition (2.8). Note that the definition of the context tree estimator depends on the parameter δ, and this parameter appears in the exponent of the upper bound. To assure the consistency of the estimator we need to choose a δ sufficiently small, depending on the transition probabilities of the process. Therefore, our estimator is not universal, in the sense that for any fixed δ it fails to be consistent for any process having D d < δ.
The same happens with the parameter d. In order to choose δ and d not depending on the process, we can allow these parameters to be a function of n, in such a way δ n goes to zero and d n goes to +∞ as n diverges. When we do this, we loose the exponential property of the upper bound.
As an anonymous referee has pointed out, Finesso et al. [9] proved that in the simpler case of estimating the order of a Markov chain, it is not possible to obtain pure exponential bounds for the overestimation event with a universal estimator. The above discussion illustrates this fact.