Documentation

CslibFrontier.Foundations.Computability.RecursiveInEvalnPrimrec

Primitive recursive evaluator for oracle computations #

This file proves that structural recursion on Nat.RecursiveIn.Code (Code.primrec_recOn', Code.primrec_recOn) and the stage-bounded oracle evaluator Nat.RecursiveIn.Code.evaln (Code.primrec_evaln) are primitive recursive.

It adapts the strong-recursion table argument of Mathlib/Computability/PartrecCode.lean (Apache 2.0, by Mario Carneiro) from Nat.Partrec.Code to Nat.RecursiveIn.Code. Relative to that proof, Code.primrec_recOn' adds the oracle constructor at Gödel number 4 (shifting the composite constructors to n + 5), and G carries the finite oracle prefix σ : List ℕ as an extra parameter of the strong recursion so that the oracle branch looks up σ[n]?.

Main results #

References #

The subcodes of Code.pair cf cg have strictly smaller Gödel numbers than pair cf cg.

The subcodes of Code.comp cf cg have strictly smaller Gödel numbers than comp cf cg.

The subcodes of Code.prec cf cg have strictly smaller Gödel numbers than prec cf cg.

The subcode of Code.rfind' cf has a strictly smaller Gödel number than rfind' cf.

theorem Nat.RecursiveIn.Code.primrec_recOn' {α : Type u_1} {σ : Type u_2} [Primcodable α] [Primcodable σ] {c : α → Code} (hc : Primrec c) {z : α → σ} (hz : Primrec z) {s : α → σ} (hs : Primrec s) {l : α → σ} (hl : Primrec l) {r : α → σ} (hr : Primrec r) {o : α → σ} (ho : Primrec o) {pr : α → Code × Code × σ × σ → σ} (hpr : Primrec₂ pr) {co : α → Code × Code × σ × σ → σ} (hco : Primrec₂ co) {pc : α → Code × Code × σ × σ → σ} (hpc : Primrec₂ pc) {rf : α → Code × σ → σ} (hrf : Primrec₂ rf) :
have PR := fun (a : α) (cf cg : Code) (hf hg : σ) => pr a (cf, cg, hf, hg); have CO := fun (a : α) (cf cg : Code) (hf hg : σ) => co a (cf, cg, hf, hg); have PC := fun (a : α) (cf cg : Code) (hf hg : σ) => pc a (cf, cg, hf, hg); have RF := fun (a : α) (cf : Code) (hf : σ) => rf a (cf, hf); have F := fun (a : α) (c : Code) => Code.recOn c (z a) (s a) (l a) (r a) (o a) (PR a) (CO a) (PC a) (RF a); Primrec fun (a : α) => F a (c a)

Structural recursion on Nat.RecursiveIn.Code with tupled branch functions is primitive recursive. Adapted from Nat.Partrec.Code.primrec_recOn' with an additional oracle branch.

theorem Nat.RecursiveIn.Code.primrec_recOn {α : Type u_1} {σ : Type u_2} [Primcodable α] [Primcodable σ] {c : α → Code} (hc : Primrec c) {z : α → σ} (hz : Primrec z) {s : α → σ} (hs : Primrec s) {l : α → σ} (hl : Primrec l) {r : α → σ} (hr : Primrec r) {o : α → σ} (ho : Primrec o) {pr : α → Code → Code → σ → σ → σ} (hpr : Primrec fun (x : α × Code × Code × σ × σ) => match x with | (a, cf, cg, hf, hg) => pr a cf cg hf hg) {co : α → Code → Code → σ → σ → σ} (hco : Primrec fun (x : α × Code × Code × σ × σ) => match x with | (a, cf, cg, hf, hg) => co a cf cg hf hg) {pc : α → Code → Code → σ → σ → σ} (hpc : Primrec fun (x : α × Code × Code × σ × σ) => match x with | (a, cf, cg, hf, hg) => pc a cf cg hf hg) {rf : α → Code → σ → σ} (hrf : Primrec fun (x : α × Code × σ) => match x with | (a, cf, hf) => rf a cf hf) :
have F := fun (a : α) (c : Code) => Code.recOn c (z a) (s a) (l a) (r a) (o a) (pr a) (co a) (pc a) (rf a); Primrec fun (a : α) => F a (c a)

Structural recursion on Nat.RecursiveIn.Code with curried branch functions is primitive recursive. Adapted from Nat.Partrec.Code.primrec_recOn with an additional oracle branch.

theorem Nat.RecursiveIn.Code.primrec_evaln :
Primrec fun (x : List ℕ × (ℕ × Code) × ℕ) => match x with | (σ, (k, c), n) => evaln σ k c n

The Nat.RecursiveIn.Code.evaln function is primitive recursive.