Documentation

CslibFrontier.Computability.PostCorrespondence.OfTM0

Turing machine halting as a modified correspondence problem #

For a Mathlib Turing.TM0 machine M with finitely many symbols and states and an input l, OfTM0.mInstance M l is an MPCP instance that is solvable iff M halts on l (OfTM0.eval_dom_iff_solvable). This is Sipser's construction [Sipser2013, proof of Theorem 5.15], phrased through the semi-Thue simulation of CslibFrontier.Computability.PostCorrespondence.Rewrite.

The configuration with state q, scanned symbol a, cells L to the left (nearest first) and cells R to the right is the word ⊢ L⁻¹ ⟨q, a⟩ R ⊣. The rules (OfTM0.Rule) rewrite a configuration word to the next one: a write changes the scanned letter, a move exchanges it with a neighbouring symbol, and a move onto an end marker first inserts the blank default. When M stops, the scanned letter becomes a halt marker, which erases the remaining symbols and finally the word ⊢ halt ⊣. The start domino is ε / ⊢ ⟨q₀, a₀⟩ R ⊣ for the initial configuration, and the copy dominoes complete the instance. The end marker ⊣ separates successive configurations, as # does in Sipser's construction.

Two differences from Sipser's construction: Mathlib's TM0 has a two-way infinite tape and halts when its transition function is undefined, with no accept state, so the instance encodes halting rather than acceptance, and it has rules to extend the tape on both sides.

Configuration representations and machine restriction come from CslibFrontier.Computability.Machines.Turing.SingleTape.TM0Restrict (Turing.TM0).

Main definitions #

Main results #

References #

inductive Cslib.PostCorrespondence.OfTM0.Letter (Γ : Type u_3) (Λ : Type u_4) :
Type (max u_3 u_4)

The letters of configuration words of a TM0 machine: tape symbols, the scanned cell with the machine state, the halt marker and the two end markers.

  • sym {Γ : Type u_3} {Λ : Type u_4} (a : Γ) : Letter Γ Λ

    A tape symbol.

  • cell {Γ : Type u_3} {Λ : Type u_4} (q : Λ) (a : Γ) : Letter Γ Λ

    The scanned cell, holding a, with the machine in state q.

  • halt {Γ : Type u_3} {Λ : Type u_4} : Letter Γ Λ

    The marker left by a halted machine, which then erases the tape.

  • lb {Γ : Type u_3} {Λ : Type u_4} : Letter Γ Λ

    The left end marker.

  • rb {Γ : Type u_3} {Λ : Type u_4} : Letter Γ Λ

    The right end marker.

Instances For
    def Cslib.PostCorrespondence.OfTM0.instDecidableEqLetter.decEq {Γ✝ : Type u_3} {Λ✝ : Type u_4} [DecidableEq Γ✝] [DecidableEq Λ✝] (x✝ x✝¹ : Letter Γ✝ Λ✝) :
    Decidable (x✝ = x✝¹)
    @[instance_reducible]
    instance Cslib.PostCorrespondence.OfTM0.instDecidableEqLetter {Γ✝ : Type u_3} {Λ✝ : Type u_4} [DecidableEq Γ✝] [DecidableEq Λ✝] :
    DecidableEq (Letter Γ✝ Λ✝)

    Letters as a sum type.

    @[instance_reducible]
    instance Cslib.PostCorrespondence.OfTM0.Letter.instFintype {Γ : Type u_1} {Λ : Type u_2} [Fintype Γ] [Fintype Λ] :
    Fintype (Letter Γ Λ)
    @[instance_reducible]

    Parsing configuration words #

    inductive Cslib.PostCorrespondence.OfTM0.Rule {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] (M : Turing.TM0.Machine Γ Λ) :
    Domino (Letter Γ Λ) → Prop

    The rules of the semi-Thue system simulating a TM0 machine M; each rule is a domino whose top rewrites to its bottom.

    theorem Cslib.PostCorrespondence.OfTM0.finite_rule {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] [Finite Γ] [Finite Λ] (M : Turing.TM0.Machine Γ Λ) :
    {d : Domino (Letter Γ Λ) | Rule M d}.Finite
    noncomputable def Cslib.PostCorrespondence.OfTM0.dominoes {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] [Fintype Γ] [Fintype Λ] (M : Turing.TM0.Machine Γ Λ) :
    List (Domino (Letter Γ Λ))

    The dominoes of the MPCP instance simulating M: the rules and a copy domino for every letter.

    theorem Cslib.PostCorrespondence.OfTM0.mem_dominoes {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] [Fintype Γ] [Fintype Λ] {M : Turing.TM0.Machine Γ Λ} {d : Domino (Letter Γ Λ)} :
    d ∈ dominoes M ↔ Rule M d ∨ ∃ (x : Letter Γ Λ), d = copy x
    noncomputable def Cslib.PostCorrespondence.OfTM0.mInstance {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] [Fintype Γ] [Fintype Λ] (M : Turing.TM0.Machine Γ Λ) (l : List Γ) :

    The MPCP instance simulating M on input l: the start domino is ⟨[], ⊢ q₀ l ⊣⟩.

    Soundness: the words reachable from the initial word #

    Completeness #

    The reduction #

    A TM0 machine halts on input l iff the MPCP instance mInstance M l is solvable.