Filtering...

types-misc

books/tools/types-misc

Included Books

other
(in-package "ACL2")
include-book
(include-book "theory-tools")
other
(program)
kwassocfunction
(defun kwassoc
  (x default alist)
  (cond ((atom alist) default)
    ((eq x (caar alist)) (cdar alist))
    (t (kwassoc x default (cdr alist)))))
strip-keywordsfunction
(defun strip-keywords
  (list)
  (if (atom list)
    (mv list nil)
    (if (keywordp (car list))
      (mv-let (slist keyalist)
        (strip-keywords (cddr list))
        (mv slist (cons (cons (car list) (cadr list)) keyalist)))
      (mv-let (slist keyalist)
        (strip-keywords (cdr list))
        (mv (cons (car list) slist) keyalist)))))
munge-componentsfunction
(defun munge-components
  (components)
  (if (atom components)
    nil
    (cons (mv-let (compo kwalist)
        (strip-keywords (car components))
        (if (consp compo)
          (if (consp (cdr compo))
            (list* (cadr compo) (car compo) kwalist)
            (list* (car compo) nil kwalist))
          (list* compo nil kwalist)))
      (munge-components (cdr components)))))
appsyms1function
(defun appsyms1
  (symbols)
  (if (atom symbols)
    nil
    (if (atom (cdr symbols))
      symbols
      (list* (car symbols) '- (appsyms1 (cdr symbols))))))
packsyms1function
(defun packsyms1
  (lst)
  (cond ((null lst) "")
    (t (concatenate 'string
        (symbol-name (car lst))
        (packsyms1 (cdr lst))))))
packsymsfunction
(defun packsyms (lst) (intern (packsyms1 lst) "ACL2"))
appsymsfunction
(defun appsyms (symbols) (packsyms (appsyms1 symbols)))
component-namefunction
(defun component-name (component) (car component))
component-typefunction
(defun component-type (component) (cadr component))
component-kwalistfunction
(defun component-kwalist (component) (cddr component))
product-namefunction
(defun product-name (product) (caar product))
product-componentsfunction
(defun product-components (product) (cdar product))
product-kwalistfunction
(defun product-kwalist (product) (cdr product))
components-namesfunction
(defun components-names
  (components)
  (if (atom components)
    nil
    (cons (component-name (car components))
      (components-names (cdr components)))))
accessor-namefunction
(defun accessor-name
  (product component)
  (appsyms (list (product-name product) (component-name component))))
accessor-listfunction
(defun accessor-list
  (product components)
  (if (consp components)
    (cons (accessor-name product (car components))
      (accessor-list product (cdr components)))
    nil))
tm-split-listfunction
(defun tm-split-list
  (half rest first)
  (if (zp half)
    (mv (reverse first) rest)
    (tm-split-list (1- half) (cdr rest) (cons (car rest) first))))
argtreefunction
(defun argtree
  (cons args)
  (cond ((endp args) nil)
    ((endp (cdr args)) (car args))
    (t (mv-let (first second)
        (tm-split-list (floor (len args) 2) args nil)
        `(,CONS ,(ARGTREE CONS FIRST) ,(ARGTREE CONS SECOND))))))
recog-consp-listfunction
(defun recog-consp-list
  (nargs obj)
  (if (zp nargs)
    `((eq ,OBJ nil))
    (if (= nargs 1)
      '(t)
      (let ((flo (floor nargs 2)))
        (cons `(consp ,OBJ)
          (append (recog-consp-list flo `(car ,OBJ))
            (recog-consp-list (- nargs flo) `(cdr ,OBJ))))))))
tree-accessorfunction
(defun tree-accessor
  (n total nest opt)
  (if (zp total)
    nil
    (if (= 1 total)
      nest
      (let ((flo (floor total 2)))
        (if (<= n flo)
          (tree-accessor n
            flo
            `(,(IF (EQ OPT :SAFE)
     'SAFE-CAR
     'CAR) ,NEST)
            opt)
          (tree-accessor (- n flo)
            (- total flo)
            `(,(IF (EQ OPT :SAFE)
     'SAFE-CDR
     'CDR) ,NEST)
            opt))))))
other
(logic)
nth-opentheorem
(defthmd nth-open
  (implies (not (zp n))
    (equal (nth n x) (nth (1- n) (cdr x)))))
true-listp-len-0theorem
(defthmd true-listp-len-0
  (implies (true-listp x) (equal (equal (len x) 0) (not x))))
acl2-count-car-cdr-of-cons-lineartheorem
(defthmd acl2-count-car-cdr-of-cons-linear
  (implies (consp x)
    (and (< (acl2-count (car x)) (acl2-count x))
      (< (acl2-count (cdr x)) (acl2-count x))))
  :rule-classes :linear)
acl2-count-nth-of-cons-lineartheorem
(defthmd acl2-count-nth-of-cons-linear
  (implies (consp x)
    (< (acl2-count (nth n x)) (acl2-count x)))
  :rule-classes (:rewrite :linear)
  :hints (("Goal" :induct (nth n x))))
acl2-count-0-len-0theorem
(defthmd acl2-count-0-len-0
  (implies (equal (acl2-count x) 0) (< (len x) 1))
  :rule-classes :linear)
acl2-count-nth-of-len-2-or-greater-lineartheorem
(defthmd acl2-count-nth-of-len-2-or-greater-linear
  (and (implies (consp x)
      (<= (+ 1 (acl2-count (nth n x))) (acl2-count x)))
    (implies (<= 2 (len x))
      (< (+ 1 (acl2-count (nth n x))) (acl2-count x))))
  :hints (("Goal" :induct (nth n x)
     :in-theory (enable acl2-count-0-len-0)))
  :rule-classes (:rewrite :linear))
len-0-true-listp-not-xtheorem
(defthmd len-0-true-listp-not-x
  (implies (and x (true-listp x)) (not (equal (len x) 0))))