;-------------------------------------------- ; SNeRE demo of a typical lecture ; ;-------------------------------------------- ;-------------------------------------------- ; Initial Setup / Relation Defs ;-------------------------------------------- ^(setq snip:*infertrace* nil) (resetnet t) (define member class condition then else act action object state plan vars suchthat do object1 object2 rel) ;-------------------------------------------- ; Primitive Actions ; Built in Actions + User Defined Actions ;-------------------------------------------- ;say (^ (define-primaction say (object1) "Print the argument node." (format t "~&Teacher Says: ~A.~%" (sneps::choose.ns object1))) ) ;ask (^ (define-primaction ask (object1) "Print the question." (format t "~&Teacher Asks: ~A?~%" (sneps::choose.ns object1))) ) ;my_write (^ (define-primaction my_write (object1) "Print what the teacher writes." (format t "~&Teacher Writes: ~A~%" (sneps::choose.ns object1))) ) ;pickup (^ (define-primaction pickup (object1) "Print what the teacher picks up." (format t "~&Teacher picks up ~A~%" (sneps::choose.ns object1))) ) ;putdown (^ (define-primaction putdown (object1) "Print what the teacher puts down." (format t "~&Teacher puts down ~A~%" (sneps::choose.ns object1))) ) ;walk (^ (define-primaction walk (object1) "Print where the teacher walks." (format t "~&Teacher walks to ~A~%" (sneps::choose.ns object1))) ) ;erase (^ (define-primaction erase (object1) "Print what the teacher erases." (format t "~&Teacher Erases: ~A~%" (sneps::choose.ns object1))) ) ;my_type (^ (define-primaction my_type (object1) "Print what the teacher types." (format t "~&Teacher Types: ~A~%" (sneps::choose.ns object1))) ) (^ (attach-primaction ;; built-in actions: snsequence snsequence sniterate sniterate achieve achieve believe believe do-one do-one withsome withsome withall withall ;;user defined actions: say say ask ask my_write my_write pickup pickup putdown putdown walk walk erase erase my_type my_type )) ;-------------------------------------------- ; Low Level Plans ;-------------------------------------------- ;call-on = say (studentName) (assert forall $x ant (build member *x class Student) cq (build act (build action call-on object1 *x) plan (build action say object1 *x)) ) ;answer-question = say(answer) OR say(AnswerComingLater) (assert forall ($x $y) &ant (build member *x class Question) &ant (build member *y class Answer) cq (build act (build action answer-question object1 *x) plan (build action snif object1 ((build condition (build object *y state LaterInLecture) then (build action say object1 "I'll answer that later.")) (build condition (build min 0 max 0 arg (build object *y state LaterInLecture)) then (build action say object1 *y)) (build else (build action say object1 "Sorry, I don't know the answer to that")))) ) ) ;view-webpage = walk(keyboard) + my_type (webPageName) (assert forall ($x $y) &ant (build member *x class keyboard) &ant (build member *y class webPage) cq (build act (build action view-webpage object1 *y) plan (build action snsequence object1 (build action walk object1 *x) object2 (build action my_type object1 *y))) ) ;write-on-board = pickup(chalk) + my_write(concept) + putdown(chalk) (assert forall $x ant (build member *x class concept) cq (build act (build action write-on-board object1 *x) plan (build action snsequence object1 (build action pickup object1 chalk) object2 (build action my_write object1 *x) ;object3 (build action putdown object1 chalk) ) ) ) ;-------------------------------------------- ; Low Level Events ;-------------------------------------------- ;-------------------------------------------- ; High Level Plans ;-------------------------------------------- ;define-concept = say(concept) + write-on-board(concept) OR write-on-board(concept) + say(concept) (assert forall $x ant (build member *x class concept) cq (build act (build action define-concept object1 *x) plan (build action do-one object1 ((build action snsequence object1 (build action say object1 *x) object2 (build action write-on-board object1 *x)) (build action snsequence object1 (build action write-on-board object1 *x) object2 (build action say object1 *x))))) ) ;show-examples = write-on-board(example) for all examples of a concept (assert forall ($x $y) &ant (build member *x class example) &ant (build member *y class concept) cq (build act (build action show-examples object1 *y) plan (build action withall vars $x suchthat (build object1 *x rel exampleOf object2 *y) do (build action write-on-board object1 *x) else (build action say object1 "Unfortunately there I have no examples"))) ) ;show-what-is-due = write-on-board(what is due) + view-webpage(course webpage) (assert forall ($x $y) &ant (build member *x class Homework) &ant (build member *y class webPage) cq (build act (build action show-what-is-due) plan (build action snsequence object1 (build action write-on-board object1 *x) object2 (build action view-webpage object1 *y))) ) ;SUBPLAN: teach a topic ;introduce history of topic ;define concepts ;show examples ;ask for questions ;if there are questions then answer them by either saying something or showing an example (assert forall $x ant (build member *x class concept) cq (build act (build action teach-a-topic object1 *x) plan (build action snsequence object1 (build action say object1 "History") object2 (build action snsequence object1 (build action define-concept object1 *x) object2 (build action snsequence object1 (build action show-examples object1 *x) object2 (build action ask object1 "any questions"))))) ) ;SUBPLAN: lecture-class ;overview of lecture ;remind what is due ;show new readings ;teach a topic (assert forall $x ant (build member *x class concept) cq (build act (build action lecture-class object1 *x) plan (build action snsequence object1 (build action say object1 "Today") object2 (build action snsequence object1 (build action show-what-is-due) object2 (build action snsequence object1 (build action view-webpage object1 "readings site") object2 (build action snsequence object1 (build action teach-a-topic object1 *x) object2 (build action believe object1 (build object lecture state taught))))))) ) ;INITIAL CONDITIONS (assert min 0 max 0 arg (build object lecture state taught)) (assert member "What Is A Computer?" class concept) (assert member "readings site" class webPage) (assert member "read Searle" class Homework) (assert member "read Searle" class concept) (assert member #chalk class chalk) (assert member #keyboard class keyboard) (assert member "cognitivism" class example) (assert member "cognitivism" class concept) (assert object1 "cognitivism" rel exampleOf object2 "What Is A Computer?") ;GOAL: lecture class (assert goal (build object lecture state taught) plan (build action lecture-class object1 "What Is A Computer?") ) ;START ACTION (perform (build action achieve object1 (build object lecture state taught)) )