0% found this document useful (0 votes)
73 views

Predicate Logic Create

This document provides an introduction to first-order predicate logic, which is more expressive than propositional logic and better suited to representing human knowledge and reasoning. It discusses modeling environments like the Wumpus world using predicates, variables, and logical connectives. The semantics of first-order logic involves interpreting sentences with respect to structured models of possible worlds. Reasoning in first-order logic aims to derive new true sentences from a given knowledge base using entailment rules that preserve truth across models.

Uploaded by

Z Chen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Predicate Logic Create

This document provides an introduction to first-order predicate logic, which is more expressive than propositional logic and better suited to representing human knowledge and reasoning. It discusses modeling environments like the Wumpus world using predicates, variables, and logical connectives. The semantics of first-order logic involves interpreting sentences with respect to structured models of possible worlds. Reasoning in first-order logic aims to derive new true sentences from a given knowledge base using entailment rules that preserve truth across models.

Uploaded by

Z Chen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Logical Representation

&
Reasoning
Part II
Predicate Logic
(First-Order Predicate Logic)
Course on AI@IID
Mannes Poel
Designing rational agents
• Knowledge/logic based approach to designing
and implementing the ? component of
rational agents.

• Needed: logical modelling of the environment,


the knowledge base KB of the agent and
inference (reasoning) with this knowledge
Course on AI@IID: 2018-2019 2
Looking back Propositional Logic
• Not very expressive.
• Does not fit the way humans think and reason
and we are the designers of intelligent agents.
• Knowlegde such as “Every adult is older than
17 years” is hard to translate in Propositional
Logic. Must be done by enumeration:
– 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎_𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 ⇒ 𝑎𝑎𝑎𝑎𝑎𝑎_𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝_𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙_𝑡𝑡𝑡𝑡𝑡𝑡𝑡_17
– 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎_𝑗𝑗𝑗𝑗𝑗𝑗𝑗 ⇒ 𝑎𝑎𝑎𝑎𝑎𝑎_𝑗𝑗𝑗𝑗𝑗𝑗𝑗_𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙_𝑡𝑡𝑡𝑡𝑡𝑡𝑡_17
– ……….
Course on AI@IID: 2018-2019 3
Wumpus world
• 𝐵𝐵1,1 ⇔ (𝑃𝑃1,2 ∨ 𝑃𝑃2,1 )
• 𝐵𝐵1,2 ⇔ (𝑃𝑃1,1 ∨ 𝑃𝑃1,3 ∨ 𝑃𝑃2,2 )
• 𝐵𝐵2,2 ⇔ (𝑃𝑃1,2 ∨ 𝑃𝑃2,1 ∨ 𝑃𝑃2,3 ∨ 𝑃𝑃3,2 )
• ……………………………….
• …………………………………..

Course on AI@IID: 2018-2019 4


Wumpus world

• If there is Pit in a square then there is Breeze


in all adjacent squares:
∀𝑥𝑥, 𝑦𝑦, 𝑣𝑣, 𝑤𝑤 𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑦𝑦) ∧ 𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴( 𝑥𝑥, 𝑦𝑦 , 𝑣𝑣, 𝑤𝑤 )
⇒ 𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵(𝑣𝑣, 𝑤𝑤)
• If there is a Breeze in a square then there is a
Pit in one of the adjacent squares:
∀𝑥𝑥, 𝑦𝑦, 𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵𝐵 𝑥𝑥, 𝑦𝑦
⇒ ∃𝑣𝑣, 𝑤𝑤 𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴( 𝑥𝑥, 𝑦𝑦 , 𝑣𝑣, 𝑤𝑤 ) ∧ 𝑃𝑃𝑃𝑃𝑃𝑃(𝑣𝑣, 𝑤𝑤)

Course on AI@IID: 2018-2019 5


(First-Order) Predicate Logic
• Knowledge is represented by predicates,
variables and logical connectives:
• Examples:
– ∀𝑥𝑥 𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴 𝑥𝑥 ⇒ 𝐴𝐴𝐴𝐴𝐴𝐴 𝑥𝑥 > 17
– ∀𝑥𝑥 𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻 𝑥𝑥 ⇒ ∃𝑦𝑦 𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻 𝑦𝑦 ∧ 𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 𝑦𝑦, 𝑥𝑥
– Different modeling in which Mother is a function
– ∀𝑥𝑥 𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻 𝑥𝑥 ⇒ ∃𝑦𝑦 𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻 𝑦𝑦 ∧ 𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 𝑥𝑥 = 𝑦𝑦

