Documentation

CslibFrontier.Foundations.Computability.RecursiveInUniform

Oracle-uniform codes #

Nat.RecursiveIn.Code.exists_code gives, for each oracle g, some code computing a function relative to g; the code may depend on g. Simulations of oracle machines and oracle programs produce one code that works for every oracle. Code.HasUniformCode o F states this for a family of oracles o : ι → ℕ →. ℕ: a single code computes F i relative to o i for every index i. The family is arbitrary, so both partial oracles (o := id) and Boolean membership oracles are instances.

The predicate is closed under the constructors of Nat.RecursiveIn, and contains every partial recursive function. HasUniformCode.ite adds a guarded call: it runs a partial computation only where a computable test asks for it, and otherwise returns its input.

Main definitions #

Main results #

def Nat.RecursiveIn.Code.HasUniformCode {ι : Type u_1} (o F : ι → ℕ →. ℕ) :

One code computes F i relative to the oracle o i, for every index i.

theorem Nat.RecursiveIn.Code.HasUniformCode.of_partrec {ι : Type u_1} {o : ι → ℕ →. ℕ} {f : ℕ →. ℕ} (hf : Nat.Partrec f) :
HasUniformCode o fun (x : ι) => f
theorem Nat.RecursiveIn.Code.HasUniformCode.of_primrec {ι : Type u_1} {o : ι → ℕ →. ℕ} {f : ℕ → ℕ} (hf : Nat.Primrec f) :
HasUniformCode o fun (x : ι) (n : ℕ) => Part.some (f n)
theorem Nat.RecursiveIn.Code.HasUniformCode.comp {ι : Type u_1} {o F G : ι → ℕ →. ℕ} (hF : HasUniformCode o F) (hG : HasUniformCode o G) :
HasUniformCode o fun (i : ι) (n : ℕ) => G i n >>= F i
theorem Nat.RecursiveIn.Code.HasUniformCode.pair {ι : Type u_1} {o F G : ι → ℕ →. ℕ} (hF : HasUniformCode o F) (hG : HasUniformCode o G) :
HasUniformCode o fun (i : ι) (n : ℕ) => Nat.pair <$> F i n <*> G i n
theorem Nat.RecursiveIn.Code.HasUniformCode.prec {ι : Type u_1} {o F G : ι → ℕ →. ℕ} (hF : HasUniformCode o F) (hG : HasUniformCode o G) :
HasUniformCode o fun (i : ι) => unpaired fun (a n : ℕ) => Nat.rec (F i a) (fun (y : ℕ) (ih : Part ℕ) => do let x ← ih G i (Nat.pair a (Nat.pair y x))) n
theorem Nat.RecursiveIn.Code.HasUniformCode.rfind {ι : Type u_1} {o F : ι → ℕ →. ℕ} (hF : HasUniformCode o F) :
HasUniformCode o fun (i : ι) (a : ℕ) => Nat.rfind fun (n : ℕ) => (fun (m : ℕ) => decide (m = 0)) <$> F i (Nat.pair a n)
theorem Nat.RecursiveIn.Code.HasUniformCode.of_eq {ι : Type u_1} {o F G : ι → ℕ →. ℕ} (hF : HasUniformCode o F) (h : ∀ (i : ι) (n : ℕ), F i n = G i n) :
theorem Nat.RecursiveIn.Code.HasUniformCode.of_computable {ι : Type u_1} {o : ι → ℕ →. ℕ} {f : ℕ → ℕ} (hf : Computable f) :
HasUniformCode o fun (x : ι) (n : ℕ) => Part.some (f n)

A total computable function, used by the same code for every oracle.

theorem Nat.RecursiveIn.Code.HasUniformCode.ite {ι : Type u_1} {o : ι → ℕ →. ℕ} {b : ℕ → ℕ} (hb : Computable b) {F : ι → ℕ →. ℕ} (hF : HasUniformCode o F) :
HasUniformCode o fun (i : ι) (n : ℕ) => if b n = 0 then Part.some n else F i n

A guarded call: where the computable test b is 0 the input is returned and F is not run, so its divergence there does not matter.

theorem Nat.RecursiveIn.Code.HasUniformCode.recursiveIn {ι : Type u_1} {o F : ι → ℕ →. ℕ} (hF : HasUniformCode o F) (i : ι) :