Counting partitions of a fixed genus

We show that, for any fixed genus $g$, the ordinary generating function for the genus $g$ partitions of an $n$-element set into $k$ blocks is algebraic. The proof involves showing that each such partition may be reduced in a unique way to a primitive partition and that the number of primitive partitions of a given genus is finite. We illustrate our method by finding the generating function for genus $2$ partitions, after identifying all genus $2$ primitive partitions, using a computer-assisted search.


Introduction
Many recent developments in discrete mathematics concern the use of topological concepts in order to obtain combinatorial properties of finite objects. The combinatorial definition of the genus of graphs and their embeddings using maps and hypermaps, allowed Jackson and Visentin [10,11] to obtain enumerative results using the theory of characters in the algebra of the symmetric group. Their approach inspires to check if other combinatorial objects with certain values for the genus have deep combinatorial properties. A genus may be defined for a partition by considering a partition as a permutation whose cycles consists of the blocks written in increasing order, and by using the combinatorial definition that exists for graph embeddings. Notice, the noncrossing ones are exactly those that have genus 0. The noncrossing partitions first defined by Kreweras [13] have a lot of interesting properties for which many authors obtained remarkable results. In her M.S. thesis Martha Yip showed that genus 1 partitions have also nice combinatorial properties, for instance a lattice structure was obtained.
In this paper we are interested in enumerative results. It is well known that the number d n,k of genus 0 partitions on n elements containing k blocks are the Narayana numbers. Their generating power series D(x, y) = n,k≥0 d n,k x n y k is algebraic and is given by a rational function of x, y and t = (1 − x − xy) 2 − 4x 2 y. The same statement also holds for genus 1 partitions: an explicit formula to this effect was conjectured by M. Yip and proved in [4]. The main result of this paper is Theorem 6.10, stating that for any integer g ≥ 0, the generating function counting all partitions of a fixed genus by the size of the underlying set and the number of parts is algebraic and is given by a rational function of x, y and t = (1 − x − xy) 2 − 4x 2 y.
We also obtain an explicit formula for g = 2, albeit the proof of this formula relies on computer assistance.
We arrive at our main result after several reduction steps. First, in Section 2, we introduce two types of elementary reductions that do not change the genus: the removal of a fixed point and the contraction of i and i+1 whenever i+1 immediately follows i in the same part. The resulting class of reduced partitions is slightly smaller than the one we introduced in [4] when we counted genus 1 partitions. The formula connecting the generating functions of all, respectively reduced partitions is also an easy substitution rule, involving the generating function of noncrossing partitions. The key idea behind our main result is the notion of parallel edges and primitive partitions, introduced in Section 5. When a permutation α sends i into j + 1 and j into i + 1, we call the directed edges (i, j +1) and (j, i+1) parallel. These may be represented by parallel line segments in a diagram, and merging the two parts of a partition along such a pair of parallel edges does not change the genus. The existence of a parallel pair of edges in a partition α on {1, . . . , n} is equivalent to the existence of a 2-cycle in the permutation α −1 ζ n used in the definition of the genus. We call a partition primitive if it has no parallel edges.
An easy cycle counting argument shows that for any fixed genus there are only finitely many primitive partitions.
Our paper is organized as follows: In the first three sections we give the notation used in the paper then we give precise description on the way to obtain a reduced partition from a general one. We also consider the case when the partition has blocks of size 2, and show that we can associate to any partition one with blocks of size 2 for which the reduction process translates in a more tractable way. It is clear that these partitions are exactly the set of fixed point free involutions also called matchings. Section 4 is devoted to the proof of a formula that allows to compute the generating function of general partitions from that of involutions.
In Section 5 we introduce the semi-primitive and primitive partitions and prove that the number of primitive partitions of fixed genus is finite. Hence their generating function is a polynomial.
In Section 6 we show a way to count all reduced partitions that yield the same primitive partition, after the removal of parallel edges. We obtain that the generating function of all reduced partitions of a fixed genus is a rational function, whose denominator is a power of 1 − x 2 y. Combining this result with the main theorem the main result of our paper follows immediately.
The last section containing general results on partitions of a fixed arbitrary genus is Section 7. Here we show how to obtain a formula for the number of all partitions of a fixed genus, assuming we found the generating function for the number of reduced partitions, after finding all primitive partitions, using the results of Section 6. Our proposed method has two key ingredients: first we rewrite the generating function of all partitions of a fixed genus as a linear combination of Laurent polynomials multiplied by negative powers of (x + xy − 1) 2 − 4x 2 y, then we may use a formula published by Gessel [6] to extract the coefficients of the monomials in the negative powers of (x + xy − 1) 2 − 4x 2 y. The remaining sections illustrate the power and limitations of our proposed method. In Section 8 we show that there are only two primitive partitions of genus 1, which may be easily found "by hand". Computing the generating function counting all partitions of genus 1 takes only a few lines, quickly reproducing the main result of [4]. In Section 9 we see that the situation for partitions of genus 2 is already much more complicated. There are 3032 primitive partitions of genus 2, which we were able to find after proving that they all belong to one of four types and relied on a computer on finding all partitions of each given type. While computing the generating function of reduced partitions, one of these types gives rise to finitely many semiprimitive partitions (see Sections 5 and 6) which we counted manually. Implementing the method outlined in Section 7 could be performed by hand, but the length of the calculation would stretch the limits of a publication of reasonable length. We relied on the assistance of Maple to find an explicit formula for the generating function of all partitions of genus 2. Extracting the coefficients using Gessel's formula can be performed automatically by hand, but the resulting formula is somewhat lengthy. The numbers we obtain from our formulas agree with the numbers obtained by directly counting genus 2 partitions of up to 12 elements, using another computer program.
Our work raises several exciting questions. Is there a way to describe the structure of the primitive partitions of a fixed genus, and is there a way to count them without using a computer-assisted search? While counting genus 2 partitions we mostly relied on bounding the number of cycles whose length is greater than 2 to facilitate the work of our computer. Perhaps there are more ways to reduce even the primitive partitions even further. Another line of future research could involve the study of types of generating functions that arise: these are all linear combinations of Laurent polynomials, multiplied by a single negative power of (x + xy − 1) 2 − 4x 2 y. A list of some areas where negative powers of (x + xy − 1) 2 − 4x 2 y occur in generating functions was already given in [4]: these range from counting faces in root polytopes [9,15] through counting convex polyominoes [6] to counting Jacobi configurations [16]. Finding a more compact formula for even genus 2 partitions depends on an ability to manipulate such expressions more nimbly.