Course on AI@IID: 2018-2019 6


(First-Order) Predicate Logic
• Much more structure than propositional logic.
• Can model almost all statements we can make
in Natural Language.
• So it is tailored to Human Language and
Reasoning.

Course on AI@IID: 2018-2019 7


Syntax (1)
• Constants: John, Peter, 2, UT, AI
• Predicates: Parent, Son, Neighbor, > , Student,
Takes, Smart
• Functions: Sqrt, Mother, Farther, Teacher
• Variables: x,y,z
• Connectives: ∧,∨, ¬, ⇒, ⇔
• Equality: =
• Quantifiers: ∀, ∃

Course on AI@IID: 2018-2019 8


Syntax (2)
• Atomic Sentence:
– predicate(term1,…,termn)
– term1=term2
• Term:
– function(term1,…,termk)
– constant
– variable
• Examples:
– Brother(KingJohn,RichardTheLionheart)
– >(Length(LeftLegOf(Richard)),Length(LeftLegOf(KingJohn)))

Course on AI@IID: 2018-2019 9


Syntax (3)
• Complex Sentences:
– ¬𝑆𝑆, 𝑆𝑆1 ∧ 𝑆𝑆2 , 𝑆𝑆1 ∨ 𝑆𝑆2 , 𝑆𝑆1 ⇒ 𝑆𝑆2 , 𝑆𝑆1 ⇔ 𝑆𝑆2
• Quantifiers:
– ∀𝑥𝑥 𝑆𝑆 𝑥𝑥
– ∃𝑦𝑦 𝑆𝑆(𝑦𝑦)

• Example:
∀𝑥𝑥 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑥𝑥, 𝐴𝐴𝐴𝐴 ⇒ 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥
∀𝑥𝑥 𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻 𝑥𝑥 ⇒ ∃𝑦𝑦 𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿 𝑥𝑥, 𝑦𝑦
Course on AI@IID: 2018-2019 10
Exercise
• How do we model in Predicate Logic the
sentence “All students who take the course on
AI are smart”?

• ∀𝑥𝑥 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥 ∧ 𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 𝑥𝑥, 𝐴𝐴𝐴𝐴 ⇒ 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥

Course on AI@IID: 2018-2019 11


Exercise
• How do we model the sentence “There is a
student who takes AI and is smart.”

• ∃𝑥𝑥 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥 ∧ 𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 𝑥𝑥, 𝐴𝐴𝐴𝐴 ⇒ 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥

• ∃𝑥𝑥 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥 ∧ 𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇(𝑥𝑥, 𝐴𝐴𝐴𝐴) ∧ 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆(𝑥𝑥)

Course on AI@IID: 2018-2019 12


Common mistakes to avoid
• Typically, ∧ is the main connective with ∃
• Common mistake: using ⇒ as the main
connective with ∃.

Course on AI@IID: 2018-2019 13


Semantics
• Logicians typically think in terms of models,
which are formally structured worlds with respect
to which truth can be evaluated
• For predicate logic a model is much more
complex than for propositional logic. It must
provide the information required to determine if
any syntactically correct sentence is true or false.
• We say m is a model of a sentence α if α is true in
m
• M(α) is the set of all models of α
• Then KB ╞ α iff M(KB) ⊆ M(α)
Course on AI@IID: 2018-2019 14
Models
• Model contains objects (domain elements) and
relations among them
• Interpretation specifies referents for
constant symbols → objects
predicate symbols → relations
function symbols → functional relations

• An atomic sentence predicate(term1,...,termn) is true


iff the objects referred to by term1,...,termn are in the
relation referred to by predicate

Course on AI@IID: 2018-2019 15


Example

Course on AI@IID: 2018-2019 16


Exercise
• Determine the models for the sentences:
∀𝑥𝑥 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥 ∧ 𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 𝑥𝑥, 𝐴𝐴𝐴𝐴 ⇒ 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥
∀𝑥𝑥 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑥𝑥, 𝐴𝐴𝐴𝐴 ⇒ 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑥𝑥
∀𝑥𝑥 𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻𝐻 𝑥𝑥 ⇒ ∃𝑦𝑦 𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿 𝑥𝑥, 𝑦𝑦

• Well that is much harder than for Prop. Logic.

• Can be reduced to propositional logic if we


