From 1280fce06c2aefcf8da33c236b1c27ceea28ef4c Mon Sep 17 00:00:00 2001 From: Eric Swenson Date: Thu, 25 Jul 2024 15:18:01 -0700 Subject: [PATCH] Fixed various bugs with the current version of SHRDLU. Also added some descriptive files with info about the various files in the source directory. --- doc/shrdlu/#files.6 | 153 ++++++++++++++++++++++++++ doc/shrdlu/#files.info | 85 ++++++++++++++ src/shrdlu/{blockl.5 => blockl.6} | 3 +- src/shrdlu/{blockp.4 => blockp.5} | 12 +- src/shrdlu/{dictio.74 => dictio.75} | 12 +- src/shrdlu/{loader.19 => loader.20} | 1 + src/shrdlu/{newans.79 => newans.80} | 22 ++-- src/shrdlu/{smspec.95 => smspec.96} | 17 ++- src/shrdlu/{smutil.149 => smutil.150} | 8 +- 9 files changed, 292 insertions(+), 21 deletions(-) create mode 100644 doc/shrdlu/#files.6 create mode 100644 doc/shrdlu/#files.info rename src/shrdlu/{blockl.5 => blockl.6} (99%) rename src/shrdlu/{blockp.4 => blockp.5} (98%) rename src/shrdlu/{dictio.74 => dictio.75} (99%) rename src/shrdlu/{loader.19 => loader.20} (98%) rename src/shrdlu/{newans.79 => newans.80} (98%) rename src/shrdlu/{smspec.95 => smspec.96} (98%) rename src/shrdlu/{smutil.149 => smutil.150} (99%) diff --git a/doc/shrdlu/#files.6 b/doc/shrdlu/#files.6 new file mode 100644 index 00000000..3a12d000 --- /dev/null +++ b/doc/shrdlu/#files.6 @@ -0,0 +1,153 @@ +******************************************************************************** +* +* This describes the files maintained on the directory SHRDLU which +* go into making up the Natural Language Understanding system designed +* by Terry Winograd (currently at Stanford University) +* +* The files are ordered alphabeticly within the directory, but are +* described here in related groups, and are listed by the printing +* routine in similar groups +* +******************************************************************************** + + + +-- Files which support the BLOCKS micro-world + + + BLOCKP > Microplanner code for essentially all the functions of the + BLOCKS world. - there are some supplementary materials at the + end of the dictionary and data files + + BLOCKL > LISP code to support the microplanner code of BLOCKS. In particular + this includes the routine for finding space on an object and + for maintaining the history list. + + DATA > The initial contents (assertions) of the BLOCKS world's + microplanner data base. Plus a few addittional function calls + for initializing all other aspects of the micro-world. + + PLNR 180 This is a complete EXPR code version of MICROPLANNER. Calls to + MICROPLANNER in SHRDLU are always done by calling the function + THVAL2, contained in the semantics files, rather than the usual + call to THVAL. PLNR 180 can be loaded independantly and run + as a toplevel MICROPLANNER if desired. A compiled version of + the files is availlable as PLNR FASL on SHRDLU, and TS PLNR on + SYS should point to a core dump of a toplevel MICROPLANNER + + THTRAC 18 This is a file of tracing routines designed for tracing opperations + during the evaluation of MICROPLANNER code + + + + + +-- Toplevel files for the language understanding system -- + + + SYSCOM > Contains the toplevel function SHRDLU as well as usefull extentions + to LISP, special printing functions, break functions, garbage + collection functions etc. + + MORPHO > Does all the morphological analysis required in the system via + the function ETAOIN which is also the function called by SHRDLU + to read in a user's sentence from the console. + + SHOW > This is the "Show - Tell" user package developed for use at a + workshop at CMU in 1972. It provides a convenient way for a + largely naieve user to interogate and change the data structures + used in the system. Consult the MANUAL CMU for further details + + SETUP > A loose ends file for setting global variables, initializing + trace routines, and setting up the initial environment. It is + intended to be the final file read into the system before + making a core dump. + + + +-- Files concerned with syntax + + + PROGMR > This file contains all the functions that comprise the programmar + language fro writing grammars. It expects to be entered from a + toplevel call to PARSE as done in SHRDLU, and executes grammar + programs via an intermediary function, APPLY-GRAMMAR, to permit + differing opperations in the cases of compiled and intrepreted + code. + + GINTER > "Grammar Interpreter" - Contains the calling sequence for use when + running an uncompiled grammar. A precompiling pass is necessary + on grammar functions to remove extra levels of function calls + and to incorporate the calling program used in GINTER to eliminate + GOTO's out of scope. + + GRAMAR > The entire syntactic recognition grammar for the system. See + A.I. MEMO 282 "Grammar for the People" for comprehensive flowcharts + of the functions in this file. + + DICTIO > Specifications and entrys for all of SHRDLU's vocabulary and + related atomic symbols. This file contains all aspects of their + definitions: syntax, semantics, macro-expanders, etc. + + + +-- Semantics files -- + + + SMSPEC > "Semantic Specialists" This contains all the functions which know + how to interpret the syntactic forms that will be found by the + grammar: noun groups, relative clauses, pronouns, etc.. All calls + to these functions come from the syntactic routines through the + function SMCALL which is in PROGMR. + + SMUTIL > Utility routines used by all the semantic functions for building + nodes, evaluating definitions, marker checks, backreference maintanence, + quantifier adjusting, building MIRCOPLANNER code. + + SMASS > Access functions that are used by the two previous files to grovel + through their data structures while retaining their perspicuity. + + + +-- Answering -- + + NEWANS > "new answer" Code for finding the answers to questions, absorbing + new information, and following commands, then fromulating the + appropriate English answers. This code is extensively interfaced + with MICROPLANNER. + + + + +-- Documentation -- + + MANUAL CMU, MANNEW >, HELP DOC, MINIH DOC + + These files are unfortunately all the documentation availlable on the + care and feeding of the system appart from Winograd's book (which is + far and away the best reference to the details of its opperation). + MANUAL CMU, as its name implys, was developed for the workshop at + CMU and it the most through overall guide. HELP DOC and MINIH DOC + are essentially excerpts from it which were intended as online references. + MANNEW is grossly incomplete, but it is also the most up to date, and + covers initial ussage of hte system. + + + .INDEX > This is a through cross-reference for all the LISP code used in the system. + It lists functions and variables alphabeticly with listings of their + interactions with the rest of the code (functions called, variables + bound ...). Also of interest is the file LISP >, which alphabeticly lists + all MACLISP functions ever invoked in the code and the functions that they + were invoked from. + + + +-- At the end of the directory, the files whose first names are "Z" are the origninal + files of the system circa January 1971. They use the old list oriented data + structures and are essentially uncommented. However they can often be of use + when trying to see if alternate formulations of some algorithm were ever + considered. + + + +  \ No newline at end of file diff --git a/doc/shrdlu/#files.info b/doc/shrdlu/#files.info new file mode 100644 index 00000000..04c0672c --- /dev/null +++ b/doc/shrdlu/#files.info @@ -0,0 +1,85 @@ +The files in trhis directory contain the following +code and information + +.lisp. (init) - allocation comments and loader functions +for making SHRDLU's from scratch + +blocks > microplanner code for the blocks world with the +supporting LISP functions + +data > initial contents of the blocks world's microplanner +database + +debug > ideosyncratic functions created by SHRDLU's +various maintainers for grovelling arround in its guts and hacking its +display routines. Guarented illegible to ordinary mortals + +demo flick the guts of ts twdemo + +dictio > specifications and entries for SHRDLU's vocabulary and +markers list. Contains all aspects of the definitions: syntactic, +semantic, macro-expanders etc. + +displa info a brief description of the usage of the model +maintained for the DEC340 scope + +ginter > "grammar interpreter" ; called the first time any grammar +routine is used when running interpretive code. + +gramar > - linked to gramar > dsk gramar. Entire syntactic recognition +grammar for SHRDLU. See also A.I. memo 282 "Grammar for the +People" for flowcharts of it. + +grind (init) - special instructions to grind to have +shrdlu's functions come out in their prefered format + +manual > user's guide to SHRDLU - everything one needs +to know to put it through its paces + +moby dump an ancient vintage core dump used for occasional +demos. Its only redeming feature is that it can execute the +entire dialog with teh attendant capabilities for +accepting new definitions, following building plans, etc. +-partially compiled and completely unintelligible internally. + +newans > (new-answer) code for finding the answers to questions, absorbing +new information, and following commands; then formulating appropriate +answers. Extensively interfaced with microplanner. + +print macro a teco macro for generating listings of all of +SHRDLU. This same effect can be gained by invoking +a teco from the "lang" directory + +setup > loose ends file for initializing global variabels, +clobering the errlist, etc. - intended to be the +last file readin when constructing a shrdlu. + +show > functions for the show/tell displaying routines +-see the user's guide + +shrdlu > core image dunp of the most current, best debugged SHRDLU. +linked to by sys;ts shrdlu + +smass > access functions that are used by the +semantics routines to crawl through +their data structures + +smspec > semantic specialist functions which do the heavy work +of the semantics component + +smutil > utility functions utilized by teh semantics routines +for globbling definitions, creating planner code, checking marker +lists, etc. + +syscom > contains the toplevel functions "SHRDLU" and "ETAOIN" +as well as system-wide utility functions for printing, +breaking, etc. + +ts twdemo a canned version of the blocks dialog using the +340 display + +xcomp > declarations for the LAP compiler + +z ... files used by the original implementation of +SHRDLU (there are known bugs in the grammar) +  \ No newline at end of file diff --git a/src/shrdlu/blockl.5 b/src/shrdlu/blockl.6 similarity index 99% rename from src/shrdlu/blockl.5 rename to src/shrdlu/blockl.6 index b012a24c..6569c319 100644 --- a/src/shrdlu/blockl.5 +++ b/src/shrdlu/blockl.6 @@ -256,7 +256,7 @@ TYPE))) (LIST (LIST (QUOTE X) X))) (SETQ XX (PACKORD X (SIZE X) XX))))) - OBJ) + (listify obj)) (RETURN (MAPCAR (QUOTE CADR) XX)))) (DEFUN PACKON @@ -285,6 +285,7 @@ ((CONS (LIST SIZE X) LIST)))) (DEFUN SIZE (X) (COND ((EQ X (QUOTE :BOX)) (QUOTE (400 400 300))) ((EQ X (QUOTE :TABLE)) (QUOTE (1200 1200 1200))) + ((eq x (quote :hand)) (quote (0 0 0))) ((ATOM X) (CADDR (ATAB X))) (X))) diff --git a/src/shrdlu/blockp.4 b/src/shrdlu/blockp.5 similarity index 98% rename from src/shrdlu/blockp.4 rename to src/shrdlu/blockp.5 index b8f14e3b..f72a24cd 100644 --- a/src/shrdlu/blockp.4 +++ b/src/shrdlu/blockp.5 @@ -493,7 +493,8 @@ THEOREM) (X Y BLOCKS PYR (WHY (EV)) EV) (!STACKUP $?X) (OR (LESSP (APPLY (QUOTE PLUS) - (MAPCAR (QUOTE (LAMBDA (X) (CADDR (SIZE X)))) $?X)) + (MAPCAR (QUOTE (LAMBDA (X) (CADDR (SIZE X)))) + (listify $?x))) 1201) (NOT (DPRINT2 (QUOTE TOO/ HIGH/,)))) (THCOND @@ -685,8 +686,13 @@ THEOREM) (TIMECHK $?EVENT $?TIME) (THOR (THGOAL (!PUTON $?EVENT $?X ?)) (THGOAL (!PICKUP $?EVENT $?X))) - (OR (THVSETQ $_Z (SUB1 (ASSQ (GET $?EVENT (QUOTE END)) - (GET $?X (QUOTE HISTORY))))) + ; ejs + ; + ; to fix: "why did you move the blue pyramid?" yielding + ; (31 (700 174 600) :HAND NIL) NON-NUMERIC VALUE + ; + (OR (THVSETQ $_Z (SUB1 (car (ASSQ (GET $?EVENT (QUOTE END)) + (GET $?X (QUOTE HISTORY)))))) (ERT TCTE-PUT WRONG)) (THAMONG $?Y (LIST (CADR $?Z))) (THSETQ $_EV (MAKESYM (QUOTE E))) diff --git a/src/shrdlu/dictio.74 b/src/shrdlu/dictio.75 similarity index 99% rename from src/shrdlu/dictio.74 rename to src/shrdlu/dictio.75 index 039163bd..f4e643ac 100644 --- a/src/shrdlu/dictio.74 +++ b/src/shrdlu/dictio.75 @@ -300,12 +300,14 @@ SEMANTICS ((VB ((TRANS (RELATION - (RESTRICTIONS: RESTRICTIONS: + ( +; RESTRICTIONS: RESTRICTIONS: PROCEDURE: ((((!ANIMATE)) ((!EVENT)))) MARKERS: PROCEDURE: - PLAUSIBILITY: (!EVAL (OR (GET MAP2 'REFER) - (ERT DO - DEFINITION))))))) +; PLAUSIBILITY: (!EVAL (OR (GET MAP2 'REFER) +; (ERT DO +; DEFINITION))) + )))) )) FEATURES (TRANS VFS PRESENT VPL VB AUX DO INF)) (DEFS DOES IRREGULAR (DO (V3PS) (VFS VPL INF))) @@ -950,7 +952,7 @@ (DEFUN THANK NIL (COND ((EQ (CADR N) 'YOU) - (SAY YOU'RE WELCOME) + (SAY YOU/'RE WELCOME) (FLUSHME) (FLUSHME) (OR NN (IOC G)) diff --git a/src/shrdlu/loader.19 b/src/shrdlu/loader.20 similarity index 98% rename from src/shrdlu/loader.19 rename to src/shrdlu/loader.20 index 0b812f82..fb4bca74 100644 --- a/src/shrdlu/loader.19 +++ b/src/shrdlu/loader.20 @@ -30,6 +30,7 @@ ((eq (car x) 'v) (setq ^w nil)) ((eq (car x) 'r) (setq ^r t)) ((eq (car x) 'w) (progn (setq ^w t) (clear-output t))) + ((eq (car x) 'g) (tyo 7)) ; ring the bell (t (break (eval (car x)))))) (SETQ *RSET T) diff --git a/src/shrdlu/newans.79 b/src/shrdlu/newans.80 similarity index 98% rename from src/shrdlu/newans.79 rename to src/shrdlu/newans.80 index 268b6f87..7623e40e 100644 --- a/src/shrdlu/newans.79 +++ b/src/shrdlu/newans.80 @@ -367,7 +367,7 @@ TEST-LOOP (PLUS (PLAUSIBILITY? RSS) (CAR ANS))) ;AN ANSWER IS VERY IMPLAUSIBILE IF IT MENTIONS (T (DIFFERENCE (PLAUSIBILITY? RSS) 512.))) ;AN EVENT THE SYSTEM CAN'T FIND. (COND ((NULL (CADR ANS)) - '((SAY I CAN/'TDISCUSSA NON-EXISTENT EVENT))) + '((SAY I CAN/'T DISCUSS A NON-EXISTENT EVENT))) ((APPEND (AND (EQ TYPE 'POLAR) '((SAY YES))) (LIST (LIST 'EVLIS @@ -772,8 +772,10 @@ TEST-LOOP ;;ANSWER HAS BEEN DECIDED ON. (PROG (COUNT EXAM X RES ANS COMMA?) (SETQ NAMES (MAPCAR '(LAMBDA (X) (NAMEOBJ X SPEC)) - NAMES)) ;NAMEOBJ RETURNS A LIST OF THE OBJECT AND THE - (COND ((NULL NAMES) (RETURN '(SAY NOTHING)))) ;THIS PATCH MAY WELL BE TOTALLOUT OF PHASE WITH + (cond ((atom names) (list names)) + (t names)))) + ;NAMEOBJ RETURNS A LIST OF THE OBJECT AND THE + (COND ((NULL NAMES) (RETURN '((SAY NOTHING))))) ;THIS PATCH MAY WELL BE TOTALLOUT OF PHASE WITH UP (SETQ COUNT 1.) ;THE BACKREF HACKER - DDM 5-12-73 INSTRUCTIONS (SETQ EXAM (CAR NAMES)) ;FOR NAMING IT. (SETQ NAMES (CDR NAMES)) @@ -852,15 +854,15 @@ TEST-LOOP (PRON-PRT 'UP OBJ1))) ((EQ VERB 'PUTON) (APPEND (CONS (SAYIFY (VBFIX 'PUT T)) - (NAMELIST-EVALED '(NIL) + (car (NAMELIST-EVALED '(NIL) 'DEF - OBJ1)) + OBJ1))) (CONS '(SAY ON) - (NAMELIST-EVALED '(NIL) + (car (NAMELIST-EVALED '(NIL) 'DEF - OBJ2)))) + OBJ2))))) ((EQ VERB 'STACKUP) - (CONS (VBFIX STACK T) (PRON-PRT 'UP OBJ1))) + (CONS (sayify (VBFIX 'STACK T)) (PRON-PRT 'UP OBJ1))) ((EQ VERB 'RAISEHAND) NIL) (T (BUG NAMEACTION - @@ -1214,7 +1216,7 @@ TEST-LOOP ;;PROBLEM AND THE PARTICLE IS ALWAYS PUT BEFORE THE NG. ;;; (CONS (LIST 'SAY PARTICLE) - (NAMELIST-EVALED '(NIL) 'DEF NG))) + (car (NAMELIST-EVALED '(NIL) 'DEF NG)))) ;;;################################################################ @@ -1533,7 +1535,7 @@ BY) (PRINC (COND ((EQ X (Quote IT)) (Quote "IT")) ;;;############################################################ (DEFUN VBFIX (X PP) - (COND ((EQ TENSE 'ING) + (COND ((or (EQ TENSE 'ING) (eq tense 'pres-past)) (SETQ X (REVERSE (EXPLODE X))) (READLIST (REVERSE (APPEND '(G N I) (VBFIX2 X) diff --git a/src/shrdlu/smspec.95 b/src/shrdlu/smspec.96 similarity index 98% rename from src/shrdlu/smspec.95 rename to src/shrdlu/smspec.96 index 2d2a2ced..38bc041f 100644 --- a/src/shrdlu/smspec.95 +++ b/src/shrdlu/smspec.96 @@ -72,6 +72,20 @@ ;CLAUSE CONTAINING IT CAN NEVER GET CALLED ;EXCEPT BY RECURSION, +; ejs: original sources didn't have this. No sources I could find in ToTS had a +; definition for this function. I did, however, in the common lisp SHRDLU +; implementation, find a definition like the following one, so I'm adding it here. +; I ran into this error: +; +; ;SMINCOM UNDEFINED FUNCTION OBJECT +; +; ;BKPT UNDF-FNCTN +; +; trying to issue the following command to SHRDLU: did you move anything to do that? +; +(defun smincom () + t) + (DEFUN SMVG NIL ;;CALLED INSIDE ANY VG (PROG (TSS TENSE) @@ -127,7 +141,7 @@ (PUTPROP TSS TENSE 'TENSE=) (RETURN T))) -(DEFUN SMADJGQSHORT NIL (ERT SMADJQSHORT NOT WRITTEN YET)) +(DEFUN SMADJQSHORT NIL (ERT SMADJQSHORT NOT WRITTEN YET)) (DEFUN SMPRON (NODE) (EVAL (SM NODE)) @@ -281,6 +295,7 @@ (AND MVB;IS THIS A "DO IT!" COMMAND? (ISQ MVB DO) (CQ OBJ1) + (boundp 'lastevent) (RETURN (SMSET LASTEVENT))) ;IF SO, RETURN THE LAST EVENT (COND ((GET PRONOUN 'BIND) diff --git a/src/shrdlu/smutil.149 b/src/shrdlu/smutil.150 similarity index 99% rename from src/shrdlu/smutil.149 rename to src/shrdlu/smutil.150 index 729e2a63..b5bcc64f 100644 --- a/src/shrdlu/smutil.149 +++ b/src/shrdlu/smutil.150 @@ -710,7 +710,13 @@ ; VARLIST) ; - BODY)) + ;ejs + ; this may be wrong, but there are some bodies that are not THGOALs + ; probably the right thing is to figure out why these are not THGOALs + ; and fix them to be. But I haven't managed to find where the (!direction right nil), aka, LEFT + ; and (!direction right t), aka RIGHT, are being formed. + (cond ((eq (caar body) 'thgoal) body) + (t (list (list 'thgoal (car body))))))) ;;;=============================================================