Documentation

Complexity.Computability.Machines.Turing.MultiTape.Halting.Partialize

Machines that diverge on a verdict #

A machine computing a total function can compute a partial one: let the first symbol it emits be a verdict. tm.partialize runs tm, but reads the first emitted symbol as a verdict instead of emitting it. After the verdict true it emits nothing, and once tm halts it loops forever in a state of its own; after the verdict false it emits the rest of the output of tm and halts with tm. So if tm halts with the output encPartial r on an input, encoding the divergence r = none as [true] and an output r = some o as false :: o, then tm.partialize diverges on that input when r = none and halts with output o when r = some o (Turing.MultiTapeTM.Computes.partialize).

The proof is a step-by-step correspondence: the configurations of tm.partialize are images of the configurations of tm under a map commuting with the steps (Turing.MultiTapeTM.Partialize.step_liftCfg), so its runs are the images of the runs of tm (Turing.MultiTapeTM.runFrom_partialize).

Main definitions #

Main results #

References #

The verdict read from an output: its first symbol, if any.

Instances For

    What follows the verdict false in an output; nothing before a verdict or after the verdict true.

    Instances For

      The state of tm.partialize for a state of tm and a verdict: a running state is kept with the verdict; once tm halts, the verdict true loops in the state (none, some true) and every other verdict halts.

      Instances For

        Emitting a symbol fixes the verdict if there was none.

        Emitting a symbol extends what follows the verdict only after the verdict false.

        noncomputable def Turing.MultiTapeTM.partialize {k : ℕ} {State : Type u_1} (tm : MultiTapeTM k Bool State) :

        tm.partialize runs tm, reading the first symbol it emits as a verdict. After the verdict true it emits nothing, and once tm halts it loops forever in the state (none, some true). After the verdict false it emits the rest of the output of tm and halts with tm. The second component of a state is the verdict read so far.

        Instances For
          def Turing.MultiTapeTM.Partialize.liftCfg {k : ℕ} {State : Type u_1} {input : List Bool} (c : Cfg k Bool State input) :
          Cfg k Bool (Option State × Option Bool) input

          The configuration of tm.partialize corresponding to a configuration of tm: the state carries the verdict of the output, and the output keeps what follows the verdict false.

          Instances For
            theorem Turing.MultiTapeTM.Partialize.inputSymbol_liftCfg {k : ℕ} {State : Type u_1} {input : List Bool} (c : Cfg k Bool State input) :

            The symbol under the input head is that of tm.

            The symbols under the work-tape heads are those of tm.

            theorem Turing.MultiTapeTM.Partialize.step_liftCfg {k : ℕ} {State : Type u_1} {input : List Bool} (tm : MultiTapeTM k Bool State) (c : Cfg k Bool State input) :

            tm.partialize steps along tm.

            theorem Turing.MultiTapeTM.Partialize.liftCfg_halted_iff {k : ℕ} {State : Type u_1} {input : List Bool} (c : Cfg k Bool State input) :

            tm.partialize has halted when tm has, unless the verdict is true.

            @[simp]
            theorem Turing.MultiTapeTM.Partialize.output_liftCfg {k : ℕ} {State : Type u_1} {input : List Bool} (c : Cfg k Bool State input) :
            theorem Turing.MultiTapeTM.runFrom_partialize {k : ℕ} {State : Type u_1} (tm : MultiTapeTM k Bool State) (input : List Bool) (t : ℕ) :

            The runs of tm.partialize are the images of the runs of tm.

            Partial results as words: the divergence none as [true], the output some o as false :: o.

            Instances For
              theorem Turing.MultiTapeTM.Computes.partialize {k : ℕ} {State : Type u_1} {tm : MultiTapeTM k Bool State} {input : List Bool} {r : Option (List Bool)} (h : tm.Computes input (encPartial r)) (o : List Bool) :
              tm.partialize.Computes input o ↔ o ∈ r

              tm.partialize computes the partial result encoded by the output of tm: if tm halts with output encPartial r, then tm.partialize halts with output o exactly when r = some o, and diverges when r = none.

              theorem Turing.MultiTapeTM.Computes.halts_partialize {k : ℕ} {State : Type u_1} {tm : MultiTapeTM k Bool State} {input : List Bool} {r : Option (List Bool)} (h : tm.Computes input (encPartial r)) :

              If tm halts with output encPartial r, then tm.partialize halts exactly when r is a result.