examples/zebra-wam.lisp @ 3325913a9b16

Add `put-void`

Not sure what I was thinking before -- we definitely need this instruction.
author Steve Losh <steve@stevelosh.com>
date Fri, 22 Jul 2016 20:32:51 +0000
parents 1411666a60f8
children (none)
(in-package #:bones.wam)

(reset-database)
(push-logic-frame)

(fact (member ?item (list* ?item ?)))
(rule (member ?item (list* ? ?rest))
  (member ?item ?rest))

(rule (next-to ?x ?y ?list)
  (in-order ?x ?y ?list))

(rule (next-to ?x ?y ?list)
  (in-order ?y ?x ?list))

(fact (in-order ?x ?y (list* ?x ?y ?)))
(rule (in-order ?x ?y (list* ? ?rest))
  (in-order ?x ?y ?rest))

(rule (= ?x ?x))

(rule
    (zebra ?houses ?water-drinker ?zebra-owner)
  ;; Houses are of the form:
  ;; (HOUSE ?country ?pet ?cigarette ?drink ?color)

  (= ?houses
     (list (house norway ? ? ? ?)
           ?
           (house ? ? ? milk ?)
           ?
           ?))

  (member   (house england ?      ?            ?            red   ) ?houses)
  (member   (house spain   dog    ?            ?            ?     ) ?houses)
  (member   (house ?       ?      ?            coffee       green ) ?houses)
  (member   (house ukraine ?      ?            tea          ?     ) ?houses)
  (member   (house ?       snails winston      ?            ?     ) ?houses)
  (member   (house ?       ?      kools        ?            yellow) ?houses)
  (member   (house ?       ?      lucky-strike orange-juice ?     ) ?houses)
  (member   (house japan   ?      parliaments  ?            ?     ) ?houses)
  (in-order (house ?       ?      ?            ?            ivory )
            (house ?       ?      ?            ?            green ) ?houses)
  (next-to  (house ?       ?      chesterfield ?            ?     )
            (house ?       fox    ?            ?            ?     ) ?houses)
  (next-to  (house ?       ?      kools        ?            ?     )
            (house ?       horse  ?            ?            ?     ) ?houses)
  (next-to  (house norway  ?      ?            ?            ?     )
            (house ?       ?      ?            ?            blue  ) ?houses)

  (member (house ?water-drinker ?     ? water ?) ?houses)
  (member (house ?zebra-owner   zebra ? ?     ?) ?houses))

(finalize-logic-frame)

(time (query-all (zebra ?houses ?water ?zebra)))
; (declaim (optimize (speed 3) (safety 0)))