CC-BY
Fabian M. Suchanek
Propositional Logic
Running Example
2
“Hermione married Ron” -> why???
married
loves
A
propositional formula
over a set of atoms A is any of the following
•
(α ∧ β)
•
(α ∨ β)
•
(α ⇒ β)
•
¬ α
•
(α ⇔ β)
•
any element of A
•
true
•
false
... where α and β are propositional formulae.
Example: A ={smart, heroic, childish, dumb}
(smart ∧ heroic) ∨ (dumb ∧ childish)
Def: Propositional Logic
3
(called
conjunction
)
(called
disjunction
)
(called
implication
)
(called
negation
)
(called
equivalence
)
(We usually omit outer brackets.)
NAND>53
A
propositional formula
over a set of atoms A is either
•
an element of A
•
or a formula of the form
This is NAND.
It is “true” if at least one of the arguments is “false”.
Also known as the “Sheffer Stroke”, and written as “|”
We define:
α ⇒ β := ¬ α ∨ β
α ⇔ β := (α ⇒ β) ∧ (β ⇒ α)
true := a ∨ ¬ a for any a ∈ A
false := ¬ true
(We usually omit outer brackets.)
α ∨β := ¬(¬ α ∧ ¬β)
Digression: Alternative definition
4
Example:
KB={smart, rich}
A (propositional)
knowledge base (KB)
over a set of atoms A is a subset K ⊆ A .
An
interpretation/valuation/denotation/possible world
for a set of atoms A is a function φ:A → {1,0} .
Often, the interpretation is given as a KB, with φ(a)=1, if a ∈ KB, 0 else .
(Here, we first talk about only one candidate for Hermione. We will later generalize the definition to the previously known definition of a KB.)
(In most of the following, we will see a KB and an interpretation as the same.)
Def: Prop. Knowledge Base, Interpretation
5
Def: Prop. Knowledge Base, Interpretation
6
In the example:
φ(smart)=1
φ(rich)=1
φ(handsome)=0
An
interpretation/valuation/denotation/possible world
for a set of atoms A is a function φ:A → {1,0} .
(Here, we first talk about only one candidate for Hermione. We will later generalize the definition to the previously known definition of a KB.)
Often, the interpretation is given as a KB, with φ(a)=1, if a ∈ KB, 0 else .
(In most of the following, we will see a KB and an interpretation as the same.)
Example:
KB={smart, rich}
A (propositional)
knowledge base (KB)
over a set of atoms A is a subset K ⊆ A .
We extend the interpretation to propositional
formulae by defining
φ(true) = 1
φ(false) = 0
φ(α ∧ β) =
φ(α ∨β) =
φ(¬ α) =
φ(α ⇒ β) =
Extending Interpretations
7
φ(true) = 1
φ(false) = 0
φ(α ∧ β) = φ(α) × φ(β)
φ(α ∨β) = 1-(1-φ(α)) × (1-φ(β))
φ(¬ α) = 1 - φ(α)
φ(α ⇒ β) = 1-(φ(α)× (1-φ(β)))
We extend the interpretation to propositional
formulae by defining
Extending Interpretations
8
Example:
KB={smart, rich}
φ(α ⇒ β) = 1-(φ(α)× (1-φ(β)))
φ(false) = 0
φ(α ∧ β) = φ(α) × φ(β)
φ(¬ α) = 1 - φ(α)
φ(true) = 1
φ(α ∨β) = 1-(1-φ(α)) × (1-φ(β))
We extend the interpretation to propositional
formulae by defining
Extending Interpretations
9
φ(rich ∧ smart)= ?
φ(rich ∨ smart)= ?
φ(smart ⇒ handsome)= ?
φ(rich ∧ smart)=1
φ(rich ∨ smart)=1
φ(smart ⇒ handsome)=0
φ(α ⇒ β) = 1-(φ(α)× (1-φ(β)))
φ(false) = 0
φ(α ∧ β) = φ(α) × φ(β)
φ(¬ α) = 1 - φ(α)
φ(true) = 1
φ(α ∨β) = 1-(1-φ(α)) × (1-φ(β))
We extend the interpretation to propositional
formulae by defining
Extending Interpretations
10
Example:
KB={smart, rich}
Example:
KB={smart, rich}
We say: The formula is true/satisfied in the KB.
φ(α ⇒ β) = 1-(φ(α)× (1-φ(β)))
φ(false) = 0
φ(α ∧ β) = φ(α) × φ(β)
φ(¬ α) = 1 - φ(α)
φ(true) = 1
φ(α ∨β) = 1-(1-φ(α)) × (1-φ(β))
We extend the interpretation to propositional
formulae by defining
Extending Interpretations
11
φ(rich ∧ smart)=1
φ(rich ∨ smart)=1
φ(smart ⇒ handsome)=0
NAND>61
eqv>62
The usual truth tables follow from this.
We extend the interpretation to propositional formulae by defining
Digression: Interpretations and NAND
12
A formula α is a
tautology
, if for all φ , φ(α)=1 .
We write ⊧ α .
Examples:
Two formulas α and β are
equivalent
, if ⊧ α ⇔ β .
⊧ rich ∨ ¬ rich
⊧ smart ∧ rich ⇒ rich
Def: Tautology, Equivalence
13
Examples:
⊧ rich ∨ smart ⇔ smart ∨ rich
⊧ ¬ ¬ smart ⇔ smart
An implication α ⇒ β is equivalent to ¬ α ∨ β .
¬ smart ∨ rich
Example:
KB={smart, rich}
smart ⇒ rich
There is only one case where an implication α ⇒ β is false: if α is true and β is false.
Implications
14
φ(smart ⇒ handsome)= ?
φ(handsome ⇒ rich)= ?
φ(handsome ∧ smart ⇒ hero)= ?
Implications
15
φ(smart ⇒ handsome)=0
φ(handsome ⇒ rich)=1
φ(handsome ∧ smart ⇒ hero)=1
details>69
An implication α ⇒ β is equivalent to ¬ α ∨ β .
¬ smart ∨ rich
Example:
KB={smart, rich}
smart ⇒ rich
There is only one case where an implication α ⇒ β is false: if α is true and β is false.
Example:
The
law of contraposition
says that an implication can be “turned around”:
smart ⇒ rich
¬ rich ⇒ ¬ smart
Implications
16
details>69
Here are some well-known tautological equivalences:
• Identity
• Domination
• Idempotence
• Double negation
• Commutation
• Associativity
• Distribution
• De Morgan
• Absorption
• Negation
p ∧ true ⇔ p, p ∨ false ⇔ p
p ∧ false⇔ false, p ∨ true ⇔ true
p ∧ p ⇔ p, p ∨ p ⇔ p
¬ ¬ p ⇔ p
(p ∧ q) ∧ r ⇔ p ∧ (q ∧ r)
(p ∨ q) ∨ r ⇔ p ∨ (q ∨ r)
p ∨ q ⇔ q ∨ p, p ∧ q ⇔ q ∧ p
p∨ (q ∧ r) ⇔ (p ∨ q)∧ (p ∨ r)
p∧ (q ∨ r) ⇔ (p ∧ q)∨ (p ∧ r)
¬ (p ∧ q) ⇔ ¬ p ∨ ¬ q
¬ (p ∨ q) ⇔ ¬ p ∧ ¬ q
p ∨ (p ∧ q) ⇔ p
p ∧ (p ∨ q) ⇔ p
p ∨ ¬ p ⇔ true, p∧ ¬ p ⇔ false
Equivalences
17
details>69
A formula in
conjunctive normal form
(CNF) is a conjunction of disjunctions
of possibly negated atoms.
Examples:
Every formula can be transformed into an equivalent CNF.
(a ∨ b ∨ ¬ c) ∧ (¬ b ∨ c ∨ d ∨ ¬ e)
b ∧ (¬ a ∨ b) ∧ (¬ b ∨ ¬ e) ∧ f ∧ (f ∨ e)
Def: Conjunctive normal form
18
Examples:
(This may entail an exponential blowup)
details>69
α
entails
β (written α ⊧ β ), if ⊧ α ⇒ β .
Examples:
a ∧ b ⊧ a
a ∧ ¬ a ⊧ b
a ∨ b ⊧ b ∨ a
If we want to find entailments in a naive way, we have to try out exponentially many
interpretations. Therefore, we usually resort to calculi (next slide).
Def: Entailment
19
details>69
An
inference rule
is a function p: Γ × Γ → Γ
where Γ is the set of formulas over a set of atoms.
We write
if
or if there are i , j , s.t.
and
.
Calculi and Proof Systems
20
Example: Modus Ponens inference rule
Example of a deduction with Modus Ponens:
a, a ⇒ b, b ⇒ c ⊦ b
and hence
a, a ⇒ b, b ⇒ c ⊦ c
An
inference rule
is a function p: Γ × Γ → Γ
where Γ is the set of formulas over a set of atoms.
We write
if
or if there are i , j , s.t.
and
.
Calculi and Proof Systems
21
Examples:
• Modus Ponens + appropriate axioms
• Natural deduction
• Resolution
A
proof system / calculus
is a set of inference rules.
A calculus is
• complete, if α ⊧ β implies α ⊦ β
• correct, ifα ⊦ β implies α ⊧ β
We broaden our definition of an
atom
: An atom over a set R of relation names,
and a set C of constants is a string of the form
with
for i=1,...,n .
Examples:
loves(Ron, Hermione)
smart(Hermione)
dumb(Ron)
The definition of a KB and an interpretation is broadened
accordingly, i.e., given the KB on the left,
φ(loves(Ron,Hermione))=1
Def: Atom
22
(We will implicitly take R as the set of lowercase words and C as the set of initial-capitalized words)
hasSpouse(Elvis,Priscilla) ⇒ hasSpouse(Priscilla,Elvis)
hasSpouse(cat,dog) ⇒ hasSpouse(dog,cat)
hasSpouse(Elvis,Elvis) ⇒ hasSpouse(Elvis,Elvis)
hasSpouse(Hermione,Ron) ⇒ hasSpouse(Ron,Hermione)
hasSpouse(Elvis,Priscilla) ∨ loves(Priscilla,Elvis)
Given this KB, which of the following formulas are true?
23
Example: A KB of atoms
hasSpouse
hasSpouse
hasSpouse
hasSpouse(Elvis,Priscilla) ⇒ hasSpouse(Priscilla,Elvis)
hasSpouse(cat,dog) ⇒ hasSpouse(dog,cat)
hasSpouse(Elvis,Elvis) ⇒ hasSpouse(Elvis,Elvis)
24
Example: A KB of atoms
hasSpouse(Elvis,Priscilla) ∨ loves(Priscilla,Elvis)
Given this KB, which of the following formulas are true?
hasSpouse
hasSpouse
hasSpouse
hasSpouse(Hermione,Ron) ⇒ hasSpouse(Ron,Hermione)
likes(Hermione, Ron) ⇒ likes(Harry,Ron)
likes(Harry, Ron) ⇒ hasSpouse(Harry,Hermione)
¬ likes(Hermione, Harry) ⇒ envies(Harry,Ron)
¬ likes(Hermione, Harry) ⇒ hasSpouse(Harry,Ron)
likes(Herm., Ron)∧ ¬ envies(Harry,Ron)⇒ ffe(Harry,Ron)
25
likes
envies
likes
Example: A KB of atoms
Given this KB, which of the following formulas are true?
>universal
A
literal
is a possibly negated atom that may contain variables from a set V of variables.
Examples:
¬ loves(x, y)
smart(z)
¬ smart(Ron)
adores(x, x)
Def: Literal / Quantified Formula
26
(We will implicitly take V as the set of single letters)
A
universally quantified formula
is a formula built over literals instead of atoms.
Example:
(sometimes written as ∀ x, y, z, ... . This is the fragment of FOL without existential quantifiers and function symbols)
loves(Hermione, x) ⇒ hates(Harry, x)
A
binding
is a function from variables to constants.
{ x → Ron, y → Elvis }
An
instantiation
(ground instance) of a formula by a binding is the
formula obtained by substituting all variables by the constants given by
the binding.
loves(Hermione, Ron) ⇒ hates(Harry, Ron)
For a formula α and an interpretation φ , we define φ(α)=1 iff φ(α')=1
for all possible instantiations α' of α . We say that the formula is
true
under φ .
loves(Hermione, x) ⇒ hates(Harry, x)
Def: Bindings
27
Example:
Example:
hasSpouse(x, y) ⇒ hasSpouse(y, x)
hasSpouse(Elvis, y) ⇒ hasSpouse(y, Elvis)
hasSpouse(x, Ron) ⇒ hasSpouse(Ron, x)
Example: Universally quantified formulas
28
hasSpouse
hasSpouse
hasSpouse
Which formulas are true?
>clauses
A
rule
is a clause with exactly one positive literal.
loves(Hermione, x) ∨ ¬ smart(x) ∨ ¬ cute(x)
We usually write them as the equivalent implication:
smart(x) ∧ cute(x) ⇒ loves(Hermione, x)
loves(Hermione, x) ← smart(x) ∧ cute(x)
... or sometimes in the following form:
A
clause
is a disjunction of literals. We often write the clause as a set.
loves(Hermione, x) ∨ smart(x) ∨ ¬ cute(x)
{loves(Hermione, x), smart(x), ¬ cute(x) }
Def: Clause & Rule
29
Head
Body
Propositional logic is a formalism to express statements and their logical connections.
Summary: Propositional Logic
30
“If you’re smart then you’re rich”: smart ⇒ rich
A calculus is a system to deduce new statements from given formulas.
Propositional logic can be broadened to atoms with arguments.