Codes for oracle computations #
Mathlib defines Nat.RecursiveIn O f inductively, as the closure of the basic functions and the
oracles in O under pairing, composition, primitive recursion and unbounded search. That is the
right notion of relative computability, but diagonal constructions need an enumeration of the
oracle computations together with finite, stage-bounded approximations. This file supplies both:
an oracle analogue Nat.RecursiveIn.Code of Mathlib's Nat.Partrec.Code, with evaluation
Code.eval g relative to an oracle g and stage-bounded evaluation Code.evaln σ k against a
finite oracle prefix σ : List ℕ.
The stage-bounded evaluator queries the oracle only below the stage: at stage k it reads at most
the first k entries of σ (Code.evaln_take). Its completeness for total oracles gives the
use principle (Code.exists_use): a convergent oracle computation depends on only finitely many
oracle values.
Main definitions #
Nat.RecursiveIn.Code: codes for oracle computations, with aDenumerableinstance.Nat.RecursiveIn.Code.eval: evaluation of a code relative to a partial oracle.Nat.RecursiveIn.Code.evaln: stage-bounded evaluation against a finite oracle prefix.Nat.RecursiveIn.Code.prefixOf: the finite prefix of lengthNof a total oracle.
Main results #
Nat.RecursiveIn.Code.exists_code:Nat.RecursiveIn {g} fholds if and only iffis the evaluation of some code relative tog.Nat.RecursiveIn.Code.turingReducible_iff_exists_code: the same statement forf ≤ᵀ g.Nat.RecursiveIn.Code.evaln_sound,Nat.RecursiveIn.Code.evaln_complete: stage-bounded evaluation is sound for any oracle agreeing with the prefix, and complete for total oracles.Nat.RecursiveIn.Code.evaln_take: a stage-kcomputation reads only the firstkoracle values.Nat.RecursiveIn.Code.exists_use: the use principle.Nat.RecursiveIn.countable_setOf_turingReducible,TuringDegree.countable_Iic: a function or degree has only countably many predecessors.
Implementation notes #
The open Mathlib PR
mathlib4#38973
(Mathlib/Computability/SingleOracle) proposes overlapping infrastructure: oracle codes
Oracle.Single.Code with eval and a relativized evaln, a code for evaln, and the jump,
related back to RecursiveIn. Its oracles are total functions and its evaln reads the whole
oracle. Nothing here is ported from it. This file instead builds on merged Mathlib's
Nat.RecursiveIn with partial oracles, and its evaln runs against a finite prefix List ℕ,
which gives evaln_take and exists_use directly. Upstreaming must be reconciled with that PR,
which CONTRIBUTING.md lists among the upstream coordination threads.
References #
Codes for computations relative to an oracle. The constructors mirror the constructors of
Nat.RecursiveIn, with oracle standing for the single oracle g passed to Code.eval. The
rfind' constructor follows Mathlib's Nat.Partrec.Code.rfind'.
- zero : Code
- succ : Code
- left : Code
- right : Code
- oracle : Code
- pair : Code → Code → Code
- comp : Code → Code → Code
- prec : Code → Code → Code
- rfind' : Code → Code
Instances For
The Gödel numbering of oracle codes, following Nat.Partrec.Code.encodeCode with the extra
atomic code oracle numbered 4.
Oracle codes are denumerable, via encodeCode and ofNatCode.
Embed a code for an ordinary partial recursive function into the oracle code language.
The embedded code computes the original function relative to any oracle.
Unbounded search with initial offset zero, taking the search parameter as its input.
Stage-bounded evaluation of an oracle code against the finite oracle prefix σ.
evaln σ k c n is defined only for inputs n < k, it runs with recursion depth bounded by k,
and an oracle query at n returns σ[n]?, so it fails if σ is too short. This is Mathlib's
Nat.Partrec.Code.evaln with an oracle case.
Monotonicity of stage-bounded evaluation in the stage and the oracle prefix, where the larger prefix need only agree with the smaller one below the smaller stage.
Completeness of stage-bounded evaluation for total oracles: every convergent computation
relative to f converges at some stage against some finite prefix of f.
Completeness with a single stage parameter: a convergent computation relative to the total
oracle f converges at some stage s against the prefix of f of length s.
The use principle: if a computation relative to the total oracle f converges, then there is
a bound N such that the computation converges to the same value relative to every total oracle
agreeing with f below N.
Nat.RecursiveIn O is closed under the unbounded search with offset used by
Code.rfind'.
A partial function is recursive in the single oracle g if and only if it is the evaluation
of some oracle code relative to g. This is the oracle analogue of
Nat.Partrec.Code.exists_code.
f ≤ᵀ g holds if and only if f is the evaluation of some oracle code relative to g.
A Turing degree has only countably many degrees below it.