Documentation

ReflectiveSubsystems.CapacityBoundedEval

Capacity-bounded evaluation: the workspace bound laws for composition and pairing #

Provenance: [Decoupling] §4.5 — the capacity-bounded evaluation lemma named there as the single load-bearing step of Conjecture 4.4 (a general representation functor).

Which half of the crux this is #

[Decoupling] §4.5 states the crux as two clauses: the universal evaluator's application combinator runs within the work memory {0,1}^{|s_work|}, and a capacity-respecting simulation transports that realizer without overflowing the budget. This file supplies the first clause only — the evaluator-side half: bound laws saying that a composite computation whose parts each fit a workspace grade S itself fits a workspace grade computed from S. The transport clause quantifies over simulation morphisms between decoupled learners, and no such morphism is defined in this development; that half waits on that definition and is not discharged here. The crux is therefore half discharged, not closed.

The family #

The workspace measure is TimeCost.spaceCost (total on the rfind'-free fragment) together with its extension spaceCostP (total over all of Nat.Partrec.Code). Its bound laws form one family, one member per constructor:

The two composite laws need a fact the recursion and search laws did not: that a subcomputation's output is no wider than the workspace it ran in. comp feeds one part's output to the other and pair holds both outputs at once, so bounding a composite by its parts' grades is impossible without it. That is the keystone size_val_le_spaceCost, with its unrestricted sibling size_valW_le on all of Nat.Partrec.Code; both are proved first.

The keystone genuinely needs the RfindFree hypothesis: spaceCost leaves rfind' a placeholder 0, which no output bit-length bounds. The workspace evaluator evalW charges the search honestly — the answer it forms is inside its max — so size_valW_le is unconditional.

The grade arithmetic #

Reading S as a capacity grade, the laws compute the grade of a composite from the grades of its parts: composition is graded by max S S' and pairing by 2 * S, the factor 2 being the price of Cantor square pairing (CodeSizeArith.size_pair_le_max, where the constant is attained). Grade closure is then immediate where the two grades agree: a realizer within grade S fed a value produced within grade S runs within the S-bit workspace (spaceCost_comp_within) — the "runs within {0,1}^{|s_work|}" shape §4.5 asks for, with no growth across composition.

No grade predicate and no graded representation is introduced here: these are flat bound laws about spaceCost. Packaging grades into a structure belongs with the graded category itself, and is deliberately not taken on here.

Boundary: the application combinator itself #

Realizability.universal_evaluator — the code realizing the exponential's evaluation morphism [A ⇒ B] × A ⟶ B — is produced by Nat.Partrec.Code.exists_code from a partial recursive function that decodes its first argument (Denumerable.ofNat Code) and hands it to Code.eval_part. It is an existence witness with no exposed constructor skeleton, so the laws below cannot be instantiated at it: they price comp/pair/prec/rfind' structure, and this code has none that the existence theorem reveals. Bounding the application combinator itself therefore needs a structurally presented universal evaluator carrying its own workspace account — a separate construction, not a corollary of this family.

The keystone: an output is no wider than the workspace that produced it #

Outputs stay within grade. The value a code computes never has more bits than the workspace charged for computing it. Every clause of spaceCost accounts for the value formed at that node — a base node maxes its input with its output, pair maxes in the bit-length of the pair it forms, comp and bounded recursion inherit the account of the node that produced the result — so the bound is structural, one case per constructor.

The RfindFree hypothesis is essential rather than incidental: spaceCost prices rfind' as the placeholder 0, and no output bit-length is bounded by 0. The unrestricted statement is size_valW_le, over the workspace evaluator that does charge the search.

theorem ReflectiveSubsystems.size_valW_le (c : Nat.Partrec.Code) (n : ℕ) (p : ℕ × ℕ) :
p ∈ evalW c n → p.1.size ≤ p.2

Outputs stay within grade, on all of Nat.Partrec.Code. The keystone without the RfindFree restriction, stated over the workspace evaluator: whenever evalW returns a value and a workspace, the value fits in that workspace. The rfind' case goes through precisely because the search's account maxes in the bit-length of the answer it forms, exactly as pair does.

The composite bound laws #

theorem ReflectiveSubsystems.spaceCost_comp_le {f g : Nat.Partrec.Code} {n S S' : ℕ} (hg : TimeCost.RfindFree g) (hgn : TimeCost.spaceCost g n ≤ S) (hf : ∀ (v : ℕ), v.size ≤ S → TimeCost.spaceCost f v ≤ S') :

The composition law. If g runs within S on n, and f runs within S' on every value of at most S bits, then comp f g runs within max S S' on n.

The keystone is what makes the second hypothesis usable: f is applied to the value g produced, and size_val_le_spaceCost is exactly the guarantee that this value is one of those f was assumed to handle. Without it the hypothesis on f would have to be uniform over all inputs, which no space measure can satisfy (a leaf node holds its input).

The pairing law. If both components run within S on n, then pair f g runs within 2 * S. The factor 2 is not slack in the argument but the price of the packing: Nat.pair is Cantor square pairing, whose result can be twice as wide as its wider component (CodeSizeArith.size_pair_le_max, with the constant attained at Nat.pair 1 0). The two sub-workspaces themselves contribute only S; the doubling is entirely the cost of holding the pair.

Grade closure — the "runs within the workspace" shape #

Capacity-bounded evaluation, evaluator side ([Decoupling] §4.5). Grade closure for composition: if g runs within the S-bit workspace, and f runs within the S-bit workspace on every value of at most S bits, then the composite runs within the S-bit workspace — the grade does not grow. This is the {0,1}^{|s_work|} clause of Conjecture 4.4's crux at the concrete carrier: evaluation of a realizer within capacity, on data within capacity, stays within capacity.

Immediate from spaceCost_comp_le at S' = S, the composite grade max S S' collapsing to S. The transport clause of the crux — that a capacity-respecting simulation carries realizers across without overflowing the budget — is a statement about simulation morphisms, which this development does not define; it is not established here.