Relations Functions

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

License

c 2001-2016 T. Uyar, A. Yayımlı, E. Harmancı

Discrete Mathematics You are free to:


I Share – copy and redistribute the material in any medium or format
Relations and Functions
I Adapt – remix, transform, and build upon the material

Under the following terms:


H. Turgut Uyar Ayşegül Gençata Yayımlı Emre Harmancı I Attribution – You must give appropriate credit, provide a link to the license,
and indicate if changes were made.
I NonCommercial – You may not use the material for commercial purposes.
I ShareAlike – If you remix, transform, or build upon the material, you must
2001-2016
distribute your contributions under the same license as the original.
For more information:
https://creativecommons.org/licenses/by-nc-sa/4.0/
Read the full license:
https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode

1 / 79 2 / 79

Topics Relation

Relations
Introduction Definition
Relation Properties relation: α ⊆ A × B × C × · · · × N
Equivalence Relations I tuple: element of relation

Functions I binary relation: α ⊆ A × B


Introduction I aαb : (a, b) ∈ α
Pigeonhole Principle
Recursion

3 / 79 4 / 79
Relation Example Relation Composition

Definition
A = {a1 , a2 , a3 , a4 }, B = {b1 , b2 , b3 }
relation composition:
α = {(a1 , b1 ), (a1 , b3 ), (a2 , b2 ), (a2 , b3 ), (a3 , b1 ), (a3 , b3 ), (a4 , b1 )}
α ⊆ A × B, β ⊆ B × C
αβ = {(a, c) | a ∈ A, c ∈ C , ∃b ∈ B [aαb ∧ bβc]}
b1 b2 b3
1 0 1
a1 1 0 1 example
0 1 1
a2 0 1 1 Mα =
1 0 1
a3 1 0 1
1 0 0
a4 1 0 0

5 / 79 6 / 79

Relation Composition Relation Composition Associativity

I Mαβ = Mα × Mβ (αβ)γ = α(βγ).


I using logical operations:
1:T 0:F ·:∧ +:∨
(a, d) ∈ (αβ)γ
example ⇔ ∃c [(a, c) ∈ αβ ∧ (c, d) ∈ γ]
⇔ ∃c [∃b [(a, b) ∈ α ∧ (b, c) ∈ β] ∧ (c, d) ∈ γ]
1 0 0 1 1 0 0
⇔ ∃b [(a, b) ∈ α ∧ ∃c [(b, c) ∈ β ∧ (c, d) ∈ γ]]
0 0 1 1 1 0 0 0 1 1 0
Mα = 0 1 1 Mβ = 0 0 1 1 Mαβ = 0 1 1 1 ⇔ ∃b [(a, b) ∈ α ∧ (b, d) ∈ βγ]
0 1 0 0 1 1 0 0 0 1 1 ⇔ (a, d) ∈ α(βγ)
1 0 1 1 1 1 0

7 / 79 8 / 79
Relation Composition Theorems Converse Relation

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

(a, c) ∈ α(β ∪ γ)
Definition
⇔ ∃b [(a, b) ∈ α ∧ (b, c) ∈ (β ∪ γ)] α−1 = {(b, a) | (a, b) ∈ α}
⇔ ∃b [(a, b) ∈ α ∧ ((b, c) ∈ β ∨ (b, c) ∈ γ)]
I Mα−1 = MαT
⇔ ∃b [((a, b) ∈ α ∧ (b, c) ∈ β)
∨ ((a, b) ∈ α ∧ (b, c) ∈ γ)]
⇔ (a, c) ∈ αβ ∨ (a, c) ∈ αγ
⇔ (a, c) ∈ αβ ∪ αγ

9 / 79 10 / 79

Converse Relation Theorems Converse Relation Theorems

α−1 = α−1 .
I (α−1 )−1 = α
I (α ∪ β)−1 = α−1 ∪ β −1 (b, a) ∈ α−1
I (α ∩ β)−1 = α−1 ∩ β −1 ⇔ (a, b) ∈ α
I α−1 = α−1 ⇔ (a, b) ∈

I (α − β)−1 = α−1 − β −1 / α−1
⇔ (b, a) ∈
⇔ (b, a) ∈ α−1

11 / 79 12 / 79
Converse Relation Theorems Converse Relation Theorems

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

