discrete mathematics - relations and functions

223
Discrete Mathematics Relations and Functions H. Turgut Uyar Ay¸ seg¨ ul Gen¸ cata Yayımlı Emre Harmancı 2001-2013

Upload: turgut-uyar

Post on 18-Dec-2014

27.291 views

Category:

Education


3 download

DESCRIPTION

Relations, relation composition, converse relation, reflexivity, symmetry, transitivity. Functions, function composition, one-to-one, onto, bijective functions, inverse function, pigeonhole principle, recursive functions.

TRANSCRIPT

Page 1: Discrete Mathematics - Relations and Functions

Discrete MathematicsRelations and Functions

H. Turgut Uyar Aysegul Gencata Yayımlı Emre Harmancı

2001-2013

Page 2: Discrete Mathematics - Relations and Functions

License

c©2001-2013 T. Uyar, A. Yayımlı, 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 specified by the author or licensor (but not in anyway 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 onlyunder the same or similar license to this one.

Legal code (the full license):http://creativecommons.org/licenses/by-nc-sa/3.0/

Page 3: Discrete Mathematics - Relations and Functions

Topics

1 RelationsIntroductionRelation PropertiesEquivalence Relations

2 FunctionsIntroductionPigeonhole PrincipleRecursion

Page 4: Discrete Mathematics - Relations and Functions

Topics

1 RelationsIntroductionRelation PropertiesEquivalence Relations

2 FunctionsIntroductionPigeonhole PrincipleRecursion

Page 5: Discrete Mathematics - Relations and Functions

Relation

Definition

relation: α ⊆ A× B × C × · · · × N

tuple: an element of a relation

α ⊆ A× B: binary relation

aαb is the same as (a, b) ∈ α

representations:

by drawingby matrix

Page 6: Discrete Mathematics - Relations and Functions

Relation

Definition

relation: α ⊆ A× B × C × · · · × N

tuple: an element of a relation

α ⊆ A× B: binary relation

aαb is the same as (a, b) ∈ α

representations:

by drawingby matrix

Page 7: Discrete Mathematics - Relations and Functions

Relation

Definition

relation: α ⊆ A× B × C × · · · × N

tuple: an element of a relation

α ⊆ A× B: binary relation

aαb is the same as (a, b) ∈ α

representations:

by drawingby matrix

Page 8: Discrete Mathematics - Relations and Functions

Relation

Definition

relation: α ⊆ A× B × C × · · · × N

tuple: an element of a relation

α ⊆ A× B: binary relation

aαb is the same as (a, b) ∈ α

representations:

by drawingby matrix

Page 9: Discrete Mathematics - Relations and Functions

Relation Example

Example

A = {a1, a2, a3, a4},B = {b1, b2, b3}α = {(a1, b1), (a1, b3), (a2, b2), (a2, b3), (a3, b1), (a3, b3), (a4, b1)}

b1 b2 b3

a1 1 0 1a2 0 1 1a3 1 0 1a4 1 0 0

Mα =

1 0 10 1 11 0 11 0 0

Page 10: Discrete Mathematics - Relations and Functions

Relation Example

Example

A = {a1, a2, a3, a4},B = {b1, b2, b3}α = {(a1, b1), (a1, b3), (a2, b2), (a2, b3), (a3, b1), (a3, b3), (a4, b1)}

b1 b2 b3

a1 1 0 1a2 0 1 1a3 1 0 1a4 1 0 0

Mα =

1 0 10 1 11 0 11 0 0

Page 11: Discrete Mathematics - Relations and Functions

Relation Composition

Definition

relation composition:let α ⊆ A× B, β ⊆ B × Cαβ = {(a, c) | a ∈ A, c ∈ C ,∃b ∈ B [aαb ∧ bβc]}

Mαβ = Mα ×Mβ

using logical operations:1 : T , 0 : F , · : ∧,+ : ∨

Page 12: Discrete Mathematics - Relations and Functions

Relation Composition Example

Example

Page 13: Discrete Mathematics - Relations and Functions

Relation Composition Matrix Example

Example

Mα =

1 0 00 0 10 1 10 1 01 0 1

Mβ =1 1 0 00 0 1 10 1 1 0

Mαβ =

1 1 0 00 1 1 00 1 1 10 0 1 11 1 1 0

Page 14: Discrete Mathematics - Relations and Functions

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) ∈ α(βγ)

Page 15: Discrete Mathematics - Relations and Functions

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) ∈ α(βγ)

Page 16: Discrete Mathematics - Relations and Functions

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) ∈ α(βγ)

Page 17: Discrete Mathematics - Relations and Functions

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) ∈ α(βγ)

Page 18: Discrete Mathematics - Relations and Functions

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) ∈ α(βγ)

Page 19: Discrete Mathematics - Relations and Functions

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) ∈ α(βγ)

Page 20: Discrete Mathematics - Relations and Functions

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) ∈ α(βγ)

Page 21: Discrete Mathematics - Relations and Functions

Relation Composition Theorems

let α, δ ⊆ A× B, andlet β, γ ⊆ B × C

α(β ∪ γ) = αβ ∪ αγ

α(β ∩ γ) ⊆ αβ ∩ αγ

(α ∪ δ)β = αβ ∪ δβ

(α ∩ δ)β ⊆ αβ ∩ δβ

(α ⊆ δ ∧ β ⊆ γ) ⇒ αβ ⊆ δγ

Page 22: Discrete Mathematics - Relations and Functions

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) ∈ αβ ∪ αγ

Page 23: Discrete Mathematics - Relations and Functions

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) ∈ αβ ∪ αγ

Page 24: Discrete Mathematics - Relations and Functions

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) ∈ αβ ∪ αγ

Page 25: Discrete Mathematics - Relations and Functions

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) ∈ αβ ∪ αγ

Page 26: Discrete Mathematics - Relations and Functions

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) ∈ αβ ∪ αγ

Page 27: Discrete Mathematics - Relations and Functions

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) ∈ αβ ∪ αγ

Page 28: Discrete Mathematics - Relations and Functions

Converse Relation

Definition

α−1 = {(b, a) | (a, b) ∈ α}

Mα−1 = MTα

Page 29: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

(α−1)−1 = α

(α ∪ β)−1 = α−1 ∪ β−1

(α ∩ β)−1 = α−1 ∩ β−1

α−1 = α−1

(α− β)−1 = α−1 − β−1

α ⊂ β ⇒ α−1 ⊂ β−1

Page 30: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

α−1 = α−1.

(b, a) ∈ α−1

⇔ (a, b) ∈ α

⇔ (a, b) /∈ α

⇔ (b, a) /∈ α−1

⇔ (b, a) ∈ α−1

Page 31: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

α−1 = α−1.

(b, a) ∈ α−1

⇔ (a, b) ∈ α

⇔ (a, b) /∈ α

⇔ (b, a) /∈ α−1

⇔ (b, a) ∈ α−1

Page 32: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

α−1 = α−1.

(b, a) ∈ α−1

⇔ (a, b) ∈ α

⇔ (a, b) /∈ α

⇔ (b, a) /∈ α−1

⇔ (b, a) ∈ α−1

Page 33: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

α−1 = α−1.

(b, a) ∈ α−1

