chapter 7 relations : the second time around yen-liang chen dept of information management national...

57
Chapter 7 Chapter 7 Relations : the Relations : the second time second time around around Yen-Liang Chen Yen-Liang Chen Dept of Information Management Dept of Information Management National Central University National Central University

Post on 19-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Chapter 7 Chapter 7 Relations : the Relations : the second time second time

around around Yen-Liang Chen Yen-Liang Chen

Dept of Information ManagementDept of Information ManagementNational Central UniversityNational Central University

Page 2: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

7.1. Relations revisited: 7.1. Relations revisited: properties of relations properties of relations

• Definition 7.1. For sets A, B, any subset of AB is called a (binary) relation from A to B. Any subset of AA is called a binary relation on A .

Page 3: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

ExamplesExamples• Ex 7.1

– Define the relation on the set Z by ab, if ab.

– For x, yZ and nZ+, the modulo n relation is defined by xy if x-y is a multiple of n.

• Ex 7.2: For x, y A, define xy if x is a prefix of y.

Page 4: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Ex 7.3.Ex 7.3.• s1s2 if v(s1,x)=s2. Here, denotes the first level

of reachability.• s1s2 if v(s1,x1x2)=s2. Here, denotes the secon

d level of reachability.• 1-equivalence relation: s1E1s2 if w(s1,x)=w(s2,x) f

or xIA. • k-equivalence relation: s1Eks2 if w(s1,x)=w(s2,x) f

or xIAk. • equivalence relation: if two states are k-equiva

lent for all k.

Page 5: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

reflexive reflexive • Definition 7.2. A relation on a set A is called r

eflexive if for all xA, (x, x).• Ex 7.4. For A={1, 2, 3, 4}, a relation AA will

be reflexive if and only if {(1, 1), (2, 2), (3, 3), (4, 4)}.

• Ex 7.5. Given a finite set A with A=n, we have AA=n2, so there are relations on A. Among them, is reflexive.

2

