home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e051 / 3.ddi / COMMON / OPSENV.LSP < prev    next >
Encoding:
Text File  |  1980-01-01  |  8.5 KB  |  266 lines

  1. ÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷                   INSTALLING OPS5 UNDER FRANZ
  2. ----------------------------------------------------------------------
  3.  
  4. The following files are needed to install OPS5 under FRANZ.
  5.     VPS2.L    -- FRANZ sources for the interpreter.
  6.     TRY5.L    -- One-rule system to check whether the
  7.              interpreter has been installed properly.
  8.  
  9. To install  OPS5 on a  VAX running  franz lisp, first  compile vps2.l
  10. with the  lisp compiler.   Then  run lisp and  give it  the following
  11. commands:
  12.  
  13.     (fasl 'vps2.o)
  14.     (i-g-v)
  15.  
  16. At that  point OPS5 is  ready to  use.  The  core image can  be saved
  17. using dumplisp or savelisp.
  18.  
  19. To  check the  interpreter,  run OPS5  and  load TRY5.L.    If it  is
  20. working, the interpreter will print the message:
  21.     ops5 installed
  22.  
  23. The file MAB.L  contains a small example OPS5 production  system.  It
  24. solves a version of  the old Monkey and Bananas problem.   To run it,
  25. load it in and give the commands:
  26.     (make start 1)
  27.     (run)
  28.  
  29. atus satified))
  30.  
  31.  
  32.  
  33. (p mb5
  34.     (goal ^status active ^type;    VPS2 -- Interpreter for OPS5
  35. ;
  36. ;    Copyright (C) 1979, 1980, 1981
  37. ;    Charles L. Forgy,  Pittsburgh, Pennsylvania
  38.  
  39.  
  40.  
  41. ; Users of this interpreter are requested to contact
  42. ;
  43. ;    Charles Forgy
  44. ;    Computer Science Department
  45. ;    Carnegie-Mellon University
  46. ;    Pittsburgh, PA  15213
  47. ; or
  48. ;    Forgy@CMUA
  49. ; so that they can be added to the mailing list for OPS5.  The mailing list
  50. ; is needed when new versions of the interpreter or manual are released.
  51.  
  52.  
  53. ;;; Definitions
  54.  
  55.  
  56.  
  57. (declare (special *matrix* *feature-count* *pcount* *vars* *cur-vars*
  58.           *curcond* *subnum* *last-node* *last-branch* *first-node*
  59.           *sendtocall* *flag-part* *alpha-flag-part* *data-part*
  60.           *alpha-data-part* *ce-vars* *virtual-cnt* *real-cnt*
  61.           *current-token* *c1* *c2* *c3* *c4* *c5* *c6* *c7* *c8* *c9*
  62.           *c10* *c11* *c12* *c13* *c14* *c15* *c16* *c17* *c18* *c19*
  63.           *c20* *c21* *c22* *c23* *c24* *c25* *c26* *c27* *c28* *c29*
  64.           *c30* *c31* *c32* *c33* *c34* *c35* *c36* *c37* *c38* *c39*
  65.           *c40* *c41* *c42* *c43* *c44* *c45* *c46* *c47* *c48* *c49*
  66.           *c50* *c51* *c52* *c53* *c54* *c55* *c56* *c57* *c58* *c59*
  67.           *c60* *c61* *c62* *c63* *c64* *record-array* *result-array* 
  68.           *max-cs* *total-cs* *limit-cs* *cr-temp* *side*
  69.           *conflict-set* *halt-flag* *phase* *critical*
  70.           *cycle-count* *total-token* *max-token* *refracts* 
  71.           *limit-token* *total-wm* *current-wm* *max-wm*
  72.           *action-count* *wmpart-list* *wm* *data-matched* *p-name*
  73.           *variable-memory* *ce-variable-memory* *max-index*
  74.           *next-index* *size-result-array* *rest* *build-trace* *last*
  75.           *ptrace* *wtrace* *in-rhs* *recording* *accept-file* *trace-file* 
  76.           *write-file* *record-index* *max-record-index* *old-wm*
  77.           *record* *filters* *break-flag* *strategy* *remaining-cycles*
  78.       *wm-filter* *rhs-bound-vars* *rhs-bound-ce-vars* *ppline* 
  79.       *ce-count* *brkpts* *class-list* *buckets* *action-type*))
  80.  
  81. (declare (localf ce-gelm gelm peek-sublex sublex
  82.           eval-nodelist sendto and-left and-right not-left not-right
  83.           top-levels-eq add-token real-add-token remove-old
  84.           remove-old-num remove-old-no-num removecs insertcs dsort
  85.           best-of best-of* conflict-set-compare =alg ))
  86.  
  87.  
  88. ;;; Functions that were revised so that they would compile efficiently
  89.  
  90.  
  91. ;* The function == is machine dependent!
  92. ;* This function compares small integers for equality.  It uses EQ
  93. ;* so that it will be fast, and it will consequently not work on all
  94. ;* Lisps.  It works in Franz Lisp for integers in [-128, 127]
  95.  
  96. (def == (macro (z) `(eq ,(cadr z) ,(caddr z))))
  97.  
  98. ; =ALG returns T if A and B are algebraicly equal.
  99.  
  100. (defun =alg (a b) (zerop (difference a b)))
  101.  
  102. (def fast-symeval 
  103.   (macro (z)
  104.      `(cond ((eq ,(cadr z) '*c1*) *c1*)
  105.         ((eq ,(cadr z) '*c2*) *c2*)
  106.         ((eq ,(cadr z) '*c3*) *c3*)
  107.         ((eq ,(cadr z) '*c4*) *c4*)
  108.         ((eq ,(cadr z) '*c5*) *c5*)
  109.         ((eq ,(cadr z) '*c6*) *c6*)
  110.         ((eq ,(cadr z) '*c7*) *c7*)
  111.         (t (eval ,(cadr z)))]
  112.  
  113. ; getvector and putvector are fast routines for using one-dimensional
  114. ; arrays.  these routines do no checking; they assume
  115. ;    1. the array is a vector with 0 being the index of the first
  116. ;       element
  117. ;    2. the vector holds arbitrary list values
  118.  
  119. ; Example call: (putvector array index value)
  120.  
  121. (def putvector
  122.   (macro (z)
  123.     (list '*rplacx (caddr z) (cadr z) (cadddr z))]
  124.  
  125. ; Example call: (getvector name index)
  126.  
  127. (def getvector
  128.   (macro (z)
  129.     (list 'cxr (caddr z) (cadr z))]
  130.  
  131. (defun ce-gelm (x k)
  132.   (prog nil
  133.    loop (and (== k 1.) (return (car x)))
  134.         (setq k (1- k))
  135.         (setq x (cdr x))
  136.         (go loop))) 
  137.  
  138. ; The loops in gelm were unwound so that fewer calls on DIFFERENCE
  139. ; would be needed
  140.  
  141. (defun gelm (x k)
  142.   (prog (ce sub)
  143.         (setq ce (/ k 10000.))
  144.         (setq sub (- k (* ce 10000.)))
  145.    celoop (and (== ce 0.) (go ph2))
  146.         (setq x (cdr x))
  147.         (and (== ce 1.) (go ph2))
  148.         (setq x (cdr x))
  149.         (and (== ce 2.) (go ph2))
  150.         (setq x (cdr x))
  151.         (and (== ce 3.) (go ph2))
  152.         (setq x (cdr x))
  153.         (and (== ce 4.) (go ph2))
  154.         (setq ce (- ce 4.))
  155.         (go celoop)
  156.    ph2  (setq x (car x))
  157.    subloop (and (== sub 0.) (go finis))
  158.         (setq x (cdr x))
  159.         (and (== sub 1.) (go finis))
  160.         (setq x (cdr x))
  161.         (and (== sub 2.) (go finis))
  162.         (setq x (cdr x))
  163.         (and (== sub 3.) (go finis))
  164.         (setq x (cdr x))
  165.         (and (== sub 4.) (go finis))
  166.         (setq x (cdr x))
  167.         (and (== sub 5.) (go finis))
  168.         (setq x (cdr x))
  169.         (and (== sub 6.) (go finis))
  170.         (setq x (cdr x))
  171.         (and (== sub 7.) (go finis))
  172.         (setq x (cdr x))
  173.         (and (== sub 8.) (go finis))
  174.         (setq sub (- sub 8.))
  175.         (go subloop)
  176.    finis (return (car x)))) 
  177.  
  178.  
  179. ;;; Utility functions
  180.  
  181.  
  182. (def neq (macro (a) `(not (eq ,(cadr a) ,(caddr a]
  183.  
  184.  
  185. (defun printline (x) (mapc (function printline*) x)) 
  186.  
  187. (defun printline* (y) (princ '| |) (print y)) 
  188.  
  189. (defun printlinec (x) (mapc (function printlinec*) x)) 
  190.  
  191. (defun printlinec* (y) (princ '| |) (princ y)) 
  192.  
  193. ; intersect two lists using eq for the equality test
  194.  
  195. (defun interq (x y)
  196.   (cond ((atom x) nil)
  197.         ((memq (car x) y) (cons (car x) (interq (cdr x) y)))
  198.         (t (interq (cdr x) y)))) 
  199.  
  200. (defun i-g-v nil
  201.  (prog (x)
  202.     (sstatus translink t)
  203.     (setsyntax '\{ 66.)
  204.     (setsyntax '\} 66.)
  205.     (setsyntax '^ 66.)
  206.     (setq *buckets* 64.)        ; OPS5 allows 64 named slots
  207.     (setq *accept-file* nil)
  208.     (setq *write-file* nil)
  209.     (setq *trace-file* nil)
  210.     (setq *class-list* nil)
  211.     (setq *brkpts* nil)
  212.     (setq *strategy* 'lex)
  213.       (setq *in-rhs* nil)
  214.       (setq *ptrace* t)
  215.       (setq *wtrace* nil)
  216.       (setq *recording* nil)
  217.         (setq *refracts* nil)
  218.     (setq *real-cnt* (setq *virtual-cnt* 0.))
  219.     (setq *max-cs* (setq *total-cs* 0.))
  220.       (setq *limit-token* 1000000.)
  221.     (setq *limit-cs* 1000000.)
  222.     (setq *critical* nil)
  223.     (setq *build-trace* nil)
  224.     (setq *wmpart-list* nil)
  225.     (setq *size-result-array* 127.)
  226.     (setq *result-array* (*makhunk 6))
  227.     (setq *record-array* (*makhunk 6))
  228.     (setq x 0)
  229.   loop    (putvector *result-array* x nil)
  230.     (setq x (1+ x))
  231.     (and (not (> x *size-result-array*)) (go loop))
  232.     (make-bottom-node)
  233.     (setq *pcount* 0.)
  234.     (initialize-record)
  235.     (setq *cycle-count* (setq *action-count* 0.))
  236.     (setq *total-token*
  237.            (setq *max-token* (setq *current-token* 0.)))
  238.     (setq *total-cs* (setq *max-cs* 0.))
  239.     (setq *total-wm* (setq *max-wm* (setq *current-wm* 0.)))
  240.     (setq *conflict-set* nil)
  241.     (setq *wmpart-list* nil)
  242.     (setq *p-name* nil)
  243.     (setq *remaining-cycles* 1000000)]
  244.  
  245. ; if the size of result-array changes, change the line in i-g-v which
  246. ; sets the value of *size-result-array*
  247.  
  248. (defun %warn (what where)
  249.   (prog nil
  250.     (terpri)
  251.     (princ '?)
  252.     (and *p-name* (princ *p-name*))
  253.     (princ '|..|)
  254.     (princ where)
  255.     (princ '|..|)
  256.     (princ what)
  257.     (return where))) 
  258.  
  259. (defun %error (what where)
  260.     (%warn what where)
  261.     (throw '!error! !error!)) 
  262.  
  263. (defun round (x) (fix (plus 0.5 x))) 
  264.  
  265. (d