(b, a) ∈ (α ∩ β)−1
(α − β)−1 = (α ∩ β)−1
⇔ (a, b) ∈ (α ∩ β) −1
= α−1 ∩ β
⇔ (a, b) ∈ α ∧ (a, b) ∈ β
= α−1 ∩ β −1
⇔ (b, a) ∈ α−1 ∧ (b, a) ∈ β −1
= α−1 − β −1
⇔ (b, a) ∈ α−1 ∩ β −1

13 / 79 14 / 79

Relation Composition Converse Relation Properties

Theorem
(αβ)−1 = β −1 α−1
I α⊆A×A
Proof. I αn : αα · · · α
I identity relation: E = {(a, a) | a ∈ A}
−1
(c, a) ∈ (αβ)
⇔ (a, c) ∈ αβ I reflexivity
⇔ ∃b [(a, b) ∈ α ∧ (b, c) ∈ β] I symmetry
⇔ ∃b [(b, a) ∈ α−1 ∧ (c, b) ∈ β −1 ] I transitivity
⇔ (c, a) ∈ β −1 α−1

15 / 79 16 / 79
Reflexivity Reflexivity Examples

reflexive
α⊆A×A R1 ⊆ {1, 2} × {1, 2} R2 ⊆ {1, 2, 3} × {1, 2, 3}
∀a ∈ A [aαa] R1 = {(1, 1), (1, 2), (2, 2)} R2 = {(1, 1), (1, 2), (2, 2)}

I E ⊆α I R1 is reflexive I R2 is not reflexive


I irreflexive: I also not irreflexive
∀a ∈ A [¬(aαa)]

17 / 79 18 / 79

Reflexivity Examples Reflexivity Examples

R ⊆ {1, 2, 3} × {1, 2, 3} R⊆Z×Z


R = {(1, 2), (2, 1), (2, 3)} R = {(a, b) | ab ≥ 0}

I R is irreflexive I R is reflexive

19 / 79 20 / 79
Symmetry Symmetry Examples

symmetric
R ⊆ {1, 2, 3} × {1, 2, 3}
α⊆A×A R = {(1, 2), (2, 1), (2, 3)}
∀a, b ∈ A [aαb ↔ bαa]
I R is not symmetric
I α−1 = α
I also not antisymmetric
I antisymmetric:
∀a, b ∈ A [aαb ∧ bαa → a = b]

21 / 79 22 / 79

Symmetry Examples Symmetry Examples

R⊆Z×Z R ⊆ {1, 2, 3} × {1, 2, 3}


R = {(a, b) | ab ≥ 0} R = {(1, 1), (2, 2)}

I R is symmetric I R is symmetric and antisymmetric

23 / 79 24 / 79
Transitivity Transitivity Examples

transitive
α⊆A×A R ⊆ {1, 2, 3} × {1, 2, 3}
∀a, b, c ∈ A [aαb ∧ bαc → aαc] R = {(1, 2), (2, 1), (2, 3)}
I α2 ⊆ α I R is antitransitive
I antitransitive:
∀a, b, c ∈ A [aαb ∧ bαc → ¬(aαc)]

25 / 79 26 / 79

Transitivity Examples Converse Relation Properties

R⊆Z×Z
R = {(a, b) | ab ≥ 0} Theorem
Reflexivity, symmetry, and transitivity are preserved
I R is not transitive in the converse relation.
I also not antitransitive

27 / 79 28 / 79
Closures Special Relations

I reflexive closure: predecessor - successor


rα = α ∪ E R⊆Z×Z
I symmetric closure: R = {(a, b) | a − b = 1}
sα = α ∪ α−1
I irreflexive
I transitive
S closure: i I antisymmetric
tα = i=1,2,3,... α = α ∪ α2 ∪ α3 ∪ · · · I antitransitive

29 / 79 30 / 79

Special Relations Special Relations

adjacency strict order


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

I irreflexive I irreflexive
I symmetric I antisymmetric
I antitransitive I transitive

31 / 79 32 / 79
Special Relations Special Relations

partial order
preorder
R⊆Z×Z
R⊆Z×Z
R = {(a, b) | a ≤ b}
R = {(a, b) | |a| ≤ |b|}
I reflexive I reflexive
I antisymmetric I transitive
I transitive

33 / 79 34 / 79

Special Relations Special Relations

limited difference comparability


R ⊆ Z × Z, m ∈ Z+ R⊆U×U
R = {(a, b) | |a − b| ≤ m} R = {(a, b) | (a ⊆ b) ∨ (b ⊆ a)}

