Criticality in Formal Languages and Statistical Physics∗

We show that the mutual information between two symbols, as a function of the number of symbols between the two, decays exponentially in any probabilistic regular grammar, but can decay like a power law for a context-free grammar. This result about formal languages is closely related to a well-known result in classical statistical mechanics that there are no phase transitions in dimensions fewer than two. It is also related to the emergence of power-law correlations in turbulence and cosmological inflation through recursive generative processes. We elucidate these physics connections and comment on potential applications of our results to machine learning tasks like training artificial recurrent neural networks. Along the way, we introduce a useful quantity which we dub the rational mutual information and discuss generalizations of our claims involving more complicated Bayesian networks.


I. INTRODUCTION
Critical behavior, where long-range correlations decay as a power law with distance, has many important physics applications ranging from phase transitions in condensed matter experiments to turbulence and inflationary fluctuations in our early Universe. It has important applications beyond the traditional purview of physics as well [1][2][3][4][5] including applications to music [4,6], genomics [7,8] and human languages [9][10][11][12].
In Figure I, we plot a statistic that can be applied to all of the above examples: the mutual information between two symbols as a function of the number of symbols in between the two symbols [9]. As discussed in previous works [9,11,13], the plot shows that the number of bits of information provided by a symbol about another drops roughly as a power-law 1 with distance in sequences (defined as the number of symbols between the two symbols of interest) as diverse as the human genome, music by Bach, and text in English and French. Why is this, when so many other correlations in nature instead drop exponentially [17]?
Better understanding the statistical properties of natural languages is interesting not only for geneticists, musicologists and linguists, but also for the machine learn- * Published in Entropy, 19, 299 (2017): http://www.mdpi.com/1099-4300/19/7/299 1 The power law discussed here should not be confused with another famous power law that occurs in natural languages: Zipf's law [14]. Zipf's law implies power law behavior in one-point statistics (in the histogram of word frequencies), whereas we are interested in two-point statistics. In the former case, the power law is in the frequency of words; in the latter case, the power law is in the separation between characters. One can easily cook up sequences which obey Zipf's law but are not critical and do not exhibit a power law in the mutual information. However, there are models of certain physical systems where Zipf's law follows from criticality [15,16].
ing community. Any tasks that involve natural language processing (e.g., data compression, speech-to-text conversion, auto-correction) exploit statistical properties of language, and can all be further improved if we can better understand these properties, even in the context of a toy model of these data sequences. Indeed, the difficulty of automatic natural language processing has been known at least as far back as Turing, whose eponymous test [22] relies on this fact. A tempting explanation is that natural language is something uniquely human. But this is far from a satisfactory one, especially given the recent successes of machines at performing tasks as complex and as "human" as playing Jeopardy! [23], chess [24], Atari games [25] and Go [26]. We will show that computer descriptions of language suffer from a much simpler problem that has involves no talk about meaning or being nonhuman: they tend to get the basic statistical properties wrong.
To illustrate this point, consider Markov models of natural language. From a linguistics point of view, it has been known for decades that such models are fundamentally unsuitable for modeling human language [27]. However, linguistic arguments typically do not produce an observable that can be used to quantitatively falsify any Markovian model of language. Instead, these arguments rely on highly specific knowledge about the data -in this case, an understanding of the language's grammar. This knowledge is non-trivial for a human speaker to acquire, much less an artificial neural network. In contrast, the mutual information is comparatively trivial to observe, requiring no specific knowledge about the data, and it immediately indicates that natural languages would be poorly approximated by a Markov/hidden Markov model as we will demonstrate.
Furthermore, the mutual information decay may offer a partial explanation of the impressive progress that has been made by using deep neural networks for natural language processing (see, e.g., [28][29][30][31][32]). (For recent reviews of deep neural networks, see [33,34]. ) We will see that a key reason that currently popular recurrent neural arXiv:1606.06737v3 [cond-mat.dis-nn] 23  Here the mutual information in bits per symbol is shown as a function of separation d(X, Y ) = |i − j|, where the symbols X and Y are located at positions i and j in the sequence in question, and shaded bands correspond to 1 − σ error bars. The statistics were computed using a sliding window using an estimator for the mutual information detailed in Appendix D. All measured curves are seen to decay roughly as power laws, explaining why they cannot be accurately modeled as Markov processes -for which the mutual information instead plummets exponentially (the example shown has I ∝ e −d/6 ). The measured curves are seen to be qualitatively similar to that of a famous critical system in physics: a 1D slice through a critical 2D Ising model, where the slope is −1/2. The human genome data consists of 177,696,512 base pairs {A, C, T,G} from chromosome 5 from the National Center for Biotechnology  networks with long-short-term memory (LSTM) [35] do much better is that they can replicate critical behavior, but that even they can be further improved, since they can under-predict long-range mutual information.
While motivated by questions about natural languages and other data sequences, we will explore the information-theoretic properties of formal languages. For simplicity, we focus on probabilistic regular grammars and probabilistic context-free grammars (PCFGs). Of course, real-world data sources like English is likely more complex than a context free grammar [36], just as a realworld magnet is more complex than the Ising model. However, these formal languages serve as toy models that capture some aspects of the real data source, and the theoretical techniques we develop for studying these toy models might be adapted to more complex formal languages. Of course, independent of their connection to natural languages, formal languages are also theoretically interesting in their own right and have connections to, e.g., group theory [37]. This paper is organized as follows. In Section II, we show how Markov processes exhibit exponential decay in mutual information with scale; we give a rigorous proof of this and other results in a series of appendices. To enable such proofs, we introduce a convenient quantity that we term rational mutual information, which bounds the mutual information and converges to it in the nearindependence limit. In Section III, we define a subclass of generative grammars and show that they exhibit critical behavior with power law decays. We then generalize our discussion using Bayesian nets and relate our findings to theorems in statistical physics. In Section IV, we discuss our results and explain how LSTM RNNs can reproduce critical behavior by emulating our generative grammar model.

