Documentation

Cslib.Computability.URM.Defs

URM Core Definitions #

This file contains the core definitions for Unlimited Register Machines (URMs): instructions, register state, programs, and machine configurations.

Main definitions #

References #

Instructions #

URM instructions.

  • Z n: Set register n to zero
  • S n: Increment register n by one
  • T m n: Transfer (copy) the contents of register m to register n
  • J m n q: If registers m and n have equal contents, jump to instruction q; otherwise proceed to the next instruction
Instances For
    def Cslib.URM.instDecidableEqInstr.decEq (x✝ x✝¹ : Instr) :
    Decidable (x✝ = x✝¹)
    Instances For
      @[instance_reducible]

      The registers read by an instruction.

      Instances For

        The register written to by an instruction, if any.

        Instances For

          The maximum register index referenced by an instruction.

          Instances For

            Shift all jump targets in an instruction by offset. Used when concatenating programs to maintain correct jump destinations.

            Instances For

              Shift all register references in an instruction by offset. Used to isolate register usage when composing programs.

              Instances For

                Register Contents #

                @[reducible, inline]

                Register contents: maps register indices to natural number contents.

                Uses the functional representation ℕ → ℕ for efficiency with rewrites, following the advice from the grind tactic documentation.

                Instances For

                  The zero registers where all registers contain 0.

                  Instances For
                    def Cslib.URM.Regs.read (σ : Regs) (n : ℕ) :

                    Read the contents of register n.

                    Instances For
                      def Cslib.URM.Regs.write (σ : Regs) (n v : ℕ) :

                      Write value v to register n.

                      Instances For

                        Initialize registers with input values in registers 0, 1, ..., k-1. Registers beyond the inputs are initialized to 0.

                        Instances For

                          Extract output from register 0.

                          Instances For

                            Programs #

                            @[reducible, inline]

                            A URM program is a list of instructions.

                            Instances For

                              The maximum register index referenced by any instruction in the program.

                              Instances For

                                Shift all jump targets in a program by offset. Used when concatenating programs: the second program's jumps must be adjusted by the length of the first program.

                                Instances For

                                  Shift all register references in a program by offset. Used to isolate register usage when composing programs.

                                  Instances For

                                    Machine State #

                                    Machine state: program counter (0-indexed) and register contents.

                                    • pc : ℕ

                                      Program counter (0-indexed).

                                    • regs : Regs

                                      Register contents.

                                    Instances For

                                      Initial state for a program with given inputs. The program counter starts at 0, and inputs are loaded into registers 0, 1, ....

                                      Instances For

                                        A state is halted if the program counter is at or beyond the program length.

                                        Instances For
                                          @[instance_reducible]
                                          @[instance_reducible]
                                          @[instance_reducible]