Personal tools
You are here: Home Projects Prolog University of Warsaw Source code ODRA Prolog interpreter distribution tape. Warsaw University, April 1983. odra.17 warplan warplantest1 warplantest2 warplantest3
Document Actions

odra.17 warplan warplantest1 warplantest2 warplantest3

by Paul McJones last modified 2019-05-20 16:52

WARPLAN - David H. D. Warren's general planner. From: David H. D. Warren. Warplan, A System for Generating Plans, research report, University of Edimburgh, Department of Computational Logic, memo 76, June 1974.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

WARPLAN - WARREN'S GENERAL  PLANNER
PROGRAM POCHODZI Z PRACY: DAWID H D WARREN
WARPLAN - A SYSTEM FOR GENERATING PLANS,
UNIVERSITY OF EDINBURGH DCL MEMO, NO 76, 1974^
DODATKOWY OPIS PROGRAMU ZNAJDUJE SIE W KSIAZCE:
F KLUZNIAK,S SZPAKOWICZ: PROLOG, WNT, W DRUKU^

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *.


-AJOP(".",3,"X'(X'X)")!
-AJOP("&",1,"X'(X'X)")-AJOP("^",2,"(X'X)'X")!

*** GENERATE AND OUTPUT A PLAN ***.

+PLANS(*C,*T) -NOT(CONSISTENT(*C,TRUE)) -/ -LIGNE -SORT(IMPOSSIBLE) -LIGNE.
+PLANS(*C,*T) -PLAN(*C,TRUE,*T,*T1) -LIGNE -OUTPUT(*T1) -LIGNE.

+OUTPUT(*XS^*X) -/ -OUTPUT1(*XS) -SORT(*X) -SORM(" .") -LIGNE.
+OUTPUT(*X) -SORM(" NOTHING NEED BE DONE .") -LIGNE.
+OUTPUT1(*XS^*X) -/ -OUTPUT1(*XS) -SORT(*X) -SORM(" ^ ") -LIGNE.
+OUTPUT1(*X) -SORT(*X) -SORM(" ^ ") -LIGNE.

*** ENTRY POINT TO THE MAIN RECURSIVE LOOP ***.

+PLAN(*X&*C,*P,*T,*T2) -/ -SOLVE(*X,*P,*T,*P1,*T1) -PLAN(*C,*P1,*T1,*T2).
+PLAN(*X,*P,*T,*T1) -SOLVE(*X,*P,*T,*P1,*T1).

*** WAYS OF SOLVING A GOAL ***.

+SOLVE(*X,*P,*T,*P,*T) -ALWAYS(*X).
+SOLVE(*X,*P,*T,*P,*T) -*X.
+SOLVE(*X,*P,*T,*P1,*T) -HOLDS(*X,*T) -AND(*X,*P,*P1).
+SOLVE(*X,*P,*T,*X&*P,*T1) -ADD(*X,*U) -ACHIEVE(*X,*U,*P,*T,*T1).

*** METHODS OF ACHIEVING A GOAL ***.

*BY EXTENSION*.
+ACHIEVE(*X,*U,*P,*T,*T1^*U) -PRESERVES(*U,*P) -CAN(*U,*C)
   -CONSISTENT(*C,*P) -PLAN(*C,*P,*T,*T1) -PRESERVES(*U,*P).
*BY INSERTION*.
+ACHIEVE(*X,*U,*P,*T^*V,*T1^*V) -PRESERVED(*X,*V) -RETRACE(*P,*V,*P1)
   -ACHIEVE(*X,*U,*P1,*T,*T1) -PRESERVED(*X,*V).

*** CHECK WHETHER A FACT HOLDS IN A CERTAIN STATE ***.

+HOLDS(*X,*T^*V) -ADD(*X,*V).
+HOLDS(*X,*T^*V) -/ -PRESERVED(*X,*V) -HOLDS(*X,*T) -PRESERVED(*X,*V).
+HOLDS(*X,*T) -GIVEN(*T,*X).

*** PROVE THAT AN ACTION PRESERVES A FACT ***.

+PRESERVES(*U,*X&*C) -PRESERVED(*X,*U) -PRESERVES(*U,*C).
+PRESERVES(*U,TRUE).

+PRESERVED(*X,*V) -MKGROUND(*X&*V,0,*N) -DEL(*X,*V) -/ -FAIL.
+PRESERVED(*X,*V).

*** RETRACING A GOAL ALREADY ACHIEVED ***.

