Cslib.URM.Instr
inductiveimported Lean
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
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in @[grind] inductive Cslib.URM.Instr : Type
- Defined in
- CSLib, `Cslib.URM.Instr`
- Lean proof
- By Jesse Alama, from github.com/leanprover/cslib at
3951377e5a3f(Copyright (c) 2026 Jesse Alama. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.33.0.Cslib.URM.Instr← Cslib.URM.Instr (Cslib/Computability/URM/Defs.lean:44): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Used by 59
- Cslib.URM.Program.shiftRegistersShift all register references in a program by
offset. Used to isolate register usage when composing programs. - Cslib.URM.State.instDecidableIsHaltedCslib.URM.State.instDecidableIsHalted
- urm_halts_toStandardFormFor any URM program p and input list inputs, p halts on inputs if and only if its standard form p.toStandardForm halts on inputs.
- Cslib.URM.State.isHalted_iffCslib.URM.State.isHalted_iff
- Cslib.URM.Program.toStandardForm_lengthtoStandardForm preserves program length.
- Cslib.URM.Instr.JumpsBoundedByAn instruction's jump target is bounded by a given length. Non-jump instructions trivially satisfy this.
- Cslib.URM.Program.instDecidableIsStandardFormCslib.URM.Program.instDecidableIsStandardForm
- Cslib.URM.Instr.IsJumpAn instruction is a jump instruction.
- Cslib.URM.Instr.capJump_JCslib.URM.Instr.capJump_J
- Cslib.URM.Instr.maxRegisterThe maximum register index referenced by an instruction.
- Cslib.URM.Instr.JumpsBoundedBy.monoJumpsBoundedBy is monotonic: if bounded for len1, then bounded for any len2 ≥ len1.
- Cslib.URM.Instr.shiftRegistersShift all register references in an instruction by
offset. Used to isolate register usage when composing programs. - Cslib.URM.Instr.capJumpCap a jump target to be at most
len. Non-jump instructions are unchanged. - Cslib.URM.Instr.readsFromThe registers read by an instruction.
- Cslib.URM.Instr.capJump_SCslib.URM.Instr.capJump_S
- Cslib.URM.Instr.JumpsBoundedBy.shiftJumpsshiftJumps preserves bounded jumps with adjusted bound.
- Cslib.URM.Instr.writesToThe register written to by an instruction, if any.
- Cslib.URM.State.isHaltedA state is halted if the program counter is at or beyond the program length.
- Cslib.URM.Program.shiftJumpsShift all jump targets in a program by
offset. Used when concatenating programs: the second program's jumps must be adjusted by the… - Cslib.URM.Instr.jumpsBoundedBy_of_nonJumpNon-jumping instructions have bounded jumps for any length.
- Cslib.URM.straight_line_halts_from_regsStraight-line programs halt from any starting registers, not just State.init. Useful for chaining: after running one program, we can run…
- Cslib.URM.Instr.capJump_TCslib.URM.Instr.capJump_T
- Cslib.URM.Step.of_nonJumpA non-jumping instruction produces a step that increments PC by 1.
- Cslib.URM.Program.IsStandardFormA program is in standard form if all jump targets are bounded by the program length. Jumps can target any instruction (0..length-1) or the…
- Cslib.URM.Program.mem_maxRegisterAny instruction in a program has maxRegister at most the program's maxRegister.
- Cslib.URM.Instr.S_nonJumpS instruction is not a jump.
- Cslib.URM.Program.IsStraightLine.consCons of non-jumping instruction preserves straight-line.
- Cslib.URM.Step.toStandardFormForward step correspondence: if p steps from s to s', then either: (1) p.toStandardForm steps from s to s' (same step), or (2) s' is…
- Cslib.URM.Instr.instDecidableIsJumpCslib.URM.Instr.instDecidableIsJump
- Cslib.URM.Program.IsStraightLine.singletonSingleton non-jumping instruction is straight-line.
- Cslib.URM.isHalted_iff_normalA state is halted iff it is normal (has no successor) in the reduction system.
- Cslib.URM.Instr.shiftJumps_of_nonJumpshiftJumps is identity for non-jumping instructions.
- Cslib.URM.Step.from_toStandardFormReverse step correspondence: if p.toStandardForm steps from s to s', then either: (1) p steps from s to s' (same step), or (2) s' is…
- Cslib.URM.Step.preserves_registerA single step preserves registers not written to by the current instruction. This is a fundamental property of URM execution: each…
- Cslib.URM.Program.IsStraightLine.appendAppend preserves straight-line property.
- Cslib.URM.Instr.Z_nonJumpZ instruction is not a jump.
- Cslib.URM.Instr.shiftJumpsShift all jump targets in an instruction by
offset. Used when concatenating programs to maintain correct jump destinations. - Cslib.URM.Program.toStandardForm_isStandardFormtoStandardForm produces a standard form program.
- Cslib.URM.Program.maxRegisterThe maximum register index referenced by any instruction in the program.
- urm_halts_toStandardForm_of_haltsIf a URM program p halts on inputs, then its standard form p.toStandardForm halts on inputs.
- Cslib.URM.straight_line_IsStandardFormStraight-line programs are in standard form.
- Cslib.URM.Instr.instDecidableJumpsBoundedByCslib.URM.Instr.instDecidableJumpsBoundedBy
- Cslib.URM.straight_line_state_at_pcIn a straight-line program, we can characterize the state at any intermediate pc. This gives us the state after executing instructions…
- Cslib.URM.Program.toStandardFormConvert a program to standard form by capping all jump targets at the program length.
- Cslib.URM.instDecidableIsStraightLineCslib.URM.instDecidableIsStraightLine
- Cslib.URM.Program.toStandardForm_idempotenttoStandardForm is idempotent: applying it twice equals applying it once.
- Cslib.URM.Instr.capJump_idempotentcapJump is idempotent: capping twice is the same as capping once.
- Cslib.URM.straightLinefinalState_specSpecification: the state from straightLinefinalState satisfies Steps, isHalted, and has pc = p.length.
- Cslib.URM.Instr.JumpsBoundedBy.capJumpcapJump always produces an instruction with bounded jump.
- Cslib.URM.StepSingle-step execution relation for URMs. Each constructor corresponds to one of the four instruction types: -
zero: ExecuteZ n(set… - Cslib.URM.Steps.preserves_registerMulti-step execution preserves registers not written by any executed instruction.
- Cslib.URM.Instr.capJump_ZCslib.URM.Instr.capJump_Z
- Cslib.URM.Instr.T_nonJumpT instruction is not a jump.
- Cslib.URM.Program.IsStraightLineA program is "straight-line" if it contains no jump instructions.
- Cslib.URM.Instr.J_IsJumpJ instruction is a jump.
- Cslib.URM.straight_line_haltsA straight-line program halts on any input.
- Cslib.URM.ProgramA URM program is a list of instructions.
- Cslib.URM.straightLinefinalStateThe halting state for a straight-line program starting from registers r. Wraps Classical.choose to hide it from the API.
- Cslib.URM.Program.getElem?_toStandardFormAccessing an instruction in toStandardForm gives the capJump'd instruction.
- Cslib.URM.Program.shiftRegistersShift all register references in a program by
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in /-- 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 -/ @[grind] inductive Cslib.URM.Instr : Type where | Z : ℕ → Instr | S : ℕ → Instr | T : ℕ → ℕ → Instr | J : ℕ → ℕ → ℕ → Instr deriving DecidableEq, Repr