Documentation

Complexitylib.Models.TuringMachine.Registers

Unary registers #

A register is a work tape holding a natural number in unary: cells 1..v hold 1, everything beyond is blank, and the head is parked at cell 1. All arithmetic in the Cook–Levin reduction emitter (docs/A5-ReductionEmitter.md) is over registers — the CNF encoding is unary, so no binary arithmetic is ever needed.

IsReg strengthens Tape.HasUnaryCounter with the cell-0 sentinel and all-blanks-beyond, making registers literally preserved by parked no-op actions and stable under the combinator phase transitions.

Main definitions #

Main results #

A tape parked for preservation: head off (so idleDir stays put and δ_right_of_start is moot) and no outside cell 0 (so readBackWrite writes back the read symbol verbatim). Machines that do not use a tape keep it parked and literally unchanged.

Equations
Instances For

    A parked tape never reads the start symbol .

    A parked tape is untouched by the no-op action writeAndMove (readBackWrite read) (idleDir read).

    A parked tape's head does not move under idleDir.

    Parked tapes pass through combinator phase boundaries unchanged.

    Parked input tapes pass through combinator phase boundaries unchanged.

    def Complexity.TM.IsReg (v : ) (t : Tape) :

    Register. The tape holds v in unary: at cell 0, 1 at cells 1..v, blank everywhere beyond, head parked at cell 1.

    Equations
    Instances For
      theorem Complexity.TM.IsReg.head_eq {v : } {t : Tape} (h : IsReg v t) :
      t.head = 1

      A register tape's head is parked at cell 1.

      theorem Complexity.TM.IsReg.cell0 {v : } {t : Tape} (h : IsReg v t) :

      A register tape's cell 0 holds the sentinel .

      theorem Complexity.TM.IsReg.cells_one {v : } {t : Tape} (h : IsReg v t) {i : } (hi : i < v) :
      t.cells (i + 1) = Γ.one

      Cells 1..v of a register holding v contain 1.

      theorem Complexity.TM.IsReg.cells_blank {v : } {t : Tape} (h : IsReg v t) {j : } (hj : v + 1 j) :

      Cells beyond position v of a register holding v are blank.

      theorem Complexity.TM.IsReg.cells_ne_start {v : } {t : Tape} (h : IsReg v t) {j : } (hj : 1 j) :

      Register cells off the sentinel are 1 or blank — never .

      theorem Complexity.TM.IsReg.parked {v : } {t : Tape} (h : IsReg v t) :

      A register tape is parked.

      A register is a unary counter (the weaker shape used by the counter subroutines).

      theorem Complexity.TM.IsReg.read_eq {v : } {t : Tape} (h : IsReg v t) :

      The register's read: 1 when nonempty, blank when zero.

      theorem Complexity.TM.reg_zero_init_bumped :
      IsReg 0 { head := 1, cells := (Tape.init []).cells }

      A blank tape with the head bumped to cell 1 is the zero register.

      Canonical register cells holding v in unary.

      Equations
      Instances For

        The canonical register tape holding v.

        Equations
        Instances For
          @[simp]

          The canonical register tape's head sits at cell 1.

          @[simp]

          The canonical register tape's cells are regCells v.

          @[simp]

          Cell 0 of the canonical register cells is the sentinel .

          theorem Complexity.TM.regCells_one {v j : } (h1 : 1 j) (h2 : j v) :

          Cells 1..v of the canonical register cells for v hold 1.

          theorem Complexity.TM.regCells_blank {v j : } (h : v + 1 j) :

          Cells beyond position v of the canonical register cells for v are blank.

          Register cells away from the sentinel are never .

          The canonical register tape regTape v satisfies IsReg v.

          theorem Complexity.TM.IsReg.eq_regT {v : } {t : Tape} (h : IsReg v t) :

          A register's tape is canonical: the IsReg predicate pins every cell and the head, so it is an equation.

          The canonical register tape is parked.

          theorem Complexity.TM.parked_regCells {h v : } (hh : 1 h) :
          Parked { head := h, cells := regCells v }

          Register cells with the head anywhere off form a parked tape.

          Writing the next mark turns regCells d into regCells (d + 1).

          Erasing the final mark turns regCells (d + 1) into regCells d.