Symbolic Method

The symbolic method quickly converts combinatorial objects into generating functions. We consider particular operations defined on sets and derive the corresponding operations on their generating functions.

We call a combinatorial class (or simply a class), where is the set of combinatorial objects and maps each object to a finite nonnegative integer called its size. (A,∣⋅∣)(\mathcal{A},\lvert \cdot \rvert) A\mathcal{A} ∣⋅∣\lvert \cdot \rvert {0,1}\lbrace 0,1\rbrace 00

This article is a simplified treatment based on Chapter 1 of the book Analytic Combinatorics.

Unlabelled Systems

In an unlabelled system, ordinary generating functions (OGFs) are used. For a class , its OGF is denoted by A\mathcal{A}

A(z)=∑α∈Az∣α∣=∑n≥0anznA(z)=\sum_{\alpha\in\mathcal{A}}z^{\lvert \alpha \rvert}=\sum_{n\geq 0}a_nz^n

We use the same letters for a class and its generating function. The coefficient counts objects in of size . ana_n [zn]A(z)\lbrack z^n\rbrack A(z) A(z)A(z) znz^n An\mathcal{A}_n A\mathcal{A} nn an=card⁡(An)a_n=\operatorname{card}(\mathcal{A}_n) card⁡\operatorname{card}

Admissibility is not discussed in this article; readers may consult the references.

We next introduce two special kinds of combinatorial classes and objects:

Let be the neutral object and the neutral class; their size and OGF are and . ϵ\epsilon E={ϵ}\mathcal{E}=\lbrace \epsilon \rbrace 00 E(z)=1E(z)=1 Let or be an atom and the atom class; an atom has size and . ∘\circ ∙\bullet Z∘={∘}\mathcal{Z}_{\circ}=\lbrace \circ\rbrace Z∙={∙}\mathcal{Z}_{\bullet}=\lbrace \bullet\rbrace Z\mathcal{Z} 11 Z(z)=zZ(z)=z

Two classes and that are combinatorially isomorphic are written or ; use the latter only for a nontrivial isomorphism. A\mathcal{A} B\mathcal{B} A=B\mathcal{A}=\mathcal{B} A≅B\mathcal{A}\cong\mathcal{B}

We have

A≅E×A≅A×E\mathcal{A}\cong\mathcal{E}\times \mathcal{A}\cong\mathcal{A}\times\mathcal{E}

where is a binary operation denoting the Cartesian product of sets. ×\times

Set (Disjoint) Union Construction

For classes and , their union is denoted by A\mathcal{A} B\mathcal{B}

A+B=(E1×A)+(E2×B)\mathcal{A}+\mathcal{B}=(\mathcal{E}_{1}\times\mathcal{A})+(\mathcal{E}_2\times\mathcal{B})

This definition preserves disjointness in set theory: imagine coloring objects of red and objects of blue. A\mathcal{A} B\mathcal{B}

The corresponding OGF is

A(z)+B(z)A(z)+B(z)

Consider

A(z)+B(z)=∑α∈Az∣α∣+∑β∈Bz∣β∣=∑n≥0(an+bn)znA(z)+B(z)=\sum _ {\alpha\in\mathcal{A}}z^{\lvert \alpha\rvert} + \sum _ {\beta\in\mathcal{B}}z^{\lvert \beta\rvert}=\sum_{n\geq 0}(a_n+b_n)z^n

This corresponds to addition of formal power series.

Cartesian Product Construction for Sets

For classes and , their Cartesian product is denoted by A\mathcal{A} B\mathcal{B}

A×B={(α,β)∣α∈A,β∈B}\mathcal{A}\times \mathcal{B}=\left\lbrace (\alpha, \beta)\mid \alpha \in \mathcal{A},\beta\in\mathcal{B}\right\rbrace

The corresponding OGF is

A(z)⋅B(z)A(z)\cdot B(z)

Define the size of as the sum of the sizes of its components. (α,β)(\alpha,\beta)

γ=(α1,α2,…,αn)  ⟹  ∣γ∣=∣α1∣+∣α2∣+⋯+∣αn∣\gamma =(\alpha_1,\alpha_2,\dots ,\alpha_n)\implies \lvert \gamma\rvert =\lvert \alpha_1\rvert +\lvert \alpha_2\rvert +\cdots +\lvert \alpha_n\rvert

