• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
        • Svex-stvs
        • Svex-decomposition-methodology
        • Sv-versus-esim
        • Svex-decomp
        • Svex-compose-dfs
        • Svex-compilation
        • Moddb
        • Svmods
        • Svstmt
        • Sv-tutorial
        • Expressions
          • Rewriting
          • Svex
          • Bit-blasting
            • Svex-focused-equivalence-checking
            • A4vec-operations
            • Svexlist-eval-gl
            • Aig-symbolic-arithmetic
            • Svex-varmasks/env->aig-env-rec
            • Svex-varmasks->a4env-rec
            • Svexlist/env-list-eval-gl
            • 4vmask-to-a4vec-rec-env
            • 4vmask-to-a4vec-rec
              • Svexlist->a4vecs-for-varlist
              • Svex-varmasks/env->aig-env-stats-rec
              • Svexlist->a4vec-nrev
              • A4veclist/svex-env-list-eval
              • A4vec
              • Svexlist-x-out-unused-vars
              • Svex->a4vec-memotable-correctp
              • A4vec/svex-env-eval
              • Svex-varmasks->a4env
              • Svex-varmasks/env->aig-env-rec-log
              • 4vmask-to-a4vec-env
              • 4veclist-from-bitlist-log-rec
              • Svex-apply-aig
              • Svexlist-vars-for-symbolic-eval
              • Nat-bool-a4env-upper-boundp
              • 4vmask-to-a4vec
              • Svexlist/env-list-vars-for-symbolic-eval
              • Svex-maskbits-for-vars
              • Svexlist->a4vec-aig-env-for-varlist
              • 4vec-from-bitlist
              • Svexlist-full-masks-p
              • Svex-varmasks/env->aig-env-stats
              • Svex-varmasks/env->aig-env
              • Svexlistlist->a4vec
              • Svex-const-concat-args
              • Svex-mask-alist-extract-vars
              • Svexlist->a4vec-top
              • Nat-bool-a4vec-upper-boundp
              • Nat-bool-a4env-lower-boundp
              • Maybe-a3vec-fix
              • Svex-maskbits-ok
              • Svex-envlist-check-boolmasks
              • Svex-env-check-boolmasks
              • Nat-bool-list-upper-boundp
              • Nat-bool-a4vec-lower-boundp
              • Maybe-svexlist-rewrite-fixpoint
              • 4vmask-to-a4vec-varcount
              • A4vec-eval
              • Svexlist-nth
              • A4veclist-nth
              • Nat-bool-list-lower-boundp
              • 4veclist-from-bitlist
              • V2i-first-n
              • A4veclist-eval-gl
              • Svex-envlist-keyset
              • Svex-a4vec-env-eval
              • A4veclist/env-list-eval
              • Svexlist-variable-mask-alist
              • Sparseint-nfix
              • A4veclist-length
              • A4veclist-eval
              • 4vec-boolmaskp
              • Nat-bool-list-nats
              • Nat-bool-a4env-p
              • Nat-bool-listp
              • A4veclist->aiglist
              • Svexlist-rewrite-fixpoint-memo
              • Nat-bool-a4vec-p
              • A4vec->aiglist
              • Svex-is-const-concat
              • Nat-bool-a4env-vars
              • Svexlist-mask-alist-memo
              • Nat-bool-a4vec-vars
              • Svexlist-vars-memo
              • A4vec-constantp
              • Svex-aig-memotable
              • Svex-a4vec-env
              • A4veclistlist
              • A4veclist
              • Symbolic-params-x-out-cond
            • Functions
            • 4vmask
            • Why-infinite-width
            • Svex-vars
            • Evaluation
            • Values
          • Symbolic-test-vector
          • Vl-to-svex
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Bit-blasting

    4vmask-to-a4vec-rec

    Signature
    (4vmask-to-a4vec-rec mask boolmask nextvar) → (mv upper lower)
    Arguments
    mask — Guard (4vmask-p mask).
    boolmask — Guard (integerp boolmask).
    nextvar — Guard (natp nextvar).
    Returns
    upper — Type (nat-bool-listp upper).
    lower — Type (nat-bool-listp lower).

    Definitions and Theorems

    Function: 4vmask-to-a4vec-rec

    (defun 4vmask-to-a4vec-rec (mask boolmask nextvar)
      (declare (xargs :guard (and (4vmask-p mask)
                                  (integerp boolmask)
                                  (natp nextvar))))
      (declare (xargs :guard (not (sparseint-< mask 0))))
      (let ((__function__ '4vmask-to-a4vec-rec))
        (declare (ignorable __function__))
        (b* ((mask (sparseint-nfix (4vmask-fix mask)))
             (nextvar (lnfix nextvar))
             ((when (sparseint-equal mask 0))
              (mv (aig-sterm t) (aig-sterm nil)))
             ((mv ubit0 ubit1 nextvar)
              (if (eql 1 (sparseint-bit 0 mask))
                  (if (logbitp 0 boolmask)
                      (mv nextvar nextvar (+ 1 nextvar))
                    (mv nextvar (1+ nextvar) (+ 2 nextvar)))
                (mv t nil nextvar)))
             ((mv rest-upper rest-lower)
              (4vmask-to-a4vec-rec (sparseint-rightshift 1 mask)
                                   (logcdr boolmask)
                                   nextvar)))
          (mv (aig-scons ubit0 rest-upper)
              (aig-scons ubit1 rest-lower)))))

    Theorem: nat-bool-listp-of-4vmask-to-a4vec-rec.upper

    (defthm nat-bool-listp-of-4vmask-to-a4vec-rec.upper
      (b* (((mv ?upper ?lower)
            (4vmask-to-a4vec-rec mask boolmask nextvar)))
        (nat-bool-listp upper))
      :rule-classes :rewrite)

    Theorem: nat-bool-listp-of-4vmask-to-a4vec-rec.lower

    (defthm nat-bool-listp-of-4vmask-to-a4vec-rec.lower
      (b* (((mv ?upper ?lower)
            (4vmask-to-a4vec-rec mask boolmask nextvar)))
        (nat-bool-listp lower))
      :rule-classes :rewrite)

    Theorem: true-listp-of-4vmask-to-a4vec-rec-upper

    (defthm true-listp-of-4vmask-to-a4vec-rec-upper
      (b* (((mv ?upper ?lower)
            (4vmask-to-a4vec-rec mask boolmask nextvar)))
        (true-listp upper))
      :rule-classes :type-prescription)

    Theorem: true-listp-of-4vmask-to-a4vec-rec-lower

    (defthm true-listp-of-4vmask-to-a4vec-rec-lower
      (b* (((mv ?upper ?lower)
            (4vmask-to-a4vec-rec mask boolmask nextvar)))
        (true-listp lower))
      :rule-classes :type-prescription)

    Theorem: 4vmask-to-a4vec-rec-lower-bounds

    (defthm 4vmask-to-a4vec-rec-lower-bounds
     (and (nat-bool-list-lower-boundp
               nextvar
               (mv-nth 0
                       (4vmask-to-a4vec-rec mask boolmask nextvar)))
          (nat-bool-list-lower-boundp
               nextvar
               (mv-nth 1
                       (4vmask-to-a4vec-rec mask boolmask nextvar))))
     :rule-classes
     ((:forward-chaining
         :trigger-terms ((4vmask-to-a4vec-rec mask boolmask nextvar)))))

    Theorem: 4vmask-to-a4vec-rec-upper-bounds

    (defthm 4vmask-to-a4vec-rec-upper-bounds
     (and (nat-bool-list-upper-boundp
               (+ (nfix nextvar)
                  (4vmask-to-a4vec-varcount mask boolmask))
               (mv-nth 0
                       (4vmask-to-a4vec-rec mask boolmask nextvar)))
          (nat-bool-list-upper-boundp
               (+ (nfix nextvar)
                  (4vmask-to-a4vec-varcount mask boolmask))
               (mv-nth 1
                       (4vmask-to-a4vec-rec mask boolmask nextvar))))
     :rule-classes
     ((:forward-chaining
         :trigger-terms ((4vmask-to-a4vec-rec mask boolmask nextvar)))))

    Theorem: member-4vmask-to-a4vec-rec-vars

    (defthm member-4vmask-to-a4vec-rec-vars
     (iff
      (member
       v
       (append
            (nat-bool-list-nats
                 (mv-nth 0
                         (4vmask-to-a4vec-rec mask boolmask nextvar)))
            (nat-bool-list-nats
                 (mv-nth 1
                         (4vmask-to-a4vec-rec mask boolmask nextvar)))))
      (and (natp v)
           (<= (nfix nextvar) v)
           (< v
              (+ (nfix nextvar)
                 (4vmask-to-a4vec-varcount mask boolmask)))))
     :rule-classes nil)

    Theorem: 4vmask-to-a4vec-rec-of-4vmask-fix-mask

    (defthm 4vmask-to-a4vec-rec-of-4vmask-fix-mask
      (equal (4vmask-to-a4vec-rec (4vmask-fix mask)
                                  boolmask nextvar)
             (4vmask-to-a4vec-rec mask boolmask nextvar)))

    Theorem: 4vmask-to-a4vec-rec-4vmask-equiv-congruence-on-mask

    (defthm 4vmask-to-a4vec-rec-4vmask-equiv-congruence-on-mask
     (implies (4vmask-equiv mask mask-equiv)
              (equal (4vmask-to-a4vec-rec mask boolmask nextvar)
                     (4vmask-to-a4vec-rec mask-equiv boolmask nextvar)))
     :rule-classes :congruence)

    Theorem: 4vmask-to-a4vec-rec-of-ifix-boolmask

    (defthm 4vmask-to-a4vec-rec-of-ifix-boolmask
      (equal (4vmask-to-a4vec-rec mask (ifix boolmask)
                                  nextvar)
             (4vmask-to-a4vec-rec mask boolmask nextvar)))

    Theorem: 4vmask-to-a4vec-rec-int-equiv-congruence-on-boolmask

    (defthm 4vmask-to-a4vec-rec-int-equiv-congruence-on-boolmask
     (implies (int-equiv boolmask boolmask-equiv)
              (equal (4vmask-to-a4vec-rec mask boolmask nextvar)
                     (4vmask-to-a4vec-rec mask boolmask-equiv nextvar)))
     :rule-classes :congruence)

    Theorem: 4vmask-to-a4vec-rec-of-nfix-nextvar

    (defthm 4vmask-to-a4vec-rec-of-nfix-nextvar
      (equal (4vmask-to-a4vec-rec mask boolmask (nfix nextvar))
             (4vmask-to-a4vec-rec mask boolmask nextvar)))

    Theorem: 4vmask-to-a4vec-rec-nat-equiv-congruence-on-nextvar

    (defthm 4vmask-to-a4vec-rec-nat-equiv-congruence-on-nextvar
     (implies (nat-equiv nextvar nextvar-equiv)
              (equal (4vmask-to-a4vec-rec mask boolmask nextvar)
                     (4vmask-to-a4vec-rec mask boolmask nextvar-equiv)))
     :rule-classes :congruence)