L02Proposition MSR2023

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

Propositional Logic

This Lecture

In the last lecture we introduced logic formulas.

In this lecture we are going to use logic to derive things.

The two important components in this lecture are:

 Conditional Statements

 Arguments
Conditional Statement (Implication)

If p then q p implies q

p is called the hypothesis; q is called the conclusion


antecedent consequent
The department says: “If your GPA is 4.0, then you will have full scholarship.”

When is the above sentence false?

• It is false when your GPA is 4.0 but you don’t receive full scholarship.
• But it is not false if your GPA is below 4.0.
• So, if your GPA is below 4.0, it is true irrespective of whether you
receive full scholarship or not.

Another example: “If there is a match of Bangladesh, then there is no class.”

When is the above sentence false?


Logic Operator

 :: IMPLIES
P Q P Q
Q is true: T T T
T F F
F T T
P is false
F F T

Convention: if we don’t say anything wrong, then it is not false, and thus true.

An implication is true provided P is false or Q is true (or both), and


false otherwise.
Example Implications
• The most common type of statement in
mathematics is the implication.
• Consider the Pythagorean Theorem:
a b c
2 2 2 Would you agree that this is the theorem?

• The equation is true as long asNO


Is this a statement?
a and b
are the legs or a right triangle and c is
the hypotenuse.
• We thus make it a statement:
Suppose a, b, c represent the three sides of a triangle. If a
and b are the legs of a right triangle with hypotenuse c, then

a b c
2 2 2
Implications
• This is a reasonable way to think about
implications:
– our claim is that the conclusion (“then” part) is
true, but on the assumption that the
hypothesis (“if” part) is true.
– We make no claim about the conclusion in
situations when the hypothesis is false.
• This is why when the hypothesis is false,
we don’t say anything wrong, i.e., our
statement is NOT false, and thus true.
Implication
• What do you mean if you say, p  q is
false?
• You mean:
– p is true and
– q is false
https://forms.gle/zES9NujMKFqTjLfo7
Implication Exercise
Which of the following are True/False?
• If 1 = 1, then most horses have 4 legs.
• If 0 = 1, then 1 = 1.
• If 8 is a prime number, then the 7624th digit
of π is an 8.
• If the 7624th digit of π is an 8, then 2 + 2 = 4.

An implication is true provided P is false or Q is true (or both), and


false otherwise.
Logical Equivalence
We want a
(compound)
statement
equivalent to
left hand side

If you see a question in the above form,


there are usually 3 ways to deal with it.
(1) Truth table
(2) Use logical rules
(3) Intuition
If-Then as Or
An implication is true
provided P is false or Q
is true (or both), and
false otherwise.
P Q P Q Idea 2: Look at the false rows,
T T T negate and take the “and”.

T F F
F T T
DeMorgan’s
F F T Laws

• If you don’t give me all your money, then I will kill you.
• Either you give me all your money or I will kill you (or both).

• If you talk to her, then you can never talk to me.


• Either you don’t talk to her or you can never talk to me (or both).
If-Then as Or
P  Q  ~P or Q

P Q
• If you don’t give me all your money, then I will kill you.
• Either you give me all your money or I will kill you (or both).

~P
P Q
• If you talk to her, then you can never talk to me.
• Either you don’t talk to her or you can never talk to me (or both).

~P
Direct proofs of implications
• To prove an implication P → Q:
– it is enough to assume P, and from it, deduce Q.
– i.e., you must explain why Q is true, but you get
to assume P is true first.
• Direct proof is the easiest style of proof and
has the advantage that such a proof often
does a great job of explaining why the
statement is true.
Direct proofs of implications
• If two numbers a and b are even, then
their sum a + b is even.

Proof:
P Q
assume P • Suppose the numbers a and b are even.
• This means that a = 2k and b = 2j for
some integers k and j.
• The sum is then a + b = 2k + 2j = 2(k +
j).
• Since k + j is an integer, this means that
Deduce Q
a + b is even.
QED
Negation of If-Then

(if p then q) 
p q  (if p then q)
p  q  (if p then  q)
p  q  (if p then  q)

p  q  p q
Negation of If-Then

previous slide

DeMorgan
Negation of If-Then

P Q
• If you eat an apple everyday, then you have no toothache.
• You eat an apple everyday but you have toothache.

negate
~Q
P Q
• If my computer is not working, then I cannot finish my homework.
• My computer is not working but I can finish my homework.
negate
~Q
Contrapositive

The contrapositive of “if p then q” is “if ~q then ~p”.

Statement: If you are a CS year 1 student,


then you are taking CSC 2110.