Therefore

A(z)⋅B(z)=(∑α∈Az∣α∣)(∑β∈Bz∣β∣)=∑(α,β)∈(A×B)z∣α∣+∣β∣=∑n≥0∑i+j=naibjznA(z)\cdot B(z)=\left(\sum _ {\alpha\in\mathcal{A}}z^{\lvert \alpha\rvert}\right)\left(\sum _ {\beta\in\mathcal{B}}z^{\lvert \beta\rvert}\right)=\sum _ {(\alpha, \beta)\in(\mathcal{A}\times \mathcal{B})}z^{\lvert \alpha\rvert +\lvert \beta\rvert}=\sum_{n\geq 0}\sum_{i+j=n}a_ib_jz^n

This corresponds to multiplication of formal power series.

Sequence Construction for Sets

The Sequence construction generates all possible combinations.

Example SEQ⁡({a})={ϵ}+{a}+{(a,a)}+{(a,a,a)}+⋯SEQ⁡({a,b})={ϵ}+{a,b}+{(a,b)}+{(b,a)}+{(a,a)}+{(b,b)}+{(a,b,a)}+{(a,b,b)}+{(a,a,b)}+{(b,b,a)}+{(b,a,b)}+{(b,b,b)}+{(a,a,a)}+{(b,a,a)}+⋯\begin{aligned} \operatorname{SEQ}(\lbrace a\rbrace)&=\lbrace \epsilon\rbrace +\lbrace a\rbrace +\lbrace (a,a)\rbrace +\lbrace (a,a,a)\rbrace +\cdots\\ \operatorname{SEQ}(\lbrace a,b\rbrace)&=\lbrace \epsilon\rbrace +\lbrace a,b\rbrace +\lbrace (a,b)\rbrace + \lbrace(b,a)\rbrace +\lbrace (a,a)\rbrace +\lbrace (b,b)\rbrace\\ &+\lbrace (a,b,a)\rbrace +\lbrace (a,b,b)\rbrace +\lbrace (a,a,b)\rbrace\\ &+\lbrace (b,b,a)\rbrace +\lbrace (b,a,b)\rbrace +\lbrace (b,b,b)\rbrace +\lbrace (a,a,a)\rbrace +\lbrace (b,a,a)\rbrace\\ &+\cdots \end{aligned}

Different component orders, such as and , are both generated, so Sequence generates ordered combinations. {(a,b)},{(b,a)}\lbrace (a,b)\rbrace ,\lbrace (b,a)\rbrace

We define

SEQ⁡(A)=E+A+(A×A)+(A×A×A)+⋯\operatorname{SEQ}(\mathcal{A})=\mathcal{E}+\mathcal{A}+(\mathcal{A}\times \mathcal{A})+(\mathcal{A}\times \mathcal{A}\times \mathcal{A})+\cdots

and require , that is, contains no object of size . A0=∅\mathcal{A}_0=\varnothing A\mathcal{A} 00

this OGF is

Q(A(z))=1+A(z)+A(z)2+A(z)3+⋯=11−A(z)Q(A(z))=1+A(z)+A(z)^2+A(z)^3+\cdots =\frac{1}{1-A(z)}

where is the Pólya quasi-inverse. QQ

Example: ordered rooted trees

We can use the Sequence construction to define ordered rooted trees, that is, rooted trees in which the order among children matters. If the class is , a tree consists of a root node and a Sequence of trees: T\mathcal{T}

T={∙}×SEQ⁡(T)\mathcal{T}=\lbrace \bullet\rbrace\times\operatorname{SEQ}(\mathcal{T})

this OGF is

T(z)=z1−T(z)T(z)=\frac{z}{1-T(z)}

The first coefficients are ; ignoring the constant term, this is OEIS . 0 1 1 2 5 14 42 132 429 1430 4862 16796 Reference

Multiset Construction for Sets

The Multiset construction generates all combinations without distinguishing the order of components.

