A universal oracle code for total oracles #
There is a single oracle code u that, relative to every total oracle f, evaluates the code
with index e at n: eval f u ⟨e, n⟩ = eval f (ofNat Code e) n
(Nat.RecursiveIn.Code.exists_universal). The code does not depend on the oracle.
The code searches for a stage s at which the stage-bounded evaluator Code.evaln, run against
the first s oracle values, converges. It reads those values from the oracle one at a time, and
the stage-bounded evaluator is primitive recursive (Code.primrec_evaln). This is the oracle
analogue of the proof of Nat.Partrec.Code.eval_part in Mathlib, whose search runs Mathlib's
Nat.Partrec.Code.evaln.
Main results #
Nat.RecursiveIn.Code.exists_universal: a universal code for all total oracles.Nat.RecursiveIn.Code.hasUniformCode_prefixOf: one code computes the encoded prefixes of every total oracle.
Implementation notes #
The search reads the oracle at every argument below the stage, so it needs a total oracle: a
partial oracle undefined at some argument that a computation never queries would make the search
diverge. The universal code for partial oracles,
Nat.RecursiveIn.Code.exists_universal_partial in RecursiveInUniversalPartial.lean, uses a
sequential simulation instead, and is built on this one.
References #
One code computes the encoded prefix k ↦ encode (prefixOf f k) of every total oracle f.
A universal oracle code for total oracles. One code u evaluates, relative to every total
oracle f, the code with index e at n when given Nat.pair e n.