2n

)( 2

2 nn

Page 6: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

symmetric symmetric • Definition 7.3. A relation on a set A is called s

ymmetric if (x, y) (y, x) for all x, yA.• Ex 7.6. With A={1, 2, 3}, what properties do the

following relations have? 1={(1, 2), (2, 1), (1, 3), (3, 1)} 2={(1, 1), (2, 2), (3, 3), (2, 3)} 3={(1, 1), (2, 2), (3, 3)} 4={(1, 1), (2, 2), (2, 3), (2, 3), (3, 2)} 5={(1, 1), (2, 3), (3, 3)}

Page 7: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

symmetricsymmetric• To count the symmetric relations on A={a1, a2,…, an}.• AA=A1A2, where A1={(a1, a1),…, (an, an)} and A2={(ai, a

j)ij}.• A1 contains n pairs, and A2 contains n2-n pairs.• A2 contains (n2-n)/2 subsets Si,j of the form {(ai, aj), (aj, a

i)ij}.• So, we have totally symmetric relations on

A.• If the relations are both symmetric and reflexive, we h

ave choices.

))(2/1( 2

22 nnn

))(2/1( 2

2 nn

Page 8: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

transitive transitive • Definition 7.4. A relation on a set A is called t

ransitive if (x,y), (y,z) (x,z) for all x, y, zA.

• Ex 7.8. Define the relation on the set Z+ by ab if a divides b. This is a transitive and reflexive relation but not symmetric.

• Ex 7.9. Define the relation on the set Z by ab if ab0. What properties do they have?

Page 9: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

anti-symmetric anti-symmetric • Definition 7.5. A relation on a set A is called a

nti-symmetric if (x, y) and (x, y) x=y for all x, yA.

• Ex 7.11. Define the relation (A, B) if AB. Then it is an anti-symmetric relation.

• Note that “not symmetric” is different from anti-symmetric.

• Ex 7.12. What properties do they have? ={(1, 2), (2, 1), (2, 3)} ={(1, 2), (2, 2)}

Page 10: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

anti-symmetricanti-symmetric• To count the anti-symmetric relations on A={a1,

a2,…, an}.– AA=A1A2, where A1={(a1, a1),…, (an, an)} and A2={(ai, aj)ij}.– A1 contains n pairs, and A2 contains n2-n pairs.– A2 contains (n2-n)/2 subsets Si,j of the form {(ai, aj), (aj, ai)ij}.– Each element in A1 can be selected or not.– Each element in Si,j can be selected either one or none.– So, we have totally anti-symmetric relations on A.

• Ex 7.13. Define the relation on the functions by f g if f is dominated by g (or fO(g)). What are their properties?

))(2/1( 2

32 nnn

Page 11: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

partial order relationpartial order relation• Definition 7.6. A relation is called a par

tial order, if is reflexive, anti-symmetric and transitive.

• Ex 7.15. Define the relation on the set Z+ by ab if a divides b.

Page 12: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

equivalence relation equivalence relation • Definition 7.7. A relation is called an

equivalence relation, if is reflexive, symmetric and transitive.

• Ex 7.16.(b)– If A={1, 2, 3}, the following are all equivalence

relations 1={(1, 1), (2, 2), (3, 3)} 2={(1, 1), (2, 2), (3, 3), (2, 3), (3,2)} 3={(1, 1), (1, 3), (2, 2), (3, 1), (3, 3)} 4={(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3,

1), (3, 2), (3, 3)}

Page 13: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

ExamplesExamples• Ex 7. 16(c). For a finite set A, A A is the largest

equivalence relation on A. The equality relation is the smallest equivalence relation on A.

• Ex 7.16(d). Let f: AB be the onto function. Define the relation on A by ab if f(a)=f(b).

• Ex 7. 16(e). If is a relation on A, then is both an equivalence relation and a partial order relation iff is the equality relation on A.

Page 14: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

7.2. Computer recognition: zero-one 7.2. Computer recognition: zero-one matrices and directed graphsmatrices and directed graphs

• Definition 7.8. Let relations 1AB and 2BC. The composite relation of 1

2 is a relation defined by 12={(x, z) y in B such that (x, y) 1 and (y, z) 2.

• Ex 7.17. Consider 1={(1, x), (2, x), (3, y), (3, z)} and 2={(w, 5), (x, 6)}. What is 1

2?

Page 15: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

composite relationcomposite relation• Ex 7. 18. Let A be the set of

employees at a computer center, while B denotes a set of programming language, and C is a set of projects……

• Theorem 7.1. 1(23)= (12)3

Page 16: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

the power of relation the power of relation • Definition 7.9. We define the powers

of relation by (a) 1=; (b) n+1= n

• Ex 7.19. If ={(1, 2), (1, 3), (2, 4), (3, 2)}, then what is 2 and 3 and 4.

Page 17: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

matrix representationmatrix representation• A relation can be represented by an mn zero-one m

atrix.• Ex 7.17. Consider 1={(1, x), (2, x), (3, y), (3, z)} and 2

={(w, 5), (x, 6)}. What is 12?

Page 18: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

matrix representationmatrix representation• Ex 7.19. If ={(1, 2), (1, 3), (2, 4), (3, 2)},

then what is 2 and 3 and 4.

Page 19: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

matrix representationmatrix representation• Let A be a set with A=n and be a relat

ion on A. If M() is the relation matrix for , then– M()=0 if and only if =.– M()=1 if and only if =AA.– M(m)=[M()]m

Page 20: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

less than less than

• Definition 7.11. Let E=(eij)mn F=(fij)mn be two zero-one matrices. We say that E precedes, or is less than , F, written as EF, if eij fij for all i, j.

• Ex 7.23. EF.

100

101E

110

101F

Page 21: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Identity matrix Identity matrix

I2=

10

01 I3=

100

010

001

Page 22: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Transpose of a matrix Transpose of a matrix

A=

11

00

10

Atr=

101

100

Page 23: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Theorem 7.2 Theorem 7.2 • Let M denote the relation matrix for . T

hen(A) R is reflexive if and only if InM.(B) R is symmetric if and only if M=Mtr.(C) R is transitive if and only if M2M.(D) R is anti-symmetric if and only if MMtrIn.

Page 24: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Graph representationGraph representation• Definition 7.14. A directed graph can be

denoted as G=(V, E), where V is the vertex set and E is the edge set.

• V={1,2,3,4,5}, E={(1,1),(1,2),(1,4),(3,2)}

Page 25: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Ex 7.27Ex 7.27• R={(1,1),(1,2),(2,3),(3,2),(3,3),(3,4),

(4,2)}• directed graph, undirected graph,

connected, undirected cycle, directed cycle

Page 26: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Terms in graphTerms in graph• strongly connected and loop-free • disconnected graph, components

Page 27: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

complete graphs complete graphs

Page 28: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Graph representation for a Graph representation for a relationrelation

• Ex 7.30, Fig 7.8, is reflexive if and only if its directed graph contains a loop at each vertex

• Ex 7.31, Fig 7.9, is symmetric if and only if its directed graph may be drawn only by loops and undirected edges

• Ex 7.32, Fig 7.10, is anti-symmetric if and only if for any xy the graph contains at most one of the edges (x, y) or (y, x)

• Ex 7.33, Fig 7.11, a relation is an equivalence relation if and only if its graph consists of disjoint union of complete graphs augmented by loops at each vertex

Page 29: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University
Page 30: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

7.3. Partial orders: Hasse Diag7.3. Partial orders: Hasse Diagrams rams

• Definition: Let A be a set with a relation on A. The pair (A, ) is called a partially ordered set, or poset, if relation on A is partially ordered. If A is called a poset, we understand that there is a partially order on A that makes A into this set.

Page 31: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Examples of PosetExamples of Poset• Ex 7.34. Let A be the set of courses offered at a

college. Define the relation on A by xy if x ,y are the same course or if x is a prerequisite for y.

• Ex 7.35. Define on A={1, 2, 3, 4} by xy if x divide y. Then (A, ) is a poset.

• Ex 7.36. Let A be the set of tasks that must be performed to build a house. Define the relation on A by xy if x ,y are the same task or if x must be performed before y.

Page 32: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Original graph and Hasse diagrOriginal graph and Hasse diagramam

Page 33: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Hasse DiagramHasse Diagram• If (A, ) is a poset, we construct a Hasse diagram for on A by drawing a line segment from x up to y, if– xy– there is no z such that xz and zy.

• Ex 7.38, Fig 7.18. The relation on (a) is the subset relation, while the relations on the others are the divide relations.

Page 34: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

totally ordered totally ordered • Definition 7.16. If (A, ) is a poset, we say that

A is totally ordered if for all x, y A either xy or yx. In this case, is called a total order.

• Ex 7.40.– On the set N, the relation defined by xy if xy is

a total order.– The subset relation is a partial order but not total o

rder.– Fig 7.19 is a total order.

Page 35: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University
Page 36: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Topological sorting Topological sorting • Given a Hasse diagram for a partial order re

lation , how to find a total order for which .

Page 37: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

maximal and minimal maximal and minimal • Definition 7.17. If (A, ) is a poset, then x is a m

aximal element of A if for all aA, axx a. Similarly, y is a minimal element of A if for all bA, byb y .

• Ex 7.42. – For the poset (P(U), ), U is the maximal and is th

e minimal.– Let B be the proper subsets of {1, 2, 3}. Then we hav

e multiple maximal elements for the poset (B, ).

RR

Page 38: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

ExamplesExamples• Ex 7.43. For the poset (Z, ), we have neither a

maximal nor a minimal element. For the poset (N, ), we have no maximal element but a minimal element 0.

• Ex 7.44. How about the poset in Fig. 7.18? Do they have maximal or minimal elements?

• Theorem 7.3. If (A, ) is a poset and A is finite, then A has both a maximal and a minimal element.

Page 39: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Least and greatestLeast and greatest• Definition 7.18. If (A, ) is a poset, then x is a least ele

ment of A if for all aA, xa. Similarly, y is a greatest element of A if for all aA, ay.

• Ex 7.45. – For the poset (P(U), ), U is the greatest and is the least.– Let B be the nonempty subsets of {1, 2, 3}. Then we have U as

the greatest maximal element and three minimal elements for the poset (B, ).

• Theorem 7.4. If poset (A, ) has a greatest or a least element, then that element is unique.

Page 40: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Lower bound and upper Lower bound and upper boundbound

• Definition 7.19. If (A, ) is a poset with BA, then xA is called a lower bound of B if xb for all bB. Likewise, yA is called an upper bound of B if by for all bB.

• An element xA is called a greatest lower bound of B if for all other lower bounds x of B we have xx. Similarly, an element xA is called a least upper bound of B if for all other upper bounds x of B we have xx.

• Theorem 7.5. If (A, ) is a poset and BA, then B has at most one lub (glb).

Page 41: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

ExamplesExamples• Ex 7.47. Let U={1, 2, 3, 4} with A=P(U)

and let be the subset relation on B. If B={{1}, {2}, {1, 2}}, then what are the upper bounds of B, lower bounds of B, the greatest lower bound and the least upper bound?

• Ex 7.48. Let be the “” relation on A. What are the results for the following cases?– A=R and B=[0, 1]– A=R and B={qQq2<2}– A=Q and B={qQq2<2}

Page 42: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

LatticeLattice• Definition 7.20. The poset (A, ) is called a latti

ce if for all x, yA the elements lub{x, y} and glb{x, y} both exist in A.

• Ex 7.49. For A=N and x, yN, define xy by xy. Then lub{x, y}=max{x, y} and glb{x, y}=min{x, y}. (N,) is a lattice.

• Ex 7.50. For the poset (P(U), ), if S, TU, we have lub{S, T}=ST and glb{S, T}=ST and it is a lattice.

Page 43: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

7.4. Equivalence relation 7.4. Equivalence relation and partitionsand partitions

• For any set A, the relation of equality is an equivalence relation on A.

• Let the relation on Z defined by xy if x-y is a multiple of 2, then is an equivalence relation on Z, where one contains all even integers and the other odd integers.

Page 44: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

partitionpartition• Definition 7.21. Given a set A and index s

et I, let AiA for iI. Then {Ai}iI is a partition of A if (a) A=iIAi and (b) AiAj= for ij.

• Ex 7.52, A={1,…,10}….• Ex 7.53. A partition of R

Page 45: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

equivalence class equivalence class • Definition 7.22. the equivalence class of

x, denoted [x], is defined by [x]={yAyx}

• Ex 7.54. Define the relation on Z by xy if 4(x-y).

• Ex 7.55. Define the relation on Z by ab if a2=b2.

Page 46: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

equivalence classequivalence class• Theorem 7.6. If is an equivalence relation on a set A

and x, yA, then (a) x[x]; (b) xy if and only if [x]=[y]; and (c) [x]=[y] or [x][y]=.

• Ex 7.56. – Let A={1, 2, 3, 4, 5}, ={(1, 1), (2, 2), (2, 3), (3, 2), (3, 3), (4, 4), (4,

5), (5, 4), (5, 5)}, Then, we have A=[1][2][4].– Consider an onto function f:AB. f({1, 3, 7})=x; f({4, 6})=y; f({2,

5})=z. The relation defined on A by ab if f(a)=f(b). A=[1][4][2].

• Ex 7.58. If an equivalence relation on A={1, 2, 3, 4, 5, 6, 7} induces the partition A={1, 2} {3}{4, 5, 7}{6}, what is ?

Page 47: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

TheoremsTheorems• Theorem 7.7. If A is a set, then any

equivalence relation on A induces a partition of A, and any partition of A gives rise to an equivalence relation on A.

• Theorem 7.8. For any set A, there is one-to-one correspondence between the set of equivalence relations on A and the set of partitions of A.

Page 48: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

7.5. Finite state machine: 7.5. Finite state machine: the minimization process the minimization process

• Two finite state machines of the same function may have different number of internal states.

• Some of these states are redundant.• A process of transforming a given

machine into one that has no redundant internal states is called the minimization process.

Page 49: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

1-equivalence1-equivalence• For the states S, we define the relation E

1 on S by s1E1s2 if w(s1, x)=w(s2, x) for all xI. The relation E1 is an equivalence relation on S, and it partitions S into subsets such that two states are in the same subset if they produce the same output for each xI.

Page 50: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

k-equivalencek-equivalence• For the states S, we define the k-equivalence r

elation Ek on S by s1Eks2 if w(s1, x)=W(s2, x) for all xIk. The relation Ek is an equivalence relation on S, and it partitions S into subsets such that two states are in the same subset if they produce the same output for each xIk.

• Finally, we call two states equivalent if they are k-equivalent for all k1.

Page 51: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Goal and tipsGoal and tips• Hence, our objective is to determine the partiti

on of S induced by E and to select one state for each equivalent class.

• Observations:– If two states are not 2-equivalent, they can not be

3-equivalent.– For s1, s2S, where s1Eks2, we find that s1Ek+1s2 if and

only if v(s1, x)Ekv(s2,x) for all xI.

Page 52: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

The procedure for the The procedure for the minimization minimization

1. Set k=1. We determine the states that are 1-equivalent.

2. Having determined Pk, we determine the states that are (k+1)-equivalent. Note that if s1Eks2, then s1Ek+1s2 if and only if v(s1, x)Ekv(s2,x) for all xI.

3. If Pk+1=Pk, the process is completed.

Page 53: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Ex 7.60. Ex 7.60. • the original table in Table 7.1 and P1:{s1}, {s2, s5,

s6}, {s3, s4}

• Table 7.2. P2:{s1}, {s2, s5}, {s6}, {s3, s4}, P2=P3

Page 54: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

refinementrefinement• Definition 7.23. If P1 and P2 are partitions

of set A, then P2 is called a refinement of P1, denoted as P2P1, if every cell of P2 is contained in a cell of P1. When P2P1 and P2P1, we write P2<P1.

• Theorem 7.9. In the minimization process, if Pk+1=Pk, then Pr+1=Pr for all rk+1.

Page 55: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

distinguishing string distinguishing string

• If s1Eks2 but s1Ek+1s2, then we have a string x=x1x2…xkxk+1Ik+1 such that w(s1, x)w(s2, x) but w(s1, x1x2…xk)=w(s2, x1x2…xk). We call this string as distinguishing string.

• s1Ek+1s2x1I [v(s1, x1) Ek v(s2, x1)]

Page 56: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Ex 7.61Ex 7.61• s2E1s6 but s2E2s6.

• X=00 is the minimal distinguishing string for s2 and s6

Page 57: Chapter 7 Relations : the second time around Yen-Liang Chen Dept of Information Management National Central University

Ex 7.62Ex 7.62• s1 and s4 are 2 equivalent but are not 3-

equivalent. • X=111 is the minimal distinguishing

string for s1 and s4