40.01.04 · combinatorics / enumeration-generating-functions

Rational Generating Functions, the Transfer-Matrix Method, and P-Partitions

shipped3 tiersLean: none

Anchor (Master): Stanley 2012 *Enumerative Combinatorics, Volume 1* 2e §4.1-4.7 (rational and quasi-polynomial generating functions, the transfer-matrix method and its determinant theorem, the theory of (P,omega)-partitions, the order polynomial and reciprocity); Lindstroem 1973 *Acta Math.* and Gessel-Viennot 1985 *Adv. Math.* 58 (nonintersecting lattice paths as a determinant); Stanley 1972 *Ordered Structures and Partitions* (Mem. AMS 119) for the originating P-partition theory

Intuition Beginner

The previous unit turned a sequence into one algebraic object and discovered that the Fibonacci numbers come out of a single ratio, divided by . That was not luck. Whenever each term of a sequence is a fixed combination of a few earlier terms, the whole sequence hides inside one ratio of polynomials. Such a ratio is called a rational generating function, and "rational" here means exactly what it means for numbers: one polynomial over another.

Why does this matter? Because the bottom polynomial controls everything. Its roots fix the building blocks the sequence is made of, and reading those blocks off gives a closed formula of a clean shape: a few fixed bases raised to the power , each scaled by a slowly growing polynomial in . The Fibonacci numbers, for instance, turn out to be a fixed multiple of the golden ratio raised to the power , rounded. The bottom polynomial is the fingerprint of the recurrence.

The second big idea is a picture. Many counting problems are secretly about walking through a small diagram. Counting words that never contain a forbidden pattern, or counting ways to tile a long thin strip, becomes counting paths of length through a handful of states. If you record the allowed one-step moves in a small grid of numbers, then raising that grid to the power counts every length- path at once. This is the transfer-matrix method: a tiny grid of numbers, raised to higher and higher powers, that does an enormous amount of counting.

The third idea, P-partitions, counts ways to label a partly-ordered collection of slots with numbers that respect the order — taller slots get larger labels. It links the counting of these labellings back to ordinary integer partitions and to the same rational-ratio machinery, closing the loop of the chapter.

Visual Beginner

Picture a board you want to tile with dominoes. A board (two rows, columns) is tiled column by column, and at the seam between column and column the only thing that matters is which squares are already poking across the seam. There are only a few possible seam states, so you can draw a little diagram: each dot is a seam state, and an arrow from one dot to another means "you can fill the next column and move from this seam to that seam".

The number of tilings of the whole board is the number of paths through this diagram from the empty start seam back to the empty end seam. The table below records the diagram as a grid: a where an arrow exists and a where it does not. Raising the grid to the power and reading one entry gives the number of length- paths, which is the number of tilings.

from state \ to state empty top overhang bottom overhang
empty 1 1 1
top overhang 1 0 0
bottom overhang 1 0 0

Each row says where you can go next from a given seam. The whole method is: build this small grid once, then powers of the grid count paths of every length, and one ratio of polynomials packages all those counts together.

Worked example Beginner

Let us count tilings of a board by dominoes using a two-state diagram, and pull out the familiar Fibonacci answer. Read the board column by column. After filling some columns flush, the seam is either flat (no square sticks across) or has a single square sticking across into the next column from a horizontal domino.

Step 1. Draw two states: (flat seam) and (one square poking across). From you may place one vertical domino and stay flat (), or place a horizontal domino in one row, poking across (). From the poking square forces the matching horizontal domino, which lands you flat again (). There is no move.

Step 2. Record the moves as a grid, rows and columns ordered : the row is and the row is . Call this grid .

Step 3. Count tilings as flat-to-flat paths. A full tiling starts flat and ends flat, so the number of tilings of width is the top-left entry of raised to the power . Compute the powers. has top-left . Squaring, has top-left . Cubing, has top-left . The next is , then .

Step 4. Read the pattern. The top-left entries are , the Fibonacci numbers. So a board has a Fibonacci number of domino tilings, and the bottom polynomial of the matching ratio is , exactly the Fibonacci denominator from the previous unit.

What this tells us: a counting problem with a small number of "seam states" becomes powers of a small grid, and the grid's powers reproduce a recurrence and its rational generating function without our ever guessing the recurrence by hand.

