19
Relations (3) Relations (3) Rosen 6 th ed., ch. 8

Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Embed Size (px)

Citation preview

Page 1: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Relations (3)Relations (3)

Rosen 6th ed., ch. 8

Page 2: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Partial orderingPartial ordering

• A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive.

• Example– ‘greater than or equal to’– ‘is a subset of’

TTT

FTT

FFT

1 2 3

1

2

3

• Greater than or equal to, on {1,2,3}

Page 3: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Example (Partial ordering)Example (Partial ordering)

• Is subset of• A ={ a, b, c} P(A) = { {}, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c} }• Partial ordering :

– 부분적으로 순서화 , {a,b} 와 {b,c} 사이에는 is-subset-of 로 순서화 할 수 없다 .

{}

{a,b,c}

{a} {b} {c}

{a.b} {a,c} {b,c}

Page 4: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Example (Partial ordering)Example (Partial ordering)• EXAMPLE 2: The divisibility relation | is a partial

ordering on the set of positive integers, because it is reflexive, antisymmetric, and transitive.

• EXAMPLE 4: Let R be the relation on the set of people

such that xRy if x and y are people and x is older than y. Show that R is not a partial ordering.Solution: No person is older than himself of herself. So this R is not reflective.

Page 5: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

ComparabilityComparability• The elements a and b of a poset (S, ≤) are called

comparable if either a ≤ b or b ≤ a. When a and b are elements of S such that neither a ≤ b nor b ≤ a are called incomparable.

• EXAMPLE 5: In the poset (Z+, |), are the integers 3 and 9 comparable? Are 5 and 7 comparable?Solution: Yes for 3 and 9, No for 5 and 7.

Page 6: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Totally Ordered RelationTotally Ordered Relation• If (S, ≤) is a poset and every two elements of S are

comparable, S is called a totally ordered or linearly ordered set, and ≤ is called total order or a linear order. A totally ordered set is also called a chain.

• EXAMPLE 6: The poset (Z+, ≤) is totally ordered because a ≤ b or b ≤ a whenever a and b are integers.

• EXAMPLE 7: The poset (Z+, |) is not totally ordered because it contains elements that are incomparable, such as 5 and 7.

