Langlib

Langlib.Automata.Turing.DSL.TM0BlockRealizability

Block Realizability Framework #

This file defines block-realizability abstractions for composing TM0 machines that operate on contiguous blocks.

Main definitions #

Main results #

Block Realizability Definitions #

def TM0RealizesBlockSep (Γ : Type) [Inhabited Γ] (sep : Γ) (f : List ΓList Γ) :

A TM0 that operates on a block ending at a designated separator.

Given a tape block ++ [sep] ++ suffix, the TM0 transforms it to f block ++ [sep] ++ suffix. The assumptions state that the input block is really the part before the first separator, that the active finite tape has no interior blanks, and that f block is again a valid block for the same separator.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    def TM0RealizesBlockSepAnySuffix (Γ : Type) [Inhabited Γ] (sep : Γ) (f : List ΓList Γ) :

    Strong separator-delimited block realizability: no invariant is required of the suffix after the separator.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def TM0RealizesBlock (Γ : Type) [Inhabited Γ] (f : List ΓList Γ) :

      A TM0 that operates on a contiguous block of non-default cells, preserving everything after the first blank.

      Given a tape block ++ [default] ++ suffix, the TM0 transforms it to f(block) ++ [default] ++ suffix, leaving suffix unchanged. This enables "serialized" composition of elementary operations.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def TM0RealizesBlockAnySuffix (Γ : Type) [Inhabited Γ] (f : List ΓList Γ) :

        Strong blank-delimited block realizability: no invariant is required of the suffix after the delimiter.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          theorem tm0RealizesBlockSep_of_anySuffix {Γ : Type} [Inhabited Γ] {sep : Γ} {f : List ΓList Γ} (hf : TM0RealizesBlockSepAnySuffix Γ sep f) :

          Composition #

          theorem tm0RealizesBlockSepAnySuffix_comp {Γ : Type} [Inhabited Γ] {sep : Γ} {f g : List ΓList Γ} (hf : TM0RealizesBlockSepAnySuffix Γ sep f) (hg : TM0RealizesBlockSepAnySuffix Γ sep g) (hf_nd : ∀ (block : List Γ), (∀ gblock, g default)gf block, g default) (hf_nsep : ∀ (block : List Γ), (∀ gblock, g sep)gf block, g sep) :

          Composition for strong separator-delimited block-realizable functions.

          theorem tm0RealizesBlockAnySuffix_comp {Γ : Type} [Inhabited Γ] {f g : List ΓList Γ} (hf : TM0RealizesBlockAnySuffix Γ f) (hg : TM0RealizesBlockAnySuffix Γ g) (hf_nd : ∀ (block : List Γ), (∀ gblock, g default)gf block, g default) :

          Composition for strong blank-delimited block-realizable functions.

          theorem tm0RealizesBlockSep_comp {Γ : Type} [Inhabited Γ] {sep : Γ} {f g : List ΓList Γ} (hf : TM0RealizesBlockSep Γ sep f) (hg : TM0RealizesBlockSep Γ sep g) (hf_nd : ∀ (block : List Γ), (∀ gblock, g default)gf block, g default) (hf_nsep : ∀ (block : List Γ), (∀ gblock, g sep)gf block, g sep) :

          Composition for separator-delimited block-realizable functions.

          theorem tm0RealizesBlock_comp {Γ : Type} [Inhabited Γ] {f g : List ΓList Γ} (hf : TM0RealizesBlock Γ f) (hg : TM0RealizesBlock Γ g) (hf_nd : ∀ (block : List Γ), (∀ gblock, g default)gf block, g default) :

          Composition of block-realizable functions. Requires f to preserve non-defaultness so that M_g can process f(block) as a valid block.

          Iteration #

          theorem tm0RealizesBlockSep_iterate {Γ : Type} [Inhabited Γ] {sep : Γ} {f : List ΓList Γ} (hf : TM0RealizesBlockSep Γ sep f) (hf_nd : ∀ (block : List Γ), (∀ gblock, g default)gf block, g default) (hf_nsep : ∀ (block : List Γ), (∀ gblock, g sep)gf block, g sep) (n : ) :

          Iterated separator-delimited block operations preserve realizability.

          theorem tm0RealizesBlockSepAnySuffix_iterate {Γ : Type} [Inhabited Γ] {sep : Γ} {f : List ΓList Γ} (hf : TM0RealizesBlockSepAnySuffix Γ sep f) (hf_nd : ∀ (block : List Γ), (∀ gblock, g default)gf block, g default) (hf_nsep : ∀ (block : List Γ), (∀ gblock, g sep)gf block, g sep) (n : ) :

          Iterated strong separator-delimited block operations preserve realizability.

          theorem tm0RealizesBlock_iterate {Γ : Type} [Inhabited Γ] {f : List ΓList Γ} (hf : TM0RealizesBlock Γ f) (hf_nd : ∀ (block : List Γ), (∀ gblock, g default)gf block, g default) (n : ) :

          Iterated block operations preserve block-realizability.

          theorem iterate_preserves_nd {Γ₀ : Type} [Inhabited Γ₀] {f : List Γ₀List Γ₀} (hf : ∀ (block : List Γ₀), (∀ gblock, g default)gf block, g default) (n : ) (block : List Γ₀) (hblock : gblock, g default) (g : Γ₀) :
          g f^[n] blockg default

          Iteration of a non-defaultness-preserving function preserves non-defaultness.

          theorem iterate_preserves_nsep {Γ₀ : Type} [Inhabited Γ₀] {f : List Γ₀List Γ₀} {sep : Γ₀} (hf : ∀ (block : List Γ₀), (∀ gblock, g sep)gf block, g sep) (n : ) (block : List Γ₀) (hblock : gblock, g sep) (g : Γ₀) :
          g f^[n] blockg sep

          Iteration preserves the "not equal to separator" invariant.

          Utility Lemmas #

          Generic: appending default to a ListBlank is identity.

          Generic: Tape.mk₁ with trailing default is identity.

          TM0Seq.evalCfg with trailing default input is the same.

          theorem reverse_ne_default {Γ : Type} [Inhabited Γ] (block : List Γ) (hblock : gblock, g default) (g : Γ) :
          g block.reverseg default

          Reverse preserves non-defaultness.

          Reverse is block-realizable #

          List reverse is block-realizable before any separator. The underlying machine RevBlock.MSep uses sep for right-boundary detection and default for left-boundary detection.

          List reverse is block-realizable. A TM0 can reverse a contiguous block of non-default cells while preserving the suffix.

          Cons (prepend) is block-realizable #

          noncomputable def consSimpleMachine {Γ : Type} [Inhabited Γ] [DecidableEq Γ] (c : Γ) :

          The simple cons machine: move left, write c, halt. Prepends c to the tape by writing at position −1.

          Equations
          Instances For

            Writing c after moving left from Tape.mk₁ l gives Tape.mk₁ (c :: l).

            theorem tm0_cons_blockSep_anySuffix {Γ : Type} [Inhabited Γ] [DecidableEq Γ] [Fintype Γ] {sep : Γ} (c : Γ) :
            TM0RealizesBlockSepAnySuffix Γ sep fun (x : List Γ) => c :: x

            Prepending a fixed element is block-realizable before any separator.

            The cons machine (consSimpleMachine) moves left, writes c, and halts. It never inspects any cell to detect a block boundary, so it works with any separator.

            theorem tm0_cons_blockSep {Γ : Type} [Inhabited Γ] [DecidableEq Γ] [Fintype Γ] {sep : Γ} (c : Γ) :
            TM0RealizesBlockSep Γ sep fun (x : List Γ) => c :: x
            theorem tm0_cons_block_anySuffix {Γ : Type} [Inhabited Γ] [DecidableEq Γ] [Fintype Γ] (c : Γ) (_hc : c default) :
            TM0RealizesBlockAnySuffix Γ fun (x : List Γ) => c :: x

            Prepending a fixed non-default element is block-realizable.

            theorem tm0_cons_block {Γ : Type} [Inhabited Γ] [DecidableEq Γ] [Fintype Γ] (c : Γ) (_hc : c default) :
            TM0RealizesBlock Γ fun (x : List Γ) => c :: x

            Identity is block-realizable #

            The identity function is realizable before any separator.

            A trivial TM0 machine that halts immediately on any input tape.

            theorem tm0_id_blockSep {Γ : Type} [Inhabited Γ] {sep : Γ} :

            The identity function is block-realizable.

            Prepend list is block-realizable #

            theorem prependList_ne_default' {Γ : Type} [Inhabited Γ] (pref block : List Γ) (hpref : gpref, g default) (hblock : gblock, g default) (g : Γ) :
            g pref ++ blockg default

            Appending a non-default prefix preserves non-defaultness.

            theorem reverse_ne_sep {Γ : Type} {sep : Γ} (block : List Γ) (hblock : gblock, g sep) (g : Γ) :
            g block.reverseg sep

            Reverse preserves the "not equal to separator" invariant.

            theorem tm0_prependList_blockSep_anySuffix {Γ : Type} [Inhabited Γ] [DecidableEq Γ] [Fintype Γ] {sep : Γ} (pref : List Γ) (hpref_nd : gpref, g default) (hpref_nsep : gpref, g sep) :
            TM0RealizesBlockSepAnySuffix Γ sep fun (block : List Γ) => pref ++ block

            Prepending a fixed non-default, non-sep list is realizable before a separator.

            theorem tm0_prependList_blockSep {Γ : Type} [Inhabited Γ] [DecidableEq Γ] [Fintype Γ] {sep : Γ} (pref : List Γ) (hpref_nd : gpref, g default) (hpref_nsep : gpref, g sep) :
            TM0RealizesBlockSep Γ sep fun (block : List Γ) => pref ++ block