⇔ (a, b) ∈ α

⇔ (a, b) /∈ α

⇔ (b, a) /∈ α−1

⇔ (b, a) ∈ α−1

Page 34: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

α−1 = α−1.

(b, a) ∈ α−1

⇔ (a, b) ∈ α

⇔ (a, b) /∈ α

⇔ (b, a) /∈ α−1

⇔ (b, a) ∈ α−1

Page 35: Discrete Mathematics - Relations and Functions

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

Page 36: Discrete Mathematics - Relations and Functions

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

Page 37: Discrete Mathematics - Relations and Functions

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

Page 38: Discrete Mathematics - Relations and Functions

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

Page 39: Discrete Mathematics - Relations and Functions

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

Page 40: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

(α− β)−1 = α−1 − β−1.

(α− β)−1 = (α ∩ β)−1

= α−1 ∩ β−1

= α−1 ∩ β−1

= α−1 − β−1

Page 41: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

(α− β)−1 = α−1 − β−1.

(α− β)−1 = (α ∩ β)−1

= α−1 ∩ β−1

= α−1 ∩ β−1

= α−1 − β−1

Page 42: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

(α− β)−1 = α−1 − β−1.

(α− β)−1 = (α ∩ β)−1

= α−1 ∩ β−1

= α−1 ∩ β−1

= α−1 − β−1

Page 43: Discrete Mathematics - Relations and Functions

Converse Relation Theorems

(α− β)−1 = α−1 − β−1.

(α− β)−1 = (α ∩ β)−1

= α−1 ∩ β−1

= α−1 ∩ β−1

= α−1 − β−1

Page 44: Discrete Mathematics - Relations and Functions

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

Page 45: Discrete Mathematics - Relations and Functions

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

Page 46: Discrete Mathematics - Relations and Functions

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

Page 47: Discrete Mathematics - Relations and Functions

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

Page 48: Discrete Mathematics - Relations and Functions

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

Page 49: Discrete Mathematics - Relations and Functions

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

Page 50: Discrete Mathematics - Relations and Functions

Topics

1 RelationsIntroductionRelation PropertiesEquivalence Relations

2 FunctionsIntroductionPigeonhole PrincipleRecursion

Page 51: Discrete Mathematics - Relations and Functions

Relation Properties

α ⊆ A× A

binary relation on A

let αn mean αα · · ·α

identity relation: E = {(x , x) | x ∈ A}

Page 52: Discrete Mathematics - Relations and Functions

Relation Properties

α ⊆ A× A

binary relation on A

let αn mean αα · · ·α

identity relation: E = {(x , x) | x ∈ A}

Page 53: Discrete Mathematics - Relations and Functions

Relation Properties

α ⊆ A× A

binary relation on A

let αn mean αα · · ·α

identity relation: E = {(x , x) | x ∈ A}

Page 54: Discrete Mathematics - Relations and Functions

Reflexivity

reflexive

α ⊆ A× A∀a [aαa]

E ⊆ α

nonreflexive:∃a [¬(aαa)]

irreflexive:∀a [¬(aαa)]

Page 55: Discrete Mathematics - Relations and Functions

Reflexivity

reflexive

α ⊆ A× A∀a [aαa]

E ⊆ α

nonreflexive:∃a [¬(aαa)]

irreflexive:∀a [¬(aαa)]

Page 56: Discrete Mathematics - Relations and Functions

Reflexivity

reflexive

α ⊆ A× A∀a [aαa]

E ⊆ α

nonreflexive:∃a [¬(aαa)]

irreflexive:∀a [¬(aαa)]

Page 57: Discrete Mathematics - Relations and Functions

Reflexivity

reflexive

α ⊆ A× A∀a [aαa]

E ⊆ α

nonreflexive:∃a [¬(aαa)]

irreflexive:∀a [¬(aαa)]

Page 58: Discrete Mathematics - Relations and Functions

Reflexivity Examples

Example

R1 ⊆ {1, 2} × {1, 2}R1 = {(1, 1), (1, 2), (2, 2)}

R1 is reflexive

Example

R2 ⊆ {1, 2, 3} × {1, 2, 3}R2 = {(1, 1), (1, 2), (2, 2)}

R2 is nonreflexive

Page 59: Discrete Mathematics - Relations and Functions

Reflexivity Examples

Example

R1 ⊆ {1, 2} × {1, 2}R1 = {(1, 1), (1, 2), (2, 2)}

R1 is reflexive

Example

R2 ⊆ {1, 2, 3} × {1, 2, 3}R2 = {(1, 1), (1, 2), (2, 2)}

R2 is nonreflexive

Page 60: Discrete Mathematics - Relations and Functions

Reflexivity Examples

Example

R ⊆ {1, 2, 3} × {1, 2, 3}R = {(1, 2), (2, 1), (2, 3)}

R is irreflexive

Page 61: Discrete Mathematics - Relations and Functions

Reflexivity Examples

Example

R ⊆ Z× ZR = {(a, b) | ab ≥ 0}

R is reflexive

Page 62: Discrete Mathematics - Relations and Functions

Symmetry

symmetric

α ⊆ A× A∀a, b [(a = b) ∨ (aαb ∧ bαa) ∨ (¬(aαb) ∧ ¬(bαa))]∀a, b [(a = b) ∨ (aαb ↔ bαa)]

α−1 = α

asymmetric:∃a, b [(a 6= b) ∧ (aαb ∧ ¬(bαa)) ∨ (¬(aαb) ∧ bαa))]

antisymmetric:∀a, b [(a = b) ∨ (aαb → ¬(bαa))]

⇔ ∀a, b [(a = b) ∨ ¬(aαb) ∨ ¬(bαa)]

⇔ ∀a, b [¬(aαb ∧ bαa) ∨ (a = b)]

⇔ ∀a, b [(aαb ∧ bαa) → (a = b)]

Page 63: Discrete Mathematics - Relations and Functions

Symmetry

symmetric

α ⊆ A× A∀a, b [(a = b) ∨ (aαb ∧ bαa) ∨ (¬(aαb) ∧ ¬(bαa))]∀a, b [(a = b) ∨ (aαb ↔ bαa)]

α−1 = α

asymmetric:∃a, b [(a 6= b) ∧ (aαb ∧ ¬(bαa)) ∨ (¬(aαb) ∧ bαa))]

antisymmetric:∀a, b [(a = b) ∨ (aαb → ¬(bαa))]

⇔ ∀a, b [(a = b) ∨ ¬(aαb) ∨ ¬(bαa)]

⇔ ∀a, b [¬(aαb ∧ bαa) ∨ (a = b)]

⇔ ∀a, b [(aαb ∧ bαa) → (a = b)]

Page 64: Discrete Mathematics - Relations and Functions

Symmetry

symmetric

α ⊆ A× A∀a, b [(a = b) ∨ (aαb ∧ bαa) ∨ (¬(aαb) ∧ ¬(bαa))]∀a, b [(a = b) ∨ (aαb ↔ bαa)]

α−1 = α

asymmetric:∃a, b [(a 6= b) ∧ (aαb ∧ ¬(bαa)) ∨ (¬(aαb) ∧ bαa))]

antisymmetric:∀a, b [(a = b) ∨ (aαb → ¬(bαa))]

