1:-include(library('ec_planner/ec_test_incl')).    2:-expects_dialect(pfc).    3 %  loading(always,'examples/Mueller2006/Chapter12/DefaultLocation.e').
    4%;
    5%; Copyright (c) 2005 IBM Corporation and others.
    6%; All rights reserved. This program and the accompanying materials
    7%; are made available under the terms of the Common Public License v1.0
    8%; which accompanies this distribution, and is available at
    9%; http://www.eclipse.org/legal/cpl-v10.html
   10%;
   11%; Contributors:
   12%; IBM - Initial implementation
   13%;
   14%; @book{Mueller:2006,
   15%;   author = "Erik T. Mueller",
   16%;   year = "2006",
   17%;   title = "Commonsense Reasoning",
   18%;   address = "San Francisco",
   19%;   publisher = "Morgan Kaufmann/Elsevier",
   20%; }
   21%;
   22
   23% load foundations/Root.e
   24
   25% load foundations/EC.e
   26
   27% sort object
   28==> sort(object).
   29
   30% sort agent: object
   31==> subsort(agent,object).
   32
   33% sort device: object
   34==> subsort(device,object).
   35
   36% sort tv: device
   37==> subsort(tv,device).
   38
   39% sort room
   40==> sort(room).
   41
   42% agent Nathan
   43==> t(agent,nathan).
   44
   45% tv TV
   46==> t(tv,tv).
   47
   48% room LivingRoom, Kitchen
   49==> t(room,livingRoom).
   50==> t(room,kitchen).
   51
   52% event TurnOn(agent,device)
   53 %  event(turnOn(agent,device)).
   54==> mpred_prop(turnOn(agent,device),event).
   55==> meta_argtypes(turnOn(agent,device)).
   56
   57% event Walk(agent,room,room)
   58 %  event(walk(agent,room,room)).
   59==> mpred_prop(walk(agent,room,room),event).
   60==> meta_argtypes(walk(agent,room,room)).
   61
   62% fluent InRoom(object,room)
   63 %  fluent(inRoom(object,room)).
   64==> mpred_prop(inRoom(object,room),fluent).
   65==> meta_argtypes(inRoom(object,room)).
   66
   67% fluent On(device)
   68 %  fluent(on(device)).
   69==> mpred_prop(on(device),fluent).
   70==> meta_argtypes(on(device)).
   71
   72% fluent PluggedIn(device)
   73 %  fluent(pluggedIn(device)).
   74==> mpred_prop(pluggedIn(device),fluent).
   75==> meta_argtypes(pluggedIn(device)).
   76
   77% fluent BrokenSwitch(device)
   78 %  fluent(brokenSwitch(device)).
   79==> mpred_prop(brokenSwitch(device),fluent).
   80==> meta_argtypes(brokenSwitch(device)).
   81
   82% predicate Ab1(device,time)
   83 %  predicate(ab1(device,time)).
   84==> mpred_prop(ab1(device,time),predicate).
   85==> meta_argtypes(ab1(device,time)).
   86
   87% predicate Ab2(room,time)
   88 %  predicate(ab2(room,time)).
   89==> mpred_prop(ab2(room,time),predicate).
   90==> meta_argtypes(ab2(room,time)).
   91
   92
   93% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:43
   94%; Sigma
   95% [agent,room1,room2,time]
   96% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:46
   97% Initiates(Walk(agent,room1,room2),InRoom(agent,room2),time).
   98axiom(initiates(walk(Agent, Room1, Room2), inRoom(Agent, Room2), Time),
   99    []).
  100
  101
  102% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:48
  103% [agent,room1,room2,time]
  104% room1!=% room2 ->
  105% Terminates(Walk(agent,room1,room2),InRoom(agent,room1),time).
  106% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:50
  107axiom(terminates(walk(Agent, Room1, Room2), inRoom(Agent, Room1), Time),
  108    [{dif(Room1, Room2)}]).
  109
  110
  111% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:52
  112% [agent,device,time]
  113% !Ab1(device,time) ->
  114% Initiates(TurnOn(agent,device),On(device),time).
  115% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:54
  116axiom(initiates(turnOn(Agent, Device), on(Device), Time),
  117    [not(ab1(Device, Time))]).
  118
  119
  120% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:56
  121%; Delta
  122% [agent,room1,room2,time]
  123% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:59
  124% Happens(Walk(agent,room1,room2),time) ->
  125% room1!=room2 &
  126% HoldsAt(InRoom(agent,room1),time).
  127% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:61
  128axiom(requires(walk(Agent, Room1, Room2), Time),
  129   
  130    [ { dif(Room1, Room2)
  131      },
  132      holds_at(inRoom(Agent, Room1), Time)
  133    ]).
  134
  135
  136% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:63
  137% [agent,device,time]
  138% Happens(TurnOn(agent,device),time) ->
  139% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:65
  140% {room}%  HoldsAt(InRoom(agent,room),time) &
  141%        HoldsAt(InRoom(device,room),time).
  142
  143 /*   exists([Room],
  144             if(happens(turnOn(Agent, Device), Time),
  145                 (holds_at(inRoom(Agent, Room), Time), holds_at(inRoom(Device, Room), Time)))).
  146 */
  147
  148 /*  not(some(Some_Param, '$kolem_Fn_8'(Fn_8_Param, InRoom_Param, Maptime))) :-
  149       happens(turnOn(Fn_8_Param, InRoom_Param), Maptime),
  150       (   not(holds_at(inRoom(Fn_8_Param, Some_Param), Maptime))
  151       ;   not(holds_at(inRoom(InRoom_Param, Some_Param),
  152                        Maptime))
  153       ).
  154 */
  155% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:66
  156axiom(not(some(Some_Param, '$kolem_Fn_8'(Fn_8_Param, InRoom_Param, Maptime))),
  157   
  158    [ not(holds_at(inRoom(Fn_8_Param, Some_Param), Maptime)),
  159      happens(turnOn(Fn_8_Param, InRoom_Param), Maptime)
  160    ]).
  161axiom(not(some(Some_Param, '$kolem_Fn_8'(Fn_8_Param, InRoom_Param, Maptime))),
  162   
  163    [ not(holds_at(inRoom(InRoom_Param, Some_Param), Maptime)),
  164      happens(turnOn(Fn_8_Param, InRoom_Param), Maptime)
  165    ]).
  166
  167 /*  not(happens(turnOn(TurnOn_Param, InRoom_Param11), Maptime9)) :-
  168       (   not(holds_at(inRoom(TurnOn_Param, Some_Param12),
  169                        Maptime9))
  170       ;   not(holds_at(inRoom(InRoom_Param11, Some_Param12),
  171                        Maptime9))
  172       ),
  173       some(Some_Param12,
  174            '$kolem_Fn_8'(TurnOn_Param, InRoom_Param11, Maptime9)).
  175 */
  176axiom(not(happens(turnOn(TurnOn_Param, InRoom_Param11), Maptime9)),
  177   
  178    [ not(holds_at(inRoom(TurnOn_Param, Some_Param12),
  179                   Maptime9)),
  180      some(Some_Param12,
  181           '$kolem_Fn_8'(TurnOn_Param, InRoom_Param11, Maptime9))
  182    ]).
  183axiom(not(happens(turnOn(TurnOn_Param, InRoom_Param11), Maptime9)),
  184   
  185    [ not(holds_at(inRoom(InRoom_Param11, Some_Param12),
  186                   Maptime9)),
  187      some(Some_Param12,
  188           '$kolem_Fn_8'(TurnOn_Param, InRoom_Param11, Maptime9))
  189    ]).
  190
  191 /*  holds_at(inRoom(InRoom_Param14, Some_Param15), Time13) :-
  192       happens(turnOn(InRoom_Param14, TurnOn_Ret), Time13),
  193       some(Some_Param15,
  194            '$kolem_Fn_8'(InRoom_Param14, TurnOn_Ret, Time13)).
  195 */
  196axiom(holds_at(inRoom(InRoom_Param14, Some_Param15), Time13),
  197   
  198    [ happens(turnOn(InRoom_Param14, TurnOn_Ret), Time13),
  199      some(Some_Param15,
  200           '$kolem_Fn_8'(InRoom_Param14, TurnOn_Ret, Time13))
  201    ]).
  202
  203 /*  holds_at(inRoom(InRoom_Param18, Some_Param20), Time17) :-
  204       happens(turnOn(TurnOn_Param19, InRoom_Param18), Time17),
  205       some(Some_Param20,
  206            '$kolem_Fn_8'(TurnOn_Param19, InRoom_Param18, Time17)).
  207 */
  208axiom(holds_at(inRoom(InRoom_Param18, Some_Param20), Time17),
  209   
  210    [ happens(turnOn(TurnOn_Param19, InRoom_Param18), Time17),
  211      some(Some_Param20,
  212           '$kolem_Fn_8'(TurnOn_Param19, InRoom_Param18, Time17))
  213    ]).
  214
  215
  216% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:68
  217% [event1,event2,time]
  218% Happens(event1,time) &
  219% Happens(event2,time) ->
  220% event1=event2.
  221% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:71
  222axiom(Event1=Event2,
  223    [happens(Event1, Time), happens(Event2, Time)]).
  224
  225
  226% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:73
  227%; Theta
  228
  229% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:75
  230% Theta: 
  231next_axiom_uses(theta).
  232 
  233
  234
  235% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:75
  236% [device,time]
  237 % HoldsAt(BrokenSwitch(device),time) -> Ab1(device,time).
  238axiom(ab1(Device, Time),
  239    [holds_at(brokenSwitch(Device), Time)]).
  240
  241% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:76
  242% Theta: 
  243next_axiom_uses(theta).
  244 
  245
  246
  247% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:76
  248% [device,time]
  249 % !HoldsAt(PluggedIn(device),time) -> Ab1(device,time).
  250axiom(ab1(Device, Time),
  251    [not(holds_at(pluggedIn(Device), Time))]).
  252
  253
  254% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:78
  255%; Psi
  256% [object,room1,room2,time]
  257% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:81
  258% HoldsAt(InRoom(object,room1),time) &
  259% HoldsAt(InRoom(object,room2),time) ->
  260% room1=room2.
  261% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:83
  262axiom(Room1=Room2,
  263   
  264    [ holds_at(inRoom(Object, Room1), Time),
  265      holds_at(inRoom(Object, Room2), Time)
  266    ]).
  267
  268
  269% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:85
  270%; Gamma
  271% [tv]
  272 % !HoldsAt(On(tv),0).
  273 %  not(initially(on(Tv))).
  274% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:87
  275axiom(not(initially(on(On_Ret))),
  276    []).
  277
  278
  279% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:88
  280% [tv]
  281 % !HoldsAt(BrokenSwitch(tv),0).
  282 %  not(initially(brokenSwitch(Tv))).
  283axiom(not(initially(brokenSwitch(BrokenSwitch_Ret))),
  284    []).
  285
  286
  287% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:89
  288% [tv]
  289 % HoldsAt(PluggedIn(tv),0).
  290axiom(initially(pluggedIn(Tv)),
  291    []).
  292
  293
  294% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:91
  295% HoldsAt(InRoom(Nathan,Kitchen),0).
  296axiom(initially(inRoom(nathan, kitchen)),
  297    []).
  298
  299
  300% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:93
  301% [time]
  302% !Ab2(LivingRoom,time) ->
  303% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:95
  304% {tv}%  HoldsAt(InRoom(tv,LivingRoom),time).
  305
  306 /*  exists([Tv],
  307          if(not(ab2(livingRoom,Time)),
  308   	  holds_at(inRoom(Tv,livingRoom),Time))).
  309 */
  310
  311 /*  holds_at(inRoom(InRoom_Param, livingRoom), Time3) :-
  312       not(ab2(livingRoom, Time3)),
  313       some(InRoom_Param, '$kolem_Fn_9'(Time3)).
  314 */
  315axiom(holds_at(inRoom(InRoom_Param, livingRoom), Time3),
  316   
  317    [ not(ab2(livingRoom, Time3)),
  318      some(InRoom_Param, '$kolem_Fn_9'(Time3))
  319    ]).
  320
  321 /*  ab2(livingRoom, Time5) :-
  322       not(holds_at(inRoom(InRoom_Param6, livingRoom), Time5)),
  323       some(InRoom_Param6, '$kolem_Fn_9'(Time5)).
  324 */
  325axiom(ab2(livingRoom, Time5),
  326   
  327    [ not(holds_at(inRoom(InRoom_Param6, livingRoom), Time5)),
  328      some(InRoom_Param6, '$kolem_Fn_9'(Time5))
  329    ]).
  330
  331 /*  not(some(Some_Param, '$kolem_Fn_9'(Time7))) :-
  332       not(holds_at(inRoom(Some_Param, livingRoom), Time7)),
  333       not(ab2(livingRoom, Time7)).
  334 */
  335axiom(not(some(Some_Param, '$kolem_Fn_9'(Time7))),
  336   
  337    [ not(holds_at(inRoom(Some_Param, livingRoom), Time7)),
  338      not(ab2(livingRoom, Time7))
  339    ]).
  340
  341
  342% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:97
  343%; goal
  344% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:99
  345% {tv} 
  346
  347
  348% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:99
  349% Happens(TurnOn(Nathan,tv),1).
  350 %  exists([Tv],happens(turnOn(nathan,Tv),1)).
  351
  352 /*  happens(turnOn(nathan, Some_Param), 1) :-
  353       some(Some_Param, '$kolem_Fn_10').
  354 */
  355axiom(happens(turnOn(nathan, Some_Param), start),
  356    [some(Some_Param, '$kolem_Fn_10'), b(t, start), ignore(t+1=start)]).
  357
  358 /*  not(some(Some_Param3, '$kolem_Fn_10')) :-
  359       not(happens(turnOn(nathan, Some_Param3), 1)).
  360 */
  361axiom(not(some(Some_Param3, '$kolem_Fn_10')),
  362   
  363    [ not(happens(turnOn(nathan, Some_Param3), start)),
  364      b(t, start),
  365      ignore(t+1=start)
  366    ]).
  367
  368
  369% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:101
  370%; for two TVs:
  371%;[tv,time] !HoldsAt(InRoom(tv,Kitchen),time).
  372%;[tv,time] {room} HoldsAt(InRoom(tv,room),time).
  373
  374% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:105
  375% completion Theta Ab1
  376% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:106
  377==> completion(theta).
  378==> completion(ab1).
  379
  380% completion Theta Ab2
  381% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:107
  382==> completion(theta).
  383==> completion(ab2).
  384
  385% range time 0 2
  386% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:109
  387==> range(time,0,2).
  388
  389% range offset 1 1
  390% From /opt/logicmoo_workspace/packs_sys/small_adventure_games/prolog/ec_planner/examples/Mueller2006/Chapter12/DefaultLocation.e:110
  391==> range(offset,1,1).
  392%; End of file.