Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 100

Chapter 1.

Logic and proofs 1

Discrete Mathematics

Cui Yu
Attendance policy Chapter 1. Logic and proofs 2

 A student is expected to attend each class session.


 If you are unable to attend the class normally under some special
cases, you need to finish the video learning within 5 days after the
end of the class.
 A record will be made about whether you are finish the study on
time.
Honework Assignment Chapter 1. Logic and proofs 3

 Cheating or copying on an assignment will result in a lower final


score
 Homework will be submitted before the next Monday, and they will
not be accepted after that.
Exam and Grading Policy Chapter 1. Logic and proofs 4

 There is a midterm exam in week 11 or 12


 Grading:
 Homework and attendance:30%
 Midterm exams: 10%
 Final exam:60%
What is discrete mathematics Chapter 1. Logic and proofs 5

 Discrete mathematics is the part of mathematics devoted to the study


of discrete(as opposed to continuous) objects.
 Examples of discrete objects: integers,steps taken by a computer
program, distinct paths to travel from point A to point B on a map
along a road network,ways to pick a winning set of numbers in a
lottery.
 A course in discrete mathematics provides the mathematical
background needed for all subsequent courses in a computer science
and for all subsequent courses in the many branches of discrete
mathematics.
Chapter 1. Logic and proofs 6

kinds of problems solved using discrete mathematics

 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

 Advanced algorithms & data structures


 Computer networks
 Operating systems
 Computer architecture
Chapter 1. Logic and proofs 8

 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

 A proposition is a declarative sentence (a sentence that declares a


fact) that is either true or false, but not both.
 Are the following sentences propositions?
 Toronto is the capital of Canada. Yes
 Read this carefully. No
 1+2=3 Yes
 x+1=2 No
 What time is it? No
Chapter 1. Logic and proofs 10

 Propositional Variables – variables that represent propositions: p,


q, r, s
– E.g. p – “Today is Friday.”
 Truth value--the value (result) of the proposition,one of the element
from set {true, false} or {T, F} or {1,0}
Chapter 1. Logic and proofs 11

 atomic propositions-propositions that can not be expressed in terms


of simpler propositions
 compound propositions--formed from existing propositions using
logical operators
 Logical operators are used to form new propositions from two or
more existing propositions. The logical operators are also called
connectives
logical operators Chapter 1. Logic and proofs 12

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.
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.”

Find the negation of the proposition “At least 10 inches of rain


fell today in Hangzhou.” and express this in simple English.
Solution: The negation is “It is not the case that at least 10 inches of rain fell
today in Hangzhou.”
In simple English, “Less than 10 inches of rain fell today in Hangzhou.”
Chapter 1. Logic and proofs 14

 What is the truth value of a compound proposition?


---depends on the truth value of each atom
proposition
---depends on the connectives
 The connectives is defined exactly using truth table

 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 tables of conjunction,disjunction and exclusive or,


respectively

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

 A conditional statement is also called an implication.


 E.g. “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

 E.g.”If you get 100% on the final, then you will get an A”.
Chapter 1. Logic and proofs 21

 The following expressions are equivalent:


if p, then q if p, q q,if p

q when p q whenever p q unless p


q follows from p q is necessary for p q provided that p

p implies q p only if q p is sufficient for q


a necessary condition for p is q
a sufficient condition for q is p
Chapter 1. Logic and proofs 22

 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

 Other conditional statements:


– Converse of p → q : q → p
– Contrapositive of p → q : ¬ q → ¬ p
– Inverse of p → q : ¬ p → ¬ q
O E.g: Express the following statements using
1. If it is sunny, then we will go to the beach.
2. If Tom has a computer, then 2+3=6.
Chapter 1. Logic and proofs 24

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

The following expressions are equivalent:


p if and only if q

p is necessary and sufficient for q


p↔q
if p then q,and conversely

p iff q

p exactly when q
Chapter 1. Logic and proofs 26

 “if and only if” can be expressed by “iff”


 Example:
