;;; This is a -*-Lisp-*- file.
;;;
;;; **********************************************************************
;;; This code was written as part of the Spice Lisp project at
;;; Carnegie-Mellon University, and has been placed in the public domain.
;;; Spice Lisp is currently incomplete and under active development.
;;; If you want to use this code or any part of Spice Lisp, please contact
;;; Scott Fahlman (FAHLMAN@CMUC). 
;;; **********************************************************************
;;;
;;; Data Base of Built-In Functions, Special Forms, and Variables in
;;; Spice Lisp.
;;; Written by Scott Fahlman and Skef Wholey.
;;; Currently maintained by Scott Fahlman.
;;;
;;; **********************************************************************

;;; This file contains an entry for each function, special form, or macro
;;; built into the standard Common Lisp environment, plus some additional
;;; sub-primitives generated internally.  For each function, record the
;;; following:

;;; 1. Whether it is a function (expr) or special form (fexpr).
;;; 2. Minimum and maximum number of args.  For fexprs and macros, this
;;;    really refers to the minimum and maximum length of the calling form.
;;;    The MAX value may be NIL, meaning infinite.
;;; 3. A marker indicating whether the form evals all its args and is free
;;;    of side effects.  Such forms turn into PROGN if the caller doesn't
;;;    want the value.
;;; 4. An indicator of the type of result returned by this form, as a type
;;;    specifier.  In some cases, we want to put T in this slot and add
;;;    a RESULT-FUNCTION property instead.

