Included Books
other
(in-package "ACL2")
include-book
(include-book "quote")
macro-argpfunction
(defund macro-argp (arg) (declare (xargs :guard t)) (or (symbolp arg) (and (true-listp arg) (or (and (= 1 (len arg)) (symbolp (first arg))) (and (= 2 (len arg)) (symbolp (first arg)) (myquotep (second arg))) (and (= 3 (len arg)) (symbolp (first arg)) (myquotep (second arg)) (symbolp (third arg)))))))
macro-arg-listpfunction
(defund macro-arg-listp (args) (declare (xargs :guard t)) (if (atom args) (null args) (and (macro-argp (first args)) (macro-arg-listp (rest args)))))
macro-argp-of-cartheorem
(defthm macro-argp-of-car (implies (macro-arg-listp macro-args) (macro-argp (car macro-args))) :hints (("Goal" :in-theory (enable macro-arg-listp))))
macro-arg-listp-of-cdrtheorem
(defthm macro-arg-listp-of-cdr (implies (macro-arg-listp macro-args) (macro-arg-listp (cdr macro-args))) :hints (("Goal" :in-theory (enable macro-arg-listp))))
macro-arg-listp-of-constheorem
(defthm macro-arg-listp-of-cons (equal (macro-arg-listp (cons macro-arg macro-args)) (and (macro-argp macro-arg) (macro-arg-listp macro-args))) :hints (("Goal" :in-theory (enable macro-arg-listp))))
macro-arg-listp-forward-to-true-listptheorem
(defthm macro-arg-listp-forward-to-true-listp (implies (macro-arg-listp macro-args) (true-listp macro-args)) :rule-classes :forward-chaining :hints (("Goal" :in-theory (enable macro-arg-listp))))
keyword-or-optional-arg-name-and-defaultfunction
(defund keyword-or-optional-arg-name-and-default (macro-arg) (declare (xargs :guard (macro-argp macro-arg) :guard-hints (("Goal" :in-theory (enable macro-argp))))) (if (symbolp macro-arg) (mv macro-arg nil) (if (< (len macro-arg) 2) (mv (first macro-arg) nil) (mv (first macro-arg) (unquote (second macro-arg))))))
symbolp-of-mv-nth-0-of-keyword-or-optional-arg-name-and-defaulttheorem
(defthm symbolp-of-mv-nth-0-of-keyword-or-optional-arg-name-and-default (implies (macro-argp macro-arg) (symbolp (mv-nth 0 (keyword-or-optional-arg-name-and-default macro-arg)))) :hints (("Goal" :in-theory (enable keyword-or-optional-arg-name-and-default macro-argp))))
maybe-skip-whole-argfunction
(defund maybe-skip-whole-arg (macro-args) (declare (xargs :guard (macro-arg-listp macro-args))) (if (and (consp macro-args) (eq '&whole (first macro-args))) (cddr macro-args) macro-args))
macro-arg-listp-of-maybe-skip-whole-argtheorem
(defthm macro-arg-listp-of-maybe-skip-whole-arg (implies (macro-arg-listp macro-args) (macro-arg-listp (maybe-skip-whole-arg macro-args))) :hints (("Goal" :in-theory (enable maybe-skip-whole-arg))))
remove-rest-and-body-from-macro-argsfunction
(defund remove-rest-and-body-from-macro-args (macro-args) (declare (xargs :guard (macro-arg-listp macro-args))) (if (endp macro-args) nil (let ((arg (first macro-args))) (if (or (eq '&rest arg) (eq '&body arg)) (remove-rest-and-body-from-macro-args (rest (rest macro-args))) (cons arg (remove-rest-and-body-from-macro-args (rest macro-args)))))))
macro-arg-listp-of-remove-rest-and-body-from-macro-argstheorem
(defthm macro-arg-listp-of-remove-rest-and-body-from-macro-args (implies (macro-arg-listp macro-args) (macro-arg-listp (remove-rest-and-body-from-macro-args macro-args))) :hints (("Goal" :in-theory (enable remove-rest-and-body-from-macro-args))))
remove-allow-other-keys-from-macro-argsfunction
(defund remove-allow-other-keys-from-macro-args (macro-args) (declare (xargs :guard (macro-arg-listp macro-args))) (if (endp macro-args) nil (let ((arg (first macro-args))) (if (eq '&allow-other-keys arg) (remove-allow-other-keys-from-macro-args (rest macro-args)) (cons arg (remove-allow-other-keys-from-macro-args (rest macro-args)))))))
macro-arg-listp-of-remove-allow-other-keys-from-macro-argstheorem
(defthm macro-arg-listp-of-remove-allow-other-keys-from-macro-args (implies (macro-arg-listp macro-args) (macro-arg-listp (remove-allow-other-keys-from-macro-args macro-args))) :hints (("Goal" :in-theory (enable remove-allow-other-keys-from-macro-args))))
lambda-list-keywordpfunction
(defun lambda-list-keywordp (macro-arg) (declare (xargs :guard t)) (member-eq macro-arg '(&whole &optional &rest &body &key &allow-other-keys)))
split-args-at-lambda-list-keywordfunction
(defund split-args-at-lambda-list-keyword (macro-args) (declare (xargs :guard (macro-arg-listp macro-args))) (if (endp macro-args) (mv nil nil) (let ((macro-arg (first macro-args))) (if (lambda-list-keywordp macro-arg) (mv nil macro-args) (mv-let (args-before remaining-args) (split-args-at-lambda-list-keyword (rest macro-args)) (mv (cons macro-arg args-before) remaining-args))))))
macro-arg-listp-of-mv-nth-0-of-split-args-at-lambda-list-keywordtheorem
(defthm macro-arg-listp-of-mv-nth-0-of-split-args-at-lambda-list-keyword (implies (macro-arg-listp macro-args) (macro-arg-listp (mv-nth 0 (split-args-at-lambda-list-keyword macro-args)))) :rule-classes :type-prescription :hints (("Goal" :in-theory (enable split-args-at-lambda-list-keyword))))
true-listp-of-mv-nth-1-of-split-args-at-lambda-list-keywordtheorem
(defthm true-listp-of-mv-nth-1-of-split-args-at-lambda-list-keyword (implies (true-listp macro-args) (true-listp (mv-nth 1 (split-args-at-lambda-list-keyword macro-args)))) :rule-classes :type-prescription :hints (("Goal" :in-theory (enable split-args-at-lambda-list-keyword))))
macro-arg-listp-of-mv-nth-1-of-split-args-at-lambda-list-keywordtheorem
(defthm macro-arg-listp-of-mv-nth-1-of-split-args-at-lambda-list-keyword (implies (macro-arg-listp macro-args) (macro-arg-listp (mv-nth 1 (split-args-at-lambda-list-keyword macro-args)))) :rule-classes :type-prescription :hints (("Goal" :in-theory (enable split-args-at-lambda-list-keyword))))
split-macro-argsfunction
(defun split-macro-args (macro-args) (declare (xargs :guard (macro-arg-listp macro-args))) (mv-let (required-args remaining-args) (split-args-at-lambda-list-keyword macro-args) (if (not (symbol-listp required-args)) (prog2$ (er hard? 'split-macro-args "Found a non-symbol required arg among: ~x0." required-args) (mv nil nil nil)) (if (endp remaining-args) (mv required-args nil nil) (mv-let (optional-args remaining-args) (if (eq '&optional (first remaining-args)) (split-args-at-lambda-list-keyword (rest remaining-args)) (mv nil remaining-args)) (if (endp remaining-args) (mv required-args optional-args nil) (if (eq '&key (first remaining-args)) (mv required-args optional-args (rest remaining-args)) (prog2$ (er hard? 'split-macro-args "Unexpected lambda-list-keyword: ~x0." (first remaining-args)) (mv nil nil nil)))))))))
symbol-listp-of-mv-nth-0-of-split-macro-argstheorem
(defthm symbol-listp-of-mv-nth-0-of-split-macro-args (implies (macro-arg-listp macro-args) (symbol-listp (mv-nth 0 (split-macro-args macro-args)))) :hints (("Goal" :in-theory (enable split-macro-args))))
macro-arg-listp-of-mv-nth-1-of-split-macro-argstheorem
(defthm macro-arg-listp-of-mv-nth-1-of-split-macro-args (implies (macro-arg-listp macro-args) (macro-arg-listp (mv-nth 1 (split-macro-args macro-args)))) :hints (("Goal" :in-theory (enable split-macro-args))))
macro-arg-listp-of-mv-nth-2-of-split-macro-argstheorem
(defthm macro-arg-listp-of-mv-nth-2-of-split-macro-args (implies (macro-arg-listp macro-args) (macro-arg-listp (mv-nth 2 (split-macro-args macro-args)))) :hints (("Goal" :in-theory (enable split-macro-args))))
keyword-or-optional-arg-namesfunction
(defun keyword-or-optional-arg-names (keyword-args) (declare (xargs :guard (macro-arg-listp keyword-args) :guard-hints (("Goal" :in-theory (enable macro-arg-listp macro-argp))))) (if (atom keyword-args) nil (let ((keyword-arg (first keyword-args))) (mv-let (name default) (keyword-or-optional-arg-name-and-default keyword-arg) (declare (ignore default)) (cons name (keyword-or-optional-arg-names (rest keyword-args)))))))
extract-required-and-optional-and-keyword-argsfunction
(defund extract-required-and-optional-and-keyword-args (macro-args) (declare (xargs :guard (macro-arg-listp macro-args))) (let* ((macro-args (maybe-skip-whole-arg macro-args)) (macro-args (remove-rest-and-body-from-macro-args macro-args)) (macro-args (remove-allow-other-keys-from-macro-args macro-args))) (split-macro-args macro-args)))
symbol-listp-of-mv-nth-0-of-extract-required-and-optional-and-keyword-argstheorem
(defthm symbol-listp-of-mv-nth-0-of-extract-required-and-optional-and-keyword-args (implies (macro-arg-listp macro-args) (symbol-listp (mv-nth 0 (extract-required-and-optional-and-keyword-args macro-args)))) :hints (("Goal" :in-theory (enable extract-required-and-optional-and-keyword-args))))
macro-arg-listp-of-mv-nth-1-of-extract-required-and-optional-and-keyword-argstheorem
(defthm macro-arg-listp-of-mv-nth-1-of-extract-required-and-optional-and-keyword-args (implies (macro-arg-listp macro-args) (macro-arg-listp (mv-nth 1 (extract-required-and-optional-and-keyword-args macro-args)))) :hints (("Goal" :in-theory (enable extract-required-and-optional-and-keyword-args))))
macro-arg-listp-of-mv-nth-2-of-extract-required-and-optional-and-keyword-argstheorem
(defthm macro-arg-listp-of-mv-nth-2-of-extract-required-and-optional-and-keyword-args (implies (macro-arg-listp macro-args) (macro-arg-listp (mv-nth 2 (extract-required-and-optional-and-keyword-args macro-args)))) :hints (("Goal" :in-theory (enable extract-required-and-optional-and-keyword-args))))
macro-arg-namesfunction
(defund macro-arg-names (macro-args) (declare (xargs :guard (macro-arg-listp macro-args))) (mv-let (required-args optional-args keyword-args) (extract-required-and-optional-and-keyword-args macro-args) (append required-args (keyword-or-optional-arg-names optional-args) (keyword-or-optional-arg-names keyword-args))))