A Primer on Category Theory with a Super Mario meme

Leonardo
5 min readSep 4, 2024

--

Category theory is a branch of mathematics that might seem abstract at first glance, but its beauty lies in its ability to describe and connect various mathematical structures through simple yet powerful concepts. While category theory is often used in advanced mathematics, computer science, and logic, today we'll embark on a playful journey through this subject using characters from the beloved Super Mario universe. Imagine Mario, Luigi, Wario, and Waluigi not just as video game icons, but as objects in a mathematical world where we explore relationships and transformations between them.

What is Category Theory?

Category theory provides a high-level framework for discussing and understanding the relationships between different mathematical structures. It revolves around two main ideas: *objects* and *morphisms* (also known as arrows or maps). Here’s a basic rundown:

- Objects: These can be anything—sets, spaces, groups, or even Mario characters! They represent entities within a category.
- Morphisms (Arrows): These are the connections between objects, describing how one object maps or transforms into another.

In category theory, the relationships between objects (through morphisms) are often depicted as arrows in a diagram. These diagrams can show how different paths between objects lead to the same result, a concept known as commutativity.

Super Mario and Category Theory: A Whimsical Analogy

Now, let’s consider our cast from the Super Mario series: Mario, Luigi, Wario, and Waluigi. We can think of each of these characters as objects in a category, with morphisms representing some form of transformation or relationship between them.

Imagine the following scenario depicted in a classic commutative diagram:

In this diagram:

Mario and Luigi: These two iconic brothers can be thought of as objects ( X ) and ( Y ), respectively.
- Wario and Waluigi: Their mischievous counterparts, Wario and Waluigi, serve as objects ( X' ) and ( Y' ).
- Arrows/Morphisms: The arrows (labeled as ( F(f) ), ( G(f) ), ( ηX ), and ( ηY ) represent different types of transformations or functions between these objects.

But before we go further, let’s define an important concept in category theory: functors.

What is a Functor?

A functor is a special kind of morphism that operates between entire categories, rather than just between objects in a single category. It essentially maps:

- Objects in one category to objects in another.
- Morphisms between objects in one category to morphisms between corresponding objects in another category.

Functors allow us to translate one category’s structure into another category, while preserving the relationships between objects and morphisms.

The Functors in Our Super Mario Diagram

In the diagram, we have two functors at play: ( F ) and ( G ). These functors map between two categories where our objects are Mario, Luigi, Wario, and Waluigi. Here’s how we can interpret the diagram:

1. ( F(f) ):
This represents a functor ( F ), which takes a morphism ( f ) from Mario to Luigi in one category and maps it to a morphism between Wario and Waluigi in another category. In this sense, ( F ) relates Mario and Luigi’s world (heroes) to Wario and Waluigi’s world (villains).

2. ( G(f) ):
Similarly, ( G(f) ) is another functor that also maps a morphism ( f ) between Wario and Waluigi, but potentially in a different category or context. This could be interpreted as a different way to relate Wario to Waluigi, giving a different perspective on the connection between them.

3. Natural Transformations ( ηX ) and ( ηY ):
The arrows ( ηX ) and ( ηY ) represent natural transformations — ways to relate the two functors ( F ) and ( G ). A natural transformation connects functors while preserving the structure of the categories.

In the case of Mario and Luigi, ( ηX ) maps Mario to Wario, while ( ηY ) maps Luigi to Waluigi. These transformations are ways of linking the functors, showing how the transformations from Mario to Wario and Luigi to Waluigi “commute” with the functors ( F ) and ( G ).

Breaking Down the Diagram

1. Mario to Luigi ( F(f) ):
The arrow from Mario to Luigi, labeled ( F(f) ), represents a function ( F ) applied to some morphism ( f ) that maps Mario to Luigi. In category theory, this could symbolize a transformation within a certain context—perhaps how Mario and Luigi, though distinct, can be related through some common operation or trait, as being brothers for example.

2. Mario to Wario ( ηX ):
The arrow ( ηX ) signifies a transformation from Mario to Wario. This might represent a more mischievous or "inverse" aspect of Mario, mapping him to his greedy counterpart, Wario. In categorical terms, ( ηX ) could be a natural transformation, indicating a way of relating different functors.

3. Luigi to Waluigi ( ηY ):
Similarly, (ηY ) maps Luigi to Waluigi, the darker, more devious version of Luigi. This arrow might represent another natural transformation, this time affecting Luigi and leading to his shadowy reflection in Waluigi.

4. Wario to Waluigi ( G(f) ):
The final arrow, ( G(f) ), depicts a function ( G ) applied to ( f ), connecting Wario to Waluigi. Here, ( G(f) ) represents the transformation within a possibly different context or under different conditions, yet still relating back to the original characters.

Commutative Diagram

In category theory, a diagram is said to commute if all paths between two objects yield the same result. In the context of our Mario characters, this means that whether we follow the path from Mario to Wario to Waluigi, or from Mario to Luigi to Waluigi, we arrive at the same conclusion. This idea of commutativity is central to many constructions in category theory, ensuring consistency across different paths of transformation.

Conclusion: Seeing Mathematics Everywhere

Through this playful analogy, we've taken a lighthearted look at how category theory, with its objects, morphisms, and commutative diagrams, can be understood using the familiar faces of the Mario universe. While this isn’t a rigorous introduction to category theory, it serves as a reminder that mathematics is not just about numbers and equations—it’s about patterns, relationships, and the underlying structure of almost everything around us.

Next time you play a game or even see a meme, take a moment to consider the hidden mathematical structures that might be lurking just beneath the surface. Who knows, you might just find a bit of category theory in your favorite game!

--

--

Leonardo

Software developer, former civil engineer. Musician. Free thinker. Writer.