Documentation

Complexitylib.Models.TuringMachine.Registers.RegisterOps

Register operations #

The hand-rolled core machines of the reduction emitter's register calculus (docs/A5-ReductionEmitter.md): skipTM (a one-step no-op, the fold identity), incRegTM (append one mark to a register), and clearRegTM (blank a register). All register arithmetic (addition, multiplication, polynomial evaluation) composes from these via the forRegTM loop combinator.

Specs are in the ghost-parametrized EmitPred style: registers are the canonical tapes regTape v, and posts are Function.update equations.

One idle step and halt: the identity for seqTM folds.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    theorem Complexity.TM.skipTM_hoareTime {n : } (inp₀ : Tape) (work₀ : Fin nTape) (ys : List Bool) (hinp₀ : Parked inp₀) (hwork₀ : ∀ (i : Fin n), Parked (work₀ i)) :
    skipTM.HoareTime (EmitPred inp₀ work₀ ys) (EmitPred inp₀ work₀ ys) 1

    skipTM changes nothing (parked tapes).

    State set shared by incRegTM and clearRegTM: scan sweeps right over the marks, back rewinds to the sentinel, park steps onto cell 1, and done halts.

    Instances For
      @[implicit_reducible]
      Equations
      @[implicit_reducible]

      IncPhase is finite (it has exactly four states).

      Equations
      • One or more equations did not get rendered due to their size.
      def Complexity.TM.incRegTM {n : } (q : Fin n) :
      TM n

      Increment register q: scan right over the marks, write a mark on the first blank, rewind to cell 1. From regTape d to regTape (d + 1) in 2d + 4 steps; every other tape untouched.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        theorem Complexity.TM.incRegTM_hoareTime {n : } (q : Fin n) (d : ) (inp₀ : Tape) (work₀ : Fin nTape) (ys : List Bool) (hinp₀ : Parked inp₀) (hwork₀ : ∀ (i : Fin n), i qParked (work₀ i)) (hq : work₀ q = regTape d) :
        (incRegTM q).HoareTime (EmitPred inp₀ work₀ ys) (EmitPred inp₀ (Function.update work₀ q (regTape (d + 1))) ys) (2 * d + 4)

        incRegTM Hoare specification. From regTape d in register q, reach regTape (d + 1) in 2d + 4 steps; the input, output, and every other work tape are untouched.

        Cells of a register holding d mid-clear: positions 1..k blanked, k+1..d still marked.

        Equations
        Instances For

          Before any blanking (k = 0), a mid-clear register is exactly regCells d.

          After blanking all d marks (k = d), a mid-clear register is regCells 0.

          No mid-clear cell at position j ≥ 1 is the sentinel.

          Blanking cell k + 1 of clearRegCells d k advances the sweep to clearRegCells d (k + 1).

          def Complexity.TM.clearRegTM {n : } (q : Fin n) :
          TM n

          Clear register q: sweep right blanking the marks, rewind to cell 1. From regTape d to regTape 0 in 2d + 4 steps; every other tape untouched.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem Complexity.TM.clearRegTM_hoareTime {n : } (q : Fin n) (d : ) (inp₀ : Tape) (work₀ : Fin nTape) (ys : List Bool) (hinp₀ : Parked inp₀) (hwork₀ : ∀ (i : Fin n), i qParked (work₀ i)) (hq : work₀ q = regTape d) :
            (clearRegTM q).HoareTime (EmitPred inp₀ work₀ ys) (EmitPred inp₀ (Function.update work₀ q (regTape 0)) ys) (2 * d + 4)

            clearRegTM Hoare specification. From regTape d in register q, reach regTape 0 in 2d + 4 steps; everything else untouched.