Primitive species and species operations, part II

In my previous post, I began describing the primitive species and species operations supported by my combinatorial species library; we looked at the ring structure on species, that is, the primitive species 0 and 1, and the operations of species sum and product. Today we’ll continue by looking at a few more primitive species: singletons, sets, and cycles.

[By the way, all the diagrams for this post and the previous one were generated programmatically using my diagrams library. I’ll probably put the code up as an example on the diagrams website sometime in the near future.]


The species X, also known as the species of singletons, is picky in a way similar to the species 1. Whereas 1 only puts a structure on the empty set of labels, X only puts a (single) structure on singleton label sets. If you give it more than one label, or none, it turns up its nose and refuses to do anything.

The species X of singletons

The species X of singletons

> take 10 $ labelled singleton
> generate singleton (['a'] :: [Char])
> generate singleton ("abc" :: [Char])

A few exercises: try to work them out yourself, then use the species library to check if you are correct!

  1. Describe the species X + X. Show that it is isomorphic to the species 2 * X.
  2. Describe the species X * X.


The species E of sets, on the other hand, isn’t picky at all: it will happily put a singleton structure on any label set. Usually we identify this structure with the label set itself; that is, the only E-structure on a label set U is U itself.

The species E of sets

The species E of sets

> take 10 $ labelled sets
> take 10 $ unlabelled sets
> generate set ([1..3] :: [Int])
> generate set ([] :: [Int])

We can now also describe the derived species X * E of elements, also known as the species of pointed sets. The only way to get any X * E structures is by partitioning the label set U into a singleton and all the rest, in which case we get exactly one structure; so there is one X * E structure for each element of U.

> take 10 $ labelled (x * set)
> take 10 $ unlabelled (x * set)
> generate (x * set) ([1..3] :: [Int])

(x is just a synonym for singleton.) Noteworthy is the fact that this is the first species we’ve looked at which has different numbers of labelled and unlabelled structures! This makes sense: there are n labelled (X * E)-structures on a size n set; but if we can’t tell the difference between the labels, any one of them is just as good as any other, so we only get one unlabelled structure (unless the label set is empty, when we don’t get any structures: the X still requires us to have at least one element!). Note also that element is a special synonym for x * set with a special semantics under generate: if we really want to pick elements of the label set, then we probably don’t want to actually see each element paired with a set of the leftover elements, we just want to see the element itself:

> generate elements ([1..3]::[Int])


The final primitive species—and the only one so far that doesn’t feel quite so utterly trivial—is the species C of cycles. C puts no structures on an empty label set, but given any non-empty label set, C generates the set of all cyclical orderings of the labels.

The species C of cycles

The species C of cycles

Of course, the above diagram only shows six of the cycle structures on five labels; the ellipsis is meant to suggest the others not shown. So… how many labelled cycle structures are there on five labels, or generally on n labels? (Of course there is only one unlabelled n-cycle.) I’ll leave it as a (hopefully easy) exercise; and of course you know how to check your answer!

> generate cycles ([1..4] :: [Int])

As you can see, cycles are indicated with angle brackets; it is understood that <1,2,3,4>, <2,3,4,1>, <3,4,1,2>, and <4,1,2,3> are all equivalent.

At this point, you’re probably thinking about a certain species and wondering why I haven’t mentioned it yet—it seems pretty fundamental and primitive. Are you thinking of… the species of lists? It turns out that we don’t have to take lists as primitive—we can define the species of lists as the derivative of the species of cycles! The derivative of a regular type is its type of one-hole… but I’m getting ahead of myself. We’ll look at species differentiation (along with several other operations on species) in the next post!


About Brent

Associate Professor of Computer Science at Hendrix College. Functional programmer, mathematician, teacher, pianist, follower of Jesus.
This entry was posted in combinatorics, haskell, math and tagged , , , , . Bookmark the permalink.

2 Responses to Primitive species and species operations, part II

  1. Pingback: Species operations: differentiation « blog :: Brent -> [String]

  2. Pingback: And now, back to your regularly scheduled combinatorial species | blog :: Brent -> [String]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.