Você está na página 1de 9

Relations and Sets Relations

Discrete Mathematics 1

Relations are sets of pairs (tuples)


20

Notation R(x,y) means (x,y)R

10

10

20

R={(x,y):10x20, 10y20, yx}

Cartesian Product

Relation: Subset of Cartesian Product

The Cartesian product of sets A and B is denoted AB and defined as follows: AB ={(x,y): xA and yB} A={1,3,5,7}, B={2,4,6} AB={(1,2),(1,4),(1,6),(3,2),(3,4),(3,6), (5,2),(5,4),(5,6),(7,2),(7,4),(7,6)}

All relations are subsets of a Cartesian product.


20 A R 10

If RAA we say R is a relation on A A relation can be specified by listing pairs or defining a predicate.

10

20

Relations:Graph and Matrix Representations


Bath

Examples of Relations

Access Relation
London B B Exeter Ba L P E Ba L P E

Bristol

Plymouth

Directed Graph

1 0 0 0 0

1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1

A={cat,dog,rat,bird} R={(x,y):x and y have at least one common letter}


cat dog

Reflexive Symmetric

rat

bird

Inverse Relations

Special Relations
Identity relation: IA AA IA ={(a,a):a A} Universal relation: UA AA UA ={(a,b):a A, b A} A={1,2,3} IA ={(1,1),(2,2),(3,3)} UA={(1,1),(2,2),(3,3),(1,2),(1,3),(2,1),( 2,3),(3,1),(3,2)}

Given a relation RAB then R-1BA such that: R-1={(y,x):(x,y)R} R={(x,y):x<y} defined on natural numbers R-1={(x,y):x>y}

Equivalence Relations

Equivalence Classes

R(x,x) for all xA (Reflexive) R(x,y)=R(y,x) for all x,yA (Symmetric) If R(x,y) and R(y,z) then R(x,z) (Transitive)
a b d c e f

For xA [x]={yA :R(x,y)} [a]={a,b,d}=[b]=[d] [c]={c} [e]=[f] ={e,f} The equivalence classes of R partition the set A

Example

A Logic Example

A={1,2,3,4,5,6}, RAA
R={(x,y):xA,yA,(x-y) is divisible by 2} Show that R is an equivalence relation Equivalence classes: [1]={1,3,5} Partition of A [2]={2,4,6} What is the intuitive meaning of this equivalence

L={P,Q} and SL=the sentences of L RSLSL R={(A,B):AB}


[P]={P,(P),(PP),(PP),(PQ)(P Q)} How many equivalence classes are there?

Other Equivalence Relations


Order Relations

Congruence mod m on integers E.g. m=5 [1]={1,6,11,16,} Registered on the same course (on a set of undergraduate) Having the same angles (on a set of triangles)

Some RAA help us order the elements of A Partial Orderings: Reflexive (R(x,x) ) Transitive (IF R(x,y),R(y,z) then R(x,z) ) Antisymmetric (If R(x,y) and R(y,x) then x=y )

Example: Partial Ordering


2 4 8

Example: Logic

Divisibility relation on {2, 3, 4, 6, 8, 9, 18} 2|4 4|8 2|8 2|6 3|6 3|9 9|18 6|18 3|18 2|18

18

Let A,B be formulas of propositional logic AB iff ABB Eg PQ Q Idempotent: AAA Antisymmetric: Sps AB and BA then ABB and BAA. But ABBA and therefore AB

Logic: 2

Example: Subsets
{a,b,c} is a partial ordering on P(A) E.g. A={a,b,c}

Transitive: Sps AB and BC then ABB and BCC therefore C(AB)C A(BC) AC Hence ACC so that AC

{a,b}

{a,c}

{b,c}

{a}

{b}

{c}

The directed graph is very messy!

Hasse Diagrams
{a,b,c}
Omit all links that can be inferred from transitivity. Omit all loops

Incomparable Elements
8 4 2 3 6 10 9 5 Hasse diagram for divisibility on {2,3,....,10}

{a,b}

{a,c}

{b,c} Draw links without arrow heads


Understand that all arrows would point upwards

{a}

