• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
      • 100-theorems
      • Arithmetic
      • Bit-vectors
        • Sparseint
          • Sparseint-impl
          • Sparseint-p
          • Sparseint-binary-bittest
          • Sparseint-concatenate
          • Sparseint-binary-bitop
          • Sparseint-bitite
            • Sparseint-fix
            • Sparseint$-binary-minus
            • Sparseint-trailing-1-count-from
            • Sparseint-trailing-0-count-from
            • Sparseint-equal
            • Sparseint-test-bitorc2
            • Sparseint-test-bitorc1
            • Sparseint-test-bitnand
            • Sparseint-test-bitandc2
            • Sparseint-test-bitandc1
            • Sparseint-test-bitand
            • Sparseint-rightshift
            • Sparseint-bitcount-from
            • Sparseint-test-bitxor
            • Sparseint-test-bitor
            • Sparseint-test-bitnor
            • Sparseint-test-biteqv
            • Sparseint-compare
            • Sparseint-binary-minus
            • Sparseint-sign-ext
            • Sparseint-plus
            • Sparseint-bitandc2
            • Sparseint-bitandc1
            • Sparseint-bitand
            • Sparseint$-leaf-bitlimit
            • Sparseint-bitxor
            • Sparseint-bitorc2
            • Sparseint-bitorc1
            • Sparseint-bitor
            • Sparseint-bitnor
            • Sparseint-bitnand
            • Sparseint-biteqv
            • Sparseint-ash
            • Sparseint-<
            • Sparseint-bit
            • Sparseint-trailing-1-count
            • Sparseint-trailing-0-count
            • Sparseint-unary-minus
            • Sparseint-length
            • Sparseint-bitnot
            • Sparseint-bitcount
            • Int-to-sparseint
            • Sparseint-val
          • Bitops
          • Bv
          • Ihs
          • Rtl
        • Algebra
      • Testing-utilities
    • Sparseint

    Sparseint-bitite

    Compute the bitwise if-then-else of the three sparseint inputs.

    Signature
    (sparseint-bitite test then else) → ite
    Arguments
    test — Guard (sparseint-p test).
    then — Guard (sparseint-p then).
    else — Guard (sparseint-p else).
    Returns
    ite — Type (sparseint-p ite).

    Definitions and Theorems

    Function: sparseint-bitite

    (defun sparseint-bitite (test then else)
      (declare (xargs :guard (and (sparseint-p test)
                                  (sparseint-p then)
                                  (sparseint-p else))))
      (let ((__function__ 'sparseint-bitite))
        (declare (ignorable __function__))
        (b* ((test (sparseint-fix test))
             (then (sparseint-fix then))
             (else (sparseint-fix else))
             (test.height (sparseint$-height test))
             ((mv test&then test&then.height)
              (sparseint$-binary-bitop-offset
                   8 test test.height
                   0 then (sparseint$-height then)))
             ((mv ~test&else ~test&else.height)
              (sparseint$-binary-bitop-offset
                   4 test test.height
                   0 else (sparseint$-height else)))
             ((mv if ?if.height)
              (sparseint$-binary-bitop-offset
                   14 test&then test&then.height
                   0 ~test&else ~test&else.height)))
          if)))

    Theorem: sparseint-p-of-sparseint-bitite

    (defthm sparseint-p-of-sparseint-bitite
      (b* ((ite (sparseint-bitite test then else)))
        (sparseint-p ite))
      :rule-classes :rewrite)

    Theorem: sparseint-bitite-correct

    (defthm sparseint-bitite-correct
      (b* ((?ite (sparseint-bitite test then else)))
        (equal (sparseint-val ite)
               (logite (sparseint-val test)
                       (sparseint-val then)
                       (sparseint-val else)))))

    Theorem: sparseint-bitite-of-sparseint-fix-test

    (defthm sparseint-bitite-of-sparseint-fix-test
      (equal (sparseint-bitite (sparseint-fix test)
                               then else)
             (sparseint-bitite test then else)))

    Theorem: sparseint-bitite-sparseint-equiv-congruence-on-test

    (defthm sparseint-bitite-sparseint-equiv-congruence-on-test
      (implies (sparseint-equiv test test-equiv)
               (equal (sparseint-bitite test then else)
                      (sparseint-bitite test-equiv then else)))
      :rule-classes :congruence)

    Theorem: sparseint-bitite-of-sparseint-fix-then

    (defthm sparseint-bitite-of-sparseint-fix-then
      (equal (sparseint-bitite test (sparseint-fix then)
                               else)
             (sparseint-bitite test then else)))

    Theorem: sparseint-bitite-sparseint-equiv-congruence-on-then

    (defthm sparseint-bitite-sparseint-equiv-congruence-on-then
      (implies (sparseint-equiv then then-equiv)
               (equal (sparseint-bitite test then else)
                      (sparseint-bitite test then-equiv else)))
      :rule-classes :congruence)

    Theorem: sparseint-bitite-of-sparseint-fix-else

    (defthm sparseint-bitite-of-sparseint-fix-else
      (equal (sparseint-bitite test then (sparseint-fix else))
             (sparseint-bitite test then else)))

    Theorem: sparseint-bitite-sparseint-equiv-congruence-on-else

    (defthm sparseint-bitite-sparseint-equiv-congruence-on-else
      (implies (sparseint-equiv else else-equiv)
               (equal (sparseint-bitite test then else)
                      (sparseint-bitite test then else-equiv)))
      :rule-classes :congruence)