From page 29 of The algebra of programming : For any category C the opposite cat
ID: 647692 • Letter: F
Question
From page 29 of The algebra of programming :
For any category C the opposite category Cop is defined to have the same objects and arrows as C, but the source and target operators are interchanged and composition is defined by swapping arguments:
f?g in Cop=g?f in C.
This doesn't makes sense. Suppose C is the categories of all functions, and we have f:A?B and g:B?C, then g?f doesn't even exist. Or, suppose f:A?B and g:B?A, then f?g:A?A, and g?f:B?B, this is not interchanging source and target, this is changing both!
Explanation / Answer
The problem in your first example is that the arrows don't compose. In the first, you have f:A?B and g:C?B, so f?g is not in C, hence in Cop f:B?A and g:B?C, and they still don't compose.
If you had f:A?B and g:B?C, then they compose to f?g=h:A?C in C. In Cop you have f:B?A and g:C?B and get g?f=h:C?A (remember in Cop you want every thing running backwards) .
Your second example is fine, you just have f:A?B and g:B?A in C and hence f?g:A?A and g?f:B?B in C. In Cop, they switch: f:B?A, g:A?B are in Cop and so are g?f:A?A and f?g:B?B.
I wonder perhaps if the phrasing used by Bird is causing a problem. The rule is better stated:
If h=g?f in C , then h=f?g in Cop.
There's also a kind of name overloading going on here, from a programmer's perspective, reusing the same names for the opposite versions is a bit odd, it might make more sense to think along the lines (restating one of the rules):
If f:X?Y is in C, then fop:Y?X is in Cop
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.