Relations: Operations & Properties

Slides:



Advertisements
Similar presentations
Partial Orderings Section 8.6.
Advertisements

Relations Relations on a Set. Properties of Relations.
Discussion #27 Chapter 5, Sections /15 Discussion #27 Closures & Equivalence Relations.
Basic Properties of Relations
1 Relations: The Second Time Around Chapter 7 Equivalence Classes.
Relations binary relations xRy on sets x  X y  Y R  X  Y Example: “less than” relation from A={0,1,2} to B={1,2,3} use traditional notation 0 < 1,
Discussion #26 Chapter 5, Sections /15 Discussion #26 Binary Relations: Operations & Properties.
Discrete Mathematics Lecture#11.
Partially Ordered Sets (POSets)
Relations Chapter 9.
Chapter 9 1. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing.
Relations: Operations & Properties. Power Sets Set of all subsets of a set A. –A = {1,2} –P(A) = 2 A = { {}, {1}, {2}, {1,2} } We note that each element.
Exam 2 Review 8.2, 8.5, 8.6, Thm. 1 for 2 roots, Thm. 2 for 1 root Theorem 1: Let c 1, c 2 be elements of the real numbers. Suppose r 2 -c 1.
Exam 2 Review 7.5, 7.6, |A1  A2  A3| =∑|Ai| - ∑|Ai ∩ Aj| + |A1∩ A2 ∩ A3| |A1  A2  A3  A4| =∑|Ai| - ∑|Ai ∩ Aj| + ∑ |Ai∩ Aj ∩ Ak| - |A1∩
Relations (1) Rosen 6 th ed., ch. 8. Binary Relations Let A, B be any two sets. A binary relation R from A to B, written (with signature) R:A↔B, is a.
Chapter 9. Chapter Summary Relations and Their Properties Representing Relations Equivalence Relations Partial Orderings.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
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.
2.6 Equivalence Relation §1.Equivalence relation §Definition 2.18: A relation R on a set A is called an equivalence relation if it is reflexive, symmetric,
Chapter 9. Section 9.1 Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
8.3 Representing Relations Directed Graphs –Vertex –Arc (directed edge) –Initial vertex –Terminal vertex.
Sets Define sets in 2 ways  Enumeration  Set comprehension (predicate on membership), e.g., {n | n  N   k  k  N  n = 10  k  0  n  50} the set.
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Chapter 8 Relations 歐亞書局.
Relations and their Properties
Sets and Subsets Set A set is a collection of well-defined objects (elements/members). The elements of the set are said to belong to (or be contained in)
Relations. Important Definitions We covered all of these definitions on the board on Monday, November 7 th. Definition 1 Definition 2 Definition 3 Definition.
Discrete Mathematics Lecture # 15 Types of Relations (contd.)
Problem Statement How do we represent relationship between two related elements ?
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Unit II Discrete Structures Relations and Functions SE (Comp.Engg.)
Representing Relations Using Matrices A relation between finite sets can be represented using a zero-one matrix Suppose R is a relation from A = {a 1,
Chapter Relations and Their Properties
Relations Section 9.1, 9.3—9.5 of Rosen Spring 2012
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
Set Theory Concepts Set – A collection of “elements” (objects, members) denoted by upper case letters A, B, etc. elements are lower case brackets are used.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Chap. 7 Relations: The Second Time Around
Binary Relations Definition: A binary relation R from a set A to a set B is a subset R ⊆ A × B. Example: Let A = { 0, 1,2 } and B = {a,b} {( 0, a), (
Section 9.3. Section Summary Representing Relations using Matrices Representing Relations using Digraphs.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 41 May 7, 2008.
Section 9.1. Section Summary Relations and Functions Properties of Relations Reflexive Relations Symmetric and Antisymmetric Relations Transitive Relations.
Chapter8 Relations 8.1: Relations and their properties.
1 Partial Orderings Epp, section Introduction An equivalence relation is a relation that is reflexive, symmetric, and transitive A partial ordering.
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.
Relations Chapter 9 Copyright © McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill.
Equivalence Relations: Selected Exercises
Relations and Their Properties
Chapter 5 Relations and Operations
CSE 2813 Discrete Structures
Unit-III Algebraic Structures
Partial Orders.
Partial Orderings CSE 2813 Discrete Structures.
CSE15 Discrete Mathematics 05/03/17
Relations Binary relations represent relationships between the elements of two sets. A binary relation R from set A to set B is defined by: R  A 
Equivalence Relations
Relations Chapter 9.
Partial Orderings.
Relations and Digraphs
Dr. Ameria Eldosoky Discrete mathematics
CSNB 143 Discrete Mathematical Structures
CS201: Data Structures and Discrete Mathematics I
Sungho Kang Yonsei University
Formal Definition and Examples
Relations.
교환 학생 프로그램 내년 1월 중순부터 6월 초 현재 학부 2,3 학년?
Equivalence Relations: Selected Exercises
Relations: The Second Time Around
Relations 12/7/2019.
Presentation transcript:

Relations: Operations & Properties

Binary Relation R = { (x, y): x  A and y  B } (R is a set) We may also write R: A  B R  AB If (x,y)  R, we say that x is R-related to y; we may also write xRy Example: <: NN (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) }

Representations for Binary Relations < -1 1 2 Tables -1 1 2 Matrices Graphs - directed graph or digraph - directed arcs 2 1 -1

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

Inverse If R: AB, then the inverse of R is R~: BA. 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 >

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).

Composition Let R:AB and S:BC be two relations. The composition of R and S, denoted by RS, 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:AB and S:BC, 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: RS = {(1,4), (4,1)} SR = {(3,2), (2,3), (2,1)} (i.e. not commutative) R(SR) = {(1,2), (4,3), (4,1)} (RS)R = {(1,2), (4,3), (4,1)} (i.e. is associative) R S Graphically: 1234 12345 1234

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 RS 1  = 1 RS(1,1) = (10)(01)(10)(00)(00) = 0 RS = {(1,4), (4,1)}

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}

Properties of Binary Relations Properties of binary relations on a set R: AA 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

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”

Symmetry (S) xy(xRy  yRx) E.g., =, “sibling” (always both ways) 1 3 2 (always both ways) Asymmetry 1 3 2 (never both ways) asymmetric  irreflexive

Antisymmetry (AS) xy(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

Transitivity (T) xyz(xRy  yRz  xRz) E.g., <, “ancestor”, “taller” if and (for every x, y, z) x y z then Note: xRy  yRz corresponds to x(RR)z, which is equivalent to x(R×R)z = xR2z; thus we can define transitivity as: xyz(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)

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 2 3  = R R R2  R Transitive 3 1 2 3 1 2 3 2 1 1 2 3  = R R R2  R Not Transitive

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?

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)

Closures & Equivalence Relations

Closure Closure means adding something until done Normally adding as little as possible until some condition is satisfied Least fixed point similarities

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)

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~ = xy(xRy  yRx)

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 xy, yz  xz; since, if we also have vx, we must have vz, 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.)

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 RR2R3 =

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 RR2R3 = Paths of any length 2 3

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

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

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} }

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

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, …}

All Partitions Are Equivalence Relations Theorem: If {S1, …, Sn} is a partition of S, then R:SS 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

All Equivalence Relations Are Partitions Theorem: If R:SS 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 (jk) 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.

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.

Partial Orders

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} 

Partial Order Definitions (Poset Definitions) A relation R: SS 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: SS is called a strict partial order if it is irreflexive, antisymmetric, and transitive. 1 2 3

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} 

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} 

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).

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

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 .

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.