Preliminaries
The study of hypermaps goes back to the sixties, they serve as a tool to encode a topological representations of a hypergraph, embedded in a surface. A hypermap is a pair of permutations (σ, α) on a set of points {1, 2, . . . , n}, such that σ and α generate a transitive subgroup of the symmetric group.
The genus g(σ, α) of a hypermap (σ, α) is defined by the equation where z(α) denotes the number of cycles of the permutation α. The genus is always a nonnegative integer, see [12]. An important special type of a hypermap is when one of the permutations constituting it is ζ n = (1, 2, . . . , n).
Note that the cyclic subgroup generated by ζ n is already transitive, the same holds even more for the subgroup generated by ζ n and α, for any permutation α.
As a direct consequence of (1.1), the genus of the permutation α is given by Hypermaps of the form (ζ n , α) are often called hypermonopoles (for instance in [1] or [18]). To count permutations of a fixed genus, a general machinery was built by S. Cautis and D. M. Jackson [1] and explicit formulas were given by A. Goupil and G. Schaeffer [8]. The subject of this paper is counting partitions of a fixed genus. We call a permutation α a partition if in each of its cycles, listing the elements beginning with the least element of the cycle results in an increasing list of integers. Note that partitions of the set {1, . . . , n}, as defined above, are in an obvious bijection with the the set-partitions of {1, . . . , n}: we identify the set-partition P = (P i ) i=1,...,k of the set {1, 2, . . . n} with the permutation α P having k cycles, whose cycles are lists of the elements of the blocks P i , the elements are listed in increasing order within each block. The genus of a partition P is the genus of the permutation α P .
While counting partitions of a fixed genus, we will use the fact that cyclic renumbering of the points takes partitions into partitions and it preserves the genus. Proposition 1.2. If α is a partition of {1, . . . , n} of genus g, then the same holds for ζ n αζ −1 n . In Section 9 we will use the following variant of [2, Lemma 5], shown in [4,Lemma 1.5]. An element i of 1, 2, . . . , n is a back point of the permutation α if α(i) < i and α(i) is not the smallest element in its cycle (i.e., there exists k such that α k (i) < α(i)). Lemma 1.3. For any permutation α ∈ Sym (n), the sum of the number of back points of the permutation α and the number of those of α −1 ζ n is equal to 2g(α).
In particular, since a partition has no back points, Lemma 1.3 has the following consequence.
It was shown in [3, Theorem 1] that a partitions of genus 0 are exactly the noncrossing partitions. A formula for the number of partitions of genus 1 of a given number of elements with a given number of parts was conjectured by M. Yip [18], and shown by the present authors [4].

