Documentation

LeanPool.Computability.Encoding

Encoding of Oracle Programs and Universality #

This file provides an encoding for oracle partial recursive functions and a definition of the universal partial recursive function relative to an oracle, along with a proof that it is universal.

The identity function is recursive in any oracle O.

theorem Computability.RecursiveIn_comp_total {O : Set ( →. )} {f g : } (hf : RecursiveIn O fun (n : ) => Part.some (f n)) (hg : RecursiveIn O fun (n : ) => Part.some (g n)) :
RecursiveIn O fun (n : ) => Part.some (f (g n))

The composition of two total recursive functions is recursive.

theorem Computability.RecursiveIn_pair_total {O : Set ( →. )} {f g : } (hf : RecursiveIn O fun (n : ) => Part.some (f n)) (hg : RecursiveIn O fun (n : ) => Part.some (g n)) :
RecursiveIn O fun (n : ) => Part.some (Nat.pair (f n) (g n))
theorem Computability.RecursiveIn_prec_total {O : Set ( →. )} {f h : } (hf : RecursiveIn O fun (n : ) => Part.some (f n)) (hh : RecursiveIn O fun (n : ) => Part.some (h n)) :
RecursiveIn O fun (p : ) => Part.some (Nat.rec (f (Nat.unpair p).1) (fun (y IH : ) => h (Nat.pair (Nat.unpair p).1 (Nat.pair y IH))) (Nat.unpair p).2)
theorem Computability.RecursiveIn_of_Primrec {O : Set ( →. )} {f : } (hf : Nat.Primrec f) :
RecursiveIn O fun (n : ) => Part.some (f n)

Every primitive recursive function is recursive.

theorem Computability.RecursiveIn.rfind' {O : Set ( →. )} {f : →. } (hf : RecursiveIn O f) :
RecursiveIn O (Nat.unpaired fun (a m : ) => Part.map (fun (x : ) => x + m) (Nat.rfind fun (n : ) => (fun (m : ) => decide (m = 0)) <$> f (Nat.pair a (n + m))))
def Computability.oracleCode {α : Type} [Denumerable α] (f : α →. ) :

Reindexes an oracle family f : α → ℕ →. ℕ to a family indexed by via the denumerable encoding of α; out-of-range indices map to the nowhere-defined function.

Equations
Instances For

    Codes (Gödel numberings) for oracle partial recursive functions.

    Instances For
      def Computability.evalo {α : Type} [Primcodable α] (f : α →. ) :

      Semantics of codeo, relative to an indexed oracle family.

      Equations
      Instances For
        @[irreducible]

        Decodes a natural number into a code; the inverse of encodeCodeo.

        Equations
        Instances For

          Returns a code for the constant function outputting a particular natural.

          Equations
          Instances For
            theorem Computability.const_inj {n₁ n₂ : } :
            const n₁ = const n₂n₁ = n₂

            Given a code c taking a pair as input, returns a code using n as the first argument to c.

            Equations
            Instances For
              theorem Computability.rfind'o {α : Type} [Primcodable α] {g : α →. } {cf : codeo} (hf : RecursiveIn (Set.range g) (evalo g cf)) :
              RecursiveIn (Set.range g) (Nat.unpaired fun (a m : ) => Part.map (fun (x : ) => x + m) (Nat.rfind fun (n : ) => (fun (m : ) => decide (m = 0)) <$> evalo g cf (Nat.pair a (n + m))))

              The encoding of the code for the constant function with value n.

              Equations
              Instances For

                One primitive-recursion step used to show encodeConst is primitive recursive.

                Equations
                Instances For

                  The encoding of the code pairing the constant n with the identity code.

                  Equations
                  Instances For

                    The encoding of the code applying oracle 0 to the constant n (an s-m-n index).

                    Equations
                    Instances For
                      theorem Computability.s_eq (n : ) :
                      s n = 4 + (5 * Nat.pair 4 (encodeConst n) + 2)
                      theorem Computability.exists_code_rel {α : Type} [Primcodable α] (g : α →. ) (f : →. ) :
                      RecursiveIn (Set.range g) f ∃ (c : codeo), evalo g c = f

                      A function is partial recursive relative to an indexed set of oracles O if and only if there is a code implementing it. Therefore, evalo is a universal partial recursive function relative to g.