• 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
      • Debugging
      • Projects
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Truth

    Index-perm

    Signature
    (index-perm n perm x numvars) → perm-idx
    Arguments
    n — current position in the list.
        Guard (natp n).
    perm — indices to permute.
        Guard (nat-listp perm).
    x — index to permute.
        Guard (natp x).
    numvars — Guard (natp numvars).
    Returns
    perm-idx — Type (natp perm-idx).

    Definitions and Theorems

    Function: index-perm

    (defun index-perm (n perm x numvars)
           (declare (xargs :guard (and (natp n)
                                       (nat-listp perm)
                                       (natp x)
                                       (natp numvars))))
           (declare (xargs :guard (and (<= n numvars)
                                       (eql (len perm) numvars))))
           (let ((__function__ 'index-perm))
                (declare (ignorable __function__))
                (b* (((when (mbe :logic (zp (- (nfix numvars) (nfix n)))
                                 :exec (eql n numvars)))
                      (lnfix x))
                     (x (index-swap n (nth n perm) x)))
                    (index-perm (1+ (lnfix n))
                                perm x numvars))))

    Theorem: natp-of-index-perm

    (defthm natp-of-index-perm
            (b* ((perm-idx (index-perm n perm x numvars)))
                (natp perm-idx))
            :rule-classes :type-prescription)

    Theorem: bound-of-index-perm

    (defthm bound-of-index-perm
            (b* ((?perm-idx (index-perm n perm x numvars)))
                (implies (and (< (nfix x) (nfix numvars))
                              (index-listp perm numvars))
                         (< perm-idx (nfix numvars))))
            :rule-classes :linear)

    Theorem: index-perm-unique

    (defthm index-perm-unique
            (iff (equal (index-perm n perm x numvars)
                        (index-perm n perm y numvars))
                 (equal (nfix x) (nfix y))))

    Theorem: index-perm-of-nfix-n

    (defthm index-perm-of-nfix-n
            (equal (index-perm (nfix n) perm x numvars)
                   (index-perm n perm x numvars)))

    Theorem: index-perm-nat-equiv-congruence-on-n

    (defthm index-perm-nat-equiv-congruence-on-n
            (implies (nat-equiv n n-equiv)
                     (equal (index-perm n perm x numvars)
                            (index-perm n-equiv perm x numvars)))
            :rule-classes :congruence)

    Theorem: index-perm-of-nfix-x

    (defthm index-perm-of-nfix-x
            (equal (index-perm n perm (nfix x) numvars)
                   (index-perm n perm x numvars)))

    Theorem: index-perm-nat-equiv-congruence-on-x

    (defthm index-perm-nat-equiv-congruence-on-x
            (implies (nat-equiv x x-equiv)
                     (equal (index-perm n perm x numvars)
                            (index-perm n perm x-equiv numvars)))
            :rule-classes :congruence)

    Theorem: index-perm-of-nfix-numvars

    (defthm index-perm-of-nfix-numvars
            (equal (index-perm n perm x (nfix numvars))
                   (index-perm n perm x numvars)))

    Theorem: index-perm-nat-equiv-congruence-on-numvars

    (defthm index-perm-nat-equiv-congruence-on-numvars
            (implies (nat-equiv numvars numvars-equiv)
                     (equal (index-perm n perm x numvars)
                            (index-perm n perm x numvars-equiv)))
            :rule-classes :congruence)