• Top
    • Documentation
    • Books
    • Boolean-reasoning
      • Ipasir
      • Aignet
      • Aig
      • Satlink
      • Truth
      • Ubdds
      • Bdd
      • Faig
      • Bed
      • 4v
        • 4v-sexprs
          • 4v-sexpr-vars
          • 4v-sexpr-eval
          • 4v-sexpr-to-faig
          • 4v-sexpr-restrict-with-rw
          • 4vs-constructors
          • 4v-sexpr-compose-with-rw
          • 4v-sexpr-restrict
          • 4v-sexpr-alist-extract
          • 4v-sexpr-compose
          • 4v-nsexpr-p
          • 4v-sexpr-purebool-p
          • 4v-sexpr-<=
          • Sfaig
          • Sexpr-equivs
          • 3v-syntax-sexprp
          • Sexpr-rewriting
            • 4v-shannon-expansion
            • Onehot-rewriting
              • 4v-onehot-sexpr-list-prime
              • 4v-onehot-sexpr-prime
              • 4v-onehot-rw-sexpr-alist-aux
                • 4v-onehot-rw-sexpr-alist
                • 4v-onehot-rw-sexpr
                • 4vs-onehot
                • 4vs-ite*-list-dumb
                • 4v-onehot-filter
                • 4v-onehot-list-p
              • 4v-sexpr-restrict-with-rw
              • 4v-sexpr-compose-with-rw
              • Sexpr-rewrite
              • Sexpr-rewrite-default
              • Sexpr-rewriting-internals
              • *sexpr-rewrites*
            • 4v-sexpr-ind
            • 4v-alist-extract
          • 4v-monotonicity
          • 4v-operations
          • Why-4v-logic
          • 4v-<=
          • 4vp
          • 4vcases
          • 4v-fix
          • 4v-lookup
      • Projects
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Onehot-rewriting

    4v-onehot-rw-sexpr-alist-aux

    Apply one-hot rewriting to a sexpr-alist.

    Logically this just walks over the alist and applies 4v-onehot-rw-sexpr to each value. But we actually use mbe to provide a more efficient implementation; see 4v-onehot-sexpr-list-prime for the basic idea and motivation.

    This is only an -aux function because it applies the onehot rewrite to every sexpr in the alist. Our main function, 4v-onehot-rw-sexpr-alist, first filters the alist to avoid rewriting sexprs that don't mention any of the variables we are assuming to be one-hot.

    Definitions and Theorems

    Function: 4v-onehot-rw-sexpr-alist-fast

    (defun 4v-onehot-rw-sexpr-alist-fast (vars sexpr-alist)
     (declare (xargs :guard (and (atom-listp vars)
                                 (not (member-equal nil vars)))))
     (let*
      ((names (alist-keys sexpr-alist))
       (sexprs (alist-vals sexpr-alist))
       (new-sexprs
            (4vs-ite*-list-dumb (4vs-onehot vars)
                                (4v-onehot-sexpr-list-prime vars sexprs)
                                (replicate (len sexprs) (4vs-x)))))
      (pairlis$ names new-sexprs)))

    Function: 4v-onehot-rw-sexpr-alist-aux

    (defun 4v-onehot-rw-sexpr-alist-aux (vars sexpr-alist)
     (declare (xargs :guard (and (atom-listp vars)
                                 (not (member-equal nil vars)))))
     (mbe
      :logic
      (cond
       ((atom sexpr-alist) nil)
       ((atom (car sexpr-alist))
        (4v-onehot-rw-sexpr-alist-aux vars (cdr sexpr-alist)))
       (t (cons (cons (caar sexpr-alist)
                      (4v-onehot-rw-sexpr vars (cdar sexpr-alist)))
                (4v-onehot-rw-sexpr-alist-aux vars (cdr sexpr-alist)))))
      :exec (4v-onehot-rw-sexpr-alist-fast vars sexpr-alist)))

    Theorem: 4v-onehot-rw-sexpr-alist-fast-removal

    (defthm 4v-onehot-rw-sexpr-alist-fast-removal
      (equal (4v-onehot-rw-sexpr-alist-fast vars sexpr-alist)
             (4v-onehot-rw-sexpr-alist-aux vars sexpr-alist)))

    Theorem: hons-assoc-equal-of-4v-onehot-rw-sexpr-alist-aux

    (defthm hons-assoc-equal-of-4v-onehot-rw-sexpr-alist-aux
     (equal
      (hons-assoc-equal name
                        (4v-onehot-rw-sexpr-alist-aux vars sexpr-alist))
      (if
       (hons-assoc-equal name sexpr-alist)
       (cons
         name
         (4v-onehot-rw-sexpr vars
                             (cdr (hons-assoc-equal name sexpr-alist))))
       nil)))

    Theorem: 4v-sexpr-alist-<=-of-4v-onehot-rw-sexpr-alist-aux

    (defthm 4v-sexpr-alist-<=-of-4v-onehot-rw-sexpr-alist-aux
     (implies
      (and (atom-listp vars)
           (not (member-equal nil vars)))
      (4v-sexpr-alist-<= (4v-onehot-rw-sexpr-alist-aux vars sexpr-alist)
                         sexpr-alist)))

    Theorem: 4v-sexpr-vars-list-of-4v-onehot-rw-sexpr-alist-aux

    (defthm 4v-sexpr-vars-list-of-4v-onehot-rw-sexpr-alist-aux
     (implies
      (atom-listp vars)
      (subsetp-equal
       (4v-sexpr-vars-list
           (alist-vals (4v-onehot-rw-sexpr-alist-aux vars sexpr-alist)))
       (append vars
               (4v-sexpr-vars-list (alist-vals sexpr-alist))))))