Professional Documents
Culture Documents
CH1 The Foundations - Logic and Proofs
CH1 The Foundations - Logic and Proofs
Discrete Mathematics
Cui Yu
Attendance policy Chapter 1. Logic and proofs 2
What is the shortest path between two cities using a transportation system?
Find the shortest tour that visits each of a group of cities only once and then
ends in the starting city.
How can we represent English sentences so that a computer can reason with
them?
How many ways can password be chosen following specific rules?
Using in computer science Chapter 1. Logic and proofs 7
Textbook:
Discrete Mathematics and Its Applications
----eighth edition
Topic : logic and proofs, sets, relations, graph theory
Learning outcome : A knowledge of mathematics as it applies
to solving problems in computer science
1.1 Propositional Logic Chapter 1. Logic and proofs 9
DEFINITION 1
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.
Chapter 1. Logic and proofs 13
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.”
Truth table:
The Truth Table for the
Negation of a Proposition.
p ¬p
T F
F T
Chapter 1. Logic and proofs 15
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.
Chapter 1. Logic and proofs 16
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.
Chapter 1. Logic and proofs 17
DEFINITION 4
Let p and q be propositions. The exclusive or of p and q, denoted by𝑝 ⨁𝑞,
is the proposition that is true when exactly one of p and q is true and is
false otherwise.
E.g. Let p and q be the propositions that state “A student can have a salad with
dinner” and “A student can have a soup with dinner,” respectively. what is ?
Solution: The is the statement “A student can have soup or salad, but not
both, with dinner.”
E.g. Express the statement”I will use all my savings to travel to Europe or to buy
an electric car” in the proposition logic using statement p:”I will use all my
savings to travel to Europe”and q:”I will use all my savings to to buy an electric
car”
Chapter 1. Logic and proofs 18
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
𝑝 ⨁𝑞
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
Chapter 1. Logic and proofs 19
DEFINITION 5
Let p and q be propositions. The conditional statement p → q, is the proposition “if
p, then q.” The conditional statement 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).
The Truth Table for the Conditional
statement p → q
p q p→q
T T T
T F F
F T T
F F T
Chapter 1. Logic and proofs 20
E.g.”If you get 100% on the final, then you will get an A”.
Chapter 1. Logic and proofs 21
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.”
Chapter 1. Logic and proofs 23
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
p called
↔ q has the same truth value as (p → q) Λ (q → p)
bi-implications.
The Truth Table for the (
Biconditional statement p ↔
q.
T T T T T T
p q p↔ q
T F F T F F
T T T
T F F
F T T F F F
F T F F F T T T T
F F T
Chapter 1. Logic and proofs 25
p iff q
p exactly when q
Chapter 1. Logic and proofs 26
(𝑞→𝑝)∧(¬𝑞→¬𝑝)
(𝑞 →𝑝 )∧(𝑝 → 𝑞)
Truth Tables of Compound Propositions Chapter 1. Logic and proofs 27
English (and every other human language) is often ambiguous. Translating sentences
into compound statements removes the ambiguity.
Example: How can this English sentence be translated into a logical expression?
“You cannot ride the roller coaster if you are under 4 feet
tall unless you are older than 16 years old.”
Solution: Let q, r, and s represent “You can ride the roller coaster,”
“You are under 4 feet tall,” and “You are older than
16 years old.” The sentence can be translated into:
(r Λ ¬ s) → ¬q.
Chapter 1. Logic and proofs 30
Example: How can this English sentence be translated into a logical expression?
“You can access the Internet from campus only if you are a computer science
major or you are not a freshman.”
Solution: Let a, c, and f represent “You can access the Internet from campus,” “You
are a computer science major,” and “You are a freshman.” The sentence can be
translated into:
a → (c ν ¬f).
Exercise 1 Chapter 1. Logic and proofs 31
Suppose u represents “you understand the material”, s represents “you study the
theory”, and w represents “you work on exercises”. Write the following compound
proposition using u, s, w, and appropriate connectives.
1) “You study the theory and work on exercises, but you don’t understand the
material.” s
2) “Studying the theory is sufficient for understanding the material.” 𝒔 → 𝒖
3)“In order to work on exercises, you need to study the theory.” w , ws
4)“When you study the theory and work on exercises, you understand the material.”
s
Exercise 3 Chapter 1. Logic and proofs 33
Write these system specifications in symbols using the propositions v: “The user enters
a valid password,” a: “Access is granted to the user,” c: “The user has contacted the
network administrator,” and logical connectives. Then determine if the system
specifications are consistent.
1)“The user has contacted the network administrator, but does not enter a valid
password.” c ∧¬v
2) “Access is granted whenever the user has contacted the network administrator or
enters a valid password.” (c ∨v) →a
3) “Access is denied if the user has not entered a valid password or has not contacted the
network administrator.” (¬v ∨¬c) →¬a
Exercise 4 Chapter 1. Logic and proofs 34
1)
𝐹 𝐹
𝐹 𝑇
𝑇 𝑇
𝑇 𝐹
Solutions Exersice 4 2) Chapter 1. Logic and proofs 36
2)
𝐹 𝑇 𝑇 𝑇
𝐹 𝐹 𝑇 𝑇
𝑇 𝑇 𝑇 𝑇
𝑇 𝑇 𝐹 𝑇
Chapter 1. Logic and proofs 37
You meet two people, A and B. Each person either always tells the truth or always
lies. Person A tells you, “We are not both truthtellers.” Determine, if possible,
which type of person each one is.
1.3 Propositional Equivalences Chapter 1. Logic and proofs 38
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.
p ¬p p ν ¬p p Λ ¬p
1 0 1 0
0 1 1 0
Chapter 1. Logic and proofs 39
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.
Compound propositions that have the same truth values in all possible cases are
called logically equivalent.
Example: Show that ¬p ν q and p → q are logically equivalent.
Truth Tables for ¬p ν q and p → q .
p q ¬p ¬p ν q p→q
1 1 0 1 1
1 0 0 0 0
0 1 1 1 1
0 0 1 1 1
Chapter 1. Logic and proofs 41
p q ¬p ν q p→q
1 1 0 1 1
1 0 0 0 0
0 1 1 1 1
0 0 1 1 1
Chapter 1. Logic and proofs 42
Example: Show that ¬(r ∨(q ∧(¬r →¬p))) ¬r ∧(p ∨¬q) are logically equivalent.
¬(r ∨(q ∧(¬r →¬p))) p ∨¬q ¬r ∧(p ∨¬q)
1 1 1 0 0 0 1 1 0 1 0
1 1 0 0 0 1 0 0 1 1 1
1 0 1 0 1 0 1 0 0 1 0
1 0 0 0 1 1 0 0 1 1
1
0 1 1 1 0 0 1
1 0 0 0
0 1 0
1 0 1 1 1 0 0 0
0 0 1
1 1 0 1 0 0 1 1
0 0 0 0
1 1 1 1 1 1 1
Exercise Chapter 1. Logic and proofs 43
Show that ¬(p ∨q) and ¬p ∨¬q are not logically equivalent.
Show that,are tautology.
logical Equivalences
Chapter 1. Logic and proofs 44
Equivalence Name
Identity laws
Domination laws
Idempotent laws
Double negation law
Commutative laws
Associative laws
Distributive laws
De Morgan’s laws
Absorption laws
Negation laws
Constructing New Logical Equivalences Chapter 1. Logic and proofs 45
E.g.:
Show that ≡
Exercise :
1 、 Prove that
1) ≡
2) p →(q ∨r) ≡(p ∧¬q) →r
3) ¬[r ∨(q ∧(¬r →¬p))] ≡¬r ∧(p ∨¬q)
by using a series of logical equivalences.
2 、 show that is a tautology
Solution Chapter 1. Logic and proofs 47
1 、 Prove that
1) p →(q ∨r) ≡(p ∧¬q) →r
2) ¬(r ∨(q ∧(¬r →¬p))) ≡¬r ∧(p ∨¬q)
by using a series of logical equivalences.
1) p →(q ∨r) ≡(p ∧¬q) →r 2) ¬(r ∨(q ∧(¬r →¬p))) ≡¬r ∧(p ∨¬q)
Solution : p →(q ∨r) Solution : ¬(r ∨(q ∧(¬r →¬p)))
¬(r ∨(q ∧(r ∨¬p)))
¬r∧¬(q∧(r ∨¬p))
¬r∧¬q∨¬(r ∨¬p)
¬r∧¬q∨(¬r ∧p)
¬r∧(¬q∨p)
¬r∧(p∨¬q)
Chapter 1. Logic and proofs 48
Solution:
1
1.4 Predicates and quantifiers Chapter 1. Logic and proofs 49
Examples:
1. Every computer connected to the university network is functioning
properly.
Math3 is functioning properly.
2. CS2 is under attack by an intrude.
There is a computer on the university network that is under attack by an
intrude.
Chapter 1. Logic and proofs 50
Exercise:
Let P() be the statement, where the universe for is all real numbers.
(1) Determine the truth value of P(0).
(2) Determine the truth value of P(1/3).
(3) Determine the truth value of P(2).
(4) Determine the set of all real numbers for which P() is true.
Exercise Chapter 1. Logic and proofs 52
Many mathematical statements assert that a property is true for all values of a
variable in a particular domain, called the domain of discourse or domain in
short.
DEFINITION 1 The universal quantification of is the statement “for all
values of x in the domain”,
denotes the universal quantification of . Here is called the universal
quantifier. We read as “for all ” or “for every ”. An element for which is
false is called a counterexample of .
Example
Let be the statement “”. What is the truth value of the
quantification , where the domain consists of all real numbers?
Solution: Because is true for all real numbers , the quantification
is true.
Chapter 1. Logic and proofs 54
Example: Let be the statement “”. What is the truth value of the
quantification , where the domain consists of all real numbers?
Solution: Because is false for , the quantification
is false.
Chapter 1. Logic and proofs 55
The existential
existential quantification of is the proposition “There exists an element
quantifier
in the domain such that”,
denotes the existential quantification of , read as “T ” “T ” or “ ”.
1 、 Let be the statement “” , be the statement “”.What are the truth value of
the and , and , respectively, where the domain consists of all real number.
2 、 Suppse that is “” , what are the truth values of the and , where the domain
consists of all integers.
Chapter 1. Logic and proofs 57
When all the elements in the domain can be listed-say -it follows
that the universal quantification is the same as
E.g. What do the statements and mean, where the domain in each case
consists of the real numbers?
The quantifiers have higher precedence than all logical operators from
propositional calculus.
e.g.
E.g.
1、
2、
3、
Logical equivalences involving quantifiers Chapter 1. Logic and proofs 65
Example:Show that
.
Negating quantified expressions Chapter 1. Logic and proofs 66
E.g. There is a student in your class who has taken a course in calculus.
Let be the statement: has taken a course in calculus.
It is not the case that there is a student in your class who has taken a course in calculus.
Every student in your class has not taken a course in calculus
Chapter 1. Logic and proofs 67
Example :
1 、 Express the statement “Every student in this class has studied calculus” using
predicates and quantifiers.
2 、 Express the statements”Some student in this class has visited England” and
“Every student in this class has visited either Canada or England”.
Chapter 1. Logic and proofs 70
Exercise :
1 、 What are the negations of the statements and .
2 、 Suppose that the domain of Q(x,y,z) consists of triples x,y,z, where x=0,1 or 2,
y=0 or 1,z=0 or 1.Write out these propositions using disjunctions and conjunctions.
Chapter 1. Logic and proofs 71
3 、 Translate in two ways each of these statements into logical expressions using
predicates,quantifiers and logical connectivities. First, let the domain consist of the
students in your class and second, let it consist of all people.
1) Everyone in your class is friendly.
2) There is a person in your class who was not born in California.
3) No student in your class has taken a course in logic programming.
4 、 Write the statement “No perfect squares are negative.”in symbols using the
predicates: S(x): x is a perfect square; N(x): x is negative.
Assume that the variable x is an integer.
Nested Quantifiers Chapter 1. Logic and proofs 72
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 Chapter 1. Logic and proofs 74
Examples:
1. Let P(x,y) be the statement “x + y = y + x.” Assume that domain of
discourse 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 domain of
discourse is the real numbers. Then x yQ(x,y) is true, but y
xQ(x,y) is false.
Chapter 1. Logic and proofs 75
We will show how to construct valid arguments in two stages; first for
propositional logic and then for predicate logic. The rules of inference
are the essential building block in the construction of valid arguments.
1. Propositional Logic
Inference Rules
2. Predicate Logic
Inference rules for propositional logic plus additional inference rules
to handle variables and quantifiers.
Chapter 1. Logic and proofs 81
Example:
Let p be “It is snowing.”
Let q be “I will study discrete math.” (𝑝∧(𝑝→ 𝑞))→𝑞
“If it is snowing, then I will study discrete math.” pq
“It is snowing.” p
q
“Therefore , I will study discrete math.”
Chapter 1. Logic and proofs 83
Example:
Let p be “it is snowing.” (¬𝑞∧(𝑝→ 𝑞))→¬ 𝑝
Let q be “I will study discrete math.”
¬𝑞
“If it is snowing, then I will study discrete math.” 𝑝→ 𝑞
“I will not study discrete math.” ¿¿ ∴ ¬𝑝
“Therefore , it is not snowing.”
Chapter 1. Logic and proofs 84
Example:
p q q r p r
Let p be “it snows.”
Let q be “I will study discrete math.”
Let r be “I will get an A.” pq
“If it snows, then I will study discrete qr
math.” pr
“If I study discrete math, I will get an A.”
“Therefore , If it snows, I will get an A.”
Chapter 1. Logic and proofs 85
Example:
p p q q
Let p be “I will study discrete math.”
pq
Let q be “I will study English literature.”
p
“I will study discrete math or I will study q
English literature.”
“I will not study discrete math.”
“Therefore , I will study English literature.”
Chapter 1. Logic and proofs 86
Example:
Let p be “I will study discrete math.”
Let q be “I will visit A.”
“I will study discrete math.”
“Therefore, I will study discrete math or I will visit A.”
p p q
p
pq
Chapter 1. Logic and proofs 87
Example:
Let p be “I will study discrete math.” p q p
Let q be “I will study English literature.” pq
“I will study discrete math and English literature” p
Example:
Let p be “I will study discrete math.” p q p q
p
Let q be “I will study English literature.”
q
“I will study discrete math.” pq
“I will study English literature.”
“Therefore, I will study discrete math and I will study English literature.”
Chapter 1. Logic and proofs 89
Example:
p r p q q r
Let p be “I will study discrete math.” ¬𝑝 ∨𝑟
Let r be “I will study English literature.” 𝑝∨𝑞
Let q be “I will study databases.” ¿¿ ∴𝑞∨𝑟
“I will not study discrete math or I will study English literature.”
“I will study discrete math or I will study databases.”
“Therefore, I will study databases or I will study English literature.”
Rules of inference Chapter 1. Logic and proofs 90
(
Chapter 1. Logic and proofs 91
Solution:
(1) P
(2) T(1)
(3) T(1)
(4) T(2)(3)
Chapter 1. Logic and proofs 92
Universal generalization
Existential instantiation
Existential generalization
Chapter 1. Logic and proofs 95
Example : Show that the premises “ Everyone in this discrete mathematics class
has taken a course in computer science ” and “Tom is a student in this class” imply
the conclusion “Tom has taken a course in computer science”. and the domain
consists of all people.
Chapter 1. Logic and proofs 96
Example : Show that the premises“ A student in this class has not read the book”
and “everyone in this class passed the first exam” imply the conclusion”Someone
who passed the first exam has not read the book”.
Chapter 1. Logic and proofs 97
Exercise: Suppose we have: “Every student in this class is a Junior.” “Every Junior
in this class passed the final exam.” “Allen is a student in this class.” Explain why
we can draw the conclusion “Allen passed the final exam.”
Chapter 1. Logic and proofs 99
Chapter 1. Logic and proofs 100
THANKS