; ======================================================================= ; FILENAME: drenched.demo ; DATE: 7th November 2004 ; PROGRAMMER: Amol Kothari ; 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 "drenched.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: ^(load "/projects/rapaport/CVA/STN2/defun_noun.cl") ; Clear the SNePS network: (resetnet t) ; 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") ; load all pre-defined path definitions: (intext "/projects/rapaport/CVA/mkb3.CVA/paths/paths") ;============================================================================== ; DEFINE THE NEW RELATIONS ;============================================================================== (define subinterval supinterval iobject) ;============================================================================== ; ENTER THE BACKGROUND KNOWLEDGE ;============================================================================== ;---------------------------------------------------------------------------------------------------- ;Rule 1: forall x,y &z : ; ; " if x leaves y then x does not have y " ;---------------------------------------------------------------------------------------------------- (assert forall $X forall $Y forall $Z forall $t1 forall $t2 &ant (build time *t1 event(build act ( build object *Y action (build lex "left") ) agent *X)) &ant (build member *Y class *Z) &ant (build before *t1 after *t2) cq (build min 0 max 0 arg(build time *t2 event (build possessor *X object *Y rel *Z) ) )) ;---------------------------------------------------------------------------------------------------- ;Rule 2: forall x,y,t1,t2 &rainstorm : ; ; " if x does not have an umbrella & there is a rainstorm then x get wet" ;---------------------------------------------------------------------------------------------------- (assert forall $X forall $Y forall $t1 forall $t2 forall $rainstorm &ant (build min 0 max 0 arg (build time *t1 event (build object *Y rel (build lex "umbrella") possessor *X))) &ant ( build subinterval *t1 supinterval *t2 ) &ant ( build time *t2 event *rainstorm ) &ant ( build member *rainstorm class (build lex "rainstorm")) cq ( build agent *X act (build action (build lex "get") object (build lex "wet"))) ) ;--------------------------------------------------------------------------------------------------- ;Rule 3: forall x : ; ; " if x gets wet then x gets upset" ;--------------------------------------------------------------------------------------------------- (assert forall $X &ant ( build act (build object (build lex "wet") action (build lex "get")= get_lex) agent *X ) cq ( build act (build object (build lex "upset")action *get_lex ) agent *X )) ;--------------------------------------------------------------------------------------------------- ;Rule 4: forall x,y &z : ; ; " if x is z's y (obj rel pos) then x is a member of class y " ;--------------------------------------------------------------------------------------------------- (assert forall $X forall $Y forall $Z &ant ( build object *X rel *Y possessor *Z) cq ( build member *X class *Y) ) ;----------------------------------------------------------------------------------------------------- ;Rule 5: forall x,y &z : ; ; " if x gets y at time t & x gets z at the same time t,& z is unknown, then z means y " ;------------------------------------------------------------------------------------------------------ (assert forall $X forall $Y forall $Z &ant (build act (build object *Y action (build lex "get")=get_lex1) agent *X ) &ant (build act (build object *Z action *get_lex1 ) agent *X ) &ant (build object *Y property (build lex "unknown")) cq (build synonym *Y synonym *Z) ) ;========================== ; CASSIE READS THE PASSAGE: ; ========================= ;============================================================================================== ;PASSAGE ; ;" Suda got drenched during the rainstorm becuase she had left her umbrella at her office. " ;============================================================================================== ;------------------------------------------------------------------------------------------------- ; The main passage structure ; ; The Cause and Effect relationship ; Cause is "Suda left her umbrella at her office" ; Effect is " Suda got drenched" ;------------------------------------------------------------------------------------------------- ( add effect (assert agent #Suda act ( build action (build lex "get") object (build lex "drenched")) )= Suda_got_drenched cause (assert time #t4 event (build agent *Suda act (build action (build lex "left") object #Suda_umbrella iobject #Suda_office ) )) ) ;----------------------------------------------------------------------------------------------- ; The Base node Suda has the proper-name Suda ;----------------------------------------------------------------------------------------------- (add object *Suda proper-name "Suda") ;----------------------------------------------------------------------------------------------- ; The object Suda_umbrella is Suda's umbrella ;----------------------------------------------------------------------------------------------- (add object *Suda_umbrella rel (build lex "umbrella") possessor *Suda) ;------------------------------------------------------------------------------------------------ ; The object Suda_office is Suda's office ;------------------------------------------------------------------------------------------------ (add object *Suda_office rel (build lex "office") possessor *Suda) ;----------------------------------------------------------------------------------------------- ; Rainstorm1 is a member of the class of rainstorms ;----------------------------------------------------------------------------------------------- (add member #rainstorm1 class (build lex "rainstorm") ) ;----------------------------------------------------------------------------------------------- ; The event rainstorm1 occurs at time t1 ;----------------------------------------------------------------------------------------------- (add time #t1 event *rainstorm1) ;(show *nodes) ;------------------------------------------------------------------------------------------------ ; t1 is a superinterval of the time interval t2 ;------------------------------------------------------------------------------------------------ (add supinterval *t1 subinterval #t2) ;------------------------------------------------------------------------------------------------ ; The event of Suda getting drenched occurs at time t2 ;------------------------------------------------------------------------------------------------ (add time *t2 event *Suda_got_drenched) ;------------------------------------------------------------------------------------------------ ; time t2 occurs after time t4 ;------------------------------------------------------------------------------------------------ (add before *t4 after *t2) ;------------------------------------------------------------------------------------------------ ; The word drenched has the property of being unknown ;------------------------------------------------------------------------------------------------ (add object (build lex "drenched") property (build lex "unknown") ) ;------------------------------------------------------------------------------------------------ ; Ask Cassie explicitly wether 'drenched' and 'upset' are synonyms ;------------------------------------------------------------------------------------------------ (deduce synonym (build lex "drenched") synonym (build lex "upset")) ; Ask Cassie what "WORD" means: ^(defineNoun "drenched") ;------------------------------------------------------------------------------------------------- ;Display all the nodes ;------------------------------------------------------------------------------------------------- (describe *nodes)