\section{An upper bound for every positive source}\label{sec:universal} \label{sec:universal-upper} Let $\pi$ be the stationary hidden law. The \emph{word-probability rank} $\rho_S$ of the source is the rank of the infinite matrix $[\pi T_uT_v\mathbf1]_{u,v}$ whose rows and columns are indexed by all finite words, including the empty word. Its entries are the probabilities of the words $uv$. The rank is at most the number $n$ of hidden states, and it is smaller when some hidden directions never affect the observations. \begin{theorem}\label{thm:universal-upper} Let $S$ have $n\ge2$ hidden states and a finite alphabet $\mathcal A$, with every symbol matrix strictly positive and their sum stochastic. If $m=\rho_S-1\ge1$, there are source-dependent $C_S,c_S>0$ such that, for every $D\ge n$, \[ G_D^\diamond(S)\le C_Se^{-c_Sr_D^{1/m}}, \qquad \diamond\in\{\mathrm{cl},\mathrm q\}. \] If $\rho_S=1$, the observed process is iid and one state or dimension is exact. In particular every positive $n$-state source admits the exponents $D^{1/(n-1)}$ and $D^{2/(n-1)}$. The devices are causal and stationary, apply one fixed update for each observed symbol, and generate on the same register at every cut. \end{theorem} \paragraph{Idea of the proof.} A memory cannot store the posterior exactly, and it cannot update a stored approximation exactly either: the posterior update is a ratio of linear functions, while the average state of a memory can only be updated linearly. The device therefore stores the monomials of degree at most $K$ in $m$ coordinates of the posterior. After one more observation, each monomial of the new coordinates is a power series in the old ones, and dropping the terms of degree above $K$ leaves a linear update of the stored monomials. There are about $K^m$ monomials, so they fit a memory with $r_D\approx K^m$, and the dropped terms have size $e^{-cK}$. This gives the rate. Three points need care. First, the power series must have small coefficients for the linear update to be a valid stochastic map or quantum channel. This holds after a block of $b_0$ symbols, because the posterior then depends only weakly on where it started. The device therefore updates its monomials once per block and keeps the symbols of the current block in a buffer. Second, a stationary device has no clock, so the position inside the block is itself stored, as the length of the buffer. Third, the device must generate from what it has stored: at the cut it measures an approximate hidden state and then runs the source exactly. The six steps of the proof take these points in order. The buffer and block labels multiply the memory size by a factor that depends only on the source. With block length $b_0=b_0(S)\ge n$, the labels are \begin{equation}\label{eq:general-tag-cost} \mathcal U=\mathcal A^{b_0},\quad \mathcal W=\bigcup_{j=b_0}^{2b_0-1}\mathcal A^j,\quad H_S=|\mathcal U||\mathcal W| =|\mathcal A|^{b_0}\sum_{j=b_0}^{2b_0-1}|\mathcal A|^j. \end{equation} Here $u\in\mathcal U$ is the last completed block and $w\in\mathcal W$ is the buffer. A register of $N$ states or dimension $d$ for the monomials therefore costs $H_SN$ classical states or quantum dimension $H_Sd$ in total. Generation uses $n$ of these states or vectors again; no extra memory is added for it. \begin{proof} Write $\Delta$ for the hidden simplex and $\mathcal F_w(x)=xT_w/(xT_w\mathbf1)$, with matrices in chronological order. \emph{1. Keep only directions that affect the future.} Define spaces of real rows, including the empty word, by \[ \mathcal V=\operatorname{span}\{\pi T_w:w\in\mathcal A^*\},\qquad \mathcal Z=\{\zeta:\zeta T_w\mathbf1=0\text{ for every }w\}, \qquad I_0=\mathcal V\cap\mathcal Z. \] Both $\mathcal V$ and $\mathcal Z$ are right-invariant under every $T_a$. The map $\zeta\mapsto(\zeta T_v\mathbf1)_v$ on $\mathcal V$ has kernel $I_0$ and the row span of the word-probability matrix as its image, so \[ \rho_S=\dim\mathcal V-\dim I_0,\qquad V_0=\{\zeta\in\mathcal V:\zeta\mathbf1=0\},\qquad \dim(V_0/I_0)=\rho_S-1. \] The empty word gives $I_0\subseteq V_0$; $\pi\mathbf1=1$ gives $\dim V_0=\dim\mathcal V-1$. If $\rho_S=1$, the quotient is generated by $\pi$ and $\pi T_a\equiv s_a\pi\pmod{I_0}$, where $s_a=\pi T_a\mathbf1$. Right invariance gives $\pi T_w\mathbf1=\prod_js_{a_j}$. Thus the output is iid and has a one-state exact generator. Henceforth $m=\rho_S-1\ge1$. Choose linear maps \[ \Pi:\mathbb R^n\longrightarrow\mathbb R^m,\quad \Lambda:\mathbb R^m\longrightarrow V_0,\quad \Pi\Lambda=I,\quad \ker\Pi\cap V_0=I_0. \] Put $L_\Pi=\|\Pi\|_{1\to1}$, $\lambda_j=\Lambda e_j$ and $L_\Lambda=\max_j\|\lambda_j\|_1=\|\Lambda\|_{1\to1}$, so $L_\Pi L_\Lambda\ge1$. Both word-generated spans stabilize within dimension $n$, so the maps are obtained by finite linear algebra from the known source. Finite-past posteriors are normalized $\pi T_w$; their martingale limits, the full-past posteriors, remain in $\mathcal V$. If $x,y\in\mathcal V\cap\Delta$ and $x-y\in I_0$, then \begin{equation}\label{eq:general-future-equivalence} P_x=P_y,\qquad \mathcal F_w(x)-\mathcal F_w(y) =\frac{(x-y)T_w}{xT_w\mathbf1}\in I_0. \end{equation} The denominators agree because all future word probabilities agree; right invariance gives the second identity. \emph{2. Forget earlier hidden states uniformly.} Set \[ \vartheta=\min_{a,i,i',j}\frac{T_a(i,j)}{T_a(i',j)},\quad \beta=\min\{\vartheta^2,1/2\},\quad \mu=\min_{a,i,j}\frac{T_a(i,j)}{(T_a\mathbf1)_i},\quad \varepsilon_\ell=2(1-\beta)^\ell. \] For a word $w=a_1\cdots a_\ell$, write $h^{(k)}=T_{a_{k+1}}\cdots T_{a_\ell}\mathbf1$ and \[ S_k=\operatorname{diag}(h^{(k-1)})^{-1} T_{a_k}\operatorname{diag}(h^{(k)}). \] These matrices are stochastic. The definition of $\vartheta$ gives $T_{a_k}(i,j)\ge\vartheta T_{a_k}(i',j)$ and, after summation, $h^{(k-1)}_{i'}/h^{(k-1)}_i\ge\vartheta$. Hence every row of $S_k$ dominates $\beta S_k(1,\cdot)$: zero-mass row differences contract in $\ell^1$ by at most $1-\beta$. The rows of $S_1\cdots S_\ell=\operatorname{diag}(T_w\mathbf1)^{-1}T_w$ are $\mathcal F_w(e_i)$, with pairwise distance at most $\varepsilon_\ell$. The final factor has entries at least $\mu$. Taking convex combinations of the product rows gives, for $x,y\in\Delta$ and nonempty $w$, \begin{equation}\label{eq:general-real-contraction} \mathcal F_w(x)_i\ge\mu,\qquad \|\mathcal F_w(x)-\mathcal F_w(y)\|_1\le\varepsilon_{|w|}. \end{equation} In particular every past $H=(\ldots,h_{-1},h_0)$ has a canonical posterior version \begin{equation}\label{eq:canonical-posterior} \widehat p(H)=\lim_{\ell\to\infty}\mathcal F_{h_{-\ell+1:0}}(\pi). \end{equation} Two approximants sharing their last $\ell$ symbols differ by at most $\varepsilon_\ell$, so this limit is uniform and past-measurable. It belongs to $\mathcal V\cap\Delta$, has coordinates at least $\mu$, and satisfies $\widehat p(Ha)=\mathcal F_a(\widehat p(H))$ by continuity. The finite-past approximants are the source's conditional hidden rows; martingale convergence identifies this version with $p_H$ almost surely. Use this version in the ideal coordinates below. \emph{3. Use small local coordinates.} Fix \begin{equation}\label{eq:general-block-choice} \delta=\frac{\mu}{8mL_\Lambda},\qquad b_0\ge n\text{ with } \varepsilon_{b_0}\le\frac{\mu}{128mL_\Pi L_\Lambda},\qquad \varrho=1/4. \end{equation} For $u\in\mathcal U$ set $c_u=\mathcal F_u(\pi)\in\mathcal V$ and $x_u(z)=c_u+\delta\Lambda z$. At a block boundary following $u$, a true posterior $y$ has coordinate $z=\Pi(y-c_u)/\delta$ satisfying \begin{equation}\label{eq:general-chart-radius} \|z\|_1\le L_\Pi\varepsilon_{b_0}/\delta\le1/16. \end{equation} The lift $y'=x_u(z)$ lies in $\mathcal V\cap\Delta$ since $\|\delta\Lambda z\|_1\le\mu/(128m)$ and $c_u\ge\mu$. Its difference from $y$ lies in $I_0$, so \eqref{eq:general-future-equivalence} gives the next coordinate \[ G_{uv}(z)=\Pi\bigl(\mathcal F_v(c_u+\delta\Lambda z)-c_v\bigr)/\delta, \qquad |u|=|v|=b_0. \] For its Taylor coefficients write \[ h_\ell=(T_v\mathbf1)_\ell,\quad R_\ell=e_\ell T_v/h_\ell,\quad q=c_u\cdot h,\quad f=\mathcal F_v(c_u), \] and define row vectors $C_j$ and scalars $\gamma_j$ by \[ C_j=\frac{\sum_\ell\lambda_j(\ell)h_\ell(R_\ell-f)}q, \qquad\gamma_j=\frac{\delta\lambda_jh}q. \] Direct affine division gives \begin{equation}\label{eq:general-chart-rational} \mathcal F_v(c_u+\delta\Lambda z) =f+\frac{\delta\sum_jC_jz_j}{1+\gamma\cdot z},\qquad G_{uv}(z)=\frac{\Pi(f-c_v)}{\delta}+ \frac{\sum_j\Pi(C_j)z_j}{1+\gamma\cdot z}. \end{equation} Since $q\ge\mu h_\ell$ and $\|R_\ell-f\|_1\le\varepsilon_{b_0}$, \[ \sum_j|\gamma_j|\le\frac{\delta mL_\Lambda}{\mu}=\frac18,\quad \|C_j\|_1\le\frac{L_\Lambda\varepsilon_{b_0}}{\mu},\quad \|\Pi(f-c_v)\|_1\le L_\Pi\varepsilon_{b_0}. \] The denominator has no zero on the closed complex polydisc $|z_j|\le4$. If $\|\cdot\|_{\mathrm A}$ is the sum of absolute Taylor coefficients, its geometric expansion on the unit polydisc proves \begin{equation}\label{eq:general-small-coefficients} q_0:=\sum_{i=1}^m\|G_{uv,i}\|_{\mathrm A} \le\frac{L_\Pi\varepsilon_{b_0}}{\delta}+ \frac{8mL_\Pi L_\Lambda\varepsilon_{b_0}}{7\mu} =\frac{64mL_\Pi L_\Lambda\varepsilon_{b_0}}{7\mu}\le\frac1{14}. \end{equation} \emph{4. Implement the truncated moments.} Retain the monomials $z^\alpha$, $1\le|\alpha|\le K$, in $m$ variables. Their number is \begin{equation}\label{eq:general-moment-count} N_K=\binom{K+m}{m}-1. \end{equation} Their ideal absolute sum is at most $\prod_j(1-|z_j|)^{-1}-1\le(1-\|z\|_1)^{-1}-1\le1/15$. Expand $G_{uv}(z)^\alpha=\sum_\nu a_{uv,\alpha\nu}z^\nu$. Take constant coefficient $\mathsf u_\alpha=a_{uv,\alpha0}$ and affine matrix $\mathsf M_{\alpha\nu}=a_{uv,\alpha\nu}$ for $1\le|\nu|\le K$. With $q_i=\|G_{uv,i}\|_{\mathrm A}$, absolute convolution gives \begin{equation}\label{eq:general-affine-mass} U+S\le\sum_{\alpha\ne0}\prod_iq_i^{\alpha_i} =\prod_i(1-q_i)^{-1}-1\le\frac{q_0}{1-q_0}\le\frac1{13}<\frac13. \end{equation} Here $U=\sum|\mathsf u_\alpha|$, $S=\sum|\mathsf M_{\alpha\nu}|$; the last step uses $\prod_i(1-q_i)\ge1-\sum_iq_i$. Lemma~\ref{lem:affine-physical} supplies stochastic maps $K_{u,v}$ on $N=2^\ell$ labels if $N_K\le N-1$, or CPTP maps $\mathcal K_{u,v}$ on dimension $d=2^\ell$ if $N_K\le d^2-1$. Pad unused Walsh or Pauli features by zero. On every input the maps have a uniform-preparation component of weight at least $2/3$ and contract nonconstant coordinates by $S\le1/3$. Since $|z_j|\le1/16<\varrho$, omitted degrees satisfy \begin{equation}\label{eq:general-moment-tail} \|\tau_{uv}(z)\|_1 \le \varrho^{K+1}\sum_{1\le|\alpha|\le K}\sum_{|\nu|>K}|a_{uv,\alpha\nu}| \le e_K:=\tfrac13\varrho^{K+1}. \end{equation} \emph{5. One update per symbol, and a stationary device.} The memory consists of the label $(u,w)$ of \eqref{eq:general-tag-cost} and a register for the monomials. Here $u$ is the last completed block and $w$ is the buffer, with $b_0\le|w|\le2b_0-1$. When a symbol $a$ is read and $|w|<2b_0-1$, the device appends $a$ to $w$. Otherwise it splits $wa=vw'$ into two halves of length $b_0$, applies $K_{u,v}$ or $\mathcal K_{u,v}$ to the register, and replaces $(u,w)$ by $(v,w')$. We call this a \emph{block update}. The classical rule is a stochastic matrix. The quantum rule measures the label, applies the map that the label selects, and writes the new label; it is a channel on every input. These rules have a stationary realization. Choose a position $J_0$ uniform on $\{0,\ldots,b_0-1\}$, independent of the source and of all the device's randomness, and set \begin{equation}\label{eq:counted-phase-tags} J_t=(J_0+t)\bmod b_0,\quad s_t=t-b_0-J_t,\quad u_t=X_{s_t-b_0+1:s_t},\quad w_t=X_{s_t+1:t}. \end{equation} Thus $J_t$ is the position inside the current block, $s_t$ is the end of the last block that has been used, $u_t$ is that block and $w_t$ is the buffer. When $J_t\ne0$ the buffer grows by one symbol. When $J_t=0$ a block update occurs and $s_t$ advances by $b_0$. The position is stored as $|w_t|-b_0$, so the device needs no clock and no record of older symbols. Fix one alignment of the blocks. Each matrix $K_{u,v}$ has entries at least $2/(3N)$, so \[ K_{u,v}=\tfrac12\mathbf1\nu_N+\tfrac12\widetilde K_{u,v}, \qquad \nu_N=(1/N,\ldots,1/N). \] Apply the first part of Lemma~\ref{lem:stationary-memory} at the times of block updates, and leave the register unchanged between them. The resulting register state depends only on the blocks already used and on independent randomness. Together with the label it is the whole classical memory. In the quantum case, for each position $j$ at time $t$, compose the channels of the last $k$ block updates. Lemma~\ref{lem:stationary-memory}, with contraction $1/3$, gives a limit $\sigma_{t,j}$: starting still earlier changes the present state by at most $2\cdot3^{-k}$. The limit is a measurable function of the blocks already used and obeys the update rule. Let $(u_{t,j},w_{t,j})$ be the labels in \eqref{eq:counted-phase-tags} when $J_t=j$. The state of the whole memory given the past is \begin{equation}\label{eq:stationary-phase-density} \rho_{X_{\le t}}=\frac1{b_0}\sum_{j=0}^{b_0-1} |u_{t,j},w_{t,j}\rangle\langle u_{t,j},w_{t,j}| \otimes\sigma_{t,j}. \end{equation} Different positions have buffers of different lengths, hence orthogonal labels. The channel for the next symbol sends each term to the term of the next position, with a block update exactly when one is due. It therefore maps \eqref{eq:stationary-phase-density} to the corresponding state one step later. Nothing outside this density matrix records the position. The construction commutes with shifts of the observations, of the device's randomness and of the uniform position, so the classical joint law is stationary. The randomness is fresh at each step, which gives the fixed conditional transition probabilities. Given $X_{\le t}$, the remaining randomness is independent of future symbols, which proves \eqref{eq:nonanticipating}. In the quantum case a shift permutes the terms of \eqref{eq:stationary-phase-density} and shifts their limits, so the state is a stationary measurable function of the past. The device keeps only the label and the register. For the error bound, the exact coordinate at the end $s_t$ of the last used block refers to the posterior given $X_{\le s_t}$, not to the posterior given the later symbols in the buffer as well. Given the whole observed past and the position, the symbols in the buffer do not change the conditional mean of the register, which was last updated at $s_t$. The exact coordinates follow \eqref{eq:general-future-equivalence}. The stored means follow an affine recursion with contraction $\kappa\le1/3$ and error $\tau\le e_K$ per block. Lemma~\ref{lem:feature-error} therefore gives, for each position, \begin{equation}\label{eq:general-boundary-error} E\le e_K/(1-1/3)\le\tfrac12\varrho^{K+1}. \end{equation} \emph{6. Generation on the same memory, and the error.} For each label $(u,w)$, expand the posterior at the cut as a function of the stored coordinate: \[ \mathcal F_w(c_u+\delta\Lambda z)=f+\sum_{\nu\ne0}h_{uw,\nu}z^\nu, \qquad f=\mathcal F_w(c_u)\ge\mu. \] Repeating the calculation of Step~3 for $|w|\ge b_0$, without the factor $\Pi/\delta$, gives \begin{equation}\label{eq:general-readout-tail} \sum_{\nu\ne0}\|h_{uw,\nu}\|_1 \le\frac{8\delta mL_\Lambda\varepsilon_{b_0}}{7\mu} =t_{b_0}:=\varepsilon_{b_0}/7<\mu/2. \end{equation} The operators $O_{uw,i}=f_iI+\sum_{1\le|\nu|\le K}h_{uw,i\nu}P_\nu$ are at least $(\mu/2)I$ and sum to $I$ on every input, because each nonconstant coefficient vector sums to zero over $i$, also after truncation. They form a measurement with $n$ outcomes. Walsh signs give classical readout probabilities with the same properties. For position $J$, let $y_J$ be the true posterior at the end of the last used block and $y'_J=x_u(z)$ its representative from Step~3. Put $p'_J=\mathcal F_w(y'_J)$. Equation~\eqref{eq:general-future-equivalence} gives $P_{p'_J}=P_{p_H}$ for the present true posterior $p_H$. The truncated readout has induced $\ell^1$ norm $B\le t_{b_0}$ and residual $\epsilon\le t_{b_0}\varrho^{K+1}$. Its mean output $q_{H,J}$ satisfies \[ \|q_{H,J}-p'_J\|_1\le\tfrac32t_{b_0}\varrho^{K+1},\qquad q_{H,J,i}\ge\mu/2. \] At the cut the device performs the measurement selected by its label. Since $H_S\ge b_0\ge n$, choose $n$ orthogonal vectors $g_i$ of the memory, or $n$ classical states; on outcome $i$ the cut channel prepares $g_i$. With $E_1^{\rm gen}=|g_1\rangle\langle g_1|+\Pi_\perp$ and $E_i^{\rm gen}=|g_i\rangle\langle g_i|$ for $i>1$, the device then runs the source exactly: \[ \mathcal G_a(X)=\sum_{i,j=1}^nT_a(i,j) \tr(E_i^{\rm gen}X)|g_j\rangle\langle g_j|. \] These maps are completely positive and their sum is trace preserving on the whole memory. Classically, use the exact transitions on the chosen states and any valid rows elsewhere. Generation uses no memory beyond what was already counted. After averaging over the device's randomness, $Q_H=b_0^{-1}\sum_JP_{q_{H,J}}$. For each position $J$ apply Lemma~\ref{lem:feature-error} to the prior $p'_J$, with $(\tau,\kappa,B,\epsilon,\mu_{\rm read})= (e_K,1/3,t_{b_0},t_{b_0}\varrho^{K+1},\mu/2)$. Convexity over the positions then gives the bound for the entire future, \[ \mathcal R\le\frac{9t_{b_0}^2}{2\mu}\,\varrho^{2K+2}. \] For one fixed alignment of the blocks the device is periodic, not stationary. Mixing uniformly over the $b_0$ alignments makes it stationary, and the error bound holds for each alignment. Finally choose the largest power of two $N\le D/H_S$ or $d\le D/H_S$; for large $D$ they exceed $D/(2H_S)$. Since $N_K+1\le(K+1)^m$, choose $K+1=\lfloor N^{1/m}\rfloor$ classically or $K+1=\lfloor d^{2/m}\rfloor$ quantumly. The capacity conditions hold, and these powers give the asserted exponents. For the finitely many remaining $D\ge n$, the constant forecast $P_\pi$ and an exact $n$-state generator have risk at most $\max_i\log(1/\pi_i)$. Increasing $C_S$ covers them. Padding unused states or dimensions with valid maps gives devices for every prescribed budget. \end{proof}