Let p be the statement “You can take the flight” and let q be the
statement “You buy a ticket.” Then p ↔ q is the statement
“You can take the flight if and only if you buy a ticket.”
Implication:
If you buy a ticket you can take the flight. 𝑞→𝒑
If you don’t buy a ticket you cannot take the flight. ¬𝑞 → ¬ 𝒑

(𝑞→𝑝)∧(¬𝑞→¬𝑝)
(𝑞 →𝑝 )∧(𝑝 → 𝑞)
Truth Tables of Compound Propositions Chapter 1. Logic and proofs 27

 We can use connectives to build up complicated compound propositions involving any


number of propositional variables, then use truth tables to determine the truth value of
these compound propositions.
 Example: Construct the truth table of the compound proposition
(p ν ¬q) → (p Λ q).
Precedence of Logical Operators Chapter 1. Logic and proofs 28

 We can use parentheses to specify the order in which logical operators in a


compound proposition are to be applied.
 To reduce the number of parentheses, the precedence order is defined for logical
operators.
Precedence of Logical Operators.
E.g. ¬p Λ q = (¬p ) Λ q
Operator Precedence
p Λ q ν r = (p Λ q ) ν r
¬ 1
Λ 2 p ν q Λ r = p ν (q Λ r)
ν 3
→ 4 (𝑝→ 𝑞)∨ 𝑟
↔ 5
Translating English Sentences Chapter 1. Logic and proofs 29

 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

1 、 Write the negation of “6 is negative”


2 、 Determine whether theses statements are true or false
1) 1+1=2 if and only if 2+3=4
2) If monkey can fly, then 1+1=3
3 、 For each of these sentences, determine whether an inclusive or, or an exclusive or.
1) A password must have at least three digits or be at eight characters long.
2) Lunch includes soup or salad.
3) School is closed if more than two feet of snow falls or if the wind chill is below
-10o
Exercise 2 Chapter 1. Logic and proofs 32

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

 Construct a truth table for each of these compound propositions.


1)
2)
3)
Solutions Exersice 4 1) Chapter 1. Logic and proofs 35

 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.

Examples of a Tautology and a Contradiction

p ¬p p ν ¬p p Λ ¬p
1 0 1 0
0 1 1 0
Chapter 1. Logic and proofs 39

Example: Determine the following compound propositions are tautology,


contradiction or contingency, respectively.
1)
2)
3)
Logical Equivalences Chapter 1. Logic and proofs 40

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

 In general, 2n rows are required if a compound proposition involves n propositional


variables in order to get the combination of all truth values.
 Example: Show that ¬p ν q and p → q are logically equivalent.

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

 Example: Show that ¬(p → q ) and p Λ ¬q are logically equivalent.


Solution:
¬(p → q ) ≡ ¬(¬p q)
≡ ¬(¬p) Λ ¬q
≡ p Λ ¬q
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)
≡ (¬ p ¬q) (p q)
≡ (¬ p p) (¬ q q)
≡T T
≡T

Chapter 1. Logic and proofs 46

 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

2 、 show that is a tautology

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

1. x is greater than 3 Let P(x) denote the statement “x is greater than 3”


What are the truth values of P(4) and P(2)?
subject predicate

2. Computer x is under attack by an intruder.


Let A(x) denote the statement. Suppose that of the computer on campus,
3. x=y+3
only cs1 and cs2 are currently under attack by intruder. What are the truth
Let Q(x,y) denote
values the statement
of A(cs1) “x=y+3”.
and A(cs3).
What are
In general, the truthinvolving
a statement values of the
Q(1,2) and Q(3,0)
n variables can be denoted by P().
A statement of the form P() is the value of the propositional function P at n-tuple (),
and P is also called an n-ary predicate.
Chapter 1. Logic and proofs 51

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

Let Q(x,y) be the statement:x +y = x−y


where the universe for x and y is the set of all real numbers. Determine the truth value
of:
(a) Q(5,−2).
(b) Q(4.7,0).
(c) Determine the set of all pairs of numbers, x and y, such that Q(x,y) is true.
Quantifiers Chapter 1. Logic and proofs 53

 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 “ ”.

