;

;? (predictions 10000 0.20 0.39 0.3 0.25 5)
;((0.1165 0.0381 0.0469 0.6285) (0.1007 0.015325 0.021183333333333332 0.026475 0.605) (0.1849 0.01275 0.015516666666666666 0.020725 0.5881))

(defvar *sentence*) (defvar *goal*) (defvar *hold*) (defvar *retrieval*)
(defvar sent1) (defvar sent2) (defvar sent3)(defvar sent4)
(defvar *response*)
(defvar *assoc*)
(defvar *vars*)
(defvar *high*)
(defvar *low*)
(defvar *study*)
(defvar *test*)
(defvar *yes*)
(defvar *no*)
(setf *vars* nil)
(setf *assoc* nil)
(defvar *plaus*)
(defvar *read*)
(setf *read* 0.1)
(setf *plaus* nil)
(defparameter *intercept* 0.6)
(setf *no* .35)
(setf *yes* .22)
(defvar *mismatch*)
(setf *mismatch* .1)
(defvar *encoding*)
(setf *encoding* 0.2)
(defvar *snoise*)
(setf *snoise* .25)
(defvar *factor*)
(setf *factor* 0.30)
(defvar *number*)
(defvar *time-role*)
(defvar *flail*)
(setf *flail* .8)
(setf  *retrieval* t)

(defparameter *rt* 0.3)
(defparameter *activation* 0.25)
(defparameter *p1* .20)
(defparameter *p2* .39)
(defparameter *runs* 50)

(defparameter *text* t)
(defparameter *graphic* nil)
(defparameter *v* nil)
(defparameter *overlay* nil)


(defvar *data-a72* '((0.119579946	0.037714544	0.041779584	0.641937669)
                     (0.098571429	0.02047619	0.014126984	0.024166667	0.638095238)
                     (0.177941176	0.025980392	0.01625817	0.023284314	0.52745098)))

