• No results found

Arithmetic/rectangular product

4.2 Partitional product and Day convolution

4.2.2 Arithmetic/rectangular product

There is another, more recently discovered monoidal structure on species known as

arithmetic product [Maia and M´endez, 2008]. The arithmetic product of the species

F and G, written F G, can intuitively be thought of as an “F-assembly of cloned

G-shapes”, that is, anF-shape containing multiple copies of asingle G-shape. Unlike the usual notion of composition (§4.3), where the F-shape is allowed to contain many different G-shapes, this notion is symmetric: an F-assembly of cloned G-shapes is isomorphic to a G-assembly of cloned F-shapes. Another intuitive way to think of the arithmetic product, which points out the symmetry more clearly, is to think of a rectangular grid of labels, together with an F-shape labelled by the rows of the grid, and a G-shape labelled by the columns. Figure 4.7 illustrates these intuitions with the arithmetic product BL.

A more formal definition requires the notion of a rectangle on a set [Maia and M´endez, 2008, Baddeley et al., 2004], which plays a role similar to that of set par- tition in the definition of partitional product. (So arithmetic product can also be called rectangular product.) In particular, whereas a binary partition of a set L is a decomposition ofLinto a sum, a rectangle onLcan be thought of as a decomposition into a product. The basic idea is to partitionLin two different ways, and require the partitions to act like the “rows” and “columns” of a rectangular matrix, which have the defining characteristic that every pair of a row and a column have a single point of intersection.

Definition 4.2.4 (Maia and M´endez [2008]). A rectangle on a set L is a pair (π, τ) of families of subsets ofL, such that

Figure 4.8: AMat-shape of size 6

• |X∩Y|= 1, for allX ∈π,Y ∈τ.

Here, π ` L denotes that π is a partition of L into any number of nonempty parts, that is, the elements of π are nonempty, pairwise disjoint, and have Las their union. We writeπ, τ L to denote that (π, τ) constitute a rectangle onL, and callπ andτ

the sides of the rectangle.

We can now formally define arithmetic product as follows:

Definition 4.2.5. Thearithmetic product FGof two speciesF andGis the species defined on objects by

(F G)L= ]

LF,LGL

F LF ×G LG.

(F G) lifts bijections σ : L −→∼ L0 to functions (F G) L → (F G) L0 as follows:

(F G)σ (LF, LG, f, g) = (P(σ)LF,P(σ) LG, F P(σ) f, G P(σ) g),

whereP(σ) :P(L)−→ P∼ (L0) denotes the functorial lifting ofσto a bijection between subsets of L and L0.

Remark. The similarity of this definition to the definition of partitional product

should be apparent: the only real difference is that rectangles (LF, LG L) have

been substituted for partitions (LF, LG `L).

Example. Mat=LLis the species of (two-dimensional)matrices.Mat-shapes consist

simply of labels arranged in a rectangular grid (Figure 4.8).

Example. Rect=EEis the species ofrectangles. One way to think of rectangles is as

equivalence classes of matrices up to reordering of the rows and columns. Each label has no fixed “position”; the only invariants on any given label are the sets of other

Figure 4.9: A Rect-shape of size 6

labels which are in the same row or column. Figure 4.9 shows an illustration; each rounded outline represents aset of labels. One can also take the species of rectangles as primitive and define arithmetic product in terms of it.

Example. Just as topological cylinders and tori may be obtained by gluing the edges

of a square, species corresponding to cylinders or tori may be obtained by starting with the species of 2D matrices and “gluing” along one or both edges by turning lists

L into cycles C. In particular, Cyl = LC is the species of (oriented) cylinders, and

Tor=CC is the species of (oriented)tori.

Although species corresponding to Klein bottles and real projective planes (which arise from gluing the edges of a square with one or both pairs of edges given a half-twist before gluing, respectively) certainly exist, it does not seem they can be constructed using , since in those cases the actions of the symmetric group along the two axes are not independent.

The ogf for F Gis given by

e F(x)Ge(x) = X n>0 fnxn ! X n>0 gnxn ! =X n>0   X d|n fdgn/d  xn,

since an (F G)-form of size n consists of a pair of anF-form and a G-form, whose sizes have a product of n.

Likewise, the egf is

X n>0   X d|n n d fdgn/d   xn n!, where n d = n! d!(n/d)!

denotes the number of d×(n/d) rectangles on a set of sizen.

An identity element for arithmetic product should be some species X such that (XG) L= ] LX,LGL X LX×G LG ! ∼ =G L.

Thus we want X LX = {?} when LG = L, and X LX = ∅ otherwise. Consider

LX, L L. Of course, L does not have the right type to be one side of a rectangle

on itself, but it is isomorphic to the set of all singleton subsets of itself, which does. The definition of a rectangle now requires every element of LX to have a nontrivial

intersection with every singleton subset of L (such intersections will automatically have size 1). Therefore LX has only one element, namely, L itself, and is isomorphic

to {?}. Intuitively, {?}, L L corresponds to the fact that we can always make a 1×n rectangle on any set of sizen, that is, any numberncan be “factored” as 1×n.

This leads to the following definition:

Definition 4.2.6. The singleton species, X, is defined by

XL=

(

{?} |L|= 1

∅ otherwise.

Remark. Like the unit species 1, the singleton species X denotes a sort of “leaf”

structure; however, instead of being a trivial leaf structure with no labels, it contains a single label, that is, it marks the spot where a single piece of data can go. Intuitively, it corresponds to the Haskell data type

dataXa =Xa

One can see that the egf and ogf for Xare

X(x) = eX(x) =x.

Species corresponding to a wide variety of standard data structures can be defined using X.

Example. The species ofordered pairs is given byX·X. Since there is only anX-shape

on a single label, and product partitions the labels, there are only (X·X)-shapes on label sets of cardinality 2, and there are two such shapes, one for each ordering of the two labels (Figure 4.10).

More generally,Xn =X· · · · ·X

| {z }

n

is the species of orderedn-tuples; there are exactly

Figure 4.10: (X·X)-shapes

Example. Recall that L denotes the species of lists, i.e. linear orderings. Besides the

interpretation of recursion, to be explored in§5.4.1, we have now seen all the necessary pieces to understand the algebraic definition ofL:

L=1+X·L.

That is, a list structure is either the trivial structure on zero labels, or a single label paired with a list structure on the remainder of the labels. We also have L =

1+X+X2+X3+. . ..

Example. Similarly, recall that the speciesB of binary trees is given by

B=1+B·X·B.

Example. The species X·E is variously known as the species of pointed sets (which

may be denoted E•) or the species of elements (denoted ε). (X·E)-structures consist of a single distinguished label paired with an unstructured collection of any number of remaining labels. There are thus n such structures on each label set of cardinality

n, one for each label.

The two different names result from the fact that we may “care about” the labels in an E-structure or not—that is, when considering data structures built on top of species, E may correspond either to a bag data structure, or instead to a “sink” where we throw labels to which we do not wish to associate any data. This makes no difference from a purely combinatorial point of view, but makes a difference when considering labelled structures (Chapter 6).