The meaning of the quantifiers


statement When true ? When false?
is true for every There is an for
which is false
There is an for is false for every
which is true
Remark:Generally, an implicit assumption is made that all domain of discourse
for quantifiers are nonempty.
Exercise Chapter 1. Logic and proofs 56

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

the existential quantification is the same as


Exercise Chapter 1. Logic and proofs 58

1 、 What are the truth values of and , where is the statement


“” and the domain consists of the positive integers not excedding 4.
2 、 Suppose P(x) is the predicate “x < |x|.” Determine the truth value of
∃xP(x)
where the universe for x is:
(a) the three numbers 1, 2, 3.
(b) the six numbers −2,−1, 0, 1, 2, 3.
Quantifiers with Restricted Domains Chapter 1. Logic and proofs 59

e.g. What do the statements


and mean, where the domain in each
case consists of the real numbers?

Note that the restriction of a universal quantification is the


same as the universal quantification of a conditional
statement. the restriction of a existential quantification is the
same as the existential quantification of a conjunction.
Quantifiers with Restricted Domains Chapter 1. Logic and proofs 60

 E.g. What do the statements and mean, where the domain in each case
consists of the real numbers?

 Note that the restriction of a universal quantification is the same as the


universal quantification of a conditional statement. the restriction of a
existential quantification is the same as the existential quantification of a
conjunction.
Chapter 1. Logic and proofs 61

Write in symbols using predicates and quantifiers:


1 、 “ Everyone who visited France stayed in Paris.”
The solution depends on the universe for the variable. If we take as the
universe all people who visited France, we can write the proposition as
∀xP(x), where P(x) is the predicate “x stayed in Paris.”
However, if we take all people as the universe , then we need to
introduce a second predicate F(x) for “x visited France.” In this case,
the proposition can be written as ∀x (F(x) → P(x)).
2 、 Every freshman at the College is taking CS 101.
Precedence of quantifiers Chapter 1. Logic and proofs 62

The quantifiers have higher precedence than all logical operators from
propositional calculus.
e.g.

Exercise:Suppose that the domain of the propositional function :>9, consists


of integers 1,2,3 and 4. Write out each of these propositions using
disjunctions, conjunctions and negations.
1) 2)
3) 4)
5)
Binding Variables Chapter 1. Logic and proofs 63

When a quantifier is used on the variable , we say that this occurrence of


the variable is bound. An occurrence of a variable that is not bound by a
quantifier or set equal to a particular value is said to be free. All the
variables that occur in a propositional function must be bound or set equal
to a particular value to turn it into a proposition.
The part of a logical expression to which a quantifier is applied is called
the scope of this quantifier.
Chapter 1. Logic and proofs 64

E.g.

1、
2、
3、
Logical equivalences involving quantifiers Chapter 1. Logic and proofs 65

DEFINITION 3 Statements involving predicates and quantifiers are logically


equivalent if and only if they have the same truth value no matter which
predicates are substituted into these statements and which domain of discourse
is used for the variables in these propositional functions. We use the notion
to indicate that the two statements and involving predicates and quantifiers
are logically equivalent.

Example:Show that
.
Negating quantified expressions Chapter 1. Logic and proofs 66

E.g. Every student in your class has taken a course in calculus

Let be the statement: has taken a course in calculus.


It is not the case that every student in your class has taken a course in calculus.
There is a student in your class who has not taken a course in calculus.

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

De Morgan’s Laws for Quantifiers


Negation Equivalent When true When false
statements
For every , is There is an for
false which is true
There is an for is true for
which is false every
Chapter 1. Logic and proofs 68

E.g: Show that

, where x does not occur as a free


variable in A
Translating from English into logical expressions Chapter 1. Logic and proofs 69

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 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.
Thinking of Nested Quantification Chapter 1. Logic and proofs 73