Check your understanding Beginner

Formal definition Intermediate+

Fix a field of characteristic zero (take ). A sequence in satisfies a constant-coefficient linear recurrence of order if there are constants with such that for all . The ordinary generating function is , following 40.01.03.

Definition (rational generating function). is rational if in the field of fractions , with , (so exists), and . The denominator is ; the reciprocals of its roots are the characteristic roots . After partial fractions over , the coefficients take the form , where has degree strictly below the multiplicity of .

Definition (quasi-polynomial). A function is a quasi-polynomial of period if there are polynomials with whenever . A sequence is a quasi-polynomial iff its generating function is with every root of a root of unity; the period is the least common multiple of the orders of those roots.

Definition (transfer matrix). Let be a finite directed graph (loops and multiple edges allowed) with an edge weight on each edge. The transfer matrix is indexed by , with the total weight of edges from to . A walk of length from to is a sequence of edges ; its weight is the product of the edge weights, and is the total weight of all length- walks from to .

Definition (labelled poset and (P,)-partition). Let be a finite poset with elements and a bijective labelling. A (P,)-partition is a map that is order-reversing () and strictly decreasing across -decreasing covers (if and then ). When is the natural labelling (order-preserving on ), every cover is weak and a -partition is simply an order-reversing map , the P-partitions of . The notation , , , and is recorded in _meta/NOTATION.md.

Counterexamples to common slips Intermediate+

  • "Every sequence has a rational generating function." The Catalan numbers do not: their generating function is algebraic but not rational, because obeys no constant-coefficient linear recurrence — the coefficients in are not constant. Rationality is the precise dividing line of constant-coefficient recurrences.

  • "The denominator may be chosen with ." If then and is not a power series at the origin. The normalisation is always available by scaling, and the recurrence is read off the coefficients of this normalised .

  • "Powers of the transfer matrix count walks only when the weights are ." The construction is weighted from the start: with edge weight on every edge, tracks walks by length; with a variable marking a statistic, becomes a multivariate generating function. The unweighted case is the specialisation .

  • "A P-partition is the same as an integer partition." An integer partition of is a P-partition of a single chain (totally ordered ), where order-reversing maps into summing to are weakly decreasing sequences. A general poset has incomparable elements, so its P-partitions are not weakly ordered — that extra freedom is exactly what the fundamental theorem organises.

Key theorem with proof Intermediate+

The signature theorem is the transfer-matrix theorem, because it converts the entire walk-counting problem on a finite digraph into a single rational generating function whose denominator is a determinant, and it is the mechanism by which tilings, restricted words, and constrained lattice walks all become rational [Stanley §4.7].

Theorem (transfer-matrix method). Let be the transfer matrix of a finite weighted digraph on vertex set with , and let be the identity. Then for any vertices the walk-generating function is the entry of the matrix inverse $$ \sum_{n \ge 0} (A^n){ij}, x^n ;=; \big[(I - xA)^{-1}\big]{ij} ;=; \frac{(-1)^{i+j},\det!\big(I - xA : j, i\big)}{\det(I - xA)}, $$ where is the minor deleting row and column . In particular each walk-generating function is rational with common denominator , a polynomial of degree with constant term .

Proof. Work in the ring of matrices over formal power series. The matrix has constant term (an invertible matrix), so it is a unit: its inverse is the Neumann series $$ (I - xA)^{-1} = \sum_{n \ge 0} (xA)^n = \sum_{n \ge 0} A^n x^n, $$ which converges formally because the term is the single matrix , so each coefficient is determined by finitely many terms (the order condition of 40.01.03). Taking the entry, , the walk-generating function, since is by construction the total weight of length- walks from to (each matrix product sums, over intermediate vertices, the products of edge weights along a walk). This proves the first equality.

For the second, apply Cramer's rule to the linear system over the field : the unique solution has , where is with its -th column replaced by . Cofactor-expanding along that column gives , the signed minor deleting row and column . Since has constant term and degree at most (each of the diagonal factors contributes at most one power of , the off-diagonal entries are each ), the entry is a ratio of polynomials with and denominator constant term .

