## 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.]

### X

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

``` > take 10 \$ labelled singleton [0,1,0,0,0,0,0,0,0,0] > generate singleton (['a'] :: [Char]) ['a'] > 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$.

### E

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

``` > take 10 \$ labelled sets [1,1,1,1,1,1,1,1,1,1] > take 10 \$ unlabelled sets [1,1,1,1,1,1,1,1,1,1] > generate set ([1..3] :: [Int]) [{1,2,3}] > 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) [0,1,2,3,4,5,6,7,8,9] > take 10 \$ unlabelled (x * set) [0,1,1,1,1,1,1,1,1,1] > generate (x * set) ([1..3] :: [Int]) [(1,{2,3}),(2,{1,3}),(3,{1,2})] ```

(`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]) [1,2,3] ```

### C

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

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]) [<1,2,3,4>,<1,2,4,3>,<1,3,2,4>,<1,3,4,2>,<1,4,2,3>,<1,4,3,2>] ```

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!
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 26, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7772599458694458, "perplexity": 529.8787465536466}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2017-13/segments/1490218195419.89/warc/CC-MAIN-20170322212955-00377-ip-10-233-31-227.ec2.internal.warc.gz"}