Sei sulla pagina 1di 223

Discrete Mathematics

Relations and Functions


H. Turgut Uyar Ayseg ul Gencata Yayml Emre Harmanc
2001-2013
License
c _2001-2013 T. Uyar, A. Yayml, E. Harmanc
You are free:
to Share to copy, distribute and transmit the work
to Remix to adapt the work
Under the following conditions:
Attribution You must attribute the work in the manner specied by the author or licensor (but not in any
way that suggests that they endorse you or your use of the work).
Noncommercial You may not use this work for commercial purposes.
Share Alike If you alter, transform, or build upon this work, you may distribute the resulting work only
under the same or similar license to this one.
Legal code (the full license):
http://creativecommons.org/licenses/by-nc-sa/3.0/
Topics
1 Relations
Introduction
Relation Properties
Equivalence Relations
2 Functions
Introduction
Pigeonhole Principle
Recursion
Topics
1 Relations
Introduction
Relation Properties
Equivalence Relations
2 Functions
Introduction
Pigeonhole Principle
Recursion
Relation
Denition
relation: A B C N
tuple: an element of a relation
A B: binary relation
ab is the same as (a, b)
representations:
by drawing
by matrix
Relation
Denition
relation: A B C N
tuple: an element of a relation
A B: binary relation
ab is the same as (a, b)
representations:
by drawing
by matrix
Relation
Denition
relation: A B C N
tuple: an element of a relation
A B: binary relation
ab is the same as (a, b)
representations:
by drawing
by matrix
Relation
Denition
relation: A B C N
tuple: an element of a relation
A B: binary relation
ab is the same as (a, b)
representations:
by drawing
by matrix
Relation Example
Example
A = a
1
, a
2
, a
3
, a
4
, B = b
1
, b
2
, b
3

= (a
1
, b
1
), (a
1
, b
3
), (a
2
, b
2
), (a
2
, b
3
), (a
3
, b
1
), (a
3
, b
3
), (a
4
, b
1
)
b
1
b
2
b
3
a
1
1 0 1
a
2
0 1 1
a
3
1 0 1
a
4
1 0 0
M

=
1 0 1
0 1 1
1 0 1
1 0 0
Relation Example
Example
A = a
1
, a
2
, a
3
, a
4
, B = b
1
, b
2
, b
3

= (a
1
, b
1
), (a
1
, b
3
), (a
2
, b
2
), (a
2
, b
3
), (a
3
, b
1
), (a
3
, b
3
), (a
4
, b
1
)
b
1
b
2
b
3
a
1
1 0 1
a
2
0 1 1
a
3
1 0 1
a
4
1 0 0
M