II. MARKOV IMPLIES EXPONENTIAL DECAY
For two discrete random variables X and Y , the following definitions of mutual information are all equivalent: where S ≡ − log B P is the Shannon entropy [38] and D(p(XY )||p(X)p(Y )) is the Kullback-Leibler divergence [39] between the joint probability distribution and the product of the individual marginals. If the base of the logarithm is taken to be B = 2, then I(X, Y ) is measured in bits. The mutual information can be interpreted as how much one variable knows about the other: I(X, Y ) is the reduction in the number of bits needed to specify for X once Y is specified. Equivalently, it is the number of encoding bits saved by using the true joint probability P (X, Y ) instead of approximating X and Y are independent. It is thus a measure of statistical dependencies between X and Y . Although it is more conventional to measure quantities such as the correlation coefficient ρ in statistics and statistical physics, the mutual information is more suitable for generic data, since it does not require that the variables X and Y are numbers or have any algebraic structure, whereas ρ requires that we are able to multiply X · Y and average. Whereas it makes sense to multiply numbers, is meaningless to multiply or average two characters such as "!" and "?".
The rest of this paper is largely a study of the mutual information between two random variables that are realizations of a discrete stochastic process, with some separation τ in time. More concretely, we can think of sequences {X 1 , X 2 , X 3 , · · · } of random variables, where each one might take values from some finite alphabet. For example, if we model English as a discrete stochastic process and take τ = 2, X could represent the first character ("F") in this sentence, whereas Y could represent the third character ("r") in this sentence.
In particular, we start by studying the mutual information function of a Markov process, which is analytically tractable. Let us briefly recapitulate some basic facts about Markov processes (see, e.g., [40] for a pedagogical review). A Markov process is defined by a matrix M of conditional probabilities M ab = P (X t+1 = a|X t = b). Such Markov matrices (also known as stochastic matrices) thus have the properties M ab ≥ 0 and a M ab = 1. They fully specify the dynamics of the model: where p t is a vector with components P (X t = a) that specifies the probability distribution at time t. Let λ i denote the eigenvalues of M, sorted by decreasing magnitude: |λ 1 | ≥ |λ 2 | ≥ |λ 3 |... All Markov matrices have |λ i | ≤ 1, which is why blowup is avoided when equation (2) is iterated, and λ 1 = 1, with the corresponding eigenvector giving a stationary probability distribution µ satisfying Mµ = µ.
In addition, two mild conditions are usually imposed on Markov matrices: M is irreducible, meaning that every state is accessible from every other state (otherwise, we could decompose the Markov process into separate Markov processes). Second, to avoid processes like 1 → 2 → 1 → 2 · · · that will never converge, we take the Markov process to be aperiodic. It is easy to show using the Perron-Frobenius theorem that being irreducible and aperiodic implies |λ 2 | < 1, and therefore that µ is unique.
This section is devoted to the intuition behind the following theorem, whose full proof is given in Appendix A and B. The theorem states roughly that for a Markov process, the mutual information between two points in time t 1 and t 2 decays exponentially for large separation |t 2 − t 1 |: Theorem 1: Let M be a Markov matrix that generates a Markov process. If M is irreducible and aperiodic, then the asymptotic behavior of the mutual information I(t 1 , t 2 ) is exponential decay toward zero for |t 2 − t 1 | 1 with decay timescale log 1 |λ2| , where λ 2 is the second largest eigenvalue of M. If M is reducible or periodic, I can instead decay to a constant; no Markov process whatsoever can produce power-law decay. Suppose M is irreducible and aperiodic so that p t → µ as t → ∞ as mentioned above. This convergence of one-point statistics, e.g., p t , has been well-studied [40]. However, one can also study higher order statistics such as the joint probability distribution for two points in time. For succinctness, let us write P (a, b) ≡ P (X = a, Y = b), where X = X t1 and Y = X t2 and τ ≡ |t 2 − t 1 |. We are interested in the asymptotic situation where the Markov process has converged to its steady state, so the marginal distribution P (a) ≡ b P (a, b) = µ a , independently of time.
If the joint probability distribution approximately factorizes as P (a, b) ≈ µ a µ b for sufficiently large and wellseparated times t 1 and t 2 (as we will soon prove), the mutual information will be small. We can therefore Taylor expand the logarithm from equation (1) around the point P (a, b) = P (a)P (b), giving where we have defined the rational mutual information For comparing the rational mutual information with the usual mutual information, it will be convenient to take e as the base B of the logarithm. We derive useful properties of the rational mutual information in Appendix A.
To mention just one, we note that the rational mutual information is not just asymptotically equal to the mutual information in the limit of near-independence, but it also provides a strict upper bound on it: 0 ≤ I ≤ I R .
Let us without loss of generality take t 2 > t 1 . Then iterating equation (2) τ times gives P (b|a) = (M τ ) ba . Since P (a, b) = P (a)P (b|a), we obtain We will continue the proof by considering the typical case where the eigenvalues of M are all distinct (nondegenerate) and the Markov matrix is irreducible and aperiodic; we will generalize to the other cases (which form a set of measure zero) in Appendix B. Since the eigenvalues are distinct, we can diagonalize M by writing for some invertible matrix B and some a diagonal matrix D whose diagonal elements are the eigenvalues: D ii = λ i . Raising equation (5) to the power τ gives M τ = BD τ B −1 , i.e., Since M is non-degenerate, irreducible and aperiodic, 1 = λ 1 > |λ 2 | > · · · > |λ n |, so all terms except the first in the sum of equation (6) decay exponentially with τ , at a decay rate that grows with c. Defining r = λ 3 /λ 2 , we have where we have made use of the fact that an irreducible and aperiodic Markov process must converge to its stationary distribution for large τ , and we have defined A as the expression in square brackets above, satisfying lim τ →∞ A ba = B b2 B −1 2a . Note that b A ba = 0 in order for M to be properly normalized.
Substituting equation (7) into equation (8) and using the facts that a µ a = 1 and b A ba = 0, we obtain where the term in the last parentheses is of the form In summary, we have shown that an irreducible and aperiodic Markov process with non-degenerate eigenvalues cannot produce critical behavior, because the mutual information decays exponentially. In fact, no Markov processes can, as we show in Appendix B.
To hammer the final nail into the coffin of Markov processes as models of critical behavior, we need to close a final loophole. Their fundamental problem is lack of long-term memory, which can be superficially overcome by redefining the state space to include symbols from the past. For example, if the current state is one of n and we wish the process to depend on the the last τ symbols, we can define an expanded state space consisting of the n τ possible sequences of length τ , and a corresponding n τ × n τ Markov matrix (or an n τ × n table of conditional probabilities for the next symbol given the last τ symbols). Although such a model could fit the curves in Figure I in theory, it cannot in practice, because M requires way more parameters than there are atoms in our observable universe (∼ 10 78 ): even for as few as n = 4 symbols and τ = 1000, the Markov process involves over 4 1000 ∼ 10 602 parameters. Scale-invariance aside, we can also see how Markov processes fail simply by considering the structure of text. To model English well, M would need to correctly close parentheses even if they were opened more than τ = 100 characters ago, requiring an M-matrix with than n 100 parameters, where n > 26 is the number of characters used.
We can significantly generalize Theorem 1 into a theorem about hidden Markov models (HMM). In an HMM, the observed sequence X 1 , · · · , X n is only part of the picture: there are hidden variables Y 1 , · · · , Y n that themselves form a Markov chain. We can think of an HMM as follows: imagine a machine with an internal state space Y that updates itself according to some Markovian dynamics. The internal dynamics are never observed, but at each time-step, it also produces some output Y i → X i that form the sequence which we can observe. These models are quite general and are used to model a wealth of empirical data (see, e.g., [41]).
Theorem 2: Let M be a Markov matrix that generates the transitions between hidden states Y i in an HMM. If M is irreducible and aperiodic, then the asymptotic behavior of the mutual information I(t 1 , t 2 ) is exponential decay toward zero for |t 2 − t 1 | 1 with decay timescale log 1 |λ2| , where λ 2 is the second largest eigenvalue of M. This theorem is a strict generalization of Theorem 1, since given any Markov process M with corresponding matrix M, we can construct an HMM that reproduces the exact statistics of M by using M as the transition matrix between the Y 's and generating X i from Y i by simply setting x i = y i with probability 1.
The proof is very similar in spirit to the proof of Theorem 1, so we will just present a sketch here, leaving a full proof to Appendix B. Let G be the Markov matrix that governs Y i → X i . To compute the joint probability between two random variables X t1 and X t2 , we simply compute the joint probability distribution between Y t1 and Y t2 , which again involves a factor of M τ and then use two factors of G to convert the joint probability on Y t1 , Y t2 to a joint probability on X t1 , X t2 . These additional two factors of G will not change the fact that there is an exponential decay given by M τ .
A simple, intuitive bound from information theory (namely the data processing inequality [40]) gives ). However, Theorem 1 implies that I(Y t1 , Y t2 ) decays exponentially. Hence I(X t1 , X t2 ) must also decay at least as fast as exponentially.
There is a well-known correspondence between so-called probabilistic regular grammars [42] (sometimes referred to as stochastic regular grammars) and HMMs. Given a probabilistic regular grammar, one can generate an HMM that reproduces all statistics and vice versa. Hence, we can also state Theorem 2 as follows: Corollary: No probabilistic regular grammar exhibits criticality.
In the next section, we will show that this statement is not true for context-free grammars.