Corollary (tilings of a board). With the two-state transfer matrix A = \begin{psmallmatrix} 1 & 1 \\ 1 & 0 \end{psmallmatrix} of the worked example, \det(I - xA) = \det\begin{psmallmatrix} 1 - x & -x \\ -x & 1 \end{psmallmatrix} = 1 - x - x^2, so the flat-to-flat generating function is up to numerator, recovering the Fibonacci tiling count and confirming the denominator predicted by the diagram.

Bridge. This theorem is the foundational reason rational generating functions and finite-state counting are the same subject: a constant-coefficient recurrence is precisely a walk count on a finite digraph, and the denominator exhibits the characteristic roots as reciprocal eigenvalues of , which builds toward the spectral reading where the dominant root is the Perron-Frobenius eigenvalue of 38.02.03. The Neumann-series proof is exactly the matrix lift of the scalar identity , and it generalises the sequence rule of 40.01.03 from one part-type to a finite state space of part-types; putting these together, the rationality of every walk-generating function appears again in 40.08.04 as the automatic rationality of regular languages and in the transfer-matrix determinant theorem of the next section. The central insight is that diagonalising the convolution by partial fractions is the same operation as diagonalising the transfer matrix by its eigenvalues, so the closed form is dual to the spectral decomposition of .

Exercises Intermediate+

Advanced results Master

The transfer-matrix circle and the rationality theorem extend through the determinant theorem, the cluster method for forbidden factors, the nonintersecting-path determinant, and the theory of -partitions with its order-polynomial reciprocity.

Theorem 1 (rationality theorem). A sequence over a field satisfies a constant-coefficient linear recurrence of order for all if and only if with , , and . The characteristic roots (reciprocals of the roots of ) and their multiplicities determine the closed form with ; conversely any such finite sum is the coefficient sequence of a rational function with that denominator. The Hankel determinants vanish for exactly when the order is , giving an intrinsic rank criterion for rationality [Stanley §4.1].

Theorem 2 (transfer-matrix determinant theorem). With the transfer matrix of a weighted digraph , , summed over all linear subgraphs (vertex-disjoint unions of directed cycles), where is the number of cycles, the total edge count, and the weight product. Consequently the walk-generating function has denominator the characteristic polynomial and numerator a signed sum over linear subgraphs of a path correction; the poles are the reciprocal eigenvalues of , so the asymptotics of are governed by the largest eigenvalue [Stanley §4.7].

Theorem 3 (Goulden-Jackson cluster method). The generating function for words over a finite alphabet avoiding every member of a set of forbidden factors is the rational function $$ \sum_{w \text{ avoiding } \mathcal{B}} x^{|w|} = \frac{1}{1 - |\mathcal{A}|x - \mathrm{C}(x)}, $$ where is the cluster generating function built from the overlap (correlation) structure of the forbidden factors. The denominator is a polynomial when is finite, so the avoidance count satisfies a constant-coefficient recurrence; this is the transfer-matrix method recast through the inclusion-exclusion of overlapping occurrences [Goulden-Jackson 1983].

Theorem 4 (Lindström-Gessel-Viennot). In an acyclic digraph with sources and sinks , the signed sum over permutations equals the weighted count of families of nonintersecting paths, where is the (weighted) path count. When the poset of sources and sinks forces every nonintersecting family to realise the identity permutation, the count of nonintersecting families is the determinant . The proof is the sign-reversing involution swapping path tails at a first intersection; the determinant of binomial path-counts yields the Jacobi-Trudi identity for Schur functions and the MacMahon box formula for plane partitions, the nonintersecting-path theory owned by 40.03.04 [Lindström 1973, Gessel-Viennot 1985].

Theorem 5 (-partition generating function and reciprocity). For a labelled poset with , the order cone of -partitions decomposes as a disjoint union over the linear extensions of (the fundamental theorem), giving $$ \sum_{\sigma}\prod_{t \in P} q^{\sigma(t)} = \sum_{w \in \mathcal{L}(P)} \frac{q^{\mathrm{maj}(w)}}{(1-q)(1-q^2)\cdots(1-q^p)}, $$ and at the level of quasi-symmetric functions , a sum of Gessel's fundamental quasi-symmetric functions over linear extensions. The order polynomial is a polynomial in of degree , and the strict and weak order polynomials satisfy the reciprocity , the combinatorial reciprocity that anticipates Ehrhart and Stanley reciprocity for order polytopes [Stanley, Ordered Structures 1972].

