3 Logic MTH1114

You might also like

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

MTH1114 Computer Mathematics

UNIT 3
FUNDAMENTALS OF LOGIC
Zaharin Yusoff (Prof Dr)

SCHOOL
UNIT 3 – Fundamentals of Logic
UNIT 3 – Fundamentals of Logic

 Expressing Statements: Basic  simplifying statements, and


determining truth values of compound statements
ESS
 Basic Connectives and Truth Tables OC
 Logical Equivalence: Laws of Logic PR
 Logical Implications: Rules of Inference

 Logical Equivalence: The Laws of Logic


 Logical Equivalence
 Laws of Logic
 Rules of Substitution

 Logical Implication : Rules of Inference


 Logical Implication: Valid Arguments
 Rules of Inference
 Proof by Contradiction

 Expressing Statements: 1st Order Logic  logic programming


 Use of Quantifiers
3.1 Basic Connectives and Truth Tables
(pg. 47 55)
Basic Connectives and Truth Tables

Assertions, called statements (or propositions), are declarative sentences that are
either true or false – but not both.

Examples
1) 1+1=2
2) 2+2=3
3) Toronto is the capital city of Canada.
4) Washington D.C. is the capital city of USA.

(1) and (4) are true while statements (2) and (3) are false.

The truth value of a statement is either:


− True, and is denoted by T or 1 if it is a true statement, or
− False, and is denoted by F or 0 if it is a false statement.

A statement with no truth value is not a proposition, such as:


• 3+1
• Go away!
A statement is said to be a primitive statement if there is really no way to break
it down into anything simpler

All the statements (1)—(4) above are primitive statements

A statement that can be broken up into or or more primitive statements is called a


compound statement.

The primitive statements within a compound statement are combined using:


 negation (NOT): ¬p,
 logical connectives
a) conjunction (AND): p∧q
b) disjunction (inclusive OR): p∨q (one or the other is true,
or both)
c) disjunction exclusive (XOR): p∨q (either one is true, but not
both)
d) implication: p→q (p is hypothesis, q is
conclusion)
(if p then q, p implies q
p is sufficient for q means p implies q
p is necessary for q means q implies p
e) biconditional: p↔q
Examples
p: I passed the exam r: I hate Discrete Mathematics
q: I attend classes s: I love Discrete Mathematics

 Negation (NOT): ¬p,


¬p: I did not pass the examThese are essentially (compound) statements.
They need not necessarily be true
 Conjunction (AND): p ∧ q
q ∧ p: I attend classes and I passed the exam
¬q ∧ p: I did not attend classes but I passed the exam

 Disjunction (inclusive OR): p∨q (one or the other is true, or both)


r ∨ p: I hate Discrete Mathematics or I passed the exam
 Exclusive (XOR): p ∨ q (either one is true, but not both)
p ∨ q : I hate Discrete Mathematics or I love Discrete Mathematics

 Implication: p → q (p is hypothesis, q is conclusion)


s → q: If I love Discrete Mathematics then I attend classes

 Biconditional: p↔q
q ↔ s: I attend classes if and only if I love Discrete Mathematics
Examples
s: Phyllis goes out for a walk.
t: The moon is out.
u: It is snowing.

If the moon is out and it is not snowing, then Phyllis goes out for a walk.

( t  u )  s
If it is snowing and the moon is not out, then Phyllis will not go out for a walk.
( u  t )  s

It is not the case that Phyllis goes out for a walk


if and only if it is snowing or the moon is out

  s  u  t 
A truth table displays the relationships among the truth values of statements.
In constructing such truth tables, we write “0” for false and “1” for true.

p q p∧q p∨q p∨q p→q p↔q

0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1 1

Example
Find the truth table for the statement ((p Ù q) ® Øq) Ú r.

(( ) )
Examples
q Ù (Ør ® p)

p Ú (q Ù r) and (p Ú q) Ù r p Ú (q Ù r) ¹ (p Ú q) Ù r
If all the truth values for a statement are true (1),
then the statement is called a tautology.
If all its truth values are false (0), then the statement is called a contradiction.
If the truth values are a combination of 0’s and 1’s,
then the statement is called a contingency.