+RETRACE(*P,*V,*P2) -CAN(*V,*C) -RETRACE1(*P,*V,*C,*P1) -APPEND(*C,*P1,*P2).
+RETRACE1(*X&*P,*V,*C,*P1) -ADD(*Y,*V) -EQUIV(*X,*Y) -/ -RETRACE1(*P,*V,*C,*P1).
+RETRACE1(*X&*P,*V,*C,*P1) -ELEM(*Y,*C) -EQUIV(*X,*Y) -/ -RETRACE1(*P,*V,*C,*P1)
.
+RETRACE1(*X&*P,*V,*C,*X&*P1) -RETRACE1(*P,*V,*C,*P1).
+RETRACE1(TRUE,*V,*C,TRUE).

*** CONSISTENCY WITH A GOAL ALREADY ACHIEVED ***.

+CONSISTENT(*C,*P) -MKGROUND(*C&*P,0,*N) -IMPOSS(*S)
   -NOT(NOT(INTERSECT(*C,*S))) -IMPLIED(*S,*C&*P) -/ -FAIL.
+CONSISTENT(*C,*P).

*** UTILITY ROUTINES ***.

+AND(*X,*P,*P) -ELEM(*Y,*P) -EQUIV(*X,*Y) -/.
+AND(*X,*P,*X&*P).

+APPEND(*X&*C,*P,*X&*P1) -/ -APPEND(*C,*P,*P1).
+APPEND(*X,*P,*X&*P).

+ELEM(*X,*Y&*C) -ELEM(*X,*Y).
+ELEM(*X,*Y&*C) -/ -ELEM(*X,*C).
+ELEM(*X,*X).

+IMPLIED(*S1&*S2,*C) -/ -IMPLIED(*S1,*C) -IMPLIED(*S2,*C).
+IMPLIED(*X,*C) -ELEM(*X,*C).
+IMPLIED(*X,*C) -*X.

+INTERSECT(*S1,*S2) -ELEM(*X,*S1) -ELEM(*X,*S2).
+NOTEQUAL(*X,*Y) -NOT(EQ(*X,*Y)) -NOT(EQ(*X,QQQ(*N1)))
   -NOT(EQ(*Y,QQQ(*N2))).

+EQUIV(*X,*Y) -NOT(NONEQUIV(*X,*Y)).

+NONEQUIV(*X,*Y) -MKGROUND(*X&*Y,0,*N) -EQ(*X,*Y) -/ -FAIL.
+NONEQUIV(*X,*Y).

+EQ(*X,*X).

+NOT(*X) -*X -/ -FAIL.
+NOT(*X).

+MKGROUND(QQQ(*N1),*N1,*N2) -/ -PLUS(*N1,1,*N2).
+MKGROUND(QQQ(*N),*N1,*N1) -/.
+MKGROUND(*X,*N1,*N2) -UNIV(*X,*NAME.*ARGS) -MKGROUNDLIST(*ARGS,*N1,*N2).
+MKGROUNDLIST(*X.*L,*N1,*N3) -MKGROUND(*X,*N1,*N2) -MKGROUNDLIST(*L,*N2,*N3).
+MKGROUNDLIST(NIL,*N,*N).


+DO(*X) -LIGNE -CLOCK -LIGNE -*X -LIGNE -CLOCK -LIGNE -/.
+CLOCK.


-NETT!
-STOP!

* * * * * * * * * * * * * * * * * * * *



WARPLAN - THE STRIPS1 PROBLEM

PATRZ KOMENTARZ W PLIKU WARPLAN


* * * * * * * * * * * * * * * * * * * *.


+ADD(AT(ROBOT,*P),GOTO1(*P,*R)).
+ADD(NEXTTO(ROBOT,*X),GOTO2(*X,*R)).
+ADD(NEXTTO(*X,*Y),PUSHTO(*X,*Y,*R)).
+ADD(NEXTTO(*Y,*X),PUSHTO(*X,*Y,*R)).
+ADD(STATUS(*S,ON),TURNON(*S)).
+ADD(ON(ROBOT,*B),CLIMBON(*B)).
+ADD(ONFLOOR,CLIMBOFF(*B)).
+ADD(INROOM(ROBOT,*R2),GOTHROUGH(*D,*R1,*R2)).

