Do the stars go up or down?

The thing that sparked my interest in category theory was a remark from Ted Odell regarding the dual of a linear transformation. As I recall, he said something like “There’s a reason the star goes up instead of down” and mumbled something about category theory. I took it he didn’t think highly of category theory, but my interest was piqued.

At the time I could think of two examples of functors that I cared about, one involving fundamental groups and one involving linear operators. The former puts the star down and the latter puts the star up.

If X and Y are topological spaces and f is a continuous function between X and Y, then f induces a map f* between the π1(X) and π1(Y), the fundamental groups of X and Y. The star goes down.

If X and Y are linear spaces and T is a continuous linear transformation between X and Y, then T* induces a map Y* between the Y*, the dual spaces of Y and X. The stars go up.

What was this arcane knowledge that Ted Odell obliquely referred to? It’s that by convention, stars go downstairs for covariant functors (like that between fundamental groups) and upstairs for contravariant functors (like that between dual spaces).

Covariant means that the induced maps go in the same direction as the original maps. Notice above that f goes from X to Y and f* goes from π1(X) to π1(Y). The X and Y are in the same order, hence covariant, going in the same direction.

Contravariant means that the induces maps go in the opposite direction as the original maps. Notice that T goes from X to Y, but T* goes from  Y* to X*, the order of X and Y is reversed, hence contravariant, going in opposite directions.

The fundamental group is defined in terms of paths in a space, i.e. functions from an interval into a space. The dual of a vector space is defined in terms of linear functions from that space to real numbers. Functors defined in terms of functions from a fixed space (like the unit interval) into the space you’re interested in are covariant. Functors defined in terms of functions from the space you’re interested into a fixed space (like the reals) are contravariant.

Another example of stars going up or down comes from differential geometry. A function f from Rn to Rm induces a map f* from the tangent space Rnp to Rmf(p). Star downstairs, n and m appearing in the same order. The analogous map on differential forms, however, is f*, star upstairs, and goes in the opposite direction. (At least in Spivak‘s notation.) Unfortunately, the use of the words “covariant” and “contravariant” in the context of tensors is backward to what is now customary usage, though for good historical reasons.

* * *

The convention described here of putting stars downstairs for covariant functors and upstairs for contravariant functors is common, but it’s not universal. I ran into an exception right after writing this post. But I believe the convention is followed more often than not.

* * *

My initial impression of category theory was positive: it could tell me why the star goes downstairs in my topology course and upstairs in my functional analysis course! My next exposure to category theory left a bad impression that lasted for years. Category theory can be used to clarify or to obfuscate, to solve problems or to create problems, like any other tool.

Related: Applied category theory

Categories, Birds, and Frogs

Freeman Dyson divided mathematicians into birds and frogs in his essay by that title.

Some mathematicians are birds, others are frogs. Birds fly high in the air and survey broad vistas of mathematics out to the far horizon. They delight in concepts that unify our thinking and bring together diverse problems from different parts of the landscape. Frogs live in the mud below and see only the flowers that grow nearby. They delight in the details of particular objects, and they solve problems one at a time.

It’s an interesting metaphor. Like all metaphors it has its limits and Dyson discusses that. Some people are somewhere between a bird and a frog, whatever kind of creature that would be, and some alternate between being birds and frogs.

The other day I thought about Dyson’s classification and wondered whether category theorists would be birds or frogs. At first category theory seems avian, looking for grand patterns across mathematics. But as you wander further in, it seems more batrachian, absorbed in drawing little boxes and arrows.

I find it interesting that category theory can profound or trivial, depending on your perspective.

The motivations and applications are profound. Category theory has been called “metamathematics” because it formalizes analogies between diverse areas of math. But basic category theory itself is very close to its axioms. The path from first principles to common definitions and theorems in category theory is much shorter than, say, the path from the definition of the real numbers to the fundamental theorem of calculus.

(This diagram quantifies the last claim to some extent: the graph of concept dependencies in category theory is more wide than deep, and not that deep. Unfortunately I don’t have a similar diagram for calculus.)

Related posts

Visualizing category concept dependencies

Category theory has a high ratio of definitions to theorems, and it can seem like every definition depends on an infinite regress of definitions. But if you graph the definition dependencies, the graph is wide rather than deep.

I picked out 65 concepts and created a visualization using GraphViz. No definition is more than six degrees away from first principles, and most are closer. The graph is pretty big, so here’s a thumbnail.

The full graph is available here.

It’s possible to define concepts in different ways and obtain a different graph. I used definitions from here.

Here is a list of other math diagrams I’ve created.

Related: Applied category theory

Seven dogmas of category theory

