Haskell/Solutions/Category theory

From testwiki
Jump to navigation Jump to search

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 ab and bc then there exists a morphism ac. 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 hg and gf. Notice that since h:BA and g:AB then hg:AA and given that there is only one morphism from A to A, namely idA, it follows that hg=idA. Using similar reasoning we can show that gf=idB.

Now, let us consider the composition (hg)f; substituting hg=idA into it yields idAf, 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(gf)=hidB=h, yet fh.

Template:Bookcat