I reflexive I reflexive
I symmetric I symmetric

35 / 79 36 / 79
Special Relations Compatibility Relations

Definition
I siblings? compatibility relation: γ
I irreflexive
I reflexive
I symmetric
I symmetric
I transitive
I when drawing, lines instead of arrows
I matrix representation as a triangle matrix
I can a relation be symmetric and transitive, but irreflexive?
I αα−1 is a compatibility relation

37 / 79 38 / 79

Compatibility Relation Example Compatibility Relation Example

I P: persons, L: languages
I P = {p1 , p2 , p3 , p4 , p5 , p6 }
A = {a1 , a2 , a3 , a4 } 1 1 0 0 I L = {l1 , l2 , l3 , l4 , l5 }
R = {(a1 , a1 ), (a2 , a2 ), 1 1 0 1 I α⊆P ×L
0 0 1 1
(a3 , a3 ), (a4 , a4 ), 0 1 1 1
(a1 , a2 ), (a2 , a1 ), 1 1 0 0 0
1 1 0 1 0 0
1 1 0 0 0
(a2 , a4 ), (a4 , a2 ), 1 1 0 0 0 1
1 0 0 1 0 1
(a3 , a4 ), (a4 , a3 )} Mα = Mα−1 = 0 0 1 1 0 1
0 0 1 0 1 1 0
0 0 0 1 1 0
0 1 1 0 0 0 1 0
0 0 1 0 0 0
0 1 1 0 0

39 / 79 40 / 79
Compatibility Relation Example Compatibility Block

Definition
I αα−1 ⊆ P × P compatibility block: C ⊆ A
∀a, b [a ∈ C ∧ b ∈ C → aγb]
1 1 0 1 0 1
1 1 0 1 0 1 I maximal compatibility block:
0 0 1 1 0 1 not a subset of another compatibility block
Mαα−1 =
1 1 1 1 1 1 I an element can be a member of more than one MCB
0 0 0 1 1 0
1 1 1 1 0 1 I complete cover: Cγ
set of all MCBs

41 / 79 42 / 79

Compatibility Block Example Equivalence Relations

Definition
I C1 = {p4 , p6 }
equivalence relation: 
I C2 = {p2 , p4 , p6 } I reflexive
I C3 = {p1 , p2 , p4 , p6 } (MCB) I symmetric
I transitive

Cγ = {{p1 , p2 , p4 , p6 }, I equivalence classes (partitions)


{p3 , p4 , p6 }, I every element is a member of exactly one equivalence class
{p4 , p5 }}
I complete cover: C

43 / 79 44 / 79
Equivalence Relation Example References

Required Reading: Grimaldi


R⊆Z×Z
R = {(a, b) | ∃m ∈ Z [a − b = 5m]}
I Chapter 5: Relations and Functions
I 5.1. Cartesian Products and Relations
I Chapter 7: Relations: The Second Time Around
I R partitions Z into 5 equivalence classes I 7.1. Relations Revisited: Properties of Relations
I 7.4. Equivalence Relations and Partitions

45 / 79 46 / 79

Functions Subset Image Examples

Definition
function: f : X → Y
∀x ∈ X ∀y1 , y2 ∈ Y [(x, y1 ), (x, y2 ) ∈ f → y1 = y2 ] f :R→R
f (x) = x 2
I X : domain, Y : codomain (or range)
f (Z) = {0, 1, 4, 9, 16, . . . }
I y = f (x) : (x, y ) ∈ f
f ({−2, 1}) = {1, 4}
I y : image of x under f
I f : X → Y, X0 ⊆ X
subset image: f (X 0 ) = {f (x) | x ∈ X 0 }

47 / 79 48 / 79
One-to-One Functions One-to-One Function Examples

I one-to-one I not one-to-one


Definition f :R→R g :Z→Z
f : X → Y is one-to-one (or injective): f (x) = 3x + 7 g (x) = x 4 − x
∀x1 , x2 ∈ X [f (x1 ) = f (x2 ) → x1 = x2 ]
f (x1 ) = f (x2 ) g (0) = 04 − 0 = 0
⇒ 3x1 + 7 = 3x2 + 7 g (1) = 14 − 1 = 0
⇒ 3x1 = 3x2
⇒ x1 = x2

49 / 79 50 / 79

Onto Functions Onto Function Examples

Definition
f : X → Y is onto (or surjective): I onto I not onto
∀y ∈ Y ∃x ∈ X [f (x) = y ]
f :R→R f :Z→Z
I f (X ) = Y f (x) = x 3 f (x) = 3x + 1

51 / 79 52 / 79
Bijective Functions Function Composition

Definition
f : X → Y,g : Y → Z
Definition
g ◦f :X →Z
f : X → Y is bijective:
(g ◦ f )(x) = g (f (x))
f is one-to-one and onto
I not commutative
I associative: f ◦ (g ◦ h) = (f ◦ g ) ◦ h

53 / 79 54 / 79

Composition Commutativity Example Composite Function Theorems

f :R→R Theorem
f (x) = x 2 f : X → Y,g : Y → Z
f is one-to-one ∧ g is one-to-one ⇒ g ◦ f is one-to-one
g :R→R
g (x) = x + 5 Proof.

g ◦f :R→R (g ◦ f )(x1 ) = (g ◦ f )(x2 )


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

55 / 79 56 / 79
Composite Function Theorems Identity Function

Theorem
f : X → Y,g : Y → Z Definition
f is onto ∧ g is onto ⇒ g ◦ f is onto identity function: 1X
Proof. 1X : X → X
∀z ∈ Z ∃y ∈ Y g (y ) = z 1X (x) = x
∀y ∈ Y ∃x ∈ X f (x) = y
⇒ ∀z ∈ Z ∃x ∈ X g (f (x)) = z

57 / 79 58 / 79

Inverse Function Inverse Function Examples

f :R→R
f (x) = 2x + 5
Definition
f : X → Y is invertible: f −1 : R → R
∃f −1 : Y → X [f −1 ◦ f = 1X ∧ f ◦ f −1 = 1Y ] f −1 (x) = x−5
2
I f −1 : inverse of function f
(2x+5)−5
(f −1 ◦ f )(x) = f −1 (f (x)) = f −1 (2x + 5) = 2 = 2x
2 =x
(f ◦ f −1 )(x) = f (f −1 (x)) = f ( x−5 x−5
2 ) = 2 2 + 5 = (x − 5) + 5 = x

59 / 79 60 / 79
Inverse Function Invertible Function

Theorem
If a function is invertible, its inverse is unique.

Proof. Theorem
f :X →Y A function is invertible if and only if it is one-to-one and onto.
g, h : Y → X
g ◦ f = 1X ∧ f ◦ g = 1Y
h ◦ f = 1X ∧ f ◦ h = 1Y
h = h ◦ 1Y = h ◦ (f ◦ g ) = (h ◦ f ) ◦ g = 1X ◦ g = g

61 / 79 62 / 79

Invertible Function Invertible Function

If bijective then invertible.


If invertible then one-to-one. If invertible then onto.
f :X →Y f :X →Y f :X →Y
I f is onto ⇒ ∀y ∈ Y ∃x ∈ X f (x) = y
f (x1 ) = f (x2 ) y I let g : Y → X be defined by x = g (y )
⇒ f −1 (f (x1 )) = f −1 (f (x2 )) = 1Y (y )
I is it possible that g (y ) = x1 6= x2 = g (y ) ?
⇒ (f −1 ◦ f )(x1 ) = (f −1 ◦ f )(x2 ) = (f ◦ f −1 )(y )
I this would mean: f (x1 ) = y = f (x2 )
⇒ 1X (x1 ) = 1X (x2 ) = f (f −1 (y ))
I but f is one-to-one
⇒ x1 = x2

63 / 79 64 / 79
Pigeonhole Principle Pigeonhole Principle Examples

Definition
pigeonhole principle (Dirichlet drawers): I Among 367 people, at least two have the same birthday.
If m pigeons go into n holes and m > n,
then at least one hole contains more than one pigeon. I In an exam where the grades are integers between 0 and 100,
how many students have to take the exam to make sure that
I f :X →Y at least two students will have the same grade?
|X | > |Y | ⇒ f is not one-to-one
I ∃x1 , x2 ∈ X [x1 6= x2 ∧ f (x1 ) = f (x2 )]

65 / 79 66 / 79

Generalized Pigeonhole Principle Pigeonhole Principle Example

Definition
generalized pigeonhole principle:
If m objects are distributed to n drawers, Theorem
then at least one of the drawers contains dm/ne objects. S = {1, 2, 3, . . . , 9}, T ⊂ S, |T | = 6
∃s1 , s2 ∈ T [s1 + s2 = 10]
example
Among 100 people, at least d100/12e = 9 were born
in the same month.