⇔ ∀a, b [(a = b) ∨ ¬(aαb) ∨ ¬(bαa)]

⇔ ∀a, b [¬(aαb ∧ bαa) ∨ (a = b)]

⇔ ∀a, b [(aαb ∧ bαa) → (a = b)]

Page 65: Discrete Mathematics - Relations and Functions

Symmetry

symmetric

α ⊆ A× A∀a, b [(a = b) ∨ (aαb ∧ bαa) ∨ (¬(aαb) ∧ ¬(bαa))]∀a, b [(a = b) ∨ (aαb ↔ bαa)]

α−1 = α

asymmetric:∃a, b [(a 6= b) ∧ (aαb ∧ ¬(bαa)) ∨ (¬(aαb) ∧ bαa))]

antisymmetric:∀a, b [(a = b) ∨ (aαb → ¬(bαa))]

⇔ ∀a, b [(a = b) ∨ ¬(aαb) ∨ ¬(bαa)]

⇔ ∀a, b [¬(aαb ∧ bαa) ∨ (a = b)]

⇔ ∀a, b [(aαb ∧ bαa) → (a = b)]

Page 66: Discrete Mathematics - Relations and Functions

Symmetry

symmetric

α ⊆ A× A∀a, b [(a = b) ∨ (aαb ∧ bαa) ∨ (¬(aαb) ∧ ¬(bαa))]∀a, b [(a = b) ∨ (aαb ↔ bαa)]

α−1 = α

asymmetric:∃a, b [(a 6= b) ∧ (aαb ∧ ¬(bαa)) ∨ (¬(aαb) ∧ bαa))]

antisymmetric:∀a, b [(a = b) ∨ (aαb → ¬(bαa))]

⇔ ∀a, b [(a = b) ∨ ¬(aαb) ∨ ¬(bαa)]

⇔ ∀a, b [¬(aαb ∧ bαa) ∨ (a = b)]

⇔ ∀a, b [(aαb ∧ bαa) → (a = b)]

Page 67: Discrete Mathematics - Relations and Functions

Symmetry

symmetric

α ⊆ A× A∀a, b [(a = b) ∨ (aαb ∧ bαa) ∨ (¬(aαb) ∧ ¬(bαa))]∀a, b [(a = b) ∨ (aαb ↔ bαa)]

α−1 = α

asymmetric:∃a, b [(a 6= b) ∧ (aαb ∧ ¬(bαa)) ∨ (¬(aαb) ∧ bαa))]

antisymmetric:∀a, b [(a = b) ∨ (aαb → ¬(bαa))]

⇔ ∀a, b [(a = b) ∨ ¬(aαb) ∨ ¬(bαa)]

⇔ ∀a, b [¬(aαb ∧ bαa) ∨ (a = b)]

⇔ ∀a, b [(aαb ∧ bαa) → (a = b)]

Page 68: Discrete Mathematics - Relations and Functions

Symmetry

symmetric

α ⊆ A× A∀a, b [(a = b) ∨ (aαb ∧ bαa) ∨ (¬(aαb) ∧ ¬(bαa))]∀a, b [(a = b) ∨ (aαb ↔ bαa)]

α−1 = α

asymmetric:∃a, b [(a 6= b) ∧ (aαb ∧ ¬(bαa)) ∨ (¬(aαb) ∧ bαa))]

antisymmetric:∀a, b [(a = b) ∨ (aαb → ¬(bαa))]

⇔ ∀a, b [(a = b) ∨ ¬(aαb) ∨ ¬(bαa)]

⇔ ∀a, b [¬(aαb ∧ bαa) ∨ (a = b)]

⇔ ∀a, b [(aαb ∧ bαa) → (a = b)]

Page 69: Discrete Mathematics - Relations and Functions

Symmetry

symmetric

α ⊆ A× A∀a, b [(a = b) ∨ (aαb ∧ bαa) ∨ (¬(aαb) ∧ ¬(bαa))]∀a, b [(a = b) ∨ (aαb ↔ bαa)]

α−1 = α

asymmetric:∃a, b [(a 6= b) ∧ (aαb ∧ ¬(bαa)) ∨ (¬(aαb) ∧ bαa))]

antisymmetric:∀a, b [(a = b) ∨ (aαb → ¬(bαa))]

⇔ ∀a, b [(a = b) ∨ ¬(aαb) ∨ ¬(bαa)]

⇔ ∀a, b [¬(aαb ∧ bαa) ∨ (a = b)]

⇔ ∀a, b [(aαb ∧ bαa) → (a = b)]

Page 70: Discrete Mathematics - Relations and Functions

Symmetry Examples

Example

R ⊆ {1, 2, 3} × {1, 2, 3}R = {(1, 2), (2, 1), (2, 3)}

R is asymmetric

Page 71: Discrete Mathematics - Relations and Functions

Symmetry Examples

Example

R ⊆ Z× ZR = {(a, b) | ab ≥ 0}

R is symmetric

Page 72: Discrete Mathematics - Relations and Functions

Symmetry Examples

Example

R ⊆ {1, 2, 3} × {1, 2, 3}R = {(1, 1), (2, 2)}

R is symmetric and antisymmetric

Page 73: Discrete Mathematics - Relations and Functions

Transitivity

transitive

α ⊆ A× A∀a, b, c [(aαb ∧ bαc) → (aαc)]

α2 ⊆ α

nontransitive:∃a, b, c [(aαb ∧ bαc) ∧ ¬(aαc)]

antitransitive:∀a, b, c [(aαb ∧ bαc) → ¬(aαc)]

Page 74: Discrete Mathematics - Relations and Functions

Transitivity

transitive

α ⊆ A× A∀a, b, c [(aαb ∧ bαc) → (aαc)]

α2 ⊆ α

nontransitive:∃a, b, c [(aαb ∧ bαc) ∧ ¬(aαc)]

antitransitive:∀a, b, c [(aαb ∧ bαc) → ¬(aαc)]

Page 75: Discrete Mathematics - Relations and Functions

Transitivity

transitive

α ⊆ A× A∀a, b, c [(aαb ∧ bαc) → (aαc)]

α2 ⊆ α

nontransitive:∃a, b, c [(aαb ∧ bαc) ∧ ¬(aαc)]

antitransitive:∀a, b, c [(aαb ∧ bαc) → ¬(aαc)]

Page 76: Discrete Mathematics - Relations and Functions

Transitivity

transitive

α ⊆ A× A∀a, b, c [(aαb ∧ bαc) → (aαc)]

α2 ⊆ α

nontransitive:∃a, b, c [(aαb ∧ bαc) ∧ ¬(aαc)]

antitransitive:∀a, b, c [(aαb ∧ bαc) → ¬(aαc)]

Page 77: Discrete Mathematics - Relations and Functions

Transitivity Examples

Example

R ⊆ {1, 2, 3} × {1, 2, 3}R = {(1, 2), (2, 1), (2, 3)}

R is antitransitive

Page 78: Discrete Mathematics - Relations and Functions

Transitivity Examples

Example

R ⊆ Z× ZR = {(a, b) | ab ≥ 0}

R is nontransitive

Page 79: Discrete Mathematics - Relations and Functions

Converse Relation Properties

Theorem