Examples
p ® (p Ú q) tautology
p Ù (Øp Ù q) contradiction
3.2 Logical Equivalence: The Laws of Logic
(pg. 55  67)

The underlying idea in this section is that we cannot and should not be
constructing truth tables for all statements that we meet (they are large
and tedious). There must be ways of handling the symbols as we do
with numbers  hence the Laws of Logic ….
Logical Equivalence

Two statements s1, s2 are said to be logically equivalent, and we write s1⇔ s2,
when the statement s1 is true (respectively, false) if and only if the statement s2 is
true (respectively, false). [This also means s1« s2, is a tautology]

Examples (p ® q) Û (Øp Ú q) [(p ® q) « (Øp Ú q) is a tautology]

(p « q) Û (p ® q) Ù (q ® p)
(p « q) Û (Øp Ú q) Ù (Øq Ú p)
We can express the connective Ú with Ø, Ù and Ú using:
(p Ú q) Û (p Ú q) Ù Ø(p Ù q)

In the table below, we have constructed the truth tables for the statements
Ø(p Ù q), Øp Ú Øq, Ø(p Ú q), and Øp Ù Øq,
where p and q are primitive statements.
The Laws of Logic (1 of 2)

For any primitive statements p, q, r, any tautology T0, and any contradiction F0

All these can be proven by constructing truth tables


The Laws of Logic (2 of 2)

All these can be proven by constructing truth tables


10) p Ú (p Ù q) Û p
Absorption Laws
p Ù (p Ú q) Û p
Using the Laws of Logic (Examples)

For primitive statements p, q, is there any simpler way to express the


compound statement (p Ú q) Ù Ø(Øp Ù q) – that is, can we find a simpler
statement that is logically equivalent to the one given?
 
(p Ú q) Ù Ø(Ø p Ù q) Reasons
Û (p Ú q) Ù (ØØ p Ú Øq) DeMorgan’s Law
Û (p Ú q) Ù (p Ú Øq) Law of Double Negation
Û p Ú (q Ù Øq) Distributive Law of Ú over Ù
Û p Ú F0 Inverse Law
Û p Identity Law
 
\ (p Ú q) Ù Ø(Ø p Ù q) Û p
Simplify the compound statement
 
Ø(Ø((p Ú q) Ù r) Ú Øq)
 
From the laws of logic it follows that
 
Ø(Ø((p Ú q) Ù r) Ú Øq) Reasons
Û ØØ((p Ú q) Ù r] Ù ØØq) DeMorgan’s Law
Û ((p Ú q) Ù r) Ù q Law of Double Negation
Û (p Ú q) Ù (r Ù q) Associative Law of Ù
Û (p Ú q) Ù (q Ù r) Commutative Law of Ù
Û ((p Ú q) Ù q) Ù r Associative Law of Ù
Û qÙr Absorption Law
(as well as the Commutative
Laws for Ù and Ú)
 
\ Ø(Ø((p Ú q) Ù r] Ú Øq) Û q Ù r
The table below gives the truth tables for the statements
p ® q, Øq ® Øp, q ® p, and Øp ® Øq.

The 3rd and 4th columns of the table reveal that


(p ® q) Û (Øq ® Øp) called the contrapositive

Columns 5 and 6 of the table show that


(q ® p) called the converse of ( p →q)
and (Øp ® Øq) called the inverse of ( p →q)
The table also shows that
(p ® q) Û (q ® p) and (Øp ® Øq) Û (p ® q)
Simplify the compound statement
 
(p ® q) Ù (Øq Ù (r Ú Øq))
 
From the laws of logic it follows that
 
