Title: Inference Rules with Quantifiers
1Inference Rules with Quantifiers
- Substitution
- SUBST(?, ?) ??
- ? ? x1/t1, x2/t2, , xn/tn
- SUBST(x/John, y/mother(x), love(x, y))
love(John, mother(John)) -
2Inference Rules with Quantifiers
- Universal instantiation
- ?x a
- ?????????????
- SUBST(x/ground-term, ?)
- ?x king(x) ? greedy(x) ? evil(x)
- ???????????????????
- king(John) ? greedy(John) ? evil(John)
3Inference Rules with Quantifiers
- Existential instantiation
- ?x a
- ??????????????
- SUBST(x/new-constant, ?)
- ?x crown(x) ? on-head(x, John)
- ??????????????
- crown(c) ? on-head(c, John)
-
-
4Inference Rules with Quantifiers
- Reduction to propositional inference
-
- ?x king(x) ? greedy(x) ? evil(x)
- king(John)
- greedy(John)
- king(John) ? greedy(John) ? evil(John)
-
5Inference Rules with Quantifiers
- An offspring of a horse is a horse
- ?
- Bluebeard is a horse
- ?
- Charlie is Bluebeards offspring
- ?
- Inferences horse(Charlie) ?
-
-
6Inference Rules with Quantifiers
- An offspring of a horse is a horse
- ?x, y horse(x) ? offspring(x, y) ? horse(y)
- Bluebeard is a horse
- horse(Bluebeard)
- Charlie is Bluebeards offspring
- offspring(Bluebeard, Charlie)
- Inference horse(Charlie)
-
-
7Generalized Modus Ponens
- p1, p2, , pn, (p1, p2, , pn ? q)
- ????????????????
- SUBST(?, q)
-
-
- pi and pi are atomic
- SUBST(?, pi) SUBST(?, pi)
-
8Generalized Modus Ponens
- Unification
- UNIFY(p, q) unifier ? where SUBST(?, p)
SUBST(?, q) - knows(John, x) ? hates(John, x)
- knows(John, Jane)
- knows(y, Leonid)
- knows(y, mother(Y))
- knows(y, Elizabeth)
- UNIFY(knows(John, x), knows(John, Jane))
x/Jane - UNIFY(knows(John, x), knows(y, Leonid))
x/Leonid, y/John - UNIFY(knows(John, x), knows(y, mother(y)))
y/John, x/mother(John) - UNIFY(knows(John, x), knows(x, Elizabeth)) fail
9Generalized Modus Ponens
- Standardization
- UNIFY(knows(John, x1), knows(x2, Elizabeth))
x1/John, x2/Elizabeth - Most generalized unifier
- UNIFY(knows(John, x), knows(y, z))
- y/John, x/John, z/John
- y/John, x/Jane, z/Jane
- y/John, x/v, z/v
- y/John, x/z, v/Jane
- y/John, x/z
10Forward Chaining
- An offspring of a horse is a horse
- ?
- Bluebeard is a horse
- ?
- Bluebeard is Charlies parent
- ?
- Offspring and parent are inverse relations
- ?
-
-
11Forward Chaining
- An offspring of a horse is a horse
- ?x,y horse(x) ? offspring(x, y) ? horse(y)
- Bluebeard is a horse
- horse(Bluebeard)
- Bluebeard is Charlies parent
- parent(Charlie, Bluebeard)
- Offspring and parent are inverse relations
- ?x,y offspring(x, y) ? parent(y, x)
-
-
12Backward Chaining
?x,y horse(x) ? offspring(x, y) ?
horse(y) horse(Bluebeard) parent(Charlie,
Bluebeard)
horse(z)
horse(z)
z/Bluebeard
horse(Bluebeard)
offspring(Bluebeard, z)
parent(z, Bluebeard)
z/Charlie
13Soundness and Completeness
- Soundness
- if KB derives a then KB a
-
14Soundness and Completeness
- Modus Ponens is sound
-
- ?x p(x) ? q(x)
- ?x ?p(x) ? r(x)
- ?x q(x) ? s(x)
- ?x r(x) ? s(x)
- q(c)
- KB derives q(c) and KB s(c)
15Soundness and Completeness
- Completeness
- if KB a then KB derives a
-
16Soundness and Completeness
- Modus Ponens is not complete
- ?x p(x) ? q(x)
- ?x ?p(x) ? r(x)
- ?x q(x) ? s(x)
- ?x r(x) ? s(x)
- q(c)
- KB derives s(a) but KB ? s(a)
17Generalized Resolution
- p1 ? pj ? pm
- q1 ? qk ? qn
- ????????????????????????????
- resolvent
- SUBST(?, p1 ? pj-1 ? pj1 ? pm ? q1 ? qk-1
? qk1 ? qn) -
- UNIFY(pj , ?qk) ? for literals pi and qi
18Generalized Resolution
- Conjunctive normal form
-
- ?x p(x) ? q(x)
- ?x ?p(x) ? r(x)
- ?x q(x) ? s(x)
- ?x r(x) ? s(x)
-
- ?p(x) ? q(x)
- p(y) ? r(y)
- ?q(z) ? s(z)
- ?r(t) ? s(t)
-
19Generalized Resolution
- Refutation proof procedure
-
- KB a if and only if KB ? ?a false
20Generalized Resolution
?p(x) ? q(x)
?q(z) ? s(z)
?p(z) ? s(z)
p(y) ? r(y)
?p(x) ? q(x) p(y) ? r(y) ?q(z) ? s(z) ?r(t) ? s(t)
s(y) ? r(r)
?r(t) ? s(t)
s(t)
?s(a)
sound and complete
21Generalized Resolution
- Conversion to CNF
- Eliminate implications
- p ? q ? ?p ? q
- Move ? inwards
- ?(p ? q) ? ?p ? ?q
- ?(p ? q) ? ?p ? ?q
- ??x p ? ?x ?p
- ??x p ? ?x ?p
- ?? p ? p
- Standardize variables
- (?x p(x)) ? (?x p(x)) ? (?x p(x)) ? (?y q(y))
22Generalized Resolution
- Conversion to CNF (cont.)
- Move quantifiers left
- p ? q ? ?X p ? q
- Skolemize (to remove ?)
- ?x p(x) ? p(c) Skolem constant
- ?x ?y p(x, y) ? ?x p(x, f(x)) Skolem function
- Distribute ? over ?
- (p ? q) ? r ? (p ? r) ? (q ? r)
- Flatten nested conjunctions and disjunctions
- (p ? q) ? r ? (p ? q ? r)
- (p ? q) ? r ? (p ? q ? r)
23Generalized Resolution
- Jack owns a dog
- ?
- Every dog owner is an animal lover
- ?
- No animal lover kills an animal
- ?
- Either Jack or Fred killed cat Kiko
- ?
24Generalized Resolution
- Jack owns a dog
- ?x dog(x) ? own(Jack, x)
- Every dog owner is an animal lover
- ?x (?y dog(y) ? own(x, y)) ? animal-loverx)
- No animal lover kills an animal
- ?x animal-lover(x) ? ?y animal(y) ? ?kill(x, y)
- Either Jack or Fred killed cat Kiko
- kill(Jack, Tuna) ? kill(Fred, Kiko)
25Generalized Resolution
- dog(c)
- owns(Jack, c)
- ?dog(y) ? ?own(x, y)) ? animal-lover(x)
- ?animal-lover(x) ? ?animal(y) ? ?kill(x, y)
- kill(Jack, Kiko) ? kill(Fred, Kiko)
- cat(Kiko)
- ?cat(x) ? animal(x)
- ? kill(Fred, Kiko)
26Logic Programming
- Robinson, J.A. 1965. A machine-oriented logic
based on the resolution principle. Journal of ACM
12 (1) 23-41. - Kowalski, R.A. Kuehner, D. 1971. Linear
Resolution with Selection Function. Artificial
Intelligence 2 (3/4) 227-260. - Kowalski, R.A. 1979. Algorithm Logic Control.
Communication of ACM 22 (7) 424-436. - Lloyd, J.W. 1987. Foundations of Logic
Programming (2nd ed.).
27Logic Programming
- Definite logic program
-
- A ? B1, B2, , Bm ? A ? ?B1 ? ?B2 ? ? ?Bm
(program clause) - head body
-
- ? A1, A2, , An ? ?A1 ? ?A2 ? ? ?An (goal
clause) - A, Bi, Aj atoms
-
28Logic Programming
- PROLOG (Alain Colmerauer 1972) only Horn clauses
(definite clauses) allowed
29Logic Programming
- The occur-check is omitted from the unification ?
unsound -
- test ? p(x, x)
- p(x, f(x))
30Logic Programming
- Backward chaining with depth-first search
? incomplete -
- p(x, y) ? q(x, y)
- q(x, y) ? q(y, x)
- p(x, x)
31Logic Programming
- Unsafe cut ? incomplete
-
- A ? B, C ? A
- B ? D, !, E
- D ? ? B, C
-
- ? D, !, E, C
-
- ? !, E, C
-
-
32Logic Programming
- Negation as failure ? P if fails to prove P
- (closed-world assumption)
-
33Exercises
- In Russell Norvigs AIMA (2nd ed.) Exercises
of Chapter 9.