Documentation

CslibFrontier.Foundations.Computability.RecursiveInUniversal

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 #

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 #

theorem Nat.RecursiveIn.Code.hasUniformCode_prefixOf :
HasUniformCode (fun (f : ℕ → ℕ) => ↑f) fun (f : ℕ → ℕ) (k : ℕ) => Part.some (Encodable.encode (prefixOf f k))

One code computes the encoded prefix k ↦ encode (prefixOf f k) of every total oracle f.

theorem Nat.RecursiveIn.Code.exists_universal :
∃ (u : Code), ∀ (f : ℕ → ℕ) (e n : ℕ), eval (↑f) u (Nat.pair e n) = eval (↑f) (Denumerable.ofNat Code e) n

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.