CMPUT 650: Learning To Make Decisions

Download Report

Transcript CMPUT 650: Learning To Make Decisions

CMPUT 272
Formal Systems
Logic in CS
Vadim Bulitko
University of Alberta
http://www.cs.ualberta.ca/~bulitko/W04
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
1
Formalism #1
bijective
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
2
Formalism #2
bijective
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
3
In terms of domain/range
Totality:
f is total iff domain(f)=Df
Onto:
f is surjective iff range(f)=Rf
One-to-one:
f is injective iff f’s mapping between domain(f)
and range(f) is one-to-one
Invertible:
f is bijective iff f’s mapping between Df and Rf is
one-to-one
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
4
Example 1
Consider:
Relation father:
Domain type: people x people
Graph: GR={<x,y>|x,ypeople & y is the father of x}
Function?
Yes
Total?
Yes
Surjective?
No
Injective?
No
Bijective?
No
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
5
Example 2
Consider:
Relation son:
Domain type: people x people
Graph: GR={<x,y>|x,ypeople & y is a son of x}
Function?
No
Total?
No
Surjective?
No
(e.g., Marilyn Monroe was not anyone’s son)
No
(husband & wife share a son)
Injective?
Bijective?
No
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
6
Example 3
Consider:
Relation father’:
Domain type: people x people
Graph: GR={<y,x>|x,ypeople & y is the father of x}
Function?
No
(several x’s (kids) for a single y (father))
No
(e.g., Marilyn Monroe was not anyone’s father)
Total?
Surjective?
Yes
Injective?
Yes
Bijective?
No
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
7
Example 4
Consider:
Relation square:
Domain type: Z x Z
Graph: GR={<x,y>|x,yZ & y=x2}
Function?
Yes
Total?
Yes
Surjective?
No
(y=-5 has no matching x)
No
(x=+10, x=-10 both match y=100)
Injective?
Bijective?
Of course not
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
8
Example 5
Consider:
Relation cube:
Domain type: Z x Z
Graph: GR={<x,y>|x,yZ & y=x3}
Function?
Yes
Total?
Yes
Surjective?
No
Injective?
(y=2 has no matching x)
Yes
Bijective?
Nope
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
9
All Yes?
How about a relation on R x R that will
score all ‘Yes’ on the 5 questions?
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
10
Example 6
Consider:
Relation cube:
Domain type: R x R
Graph: GR={<x,y>|x,yR & y=x3}
Function?
Yes
Total?
Yes
Surjective?
Yes
Injective?
Yes
Bijective?
YES!
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
11
All No?
How about a relation on R x R that will
score all ‘No’ on the 5 questions?
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
12
Example 7
Consider:
Relation circle:
Domain type: R x R
Graph: GR={<x,y>|x,yR & x2+y2=25}
Function?
No
(x=0 has two matching y: +5, -5)
No
(x=10 has no matching y)
No
(y=10 has no matching x)
No
(x=-5 and x=+5 both match y=0)
Total?
Surjective?
Injective?
Bijective?
Are you kidding?
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
13
Key Properties
Df
Rf
range(f)
domain(f)
Not a function
f
Not injective
Not
surjective
Not total
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
14
In terms of domain/range
Totality:
f is total iff domain(f)=Df
Onto:
f is surjective iff range(f)=Rf
One-to-one:
f is injective iff f’s mapping between domain(f)
and range(f) is one-to-one
Invertible:
f is bijective iff f’s mapping between Df and Rf is
one-to-one
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
15
Proofs
Totality:
f is total iff domain(f)=Df
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
16
Proofs
Onto:
f is surjective iff range(f)=Rf
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
17
Proofs
One-to-one:
f is injective iff f’s mapping between domain(f)
and range(f) is one-to-one
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
18
Proofs
Invertible:
f is bijective iff f’s mapping between Df and Rf is
one-to-one
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
19
Proofs
Bijective functions live up to their
name:
f : Df  Rf is bijective implies
exists f -1 : Rf  Df such that
for any xDf, yRf
if f(x)=y then f -1(y)=x
And f
Lecture 22
-1
is bijective too!
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
20
Binary Relations
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
21
Definition
What is a binary relation?
Recall the general definition of relation:
Domain type:
Graph:
DR = X x Y
GR={<x,y>|x X,yY & P[x,y]}
A binary relation is simply a relation with two
arguments of the same type:
DR=A x A
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
22
Examples
Binary relations on numbers:
DR=R x R
<, , , etc.
Binary relations on sets:
DR = 2U x 2U
, , etc.
Binary relations on people:
DR = people x people
Father of, son of, in love with, took C272
from
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
23
Notation
Full notation:
Example:
<a,b>  GR
<3,4>  G<
Shorthand:
Example:
aRb
3<4
MIZAR notation: In[a,b,R]
Example:
In[3,4,less]
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
24
Arrow Diagram
Some loops, but not all loops
0
Lecture 22
1
2
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
4
25
Symmetry
A binary relation R is symmetric iff
for any x,y holds x R y implies y R x
Examples:
=

x
y
Counter-examples:
<

Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
26
Asymmetry
A binary relation R is asymmetric iff
for any x,y holds x R y implies NOT y R x
Counter-examples:
=

Examples:
x
y
<

Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
27
Question
Is every binary relation either symmetric or
asymmetric?
No
Example:
Define a relation R:
<x,y> holds for all integers x<y
<0,0> holds
<0,0> holds  cannot be asymmetric
<1,2> holds but <2,1> doesn’t hold  cannot be symmetric
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
28
Anti-symmetry
A binary relation R is anti-symmetric iff
for any x,y holds x R y and y R x implies x=y
Examples:


=
x
y
Counter-Examples:

x=y
How about?
<
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
29
Relations among
relations…
For any relation R, is R either symmetric,
asymmetric or antisymmetric?
No
For any asymmetric relation R, is R also
antisymmetric?
Yes
For any antisymmetric relation R, is R also
asymmetric?
No
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
30
Reflexivity
A binary relation R is reflexive iff
for any x holds x R x
Examples:
=


x
Counter-examples:
<


Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
31
Irreflexivity
A binary relation R is irreflexive iff
for any x holds NOT x R x
Counter-Examples:
=


x
Examples:
<


Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
32
Relations & Sets
Recall the definition of relation:
Domain type: DR = A x A
Graph:
GR={<x,y>|x A,yA & P[x,y]}
Can manipulate graphs with set operations
Define IA={<x,y>|x A,yA & x=y} (identity)
Then G< = G \ IA
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
33
More on Relations & Sets
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
34
More Questions / Proofs
For any binary relation R:
if R is asymmetric, then is R irreflexive?
yes
if R is irreflexive, then is R asymmetric?
no
if R is irreflexive and antisymmetric, then is R
asymmetric?
yes
Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
35
Transitivity
A binary relation R is transitive iff
for any x,y,z holds
x R y and y R z implies x R z
Examples:
<

=
x
y
z
Counter-examples:

Lecture 22
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
36
Connectivity / Connectedness
A binary relation R is connected iff
for any x,y holds x R y or y R x
Counter-examples:
=


<
x
y
or
Examples:


Lecture 22
x
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
y
37
A puzzle
Consider the relation below:
all known present links are shown solid
all known absent links are shown dashed
we also know it is transitive
Can it be connected?
2
3
1
Lecture 22
4
5
© Vadim Bulitko : CMPUT 272, Winter 2004, UofA
38