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 #
Cslib.PostCorrespondence.OfTM0.Letter: the letters of configuration words.Cslib.PostCorrespondence.OfTM0.Rule: the rewriting rules simulating a machine.Cslib.PostCorrespondence.OfTM0.mInstance: the MPCP instance of a machine and an input.
Main results #
Cslib.PostCorrespondence.OfTM0.eval_dom_iff_solvable:Mhalts onliffmInstance M lis solvable.Cslib.PostCorrespondence.OfTM0.primrec_mInstance: the instance depends primitive recursively on the input.
References #
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 stateq. - 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
Parsing configuration words #
The rules of the semi-Thue system simulating a TM0 machine M; each rule is a domino whose
top rewrites to its bottom.
- stop {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} {q : Λ} {a : Γ} : M q a = none → Rule M { top := [Letter.cell q a], bottom := [Letter.halt] }
Halting: the scanned cell becomes the halt marker.
- write {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} {q : Λ} {a : Γ} {q' : Λ} {b : Γ} : M q a = some (q', Turing.TM0.Stmt.write b) → Rule M { top := [Letter.cell q a], bottom := [Letter.cell q' b] }
A write step.
- right {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} {q : Λ} {a : Γ} {q' : Λ} (c : Γ) : M q a = some (q', Turing.TM0.Stmt.move Turing.Dir.right) →
Rule M { top := [Letter.cell q a, Letter.sym c], bottom := [Letter.sym a, Letter.cell q' c] }
A right move onto a written cell.
- rightEnd {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} {q : Λ} {a : Γ} {q' : Λ} : M q a = some (q', Turing.TM0.Stmt.move Turing.Dir.right) →
Rule M { top := [Letter.cell q a, Letter.rb], bottom := [Letter.sym a, Letter.cell q' default, Letter.rb] }
A right move onto a fresh blank cell.
- left {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} {q : Λ} {a : Γ} {q' : Λ} (c : Γ) : M q a = some (q', Turing.TM0.Stmt.move Turing.Dir.left) →
Rule M { top := [Letter.sym c, Letter.cell q a], bottom := [Letter.cell q' c, Letter.sym a] }
A left move onto a written cell.
- leftEnd {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} {q : Λ} {a : Γ} {q' : Λ} : M q a = some (q', Turing.TM0.Stmt.move Turing.Dir.left) →
Rule M { top := [Letter.lb, Letter.cell q a], bottom := [Letter.lb, Letter.cell q' default, Letter.sym a] }
A left move onto a fresh blank cell.
- eatLeft {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} (c : Γ) : Rule M { top := [Letter.sym c, Letter.halt], bottom := [Letter.halt] }
The halt marker erases the symbol to its left.
- eatRight {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} (c : Γ) : Rule M { top := [Letter.halt, Letter.sym c], bottom := [Letter.halt] }
The halt marker erases the symbol to its right.
- finish {Γ : Type u_1} {Λ : Type u_2} [Inhabited Γ] [Inhabited Λ] {M : Turing.TM0.Machine Γ Λ} : Rule M { top := [Letter.lb, Letter.halt, Letter.rb], bottom := [] }
The erased tape is deleted.
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.