• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Poseidon
      • Where-do-i-place-my-book
      • Axe
      • Bigmems
      • Builtins
      • Execloader
      • Aleo
      • 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
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Integer-operations

    Int-mod

    Modulo of signed integer values.

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

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

    Definitions and Theorems

    Function: int-mod

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

    Theorem: intp-of-int-mod

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

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

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

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

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

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

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

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

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