\section{Tight gradings and protected matching}\label{sec:tight} Fix a primitive pair $d,e>0$ and write \[ G_{d,e}(z)=1+\sum_{k\geq1}c_kz^k. \] For a formal series $J$ in named variables, brackets such as $[z^k]J$ denote the coefficient of the indicated monomial; absent monomials have coefficient zero. Thus $c_k=[z^k]G_{d,e}$. For each $k\geq1$, choose positive integers $D_1,D_2$ satisfying \begin{equation}\label{eq:ambient} eD_1-dD_2=1,\qquad D_1>kd+1,\qquad D_2>ke. \end{equation} B\'ezout's identity gives one integral solution, and adding a sufficiently large multiple of $(d,e)$ gives these inequalities. In particular $\gcd(D_1,D_2)=1$. All constructions involving $D_1,D_2$ in this section are for this fixed $k$. \subsection{Paths, shadows, and the coefficient formula} The maximal lower Dyck path $C(D_1,D_2)$ joins $(0,0)$ to $(D_1,D_2)$ by east and north unit edges and stays as close as possible to the segment from $(0,0)$ to $(D_1,D_2)$ while remaining below it. Its word is \[ \prod_{x=1}^{D_1} EN^{\lfloor xD_2/D_1\rfloor-\lfloor(x-1)D_2/D_1\rfloor}, \] where concatenation reads from left to right. We also read the path cyclically, or extend it periodically by translation by $(D_1,D_2)$. Its edges retain their labels under cyclic reading. A grading $\omega$ assigns a nonnegative integer to each edge. An edge is selected if its grade is positive. For an oriented interval $J$ of the path, let $J_E,J_N$ be its horizontal and vertical edges, respectively, and write $\omega(J_E)=\sum_{h\in J_E}\omega(h)$ and $\omega(J_N)=\sum_{v\in J_N}\omega(v)$. We consider gradings of totals \[ p=\omega(C_N)=kd,\qquad q=\omega(C_E)=ke. \] For a selected horizontal edge $h$, its horizontal shadow interval starts at $h$ and ends at the first vertical edge for which $|J_N|=\omega(J_E)$. Its shadow $\sh(h)$ is the set of vertical edges in this interval. For a selected vertical edge $v$, read backwards from $v$ to the first horizontal edge for which $|J_E|=\omega(J_N)$; the horizontal edges in that interval form $\sh(v)$. A zero-grade edge has empty shadow. Since $q0$ pushes the record $(h,0)$. \item A vertical edge of grade $s\geq0$ requires $z\geq s$ and replaces $(r,z)$ by $(r-1,z-s)$. \item If $r$ becomes zero, pop the record. If a parent remains, add $z+1$ to its free balance; the extra token is the former root's token. \end{enumerate} The demand in step 3 is tested before step 4. For example, adjacent edges of grades $E_1N_1$ fail this test and are incompatible, whereas $E_1E_0N_1$ is accepted with final free balance zero. \begin{lemma}\label{lem:stack} On a maximal blue interval, compatibility for all forward selected pairs is equivalent to legality of the protected matching. If the interval has $m+1$ horizontal edges, its total vertical grade is at most $m$. \end{lemma} \begin{proof} Assume all earlier steps are legal, and let $h$ be the most recent active root at a vertical edge $v$ of positive grade $s$. If $s\leq z$, Lemma~\ref{lem:red} gives a backwards witness strictly after $h$. It is also strictly after every older active root. Roots that have already closed have a strict horizontal witness. If $s>z$, the relative red height after $v$, measured immediately after $h$, is negative. Before this step that relative height was nonnegative throughout the interval after $h$, since the token of $h$ remained protected. In particular the height just before every intervening horizontal edge was nonnegative. None can start a balanced suffix ending at $v$. The horizontal witness for $(h,v)$ also fails because $h$ is active at $v$. Thus compatibility fails at the first illegal step. Zero-grade vertical edges impose no selected-pair condition and satisfy the demand automatically. The root remains protected through the last vertical edge of the interval. Its token is therefore never consumed inside the interval. At most the other $m$ red tokens can be consumed, proving the bound. \end{proof} Cyclic pairs are covered by the same witnesses. If a selected vertical edge is earlier than a selected horizontal edge after our cut, the cyclic interval passes the latter's blue closing edge before reaching its target. This is a strict horizontal witness. The same argument treats pairs in different maximal blue intervals. \section{The single-root frame}\label{sec:frames} We next determine the underlying words of all the tight gradings in \eqref{eq:tight}. This will replace the path of $k$-dependent size by a fixed finite automaton. Assign to an edge starting at $(x,y)$ the rank \[ \rho(x,y)=D_2x-D_1y. \] The horizontal starts have ranks in $[0,D_1)$ and the vertical starts have ranks in $[D_1,D_1+D_2)$. Indeed, a horizontal edge starts at $(x,\lfloor D_2x/D_1\rfloor)$, and a vertical edge in column $x$ starts at a height between $\lfloor D_2(x-1)/D_1\rfloor$ and $\lfloor D_2x/D_1\rfloor-1$. Along each step the rank increases by $D_2$ modulo $D_1+D_2$. Coprimality implies that the ranks of all edge starts are exactly $0,1,\ldots,D_1+D_2-1$. \begin{lemma}\label{lem:orientation} Every tight grading of totals $(p,q)=(kd,ke)$ has all its selected vertical edges covered by horizontal shadows. \end{lemma} \begin{proof} We show that the other shadow inclusion would force $pD_2-qD_1>0$. A maximal vertical shadow interval begins with a horizontal edge and ends with its root vertical edge. Write its numbers of edges as $n_i$ horizontal and $m_i+1$ vertical. First-return balance says that its total vertical grade is $n_i$. For each selected horizontal edge in this interval, vertical compatibility with the root fails: the root's first backwards return reaches the beginning of the interval. Horizontal compatibility consequently supplies a first-return interval ending strictly before the root. All these horizontal shadows lie inside the maximal vertical interval and avoid its last edge. Restricting the horizontal grading to this interval preserves those shadows. Their union has size equal to its total horizontal grade, by the same blue matching as above. This grade is at most $m_i$. Let $r_i$ be the rank of the first horizontal edge. The start of the last vertical edge has rank $r_i+n_iD_2-m_iD_1$. Since the former rank is below $D_1$ and the latter is at least $D_1$, we have $n_iD_2-m_iD_1>0$. All selected horizontal edges are in these maximal intervals under the assumed inclusion. Summing, and using the vertical shadow mass $\sum_i n_i=p$, gives \[ pD_2-qD_1 =\sum_i(n_iD_2-m_iD_1)+(\sum_i m_i-q)D_1>0. \] But \eqref{eq:ambient} gives $pD_2-qD_1=-k$. Thus only the stated shadow inclusion is possible. \end{proof} \begin{proposition}\label{prop:single} A tight grading of totals $(kd,ke)$ has exactly one maximal horizontal shadow interval. It has $kd+1$ horizontal edges and $ke$ vertical edges, begins at a horizontal edge of rank $\ell$ with $0\leq\ellke\geq k$. The nonnegative integer $\sum_i m_i-p$ must be zero. Consequently $\sum_i m_i=p$ and $\sum_i\delta_i=k$. Using $eD_1-dD_2=1$ gives \[ d\delta_i-m_i=(dn_i-em_i)D_1. \] Both $d\delta_i$ and $m_i$ lie in $[0,kd]$, whose length is less than $D_1$. Their difference is a multiple of $D_1$, so \begin{equation}\label{eq:proportional} m_i=d\delta_i,\qquad n_i=e\delta_i. \end{equation} Starting at rank $r_i$, the horizontal edge reached after $r_id$ horizontal steps has relative height \[ \left\lfloor\frac{r_i+r_idD_2}{D_1}\right\rfloor=r_ie, \] and hence rank zero. It belongs to the interval because $r_i<\delta_i$ and $r_id\leq m_i$. Every maximal blue interval thus contains the same rank-zero horizontal edge. Since these intervals are disjoint, there is exactly one. Its counts follow from \eqref{eq:proportional} and \eqref{eq:mass}, and its root rank satisfies $0\leq\ell\ell\}}, \qquad 1\leq x\leq kd.\label{eq:height} \end{align} Here $\mathbf{1}$ is $1$ if its subscripted condition holds and $0$ otherwise. To verify the second equality, substitute $D_2=(eD_1-1)/d$. If $d\nmid x$, the distance of $ex/d$ to an integer is at least $1/d$, whereas the perturbation $(\ell-x/d)/D_1$ has absolute value less than $k/D_1<1/d$. For $x=jd$, the sign of $\ell-j$ gives the asserted correction. At $x=kd$ the height is $ke-1$. The horizontal edge there has rank $\ell+D_1-k0$, and $F(0,u)=0$. The operator $\Delta$ preserves divisibility by every power of $t$. Thus inputs agreeing modulo $t^n$ give right-hand sides agreeing modulo $t^{n+1}$ in \eqref{eq:proper}. Successive substitution from the constant terms stabilizes each coefficient and gives a unique solution. Each stabilization involves finitely many polynomial operations in $u$ and finitely many divided differences, so the coefficients remain polynomial in $u$. The tree decomposition satisfies the equations and the same constant terms, which identifies the solution. \end{proof} \section{Algebraicity and extraction}\label{sec:algebraicity} We use the following form of the system theorem of Notarantonio and Yurkevich~\cite[Theorem~1.3]{NY}. Over any field of characteristic zero, a finite system of the form \eqref{eq:proper}, with polynomial initial terms, polynomial right-hand sides, one catalytic variable, and a fixed finite maximum order of divided differences, has a unique solution in $\FF[u][[t]]$, and every component is algebraic over $\FF(t,u)$. The difference operator in~\cite{NY} is taken at an arbitrary field element; here that element is zero. All these hypotheses hold for \eqref{eq:dde}. In particular the state number $m=3(d+e)$ and the difference order $a$ are independent of $k$. It follows that every entry of $F$ is algebraic over $\FF(t,u)$. \begin{lemma}\label{lem:specialize} If $J(t,u)\in\FF[u][[t]]$ is algebraic over $\FF(t,u)$, then $J(t,0)$ is algebraic over $\FF(t)$. \end{lemma} \begin{proof} Choose a nonzero polynomial $P(t,u,Z)\in\FF[t,u,Z]$ annihilating $J$. Divide its coefficients by their greatest common power of $u$. Since multiplication by $u$ is injective on $\FF[u][[t]]$, the resulting polynomial still annihilates $J$ and its specialization at $u=0$ is nonzero. Evaluating the identity at $u=0$ gives the desired relation. \end{proof} \begin{proof}[Proof of Theorem~\ref{thm:main}] The graph selects the words $W_{k,\ell}$ with their root-rank multiplicities. Specializing $u=0$ selects subtrees whose final free balance is zero. Proposition~\ref{prop:bijection} therefore gives \begin{equation}\label{eq:extract} \alpha F(t,0)\beta =\sum_{k\geq1}c_kt^{k(d+e)+1} =t\bigl(G_{d,e}(t^{d+e})-1\bigr). \end{equation} The extra unit of length is the root horizontal edge. By the system theorem and Lemma~\ref{lem:specialize}, the left side is algebraic over $\FF(t)$. Hence so is $G_{d,e}(t^{d+e})$. The extension $\FF(t)/\FF(t^{d+e})$ is finite algebraic, so transitivity makes this series algebraic over $\FF(t^{d+e})$. Pulling back a nonzero relation through the injective substitution $z\mapsto t^{d+e}$ proves that $G_{d,e}(z)$ is algebraic over $\FF(z)$. \end{proof} \begin{example} For $P_1(X)=1+w_1X$ and $P_2(Y)=1+v_1Y$, the direction $(1,1)$ has wall function $G_{1,1}(z)=1+w_1v_1z$. \end{example} \begin{proof} At $k=1$ the only accepted decoration is $EEN$ with grades $(1,0,1)$, of weight $v_1w_1$. For $k>1$ the frames are $(EN)^\ell E(EN)^{k-\ell-1}EN$. If $\ell>0$, the root closes at the first $N$, too early. If $\ell=0$, every $EN$ before the final $EN$ must be a child with grades $(1,0)$: a zero horizontal grade would close the global root, and a positive vertical grade would consume the child's protected token. The last vertical edge can have grade at most one, whereas the required total is $k$. Thus no accepted decoration occurs for $k>1$. \end{proof}