; ======================================================================= ; FILENAME: peramb.demo ; DATE: 2/14/2005 ; PROGRAMMER: Chris Becker ;; this template version: template.demo.2003.11.17.txt ; 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 "peramb.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; ;^(setq snip:*infertrace* nil) ; Load the verb definition algorithm: ^(load "verbalgorithm3.1/defun_verb.cl") ;; load Dmitriy Dligach's show utility ^(load "show.lisp") ; Clear the SNePS network: (resetnet t) ;turn on full forward inferencing: ^(setq snip:*infertrace* nil) ; ;enter the "snip" package: ^(in-package snip) ^(defun broadcast-one-report (rep) (let (anysent) (do.chset (ch *OUTGOING-CHANNELS* anysent) (when (isopen.ch ch) (setq anysent (or (try-to-send-report rep ch) anysent))))) nil) ^(in-package sneps) ; load all pre-defined relations: (intext "rels") ; load all pre-defined path definitions: (intext "paths") ;;---------------------------------------------------------------- ;;---------------------------------------------------------------- (define name) ;;; General inference rules () ;;; Rule #1 ;;---------------------------------------------------------- ;;; Actions performed by the same agent ;;; on the same object are similar ;;---------------------------------------------------------- (describe (assert forall ($A $B $Y $Z) &ant ( (build agent *Y act (build action *A object *Z) ) (build agent *Y act (build action *B object *Z) ) ) cq (build similar *A similar *B) )) ;;; Rule #1 ;;---------------------------------------------------------- ;;; Actions performed on the same class of object are similar ;;; ;;; ;;---------------------------------------------------------- (describe (assert forall ($A $B $C $D $E $F $G $H $X $Y) &ant ( (build subclass *D superclass *H) (build member *B class *E) (build member *C class *F) (build subclass *E superclass *G) (build subclass *F superclass *G) (build agent *X act (build action *A object *B)) (build agent *Y act (build action *D object *C)) ) cq ((build similar *A similar *D) (build similar *A similar *H) ) )) ;;---------------------------------------------------------- ;;; The contexts ;;---------------------------------------------------------- ;;; CONTEXT #1 ;;"In the morning we rose to *perambulate* a city... ;; ...and surveyed the ruins of ancient magnificence..." () ;; The verb "perambulate" is unknown. (add object (build lex "perambulate") = perambulate property (build lex "unknown")) ;; "the morning" is a time (describe (add member (build lex "the morning") = the_morning class (build lex "time") = time)) ;; "a city" is a "city" (describe (add member (build lex "a city") = a_city class (build lex "city") = city)) ;; city is a place (describe (add subclass *city superclass (build lex "place") = place)) ;; "the ruins" are "ruins" (describe (add member (build lex "the ruins") = the_ruins class (build lex "ruins") = ruins)) ;; ruins is a place (describe (add subclass *ruins superclass *place)) ;; the ruins are magnificent (describe (add object *the_ruins property (build lex "magnificence") = magnificence)) ;; the ruin's magnificence is ancient (describe (add mod (build lex "ancient") = ancient head *magnificence )) ;; "we" is a class of persons (describe (add member (build lex "we") = we class (build lex "person") = person)) ;;---------------------------------------------------------- ;; ;; "We surveyed the ruins." (describe (add agent *we act (build action (build lex "survey") = survey object *the_ruins) time *the_morning)) ;; "We perambulated a city" (describe (add agent *we act (build action *perambulate object *a_city) time *the_morning) = we_peramb_city) ;; We rose to [perambulate a city] (describe (add agent *we act (build action (build lex "rose") = rose to *we_peramb_city) time *the_morning) = we_rose_to) ;; "survey" is a subclass of "perceive" (describe (add subclass *survey superclass (build lex "perceive") = perceive)) ;; "rose" is a subclass of "move" (describe (add subclass *rose superclass (build lex "move") = move)) ;; force rule to fire (describe (deduce similar $x similar $y)) ;-------------------- ;; define perambulate ;-------------------- ^(defineVerb 'perambulate) () ;;; CONTEXT #2 ;;; (same agent, same object, different verbs) ;;---------------------------------------------------------- ;;; "We are going to attack a city and destroy it soon" ;; "soon" is a time (describe (add member (build lex "soon") = soon class *time)) ;; "We attack a city" (describe (add agent *we act (build action (build lex "attack") = attack object *a_city) time *soon) = we_attack_city) ;; "We destroy [a city]" (describe (add agent *we act (build action (build lex "destroy") = destroy object *a_city) time *soon) = we_destroy_city) ;; "attack" is a subclass of "activity" (describe (add subclass *attack superclass (build lex "activity") = activity)) ;; "destroy" is a subclass of "unmake" (describe (add subclass *destroy superclass (build lex "unmake") = unmake)) ;; force rule to fire (describe (deduce similar $x similar $y)) ;-------------------- ;; define perambulate ;-------------------- ^(defineVerb 'perambulate) () ;;; CONTEXT #3 ;; (same verb, same agent different object) ;;; "Nightly did the hereditary prince of the land ;;; *perambulate* the streets of his capital, disguised, ;;; well armed, alone, or with a single confidential ;;; attendant." ;; "nightly" is a time (describe (add member (build lex "nightly") = nightly class *time)) ;; "prince" is a person (describe (add member (build lex "prince") = prince class *person)) ;; "streets of the capital" are "streets" (describe (add member (build lex "the [capital] streets") = streets_capital class (build lex "streets") = streets)) ;; "streets" is a place (describe (add subclass *streets superclass *place)) ;; "At night, the prince perambulated the streets of the capital" (describe (add agent *prince act (build action *perambulate object *streets_capital) time *nightly)) ;; force rule to fire (describe (deduce similar $x similar $y)) ;-------------------- ;; define perambulate ;-------------------- ^(defineVerb 'perambulate) () ;;; CONTEXT #4 ;;; same agent class, same object class, different verb ;; [When you walk the streets] you feel either that you ;; are up very early, before any one is awake, or ;; that you are in a boom town from which the boom ;; has departed. ;; "the paris streets" are "streets" (describe (add member (build lex "the [Paris] streets") = the_paris_streets class *streets)) ;; "you walk the streets" (describe (add agent (build lex "you") = you act (build action (build lex "walk") = walk object *the_paris_streets))) ;; "you" is a person (describe (add member *you class *person)) ;; "walk" is a subclass of "move" (describe (add subclass *walk superclass *move)) ;; force rule to fire (describe (deduce similar $x similar $y)) ;-------------------- ;; define perambulate ;-------------------- ^(defineVerb 'perambulate) () ;;; CONTEXT #5 ;; (same agent class, different object, same verb) ;; "Ideas came to her chiefly when she was in motion. She ;; liked to *perambulate* the room with a duster in her ;; hand, with which she stopped to polish the backs of ;; already lustrous books, musing and romancing as she ;; did so." ;; "She (liked to) perambulate the room". (describe (add agent (build lex "her") = her act (build action *perambulate object (build lex "the room") = the_room_a))) = she_peramb_room ;; "she liked to (perambulate the room)". (describe (add agent *her act (build action (build lex "liked") = liked to *she_peramb_room))) ;; "the room" is a "room". (describe (add member *the_room_A class (build lex "room") = room)) ;; "room" is a place. (describe (add subclass *room superclass *place)) ;; "her" is a person. (describe (add member *her class *person)) ;; force rule to fire (describe (deduce similar $x similar $y)) ;-------------------- ;; define perambulate ;-------------------- ^(defineVerb 'perambulate) () ;;; CONTEXT #6 ;; (same agent class, same object class, different verb) ;; "Athena crossed the room to the other bed" (describe (add agent (build lex "Athena") = Athena act (build action (build lex "crossed") = crossed object (build lex "the room") = the_room_B to (build lex "the [other] bed") = other_bed))) ;; "other bed" is a "bed" (describe (add member *other_bed class (build lex "bed") = bed)) ;; "Athena" is a person (describe (add member *Athena class *person)) ;; "the room" is a "room" (describe (add member *the_room_B class *room)) ;; "crossed" is a subclass of "move" (describe (add subclass *crossed superclass *move)) ;; force rule to fire (describe (deduce similar $x similar $y)) ;-------------------- ;; define perambulate ;-------------------- ^(defineVerb 'perambulate) ()