The reflexivity, symmetry and transitivity propertiesare preserved in the converse relation.

Page 80: Discrete Mathematics - Relations and Functions

Closures

reflexive closure:rα = α ∪ E

symmetric closure:sα = α ∪ α−1

transitive closure:tα =

⋃i=1,2,3,... αi = α ∪ α2 ∪ α3 ∪ · · ·

Page 81: Discrete Mathematics - Relations and Functions

Closures

reflexive closure:rα = α ∪ E

symmetric closure:sα = α ∪ α−1

transitive closure:tα =

⋃i=1,2,3,... αi = α ∪ α2 ∪ α3 ∪ · · ·

Page 82: Discrete Mathematics - Relations and Functions

Closures

reflexive closure:rα = α ∪ E

symmetric closure:sα = α ∪ α−1

transitive closure:tα =

⋃i=1,2,3,... αi = α ∪ α2 ∪ α3 ∪ · · ·

Page 83: Discrete Mathematics - Relations and Functions

Special Relations

predecessor - successor

R ⊆ Z× ZR = {(a, b) | a− b = 1}

irreflexive

antisymmetric

antitransitive

Page 84: Discrete Mathematics - Relations and Functions

Special Relations

adjacency

R ⊆ Z× ZR = {(a, b) | |a− b| = 1}

irreflexive

symmetric

antitransitive

Page 85: Discrete Mathematics - Relations and Functions

Special Relations

strict order

R ⊆ Z× ZR = {(a, b) | a < b}

irreflexive

antisymmetric

transitive

Page 86: Discrete Mathematics - Relations and Functions

Special Relations

partial order

R ⊆ Z× ZR = {(a, b) | a ≤ b}

reflexive

antisymmetric

transitive

Page 87: Discrete Mathematics - Relations and Functions

Special Relations

preorder

R ⊆ Z× ZR = {(a, b) | |a| ≤ |b|}

reflexive

asymmetric

transitive

Page 88: Discrete Mathematics - Relations and Functions

Special Relations

limited difference

R ⊆ Z× Z,m ∈ Z+

R = {(a, b) | |a− b| ≤ m}

reflexive

symmetric

nontransitive

Page 89: Discrete Mathematics - Relations and Functions

Special Relations

comparability

R ⊆ U× UR = {(a, b) | (a ⊆ b) ∨ (b ⊆ a)}

reflexive

symmetric

nontransitive

Page 90: Discrete Mathematics - Relations and Functions

Special Relations

sibling

irreflexive

symmetric

transitive

how can a relation be symmetric, transitive and nonreflexive?

Page 91: Discrete Mathematics - Relations and Functions

Special Relations

sibling

irreflexive

symmetric

transitive

how can a relation be symmetric, transitive and nonreflexive?

Page 92: Discrete Mathematics - Relations and Functions

Topics

1 RelationsIntroductionRelation PropertiesEquivalence Relations

2 FunctionsIntroductionPigeonhole PrincipleRecursion

Page 93: Discrete Mathematics - Relations and Functions

Compatibility Relations

Definition

compatibility relation: γ

reflexive

symmetric

when drawing, lines instead of arrows

matrix representation as a triangle matrix

αα−1 is a compatibility relation

Page 94: Discrete Mathematics - Relations and Functions

Compatibility Relations

Definition

compatibility relation: γ

reflexive

symmetric

when drawing, lines instead of arrows

matrix representation as a triangle matrix

αα−1 is a compatibility relation

Page 95: Discrete Mathematics - Relations and Functions

Compatibility Relations

Definition

compatibility relation: γ

reflexive

symmetric

when drawing, lines instead of arrows

matrix representation as a triangle matrix

αα−1 is a compatibility relation

Page 96: Discrete Mathematics - Relations and Functions

Compatibility Relation Example

Example

A = {a1, a2, a3, a4}R = {(a1, a1), (a2, a2),

(a3, a3), (a4, a4),

(a1, a2), (a2, a1),

(a2, a4), (a4, a2),

(a3, a4), (a4, a3)}

1 1 0 01 1 0 10 0 1 10 1 1 1

10 00 1 1

Page 97: Discrete Mathematics - Relations and Functions

Compatibility Relation Example

Example

A = {a1, a2, a3, a4}R = {(a1, a1), (a2, a2),

(a3, a3), (a4, a4),

(a1, a2), (a2, a1),

(a2, a4), (a4, a2),

(a3, a4), (a4, a3)}

1 1 0 01 1 0 10 0 1 10 1 1 1

10 00 1 1

Page 98: Discrete Mathematics - Relations and Functions

Compatibility Relation Example

Example (αα−1)

P: persons, L: languagesP = {p1, p2, p3, p4, p5, p6}L = {l1, l2, l3, l4, l5}

α ⊆ P × L

Mα =

1 1 0 0 01 1 0 0 00 0 1 0 11 0 1 1 00 0 0 1 00 1 1 0 0

Mα−1 =

1 1 0 1 0 01 1 0 0 0 10 0 1 1 0 10 0 0 1 1 00 0 1 0 0 0

Page 99: Discrete Mathematics - Relations and Functions

Compatibility Relation Example

Example (αα−1)

P: persons, L: languagesP = {p1, p2, p3, p4, p5, p6}L = {l1, l2, l3, l4, l5}

α ⊆ P × L

Mα =

1 1 0 0 01 1 0 0 00 0 1 0 11 0 1 1 00 0 0 1 00 1 1 0 0

Mα−1 =

1 1 0 1 0 01 1 0 0 0 10 0 1 1 0 10 0 0 1 1 00 0 1 0 0 0

Page 100: Discrete Mathematics - Relations and Functions

Compatibility Relation Example

Example (αα−1)

αα−1 ⊆ P × P

Mαα−1 =

1 1 0 1 0 11 1 0 1 0 10 0 1 1 0 11 1 1 1 1 10 0 0 1 1 01 1 1 1 0 1

Page 101: Discrete Mathematics - Relations and Functions

Compatibility Block

Definition

compatibility block: C ⊆ A∀a, b [a ∈ C ∧ b ∈ C → aγb]

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

Page 102: Discrete Mathematics - Relations and Functions

Compatibility Block

Definition

compatibility block: C ⊆ A∀a, b [a ∈ C ∧ b ∈ C → aγb]

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

Page 103: Discrete Mathematics - Relations and Functions

Compatibility Block

Definition

compatibility block: C ⊆ A∀a, b [a ∈ C ∧ b ∈ C → aγb]

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

Page 104: Discrete Mathematics - Relations and Functions

Compatibility Block Example

Example (αα−1)

C1 = {a4, a6}C2 = {a2, a4, a6}C3 = {a1, a2, a4, a6} (MCB)

Cγ(A) = {{a1, a2, a4, a6},{a3, a4, a6},{a4, a5}}

Page 105: Discrete Mathematics - Relations and Functions

Compatibility Block Example

Example (αα−1)

C1 = {a4, a6}C2 = {a2, a4, a6}C3 = {a1, a2, a4, a6} (MCB)

Cγ(A) = {{a1, a2, a4, a6},{a3, a4, a6},{a4, a5}}

Page 106: Discrete Mathematics - Relations and Functions

Compatibility Block Example

Example (αα−1)

