Pace is a small experimental companion to CSLib for proving resource bounds for executable programs. The Lean package is pace, with namespace Pace. The first example connects a counted Lean evaluator to Sunstone's production Rust charref::accumulate function.
The v0 scope is deliberately narrow: checked u32 arithmetic, comparisons, short-circuit disjunction, local bindings, conditionals and returns. The claimed resources are operations in this explicit model. They are not elapsed time or machine instructions.
From this checkout:
Install the pinned Lean toolchain once with mise trust .mise.toml and mise install.
Lake fetches the locked Lean dependencies on the first build. An elan installation can
also use lean-toolchain and run the same Lake commands without mise exec --.
mise exec -- lake build
mise exec -- lake test
mise exec -- lake env lean --run Tooling/Demo.lean
python3 tools/sunstone.py --verify
python3 -m unittest discover -s testsThe build checks the Lean definitions and proofs. lake test audits Pace declarations for project postulates and dependencies on admitted proofs or native-evaluation axioms, without linking a native executable. The demo prints results and resource counts for sample inputs. --verify checks stored identities and regenerates the cost AST from stored LLBC without invoking the extraction binaries. The Python tests exercise source drift and unsupported or omitted operations.
For a fresh extraction checked against the current production module:
python3 tools/sunstone.py --check \
--production-source ../bonvoyage/sunstone/kernel/src/charref/mod.rsThis example assumes the pace and Leif checkouts are siblings under Billy-Company. Pass the actual module path when they are elsewhere. The command requires byte equality between production source and the stored module, reruns pinned Charon and Aeneas, and compares their output and the cost program with stored artifacts. A successful Lean build or --verify alone does not establish fresh extraction from current production source.
Python 3.9 or newer and the standard library suffice for the Python checks. Lean is pinned to 4.36.0 through mise and Lake. Fresh extraction also requires the pinned Charon and Aeneas distribution and rustup nightly-2026-09-17 with rustc-dev, llvm-tools, rust-src and miri, as specified by the distribution's rust-toolchain file. Tool versions and binary hashes are recorded in Pilots/Sunstone/Artifacts/pins.json.
The current extraction binary pins target Apple Silicon macOS. Building the stored Lean proof does not require those binaries; regenerating it on another platform needs a separately pinned tool distribution.
Use --tool-dir /path/to/distribution to select extraction binaries explicitly. Otherwise discovery checks PACE_AENEAS_TOOL_DIR, the sibling Leif checkout's pinned tool directory, then co-located charon and aeneas commands on PATH. Discovered tools must still match the pinned versions and hashes. The package does not install these tools automatically.
Sunstone accumulates a numeric HTML character reference with a guard followed by number * radix + digit, capped at OVERFLOW. Inputs that already exceed the cap, or have an unsupported radix or digit, return early.
The example uses two generated representations of the same source:
- Pinned Charon LLBC is translated into a small cost AST and evaluated with explicit resource accounting. Extraction uses a staged crate named
sunstone_cost_pilotcontaining the exact whole production character-reference module. - Aeneas translates the LLBC into its checked
Result U32value model.
Lean checks the connection between the counted evaluator's result and the Aeneas value model for every u32 input. The resource contracts bound comparisons by four, additions by one and multiplications by one per call. These are separate coordinates of a resource vector. The evaluator also charges literal evaluation, variable reads, conditional dispatch, bindings and returns in the normalized AST. LLBC copies, storage markers and borrow-check markers are eliminated; these counts do not count every source-level read or machine copy. Include every coordinate when discussing the complete modeled cost.
The complete vector has a proved upper bound of 27 abstract node visits per call.
The end-to-end contract is Pace.Pilots.Sunstone.certified in
Proof.lean.
Rust's OVERFLOW is a compile-time constant. Resolving SCALAR_MAX + 1 while generating the model does not charge a runtime addition. The one runtime addition is the + digit expression on the arithmetic path.
The staged source and extraction artifacts live under Pilots/Sunstone/Source and Pilots/Sunstone/Artifacts. The generated cost program is Pace/Pilots/Sunstone/Program.lean, defining Pace.Pilots.Sunstone.program : Stmt; the Aeneas value extraction lives under Pace/Pilots/Sunstone/Extracted.
See the model and trust boundaries for the precise scope and interpretation.
The stored generated example is a snapshot. Its proof remains a theorem about that snapshot when the production source changes. To claim that it describes a particular production checkout, run the source check against that checkout and keep its provenance with the result.
The fresh check regenerates the representations and compares the relevant artifacts. Source and extraction identities tie the result to concrete inputs; they do not prove the Rust frontend, adapter or compiler correct. Unsupported LLBC constructs must fail closed rather than be skipped. A newly added charged operation that preserves the returned value must still affect the counted AST or cause rejection.
CSLib already provides foundations for cost reasoning. Pace instantiates CSLib's TimeM with operation-count vectors. It adds a restricted execution model, an adapter from real extracted code and a proof relating that model to a separate value extraction. It complements CSLib rather than introducing a competing general cost monad.
This v0 does not automatically instrument arbitrary Lean or Rust programs. Extending the supported language requires corresponding semantics, adapter handling, proof rules and rejection tests.
A useful claim is: “For this source-linked model and these inputs, execution performs at most four comparisons, one multiplication and one addition.”
A claim such as “this always finishes within one microsecond” needs an additional timing model connecting these resources to a specified compiler, binary, processor and execution environment. A benchmark can provide empirical evidence for that connection. Containers help reproduce software environments; neither a container nor a previous timing measurement supplies the missing universal timing theorem.
The project also does not infer a speedup merely from comparing two upper bounds. A speedup proof needs a relational cost argument or bounds strong enough to compare the two actual modeled executions.
Copyright © 2026 The Billy Company. Apache-2.0.