Uploaded by Zyad “zMe” Elmaghraby

1.1 Propositional Logic

advertisement
Propositional Logic
Chapter 1, Section 1
What is a proposition?
A proposition is a declarative sentence that is either true or false.
Examples:
●
●
●
●
●
●
The sky is blue.
Noam Chomsky is a Laureate Professor at U of A.
It is hot in Tucson.
1+0=1
2+2=5
All CSc 245 students wear red on Mondays.
Are the following propositions?
All dogs are brown.
Howard is a dog.
Howard is the best dog.
Is Howard brown?
x + 7 = 10
For all real numbers x,
x + 7 = 10.
Get on the bus.
Alice walked or took
the bus.
Propositional Logic
● Uses truth values (T and F), analogous to constants in
algebra
● Uses propositional variables (e.g. p and q), analogous to
variables in algebra
● Propositional variables can have the value T (true) or the
value F (false)
● If a statement is always true, it can be denoted as T, and if a
statement is always false, it can be denoted as F (like
constants)
Connectives
●
●
●
●
●
●
Analogous to arithmetic operations
Negation (NOT) ¬
Conjunction (AND) ∧
Disjunction (OR) ∨
Implication →
Biconditional ↔
Negation
● Denotes the opposite of the proposition
● If p = “It is raining,” then ¬p = “It is not
raining.”
p
¬p
T
F
F
T
This is a truth table, which shows all
the possible truth values of an
expression by looking at all possible
truth value combinations of the atomic
propositions (in this case, just p).
Conjunction
● Denotes “p AND q”
● If p = “It is raining,” and q = “It is cold,”
then p ∧ q = “It is raining, and it is
cold.”
p
q
p∧q
T
T
T
T
F
F
F
T
F
F
F
F
●
●
Notice how the addition of another
variable doubles the number of possible
truth values.
A conjunction is true ONLY when both
sides are true.
Disjunction
● Denotes “p OR q”
● If p = “It is raining,” and q = “It is cold,”
then p ∨ q = “It is raining, or it is cold.”
p
q
p∨q
T
T
T
T
F
T
F
T
T
F
F
F
●
●
The logical OR is an inclusive OR,
unlike many English or’s--here we mean,
true if one or the other or both are true.
A disjunction is false ONLY when both
sides are false.
XOR
● Denotes “p OR q but not p AND q”
● If p = “It is raining,” and q = “It is cold,”
then p ⊕ q = “It is either raining or it is
cold but not both.”
p
q
p⊕q
T
T
F
T
F
T
F
T
T
F
F
F
●
●
●
●
The only difference from Disjunction is
in the first row where both p and q are
true.
What’s another way to describe XOR?
What is a common application of XOR?
Why isn’t XOR considered a basic
logical operator?
XOR
● XOR is used in cryptography for quick encryption and decryption of
a binary message.
Encryption
Message
011001110
Key
110011010
Encrypted
Message
⊕
=
101010100
Decryption
Encrypted
Message
101010100
Key
110011010
Decrypted
Message
⊕
=
011001110
● XOR is not considered a basic operator because it can be expressed
with the other operators.
● p ⊕ q ≡ (p ∨ q) ∧ ¬(p∧q)
Implication
p
q
● Denotes “if p, then q” or “p implies q”
● If p = “It is raining,” and q = “It is cold,”
then p → q = “If it is raining, then it is
cold.”
p→q
T
T
T
T
F
F
F
T
T
F
F
T
● p → q is false ONLY when p is
● Notice
→ q is always
true andthat
q is pfalse
is an
false.
● true
Whatwhen
wouldpbe
equivalent
● This
meansusing
that the
F can
imply
expression
previous
operators?
anything.
¬p ∨ q
“Did you hear that Alice is
going to Spain?”
��
p = Alice is going to Spain
q = I’m a monkey’s uncle.
p→q = If Alice is going to
Spain, then I’m a monkey’s
uncle.
“No way. If Alice is going to
Spain, then I’m a monkey’s
uncle.”
1. p → q
2. q is absurd
Conclusion:
p is absurd
��
Implication
An implication is also called a conditional
statement, and is very important for much of
what will come later in this course.
In the implication p → q, p is called the
hypothesis (or premise or antecedent) and q
is called the conclusion (or consequence).
Note that p → q does NOT mean that p is
true. Nor does it mean that q is true.
Implication
●
●
The “meaning” of p → q depends only on the truth
values of p and q.
It is possible to have legal (and true) implications that
make no colloquial sense.
Example:
If the moon is made of green cheese, then I
have more money than Bill Gates.
Is the implication TRUE or FALSE?
The implication is TRUE regardless of how much
money I have because we know the moon is not
made of green cheese and false implies anything.
Implication
An implication could be thought of as an
obligation or contract.
Example:
If you get a better grade on the final than on at least one of the
midterms, the lowest midterm grade will be replaced by the final exam
grade.
If you do better on the final exam than at least one of the midterms, and the instructor does
not replace the lowest midterm grade with your final exam grade, she didn’t live up to her
end of the contract. In other words, the implication in the syllabus was a lie (i.e. False)
because it is evident now that the truth values of the clauses would be T → F.
Implication: p→q means...
if p, q
q unless ¬p
q follows from p
q if p
p implies q
p is sufficient for q
q is a necessary condition for p
if p, then q
p only if q
q whenever p
q when p
q is necessary for p
p is a sufficient condition for q
Implication
Let p = “Alice is a CS major,” and q = “Alice
knows how to program.”
Translate the following to English:
1. p → q
2. q → p
3. ¬p → ¬q
1. If Alice is a CS major, then she knows how to program.
4. ¬q → ¬p
2. If Alice knows how to program, then she is a CS major.
3. If Alice is not a CS major, then she does not know how to
program.
4. If Alice does not know how to program, then she is not a CS
major.
Implication
Statements 2 and 3
are logically
equivalent.
1.
2.
3.
4.
p → q (original implication)
q → p (converse)
¬p → ¬q (inverse)
¬q → ¬p (contrapositive)
1. If Alice is a CS major, then she
knows how to program.
2. If Alice knows how to program,
then she is a CS major.
3. If Alice is not a CS major, then she
does not know how to program.
4. If Alice does not know how to
program, then she is not a CS
major.
Statements
1 and 4 are
logically
equivalent.
If Statement 1 is TRUE,
which of the other
statements must also be
TRUE?
Only Statement 4.
Biconditional
p
q
p↔q
T
T
T
T
F
F
F
T
F
F
F
T
● Denotes “p if and only if q” or “p
implies q and q implies p”
● If p = “It is raining,” and q = “It is
cold,” then p ↔ q = “It is raining if
and only if it is cold.”
●
●
The only difference between p ↔ q
and p → q is the value when p = F and
q = T because now q → p as well.
What is another way to express p ↔ q
using the previous operators?
(p → q) ∧ (q → p)
Constructing a Truth Table: p → (q ∨ ¬r)
● We need a row for every possible combination of values for the
atomic propositions (i.e. p, q, and r)--how many?
● We need a column for the compound expression (at the far right)
● We need columns for each of the atomic propositions.
● We could use a column for each compound expression within the
whole expression (e.g. q ∨ ¬ r)
Ex: Build a truth table for p → (q ∨ ¬r)
● How many rows will we need?
2×2×2=8
● How many columns will we need?
at least 4
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
r
¬r
q ∨ ¬r
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
p
T
T
T
T
F
F
F
F
q
r
¬r
q ∨ ¬r
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
T
T
T
T
T
F
T
F
F
T
F
T
F
F
F
F
r
¬r
q ∨ ¬r
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
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
¬r
q ∨ ¬r
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
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
¬r
q ∨ ¬r
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
r
¬r
T
T
T
F
T
T
F
T
T
F
T
F
T
F
F
T
F
T
T
F
F
T
F
T
F
F
T
F
F
F
F
T
q ∨ ¬r
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
r
¬r
T
T
T
F
T
T
F
T
T
F
T
F
T
F
F
T
F
T
T
F
F
T
F
T
F
F
T
F
F
F
F
T
q ∨ ¬r
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
r
¬r
q ∨ ¬r
T
T
T
F
T
T
T
F
T
T
T
F
T
F
F
T
F
F
T
T
F
T
T
F
T
F
T
F
T
T
F
F
T
F
F
F
F
F
T
T
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
r
¬r
q ∨ ¬r
T
T
T
F
T
T
T
F
T
T
T
F
T
F
F
T
F
F
T
T
F
T
T
F
T
F
T
F
T
T
F
F
T
F
F
F
F
F
T
T
p →(q ∨ ¬r)
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
r
¬r
q ∨ ¬r
T
T
T
F
T
T
T
F
T
T
T
F
T
F
F
T
F
F
T
T
F
T
T
F
T
F
T
F
T
T
F
F
T
F
F
F
F
F
T
T
p →(q ∨ ¬r)
F
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
r
¬r
q ∨ ¬r
p →(q ∨ ¬r)
T
T
T
F
T
T
T
T
F
T
T
T
T
F
T
F
F
F
T
F
F
T
T
T
F
T
T
F
T
T
F
T
F
T
T
T
F
F
T
F
F
T
F
F
F
T
T
T
Example 1. Build a truth table for p → (q ∨ ¬r)
p
q
r
¬r
q ∨ ¬r
p →(q ∨ ¬r)
T
T
T
F
T
T
T
T
F
T
T
T
T
F
T
F
F
F
T
F
F
T
T
T
F
T
T
F
T
T
F
T
F
T
T
T
F
F
T
F
F
T
F
F
F
T
T
T
Logical Equivalence
● Two propositions are logically equivalent if they always have
the same truth value.
● EX: A conditional p →q is always equivalent to its
contrapositive ¬q → ¬p.
● This can be shown with a truth table.
Example 2. Show with a truth table that p → q is equivalent to ¬q→¬p
p
q
¬p
¬q
p→q
¬q → ¬p
Example 2. Show with a truth table that p → q is equivalent to ¬q→¬p
p
T
T
F
F
q
¬p
¬q
p→q
¬q → ¬p
Example 2. Show with a truth table that p → q is equivalent to ¬q→¬p
p
q
T
T
T
F
F
T
F
F
¬p
¬q
p→q
¬q → ¬p
Example 2. Show with a truth table that p → q is equivalent to ¬q→¬p
p
q
¬p
T
T
F
T
F
F
F
T
T
F
F
T
¬q
p→q
¬q → ¬p
Example 2. Show with a truth table that p → q is equivalent to ¬q→¬p
p
q
¬p
¬q
T
T
F
F
T
F
F
T
F
T
T
F
F
F
T
T
p→q
¬q → ¬p
Example 2. Show with a truth table that p → q is equivalent to ¬q→¬p
p
q
¬p
¬q
p→q
T
T
F
F
T
T
F
F
T
F
F
T
T
F
T
F
F
T
T
T
¬q → ¬p
Example 2. Show with a truth table that p → q is equivalent to ¬q→¬p
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
The truth values for the two expressions are the same
for every truth value combination of p and q.
Therefore, the expressions are logically equivalent.
Example 3.
Are the following expressions logically equivalent? Justify your
answer with a truth table.
a. ¬(p ∧ q) and ¬p ∧ ¬q
b. ¬(p ∨ q) and ¬p ∧ ¬q
Example 3 (a)
¬(p ∧ q) and ¬p ∧ ¬q
p
q
¬(p ∧ q)
¬p ∧ ¬q
Example 3 (b)
¬(p ∨ q) and ¬p ∧ ¬q
p
q
¬(p ∨ q)
¬p ∧ ¬q
How many rows are needed in a truth table with n
propositional variables?
Answer: 2n
Explanation: This follows from the fact that each of the n variables
can draw from one of two truth values (T or F).
This also means that with n propositional variables, we can
construct 2n distinct (i.e. not equivalent) propositions.
Precedence of Logical Operators
● Like arithmetic operators, logical operators
follow a specified order of precedence.
● Parentheses may also be used to specify that a
given operation is to be evaluated first (e.g. p ∨ q
→ ¬ r is equivalent to (p ∨ q) → ¬ r but not to p
∨ (q → ¬ r).
()
¬
∧
∨
→
↔
Example 4. Evaluate the following expression.
Let p = T, q = F, r = F, and s = T.
p↔q∨(r→(s∧¬q)∨q→r)↔s
Example 5. Given the truth values below, evaluate each expression until it is
in its simplest form.
Given: p = T, q = F, r = T
a. (p ∧ q) ∨ ¬(q ∧ r) → p
b. q ∨ ¬ (s ∨ p) ∧ q ∧ (q→(s ∨ p))
c. (p → (q → r) ∧ s) → ¬p
Example 5 (a)
Given: p = T, q = F, r = T
(p ∧ q) ∨ ¬(q ∧ r) → p
Example 5 (b)
Given: p = T, q = F, r = T
q ∨ ¬ (s ∨ p) ∧ q ∧ (q→(s ∨ p))
Example 5 (c)
Given: p = T, q = F, r = T
(p → (q → r) ∧ s) → ¬p
Download