Documentation

Bignum.Common.Memory

Memory Model #

This file defines the memory model.

Main Definitions #

References #

This corresponds to the memory component in HOL Light's model. Source: s2n-bignum/common/components.ml (memory-related definitions)

@[reducible, inline]

Memory addresses are 64-bit values.

Equations
Instances For

    Memory is modeled as a partial function from addresses to bytes. We use Option to represent potentially uninitialized memory.

    Equations
    Instances For

      Empty memory (all addresses uninitialized).

      Equations
      Instances For

        Read a single byte from memory at the given address.

        Equations
        Instances For
          def Bignum.Memory.write_byte (mem : Memory) (addr : Address) (byte : UInt8) :

          Write a single byte to memory at the given address.

          Equations
          Instances For

            Read n bytes from memory starting at addr. Returns None if any byte is uninitialized.

            Equations
            Instances For
              @[irreducible]
              def Bignum.Memory.read_bytes.aux (mem : Memory) (addr : Address) (n i : ) (acc : List UInt8) :
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def Bignum.Memory.write_bytes (mem : Memory) (addr : Address) (bytes : List UInt8) :

                Write bytes to memory starting at addr.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Read a 64-bit word from memory in little-endian format. The address should be the lowest byte address.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    Write a 64-bit word to memory in little-endian format.

                    Equations
                    Instances For

                      Read a bignum (multiple 64-bit words) from memory. The bignum is stored as an array of n words at address addr.

                      Corresponds to HOL Light's bignum_from_memory. Source: s2n-bignum proofs use this extensively (e.g., bignum_add.ml:91-92)

                      Equations
                      Instances For
                        @[irreducible]
                        def Bignum.Memory.read_bignum.aux (mem : Memory) (addr : Address) (n i acc : ) :
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          def Bignum.Memory.write_bignum (mem : Memory) (addr : Address) (n val : ) :

                          Write a bignum to memory as n 64-bit words.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def Bignum.nonoverlapping (addr1 : Address) (size1 : ) (addr2 : Address) (size2 : ) :

                            Check if two memory regions do not overlap. This corresponds to HOL Light's nonoverlapping, used extensively in preconditions.

                            Source: s2n-bignum/common/overlap.ml

                            Equations
                            Instances For
                              def Bignum.bytes_loaded (mem : Memory) (addr : Address) (bytes : List UInt8) :

                              Bytes are loaded at a given address (no alignment requirement).

                              Equations
                              Instances For
                                def Bignum.aligned_bytes_loaded (mem : Memory) (addr : Address) (bytes : List UInt8) :

                                Bytes are loaded and aligned at a given address. Corresponds to HOL Light's aligned_bytes_loaded.

                                Equations
                                Instances For
                                  theorem Bignum.aligned_bytes_loaded_implies_bytes_loaded (mem : Memory) (addr : Address) (bytes : List UInt8) :
                                  aligned_bytes_loaded mem addr bytesbytes_loaded mem addr bytes

                                  Aligned bytes loaded implies bytes loaded.