=
1 0 1
0 1 1
1 0 1
1 0 0
Relation Composition
Denition
relation composition:
let A B, B C
= (a, c) [ a A, c C, b B [ab bc]
M

= M

using logical operations:


1 : T, 0 : F, : , + :
Relation Composition Example
Example
Relation Composition Matrix Example
Example
M

=
1 0 0
0 0 1
0 1 1
0 1 0
1 0 1
M

=
1 1 0 0
0 0 1 1
0 1 1 0
M

=
1 1 0 0
0 1 1 0
0 1 1 1
0 0 1 1
1 1 1 0
Relation Composition Associativity
relation composition is associative
() = ().
(a, d) ()
c [(a, c) (c, d) ]
c [b [(a, b) (b, c) ] (c, d) ]
b [(a, b) c [(b, c) (c, d) ]]
b [(a, b) (b, d) ]
(a, d) ()
Relation Composition Associativity
relation composition is associative
() = ().
(a, d) ()
c [(a, c) (c, d) ]
c [b [(a, b) (b, c) ] (c, d) ]
b [(a, b) c [(b, c) (c, d) ]]
b [(a, b) (b, d) ]
(a, d) ()
Relation Composition Associativity
relation composition is associative
() = ().
(a, d) ()
c [(a, c) (c, d) ]
c [b [(a, b) (b, c) ] (c, d) ]
b [(a, b) c [(b, c) (c, d) ]]
b [(a, b) (b, d) ]
(a, d) ()
Relation Composition Associativity
relation composition is associative
() = ().
(a, d) ()
c [(a, c) (c, d) ]
c [b [(a, b) (b, c) ] (c, d) ]
b [(a, b) c [(b, c) (c, d) ]]
b [(a, b) (b, d) ]
(a, d) ()
Relation Composition Associativity
relation composition is associative
() = ().
(a, d) ()
c [(a, c) (c, d) ]
c [b [(a, b) (b, c) ] (c, d) ]
b [(a, b) c [(b, c) (c, d) ]]
b [(a, b) (b, d) ]
(a, d) ()
Relation Composition Associativity
relation composition is associative
() = ().
(a, d) ()
c [(a, c) (c, d) ]
c [b [(a, b) (b, c) ] (c, d) ]
b [(a, b) c [(b, c) (c, d) ]]
b [(a, b) (b, d) ]
(a, d) ()
Relation Composition Associativity
relation composition is associative
() = ().
(a, d) ()
c [(a, c) (c, d) ]
c [b [(a, b) (b, c) ] (c, d) ]
b [(a, b) c [(b, c) (c, d) ]]
b [(a, b) (b, d) ]
(a, d) ()
Relation Composition Theorems
let , A B, and
let , B C
( ) =
( )
( ) =
( )
( )
Relation Composition Theorems
( ) = .
(a, c) ( )
b [(a, b) (b, c) ( )]
b [(a, b) ((b, c) (b, c) )]
b [((a, b) (b, c) )
((a, b) (b, c) )]
(a, c) (a, c)
(a, c)
Relation Composition Theorems
( ) = .
(a, c) ( )
b [(a, b) (b, c) ( )]
b [(a, b) ((b, c) (b, c) )]
b [((a, b) (b, c) )
((a, b) (b, c) )]
(a, c) (a, c)
(a, c)
Relation Composition Theorems
( ) = .
(a, c) ( )
b [(a, b) (b, c) ( )]
b [(a, b) ((b, c) (b, c) )]
b [((a, b) (b, c) )
((a, b) (b, c) )]
(a, c) (a, c)
(a, c)
Relation Composition Theorems
( ) = .
(a, c) ( )
b [(a, b) (b, c) ( )]
b [(a, b) ((b, c) (b, c) )]
b [((a, b) (b, c) )
((a, b) (b, c) )]
(a, c) (a, c)
(a, c)
Relation Composition Theorems
( ) = .
(a, c) ( )
b [(a, b) (b, c) ( )]
b [(a, b) ((b, c) (b, c) )]
b [((a, b) (b, c) )
((a, b) (b, c) )]
(a, c) (a, c)
(a, c)
Relation Composition Theorems
( ) = .
(a, c) ( )
b [(a, b) (b, c) ( )]
b [(a, b) ((b, c) (b, c) )]
b [((a, b) (b, c) )
((a, b) (b, c) )]
(a, c) (a, c)
(a, c)
Converse Relation
Denition

1
= (b, a) [ (a, b)
M

1 = M
T

Converse Relation Theorems


(
1
)
1
=
( )
1
=
1

1
( )
1
=
1

1

1
=
1
( )
1
=
1

1

1

1
Converse Relation Theorems

1
=
1
.
(b, a)
1
(a, b)
(a, b) /
(b, a) /
1
(b, a)
1
Converse Relation Theorems

1
=
1
.
(b, a)
1
(a, b)
(a, b) /
(b, a) /
1
(b, a)
1
Converse Relation Theorems

1
=
1
.
(b, a)
1
(a, b)
(a, b) /
(b, a) /
1
(b, a)
1
Converse Relation Theorems

1
=
1
.
(b, a)
1
(a, b)
(a, b) /
(b, a) /
1
(b, a)
1
Converse Relation Theorems

1
=
1
.
(b, a)
1
(a, b)
(a, b) /
(b, a) /
1
(b, a)
1
Converse Relation Theorems
( )
1
=
1

1
.
(b, a) ( )
1
(a, b) ( )
(a, b) (a, b)
(b, a)
1
(b, a)
1
(b, a)
1

1
Converse Relation Theorems
( )
1
=
1

1
.
(b, a) ( )
1
(a, b) ( )
(a, b) (a, b)
(b, a)
1
(b, a)
1
(b, a)
1

1
Converse Relation Theorems
( )
1
=
1

1
.
(b, a) ( )
1
(a, b) ( )
(a, b) (a, b)
(b, a)
1
(b, a)
1
(b, a)
1

1
Converse Relation Theorems
( )
1
=
1

1
.
(b, a) ( )
1
(a, b) ( )
(a, b) (a, b)
(b, a)
1
(b, a)
1
(b, a)
1

1
Converse Relation Theorems
( )
1
=
1

1
.
(b, a) ( )
1
(a, b) ( )
(a, b) (a, b)
(b, a)
1
(b, a)
1
(b, a)
1

1
Converse Relation Theorems
( )
1
=
1

1
.
( )
1
= ( )
1
=
1

1
=
1

1
=
1

1
Converse Relation Theorems
( )
1
=
1

1
.
( )
1
= ( )
1
=
1

1
=
1

1
=
1

1
Converse Relation Theorems
( )
1
=
1

1
.
( )
1
= ( )
1
=
1

1
=
1

1
=
1

1
Converse Relation Theorems
( )
1
=
1

1
.
( )
1
= ( )
1
=
1

1
=
1

1
=
1

1
Relation Composition Converse
Theorem
()
1
=
1

1
Proof.
(c, a) ()
1
(a, c)
b [(a, b) (b, c) ]
b [(b, a)
1
(c, b)
1
]
(c, a)
1

1
Relation Composition Converse
Theorem
()
1
=
1

1
Proof.
(c, a) ()
1
(a, c)
b [(a, b) (b, c) ]
b [(b, a)
1
(c, b)
1
]
(c, a)
1

1
Relation Composition Converse
Theorem
()
1
=
1

1
Proof.
(c, a) ()
1
(a, c)
b [(a, b) (b, c) ]
b [(b, a)
1
(c, b)
1
]
(c, a)
1

1
Relation Composition Converse
Theorem
()
1
=
1

1
Proof.
(c, a) ()
1
(a, c)
b [(a, b) (b, c) ]
b [(b, a)
1
(c, b)
1
]
(c, a)
1

1
Relation Composition Converse
Theorem
()
1
=
1

1
Proof.
(c, a) ()
1
(a, c)
b [(a, b) (b, c) ]
b [(b, a)
1
(c, b)
1
]
(c, a)
1

1
Relation Composition Converse
Theorem
()
1
=
1

1
Proof.
(c, a) ()
1
(a, c)
b [(a, b) (b, c) ]
b [(b, a)
1
(c, b)
1
]
(c, a)
1

1
Topics
1 Relations
Introduction
Relation Properties
Equivalence Relations
2 Functions
Introduction
Pigeonhole Principle
Recursion
Relation Properties
A A
binary relation on A
let
n
mean
identity relation: E = (x, x) [ x A
Relation Properties
A A
binary relation on A
let
n
mean
identity relation: E = (x, x) [ x A
Relation Properties
A A
binary relation on A
let
n
mean
identity relation: E = (x, x) [ x A
Reexivity
reexive
A A
a [aa]
E
nonreexive:
a [(aa)]
irreexive:
a [(aa)]
Reexivity
reexive
A A
a [aa]
E
nonreexive:
a [(aa)]
irreexive:
a [(aa)]
Reexivity
reexive
A A
a [aa]
E
nonreexive:
a [(aa)]
irreexive:
a [(aa)]
Reexivity
reexive
A A
a [aa]
E
nonreexive:
a [(aa)]
irreexive:
a [(aa)]
Reexivity Examples
Example

1
1, 2 1, 2

1
= (1, 1), (1, 2), (2, 2)

1
is reexive
Example

2
1, 2, 3 1, 2, 3

2
= (1, 1), (1, 2), (2, 2)

2
is nonreexive
Reexivity Examples
Example

1
1, 2 1, 2

1
= (1, 1), (1, 2), (2, 2)

1
is reexive
Example

2
1, 2, 3 1, 2, 3

2
= (1, 1), (1, 2), (2, 2)

2
is nonreexive
Reexivity Examples
Example
1, 2, 3 1, 2, 3
= (1, 2), (2, 1), (2, 3)
is irreexive
Reexivity Examples
Example
Z Z
= (a, b) [ ab 0
is reexive
Symmetry
symmetric
A A
a, b [(a = b) (ab ba) ((ab) (ba))]
a, b [(a = b) (ab ba)]

1
=
asymmetric:
a, b [(a ,= b) (ab (ba)) ((ab) ba))]
antisymmetric:
a, b [(a = b) (ab (ba))]
a, b [(a = b) (ab) (ba)]
a, b [(ab ba) (a = b)]
a, b [(ab ba) (a = b)]
Symmetry
symmetric
A A
a, b [(a = b) (ab ba) ((ab) (ba))]
a, b [(a = b) (ab ba)]

1
=
asymmetric:
a, b [(a ,= b) (ab (ba)) ((ab) ba))]
antisymmetric:
a, b [(a = b) (ab (ba))]
a, b [(a = b) (ab) (ba)]
a, b [(ab ba) (a = b)]
a, b [(ab ba) (a = b)]
Symmetry
symmetric
A A
a, b [(a = b) (ab ba) ((ab) (ba))]
a, b [(a = b) (ab ba)]

1
=
asymmetric:
a, b [(a ,= b) (ab (ba)) ((ab) ba))]
antisymmetric:
a, b [(a = b) (ab (ba))]
a, b [(a = b) (ab) (ba)]
a, b [(ab ba) (a = b)]
a, b [(ab ba) (a = b)]
Symmetry
symmetric
A A
a, b [(a = b) (ab ba) ((ab) (ba))]
a, b [(a = b) (ab ba)]

1
=
asymmetric:
a, b [(a ,= b) (ab (ba)) ((ab) ba))]
antisymmetric:
a, b [(a = b) (ab (ba))]
a, b [(a = b) (ab) (ba)]
a, b [(ab ba) (a = b)]
a, b [(ab ba) (a = b)]
Symmetry
symmetric
A A
a, b [(a = b) (ab ba) ((ab) (ba))]
a, b [(a = b) (ab ba)]

1
=
asymmetric:
a, b [(a ,= b) (ab (ba)) ((ab) ba))]
antisymmetric:
a, b [(a = b) (ab (ba))]
a, b [(a = b) (ab) (ba)]
a, b [(ab ba) (a = b)]
a, b [(ab ba) (a = b)]
Symmetry
symmetric
A A
a, b [(a = b) (ab ba) ((ab) (ba))]
a, b [(a = b) (ab ba)]

1
=
asymmetric:
a, b [(a ,= b) (ab (ba)) ((ab) ba))]
antisymmetric:
a, b [(a = b) (ab (ba))]
a, b [(a = b) (ab) (ba)]
a, b [(ab ba) (a = b)]
a, b [(ab ba) (a = b)]
Symmetry
symmetric
A A
a, b [(a = b) (ab ba) ((ab) (ba))]
a, b [(a = b) (ab ba)]