Example MSET⁡({a})={ϵ}+{a}+{(a,a)}+{(a,a,a)}+⋯MSET⁡({a,b})={ϵ}+{a}+{(a,a)}+{(a,a,a)}+⋯+{b}+{(a,b)}+{(a,a,b)}+⋯+{(b,b)}+{(a,b,b)}+{(a,a,b,b)}+⋯+⋯\begin{aligned} \operatorname{MSET}(\lbrace a\rbrace)&=\lbrace \epsilon\rbrace +\lbrace a\rbrace +\lbrace (a,a)\rbrace +\lbrace (a,a,a)\rbrace +\cdots\\ \operatorname{MSET}(\lbrace a,b\rbrace)&=\lbrace \epsilon\rbrace +\lbrace a\rbrace +\lbrace (a,a)\rbrace +\lbrace (a,a,a)\rbrace +\cdots\\ &+\lbrace b\rbrace +\lbrace (a,b)\rbrace +\lbrace (a,a,b)\rbrace +\cdots \\ &+\lbrace (b,b)\rbrace + \lbrace (a,b,b)\rbrace +\lbrace (a,a,b,b)\rbrace + \cdots\\ &+\cdots \end{aligned}

Notice that sequences with the same components in a different order are identified by the Multiset construction. {(b,a)},{(a,b,a)}\lbrace (b,a)\rbrace,\lbrace (a,b,a)\rbrace SEQ⁡({a,b})\operatorname{SEQ}(\lbrace a,b\rbrace) MSET⁡({a,b})\operatorname{MSET}(\lbrace a,b\rbrace)

We define its recurrence as

MSET⁡({α0,α1,…,αn})=MSET⁡({α0,α1,…,αn−1})×SEQ⁡({αn})\operatorname{MSET}(\lbrace \alpha_0,\alpha_1,\dots, \alpha_n\rbrace)=\operatorname{MSET}(\lbrace \alpha_0,\alpha_1,\dots, \alpha_{n-1}\rbrace)\times \operatorname{SEQ}(\lbrace \alpha_n\rbrace)

That is,

MSET⁡(A)=∏α∈ASEQ⁡({α})\operatorname{MSET}(\mathcal{A})=\prod _ {\alpha\in\mathcal{A}}\operatorname{SEQ}(\lbrace \alpha\rbrace)

and require . Equivalently, we may write A0=∅\mathcal{A}_0=\varnothing

MSET⁡(A)=SEQ⁡(A)/R\operatorname{MSET}(\mathcal{A})=\operatorname{SEQ}(\mathcal{A})/\mathbf{R}

where is an equivalence relation. We say if and only if there exists a permutation such that for every , . R\mathbf{R} (α1,…,αn)R(β1,…,βn)(\alpha_1,\dots,\alpha_n)\mathbf{R}(\beta_1,\dots,\beta_n) σ\sigma jj βj=ασ(j)\beta_{j}=\alpha_{\sigma(j)}

this OGF is

Exp⁡(A(z))=∏α∈A(1−z∣α∣)−1=∏n≥1(1−zn)−an\operatorname{Exp}(A(z))=\prod _ {\alpha \in\mathcal{A}}\left(1-z^{\lvert \alpha \rvert}\right)^{-1}=\prod _ {n\geq 1}\left(1-z^n\right)^{-a_n}

Notice that

ln⁡(1+z)=z1−z22+z33−⋯=∑n≥1(−1)n−1znn\ln(1+z)=\frac{z}{1}-\frac{z^2}{2}+\frac{z^3}{3}-\cdots =\sum_{n\geq 1}\frac{(-1)^{n-1}z^n}{n}

and , so A(z)=exp⁡(ln⁡(A(z)))A(z)=\exp(\ln(A(z)))

Exp⁡(A(z))=exp⁡(∑n≥1−an⋅ln⁡(1−zn))=exp⁡(∑n≥1−an⋅∑m≥1−znmm)=exp⁡(A(z)1+A(z2)2+A(z3)3+⋯ )\begin{aligned} \operatorname{Exp}(A(z))&=\exp\left(\sum _ {n\geq 1}-a_n\cdot \ln\left(1-z^n\right)\right)\\ &=\exp\left(\sum _ {n\geq 1}-a_n\cdot \sum _ {m\geq 1}\frac{-z^{nm}}{m}\right)\\ &=\exp\left(\frac{A(z)}{1}+\frac{A(z^2)}{2}+\frac{A(z^3)}{3}+\cdots \right) \end{aligned}

The operator is the Pólya exponential, also called the Euler transform. Exp⁡\operatorname{Exp}

Example LOJ 6268. Partition numbers

