Title: Propositional%20Logic
1Propositional Logic
2Content
- Mathematical proof (what and why)
- Logic, basic operators
- Using simple operators to construct any operator
- Logical equivalence, DeMorgans law
- Conditional statement (if, if and only if)
- Arguments
3Pythagorean theorem
Familiar? Obvious?
4Good Proof
c
b
b-a
a
b-a
We will show that these five pieces can be
rearranged into
(i) a c?c square, and then (ii) an a?a a b?b
square
And then we can conclude that
5Good Proof
The five pieces can be rearranged into
(i) a c?c square
c
b-a
c
c
a
b
c
6Good Proof
How to rearrange them into an axa square and a
bxb square?
c
b
a
7Good Proof
a
b
b
a
a
b-a
b
74 proofs in http//www.cut-the-knot.org/pythagora
s/index.shtml
8Bad Proof
A similar rearrangement technique shows that
6564
Whats wrong with the proof?
9Mathematical Proof
To prove mathematical theorems, we need a more
rigorous system.
The standard procedure for proving mathematical
theorems is invented by Euclid in 300BC. First
he started with five axioms (the truth of
these statements are taken for granted). Then he
uses logic to deduce the truth of other
statements.
- It is possible to draw a straight line from any
point to any other point. - It is possible to produce a finite straight line
continuously in a straight line. - It is possible to describe a circle with any
center and any radius. - It is true that all right angles are equal to one
another. - ("Parallel postulate") It is true that, if a
straight line falling on two straight lines make
the interior angles on the same side less than
two right angles, - the two straight lines, if produced
indefinitely, intersect on that side on which are
the angles less than the two right angles.
Euclids proof of Pythagoreans theorem
http//en.wikipedia.org/wiki/Pythagorean_theorem
(Optional) See page 18 of the notes for the ZFC
axioms that we now use.
10Content
- Mathematical proof (what and why)
- Logic, basic operators
- Using simple operators to construct any operator
- Logical equivalence, DeMorgans law
- Conditional statement (if, if and only if)
- Arguments
Now, we have seen the need of a rigorous proof
system. We will proceed to define the basic
logic system.
11Statement (Proposition)
A Statement is a sentence that is either True or
False
True
2 2 4
Examples
False
3 x 3 8
787009911 is a prime
Today is Tuesday.
Non-examples
xygt0 x2y2z2
They are true for some values of x and y but are
false for some other values of x and y.
12Logic Operators
Logic operators are used to construct new
statements from old statements. There are three
main logic operators, NOT, AND, OR.
P is true if and only if P is false
13Logic Operators
Logic operators are used to construct new
statements from old statements. There are three
main logic operators, NOT, AND, OR.
14Compound Statement
p it is hot
q it is sunny
It is hot and sunny It is not hot but
sunny It is neither hot nor sunny
We can also define logic operators on three or
more statements, e.g. OR(P,Q,R)
15More Logical Operators
We can define more logical operators as we need.
coffee or tea
majority
?
exclusive-or
P Q R M(P,Q,R)
T T T T
T T F T
T F T T
T F F F
F T T T
F T F F
F F T F
F F F F
p q p ? q
T T F
T F T
F T T
F F F
16Content
- Mathematical proof (what and why)
- Logic, basic operators
- Using simple operators to construct any operator
- Logical equivalence, DeMorgans law
- Conditional statement (if, if and only if)
- Arguments
We can define as many new operators as we
like. But we will see how to construct any
operator from AND, OR, NOT.
17Formula for Exclusive-Or
Idea 0 Guess and check
p q
T T F T F F
T F T T T T
F T T T T T
F F F F T F
Logical equivalence Two statements have the same
truth table
As you will see, there are many different ways to
write the same logical formula. One can always
use a truth table to check whether two statements
are equivalent.
18Exclusive-Or
Is there a more systematic way to construct such
a formula?
Idea 1 Look at the true rows
Idea 1 Look at the true rows
Idea 1 Look at the true rows
p q p ? q
T T F
T F T
F T T
F F F
Want the formula to be true exactly when the
input belongs to a true row.
The input is the second row exactly if this
sub-formula is satisfied
And the formula is true exactly when the input is
the second row or the third row.
19Exclusive-Or
Is there a more systematic way to construct such
a formula?
Idea 2 Look at the false rows
p q p ? q
T T F
T F T
F T T
F F F
Want the formula to be true exactly when the
input does not belong to a false row.
The input is the first row exactly if this
sub-formula is satisfied
And the formula is true exactly when the input is
not in the 1st row and the 4th row.
20Writing Logical Formula for a Truth Table
Digital logic
Given a digital circuit, we can construct the
truth table.
Now, suppose we are given only the truth table
(i.e. the specification, e.g. the specification
of the majority function), how can we construct a
digital circuit (i.e. formula) using only simple
gates (such as AND, OR, NOT) that has the same
function?
21Writing Logical Formula for a Truth Table
Use idea 1 or idea 2.
Idea 1 Look at the true rows and
take the or.
p q r output
T T T F
T T F T
T F T T
T F F F
F T T T
F T F T
F F T T
F F F F
The formula is true exactly when the input is one
of the true rows.
22Writing Logical Formula for a Truth Table
Idea 2 Look at the false rows, negate and
take the and.
p q r output
T T T F
T T F T
T F T T
T F F F
F T T T
F T F T
F F T T
F F F F
The formula is true exactly when the input is not
one of the false row.
23Content
- Mathematical proof (what and why)
- Logic, basic operators
- Using simple operators to construct any operator
- Logical equivalence, DeMorgans law
- Conditional statement (if, if and only if)
- Arguments
There are many different ways to write the same
logical formula. As we have seen, one can always
write a formula using only AND, OR, NOT.
24DeMorgans Laws
Logical equivalence Two statements have the same
truth table
Statement Tom is in the football team and the
basketball team. Negation Tom is not in the
football team or not in the basketball team.
De Morgans Law
Why the negation of the above statement is not
the following Tom is not in the football team
and not in the basketball team?
The definition of the negation is that exactly
one of P or P is true, but it could be the case
that both the above statement and the original
statement are false (e.g. Tom is in the football
team but not in the basketball team).
25DeMorgans Laws
Logical equivalence Two statements have the same
truth table
Statement The number 783477841 is divisible by 7
or 11. Negation The number 783477841 is not
divisible by 7 and not divisible by 11.
De Morgans Law
Again, the negation of the above statement is
not The number 783477841 is not divisible by 7
or not divisible by 11.
In either case, we flip the inside operator
from OR to AND or from AND to OR.
26DeMorgans Laws
Logical equivalence Two statements have the same
truth table
De Morgans Law
T T F F
T F T T
F T T T
F F T T
De Morgans Law
27Simplifying Statement
We can use logical rules to simplify a logical
formula.
DeMorgan
Distributive law
The DeMorgans Law allows us to always move the
NOT inside.
(Optional) See textbook for more identities.
28Tautology, Contradiction
A tautology is a statement that is always true.
A contradiction is a statement that is always
false.
(negation of a tautology)
In general it is difficult to tell whether a
statement is a contradiction. It is one of the
most important problems in CS the
satisfiability problem.
29Checkpoint
Key points to know.
- Write a logical formula from a truth table.
- Check logical equivalence of two logical
formulas. - DeMorgans rule and other simple logical rules
(e.g. distributive). - Use simple logical rules to simplify a logical
formula.
30Content
- Mathematical proof (what and why)
- Logic, basic operators
- Using simple operators to construct any operator
- Logical equivalence, DeMorgans law
- Conditional statement (if, if and only if)
- Arguments
31Conditional Statement
If p then q
p implies q
p is called the hypothesis q is called the
conclusion
If your GPA is 4.0, then you will have full
scholarship.
The department says
When is the above sentence false?
- It is false when your GPA is 4.0 but you dont
receive full scholarship. - But it is not false if your GPA is below 4.0.
Another example If there is typhoon T8 today,
then there is no class.
When is the above sentence false?
32Logic Operator
Convention if we dont say anything wrong, then
it is not false, and thus true.
Make sure you understand the definition of
IF. The IF operation is very important in
mathematical proofs.
33Logical Equivalence
- If you see a question in the above form,
- there are usually 3 ways to deal with it.
- Truth table
- Use logical rules
- Intuition
34If-Then as Or
Idea 2 Look at the false rows, negate and
take the and.
- If you dont 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 dont talk to her or you can never
talk to me (or both).
35Negation of If-Then
- If you eat an apple everyday, then you have no
toothache. - You eat an apple everyday but you have toothache.
- If my computer is not working, then I cannot
finish my homework. - My computer is not working but I can finish my
homework.
previous slide
DeMorgan
36Contrapositive
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 you drive, then you dont drink.
Contrapositive If you drink, then you dont
drive.
Fact A conditional statement is logically
equivalent to its contrapositive.
37Proofs
Statement If P, then Q
Contrapositive If Q, then P.
F F T
T F F
F T T
T T T
T T T
T F F
F T T
F F T
In words, the only way the above statements are
false is when P true and Q false.
38Contrapositive
Statement If P, then Q
Contrapositive If Q, then P.
Or we can see it using logical rules
Contrapositive is useful in mathematical proofs,
e.g. to prove
Statement If x2 is an even number, then x is
an even number.
You could instead prove
Contrapositive If x is an odd number, then x2
is an odd number.
This is equivalent and is easier to prove.
39If, Only-If
- You succeed if you work hand.
- You succeed only if you work 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.
40Necessary AND Sufficient Condition
Note P Q is equivalent to (P Q)
( P Q)
Is the statement x is an even number if and only
if x2 is an even number true?
41Math vs English
Parent if you dont clean your room, then you
cant watch a DVD.
C
D
This sentence says
So
In real life it also means
Mathematician if a number x greater than 2 is
not an odd number, then
x is not a prime number.
This sentence says
But of course it doesnt mean
42Necessary, Sufficient Condition
Mathematician if a number x greater than 2 is
not an odd number, then
x is not a prime number.
This sentence says
But of course it doesnt mean
Being an odd number gt 2 is a necessary condition
for this number to be prime. Being a prime
number gt 2 is a sufficient condition for this
number to be odd.
43Checkpoint
- Conditional Statements
- The meaning of IF and its logical forms
- Contrapositive
- If, only if, if and only if
44Content
- Mathematical proof (what and why)
- Logic, basic operators
- Using simple operators to construct any operator
- Logical equivalence, DeMorgans law
- Conditional statement (if, if and only if)
- Arguments
45Argument
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
whenever all the assumptions are true, then the
conclusion is true.
If today is Wednesday, then yesterday is
Tuesday. Today is Wednesday. Yesterday is
Tuesday.
Informally, an argument is valid if the
conclusion follows from the assumptions.
46Argument
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
whenever all the assumptions are true, then the
conclusion is true.
- It is possible to draw a straight line from any
point to any other point. - It is possible to produce a finite straight line
continuously in a straight line. - It is possible to describe a circle with any
center and any radius. - It is true that all right angles are equal to one
another. - ("Parallel postulate") It is true that, if a
straight line falling on two straight lines make
the interior angles on the same side less than
two right angles, - the two straight lines, if produced
indefinitely, intersect on that side on which are
the angles less than the two right angles.
Pythagoreans theorem
This is the formal way to prove theorems from
axioms.
47Modus Ponens
Rule
If p then q. p q
If typhoon, then class cancelled. Typhoon. 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.
48Modus Tollens
Rule
If p then q. q p
If typhoon, then class cancelled. Class not
cancelled. 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.
49Equivalence
- 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
Is it valid?
conclusion
50Valid Argument?
Is it valid?
assumptions
conclusion
P Q R
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F
T T T
T F T
F T T
F T T
T T F
T F T
T T F
T T T
OK?
T yes
F yes
F yes
F yes
F yes
F yes
F yes
F no
To prove an argument is not valid, we just need
to find a counterexample.
51Valid Arguments?
assumptions
conclusion
p q p?q q p
T T T T T
T F F F T
F T T T F
F F T F F
If p then q. q p
Assumptions are true, but not the conclusion.
If you are a fish, then you drink water. You
drink water. You are a fish.
52Valid Arguments?
assumptions
conclusion
p q p?q p q
T T T F F
T F F F T
F T T T F
F F T T T
If p then q. p q
If you are a fish, then you drink water. You are
not a fish. You do not drink water.
53Exercises
54More Exercises
Valid argument True conclusion
True conclusion Valid argument
55Contradiction
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)
56Truth-tellers and Liers
Truth-tellers always tell the truth. Liers always
lie.
A says B is a truth-teller. B says A and I are
of opposite type.
Suppose A is a truth-teller. Then B is a
truth-teller (because what A says is true). Then
A is a lier (because what B says is true) A
contradiction. So A must be a lier. So B must be
a lier (because what A says is false). No
contradiction.
57Quick Summary
- Arguments
- definition of a valid argument
- method of affirming, denying, contradiction
- Key points
- Make sure you understand conditional statements
and contrapositive. - Make sure you can check whether an argument is
valid.
58 Which is true? Which is false?
The sentence below is false. The sentence
above is true.