Table
Product sets and partitions
Relations and digraphs
Paths in relations and digraphs
Properties of relations
Equivalence relations
Operations on relations
Product sets and partitions Def.) product set or Cartesian product A×B
A×B={(a,b)|a∈A and b∈B}
e.g.) A={1,2,3} and B={r,s}
A×B={(1,r),(1,s),(2,r),(2,s),(3,r),(3,s)}
Def.) partition or quotient set P of a nonempty set A
Each element of A belongs to one of the sets in P.
If A1 and A2 are distinct elements of P, then A1∩A2=∅.
e.g.) A={a, b, c, d, e, f, g, h}
A1={a,b,c,d}, A2={a,c,e,f,g,h}, A3={a,c,e,g}, A4={b,d}
A5={f,h}
{A1, A2} : not a partition ∵A1∩A2≠∅
P={A3,A4,A5} is a partition of A.
Relations and digraphs Def.) Let A and B be nonempty sets. Relation R from A to B ⊆ A×B.
If R⊆A×B and (a,b)∈R, then a is related to b by R, a R b.
When R⊆A×A , R is a relation on A.
e.g.) A: the set of positive integers
a R b iff a divides b, a|b.
Then, 4R12, 5R7.
Def.) Let R ⊆ A×B be a relation from A to B.
the domain of R, Dom(R) : the set of elements in A
the range of R, Ran(R) : the set of elements in B
the R-relative set of x, R(x)={y∈B|x R y},
if R is a relation from A to B and x∈A.
e.g.) A={a,b,c,d} and R⊆A×A.
R={(a,a),(a,b),(b,c),(c,a),(d,c),(c,b)}
If A1={c,d}, then R(A1)={a,b,c}
Relations and digraphs Theorem : Let R be a relation from A to B, and let A1⊆A and A2⊆A.
If A1⊆ A2, then R(A1) ⊆ R(A2).
R(A1∪ A2)=R(A1) ∪ R(A2). R(A1 ∩ A2)⊆R(A1) ∩ R(A2)
e.g.) A={x|x is an integer}
R:≤
A1={0,1,2}, A2={9,13}
R(A1)={0,1,2,…}, if x≤y.
R(A2)={9,10,11,…}, if x≤y.
∴R(A1) ∩ R(A2)={9,10,11,…}
A1∩ A2=∅, R(A1∩ A2) = ∅
0≤n or 1≤n or 2≤n
Relations and digraphs
e.g.) Let A= {1,2,3} and B={x,y,z,w,p,q}, and let R ⊆ A×B.
Then, consider R={(1,x),(1,z),(2,w),(2,p),(2,q),(3,y)}.
Let A1={1,2} and A2={2,3}.
(1) R(A1)={x,z,w,p,q}
R(A2)={w,p,q,y}
R(A1)∪R(A2)={x,y,z,w,p,q}=B
Since A1∪A2=A, R(A1∪A2)=R(A)=B
(2) R(A1)∩R(A2)={w,p,q}=R(A1∩A2)
∴ R(A1)∩R(A2)⊇ R(A1∩A2)
Relations and digraphs
Def.) If A={a1,a2…am}and B={b1,b2…bn} are finite sets,
and R is a relation from A to B, then
R: m×n matrix MR=[mij],
mij= 1 if (ai,bj)∈R
0 if (ai,bj)∉R
MR : the matrix of R.
e.g.) A={1,2,3}, B={r,s}, R={(1,r),(2,s),(3,r)}
the matrix of R, m×n,
MR = 1 0 1
0 1 2
1 0 3
Relations and digraphs
Def.) digraph (or directed graph) of R
e.g.) A={1,2}, R={(1,1),(1,2),(2,1),(2,2)}
R is a relation on A.
1
2 3
vertices
Edge: a3 R a1
1 2
Relations and digraphs Def.) in-degree of a: the no. of b∈A s.t. (b,a)∈R
out-degree of a: the no. of b∈A s.t. (a,b)∈R
e.g.) The vertex 1 in the previous figure has in-degree 2.
e.g.) A={1,4,5}
Sol.) MR =
R={(1,4),(1,5),(4,1),(4,4),(5,4),(5,5)}
1 4
5
R
1
4
5
1
0
1
0
4
1
1
1
5
1
0
1
Relations and digraphs
Def.) the restriction of R to B : R∩(B×B)
if R is a relation on a set A and B⊆A.
e.g.) R ∩(B×B)
A={a,b,c}, B={a,b}
R={(a,a),(a,c),(b,c),(b,a),(c,c)}
B×B={(a,a),(a,b),(b,a),(b,b)}
R ∩(B×B) = {(a,a),(b,a)}
Paths in relations and digraphs Def.) a path of length n in R from a to b:
π: a, x1,x2,…,xn-1, b such that
a finite sequence aRx1, x1Rx2, … , xn-1Rb
e.g.)
π1:1,2,3 a path of length 2 from vertex 1 to vertex 3
π2: 1,2,5,1 π3:2,3
1
5 4
2
3
n+1 elements
Paths in relations and digraphs Def.)
Cycle : a path that begins and ends at the same vertex.
x Rn y: There is a path of length n from x to y in R
x R∞ y: There is some path in R from x to y.
⇒ connectivity relation for R.
e.g.) A={a,b,c,d,e}, R={(a,a),(a,b),(b,c),(c,e),(c,d),(d,e)}
(a) R2 (b) R∞
(a) R2 ={(a,a),(a,b),(a,c),(b,d),(b,e),(c,e)}
(b) R∞={(a,a),(a,b),(a,c),(a,d),(a,e),(b,c,),(b,d),(b,e),(c,d),(c,e),(d,e)}
a R2 a a R2 b a R2 c b R2 d b R2 e c R2 e
a b
c
d e
Paths in relations and digraphs Theorem
R is a relation on A ={a1,a2,…an}.
MR2=MR⊙MR
Proof) MR=[mij] MR2=[nij]
By the definition of MR⊙MR, the i, jth element of MR⊙MR is l iff the row i of MR and the column j of MR have a 1 in the same relative position, say k.
⇒mik=1 and mkj=1 for some k, 1≤k≤n.
By the definition of MR, this means that ai R ak and akR aj.
Thus, ai R2 aj , so nij=1
∴ MR⊙MR = MR2
MRn
Paths in relations and digraphs Theorem
For n≥2 and R a relation on a finite set A, we have
= MR⊙ MR⊙ … ⊙ MR (n factors).
Proof by induction
Basis step Let n=2. MR2 = MR⊙ MR
Induction hypothesis
n=k for some k≥2, MRk = MR⊙.. ⊙ MR (k factors)
Induction step
n=k+1. MRk+1 =[xij], MR
k =[yij], and MR =[mij]
if xij =1, we must have a path of length k+1 from ai to aj.
ai as aj
k 1
Paths in relations and digraphs
⇒ yis=1 and msj=1, so MRk ⊙ MR has a 1 in position i,j.
Similarly, if MRk ⊙ MR has a l in position i,j, then xij=1.
⇒ MRk+1 = MR
k ⊙ MR
MRk+1 = MR
k ⊙ MR
= (MR⊙.. ⊙ MR )⊙ MR (k+1 factors)
Thus, by the induction, MRn = MR⊙ MR⊙ … ⊙ MR (n
factors) is true for all n≥2.
Paths in relations and digraphs
Page 140, #26
A={1,2,3,4,5}, R: aRb iff a<b
(a) R2 and R3
R2=
R3=
Then, R=?
(b) a R2 b iff ?
(c) a R3 b iff ?
Properties of relations
Def.) reflexive
a relation R on a set A(≡ R⊆A×A) is reflexive if (a,a)∈R
for all a∈A.
e.g.) A={1,2,3}, R={(1,1),(2,2),(3,3)}:reflexive
cf.) “irreflexive” if (a,a)∉R for all a∈A.
e.g.) R={(1,1),(2,3)}
Is the empty relation reflexive?
Properties of relations
Def.) Symmetric
A relation R⊆A×A is symmetric if whenever aRb, then bRa.
Def.) asymmetric
If whenever aRb, then bRa
Def.) antisymmetric
If whenever aRb and bRa, then a=b
⇒if whenever a≠b, aRb or bRa
Properties of relations
e.g.) A: the set of integers. R={(a,b)∈A×A|a<b}
Sol.)
Symmetric
if a<b, then b≮a, R is not symmetric.
Asymmetric
if a<b, then b≮a, R is asymmetric.
Antisymmetric
if a≠b, then either a≮b or b≮a, R is antisymmetric
Properties of relations e.g.) A={1,2,3,4}, R={(1,2),(2,2),(3,4),(4,1)}
R: not symmetric (1,2)∈R but (2,1)∉R
not asymmetric (2,2) ∈R
antisymmetric!
• Let MR=[mij]
1. symmetric
if mij=1, then mji=1
if mij=0, then mji=0
2. asymmetric
if mij=1, then mji=0
mii=0 for all i if R is asymmetric.
3. antisymmetric
if i≠j, then mij=0 or mji=0.
Properties of relations
e.g.) MR1=
MR2=
MR3=
1 0 1
0 0 1
1 1 1
1 1 1
0 1 0
0 0 1
0 1 1 1
0 0 1 0
0 0 0 1
0 0 0 0
MR1 MR2 MR3
Reflexive
Irreflexive
Symmetric
Asymmetric
antisymmetric
Properties of relations
Digraph and graph of symmetric relation
Let A= {a,b,c} and R1⊆A×A.
a c
b
a c
b
Digraph of R1
R1 = 0 1 1
1 0 1
1 1 0
“graph” of R1
Properties of relations
Def.) Transitive
If whenever a R b and b R c, then a R c.
e.g.) A: the set of integers. R : the realtion “<“
a R b and b R c. a,b,c∈A
⇒a<b and b<c, then a<c, so a R c. Hence R is transitive.
e.g.) A={1,2,3,4} R={(1,2),(1,3),(4,2)} ⇒ transitive!
e.g.) A={1,2,3}
MR =
1 1 1
0 0 1
0 0 1
R={(1,1),(1,2),(1,3),(2,3),(3,3)}
Since (1,2) and (2,3), then (1,3).
Since (1,3) and (3,3), then (1,3).
Properties of relations
Theorem R⊆AxA
Reflexivity of R
a∈R(a) for all a in A
Symmetry of R
a∈R(b) iff b∈R(a)
Transitivity of R
if b∈R(a) and c∈R(b), then c∈R(a)
Equivalence relations
Def.) A relation R on a set A is an equivalence if it is reflexive,
symmetric, and transitive.
e.g.) Let A={1,2,3,4} and
R={(1,1),(1,2),(2,1),(2,2),(3,4),(4,3),(3,3),(4,4)}
reflexive?
symmetric?
transitive?
Equivalence relations Theorem
Let P be a partition of a set A.
Define the relation R on A:
a R b iff a and b are members of the same block.
Then R is an equivalence relation on A.
Proof Reflexive : If a∈A, then a R a. (∵a is in the same block) Symmetric : If a R b, a and b are in the same block. So. b R a Transitive : If a R b and b R c, then a, b, and c must be in the same
block of P. Thus, a R c.
R is the equivalence relation “determined by P.”
Equivalence relations Theorem
Let R be an equivalence relation on A, and let P be the collection
of all distinct relative sets R(a) for a in A. Then P is a partition of
A, and R is the equivalence relation determined by P.
Proof
(a) Every element of A belongs to some relative set.
(b) If R(a) and R(b) are not identical, then R(a)∩R(b)=∅.
(a) is true, since a∈R(a) by reflexivity of R.
(b) ⇒If R(a)∩R(b)≠∅, then R(a)=R(b). Then a R c and b R c
Since R is symmetric, c R b, and a R b by transitivity.
By Lemma, R(a)=R(b), Thus, P is a partition.
By Theorem, P determines R.
Equivalence relations e.g.) Let A={1,2,3,4} and
R={(1,1),(1,2),(2,1),(2,2),(3,4),(4,3),(3,3),(4,4)}
Find partition of A
Sol.) R(1) = {1,2}=R(2)
R(3) = {3,4}=R(4)
Given R, hence, P={{1,2},{3,4}}
Page 152, problem 20.
Let A={a,b,c,d,e} and R⊆AxA.
MR =
a b c d e
1 1 1 0 1
1 1 1 0 1
1 1 1 0 1
0 0 0 1 0
1 1 1 0 1
a
b
d
d
e
∴partition of A : A/R=?
Operations on relations Operations R,S ⊆ A×B
1. complementary relation : R
2. intersection : R∩S
3. union : R∪S
4. inverse : R-1 : relation from B to A
R-1⊆ B×A
e.g.) A={1,2,3,4}, B={a,b,c}
R={(1,a), (1,b), (2,b), (2,c), (3,b), (4,a)}
S={(1,b),(2,c),(3,b),(4,b)}
Operations on relations
Closures
reflexive closure of R
Symmetric closure of R
If A={a,b,c,d} and R={(a,b),(b,c),(a,c),(c,d)}, then
R-1={(b,a), (c,b),(c,a),(d,c)}
the symmetric closure of R:
R∪ R-1 ={(a,b),(b,a),(b,c),(c,b),(a,c),(c,a),(c,d),(d,c)}
a
b c
d a
b
d
c
R
(does not possess a
reflexive property) The reflexive closure of R
Operations on relations Transitive closure of R
Method 1: Finding transitivity from R
Method 2: computing R∞
Method 3: Warshall’s algorithm
a d
b c
“R is not transitive”
Warshall’s algorithm
e.g.) A= {1,2,3,4}, R={(1,2),(2,3),(3,4),(2,1)}
Method 1
(1,2),(2,3) ⇒(1,3)
(1,2),(2,1) ⇒(1,1)
Method 2
….
1 2
3
4
R∞={(1,1),(1,2),(1,3),(1,4),(2,1)…(3,4)}
Warshall’s algorithm Method 3
Warshall’s algorithm
How to implement the transitive closure of R!
Boolean matrix Wk
A={a1,a2,…,an}, R⊆A×A, 1≤k≤n
Wk=[tij]
tij=1 iff there is a path from ai to aj in R whose interior vertices come
from the set {a1,a2,…,ak}.
Wn : iff some path in R connects ai with aj .
Wn = MR∞
(since any vertex must come from the set {a1,a2,…,an})
Suppose Wk=[tij] and Wk-1=[sij]
(1) sij=1 or (2) sik=1 and skj=1
⇒ tij=1
ai aj
ak Subpath 1 Subpath 2
Warshall’s algorithm
Algorithm
Step 1: Copy Wk-1 into Wk. W0=MR.
Step 2: List the locations p1,p2…, in column k of Wk-1 , where
the entry is 1, and the locations q1,q2…, in row k of Wk-1 ,
where the entry is 1.
Step 3: Put 1’s in all the positions pi, qj of Wk.
Warshall’s algorithm e.g.) A={1,2,3,4}, R={(1,2),(2,3),(3,4),(2,1)}
W0=MR= 1
2
3
4
1
0
1
0
0
2
1
0
0
0
3
0
1
0
0
4
0
0
1
0
1≤k≤4(=n)
1. k=1
2-1, 1-2
i k k j
2. k=2
i 1 2,2 1 j
2 2
3 3. k=3
i 1 3,3 4 j
2
w1=
0
1
0
0
1
1
0
0
0
1
0
0
0
0
1
0
w2= 1
1
0
0
1
1
0
0
1
1
0
0
0
0
1
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
1
0
w3=
4. k=4
1 4, 4-(None of 1’s)
2
3 No new 1’s are added.
∴MR∞=W4=W3