• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Error-checking
        • Apt
        • Abnf
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Prime-field-constraint-systems
        • Soft
        • Bv
        • Imp-language
        • Event-macros
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
        • Prime-fields
        • Java
        • C
          • Atc
          • Language
          • Representation
            • Representation-of-integer-operations
            • Representation-of-integers
            • Representation-of-integer-conversions
              • Def-integer-conversion
              • Integer-conversions-signed-from-unsigned-okp
              • Def-integer-conversions-loop-outer
              • Def-integer-conversions-loop-inner
              • Sshort-from-ullong-okp
              • Sllong-from-ushort-okp
              • Sllong-from-ullong-okp
              • Sshort-from-ushort-okp
              • Sshort-from-ulong-okp
              • Sshort-from-uint-okp
              • Sshort-from-uchar-okp
              • Sshort-from-slong-okp
              • Sshort-from-sllong-okp
              • Sshort-from-sint-okp
              • Slong-from-ushort-okp
              • Slong-from-ulong-okp
              • Slong-from-ullong-okp
              • Slong-from-uint-okp
              • Slong-from-uchar-okp
              • Slong-from-sllong-okp
              • Sllong-from-ulong-okp
              • Sllong-from-uint-okp
              • Sllong-from-uchar-okp
              • Sint-from-ushort-okp
              • Sint-from-ulong-okp
              • Sint-from-ullong-okp
              • Sint-from-uchar-okp
              • Sint-from-slong-okp
              • Sint-from-sllong-okp
              • Schar-from-ushort-okp
              • Schar-from-ulong-okp
              • Schar-from-ullong-okp
              • Schar-from-uint-okp
              • Schar-from-uchar-okp
              • Schar-from-sshort-okp
              • Schar-from-slong-okp
              • Schar-from-sllong-okp
              • Schar-from-sint-okp
              • Ushort-from-ulong
              • Ushort-from-ullong
              • Ushort-from-uint
              • Ushort-from-uchar
              • Ushort-from-sshort
              • Ushort-from-slong
              • Ushort-from-sllong
              • Ushort-from-sint
              • Ushort-from-schar
              • Ulong-from-ushort
              • Ulong-from-ullong
              • Ulong-from-uchar
              • Ulong-from-sshort
              • Ulong-from-slong
              • Ulong-from-sllong
              • Ulong-from-schar
              • Ullong-from-ushort
              • Ullong-from-ulong
              • Ullong-from-uint
              • Ullong-from-uchar
              • Ullong-from-sshort
              • Ullong-from-slong
              • Ullong-from-sllong
              • Ullong-from-sint
              • Ullong-from-schar
              • Uint-from-ushort
              • Uint-from-ullong
              • Uint-from-sshort
              • Uint-from-sllong
              • Uchar-from-ushort
              • Uchar-from-ulong
              • Uchar-from-ullong
              • Uchar-from-sshort
              • Uchar-from-slong
              • Uchar-from-sllong
              • Uchar-from-schar
              • Sshort-from-ushort
              • Sshort-from-ulong
              • Sshort-from-ullong
              • Sshort-from-uint
              • Sshort-from-uchar
              • Sshort-from-slong
              • Sshort-from-sllong
              • Sshort-from-sint
              • Sshort-from-schar
              • Slong-from-ushort
              • Slong-from-ulong
              • Slong-from-ullong
              • Slong-from-uint
              • Slong-from-uchar
              • Slong-from-sshort
              • Slong-from-sllong
              • Sllong-from-ushort
              • Sllong-from-ulong
              • Sllong-from-ullong
              • Sllong-from-uint
              • Sllong-from-uchar
              • Sllong-from-sshort
              • Sllong-from-slong
              • Sllong-from-sint
              • Sllong-from-schar
              • Sint-from-ushort
              • Sint-from-ulong
              • Sint-from-ullong
              • Sint-from-uint-okp
              • Sint-from-uchar
              • Sint-from-sshort
              • Sint-from-slong
              • Sint-from-sllong
              • Schar-from-ushort
              • Schar-from-ulong
              • Schar-from-ullong
              • Schar-from-uint
              • Schar-from-uchar
              • Schar-from-sshort
              • Schar-from-slong
              • Schar-from-sllong
              • Schar-from-sint
              • Ulong-from-uint
              • Ulong-from-sint
              • Uint-from-ulong
              • Uint-from-uchar
              • Uint-from-slong
              • Uint-from-sint
              • Uint-from-schar
              • Uchar-from-uint
              • Uchar-from-sint
              • Slong-from-sint
              • Slong-from-schar
              • Sint-from-uint
              • Sint-from-schar
          • Pack
        • Syntheto
        • Number-theory
        • Cryptography
        • Lists-light
        • File-io-light
        • Json
        • Built-ins
        • Axe
        • Solidity
        • Std-extensions
        • Htclient
        • Typed-lists-light
        • Arithmetic-light
      • X86isa
      • Axe
      • Execloader
    • Testing-utilities
    • Math
  • Representation

