Shared resources across all native frontend roots #
The outer loop reserves heap and pointer cells for every remaining root. A particular root gets only its own remaining allocation, so its execution theorem cannot consume another root's budget.
Main definitions #
rootArena: the existing traversal arena restricted to one root's actual remaining budget.ForestCursor,ForestCursor.Invariant: exact root index, output and global resource relation.
Main results #
rootArena_ready: the global signed envelope derives each dynamic root envelope.
These native composition invariants are original; the program remains the existing native code.
Restrict a root call to its own heap and pointer-table allowance. All addresses stay fixed.
Instances For
Monotonicity of the existing polynomial envelope derives every root's actual local fit.
Mathematical proof state of the native outer descriptor loop.
- index : ℕ
Number of root descriptors already executed.
- nodes : List (ℕ × ThreeSum.ChanHe.Node)
Actual native pointer and existing-node pairs already emitted.
Instances For
Exact frontend output, native controller registers and all remaining-root reservations.
- bounded : WordRAM.Data.Bounded (w + 2) x
Every actual word fits.
- controls : a.Controls x
The traversal constants remain actual registers.
- frontend : Frontend.Output l U rs x.mem
Every frontend descriptor and compact array is still available.
Actual descriptor base and root count.
Actual root index and shared fuel.
Native descriptor stride and outer increment constant.
The actual index never passes the last descriptor.
Every candidate prime still has its actual bitmap bit.
The heap avoids all shared reservations.
- heapBudget : x.regs Traversal.heap + (l.count - s.index) * (Traversal.Math.work a.fuel * Traversal.allocationSize a.n a.m a.N) ≤ a.ceiling
All unprocessed roots retain their complete allocation budgets.
The native count agrees with the emitted list.
All unprocessed roots retain their complete pointer-table budgets.
Exact native pointer-table and packed-cell readback.
- outputBounds (i : Fin s.nodes.length) : a.floor ≤ s.nodes[↑i].1 ∧ s.nodes[↑i].1 + 4 * a.N ≤ x.regs Traversal.heap
Every earlier packed array is safely below the current fresh allocation.
- exactOutput : List.map Prod.snd s.nodes ++ Traversal.Math.output a.m.primesLE a.Λ (List.map Traversal.Entry.task (List.drop s.index (entries l U rs))) = Traversal.Math.output a.m.primesLE a.Λ (List.map Traversal.Entry.task (entries l U rs))
The emitted prefix and untouched roots give exactly the original finite forest.
Original memory below the shared stack is retained throughout the forest.
Instances For
A live outer iteration has room for the one root it is about to execute.