• 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

    Var

    Signature
    (var n numvars) → var-enc
    Arguments
    n — Guard (natp n).
    numvars — Guard (natp numvars).
    Returns
    var-enc — Type (natp var-enc).

    Definitions and Theorems

    Function: var

    (defun var (n numvars)
           (declare (xargs :guard (and (natp n) (natp numvars))))
           (declare (xargs :guard (< n numvars)))
           (let ((__function__ 'var))
                (declare (ignorable __function__))
                (b* ((n (lnfix n))
                     (numvars (lnfix numvars))
                     (w (ash 1 n))
                     (rep (ash (logmask w) w)))
                    (var-repetitions (+ 1 n) rep numvars))))

    Theorem: natp-of-var

    (defthm natp-of-var
            (b* ((var-enc (var n numvars)))
                (natp var-enc))
            :rule-classes :type-prescription)

    Theorem: logbitp-of-var

    (defthm logbitp-of-var
            (b* ((?var-enc (var n numvars)))
                (implies (< (nfix n) (nfix numvars))
                         (equal (logbitp env var-enc)
                                (and (< (nfix env) (ash 1 numvars))
                                     (logbitp n (nfix env)))))))

    Theorem: eval-of-var

    (defthm eval-of-var
            (b* ((?var-enc (var n numvars)))
                (implies (< (nfix n) (nfix numvars))
                         (equal (truth-eval var-enc env numvars)
                                (env-lookup n env)))))

    Theorem: var-size-basic

    (defthm var-size-basic
            (b* ((?var-enc (var n numvars)))
                (implies (and (< (nfix n) numvars)
                              (natp numvars))
                         (unsigned-byte-p (ash 1 numvars)
                                          var-enc))))

    Theorem: var-size

    (defthm var-size
            (b* ((?var-enc (var n numvars)))
                (implies (and (natp m)
                              (<= (ash 1 numvars) m)
                              (< (nfix n) numvars)
                              (natp numvars))
                         (unsigned-byte-p m var-enc))))

    Theorem: var-negated-masked-size

    (defthm
      var-negated-masked-size
      (b* ((?var-enc (var n numvars)))
          (implies (and (< (nfix n) numvars)
                        (natp numvars))
                   (unsigned-byte-p (- (ash 1 numvars) (ash 1 (nfix n)))
                                    (loghead (ash 1 numvars)
                                             (lognot var-enc))))))

    Theorem: var-negated

    (defthm var-negated
            (b* ((?var-enc (var n numvars)))
                (implies (and (< (nfix n) numvars)
                              (natp numvars))
                         (equal (loghead (ash 1 numvars)
                                         (lognot var-enc))
                                (logtail (ash 1 (nfix n)) var-enc)))))

    Theorem: var-of-nfix-n

    (defthm var-of-nfix-n
            (equal (var (nfix n) numvars)
                   (var n numvars)))

    Theorem: var-nat-equiv-congruence-on-n

    (defthm var-nat-equiv-congruence-on-n
            (implies (nat-equiv n n-equiv)
                     (equal (var n numvars)
                            (var n-equiv numvars)))
            :rule-classes :congruence)

    Theorem: var-of-nfix-numvars

    (defthm var-of-nfix-numvars
            (equal (var n (nfix numvars))
                   (var n numvars)))

    Theorem: var-nat-equiv-congruence-on-numvars

    (defthm var-nat-equiv-congruence-on-numvars
            (implies (nat-equiv numvars numvars-equiv)
                     (equal (var n numvars)
                            (var n numvars-equiv)))
            :rule-classes :congruence)