Cslib.URM.straightLinefinalState_spec
theoremverifiedformalizationimported Lean
Specification: the state from straightLinefinalState satisfies Steps, isHalted, and has pc = p.length.
Statement
set_option autoImplicit true in set_option relaxedAutoImplicit true in theorem Cslib.URM.straightLinefinalState_spec {p : Program} (hsl : p.IsStraightLine) (r : Regs) : let s := straightLinefinalState hsl r Steps p ⟨0, r⟩ s ∧ s.isHalted p ∧ s.pc = p.length
- Formalizes
- CSLib, `Cslib.URM.straightLinefinalState_spec`
- 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.straightLinefinalState_spec← Cslib.URM.straightLinefinalState_spec (Cslib/Computability/URM/StraightLine.lean:112): verbatim
- Verified
- 08 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 28
- Cslib.URM.ProgramA URM program is a list of instructions.
- Cslib.URM.Program.IsStraightLineA program is "straight-line" if it contains no jump instructions.
- Cslib.URM.RegsRegister contents: maps register indices to natural number contents. Uses the functional representation
ℕ → ℕfor efficiency with… - Cslib.URM.StateMachine state: program counter (0-indexed) and register contents.
- 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.StepsMulti-step execution: the reflexive-transitive closure of
Step. - Cslib.URM.State.isHaltedA state is halted if the program counter is at or beyond the program length.
- 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.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.Regs.write_read_selfCslib.URM.Regs.write_read_self
- Cslib.URM.Regs.write_read_of_neCslib.URM.Regs.write_read_of_ne
- Cslib.URM.State.isHalted_iffCslib.URM.State.isHalted_iff
- Cslib.URM.Instr.Z_nonJumpZ instruction is not a jump.
- Cslib.URM.Instr.S_nonJumpS instruction is not a jump.
- Cslib.URM.Instr.T_nonJumpT instruction is not a jump.
- Cslib.URM.Instr.J_IsJumpJ instruction is a jump.
- Cslib.URM.Instr.capJump_ZCslib.URM.Instr.capJump_Z
- Cslib.URM.Instr.capJump_SCslib.URM.Instr.capJump_S
- Cslib.URM.Instr.capJump_TCslib.URM.Instr.capJump_T
- Cslib.URM.Instr.capJump_JCslib.URM.Instr.capJump_J
- Cslib.URM.Instr.capJump_idempotentcapJump is idempotent: capping twice is the same as capping once.
- Cslib.URM.State.instDecidableIsHaltedCslib.URM.State.instDecidableIsHalted
- Cslib.URM.State.instInhabitedCslib.URM.State.instInhabited
- Cslib.URM.State.instReprCslib.URM.State.instRepr
- Cslib.URM.Instr.instDecidableIsJumpCslib.URM.Instr.instDecidableIsJump
- Cslib.URM.Instr.instDecidableJumpsBoundedByCslib.URM.Instr.instDecidableJumpsBoundedBy
- Cslib.URM.instSetoidProgramSetoid instance for programs, enabling the ≈ notation.
- Cslib.URM.instDecidableIsStraightLineCslib.URM.instDecidableIsStraightLine
Lean source view module on GitHub
set_option autoImplicit true in set_option relaxedAutoImplicit true in /-- Specification: the state from straightLinefinalState satisfies Steps, isHalted, and has pc = p.length. -/ theorem Cslib.URM.straightLinefinalState_spec {p : Program} (hsl : p.IsStraightLine) (r : Regs) : let s := straightLinefinalState hsl r Steps p ⟨0, r⟩ s ∧ s.isHalted p ∧ s.pc = p.length := Classical.choose_spec (straight_line_halts_from_regs hsl r)