Gödel Numbering for Partial Recursive Functions. #
This file defines Nat.Partrec.Code, an inductive datatype describing code for partial
recursive functions on ℕ. It defines an encoding for these codes, and proves that the constructors
are primitive recursive with respect to the encoding.
It also defines the evaluation of these codes as partial functions using PFun, and proves that a
function is partially recursive (as defined by Nat.Partrec) if and only if it is the evaluation
of some code.
Main Definitions #
Nat.Partrec.Code: Inductive datatype for partial recursive codes.Nat.Partrec.Code.encodeCode: A (computable) encoding of codes as natural numbers.Nat.Partrec.Code.ofNatCode: The inverse of this encoding.Nat.Partrec.Code.eval: The interpretation of aNat.Partrec.Codeas a partial function.
Main Results #
Nat.Partrec.Code.primrec_recOn: Recursion onNat.Partrec.Codeis primitive recursive.Nat.Partrec.Code.computable_recOn: Recursion onNat.Partrec.Codeis computable.Nat.Partrec.Code.smn: The $S_n^m$ theorem.Nat.Partrec.Code.exists_code: Partial recursiveness is equivalent to being the eval of a code.Nat.Partrec.Code.primrec_evaln:evalnis primitive recursive.Nat.Partrec.Code.fixed_point: Roger's fixed point theorem.Nat.Partrec.Code.fixed_point₂: Kleene's second recursion theorem.
References #
- [Mario Carneiro, Formalizing computability theory via partial recursive functions][carneiro2019]
Returns a code for the constant function outputting a particular natural.
Instances For
Given a code c taking a pair as input, returns a code using n as the first argument to c.
Instances For
An encoding of a Nat.Partrec.Code as a ℕ.
Instances For
A decoder for Nat.Partrec.Code.encodeCode, taking any ℕ to the Nat.Partrec.Code it represents.
Instances For
Recursion on Nat.Partrec.Code is primitive recursive.
Recursion on Nat.Partrec.Code is computable.
The interpretation of a Nat.Partrec.Code as a partial function.
Nat.Partrec.Code.zero: The constant zero function.Nat.Partrec.Code.succ: The successor function.Nat.Partrec.Code.left: Left unpairing of a pair of ℕ (encoded byNat.pair)Nat.Partrec.Code.right: Right unpairing of a pair of ℕ (encoded byNat.pair)Nat.Partrec.Code.pair: Pairs the outputs of argument codes usingNat.pair.Nat.Partrec.Code.comp: Composition of two argument codes.Nat.Partrec.Code.prec: Primitive recursion. Given an argument of the formNat.pair a n:Nat.Partrec.Code.rfind': Minimization starting at a provided value. Given an argument of the formNat.pair a m, returns the leastn ≥ msuch thateval cf (pair a n) = 0, if such annexists and ifeval cf (pair a k)terminates for allm ≤ k ≤ n.
Instances For
Helper lemma for the evaluation of prec in the base case.
The $S_n^m$ theorem: There is a computable function, namely Nat.Partrec.Code.curry, that takes a
program and a ℕ n, and returns a new program using n as the first argument.
A function is partial recursive if and only if there is a code implementing it. Therefore,
eval is a universal partial recursive function.
A modified evaluation for the code which returns an Option ℕ instead of a Part ℕ. To avoid
undecidability, evaln takes a parameter k and fails if it encounters a number ≥ k in the course
of its execution. Other than this, the semantics are the same as in Nat.Partrec.Code.eval.
Instances For
The Nat.Partrec.Code.evaln function is primitive recursive.
Roger's fixed-point theorem: any total, computable f has a fixed point.
That is, under the interpretation given by Nat.Partrec.Code.eval, there is a code c
such that c and f c have the same evaluation.
Kleene's second recursion theorem
There are only countably many partial recursive partial functions ℕ →. ℕ.
There are only countably many computable functions ℕ → ℕ.