III. POWER LAWS FROM GENERATIVE GRAMMAR
If computationally feasible Markov processes cannot produce critical behavior, then how do such sequences arise?
In this section, we construct a toy model where sequences exhibit criticality. In the parlance of theoretical linguistics, our language is generated by a stochastic or probabilistic context-free grammar (PCFG) [43][44][45][46]. We will discuss the relationship between our model and a generic PCFG in Section C.

A. A simple recursive grammar model
We can formalize the above considerations by giving production rules for a toy language L over an alphabet A. The language is defined by how a native speaker of L produces sentences: first, she draws one of the |A| characters from some probability distribution µ on A. She then takes this character x 0 and replaces it with q new symbols, drawn from a probability distribution P (b|a), where a ∈ A is the first symbol and b ∈ A is any of the second symbols. This is repeated over and over. After u steps, she has a sentence of length q u . 2 One can ask for the character statistics of the sentence at production step u given the statistics of the sentence at production step u − 1. The character distribution is simply Of course this equation does not imply that the process is a Markov process when the sentences are read left to right. To characterize the statistics as read from left to right, we really want to compute the statistical dependencies within a given sequence, e.g., at fixed u.
To see that the mutual information decays like a power law rather than exponentially with separation, consider two random variables X and Y separated by τ . One can ask how many generations took place between X and the nearest ancestor of X and Y . Typically, this will be about log q τ generations. Hence in the tree graph shown in Figure 2, which illustrates the special case q = 2, the number of edges ∆ between X and Y is about 2 log q τ . Hence by the previous result for Markov processes, we expect an exponential decay of the mutual information in the variable ∆ ∼ 2 log q τ . This means that I(X, Y ) should be of the form where γ is controlled by the second-largest eigenvalue of G, the matrix of conditional probabilities P (b|a). But this exponential decay in ∆ is exactly a power-law decay in τ ! This intuitive argument is transformed into a rigorous proof in Appendix C.

