URM Core Definitions #
This file contains the core definitions for Unlimited Register Machines (URMs): instructions, register state, programs, and machine configurations.
Main definitions #
URM.Instr: The four URM instructions (Z, S, T, J)URM.Regs: Register contents as a functionℕ → ℕURM.Program: A finite sequence of instructionsURM.State: Machine state (program counter + registers)
References #
Instructions #
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 #
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
Initialize registers with input values in registers 0, 1, ..., k-1. Registers beyond the inputs are initialized to 0.
Instances For
Programs #
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.
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.