Cslib.URM.Step.from_toStandardForm
theoremverifiedformalizationimported Lean
Reverse 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 halted in p.toStandardForm, and p steps to a state that is also halted with the same registers (this only happens for jumps with unbounded targets).
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in open Cslib.URM.Program Cslib.URM.State Cslib.URM.Instr in theorem Cslib.URM.Step.from_toStandardForm {p : Program} {s s' : State} (hstep : Step p.toStandardForm s s') : Step p s s' ∨ (s'.isHalted p.toStandardForm ∧ ∃ s₂, Step p s s₂ ∧ s₂.isHalted p ∧ s'.regs = s₂.regs)
- Formalizes
- CSLib, `Cslib.URM.Step.from_toStandardForm`
- 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.from_toStandardForm← Cslib.URM.Step.from_toStandardForm (Cslib/Computability/URM/StandardForm.lean:156): adapted
What was changed in
Cslib.URM.Step.from_toStandardForm--- Cslib/Computability/URM/StandardForm.lean:156 (Cslib.URM.Step.from_toStandardForm) +++ as compiled here @@ -1,7 +1,5 @@ -open Program State Instr in -/-- Reverse 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 halted in p.toStandardForm, and p steps to a state that is also halted - with the same registers (this only happens for jumps with unbounded targets). -/ -theorem Step.from_toStandardForm {p : Program} {s s' : State} (hstep : Step p.toStandardForm s s') : +set_option autoImplicit true in +set_option relaxedAutoImplicit true in +open Cslib.URM.Program Cslib.URM.State Cslib.URM.Instr in +theorem Cslib.URM.Step.from_toStandardForm {p : Program} {s s' : State} (hstep : Step p.toStandardForm s s') : Step p s s' ∨ - Verified
- 08 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 24
- 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.State.isHalted_iffCslib.URM.State.isHalted_iff
- Cslib.URM.Program.toStandardForm_lengthtoStandardForm preserves program length.
- Cslib.URM.Program.instDecidableIsStandardFormCslib.URM.Program.instDecidableIsStandardForm
- Cslib.URM.Instr.capJumpCap a jump target to be at most
len. Non-jump instructions are unchanged. - Cslib.URM.Regs.writeWrite value v to register n.
- Cslib.URM.State.isHaltedA state is halted if the program counter is at or beyond the program length.
- Cslib.URM.RegsRegister contents: maps register indices to natural number contents. Uses the functional representation
ℕ → ℕfor efficiency with… - Cslib.URM.Regs.write_read_selfCslib.URM.Regs.write_read_self
- Cslib.URM.Instr.instDecidableIsJumpCslib.URM.Instr.instDecidableIsJump
- Cslib.URM.State.instInhabitedCslib.URM.State.instInhabited
- Cslib.URM.instSetoidProgramSetoid instance for programs, enabling the ≈ notation.
- Cslib.URM.Regs.write_read_of_neCslib.URM.Regs.write_read_of_ne
- Cslib.URM.Regs.readRead the contents of register n.
- Cslib.URM.Instr.instDecidableJumpsBoundedByCslib.URM.Instr.instDecidableJumpsBoundedBy
- 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.State.instReprCslib.URM.State.instRepr
- Cslib.URM.Program.toStandardForm_idempotenttoStandardForm is idempotent: applying it twice equals applying it once.
- Cslib.URM.StepSingle-step execution relation for URMs. Each constructor corresponds to one of the four instruction types: -
zero: ExecuteZ n(set… - Cslib.URM.StateMachine state: program counter (0-indexed) and register contents.
- Cslib.URM.ProgramA URM program is a list of instructions.
- Cslib.URM.Program.getElem?_toStandardFormAccessing an instruction in toStandardForm gives the capJump'd instruction.
- Used by 1
- 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.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
set_option autoImplicit true inset_option relaxedAutoImplicit true inopen Cslib.URM.Program Cslib.URM.State Cslib.URM.Instr in/-- Reverse 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 halted in p.toStandardForm, and p steps to a state that is also halted with the same registers (this only happens for jumps with unbounded targets). -/theorem Cslib.URM.Step.from_toStandardForm {p : Program} {s s' : State} (hstep : Step p.toStandardForm s s') : Step p s s' ∨ (s'.isHalted p.toStandardForm ∧ ∃ s₂, Step p s s₂ ∧ s₂.isHalted p ∧ s'.regs = s₂.regs) := by cases hstep with | jump_eq hinstr _ => simp only [Program.getElem?_toStandardForm, Option.map_eq_some_iff] at hinstr obtain ⟨instr, _⟩ := hinstr cases instr with | J => grind [=> jump_eq] | _ => grind | _ => grind [getElem?_toStandardForm, Option.map_eq_some_iff]