Documentation

Complexitylib.Models.RandomAccessMachine.Simulation.RegisterStore.Defs

Sparse RAM register stores on Turing tapes: definitions #

This file defines the auditable representation boundary for simulating a RAM with a Turing machine. A finite register file is represented by a list of address/value pairs. Zero-valued registers are omitted. Words use a self-delimiting binary code consisting of a unary width, a zero separator, and exactly that many binary payload bits. Thus a word of bit-width w occupies 2 * w + 1 tape cells.

Snapshot adds the program counter to a finite store. Its bit encoding begins with the program counter and entry count, followed by the address and value of each entry. The corresponding decoders are total Option-valued functions.

Proofs that the store operations implement functional register reads/writes and that every codec round-trips live in the internal module.

Maximum bit-width of an instruction's hardwired register indices, immediate, and jump target. These literals are fixed with the program and are therefore not charged as runtime indirect addresses by Instr.logCost.

Equations
Instances For
    @[reducible, inline]

    One sparse register entry: an address paired with its nonzero value.

    Equations
    Instances For
      @[reducible, inline]

      A finite sparse register file.

      Equations
      Instances For

        Read an address from a sparse store, defaulting to zero.

        Equations
        Instances For

          Write one address in a sparse store. Writing zero removes the entry; writing a nonzero value replaces the first matching entry or appends a fresh entry when the address is absent.

          Equations
          Instances For

            No address occurs twice in a sparse store.

            Equations
            Instances For

              Every materialized entry carries a nonzero value.

              Equations
              Instances For

                A canonical sparse store has unique addresses and omits zero values.

                Equations
                Instances For

                  Decode a sparse store into the RAM model's total register file.

                  Equations
                  Instances For

                    A finite sparse store represents a total RAM register file exactly.

                    Equations
                    Instances For

                      Maximum address/value bit-width materialized in a sparse store.

                      Equations
                      Instances For
                        noncomputable def Complexity.RAM.RegisterStore.ofRegs (regs : ) (hfinite : (Function.support regs).Finite) :

                        Materialize the finite support of a total register file as a sparse store.

                        Equations
                        Instances For

                          Nonzero public-input registers, selected from the known finite input range.

                          Equations
                          Instances For

                            Canonical sparse materialization of the RAM public-input register file.

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

                              Self-delimiting binary words #

                              Encode a natural as unary bit-width, a zero separator, and fixed-width little-endian payload bits. The payload convention matches the library's canonical binary-arithmetic work tapes.

                              Equations
                              Instances For

                                Parse one self-delimiting binary word and return the unconsumed suffix.

                                Equations
                                Instances For

                                  Serialize an address/value entry as two self-delimiting words.

                                  Equations
                                  Instances For

                                    Parse one address/value entry and return the unconsumed suffix.

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

                                      Number of tape cells occupied by the concatenated self-delimiting codes of the live sparse-store entries. Unlike Snapshot.sizeBound, this charges the actual width of every entry instead of multiplying the entry count by one run-wide maximum width.

                                      Equations
                                      Instances For

                                        Parse exactly count sparse entries and return the unconsumed suffix.

                                        Equations
                                        Instances For

                                          A finite RAM snapshot: program counter plus sparse register store.

                                          • pc :

                                            Program counter of the represented RAM configuration.

                                          • store : Store

                                            Materialized nonzero register entries.

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

                                              Decode a finite snapshot to a RAM configuration.

                                              Equations
                                              Instances For

                                                Serialize a snapshot as program counter, entry count, and entries.

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

                                                  Parse one snapshot prefix and return the unconsumed suffix.

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

                                                    Decode an exact snapshot code, rejecting trailing bits.

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

                                                      A canonical snapshot represents a RAM configuration exactly.

                                                      Equations
                                                      Instances For

                                                        One width envelope for the program counter, entry count, addresses, and values of a finite snapshot.

                                                        Equations
                                                        Instances For

                                                          Concrete tape-cell envelope for the canonical snapshot encoding.

                                                          Equations
                                                          Instances For

                                                            One-step width envelope: old width plus one, or a width explicitly exposed by the instruction literal or its logarithmic runtime charge.

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

                                                              Materialize a RAM configuration whose register support is finite.

                                                              Equations
                                                              Instances For

                                                                Canonical finite snapshot of the RAM public-input configuration.

                                                                Equations
                                                                Instances For

                                                                  The instruction selected by a finite snapshot.

                                                                  Equations
                                                                  Instances For

                                                                    Execute one RAM instruction directly on the sparse finite store.

                                                                    Equations
                                                                    Instances For

                                                                      Execute the selected RAM instruction on a sparse snapshot.

                                                                      Equations
                                                                      Instances For

                                                                        A sparse snapshot is halted exactly when its selected instruction is halt.

                                                                        Equations
                                                                        Instances For

                                                                          Fuel-bounded sparse execution, stopping at the first halted snapshot.

                                                                          Equations
                                                                          Instances For