Page 7: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Lexicographical orderLexicographical order,...},...,,|,...),...,,{( 221121 iii AaAaAaaaaA

ii AR each on orderinglinear a

kkkkk

kk

yRxyxk

yyyyxxxx

,such that integer smallest for the

ifonly and iforder hicallexicograpin

,...),...,,( sequence theprecedes ,...),...,,( sequence The 2121

Example : 사전의 단어 순서

ss"discreetne"discreet""

ally)alphabetic precedes ( ,

,, ,4

),,,,(

),,,,,,,,(

,order hicallexicograpin relex"" precedes relative""

eaea

yxeyaxk

xelery

evitalerx

kkkk

Page 8: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Hasse DiagramsHasse Diagrams• Start with the directed graph of a relation.– Remove loops.– Remove all edges that must be in the partial

ordering because of the presence of other edges and transitivity.

– Remove all the arrows. All edges point “upward” toward their terminal vertex.

• See Figure 2 of page 571.

Page 9: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Hasse DiagramsHasse Diagrams• EXAMPLE 12: Draw the Hasse diagram

representing the partial ordering {(a, b) | a divides b} on {1, 2, 3, 4, 6, 8, 12}=> see FIGURE 3 of page 572.

• EXAMPLE 13: Draw the Hasse diagram representing the partial ordering {(A, B) | A B} on the power set P(S) where S = {a, b, c}=> see FIGURE 4 of page 573.

Page 10: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Maximal and Minimal ElementsMaximal and Minimal Elements• An element of a poset is called maximal if it is not

less than any element of the poset. Similary, an element of a poset is called minimal if it is not greater than any element of the poset.

• EXAMPLE 14: Which elements of the poset ({2, 4, 5, 10, 12, 20, 25}, |) are maximal, and which are minimal? Solution: 12, 20, and 25 are maximal and 2 and 5 are minimal.

Page 11: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Greatest and Least ElementsGreatest and Least Elements• An element of a poset is called greatest element if

it is greater than all the other elements in the poset. Similary, an element of a poset is called least element if it is less than all the other elements in the poset.

• EXAMPLE 17: Is there a greatest element and a least element in the poset (Z+, |) ?Solution: The integer 1 is the least element because 1|n whenever n is a positive integer. Because there is no integer that is divisible by all positive integers, there is no greatest element.

Page 12: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

ExampleExample• EXAMPLE 15: Determine whether the posets

represented by following Hasse diagrams have greatest element and a least element.

g: a, l: x g: x, l: x g: d, l: x g: d, l: a

c

a

b d

c

a b

ed

c

a b

d

b c

a

d

Page 13: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Upper Bound and Lower BoundUpper Bound and Lower Bound• If u is an element of a poset (S, ≤) such that a ≤ u

for all elements a A(A S), then u is called an upper bound of A. Likewise, if l is element of a poset (S, ≤) such that l ≤ a for all elements a A(A S), then l is called an lower bound of A.

• EXAMPLE 18: Find the lower and upper bounds of the subsets {a, b, c}, {j, h}, and {a, c, d, f} in the poset with the Hasse diagram shown in Figure 7.

Page 14: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

ExampleExampleSolution:

{a, b, c}: u-b is e, f, j, and h. l-b is a.

{j, h}: no u-b. l-b is a, b, c, d, e, and f. {a, c, d, f}: u-b is f, h, and j. l-b is a. Fig. 7.

f

jh

g

e

bc

a

d

Page 15: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Upper Bound and Lower Bound Cont.Upper Bound and Lower Bound Cont.• The element x is called the least upper bound of

the subset A if x is an upper bound that is less than every other upper bound of A. Similarly, the element y is called the greatest lower bound of the subset A if y is a lower bound that is greater than every other lower bound of A.

• EXAMPLE 19: Find the greatest lower bound and the least upper upper bound of {b, d, g}, if they exist, in the poset shown in Fig. 7.Solution: g and b.

Page 16: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

LatticesLattices• 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.

• EXAMPLE 22: Is the poset (Z+, |) a lattice?Solution: a 와 b 를 두 정수라 하자 . 이 두 정수의 최소공배수와 최대공약수가 각각 최소상한계와 최대하한계이므로 , 이 poset 은 격자이다 .

Page 17: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

cb

d e

f

a

ExampleExample• EXAMPLE 21: 아래 하세 도표들로 표현되는 부분 순서

집합들이 격자 (lattice) 인지 판별하시오 .

(a) (b) (c)

– (a), (c) 는 격자 , (b) 는 b 와 c 가 최소상한계를 가지지 않으므로 격자가 아니다 . d, e, f 가 이들의 상한계이지만 , 이들 중 어느 것도 나머지 둘 보다 모두 작지는 않다 . (Information flow 에 활용 )

– Study EXAMPLE 23.

f

dcb

e g

h

a

e

a

c d

b

f

Page 18: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Topological SortingTopological Sorting• A total ordering is said to be compatible with the

partial ordering R if a ≤ b whenever aRb. Constructing a compatible total ordering from a partial ordering is called topological sorting.

• EXAMPLE 26: Find a compatible total ordering for the poset ({1, 2, 4, 5, 12, 20}, |).Solution: 1 < 5 < 2 < 4 < 20 < 12.

• Study EXAMPLE 27.

Page 19: Relations (3) Rosen 6 th ed., ch. 8. Partial ordering A relation R is a partial ordering if it is reflexive, antisymmetric, and transitive. Example –

Algorithm for Topological SortingAlgorithm for Topological SortingALGORITHM Topological SortingProcedure topological sort((s, ≤): finite poset)k := 1while S ≠ Фbegin

ak := a minimal element of S S := S – {ak}k := k + 1

end {a1, a2, …, an is a compatible total ordering of S}