Oracle Computability #
This file defines a model of oracle computability using partial recursive functions. It extends
the notion of Nat.Partrec by allowing access to a set of oracle functions.
Main Definitions #
RecursiveIn O f: A partial functionf : ℕ →. ℕis recursive in a set of oraclesO ⊆ ℕ →. ℕif it can be constructed from constants, basic operations, and functions inOusing pairing, composition, primitive recursion, and μ-recursion.liftPrim: Encodes a functionα →. σas a functionℕ →. ℕusingPrimcodable.RecursiveIn',RecursiveIn₂,ComputableIn,ComputableIn₂: Versions ofRecursiveInfor functions betweenPrimcodabletypes.
Implementation Notes #
The encoding/decoding mechanism relies on Primcodable. The definition of RecursiveIn mimics
the inductive structure of Nat.Partrec.
References #
- [Odifreddi1989] Odifreddi, Piergiorgio. Classical Recursion Theory: The Theory of Functions and Sets of Natural Numbers, Vol. I.
Tags #
Computability, Oracle, Recursion, Primitive Recursion
The type of partial functions recursive in a set of oracles O is the smallest type containing
the constant zero, the successor, left and right projections, each oracle g ∈ O,
and is closed under pairing, composition, primitive recursion, and μ-recursion.
- zero {O : Set (ℕ →. ℕ)} : RecursiveIn O fun (x : ℕ) => 0
- succ {O : Set (ℕ →. ℕ)} : RecursiveIn O ↑Nat.succ
- left {O : Set (ℕ →. ℕ)} : RecursiveIn O fun (n : ℕ) => ↑(some (Nat.unpair n).1)
- right {O : Set (ℕ →. ℕ)} : RecursiveIn O fun (n : ℕ) => ↑(some (Nat.unpair n).2)
- oracle {O : Set (ℕ →. ℕ)} (g : ℕ →. ℕ) : g ∈ O → RecursiveIn O g
- pair {O : Set (ℕ →. ℕ)} {f h : ℕ →. ℕ} (hf : RecursiveIn O f) (hh : RecursiveIn O h) : RecursiveIn O fun (n : ℕ) => Nat.pair <$> f n <*> h n
- comp {O : Set (ℕ →. ℕ)} {f h : ℕ →. ℕ} (hf : RecursiveIn O f) (hh : RecursiveIn O h) : RecursiveIn O fun (n : ℕ) => h n >>= f
- prec {O : Set (ℕ →. ℕ)} {f h : ℕ →. ℕ} (hf : RecursiveIn O f) (hh : RecursiveIn O h) : RecursiveIn O fun (p : ℕ) => match Nat.unpair p with | (a, n) => Nat.rec (f a) (fun (y : ℕ) (IH : Part ℕ) => do let i ← IH h (Nat.pair a (Nat.pair y i))) n
- rfind {O : Set (ℕ →. ℕ)} {f : ℕ →. ℕ} (hf : RecursiveIn O f) : RecursiveIn O fun (a : ℕ) => Nat.rfind fun (n : ℕ) => (fun (m : ℕ) => decide (m = 0)) <$> f (Nat.pair a n)
Instances For
The primitive recursive functions ℕ → ℕ relative to a set of oracles O.
- zero {O : Set (ℕ → ℕ)} : PrimrecIn O fun (x : ℕ) => 0
- succ {O : Set (ℕ → ℕ)} : PrimrecIn O Nat.succ
- left {O : Set (ℕ → ℕ)} : PrimrecIn O fun (n : ℕ) => (Nat.unpair n).1
- right {O : Set (ℕ → ℕ)} : PrimrecIn O fun (n : ℕ) => (Nat.unpair n).2
- oracle {O : Set (ℕ → ℕ)} (g : ℕ → ℕ) : g ∈ O → PrimrecIn O g
- pair {O : Set (ℕ → ℕ)} {f g : ℕ → ℕ} : PrimrecIn O f → PrimrecIn O g → PrimrecIn O fun (n : ℕ) => Nat.pair (f n) (g n)
- comp {O : Set (ℕ → ℕ)} {f g : ℕ → ℕ} : PrimrecIn O f → PrimrecIn O g → PrimrecIn O fun (n : ℕ) => f (g n)
- prec {O : Set (ℕ → ℕ)} {f g : ℕ → ℕ} : PrimrecIn O f → PrimrecIn O g → PrimrecIn O (Nat.unpaired fun (z n : ℕ) => Nat.rec (f z) (fun (y IH : ℕ) => g (Nat.pair z (Nat.pair y IH))) n)
Instances For
Encodes a partial function α →. σ as a partial function ℕ →. ℕ using Primcodable.
Equations
- Computability.liftPrim f n = (↑(Encodable.decode n)).bind fun (a : α) => Part.map Encodable.encode (f a)
Instances For
Encodes a total function α → σ as a function ℕ → ℕ using Primcodable.
Equations
- Computability.liftPrimrec f n = (Option.map (fun (a : α) => Encodable.encode (f a)) (Encodable.decode n)).getD 0
Instances For
A partial function between Primcodable types is recursive in O if its lift is.
Equations
Instances For
Relative primitive recursion between primcodable types
Equations
Instances For
A binary partial function is recursive in O if the curried form is.
Equations
- Computability.RecursiveIn₂ O f = Computability.RecursiveIn' O fun (p : α × β) => f p.1 p.2
Instances For
A total function is computable in O if its constant lift is recursive in O.
Equations
- Computability.ComputableIn O f = Computability.RecursiveIn' O fun (a : α) => Part.some (f a)
Instances For
A binary total function is computable in O.
Equations
- Computability.ComputableIn₂ O f = Computability.ComputableIn O fun (p : α × β) => f p.1 p.2
Instances For
If a function is partial recursive, then it is recursive in every partial function.
If a function is computable, then it is computable in every oracle.
If a function is recursive in the constant zero function, then it is partial recursive.
If a function is partial recursive in the constant none function, then it is partial recursive.
A partial function f is partial recursive if and only if it is recursive in
every partial function g.