Professional Documents
Culture Documents
Week 2 Relations
Week 2 Relations
→
Sequence : list of things in a certain order .
braces E) '
instead of 471 .
→ Order matters
→
repeated occurrences do matter .
tuple
→ 2-
tuple also called ordered
pairs .
→ A ✗ B- -
{ Cny ) / n C- A and
y C-
B }
A ✗ B has ordered A and B
→
pairs from
e. g
A =
{ 1,2 } B =
{ a ,b, c
} G-
{ 0 ☐
, }
A ✗ BXC =
{ ( 1
,
a
,
☐
1,1 ,
a
,☐ ) , (2%0) ,
12,9 ☐)
,
(1) b) b) ( ,
1
,
b , ☐) ( 2 b , G) 12
, , ,
b,☐) ( 1,48,
, ,
(1) C ☐) , (2) C) D)
,
, (2) C , D) {
Binary Relations
sets A and B relation from A to
→ For
,
a
binary B
4- R is written
as a ☒ b.
[ can also do R ( as b) and 7 Rca b)J ,
Relations on a set
→ a relation from set A b- A itself is called a relation on
A
→
essentially a relation on A is a subset of A ✗ A .
e-
9
< =
{ Coe, ) C-
y 2- ✗ z / n is smaller than y }
C- 1
,
0 ) C- <
(5) 2) ¢ <
Representing relations
→ e.
g
A = ( 1
,
2,3 , 4)
Relation of A =
9 ( 1,1 ) (127,1133%4) 131112,21
, ,
,
(2) 4), 13,3) }
can be represented as
f. •?
directedgraph.ly#.P
also relations using
→
can
represent 0-1 matrix
I 2 3 4
does not
%!%%a%?µ!!
" are
3
4
µ ,
00
00
I
000
↓ I
i
of matter but . row and column must
Properties of relations
→
Relation R on set A is a reflexive if (a) a) ER for
ever# a c- A ( one reflexive
non
in reflexive)
is
enough 6- make it
.
R
e. g -
all elements a. b EA
→ A relation
R is
symmetric if for , D-
e-
g Re
{ ( 1,1 ) , (2
, 2) (3) 3) , { is
symetréc .
9
→
antisymmetric can also be antisymmetric
(opposite of symmetric symmetric is enough 6- make anti
lone non
←9
R -41,3 ) ( 2,3) , ( 1,27 }
-
,
symmetric )
Transitivity
→
if both la b) ,
ER and ( b c)
,
ER then
( a. c) ER
→ In a directed graph R is transitive if every
,
k z → w
Not transitive
g
- -
x z → w Not transitive
y
- -
[Ézw
-✓
Transitive
2-
every
as
step journey is
covered .
Transitive closure
→
let R be a relation on set A
The transitive closure of R is the smallest transitive
relation on A containing R
it is denoted
→
by R* then R=R*)
( If R is already transitive
Recursive if fa , b) ER
*
and ( b , c) c- R* then
Ca , c) C- R*
e.g
*
R R
N# 2-
: → w :
- -
- -
-
- -
nE ? -7¥
→ what order will we add the transitive elements
Warshall 's
Algorithm
Algorithm A finite sequence of precise step by step
→
:
instructions
the matrix of transitive closure
→ Warshall's Algorithm computes
:
R* of R
→ Given Relation R on
a a set A with n elements
we
begin with an nxn matrix Mo
→
There are n rounds where in
every
round we
change the
matrix some rules
using
↳ M Me Mn
Mo ,
. _ .
.
→
Mn is the transitive closure relation
→
Rule No .
1 : Never change the Is
i
; k
TE☆ unit I
'
-1
k I
Mk -1 Mk
relation
e.
g let R be a on set A
{ a. b. Sdl
R =/ ( a
,
d) , lb a) ( , ,
b
, c) / ↳ a)
, ,
Cec d) Cd c) /
, , ,
=\ : :|
•
I 0 I 0
Round I
④:- / :: :)
°
I 0 0 I
- mi 1 0 1 4
,
00 I O
O O I 0
→
skip to round 4
mil : : :
I
I 0
0 I
I
1
:|
1
Equivalence Relation
→ A relation R on a set A is an equivalence relation
if it is
1) Reflexive
2)
and
Symmetric
3) Transitive
→
e.g { & , g) C- 2- ✗ Z
/ x -
y is divisible
by 41
Partial Order
→ if relation R on set A is
D Reflexive
2) anti
symmetric
3) Transitive
order
e. g
≤ is a
partial
Hasse Diagram
→
Only for partial orders
→
since we know
they are reflexive ,
we can assume it and not
draw loops
since know
they transitive we can
ignore making
→
we are
,
→ since we it is /all
antisymmetricheads arrows
go one way) ,
Linear Orders
(b) a) C- R
Antisymmetric Not
Antisymmetric
→
Nopoinblome →
somepointscomeinpairs
in pairs
Transitive Not Transitive
There isasstep journey
→
every
2-
step path →
lhateannotbedanein
canbedoneintstep 1- step .