(p ® q) Ù (Øq Ù (r Ú Øq)) Reasons
Û (p ® q) Ù Øq Absorption Laws
Û (Øp Ú q) Ù Øq Substitution (p ® q) Û (Øp Ú q)
Û Øq Ù (Øp Ú q) Commutative Law of Ù
Û (Øq Ù Øp) Ú (Øq Ù q) Distributive Laws
Û (Øq Ù Øp) Ú F0 Inverse Laws
Û (Øq Ù Øp) Identity Laws
Û Ø(q Ú p) DeMorgan
Laws
1) (b) Use the Laws of Logic to prove that the following is a tautology

((p  Ø(Ø p  q))  (p  q))  p

((p  Ø (Øp  q))  (p  q))  p


Û ((p  (Ø(Øp)  Øq))  (p  q)) p De Morgan’s law
Û ((p  (p  Øq))  (p  q))  p Double Negation law
Û (((p  p)  Øq)  (p  q))  p Associative law
Û ((p  Øq)  (p  q))  p Idempotent law
Û (p  (Øq  q))  p Distributive law
Û (p  T0)  p Inverse law
Ûpp Identity law
Û Øp  p Substitution a  b Û Øa  b
Û T0 Inverse law
3.3 Logical Implication : Rules of Inference
(pg. 67  86)
Laws of Inference

1) Valid Argument: (p1 Ù p2 Ù p3 Ù … Ù pn) ® q

2) Modus Ponens: [p  (p  q)]  q.

3) Law of the Syllogism: [(p  q)  (q  r)]  (p  r)

4) Modus Tollens: [(p  q)  q]  p

5) Proof by Contradiction / Reductio ad Absurdum


Assume conclusion is false  Contradiction
Logical Implication

Given (p1 Ù p2 Ù p3 Ù … Ù pn) ® q. where n is a positive integer.

The statements p1, p2, p3, …, pn are called the premises of the argument, and the
statement q is the conclusion for the argument.
An argument is called valid if whenever each of the premises p1, p2, p3, …, pn is true,
then the conclusion q is likewise true.

Note that if any one of p1, p2, p3, …, pn is false, then the hypothesis p1 Ù p2 Ù … Ù pn is
false and the implication (p1 Ù p2 Ù p3 Ù … Ù pn) ® q is automatically true, regardless of
the truth value of q.

Consequently, one way to establish the validity of a given argument is to show that the
statement (p1 Ù p2 Ù p3 Ù … Ù pn) ® q is a tautology.
Example And let p1, p2, p3 denote the premises
Let p, q, r denote primitive statements: p1: If Roger studies, then he will pass
p: Roger studies. discrete mathematics.
q: Roger plays tennis. p2: If Roger doesn’t play tennis, then
r: Roger passes discrete mathematics. he’ll study.
p3: Roger failed discrete mathematics
We want to determine whether the following argument
. is a valid argument:
(p1 Ù p2 Ù p3) ® q

To do so, we rewrite p1, p2, p3 as: p1: p ® r p2: Øq ® p, p3: Ør

[(p ® r) Ù (Øq ® p) Ù Ør] ® q

(p1 Ù p2 Ù p3) ® q is a tautology and hence a valid argument.


Rules of Inference

One rule of inference is called Modus Ponens, or the Rule of Detachment.


(Modus Ponens comes from Latin to mean “the method of affirming.”). In symbolic
form this rule is expressed by the logical implication
[p  (p  q)]  q.

This is verified in the table below, where we find that the fourth row is the only one
where both of the premises p and p  q (and the conclusion q) are true.

The actual rule will be written in the form: p


p q
 q

This rule arises when we argue that if (1) p is true, and (2) p  q is true (or p  q),
then the conclusion q must also be true. (After all, if q were false and p were true,
then we could not have p  q true.)
Examples (Modus Ponens)
a) 1) Lydia wins a ten-million-dollar lottery p
2) If Lydia wins a ten-million-dollar lottery, then Kay will quit her job pq

3) Therefore Kay will quit her job.  q


b) 1) If Allison vacations in Paris, then she will have
to win a
scholarship.
pq
The2)second
Allisonrule
is vacationing
of inferenceinisParis. p Syllogism, which is given by
called the Law of the
the 3) Therefore
logical Allison won a scholarship.
implication  q
[(p  q)  (q  r)]  (p  r)

