Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1.  
  2. /* Precondition Axioms */
  3. poss(open(C),S):-
  4. is_container(C),
  5. isClosed(C,S).
  6.  
  7. poss(close(C),S):-
  8. is_container(C),
  9. not(isClosed(C,S)).
  10.  
  11. poss(fetch(X,Y),S):-
  12. is_container(Y),
  13. inside(X,Y,S),
  14. not isClosed(Y,S).
  15.  
  16. poss(putAway(X,Y),S):-
  17. is_container(Y),
  18. have(X,S),
  19. not(isClosed(Y,S)).
  20.  
  21. poss(loosen(X,Y),S):-
  22. nut(X),
  23. hub(Y),
  24. have(wrench,S),
  25. on(X,Y,S),
  26. tight(X,Y,S),
  27. on(Y,ground,S).
  28.  
  29. poss(tighten(X,Y),S):-
  30. nut(X),
  31. hub(Y),
  32. have(wrench,S),
  33. on(X,Y,S),
  34. not tight(X,Y,S),
  35. on(Y,ground,S).
  36.  
  37. poss(jackUp(Object),S):-
  38. have(jack,S),
  39. not lifted(Object,S),
  40. on(Object,ground,S).
  41.  
  42. poss(jackDown(Object),S):-
  43. lifted(Object,S),
  44. not on(Object,ground,S).
  45.  
  46. poss(remove(N,H),S):-
  47. nut(N),
  48. hub(H),
  49. lifted(H,S),
  50. on(N,H,S),
  51. fastened(H,S),
  52. have(wrench,S),
  53. not(tight(N,H,S)),
  54.  
  55. poss(putOn(N,H),S):-
  56. nut(N),
  57. hub(H),
  58. lifted(H,S),
  59. not fastened(H,S),
  60. have(N,S),
  61. have(wrench,S),
  62. not on(N,H,S).
  63.  
  64. poss(remove(W,H),S):-
  65. wheel(W),
  66. hub(H),
  67. lifted(H,S),
  68. not fastened(H,S),
  69. on(W,H,S).
  70.  
  71. poss(putOn(W,H)):-
  72. wheel(W),
  73. hub(H),
  74. have(W,S),
  75. free(H,S),
  76. lifted(H,S),
  77. not fastened(H,S),
  78. not on(W,H,S).
  79.  
  80. /* Successor State Axioms */
  81.  
  82. inside(Object, Container, [putAway(Object,Container) | S]) :- is_container(Container).
  83. inside(Object, Container, [A | S]) :- inside( Object, Container, S ),
  84. not(A=fetch(Object,Container)).
  85.  
  86. inflated(W, [A | S]) :- wheel(W), inflated(W,S).
  87.  
  88. isClosed(C, [close(C) | S]):- is_container(C).
  89. isClosed(C, [A|S]) :- isClosed(C, S), not A=open(C).
  90.  
  91. have(X, [fetch(X,Y) | S]) :- is_container(Y).
  92. have(X, [remove(X,Y) | S]).
  93.  
  94. have(jack, [jackDown(Object)|S]).
  95. have(jack, [A|S]) :- not (A=jackUp(X)), have(jack,S).
  96. have(X, [A|S]) :- not (A=putAway(X,Y)), have(X,S).
  97.  
  98. tight(N,H, [tighten(N,H) | S]).
  99. tight(N,H, [A | S]) :- tight(N,H,S), not(A=loosen(N,H)).
  100.  
  101. lifted(X, [jackUp(X) | S]).
  102. lifted(X, [A|S]) :- lifted(X,S), not (A=jackDown(X)).
  103.  
  104. on(X,ground, [jackDown(X)|S]).
  105. on(X, ground, [A|S]) :- on(X, ground, S), not A=jackUp(X).
  106.  
  107. on(X,Y, [putOn(X,Y) | S]).
  108. on(X,Y, [A | S]) :- on(X,Y,S), not A=jackDown(X), not A=remove(X,Y).
  109.  
  110. fastened(H, [tighten(N, H) | S]) :- nut(N), hub(H).
  111. fastened(H, [A|S]) :- nut(N), hub(H), not A=loosen(N, H), not A=remove(N,H), fastened(H,S).
  112.  
  113. free(H, [remove(W,H)|S]).
  114. free(H, [A|S]) :- free(H,S), not A=putOn(W,H).
  115.  
  116. /* Declarative Heuristics */
  117.  
  118. useless(close(C), [A | S]) :- A=open(C).
  119. useless(open(C), [A | S]) :- A=close(C).
  120.  
  121. useless(putOn(X, Y), [A | S]) :- A=remove(X,Y).
  122. useless(remove(X,Y), [A | S]) :- A=putOn(X, Y).
  123.  
  124. useless(fetch(X,Y), [A|S]) :- A=putAway(X,Y).
  125. useless(putAway(X,Y), [A|S]) :- A=fetch(X,Y).
  126.  
  127. useless(loosen(X,Y), [A | S]) :- A=tighten(X,Y).
  128. useless(tighten(X,Y), [A|S]) :- A=loosen(X,Y).
  129.  
  130. useless(jackUp(X), [A|S]) :- A=jackDown(X).
  131. useless(jackDown(X), [A|S]) :- A=jackUp(X).
  132. useless(jackUp(X), S) :- member(jackUp(X), S).
  133. useless(jackDown(X), S) :- member(jackDown(X), S).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement