35load('foundations/Root.e').
36
38load('foundations/EC.e').
39
42sort(object).
43
45subsort(agent, object).
46
49subsort(food, object).
50
52sort(surface).
53
55sort(plan).
56
59reified_sort(belief).
60
64t(agent, cat).
65
67t(surface, floor).
68
69t(surface, chair).
70
71t(surface, shelf).
72
73t(surface, table).
74
76t(food, food1).
77
78t(food, food2).
79
81t(plan, p1).
82
83t(plan, p1a).
84
85t(plan, p1b).
86
87t(plan, p2).
88
89t(plan, p2a).
90
93predicate(selectedPlan(agent, belief, plan, time)).
94
97predicate(soundPlan(agent, belief, plan, time)).
98
101fluent(on(object, surface)).
102
104fluent(goal(agent, belief)).
105
107fluent(canJump(surface, surface)).
108
110fluent(plan(agent, belief, plan)).
111
114fluent(satiated(agent)).
115
117fluent(believe(agent, belief)).
118
121event(addPlan(agent, belief, plan)).
122
124event(dropPlan(agent, belief, plan)).
125
127event(jump(agent, surface, surface)).
128
131event(move(surface, surface, surface)).
132
134event(eat(agent, food)).
135
137event(wait(agent)).
138
141t(belief, 'bSatiated(agent)').
142
144t(belief, 'bCanJump(surface').
145
146t(belief, 'surface)').
147
150t(belief, 'bOn(object').
151
152t(belief, 'surface)').
153
161initiates(addPlan(Agent, Belief, Plan), plan(Agent, Belief, Plan), Time).
162
169terminates(dropPlan(Agent, Belief, Plan), plan(Agent, Belief, Plan), Time).
170
178holds_at(on(Agent, Surface1), Time), holds_at(canJump(Surface1, Surface2), Time) ->
179 initiates(jump(Agent, Surface1, Surface2),
180 on(Agent, Surface2),
181 Time).
182
190holds_at(on(Agent, Surface1), Time), holds_at(canJump(Surface1, Surface2), Time) ->
191 terminates(jump(Agent, Surface1, Surface2),
192 on(Agent, Surface1),
193 Time).
194
200initiates(move(Surface1, Surface2, Surface3), canJump(Surface1, Surface3), Time).
201
207terminates(move(Surface1, Surface2, Surface3), canJump(Surface1, Surface2), Time).
208
216holds_at(on(Agent, Surface), Time), holds_at(on(Food, Surface), Time) ->
217 initiates(eat(Agent, Food),
218 satiated(Agent),
219 Time).
220
228holds_at(on(Agent, Surface), Time), holds_at(on(Food, Surface), Time) ->
229 terminates(eat(Agent, Food),
230 on(Food, Surface),
231 Time).
232
243holds_at(believe(Agent, bOn(Agent, Surface1)), Time), holds_at(believe(Agent, bCanJump(Surface1, Surface2)), Time), Belief=bOn(Agent, Surface2) ->
244 initiates(jump(Agent, Surface1, Surface2),
245 believe(Agent, Belief),
246 Time).
247
259holds_at(believe(Agent, bOn(Agent, Surface1)), Time), holds_at(believe(Agent, bCanJump(Surface1, Surface2)), Time), Belief=bOn(Agent, Surface1) ->
260 terminates(jump(Agent, Surface1, Surface2),
261 believe(Agent, Belief),
262 Time).
263
273Belief=bCanJump(Surface1, Surface3) ->
274 initiates(move(Surface1, Surface2, Surface3),
275 believe(Agent, Belief),
276 Time).
277
286Belief=bCanJump(Surface1, Surface2) ->
287 terminates(move(Surface1, Surface2, Surface3),
288 believe(Agent, Belief),
289 Time).
290
299holds_at(believe(Agent, bOn(Agent, Surface)), Time), holds_at(believe(Agent, bOn(Food, Surface)), Time), Belief=bSatiated(Agent) ->
300 initiates(eat(Agent, Food),
301 believe(Agent, Belief),
302 Time).
303
312holds_at(believe(Agent, bOn(Agent, Surface)), Time), holds_at(believe(Agent, bOn(Food, Surface)), Time), Belief=bOn(Food, Surface) ->
313 terminates(eat(Agent, Food),
314 believe(Agent, Belief),
315 Time).
316
330holds_at(goal(Agent, Belief), Time), not(holds_at(believe(Agent, Belief), Time)), selectedPlan(Agent, Belief, Plan, Time), not(exists([Plan1], holds_at(plan(Agent, Belief, Plan1), Time))) ->
331 happens(addPlan(Agent, Belief, Plan), Time).
332
343holds_at(plan(Agent, Belief, p1), Time), not(holds_at(believe(Agent, Belief), Time)), soundPlan(Agent, Belief, p1, Time) ->
344 happens(jump(cat, floor, chair), Time).
345
354holds_at(plan(Agent, Belief, p1a), Time), not(holds_at(believe(Agent, Belief), Time)), soundPlan(Agent, Belief, p1a, Time) ->
355 happens(wait(cat), Time).
356
365holds_at(plan(Agent, Belief, p2), Time), not(holds_at(believe(Agent, Belief), Time)), soundPlan(Agent, Belief, p2, Time) ->
366 happens(jump(cat, chair, shelf), Time).
367
375holds_at(plan(Agent, Belief, Plan), Time) ->
376 happens(dropPlan(Agent, Belief, Plan), Time).
377
387holds_at(plan(Agent, Belief, p1), Time), not(holds_at(believe(Agent, Belief), Time)), soundPlan(Agent, Belief, p1, Time) ->
388 happens(addPlan(Agent, Belief, p1a), Time).
389
398holds_at(plan(Agent, Belief, p1a), Time), not(holds_at(believe(Agent, Belief), Time)), soundPlan(Agent, Belief, p1a, Time) ->
399 happens(addPlan(Agent, Belief, p1b), Time).
400
409holds_at(plan(Agent, Belief, p2), Time), not(holds_at(believe(Agent, Belief), Time)), soundPlan(Agent, Belief, p2, Time) ->
410 happens(addPlan(Agent, Belief, p2a), Time).
411
421not(holds_at(satiated(Agent), Time)), holds_at(on(Agent, Surface), Time), holds_at(on(Food, Surface), Time) ->
422 happens(eat(Agent, Food), Time).
423
430happens(move(chair, table, shelf), 2).
431
432%
433%
434% ; SelectedPlan - plan library
435%
436% ;[agent,belief,plan,time]
437% ;SelectedPlan(agent,belief,plan,time) <->
438% ;(agent=Cat & belief=BSatiated(Cat) & plan=P1 & time=0) |
439% ;(agent=Cat & belief=BSatiated(Cat) & plan=P2 & time=4).
440% examples/Mueller2006/Chapter11/HungryCat.e:214
441%
442% examples/Mueller2006/Chapter11/HungryCat.e:215
443% [agent,belief,plan,time]%
444% SelectedPlan(agent,belief,plan,time) <->
445% ({surface1,surface2,surface3,food}
446% HoldsAt(Believe(agent,BOn(agent,surface1)),time) &
447% HoldsAt(Believe(agent,BCanJump(surface1,surface2)),time) &
448% HoldsAt(Believe(agent,BCanJump(surface2,surface3)),time) &
449% HoldsAt(Believe(agent,BOn(food,surface3)),time) &
450% belief=BSatiated(agent) &
451% plan=P1 &
452% time=0) |
453% ({surface1,surface2,surface3,food}
454% HoldsAt(Believe(agent,BOn(agent,surface1)),time) &
455% HoldsAt(Believe(agent,BCanJump(surface1,surface2)),time) &
456% HoldsAt(Believe(agent,BCanJump(surface2,surface3)),time) &
457% HoldsAt(Believe(agent,BOn(food,surface3)),time) &
458% belief=BSatiated(agent) &
459% plan=P2 &
460% time=4).
461selectedPlan(Agent, Belief, Plan, Time) <->
462 ( exists([Surface1, Surface2, Surface3, Food],
463 (holds_at(believe(Agent, bOn(Agent, Surface1)), Time), holds_at(believe(Agent, bCanJump(Surface1, Surface2)), Time), holds_at(believe(Agent, bCanJump(Surface2, Surface3)), Time), holds_at(believe(Agent, bOn(Food, Surface3)), Time), Belief=bSatiated(Agent), Plan=p1, Time=0))
464 ; exists(
465 [ Surface18,
466 Surface29,
467 Surface310,
468 Food11
469 ],
470 (holds_at(believe(Agent, bOn(Agent, Surface18)), Time), holds_at(believe(Agent, bCanJump(Surface18, Surface29)), Time), holds_at(believe(Agent, bCanJump(Surface29, Surface310)), Time), holds_at(believe(Agent, bOn(Food11, Surface310)), Time), Belief=bSatiated(Agent), Plan=p2, Time=4))
471 ).
472
473% examples/Mueller2006/Chapter11/HungryCat.e:232
474%
475%
476%
477% ; SoundPlan
478%
479% examples/Mueller2006/Chapter11/HungryCat.e:237
480% [agent,belief,plan,time]%
481% SoundPlan(agent,belief,plan,time) <->
482% (plan=P1 ->
483% HoldsAt(Believe(agent,BCanJump(Floor,Chair)),time) &
484% HoldsAt(Believe(agent,BCanJump(Chair,Table)),time)) &
485% ((plan=P1a | plan=P1b) ->
486% HoldsAt(Believe(agent,BCanJump(Chair,Table)),time)).
487soundPlan(Agent, Belief, Plan, Time) <->
488 ( Plan=p1->holds_at(believe(Agent, bCanJump(floor, chair)), Time), holds_at(believe(Agent, bCanJump(chair, table)), Time)
489 ),
490 ( Plan=p1a;Plan=p1b->holds_at(believe(Agent, bCanJump(chair, table)), Time)
491 ).
492
493% examples/Mueller2006/Chapter11/HungryCat.e:243
494%
495%
496% ; Gamma
497%
498% examples/Mueller2006/Chapter11/HungryCat.e:247
499% [agent,belief]%
500% HoldsAt(Goal(agent,belief),0) <->
501% (agent=Cat & belief=BSatiated(Cat)).
502holds_at(goal(Agent, Belief), 0) <->
503 Agent=cat,
504 Belief=bSatiated(cat).
505
510not(holds_at(plan(Agent, Belief, Plan), 0)).
511
512%
513%
514% examples/Mueller2006/Chapter11/HungryCat.e:253
515% [object,surface] % HoldsAt(On(object,surface),0) <->
516% (object=Cat & surface=Floor) |
517% (object=Food1 & surface=Table) |
518% (object=Food2 & surface=Shelf).
519holds_at(on(Object, Surface), 0) <->
520 ( Object=cat,
521 Surface=floor
522 ; Object=food1,
523 Surface=table
524 ; Object=food2,
525 Surface=shelf
526 ).
527
528%
529%
530% examples/Mueller2006/Chapter11/HungryCat.e:258
531% [surface1,surface2] % HoldsAt(CanJump(surface1,surface2),0) <->
532% (surface1=Floor & surface2=Chair) |
533% (surface1=Chair & surface2=Table) |
534% (surface1=Shelf & surface2=Table).
535holds_at(canJump(Surface1, Surface2), 0) <->
536 ( Surface1=floor,
537 Surface2=chair
538 ; Surface1=chair,
539 Surface2=table
540 ; Surface1=shelf,
541 Surface2=table
542 ).
543
544%
545%
546% examples/Mueller2006/Chapter11/HungryCat.e:263
547% [agent,object,surface]%
548% HoldsAt(Believe(agent,BOn(object,surface)),0) <->
549% (agent=Cat & object=Cat & surface=Floor) |
550% (agent=Cat & object=Food1 & surface=Table).
551holds_at(believe(Agent, bOn(Object, Surface)), 0) <->
552 ( Agent=cat,
553 Object=cat,
554 Surface=floor
555 ; Agent=cat,
556 Object=food1,
557 Surface=table
558 ).
559
560%
561%
562% examples/Mueller2006/Chapter11/HungryCat.e:268
563% [agent,surface1,surface2]%
564% HoldsAt(Believe(agent,BCanJump(surface1,surface2)),0) <->
565% (agent=Cat & surface1=Floor & surface2=Chair) |
566% (agent=Cat & surface1=Chair & surface2=Table) |
567% (agent=Cat & surface1=Shelf & surface2=Table).
568holds_at(believe(Agent, bCanJump(Surface1, Surface2)), 0) <->
569 ( Agent=cat,
570 Surface1=floor,
571 Surface2=chair
572 ; Agent=cat,
573 Surface1=chair,
574 Surface2=table
575 ; Agent=cat,
576 Surface1=shelf,
577 Surface2=table
578 ).
579
584not(holds_at(believe(cat, bSatiated(cat)), 0)).
585
590not(holds_at(satiated(cat), 0)).
591
595completion(happens).
596
600range(time, 0, 7).
601
603range(offset, 1, 1).
604