Sei sulla pagina 1di 9

Relations

Discrete Mathematics 1

Cartesian Product

The Cartesian product of sets A and B is denoted A×B and defined as follows:

A×B ={(x,y): xA and yB} A={1,3,5,7}, B={2,4,6} A×B={(1,2),(1,4),(1,6),(3,2),(3,4),(3,6),

(5,2),(5,4),(5,6),(7,2),(7,4),(7,6)}

Relations and Sets

Relations are sets of pairs (tuples)

20
Notation R(x,y)
means (x,y)∈R
10
10
20
R={(x,y):10≤x≤20, 10≤y≤20, y≤x}

Relation: Subset of Cartesian Product

All relations are subsets of a Cartesian product.

If RA×A we say R

is a relation on A

A relation can be

specified by listing pairs or defining a predicate.

A

20

10

R
10
A 20
Relations:Graph and Matrix
Representations
Bath
Access Relation
London
B
Ba
L
P
E
Bristol
B
 1
1
1
1
1 
Ba
0
1
0
0
0
Exeter
Plymouth
L
0
1
1
1
1
Directed Graph
P
 0
1
1
1
1
E
0
1
1
1
1

Inverse Relations

Given a relation RA×B then R -1 B×A such that:

R -1 ={(y,x):(x,y)R} R={(x,y):x<y} defined on natural numbers R -1 ={(x,y):x>y}

Examples of Relations

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

cat
dog
rat
bird

Reflexive

Symmetric

Special Relations

Identity relation: I A A×A I A ={(a,a):a A} Universal relation: U A A×A U A ={(a,b):a A, b A} A={1,2,3} I A ={(1,1),(2,2),(3,3)} U A ={(1,1),(2,2),(3,3),(1,2),(1,3),(2,1),(

2,3),(3,1),(3,2)}

Equivalence Relations

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

Example

A={1,2,3,4,5,6}, RA×A

R={(x,y):xA,yA,(x-y) is divisible by 2} Show that R is an equivalence relation Equivalence classes:

[1]={1,3,5}

[2]={2,4,6} What is the intuitive meaning of this equivalence

Partition of A

Equivalence Classes

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

A Logic Example

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

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

Other Equivalence 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)

48
6

Example: Partial Ordering

2

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

3 9
18

Order Relations

Some RA×A 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: Logic

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

Transitive:

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

{a,b}

Hasse Diagrams

{a,b,c}
{b,c}
{a,c}
{a}
{b}
{c}

• Omit all links that can be

inferred from transitivity.

• Omit all loops

• Understand that all arrows would point upwards

Example: Subsets

{a,b,c}
{a,b}
{a,c}
{b,c}
{a}
{b}
{c}

is a partial ordering on P(A)

E.g. A={a,b,c}

The directed graph is very messy!

Incomparable Elements

8

4

2

10
6
9
3 5

Hasse diagram for divisibility

,10}

on {2,3,

7

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

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.

5

4

3

2

Max/Min Examples
{a,b,c}
t
t
t
10
8
t 6
9
4
t
{a,b}
{a,c}
t,b
5
3
7
2
b
b
{a}
{b}
{c}
b
b

Maximal and Minimal Elements

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

Upper and Lower Bounds

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 Example:

Consider the partial order “is a factor of” on the set

A={3,9,12,15,36,45,180}
180
36
9
12
3

45

15

Meet=greatest common

divisor

Join=least common

multiple

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

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

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 RR +

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

Examples of Closure:2

R Reflexive Closure
1
1
2
3
2
3
Symmetric Closure
1
2
3

Examples of Closure

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

Composition of Relations

R be a relation on A×B and S be a relation on B×C. The composition S ° R is a relation on A×C defined by S ° R={(x,z):(x,y)R and (y,z)S for some yB}

S ° R(x,z)
C
A
B
S(y,z)
x R(x,y)
z
y

Example of a Composition

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

Example of Transitive Closure

A={1,2,3} and R={(1,1),(1,2),(1,3),(3,1),(2,3)} R 2 ={(1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(2,1)} RR 2 ={(1,1),(1,2),(1,3),(2,3),(3,1),(3,2),(3,3),(2,1),} RR 2 R 3 ={(1,1),(1,2),(1,3),(3,1),(2,3),(3,2),(3,3),(2,1)

,(2,2)}

R

1
2
3
R +
1
2
3

Transitive Closure

Let R 2 = R ° R, R 3 = R ° R ° R etc Transitive closure is:

R + =RR 2 R 3 R k Where R k is the smallest value such that R + is transitive