From: Scott Brown
Subject: PAIP auxfns.lisp continuable error
Date: 
Message-ID: <61814e82.0408272204.4b50dd55@posting.google.com>
When I try to load the file auxfns.lisp from "Paradigms of Artificial
Intelligence Programming" using clisp I get the following error
message:

Continuable Error
DEFUN/DEFMACRO(SYMBOL): #<PACKAGE COMMON-LISP> is locked

What changes do I have to make to get the source code from PAIP to
work with clisp ?

From: Tayssir John Gabbour
Subject: Re: PAIP auxfns.lisp continuable error
Date: 
Message-ID: <866764be.0408280418.4bffa960@posting.google.com>
·············@yahoo.com.au (Scott Brown) wrote in message news:<····························@posting.google.com>...
> When I try to load the file auxfns.lisp from "Paradigms of Artificial
> Intelligence Programming" using clisp I get the following error
> message:
> 
> Continuable Error
> DEFUN/DEFMACRO(SYMBOL): #<PACKAGE COMMON-LISP> is locked
> 
> What changes do I have to make to get the source code from PAIP to
> work with clisp ?

My condolences. I had the same problem last year, when I did the same.
I was very disappointed, and believed the lisp world was full of as
much bullshit as the rest of the programming world, a world that can't
get a simple install program to work.

I mean, the book is about as good as you'll find in the computing
world, and he wrote such a big tome himself, but boy did he drop the
ball here. Maybe a free software project needs to take up the slack
here or something. Despite working as a big cheese at Google, he
replied to a query about PAIP near-instantly, so he does care, just...
sigh, world not black & white.

Quick hacks to get you up and running.

----
Line 87:

Replace load-paip-file with:

(defun load-paip-file (file)
  "Load the binary file if it exists and is newer, else load the
source."
  (load (paip-pathname file :lisp)))


Reasoning - here it wants to find some directory full of compiled lisp
files. Norvig seems to have a function which compiles all files to the
proper place, but it's broke and he don't care.

----
When code complains about locked common-lisp package:

Simply "ignore the lock and proceed."

If you had time, you could also look at lines 209 and 261, where he
defines SYMBOL and DEBUG, which create the conflict. You could do some
global search-replace symbol/debug -> symbol2/debug2... but ignoring
the lock and proceeding seems a fine lazy way to live.


----
Weirdnesses when you run (do-examples :all):

Do some subset of them. You can run things like (do-examples '(1 2))
or (do-examples 4).


Hope this helps,
Reply if it doesn't,
Tayssir
From: Scott Brown
Subject: Re: PAIP auxfns.lisp continuable error
Date: 
Message-ID: <61814e82.0408291930.512d05f2@posting.google.com>
···········@yahoo.com (Tayssir John Gabbour) wrote in message news:<····························@posting.google.com>...
> ·············@yahoo.com.au (Scott Brown) wrote in message news:<····························@posting.google.com>...
> > When I try to load the file auxfns.lisp from "Paradigms of Artificial
> > Intelligence Programming" using clisp I get the following error
> > message:
> > 
> > Continuable Error
> > DEFUN/DEFMACRO(SYMBOL): #<PACKAGE COMMON-LISP> is locked
> > 
> > What changes do I have to make to get the source code from PAIP to
> > work with clisp ?
> 
> My condolences. I had the same problem last year, when I did the same.
> I was very disappointed, and believed the lisp world was full of as
> much bullshit as the rest of the programming world, a world that can't
> get a simple install program to work.
> 
> I mean, the book is about as good as you'll find in the computing
> world, and he wrote such a big tome himself, but boy did he drop the
> ball here. Maybe a free software project needs to take up the slack
> here or something. Despite working as a big cheese at Google, he
> replied to a query about PAIP near-instantly, so he does care, just...
> sigh, world not black & white.
> 
> Quick hacks to get you up and running.
> 
> ----
> Line 87:
> 
> Replace load-paip-file with:
> 
> (defun load-paip-file (file)
>   "Load the binary file if it exists and is newer, else load the
> source."
>   (load (paip-pathname file :lisp)))
> 
> 
> Reasoning - here it wants to find some directory full of compiled lisp
> files. Norvig seems to have a function which compiles all files to the
> proper place, but it's broke and he don't care.
> 
> ----
> When code complains about locked common-lisp package:
> 
> Simply "ignore the lock and proceed."
> 
> If you had time, you could also look at lines 209 and 261, where he
> defines SYMBOL and DEBUG, which create the conflict. You could do some
> global search-replace symbol/debug -> symbol2/debug2... but ignoring
> the lock and proceeding seems a fine lazy way to live.
> 
> 
> ----
> Weirdnesses when you run (do-examples :all):
> 
> Do some subset of them. You can run things like (do-examples '(1 2))
> or (do-examples 4).
> 
> 
> Hope this helps,
> Reply if it doesn't,
> Tayssir

It worked.  Thank you for your help.
From: Pascal Bourguignon
Subject: Re: PAIP auxfns.lisp continuable error
Date: 
Message-ID: <873c27spn0.fsf@thalassa.informatimago.com>
·············@yahoo.com.au (Scott Brown) writes:

> When I try to load the file auxfns.lisp from "Paradigms of Artificial
> Intelligence Programming" using clisp I get the following error
> message:
> 
> Continuable Error
> DEFUN/DEFMACRO(SYMBOL): #<PACKAGE COMMON-LISP> is locked
> 
> What changes do I have to make to get the source code from PAIP to
> work with clisp ?

You should not load loop.lisp because clisp (and all Common-Lisp
implementations!) already contain a LOOP implementation.

Norvig code was written at the time of ClTl2 (pre-Common-Lisp), when
it was not decided yet that LOOP be included in Common-Lisp, and when
some lisp implementations did not have it.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.
From: Bill Clementson
Subject: Re: PAIP auxfns.lisp continuable error
Date: 
Message-ID: <1b3ac8a3.0408291942.28804bd6@posting.google.com>
·············@yahoo.com.au (Scott Brown) wrote in message news:<····························@posting.google.com>...
> When I try to load the file auxfns.lisp from "Paradigms of Artificial
> Intelligence Programming" using clisp I get the following error
> message:
> 
> Continuable Error
> DEFUN/DEFMACRO(SYMBOL): #<PACKAGE COMMON-LISP> is locked
> 
> What changes do I have to make to get the source code from PAIP to
> work with clisp ?

The following works for me:

(setq *WARN-ON-FLOATING-POINT-CONTAGION* nil)
(without-package-lock nil (load "auxfns.lisp"))
(requires "examples")

;; then either run the examples for a single chapter:
(do-examples 1)  ; or a different chapter number

;; or all the examples:
(do-examples :all)

;; or just play around with the code:
(requires "othello")
(requires "othello2")
(othello (minimax-searcher 3 #'count-difference) (maximizer #'count-difference))

Hope that helps.

--
Bill Clementson
From: Joel Ray Holveck
Subject: Re: PAIP auxfns.lisp continuable error
Date: 
Message-ID: <y7ck6vgjm1r.fsf@sindri.juniper.net>
--=-=-=

> What changes do I have to make to get the source code from PAIP to
> work with clisp ?

I just wrote some changes to PAIP's source code:

* Turned back on the compiler warnings that auxfns turns off

* Rename SYMBOL to CONCAT-SYMBOL

* Change ALL-SQUARES in othello from a DEFCONSTANT to a DEFPARAMETER,
  so that you can load othello2 correctly (otherwise you end up
  redefining a constant)

And, my personal favorite,

* Added a file load.lisp, which loads the latest versions of
  everything into a package "PAIP", and exports the functions called
  by the examples

I'm in the office and left my copy of PAIP at home, so I may have done
some things that are inconsistent with the text, such as loading an
old version of the file.  But there shouldn't be anything too
traumatic.  This is completely and utterly untested; I know that
"load" works.

This code is released under the same license as the rest of the PAIP
source code.

It's attached as a Unix patch file; email me privately if you need to
apply the patch and don't know how.

joelh


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=paip.patch

diff -uN paip.bak/auxfns.lisp paip/auxfns.lisp
--- paip.bak/auxfns.lisp	Tue Apr  9 12:18:14 2002
+++ paip/auxfns.lisp	Mon Aug 30 15:27:33 2004
@@ -5,8 +5,11 @@
 ;;; File auxfns.lisp: Auxiliary functions used by all other programs
 ;;; Load this file before running any other programs.
 
+;;; Modified by joelh; marks left
+
 ;;;; Implementation-Specific Details
 
+#+nil					;joelh
 (eval-when (eval compile load)
   ;; Make it ok to place a function definition on a built-in LISP symbol.
   #+(or Allegro EXCL)
@@ -64,7 +67,7 @@
 		      #+MCL "fasl"
 		      #+Allegro excl:*fasl-default-type*
 		      #+(or AKCL KCL) "o"
-		      #+CMU "sparcf"
+		      #+CMU "x86f"
 		      #+CLISP "fas"
 		      "bin"))  ;;???  Maybe Change this
    :directory (append (pathname-directory *paip-source*) '("bin"))
@@ -206,9 +209,12 @@
 ;;; Therefore, it would be best to rename the function SYMBOL to something 
 ;;; else.  This has not been done (for compatibility with the book).  
 
-(defun symbol (&rest args)
+(defun concat-symbol (&rest args)	;joelh, and callers changed
   "Concatenate symbols or strings to form an interned symbol"
   (intern (format nil "~{~a~}" args)))
+;;; If you want the old name too (since it's probably okay), then
+;;; uncomment the next line.  -joelh
+;;(setf (symbol-function 'symbol) #'concat-symbol)
 
 (defun new-symbol (&rest args)
   "Concatenate symbols or strings to form an uninterned symbol"
@@ -379,9 +385,9 @@
 
 (defmacro defresource (name &key constructor (initial-copies 0)
                        (size (max initial-copies 10)))
-  (let ((resource (symbol '* (symbol name '-resource*)))
-        (deallocate (symbol 'deallocate- name))
-        (allocate (symbol 'allocate- name)))
+  (let ((resource (concat-symbol '* (concat-symbol name '-resource*)))
+        (deallocate (concat-symbol 'deallocate- name))
+        (allocate (concat-symbol 'allocate- name)))
     `(progn
        (defparameter ,resource (make-array ,size :fill-pointer 0))
        (defun ,allocate ()
@@ -399,8 +405,8 @@
 
 (defmacro with-resource ((var resource &optional protect) &rest body)
   "Execute body with VAR bound to an instance of RESOURCE."
-  (let ((allocate (symbol 'allocate- resource))
-        (deallocate (symbol 'deallocate- resource)))
+  (let ((allocate (concat-symbol 'allocate- resource))
+        (deallocate (concat-symbol 'deallocate- resource)))
     (if protect
         `(let ((,var nil))
            (unwind-protect (progn (setf ,var (,allocate)) ,@body)
@@ -493,9 +499,9 @@
   "Represent an enumerated type with integers 0-n."
   `(progn
      (deftype ,type () '(integer 0 ,(- (length elements) 1)))
-     (defun ,(symbol type '->symbol) (,type)
+     (defun ,(concat-symbol type '->symbol) (,type)
        (elt ',elements ,type))
-     (defun ,(symbol 'symbol-> type) (symbol)
+     (defun ,(concat-symbol 'symbol-> type) (symbol)
        (position symbol ',elements))
      ,@(loop for element in elements
              for i from 0
@@ -685,4 +691,4 @@
                                fn result
                                (funcall-if key (pop seq))))))
              result))))
-)
\ No newline at end of file
+)
diff -uN paip.bak/lexicon.lisp paip/lexicon.lisp
--- paip.bak/lexicon.lisp	Tue Feb  4 22:39:53 1997
+++ paip/lexicon.lisp	Mon Aug 30 15:25:53 2004
@@ -5,6 +5,8 @@
 ;;;; File lexicon.lisp:  Macros and functions to support the entry of
 ;;;; words into the lexicon.
 
+;;; Modified by joelh to use concat-symbol instead of symbol
+
 (defvar *abbrevs* (make-hash-table))
 
 (defmacro abbrev (symbol definition)
@@ -83,7 +85,7 @@
   "Add a noun and its plural to the lexicon."
   `(add-noun-form ',base ,@(mapcar #'kwote args)))
 
-(defun add-noun-form (base &optional (plural (symbol base 's))
+(defun add-noun-form (base &optional (plural (concat-symbol base 's))
                       (sem base) &rest slots)
   (if (eq plural '*)
       (add-word base 'noun '? slots sem)
@@ -96,10 +98,10 @@
   `(add-verb ',senses ',base ,@(mapcar #'kwote (mklist forms))))
 
 (defun add-verb (senses base &optional
-                 (past (symbol (strip-vowel base) 'ed))
+                 (past (concat-symbol (strip-vowel base) 'ed))
                  (past-part past)
-                 (pres-part (symbol (strip-vowel base) 'ing))
-                 (plural (symbol base 's)))
+                 (pres-part (concat-symbol (strip-vowel base) 'ing))
+                 (plural (concat-symbol base 's)))
   "Enter a verb into the lexicon."
   (add-word base 'verb 'nonfinite senses)
   (add-word base 'verb '(finite ~3sing present) senses)
diff -uN paip.bak/load.lisp paip/load.lisp
--- paip.bak/load.lisp	Wed Dec 31 16:00:00 1969
+++ paip/load.lisp	Mon Aug 30 15:13:02 2004
@@ -0,0 +1,70 @@
+;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Package: CL-USER; Base: 10 -*-
+;; load.lisp - Load useful PAIP functions
+
+(in-package "CL-USER")
+
+(defpackage "PAIP"
+  (:use "COMMON-LISP"))			;Exports are built below
+
+(in-package "PAIP")
+(load (merge-pathnames #p"auxfns" *load-pathname*))
+(requires
+ ;; Eliza
+ "eliza-pm"
+ ;; Scheme
+ "compile3" "compopt" "interp3"
+ ;; Macsyma
+ "cmacsyma"
+ ;; Tutor
+ "examples"
+ ;; General Problem Solvec
+ "gps-srch"
+ ;; English Grammar
+ "grammar"
+ ;; Knowldge representation
+ "krep"
+ ;; Mycin (samples in mycin-r)
+ "mycin"
+ ;; Othello
+ "othello2"
+ ;; Pattern Matcher
+ "patmatch"
+ ;; Prolog
+ "prolog" "prologc" "prologcp"
+ ;; Searching
+ "search"
+ ;; Student word problems
+ "student"
+ ;; PSG natural language parser
+ "syntax3"
+ ;; DCG parser
+ "unifgram"
+ ;; Unification
+ "unify"
+ ;; Line-labeling using Waltz filtering
+ "waltz")
+
+(defvar *export-verbose* t)
+(let ((skip (make-hash-table :test 'eq)))
+  (when *export-verbose*
+    (format t "~&;; Exporting from PAIP:"))
+  (loop
+   for sym in '(fib
+		deposit interest balance withdraw
+		name* balance* interest-rate* withdraw*)
+   do (setf (gethash sym skip) t))
+  (export
+   (loop
+    for chapter in *chapters*
+    when *export-verbose* do (format t "~&; ~A" chapter)
+    nconcing (loop
+	      for ex in (chapter-examples chapter)
+	      for form = (and (listp ex) (car ex))
+	      for sym = (etypecase form
+			  (list (car form))
+			  (symbol nil))
+	      unless (or (gethash sym skip)
+			 (not (eq (symbol-package sym) (find-package "PAIP"))))
+	        do (when *export-verbose* (print sym))
+		and do (setf (gethash sym skip) t)
+  	        and collect sym))))
diff -uN paip.bak/othello.lisp paip/othello.lisp
--- paip.bak/othello.lisp	Tue Feb  4 22:39:54 1997
+++ paip/othello.lisp	Mon Aug 30 15:25:53 2004
@@ -7,6 +7,9 @@
 
 ;;; One bug fix by Alberto Segre, ·····@cs.cornell.edu, March 1993.
 
+;;; Modified by joelh to use defparameters in some places so othello2
+;;; can load
+
 (defun cross-product (fn xlist ylist)
   "Return a list of all (fn x y) values."
   (mappend #'(lambda (y)
@@ -36,7 +39,7 @@
 (defun copy-board (board)
   (copy-seq board))
 
-(defconstant all-squares
+(defparameter all-squares		;joelh- was defconstant
   (loop for i from 11 to 88 when (<= 1 (mod i 10) 8) collect i))
 
 (defun initial-board ()
@@ -273,7 +276,7 @@
     (aref neighbor-table square)))
 
 (let ((square-names 
-        (cross-product #'symbol
+        (cross-product #'concat-symbol
                        '(? a b c d e f g h ?)
                        '(? 1 2 3 4 5 6 7 8 ?))))
 
diff -uN paip.bak/othello2.lisp paip/othello2.lisp
--- paip.bak/othello2.lisp	Tue Feb  4 22:39:55 1997
+++ paip/othello2.lisp	Mon Aug 30 15:25:54 2004
@@ -10,9 +10,12 @@
 ;;;; then compile edge-table.lisp.  This will save the edge-table for
 ;;;; future use.
 
+;;; Modified by joelh to use defparameters in some places so it can
+;;; load after loading othello
+
 (requires "othello")
 
-(defconstant all-squares
+(defparameter all-squares		;joelh
   (sort (loop for i from 11 to 88 
 	      when (<= 1 (mod i 10) 8) collect i)
         #'> :key #'(lambda (sq) (elt *weights* sq))))
diff -uN paip.bak/prologc.lisp paip/prologc.lisp
--- paip.bak/prologc.lisp	Tue Feb  4 22:39:56 1997
+++ paip/prologc.lisp	Mon Aug 30 15:25:53 2004
@@ -5,6 +5,8 @@
 ;;;; File prologc.lisp: Final version of the compiler,
 ;;;; including all improvements from the chapter.
 
+;;; Modified by joelh to use concat-symbol instead of symbol
+
 (requires "prolog")
 
 (defconstant unbound "Unbound")
@@ -96,7 +98,7 @@
 
 (defun make-predicate (symbol arity)
   "Return the symbol: symbol/arity"
-  (symbol symbol '/ arity))
+  (concat-symbol symbol '/ arity))
 
 (defun make-= (x y) `(= ,x ,y))
 
diff -uN paip.bak/prologc1.lisp paip/prologc1.lisp
--- paip.bak/prologc1.lisp	Tue Feb  4 22:39:57 1997
+++ paip/prologc1.lisp	Mon Aug 30 15:25:52 2004
@@ -5,6 +5,8 @@
 ;;;; File prologc1.lisp: Version 1 of the prolog compiler, 
 ;;;; including the destructive unification routines from Chapter 11.
 
+;;; Modified by joelh to use concat-symbol instead of symbol
+
 (requires "prolog")
 
 (defconstant unbound "Unbound")
@@ -108,7 +110,7 @@
 
 (defun make-predicate (symbol arity)
   "Return the symbol: symbol/arity"
-  (symbol symbol '/ arity))
+  (concat-symbol symbol '/ arity))
 
 (defun compile-clause (parms clause cont)
   "Transform away the head, and compile the resulting body."
diff -uN paip.bak/prologc2.lisp paip/prologc2.lisp
--- paip.bak/prologc2.lisp	Tue Feb  4 22:39:57 1997
+++ paip/prologc2.lisp	Mon Aug 30 15:25:52 2004
@@ -5,6 +5,8 @@
 ;;;; File prologc2.lisp: Version 2 of the prolog compiler, 
 ;;;; fixing the first set of bugs.
 
+;;; Modified by joelh to use concat-symbol instead of symbol
+
 (requires "prolog")
 
 (defconstant unbound "Unbound")
@@ -96,7 +98,7 @@
 
 (defun make-predicate (symbol arity)
   "Return the symbol: symbol/arity"
-  (symbol symbol '/ arity))
+  (concat-symbol symbol '/ arity))
 
 (defun make-= (x y) `(= ,x ,y))
 
diff -uN paip.bak/unifgram.lisp paip/unifgram.lisp
--- paip.bak/unifgram.lisp	Tue Feb  4 22:39:59 1997
+++ paip/unifgram.lisp	Mon Aug 30 15:25:51 2004
@@ -4,6 +4,8 @@
 
 ;;;; File unifgram.lisp: The DCG parser from Chapter 20.
 
+;;; Modified by joelh to use concat-symbol instead of symbol
+
 (requires "prologcp")
 
 (defmacro rule (head &optional (arrow ':-) &body body)
@@ -22,7 +24,7 @@
 
 (defun make-dcg (head body)
   (let ((n (count-if (complement #'dcg-normal-goal-p) body)))
-    `(<- (,@head ?s0 ,(symbol '?s n))
+    `(<- (,@head ?s0 ,(concat-symbol '?s n))
          .,(make-dcg-body body 0))))
 
 (defun make-dcg-body (body n)
@@ -40,13 +42,13 @@
                    (make-dcg-body (rest body) n)))
           ((dcg-word-list-p goal)
            (cons
-             `(= ,(symbol '?s n)
-                 (,@(rest goal) .,(symbol '?s (+ n 1))))
+             `(= ,(concat-symbol '?s n)
+                 (,@(rest goal) .,(concat-symbol '?s (+ n 1))))
              (make-dcg-body (rest body) (+ n 1))))
           (t (cons
                (append goal
-                       (list (symbol '?s n)
-                             (symbol '?s (+ n 1))))
+                       (list (concat-symbol '?s n)
+                             (concat-symbol '?s (+ n 1))))
                (make-dcg-body (rest body) (+ n 1))))))))
 
 (setf (get '==> 'rule-function) 'make-augmented-dcg)
@@ -155,9 +157,9 @@
   "Define this category as an automatic conjunction."
   (assert (eq ==> '==>))
   `(progn
-     (setf (get ',cat 'conj-cat) ',(symbol cat '_))
+     (setf (get ',cat 'conj-cat) ',(concat-symbol cat '_))
      (rule (,cat ,@(butlast args) ?combined-sem) ==>
-       (,(symbol cat '_) ,@(butlast args) ,sem1)
+       (,(concat-symbol cat '_) ,@(butlast args) ,sem1)
        (,conj-cat ,sem1 ?combined-sem))
      (rule (,conj-cat ,sem1 ,combined-sem) ==>
        ,conj

--=-=-=--