• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
      • Ipasir
      • Aignet
      • Aig
      • Satlink
      • Truth
        • Index-permute-shrink
        • Permute-stretch
        • Env-mismatch-aux
        • Permute-shrink
        • Permute-polarity
        • Env-permute-polarity
        • Env-permute-shrink
        • Permute-var-down
        • Swap-vars-aux
          • Env-permute-stretch
          • Swap-vars
          • Permute-var-up
          • Negative-cofactor
          • Truth-perm-rev
          • Index-permute-stretch
          • Env-mismatch
          • Truth-perm
          • Swap-polarity
          • Positive-cofactor
          • Index-perm-rev
          • Env-perm-rev
          • Nth-set-bit-pos
          • Index-swap
          • Env-move-var-down
          • Is-xor-with-var
          • Index-perm
          • Env-swap-vars
          • Var
          • Truth-eval
          • Index-move-down
          • Env-update
          • Env-perm
          • Depends-on-witness
          • Env-swap-polarity
          • Var-repetitions
          • Env-move-var-up
          • Index-move-up
          • Depends-on
          • Truth-norm
          • Index-listp
          • Env-diff-index
          • Env-lookup
          • True
          • False
        • Ubdds
        • Bdd
        • Faig
        • Bed
        • 4v
      • Projects
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Truth

    Swap-vars-aux

    Signature
    (swap-vars-aux n m truth numvars) → swapped-truth
    Arguments
    n — Guard (natp n).
    m — Guard (natp m).
    truth — Guard (integerp truth).
    numvars — Guard (natp numvars).
    Returns
    swapped-truth — Type (integerp swapped-truth).

    Definitions and Theorems

    Function: swap-vars-aux

    (defun swap-vars-aux (n m truth numvars)
           (declare (xargs :guard (and (natp n)
                                       (natp m)
                                       (integerp truth)
                                       (natp numvars))))
           (declare (xargs :guard (and (< n numvars) (< m n))))
           (let ((__function__ 'swap-vars-aux))
                (declare (ignorable __function__))
                (b* ((truth (loghead (ash 1 (lnfix numvars)) truth))
                     (varn (var n numvars))
                     (varm (var m numvars))
                     (same (logeqv varn varm))
                     (n&~m (logand varn (lognot varm)))
                     (m&~n (logand varm (lognot varn)))
                     (shift (- (ash 1 (lnfix n))
                               (ash 1 (lnfix m)))))
                    (logior (logand same truth)
                            (ash (logand n&~m truth) (- shift))
                            (ash (logand m&~n truth) shift)))))

    Theorem: integerp-of-swap-vars-aux

    (defthm integerp-of-swap-vars-aux
            (b* ((swapped-truth (swap-vars-aux n m truth numvars)))
                (integerp swapped-truth))
            :rule-classes :type-prescription)

    Theorem: eval-of-swap-vars-aux

    (defthm
         eval-of-swap-vars-aux
         (b* ((?swapped-truth (swap-vars-aux n m truth numvars)))
             (implies (and (< (nfix n) (nfix numvars))
                           (< (nfix m) (nfix n)))
                      (equal (truth-eval swapped-truth env numvars)
                             (truth-eval truth (env-swap-vars n m env)
                                         numvars)))))

    Theorem: size-of-swap-vars-aux

    (defthm size-of-swap-vars-aux
            (b* ((?swapped-truth (swap-vars-aux n m truth numvars)))
                (implies (and (< (nfix n) (nfix numvars))
                              (< (nfix m) (nfix n))
                              (natp size)
                              (<= (ash 1 (nfix numvars)) size))
                         (unsigned-byte-p size swapped-truth))))

    Theorem: truth-norm-of-swap-vars-aux

    (defthm truth-norm-of-swap-vars-aux
            (b* ((?swapped-truth (swap-vars-aux n m truth numvars)))
                (implies (and (< (nfix n) (nfix numvars))
                              (< (nfix m) (nfix n)))
                         (equal (truth-norm swapped-truth numvars)
                                swapped-truth))))

    Theorem: swap-vars-aux-of-truth-norm

    (defthm swap-vars-aux-of-truth-norm
            (equal (swap-vars-aux n m (truth-norm truth numvars)
                                  numvars)
                   (swap-vars-aux n m truth numvars)))

    Theorem: swap-vars-aux-of-nfix-n

    (defthm swap-vars-aux-of-nfix-n
            (equal (swap-vars-aux (nfix n) m truth numvars)
                   (swap-vars-aux n m truth numvars)))

    Theorem: swap-vars-aux-nat-equiv-congruence-on-n

    (defthm swap-vars-aux-nat-equiv-congruence-on-n
            (implies (nat-equiv n n-equiv)
                     (equal (swap-vars-aux n m truth numvars)
                            (swap-vars-aux n-equiv m truth numvars)))
            :rule-classes :congruence)

    Theorem: swap-vars-aux-of-nfix-m

    (defthm swap-vars-aux-of-nfix-m
            (equal (swap-vars-aux n (nfix m) truth numvars)
                   (swap-vars-aux n m truth numvars)))

    Theorem: swap-vars-aux-nat-equiv-congruence-on-m

    (defthm swap-vars-aux-nat-equiv-congruence-on-m
            (implies (nat-equiv m m-equiv)
                     (equal (swap-vars-aux n m truth numvars)
                            (swap-vars-aux n m-equiv truth numvars)))
            :rule-classes :congruence)

    Theorem: swap-vars-aux-of-ifix-truth

    (defthm swap-vars-aux-of-ifix-truth
            (equal (swap-vars-aux n m (ifix truth) numvars)
                   (swap-vars-aux n m truth numvars)))

    Theorem: swap-vars-aux-int-equiv-congruence-on-truth

    (defthm swap-vars-aux-int-equiv-congruence-on-truth
            (implies (int-equiv truth truth-equiv)
                     (equal (swap-vars-aux n m truth numvars)
                            (swap-vars-aux n m truth-equiv numvars)))
            :rule-classes :congruence)

    Theorem: swap-vars-aux-of-nfix-numvars

    (defthm swap-vars-aux-of-nfix-numvars
            (equal (swap-vars-aux n m truth (nfix numvars))
                   (swap-vars-aux n m truth numvars)))

    Theorem: swap-vars-aux-nat-equiv-congruence-on-numvars

    (defthm swap-vars-aux-nat-equiv-congruence-on-numvars
            (implies (nat-equiv numvars numvars-equiv)
                     (equal (swap-vars-aux n m truth numvars)
                            (swap-vars-aux n m truth numvars-equiv)))
            :rule-classes :congruence)