Haskell/Solutions/Category theory

Which law implies transitivity?
Formally, transitivity of a partial order is defined as: for any $$a$$, $$b$$, and $$c$$ if $$a < b$$ and $$b < c$$ then $$a < c$$. In the category defined by a partial order this translates to: for any objects $$a$$, $$b$$, and $$c$$ if there exist morphisms $$a \to b$$ and $$b \to c$$ then there exists a morphism $$a \to c$$. This is guaranteed by the second law of categories, i.e., that they are closed under composition. Indeed, the last morphism is a composition of the first two.

Why does adding an arrow break category laws?


Let's consider what must be the result of the compositions $$h \circ g$$ and $$g \circ f$$. Notice that since $$h : B \to A$$ and $$g : A \to B$$ then $$h \circ g : A \to A$$ and given that there is only one morphism from $$A$$ to $$A$$, namely $$\operatorname{id}_A$$, it follows that $$h \circ g = \operatorname{id}_A$$. Using similar reasoning we can show that $$g \circ f = \operatorname{id}_B$$.

Now, let us consider the composition $$(h \circ g) \circ f$$; substituting $$h \circ g = \operatorname{id}_A$$ into it yields $$\operatorname{id}_A \circ f$$, which can be simplified to $$f$$ using the third law of categories. However, the first law of categories states that this composition should be equal to $$h \circ (g \circ f) = h \circ \operatorname{id}_B = h$$, yet $$f \neq h$$.