Finding composition of relations using matrix

116 Views Asked by At

I am reading some examples on the composition of relations from https://www.javatpoint.com/composition-of-relations.

There is an example saying:

Let P = {2, 3, 4, 5}. Consider the relation R and S on P defined by
R = {(2, 2), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 5), (5, 3)}
S = {(2, 3), (2, 5), (3, 4), (3, 5), (4, 2), (4, 3), (4, 5), (5, 2), (5, 5)}.

It obtains R o S by multiplying two matrices together:

$$M_R = \left[\begin{array}{l}1&1&1&1\\0&0&1&1\\0&0&0&1\\0&1&0&0\end{array}\right] M_S = \left[\begin{array}{l}0&1&0&1\\0&0&1&1\\1&1&0&1\\1&0&0&1\end{array}\right]M_R*M_S = \left[\begin{array}{l}2&2&1&4\\2&1&0&2\\1&0&0&1\\0&0&1&1\end{array}\right]$$

So,

R o S = {(2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (4, 2), (4, 5), (5, 2), (5, 3), (5, 4), (5, 5)}.

These matrices look good to me but I am wondering why (2,5) isn't in R o S because (2,3) in R and (3,5) in S should result in (2,5)?

Thanks!