Download presentation
Presentation is loading. Please wait.
1
Partial Order Relations
Lecture 50 Section 10.5 Wed, Apr 20, 2005
2
Antisymmetry A relation R on a set A is antisymmetric if for all a, b A, (a, b) R and (b, a) R a = b. This is equivalent to (a, b) R and a b (b, a) R.
3
Examples: Antisymmetry
The following relations are antisymmetric. a b, on Z+. A B, on (U). x y, on R. A B = A, on (U). f(x)g(x) = f(x) on the set of all functions from R to R.
4
Partial Order Relations
A relation R on a set A is a partial order relation if R is reflexive. R is antisymmetric. R is transitive. We use as the generic symbol for a partial order relation.
5
Examples: Partial Order Relations
The following relations are partial order relations. a b, on Z+. A B, on (U). x y, on R. Is the relation f(x)g(x) = f(x) on functions a partial order relation?
6
Lexicographic Order Given a finite set of symbols, let them be listed in a specific order. For example, a < b < c. Let S be the set of all finite strings over the set of symbols. Then we may define the lexicographic order relation on S.
7
Lexicographic Order Let s, t S and let s = a1a2…am and t = b1b2…bn.
Then s t if s = , or |s| |t| and ai = bi, for all 1 i m, or There exists k 1 with k m and k n and ai = bi for all 1 i < k, but ak < bk.
8
Lexicographic Order The first condition says that s for all strings s S. The second condition says that s is no longer than t and all of s matches the first part of t. The third condition says that s and t differ at some common position.
9
Lexicographic Order Theorem: The lexicographic order relation is a partial order. Proof: Reflexive: Obvious (?) Antisymmetric: Suppose s t and t s for some s, t S. There are potentially 9 combinations of reasons for this.
10
Lexicographic Order Maybe both are true because of the first condition. Then s = and t = , so s = t. Maybe both are true because of the second condition. Then |s| |t| and |t| |s|, implying that s and t have the same length. But also s matches “the first part” of t and t matches “the first part” of s. Therefore, s = t. The second and third conditions are incompatible. Etc.
11
Lexicographic Order Transitivity:
Suppose that s t and t u, for some s, t, u S. There are potentially 27 combinations of reasons for this. (!!!) Maybe s = and t = . Then s u. Etc.
12
Hasse Diagrams A Hasse diagram is a drawing that represents a partial order relation. Draw a diagram in which a b is represented by a b. a is drawn below b. If there exists c such that a c and c b, then we represent only a c and c b; a b is implied by transitivity.
13
Example: Hasse Diagram
Let the relation be on ({a, b, c}). {a, b, c} {a, b} {a, c} {b, c} {a} {b} {c} {}
14
Example: Hasse Diagram
Let the relation be on {1, 2, 3, 4, 6, 12} 12 6 4 2 1 3
15
Example: Partial Order Relation
Let F be the set of all functions f : R+ R+. Let E be the set of equivalence classes [f] of F, under the equivalence relation f ~ g if f(x) is (g(x)). Define on E by [f] [g] if f(x) is O(g(x)).
16
[f] [g] is Well Defined
First, we must show that is well defined on E. Let f1, f2 [f] and g1, g2 [g]. Then f1~ f2 and g1 ~ g2. To show that is well defined, we must show that if [f1] [g1], then [f2] [g2], meaning that it does not matter which function we select to represent the class.
17
[f] [g] is Well Defined
So suppose that [f1] [g1]. Then f2(x) is O(f1(x)), and f1(x) is O(g1(x)) and g1(x) is O(g2(x)). So, f2(x) is O(g2(x)). Therefore, [f2] [g2].
18
Example: Partial Order Relation
Theorem: is a partial order relation on E. Proof: Reflexivity It is clear that [f] [f] . (Use M = 1, x0 = 0.)
19
Example: Partial Order Relation
Antisymmetry Suppose that [f] [g] and [g] [f] . Then f(x) is O(g(x)) and g(x) is O(f(x)). Then f(x) is (g(x)). Therefore, f ~ g. Therefore, [f] = [g].
20
Example: Partial Order Relation
Transitivity Suppose that [f] [g] and [g] [h]. Then f(x) is O(g(x)) and g(x) is O(h(x)). We have already shown that this implies that f(x) is O(h(x)). Therefore, [f] [h]. Thus, is a partial order relation on E.
21
Comparable Elements and Total Orders
Given a partial order on a set A, two elements a, b A are comparable if a b or b a. A partial order relation is a total order relation if any two elements are comparable under that relation.
22
Total Order Relations Which of the following partial orders are total orders? x y, on R. A B, on (U). a b, on Z+.
23
Total Order Relations Define [f] [g] to mean f(x) is O(g(x)). Is this a total order relation on the set of equivalence classes of functions? Which are total orders on R R. (a, b) (c, d) if a c and b d. (a, b) (c, d) if a c or b d. (a, b) (c, d) if a + b c + d. (a, b) (c, d) if a < c or (a = c and b d).
24
Example: Total Ordering and Sorting
In order to sort the list {(2, 3), (3, 3), (3, 2), (2, 2)}. it is necessary that be a total ordering of the Point class. If is not a total order relation, then the results of any sorting algorithm are unpredictable. Why?
25
Example: Total Ordering and Sorting
Define a Point object to consist of two doubles. class Point { double x; double y; };
26
Example: Total Ordering and Sorting
Define operator<() on the Point class as follows. Then define operator<=() to mean that a < b or a == b. bool operator<(const Point& p, const Point& q) { if (p.x != q.x) return p.x < q.x; else return p.y < q.y; }
27
C Library Functions There are two standard library functions, bsearch() and qsort(), that perform a binary search and a quicksort on an array, respectively. For each function, one parameter is a function compare(a, b) that returns < 0 if a < b = 0 if a == b > 0 if a > b
28
C Library Functions Those three requirements are not sufficient to guarantee that operator<=() is a total order relation. It is the programmer’s responsibility to be sure that it is. Otherwise, neither bsearch() nor qsort() is guaranteed to work properly.
29
Chains of Elements Let a partial order be defined on a set A.
A subset B A is called a chain if any two elements of B are comparable. That is, is a total order on B (although not on A).
30
Chains of Elements Find a chain of subsets in ({a, b, c}) under the subset relation. What is the longest possible chain? Find a chain of integers in Z+ under the divides relation.
31
Maximal and Greatest Elements
Let A be a partially ordered set under . An element a A is a maximal element if, for all b A, either b a or a and b are not comparable. An element a A is a greatest element if, for all b A, b a.
32
Example Let A = {1, 2, 3, …, 20} and let the relation be a b.
Are there any maximal elements? If so, what are they? Are there any greatest elements?
33
Example Let B = {1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60} and let the relation be a b. Are there any maximal elements? If so, what are they? Are there any greatest elements?
34
Maximal and Greatest Elements
Must maximal elements be exist? Must greatest elements be exist? If maximal elements exist, must they be unique? If greatest elements exist, must they be unique?
35
Minimal and Least Elements
Minimal and least elements are similar to maximal and greatest elements, respectively. An element a A is a minimal element if, for all b A, either a b or a and b are not comparable. An element a A is a least element if, for all b A, a b.
36
Examples What are the minimal and least elements (if any) of the sets
B = {1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60} under the relation a b?
37
Compatible Order Relations
Let 1 and 2 be partial order relations defined on a set A. We call 2 compatible with 1 if, whenever a 1 b, it is also the case that a 2 b. In other words, a, b A, a 1 b a 2 b.
38
Topological Sorting Given a partial order relation 1 defined on a set A, a topological sorting for 1 is a total order relation 2 that is compatible with 1. For example, the ordinary “less than or equal to” relation is a topological sorting for the “divides” relation because is a total order, and If a b, then a b.
39
Application: Computer Graphics
In the “old days,” a difficult problem in computer graphics was to draw the objects of a scene in such a way that when two objects were on the same line of sight, the closer object obscured the farther object. One solution was the Painter’s Algorithm: sort the shapes from front to back, and then draw them from back to front.
40
Application: Computer Graphics
Define the relation a 1 b on the shapes to mean that shape a hides part of shape b. Define the relation a 2 b on the shapes to mean that shape a is closer to the viewer than is shape b. Clearly, 2 is a topological sorting for 1.
41
Application: Computer Graphics
Therefore, the Painter’s Algorithm was to Determine which shapes hide which shapes (relation 1). Find a topological sorting for 1 (relation 2). Draw the shapes in reverse order according to the total ordering 2 .
42
Example Consider the following scene, with the viewpoint inside the house, looking out at the tree.
43
Example The scene might be rendered like this:
44
Topological Sorting Theorem: If A is a finite set with a partial order 1 defined on it, then there exists a topological sorting for 1. The proof is the following algorithm. A partially ordered finite set must have a minimal element. Let x0 be a minimal element of A. Let A1 = A – {x0}.
45
Topological Sorting A1 is again a partially ordered finite set, so it must have a minimal element. Let x1 be a minimal element of A1 and define A2 = A1 – {x1}. Continue in this manner, defining x3, x4, x5, and so on, until no elements remain. Then define 2 as follows: xi 2 xj if and only if i j.
46
Example Let A = {1, 2, 3, …, 10} under the “divides” relation. 8 10 9
4 6 2 3 5 7 1
47
Example Let x0 = 1 and remove 1 from the set. 8 10 9 4 6 2 3 5 7
48
Example Let x1 = 7 and remove 7 from the set. 8 10 9 4 6 2 3 5
49
Example Let x2 = 5 and remove 5 from the set. 8 10 9 4 6 2 3
50
Example Let x3 = 3 and remove 3 from the set. 8 10 9 4 6 2
51
Example Let x4 = 9 and remove 9 from the set. 8 10 4 6 2
52
Example Let x5 = 2 and remove 2 from the set. 8 10 4 6
53
Example Let x6 = 10 and remove 10 from the set. 8 4 6
54
Example Let x7 = 6 and remove 6 from the set. 8 4
55
Example Let x8 = 4 and remove 4 from the set. 8
56
Example Let x9 = 8 and remove 8 from the set.
57
Example The total ordering is 1, 7, 5, 3, 9, 2, 10, 6, 4, 8.
This ordering is compatible with the divide relation. A number of the choices were arbitrary, so there are many other topological sortings for the divide relation on this set.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.