+DEL(AT(*X,*Z),*U) -MOVED(*X,*U).
+DEL(NEXTTO(*Z,ROBOT),*U) -/ -DEL(NEXTTO(ROBOT,*Z),*U).
+DEL(NEXTTO(ROBOT,*X),PUSHTO(*X,*Y,*R)) -/ -FAIL.
+DEL(NEXTTO(ROBOT,*B),CLIMBON(*B)) -/ -FAIL.
+DEL(NEXTTO(ROBOT,*B),CLIMBOFF(*B)) -/ -FAIL.
+DEL(NEXTTO(*X,*Z),*U) -MOVED(*X,*U).
+DEL(NEXTTO(*Z,*X),*U) -MOVED(*X,*U).
+DEL(ON(*X,*Z),*U) -MOVED(*X,*U).
+DEL(ONFLOOR,CLIMBON(*B)).
+DEL(INROOM(ROBOT,*Z),GOTHROUGH(*D,*R1,*R2)).
+DEL(STATUS(*S,*Z),TURNON(*S)).

+MOVED(ROBOT,GOTO1(*P,*R)).
+MOVED(ROBOT,GOTO2(*X,*R)).
+MOVED(ROBOT,PUSHTO(*X,*Y,*R)).
+MOVED(*X,PUSHTO(*X,*Y,*R)).
+MOVED(ROBOT,CLIMBON(*B)).
+MOVED(ROBOT,CLIMBOFF(*B)).
+MOVED(ROBOT,GOTHROUGH(*D,*R1,*R2)).

+CAN(GOTO1(*P,*R),LOCINROOM(*P,*R)&INROOM(ROBOT,*R)&ONFLOOR).
+CAN(GOTO2(*X,*R),INROOM(*X,*R)&INROOM(ROBOT,*R)&ONFLOOR).
+CAN(TURNON(LIGHTSWITCH(*S)),ON(ROBOT,BOX(1))&NEXTTO(BOX(1),LIGHTSWITCH(*S))).
+CAN(PUSHTO(*X,*Y,*R),PUSHABLE(*X)&INROOM(*Y,*R)&INROOM(*X,*R)&
   NEXTTO(ROBOT,*X)&ONFLOOR).
+CAN(GOTHROUGH(*D,*R1,*R2),CONNECTS(*D,*R1,*R2)&INROOM(ROBOT,*R1)
   &NEXTTO(ROBOT,*D)&ONFLOOR).
+CAN(CLIMBOFF(BOX(*B)),ON(ROBOT,BOX(*B))).
+CAN(CLIMBON(BOX(*B)),NEXTTO(ROBOT,BOX(*B))&ONFLOOR).

+ALWAYS(INROOM(*D,*R1)) -ALWAYS(CONNECTS(*D,*R1,*R2)).
+ALWAYS(CONNECTS(*D,*R2,*R1)) -CONNECTS1(*D,*R1,*R2).
+ALWAYS(CONNECTS(*D,*R1,*R2)) -CONNECTS1(*D,*R1,*R2).
+ALWAYS(PUSHABLE(BOX(*N))).
+ALWAYS(LOCINROOM(POINT(*N),ROOM(1))) -RANGE(*N,1,5).
+ALWAYS(LOCINROOM(POINT(6),ROOM(4))).
+ALWAYS(INROOM(LIGHTSWITCH(1),ROOM(1))).
+ALWAYS(AT(LIGHTSWITCH(1),POINT(4))).

+IMPOSS(AT(*X,*Y) & AT(*X,*Z) & NOTEQUAL(*Y,*Z)).

+CONNECTS1(DOOR(*N),ROOM(*N),ROOM(5)) -RANGE(*N,1,4).

+RANGE(*M,*M,*N).
+RANGE(*M,*L,*N) -NOTEQUAL(*L,*N) -PLUS(*L,1,*L1) -RANGE(*M,*L1,*N).


+GIVEN(STRIPS1,AT(BOX(*N),POINT(*N))) -RANGE(*N,1,3).
+GIVEN(STRIPS1,AT(ROBOT,POINT(5))).
+GIVEN(STRIPS1,INROOM(BOX(*N),ROOM(1))) -RANGE(*N,1,3).
+GIVEN(STRIPS1,ONFLOOR).
+GIVEN(STRIPS1,STATUS(LIGHTSWITCH(1),OFF)).
+GIVEN(STRIPS1,INROOM(ROBOT,ROOM(1))).



-DO(PLANS(AT(ROBOT,POINT(5)),STRIPS1))!
-DO(PLANS(AT(ROBOT,POINT(1)) & AT(ROBOT,POINT(2)),STRIPS1))!
-DO(PLANS(AT(ROBOT,POINT(4)),STRIPS1))!
-DO(PLANS(STATUS(LIGHTSWITCH(1),ON),STRIPS1))! **9**.
-DO(PLANS(AT(ROBOT,POINT(6)),STRIPS1))! ***9***.
-DO(PLANS(INROOM(BOX(1),ROOM(1)) & INROOM(BOX(2),ROOM(2))&
   INROOM(BOX(3),ROOM(3)) & AT(ROBOT,POINT(6)),STRIPS1))!