Contrapositive: If you are not taking CSC 2110,


then you are not a CS year 1 student.

Statement: If x2 is an even number,


then x is an even number.

Contrapositive: If x is an odd number,


then x2 is an odd number.
Fact: A conditional statement is logically equivalent to its contrapositive.

Often it is easier to analyze the contrapositive.


Proofs

Statement: If P, then Q

Contrapositive: If Q, then P.
Proof using the Truth table

T T T F F T
T F F T F F
F T T F T T
F F T T T T

Proof using logical rules…


Inverse
• The Inverse of an implication P → Q is the
implication ~P → ~Q .
• The inverse is NOT logically equivalent to
the original implication.
– That is, whether the inverse of an implication
is true is independent of the truth of the
implication
Converse
• The converse of an implication P → Q is
the implication Q → P.
• The converse is NOT logically equivalent
to the original implication.
– That is, whether the converse of an
implication is true is independent of the truth
of the implication
Converse and Inverse
• Converse and Inverse of a statement are
logically equivalent to each other…
• Why/How?
– P -> Q
– Inverse: ~P -> ~Q
– Converse: Q -> P
– Contrapositive of ~P -> ~Q is ~~Q -> ~~P, i.e.,
Q -> P.
Converse
• Mathematics is overflowing with examples of
true implications which have a false converse.
– If a number greater than 2 is prime, then that
number is odd.
• CONVERSE: If a number (>2) is odd, then it is a
prime
• However, just because a number is odd does not
mean it is prime.
– If a shape is a square, then it is a rectangle.
• CONVERSE: If a shape is a rectangle, then it is a
square
• But it is false that if a shape is a rectangle, then it
is a square.
Converse
• Sometimes the converse of a true
statement is also true.
• For example, the Pythagorean theorem
has a true converse: Suppose, a, b, c are
the three sides of a triangle. if a2 + b2 = c2,
then the triangle with sides a, b, and c is a
right triangle.
• Whenever you encounter an implication in
mathematics, it is always reasonable to
ask whether the converse is true.
When both P → Q and Q → P are true, we say that P and
Q are equivalent and write P ↔ Q. This is also called the
biconditional. We will come back to this soon….
Implication and Converse
and contrapositive
• True or False: If you draw any nine playing
cards from a regular deck, then you will
have at least three cards all of the same
suit.
• contrapositive: If you don’t have at least
three cards all of the same suit, then you
don’t have nine cards.
• True: you can at most have two cards of
each of the four suits, for a total of eight
cards (or fewer).
Understanding implications
Please take this quiz while students are
coming and joining the class…

https://forms.gle/nW2nnTZidUobUzqd9
Understanding implications
P Q P
• Suppose I tell Rimpi that if she gets a 93% on
her final, then she will get an A in the class.
Assuming that what I said is true, what can you
Q
conclude in the following cases:
P is true; since P  Q is
• Rimpi gets a 93% on her final. true; Q must be true
– Rimpi gets an A.
Q is true; P  Q is given true;
• Rimpi gets an A in the class. But P still can be both true or
– Cannot conclude anything. false. P is false; P  Q is
(automatically)
• Rimpi does not get a 93% on her final. true; Q can be
– Cannot conclude anything. both true or false.
• Rimpi does not get an A in the class. Q is false; P  Q is
given true; P then
– Rimpi does not get a 93% on her final. must be false.
Implies, if, only if
• We can say: Q if P (i.e., if
P Q P Q P then Q)
– P is a sufficient condition
T T T
T F F for Q
F T T • Or we can say P only if Q.
F F T – i.e., if not q, then not p.
• (i.e., contrapositively: if p
Look at the True rows;
then q.)
When P is true, – Q is a necessary condition
what about Q? Q is also true!
So, P is sufficient to make Q true for P
(Note that Q can still be true Look at the True rows;
when P is not.) Can P be true without Q being true?
No! So, Q is necessary for P to be true.
If you work hard., you will succeed
SR If, Only-If R = you will
succeed
• You will succeed if you work hard.
S = you work
• You will succeed only if you work hard.
hard

R if S means “if S then R” or equivalently “S implies R”

We also say S is a sufficient condition for R.

R only if S means “if R then S” or equivalently “R implies S”

We also say S is a necessary condition for R.

You will succeed if and only if you work hard.

P if and only if (iff) Q means P and Q are logically equivalent.

That is, P implies Q and Q implies P.


Math vs English

Parent: if you don’t clean your room, then you can’t watch a DVD.

C D
contrapositive
This sentence says DC

In real life it also means


So

Mathematician: if a number x greater than 2 is not an odd number,


