Discrete Mathematics
Week12 Relations
Chapter 8 Relations
Chih-Wei Yi
Dept. of Computer Science
National Chiao Tung University
2 May 2008
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Binary Relations
De…nition
Let A and B be any two sets. A binary relation R from A to B,
written R : A $ B, is a subset of A B. The notation aRb means
(a, b ) 2 R.
If aRb, we may say “a is related to b (by relation R)”, or “a
relates to b (under relation R)”.
Example
<: N $ N : f(n, m) j n < mg. a < b means (a, b ) 2<.
A binary relation R corresponds to a predicate function
PR : A B ! fT , F g de…ned over the 2 sets A and B.
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Examples of Binary Relations
Let A = f0, 1, 2g and B = fa, b g. Then
R = f(0, a), (0, b ), (1, a), (2, b )g is a relation from A to B.
For instance, we have 0Ra, 0Rb, etc..
Can we have visualized expressions of relations?
Let A be the set of all cities, and let B be the set of the 50
states in the USA. De…ne the relation R by specifying that
(a, b ) belongs to R if city a is in state b. For instance,
(Boulder,Colorado), (Bangor,Maine), (Ann Arbor,Michigan),
(Middletown,New Jersey), (Middletown,New York),
(Cupertino,California), and (Red Bank,New Jersey) are in R.
“eats” : f(a, b ) j organism a eats food b g.
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Complementary Relations
De…nition
Let R : A $ B be any binary relation. Then, R : A $ B, the
complement of R, is the binary relation de…ned by
R: f(a, b ) j (a, b ) 2
/ R g = (A B) R.
Note this is just R if the universe of discourse is U = A B;
thus the name complement.
The complement of R is R.
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Inverse Relations
De…nition
Any binary relation R : A $ B has an inverse relation
R 1 : B $ A, de…ned by
1
R : f(b, a) j (a, b ) 2 R g.
Examples
1 < 1 = f(b, a) j a < b g = f(b, a) j b > ag =>.
2 If R : People ! Foods is de…ned by "aRb , a eats b", then
1
bR a , b is eaten by a.
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Examples
Example
Let A = f1, 2, 3, 4, 5g and R : A $ A : f(a, b ) : a j b g. What
are R and R 1 ?
Solution
(1, 1) , (1, 2) , (1, 3) , (1, 4) , (1, 5) , (2, 2) , (2, 4) ,
R=
(3, 3) , (4, 4) , (5, 5)
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Examples
Example
Let A = f1, 2, 3, 4, 5g and R : A $ A : f(a, b ) : a j b g. What
are R and R 1 ?
Solution
(1, 1) , (1, 2) , (1, 3) , (1, 4) , (1, 5) , (2, 2) , (2, 4) ,
R=
(3, 3) , (4, 4) , (5, 5)
8 9
< (2, 1) , (2, 3) , (2, 5) , (3, 1) , (3, 2) , (3, 4) , (3, 5) , =
R= (4, 1) , (4, 2) , (4, 3) , (4, 5) , (5, 1) , (5, 2) , (5, 3) ,
: ;
(5, 4)
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Examples
Example
Let A = f1, 2, 3, 4, 5g and R : A $ A : f(a, b ) : a j b g. What
are R and R 1 ?
Solution
(1, 1) , (1, 2) , (1, 3) , (1, 4) , (1, 5) , (2, 2) , (2, 4) ,
R=
(3, 3) , (4, 4) , (5, 5)
8 9
< (2, 1) , (2, 3) , (2, 5) , (3, 1) , (3, 2) , (3, 4) , (3, 5) , =
R= (4, 1) , (4, 2) , (4, 3) , (4, 5) , (5, 1) , (5, 2) , (5, 3) ,
: ;
(5, 4)
1 (1, 1) , (2, 1) , (3, 1) , (4, 1) , (5, 1) , (2, 2) , (4, 2) ,
R =
(3, 3) , (4, 4) , (5, 5)
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Relations on a Set
De…nition
A (binary) relation from a set A to itself is called a relation on the
set A.
E.g., the "<" relation from earlier was de…ned as a relation
on the set N of natural numbers.
The identity relation IA on a set A is the set f(a, a) j a 2 Ag.
Let A be the set f1, 2, 3, 4g. Which ordered pairs are in the
relation R = f(a, b ) j a divides b g?
How many relations are there on a set with n elements?
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Re‡exivity
De…nition
A relation R on A is re‡exive if 8a 2 A, aRa. A relation is
irre‡exive i¤ its complementary relation is re‡exive.
E.g., the relation : f(a, b ) j a b g is re‡exive.
E.g., < is irre‡exive.
"irre‡exive"6="not re‡exive"!
"likes" between people is not re‡exive, but not irre‡exive
either. (Not everyone likes themselves, but not everyone
dislikes themselves either.)
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Example 7 from Textbook
Example
Consider the following relations on f1, 2, 3, 4g.
R1 = f(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)g ,
R2 = f(1, 1), (1, 2), (2, 1)g ,
R3 = f(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)g ,
R4 = f(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)g ,
(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3),
R5 = ,
(3, 4), (4, 4)
R6 = f(3, 4)g .
Which of these relations are re‡exive, irre‡exive, and not re‡exive?
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Symmetry & Antisymmetry
De…nition
A binary relation R on A is symmetric i¤ R = R 1, that is
(a, b ) 2 R $ (b, a) 2 R.
E.g., = (equality) is symmetric, and < is not.
"is married to" is symmetric, and "likes" is not.
A binary relation R is antisymmetric if
(a, b ) 2 R ^ (b, a) 2 R ! a = b.
E.g., < is antisymmetric, and "likes" is not.
Which relations from Example 7 are symmetric and which are
antisymmetric?
If R1 is symmetric and R2 is antisymmetric, is it true that
R1 \ R2 = ??
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Transitivity
De…nition
A relation R is transitive i¤
8a, b, c : (a, b ) 2 R ^ (b, c ) 2 R ! (a, c ) 2 R.
A relation is intransitive if it is not transitive.
E.g., "is an ancestor of" is transitive, and "likes" is
intransitive.
Which of the relations in Example 7 are transitive?
Is the "divides" relations on the set of positive integers
transitive?
"is within 1 mile of" is . . . ?
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Combining Relations
Since relations from A to B are subsets of A B, two relations
from A to B can be combined through set operations.
Let A = f1, 2, 3g and B = f1, 2, 3, 4g. The relations
R1 = f(1, 1), (2, 2), (3, 3)g and
R2 = f(1, 1), (1, 2), (1, 3), (1, 4)g can be combined to obtain
R1 [ R2 = f(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (3, 3)g ,
R1 \ R2 = f(1, 1)g ,
R1 R2 = f(2, 2), (3, 3)g
R2 R1 = f((1, 2), (1, 3), (1, 4)g .
Quiz: What is R1 R2 ?
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Composite Relations
Let R : A $ B, and S : B $ C . Then the composite S R of
R and S is de…ned as: S R = f(a, c ) j aRb ^ bSc g .
Example 1 Function composition f g is an example.
Example 2 A = f1, 2, 3g, B = fa, b, c, d g, C = fx, y , z g.
R : A $ B, R = f(1, a), (1, b ), (2, b ), (2, c )g.
S : B $ C , S = f(a, x ), (a, y ), (b, y ), (d, z )g.
S R = f(1, x ), (1, y ), (2, y )g.
The nth power R n of a relation R on a set A can be de…ned
R 0 : IA ;
recursively by
R n +1 : R n R for all n 0.
Negative powers of R can also be de…ned if desired, by
R n : (R 1 )n .
Discrete Mathematics
Chapter 8 Relations
8.1 Relations and Their Properties
Whether A Relation Is Transitive Or Not?
Theorem
The relation R on a set A is transitive if and only if R n R for all
n = 1, 2, 3, .
Think about what (a, b ) 2 R k means?
How to prove an "if and only if" statement?
Let R = f(1, 1), (2, 1), (3, 2), (4, 3)g. Find the powers R n for
n = 2, 3, .
Let R = f(1, 2), (1, 3), (2, 2), (2, 3), (4, 3)g. Find the powers
R n for n = 2, 3, .
Discrete Mathematics
Chapter 8 Relations
8.2 n-ary Relations and Their Applications
n-ary Relations
De…nition
An n-ary relation R on sets A1 , , An , written R : A1 , , An , is
a subset R A1 An .
The sets Ai are called the domains of R.
The degree of R is n.
R is functional in domain Ai if it contains at most one n-tuple
( , ai , ) for any value ai within domain Ai .
Discrete Mathematics
Chapter 8 Relations
8.2 n-ary Relations and Their Applications
Relational Databases
A relational database is essentially an n-ary relation R.
A domain Ai is a primary key for the database if the relation
R is functional in Ai .
A composite key for the database is a set of domains
fAi , Aj , g such that R contains at most 1 n-tuple
( , ai , , aj , ) for each composite value
( ai , aj , ) 2 Ai Aj .
Discrete Mathematics
Chapter 8 Relations
8.2 n-ary Relations and Their Applications
Selection Operators
Let A be any n-ary domain A = A1 An , and let
C : A ! fT , F g be any condition (predicate) on elements
(n-tuples) of A.
Then, the selection operator sC is the operator that maps any
(n-ary) relation R on A to the n-ary relation of all n-tuples
from R that satisfy C .
I.e., 8R A,
sC ( R ) = R \ f a 2 A j sC ( a ) = T g
= f a 2 R j sC ( a ) = T g .
Discrete Mathematics
Chapter 8 Relations
8.2 n-ary Relations and Their Applications
Selection Operator Example
Suppose we have a domain
A = StudentName Standing SocSecNos.
Suppose we de…ne a certain condition on A,
UpperLevel (name, standing , ssn )
: [(standing = junior) _ (standing = senior)]
Then, sUpperLevel is the selection operator that takes any
relation R on A (database of students) and produces a relation
consisting of just the upper-level classes (juniors and seniors).
Discrete Mathematics
Chapter 8 Relations
8.2 n-ary Relations and Their Applications
Projection Operators
Let A = A1 An be any n-ary domain, and let
fik g = (i1 , . . . , im ) be a sequence of indices all falling in the
range 1 to n.
That is, where 1 ik n for all 1 k m.
Then the projection operator on n-tuples
Pfik g : A ! Ai1 Aim
is de…ned by
P f i k g ( a1 , , an ) = ( ai 1 , , ai m ) .
Discrete Mathematics
Chapter 8 Relations
8.2 n-ary Relations and Their Applications
Projection Example
Suppose we have a ternary (3-ary) domain
Cars = Model Year Color . (n = 3)
Consider the index sequence fik g = f1, 3g. (m = 2)
Then the projection Pfik g simply maps each tuple
(a1 , a2 , a3 ) = (model, year , color ) to its image:
(ai1 , ai2 ) = (a1 , a3 ) = (model, color ).
This operator can be usefully applied to a whole relation
R Cars (database of cars) to obtain a list of model/color
combinations available.
Discrete Mathematics
Chapter 8 Relations
8.2 n-ary Relations and Their Applications
Join Operator
Puts two relations together to form a sort of combined
relation.
If the tuple (A, B ) appears in R1 , and the tuple (B, C )
appears in R2 , then the tuple (A, B, C ) appears in the join
J (R1 , R2 ).
A, B, C can also be sequences of elements rather than single
elements.
Discrete Mathematics
Chapter 8 Relations
8.2 n-ary Relations and Their Applications
Join Example
Suppose R1 is a teaching assignment table, relating Professors
to Courses.
Suppose R2 is a room assignment table relating Courses to
Rooms and Times.
Then J (R1 , R2 ) is like your class schedule, listing
(professor , course, room, time ).
Discrete Mathematics
Chapter 8 Relations
8.3 Representing Relations
Representing Relations
Some ways to represent n-ary relations:
With an explicit list or table of its tuples.
With a function from the domain to fT , F g.
Some special ways to represent binary relations:
With a zero-one matrix.
With a directed graph.
Discrete Mathematics
Chapter 8 Relations
8.3 Representing Relations
Using Zero-One Matrices
To represent a relation R by a matrix MR = [mij ], let mij = 1
if (ai , bj ) 2 R, else 0.
E.g., Joe likes Susan and Mary, Fred likes Mary, and Mark
likes Sally. The 0 1 matrix representation of that “Likes”
relation:
Susan Mary Sally
Joe 1 1 0
Fred 0 1 0
Mark 0 0 1
Discrete Mathematics
Chapter 8 Relations
8.3 Representing Relations
Examples
Example
Let S = fSpring,Summer,Fall,Winterg and
F = fApple,Berry,Cherry,Durian,E*g. Which ordered pairs are in
the relation R represented by the matrix?
Apple Berry Cherry Durian
Spring 1 0 1 0
Summer 0 0 1 1
Fall 0 1 0 0
Winter 1 0 0 0
Discrete Mathematics
Chapter 8 Relations
8.3 Representing Relations
Zero-One Re‡exive, Symmetric
Terms: re‡exive, non-re‡exive1 , irre‡exive, symmetric,
asymmetric2 , and antisymmetric.
These relation characteristics are very easy to recognize by
inspection of the zero-one matrix.
1
any- 0 any- 1 0
1 0 1 0 1
thing thing 1
0
an
an
yt
yt
hin
h
any- 1 0
in
g
0
g
thing thing
any-
1 0 0 0
Reflexive: Irreflexive: Symmetric: Antisymmetric:
all 1’s on diagonal all 0’s on diagonal all identical all 1’s are across
across diagonal from 0’s
1A relation R on A is non-re‡exive if it is not re‡exive.
2A relation R on A is asymmetric if 8a, b 2 A : aRb ! bR a.
Discrete Mathematics
Chapter 8 Relations
8.3 Representing Relations
Matrix Operation v.s. Relation Operations
MR 1 [R 2 = MR 1 _ MR 2 ; MR 1 \R 2 = MR 1 ^ MR 2 .
_ and ^ are element-wise Boolean operators.
MS R = MR MS ; MR n = (MR )n .
denotes Boolean matrix multiplications.
MR = (MR )T .
1
Quiz: If R is a symmetric relation, MR is a symmetric matrix.
Discrete Mathematics
Chapter 8 Relations
8.3 Representing Relations
Using Directed Graphs
A directed graph or digraph G = (VG , EG ) is a set VG of
vertices (nodes) with a set EG VG VG of edges
(arcs, links ). Visually represented using dots for nodes, and
arrows for edges. Notice that a relation R : A $ B can be
represented as a graph GR = (VG = A [ B, EG = R ).
Edge set EG
MR Susan Mary Sally GR (blue arrows)
Joe 1 1 0 Joe Susan
Fred 0 1 0 Fred Mary
Mark 0 0 1 Mark Sally
Node set VG
(black dots)
Discrete Mathematics
Chapter 8 Relations
8.3 Representing Relations
Digraph Re‡exive, Symmetric
It is extremely easy to recognize the
re‡exive/irre‡exive/symmetric/antisymmetric properties by
graph inspection.
P
P P
P P
P P P P P P
Reflexive: Irreflexive: Symmetric: Antisymmetric:
Every node No node Every link is No link is
has a self-loop links to itself bidirectional bidirectional
Asymmetric, non-antisymmetric Non-reflexive, non-irreflexive
Discrete Mathematics
Chapter 8 Relations
8.4 Closures of Relations
Closures of Relations
For any property X , the “X closure” of a set (or relation) R is
de…ned as the “smallest” superset of R that has the given
property.
The re‡exive closure of a relation R on A is obtained by
adding (a, a) to R for each a 2 A. I.e., it is R [ IA .
The symmetric closure of R is obtained by adding (b, a) to R
for each (a, b ) in R. I.e., it is R [ R 1 .
The transitive closure or connectivity relation of R is obtained
by repeatedly adding (a, c ) to R for each (a, b ) and (b, c ) in
R. I.e., it is [
R = Rn.
n 2Z +
Discrete Mathematics
Chapter 8 Relations
8.4 Closures of Relations
Paths in Digraphs/Binary Relations
De…nition
A path of length n from node a to b in the directed graph G (or
the binary relation R) is a sequence (a, x1 ), (x1 , x2 ), , ( xn 1 , b )
of n ordered pairs in EG (or R). A path of length n 1 from a to
a is called a circuit or a cycle.
Theorem
There exists a path of length n from a to b in R if and only if
(a, b ) 2 R n .
An empty sequence of edges is considered a path of length 0
from a to a.
If any path from a to b exists, then we say that a is connected
to b. (“You can get there from here.”)
Discrete Mathematics
Chapter 8 Relations
8.4 Closures of Relations
Simple Transitive Closure Algorithm
Lemma
Let A be a set with n element, and let R be a relation on A. If
there is a path of length at least one in R from a to b, then there
is such a path with length not exceeding n.
procedure transClosure(MR : rank-n 0-1 matrix)
// A procedure computes R with 0-1 matrices.
A := B := MR ;
for i := 2 to n begin
A := A MR ; B := B _ A;
end
return B
This algorithm takes Θ(n4 ) time.
Discrete Mathematics
Chapter 8 Relations
8.4 Closures of Relations
A Faster Transitive Closure Algorithm
procedure transClosure(MR : rank-n 0-1 matrix)
A := B := MR ;
for i := 2 to dlog2 ne begin
i
A := A A; // A represents R 2 .
B := B _ A; // “add” into B.
end
return B
This algorihtm takes only Θ(n3 logn) time, BUT NOT
CORRECT.
Discrete Mathematics
Chapter 8 Relations
8.4 Closures of Relations
Roy-Warshall Algorithm
procedure Warshall(MR : rank-n 0-1 matrix)
W := MR ;
for k := 1 to n
for i := 1 to n
for j := 1 to n
wij := wij _ (wik ^ wkj )
return W {This represents R .}
Uses only Θ(n3 ) operations!
wij = 1 means there is a path from i to j going only through
nodes k.
Discrete Mathematics
Chapter 8 Relations
8.4 Closures of Relations
Examples
Example
Find the symmetric closure, re‡exive closure, and transitive closure
of the following relation.
P
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Equivalence Relations
De…nition
An equivalence relation (e.r.) on a set A is simply any binary
relation on A that is re‡exive, symmetric, and transitive.
E.g., "=" itself is an equivalence relation.
For any function f : A ! B, the relation “have the same f
value”, or =f : f(a1 , a2 ) j f (a1 ) = f (a2 )g is an equivalence
relation.
E.g., let m = “mother of”, then =m : “have the same
mother” is an e.r..
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Examples of E.R.’s
Examples
“Strings a and b are the same length.”
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Examples of E.R.’s
Examples
“Strings a and b are the same length.”
“Integers a and b have the same absolute value.”
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Examples of E.R.’s
Examples
“Strings a and b are the same length.”
“Integers a and b have the same absolute value.”
“Real numbers a and b have the same fractional part (i.e.,
a b 2 Z ).”
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Examples of E.R.’s
Examples
“Strings a and b are the same length.”
“Integers a and b have the same absolute value.”
“Real numbers a and b have the same fractional part (i.e.,
a b 2 Z ).”
“Integers a and b have the same residue modulo m.” (for a
given m > 1)
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Equivalence Classes
De…nition
Let R be any equivalence relation on a set A. The equivalence
class of a is
[a ]R : fb j aRb g . (optional subscript R)
It is the set of all elements of A that are “equivalent” to a
according to the E.R. R.
Each such b (including a itself) is called a representative of
[a ]R .
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Equivalence Class Examples
“Strings a and b are the same length.”
[a] = the set of all strings of the same length as a.
“Integers a and b have the same absolute value.”
“Real numbers a and b have the same fractional part (i.e.,
a b 2 Z ).”
“Integers a and b have the same residue modulo m.” (for a
given m > 1)
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Equivalence Class Examples
“Strings a and b are the same length.”
[a] = the set of all strings of the same length as a.
“Integers a and b have the same absolute value.”
[a] = the set fa, ag.
“Real numbers a and b have the same fractional part (i.e.,
a b 2 Z ).”
“Integers a and b have the same residue modulo m.” (for a
given m > 1)
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Equivalence Class Examples
“Strings a and b are the same length.”
[a] = the set of all strings of the same length as a.
“Integers a and b have the same absolute value.”
[a] = the set fa, ag.
“Real numbers a and b have the same fractional part (i.e.,
a b 2 Z ).”
[a] = the set f ,a 2, a 1, a, a + 1, a + 2, g.
“Integers a and b have the same residue modulo m.” (for a
given m > 1)
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Equivalence Class Examples
“Strings a and b are the same length.”
[a] = the set of all strings of the same length as a.
“Integers a and b have the same absolute value.”
[a] = the set fa, ag.
“Real numbers a and b have the same fractional part (i.e.,
a b 2 Z ).”
[a] = the set f ,a 2, a 1, a, a + 1, a + 2, g.
“Integers a and b have the same residue modulo m.” (for a
given m > 1)
[a] = the set f ,a 2m, a m, a, a + m, a + 2m, g.
Discrete Mathematics
Chapter 8 Relations
8.5 Equivalence Relations
Partitions
De…nition
A partition of a set A is the set of all the equivalence classes
fA1 , A2 , . . . g for some e.r. on A.
Example
Let m 2 Z+ . For any a, b 2 Z, we de…ne aRb i¤ m j a b. Then,
R is an e.r., and f[0] , [1] , , [m 1]g is a partition of Z for R.
The Ai ’s are all disjoint and their union is equal to A.
They “partition” the set into pieces. Within each piece, all
members of the set are equivalent to each other.
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Partial Orderings
De…nition
A relation R on a set S is called a partial ordering or partial order
if it is re‡exive, antisymmetric, and transitive. A set S together
with a partial ordering R is called a partially ordered set, or poset,
and is denoted by (S, R ).
The “greater than or equal” relation is a partial ordering on
the set of integers.
The divisibility relation j is a partial ordering on the set of
positive integers.
The inclusion relation is a partial ordering on the power set
of a set S.
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Total Orderings
De…nition
If (S, 4) is a poset and every two elements of S are comparable, S
is called a totally ordered set or linearly ordered set, and 4 is called
a total order or a linear order. A totally ordered set is also called a
chain.
E.g., (N, ).
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Lexicographic Order
(A1 , 41 ) and (A1 , 42 ) are posets. For any
(a1 , a2 ), (b1 , b2 ) 2 A1 A2 , we say (a1 , a2 ) 4 (b1 , b2 ) if and
only if a1 41 b1 or both a1 = b1 and a2 42 b2 .
The lexicographic order of the Cartesian product of posets is a
partial order.
Please prove this by yourself.
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Hasse Diagrams
Digraphs for …nite posets can be simpli…ed by following ideas.
1 Remove loops at every vertices.
2 Remove edge that must be present because of the transitivity.
3 Arrange each edge so that its initial vertex is below its
terminal vertex.
4 Remove all the arrows.
The simpli…ed diagrams are called Hasse diagrams.
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Example of Hasse Diagrams
P
P
P
P
P
P P
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Example of Hasse Diagrams (Cont.)
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Maximal and Minimal Elements
De…nition
a is a maximal (resp., minimal) element in the poset (S, 4) if
there is no b 2 S such that a b (resp., b a).
De…nition
a is the greatest (resp., least) element of the poset (S, 4) if b 4 a
(resp., a 4 b) for all b 2 S.
Lemma
Every …nite nonempty poset (S, 4) has a minimal element.
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Maximal and Minimal Elements (Cont.)
De…nition
A is a subset of of a poset (S, 4).
u 2 S is called an upper bound (resp., lower bound) of A if
a 4 u (resp., u 4 a) for all a 2 A.
x 2 S is called the least upper bound (resp., greatest lower
bound) of A if x is an upper bound (resp., lower bound) that
is less than every other upper bound (resp., lower bound) of A.
De…nition
(S, 4) is a well-ordered set if it is a poset such that 4 is a total
ordering and every nonempty subset of S has a least element.
E.g., (Z+ , ) is well-ordered but (R, ) is not.
There is "well-ordered induction".
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Lattices
De…nition
A partially ordered set in which every pair of elements has both a
least upper bound and a greatest lower bound is called a lattice.
i h
g f
e d
c b
a
Example
Determine whether the posets (f1, 2, 3, 4, 5g , j) and
(f1, 2, 4, 8, 16g , j) are lattices.
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Topological Sorting
Motivation: A project is make up of 20 di¤erent tasks. Some
tasks can be completed only after others have been …nished.
How can an order be found for these tasks?
Topological sorting: Given a partial ordering R, …nd a total
ordering 4 such that a 4 b whenever aRb. 4 is said
compatible with R.
Discrete Mathematics
Chapter 8 Relations
8.6 Partial Orderings
Topological Sorting for Finite Posets
procedure topological_sort(S: …nite poset)
k := 1
while S 6= ?
begin
ak := a minimal element of S
S : = S f ak g
k := k + 1
end {a1 , a2 , , an is a compatible total ordering of S}