(defun built-in-fn (fn nargs side-effect-free result-type
		       &optional (result-function nil) (maybe-multiple nil))
  (let ((new-args (if (not (listp nargs))
		      (cons nargs nargs)
		      (cons (car nargs) (cadr nargs)))))
    (%put fn 'declared-function-type 'expr)
    (%put fn 'clc-args new-args)
    (if side-effect-free
	(%put fn 'expr-with-no-side-effects t))
    (if (not (eq result-type t))
	(%put fn 'result-type result-type))
    (if result-function
	(%put fn 'result-function result-function))
    (unless maybe-multiple
	(%put fn 'single-value t))
    fn))


(defun built-in-sf (fn nargs side-effect-free result-type
		       &optional (result-function nil) (maybe-multiple nil))
  (let ((new-args (if (not (listp nargs))
		      (cons nargs nargs)
		      (cons (car nargs) (cadr nargs)))))
    (%put fn 'declared-function-type 'fexpr)
    (%put fn 'clc-args new-args)
    (if side-effect-free
	(%put fn 'expr-with-no-side-effects t))
    (if (not (eq result-type t))
	(%put fn 'result-type result-type))
    (if result-function
	(%put fn 'result-function result-function))
    (unless maybe-multiple
	(%put fn 'single-value t))
    fn))


;;; Function for globally declaring variables in this file.

(defun built-in-special (var type)
  (%put var 'globally-special t)
  (%put var 'globally-special-type type)
  var)


;;; The following functions declare that the return from a function is of
;;; the same type as the return from one of its arguments.

(defun result-type-arg1 (args)
  (find-type (car args)))

(defun result-type-arg2 (args)
  (find-type (cadr args)))

(defun result-type-arg3 (args)
  (find-type (caddr args)))

(defun type-spec-arg1 (args)
  (cond ((and (listp (car args))
	      (eq (caar args) 'quote))
	 (let ((type (cadr (car args))))
	   (if (atom type) type (car type))))
	(t t)))

(defun type-spec-arg2 (args)
  (cond ((and (listp (cadr args))
	     (eq (car (cadr args)) 'quote))
	 (let ((type (cadr (cadr args))))
	   (if (atom type) type (car type))))
	(t t)))

(defun the-result-type (args)
  (car args))

(defun float-result-type (args)
  (cond ((atom (cdr args)) 'single-float)
	((numberp (cadr args))
	 (find-type (cadr args)))
	(t 'number)))

;;; Here is the data base of built-in functions and special forms,
;;; following the function summary from the current manual.  Macros
;;; are set up in the MACROS file, so don't need entries here. 

(built-in-fn 'coerce 2 nil t 'type-spec-arg2)
(built-in-fn 'type-of 1 t t)

;; In the "Program Structure" chapter.

(built-in-special 'lambda-list-keywords 'list)
(built-in-special 'lambda-paramters-limit 'fixnum)
(built-in-sf 'defun '(2) nil 'symbol)
(built-in-sf 'eval-when '(1) nil t)

;;; In the "Predicates" chapter:

(built-in-fn 'typep 2 t 'predicate)
(built-in-fn 'subtypep 2 t 'predicate nil 'multiple)
(built-in-fn 'null 1 t 'predicate)
(built-in-fn 'symbolp 1 t 'predicate)
(built-in-fn 'atom 1 t 'predicate)
(built-in-fn 'consp 1 t 'predicate)
(built-in-fn 'listp 1 t 'predicate)
(built-in-fn 'numberp 1 t 'predicate)
(built-in-fn 'integerp 1 t 'predicate)
(built-in-fn 'rationalp 1 t 'predicate)
(built-in-fn 'floatp 1 t 'predicate)
(built-in-fn 'complexp 1 t 'predicate)
(built-in-fn 'characterp 1 t 'predicate)
(built-in-fn 'stringp 1 t 'predicate)
(built-in-fn 'bit-vector-p 1 t 'predicate)
(built-in-fn 'vectorp 1 t 'predicate)
(built-in-fn 'simple-vector-p 1 t 'predicate)
(built-in-fn 'simple-string-p 1 t 'predicate)
(built-in-fn 'simple-bit-vector-p 1 t 'predicate)
(built-in-fn 'arrayp 1 t 'predicate)
(built-in-fn 'packagep 1 t 'predicate)
(built-in-fn 'functionp 1 t 'predicate)
(built-in-fn 'compiled-function-p 1 t 'predicate)
(built-in-fn 'commonp 1 t 'predicate)
(built-in-fn 'eq 2 t 'predicate)
(built-in-fn 'eql 2 t 'predicate)
(built-in-fn 'equal 2 t 'predicate)
(built-in-fn 'equalp 2 t 'predicate)
(built-in-fn 'not 1 t 'predicate)
(built-in-sf 'and '(0) nil t)
(built-in-sf 'or '(0) nil t)

;;; In the "Control Structure" chapter:

(built-in-sf 'quote 1 nil t)
(built-in-sf 'function 1 nil t)
(built-in-fn 'symbol-value 1 t t)
(built-in-fn 'symbol-function 1 t t)
(built-in-fn 'boundp 1 t 'predicate)
(built-in-fn 'fboundp 1 t 'predicate)
(built-in-fn 'special-form-p 1 t t)
(built-in-sf 'setq '(0) nil t)
(built-in-sf 'psetq '(0) nil t)
(built-in-fn 'set 2 nil t 'result-type-arg2)
(built-in-fn 'makunbound 1 nil 'symbol)
(built-in-fn 'fmakunbound 1 nil 'symbol)
(built-in-fn 'get-setf-method 1 t t)
(built-in-fn 'get-setf-method-multiple-value 1 t t)
(built-in-fn 'apply '(2) nil t)
(built-in-fn 'funcall '(1) nil t)
(built-in-special 'call-arguments-limit 'fixnum)
(built-in-sf 'progn '(0) nil t)
(built-in-sf 'prog1 '(1) nil t)
(built-in-sf 'prog2 '(2) nil t)
(built-in-sf 'let '(1) nil t)
(built-in-sf 'let* '(1) nil t)
(built-in-sf 'compiler-let '(1) nil t)
(built-in-sf 'progv '(2) nil t)
(built-in-sf 'flet '(1) nil t)
(built-in-sf 'labels '(1) nil t)
(built-in-sf 'macrolet '(1) nil t)
(built-in-sf 'cond '(0) nil t)
(built-in-sf 'if '(2 3) nil t)
(built-in-sf 'block '(1) nil t)
(built-in-sf 'return-from '(1 2) nil t)
(built-in-fn 'mapcar '(2) nil 'list)
(built-in-fn 'maplist '(2) nil 'list)
(built-in-fn 'mapc '(2) nil t)
(built-in-fn 'mapl '(2) nil t)
(built-in-fn 'mapcan '(2) nil 'list)
(built-in-fn 'mapcon '(2) nil 'list)
(built-in-sf 'tagbody '(0) nil t)
(built-in-sf 'prog '(1) nil t)
(built-in-sf 'prog* '(1) nil t)
(built-in-sf 'go 1 nil t)
(built-in-fn 'values '(0) t t nil 'multiple)
(built-in-special 'multiple-values-limit 'fixnum)
(built-in-fn 'values-list 1 t t  nil 'multiple)
(built-in-sf 'multiple-value-list 1 t 'list)
(built-in-sf 'multiple-value-call '(1) nil t)
(built-in-sf 'multiple-value-prog1 '(1) nil t)
(built-in-sf 'multiple-value-bind '(2) nil t)
(built-in-sf 'multiple-value-setq 2 nil t)
(built-in-sf 'catch '(1) nil t)
(built-in-sf 'unwind-protect '(1) nil t)
(built-in-sf 'throw 2 nil t)

;;; In the "Macros" chapter:

(built-in-fn 'macro-function 1 nil t)
(built-in-fn 'macroexpand '(1 5) nil 'list  nil 'multiple)
(built-in-fn 'macroexpand-1 '(1 5) nil 'list  nil 'multiple)
(built-in-special '*macroexpand-hook* t)

;;; In the "Declarations" chapter:

(built-in-fn 'proclaim 1 nil t)
(built-in-sf 'the 2 nil t 'the-result-type)

;;; In the "Symbols" chapter:

(built-in-fn 'get '(2 3) t t)
(built-in-fn 'remprop 2 nil t)
(built-in-fn 'symbol-plist 1 t 'list)
(built-in-fn 'getf '(2 3) t t)
(built-in-fn 'get-properties 2 t t nil 'multiple)

(built-in-fn 'symbol-name 1 t 'simple-string)
(built-in-fn 'samenamep 2 t 'predicate)
(built-in-fn 'make-symbol 1 t 'symbol)
(built-in-fn 'copy-symbol '(1 2) t 'symbol)
(built-in-fn 'gensym '(0 1) nil 'symbol)
(built-in-fn 'gentemp '(0 2) nil 'symbol)
(built-in-fn 'symbol-package 1 t 'package)
(built-in-fn 'keywordp  1 t 'predicate)

;;; In the "Packages" chapter:

(built-in-special '*package* 'package)
(built-in-fn 'make-package '(1) nil 'package)
(built-in-fn 'in-package '(1) nil t)
(built-in-fn 'find-package 1 t 'package)
(built-in-fn 'package-name 1 t 'simple-string)
(built-in-fn 'package-nicknames 1 t 'list)
(built-in-fn 'rename-package '(2 3) nil t)
(built-in-fn 'package-use-list 1 t 'list)
(built-in-fn 'package-used-by-list 1 t 'list)
(built-in-fn 'package-shadowing-symbols 1 t 'list)
(built-in-fn 'list-all-packages 0 t 'list)
(built-in-fn 'intern '(1 2) nil 'symbol nil 'multiple)
(built-in-fn 'find-symbol '(1 2) t 'symbol nil 'multiple)
(built-in-fn 'unintern '(1 2) nil 'predicate)
(built-in-fn 'export '(1 2) nil 'symbol)
(built-in-fn 'unexport '(1 2) nil 'symbol)
(built-in-fn 'import '(1 2) nil 'symbol)
(built-in-fn 'shadowing-import '(1 2) nil 'symbol)
(built-in-fn 'shadow '(1 2) nil 'symbol)
(built-in-fn 'use-package '(1 2) nil 'symbol)
(built-in-fn 'ususe-package '(1 2) nil 'symbol)
(built-in-fn 'find-all-symbols 1 t 'list)
(built-in-special '*modules* 'list)
(built-in-fn 'provide 1 nil t)
(built-in-fn 'require '(1 2) nil t)

;;; In the "Numbers" chapter:

(built-in-fn 'zerop 1 t 'predicate)
(built-in-fn 'plusp 1 t 'predicate)
(built-in-fn 'minusp 1 t 'predicate)
(built-in-fn 'oddp 1 t 'predicate)
(built-in-fn 'evenp 1 t 'predicate)

(built-in-fn '= '(1) t 'predicate)
(built-in-fn '/= '(1) t 'predicate)
(built-in-fn '< '(1) t 'predicate)
(built-in-fn '> '(1) t 'predicate)
(built-in-fn '<= '(1) t 'predicate)
(built-in-fn '>= '(1) t 'predicate)
(built-in-fn 'max '(1) t t 'numeric-result-type)
(built-in-fn 'min '(1) t t 'numeric-result-type)
(built-in-fn '+ '(0) t t 'numeric-result-type)
(built-in-fn '- '(1) t t 'numeric-result-type)
(built-in-fn '* '(0) t t 'numeric-result-type)
(built-in-fn '/ '(1) t t '/-result-type)
(built-in-fn '1+ 1 t t 'numeric-result-type1)
(built-in-fn '1- 1 t t 'numeric-result-type1)
(built-in-fn 'conjugate 1 t 'number)
(built-in-fn 'gcd '(0) t t 'boolean-result-type)
(built-in-fn 'lcm '(1) t 'integer)

(built-in-fn 'exp 1 t 'number)
(built-in-fn 'expt 2 t 'number)
(built-in-fn 'log '(1 2) t 'number)
(built-in-fn 'sqrt 1 t 'number)
(built-in-fn 'isqrt 1 t 'integer)
(built-in-fn 'abs 1 t 'number)
(built-in-fn 'phase 1 t 'number)
(built-in-fn 'signum 1 t 'number)
(built-in-fn 'sin 1 t 'number)
(built-in-fn 'cos 1 t 'number)
(built-in-fn 'tan 1 t 'number)
(built-in-fn 'cis 1 t 'number)
(built-in-fn 'asin 1 t 'number)
(built-in-fn 'acos 1 t 'number)
(built-in-fn 'atan '(1 2) t 'number)
(built-in-special 'pi 'long-float)
(built-in-fn 'sinh 1 t 'number)
(built-in-fn 'cosh 1 t 'number)
(built-in-fn 'tanh 1 t 'number)
(built-in-fn 'asinh 1 t 'number)
(built-in-fn 'acosh 1 t 'number)
(built-in-fn 'atanh 1 t 'number)

(built-in-fn 'float '(1 2) t t 'float-result-type)
(built-in-fn 'rational 1 t 'rational)
(built-in-fn 'rationalize 1 t 'rational)
(built-in-fn 'numerator 1 t 'integer)
(built-in-fn 'denominator 1 t 'integer)
(built-in-fn 'floor '(1 2) t 'integer nil 'multiple)
(built-in-fn 'ceiling '(1 2) t 'integer nil 'multiple)
(built-in-fn 'truncate '(1 2) t 'integer nil 'multiple)
(built-in-fn 'round '(1 2) t 'integer nil 'multiple)
(built-in-fn 'mod 2 t 'number)
(built-in-fn 'rem 2 t 'number)
(built-in-fn 'ffloor '(1 2) t 'float nil 'multiple)
(built-in-fn 'fceiling '(1 2) t 'float nil 'multiple)
(built-in-fn 'fround '(1 2) t 'float nil 'multiple)
(built-in-fn 'ftruncate '(1 2) t 'float nil 'multiple)
(built-in-fn 'decode-float 1 t t 'result-type-arg1 'multiple)
(built-in-fn 'scale-float 2 t t 'result-type-arg1)
(built-in-fn 'float-radix 1 t 'fixnum)
(built-in-fn 'float-sign '(1 2) t 'number)
(built-in-fn 'float-digits 1 t 'fixnum)
(built-in-fn 'float-precision 1 t 'fixnum)
(built-in-fn 'integer-decode-float 1 t 'integer nil 'multiple)
(built-in-fn 'complex '(1 2) t 'number)
(built-in-fn 'realpart 1 t 'number)
(built-in-fn 'imagpart 1 t 'number)

(built-in-fn 'logior '(0) t t 'boolean-result-type)
(built-in-fn 'logxor '(0) t t 'boolean-result-type)
(built-in-fn 'logand '(0) t t 'boolean-result-type)
(built-in-fn 'logeqv '(0) t t 'boolean-result-type)
(built-in-fn 'lognand 2 t t 'boolean-result-type)
(built-in-fn 'lognor 2 t t 'boolean-result-type)
(built-in-fn 'logandc1 2 t t 'boolean-result-type)
(built-in-fn 'logandc2 2 t t 'boolean-result-type)
(built-in-fn 'logorc1 2 t t 'boolean-result-type)
(built-in-fn 'logorc2 2 t t 'boolean-result-type)
(built-in-fn 'boole 3 t 'integer)
(built-in-special 'boole-clr 'fixnum)
(built-in-special 'boole-set 'fixnum)
(built-in-special 'boole-1 'fixnum)
(built-in-special 'boole-2 'fixnum)
(built-in-special 'boole-c1 'fixnum)
(built-in-special 'boole-c2 'fixnum)
(built-in-special 'boole-and 'fixnum)
(built-in-special 'boole-ior 'fixnum)
(built-in-special 'boole-xor 'fixnum)
(built-in-special 'boole-eqv 'fixnum)
(built-in-special 'boole-nand 'fixnum)
(built-in-special 'boole-nor 'fixnum)
(built-in-special 'boole-andc1 'fixnum)
(built-in-special 'boole-andc2 'fixnum)
(built-in-special 'boole-orc1 'fixnum)
(built-in-special 'boole-orc2 'fixnum)
(built-in-fn 'lognot 1 t t 'boolean-result-type)
(built-in-fn 'logtest 2 t 'predicate)
(built-in-fn 'logbitp 2 t 'predicate)
(built-in-fn 'ash 2 t 'integer)

;;; Note: several of the following depend on the fact that in Spice Lisp a
;;; fixnum is sufficient to represent the number of bits in the largest
;;; bignum.

(built-in-fn 'logcount 1 t 'fixnum)
(built-in-fn 'integer-length 1 t 'fixnum)
(built-in-fn 'byte 2 t 'list)
(built-in-fn 'byte-size 1 t 'fixnum)
(built-in-fn 'byte-position 1 t 'fixnum)
(built-in-fn 'ldb 2 t 'integer)
(built-in-fn 'ldb-test 2 t 'predicate)
(built-in-fn 'mask-field 2 t 'integer)
(built-in-fn 'dpb 3 t 'integer)
(built-in-fn 'deposit-field 3 t 'integer)

(built-in-fn 'random '(1 2) nil 'number)
(built-in-special '*random-state* 'random-state)
(built-in-fn 'make-random-state '(0 1) nil 'random-state)
(built-in-fn 'random-state-p 1 t 'predicate)

(built-in-special 'most-positive-fixnum 'fixnum)
(built-in-special 'most-negative-fixnum 'fixnum)
(built-in-special 'most-positive-short-float 'short-float)
(built-in-special 'least-positive-short-float 'short-float)
(built-in-special 'least-negative-short-float 'short-float)
(built-in-special 'most-negative-short-float 'short-float)
(built-in-special 'most-positive-single-float 'single-float)
(built-in-special 'least-positive-single-float 'single-float)
(built-in-special 'least-negative-single-float 'single-float)
(built-in-special 'most-negative-single-float 'single-float)
(built-in-special 'most-positive-double-float 'double-float)
(built-in-special 'least-positive-double-float 'double-float)
(built-in-special 'least-negative-double-float 'double-float)
(built-in-special 'most-negative-double-float 'double-float)
(built-in-special 'most-positive-long-float 'long-float)
(built-in-special 'least-positive-long-float 'long-float)
(built-in-special 'least-negative-long-float 'long-float)
(built-in-special 'most-negative-long-float 'long-float)
(built-in-special 'short-float-epsilon 'short-float)
(built-in-special 'single-float-epsilon 'single-float)
(built-in-special 'double-float-epsilon 'double-float)
(built-in-special 'long-float-epsilon 'long-float)
(built-in-special 'short-float-negative-epsilon 'short-float)
(built-in-special 'single-float-negative-epsilon 'single-float)
(built-in-special 'double-float-negative-epsilon 'double-float)
(built-in-special 'long-float-negative-epsilon 'long-float)

;;; In "Characters" chapter:

(built-in-special 'char-code-limit 'fixnum)
(built-in-special 'char-font-limit 'fixnum)
(built-in-special 'char-bits-limit 'fixnum)
(built-in-fn 'standard-char-p 1 t 'predicate)
(built-in-fn 'graphic-char-p 1 t 'predicate)
(built-in-fn 'string-char-p 1 t 'predicate)
(built-in-fn 'alpha-char-p 1 t 'predicate)
(built-in-fn 'upper-case-p 1 t 'predicate)
(built-in-fn 'lower-case-p 1 t 'predicate)
(built-in-fn 'both-case-p 1 t 'predicate)
(built-in-fn 'digit-char-p '(1 2) t t)
(built-in-fn 'alphanumericp 1 t 'predicate)

(built-in-fn 'char= '(1) t 'predicate)
(built-in-fn 'char/= '(1) t 'predicate)
(built-in-fn 'char< '(1) t 'predicate)
(built-in-fn 'char> '(1) t 'predicate)
(built-in-fn 'char<= '(1) t 'predicate)
(built-in-fn 'char>= '(1) t 'predicate)
(built-in-fn 'char-equal '(1) t 'predicate)
(built-in-fn 'char-not-equal '(1) t 'predicate)
(built-in-fn 'char-lessp '(1) t 'predicate)
(built-in-fn 'char-greaterp '(1) t 'predicate)
(built-in-fn 'char-not-greaterp '(1) t 'predicate)
(built-in-fn 'char-not-lessp '(1) t 'predicate)

(built-in-fn 'character 1 t 'character)
(built-in-fn 'char-code 1 t 'fixnum)
(built-in-fn 'char-bits 1 t 'fixnum)
(built-in-fn 'char-font 1 t 'fixnum)
(built-in-fn 'code-char '(1 3) t 'character)
(built-in-fn 'make-char '(1 3) t 'character)

(built-in-fn 'char-upcase 1 t 'character)
(built-in-fn 'char-downcase 1 t 'character)
(built-in-fn 'digit-char '(1 4) t t)
(built-in-fn 'char-int 1 t 'fixnum)
(built-in-fn 'int-char 1 t 'character)
(built-in-fn 'char-name 1 t 'symbol)
(built-in-fn 'name-char 1 t t)

(built-in-special 'char-control-bit 'fixnum)
(built-in-special 'char-meta-bit 'fixnum)
(built-in-special 'char-hyper-bit 'fixnum)
(built-in-special 'char-super-bit 'fixnum)
(built-in-fn 'char-bit 2 t 'predicate)
(built-in-fn 'set-char-bit 3 t 'character)

;;; In the "Sequences" chapter:

(built-in-fn 'elt 2 t t)
(built-in-fn 'subseq '(2 3) t t 'result-type-arg1)
(built-in-fn 'copy-seq 1 t t 'result-type-arg1)
(built-in-fn 'length 1 t 'fixnum)
(built-in-fn 'reverse 1 t t 'result-type-arg1)
(built-in-fn 'nreverse 1 nil t 'result-type-arg1)

(built-in-fn 'make-sequence '(2) t t 'type-spec-arg1)
(built-in-fn 'concatenate '(1) t t 'type-spec-arg1)
(built-in-fn 'map '(3) nil t 'type-spec-arg1)
(built-in-fn 'some '(2) t 'predicate)
(built-in-fn 'every '(2) t 'predicate)
(built-in-fn 'notany '(2) t 'predicate)
(built-in-fn 'notevery '(2) t 'predicate)
(built-in-fn 'reduce '(2) t t)
(built-in-fn 'fill '(2) nil t 'result-type-arg1)
(built-in-fn 'replace '(2) nil t 'result-type-arg1)
(built-in-fn 'remove '(2) t t 'result-type-arg2)
(built-in-fn 'remove-if '(2) t t 'result-type-arg2)
(built-in-fn 'remove-if-not '(2) t t 'result-type-arg2)
(built-in-fn 'delete '(2) nil t 'result-type-arg2)
(built-in-fn 'delete-if '(2) nil t 'result-type-arg2)
(built-in-fn 'delete-if-not '(2) nil t 'result-type-arg2)
(built-in-fn 'remove-duplicates '(1) t t 'result-type-arg1)
(built-in-fn 'delete-duplicates '(1) nil t 'result-type-arg1)
(built-in-fn 'substitute '(3) t t 'result-type-arg3)
(built-in-fn 'substitute-if '(3)  t t 'result-type-arg3)
(built-in-fn 'substitute-if-not '(3) t t 'result-type-arg3)
(built-in-fn 'nsubstitute '(3) nil t 'result-type-arg3)
(built-in-fn 'nsubstitute-if '(3) nil t 'result-type-arg3)
(built-in-fn 'nsubstitute-if-not '(3) nil t 'result-type-arg3)

(built-in-fn 'find '(2) t t)
(built-in-fn 'find-if '(2) t t)
(built-in-fn 'find-if-not '(2) t t)
(built-in-fn 'position '(2) t t)
(built-in-fn 'position-if '(2) t t)
(built-in-fn 'position-if-not '(2) t t)
(built-in-fn 'count '(2) t 'fixnum)
(built-in-fn 'count-if '(2) t 'fixnum)
(built-in-fn 'count-if-not '(2) t 'fixnum)
(built-in-fn 'mismatch '(2) t t)
(built-in-fn 'search '(2) t t)
(built-in-fn 'sort '(2) nil t 'result-type-arg1)
(built-in-fn 'stable-sort '(2) nil t 'result-type-arg1)
(built-in-fn 'merge '(4) nil t 'type-spec-arg1)

;;; In the "Manipulating 'List Structure" chapter:

(built-in-fn 'car 1 t t)
(built-in-fn 'cdr 1 t t)
(built-in-fn 'caar 1 t t)
(built-in-fn 'cadr 1 t t)
(built-in-fn 'cdar 1 t t)
(built-in-fn 'cddr 1 t t)
(built-in-fn 'caaar 1 t t)
(built-in-fn 'caadr 1 t t)
(built-in-fn 'cadar 1 t t)
(built-in-fn 'caddr 1 t t)
(built-in-fn 'cdaar 1 t t)
(built-in-fn 'cdadr 1 t t)
(built-in-fn 'cddar 1 t t)
(built-in-fn 'cdddr 1 t t)
(built-in-fn 'caaaar 1 t t)
(built-in-fn 'caaadr 1 t t)
(built-in-fn 'caadar 1 t t)
(built-in-fn 'caaddr 1 t t)
(built-in-fn 'cadaar 1 t t)
(built-in-fn 'cadadr 1 t t)
(built-in-fn 'caddar 1 t t)
(built-in-fn 'cadddr 1 t t)
(built-in-fn 'cdaaar 1 t t)
(built-in-fn 'cdaadr 1 t t)
(built-in-fn 'cdadar 1 t t)
(built-in-fn 'cdaddr 1 t t)
(built-in-fn 'cddaar 1 t t)
(built-in-fn 'cddadr 1 t t)
(built-in-fn 'cdddar 1 t t)
(built-in-fn 'cddddr 1 t t)

(built-in-fn 'cons 2 t 'list)
(built-in-fn 'tree-equal '(2) t 'predicate)
(built-in-fn 'endp 1 t 'predicate)
(built-in-fn 'list-length 1 t t)
(built-in-fn 'nth 2 t t)
(built-in-fn 'first 1 t t)
(built-in-fn 'second 1 t t)
(built-in-fn 'third 1 t t)
(built-in-fn 'fourth 1 t t)
(built-in-fn 'fifth 1 t t)
(built-in-fn 'sixth 1 t t)
(built-in-fn 'seventh 1 t t)
(built-in-fn 'eighth 1 t t)
(built-in-fn 'ninth 1 t t)
(built-in-fn 'tenth 1 t t)

(built-in-fn 'rest 1 t t)
(built-in-fn 'nthcdr 2 t t)
(built-in-fn 'last 1 t 'list)
(built-in-fn 'list '(0) t 'list)
(built-in-fn 'list* '(1) t t)			; since '(list* x) => x
(built-in-fn 'make-list '(1) t 'list)
(built-in-fn 'append '(0) t 'list)
(built-in-fn 'copy-list 1 t 'list)
(built-in-fn 'copy-alist 1 t 'list)
(built-in-fn 'copy-tree 1 t 'list)
(built-in-fn 'revappend 2 t 'list)
(built-in-fn 'nconc '(0) nil 'list)
(built-in-fn 'nreconc 2 nil 'list)
(built-in-fn 'butlast '(1 2) t 'list)
(built-in-fn 'nbutlast '(1 2) nil 'list)
(built-in-fn 'ldiff 2 t 'list)
(built-in-fn 'rplaca 2 nil 'list)
(built-in-fn 'rplacd 2 nil 'list)

(built-in-fn 'subst '(3) t 'list)
(built-in-fn 'subst-if '(3) t 'list)
(built-in-fn 'subst-if-not '(3) t 'list)
(built-in-fn 'nsubst '(3) nil 'list)
(built-in-fn 'nsubst-if '(3) nil 'list)
(built-in-fn 'nsubst-if-not '(3) nil 'list)
(built-in-fn 'sublis '(2) t 'list)
(built-in-fn 'nsublis '(2) nil 'list)

(built-in-fn 'member '(2) t 'list)
(built-in-fn 'member-if '(2) t 'list)
(built-in-fn 'member-if-not '(2) t 'list)
(built-in-fn 'tailp 2 t 'predicate)
(built-in-fn 'adjoin '(2) t 'list)
(built-in-fn 'union '(2) t 'list)
(built-in-fn 'nunion '(2) nil 'list)
(built-in-fn 'intersection '(2) t 'list)
(built-in-fn 'nintersection '(2) nil 'list)
(built-in-fn 'set-difference '(2) t 'list)
(built-in-fn 'nset-difference '(2) nil 'list)
(built-in-fn 'set-exclusive-or '(2) t 'list)
(built-in-fn 'nset-exclusive-or '(2) nil 'list)
(built-in-fn 'subsetp '(2) t 'predicate)

(built-in-fn 'acons 3 t 'list)
(built-in-fn 'pairlis '(2 3) t 'list)
(built-in-fn 'assoc '(2) t 'list)
(built-in-fn 'assoc-if 2 t 'list)
(built-in-fn 'assoc-if-not 2 t 'list)
(built-in-fn 'rassoc '(2) t 'list)
(built-in-fn 'rassoc-if 2 t 'list)
(built-in-fn 'rassoc-if-not 2 t 'list)

;;; In the Hash-Table chapter:

(built-in-fn 'make-hash-table '(0) t 'hash-table)
(built-in-fn 'hash-table-p 1 t 'predicate)
(built-in-fn 'gethash '(2 3) t t nil 'multiple)
(built-in-fn 'remhash 2 nil t)
(built-in-fn 'maphash 2 nil 'predicate)
(built-in-fn 'clrhash 1 nil 'hash-table)
(built-in-fn 'hash-table-count 1 t 'fixnum)
(built-in-fn 'sxhash 1 t 'fixnum)

;;; In the "Arrays" chapter:

(built-in-fn 'make-array '(1) t 'array)
(built-in-special 'array-rank-limit 'fixnum)
(built-in-special 'array-dimension-limit 'fixnum)
(built-in-special 'array-total-size-limit 'fixnum)
(built-in-fn 'vector '(0) t 'simple-vector)
(built-in-fn 'aref '(1) t t)
(built-in-fn 'array-element-type 1 t t)
(built-in-fn 'array-rank 1 t 'fixnum)
(built-in-fn 'array-dimension 2 t 'fixnum)
(built-in-fn 'array-dimensions 1 t 'list)
(built-in-fn 'array-in-bounds-p '(1) t 'predicate)
(built-in-fn 'array-row-major-index '(1) t 'fixnum)

(built-in-fn 'svref 2 t t)
(built-in-fn 'bit '(1) t 'fixnum)
(built-in-fn 'sbit '(1) t 'fixnum)

(built-in-fn 'bit-and '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-ior '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-xor '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-eqv '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-nand '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-nor '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-andc1 '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-andc2 '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-orc1 '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-orc2 '(2 3) nil t 'result-type-arg1)
(built-in-fn 'bit-not '(1 2) nil t 'result-type-arg1)

(built-in-fn 'array-has-fill-pointer-p 1 t 'predicate)
(built-in-fn 'fill-pointer 1 t 'fixnum)
(built-in-fn 'vector-push 2 nil t)
(built-in-fn 'vector-push-extend '(2 3) nil 'fixnum)
(built-in-fn 'vector-pop 1 nil t)
(built-in-fn 'adjust-array '(2) nil t 'result-type-arg1)

;;; In the "Strings" chapter:

(built-in-fn 'char 2 t 'character)
(built-in-fn 'schar 2 t 'character)

(built-in-fn 'string= '(2) t 'predicate)
(built-in-fn 'string-equal '(2) t 'predicate)
(built-in-fn 'string< '(2) t t)
(built-in-fn 'string> '(2) t t)
(built-in-fn 'string<= '(2) t t)
(built-in-fn 'string>= '(2) t t)
(built-in-fn 'string/= '(2) t t)
(built-in-fn 'string-lessp '(2) t t)
(built-in-fn 'string-greaterp '(2) t t)
(built-in-fn 'string-not-lessp '(2) t t)
(built-in-fn 'string-not-greaterp '(2) t t)
(built-in-fn 'string-not-equal '(2) t t)

(built-in-fn 'make-string '(1) t 'simple-string)
(built-in-fn 'string-trim 2 t 'simple-string)
(built-in-fn 'string-left-trim 2 t 'simple-string)
(built-in-fn 'string-right-trim 2 t 'simple-string)
(built-in-fn 'string-upcase '(1) t 'simple-string)
(built-in-fn 'string-downcase '(1) t 'simple-string)
(built-in-fn 'string-capitalize '(1) t 'simple-string)
(built-in-fn 'nstring-upcase '(1) nil 'string)
(built-in-fn 'nstring-downcase '(1) nil 'string)
(built-in-fn 'nstring-capitalize '(1) nil 'string)
(built-in-fn 'string 1 t 'string)

;;; In the "Eval" chapter:

(built-in-fn 'eval 1 nil t nil 'multiple)
(built-in-special '*evalhook* t)
(built-in-special '*applyhook* t)
(built-in-fn '*eval 5 nil t nil 'multiple)
(built-in-fn 'evalhook '(3 7) nil t nil 'multiple)
(built-in-fn 'applyhook '(4 8) nil t nil 'multiple)
(built-in-fn 'constantp 1 t 'predicate)

;;; In the "Streams" chapter:

(built-in-special '*standard-input* 'stream)
(built-in-special '*standard-output* 'stream)
(built-in-special '*error-output* 'stream)
(built-in-special '*query-io* 'stream)
(built-in-special '*debug-io* 'stream)
(built-in-special '*terminal-io* 'stream)
(built-in-special '*trace-output* 'stream)

(built-in-fn 'make-synonym-stream 1 t 'stream)
(built-in-fn 'make-broadcast-stream '(0) t 'stream)
(built-in-fn 'make-concatenated-stream '(0) t 'stream)
(built-in-fn 'make-two-way-stream 2 t 'stream)
(built-in-fn 'make-echo-stream 2 t 'stream)
(built-in-fn 'make-string-input-stream '(1 3) t 'stream)
(built-in-fn 'make-string-output-stream 0 t 'stream)
(built-in-fn 'get-output-stream-string 1 nil 'string)
(built-in-fn 'streamp 1 t 'predicate)
(built-in-fn 'input-stream-p 1 t 'predicate)
(built-in-fn 'output-stream-p 1 t 'predicate)
(built-in-fn 'close '(1) nil 'stream)

;;; In the "Input/Output" chapter:

(built-in-special '*read-base* 'fixnum)
(built-in-special '*readtable* 'readtable)
(built-in-fn 'copy-readtable '(0 2) nil 'readtable)
(built-in-fn 'readtablep 1 t 'predicate)
(built-in-fn 'set-syntax-from-char '(2 4) nil t)
(built-in-fn 'set-macro-character '(2 4) nil t)
(built-in-fn 'get-macro-character '(1 2) t t nil 'multiple)
(built-in-fn 'make-dispatch-macro-character '(1 3) nil t)
(built-in-fn 'set-dispatch-macro-character '(3 4) nil t)
(built-in-fn 'get-dispatch-macro-character '(2 3) t t)

(built-in-special '*print-escape* t)
(built-in-special '*print-pretty* t)
(built-in-special '*print-circle* t)
(built-in-special '*print-base* 'fixnum)
(built-in-special '*print-radix* t)
(built-in-special '*print-case* t)
(built-in-special '*print-level* t)
(built-in-special '*print-length* t)
(built-in-special '*print-array* t)

(built-in-fn 'read '(0 4) nil t)
(built-in-special '*read-default-float-format* 'symbol)
(built-in-fn 'read-preserving-whitespace '(0 4) nil t)
(built-in-fn 'read-delimited-list '(1 3) nil t)
(built-in-fn 'read-line '(0 4) nil 'simple-string  nil 'multiple)
(built-in-fn 'read-char '(0 4) nil 'character)
(built-in-fn 'unread-char '(1 2) nil t)
(built-in-fn 'peek-char '(0 5) nil 'character)
(built-in-fn 'listen '(0 1) t 'predicate)
(built-in-fn 'read-char-no-hang '(0 4) nil t)
(built-in-fn 'clear-input '(0 1) nil t)
(built-in-fn 'read-from-string '(1) nil t)
(built-in-fn 'parse-integer '(1) t 'integer)
(built-in-fn 'read-byte '(1 3) nil 'integer)

(built-in-fn 'write '(1) nil t 'result-type-arg1)
(built-in-fn 'prin1 '(1 2) nil t 'result-type-arg1)
(built-in-fn 'print '(1 2) nil t 'result-type-arg1)
(built-in-fn 'pprint '(1 2) nil t 'result-type-arg1)
(built-in-fn 'princ '(1 2) nil t 'result-type-arg1)
(built-in-fn 'write-to-string '(1) t 'simple-string)
(built-in-fn 'prin1-to-string 1 t 'simple-string)
(built-in-fn 'princ-to-string 1 t 'simple-string)
(built-in-fn 'write-char '(1 2) nil t)
(built-in-fn 'write-string '(1) nil 'string)
(built-in-fn 'write-line '(1) nil 'string)
(built-in-fn 'terpri '(0 1) nil t)
(built-in-fn 'fresh-line '(0 1) nil t)
(built-in-fn 'finish-output '(0 1) nil t)
(built-in-fn 'force-output '(0 1) nil t)
(built-in-fn 'clear-output '(0 1) nil t)
(built-in-fn 'write-byte 2 nil t)
(built-in-fn 'format '(2) nil t)

(built-in-fn 'y-or-n-p '(0 2) nil 'predicate)
(built-in-fn 'yes-or-no-p '(0 2) nil 'predicate)

;;; In the "File System Interface" chapter:

(built-in-fn 'pathname 1 t t)
(built-in-fn 'truename 1 nil t)
(built-in-fn 'parse-namestring '(1 6) t t nil 'multiple)
(built-in-fn 'merge-pathnames '(1 3) t t)
(built-in-fn 'make-pathname '(0) t t)
(built-in-fn 'pathnamep 1 t 'predicate)
(built-in-fn 'pathname-host 1 t t)
(built-in-fn 'pathname-device 1 t t)
(built-in-fn 'pathname-directory 1 t t)
(built-in-fn 'pathname-name 1 t t)
(built-in-fn 'pathname-type 1 t t)
(built-in-fn 'pathname-version 1 t t)
(built-in-fn 'namestring 1 t 'simple-string)
(built-in-fn 'file-namestring 1 t 'simple-string)
(built-in-fn 'directory-namestring 1 t 'simple-string)
(built-in-fn 'host-namestring 1 t 'simple-string)
(built-in-fn 'enough-namestring '(1 2) t 'simple-string)
(built-in-fn 'user-homedir-pathname '(0 1) t t)
(built-in-fn 'init-file-pathname '(1 2) t t)
(built-in-special '*default-pathname-defaults* t)

(built-in-fn 'open '(1) nil t)
(built-in-fn 'rename-file 2 nil t nil 'multiple)
(built-in-fn 'delete-file 1 nil t)
(built-in-fn 'probe-file 1 t t)
(built-in-fn 'file-write-date 1 t t)
(built-in-fn 'file-author 1 t t)
(built-in-fn 'file-position '(1 2) nil t)
(built-in-fn 'file-length 1 t 'integer)
(built-in-fn 'load '(1) nil t)
(built-in-special '*load-verbose* t)
(built-in-fn 'directory 1 t 'list)

;;; In the "Errors" chapter:

(built-in-fn 'error '(1) nil t)
(built-in-fn 'cerror '(2) nil t)
(built-in-fn 'warn '(1) nil t)
(built-in-special '*break-on-warnings* t)
(built-in-fn 'break '(0) nil t)


;;; In the "Miscellaneous" Chapter.

(built-in-fn 'compile '(1 2) nil t)
(built-in-fn 'compile-file '(0) nil t)
(built-in-fn 'disassemble '(1 2) nil t)
(built-in-fn 'documentation 2 t t)
(built-in-fn 'describe 1 nil t)
(built-in-fn 'inspect 1 nil t)
(built-in-fn 'room '(0 2) nil t)
(built-in-fn 'ed '(0 1) nil t)
(built-in-fn 'dribble '(0 1) nil t)
(built-in-fn 'apropos '(1 2) nil t)
(built-in-fn 'apropos-list '(1 2) t 'list)
(built-in-fn 'get-decoded-time 0 t t nil 'multiple)
(built-in-fn 'get-universal-time 0 t 'integer)
(built-in-fn 'decode-universal-time '(1 2) t t nil 'multiple)
(built-in-fn 'encode-universal-time '(6 7) t 'integer)
(built-in-special 'internal-time-units-per-second 'integer)
(built-in-fn 'get-internal-run-time 0 t 'integer)
(built-in-fn 'get-internal-real-time 0 t 'integer)
(built-in-fn 'sleep 1 nil t)
(built-in-fn 'lisp-implementation-type 0 t 'simple-string)
(built-in-fn 'lisp-implementation-version 0 t 'simple-string)
(built-in-fn 'machine-type 0 t 'simple-string)
(built-in-fn 'machine-version 0 t 'simple-string)
(built-in-fn 'machine-instance 0 t 'simple-string)
(built-in-fn 'software-type 0 t 'simple-string)
(built-in-fn 'software-version 0 t 'simple-string)
(built-in-fn 'short-site-name 0 t 'simple-string)
(built-in-fn 'long-site-name 0 t 'simple-string)
(built-in-special '*features* 'list)
(built-in-fn 'identity 1 t t 'result-type-arg1)

;;; These are extensions.

(built-in-fn 'unproclaim 1 nil t)
(built-in-fn 'memq 2 t 'list)
(built-in-fn 'assq 2 t 'list)
(built-in-fn 'delq '(2 3) nil 'list)
(built-in-fn 'uncompile 1 nil 'symbol)
(built-in-fn 'compiledp 1 nil 'predicate)

;;; Internal thingies created by macros and transforms.

(built-in-fn 'structure-typep 2 t 'predicate)
(built-in-fn 'slisp-b-vector-p 1 t 'predicate)
(built-in-fn 'slisp-u-vector-p 1 t 'predicate)
(built-in-fn 'slisp-vector-p 1 t 'predicate)
(built-in-fn 'slisp-array-p 1 t 'predicate)

;;; Internal functions used to open code some sequence functions:

(built-in-fn 'list-length* '(1)  t 'simple-vector)
(built-in-fn 'vector-subseq* '(2 3) t 'simple-vector)
(built-in-fn 'simple-subseq* '(2 3) t 'simple-vector)
(built-in-fn 'list-subseq* '(2 3) t 'list)
(built-in-fn 'list-copy-seq* 1 t 'list)
(built-in-fn 'simple-copy-seq* 1 t 'simple-vector)
(built-in-fn 'vector-copy-seq* 1 t 'simple-vector)
(built-in-fn 'list-fill* 4 nil 'list)
(built-in-fn 'simple-fill* 4 nil 'simple-vector)
(built-in-fn 'vector-fill* 4 nil 'vector)
(built-in-fn 'list-replace-from-list* 6 nil 'list)
(built-in-fn 'list-replace-from-simple* 6 nil 'list)
(built-in-fn 'list-replace-from-vector* 6 nil 'list)
(built-in-fn 'simple-replace-from-list* 6 nil 'simple-vector)
(built-in-fn 'simple-replace-from-simple* 6 nil 'simple-vector)
(built-in-fn 'simple-replace-from-vector* 6 nil 'simple-vector)
(built-in-fn 'vector-replace-from-list* 6 nil 'vector)
(built-in-fn 'vector-replace-from-simple* 6 nil 'vector)
(built-in-fn 'vector-replace-from-vector* 6 nil 'vector)
(built-in-fn 'list-reverse* 1 t 'list)
(built-in-fn 'simple-reverse* 1 t 'simple-vector)
(built-in-fn 'vector-reverse* 1 t 'simple-vector)
(built-in-fn 'list-nreverse* 1 nil 'list)
(built-in-fn 'simple-nreverse* 1 nil 'simple-vector)
(built-in-fn 'vector-nreverse* 1 nil 'vector)
(built-in-fn 'concat-to-list* '(0) t 'list)
(built-in-fn 'concat-to-simple* '(1) t 'simple-vector)
(built-in-fn 'vector-to-list* 1 t 'list)
(built-in-fn 'simple-to-list* 1 t 'list)
(built-in-fn 'list-to-simple* 2 t 'simple-vector)
(built-in-fn 'vector-to-simple* 2 t 'simple-vector)
(built-in-fn 'list-remove-duplicates* 5 t 'list)
(built-in-fn 'simple-remove-duplicates* '(7 8) t 'simple-vector)
(built-in-fn 'vector-remove-duplicates* '(7 8) t 'simple-vector)
(built-in-fn 'list-delete-duplicates* 5 nil 'list)
(built-in-fn 'simple-delete-duplicates* '(7 8) nil 'simple-vector)
(built-in-fn 'vector-delete-duplicates* '(7 8) nil 'vector)
(built-in-fn 'list-substitute* 9 t 'list)
(built-in-fn 'vector-substitute* 11 t 'vector)
(built-in-fn 'list-substitute-if* 7 t 'list)
(built-in-fn 'vector-substitute-if* 9 t 'vector)
(built-in-fn 'list-substitute-if-not* 7 t 'list)
(built-in-fn 'vector-substitute-if-not* 9 t 'vector)
(built-in-fn 'nlist-substitute* 9 nil 'list)
(built-in-fn 'nvector-substitute* 10 nil 'vector)
(built-in-fn 'nlist-substitute-if* 7 nil 'list)
(built-in-fn 'nvector-substitute-if* 8 nil 'vector)
(built-in-fn 'nlist-substitute-if-not* 7 nil 'list)
(built-in-fn 'nvector-substitute-if-not* 8 nil 'vector)

(built-in-fn 'string=* 6 t 'predicate)
(built-in-fn 'string/=* 6 t t)
(built-in-fn 'string<* 6 t t)
(built-in-fn 'string>* 6 t t)
(built-in-fn 'string<=* 6 t t)
(built-in-fn 'string>=* 6 t t)

;;; Internal forms called by SETF.

(built-in-fn '%put 3 nil t 'result-type-arg3)
(built-in-fn '%rplaca 2 nil t 'result-type-arg2)
(built-in-fn '%rplacd 2 nil t 'result-type-arg2)
(built-in-fn '%setnth 3 nil t 'result-type-arg3)
(built-in-fn '%setelt 3 nil t 'result-type-arg3)
(built-in-fn '%puthash 3 nil t 'result-type-arg3)
(built-in-fn '%aset1 '(1) nil t)
(built-in-fn '%svset 3 nil t 'result-type-arg3)
(built-in-fn 'shrink-vector 2 nil 'vector)
(built-in-fn '%bitset '(1) nil 'fixnum)
(built-in-fn '%sbitset '(1) nil 'fixnum)
(built-in-fn '%set-fill-pointer 2 nil t)
(built-in-fn '%scharset 3 nil 'character)
(built-in-fn '%charset 3 nil 'character)
(built-in-fn '%set-documentation 3 nil t 'result-type-arg3)

;;; An internal function the code produced by DEFSTRUCT calls.

(built-in-fn 'setelt-form 4 nil 'list)

;;; Keyword hackery.

(built-in-fn '%get-key 2 t 'list)
(built-in-fn 'keyword-test 2 nil t)