<<

Partial Orders Strict Orders Equivalence Relations Sections 6.7-6.9 Prof. Sandy Irani Partial Orders

A binary R on a A is a partial if R is: • Reflexive • Anti-Symmetric • Transitive Notation: x, y ∈ A, xRy ↔ x ≼ y

Standard example: (ℤ, ≤) x is related to y if x ≤ y Reflexive? Anti-symmetric? Transitive? Partial Orders + Another example: (ℤ , ≼푝) + + n For x, y ∈ ℤ , x ≼푝 y if there is an n ∈ ℤ such that x = y

Relfexive?

Anti-Symmetric?

Transitive? Incomparable Elements

Another example: ({2, 4, 8, 64}, ≼푝) + + n For x, y ∈ ℤ , x ≼푝 y if there is an n ∈ ℤ such that x = y

4 4 ≼푝8? 2 64 8 ≼푝 4?

8 4 and 8 are incomparable

Two elements, x and y, in a partial order are incomparable if x ⋠ y and y ⋠ x Incomparable Elements

What about (ℤ, ≤)? Are any two elements incomparable? 4 ≤ 8? 8 ≤ 4? 4 ≤ 4?

A partial order (A, ≼) is also a total order if for every x, y ∈ A, x ≼ y or y ≼ x.

+ (ℤ , ≼푝) is not a total order Partial Orders/Total Orders

Relation R on the set {0,1}5 is defined as follows. For every x, y ∈ {0,1}5 x is related to y if y can be obtained by taking x and changing zero or more 0’s to 1’s.

Examples: Partial Orders/Total Orders

Relation R on the set {0,1}5 is defined as follows. For every x, y ∈ {0,1}5 x is related to y if y can be obtained by taking x and changing zero or more 0’s to 1’s.

Reflexive?

Anti-symmetric?

Transitive? Total Order? Prefix

A string x is a prefix of a string y if y can be obtained by adding zero or more characters to the end of x.

Consider {a, b}* (the set of all strings over the alphabet {a, b}.)

Examples: Partial Orders/Total Orders *

Relation R on the set {a, b}* is defined as follows. For every x, y ∈ {a, b}* xRy if x is a prefix of y

Select the correct description of R.

A) Partial Order C) Total Order and a Total Order but not a Partial Order

B) Partial Order D) Neither a Total Order but not a Total Order nor a Partial Order Partial Orders/Total Orders

Relation R on the set {a, b}* is defined as follows. For every x, y ∈ {a, b}* xRy if x is a prefix of y

Reflexive?

Anti-symmetric?

Transitive? Total Order? Partial Orders/Total Orders * Relation R on the set of players on a football team. For every two players, x and y on the team, xRy if y weighs at least as much as x (Big team, so can assume that here are all possible height/weight combinations)

Select the correct description of R.

A) Partial Order C) Total Order and a Total Order but not a Partial Order

B) Partial Order D) Neither a Total Order but not a Total Order nor a Partial Order Partial Orders/Total Orders Relation R on the set of players on a football team. For every two players, x and y on the team, xRy if y weighs at least as much as x

Reflexive?

Anti-symmetric?

Transitive? Total Order? Partial Orders/Total Orders Relation R on the set of players on a football team. For every two players, x and y on the team, xRy if y weighs at least as much as x (No two players on the team have the same weight)

Reflexive?

Anti-symmetric?

Transitive? Total Order? Hasse Diagrams

Hasse Diagrams are a clean way to depict a partial order.

If x ≼ y, then x appears below y. (Converse not necessarily true)

A line between x and y if x ≼ y and there is no z such that x ≼ z and z ≼ y Hasse Diagrams

If x ≼ y, then x appears ( {2, 4, 8, 16, 32, 64}, ≼푝) below y. (Converse not necessarily true)

A line between x and y if x ≼ y and there is no z such that x ≼ z and z ≼ y Maximal/Minimal Elements in a Partial Order x is a maximal element ( {2, 4, 8, 16, 32, 64}, ≼푝) if there is no y such that 64 x ≼ y 16 x is a minimal element 8 32 4 if there is no y such that y ≼ x 2 Maximal elements:

Minimal elements: Hasse Diagrams * g e Which pair of elements are not comparable? a c A) b and e b B) f and e d f C) b and c

D) b and g Hasse Diagrams

The Hasse diagram for a total order is just a chain: ( {1, 2, 3, 4, 5}, ≤ ) 5 4 3 2

1 Strict Orders

A R on a set A is a strict order if R is: • Anti-Reflexive • Anti-Symmetric • Transitive Notation: x, y ∈ A, xRy ↔ x ≼ y

Standard example: (ℤ, <) x is related to y if x < y Anti-Reflexive? Anti-symmetric? Transitive? Strict vs. Partial Orders

Partial Order Strict Order

4 4 2 64 2 64

8 8