Problem: Let be the number of partitions of . Find modulo . f(n)f(n) nn f(1),f(2),…,f(105)f(1),f(2),\dots,f(10^5) 998244353998244353

Solution: Let be the class of all positive integers. Then (the subscript is a restricted construction, discussed below). What is required is I\mathcal{I} I=SEQ⁡≥1(Z)=Z×SEQ⁡(Z)\mathcal{I}=\operatorname{SEQ}_{\geq 1}(\mathcal{Z})=\mathcal{Z}\times \operatorname{SEQ}(\mathcal{Z}) ≥1\geq 1

MSET⁡(I)\operatorname{MSET}(\mathcal{I})

The first coefficients of this OGF are (ignoring the constant term), namely OEIS . 1 2 3 5 7 11 15 22 30 42 Reference

Example Luogu P4389. Fu Princess’s Knapsack

Problem: Given kinds of goods with volumes and a positive integer , find the number of ways to fill knapsacks of volumes modulo (unlimited quantities of goods are allowed, and goods of the same volume but different kinds are distinct). Assume and . nn v1,…,vnv_1,\dots ,v_n mm 1,2,…,m1,2,\dots,m 998244353998244353 1≤n,m≤1051\leq n,m\leq 10^5 1≤vi≤m1\leq v_i\leq m

Solution: Let be the class of goods. The desired values are the coefficients of the OGF corresponding to . A\mathcal{A} MSET⁡(A)\operatorname{MSET}(\mathcal{A})

Example Luogu P5900. Counting unlabelled unrooted trees

Problem: Find the number of unlabelled unrooted trees with vertices modulo . Assume . nn 998244353998244353 1≤n≤2×1051\leq n\leq 2\times 10^5

Solution: Let be the combinatorial class of unlabelled rooted trees. Then T\mathcal{T}

T={∙}×MSET⁡(T)\mathcal{T}=\lbrace \bullet\rbrace\times\operatorname{MSET}(\mathcal{T})

According to Richard Otter’s paper , the OGF of unrooted trees is Reference

T(z)−12T2(z)+12T(z2)T(z)-\frac{1}{2}T^2(z)+\frac{1}{2}T(z^2)

The first coefficients are (ignoring the constant term), namely OEIS . 1 1 1 2 3 6 11 23 47 106 Reference

Powerset Construction for Sets

The Powerset construction generates all subsets.

Example PSET⁡({a})={ϵ}+{a}PSET⁡({a,b})={ϵ}+{a}+{b}+{(a,b)}PSET⁡({a,b,c})={ϵ}+{a}+{b}+{(a,b)}+{c}+{(a,c)}+{(b,c)}+{(a,b,c)}\begin{aligned} \operatorname{PSET}(\lbrace a\rbrace)&=\lbrace \epsilon\rbrace +\lbrace a\rbrace \\ \operatorname{PSET}(\lbrace a,b\rbrace)&=\lbrace \epsilon\rbrace +\lbrace a\rbrace +\lbrace b\rbrace +\lbrace (a,b)\rbrace \\ \operatorname{PSET}(\lbrace a,b,c\rbrace)&=\lbrace \epsilon\rbrace +\lbrace a\rbrace +\lbrace b\rbrace +\lbrace (a,b)\rbrace +\lbrace c\rbrace +\lbrace (a,c)\rbrace +\lbrace (b,c)\rbrace +\lbrace (a,b,c)\rbrace\\ \end{aligned}

We define its recurrence as

PSET⁡({α0,α1,…,αn})=PSET⁡({α0,α1,…,αn−1})×({ϵ}+{αn})\operatorname{PSET}(\lbrace \alpha_0,\alpha_1,\dots, \alpha_n\rbrace)=\operatorname{PSET}(\lbrace \alpha_0,\alpha_1,\dots, \alpha_{n-1}\rbrace)\times (\lbrace \epsilon\rbrace +\lbrace \alpha_n\rbrace)

That is,

PSET⁡(A)≅∏α∈A({ϵ}+{α})\operatorname{PSET}(\mathcal{A})\cong \prod _ {\alpha\in\mathcal{A}}\left(\lbrace \epsilon \rbrace +\lbrace \alpha\rbrace\right)

and require . A0=∅\mathcal{A}_0=\varnothing

this OGF is