can enumerate all possibilities.
Course on AI@IID: 2018-2019 17
Entailment
• KB ╞ α means that knowledge base KB entails
α. Meaning that in all models in which KB is
true also α is true. (Model checking.)

𝑀𝑀(𝛼𝛼)

Course on AI@IID: 2018-2019 18


Syntax, semantics and grounding

Sentences represent physical configurations of the world and


reasoning is a process of constructing new sentences out of old
ones. The reasoning process should ensure that the new
sentences represent physical configurations that actual follow
from the old ones. Meaning that the KB of the agent should be
grounded in the environment it “lives” in.
Course on AI@IID: 2018-2019 19
Semantics of sentences
Given a model m (truth assigment to the atomic
sentences or symbols). Then
• ¬S is true iff S is false
• S1 ∧ S2 is true iff S1 is true and S2 is true
• S1 ∨ S2 is true iff S1 is true or S2 is true
• S1 ⇒ S2 is true iff S1 is false or S2 is true
• S1 ⇒ S2 is false iff S1 is true and S2 is false
• S1 ⇔ S2 is true iff S1⇒S2 is true and S2⇒S1 is
true
Course on AI@IID: 2018-2019 20
Semantics of Quantifiers
• ∀𝑥𝑥 𝑃𝑃 𝑥𝑥 is true in model m iff P is true for
every instantiation of 𝑥𝑥. So it is equivalent to
𝑃𝑃 𝐴𝐴 ∧ 𝑃𝑃 𝐵𝐵 ∧ ⋯ ∧ 𝑃𝑃 𝐾𝐾

where A,B,..,K are the possible instantiations


of 𝑥𝑥.
• ∃𝑥𝑥 𝑃𝑃 𝑥𝑥 is true in model m iff P is true for at
least one instantiation of 𝑥𝑥.

Course on AI@IID: 2018-2019 21


Inference
• Theorem proving: applying rules to derive a
proof of KB ╞ α without model checking.

• Well known rule is Universal Instantiation:


∀𝑥𝑥 𝑃𝑃(𝑥𝑥)
𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆( 𝑥𝑥/𝐴𝐴 , 𝑃𝑃 𝑥𝑥 )
Substituting 𝐴𝐴 for 𝑥𝑥 in 𝑃𝑃.

Course on AI@IID: 2018-2019 22


Inference
Well known rule is Existential Instantiation:
∃𝑥𝑥 𝑃𝑃(𝑥𝑥)
𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆( 𝑥𝑥/𝐴𝐴 , 𝑃𝑃 𝑥𝑥 )
Substituting 𝐴𝐴 for 𝑥𝑥 in 𝑃𝑃 in which 𝐴𝐴 is a constant
that does not appear elsewhere in the
knowledge base.

Course on AI@IID: 2018-2019 23


Example Existential Quantification
∃𝑥𝑥 𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶(𝑥𝑥) is
instantiated as C

𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶(𝐶𝐶) where C
new constant referring
to the crown.
C is called a Skolem
constant.

Course on AI@IID: 2018-2019 24


Concepts
• Logical equivalence: 𝛼𝛼 ≡ 𝛽𝛽 if 𝑀𝑀 𝛼𝛼 = 𝑀𝑀 𝛽𝛽 .
• Examples: 𝑝𝑝 ∧ 𝑞𝑞 ≡ 𝑞𝑞 ∧ 𝑝𝑝.
• Validity: A sentence 𝛼𝛼 is valid if it is true in all
models (a.k.a. tautologies)
• Satisfiability: a sentence 𝛼𝛼 is satisfiable if it is
true in some model, i.e. 𝑀𝑀 𝛼𝛼 ≠ ∅
• Example: 𝐾𝐾𝐾𝐾╞ α if 𝐾𝐾𝐾𝐾∧¬α is unsatisfiable.
(Proof by contradiction.)
Course on AI@IID: 2018-2019 25
Logical Inference for Predicate
Logic

1. Transforming to CNF
2. Unification
3. Resolution

Course on AI@IID: 2018-2019 26


Equivalence

Course on AI@IID: 2018-2019 27


Equivalence for quantifiers
• ∀𝑥𝑥 ¬𝑃𝑃 ≡ ¬∃𝑥𝑥 𝑃𝑃
• ¬∀𝑥𝑥 𝑃𝑃 ≡ ∃𝑥𝑥 ¬𝑃𝑃
• ∀𝑥𝑥 𝑃𝑃 ≡ ¬∃𝑥𝑥 ¬𝑃𝑃
• ∃𝑥𝑥 𝑃𝑃 ≡ ¬∀𝑥𝑥 ¬𝑃𝑃

