Propositional logic
Propositional logic
1
BRAIN TEASER: TORTOISE FARM
Backstory and Goal Clues
Drissel's Tortoise Farm is 1. Shelly is 32.
a refuge for tortoises 2. Methuselah is 50.
from all over the world, 3. The black neck
many of which can live tortoise is 18 years
to be well over 100 older than the swoop-
years of age. Using only backed tortoise.
the clues below, match 4. Of the 50-year-old
each tortoise on the one and the 14-year-
farm to its species and old tortoise, one is the
age. pitch belly tortoise and
the other is named
Chewie.
SECTION TOPICS
• Propositions
• Connectives
• Negation
• Conjunction
• Disjunction
• Implication; contrapositive, inverse,
converse
• Biconditional
• Truth Tables
PROPOSITIONS
A proposition is a declarative sentence that is either true or
false (but not both).
Examples:
• Ghana is in North America
• 1+1 = 2
• It is raining (here, now)
Not propositions:
• x+y=z
• Where is it?
COMPOUND PROPOSITIONS
p
T
F
COMPOUND PROPOSITIONS: NEGATION
• The negation of a proposition p is denoted by ¬p and has
this truth table:
p ¬p
T F
F T
• The four rows correspond to the pairs of truth values TT, TF, FT and FF
• Example: If p denotes “I am at home.” and q denotes “It is raining.” then p ∧q
denotes “I am at home and it is raining.”
DISJUNCTION (OR)
• The disjunction of propositions p and q denoted by p ∨q is another
proposition (pq) that is true when either p or q (or both) are true, and false
otherwise.
• Has this truth table:
p q p ∨q
T T T
T F T
F T T
F F F
p q p q
T T F
T F T
F T T
F F F
THE CONNECTIVE OR IN ENGLISH
• In English “or” has two distinct meanings.
• “Inclusive Or” - In the sentence “Students who have taken
CS202 or Math120 may take this class,” we assume that
students need to have taken one of the prerequisites but may
have taken both. This is the meaning of disjunction. For p ∨q
to be true, either one or both of p and q must be true.
• “Exclusive Or” - When reading the sentence “Soup or salad p q p ⊕q
T T F
comes with this entrée,” we do not expect to be able to get
T F T
both soup and salad. This is the meaning of Exclusive Or F T T
(Xor). In p ⊕ q , one of p and q must be true, but not both. F F F
IMPLICATION
• If p and q are propositions, then p →q is a conditional statement or
implication which is read as “if p, then q ” that is false when p is true
and q is false, and true otherwise
p q p →q
T T T
T F F
if p, then q p implies q
if p, q p only if q
q unless ¬p q when p
q if p
q whenever p p is sufficient for q
q follows from p q is necessary for p
p q r r pq p q → r
T T T F T F
T T F T T T
T F T F T F
T F F T T T
F T T F T F
F T F T T T
F F T F F T
F F F T F T
EQUIVALENT PROPOSITIONS
• Two propositions are equivalent if they always have the same truth value.
• Example: Show using a truth table that the conditional (p→q ) is equivalent to
the contrapositive (¬q → ¬ p)
Solution:
p q ¬p ¬q p →q ¬q → ¬ p
T T F F T T
T F F T F F
F T T F T T
F F T T T T
USING A TRUTH TABLE TO SHOW NON-EQUIVALENCE
Example: Show using truth tables that neither the converse (q→p)
nor inverse (¬ p →¬ q) of an implication are not equivalent to the implication (p →q)
Solution:
p q ¬p ¬q p →q ¬ p →¬ q q→p
T T F F T T T
T F F T F T T
F T T F T F F
F F T T T T T
QUESTION
• How many rows are there in a truth table with n propositional variables?
• Note that this means that with n propositional variables, we can construct 2n
distinct (i.e., not equivalent) propositions.
PRECEDENCE OF LOGICAL OPERATORS
ORDER OF OPERATIONS
Operator Precedence
1
2
3
→ 4
5
p q → r is equivalent to (p q) → r
If the intended meaning is p (q → r )
then parentheses must be used.
LOGIC AND BIT OPERATIONS
In computers, T and F are represented as 1 and 0 (bits) respectively.
A bit string is a sequence of bits (0’s and 1’s).
A binary number is a number in base 2, whose digits are 0 and 1. In
binary, the number
10101011 is the number:
1x27 + 0x26 + 1x25 + 0x24 + 1x23 + 0x22 + 1x21 + 1x20 =
128+32+8+2+1 = 171
LOGIC AND BIT OPERATIONS
Bitwise Not: complement of each bit
10110111=
Bitwise And: 11 = 1, all else equal 0
1011011111101101 =
Bitwise Or: 00 = 0, all else equal 1
1000100011101001 =
Bitwise Exclusive-Or, 11=0, 00=0, all else = 1
1001101100011001 =
LOGIC AND BIT OPERATIONS
Bitwise Not: complement of each bit
10110111= 01001000
Bitwise And: 11 = 1, all else equal 0
1011011111101101 = 10100101
Bitwise Or: 00 = 0, all else equal 1
1000100011101001 = 11101001
Bitwise Exclusive-Or, 11=0, 00=0, all else = 1
1001101100011001 = 10000010
TAKE HOME MESSAGE
Propositions- statements T or F
Operators: - Negation ¬ - opposite of truth values than the original proposition
- And ∧ - true when both p and q are true, and false otherwise.
- Or ∨ - true when either p or q (or both) are true, and false otherwise.
- Exclusive Or - true when either p or q but not both are true, and false
otherwise.
- If-then → - false when p is true and q is false, and true otherwise
- Iff - is true when both p and q are true or both are false, and false
otherwise.
Truth tables: - Rows for every possible combination of values
- Columns for the truth value of each expression and one for the compound
proposition
Bits: In computers T and F are represented as 1 and 0 (bits) respectively, same operators
can be used