0% found this document useful (0 votes)
45 views39 pages

Inference in FOL (AIMA Ch. 9)

This document discusses various techniques for first-order logic (FOL) inference, including: 1) Reducing FOL inference to propositional inference through predicate instantiation and Skolemization. 2) The use of unification to directly infer conclusions when predicate arguments match. 3) Generalized modus ponens as a sound inference rule for definite clause logic. 4) Forward and backward chaining algorithms for deducing conclusions by applying inference rules to facts and clauses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views39 pages

Inference in FOL (AIMA Ch. 9)

This document discusses various techniques for first-order logic (FOL) inference, including: 1) Reducing FOL inference to propositional inference through predicate instantiation and Skolemization. 2) The use of unification to directly infer conclusions when predicate arguments match. 3) Generalized modus ponens as a sound inference rule for definite clause logic. 4) Forward and backward chaining algorithms for deducing conclusions by applying inference rules to facts and clauses.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Inference in FOL [AIMA Ch.

9]
• Reducing first-order inference to
propositional inference
• Unification
• Generalized Modus Ponens
• Forward and backward chaining
• Logic programming
• Resolution

1
A brief history of reasoning
450b.c. Stoics propositional logic, inference (maybe)
322b.c. Aristotle “syllogisms” (inference rules), quantifiers
1565 Cardano probability theory (propositional logic+
uncertainty)
1847 Boole propositional logic (again)
1879 Freg first-order logic
1922 e proof by truth tables
1930 Wittgenstein ∃ complete algorithm for
1930 Gödel FOL
Herbrand complete algorithm for FOL (reduce to
1931 Gödel propositional)
1960 Davis/Putnam ¬∃ complete algorithm for arithmetic
“practical” algorithm for propositional
1965 Robinson logic
“practical” algorithm for FOL—
resolution

2
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 K ing(x) ∧ Greedy(x) ⇒ E vil(x) yields


K ing(J ohn) ∧ Greedy(John) ⇒ E vil(J ohn) K ing(Richard)
∧ Greedy(Richard) ⇒ E vil(Richard)
K ing(Father(J ohn)) ∧ Greedy(Father(J ohn)) ⇒
Evil(Father(J ohn))

3
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, J ohn)

provided C1 is a new constant symbol, called a Skolem constant

• Another example: from ∃x d(xy)/dy=xy we obtain


d(ey)/dy=ey
provided e is a new constant symbol

4
Existential instantition contd.
• UI can be applied several times to add new
sentences; the new KB is logically equivalent to the
old

• EI can be applied once to replace the existential sentence;


the new KB is not equivalent to the old, but is satisfiable
iff the old KB was satisfiable

5
Reduction to propositional inference
Suppose the KB contains just the following:
∀x K ing(x) ∧ Greedy(x) ⇒ E vil(x)
K ing(J ohn)
Greedy(J ohn)
Brother(Richard, J ohn)

Instantiating the universal


sentence in all possible
ways, we have
K ing(J ohn) ∧
Greedy(J ohn) ⇒
E vil(J ohn)
K ing(Richard) ∧ Greedy(Richard) ⇒ E vil(Richard)
K ing(J ohn)
Greedy(J ohn)
Brother(Richard, J ohn)

The new KB is 6
Reduction contd.
• Claim: a ground sentence is entailed by new KB iff
entailed by original KB
• Claim: 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)))

7
Reduction contd.
• Theorem: Herbrand (1930). If a sentence α is
entailed by an FOL KB, it is entailed by a finite
subset of the propositional KB
• Idea: For n = 0 to ∞ do
create a propositional KB by instantiating with
depth-n terms and see if α is entailed by KB
• Problem: works if α is entailed, loops if α is not
entailed
• Theorem: Turing (1936), Church (1936),
entailment in FOL is semidecidable

8
Problems with propositionalization
• Propositionalization seems to generate lots of
irrelevant sentences.
• E.g., from
∀x K ing(x) ∧ Greedy(x) ⇒ E vil(x)
K ing(J ohn)
∀y Greedy(y)
Brother(Richard, J ohn)
• it seems obvious that E vil(J ohn), but propositionalization
produces lots of facts such as Greedy(Richard) that are
irrelevant
• With p k-ary predicates and n constants, there are p · nk
instantiations
• With function symbols, it gets much much worse!

9
Unification
• We can get the inference immediately if we can find
a substitution θ such that K ing(x) and Greedy(x)
match K ing(John) and Greedy(y)
• θ = {x/John, y/John} works
• UNIFY(α, β) = θ if αθ = βθ

p q θ
K nows(J ohn, x) K nows(J ohn, J ane) {x/J ane}
K nows(J ohn, x) K nows(y,OJ) {x/OJ , y/J ohn}
K nows(J ohn, x) K nows(y,M other(y)) {y/J ohn, x/M other(J ohn)}
K nows(J ohn, x) K nows(x,OJ ) f ail

Standardizing apart eliminates overlap of variables, e.g., K nows(z17, OJ)

10
The unification algorithm

11
The unification algorithm

12
Generalized Modus Ponens (GMP)
p1’, p2’, … , pn’ , (p1 ∧ p2 ∧ … ∧ pn ⇒ q)

• where pi ’θ = pi θ for all i


• p1’ is K ing(J ohn) p1 is K ing(x)
• p2’ is Greedy(y) p2 is Greedy(x)
• θ is {x/J ohn, y/J ohn} q is E vil(x)
• q θ is E vil(J ohn)

GMP used with KB of definite clauses (exactly one positive


literal)

All variables assumed universally quantified