Course on AI@IID: 2018-2019 28


Resolution rule
𝑙𝑙1 ∨ 𝑙𝑙2 … .∨ 𝑙𝑙𝑘𝑘 𝑚𝑚1 ∨ 𝑚𝑚2 … .∨ 𝑚𝑚𝑛𝑛
𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆(𝜃𝜃, 𝑙𝑙1 ∨ … ∨ 𝑙𝑙𝑖𝑖−1 ∨ 𝑙𝑙𝑖𝑖+1 … .∨ 𝑙𝑙𝑘𝑘 ∨ 𝑚𝑚1 ∨ … ∨ 𝑚𝑚𝑗𝑗−1 ∨ 𝑚𝑚𝑗𝑗+1 … .∨ 𝑚𝑚𝑛𝑛 )

Where 𝑈𝑈𝑈𝑈𝑈𝑈𝑈𝑈𝑈𝑈(𝑙𝑙𝑖𝑖 , ¬𝑚𝑚𝑗𝑗 ) = 𝜃𝜃:

One technical aspect: remove multiple copies of the same literal.

Course on AI@IID: 2018-2019 29


Transforming to CNF
The recipe becomes more complicated because we
have to get rid of the quantifiers

1. Replace all A ⇔ B by (A ⇒ B) ∧ (B ⇒ A)
2. Replace all A ⇒ B by ¬A ∨ B
3. Move negation signs inwards starting from the outside
until every negation sign is directly in front of a literal
4. Remove quantifiers
5. Distribute ∨ over ∧ until you obtain CNF

Course on AI@IID: 2018-2019 30


Move negation inside
Remember:
• ¬∀𝑥𝑥 𝑃𝑃 ≡ ∃𝑥𝑥 ¬𝑃𝑃
• ¬∃𝑥𝑥 𝑃𝑃 ≡ ∀𝑥𝑥 ¬𝑃𝑃

Course on AI@IID: 2018-2019 31


Resolution in first-order logic, example
• Be careful with variables: the x in one sentence and the x in
another sentence are not the same variable!
• This becomes urgent when you start instantiating variables
• Precaution: standardise apart
– Or: rename variables so that they are different per sentence
• Rename variable in second premises:
∀𝑥𝑥, 𝑦𝑦 𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ⇒ ∃𝑧𝑧 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑧𝑧) ∧ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑧𝑧, 𝑦𝑦)
∃𝑣𝑣 𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑣𝑣, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
• Rename variable in negated conclusion:
Resolution in first-order logic, example
• First remove ⇒ (implication elimination):

∀𝑥𝑥, 𝑦𝑦 𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ⇒ ∃𝑧𝑧 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑧𝑧) ∧ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑧𝑧, 𝑦𝑦)

∀𝑥𝑥, 𝑦𝑦 ¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ [ ∃𝑧𝑧 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑧𝑧) ∧ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑧𝑧, 𝑦𝑦) ]

• Note the position of the negation sign!


• We are now in a position to remove the quantifiers
– There are no negation signs to be pushed inwards in this example

Course on AI@IID: 2018-2019 33


Resolution in first-order logic, example
First work away ∃:
• ∃𝑣𝑣 𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑣𝑣, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
Simple Skolemisation works: (G is a new constant)
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)

Course on AI@IID: 2018-2019 34


Resolution in first-order logic, example
(Still working away ∃)
• ∀𝑥𝑥, 𝑦𝑦 ¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑥𝑥, 𝑦𝑦 ∨
[ ∃𝑧𝑧 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑧𝑧) ∧ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑧𝑧, 𝑦𝑦) ]
– 𝑧𝑧 within the scope of both 𝑥𝑥 and 𝑦𝑦
– Simple Skolemisation is not allowed
– Hence: introduce a Skolem function with two (!)
arguments:
• ∀𝑥𝑥, 𝑦𝑦 ¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑥𝑥, 𝑦𝑦 ∨
(𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑆𝑆(𝑥𝑥, 𝑦𝑦)) ∧ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝑥𝑥, 𝑦𝑦), 𝑦𝑦))
Course on AI@IID: 2018-2019 35
Resolution in first-order logic, example
• Now only universal quantifiers remain; drop them
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽
¬𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑤𝑤, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ (𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑆𝑆(𝑥𝑥, 𝑦𝑦)) ∧ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝑥𝑥, 𝑦𝑦), 𝑦𝑦))
• First two in CNF, third isn’t

