The orbit collector collector cR — discharging Prop 2.2's modeled premise #
Provenance: [SQ] §2.2 / Prop 2.2 (~lines 107–119), the FV-AC row.
Extends CodeLayer/AdditiveComplexity.lean (E, elen, KE, KE_t, E_len_comp) and
CodeLayer/BinaryConstant.lean (bconst, eval_bconst, elen_bconst_le, prop_2_2_core).
Status: PROVED (eval level). Target B (an explicit evaln budget) is a documented WALL; Target C
(H_T) is a declared model boundary. See the boundary note below.
What this replaces #
prop_2_2_core (in BinaryConstant.lean) took the collector coll : Code as an ARBITRARY code and
ASSUMED the assembly halts on some output y
(h : y ∈ evaln T (comp coll (comp cR (bconst n))) 0). That is the "modeled premise". This file
CONSTRUCTS a genuine collector and PROVES the assembly computes the orbit prefix, so the premise is
discharged at the eval level.
The construction — a fixed iterator template with the rule plugged in #
A rule-INDEPENDENT collector receiving cR(n) cannot re-run cR (first-order Code, no
internalized universal evaluator). So the collector is a fixed template
collector · := prec zero (stepWrap ·) applied to the rule code cR — the rule appears as the
subterm comp cR projState inside stepWrap. This is faithful:
elen (collector cR) = elen cR + 60 (a fixed constant plus the rule), so the assembled length is
still elen cR + O(log n) = r + O(log n).
I/O convention (fixed here; consumed by prop_2_2_eval) #
- Step map:
rs : ℕ → ℕ(state ↦ next state), computed bycR(hcR : ∀ x, eval cR x = some (rs x); the rule is a total deterministic step, as in Prop 2.2). - Initial condition
x₀ = 0(absorbed into the fixedO(1)collector — the paper puts the IC in theH_Tresidual). - Orbit:
o_t := rs^[t] 0(certified byorbitAcc_fst). - Accumulator / encoded prefix:
orbitAcc rs n : ℕ, defined by the same recursion the code runs:orbitAcc rs 0 = 0andorbitAcc rs (k+1) = pair (rs sₖ) (pair encₖ sₖ)wheresₖ = (orbitAcc rs k).unpair.1(current state) andencₖ = (orbitAcc rs k).unpair.2(prefix). SoorbitAcc rs n = Nat.pair (o_n) ⟨encoded o_0 … o_{n-1}⟩— a singleℕencoding the length-norbit prefix. This is Prop 2.2'so_{1:n}object. - Assembly:
assembly cR n := comp (collector cR) (pair zero (bconst n)). On input0:bconst n → n,pair zero (bconst n) → Nat.pair 0 n,collector cRiterates →orbitAcc rs n.
Boundaries #
- Target B (explicit
evalnbudget) — WALL.evaln's single budgetkguardsn ≤ kat every node (andevaln_boundforces every intermediate value≤ k), so any budget for the iterator is at least its largest intermediate valueorbitAcc rs n— super-exponential inn, NOT polynomial.evaln'skis fuel-with-a-value-ceiling, not the paper's TIME budgetT. Honest fallback shipped:prop_2_2_t_exists(∃ SOME budget, viaevaln_complete). See the module note on the documented wall. - Target C (
H_T) — model boundary.H_T = E_X[log 1/P*(X)]lives on a probabilistic-program semantics (argmin overP_T, expected log-loss) Mathlib lacks. The deterministic-regime rendering (per-step log-loss= 0) is0 = 0— no content; thelog|O|initial residual needs the probabilistic layer. Declared a boundary, consistent withS_Titself being imported.
Length law for prec #
The additive length law for prec (identical shape to E_len_comp/E_len_pair).
The orbit accumulator (Lean-level) and its orbit certification #
The encoded orbit prefix: a single ℕ built by the same recursion the collector code runs.
orbitAcc rs n = Nat.pair (current state) (encoded prefix o_0 … o_{n-1}).
Equations
- One or more equations did not get rendered due to their size.
- ReflectiveSubsystems.orbitAcc rs 0 = 0
Instances For
Orbit certification: the current-state component after n steps is exactly rs^[n] 0 — so the
collected stream genuinely is the rule's orbit o_t = rs^[t] x₀ with x₀ = 0.
The collector code #
Extract the recursion accumulator from a prec-step input Nat.pair a (Nat.pair y m): two
right unpairings give m.
Instances For
The current-state projection: left of the accumulator.
Instances For
The prefix projection: right of the accumulator.
Instances For
Eval correctness #
Eval correctness of the full assembly: on input 0 it computes the orbit prefix
orbitAcc rs n — the collector premise DISCHARGED.
Length accounting #
The collector's length is a fixed O(1) plus the rule —
elen (collector cR) = elen cR + 60. So the collector contributes only a constant to the assembled
program length.
The assembled program's length: elen cR + elen (bconst n) + 69.
Prop 2.2 core, DISCHARGED at the eval level #
Prop 2.2 |P|-component, collector premise DISCHARGED (eval level). For a rule cR
computing a total step map rs, the length-n orbit prefix orbitAcc rs n has additive complexity
KE ≤ elen cR + κ·Nat.size n + (84 + elen dbl) with κ = 15 + elen dbl — i.e. r + O(log n), with
the collector CONSTRUCTED (not modeled). The witness is assembly cR n; its length is additive by
elen_assembly, and elen (bconst n) = O(Nat.size n) by elen_bconst_le.
Target B — the honest ∃-budget fallback (explicit budget is walled; see the module note) #
Prop 2.2 |P|-component, time-bounded form (∃-budget fallback). There EXISTS a step budget
T under which KE_t T (orbitAcc rs n) ≤ elen cR + κ·Nat.size n + (84 + elen dbl). The budget is
existential (via evaln_complete), NOT an explicit polynomial in n: evaln's k caps
intermediate values, so any explicit budget for this iterator is ≥ orbitAcc rs n
(super-exponential in n). The explicit-polynomial budget is a documented wall (module note),
mirroring KE_t_eventually.
The native-cost LINEAR bound, discharged for the collector #
prop_2_2_t_exists above ships an EXISTENTIAL evaln budget because evaln's fuel caps
intermediate VALUES (evaln_bound), so no explicit polynomial budget exists for this value-growing
iterator. The native step count TimeCost.tc (see CodeLayer/TimeCost.lean) instead charges each
prec/comp unfolding O(1) regardless of value magnitude, so it DOES admit an explicit linear
bound. The projection/stepWrap cost lemmas below feed the generic TimeCost.tc_prec_le engine.
One collector step costs a fixed 18 plus one call to the rule cR. The 18 is the
proj/pair/comp overhead of stepWrap; the only value-dependent term is tc cR (val projState x),
which a uniform per-call bound caps WITHOUT reference to the magnitude of val projState x.
Prop 2.2 |P|-component, native-time LINEAR bound — DISCHARGED for the
collector. For a rule cR whose per-call native cost is ≤ K uniformly (hK), the collector's
native sequential-time cost on Nat.pair a n is ≤ (K + 19)·n + 19 — LINEAR in the number of orbit
steps n, with the explicit fixed constant C = 19 (the stepWrap proj/pair/comp overhead). The
bound is MAGNITUDE-INDEPENDENT: it never mentions the accumulator values rs^[i] 0 — which grow
super-exponentially and are exactly what forced the evaln value-cap wall behind
prop_2_2_t_exists — because each step's rule call is capped by the uniform hK, not by the value
threaded through it. This is the wall discharged: TimeCost.tc charges O(1) per prec/comp
unfolding regardless of value size (value-agreement TimeCost.eval_eq_val certifies the value
carries no cap). hcR (the rule genuinely computes the total step map rs) is unused in the bound;
it certifies collector cR is the honest orbit collector of eval_collector, keeping the statement
parallel to prop_2_2_t_exists.