• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
        • Prime-fields
        • Json
        • Syntheto
        • File-io-light
        • Cryptography
        • Number-theory
        • Lists-light
        • Axe
        • Builtins
        • Solidity
          • Values
            • Integer-values
              • Integer-operations
                • Def-uint/int-binary-op
                • Def-uint/int-unary-op
                • Def-uint/int-comparison
                • Uint-mod
                  • Uint-div
                  • Uint-shr
                  • Uint-shl
                  • Int-mod
                  • Int-div
                  • Uint-xor
                  • Uint-sub
                  • Uint-mul
                  • Uint-ior
                  • Uint-exp
                  • Uint-and
                  • Uint-add
                  • Int-xor
                  • Int-sub
                  • Int-mul
                  • Int-ior
                  • Int-and
                  • Int-add
                  • Uint-le
                  • Uint-ge
                  • Uint-ne
                  • Uint-lt
                  • Uint-gt
                  • Uint-eq
                  • Int-ne
                  • Int-lt
                  • Int-le
                  • Int-gt
                  • Int-ge
                  • Int-eq
                  • Uint-minus
                  • Uint-not
                  • Int-not
                  • Int-minus
                • Bit-size
                • Uint
                • Int
              • Boolean-values
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Integer-operations

    Uint-mod

    Modulo of unsigned integer values.

    Signature
    (uint-mod left-operand right-operand) → result
    Arguments
    left-operand — Guard (uintp left-operand).
    right-operand — Guard (uintp right-operand).
    Returns
    result — Type (uintp result).

    This has the usual relation with division [SD: Types: Integers: Modulo], so we use rem here.

    Definitions and Theorems

    Function: uint-mod

    (defun uint-mod (left-operand right-operand)
      (declare (xargs :guard (and (uintp left-operand)
                                  (uintp right-operand))))
      (declare
           (xargs :guard (not (equal (uint->value right-operand) 0))))
      (b* ((size (uint->size left-operand))
           (x (uint->value left-operand))
           (y (uint->value right-operand)))
        (make-uint :size (uint->size left-operand)
                   :value (loghead size (rem x y)))))

    Theorem: uintp-of-uint-mod

    (defthm uintp-of-uint-mod
      (b* ((result (uint-mod left-operand right-operand)))
        (uintp result))
      :rule-classes :rewrite)

    Theorem: uint-mod-of-uint-fix-left-operand

    (defthm uint-mod-of-uint-fix-left-operand
      (equal (uint-mod (uint-fix left-operand)
                       right-operand)
             (uint-mod left-operand right-operand)))

    Theorem: uint-mod-uint-equiv-congruence-on-left-operand

    (defthm uint-mod-uint-equiv-congruence-on-left-operand
      (implies (uint-equiv left-operand left-operand-equiv)
               (equal (uint-mod left-operand right-operand)
                      (uint-mod left-operand-equiv right-operand)))
      :rule-classes :congruence)

    Theorem: uint-mod-of-uint-fix-right-operand

    (defthm uint-mod-of-uint-fix-right-operand
      (equal (uint-mod left-operand (uint-fix right-operand))
             (uint-mod left-operand right-operand)))

    Theorem: uint-mod-uint-equiv-congruence-on-right-operand

    (defthm uint-mod-uint-equiv-congruence-on-right-operand
      (implies (uint-equiv right-operand right-operand-equiv)
               (equal (uint-mod left-operand right-operand)
                      (uint-mod left-operand right-operand-equiv)))
      :rule-classes :congruence)