Discrete Slides
Discrete Slides
References Book:
Invitation to Discrete Maths, 2nd edition.
By Matousek and Nesetril.
Discrete Mathematics. By Lovasz, Pelikan
and Vesztergombi.
2
The Foundations: Logic and
Proofs
Chapter 1, Part I: Propositional
Logic
Formal: Input_wire_A
value in {0, 1}
Example 1: Adder
One-bit Full Adder with
Alice and Bob have never met but they would like to
exchange a message. Eve would like to eavesdrop.
E.g. between you and the Bank of America.
They could come up with a good
encryption algorithm and exchange the
encryption key – but how to do it without
Eve getting it? (If Eve gets it, all security
is lost.)
11
Applications: Coloring a Map
15
16
Examples: Propositions
17
18
Activity 1
21
1. Negation:
DEFINITION 1:
Let p be a proposition. The negation of p, denoted by ¬p, is the statement
“It is not the case that p.”
The proposition ¬p is read “not p.” The truth value of the negation of p, ¬p
is the opposite of the truth value of p.
Examples
Find the negation of the proposition “Today is Friday.” and
express this in simple English.
Solution: The negation is “It is not the case that today is Friday.”
In simple English, “Today is not Friday.” or “It is not
Friday today.”
Find the negation of the proposition “At least 10 mm of rain fell
today in Karachi.” and express this in simple English.
Solution: The negation is “It is not the case that at least 10 mm of
rain fell today in Karachi.”
22
In simple English, “Less than 10 mm of rain fell today
in Karachi.”
Negation:
Note: Always assume fixed times, fixed places, and particular people
unless otherwise noted.
Truth table: The Truth Table for the
Negation of a Proposition.
p ¬p
T F
F T
23
2. Conjunction:
DEFINITION 2
Let p and q be propositions. The conjunction of p and q, denoted by p
Λ q, is the proposition “p and q”. The conjunction p Λ q is true when
both p and q are true and is false otherwise.
Examples
Find the conjunction of the propositions p and q where p is the
proposition “Today is Friday.” and q is the proposition “It is
raining today.”, and the truth value of the conjunction.
Solution: The conjunction is the proposition “Today is Friday and
it is raining today.” The proposition is true on rainy Fridays.
24
3. Disjunction:
DEFINITION 3
Let p and q be propositions. The disjunction of p and q, denoted by p ν
q, is the proposition “p or q”. The disjunction p ν q is false when both p
and q are false and is true otherwise.
Note:
inclusive or : The disjunction is true when at least one of the two
propositions is true.
E.g. “Students who have taken calculus or computer science can take
this class.” – those who take one or both classes.
exclusive or : The disjunction is true only when one of the
proposition is true.
E.g. “Students who have taken calculus or computer science, but not
both, can take this class.” – only those who take one of them.
Definition 3 uses inclusive or.
25
26
4. Exclusive OR:
DEFINITION 4
Let p and q be propositions. The exclusive or of p and q, denoted by p q,
is the proposition that is true when exactly one of p and q is true and is
false otherwise.
The Truth Table for The Truth Table for The Truth Table for the
the Conjunction of the Disjunction of Exclusive Or (XOR) of
Two Propositions. Two Propositions. Two Propositions.
p q pΛq p q pνq p q p q
T T T T T T T T F
T F F T F T T F T
F T F F T T F T T
F F F F F F F F F
27
28
29
5. Implication / Conditional Statements:
DEFINITION 5
Let p and q be propositions. The conditional statement p → q, is the
proposition “if p, then q.” The conditional statement p → q is false
when p is true
and q is false, and true otherwise. In the conditional
statement p → q, p is called the hypothesis (or antecedent or premise)
and q is called the conclusion (or consequence).
A conditional statement is also called an implication.
Example: “If I am elected, then I will lower taxes.” p→q
implication:
elected, lower taxes. T T |T
not elected, lower taxes. F T |T
not elected, not lower taxes. F F |T
elected, not lower taxes. T F |F
30
Example: Conditional Statements
Example:
Let p be the statement “Maria learns discrete mathematics.” and
q the statement “Maria will find a good job.” Express the
statement p → q as a statement in English.
Solution: Any of the following -
“If Maria learns discrete mathematics, then she will find a
good job.
“Maria will find a good job when she learns discrete
mathematics.”
“For Maria to get a good job, it is sufficient for her to
learn discrete mathematics.”
“Maria will find a good job unless she does not learn
discrete mathematics.”
31
Examples: Implication
32
Examples: Implication
33
34
Other conditional statements:
Converse of p → q : q → p
Contrapositive of p → q : ¬ q → ¬ p
Inverse of p → q : ¬ p → ¬ q
35
Converse, Contrapositive, and Inverse
From p →q we can form new conditional
statements .
q →p is the converse of p →q
¬q → ¬ p is the contrapositive of p →q
¬ p → ¬ q is the inverse of p →q
Contrapositive of p → q is ¬q → ¬p
Any proposition and its contrapositive are
logically equivalent (have the same truth
table values) – Check with the truth table.
E.g. The contrapositive of “If you get 100%
in this course, you will get an A+” is “If you
do not get an A+ in this course, you did not
get 100%”.
37
Converse:
Converse of p → q is q → p
Both are not logically equivalent.
Ex 1: “If you get 100% in this course, you
will get an A+” and “If you get an A+ in this
course, you scored 100%” are not
equivalent.
Ex 2: If you won the lottery, you are rich.
38
Inverse:
Inverse of p → q is ¬p → ¬q
Both are not logically equivalent.
Ex1 : “If you get 100% in this course, you
will get an A+” and “If you didn’t 100%,
then won’t have an A+ in this course.” are
not equivalent.
Ex2: You can not ride the roller coaster if
you are under 4 feet. What is its inverse
statement? 39
Example of converse (1/2)
41
6. Bi-implications:
DEFINITION 6
Let p and q be propositions. The biconditional statement p ↔ q is the
proposition “p if and only if q.” The biconditional statement p ↔ q is
true when p and q have the same truth values, and is false otherwise.
Biconditional statements are also called bi-implications.
T T F T T T
T F T T F F
F T F F F T
F F T T F F 46
Example Truth Table
p q r r pq p q → r
T T T F T F
T T F T T T
T F T F T F
T F F T T T
F T T F T F
F T F T T T
F F T F F T
F F F T F T
Problem:
How many rows are there in a truth table with
n propositional variables?
52
System Specifications
System and Software engineers take requirements in
English and express them in a precise specification
language based on logic.
Example: Express in propositional logic:
“The automated reply cannot be sent when the file system
is full”
Solution: One possible solution: Let p denote “The
automated reply can be sent” and q denote “The file
system is full.”
q→ ¬ p
1.1 Propositional Logic
Logic and Bit Operations
Computers represent information using bits.
A bit is a symbol with two possible values, 0 and 1.
By convention, 1 represents T (true) and 0 represents F (false).
A variable is called a Boolean variable if its value is either true or
false.
Bit operation – replace true by 1 and false by 0 in logical
operations.
Example: Find the bitwise OR, bitwise AND, and bitwise XOR of the
bit string 01 1011 0110 and 11 0001 1101.
Solution:
01 1011 0110
11 0001 1101
-------------------
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR
55
Propositional Equivalences
DEFINITION 1
A compound proposition that is always true, no matter
what the truth values of the propositions that occurs in
it, is called a tautology.
A compound proposition that is always false is called a
contradiction.
A compound proposition that is neither a tautology or a
contradiction is called a contingency.
Examples of a Tautology and a Contradiction.
p ¬p p ν ¬p p Λ ¬p
T F T F
F T T F 56
57
58
Propositional Equivalences
DEFINITION 2
The compound propositions p and q are called logically equivalent if p ↔
q is a tautology. The notation p ≡ q denotes that p and q are logically
equivalent.
60
Propositional Equivalences
61
Applications: Boolean Searches
Logical connectives are used extensively in
searches of large collections of information.
Example: indexes of Web pages.
67
Example 3:
68
69
70
71
72
73
74
75
76
Propositional Equivalences
Constructing New Logical Equivalences
Example: Show that ¬(p → q ) and p Λ ¬q are logically equivalent.
Solution:
¬(p → q ) ≡ ¬(¬p ν q) by example discussed in slide 66
≡ ¬(¬p) Λ ¬q by the second De Morgan law
≡ p Λ ¬q by the double negation law
Example: Show that (p Λ q) → (p ν q) is a tautology.
Solution: To show that this statement is a tautology, we will use logical
equivalences to demonstrate that it is logically equivalent to T.
(p Λ q) → (p ν q) ≡ ¬(p Λ q) ν (p ν q) by example already discussed
≡ (¬ p ν ¬q) ν (p ν q) by the first De Morgan law
≡ (¬ p ν p) ν (¬ q ν q) by the associative and
communicative law for disjunction
≡TνT
≡T 77
Note: The above examples can also be done using truth tables.
78
Exercise
79
Exercise
80
The Foundations: Logic and
Proofs
Chapter 1, Part II: Predicate Logic
Summary
If we have:
“All men are mortal.”
“Socrates is a man.”
Does it follow that “Socrates is mortal?”
Can’t be represented in propositional
logic. Need a language that talks about
objects, their properties, and their
relations.
Later we’ll see how to draw inferences.
Introducing Predicate Logic
Predicate logic uses the following new
features:
Variables: x, y, z
Predicates: P(x), M(x)
Quantifiers (to be covered in a few slides):
Propositional functions are a generalization of
propositions.
They contain variables and a predicate, e.g., P(x)
Variables can be replaced by elements from their
domain.
Propositional Functions
Propositional functions become propositions (and
have truth values) when their variables are each
replaced by a value from the domain (or bound by a
quantifier, as we will see later).
The statement P(x) is said to be the value of the
propositional function P at x.
For example, let P(x) denote “x > 0” and the domain
be the integers. Then:
P(-3) is false.
P(0) is false.
P(3) is true.
Often the domain is denoted by U. So in this example
U is the integers.
Examples of Propositional Functions
Let “x + y = z” be denoted by R(x, y, z) and U (for all three
variables) be the integers. Find these truth values:
R(2,-1,5)
Solution: F
R(3,4,7)
Solution: T
R(x, 3, z)
Solution: Not a Proposition
Now let “x - y = z” be denoted by Q(x, y, z), with U as the
integers. Find these truth values:
Q(2,-1,3)
Solution: T
Q(3,4,7)
Solution: F
Q(x, 3, z)
Solution: Not a Proposition
Compound Expressions
Connectives from propositional logic carry over to predicate
logic.
If P(x) denotes “x > 0,” find these truth values:
P(3) ∨ P(-1) Solution: T
P(3) ∧ P(-1) Solution: F
P(3) → P(-1) Solution: F
P(3) → P(1) Solution: T
Expressions with variables are not propositions and therefore
do not have truth values. For example,
P(3) ∧ P(y)
P(x) → P(y)
When used with quantifiers (to be introduced next), these
expressions (propositional functions) become propositions.
Quantifiers
Charles Peirce (1839-1914)
91
Universal Quantifier
x P(x) is read as “ For all x, P(x)” or “For every x,
P(x)”
Examples:
1) If P(x) denotes “x > 0” and U is the integers, then x
P(x) is false.
2) If P(x) denotes “x > 0” and U is the positive integers,
then x P(x) is true.
3) If P(x) denotes “x is even” and U is the integers, then
x P(x) is false.
Existential Quantifier
99
Translating from English to Logic
Example 2: Translate the following sentence
into predicate logic: “Some student in this
class has taken a course in Java.”
Solution:
First decide on the domain U.
Solution 1: If U is all students in this class, translate
as
x J(x)
Solution 1: But if U is all people, then translate as
x (S(x) ∧ J(x))
x (S(x)→ J(x)) is not correct. What does it mean?
if we are interested in people other than those in this class, we look at the
statement a little differently. Our statement can be expressed as
“There is a person x having the properties that x is a student in this class and
x has studied Java.”
In this case, the domain for the variable x consists of all people. We
introduce S(x) to represent
“x is a student in this class.” Our solution becomes ∃x(S(x) ∧ J(x)) because
the statement is that there is a person x who is a student in this class and
who has studied Java.
[Caution! Our statement cannot be expressed as ∃x(S(x) → J(x)), which is
true when there is someone not in the class because, in that case, for such a
person x, S(x) → J(x) becomes either F→T or F→F, both of which are true.]
101
Returning to the Socrates Example
Introduce the propositional functions Man(x)
denoting “x is a man” and Mortal(x) denoting
“x is mortal.” Specify the domain as all
people.
The two premises are:
Even if the domains are infinite, you can still think of the
quantifiers in this fashion, but the equivalent expressions
without quantifiers will be infinitely long.
Negating Quantified Expressions
Consider x J(x)
“Every student in your class has taken a course in Java.”
Here J(x) is “x has taken a course in Java” and
the domain is students in your class.
Negating the original statement gives “It is not the
case that every student in your class has taken a
course in Java.” This implies that “There is a
student in your class who has not taken a course
in Java.”
Symbolically ¬x J(x) and x ¬J(x) are equivalent
Negating Quantified Expressions
(continued)
Now Consider x J(x)
“There is a student in this class who has taken a
course in Java.”
Where J(x) is “x has taken a course in Java.”
Negating the original statement gives “It is
not the case that there is a student in this
class who has taken Java.” This implies that
“Every student in this class has not taken a
course in Java”
Symbolically ¬ x J(x) and x ¬J(x) are
equivalent
De Morgan’s Laws for Quantifiers
The rules for negating quantifiers are:
Solution: x F(x)
Translation (cont)
Now we have:
Lewis Carroll Example
Charles Lutwidge
Dodgson
(AKA Lewis Caroll)
(1832-1898)
The first two are called premises and the third is called the
conclusion.
1. “All lions are fierce.”
2. “Some lions do not drink coffee.”
3. “Some fierce creatures do not drink coffee.”
Here is one way to translate these statements to predicate
logic. Let P(x), Q(x), and R(x) be the propositional functions “x
is a lion,” “x is fierce,” and “x drinks coffee,” respectively.
1. x (P(x)→ Q(x))
2. x (P(x) ∧ ¬R(x))
3. x (Q(x) ∧ ¬R(x))
Later we will see how to prove that the conclusion follows
from the premises.
Nested Quantifiers
Section 1.5
Section Summary
Nested Quantifiers
Order of Quantifiers
Translating from Nested Quantifiers into
English
Translating Mathematical Statements into
Statements involving Nested Quantifiers.
Translated English Sentences into Logical
Expressions.
Negating Nested Quantifiers.
Nested Quantifiers
Nested quantifiers are often necessary to express
the meaning of sentences in English as well as
important concepts in computer science and
mathematics.
Example: “Every real number has an inverse” is
x y(x + y = 0)
where the domains of x and y are the real numbers.
We can also think of nested propositional
functions:
x y(x + y = 0) can be viewed as x Q(x) where Q(x) is
y P(x, y) where P(x, y) is (x + y = 0)
Thinking of Nested Quantification
Nested Loops
To see if xyP (x,y) is true, loop through the values of x :
At each step, loop through the values for y.
If for some pair of x andy, P(x,y) is false, then x yP(x,y) is false and both
the outer and inner loop terminate.
x y P(x,y) is true if the outer loop ends after stepping through each x.
To see if x yP(x,y) is true, loop through the values of x:
At each step, loop through the values for y.
The inner loop ends when a pair x and y is found such that P(x, y) is true.
If no y is found such that P(x, y) is true the outer loop terminates as x
yP(x,y) has been shown to be false.
x y P(x,y) is true if the outer loop ends after stepping through each
x.
If the domains of the variables are infinite, then this process
can not actually be carried out.
Order of Quantifiers
Examples:
1. Let P(x,y) be the statement “x + y = y +
x.” Assume that U is the real numbers.
Then x yP(x,y) andy xP(x,y) have
the same truth value.
2. Let Q(x,y) be the statement “x + y = 0.”
Assume that U is the real numbers. Then
x yP(x,y) is true, but y xP(x,y) is
false.
Questions on Order of Quantifiers
Example 1: Let U be the real numbers,
Define P(x,y) : x ∙ y = 0
What is the truth value of the following:
1. xyP(x,y)
Answer: False
2. xyP(x,y)
Answer: True
3. xy P(x,y)
Answer: True
4. x y P(x,y)
Answer: True
Questions on Order of Quantifiers
Example 2: Let U be the real numbers,
Define P(x,y) : x / y = 1
What is the truth value of the following:
1. xyP(x,y)
Answer: False
2. xyP(x,y)
Answer: True
3. xy P(x,y)
Answer: False
4. x y P(x,y)
Answer: True
Quantifications of Two Variables
Statement When True? When False
P(x,y) is true for every There is a pair x, y for
pair x,y. which P(x,y) is false.
Solution: Yes! The left and the right side will always have the same truth value.
The order in which x and y are picked does not matter.
Is this a valid equivalence?
Solution: No! The left and the right side may have different truth values for
some propositional functions for P. Try “x + y = 0” for P(x,y) with U being the
integers. The order in which the values of x and y are picked does matter.
Solution: Yes! The left and the right side will always have the same truth value
no matter what propositional functions are denoted by P(x) and Q(x).
Valid Arguments
Inference Rules for Propositional Logic
Using Rules of Inference to Build
Arguments
Rules of Inference for Quantified
Statements
Building Arguments for Quantified
Statements
Revisiting the Socrates Example
p→q
p
∴q
the statement ((p → q) ∧ p) → q is a tautology
Argument Form
p: ““You have access to the network”
q: “You can change your grade”
the argument has the form
“If you have access to the network, then you can change
your grade.”
“You have access to the network.”
∴ “You can change your grade.”
Implication elimination
Abbreviated to MP or modus ponens
p→q
whenever p → q is true
p q
T T T
and p is true, T F F
Corresponding Tautology:
(p ∧ (p →q)) → q
Example:
Let p be “It is snowing.”
Let q be “I will study discrete math.”
Corresponding Tautology:
(¬p∧(p →q))→¬q
Example:
Let p be “it is snowing.”
Let q be “I will study discrete math.”
Corresponding Tautology:
((p →q) ∧ (q→r))→(p→ r)
Example:
Let p be “it snows.”
Let q be “I will study discrete math.”
Let r be “I will get an A.”
Corresponding Tautology:
(¬p∧(p ∨q))→q
Example:
Let p be “I will study discrete math.”
Let q be “I will study English literature.”
Corresponding Tautology:
p →(p ∨q)
Example:
Let p be “I will study discrete math.”
Let q be “I will visit Las Vegas.”
Corresponding Tautology:
(p∧q) →p
Example:
Let p be “I will study discrete math.”
Let q be “I will study English literature.”
Corresponding Tautology:
((p) ∧ (q)) →(p ∧ q)
Example:
Let p be “I will study discrete math.”
Let q be “I will study English literature.”
Corresponding Tautology:
((¬p ∨ r ) ∧ (p ∨ q)) →(q ∨ r)
Example:
Let p be “I will study discrete math.”
Let r be “I will study English literature.”
Let q be “I will study databases.”
C
Fallacies
Arguments are based on tautologies.
Fallacies are based on contingencies.
The proposition ((p → q) ∧q) → p is not a tautology,
because it is false when p is false and q is true.
This type of incorrect reasoning is called the
fallacy of affirming the conclusion.
Example:
If you do every problem in this book, then you will
learn discrete mathematics. You learned discrete
mathematics. Therefore, you did every problem in
this book.
Fallacy of denying the hypothesis.
160
161
162
163
164
165
166
167
168
EXAMPLE #2
169
170
171
172
Valid Arguments
174
Universal Instantiation
175
Universal Generalization
177
Existential Generalization
This is equivalent to
A⊆B and B⊆A
Proper Subsets
is true. U
B
A
Venn Diagram
Set Cardinality
Definition: If there are exactly n distinct elements in S
where n is a nonnegative integer, we say that S is
finite. Otherwise it is infinite.
Definition: The cardinality of a finite set A, denoted by
|A|, is the number of (distinct) elements of A.
Examples:
1. |ø| = 0
2. Let S be the letters of the English alphabet. Then |S|
= 26
3. |{1,2,3}| = 3
4. |{ø}| = 1
5. The set of integers is infinite.
Power Sets
Example:
A = {a,b} B = {1,2,3}
A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)}
Set Operations
Union
Intersection
Complementation
Difference
More on Set Cardinality
Set Identities
Proving Identities
Membership Tables
Boolean Algebra
A
Ā
Difference
• Example: Let A be the math majors in your class and B be the CS majors.
To count the number of students who are either math majors or CS majors,
add the number of math majors and the number of CS majors, and subtract
the number of joint CS/math majors.
• We will return to this principle in Chapter 6 and Chapter 8 where we will
derive a formula for the cardinality of the union of n sets, where n is a
positive integer.
Review Questions
Example: U = {0,1,2,3,4,5,6,7,8,9,10} A = {1,2,3,4,5}, B ={4,5,6,7,8}
1. A ∪ B
Solution: {1,2,3,4,5,6,7,8}
2. A ∩ B
Solution: {4,5}
3. Ā
Solution: {0,6,7,8,9,10}
4.
Solution: {0,1,2,3,9,10}
5. A – B
Solution: {1,2,3}
6. B – A
Solution: {6,7,8}
Symmetric Difference (optional)
Example:
U = {0,1,2,3,4,5,6,7,8,9,10}
A = {1,2,3,4,5} B ={4,5,6,7,8}
U
A B
What is:
Solution: {1,2,3,6,7,8}
Venn Diagram
Set Identities
Identity laws
Domination laws
Idempotent laws
Complementation law
Commutative laws
Associative laws
Distributive laws
Absorption laws
Complement laws
Proving Set Identities
Example:
Proof of Second De Morgan Law
1) and
2)
Continued on next slide
Proof of Second De Morgan Law
Solution:
A B C
1 1 1 1 1 1 1 1
1 1 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 0 0 0 1 1 1 1
0 1 1 1 1 1 1 1
0 1 0 0 0 1 0 0
0 0 1 0 0 0 1 0
0 0 0 0 0 0 0 0
Section 2.3
Section Summary
Definition of a Function.
Domain, Codomain
Image, Pre image
Injection, Surjection, Bijection
Inverse Function
Function Composition
Graphing Functions
Floor, Ceiling, Factorial
Functions
Definition: Let A and B be nonempty sets. A function f
from A to B, denoted f: A → B is an assignment of each
element of A to exactly one element of B. We write
f(a) = b if b is the unique element of B assigned by the
function f to the element a of A. Students Grades
Functions are sometimes A
Carlota Rodriguez
called mappings or B
transformations. Sandeep Patel C
Jalen Williams D
F
Kathy Scott
Functions
Definition: Let A and B be nonempty sets. A function f
from A to B, denoted f: A → B is an assignment of each
element of A to exactly one element of B. We write
f(a) = b if b is the unique element of B assigned by the
function f to the element a of A.
Functions
A function f: A → B can also be defined as a subset of
A×B (a relation). This subset is restricted to be a
relation where no two elements of the relation have
the same first element.
Specifically, a function f from A to B contains one, and
only one ordered pair (a, b) for every element a∈ A.
and
Functions
Given a function f: A → B:
We say f maps A to B or
f is a mapping from A to B.
A is called the domain of f.
B is called the codomain of f.
If f(a) = b,
then b is called the image of a under f.
a is called the preimage of b.
The range of f is the set of all images of points in A under f. We
denote it by f(A).
Two functions are equal when they have the same domain, the
same codomain and map each element of the domain to the
same element of the codomain.
Equal Functions
Two functions are equal when they
have the same domain,
have the same codomain,
map each element of their common domain to the same
element in their common codomain.
If we change either the domain or the codomain of a
function, then we obtain a different function.
If we change the mapping of elements, then we also
obtain a different function.
Representing Functions
Functions may be specified in different ways:
An explicit statement of the assignment.
Students and grades example.
A formula.
f(x) = x + 1
A computer program.
A Java program that when given an integer n, produces the nth
Fibonacci Number (covered in the next section and also
inChapter 5).
Activity Time
What are the domain,
codomain, and range of the
following function
Solution
Let G be the function that assigns a grade to a student
in our discrete mathematics class.
Note that G(Adams) = A, for instance.
The domain of G is the set {Adams, Chou, Goodfriend,
Rodriguez, Stevens},
The codomain is the set {A,B,C,D,F}.
The range of G is the set {A,B,C, F},
Questions
f(a) = ? z A B
a
The image of d is ? z x
b
The domain of f is ? A y
c
The codomain of f is ? B
d z
The preimage of y is ? b
f(A) = ?
The preimage(s) of z is (are) ? {a,c,d}
Question on Functions and Sets
If and S is a subset of A, then
A B
a
f {a,b,c,} is ? {y,z}
x
b
f {c,d} is ? {z} y
c
d z
Injections
Definition: A function f is said to be one-to-one , or
injective, if and only if f(a) = f(b) implies that a = b for
all a and b in the domain of f. A function is said to be
an injection if it is one-to-one.
A B
a x
v
b
y
c
z
d
w
Surjections
Definition: A function f from A to B is called onto or
surjective, if and only if for every element
there is an element with . A
function f is called a surjection if it is onto.
A B
a x
b
y
c
z
d
Bijections
Definition: A function f is a one-to-one
correspondence, or a bijection, if it is both one-to-one
and onto (surjective and injective).
A B
a x
b
y
c
d z
w
real-valued
A function is called real-valued if its codomain is the
set of real numbers.
i A(1) = 1
i A(2) = 2
i A(3) = 3
Inverse Functions
Definition: Let f be a bijection from A to B. Then the
inverse of f, denoted , is the function from B to A
defined as
No inverse exists unless f is a bijection. Why?
Inverse Functions
A f
B A B
a V V
a
b b
W W
c c
d X X
d
Y Y
Questions
Example 1: Let f be the function from {a,b,c} to {1,2,3}
such that f(a) = 2, f(b) = 3, and f(c) = 1. Is f invertible
and if so what is its inverse?
and
Composition Questions
Example 2: Let g be the function from the set {a,b,c} to
itself such that g(a) = b, g(b) = c, and g(c) = a. Let f be the
function from the set {a,b,c} to the set {1,2,3} such that
f(a) = 3, f(b) = 2, and f(c) = 1.
What is the composition of f and g, and what is the
composition of g and f.
Solution: The composition f∘g is defined by
f∘g (a)= f(g(a)) = f(b) = 2.
f∘g (b)= f(g(b)) = f(c) = 1.
f∘g (c)= f(g(c)) = f(a) = 3.
Note that g∘f is not defined, because the range of f is not a
subset of the domain of g.
Composition Questions
Example 2: Let f and g be functions from the set of
integers to the set of integers defined by f(x) = 2x + 3
and g(x) = 3x + 2.
What is the composition of f and g, and also the
composition of g and f ?
Solution:
f∘g (x)= f(g(x)) = f(3x + 2) = 2(3x + 2) + 3 = 6x + 7
g∘f (x)= g(f(x)) = g(2x + 3) = 3(2x + 3) + 2 = 6x + 11
Graphs of Functions
Let f be a function from the set A to the set B. The
graph of the function f is the set of ordered pairs
{(a,b) | a ∈A and f(a) = b}.
Example:
Floor and Ceiling Functions
Solution:
It is Surjective (onto function). This can be shown by
an example; ƒ (0) = 0, and ƒ (1) = 0.
Ceiling Functions
Determine whether the function from R to Z is
Injective OR Surjective.
ƒ(a) = ⌈ a/2 ⌉
Solution:
It is Surjective (onto function). This can be shown by
an example; ƒ (1) = 1, and ƒ (2) = 1.
Floor and Ceiling Functions
Proving Properties of Functions
Example: Prove that x is a real number, then
⌊2x⌋= ⌊x⌋ + ⌊x + 1/2⌋
Solution: Let x = n + ε, where n is an integer and 0 ≤ ε< 1.
Case 1: ε < ½
2x = 2n + 2ε and ⌊2x⌋ = 2n, since 0 ≤ 2ε< 1.
⌊x + 1/2⌋ = n, since x + ½ = n + (1/2 + ε ) and 0 ≤ ½ +ε < 1.
Hence, ⌊2x⌋ = 2n and ⌊x⌋ + ⌊x + 1/2⌋ = n + n = 2n.
Case 2: ε ≥ ½
2x = 2n + 2ε = (2n + 1) +(2ε − 1) and ⌊2x⌋ =2n + 1,
since 0 ≤ 2 ε - 1< 1.
⌊x + 1/2⌋ = ⌊ n + (1/2 + ε)⌋ = ⌊ n + 1 + (ε – 1/2)⌋ = n + 1 since
0 ≤ ε – 1/2< 1.
Hence, ⌊2x⌋ = 2n + 1 and ⌊x⌋ + ⌊x + 1/2⌋ = n + (n + 1) = 2n + 1.
Factorial Function
Definition: f: N → Z+ , denoted by f(n) = n! is the
product of the first n positive integers when n is a
nonnegative integer.
f(n) = 1 ∙ 2 ∙∙∙ (n – 1) ∙ n, f(0) = 0! = 1
f(6) = 6! = 1 ∙ 2 ∙ 3∙ 4∙ 5 ∙ 6 = 720
f(20) = 2,432,902,008,176,640,000.