A self-contained description of a Turing machine over the tape alphabet Γ.
Bundles the (existential) state type Q, its DecidableEq instance, the underlying
TM, and an optional explicit source/encoding source : List Γ used by certain
concrete encodings.
- Q : Type
- decEq : DecidableEq self.Q
- machine : TuringMachine.TM self.Q Γ
- source : List Γ
Instances For
The language L(d) recognized by the Turing machine packaged inside d.
Instances For
M.haltsWithOutput w out says that running M.machine on input w reaches a
halt configuration after some number of steps n, and at that point the first
out.length cells of the tape spell out out. This is the "halt with out on the
tape" predicate used to formalize the printing/output behavior of TMs.
Instances For
A TMEncoding packages the data Sipser uses to set up the self-reproducing
TM construction:
encode: turns a TM description into its string code⟨M⟩;printTMDesc w: the "printer" machineP_wthat on any input halts withwon the tape (printTMDesc_spec);q_computable: the functionq(w) = ⟨P_w⟩is computable. This is the formal counterpart of the textbook Lemma giving the computable functionq : Σ* → Σ*withq(w) = ⟨P_w⟩.
- encode : TMDescription Γ → List Γ
- printTMDesc : List Γ → TMDescription Γ
- printTMDesc_spec (w input : List Γ) : (self.printTMDesc w).haltsWithOutput input w
- q_computable : TuringMachine.IsComputableFunction fun (w : List Γ) => self.encode (self.printTMDesc w)
Instances For
IsMinimalTM enc d says d is a minimal Turing machine for its language under
the encoding enc: no strictly shorter description d' recognizes the same
language. Formally, for every d', |⟨d'⟩| < |⟨d⟩| implies L(d') ≠ L(d).
Instances For
The data needed to build Sipser's self-reproducing TM SELF. Bundles:
- an encoding
encode : TMDescription → List Γ; - the printer-machine constructor
printTMtogether with its halting spec; - a sequential
composeoperator that runsAthenB(output ofAbecomes input ofB) and whose code is some concatenationcombineDesc (encode A) (encode B); - a "quine helper"
quineBthat on inputinputhalts with⟨P_input⟩ ⟨quineB⟩on the tape. This is exactly the structure used in the proof that some TMSELFprints its own description on every input.
- encode : TMDescription Γ → List Γ
- printTM : List Γ → TMDescription Γ
- printTM_spec (w input : List Γ) : (self.printTM w).haltsWithOutput input w
- compose : TMDescription Γ → TMDescription Γ → TMDescription Γ
- compose_spec (A B : TMDescription Γ) (w mid out : List Γ) : A.haltsWithOutput w mid → B.haltsWithOutput mid out → (self.compose A B).haltsWithOutput w out
- encode_compose (A B : TMDescription Γ) : self.encode (self.compose A B) = self.combineDesc (self.encode A) (self.encode B)
- quineB : TMDescription Γ
- quineB_spec (input : List Γ) : self.quineB.haltsWithOutput input (self.combineDesc (self.encode (self.printTM input)) (self.encode self.quineB))
Instances For
The computable map q(w) := ⟨P_w⟩ inside a SelfRefFramework: it sends a
string w to the code of the printer-machine that outputs w.
Instances For
An extension of SelfRefFramework exposing a concrete second-stage machine
machineB whose halting spec is stated directly in terms of the framework's
function q, matching the textbook construction B(input) = ⟨P_q(input)⟩ ⟨machineB⟩.
- encode : TMDescription Γ → List Γ
- printTM : List Γ → TMDescription Γ
- compose : TMDescription Γ → TMDescription Γ → TMDescription Γ
- compose_spec (A B : TMDescription Γ) (w mid out : List Γ) : A.haltsWithOutput w mid → B.haltsWithOutput mid out → (self.compose A B).haltsWithOutput w out
- combineDesc : List Γ → List Γ → List Γ
- encode_compose (A B : TMDescription Γ) : self.encode (self.compose A B) = self.combineDesc (self.encode A) (self.encode B)
- quineB : TMDescription Γ
- quineB_spec (input : List Γ) : self.quineB.haltsWithOutput input (self.combineDesc (self.encode (self.printTM input)) (self.encode self.quineB))
- machineB : TMDescription Γ
- machineB_spec (input : List Γ) : self.machineB.haltsWithOutput input (self.combineDesc (self.q input) (self.encode self.machineB))
Instances For
Self-Reproducing TM (Sipser, Lecture 11). Given a SelfRefFramework F,
there exists a TM SELF such that on every input w, SELF halts with ⟨SELF⟩
on the tape. The witness is SELF := compose (printTM ⟨quineB⟩) quineB.
A "tape-output" fixed-point witness: a TM fixedTM whose output on input is
g input ⟨fixedTM⟩. This packages the self-referential ability to depend on one's
own code at the tape level, parameterized by an external two-argument map g.
- fixedTM : TMDescription Γ
- fixedTM_spec (input : List Γ) : self.fixedTM.haltsWithOutput input (self.g input (encode self.fixedTM))
Instances For
An abstract acceptable indexing ("coding") of Turing machines over alphabet Γ,
sufficient to formalize the Recursion / Fixed-point theorems and the MIN_TM
unrecognizability proof. It records:
- an index type
TMIndexwith anencode/decodepair and language assignment; - a pairing function
pairon strings; - an
smnfunction with the standards-m-nspecification; - a notion
IsComputableof computable index transformations, closed under the needed operations (composition, applyingsmn, and the diagonalx ↦ smn x x); representable: every computableh : TMIndex → TMIndexis "implemented" by some indexe₀, i.e.languageOf (smn e₀ x) = languageOf (h x);languages_beyond_length: arbitrarily long codes are needed to span all languages — there exist indices whose language differs from all shorter ones;recognizable_enumSearch_computable: a recognizable set of codes plus an enumeration witnesstthat strictly increases code-length yields a computablet.
- TMIndex : Type
- smn_spec (e x : self.TMIndex) (w : List Γ) : w ∈ self.languageOf (self.smn e x) ↔ self.pair w (self.encode x) ∈ self.languageOf e
- representable (h : self.TMIndex → self.TMIndex) : self.IsComputable h → ∃ (e : self.TMIndex), ∀ (x : self.TMIndex), self.languageOf (self.smn e x) = self.languageOf (h x)
- isComputable_smn_diag : self.IsComputable fun (x : self.TMIndex) => self.smn x x
- isComputable_comp (f g : self.TMIndex → self.TMIndex) : self.IsComputable f → self.IsComputable g → self.IsComputable (f ∘ g)
- isComputable_smn_apply (e : self.TMIndex) : self.IsComputable (self.smn e)
- languages_beyond_length (n : ℕ) : ∃ (M : self.TMIndex), ∀ (M' : self.TMIndex), (self.encode M').length < n → self.languageOf M' ≠ self.languageOf M
Instances For
Recursion Theorem (language form). For any computable transformation
t : TMIndex → TMIndex of TM indices, there exists R whose language equals the
language of t R. This is the language-level avatar of Sipser's statement that for
any TM T there is a TM R such that R on w behaves like T on ⟨w, R⟩.
Fixed-point Theorem (Sipser, Lecture 11, Ex 2). For any computable
function f : Σ* → Σ* (with codomain landing in valid encodings), there is a TM
R and a TM S with f(⟨R⟩) = ⟨S⟩ and L(R) = L(S). In other words, every
computable transformation on TM descriptions has a "fixed point" up to language
equality.
PrintsAndHalts M w says: started on the empty tape, M reaches an accept
configuration after some n steps, with cells 0, …, |w|-1 holding the symbols
of w and everywhere else the blank symbol. Captures "M halts having printed
exactly w".
Instances For
Same as PrintsAndHalts but starting from an arbitrary input instead of
the blank tape: after some n steps M accepts and the first |w| tape cells
contain w.
Instances For
The concrete printer-machine P_w for a string w: a TM with |w| + 2
states (one per character, plus an accept and a reject state) that on any input
writes w[0], w[1], …, w[|w|-1] left-to-right and accepts. This is the explicit
construction underlying the computable function q(w) = ⟨P_w⟩.
Instances For
Key loop invariant of printTM: after k ≤ |w| steps on any input, the
machine is in state k, the head is at position k, and tape cells
0, …, k-1 already hold the first k symbols of w. Proved by induction on
k.
Correctness of printTM: on any input, after exactly |w| steps the printer
machine P_w halts (in fact accepts) and the first |w| tape cells (read off by
Config.readTape) spell out w. This realizes the haltsWithOutput spec
demanded by TMEncoding.
Abstract form of the textbook Lemma: from any TMEncoding enc we get a
computable function q : Σ* → Σ* with q(w) = ⟨P_w⟩, where P_w is a TM that on
every input halts with w on the tape.
A concrete instance of TMEncoding built from the explicit printTM
construction. The encoding of a description is taken to be its stored source
field, and printTMDesc w packages the printTM w machine together with
source := w, so q(w) = encode(printTMDesc w) = w is the identity, which is
clearly computable.
Instances For
Lemma (Computable function q) (Sipser, Lecture 11): instantiated with
the concrete encoding. There is a computable q : Σ* → Σ* such that for every
w the description P_w := printTMDesc w satisfies q w = ⟨P_w⟩ and on any
input P_w halts with w on the tape.
Every TM index M has a minimal equivalent: there exists M' with the
same language as M such that M' is minimal. Proved by strong induction on the
code-length, descending to a shorter equivalent whenever M itself is not
minimal.
MIN_TM contains codes of arbitrarily large length: for every n there is a
minimal index B with |⟨B⟩| ≥ n. Combines languages_beyond_length with
exists_minimal_for_language (a shorter minimal equivalent could not differ from
all length-< n indices).
Strict version of min_tm_has_arbitrarily_long_elements: for every n some
minimal index B has |⟨B⟩| > n.
MIN_TM is T-unrecognizable (Sipser, Lecture 11, Ex 3). The language of
codes of minimal Turing machines is not Turing-recognizable. The proof is by
contradiction via the Recursion Theorem: if MIN_TM were recognizable, an
enumeration would produce a computable map t sending each M to a strictly
longer minimal machine, but then any fixed point R of t from the Recursion
Theorem (with L(R) = L(t R)) would witness t R not being minimal — a
contradiction.
A TMCoding augmented with a computable "complement" operation compl
mapping each index M to an index whose language is the set complement of
L(M). Useful for applying the Recursion Theorem to constructions that flip
acceptance.
- coding : TMCoding Γ
- compl_spec (M : self.coding.TMIndex) : self.coding.languageOf (self.compl M) = (self.coding.languageOf M)ᶜ
- compl_computable : self.coding.IsComputable self.compl
Instances For
A_TM is undecidable — new proof via the Recursion Theorem (Sipser,
Lecture 11, Ex 1). Suppose H decided A_TM. Let D be H with its accept and
reject states swapped (so D decides the complement of A_TM). By the
self-reference property of enc, there is a description d₀ whose computation
behaves like running D on ⟨d₀⟩, giving d₀.accepts ↔ ¬ d₀.accepts,
contradiction.
The complement \overline{A_{TM}} of the acceptance language A_TM. This
language is famously not Turing-recognizable and is the one whose
"unprovability" gives Gödel-style results in this development.
Instances For
A minimal abstract "formal proof system" over a TM-encoding enc. It picks
out a Turing-recognizable set provable ⊆ Σ* of provable statements about TM
descriptions, with the soundness assumption that if ⟨d⟩ ∈ provable then d
does not accept (the statement "d is non-accepting" is true).
- enc : TuringMachine.TMEncoding Γ
- provable_recognizable : TuringMachine.IsTuringRecognizable self.provable
Instances For
A FormalProofSystem is complete if every true non-acceptance statement
is provable: whenever d does not accept, ⟨d⟩ ∈ provable. Gödel's
First Incompleteness Theorem says no sound, recognizable system can be complete
in this sense.
Instances For
Gödel's First Incompleteness Theorem (Sipser, Lecture 11). For any sound
proof system whose set of provable statements about TMs is Turing-recognizable,
there is a true statement that is unprovable: there exists a description d
such that d does not accept (true statement) yet ⟨d⟩ ∉ provable.
The proof uses the self-reference property of the encoding enc to build d₀
whose machine effectively simulates the recognizer P of provable on ⟨d₀⟩;
soundness then forces d₀ to be non-accepting and unprovable.
A True but Unprovable Statement (Sipser, Lecture 11). Concrete version
of Gödel's theorem: given an explicit TM P whose language is provable and
soundness of provable, there is a description d₀ such that (1) d₀ does not
accept (the statement ⟨d₀⟩ ∈ \overline{A_{TM}} is true) and (2)
⟨d₀⟩ ∉ provable (it has no proof). The witness d₀ corresponds to Sipser's
machine R which on any input obtains its own code, forms the statement
φ_U = "⟨R, 0⟩ ∈ \overline{A_{TM}}", and searches for a proof of φ_U.