Joseph Goguen gave seven dogmas in his paper A Categorical Manifesto.

  1. To each species of mathematical structure, there corresponds a category whose objects have that structure, and whose morphisms preserve it.
  2. To any natural construction on structures of one species, yielding structures of another species, there corresponds a functor from the category of the first species to the category of the second.
  3. To each natural translation from a construction F : A -> B to a construction G: A -> B there corresponds a natural transformation F => G.
  4. A diagram D in a category C can be seen as a system of constraints, and then a limit of D represents all possible solutions of the system.
  5. To any canonical construction from one species of structure to another corresponds an adjuction between the corresponding categories.
  6. Given a species of structure, say widgets, then the result of interconnecting a system of widgets to form a super-widget corresponds to taking the colimit of the diagram of widgets in which the morphisms show how they are interconnected.
  7. Given a species of structure C, then a species of structure obtained by “decorating” or “enriching” that of C corresponds to a comma category under C (or under a functor from C).

Although category theory is all about general patterns, it can be hard to learn what the general patterns of category theory are. The list above is the best high-level description of category theory I’ve seen.

Related posts

Covariant and contravariant

The terms covariant and contravariant come up in many contexts. An earlier post discussed how the terms are used in programming and category theory. The meaning in programming is an instance of the general use in category theory.

Vector fields can be covariant or contravariant too. This is also an instance of the categorical usage, except the terminology is backward.

Michael Spivak explains:

Nowadays such situations are always distinguished by calling the things which go in the same direction “covariant” and the things which go in the opposite direction “contravariant.” Classical terminology used these same words, and it just happens to have reversed this: a vector field is called a contravariant vector field, while a section of T*M is called a covariant vector field. And no one had the gall or authority to reverse terminology sanctified by years of usage. So it’s very easy to remember which kind of vector field is covariant, and which is contravariant — it’s just the opposite of what it logically ought to be.

Emphasis added.

In defense of classical nomenclature, it was established decades before category theory. And as Spivak explains immediately following the quotation above, the original terminology made sense in its original context.

From Spivak’s Differential Geometry, volume 1. I own the 2nd edition and quoted from it. But it’s out of print so I linked to the 3rd edition. I doubt the quote changed between editions, but I don’t know.

Related: Applied category theory

Covariance and contravariance in math and CS

I heard the terms “covariance” and “contravariance” used in math long before I heard them used in object oriented programming.  I was curious whether there was any connection between the two. To my surprise, they’re very similar. In fact, you could formalize the OOP use of the terms so that they’re not just analogous but actually special cases of the mathematical terms.

When I started writing this post, I intended to explain covariance and contravariance. However, the post became longer and more technical than I like to write here. Instead, I’ll just announce that a connection exists and give references for those who want to read further.

Chris Burrows describes covariance and contravariance in object oriented programming in his article New C# Features in the .NET Framework 4.

The terms covariant and contravariant were defined in category theory before computer scientists applied the terms to object oriented programming. Wikipedia has a short, readable introduction to category theory, including covariant and contravariant functors. See also A Categorical Manifesto (PostScript file).

Computer scientists have been interested in category theory for some time, so it’s not too surprising that category theory terms would filter down into practical programming. The real surprise was hearing category terminology used outside of math. It was like the feeling you get when you run into a coworker at a family reunion or a neighbor at a restaurant in another city.

Update (3 Jan 2011): See also Liskov Substitution Principle is Contravariance

Update (28 Feb 2013): See also how covariance and contravariance are used in the opposite sense with vector fields.

Related posts

My mathematical opposite

Eugenia Cheng may be my mathematical opposite. She did a great interview with Peter Rowlett in which she bubbles over with enthusiasm for category theory. She explains that she couldn’t stand applied math, but stuck with math because she believed there was something there she could love. The further she moved from applicable math, the happier she became. Abstract algebra was a big improvement, but still too concrete. When she discovered category theory, she was home.

Category theory is a sort of meta-mathematics. It aims to identify patterns across diverse areas of math the way a particular area of math may identify patterns in nature. I like the idea of category theory, but I get that deer-in-the-headlights look in my eyes almost immediately when I look at category theory in any detail.

I enjoy pure math, though I prefer analysis to algebra. I even enjoyed my first abstract algebra class, but when I ran into category theory I knew I’d exceeded my abstraction tolerance. I moved more toward the applied end of the spectrum the longer I was in college. Afterward, I moved so far toward the applied end that you might say I fell off the end and moved into things that are so applied that they’re not strictly mathematics: mathematical modeling, software development, statistics, etc. I call myself a very applied mathematician because I actually apply math and don’t just study areas of math that could potentially be applied.

I appreciate Eugenia Cheng’s enthusiasm even though I don’t share her taste in math. I have long intended to go back and learn a little category theory. It would be great mental exercise precisely because it is so foreign to my way of thinking. Cheng’s interview inspired me to give it one more try.

Update: After this post was written, I did give category theory another try, and gave up again. Then a couple years later I finally committed to digging into category theory and have found practical uses for it.