Synthesis. The rationality theorem is the foundational reason finitary structure and rational generating functions coincide: a sequence is rational exactly when it is a walk count on a finite digraph, and the transfer-matrix theorem is the matrix lift of the scalar sequence rule from 40.01.03, with the denominator exhibiting the characteristic roots as reciprocal eigenvalues. The central insight is that partial fractions, the spectral decomposition of , and the cycle structure of the digraph are three faces of one object: the closed form is dual to the eigenvalue expansion of , and the largest eigenvalue's dominance is exactly the Perron-Frobenius theorem of 38.02.03, so asymptotic growth is read off the spectral radius. Putting these together, the determinant theorem turns counting into the cycle combinatorics of a digraph, the cluster method specialises it to forbidden-factor avoidance, and the Lindström-Gessel-Viennot lemma is the same determinant-as-signed-sum principle applied to lattice paths, which generalises into the Schur-function and plane-partition enumeration of 40.03.04. The bridge is that -partition theory closes the circle: the order generating function factors over linear extensions into chain generating functions — themselves rational, the single-chain instance of the whole machinery — and the order-polynomial reciprocity is the quasi-polynomial denominator-period phenomenon read on the poset, so the chapter's rational, transfer-matrix, and partition strands are one theory of finitely-generated counting.

Full proof set Master

Proposition 1 (rationality theorem, forward direction). If satisfies for , then with , ; and partial fractions give with .

Proof. As in Exercise 3, with , of degree , and makes valid in . Factor over , the distinct with . Partial fractions over write (the numerator degree being below the denominator degree, no polynomial part). Since , a polynomial in of degree times , summing gives with of degree .

Proposition 2 (rationality theorem, converse). If with of degree , then is rational with denominator dividing , and satisfies a constant-coefficient linear recurrence.

Proof. Each summand is , so is a finite -combination of these, hence rational with denominator (of degree ) after clearing. Writing , the relation with forces, on comparing coefficients for , the recurrence . The operator , where is the shift , annihilates each (the factor kills a degree- polynomial times ), giving the recurrence intrinsically.

Proposition 3 (transfer-matrix walk-counting identity). , and the common denominator of all entries is , with constant term .

Proof. In , is invertible because its constant term is invertible; the inverse is , the formal Neumann series, convergent coefficientwise (the -coefficient is the single matrix ). The entry is . Matrix multiplication gives , the total weight of length- walks , establishing the combinatorial identity. By the adjugate formula , every entry is a polynomial over ; since , the denominator has constant term and the entries lie in .

Proposition 4 (fundamental theorem of -partitions). The set of -partitions is the disjoint union, over linear extensions of , of the sets of partitions of the corresponding labelled chain; hence the order generating function factors as .

Proof. A -partition induces a total preorder on by the values , refined to a total order by the labels on ties: declare if , or and . This total order is a linear extension of (it refines the partial order, since is order-reversing with the strict-on--descent rule), and is a -partition of the resulting chain. Conversely each linear extension contributes the partitions of its chain that are strictly decreasing exactly at the descents of (positions where decreases along ) and weakly decreasing elsewhere; these are encoded by a sequence of nonnegative integers with prescribed weak/strict steps, whose generating function is by the standard bijection sending a descent at position to a forced unit increment (the major-index statistic collecting these forced increments). The map is well-defined and its fibres are exactly , so and the generating functions add.

Connections Master

  • The transfer matrix's denominator makes the characteristic roots the reciprocal eigenvalues of , so the asymptotic growth is governed by the spectral radius — the Perron-Frobenius eigenvalue when is a nonnegative irreducible matrix. The Perron-Frobenius theory of 38.02.03 approaches the same matrix from the eigenvector and positivity angle (existence of a positive dominant eigenvalue and eigenvector); this unit supplies the generating-function and walk-counting angle, and the two meet at the dominant pole of the rational walk-generating function.

  • The Lindström-Gessel-Viennot lemma proved here as a determinant is the engine of the nonintersecting-lattice-path enumeration developed at 40.03.04, where the general determinant of binomial path-counts yields the Jacobi-Trudi identity for Schur functions, the MacMahon box generating function for plane partitions, and the hook-length formula. The forward link is exact: the sign-reversing tail-swap involution here is the case of the involution that proves the full determinant formula there.

  • The -partition generating function expands into Gessel's fundamental quasi-symmetric functions summed over linear extensions, the preview of the quasi-symmetric and symmetric function theory owned by 40.08.06; the chain generating function is the single-chain instance, and the order-polynomial reciprocity is the combinatorial-reciprocity shadow of the Ehrhart reciprocity for order polytopes treated in 40.03.02.

  • The rationality theorem's reading of a constant-coefficient recurrence as a rational generating function is the formal-power-series specialisation of the sequence rule of 40.01.03, here with a finite state space rather than a single part-type; the same rationality reappears as the regularity of formal languages and finite automata in the symbolic method of 40.08.04, where avoidance of a finite set of factors is exactly the cluster/transfer-matrix denominator computed in this unit.

