The graded exponential, and what applying one costs ([Decoupling] §4.5) #
A bounded work memory cannot carry a strict function space: no capacity is closed under the
exponential, neither in element count (FV-14) nor in realizer length (FV-16). What survives is a
graded exponential: for each resource grade g, the morphisms that own a realizer within g.
This module builds that object over Kleene's first algebra on Nat.Partrec.Code and prices its
application.
The grade currency #
A grade bounds a realizer's description length, Nat.size of its Gödel index. This is not a
free choice: it is the currency the priced universal evaluator already charges in, so a grade can
be spent directly in that account without a conversion factor. It is also, on the nose, the
realizer length of the counting bound (ReflectiveSubsystems.bitlen) transported along the
Code ≃ ℕ numbering — grade_encode and bitlen_ofNat record the identification, so the
non-closure theorems and the grading here speak of one quantity, not two that happen to agree.
What the identification is about is the measure alone: the counting bound is stated over
assemblies whose elements carry one name each, while the exponential graded here is the
many-realizers form; the two settings meet where naming is unambiguous, the condition isolated
below (Modest).
Application goes through the reference dynamics #
The partial combinatory algebra applies by decoding: ap a b decodes a to a code and runs it.
That decode is an existence statement with no constructor skeleton, so nothing about the run can
be priced — which is exactly what the priced evaluator was built to replace. So application is
repackaged here as a run of the reference dynamics: appRun r x τ is the configuration the
small-step machine reaches after τ steps from ⟨r, x⟩, and appValue_mem_ap /
exists_appRun_of_mem_ap say that this run computes the algebra's application and nothing else.
Both directions are the machine's own soundness and completeness against Code.eval, applied at
the application interface; no new semantics is introduced.
What a grade buys, and what it does not #
appConfig_size_le is the whole of what a grade provably buys on the workspace side: the
initial configuration's width is affine in the grade and the argument's width. Every later
configuration holds values the computation has produced, which are outputs rather than functions
of the code's shape, so nothing bounds them from the grade alone. The workspace account therefore
stays relative to a named width hypothesis W, exactly as bounded universality itself is — and
gradedApp_workspace is that account: under the hypothesis, the evaluator's workspace on the
application is F of the wider of W and a grade-derived affine budget. An affine bound free of
W, derived from the grade alone, would make this false, not merely unproved — a W-free bound as
such need not be (a trivial max over finitely many inputs is W-free), only the affine, grade-derived
one.
Deliberately absent #
No functoriality statement: transporting graded realizers along a change of algebra is the
applicative-morphism question, settled territory that this development does not re-enter. No
graded Cartesian closed structure: gradedExp is built and priced as an object, with the
inclusion and grade-monotonicity morphisms it needs, and nothing is claimed about closure of the
grading itself. Both are scope decisions rather than gaps.
Prior art #
Resource-graded exponential modalities are the bounded-linear-logic tradition (Girard–Scedrov–Scott
1992), with a semantics on assemblies given by Fukihara–Katsumata (2021). Nothing about the concept
is new here; what is new is the concrete instantiation on Nat.Partrec.Code together with a
machine-checked affine price for applying it.
The grade currency #
The grade of a realizer: the bit-length of its Gödel index — Nat.size of the code's
encoding. Realizers in the realizability category are already numbers, so the round trip through
Code is the identity (grade_eq_size); it is written out here because the measure is a
property of the code, not of the numeral that happens to name it.
Equations
Instances For
The grade of a code's index is its realizer length in the sense of the counting bound
(ReflectiveSubsystems.bitlen). The two accounts — the non-closure theorems, which measure a
realizer's length, and the grading here, which budgets it — use one quantity.
The same identification read the other way: the realizer length of the code a numeral names is that numeral's grade.
The graded exponential #
The graded exponential [A ⇒ B]_g: the sub-assembly of the exponential expAsm A B whose
elements own a realizer of grade at most g, realized by exactly those realizers.
Two clauses, and both are load-bearing. The carrier condition is what makes the object inhabited
by affordable morphisms; the realizability condition is what makes a realizer drawn from the
object affordable in turn, which is what the application account below consumes. Every element is
realized (realized) precisely because the carrier condition says so.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The function underlying an element of the graded exponential. An element carries a morphism
A ⟶ B together with the evidence that it is affordable; this reads off the morphism.
Equations
- ReflectiveSubsystems.fn f = ↑↑f
Instances For
The inclusion of the graded exponential into the exponential: forget the grade.
Equations
Instances For
The inclusion is a morphism, tracked by the identity code: forgetting a grade changes no realizer.
The inclusion is trackable, hence a morphism [A ⇒ B]_g ⟶ [A ⇒ B].
Relaxing the budget: an element affordable at grade g is affordable at any larger grade.
Equations
- ReflectiveSubsystems.relax h f = ⟨↑f, ⋯⟩
Instances For
Grade monotonicity. The graded exponentials form an increasing family, and the inclusion of
one grade into a larger one is a morphism tracked by the identity code — a realizer affordable at
g is affordable at g', and no re-coding is needed to say so.
The grade-relaxing map is trackable, hence a morphism [A ⇒ B]_g ⟶ [A ⇒ B]_{g'}.
Application, as a run of the reference dynamics #
The application argument: what the universal evaluator is handed to run the realizer r on
the input x for τ steps.
Equations
- ReflectiveSubsystems.appInput r x τ = Nat.pair (Nat.pair r x) τ
Instances For
The application run: the configuration the reference dynamics reaches after τ steps from
the initial configuration of r on x. This — not the algebra's decode — is what gets priced.
Equations
Instances For
Has the application run finished after τ steps?
Equations
Instances For
The value a finished application run holds.
Equations
Instances For
The run computes the application (soundness half). If the run has finished, its value is a
genuine value of the algebra's application r · x.
The run computes the application (completeness half). Every value the algebra's application
r · x produces is reached by the run, at some number of steps.
The run's width hypothesis is not vacuous. On an application that finishes, the widths of
the configurations the run passes through are bounded uniformly: the initial segment is finite, and
past the halting step the run is constant (appRun_of_halted).
So the hypothesis carried through the workspace account is quantitative — which W — rather than
existential. What no grade supplies is the value of W, since the configurations hold values the
computation produced.
What the grade bounds: the initial width #
What a grade buys on the workspace side, exactly. The initial configuration of the application run is affine in the grade and the argument's width — unconditionally, with no hypothesis about the run.
This is also the boundary. Every later configuration of the run holds values the computation has produced; those are outputs of the computation rather than functions of the code's shape, so no grade bounds them. That is why the workspace account below is relative to a named width hypothesis and not derived from the grade alone.
The workspace account of a graded application #
The graded application's workspace account ([Decoupling] §4.5, "the universal evaluator's
application combinator runs within the work memory", grade-relative). Under bounded universality
at F, some code runs the application of a grade-g realizer — computing the reference dynamics
on every input, so the semantics is the algebra's own — within F of the wider of the run's width
bound and a budget affine in the grade, the argument's width, and the counter's width.
The width hypothesis W stays a hypothesis. Grades bound the initial configuration
(appConfig_size_le) and nothing further, so an affine bound free of W, derived from the
grade alone, would not be a stronger theorem but a false one — a W-free bound as such need not
be (a trivial max over finitely many inputs is W-free), only the affine, grade-derived one.
The price bounded universality is actually discharged at is monotone, so it can serve as the budget the account is stated against.
The account, unconditionally. Bounded universality holds at an affine price, so the graded
application's workspace bound needs no hypothesis about F at all: only the run's width.
Semantic closure #
The graded application, semantics and price together ([Decoupling] §4.5). On a run whose
configurations never exceed W bits, applying an element of [A ⇒ B]_g to a named argument both
finishes with a genuine realizer of the applied value and is carried out by a single evaluator
within F of the wider of W and the grade-derived budget.
The width hypothesis is stated over all step counts rather than up to a fixed one because the step
count at which the application finishes is produced by the run, not chosen in advance; it remains
satisfiable for exactly that reason (exists_width_bound).
The grade meets the capacity filtration #
An assembly is modest when no code names two different elements. This is the direction an assembly need not have — an element may still own many realizers — and it holds automatically whenever the elements are named by an injective encoding.
Equations
Instances For
A grade caps the exponential's element count. The graded exponential fits in exactly its
grade: an element is determined by any realizer it owns — application in the algebra is
single-valued, and a modest codomain names unambiguously — so the carrier injects into the codes of
grade at most g, of which there are at most 2 ^ g.
Set beside the non-closure theorems, this is what the grading is for. No capacity is closed under the ungraded exponential, in element count or in realizer length; a graded exponential is a capacity object again, with the grade as its budget. What is bought is not closure — the morphisms priced out are genuinely absent — but a filtration whose every level fits.