Exp⁡‾(A(z))=∏α∈A(1+z∣α∣)=∏n≥1(1+zn)an=exp⁡(∑n≥1an⋅ln⁡(1+zn))=exp⁡(∑n≥1an⋅∑m≥1(−1)m−1znmm)=exp⁡(A(z)1−A(z2)2+A(z3)3−⋯ )\begin{aligned} \overline{\operatorname{Exp}}(A(z))&=\prod _ {\alpha\in\mathcal{A}}\left(1+z^{\lvert \alpha \rvert}\right)=\prod _ {n\geq 1}\left(1+z^n\right)^{a_n}\\ &=\exp\left(\sum _ {n\geq 1}a_n\cdot \ln\left(1+z^n\right)\right)\\ &=\exp\left(\sum _ {n\geq 1}a_n\cdot \sum _ {m\geq 1}\frac{(-1)^{m-1}z^{nm}}{m}\right)\\ &=\exp\left(\frac{A(z)}{1}-\frac{A(z^2)}{2}+\frac{A(z^3)}{3}-\cdots \right) \end{aligned}

where is the modified Pólya exponential. Exp⁡‾\overline{\operatorname{Exp}}

It is immediate that . PSET⁡(A)⊂MSET⁡(A)\operatorname{PSET}(\mathcal{A})\subset \operatorname{MSET}(\mathcal{A})

Cycle Construction for Sets

The Cycle construction generates all combinations without distinguishing combinations that differ only by rotation.

We define it as

CYC⁡(A)=(SEQ⁡(A)∖{ϵ})/S\operatorname{CYC}(\mathcal{A})=\left(\operatorname{SEQ}(\mathcal{A})\setminus\lbrace \epsilon\rbrace\right)/\mathbf{S}

where is an equivalence relation. We say if and only if there exists a cyclic shift such that for every , . S\mathbf{S} (α1,…,αn)S(β1,…,βn)(\alpha_1,\dots,\alpha_n)\mathbf{S}(\beta_1,\dots,\beta_n) τ\tau jj βj=ατ(j)\beta_j=\alpha_{\tau(j)}

Example

For convenience, let both be characters of size . Here we list only strings of sizes and : a,b\mathtt{a},\mathtt{b} 11 33 44

CYC⁡({a,b})3={aaa}+{aab}+{abb}+{bbb}\operatorname{CYC}(\lbrace \mathtt{a},\mathtt{b}\rbrace)_3=\lbrace \mathtt{aaa}\rbrace +\lbrace \mathtt{aab}\rbrace+\lbrace \mathtt{abb}\rbrace+\lbrace \mathtt{bbb}\rbrace

Among cyclically equivalent strings, retain only one representative. aabSbaaSaba\mathtt{aab}\mathbf{S}\mathtt{baa}\mathbf{S}\mathtt{aba} abbSbabSbba\mathtt{abb}\mathbf{S}\mathtt{bab}\mathbf{S}\mathtt{bba}

CYC⁡({a,b})4={aaaa}+{aaab}+{aabb}+{abbb}+{bbbb}+{abab}\operatorname{CYC}(\lbrace \mathtt{a},\mathtt{b}\rbrace)_4=\lbrace \mathtt{aaaa}\rbrace +\lbrace \mathtt{aaab}\rbrace+\lbrace \mathtt{aabb}\rbrace+\lbrace \mathtt{abbb}\rbrace+\lbrace \mathtt{bbbb}\rbrace +\lbrace \mathtt{abab}\rbrace

Here , , , and . aaabSbaaaSabaaSaaba\mathtt{aaab}\mathbf{S}\mathtt{baaa}\mathbf{S}\mathtt{abaa}\mathbf{S}\mathtt{aaba} aabbSbaabSbbaaSabba\mathtt{aabb}\mathbf{S}\mathtt{baab}\mathbf{S}\mathtt{bbaa}\mathbf{S}\mathtt{abba} abbbSbabbSbbabSbbba\mathtt{abbb}\mathbf{S}\mathtt{babb}\mathbf{S}\mathtt{bbab}\mathbf{S}\mathtt{bbba} ababSbaba\mathtt{abab}\mathbf{S}\mathtt{baba}

this OGF is

Log⁡(A(z))=∑n≥1φ(n)nln⁡11−A(zn)\operatorname{Log}(A(z))=\sum _ {n\geq 1}\frac{\varphi(n)}{n}\ln\frac{1}{1-A(z^n)}