B. Further Generalization: strongly correlated characters in words
In the model we have been describing so far, all nodes emanating from the same parent can be freely permuted Deep dynamics: since they are conditionally independent. In this sense, characters within a newly generated word are uncorrelated. We call models with this property weakly correlated. There are still arbitrarily large correlations between words, but not inside of words. If a weakly correlated grammar allows a → ab, it must allow for a → ba with the same probability. We now wish to relax this property to allow for the strongly-correlated case where variables may not be conditionally independent given the parents. This allows us to take a big step towards modeling realistic languages: in English, god significantly differs in meaning and usage from dog.
In the previous computation, the crucial ingredient was the joint probability P (a, b) = P (X = a, Y = b). Let us start with a seemingly trivial remark. This joint probability can be re-interpreted as a conditional joint probability. Instead of X and Y being random variables at specified sites t 1 and t 2 , we can view them as random variables at randomly chosen locations, conditioned on their locations being t 1 and t 2 . Somewhat pedantically, we write P (a, b) = P (a, b|t 1 , t 2 ). This clarifies the important fact that the only way that P (a, b|t 1 , t 2 ) depends on t 1 and t 2 is via a dependence on ∆(t 1 , t 2 ). Hence P (a, b|t 1 , t 2 ) = P (a, b|∆).
This equation is specific to weakly correlated models and does not hold for generic strongly correlated models.
In computing the mutual information as a function of separation, the relevant quantity is the right hand side of equation (7). The reason is that in practical scenarios, we estimate probabilities by sampling a sequence at fixed separation Now whereas P (a, b|t 1 , t 2 ) will change when strong correlations are introduced, P (a, b|∆) will retain a very similar form. This can be seen as follows: knowledge of the geodesic distance corresponds to knowledge of how high up the closest parent node is in the hierarchy (see Figure  2). Imagine flowing down from the parent node to the leaves. We start with the stationary distribution µ i at the parent node. At the first layer below the parent node (corresponding to a causal distance ∆−2), we get Q rr ≡ P (rr ) = i P S (rr |i)P (i), where the symmetrized probability P S = 1 2 i [P (rr |i) + P (r r|i)] comes into play because knowledge of the fact that r, r are separated by ∆ − 2 gives no information about their order. To continue this process to the second stage and beyond, we only need the matrix G sr = P (s|r) = s P S (ss |r). The reason is that since we only wish to compute the twopoint function at the bottom of the tree, the only place where a three-point function is ever needed is at the very top of the tree, where we need to take a single parent into two children nodes. After that, the computation only involves evolving a child node into a grand-child node, and so forth. Hence the overall two-point probability matrix P (ab|∆) is given by the simple equation As we can see from the above formula, changing to the strongly correlated case essentially reduces to the weakly correlated case where except for a perturbation near the top of the tree. We can think of the generalization as equivalent to the old model except for a different initial condition. We thus expect on intuitive grounds that the model will still exhibit power law decay. This intuition is correct, as we will prove in Appendix C. Our result can be summarized by the following theorem: Theorem 3 There exist probabilistic context free grammars (PCFGs) such that the mutual information I(A, B) between two symbols A and B in the terminal strings of the language decay like d −k , where d is the number of symbols in between A and B.
In Appendix C, we give an explicit formula for k as well as the normalization of the power law for a particular class of grammars.

C. Further Generalization: Bayesian networks and context-free grammars
Just how generic is the scaling behavior of our model? What if the length of the words is not constant? What about more complex dependencies between layers? If we retrace the derivation in the above arguments, it becomes clear that the only key feature of all of our models considered so far is that the rational mutual information decays exponentially with the causal distance ∆: This is true for (hidden) Markov processes and the hierarchical grammar models that we have considered above. So far we have defined ∆ in terms of quantities specific to these models; for a Markov process, ∆ is simply the time separation. Can we define ∆ more generically? In order to do so, let us make a brief aside about Bayesian networks. Formally, a Bayesian net is a directed acyclic graph (DAG), where the vertices are random variables and conditional dependencies are represented by the arrows. Now instead of thinking of X and Y as living at certain times (t 1 , t 2 ), we can think of them as living at vertices (i, j) of the graph.
We define ∆(i, j) as follows. Since the Bayesian net is a DAG, it is equipped with a partial order ≤ on vertices. We write k ≤ l iff there is a path from k to l, in which case we say that k is an ancestor of l. We define the L(k, l) to be the number of edges on the shortest directed path from k to l. Finally, we define the causal distance ∆(i, j) to be It is easy to see that this reduces to our previous definition of ∆ for Markov processes and recursive generative trees (see Figure 2).
Is it true that our exponential decay result from equation (14) holds even for a generic Bayesian net? The answer is yes, under a suitable approximation. The approximation is to ignore long paths in the network when computing the mutual information. In other words, the mutual information tends to be dominated by the shortest paths via a common ancestor, whose length is ∆. This is a generally a reasonable approximation, because these longer paths will give exponentially weaker correlations, so unless the number of paths increases exponentially (or faster) with length, the overall scaling will not change.
With this approximation, we can state a key finding of our theoretical work. Deep models are important because without the extra "dimension" of depth/abstraction, there is no way to construct "shortcuts" between random variables that are separated by large amounts of time with short-range interactions; 1D models will be doomed to exponential decay. Hence the ubiquity of power laws may partially explain the success of applications of deep learning to natural language processing. In fact, this can be seen as the Bayesian net version of the important result in statistical physics that there are no phase transitions in 1D [48,49].
One might object that while the requirement of shortranged interactions is highly motivated in physical systems, it is unclear why this restriction is necessary in the context of natural languages. Our response is that allowing for allowing for a generic interaction between say k-nearest neighbors will increase the number of parameters in the model exponentially with k.
There are close analogies between our deep recursive grammar and more conventional physical systems. For example, according to the emerging standard model of cosmology, there was an early period of cosmological inflation when density fluctuations get getting added on a fixed scale as space itself underwent repeated doublings, combining to produce an excellent approximation to a power-law correlation function. This inflationary process is simply a special case of our deep recursive model (generalized from 1 to 3 dimensions). In this case, the hidden "depth" dimension in our model corresponds to cosmic time, and the time parameter which labels the place in the sequence of interest corresponds to space. A similar physical analogy is turbulence in a fluid, where energy in the form of vortices cascades from large scales to ever smaller scales through a recursive process where larger vortices create smaller ones, leading to a scale-invariant power spectrum. In both the inflation case and the turbulence case, there is a hierarchical generative process akin to our formal language model (except in three dimensions and with continuous variables), whereby parts of the system generate smaller parts in an essentially Markovian fashion.
There is also a close analogy to quantum mechanics: in equation (13) expresses the exponential decay of the mutual information with geodesic distance through the Bayesian network; in quantum mechanics, the correlation function of a many body system decays exponentially with the geodesic distance defined by the tensor network which represents the wavefunction [50].
It is also worth examining our model using techniques from linguistics. A generic PCFG G consists of three ingredients: 1. An alphabet A = A ∪ T which consists of nonterminal symbols A and terminal symbols T .

