News for hackers. Stuff that matters.
Re:Category Theory, Syntactically (2016) by jules on Thursday April 27, 2017 @08:05AM (#14210815)
A category abstracts the concept of function composition. You need two things: an identity element, and a composition operation. For functions the identity element is the identity function id(x)=x and the composition operation is function composition compose(f,g) = (x -> f(g(x))). The twist is that you can't compose any two functions; their input and output types have to match up. If g is A -> B and f is B -> C you can compose them to a function A -> C, but the output type of g has to match up with the input type of f. Categories generalise this concept from composing functions to composing any thing with a notion of input and output type. In practice that often ends up being function composition anyway, but with restrictions on the function. For instance if you compose two linear functions you get a linear function, so this forms a category. Or continuous functions, or functions that can be differentiated, etcetera. However, quadratic functions do not form a category, because if you compose a quadratic function with another quadratic function you may get a function with higher degree. For instance if f(x) = x^2 then compose(f,f) is x^4. Polynomials on the other hand do form a category. In general this need not be composition of functions, as long as there's an identity element and a compose operation with a notion of input and output type. Binary relations is the easiest example that I can think of.
Re:Category Theory, Syntactically (2016) by agumonkey on Thursday April 27, 2017 @09:05AM (#14211140)
So it's more a generalization of Groups right ?
Re:Category Theory, Syntactically (2016) by stabbles on Thursday April 27, 2017 @09:23AM (#14211241)
A monoid (weaker than group: doesn't need to have an inverse) is an example of a category, with a single object G (namely the underlying set) and a lot of arrows from G -> G.

If you take the natural numbers N = {0, 1, ...} as a set and + as a binary operator forming a monoid (N, +, 0), then the arrows would correspond to (. + 0), (. + 1), (. + 2) etc. Here (. + 0) can be seen as the identity arrow, and composition of arrows (. + a) and (. + b) yields a new arrow (. + (a+b)).

Re:Category Theory, Syntactically (2016) by ihm on Thursday April 27, 2017 @11:22AM (#14212153)
Yes, roughly. You can think about a category like a group which carries around "type parameters" to say which "elements" you can and can't multiply. Also, "elements" may not be invertible.

For example, for each N, there is a group of invertible N by N matrices. If we want to allow non-square matrices too, we can bundle them up as a category:

- The objects are the natural numbers

- A map from N to M is an M row by N column matrix

- We compose A : N -> M and B : M -> K by multiplying them as matrices to get BA : N -> K. The objects (i.e., the dimensions) are type checking which things we can and can't multiply

Re:Category Theory, Syntactically (2016) by jules on Thursday April 27, 2017 @12:22PM (#14212699)
There are two differences:

1) Groups have an inverse operation, categories don't.

2) You can compose any two elements in a group, whereas in a category the input and output types have to match up.

Re:Category Theory, Syntactically (2016) by tel on Thursday April 27, 2017 @10:58AM (#14211979)
The category-like generalization of the group is the groupoid: all arrows are isomorphisms.