Course on AI@IID: 2018-2019 36


Resolution in first-order logic, example

¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑥𝑥, 𝑦𝑦 ∨
[𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑆𝑆(𝑥𝑥, 𝑦𝑦)) ∧ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝑥𝑥, 𝑦𝑦), 𝑦𝑦)]

(distributivity)

¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑥𝑥, 𝑦𝑦 ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑥𝑥, 𝑆𝑆 𝑥𝑥, 𝑦𝑦 ∧


[¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝑥𝑥, 𝑦𝑦), 𝑦𝑦)]
CNF!

Course on AI@IID: 2018-2019 37


Resolution in first-order logic, example
• We have, conjunctions taken apart:
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽
¬𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑤𝑤, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑆𝑆(𝑥𝑥, 𝑦𝑦))
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝑥𝑥, 𝑦𝑦), 𝑦𝑦)

• Last steps, resolution, in “animated” form

Course on AI@IID: 2018-2019 38


Resolution in first-order logic, example
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽 unify {𝑥𝑥/G, 𝑦𝑦/John} and
apply resolution
¬𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑤𝑤, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑆𝑆(𝑥𝑥, 𝑦𝑦))
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝑥𝑥, 𝑦𝑦), 𝑦𝑦)

𝑥𝑥 = 𝐺𝐺
𝑦𝑦 = 𝐽𝐽𝐽𝐽𝐽𝐽𝐽

Course on AI@IID: 2018-2019 39


Resolution in first-order logic, example
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
¬𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑤𝑤, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑆𝑆(𝑥𝑥, 𝑦𝑦))
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽), 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽), 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)

unify {𝑤𝑤/𝑆𝑆(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)}

𝑥𝑥 = 𝐺𝐺
𝑦𝑦 = 𝐽𝐽𝐽𝐽𝐽𝐽𝐽
𝑤𝑤 = 𝑆𝑆(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)

Course on AI@IID: 2018-2019 40


Resolution in first-order logic,
example: done!
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
¬𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽), 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝑥𝑥, 𝑦𝑦) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑥𝑥, 𝑆𝑆(𝑥𝑥, 𝑦𝑦))
¬𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽) ∨ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽), 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)

𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃(𝑆𝑆(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽), 𝐽𝐽𝐽𝐽𝐽𝐽𝐽) contradiction!

𝑥𝑥 = 𝐺𝐺
𝑦𝑦 = 𝐽𝐽𝐽𝐽𝐽𝐽𝐽
𝑤𝑤 = 𝑆𝑆(𝐺𝐺, 𝐽𝐽𝐽𝐽𝐽𝐽𝐽)

Course on AI@IID: 2018-2019 41


Proof by resolution
Predicate Logic
• It is sound: if it is proven by resolution that α
follows from KB then 𝐾𝐾𝐾𝐾 ⊨ 𝛼𝛼
• It is refutation-complete: If 𝐾𝐾𝐾𝐾 ⊨ 𝛼𝛼 then it
can be proven by resolution that α follows
from KB. Resolution cannot be used to
generate all logical consequences of a set of
sentences.
• And moreover it is algorithmic.

Course on AI@IID: 2018-2019 42


What did we learn
• Basic logical formalisms for modeling
knowledge:
– Propositional Logic: 𝑝𝑝, 𝑞𝑞, 𝑝𝑝⋁𝑞𝑞, 𝑝𝑝⋀𝑞𝑞, ¬𝑝𝑝, 𝑝𝑝 ⇒ 𝑞𝑞,
– Predicate Logic: 𝑃𝑃 𝑥𝑥, 𝑦𝑦 , ∀𝑥𝑥 𝑄𝑄 𝑥𝑥 , ∀𝑥𝑥∃𝑦𝑦 𝑃𝑃(𝑥𝑥, 𝑦𝑦)
• Basic formalism for computational logic
inference for propositional logic:
– Resolution, which is sound and complete.

Course on AI@IID: 2018-2019 43


Class exercise: Muddiest point
Write down on a sheet of paper:

What did you find the most confusing (or


muddiest) point of this part of the lecture

Hand in your sheet of paper at the end of


lecture when leaving the lecture room.

Course on AI@IID: 2018-2019 44


45

Course on AI@IID: 2018-2019

You might also like