2.
A set of production rules of the form a → B, where the left hand side a ∈ A is always a single nonterminal character and B is a string consisting of symbols in A.
3. Probabilities associated with each production rule P (a → B), such that for each a ∈ A, B P (a → B) = 1.
It is a remarkable fact that any stochastic-context free grammars can be put in Chomsky normal form [27,45]. This means that given G, there exists some other gram-marḠ such that all the production rules are either of the form a → bc or a → α, where a, b, c ∈ A and α ∈ T and the corresponding languages L(G) = L(Ḡ).
In other words, given some complicated grammar G, we can always find a grammarḠ such that the corresponding statistics of the languages are identical and all the production rules replace a symbol by at most two symbols (at the cost of increasing the number of production rules inḠ).
This formalism allows us to strengthen our claims. Our model with a branching factor q = 2 is precisely the class of all context-free grammars that are generated by the production rules of the form a → bc. While this might naively seem like a very small subset of all possible context-free grammars, the fact that any context-free grammar can be converted into Chomsky normal form shows that our theory deals with a generic context-free grammar, except for the additional step of producing terminal symbols from non-terminal symbols. Starting from a single symbol, the deep dynamics of the PCFG in normal form are given by a strongly-correlated branching process with q = 2 which proceeds for a characteristic number of productions before terminal symbols are produced. Before most symbols have been converted to terminal symbols, our theory applies, and power-law correlations will exist amongst the non-terminal symbols.
To the extent that the terminal symbols that are then produced from non-terminal symbols reflect the correlations of the non-terminal symbols, we expect context-free grammars to be able to produce power law correlations.
From our corollary to Theorem 2, we know that regular grammars cannot exhibit power-law decays in mutual information. Hence context-free grammars are the simplest grammars which support criticality, e.g., they are the lowest in the Chomsky hierarchy that supports criticality. Note that our corollary to Theorem 2 also implies that not all context-free grammars exhibit criticality since regular grammars are a strict subset of context-free grammars. Whether one can formulate an even sharper criterion should be the subject of future work.

IV. DISCUSSION
By introducing a quantity we term rational mutual information, we have proved that hidden Markov processes generically exhibit exponential decay, whereas PCFGs can exhibit power law decays thanks to the "extra dimension" in the network. To the extent that natural languages and other empirical data sources are generated by processes more similar to PCFGs than Markov processes, this explains why they can exhibit power law decays.
We will draw on these lessons to give a semi-heuristic explanation for the success of deep recurrent neural networks widely used for natural language processing, and discuss how mutual information can be used as a tool for validating machine learning algorithms.