13
Soundness of GMP
Need to show that

p1’, p2’, … , pn’ , (p1 ∧ p2 ∧ … ∧ pn ⇒ q) ╞ qθ

provided that pi ’θ = pi θ for all i

Lemma: For any definite clause p, we have p╞ pθ by UI


1. (p1 ∧ p2 ∧ … ∧ pn ⇒ q) ╞ (p1 ∧ p2 ∧ … ∧ pn ⇒ q)θ = (p1θ ∧ p2θ
∧ … ∧ pnθ ⇒ q θ)
2. p1’, p2’, … , pn’ ╞ p1’ ∧ p2’ ∧ … ∧ pn’ ╞ p1’θ ∧ p2’θ ∧ … ∧ pn’θ
3. From 1 and 2, q follows by ordinary Modus Ponens

14
Example knowledge base
• The law says that it is a crime for an
American to sell weapons to hostile nations.
The country Nono, an enemy of America,
has some missiles, and all of its missiles
were sold to it by Colonel West, who is
American.

• Prove that Col. West is a criminal

15
Example knowledge base contd.
… it is a crime for an American to sell weapons to hostile nations:
American(x) ∧ Weapon(y) ∧ Sells(x,y,z) ∧ Hostile(z) ⇒ Criminal(x)
Nono … has some missiles, i.e., ∃x Owns(Nono,x) ∧ M issile(x):

• Owns(Nono,M ) and M issile(M )


•… all of its missiles were sold to it by Colonol West
• ∀x M issile(x) ∧ Owns(Nono,x) ⇒ Sells(West,x,Nono)
•Missiles are weapons:
• M issile(x) ⇒ Weapon(x)
•An enemy of America counts as “hostile”:
• E nemy(x,America) ⇒ Hostile(x)
•West, who is American …
• American(west)
•The country Non, an enemy of America
• E nemy(Nono,America)

16
Forward chaining algorithm

17
Forward chaining proof

18
Forward chaining proof

19
Forward chaining proof

20
Properties of forward chaining
• Sound and complete for first-order definite clauses
(proof similar to propositional proof)
• Datalog = first-order definite clauses + no
functions (e.g., crime KB)
• FC terminates for Datalog in poly iterations: at
most p · nk literals
• May not terminate in general if α is not
entailed
• This is unavoidable: entailment with definite
clauses is semidecidable

21
Efficiency of forward chaining
• Simple observation: no need to match a rule on iteration k if
a premise wasn't added on iteration k-1
⇒ match each rule whose premise contains a newly added literal

• Matching itself can be expensive

• Database indexing allows O(1) retrieval of known


facts e.g., query M issile(x) retrieves M issile(M 1 )

• Matching conjunctive premises against known facts is


NP-hard

• Forward chaining is widely used in deductive


databases

22
Hard matching example

• Colorable() is inferred iff the CSP has a


solution
• CSPs include 3SAT as a special case,
hence matching is NP-hard
23
Backward chaining algorithm

24
Backward chaining example

25
Backward chaining example

26
Backward chaining example

27
Backward chaining example

28
Backward chaining example

29
Backward chaining example

30
Backward chaining example

31
Properties of backward chaining
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)


⇒ fix using caching of previous results (extra space!)

Widely used (without improvements!) for logic programming

32
Logic programming
• Sound bite: computation as inference on logical
KBs
Logic programming Ordinary programming
1. Identify problem Identify problem
2. Assemble information Assemble information
3. Tea break Figure out solution
4. Encode information in Program solution
KB Encode problem as data
5. Encode problem as Apply program to data
facts Debug procedural
6. Ask queries errors
7. Find false
Should factsto debug Capital(NewYork,US) than x := x + 2!
be easier

33
Prolog systems

•Basis: backward chaining with Horn clauses + bells & whistles Widely
used in Europe, Japan (basis of 5th Generation project) Compilation
techniques ⇒ approaching a billion LIPS

•Program = set of clauses = head :- literal1, … literaln.


• criminal(X) :- american(X), weapon(Y), sells(X,Y,Z), hostile(Z).

• Efficient unification by open coding


• Efficient retrieval of matching clauses by direct linking
• Depth-first, left-to-right backward chaining
• Built-in predicates for arithmetic etc., e.g., X is Y*Z+3
• Closed-world assumption (“negation as failure”)
e.g., given alive(X) :- not dead(X).
alive(joe) succeeds if dead(joe) fails 34
Prolog examples
Depth-first search from a start state X:
dfs(X) :- goal(X).
dfs(X) :- successor(X,S),dfs(S).
No need to loop over S: successor succeeds for

each Appending two lists to produce a third:


append([],Y,Y).
append([X|L],Y,[X|Z]) :-
append(L,Y,Z). query: append(A,B,
answers: A=[] ?
[1,2]) B=[1,2]
A=[1] B=[2]
A=[1,2] B=[]

35
Resolution: brief summary
Full first-order version:
l1 ∨ … ∨ lk, m1 ∨ … ∨ mn
(l1 ∨ … li -1 ∨ li +1 ∨ … ∨ lk ∨ m1 ∨ … ∨ mj -1 ∨ mj +1 ∨ … ∨ mn)θ
where UNIFY(li , ¬mj )=θ.

For example,
¬Rich(x) ∨ Unhappy(x)
Rich(K en)
Unhappy(K en)
with θ = {x/K en}

Apply resolution steps to


CNF(K B ∧ ¬α); complete for
FOL
36
Conversion to CNF

37
Conversion to CNF contd.

38
Resolution proof: definite clauses

39

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy