Filtering...

basis-b

basis-b
other
(in-package "ACL2")
enforce-redundancy-er-argsfunction
(defun enforce-redundancy-er-args
  (event-form-var wrld-var)
  (list "Enforce-redundancy is active; see :DOC set-enforce-redundancy and ~
         see :DOC redundant-events.  However, the following event ~@0:~|~%~x1"
    `(if (and (symbolp (cadr ,EVENT-FORM-VAR))
        (decode-logical-name (cadr ,EVENT-FORM-VAR) ,WRLD-VAR))
      "conflicts with an existing event of the same name"
      "is not redundant")
    event-form-var))
enforce-redundancymacro
(defmacro enforce-redundancy
  (event-form ctx wrld form)
  (let ((var 'redun-check-var))
    `(let ((,VAR (and (not (eq (ld-skip-proofsp state) 'include-book))
           (cdr (assoc-eq :enforce-redundancy (table-alist 'acl2-defaults-table ,WRLD))))))
      (cond ((eq ,VAR t) (check-vars-not-free (,VAR)
            (er soft
              ,CTX
              ,@(ENFORCE-REDUNDANCY-ER-ARGS EVENT-FORM WRLD))))
        (t (pprogn (cond (,VAR (check-vars-not-free (,VAR)
                  (warning$ ,CTX
                    "Enforce-redundancy"
                    ,@(ENFORCE-REDUNDANCY-ER-ARGS EVENT-FORM WRLD))))
              (t state))
            (check-vars-not-free (,VAR) ,FORM)))))))
global-setfunction
(defun global-set
  (var val wrld)
  (declare (xargs :guard (and (symbolp var) (plist-worldp wrld))))
  (putprop var 'global-value val wrld))
tilde-@-illegal-variable-or-constant-name-phrasefunction
(defun tilde-@-illegal-variable-or-constant-name-phrase
  (name)
  (cond ((not (symbolp name)) "be symbols")
    ((keywordp name) "not be in the KEYWORD package")
    ((and (legal-constantp1 name)
       (equal (symbol-package-name name) *main-lisp-package-name*)) (cons "not be in the main Lisp package, ~x0"
        (list (cons #\0 *main-lisp-package-name*))))
    ((and (> (length (symbol-name name)) 0)
       (eql (char (symbol-name name) 0) #\&)) "not start with ampersands")
    ((and (not (legal-constantp1 name))
       (member-eq name *common-lisp-specials-and-constants*)) "not be among certain symbols from the main Lisp package, namely, the ~
          value of the list *common-lisp-specials-and-constants*")
    ((and (not (legal-constantp1 name))
       (equal (symbol-package-name name) *main-lisp-package-name*)
       (not (member-eq name
           *common-lisp-symbols-from-main-lisp-package*))) "either not be in the main Lisp package, or else must be among the ~
          imports into ACL2 from that package, namely, the list ~
          *common-lisp-symbols-from-main-lisp-package*")
    (t "be approved by LEGAL-VARIABLE-OR-CONSTANT-NAMEP and this ~
            one wasn't, even though it passes all the checks known to ~
            the diagnostic function ~
            TILDE-@-ILLEGAL-VARIABLE-OR-CONSTANT-NAME-PHRASE")))
gsymfunction
(defun gsym
  (pkg-witness char-lst cnt)
  (declare (xargs :guard (and (symbolp pkg-witness)
        (character-listp char-lst)
        (integerp cnt)
        (<= 0 cnt))))
  (intern-in-package-of-symbol (coerce (append char-lst (explode-nonnegative-integer cnt 10 nil))
      'string)
    pkg-witness))
genvar1-guardpfunction
(defun genvar1-guardp
  (pkg-witness char-lst avoid-lst cnt)
  (declare (xargs :guard t))
  (and (symbolp pkg-witness)
    (let ((p (symbol-package-name pkg-witness)))
      (and (not (equal p "KEYWORD"))
        (not (equal p *main-lisp-package-name*))))
    (character-listp char-lst)
    (consp char-lst)
    (not (eql (car char-lst) #\*))
    (not (eql (car char-lst) #\&))
    (true-listp avoid-lst)
    (natp cnt)))
genvar1function
(defun genvar1
  (pkg-witness char-lst avoid-lst cnt)
  (declare (xargs :guard (genvar1-guardp pkg-witness char-lst avoid-lst cnt)))
  (if (mbt (genvar1-guardp pkg-witness char-lst avoid-lst cnt))
    (let ((sym (mbe :logic (gsym pkg-witness char-lst cnt)
           :exec (intern-in-package-of-symbol (coerce (append char-lst (explode-nonnegative-integer cnt 10 nil))
               'string)
             pkg-witness))))
      (cond ((or (member sym avoid-lst) (not (legal-variablep sym))) (genvar1 pkg-witness char-lst avoid-lst (1+ cnt)))
        (t sym)))
    nil))
genvar-guardpfunction
(defun genvar-guardp
  (pkg-witness prefix n avoid-lst)
  (declare (xargs :guard t))
  (and (symbolp pkg-witness)
    (stringp prefix)
    (or (null n) (natp n))
    (true-listp avoid-lst)))
genvarfunction
(defun genvar
  (pkg-witness prefix n avoid-lst)
  (declare (xargs :guard (genvar-guardp pkg-witness prefix n avoid-lst)))
  (let* ((pkg-witness (cond ((let ((p (symbol-package-name pkg-witness)))
            (or (equal p "KEYWORD") (equal p *main-lisp-package-name*))) 'genvar)
         (t pkg-witness))) (sym (if (null n)
          (intern-in-package-of-symbol prefix pkg-witness)
          nil))
      (cnt (if n
          n
          0)))
    (cond ((and (null n)
         (legal-variablep sym)
         (not (member sym avoid-lst))) sym)
      (t (let ((char-lst (coerce prefix 'list)))
          (cond ((null char-lst) (genvar1 pkg-witness '(#\V) avoid-lst cnt))
            ((and (consp char-lst)
               (or (eql (car char-lst) #\*) (eql (car char-lst) #\&))) (genvar1 pkg-witness (cons #\V char-lst) avoid-lst cnt))
            (t (genvar1 pkg-witness char-lst avoid-lst cnt))))))))
gen-formals-from-pretty-flags1function
(defun gen-formals-from-pretty-flags1
  (pretty-flags i avoid)
  (cond ((endp pretty-flags) nil)
    ((and (symbolp (car pretty-flags))
       (or (equal (symbol-name (car pretty-flags)) "*")
         (eq (car pretty-flags) :df))) (let ((xi (pack2 'x i)))
        (cond ((member-eq xi avoid) (let ((new-var (genvar 'genvar "GENSYM" 1 avoid)))
              (cons new-var
                (gen-formals-from-pretty-flags1 (cdr pretty-flags)
                  (+ i 1)
                  (cons new-var avoid)))))
          (t (cons xi
              (gen-formals-from-pretty-flags1 (cdr pretty-flags)
                (+ i 1)
                avoid))))))
    (t (cons (car pretty-flags)
        (gen-formals-from-pretty-flags1 (cdr pretty-flags)
          (+ i 1)
          avoid)))))
gen-formals-from-pretty-flagsfunction
(defun gen-formals-from-pretty-flags
  (pretty-flags)
  (gen-formals-from-pretty-flags1 pretty-flags 1 pretty-flags))
collect-non-xfunction
(defun collect-non-x
  (x lst)
  (declare (xargs :guard (true-listp lst)))
  (cond ((endp lst) nil)
    ((equal (car lst) x) (collect-non-x x (cdr lst)))
    (t (cons (car lst) (collect-non-x x (cdr lst))))))
collect-non-nil-dffunction
(defun collect-non-nil-df
  (lst)
  (declare (xargs :guard (true-listp lst)))
  (cond ((endp lst) nil)
    ((or (eq (car lst) nil) (eq (car lst) :df)) (collect-non-nil-df (cdr lst)))
    (t (cons (car lst) (collect-non-nil-df (cdr lst))))))
collect-non-*function
(defun collect-non-*
  (lst)
  (declare (xargs :guard (symbol-listp lst)))
  (cond ((endp lst) nil)
    ((equal (symbol-name (car lst)) "*") (collect-non-* (cdr lst)))
    (t (cons (car lst) (collect-non-* (cdr lst))))))
defstub-body-newfunction
(defun defstub-body-new
  (outputs)
  (cond ((atom outputs) (cond ((and (symbolp outputs) (equal (symbol-name outputs) "*")) nil)
        ((eq outputs :df) '(df0))
        (t outputs)))
    ((and (symbolp (car outputs))
       (equal (symbol-name (car outputs)) "*")) (cons nil (defstub-body-new (cdr outputs))))
    ((eq (car outputs) :df) (cons '(df0) (defstub-body-new (cdr outputs))))
    (t (cons (car outputs) (defstub-body-new (cdr outputs))))))
collect-non-*-dffunction
(defun collect-non-*-df
  (lst)
  (declare (xargs :guard (symbol-listp lst)))
  (cond ((endp lst) nil)
    ((or (equal (symbol-name (car lst)) "*") (eq (car lst) :df)) (collect-non-*-df (cdr lst)))
    (t (cons (car lst) (collect-non-*-df (cdr lst))))))
collect-by-positionfunction
(defun collect-by-position
  (sub-domain full-domain full-range)
  (declare (xargs :guard (and (symbol-listp full-domain)
        (true-listp sub-domain)
        (true-listp full-range)
        (eql (length full-domain) (length full-range)))))
  (if (endp full-domain)
    nil
    (if (member-eq (car full-domain) sub-domain)
      (cons (car full-range)
        (collect-by-position sub-domain
          (cdr full-domain)
          (cdr full-range)))
      (collect-by-position sub-domain
        (cdr full-domain)
        (cdr full-range)))))
defproxymacro
(defmacro defproxy
  (name args-sig arrow body-sig)
  (cond ((not (and (symbol-listp args-sig)
         (symbolp arrow)
         (equal (symbol-name arrow) "=>"))) (er hard
        'defproxy
        "Defproxy must be of the form (proxy name args-sig => body-sig), ~
         where args-sig is a true-list of symbols.  See :DOC defproxy."))
    (t (let* ((formals (gen-formals-from-pretty-flags args-sig)) (body (defstub-body-new body-sig))
          (stobjs (collect-non-*-df args-sig))
          (dfs (collect-by-position '(:df) args-sig formals)))
        `(defun ,NAME
          ,FORMALS
          (declare (xargs :non-executable :program :mode :program ,@(AND STOBJS `(:STOBJS ,STOBJS))
              ,@(AND DFS `(:DFS ,DFS)))
            (ignorable ,@FORMALS))
          (prog2$ (throw-nonexec-error ',NAME nil) ,BODY))))))
defstub-ignoresfunction
(defun defstub-ignores
  (formals body)
  (declare (xargs :guard t))
  (if (and (symbol-listp formals)
      (or (symbolp body)
        (and (consp body) (true-listp (cdr body)))))
    (set-difference-eq formals
      (if (symbolp body)
        (list body)
        (cdr body)))
    nil))
defstub-body-old-auxfunction
(defun defstub-body-old-aux
  (outputs-without-mv stobjs)
  (declare (xargs :guard (symbol-listp stobjs)))
  (cond ((atom outputs-without-mv) nil)
    ((member-eq (car outputs-without-mv) stobjs) (cons (car outputs-without-mv)
        (defstub-body-old-aux (cdr outputs-without-mv) stobjs)))
    (t (cons nil
        (defstub-body-old-aux (cdr outputs-without-mv) stobjs)))))
defstub-body-oldfunction
(defun defstub-body-old
  (outputs stobjs)
  (declare (xargs :guard (symbol-listp stobjs)))
  (cond ((atom outputs) (cond ((member-eq outputs stobjs) outputs) (t nil)))
    (t (cons (car outputs)
        (defstub-body-old-aux (cdr outputs) stobjs)))))
defstub-fn1function
(defun defstub-fn1
  (signatures name formals ign-dcl stobjs dfs body outputs)
  `(with-output :off (:other-than error summary)
    :ctx '(defstub . ,NAME)
    :summary-off value
    (encapsulate ,SIGNATURES
      (with-output :off summary (logic))
      (with-output :summary-off (:other-than redundant)
        (local (defun ,NAME
            ,FORMALS
            (declare ,IGN-DCL
              ,@(AND STOBJS `((XARGS :STOBJS ,STOBJS)))
              ,@(AND DFS `((TYPE DOUBLE-FLOAT ,@DFS))))
            ,BODY)))
      ,@(AND (CONSP OUTPUTS)
       `((WITH-OUTPUT :OFF SUMMARY
                      (DEFTHM ,(PACKN-POS (LIST "TRUE-LISTP-" NAME) NAME)
                              (TRUE-LISTP (,NAME ,@FORMALS)) :RULE-CLASSES
                              :TYPE-PRESCRIPTION)))))))
defstub-fnfunction
(defun defstub-fn
  (name args)
  (let ((len-args (length args)))
    (cond ((not (and name (symbolp name))) `(er soft
          '(defstub . ,NAME)
          "The first argument of defstub must be a non-nil symbol.  The form ~
            ~x0 is thus illegal."
          '(defstub ,NAME ,@ARGS)))
      ((< len-args 2) `(er soft
          '(defstub . ,NAME)
          "Defstub must be of the form (defstub name inputs => outputs ...) ~
            or (defstub name inputs outputs ...).  See :DOC defstub."))
      ((or (= len-args 2)
         (and (keywordp (caddr args)) (not (eq (caddr args) :df)))) (let* ((inputs (car args)) (outputs (cadr args))
            (options (cddr args))
            (stobjs (and (keyword-value-listp options)
                (cadr (assoc-keyword :stobjs options))))
            (stobjs (cond ((symbol-listp stobjs) stobjs)
                ((symbolp stobjs) (list stobjs))
                (t nil)))
            (stobjs (cond ((and (true-listp inputs) (member-eq 'state inputs)) (add-to-set-eq 'state stobjs))
                (t stobjs)))
            (dfs (and (keyword-value-listp options)
                (cadr (assoc-keyword :dfs options))))
            (body (defstub-body-old outputs stobjs)))
          (defstub-fn1 `((,NAME ,@ARGS))
            name
            inputs
            `(ignorable ,@INPUTS)
            stobjs
            dfs
            body
            outputs)))
      (t (let* ((inputs (car args)) (arrow (cadr args))
            (outputs (caddr args))
            (options (cdddr args))
            (formals (and (symbol-listp inputs)
                (gen-formals-from-pretty-flags inputs)))
            (body (defstub-body-new outputs))
            (ignores (defstub-ignores formals body))
            (stobjs (and (symbol-listp inputs) (collect-non-*-df inputs)))
            (dfs (collect-by-position '(:df) inputs formals)))
          (defstub-fn1 `(((,NAME ,@INPUTS) ,ARROW ,OUTPUTS ,@OPTIONS))
            name
            formals
            `(ignore ,@IGNORES)
            stobjs
            dfs
            body
            outputs))))))
defstubmacro
(defmacro defstub (name &rest args) (defstub-fn name args))
*primitive-formals-and-guards*constant
(defconst *primitive-formals-and-guards*
  '((acl2-numberp (x) 't) (bad-atom<= (x y)
      (if (bad-atom x)
        (bad-atom y)
        'nil))
    (binary-* (x y)
      (if (acl2-numberp x)
        (acl2-numberp y)
        'nil))
    (binary-+ (x y)
      (if (acl2-numberp x)
        (acl2-numberp y)
        'nil))
    (unary-- (x) (acl2-numberp x))
    (unary-/ (x)
      (if (acl2-numberp x)
        (not (equal x '0))
        'nil))
    (< (x y)
      (if (rationalp x)
        (rationalp y)
        'nil))
    (car (x)
      (if (consp x)
        't
        (equal x 'nil)))
    (cdr (x)
      (if (consp x)
        't
        (equal x 'nil)))
    (char-code (x) (characterp x))
    (characterp (x) 't)
    (code-char (x)
      (if (integerp x)
        (if (< x '0)
          'nil
          (< x '256))
        'nil))
    (complex (x y)
      (if (rationalp x)
        (rationalp y)
        'nil))
    (complex-rationalp (x) 't)
    (coerce (x y)
      (if (equal y 'list)
        (stringp x)
        (if (equal y 'string)
          (character-listp x)
          'nil)))
    (cons (x y) 't)
    (consp (x) 't)
    (denominator (x) (rationalp x))
    (equal (x y) 't)
    (if (x y z)
      't)
    (imagpart (x) (acl2-numberp x))
    (integerp (x) 't)
    (intern-in-package-of-symbol (str sym)
      (if (stringp str)
        (symbolp sym)
        'nil))
    (numerator (x) (rationalp x))
    (pkg-imports (pkg) (stringp pkg))
    (pkg-witness (pkg)
      (if (stringp pkg)
        (not (equal pkg '""))
        'nil))
    (rationalp (x) 't)
    (realpart (x) (acl2-numberp x))
    (stringp (x) 't)
    (symbol-name (x) (symbolp x))
    (symbol-package-name (x) (symbolp x))
    (symbolp (x) 't)))
*primitive-monadic-booleans*constant
(defconst *primitive-monadic-booleans*
  '(acl2-numberp characterp
    complex-rationalp
    consp
    integerp
    rationalp
    stringp
    symbolp))
cons-term1-casesfunction
(defun cons-term1-cases
  (alist)
  (cond ((endp alist) nil)
    ((member-eq (caar alist)
       '(if bad-atom<=
         pkg-imports
         pkg-witness)) (cons-term1-cases (cdr alist)))
    (t (cons (let* ((trip (car alist)) (fn (car trip))
            (formals (cadr trip))
            (guard (caddr trip)))
          (list fn
            (cond ((equal guard *t*) `(kwote (,FN ,@FORMALS)))
              ((or (equal formals '(x)) (equal formals '(x y))) `(and ,GUARD (kwote (,FN ,@FORMALS))))
              (t (case-match formals
                  ((f1) `(let ((,F1 x))
                      (and ,GUARD (kwote (,FN ,@FORMALS)))))
                  ((f1 f2) `(let ((,F1 x) (,F2 y))
                      (and ,GUARD (kwote (,FN ,@FORMALS)))))
                  (& (er hard!
                      'cons-term1-cases
                      "Unexpected formals, ~x0"
                      formals)))))))
        (cons-term1-cases (cdr alist))))))
*cons-term1-alist*constant
(defconst *cons-term1-alist*
  (cons-term1-cases *primitive-formals-and-guards*))
cons-term1-bodymacro
(defmacro cons-term1-body
  nil
  `(let ((x (unquote (car args))) (y (unquote (cadr args))))
    (or (case fn
        ,@*CONS-TERM1-ALIST*
        (if (kwote (if x
              y
              (unquote (caddr args)))))
        (not (kwote (not x))))
      (cons fn args))))
quote-listpfunction
(defun quote-listp
  (l)
  (declare (xargs :guard (true-listp l)))
  (cond ((null l) t)
    (t (and (quotep (car l)) (quote-listp (cdr l))))))
cons-term1function
(defun cons-term1
  (fn args)
  (declare (xargs :guard (and (pseudo-term-listp args) (quote-listp args))))
  (cons-term1-body))
cons-termfunction
(defun cons-term
  (fn args)
  (declare (xargs :guard (pseudo-term-listp args)))
  (cond ((quote-listp args) (cons-term1 fn args))
    (t (cons fn args))))
cons-term*macro
(defmacro cons-term*
  (fn &rest args)
  `(cons-term ,FN (list ,@ARGS)))
mcons-termmacro
(defmacro mcons-term (fn args) `(cons-term ,FN ,ARGS))
mcons-term*macro
(defmacro mcons-term*
  (fn &rest args)
  `(cons-term* ,FN ,@ARGS))
fcons-termmacro
(defmacro fcons-term (fn args) (list 'cons fn args))
cdr-nestfunction
(defun cdr-nest
  (n v)
  (cond ((equal n 0) v) (t (fargn1 v n))))
encapsulate
(encapsulate nil
  (logic)
  (partial-encapsulate (((constrained-df-string *) => * :formals (x)))
    nil
    (local (defun constrained-df-string (x) (declare (ignore x)) ""))
    (defthm stringp-constrained-df-string
      (stringp (constrained-df-string x))
      :rule-classes :type-prescription)))
df-stringfunction
(defun df-string
  (x)
  (declare (xargs :guard t :mode :logic))
  (constrained-df-string x))
stobj-print-namefunction
(defun stobj-print-name
  (name)
  (declare (xargs :guard (symbolp name)))
  (let* ((s (symbol-name name)))
    (coerce (cons #\<
        (append (string-downcase1 (coerce s 'list)) '(#\>)))
      'string)))
*error-triple-sig*constant
(defconst *error-triple-sig* '(nil nil state))
*error-triple-df-sig*constant
(defconst *error-triple-df-sig* '(nil :df state))
*cmp-sig*constant
(defconst *cmp-sig* '(nil nil))
eviscerate-stobjs1function
(defun eviscerate-stobjs1
  (estobjs-out lst
    print-level
    print-length
    alist
    evisc-table
    hiding-cars
    iprint-alist
    iprint-fal-new
    iprint-fal-old
    eager-p)
  (cond ((null estobjs-out) (mv nil iprint-alist iprint-fal-new))
    ((car estobjs-out) (mv-let (rest iprint-alist iprint-fal-new)
        (eviscerate-stobjs1 (cdr estobjs-out)
          (cdr lst)
          print-level
          print-length
          alist
          evisc-table
          hiding-cars
          iprint-alist
          iprint-fal-new
          iprint-fal-old
          eager-p)
        (mv (cons (car estobjs-out) rest)
          iprint-alist
          iprint-fal-new)))
    (t (mv-let (first iprint-alist iprint-fal-new)
        (eviscerate (car lst)
          print-level
          print-length
          alist
          evisc-table
          hiding-cars
          iprint-alist
          iprint-fal-new
          iprint-fal-old
          eager-p)
        (mv-let (rest iprint-alist iprint-fal-new)
          (eviscerate-stobjs1 (cdr estobjs-out)
            (cdr lst)
            print-level
            print-length
            alist
            evisc-table
            hiding-cars
            iprint-alist
            iprint-fal-new
            iprint-fal-old
            eager-p)
          (mv (cons first rest) iprint-alist iprint-fal-new))))))
eviscerate-stobjsfunction
(defun eviscerate-stobjs
  (estobjs-out lst
    print-level
    print-length
    alist
    evisc-table
    hiding-cars
    iprint-alist
    iprint-fal-old
    eager-p)
  (cond ((null estobjs-out) (eviscerate lst
        print-level
        print-length
        alist
        evisc-table
        hiding-cars
        iprint-alist
        nil
        iprint-fal-old
        eager-p))
    ((null (cdr estobjs-out)) (cond ((car estobjs-out) (mv (car estobjs-out) iprint-alist nil))
        (t (eviscerate lst
            print-level
            print-length
            alist
            evisc-table
            hiding-cars
            iprint-alist
            nil
            iprint-fal-old
            eager-p))))
    (t (eviscerate-stobjs1 estobjs-out
        lst
        print-level
        print-length
        alist
        evisc-table
        hiding-cars
        iprint-alist
        nil
        iprint-fal-old
        eager-p))))
eviscerate-stobjs-topfunction
(defun eviscerate-stobjs-top
  (estobjs-out lst
    print-level
    print-length
    alist
    evisc-table
    hiding-cars
    state)
  (pprogn (iprint-oracle-updates? state)
    (brr-evisc-tuple-oracle-update state)
    (let ((iprint-fal-old (f-get-global 'iprint-fal state)))
      (mv-let (result iprint-alist iprint-fal-new)
        (eviscerate-stobjs estobjs-out
          lst
          print-level
          print-length
          alist
          evisc-table
          hiding-cars
          (and (iprint-enabledp state) (iprint-last-index state))
          iprint-fal-old
          (iprint-eager-p iprint-fal-old))
        (fast-alist-free-on-exit iprint-fal-new
          (let ((state (cond ((eq iprint-alist t) (f-put-global 'evisc-hitp-without-iprint t state))
                 ((atom iprint-alist) state)
                 (t (update-iprint-ar-fal iprint-alist
                     iprint-fal-new
                     iprint-fal-old
                     state)))))
            (mv result state)))))))
flambda-applicationpmacro
(defmacro flambda-applicationp (term) `(consp (car ,TERM)))
lambda-applicationpother
(defabbrev lambda-applicationp
  (term)
  (and (consp term) (flambda-applicationp term)))
flambdapmacro
(defmacro flambdap (fn) `(consp ,FN))
lambda-formalsmacro
(defmacro lambda-formals (x) `(cadr ,X))
lambda-bodymacro
(defmacro lambda-body (x) `(caddr ,X))
make-lambdamacro
(defmacro make-lambda
  (args body)
  `(list 'lambda ,ARGS ,BODY))
make-letfunction
(defun make-let
  (bindings ignores type-dcls body)
  `(let ,BINDINGS
    ,@(AND (OR IGNORES TYPE-DCLS)
       `((DECLARE ,@(AND IGNORES `((IGNORE ,@IGNORES)))
                  ,@TYPE-DCLS)))
    ,BODY))
er-let*macro
(defmacro er-let*
  (alist body)
  (declare (xargs :guard (and (doublet-listp alist) (symbol-alistp alist))))
  (cond ((null alist) (list 'check-vars-not-free
        '(er-let-star-use-nowhere-else)
        body))
    (t (list 'mv-let
        (list 'er-let-star-use-nowhere-else (caar alist) 'state)
        (cadar alist)
        (list 'cond
          (list 'er-let-star-use-nowhere-else
            (list 'mv 'er-let-star-use-nowhere-else (caar alist) 'state))
          (list t (list 'er-let* (cdr alist) body)))))))
matchmacro
(defmacro match (x pat) (list 'case-match x (list pat t)))
match!macro
(defmacro match!
  (x pat)
  (list 'or
    (list 'case-match x (list pat '(value nil)))
    (list 'er
      'soft
      nil
      "The form ~x0 was supposed to match the pattern ~x1."
      x
      (kwote pat))))
def-basic-type-sets1function
(defun def-basic-type-sets1
  (lst i)
  (declare (xargs :guard (and (integerp i) (true-listp lst))))
  (cond ((null lst) nil)
    (t (cons (list 'defconst (car lst) (list 'the-type-set (expt 2 i)))
        (def-basic-type-sets1 (cdr lst) (+ i 1))))))
def-basic-type-setsmacro
(defmacro def-basic-type-sets
  (&rest lst)
  (let ((n (length lst)))
    `(progn (defconst *actual-primitive-types* ',LST)
      (defconst *min-type-set* (- (expt 2 ,N)))
      (defconst *max-type-set* (- (expt 2 ,N) 1))
      (defmacro the-type-set
        (x)
        `(the (integer ,*MIN-TYPE-SET* ,*MAX-TYPE-SET*) ,X))
      ,@(DEF-BASIC-TYPE-SETS1 LST 0))))
list-of-the-type-setfunction
(defun list-of-the-type-set
  (x)
  (cond ((consp x) (cons (list 'the-type-set (car x))
        (list-of-the-type-set (cdr x))))
    (t nil)))
ts=macro
(defmacro ts=
  (a b)
  (list '= (list 'the-type-set a) (list 'the-type-set b)))
ts-complement0macro
(defmacro ts-complement0
  (x)
  (list 'the-type-set (list 'lognot (list 'the-type-set x))))
ts-complementpmacro
(defmacro ts-complementp (x) (list 'minusp x))
ts-union0-fnfunction
(defun ts-union0-fn
  (x)
  (list 'the-type-set
    (cond ((null x) '*ts-empty*)
      ((null (cdr x)) (car x))
      (t (xxxjoin 'logior (list-of-the-type-set x))))))
ts-union0macro
(defmacro ts-union0
  (&rest x)
  (declare (xargs :guard (true-listp x)))
  (ts-union0-fn x))
ts-intersection0macro
(defmacro ts-intersection0
  (&rest x)
  (list 'the-type-set (cons 'logand (list-of-the-type-set x))))
ts-disjointpmacro
(defmacro ts-disjointp
  (&rest x)
  (list 'ts= (cons 'ts-intersection x) '*ts-empty*))
ts-intersectpmacro
(defmacro ts-intersectp
  (&rest x)
  (list 'not
    (list 'ts= (cons 'ts-intersection x) '*ts-empty*)))
ts-builder-case-listpfunction
(defun ts-builder-case-listp
  (x)
  (cond ((atom x) (eq x nil))
    ((and (consp (car x))
       (true-listp (car x))
       (not (null (cdr (car x))))) (cond ((or (eq t (car (car x))) (eq 'otherwise (car (car x)))) (cond ((null (cdr x)) 'otherwise) (t nil)))
        (t (let ((ans (ts-builder-case-listp (cdr x))))
            (cond ((eq ans 'otherwise) (cond ((symbolp (car (car x))) 'otherwise) (t nil)))
              (t ans))))))
    (t nil)))
ts-builder-macro1function
(defun ts-builder-macro1
  (x case-lst seen)
  (declare (xargs :guard (and (symbolp x) (ts-builder-case-listp case-lst))))
  (cond ((null case-lst) nil)
    ((or (eq (caar case-lst) t) (eq (caar case-lst) 'otherwise)) (sublis (list (cons 'x x)
          (cons 'seen seen)
          (cons 'ts2 (cadr (car case-lst))))
        '((cond ((ts-intersectp x (ts-complement0 (ts-union0 . seen))) ts2)
           (t *ts-empty*)))))
    (t (cons (sublis (list (cons 'x x)
            (cons 'ts1 (caar case-lst))
            (cons 'ts2 (cadr (car case-lst))))
          '(cond ((ts-intersectp x ts1) ts2) (t *ts-empty*)))
        (ts-builder-macro1 x
          (cdr case-lst)
          (cons (caar case-lst) seen))))))
ts-builder-macrofunction
(defun ts-builder-macro
  (x case-lst)
  (declare (xargs :guard (and (symbolp x) (ts-builder-case-listp case-lst))))
  (cons 'ts-union (ts-builder-macro1 x case-lst nil)))
ts-buildermacro
(defmacro ts-builder
  (&rest args)
  (ts-builder-macro (car args) (cdr args)))
ffn-symb-pmacro
(defmacro ffn-symb-p
  (term sym)
  (cond ((symbolp term) `(and (nvariablep ,TERM) (eq (ffn-symb ,TERM) ,SYM)))
    ((and (consp sym) (eq (car sym) 'quote)) `(let ((term ,TERM))
        (and (nvariablep term) (eq (ffn-symb term) ,SYM))))
    (t `(let ((term ,TERM) (sym ,SYM))
        (and (nvariablep term) (eq (ffn-symb term) sym))))))
strip-notother
(defabbrev strip-not
  (term)
  (cond ((ffn-symb-p term 'not) (mv t (fargn term 1)))
    (t (mv nil term))))
equalitypmacro
(defmacro equalityp (term) `(ffn-symb-p ,TERM 'equal))
inequalitypmacro
(defmacro inequalityp (term) `(ffn-symb-p ,TERM '<))
consitypmacro
(defmacro consityp (term) `(ffn-symb-p ,TERM 'cons))
print-current-idatefunction
(defun print-current-idate
  (channel state)
  (mv-let (d state)
    (read-idate state)
    (print-idate d channel state)))
skip-when-logicfunction
(defun skip-when-logic
  (str state)
  (pprogn (observation 'top-level
      "~s0 events are skipped when the default-defun-mode is ~x1."
      str
      (default-defun-mode-from-state state))
    (mv nil nil state)))
chk-inhibit-output-lstfunction
(defun chk-inhibit-output-lst
  (lst ctx state)
  (let ((msg (chk-inhibit-output-lst-msg lst)))
    (cond (msg (er soft ctx "~@0" msg))
      (t (let ((lst (if (member-eq 'warning! lst)
               (add-to-set-eq 'warning lst)
               lst)))
          (pprogn (cond ((and (member-eq 'prove lst)
                 (not (member-eq 'proof-tree lst))
                 (member-eq 'proof-tree
                   (f-get-global 'inhibit-output-lst state))) (warning$ ctx
                  nil
                  "The printing of proof-trees is being ~
                                         enabled while the printing of proofs ~
                                         is being disabled.  You may want to ~
                                         execute :STOP-PROOF-TREE in order to ~
                                         inhibit proof-trees as well."))
              (t state))
            (value lst)))))))
set-inhibit-output-lst-fnfunction
(defun set-inhibit-output-lst-fn
  (lst state)
  (er-let* ((lst (chk-inhibit-output-lst lst 'set-inhibit-output-lst state)))
    (pprogn (f-put-global 'inhibit-output-lst lst state)
      (value lst))))
set-inhibit-output-lstmacro
(defmacro set-inhibit-output-lst
  (lst)
  `(set-inhibit-output-lst-fn ,LST state))
*ld-special-error*constant
(defconst *ld-special-error*
  "~x1 is an illegal value for the state global variable ~x0.  See ~
   :DOC ~x0.")
*state-global-error*constant
(defconst *state-global-error* *ld-special-error*)
chk-ld-skip-proofspfunction
(defun chk-ld-skip-proofsp
  (val ctx state)
  (declare (xargs :mode :program))
  (cond ((member-eq val
       '(t nil
         include-book
         initialize-acl2
         include-book-with-locals)) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-skip-proofsp val))))
set-ld-skip-proofspfunction
(defun set-ld-skip-proofsp
  (val state)
  (declare (xargs :mode :program))
  (er-progn (chk-ld-skip-proofsp val 'set-ld-skip-proofsp state)
    (pprogn (f-put-global 'ld-skip-proofsp val state)
      (value val))))
set-ld-skip-proofsmacro
(defmacro set-ld-skip-proofs
  (val state)
  (declare (ignore state))
  `(set-ld-skip-proofsp ,VAL state))
set-write-acl2xfunction
(defun set-write-acl2x
  (val state)
  (declare (xargs :guard (state-p state)))
  (er-progn (cond ((member-eq val '(t nil)) (value nil))
      ((and (consp val) (null (cdr val))) (chk-ld-skip-proofsp (car val) 'set-write-acl2x state))
      (t (er soft
          'set-write-acl2x
          "Illegal value for set-write-acl2x, ~x0.  See :DOC ~
                 set-write-acl2x."
          val)))
    (pprogn (f-put-global 'write-acl2x val state) (value val))))
*check-sum-exclusive-maximum*constant
(defconst *check-sum-exclusive-maximum* 268435399)
*check-length-exclusive-maximum*constant
(defconst *check-length-exclusive-maximum* 2097143)
*-check-sum-exclusive-maximum*constant
(defconst *-check-sum-exclusive-maximum*
  (- *check-sum-exclusive-maximum*))
*1-check-length-exclusive-maximum*constant
(defconst *1-check-length-exclusive-maximum*
  (1- *check-length-exclusive-maximum*))
ascii-code!function
(defun ascii-code!
  (x)
  (let ((y (char-code x)))
    (cond ((or (= y 0) (= y 128)) 1)
      ((< 127 y) (- y 128))
      (t y))))
check-sum1function
(defun check-sum1
  (sum len channel state)
  (declare (type (signed-byte 32) sum len))
  (let ((len (cond ((= len 0) *1-check-length-exclusive-maximum*)
         (t (the (signed-byte 32) (1- len))))))
    (declare (type (signed-byte 32) len))
    (mv-let (x state)
      (read-char$ channel state)
      (cond ((not (characterp x)) (mv sum state))
        (t (let ((inc (ascii-code! x)))
            (declare (type (unsigned-byte 7) inc))
            (cond ((and (= inc 0) (not (eql x #\	))) (mv x state))
              (t (let ((inc (the (unsigned-byte 7) (cond ((= inc 0) 9) (t inc)))))
                  (declare (type (unsigned-byte 7) inc))
                  (let ((sum (+ sum (the (signed-byte 32) (* inc len)))))
                    (declare (type (signed-byte 32) sum))
                    (check-sum1 (cond ((>= sum *check-sum-exclusive-maximum*) (the (signed-byte 32)
                            (+ sum *-check-sum-exclusive-maximum*)))
                        (t sum))
                      len
                      channel
                      state)))))))))))
check-sumfunction
(defun check-sum
  (channel state)
  (check-sum1 0
    *1-check-length-exclusive-maximum*
    channel
    state))
plus-mod-m31function
(defun plus-mod-m31
  (u v)
  (declare (type (signed-byte 32) u v))
  (the (signed-byte 32)
    (let ((u (min u v)) (v (max u v)))
      (declare (type (signed-byte 32) u v))
      (cond ((< u 1073741824) (cond ((< v 1073741824) (the (signed-byte 32) (+ u v)))
            (t (let ((part (+ (the (signed-byte 32) (logand v 1073741823)) u)))
                (declare (type (signed-byte 32) part))
                (cond ((< part 1073741823) (the (signed-byte 32) (logior part 1073741824)))
                  ((eql part 1073741823) 0)
                  (t (the (signed-byte 32)
                      (1+ (the (signed-byte 32) (logxor part 1073741824))))))))))
        (t (the (signed-byte 32)
            (- 2147483647
              (the (signed-byte 32)
                (+ (the (signed-byte 32) (- 2147483647 u))
                  (the (signed-byte 32) (- 2147483647 v)))))))))))
double-mod-m31function
(defun double-mod-m31
  (x)
  (declare (type (signed-byte 32) x))
  (the (signed-byte 32)
    (cond ((< x 1073741824) (the (signed-byte 32) (ash x 1)))
      (t (the (signed-byte 32)
          (- 2147483647
            (the (signed-byte 32)
              (ash (the (signed-byte 32) (- 2147483647 x)) 1))))))))
times-expt-2-16-mod-m31function
(defun times-expt-2-16-mod-m31
  (x)
  (declare (type (signed-byte 32) x))
  (the (signed-byte 32)
    (let ((hi (ash x -16)) (lo (logand x 65535)))
      (declare (type (signed-byte 32) hi lo))
      (cond ((eql 0 (the (signed-byte 32) (logand lo 32768))) (the (signed-byte 32)
            (plus-mod-m31 (double-mod-m31 hi)
              (the (signed-byte 32) (ash lo 16)))))
        (t (the (signed-byte 32)
            (plus-mod-m31 (double-mod-m31 hi)
              (the (signed-byte 32)
                (logior 1
                  (the (signed-byte 32)
                    (ash (the (signed-byte 32) (logand lo 32767)) 16)))))))))))
times-mod-m31function
(defun times-mod-m31
  (u v)
  (declare (type (signed-byte 32) u v))
  (the (signed-byte 32)
    (rem (the (signed-byte 64) (* u v)) 2147483647)))
fchecksum-natural-auxfunction
(defun fchecksum-natural-aux
  (n ans)
  (declare (type (integer 0 *) n))
  (declare (type (signed-byte 32) ans))
  (the (signed-byte 32)
    (if (eql n 0)
      ans
      (fchecksum-natural-aux (the (integer 0 *) (ash n -31))
        (the (signed-byte 32)
          (logxor ans
            (the (signed-byte 32)
              (times-mod-m31 (logand n 2147483647) 392894102))))))))
fchecksum-naturalfunction
(defun fchecksum-natural
  (n)
  (declare (type (integer 0 *) n))
  (the (signed-byte 32) (fchecksum-natural-aux n 28371987)))
fchecksum-string1function
(defun fchecksum-string1
  (str i len ans)
  (declare (type string str))
  (declare (type (signed-byte 32) i len ans))
  (the (signed-byte 32)
    (if (>= i len)
      ans
      (let* ((c0 (logand 127
             (the (signed-byte 32)
               (char-code (the character (char str i)))))) (i (+ i 1))
          (c1 (if (>= i len)
              0
              (char-code (the character (char str i)))))
          (i (+ i 1))
          (c2 (if (>= i len)
              0
              (char-code (the character (char str i)))))
          (i (+ i 1))
          (c3 (if (>= i len)
              0
              (char-code (the character (char str i)))))
          (bits (logior (the (signed-byte 32) (ash c0 24))
              (the (signed-byte 32)
                (logior (the (signed-byte 32) (ash c1 16))
                  (the (signed-byte 32)
                    (logior (the (signed-byte 32) (ash c2 8))
                      (the (signed-byte 32) c3))))))))
        (declare (type (signed-byte 32) c0 i c1 c2 c3 bits))
        (fchecksum-string1 str
          i
          len
          (the (signed-byte 32)
            (logxor ans
              (the (signed-byte 32) (times-mod-m31 bits 506249751)))))))))
fchecksum-string2function
(defun fchecksum-string2
  (str i len ans)
  (declare (type string str))
  (declare (type (signed-byte 32) ans))
  (declare (type (integer 0 *) i len))
  (the (signed-byte 32)
    (if (>= i len)
      ans
      (let* ((c0 (logand 127
             (the (signed-byte 32)
               (char-code (the character (char str i)))))) (i (+ i 1))
          (c1 (if (>= i len)
              0
              (char-code (the character (char str i)))))
          (i (+ i 1))
          (c2 (if (>= i len)
              0
              (char-code (the character (char str i)))))
          (i (+ i 1))
          (c3 (if (>= i len)
              0
              (char-code (the character (char str i)))))
          (bits (logior (the (signed-byte 32) (ash c0 24))
              (the (signed-byte 32)
                (logior (the (signed-byte 32) (ash c1 16))
                  (the (signed-byte 32)
                    (logior (the (signed-byte 32) (ash c2 8))
                      (the (signed-byte 32) c3))))))))
        (declare (type (signed-byte 32) c0 c1 c2 c3 bits)
          (type (integer 0 *) i))
        (fchecksum-string2 str
          i
          len
          (the (signed-byte 32)
            (logxor ans
              (the (signed-byte 32) (times-mod-m31 bits 506249751)))))))))
fchecksum-stringfunction
(defun fchecksum-string
  (str)
  (declare (type string str))
  (the (signed-byte 32)
    (let ((length (length str)))
      (declare (type (integer 0 *) length))
      (cond ((< length 2147483647) (fchecksum-string1 str
            0
            length
            (times-mod-m31 (the (signed-byte 32) (+ 1 length))
              718273893)))
        (t (fchecksum-string2 str
            0
            length
            (rem (the integer (* (+ 1 length) 718273893)) 2147483647)))))))
fchecksum-atomfunction
(defun fchecksum-atom
  (x)
  (the (signed-byte 32)
    (cond ((natp x) (fchecksum-natural x))
      ((integerp x) (let ((abs-code (fchecksum-natural (- x))))
          (declare (type (signed-byte 32) abs-code))
          (times-mod-m31 abs-code 283748912)))
      ((symbolp x) (let* ((pkg-code (fchecksum-string (symbol-package-name x))) (sym-code (fchecksum-string (symbol-name x)))
            (pkg-code-scramble (times-mod-m31 pkg-code 938187814)))
          (declare (type (signed-byte 32) pkg-code sym-code pkg-code-scramble))
          (logxor pkg-code-scramble sym-code)))
      ((stringp x) (fchecksum-string x))
      ((characterp x) (times-mod-m31 (char-code x) 619823821))
      ((rationalp x) (let* ((num-code (fchecksum-atom (numerator x))) (den-code (fchecksum-natural (denominator x)))
            (num-scramble (times-mod-m31 num-code 111298397))
            (den-scramble (times-mod-m31 den-code 391892127)))
          (declare (type (signed-byte 32)
              num-code
              den-code
              num-scramble
              den-scramble))
          (logxor num-scramble den-scramble)))
      ((complex-rationalp x) (let* ((imag-code (fchecksum-atom (imagpart x))) (real-code (fchecksum-atom (realpart x)))
            (imag-scramble (times-mod-m31 imag-code 18783723))
            (real-scramble (times-mod-m31 real-code 981827319)))
          (declare (type (signed-byte 32)
              imag-code
              real-code
              imag-scramble
              real-scramble))
          (logxor imag-scramble real-scramble)))
      (t (prog2$ (er hard 'fchecksum-atom "Bad atom, ~x0" x) 0)))))
*fchecksum-obj-stack-bound-init*constant
(defconst *fchecksum-obj-stack-bound-init* 10000)
fchecksum-obj2mutual-recursion
(mutual-recursion (defun fchecksum-obj2
    (x)
    (declare (xargs :guard t))
    (the (signed-byte 32) (fchecksum-obj x)))
  (defun fchecksum-obj
    (x)
    (declare (xargs :guard t))
    (the (signed-byte 32)
      (cond ((atom x) (fchecksum-atom x))
        (t (let* ((car-code (fchecksum-obj2 (car x))) (cdr-code (fchecksum-obj2 (cdr x)))
              (car-scramble (times-mod-m31 car-code 627718124))
              (cdr-scramble (times-mod-m31 cdr-code 278917287)))
            (declare (type (signed-byte 32)
                car-code
                cdr-code
                car-scramble
                cdr-scramble))
            (logxor car-scramble cdr-scramble)))))))
check-sum-objfunction
(defun check-sum-obj
  (obj)
  (declare (xargs :guard t))
  (fchecksum-obj obj))
read-file-iteratefunction
(defun read-file-iterate
  (channel acc state)
  (mv-let (eof obj state)
    (read-object channel state)
    (cond (eof (mv (reverse acc) state))
      (t (read-file-iterate channel (cons obj acc) state)))))
read-file+function
(defun read-file+
  (name msg ctx state)
  (declare (xargs :stobjs state :mode :program))
  (mv-let (channel state)
    (open-input-channel name :object state)
    (cond (channel (mv-let (ans state)
          (read-file-iterate channel nil state)
          (pprogn (close-input-channel channel state)
            (mv nil ans state))))
      (msg (er soft ctx "~@0" msg))
      (t (er soft ctx "No file found ~x0." name)))))
read-filefunction
(defun read-file
  (name state)
  (declare (xargs :stobjs state :mode :program))
  (read-file+ name nil 'read-file state))
formalsfunction
(defun formals
  (fn w)
  (declare (xargs :guard (and (symbolp fn) (plist-worldp w))))
  (let ((temp (getpropc fn 'formals t w)))
    (cond ((eq temp t) (er hard?
          'formals
          "Every function symbol is supposed to have a 'FORMALS property ~
                but ~x0 does not!"
          fn))
      (t temp))))
plist-worldp-with-formalsfunction
(defun plist-worldp-with-formals
  (alist)
  (declare (xargs :guard t))
  (cond ((atom alist) (eq alist nil))
    (t (and (consp (car alist))
        (symbolp (car (car alist)))
        (consp (cdr (car alist)))
        (symbolp (cadr (car alist)))
        (or (not (eq (cadr (car alist)) 'formals))
          (eq (cddr (car alist)) *acl2-property-unbound*)
          (true-listp (cddr (car alist))))
        (plist-worldp-with-formals (cdr alist))))))
arityfunction
(defun arity
  (fn w)
  (declare (xargs :guard (and (or (and (consp fn) (consp (cdr fn)) (true-listp (cadr fn)))
          (symbolp fn))
        (plist-worldp-with-formals w))))
  (cond ((flambdap fn) (length (lambda-formals fn)))
    (t (let ((temp (getpropc fn 'formals t w)))
        (cond ((eq temp t) nil) (t (length temp)))))))
symbol-classfunction
(defun symbol-class
  (sym wrld)
  (declare (xargs :guard (and (symbolp sym) (plist-worldp wrld))))
  (if (eq sym 'cons)
    :common-lisp-compliant (or (getpropc sym 'symbol-class nil wrld)
      (if (getpropc sym 'theorem nil wrld)
        :ideal :program))))
fdefun-modemacro
(defmacro fdefun-mode
  (fn wrld)
  `(if (eq (symbol-class ,FN ,WRLD) :program)
    :program :logic))
defun-modefunction
(defun defun-mode
  (name wrld)
  (declare (xargs :guard (plist-worldp wrld)))
  (cond ((and (symbolp name) (function-symbolp name wrld)) (fdefun-mode name wrld))
    (t nil)))
arities-okpfunction
(defun arities-okp
  (user-table w)
  (declare (xargs :guard (and (symbol-alistp user-table)
        (plist-worldp-with-formals w))))
  (cond ((endp user-table) t)
    (t (and (equal (arity (car (car user-table)) w)
          (cdr (car user-table)))
        (logicp (car (car user-table)) w)
        (arities-okp (cdr user-table) w)))))
other
(set-table-guard user-defined-functions-table
  (and (symbolp val)
    (case key
      ((untranslate untranslate-lst) (equal (length (getpropc val 'formals nil world))
          (length (getpropc key 'formals nil world))))
      (untranslate-preprocess (equal (length (getpropc val 'formals nil world)) 2))
      (otherwise nil))
    (equal (getpropc val 'stobjs-out '(nil) world) '(nil))))
other
(defrec def-body
  ((nume hyp . concl) equiv
    recursivep
    formals
    rune . controller-alist)
  t)
latest-bodyfunction
(defun latest-body
  (fncall hyp concl)
  (if hyp
    (fcons-term* 'if hyp concl (fcons-term* 'hide fncall))
    concl))
def-bodyfunction
(defun def-body
  (fn wrld)
  (declare (xargs :guard (and (symbolp fn)
        (plist-worldp wrld)
        (true-listp (getpropc fn 'def-bodies nil wrld)))))
  (car (getpropc fn 'def-bodies nil wrld)))
bodyfunction
(defun body
  (fn normalp w)
  (cond ((flambdap fn) (lambda-body fn))
    (normalp (let ((def-body (def-body fn w)))
        (cond ((not (eq (access def-body def-body :equiv) 'equal)) (getpropc fn 'unnormalized-body nil w))
          (t (latest-body (fcons-term fn (access def-body def-body :formals))
              (access def-body def-body :hyp)
              (access def-body def-body :concl))))))
    (t (getpropc fn 'unnormalized-body nil w))))
get-stobj-recognizerfunction
(defun get-stobj-recognizer
  (stobj wrld)
  (cond ((eq stobj 'state) 'state-p)
    (t (let ((prop (getpropc stobj 'stobj nil wrld)))
        (and prop (access stobj-property prop :recognizer))))))
stobj-recognizer-termsfunction
(defun stobj-recognizer-terms
  (known-stobjs wrld)
  (cond ((endp known-stobjs) nil)
    (t (cons (fcons-term* (get-stobj-recognizer (car known-stobjs) wrld)
          (car known-stobjs))
        (stobj-recognizer-terms (cdr known-stobjs) wrld)))))
mcons-term-smartfunction
(defun mcons-term-smart
  (fn args)
  (if (and (eq fn 'if) (equal (car args) *t*))
    (cadr args)
    (cons-term fn args)))
optimize-stobj-recognizers1mutual-recursion
(mutual-recursion (defun optimize-stobj-recognizers1
    (known-stobjs recog-terms term)
    (cond ((variablep term) term)
      ((fquotep term) term)
      ((flambda-applicationp term) (let ((formals (lambda-formals (ffn-symb term))) (body (lambda-body (ffn-symb term))))
          (cond ((intersectp-eq known-stobjs formals) (fcons-term (make-lambda formals
                  (optimize-stobj-recognizers1 known-stobjs recog-terms body))
                (optimize-stobj-recognizers1-lst known-stobjs
                  recog-terms
                  (fargs term))))
            (t (fcons-term (ffn-symb term)
                (optimize-stobj-recognizers1-lst known-stobjs
                  recog-terms
                  (fargs term)))))))
      ((and (null (cdr (fargs term)))
         (member-equal term recog-terms)) *t*)
      (t (mcons-term-smart (ffn-symb term)
          (optimize-stobj-recognizers1-lst known-stobjs
            recog-terms
            (fargs term))))))
  (defun optimize-stobj-recognizers1-lst
    (known-stobjs recog-terms lst)
    (cond ((endp lst) nil)
      (t (cons (optimize-stobj-recognizers1 known-stobjs
            recog-terms
            (car lst))
          (optimize-stobj-recognizers1-lst known-stobjs
            recog-terms
            (cdr lst)))))))
optimize-stobj-recognizersfunction
(defun optimize-stobj-recognizers
  (known-stobjs term wrld)
  (cond ((null known-stobjs) term)
    (t (optimize-stobj-recognizers1 known-stobjs
        (stobj-recognizer-terms known-stobjs wrld)
        term))))
optimize-dfpmutual-recursion
(mutual-recursion (defun optimize-dfp
    (known-dfs term)
    (cond ((or (variablep term) (fquotep term)) term)
      ((and (eq (ffn-symb term) 'dfp)
         (variablep (fargn term 1))
         (member-eq (fargn term 1) known-dfs)) *t*)
      (t (mcons-term-smart (ffn-symb term)
          (optimize-dfp-lst known-dfs (fargs term))))))
  (defun optimize-dfp-lst
    (known-dfs termlist)
    (cond ((endp termlist) nil)
      (t (cons (optimize-dfp known-dfs (car termlist))
          (optimize-dfp-lst known-dfs (cdr termlist)))))))
guardfunction
(defun guard
  (fn stobj-optp w)
  (cond ((flambdap fn) *t*)
    ((or (not stobj-optp) (all-nils (stobjs-in fn w))) (getpropc fn 'guard *t* w))
    (t (let* ((guard (or (getpropc fn 'guard *t* w)
             (illegal 'guard
               "Found a nil guard for ~x0."
               (list (cons #\0 fn))))) (stobjs-in (stobjs-in fn w))
          (known-dfs (collect-by-position '(:df) stobjs-in (formals fn w))))
        (optimize-stobj-recognizers (collect-non-nil-df stobjs-in)
          (if known-dfs
            (optimize-dfp known-dfs guard)
            guard)
          w)))))
guard-lstfunction
(defun guard-lst
  (fns stobj-optp w)
  (cond ((null fns) nil)
    (t (cons (guard (car fns) stobj-optp w)
        (guard-lst (cdr fns) stobj-optp w)))))
equivalence-relationpmacro
(defmacro equivalence-relationp
  (fn w)
  `(let ((fn ,FN))
    (or (eq fn 'equal)
      (eq fn 'iff)
      (and (not (flambdap fn)) (getpropc fn 'coarsenings nil ,W)))))
global-set-lstfunction
(defun global-set-lst
  (alist wrld)
  (cond ((null alist) wrld)
    (t (global-set-lst (cdr alist)
        (global-set (caar alist) (cadar alist) wrld)))))
cons-term1-body-mv2macro
(defmacro cons-term1-body-mv2
  nil
  `(let ((x (unquote (car args))) (y (unquote (cadr args))))
    (let ((evg (case fn
           ,@*CONS-TERM1-ALIST*
           (if (kwote (if x
                 y
                 (unquote (caddr args)))))
           (not (kwote (not x))))))
      (cond (evg (mv t evg)) (t (mv nil form))))))
cons-term1-mv2function
(defun cons-term1-mv2
  (fn args form)
  (declare (xargs :guard (and (pseudo-term-listp args) (quote-listp args))))
  (cons-term1-body-mv2))
sublis-var1mutual-recursion
(mutual-recursion (defun sublis-var1
    (alist form)
    (declare (xargs :guard (and (symbol-alistp alist)
          (pseudo-term-listp (strip-cdrs alist))
          (pseudo-termp form))))
    (cond ((variablep form) (let ((a (assoc-eq form alist)))
          (cond (a (mv (not (eq form (cdr a))) (cdr a)))
            (t (mv nil form)))))
      ((fquotep form) (mv nil form))
      (t (mv-let (changedp lst)
          (sublis-var1-lst alist (fargs form))
          (let ((fn (ffn-symb form)))
            (cond (changedp (mv t (cons-term fn lst)))
              ((and (symbolp fn) (quote-listp lst)) (cons-term1-mv2 fn lst form))
              (t (mv nil form))))))))
  (defun sublis-var1-lst
    (alist l)
    (declare (xargs :guard (and (symbol-alistp alist)
          (pseudo-term-listp (strip-cdrs alist))
          (pseudo-term-listp l))))
    (cond ((endp l) (mv nil l))
      (t (mv-let (changedp1 term)
          (sublis-var1 alist (car l))
          (mv-let (changedp2 lst)
            (sublis-var1-lst alist (cdr l))
            (cond ((or changedp1 changedp2) (mv t (cons term lst)))
              (t (mv nil l)))))))))
sublis-varfunction
(defun sublis-var
  (alist form)
  (declare (xargs :guard (and (symbol-alistp alist)
        (pseudo-term-listp (strip-cdrs alist))
        (pseudo-termp form))))
  (mv-let (changedp val)
    (sublis-var1 alist form)
    (declare (ignore changedp))
    val))
sublis-var-lstfunction
(defun sublis-var-lst
  (alist l)
  (declare (xargs :guard (and (symbol-alistp alist)
        (pseudo-term-listp (strip-cdrs alist))
        (pseudo-term-listp l))))
  (mv-let (changedp val)
    (sublis-var1-lst alist l)
    (declare (ignore changedp))
    val))
subcor-var1function
(defun subcor-var1
  (vars terms var)
  (declare (xargs :guard (and (symbol-listp vars)
        (pseudo-term-listp terms)
        (equal (length vars) (length terms))
        (variablep var))))
  (cond ((endp vars) var)
    ((eq var (car vars)) (car terms))
    (t (subcor-var1 (cdr vars) (cdr terms) var))))
subcor-varmutual-recursion
(mutual-recursion (defun subcor-var
    (vars terms form)
    (declare (xargs :guard (and (symbol-listp vars)
          (pseudo-term-listp terms)
          (equal (length vars) (length terms))
          (pseudo-termp form))))
    (cond ((variablep form) (subcor-var1 vars terms form))
      ((fquotep form) form)
      (t (cons-term (ffn-symb form)
          (subcor-var-lst vars terms (fargs form))))))
  (defun subcor-var-lst
    (vars terms forms)
    (declare (xargs :guard (and (symbol-listp vars)
          (pseudo-term-listp terms)
          (equal (length vars) (length terms))
          (pseudo-term-listp forms))))
    (cond ((endp forms) nil)
      (t (cons (subcor-var vars terms (car forms))
          (subcor-var-lst vars terms (cdr forms)))))))
make-reversed-ad-listfunction
(defun make-reversed-ad-list
  (term ans)
  (cond ((variablep term) (mv ans term))
    ((fquotep term) (mv ans term))
    ((eq (ffn-symb term) 'car) (make-reversed-ad-list (fargn term 1) (cons '#\A ans)))
    ((eq (ffn-symb term) 'cdr) (make-reversed-ad-list (fargn term 1) (cons '#\D ans)))
    (t (mv ans term))))
car-cdr-abbrev-namefunction
(defun car-cdr-abbrev-name
  (adr-lst)
  (intern (coerce (cons #\C adr-lst) 'string) "ACL2"))
pretty-parse-ad-listfunction
(defun pretty-parse-ad-list
  (ad-list dr-list n base)
  (cond ((eql n 5) (pretty-parse-ad-list ad-list
        '(#\R)
        1
        (list (car-cdr-abbrev-name dr-list) base)))
    ((endp ad-list) (cond ((eql n 1) base)
        (t (list (car-cdr-abbrev-name dr-list) base))))
    ((eql (car ad-list) #\A) (pretty-parse-ad-list (cdr ad-list)
        '(#\R)
        1
        (list (car-cdr-abbrev-name (cons #\A dr-list)) base)))
    (t (pretty-parse-ad-list (cdr ad-list)
        (cons #\D dr-list)
        (+ 1 n)
        base))))
untranslate-car-cdr-nestfunction
(defun untranslate-car-cdr-nest
  (term)
  (mv-let (ad-list base)
    (make-reversed-ad-list term nil)
    (cond ((null ad-list) base)
      (t (pretty-parse-ad-list ad-list '(#\R) 1 base)))))
collect-non-trivial-bindingsfunction
(defun collect-non-trivial-bindings
  (vars vals)
  (cond ((null vars) nil)
    ((eq (car vars) (car vals)) (collect-non-trivial-bindings (cdr vars) (cdr vals)))
    (t (cons (list (car vars) (car vals))
        (collect-non-trivial-bindings (cdr vars) (cdr vals))))))
untranslate-andfunction
(defun untranslate-and
  (p q iff-flg)
  (declare (ignore iff-flg))
  (cond ((and (consp q) (eq (car q) 'and)) (cons 'and (cons p (cdr q))))
    (t (list 'and p q))))
untranslate-orfunction
(defun untranslate-or
  (p q)
  (cond ((and (consp q) (eq (car q) 'or)) (cons 'or (cons p (cdr q))))
    (t (list 'or p q))))
case-lengthfunction
(defun case-length
  (key term)
  (case-match term
    (('if ('equal key1 ('quote val)) & y) (cond ((and (if (null key)
             (variablep key1)
             (eq key key1))
           (eqlablep val)) (1+ (case-length key1 y)))
        (t 1)))
    (('if ('eql key1 ('quote val)) & y) (cond ((and (if (null key)
             (variablep key1)
             (eq key key1))
           (eqlablep val)) (1+ (case-length key1 y)))
        (t 1)))
    (('if ('member key1 ('quote val)) & y) (cond ((and (if (null key)
             (variablep key1)
             (eq key key1))
           (eqlable-listp val)) (1+ (case-length key1 y)))
        (t 1)))
    (& 1)))
cond-lengthfunction
(defun cond-length
  (term)
  (case-match term (('if & & z) (1+ (cond-length z))) (& 1)))
*untranslate-boolean-primitives*constant
(defconst *untranslate-boolean-primitives* '(equal))
right-associated-argsfunction
(defun right-associated-args
  (fn term)
  (let ((arg2 (fargn term 2)))
    (cond ((and (nvariablep arg2)
         (not (fquotep arg2))
         (eq fn (ffn-symb arg2))) (cons (fargn term 1) (right-associated-args fn arg2)))
      (t (fargs term)))))
dumb-negate-litfunction
(defun dumb-negate-lit
  (term)
  (declare (xargs :guard (pseudo-termp term)))
  (cond ((variablep term) (fcons-term* 'not term))
    ((fquotep term) (cond ((equal term *nil*) *t*) (t *nil*)))
    ((eq (ffn-symb term) 'not) (fargn term 1))
    ((and (eq (ffn-symb term) 'equal)
       (or (equal (fargn term 2) *nil*)
         (equal (fargn term 1) *nil*))) (if (equal (fargn term 2) *nil*)
        (fargn term 1)
        (fargn term 2)))
    (t (fcons-term* 'not term))))
dumb-negate-lit-lstfunction
(defun dumb-negate-lit-lst
  (lst)
  (cond ((endp lst) nil)
    (t (cons (dumb-negate-lit (car lst))
        (dumb-negate-lit-lst (cdr lst))))))
term-stobjs-out-alistmutual-recursion
(mutual-recursion (defun term-stobjs-out-alist
    (vars args alist wrld)
    (if (endp vars)
      nil
      (let ((st (term-stobjs-out (car args) alist wrld)) (rest (term-stobjs-out-alist (cdr vars) (cdr args) alist wrld)))
        (if (and st (symbolp st))
          (acons (car vars) st rest)
          rest))))
  (defun term-stobjs-out
    (term alist wrld)
    (cond ((variablep term) (or (cdr (assoc term alist))
          (and (getpropc term 'stobj nil wrld) term)))
      ((fquotep term) nil)
      (t (let ((fn (ffn-symb term)))
          (cond ((eq fn 'do$) (and (quotep (fargn term 5))
                (let ((lst (unquote (fargn term 5))))
                  (and (true-listp lst)
                    (if (null (cdr lst))
                      (car lst)
                      lst)))))
            ((eq fn 'return-last) (term-stobjs-out (car (last (fargs term))) alist wrld))
            ((member-eq fn '(nth mv-nth)) (let* ((arg1 (fargn term 1)) (n (and (quotep arg1) (cadr arg1))))
                (and (integerp n)
                  (<= 0 n)
                  (let ((term-stobjs-out (term-stobjs-out (fargn term 2) alist wrld)))
                    (and (consp term-stobjs-out) (nth n term-stobjs-out))))))
            ((eq fn 'update-nth) (term-stobjs-out (fargn term 3) alist wrld))
            ((flambdap fn) (let ((vars (lambda-formals fn)) (body (lambda-body fn)))
                (term-stobjs-out body
                  (term-stobjs-out-alist vars (fargs term) alist wrld)
                  wrld)))
            ((eq fn 'if) (or (term-stobjs-out (fargn term 2) alist wrld)
                (term-stobjs-out (fargn term 3) alist wrld)))
            ((eq fn 'read-user-stobj-alist) nil)
            (t (let ((lst (stobjs-out fn wrld)))
                (cond ((and (consp lst) (null (cdr lst))) (car lst))
                  (t lst))))))))))
accessor-rootfunction
(defun accessor-root
  (n term wrld)
  (let ((st (term-stobjs-out term
         (table-alist 'nth-aliases-table wrld)
         wrld)))
    (and st
      (symbolp st)
      (let ((accessor-names (getpropc st 'accessor-names nil wrld)))
        (and accessor-names
          (< n (car (dimensions st accessor-names)))
          (aref1 st accessor-names n))))))
progn!macro
(defmacro progn!
  (&rest r)
  (declare (xargs :guard (or (not (symbolp (car r)))
        (eq (car r) :state-global-bindings))))
  (cond ((and (consp r) (eq (car r) :state-global-bindings)) `(state-global-let* ,(CADR R)
        (progn!-fn ',(CDDR R) ',(CADR R) state)))
    (t `(progn!-fn ',R nil state))))
ld-redefinition-actionfunction
(defun ld-redefinition-action
  (state)
  (f-get-global 'ld-redefinition-action state))
chk-ld-redefinition-actionfunction
(defun chk-ld-redefinition-action
  (val ctx state)
  (cond ((or (null val)
       (and (consp val)
         (member-eq (car val) '(:query :warn :doit :warn! :doit!))
         (member-eq (cdr val) '(:erase :overwrite)))) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-redefinition-action val))))
set-ld-redefinition-actionfunction
(defun set-ld-redefinition-action
  (val state)
  (er-progn (chk-ld-redefinition-action val
      'set-ld-redefinition-action
      state)
    (pprogn (f-put-global 'ld-redefinition-action val state)
      (value val))))
redefmacro
(defmacro redef
  nil
  '(set-ld-redefinition-action '(:query . :overwrite) state))
redef!macro
(defmacro redef!
  nil
  '(set-ld-redefinition-action '(:warn! . :overwrite) state))
redef+macro
(defmacro redef+
  nil
  `(with-output :off (summary event)
    (progn (defttag :redef+)
      (progn! (set-ld-redefinition-action '(:warn! . :overwrite) state)
        (program)
        (set-temp-touchable-vars t state)
        (set-temp-touchable-fns t state)
        (f-put-global 'redundant-with-raw-code-okp t state)
        (set-state-ok t)))))
redef-macro
(defmacro redef-
  nil
  `(with-output :off (summary event)
    (progn (redef+)
      (progn! (f-put-global 'redundant-with-raw-code-okp nil state)
        (set-temp-touchable-vars nil state)
        (set-temp-touchable-fns nil state)
        (defttag nil)
        (logic)
        (set-ld-redefinition-action nil state)
        (set-state-ok nil)))))
chk-current-packagefunction
(defun chk-current-package
  (val ctx state)
  (cond ((find-non-hidden-package-entry val
       (known-package-alist state)) (value nil))
    (t (er soft ctx *ld-special-error* 'current-package val))))
set-current-packagefunction
(defun set-current-package
  (val state)
  (er-progn (chk-current-package val 'set-current-package state)
    (pprogn (f-put-global 'current-package val state)
      (value val))))
defun-for-state-namefunction
(defun defun-for-state-name
  (name)
  (add-suffix name "-STATE"))
error-free-triple-to-statemacro
(defmacro error-free-triple-to-state
  (ctx form)
  (declare (xargs :guard (and (consp ctx) (eq (car ctx) 'quote))))
  `(mv-let (erp val state)
    ,FORM
    (declare (ignore val))
    (prog2$ (and erp
        (er hard
          ,CTX
          "An error message may have been printed above."))
      state)))
defun-for-statemacro
(defmacro defun-for-state
  (name args)
  `(defun ,(DEFUN-FOR-STATE-NAME NAME)
    ,(IF (MEMBER-EQ 'STATE ARGS)
     ARGS
     (APPEND ARGS '(STATE)))
    (error-free-triple-to-state ',NAME (,NAME ,@ARGS))))
other
(defun-for-state set-current-package (val state))
standard-oifunction
(defun standard-oi
  (state)
  (f-get-global 'standard-oi state))
read-standard-oifunction
(defun read-standard-oi
  (state)
  (let ((standard-oi (standard-oi state)))
    (cond ((consp standard-oi) (let ((state (f-put-global 'standard-oi (cdr standard-oi) state)))
          (mv nil (car standard-oi) state)))
      ((null standard-oi) (mv t nil state))
      (t (read-object standard-oi state)))))
chk-standard-oifunction
(defun chk-standard-oi
  (val ctx state)
  (cond ((and (symbolp val) (open-input-channel-p val :object state)) (value nil))
    ((true-listp val) (value nil))
    ((and (consp val)
       (symbolp (cdr (last val)))
       (open-input-channel-p (cdr (last val)) :object state)) (value nil))
    (t (er soft ctx *ld-special-error* 'standard-oi val))))
set-standard-oifunction
(defun set-standard-oi
  (val state)
  (er-progn (chk-standard-oi val 'set-standard-oi state)
    (pprogn (f-put-global 'standard-oi val state) (value val))))
chk-standard-cofunction
(defun chk-standard-co
  (val ctx state)
  (cond ((and (symbolp val)
       (open-output-channel-p val :character state)) (value nil))
    (t (er soft ctx *ld-special-error* 'standard-co val))))
set-standard-cofunction
(defun set-standard-co
  (val state)
  (er-progn (chk-standard-co val 'set-standard-co state)
    (pprogn (f-put-global 'standard-co val state) (value val))))
proofs-cofunction
(defun proofs-co (state) (f-get-global 'proofs-co state))
chk-proofs-cofunction
(defun chk-proofs-co
  (val ctx state)
  (cond ((and (symbolp val)
       (open-output-channel-p val :character state)) (value nil))
    (t (er soft ctx *ld-special-error* 'proofs-co val))))
set-proofs-cofunction
(defun set-proofs-co
  (val state)
  (er-progn (chk-proofs-co val 'set-proofs-co state)
    (pprogn (f-put-global 'proofs-co val state) (value val))))
chk-trace-cofunction
(defun chk-trace-co
  (val ctx state)
  (cond ((and (symbolp val)
       (open-output-channel-p val :character state)) (value nil))
    (t (er soft ctx *state-global-error* 'trace-co val))))
set-trace-cofunction
(defun set-trace-co
  (val state)
  (er-progn (chk-trace-co val 'set-trace-co state)
    (pprogn (f-put-global 'trace-co val state) (value val))))
illegal-state-ld-promptfunction
(defun illegal-state-ld-prompt
  (channel state)
  (fmt1 "[Illegal-State] ~*0"
    (list (cons #\0
        (list ""
          ">"
          ">"
          ">"
          (make-list-ac (f-get-global 'ld-level state) nil nil))))
    0
    channel
    state
    nil))
ld-pre-eval-filterfunction
(defun ld-pre-eval-filter
  (state)
  (f-get-global 'ld-pre-eval-filter state))
illegal-state-pfunction
(defun illegal-state-p
  (state)
  (eq (ld-pre-eval-filter state) :illegal-state))
ld-promptfunction
(defun ld-prompt
  (state)
  (cond ((illegal-state-p state) 'illegal-state-ld-prompt)
    (t (f-get-global 'ld-prompt state))))
chk-ld-promptfunction
(defun chk-ld-prompt
  (val ctx state)
  (cond ((or (null val) (eq val t)) (value nil))
    (t (let ((wrld (w state)))
        (cond ((and (symbolp val)
             (equal (arity val wrld) 2)
             (equal (stobjs-in val wrld) '(nil state))
             (equal (stobjs-out val wrld) '(nil state))) (cond ((or (eq val 'brr-prompt)
                 (eq val 'wormhole-prompt)
                 (ttag wrld)) (value nil))
              (t (er soft
                  ctx
                  "It is illegal to set the ld-prompt to ~x0 ~
                                  unless there is an active trust ttag.  See ~
                                  :DOC ~x1."
                  val
                  'ld-prompt))))
          (t (er soft ctx *ld-special-error* 'ld-prompt val)))))))
set-ld-promptfunction
(defun set-ld-prompt
  (val state)
  (er-progn (chk-ld-prompt val 'set-ld-prompt state)
    (pprogn (f-put-global 'ld-prompt val state) (value val))))
ld-keyword-aliasesfunction
(defun ld-keyword-aliases
  (state)
  (table-alist 'ld-keyword-aliases (w state)))
ld-keyword-aliasespfunction
(defun ld-keyword-aliasesp
  (key val wrld)
  (and (keywordp key)
    (true-listp val)
    (int= (length val) 2)
    (let ((n (car val)) (fn (cadr val)))
      (and (natp n)
        (cond ((and (symbolp fn) (function-symbolp fn wrld)) (equal (arity fn wrld) n))
          ((and (symbolp fn) (getpropc fn 'macro-body nil wrld)) t)
          (t (and (true-listp fn)
              (>= (length fn) 3)
              (<= (length fn) 4)
              (eq (car fn) 'lambda)
              (arglistp (cadr fn))
              (int= (length (cadr fn)) n))))))))
other
(set-table-guard ld-keyword-aliases
  (ld-keyword-aliasesp key val world)
  :show t)
add-ld-keyword-alias!macro
(defmacro add-ld-keyword-alias!
  (key val)
  `(with-output :off (event summary)
    (progn (table ld-keyword-aliases ,KEY ,VAL)
      (table ld-keyword-aliases))))
add-ld-keyword-aliasmacro
(defmacro add-ld-keyword-alias
  (key val)
  `(local (add-ld-keyword-alias! ,KEY ,VAL)))
set-ld-keyword-aliases!macro
(defmacro set-ld-keyword-aliases!
  (alist)
  `(with-output :off (event summary)
    (progn (table ld-keyword-aliases nil ',ALIST :clear)
      (table ld-keyword-aliases))))
set-ld-keyword-aliasesmacro
(defmacro set-ld-keyword-aliases
  (alist &optional state)
  (declare (ignore state))
  `(local (set-ld-keyword-aliases! ,ALIST)))
ld-missing-input-okfunction
(defun ld-missing-input-ok
  (state)
  (f-get-global 'ld-missing-input-ok state))
chk-ld-missing-input-okfunction
(defun chk-ld-missing-input-ok
  (val ctx state)
  (cond ((or (member-eq val '(t nil :warn)) (msgp val)) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-missing-input-ok val))))
set-ld-missing-input-okfunction
(defun set-ld-missing-input-ok
  (val state)
  (er-progn (chk-ld-missing-input-ok val 'set-ld-missing-input-ok state)
    (pprogn (f-put-global 'ld-missing-input-ok val state)
      (value val))))
ld-always-skip-top-level-localsfunction
(defun ld-always-skip-top-level-locals
  (state)
  (f-get-global 'ld-always-skip-top-level-locals state))
chk-ld-always-skip-top-level-localsfunction
(defun chk-ld-always-skip-top-level-locals
  (val ctx state)
  (cond ((member-eq val '(t nil)) (value nil))
    (t (er soft
        ctx
        *ld-special-error*
        'ld-always-skip-top-level-locals
        val))))
set-ld-always-skip-top-level-localsfunction
(defun set-ld-always-skip-top-level-locals
  (val state)
  (er-progn (chk-ld-always-skip-top-level-locals val
      'set-ld-always-skip-top-level-locals
      state)
    (pprogn (f-put-global 'ld-always-skip-top-level-locals val state)
      (value val))))
new-namepfunction
(defun new-namep
  (name wrld)
  (declare (xargs :guard (and (symbolp name) (plist-worldp wrld))))
  (let ((redefined (getpropc name 'redefined nil wrld)))
    (cond ((and (consp redefined) (eq (car redefined) :erase)) (not (has-propsp name
            '(redefined global-value table-alist table-guard)
            'current-acl2-world
            wrld
            nil)))
      ((and (consp redefined)
         (or (eq (car redefined) :overwrite)
           (eq (car redefined) :reclassifying-overwrite))) (not (has-propsp name
            '(redefined lemmas
              global-value
              label
              linear-lemmas
              forward-chaining-rules
              eliminate-destructors-rules
              coarsenings
              congruences
              pequivs
              induction-rules
              theorem
              untranslated-theorem
              classes
              const
              theory
              table-guard
              table-alist
              macro-body
              macro-args
              predefined
              tau-pair
              pos-implicants
              neg-implicants
              unevalable-but-known
              signature-rules-form-1
              signature-rules-form-2
              big-switch
              tau-bounders-form-1
              tau-bounders-form-2)
            'current-acl2-world
            wrld
            nil)))
      (t (not (has-propsp name
            '(global-value table-alist table-guard)
            'current-acl2-world
            wrld
            nil))))))
attach-stobj-guard-msgfunction
(defun attach-stobj-guard-msg
  (gen impl wrld)
  (declare (xargs :guard (plist-worldp wrld)))
  (cond ((not (and (symbolp gen) (symbolp impl))) (msg "The arguments to ~x0 must evaluate to symbols but ~&1 ~
               ~#1~[is not a symbol~/are not symbols~]."
        'attach-stobj
        (append (if (symbolp gen)
            nil
            (list gen))
          (if (symbolp impl)
            nil
            (list impl)))))
    ((not (new-namep gen wrld)) (msg "The name ~x0 is in use, so it cannot serve here as an ~
               attachable stobj.  See :DOC attach-stobj."
        gen))
    ((or (null impl) (getpropc impl 'absstobj-info nil wrld)) nil)
    (t (msg "Since ~x0 is not currently the name of an abstract stobj, it ~
               is not available to be attached to a stobj.  See :DOC ~
               attach-stobj."
        impl))))
attach-stobj-guardfunction
(defun attach-stobj-guard
  (gen impl wrld)
  (declare (xargs :guard (plist-worldp wrld)))
  (null (attach-stobj-guard-msg gen impl wrld)))
other
(set-table-guard attach-stobj-table
  (attach-stobj-guard key val world)
  :topic attach-stobj
  :coda (attach-stobj-guard-msg key val world))
attach-stobjmacro
(defmacro attach-stobj
  (gen impl)
  `(with-output :off (event summary)
    (table attach-stobj-table ',GEN ',IMPL)))
chk-ld-pre-eval-filterfunction
(defun chk-ld-pre-eval-filter
  (val ctx state)
  (cond ((or (member-eq val '(:all :query :illegal-state))
       (and (symbolp val)
         (not (keywordp val))
         (not (equal (symbol-package-name val) *main-lisp-package-name*))
         (new-namep val (w state)))) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-pre-eval-filter val))))
set-ld-pre-eval-filterfunction
(defun set-ld-pre-eval-filter
  (val state)
  (er-progn (chk-ld-pre-eval-filter val 'set-ld-pre-eval-filter state)
    (pprogn (f-put-global 'ld-pre-eval-filter val state)
      (value val))))
ld-pre-eval-printfunction
(defun ld-pre-eval-print
  (state)
  (f-get-global 'ld-pre-eval-print state))
chk-ld-pre-eval-printfunction
(defun chk-ld-pre-eval-print
  (val ctx state)
  (cond ((member-eq val '(nil t :never)) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-pre-eval-print val))))
set-ld-pre-eval-printfunction
(defun set-ld-pre-eval-print
  (val state)
  (er-progn (chk-ld-pre-eval-print val 'set-ld-pre-eval-print state)
    (pprogn (f-put-global 'ld-pre-eval-print val state)
      (value val))))
ld-post-eval-printfunction
(defun ld-post-eval-print
  (state)
  (f-get-global 'ld-post-eval-print state))
chk-ld-post-eval-printfunction
(defun chk-ld-post-eval-print
  (val ctx state)
  (cond ((member-eq val '(nil t :command-conventions)) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-post-eval-print val))))
set-ld-post-eval-printfunction
(defun set-ld-post-eval-print
  (val state)
  (er-progn (chk-ld-post-eval-print val 'set-ld-post-eval-print state)
    (pprogn (f-put-global 'ld-post-eval-print val state)
      (value val))))
ld-error-triplesfunction
(defun ld-error-triples
  (state)
  (f-get-global 'ld-error-triples state))
chk-ld-error-triplesfunction
(defun chk-ld-error-triples
  (val ctx state)
  (cond ((member-eq val '(nil t)) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-error-triples val))))
set-ld-error-triplesfunction
(defun set-ld-error-triples
  (val state)
  (er-progn (chk-ld-error-triples val 'set-ld-error-triples state)
    (pprogn (f-put-global 'ld-error-triples val state)
      (value val))))
ld-error-actionfunction
(defun ld-error-action
  (state)
  (f-get-global 'ld-error-action state))
chk-ld-error-actionfunction
(defun chk-ld-error-action
  (val ctx state)
  (cond ((member-eq val '(:continue :return :return! :error)) (value nil))
    ((and (consp val)
       (eq (car val) :exit)
       (consp (cdr val))
       (natp (cadr val))
       (null (cddr val))) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-error-action val))))
set-ld-error-actionfunction
(defun set-ld-error-action
  (val state)
  (er-progn (chk-ld-error-action val 'set-ld-error-action state)
    (pprogn (f-put-global 'ld-error-action val state)
      (value val))))
ld-query-control-alistfunction
(defun ld-query-control-alist
  (state)
  (f-get-global 'ld-query-control-alist state))
ld-query-control-alistpfunction
(defun ld-query-control-alistp
  (val)
  (cond ((atom val) (or (eq val nil) (eq val t)))
    ((and (consp (car val))
       (symbolp (caar val))
       (or (eq (cdar val) nil)
         (eq (cdar val) t)
         (keywordp (cdar val))
         (and (consp (cdar val))
           (keywordp (cadar val))
           (null (cddar val))))) (ld-query-control-alistp (cdr val)))
    (t nil)))
cdr-assoc-query-idfunction
(defun cdr-assoc-query-id
  (id alist)
  (cond ((atom alist) alist)
    ((eq id (caar alist)) (cdar alist))
    (t (cdr-assoc-query-id id (cdr alist)))))
chk-ld-query-control-alistfunction
(defun chk-ld-query-control-alist
  (val ctx state)
  (cond ((ld-query-control-alistp val) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-query-control-alist val))))
set-ld-query-control-alistfunction
(defun set-ld-query-control-alist
  (val state)
  (er-progn (chk-ld-query-control-alist val
      'set-ld-query-control-alist
      state)
    (pprogn (f-put-global 'ld-query-control-alist val state)
      (value val))))
ld-verbosefunction
(defun ld-verbose (state) (f-get-global 'ld-verbose state))
chk-ld-verbosefunction
(defun chk-ld-verbose
  (val ctx state)
  (cond ((or (stringp val) (and (consp val) (stringp (car val)))) (value nil))
    ((member-eq val '(nil t)) (value nil))
    (t (er soft ctx *ld-special-error* 'ld-verbose val))))
set-ld-verbosefunction
(defun set-ld-verbose
  (val state)
  (er-progn (chk-ld-verbose val 'set-ld-verbose state)
    (pprogn (f-put-global 'ld-verbose val state) (value val))))
chk-ld-user-stobjs-modified-warningfunction
(defun chk-ld-user-stobjs-modified-warning
  (val ctx state)
  (cond ((member-eq val '(nil t :same)) (value nil))
    (t (er soft
        ctx
        *ld-special-error*
        'ld-user-stobjs-modified-warning
        val))))
set-ld-user-stobjs-modified-warningfunction
(defun set-ld-user-stobjs-modified-warning
  (val state)
  (er-progn (chk-ld-user-stobjs-modified-warning val
      'set-ld-user-stobjs-modified-warning
      state)
    (pprogn (f-put-global 'ld-user-stobjs-modified-warning val state)
      (value val))))
*nqthm-to-acl2-primitives*constant
(defconst *nqthm-to-acl2-primitives*
  '((add1 1+) (add-to-set add-to-set-equal add-to-set-eq)
    (and and)
    (append append binary-append)
    (apply-subr . "Doesn't correspond to anything in ACL2, really.
                     See the documentation for DEFEVALUATOR and META.")
    (apply$ . "See the documentation for DEFEVALUATOR and META.")
    (assoc assoc-equal assoc assoc-eq)
    (body . "See the documentation for DEFEVALUATOR and META.")
    (car car)
    (cdr cdr)
    (cons cons)
    (count acl2-count)
    (difference -)
    (equal equal eq eql =)
    (eval$ . "See the documentation for DEFEVALUATOR and META.")
    (false . "Nqthm's F corresponds to the ACL2 symbol NIL.")
    (falsep not null)
    (formals . "See the documentation for DEFEVALUATOR and META.")
    (geq >=)
    (greaterp >)
    (identity identity)
    (if if)
    (iff iff)
    (implies implies)
    (leq <=)
    (lessp <)
    (listp consp)
    (litatom symbolp)
    (max max)
    (member member-equal member member-eq)
    (minus - unary--)
    (negativep minusp)
    (negative-guts abs)
    (nlistp atom)
    (not not)
    (numberp acl2-numberp integerp rationalp)
    (or or)
    (ordinalp o-p)
    (ord-lessp o<)
    (pack . "See INTERN and COERCE.")
    (pairlist pairlis$)
    (plus + binary-+)
    (quotient /)
    (remainder rem mod)
    (strip-cars strip-cars)
    (sub1 1-)
    (times * binary-*)
    (true . "The symbol T.")
    (union union-equal union-eq)
    (unpack . "See SYMBOL-NAME and COERCE.")
    (v&c$ . "See the documentation for DEFEVALUATOR and META.")
    (v&c-apply$ . "See the documentation for DEFEVALUATOR and META.")
    (zero . "The number 0.")
    (zerop zerop)))
*nqthm-to-acl2-commands*constant
(defconst *nqthm-to-acl2-commands*
  '((accumulated-persistence accumulated-persistence) (add-axiom defaxiom)
    (add-shell . "There is no shell principle in ACL2.")
    (axiom defaxiom)
    (backquote-setting . "Backquote is supported in ACL2, but not
                     currently documented.")
    (boot-strap ground-zero)
    (break-lemma monitor)
    (break-rewrite break-rewrite)
    (ch pbt . "See also :DOC history.")
    (chronology pbt . "See also :DOC history.")
    (comment deflabel)
    (compile-uncompiled-defns comp)
    (constrain . "See :DOC encapsulate and :DOC local.")
    (data-base . "Perhaps the closest ACL2 analogue of DATA-BASE
                     is PROPS.  But see :DOC history for a collection
                     of commands for querying the ACL2 database
                     (``world'').  Note that the notions of
                     supporters and dependents are not supported in
                     ACL2.")
    (dcl defstub)
    (defn defun defmacro)
    (deftheory deftheory)
    (disable disable)
    (disable-theory . "See :DOC theories.  The Nqthm command
                     (DISABLE-THEORY FOO) corresponds roughly to the
                     ACL2 command
                     (in-theory (set-difference-theories
                                  (current-theory :here)
                                  (theory 'foo))).")
    (do-events ld)
    (do-file ld)
    (elim elim)
    (enable enable)
    (enable-theory . "See :DOC theories.  The Nqthm command
                     (ENABLE-THEORY FOO) corresponds roughly to the
                     ACL2 command
                     (in-theory (union-theories
                                  (theory 'foo)
                                  (current-theory :here))).")
    (events-since pbt)
    (functionally-instantiate . "ACL2 provides a form of the :USE hint that
                     corresponds roughly to the
                     FUNCTIONALLY-INSTANTIATE event of Nqthm. See
                     :DOC lemma-instance.")
    (generalize generalize)
    (hints hints)
    (lemma defthm)
    (maintain-rewrite-path brr)
    (make-lib . "There is no direct analogue of Nqthm's notion of
                     ``library.''  See :DOC books for a description
                     of ACL2's mechanism for creating and saving
                     collections of events.")
    (meta meta)
    (names name)
    (note-lib include-book)
    (ppe pe)
    (prove thm)
    (proveall . "See :DOC ld and :DOC certify-book.  The latter
                     corresponds to Nqthm's PROVE-FILE,which may be
                     what you're interested in, really.")
    (prove-file certify-book)
    (prove-file-out certify-book)
    (prove-lemma defthm . "See also :DOC hints.")
    (r-loop . "The top-level ACL2 loop is an evaluation loop as
                     well, so no analogue of R-LOOP is necessary.")
    (rewrite rewrite)
    (rule-classes rule-classes)
    (set-status in-theory)
    (skim-file ld-skip-proofsp)
    (toggle in-theory)
    (toggle-defined-functions executable-counterpart-theory)
    (translate trans trans1)
    (ubt ubt u)
    (unbreak-lemma unmonitor)
    (undo-back-through ubt)
    (undo-name . "See :DOC ubt.  There is no way to undo names in
                     ACL2 without undoing back through such names.
                     However, see :DOC ld-skip-proofsp for
                     information about how to quickly recover the
                     state.")))
nqthm-to-acl2-fnfunction
(defun nqthm-to-acl2-fn
  (name state)
  (declare (xargs :guard (symbolp name)))
  (io? temporary
    nil
    (mv erp val state)
    (name)
    (let ((prims (cdr (assoc-eq name *nqthm-to-acl2-primitives*))) (comms (cdr (assoc-eq name *nqthm-to-acl2-commands*))))
      (pprogn (cond (prims (let ((syms (fix-true-list prims)) (info (if (consp prims)
                    (cdr (last prims))
                    prims)))
              (pprogn (if syms
                  (fms "Related ACL2 primitives (use :PE or see documentation ~
                         to learn more):  ~&0.~%"
                    (list (cons #\0 syms))
                    *standard-co*
                    state
                    nil)
                  state)
                (if info
                  (pprogn (fms info (list (cons #\0 syms)) *standard-co* state nil)
                    (newline *standard-co* state))
                  state))))
          (t state))
        (cond (comms (let ((syms (fix-true-list comms)) (info (if (consp comms)
                    (cdr (last comms))
                    comms)))
              (pprogn (if syms
                  (fms "Related ACL2 commands (use :PE or see documentation ~
                         to learn more):  ~&0.~%"
                    (list (cons #\0 syms))
                    *standard-co*
                    state
                    nil)
                  state)
                (if info
                  (pprogn (fms info (list (cons #\0 syms)) *standard-co* state nil)
                    (newline *standard-co* state))
                  state))))
          (t state))
        (if (or prims comms)
          (value :invisible)
          (pprogn (fms "Sorry, but there seems to be no ACL2 notion corresponding ~
                   to the alleged Nqthm notion ~x0.~%"
              (list (cons #\0 name))
              *standard-co*
              state
              nil)
            (value :invisible)))))))
nqthm-to-acl2macro
(defmacro nqthm-to-acl2
  (x)
  (declare (xargs :guard (and (true-listp x)
        (equal (length x) 2)
        (eq (car x) 'quote)
        (symbolp (cadr x)))))
  `(nqthm-to-acl2-fn ,X state))
allocate-fixnum-rangefunction
(defun allocate-fixnum-range
  (fixnum-lo fixnum-hi)
  (declare (xargs :guard (and (integerp fixnum-lo)
        (integerp fixnum-hi)
        (>= fixnum-hi fixnum-lo)))
    (type (signed-byte 61) fixnum-lo fixnum-hi))
  (let ((tmp (- fixnum-hi fixnum-lo)))
    (declare (ignore tmp))
    nil))
allegro-allocate-slowly-fnfunction
(defun allegro-allocate-slowly-fn
  (free-bytes-new-other free-bytes-new-pages
    free-percent-new
    expansion-free-percent-old
    expansion-free-percent-new)
  (declare (ignore free-bytes-new-other
      free-bytes-new-pages
      free-percent-new
      expansion-free-percent-old
      expansion-free-percent-new))
  nil)
clear-pstkmacro
(defmacro clear-pstk nil nil)
*pstk-vars*constant
(defconst *pstk-vars*
  '(pstk-var-0 pstk-var-1
    pstk-var-2
    pstk-var-3
    pstk-var-4
    pstk-var-5
    pstk-var-6
    pstk-var-7
    pstk-var-8
    pstk-var-9
    pstk-var-10
    pstk-var-11
    pstk-var-12))
pstk-bindings-and-argsfunction
(defun pstk-bindings-and-args
  (args vars)
  (cond ((endp args) (mv nil nil nil))
    ((endp vars) (mv (er hard
          'pstk-bindings-and-args
          "The ACL2 sources need *pstk-vars* to be extended.")
        nil
        nil))
    (t (mv-let (bindings rest-args fake-args)
        (pstk-bindings-and-args (cdr args) (cdr vars))
        (cond ((eq (car args) 'state) (mv bindings
              (cons (car args) rest-args)
              (cons ''<state> rest-args)))
          ((symbolp (car args)) (mv bindings
              (cons (car args) rest-args)
              (cons (car args) fake-args)))
          (t (mv (cons (list (car vars) (car args)) bindings)
              (cons (car vars) rest-args)
              (cons (car vars) fake-args))))))))
pstkmacro
(defmacro pstk
  (form)
  (declare (xargs :guard (consp form)))
  `(check-vars-not-free ,*PSTK-VARS* ,FORM))
pstack-fnfunction
(defun pstack-fn
  (allp state)
  (declare (ignore allp))
  (value :invisible))
pstackmacro
(defmacro pstack (&optional allp) `(pstack-fn ,ALLP state))
verbose-pstackfunction
(defun verbose-pstack
  (flg-or-list)
  (declare (xargs :guard (or (eq flg-or-list t)
        (eq flg-or-list nil)
        (symbol-listp flg-or-list))))
  flg-or-list)
set-print-clause-idsmacro
(defmacro set-print-clause-ids
  (flg)
  (declare (xargs :guard (member-equal flg '(t 't nil 'nil))))
  (let ((flg (if (atom flg)
         (list 'quote flg)
         flg)))
    `(f-put-global 'print-clause-ids ,FLG state)))
set-saved-output-token-lstfunction
(defun set-saved-output-token-lst
  (save-flg state)
  (declare (xargs :stobjs state))
  (cond ((member-eq save-flg '(t :all)) (f-put-global 'saved-output-token-lst :all state))
    ((null save-flg) (f-put-global 'saved-output-token-lst nil state))
    ((true-listp save-flg) (f-put-global 'saved-output-token-lst save-flg state))
    (t (prog2$ (er hard
          'set-saved-output
          "Illegal first argument to set-saved-output-token-lst ~
                        (must be ~x0 or a true-listp): ~x1."
          t
          save-flg)
        state))))
set-gag-mode-fnfunction
(defun set-gag-mode-fn
  (action state)
  (let ((action (if (and (consp action)
           (consp (cdr action))
           (eq (car action) 'quote))
         (cadr action)
         action)))
    (pprogn (case action
        ((t) (pprogn (set-saved-output-token-lst t state)
            (set-print-clause-ids nil)))
        (:goals (pprogn (set-saved-output-token-lst t state)
            (set-print-clause-ids t)))
        ((nil) (pprogn (set-saved-output-token-lst nil state)
            (set-print-clause-ids nil)))
        (otherwise (prog2$ (er hard
              'set-gag-mode
              "Unknown set-gag-mode argument, ~x0"
              action)
            state)))
      (f-put-global 'gag-mode action state))))
set-gag-modemacro
(defmacro set-gag-mode
  (action)
  `(set-gag-mode-fn ,ACTION state))
pop-inhibit-output-lst-stackfunction
(defun pop-inhibit-output-lst-stack
  (state)
  (let ((stk (f-get-global 'inhibit-output-lst-stack state)))
    (cond ((atom stk) state)
      ((atom (car stk)) (f-put-global 'inhibit-output-lst-stack (cdr stk) state))
      (t (pprogn (set-inhibit-output-lst-state (caar stk) state)
          (set-gag-mode (cdar stk))
          (f-put-global 'inhibit-output-lst-stack (cdr stk) state))))))
push-inhibit-output-lst-stackfunction
(defun push-inhibit-output-lst-stack
  (state)
  (f-put-global 'inhibit-output-lst-stack
    (cons (cons (f-get-global 'inhibit-output-lst state)
        (f-get-global 'gag-mode state))
      (f-get-global 'inhibit-output-lst-stack state))
    state))
set-gc-threshold$-fnfunction
(defun set-gc-threshold$-fn
  (new-threshold verbose-p)
  (declare (ignorable verbose-p))
  (let ((ctx 'set-gc-threshold$))
    (cond ((not (posp new-threshold)) (er hard
          ctx
          "The argument to set-gc-threshold$ must be a positive integer, so ~
           the value ~x0 is illegal."
          new-threshold))
      (t t))))
set-gc-threshold$macro
(defmacro set-gc-threshold$
  (new-threshold &optional (verbose-p 't))
  `(set-gc-threshold$-fn ,NEW-THRESHOLD ,VERBOSE-P))