In tabular form it is written pq


qr
 pr
Example (Syllogism)
1) If the integer 35244 is divisible by 396,
then the integer 35244 is divisible by 66. pq
2) If the integer 35244 is divisible by 66,
then the integer 35244 is divisible by 3. qr
3) Therefore, if the integer 35244 is divisible by 396,
then the integer 35244 is divisible by 3. pr
Example
1) Rita is baking a cake. p
2) If Rita is baking a cake, then she is not practicing her flute. p
q
3) If Rita is not practicing her flute, then her father will not buy her a car. q  r
4) Therefore Rita’s father will not buy her a car.  r
(1) ∧ (2) ∧ (3) ⇒ (4) [i.e. it is a valid argument]. It can be shown in two ways:
 (1) & (2) ⇒ q (Modus Ponens) & (3) ⇒ r (Modus Ponens)
 (2) & (3) ⇒ p  r (Syllogism) & (1) ⇒ r (Modus Ponens)

The third rule of inference is called Modus Tollens, which is given by the logical
implication
[(p  q)  q]  p

In tabular form it is written pq


q
 p
Modus Tollens comes from Latin and can be translated as “method of denying.”
This is appropriate because we deny the conclusion, q, so as to prove p.
(Note that we can also obtain this rule from the one for Modus Ponens by using
the fact that p  q  q  p.)
Example (Modus Tollens)
1) If Connie is elected president of Phi Delta sorority,
then Helen will pledge that sorority. pq
2) Helen did not pledge Phi Delta sorority. q
3) Therefore Connie was not elected  p
president of Phi Delta sorority.

Example pr
rs
The following is a valid argument
t  s
t  u
u
Steps Reasons  p
1) p  r, r  s Premises
2) ps Step (1) and the Law of the Syllogism
3) t  s Premise
4) s  t Step (3) and the Commutative Law of 
5) st Step (4) and the fact that s  t  s  t
6) pt Steps (2) and (5) and the Law of the Syllogism
7) t  u Premise
8) tu Step (7) and the fact that t  u  t  u
9) pu Steps (6) and (8) and the Law of the Syllogism
10) u Premise
11)  p Steps (9) and (10) and Modus Tollens
A word of warning ….

Some seemingly ‘easy’ conclusions may not be valid arguments. For example, the
preceding argument shows that
[(p  r)  (r  s)  (t  s)  (t  u)  u]  p.
But note that
[(p  r)  (r  s)  (t  s )  (t  u)  u]  p.

For when p has the truth value 0 and u has the truth value 1, the truth value of p is
1 while that of u and (p  r)  (r  s)  (t  s )  (t  u)  u is 0.

The same is the case for the following, which are NOT valid arguments:

1) If Margaret Thatcher is the president of the United


States, then she is at least 35 years old. pq
2) Margaret Thatcher is at least 35 years old. q
3) Therefore Margaret Thatcher is the president of the United States.  p

4) If 2 + 3 = 6, then 2 + 4 = 6. p  q
5) 2 + 3 ≠ 6. p
6) Therefore 2 + 4 ≠ 6.  q
There are other rules of inference, albeit less major …

Rule of Conjunction p
q
 pq
Rule of Disjunctive Syllogism p  q
p
 q

Rule of Contradiction p  F0
 p

This rule tells us that if p is a statement and p  F0 is true, then p must be


false because F0 is false. So then we have p true.

The Rule of Contradiction is the basis of a method for establishing the validity of
an argument  namely, the method of Proof by Contradiction, or Reductio ad
Absurdum. The idea behind the method of Proof by Contradiction is:
• to establish a statement (namely, the conclusion of an argument)
• by showing that, if this statement were false, then we would be able to
deduce an impossible consequence (or contradiction).
Example
pq
q  (r  s)
r  (t  u)
pt
 u