C1 = {a4, a6}C2 = {a2, a4, a6}C3 = {a1, a2, a4, a6} (MCB)

Cγ(A) = {{a1, a2, a4, a6},{a3, a4, a6},{a4, a5}}

Page 107: Discrete Mathematics - Relations and Functions

Equivalence Relations

Definition

equivalence relation: ε

reflexive

symmetric

transitive

equivalence classes (partitions)

every element is a member of exactly one equivalence class

complete cover: Cε

Page 108: Discrete Mathematics - Relations and Functions

Equivalence Relations

Definition

equivalence relation: ε

reflexive

symmetric

transitive

equivalence classes (partitions)

every element is a member of exactly one equivalence class

complete cover: Cε

Page 109: Discrete Mathematics - Relations and Functions

Equivalence Relation Example

Example

R ⊆ Z× ZR = {(a, b) | ∃m ∈ Z [a− b = 5m]}

R partitions Z into 5 equivalence classes

Page 110: Discrete Mathematics - Relations and Functions

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 Relations7.4. Equivalence Relations and Partitions

Supplementary Reading: O’Donnell, Hall, Page

Chapter 10: Relations

Page 111: Discrete Mathematics - Relations and Functions

Topics

1 RelationsIntroductionRelation PropertiesEquivalence Relations

2 FunctionsIntroductionPigeonhole PrincipleRecursion

Page 112: Discrete Mathematics - Relations and Functions

Functions

Definition

function: f : X → Y∀x ∈ X ∀y1, y2 ∈ Y (x , y1), (x , y2) ∈ f ⇒ y1 = y2

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 X1 ⊆ Xsubset image: f (X1) = {f (x) | x ∈ X1}

Page 113: Discrete Mathematics - Relations and Functions

Functions

Definition

function: f : X → Y∀x ∈ X ∀y1, y2 ∈ Y (x , y1), (x , y2) ∈ f ⇒ y1 = y2

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 X1 ⊆ Xsubset image: f (X1) = {f (x) | x ∈ X1}

Page 114: Discrete Mathematics - Relations and Functions

Functions

Definition

function: f : X → Y∀x ∈ X ∀y1, y2 ∈ Y (x , y1), (x , y2) ∈ f ⇒ y1 = y2

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 X1 ⊆ Xsubset image: f (X1) = {f (x) | x ∈ X1}

Page 115: Discrete Mathematics - Relations and Functions

Subset Image Examples

Example

f : R → Rf (x) = x2

f (Z) = {0, 1, 4, 9, 16, . . . }

f ({−2, 1}) = {1, 4}

Page 116: Discrete Mathematics - Relations and Functions

Subset Image Examples

Example

f : R → Rf (x) = x2

f (Z) = {0, 1, 4, 9, 16, . . . }

f ({−2, 1}) = {1, 4}

Page 117: Discrete Mathematics - Relations and Functions

Function Properties

Definition

f : X → Y is one-to-one (or injective):∀x1, x2 ∈ X f (x1) = f (x2) ⇒ x1 = x2

Definition

f : X → Y is onto (or surjective):∀y ∈ Y ∃x ∈ X f (x) = y

f (X ) = Y

Definition

f : X → Y is bijective:f is one-to-one and onto

Page 118: Discrete Mathematics - Relations and Functions

Function Properties

Definition

f : X → Y is one-to-one (or injective):∀x1, x2 ∈ X f (x1) = f (x2) ⇒ x1 = x2

Definition

f : X → Y is onto (or surjective):∀y ∈ Y ∃x ∈ X f (x) = y

f (X ) = Y

Definition

f : X → Y is bijective:f is one-to-one and onto

Page 119: Discrete Mathematics - Relations and Functions

Function Properties

Definition

f : X → Y is one-to-one (or injective):∀x1, x2 ∈ X f (x1) = f (x2) ⇒ x1 = x2

Definition

f : X → Y is onto (or surjective):∀y ∈ Y ∃x ∈ X f (x) = y

f (X ) = Y

Definition

f : X → Y is bijective:f is one-to-one and onto

Page 120: Discrete Mathematics - Relations and Functions

One-to-one Function Examples

Example

f : R → Rf (x) = 3x + 7

f (x1) = f (x2)⇒ 3x1 + 7 = 3x2 + 7⇒ 3x1 = 3x2

⇒ x1 = x2

Counterexample

g : Z → Zg(x) = x4 − x

g(0) = 04 − 0 = 0g(1) = 14 − 1 = 0

Page 121: Discrete Mathematics - Relations and Functions

One-to-one Function Examples

Example

f : R → Rf (x) = 3x + 7

f (x1) = f (x2)⇒ 3x1 + 7 = 3x2 + 7⇒ 3x1 = 3x2

⇒ x1 = x2

Counterexample

g : Z → Zg(x) = x4 − x

g(0) = 04 − 0 = 0g(1) = 14 − 1 = 0

Page 122: Discrete Mathematics - Relations and Functions

One-to-one Function Examples

Example

f : R → Rf (x) = 3x + 7

f (x1) = f (x2)⇒ 3x1 + 7 = 3x2 + 7⇒ 3x1 = 3x2

⇒ x1 = x2

Counterexample

g : Z → Zg(x) = x4 − x

g(0) = 04 − 0 = 0g(1) = 14 − 1 = 0

Page 123: Discrete Mathematics - Relations and Functions

One-to-one Function Examples

Example

f : R → Rf (x) = 3x + 7

f (x1) = f (x2)⇒ 3x1 + 7 = 3x2 + 7⇒ 3x1 = 3x2

⇒ x1 = x2

Counterexample

g : Z → Zg(x) = x4 − x

g(0) = 04 − 0 = 0g(1) = 14 − 1 = 0

Page 124: Discrete Mathematics - Relations and Functions

One-to-one Function Examples

Example

f : R → Rf (x) = 3x + 7

f (x1) = f (x2)⇒ 3x1 + 7 = 3x2 + 7⇒ 3x1 = 3x2

⇒ x1 = x2

Counterexample

g : Z → Zg(x) = x4 − x

g(0) = 04 − 0 = 0g(1) = 14 − 1 = 0

Page 125: Discrete Mathematics - Relations and Functions

One-to-one Function Examples

Example

f : R → Rf (x) = 3x + 7

f (x1) = f (x2)⇒ 3x1 + 7 = 3x2 + 7⇒ 3x1 = 3x2

⇒ x1 = x2

Counterexample

g : Z → Zg(x) = x4 − x

g(0) = 04 − 0 = 0g(1) = 14 − 1 = 0

Page 126: Discrete Mathematics - Relations and Functions

One-to-one Function Examples

Example

f : R → Rf (x) = 3x + 7

f (x1) = f (x2)⇒ 3x1 + 7 = 3x2 + 7⇒ 3x1 = 3x2

⇒ x1 = x2

Counterexample

g : Z → Zg(x) = x4 − x

g(0) = 04 − 0 = 0g(1) = 14 − 1 = 0

Page 127: Discrete Mathematics - Relations and Functions

One-to-one Function Examples

Example

f : R → Rf (x) = 3x + 7

f (x1) = f (x2)⇒ 3x1 + 7 = 3x2 + 7⇒ 3x1 = 3x2