A. Connection to Recurrent Neural Networks
While the generative grammar model is appealing from a linguistic perspective, it may appear to have little to do with machine learning algorithms that are implemented in practice. However, as we will now see, this model can in fact be viewed an idealized version of a long-short term memory (LSTM) recurrent neural network (RNN) that is generating ("hallucinating") a sequence. Figure 4 shows that an LSTM RNN can reproduce critical behavior. In this example, we trained an RNN (consisting of three hidden LSTM layers of size 256 as described in [29]) to predict the next character in the 100MB Wikipedia sample known as enwik8 [20]. We then used the LSTM to hallucinate 1 MB of text and measured the mutual information as a function of distance. Figure 4 shows that not only is the resulting mutual information function a rough power law, but it also has a slope that is relatively similar to the original. We can understand this success by considering a simplified model that is less powerful and complex than a full LSTM, but retains some of its core features -such an approach to studying deep neural nets has proved fruitful in the past (e.g., [51]).
The usual implementation of LSTMs consists of multiple cells stacked one on top of each other. Each cell of the LSTM (depicted as a yellow circle in Fig. 3) has a state that is characterized by a matrix of numbers C t and is updated according to the following rule where • denotes element wise multiplication, and D t = D t (C t−1 , x t ) is some function of the input x t from the cell from the layer above (denoted by downward arrows in Figure 3, the details of which do not concern us. Generically, a graph of this picture would look like a rectangular lattice, with each node having an arrow to its right (corresponding to the first term in the above equation), and an arrow from above (corresponding to the second term in the equation). However, if the forget weights f weights decay rapidly with depth (e.g., as we go from the bottom cell to the towards the top) so that the timescales for forgetting grow exponentially, we will show that a reasonable approximation to the dynamics is given by Figure 3.
If we neglect the dependency of D t on C t−1 , the forget gate f t leads to exponential decay of C t−1 e.g., C t = f t • C 0 ; this is how LSTM's forget their past. Note that all operations including exponentiation are performed element-wise in this section only.
In general, a cell will smoothly forget its past over a timescale of ∼ log(1/f ) ≡ τ f . On timescales τ f , the cells are weakly correlated; on timescales τ f , the cells are strongly correlated. Hence a discrete approximation to this above equation is the following: This simple approximation leads us right back to the hierarchical grammar. The first line of the above equation is labeled "remember" in Figure 2 and the second line is what we refer to as "Markov," since the next state depends only on the previous. Since each cell perfectly remembers its pervious state for τ f time-steps, the tree can be reorganized so that it is exactly of the form shown in Figure 3, by omitting nodes which simply copy the previous state. Now supposing that τ f grows exponentially with depth τ f (layer i) ∝ q τ f (layer i + 1), we see that the successive layers become exponentially sparse, which is exactly what happens in our deep grammar model, identifying the parameter q, governing the growth of the forget timescale, with the branching parameter in the deep grammar model. (Compare Figure 2 and Figure 3.)

B. A new diagnostic for machine learning
How can one tell whether an neural network can be further improved? For example, an LSTM RNN similar to the one we used in Figure 3 can predict Wikipedia text with a residual entropy ∼ 1.4 bits/character [29], which is very close to the performance of current state of the art custom compression software -which achieves ∼ 1.3 bits/character [52]. Is that essentially the best compression possible, or can significant improvements be made?
Our results provide an powerful diagnostic for shedding further light on this question: measuring the mutual information as a function of separation between symbols is a computationally efficient way of extracting much more meaningful information about the performance of a model than simply evaluating the loss function, usually given by the conditional entropy H(X t |X t−1 , X t−2 , . . . ). Our deep generative grammar model can be viewed as an idealization of a long-short term memory (LSTM) recurrent neural net, where the "forget weights" drop with depth so that the forget timescales grow exponentially with depth. The graph drawn here is clearly isomorphic to the graph drawn in Figure 1. For each cell, we approximate the usual incremental updating rule by either perfectly remembering the previous state (horizontal arrows) or by ignoring the previous state and determining the cell state by a random rule depending on the node above (vertical arrows).
separation. Without requiring any knowledge about the true entropy of the input text (which is famously NPhard to compute), this figure immediately shows that the LSTM-RNN we trained is performing sub-optimally; it is not able to capture all the long-term dependencies found in the training data.
As a comparison, we also calculated the bigram transition matrix P (X 3 X 4 |X 1 X 2 ) from the data and used it to hallucinate 1 MB of text. Despite the fact that this higher order Markov model needs ∼ 10 3 more parameters than our LSTM-RNN, it captures less than a fifth of the mutual information captured by the LSTM-RNN even at modest separations 5. This phenomenon is related to a classic result in the theory of formal languages: a context free grammar In summary, Figure 3 shows both the successes and shortcomings of machine learning. On the one hand, LSTM-RNN's can capture long-range correlations much more efficiently than Markovian models; on the other hand, they cannot match the two point functions of training data, never mind higher order statistics! One might wonder how the lack of mutual information at large scales for the bigram Markov model is manifested in the hallucinated text. Below we give a line from the Markov hallucinations: This curve shows a sharp exponential decay after a distance of ∼ 10, in agreement with our theoretical predictions. We also measured the mutual information for hallucinated text on a Markov process for bigrams, which still underperforms the LSTMs in long-ranged correlations, despite having ∼ 10 3 more parameters than Despite using many fewer parameters, the LSTM manages to produce a realistic looking URL and is able to close brackets correctly [53], something that the Markov model struggles with.
Although great challenges remain to accurately model natural languages, our results at least allow us to improve on some earlier answers to key questions we sought to address : 1. Why is natural language so hard? The old answer was that language is uniquely human. Our new answer is that at least part of the difficulty is that natural language is a critical system, with long-ranged correlations that are difficult for machines to learn.
2. Why are machines bad at natural languages, and why are they good? The old answer is that Markov models are simply not brain/human-like, whereas neural nets are more brain-like and hence better.
Our new answer is that Markov models or other 1-dimensional models cannot exhibit critical behavior, whereas neural nets and other deep models (where an extra hidden dimension is formed by the layers of the network) are able to exhibit critical behavior.
3. How can we know when machines are bad or good?
The old answer is to compute the loss function.
Our new answer is to also compute the mutual information as a function of separation, which can immediately show how well the model is doing at capturing correlations on different scales.
Future studies could include generalizing our theorems to more complex formal languages such as Merge Grammars.
1. Symmetry: for any two random variables X and Y , I R (X, Y ) = I R (Y, X). The proof is straightforward: 2. Upper bound to mutual information: The logarithm function satisfies ln(1 + x) ≤ x with equality if and only if (iff) x = 0. Therefore setting x = P (a,b) P (a)P (b) − 1 gives Hence the rational mutual information I R ≥ I ln B with equality iff I = 0 (or simply I R ≥ I if we use the natural logarithm base B = e).
3. Non-negativity. It follows from the above inequality that I R (X, Y ) ≥ 0 with equality iff P (a, b) = P (a)P (b), since I R = I = 0 iff P (a, b) = P (a)P (b). Note that this short proof is only possible because of the information inequality I ≥ 0. From the definition of I R , it is only obvious that I R ≥ −1; information theory gives a much tighter bound. Our findings 1-3 can be summarized as follows: where both equalities occur iff p(X, Y ) = p(X)p(Y ). It is impossible for one of the last two relations to be an equality while the other is an inequality.

4.
Generalization. Note that if we view the mutual information as the divergence between two joint probability distributions, we can generalize the notion of rational mutual information to that of rational divergence: where the expectation value is taken with respect to the "true" probability distribution p. This is a special case of what is known in the literature as α-divergence [54].
The α-divergence is itself a special case of so-called f -divergences [55][56][57]: where D R (p||q) corresponds to f (x) = 1 x − 1. Note that as it is written, p could be any probability measure on either a discrete or continuous space. The above results can be trivially modified to show that D R (p||q) ≥ D KL (p||q) and hence D R (p||q) ≥ 0, with equality iff p = q.

The degenerate case
First, we consider the case where the Markov matrix M has degenerate eigenvalues. In this case, we cannot guarantee that M can be diagonalized. However, any complex matrix can be put into Jordan normal form. In Jordan normal form, a matrix is block diagonal, with each d × d block corresponding to an eigenvalue with degeneracy d. These blocks have a particularly simple form, with block i having λ i on the diagonal and ones right above the diagonal. For example, if there are only three distinct eigenvalues and λ 2 is threefold degenerate, the the Jordan form of M would be (B1) Note that the largest eigenvalue is unique and equal to 1 for all irreducible and aperiodic M. In this example, the matrix power M τ is In the general case, raising a matrix to an arbitrary power will yield a matrix which is still block diagonal, with each block being an upper triangular matrix. The important point is that in block i, every entry scales ∝ λ τ i , up to a combinatorial factor. Each combinatorial factor grows only polynomially with τ , with the degree of the polynomials in the ith block bounded by the multiplicity of λ i , minus one.
Using this Jordan decomposition, we can replicate equation (7) and write There are two cases, depending on whether the second eigenvalue λ 2 is degenerate or not. If not, then the equation still holds, since for i ≥ 3, (λ i /λ 2 ) τ decays faster than any polynomial of finite degree. On the other hand, if the second eigenvalue is degenerate with multiplicity m 2 , we instead define A with the combinatorial factor removed: If m 2 = 1, this definition simply reduces to the previous definition of A. With this definition, Hence in the most general case, the mutual information decays like a polynomial P(τ )e −γτ , where γ = 2 ln 1 λ2 . The polynomial is non-constant if and only if the second largest eigenvalue is degenerate. Note that even in this case, the mutual information decays exponentially in the sense that it is possible to bound the mutual information by an exponential.

The reducible case
Now let us generalize to the case where the Markov process is reducible. A general Markov state space can be partitioned into m subsets, where elements in the same partition communicate with each other: it is possible to transition from i → j and j → i for i, j ∈ S i .
In general, the set of partitions will be a finite directed acyclic graph (DAG), where the arrows of the DAG are inherited from the Markov chain. Since the DAG is finite, after some finite amount of time, almost all the probability will be concentrated in the "final" partitions that have no outgoing arrows and almost no probability will be in the "transient" partitions. Since the statistics of the chain that we are interested are determined by running the chain for infinite time, they are insensitive to transient behavior, and hence we can ignore all but the final partitions. (The mutual information at fixed separation is still determined by averaging over all (infinite) time steps.) Consider the case where the initial probability distribution only has support on one of the S i . Since states in S j = S i will never be accessed, the Markov process (with this initial condition) is identical to an irreducible Markov process on S i . Our previous results imply that the mutual information will exponentially decay to zero.
Let us define the random variable Z = f (X), where f (x ∈ S i ) = S i . For a general initial condition, the total probability within each set S i is independent of time. This means that the entropy H(Z) is independent of time. Using the fact that H(Z|X) = H(Y |X) = 0, one can show that where I(X, Y |Z) = H(X|Z) − H(Y |X, Z) is the conditional mutual information. Our previous results then imply that the conditional mutual information decays exponentially, whereas the second term H(Z) ≤ log m is constant. In the language of statistical physics, this is an example of topological order which leads to constant terms in the correlation functions; here, the Markov graph of M is disconnected, so there are m degenerate equilibrium states.

The periodic case
If a Markov process is periodic, one can further decompose each final partition. It is easy to check that the period of each element in a partition must be constant throughout the partition. It follows that each final partition S i can be decomposed into cyclic classes S i1 , S i2 , · · · , S id , where d is the period of the elements in the partition in S i . The arguments in the previous section with f (x ∈ S ik ) = S ik then show that the mutual information again has two terms, one of which exponentially decays, the other of which is constant.

The n > 1 case
The following proof holds only for order n = 1 Markov processes, but we can easily extend the results for arbitrary n. Any n = 2 Markov process can be converted into an n = 1 Markov process on pairs of letters X 1 X 2 . Hence our proof shows that I(X 1 X 2 , Y 1 Y 2 ) decays exponentially. But for any random variables X, Y , the data processing inequality [40] states that I(X, g(Y )) ≤ I(X, Y ), where g is an arbitrary function of Y . Letting g(Y 1 Y 2 ) = Y 1 , and then permuting and applying g(X 1 , X 2 ) = X 1 gives Hence, we see that I(X 1 , Y 1 ) must exponentially decay. The preceding remarks can be easily formalized into a proof for an arbitrary Markov process by induction on n.

The detailed balance case
This asymptotic relation can be strengthened for a subclass of Markov processes which obey a condition known as detailed balance. This subclass arises naturally in the study of statistical physics [58]. For our purposes, this simply means that there exist some real numbers K m and a symmetric matrix S ab = S ba such that Let us note the following facts. (1) The matrix power is simply (M τ ) ab = e Ka/2 (S τ ) ab e −K b /2 . (2) By the spectral theorem, we can diagonalize S into an orthonormal basis of eigenvectors, which we label as v (or sometimes w), e.g., Sv = λ i v and v · w = δ vw . Notice that (3) µ a = 1 Z e Ka is an eigenvector with eigenvalue 1, and hence is the stationary state: The previous facts then let us finish the calculation: Now using the fact that ||A|| 2 = tr A T A and is therefore invariant under an orthogonal change of basis, we find that Since the λ i 's are both the eigenvalues of M and S, and since M is irreducible and aperiodic, there is exactly one eigenvalue λ 1 = 1, and all other eigenvalues are less than one. Altogether, Hence one can easily estimate the asymptotic behavior of the mutual information if one has knowledge of the spectrum of M . We see that the mutual information exponentially decays, with a decay scale time-scale given by the second largest eigenvalue λ 2 : (B15)

Hidden Markov Model
In this subsection, we generalize our findings to hidden Markov models and present a proof of Theorem 2. If we have a Bayesian network of the form W ← X → X → Y → Z, one can show that I(W, Z) ≤ I(X, Y ) using arguments similar to the proof of the data processing inequality. Hence if I(X, Y ) decays exponentially, I(W, Z) should also decay exponentially. In what follows, we will show this in greater detail.
Based on the considerations in the main body of the text, the joint probability distribution between two visible states X t1 , X t2 is given by where the term in brackets would have been there in an ordinary Markov model and the two new factors of G are the result of the generalization. Note that as before, µ is the stationary state corresponding to M. We will only consider the typical case where M is aperiodic, irreducible, and non-degenerate; once we have this case, the other cases can be easily treated by mimicking our above proof for or ordinary Markov processes. Using equation (7) and defining g = Mµ gives Plugging this in to our definition of rational mutual information gives where we have used the facts that i G ij = 1, i A ij = 0, and as before C is asymptotically constant. This shows that I R ∝ λ 2τ 2 exponentially decays.
In this appendix, we prove that the rational mutual information decays like a power law for a sub-class of generative grammars. We proceed by mimicking the strategy employed in the above appendix. Let G be the linear operator associated with the matrix P b|a , the probability that a node takes the value b given that the parent node has value b. We will assume that G is irreducible and aperiodic, with no degeneracies. From the above discussion, we see that removing the degeneracy assumption does not qualitatively change things; one simply replaces the procedure of diagonalizing G with putting G in Jordan normal form.
Let us start with the weakly correlated case. In this case, since as we have discussed in the main text, the parent node has the stationary distribution µ and G ∆/2 give the conditional probabilities from transitioning from the parent node to the nodes at the bottom of the tree that we are interested in. We now employ our favorite trick of diagonalizing G and then writing which gives where we have defined = λ ∆/2 2 . Now note that r A ar µ r = 0, since µ is an eigenvector with eigenvalue 1 of G ∆/2 . Hence this simplifies the above to just From the definition of rational mutual information, and employing the fact that i A ij = 0 gives where N ab ≡ (µ a µ b ) −1/2 r µ r A ar A br is a symmetric matrix and || · || denotes the Frobenius norm. Hence Let us now generalize to the strongly correlated case. As discussed in the text, the joint probability is modified to where Q is some symmetric matrix which satisfies r Q rs = µ s . We now employ our favorite trick of diagonalizing G and then writing where ≡ λ . This gives Now defining the symmetric matrices R ab ≡ rs Q rs A ar A bs ≡ (µ a µ b ) 1/2 N ab , and noting that a R ab = 0, we have which gives In either the strongly or the weakly correlated case, note that N is asymptotically constant. We can write the second largest eigenvalue |λ 2 | 2 = q −k2/2 , where q is the branching factor, Behold the glorious power law! We note that the normalization C must be a function of the form C = m 2 f (λ 2 , q), where m 2 is the multiplicity of the eigenvalue λ 2 . We evaluate this normalization in the next section.
As before, this result can be sharpened if we assume that G satisfies detailed balance G mn = e Km/2 S mn e −Kn/2 where S is a symmetric matrix and K n are just numbers. Let us only consider the weakly correlated case. By the spectral theorem, we diagonalize S into an orthonormal basis of eigenvectors v. As before, G and S share the same eigenvalues. Proceeding, where Z is a constant that ensures that P is properly normalized. Let us move full steam ahead to compute the rational mutual information: ab P (a, b) 2 P (a)P (b) This is just the Frobenius norm of the symmetric matrix H ≡ v λ ∆ v v a v b ! The eigenvalues of the matrix can be read off, so we have Hence we have computed the rational mutual information exactly as a function of ∆.In the next section, we use this result to compute the mutual information as a function of separation |i − j|, which will lead to a precise evaluation of the normalization constant C in the equation

Detailed evaluation of the normalization
For simplicity, we specialize to the case q = 2 although our results can surely be extended to q > 2. Define δ = ∆/2 and d = |i − j|. We wish to compute the expected value of I R conditioned on knowledge of d. By Bayes rule, p(δ|d) ∝ p(d|δ)p(δ). Now p(d|δ) is given by a triangle distribution with mean 2 δ−1 and compact support (0, 2 δ ). On the other hand, p(δ) ∝ 2 δ for δ ≤ δ max and p(δ) = 0 for δ ≤ 0 or δ > δ max . This new constant δ max serves two purposes. First, it can be thought of as a way to regulate the probability distribution p(δ) so that it is normalizable; at the end of the calculation we formally take δ max → ∞ without obstruction. Second, if we are interested in empirically sampling the mutual information, we cannot generate an infinite string, so setting δ max to a finite value accounts for the fact that our generated string may be finite. : Decay of rational mutual information with separation for a binary sequence from a numerical simulation with probabilities p(0|0) = p(1|1) = 0.9 and a branching factor q = 2. The blue curve is not a fit to the simulated data but rather an analytic calculation. The smooth power law displayed on the left is what is predicted by our "continuum" approximation. The very small discrepancies (right) are not random but are fully accounted for by more involved exact calculations with discrete sums.
We now assume d 1 so that we can swap discrete sums with integrals. We can then compute the conditional expectation value of 2 −k2δ . This yields or equivalently, It turns out it is also possible to compute the answer without making any approximations with integrals: The resulting predictions are compared in figure Figure 5.
Appendix D: Estimating (rational) mutual information from empirical data Estimating mutual information or rational mutual information from empirical data is fraught with subtleties.
It is well known that a naive estimate of the Shannon entropy obtainedŜ = − K i=1 Ni N log Ni N is biased, generally underestimating the true entropy from finite samples. For example, We use the estimator advocated by Grassberger [59]: where ψ(x) is the digamma function, N = N i , and K is the number of characters in the alphabet. The mutual information estimator can then be estimated bŷ I(X, Y ) =Ŝ(X) +Ŝ(Y ) −Ŝ(X, Y ). The variance of this estimator is then the sum of the variances var(Î) = varEnt(X) + varEnt(Y ) + varEnt(X, Y ), where the varEntropy is defined as varEnt(X) = var (− log p(X), ) where we can again replace logarithms with the digamma function ψ. The uncertainty after N measurements is then ≈ var(Î)/N .
To compare our theoretical results with experiment in Fig. 4, we must measure the rational mutual information for a binary sequence from (simulated) data. For a binary sequence with covariance coefficient ρ(X, Y ) = P (1, 1) − P (1) 2 , the rational mutual information is This was essentially calculated in [60] by considering the limit where the covariance coefficient is small ρ 1. In their paper, there is an erroneous factor of 2. To estimate covariance ρ(d) as a function of d (sometimes confusingly referred to as the correlation function), we use the unbiased estimator for a data sequence {x 1 , x 2 , · · · x n }: However, it is important to note that estimating the covariance function ρ by averaging and then squaring will generically yield a biased estimate; we circumvent this by simply estimating I R (X, Y ) 1/2 ∝ ρ(X, Y ).