{b}

{c}

Notice that 5 and 6 are not related in either direction. Similarly for 2 and 3 If neither R(x,y) or R(y,x) then x and y are said to be incomparable

Total Orderings

Maximal and Minimal Elements

A total ordering is a partial ordering in which every pair is related. For any x,y either R(x,y) or R(y,x)

The Hasse diagram is simply a long chain.

Let (A,) be a partially ordered set and CA then A maximal element of C is any element t such that xC tx implies that x=t A minimal element of C is any element b such that xC xb implies that x=b

Max/Min Examples
{a,b,c}
t t t

Upper and Lower Bounds

8 4 2 3
b t

10

{a,b}

{a,c}

t t,b

5
b

{a}

{b}

{c}

Let (A,) be a partially ordered set and CA then u is an upper bound of C if xC xu l is a lower bound of C if xC lx lub is a least upper bound of C if for all other upper bounds x of C, lubx glb is a greatest lower bound of C if for all other lower bounds y of C, yglb

glb,lub vs min and max


Let be the standard total ordering on R Let C=[10,20] Min=10, Max=20 Lower bounds =(-,10], glb=10 Upper bounds= [20, ), lub=20 Let C=(10,20) (i.e. [10,20]-{10,20}) No Min, No Max Lower bounds =(-,10], glb=10 Upper bounds= [20, ), lub=20

Lattice

A partially ordered set (,A) is a lattice if every pair of elements {a,b} has a l.u.b and a g.l.b In this case the l.u.b of {a,b} is called the join of a and b and written ab The g.l.b of {a,b} is called the meet of a and b and written ab

Lattice Example:
Consider the partial order is a factor of on the set A={3,9,12,15,36,45,180} 180 36 9 12 45 15
Meet=greatest common divisor Join=least common multiple

Properties of Meet and Join


If ab and cd then acbd and acbd bbd (rhs is an upper bound of b) dbd (similarly) ab and cd (given) Hence, bd is and upper bound of a and c But ac is l.u.b of {a,c} therefore acbd as required

Closure of Relations

Examples of Closure

If a relation R fails to have a certain property P then it may be possible to extend R to R+ so the R+ does satisfy P R+ is an extension of R if R R+ R+ is the closure of R under P if it is an extension of R and R+ satisfies P and For any other extension R++ satisfying P R+R++

A={1,2,3} R={(1,1),(1,2),(1,3),(3,1),(2,3)} Reflexive closure: R={(1,1),(1,2),(1,3),(3,1),(2,3),(2,2),(3 ,3)} Symmetric closure: R={(1,1),(1,2),(1,3),(3,1),(2,3),(2,1),(3 ,2)}

Examples of Closure:2

Composition of Relations

R 1

Reflexive Closure 1

Symmetric Closure 1

R be a relation on AB and S be a relation on BC. The composition SR is a relation on AC defined by SR={(x,z):(x,y)R and (y,z)S for some yB}
SR(x,z)

A 2 3 2 3 x R(x,y)

B S(y,z) y z

Example of a Composition

Transitive Closure

C=set of courses E=set of engineering undergraduates D=set of departments REC R={(e,c):student e studies course c} SCD S={(c,d):course c is run by department d} SR={(e,d):student e studies a course run by department d}

Let R2= RR, R3= RRR etc Transitive closure is: R+=RR2 R3 Rk Where Rk is the smallest value such that R+ is transitive

Example of Transitive Closure


Google and Relations


A={1,2,3} and R={(1,1),(1,2),(1,3),(3,1),(2,3)} R2={(1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(2,1)} RR2={(1,1),(1,2),(1,3),(2,3),(3,1),(3,2),(3,3),(2,1),} RR2R3={(1,1),(1,2),(1,3),(3,1),(2,3),(3,2),(3,3),(2,1) ,(2,2)}


R 1 1 R+

P=set of all web pages LinksPP Links={(x,y):page x contains a link to page y} Links not symmetric, reflexive or transitive If we represent as a matrix, the sum of each column=number of links to a page This is an important component of Google page rank Much of Googles power arises from calculations on the Links relation

Você também pode gostar