Steps Reasons
1) p  q Premise
2) q  (r  s) Premise
3) p  (r  s) Steps (1) and (2) and the Law of the Syllogism
4) p  t Premise
5) p Step (4) and the Rule of Conjunctive Simplification
6) r  s Steps (5) and (3) and the Rule of Detachment
7) r Step (6) and the Rule of Conjunctive Simplification
8) r  (t  u) Premise
9) (r  t)  u Step (8), the Associative Law of , and DeMorgan’s Laws
10) t Step (4) and the Rule of Conjunctive Simplification
11) r  t Steps (7) and (10) and the Rule of Conjunction
12) u Steps (9) and (11), the Law of Double Negation,
and the Rule of Disjunctive Syllogism
3.4 The Use of Quantifiers
(pg. 86  103)
The Use of Quantifiers

A declarative sentence is an open statement if


1) it contains one or more variables, and
2) it is not a statement, but
3) it becomes a statement when the variables in it are replaced by certain
allowable choices (from a Universe).

Examples The number x + 2 is an even integer.


…. x = y, …, x > y, …., x < y, …

We can write:
p(x): The number x + 2 is an even integer
[Then ¬p(x) may be read “The number x + 2 is not an even integer”.]

Similarly for two or more variables.


 
q(x, y): The numbers y + 2, x – y, and x + 2y are even integers.
 
Thus: p(5): The number 7 (=5 + 2) is an even integer. (FALSE)
¬p(7): The number 9 is not an even integer. (TRUE)
q(4, 2): The numbers 4, 2, and 8 are even integers. (TRUE)
Quantifiers quantify elements of a given universe vis-à-vis an open statement,
and is written preceding the said statement:
 existential quantifier – For some x (or there exists an x): $
 universal quantifier – For all x: "

A variable is either free or bound:


• bound if quantified – x is bound in $x p(x) or "x p(x)
• Free otherwise – free in p(x)
Example
Given the universe as all real numbers, and open statements:
p(x): x≥0
q(x): x2 ≥ 0
r(x): x2 – 3x – 4 = 0
s(x):x2 – 3 > 0
$x [p(x) Ù r(x)] is true
This follows because the real number 4, for example, is a number of the universe
and is such that both of the statements p(4) and r(4) are true. But the following is
obviously false as p(x) is always false for any negative x:
"x [p(x) Ù r(x)] is false

"x [p(x) ® q(x)] is true


 
If we replace x in p(x) by a negative real number a, then p(a) is false, but the
p(a) ® q(a) would still be true regardless of the truth of q(a). Replacing x in p(x)
by a nonnegative real number b, we find that p(b) and q(b) are both true, as is
p(b) ® q(b). Consequently, p(x) ® q(x) is true for all replacements x taken from
the universe of all real numbers, and the (quantified) statement "x [p(x) ® q(x)] is
true.
Observe that "x p(x) Þ $x p(x), but not conversely
• The open statements p(x) and q(x) defined for a given universe are called
(logical) equivalent, and we write "x [p(x) Û q(x)] when the biconditional
p(a) « q(a) is true for each replacement a from the universe (that is, p(a) Û q(a)
for each a in the universe).
• If the implication p(a) ® q(a) is true for each a in the universe (that is, p(a) Þ q(a)
for each a in the universe), then we write "x [p(x) Þ q(x)] and say that p(x)
logically implies q(x).

For open statements p(x), q(x) – defined for a prescribed universe – and the
universally quantified statement "x [p(x) ® q(x)], we define:
1) The contrapositive of "x [p(x) ® q(x)] to be "x [Øq(x) ® Ø p(x)].
2) The converse of "x [p(x) ® q(x)] to be "x [q(x) ® p(x)].
3) The inverse of "x [p(x) ® q(x)] to be "x [Øp(x) ® Ø q(x)].

We have:
THANK YOU TERIMA KASIH
MERCI ARIGATO/ OKINI
GRAZZIE GO MA SSEUM NI DA
GRACIAS SHUKRIYA
SPASIBA XIE-XIE NI
DANKE KAMSIAH / MMKOI
MANGE TAK JABAI INAU
NAN DHRI NGGO BUTE KABU
CAM ON KOP KUN KAH

You might also like