Elementary reductions and reduced permutations
In this section we will describe a reduction process that is similar to the one we used in [4] to prove the formula for the partitions of genus one, but the class of reductions used will be slightly larger this time. Here and in the rest of the paper we will often write i + j instead of ζ j n (i), that is, all additions and subtractions are understood to be taken modulo the number of elements in the underlying set.
Consider the partition   and it has genus 2 by (1.2). The partition α 0 is shown in Figure 1. We may represent every permutation α in a similar way: we put the elements 1, . . . , n on a circle in clockwise order and for each i put a directed edge beginning at i and ending at α(i).
We may always omit indicating the loops corresponding to the fixed points of α, and for the two-cycles we may always use a single undirected edge to replace a pair of directed edges between the same pair of points. Finally, for partitions we may also omit indicating the orientation on the remaining edges, as each cycle of length at least 3 of a permutation that is a partition is oriented clockwise. We call the resulting figure the diagram of the partition. We will repeatedly use reduction steps of two kinds: one removes a fixed point of α, and the other one removes a fixed point of α −1 ζ n . We define these steps for permutations in general, and the main result in this section will be about classes of permutations that do not have to be partitions. given an i such that α(i) = i, we remove the cycle (i) from the cycle decomposition of α and replace all j > i by j − 1, thus obtaining the cycle decomposition of a permutation α ′ of {1, . . . , n − 1}. We call the inverse of this operation, assigning α to α ′ , an elementary extension of the first kind.
For example, the permutation α 0 given in (2.1) (shown in Figure 1 As a consequence of these two lemmas, the permutation α ′ , obtained from α the removal of the fixed point i satisfies The number of permuted elements decreased by one, so the genus remains unchanged by (1.2). The second elementary reduction we will use is completely analogous: it removes a fixed point of α −1 ζ n . Note that, in analogy to Lemma 2.2, the following observation holds. Definition 2.5. Let α be any permutation of {1, . . . , n}. An elementary reduction of the second kind is the removal of a dual fixed point of α as follows: given an i < n such that α(i) = i + 1, in the decomposition of α we remove i from the cycle containing it, and replace all j > i by j −1, thus obtaining the cycle decomposition of a permutation α ′ of {1, . . . , n−1}. We call the inverse of this operation, assigning α to α ′ , an elementary extension of the second kind.
Just like an elementary reduction of the first kind, an elementary reduction of the second kind does not change the genus. For the permutation α 0 given in (2.1), the permutation α −1 0 ζ 17 has two fixed points: we have α 0 (6) = 7 and α 0 (13) = 14. After removing the fixed point 5, for resulting permutation α 1 not only 5 and 12 are dual fixed points of α, but we also have α 1 (4) = 5. We may continue removing fixed points and dual fixed points, until we end up with a permutation having no fixed points nor dual fixed points. Note that in some cases we may end up removing all permuted elements, and so we will consider the degenerate bijection of the empty set with itself a permutation. This case does not arise if we start with a permutation that has positive genus.
In the case of α 0 given in (2.1) we may perform elementary reductions in many ways, but after removing all fixed points and dual fixed points, we will always end up with the same reduced permutation α 1 , shown in Figure 2. It is a trivial fact that each elementary reduction steps takes a partition into a partition. Furthermore, even though there may be many ways to perform the elementary reductions, if we keep performing these operations until no such operation can be performed, the resulting reduced permutation is unique. Proof. Let us call an element i ∈ {1, 2, . . . , n} removable if all elements j belonging to the clockwise arc [i, α(i)] have the property that α(j) also belongs to the same arc and that for any two elements j, j ′ on the clockwise arc [i, α(i)], the directed edges j → α(j) and j ′ → α(j ′ ) do not cross: equivalently, the clockwise arcs [j, α(j)] and [j, α(j ′ )] are either disjoint, or they contain each other, or their intersection is a subset of {j, j ′ , α(j), α(j ′ )}. It is easy to see by induction on the number of elements contained in the clockwise arc [i, α(i)] that an element i is removable, if and only of it gets removed during any sequence of elementary reduction steps that does not stop before reaching a reduced permutation. By the end of any such reduction process, each number i that is not removable is decreased by the number of removable elements in the interval [1, i].
Due to Theorem 2.7, any class of permutations that is closed under elementary reductions and extensions is completely determined by the reduced permutations in the class. Knowing how to count the reduced permutations should enable us to count all permutations in the class. We will provide a formula for this in Section 4.

Bicolored matchings and reduced permutations
The elementary reductions of the first and second kind, introduced in Section 2, are duals of each other. In this section we review a representation of permutations as bicolored matchings: in this setting the duality becomes more apparent, making the proofs in Section 4 easier to present. The bicolored construction presented here is a simplification of the four-colored construction presented in [3].
Let α be a permutation of the set {1, . . . , n}. We define the bicolored matching µ[α] associated to α as the following permutation of the set {±1, . . . , ±n}: for each positive i, the permutation µ[α] matches i with −α(i) and they form the 2-cycle (i, −α(i)). Equivalently, for each i > 0, the permutation µ[α] contains the 2-cycle (−i, α −1 (i)). The permutation µ[α] is a fixed point free involution arising as a product of n 2-cycles which we may think of as edges in a matching of the set {±1, . . . , ±n}, where each edge matches a positive element with a negative element.
The following statement is a degenerate case of [3, Ch 1, Propriété II.1], regarding the representability of a hypermap as a map.
We may represent the matching µ[α] by marking the elements −1, 1, −2, 2, . . . , −n, n on a circle in this order and then connecting the elements i and µ[α](i) with an edge, as shown in Figure 3. The effect of an elementary reduction of the first kind on the associated bicolored matchings is the following. To describe the similar effect of an elementary reduction of the second kind on the associated bicolored matchings we need to distinguish two cases, depending on whether the dual fixed point we want to remove is n or a point with a smaller label.
by removing the edge (i, −(i + 1)) and and decreasing the absolute value of the labels on the points i + 1, −(i + 2), i + 2, . . . , −n, n by one (without changing their sign).  It is also easy to describe in terms of the associated bicolored matchings, which edges get removed in the reduction process that yields the unique reduced permutation which exists according to Theorem 2.7.
Definition 3.7. Let α be a permutation of {1, . . . , n} and let µ[α] be the associated bicolored matching. We call an edge (u, v) in µ[α] removable if it has the following properties: (1) No other edge crosses the edge (u, v).
Then, for at least one of these sublists, the set of edges connecting the elements of this sublist form a set of pairwise non-crossing edges.
Let α be a permutation of {1, . . . , n} and let α ′ be the unique reduced permutation α ′ of {1, . . . , n ′ } that may be obtained by performing a sequence of elementary reductions, starting with α. Starting with α, let us perform a sequence of elementary reductions yielding α ′ , and let us simultaneously remove the appropriate edges and relabel the remaining points as indicated in Lemmas 3.3 through 3.5 above.
Proposition 3.8. The set of edges removed from µ[α] in the process described above is exactly the set of removable edges.
Proof. If (u, v) gets removed in any elementary reduction process leading to the bicolored matching µ[α ′ ] then (u, v) must be a removable edge. Indeed, an elementary reduction allows only removing an edge connecting consecutive elements of the circular list (−1, 1, . . . , −n, n). If, after a certain number of elementary reductions, the image of v consecutively follows the image of u in the circular order then all edges having at last one endpoint from the sublist u, . . . , v must be formerly reduced edges, and thus have both endpoints belong to the list and form a set of pairwise non-crossing edges. Similarly, if after a certain number of elementary reductions, the image of u consecutively follows the image of v in the circular order then the sublist v, . . . , u of the original circular order must support a set of pairwise non-crossing edges.
Conversely, in any sequence of elementary reductions that leads to a reduced permutation, every removable edge will be removed at some point. This may be shown by induction on the number of pairwise non-crossing edges nested by the edge (u, v), forming the set of all edges connecting the endpoints on the sublist u, . . . , v or v, . . . , u. From here on we distinguish two cases: Case 1: The permutation α has genus zero. In this degenerate case no two edges of µ[α] cross and α ′ is the empty permutation. Case 2: The permutation α has positive genus. In this case, for any removable edge (u, v), exactly one of the sublists u, . . . , v and v, . . . , u of the circular order (−1, 1, . . . , −n, n) has the non-crossing property described in item (2) of Definition 3.7, otherwise µ[α] would consist of pairwise non-crossing edges and have genus zero. Without loss of generality, we may assume that (u, . . . , v) is the sublist with the noncrossing property. It is easy to see that all edges connecting two points on this list are also removable. We may now show that all removable edges get removed by induction on the number of elements in the sublist (u, . . . , v).

Counting permutations whose set is closed under elementary reductions
Due to Theorem 2.7, any class of permutations that is closed under elementary reductions and extensions is completely determined by the reduced permutations in the class. Knowing how to count the reduced permutations should enable us to count all permutations in the class. The main result of this section contains a formula telling how to do this when we are interested in the number of permutations on a given number of elements with a given number of cycles. To state our main result we will need to use the generating function D(x, y) = 1 + . . , n} having k parts. Note that we deviate from the usual conventions by defining the constant term to be 1, i.e. we consider that there is one non-crossing partition on the empty set and it has zero blocks. This generating function is given by the formula In the proof of the main result of this section we will use the following lemma.
Proof. Consider a cycle (i 1 , . . . , i m ) of α, where i 1 is the least element of the cycle. This cycle corresponds to a set of edges These edges are pairwise noncrossing if and only if i 1 < · · · < i k holds. We obtain that α is a partition if and only if edges of µ[α] associated to the same cycle are pairwise noncrossing. In this case, for each cycle (i 1 , . . . , i m ), the edge (i m , −i 1 ) pointing from the positive copy of the largest element to the negative copy of the smallest element in the cycle of α is the only edge between a positive point with larger and a negative point with smaller absolute value. Finally, for a partition α is noncrossing if any pair of edges of µ[α], associated to different cycles in α, is also noncrossing.
The main result of this section is the following.
Consider a class C of permutations that is closed under elementary reductions and extensions. Let p(n, k) and r(n, k) respectively be the number of all, respectively all reduced permutations of {1, . . . , n} in the class having k cycles. Then the generating functions P (x, y) := n,k p(n, k)x n y k and R(x, y) := n,k r(n, k)x n y k satisfy the equation We will prove Theorem 4.2 in two stages. First we show the following result.
Proof. Consider an arbitrary permutation α of {1, . . . , n} in the class C having k cycles and let α ′ be the unique reduced permutation obtained by a sequence of elementary reductions. Assume α ′ is a permutation of {1, . . . , n 1 } and has k 1 cycles. Thus µ(α ′ ) is a matching of 2n 1 elements, these elements form a circular list (−1, 1, . . . , −n 1 , n 1 ). Any removable edge of µ[α] has to be reinserted between two consecutive elements of this circular list. We will adapt the results on pointing and substitution, described in the book of Flajolet and Sedgewick [5, Section I.6.2], to a two variable setting, keeping in mind the two-coloring of the points. We will use the notation We distinguish two cases, and describe the generating function of the permutations belonging to each case. We begin with the more straightforward case.
at the end of the removal process. This leaves the label of 1 unchanged, and we will have to relabel the points from here with 1, −2, 2, . . . , n, −1 in the circular order. This observation determines the assignment of labels completely, we only need to keep track of the sets of reinserted edges. For each of the arcs (−1, 1), (1, −2), . . . , (−n 1 , n 1 ), (n 1 , −1) created by the points of µ[α ′ ] we may reinsert a set of pairwise noncrossing edges independently, the only restriction being that we want to reinsert n−n 1 edges altogether, making sure that α has k cycles. As we will see below, the way to count the additional cycles created is different for the arcs (−i, i) from that of the arcs (i, −(i + 1)). We have n 1 arcs of each type, and at the level of generating functions we will have 2n 1 factors, n 1 of each type.
Consider first all edges reinserted between i and −(i+1) (for some i > 0). These form a set of pairwise non-crossing edges such that their points listed in the circular order begin with a negative element and end with a positive element, and the absolute value of the labels keeps (weakly) increasing as we parse the elements in the cyclic order. The number of cycles created by the reinsertion of these edges is the number of edges (u, v) such that u is negative and precedes v in the circular order. Indeed, a removable edge does not cross any edge, as we parse the signed points in cyclic order, starting from −1, each removable edge edge (u, −v) with 0 < u < v begins or continues a cycle, and each removable edge (u, −v) with 0 < v < u completes a cycle. The cycles completed by a removable edge consists only of removable edges, these are the new cycles, contributed by the reinsertion of such edges. On the other hand, if we remove all other edges and keep only the removable edges inserted between i and −(i + 1), by Lemma 4.1, this set of bicolored edges encodes a noncrossing partition with the same number of parts as the number of newly added cycles, after decreasing the absolute values of all labels appropriately. Therefore, if we insert n ′ ≥ 0 edges between i and −(i + 1) then the number of ways to create k ′ new cycles is [x n ′ y k ′ ]D(x, y). Note that this includes the possibility of n ′ = k ′ = 0, that is, we may choose not to insert any edge between i and −(i + 1) at all. Consider next all edges reinserted between −i and i (for some i > 0). These form a set of pairwise non-crossing edges, such that the points listed in the circular order begin with a positive element and end with a negative element. As before, the number of cycles created by the reinsertion of these edges is the number of edges (u, v) such that u is negative and precedes v in the circular order. On the other hand, if we remove all other edges and keep only the ones inserted between i and −i, to apply Lemma 4.1 we need to swap the signs to make sure that the point with the label of least absolute value, first parsed in the cyclic order has negative sign. Thus inserting n ′′ ≥ 0 edges between −i and i then the number of ways to create k ′′ new cycles can be done in as many ways as one can create a noncrossing partition on n ′′ points with n ′′ − k ′′ parts. This number is [x n ′′ y n ′′ −k ′′ ] (D(x, y) if n ′′ , k ′′ > 0 and it is 1 when n ′′ = k ′′ = 0. In the case when n ′′ , k ′′ > 0 we obtain that Here we used the fact that the number of noncrossing partitions of n ′′ elements into n ′′ − k ′′ parts is the same as the number of noncrossing partitions of n ′′ elements into k ′′ + 1 parts. Note that each nonempty partition has at least one part, hence D(x, y) −1 is a multiple of y. To summarize, the number of ways to insert n ′′ ≥ 0 edges between −i and i while creating k ′′ new cycles is Combining the contribution of the edges inserted on the arcs (i, −(i+1)) for some i with those inserted on the arcs (−i, i) for some i, we obtain that the number of partitions counted in this case is Case 2 Either (1, −2) or (−1, 1) is a removable edge of µ[α]. Note that 1 can only be matched with one of −1 and −2, so this case has two mutually exclusive subcases. If (1, −2) is a removable edge of µ[α] then this edge is among the edges that are to be reinserted between 1 and −2 of the bicolored matching µ(α ′ ) associated to the reduced permutation α ′ . If we reinsert n ′ edges, thus creating k ′ cycles then we also need to select one of the positive endpoints to be the 1 in α. This can be done in ways. Counting the parts created by inserting edges on the other arcs created by α ′ is completely analogous to the process described in the previous case. Hence the total number of all permutations counted in this case is A completely analogous reasoning shows that in the case when (−1, 1) is a removable edge of α, the total number of permutations counted is [x n y k ]R xD(x, y)(D(x, y) + y − 1) y , y x ∂ ∂x D(x, y) D(x, y) + y − 1 .
The second stage of proving Theorem 4.2 contains some algebraic manipulations. Observe first that D(x, y) may be equivalently given by the quadratic equation x · D(x, y) 2 + (xy − 1 − x)D(x, y) + 1 = 0.
Proof. Taking the partial derivative with respect to x on both sides of (4.2) we obtain Using this equation we may express ∂ ∂x D(x, y) as follows: This equation directly implies .
Finally a direct consequence of (4.1) we have Combining (4.5) and (4.6) yields the stated equality.

Parallel edges and primitive partitions
From now on we restrict our attention to partitions of genus g. As a consequence of Theorem 4.2, it suffices to count reduced partitions of a fixed genus, the rest follows by substitution into the formula given there.
Our next way to simplify is the elimination of parallel edges. . , n} such that α(i) = j + 1 and α(j) = i + 1, we say that the ordered pairs (i, α(i)) and (j, α(j)) are parallel edges.
To avoid confusion with 2-cycles we will use the notation i → α(i) and j → α(j). Note that a reduced permutation has no fixed points or dual fixed points, and so for any pair of parallel edges, the set of points {i, α(i), j, α(j)} has 4 elements.
Direct substitution into the definition yields the following. In general, a permutation α may have a pair of parallel edges whose points all belong to the same cycle of α. This is not the case for partitions.
is also a partition. Furthermore, γ i,j [α] has the same genus as α.
Proof. The points i, i + 1, j, j + 1 follow each other in this cyclic order, as shown in Figure 4.  Since in each cycle of a permutation α representing a partition there is a unique k such that α(k) ≤ k, the sequence i, j + 1, · · · , j, i + 1 cannot be a subsequence of a cycle of α. Removing the parallel edges j → i + 1 and i → j + 1 and adding the directed edges i → i + 1 and j → j + 1 merges the two polygons into a single polygon. The resulting permutation γ i,j [α] is a partition and we have z(γ i,j [α]) = z(α)−1. Note also that γ i,j [α] −1 ζ n is obtained from α −1 ζ n by replacing the 2-cycle (i, j) with the pair of fixed points (i)(j). Hence z(γ i,j [α] −1 ζ n ) = z(α −1 ζ n )+1, and the genus is unchanged by (1.2).
Note that γ i,j [α] is not reduced, but we can make it reduced by removing the dual fixed points i and j.
Definition 5.4. Let α be a reduced partition on {1, . . . , n} and let {i → α(i)), j → α(j)} be a pair of parallel edges. We will refer to taking γ i,j [α] and then removing its dual fixed points i and j using two elementary reductions of the second kind as the removal of the pair of parallel edges {i → α(i), j → α(j)}.
A direct consequence of the definitions is the following.   Figure 5. The semiprimitive partition α 2 associated to α 0 Definition 5.6. We call a partition α semiprimitive if it has no pair of parallel edges {i → α(i), j → α(j)} such that (i, α(i)) is a 2-cycle. We call a partition α primitive if it contains no pairs of parallel edges at all.
The partition α 2 shown in Figure 5 is semiprimitive: its only pair of parallel edges is ({9, 5), (4, 10)} and both of these directed edges are parts of 3-cycles. Removing this last pair of parallel edges yields the primitive partition shown in Figure 6. In analogy to Proposition 5.7, we also have the following statement. Proof. The proof depends on the following observation. The answer to the question whether i and α(i) form a 2-cycle (equivalently: i is a fixed point of α 2 ) remains essentially unchanged after the removal a pair of parallel edges, where neither of the edges is i → α(i). Only the labels i and α(i) may decrease accordingly. If initially α −1 ζ n has m ′ 2-cycles (i, j) such that i or j is a fixed point of α 2 , then σ[α] is a partition of {1, . . . , n − 2m ′ }. Furthermore σ[α] −1 ζ n−2m ′ is obtained from α −1 ζ n by deleting all 2-cycles (i, j) of α −1 ζ n such that i or j is a fixed point of α 2 and decreasing each label k by the number of elements removed from the set {1, . . . , k}.
The main result of this paper is a consequence of the following observation.
Theorem 5.9. A primitive partition of genus g is a partition of a set with at most 6(2g − 1) elements. Moreover for any g there is a finite number of semiprimitive partitions of genus g, hence also a finite number of primitive ones.
Proof. Let α be a primitive partition of genus g of the set {1, . . . , n}. Since α is reduced, it has no fixed points, every cycle of α has length at least 2 and z(α) ≤ n/2 . By the same reason, α −1 ζ n has no fixed point either, and by the primitivity of α, there are no 2-cycles in α −1 ζ n either, each of its cycles has length at least 3. Thus z(α −1 ζ n ) ≤ n/3. Equation (1.2), together with the above observations, yields and the stated inequality follows after rearranging. Consider now a semiprimitive partition α of genus g. By Proposition 5.7, after the removal of parallel pairs of edges we arrive at the unique primitive partition π(α). By the already shown part of the statement, π(α) is a partition of at most 6(2g − 1) elements. Since α is semiprimitive, each removal of a parallel pair of edges results in merging two of its cycles, of length c 1 ≥ 3 and c 2 ≥ 3 into a cycle of length c 1 + c 2 , where the removed parallel pair of edges corresponds to a diagonal of the cycle that was created. For example, the primitive partition shown in Figure 6 arises by merging the two triangles of the semiprimitive partition shown in Figure 5. Replaying the sequence of moves resulting in π(α) backward, what we see in each step is that a cycle of length at least 4 of the current partition is cut into two smaller polygons by cutting along a diagonal. For a fixed primitive partition, this sequence of actions can be performed only in finitely many ways.

