## On Approximate Pattern Matching for a Class of Gibbs Random Fields

### November 27, 2006

• Abstract: We prove an exponential approximation for the law of approximate occurrence of typical patterns for a class of Gibbsian sources on the lattice ${\mathbb{Z}}^{d}$  , $d\ge 2$  . From this result, we deduce a law of large numbers and a large deviation result for the the waiting time of distorted patterns.
Key-words: Gibbs measures, approximate matching, exponential law, lossy data compression, law of large numbers, large deviations.

1 Introduction

In recent years there has been growing interest in a detailed probabilistic analysis of pattern matching and approximate pattern matching. For example, in information theory, motivation comes from studying performance of idealized Lempel-Ziv coding schemes. In mathematical biology, one likes to have accurate estimates for the probability that two (e.g. DNA) sequences agree in a large interval with some error-percentage.
There is also considerable interest in the analysis of occurrence of patterns in the multi-dimensional setting, e.g., in the context of video-image compression [2, and more generally, lossy data compression [5, 6.
In this paper we study the following problem. Fix a pattern ${A}_{n}$  in a cubic box of size $n$  . Given a configuration $\sigma$  of a Gibbs random field, what is the size of the ”observation window” in which we do not necessary see exactly this pattern for the first time, but any pattern obtained by distorsion of the fixed pattern ${A}_{n}$  ? By this we mean a pattern which contains a fixed fraction $\epsilon$  of spins different from those of ${A}_{n}$  . We are interested in the behavior of the volume of this observation window, that we call ”approximate hitting-time”, when $n$  grows.
Our main result (Theorem  1 ) can be phrased as follows. The distribution of the approximate hitting-time, when properly normalized, gets closer and closer to an exponential law. The normalization is the product of a certain parameter ${\Lambda }_{n}$  and the probability of the set of distorted patterns $\left[{A}_{n}{\right]}^{\epsilon }$  . In fact, we get a precise control of the error term which allows us to derive two corollaries for the approximate waiting-time: given a configuration $\eta$  randomly chosen from an ergodic Gibbs random field, we increase the obervation window in the random configuration $\sigma$  drawn from the given Gibbs random field until we see approximately the pattern ${\eta }_{{C}_{n}}$  . The first corollary implies a law of large numbers allowing to get the rate distorsion function almost-surely from this approximate waiting-time. The second corollary is related to large deviations bounds. While the law of large numbers for approximate waiting-times appears in [6, the large deviation result is new. Moreover, the convergence in distribution to the exponential law of the rescaled approximate hitting-time is also new.
We briefly indicate the key ingredients needed to prove this exponential approximation.
First, we assume that the Gibbs random field satisfies a certain strong mixing condition (non-uniformly $\phi$  -mixing condition). For instance, this property holds for all Markov random fields which satisfy the Dobrushin uniqueness condition. The second key ingredient is a result by Chi [4allowing one to obtain the rate distorsion function ”à la Shannon-McMillan-Breiman”. We take advantage of our previous work [1in which we deal with ”exact” hitting-times. The proof of the main result of the present work readily follows a large part of the proof in [1but there is a crucial step which is different (”second moment estimate ”). Moreover, one has to restrict to ”good” patterns: if a pattern has ”too much overlap” with its translates by vectors of size of order $n$  , then one cannot hope to obtain an exponential distribution. These good patterns are shown to be typical in the sense that the measure of good patterns approaches one exponentially fast as $n$  diverges (Proposition  2 ). When we have a random field distributed according to a Bernoulli measure, the goodness assumption on patternscan be removed. In this case, we prove (Theorem 2) that for any pattern Theorem 1 applies. Surprisingly, our proof involves the strong invariance principle for simple random walks. We have no idea to provide a simpler proof.
Outline of the paper. In the next section, we set notations and definitions, and state our main theorems. In section 3, we apply the exponential approximation of the previous section to approximate waiting times for which we obtain a.s. strong approximation and large deviations results. In section 4, we give all proofs.
Acknowledgment. We thank Z. Chi for providing us his preprint [4.

2 Set-up and main results

For the sake of simplicity, we consider a $\left\{0,1\right\}$  -valued random field on the lattice $\mathbb{Z}d$  , $d\ge 2$  . The results hold for arbitrary finite alphabets as well. Configurations are denoted $\eta ,\sigma ,\omega$  and collected in the set $\Omega =\left\{0,1{\right\}}^{\mathbb{Z}d}$  . $\Omega$  is provided with the Borel $\sigma$  -field, and for $V\subseteq {\mathbb{Z}}^{d}$  , ${\mathcal{ℱ}}_{V}$  denotes the $\sigma$  -algebra generated by $\left\{{\sigma }_{x}:x\in V\right\}$  .
For a finite subset $V\subseteq \mathbb{Z}d$  and configurations $\sigma ,\eta \in \Omega$  we denote by
 $\begin{array}{c}\Delta \left(V,\eta ,\sigma \right)={\sum }_{x\in V}|{\eta }_{x}-{\sigma }_{x}|\end{array}$ (2.1)
the number of mismatches between $\sigma$  and $\eta$  in the volume $V$  , i.e., the Hamming distance between ${\eta }_{V}$  and ${\sigma }_{V}$  times the cardinality of $V$  .
We denote by ${C}_{n}$  the cube $\left[0,n{\right]}^{d}\cap {\mathbb{Z}}^{d}$  . A $n$  -pattern is a map ${A}_{n}:{C}_{n}\to \left\{0,1\right\}$  .
It is naturally associated to its cylinder $\left[{A}_{n}\right]=\left\{\sigma \in \Omega :{\sigma }_{{C}_{n}}={A}_{n}\right\}$  . For a pattern ${A}_{n}$  and $x\in {\mathbb{Z}}^{d}$  we denote by ${\theta }_{-x}{A}_{n}$  the pattern supported on ${C}_{n}+x$  defined by ${A}_{n}\left(y+x\right)={A}_{n}\left(y\right)$  ( $y\in {C}_{n}$  ).
For a pattern ${A}_{n}$  we denote by $\left[{A}_{n}{\right]}^{\epsilon }$  the set of configurations which $\epsilon$  -match with ${A}_{n}$  :
 $\begin{array}{c}\left[{A}_{n}{\right]}^{\epsilon }=\left\{\omega \in \Omega :\Delta \left({C}_{n},\omega ,{A}_{n}\right)\le \epsilon |{C}_{n}|\right\}.\end{array}$ (2.2)
The set of configurations $\left[{A}_{n}{\right]}^{\epsilon }$  can also be viewed as a set of $n$  -patterns, and we will (with a slight abuse of notation) use the same symbol for the set of configurations and the set of $n$  -patterns which are restrictions of configurations in $\left[An\right]\epsilon$  to ${C}_{n}$  .
DEFINITION 1. The approximate hitting time of $\left[{A}_{n}{\right]}^{\epsilon }$  in a configuration $\sigma$  is defined as
 $\begin{array}{c}{\mathbf{T}}_{\left[{A}_{n}{\right]}^{\epsilon }}\left(\sigma \right)=min\left\{|{C}_{k}|:k>0,\exists x\in {\mathbb{Z}}^{d},{C}_{n}+x\subseteq {C}_{k}and{\theta }_{-x}\sigma \in \left[An\right]\epsilon \right\}.\end{array}$ (2.3)
For $\epsilon =0$  (exact matching time or occurrence time of a pattern), we obtained in [1an exponential approximation for the law of ${\mathbf{T}}_{\left[An\right]\epsilon }$  under the hypotheses of non-uniform $\phi$  -mixing and Gibbsianness of the random field. We recall here what this mixing assumption is. For $m>0$  define
 $\begin{array}{c}\phi \left(m\right)=sup\frac{1}{|{A}_{1}|}|\mathbb{P}\left({E}_{{A}_{1}}|{E}_{{A}_{2}}\right)-\mathbb{P}\left({E}_{{A}_{1}}\right)|\end{array}$ (2.4)
where the supremum is taken over all finite subsets ${A}_{1},{A}_{2}$  of $\mathbb{Z}d$  , with $d\left({A}_{1},{A}_{2}\right)\ge m$  ( $\text{1}$  ) and ${E}_{{A}_{i}}\in {\mathcal{ℱ}}_{{A}_{i}}$  , with $\mathbb{P}\left({E}_{{A}_{2}}\right)>0$  . Note that this $\phi \left(m\right)$  differs from the usual $\phi$  -mixing function since we divide by the size of the dependence set of the event ${E}_{{A}_{1}}$  .
DEFINITION 2. A random field is non-uniformly exponentially $\phi$  -mixing if there exist constants ${C}_{1},{C}_{2}>0$  such that
 $\begin{array}{c}\phi \left(m\right)\le {C}_{1}{e}^{-{C}_{2}m}\text{for all}m>0.\end{array}$ (2.5)
A typical example of a Gibbs field satisfying this assumption is the 2d-Ising model above critical temperature. In general, it is satisfied in the so-called high-temperature regime of Dobrushin uniqueness. We refer the reader to [8, 9for more details on this and on Gibbs measures in general.
An important property of Gibbs measures is the so-called “finite energy” property.
This means that there is a continuous version of the conditional probability $\mathbb{P}\left({\sigma }_{0}=0|{\sigma }_{\mathbb{Z}d\\left\{0\right\}}\right)$  such that
 $\begin{array}{c}\delta <\mathbb{P}\left({\sigma }_{0}=0|{\sigma }_{\mathbb{Z}d\\left\{0\right\}}\right)<\left(1-\delta \right)\end{array}$ (2.6)
where $\delta \in \left(0,\frac{1}{2}\right)$  is independent of $\sigma$  . This immediately implies the existence of $\kappa >0$  such that for all $V\subseteq \mathbb{Z}d$  , and all $\eta \in \Omega$
 $\begin{array}{c}\mathbb{P}\left(\left\{\sigma :{\sigma }_{V}={\eta }_{V}\right\}\right)\le {e}^{-\kappa |V|}.\end{array}$ (2.7)
We will use the following estimate:
LEMMA 1. Under the assumption that $\mathbb{P}$  is a Gibbs measure, there exist ${\epsilon }_{c}>0$  and $K=K\left({\epsilon }_{c}\right)>0$  such that for any pattern ${A}_{n}$  and any $\epsilon <{\epsilon }_{c}$  $\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\right)\le {e}^{-K{n}^{d}}.$
• Proof. This is an immediate consequence of the estimate ( 2.7 ) and the estimate $|\left[{A}_{n}{\right]}^{\epsilon }|\le {\sum }_{k=0}^{\epsilon {n}^{d}}\left(\genfrac{}{}{0}{}{{n}^{d}}{k}\right)\le {e}^{{n}^{d}I\left(\epsilon \right)}$  with $I\left(\epsilon \right)↓0$  if $\epsilon ↓0$  .
Contrarily to the situation for exact matching, we will need an assumption on the patterns in order to obtain an exponential law. This can be compared with the condition of not being ”badly self-repeating” needed to obtain the exponential law for the return times in [1. As we shall see, being a ”good” pattern is a typical property.
DEFINITION 3. Given $0<\alpha <1,0\le \epsilon <1$  , we say that a $n$  -pattern ${A}_{n}$  is called $\left(\epsilon ,\alpha \right)$  -good if the set $\left[An\right]\epsilon \cap {\theta }_{x}\left[{A}_{n}{\right]}^{\epsilon }$  is empty for all $x\in {\mathbb{Z}}^{d}$  such that $|x|\le \alpha n$  . The set of all $\left(\epsilon ,\alpha \right)$  -good patterns is denoted by ${\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)$  . By abuse of notation, we use the same symbol for the set of configurations $\omega$  such that ${\omega }_{{C}_{n}}$  is $\left(\epsilon ,\alpha \right)$  -good.
For $\epsilon =0$  and $\alpha <1/2$  , ${\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)$  coincides with the set of non badly self-repeating patterns in [1, definition 5.1.
We shall need a result by Chi [4on the rate distorsion function. We recall briefly the definition of the rate distorsion function and refer the reader to [3for moreinformation and background and to [6for a discussion on lossy data compression.
Given a stationary and ergodic measure $\mathbb{Q}$  and a stationary and ergodic Gibbs measure $\mathbb{P}$  , the rate distortion function $\mathcal{ℛ}\left(\mathbb{Q},\mathbb{P},\epsilon \right)$  is defined as follows:
 $\begin{array}{cc}\mathcal{ℛ}\left(\mathbb{Q},\mathbb{P},\epsilon \right)& ={lim}_{n\to \infty }{\mathcal{ℛ}}_{n}\left(\mathbb{Q},\mathbb{P},\epsilon \right)\end{array}$ (2.8)
 $\begin{array}{cc}{\mathcal{ℛ}}_{n}\left(\mathbb{Q},\mathbb{P},\epsilon \right)& ={inf}_{{J}_{n}}\frac{1}{|{C}_{n}|}H\left({\mathbb{J}}_{n}\parallel {\mathbb{Q}}_{n}×{\mathbb{P}}_{n}\right)\end{array}$ (2.9)
 $\begin{array}{}\end{array}$
where the infimum taken over all joint distributions ${\mathbb{J}}_{n}$  on $\left\{0,1{\right\}}^{{n}^{d}}×\left\{0,1{\right\}}^{{n}^{d}}$  such that the $\left\{0,1{\right\}}^{{n}^{d}}$  -marginal of ${\mathbb{J}}_{n}$  is ${\mathbb{Q}}_{n}$  and $\int \frac{\Delta \left({C}_{n},\omega ,\sigma \right)}{|{C}_{n}|}d{\mathbb{J}}_{n}\left(\omega ,\sigma \right)\le \epsilon .$  $H\left({\mathbb{J}}_{n}\parallel {\mathbb{Q}}_{n}×{\mathbb{P}}_{n}\right)$  is the relative entropy between ${\mathbb{J}}_{n}$  and ${\mathbb{Q}}_{n}×{\mathbb{P}}_{n}$  .
We have the following key result which follows from [4and [6,Theorem25.
PROPOSITION 1. Let $\mathbb{Q}$  be a stationary and ergodic measure and $\mathbb{P}$  be a stationary and ergodic Gibbs measure. Then
 $\begin{array}{c}\mathcal{ℛ}\left(\mathbb{Q},\mathbb{P},\epsilon \right)=-{lim}_{n\to \infty }\frac{1}{|{C}_{n}|}log\mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)\mathbb{Q}-\text{almost-surely}.\end{array}$ (2.10)
Moreover, $\mathcal{ℛ}$  is a convex (and hence continuous) function of $\epsilon$  and is non-zero in some interval $\left[0,{\epsilon }_{0}\right)$  .
The property  2.10 is called the generalized asymptotic equipartition property in [6. Throughout we will simply write $\mathcal{ℛ}\left(\epsilon \right)$  instead of $\mathcal{ℛ}\left(\mathbb{Q},\mathbb{P},\epsilon \right)$  .
We can now state our main result.
THEOREM 1. Suppose that $\mathbb{P}$  is a non-uniformly exponentially $\phi$  -mixing Gibbs measure and $\mathbb{Q}$  is a stationary and ergodic Gibbs measure. Assume that the rate distortion function ( 2.8 ) is strictly positive in $\left[0,{\epsilon }_{0}\right)$  . Then for all $\alpha \in \left(0,1\right)$  and $\epsilon >0$  small enough: namely, $\frac{\epsilon }{\alpha }<{\epsilon }_{0},$  there exist ${\Lambda }_{1},{\Lambda }_{2},C,c\in \left(0,\infty \right)$  , such that and for every $t>0$  , $n\ge 1$  , and $\mathbb{Q}$  -almost all $\omega$  with ${\omega }_{{C}_{n}}\in {\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)$  , the following estimate holds:
 $\begin{array}{c}|\mathbb{P}\left({\mathbf{T}}_{\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }}>\frac{t}{{\Lambda }_{n}\mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)}\right)-{e}^{-t}|\le C{e}^{-ct}{e}^{-K{n}^{d}}\end{array}$ (2.11)
where ${\Lambda }_{n}=\Lambda \left({\omega }_{{C}_{n}}\right)$  is such that
 $\begin{array}{c}{\Lambda }_{1}\le {\Lambda }_{n}\le {\Lambda }_{2}.\end{array}$ (2.12)
Dependence of the parameters in Theorem  1 on $\epsilon$  and $\alpha$  will be discussed after the proof, see Remark  1 .
Let us briefly comment on the difference between Theorem  1 and the one obtained in [1for exact matching, that is the case corresponding to $\epsilon =0$  . First of all, we need to restrict ourselves to special patterns, i.e., $\left(\epsilon ,\alpha \right)$  -good patterns, whereas in [1result applies to all patterns. Secondly, the error term that we obtain in [1is of the form $C{e}^{-ct}\mathbb{P}\left(\left[{\omega }_{{C}_{n}}\right]{\right)}^{\rho }$  , where $\rho >0$  . Of course, the factor $\mathbb{P}\left(\left[{\omega }_{{C}_{n}}\right]{\right)}^{\rho }$  is uniformly exponentially small for Gibbs measures. This is no longer true for $\mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)$  if $\epsilon$  is too large. This is precisely why we need Lemma  1 . Thirdly, a crucial step in the proof of Theorem  1 , which differs slightly from that in [1for the case $\epsilon =0$  , involves Proposition  1 . This explains why we need to restrict to typical configurations in the sense of this result.
Let us close this set of remarks by noticing that $\mathbb{Q}$  has to be a stationary and ergodic measure, but not necessarily Gibbsian. But for later use of Theorem  1 we shall also need the latter assumption, so we already impose it to state the theorem.
The following proposition shows that ” ${\omega }_{{C}_{n}}\in \mathcal{G}\left(\epsilon ,\alpha \right)$  ”, i.e. that a pattern being $\left(\epsilon ,\alpha \right)$  -good, is a typical property.
PROPOSITION 2. Let $\mathbb{Q}$  be a stationary Gibbs measure. Then, if $\alpha <1/2$  and $\epsilon >0$  is small enough, there exists $\nu >0$  such that for all $n\ge 1$
 $\begin{array}{c}\mathbb{Q}\left({\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)\right)>1-{e}^{-\nu {n}^{d}}.\end{array}$ (2.13)
It turns out that if the random field has a non-trivial dependence structure, then the restriction to $\left(\epsilon ,\alpha \right)$  -good patterns is unavoidable. However, in the case of a random field distributed according to a Bernoulli measure, the exponential law  2.11 holds for all approximate patterns. This is expressed by the following theorem.
THEOREM 2. If $\mathbb{P}$  is the Bernoulli measure with $\mathbb{P}\left({\sigma }_{0}=1\right)=1/2$  , then ( 2.11 ) holds without the restriction that ${\omega }_{{C}_{n}}$  is $\left(\epsilon ,\alpha \right)$  -good.

$\text{1}$  As usual, $d\left({A}_{1},{A}_{2}\right):=inf\left\{d\left(x,y\right):x\in {A}_{1},y\in {A}_{2}\right\}$  and $d\left(x,y\right):=||x-y|{|}_{\infty }={max}_{1\le i\le d}|{x}_{i}-{y}_{i}|$  .

3 Approximate waiting-time fluctuations

The purpose of this section is to derive two consequences of Theorem  1 and Proposition  2 . The first one implies a strong law of large numbers for the approximate waiting-time. It was previously derived in [6directly using the mixing property  2.5 .
The second one concerns large deviations of the approximate waiting-time and it is a new result. Given two configurations $\omega ,\sigma$  , the approximate waiting time is ${\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right):={\mathbf{T}}_{\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }}\left(\sigma \right)$  .
PROPOSITION 3. Under the assumptions of Theorem  1 and Proposition  2 , there exists ${\gamma }_{0}>0$  such that for all $\gamma >{\gamma }_{0}$  :
 $\begin{array}{c}-\gamma logn\le log\left({\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right)\mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)\right)\le log\left(log{n}^{\gamma }\right)\end{array}$ (3.1)
$\mathbb{Q}×\mathbb{P}$  -eventually almost surely. In particular ${lim}_{n\to \infty }\frac{1}{|{C}_{n}|}log{\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right)=\mathcal{ℛ}\left(\mathbb{Q},\mathbb{P},\epsilon \right)\mathbb{Q}×\mathbb{P}-\text{almost surely}.$
With Proposition  3 we recover the results of Theorems 26 and 27 in [6. However, there is a substantial difference in conditions on random fields. We have to restrict ourselves to measures $\mathbb{Q}$  which are stationary and ergodic Gibbs measures, while in [6 $\mathbb{Q}$  is only assumed to be stationary and ergodic. On the other hand, we permit Gibbs $\mathbb{P}$  , while in [6 $\mathbb{P}$  must be Bernoulli. The reason for our assumptions on $\mathbb{Q}$  is that Proposition  2 is valid for Gibbs measures. We do not know if it can be extended to more general situations.
Let us also remark that by a basic result in Probability Theory, this strong approximation implies that if a central limit theorem holds for $-\left(1/|{C}_{n}|\right)log\mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)\right)$  , then it holds also for $\left(1/|{C}_{n}|\right)log{\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right)$  . Unfortunately, the former seems to be a difficult issue, except in the iid case. We refer the reader to [6for some results in that direction.
We have the following (partial) large deviation results. We first need the following lemma showing that we can define the generalized conditional $q$  -order Rényi entropy for Gibbs random fields. This was first done in [11for ( $\alpha$  -mixing) stochastic processes ( $d=1$  ) with the difference that here we need to condition on $\left(\epsilon ,\alpha \right)$  -good patterns and use the Gibbs property instead of mixing.
LEMMA 2. Let $\mathbb{Q},\mathbb{P}$  be stationary Gibbs measures and assume that $\alpha <1/2$  and $0\le \epsilon <1$  . Then, for all $q\in \mathbb{R}$  , the following function is well-defined:
 $\begin{array}{c}{\mathcal{ℰ}}_{\epsilon }\left(q\right):={\mathcal{ℰ}}_{\epsilon }\left(q;\mathbb{Q},\mathbb{P}\right)={lim}_{n\to \infty }\frac{1}{|{C}_{n}|}log\int \mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }{\right)}^{q}d{\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}\left(\omega \right).\end{array}$ (3.2)
( ${\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}$  denotes the measure $\mathbb{Q}$  conditioned on the set of good patterns.)
The generalized $q$  -order Rényi entropy should be defined as $-{\mathcal{ℰ}}_{\epsilon }\left(-q\right)/q$  .
We now have the following theorem. By ${a}_{n}\approx {b}_{n}$  we mean that $max\left\{{a}_{n}/{b}_{n},{b}_{n}/{a}_{n}\right\}$  is bounded from above.
THEOREM 3. Let $\mathbb{P}$  be a non-uniformly exponentially $\phi$  -mixing Gibbs measure and $\mathbb{Q}$  a stationary and ergodic Gibbs measure. If $\epsilon >0$  is small enough, then for any ${\alpha }_{0}\le \alpha <1/2$  , we have
 $\begin{array}{c}\int \int \left({\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right){\right)}^{q}d{\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}\left(\omega \right)d\mathbb{P}\left(\sigma \right)\approx \int \mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }{\right)}^{-q}d{\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}\left(\omega \right)\text{if}q\ge -1\end{array}$ (3.3)
and
 $\begin{array}{c}\int \int \left({\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right){\right)}^{q}d{\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}\left(\omega \right)d\mathbb{P}\left(\sigma \right)\approx \int \mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)d{\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}\left(\omega \right)\text{if}q<-1\end{array}$ (3.4)
In particular,
 $\begin{array}{c}{lim}_{n\to \infty }\frac{1}{|{C}_{n}|}log\int \int \left({\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right){\right)}^{q}d{\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}\left(\omega \right)d\mathbb{P}\left(\sigma \right)=\left\{\begin{array}{c}{\mathcal{ℰ}}_{\epsilon }\left(-q\right)\text{if}q\ge -1\\ {\mathcal{ℰ}}_{\epsilon }\left(1\right)\text{if}q<-1.\\ \end{array}\end{array}$ (3.5)
It follows from this theorem that Theorem 4.5.20 in [7applies to large deviations of $\left(\left(1/|{C}_{n}|\right)log{\mathbf{W}}_{n}^{\epsilon }\left(\eta ,\sigma \right){\right)}_{n}$  . We do not know under which conditions the function $q↦{\mathcal{ℰ}}_{\epsilon }\left(q\right)$  is, for example, continuously differentiable for $\epsilon$  small enough. It it were the case, we would get a large deviation principle for $\left(\left(1/|{C}_{n}|\right)log{\mathbf{W}}_{n}^{\epsilon }\left(\eta ,\sigma \right){\right)}_{n}$  with a rate function given by the Legendre transform of ${\mathcal{ℰ}}_{\epsilon }\left(-q\right)$  for $q>-1$  .

4 Proofs

4.1 Proof of Theorem  1

The proof of Theorem  1 is quite similar to the proof of exponential law in [1. We describe briefly the common approach and indicate the differences. We also provide the necessary modifications of the proof.
It is well known that a random variable $Z$  has an exponential distribution if and only if $\mathbb{P}\left(Z>s+t|Z>t\right)=\mathbb{P}\left(Z>s\right)$  or, equivalently, $\mathbb{P}\left(Z>s+t\right)=\mathbb{P}\left(Z>s\right)\mathbb{P}\left(Z>t\right).$  The basic ingredient of the proof in [1was Lemma 4.4 (”Iteration Lemma”). This result establishes that for a pattern ${A}_{n}$  and any finite number of cubes ${C}_{i}\subseteq {\mathbb{Z}}^{d}$  , $i=1,\dots ,k$  , with equal volumes $|{C}_{i}|={\left(\frac{1}{\mathbb{P}\left({A}_{n}\right)}\right)}^{\gamma }$  we have
 $\begin{array}{c}\mathbb{P}\left({A}_{n}{\text{does not occur in}}^{k}{\bigcup }_{i=1}{C}_{i}\right)\approx \mathbb{P}{\left({A}_{n}\text{does not occur in}{C}_{1}\right)}^{k}.\end{array}$ (4.1)
In [1we also observed that the Iteration Lemma remains valid if a pattern ${A}_{n}$  is replaced by the event $\left[{A}_{n}{\right]}^{\epsilon }$  , with $\left[{A}_{n}{\right]}^{\epsilon }$  does not occur in volume $V$  if any pattern ${B}_{n}\in \left[{A}_{n}{\right]}^{\epsilon }$  does not occur in volume $V$  .
Another important ingredient of the proof is the control of the parameter of the exponential distribution. Lemma 4.3 (”The parameter”) in [1concerns non-triviality of the parameter ${\Lambda }_{n}$  , that is, the fact that it is neither null nor infinite. To prove Lemma 4.3, we established a uniform second moment estimate for the number of occurrences of a pattern ${A}_{n}$  in a configuration $\sigma$  restricted to a box that has later to be taken of size $1/\mathbb{P}\left(\left[{A}_{n}\right]\right)$  . It is the proof of this second moment estimate that we have to modify completely. In remark 4.1 in [1, we noticed that if ${E}_{n}\in {\mathcal{ℱ}}_{{C}_{n}}$  are events such that $\mathbb{P}\left({E}_{n}\right)<{e}^{-c{n}^{d}}$  for some $c>0$  , and such that
 $\begin{array}{c}{limsup}_{n\to \infty }{\sum }_{0<|x| (4.2)
then this implies, together with the mixing property  2.5 and the Gibbs property  2.7 , that the desired uniform second moment estimate holds. In turn, this implies the non-triviality of the parameter  2.12 (Lemma 4.3 in [1). Thus, we turn to prove  4.2 when the event ${E}_{n}$  is $\left[{A}_{n}{\right]}^{\epsilon }$  , where ${A}_{n}$  is a good and typical pattern. We assume that patterns ${A}_{n}$  are such that ${\cap }_{n}{A}_{n}=\left\{\sigma \right\}$  , with $\sigma$  chosen from the $\mathbb{Q}$  -measure one set of Proposition  1 and such that ${A}_{n}$  is good in the sense of Definition  3 .
We have to show for patterns ${A}_{n}\in {\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)$  with $\epsilon /\alpha <{\epsilon }_{0}$  , there exists a finite $C=C\left(\epsilon ,\alpha \right)$  such that for all $n$
 $\begin{array}{c}{\sum }_{0<|x|\le n}\frac{\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\cap {\theta }_{x}\left[{A}_{n}{\right]}^{\epsilon }\right)}{\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\right)}\le C\left(\epsilon ,\alpha \right).\end{array}$ (4.3)
First of all, since ${A}_{n}\in {\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)$  (see Definition  3 ), the terms corresponding to $x$  with $|x|<\alpha n$  are equal to $0$  . Therefore we have to estimate the sum
 $\begin{array}{c}{\sum }_{\alpha n\le |x|\le n}\frac{\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\cap {\theta }_{x}\left[{A}_{n}{\right]}^{\epsilon }\right)}{\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\right)}\end{array}$ (4.4)
Note that for $x$  with $|x|\ge \alpha n$  , the intersection $\left({C}_{n}+x\right)\cap {C}_{n}$  is not very large:
$|\left({C}_{n}+x\right)\cap {C}_{n}|\le \left(1-\alpha \right){n}^{d}.$  Note also that $\Delta \left(V,\omega ,{A}_{n}\right)$  denotes the number of differences between $\omega$  and ${A}_{n}$  in the volume $V$  , see  2.1 . Then we can write
 $\begin{array}{c}\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\cap {\theta }_{x}\left[{A}_{n}{\right]}^{\epsilon }\right)=\mathbb{P}\left(\omega :\Delta \left({C}_{n},\omega ,{A}_{n}\right)\le \epsilon {n}^{d}\cap \Delta \left({C}_{n}+x,\omega ,{\theta }_{-x}{A}_{n}\right)\le \epsilon {n}^{d}\right)\end{array}$ (4.5)
where by ${\theta }_{-x}{A}_{n}$  we mean ${\theta }_{-x}{A}_{n}\left(y+x\right)={A}_{n}\left(y\right)$  , $y\in {C}_{n}$  . For the sake of convenience, we simply write $C$  for ${C}_{n}$  and ${C}_{x}$  for ${C}_{n}+x$  in the course of this proof. We also introduce the short-hand notations
 $\begin{array}{ccc}& & {S}_{1}=\Delta \left(C\{C}_{x},\omega ,{A}_{n}\right)\end{array}$
 $\begin{array}{ccc}& & {S}_{2}=\Delta \left(C\cap {C}_{x},\omega ,{A}_{n}\right)\end{array}$
 $\begin{array}{ccc}& & {S}_{3}=\Delta \left(C\cap {C}_{x},\omega ,{\theta }_{-x}{A}_{n}\right)\end{array}$
 $\begin{array}{ccc}& & {S}_{4}=\Delta \left(C\{C}_{x},\omega ,{\theta }_{-x}{A}_{n}\right).\end{array}$ (4.6)
With these notations what we have to estimate
 $\begin{array}{c}{\sum }_{\alpha n\le |x|\le n}\frac{\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\cap {\theta }_{x}\left[{A}_{n}{\right]}^{\epsilon }\right)}{\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\right)}={\sum }_{\alpha n\le |x|\le n}\mathbb{P}\left({S}_{3}+{S}_{4}\le \epsilon {n}^{d}|{S}_{1}+{S}_{2}\le \epsilon {n}^{d}\right).\end{array}$ (4.7)
The following estimate is a corollary of [4and a basic property of a Gibbs measures:
for any configuration $\xi$  :
 $\begin{array}{c}\mathbb{P}\left(\left\{\omega :\Delta \left({V}_{n},\omega ,\sigma \right)\le \epsilon |{V}_{n}|\right\}|{\xi }_{{V}_{n}^{c}}\right)\le exp\left(-|{V}_{n}|\mathcal{ℛ}\left(\epsilon \right)+c|\partial {V}_{n}|\right)\end{array}$ (4.8)
Indeed, the unconditioned statement is proved in [4, and conditioning can at most introduce a term of order $exp\left(c|\partial {V}_{n}|\right)$  .
We proceed as follows
 $\begin{array}{cc}\mathbb{P}\left(\left({S}_{1}+{S}_{2}\right)& \le \epsilon {n}^{d}\cap \left({S}_{3}+{S}_{4}\right)\le \epsilon {n}^{d}\right)\end{array}$
 $\begin{array}{cc}& \le \mathbb{P}\left(\left({S}_{1}+{S}_{2}\right)\le \epsilon {n}^{d}\cap {S}_{4}\le \epsilon {n}^{d}\right)\end{array}$
 $\begin{array}{cc}& \le {sup}_{\xi }\mathbb{P}\left({S}_{4}\le \epsilon {n}^{d}|{\xi }_{{\mathbb{Z}}^{d}\\left({C}_{x}\C\right)}\right)\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\right)\end{array}$
 $\begin{array}{cc}& \le exp\left(-\alpha {n}^{d}\mathcal{ℛ}\left(\frac{\epsilon }{\alpha }\right)+c{n}^{d-1}\right)\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\right).\end{array}$
Therefore ${\sum }_{\alpha n\le |x|\le n}\frac{\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\cap {\theta }_{x}\left[{A}_{n}{\right]}^{\epsilon }\right)}{\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\right)}\le {n}^{d}exp\left(-\alpha {n}^{d}\mathcal{ℛ}\left(\frac{\epsilon }{\alpha }\right)+c{n}^{d-1}\right)=:{C}_{n}\left(\epsilon ,\alpha \right).$  Taking into account that $\epsilon /\alpha <{\epsilon }_{0}$  , and hence $\mathcal{ℛ}\left(\epsilon /\alpha \right)>0$  , we conclude that ${C}_{n}\left(\epsilon ,\alpha \right)\to 0$  as $n\to \infty$  , and hence $C\left(\epsilon ,\alpha \right)={sup}_{n}{C}_{n}\left(\epsilon ,\alpha \right)$  is finite. This finishes the proof.
REMARK 1. The parameters of Theorem  1 depend on the choice of $\epsilon$  and $\alpha$  . The most interesting is the dependence of ${\Lambda }_{1}$  and ${\Lambda }_{2}$  . TheParameter Lemma of [1in fact shows that a uniform choice ${\Lambda }_{2}=2$  suffices. A more interesting question is whether we can give a uniform bound on ${\Lambda }_{1}$  for a large set of $\epsilon$  and $\alpha$  . The present modification of the second moment estimate together with the rest of Lemma 4.3 in [1, which remains unchanged, gives that for some $c$  , dependent on $\epsilon$  alone, the following choice of ${\Lambda }_{1}={\Lambda }_{1}\left(\epsilon ,\alpha \right)$  will suffice ${\Lambda }_{1}=\frac{1}{c+C\left(\epsilon ,\alpha \right)}.$  The rate distortion function $\mathcal{ℛ}$  is a monotonically decreasing function.
Hence, for a fixed $\epsilon >0$  , $\alpha \mathcal{ℛ}\left(\frac{\epsilon }{\alpha }\right)$  is a monotonically increasing function of $\alpha$  , and finally, $C\left(\epsilon ,\alpha \right)$  is monotonically decreasing in $\alpha$  . Therefore, if $\epsilon <{\epsilon }_{0}$  , then for all $\alpha >{\alpha }_{0}:=0.99\frac{\epsilon }{{\epsilon }_{0}}$  ${\Lambda }_{1}\left(\epsilon ,\alpha \right)\ge {\Lambda }_{1}\left(\epsilon ,{\alpha }_{0}\right)>0.$  Therefore, for a fixed $\epsilon >0$  we obtain a uniform (in $\alpha$  ) bound on the parameter ${\Lambda }_{1}$  .

4.2 Proof of Proposition  2

For $\epsilon =0$  we know that most patterns are $\left(0,\alpha \right)$  -good for any $\alpha <1$  . Indeed, it is proved in [1(lemma 5.3) that $\mathbb{Q}\left({\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)\right)\ge 1-{e}^{-{\kappa }^{\prime }{n}^{d}}$  , for some ${\kappa }^{\prime }>0$  .
Let us now argue that for small $\epsilon$  this is still the case. Suppose $\alpha <1/2$  , that is, we are going to consider vectors $x\in {\mathbb{Z}}^{d}$  such that $|x|\le \frac{n}{2}$  . An element $A$  of $\left[{A}_{n}{\right]}^{\epsilon }\cap {\theta }_{x}\left[{A}_{n}{\right]}^{\epsilon }$  satisfies
 $\begin{array}{c}{\sum }_{y\in {C}_{x}\cap C}|A\left(y\right)-A\left(y-x\right)|\le 2\epsilon {n}^{d}.\end{array}$ (4.9)
(Recall that $C={C}_{n}$  and ${C}_{x}={C}_{n}+x$  . This implies that there exists a set ${V}_{n}\subseteq C$  and a disjoint translate ${V}_{n}+z\subseteq C$  such that $|{V}_{n}|>\left(1/2{\right)}^{d}{n}^{d}$  such that ${\theta }_{-z}{A}_{{V}_{n}+z}$  matches with error fraction ${2}^{d+1}\epsilon$  with ${A}_{{V}_{n}}$  , this can be made as small as ${e}^{-\nu {n}^{d}}$  , for some $\nu >0$  , for $\epsilon$  sufficiently small uniformly in ${A}_{{V}_{n}}$  by Lemma  1 . Therefore we obtain that
 $\begin{array}{c}\mathbb{Q}\left(\mathcal{G}\left(\epsilon ,{\alpha }_{0}\right)\right)>1-{e}^{-\nu {n}^{d}}\end{array}$ (4.10)
for all $\alpha <1/2$  and $\epsilon$  small enough.

4.3 Proof of Theorem  2

We consider the case $d=1$  only, because the case $d\ge 2$  is completely analogous.
Start with the particular pattern ${A}_{n}=0\cdots 0$  that we simply denote by ${0}_{n}$  . The difficulty with this ”bad pattern” comes from the fact that the second moment estimate does not apply, because ( 4.2 ) fails. Therefore, we have to prove by other means that there exists $\delta >0$  such that for all $n\in \mathbb{N}$  ,
 $\begin{array}{c}\delta <\mathbb{P}\left({\mathbf{T}}_{\left[{0}_{n}{\right]}^{\epsilon }}>\frac{1}{\mathbb{P}\left(\left[{0}_{n}{\right]}^{\epsilon }\right)}\right)<1-\delta \end{array}$ (4.11)
which would imply the non-triviality of the parameter ${\Lambda }_{n}$  . We will first show that there exists a sequence ${k}_{n}↑\infty$  such that
 $\begin{array}{c}\delta <\mathbb{P}\left({\mathbf{T}}_{\left[{0}_{n}{\right]}^{\epsilon }}>{k}_{n}\right)<1-\delta .\end{array}$ (4.12)
It will then follow easily from the Bernoulli character of $\mathbb{P}$  that ${k}_{n}$  does not depend on the choice of the pattern, i.e., ( 4.12 ) holds with the same ${k}_{n}$  for any pattern ${A}_{n}$  . Then we can apply Theorem  1 for good patterns, and obtain ${k}_{n}=1/\mathbb{P}\left(\left[{A}_{n}{\right]}^{\epsilon }\right)=1/\mathbb{P}\left(\left[{0}_{n}{\right]}^{\epsilon }\right)$  .
We have the following identities:
 $\begin{array}{ccc}\mathbb{P}\left({\mathbf{T}}_{\left[{0}_{n}{\right]}^{\epsilon }}\le {k}_{n}\right)& =& \mathbb{P}\left({}^{{k}_{n}}{min}_{k=0}{\sum }_{i=k}^{k+n}{\omega }_{i}\le n\epsilon \right)\end{array}$
 $\begin{array}{ccc}& =& \mathbb{P}\left({}^{{k}_{n}}{max}_{k=0}{\sum }_{i=k}^{k+n}\left(1-2{\omega }_{i}\right)\ge \left(1-2\epsilon \right)n\right)\end{array}$
 $\begin{array}{ccc}& =& \mathbb{P}\left({}^{{k}_{n}}{max}_{k=0}\left({S}_{k+n}-{S}_{k}\right)\ge \left(1-2\epsilon \right)n\right)\end{array}$ (4.13)
where ${S}_{n}$  is the position of a simple random walk on $\mathbb{Z}$  (with ${S}_{0}=0$  ) after $n$  steps.
By Theorem 7.23 in [12, together with the strong invariance principle [12p. 53, we have
 $\begin{array}{c}{}^{{k}_{n}}{max}_{k=0}\left({S}_{k+n}-{S}_{k}\right)=alog{k}_{n}+bloglog{k}_{n}+c+o\left(1\right)+X\end{array}$ (4.14)
where $X$  is a random variable with a Gumbel distribution. Therefore, if we choose ${k}_{n}$  such that
 $\begin{array}{c}\left(1-2\epsilon \right)n=alog{k}_{n}+bloglog{k}_{n}+c+o\left(1\right)\end{array}$ (4.15)
then ( 4.12 ) holds.
If we now choose any other pattern ${A}_{n}$  , then under $\mathbb{P}$  , ${S}_{n}=2{\sum }_{i=0}^{n}\left(1/2-{\sigma }_{i}-{A}_{n}\left(i\right)\right)$  is again distributed as a simple random walk, so we find the same ${k}_{n}$  , which completes the proof of the theorem.

4.4 Proof of Proposition  3

By using Theorem  1 we immediately get $\mathbb{Q}×\mathbb{P}\left\{\left(\omega ,\sigma \right):log\left({\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right)\mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)\right)>logt\right\}=$  $\int d\mathbb{Q}\left(\omega \right)\mathbb{P}\left\{\sigma :log\left({\mathbf{T}}_{\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }}\left(\sigma \right)\mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)\right)>logt\right\}\le {e}^{-{\Lambda }_{1}t}+C{e}^{-K{n}^{d}}+{\sum }_{{A}_{n}\in {\mathcal{G}}_{n}^{c}\left(\epsilon ,\alpha \right)}\mathbb{Q}\left(\left[{A}_{n}\right]\right).$  Now we choose $t={t}_{n}=log\left({n}^{\gamma }\right)$  with $\gamma >0$  such that ${\Lambda }_{1}\gamma >1$  . This makes the first term in the rhs summable in $n$  . The last one equals the $\mathbb{Q}$  -measure of the complement of ${\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)$  , which is less than ${e}^{-\nu {n}^{d}}$  by Proposition  2 . We thus get the upper bound in  3.1 by an application of the Borel-Cantelli Lemma. Now we turn to prove the lower bound in  3.1 . Proceeding as before, we get $\mathbb{Q}×\mathbb{P}\left\{\left(\omega ,\sigma \right):log\left({\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right)\mathbb{P}\left(\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }\right)\right)\le logt\right\}\le$  $1-{e}^{-{\Lambda }_{2}t}+C{e}^{-K{n}^{d}}+{\sum }_{{A}_{n}\in {\mathcal{G}}_{n}^{c}\left(\epsilon ,\alpha \right)}\mathbb{Q}\left(\left[{A}_{n}\right]\right)\le$  ${\Lambda }_{2}t+C{e}^{-K{n}^{d}}+{e}^{-\nu {n}^{d}}.$  We have used Theorem  1 and Proposition  2 . We now choose $t={t}_{n}={n}^{-\gamma }$  , with $\gamma >1$  , to get a summable upper bound in $n$  for the above probability. An application of Borel-Cantelli Lemma gives the desired result and the proof of the proposition is complete.

4.5 Proof of Lemma  2

We only consider the case $q>0$  leaving the (very similar) proof for the case $q<0$  to the reader. Let ${\mathcal{S}}_{\square }$  be the system of all rectangular boxes of the form $V={\mathbb{Z}}^{d}{\cap }^{d}{\prod }_{k=1}\left[{m}_{k},{n}_{k}\right]\text{with}{m}_{k},{n}_{k}\in \mathbb{Z},{m}_{k}\le {n}_{k}.$  Before proceeding, we have to extend definition  3 somewhat. We will denote by ${\mathcal{G}}_{V}\left(\epsilon ,\alpha \right)$  the set of good patterns supported on $V\in {\mathcal{S}}_{\square }$  . We shall need Proposition  2 which remains valid if one replaces ${\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)$  with ${\mathcal{G}}_{V}\left(\epsilon ,\alpha \right)$  and $n$  by $|V|$  in  2.13 .
We are going to prove that the function $a:{\mathcal{S}}_{\square }\to \left(-\infty ,+\infty \right)$  defined as $a\left(V\right):=-log\int {\mathbb{P}}^{q}\left(\left[{\sigma }_{V}{\right]}^{\epsilon }\right)d{\mathbb{Q}}_{{\mathcal{G}}_{V\cup {V}^{\prime }}\left(\epsilon ,\alpha \right)}\left(\sigma \right)$  satisfies $a\left(V\cup {V}^{\prime }\right)\le a\left(V\right)+a\left({V}^{\prime }\right)+C|\partial \left(V\cup {V}^{\prime }\right)|$  for all $V,{V}^{\prime }\in {\mathcal{S}}_{\square }$  such that $V\cup {V}^{\prime }\in {\mathcal{S}}_{\square }$  and $V\cap {V}^{\prime }=\mathbb{\varnothing }$  , where $C$  is a constant (depends on $q$  ), and where $\partial V$  denotes the boundary of $V$  . Of course, $|\partial \left(V\cup {V}^{\prime }\right)|$  is a surface order correction. If such a property holds (together with $a\left(V+x\right)=a\left(V\right)$  , for all $x\in {\mathbb{Z}}^{d}$  , $V\in {\mathcal{S}}_{\square }$  which is obvious by stationarity of the measure), then a generalised sub-additive lemma, obtained as a combination of a lemma found in [8and another one given in [7, will guarantee that ${lim}_{n\to \infty }\frac{a\left({C}_{n}\right)}{|{C}_{n}|}$  exists, as we wish. For all $q\in \mathbb{R}$  , $V,{V}^{\prime }\in {\mathcal{S}}_{\square }$  such that $V\cup {V}^{\prime }\in {\mathcal{S}}_{\square }$  and $V\cap {V}^{\prime }=\mathbb{\varnothing }$  , we have the following:
${\mathbb{P}}^{q}\left(\left[{\sigma }_{V\cup {V}^{\prime }}{\right]}^{\epsilon }\right)={\left({\sum }_{{\omega }_{V\cup {V}^{\prime }}\in \left[{\sigma }_{V\cup {V}^{\prime }}{\right]}^{\epsilon }}\mathbb{P}\left(\left[{\omega }_{V\cup {V}^{\prime }}\right]\right)\right)}^{q}\ge$  ${e}^{{K}_{1}|\partial \left(V\cup {V}^{\prime }\right)|}{\left({\sum }_{{\omega }_{V\cup {V}^{\prime }}\in \left[{\sigma }_{V\cup {V}^{\prime }}{\right]}^{\epsilon }}\mathbb{P}\left(\left[{\omega }_{V}\right]\right)\mathbb{P}\left({\omega }_{{V}^{\prime }}\right]\right)\right)}^{q}\ge$  ${e}^{{K}_{2}|\partial \left(V\cup {V}^{\prime }\right)|}{\left({\sum }_{{\omega }_{V}\in \left[{\sigma }_{V}{\right]}^{\epsilon }}\mathbb{P}\left(\left[{\omega }_{V}\right]\right)\right)}^{q}{\left({\sum }_{{\omega }_{{V}^{\prime }}\in \left[{\omega }_{{V}^{\prime }}{\right]}^{\epsilon }}\mathbb{P}\left({\omega }_{{V}^{\prime }}\right]\right)\right)}^{q}=$  ${e}^{{K}_{2}|\partial \left(V\cup {V}^{\prime }\right)|}{\mathbb{P}}^{q}\left(\left[{\sigma }_{V\cup {V}^{\prime }}{\right]}^{\epsilon }\right){\mathbb{P}}^{q}\left(\left[{\sigma }_{V\cup {V}^{\prime }}{\right]}^{\epsilon }\right)$  where ${K}_{1},{K}_{2}$  are constants. The first inequality follows from the Gibbs property and the second one is a simple consequence of the Hamming distance property. To complete the proof we again use the Gibbs property to get $\int {\mathbb{P}}^{q}\left(\left[{\sigma }_{V\cup {V}^{\prime }}{\right]}^{\epsilon }\right)d{\mathbb{Q}}_{{\mathcal{G}}_{V\cup {V}^{\prime }}\left(\epsilon ,\alpha \right)}\left(\sigma \right)={\sum }_{{\omega }_{V\cup {V}^{\prime }}\in \left\{0,1{\right\}}^{V\cup {V}^{\prime }}}{\mathbb{P}}^{q}\left(\left[{\omega }_{V\cup {V}^{\prime }}{\right]}^{\epsilon }\right){\mathbb{Q}}_{{\mathcal{G}}_{V\cup {V}^{\prime }}\left(\epsilon ,\alpha \right)}\left(\left[{\omega }_{V\cup {V}^{\prime }}\right]\right)\ge$  $\mathbb{Q}\left({\mathcal{G}}_{V\cup {V}^{\prime }}\left(\epsilon ,\alpha \right)\right){e}^{{K}_{3}|\partial \left(V\cup {V}^{\prime }\right)|}×$  ${\sum }_{{\omega }_{V}\in \left\{0,1{\right\}}^{V}}{\mathbb{P}}^{q}\left(\left[{\omega }_{V}{\right]}^{\epsilon }\right){\mathbb{Q}}_{{\mathcal{G}}_{V\cup {V}^{\prime }}\left(\epsilon ,\alpha \right)}\left(\left[{\omega }_{V}\right]\right)×{\sum }_{{\omega }_{{V}^{\prime }}\in \left\{0,1{\right\}}^{{V}^{\prime }}}{\mathbb{P}}^{q}\left(\left[{\omega }_{{V}^{\prime }}{\right]}^{\epsilon }\right){\mathbb{Q}}_{{\mathcal{G}}_{V\cup {V}^{\prime }}\left(\epsilon ,\alpha \right)}\left(\left[{\omega }_{{V}^{\prime }}\right]\right)\ge$  $\frac{1}{2}{e}^{{K}_{3}|\partial \left(V\cup {V}^{\prime }\right)|}\int {\mathbb{P}}^{q}\left(\left[{\sigma }_{V}{\right]}^{\epsilon }\right)d{\mathbb{Q}}_{{\mathcal{G}}_{V}\left(\epsilon ,\alpha \right)}\left(\sigma \right)×\int {\mathbb{P}}^{q}\left(\left[{\sigma }_{{V}^{\prime }}{\right]}^{\epsilon }\right)d{\mathbb{Q}}_{{\mathcal{G}}_{{V}^{\prime }}\left(\epsilon ,\alpha \right)}\left(\sigma \right)$  where ${K}_{3}$  is a constant. The second inequality is the consequence of Proposition  2 if $|V\cup {V}^{\prime }|$  is large enough. The lemma is proved.

4.6 Proof of Theorem  3

Since the proof of this theorem is very similar to that of Theorem 2.7 in [1, we only sketch it to indicate the little differences between them.
The starting point is of course to write $\int \int \left({\mathbf{W}}_{n}^{\epsilon }\left(\omega ,\sigma \right){\right)}^{q}d{\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}\left(\omega \right)d\mathbb{P}\left(\sigma \right)=\int d{\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}\left(\omega \right)\int {\mathbf{T}}_{\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }}^{q}\left(\sigma \right)d\mathbb{P}\left(\sigma \right).$  Then we can mimic the proof of Theorem 2.7 in [1by using Theorem  1 and the analog of lemma 4.3 in [1, which holds true when ${\mathbf{T}}_{\left[{\omega }_{{C}_{n}}\right]}$  is replaced by ${\mathbf{T}}_{\left[{\omega }_{{C}_{n}}{\right]}^{\epsilon }}$  , provided that ${\omega }_{{C}_{n}}$  be a $\left(\epsilon ,\alpha \right)$  -good pattern (see the beginning of the proof of Theorem  1 ), and $\omega$  be $\mathbb{Q}$  -typical in the sense of Proposition  1 . Notice that we integrate with respect to the conditional measure ${\mathbb{Q}}_{{\mathcal{G}}_{n}\left(\epsilon ,\alpha \right)}$  which takes care of these two properties.
References

1. M. Abadi, J.-R. Chazottes F. Redig and E. Verbitskiy, Exponential distribution for the occurrence of rare patterns in Gibsian random fields, Commun. Math. Phys. 246 no. 2 (2004), 269–294.
2. M. Alzina, W. Szpankowski and A. Grama, 2d-pattern matching, image and video-compression: theory, algorithms and experiments, IEEE Transactions on Image Processing 11 no. 3, (2002), 318-331.
3. T. Berger, Rate Distorsion Theory: A Mathematical Basis for Data Compression. Englewood Cliffs, NJ: Prentice-Hall, 1971.
4. Z. Chi, Conditional large deviation principle for finite state Gibbs random fields. Preprint (2002).
5. A. Dembo, I. Kontoyiannis, The asymptotics of waiting times between stationary processes, allowing distortion, Ann. Appl. Probab. 9 (1999), no. 2, 413–429.
6. A. Dembo, I. Kontoyiannis, Source coding, large deviations, and approximate matching, IEEE Trans. Inform. Th. 48 no. 6 (2002), 1590–1615.
7. A. Dembo, O. Zeitouni, Large deviations techniques and applications. Second edition. Applications of Mathematics (New York) 38. Springer-Verlag, New York, 1998.
8. H.-O. Georgii. Gibbs Measures and Phase Transitions. Walter de Gruyter & Co., Berlin, 1988.
9. X. Guyon. Random Fields on a Network. Modeling, Statistics and Applications, Springer Verlag, New York, Berlin, 1995.
10. I. Kontoyiannis, Pattern matching and lossy data compression on random fields, IEEE Trans. Inform. Th. 49 no. 4 (2003), 1047–1051.
11. T. Luczak, W. Szpankowski, A suboptimal lossy data compression based on approximate pattern matching, IEEE Trans. Inform. Th. 43 no. 5 (1997), 1439–1451.
12. P. Révész, Random Walks in Random and Non-Random Environments, World Scientific, Singapore, New Jersey, London, Hong Kong, (1990).