Relations a b graph(

advertisement
Binary relation R from A to B
codomain
domain
A
B
Mathematics for Computer Science
MIT 6.042J/18.062J
Relations
a1
L4-1.1
September 9, 2005
Example
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
L4-1.2
September 9, 2005
6.003
Sqrt(9)
5
6.012
50/10 - 3
2
L4-1.3
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
Example
Cities
Cities
Boston
Boston
Providence
Providence
Providence
New York
New York
New York
“direct bus
connection”
September 9, 2005
“evaluates to”
1+2
September 9, 2005
Cities
values
6.042
Example
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
b3
graph(R)
Arithmetic
Expressions
Classes
“is taking”
Boston
b2
Example
Students
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
b1
a2
a3
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
R
L4-1.5
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
3
L4-1.4
“direct bus
connection”
September 9, 2005
L4-1.6
1
Relation Abstraction
A
(Binary) Relation:
a
domain = set A
a
a
codomain = set B
graph = subset of A × B
Relation Abstraction
Relation on A:
domain = set A
codomain = set A
B
R
1
b1
2
b2
3
b3
A
a1
a2
R
a3
graph = {(a1,a1), (a1,a3),(a3,a3)}
graph(R) = { (a1 , b1 ), (a1 , b3 ), (a3 , b3
) }
A× B = { (a1 , b1 ), (a1 , b2 ), (a1 , b3 )
(a2 , b1 ), (a2 , b2 ), (a2 , b3 )
(a3 , b1 ), (a3 , b2 ), (a3 , b3 ) }
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
L4-1.7
September 9, 2005
Types of Binary Relations on A
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.8
Equivalence Relations
• Equivalence (mod 4): •Equivalence
•Partial Orders
1 ≡ 5 (same remainder/4)
• Propositional equivalence:
P ∧Q ≡ P ∨Q
(same truth table)
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
L4-1.9
September 9, 2005
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.10
Def. of Equivalence on Set A
Equivalence Relations
• Equivalent code (compilers):
x:=1;x:=x+1 ≡ x:=2
(same effect)
There is a function, f, on A such that
?
a R b iff f(a) = f(b)
• Rubik’s cube equivalence
≡
(same reachability group)
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.11
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.12
2
Equivalence Relations
Hash Functions
How to map a large address space
into a smaller address space?
• Equivalence (mod 4):
1 ≡ 5 (same remainder/4)
Large
Large set
set of
of
addresses
addresses
f(x) = x mod 4
h
Small
Small
address
addressspace
space
So no collisions occur?
h( name1 ) = h( name2 )
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.13
h( name1 ) = h( name2 )
Athena assigns user directories
based on the
first two letters of a username:
rab & raej in r/a/
Collides with is an
equivalence relation
(on addresses in large space)
September 9, 2005
L4-1.14
Athena Equivalence
Hash Collision Equivalence
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
L4-1.15
September 9, 2005
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
L4-1.16
Athena Equivalence
Same User Directory
• Names with
same first 2 letters:
Ben ≡ Betty
• f(name) = first two letters
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005. All rights reserved.
September 9, 2005
L4-1.17
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.18
3
Partitions
Athena Partition
Theorem: An equivalence
relation partitions its domain
into collections of equivalent
elements called
• All names starting with "aa"
• All names starting with "ab"
• All names starting with "ac"
equivalence classes.
• All names starting with "zz"
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
#
26 × 26 equivalence classes
L4-1.19
Some properties of relations:
Relation R on set A is
Reflexive:
if aRa for all a ∈ A.
Symmetric:
if aRb → bRa for all a,b ∈ A.
Transitive:
if [aRb ∧ bRc] → aRc for all a,b,c ∈ A.
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.21
Equivalence Relation Properties
Theorem:
R is an equivalence relation
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.20
Equivalence Relation Properties
Equivalence Relation R on set A is
Reflexive: aRa
Symmetric: aRb → bRa
Transitive: [aRb ∧ bRc] → aRc
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.22
Team Problems
Problems 1 & 2
iff it is
Reflexive, Symmetric,
& Transitive
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.23
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.24
4
Ordering Relations
•
•
•
•
Partial Orders
≤ on the Integers
< on the Reals
⊆ on Sets (subset)
⊂ on Sets (proper subset)
y << x (much less than)
(say, y + 2 ≤ x)
¬ [3 << 4] ¬ [4 << 3]
incomparable
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.29
Partial Orders
L4-1.30
September 9, 2005
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
(Proper) Subset Relation
{1,2,3,5,10,15,30}
The proper subset relation,
⊂,
on sets is the canonical
example.
{1,2,5,10}
{1,3,5,15}
{1,3}
{1,2}
{1,5}
{1}
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.31
Partial Order: divides
L4-1.32
September 9, 2005
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
Partial Order: divides
30
a divides b (a | b) iff
ka = b for some k∈N
10
2|10
15
3
2
5
1|2
1
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.33
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.34
5
Subset Relation
{1,2,3,5,10,15,30}
{1,2,5,10}
{1,3,5,15}
{1,3}
Divides & Subset
same "shape"
{1,2}
{1,5}
{1}
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
L4-1.35
September 9, 2005
Def. of Partial Order on Set A
L4-1.37
Subset Relation
15Æ{1,3,5,15}
30 Æ{1,2,3,5,10,15,30}
10 Æ{1,2,5,10}
3 Æ{1,3}
5 Æ{1,5}
September 9, 2005
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.38
Properties of ⊂
[A ⊂ B and B ⊂ C] implies A ⊂ C
Transitive
A ⊂ B implies ¬(B ⊂ A)
for A ≠ B
Antisymmetric
2 Æ{1,2}
1 Æ{1}
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
L4-1.36
Let
g(n)::= divisors of n
n | m iff g(n) ⊂ g(m)
for n ≠ m
a R b iff g(a) ⊂ g(b)
for a ≠ b
September 9, 2005
September 9, 2005
Divides & Subset
There is a set-valued
function, g, on A such that
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
L4-1.39
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.40
6
Axioms for Partial Order
Total Order on A
Theorem: R is a partial order iff
Partial Order, R, such that
Transitive & Antisymmetric
(Compare to Equivalence:
Reflexive, Transitive, Symmetric.)
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.41
Total Orders
aRb or bRa
for all a≠b ∈A
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
Total Orders
a < b or b < a
a ≤ b or b ≤ a
(for numbers a ≠ b)
(for all a, b)
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.44
L4-1.45
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.46
Team Problems
Problems 3 & 4
Copyright © Albert R. Meyer and Ronitt Rubinfeld 2005.
September 9, 2005
L4-1.47
7
Download