; Lines beginning with a semi-colon are comments.
; Lines beginning with "^" are Lisp commands.
; All other lines are SNePSUL commands.

; =======================================================================
; FILENAME:    myHydrophone-demo
; BASED ON:    HYDROPHONE.demo
; DATE:        6 Jun 07
; PROGRAMMER:  Ahmed Mohammed Hassan, WJR
;
; To use this file: run SNePS; at the SNePS prompt (*), type:
;
; (demo "myHydrophone-demo" :av)
;
; Make sure all necessary files are in the current working directory or else use full path names.
; =======================================================================
; Turn off inference tracing.
^(setq snip:*infertrace* nil)

; Load the noun definition algorithm:
^(load "/projects/rapaport/CVA/STN2/defun_noun.cl")

; Clear the SNePS network:
(resetnet t)

; 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")

; DEFINING RELATIONS
; =====================
;(define object class property member lex)
(define location mod action-mod action-head)
;(define possessor rel agent)
;(define as-obj1 as-obj2 as-property quality equiv proposition)
(define as-obj1 as-obj2 as-property quality proposition)

; BACKGROUND KNOWLEDGE:
; =====================
; Annotated SNePSUL codes of background knowledge
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%       {Prior knowledge representations:}
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

; Voices on the surface are strong and clear to the best degree:
(describe
  (assert forall $x
          &ant (build member *x class (build lex "VOICE"))
          &ant (build object *x location (build lex "SURFACE"))
          cq   (build object *x
		      property ((build lex "STRONG") (build lex "CLEAR"))
                      quality (build lex "MAXIMUM"))))

; If a human is at some location,
; then (the source of) his voice is at that same location:
(describe
  (assert forall ($someone $somewhere $prop)
          &ant (build object *someone location *somewhere)
          &ant (build object *prop possessor *someone rel (build lex "VOICE"))
          cq   (build object *prop location *somewhere)))

; If a human is NOT on the surface, then that human is PROBABLY underwater:
(describe
  (assert
    forall $human
    &ant (build member *human class (build lex "HUMAN"))
    &ant (build min 0 max 0 arg (build object *human location *theSurface))
    cq   (build mod (build lex "PROBABLY")
                proposition (build object *human
                                   location (build lex "UNDERWATER")))))
     
; If x is as p as y,
;    then if x has property p to degree q1 and y has property p to degree q2,
;            then q1 is equivalent to q2:
(describe
  (assert forall ($x $y $p $q1 $q2)
          &ant(build as-obj1 *x as-obj2 *y as-property *p)
          &ant(build object *x property *p quality *q1)
          &ant(build object *y property *p quality *q2)
          cq (build equiv *q1 equiv *q2)))

; The meaning of the act of "{going through}":
; If SOMETHING $x$ goes through $y$ then:
;    $y$ has an entry point $npt$,
;    $y$ has an exit point $xpt$,
;    $x$ enters $npt$, and
;    $x$ leaves $xpt$:
(describe
  (assert
    forall ($x $y $npt $xpt)
    ant (build agent *x act (build object *y action (build lex "THROUGH")))
    cq  (build member (*npt *xpt) class (build lex "THING"))
    cq  (build possessor *y object *npt rel (build lex "ENTRY POINT"))
    cq  (build possessor *y object *xpt rel (build lex "EXIT POINT"))
    cq  (build agent *x act (build object *npt action (build lex "ENTER")))
    cq  (build agent *x act (build object *xpt action (build lex "EXIT")))))

; If a VOICE goes through $y$ then:
;    $y$ is used for talking,
;    $y$ is a physical object 
; In fact, this should be another PK rule that infers that: 
; whatever is used for talking is a device and hence a physical object
(describe
  (assert
    forall ($y)
    ant (build agent (build lex "VOICE")
               act (build object *y action (build lex "THROUGH")))
    cq  (build member *y class (build lex "PHYSICAL OBJECT"))))
;  future modifications:  cq  (build ANYTHING_ELSE...)

; CASSIE READS THE PASSAGE:
; =========================
; Annotated SNePSUL codes of the passage
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%       {SNePS Text representations:}
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; There is a human who has voice:
; "his voice  ... "
; Someone is human:
(describe (add member #theHero class (build lex "HUMAN")))

; Something is a voice:
(describe (add member #theVoice class (build lex "VOICE")))

; The human has that voice:
(describe (add object *theVoice possessor *theHero rel (build lex "VOICE")))

; The human voice crackled briskly through the hydrophone:
; " ...  voice crackled briskly through the hydrophone  ... "
; Something is hydrophone:
(describe (add member #theWord class (build lex "HYDROPHONE")))

; The human voice did the actions: "crackled briskly"  ... :
(describe
  (add agent *theVoice
       act (build object *theWord
                  action (build lex "CRACKLE BRISKLY"))))

; ... and also went "through" that hydrophone:
(describe
  (add agent *theVoice
       act (build object *theWord action (build lex "THROUGH"))))

; The output voice is as strong and clear as the input voice on the surface:
; "his voice crackled...AS strong and clear AS IF he had been on the surface"
; Something is surface:
(describe (add member #theSurface class (build lex "SURFACE")))

; IT IS NOT THE CASE THAT the human has been on the surface:
(describe (add min 0 max 0 arg (build object *theHero location *theSurface)))

; Something is a voice  ... :
(describe (add member #aSurVoice class (build lex "VOICE")))

;  ...  on the surface:
(describe (add object *aSurVoice location (build lex "SURFACE")))   

; The voice is AS strong (AND) clear AS that voice on surface:
(describe
  (add as-obj1 *theVoice
       as-obj2 *aSurVoice
       as-property ((build lex "STRONG")(build lex "CLEAR")))

         
; ==================================================
; Ask Cassie what "HYDROPHONE" means:
^(defineNoun "HYDROPHONE")