⇒ x1 = x2

Counterexample

g : Z → Zg(x) = x4 − x

g(0) = 04 − 0 = 0g(1) = 14 − 1 = 0

Page 128: Discrete Mathematics - Relations and Functions

Onto Function Examples

Example

f : R → Rf (x) = x3

Counterexample

f : Z → Zf (x) = 3x + 1

Page 129: Discrete Mathematics - Relations and Functions

Onto Function Examples

Example

f : R → Rf (x) = x3

Counterexample

f : Z → Zf (x) = 3x + 1

Page 130: Discrete Mathematics - Relations and Functions

Function Composition

Definition

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

Page 131: Discrete Mathematics - Relations and Functions

Function Composition

Definition

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

Page 132: Discrete Mathematics - Relations and Functions

Function Composition Examples

Example (commutativity)

f : R → Rf (x) = x2

g : R → Rg(x) = x + 5

g ◦ f : R → R(g ◦ f )(x) = x2 + 5

f ◦ g : R → R(f ◦ g)(x) = (x + 5)2

Page 133: Discrete Mathematics - Relations and Functions

Function Composition Examples

Example (commutativity)

f : R → Rf (x) = x2

g : R → Rg(x) = x + 5

g ◦ f : R → R(g ◦ f )(x) = x2 + 5

f ◦ g : R → R(f ◦ g)(x) = (x + 5)2

Page 134: Discrete Mathematics - Relations and Functions

Function Composition Examples

Example (commutativity)

f : R → Rf (x) = x2

g : R → Rg(x) = x + 5

g ◦ f : R → R(g ◦ f )(x) = x2 + 5

f ◦ g : R → R(f ◦ g)(x) = (x + 5)2

Page 135: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf is one-to-one ∧ g is one-to-one ⇒ g ◦ f is one-to-one

Proof.

(g ◦ f )(a1) = (g ◦ f )(a2)⇒ g(f (a1)) = g(f (a2))⇒ f (a1) = f (a2)⇒ a1 = a2

Page 136: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf is one-to-one ∧ g is one-to-one ⇒ g ◦ f is one-to-one

Proof.

(g ◦ f )(a1) = (g ◦ f )(a2)⇒ g(f (a1)) = g(f (a2))⇒ f (a1) = f (a2)⇒ a1 = a2

Page 137: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf is one-to-one ∧ g is one-to-one ⇒ g ◦ f is one-to-one

Proof.

(g ◦ f )(a1) = (g ◦ f )(a2)⇒ g(f (a1)) = g(f (a2))⇒ f (a1) = f (a2)⇒ a1 = a2

Page 138: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf is one-to-one ∧ g is one-to-one ⇒ g ◦ f is one-to-one

Proof.

(g ◦ f )(a1) = (g ◦ f )(a2)⇒ g(f (a1)) = g(f (a2))⇒ f (a1) = f (a2)⇒ a1 = a2

Page 139: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf is one-to-one ∧ g is one-to-one ⇒ g ◦ f is one-to-one

Proof.

(g ◦ f )(a1) = (g ◦ f )(a2)⇒ g(f (a1)) = g(f (a2))⇒ f (a1) = f (a2)⇒ a1 = a2

Page 140: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf 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

Page 141: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf 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

Page 142: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf 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

Page 143: Discrete Mathematics - Relations and Functions

Composite Function Theorems

Theorem

let f : X → Y , g : Y → Zf 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

Page 144: Discrete Mathematics - Relations and Functions

Identity Function

Definition

identity function: 1X

1X : X → X1X (x) = x

Page 145: Discrete Mathematics - Relations and Functions

Inverse Function

Definition

f : X → Y is invertible:∃f −1 : Y → X [f −1 ◦ f = 1X ∧ f ◦ f −1 = 1Y ]

f −1: inverse of function f

Page 146: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 147: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 148: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 149: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 150: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 151: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 152: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 153: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 154: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 155: Discrete Mathematics - Relations and Functions

Inverse Function Examples

Example

f : R → Rf (x) = 2x + 5

f −1 : R → Rf −1(x) = x−5

2

(f −1 ◦ f )(x) = f −1(f (x)) = f −1(2x + 5) = (2x+5)−52 = 2x

2 = x

(f ◦ f −1)(x) = f (f −1(x)) = f ( x−52 ) = 2 x−5

2 + 5 = (x − 5) + 5 = x

Page 156: Discrete Mathematics - Relations and Functions

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 = 1X ∧ f ◦ g = 1Y

h ◦ f = 1X ∧ f ◦ h = 1Y

h = h ◦ 1Y = h ◦ (f ◦ g) = (h ◦ f ) ◦ g = 1X ◦ g = g

Page 157: Discrete Mathematics - Relations and Functions

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 = 1X ∧ f ◦ g = 1Y

h ◦ f = 1X ∧ f ◦ h = 1Y

h = h ◦ 1Y = h ◦ (f ◦ g) = (h ◦ f ) ◦ g = 1X ◦ g = g

Page 158: Discrete Mathematics - Relations and Functions

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 = 1X ∧ f ◦ g = 1Y

h ◦ f = 1X ∧ f ◦ h = 1Y

h = h ◦ 1Y = h ◦ (f ◦ g) = (h ◦ f ) ◦ g = 1X ◦ g = g

Page 159: Discrete Mathematics - Relations and Functions

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 = 1X ∧ f ◦ g = 1Y

h ◦ f = 1X ∧ f ◦ h = 1Y

h = h ◦ 1Y = h ◦ (f ◦ g) = (h ◦ f ) ◦ g = 1X ◦ g = g

Page 160: Discrete Mathematics - Relations and Functions

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 = 1X ∧ f ◦ g = 1Y

h ◦ f = 1X ∧ f ◦ h = 1Y

h = h ◦ 1Y = h ◦ (f ◦ g) = (h ◦ f ) ◦ g = 1X ◦ g = g

Page 161: Discrete Mathematics - Relations and Functions

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 = 1X ∧ f ◦ g = 1Y

h ◦ f = 1X ∧ f ◦ h = 1Y

h = h ◦ 1Y = h ◦ (f ◦ g) = (h ◦ f ) ◦ g = 1X ◦ g = g

Page 162: Discrete Mathematics - Relations and Functions

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 = 1X ∧ f ◦ g = 1Y

h ◦ f = 1X ∧ f ◦ h = 1Y

h = h ◦ 1Y = h ◦ (f ◦ g) = (h ◦ f ) ◦ g = 1X ◦ g = g

Page 163: Discrete Mathematics - Relations and Functions

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 = 1X ∧ f ◦ g = 1Y

h ◦ f = 1X ∧ f ◦ h = 1Y

h = h ◦ 1Y = h ◦ (f ◦ g) = (h ◦ f ) ◦ g = 1X ◦ g = g

Page 164: Discrete Mathematics - Relations and Functions

Invertible Function

Theorem

A function is invertible if and only if it is one-to-one and onto.

Page 165: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 166: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 167: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 168: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 169: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 170: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 171: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 172: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 173: Discrete Mathematics - Relations and Functions

Invertible Function

If invertible then one-to-one.

f : A → B

f (a1) = f (a2)

⇒ f −1(f (a1)) = f −1(f (a2))

