Documentation

CslibFrontier.Foundations.Computability.RecursiveInUniversalPartial

A universal oracle code for partial oracles #

There is a single oracle code u that, relative to every partial oracle g : ℕ →. ℕ, evaluates the code with index e at n: eval g u ⟨e, n⟩ = eval g (ofNat Code e) n (Nat.RecursiveIn.Code.exists_universal_partial). The code does not depend on the oracle. This is the relativized enumeration theorem for the semantics of Code.eval, in which a query at a point where the oracle is undefined diverges.

The universal code for total oracles, Code.exists_universal, searches over stages and reads an oracle prefix, so it queries points that the simulated computation may never query; relative to a partial oracle that search can diverge on a convergent computation. The code here queries the oracle only on demand. It keeps a finite table of the answers obtained so far and runs the simulated code against the table (Code.evalAsk). The run either finishes, or stops at the first query the table cannot answer; the code then asks the oracle at that point, records the answer, and runs again.

A run against a table is itself an oracle computation relative to a total oracle that presents the table. The code for it is a primitive recursive translation of the simulated code, and the universal code for total oracles evaluates it.

Main definitions #

Main results #

Implementation notes #

Cslib.ClockedComp.exists_code_eval in RecursiveInClocked.lean turns a family of oracle programs with a computable dialogue into one code for all partial oracles, and each compiled code has a computable dialogue. A universal code would need the dialogue of all compiled codes to be computable jointly in the code, which that file does not prove; this file instead compiles runs against tables into codes and uses the universal code for total oracles.

Relation to the unrelativized enumeration theorem #

Kleene's enumeration theorem gives one partial recursive function that evaluates every partial recursive function from its index and argument [Kle43]; it has no oracle. The Lean statement ∃ u, ∀ g e n, eval g u (Nat.pair e n) = eval g (ofNat Code e) n extends it in two ways.

References #

Runs against an answer table #

Evaluation of a code against the answer table h : ℕ → Option ℕ, in the order in which Code.eval runs the computation. The run returns inr v if it finishes with v using only answers in h, and inl q at the first query q that h does not answer.

theorem Nat.RecursiveIn.Code.evalAsk_sound {h : ℕ → Option ℕ} {g : ℕ →. ℕ} (hh : ∀ (q v : ℕ), h q = some v → v ∈ g q) (c : Code) {n : ℕ} {r : ℕ ⊕ ℕ} :
r ∈ evalAsk h c n → Sum.elim (fun (q : ℕ) => h q = none) (fun (v : ℕ) => v ∈ eval g c n) r

Soundness of runs against an answer table. If the table h agrees with the oracle g wherever it answers, a finished run against h gives a value of the evaluation relative to g, and a request is at a point that h does not answer.

theorem Nat.RecursiveIn.Code.evalAsk_complete {g : ℕ →. ℕ} {c : Code} {n x : ℕ} (hx : x ∈ eval g c n) :
∃ (N : ℕ), ∀ (h : ℕ → Option ℕ), (∀ (q v : ℕ), h q = some v → v ∈ g q) → ∃ r ∈ evalAsk h c n, r = Sum.inr x ∨ ∃ q < N, r = Sum.inl q ∧ h q = none ∧ (g q).Dom

Completeness of runs against an answer table. If a computation relative to g converges to x, there is a bound N such that against every table h agreeing with g, the run either finishes with x or requests an answer at a point q < N that h does not answer and where g is defined.

Compiling runs against an answer table into codes #

Asking the oracle on demand #

The universal code #

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

A universal oracle code for partial oracles. One code u evaluates, relative to every partial oracle g, the code with index e at n when given Nat.pair e n. The code does not depend on the oracle. Relativized form of Kleene's enumeration theorem [Kle43].