• 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
        • Program-execution
        • Sdm-instruction-set-summary
        • Tlb
        • Running-linux
        • Introduction
        • Asmtest
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
          • X86isa-state
          • Syscalls
          • Cpuid
          • Linear-memory
          • Rflag-specifications
          • Characterizing-undefined-behavior
          • Top-level-memory
          • App-view
          • X86-decoder
          • Physical-memory
          • Decoding-and-spec-utils
          • Instructions
            • Two-byte-opcodes
            • One-byte-opcodes
            • Fp-opcodes
            • Instruction-semantic-functions
              • Sar-spec
              • Shr-spec
              • Sal/shl-spec
              • Rol-spec
              • Ror-spec
              • Rcl-spec
              • Rcr-spec
              • Simd-sub-spec
              • Simd-add-spec
              • Imul-spec
              • Mul-spec
              • Idiv-spec
                • Idiv-spec-64
                • Idiv-spec-32
                • Idiv-spec-8
                • Idiv-spec-16
                • Div-spec
                • Shrd-spec
                • Shld-spec
                • Gpr-arith/logic-spec
                • Shrx-spec
                • Shlx-spec
                • Sarx-spec
                • Floating-point-specifications
              • X86-illegal-instruction
              • Implemented-opcodes
              • Opcode-maps
              • X86-general-protection
              • X86-device-not-available
              • X86-step-unimplemented
              • Privileged-opcodes
              • Three-byte-opcodes
            • Register-readers-and-writers
            • X86-modes
            • Segmentation
            • Other-non-deterministic-computations
            • Environment
            • Paging
          • Implemented-opcodes
          • To-do
          • Proof-utilities
          • Peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • 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
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Idiv-spec

    Idiv-spec-16

    Signature
    (idiv-spec-16 dst src) → (mv * * *)

    Definitions and Theorems

    Function: idiv-spec-16

    (defun idiv-spec-16 (dst src)
      (declare (type (unsigned-byte 32) dst)
               (type (unsigned-byte 16) src))
      (declare (xargs :guard (not (equal src 0))))
      (let ((__function__ 'idiv-spec-16))
        (declare (ignorable __function__))
        (b* ((dst-int (the (signed-byte 32) (ntoi 32 dst)))
             (src-int (the (signed-byte 16) (ntoi 16 src)))
             (quotient-int (the (signed-byte 33)
                                (truncate dst-int src-int)))
             (remainder-int (the (signed-byte 16)
                                 (rem dst-int src-int)))
             (overflow? (or (< (the (signed-byte 33) quotient-int)
                               -32768)
                            (< 32767
                               (the (signed-byte 33) quotient-int))))
             ((when overflow?)
              (mv (list (cons 'quotient-int quotient-int)
                        (cons 'remainder-int remainder-int))
                  0 0))
             (quotient (the (unsigned-byte 16)
                            (n-size 16 quotient-int)))
             (remainder (the (unsigned-byte 16)
                             (n-size 16 remainder-int))))
          (mv overflow? quotient remainder))))

    Theorem: n16-mv-nth-1-idiv-spec-16

    (defthm n16-mv-nth-1-idiv-spec-16
     (implies (not (mv-nth 0 (idiv-spec-16 dst src)))
              (unsigned-byte-p 16 (mv-nth 1 (idiv-spec-16 dst src))))
     :rule-classes
     (:rewrite
      (:type-prescription
          :corollary (implies (not (mv-nth 0 (idiv-spec-16 dst src)))
                              (natp (mv-nth 1 (idiv-spec-16 dst src))))
          :hints
          (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp))))
      (:linear
       :corollary (implies (not (mv-nth 0 (idiv-spec-16 dst src)))
                           (and (<= 0 (mv-nth 1 (idiv-spec-16 dst src)))
                                (< (mv-nth 1 (idiv-spec-16 dst src))
                                   65536)))
       :hints
       (("Goal"
            :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))

    Theorem: mv-nth-2-idiv-spec-16

    (defthm mv-nth-2-idiv-spec-16
     (implies (and (unsigned-byte-p 16 src) (< 0 src))
              (unsigned-byte-p 16 (mv-nth 2 (idiv-spec-16 dst src))))
     :rule-classes
     (:rewrite
      (:type-prescription
          :corollary (implies (and (unsigned-byte-p 16 src) (< 0 src))
                              (natp (mv-nth 2 (idiv-spec-16 dst src))))
          :hints
          (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp))))
      (:linear
       :corollary (implies (and (unsigned-byte-p 16 src) (< 0 src))
                           (and (<= 0 (mv-nth 2 (idiv-spec-16 dst src)))
                                (< (mv-nth 2 (idiv-spec-16 dst src))
                                   65536)))
       :hints
       (("Goal"
            :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))