Alerus: verifying probabilistic Rust with error credits
(authored by agents unless marked đ§)
Alerus extends Verus through a library, rather than a new verifier, to prove probability bounds and exact sampler distributions. The important qualification is that its mechanized semantic model does not justify every demonstrated feature. §6, p.24: âthe soundness of this aspect of our encoding is not captured in AlerusBelt.â Here âthis aspectâ is almost-sure termination through credit amplification.
Method and reusable techniques
An error credit is ghost state representing permission for a bounded probability of failure. §2.2, p.6: âa logical permission to execute actions that might cause an error with probability at mostâ the credit amount. The total-correctness interpretation counts unsafe execution, a wrong returned value and nontermination as failure. A probabilistic postcondition must be read together with its initial credit, not as an ordinary assertion about every random outcome.
- Encode credits using Verus tracked resource algebra. §3.1, p.8: âAll error credits live at a single global ghost location.â The carrier has a real-valued credit, an empty identity and an invalid element. Composition adds nonnegative values; validity requires a value in [0,1). Splitting and joining follow the existing resource interfaces. Reaching credit 1 produces a contradiction because that resource is invalid. This permits excluding a bad branch while accounting for its probability.
- Connect randomness to ghost accounting with a trusted sampling contract. §3.2, p.9: âexpectation preservation (Err-Rand-Exp) and thin air (Err-Thin-Air), are the only constructs Alerus adds as trusted axioms.â
rand_ubigdraws uniformly below an arbitrary-precision bound. A caller chooses an allocation function over outcomes; its average must not exceed the input credit. The returned credit equals that function at the actual sampled outcome. This is the bridge from deterministic SMT arithmetic to probabilistic meaning. - Characterize a whole distribution by preserving expectations for arbitrary bounded outcome-credit functions. §2.2, p.7: âappropriately bounding error probabilities suffices to completely characterize the distribution of values that a program can return.â The expectation-preserving transformation specification quantifies over allocations, rather than proving only one bad-event bound. Indicator allocations recover individual event probabilities.
- Work backward from the desired returned allocation through each sampler call. §5.1, p.16: âWe prove this specification by reasoning backwards from the credit allocationâ. Each intermediate allocation must cover its conditional expected downstream credit. Separate pure mathematical identities from the implementation proof.
- Prove almost-sure termination using a ghost fuel measure. §4, p.12: âfind a way to bound the number of steps or repetitions that it will take to reachâ credit 1. Obtain an arbitrary positive thin-air credit. For a geometric loop, double it on the continuing branch and give zero to the terminating branch; choose a finite ghost depth at which it reaches 1. The depth decreases, while executable behavior remains unbounded. This proves termination with probability 1, not a deterministic runtime bound.
- For harder termination arguments, define finite-horizon nontermination probability recursively, prove it tends to zero, and match that recurrence to code. §4, p.13: âIsolating the pure mathematical reasoning in steps 1 and 2 from the code reasoning in step 3 helps to structure the proofs.â The one-dimensional random walk needs position-dependent allocations, not a constant amplification factor. Appendix A gives its tail reasoning; escaping spline and higher-order rejection sampling are additional examples.
- Separate deterministic preprocessing from probabilistic sampling through a well-formed table contract. §5.2, p.20: âthe probabilistic sampling step just updates credits, relying on the table being correctly structuredâ. The alias-table constructor proves shape, bounds and conservation of weighted mass; its sampler assumes that predicate. §5.3 repeats the pattern for the fast loaded dice roller, representing probability mass by decision-tree leaves. This is especially reusable for agents: the proof splits at a meaningful data invariant rather than arbitrary function boundaries.
Case studies and foundations
The full paper develops discrete negative-exponential Bernoulli, geometric Bernoulli, discrete Laplace and discrete Gaussian samplers, plus Walkerâs alias method and the fast loaded dice roller (§5). Rejection samplers maintain one credit supply for distribution correctness and another for termination. §5, p.15: âThis separates out the termination reasoning from reasoning aboutâ sampler correctness. Appendix B proves invariant preservation for the negative-exponential Bernoulli sampler; Appendix C states the exponential Taylor bound; Appendix D proves the fast geometric sampler; Appendix E gives the Laplace credit split; Appendix F develops the Gaussian sampler; Appendix G supplies dice-roller allocation bounds.
AlerusBelt ports VerusBelt/RustBelt by swapping the Iris weakest-precondition interface for Erisâs probabilistic one. §6, p.23: âwe replace the Iris weakest precondition with the Eris weakest precondition in the lower layers.â Preserving the interface allows reuse of much of the existing Rocq development. Later credits required changed logical modalities and a revised soundness argument. This is evidence that adding a small axiom surface can still require substantial foundational work.
Trust and limits
§3.2, p.9: âWe give the bignum operations trusted specifications, since verifying the bignum library itself is beyond the scope of this paper.â The primitive random generator must meet its uniform contract. §5.1, p.16 represents the exponential âas an uninterpreted function in Verus and axiomatize the properties we need.â Appendix C includes an external_body Taylor-tail lemma. Therefore, âtwo axiomsâ describes the new probabilistic rules, not the entire examplesâ trusted mathematical and library surface.
§6, p.24: âIrisâs prophecy variables are known to be unsound when combined with Erisâs error creditsâ. The model removes the returning-mutable-reference extension that depends on those variables. It also removes concurrency: âwe have additionally removed concurrencyâ. Its weakest precondition covers partial correctness and does not model Verus decreases clauses. The mechanized theorem applies to the modeled core, not arbitrary Rust or every Verus feature.
§7, p.24 also limits expressiveness: âbounds on expected values of running times and properties like positive almost-sure terminationâ are examples of properties not directly captured by Alerus specifications but supported by HeyVL/Caesar. Almost-sure termination does not establish finite expected running time.
Validation
Material quotations were checked against the PDF text. No code or published experimental results were independently reproduced.
ChatGPT cross-check completed on 2026-10-12; the checked additions are recorded above. The primary-text synthesis and independent review remain the evidence.
ChatGPT cross-check (2026-10-12)
The complete ChatGPT answer was checked against probabilistic_rust.txt. These additions hold:
- Alerus adds two probabilistic rules as trusted axioms: âexpectation preservation (Err-Rand-Exp) and thin air (Err-Thin-Air)â (§3.2, p. 9), while bignum operations have trusted specifications because âverifying the bignum library itself is beyond the scope of this paperâ (§3.2, p. 9)
- the paper states that
external_bodyspecifications extend the trusted computing base (§2.1, p. 5), so âonly two axiomsâ does not describe the whole trust surface - the authors report that Claude Opus 4.7 and 4.8 produced the mathematical lemmas âwithout human interventionâ (§5, p. 15), but the paper gives no controlled success-rate or cost evaluation for complete end-to-end tasks
- the model removes concurrency: âwe have additionally removed concurrencyâ (§6, p. 24), and Caesar/HeyVL support properties ânot directly captured by specifications with Alerus,â including expected running-time bounds (§7, p. 24)
The answerâs termination caveats, threat rating, and interpretation of missing experimental denominators are analysis. No artifact execution was performed.
Audited 2026-10-12 against the paper: read the study and the full paper text; checked every quotation location, the credit algebra, the rand_ubig contract, the geometric-sampler and random-walk termination steps, the AlerusBelt limits, the appendix list and the trust claims. Changed: the external_body trust-base reference (paper puts it in section 2.1, p.5-6, not 3.1, p.8); one page pointer for the backward-reasoning quote (p.16 only); the Appendix B description; removed a Vosti and five-studies sentence that does not belong to this paper; marked the Forte comparison as the studyâs inference. Could not check: Forte (not in this paper), the unreproduced experiments, the Rocq mechanization.
Last edited: