Download presentation
Presentation is loading. Please wait.
1
Relations: Operations & Properties
2
Binary Relation R = { (x, y): x A and y B } (R is a set)
We may also write R: A B R AB If (x,y) R, we say that x is R-related to y; we may also write xRy Example: <: NN (where N is the set of natural numbers) (2,3) < or 2<3 Predicates also define relations <: {0,1,2}{1,0,1,2} = {(x,y) | x {0,1,2} y {1,0,1,2} x < y} = { (0,1), (0,2), (1,2) }
3
Representations for Binary Relations
< -1 1 2 Tables -1 1 2 Matrices Graphs - directed graph or digraph - directed arcs 2 1 -1
4
Domains and Ranges for Binary Relations
Let R = {(0,1), (0,2), (1,2)}, then Domain of R = dom R = dom(R) = {x | y((x,y) R)} i.e. {0,1} like XR Range of R = ran R = ran(R) = {y | x((x,y) R)} i.e. {1,2} like YR 2 1 -1 Range Space Domain Space Domain Range
5
Inverse If R: AB, then the inverse of R is R~: BA.
R-1 is also a common notation R~ is defined by {(y,x) | (x,y) R}. If R = {(a,b), (a,c)}, then R~ = {(b,a), (c,a)} > is the inverse of < on the reals Note that R~ ~R The complement of < is But the inverse of < is >
6
Set Operations Since relations are sets, set operations apply (just like relational algebra). The arity must be the same indeed, the sets for the domain space and range space must be the same (just like in relational algebra).
7
Composition Let R:AB and S:BC be two relations. The composition of R and S, denoted by RS, contains the pairs (x,z) if and only if there is an intermediate object y such that (x,y) is in R and (y,z) is in S. Given R:AB and S:BC, with A = {1,2,3,4}, B = {1,2,3,4,5}, C = {1,2,3,4}, and R = {(1,3), (4,2), (1,1)} and S = {(3,4), (2,1), (4,2)}, we have: RS = {(1,4), (4,1)} SR = {(3,2), (2,3), (2,1)} (i.e. not commutative) R(SR) = {(1,2), (4,3), (4,1)} (RS)R = {(1,2), (4,3), (4,1)} (i.e. is associative) R S Graphically: 1234 12345 1234
8
Composition & Matrix Multiplication
Relation matrices only contain 0’s and 1’s. For relational matrix multiplication, use for *, for +, with 1=T and 0=F. 1 4 3 2 5 R 5 1 4 3 2 S 4 3 2 1 RS 1 = 1 RS(1,1) = (10)(01)(10)(00)(00) = 0 RS = {(1,4), (4,1)}
9
Combined Operations All operations we have discussed can be combined so long as the compatibility requirements are met. Example: R = {(1,1), (3,1), (1,2)} S = {(1,1), (2,3)} (R S)~ R = {(1,1), (3,1), (1,2), (2,3)}~ R = {(1,1), (1,3), (2,1), (3,2)} R = {(1,1), (1,2), (2,1), (2,2)} R: A B S: B A A = {1,2,3} B = {1,2,3}
10
Properties of Binary Relations
Properties of binary relations on a set R: AA help us with lots of things groupings, orderings, … Because there is only one set A: matrices are square |A| |A| graphs can be drawn with only one set of nodes R = {(1,3), (4,2), (3,3), (3,4)} 1 4 3 2 1 3 2 4
11
Reflexivity (R) x(xRx) E.g., =, , “is in same major as”, etc.
Reflexive 1 3 2 Note: Irreflexive Neither 3 2 1 1 3 2 e.g., < e.g., “loves”
12
Symmetry (S) xy(xRy yRx) E.g., =, “sibling” (always both ways)
1 3 2 (always both ways) Asymmetry 1 3 2 (never both ways) asymmetric irreflexive
13
Antisymmetry (AS) xy(xRy yRx x = y) E.g., , , = Notes:
Can be both symmetric and antisymmetric (e.g., =) Can be neither symmetric nor antisymmetric (e.g., “loves”) Antisymmetry is NOT asymmetry
14
Transitivity (T) xyz(xRy yRz xRz)
E.g., <, “ancestor”, “taller” if and (for every x, y, z) x y z then Note: xRy yRz corresponds to x(RR)z, which is equivalent to x(R×R)z = xR2z; thus we can define transitivity as: xyz(xR2z xRz) “If I can get there in two steps, then I can get there in one.” Formally: if (x,z)R2, then (x,z)R (x,z)R2 (x,z)R R2 R (def. of subset)
15
Examples R R R2 R R R R2 R 1 2 3 = 1 2 3 = 1 1 1 Transitive 1
3 2 1 3 2 1 3 2 1 = R R R2 R Transitive 3 1 2 3 1 2 3 2 1 1 = R R R2 R Not Transitive
16
Practice Exercises (I)
PE1 Consider the set A={a,b,c,d}. Give an example of a relation on A that is neither symmetric nor antisymmetric PE2 Consider the relation "is mother of". Is this relation reflexive? Is it symmetric? Is it transitive? Is it antisymmetric? PE3 Consider the relation "takes a class with". Is this relation reflexive? Is it symmetric? Is it transitive? Is it antisymmetric?
17
Practice Exercises (II)
PE1 Which of reflexive, symmetric, antisymmetric and transitive are properties of the empty relation? PE2 T or F : If R is transitive then R is symmetirc. (Justify your answer) PE3 A relation R is asymmetric if whenever (x,y) is in R then (y,x) is not in R (or, equivalently, xRy -> not yRx). T or F : A relation can be both symmetric and asymmetric. (Justify your answer)
18
Closures & Equivalence Relations
19
Closure Closure means adding something until done
Normally adding as little as possible until some condition is satisfied Least fixed point similarities
20
Reflexive Closure Reflexive closure of a relation: R(r) x (xRx)
smallest reflexive relation that contains R (i.e. fewest pairs added) R(r) = R IA (R is a relation on a set A, and IA is the identity relation 1’s on the diagonal and 0’s elsewhere.) 1 3 2 1 3 2 R = R(r) = x (xRx)
21
Symmetric Closure Symmetric closure of a relation: R(s)
smallest symmetric relation that contains R (i.e. fewest pairs added) R(s) = R R~ (R~ is R inverse) 1 3 2 1 3 2 1 3 2 R = R~ = R R~ = xy(xRy yRx)
22
Transitive Closure Transitive closure of a relation: R(t) = R+
smallest transitive relation that contains R (i.e. fewest pairs added) for each path of length i, there must be a direct path. (This follows from xy, yz xz; since, if we also have vx, we must have vz, a path of length 3.) R(t) = R R2 R3 … R|A|. (No path can be longer than |A|, the number of elements in A.)
23
Transitive Closure – Example 1
3 2 1 R = All paths of length 1 2 3 1 3 2 1 All paths of length 2 R2 = 2 3 1 3 2 1 R×R2 = R3 = All paths of length 3 2 3 1 3 2 RR2R3 =
24
Transitive Closure – Example 2
1 3 2 1 R = All paths of length 1 2 3 1 3 2 1 R2 = All paths of length 2 2 3 1 3 2 1 R×R2 = R3 = All paths of length 3 2 3 1 3 2 1 RR2R3 = Paths of any length 2 3
25
Reflexive Transitive Closure
Reflexive transitive closure of a relation: R* smallest reflexive and transitive relation that contains R R* = IA R+ = R0 R+ = R0 R1 R2 …R|A| Example: 1 3 2 1 3 2 IA = R0 = R1 R2 R3 = 1 3 2 1 R0 R1 R2 R3 = 2 3
26
Equivalence Relations
R, S, T Equivalence relations are about “equivalence” Examples: = for integers x = x reflexive x = y y = x symmetric x=y y=z x=z transitive = for sets A = A reflexive A = B B = A symmetric A=B B=C A=C transitive “has same major as” for college students same major as self reflexive same major as each other symmetric same as, same as same as transitive
27
Partition (I) A set of subsets Si=1,2,…n of S, such that:
ni=1 Si = S Sj Sk = for j k Each Si is called a block (or equivalence class) Example: Suppose we form teams (e.g., for a doubles tennis tournament) from{Abe, Kay, Jim, Nan, Pat, Zed} Teams could be: { {Abe, Nan}, {Kay, Jim}, {Pat, Zed} }
28
Partition (II) Since individual elements can only appear in one block (Sj Sk = for j k), blocks can be represented by any element within the block E.g., Nan’s Team Jenny’s Family Formally, [x] = set of all elements related to x, and y [x] iff xRy E.g., [Nan] represents {Abe, Nan}, Nan’s team [Jenny] represents the members of Jenny’s family
29
Example The mod function partitions the natural numbers as follows:
0 mod 3 = 0 so 0 forms a class [0] 1 mod 3 = 1 so 1 forms new class [1] 2 mod 3 = 2 so 2 forms new class [2] 3 mod 3 = 0 so 3 belongs to [0] 4 mod 3 = 1 so 4 belongs to [1] 5 mod 3 = 2 so 5 belongs to [2] 6 mod 3 = 0 so 6 belongs to [0] … The mod function creates 3 partitions or equivalence classes: [0] = {0, 3, 6, …} [1] = {1, 4, 7,…} [2] = {2, 5, 8, …}
30
All Partitions Are Equivalence Relations
Theorem: If {S1, …, Sn} is a partition of S, then R:SS is an equivalence relation, where R is “in same block as.” Proof: To prove that R is an equivalence relation, we must prove that R is reflexive, symmetric, and transitive: Reflexive: every element is in the same block as itself Symmetric: if x is in the same block as y, then y is clearly in the same block as x Transitive: if x and y are in the same block and y and z are in the same block, x and z are also in the same block
31
All Equivalence Relations Are Partitions
Theorem: If R:SS is an equivalence relation and [x] = { y | xRy }, then { [x] | x S } is a partition P of S. Proof: To prove that we have a partition, we must prove (1) that every element of S is in a block of P, and (2) that for every pair of distinct blocks Sj and Sk (jk) of P, Sj Sk = : (1) Since R is reflexive, xRx, every element of S is at least in its own block and thus in some block of P (2) Suppose Sj Sk for distinct blocks Sj and Sk of P. Then, at least one element y is in both Sj and Sk. Let Sj = {y, x1, … xn} and Sk = {y, z1, … zm}, then yRxi, i=1, 2, …, n, and yRzp, p=1, 2, …, m. Since R is symmetric, xiRy, and since R is transitive xiRzp. But now, since the elements of Sj are R-related to the elements of Sk, x1, …, xn, y, z1, …, zm are together in a block of P and thus Si and Sk are not distinct blocks of P.
32
Practice Exercises PE1 Show that the relation ”has the same birthday as" (e.g., John has the same birthday as Jenny) is an equivalence relation PE2 Show that the four suits (spades, hearts, diamonds, clubs)form a partition of a deck of playing cards (excluding the Joker). What is the corresponding equivalence relation? PE3 Is the relation “attends Church with” (e.g., Kathy attends Church with Laurel) an equivalence relation? Justify your answer.
33
Partial Orders
34
Partial Orders Total orderings: single sequence of elements Partial orderings: some elements may come before/after others, but some need not be ordered Examples of partial orderings: “must be completed before” “set inclusion, ” foundation framing plumbing wiring finishing {a, b, c} {a, b} {a, c} {b, c} {a} {b} {c}
35
Partial Order Definitions (Poset Definitions)
A relation R: SS is called a (weak) partial order if it is reflexive, antisymmetric, and transitive. e.g. on the integers 1 2 3 e.g. < on the integers A relation R: SS is called a strict partial order if it is irreflexive, antisymmetric, and transitive. 1 2 3
36
Total Order A total ordering is a partial ordering in which every element is related to every other element. (This forces a linear order or chain.) Examples: 1 2 3 4 5 R: on {1, 2, 3, 4, 5} is total. Pick any two; they’re related one way or the other with respect to . R: on {{a, b}, {a}, {b}, } is not total. We can find a pair not related one way or the other with respect to . {a} & {b}: neither {a} {b} nor {b} {a} {a,b} {a} {b}
37
Hasse Diagrams We produce Hasse Diagrams from directed graphs of relations by doing a transitive reduction plus a reflexive reduction (if weak) and (usually) dropping arrowheads 1) Transitive reduction discard all arcs except those that “directly cover” an element. 2) Reflexive reduction discard all self loops. For we write: {b} {a} {a, b} Important: Efficiency, simplicity, always reproduce the original {a, b} {a} {b}
38
Upper and Lower Bounds If a poset is built from relation R on set A, then any x A satisfying xRy is an upper bound of y, and any x A satisfying yRx is a lower bound of y. Examples: If A = {a, b, c} and R is , then {a, c} - is an upper bound of {a}, {c}, and . - is also an upper bound of {a, c} (weak poset). - is a lower bound of {a, b, c}. - is also a lower bound of {a, c} (weak poset).
39
Maximal and Minimal Elements
If a poset is built from relation R on set A, then y A is a maximal element if there is no x such that xRy, and x A is a minimal element if there is no y such that xRy. (Note: We either need the poset to be strict or x y.) In a Hasse diagram, every element with no element “above” is maximal, and every element with no element “below” it is minimal. Maximal elements Minimal elements
40
Least Upper and Greatest Lower Bounds
A least upper bound of two elements x and y is a minimal element in the intersection of the upper bounds of x and y. A greatest lower bound is a maximal element in the intersection of the lower bounds of x and y. Examples: For , {a, c} is a least upper bound of {a} and {c}, is a greatest lower bound of {a} and {b, c}, and {a} is a least upper bound of {a} and .
41
Practice Exercises PE1 Show that the relation “is divisible by” (defined over the real numbers) is a partial order PE2 Is the logic relation “implies” (e.g., A implies B, or A->B) a partial order? Justify your answer.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.