Unit V - Logic
Unit V - Logic
Unit V - Logic
1
1.1 Propositional Logic
Propositions
A proposition is a declarative sentence (that is, a sentence that
declares a fact) that is either true or false, but not both.
2
Some sentences that are not propositions are given in
Example.
3.x+1=2.
4 . x + y = Z.
TRUTH TABLE
p ¬p
T F
F T
DEFINITION 1 : Let p be a proposition. The negation of p, denoted by ¬p
(also denoted by p), is the statement
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.
5
EXAMPLE : Find the negation of the proposition
Solution:
6
EXAMPLE : Find the negation of the proposition
Solution:
(or)
7
CONJUNCTION
8
DEFINITION 2
9
EXAMPLE Find the conjunction of the propositions p and q
where p is the proposition "Today is Friday"
10
EXAMPLE Find the conjunction of the propositions p and q
where p is the proposition "Today is Friday"
11
DISJUNCTION
12
DEFINITION 3:
"p or q ." The disjunction p V q is false when both p and q are false and
is true otherwise.
13
EXAMPLE :
Solution:
14
EXAMPLE :
Solution:
“Today is Friday or it is raining today”. This is true on any day that is either
a Friday or a rainy day (including rainy Fridays). It is only false on days
that are not Fridays when it also does not rain.
15
CONDITIONAL STATEMENT
16
DEFINITION 4:
17
The statement 𝑝 → 𝑞 is called a conditional statement because 𝑝 → 𝑞
asserts that q is true
statement 𝑝 → 𝑞 is true when both p and q are true and when p is false
(no matter what truth value q has).
18
EXAMPLE:
Solution:
19
EXAMPLE:
Solution:
“If Maria learns computer science, then she will find a good job”.
20
BICONDITIONAL STATEMENT
21
DEFINITION 5:
22
There are some other common ways to express p ↔ q:
23
EXAMPLE:
Solution:
24
EXAMPLE:
Solution:
25
Truth Tables of Compound Propositions
26
TYPE STATEMENT SYMBOL
Statement If p, then q. 𝑝→𝑞
¬𝑞 → ¬𝑝
Contrapositive If not q, then not p.
If two angles are congruent, then they
Statement
have the same measure.
Answer.
Here domain = {1,2,3,4}. ∀𝑥 𝑃 𝑥 is the same as the conjunction
𝑃(1) ∧ 𝑃(2) ∧ 𝑃(3) ∧ 𝑃(4).
𝑃(4), which is the statement “42 < 10,” is false.
Therefore, ∀𝑥 𝑃 𝑥 is false.
Let 𝑃(𝑥) denote the statement “𝑥 > 3.” What is the truth
value of the quantification ∃ 𝑥 𝑃(𝑥), where the domain
consists of all real numbers?
Answer.
Because “𝑥 > 3” is sometimes true. For instance, when 𝑥
= 4, the existential quantification of 𝑃(𝑥), which is ∃ 𝑥 𝑃(𝑥),
is true.
Let 𝑄(𝑥) denote the statement “𝑥 = 𝑥 + 1.” What is the
truth value of the quantification ∃ 𝑥 𝑄(𝑥), where the domain
consists of all real numbers?
Answer.
Because 𝑄(𝑥) is false for every real number 𝑥, the existential
quantification of 𝑄(𝑥), which is ∃ 𝑥 𝑄(𝑥), is false.
Precedence of Quantifiers
Solution:
By De Morgan’s law for universal quantifiers,
¬∀𝑥(𝑃(𝑥) → 𝑄(𝑥)) ≡ ∃𝑥(¬(𝑃(𝑥) → 𝑄(𝑥))). ---- (1)
W. K. T. , ¬ 𝑃 𝑥 → 𝑄 𝑥 ≡ 𝑃 𝑥 ∧ ¬𝑄 𝑥 . ----(2)
Substituting (2) in (1) it follows that,
¬∀𝑥 𝑃 𝑥 → 𝑄 𝑥 ≡ ∃𝑥(𝑃(𝑥) ∧ ¬𝑄(𝑥)).
Translating from English into Logical Expressions
Express the statement “Every student in this class has studied calculus”
using predicates and quantifiers.
Solution.
Rewrite: “For every student in this class, that student has studied
calculus.”
Introduce variable: “For every student 𝑥 in this class, 𝑥 has studied
calculus.”
Introduce Predicate: 𝐶(𝑥), which is the statement “𝑥 has studied
calculus.”
Translation: ∀𝑥 𝐶 𝑥 .
Use predicates and quantifiers to express the system specifications “Every
mail message larger than one megabyte will be compressed” and “If a
user is active, at least one network link will be available.”
Solution.
Let 𝑆(𝑚, 𝑦) be “Mail message 𝑚 is larger than 𝑦 megabytes,” where the
variable 𝑥 has the domain of all mail messages and the variable 𝑦 is a
positive real number.
Let 𝐶(𝑚) denote “Mail message 𝑚 will be compressed.”
Therefore, ∀ 𝑚 (𝑆(𝑚, 1) → 𝐶(𝑚)).
Let 𝐴(𝑢) represent “User 𝑢 is active,” where the variable 𝑢 has the
domain of all users.
Let 𝑆(𝑛, 𝑥) denote “Network link 𝑛 is in state 𝑥,” where 𝑛 has the
domain of all network links and 𝑥 has the domain of all possible
states for a network link.
Therefore, ∃ 𝑢 𝐴 𝑢 → ∃ 𝑛 𝑆(𝑛, 𝑎𝑣𝑎𝑖𝑙𝑎𝑏𝑙𝑒).
Nested Quantifiers
Solution.
Given 𝑃(𝑥, 𝑦) is the statement “𝒙 + 𝒚 = 𝒚 + 𝒙.”
∀𝒙 ∀𝒚 𝑷 𝒙, 𝒚 reads as: "For all real numbers 𝑥 and for all real numbers 𝑦, 𝑥
+ 𝑦 = 𝑦 + 𝑥."
Since addition is commutative, 𝑥 + 𝑦 = 𝑦 + 𝑥 holds true for any pair of real
numbers 𝑥 and 𝑦.
Therefore, ∀ 𝑥 ∀ 𝑦 𝑃(𝑥, 𝑦) is true.
∀ 𝒚 ∀ 𝒙 𝑷 𝒙, 𝒚 reads as: "For all real numbers 𝑦 and for all real
numbers 𝑥, 𝑥 + 𝑦 = 𝑦 + 𝑥."
Since addition is commutative for real numbers, this statement
also holds true for any 𝑥 and 𝑦.
Thus, ∀ 𝑦 ∀ 𝑥 𝑃(𝑥, 𝑦) is also true.
Translating Mathematical Statements into Statements
Involving Nested Quantifiers
Translate the statement “The sum of two positive integers is always
positive” into a logical expression.
Solution.
Rewrite: : “For every two integers, if these integers are both positive,
then the sum of these integers is positive.”
Introduce variable: Let 𝑥 and 𝑦 be variables. “For all positive integers
𝑥 and 𝑦, 𝑥 + 𝑦 is positive.”
Translation: ∀ 𝑥 ∀ 𝑦 ((𝑥 > 0) ∧ (𝑦 > 0) → (𝑥 + 𝑦 > 0)), where the
domain for both variables consists of all integers.
Negating Nested Quantifiers
Given ∀ 𝑥 ∃ 𝑦 (𝑥𝑦 = 1). This reads as: "For every 𝑥, there
exists a y such that 𝑥𝑦 = 1.“
¬ ( ∀ 𝑥 ∃ 𝑦 (𝑥𝑦 = 1))
Apply the Negation Rules:
The negation of ∀𝒙 is ∃𝒙. The negation of ∃𝒚 is ∀𝒚.
So, we rewrite the negation as:
∃𝑥∀𝑦¬
(𝑥𝑦 = 1)
Use quantifiers to express the statement that "There does not exist a
woman who has taken a flight on every airline in the world".
Solution.
Let ‘𝑤′ represent woman and ‘a’ represent airline. Let 𝑃(𝑤, 𝑓) represent
“𝑤 has taken 𝑓” and 𝑄(𝑓, 𝑎) represent " 𝑓 is a flight on 𝑎.“
Statement: ¬ ∃ 𝑤 ∀ 𝑎 ∃ 𝑓 (𝑃(𝑤, 𝑓) ∧ 𝑄(𝑓, 𝑎))
By successively applying De Morgan’s laws for quantifiers,
∀𝑤¬∀𝑎∃𝑓 𝑃 𝑤, 𝑓 ∧ 𝑄 𝑓, 𝑎 ≡ ∀ 𝑤 ∃ 𝑎 ¬ ∃ 𝑓 𝑃 𝑤, 𝑓 ∧ 𝑄 𝑓, 𝑎
≡ ∀ 𝑤 ∃ 𝑎 ∀ 𝑓 ¬ 𝑃 𝑤, 𝑓 ∧ 𝑄 𝑓, 𝑎
≡ ∀ 𝑤 ∃ 𝑎 ∀ 𝑓 (¬𝑃(𝑤, 𝑓) ∨ ¬𝑄(𝑓, 𝑎)).
RULES OF INFERENCE
• An argument is a sequence of propositions.
• The final proposition is called the conclusion of the argument
while the other propositions are called the premises or
hypotheses of the argument.
• An argument is valid whenever the truth of all its premises
implies the truth of its conclusion.
• Rules of inference are patterns of logically valid deductions
from hypotheses to conclusions.
• Proofs in mathematics are valid arguments that establish the
truth of mathematical statements.
Determine whether the argument given here is valid and determine
whether its conclusion must be true because of the validity of the
argument.
3 2 3 2 3
“If 2> , then 2 > . We know that 2 > . Consequently,
2 2 2
2 3 2 9
2 =2> = .”
2 4
3 3 2
Solution. Let 𝑝: 2 > and 𝑞: 2 > .
2 2
Premises: 𝑝 → 𝑞, 𝑝
Conclusion: 𝑞
The argument is valid by the rule Modus ponens.
3
But 2 > is false. Consequently, we cannot conclude that the
2
¬𝑝 ∧ 𝑞 Premise
𝑟→𝑝 Premise
¬𝑟 → 𝑠 Premise
𝑠→𝑡 Premise
Proof.
Assume that the hypothesis of this conditional statement is true,
namely, we assume that m and n are both perfect squares.
By the definition of perfect square, it follows that there are
integers 𝑠 and 𝑡 such that 𝒎 = 𝒔𝟐 and 𝒏 = 𝒕𝟐 .
Hence 𝒎𝒏 = 𝑠 2 𝑡 2 = (𝑠𝑠)(𝑡𝑡) = (𝑠𝑡)(𝑠𝑡) = 𝒔𝒕 𝟐 , using
commutativity and associativity of multiplication.
By the definition of perfect square, it follows that 𝑚𝑛 is also a
perfect square, because it is the square of 𝑠𝑡, which is an integer.
PROOF BY CONTRAPOSITION
• Proofs that are not direct proofs, that do not start with the
premises and end with the conclusion, are called indirect proofs.
• An extremely useful type of indirect proof is known as proof by
contraposition.
• Proofs by contraposition make use of the fact that the conditional
statement 𝑝 → 𝑞 is equivalent to its contrapositive, ¬𝑞 → ¬𝑝.
• This means that the conditional statement 𝑝 → 𝑞 can be proved
by showing that its contrapositive, ¬𝑞 → ¬𝑝, is true.
• In a proof by contraposition of 𝑝 → 𝑞, we take ¬𝑞 as a premise,
and using axioms, definitions, and previously proven theorems,
together with rules of inference, we show that ¬𝑝 must follow.
Prove that if 𝑛 is an integer and 3𝑛 + 2 is odd, then 𝑛 is odd.
Direct Proof
Assume 3𝑛 + 2 is an odd integer. i.e. 3𝑛 + 2 = 2𝑘 + 1, for some
integer 𝑘.
This implies 3𝑛 + 1 = 2𝑘, but there does not seem to be any direct way
to conclude that 𝑛 is odd.
Proof by contraposition
Assume that the conclusion of the conditional statement is false; namely,
assume that 𝑛 is even. Then 𝑛 = 2𝑘 for some integer 𝑘. Substituting we
get
3𝑛 + 2 = 3(2𝑘) + 2 = 6𝑘 + 2 = 2 3𝑘 + 1 which is even.
Because the negation of the conclusion of the conditional statement
implies that the hypothesis is false, the original conditional statement is
true.
Prove that if 𝑛 is an integer and 𝑛2 is odd, then 𝑛 is odd.
Direct Proof
Suppose that 𝑛 is an integer and 𝑛2 is odd. Then, there exists an integer 𝑘
such that 𝑛2 = 2𝑘 + 1. There is no obvious approach to show that 𝑛 is
odd because solving for 𝑛 produces the equation 𝑛 = ±√2𝑘 + 1.
Proof by contraposition
Assume that the hypothesis of the statement is false; namely, assume that
𝑛 is even. Then 𝑛 = 2𝑘 for some integer 𝑘. Squaring on both sides, we
obtain
𝑛2 = 4𝑘 2 = 2(2𝑘 2 ) which is even.
Because the negation of the hypothesis statement implies that the
conclusion is false, the original conditional statement is true.
PROOF BY CONTRADICTION
• Suppose we want to prove that a statement 𝑝 is true.
Furthermore, suppose that we can find a contradiction 𝑞
such that ¬𝑝 → 𝑞 is true.
• Because 𝑞 is false, but ¬𝑝 → 𝑞 is true, we can conclude
that ¬𝑝 is false, which means that 𝑝 is true.
• Because the statement 𝑟 ∧ ¬𝑟 is a contradiction whenever
𝑟 is a proposition, we can prove that 𝑝 is true if we can
show that ¬𝑝 → 𝑟 ∧ ¬𝑟 is true for some proposition 𝑟.
• Proofs of this type are called proofs by contradiction. It is
another type of indirect proof.
Prove that √2 is irrational by giving a proof by contradiction.
Proof.
Let 𝑝 be the proposition “√2 is irrational.” Suppose that ¬𝑝 is true.
¬𝑝 : “It is not the case that √2 is irrational,” which says that √2 is
rational.
If √2 is rational, there exist integers 𝑎 and 𝑏 with √2 = 𝑎/𝑏, where
𝑏 = 0 and 𝑎 and 𝑏 have no common factors.
𝑎2
Squaring on both sides of the equation, 2 = .
𝑏2
Hence 2𝑏 2 = 𝑎2 .
By the definition of an even integer it follows that 𝑎2 is even.
Furthermore, since 𝑎 is even, 𝑎 = 2𝑐 for some integer 𝑐. Thus,
2𝑏 2 = 4𝑐 2 .
Dividing both sides of this equation by 2 gives 𝑏 2 = 2𝑐 2 . By the
definition of even, this means that 𝑏 2 is even which implies 𝑏 is even.
Thus, If √2 is rational, there exist integers 𝑎 and 𝑏 with √2 = 𝑎/𝑏,
where 𝑏 = 0 and a and 𝑏 have no common factors, but 𝑎 and 𝑏 are
even.
i.e. 2 divides a and b.
This is a contradiction to our assumption that 𝑎 and 𝑏 have no
common factors.
Then ¬𝑝 must be false. That is, the statement 𝑝,“√2 is irrational,” is
true.
Give a proof by contradiction of the theorem “If 3𝑛 + 2 is odd, then
𝑛 is odd.”
Proof. Let 𝑝 be “3𝑛 + 2 is odd” and 𝑞 be “𝑛 is odd.”
Assume that both 𝑝 and ¬𝑞 are true. That is, 3𝑛 + 2 is odd and 𝑛 is
not odd.
𝑛 is not odd implies that it is even. Then there is an integer 𝑘 such
that 𝑛 = 2𝑘.
This implies that 3𝑛 + 2 = 3(2𝑘) + 2 = 6𝑘 + 2 = 2(3𝑘 + 1).
Then 3𝑛 + 2 is even. The statement “3𝑛 + 2 is even” is equivalent
to the statement ¬𝑝, because an integer is even if and only if it is not
odd.
Because both 𝑝 and ¬𝑝 are true, we have a contradiction.
Thus, if 3𝑛 + 2 is odd, then 𝑛 is odd.
PROOF BY CASES
To prove
𝑝1 ∨ 𝑝2 ∨ ⋯ ∨ 𝑝𝑛 → 𝑞
we need to prove
𝑝1 → 𝑞 ∧ 𝑝2 → 𝑞 ∧ ⋯ ∧ 𝑝𝑛 → 𝑞
2
2 ( 2. 2) 2
𝑥𝑦 = 2 = 2 = 2 = 2.