6.4: Matrices of Relations
( \newcommand{\kernel}{\mathrm{null}\,}\)
We have discussed two of the many possible ways of representing a relation, namely as a digraph or as a set of ordered pairs. In this section we will discuss the representation of relations by matrices.
Representing a Relation with a Matrix
Definition
Let
Example
Let
we have2 𝑟 2 , 𝑅 1 1 = 1 we have2 𝑟 5 , 𝑅 1 2 = 1 we have5 𝑟 6 , 𝑅 2 3 = 1 we have6 𝑟 6 , 𝑅 3 3 = 1
All other entries of
Composition as Matrix Multiplication
From the definition of
The adjacency matrix of
We do not write
Definition
Boolean arithmetic is the arithmetic defined on
Table
Notice that from Chapter 3, this is the “arithmetic of logic,” where
Example
Suppose that
Theorem
Let
Remark: A convenient help in constructing the adjacency matrix of a relation from a set
To fill in the matrix,
Example
This final example gives an insight into how relational data base programs can systematically answer questions pertaining to large masses of information. Matrices
Although the relation between the software and computers is not implicit from the data given, we can easily compute this information. The matrix of
This matrix tells us at a glance which software will run on the computers listed. In this case, all software will run on all computers with the exception of program P2, which will not run on the computer C3, and programs P3 and P4, which will not run on the computer C1.
Exercises
Exercise
Let
- Determine the adjacency matrices of
and𝑟 1 𝑟 2 . - Use the definition of composition to find
𝑟 1 𝑟 2 . - Verify the result in part b by finding the product of the adjacency matrices of
and𝑟 1 𝑟 2 .
- Answer
-
and4 5 6 1 2 3 4 ⎛ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ 0 0 0 1 0 0 0 1 0 0 0 1 ⎞ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ 6 7 8 4 5 6 ⎛ ⎜ ⎜ ⎜ ⎜ ⎝ 0 0 0 1 0 0 0 1 0 ⎞ ⎟ ⎟ ⎟ ⎟ ⎠ 𝑟 1 𝑟 2 = { ( 3 , 6 ) , ( 4 , 7 ) } 6 7 8 1 2 3 4 ⎛ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ 0 0 0 0 0 0 1 0 0 0 1 0 ⎞ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠
Exercise
- Determine the adjacency matrix of each relation given via the digraphs in Exercise 6.3.3 of Section 6.3.
- Using the matrices found in part (a) above, find
of each relation in Exercise 6.3.3 of Section 6.3.𝑟 2 - Find the digraph of
directly from the given digraph and compare your results with those of part (b).𝑟 2
Exercise
Suppose that the matrices in Example
- Answer
-
Table
6 . 4 . 2 R : if and only if𝑥 𝑟 𝑦 | 𝑥 − 𝑦 | = 1 S : if and only if𝑥 𝑠 𝑦 is less than𝑥 𝑦 .
Exercise
Let
- compute
using Boolean arithmetic and give an interpretation of the relation it defines, and𝑆 𝑅 - compute
using regular arithmetic and give an interpretation of what the result describes.𝑆 𝑅
Exercise
How many different reflexive, symmetric relations are there on a set with three elements?
- Hint
-
Consider the possible matrices.
- Answer
-
The diagonal entries of the matrix for such a relation must be 1. When the three entries above the diagonal are determined, the entries below are also determined. Therefore, there are
fitting the description.2 3
Exercise
Let
- Explain why
is a partial ordering on𝑟 𝐴 . - Draw its Hasse diagram.
Exercise
Define relations
- Represent
and𝑝 as both graphs and matrices.𝑞 - Determine
𝑝 𝑞 , and𝑝 2 , and represent them clearly in any way.𝑞 2 ;
- Answer
-
and1 2 3 4 1 2 3 4 ⎛ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 ⎞ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ 1 2 3 4 1 2 3 4 ⎛ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 ⎞ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ 𝑃 𝑄 = 1 2 3 4 1 2 3 4 ⎛ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 ⎞ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ 𝑃 2 = 1 2 3 4 1 2 3 4 ⎛ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 ⎞ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ = 𝑄 2
Exercise
- Prove that if
is a transitive relation on a set𝑟 then𝐴 , 𝑟 2 ⊆ 𝑟 . - Find an example of a transitive relation for which
𝑟 2 ≠ 𝑟 .
Exercise
We define
- Prove that
is a partial ordering on all≤ relation matrices.𝑛 × 𝑛 - Prove that
, but the converse is not true.𝑅 ≤ 𝑆 ⇒ 𝑅 2 ≤ 𝑆 2 - If
and𝑅 are matrices of equivalence relations and𝑆 how are the equivalence classes defined by𝑅 ≤ 𝑆 , related to the equivalence classes defined by𝑅 𝑆 ?
- Answer
-
- Reflexive:
for all𝑅 𝑖 𝑗 = 𝑅 𝑖 𝑗 ,𝑖 , therefore𝑗 𝑅 𝑖 𝑗 ≤ 𝑅 𝑖 𝑗
Antisymmetric: Assume and𝑅 𝑖 𝑗 ≤ 𝑆 𝑖 𝑗 for all𝑆 𝑖 𝑗 ≤ 𝑅 𝑖 𝑗 ,1 ≤ 𝑖 . Therefore,𝑗 ≤ 𝑛 for all𝑅 𝑖 𝑗 = 𝑆 𝑖 𝑗 ,1 ≤ 𝑖 and so𝑗 ≤ 𝑛 𝑅 = 𝑆
Transitive: Assume , and𝑅 , 𝑆 are matrices where𝑇 and𝑅 𝑖 𝑗 ≤ 𝑆 𝑖 𝑗 , for all𝑆 𝑖 𝑗 ≤ 𝑇 𝑖 𝑗 ,1 ≤ 𝑖 . Then𝑗 ≤ 𝑛 for all𝑅 𝑖 𝑗 ≤ 𝑇 𝑖 𝑗 ,1 ≤ 𝑖 , and so𝑗 ≤ 𝑛 .𝑅 ≤ 𝑇 ( 𝑅 2 ) 𝑖 𝑗 = 𝑅 𝑖 1 𝑅 1 𝑗 + 𝑅 𝑖 2 𝑅 2 𝑗 + ⋯ + 𝑅 𝑖 𝑛 𝑅 𝑛 𝑗 ≤ 𝑆 𝑖 1 𝑆 1 𝑗 + 𝑆 𝑖 2 𝑆 2 𝑗 + ⋯ + 𝑆 𝑖 𝑛 𝑆 𝑛 𝑗 = ( 𝑆 2 ) 𝑖 𝑗 ⇒ 𝑅 2 ≤ 𝑆 2 ( 6 . 4 . 1 )
To verify that the converse is not true we need only one example. For , let𝑛 = 2 and all other entries equal𝑅 1 2 = 1 , and let0 be the zero matrix. Since𝑆 and𝑅 2 are both the zero matrix,𝑆 2 , but since𝑅 2 ≤ 𝑆 2 ,𝑅 1 2 > 𝑆 1 2 is false.𝑅 ≤ 𝑆 - The matrices are defined on the same set
. Let𝐴 = { 𝑎 1 , 𝑎 2 , ⋯ , 𝑎 𝑛 } ,𝑐 ( 𝑎 𝑖 ) be the equivalence classes defined by𝑖 = 1 , 2 , ⋯ , 𝑛 and let𝑅 ) be those defined by𝑑 ( 𝑎 𝑖 . Claim:𝑆 .𝑐 ( 𝑎 𝑖 ) ⊆ 𝑑 ( 𝑎 𝑖 )
𝑎 𝑗 ∈ 𝑐 ( 𝑎 𝑖 ) ⇒ 𝑎 𝑖 𝑟 𝑎 𝑗 ⇒ 𝑅 𝑖 𝑗 = 1 ⇒ 𝑆 𝑖 𝑗 = 1 ⇒ 𝑎 𝑖 𝑠 𝑎 𝑗 ⇒ 𝑎 𝑗 ∈ 𝑑 ( 𝑎 𝑖 ) ( 6 . 4 . 2 )
- Reflexive: