Functions Assume A and B are non-empty sets Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 7 / 38
Functions Assume A and B are non-empty sets A function f from A to B is an assignment of exactly one element of B to each element of A Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 7 / 38
Functions Assume A and B are non-empty sets A function f from A to B is an assignment of exactly one element of B to each element of A f ( a ) = b if f assigns b to a Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 7 / 38
Functions Assume A and B are non-empty sets A function f from A to B is an assignment of exactly one element of B to each element of A f ( a ) = b if f assigns b to a f : A → B if f is a function from A to B Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 7 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Is the function √· : Z + → R + injective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Is the function √· : Z + → R + injective? YES Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Is the function √· : Z + → R + injective? YES Is the squaring function · 2 : Z → Z injective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Is the function √· : Z + → R + injective? YES Is the squaring function · 2 : Z → Z injective? NO Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Is the function √· : Z + → R + injective? YES Is the squaring function · 2 : Z → Z injective? NO Is the function | · | : R → R injective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Is the function √· : Z + → R + injective? YES Is the squaring function · 2 : Z → Z injective? NO Is the function | · | : R → R injective? NO Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Is the function √· : Z + → R + injective? YES Is the squaring function · 2 : Z → Z injective? NO Is the function | · | : R → R injective? NO Assume m > 1. Is mod m : Z → { 0 , . . . , m − 1 } injective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
One-to-one or injective functions Definition f : A → B is injective iff ∀ a , c ∈ A (if f ( a ) = f ( c ) then a = c ) Is the identity function ι A : A → A injective? YES Is the function √· : Z + → R + injective? YES Is the squaring function · 2 : Z → Z injective? NO Is the function | · | : R → R injective? NO Assume m > 1. Is mod m : Z → { 0 , . . . , m − 1 } injective? NO Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Is the function √· : Z + → R + surjective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Is the function √· : Z + → R + surjective? NO Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Is the function √· : Z + → R + surjective? NO Is the function · 2 : Z → Z surjective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Is the function √· : Z + → R + surjective? NO Is the function · 2 : Z → Z surjective? NO Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Is the function √· : Z + → R + surjective? NO Is the function · 2 : Z → Z surjective? NO Is the function | · | : R → R surjective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Is the function √· : Z + → R + surjective? NO Is the function · 2 : Z → Z surjective? NO Is the function | · | : R → R surjective? NO Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Is the function √· : Z + → R + surjective? NO Is the function · 2 : Z → Z surjective? NO Is the function | · | : R → R surjective? NO Assume m > 1. Is mod m : Z → { 0 , . . . , m − 1 } surjective? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
Onto or surjective functions Definition f : A → B is surjective iff ∀ b ∈ B ∃ a ∈ A ( f ( a ) = b ) Is the identity function ι A : A → A surjective? YES Is the function √· : Z + → R + surjective? NO Is the function · 2 : Z → Z surjective? NO Is the function | · | : R → R surjective? NO Assume m > 1. Is mod m : Z → { 0 , . . . , m − 1 } surjective? YES Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Is the identity function ι A : A → A a bijection? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Is the identity function ι A : A → A a bijection? YES Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Is the identity function ι A : A → A a bijection? YES Is the function √· : R + → R + a bijection? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Is the identity function ι A : A → A a bijection? YES Is the function √· : R + → R + a bijection? YES Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Is the identity function ι A : A → A a bijection? YES Is the function √· : R + → R + a bijection? YES Is the function · 2 : R → R a bijection? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Is the identity function ι A : A → A a bijection? YES Is the function √· : R + → R + a bijection? YES Is the function · 2 : R → R a bijection? NO Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Is the identity function ι A : A → A a bijection? YES Is the function √· : R + → R + a bijection? YES Is the function · 2 : R → R a bijection? NO Is the function | · | : R → R a bijection? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
One-to-one correspondence or bijection Definition f : A → B is a bijection iff it is both injective and surjective Is the identity function ι A : A → A a bijection? YES Is the function √· : R + → R + a bijection? YES Is the function · 2 : R → R a bijection? NO Is the function | · | : R → R a bijection? NO Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38
Function composition Definition Let f : B → C and g : A → B . The composition function f ◦ g : A → C is ( f ◦ g )( a ) = f ( g ( a )) Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 11 / 38
Results about function composition Theorem The composition of two functions is a function Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 12 / 38
Results about function composition Theorem The composition of two functions is a function Theorem The composition of two injective functions is an injective function Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 12 / 38
Results about function composition Theorem The composition of two functions is a function Theorem The composition of two injective functions is an injective function Theorem The composition of two surjective functions is a surjective function Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 12 / 38
Results about function composition Theorem The composition of two functions is a function Theorem The composition of two injective functions is an injective function Theorem The composition of two surjective functions is a surjective function Corollary The composition of two bijections is a bijection Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 12 / 38
Inverse function Definition If f : A → B is a bijection, then the inverse of f , written f − 1 : B → A is f − 1 ( b ) = a iff f ( a ) = b f –1 ( b ) a = f –1 ( b ) b = f ( a ) f ( a ) f –1 A B f 1 Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 13 / 38
Inverse function Definition If f : A → B is a bijection, then the inverse of f , written f − 1 : B → A is f − 1 ( b ) = a iff f ( a ) = b f –1 ( b ) a = f –1 ( b ) b = f ( a ) f ( a ) f –1 A B f 1 What is the inverse of ι A : A → A ? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 13 / 38
Inverse function Definition If f : A → B is a bijection, then the inverse of f , written f − 1 : B → A is f − 1 ( b ) = a iff f ( a ) = b f –1 ( b ) a = f –1 ( b ) b = f ( a ) f ( a ) f –1 A B f 1 What is the inverse of ι A : A → A ? What is the inverse of √· : R + → R + ? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 13 / 38
Inverse function Definition If f : A → B is a bijection, then the inverse of f , written f − 1 : B → A is f − 1 ( b ) = a iff f ( a ) = b f –1 ( b ) a = f –1 ( b ) b = f ( a ) f ( a ) f –1 A B f 1 What is the inverse of ι A : A → A ? What is the inverse of √· : R + → R + ? What is f − 1 ◦ f ? and f ◦ f − 1 ? Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 13 / 38
The floor and ceiling functions Definition The floor function ⌊ ⌋ : R → Z is ⌊ x ⌋ equals the largest integer less than or equal to x Definition The ceiling function ⌈ ⌉ : R → Z is ⌈ x ⌉ equals the smallest integer greater than or equal to x Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 14 / 38
The floor and ceiling functions Definition The floor function ⌊ ⌋ : R → Z is ⌊ x ⌋ equals the largest integer less than or equal to x Definition The ceiling function ⌈ ⌉ : R → Z is ⌈ x ⌉ equals the smallest integer greater than or equal to x � 1 � � − 1 � = = ⌊ 0 ⌋ = ⌈ 0 ⌉ = 0 2 2 Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 14 / 38
The floor and ceiling functions Definition The floor function ⌊ ⌋ : R → Z is ⌊ x ⌋ equals the largest integer less than or equal to x Definition The ceiling function ⌈ ⌉ : R → Z is ⌈ x ⌉ equals the smallest integer greater than or equal to x � 1 � � − 1 � = = ⌊ 0 ⌋ = ⌈ 0 ⌉ = 0 2 2 ⌊− 6 . 1 ⌋ = − 7 ⌈ 6 . 1 ⌉ = 7 Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 14 / 38
The factorial function Definition The factorial function f : N → N , denoted as f ( n ) = n ! assigns to n the product of the first n positive integers f ( 0 ) = 0 ! = 1 and f ( n ) = n ! = 1 · 2 · · · · · ( n − 1 ) · n Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 15 / 38
Relations Definition A binary relation R on sets A and B is a subset R ⊆ A × B Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38
Relations Definition A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples ( a , b ) with a ∈ A and b ∈ B Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38
Relations Definition A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples ( a , b ) with a ∈ A and b ∈ B Often we write a R b for ( a , b ) ∈ R Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38
Relations Definition A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples ( a , b ) with a ∈ A and b ∈ B Often we write a R b for ( a , b ) ∈ R A function f is a restricted relation where ∀ a ∈ A ∃ b ∈ B ((( a , b ) ∈ f ) ∧ ∀ c ∈ B (( a , c ) ∈ f → c = b )) Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38
Relations Definition A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples ( a , b ) with a ∈ A and b ∈ B Often we write a R b for ( a , b ) ∈ R A function f is a restricted relation where ∀ a ∈ A ∃ b ∈ B ((( a , b ) ∈ f ) ∧ ∀ c ∈ B (( a , c ) ∈ f → c = b )) R is a relation on A if B = A (so, R ⊆ A × A ) Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38
Relations Definition A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples ( a , b ) with a ∈ A and b ∈ B Often we write a R b for ( a , b ) ∈ R A function f is a restricted relation where ∀ a ∈ A ∃ b ∈ B ((( a , b ) ∈ f ) ∧ ∀ c ∈ B (( a , c ) ∈ f → c = b )) R is a relation on A if B = A (so, R ⊆ A × A ) Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38
Relations Definition A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples ( a , b ) with a ∈ A and b ∈ B Often we write a R b for ( a , b ) ∈ R A function f is a restricted relation where ∀ a ∈ A ∃ b ∈ B ((( a , b ) ∈ f ) ∧ ∀ c ∈ B (( a , c ) ∈ f → c = b )) R is a relation on A if B = A (so, R ⊆ A × A ) Definition Given sets A 1 , . . . , A n a subset R ⊆ A 1 × · · · × A n is an n -ary relation Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38
Examples R ⊆ A × B , A students, B courses; (A Student, DMMR) ∈ R Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38
Examples R ⊆ A × B , A students, B courses; (A Student, DMMR) ∈ R Graphs are relations on vertices: covered later in course Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38
Examples R ⊆ A × B , A students, B courses; (A Student, DMMR) ∈ R Graphs are relations on vertices: covered later in course Divides | : Z + × Z + is { ( n , m ) | ∃ k ∈ Z + ( m = kn ) } Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38
Examples R ⊆ A × B , A students, B courses; (A Student, DMMR) ∈ R Graphs are relations on vertices: covered later in course Divides | : Z + × Z + is { ( n , m ) | ∃ k ∈ Z + ( m = kn ) } R = { ( a , b ) | m divides a − b } where m > 1 is an integer Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38
Examples R ⊆ A × B , A students, B courses; (A Student, DMMR) ∈ R Graphs are relations on vertices: covered later in course Divides | : Z + × Z + is { ( n , m ) | ∃ k ∈ Z + ( m = kn ) } R = { ( a , b ) | m divides a − b } where m > 1 is an integer Written as a ≡ b ( mod m ) Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38
Notation R ∪ S union; R ∩ S intersection; Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 18 / 38
Notation R ∪ S union; R ∩ S intersection; If R i are relations on A × B for all i ∈ I then � i ∈ I R i and � i ∈ I R i are relations on A × B Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 18 / 38
Notation R ∪ S union; R ∩ S intersection; If R i are relations on A × B for all i ∈ I then � i ∈ I R i and � i ∈ I R i are relations on A × B R ⊆ S subset and R = S equality Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 18 / 38
Relation composition Definition Let R ⊆ B × C and S ⊆ A × B . The composition relation ( R ◦ S ) ⊆ A × C is { ( a , c ) | ∃ b ( a , b ) ∈ S ∧ ( b , c ) ∈ R } Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 19 / 38
Relation composition Definition Let R ⊆ B × C and S ⊆ A × B . The composition relation ( R ◦ S ) ⊆ A × C is { ( a , c ) | ∃ b ( a , b ) ∈ S ∧ ( b , c ) ∈ R } Closure R is a relation on A : R 0 is the identity relation ( ι A ) R n + 1 = R n ◦ R R ∗ = � n ≥ 0 R n Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 19 / 38
Relation composition Definition Let R ⊆ B × C and S ⊆ A × B . The composition relation ( R ◦ S ) ⊆ A × C is { ( a , c ) | ∃ b ( a , b ) ∈ S ∧ ( b , c ) ∈ R } Closure R is a relation on A : R 0 is the identity relation ( ι A ) R n + 1 = R n ◦ R R ∗ = � n ≥ 0 R n Example: reachability in a graph Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 19 / 38
Properties of binary relation R on A reflexive iff ∀ x ∈ A ( x , x ) ∈ R Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38
Properties of binary relation R on A reflexive iff ∀ x ∈ A ( x , x ) ∈ R ≤ , = , and | are reflexive, but < is not Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38
Properties of binary relation R on A reflexive iff ∀ x ∈ A ( x , x ) ∈ R ≤ , = , and | are reflexive, but < is not symmetric iff ∀ x , y ∈ A (( x , y ) ∈ R → ( y , x ) ∈ R ) = is symmetric, but ≤ , < , and | are not Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38
Recommend
More recommend