where is the Euler function and is the Pólya logarithm. φ\varphi Log⁡\operatorname{Log}

The proof is more involved; see Flajolet's paper or the appendix of Analytic Combinatorics. Reference

Restricted Constructions

The constructions above impose no restriction on the number of components. A predicate on the subscript of can impose such a restriction: SEQ⁡\operatorname{SEQ}

SEQ⁡=k(B),SEQ⁡≥k(B),SEQ⁡1..k(B)\operatorname{SEQ}_{=k}(\mathcal{B}),\quad \operatorname{SEQ}_{\geq k}(\mathcal{B}),\quad \operatorname{SEQ}_{1..k}(\mathcal{B})

Here is often abbreviated as , and means the interval . SEQ⁡=k(B)\operatorname{SEQ}_{=k}(\mathcal{B}) SEQ⁡k(B)\operatorname{SEQ}_k(\mathcal{B}) SEQ⁡1..k(B)\operatorname{SEQ}_{1..k}(\mathcal{B}) [1..k]\lbrack 1..k\rbrack

Let be any one of above, and K\mathfrak{K} SEQ⁡,PSET⁡,MSET⁡,CYC⁡\operatorname{SEQ},\operatorname{PSET},\operatorname{MSET},\operatorname{CYC}

A=Kk(B)\mathcal{A}=\mathfrak{K}_k(\mathcal{B})

That is, for , we require α∈A\alpha\in\mathcal{A}

α={(β1,β2,…,βk)∣β∈B}\alpha =\lbrace (\beta_1,\beta_2,\dots ,\beta_k)\mid \beta\in\mathcal{B}\rbrace

Let be the number of components of a combinatorial object; introduce an extra variable to track this number. χ\chi χ(α)=k\chi(\alpha)=k

Let

An,k=card⁡{α∈A∣∣α∣=n,χ(α)=k}A _ {n,k}=\operatorname{card}\left\lbrace \alpha\in\mathcal{A}\mid \lvert \alpha\rvert =n,\chi(\alpha)=k\right\rbrace

Then

A(z,u)=∑n,kAn,kukzn=∑α∈Az∣α∣uχ(α)A(z,u)=\sum _ {n,k}A _ {n,k}u^kz^n=\sum _ {\alpha\in\mathcal{A}}z^{\lvert \alpha\rvert}u^{\chi(\alpha)}

Extracting the coefficient of gives the desired expression; for example, directly gives uku^k A=SEQ⁡k(B)\mathcal{A}=\operatorname{SEQ}_k(\mathcal{B})

A(z,u)=∑k≥0ukB(z)k=11−uB(z)  ⟹  A(z)=B(z)k\begin{aligned} &{}A(z,u)=\sum _ {k\geq 0}u^kB(z)^k=\frac{1}{1-uB(z)}\\ \implies &{}A(z)=B(z)^k \end{aligned}

Clearly,

A=SEQ⁡≥k(B)  ⟹  A(z)=B(z)k1−B(z)\mathcal{A}=\operatorname{SEQ}_{\geq k}(\mathcal{B})\implies A(z)=\frac{B(z)^k}{1-B(z)}

For and , we already have MSET⁡k(B)\operatorname{MSET} _ k(\mathcal{B}) PSET⁡k(B)\operatorname{PSET} _ k(\mathcal{B})

A(z,u)=∏n(1−uzn)−bn  ⟹  A(z)=[uk]exp⁡(u1B(z)+u22B(z2)+u33B(z3)+⋯ )\begin{aligned} &{}A(z,u)=\prod_n\left(1-uz^n\right)^{-b_n}\\ \implies &{}A(z)=\lbrack u^k\rbrack \exp\left(\frac{u}{1}B(z)+\frac{u^2}{2}B(z^2)+\frac{u^3}{3}B(z^3)+\cdots\right) \end{aligned}

and

A(z,u)=∏n(1+uzn)bn  ⟹  A(z)=[uk]exp⁡(u1B(z)−u22B(z2)+u33B(z3)−⋯ )\begin{aligned} &{}A(z,u)=\prod_n\left(1+uz^n\right)^{b_n}\\ \implies &{}A(z)=\lbrack u^k\rbrack \exp\left(\frac{u}{1}B(z)-\frac{u^2}{2}B(z^2)+\frac{u^3}{3}B(z^3)-\cdots\right) \end{aligned}

