Title: UIUC CS 497: Section EA Lecture
1UIUC CS 497 Section EALecture 3
- Reasoning in Artificial Intelligence
- Professor Eyal Amir
- Spring Semester 2004
2Last Time
- SAT checking using DPLL (instantiate, propagate,
backtrack) - Entailment/SAT checking using Resolution (create
more and more clauses until KB is saturated) - Formal verification uses mainly SAT checking such
as DPLL, but also sometimes resolution
3From Homework You Should Know
- Deduction theorem for FOL
- Language of FOL
- Soundness, completeness, and incompleteness
theorems - Models of FOL
4Today
- Reasoning procedure for FOL
- Proving entailment using Resolution
- Application du jour Temporal Reasoning
- Applications we will not touch
- Spatial reasoning, formal verification,
mathematics, planning, NLP,
5First-Order Theories
- Signature L
- Function symbols (f(x,y))
- Predicate (relation) symbols (P(x,A))
- Constant symbols (A,B,C,)
- FOL language quantification over objects
6Model Theory Reminder
- Structure/Interpretation ltU,Igt
- U Universe of elements
- I Mapping of
- Constant symbols to elements in U
- Predicate symbols to relations over U
- Function symbols to functions over U
- M T - M satisfies T
- T is a theory, i.e., a set of FOL sentences in
language L for which M is an interpretation
-
7Logical Entailment
-
b
a
?
Lman, woman, loves M1ltU1,I1gt U1Sue,Kim,Pat
I1manPat I1womanSue,Kim I1lovesltPat,
Kimgt,ltPat,Suegt
-
b
g
?
8Clausal Form
- Every FOL formula is consistency-equivalent to
conjunction of F.O. clauses. - First-order clause
- Only universal quantifiers (which are implicit)
- Disjunction of literals (atoms or their negation)
9Conversion to Clausal Form
- ? replaced by ?, ?
- Negations in front of atoms
- Standardize variables (unique vars.)
- Eliminate existentials (Skolemization)
- Drop all universal quantifiers
- Move disjunctions in (put into CNF)
- Rename vars. (standardize vars. apart)
10Take a Breath
- Until now
- First-order logic basics
- How to convert a general FOL sentence to clausal
form - From now Resolution theorem proving
- Search in the space of proofs
- Later Temporal reasoning
11Resolution Theorem Proving
- Given
- KB a set of first-order sentences
- Query Q a logical sentence
- Calling procedure
- Add ?Q to KB
- Convert KB into clausal form
- Run theorem prover. If we prove contradiction,
return T.
12Resolution Theorem Proving
- Add ?Q to KB
- Convert KB into clausal form
- Run theorem prover. If we prove contradiction,
return T. - Deduction theorem
- KB Q iff KB ? ?Q
FALSE
-
-
13Resolution Theorem Proving
- Add ?Q to KB
- Convert KB into clausal form
- Run theorem prover. If we prove contradiction,
return T. - Deduction theorem
- KB Q iff KB ? ?Q
FALSE
-
-
14First-Order Resolution
- Resolution inference rule
- C1 P(t1,,tk) ? C1(t1,,tk)
- C2 ?P(s1,,sk) ? C2(s1,,sk)
- mgu(ltt1,,tkgt,lts1,,skgt) r1,,rn
- --------------------------------------------
- C3 (C1 ? C2) r1,,rn
15First-Order Resolution
- Resolution algorithm (saturation)
- While there are unresolved C1,C2
- Select C1, C2 in KB
- If C1, C2 are resolvable, resolve them into a new
clause C3 - Add C3 to KB
- If C3
- return T.
- STOP
C1 P(t1,,tk) ? C1(t1,,tk) C2 ?P(s1,,sk)
? C2(s1,,sk) mgu(ltt1,,tkgt,lts1,,skgt)
r1,,rn ----------------------------------------
---- C3 (C1 ? C2) r1,,rn
16Resolution in Action
C1 P(t1,,tk) ? C1(t1,,tk) C2 ?P(s1,,sk)
? C2(s1,,sk) mgu(ltt1,,tkgt,lts1,,skgt)
r1,,rn ----------------------------------------
---- C3 (C1 ? C2) r1,,rn
On board
KB
Negated Query
17Resolution in Action
C1 P(t1,,tk) ? C1(t1,,tk) C2 ?P(s1,,sk)
? C2(s1,,sk) mgu(ltt1,,tkgt,lts1,,skgt)
r1,,rn ----------------------------------------
---- C3 (C1 ? C2) r1,,rn
On board
KB
Negated Query
18First-Order Resolution
- Resolution algorithm (saturation)
- While there are unresolved C1,C2
- Select C1, C2 in KB
- If C1, C2 are resolvable, resolve them into a new
clause C3 - Add C3 to KB
- If C3
- return T.
- STOP
C1 P(t1,,tk) ? C1(t1,,tk) C2 ?P(s1,,sk)
? C2(s1,,sk) mgu(ltt1,,tkgt,lts1,,skgt)
r1,,rn ----------------------------------------
---- C3 (C1 ? C2) r1,,rn
19First-Order Resolution Rule
- (2) If C1, C2 are resolvable, resolve them into a
new clause C3 - If C1,C2 have two literals l1,l2 with same
predicates (P) and opposite polarity, and - If l1 P(t1,,tk), l2 ?P(s1,,sk), unifiable
- with mgu (most general unifier) r1,,rn,
- then
C1 P(t1,,tk) ? C1(t1,,tk) C2 ?P(s1,,sk)
? C2(s1,,sk) mgu(ltt1,,tkgt,lts1,,skgt)
r1,,rn ----------------------------------------
---- C3 (C1 ? C2) r1,,rn
20Unification
- P(t1,,tk),?P(s1,,sk), unifiable with mgu (most
general unifier) sr1,rk - Substitution replace vars. by terms
- Term constant, variable, or a function of terms
- Composition of substitutions
- x/g(w,v) w/A,v/f(B,z)
- x/g(A,f(B,z),w/A,v/f(B,z)
x/B,y/z
x/B,y/z,x/w
x/B,y/z,z/w
(P(x) v Q(f(x)) v P(g(B,x)) v P(f(y))) x/B,y/z
(P(B) v Q(f(B)) v P(g(B,B)) v P(f(z)))
21Unification
- Unification find a substitution s for
- C1 P(t1,,tk) ? C1(t1,,tk)
- C2 ?P(s1,,sk) ? C2(s1,,sk)
- such that P(t1,,tk)s P(s1,,sk)s
P(A,y,g(x,y))y/f(A) P(z,f(z),g(x,f(w)))z/A,w/
A sy/f(A),z/A,w/A
P(A,y,g(x,y))y/f(w) P(z,f(w),g(x,f(w)))z/A s
y/f(w),z/A
Most general unifier
22Unification
- Substitution s1 more general than s2 if there is
substitution ? such that - s1 ? s2
P(A,y,g(x,y))y/f(A) P(z,f(z),g(x,f(w)))z/A,w/
A sy/f(A),z/A,w/A
P(A,y,g(x,y))y/f(w) P(z,f(w),g(x,f(w)))z/A s
y/f(w),z/A
Most general unifier
23Unification
- Substitution s1 more general than s2 if there is
substitution ? such that - s1 ? s2
s2y/f(A),z/A,w/A
?w/A
s1y/f(w),z/A
Most general unifier
24Finding the MGU
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,w))
25Finding the MGU
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,w))
26Finding the MGU
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,w))
27Finding the MGU
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,w))
28Finding the MGU
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,w))
29Finding the MGU
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
Occurs check
F
x P(A,y,g(x,y)) y P(z,f(w),g(v,w))
part(3,x) y part(3,y) f(w)
part(1,x) P part(1,y) P
part(2,x) A part(2,y) z
part(4,x) g(x,f(w)) part(4,y) g(v,w)
30Finding the MGU another example
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,f(w)))
31Finding the MGU another example
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,f(w)))
32Finding the MGU another example
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,f(w)))
33Finding the MGU another example
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,f(w)))
34Finding the MGU another example
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,f(w)))
35Finding the MGU another example
- Procedure MGU(x,y)
- If xy, return
- If x or y are vars., return MGUvar(x,y)
- If x or y are const.,or Len(x)/Len(y), return
F. - s ? For i ? 1 to Len(x)
- s ? MGU(part(i,x),part(i,y)) if sF, return F.
- s ? compose(s,s) x ? subst(x,s) y ? subst(y,s)
- Return s
x P(A,y,g(x,y)) y P(z,f(w),g(v,f(w)))
part(3,x) y part(3,y) f(w)
part(1,x) P part(1,y) P
part(2,x) A part(2,y) z
part(4,x) g(x,f(w)) part(4,y)
g(v,f(w))
sy/f(w),z/A,v/x
36Correctness of FOL Resolution
- Soundness Resolution is sound for first-order
inference - Refutation Completeness Resolution will find the
empty clause, if FALSE is entailed - No guarantee of termination (saturation), if
FALSE not entailed FOL semi-decidable
37Simple Efficiency Improvements
- Subsumption between clauses
- If clause C subsumes clause D (C entails D), then
we can remove D from the KB. - P(A) P(A),P(B)
- P(A) P(A)
-
- P(f(x),A),Q(g(x),B) P(f(v),y),Q(g(v),y)
- Algorithm for checking subsumption?
-
-
-
P(A)
P(t)
-
38Simple Efficiency Improvements
- Subsumption within the clause
- If literal a subsumes literal b (a entails b),
then we can remove a from the clause - But, notice the variables scope
- P(A),P(t)
- P(A),P(B),P(t)
- P(A,x),P(y,B)
- P(x),Q(x),P(A)
P(A)
P(A),P(B)
P(A,x),P(y,B)
P(x),Q(x),P(A)
39Properties of Resolution
- Unifying two literals of length n
- O(n2) because of occurs check
- Finding two resolvable clauses from m clauses of
length n - O(m2n2) the simple bound
- Overall algorithm
- Semi-decidable
- Unbounded length of proof as function of n,m
40Related to FOL Resolution
- Clause selection and restriction strategies for
resolution (lecture 5, paper 19) - Consequence finding (paper 3)
- Constraint Satisfaction Problem (paper 5)
- Reasoning with equality (paper 6)
- DPLL in FOL (paper 7)
- Decidable fragments of FOL (paper 8)
41Summary So Far
- Resolution theorem proving allows us to find
contradictions and explanation. - The deduction theorem tells us how to ask queries
from Resolution - Next Temporal Reasoning
42Situation Calculus
- A first-order language for describing the effects
of actions and events over time - Constants S0 initial state action constants
- Functions result(ltactiongt,ltsituationgt)
- Predicates fluents properties that change
over time - at(1, S0)
- at(x,s) ? at(x1,result(move_fwd,s))
- Query at(11,s) ? ?ans(s) ?
?at(11,s) ? ans(s)
43Situation Calculus
- Requires axioms describing effects and
non-effects of actions/events - Can be used for planning, projection, diagnosis,
filtering (tracking) - Frame Problem the compact and natural-language-li
ke specification of effects of actions - Qualification Problem the preconditions of
actions
44Notations
- Substitutions
- fs s x1/t1,,xk/tk
- fs s x1/t1,,xk/tk
45Next Time
- Description Logics
- Requires prior knowledge of
- FOL theorem proving
- Tableau theorem proving will be useful
- Frame systems will be useful