200 likes | 348 Views
After the Practical on Clausal Form and Resolution. Question 5 Proving the query of Question 4. Background. We started out from these two formulas: opp(off,on) opp(on,off) XY(opp(X,Y) (next(s(X,off,Y),s(X,on,off) next(s(X,on,off),s(Y,off,X))))
E N D
After the Practical on Clausal Form and Resolution Question 5 Proving the query of Question 4
Background We started out from these two formulas: • opp(off,on) opp(on,off) • XY(opp(X,Y) (next(s(X,off,Y),s(X,on,off) next(s(X,on,off),s(Y,off,X)))) trying to prove the query of Q4: • ABCDVS(next(s(A,B,V),S)next(S,s(C,D,V)))
What the second formula means XY(opp(X,Y) (next(s(X,off,Y),s(X,on,off) next(s(X,on,off),s(Y,off,X)))) “There are only two kinds of transitions, namely next(s(X,off,Y),s(X,on,off) and next(s(X,on,off),s(Y,off,X)”
What needs to be done (intuitive view) From • opp(off,on) opp(on,off) • XY(opp(X,Y) (next(s(X,off,Y),s(X,on,off) next(s(X,on,off),s(Y,off,X)))) Prove: • ABCDVS(next(s(A,B,V),S)next(S,s(C,D,V)))
What needs to be done(using resolution) Given • opp(off,on) opp(on,off) • XY(opp(X,Y) (next(s(X,off,Y),s(X,on,off) next(s(X,on,off),s(Y,off,X)))) Refute: ABCDVS(next(s(A,B,V),S)next(S,s(C,D,V)))
What needs to be done To use resolution • write everything in clausal form • use :- The results are as follows:
Proving 5 from 1-4 • opp(off,on) :- • opp(on,off) :- • next(s(X,off,Y),s(X,on,off)) :- opp(X,Y) • next(s(X,on,off),s(Y,off,X)) :- opp(X,Y) • :- next(s(A,B,V),S) , next(S,s(C,D,V)) Let’s proceed as human calculators first
From 1-4, using Modus Ponens • opp(off,on) :- • opp(on,off) :- • next(s(X,off,Y),s(X,on,off)) :- opp(X,Y) • next(s(X,on,off),s(Y,off,X)) :- opp(X,Y) next(s(off,off,on),s(off,on,off)) (1,3) X=off,Y=on next(s(on,off,off),s(on,on,off)) (2,3) X=on,Y=off next(s(off,on,off),s(on,off,off)) (1,4) X=off,Y=on next(s(on,on,off),s(off,off,on)) (2,4) X=on,Y=off
Informally: suppose s(a,b,c)=s(red,amber,green). Then next s(off,off,on) [go] s(off,on,off) [almost stop] next s(on,off,off) [stop] s(on,on,off) [almost go] next s(off,on,off) [almost stop] s(on,off,off) [stop] next(s(on,on,off) [almost go] s(off,off,on) [go]
“Proving” (5) from what we know 1. next (s(off,off,on), s(off,on,off)) 2. next (s(on,off,off), s(on,on,off)) 3. next (s(off,on,off), s(on,off,off)) 4. next (s(on,on,off), s(off,off,on)) (5) asks: “Can you go from a state (..,..,V) to another state S, from which you can go to another state (..,..,V) ?” 5. :- next(s(A,B,V),S) , next(S,s(C,D,V))
1. next (s(off,off,on), s(off,on,off)) 2. next (s(on,off,off), s(on,on,off)) 3. next (s(off,on,off), s(on,off,off)) 4. next (s(on,on,off), s(off,off,on)) The following transitions are possible: 1,3 goes from (.,.,on) via (.,.,off) to (.,.,off) 2,4 goes from (.,.,off) via (.,.,off) to (.,.,on) 3,2 goes from (.,.,off) via (.,.,off) to (.,.,off) ! 4,1 goes from (.,.,off) via (.,.,on) to (.,.,off) !
3,2 goes from (.,.,off) via (.,.,off) to (.,.,off) ! 4,1 goes from (.,.,off) via (.,.,on) to (.,.,off) ! These are the ones that allow us to “prove” 5. :- next(s(A,B,V),S) , next(S,s(C,D,V)) The unifications enabling us to prove this: 1. next (s(off,off,on), s(off,on,off)) 2. next (s(on,off,off), s(on,on,off)) 3. next (s(off,on,off), s(on,off,off)) 4. next (s(on,on,off), s(off,off,on)) (3,2): A=off,B=on,V=off,S=(on,off,off),C=on,D=on (4,1): A=on,B=on,V=off,S=(off,off,on),C=off,D=on
What would SLD resolution do? • Modus Ponens is not a rule (as such) • All we have is resolution • Recall: a goal p can be proven either because it’s a fact, or because there’s a rulep :- q1,..,qn, where each of q1,..,qn can be proven.
Proving 5 from 1-4 • opp(off,on) :- • opp(on,off) :- • next(s(X,off,Y),s(X,on,off)) :- opp(X,Y) • next(s(X,on,off),s(Y,off,X)) :- opp(X,Y) • :- next(s(A,B,V),S) , next(S,s(C,D,V)) Now with resolution (selecting leftmost literal first). Choose matching clauses smartly, based on our thinking so far.
Proving 5 from 1-4 5 :- next(s(A,B,V),S) , next(S,s(C,D,V)) First step: match next(s(A,B,V),S) with clause 4: 4. next(s(X,on,off),s(Y,off,X)) :- opp(X,Y) After replacement, our new goal is :- opp(X,Y) , next(S,s(C,D,V)) We have made these unifications: A=X,B=on,V=off,S=(Y,off,X). Second step: we might for example choose unifications X=on, Y=off, to prove opp(X,Y)
Proving 5 from 1-4 We had :- opp(X,Y) , next(S,s(C,D,V)) After proving opp(X,Y) using a fact in the KB, we only have to prove :- next(S,(s(C,D,V)) (The story so far: “Let’s try the transition next(s(X,on,off),s(Y,off,X)) where X=on,Y=off”. This is: next(s(on,on,off),s(off,off,on)) .)
Proving 5 from 1-4 Recall that the subgoal we now need to prove is :- next(S,s(C,D,V)) Third step: prove this goal, using the clause 3. next(s(X,off,Y),s(X,on,off)) :- opp(X,Y) This means we have to use these unifications: S=(X,off,Y), C=X,D=on, (V=off) But wait: these X and Y don’t necessarily have the same value as the ones we used for clause 4! So, let’s call the new ones X’ and Y’:
Using X’ and Y’ for clause 3 Recall that the goal we now need to prove is :- next(S,s(C,D,V)) Third step: prove this goal, using 3. next(s(X’,off,Y’),s(X’,on,off)) :- opp(X’,Y’) This means we have to use these unifications: S=(X’,off,Y’), C=X’,D=on,(V=off),X’=Y,Y’=X We can now replace next(S,s(C,D,V)) by :- opp(X’,Y’)
Proving 5 from 1-4 Fourth step: prove :- opp(X’,Y’) But we have already decided to unify X= on, Y=off, X’=Y and Y’=X. So, we prove this goal with X’=off, Y’=on, using clause 1: opp(off,on) :- We now replace opp(X’,Y’) by the empty clause, so there is nothing left to prove: :-
Proving 5 from 1-4 A table summarising this resolution process can be found in the answer to Question 5. Please note: • This shows a sequence of choices that happen to prove the query quickly • An automated procedure would almost certainly take longer • There is one other solution. Can you spot it?