then x is not a prime number.
O = x > 2 is an odd
number
This sentence says
P = x > 2 is a
But of course it doesn’t mean prime number
Necessary, Sufficient Condition

Mathematician: if a number x greater than 2 is not an odd number,


then x is not a prime number.
O = x > 2 is an odd P = x > 2 is a
number prime number
This sentence says

But of course it doesn’t mean

Contrapositive
Mathematician: if a number x greater than 2 is a prime number
then x is a odd number.

Being an odd number > 2 is a necessary condition for this number to be prime.
P only if O

Being a prime number > 2 is a sufficient condition for this number to be odd.
O if P
Necessary AND Sufficient Condition

 :: IFF
P Q P Q
T T T
T F F
F T F
F F T
Note: P Q is equivalent to (P Q) (Q P)

Note: P Q is equivalent to (P Q) ( P Q)

Is the statement “x is an even number if and only if x 2 is an even number” true?


Another Proof!
• x is an even number if and only if x2 is an
even number.
• p = x is an even number
• q = x2 is an even number
• So we need to prove: p  q
– i.e., p  q and q  p
x is an even number if and only if x2 is an even number
Proof:
p = x is an even number
a. p  q q = x2 is an even number

x is even  x = 2k
 x2 = (2k) 2 = 4k2, which is even
b. q  p
x2 is even  x2 = 2k
 x = √(2k) =

b. q  p  p  q CONTRAPOSITIVE

x is NOT even  x = 2k + 1
 x2 = (2k + 1) 2 = 4k2 + 2k + 1, which is NOT even
Hypothesis and Conclusion
May not be related

• If 1 = -1, then I am the King of the world


• If computers are machines, then Mashrafi
is a Cricket Player
• If 2+2 = 5, then Chandler is a girl.
• But for meaningful statements, we
formulate an implication when there is a
relation between the hypothesis and
conclusion.
This Lecture

 Conditional Statements

• The meaning of IF and its logical forms

• Contrapositive

• If, only if, if and only if

 Arguments
Argument Form
An argument is a sequence of statements forms.
All statement forms but the final one are called assumptions or hypothesis
or premises.
The final statement form is called the conclusion.
An argument form is valid if:

No matter what particular statements are substituted for


the statement variables in its premises,
whenever all the assumptions are true, then the conclusion
is true.
Argument

An argument is a sequence of statements.


All statements but the final one are called assumptions or hypothesis.
The final statement is called the conclusion.
An argument is valid if: its form is valid

If today is Wednesday, then yesterday is Tuesday.

Today is Wednesday.

Yesterday is Tuesday.

This is valid, because its form is valid: See next slide…


Modus Ponens

If p then q. If typhoon, then class cancelled.


p Typhoon.
q Class cancelled.

assumptions conclusion

p q p→q p q
T T T T T
T F F T F
F T T F T
F F T F F

Modus ponens is Latin meaning “method of affirming”.


Modus Tollens

If p then q. If typhoon, then class cancelled.


~q Class not cancelled.
~p No typhoon.

assumptions conclusion

p q p→q ~q ~p
T T T F F
T F F T F
F T T F T
F F T T T

Modus tollens is Latin meaning “method of denying”.


Equivalence

A student is trying to prove that propositions P, Q, and R are all true.


She proceeds as follows.
First, she proves three facts:
• P implies Q
• Q implies R
• R implies P.
Then she concludes,
``Thus P, Q, and R are all true.''

Proposed argument: assumption

( P  Q), (Q  R ), ( R  P ) Is it valid?

PQ R
conclusion
Valid Argument?

( P  Q), (Q  R ), ( R  P ) Is it valid?

PQ R
assumptions conclusion
P Q R OK?
T T T T T T T yes
T T F T F T F yes
T F T F T T F yes
T F F F T T F yes
F T T T T F F yes
F T F T F T F yes
F F T T T F F yes
F F F T T T F no

Assumptions are true, but not the conclusion.

To prove an argument is not valid, we just need to find a counterexample.


Valid Arguments?
assumptions conclusion

p q p→q q p
T T T T T
If p then q.
q T F F F T
p
F T T T F
F F T F F

Assumptions are true, but not the conclusion.

If you are a fish, then you drink water.


You drink water.
You are a fish.
Valid Arguments?
assumptions conclusion

p q p→q ~p ~q
T T T F F
If p then q.
~p T F F F T
~q
F T T T F
F F T T T

Assumptions are true, but not the conclusion.

If you are a fish, then you drink water.


You are not a fish.
You do not drink water.
Exercises
REMOVE THIS Exercises

