• 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
          • Syntax-for-tools
          • Atc
          • Language
            • Abstract-syntax
            • Integer-ranges
            • Implementation-environments
              • Schar-format
              • Uinteger-sinteger-bit-roles-wfp
              • Integer-format
              • Sinteger-format
              • Integer-format-llong-wfp
              • Integer-format-short-wfp
              • Integer-format-long-wfp
              • Integer-format-int-wfp
              • Uinteger-format
              • Schar-format->min
              • Char+short+int+long+llong-format
              • Uchar-format
              • Char-format->min
              • Integer-format-inc-sign-tcnpnt
              • Char-format->max
              • Sinteger-format->min
              • Sinteger-bit-role
              • Sinteger-bit-roles-wfp
              • Schar-format->max
              • Signed-format
                • Signed-format-fix
                • Signed-format-case
                  • Signed-format-equiv
                  • Signed-formatp
                  • Signed-format-kind
                  • Signed-format-twos-complement
                  • Signed-format-sign-magnitude
                  • Signed-format-ones-complement
                • Short-format-16tcnt
                • Llong-format-64tcnt
                • Ienv
                • Uinteger-bit-role
                • Long-format-32tcnt
                • Int-format-16tcnt
                • Uinteger-bit-roles-wfp
                • Uinteger+sinteger-format
                • Uinteger-bit-roles-value-count
                • Sinteger-bit-roles-value-count
                • Sinteger-bit-roles-inc-n-and-sign
                • Uinteger-bit-roles-inc-n
                • Sinteger-format-inc-sign-tcnpnt
                • Sinteger-bit-roles-inc-n
                • Uchar-format->max
                • Char+short+int+long+llong-format-wfp
                • Uinteger-bit-roles-exponents
                • Sinteger-bit-roles-exponents
                • Integer-format->bit-size
                • Char-format
                • Sinteger-bit-roles-sign-count
                • Ienv->char-min
                • Uinteger-format-inc-npnt
                • Ienv->schar-min
                • Ienv->char-size
                • Ienv->char-max
                • Uinteger-format->max
                • Sinteger-format->max
                • Ienv->schar-max
                • Ienv->uchar-max
                • Ienv->short-bit-size
                • Ienv->long-bit-size
                • Ienv->llong-bit-size
                • Schar-format-8tcnt
                • Ienv->int-bit-size
                • Ienv->sshort-min
                • Ienv->sllong-min
                • Char-format-8u
                • Ienv->ushort-max
                • Ienv->ulong-max
                • Ienv->ullong-max
                • Ienv->uint-max
                • Ienv->sshort-max
                • Ienv->slong-min
                • Ienv->slong-max
                • Ienv->sllong-max
                • Ienv->sint-min
                • Ienv->sint-max
                • Char8+short16+int16+long32+llong64-tcnt
                • Uchar-format-8
                • Uinteger-bit-role-list
                • Sinteger-bit-role-list
                • Uinteger-sinteger-bit-roles-wfp-of-inc-n-and-sign
              • Dynamic-semantics
              • Static-semantics
              • Grammar
              • Integer-formats
              • Types
              • Portable-ascii-identifiers
              • Values
              • Integer-operations
              • Computation-states
              • Object-designators
              • Operations
              • Errors
              • Tag-environments
              • Function-environments
              • Character-sets
              • Flexible-array-member-removal
              • Arithmetic-operations
              • Pointer-operations
              • Bytes
              • Keywords
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • Representation
            • Transformation-tools
            • Insertion-sort
            • Pack
          • 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
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Signed-format

    Signed-format-case

    Case macro for the different kinds of signed-format structures.

    This is an ACL2::fty sum-type case macro, typically introduced by fty::defflexsum or fty::deftagsum. It allows you to safely check the type of a signed-format structure, or to split into cases based on its type.

    Short Form

    In its short form, signed-format-case allows you to safely check the type of a signed-format structure. For example:

    (signed-format-case x :sign-magnitude)

    is essentially just a safer alternative to writing:

    (equal (signed-format-kind x) :sign-magnitude)

    Why is using signed-format-case safer? When we directly inspect the kind with equal, there is no static checking being done to ensure that, e.g., :sign-magnitude is a valid kind of signed-format structure. That means there is nothing to save you if, later, you change the kind keyword for this type from :sign-magnitude to something else. It also means you get no help if you just make a typo when writing the :sign-magnitude symbol. Over the course of developing VL, we found that such issues were very frequent sources of errors!

    Long Form

    In its longer form, signed-format-case allows you to split into cases based on the kind of structure you are looking at. A typical example would be:

    (signed-format-case x
      :sign-magnitude ...
      :ones-complement ...
      :twos-complement ...)

    It is also possible to consolidate ``uninteresting'' cases using :otherwise.

    For convenience, the case macro automatically binds the fields of x for you, as appropriate for each case. That is, in the :sign-magnitude case, you can use fty::defprod-style foo.bar style accessors for x without having to explicitly add a sign-magnitude b* binder.