 will be discussing matrix of a relation what we will see that given a relation from a set a to b or a relation on a set a we can define a binary matrix corresponding to the relation and this matrix plays an important role in studying properties of relations and operating one relation by the by another relation and so on. So to begin with let us start with a set a given by a1 up to an and a set b given by b1 up to bm now suppose r is a relation from a to b and of course n and m are finite positive integers what we can do is that we can label the rows and columns of a matrix by the elements of a and b respectively for example let us write a1 a2 a3 one below another and b1 b2 3 and so on up to bm and now we have positions of matrices indexed by a1 b1 a2 b2 a1 b2 a1 b3 a1 bm and so on we can fill fill in these gaps by writing m11 m12 m13 and m1 m in the next row we write m21 m22 m23 and so on m2 m at this point let us just change the notation a little bit and understand that this m and this m are not same so probably write this as m dash so we have got b1 up to bm dash this is 1 m dash 2 m dash and so on the next row we have m31 m32 m33 so on up to m3 m dash and then a mn1 mn2 nn3 so on up to mn m dash now as we have already studied that a relation is nothing but a subset of the Cartesian product of a and b therefore what we will do is that if a pair a i b j belongs to the relation we will put one in the corresponding mi j and if it does not belong to the relation then we will put 0 so we will write m i j equal to 0 if a i b j is not in R and we will write m i j equal to 1 if a i b j belongs to R and if by using this rule we fill in the fill in the matrix that we have already written down the mi j matrix then we will find that it becomes a binary matrix so what we will write is that this matrix that we denote by m sub R is equal to m11 up to m1 m dash m21 up to m2 m dash and so on and at the in the last column it is mn1 up to mn m dash now of course here we will assume that we will know we know the ordering the ordering is fixed the ordering of the set a in which we have level the by using which we have level the rows of the matrices rows of the matrix and the ordering of the set B by using which we have level the columns of the matrix m sub R it is now clear that the matrix m sub R is a binary matrix there is a special case of this which is used very often that is when a and b are same so in this case we have only one set a which is finite consisting of elements a1 up to a n and we have a relation R well which is a subset of a cross a so this relation is a relation on a and then we write m sub R which is the matrix corresponding to the relation R which is given by m ij which is an n by n matrix defined by m ij is equal to 0 if ai aj is not in R and 1 if ai aj is in R we will now look at some examples related to this idea of a matrix of a relation so first of all we check a well-known example that is the relation less than or equal to on the set 0 1 2 3 4 so in this case the set a is the set 0 1 2 3 4 we may even write that here now we are we are to construct the matrix corresponding to the relation given by less than or equal to let us call that matrix m sub less than or equal to which is equal to now at this point we are we have to label the rows and columns let us do that we label the columns by 0 1 2 3 4 and label the rows by 0 1 2 3 4 of course we have a matrix over here and there are entries that we have to fill in so let us start constructing the matrix we take 0 and 0 from here and here and we ask the question is 0 less than or equal to 0 the answer is yes therefore we write 1 after that we ask the question is 0 less than or equal to 1 the answer is yes therefore we write 1 then we ask the question is 0 less than or equal to 2 the answer is yes and therefore we write 1 over here and like this we fill in once in all the entries of the first row because 0 is less than all the elements of the set 0 1 2 3 4 then we move to the second row and we start checking we ask the question whether 0 is I am sorry whether 1 is less than or equal to 0 which is not true therefore we write 0 over here and then we write whether then we ask whether 1 is less than or equal to 1 and of course we know that 1 is less than or equal to 1 therefore we get 1 over here 1 is less than or equal to 2 so we get 2 over here 1 over here and similarly this in the third row the first column entry is 0 because 2 is not less than or equal to 0 2 is not less than or equal to 1 so 0 over here and then again 1 in the similar way we can fill in all the entries of the matrix and we get a matrix as this one right we will now look at another example where we are given a digraph and we are asked to find out well the corresponding matrix well that means that essentially a digraph is connected to a relation a relation is connected to a binary matrix therefore in effect any digraph is related to a binary matrix and if somebody looks at graph theory by not looking at relations then of course there is a graph such related to binary binary matrices and those matrices are called adjacency matrices so what we are looking at as matrices of relations are in a sense equivalent to adjacency matrices of digraphs but let us look at this example now we have five vertices v1 then v2 then we have v3 and then we have v4 and we have v5 and we have an adjoining v1 to v2 and v2 to v3 and then we have an adjoining v3 to v5 and an adjoining v4 to v1 and v4 to v2 right and this adjoining v3 to v4 so we write we write a draw a line from v3 to v4 and put an arrow head towards v4 so this is the graph that we have got so the underlying set of vertices or the set on which the relation is defined is v1 v2 v3 v4 and v5 and we would like to know the relation let us suppose the relation given by the digraph be denoted by R suppose R is the relation given by the above digraph alright and we would like to find out MR for that we again label the rows and columns of a matrix by the elements of a according to the order given here we could have basically chosen any order but we have to specify the order at some place possibly at the beginning so let us now write v1 up to v5 and v1 up to v5 as the labels of the rows and then let us start checking here see v1 is related to v2 therefore I put a 1 here and v1 is not related to anything else therefore I am free to put 0 in all the other places now let us look at v2 v2 is related to v3 well I put a 1 there and otherwise v2 is not related to anything else therefore I will put 0 as the other entries of the second row and then we come to v3 that is a third row and in the third row v3 is related to two elements v4 and v5 so v3 is not related to v1 so I put a 0 over here v3 is not related to v2 I put a 0 over here v3 v3 is well v3 is not related to itself so I put a 0 here but v3 is related to v4 therefore I will put a 1 over here and v3 is related to v5 so I put a 1 over here again and then we go to v4 where we find that v4 is related to v1 therefore I put a 1 over here and also it is related to v2 I put a 1 over here and rest of the places I put 0s and v5 is not related to any other element therefore I put a all 0s in the fifth row thus we have the basic matrix corresponding the relation are and we can write if we choose to forget the ordering that is to say suppose we fix the ordering once and we say that okay fine we do not write the ordering beside the rows and columns of the matrix all the time therefore we can write mr as 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 and 1 1 0 0 0 and at the end we have another row that is all 0 row that is corresponding to v5 this is the matrix corresponding to R now we move on to see what we can do with these matrices sometimes these matrices are useful in computing the results of operations on relations for example we have seen before that given several relation on a set we can take union intersection and composition of those relations and sometimes what happens is that if we are able to construct the corresponding matrices then we can determine the union and intersection composition of several relations very quickly and possibly by using a computer therefore let us see how to deal with unions for that we have to just see the see some general definitions so suppose r and s are two relations on a set a suppose r and s are two relations on a set a of cardinality n in finite all right whose matrices are given by mr well which is I will write it as m ij this is so it is n this is n x n and we have ms which we denote by let us say m dash ij n x n then we know that all these m ij s and m dash ij s are elements of the set 01 and on the set 01 we have the usual operations or and and given by this this operation is known as or and this operation is known as and we use this elementary operation to define operations on the matrices of relations we will define mr or ms as m ij or m dash ij n x n that is we take these two matrices and then we take element wise or to get another matrix which we call or of these two matrices similarly we will take these two matrices mr and ms and take element wise and to determine another matrix which we will call the and of these two matrices now the question is that what is the use of doing this we will shortly see that and an or of these two the and and or of these two matrices correspond to union and intersection of the relations let us look at it by an example so we check one example we consider a set a which is 1 2 3 and 4 and then we will consider a relation on a given by 1 2 1 3 and 2 4 we consider another relation s on a given by 1 2 2 3 and 4 4 all right now let us look quickly at what is r union s r union s is given by 1 2 1 3 2 3 2 4 and 4 4 and r intersection is the single turn given by now let us see what happens if we consider the matrices instead of these sets mr is equal to now let us label the rows 1 2 3 and 4 1 2 3 and 4 so 1 is related to 2 therefore I put a 1 over here and 1 is related to 3 so I put a 1 over here so it is 0 and this is 0 and 2 is related to 4 and that is all and there is no pair inside r therefore I complete the matrix in this way all right so I write it again so the matrix corresponding to mr is 0 1 1 0 0 0 0 1 0 0 0 0 and 0 0 0 0 now let us find out the matrix corresponding to MS again I have to label first 1 2 3 4 and 1 2 3 4 and if I write like this then in MS 1 is related to 2 so I will put a 1 over here and 2 is related to 3 so I will put a 1 over here and then I have 4 is related to 4 so I put a 1 over here rest of the entries are 0 so I will get something like this and 3 is not related to anything therefore I will put all 0 over here all right so I have got this one now I would like to take mr or MS for that I process these two matrices now I check the first entry in mr and MS both are 0 so 0 second entry both 1 so 1 third entry 1 0 1 0 is 1 therefore it is 1 and 0 0 is 0 so therefore it is 0 then in the second row we have 0 0 0 0 1 so therefore we have got 1 over here and then 1 0 so we have got 1 over here and similarly we check the third row we will find that this is all 0s and then at the end in the fourth row please see that if we compare the elements of mr and MS then first three entries are 0s in both the matrices therefore the result is 0 only in the last one in MS the 4 4 entry is 1 so therefore I will put a 1 over here and rest of the cases is 0 now let us try to construct the relation corresponding to this matrix we see that in this relation we will have this is 1 is related to 2 and then the entry 1 3 is 1 therefore 1 is related to 3 then in the second row 2 3 is related to 3 and in the again in the second row 2 4 is related to 2 is related to 4 and then at the end 4 is related to 4 so we see that the relation corresponding to the matrix mr or MS is 1 2 1 3 2 3 2 4 and 4 4 which is exactly same as the relation the relation are union s so the matrix that we have obtained is nothing but the matrix corresponding to R union s and this is in general true therefore we have one result which says that mr or MS gives me the matrix corresponding to M R union s now what about the intersection and let us look at the same pair of matrices so we have again mr which is equal to 0 1 1 0 0 0 0 1 then 0 0 0 0 and 0 0 0 0 and we write MS which is 0 1 0 0 0 0 1 0 and then the third row is totally 0 and the last row is all 0 except at the last entry where we have one and now we check and of these two relations mr and MS which gives me well I can compare in the same way I can see that the first entry of mr and first entry of MS is 0 so I put a 0 over here first in the first row second column entry is 1 in both the matrices so I put 1 over here and the rest two are 0s please note here that the in the previous example we were using element wise or so we 0 or 0 is 0 0 or 1 equal to 1 or 0 equal to 1 or 1 which is equal to 1 but in this case the element wise operation is and therefore it is basically making most of the things 0 so I have got 0 0 is 0 0 1 is 0 1 0 is 0 and 1 1 is 1 and that is the rule that I am using so we see that if we look at the second row and element wise I see that there is no common one as entries therefore all the entries will be 0s and of course the third row is 0 in the first and also in the second matrix therefore all 0 and the fourth row is 0 in the first matrix therefore it is 0 therefore we have a single ton and that is this single ton is the entry first row second column so it is 1 2 therefore the matrix the relation corresponding to the matrix MR well here is a mistake this is and so let me write it down well here this is and so MR and MS is equal to 1 2 and which is our intersection S therefore we can write MR and MS is equal to MR intersection S next we will look at the scenario of what happens if we take a product of two matrices corresponding to two relations the question is that whether it connects to some basic operations on relations so let us look let us look at what happens if we just take matrix product so again we are considering a set A which consists of n elements and we have a matrix R matrix of R defined as MR which is essentially MIJ it is an n x n matrix we have another matrix MS which is let us say is given by S IJ which is n x n and now if I just take a product of these two matrices usual matrix product then we will get MR MS which is equal to some T IJ n x n where T IJ is equal to sigma k going from 1 to n M I K S KJ of course this is usual matrix multiplication and well we have to remember that in this case the summation that we see in the right hand side of the equation containing T IJ is a summation over integers now we ask a question that what happens if T IJ is 0 for a pair I IJ so that means if T IJ equal to 0 then there exists no K belonging to 1 to up to n such that M I K S KJ is not 0 so that means that in other words in other words there exists no AK belonging to a right such that AI related to AK and AK related to AK related by S well AK related to AJ we have to remember here that this relation is S and this relation is R so there is no AK such that this holds but that means that this implies that AI is not related by R composition S to AJ or if we want to be a bit more specific then we will write AJ AI AJ does not belong to R composition S now suppose suppose we have a situation where the sum T IJ is not equal to 0 suppose T IJ is not equal to 0 then please note that this summation is a sum of non negative integers because M I K and SKJ are non negative integers therefore if T IJ is not 0 there has to exist at least one K such that such that well M I K equal to SKJ equal to 1 so let me write that then there exists K belonging to 1 up to n such that M I K SKJ both are 1 that means that is AI related by the relation R to AK and AK is related by the relation S to AJ which implies AI R composition S AJ or if we like to write AI, AJ the ordered pair AI AJ belongs to R composition S thus this proves that M R MR product MS has something to do with the matrix corresponding to the composition of R and S what we do is that we slightly modify the definition of product and we write MR then a small dot and then MS we write this that this is equal to let us say T just put a small dash over it IJ where T IJ dash is 1 if T IJ as we have defined above is not equal to 0 T IJ dash is 0 if T IJ equal to 0 so we define a new matrix MR composition MS in this way and it is clear from the discussion that we had that this is same as the matrix corresponding to MR composition S let us look at an example of this composition rule so let us again go back to the matrices that we were talking about here as you can see that this MR is this and MS is this matrix we will write a fresh these matrices and take the product MR product MS which is equal to 0 1 1 0 0 0 0 1 then 0 0 0 0 then 0 0 0 0 and here we have this new operation on matrices and then 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 now we start checking the elements if we see that the first row first day a first row first column is 0 second row first row second column also 0 but then if we go to the first row then we get a 1 and then then 0 and then if we check the other entries we will see that they are 0 0 0 1 and rest are 0 so either one can compute this directly or one can take a product the usual product of these two binary matrices such that the elements are the are calculated over the sum is calculated over integers and then the then modify the product matrix by the rule that if the entry is 0 it is 0 that if the entry is non-zero put 1 then you will get this matrix and this is the matrix corresponding to MR composition s that can be directly checked we have done this example in one of our previous lectures so therefore we have our composition s is given by 1 3 and 2 4 in this lecture we have defined relation at the matrix corresponding to a relation and we have basically seen that this matrix is nothing but adjacency matrix of a digraph that is the digraph corresponding to the relation so we have a situation like this we have digraphs then we have matrices let us say binary matrices and we have relations and what we have done is that we have developed connections among all these different concepts we have seen that essentially they are same and then we have seen that the basic operations and compositions of relations can be expressed very nicely as operations over binary matrices this is what we do in this lecture so thank you.