(defvar *WWW-interface*)                
(setf  *WWW-interface* 
      '((:heading "Anderson 1972" 2)
        (:table)
        
        (:table)
        "Probability of finding a referent (exp. 1 & 2), R: " (:string :sy *p1*  .20)   (:new-row)
        "Probability of finding a referent (exp. 3), R: "     (:string :sy *p2*  .39)   (:new-row)
        "Retrieval threshold: "                               (:string :sy *rt*  .30)  (:new-row)
        "Activation: "                                        (:string :sy *activation*  .25)     (:new-row)
        "Activation noise, s: "                               (:string :sy *snoise* .2)     (:new-row)
        "Number of runs (50 - 1000): "                        (:string :sy *runs* 50)     (:new-row)
        (:table-end)
        
        (:table)
        (:checkbox "Trace" :sy *v*  nil)  (:new-row)
        (:checkbox "Text output" :sy *text*  t) (:new-row)
        (:checkbox "Graphic output" :sy *graphic*  nil) (:new-row)
        (:checkbox "Show both simulation and experiment data" :sy *overlay*  nil) 
        (:table-end)
        
        (:table-end)
         
                
        
        (:new-para)
        
        (:button "Show Experimental Results" "(display-a72 nil *data-a72*)")
        
        (:new-para)
        
        (:button "Run model" "(if (and (numberp *p1*) (numberp *p2*)
                                       (numberp *rt*) (numberp *activation*)
                                       (numberp *runs*) (numberp *snoise*)
                                       )
                                   (display-a72  (predictions (min 1000 (max *runs* 50)) *p1* *p2* *rt* *activation* 5) *data-a72*)
                                   
                                   (format *standard-output* \"All parameters must be numbers~%\"))")
        (:reset "Default values")
        (:button "Production Rules" "(let ((prods (no-output (pp))))
                                       (dolist (x prods)
                                         (pp-fct (list x))
                                         (spp-fct (list x))
                                         (format *standard-output* \"~%\")))")
        (:button "Chunk types" "(chunk-type)")
        (:button "Chunks" "(dm)")
        (:new-para)
         "TIME and SIZE:"
        (:new-para)
        "- It usually takes about 1 minute for 50 runs of the model"
        (:new-line)
        "- The trace of 50 runs is approximatly 64K bytes (40 pages) in size"
        (:new-para)))


(defun display-a72 (model exp)
  (when model 
    (format *standard-output* "~%~%Parameters for run: (~S ~S ~S ~S ~S ~s)~%" 
            *p1* *p2* *rt* *activation* *snoise* (min 1000 (max *runs* 50))))

  (when *text*
    (let ((count ))
      (when model
        (format *standard-output* "~%ACT-R Proportions of recall~%")
        (dotimes (i 3)
          (format *standard-output* "Experiment ~s~%Number Recalled      Proportion~%" (1+ i))
          (setf count 0)
          (dolist (j (nth i model))
            (format *standard-output* " ~s                     ~4,3f~%" (1- (- (length (nth i model)) count))
                    j)
            (incf count)
            )))
      (when (or (null model) *overlay*)
        (setf count 1)
        (format *standard-output* "~%Experimental Proportions of recall~%")
        (dotimes (i 3)
          (format *standard-output* "Experiment ~s~%Number Recalled      Proportion~%" (1+ i))
          (setf count 0)
          (dolist (j (nth i exp))
            (format *standard-output* " ~s                     ~4,3f~%" (1- (- (length (nth i exp)) count))
                    j)
            (incf count))))
      
      (unless *graphic* (format *standard-output* 
                                "~%</pre>If your browser supports JAVA, you 
                               can display the data in a graph by checking 
                               the Graphic output box on the interface page.<pre>~%~%"))))
  (when *graphic*
    (format *standard-output* " 
        <applet 
        code = \"DansGraphs.class\" 
        width = 600 
        height = 500> 
        <PARAM name=\"title\" value=\"Anderson 1972\">
        <PARAM name=\"xmin\" value=\"0\">
        <PARAM name=\"xmax\" value=\"6\">
        <PARAM name=\"ymax\" value=\"0.70\">
        <PARAM name=\"ymin\" value=\"0.00\">
        <PARAM name=\"numxlabels\" value=\"7\">
        <PARAM name=\"xlabels\" value=\" ;4;3;2;1;0; ;\">
        <PARAM name=\"widestxlabel\" value=\"W\">
        <PARAM name=\"longestline\" value=\"5\">
        <PARAM name=\"numlines\" value=\"~s\">
        <PARAM name=\"yspacing\" value=\".05\">
        <PARAM name=\"ydiv\" value=\".025\">
        <PARAM name=\"xname\" value=\"Number of words recalled\">
        <PARAM name=\"yname\" value=\"Proportion\">
        <PARAM name=\"lcolor0\" value=\"0\">
        <PARAM name=\"lstyle0\" value=\"~s\">
        <PARAM name=\"xval0\" value=\"2;3;4;5;\">
        <PARAM name=\"lcolor1\" value=\"1\">
        <PARAM name=\"lstyle1\" value=\"~s\">
        <PARAM name=\"xval1\" value=\"1;2;3;4;5;\">
        <PARAM name=\"lcolor2\" value=\"2\">
        <PARAM name=\"lstyle2\" value=\"~s\">
        <PARAM name=\"xval2\" value=\"1;2;3;4;5;\">
        <PARAM name=\"yval0\" value=\"~4,3f;~4,3f;~4,3f;~4,3f;\">
        <PARAM name=\"yval1\" value=\"~4,3f;~4,3f;~4,3f;~4,3f;~4,3f;\">
        <PARAM name=\"yval2\" value=\"~4,3f;~4,3f;~4,3f;~4,3f;~4,3f;\">
        <PARAM name=\"name0\" value=\"~a Experiment 1\">
        <PARAM name=\"name1\" value=\"~a Experiment 2\">
        <PARAM name=\"name2\" value=\"~a Experiment 3\">
       "
        

            (if (and model *overlay*) 6 3)
            
            (if model 2 8737)
            (if model 2 8737)
            (if model 2 8737)
            
            (nth 0 (nth 0 (if model model exp)))
            (nth 1 (nth 0 (if model model exp)))
            (nth 2 (nth 0 (if model model exp)))
            (nth 3 (nth 0 (if model model exp)))
            (nth 0 (nth 1 (if model model exp)))
            (nth 1 (nth 1 (if model model exp)))
            (nth 2 (nth 1 (if model model exp)))
            (nth 3 (nth 1 (if model model exp)))
            (nth 4 (nth 1 (if model model exp)))
            (nth 0 (nth 2 (if model model exp)))
            (nth 1 (nth 2 (if model model exp)))
            (nth 2 (nth 2 (if model model exp)))
            (nth 3 (nth 2 (if model model exp)))
            (nth 4 (nth 2 (if model model exp)))
            
            (if model "ACT-R" " ")
            (if model "ACT-R" " ")
            (if model "ACT-R" " "))


    (when (and model *overlay*)
      (format *standard-output*
              "<PARAM name=\"lcolor3\" value=\"0\">
               <PARAM name=\"lstyle3\" value=\"2185\">
               <PARAM name=\"xval3\" value=\"2;3;4;5;\">
               <PARAM name=\"lcolor4\" value=\"1\">
               <PARAM name=\"lstyle4\" value=\"2185\">
               <PARAM name=\"xval4\" value=\"1;2;3;4;5;\">
               <PARAM name=\"lcolor5\" value=\"2\">
               <PARAM name=\"lstyle5\" value=\"2185\">
               <PARAM name=\"xval5\" value=\"1;2;3;4;5;\">
               <PARAM name=\"yval3\" value=\"~4,3f;~4,3f;~4,3f;~4,3f;\">
               <PARAM name=\"yval4\" value=\"~4,3f;~4,3f;~4,3f;~4,3f;~4,3f;\">
               <PARAM name=\"yval5\" value=\"~4,3f;~4,3f;~4,3f;~4,3f;~4,3f;\">
               <PARAM name=\"name3\" value=\"Experiment 1\">
               <PARAM name=\"name4\" value=\"Experiment 2\">
               <PARAM name=\"name5\" value=\"Experiment 3\">
         "
              (nth 0 (nth 0 exp))
              (nth 1 (nth 0 exp))
              (nth 2 (nth 0 exp))
              (nth 3 (nth 0 exp))
              (nth 0 (nth 1 exp))
              (nth 1 (nth 1 exp))
              (nth 2 (nth 1 exp))
              (nth 3 (nth 1 exp))
              (nth 4 (nth 1 exp))
              (nth 0 (nth 2 exp))
              (nth 1 (nth 2 exp))
              (nth 2 (nth 2 exp))
              (nth 3 (nth 2 exp))
              (nth 4 (nth 2 exp))
              ))
    
    (format *standard-output* "
             <HR> Either your browser does not support JAVA or this graph has scrolled off the top of the display.~%
             </HR></applet>")))
               
;General functions
(defun read-word () 
   (eval `(mod-chunk ,*goal* word ,(or (pop *sentence*) 'eos))))

 (defun get-activation (item)
(caar (no-output (eval `(sdp ,item :activation)))))

(defun comprehend-sentence (sent)
         (setf *goal* 'goal)
         (mod-chunk goal word nil type nil link nil link-type nil
                      task Comprehend past nil meaning nil)
         (setf *sentence* sent)
         (setf *hold* *sentence*)
         (goal-focus goal)
         (run))

(defun average (lis &optional (n 1))
  (list (if lis (/ (apply '+ lis) (length lis)) nil)
        (/ (length lis) (* 1.0 n))))

(defun uniform-ias (val)
  (do ((temp (no-output (eval `(sdm context experiment))) (cdr temp)))
      ((null temp) nil)
      (set-ia-fct (list (list (chunk-slot-value-fct (car temp) 'child)
                          (car temp) val)
                        (list (chunk-slot-value-fct (car temp) 'parent)
                          (car temp) val)
                        (list (chunk-slot-value-fct (car temp) 'context)
                          (car temp) val)
                        (list (chunk-slot-value-fct (car temp) 'role)
                          (car temp) val)))))


(defun reset-sent () (setf *sentence* *hold*))

(defun encode-script (name script variable)
  (setf *vars* (cons variable *vars*))
  (setf *assoc* (cons (list variable variable) *assoc*))
  (eval `(add-dm (,name isa chunk) (,variable isa chunk)))
  (mapcar #'(lambda (x) (encode-triple x name)) script))

(defun encode-triple (triple context)
  (let* ((agent (encode-it (car triple) 'noun))
        (relation (encode-it (cadr triple) 'verb))
        (object (encode-it (caddr triple) 'noun))
        (proposition (gentemp "PROP"))
        (semantic-chunks
    (eval `(add-dm (,proposition isa proposition context ,context)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,agent parent ,proposition
                    role agent referent ,context)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,relation parent ,proposition
                    role relation referent ,context)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,object parent ,proposition
                    role object referent ,context)))))
    (eval `(set-ia (,agent ,proposition 10) (,relation ,proposition 10)
                   (,object ,proposition 10)))))


(defun encode-it (word type)
  (cond ((assoc word *assoc*) (second (assoc word *assoc*)))
        (t
  (let ((idea (gentemp (string word))))
    (setf *assoc* (cons (list word idea) *assoc*))
    (eval `(add-dm (,word isa chunk)
            (,idea isa chunk)
            (,(gentemp "LEX") isa lex-entry type ,type word ,word meaning ,idea)))
    idea))))

;to derive predictions for Anderson (1972)
(defun encode-4tuple (fourtuple prob strength1)
  (reset) 
  (let* ((agent (encode-it (car fourtuple) 'noun))
        (relation (encode-it (cadr fourtuple) 'verb))
        (object (encode-it (caddr fourtuple) 'noun))
        (location (encode-it (cadddr fourtuple) 'noun))
        (proposition (gentemp "PROP"))
   (roles (eval `(add-dm (,proposition isa proposition)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,agent parent ,proposition
                    role agent context experiment)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,relation parent ,proposition
                    role relation context experiment)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,object parent ,proposition
                    role object context experiment)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,location parent ,proposition
                    role location context experiment))))
   (mra (second roles))
   (mrr (third roles))
   (mro (fourth roles))
   (mrl (fifth roles)))
  (eval `(no-output (sdp ,mra :base-level ,strength1) 
                    (sdp ,mrr :base-level ,strength1)
                   (sdp ,mro :base-level ,strength1) 
                   (sdp ,mrl :base-level ,strength1)))
  (cond ((< (random 1.0) prob) 
           (eval `(mod-chunk ,mra referent hair))
           (eval `(mod-chunk ,mrr referent hair))
           (eval `(mod-chunk ,mro referent hair))
           (eval `(mod-chunk ,mrl referent hair))))
    proposition))

(defun do-recall-4 (prob rt strength1 strength2 flag)
(let (result)
  (encode-4tuple '(hippie touched debutante park) prob strength1)
  (mod-chunk goal prompt hippie) (goal-focus goal) 
  (eval `(sgp :v ,*v* :rt ,rt))
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
  (encode-4tuple '(hippie touched debutante park) prob strength1)
 (mod-chunk goal prompt touched) (goal-focus goal)
  (eval `(sgp :v ,*v* :rt ,rt))
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
  (encode-4tuple '(hippie touched debutante park) prob strength1)
  (mod-chunk goal prompt debutante) (goal-focus goal)
  (eval `(sgp :v ,*v* :rt ,rt))
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
  (encode-4tuple '(hippie touched debutante park) prob strength1)
  (mod-chunk goal prompt park) (goal-focus goal) 
  (eval `(sgp :v ,*v* :rt ,rt))
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
))

(defun distribution-4 (n flag prob rt strength1 strength2)
  (do ((count 0 (1+ count))
       (result (list 0 0 0 0) 
               (update-result result (do-recall-4 prob rt strength1 strength2 flag))))
      ((equal count n) result)))

(defun encode-5tuple (fourtuple prob strength1)
  (reset)
  (let* ((agent (encode-it (car fourtuple) 'noun))
        (relation (encode-it (cadr fourtuple) 'verb))
        (object (encode-it (caddr fourtuple) 'noun))
        (location (encode-it (cadddr fourtuple) 'noun))
        (time (encode-it (fifth fourtuple) 'noun))
        (proposition (gentemp "PROP"))
   (roles (eval `(add-dm (,proposition isa proposition)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,agent parent ,proposition
                    role agent context experiment)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,relation parent ,proposition
                    role relation context experiment)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,object parent ,proposition
                    role object context experiment)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,location parent ,proposition
                    role location context experiment)
                   (,(gentemp "Semantic-chunk") isa semantic-chunk child ,time parent ,proposition
                    role time context experiment))))
   (mra (second roles))
   (mrr (third roles))
   (mro (fourth roles))
   (mrl (fifth roles))
   (mrt (sixth roles)))
  (eval `(no-output (sdp ,mra :base-level ,strength1) 
                    (sdp ,mrr :base-level ,strength1)
                   (sdp ,mro :base-level ,strength1) 
                   (sdp ,mrl :base-level ,strength1)
                   (sdp ,mrt :base-level ,strength1)))
  (cond ((< (random 1.0) prob) 
           (eval `(mod-chunk ,mra referent hair))
           (eval `(mod-chunk ,mrr referent hair))
           (eval `(mod-chunk ,mro referent hair))
           (eval `(mod-chunk ,mrl referent hair))
          (eval `(mod-chunk ,mrt referent hair))))
    proposition))

(defun do-recall-5 (prob rt strength1 strength2 flag)
(let (result)
  (encode-5tuple '(hippie touched debutante park friday) prob strength1)
  (mod-chunk goal prompt hippie) (goal-focus goal) 
  (eval `(sgp :v ,*v* :rt ,rt)) (setf *time-role* t)
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)
                   (sdp role5 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
  (encode-5tuple '(hippie touched debutante park friday) prob strength1)
 (mod-chunk goal prompt touched) (goal-focus goal)
  (eval `(sgp :v ,*v* :rt ,rt))(setf *time-role* t)
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)
                   (sdp role5 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
  (encode-5tuple '(hippie touched debutante park friday) prob strength1)
  (mod-chunk goal prompt debutante) (goal-focus goal)
  (eval `(sgp :v ,*v* :rt ,rt))(setf *time-role* t)
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)
                   (sdp role5 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
  (encode-5tuple '(hippie touched debutante park friday) prob strength1)
  (mod-chunk goal prompt park) (goal-focus goal) 
  (eval `(sgp :v ,*v* :rt ,rt))(setf *time-role* t)
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)
                   (sdp role5 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
  (encode-5tuple '(hippie touched debutante park friday) prob strength1)
  (mod-chunk goal prompt friday) (goal-focus goal) 
  (eval `(sgp :v ,*v* :rt ,rt))(setf *time-role* t)
  (eval `(no-output (sdp role1 :base-level ,strength2) 
                    (sdp role2 :base-level ,strength2)
                   (sdp role3 :base-level ,strength2) 
                   (sdp role4 :base-level ,strength2)
                   (sdp role5 :base-level ,strength2)))
  (run)
  (setf result (cons *number* result))
))

(defun distribution-5 (n flag prob rt strength1 strength2)
  (do ((count 0 (1+ count))
       (result (list 0 0 0 0 0) 
               (update-result result (do-recall-5 prob rt strength1 strength2 flag))))
      ((equal count n) result)))

(defun update-result (result lis)
  (do ((temp lis (cdr temp)))
      ((null temp) result)
    (rplaca (nthcdr (car temp) result) (1+ (nth (car temp) result)))))

(defun predictions (n prob1 prob2 rt strength1 strength2)
  (let* ((n5 (round (/ n 5)))
        (n4 (round (/ n 4)))
        (l5 (mapcar '* '(1 4 6 4 1) (make-list 5 :initial-element (* n5 5.0))))
        (l4 (mapcar '* '(1 3 3 1) (make-list 4 :initial-element (* n4 4.0)))))
    (list 
     (mapcar '/ (reverse (distribution-4 n4 nil  prob1  rt strength1
                                         strength2)) l4)
     (mapcar '/ (reverse (distribution-5 n5 nil prob1  rt strength1 
                                         strength2)) l5)
     (mapcar '/ (reverse (distribution-5 n5 nil prob2  rt strength1
                                         strength2)) l5))))
   
  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; The ACT-R model
(clearall)
(setf *assoc* '((hippie *hippie*) (touched *touch*) (debutante *debutante*) (park *park*)
                (ate *eat*) (consumed *eat*)(friday *friday*)))

(eval `(sgp :era t :lf 0.3 :rt 0.2 :ans .2 :ga 0))

(chunk-type parse word type link link-type task past meaning)
(chunk-type proposition context)
(chunk-type match-props agent relation object context referent check response)
(chunk-type struct)
(chunk-type lex-entry word type meaning)
(chunk-type semantic-chunk child parent role referent context)
(chunk-type syntactic-chunk child parent role referent context)
(chunk-type respond response parent)
(chunk-type response opposite)
(chunk-type associate proposition agent relation object)
(chunk-type find-referent meaning agent relation object)
(chunk-type match-up struct response state struct-test word)
(chunk-type recall prompt prompt-role recall-role proposition)

(add-dm (goal isa recall)(retrieve isa chunk)
        (the-mouse isa chunk) (the-cat isa chunk) (switch isa chunk)
        (goal1 isa match-up response yes state start) (args isa chunk)
        (subject isa chunk) (role isa chunk) (start isa chunk)
        (bob isa chunk) (*bob* isa chunk) (bobby isa chunk) (again isa chunk)
        (dan-n isa lex-entry type noun word dan meaning *dan*)
        (danny-n isa lex-entry type noun word danny meaning *dan*)
        (dan isa chunk) (*dan* isa chunk) (danny isa chunk)
        (bob-n isa lex-entry type noun word bob meaning *bob*)
        (bobby-n isa lex-entry type noun word bobby meaning *bob*)
        (tom isa chunk) (*tom* isa chunk) (tommy isa chunk)
        (tom-n isa lex-entry type noun word tom meaning *tom*)
        (tommy-n isa lex-entry type noun word tommy meaning *tom*)
        (the-det isa lex-entry type det word the) (null isa chunk)
        (the-cat-n isa lex-entry type noun word the-cat meaning *cat*)
        (chased-v isa lex-entry type verb word chased meaning *chase*)
        (petted-v isa lex-entry type verb word petted meaning *pet*)
        (petted isa chunk) (*pet* isa chunk) (plaus isa chunk)
        (eat-v isa lex-entry type verb word ate meaning *eat*)
        (consume-v Isa lex-entry type verb word consumed meaning *eat*)
        (ate isa chunk)(consumed isa chunk) (*eat* isa chunk)
        (the-mouse-n isa lex-entry type noun word the-mouse meaning *mouse*)
        (by-prep isa lex-entry type prep word by) (comprehend isa chunk)
        (prep isa chunk) (by isa chunk) (pp isa chunk) (recognize isa chunk)
        (first-np isa chunk) (form isa chunk) (noun-match isa chunk)
        (yes isa response opposite no) (no isa response opposite yes)
        (*cat* isa chunk) (*chase* isa chunk) (*mouse* isa chunk)
        (was-aux isa lex-entry type aux word was) (subj-test isa chunk)
        (was isa chunk) (aux isa chunk) (needs-subj isa chunk)
        (mouse isa chunk) (eos isa chunk) (done isa chunk) (experiment isa chunk)
        (np isa chunk) (vp isa chunk) (sent isa chunk) (agent isa chunk) (object isa chunk)
        (relation isa chunk) (arg1 isa chunk) (arg2 isa chunk)
        (chased isa chunk) (verb isa chunk) (aux-test isa chunk)(vp1 isa chunk)
        (cat isa chunk) (noun isa chunk)(head isa chunk)
        (det isa chunk)(the isa chunk) (sentence1 isa chunk)
        (location isa chunk) (time isa chunk) (word isa chunk))

(add-dm  (hair isa chunk)
        (role1 isa semantic-chunk child *hippie* parent hair role agent)
        (role2 isa semantic-chunk child *debutante* parent hair role object)
        (role3 isa semantic-chunk child *touch* parent hair role relation)
        (role4 isa semantic-chunk child *park* parent hair role location)
        (role5 isa semantic-chunk child *friday* parent hair role time)
         (friday isa chunk) (*friday* isa chunk) 
        (hippie isa chunk) (touched isa chunk) (debutante isa chunk) (park isa chunk)
        (*hippie* isa chunk) (*touch* isa chunk) (*debutante* isa chunk) (*park* isa chunk)
        (hippie-n isa lex-entry type noun word hippie meaning *hippie*)
        (touched-v isa lex-entry type verb word touched meaning *touch*)
        (debutante-n isa lex-entry type noun word debutante meaning *debutante*)
        (park-n isa lex-entry type noun word park meaning *park*)
        (friday-n isa lex-entry type noun word friday meaning *friday*))

(setf  *time-role* nil)
(sdp :base-level 3)
(goal-focus goal)

(no-output (do ((props (sdm isa proposition) (cdr props)))
    ((null props) nil)
    (eval `(sdp ,(car props) :references 2 :creation-time -10000))))
(goal-focus goal)

(p read-word
   =goal>
      isa parse
      word nil
==>
!eval! (read-word))

(eval `(spp read-word :effort ,*read*))

;productions for parsing
(p retrieve-type
   =goal>
      isa parse
      word =word
   -  word eos
      type nil
   =entry>
      isa lex-entry
      word =word
      type =type
==>
  =goal>
      type =type)

(p np-no-sent
   =goal>
      isa parse
      type noun
      word =word
      link nil
      meaning nil
   =lex>
      isa lex-entry
      word =word
      meaning =mean
==>
  =meaning>
      isa proposition
  =np>
      isa struct
  =sent>
      isa struct
  =semantic-chunk>
       isa semantic-chunk
       role agent
       parent =meaning
       child =mean
       context experiment
  =syntactic-chunk1>
      isa syntactic-chunk
      referent np
      role head
      child =word
      parent =np
  =syntactic-chunk2>
      isa syntactic-chunk
      referent sent
      role arg1
      child =np
      parent =sent
  =goal>
      word nil
      type nil
      link =np
      link-type np
      meaning =meaning
)

(p np-vp
   =goal>
      isa parse
      type noun
      word =word
      link =vp
      link-type vp
      meaning =meaning
  =lex>
     isa lex-entry
     word =word
     meaning =mean
==>
  =semantic-chunk>
     isa semantic-chunk
     role object
     child =mean
     parent =meaning
     context experiment
  =np>
      isa struct
  =syntactic-chunk1>
     isa syntactic-chunk
      referent np
      role head
      child =word
      parent =np
      context sentence1
  =syntactic-chunk2>
     isa syntactic-chunk
     referent vp
     role arg2
     child =np
     parent =vp
     context sentence1
  =goal>
      word nil
      type nil
      link =np
      link-type np
)

(p np-pp
   =goal>
      isa parse
      type noun 
      word =word
      link =pp
      link-type pp
      meaning =meaning
  =lex>
     isa lex-entry
     word =word
     meaning =mean
==>
  =semantic-chunk>
     isa semantic-chunk
     role agent
     parent =meaning
     child =mean
     context experiment
  =np>
      isa struct
  =syntactic-chunk1>
     isa syntactic-chunk
      referent np
      role head
      child =word
      parent =np
  =syntactic-chunk2>
     isa syntactic-chunk
     referent pp
     role head
     child =np
     parent =pp
  =goal>
      word nil
      type nil
      link =np
      link-type np
)

(p verb-attach
   =goal>
      isa parse
      type verb
      word =word
      link =vp1
      link-type vp1
      meaning =meaning
   =role1>
      isa semantic-chunk
      parent =meaning
      role agent
      child =noun
   =syntactic-chunk>
      isa syntactic-chunk
      child =vp1
      parent =parent
   =lex>
      isa lex-entry
      word =word
      meaning =mean
==>
   =semantic-chunk>
      isa semantic-chunk
      role relation
      parent =meaning
      child =mean
      context experiment
   =role1>
      role object
   =syntactic-chunk2>
      isa syntactic-chunk
      referent vp1
      role head
      child =word
      parent =vp1
      context sentence1
   =goal>
      link =parent
      link-type vp
      type nil
      word nil)


(p prep-sent
   =goal>
      isa parse
      type prep
      word =word
      link =vp
      link-type vp
==>
  =prepp>
      isa struct
  =syntactic-chunk1>
      isa syntactic-chunk
      referent pp
      role arg1
      child =word
      parent =prepp
      context sentence1
  =syntactic-chunk2>
      isa syntactic-chunk
      referent vp
      role arg2
      child =prepp
      parent =vp
  =goal>
      word nil
      type nil
      link =prepp
      link-type pp
)


(p verb-np
   =goal>
      isa parse
      type verb
      word =word
      link =np
      link-type np
      meaning =meaning
   =orole>
      isa syntactic-chunk
      child =np
      parent =sent
   =lex>
      isa lex-entry
      word =word
      meaning =mean
==>
   =semantic-chunk>
      isa semantic-chunk
      role relation
      child =mean
      parent =meaning
      context experiment
   =vp>
      isa struct
   =vp1>
      isa struct
   =syntactic-chunk1>
      isa syntactic-chunk
      referent vp1
      role head
      child =word
      parent =vp1
      context sentence1
   =syntactic-chunk3>
      isa syntactic-chunk
      referent vp1
      role arg1
      child null
      parent =vp1
      context sentence1
  =syntactic-chunk2>
      isa syntactic-chunk
      referent sent
      role head
      child =vp
      parent =sent
      context sentence1
   =syntactic-chunk4>
      isa syntactic-chunk
      referent vp
      role head
      child =vp1
      parent =vp
      context sentence1
   =goal>
     link =vp
     word nil
     type nil
     link-type vp)

(p aux-vp
   =goal>
      isa parse
      type aux
      word =word
      link =np
      link-type np
      meaning =meaning
   =orole>
      isa syntactic-chunk
      child =np
      parent =sent
==>
  =vp>
     isa struct
  =vp1>
     isa struct
   =syntactic-chunk1>
      isa syntactic-chunk
      referent vp1
      role arg1
      child =word
      parent =vp1
      context sentence1
  =syntactic-chunk2>
      isa syntactic-chunk
      referent sent
      role head
      child =vp
      parent =sent
      context sentence1
  =syntactic-chunk3>
      isa syntactic-chunk
      referent vp
      role head
      child =vp1
      parent =vp
      context sentence1
   =goal>
     word nil
     type nil
     link =vp1
     link-type vp1
     past =word)

; productions for trying to find a situational referent
(p complete
  =goal>
     isa parse
     word eos
     task comprehend
     meaning =meaning
  =semantic-chunk1>
     isa semantic-chunk
     parent =meaning
     role agent
     child =agent
  =semantic-chunk2>
     isa semantic-chunk
     parent =meaning
     role relation
     child =relation
   =semantic-chunk3>
     isa semantic-chunk
     parent =meaning
     role object
     child =object
==>
=newgoal>
   isa find-referent
   agent =agent
   relation =relation
   object =object
!focus-on! =newgoal)

(p Find-Referent
   =goal>
      isa find-referent
      agent =agent
      relation =relation
      object =object
   =proposition>
      isa proposition
==>
=newgoal>
    isa associate
    proposition =proposition
      agent =agent
      relation =relation
      object =object
!focus-on! =newgoal)


(p Associate
   =goal>
     isa associate
     proposition =proposition
      agent =agent
      relation =relation
      object =object
  =proposition>
     isa proposition
  =semantic-chunk1>
     isa semantic-chunk
     parent =meaning
     role agent
     child =agent
     context experiment
     referent nil
  =semantic-chunk2>
     isa semantic-chunk
     parent =meaning
     role relation
     child =relation
     context experiment
     referent nil
   =semantic-chunk3>
     isa semantic-chunk
     parent =meaning
     role object
     child =object
     context experiment
     referent nil
==>
   =semantic-chunk1>
     referent =proposition
   =semantic-chunk2>
     referent =proposition
   =semantic-chunk3>
     referent =proposition
!pop!)

(p go-ahead
   =goal>
      isa find-referent
      agent =agent
      relation =relation
      object =object
  =semantic-chunk1>
     isa semantic-chunk
     parent =meaning
     role agent
     child =agent
     context experiment
     referent nil
  =semantic-chunk2>
     isa semantic-chunk
     parent =meaning
     role relation
     child =relation
     context experiment
     referent nil
   =semantic-chunk3>
     isa semantic-chunk
     parent =meaning
     role object
     child =object
     context experiment
     referent nil
==>
!pop!)

(spp go-ahead :r .5)

;productions that implement match of either proposition or situational referent

(p match-props
  =goal>
     isa parse
     word eos
     task recognize
     meaning =meaning
  =semantic-chunk1>
     isa semantic-chunk
     parent =meaning
     child =agent
     role agent
  =semantic-chunk2>
     isa semantic-chunk
     parent =meaning
     child =relation
     role relation
  =semantic-chunk3>
     isa semantic-chunk
     parent =meaning
     child =object
     role object
==>
  =newgoal>
     isa match-props
     agent =agent
     object =object
     relation =relation
     context experiment
!focus-on! =newgoal)

(p try-plausibility
   =goal>
      isa match-props
      context =context
      referent nil 
!eval!  *plaus*
   =mrole>
      isa semantic-chunk
      context =context
      referent =prop1
   =role>
       isa semantic-chunk
       parent =prop1
       referent =script
    =prop>
       isa proposition
       context =script
==>
!eval! (setf *plaus* nil)
   =goal>
      referent =prop
      context agent
      response yes
      check nil)

(p default-no
  =goal>
      isa match-props
==>
!eval! (setf *response* nil)
  =newgoal>
     isa respond
     response nil
     parent =goal
!focus-on! =newgoal)  

(spp default-no :r .25)


(p try-retrieval
   =goal>
      isa match-props
      context =context
      relation =relation
      referent nil
  =semantic-chunk>
      isa semantic-chunk
      parent =proposition
      role relation
      context =context
      referent =referent
!eval! *retrieval*
==>
   =goal>
      referent =proposition
      check nil
      context agent
      response yes)


(p check-agent
   =goal>
       isa match-props
       referent =referent
       context agent
       check nil
    =semantic-chunk>
       isa semantic-chunk
       parent =referent
       role agent
       child =term
==>
    =goal>
       check =term)


(p checked-agent
   =goal>
       isa match-props
       referent =referent
       context agent
       check =agent
       agent =agent
==>
    =goal>
       check nil
       context relation)

      
(p check-relation
   =goal>
       isa match-props
       referent =referent
       context relation
       check nil
    =semantic-chunk>
       isa semantic-chunk
       parent =referent
       role relation
       child =term
==>
    =goal>
       check =term)

(p checked-relation
   =goal>
       isa match-props
       referent =referent
       context relation
       check =relation
       relation =relation
==>
    =goal>
       check nil
       context object)

(p check-object
   =goal>
       isa match-props
       referent =referent
       context object
       check nil
    =semantic-chunk>
       isa semantic-chunk
       parent =referent
       role object
       child =term
==>
    =goal>
       check =term)

(p checked-object
   =goal>
       isa match-props
       referent =referent
       context object
       check =object
       object =object
       response =response
==>
=newgoal>
     isa respond
     response =response
     parent =goal
!focus-on! =newgoal)


(p fail-check-agent
   =goal>
       isa match-props
       context agent
       check =object
!eval! (not (member =object *vars*))   
==>
  =goal>
     check nil 
     context relation
     response no
) 

(EVAL `(spp fail-check-agent :r .5 :effort ,(+ 0.05 *mismatch*)))

(p variable-agent
   =goal>
       isa match-props
       context agent
       check =object
!eval! (member =object *vars*)   
==>
  =goal>
     check nil 
     context relation
) 

(p fail-check-relation
   =goal>
       isa match-props
       context relation
       check =object
!eval! (not (member =object *vars*))  
==>
  =goal>
     check nil 
     context object
     response no
) 

(eval `(spp fail-check-relation :r .5 :effort ,(+ 0.05 *mismatch*)))



(p variable-relation
   =goal>
       isa match-props
       context relation
       check =object
!eval! (member =object *vars*)  
==>
=goal>
     check nil
     context object)

(p fail-check-object
   =goal>
       isa match-props
       context object
       check =object
!eval!  (not (member =object *vars*))
==>
=newgoal>
     isa respond
     response no
     parent =goal
!focus-on! =newgoal)

(eval `(spp fail-check-object :r .5 :effort ,(+ 0.05 *mismatch*)))




(p variable-object
   =goal>
       isa match-props
       context object
       check =object
       response =response
!eval! (member =object *vars*)
==>
=newgoal>
     isa respond
     response =response
     parent =goal
!focus-on! =newgoal)

(p start-recognition
  =goal>
     isa match-up
     state start
     word nil
==>
!eval! (read-word))

(eval `(spp start-recognition :effort ,*encoding*))

;productions that choose between syntax matching and a comprehension strategy

(p retrieve-sentence
   =goal>
     isa match-up
     state start
     word =word
     struct nil
   =syntactic-chunk>
     isa syntactic-chunk
     role head
     referent =type
     child =word
     parent =np
==>
   =goal>
     struct =np
     struct-test =type)

(p begin-comprehend
   =goal>
     isa match-up
     word =word
==>
!eval! (reset-sent)
   =newgoal> 
      isa parse 
      task recognize
!eval! (setf *goal* =newgoal)
!focus-on! =newgoal)

;productions that implement syntactic matching

(p retrieve-again
   =goal>
     isa match-up
     state start
     word =word
     struct =struct
   - struct-test sent
   =syntactic-chunk>
     isa syntactic-chunk
     child =struct
     parent =parent
     referent =type
==>
   =goal>
     struct =parent
     struct-test =type)

(p retrieve-subject
   =goal>
      isa match-up
      state start
      struct =struct
      struct-test sent
   =syntactic-chunk0>
     isa syntactic-chunk
     referent sent
     role head
     child =vp
     parent =struct
  =syntactic-chunk1>
      isa syntactic-chunk
      referent sent
      role arg1
      child =subj
      parent =struct
  =syntactic-chunk2> 
      isa syntactic-chunk 
      referent np
      role head
      child =head
      parent =subj
==>
  =goal>
      struct =vp
      struct-test =head
      state subj-test)

(p subjects-match
   =goal>
      isa match-up
      state subj-test
      struct-test =noun
      word =noun
==>
   =goal>
      struct-test null
      state aux-test
!eval! (read-word))

(eval `(spp subjects-match :effort ,*read*))

(p subjects-mismatch
   =goal>
      isa match-up
      state subj-test
      struct-test =noun
   -  word =noun
      response =response
==>
   =goal>
      struct-test null
      state aux-test
      response no
!eval! (read-word))

(eval `(spp subjects-mismatch :effort ,*read*))

(p retrieve-aux
   =goal>
     isa match-up
     state aux-test
     struct-test null
     struct =struct
   =syntactic-chunk2>
     isa syntactic-chunk
     referent vp
     role head
     child =vp1
     parent =struct
   =syntactic-chunk3>
     isa syntactic-chunk
     referent vp1
     role arg1
     child =aux
     parent =vp1
==>
  =goal>
     state aux
     struct-test =aux)

(p aux-aux
   =goal>
      isa match-up
      state aux
      word =word
      struct-test =word
      struct =struct
==>
!eval! (read-word)
  =goal>
     struct-test null)

(eval `(spp aux-aux :effort ,*read*))


(p retrieve-verb
   =goal>
      isa match-up
     state aux
      - word was
      struct-test null
      response =response
      word =struct
==>
  =newgoal>
     isa respond
     response =response
     parent =goal
!focus-on! =newgoal)

(p aux-noaux-yes
   =goal>
      isa match-up
      state aux
    -  word was
      struct-test was
      response no
==>
  =goal>
     response yes
     struct-test null)

(eval `(spp aux-noaux-yes :effort ,(+ 0.05 *mismatch*)))

(p noaux-aux-yes
   =goal>
      isa match-up
     state aux
      word was
      struct-test null
      struct =struct
      response no
==>
!eval! (read-word)
  =goal>
     response yes) 

(eval `(spp noaux-aux-yes :effort ,(+ *mismatch* *read*)))

(p aux-noaux-no
   =goal>
      isa match-up
      state aux
    -  word was
      struct-test was
      response yes
      struct =struct
   =syntactic-chunk1>
      isa syntactic-chunk
      referent vp
      parent =struct
      child =vp1
      role head
    =syntactic-chunk2>
      isa syntactic-chunk
      referent vp1
      parent =vp1
      child =head
      role head
==>
  =goal>
     response no
     struct-test null)

(eval `(spp aux-noaux-no :effort ,(+ 0.05 *mismatch*)))

(p noaux-aux-no
   =goal>
      isa match-up
     state aux
      word was
      struct-test null
      struct =struct
      response yes
   =syntactic-chunk1>
      isa syntactic-chunk
      referent vp
      parent =struct
      child =vp1
      role head
    =syntactic-chunk2>
      isa syntactic-chunk
      referent vp1
      parent =vp1
      child =head
      role head
==>
!eval! (read-word)
  =goal>
     response no) 

(eval `(spp noaux-aux-no :effort ,(+ *mismatch* *read*)))
;response generation productions
  

(p respond-yes
  =goal>
     isa respond
     response yes
==>
!eval! (setf *response* 'yes)
!output! yes
!pop!)

(eval `(spp respond-yes :effort ,*yes*))

(p respond-no
  =goal>
     isa respond
     response no
!eval! (not *plaus*)
==>
!eval! (setf *response* 'no)
!output! no
!pop!)

(eval `(spp respond-no :effort ,*no*))

(p switch-plausibility
   =goal>
       isa respond
      - response yes
       parent =newgoal
!eval! (and *plaus* *retrieval*)
   =newgoal>
       isa match-props
==>
!eval! (setf *retrieval* nil)
  =newgoal>
       context experiment
       referent nil
       check nil
       response nil
!focus-on! =newgoal)

(spp switch-plausibility :r 1.0)

(p respond-no-ANYWAYS
  =goal>
     isa respond
     response no
!eval! *plaus*
==>
!eval! (setf *response* 'no)
!output! no
!pop!)

(eval `(spp respond-no-anyways :effort ,*no* :R 0.95))

(p guess-no
    =goal>
       isa respond
       response nil
!eval! (not *plaus*)
==>
!eval! (setf *response* 'no)
!output! no
!pop!)

(eval `(spp guess-no :effort ,(+ *flail* *no*)))

(p guess-yes
    =goal>
       isa respond
       response nil
!eval! (not *plaus*)
==>
!eval! (setf *response* 'yes)
!output! yes
!pop!)

(eval `(spp guess-yes :effort ,(+ *flail* *yes*)))

;Productions to perform recall

       
(p encode-prompt
   =goal>
      isa recall
      prompt =prompt
      prompt-role nil
   =semantic-chunk>
      isa lex-entry
      word =prompt
      meaning =meaning
==>
!eval! (setf *number* 0)
  =goal>
      prompt =meaning
      prompt-role word)

(p retrieve-proposition
   =goal>
      isa recall
      prompt =idea
      prompt-role word
   =semantic-chunk>
      isa semantic-chunk
      child =idea
      parent =prop
      role =role
      referent nil
      context experiment
==>
   =goal>
      prompt-role =role
      proposition =prop
      recall-role agent)

(p retrieve-script
   =goal>
      isa recall
      prompt =idea
      prompt-role word
   =semantic-chunk>
      isa semantic-chunk
      child =idea
      parent =prop
      role =role
      referent =ref
      context experiment
==>
   =goal>
      prompt-role =role
      proposition =ref
      recall-role agent)

(p recall-agent
    =goal>
       isa recall
     - prompt-role agent
       recall-role agent
       proposition =prop
   =semantic-chunk>
      isa semantic-chunk
      child =idea
      parent =prop
      role agent
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!eval! (setf *number* (1+ *number*))
!output! =word
   =goal>
      recall-role relation)

(p recall-relation
    =goal>
       isa recall
     - prompt-role relation
       recall-role relation
       proposition =prop
   =semantic-chunk>
      isa semantic-chunk
      child =idea
      parent =prop
      role relation
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!eval! (setf *number* (1+ *number*))
!output! =word
   =goal>
      recall-role object)

(p recall-object
    =goal>
       isa recall
     - prompt-role object
       recall-role object
       proposition =prop
   =semantic-chunk>
      isa semantic-chunk
      child =idea
      parent =prop
      role object
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!eval! (setf *number* (1+ *number*))
!output! =word
   =goal>
      recall-role location)

(p recall-location
    =goal>
       isa recall
     - prompt-role location
       recall-role location
       proposition =prop
   =semantic-chunk>
      isa semantic-chunk
      child =idea
      parent =prop
      role location
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!eval! (setf *number* (1+ *number*))
!output! =word
   =goal>
      recall-role time)


(p recall-time
    =goal>
       isa recall
     - prompt-role time
       recall-role time
       proposition =prop
!eval!  *time-role*
   =semantic-chunk>
      isa semantic-chunk
      child =idea
      parent =prop
      role time
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!eval! (setf *number* (1+ *number*))
!output! =word
!pop!)

(p output-agent
    =goal>
       isa recall
       prompt =idea
       prompt-role agent
       recall-role agent
       proposition =prop
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!output! =word
   =goal>
      recall-role relation)

(p output-relation
    =goal>
       isa recall
       prompt =idea
       prompt-role relation
       recall-role relation
       proposition =prop
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!output! =word
   =goal>
      recall-role object)

(p output-object
    =goal>
       isa recall
       prompt =idea
       prompt-role object
       recall-role object
       proposition =prop
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!output! =word
   =goal>
      recall-role location)

(p output-location
    =goal>
       isa recall
       prompt =idea
       prompt-role location
       recall-role location
       proposition =prop
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!output! =word
   =goal>
      recall-role time)



(p output-time
    =goal>
       isa recall
       prompt =idea
       prompt-role time
       recall-role time
       proposition =prop
   =lex-entry>
       isa lex-entry
       word =word
       meaning =idea
==>
!output! =word
!pop!)

(p skip-agent
    =goal>
       isa recall
       recall-role agent
==>
   =goal>
      recall-role relation)

(spp skip-agent :r .5)

(p skip-relation
    =goal>
       isa recall
       recall-role relation
==>
   =goal>
      recall-role object)

(spp skip-relation :r .5)

(p skip-object
    =goal>
       isa recall
       recall-role object
==>
   =goal>
      recall-role location)

(spp skip-object :r .5)


(p skip-location
    =goal>
       isa recall
       recall-role location
==>
   =goal>
      recall-role time)

(spp skip-location :r .5)

(p skip-time
    =goal>
       isa recall
       recall-role time
==>
!pop!)

(spp skip-time :r .5)