The same applies to . CYC⁡k(B)\operatorname{CYC}_k(\mathcal{B})

Computing the OGFs corresponding to and using the above formula MSET⁡3(B)\operatorname{MSET}_3(\mathcal{B}) MSET⁡4(B)\operatorname{MSET}_4(\mathcal{B})

Try computing : A=MSET⁡3(B)\mathcal{A}=\operatorname{MSET}_3(\mathcal{B})

[u3]A(z,u)=10!([u3]1)+11!([u3](u1B(z)+u22B(z2)+u33B(z3)+⋯ ))+12!([u3](u1B(z)+u22B(z2)+⋯ )2)+13!([u3](u1B(z)+⋯ )3)=B(z)36+B(z)B(z2)2+B(z)33\begin{aligned} \lbrack u^3\rbrack A(z,u)&= \frac{1}{0!}\left(\lbrack u^3\rbrack 1\right)+\frac{1}{1!}\left(\lbrack u^3\rbrack \left(\frac{u}{1}B(z)+\frac{u^2}{2}B(z^2)+\frac{u^3}{3}B(z^3)+\cdots \right)\right)\\ &+\frac{1}{2!}\left(\lbrack u^3\rbrack \left(\frac{u}{1}B(z)+\frac{u^2}{2}B(z^2)+\cdots \right)^2\right)\\ &+\frac{1}{3!}\left(\lbrack u^3\rbrack \left(\frac{u}{1}B(z)+\cdots \right)^3\right)\\ &=\frac{B(z)^3}{6}+\frac{B(z)B(z^2)}{2}+\frac{B(z)^3}{3} \end{aligned}

Try computing : A=MSET⁡4(B)\mathcal{A}=\operatorname{MSET}_4(\mathcal{B})

[u4]A(z,u)=10!([u4]1)+11!([u4](u1B(z)+u22B(z2)+u33B(z3)+u44B(z4)+⋯ ))+12!([u4](u1B(z)+u22B(z2)+u33B(z3)+⋯ )2)+13!([u4](u1B(z)+u22B(z2)+⋯ )3)+14!([u4](u1B(z)+⋯ )4)=B(z4)4+12!(B(z2)24+2B(z)B(z3)3)+13!(3B(z)2B(z2)2)+B(z)44!=B(z)424+B(z)2B(z2)4+B(z)B(z3)3+B(z2)28+B(z4)4\begin{aligned} \lbrack u^4\rbrack A(z,u)&= \frac{1}{0!}\left(\lbrack u^4\rbrack 1\right)+\frac{1}{1!}\left(\lbrack u^4\rbrack \left(\frac{u}{1}B(z)+\frac{u^2}{2}B(z^2)+\frac{u^3}{3}B(z^3)+\frac{u^4}{4}B(z^4)+\cdots \right)\right)\\ &+\frac{1}{2!}\left(\lbrack u^4\rbrack \left(\frac{u}{1}B(z)+\frac{u^2}{2}B(z^2)+\frac{u^3}{3}B(z^3)+\cdots \right)^2\right)\\ &+\frac{1}{3!}\left(\lbrack u^4\rbrack \left(\frac{u}{1}B(z)+\frac{u^2}{2}B(z^2)+\cdots \right)^3\right)\\ &+\frac{1}{4!}\left(\lbrack u^4\rbrack \left(\frac{u}{1}B(z)+\cdots \right)^4\right)\\ &=\frac{B(z^4)}{4}+\frac{1}{2!}\left(\frac{B(z^2)^2}{4}+\frac{2B(z)B(z^3)}{3}\right)+\frac{1}{3!}\left(\frac{3B(z)^2B(z^2)}{2}\right)+\frac{B(z)^4}{4!}\\ &=\frac{B(z)^4}{24}+\frac{B(z)^2B(z^2)}{4}+\frac{B(z)B(z^3)}{3}+\frac{B(z^2)^2}{8}+\frac{B(z^4)}{4} \end{aligned}

Thus for is an expression in . A=Kk(B)\mathcal{A}=\mathfrak{K}_k(\mathcal{B}) A(z)A(z) B(z),B(z2),…,B(zk)B(z),B(z^2),\dots ,B(z^k)