For x, y ∈ ℤ, x ≼푝 y For x, y ∈ ℤ, x ≼푝 y if there is an n, if there is an n, n ∈ ℤ+ n ∈ ℤ+, n > 1 and xn = y and xn = y Strict Orders A binary relation R on a set A is a strict order if R is: • Anti-Reflexive • Transitive

If a relation R is anti-reflexive and transitive, then R is also anti-symmetric.

[ (Anti-Reflexive) ᴧ (Transitive) ] → (Anti-Symmetric)

Contrapositive:

[¬(Anti-Symmetric) ᴧ (Transitive) ] → ¬(Anti-Reflexive) [¬(Anti-Symmetric) ᴧ (Transitive) ] → ¬(Anti-Reflexive)

Proof: Anti-symmetric means you never have this pattern:

¬(Anti-Symmetric) means that you do have this pattern Somewhere:

If the relation is transitive, then you also have:

Which means that the relation is not Anti-Reflexive. □ Strict Orders A binary relation R on a set A is a strict order if R is: • Anti-Reflexive • Transitive

A strict order is also a total order if for every x, y if x ≠ y then xRy or yRx (i.e. every distinct pair of elements in the are comparable.) Partial Orders/Total Orders *

Relation R on the set {0,1}8 is defined as follows. For every x, y ∈ {0,1}8 if y contains more 1’s than x.

Select the correct description of R.

A) Strict Order C) Total Order and a Total Order but not a Strict Order

B) Strict Order D) Neither a Strict Order but not a Total Order nor a Partial Order Partial Orders/Total Orders

Relation R on the set {0,1}8 is defined as follows. For every x, y ∈ {0,1}8 if y contains more 1’s than x.

Anti-Reflexive?

Anti-symmetric?

Transitive? Total Order? Partial Orders/Total Orders Relation R on a of people. For every x, y in the group, xRy if y is taller than x.

Select the correct description of R.

Anti-Reflexive?

Anti-symmetric?

Transitive? Total Order?

Precedence Relationships Strict orders are useful for representing precedence relationships

Vertices: set of tasks Relation: task x must be completed before task y begins.

Prerequisite structure for some ICS/CS classes:

ICS 31 ICS 32 ICS 33

ICS 51 CS 151 CS 152 ICS 6B ICS 6D

Prerequisite are represented by a directed graph with no cycles which is not necessarily transitive. Directed Acyclic Graphs (DAGs)

A directed graph is acyclic if it does not have any positive length cycles. is a cycle of length 0. (no edges) is a cycle of length 1. v DAGs and Precedence Constraints

Graph representing prerequisite structure must be a DAG G. Course x must be taken before course y ↔ (x,y) is in the transitive closure of G.

Theorem: G is a (DAG) if and only if G+ is a strict order. Topological Sort of a DAG

A topological sort of a DAG G is an ordering of the vertices such that for every edge (u,v) in G, u comes before v in the ordering.

ICS 31 ICS 32 ICS 33

ICS 51 CS 151 CS 152 ICS 6B ICS 6D

Note: there can be more than one topological sorts for a graph. Topological Sorts *

Which ordering is not a valid topological sort for the graph given below:

d a f e

b c

A) f, d, a, c, b, e C) f, b, d, a, e, c

B) f, c, d, b, a, e Topological Sorts

To find a topological sort, keep removing vertices that are minimal (in-degree 0) d a f e

b c Equivalence Relations

A binary relation R is an if R is: • Reflexive • Symmetric • Transitive Notation: if xRy then x ~ y

a d e

c b f Equivalence Relation Example

Domain: ℤ For x, y ∈ ℤ, x ~ y if x-z is an multiple of 5 (x - z = 5k for k ∈ ℤ)

Here is the arrow diagram for the relation on a restricted, : {-4, -1, 2, 6, 7, 8, 19, 21, 27}

27 19 -1 6

7 8 2 21 -4 Equivalence Relation Example

Domain: ℤ For x, y ∈ ℤ, x ~ y if x-z is an integer multiple of 5 (x - z = 5k for k ∈ ℤ)

Reflexive:

Symmetric

Transitive: Equivalence Relation Example

Domain: group of people For x, y in the group, x ~ y if x and y have the same birthday

Reflexive:

Symmetric

Transitive: Equivalence Relations *

Domain is a group of people: Relation R: xRy if x and y have the same first name or same last name. Q: xQy if x and y have the same first name and same last name.

Which statement is correct?

A) Q and R are both C) R is an equivalence equivalence relations relation but Q is not

B) Q is an equivalence D) Neither a Q nor R relation but R is not are equivalence relations Equivalence Classes

If x is in the domain of an equivalence relation: [x] = {y: x ~ y} [x] is the equivalence class for x.

The set of distinct equivalence classes of an equivalence relation form a partition of the domain.

How many equivalence classes are there for the birthday equivalence relation? …as many as… Equivalence Classes

Domain: ℤ For x, y ∈ ℤ, x ~ y if x-z is an integer multiple of 5 (x - z = 5k for k ∈ ℤ)

Equivalence classes?