Counting reduced partitions
What we have obtained so far is that each reduced partition of genus g is obtained from one of finitely many semiprimitive partitions by repeatedly adding 2-cycles (u, v) in such a way that either the directed edge u → v or the directed edge v → u forms a parallel pair with an existing edge of the current partition. Such an operation does not change the number of parts of size greater than 2, the addition of 2-cycles appears as adding parallel line segments to the diagram of the partition. Each newly added 2-cycle is parallel to at least one already existing edge in the diagram. In order to avoid ambiguities, let us have a closer look whether it is possible that the lastly added 2-cycle (u, v) creates more than one parallel pair of directed edges in the current partition β (1) If u → α(u) and v → α(v) form a parallel pair of edges then they are in the same parallel class.
(2) For a 2-cycle (u, v) the directed edges u → v and v → u are in the same parallel class.
By a slight abuse of the terminology we will refer to 2-cycles being in the same parallel class, instead of saying that both directed edges of the 2-cycle are in the same parallel class. An example of a reduced partition containing many directed edges in the same parallel class is shown in Figure 7.  (9,14) and (7,17) are represented with parallel line segments, but they are not parallel. The parallel classes are still easily recognizable, because of the following observation.
Lemma 6.2. In a reduced partition, the set of endpoints of all directed edges belonging to the same parallel class form two cyclically consecutive sets of labels. The two sets can not be merged into a single cyclically consecutive set.
Indeed, between every two directed edges u → v and u ′ → v ′ there is a sequence of edges such that any two consecutive edges form either a parallel pair, or have the same pair of endpoints. Using this observation it is easy to show the first statement by induction on the number of edges. The second statement is an easy consequence of the fact that there is no directed edge of the form u → u + 1 in a reduced partition.
The second key observation is the following. Lemma 6.3. Let α be a partition, let (u, v) be a 2-cycle of α and let {u → v, u ′ → v ′ } be a parallel pair of edges. The removal of this parallel pair decreases the number of 2-cycles in the parallel class of u → v by one. Furthermore, the label 1 will belong to a directed edge in the same parallel class as before, and it will belong to the same consecutive set of endpoints associated to that class.
The proof is left to the reader. As a consequence of Lemmas 6.2 and 6.3, we may uniquely reconstruct a reduced partition α from the unique semiprimitive partition σ[α] that can be obtained by the removal of parallel pairs of directed edges from it, if we now the number of 2-cycles added to each parallel class of σ[α], and the location of the point labeled 1 in α (the latter is restricted by Lemma 6.3).
The unique semiprimitive partition associated to the partition shown in Figure 7 is also primitive, it is the partition α 3 shown in Figure 6. The primitive partition α 3 allows the addition of 2-cycles to 6 parallel classes, each corresponding to one edge of the diagram of α 3 . The direction of this edge matters if it is part of a cycle longer than two: edges in the parallel class of {(14, 17)} will appear all above the unique 4-cycle. On the other hand 2-cycles that are in the parallel class corresponding to a 2-cycle of α 3 may have been added on either side of the original 2-cycle.
For semiprimitive but not primitive partitions a minor complication arises due to the fact that such a partition contains parallel pairs of edges. For example, for the partition shown in Figure 5 the first 2-cycle inserted as a parallel to 9 → 5 is also parallel to 4 → 10. Additional 2-cycles in the same parallel class can not be automatically associated to a single edge of α 2 . In such situations we will make an arbitrary choice and mark one of the two edges, say 9 → 5 as the directed edge representing the parallel class of 2-cycles that may be merged into this edge by repeated removals of parallel edges. Definition 6.4. In a semiprimitive partition we select each edge of its diagram that is not part of a parallel pair as a parallel class representative and from each parallel pair of edges we select exactly one as a parallel class representative. Subject to this selection we say that a point has type 0, 1, or 2, respectively if the number of edges incident to it in the diagram that are parallel class representatives is 0, 1, or 2, respectively.
Subject to the selection of 9 → 5 as a parallel class representative, the type 1 points of α 2 are 1, 3, 4, 6, 8, 10. These are the endpoints of the edges representing 2-cycles and the points 4 and 10 which are endpoints of the edge 4 → 10 that is not a parallel class representative. The type 2 points in the same diagram are 2, 5, 7, 9. There are no type 0 points. We will see in Section 9 that no type 0 points arise in genus 2. This possibility may occur for higher genuses if in a semiprimitive partition a point is contained in two edges, both of which form a parallel pair of edges, and neither of them is selected as a parallel class representative.
Subject to a last trick, we are now in the position to write a generating function formula for all reduced partitions α for which σ[α] is the same semiprimitive partition. Definition 6.5. Given a semiprimitive partition β, let us denote by r β (n, k) the number of all reduced partitions α of {1, . . . , n} into k parts, satisfying σ[α] = β. We denote by R β (x, y) the generating function R β (x, y) = n≥1,k≥1 r β (n, k)x n y k .
Clearly R(x, y), the generating function of all reduced partitions of genus g, is the sum of R β (x, y) over all (finitely many) semiprimitive partitions β of genus g. The last trick we will use is to compute average contribution of a semiprimitive partition in a cyclic recoloring class.
Keeping in mind Proposition 1.2, together with each semiprimitive partition β on {1, . . . , m} we consider all partitions of the form ζ j m βζ −j m . These are all partitions of the same genus, and they are also semiprimitive: Lemma 6.6. Let β be a partition of the set {1, . . . , m}. If β is primitive or semiprimitive then the same holds for all ζ j m βζ −j m . Indeed, cyclic relabeling does not change the cycle structure of β or β −1 ζ m , and parallel pairs of directed edges are taken into parallel pairs of directed edges under cyclic relabeling. Definition 6.7. Let β be a semiprimitive partition of {1, . . . , m} . We call the average contribution of β to R(x, y) modulo cyclic relabeling the generating function No matter how many elements are equivalent to β modulo cyclic relabeling, if we replace each R β (x, y) with R β (x, y), we over-count the contribution of each equivalent semiprimitive partition m times, and then we divide by m. Therefore we have where β ranges over all semiprimitive partitions of genus g.
Theorem 6.8. Let β be a semiprimitive partition on m points with c cycles, whose diagram has p parallel classes. Suppose we have selected parallel class representatives as described in Definition 6.4 and, subject to this selection, β has m i points of type i for i = 0, 1, 2. Then the average contribution of β to R(x, y) modulo cyclic relabeling is given by Proof. When we take the m cyclically relabeled copies ζ j m βζ −j m of β, we will keep the same directed edges as parallel class representatives. This way the label 1 will appear as a type i point exactly m i times, where i = 0, 1, 2 in these copies. In all cases below the factor x m y c is there because each ζ j m βζ −j m is a partition of m elements with c cycles. Case 1. If 1 is a type 0 point then to construct the only choice we can make is to choose number of 2-cycles added to each parallel class of directed edges in ζ j m βζ −j m . Each parallel class contributes a factor of as each 2-cycle is a distinct part (contributing a factor of y) with two points (factor of x 2 ). Case 2. If 1 is a type 1 point then, besides selecting the number of 2-cycles added to each parallel class, we must also select the position of the label 1 in α. This selection must be made within the parallel class whose representative contains 1, and the endpoint must be in the same consecutive set of endpoints that contains the 1 of ζ j m βζ −j m . If there are n edges added in this parallel class, then this choice may be performed (n + 1) ways. Hence the parallel class represented by the directed edge containing the label 1 in ζ j m βζ −j m contributes a factor of 1 all other parallel classes contribute a factor of 1/(1 − x 2 y). Case 3. The case when 1 is a type 2 point is similar to the previous case, except that now the 1 of α may be the endpoint of a directed edge in one of two parallel classes, represented by a directed edge containing 1 in ζ j m βζ −j m . If these two classes contain n added 2-cycles then there are n ways to select the number of 2-cycles in one of the two classes and n ways to select the position of the label 1 in α. Hence these two parallel classes contribute a factor of all other parallel classes contribute a factor of 1/(1 − x 2 y).
As a direct consequence of Theorem 5.9 and Theorem 6.8 we have the following result. Corollary 6.9. For a fixed genus g, the generating function R(x, y) of reduced partitions of genus g is a rational function of x and y. Moreover, the denominator of R(x, y) is a power of 1 − x 2 y.
Combining Corollary 6.9 with Theorem 4.2 we obtain the main result of our paper. Theorem 6.10. For a fixed g the generating function P (x, y) = n,k p(n, k)x n y k of genus g partitions of n elements with k parts is algebraic. More precisely, it may be obtained by substituting x, y and (x + xy − 1) 2 − 4x 2 y into a rational expression.

