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โœยน)
    Equations
    Instances For
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        The register written to by an instruction, if any.

        Equations
        Instances For

          The maximum register index referenced by an instruction.

          Equations
          Instances For

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

            Equations
            Instances For

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

              Equations
              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.

                Equations
                Instances For

                  The zero registers where all registers contain 0.

                  Equations
                  Instances For

                    Read the contents of register n.

                    Equations
                    Instances For
                      def Cslib.URM.Regs.write (ฯƒ : Regs) (n v : โ„•) :

                      Write value v to register n.

                      Equations
                      Instances For

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

                        Equations
                        Instances For

                          Extract output from register 0.

                          Equations
                          Instances For

                            Programs #

                            @[reducible, inline]

                            A URM program is a list of instructions.

                            Equations
                            Instances For

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

                              Equations
                              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.

                                Equations
                                Instances For

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

                                  Equations
                                  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, ....

                                      Equations
                                      Instances For

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

                                        Equations
                                        Instances For