; ======================================================================= ; FILENAME: jabberwock.demo ; DATE: 2007-05-10 ; PROGRAMMER: Paul M. Heider ;; this template version: snepsul-template.demo-20061005.txt ; Lines beginning with a semi-colon are comments. ; Lines beginning with "^" are Lisp commands. ; All other lines are SNePSUL commands. ; ; To use this file: run SNePS; at the SNePS prompt (*), type: ; ; (demo "/home/lingrad/pmheider/courses/CSE727/word/jabberwock.demo" :av) ; (demo "/home/lingrad/pmheider/courses/CSE727/word/jabberwock.demo") ; ; 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) ; 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") ; object/state: a subclass of the object/property ; for (assert object A state B), object A is said to be in the state B where ; state is some non-permanent property currently assigned to A (define state) ; agent/act/action/manner: a subclass of the agent/act/action ; for (assert agent A act (build action B manner C)), C correlates to a ; standard definition of an adverb: A performs B in the manner of C. ;(define manner) ; BACKGROUND KNOWLEDGE: ; ===================== ;; animacy is a property with two possible states: dead or alive ;; any individual of a class who has the proper animate can either ;; be in the state of dead or in the state of alive (and is alive by default) ;;;; ANIMALS ;;;; ;; birds are animals (describe (assert subclass (build lex "bird") = bird superclass (build lex "animal") = animal)) ;; animals are animate (describe (assert object *animal property (build lex "animate") = animate)) ;; Animals have jaws (describe (assert whole *animal part (build lex "jaws"))) ;; Animals have claws (describe (assert whole *animal part (build lex "claws"))) ;; Animals have eyes (describe (assert whole *animal part (build lex "eyes"))) ;; Animals have a head (describe (assert whole *animal part (build lex "head"))) ;; dangerous animals are monsters ;; All P that is a member of the class animal and has the property dangerous ;; is a monster (describe (assert forall $p &ant ((build member *p class *animal) (build object *p property (build lex "dangerous"))) cq (build member *p class (build lex "monster")))) ;; All P that is a member of some subclass of animal and that has the ;; property dangerous is a monster (describe (assert forall ($p $q) &ant ((build member *p class *q) (build subclass *q superclass (build lex "animal")) (build object *p property (build lex "dangerous"))) cq (build member *p class (build lex "monster")))) ; All Q, that have a member which is a monster, is a class of monsters ; (that is, all members of Q are monsters) ;; All Q, that have a member which is a monster, is a subclass of monsters (describe (assert forall ($p $q) &ant ((build member *p class (build lex "monster")) (build member *p class *q)) cq (build subclass *q superclass (build lex "monster")))) ;;;; HUMANS ;;;; ;; humans are animate (describe (assert object (build lex "human") = human property *animate)) ;; For all P and Q, if they share the "son of" relation, they are both human (describe (assert forall ($p $q) ant (build object1 *p rel (build lex "son of") object2 *q) cq ((build member *p class *human) (build member *q class *human)))) ;;;; CLASS INFERENCING ON PATHS ;;;; ;;;; If P should beware some class Q which has a member R, ;;;; then P should also beware R ;;;; (NB the inverse could also be true but was not coded as it did not ;;;; directly apply) (describe (assert forall ($p $q $r) &ant ((build agent *p act (build action (build lex "beware") object *q)) (build member *r class *q)) cq (build agent *p act (build action (build lex "beware") object *r))) = beware-the-X) ;; If Q is an instance of jaws and P has Q and P is a member of R, ;; then R is subclass of animal (describe (assert forall ($p $q $r) &ant (build member *q class (build lex "jaws")) &ant (build whole *p part *q) &ant (build member *p class *r) cq (build subclass *r superclass *animal)) = types-of-animals-have-jaws) ;; For all P that are members of the class Animal, they have Q, a member ;; of jaws (describe (assert forall ($p $q) ant (build member *p class (build lex "animal")) cq ((build whole *p part *q) (build member *q class (build lex "jaws")))) = all-animals-have-jaws) ;; For all P that are members of the class Q which is a subclass of ;; Animal, they have R, a member of jaws (describe (assert forall ($p $q $r) &ant ((build member *p class *q) (build subclass *q superclass (build lex "animal"))) cq ((build whole *p part *r) (build member *r class (build lex "jaws")))) = all-subclasses-of-animals-have-jaws) ;; things that catch are dangerous ;;;; Any agent P which can catch is also dangerous (describe (assert forall $p ant (build agent *p act (build action (build lex "catch"))) cq (build object *p property (build lex "dangerous"))) = catchers-are-dangerous) ;; If some part of you is dangerous, you are dangerous ;;;; For all P with part Q such that Q is dangerous, ;;;; P is, by association, dangerous (describe (assert forall ($p $q) &ant ((build whole *p part *q) (build object *q property (build lex "dangerous"))) cq (build object *p property (build lex "dangerous"))) = you-are-what-youre-made-of) ;; given NPa Va NPb and NPa Va NPc ;; where NPb is of unknown class and NPc is of known class ;; NPb is a type of NPc ;; whiffling is a type of flying ;;;; If P whiffles, P can be said to fly with some whiffly aspect (describe (assert forall $p ant (build agent *p act (build action (build lex "whiffle"))) cq (build agent *p act (build action (build lex "fly") manner (build lex "whifflingly"))))) ;; bad is the enemy of good ;;;; If P is the foe of Q and Q is good, then P is evil (describe (assert forall ($p $q) &ant ((build object1 *p rel (build lex "foe of") object2 *q) (build object *q property (build lex "good"))) cq (build object *p property (build lex "evil"))) = good-fights-evil) ;; The ego should always be a hero ;;;; Any P with the property "main character" is good (describe (assert forall $p ant (build object *p property (build lex "main character")) cq (build object *p property (build lex "good"))) = my-side-is-right) ;; Given P is a member of Q and Q is a subclass of R, Q has the ;; property S if that P and R also already have it ;; Given P is a member of Q and Q is a subclass of R, Q has the ;; part S if P has T, an instance of it, and R has it abstractly ;; Given P is a member of Q and P is a member of R and ;; that R has at least one subclass S, Q is also ;; a subclass of R ; CASSIE READS THE PASSAGE: ; ========================= ;;;;;;;;;;;;;;;;;;;;;;;; STANZA 1 ;;;;;;;;;;;;;;;;;;;;;;;; ; ``Beware the jabberwock, my son! ; The jaws that bite, the claws that catch! ; Beware the Jubjub bird, and shun ; The frumious Bandersnatch!'' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; One should beware the jabberwock. ;;;; Something is called "jabberwock." (describe (add object #TheJabberwock proper-name "TheJabberwock")) ;;;; It is a type of jabberwocky (describe (add member *TheJabberwock class (build lex "JabberwockY") = JabberwockY)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Ask Cassie what "JabberwockY" means: ^(defineNoun "JabberwockY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; The addressee is named George Spelvin (describe (add object #addressee proper-name "George Spelvin")) ;;;; The speaker is named Old Man. (describe (add object #speaker proper-name "Old Man")) ;;;; Addressee is Speaker's son (describe (add object1 *addressee rel (build lex "son of") object2 *speaker)) ;;;; Addressee should beware the jabberwock. (describe (add agent *addressee act (build action (build lex "beware") = beware object *TheJabberwock)) = beware-the-jw) ;; Jaws that bite are what the jabberwock has. ;;;; Something is a type of jaws (describe (add member #jaws class (build lex "jaws") = jaws-lex) = somethings-are-jaws) ;;;; The jabberwock has these. (describe (add whole *TheJabberwock part *jaws) = jw-has-jaws) ;;;; All jaws are used for biting. (describe (add forall $p ant (build member *p class (build lex "jaws")) cq (build agent *p act (build action (build lex "bite")))) = jaws-bite) ;; Claws that catch are what the jabberwock has. ;;;; Something is of the type claws (describe (add member #claws class (build lex "claws") = claws-lex) = somethings-are-claws) ;;;; The jabberwock has these. (describe (add whole *TheJabberwock part *claws) = jw-has-claws) ;;;; Claws are used for catching. (describe (add forall $p ant (build member *p class (build lex "claws")) cq (build agent *p act (build action (build lex "catch")))) = claws-catch) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Ask Cassie what "JabberwockY" means: ^(defineNoun "JabberwockY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; One should beware the Jubjub bird. ;;;; There is a type of bird called Jubjub. (describe (add subclass (build lex "Jubjub bird") = Jubjub superclass *bird)) ;;;; The addressee should beware all Jubjub-birds. (describe (add agent *addressee act (build action (find lex "beware") object *Jubjub))) ;; One should shun the frumious bandersnatch. ;;;; Something is a bandersnatch. ;;;; It is frumious. ;;;; The addressee should shun the bandersnatch. ;;;;;; Skipped because nothing interesting comes of the bandersnatch ;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;; STANZA 2 ;;;;;;;;;;;;;;;;;;;;;;;; ; He took his vorpal sword in hand: ; Long time the manxome foe he sought -- ; So rested he by the Tumtum tree, ; And stood awhile in thought. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The addressee is our main character (describe (add object *addressee property (build lex "main character")) = ego-is-main-character) ;;;; A vorpal sword is an instance of a sword (describe (add member (build lex "vorpal sword") = vorpal-sword class (build lex "sword") = sword)) ;;;;;; "I am afraid I can't explain 'vorpal blade' for you..." ;;;;;; Dodgson's Explanation to Maud Standen ;;;;;; --Letter, December 1877 ;;;;;; http://www76.pair.com/keithlim/jabberwocky/poem/maudstanden.html ;;;; It has the property of being vorpal (describe (add object *vorpal-sword property (build lex "vorpal"))) ;;;; It is the addressee's. (describe (add object *vorpal-sword rel *sword possessor *addressee)) ;; The addressee sought the jabberwock. (describe (add agent *addressee act (build action (build lex "seek") object *TheJabberwock))) ;; The jabberwock was a manxome foe. ;;;; The jabberwock is the foe of the addressee. (describe (add object1 *TheJabberwock rel (build lex "foe of") object2 *addressee) = jw-is-foe-of-ego) ;;;;;;;;;;;;;;;;;;;;;;;; STANZA 3 ;;;;;;;;;;;;;;;;;;;;;;;; ; And, as in uffish thought he stood, ; The jabberwock, with eyes of flame, ; Came whiffling through the tulgey wood, ; And burbled as it came! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The jabberwock had eyes of flame. ;;;; Something is a type of eyes. (describe (add member #eyes class (build lex "eyes") = eyes-lex) = somethings-are-eyes) ;;;; The jabberwock has these. (describe (add whole *TheJabberwock part *eyes) = jw-has-eyes) ;;;; They are made of flame. (describe (add whole *eyes part (build lex "flame") = flame)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Ask Cassie what "JabberwockY" means: ^(defineNoun "JabberwockY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The jabberwock came whiffling. ;;;; The jabberwock whiffled (describe (add agent *TheJabberwock act (build action (build lex "whiffle")))) ;; The jabberwock burbled as it came. ;;;; The jabberwock performed the action burble (describe (add agent *TheJabberwock act (build action (build lex "burble")))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Ask Cassie what "JabberwockY" means: ^(defineNoun "JabberwockY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;; STANZA 4 ;;;;;;;;;;;;;;;;;;;;;;;; ; One, two! One, two! And through and through ; The vorpal blade went snicker-snack! ; He left it dead, and with its head ; He went galumphing back. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The addressee killed the jabberwock with his sword. ;;;; The addressee killed the jabberwock (describe (add agent *addressee act (build action (build lex "kill") object *TheJabberwock)) = Morte-de-Jabberwock) ;;;; The jabberwock is dead. (describe (add object *TheJabberwock state *dead)) ;; The hero went galumphing home with the jabberwock's head. ;;;; Something is a head (describe (add member #head class (build lex "head")) = something-is-a-head) ;;;; The jabberwock has a head. (describe (add whole *TheJabberwock part *head)) ;;;; The addressee took its head. (describe (add agent *addressee act (build action (build lex "take") object *head))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Ask Cassie what "JabberwockY" means: ^(defineNoun "JabberwockY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; The addressee returned home with the head ;; The addressee returned home (describe (add agent *addressee act (build action (build lex "return") object #home))) ;;;;;;;;;;;;;;;;;;;;;;;; STANZA 5 ;;;;;;;;;;;;;;;;;;;;;;;; ; ``And, has thou slain the jabberwock? ; Come to my arms, my beamish boy! ; O frabjous day! Callooh! Callay!'' ; He chortled in his joy. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Killing the jabberwock made the old man happy. ;;;; The death of the jabberwock pleased the old man (describe (add agent *Morte-de-Jabberwock act (build action (build lex "please") object *old-man))) (describe *nodes) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Ask Cassie what "JabberwockY" means: ^(defineNoun "JabberwockY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;