Extracting the coefficients from our generating functions
In this section, we describe a method to explicitly compute the generating function P (x, y) of all partitions of a fixed genus g from the generating function R(x, y) of the reduced partitions. Our procedure allows us to write P (x, y) in such a form that a formula due to Gessel may be used to extract the coefficient, thus obtaining formulas for all such partitions of a set of a given size, with a given number of parts.
By Corollary 6.9, the generating function R(x, y) of reduced partitions is a linear combination of rational functions of the form To obtain P (x, y), by Theorem 4.2, we need to replace each occurrence of x by the quotient (D(x, y) − 1)/y, and then multiply the result by the multiplicative inverse of Thus, to obtain P (x, y) from R(x, y), we have to replace each r i 1 ,i 2 ,i 3 (x, y) with We may express each p i 1 ,i 2 ,i 3 (x, y) in terms of ∆(x, y) as follows. First we simplify the denominator of p i 1 ,i 2 ,i 3 (x, y) using the following lemma.
Proof. After multiplying the numerator and the denominator by ∆(x, y), using (7.2) and simplifying by 2, we may rewrite the right hand side as Multiplying the numerator and the denominator on the right hand side by xy the stated equality is equivalent to Observe next that (4.2) may be rewritten as x(D((x, y) − 1) 2 + (xy + x − 1)(D(x, y) − 1) + xy = 0.
Using this equation we may replace −x(D((x, y)−1) 2 with (xy +x−1)(D(x, y)−1)+xy on the left hand side of (7.4). We obtain that the stated equality is equivalent to The last equation is easily seen to be an equivalent form of (4.2).
Directly from the definition of D(x, y) we obtain 2xy . Indeed, the stated equality directly follows from after simplification.
Proposition 7.3. The expression p i 1 ,i 2 ,i 3 (x, y) is given by Proof. The first line is a direct consequence of Lemma 7.2. To obtain the second line, we write Indeed, note that any even positive power of ∆(x, y) is a polynomial, and any odd positive power of of ∆(x, y) may be written as a product of a polynomial and of ∆(x, y) −1 .
It remains to show how to compute the coefficient of x n y k in a negative integer power of ∆(x, y). For this purpose, Gessel's following formula may be used, see [6,Eq. (2)]: Here each (u) m = u(u + 1) · · · (u + m − 1) is a rising factorial. As pointed out by Strehl [16, p. 180] (see also [6, p. 64]), [6,Eq. (2)] is a consequence of classical results in the theory of special functions. We used this formula in [4] in the special case when α is the half of an odd integer, to count partitions of genus 1. As noted in [4], replacing each appearance of y with xy yields a formula for a negative power of ∆(x, y): Next we replace j with k and i with n − k. Thus we obtain: In the case when α = m + 1/2 is the half of an odd integer, it is easy to see that When we count partitions of a higher fixed genus, substituting integer values of α may also be necessary.

Partitions of genus one
As a "warm up", in this section we apply the results of the preceding sections and quickly reproduce the generating function formula for genus one partitions, first found in [4]. For these partitions Theorem 5.9 gives that any primitive partition is a partition on at most 6(2 · 1 − 1) = 6 elements. Simple trial and error gives that the only primitive partitions are β 1 = (1, 3)(2, 4) and β 2 = (1, 4)(2, 5) (3,6). Since all cycles have length 2, these are also the only semiprimitive partitions and all points have type 1. As a consequence of Theorem 6.8, the generating function of all reduced partitions of genus one is  Theorem 8.2. The generating function P (x, y) of all partitions of genus one is given by

Genus 2 partitions
For genus 2 partitions Theorem 5.9 gives that any primitive partition is a partition on at most 6(2 · 2 − 1) = 18 elements. First we have a closer look at the possible cycle lengths of these partitions.
Theorem 9.1. For a primitive partition β of genus 2 on n elements, one of the following holds: Case 2: β has exactly one cycle whose length is greater than 2. Let c 1 be the length of this cycle. In this case we have and c 1 has the same parity as n. Equation (9.1) yields n ≤ 24 − 3c 1 . (9.4) Assume, by way of contradiction that c 1 ≥ 5 holds. In this case (9.4) yields n ≤ 9. Just like in the previous case, β −1 ζ n can not have three 3-cycles with altogether at most 3 back points, thus we must have z(β −1 ζ n ) ≤ 2. Equation (9.1) yields n ≤ 12 − c 1 Since c 1 ≥ 5, we obtain n ≤ 7. Just like in the previous case β −1 ζ n can not have one 3-cycle and one cycle of length at most 4, as these could contain at most 3 back points. We are left with z(β −1 ζ n ) = 1 and Equation (9.1) yields n ≤ 10 − c 1 Since c 1 ≥ 5, we obtain n ≤ 5. This, together with n ≥ c 1 forces n = c 1 = 5 and β = (12345), a partition of genus 0, not 2. This contradiction proves that we can only have c 1 = 3 or c 1 = 4. For c = 3 (9.4) Equation gives n ≤ 15, for c = 3 Equation (9.4) gives n ≤ 12. Case 3: All cycles of β are 2-cycles. In this case Theorem 5.9 implies n ≤ 18.
We have found all primitive partitions using a computer search. They are shown in Table 1. The last line indicates the number of parts as a function of n.
9.1. Reduced matchings of genus 2. If a primitive partition contains only 2-cycles then all points have type 1 and the number of parallel classes is the same as the number of 2-cycles, that is n/2. By Theorem 6.8 the generating function of all reduced partitions associated to such primitive partitions is This expression may be simplified to R M (x, y) = 21 · (x 2 y) 4 · 1 + 3 · x 2 y + (x 2 y) 2 (1 − x 2 y) 10 .  Table 1. Numbers of primitive partitions of genus 2 2. All partitions of genus 2 with this property have already been counted and this gives us a means to verify the numbers we found with computer in this case.
In analogy to Theorem 4.2, it is not hard to show that the generating function n≥0 m 2 (n) · t n for all matchings of genus 2 with n edges is R M (C(t), t), where 2t is a generating function of the Catalan numbers (the coefficient of t n counts the number of noncrossing partitions of 2n such that each part has two elements). Evaluating the Taylor series of R M (C(t), t) gives R M (C(t), t) = t 4 +483·t 5 +6468·t 6 +66066·t 7 +570570·t 8 +4390386·t 9 +31039008·t 10 +· · · The coefficients are listed as sequence A006298 in [14], as counting "genus 2 rooted maps with 1 face with n points", the main reference being the work of Walsh and Lehman [17]. 9.2. The contribution of the other primitive partitions. If a primitive partition of genus 2 of {1, . . . , n} contains only one 3-cycle then 3 points have type 2 and n − 3 points have type 1. The number of parallel classes is 3 + (n − 3)/2 = (n + 3)/2. By Theorem 6.8 the generating function of all reduced partitions associated to such primitive partitions is R △ (x, y) = 14 · x 7 y 3 · 4 + 3 · (1 + x 2 y) 7 · (1 − x 2 y) 6 + 141 · x 9 y 4 · 6 + 3 · (1 + x 2 y) 9 · (1 − x 2 y) 7 + 407 · x 11 y 5 · 8 + 3 · (1 + x 2 y) 11 · (1 − x 2 y) 8 + 455 · x 13 y 6 · 10 + 3 · (1 + x 2 y) 13 · (1 − x 2 y) 9 . This expression may be simplified to R △ (x, y) = 7 · x 7 y 3 (2 + 13x 2 y + 13(x 2 y) 2 + 2( If a primitive partition of genus 2 of {1, . . . , n} contains two 3-cycles then 6 points have type 2 and n−6 points have type 1. The number of parallel classes is 6+(n−6)/2 = (n + 6)/2. By Theorem 6.8 the generating function of all reduced partitions associated to such primitive partitions is R (x, y) = x 6 y 2 · 6(1 + x 2 y) 6(1 − x 2 y) 7 + 20 · x 8 y 3 · 2 + 6(1 + x 2 y) 8(1 − x 2 y) 8 + 65 · x 10 y 4 · 4 + 6(1 + x 2 y) 10(1 − x 2 y) 9 + 52 · x 12 y 5 · 6 + 6(1 + x 2 y) This expression may be simplified to Finally, if a primitive partition of genus 2 of {1, . . . , n} contains one 4-cycle then 4 points have type 2 and n − 4 points have type 1. The number of parallel classes is 4 + (n − 4)/2 = (n + 8)/2. By Theorem 6.8 the generating function of all reduced partitions associated to such primitive partitions is This expression may be simplified to R (x, y) = 6x 8 y 3 (1 + x 2 y) (1 − x 2 y) 9 . (9.8) 9.3. Semiprimitive partitions that are not primitive. A semiprimitive partition that is not primitive has at least one parallel pair of directed edges whose removal leads to a cycle of length at least 4. Continuing the removal of parallel pairs of directed edges, the primitive partition reached must also have a cycle of length at least 4. In genus 2 this is only possible when the primitive partition has a single 4-cycle, and each semiprimitive partition arises from cutting the unique 4-cycle into two 3-cycles. An example of such a semiprimitive partition is shown in Figure 5, removing its pair of parallel edges results in the primitive partition shown in Figure 6. When counting semiprimitive partitions, it is important to the number of equivalent partitions modulo cyclic relabeling is usually different for the semiprimitive partition and the associated primitive partition. For example, the primitive partition shown in Figure 6 has 4 distinct partitions in its equivalence class (ζ 4 8 α 2 ζ −4 8 = α 2 ), whereas the semiprimitive partition shown in Figure 5 has 5 distinct partitions in its equivalence class (ζ 5 10 α 3 ζ −5 10 = α 3 ). Writing a program that searches for all semiprimitive partitions of genus 2 that are not primitive is more complicated then identifying primitive partitions, luckily the semiprimitive partitions can also be identified "by hand". We spare the reader the details of the tedious work, we summarize our findings in Table 2.
The number n refers to the size of the underlying set of the semiprimitive partition. The underlying set of the associated primitive partition has two less elements. We listed one representative from each cyclic relabeling equivalence class, and indicated the number of equivalent (semi-)primitive partitions up to cyclic relabelings. On the left hand side we see that there are 4 + 2 = 6 primitive partitions containing a 4-cycle (1, 4, 7)(8, 11, 14)(2, 9)(3, 10)(5, 12)(6, 13) 7 Table 2. Semiprimitive partitions of genus 2 on 8 elements, 10 + 5 = 15 on 10 elements and 6 + 3 = 9 on 12 elements. In most cases we get 2 inequivalent semiprimitive partitions by cutting the 4-cycle of a primitive partition along one of its diagonals, in the case when only one semiprimitive partition is indicated, cutting along the other diagonal yields an equivalent partition up to cyclic relabeling. By adding up the numbers associated to the same value of n in the last column, we see that there are 15 semiprimitive (but not primitive) partitions on 10 elements, 36 such partitions on 12 elements and 21 such partitions on 14 elements.