• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • C
      • Proof-checker-array
      • Soft
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Ethereum
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • Zcash
      • Des
      • 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
            • Rflags-reads-and-writes
            • General-sf-spec-fn
              • General-cf-spec-fn
              • General-pf-spec-fn
              • General-of-spec-fn
              • Zf-spec
              • Sbb-af-spec8
              • Sbb-af-spec64
              • Sbb-af-spec32
              • Sbb-af-spec16
              • Adc-af-spec8
              • Adc-af-spec64
              • Adc-af-spec32
              • Adc-af-spec16
              • Sub-af-spec8
              • Sub-af-spec64
              • Sub-af-spec32
              • Sub-af-spec16
              • Add-af-spec8
              • Add-af-spec64
              • Add-af-spec32
              • Add-af-spec16
              • Pf-spec64
              • Pf-spec32
              • Pf-spec16
              • Of-spec64
              • Sf-spec64
              • Sf-spec32
              • Sf-spec16
              • Pf-spec8
              • Of-spec8
              • Of-spec32
              • Of-spec16
              • Cf-spec8
              • Cf-spec64
              • Cf-spec32
              • Cf-spec16
              • Sf-spec8
            • Characterizing-undefined-behavior
            • App-view
            • Top-level-memory
            • X86-decoder
            • Physical-memory
            • Decoding-and-spec-utils
            • Instructions
            • 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
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Axe
        • Poseidon
        • Where-do-i-place-my-book
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Rflag-specifications

    General-sf-spec-fn

    Signature
    (general-sf-spec-fn result-nbits result) → *

    General SF Specification (Source: Intel Manuals, Vol. 1, Section 3.4.3.1):

    Sign flag Set equal to the most-significant bit of the result, which is the sign bit of a signed integer. (0 indicates a positive value and 1 indicates a negative value.)

    Definitions and Theorems

    Function: general-sf-spec-fn$inline

    (defun general-sf-spec-fn$inline (result-nbits result)
      (declare (type (member 8 16 32 64) result-nbits)
               (type (integer 0 *) result))
      (declare (xargs :guard (unsigned-byte-p result-nbits result)))
      (mbe :logic (part-select result
                               :low (1- result-nbits)
                               :width 1)
           :exec (the (unsigned-byte 1)
                      (ash (if (eql result-nbits 64)
                               result
                             (the (unsigned-byte 50) result))
                           (the (integer -63 0)
                                (- (the (integer 0 63)
                                        (1- (the (integer 0 64)
                                                 result-nbits)))))))))

    Theorem: n01p-general-sf-spec-fn

    (defthm n01p-general-sf-spec-fn
     (unsigned-byte-p 1
                      (general-sf-spec-fn result-nbits result))
     :rule-classes
     (:rewrite
      (:type-prescription
         :corollary (bitp (general-sf-spec-fn result-nbits result))
         :hints
         (("Goal"
               :in-theory
               '(unsigned-byte-p integer-range-p natp bitp (:e expt)))))
      (:linear
       :corollary (and (<= 0
                           (general-sf-spec-fn result-nbits result))
                       (< (general-sf-spec-fn result-nbits result)
                          2))
       :hints
       (("Goal"
            :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))