Straight-Line Programs #
This file defines straight-line programs (those without jumps) and proves they always halt exactly at their length.
Main definitions #
Program.IsStraightLine: a program contains no jump instructions
Main results #
straight_line_halts: straight-line programs always haltstraightLine_finalState: final state after running a straight-line program
Straight-Line Programs #
A program is "straight-line" if it contains no jump instructions.
Equations
- p.IsStraightLine = ∀ i ∈ p, ¬i.IsJump
Instances For
Equations
- Cslib.URM.instDecidableIsStraightLine p = inferInstanceAs (Decidable (∀ i ∈ p, ¬i.IsJump))
Append preserves straight-line property.
Cons of non-jumping instruction preserves straight-line.
Singleton non-jumping instruction is straight-line.
Straight-Line Program Execution #
Straight-line programs halt from any starting registers, not just State.init. Useful for chaining: after running one program, we can run the next straight-line segment from whatever registers we're in.
A straight-line program halts on any input.
The halting state for a straight-line program starting from registers r. Wraps Classical.choose to hide it from the API.
Equations
Instances For
Specification: the state from straightLine_finalState satisfies Steps, isHalted, and has pc = p.length.
The final registers after running a straight-line program from given starting registers.
Equations
Instances For
For a straight-line program, s.regs equals straightLine_finalRegs if halted from r.
In a straight-line program, we can characterize the state at any intermediate pc. This gives us the state after executing instructions 0..pc-1.