Professional Documents
Culture Documents
Proposition Al
Proposition Al
Proposition Al
Propositional Logic
Jonathan Buss
October 1, 2015
1/448
Broad Outline of Propositional Logic
2/448
Logic: What and Why
If the train arrives late and there are no taxis at the station,
then John is late for his meeting.
John is not late for his meeting.
The train did arrive late.
Therefore, there were taxis at the station.
If the train arrives late and there are no taxis at the station,
then John is late for his meeting.
John is not late for his meeting.
The train did arrive late.
Therefore, there were taxis at the station.
If the train arrives late and there are no taxis at the station,
then John is late for his meeting.
John is not late for his meeting.
The train did arrive late.
Therefore, there were taxis at the station.
If it rains, and Jane does not take her umbrella, then Jane gets
very wet. Jane does not get very wet. It rains. Therefore, Jane
takes her umbrella.
An equally valid argument!
In some of the cases, we may not know whether the statement is true or
false, but it’s one or the other—and not both.
Examples
Examples
In the field of “artificial intelligence,” one must deal with such sentences.
For this course, however, we shall ignore them.
Syntax 15/448
Atomic and compound propositions
Syntax 16/448
Symbols and expressions
Definition:
(ϕ ∧ η) , (ϕ ∨ η) , (ϕ → η) , and (ϕ ↔ η)
is a formula.
4. Nothing else is a formula.
1. p, q, r , s (rule 1)
2. (¬p) (rule 2, from #1)
3. (r ∧ q) (rule 3, from #1)
4. ((¬p) → s) (rule 3, from #2 and #1)
5. ((r ∧ q) ∨ ((¬p) → s)) (rule 3, from #3 and #4)
6. (¬(r ∧ q)) (rule 2, from #3)
From the definition, we see that there are six kinds of formulas.
Question: Can a formula have two (or more) kinds? E.g., can it be both
a conjunction and an implication? Or both a negation and a disjunction?
Question: Do we care?
Semantics 24/448
Semantics
Semantics 25/448
Valuations: the status of atoms
Definition:
Semantics 26/448
Compound formulas
¬ϕ Not A
ϕ∧η A and B
ϕ∨η A or B
ϕ→η If A then B
ϕ↔η A iff B
Semantics 27/448
Semantics of Connectives
ϕ (¬ϕ)
T F
F T
The other connectives are binary; they map two values to one value.
Thus their truth tables require four lines to cover the possibilities.
ϕ η (ϕ ∧ η) (ϕ ∨ η) (ϕ → η) (ϕ ↔ η)
T T T T T T
T F F T F F
F T F T T F
F F F F T T
The column for ∨ shows that it means “one or the other or both”.
(This is called “inclusive or”.)
Some people find the meaning of → rather unintuitive. You may want to
think of → as meaning “truth is preserved ”.
Some people prefer to call that sentence non-sensical, rather than true.
But propositional logic gives every formula a meaning.
1. p t = t(p).
if ϕ t = F
§
T
2. (¬ϕ) =
t
The value of a formula
F if ϕ t = T
§
T if ϕ = η = T
t t comes from the values of its
3. (ϕ ∧ η) t = variables, combined as given
F otherwise
§
T if ϕ t = T or η t = T by its connectives.
4. (ϕ ∨ η) t =
F otherwise
The valuation t is necessary.
if ϕ t = F or η t = T
§
T
5. (ϕ → η) t = Without a valuation, a
F otherwise
formula has no value.
if ϕ t = η t
§
T
6. (ϕ ↔ η) t =
F otherwise
(1) an atom, (2) (¬ϕ), (3) (ϕ ∧ η), (4) (ϕ ∨ η), (5) (ϕ → η),
or (6) (ϕ ↔ η).
In each case, it is of that form in exactly one way.
As an example, consider (p ∧ q) → r . It can be formed from the two
formulas (p ∧ q) and r using the connective →.
If we tried to form it using ∧, the two parts would need to be (p and
q) → r . But neither of those is a formula!
0, 1, 2, 3, 4, . . .
n
n(n+1)
x=
P
Example: Show that 2 for every natural number n.
x=0
n
n(n+1)
x=
P
Let P be the property; that is, let P(n) be “ 2 ”.
x=0
The left side of the equation is just 0. Also the right side evaluates to 0.
Thus 0 has property P .
The left side of the equation is just 0. Also the right side evaluates to 0.
Thus 0 has property P .
We calculate:
k+1
X k
X
x= x + (k + 1)
P
definition of
x=0 x=0
k(k+1)
= 2 + (k + 1) hypothesis
k
= 2 + 1 (k + 1) "algebra"
(k+1)(k+2)
= 2 DONE!
We calculate:
k+1
X k
X
x= x + (k + 1)
P
definition of
x=0 x=0
k(k+1)
= 2 + (k + 1) hypothesis
k
= 2 + 1 (k + 1) "algebra"
(k+1)(k+2)
= 2 DONE!
• The proof has two parts: the “basis” and the “inductive step”.
• In the inductive step, hypothesize P(k) and prove P(k + 1) from it.
But the induction principle does not say how to actually do either step.
We must invent the method ourselves.
OR
For every natural number n, every formula whose parse tree has
height n or less has property P .
OR
The proof will consider formulas of the form (ϕ → η). One such is our
previous example ((p ∧ q) → r), which has (p ∧ q) for ϕ and r for η.
The proof will consider formulas of the form (ϕ → η). One such is our
previous example ((p ∧ q) → r), which has (p ∧ q) for ϕ and r for η.
The proof will consider formulas of the form (ϕ → η). One such is our
previous example ((p ∧ q) → r), which has (p ∧ q) for ϕ and r for η.
Is this the only way to write the formula ((p ∧ q) → r)? What about
((p ∧ q) → r) = (ϕ 0 ∧ η0 ) ,
The proof will consider formulas of the form (ϕ → η). One such is our
previous example ((p ∧ q) → r), which has (p ∧ q) for ϕ and r for η.
Is this the only way to write the formula ((p ∧ q) → r)? What about
((p ∧ q) → r) = (ϕ 0 ∧ η0 ) ,
How can we make sure the inductive step works for every formula?
That is, if ϕ 0 ∧ η0 is the same expression as ϕ → η, how can we argue
that neither ϕ 0 nor η0 can be a formula?
(Unless, of course, ϕ = ϕ 0 and η = η0 .)
Can ϕ 0 (or η0 ) have an equal number of left and right parentheses?
If not, why not?
How can we make sure the inductive step works for every formula?
That is, if ϕ 0 ∧ η0 is the same expression as ϕ → η, how can we argue
that neither ϕ 0 nor η0 can be a formula?
(Unless, of course, ϕ = ϕ 0 and η = η0 .)
Can ϕ 0 (or η0 ) have an equal number of left and right parentheses?
If not, why not?
Property P(n):
If η0 has the same length as η, then they must be the same string (both
start at the second symbol of ϕ ).
Otherwise, either η0 is a proper prefix of η or η is a proper prefix of η0 .
But since η and η0 are formulas with at most k connectives, the
inductive hypothesis applies to them.
In particular, each has property B, and thus neither can be a proper
prefix of the other.
Thus ϕ has a unique derivation, as required by property C.
Semantics Mathematical induction 49/448
Commentary
The “goal” of the proof is property C—unique formation.
....................................................................
p t = t(p) if α t = T or β t = T
§
T
(α ∨ β) t =
§
T if α t = F F otherwise
(¬α) t =
F if α t = T if α t = F or β t = T
§
T
(α → β) t =
§
T if α t = β t = T F otherwise
(α ∧ β) t =
F otherwise if α t = β t
§
T
(α ↔ β) t =
F otherwise
Build the truth table of (p → ¬q) → (q ∨ ¬p) .
Definition.
For larger formulas, with more variables, this can take a long time.
Can we do better? Is there some other method?
Rather than fill out an entire truth table, we can analyze what would
happen if we did.
Let A be a truth value; that is, A ∈ {F, T}. We can combine it with other
truth values as follows.
α≡β
α?γ ≡ β ?γ .
Commutativity Idempotence
α∧β ≡β ∧α α∨α≡α
α∨β ≡β ∨α α∧α≡α
α↔β ≡β ↔α Double Negation
Associativity ¬(¬α) ≡ α
α ∧ (β ∧ γ) ≡ (α ∧ β) ∧ γ De Morgan’s Laws
α ∨ (β ∨ γ) ≡ (α ∨ β) ∨ γ
¬(α ∧ β) ≡ ¬α ∨ ¬β
Distributivity ¬(α ∨ β) ≡ ¬α ∧ ¬β
α ∨ (β ∧ γ) ≡ (α ∨ β) ∧ (α ∨ γ)
α ∧ (β ∨ γ) ≡ (α ∧ β) ∨ (α ∧ γ)
1. (p ∧ q) ∨ (q ∧ r) ≡ q ∧ (p ∨ r)
2. (p ∨ r) ∧ (q ∨ s) ≡ (p ∧ q) ∨ (p ∧ s) ∨ (r ∧ q) ∨ (r ∧ s)
3. p ∨ (p ∧ q) ≡ p (without using Simplification II)
4. ¬(¬p ∨ ¬(r ∨ s)) ≡ (p ∧ r) ∨ (p ∧ s)
5. ¬(¬(p ∧ q) ∨ p) ≡ F
6. p ≡ p ∧ (q → p)
7. p ≡ p ∧ (¬(¬q ∧ ¬p) ∨ p)
8. p ∧ (¬(¬q ∧ ¬p) ∨ p) ≡ q
Note: Apply only one rule per line of your proof (but you may apply the
rule multiple times).
• α is a logical consequence of Σ, or
• Σ (semantically) entails α, or
• in symbols, Σ |= α,
if Σ t = T then also α t = T.
Example.
{(p → q), (q → r)} |= (p → r) .
Example.
{(p → q), (q → r)} |= (p → r) .
Example.
((p → ¬q) ∨ r), (q ∧ ¬r), (p ↔ r) 6|= (p ∧ (q → r)) .
Example.
{(p → q), (q → r)} |= (p → r) .
Example.
((p → ¬q) ∨ r), (q ∧ ¬r), (p ↔ r) 6|= (p ∧ (q → r)) .
Example.
{(p → q), (q → r)} |= (p → r) .
Example.
((p → ¬q) ∨ r), (q ∧ ¬r), (p ↔ r) 6|= (p ∧ (q → r)) .
if ( i ∨ ¬u ) { i u q i ∨ ¬u ¬(u ∧ q) u ∧ ¬q Action
if ( ¬(u ∧ q) ) {
T T T T
P1
} T T F T
else if ( u ∧ ¬q ) { T F T T
P2
} T F F T
else { F T T F P4
P3
F T F F P4
}
} else { F F T T
P4 F F F T
}
if ( i ∨ ¬u ) { i u q i ∨ ¬u ¬(u ∧ q) u ∧ ¬q Action
if ( ¬(u ∧ q) ) {
T T T T F F P3
P1
} T T F T T P1
else if ( u ∧ ¬q ) { T F T T T P1
P2
} T F F T T P1
else { F T T F P4
P3
F T F F P4
}
} else { F F T T T P1
P4 F F F T T P1
}
if ( i ∨ ¬u ) { i u q i ∨ ¬u ¬(u ∧ q) u ∧ ¬q Action
if ( ¬(u ∧ q) ) {
T T T T F F P3
P1
} T T F T T P1
else if ( u ∧ ¬q ) { T F T T T P1
P2
} T F F T T P1
else { F T T F P4
P3
F T F F P4
}
} else { F F T T T P1
P4 F F F T T P1
}
P2 is never executed.
is true.
if ( i ∨ ¬u ) { if ( i ∧ u ∧ q ) {
if ( ¬(u ∧ q) ) { P3
P1 }
} else if ( ¬i ∧ u ) {
else if ( u ∧ ¬q ) { P4
P2 }
} else {
else { P1
P3 }
}
}
else {
P4
}
Working with Formulas Conditional Code 74/448
Simplifying Code
To prove that the two fragments are equivalent, show that each block of
code P1 , P2 , P3 , and P4 is executed under equivalent conditions.
Lemma. Each of the sets {∧, ¬}, {∨, ¬}, and {→, ¬} is adequate.
Proof: For the first two, use De Morgan’s laws. For the third, . . . ?
Question: Is there a binary connective ∗ such that the singleton set {∗}
is adequate?
Question: Find all minimal adequate sets containing only binary, unary
and nullary connectives.
The key here is the set of inference rules. A set of inference rules defines
a proof system.
Σ`ϕ .
This means,
Σ ` ϕ implies Σ |= ϕ .
1. p assumption
2. q assumption
3. ¬p ∨ ¬q assumption (from negated goal)
1. p assumption
2. q assumption
3. ¬p ∨ ¬q assumption (from negated goal)
1. p assumption
2. q assumption
3. ¬p ∨ ¬q assumption (from negated goal)
4. ¬q 1, 3
1. p assumption
2. q assumption
3. ¬p ∨ ¬q assumption (from negated goal)
4. ¬q 1, 3
5. ⊥ 2, 4
1. ¬p ∨ q assumption
2. ¬q ∨ r assumption
3. p assumption (from negated conclusion)
4. ¬r assumption (from negated conclusion)
1. ¬p ∨ q assumption
2. ¬q ∨ r assumption
3. p assumption (from negated conclusion)
4. ¬r assumption (from negated conclusion)
5. q 1, 3 (variable p)
1. ¬p ∨ q assumption
2. ¬q ∨ r assumption
3. p assumption (from negated conclusion)
4. ¬r assumption (from negated conclusion)
5. q 1, 3 (variable p)
6. r 2, 5 (variable q)
1. ¬p ∨ q assumption
2. ¬q ∨ r assumption
3. p assumption (from negated conclusion)
4. ¬r assumption (from negated conclusion)
5. q 1, 3 (variable p)
6. r 2, 5 (variable q)
7. ⊥ 4, 6 (variable r )
Refutation complete!
• If Σ ∧ ¬ϕ is consistent, then . . .
• If Σ ∧ ¬ϕ is inconsistent, then . . .
• If Σ ∧ ϕ is consistent, then. . .
• If Σ ∧ ϕ is inconsistent, then . . .
Inductive hypothesis: The claim holds for sets having at most k variables.
Done!
Proofs in Propositional Logic Soundness and Completeness of Resolution 100/448
Resolution Provides an Algorithm
Modern SAT solvers can often solve hard real-world instances with over
a million propositional variables and several million clauses.
http://www.satcompetition.org/