P and Q
P or Q
P Q P Q
0 0 0 0 0 0

RECTANGLE
0 1 1 0 1 0
1 0 1 1 0 0
1 1 1 1 1 1

P or Q
P and Q P Q P

TO READ THE
P Q P 0 0 0 0
0 0 0 0 0 1 1 0
0 1 0 0 1 0 1 1
1 0 0 1 1 1 1 1
1 1 1 1

Q->R
P->Q

P->R
CONTENTS
P Q R
0 0 0 1 1 1
P or Q

0 0 1 1 1 1
P Q ~Q P
0 1 0 1 0 1
0 0 0 1 0 0 1 1 1 1 1
0 1 1 0 0 1 0 0 0 1 0
1 0 1 1 1 1 0 1 0 1 1
1 1 1 0 1 1 1 0 1 0 0
1 1 1 1 1 1
More Exercises
REMOVE THIS More Exercises

~P->~Q
RECTANGLE

P->Q
~P->Q P Q ~P ~Q
P ~P Q ~Q P 0 0 1 1 1 1
0 1 0 0 1 0 0 1 1 0 0 1
0 1 1 1 0 0 1 0 0 1 1 0

TO READ THE
1 0 0 1 1 1 1 1 0 0 1 1
1 0 1 1 0 1

CONTENTS
~P->~Q
Q->P

P Q ~P ~Q
0 0 1 1 1 1 Valid argument True conclusion
0 1 1 0 0 0
1 0 0 1 1 1 True conclusion Valid argument
1 1 0 0 1 1
Valid argument  True conclusion

If John Lennon was a Rock Star, then John Lennon had red hair.
John Lennon was a Rock Star.
\ John Lennon had red hair modus ponens

But Conclusion is False!!!

True conclusion  Valid argument

If New York is a big city, then New York has tall buildings.
New York has tall buildings.
 New York is a big city.

But Conclusion is True!!!


Which form is this?

P 
P Q
0 0 Q 
0 1
1 0
1 1
~P->C
Contradiction
P ~P C P
0 1 0 0 0 Here C means Contradiction

1 0 0 1 1
If you can show that the assumption that the statement
p is false leads logically to a contradiction,
then you can conclude that p is true.

This is similar to the method of denying (modus tollens)


Knights and Knaves

Knights always tell the truth.


Knaves always lie.

A says: B is a knight.
B says: A and I are of opposite type.

Suppose A is a knight.
Then B is a knight (because what A says is true).
Then A is a knave (because what B says is true)
A contradiction.

So A must be a knave.
So B must be a knave (because what A says is false).
Complex Deductions
You are about to leave for BUET in the morning and
discover that you don’t have your glasses. You know that
the following statements are true:
A. If my glasses are on the dining table, then I saw them at
breakfast.
B. I was reading the newspaper in the living room or I was
reading the newspaper in the dining room.
C. If I was reading the newspaper in the living room, then
the glasses are on the coffee table.
D. I did not see my glasses at breakfast
E. If I was reading Sohel sir’s lecture in bed, then my
glasses are on the bed side table
F. If I was reading the newspaper in the dining room, then
my glasses are on the dining table.
The glasses are on the coffee table.
Complex Deductions p~q q
You are about to leave for BUET in the  ~p
morning and discover that you don’t
have your glasses. You know that the By A and D and modus tollens:
following statements are true:
1. My glasses are not on the dining table
A. If my glasses are on the dining
table, then I saw them at breakfast.
By F and 1 and modus tollens:
B. I was reading the newspaper in the
living room or I was reading the 2. I was not reading the newspaper in
newspaper in the dining room. the dining room
C. If I was reading the newspaper in By B and 2 and elimination:
the living room, then the glasses are
on the coffee table. 3. I was reading the newspaper in the
living room
D. I did not see my glasses at
breakfast By C and 3 and modus ponens:
E. If I was reading Sohel sir’s lecture in
bed, then my glasses are on the bed 4. The glasses are on the coffee table.
side table
pq
The glasses are on
F. If I was reading the newspaper in
the dining room, then my glasses p
are on the dining table. q the coffee table.
Quick Summary

 Conditional Statements
• The meaning of IF and its logical forms
• Contrapositive
• If, only if, if and only if
 Arguments
• definition of a valid argument
• method of affirming, denying, contradiction

Key points:

(1) Make sure you understand conditional statements and contrapositive.

(2) Make sure you can check whether an argument is valid.


Which is true?

Which is false?

“The sentence below is false.”

“The sentence above is true.”


Exercise: Arguments

https://forms.gle/bne2KhRzPYncakW47

You might also like