From Mathlib's partial recursive functions into the ambient model #
Mathlib's Turing.ToPartrec.Code is a small first-order language on lists of naturals
(zero', succ, tail, cons, comp, case, fix) in which every partial recursive
function is computable (Turing.ToPartrec.Code.exists_code). It translates construct by
construct into the ambient language (Prog.ofCode), with lists of naturals encoded as
cons-chains of unary numerals (encL) and fix as a loop; ofCode_sound and
ofCode_complete are the two directions of the correctness of the translation.
exists_compile is the resulting bridge for the halting problem: a map compile from
Nat.Partrec.Code to programs, computable on descriptions, such that compile pc halts on
the empty input iff pc does on 0: compile pc hardcodes the code number of pc into
the translation of a ToPartrec.Code for the universal partial function n ↦ (ofNat n).eval 0.
Lists of naturals as data: a cons-chain of unary numerals.
Equations
Instances For
The body of the translation of fix f: run f, then dispatch on the head of the
result (stop with the tail if it is 0, continue with the tail otherwise).
Equations
- One or more equations did not get rendered due to their size.
Instances For
The headI :: tail assembly of the translation of cons f fs, in an environment
[fs v, f v, v].
Equations
Instances For
Translation of ToPartrec.Code into the ambient language.
Equations
- One or more equations did not get rendered due to their size.
- MIPRE.Cost.Prog.ofCode Turing.ToPartrec.Code.zero' = MIPRE.Cost.Prog.nil.cons (MIPRE.Cost.Prog.var 0)
- MIPRE.Cost.Prog.ofCode Turing.ToPartrec.Code.tail = MIPRE.Cost.Prog.elim 0 MIPRE.Cost.Prog.nil (MIPRE.Cost.Prog.var 1)
- MIPRE.Cost.Prog.ofCode (f.cons fs) = (MIPRE.Cost.Prog.ofCode f).let_ ((MIPRE.Cost.Prog.callVar 1 (MIPRE.Cost.Prog.ofCode fs)).let_ MIPRE.Cost.Prog.consTail)
- MIPRE.Cost.Prog.ofCode (f.comp g) = (MIPRE.Cost.Prog.ofCode g).let_ (MIPRE.Cost.Prog.ofCode f)
- MIPRE.Cost.Prog.ofCode f.fix = (MIPRE.Cost.Prog.ofCode f).fixBody.loop
Instances For
Forward runs of the pieces #
Soundness #
Completeness #
The halting-problem bridge #
The universal partial function on code numbers: n ↦ (decode n).eval 0.
Equations
- MIPRE.Cost.univPart n = (↑(Encodable.decode n)).bind fun (c : Nat.Partrec.Code) => c.eval 0
Instances For
The halting problem transfers from Nat.Partrec.Code to the ambient model along a map
compile, computable on descriptions (encode (compile pc) : Data).