Historical & philosophical context Master

The reading of a linear recurrence as a rational generating function is among the oldest analytic tools in combinatorics, traceable to Abraham de Moivre's work on recurrent series in the Miscellanea Analytica (1730) and the Doctrine of Chances, where the partial-fraction solution of a constant-coefficient recurrence first appears systematically; Euler's 1748 Introductio [Stanley §4.1, on the analytic tradition] embedded it in the generating-function method. The transfer-matrix method itself crystallised in twentieth-century statistical mechanics — Kramers and Wannier's 1941 transfer matrix for the two-dimensional Ising model, and Lieb, Temperley, and Fisher's dimer and tiling enumerations — before being abstracted into the purely combinatorial walk-counting form presented in Stanley's Enumerative Combinatorics.

The determinant for nonintersecting paths has a doubled history: Bernt Lindström proved it in 1973 in the language of matroid representations [Lindström 1973], and Ira Gessel and Gérard Viennot rediscovered and systematically deployed it in 1985 [Gessel-Viennot 1985], connecting it to the Jacobi-Trudi identity and to plane-partition enumeration; the result is now universally called the Lindström-Gessel-Viennot lemma. The theory of P-partitions is Richard Stanley's doctoral work, published as Ordered Structures and Partitions in 1972 [Stanley, Ordered Structures 1972], which unified MacMahon's much earlier partition-analysis computations under a single poset-theoretic generating function and supplied the combinatorial reciprocity that later became the order-polytope instance of Ehrhart reciprocity. Gessel's fundamental quasi-symmetric functions, introduced in his own 1984 thesis-derived work, gave the P-partition generating function its modern symmetric-function home.

Bibliography Master

@book{stanley2012ec1,
  author    = {Stanley, Richard P.},
  title     = {Enumerative Combinatorics, Volume 1},
  series    = {Cambridge Studies in Advanced Mathematics},
  volume    = {49},
  edition   = {2},
  publisher = {Cambridge University Press},
  year      = {2012}
}

@book{stanley1972ordered,
  author    = {Stanley, Richard P.},
  title     = {Ordered Structures and Partitions},
  series    = {Memoirs of the American Mathematical Society},
  number    = {119},
  publisher = {American Mathematical Society},
  year      = {1972}
}

@article{lindstrom1973,
  author  = {Lindstr\"{o}m, Bernt},
  title   = {On the vector representations of induced matroids},
  journal = {Bulletin of the London Mathematical Society},
  volume  = {5},
  year    = {1973},
  pages   = {85--90}
}

@article{gesselviennot1985,
  author  = {Gessel, Ira and Viennot, G\'{e}rard},
  title   = {Binomial determinants, paths, and hook length formulae},
  journal = {Advances in Mathematics},
  volume  = {58},
  number  = {3},
  year    = {1985},
  pages   = {300--321}
}

@book{gouldenjackson1983,
  author    = {Goulden, Ian P. and Jackson, David M.},
  title     = {Combinatorial Enumeration},
  publisher = {John Wiley \& Sons},
  year      = {1983}
}

@article{kramerswannier1941,
  author  = {Kramers, H. A. and Wannier, G. H.},
  title   = {Statistics of the two-dimensional ferromagnet. Part I},
  journal = {Physical Review},
  volume  = {60},
  year    = {1941},
  pages   = {252--262}
}

@book{demoivre1730miscellanea,
  author    = {de Moivre, Abraham},
  title     = {Miscellanea Analytica de Seriebus et Quadraturis},
  publisher = {J. Tonson \& J. Watts},
  address   = {London},
  year      = {1730}
}