⇒ (f −1 ◦ f )(a1) = (f −1 ◦ f )(a2)

⇒ 1A(a1) = 1A(a2)

⇒ a1 = a2

If invertible then onto.

f : A → B

b

= 1B(b)

= (f ◦ f −1)(b)

= f (f −1(b))

Page 174: Discrete Mathematics - Relations and Functions

Invertible Function

If bijective then invertible.

f : A → B

f is onto ⇒ ∀b ∈ B ∃a ∈ A f (a) = b

let g : B → A be defined by a = g(b)

is it possible that g(b) = a1 6= a2 = g(b) ?

this would mean: f (a1) = b = f (a2)

but f is one-to-one

Page 175: Discrete Mathematics - Relations and Functions

Invertible Function

If bijective then invertible.

f : A → B

f is onto ⇒ ∀b ∈ B ∃a ∈ A f (a) = b

let g : B → A be defined by a = g(b)

is it possible that g(b) = a1 6= a2 = g(b) ?

this would mean: f (a1) = b = f (a2)

but f is one-to-one

Page 176: Discrete Mathematics - Relations and Functions

Invertible Function

If bijective then invertible.

f : A → B

f is onto ⇒ ∀b ∈ B ∃a ∈ A f (a) = b

let g : B → A be defined by a = g(b)

is it possible that g(b) = a1 6= a2 = g(b) ?

this would mean: f (a1) = b = f (a2)

but f is one-to-one

Page 177: Discrete Mathematics - Relations and Functions

Topics

1 RelationsIntroductionRelation PropertiesEquivalence Relations

2 FunctionsIntroductionPigeonhole PrincipleRecursion

Page 178: Discrete Mathematics - Relations and Functions

Pigeonhole Principle

Definition

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 → Yif |X | > |Y | then f cannot be one-to-one

∃x1, x2 ∈ X [x1 6= x2 ∧ f (x1) = f (x2)]

Page 179: Discrete Mathematics - Relations and Functions

Pigeonhole Principle

Definition

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 → Yif |X | > |Y | then f cannot be one-to-one

∃x1, x2 ∈ X [x1 6= x2 ∧ f (x1) = f (x2)]

Page 180: Discrete Mathematics - Relations and Functions

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 thatat least two students will have the same grade?

Page 181: Discrete Mathematics - Relations and Functions

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 thatat least two students will have the same grade?

Page 182: Discrete Mathematics - Relations and Functions

Generalized Pigeonhole Principle

Definition

Generalized Pigeonhole Principle:If m objects are distributed to n drawers,then at least one of the drawers contains dm/ne objects.

Example

Among 100 people, at least 9 (d100/12e) were bornin the same month.

Page 183: Discrete Mathematics - Relations and Functions

Generalized Pigeonhole Principle

Definition

Generalized Pigeonhole Principle:If m objects are distributed to n drawers,then at least one of the drawers contains dm/ne objects.

Example

Among 100 people, at least 9 (d100/12e) were bornin the same month.

Page 184: Discrete Mathematics - Relations and Functions

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.

Page 185: Discrete Mathematics - Relations and Functions

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 elementsin all nonempty subsets of S cannot be all different.

Proof Trial

A ⊆ SsA : sum of the elements of A

holes:1 ≤ sA ≤ 9 + · · ·+ 14 = 69

pigeons: 26 − 1 = 63

Proof.

look at the subsets for which|A| ≤ 5

holes:1 ≤ sA ≤ 10 + · · ·+ 14 = 60

pigeons: 26 − 2 = 62

Page 186: Discrete Mathematics - Relations and Functions

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 elementsin all nonempty subsets of S cannot be all different.

Proof Trial

A ⊆ SsA : sum of the elements of A

holes:1 ≤ sA ≤ 9 + · · ·+ 14 = 69

pigeons: 26 − 1 = 63

Proof.

look at the subsets for which|A| ≤ 5

holes:1 ≤ sA ≤ 10 + · · ·+ 14 = 60

pigeons: 26 − 2 = 62

Page 187: Discrete Mathematics - Relations and Functions

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 elementsin all nonempty subsets of S cannot be all different.

Proof Trial

A ⊆ SsA : sum of the elements of A

holes:1 ≤ sA ≤ 9 + · · ·+ 14 = 69

pigeons: 26 − 1 = 63

Proof.

look at the subsets for which|A| ≤ 5

holes:1 ≤ sA ≤ 10 + · · ·+ 14 = 60

pigeons: 26 − 2 = 62

Page 188: Discrete Mathematics - Relations and Functions

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 elementsin all nonempty subsets of S cannot be all different.

Proof Trial

A ⊆ SsA : sum of the elements of A

holes:1 ≤ sA ≤ 9 + · · ·+ 14 = 69

pigeons: 26 − 1 = 63

Proof.

look at the subsets for which|A| ≤ 5

holes:1 ≤ sA ≤ 10 + · · ·+ 14 = 60

pigeons: 26 − 2 = 62

Page 189: Discrete Mathematics - Relations and Functions

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 elementsin all nonempty subsets of S cannot be all different.

Proof Trial

A ⊆ SsA : sum of the elements of A

holes:1 ≤ sA ≤ 9 + · · ·+ 14 = 69

pigeons: 26 − 1 = 63

Proof.

look at the subsets for which|A| ≤ 5

holes:1 ≤ sA ≤ 10 + · · ·+ 14 = 60

pigeons: 26 − 2 = 62

Page 190: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

There is at least one pair of elements among 101 elementschosen from set S = {1, 2, 3, . . . , 200},so that one of the elements of the pair divides the other.

Proof Method

we first show that∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

then, by using this theorem we prove the main theorem

Page 191: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

There is at least one pair of elements among 101 elementschosen from set S = {1, 2, 3, . . . , 200},so that one of the elements of the pair divides the other.

Proof Method

we first show that∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

then, by using this theorem we prove the main theorem

Page 192: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 193: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 194: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 195: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 196: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 197: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 198: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 199: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 200: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 201: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 202: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 203: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

∀n ∃!p [n = 2rp ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]

Proof of existence.

n = 1: r = 0, p = 1n ≤ k: assume n = 2rpn = k + 1:n = 2 : r = 1, p = 1n prime (n > 2) : r = 0, p = n¬(n prime) : n = n1n2

n = 2r1p1 · 2r2p2

n = 2r1+r2 · p1p2

Proof of uniqueness.

if not unique:

n = 2r1p1 = 2r2p2

⇒ 2r1−r2p1 = p2

⇒ 2|p2

Page 204: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

There is at least one pair of elements among 101 elementschosen 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 olsuns = 2r t → f (s) = t

if 101 elements are chosen from S , at least two of themwill have the same image in T : f (s1) = f (s2) ⇒ 2m1t = 2m2t

s1s2

=2m1t

2m2t= 2m1−m2

Page 205: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

There is at least one pair of elements among 101 elementschosen 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 olsuns = 2r t → f (s) = t

if 101 elements are chosen from S , at least two of themwill have the same image in T : f (s1) = f (s2) ⇒ 2m1t = 2m2t

s1s2

=2m1t

2m2t= 2m1−m2

Page 206: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

There is at least one pair of elements among 101 elementschosen 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 olsuns = 2r t → f (s) = t

