MID 1 Content
MID 1 Content
Proofs
Chapter 1, Part I: Propositional
Logic
Mr. Shoaib
Raza
Discrete Mathematics
Discrete mathematics is the part of mathematics devoted to the
study of discrete objects (Kenneth H. Rosen, 7th edition).
● How to think (and argument) mathematically.
8
TEXT Book:
● Discrete Mathematics & its
Applications, 7th edition. By Kenneth H.
Rosen.
References Book:
● Invitation to Discrete Maths, 2nd edition.
By Matousek and Nesetril.
● Discrete Mathematics. By Lovasz, Pelikan
and Vesztergombi.
9
Logic
Example 1: Adder
One-bit Full Adder
with
Carry-In and
Carry-Out
4-bit full adder
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.)
12
Applications: Coloring a Map
Graph:
A vertex correspond to a course.
An edge between two vertices denotes that there is at least one
common
student in the courses they represent.
Each time slot for a final exam is represented by a different
color.
15
A coloring of the graph corresponds to a valid schedule of the
Applications: Scheduling of Final Exams
1 1
Time Courses
Period
2 7 2 I 1,6
7
II 2
III 3,5
4,7
6 3 6 3 IV
5 4 5 4
17
Logic
● Logic is fundamental because it allows us to
understand meaning of statements, deduce
information about mathematical structures and
uncover further structures.
19
20
Examples: Propositions
21
22
Activity 1
25
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
26
of rain
In fell today
simple in Karachi.”
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
27
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.
28
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.
29
30
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
31
32
33
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
34
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.”
35
Examples: Implication
36
Examples: Implication
37
38
● Other conditional statements:
⚪ Converse of p → q : q → p
⚪ Contrapositive of p → q : ¬ q →
¬p
⚪ Inverse of p → q : ¬ p → ¬q
39
Converse, Contrapositive, and Inverse
● From p →q we can form new
statements
conditional .
⚪ q →p is the converse of p →q
⚪ ¬q → ¬ p is the contrapositive of p →q
⚪ ¬p→¬q is the inverse of p →q
41
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.
42
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?
43
Example of converse (1/2)
● Find the converse of the following
statement:
● R: ‘Raining tomorrow is a sufficient
condition for my not going to
town.’
● Step 1: Assign propositional
variables to
● component propositions
● P: It will rain tomorrow
44
45
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.
(p ν ¬q) → (p Λ q).
T T F T T T
T F T T F F
F T F F F T
F F T T F F 50
Example Truth Table
● Construct a truth table for
p q r ¬r p∨ p∨ q
q →
T T T F T ¬r
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?
53
Translating English Sentences
56
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.
59
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 60
61
62
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.
64
Propositional Equivalences
65
Applications: Boolean Searches
● Logical connectives are used extensively in
searches of large collections of
information.
⚪ Example: indexes of Web pages.
71
Example 3:
72
Propositional Satisfiability
● A compound proposition is satisfiable if there is an
assignment of truth values to its variables that makes it
true.
● When no such assignments exists, that is, when the
compound proposition is false for all assignments of truth
values to its variables, the compound proposition is
unsatisfiable.
84
The Foundations: Logic and
Proofs
Chapter 1, Part II: Predicate Logic
Summary
● Predicate Logic (First-Order Logic (FOL),
Predicate Calculus)
⚪ The Language of Quantifiers
⚪ Logical Equivalences
⚪ Nested Quantifiers
⚪ Translation from Predicate Logic to English
⚪ Translation from English to Predicate Logic
Predicates and Quantifiers
Section 1.4
Section Summary
● Predicates
● Variables
● Quantifiers
⚪ Universal Quantifier
⚪ Existential Quantifier
● Negating Quantifiers
⚪ De Morgan’s Laws for
Quantifiers
● Translating English to Logic
● Logic Programming (optional)
Propositional Logic Not Enough
● 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
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
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(- Solution: T
1) Solution: F
P(3) ∧ P(- Solution: F
1) Solution: T
P(3) → P(-1) with variables are not propositions and therefore
● Expressions
do
P(3)not have truth values.
→ P(1) 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)
● We need quantifiers to express the meaning of English
words including all and some:
⚪ “All men are Mortal.”
⚪ “Some cats do not have fur.”
● The two most important quantifiers are:
⚪ Universal Quantifier, “For all,” symbol: ∀
⚪ Existential Quantifier, “There exists,” symbol: ∃
● We write as in ∀x P(x) and ∃x P(x).
● ∀x P(x) asserts P(x) is true for every x in the domain.
● ∃x P(x) asserts P(x) is true for some x in the domain.
● The quantifiers are said to bind the variable x in these
expressions.
Quantifiers
⚪ Universal Quantifier, “For all,” symbol: ∀
⚪ Existential Quantifier, “There exists,”
symbol:
∃
95
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
103
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.]
105
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)
● U = {Nitwits, Blubbers, Oddments}
F(x): x is a Nitwit
S(x): x is a Blubber
T(x): x is a Oddment
“Nothing is a
Blubber.”
Solution: ∀ x
(F(x)→ S(x))
Translation (cont)
● U = {Nitwits, Blubbers, Oddments}
F(x): x is a Nitwit
S(x): x is a Blubber
T(x): x is a Oddment
“Some Nitwits are
Oddments.”
Solution: ∃x
(F(x) ∧ T(x))
Translation (cont)
● U = {Nitwits, Blubbers, Oddments}
F(x): x is a Nitwit
S(x): x is a Blubber
T(x): x is a Oddment
“No Blubber is a
Oddment.”
● 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 ∀ x ∀ y P (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) and ∀ y ∀ 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. ∀ x ∀ yP(x,y)
Answer: False
2. ∀ x ∃ yP(x,y)
Answer: True
3. ∃ x ∀ y 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. ∀ x ∀ yP(x,y)
Answer: False
2. ∀ x ∃ yP(x,y)
Answer: True
3. ∃ x ∀ y 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.
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 p→q
● whenever p → q is true T T T
T F F
● and p is true,
F T T
● q must also be true. F F T
Modus Ponens
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.”
q→r
∴p→
r
Disjunctive Syllogism
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.”
S2
.
.
.
Sn
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.
164
165
166
167
168
169
170
171
172
EXAMPLE #2
173
174
175
176
Valid Arguments
178
Universal Instantiation
179
Universal Generalization
182
Basic Structures: Sets and
Functions
Chapter 2
Sets
Section 2.1
Section Summary
● Definition of sets
● Describing Sets
⚪ Roster Method
⚪ Set-Builder Notation
● Some Important Sets in Mathematics
● Empty Set and Universal Set
● Subsets and Set Equality
● Cardinality of Sets
● Tuples
● Cartesian Product
Introduction
● Sets are one of the basic building blocks for the types of
objects considered in discrete mathematics.
⚪ Important for counting.
⚪ Programming languages have set operations.
● Set theory is an important branch of mathematics.
⚪ Many different systems of axioms have been used to develop set
theory.
⚪ Here we are not concerned with a formal set of axioms for set
theory. Instead, we will use what is called naïve set theory.
Sets
● A set is an unordered collection of objects.
⚪ the students in this class
⚪ the chairs in this room
● The objects in a set are called the
elements, or members of the set. A set is
said to contain its elements.
● The notation a ∈ A denotes that a is
an element of the set A.
● If a is not a member of A, write a ∉ A
Describing a Set: Roster Method
● S = {a,b,c,d}
● Order not important
S = {a,b,c,d} = {b,c,a,d}
● Each distinct object is either a member or not; listing
more than once does not change the set.
S = {a,b,c,d} = {a,b,c,b,c,d}
● Elipses (…) may be used to describe a set without listing all of
the members when the pattern is clear.
S = {a,b,c,d, ……,z }
Roster Method
● Set of all vowels in the English alphabet:
V = {a,e,i,o,u}
● Set of all odd positive integers less than
10:
O = {1,3,5,7,9}
● Set of all positive integers less than 100:
S = {1,2,3,……..,99}
● Set of all integers less than 0:
S = {…., -3,-2,-1}
Some Important Sets
● This is equivalent to
A⊆ B and B⊆
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}| =
Power Sets
Example:
A = {a,b} B = {1,2,3}
A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)}
A
Ā
Difference
● Definition: Let A and B be sets. The
difference of A and B, denoted by A – B, is the
set containing the elements of A that are not in
B. The difference of A and B is also called the
complement of B with respect to A.
A – B = {x | x ∈ A ∧ x ∉ B} =
A
∩□B
A
U
Venn Diagram for
B A−B
The Cardinality of the Union of Two
Sets
Inclusion-Exclusion
U
|A ∪ B| = |A| + | B| - |A ∩
A B
B|
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}
U
A = {1,2,3,4,5} B
A B
={4,5,6,7,8}
What is:
⚪ Solution: {1,2,3,6,7,8}
Venn Diagram
Set Identities
● Identity laws
● Domination laws
● Idempotent laws
● Complementation law
● Associative laws
● Distributive laws
● Absorption laws
● Complement laws
Proving Set Identities
● Different ways to prove set identities:
1. Prove that each set (side of the identity) is a
subset of the other.
2. Use set builder notation and propositional
logic.
3. Membership Tables: Verify that elements in the
same combination of sets always either
belong or do not belong to the same side of
the identity. Use 1 to indicate it is in the set
and a 0 to indicate that it is not.
Proof of Second De Morgan Law
1)
and
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
Functions
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
Kathy Scott
F
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 ? y
c
TheAcodomain of f is ? B
d z
The preimage of y is ? b
f(A) = ?
The preimage(s) of z is {a,c,d}
Question on Functions and Sets
⚫ If and S is a subset of A, then
A B
f {a,b,c,} is ? {y,z} a
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.
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
f(2) = 2! = 1 ∙ 2 = 2
f(6) = 6! = 1 ∙ 2 ∙ 3∙ 4∙ 5 ∙ 6 = 720
f(20) = 2,432,902,008,176,640,000.