67 / 79 68 / 79
Pigeonhole Principle Example Pigeonhole Principle Example

Theorem
S ⊆ Z+ , ∀a ∈ S [a ≤ 14], |S| = 6
T = P(S) − ∅
Theorem
X = {ΣA | A ∈ T }, ΣA : sum of the elements in A
S = {1, 2, 3, . . . , 200}, T ⊂ S, |T | = 101
|X | < |T |
∃s1 , s2 ∈ T [s2 |s1 ]
I first, show that:
Proof Attempt Proof.
∀n ∃!p [n = 2r p ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]]
consider T − S
I holes: I then, use this to prove the main theorem
1 ≤ ΣA ≤ 9 + · · · + 14 = 69 I holes:
I pigeons: 26 − 1 = 63 1 ≤ sA ≤ 10 + · · · + 14 = 60
I pigeons: 26 − 2 = 62

69 / 79 70 / 79

Pigeonhole Principle Example Pigeonhole Principle Example

Theorem Theorem
∀n ∃!p [n = 2r p ∧ r ∈ N ∧ ∃t ∈ Z [p = 2t + 1]] S = {1, 2, 3, . . . , 200}, T ⊂ S, |T | = 101
∃s1 , s2 ∈ T [s2 |s1 ]
Proof of existence. Proof of uniqueness. Proof.
n = 1: r = 0, p = 1 if not unique: I P = {p | p ∈ S, ∃i ∈ Z [p = 2i + 1]}, |P| = 100
n ≤ k: assume n = 2r p
n = k + 1: I f : S → P, r ∈ N, s = 2r p → f (s) = p
n=2: r = 1, p = 1 n = 2r1 p1 = 2r2 p2 I |T | = 101 ⇒ at least two elements have the same image in P:
⇒ 2r1 −r2 p1 = p2
n prime (n > 2) : r = 0, p = n f (s1 ) = f (s2 ) ⇒ 2r1 p = 2r2 p
¬(n prime) : n = n1 n2 ⇒ 2|p2
n = 2r1 p1 · 2r2 p2 s1 2r1 p
= r = 2r1 −r2
n = 2r1 +r2 · p1 p2 s2 2 2p

71 / 79 72 / 79
Recursive Functions Recursion Examples

Definition
recursive function: a function defined in terms of itself (
n − 10 if n > 100
f (n) = h(f (m)) f 91(n) =
f 91(f 91(n + 11)) if n ≤ 100
I inductively defined function: a recursive function
where the size is reduced at every step (
1 if n = 0
n! =
( n · (n − 1)! if n > 0
k if n = 0
f (n) =
h(f (n − 1)) if n > 0

73 / 79 74 / 79

Greatest Common Divisor Fibonacci Sequence

(
b if b | a
gcd(a, b) =
gcd(b, a mod b) if b - a 
1
 if n = 1
Fn = fib(n) = 1 if n = 2

gcd(333, 84) = gcd(84, 333 mod 84) 
fib(n − 2) + fib(n − 1) if n > 2
= gcd(84, 81)
= gcd(81, 84 mod 81) F1 F2 F3 F4 F5 F6 F7 F8 . . .
= gcd(81, 3) 1 1 2 3 5 8 13 21 . . .
= 3

75 / 79 76 / 79
Fibonacci Sequence Ackermann Function

Theorem
P n 2
i=1 Fi = Fn · Fn+1

Proof. P2 
2
n=2: i=1 Fi = F1 2 + F2 2 = 1 + 1 = 1 · 2 = F2 · F3 y + 1
 if x = 0
Pk 2 ack(x, y ) = ack(x − 1, 1) if y = 0
n=k: i=1 Fi = Fk · Fk+1 
ack(x − 1, ack(x, y − 1)) if x > 0 ∧ y > 0

Pk+1 2 Pk 2 2
n =k +1: i=1 Fi = i=1 Fi + Fk+1
= Fk · Fk+1 + Fk+1 2
= Fk+1 · (Fk + Fk+1 )
= Fk+1 · Fk+2

77 / 79 78 / 79

References

Required Reading: Grimaldi


I Chapter 5: Relations and Functions
I 5.2. Functions: Plain and One-to-One
I 5.3. Onto Functions: Stirling Numbers of the Second Kind
I 5.5. The Pigeonhole Principle
I 5.6. Function Composition and Inverse Functions

79 / 79

You might also like