Documentation

CslibFrontier.Foundations.Computability.RecursiveInSmn

The oracle-uniform s-m-n theorem #

A code for a two-argument oracle program reads its arguments m and n as the paired input Nat.pair m n. Specializing the first argument to a fixed parameter m gives the code Code.curry c m, which runs c after pairing its own input with m. This file proves that specialization is a primitive recursive operation on codes and that it preserves evaluation relative to every oracle (Code.eval_curry). The specializing map does not depend on the oracle: it is a syntactic operation on codes, and one primitive recursive index map works for all oracles at once (Code.exists_primrec₂_smn). This is the relativized s-m-n theorem, in the s¹₁ form where several parameters are passed as one paired number.

On the way, the constructors of Nat.RecursiveIn.Code are shown primitive recursive on codes, as is the embedding Code.ofPartrec of ordinary codes. Together with Code.eval, which composes the evaluations of the two parts of Code.comp cf cg, Code.primrec₂_comp says that composition of oracle programs is a primitive recursive operation on codes, for every oracle.

Main definitions #

Main results #

Implementation notes #

The constructor lemmas adapt Nat.Partrec.Code.primrec₂_pair and its neighbours in Mathlib/Computability/PartrecCode.lean (Apache 2.0, by Mario Carneiro) to the numbering Code.encodeCode, which differs from Mathlib's by the extra atomic code oracle. The embedding lemma Code.primrec_ofPartrec and the definition of Code.curry through the embedded constant code follow Nat.Partrec.Code.primrec_toSingleOracleCode and TauCeti.Oracle.Single.Code.curry in Tau Ceti's SingleOracle/Code (Apache 2.0, by the Tau Ceti contributors), restated for this library's oracle codes and its existing embedding Code.ofPartrec. Code.curry is the oracle analogue of Mathlib's Nat.Partrec.Code.curry.

References #

Forming the pairing code of two codes is primitive recursive.

Forming the composition code of two codes is primitive recursive.

Forming the primitive recursion code of two codes is primitive recursive.

Forming the unbounded search code of a code is primitive recursive.

Embedding ordinary codes into oracle codes is primitive recursive.

Specialize the first argument of a code to the parameter m: on input n, the code curry c m runs c on Nat.pair m n. It composes c with the pairing of the embedded constant code for m and the identity code pair left right.

@[simp]
theorem Nat.RecursiveIn.Code.eval_curry (g : ℕ →. ℕ) (c : Code) (m n : ℕ) :
eval g (c.curry m) n = eval g c (Nat.pair m n)

Specialization preserves evaluation relative to every oracle g, including partial ones.

Specialization is primitive recursive in the code and the parameter.

theorem Nat.RecursiveIn.Code.exists_primrec₂_smn :
∃ (s : ℕ → ℕ → ℕ), Primrec₂ s ∧ ∀ (g : ℕ →. ℕ) (e m n : ℕ), eval g (Denumerable.ofNat Code (s e m)) n = eval g (Denumerable.ofNat Code e) (Nat.pair m n)

The oracle-uniform s-m-n theorem, in the s¹₁ form with paired arguments. A single primitive recursive map s on indices specializes the first argument: for every oracle g, including partial ones, every index e and all m and n, the program with index s e m computes relative to g on n what the program with index e computes relative to g on Nat.pair m n. The map s is chosen before the oracle, so it is the same for all oracles; it is fun e m => encode (curry (ofNat Code e) m). Relativized form of Kleene's s-m-n theorem [Kle52]; see also [Soa87] for relativization.