1
=
asymmetric:
a, b [(a ,= b) (ab (ba)) ((ab) ba))]
antisymmetric:
a, b [(a = b) (ab (ba))]
a, b [(a = b) (ab) (ba)]
a, b [(ab ba) (a = b)]
a, b [(ab ba) (a = b)]
Symmetry
symmetric
A A
a, b [(a = b) (ab ba) ((ab) (ba))]
a, b [(a = b) (ab ba)]

1
=
asymmetric:
a, b [(a ,= b) (ab (ba)) ((ab) ba))]
antisymmetric:
a, b [(a = b) (ab (ba))]
a, b [(a = b) (ab) (ba)]
a, b [(ab ba) (a = b)]
a, b [(ab ba) (a = b)]
Symmetry Examples
Example
1, 2, 3 1, 2, 3
= (1, 2), (2, 1), (2, 3)
is asymmetric
Symmetry Examples
Example
Z Z
= (a, b) [ ab 0
is symmetric
Symmetry Examples
Example
1, 2, 3 1, 2, 3
= (1, 1), (2, 2)
is symmetric and antisymmetric
Transitivity
transitive
A A
a, b, c [(ab bc) (ac)]

2

nontransitive:
a, b, c [(ab bc) (ac)]
antitransitive:
a, b, c [(ab bc) (ac)]
Transitivity
transitive
A A
a, b, c [(ab bc) (ac)]

2

nontransitive:
a, b, c [(ab bc) (ac)]
antitransitive:
a, b, c [(ab bc) (ac)]
Transitivity
transitive
A A
a, b, c [(ab bc) (ac)]

2

nontransitive:
a, b, c [(ab bc) (ac)]
antitransitive:
a, b, c [(ab bc) (ac)]
Transitivity
transitive
A A
a, b, c [(ab bc) (ac)]

2

nontransitive:
a, b, c [(ab bc) (ac)]
antitransitive:
a, b, c [(ab bc) (ac)]
Transitivity Examples
Example
1, 2, 3 1, 2, 3
= (1, 2), (2, 1), (2, 3)
is antitransitive
Transitivity Examples
Example
Z Z
= (a, b) [ ab 0
is nontransitive
Converse Relation Properties
Theorem
The reexivity, symmetry and transitivity properties
are preserved in the converse relation.
Closures
reexive closure:
r

= E
symmetric closure:
s

=
1
transitive closure:
t

i =1,2,3,...

i
=
2

3

Closures
reexive closure:
r

= E
symmetric closure:
s

=
1
transitive closure:
t

i =1,2,3,...

i
=
2

3

Closures
reexive closure:
r

= E
symmetric closure:
s

=
1
transitive closure:
t

i =1,2,3,...

i
=
2

3

Special Relations
predecessor - successor
Z Z
= (a, b) [ a b = 1
irreexive
antisymmetric
antitransitive
Special Relations
adjacency
Z Z
= (a, b) [ [a b[ = 1
irreexive
symmetric
antitransitive
Special Relations
strict order
Z Z
= (a, b) [ a < b
irreexive
antisymmetric
transitive
Special Relations
partial order
Z Z
= (a, b) [ a b
reexive
antisymmetric
transitive
Special Relations
preorder
Z Z
= (a, b) [ [a[ [b[
reexive
asymmetric
transitive
Special Relations
limited dierence
Z Z, m Z
+
= (a, b) [ [a b[ m
reexive
symmetric
nontransitive
Special Relations
comparability
U U
= (a, b) [ (a b) (b a)
reexive
symmetric
nontransitive
Special Relations
sibling
irreexive
symmetric
transitive
how can a relation be symmetric, transitive and nonreexive?
Special Relations
sibling
irreexive
symmetric
transitive
how can a relation be symmetric, transitive and nonreexive?
Topics
1 Relations
Introduction
Relation Properties
Equivalence Relations
2 Functions
Introduction
Pigeonhole Principle
Recursion
Compatibility Relations
Denition
compatibility relation:
reexive
symmetric
when drawing, lines instead of arrows
matrix representation as a triangle matrix

1
is a compatibility relation
Compatibility Relations
Denition
compatibility relation:
reexive
symmetric
when drawing, lines instead of arrows
matrix representation as a triangle matrix

1
is a compatibility relation
Compatibility Relations
Denition
compatibility relation:
reexive
symmetric
when drawing, lines instead of arrows
matrix representation as a triangle matrix

1
is a compatibility relation
Compatibility Relation Example
Example
A = a
1
, a
2
, a
3
, a
4

= (a
1
, a
1
), (a
2
, a
2
),
(a
3
, a
3
), (a
4
, a
4
),
(a
1
, a
2
), (a
2
, a
1
),
(a
2
, a
4
), (a
4
, a
2
),
(a
3
, a
4
), (a
4
, a
3
)
1 1 0 0
1 1 0 1
0 0 1 1
0 1 1 1
1
0 0
0 1 1
Compatibility Relation Example
Example
A = a
1
, a
2
, a
3
, a
4

= (a
1
, a
1
), (a
2
, a
2
),
(a
3
, a
3
), (a
4
, a
4
),
(a
1
, a
2
), (a
2
, a
1
),
(a
2
, a
4
), (a
4
, a
2
),
(a
3
, a
4
), (a
4
, a
3
)
1 1 0 0
1 1 0 1
0 0 1 1
0 1 1 1
1
0 0
0 1 1
Compatibility Relation Example
Example (
1
)
P: persons, L: languages
P = p
1
, p
2
, p
3
, p
4
, p
5
, p
6

L = l
1
, l
2
, l
3
, l
4
, l
5

P L
M

=
1 1 0 0 0
1 1 0 0 0
0 0 1 0 1
1 0 1 1 0
0 0 0 1 0
0 1 1 0 0
M

1 =
1 1 0 1 0 0
1 1 0 0 0 1
0 0 1 1 0 1
0 0 0 1 1 0
0 0 1 0 0 0
Compatibility Relation Example
Example (
1
)
P: persons, L: languages
P = p
1
, p
2
, p
3
, p
4
, p
5
, p
6

L = l
1
, l
2
, l
3
, l
4
, l
5

P L
M

=
1 1 0 0 0
1 1 0 0 0
0 0 1 0 1
1 0 1 1 0
0 0 0 1 0
0 1 1 0 0
M

1 =
1 1 0 1 0 0
1 1 0 0 0 1
0 0 1 1 0 1
0 0 0 1 1 0
0 0 1 0 0 0
Compatibility Relation Example
Example (
1
)

1
P P
M

1 =
1 1 0 1 0 1
1 1 0 1 0 1
0 0 1 1 0 1
1 1 1 1 1 1
0 0 0 1 1 0
1 1 1 1 0 1
Compatibility Block
Denition
compatibility block: C A
a, b [a C b C ab]
maximal compatibility block:
not a subset of another compatibility block
an element can be a member of more than one MCB
complete cover: C

set of all MCBs


Compatibility Block
Denition
compatibility block: C A
a, b [a C b C ab]
maximal compatibility block:
not a subset of another compatibility block
an element can be a member of more than one MCB
complete cover: C

set of all MCBs


Compatibility Block
Denition
compatibility block: C A
a, b [a C b C ab]
maximal compatibility block:
not a subset of another compatibility block
an element can be a member of more than one MCB
complete cover: C

set of all MCBs


Compatibility Block Example
Example (
1
)
C
1
= a
4
, a
6

C
2
= a
2
, a
4
, a
6

C
3
= a
1
, a
2
, a
4
, a
6
(MCB)
C

(A) = a
1
, a
2
, a
4
, a
6
,
a
3
, a
4
, a
6
,
a
4
, a
5

Compatibility Block Example


Example (
1
)
C
1
= a
4
, a
6

C
2
= a
2
, a
4
, a
6

C
3
= a
1
, a
2
, a
4
, a
6
(MCB)
C

(A) = a
1
, a
2
, a
4
, a
6
,
a
3
, a
4
, a
6
,
a
4
, a
5

Compatibility Block Example


Example (
1
)
C
1
= a
4
, a
6

C
2
= a
2
, a
4
, a
6

C
3
= a
1
, a
2
, a
4
, a
6
(MCB)
C

(A) = a
1
, a
2
, a
4
, a
6
,
a
3
, a
4
, a
6
,
a
4
, a
5

Equivalence Relations
Denition
equivalence relation:
reexive
symmetric
transitive
equivalence classes (partitions)
every element is a member of exactly one equivalence class
complete cover: C

Equivalence Relations
Denition
equivalence relation:
reexive
symmetric
transitive
equivalence classes (partitions)
every element is a member of exactly one equivalence class
complete cover: C

Equivalence Relation Example


Example
Z Z
= (a, b) [ m Z [a b = 5m]
partitions Z into 5 equivalence classes
References
Required Reading: Grimaldi
Chapter 5: Relations and Functions
5.1. Cartesian Products and Relations
Chapter 7: Relations: The Second Time Around
7.1. Relations Revisited: Properties of Relations
7.4. Equivalence Relations and Partitions
Supplementary Reading: ODonnell, Hall, Page
Chapter 10: Relations
Topics
1 Relations
Introduction
Relation Properties
Equivalence Relations
2 Functions
Introduction
Pigeonhole Principle
Recursion
Functions
Denition
function: f : X Y
x X y
1
, y
2
Y (x, y
1
), (x, y
2
) f y
1
= y
2
X: domain, Y: codomain (or range)
y = f (x) is the same as (x, y) f
y is the image of x under f
let f : X Y, and X
1
X
subset image: f (X
1
) = f (x) [ x X
1

Functions
Denition
function: f : X Y
x X y
1
, y
2
Y (x, y
1
), (x, y
2
) f y
1
= y
2
X: domain, Y: codomain (or range)
y = f (x) is the same as (x, y) f
y is the image of x under f
let f : X Y, and X
1
X
subset image: f (X
1
) = f (x) [ x X
1

Functions
Denition
function: f : X Y
x X y
1
, y
2
Y (x, y
1
), (x, y
2
) f y
1
= y
2
X: domain, Y: codomain (or range)
y = f (x) is the same as (x, y) f
y is the image of x under f
let f : X Y, and X
1
X
subset image: f (X
1
) = f (x) [ x X
1

Subset Image Examples


Example
f : R R
f (x) = x
2
f (Z) = 0, 1, 4, 9, 16, . . .
f (2, 1) = 1, 4
Subset Image Examples
Example
f : R R
f (x) = x
2
f (Z) = 0, 1, 4, 9, 16, . . .
f (2, 1) = 1, 4
Function Properties
Denition
f : X Y is one-to-one (or injective):
x
1
, x
2
X f (x
1
) = f (x
2
) x
1
= x
2
Denition
f : X Y is onto (or surjective):
y Y x X f (x) = y
f (X) = Y
Denition
f : X Y is bijective:
f is one-to-one and onto
Function Properties
Denition
f : X Y is one-to-one (or injective):
x
1
, x
2
X f (x
1
) = f (x
2
) x
1
= x
2
Denition
f : X Y is onto (or surjective):
y Y x X f (x) = y
f (X) = Y
Denition
f : X Y is bijective:
f is one-to-one and onto
Function Properties
Denition
f : X Y is one-to-one (or injective):
x
1
, x
2
X f (x
1
) = f (x
2
) x
1
= x
2
Denition
f : X Y is onto (or surjective):
y Y x X f (x) = y
f (X) = Y
Denition
f : X Y is bijective:
f is one-to-one and onto
One-to-one Function Examples
Example
f : R R
f (x) = 3x + 7
f (x
1
) = f (x
2
)
3x
1
+ 7 = 3x
2
+ 7
3x
1
= 3x
2
x
1
= x
2
Counterexample
g : Z Z
g(x) = x
4
x
g(0) = 0
4
0 = 0
g(1) = 1
4
1 = 0
One-to-one Function Examples
Example
f : R R
f (x) = 3x + 7
f (x
1
) = f (x
2
)
3x
1
+ 7 = 3x
2
+ 7
3x
1
= 3x
2
x
1
= x
2
Counterexample
g : Z Z
g(x) = x
4
x
g(0) = 0
4
0 = 0
g(1) = 1
4
1 = 0
One-to-one Function Examples
Example
f : R R
f (x) = 3x + 7
f (x
1
) = f (x
2
)
3x
1
+ 7 = 3x
2
+ 7
3x
1
= 3x
2
x
1
= x
2
Counterexample
g : Z Z
g(x) = x
4
x
g(0) = 0
4
0 = 0
g(1) = 1
4
1 = 0
One-to-one Function Examples
Example
f : R R
f (x) = 3x + 7
f (x
1
) = f (x
2
)
3x
1
+ 7 = 3x
2
+ 7
3x
1
= 3x
2
x
1
= x
2
Counterexample
g : Z Z
g(x) = x
4
x
g(0) = 0
4
0 = 0
g(1) = 1
4
1 = 0
One-to-one Function Examples
Example
f : R R
f (x) = 3x + 7
f (x
1
) = f (x
2
)
3x
1
+ 7 = 3x
2
+ 7
3x
1
= 3x
2
x
1
= x
2
Counterexample
g : Z Z
g(x) = x
4
x
g(0) = 0
4
0 = 0
g(1) = 1
4
1 = 0
One-to-one Function Examples
Example
f : R R
f (x) = 3x + 7
f (x
1
) = f (x
2
)
3x
1
+ 7 = 3x
2
+ 7
3x
1
= 3x
2
x
1
= x
2
Counterexample
g : Z Z
g(x) = x
4
x
g(0) = 0
4
0 = 0
g(1) = 1
4
1 = 0
One-to-one Function Examples
Example
f : R R
f (x) = 3x + 7
f (x
1
) = f (x
2
)
3x
1
+ 7 = 3x
2
+ 7
3x
1
= 3x
2
x
1
= x
2
Counterexample
g : Z Z
g(x) = x
4
x
g(0) = 0
4
0 = 0
g(1) = 1
4
1 = 0
One-to-one Function Examples
Example
f : R R
f (x) = 3x + 7
f (x
1
) = f (x
2
)
3x
1
+ 7 = 3x
2
+ 7
3x
1
= 3x
2
x
1
= x
2
Counterexample
g : Z Z
g(x) = x
4
x
g(0) = 0
4
0 = 0
g(1) = 1
4
1 = 0
Onto Function Examples
Example
f : R R
f (x) = x
3
Counterexample
f : Z Z
f (x) = 3x + 1
Onto Function Examples
Example
f : R R
f (x) = x
3
Counterexample
f : Z Z
f (x) = 3x + 1
Function Composition
Denition
let f : X Y, g : Y Z
g f : X Z
(g f )(x) = g(f (x))
function composition is not commutative
function composition is associative:
f (g h) = (f g) h
Function Composition
Denition
let f : X Y, g : Y Z
g f : X Z
(g f )(x) = g(f (x))
function composition is not commutative
function composition is associative:
f (g h) = (f g) h
Function Composition Examples
Example (commutativity)
f : R R
f (x) = x
2
g : R R
g(x) = x + 5
g f : R R
(g f )(x) = x
2
+ 5
f g : R R
(f g)(x) = (x + 5)
2
Function Composition Examples
Example (commutativity)
f : R R
f (x) = x
2
g : R R
g(x) = x + 5
g f : R R
(g f )(x) = x
2
+ 5
f g : R R
(f g)(x) = (x + 5)
2
Function Composition Examples
Example (commutativity)
f : R R
f (x) = x
2
g : R R
g(x) = x + 5
g f : R R
(g f )(x) = x
2
+ 5
f g : R R
(f g)(x) = (x + 5)
2
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is one-to-one g is one-to-one g f is one-to-one
Proof.
(g f )(a
1
) = (g f )(a
2
)
g(f (a
1
)) = g(f (a
2
))
f (a
1
) = f (a
2
)
a
1
= a
2
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is one-to-one g is one-to-one g f is one-to-one
Proof.
(g f )(a
1
) = (g f )(a
2
)
g(f (a
1
)) = g(f (a
2
))
f (a
1
) = f (a
2
)
a
1
= a
2
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is one-to-one g is one-to-one g f is one-to-one
Proof.
(g f )(a
1
) = (g f )(a
2
)
g(f (a
1
)) = g(f (a
2
))
f (a
1
) = f (a
2
)
a
1
= a
2
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is one-to-one g is one-to-one g f is one-to-one
Proof.
(g f )(a
1
) = (g f )(a
2
)
g(f (a
1
)) = g(f (a
2
))
f (a
1
) = f (a
2
)
a
1
= a
2
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is one-to-one g is one-to-one g f is one-to-one
Proof.
(g f )(a
1
) = (g f )(a
2
)
g(f (a
1
)) = g(f (a
2
))
f (a
1
) = f (a
2
)
a
1
= a
2
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is onto g is onto g f is onto
Proof.
z Z y Y g(y) = z
y Y x X f (x) = y
z Z x X g(f (x)) = z
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is onto g is onto g f is onto
Proof.
z Z y Y g(y) = z
y Y x X f (x) = y
z Z x X g(f (x)) = z
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is onto g is onto g f is onto
Proof.
z Z y Y g(y) = z
y Y x X f (x) = y
z Z x X g(f (x)) = z
Composite Function Theorems
Theorem
let f : X Y, g : Y Z
f is onto g is onto g f is onto
Proof.
z Z y Y g(y) = z
y Y x X f (x) = y
z Z x X g(f (x)) = z
Identity Function
Denition
identity function: 1
X
1
X
: X X
1
X
(x) = x
Inverse Function
Denition
f : X Y is invertible:
f
1
: Y X [f
1
f = 1
X
f f
1
= 1
Y
]
f
1
: inverse of function f
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function Examples
Example
f : R R
f (x) = 2x + 5
f
1
: R R
f
1
(x) =
x5
2
(f
1
f )(x) = f
1
(f (x)) = f
1
(2x + 5) =
(2x+5)5
2
=
2x
2
= x
(f f
1
)(x) = f (f
1
(x)) = f (
x5
2
) = 2
x5
2
+ 5 = (x 5) + 5 = x
Inverse Function
Theorem
If a function is invertible, its inverse is unique.
Proof.
let f : X Y
let g, h : Y X such that:
g f = 1
X
f g = 1
Y
h f = 1
X
f h = 1
Y
h = h 1
Y
= h (f g) = (h f ) g = 1
X
g = g
Inverse Function
Theorem
If a function is invertible, its inverse is unique.
Proof.
let f : X Y
let g, h : Y X such that:
g f = 1
X
f g = 1
Y
h f = 1
X
f h = 1
Y
h = h 1
Y
= h (f g) = (h f ) g = 1
X
g = g
Inverse Function
Theorem
If a function is invertible, its inverse is unique.
Proof.
let f : X Y
let g, h : Y X such that:
g f = 1
X
f g = 1
Y
h f = 1
X
f h = 1
Y
h = h 1
Y
= h (f g) = (h f ) g = 1
X
g = g
Inverse Function
Theorem
If a function is invertible, its inverse is unique.
Proof.
let f : X Y
let g, h : Y X such that:
g f = 1
X
f g = 1
Y
h f = 1
X
f h = 1
Y
h = h 1
Y
= h (f g) = (h f ) g = 1
X
g = g
Inverse Function
Theorem
If a function is invertible, its inverse is unique.
Proof.
let f : X Y
let g, h : Y X such that:
g f = 1
X
f g = 1
Y
h f = 1
X
f h = 1
Y
h = h 1
Y
= h (f g) = (h f ) g = 1
X
g = g
Inverse Function
Theorem
If a function is invertible, its inverse is unique.
Proof.
let f : X Y
let g, h : Y X such that:
g f = 1
X
f g = 1
Y
h f = 1
X
f h = 1
Y
h = h 1
Y
= h (f g) = (h f ) g = 1
X
g = g
Inverse Function
Theorem
If a function is invertible, its inverse is unique.
Proof.
let f : X Y
let g, h : Y X such that:
g f = 1
X
f g = 1
Y
h f = 1
X
f h = 1
Y
h = h 1
Y
= h (f g) = (h f ) g = 1
X
g = g
Inverse Function
Theorem
If a function is invertible, its inverse is unique.
Proof.
let f : X Y
let g, h : Y X such that:
g f = 1
X
f g = 1
Y
h f = 1
X
f h = 1
Y
h = h 1
Y
= h (f g) = (h f ) g = 1
X
g = g
Invertible Function
Theorem
A function is invertible if and only if it is one-to-one and onto.
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If invertible then one-to-one.
f : A B
f (a
1
) = f (a
2
)
f
1
(f (a
1
)) = f
1
(f (a
2
))
(f
1
f )(a
1
) = (f
1
f )(a
2
)
1
A
(a
1
) = 1
A
(a
2
)
a
1
= a
2
If invertible then onto.
f : A B
b
= 1
B
(b)
= (f f
1
)(b)
= f (f
1
(b))
Invertible Function
If bijective then invertible.
f : A B
f is onto b B a A f (a) = b
let g : B A be dened by a = g(b)
is it possible that g(b) = a
1
,= a
2
= g(b) ?
this would mean: f (a
1
) = b = f (a
2
)
but f is one-to-one
Invertible Function
If bijective then invertible.
f : A B
f is onto b B a A f (a) = b
let g : B A be dened by a = g(b)
is it possible that g(b) = a
1
,= a
2
= g(b) ?
this would mean: f (a
1
) = b = f (a
2
)
but f is one-to-one
Invertible Function
If bijective then invertible.
f : A B
f is onto b B a A f (a) = b
let g : B A be dened by a = g(b)
is it possible that g(b) = a
1
,= a
2
= g(b) ?
this would mean: f (a
1
) = b = f (a
2
)
but f is one-to-one
Topics
1 Relations
Introduction
Relation Properties
Equivalence Relations
2 Functions
Introduction
Pigeonhole Principle
Recursion
Pigeonhole Principle
Denition
Pigeonhole Principle (Dirichlet drawers):
If m pigeons go into n holes and m > n,
then at least one hole contains more than one pigeon.
let f : X Y
if [X[ > [Y[ then f cannot be one-to-one
x
1
, x
2
X [x
1
,= x
2
f (x
1
) = f (x
2
)]
Pigeonhole Principle
Denition
Pigeonhole Principle (Dirichlet drawers):
If m pigeons go into n holes and m > n,
then at least one hole contains more than one pigeon.
let f : X Y
if [X[ > [Y[ then f cannot be one-to-one
x
1
, x
2
X [x
1
,= x
2
f (x
1
) = f (x
2
)]
Pigeonhole Principle Examples
Example
Among 367 people, at least two have the same birthday.
In an exam where the grades integers between 0 and 100,
how many students have to take the exam to make sure that
at least two students will have the same grade?
Pigeonhole Principle Examples
Example
Among 367 people, at least two have the same birthday.
In an exam where the grades integers between 0 and 100,
how many students have to take the exam to make sure that
at least two students will have the same grade?
Generalized Pigeonhole Principle
Denition
Generalized Pigeonhole Principle:
If m objects are distributed to n drawers,
then at least one of the drawers contains m/n| objects.
Example
Among 100 people, at least 9 (100/12|) were born
in the same month.
Generalized Pigeonhole Principle
Denition
Generalized Pigeonhole Principle:
If m objects are distributed to n drawers,
then at least one of the drawers contains m/n| objects.
Example
Among 100 people, at least 9 (100/12|) were born
in the same month.
Pigeonhole Principle Example
Theorem
In any subset of cardinality 6 of the set S = 1,2,3,. . . ,9,
there are two elements which total 10.
Pigeonhole Principle Example
Theorem
Let S be a set of positive integers smaller than or equal to 14,
with cardinality 6. The sums of the elements
in all nonempty subsets of S cannot be all dierent.
Proof Trial
A S
s
A
: sum of the elements of A
holes:
1 s
A
9 + + 14 = 69
pigeons: 2
6
1 = 63
Proof.
look at the subsets for which
[A[ 5
holes:
1 s
A
10 + + 14 = 60
pigeons: 2
6
2 = 62
Pigeonhole Principle Example
Theorem
Let S be a set of positive integers smaller than or equal to 14,
with cardinality 6. The sums of the elements
in all nonempty subsets of S cannot be all dierent.
Proof Trial
A S
s
A
: sum of the elements of A
holes:
1 s
A
9 + + 14 = 69
pigeons: 2
6
1 = 63
Proof.
look at the subsets for which
[A[ 5
holes:
1 s
A
10 + + 14 = 60
pigeons: 2
6
2 = 62
Pigeonhole Principle Example
Theorem
Let S be a set of positive integers smaller than or equal to 14,
with cardinality 6. The sums of the elements
in all nonempty subsets of S cannot be all dierent.
Proof Trial
A S
s
A
: sum of the elements of A
holes:
1 s
A
9 + + 14 = 69
pigeons: 2
6
1 = 63
Proof.
look at the subsets for which
[A[ 5
holes:
1 s
A
10 + + 14 = 60
pigeons: 2
6
2 = 62
Pigeonhole Principle Example
Theorem
Let S be a set of positive integers smaller than or equal to 14,
with cardinality 6. The sums of the elements
in all nonempty subsets of S cannot be all dierent.
Proof Trial
A S
s
A
: sum of the elements of A
holes:
1 s
A
9 + + 14 = 69
pigeons: 2
6
1 = 63
Proof.
look at the subsets for which
[A[ 5
holes:
1 s
A
10 + + 14 = 60
pigeons: 2
6
2 = 62
Pigeonhole Principle Example
Theorem
Let S be a set of positive integers smaller than or equal to 14,
with cardinality 6. The sums of the elements
in all nonempty subsets of S cannot be all dierent.
Proof Trial
A S
s
A
: sum of the elements of A
holes:
1 s
A
9 + + 14 = 69
pigeons: 2
6
1 = 63
Proof.
look at the subsets for which
[A[ 5
holes:
1 s
A
10 + + 14 = 60
pigeons: 2
6
2 = 62
Pigeonhole Principle Example
Theorem
There is at least one pair of elements among 101 elements
chosen from set S = 1, 2, 3, . . . , 200,
so that one of the elements of the pair divides the other.
Proof Method
we rst show that
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
then, by using this theorem we prove the main theorem
Pigeonhole Principle Example
Theorem
There is at least one pair of elements among 101 elements
chosen from set S = 1, 2, 3, . . . , 200,
so that one of the elements of the pair divides the other.
Proof Method
we rst show that
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
then, by using this theorem we prove the main theorem
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
n !p [n = 2
r
p r N t Z [p = 2t + 1]]
Proof of existence.
n = 1: r = 0, p = 1
n k: assume n = 2
r
p
n = k + 1:
n = 2 : r = 1, p = 1
n prime (n > 2) : r = 0, p = n
(n prime) : n = n
1
n
2
n = 2
r
1
p
1
2
r
2
p
2
n = 2
r
1
+r
2
p
1
p
2
Proof of uniqueness.
if not unique:
n = 2
r
1
p
1
= 2
r
2
p
2
2
r
1
r
2
p
1
= p
2
2[p
2
Pigeonhole Principle Example
Theorem
There is at least one pair of elements among 101 elements
chosen from set S = 1, 2, 3, . . . , 200
so that one of the elements of the pair divides the other.
Proof.
T = t [ t S, i Z [t = 2i + 1], [T[ = 100
f : S T, r N olsun
s = 2
r
t f (s) = t
if 101 elements are chosen from S, at least two of them
will have the same image in T: f (s
1
) = f (s
2
) 2
m
1
t = 2
m
2
t
s
1
s
2
=
2
m
1
t
2
m
2
t
= 2
m
1
m
2
Pigeonhole Principle Example
Theorem
There is at least one pair of elements among 101 elements
chosen from set S = 1, 2, 3, . . . , 200
so that one of the elements of the pair divides the other.
Proof.
T = t [ t S, i Z [t = 2i + 1], [T[ = 100
f : S T, r N olsun
s = 2
r
t f (s) = t
if 101 elements are chosen from S, at least two of them
will have the same image in T: f (s
1
) = f (s
2
) 2
m
1
t = 2
m
2
t
s
1
s
2
=
2
m
1
t
2
m
2
t
= 2
m
1
m
2
Pigeonhole Principle Example
Theorem
There is at least one pair of elements among 101 elements
chosen from set S = 1, 2, 3, . . . , 200
so that one of the elements of the pair divides the other.
Proof.
T = t [ t S, i Z [t = 2i + 1], [T[ = 100
f : S T, r N olsun
s = 2
r
t f (s) = t
if 101 elements are chosen from S, at least two of them
will have the same image in T: f (s
1
) = f (s
2
) 2
m
1
t = 2
m
2
t
s
1
s
2
=
2
m
1
t
2
m
2
t
= 2
m
1
m
2
Pigeonhole Principle Example
Theorem
There is at least one pair of elements among 101 elements
chosen from set S = 1, 2, 3, . . . , 200
so that one of the elements of the pair divides the other.
Proof.
T = t [ t S, i Z [t = 2i + 1], [T[ = 100
f : S T, r N olsun
s = 2
r
t f (s) = t
if 101 elements are chosen from S, at least two of them
will have the same image in T: f (s
1
) = f (s
2
) 2
m
1
t = 2
m
2
t
s
1
s
2
=
2
m
1
t
2
m
2
t
= 2
m
1
m
2
Topics
1 Relations
Introduction
Relation Properties
Equivalence Relations
2 Functions
Introduction
Pigeonhole Principle
Recursion
Recursive Functions
Denition
recursive function: a function dened in terms of itself
f (n) = h(f (m))
inductively dened function: a recursive function
where the size is reduced at every step
f (n) =

k n = 0
h(f (n 1)) n > 0
Recursion Examples
Example
f 91(n) =

n 10 n > 100
f 91(f 91(n + 11)) n 100
Example (factorial)
f (n) =

1 n = 0
n f (n 1) n > 0
Recursion Examples
Example
f 91(n) =

n 10 n > 100
f 91(f 91(n + 11)) n 100
Example (factorial)
f (n) =

1 n = 0
n f (n 1) n > 0
Euclid Algorithm
Example (greatest common divisor)
gcd(a, b) =

b b[a
gcd(b, a mod b) b a
gcd(333, 84) = gcd(84, 333 mod 84)
= gcd(84, 81)
= gcd(81, 84 mod 81)
= gcd(81, 3)
= 3
Euclid Algorithm
Example (greatest common divisor)
gcd(a, b) =

b b[a
gcd(b, a mod b) b a
gcd(333, 84) = gcd(84, 333 mod 84)
= gcd(84, 81)
= gcd(81, 84 mod 81)
= gcd(81, 3)
= 3
Fibonacci Series
Fibonacci series
F
n
= b(n) =

1 n = 1
1 n = 2
b(n 1) + b(n 2) n > 2
F
1
F
2
F
3
F
4
F
5
F
6
F
7
F
8
. . .
1 1 2 3 5 8 13 21 . . .
Fibonacci Series
Theorem

n
i =1
F
i
2
= F
n
F
n+1
Proof.
n = 2 :

2
i =1
F
i
2
= F
1
2
+ F
2
2
= 1 + 1 = 1 2 = F
2
F
3
n = k :

k
i =1
F
i
2
= F
k
F
k+1
n = k + 1 :

k+1
i =1
F
i
2
=

k
i =1
F
i
2
+ F
k+1
2
= F
k
F
k+1
+ F
k+1
2
= F
k+1
(F
k
+ F
k+1
)
= F
k+1
F
k+2
Fibonacci Series
Theorem

n
i =1
F
i
2
= F
n
F
n+1
Proof.
n = 2 :

2
i =1
F
i
2
= F
1
2
+ F
2
2
= 1 + 1 = 1 2 = F
2
F
3
n = k :

k
i =1
F
i
2
= F
k
F
k+1
n = k + 1 :

k+1
i =1
F
i
2
=

k
i =1
F
i
2
+ F
k+1
2
= F
k
F
k+1
+ F
k+1
2
= F
k+1
(F
k
+ F
k+1
)
= F
k+1
F
k+2
Fibonacci Series
Theorem

n
i =1
F
i
2
= F
n
F
n+1
Proof.
n = 2 :

2
i =1
F
i
2
= F
1
2
+ F
2
2
= 1 + 1 = 1 2 = F
2
F
3
n = k :

k
i =1
F
i
2
= F
k
F
k+1
n = k + 1 :

k+1
i =1
F
i
2
=

k
i =1
F
i
2
+ F
k+1
2
= F
k
F
k+1
+ F
k+1
2
= F
k+1
(F
k
+ F
k+1
)
= F
k+1
F
k+2
Fibonacci Series
Theorem

n
i =1
F
i
2
= F
n
F
n+1
Proof.
n = 2 :

2
i =1
F
i
2
= F
1
2
+ F
2
2
= 1 + 1 = 1 2 = F
2
F
3
n = k :

k
i =1
F
i
2
= F
k
F
k+1
n = k + 1 :

k+1
i =1
F
i
2
=

k
i =1
F
i
2
+ F
k+1
2
= F
k
F
k+1
+ F
k+1
2
= F
k+1
(F
k
+ F
k+1
)
= F
k+1
F
k+2
Fibonacci Series
Theorem

n
i =1
F
i
2
= F
n
F
n+1
Proof.
n = 2 :

2
i =1
F
i
2
= F
1
2
+ F
2
2
= 1 + 1 = 1 2 = F
2
F
3
n = k :

k
i =1
F
i
2
= F
k
F
k+1
n = k + 1 :

k+1
i =1
F
i
2
=

k
i =1
F
i
2
+ F
k+1
2
= F
k
F
k+1
+ F
k+1
2
= F
k+1
(F
k
+ F
k+1
)
= F
k+1
F
k+2
Fibonacci Series
Theorem

n
i =1
F
i
2
= F
n
F
n+1
Proof.
n = 2 :

2
i =1
F
i
2
= F
1
2
+ F
2
2
= 1 + 1 = 1 2 = F
2
F
3
n = k :

k
i =1
F
i
2
= F
k
F
k+1
n = k + 1 :

k+1
i =1
F
i
2
=

k
i =1
F
i
2
+ F
k+1
2
= F
k
F
k+1
+ F
k+1
2
= F
k+1
(F
k
+ F
k+1
)
= F
k+1
F
k+2
Fibonacci Series
Theorem

n
i =1
F
i
2
= F
n
F
n+1
Proof.
n = 2 :

2
i =1
F
i
2
= F
1
2
+ F
2
2
= 1 + 1 = 1 2 = F
2
F
3
n = k :

k
i =1
F
i
2
= F
k
F
k+1
n = k + 1 :

k+1
i =1
F
i
2
=

k
i =1
F
i
2
+ F
k+1
2
= F
k
F
k+1
+ F
k+1
2
= F
k+1
(F
k
+ F
k+1
)
= F
k+1
F
k+2
Ackermann Function
Ackermann function
ack(x, y) =

y + 1 x = 0
ack(x 1, 1) y = 0
ack(x 1, ack(x, y 1)) x > 0 y > 0
References
Required Reading: Grimaldi
Chapter 5: Relations and Functions
5.2. Functions: Plain and One-to-One
5.3. Onto Functions: Stirling Numbers of the Second Kind
5.5. The Pigeonhole Principle
5.6. Function Composition and Inverse Functions
Supplementary Reading: ODonnell, Hall, Page
Chapter 11: Functions

Potrebbero piacerti anche