Since this is (at least it seems to me) tightly related to programming, I'm asking here rather than on math or cs, but if you it think it best fits there or in another side, please just give your opinion.
At the end of Chapter 2 of Bartosz Milewski's Category Theory for Programmers, there's this question:
How many different functions are there from
BooltoBool? Can you implement them all?
This is my reasoning:
Boolhas only two elements in it,TrueandFalse;- different refers to what the functions do if considered blackboxes, regardless of what happens within them (for instance, two functions coding the sum of two
Ints asarg1 + arg2andarg2 + arg1respectively, would be the same function fromInttoInt); - so the different functions are those going from one of the two
Bools to another of the twoBools:TtoTTtoFFtoTFtoF
- What functions do I need to make those in-out scenarii possible? Well, I think I need only two, for instance the identity function, which would allow 1 and 4, and the negation, which would allow 2 and 3.
Is my reasoning correct?