Math 42, Discrete Mathematics
Fall 2018
Richard P. Kubelka
San Jose State University
last updated 12/05/2018 at 15:47:21
For use by students in this class only; all rights reserved.Note: some prose & some tables are taken directly from Kenneth R. Rosen, Discrete
Mathematics and Its Applications, 8th Ed., the o�cial text adopted for this course.
c© R. P. Kubelka
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Binary Relations from A to B
De�nition
Let A and B be sets. A binary relation from A to B is a
subset of A× B
Suppose R ⊆ A× B is a relation from A to B. If (a,b) ∈ R,we write aRb and say that a is related to b by R. If
(a,b) /∈ R, we write a�Rb.
Remark
A relation as de�ned above is called binary because it
involves ordered pairs. We could talk about ternary
relations involving ordered triples, quaternary relations
involving ordered quadruples, n-ary relations involving
ordered n-tuples, etc.
Since we will restrict our investigation to the binary case, we
will henceforth simply speak of �relations," instead of �binary
relations."
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Relations � Examples
Examples
1. Suppose A = {students in this Math 42 class} and
B = {countries in the world other than the US}. Let
R1 = {(a,b) |a has visited b}.
2. If f : A→ B is a function, then R2 = {(a, f(a)) |a ∈ A}is a relation, called the graph of the function.
Remarks
I Conversely, if R ⊆ A× B is a relation with the property that
every element of A is the �rst entry in precisely one ordered
pair of R, then setting f(a) = b whenever (a,b) ∈ R de�nes
a function f : A→ B.
I Note that R1 illustrates the fact that a given a ∈ A may
correspond under a relation to many elements b ∈ B�or
none.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Relations � Examples
3. R3 = ∅ ⊆ A× B.4. R4 = A× B ⊆ A× B.
For the most part, we will be interested in relations where
B = A.
De�nition
A relation on A is a subset of A×A, i.e., a relation from A
to A.
Examples
The relations 3 and 4 above are relations on A when B = A.
5. For any set A, R5 = {(a,a) |a ∈ A} is a relation on
A. This relation, of course, is just equality, and we
write �a1 = a2" instead of �a1R5a2."
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Relations � Examples
Examples
6. R6 = {(a1,a2) |a1 6= a2}. We write �a1 6= a2" instead
of �a1R6a2."
For the following examples, let A = Z+.
7. R7 = {(a1,a2) |a1 > a2}. We write �a1 > a2" instead
of �a1R7a2."
8. R8 = {(a1,a2) |a1 > a2}. We write �a1 > a2" instead
of �a1R8a2."
Remark
Relations 7 and 8 can be de�ned for A any subset of R.
9. R9 = {(a1,a2) |a1 divides a2}. We write �a1 |a2"
instead of �a1R9a2."
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Relations � Examples
Examples
10. If A = P(S), for some set S, we may de�ne the relation
R10 = {(X, Y) |X ⊆ Y}. We write �X ⊆ Y" instead of
�XR10Y."
For the following examples, let A = {all triangles}.
11. R11 = {(a1,a2) |a1 is congruent to a2}. We write
�a1 ∼= a2" instead of �a1R11a2."
12. R12 = {(a1,a2) |a1 is similar to a2}. We write
�a1 ∼ a2" instead of �a1R12a2."
Remark
For technical reasons, it turns out that there is no �set of all
triangles." But at this point there's no harm in pretending
that there is.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Relations � Examples
For the following two examples, let A be the set of all human
beings, living and dead.
13. R13 = {(a1,a2) |a1 is Facebook friends with a2}.
14. R14 = {(a1,a2) |a1 loves a2}.
15. Let A = {(p,q) |p,q ∈ Z ∧ q 6= 0} and de�ne
(p1,q1)R15(p2,q2) if and only if p1q2 = p2q1.
Warning
The set A is already a set of ordered pairs. So the relation
R15 is a set of ordered pairs of ordered pairs:
((p1,q1), (p2,q2)).
This relation is much more complicated than the others but
it is nonetheless very important.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Properties of Relations on A
De�nitions
Let R be a relation on A.
I R is called re�exive if aRa for all a ∈ A. That is, if∀a ∈ A, (a,a) ∈ R.
I R is called symmetric if a1Ra2 implies a2Ra1. That is,
if ∀(a1,a2) ∈ A×A, ((a1,a2) ∈ R)→ ((a2,a1) ∈ R).I R is called antisymmetric if a1Ra2 and a2Ra1 implies
a1 = a2.
I R is called transitive if a1Ra2 and a2Ra3 implies
a1Ra3. That is,
if ∀(a1,a2,a3) ∈ A×A×A, (((a1,a2) ∈R)∧ (a2,a3) ∈ R))→ ((a1,a3) ∈ R)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Properties of Example Relations
Table 1: Properties of Example Relations
R S T A
R3 Y Y Y
R4 Y Y Y
R5 Y Y Y Y
R6 Y
R7 Y Y Y
R8 Y Y
R9 Y Y Y
R10 Y Y Y
R11 Y Y Y
R12 Y Y Y
R13 Y
R14
R15 Y Y Y
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations
A type of relation on A that is very important in many
branches of mathematics is an equivalence relation.
De�nition
A relation R on a set A is called an equivalence relation on
A if R is
1. re�exive,
2. symmetric, &
3. transitive.
Example
Let A = Z and �x a positive integer n. De�ne a relation R16on A by
R16 = {(r, s) | r− s = nk for some k ∈ Z}= {(r, s) |n divides r− s evenly}
(1)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations � Examples
Claim
R16 is an equivalence relation on Z.
Proof.
Re�exive If r ∈ Z, we must show that rR16r. But
r− r = 0 = n · 0, which is what we need.
Symmetric If rR16s, we must show sR16r. rR16s gives us
that r− s = nk for some k ∈ Z. But thens− r = −nk = n(−k), and −k ∈ Z. So we
have what we need.
Transitive If rR16s and sR16t, then r− s = nk and
s− t = nl for some k, l ∈ Z. Then
r− t = (r− s)+ (s− t) = nk+nl = n(k+ l).
And since (k+ l) ∈ Z, we have rR16t, which is
what we needed.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations � Examples
RemarksI If (r, s) ∈ R16�i.e., rR16s�we write
r ≡ s (mod n)
and say �r is congruent to s modulo n."
I If n = 2, r ≡ s (mod 2) if and only if r and s have the
same parity, i.e., are both odd or both even.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations � Examples
Example
Recall that when A = {(p,q) |p,q ∈ Z ∧ q 6= 0}, we de�ned
(p1,q1)R15(p2,q2) if and only if p1q2 = p2q1.
Claim
R15 is an equivalence relation on Z× (Z− {0}).
Proof.
Re�exive If (p,q) ∈ A, then pq = pq. So(p,q)R15(p,q), as needed.
Symmetric If (p1,q1)R15(p2,q2), then p1q2 = p2q1. Butthen p2q1 = p1q2. So (p2,q2)R15(p1,q1), asdesired.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations � Examples
Example
(cont'd)
Proof.
(cont'd)
Transitive If (p1,q1)R15(p2,q2) and (p2,q2)R15(p3,q3),then p1q2 = p2q1, and p2q3 = p3q2. So
p1q3q2 = p2q3q1 = p2q1q3 = p3q1q2. (2)
But the extreme left and right ends of (2)
both contain a factor of q2 6= 0. Dividing by
q2 gives p1q3 = p3q1, and hence the desired
(p1,q1)R15(p3,q3).
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations
De�nition
Two elements a1,a2 ∈ A that are related by an equivalence
relation R�i.e., that satisfy a1Ra2�are called equivalent.
The notation a1 ∼ a2 is often used to denote that a1 and a2are equivalent with respect to a particular equivalence
relation. (Although speci�c equivalence relations like
congruence mod n, and, of course, equality, have their own
symbols, ≡ and =.)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Classes
De�nition
If ∼ is an equivalence relation on A, and if a ∈ A, then we
de�ne [a], the equivalence class of a, by
[a] = {b ∈ A |b ∼ a}. (3)
Remark
In cases where more than one equivalence relation on A is
under consideration, we write [a]R = {b ∈ A |bRa} to
emphasize the particular equivalence relation R.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Classes � Examples
Example
Recall that for a �xed positive integer n, we de�ned the
relation R16 by
R16 = {(r, s) | r− s = nk for some k ∈ Z}= {(r, s) |n divides r− s evenly}
(4)
Moreover, we proved that R16 is an equivalence relation.
So what are the equivalence classes for R16?
If m ∈ Z, we have
[m] = {k ∈ Z |k ≡ m mod n}
= {k ∈ Z |k−m = nl for some l ∈ Z}= {k ∈ Z |k = m+ nl for some l ∈ Z}= {m,m± n,m± 2n, . . .}
(5)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Classes � Examples
Example
Recall that when A = {(p,q) |p,q ∈ Z ∧ q 6= 0}, we de�ned
(p1,q1)R15(p2,q2) if and only if p1q2 = p2q1.
Furthermore, we proved that R15 is an equivalence relation.
So what are the equivalence classes for R15?
If (p,q) ∈ A, we have
[(p,q)] = {(r, s) ∈ A | (r, s) ∼ (p,q)} (6)
Case 1 (r, s) ∼ (0,q) if and only if r = 0. So
[(0,q)] = {(0, s) | s 6= 0} (7)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Classes � Examples
Example
(cont'd)
Case 2 If p 6= 0,
(r, s) ∼ (p,q)⇔ rq = ps⇔ r
p=s
q= v ∈ Q−{0}
(8)
so (r, s) = (vp, vq).
Thus,
[(p,q)] = {(r, s) | (r, s) ∼ (p,q)}
= {(vp, vq) | v ∈ Q− {0}} ∩A(9)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Classes � Examples
Example
(cont'd)
For example,
[(1, 2)] = {(1, 2), (−1,−2), (2, 4), (−2,−4), (3, 6), . . .} (10)
Remark
When we use the rational numbers�numbers of the form
p/q where p,q ∈ Z and q 6= 0�we're actually dealing with
the equivalence classes discussed in this example because
we're using the fact that
1
2=
−1
−2=
2
4=
−2
−4=
3
6=
−3
−6= . . .
That's why this rather complicated example is important.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions
De�nition
A partition of a set S is a collection of disjoint nonempty
subsets of S whose union is all of S.
In other words, P = {Ai |Ai ⊆ S ∀i ∈ I} is a partition of S if
and only if
1. Ai 6= ∅ ∀i ∈ I;2. Ai ∩Aj = ∅ ∀i 6= j ∈ I; and3.
⋃i∈IAi = S.
Remark
We call the Ai in a partition mutually exclusive and
exhaustive because they are mutually exclusive and
together they exhaust all the possible elements of S.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Partitions
Figure 1: A Partition of a Set
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions
Partitions are intimately related to equivalence relations, as
the following theorem shows.
Theorem
Let R be an equivalence relation on a set S. Then the
equivalence classes of R form a partition of S. Conversely,
given a partition {Ai | i ∈ I} of the set S, there is an
equivalence relation R that has the sets Ai, i ∈ I, as itsequivalence classes.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions
Proof.
�⇒"
Assume that R is an equivalence relation on S and Let
P = {[s] | s ∈ S} be the set of its equivalence classes. We
must show that P is a partition of S.
1. For each equivalence class [s] ∈ P, s ∈ [s] by re�exivity,
so [s] 6= ∅.2. Given [s], [t] ∈ P, we must show that either [s] = [t] or
[s] ∩ [t] = ∅.Suppose u ∈ [s] ∩ [t], i.e., [s] ∩ [t] 6= ∅. Then u ∼ s and
u ∼ t. Now if v ∈ [s], then v ∼ s. But symmetry of the
relation gives that s ∼ u, and transitivity then implies
that v ∼ u; transitivity again gives v ∼ t. Hence
[s] ⊆ [t]. A similar argument gives that [t] ⊆ [s], and so
[s] = [t].
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions
Proof.
(cont'd)
3.⋃
s∈S[s] ⊆ S since [s] ⊆ S ∀s ∈ S. On the other hand,
for every s ∈ S, s ∈ [s] ⊆⋃
s∈S[s]. Thus⋃
s∈S[s] = S,as needed.
�⇐"
If P = {Ai | i ∈ I} is a partition of S, we must show that P
de�nes an equivalence relation R on S whose equivalence
classes are the Ai.
De�ne the relation R by s ∼ t if and only if s, t ∈ Ai0 for
some i0 ∈ I, i.e., if and only if s and t are in the same piece
of the partition.
Re�exive If s ∈ S, then since⋃
i∈IAi = S, we must
have s ∈ Ai0 for some i0 ∈ I. But since s is inthe same Ai0 as itself, s ∼ s.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions
Proof.
(cont'd)
Symmetric If s ∼ t, then s, t ∈ Ai0 for some i0 ∈ I. Butthen t, s ∈ Ai0 , and so t ∼ s.
Transitive If s ∼ t and t ∼ v, then s, t ∈ Ai0 for some
i0 ∈ I, and t, v ∈ Aj0 for some j0 ∈ I. Thent ∈ Ai0 ∩Aj0 6= ∅. This implies that
Aj0 = Ai0 , so s, v ∈ Ai0 , and thus s ∼ v, as
needed.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions � Example
Example
Let A = R. And consider
P = {[k+ i/100− 0.005,k+ i/100+ 0.005) |k ∈ Z, i = 0, . . . , 99}(11)
Claim
P is a partition of A = R.
So that means that P gives rise to an equivalence relation ∼.
De�ne x ∼ y if and only if
b100x+ 0.5c = b100y+ 0.5c
This ∼ is the equivalence relation that gives rise to the
partition P.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions � Example
Example
(cont'd)
What's it all about? This is the equivalence relation we get
when we round a number to the nearest hundredth. A similar
argument yields the equivalence relation of rounding to any
speci�ed decimal place.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions � Example
Example
Suppose f : X→ Y is a function. De�ne a relation ∼ on X by
x1 ∼ x2 if and only if f(x1) = f(x2). Show that ∼ is an
equivalence relation.
Proof.
Re�exive For each x ∈ X, f(x) = f(x) since �=� is
re�exive. Thus x ∼ x.
Symmetric If x1 ∼ x2, then f(x1) = f(x2). But �=� is
symmetric, so f(x2) = f(x1), and thus x2 ∼ x1.
Transitive x1 ∼ x2 and x2 ∼ x3, then f(x1) = f(x2) andf(x2) = f(x3). But then f(x1) = f(x3) by the
transitivity of �=�, and so x1 ∼ x3, as needed.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions � Example
Example
(cont'd)
Remark
Note that the same result�with the same proof�would hold
if ≈ were an equivalence relation on Y and we de�ned ∼ on
X by x1 ∼ x2 if and only if f(x1) ≈ f(x2)
Suppose that f : R→ R is given by f(x) = sin x and that we
de�ne x1 ∼ x2 if and only if f(x1) = f(x2). What is [π/2],i.e., the equivalence class represented by π/2?
[π/2] = {x ∈ R | sin x = sinπ/2 = 1}
= {π/2+ k2π |k ∈ Z}.(12)
Note that x2 ∼ x1 if and only if x2 − x1 = k · 2π for some
k ∈ Z. Does this look familiar?
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Equivalence Relations & Partitions � Example
Let A = R and de�ne ∼ on A by
a ∼ b if and only if a− b = k · 2π, (13)
where k ∈ Z.
RemarksI The relation ∼ de�ned in (13) is an equivalence
relation. The proof is similar to the proof that
congruence modulo n is an equivalence relation.
I The relation ∼ is the same relation as the one de�ned by
the sine function above.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Matrices
De�nition
A matrix is a rectangular array of numbers. A matrix with m
rows and n columns is called an m× n matrix�pronounced
�m by n matrix.�
I The plural of �matrix� is �matrices.� There's no such
thing as a �matrice.�
I A matrix with the same number of rows as columns is
called square.
I Two matrices are equal if they have the same number of
rows and the same number of columns and the
corresponding entries in every position are equal.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Matrices
A generic matrix looks like
A =
a11 a12 · · · a1na21 a22 · · · a2n...
... · · ·...
am1 am2 · · · amn
, (14)
or A = [aij], for short.
We call aij the (i, j)th entry or element of A. The left-hand
subscript gives the row number, while the right-hand
subscript gives the column number.
Thus aij gives the element that occupies the intersection of
the i-th row and the j-th column.
Remark
Matrices are ubiquitous in science, mathematics, and even
business, but we will be interested only in binary matrices,
matrices whose entries are only 0's and 1's.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Relations and Matrices
Given a relation R on the set A = {a1, . . . ,an}, we build a
binary matrix M = [mij] as follows:
mij =
{1 if aiRaj
0 if ai�Raj.(15)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Relations and Matrices
Example
Let A = {2, 3, 4, 5, 6} and suppose R is de�ned by aRb if and
only if a ≡ b mod 3. Then
I R ={(2, 2), (2, 5), (3, 3), (3, 6), (4, 4), (5, 2), (5, 5), (6, 3), (6, 6)}.
I The matrix M associated to R is
M =
1 0 0 1 00 1 0 0 10 0 1 0 01 0 0 1 00 1 0 0 1
. (16)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Relations and Matrices
I Could we detect Re�exivity in R by looking at M? How?
Note that for Re�exivity, we need aRa for all a ∈ A.But since the elements of A are all numbered, that
means we need aiRai for all i = 1, . . . ,n. And that
will be true exactly when mii = 1 for all i = 1, . . . ,n,i.e., when all the diagonal entries of M are 1's.
I Could we detect Symmetry in R by looking at M? How?
For Symmetry, we need ajRai whenever we have aiRaj,
i.e., we need mji = 1 whenever mij = 1. On the other
hand, if mij = 0 and mji = 1, we would have ai�Rajand ajRai, contradicting symmetry. So we conclude
that R will be symmetric if and only if mji = mij for all
i, j = 1, . . . ,n. A square matrix M is called symmetric
if mji = mij for all i, j = 1, . . . ,n. So R will be
symmetric exactly when its corresponding matrix M is
symmetric.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Boolean Product of Matrices
De�nition
Let S = {0, 1}, we de�ne two operations on S as follows:
a1 ∧ a2 =
{1 if a1 = a2 = 1
0 otherwise,(17)
a1 ∨ a2 =
{0 if a1 = a2 = 0
1 otherwise.(18)
Remark
Note that if we interpret 1 as T and 0 as F, these are
precisely the operations of disjunction (∧) and conjunction
(∨) we studied in Chapter 1.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
De�nition
Given two n× n binary matrices A and B , the Booleanproduct C = A� B is the n× n binary matrix whose
(i, j)th entry cij is given by:
cij = (ai1 ∧ b1j)∨ (ai2 ∧ b2j)∨ · · ·∨ (ain ∧ bnj) (19)
(See p. 192, Rosen, 8th Ed., for this de�nition.)
Remark
We denote A�A by A[2].
De�nition
Given two n× n binary matrices N and M, we say N ⊆ M if
nij 6 mij for all i, j = 1, . . . ,n.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Binary Matrices and Transitivity
FactsI Suppose R1 and R2 are two relations on
A = {a1, . . . ,an}, and MR1 and MR2 are their binary
matrices, then MR1 ⊆ MR2 if and only if R1 ⊆ R2.I A relation R on A = {a1, . . . ,an} is transitive, if and
only if M[2]R ⊆ MR.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Representing Relations with Digraphs
De�nition
A directed graph, or digraph, consists of a set V of
vertices (or nodes) together with a set E of ordered pairs of
elements of V called edges (or arcs). The vertex a is called
the initial vertex of the edge (a,b) and the vertex b is
called the terminal vertex of this edge.
Remark
Note any relation R on a set A = {a1, . . . ,an} immediately
gives rise to a digraph: let V = A and let E = R. This works
because R is already a set of ordered pairs of the elements of
V = A.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Digraphs
Figure 2: Digraph 1
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Representing Relations with Digraphs
Example
The matrix for the relation R represented by the digraph in
Figure 2 is
MR =
0 0 1 11 1 1 01 0 1 01 0 1 0
(20)
I Is R re�exive? No, since not all the diagonal entries of
MR are 1s: m11 = 0 = m22
I Is R symmetric? No, since MR is not a symmetric
matrix.
I is R transitive? Well, we need to compute M[2]R .
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Representing Relations with Digraphs
Example (cont'd)
The matrix M[2]R for the relation represented by the digraph
in Figure 2 is
NR = M[2]R =
1 0 1 01 1 1 11 0 1 11 0 1 1
(21)
Since n11 = 1 and m11 = 0, R cannot be transitive.
Why is n11 = 1? Because, for example,
m13 ∧m31 = 1∧ 1 = 1. This means that a1Ra3 and
a3Ra1. Transitivity would then imply a1Ra1. But m11 = 0,so a1�Ra1, a contradiction.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Representing Relations with Digraphs
Example (cont'd)
Remark
Note that n14 = 0 while m14 = 1. What's the signi�cance
of this? The fact that mij = 1 encodes the fact that we can
get from ai to aj in one step, while nij = 0 encodes the
impossibility of getting from ai to aj in exactly two steps.
So here we can get from a1 to a4 in one step but not in two
steps.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Digraphs
Figure 3: Digraph 2
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Representing Relations with Digraphs
Example
The matrix for the relation R represented by the digraph in
Figure 3 is
MR =
1 0 1 10 1 0 01 0 1 01 0 0 1
(22)
I Is R re�exive? Yes, since all the diagonal entries of MR
are 1s.
I Is R symmetric? Yes, since MR is a symmetric matrix.
I is R transitive? Well, we need to compute M[2]R .
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Representing Relations with Digraphs
Example (cont'd)
The matrix M[2]R for the relation represented by the digraph
in Figure 3 is
NR = M[2]R =
1 0 1 10 1 0 01 0 1 11 0 1 1
(23)
Since n34 = 1 and m34 = 0, R cannot be transitive.
Why is n34 = 1? Because, for example,
m31 ∧m14 = 1∧ 1 = 1. This means that a3Ra1 and
a1Ra4. Transitivity would then imply a3Ra4. But m34 = 0,so a3�Ra4, a contradiction.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Example (cont'd)
Now suppose we consider the relation represented by the
digraph in Figure 3 but with A = {a, c,d,b}, i.e., with the
elements of A written in a di�erent order.
The new matrix MR will be
MR =
1 1 1 01 1 0 01 0 1 00 0 0 1
(24)
Notice that we can �partition� the matrix MR into blocks as
follows:
MR =
1 1 1 01 1 0 01 0 1 0
0 0 0 1
(25)
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Digraphs
Figure 4: Digraph 3
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Representing Relations with Digraphs
Example
The matrix for the relation R represented by the digraph in
Figure 4 is
MR =
1 1 1 10 1 0 10 0 1 10 0 0 1
(26)
I Is R re�exive? Yes, since all the diagonal entries of MR
are 1s.
I Is R symmetric? No, since MR is not a symmetric
matrix.
I is R antisymmetric? Well, we haven't looked at that
yet.
Math 42,Discrete
Mathematics
Richard P.Kubelka
San Jose StateUniversity
Relations &Their Properties
EquivalenceRelations
Matrices,Digraphs, &RepresentingRelations
c© R. P. Kubelka
Representing Relations with Digraphs
Example (cont'd)
I Recall that R is antisymmetric if and only if aiRaj and
ajRai together imply that ai = aj, i.e., i = j. In terms
of the matrix MR, this means that if i 6= j and mij = 1,then we must have mji = 0. MR satis�es this
condition, so R is antisymmetric.
I The matrix M[2]R for the relation represented by the
digraph in Figure 4 is
NR = M[2]R =
1 1 1 10 1 0 10 0 1 10 0 0 1
=
1 1 1 10 1 0 10 0 1 10 0 0 1
= MR
(27)
But since NR ⊆ MR, R is transitive.
Top Related