Finite numeric switches for structured RAM programs #
select compiles a finite family of commands into a decrementing decision
tree. A valid numeric code in test selects the corresponding branch. The
register one must contain one and be distinct from test.
Store presented to the selected branch after the tested code has been decremented to zero.
Equations
- Complexity.RAM.Structured.Switch.cleared store test = Function.update store test 0
Instances For
A finite numeric switch. Invalid codes fall through to skip; correctness
theorems use the explicit hypothesis code < count.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.RAM.Structured.Switch.select 0 x✝¹ x✝ x_6 = Complexity.RAM.Structured.Cmd.skip
Instances For
Exact compiled/source transition count for selecting code.
Equations
- Complexity.RAM.Structured.Switch.stepCount code branchSteps = 3 * code + branchSteps + 1
Instances For
Envelope-based logarithmic-cost bound for selecting code.
Each skipped case pays at most seven envelope widths: three for the nonzero conditional and four for the decrement. The selected zero case pays one.