Representation-of-integer-conversions

A representation of C integer conversions in ACL2.

This is part of the shallow embedding.

We define ACL2 functions that convert between values of different C integer types.

Conversions between C types are described in [C:6.3]. Here we define conversions among the integer types supported by our model; these conversions are described in [C:6.3.1.3].

For the case of a conversion to a signed integer that cannot represent the original value, we use a guard that rules out that case. This way, in order to use the conversion, it must be provably the case that the value is representable in the new signed integer type.

For the case of a conversion to an unsigned integer, we use mod (via the modular constructor) to make it fit. If the original value fits, the mod has no effect. Otherwise, the mod corresponds to the repeated addition or subtraction described in [C:6.3.1.3].

Subtopics

Def-integer-conversion
Event to generate the conversion between C integer types.
Integer-conversions-signed-from-unsigned-okp
Theorems about certain conversions from unsigned to signed being always allowed for certain integer type sizes.
Def-integer-conversions-loop-outer
Events to generate the conversions between each of a list of source types and each of a list of destination types.
Def-integer-conversions-loop-inner
Events to generate the conversions between a source type and each of a list of destination types.
Sshort-from-ullong-okp
Check if a conversion from type unsigned long long to type signed short is well-defined.
Sllong-from-ushort-okp
Check if a conversion from type unsigned short to type signed long long is well-defined.
Sllong-from-ullong-okp
Check if a conversion from type unsigned long long to type signed long long is well-defined.
Sshort-from-ushort-okp
Check if a conversion from type unsigned short to type signed short is well-defined.
Sshort-from-ulong-okp
Check if a conversion from type unsigned long to type signed short is well-defined.
Sshort-from-uint-okp
Check if a conversion from type unsigned int to type signed short is well-defined.
Sshort-from-uchar-okp
Check if a conversion from type unsigned char to type signed short is well-defined.
Sshort-from-slong-okp
Check if a conversion from type signed long to type signed short is well-defined.
Sshort-from-sllong-okp
Check if a conversion from type signed long long to type signed short is well-defined.
Sshort-from-sint-okp
Check if a conversion from type signed int to type signed short is well-defined.
Slong-from-ushort-okp
Check if a conversion from type unsigned short to type signed long is well-defined.
Slong-from-ulong-okp
Check if a conversion from type unsigned long to type signed long is well-defined.
Slong-from-ullong-okp
Check if a conversion from type unsigned long long to type signed long is well-defined.
Slong-from-uint-okp
Check if a conversion from type unsigned int to type signed long is well-defined.
Slong-from-uchar-okp
Check if a conversion from type unsigned char to type signed long is well-defined.
Slong-from-sllong-okp
Check if a conversion from type signed long long to type signed long is well-defined.
Sllong-from-ulong-okp
Check if a conversion from type unsigned long to type signed long long is well-defined.
Sllong-from-uint-okp
Check if a conversion from type unsigned int to type signed long long is well-defined.
Sllong-from-uchar-okp
Check if a conversion from type unsigned char to type signed long long is well-defined.
Sint-from-ushort-okp
Check if a conversion from type unsigned short to type signed int is well-defined.
Sint-from-ulong-okp
Check if a conversion from type unsigned long to type signed int is well-defined.
Sint-from-ullong-okp
Check if a conversion from type unsigned long long to type signed int is well-defined.
Sint-from-uchar-okp
Check if a conversion from type unsigned char to type signed int is well-defined.
Sint-from-slong-okp
Check if a conversion from type signed long to type signed int is well-defined.
Sint-from-sllong-okp
Check if a conversion from type signed long long to type signed int is well-defined.
Schar-from-ushort-okp
Check if a conversion from type unsigned short to type signed char is well-defined.
Schar-from-ulong-okp
Check if a conversion from type unsigned long to type signed char is well-defined.
Schar-from-ullong-okp
Check if a conversion from type unsigned long long to type signed char is well-defined.
Schar-from-uint-okp
Check if a conversion from type unsigned int to type signed char is well-defined.
Schar-from-uchar-okp
Check if a conversion from type unsigned char to type signed char is well-defined.
Schar-from-sshort-okp
Check if a conversion from type signed short to type signed char is well-defined.
Schar-from-slong-okp
Check if a conversion from type signed long to type signed char is well-defined.
Schar-from-sllong-okp
Check if a conversion from type signed long long to type signed char is well-defined.
Schar-from-sint-okp
Check if a conversion from type signed int to type signed char is well-defined.
Ushort-from-ulong
Convert from type unsigned long to type unsigned short.
Ushort-from-ullong
Convert from type unsigned long long to type unsigned short.
Ushort-from-uint
Convert from type unsigned int to type unsigned short.
Ushort-from-uchar
Convert from type unsigned char to type unsigned short.
Ushort-from-sshort
Convert from type signed short to type unsigned short.
Ushort-from-slong
Convert from type signed long to type unsigned short.
Ushort-from-sllong
Convert from type signed long long to type unsigned short.
Ushort-from-sint
Convert from type signed int to type unsigned short.
Ushort-from-schar
Convert from type signed char to type unsigned short.
Ulong-from-ushort
Convert from type unsigned short to type unsigned long.
Ulong-from-ullong
Convert from type unsigned long long to type unsigned long.
Ulong-from-uchar
Convert from type unsigned char to type unsigned long.
Ulong-from-sshort
Convert from type signed short to type unsigned long.
Ulong-from-slong
Convert from type signed long to type unsigned long.
Ulong-from-sllong
Convert from type signed long long to type unsigned long.
Ulong-from-schar
Convert from type signed char to type unsigned long.
Ullong-from-ushort
Convert from type unsigned short to type unsigned long long.
Ullong-from-ulong
Convert from type unsigned long to type unsigned long long.
Ullong-from-uint
Convert from type unsigned int to type unsigned long long.
Ullong-from-uchar
Convert from type unsigned char to type unsigned long long.
Ullong-from-sshort
Convert from type signed short to type unsigned long long.
Ullong-from-slong
Convert from type signed long to type unsigned long long.
Ullong-from-sllong
Convert from type signed long long to type unsigned long long.
Ullong-from-sint
Convert from type signed int to type unsigned long long.
Ullong-from-schar
Convert from type signed char to type unsigned long long.
Uint-from-ushort
Convert from type unsigned short to type unsigned int.
Uint-from-ullong
Convert from type unsigned long long to type unsigned int.
Uint-from-sshort
Convert from type signed short to type unsigned int.
Uint-from-sllong
Convert from type signed long long to type unsigned int.
Uchar-from-ushort
Convert from type unsigned short to type unsigned char.
Uchar-from-ulong
Convert from type unsigned long to type unsigned char.
Uchar-from-ullong
Convert from type unsigned long long to type unsigned char.
Uchar-from-sshort
Convert from type signed short to type unsigned char.
Uchar-from-slong
Convert from type signed long to type unsigned char.
Uchar-from-sllong
Convert from type signed long long to type unsigned char.
Uchar-from-schar
Convert from type signed char to type unsigned char.
Sshort-from-ushort
Convert from type unsigned short to type signed short.
Sshort-from-ulong
Convert from type unsigned long to type signed short.
Sshort-from-ullong
Convert from type unsigned long long to type signed short.
Sshort-from-uint
Convert from type unsigned int to type signed short.
Sshort-from-uchar
Convert from type unsigned char to type signed short.
Sshort-from-slong
Convert from type signed long to type signed short.
Sshort-from-sllong
Convert from type signed long long to type signed short.
Sshort-from-sint
Convert from type signed int to type signed short.
Sshort-from-schar
Convert from type signed char to type signed short.
Slong-from-ushort
Convert from type unsigned short to type signed long.
Slong-from-ulong
Convert from type unsigned long to type signed long.
Slong-from-ullong
Convert from type unsigned long long to type signed long.
Slong-from-uint
Convert from type unsigned int to type signed long.
Slong-from-uchar
Convert from type unsigned char to type signed long.
Slong-from-sshort
Convert from type signed short to type signed long.
Slong-from-sllong
Convert from type signed long long to type signed long.
Sllong-from-ushort
Convert from type unsigned short to type signed long long.
Sllong-from-ulong
Convert from type unsigned long to type signed long long.
Sllong-from-ullong
Convert from type unsigned long long to type signed long long.
Sllong-from-uint
Convert from type unsigned int to type signed long long.
Sllong-from-uchar
Convert from type unsigned char to type signed long long.
Sllong-from-sshort
Convert from type signed short to type signed long long.
Sllong-from-slong
Convert from type signed long to type signed long long.
Sllong-from-sint
Convert from type signed int to type signed long long.
Sllong-from-schar
Convert from type signed char to type signed long long.
Sint-from-ushort
Convert from type unsigned short to type signed int.
Sint-from-ulong
Convert from type unsigned long to type signed int.
Sint-from-ullong
Convert from type unsigned long long to type signed int.
Sint-from-uint-okp
Check if a conversion from type unsigned int to type signed int is well-defined.
Sint-from-uchar
Convert from type unsigned char to type signed int.
Sint-from-sshort
Convert from type signed short to type signed int.
Sint-from-slong
Convert from type signed long to type signed int.
Sint-from-sllong
Convert from type signed long long to type signed int.
Schar-from-ushort
Convert from type unsigned short to type signed char.
Schar-from-ulong
Convert from type unsigned long to type signed char.
Schar-from-ullong
Convert from type unsigned long long to type signed char.
Schar-from-uint
Convert from type unsigned int to type signed char.
Schar-from-uchar
Convert from type unsigned char to type signed char.
Schar-from-sshort
Convert from type signed short to type signed char.
Schar-from-slong
Convert from type signed long to type signed char.
Schar-from-sllong
Convert from type signed long long to type signed char.
Schar-from-sint
Convert from type signed int to type signed char.
Ulong-from-uint
Convert from type unsigned int to type unsigned long.
Ulong-from-sint
Convert from type signed int to type unsigned long.
Uint-from-ulong
Convert from type unsigned long to type unsigned int.
Uint-from-uchar
Convert from type unsigned char to type unsigned int.
Uint-from-slong
Convert from type signed long to type unsigned int.
Uint-from-sint
Convert from type signed int to type unsigned int.
Uint-from-schar
Convert from type signed char to type unsigned int.
Uchar-from-uint
Convert from type unsigned int to type unsigned char.
Uchar-from-sint
Convert from type signed int to type unsigned char.
Slong-from-sint
Convert from type signed int to type signed long.
Slong-from-schar
Convert from type signed char to type signed long.
Sint-from-uint
Convert from type unsigned int to type signed int.
Sint-from-schar
Convert from type signed char to type signed int.