Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Logic Programming School of Informatics, University of Edinburgh Describing State Change Predicate logic is stateless: if p(a) can once be deduced from.

Similar presentations


Presentation on theme: "1 Logic Programming School of Informatics, University of Edinburgh Describing State Change Predicate logic is stateless: if p(a) can once be deduced from."— Presentation transcript:

1 1 Logic Programming School of Informatics, University of Edinburgh Describing State Change Predicate logic is stateless: if p(a) can once be deduced from a set of axioms then it can always be deduced from those axioms. Modelling the real world, however, requires us to talk about state change. We look at one simple (but common) way to model state in a stateless logic.

2 2 Logic Programming School of Informatics, University of Edinburgh Blocks World Example c b a t1t2t3 c b a t1t2t3 trans(Block, From, To) …….. Op 1 Op n

3 3 Logic Programming School of Informatics, University of Edinburgh State Change as Recursion poss(s0). poss(do(Op, S)) :- poss(S), pact(do(Op, S)). c b a t1t2t3 do( Op1, s0 ) s0 do(Op2, do(Op1, s0 ) )

4 4 Logic Programming School of Informatics, University of Edinburgh Possible Actions pact(do(trans(X, Y, Z), S)) :- holds(clr(Z), S), holds(clr(X), S), holds(on(X, Y), S), \+(X = Z), \+(Z = Y), \+(X = Y). c b a t1t2t3 c b a t1t2t3 trans(c, a, t3) clr(c) clr(t3) on(c,a)

5 5 Logic Programming School of Informatics, University of Edinburgh Initial Conditions holds(on(c,a), s0). holds(on(a,t1), s0). holds(on(b,t2), s0). holds(clr(c), s0). holds(clr(b), s0). holds(clr(t3), s0). c b a t1t2t3

6 6 Logic Programming School of Informatics, University of Edinburgh Transition Effects on State holds(clr(Y), do(trans(_, Y, _), _)). holds(on(X, Z), do(trans(X, _, Z), _)). c b a t1t2t3 c b a t1t2t3 trans(c, a, t3) clr(a) on(c,t3)

7 7 Logic Programming School of Informatics, University of Edinburgh Frame Axiom holds(C, do(trans(X, Y, Z), S)) :- holds(C, S), \+(C = clr(Z)), \+(C = on(X, Y)). c b a t1t2t3 c b a t1t2t3 trans(c, a, t3) on(a,t1) on(b,t2) clr(c) clr(b) on(a,t1) on(b,t2) clr(c) clr(b) on(c,a) clr(t3)

8 8 Logic Programming School of Informatics, University of Edinburgh Goal State goal :- poss(S), holds(on(a,b), S), holds(clr(a), S), holds(on(b,c), S), holds(on(c,t3), S), holds(clr(t1), S), holds(clr(t2), S). c b a t1t2t3

9 9 Logic Programming School of Informatics, University of Edinburgh Plan c b a t1t2t3 c b a t1t2t3 c b a t1t2t3 c b a t1t2t3 trans(c, a, t3)trans(b, t2, c)trans(a, t1, b) poss(do(trans(a,t1,b), do(trans(b,t2,c), do(trans(c,a,t3), s0))))

10 10 Logic Programming School of Informatics, University of Edinburgh Subsumption Based Systems Subsumption based inference is used in programming systems that employ types, classes, description logics and the like. We look at how to infer subsumption in two ways: Through term structure; Through translation to FOPC There are other ways (e.g. by writing a type unification system) but we don’t cover those.

11 11 Logic Programming School of Informatics, University of Edinburgh Term Encoding For Subsumption animal mammalreptile dog vehicle carbus Type described as a structured term e.g. animal(mammal(dog(X))) | ?- animal(X) = animal(mammal(Y)). X = mammal(Y) | ?- animal(X) = vehicle(Y). no | ?- animal(mammal(dog(rover))) = vehicle(car(rover)). no

12 12 Logic Programming School of Informatics, University of Edinburgh Vocabulary Describing Classes subclass(mammal, animal) subclass(intersection(warm_blooded, lactating), mammal) domain(biomass,animal) range(biomass,number) etc… “Mammals are animals” “Mammals are warm blooded and lactating” “Biomass is a function over animals” “Biomass is a function returning a number”

13 13 Logic Programming School of Informatics, University of Edinburgh Translator to FOPC t(subclass(C,D), (T1 :- T2)) :- th(D, Y, T1), tb(C, Y, T2). t(equivalent(C,D), (T1,T2)) :- t(subclass(C,D), T1), t(subclass(D,C), T2). t(range(R,D), (T1 :- T2)) :- th(D, Y, T1), T2 =.. [R,_,Y]. t(domain(R,D), (T1 :- T2)) :- th(D, X, T1), T2 =.. [R,X,_]. t(X : A, T) :- th(A, X, T). t((X1,X2):R, T) :- atom(R), T =.. [R,X1,X2]. th(A, X, T) :- atom(A), T =.. [A,X]. th(intersection(C,D), X, (T1,T2)) :- th(C, X, T1), th(D, X, T2). th(all(R,C), X, (T1 :- T2)) :- th(C, Y, T1), T2 =.. [R,X,Y]. tb(A, X, T) :- atom(A), T =.. [A,X]. tb(intersection(C,D), X, (T1,T2)) :- tb(C, X, T1), tb(D, X, T2). tb(union(C,D), X, (T1 ; T2)) :- tb(C, X, T1), tb(D, X, T2). tb(some(R,C), X, (T1,T2)) :- tb(C, Y, T2), T1 =.. [R,X,Y].

14 14 Logic Programming School of Informatics, University of Edinburgh Applying FOPC Translator | ?- t(subclass(mammal, animal), S). S = (animal(X) :- mammal(X)) | ?- t(subclass(intersection(warm_blooded, lactating), mammal), R). R = (mammal(X) :- warm_blooded(X), lactating(X)) | ?- t(domain(biomass,animal), D). D = (animal(X) :- biomass(X,_)) | ?- t(range(biomass,number), R). R = (number(X) :- biomass(_,X))


Download ppt "1 Logic Programming School of Informatics, University of Edinburgh Describing State Change Predicate logic is stateless: if p(a) can once be deduced from."

Similar presentations


Ads by Google