Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Propositional Logic Truth Tables

CITS2211 Discrete Structures


Propositional Logic

Unit coordinator: Rachel Cardell-Oliver

July 31, 2017


Propositional Logic Truth Tables

Highlights

This lecture will address the following questions:


1 What is a proposition?
2 How are propositions combined?
3 How are propositions related to natural language and things in
the real world such as computer programs?
4 How is the truth or falsity of a proposition decided?
Propositional Logic Truth Tables

Reading

Mathematics for Computer Science


Introduction
Chapter 1, Section 1.1
Chapter 3, Section 3.1
Chapter 3, Section 3.2
Propositional Logic Truth Tables

Why study propositional logic

English language has many ambiguities. This is tolerable in


normal conversation but not if we wish to formulate precise
ideas.
Propositions and logical connectives arise all the time in
computer programs. For example, in conditional statements or
loops.
Computer programs themselves can be reasoned about using
logic. It is possible (although difficult) to prove a program is
correct.
Leading CPU chip manufacturers now routinely prove chip
correctness to avoid mistakes like the notorious Intel division
bug in the 1990s.
Propositional Logic Truth Tables

The first topic in cits2211 is logic.

Definition (from
www.oxforddictionaries.com/definition/english/logic):

Reasoning conducted or assessed according to strict principles of


validity.
Propositional Logic Truth Tables

Example: Warm up: You have 4 cards. Each card has a number on
one side and a letter on the other. If the cards are dealt so that
you can see
K 5 2 J
Which cards would you have to turn over, to test the rule that if
theres a J on one side then theres a 5 on the other side? Give
reasons for your answer.
Propositional Logic Truth Tables

Definition: A proposition is a statement that is either true or false.

Example: All men are mortal

Example: The earth is flat

Example: 1+1 = 2

Example: The evergreen forests of Canada comprise spruce, pine


and fir trees.
Propositional Logic Truth Tables

In English, we combine simple propositions into more complex ones


using connectives.

Example: The earth is not flat (not F)

Example: The earth is flat or I am mad (F or M)

Example: The earth is flat unless I am mad (F or M)

Example: Your money or your life (M or L, but be aware this really


means M xor L)

Example: If all men are mortal and all Greeks are men then all
Greeks are mortal (if MX and GM then GX)

Example: All babies are illogical (B implies not L)


Propositional Logic Truth Tables

Example: It is raining today and today is winter. (R and W)

Example: It is raining despite the season being winter. (R and W)

Example: If I can afford it then I will buy it (A implies B)

Example: I will buy it if I can afford it (A implies B)

Example: I will buy it when I can afford it (A implies B)

Example: I can afford it only if I buy it (A implies B)


Propositional Logic Truth Tables

not
and
The logic operators are: or
implies (if-then)
iff (if and only if)

The meaning of these operators can be defined using a truth table.


Propositional Logic Truth Tables

P Q PQ P Q PQ
P P T T T T
T F T F T F
F T F T F T
F F F F
Propositional Logic Truth Tables

P Q PQ P Q PQ
P P T T T T T T
T F T F F T F T
F T F T F F T T
F F F F F F
Propositional Logic Truth Tables

P Q PQ P Q PQ
T T T T
T F T F
F T F T
F F F F
Propositional Logic Truth Tables

P Q PQ P Q PQ
T T T T T T
T F F T F F
F T T F T F
F F T F F T
Propositional Logic Truth Tables

Implication is important, remember an implication is true exactly


when the if-part is false or the then-part is true. False implies
anything, True can not imply false.

Example: True: If pigs can oink then the sky is blue

Example: False: If the sky is blue then the sky is red

Example: True: If pigs can fly then the sky is red

Example: True: If pigs can fly then the sky is blue


Propositional Logic Truth Tables

Propositional logic is a formal language

A formal language consists of


1 A set of permitted symbols; its alphabet
2 Rules defining the correct order of symbol in sentences; its
syntax
3 Assignment of meaning to correctly written sentences; its
semantics
Propositional Logic Truth Tables

Here is the formal language of propositional logic:


1 The alphabet of propositional logic consists of symbols for
denoting propositions called identifiers. For example, P, Q
and R, punctuation symbols, that is brackets ( ), and
propositional connectives , , , , .
2 The syntax of propositional logic is defined by the following
rules for construction of well formed formulae (wff), which
represent propositions: An identifier is a proposition. If P and
Q are propositions then so are P, P Q, P Q, P Q
and P Q. Note that arbitrarily complex propositions can
be built recursively using these rules.
3 The semantics of a proposition (its truth value) is derived
from the possible truth values of its sub-parts and the truth
tables for connectives.
Propositional Logic Truth Tables

Which of the following are wff of propositional logic ? Why ?

P Q

P Q R (S P)

P P

P Q
Propositional Logic Truth Tables

Brackets can be used to resolve ambiguity. But over-using brackets


can be irritating. Definition: Precedence of Symbols:
B rackets
N egation
C onjunction
D isjunction
I mplication
E quivalence

Example: Add (redundant!) brackets to the following formula to


show how it is interpreted under the operator precedence rules.

P Q S T V W
Propositional Logic Truth Tables

Todays lecture will address the following questions:


1 How to use truth tables to evaluate compound propositions
2 Introduce some common rules of propositional logic
3 How to identify tautologies and equivalences
Propositional Logic Truth Tables

Definition: Two propositions are equivalent if they have the same


truth value for all possible values of their identifiers.
Here are some commonly used propositional equivalences. Each
can be derived from a truth table (exercise).

Expression Equivalent To Name of Rule


P Q Q P Commutativity
P Q Q P
(P Q) R P (Q R) Associativity
(P Q) R P (Q R)
(P Q) P Q De Morgans laws
(P Q) P Q
PQ P Q Implication
PQ Q P Contrapositive
P (P) Double negation
Propositional Logic Truth Tables

Example: Derive De Morgans law (P Q) equivalent to


P Q using a truth table.

LHS RHS
P Q P Q (P Q) P Q P Q LHS RHS
T T
T F
F T
F F
Propositional Logic Truth Tables

Example: Derive the contrapositive law using a truth table.

LHS RHS
P Q PQ Q P Q P LHS RHS
T T
T F
F T
F F
Propositional Logic Truth Tables

Propositional Logic in Programs

Propositional logic is used in computer programs.

If ( x > 0 || ( x <= 0 && y > 100 ) )


return true;
else
return false;

Example: Use propositional logic to simplify this statement.


Propositional Logic Truth Tables

Definition: A tautology is a compound proposition which is true


under all possible assignments of truth values to its prime
propositions.

Example: Show that P P is a tautology.

Definition: A contradiction is a compound proposition which is


false under all possible assignments of truth values to its prime
propositions.

Example: Show that P P is a contradiction.


Propositional Logic Truth Tables

Definition: An contingent proposition is one which is neither a


tautology nor a contradiction.

Example: Show that P P is a contingent proposition.

Definition: Two propositions are logically equivalent if and only if


their equivalence is a tautology.

Example: Show that P Q is logically equivalent to P Q


Propositional Logic Truth Tables

Axioms of Propositional Logic (1)

Expression Equivalent To Name of Rule


P Q Q P Commutativity
P Q Q P
(P Q) R P (Q R) Associativity
(P Q) R P (Q R)
P (Q R) (P Q) (P R) Distributivity
P (Q R) (P Q) (P R)
(P Q) P Q De Morgan
(P Q) P Q
P P Double Negation
P P T Excluded Middle
P P F Contradiction
Propositional Logic Truth Tables

Axioms of Propositional Logic (2)

Expression Equivalent To Name of Rule


PQ P Q Implication
PQ (P Q) (Q P) Equivalence
P (P Q) P Or Absorption
P P P
P T T
P F P
P (P Q) P And Absorption
P P P
P T P
P F F
P P Identity
Propositional Logic Truth Tables

Axioms of Propositional Logic (3)

The table of rules on the previous two pages (axioms) can be used
to derive all tautologies.
An even more elegant axiomatisation was discovered by Edward
Vermilye Huntington in 1933.

Expression Equivalent To Name of Rule


P Q Q P Commutativity
(P Q) R P (Q R) Associativity
(P Q) (P Q) P Huntington axiom

But note that these axioms are not very convenient for writing
proofs. So you are recommended to use a wider range of laws.

You might also like