Documentation

Complexitylib.Models.RandomAccessMachine.Structured.Switch.Defs

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
Instances For
    def Complexity.RAM.Structured.Switch.select (count test one : ) :
    (Fin countCmd)Cmd

    A finite numeric switch. Invalid codes fall through to skip; correctness theorems use the explicit hypothesis code < count.

    Equations
    Instances For

      Exact compiled/source transition count for selecting code.

      Equations
      Instances For
        def Complexity.RAM.Structured.Switch.costBound (code branchCost width : ) :

        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.

        Equations
        Instances For