if 101 elements are chosen from S , at least two of themwill have the same image in T : f (s1) = f (s2) ⇒ 2m1t = 2m2t

s1s2

=2m1t

2m2t= 2m1−m2

Page 207: Discrete Mathematics - Relations and Functions

Pigeonhole Principle Example

Theorem

There is at least one pair of elements among 101 elementschosen 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 olsuns = 2r t → f (s) = t

if 101 elements are chosen from S , at least two of themwill have the same image in T : f (s1) = f (s2) ⇒ 2m1t = 2m2t

s1s2

=2m1t

2m2t= 2m1−m2

Page 208: Discrete Mathematics - Relations and Functions

Topics

1 RelationsIntroductionRelation PropertiesEquivalence Relations

2 FunctionsIntroductionPigeonhole PrincipleRecursion

Page 209: Discrete Mathematics - Relations and Functions

Recursive Functions

Definition

recursive function: a function defined in terms of itself

f (n) = h(f (m))

inductively defined function: a recursive functionwhere the size is reduced at every step

f (n) =

{k n = 0h(f (n − 1)) n > 0

Page 210: Discrete Mathematics - Relations and Functions

Recursion Examples

Example

f 91(n) =

{n − 10 n > 100f 91(f 91(n + 11)) n ≤ 100

Example (factorial)

f (n) =

{1 n = 0n · f (n − 1) n > 0

Page 211: Discrete Mathematics - Relations and Functions

Recursion Examples

Example

f 91(n) =

{n − 10 n > 100f 91(f 91(n + 11)) n ≤ 100

Example (factorial)

f (n) =

{1 n = 0n · f (n − 1) n > 0

Page 212: Discrete Mathematics - Relations and Functions

Euclid Algorithm

Example (greatest common divisor)

gcd(a, b) =

{b b|agcd(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

Page 213: Discrete Mathematics - Relations and Functions

Euclid Algorithm

Example (greatest common divisor)

gcd(a, b) =

{b b|agcd(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

Page 214: Discrete Mathematics - Relations and Functions

Fibonacci Series

Fibonacci series

Fn = fib(n) =

1 n = 11 n = 2fib(n − 1) + fib(n − 2) n > 2

F1 F2 F3 F4 F5 F6 F7 F8 . . .1 1 2 3 5 8 13 21 . . .

Page 215: Discrete Mathematics - Relations and Functions

Fibonacci Series

Theorem∑ni=1 Fi

2 = Fn · Fn+1

Proof.

n = 2 :∑2

i=1 Fi2 = F1

2 + F22 = 1 + 1 = 1 · 2 = F2 · F3

n = k :∑k

i=1 Fi2 = Fk · Fk+1

n = k + 1 :∑k+1

i=1 Fi2 =

∑ki=1 Fi

2 + Fk+12

= Fk · Fk+1 + Fk+12

= Fk+1 · (Fk + Fk+1)

= Fk+1 · Fk+2

Page 216: Discrete Mathematics - Relations and Functions

Fibonacci Series

Theorem∑ni=1 Fi

2 = Fn · Fn+1

Proof.

n = 2 :∑2

i=1 Fi2 = F1

2 + F22 = 1 + 1 = 1 · 2 = F2 · F3

n = k :∑k

i=1 Fi2 = Fk · Fk+1

n = k + 1 :∑k+1

i=1 Fi2 =

∑ki=1 Fi

2 + Fk+12

= Fk · Fk+1 + Fk+12

= Fk+1 · (Fk + Fk+1)

= Fk+1 · Fk+2

Page 217: Discrete Mathematics - Relations and Functions

Fibonacci Series

Theorem∑ni=1 Fi

2 = Fn · Fn+1

Proof.

n = 2 :∑2

i=1 Fi2 = F1

2 + F22 = 1 + 1 = 1 · 2 = F2 · F3

n = k :∑k

i=1 Fi2 = Fk · Fk+1

n = k + 1 :∑k+1

i=1 Fi2 =

∑ki=1 Fi

2 + Fk+12

= Fk · Fk+1 + Fk+12

= Fk+1 · (Fk + Fk+1)

= Fk+1 · Fk+2

Page 218: Discrete Mathematics - Relations and Functions

Fibonacci Series

Theorem∑ni=1 Fi

2 = Fn · Fn+1

Proof.

n = 2 :∑2

i=1 Fi2 = F1

2 + F22 = 1 + 1 = 1 · 2 = F2 · F3

n = k :∑k

i=1 Fi2 = Fk · Fk+1

n = k + 1 :∑k+1

i=1 Fi2 =

∑ki=1 Fi

2 + Fk+12

= Fk · Fk+1 + Fk+12

= Fk+1 · (Fk + Fk+1)

= Fk+1 · Fk+2

Page 219: Discrete Mathematics - Relations and Functions

Fibonacci Series

Theorem∑ni=1 Fi

2 = Fn · Fn+1

Proof.

n = 2 :∑2

i=1 Fi2 = F1

2 + F22 = 1 + 1 = 1 · 2 = F2 · F3

n = k :∑k

i=1 Fi2 = Fk · Fk+1

n = k + 1 :∑k+1

i=1 Fi2 =

∑ki=1 Fi

2 + Fk+12

= Fk · Fk+1 + Fk+12

= Fk+1 · (Fk + Fk+1)

= Fk+1 · Fk+2

Page 220: Discrete Mathematics - Relations and Functions

Fibonacci Series

Theorem∑ni=1 Fi

2 = Fn · Fn+1

Proof.

n = 2 :∑2

i=1 Fi2 = F1

2 + F22 = 1 + 1 = 1 · 2 = F2 · F3

n = k :∑k

i=1 Fi2 = Fk · Fk+1

n = k + 1 :∑k+1

i=1 Fi2 =

∑ki=1 Fi

2 + Fk+12

= Fk · Fk+1 + Fk+12

= Fk+1 · (Fk + Fk+1)

= Fk+1 · Fk+2

Page 221: Discrete Mathematics - Relations and Functions

Fibonacci Series

Theorem∑ni=1 Fi

2 = Fn · Fn+1

Proof.

n = 2 :∑2

i=1 Fi2 = F1

2 + F22 = 1 + 1 = 1 · 2 = F2 · F3

n = k :∑k

i=1 Fi2 = Fk · Fk+1

n = k + 1 :∑k+1

i=1 Fi2 =

∑ki=1 Fi

2 + Fk+12

= Fk · Fk+1 + Fk+12

= Fk+1 · (Fk + Fk+1)

= Fk+1 · Fk+2

Page 222: Discrete Mathematics - Relations and Functions

Ackermann Function

Ackermann function

ack(x , y) =

y + 1 x = 0ack(x − 1, 1) y = 0ack(x − 1, ack(x , y − 1)) x > 0 ∧ y > 0

Page 223: Discrete Mathematics - Relations and Functions

References

Required Reading: Grimaldi

Chapter 5: Relations and Functions

5.2. Functions: Plain and One-to-One5.3. Onto Functions: Stirling Numbers of the Second Kind5.5. The Pigeonhole Principle5.6. Function Composition and Inverse Functions

Supplementary Reading: O’Donnell, Hall, Page

Chapter 11: Functions