• No se han encontrado resultados

INSTITUT UNIVERSITARI D’INVESTIGACIONS EN

We begin with the formal definition of Bergeron et al. [1998]: (F ◦G) L=X

π`L

F π×Y p∈π

G p (4.3.1)

(there are some subtle issues with this definition, to be discussed shortly, but it will suffice to consider the general idea and some examples). Figure 4.13 shows an abstract representation of the definition, in which labels are shown as dots, and shapes are represented abstractly as arcs drawn across edges leading to the labels contained in the shape, identified by the name of a species. So the diagram illustrates how an (F ◦G)-shape consists abstractly of a top-levelF-shape with subordinateG-shapes.

Example. Figure 4.14 shows a concrete example of a (B◦L+)-shape, a binary tree

containing nonempty lists.

Example. As an example, we may define the species Parof set partitions, illustrated

in Figure 4.15, by

F

=

Figure 4.13: Generic species composition

4

8

9

1

7

5

3

0

6

2

Figure 4.14: An example (B◦L+)-shape

Par

6

3

0

1

5

2

4

Figure 4.16: An example (B×Par)-shape

7

0

5

6

1

2

4

3

Figure 4.17: An example R-shape

That is, a set partition is a set of non-empty sets. Similarly, the species S of permu- tations is given by S=E◦C, a set ofcycles.

Given the speciesPar, we may define the speciesB×Parofpartitioned trees. Struc- tures of this species are labeled binary tree shapes with a superimposed partitioning of the labels (as illustrated in Figure 4.16), and can be used to model trees containing data elements with decidable equality; the partition indicates equivalence classes of elements.

Example. The speciesRof nonemptyn-ary (“rose”) trees, with data stored at internal

nodes, may be defined by the recursive species equation

R=X·(L◦R).

An example R-shape is shown in Figure 4.17. Note the use of L means the children of each node are linearly ordered. UsingE in place ofL yields a more graph-theoretic notion of a rooted tree, with no structure imposed on the neighbors of a particular node.

7 6 5 4 3 2 1 0 3 2 1 0 1 0 0

Figure 4.18: Example P-shapes

Plan = X·(C◦R) is the species of planar embeddings of rooted trees, where the top-level subtrees of the root are ordered cyclically. Each node other than the root, on the other hand, still has a linear order on its children, fixed by the distinguished edge from the node towards the root.

Example. The speciesPofperfect trees, with data stored in the leaves, may be defined

by

P=X+ (P◦X2).

That is, a perfect tree is either a single node, or a perfect tree containing pairs. Functional programmers will recognize this as anon-regular ornested recursive type; it corresponds to the Haskell type:

dataPa =Leaf a |Branch(P(a,a)) Figure 4.18 illustrates some exampleP-shapes.

In addition to being the identity for , Xis the (two-sided) identity for ◦as well. We have (X◦G) L=X π`L Xπ×Y p∈π G p,

in which X π is (cancelling the summands in which it occurs) except in the case where π is the singleton partition {L}, in which case the summand is isomorphic to

G L. On the other side,

(F ◦X) L=X

π`L

F π×Y p∈π

Xp;

the only way to get a product in which none of the X p are is when π ∼=L is the complete partition ofLinto singleton subsets, in which case we again have something isomorphic to F L.

As for generating functions, the mapping from species to egfs is indeed homomor- phic with respect to composition:

(F ◦G)(x) = F(G(x)).

A direct combinatorial proof can be given, making use ofFa`a di Bruno’s formula[John- son, 2002].

1

0

1

0

1

0

Figure 4.19: An infinite family of (B◦L)-shapes of size 2 On the other hand, in general,

^

(F ◦G)(x)6=Fe(Ge(x)).

Bergeron et al. [1998, Exercise 1.4.3] pose the specific counterexample of eS(x) 6= e

E(Ce(x)), which is not hard to show (hint:eS(x) = Q

k>1 1

1−xk and Ce(x) =x+x2+x3+

· · · = 1xx). A more intuitive explanation of the failure of ogfs to be homomorphic with respect to composition—along with a characterization of the situations when homomorphism does hold—is left to future work. In any case, to compute ogfs for composed species, one may turn to cycle index series, which can be seen as a gener- alization of both egfs and ogfs, and which retain more information than either; see Bergeron et al. [1998,§1.2, §1.4] for details.

As hinted previously, the formal definition of composition given in (4.3.1) requires additional qualification; in particular, it requires delicate treatment with regard to partitions and infinite families of shapes. To see the issue, let Band L be the species of binary trees and lists. Consider the species B◦L, whose shapes should consist of binary trees containing lists at their nodes. Intuitively, this gives rise to infinite families of shapes such as those illustrated in Figure 4.19, which are all of size 2.

There are several possible reactions to Figure 4.19, depending on the exact setting in which we are working.

• If we are working in (B ⇒ Set), where the set of shapes on a given set of labels may be infinite, then this should be allowed, and is exactly the meaning that composition ought to have in this case. Note, however, that this means we would need to allow π ` L to include “partitions” with arbitrary numbers of

empty parts (to correspond to the empty lists). Typically, the notation π ` L

denotes partitions into nonempty parts.

• On the other hand, if we are working in (B ⇒ FinSet), as is more traditional in a combinatorial setting, this must not be allowed. One possibility would be to simply insist thatπ`Lin (4.3.1) excludes partitions with empty parts, as is usual. But as we have just seen, this does not generalize nicely to (B ⇒ Set), and in any case it would still be a bit strange, since, for example, B◦L and

B◦L+ would “silently” end up being the same. It is better to front the issue by

simply insisting that F ◦G is only defined when G=.

We can reformulate the definition of composition in a better way which naturally allows for empty parts and which also makes for a clearer path to a generalized notion of composition (to be discussed in the next section). In fact, Joyal [1981, p. 11] already mentions this as an alternative definition. The idea is to use another finite setP, representing parts of a partition, and a functionχ:L→P which assigns each

l ∈ L to some p∈ P. The fibers of χ, i.e. the sets χ−1(p) for p P, thus constitute

a partition of L. Note, however, that this naturally allows for empty parts, since χ

may not be surjective. We then say that an (F ◦G)-shape on the labels Lconsists of some set P, a partition function χ:L→ P, an F-shape on P, and G-shapes on the fibers of χ. However, we must also quotient out by bijections between P and other finite sets; the precise identity of P should not matter. We can thus define (F ◦G) using a coend: (F ◦G) L=∃P ∈B. X χ:L→P F P ×Y p∈P G (χ−1 p). (4.3.2) In the case that G = is required, only surjective χ will result in shapes, so the coend reduces to the original definition (4.3.1), using the notation π ` L with its usual meaning of a partition into nonempty parts.