-DO(PLANS(NEXTTO(BOX(1),BOX(2))&NEXTTO(BOX(3),BOX(2)),STRIPS1))!
-STOP!

* * * * * * * * * * * * * * * * * * *


WARPLAN - MACHINE CODE GENERATION

PATRZ KOMENTARZ W PLIKU WARPLAN


* * * * * * * * * * * * * * * * * * * *.

+OUTPUT(*X) -SORT(*X). **ZEBY ODROZNIC ZMIENNE ***.

-AJOP("#",4,"X'(X'X)") -AJOP("IS",4,"X'(X'X)")
   -AJOP("+",5,"(X'X)'X") -AJOP("-",5,"(X'X)'X")
   -AJOP("LOAD",6,"'X") -AJOP("ADD",6,"'X")
   -AJOP("SUBTRACT",6,"'X")  -AJOP("STORE",6,"'X")
   -AJOP("REG",6,"'X")!

+ADD(ACC IS *V1+*V2, ADD *R #*V1+*V2).
+ADD(ACC IS *V1-*V2, SUBTRACT *R #*V1-*V2).
+ADD(ACC IS *V, LOAD *R #*V).
+ADD(REG *R IS *V, STORE *R #*V).

+DEL(ACC IS *Z, *U) -ADD(ACC IS *V, *U).
+DEL(REG *R IS *Z, *U) -ADD(REG *R IS *V, *U).

+CAN(LOAD *R #*V, REG *R IS *V).
+CAN(STORE *R #*V, ACC IS *V).
+CAN(ADD *R #*V1+*V2, REG *R IS *V2 & ACC IS *V1).
+CAN(SUBTRACT *R  #*V1-*V2, REG *R IS *V2 & ACC IS *V1 ).


+GIVEN(INIT,REG 1 IS C1).
+GIVEN(INIT,REG 2 IS C2).
+GIVEN(INIT,REG 3 IS C3).
+GIVEN(INIT,REG 4 IS C4).


-DO(PLANS(ACC IS (C1-C2)+(C3-C4)-(C4-C1),INIT))!
-DO(PLANS(REG 1 IS C1+(C2-C3) & REG 2 IS C2-C3 & REG 3 IS C4+C4, INIT))!*18*.

-DO(PLANS(ACC IS (C1-C2)+(C3-C4),INIT)) !
-DO(PLANS(ACC IS (C1-C2) + (C1 - C2),INIT ))!
-DO(PLANS(REG 2 IS C3,INIT))!
-DO(PLANS(REG 2 IS (C3-C2) + (C1-C2),INIT))!
-STOP!

* * * * * * * * * * * * * * * * * *

WARPLAN - CUBE WORLDS

PATRZ KOMENTARZ W PLIKU WARPLAN


* * * * * * * * * * * * * * * * * *.

+ADD(ON(*U,*W),MOVE(*U,*V,*W)).
+ADD(CLEAR(*V),MOVE(*U,*V,*W)).

+DEL(ON(*U,*Z),MOVE(*U,*V,*W)).
+DEL(CLEAR(*W),MOVE(*U,*V,*W)).

+CAN(MOVE(*U,*V,FLOOR),ON(*U,*V)&NOTEQUAL(*V,FLOOR)&CLEAR(*U)).
+CAN(MOVE(*U,*V,*W),CLEAR(*W)&ON(*U,*V)&NOTEQUAL(*U,*W)&CLEAR(*U)).

+IMPOSS(ON(*X,*Y)&CLEAR(*Y)).
+IMPOSS(ON(*X,*Y)&ON(*X,*Z)&NOTEQUAL(*Y,*Z)).
+IMPOSS(ON(*X,*Z) & ON(*Y,*Z) & NOTEQUAL(*Z,FLOOR) & NOTEQUAL(*X,*Y) ).
+IMPOSS(ON(*X,*X)).


          *****  THREE BLOCKS *****.
+GIVEN(START,ON(A,FLOOR)).
+GIVEN(START,ON(B,FLOOR)).
+GIVEN(START,ON(C,A)).
+GIVEN(START,CLEAR(B)).
+GIVEN(START,CLEAR(C)).


-DO(SORM("POCZATEK PROB"))!
-DO(PLANS(ON(C,A),START))!
-DO(PLANS(ON(C,FLOOR),START))!
-DO(PLANS(ON(A,B)&ON(C,B),START))!
-DO(PLANS(ON(A,B)&ON(B,C),START))!
-DO(PLANS(ON(A,C),START))!

-STOP!
                                                                               
« November 2020 »
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: