June 26, 2026
We develop a quantitative theory of the Random Language Model (RLM), an ensemble of stochastic context-free grammars, in a scaling limit where the number of hidden symbols \(N \to \infty\) while the grammar temperature \(\tilde{\epsilon}_d\to 0\) at fixed \(x = \tilde{\epsilon}_d\log N\). In this limit, the model admits a controlled description based on a large-deviation principle over rule-usage patterns. A semi-annealed approximation maps the problem to a class of Random Energy Models with nontrivial combinatorics.
We show that the RLM exhibits a condensation transition at a critical value \(x_c=1/8\), below which rule usage concentrates and language statistics acquire a nontrivial dependence on corpus length. A second characteristic scale at \(x=1/2\) marks the onset of entropy reduction from its maximal value. Across these regimes, we derive explicit scaling laws for the number of distinct rules, entropy, and related observables, identifying distinct scaling, saturation, and critical regimes controlled by the interplay of grammar size, corpus length, and temperature.
The theory resolves previous ambiguities regarding the existence of a thermodynamic transition and explains the slow approach to the large-\(N\) limit as a consequence of the dependence on \(\log N\). It further provides a unified framework in which universal statistical properties of language emerge from typical realizations of generative grammars, with implications for both natural language statistics and the behavior of large language models.
Despite its perennial interest, the quantitative study of language has focused on a small number of observables, among them: (1) the distribution of word rarity in a text, characterized by Zipf’s law and Heaps’ law [1], [2]; and (2) the entropy rate of text [3]–[5]. By now these are empirically well characterized: Zipf’s law states that when sorted by decreasing frequency in a text, the \(k^{th}\) word will have relative frequency \(1/k^\alpha\) with \(\alpha \approx 1\); Heaps’ law states that in a text of length \(\ell\) the number of unique words scales as \(n_* \sim \ell^{b}\) with \(b \approx 0.5\); and the entropy rate per character in English is \(\approx 1.3\). The mild language-dependence of these quantities has also been characterized [6]–[10]. They provide a nontrivial but coarse, low-dimensional view of language structure.
The simple universal character of these results stands in contrast to classical linguistic studies, which emphasize the structural diversity of syntax across natural languages, as developed in generative grammar and related traditions [11]–[14]. While these approaches provide highly refined formal descriptions of grammatical structure, they do not, in general, yield predictions for coarse-grained observables such as frequency distributions or entropy rates. Partial bridges exist, for example in dependency and probabilistic grammars [15], [16], but a unified quantitative framework linking syntactic structure to statistical regularities remains underdeveloped.
A conceptual bridge between statistical and generative approaches is obtained by considering an ensemble of languages, where the definition of the ensemble encodes the structural constraints, while the behavior of typical languages can give rise to universal laws. Such an ensemble was proposed in [17] and dubbed the Random Language Model (RLM), taking the context-free structure of natural and computer languages as the basis for the ensemble. A language is created from a stochastic context-free grammar, which is a generative model for sequences with hidden tree structure, called derivations. Each grammar generates an infinite set of possible sequences, and assigns to each sequence a probability \(P\) of occurrence. The dynamic range of probabilities is controlled by two temperature-like parameters, \(\tilde{\epsilon}_d\) and \(\tilde{\epsilon}_s\), which control the variability of grammar rules and symbol emissions, respectively. At large \(\tilde{\epsilon}_d,\tilde{\epsilon}_s\) the output distribution approaches maximal entropy and exhibits little structure, while at small \(\tilde{\epsilon}_d,\tilde{\epsilon}_s\) it becomes highly constrained.
Context-free grammar-based codes are universal [18], in that sequences from any stationary and ergodic source can be compressed by a grammar-based code whose compression rate approaches the entropy rate of the source. This justifies the use of context-free grammars as a parametrization of sequence generators. In particular, they span the entire range from trivial output with maximal entropy to arbitrarily constrained sequences of vanishing entropy.
Ref. [17] showed that typical languages show a strong dependence on \(\tilde{\epsilon}_d\) such that the entropy rate of sequences is nearly maximal above a certain value \(\tilde{\epsilon}_d>\tilde{\epsilon}_d{}_*\) while it drops precipitously below \(\tilde{\epsilon}_d{}_*\). A spin-glass order parameter was found to be consistent with this interpretation, although a controlled theoretical description was not obtained, and a single critical temperature was not identified.
Ref. [19] showed that the RLM has a field-theoretic representation, which was used to build a quantitative description of the high-temperature phase in the replica-symmetric approximation [20]. While this could explain the spin-glass order parameter of [17], it ultimately did not lead to a complete description of the low-temperature phase.
In Ref. [21], the existence of a true thermodynamic phase transition in the RLM was questioned. By analogy with Heisenberg spin glasses, the Binder cumulant was used to diagnose a phase transition; the results suggest that a true thermodynamic phase transition could exist only in the limit where the number of hidden symbols \(N\) diverges. This appears to be in tension with the empirical results of [17], where measured properties at different \(N\) from \(N=10\) to \(N=40\) (and up to \(N=80\) in [22]) showed a quantitative dependence on \(N\) that could be collapsed. These correspond to grammar sizes \(N^3\) from \(1000\) to \(64000\). Such finite-size scaling suggests that these \(N\) are already in a scaling regime not qualitatively different from \(N \to \infty\).
Here, we resolve this apparent paradox by a detailed theoretical and empirical study of the RLM, in a new approximation that is applicable to the low-temperature phase. This semi-annealed approximation considers an annealed average over grammar weights, but over finite grammars and derivations. It respects both the wide dynamic range of the low-temperature phase and the finiteness of \(N\) (and trees) in any putative application of the model. The essential step is to consider a double scaling limit in which \(N \to \infty\) while \(\tilde{\epsilon}_d\to 0\) such that \(x=\tilde{\epsilon}_d\log N\) is finite; this maintains the ability to span the full range of entropy while enabling analytical control in the large \(N\) limit. We will show that the RLM inherits critical behavior from the Random Energy Model (REM) of Derrida [23], [24], but enriched by the tree structure of derivations. There is a critical condensation transition at \(x_c=1/8\), below which the entropy rate is \(\mathcal{O}(1)\) in the large \(N\) limit, while it is \(\mathcal{O}(\log N)\) above. It will follow in the course of the theory that the large \(N\) behavior is primarily controlled by \(\log N\), explaining the slowness of approach to the putative thermodynamic limit observed in numerical studies.
We show that Heaps’ law is predicted by the theory, and that the dependence of entropy (or code length) on context length is also captured by the theory. Overall, we show that universal statistical properties of language emerge from a minimal ensemble of generative grammars governed by a well-defined condensation transition.
A brief report of this theory has been presented in [25].
The outline of this paper is as follows. First, we recall the field-theoretic representation of the RLM, originally presented in [19]. Then, we show how a simple ‘paramagnetic’ ansatz for solutions can be consistent if and only if the Law of Large Numbers (LLN) holds for various sums. These sums take the form of partition sums of Random Energy Models, establishing the basic connection between the two models. Like the REM, the breakdown of the LLN depends upon the variance of the corresponding energies, and there is competition between the number of elements in the sum and the variances. It will become transparent that the analog of the thermodynamic limit in the REM is exactly the scaling limit mentioned above, along with its extension to the surface layer.
This discussion motivates the semi-annealed approximation that follows. We rewrite the RLM partition function in terms of excitations called ‘patterns,’ which are analogous to occupation numbers in statistical mechanics. We present the combinatorics of counting derivations, both for small and large corpora, and including both the tree structure and the surface layer. We then derive the most likely pattern and compare this prediction directly with numerics, finding good agreement. The theory shows that the number of unique hidden rules \(p\) used in a corpus is a key observable. We present numerical results of \(p\) versus \(x\), \(N\), and corpus length \(\ell\), finding various scaling laws, which are characterized. Then we analytically find the leading-order behavior of \(p\) in all regimes, showing that all numerical results are accounted for within the approximation.
We then use these results to derive the thermodynamics of the model, in particular the energy and entropy. Theoretical results are in excellent agreement with numerics, and the energy shows a clear change in scaling at a critical \(x\) that tends to \(x_c=1/8\) in the scaling limit. Finally, we apply the theory both to natural language and Large Language Models (LLMs). We show how the theory reproduces Heaps’ law, in quantitative agreement with previous work, and the dependence of entropy on context length observed in LLMs.
The Random Language Model is defined as follows [17]. A stochastic context-free grammar [11], [26], [27] is a generative model for sequences with a hidden tree structure; a grammar in Chomsky normal form defines a weight over binary trees, called derivations, in which the leaves of the tree represent the observed sequence; Fig. 1 shows an example derivation of English phrase structure. The grammar \(\mathcal{G}\) is defined by two objects \(\mathcal{G}= \{M_{abc}, O_{aB} \}\) over sets of hidden ("nonterminal") symbols indexed by \(a=1,\ldots,N\) and observable ("terminal") symbols indexed by \(B=1,\ldots,T\) such that the rule \(a \to bc\) has the weight \(M_{abc}\) and the rule \(a \to B\) has the weight \(O_{aB}\). Conventionally, each derivation begins with a distinguished symbol, called the start symbol, which is the root. The model of [17] defines weights for tree topologies based on a branching process with emission probability \(p_E\), so that a binary tree \(\mathcal{T}\) with \(\ell\) leaves has a probability \(\mathbb{P}(\mathcal{T}| \mathcal{G}) = W_{tree}(\mathcal{T})/Z_{tree}\) with \(W_{tree}(\mathcal{T}) = p_E^{\ell} (1-p_E)^{2\ell-1}\). The ‘emission probability’ \(p_E\) controls the size of trees 1. The tree is defined by a set of interior branches \(\Omega_\mathcal{T}\) and surface branches \(\partial\Omega_\mathcal{T}\). The emission probability \(p_E\) needs to be tuned close to \(1/2^+\) to obtain large trees; if we write \(p_E = 1/2 + \varepsilon\) then the distribution of tree lengths is given by \(\mathbb{P}(\ell) \propto e^{-\ell/\xi}/\ell^{3/2}\) with \(\xi = 1/(4\varepsilon^2)\).
Given the topology of a tree, \(\mathcal{G}\) defines a weight for each derivation on it. Writing the hidden symbols of a particular derivation as \(\{\sigma_i\}\) and the observable symbols as \(\{ o_t \}\) the weight is \[\begin{align} \label{w1} W( \{\sigma_i, o_t \} | \mathcal{T}, \mathcal{G}) = \prod_{\alpha \in \Omega_\mathcal{T}} M_{\sigma_{\alpha_1} \sigma_{\alpha_2} \sigma_{\alpha_3} } \prod_{\alpha \in \partial\Omega_\mathcal{T}} O_{\sigma_{\alpha_1} o_{\alpha_2} }, \end{align}\tag{1}\] where each \(\alpha=(\alpha_1,\alpha_2,\alpha_3)\) is a factor in the order \(\sigma_{\alpha_1} \to \sigma_{\alpha_2} \sigma_{\alpha_3}\). We can write the weight in a Boltzmann form \[\begin{align} \label{w2} W( \{\sigma_i, o_t \} | \mathcal{T}, \mathcal{G}) = e^{-E}, \end{align}\tag{2}\] with \[\begin{align} E = - \sum_{\alpha \in \Omega_\mathcal{T}} \log M_{\sigma_{\alpha_1} \sigma_{\alpha_2} \sigma_{\alpha_3} } -\sum_{\alpha \in \partial\Omega_\mathcal{T}} \log O_{\sigma_{\alpha_1} o_{\alpha_2} } \end{align}\] We can write this as \[\begin{align} E & = -\sum_{a,b,c} \pi_{abc}(\sigma; \mathcal{T}) \log M_{abc} - \sum_{a,B} \rho_{aB}(\sigma,o; \mathcal{T}) \log O_{aB} \end{align}\] where the usage frequencies are \[\begin{align} \pi_{abc}(\sigma; \mathcal{T}) & = \sum_{\alpha \in \Omega_{\mathcal{T}}} \delta_{\sigma_{\alpha_1},a} \delta_{\sigma_{\alpha_2},b} \delta_{\sigma_{\alpha_3},c} \\ \rho_{aB}(\sigma,o; \mathcal{T}) & = \sum_{\alpha \in \partial\Omega_{\mathcal{T}}} \delta_{\sigma_{\alpha_1},a} \delta_{o_{\alpha_2},B} \end{align}\] For a given derivation, these quantities count how many times each grammar rule is used. The grammar can be written as \(\log M_{abc} = \log \overline{M} + \log M_{abc}/\overline{M} \equiv \log \overline{M} + X_{abc}\) and similarly \(\log O_{aB} = \log \overline{O} + Y_{aB}\). Using the sum rules \(\sum_{a,b,c} \pi_{abc} = |\Omega| = \ell - 1\) and \(\sum_{a,B} \rho_{aB} = |\partial\Omega| = \ell\) we can extract a mean contribution, independent of the configuration \(\sigma, o\). Thus \[\begin{align} E & = E_0 -\sum_{a,b,c} \pi_{abc}(\sigma; \mathcal{T}) X_{abc} - \sum_{a,B} \rho_{aB}(\sigma,o; \mathcal{T}) Y_{aB} \end{align}\] with \(E_0 = -(\ell-1) \log \overline{M} - \ell \log \overline{O}\). The partition function of derivations on a fixed tree and with a fixed grammar is \[\begin{align} Z(\mathcal{T},\mathcal{G}) = \sum_{\{ \sigma_i, o_t \} } W( \{\sigma_i, o_t \} | \mathcal{T}, \mathcal{G}) . \end{align}\] The above definitions are for a single grammar \(\mathcal{G}\). The Random Language Model is an ensemble of grammars in which the \(X_{abc}\) and \(Y_{aB}\) are drawn from a Gaussian distribution, iid for each rule, with variance \(1/(2\tilde{\epsilon}_d)\) and \(1/(2\tilde{\epsilon}_s)\) for \(X\) and \(Y\), respectively.
Here we recall the construction of [19], which builds a field theoretic representation of the RLM. We will use this field theory to show the breakdown of simple ‘paramagnetic’ saddle-point solutions, governed by the Random Energy Model. This discussion parallels that of [25], with the difference that here we use the formalism of [19], which will also be employed in later sections, while in [25] the conventional belief propagation equations [28] on a fixed tree were used 2. In a first reading, this section can be skipped.
The main idea of the construction in [19] is to find a field theory whose Feynman diagrams generate exactly the syntax trees of the RLM, with the correct weights. Such a field theory will operate on a fixed grammar \(\mathcal{G}= \{M_{abc}, O_{aB} \}\) and thus be a disordered field theory. Note that the later sections of [19], which solve the model in the replica-symmetric approximation, contain a subtle error corrected in [29]. This does not affect the following discussion.
Fix a stochastic context-free grammar in Chomsky normal form \(\mathcal{G}= \{M_{abc}, O_{aB} \}\). We consider the partition function of \(m\) sentences with total length \(\ell\), which can be written as \[\begin{align} \mathbb{Z}(\mathcal{G}; m, \ell) = \sum_{\{\ell_i\}, \sum_{i=1}^m \ell_i = \ell} \prod_i \mathbb{Z}(\mathcal{G}; \ell_i) , \end{align}\] where the tree-averaged partition function for a single sentence of length \(\ell_i\) is \[\begin{align} \mathbb{Z}(\mathcal{G}; \ell_i) = \sum_{\mathcal{T}, \ell(\mathcal{T})=\ell_i} \mathbb{P}(\mathcal{T}| \mathcal{G}) Z(\mathcal{T},\mathcal{G}) . \end{align}\] We have \(\sum_{i} |\partial\Omega_{\mathcal{T}_i}| = \sum \ell_i = \ell\), and \(\sum_i |\Omega_{\mathcal{T}_i}| = \sum (2\ell_i-1) = 2\ell - m\), so that \(\mathbb{Z}_{tree} \equiv \prod_i \mathbb{P}(\mathcal{T}_i|\mathcal{G})=p_E^{\ell} (1-p_E)^{2\ell-m} Z_{tree}^{-m}\) just gives a trivial factor.
The first result of [19] is that \(\mathbb{Z}(\mathcal{G}; m,\ell)\) has a field-theoretic representation in terms of two complex scalar ‘fields’ \(L_a, R_a, a = 1,\ldots,N\) living on the space of hidden symbols. This takes the form \[\begin{align} \label{W2} \mathbb{Z}(\mathcal{G}; m, \ell) = m! \oint' \frac{d\zeta}{\zeta^{1+m}} \oint' \frac{d\xi}{\xi^{1+\ell}} \oint' \frac{d\eta}{\eta^{1+\ell-m}} \;\mathcal{F}(\mathcal{G}), \end{align}\tag{3}\] where \(\oint' = \oint/(2\pi i)\), where \[\begin{align} \mathcal{F}(\mathcal{G}) = \int DL \int DR \; e^{-\frac{1}{g} \sum_a \left[ L_a L_a^\dagger + R_a R_a^\dagger \right] } e^{I} , \end{align}\] where \({}^\dagger\) denotes complex conjugate and \[\begin{align} \label{I} I & = \zeta h (L_1+R_1) + \xi \sum_a O_a (L_a^\dagger + R_a^\dagger) \notag\\ & \qquad + \eta \sum_{a,b,c} M_{abc} (L_a^\dagger + R_a^\dagger) L_b R_c. \end{align}\tag{4}\] with \(O_a = \sum_B O_{aB}\). The measure \(DL=\prod_a d\text{Re}[L_a] d\text{Im}[L_a]/(\pi g)\) is normalized such that \(\int DL \; e^{-\frac{1}{g} \sum_a L_a L_a^\dagger} = 1\), and similarly for \(R\). The constants \(g\) and \(h\) are chosen to satisfy \((2h)^m g^{2\ell-m} = p_E^\ell (1-p_E)^{2\ell-m} Z_{tree}^{-m}\), i.e. \(g=\sqrt{p}(1-p), h=\sqrt{p}/(2Z_{tree})\).
Eq.@eq:W2 defines a complex-valued \(3+2N-\)component disordered field theory in 0 dimensions. The fact that the \(L_a,R_a\) fields are complex-valued corresponds to the trees being directed: roots are distinguished from leaves, and for example \(M_{abc}\) corresponds specifically to a branch from \(a \to bc\) that is aligned from root towards the leaves. This entails that the propagator of the field theory distinguishes ‘past’ from ‘future’, if we identify time as flowing from the root to the leaves.
It follows by a straightforward rescaling that in this representation, \(\mathbb{Z}(\mathcal{G}; m,\ell)\) is governed by a saddle-point when \(\ell \to \infty\) and \(m \to \infty\) at finite average sentence length \(\ell/m\). This is the limit of a large text. It is convenient to write \(H_a = L_a^\dagger+R_a^\dagger\) for a head. The saddle-point equations are \[\tag{5} \begin{align} L_a & = g \xi O_a + g \eta \sum_{b,c} M_{abc} L_b R_c \tag{6}\\ L_a^\dagger & = g h \zeta \delta_{a1} + g \eta \sum_{a',b,c} M_{a'bc} H_{a'} \delta_{ab} R_c \tag{7} \\ R_a & = g \xi O_a + g \eta \sum_{b,c} M_{abc} L_b R_c \tag{8} \\ R_a^\dagger & = g h \zeta \delta_{a1} + g \eta \sum_{a',b,c} M_{a'bc} H_{a'} L_b \delta_{ac} \tag{9} \\ \ell-m & = \eta \sum_{a,b,c} M_{abc} H_a L_b R_c \tag{10} \\ \ell & = \xi \sum_{a} O_a H_a \tag{11} \\ m & = \zeta h (L_1+R_1) \tag{12} \end{align}\] for all \(a\) 3.
Eqs.@eq:SP bear a formal resemblance to belief propagation equations [28], but they are not identical. The former are defined for one fixed tree, and in terms of quantities with fixed site indices. In contrast, here the fields are defined on the symbols, and the partition function that is generated automatically samples all tree topologies. Nevertheless, this identification allows us to interpret \(L_a\) and \(R_a\) as downward messages, while \(L^\dagger_a\) and \(R^\dagger_a\) are upward messages.
Subtracting the third equation from the first we see that \(R_a=L_a\) although the left-right symmetry does not hold for the conjugates, in general. We can however sum the \(L^\dagger\) and \(R^\dagger\) equations (after swapping \(b\) and \(c\) in the latter) to get \[\begin{align} H_a & = 2 g h \zeta \delta_{a1} + g \eta \sum_{a',c} [M_{a'ac} + M_{a'ca} ] H_{a'} L_c \label{SP8} \end{align}\tag{13}\] which is closed in \(H_a\) rather than \(L^\dagger_a\) and \(R^\dagger_a\) separately. This implies that unless we probe observables that break the left-right symmetry, we can reduce the theory by eliminating the \(R_a\) field.
Evaluating \(\mathbb{Z}(\mathcal{G}; m,\ell)\) on the saddle-point, we obtain to leading exponential order \[\begin{align} \left.\mathbb{Z}(\mathcal{G}; m,\ell)\right|_{SP} & = \frac{m!}{\zeta^m \xi^\ell \eta^{\ell-m}} e^{-\frac{1}{g} \sum L_a [L^\dagger_a+R^\dagger_a] } e^{m + \ell + \ell - m} \notag \\ & = \frac{m!}{\zeta^m \xi^\ell \eta^{\ell-m}} e^{-\frac{1}{g} g (2\ell-m) } e^{2\ell} \notag \\ & = \left( \frac{m \eta}{\zeta} \right)^m \left( \xi \eta \right)^{-\ell} \end{align}\] using \(\sum L_a [L^\dagger_a+R^\dagger_a] = \sum_a g \xi O_a H_a+ g \eta \sum_{b,c} M_{abc} H_a L_b R_c = g \ell + g (\ell-m) = g (2\ell-m)\). This expression for \(\mathbb{Z}\) includes the terms that give a finite limit in \(\lim_{m \to \infty} \log \mathbb{Z}/m\). Further simplification requires solution of the saddle-point equations.
To establish the connection to the REM, consider the ‘paramagnetic’ ansatz \[\begin{align} L_a & = g \xi O_a + \bar L\\ H_a & = 2 g h \zeta \delta_{a1} + \bar H \end{align}\] so that the main equations above become \[\begin{align} \bar L & = g \eta \sum_{b,c} M_{abc} (g \xi O_b + \bar L) (g \xi O_c + \bar L) \\ \bar H & = g \eta \sum_{a',c} (M_{a'ca}+M_{a'ac}) (2g h \zeta \delta_{a'1} + \bar H ) (g \xi O_c + \bar L) \end{align}\] and we also have normalization equations for \(\eta,\xi,\) and \(\zeta\): \[\begin{align} \ell-m & = \eta \sum_{a,b,c} M_{abc} (2 g h \zeta \delta_{a1} + \bar H ) (g \xi O_b + \bar L)(g \xi O_c + \bar L) \\ \ell & = \xi \sum_{a} O_a (2 g h \zeta \delta_{a1} + \bar H ) \\ m & = 2\zeta h (g \xi O_1 + \bar L) \end{align}\] Let us make the simplifying assumption that \(O_1=0\), i.e. the start symbol never directly becomes an observable. In the general case this is a \(1/N\) correction that is irrelevant in the large \(N\) limit to be considered. Then \(\zeta = m/(2h\bar L)\) and \(\xi = \ell/(\bar H \sum_a O_a)\), and the \(\eta\) equation is trivially solved.
Now return to the main equations. The paramagnetic ansatz will close if the law of large numbers holds for all terms carrying a free index. We have the sums \[\begin{align} S_a^{(1)} &= \sum_{b,c} M_{abc} \\ S_a^{(2)} &= \sum_{b,c} M_{abc} O_b \\ S_a^{(3)} &= \sum_{b,c} M_{abc} O_c \\ S_a^{(4)} &= \sum_{b,c} M_{abc} O_b O_c \\ S_a^{(5)} &= \sum_{c} (M_{1ac}+M_{1ca}) \\ S_a^{(6)} &= \sum_{c} (M_{1ac}+M_{1ca}) O_c \end{align}\] which all take the form of a REM partition function but with different system sizes and variances. Let us write \[\begin{align} Z_{REM}(\mathcal{N},\lambda) = \sum_{j=1}^{\mathcal{N}} e^{-\beta E_j} \end{align}\] where \(\langle E_j \rangle = 0, \langle (\beta E_j)^2 \rangle = \lambda^2/2\). Derrida’s result is that the LLN breaks down when \[\begin{align} \frac{T}{T_c} = \frac{2\sqrt{\log 2}}{\beta J} = \frac{2\sqrt{\log \mathcal{N}}}{\lambda} \end{align}\] is smaller than unity. The corresponding parameters for the above sums are \[\begin{align} \mathcal{N}^{(1)} & = N^2, \lambda^{(1)} = \sqrt{1/\tilde{\epsilon}_d} \\ \mathcal{N}^{(2)} & = N^2 T, \lambda^{(2)} = \sqrt{1/\tilde{\epsilon}_d+ 1/\tilde{\epsilon}_s} \\ \mathcal{N}^{(3)} & = N^2 T, \lambda^{(3)} = \sqrt{1/\tilde{\epsilon}_d+ 1/\tilde{\epsilon}_s} \\ \mathcal{N}^{(4)} & = N^2 T^2, \lambda^{(4)} = \sqrt{1/\tilde{\epsilon}_d+ 2/\tilde{\epsilon}_s} \\ \mathcal{N}^{(5)} & = N, \lambda^{(5)} = \sqrt{1/\tilde{\epsilon}_d} \\ \mathcal{N}^{(6)} & = N T, \lambda^{(6)} = \sqrt{1/\tilde{\epsilon}_d+ 1/\tilde{\epsilon}_s} \end{align}\]
Note that, in the scaling limit, we have that all \(\lambda^{(i)} \sim \sqrt{\log N}\) while \(\sqrt{\log \mathcal{N}^i} \sim \sqrt{\log N}\) as well. Hence \(T/T_c\) is finite. The scaling limit of the RLM corresponds to the thermodynamic limit of the REM.
We see that the first breakdown will occur due to the root terms (i.e. those involving fixed symbol index 1), when \(\tilde{\epsilon}_d\log N < 1/4\) or \(\frac{\tilde{\epsilon}_d\tilde{\epsilon}_s}{\tilde{\epsilon}_d+\tilde{\epsilon}_s} \log NT < 1/4\). However it is not obvious whether the associated terms are actually relevant in the equations. A short calculation shows that, starting from the large \(\tilde{\epsilon}_d\) limit where all terms are self-averaging, the root terms have a relative weight \[\begin{align} \frac{2g h \zeta \delta_{a'1}}{\bar H} \sim \frac{m}{\ell-2m}, \end{align}\] which is finite as \(N \to \infty\) but suppressed for large trees, since \(\ell/m\) is the average length of a sentence.
After this first breakdown, which has a weak effect because it is suppressed by the average sentence length, the LLN will break down when \(S_a^{(1)}\) is not self-averaging; this occurs at \(\tilde{\epsilon}_d\log N = 1/8\). This sum controls the bulk propagation of messages and the breakdown of the LLN for it will destabilize the paramagnetic solution.
The result of the analysis is then the following: starting at large \(\tilde{\epsilon}_d\), for the bulk of the tree (i.e. for observables that do not depend on the terminals, and are therefore independent of \(\tilde{\epsilon}_s\) and \(T\)), a first weak breakdown will occur at \(\tilde{\epsilon}_d\log N = 1/4\), due to the influence of the start symbol. A complete breakdown will occur at \(\tilde{\epsilon}_d\log N = 1/8\).
For observables that depend on the terminals, the result depends on \(T/N\) and \(\tilde{\epsilon}_d/\tilde{\epsilon}_s\) but if \(\tilde{\epsilon}_s\) is fixed to be small (which is usually taken in the numerics, e.g. \(\tilde{\epsilon}_s= 0.01\)) then a weak breakdown will occur at \(\frac{\tilde{\epsilon}_d\tilde{\epsilon}_s}{\tilde{\epsilon}_d+\tilde{\epsilon}_s} \log NT = 1/4\), and a complete breakdown at \(\frac{\tilde{\epsilon}_d\tilde{\epsilon}_s}{\tilde{\epsilon}_d+\tilde{\epsilon}_s} \log (N^2T) = 1/4\).
These breakdowns are all of the LLN. As in the REM there will be corresponding breakdowns in the CLT at larger temperatures [30]. For a sum over \(N^K\) variables, the LLN breaks down at \(x_{LLN}=1/4K\) while the CLT breaks down at \(x_{CLT}=1/K\). Thus each CLT transition occurs at a value of \(x\) that is larger by a factor 4.
The phase diagram of the RLM is sketched in Fig.2, as a function of \(x\) and a scaling variable \(G=n/(Na)\) where \(a\sim \sqrt{8x}\) that will emerge from the analytical developments that follow as an effective corpus length. The transitions at \(x_c=1/8\) (dashed) and \(x=1/2\) (dotted) are indicated, delineating the frozen regime \(x<1/8\), the transition regime \(1/8 < x < 1/2\), and a ‘babbling’ regime \(x>1/2\). Further arguments (see [25]) indicate that \(x=1\) should also play a role as the initial onset of correlations in derivations, although it is not manifest in the bulk observables to follow here. It is indicated by a dash-dotted line.
The phase diagram has further structure to be elucidated in what follows: a critical regime near \(x_c=1/8\), and a saturation regime at small \(x\).
Although the field-theoretic approach locates the critical transitions, once the paramagnetic solution breaks down it is impractical to directly solve the full saddle-point equations. Fortunately, in the large \(N\) limit we can exploit a subtle self-averaging property of the model, as detailed next.
The above results indicate that at low temperature, there is a competition between increasing \(N\), which favours averaging, and lowering \(\tilde{\epsilon}_d\), which increases rule variance. This opens the possibility to take \(N \to \infty\) while also taking \(\tilde{\epsilon}_d\to 0\), such that \(\tilde{\epsilon}_d\log N\) remains finite. In this scaling limit, we can exploit simplifications due to large \(N\) while also retaining the ability to control entropy and other language properties, by tuning \(x = \tilde{\epsilon}_d\log N\). Similar considerations imply that we should fix \(y = \tilde{\epsilon}_s\log T\) to obtain nontrivial scaling in the surface properties.
We will consider this limit both for finite trees and in the limit of a large corpus; in the numerics of [17], trees were chosen by a branching process with \(\langle \ell \rangle \approx 15\). This of course does not preclude considering the limit of an infinite corpus.
Consider the partition sum of the RLM for a fixed forest \(\mathcal{F}\) of trees with lengths \(\{ \ell_i, i = 1 \ldots m \}\) and grammar \(\mathcal{G}\), which is written as a sum over trees \(\mathcal{T}_i\): \[\begin{align} \mathbb{Z}(\mathcal{F}; \mathcal{G}) = \prod_i Z(\mathcal{T}_i,\mathcal{G}) . \end{align}\] with \[\begin{align} Z(\mathcal{T},\mathcal{G}) = \underbrace{\overline{M}^{\ell-1} \overline{O}^\ell }_{Z_0(\ell)} \sum_{\{ \sigma_i, o_t \} } e^{-E'} \end{align}\] and \[\begin{align} E' = -\sum_{a,b,c} \pi_{abc}(\sigma; \mathcal{T}) X_{abc} -\sum_{a,B} \rho_{aB}(\sigma,o; \mathcal{T}) Y_{aB} . \end{align}\]
Fix a forest \(\mathcal{F}\) and define the rule spectrum \(\{p_k, q_k, k \geq 1\}\) that for each \(k\) indicates how many rules are used \(k\) times, with \(p_k\) counting the number of hidden rules and \(q_k\) the number of terminal rules. For example, the derivation in Fig.1 has 7 branches, of which 2 use the same rule, so that \(p_1 = 5, p_2 = 1,\) and \(p_k=0\) for \(k \geq 3\), and \(q_1=8,q_k= 0\) for \(k \geq 2\). The set of all derivations consistent with a given spectrum is called a pattern, \(P(\{p_k,q_k\}; \mathcal{F})\).
The partition sum \(Z\) can be organized as a sum over patterns, which are the relevant excitations of the model: \[\begin{align} \mathbb{Z}(\mathcal{F}; \mathcal{G}) = \mathbb{Z}_0 \sum_{\{ P \}} \underbrace{\sum_{ (\sigma,o) \in P } e^{- E'(\sigma,o; \mathcal{G})}}_{\mathcal{P}(P; \mathcal{G})} , \end{align}\] where \(\mathbb{Z}_0 = \prod_i Z(\ell_i)\) depends only on the number of trees \(m\) and the total length \(\ell = \sum_i \ell_i\). For any derivation, applying a global permutation to the symbols results in another derivation with the same pattern, but different rules. Since the model is defined by iid rule weights, each pattern thus explores the space of grammars. In other words, even though \(\mathbb{Z}\) is computed for a fixed grammar, sums over symbol values amount to sums over possible grammar weights. This is a form of self-averaging, which we use to justify the semi-annealed approximation that follows. It is however essential to respect the rule spectrum of the pattern, since this controls the Boltzmann weight.
The organization of the partition function as a sum over patterns suggests a natural large-deviation structure. Each pattern \(P\) contributes a weight that combines an energetic term, controlled by the rule multiplicities, and a combinatorial entropy that counts the number of derivations realizing that spectrum. Crucially, both contributions diverge in the scaling limit (in particular both are powers of \(N\), as confirmed below). As a result, the partition function can be written \[\begin{align} \mathbb{Z}(\mathcal{F}; \mathcal{G})/\mathbb{Z}_0 = \sum_{\{ P \}} e^{S(P)} e^{-\hat{E}(P)} \end{align}\] where \(S(P)\) encodes the entropy of patterns and \(\hat{E}(P)\) is an effective energy after averaging over rule weights. In the scaling limit this will be dominated by a saddle point \(P_*\) that minimizes the effective free energy \(\hat{E}-S\). This provides a basis for a semi-annealed approximation: we perform an annealed average over rule weights within each pattern, while retaining the constraint that the pattern itself is selected by a saddle-point condition at fixed \(N\). In this sense, the approximation is not a fully annealed treatment of the original quenched problem, but rather a coarse-grained saddle-point evaluation over patterns, which captures the dominant contributions in the scaling limit.
This perspective also clarifies the role of the rule spectrum \(\{ p_k, q_k \}\) as an order-parameter-like object: different phases of the model correspond to qualitatively different saddle-point spectra, reflecting whether weight is distributed over many rules or concentrated onto a few. As we show below, this structure leads to a condensation transition analogous to that of the Random Energy Model.
There are two important ingredients to the semi-annealed approximation. First, since trees can be sampled sequentially from the root without backtracking, for a given head \(a\) there are \(N^2\) possible rules \(a \to bc\) to consider. This defines an elementary REM partition sum, one for each branch.
Second, although rule distributions are heavy-tailed at small \(\tilde{\epsilon}_d\), at any finite \(N\) we only sample a finite number of values from the distribution. Using extreme-value statistics, a sum over \(N^2\) variables sampled from \(P(M)\) will typically not see a value larger than \(M^*\) where \[\begin{align} \frac{1}{N^2} & = \int_{M^*}^\infty dM P(M) \notag \\ & = \int_{M^*}^\infty \frac{dM}{M\sqrt{\pi/\tilde{\epsilon}_d}} e^{-\tilde{\epsilon}_d\log^2 (M/\overline{M}) } \notag \\ & = \int_{X_*}^\infty \frac{dX}{\sqrt{\pi/\tilde{\epsilon}_d}} e^{-\tilde{\epsilon}_dX^2 } \notag \\ & = \frac{1}{2}\text{erfc}(\sqrt{\tilde{\epsilon}_d} X_*) \end{align}\] with \(X=\log (M/\overline{M})\) and \(X_* = \log (M^*/\overline{M})\). Define an average restricted to the interval \(M<M^*\), or equivalently \(X<X_*\): \[\begin{align} \langle f(X) \rangle_{X<X_*} = \frac{\int_{-\infty}^{X_*} dX P(X) f(X)}{\int_{-\infty}^{X_*} dX P(X)} \end{align}\] Then in the semi-annealed approximation, a pattern contributes \[\begin{align} \label{P} \mathcal{P}(\{p_k, q_k\}) = \underbrace{\left. \Omega N^Q T^{Q'} \right. }_{e^S} \underbrace{\prod_k \langle e^{k X} \rangle_{X<X_*}^{p_k} \prod_{k'} \langle e^{k' Y} \rangle_{Y<Y_*}^{q_{k'}} }_{e^{-\hat{E}}} \end{align}\tag{14}\] where \(Q\) and \(Q'\) count the number of DOF in the average over symbols, and \(\Omega\) accounts for the entropy of the pattern.
Exact counting of derivations is difficult in large trees, but we can obtain a simple estimate by counting degrees of freedom. We consider a forest of \(m\) trees, of total length \(\ell\). There are \(n= \ell-m\) branches. We have \(n = \sum_k k p_k\) and \(\ell = \sum_k k q_k\). The total number of unique hidden rules used in the pattern is \(p = \sum_j p_j\), while \(q= \sum_j q_k\) is the total number of unique terminal rules. Eventually we will need to decide on the relative size of \(\ell\) and \(N\).
First choose the symbols used by the \(p\) branching rules; this gives \(\binom{N^3}{p} \sim N^{3p}/p!\) if \(N^3 \gg p\). The first correction is a factor \(e^{-p^2/2N^3}\) that will be negligible if \(p \ll N^3\).
Then distribute these according to the rarity distribution; this gives a multinomial coefficient \[\begin{align} \binom{p}{p_1 \; p_2 \; \cdots }. \end{align}\]
Having fixed the identities of the rules, we can then create different derivations by placing them in different configurations. This can be estimated due to two simplifying factors of the model: first, the tree structure allows configurations to be built sequentially, starting from the root, without backtracking. Second, since all rules are iid, if for example we have a rule \(a \to bc\), then the likelihood of having a rule whose head is \(b\) is independent of the value \((a)\) of the head. Thus, suppose we have a pile of \(\ell_c\) rules, of which \(p\) of them are unique. We assume that \(\ell_c/p\) is large, so that a typical rule appears frequently. Then, starting from the root, we will have typically \(p/N\) rules with the start symbol as head. Continuing to its children, we will have \(p/N\) choices for the next branch, and so on. This yields a simple estimate \((p/N)^{\ell_c}\) for the number of unique derivations. It implies that the pile will yield a unique derivation if \(p \approx N\).
This estimate is refined by an exact calculation based on Eqs.@eq:SP (see Appendix 11). It confirms the \((p/N)^{\ell_c}\) result and applies even when \(p<N\), when the above argument is unreliable; indeed an analysis of corrections to the leading order reveals that the estimate works best when \(p/N\) is small and when the total corpus length is small.
However, this estimate does not account for the depletion of rules as we build derivations. We account for this by dividing up the full \(n\) rules (counted with multiplicity) into piles of \(\ell_c\) rules, each of which has \(N\) unique rules. Each pile will then typically have a unique derivation. Since the average repetition rate of a rule is \(n/p\) we take \(\ell_c = n N/p\), and hence \(m_c = p/N\) piles, which play the role of correlation volumes. This requires \(p/N\geq 1\), since \(m_c\) must be integer.
For \(p>N\), counting derivations thus reduces to counting the number of ways to partition the initial \(n\) rules (with given multiplicity spectrum) into \(m_c\) correlation volumes. Label the volumes 1 through \(m_c\) and consider each rule type \(r\), i.e. triple \(r= (a,b,c)\) corresponding to \(a \to bc\). Suppose this rule occurs \(\pi\) times in the complete pile of \(n\) rules. Then there are \(\binom{\pi + m_c - 1}{m_c -1}\) ways to put these \(\pi\) rules into the correlation volumes. Repeating this for all rules and recalling the definitions of \(\{ p_k \}\) we find 4 \[\begin{align} \prod_{k \geq 1} \binom{k + m_c - 1}{m_c -1}^{p_k} . \end{align}\] As a result, counting derivations gives a factor \[\begin{align} \label{OmD1} \Omega_D = \begin{cases} (p/N)^{n} &\qquad p/N<1 \\ \prod_{k \geq 1} \binom{k + m_c - 1}{m_c -1}^{p_k} &\qquad p/N>1 \end{cases} \end{align}\tag{15}\]
Now we choose and place the terminal rules. Consider the hidden symbols as given, for any particular realization of the pattern. We first need to know how many unique hidden symbols there are that become leaves; this depends on the topology of the tree. It is easily seen that the number is between \(p\) (if the tree always branches to the right, say) and \(2p\) (if the tree is fully balanced). For the branching process considered in the model, the typical value is \(3p/2\), as can be seen by a generating function argument.
We will assume that \(3p/2 > N\), so that all hidden symbols are represented. Then, the argument is very similar: first we choose the rules, \(\binom{NT}{q} \sim (NT)^q/q!\) if \(q \ll NT\); then we distribute these according to the rarity distribution, giving a multinomial coefficient \(\binom{q}{q_1 q_2 \cdots }\). Then we need to count sequences that are compatible. For each hidden symbol that becomes a leaf, there are typically \(q/N\) terminal rules that are compatible. Thus, as before we estimate \((q/N)^\ell\) sequences if rule depletion is ignored. Taking into account rule depletion, we split the \(\ell\) rules (counted with multiplicity) into \(m_c'\) piles of \(\ell_c'\) rules each. If each pile has \(N\) unique rules, then there will typically be one compatible sequence, which leads to \(\ell_c' = \ell N/q\) and \(m_c' = q/N\). Finally we need to count the number of ways to put the rules into piles. The result from counting sequences is a factor \[\begin{align} \label{OmpD1} \Omega_D' = \begin{cases} (q/N)^{\ell} &\qquad q/N<1 \\ \prod_{k \geq 1} \binom{k + m_c' - 1}{m_c' -1}^{q_k} &\qquad q/N>1 \end{cases} \end{align}\tag{16}\] We then obtain a simple estimate of the number of derivations as \[\begin{align} \label{S1} e^S & = \Omega N^Q T^{Q'} \notag\\ & = \binom{p}{p_1 p_2 \cdots } \frac{1}{p!} \binom{q}{q_1 q_2 \cdots } \frac{1}{q!} \Omega_D \Omega_D' N^{3p} (NT)^q, \end{align}\tag{17}\] with \(m_c=p/N\) and \(m_c'=q/N\), so that \(Q = 3p+q, Q' = q\). Note that \(\Omega\) also depends on \(N\) through \(m_c\).
The effective energies of patterns depend on \(g_k=\langle e^{k X} \rangle_{X<X_*}\) and \(h_k=\langle e^{k Y} \rangle_{Y<Y_*}\). We have \[\begin{align} g_k = \langle e^{k X} \rangle_{X<X_*} & = \frac{\int_{-\infty}^{X_*} dX P(X) e^{kX } }{\int_{-\infty}^{X_*} dX P(X)} \notag\\ & = \frac{\int_{-\infty}^{X_*} dX e^{kX } e^{-\tilde{\epsilon}_dX^2} }{\int_{-\infty}^{X_*} e^{-\tilde{\epsilon}_dX^2} } \notag\\ & = \frac{ e^{k^2/(4\tilde{\epsilon}_d)} \text{erfc}((k-2\tilde{\epsilon}_dX_*)/\sqrt{4\tilde{\epsilon}_d} ) }{ 2 - \text{erfc}(\sqrt{\tilde{\epsilon}_d} X_*) } \end{align}\] We can simplify this expression, and that for \(X_*\), in the scaling limit. We use the continued fraction representation \[\begin{align} \text{erfc}(z) = \frac{z}{\sqrt{\pi} } e^{-z^2} \frac{1}{z^2+h(z)} \end{align}\] where \(h(z) = 1/2 + \ldots\) for \(z \gg 1\). (For \(z \ll -1\) we can use erfc\((z)=2-\text{erfc}(-z)\))
First, at large \(N\) we have that \(\text{erfc}(\sqrt{\tilde{\epsilon}_d} X_*) = 2/N^2 \ll 1\) so that we can use its asymptotics to obtain \(e^{-\tilde{\epsilon}_dX_*^2}/\sqrt{\tilde{\epsilon}_dX_*^2} \approx \sqrt{4\pi}/N^2\), which is solved \[\begin{align} 2 \tilde{\epsilon}_dX_*^2 = W_0(N^4/(2\pi)) \equiv w \sim \log(N^4/(2\pi)) \end{align}\] where \(W_0\) is a branch of the Lambert-\(W\) function satisfying \(W(z)e^{W(z)}=z\). Note then that \[\begin{align} \tilde{\epsilon}_dX_* = \sqrt{\tilde{\epsilon}_d} \sqrt{\tilde{\epsilon}_dX_*^2} \sim \sqrt{2 \tilde{\epsilon}_d\log N}, \end{align}\] which is finite in the scaling limit. As a result, the argument to \(\text{erfc}\) in \(g_k\) is large in magnitude (since \(\tilde{\epsilon}_d\ll 1\)) but may take either sign. We then have \[\begin{align} g_k& \sim \frac{1}{2}e^{k^2/(4\tilde{\epsilon}_d)} \begin{cases} 2 & k < 2 \tilde{\epsilon}_dX_* \\ \frac{ e^{ -(k-2\tilde{\epsilon}_dX_*)^2/(4\tilde{\epsilon}_d) } }{ \sqrt{\pi} (k-2\tilde{\epsilon}_dX_*)/\sqrt{4\tilde{\epsilon}_d}} & k > 2 \tilde{\epsilon}_dX_* \end{cases} \\ & = \begin{cases} e^{k^2/(4\tilde{\epsilon}_d)} & k < 2 \tilde{\epsilon}_dX_* \\ \frac{ e^{ (4k\tilde{\epsilon}_dX_* - 4\tilde{\epsilon}_d^2 X_*^2)/(4\tilde{\epsilon}_d) } }{ (k-2\tilde{\epsilon}_dX_*) \sqrt{\pi/\tilde{\epsilon}_d} } & k > 2 \tilde{\epsilon}_dX_* \end{cases} \end{align}\] The asymptotics depend on \(k\): for any given value of \(x\), rules that are repeated often enough will feel the effect of finite \(N\).
The surface terms are analogous. Define \(Y_*\) as the solution to \(2\tilde{\epsilon}_sY_*^2 = W_0(T^2/(2\pi)) \equiv w'\). We have \[\begin{align} h_k & = \frac{1}{2 - \text{erfc}(\sqrt{\tilde{\epsilon}_s} Y_*)} e^{k^2/(4\tilde{\epsilon}_s)} \text{erfc}\left( \frac{k-2\tilde{\epsilon}_sY_*}{\sqrt{4\tilde{\epsilon}_s}} \right) \\ & \sim \begin{cases} e^{k^2/(4\tilde{\epsilon}_s)} & k < 2 \tilde{\epsilon}_sY_* \\ \frac{ e^{ (4k\tilde{\epsilon}_sY_* - 4\tilde{\epsilon}_s^2 Y_*^2)/(4\tilde{\epsilon}_s) } }{ (k-2\tilde{\epsilon}_sY_*) \sqrt{\pi/\tilde{\epsilon}_s} } & k > 2 \tilde{\epsilon}_sY_* \end{cases} \end{align}\] This structure completely parallels that of the hidden layers, but note that \(w\) depends on \(N^4\) while \(w'\) depends on \(T^2\).
It is useful to note that \(e^{-\tilde{\epsilon}_dX_*^2} = \sqrt{2\pi w}/N^2\) with \(w = W_0(N^4/2\pi)\) and similarly \(e^{-\tilde{\epsilon}_sY_*^2} = \sqrt{2\pi w'}/T\) with \(w' = W_0(T^2/2\pi)\).
The Lambert-\(W\) function appears repeatedly in what follows. Defined by \(W(z) e^{W(z)} = z\), it has two branches: the \(W_0\) branch exists for \(z > -1/e\), behaves as \(W_0(z) \sim z\) as \(z\to 0\) and has large \(z\) behavior \(W_0(z) \sim \log z - \log \log z\). The second branch \(W_{-1}(z)\) exists for \(-1/e < z < 0\) and has asymptotics \(W_{-1}(z) \sim (\log -z) - (\log (-\log -z))\) for \(|z| \ll 1\). For \(z<-1/e\) neither \(W_0(z)\) nor \(W_{-1}(z)\) exist.
Below we will see frequent appearance of the quantities \[\label{aap} \begin{align} a & \equiv \sqrt{2 w \tilde{\epsilon}_d} \sim \sqrt{8 (\log N) \tilde{\epsilon}_d} = \sqrt{8x} \\ a' & \equiv \sqrt{2 w' \tilde{\epsilon}_s} \sim \sqrt{4 (\log T) \tilde{\epsilon}_s} = \sqrt{4y} \end{align}\tag{18}\] Note also that \(2 \tilde{\epsilon}_dX_* = \sqrt{2\tilde{\epsilon}_d} \sqrt{2 \tilde{\epsilon}_dX_*^2} = \sqrt{2\tilde{\epsilon}_dw} = a\) and \(2 \tilde{\epsilon}_sY_* = \sqrt{2\tilde{\epsilon}_sw'} = a'\).
If we define integers \(r,s\) such that \[\begin{align} & r < a < r+1 \\ & s < a' < s+1 \end{align}\] then we can write \[\begin{align} \label{gk1} g_k \sim \begin{cases} N^{\frac{k^2}{4x}} & k \leq r \\ N^{-2 + \frac{k a}{2x} } \frac{ a }{ k-a } & k > r \end{cases} \end{align}\tag{19}\] and \[\begin{align} \label{hk1} h_k \sim \begin{cases} T^{\frac{k^2}{4y}} & k \leq s \\ T^{-1 + \frac{k a'}{2y} } \frac{ a' }{ k-a' } & k > s \end{cases} \end{align}\tag{20}\] which give the energetic contribution \[\begin{align} \label{Ehat1} e^{-\hat{E}(P)} = \prod_k g_k^{p_k} h_k^{q_{k}} \end{align}\tag{21}\] Eqs.@eq:gk1 ,20 show explicitly that in the scaling limit, the energetic contributions have singular behavior at a whole array of temperatures, just as in the REM [24]. In particular, whenever \(a\) or \(a'\) is a positive integer, then one of the above asymptotics changes form.
We have now all the ingredients for the semi-annealed approximation. Eqs.@eq:OmD1 ,16 ,17 give the entropic part while Eqs.@eq:aap ,19 ,20 ,21 give the energetic part.
Consider initially a finite tree so that all \(p_k\) and \(q_k\) are finite. Also, for simplicity, consider \(r=s=0\), that is \(a <1, a' <1\), which corresponds to \(8x<1, 4y<1\) in the scaling limit. Then the leading behavior of the pattern weight is \[\begin{align} \mathcal{P}( \{p_k, q_k \}) &\sim N^{3p+q} T^q \prod_k \left( N^{-2 + \frac{k a}{2x} } \right)^{p_k} \left( T^{-1 + \frac{k a'}{2y} } \right)^{q_k} \\ &= N^{p+q + \frac{n a}{2x}} T^{\ell a'/2y} \\ &\sim N^{p+q+ n \sqrt{2/x}} T^{\ell \sqrt{1/y} } . \end{align}\] As alluded to above, all contributions diverge in the scaling limit. Similar to other defect models, such as the XY model [31]–[34], the weight of excitations depends on the temperature(s). When the multinomial factors of \(e^S\) are included, this implies that rule spectra will have preferred forms in the scaling limit. Hence there is a dominant pattern at each given \(\tilde{\epsilon}_d,\tilde{\epsilon}_s\).
In what follows, we extract the dominant patterns and their properties. First, we do so in finite trees, and then in large corpora; our goal throughout is to extract the leading asymptotic forms of observables in the scaling limit. These will be compared with direct numerical simulations and will be applied to data from real languages in subsequent sections.
In the scaling limit there will be a preferred spectrum of rule multiplicities. We have \(p = \sum_k p_k,q = \sum_k q_k, n = \ell-m = \sum_k k p_k, \ell = \sum_k k q_k\). First consider the \(\{ p_k \}\); the hidden and surface spectra are decoupled so long as \(p/N>2/3\), which can be verified later. We maximize \(\mathcal{P}\) with a Lagrange multiplier \(\tilde{n}\) that imposes \(n = \sum_k k p_k\). Using the Stirling approximation for \(p_k!\) we obtain \[\begin{align} p_k = N^3 g_k e^{- k \tilde{n}} e^{\partial_{p_k} \log \Omega_D} \end{align}\] where \(\tilde{n}\) is fixed by \[\begin{align} n & = \sum_k k N^3 g_k e^{- k \tilde{n}} e^{\partial_{p_k} \log \Omega_D} \end{align}\] This depends both on the corpus size and on the behavior of the \(g_k\), which in turn depends on \(x\). We find \[\begin{align} \label{pk} p_k = \begin{cases} N^3 g_k e^{- k \tilde{n}} e^{n/p} \qquad\qquad & p<N \\ v \binom{k + m_c - 1}{m_c -1} N^3 g_k e^{- k \tilde{n}} \qquad\qquad & p>N \end{cases} , \end{align}\tag{22}\] with \(m_c=p/N\) and \(v = e^{\sum_{k'} \frac{p_{k'}}{N} \log \left(1+\frac{k'}{m_c-1}\right)}\).
Note that \(p\) is determined self-consistently from the solution, so we do not know in advance which regime we are in. However, if consider a single tree in the scaling limit, then we can expect \(p < N\), while if we consider a corpus of diverging size, then it is possible (and likely) to have \(p>N\).
The surface terms are analogous. The most likely pattern satisfies \[\begin{align} q_k = NT h_k e^{- k \tilde{m}} e^{\partial_{q_k} \log \Omega'_D} \end{align}\] This gives \[\begin{align} \label{qk} q_k = \begin{cases} NT h_k e^{- k \tilde{m}} e^{\ell/q} \qquad\qquad & q<N \\ v' \binom{k + m_c' - 1}{m_c' -1} NT h_k e^{- k \tilde{m}}\qquad\qquad & q>N \end{cases} , \end{align}\tag{23}\] with \(m_c' = q/N\) and \(v' = e^{\sum_k \frac{q_k}{N} \log (1+k/(m_c'-1))}\). \(q=\sum_k q_k\) must be determined self-consistently, and \(\tilde{m}\) is fixed implicitly by the constraint \(\ell = \sum_k k q_k\).
First consider a single finite tree in the scaling limit. Then since \(p\leq\ell\) while \(N\) diverges, we use Eq.@eq:pk with \(p<N\). We need to find \(\tilde{n}\) such that \(n=\sum_k k p_k\), and \(p\) such that \(p =\sum_k p_k\). The result for \(n=20\) is shown in Fig.3c and compared to sampled data from the RLM, where \(n\) is dynamical with \(\langle n \rangle \approx 16\), without fitting parameters. It captures all the features of the data.
We can obtain analytical approximations for the full spectrum in several regimes, as detailed in Appendix 13. In the frozen regime \(x<1/8\) we have \[\begin{align} p_k \approx N a z^k e^{n/p} /(k-a) \end{align}\] with \(z = N^{a/2x} e^{-\tilde{n}}\). In terms of \(G = n/Na\) we find \(z \approx 1 - e^{W_{-1}( -1/\log G )}\). At small \(x\), \(a \ll 1\), \(G \gg 1\) and \(z \to 1^-\), so that \(p_k/p \propto z^k/k\) is asymptotically independent of \(x\). This is observed in the data (Fig.3ab) for \(x \lesssim 10^{-2}\).
For \(x>1/8\) we find \(p \approx n\), that is, all rules are used uniquely. The \(x\) dependence of \(p_k\) does not have a simple form, but analytical approximations are available.
Now consider the opposite regime where \(p/N>1\). First, we present numerical data from the RLM at various \(N\), \(\tilde{\epsilon}_d\), and \(n\). Fig.4a shows the number of unique rules that appear in a corpus of total length \(\ell=n+m\), versus \(n/N\), at various \(x=\tilde{\epsilon}_d\log N\) in the frozen regime. Rules are counted over complete sentences; the plateau at small \(\ell\) corresponds to the typical number of unique rules in one sentence. Beyond this, \(p\) is approximately power-law in \(\ell\), with a ‘novelty’ exponent that changes continuously as \(x\) varies. Heavy dotted and dash-dotted lines indicate powers \(\ell^{0.5}\) and \(\ell^{0.15}\), respectively. This indicates that the language continues to exhibit novelty as corpus length grows, and the novelty rate depends upon the temperature \(\tilde{\epsilon}_d\). At smaller temperatures, the increase of novelty with corpus length is slower. Above \(x>1/8\), shown in Fig.4b, the pattern is similar: the dash-dotted line indicates a power \(\ell^{0.5}\).
The \(N\) dependence is shown in Fig.5, at \(n \approx 850\) which is the upper limit where we have data across all values of \(x\) and \(N\). The leading dependence is \(p \propto N\) at finite \(x=\tilde{\epsilon}_d\log N\); a remaining weak dependence is collapsed by rescaling with a factor of \(\log \log G\), with \(G = n/(Na)\), as shown in Fig.5b. As a function of \(x\) we have approximately \(p/N \propto \sqrt{x} \log \log G\) in the frozen regime, at small \(x\). Theory should be able to rationalize all these scalings.
From Eqs.@eq:gk1 ,22 we can solve the model in the frozen regime, explained in Appendix 14, and obtain the phase diagram of the RLM, shown in Fig.2 in terms of the scaling variables \(x = \tilde{\epsilon}_d\log N\) and \(G = n/(Na)\). These are rescaled temperature and corpus-size parameters, respectively. \(G\) emerges from the solution of the equations, explained in what follows. Here \(a = \sqrt{2 w \tilde{\epsilon}_d} \sim \sqrt{8x}\).
Note that \(a/\sqrt{8x} = \sqrt{w/4\log N} \approx \sqrt{1 - \frac{\log \log N^4}{\log N^4} } \approx 0.90\) for \(N=40\), so there is a slight but measureable difference between \(a\) and its large-\(N\) asymptotic form \(\sqrt{8x}\).
Within the frozen phase \(x<1/8\), we find three regimes: a saturating regime for \(x<x_{lo}\), a scaling regime for \(x_{lo}<x \ll 1/8\), and a critical regime when \(x \approx 1/8\). The scaling regime is where increasing the corpus size still realizes new rules, and the critical regime is where condensation is just occurring and rule use increases rapidly. In the saturating regime the number of rules used per symbol becomes small, and the semi-annealed theory breaks down.
We find the onset to saturation occurs at \[\begin{align} \label{xlo} x_{lo} = \frac{1}{8} \left( 8 \pi e^2 \right)^{-8/3} (n/N)^{-10/3} \end{align}\tag{24}\] Noting that \(\frac{1}{8} \left( 8 \pi e^2 \right)^{-8/3} \approx 1.1 \times 10^{-7}\), even at finite \(n/N\) this predicts a very small value of \(x_{lo}\), not visible in our numerics.
The number of unique rules per symbol is: \[\begin{align} p/N \approx \begin{cases} \frac{2}{3} a \sqrt{2\pi e^3} \log(3/2k_*) G^{\beta(G)} \qquad & x_{lo}< x \ll 1/8 \\ a \sqrt{2\pi e} e^{4 + \frac{3}{k_*-a} } \frac{ 1 }{k_*-a} \qquad & x \approx 1/8^- \end{cases} , \end{align}\] where \[\begin{align} \beta(G) \approx \frac{2}{1+\log G^{2/3} \log \log G^{2/3}} \end{align}\] is the novelty exponent, and \[\begin{align} k_* \approx \begin{cases} 3 (2\log (\log G^{2/3} \log \log G^{2/3}))^{-1} \qquad & x_{lo} < x \ll 1/8 \\ \frac{3}{4} + \frac{1}{2}a + \frac{1}{2}\sqrt{a^2 + a + \frac{9}{4}} \qquad & x \approx 1/8^- \end{cases} . \end{align}\] All results hold only for \(G\) in an intermediate range where the semi-annealed saddle exists. When \(G\) is too small, or potentially too large, rule use may be affected by the finiteness of the rule-set or the corpora. These implied thresholds are sensitive to corrections to the theory and therefore not well-predicted by the leading order solution that we consider.
For later use we have auxiliary variables \[\begin{align} z \approx k_* e^{3/2k_*} N/p \qquad & x_{lo} < x < 1/8 \end{align}\] and \[\begin{align} v \approx e^{k_*} \qquad & x_{lo} < x < 1/8 \end{align}\] In the scaling regime these can also be written in terms of \(\alpha \approx e^{3/2k_*}\).
Note that the four quantities \(N,\tilde{\epsilon}_d, p, n\) appear only in the three combinations \(p/N, n/N,\) and \(\tilde{\epsilon}_dw \sim \tilde{\epsilon}_d\log N\). This indicates that the scaling limit should be taken with \(n/N\) fixed and that \(p \propto N\) in this limit. This leading \(N\)-dependence of \(p\) is observed in Fig.5a.
The scaling regime is so-called because there, we have a further reduction to only two key combinations of parameters: \(p/Na\), and \(G=n/Na\). These results explain observations of Figs.4,5:
First, the predicted scaling collapse of \(p/Na\) versus \(G\) is tested in Fig.6a, where curves for \(x< 0.012\) collapse over the full range of \(G\), up to a small factor. At larger \(x\), the curves peel off when the critical regime becomes relevant. This lower function is the envelope valid for small enough \(x\). Note moreover that the raw \(p/N\) curves span a vertical range of \(6-10\) in Fig.4a, collapsed down to \(1.3-3\) here, even without accounting for critical regime effects to be understood later.
Second, the term \(G^{\beta(G)}\) explains the behavior \(p \sim n^{\beta(x)}\) with continuously changing exponent \(\beta(x)\), observed in Fig. 4a. Since \(\beta(G)\) decreases as \(G\) increases, the term \(G^{\beta(G)}\) predicts a concave shape of the envelope, as observed in Fig.6a. Third, since \(G^{\beta(G)} \sim e^{\frac{2 }{\log\log(G) }} \to 1\) at large \(G\), in this regime Eq.@eq:mc2 predicts that the \(N\)-dependence of \(p\) is fully captured by \(p \propto N \log\log G\), ignoring the ultra-slow \(\log\log\log G^{2/3}\) factor. This is confirmed in Fig.5b.
Fourth, Eq.@eq:mc2 predicts \(p/N \propto a \sim \sqrt{8x}\) in the scaling regime, confirmed in Fig.5b.
The critical regime is similar to the scaling regime, except that \(\beta(G)\) effectively increases, reaching a value \(\beta_c \approx 2/(1+e) \approx 0.537..\). This explains the scaling seen in Fig.4a as \(x \to 1/8^-\) and more generally the upturn visible in Fig.5b and Fig.6a.
Overall, the theory captures the scaling dependence of \(p\) on \(n\), \(N\), and \(x\) in surprising detail.
For \(x>1/8\), the asymptotics of small-\(k\) values of \(g_k\) differ. In Appendix 14 we obtain analytical approximations here, with the result \[\begin{align} p/N \approx \begin{cases} \frac{1}{2}N^{\chi } G^{1/2} \log G \qquad & n/N \gg N^{2\chi} \\ n/N \qquad & n/N \ll N^{2\chi} \end{cases} \end{align}\] where \(\chi(x) = 2 + \frac{1}{4x} - \sqrt{\frac{2}{x}}\). The scaling limit is taken at fixed \(n/N\) while \(N \to \infty\), so asymptotically we predict that \(p \approx n\) for \(x>1/8\) and all rules are used uniquely. In practice however we can see the other regime in numerics; the prediction \(p/N \sim G^{1/2}\) is observed, see Fig.6b.
For later use we will need \[\begin{align} z \approx N^{-\chi} e^{-G/A} \end{align}\] and \(v \approx e^{-G/A}\), for \(N^{2\chi} \gg n/N\).
The surface layer is solved analogously. It is decoupled (provided \(p/N>2/3\) as assumed) due to the hidden feedforward nature of the sequences along the hierarchical dimension. Comparing \(p_k\) in Eq.@eq:pk to \(q_k\) in Eq.@eq:qk and \(g_k\) in Eq.@eq:gk1 to \(h_k\) in Eq.@eq:hk1 , they are mathematically isomorphic. Results from the hidden layer can lifted by mapping \[\begin{align} a & \to a' \\ p_k/N &\to q_k/N \\ m_c &\to m_c' \\ v &\to v' \\ n/N &\to \ell/N \\ N &\to T^{1/2} \\ x &\to \frac{1}{2}y \end{align}\] This implies that we will have a control parameter \[\begin{align} G' = \frac{\ell/N}{a'} . \end{align}\] The existence and qualitative similarity of the RLM transition obtained as a function of \(\tilde{\epsilon}_s\), rather than \(\tilde{\epsilon}_d\), was shown in [22].
Now let us evaluate the partition function \(Z\) in the semi-annealed approximation. We work in the limit of a large corpus. Initially we consider only the hidden variables (WLOG). For given \(n\), the most likely pattern gives a weight (including its entropy)
\[\begin{align} & \Omega_D \frac{1}{p!} \binom{p}{p_1 p_2 \cdots } \prod_k \left( N^{3} g_k \right)^{p_k} \notag \\ & \qquad = \frac{1}{p!} \binom{p}{p_1 p_2 \cdots } \prod_k \left( e^{\tilde{n} k} p_k v^{-1} \right)^{p_k} \notag\\ & \qquad \approx e^{\tilde{n} n} \prod_k \frac{p_k^{p_k} }{(p_k/e)^{p_k}} v^{-p_k} \notag\\ & \qquad = e^{\tilde{n} n} e^p v^{-p} \notag\\ & \qquad = e^{\tilde{n} n} e^{p-p \log v} \end{align}\] where we used the Stirling approximation \(p! \approx (p/e)^p\) and only kept leading terms (in keeping with the previous use of Stirling).
The surface terms are completely analogous and give a contribution \(e^{\tilde{m} \ell + q \log e/v'}\). Finally in the semi-annealed approximation we estimate \[\begin{align} \mathbb{Z}(\mathcal{F}; \mathcal{G}) \approx \overline{M}^{\ell-m} \overline{O}^\ell e^{\tilde{n} (\ell-m) + p \log e/v} e^{\tilde{m} \ell + q \log e/v'} \end{align}\] We now apply the scaling symmetry of the model to restore \(\beta\) [22]; this amounts to making replacements \(\overline{M} \to \overline{M}^\beta, \overline{O} \to \overline{O}^\beta, \tilde{\epsilon}_d\to \tilde{\epsilon}_d/\beta^2, \tilde{\epsilon}_s\to \tilde{\epsilon}_s/\beta^2\).
We extract the energy and Boltzmann entropy from \[\begin{align} \langle E \rangle & = -\partial\langle \log \mathbb{Z}\rangle/\partial\beta|_{\beta=1} \\ \langle S_{Bol} \rangle & = \langle \log \mathbb{Z}\rangle + \langle E \rangle \end{align}\] and finally decompose the Boltzmann entropy as [22] \[\begin{align} \langle S_{Bol} \rangle = (2\ell-2m) H_d + \ell H_{s|d} \end{align}\] in terms of the Shannon entropy rates of the interior (\(H_d\)), and surface, conditional on interior (\(H_{s|d}\)). At small \(\tilde{\epsilon}_s\) this conditional entropy can be written [22] \(H_{s|d} \approx H_s - H_d\) in terms of the entropy rate of the surface \(H_s\). In the limit of a deterministic surface layer, \(H_{s|d}=0\) and \(H_s=H_d\).
Note that these quantities will in general depend on the corpus length \(\ell\). The asymptotic entropy rate is obtained from the putative limit \(\ell \to \infty\).
In what follows, we focus on the contributions from the hidden variables. This is motivated by the data-processing inequality [35]: the surface layer can only lose information, and alone it cannot generate long-range correlations, so it is natural to consider a deterministic surface layer. Linguistically, this amounts to the statement that the hidden symbols are so refined as to encode all possible features of each word; then for a given language, each hidden symbol has a unique observable symbol (terminal).
The hidden entropy rate in a corpus of length \(\ell\) is \[\begin{align} H_d(\ell) = \frac{1}{2}\left[ 1 - \partial_{\beta} \right]_{\beta=1} \left[ \tilde{n} + \frac{p}{n} \log e/v \right] \end{align}\] Note that \[\begin{align} \tilde{n} = X_* - \log z \end{align}\] and we have \(X_* = \beta\sqrt{ w/2\tilde{\epsilon}_d}\) whose contribution drops from the entropy, \(X_*-\partial_\beta X_*=0\) at \(\beta=1\). So the entropy depends on \(z, v,\) and \(p\).
In the frozen regime we have \[\begin{align} \log z & = \log k_* + \frac{3}{2k_*} - \log (p/N) \\ & = \log (3/2) - \log \log \alpha + \log \alpha - \log (p/N) \\ & = C - \log a + F_z (\log G^{2/3}) \end{align}\] with \(C = 2 \log (3/2) - \frac{1}{2}\log (2\pi e^3)\) and \[\begin{align} F_z (L) & = -2 \log \log \alpha + \log \alpha - \frac{3 L}{1+ \alpha} \end{align}\] We also have \[\begin{align} \frac{p}{n} \log e/v & = \frac{2}{3} a \sqrt{2\pi e^3} \log(\alpha ) G^{\beta(G)} \frac{N}{n} \left[ 1 - \frac{1}{1+\alpha} \log G \right] \\ & = F_p(\log G^{2/3}) \end{align}\] with \[\begin{align} F_p(L) = \frac{2}{3} \sqrt{2\pi e^3} \log(\alpha ) e^{ \frac{3}{2} L \frac{1-\alpha}{1+\alpha}} \left[ 1 - \frac{3L/2}{1+\alpha} \right] \end{align}\] and we note that \(\alpha(L) = L \log L + \ldots\).
Thus after setting \(a \to a/\beta\) to take the derivatives we get \[\begin{align} \label{Hd} H_d(\ell) = \frac{1}{2}\left[ -C - 1 + \log a - F(L) + \frac{2}{3} F'(L) \right] \end{align}\tag{25}\] with \(F(L) = F_z(L) - F_p(L)\). The \(\ell, m\) and \(N\) dependence has collapsed into \(L=\log G^{2/3}\) with \(G = (\ell-m)/(Na)\).
The asymptotic entropy rate would be obtained from \(\lim_{\ell \to \infty} H_d(\ell)\). Note however that \(F(L) \sim \log L \sim \log \log \ell\) as \(\ell \to \infty\), so in fact Eq.@eq:Hd predicts that the entropy rate is never attained. This is an artifact of the semi-annealed approximation, since at large enough \(G\) the semi-annealed saddle becomes unphysical. However this dependence is so slow that it is not a problem in practice. For example at \(G=10^{12}\) we have \(\log \log G - \frac{2}{\log \log G} - \log \log \log G \approx 1.5\). Hence we can consider a convenient renormalization scale \(\ell_\infty\) to define the entropy rate. Ignoring the slow factors we get \[\begin{align} \label{Hd2} H_d(\ell_\infty) \approx \frac{1}{4} \log 8x + \text{const} \qquad x\ll 1/8 \end{align}\tag{26}\] As shown in Fig.7a in the dotted and dash-dotted lines, this correctly predicts the logarithmic behavior in the frozen regime, with the correct prefactor \(1/4\).
Later we will use the finite-\(\ell\) dependence. The leading term gives \[\begin{align} \label{Hd3} H_d(\ell) - H_d(\ell_\infty) \approx \text{const} - \frac{1}{2}\log \alpha \qquad x\ll 1/8 \end{align}\tag{27}\]
Although not accessed in our numerics, theory predicts a crossover to a very low-temperature saturation regime at \(x<x_{lo}\) where \(H_d\) asymptotes.
For \(x<1/8\) but close to \(1/8\) we obtain another contribution from the singularity at \(x=1/8\). We have \[\begin{align} \log z & = - \log a - \frac{3}{k_* - a } + \ldots \end{align}\] with \(k_* \approx \frac{3}{4} + \frac{1}{2}a + \frac{1}{2}\sqrt{a^2 + a + \frac{9}{4}}\). Then we get (with \(a \sim \sqrt{8x}/\beta\)) \[\begin{align} \label{Hc} H_d(\ell_\infty) \approx \frac{1}{4} \log 8x + \frac{3k_*/2}{(k_*-\sqrt{8x})^2} + \text{const} \qquad x \approx 1/8 \end{align}\tag{28}\] Call this prediction \(H_{hi}(x)\). It predicts the observed steepening of \(H_d\) as \(x \to 1/8^-\), as shown in Fig.7a (dashed curve).
In the transition regime we need both \(\log z\) and the \(p/n\) terms. We have, in the scaling limit, \(-\log z + (p/n)\log(e/v) = 1 + \chi \log N + \ldots\) so that \[\begin{align} H_d(\ell_\infty) & \approx \left(1 - \frac{1}{8x} \right) \log N + \frac{1}{2} \qquad 1/8<x<1/2 \end{align}\] independent of \(\ell_\infty\) in this approximation.
This result is very interesting as it implies a change of scaling \(H_d \sim \log N\) for \(x>1/8\) to \(H_d \sim 1\) for \(x<1/8\). This is visible in Fig.7a, and in plots of normalized entropy, e.g. Fig. 2 of [17]. In the scaling limit it implies that \(x\approx 1/2\) is where we will first see the entropy drop from its maximal value, although for large enough \(N\) it will be \(\mathcal{O}(\log N)\) until \(x=1/8\).
We likewise obtain results for the energy. We restrict to the hidden part of energy, \(E_d\), which is obtained from the part of \(\log Z\) proportional to \(\ell-m\). This leads to \[\begin{align} \langle E_d \rangle & = - \left.\frac{\partial}{\partial\beta}\right|_{\beta=1} \left[ \beta \log \bar M + \tilde{n}(\beta) + \frac{p}{\ell-m} \log e/v \right] \notag\\ & = \log N^2 - \begin{cases} \frac{1}{2\tilde{\epsilon}_d} & x \gtrsim 1/8 \\ \sqrt{\frac{w}{2\tilde{\epsilon}_d}} + \ldots& x < 1/8 \end{cases} , \end{align}\] where we neglect subleading terms. In the frozen regime the leading term is \(2 - \langle E_d \rangle/\log N = \sqrt{w/ 2\tilde{\epsilon}_d\log^2 N} \approx \sqrt{2/x}\). Note that the two regimes match at \(2 w \tilde{\epsilon}_d= 1\) which reduces to \(x = 1/8 + \tilde{\epsilon}_d/4 \log (\pi/\tilde{\epsilon}_d)\); in the scaling limit this becomes \(x=1/8\) as expected. Hence \(\langle E_d \rangle\) is continuous in the semi-annealed approximation, and clearly shows the phase transition at \(x_c=1/8\).
The theoretical predictions are compared with numerics in Fig.7b. They are quantitatively good, only entailing a small error near the transition point.
The relations \(p \sim (\ell-m)^\beta\) and \(q \sim \ell^{\beta'}\) for the number of unique hidden and lexical rules in a corpus of total length \(\ell\) are related to a known linguistic law called Heaps law [2]. The latter states that the number of unique words in a corpus of length \(\ell\) satisfies \(n_* \sim \ell^b\) where \(b \approx 1/2\). The two laws are not identical, because we can have multiple rules \(a \to B\) for different hidden symbols \(a\) that yield the same word \(B\). However since the rules are iid in the RLM, we can derive the needed law.
Indeed, a word \(B\) appears in a corpus if and only if at least one lexical rule yields \(B\). Since the words are uniform, the probability that \(B\) doesn’t appear is \((1-1/T)^q\). Then the expected number of unique words is \[\begin{align} \label{Heaps} n_* = T \left( 1 - \left(1-\frac{1}{T} \right)^q \right) \approx T (1 - e^{-q/T} ) \end{align}\tag{29}\] where the latter expression holds if \(q \lesssim T\). Thus if \(q \sim \ell^{\beta'}\) then we predict \(n_* \sim \ell^{\beta'}\) for \(q \ll T\), which is exactly Heaps law. Moreover, we predict \(\beta' = 1/2\) near \(y=1/4\), which is exactly the most typically reported value.
A detailed analysis on large texts [6] found values \(b = 0.54, 0.52, 0.60, 0.47,\) and \(0.51\) for English, French, German, Hebrew, and Spanish, respectively. Two languages, Chinese and Russian, showed a two-regime law, with \(b = 0.77\) and \(b=0.65\) when fit to a single power law. The empirical results are in quite remarkable agreement with the theory. Above we found that in the transition region we have approximately \(\beta = 0.5\), while \(\beta = 0.53..\) near the critical point \(x=1/8\), and that \(\beta\) (and likewise for \(\beta'\)) will gradually decrease as \(x\) (\(y\)) decreases. Note that the predictions for \(\beta'\) are identical in the corresponding regime. Thus the data supports that languages are not far from the freezing transition at \(x=1/8, y=1/4\).
The prediction Eq.@eq:Heaps actually implies a saturation of Heaps law as \(q \to T\), i.e. when the corpus exhausts the vocabulary. The approach of saturation is visible in the plots of [6].
Heaps law is related to Zipf’s law [1], [36], the power-law relationship between the frequency of a word \(f_B\) and its rank, \(r_B\), with \(f_B \propto r_B^{-\zeta}\) and \(\zeta \approx 1\). This relationship can be expressed in terms of the probability of a word frequency \(f\), \(\mathbb{P}(f) \sim f^{-\alpha}\). Asymptotically \(\alpha = 1 + 1/\zeta\) [7], but it was noted in [7] that \(\mathbb{P}(f)\) generally shows two regimes with distinct exponents \(\alpha_\pm\), \(\mathbb{P}(f) \sim f^{-\alpha_-}\) for \(f < f_*\) and \(\mathbb{P}(f) \sim f^{-\alpha_+}\) for \(f > f_*\) . In this case \(\alpha_+ = 1+1/\zeta\) but no simple relation holds for \(\alpha_-\). In the absence of two-regime scaling, \(b=1/\zeta\).
In principle it should be possible to extract a \(\mathbb{P}(f)\) from the theory, but it does not appear straightforward. It was shown empirically in [17] that a two-regime Zipf law is reproduced by the RLM.
Heaps’ law can also be rationalized by a sample-space-reducing model in which the number of accessible states decreases as a text is written [37], [38]. Such models, however, fail to match the observed correlation structure between words. This structure is captured implicitly by the dependence of entropy on text length, to which we turn next.
Recently, Ref.[40] measured the code length \(\mathcal{L} = -\langle \log P(x_0 | x_{-K},x_{-K+1},\ldots x_{-1}) \rangle\) of natural language, as a function of context length \(K\). \(\mathcal{L}\) is a proxy for the entropy rate over text blocks of length \(K\), and it has the same behavior over different datasets and models [40]. In all cases it was observed that \(\mathcal{L}\) decreases approximately logarithmically with \(K\); see the red curve in Fig.8 for an example, measured from OLMo 2 [39], a Large Language Model with \(10^9\) parameters.
We model these results as follows: since grammar-based codes are universal [18], we can model any source as a stochastic context-free grammar, and thus place any source in the RLM phase diagram. We obtain a prediction for \(\mathcal{L}\) by assuming that tokens are in one-to-one correspondence with hidden symbols, and that the surface layer is a deterministic map, as discussed above. Since we expect the number of hidden symbols to be very large, and the entropy rate of natural language is finite, we expect the data to be in the frozen regime. Then from Eq.@eq:Hd3 , we obtain \[\begin{align} \mathcal{L}(K) = \text{const} - \frac{1}{2}\log \alpha + \ldots \end{align}\] in nats/token, where \(\alpha(G) = e^{-W_{-1}(-1/\log G^{2/3})} \approx \log G^{2/3} \log \log G^{2/3}\) and we have \(G = K/Na\) since \(K\) plays the role of corpus length. To convert to an entropy rate in bits/character we multiply by \(1/(n_{c/t}\log 2)\) where \(n_{c/t}=4.79\) is the number of characters per token in this dataset [40]. This expression is only expected to hold for large enough \(G\). The theoretical expression has two fitting parameters: the additive constant, and the product \(Na\). With \(Na \approx 2.2\) we obtain a good fit (Fig.8, blue curve) over the entire range that the solution exists, that is \(G \gtrsim 59\).
In this work we have developed a controlled theory of the Random Language Model in a (double) scaling limit where the grammar temperature \(\tilde{\epsilon}_d\to 0\) and the number of hidden symbols \(N\to \infty\) at fixed \(x = \tilde{\epsilon}_d\log N\). In this limit, the model exhibits a condensation transition at \(x_c=1/8\), inherited from the Random Energy Model, and governed by the breakdown of the law of large numbers in sums over grammar weights. This resolves the apparent paradox between finite-\(N\) numerical results, which show smooth crossover behavior, and the existence of a sharp transition in the thermodynamic limit. We focus on the regime of a large corpus, \(G \gg 1\) where \(G \sim n/N\sqrt{8x}\) is a rescaled corpus length that emerges from the theory.
The key technical step is the reorganization of the partition function as a sum over patterns, characterized by their rule multiplicity spectrum \(\{ p_k, q_k \}\). This leads to a semi-annealed description in which the dominant contribution arises from a saddle-point pattern. Within this framework, the number of distinct rules \(p\), or equivalently the ratio \(p/N\), emerges as a natural order parameter. In the high-temperature (“babbling") regime, weight is distributed over many rules and \(p/N \sim G\), corresponding to delocalized grammar usage and high entropy. In contrast, below \(x_c\) the model enters a frozen phase in which weight condenses onto a small subset of rules, \(p/N \sim G^{\beta(G)}\) where \(\beta(G) < 1\) is nontrivial, leading to low entropy and strongly constrained structure. The transition between these regimes is continuous in finite systems but sharp in the scaling limit.
The semi-annealed theory provides explicit predictions for the rule spectrum, entropy, and energy, and explains the scaling of the number of distinct rules with corpus size and temperature. In particular, it rationalizes the emergence of Heaps’ law and its continuously varying exponent as a function of \(x\), and connects these behaviors to the proximity of the system to the condensation transition. More generally, the theory shows how coarse-grained statistical regularities of language can arise from an ensemble of generative grammars through a well-defined statistical-mechanical mechanism.
The framework also provides a natural interpretation of recent observations in large language models. Retaining the corpus-length dependence of entropy (or code length) in the theory, we capture empirical measurements over several orders of magnitude in context length.
Several directions remain open. A more complete treatment of the quenched problem, beyond the semi-annealed approximation, would further clarify the nature of fluctuations around the saddle-point pattern. It would also be of interest to extend the analysis to richer grammatical structures beyond context-free rules [41], [42], and to connect the present static theory to dynamical or learning-based formulations, in which the parameters \(x\) and \(N\) emerge from training processes. Similarly, although the present results suggest that many features of natural language are captured by the purely random ensemble, it would be useful to incorporate grammatical parameters, and their known phylogenetic relations, into the theory [43]–[45].
More broadly, our results suggest that universal statistical properties of language may be understood as consequences of an underlying condensation transition in the space of generative models.
Finally, the semi-annealed construction is not specific to language, but applies more broadly to systems in which macroscopic behavior is controlled by rare configurations selected from a disordered ensemble. Examples include glasses [46], optimization landscapes in machine learning, random Markov systems [47], [48], random growth processes [49], and evolutionary fitness
landscapes, where dominant states arise from extreme-value statistics but must be described in terms of coarse-grained, permutation-invariant observables.
Acknowledgments: EDG acknowledges conversations with Alessio Giorlandino, Sebastian Goldt, and Alessandro Treves, and NSERC Discovery Grant RGPIN-2020-04762.
Suppose we have \(p\) rules \(a_r \to b_r c_r\), \(r = 1, \ldots, p\) and \(q\) rules \(t_r \to B_r\). Write \[\begin{align} M_{abc} = \sum_r \delta_{(abc),(a_r,b_r,c_r)}, \quad O_{aB} = \sum_r \delta_{(aB),(t_r,B_r)} . \end{align}\] The partition function \(\mathbb{Z}(\mathcal{G}; m,\ell)\) then counts how many configurations can be made with this grammar. We will evaluate this, averaged over the identities of the rules, in the annealed approximation. Using the diagrammatic representation the grammar contributes through a term \[\begin{align} e^{\eta \sum_{abc} M_{abc} H_a L_b R_c} , \end{align}\] which can be grammar-averaged, assuming independence of rules, to obtain \[\begin{align} \overline{ e^{\eta \sum_{abc} M_{abc} H_a L_b R_c} } & = \prod_{r=1}^{p} \left( \frac{1}{N^3} \sum_{a_r=1}^N \sum_{b_r=1}^N \sum_{c_r=1}^N e^{\eta \sum_{abc} \delta_{(abc),(a_r,b_r,c_r)} H_a L_b R_c} \right) \\ & = \prod_{r=1}^{p} \left( \frac{1}{N^3} \sum_{a_r=1}^N \sum_{b_r=1}^N \sum_{c_r=1}^N e^{\eta H_{a_r} L_{b_r} R_{c_r}} \right) \\ & = ( S/N^3)^p \end{align}\] with \(S= \sum_{a,b,c} e^{\eta H_{a} L_{b} R_{c}}\). Likewise the average over terminal rules gives \[\begin{align} \overline{ e^{\xi \sum_{a,B} O_{aB} H_a} } & = \prod_{r=1}^{q} \left( \frac{1}{NT} \sum_{t_r=1}^N \sum_{B_r=1}^T e^{\xi H_{t_r} } \right) \\ & = ( S'/N)^q \end{align}\] with \(S' = \sum_a e^{\xi H_a}\).
The same arguments as in [19] imply that \(Z\) is dominated by a saddle-point. The saddle-point equations are \[\begin{align} L_a & = g q S'^{-1} \xi e^{\xi H_a} + g p S^{-1} \eta \sum_{b,c} L_b R_c e^{\eta H_{a} L_{b} R_{c}} \tag{30}\\ R_a & = g q S'^{-1} \xi e^{\xi H_a} + g p S^{-1} \eta \sum_{b,c} L_b R_c e^{\eta H_{a} L_{b} R_{c}} \tag{31}\\ L^\dagger_a & = g h \zeta \delta_{a1} + g p S^{-1} \eta \sum_{a',c} H_{a'} R_c e^{\eta H_{a'} L_{a} R_{c}} \tag{32} \\ R^\dagger_a & = g h \zeta \delta_{a1} + g p S^{-1} \eta \sum_{a',b} H_{a'} L_b e^{\eta H_{a'} L_{b} R_{a}} \tag{33} \\ \ell-m & = p S^{-1} \eta \sum_{a,b,c} H_a L_b R_c e^{\eta H_{a} L_{b} R_{c}} \tag{34} \\ \ell & = q S'^{-1} \xi \sum_{a} H_a e^{\xi H_a} \tag{35} \\ m & = \zeta h (L_1+R_1) \tag{36} \end{align}\] Subtracting the first two equations implies \(L_a=R_a\). Adding the third and fourth closes the equations in terms of \(H_a= L^\dagger_a+R^\dagger_a\): \[\begin{align} H_a & = 2 g h \zeta \delta_{a1} + 2 g p S^{-1} \eta \sum_{a',b} H_{a'} L_b e^{\eta H_{a'} L_{b} L_{a}} \label{cjskqwoi} \end{align}\tag{37}\] Note that \[\begin{align} \sum_a L_a H_a & = 2 g h \zeta L_1 + 2 g p S^{-1} \eta \sum_{a,a',b} H_{a'} L_a L_b e^{\eta H_{a'} L_{b} L_{a}} \\ & = gm + 2 g (\ell-m) \end{align}\] so that the partition function at the saddle-point is \[\begin{align} \overline{ \mathbb{Z}(\mathcal{G}; m,\ell) } & = \frac{m!}{\zeta^m \xi^\ell \eta^{\ell-m} } e^{-\frac{1}{g} \sum_a L_a H_a} e^{\zeta h (L_1+R_1) + q \log (S'/N) + p \log (S/N^3) } \\ & = \frac{m!}{\zeta^m \xi^\ell \eta^{\ell-m} } e^{-(2\ell-m)} e^{m} (S'/N)^q (S/N^3)^p . \end{align}\] The saddle-point equations have no disorder, so they will have a simple solution \(H_a=H_*\) for all \(a>1\), and likewise for \(L_a\). Then we have the system \[\begin{align} L_1 & = g q S'^{-1} \xi e^{\xi H_a} + g p S^{-1} \eta \sum_{b,c} L_b L_c e^{\eta H_{1} L_{b} L_{c}} \\ L_* & = g q S'^{-1} \xi e^{\xi H_a} + g p S^{-1} \eta \sum_{b,c} L_b L_c e^{\eta H_{*} L_{b} L_{c}} \\ H_1 & = 2g h \zeta + 2g p S^{-1} \eta \sum_{a',c} H_{a'} L_c e^{\eta H_{a'} L_{1} L_{c}} \\ H_* & = 2g p S^{-1} \eta \sum_{a',c} H_{a'} L_c e^{\eta H_{a'} L_{*} L_{c}} \\ \ell-m & = p S^{-1} \eta \sum_{a,b,c} H_a L_b L_c e^{\eta H_{a} L_{b} L_{c}} \\ \ell & = q S'^{-1}\xi \sum_{a} H_a e^{\xi H_a} \\ m & = 2\zeta h L_1 \\ S & = \sum_{a,b,c} e^{\eta H_{a} L_{b} L_{c}} \\ S' & = \sum_a e^{\xi H_a} \end{align}\] This system has a one-parameter scaling symmetry \[\begin{align} \xi \to c \xi, \quad H \to (1/c) H, \quad L \to c L, \quad \eta \to (1/c) \eta, \quad \zeta \to (1/c) \zeta \end{align}\] for any \(c\), which allows us to fix \(\zeta=1\) and hence \(L_1 = m/(2h)\).
There are various possible regimes of interest depending upon the scaling of \(\ell\) and \(m\) with \(N\). We assume \(p \sim N\).
The most important regime is when the average tree length \(\ell/m\) is large, because then correlation lengths can be large. This should also be the simplest, because the root plays a less important role. In this case we can seek a solution with \(H_1 \sim H_*\) and \(L_1 \sim L_*\). In the large \(N\) limit the contributions of the root would then be negligible compared to the bulk in all sums, giving \[\begin{align} L_1 & = g q S'^{-1} \xi e^{\xi H_1} + g p S^{-1} \eta (N-1)^2 L_*^2 e^{\eta H_{1} L_*^2 } \\ L_* & = g q S'^{-1} \xi e^{\xi H_*} + g p S^{-1} \eta (N-1)^2 L_*^2 e^{\eta H_{*} L_*^2} \\ H_1 & = 2g h + 2g p S^{-1} \eta (N-1)^2 H_{*} L_* e^{\eta H_{*} L_{1} L_*} \\ H_* & = 2g p S^{-1} \eta (N-1)^2 H_{*} L_* e^{\eta H_{*} L_{*}^2 } \\ \ell-m & = p S^{-1} \eta (N-1)^3 H_* L_*^2 e^{\eta H_{*} L_{*}^2 } \\ \ell & = q S'^{-1} \xi (N-1) H_* e^{\xi H_*} \\ S & = (N-1)^3 e^{\eta H_{*} L_*^2 } , \\ S' &= (N-1) e^{\xi H_*} \end{align}\] which reduces to \[\begin{align} L_* & = g (q/N) \xi + g (p/N) \eta L_*^2 \\ \ell-m & = p \eta H_* L_*^2 \\ \ell & = q \xi H_* \\ H_* & = 2g (p/N) \eta H_{*} L_* \end{align}\] and then to \[\begin{align} L_* & = g \ell /(N H_*) + (g/N) (\ell-m) /H_*\\ H_* & = 2(g/N) (\ell-m)/L_*. \end{align}\] For \(m/\ell \to 0\) in the large \(N\) limit these are degenerate but consistent and give \(H_*L_* = 2g\ell/N\). It follows \(\eta = \ell/(p H_*L_*^2) = N/(2g p L_*)\) and then we have, using \(S = N^3 e^{\ell/p}\), \[\begin{align} L_1 & = g \ell/(N H_*) + g p N^{-1} e^{-\ell/p} \eta L_*^2 e^{\eta H_{1} L_*^2 } \\ H_1 & = 2g h + 2g p N^{-1} e^{-\ell/p} \eta H_{*} L_* e^{\eta H_{*} L_{1} L_*} \end{align}\] which become \[\begin{align} L_1 & = g \ell/(N H_*) + \frac{1}{2}e^{-\ell/p} L_* e^{N H_{1} L_* /(2gp) } \\ H_1 & = 2g h + e^{-\ell/p} H_{*} e^{N H_{*} L_{1} /(2gp) } \end{align}\] and then \[\begin{align} H_* L_1 & = g \ell/N + \frac{1}{2}e^{-\ell/p} (2g\ell/N) e^{N H_{1} L_* /(2gp) } \\ H_1 L_* & = 2g h L_* + e^{-\ell/p} (2g\ell/N) e^{N H_{*} L_{1} /(2gp) } \end{align}\] These are nontrivial but consistent if \(m/\ell \to 0\) as \(N \to \infty\). Since \(L_1 \sim m\) we get \(H_* \sim 1/m\) and we see that \(H_1 \sim 1, L_* \sim 1\). This allows a weak divergence of \(m\) with \(N\). For example, in \(S\) we have \[\begin{align} S = N^3 e^{\eta H_* L_*^2} + 2N^2 e^{\eta H_* L_* L_1} + \ldots \end{align}\] which can be dominated by the second term if, assuming \(\eta H_* L_*^2 \approx \ell/p\) as above, \(N \ll 2 e^{(L_1/L_*-1)(\ell/p)}\), i.e. \(m > 1 + (p/\ell) \log N\). Therefore to avoid this, \(m\) cannot grow faster than \((p/\ell) \log N\).
The partition function becomes \[\begin{align} \overline{ \mathbb{Z}(\mathcal{G}; m,\ell) } & = m! e^{-2\ell+2m} (N/(2g p L_*))^m (\ell N/(2g q p H_* L_*))^{-\ell} (e^{\ell/q})^q (e^{\ell/p})^p \\ & = m! e^{2m} (N/(2g p L_*))^m (N^2 /(4g^2 pq))^{-\ell} \end{align}\] so that the leading behavior of \(\log\overline{ \mathbb{Z}(\mathcal{G}; m,\ell) }\) is \[\begin{align} \log\overline{ \mathbb{Z}(\mathcal{G}; m,\ell) } = \ell \log (4g^2) + \ell \log (q/N) + (\ell-m)\log (p/N) + \ldots \end{align}\] with corrections proportional to \(m\). This result matches expectations: the term \(\ell \log (4g^2)\) is the entropy of trees, while \((\ell-m)\log (p/N) + \ell \log (q/N)\) is the entropy of derivations on the trees. The latter is exactly what is predicted by counting derivations.
To examine the corrections, we have \[\begin{align} H_* L_1 = \frac{2gp}{N} \left[ \ell/p + \log (N/2g\ell) + \log(H_1L_*-2ghL_*) \right] \end{align}\] and then \[\begin{align} \ell e^{-\ell/p} e^{N H_{1} L_* /(2gp) } = \ell + 2p \log (N/2g\ell) + 2p \log(H_1L_*-2ghL_*) \end{align}\] giving \(H_1 L_* \approx 2g\ell/N\) up to logarithmic corrections. Similarly \(H_* L_1 \approx 2g\ell/N\). To obtain the corrections we write \(H_1 L_* = 2g\ell/N + a\), \(H_* L_1 = 2g\ell/N + b\), giving \[\begin{align} b & = (g\ell/N) \left[ e^{N a /(2gp) } -1 \right] \\ a & = 2g h L_* + (2g\ell/N) \left[ e^{N b /(2gp) } -1 \right] . \end{align}\] Assuming that \(a\) and \(b\) are small (since \(2g\ell/N \sim 1\)) we get \(b \approx a \ell/(2p)\) and then \(2gh L_* = a - \ell b/p = a ( 1 - \ell^2/2p^2)\). This yields \[\begin{align} & N h L_*^2 ( 1 - \ell^2/(2p^2))^{-1} + 2 p L_* - mp/h = 0 \\ \end{align}\] and finally \[\begin{align} L_* & = \frac{2p^2 - \ell^2}{4pNh} \left[ - 1 \pm \sqrt{ 1 + \frac{4pmN}{2p^2 - \ell^2} } \right] \\ & \approx \frac{\sqrt{2p^2 - \ell^2}}{2h\sqrt{pN/m}} , \end{align}\] valid for \(p>\ell/\sqrt{2}\). The approximation further requires \(a,b \lesssim 1\) which reduce to \[\begin{align} \frac{4p^2 g^2}{( 2p^2 - \ell^2)} \frac{m p}{ N} \lesssim 1 \end{align}\] which can only hold if5 \(\ell < \sqrt{2} p \lesssim 4\sqrt{2} N m\). This means that the average sentence length \(\ell/m\) cannot grow faster than linearly in \(N\).
The above results can be extended to computation of \(\overline{ \log \mathbb{Z}}\), the quenched average over grammars. Using the replica method \[\begin{align} \overline{ \log \mathbb{Z}} = \overline{ \lim_{q \to 0} d(\mathbb{Z}^q)/dq } = \lim_{q \to 0} d\overline{\mathbb{Z}^q}/dq \end{align}\] we need to replicate all \(\{ \eta, \zeta, \xi, L_a, R_a \}\), adding a replica index \(\alpha = 1,\ldots,q\). The key point is that the exponential coupling gets replaced by \[\begin{align} e^{\eta H_a L_a R_a} \to e^{\sum_\alpha \eta_\alpha H_a^\alpha L_a^\alpha R_a^\alpha} , \end{align}\] and likewise for \(e^{\xi H_a}\), which does not affect the structure of the saddle-point equations. If we make the same assumption \(L_a^\alpha = L_*^\alpha\) for \(a>1\), then it is easily shown that all replicas are identical, so that \(\overline{\log \mathbb{Z}} = \log \overline{\mathbb{Z}}\).
Thus the only way to find more general solutions is to break the symmetry among symbols. Preliminary attempts to find RLM solutions breaking the symbol symmetry were reported in [50].
Suppose we have \(p\) rules \(r= 1, \ldots, p\) with \(\pi_r\) copies of each rule. We want to count the number of ways to place these into \(m_c\) piles \(j = 1,\ldots,m_c\) such that each pile has \(\ell_c\) rules, counted with multiplicity. Consistency requires that \(\sum_r \pi_r = \ell_c m_c = n\).
Let \(A_{rj}\) be the number of rule \(r\) placed into pile \(j\). Then, considered as a matrix, \(A\) has both imposed row sums and imposed column sums. Understanding such “contingency tables" is a classical problem of statistics [51], and has been studied in combinatorics [52]. We use statistical physics methods that allow us to go beyond the leading order. We want to compute \[\begin{align} Z_c & = \sum_{ \{ A_{rj} \} } \prod_{r=1}^{p-1} \delta_{\pi_r - \sum_j A_{rj}} \prod_{j=1}^{m_c} \delta_{\ell_c - \sum_r A_{rj} } \\ & = \sum_{ \{ A_{rj} \} } \prod_{r=1}^{p-1} \int_0^{2\pi} \frac{d\lambda_r}{2\pi} e^{ i\lambda_r (\pi_r - \sum_j A_{rj}) } \prod_{j=1}^{m_c} \int_0^{2\pi} \frac{d\gamma_j}{2\pi} e^{i\gamma_j (\ell_c - \sum_r A_{rj}) } \notag\\ & = \prod_{r=1}^{p-1} \int_0^{2\pi} \frac{d\lambda_r}{2\pi} e^{ i\lambda_r \pi_r } \prod_{j=1}^{m_c} \int_0^{2\pi} \frac{d\gamma_j}{2\pi} e^{i\gamma_j \ell_c } \prod_{r} \prod_{j} (1 - e^{-i\lambda_r \Theta_{p-r} - i\gamma_j } )^{-1} \notag \end{align}\] where the Kronecker \(\delta\)’s enforce the constraints. Note that \(r\) only runs from \(1\) to \(p-1\) in the constraints because one of the constraints is redundant, due to the consistency relation. In the third line, \(\Theta_{p-r}\) is 1 except when \(r=p\). The regime of interest is when \(\ell_c\) is large, so we can seek a saddle-point. The action is \[\begin{align} S = -\sum_{r < p} i\lambda_r \pi_r - \sum_{j \leq m_c} i\gamma_j \ell_c + \sum_r \sum_j \log(1 - e^{-i\lambda_r \Theta_{p-r} - i\gamma_j }) \end{align}\] and the saddle-point equations are \[\begin{align} \pi_r & = \sum_{j} (1 - e^{-i\lambda_r - i\gamma_j } )^{-1} e^{-i\lambda_r - i\gamma_j } \\ \ell_c & = \sum_{r \leq p} (1 - e^{-i\lambda_r \Theta_{p-r} - i\gamma_j } )^{-1} e^{-i\lambda_r \Theta_{p-r} - i\gamma_j } \end{align}\] The \(\gamma_j\) equations have a solution \(\gamma_j=\gamma\) for all \(j\). This leads to \[\begin{align} \pi_r & = m_c (e^{i\lambda_r + i\gamma } -1 )^{-1} \\ \ell_c & = \sum_{r<p} (e^{i\lambda_r + i\gamma } -1 )^{-1} + (e^{i\gamma } -1 )^{-1} \end{align}\] and then \[\begin{align} i\lambda_r & = -i\gamma + \log (1 + m_c/\pi_r) \\ \ell_c & = \sum_{r<p} (\pi_r/m_c) + (e^{i\gamma } -1 )^{-1} = (n-\pi_p)/m_c + (e^{i\gamma } -1 )^{-1} \end{align}\] The second equation yields \(i\gamma = \log (1 + m_c/\pi_p)\). Evaluating the action we have \[\begin{align} S|_{SP} & = -\sum_{r < p} [-i\gamma + \log (1 + m_c/\pi_r)] \pi_r - m_c [\log (1 + m_c/\pi_p)] \ell_c \notag\\ &\qquad + \sum_{r<p} m_c \log(1 - 1/(1+m_c/\pi_r)) + m_c \log(1 - 1/(1+m_c/\pi_p)) \notag \\ & = i\gamma (n-\pi_p) - \sum_{r < p} \pi_r \log (1 + m_c/\pi_r) - n \log (1 + m_c/\pi_p) \notag\\ &\qquad + \sum_{r \leq p} m_c \log(m_c/(\pi_r+m_c)) \notag \\ & = - \sum_{r \leq p} \pi_r \log (1 + m_c/\pi_r) - \sum_{r \leq p} m_c \log(1+\pi_r/m_c) \end{align}\] All dependence on the special index \(r=p\) has disappeared, as it must.
Note that, using Stirling, \[\begin{align} \prod_{k \geq 1} \binom{k + m_c - 1}{m_c-1}^{p_k} &= \prod_r \binom{\pi_r + m_c - 1}{m_c-1} \\ & \sim \frac{(\pi_r+m_c-1)^{\pi_r+m_c-1}}{(m_c-1)^{m_c-1}\pi_r^{\pi_r}} \\ & = \prod_r \left(1+\frac{m_c-1}{\pi_r} \right)^{\pi_r} \left(1+\frac{\pi_r}{m_c-1} \right)^{m_c-1} \\ & \sim e^{-S|_{SP}} \end{align}\] for \(m_c \gg 1\). This leading estimate agrees with a classical approximation of Good [51]. It implies that when \(m_c \gg 1\) the argument given in the main text, which does not enforce that each pile have strictly \(\ell_c\) rules, gives the same result as the leading saddle-point contribution of the full computation.
The corrections are obtained by evaluating the Hessian at the saddle point. Starting from the nonlinear part of the action \[\begin{align} S_2 = \sum_{r<p} \sum_j \log(1 - e^{-i\lambda_r - i\gamma_j }) + \sum_j \log(1 - e^{- i\gamma_j }) \end{align}\] we have \[\begin{align} \partial_r S_2 & = i\sum_j (e^{i\lambda_r + i\gamma_j }-1)^{-1} \\ \partial_j S_2 & = i\sum_{r<p} (e^{i\lambda_r + i\gamma_j }-1)^{-1} + i(e^{i\gamma_j }-1)^{-1} \end{align}\] and then \[\begin{align} \partial_{r'} \partial_r S_2 & = \delta_{rr'} \sum_j (e^{i\lambda_r + i\gamma_j }-1)^{-2} e^{i\lambda_r + i\gamma_j } \\ \partial_j \partial_r S_2 & = (e^{i\lambda_r + i\gamma_j }-1)^{-2} e^{i\lambda_r + i\gamma_j } \\ \partial_{j'} \partial_j S_2 & = \delta_{jj'} [ \sum_{r<p} (e^{i\lambda_r + i\gamma_j }-1)^{-2} e^{i\lambda_r + i\gamma_j } + \sum_j (e^{i\gamma_j }-1)^{-2} e^{i\gamma_j } ] \end{align}\] The Hessian matrix, evaluated on the saddle-point, is \[\begin{align} H = \begin{bmatrix} \nabla_{r} \nabla_{r'} S_2 & \nabla_{r} \nabla_{j} S_2 \\ \nabla_{j'} \nabla_{r'} S_2 & \nabla_{j} \nabla_{j'} S_2 \end{bmatrix} = \begin{bmatrix} \delta_{rr'} m_c v_r & v_r \\ v_r & \delta_{jj'} a \end{bmatrix} \end{align}\] where \(r\) and \(r\) run from \(1\) to \(p-1\). Here \(v_r = \pi_r (\pi_r+m_c)/m_c^2\) and \(a= \sum_{r=1}^p v_r\). Its determinant is \[\begin{align} \det H & = a^{m_c-1} m_c^{p-1} \prod_{r=1}^p v_r \notag\\ & = \left[\sum_{k \geq 1} p_k k (k+m_c) \right]^{m_c-1} m_c^{-2m_c+2+p-1 -2p} \prod_{k \geq 1} ( k (k+m_c))^{p_k} \end{align}\] so that \[\begin{align} Z_c \approx e^{-S|_{SP}} (2\pi)^{-(m_c+p-1)/2} |\det H|^{-1/2} \end{align}\] Since \(S_{SP} \sim n\) while \(\log \det H \sim \max\{p,m_c\}\) the latter is subdominant as expected.
To orient ourselves consider the frozen regime \(r=0\), which means that \(x < 1/8\). Then \(\tilde{n}\) is fixed by \[\begin{align} n & = N e^{n/p} a \sum_{k\geq 1} \frac{k z^k}{k-a} \notag \\ & \approx N e^{n/p} a \sum_k z^k \notag \\ & = N e^{n/p} a z/(1-z) \end{align}\] where \(z = N^{a/2x} e^{-\tilde{n}}\) and we have assumed \(a \ll 1\), which is \(8x \ll 1\). This gives \[\begin{align} z^{-1} = 1 + e^{n/p}/G . \end{align}\] where \(G = n/Na\). We still have to fix \(p\) through \[\begin{align} p & = \sum_k p_k = N e^{n/p} a \sum_{k\geq 1} \frac{z^k}{k-a} \notag \\ & \approx N e^{n/p} a \sum_k z^k/k \notag \\ & = N e^{n/p} a \log(1/(1-z)) \end{align}\] whence \[\begin{align} n/p = W\left(G / \log(1/(1-z))\right) \end{align}\] and then \[\begin{align} z^{-1} & = 1 + \frac{1}{G} e^{W\left(G/\log(1/(1-z)) \right) } \\ & = 1 + \frac{1}{\log(1/(1-z)) W\left(G/\log(1/(1-z)) \right)} \end{align}\] which becomes \[\begin{align} \frac{z}{1-z} & = \log\left(\frac{1}{1-z}\right) W\left(\frac{G}{\log(1/(1-z))}\right) \end{align}\] This can be rewritten as \[\begin{align} \log \left(\frac{1}{1-z} \right) \frac{1-z}{z} \log \left(\frac{1-z}{z} G \right) = 1 \end{align}\] This simplifies if \(z \to 1^-\) in which it becomes \[\begin{align} \log(1-z) & \approx W_{-1}\left(-\frac{1}{\log G}\right) \\ & \approx -\log\log G -\log\log\log G \end{align}\] so that \(1-z \approx 1/(\log G \log \log G )\) which finally gives \(n/p = W(G / (\log\log G+\log\log\log G))\). The \(z \to 1^-\) regime is reached for small \(x\).
The result is that the rule use spectrum should follow \(p_k/p \propto z^k/k\) at small \(x\), asymptotically independent of \(x\) (since \(z \to 1^-\)). This is observed in the data (Fig.3ab).
This result breaks down as \(x \to 1/8^-\) because then the denominator \(k-a\sim k-\sqrt{8x}\) in the sums determining \(n\) and \(p\) has a singularity for \(k=1\); this singularity can be extracted separately, extending the theory to the critical region. This changes the \(n\) and \(p\) equations to \[\begin{align} n & = N e^{n/p} a \sum_{k\geq 1} \frac{k z^k}{k-a} \notag \\ & \approx N e^{n/p} a \left[ \frac{z}{1-a} + \sum_{k \geq 2} z^k \right] \notag \\ & = N e^{n/p} a \left[ \frac{z}{1/a -1 } + \frac{z}{1-z} \right] \end{align}\] and \[\begin{align} p & = \sum_k p_k = N e^{n/p} a \sum_{k\geq 1} \frac{z^k}{k-a} \notag \\ & \approx N e^{n/p} a \left[ \frac{z}{1-a} + \sum_{k \geq 2} z^k/k \right] \notag \\ & = N e^{n/p} a \left[ \frac{z}{1/a -1 } + \log(1/(1-z)) \right] \end{align}\] In the critical region \(\delta x = 1/8-x \ll 1\), we have \[\begin{align} G \approx e^{n/p} z [1/ (4\delta x) + 1], \qquad p/n = 1 + \mathcal{O}(\delta x) \end{align}\] Therefore \(x=1/8\) is where \(p/n \to 1\) from below, in finite trees.
For small trees it is convenient to make an approximation considering only the \(k=1\) and \(k=2\) terms in the sums. At high temperature and in small trees, most rules are used uniquely; if we keep only the \(k=1\) and \(k=2\) terms we have \[\begin{align} n & \approx N^3 e^{n/p} e^{-\tilde{n}} [ g_1 + 2 g_2 e^{-\tilde{n}}] \\ p & \approx N^3 e^{n/p} e^{-\tilde{n}} [ g_1 + g_2 e^{-\tilde{n}}] \end{align}\] so that \[\begin{align} e^{-\tilde{n}} & = \frac{-g_1}{4g_2} \left[ -1 + \sqrt{1 + \frac{8n g_2 e^{-n/p}}{N^3 g_1^2} } \right] \\ & \approx \frac{n}{N^3 g_1} e^{-n/p} \notag \end{align}\] and \[\begin{align} n/p = 1 + g_2 e^{-\tilde{n}}/(g_1 + g_2 e^{-\tilde{n}}) \end{align}\] This result can be used in the high-temperature regime \(x>1/8\).
Again start with the frozen regime \(r=0\), which means that \(x < 1/8\). Then \(\tilde{n}\) is fixed by \[\begin{align} n & = v N a \sum_k k \binom{k + m_c - 1}{m_c -1} \frac{ z^k }{ k-a } \\ & \approx v N a \sum_k \binom{k + m_c - 1}{m_c -1} z^k \\ & = v N a \left[ \frac{1}{(1 - z )^{m_c}} - 1 \right] \end{align}\] where we assume \(1 \gg a\), i.e. \(x \ll 1/8\). This is solved \[\begin{align} \label{z1} z = 1 - \left( 1 + G/v \right)^{-1/m_c} \end{align}\tag{38}\] Now we need to find \(p\) and \(v\). Since \(v = e^{\sum_{k'} \frac{p_{k'}}{N} \log \left(1+\frac{k'}{m_c-1}\right)}\) has only a logarithmic dependence on \(k\) beyond \(p_k\), we evaluate the log factor at the dominant \(k\) satisfying \(0 = \partial_k \phi(k)\) where the summand is written \(e^{\phi(k)}\), i.e. \[\begin{align} 0 & = \partial_k \left[ (k+m_c-1 + \frac{1}{2}) \log (k+m_c-1) - (k +\frac{1}{2}) \log k + k \log z - \log (k-a) \right] \\ &= \log \frac{k+m_c-1}{k} + \log z + \frac{1}{2(k+m_c-1)} - \frac{1}{2k} - \frac{1}{k-a} , \end{align}\] where for later convenience we include the term relevant in the critical region, with \(a = 2\tilde{\epsilon}_dX_* = \sqrt{2w\tilde{\epsilon}_d}\). This is \[\begin{align} \label{k1} 1 + \frac{m_c-1}{k_*} = \frac{\alpha}{z} \end{align}\tag{39}\] with \[\begin{align} \label{alpha} \alpha = e^{ \frac{1}{k_*-a} + \frac{1}{2k_*} -\frac{1}{2(k_*+m_c-1)} }. \end{align}\tag{40}\] We have \(\alpha > 1\). We also have \[\begin{align} p & = v N a \sum_k \binom{k + m_c - 1}{m_c -1} \frac{ z^k }{ k-a } \notag \\ & \approx (n v/G) \binom{k_* + m_c - 1}{m_c -1} \frac{z^{k_*}}{k_*-a} \sqrt{2\pi k_*} \end{align}\] where the \(\sqrt{2\pi k_*}\) factor comes from the fluctuations around the saddle-point, determined from \(\partial^2_k \phi|_{k=k_*} = 1/(k_*+m_c-1) - 1/k_* + \mathcal{O}(1/k_*^2) \approx -1/k_*\) for \(m_c \gg k_* \gg 1\). We get \[\begin{align} \label{p1} \frac{p G}{n v} & \approx \sqrt{2\pi} \frac{(k_* + m_c - 1)^{k_* + m_c - \frac{1}{2}}}{k_*^{k_*+\frac{1}{2}} (m_c-1)^{m_c-\frac{1}{2}} }\frac{z^{k_*}}{k_*-a} \sqrt{k_*} \notag \\ & = \sqrt{2\pi} \left(1 + \frac{m_c-1}{k_*} \right)^{k_*} \left(1 + \frac{k_*}{m_c-1} \right)^{m_c-\frac{1}{2}} \frac{z^{k_*}}{k_*-a} \notag \\ & = \sqrt{2\pi} \left(\frac{\alpha}{z} \right)^{k_*} \left(1+ \frac{z}{\alpha-z} \right)^{m_c-\frac{1}{2}} \frac{z^{k_*}}{k_*-a} \notag \\ & = \sqrt{2\pi} \alpha^{k_* + m_c - \frac{1}{2}} (\alpha-z) ^{-m_c+\frac{1}{2}} \frac{1}{k_*-a} \end{align}\tag{41}\]
In our approximation \(v \approx e^{\sum_{k'} \frac{p_{k'}}{N} \log \left(1+\frac{k_*}{m_c-1}\right)} = \left(1+\frac{k_*}{m_c-1}\right)^{m_c}\) so that \[\begin{align} \label{v1} v^{1/m_c} & \approx 1 + \frac{k_*}{m_c-1} \end{align}\tag{42}\] Eqs.@eq:z1 ,39 ,40 ,41 , 42 , and \(G = n/Na\) define the theory in the frozen phase, for \(p>N\).
Assuming \(\log v \ll m_c\) we have that \(v^{1/m_c} - 1\) is small, so from Eq.@eq:v1 we get \(k_* \ll m_c-1 \sim m_c\). Then \(z/\alpha \approx k_*/m_c\). We get \(\log v \approx k_*\). If \(z \ll 1\) then from \(z = 1 - (1+G/v)^{-1/m_c}\) we get \(z \approx \log(1+G/v)/m_c\). Thus we get \(\log v \approx m_c z/\alpha \approx \log(1+G/v)/\alpha\), that is \[\begin{align} \label{v2} v^\alpha = 1 + G/v . \end{align}\tag{43}\] We get \[\begin{align} p & \approx \sqrt{2\pi} (n/G) v e^{zm_c/\alpha} \frac{ \alpha^{k_*} }{k_*-a} \notag \\ & \approx \sqrt{2\pi} (n/G) v^2 \frac{ \alpha^{k_*} }{k_*-a} \end{align}\] Consider now \(a \ll 1\) so that \(\alpha \approx e^{3/(2k_*)}\). For \(G/v \gg 1\) we get \(v\approx G^{1/(1+\alpha)}\) and then \[\begin{align} \label{alpha2} \frac{3}{2 \log \alpha} \approx \frac{m_c z}{\alpha} \approx \frac{1}{\alpha} \log G/v \approx \frac{1}{1+\alpha} \log G. \end{align}\tag{44}\] There are two branches of solutions. If \(\alpha \gtrsim 1\) then \(\alpha \approx e^{-W\left(-\frac{3}{2\log G}\right)}\). The \(W_{-1}\) branch gives \(\alpha \approx \log G^{2/3} \log \log G^{2/3}\). The other branch is when \(\alpha\) is close to unity and we have \(\alpha \approx e^{3/\log G}\). The physical one is such that \(\alpha\) increases with \(G\), which corresponds to the novelty exponent decreasing with \(G\), as will be seen shortly. This leads to \[\begin{align} \alpha \approx e^{-W_{-1}\left(-\frac{3}{2\log G}\right)} \approx \log G^{2/3} \log \log G^{2/3} \qquad G \gg 1 \end{align}\] for large enough \(G\). Strictly, this branch can only hold when \(k_* \geq 1\) and thus \(\alpha< e^{3/2}\). This would impose \(G<G_c=240\). Because \(\alpha\) depends on \(\log G\), the critical \(G_c\) where the branch disappears is very sensitive to corrections to this equation; for example including leading corrections of 12 changes this to \(G_c \to 4399\). Empirically we will find that the branch describes the data over the entire range of \(G\) probed.
Note that this solution does not exist for \(G \lesssim 59\). It applies in the large and well-sampled corpus regime only.
Thus we get \[\begin{align} \label{mc2} p/N & \approx a \sqrt{2\pi} e^{3/2} \frac{2}{3} \log(\alpha) G^{\frac{2}{1+\alpha}} \notag \\ & \approx \frac{2}{3} a \sqrt{2\pi} e^{3/2} \log(\log G^{2/3} \log \log G^{2/3}) G^{\frac{2}{1+\alpha}} \qquad x \ll 1/8 \end{align}\tag{45}\] at large enough \(G\). The various scaling behaviors of this result are discussed in the main text.
We have assumed \(z \ll 1\) which should be checked. We have \[\begin{align} \frac{1}{z} \approx \frac{m_c}{k_* \alpha} & \sim N a \sqrt{2\pi} e^{3/2} \frac{4}{9} \log^2(\alpha) G^{\frac{2}{1+\alpha}} \frac{\log G}{1+\alpha} \\ & \sim n G^{-1 + \frac{2}{1+\alpha}} \end{align}\] where we ignore logarithmic factors. At large \(G\), \(\alpha \gg 1\) so \(z \ll 1\) amounts to \(n \gg G\) or \(N a \gg 1\) which is satisfied in the scaling limit.
We also have assumed \(\log v/m_c \ll 1\) which should be checked. We have \[\begin{align} \frac{\log v}{m_c} & \sim \frac{\log G}{(1+\alpha) a (\log \log G^{2/3})} G^{- 2/(1+\alpha)}\\ & \sim \frac{1}{\sqrt{8x} (\log \log G^{2/3})^2} e^{- 3/(\log \log G^{2/3})} , \end{align}\] which is small if \(6/(\log \log G^{2/3}) \gtrsim -\log 8x\), which is easily satisfied down to very small temperatures.
At small enough \(x\), the assumption \(\log v \ll m_c\) will break down. In this regime \(z \sim \mathcal{O}(1)\) and we anticipate that \(k_* \gg 1\). Then since \[\begin{align} \label{zlo} z = 1 - \left( 1 + G/v \right)^{-1/m_c} \end{align}\tag{46}\] and \[\begin{align} \label{alphalo} \alpha = 1 + \frac{1}{k_*} + \ldots \end{align}\tag{47}\] the \(k_*\) equation becomes \[\begin{align} z \frac{m_c-1}{k_*} = \alpha-z = \frac{1}{k_*} + \left( 1 + G/v \right)^{-1/m_c} , \end{align}\] that is \[\begin{align} \label{klo} k_* = (z (m_c-1) - 1) \left( 1 + G/v \right)^{1/m_c} \end{align}\tag{48}\] while the \(v\) equation is \[\begin{align} \label{vlo} v^{1/m_c} & \approx 1 + \frac{k_*}{m_c-1} \approx \frac{k_*}{m_c-1} \end{align}\tag{49}\] If \(k_* \gg 1\) then we should have \(G/v \gg 1\) so that \[\begin{align} k_* \approx (z (m_c-1) - 1) G^{-1/m_c} v^{1/m_c} \approx (z (m_c-1) - 1) G^{1/m_c} \frac{m_c-1}{k_*} \end{align}\] whence \(k_* \sim G^{1/2m_c} (m_c-1)\). Assume \(z(m_c-1) \gtrsim 1\) so that \(k_* \approx \sqrt{z} G^{1/2m_c} (m_c-1)\) which leads to \(v \approx G^{1/2} z^{m_c/2}\). Then \[\begin{align} z \approx 1 - \left( 1 + G^{1/2} z^{-m_c/2} \right)^{-1/m_c} \end{align}\] For large \(G\) and \(m_c\) not too large we have \(z \approx 1^-\). Then \[\begin{align} \frac{p G}{n v} & \approx \sqrt{2\pi} \alpha^{k_* + m_c - \frac{1}{2}} (z (m_c-1)/k_*)^{-m_c+\frac{1}{2}} \frac{1}{k_*} \\ & \approx \sqrt{2\pi} e^{1 + (m_c -1/2)/k_*} v^{1-\frac{1}{2m_c}} \frac{1}{G^{1/2m_c} (m_c-1)} \\ & \approx \sqrt{2\pi} e G^{\frac{1}{2}-\frac{3}{4m_c}} \frac{1}{m_c-1} \end{align}\] and finally \[\begin{align} \label{plo2} m_c (m_c - 1) \approx a \sqrt{2\pi} e G^{1-\frac{3}{4m_c}} \end{align}\tag{50}\] To be consistent with \(z \approx 1^-\) we need \[\begin{align} \label{satthres} 1 \lesssim \frac{\log G}{2m_c} \end{align}\tag{51}\] which is satisfied for small enough \(x\), as expected. This gives a regime boundary defined by \((\log G)(\log G -2) = 4 a \sqrt{2\pi} e G^{1-\frac{3}{2 \log G}}\). However the condition \(z (m_c-1) \gtrsim 1\), assumed above, requires \(m_c \gtrsim 2\), which turns out to be more stringent in general. In particular the saturation regime can exist only when \(2 \lesssim m_c \lesssim \frac{1}{2}\log G\), which means \(G \gtrsim e^4 \approx 55\). For larger \(G\), \(m_c \gtrsim 2\) reduces to \(x > x_{lo}\) with \[\begin{align} \label{xlo2} x_{lo} = \frac{1}{8} \left( 8 \pi e^2 \right)^{-8/3} (n/N)^{-10/3} \end{align}\tag{52}\] Since the condition \(m_c \gtrsim 2\) is more stringent than \(z \approx 1^-\), as \(x\) is lowered from the scaling regime, eventually \(m_c \approx 2\) and a saturation regime is reached, but its description requires that we go beyond the semi-annealed theory. We expect that \(m_c \to 1^+\) but it may not be described by 50 .
( To see that \(k_* \gg 1\), note that \(\log v/m_c \gg 1\) implies \(k_*/(m_c-1) \gg 1\). Then \(\alpha/z \approx 1\), but since \(z < 1\) and \(\alpha > 1\) we get that \(z \approx 1\) and \(\alpha \approx 1\), the latter implying that \(k_* \gg 1\).)
As \(x \to 1/8^-\), we cannot neglect \(a\) above. Initially, this will be important only in the \(p\) and \(v\) sums, because \(n\) has an extra factor of \(k\) in the summand and is thus dominated by larger \(k\).
Assuming \(m_c \gg k_*\) we still have \(v^\alpha = 1+G/v\), but now including \(a\) the equation for \(\alpha\) is \[\begin{align} \log \alpha \approx \frac{1}{k_*-a} + \frac{1}{2k_*} = (1+\alpha) \left[ \frac{1}{2\log G} + \frac{1}{\log G - a(1+\alpha)} \right] \end{align}\] If we define \(G_{crit}\) by \[\begin{align} \label{Gcrit} \frac{3}{2 \log G_{crit} } = \frac{1}{2\log G} + \frac{1}{\log G - a(1+\alpha)} \end{align}\tag{53}\] then the structure of the equations is the same as before except that \(\alpha(G) \to \alpha(G_{crit})\). The effect of \(a\) in \(G_{crit}\) is to decrease \(G_{crit}\) compared to \(G\). Hence \(G_{crit}\) decreases as \(x\to 1/8^-\) and concurrently \(\alpha\) decreases, explaining the increase in the novelty exponent visible in Fig.6. From \(\alpha \approx e^{-W_{-1}(-3/2\log G_{crit})}\) the smallest value that \(\alpha\) can reach is \(e\), giving novelty exponent \(2/(1+e) = 0.537..\). Setting \(\alpha=e\) and extracting only the contribution from the singularity at \(k_*-a\) gives \[\begin{align} k_* \approx \frac{3}{4} + \frac{1}{2}a + \frac{1}{2}\sqrt{a^2 + a + \frac{9}{4}} . \end{align}\] and \(p\) is \[\begin{align} p/N & \approx a \sqrt{2\pi e} e^{4 + \frac{3}{k_*-a} } \frac{ 1 }{k_*-a} \end{align}\] Here we have assumed that the \(n\) equation does not change in this region, because the \(n\) sum is dominated by much larger \(k\), and the singularity at \(x=1/8\) affects only the \(k=1\) term. Nevertheless, it is straightforward to extract this term separately.
We have \[\begin{align} n & = v N a \sum_{k \geq 1} k \binom{k + m_c - 1}{m_c -1} \frac{ z^k }{ k-a } \\ & = vN a \left[ \frac{m_c}{1-a} z + \sum_{k \geq 2} \binom{k + m_c - 1}{m_c -1} \frac{ k }{ (k-a) } z^k \right] \\ & \approx v N a \left[ \frac{m_c}{1-a} z + \sum_{k \geq 2} \binom{k + m_c - 1}{m_c -1} z^k \right] \\ & = v N a \left[ \frac{m_c}{1-a} z- m_c z + \frac{1}{(1 - z)^{m_c}} - 1 \right] \\ & =v (n/G) \left[ \frac{a}{1-a} m_c z + \frac{1}{(1 - z)^{m_c}} - 1 \right] \end{align}\] In the scaling regime solution we have \(z m_c \sim \log v\) so that \((1-z)^{-m_c} \sim v\), and the new term is smaller by a factor \(\sim (\log v)/v \ll 1\). This breaks down close enough to \(x_c=1/8\). Away from the singularity the leading change is just to replace \(G\) by \(G_{eff} = G - v z m_c a/(1-a)\) in the \(z\) equation, i.e. \[\begin{align} \label{z2} z = 1 - \left( 1 + \frac{1}{v} \left[ G - v z m_c \frac{a}{1-a} \right] \right)^{-1/m_c} \qquad x<1/8 \end{align}\tag{54}\] where \(z\) can be substituted by iteration. The effect of replacing \(G\) by \(G_{eff}\) is similar to the effect of replacing \(G\) by \(G_{crit}\) above, but in different terms. In particular, as \(x \to 1/8^-\) then \(G_{eff}\) decreases with respect to \(G\).
The same technique can be adapted to other regions. For example if \(r=1\) so that \(1/8 < x < 1/2\), then we simply replace \(g_1\) by the other asymptotic expression. This results in \[\begin{align} z = 1 - \left( 1 + \frac{1}{v} \left[ \underbrace{G - \frac{N^2}{a} v z m_c e^{1/4\tilde{\epsilon}_d} e^{-X_*} + v z m_c }_{G_{trans}} \right] \right)^{-1/m_c} . \qquad 1/8<x<1/2 \end{align}\] For \(\log (G_{trans}/v) \ll m_c\) we get \(z m_c \approx \log (G_{trans}/v)\). We then have \[\begin{align} G_{trans}/v \approx G/v - \log (G_{trans}/v) \left[ \underbrace{\frac{N^2}{a} e^{1/4\tilde{\epsilon}_d} e^{-X_*} - 1 }_{A} \right] \end{align}\] which is \((G_{trans}/v) e^{G_{trans}/Av} = e^{G/Av}\), so that \[\begin{align} G_{trans}/Av & = W\left( e^{G/Av}/A \right) . \end{align}\] If \(G/v \gg A \log A\) then \(G_{trans} = G - A v \log G/v + \ldots\) and the new term is a correction. However if \(G/v \ll A \log A\) then \(G_{trans} = v e^{G/Av} + \ldots\).
Similar to above we get \[\begin{align} \label{v3} v^\alpha = 1 + G_{trans}/v \end{align}\tag{55}\] and then the \(p\) equation becomes \[\begin{align} \left( p/n \right) G + G_{trans} - G & = v \frac{(k_*+m_c-1)^{k_*+m_c-\frac{1}{2}}}{(m_c-1)^{m_c-\frac{1}{2}} k_*^{k_*+\frac{1}{2}} } \frac{z^{k_*}}{k_*-a} \sqrt{2\pi k_*} \\ & \approx \sqrt{2\pi} v^2 \frac{ \alpha^{k_*} }{k_*-a} \end{align}\] where the derivation proceeds exactly as in the frozen regime. We still have Eq.@eq:k1 and Eq.@eq:alpha , but now \(k_* \geq 2\).
Initially, the terms for repeated rules (i.e. those for \(k>1\)) will dominate and the equations are identical to those in the frozen regime. In the well-sampled limit \(G_{trans} \approx G\) and the solution is then identical to that in the frozen regime. For this to hold, we require \(v^2/\log v \gg G_{trans}-G\), which amounts to \(A \ll v\) up to log corrections. This would require \(A \ll v \sim G^{1/(1+\alpha)} \sim e^{1/\log\log G}\).
Now examine \[\begin{align} A & = \frac{N^2}{a} e^{1/4\tilde{\epsilon}_d} e^{-X_*} - 1 \\ & \approx \frac{ N^{\chi } }{\sqrt{8x} } - 1 \end{align}\] where \(\chi(x) = 2 + \frac{1}{4x} - \sqrt{\frac{2}{x}}\). Noting that \(\chi(1/8) = 0\) and \(\chi(1/2) = 1/2\) we see that the first term in \(A\) is dominant in the scaling limit, except very close to \(x=1/8\). The second term is a correction, small until the critical region is approached. Away from the critical region, the inequality \(A \ll v\) corresponds to \(N^{\chi } \ll e^{1/\log \log (n/N)}\), which is violated as soon as \(x>1/8\), because then \(N^\chi \gg 1\). So in fact for \(x>1/8\), we must have the \(k=1\) terms playing a role.
In the scaling limit \(A\) diverges for any \(x>1/8\). When \(A \gg v\) the \(k=1\) terms will be important in either the \(p\) sum or the \(n\) sum. This will first happen in the \(p\) sum, because it is less weighted towards larger \(k\). If the \(p\) sum becomes dominated by the \(k=1\) term then we get \[\begin{align} (p/n) G \approx G - G_{trans} = vz m_c A \approx v A \log( G_{trans}/v) , \end{align}\] that is \[\begin{align} m_c & \approx \frac{n/N}{G} v A \log( G_{trans}/v) \notag \\ & = a v A \log( G_{trans}/v) \notag \\ & \approx a G_{trans}^{1/(1+\alpha)} A \frac{\alpha}{1+\alpha} \log G_{trans} \label{mc3} \end{align}\tag{56}\] where we used \(v \approx G_{trans}^{1/(1+\alpha)}\), which holds for \(G_{trans}/v \gtrsim 1\). In this regime we take the other branch of the \(\alpha\) equation, leading to \(\alpha \approx e^{\frac{2}{\log G_{trans}-2a} + \frac{1}{\log G_{trans} } }\), which is close to 1 at large \(G_{trans}\). If \(G/v \gg A \log A\) then \(G_{trans} \approx G\) so that \[\begin{align} m_c & \approx \frac{1}{2}a G^{1/(1+\alpha)} A \log G \end{align}\] Recalling the behavior of \(A\), away from \(x=1/8\) and in large enough grammars, we have \[\begin{align} \label{qvzbfrmw} m_c & \approx \frac{1}{2}N^{\chi } G^{1/(1+\alpha)} \log G . \qquad 1/8 < x < 1/2 \end{align}\tag{57}\]
In passing from Eq.@eq:mc2 to Eq.@eq:mc3 we have assumed that \(G/v \gg A \log A\), which amounts to \(n/N \gg N^{\frac{1+\alpha}{\alpha}\chi}\) up to corrections.
At fixed \(N\) and small enough \(n\) we will have \(G/v \ll A \log A\) and then \(G_{trans} \approx v e^{G/Av}\) that leads to \[\begin{align} m_c & \approx a G = n/N, \end{align}\] and thus \(p=n\) which means that all rules are used uniquely.
Overall the results in this regime are summarized \[\begin{align} m_c \approx \begin{cases} \frac{1}{2}N^{\chi } G^{1/(1+\alpha)} \log G \qquad & n/N \gg N^{\frac{1+\alpha}{\alpha}\chi} \\ n/N \qquad & n/N \ll N^{\frac{1+\alpha}{\alpha}\chi} \end{cases} \end{align}\] where \(\alpha \approx 1\). In the first regime this leads to \(m_c \sim G^{1/2}\) as observed, see Fig.6b.
Note however that the scaling limit is taken at fixed \(n/N\) so that asymptotically we have \(m_c \approx n/N\). In the scaling limit we obtain \[\begin{align} z = \frac{\log(G_{trans}/v)}{m_c} \approx \frac{1}{a G_{trans}^{1/(1+\alpha)} A } \approx e^{-G/A} N^{-\chi} \end{align}\] while for later use we will need \[\begin{align} \frac{p}{n} \log e/v & \approx 1 - W(G/A\alpha) \approx 1 - \frac{G}{A} \end{align}\] in the scaling limit.
\(Z_{tree} = 2p_E/(1+|2p_E-1|) = 1\) for \(p_E>1/2\).↩︎
The idea to relate belief propagation equations to the Random Energy Model is due to Alessio Giorlandino and Sebastian Goldt.↩︎
Here we have fixed a typo in the second and fourth equations, with \(H_{a'}\) rather than \(H_a\) as published in [19].↩︎
This procedure does not strictly enforce that each pile has exactly \(\ell_c\) rules, counted with multiplicity. However in the large \(m_c\) limit this is the most likely outcome. The corrections are computable; see Appendix 12 on Contingency Tables.↩︎
We have \(g^2 \approx 1/8\) to get large trees↩︎