Cslib.URM.Step
inductiveimported Lean
Single-step execution relation for URMs. Each constructor corresponds to one of the four instruction types: - zero: Execute Z n (set register n to 0) - succ: Execute S n (increment register n) - transfer: Execute T m n (copy register m to register n) - jump_eq: Execute J m n q when registers m and n are equal (jump to q) - jump_ne: Execute J m n q when registers m and n differ (proceed to next)
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in variable (p : Program) in @[grind] inductive Cslib.URM.Step : State → State → Prop
- Defined in
- CSLib, `Cslib.URM.Step`
- 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.Step← Cslib.URM.Step (Cslib/Computability/URM/Execution.lean:59): verbatim
- Verified
- 08 Oct 2026
- Axioms
- none listed
- Built on 8
- Cslib.URM.State.instDecidableIsHaltedCslib.URM.State.instDecidableIsHalted
- Cslib.URM.InstrURM instructions. -
Z n: Set register n to zero -S n: Increment register n by one -T m n: Transfer (copy) the contents of register… - Cslib.URM.Regs.writeWrite value v to register n.
- Cslib.URM.State.instInhabitedCslib.URM.State.instInhabited
- Cslib.URM.Regs.readRead the contents of register n.
- Cslib.URM.State.instReprCslib.URM.State.instRepr
- Cslib.URM.StateMachine state: program counter (0-indexed) and register contents.
- Cslib.URM.ProgramA URM program is a list of instructions.
- Used by 14
- Cslib.URM.Step.deterministicThe step relation is deterministic: each state has at most one successor.
- 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.Step.no_step_of_haltedA halted state has no successor in the step relation.
- Cslib.URM.StepsMulti-step execution: the reflexive-transitive closure of
Step. - 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.Step.of_nonJumpA non-jumping instruction produces a step that increments PC by 1.
- 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.isHalted_iff_normalA state is halted iff it is normal (has no successor) in the reduction system.
- 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…
- 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_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.Steps.preserves_registerMulti-step execution preserves registers not written by any executed instruction.
- Cslib.URM.halts_iff_normalizableHalting is equivalent to normalizability in the reduction system.
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in variable (p : Program) in /-- Single-step execution relation for URMs. Each constructor corresponds to one of the four instruction types: - `zero`: Execute `Z n` (set register n to 0) - `succ`: Execute `S n` (increment register n) - `transfer`: Execute `T m n` (copy register m to register n) - `jump_eq`: Execute `J m n q` when registers m and n are equal (jump to q) - `jump_ne`: Execute `J m n q` when registers m and n differ (proceed to next) -/ @[grind] inductive Cslib.URM.Step : State → State → Prop where | zero {s : State} {n : ℕ} (h : p[s.pc]? = some (Instr.Z n)) : Step s ⟨s.pc + 1, s.regs.write n 0⟩ | succ {s : State} {n : ℕ} (h : p[s.pc]? = some (Instr.S n)) : Step s ⟨s.pc + 1, s.regs.write n (s.regs.read n + 1)⟩ | transfer {s : State} {m n : ℕ} (h : p[s.pc]? = some (Instr.T m n)) : Step s ⟨s.pc + 1, s.regs.write n (s.regs.read m)⟩ | jump_eq {s : State} {m n q : ℕ} (h : p[s.pc]? = some (Instr.J m n q)) (heq : s.regs.read m = s.regs.read n) : Step s ⟨q, s.regs⟩ | jump_ne {s : State} {m n q : ℕ} (h : p[s.pc]? = some (Instr.J m n q)) (hne : s.regs.read m ≠ s.regs.read n) : Step s ⟨s.pc + 1, s.regs⟩