330 likes | 1.22k Views
Discrete Math for CS. Binary Relation Exercise:. If R = { (a,b): a < b}. Show R on the diagram below.. . . A. B. . . . . . . . . 8. 6. 4. 2. 1. 3. 5. 7. . . . . . . . . . . . . . . . . Discrete Math for CS. Binary Relations as Sets of Ordered Pairs:. Because we mention one set before another in a Cartesian Product, A x B, the element, (a,b), in any relation, R, over A and B must have its first element from A and its second element from B.So we say that the elements of R form ordered pairs..
E N D
1. Discrete Math for CS Binary Relation: A binary relation between sets A and B is a subset of the Cartesian Product A x B. If A = B we say that the relation is a relation on A.
Suppose A = {1, 3, 5, 7} and B = {2, 4, 6, 8}.
Further suppose R = { (1,2), (3,4), (5,6), (7,8)}. This is a subset of A x B so is a binary relation between A and B
2. Discrete Math for CS
3. Discrete Math for CS Binary Relations as Sets of Ordered Pairs: Because we mention one set before another in a Cartesian Product, A x B, the element, (a,b), in any relation, R, over A and B must have its first element from A and its second element from B.
So we say that the elements of R form ordered pairs.
4. Discrete Math for CS Exercise: If X = {1, 2, 3, 4, 5, 6}, find R = { (x,y): x is a divisor of y}
5. Discrete Math for CS Graph Representation of a Binary Relation: If A and B are two finite sets and R is a binary relation between A and B we can represent this relation as a graph (set of vertices and edges).
6. Discrete Math for CS Example: A = {1, 2, 3, 4, 5, 6}. R is a relation on A defined by the following directed graph.
7. Discrete Math for CS Matrix Representation of a Binary Relation: If A and B are finite sets and R is a binary relation between A and B then create a matrix, M, with the following properties:
the rows of the matrix are indexed by the elements of A
the columns of the matrix are indexed by elements of B
M(ai,bj) = 1 if (ai,bj) belongs to R; 0 otherwise
8. Discrete Math for CS Notation: If R is a binary relation on a set, X, we write x R y whenever (x,y) e R.
9. Discrete Math for CS RelationProperties: Suppose R is a relation on a set A.
We say
R is reflexive if a R a for all a e A.
R is symmetric if x R y ==> y R x for all x, y e A.
R is antisymmetric when (x R y and y R x ==> x == y) for all x, y e A.
R is transitive when (x R y and y R z ==> x R z) for all x, y, z e A.
10. Discrete Math for CS Understanding Relations as Ordered Pairs: R is reflexive if (x,x) e R for all x e A.
R is symmetric if when (x,y) e R then (y,x) e R for all x,y e A.
R is antisymmetric if when (x,y) e R and x != y then (y,x) e R.
R is transitive if when (x,y) e R and (y,z) e R then (x,z) e R
11. Discrete Math for CS Understanding Relations as digraphs. If R is a relation represented as a di-graph then
R is reflexive if every node has a loop to itself attached.
R is symmetric if every directed edge is directed in both directions.
R is antisymmetric if there is no bi-directional edge.
If there is a directed edge from x to y and another from y to z then there is a directed edge from x to z
12. Discrete Math for CS Understanding Relations as Matrices: Given a binary relation R on a finite set X.
Let M be the matrix whose rows and columns are indexed by the elements of X.
R is reflexive if the elements on the leading diagonal are all 1(T).
R is symmetric if the matrix is symmetric about the main diagonal.
R is antisymmetric if there are no symmetrical elements. Hence if mij == 1 the mji != 1.
The text says transitivity is not readily apparent. We'll see!
13. Discrete Math for CS Exercise: Evaluate the following relations for the previously mentioned properties:
x divides y on the natural numbers
x != y on the integers.
x is the same age as y in the set of all people.
a/b has the same value as c/d in the set of all rationals, Q.
14. Discrete Math for CS The Closure of a Relation: Suppose R is a relation on a set A. Then R A x A.
If R does not possess a relation property P, say being reflexive, then there exists another relation R* on A with the three properties
R R*
R* possesses the desired property.
If any other relation, say R', satisfies 1) and 2) then R* R'.
We call R* the closure of R with respect to the property P on the set A.
15. Discrete Math for CS Example: A = {1, 2, 3} and R is the relation {(1,1),(1,2),(1,3),(3,1),(2,3)}.
Find the closure of R with respect to the reflexive property.
16. Discrete Math for CS Equivalence Relation: A relation R on a set A that is reflexive, symmetric and transitive is said to be an equivalence relation.
Equivalence relations generalize the concept of equality.
Exercise: Show = is an equivalence relation.
Exercise: Show a/b has the same value as c/d in the set of all rationals, Q is an equivalence relation.
Exercise: Show has the same angles is an equivalence relation on the set of all triangles.
Exercise: Show that x R y if xy > 0 for all x, y e R.
Exercise: Give a name to the relation R in the previous exercise.
17. Discrete Math for CS Equivalence Relations and Partitions: The examples on the previous slide show there is a strong relationship between equivalence relations and partitions.
A partition is a set of non-empty subsets A1, A2, ... of a set A such that
A1 U A2 U ... = A
Ai Aj = O for every pair i, j where i != j.
We call each Ai a block of the partition.
18. Discrete Math for CS Example:
19. Discrete Math for CS Equivalence Class: If R is an equivalence relation on a set E, then
20. Discrete Math for CS
21. Discrete Math for CS Theorem: Let R be an equivalence relation on a set A, then the equivalence classes of R form a partition of A.
Proof: All equivalence classes are non-empty subsets of A. This is because for every x e A, xRx and so x e Ex.
22. Discrete Math for CS Proof (cont): So
23. Discrete Math for CS Proof (cont): We are left having to prove the second part of the definition of a partition. Namely that any two equivalence classes that are not equal are disjoint.
24. Discrete Math for CS Proof (cont): Suppose
25. Discrete Math for CS Example: Let R be a relation on R satisfying xRy iff x y is an integer. Show R is an equivalence relation and find the equivalence classes [0], [] and [sqrt(2)].
26. Discrete Math for CS Partial Orders: A binary relation on a set A that is reflexive, anti-symmetric and transitive is called a partial order and the set is called a partially ordered set with respect to the relation or a poset for short.
Partial orders allow elements to preceed one another but not necessarily.
Examples:
subsets of a set are ordered partially
27. Discrete Math for CS Partial Orders: Example:
subsets of a set are ordered partially
28. Discrete Math for CS Partial Orders: Example:
is a divisor of in the set of natural numbers.
29. Discrete Math for CS Posets: A set on which a partial order is defined is called a poset.
If R is a partial order on a set A and xRy we say that x is a predecessor of y and y is a successor of x.
An element of A can have many pedecessors but if xRy and there is no z such that xRz and zRy we say x is an immediate predecessor of y (written x ? y).
We use a Hasse Diagram to represent immediate predecessors.
The vertices of a Hasse Diagram represent the elements of A and if they are directly connected then the lower vertex is the immediate predecessor of the upper vertex.
30. Discrete Math for CS Example: Let A = {1,2,3,6,12,18}. Let R be the relation is a divisor of.
R is reflexive (a is a divisor of a), anti-symmetric (a is a divisor of b and b is a divisor of a implies a == b) and transitive (a is a divisor of b and b is a divisor of c implies a is a divisor of c).
R is a partial order.
31. Discrete Math for CS Total Order: A total order is a partial order in which every two elements of the set are related. Hence if a, b ? A, either aRb or bRa.