Download Inference in FOL Last Lecture

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Inquiry wikipedia , lookup

Statistical inference wikipedia , lookup

Propositional calculus wikipedia , lookup

Truth-bearer wikipedia , lookup

Transcript
Inference in FOL
Introduction to Artificial Intelligence
H di Moradi
Hadi
M di
1
Last Lecture
„
First Order Logic
„
„
„
„
Facts
Objects
Relations
Knowledge Representation
2
1
Logic as a representation of the
World
R
Representation:
i
Sentences
S
entails
Sentence
Refers to
(Semantics)
World
Facts
follows
Fact
3
Desirable Properties of Inference
Procedures
derivation
Sentences
Facts
entail
Follows – from-1
Sentence
Fact
4
2
Inference in First-Order Logic
Given a statement, is it true or false?
f l
„
Proofs – extend propositional logic inference to deal
with quantifiers
„
„
„
„
i.e: if a sentence is entailed by the knowledge base
Unification
Generalized modus ponens
Forward and backward chaining
„
inference rules and reasoning program
5
Inference in First-Order Logic
Given a statement
statement, is it true or false?
„
Completeness:
„
„
Resolution:
„
„
Gödel’s theorem: for FOL, any sentence entailed by another
set of sentences can be proved from that set
iinference
f
procedure
d
that
th t iis complete
l t for
f any sett off
sentences
Logic programming
6
3
Remember:
propositional
logic
7
Reminder
„
Ground term: A term that does not
contain a variable.
„
„
„
A constant symbol
A function applies to some ground term
{{x/a}:
/ } substitution/binding
/
g list
8
4
Universal instantiation (UI)
„
Every instantiation of a universally quantified sentence is
entailed by it:
„
∀v α
Subst({v/g}, α)
for any variable v and ground term g
„
E.g., ∀x King(x) ∧ Greedy(x) ⇒ Evil(x) yields:
„
„
King(John) ∧ Greedy(John) ⇒ Evil(John)
9
Existential instantiation (EI)
„
For any sentence α, variable v, and constant
symbol k that does not appear elsewhere in
the knowledge base:
„
∃v α
Subst({v/k}, α)
„
E.g., ∃x Crown(x) ∧ OnHead(x,John) yields:
Crown(C1) ∧ OnHead(C1,John)
10
provided C is a new constant symbol called
5
Reduction to propositional
inference
Suppose the KB contains just the following:
∀x King(x) ∧ Greedy(x) ⇒ Evil(x)
King(John)
Greedy(John)
Brother(Richard,John)
„
Instantiating the universal sentence in all possible ways, we have:
King(John) ∧ Greedy(John) ⇒ Evil(John)
Ki (Ri h d) ∧ Greedy(Richard)
King(Richard)
G d (Ri h d) ⇒ Evil(Richard)
E il(Ri h d)
King(John)
Greedy(John)
Brother(Richard,John)
„
The new KB is propositionalized: proposition symbols are
„
11
Reduction contd.
„
Every FOL KB can be propositionalized so as to
preserve entailment
„
„
Idea: propositionalize KB and query, apply resolution,
return result
„
„
Problem: with function symbols, there are infinitely
many ground terms,
„
„
e.g., Father(Father(Father(John)))
12
6
Reduction contd.
Theorem: Herbrand ((1930).
) If a sentence α is entailed byy an FOL
KB, it is entailed by a finite subset of the propositionalized KB
Idea: For n = 0 to ∞ do
create a propositional KB by instantiating with depth-$n$ terms
see if α is entailed by this KB
Problem: works if α is entailed, loops if α is not entailed
Theorem: Turing (1936), Church (1936) Entailment for FOL is
semidecidable (algorithms exist that say yes to every entailed
sentence, but no algorithm exists that also says no to every
nonentailed sentence.)
13
Problems with
propositionalization
„
Propositionalization
p
seems to generate
g
lots of irrelevant
sentences.
„
„
„
14
7
Proofs
15
Proofs
The three new inference rules for FOL (compared to
propositional logic) are:
1. Universal Elimination (UE):
for any sentence α, variable x and ground
term τ,
∀x α
i.e. an instance of x makes alpha true.
α{x/τ}
τ is already in the KB
16
8
Proofs
The three new inference rules for FOL (compared to
propositional logic) are:
2. Existential Elimination (EE):
for any sentence α, variable x and constant
symbol k not in KB,
∃x α
α{x/k}
17
Proofs
The three new inference rules for FOL
(compared to propositional logic) are:
3. Existential Introduction (EI):
for any sentence α, variable x not in α
and ground term g in α,
α
α
∃x α{g/x}
e.g. from Likes(Joe, Candy) we can infer ∃ x likes(x, Candy)
18
9
Example Proof
19
Search with primitive example
rules
20
10
Unification
„
We can get the inference immediately if we can find a substitution θ
such that King(x) and Greedy(x) match King(John) and Greedy(y)
„
θ = {x/John,y/John} works
„
Unify(α,β) = θ if αθ = βθ
„
p
Knows(John,x)
Knows(John,x)
Knows(John,x)
Knows(John,x)
q
Knows(John,Jane)
Knows(y,OJ)
Knows(y,Mother(y))
Knows(x,OJ)
θ
21
Unification
„
To unify Knows(John,x)
Knows(John x) and Knows(y,z)
Knows(y z),
„
22
11
More Unification Examples
VARIABLE term
1 – unify(P(a,X), P(a,b))
2 – unify(P(a,X), P(Y,b))
3 – unify(P(a,X), P(Y,f(a))
4 – unify(P(a,X),
if (P( X) P(X,b))
P(X b))
θ = {X/b}
θ = {Y/a, X/b}
θ = {Y/a, X/f(a)}
θ = failure
f il
Note: If P(a,X) and P(X,b) are independent, then we
can replace X with Y and get the unification to
work.
23
Generalized Modus Ponens
(GMP)
p1',, p2',, … , pn',, ( p1 ∧ p2 ∧ … ∧ pn ⇒q)
q)
qθ
p1 is King(x)
p1' is King(John)
p2 is Greedy(x)
p2' is Greedy(y)
θ is {x/John,y/John}
q is Evil(x)
q θ is Evil(John)
where pi'θ = pi θ for all i
24
12
Soundness of GMP
25
Properties of GMP
„
Why is GMP an efficient inference rule?
„
„
„
It takes bigger steps, combining several small
inferences into one
It takes sensible steps: uses eliminations that are
guaranteed to help (rather than random UEs)
It uses a pre-compilation step which converts the
KB to canonical form (Horn sentences)
26
13
Properties of GMP
Remember: sentence in Horn from is a
conjunction of Horn clauses
(clauses with at most one positive
literal), e.g.,
(A ∨ ¬B) ∧ (B ∨ ¬C ∨ ¬D), that is (B ⇒
A) ∧ ((C ∧ D) ⇒ B)
27
Horn form
„
„
We convert sentences to Horn form as they are
entered into the KB
Using Existential Elimination and And Elimination
28
14
Forward chaining
Ho to design a program to do inference for me?
How
29
Forward chaining example
=> {x/Bob}
30
15
Example: Forward Chaining
Current available rules
„ A ^ C => E
„ D ^ C => F
„ B ^ E => F
„ B =>
>C
„ F => G
31
Improving Forward Chaining
„
Problems with FC:
„
Solutions:
32
16
Forward chaining proof
33
Forward chaining proof
34
17
Forward chaining proof
35
Properties of forward chaining
„
Sound and complete for first
first-order
order definite clauses
„
36
18
Inference example
quaker(X) => pacifist(X)
pacifist(X).
republican(X) => ¬pacifist(X).
republican(george).
quaker(richard).
republican(richard)?
Can we use forward chaining to achieve this?
37
Backward chaining
38
19
Backward chaining example
39
A simple example
„
B^C=> G
A^G=> I
D^G=>J
E=> C
D^C >K
D^C=>K
F=>C
„
Q: I?
„
„
„
„
„
40
20
Another Example (from
Konelsky)
„
Nintendo example.
example
„
Nintendo says it is Criminal for a programmer to
provide emulators to people. My friends don’t
have a Nintendo 64, but they use software that
runs N64 games on their PC, which is written by
Reality Man, who is a programmer.
41
Forward Chaining
„
The knowledge base initially contains:
„
„
„
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧
Provide(x,z,y) ⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games) ⇒
Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games) ⇒ Emulator(x)
42
21
Forward Chaining
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)
Provide(x z y)
⇒ Criminal(x)
(1)
Use(friends, x) ∧ Runs(x, N64 games)
⇒ Provide(Reality Man, friends, x)
(2)
Software(x) ∧ Runs(x, N64 games)
⇒ Emulator(x)
„
(3)
Now we add atomic sentences to the KB sequentially, and
call on the forward-chaining procedure:
„
FORWARD-CHAIN(KB, Programmer(Reality Man))
43
Forward Chaining
Programmer(x)
g
( ) ∧ Emulator(y)
(y) ∧ People(z)
p ( ) ∧ Provide(x,z,y)
( , ,y)
⇒ Criminal(x)
(1)
Use(friends, x) ∧ Runs(x, N64 games)
⇒ Provide(Reality Man, friends, x)
(2)
Software(x) ∧ Runs(x, N64 games)
⇒ Emulator(x)
(3)
Programmer(Reality Man)
„
(4)
This new premise unifies with (1) with
subst({x/Reality Man}, Programmer(x))
but not all the premises of (1) are yet known, so
nothing further happens.
44
22
Forward Chaining
Programmer(x) ∧ Emulator(y) ∧ People(z)
Provide(x,z,y)
⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games)
⇒ Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games)
⇒ Emulator(x)
E l t ( )
∧
(1)
(2)
(3)
Programmer(Reality Man)
„
(4)
Continue adding atomic sentences:
„
FORWARD-CHAIN(KB, People(friends))
45
Forward Chaining
Programmer(x) ∧ Emulator(y) ∧ People(z)
Provide(x z y)
Provide(x,z,y)
⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games)
⇒ Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games)
⇒ Emulator(x)
Programmer(Reality Man)
People(friends)
„
∧
(1)
(2)
(3)
(4)
(5)
This also unifies with (1) with subst({z/friends},
People(z)) but other premises are still missing.
46
23
Forward Chaining
„
Programmer(x) ∧ Emulator(y) ∧ People(z)
Provide(x,z,y)
⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games)
⇒ Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games)
⇒ Emulator(x)
E l t ( )
Programmer(Reality Man)
People(friends)
Add:
„
∧
(1)
(2)
(3)
(4)
(5)
FORWARD-CHAIN(KB, Software(U64))
47
Forward Chaining
Programmer(x)
g
( ) ∧ Emulator(y)
(y) ∧ People(z)
p ( ) ∧ Provide(x,z,y)
( , ,y)
⇒ Criminal(x)
(1)
Use(friends, x) ∧ Runs(x, N64 games)
⇒ Provide(Reality Man, friends, x)
(2)
Software(x) ∧ Runs(x, N64 games)
⇒ Emulator(x)
(3)
Programmer(Reality
g
(
y Man))
People(friends)
Software(U64)
„
( )
(4)
(5)
(6)
This new premise unifies with (3) but the other
premise is not yet known.
48
24
Forward Chaining
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)
⇒ Criminal(x)
(1)
Use(friends, x) ∧ Runs(x, N64 games)
⇒ Provide(Reality Man, friends, x)
(2)
Software(x) ∧ Runs(x, N64 games)
⇒ Emulator(x)
(3)
Programmer(Reality Man)
People(friends)
Software(U64)
„
(4)
(5)
(6)
Add:
„
FORWARD-CHAIN(KB, Use(friends, U64))
49
Forward Chaining
„
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games) ⇒ Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games) ⇒ Emulator(x)
(1)
(2)
(3)
Programmer(Reality Man)
People(friends)
Software(U64)
Use(friends, U64)
(4)
(5)
(6)
(7)
This premise unifies with (2) but one still lacks.
50
25
Forward Chaining
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games) ⇒ Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games) ⇒ Emulator(x)
„
Programmer(Reality Man)
People(friends)
Software(U64)
Use(friends U64)
Use(friends,
Add:
„
(1)
(2)
(3)
(4)
(5)
(6)
(7)
FORWARD-CHAIN(Runs(U64, N64 games))
51
Forward Chaining
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games) ⇒ Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games) ⇒ Emulator(x)
„
Programmer(Reality Man)
People(friends)
Software(U64)
Use(friends U64)
Use(friends,
Runs(U64, N64 games)
This new premise unifies with (2) and (3).
(1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
52
26
Forward Chaining
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games) ⇒ Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games) ⇒ Emulator(x)
„
(1)
(2)
(3)
Programmer(Reality Man)
(4)
People(friends)
(5)
Software(U64)
(6)
Use(friends U64)
Use(friends,
(7)
Runs(U64, N64 games)
(8)
Premises (6), (7) and (8) satisfy the implications fully.
53
Forward Chaining
„
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)⇒ Criminal(x)
Use(friends, x) ∧ Runs(x, N64 games) ⇒ Provide(Reality Man, friends, x)
Software(x) ∧ Runs(x, N64 games) ⇒ Emulator(x)
(1)
(2)
(3)
Programmer(Reality Man)
People(friends)
Software(U64)
Use(friends U64)
Use(friends,
Runs(U64, N64 games)
(4)
(5)
(6)
(7)
(8)
So we can infer the consequents, which are now added to the
knowledge base (this is done in two separate steps).
54
27
Forward Chaining
„
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)⇒ Criminal(x)
(1)
U (f i d x)) ∧ Runs(x,
Use(friends,
R
( N64 games)) ⇒ Provide(Reality
P
id (R lit Man,
M
friends,
f i d x))
(2)
Software(x) ∧ Runs(x, N64 games) ⇒ Emulator(x)
(3)
Programmer(Reality Man)
(4)
People(friends)
(5)
Software(U64)
(6)
Use(friends, U64)
(7)
Runs(U64, N64 games)
(8)
Provide(Reality Man, friends, U64)
(9)
Emulator(U64)
(10)
Addition of these new facts triggers further forward chaining.
55
Forward Chaining
„
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧ Provide(x,z,y)⇒ Criminal(x)
(1)
U (f i d x)) ∧ Runs(x,
Use(friends,
R
( N64 games)) ⇒ Provide(Reality
P
id (R lit Man,
M
friends,
f i d x))
(2)
Software(x) ∧ Runs(x, N64 games) ⇒ Emulator(x)
(3)
Programmer(Reality Man)
(4)
People(friends)
(5)
Software(U64)
(6)
Use(friends, U64)
(7)
Runs(U64, N64 games)
(8)
Provide(Reality Man, friends, U64)
(9)
Emulator(U64)
(10)
Criminal(Reality Man)
(11)
Which results in the final conclusion: Criminal(Reality Man)
56
28
Forward Chaining
„
„
Forward Chaining acts like a breadth
breadth-first
first
search at the top level, with depth-first subsearches.
Since the search space spans the entire KB, a
large KB must be organized in an intelligent
manner in order to enable efficient searches
in reasonable time.
57
Backward Chaining
„
Current knowledge:
„
„
What implications can lead to this fact?
„
„
„
„
„
hurts(x, head)
kicked(x, head)
fell_on(x, head)
brain tumor(x)
brain_tumor(x)
hangover(x)
What facts do we need in order to prove these?
58
29
Backward Chaining
„
The algorithm
(available in detail in Fig.
Fig 9.2
9 2 on page 275 of the text):
„
a knowledge base KB
„
a desired conclusion c or question q
„
finds all sentences that are answers to q in KB or proves c
„
„
„
„
if q is directly provable by premises in KB, infer q and remember
how q was inferred (building a list of answers).
find all implications
p
that have q as a consequent.
q
for each of these implications, find out whether all of its premises
are now in the KB, in which case infer the consequent and add it
to the KB, remembering how it was inferred. If necessary,
attempt to prove the implication also via backward chaining
premises that are conjuncts are processed one conjunct at a time
59
Backward Chaining
„
Q
Question:
Has Realityy Man done anything
y
g
criminal?
„
„
Criminal(Reality Man)
Possible answers:
„
Steal(x, y) ⇒ Criminal(x)
„
Kill(x y) ⇒ Criminal(x)
Kill(x,
„
Grow(x, y) ∧ Illegal(y) ⇒ Criminal(x)
„
HaveSillyName(x) ⇒ Criminal(x)
„
Programmer(x) ∧ Emulator(y) ∧ People(z) ∧
Provide(x,z,y) ⇒Criminal(x)
60
30
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
61
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
Steal(x,y)
62
31
Backward Chaining
„
Question: Has Reality Man done
anything criminal?
Criminal(x)
Steal(x,y)
FAIL
63
Backward Chaining
„
Question: Has Reality Man done
anything criminal?
Criminal(x)
Steal(x,y)
Kill(x,y)
FAIL
64
32
Backward Chaining
„
Question: Has Reality Man done
anything criminal?
Criminal(x)
Steal(x,y)
Kill(x,y)
FAIL
FAIL
65
Backward Chaining
„
Question: Has Reality Man done
anything criminal?
Criminal(x)
Steal(x,y)
FAIL
Kill(x,y)
ggrows(x,y)
( ,y)
Illegal(y)
g (y)
FAIL
66
33
Backward Chaining
„
Question: Has Reality Man done
anything criminal?
Criminal(x)
Steal(x y)
Steal(x,y)
FAIL
Kill(x y)
Kill(x,y)
FAIL
grows(x y)
grows(x,y)
FAIL
Illegal(y)
FAIL
67
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
Steal(x,y)
FAIL
„
Kill(x,y)
FAIL
grows(x,y)
FAIL
Illegal(y)
FAIL
Backward Chaining is a depth-first search: in
any knowledge base of realistic size, many
search paths will result in failure.
68
34
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
69
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
Programmer(x)
Yes, {x/Reality Man}
70
35
Backward Chaining
„
Question: Has Reality Man done
anything criminal?
Criminal(x)
Programmer(x)
People(Z)
Yes, {x/Reality Man}
Yes, {z/friends}
71
Backward Chaining
„
Question: Has Reality Man done
anything criminal?
Criminal(x)
Programmer(x)
Emulator(y)
Yes, {x/Reality Man}
People(Z)
Yes, {z/friends}
72
36
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
Programmer(x)
Emulator(y)
People(Z)
Yes, {x/Reality Man}
Yes, {z/friends}
Software(ultraHLE)
Yes, {y/UltraHLE}
73
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
Programmer(x)
Yes, {x/Reality Man}
Emulator(y)
People(Z)
Yes, {z/friends}
Software(ultraHLE)
Yes, {y/UltraHLE}
Runs(UltraHLE, N64 games)
yes, {}
74
37
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
Programmer(x)
Emulator(y)
Yes, {x/Reality Man}
People(Z)
Yes, {z/friends}
Provide
(reality man,
ultraHLE,
friends)
Software(ultraHLE)
Runs(UltraHLE, N64 games)
Yes, {y/UltraHLE}
yes, {}
75
Backward Chaining
„
Question: Has Reality Man done anything criminal?
Criminal(x)
Programmer(x)
Emulator(y)
Yes, {x/Reality Man}
People(Z)
Yes, {z/friends}
Provide
(reality man,
ultraHLE,
friends)
Software(ultraHLE)
Yes, {y/UltraHLE}
Use(friends, UltraHLE)
Runs(UltraHLE, N64 games)
yes, {}
76
38
Properties of backward
chaining
„
Depth-first
Depth
first recursive proof search: space is
linear in size of proof
„
„
Incomplete due to infinite loops
„
„
⇒ fix by checking current goal against every goal
on stack
„
„
Inefficient due to repeated subgoals (both
success and failure)
77
⇒ fix using caching of previous results (extra
Completeness
„
As explained earlier, Generalized Modus Ponens
requires sentences to be in Horn form:
„
„
„
atomic, or
an implication with a conjunction of atomic
sentences as the antecedent and an atom as the
consequent.
However, some sentences cannot be expressed
However
in Horn form.
„
„
e.g.: ∀x ¬ bored_of_this_lecture (x)
Cannot be expressed in Horn form due to presence
of negation.
78
39
Completeness
„
A significant problem since Modus
Ponens cannot operate on such a
sentence, and thus cannot use it in
inference.
„
Knowledge
o edge e
exists
s s bu
but ca
cannot
o be used
used.
„
Thus inference using Modus Ponens is
incomplete.
79
Completeness
„
„
However, Kurt Gödel in 1930-31
However
1930 31 developed
the completeness theorem, which shows
that it is possible to find complete inference
rules.
The theorem states:
„
„
a y sentence entailed
any
a d by a set of
o sentences can
a
be proven from that set.
=> Resolution Algorithm which is a
complete inference method.
80
40
Completeness
„
„
„
The completeness theorem says that a sentence can
be proved if it is entailed by another set of sentences.
This is a big deal, since arbitrarily deeply nested
functions combined with universal quantification
make a potentially infinite search space.
But entailment in first-order
first order logic is only semi
semidecidable, meaning that if a sentence is not entailed
by another set of sentences, it cannot necessarily be
proven.
81
Completeness in FOL
82
41
Historical note
83
Kinship Example
KB:
KB
(1) father (art, jon)
(2) father (bob, kim)
(3) father (X, Y) ⇒ parent (X, Y)
Goal:
parent (art, jon)?
84
42
Refutation Proof/Graph
~parent(art,jon)
( j ) ~father(X,
f h (X Y) \/ parent(X,
(X Y)
\
/
~ father (art, jon)
father (art, jon)
\
/
[]
85
Resolution
86
43
Resolution inference rule
87
Remember: normal forms
“product of sums of
simple variables or
negated simple variables”
“sum of products of
simple variables or
negated simple variables”
88
44
Conjunctive normal form
89
Skolemization
90
45
Examples: Converting FOL
sentences to clause form…
Convert the sentence
1. (∀x)(P(x) => ((∀y)(P(y) => P(f(x,y))) ^ ~(∀y)(Q(x,y)
=> P(y))))
(like A => B ^ C)
„
2. Eliminate =>
(∀x)(~P(x) ∨ ((∀y)(~P(y) ∨ P(f(x,y))) ^ ~(∀y)(~Q(x,y) ∨
(y))))
P(y))))
3. Reduce scope of negation
(∀x)(~P(x) ∨ ((∀y)(~P(y) ∨ P(f(x,y))) ^ (∃y)(Q(x,y) ^
~P(y))))
4. Standardize variables
(∀x)(~P(x) ∨ ((∀y)(~P(y) ∨ P(f(x,y))) ^ (∃z)(Q(x,z) ^
~P(z))))
91
Examples: Converting FOL
sentences to clause form…
5. Eliminate existential quantification
(∀x)(~P(x) ∨((∀y)(~P(y) ∨ P(f(x,y))) ^
(Q(x,g(x)) ^ ~P(g(x)))))
6. Drop universal quantification symbols
(~P(x) ∨ ((~P(y) ∨ P(f(x,y))) ^ (Q(x,g(x)) ^
~P(g(x)))))
7. Convert to conjunction of disjunctions
(~P(x) ∨ ~P(y) ∨ P(f(x,y))) ^ (~P(x) ∨
Q(x,g(x))) ^(~P(x) ∨ ~P(g(x)))
92
46
Examples: Converting FOL
sentences to clause form…
8. Create separate clauses
~P(x) ∨ ~P(y) ∨ P(f(x,y))
~P(x) ∨ Q(x,g(x))
~P(x) ∨ ~P(g(x))
9. Standardize variables
~P(x) ∨ ~P(y) ∨ P(f(x,y))
~P(z) ∨ Q(z,g(z))
~P(w) ∨ ~P(g(w))
93
Resolution proof
94
47
Resolution proof
95
Reference in First-Order Logic
„
Resolution Proofs
In a forward- or backward-chaining algorithm, just as
Modus Ponens.
P(w) ⇒ Q(w)
Q( y) ⇒ S ( y)
{y/w}
P(w) ⇒ S(w)
True ⇒ P ( x ) ∨ R ( x)
{w/x}
True ⇒ S ( x) ∨ R( x)
R( z ) ⇒ S ( z )
{x/A,z/A}
True ⇒ S ( A)
96
48
Inference in First-Order Logic
„
Refutation
P(w) ⇒ Q(w)
Q( y) ⇒ S ( y)
{y/w}
P(w) ⇒ S(w)
True ⇒ P ( x) ∨ R ( x)
{w/x}
R( z ) ⇒ S ( z )
True ⇒ S ( x) ∨ R( x)
{z/x}
( KB ∧ ¬P ⇒ False) ⇔ ( KB ⇒ P )
True ⇒ S ( A)
S ( A) ⇒ False
{x/A}
True ⇒ False
97
Example of Refutation Proof
(in conjunctive normal form)
(1)
(2)
(3)
(4)
Cats like fish
Cats eat everything they
like.
Josephine is a cat.
Prove: Josephine eats fish.
¬cat (x) ∨ likes (x,fish)
¬cat (y) ∨ ¬likes (y,z) ∨ eats
(y,z)
cat (jo)
eats (j
(jo,fish)
,
)
98
49
Backward Chaining
Negation of goal wff: ¬ eats(jo, fish)
¬ eats(jo, fish)
¬ cat(y) ∨ ¬likes(y, z) ∨ eats(y, z)
θ = {y/jo, z/fish}
¬ cat(jo) ∨ ¬likes(jo, fish)
cat(jo)
θ=∅
¬ cat(x) ∨ likes(x, fish)
¬ likes(jo, fish)
θ = {x/jo}
¬ cat(jo)
cat(jo)
⊥ (contradiction)
99
Forward chaining
¬cat (X) ∨ likes (X,fish)
cat (jo)
\
/
¬cat (Y) ∨ ¬likes (Y,Z) ∨ eats (Y,Z)
likes (jo,fish)
\
/
¬cat (jo) ∨ eats (jo,fish)
cat (jo)
\
/
eats (jo,fish)
\
¬ eats (jo,fish)
/
[]
100
50
Question:
„
„
When would you use forward chaining?
What about backward chaining?
A:
„
„
FC: If expert needs to gather information
before any inferencing
BC: If expert has a hypothetical solution
101
Resolution proof: definite clauses
102
51