Nested Loops
 To see if xyP (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

Exercise : Let the domain of discourse be the real numbers,define P(x,y)


: x ∙ y = 0 , What is the truth value of the following:
False
True
True
True
Chapter 1. Logic and proofs 76

 Exercise: Let the domain of discourse be the real numbers. Define


P(x,y) : x / y = 1. What is the truth value of the following:
False
False
False
True
Quantifications of Two Variables Chapter 1. Logic and proofs 77

Statement When True? When False


P(x,y) is true for every There is a pair x, y for
xyP  x, y  pair x,y. which P(x,y) is false.
yxP  x, y 
For every x there is a There is an x such
∀ 𝑥 ∃ 𝑦𝑃(𝑥, 𝑦) y for which P(x,y) is that P(x,y) is false for
true. every y.
There is an x for For every x there is a
xyP  x, y  which P(x,y) is true y for which P(x,y) is
for every y. false.
There is a pair x, y for P(x,y) is false for
xyP  x, y  which P(x,y) is true. every pair x,y
yxP  x, y 
Translating Nested Quantifiers into English Chapter 1. Logic and proofs 78

Example : Translate the statement


 x C  X   y C  y   F  X , y 

where C(x) is “x has a computer,” and F(x,y) is “x and y are


friends,” and the domain for both x and y consists of all students in
your school.
Solution: Every student in your school has a computer or has a
friend who has a computer.
Chapter 1. Logic and proofs 79

Example : Translate “The sum of two positive integers is always positive”


into a logical expression.
Solution:
1. Rewrite the statement to make the implied quantifiers and domains
explicit:
“For every two integers, if these integers are both positive, then the
sum of these integers is positive.”
2. Introduce the variables x and y, and specify the domain, to obtain:
“For all positive integers x and y, x + y is positive.”
3. The result is: xy  x  0    y  0    x  y  0 
where the domain of both variables consists of all integers
Rules of inference Chapter 1. Logic and proofs 80

 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

 An argument form in propositional logic is a sequence of compound


propositions involving propositional variables. An argument form is
valid no matter which particular propositions are substituted for the
propositional variables in its premises, the conclusion is true if the
premises are all true.
If the premises are p1 ,p2, …,pn and the conclusion is q then
(p1 ∧ p2 ∧ … ∧ pn ) → q is a tautology.
Inference rules are all argument simple argument forms that will be
used to construct more complex argument forms.
Rules of Inference for Propositional Logic Chapter 1. Logic and proofs 82

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.” pq
“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.” pq
“If it snows, then I will study discrete qr
math.” pr
“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.”
pq
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
 pq
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.” pq
“I will study discrete math and English literature” p

“Therefore, I will study discrete math.”


Chapter 1. Logic and proofs 88

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.” pq
“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

Two rules for propositions:


P rule: premises can be used during the inference
T rule:proposition S can be used in the inference if S can be deduced by other
propositions(S is true)
Example : From the single proposition p   p  q  ,show that q is a conclusion.

Solution:
(1) P
(2) T(1)
(3) T(1)
(4) T(2)(3)
Chapter 1. Logic and proofs 92

 Exercise: Show that the premises”


Chapter 1. Logic and proofs 93

 Example:With these hypotheses:


“It is not sunny this afternoon and it is colder than yesterday.”
“We will go swimming only if it is sunny.”
“If we do not go swimming, then we will take a trip.”
“If we take a trip, then we will be home by sunset.”
Using the inference rules, construct a valid argument for the conclusion:
“We will be home by sunset.”
Solution:
1. Choose propositional variables: p : “It is sunny this afternoon.”
r : “We will go swimming.” t : “We will be home by sunset.”
q : “It is colder than yesterday.” s : “We will take a trip.”
2. Translation into propositional logic: Hypotheses: p  q, r  p, r  s, s  t

3. Construct the Valid Argument


Conclusion: t
Rules of inference for quantified statements Chapter 1. Logic and proofs 94

Rule of Inference Name


Universal instantiation

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

 Example: Determine whether this argument is valid:


Lynn works part time or full time.
If Lynn does not play on the team, then she does not work part time.
If Lynn plays on the team, she is busy.
Lynn does not work full time.
Therefore, Lynn is busy.
Chapter 1. Logic and proofs 98

 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

You might also like