Basic Category Theory
arxiv.org
arxiv.org
I agree, the words "relatively little background" are too vague. What I had in mind was that the book requires little background relative to many other introductions to category theory (such as the grand-daddy of them all, Mac Lane's Categories for the Working Mathematician). But I should have been more specific. If update the arXiv submission, I'll fix that.
As cokernel points out, the level of knowledge assumed is roughly what you'd get from an undergraduate mathematics degree at an ordinary university in Britain (and probably many other countries too). I know this because I used it several times to teach a master's course at the University of Glasgow. Probably the most famous master's-level category theory course is the one that Cambridge runs in its Part III (master's) programme, which I've also taught. But this book covers much less than the Cambridge course, and assumes less background too.
If you've taken either (i) enough algebra that you're comfortable with rings, groups and vector spaces, or (ii) any kind of topology course, then you should be able to understand enough of the examples that you can get a good grip on the general concepts. If you haven't, then it might not be the right book for you. As others have pointed out, Lawvere and Schanuel's book Conceptual Mathematics assumes much less background than mine, and there are also texts oriented towards readers with a computer science background.
I'm surprised he cites Sets for Mathematics but doesn't include it in his further reading. If you have some university level abstract algebra (groups, rings, vector spaces, topology) then Sets is a quicker start and better reference guide for Category Theory. I started with this book before I had done any abstract algebra and I quickly got out of my depth. But when I did get more algebraic structures under my belt, I had quite a few aha! moments and referred back to this book quite frequently.
I haven't read Awodey's introductory Category Theory book so I can't comment there.
Speaking of Category Theory: Bill Lawvere is an interesting and exceptional 20th century mathematician who probably has less name recognition than he deserves. Lawvere's Wikipedia page: https://en.wikipedia.org/wiki/William_Lawvere
It's a great book! Don't forget to do the exercises. It starts off very easy but if you don't do the exercises all of a sudden you'll be lost.
It assumes almost no prior math knowledge (okay, you should know what sets and functions are...).
Sizing this up, my real question now becomes: as an active day-to-day-life programmer, by how much exactly will this propel my work if I already know and use monads, basic function composition and Haskell?
I'm sure there's some amount of skill/quality/productivity payoff if you evaluate this kind of time investment over the whole lifetime-of-work outstanding, but seems impossible to judge beforehand. Any, er, "testimonials" in terms of how this actually changed work and coding for you or others, other than "just neat geeky theory to digest and reason about endlessly"?
It's just SO MUCH material to dive into (in terms of sources lectures books etc, I'm sure once grasped everyone could condense it into a single page, though fully comprehensible only to themselves, until for teaching others once again decompressed into 15-hours-of-lectures/26-chapters-totalling-book-length) and I'm still driven by this odd old urge to "just go pump out code and make programs happen" back from my earliest Pascal/Basic days I suppose..
On the subject of it improving your coding, not so sure how much you could measure that. I think it's usually preferable to have a strong understanding of the basis of what you're working with, however, as it gives you some confidence to think critically about things you would usually just accept as fact.
A well put together guide, but note that 'relatively little' here means you're OK with some abstract algebra, at least, as the second example of the introduction begins: This example involves rings, which in this book are always taken to have a multiplicative identity, called 1. Similarly, homomorphisms of rings are understood to preserve multiplicative identities. ;-)
Additionally, what are applications of category theory to computer programming, or computer science in general? I find this really interesting from an outsiders view and want to learn it. I'm looking for a truly basic and gentle approach to learning category theory, without removing the rigor.
"The primary distinguishing feature of the book, compared to standard textbooks in algebra, is the early introduction of categories, used as a unifying theme in the presentation of the main topics."
The book doesn't really require much knowledge.
If you either already have a math degree, or if you're already at the point where you're ready to take an upper-level undergraduate math course, then it may be a decent book for you. Maybe. For example, if you're:
- already very comfortable with linear algebra
- possibly been exposed to a bit of topology in analysis class
- already been exposed to abstract algebra a bit by a more theoretical approach to linear algebra (comfortable with proving things in linear algebra via vector spaces and fields)
Otherwise, I would absolutely steer clear of it. The writing style is also not terribly beginner-friendly, in my opinion.
The closest book I can think of to what you're asking for would be "Conceptual Mathematics: A First Introduction to Categories". Though obviously I don't know whether it's a good fit for your particular background and learning style.
Categories are not a good way to be introduced to the "main topics" of abstract algebra. Yes, Category Theory can be seen as the "Chapter 0" of a course on abstract algebra, but for beginners a traditional presentation based on sets would be much easier to digest.
There is a similarity between using categories and using functional programming style or a language - as opposed to using an approach to mathematics based on sets and using the imperative programming style or a language: the latter is just more intuitive and therefore easier to learn for a beginner.
If you read the referenced book, you'd know the author does exactly this.
That said, I second the recommendation of "Algebra: Chapter 0".
http://www.cambridge.org/catalogue/catalogue.asp?isbn=978052...
I believe this book has been discussed "recently" on HN, but I couldn't find a thread.
Mathematicians write for multiple audiences, but there are two major mathematical audiences for their works: specialists in the same field and researchers in other fields. Phrases like "relatively little mathematical background" normally signal that a work is intended to be accessible to non-specialists, but it's often safe to assume that it is aimed at research mathematicians. I think if a work actually requires relatively little mathematical background, a mathematician is more likely to say something like "no, really, you don't need to know mathematics to understand this!" even when it's not quite true.
I think you really need no more than high school algebra to understand basically what category theory is about.
I don't think there's a basic and gentle approach to learning category theory that doesn't remove the rigor. You can learn at a high level what some of the stuff in category theory and get a basic feel and intuition for it, if that's what you want. But, if you want to learn category with the rigor, you're going to have to first learn how to write a proof in mathematics. Really though, you're going to want to have a decent grasp on some basic abstract algebra. Otherwise you're never going to be able to understand the examples for category theory.
When I see "minimal mathematical background" or the like, I usually think: "Understands basic set theory, the concept of a function, and has familiarity with basic proof structures"
When I see "mathematical maturity", I think "Understands, real analysis, abstract algebra, and topology."
Hope that helps.
In math many "general topics" like calculus, linear algebra, probability etc are sometimes studied a few times (eg the second course in calculus might start from scratch and carefully construct the real numbers, which the first course skipped), and I've noticed some authors use "Introduction to X" to mean "this textbook is meant to be a first course in X"
To be fair, though, who is going to read an introduction to category theory that isn't familiar with abstract algebra?
Someone should write 'an introduction to introductions to category theory'
More like the "Prereqs for an Intro to Category Theory."
The author intended his remark that the work is "for readers with relatively little mathematical background" to mean that his readers aren't assumed to have previous exposure to category theory, not that they have zero math.
He's reiterating the Basic in the title "Basic Category Theory."
Category theory is like the refactoring of a lot of math to express commonalities with a view toward recognition and reuse.
The Gang-of-Four OOP patterns book would also seem abstract for anyone sans programming experience.
This paper is fascinating:
Now, not to say that proving things about groups and rings is simple. but just because the word has 5 syllables doesn't mean the concept is hard. Whereas certain concepts in calculus - I think - are quite difficult to solve for even simple looking integrals.
This is a curse which keeps affecting large groups of programmers, to read about some pretty looking abstraction and then wanting to use it everywhere regardless if it is suitable or not. I'm thinking of Design Patterns, CQRS, complex microservice architectures etc.
This point seems to be repeated with every new mathematics.
> It's a pretty abstraction, but I don't see actual results from it.
It has applications in physics and is widely used in computation, particularly for reasoning about composition of programs with side effects. With respect, if you don't see any actual results, you haven't been looking.
With respect, if you think any category-theoretic results were necessary to author even 0.01% of the code executed in computation globally, you're willfully deluding yourself.
I will also claim that their use is only going to grow with Rust adoption and Java adopting lambdas and functional APIs.
You said "It has applications in physics and is widely used in computation". Category theory is not widely used by those who program computers and thus produce computation in them.
> I will however claim that, despite being unnecessary in principle, quite a bit more than 0.01% of code executed globally did make use of category theoretic abstractions because they are so useful (depending on how you measure this of course). Pretty much any program written for .NET and Scala makes use of monadic composition.
And like clockwork, you provide the bog-standard argument for why knowing category theory is important: you point out how many people productively write software without knowing anything about category theory (or even abstract algebra).
Saying that people use category theory to write software without knowing it is like saying they use Maxwell's Laws to write software: so reductive it loses all relevance to productive conversation. That's bad, unless your goal is to make the conversation unproductive.
Computation is bigger than just programming in industry. "Computing" has always referred to the overall discipline of computer science.
> you point out how many people productively write software without knowing anything about category theory (or even abstract algebra).
That wasn't my point at all. Read again. They can have even more productivity if they used category theoretic abstractions.
> Saying that people use category theory to write software without knowing it is like saying they use Maxwell's Laws to write software
Good thing that's not what I said either. You're making a habit of this.
People can understand a structure, in that they can grasp its semantics and its application, without knowing it's canonical name.
There's actually a bit of harm too: the abstract nonsense seems to make it harder to reason about execution speed and makes it very easy to write very slow code. I know a lot of people have a hard time being able to predict the speed with which, say, Haskell code will run.
As an example, consider the theory of Containers [0]. A container is an abtract mathematical model of some kind of data structures (such as lists, trees etc.). Like most mathematical structures they form a category. Further more, each container gives rise to a endo-functor Type → Type. In fact they form a full subcategory of such functors.
For instance the list endofunctor L : Type → Type can be seen as a generic data structure which takes a type parameter, A, and gives the type of lists of elements of A, namely L(A). The functor structure is the generic map function which to each f : A → B gives a function map f : L(A) → L(B). These kinds of generic maps are almost always natural transformations, which tells you a lot about their properties. Knowning these things makes it easier to reason about your code.
These are ofcourse very simple examples. For more elaborate applications of containers, see zippers — which involve an adjunction in the form of a differentiation structures. In layman's terms, zippers are datastructures with holes in context.[1]
[0]: http://www.cs.nott.ac.uk/~psztxa/publ/cont-tcs.pdf
[1]: This master thesis has a readable introduction: https://www.duo.uio.no/bitstream/handle/10852/10740/thesisgy...
Fundamentally, category theory is seen as some sort of holy grail of programming. The hope is that learning about only one API will let you interact naturally and composably with any interface conforming to that design.
print("hello ");
print("world")
you expect the output to be "hello world" and not "worldhello " or something weirder. Moggi realized that the semicolon there was a monadic operation that arranged for the two outputs to be printed sequentially.That might seem like a small thing, but it isn't. In theory, so far as I understand, specifically in denotational semantics, the next best alternative is continuation passing, which adds an extra parameter and return value to the actions and is generally awkward.
The big advantage, though, is practically, in lazy programming languages like Haskell. In that case, the alternative was world passing, where the entire (metaphorical) universe is passed to the action to allow normal parameter passing conventions to sequentially associate the actions. (In contrast, monadic IO does the same thing, but hides the world in the definition of the monad.) The result is sequential code that we all know and love.
Then it was discovered that other bases than the (metaphorical) IO world made for meaningful, useful monads: the maybe monad aborts a computation on the first error, for example. And other data structures like lists...well, go look for a paper with a title like "turn your failures into a list of successes" and we were off and running.
[Edit]
And I'm thinking of the wrong Wadler paper. Try some of the ones from here [1], starting at the bottom.
[1]: http://www.logicmatters.net/2017/01/02/tom-leinsters-basic-c...
I enjoyed it, it's not a text, there are no exercises. Popular overview of the subject, including a first half that mentions category theory only in passing.
Brave to even attempt such a book and I thought she pulled it off rather well. I hope we hear more from her and others mathematicians are similarly inspired.
I have only looked in the first chapter, so I cannot speak further on that atm. That said, I appreciate that a text talks about the universal property - I did not encounter a definition of it in a text when in grad school. I only encountered it because lecturers at my grad program made sure to talk about it.
This is something math and computer science students typically learn in the first two weeks in their mandatory math lectures at least at German universities
You surely know that an isomorphism of sets (bijective function) has an inverse that is also an isomorphism of sets.
For differentiable functions a similar statement does not hold in general (just consider [-1,1] -> [-1,1]; x \mapsto x^3; its inverse is not differentiable everywhere on [-1,1]; so its inverse exists as an isomorphism of sets, but not as a differentiable function). Since diffeomorphisms for R^d are introduced in the 2nd semester for math students (typically in the context of the inverse function theorem), one better has already understood the basics before.
For example, I still don't know how the Segre embedding of projective varieties is constructed (my algebraic geometry lecturer laboured hard to try and impart that knowledge, with the result that I thought it was difficult and abstruse); but I now know that it's a product in an appropriate category, so while the construction may be really nontrivial, the object itself is just the same old product which I already know and love. I now know that the difficulty lay in showing that this object exists and has the required properties, rather than the object itself being in some deep moral sense "hard to understand".
[html version] http://category-theory.mitpress.mit.edu
[old pdf version] http://math.mit.edu/~dspivak/CT4S.pdf
https://golem.ph.utexas.edu/category/2017/01/basic_category_...