Documentation

Realizability.RealizabilityCCC

The realizability category is Cartesian closed #

The exponential [A ⇒ B] is the set of realizer-codes implementing morphisms "under extensional equality". Realizability/Realizability.lean established the realizability category and products on a single-encoding assembly, but the exponential needs the modest / relational assembly form (each morphism realized by many codes — exactly the "extensional equality" subtlety). This file builds that form and proves the category Cartesian closed, concretely (terminal + product + exponential universal properties as natural bijections).

The PCA and assemblies #

Realizers are natural numbers; application is Kleene's first PCA over Nat.Partrec.Code: ap a b := (ofNat Code a).eval b. An assembly is a type with a realizability relation realizes : ℕ → carrier → Prop (every element realized by ≥1 code). A morphism is a function tracked by a realizer code (Tracks), and A ⟶ B is the trackable functions — a genuine CategoryTheory.Category. (Finiteness is the finite full subcategory; the CCC structure does not need it, so it is omitted here for the general result.)

Kleene's first PCA application on ℕ: decode a to a code and run it on b.

Equations
Instances For

    An assembly over the PCA: a carrier with a realizability relation, every element realized.

    • carrier : Type

      the underlying set of elements.

    • realizes : ℕ → self.carrier → Prop

      realizes n x : the code n is a realizer of x — a program-level name for it. An element may have many realizers, and a code may realize elements of several assemblies.

    • realized (x : self.carrier) : ∃ (n : ℕ), self.realizes n x

      every element has at least one realizer: nothing in the carrier is unnameable.

    Instances For
      def RealizabilityCCC.Tracks (A B : Asm) (r : ℕ) (f : A.carrier → B.carrier) :

      r tracks f : on any realizer n of x, r·n is defined and realizes f x.

      Equations
      Instances For

        f is trackable (a morphism): some code tracks it.

        Equations
        Instances For

          Composition realizer code ("apply rf then rg").

          Equations
          Instances For
            theorem RealizabilityCCC.tracks_comp {A B C : Asm} {rf rg : ℕ} {f : A.carrier → B.carrier} {g : B.carrier → C.carrier} (hrf : Tracks A B rf f) (hrg : Tracks B C rg g) :
            Tracks A C (compCode rg rf) (g ∘ f)
            @[instance_reducible]

            The realizability category: objects are assemblies, morphisms the trackable functions.

            Equations
            • One or more equations did not get rendered due to their size.

            Terminal object #

            The terminal assembly: a single point, realized by every code.

            Equations
            Instances For

              The unique map into the terminal assembly is trackable (by idCode).

              Binary products #

              Product assembly: a code realizes (a,b) iff its two halves realize a and b.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                The realizer of the first projection: the code of Code.left, which reads back the first component of a paired input (ap_leftCode).

                Equations
                Instances For

                  The realizer of the second projection: the code of Code.right, which reads back the second component of a paired input (ap_rightCode).

                  Equations
                  Instances For

                    The first projection is tracked, by Code.left.

                    The second projection is tracked, by Code.right.

                    Exponentials — the realizability category is Cartesian closed #

                    Exponential assembly [A ⇒ B]: the carrier is the morphisms A ⟶ B (trackable functions), and a code realizes a morphism iff it tracks it — the many-realizers ("under extensional equality") structure the single-encoding assembly could not express.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      theorem RealizabilityCCC.ev_tracks (A B : Asm) :
                      Trackable (prodAsm (expAsm A B) A) B fun (p : (prodAsm (expAsm A B) A).carrier) => ↑p.1 p.2

                      Evaluation is tracked — ev : [A ⇒ B] × A ⟶ B, (f, a) ↦ f a, realized by the universal evaluator code (Realizability.universal_evaluator).

                      theorem RealizabilityCCC.curry_inner_tracks {C A B : Asm} {rh : ℕ} {h : C.carrier × A.carrier → B.carrier} (hrh : Tracks (prodAsm C A) B rh h) (c : C.carrier) {rc : ℕ} (hrc : C.realizes rc c) :

                      If rh tracks h : C × A → B, then for any realizer rc of c, the code ⌜curry (ofNat rh) rc⌝ tracks the residual a ↦ h(c,a). (s-m-n / eval_curry.)

                      noncomputable def RealizabilityCCC.curryFn {C A B : Asm} (rh : ℕ) (h : C.carrier × A.carrier → B.carrier) (hrh : Tracks (prodAsm C A) B rh h) (c : C.carrier) :

                      The curried map c ↦ (a ↦ h(c,a)) into the exponential.

                      Equations
                      Instances For
                        theorem RealizabilityCCC.curry_tracks {C A B : Asm} {rh : ℕ} {h : C.carrier × A.carrier → B.carrier} (hrh : Tracks (prodAsm C A) B rh h) :
                        Trackable C (expAsm A B) (curryFn rh h hrh)

                        The curried map is itself a morphism C ⟶ [A ⇒ B] (tracked by the currying code).

                        theorem RealizabilityCCC.exp_universal {C A B : Asm} (g : prodAsm C A ⟶ B) :
                        ∃! t : C ⟶ expAsm A B, ∀ (c : C.carrier) (a : A.carrier), ↑(↑t c) a = ↑g (c, a)

                        The realizability category is Cartesian closed — the exponential's universal property: every morphism g : C × A ⟶ B has a unique transpose t : C ⟶ [A ⇒ B] factoring it through evaluation, (t c) a = g (c, a). Together with the terminal object and binary products, this is Cartesian closure. The transpose is curryFn; uniqueness is extensional (morphism equality is function equality, the realizer existentially quantified).