Note that a restricted construction does not require . Kk(B)\mathfrak{K}_k(\mathcal{B}) B0=∅\mathcal{B}_0=\varnothing

Common restricted constructions PSET⁡2(A):A(z)22−A(z2)2MSET⁡2(A):A(z)22+A(z2)2CYC⁡2(A):A(z)22+A(z2)2\begin{aligned} \operatorname{PSET} _ {2}(\mathcal{A})&:\quad \frac{A(z)^2}{2}-\frac{A(z^2)}{2}\\ \operatorname{MSET} _ {2}(\mathcal{A})&:\quad \frac{A(z)^2}{2}+\frac{A(z^2)}{2}\\ \operatorname{CYC} _ {2}(\mathcal{A})&:\quad \frac{A(z)^2}{2}+\frac{A(z^2)}{2} \end{aligned} PSET⁡3(A):A(z)36−A(z)A(z2)2+A(z3)3MSET⁡3(A):A(z)36+A(z)A(z2)2+A(z3)3CYC⁡3(A):A(z)33+2A(z3)3\begin{aligned} \operatorname{PSET} _ {3}(\mathcal{A})&:\quad \frac{A(z)^3}{6}-\frac{A(z)A(z^2)}{2}+\frac{A(z^3)}{3}\\ \operatorname{MSET} _ {3}(\mathcal{A})&:\quad \frac{A(z)^3}{6}+\frac{A(z)A(z^2)}{2}+\frac{A(z^3)}{3}\\ \operatorname{CYC} _ {3}(\mathcal{A})&:\quad \frac{A(z)^3}{3}+\frac{2A(z^3)}{3}\\ \end{aligned} PSET⁡4(A):A(z)424−A(z)2A(z2)4+A(z)A(z3)3+A(z2)28−A(z4)4MSET⁡4(A):A(z)424+A(z)2A(z2)4+A(z)A(z3)3+A(z2)28+A(z4)4CYC⁡4(A):A(z)44+A(z2)24+A(z4)2\begin{aligned} \operatorname{PSET} _ {4}(\mathcal{A})&:\quad \frac{A(z)^4}{24}-\frac{A(z)^2A(z^2)}{4}+\frac{A(z)A(z^3)}{3}+\frac{A(z^2)^2}{8}-\frac{A(z^4)}{4}\\ \operatorname{MSET} _ {4}(\mathcal{A})&:\quad \frac{A(z)^4}{24}+\frac{A(z)^2A(z^2)}{4}+\frac{A(z)A(z^3)}{3}+\frac{A(z^2)^2}{8}+\frac{A(z^4)}{4}\\ \operatorname{CYC} _ {4}(\mathcal{A})&:\quad \frac{A(z)^4}{4}+\frac{A(z^2)^2}{4}+\frac{A(z^4)}{2}\\ \end{aligned}

The calculation is effective but cumbersome; see the references on Pólya enumeration and cycle indices. Reference Reference

Example LOJ 6538. Counting Alkyls, strengthened version, strengthened version

Problem: Find the number of unordered trees with vertices, rooted at a node of degree at most , while every other node has degree at most , modulo . Assume . nn 33 44 998244353998244353 1≤n≤1051\leq n\leq 10^5

Solution: Let the combinatorial class be . Then T\mathcal{T}

T={∙}×MSET⁡0,1,2,3(T)\mathcal{T}=\lbrace \bullet\rbrace\times\operatorname{MSET}_{0,1,2,3}(\mathcal{T})

Alternatively, let . Then T^=T+{ϵ}\hat{\mathcal{T}}=\mathcal{T}+\lbrace \epsilon\rbrace

T^={ϵ}+{∙}×MSET⁡3(T^)\hat{\mathcal{T}}=\lbrace \epsilon\rbrace +\lbrace \bullet\rbrace\times\operatorname{MSET}_{3}(\hat{\mathcal{T}})

The same result can be obtained.

References

  • Philippe Flajolet and Robert Sedgewick. . Reference

This content comes from OI Wiki: Symbolic Method. See the original for authors and revision history. AIOJ has adapted the formatting, in-site links, and resource paths.

Content is shared under CC BY-SA 4.0 and SATA license; additional terms are governed by the original notice. Thanks to the OI Wiki authors and contributors; per the SATA terms, please visit the OI Wiki repository and star it to show your support.