; ======================================================================= ; FILENAME: buildmaker.demo ; DATE: 12-14-03 ; PROGRAMMER: Jonathan Bona ; ; Lines beginning with a semi-colon are comments. ; Lines beginning with "^" are Lisp commands. ; All other lines are SNePS commands. ; ; To use this file: run SNePS; at the SNePS prompt (*), type: ; ; (demo "~/class/663/projects/one/code/maker.demo" :av) ; ; Make sure all necessary files are in the current working directory ; or else use full path names. ; ======================================================================= ; Turn off inference tracing. ; This is optional; if tracing is desired, then delete this. ^(setq snip:*infertrace* nil) ; Load the appropriate definition algorithm: ; first: on cse systems, second: on laptop ^(load "/projects/rapaport/CVA/STN2/defun_noun.cl") ; Clear the SNePS network: (resetnet) ; OPTIONAL: ; UNCOMMENT THE FOLLOWING CODE TO TURN FULL FORWARD INFERENCING ON: ; ;enter the "snip" package: ; ^(in-package snip) ;turn on full forward inferencing: ; ^(defun broadcast-one-report (represent) ; (let (anysent) ; (do.chset (ch *OUTGOING-CHANNELS* anysent) ; (when (isopen.ch ch) ; (setq anysent ; (or (try-to-send-report represent ch) ; anysent))))) ; nil) ;re-enter the "sneps" package: ; ^(in-package sneps) ; load all pre-defined relations: (intext "/projects/rapaport/CVA/STN2/demos/rels") (intext "~jpbona/class/663/projects/one/code/rels") (define instrument ability) ; load all pre-defined path definitions: (intext "/projects/rapaport/CVA/mkb3.CVA/paths/paths") ; BACKGROUND KNOWLEDGE: ; ===================== ;; if an agent knows that they (themselves) have an ability to perform some action directed toward ;; some object and using some instrument, then they have that ability (describe (add forall ($anyone $anyobject $anyaction $anyobject $anyinstrument) ant (build agent *anyone act (build action (build lex "know") object (build agent *anyone ability (build action *anyaction object *anyobject instrument *anyinstrument)))) cq (build agent *anyone ability (build action *anyaction object *anyobject instrument *anyinstrument))) ) ;; if an agent mounts some thing, and the thing is the back of an object, then ;; the agent mounts the object (describe (add forall ($mounter $mountee-back $mountee) &ant ((build agent *mounter act (build action (build lex "mount") object *mountee-back)) (build possessor *mountee rel (build lex "back") object *mountee-back)) cq (build agent *mounter act (build action (build lex "mount") object *mountee))) ) ;; if anything mounts something else, then the first thing rides the second (describe (add forall ($mounter $mountee) ant (build agent *mounter act (build action (build lex "mount") object *mountee)) cq (build agent *mounter act (build action (build lex "ride") object *mountee))) ) ;; if something rides something else, the rider is on the ridee (describe (add forall ($rider $ridee) ant (build agent *rider act (build action (build lex "ride") object *ridee)) cq (build object1 *rider rel (build lex "on") object2 *ridee)) ) ;; something ridden is possibly an animal (describe (add forall ($rider $ridee) ant (build agent *rider act (build action (build lex "ride") object *ridee)) cq (build mode (build lex "possibly") member *ridee class (build lex "animal"))) ) ;; if something1 mounts something2 then something1 is larger than something2 (describe (add forall ($p2 $a2) ant (build agent *p2 act (build action (build lex "mount") object *a2)) cq (build object1 *a2 rel (build lex "larger than") object2 *p2)) ) ;; if x is smaller than y then y is larger than x (describe (add forall ($small $large) ant (build object1 *small rel (build lex "smaller than") object2 *large) cq (build object1 *large rel (build lex "larger than") object2 *small))) ;; if x is larger than y, then y is smaller than x (describe (add forall ($small2 $large2) ant (build object1 *large2 rel (build lex "larger than") object2 *small2) cq (build object1 *small2 rel (build lex "smaller than") object2 *large2)) ) ;; sand is part of the desert (describe (add part (build lex "sand") whole (build lex "desert")) ) ;; humans are animals (describe (add subclass (build lex "human") superclass (build lex "animal")) ) ;; worms are animals (describe (add subclass (build lex "worm") superclass (build lex "animal")) ) ;; worms are elongated and flexible (describe (add forall $w ant (build member *w class (build lex "worm")) cq ((build object *w property (build lex "flexible")) (build object *w property (build lex "elongated")))) ) ;; creatures are animals (describe (add subclass (build lex "creature") superclass (build lex "animal")) ) ;; worms tunnel in the ground (describe (add forall $w100 ant (build member *w100 class (build lex "worm")) cq (build agent *w100 ability (build action (build lex "tunnel") object (build lex "ground")))) ) ;; information about equivalency: ;; if two classes are equivalent, then they are each subclasses of the other (describe (add forall ($c1 $c2) ant (build equiv *c1 equiv *c2) cq ((build subclass *c1 superclass *c2) (build subclass *c2 subclass *c1))) ) ;; if two things are equivalent and one of them is a member ;; of some class, the other is also a member of that class (describe (add forall ($thing1 $class $thing2) &ant ((build member *thing1 class *class) (build equiv *thing1 equiv *thing2)) cq (build member *thing2 class *class)) ) ;; if two things are equivalent and one of them is a subclass ;; of some superclass, then the second thing is also a subclass ;; of the same superclass (describe (add forall ($subclass1 $subclass2 $superclass) &ant((build subclass *subclass1 superclass *superclass) (build equiv *subclass1 equiv *subclass2)) cq (build subclass *subclass2 superclass *superclass))) ;; if any two agents are equivalent, and one of them performs an action, ;; then the other performs that action (describe (add forall ($agent1 $agent2 $action) &ant ((build equiv *agent1 equiv *agent2) (build agent *agent1 ability *action)) cq (build agent *agent2 ability *action)) ) ;; if two objects are equivalent, they share all their properties (describe (add forall ($object1 $object2 $prop) &ant ((build equiv *object1 equiv *object2) ( build object *object1 property *prop)) cq (build object *object2 property *prop)) ) ;; if two objects are equivalent and an agent performs some action on one of them, ;; then the agent performs that action on both of them (describe (add forall ($object1 $object2 $agent1 $action1) &ant ((build equiv *object1 equiv *object2) (build agent *agent1 act (build action *action1 object *object1))) cq (build agent *agent1 act (build action *action1 object *object2))) ) ;; if two objects are equivalent and an agent performs some action on one of them ;; using an instrument, then the agent performs that action on the other of them (describe (add forall ($object1 $object2 $agent1 $action1 $inst) &ant ((build equiv *object1 equiv *object2) (build agent *agent1 act (build action *action1 object *object1 instrument *inst))) cq (build agent *agent1 act (build action *action1 object *object2 instrument *inst))) ) ;; anyone named Paul is (most likely) a male human (describe (add forall $p ant (build object *p proper-name "paul") cq ((build member *p class (build lex "human")) (build member *p class (build lex "male")))) ) ;; if something1 is the interior of something2 ;; then something1 is part of the whole something2 ;; then something1 is inside something2 (describe (add forall ($x $y) ant (build possessor *x rel (build lex "interior") object *y) cq((build part *y whole *x) (build object1 *y rel (build lex "inside") object2 *x))) ) ;; if an agent holds something open, then that thing has the property open (describe (add forall ($thing $agent $object) ant (build agent *agent act (build action (build lex "hold open") object *object)) cq (build object *object property (build lex "open")))) ;; if something1 is a part of something2 ;; and somehting2 is a part of something3 ;; then something1 is a part of something3 (describe (add forall ($part1 $part2 $whole) &ant ((build part *part1 whole *part2) (build part *part2 whole whole)) cq (build part *part1 whole *whole)) ) ;; COMMENTED OUT BECAUSE IT SENDS CASSIE INTO AN INFINITE LOOP ;; if an agent mounts some animal1 using instrument1, and instrument1 ;; performs some action on part of animal2, then animal1 and animal2 ;; are equivalent (they are the same entity) ;(describe ;(add forall ($person $action1 $animal1 $animal2 $part-animal2 $instrument1) ; &ant ((build agent *person ; act (build action (build lex "mount") ; object *animal1 ; instrument *instrument1)) ; (build part *part-animal2 ; whole *animal2) ; (build agent *instrument1 ; act (build action *action1 ; object *part-animal2))) ; cq ( build equiv *animal1 ; equiv *animal2)) ;) ;; if a worm has a ring segment, the ring segment is part of the worm (describe (add forall ($rs $w) &ant ((build possessor *w object *rs rel (build lex "ring segment")) (build member *w class (build lex "worm"))) cq (build part *rs whole *w)) ) ;; if something is the forward edge of something else, ;; then the forward edge is part of the other thing (describe (add forall ($edge $thing) ant (build possessor *thing object *edge rel (build lex "forward edge")) cq (build part *edge whole *thing)) ) ;; if an agent has some ability then the agent ;; possibly acts on that ability (describe (add forall ($agent1 $act1 ) ant (build agent *agent1 ability *act1) cq (build mode (build lex "possibly") agent *agent1 act *act1)) ) ; CASSIE READS THE PASSAGE: ; ========================= ; "With the whip like hook-staffs Paul knew he could mount the maker's ; high curving back. For as long as a forward edge of the worm's ; ring segment was held open by a hook open to admit abrasive sand into ; the more sensitive interior the creature would not retreat beneath the desert." ;;------------------------------------------------------------------------ ; "With the whip like hook-staffs Paul knew he could mount the maker's ; high curving back." ;;------------------------------------------------------------------------ ;; something in the story is named "Paul" (describe (add object #paul proper-name "paul")) ;; something in the story ("the maker") is maker (describe (add member #themaker class (build lex "maker"))) ;; something in the story is a hookstaff (describe (add member #thehook class (build lex "hook staff"))) ;; something is the back of the maker (describe (add object #theback rel (build lex "back") possessor *themaker)) ;; the hook staff(s) is/are "whip like" (describe (add object *thehook property (build lex "whiplike"))) ;; the maker's back is high (describe (add object *theback property (build lex "high"))) ;; the maker's back is curved (describe (add object *theback property (build lex "curved"))) ;; paul knows that he has the ability to mount the back of the maker, ;; using the hook staff as an instrument (describe (add agent *paul act (build action (build lex "know") object (build agent *paul ability (build action (build lex "mount") object *theback instrument *thehook))))) ^(defineNoun "maker") ;;---------------------------------------------------- ;; The worm's ring segment and its forward edge ;; "the worm" is a worm (describe (add member #worm class (build lex "worm"))) ;; there's something that is the worm's ring segment (describe (add possessor *worm object #ring-segment rel (build lex "ring segment"))) ;; there's some forward edge of the ring segment (describe (add possessor *ring-segment object #forward-edge rel (build lex "forward edge"))) ;; the interior of the worm is the worm's interior (describe (add possessor *worm rel (build lex "interior") object #sens-interior)) ;; the interior of the worm is sensitive (more so than the rest of the worm...) (describe (add object *sens-interior property (build lex "sensitive"))) ;; some (a piece of) sand exists (describe (add member #sand class (build lex "sand"))) ;; the piece (portion?) of sand is abrasive (describe (add object *sand property (build lex "abrasive"))) ;; admitting abrasive sand into the worm's sensitive interior (describe (build action (build lex "admit") object *sand location *sens-interior) = admit-sand) ;; "the desert" is a desert (describe (add member #desert class (build lex "desert"))) ;; "the worm" is a creature (describe (add member *worm class (build lex "creature"))) ;; if the hook holds open the forward edge ;; then the forward edge admits the abrasive sand into the sensitive interior ;; then the creature(worm) will not retreat below the desert (describe (add forall () ant (build act (build action (build lex "hold open") object *forward-edge) agent *thehook) cq (build agent *forward-edge act (build action (build lex "admit") object (build object1 *sand rel (build lex "inside") object2 *sens-interior))) cq (build min 0 max 0 agent *worm act (build action (build lex "retreat beneath") object *desert))) ) ;; the hookstaff holds the forward edge of the ring segment open (add agent *thehook act (build action (build lex "hold open") object *forward-edge)) ;; the maker and the worm are equivalent :see section 6.3 (describe (add equiv *themaker equiv *worm)) ; Ask Cassie what "maker" means: ^(defineNoun "maker")