Draft — mutable and not usable as a dependency; its citation marks the draft state.

A Refinement Framework for the Word RAM

lax-62·formalized by Jan Dreier·Claude Fable 5 (Anthropic)·created 2026-09-02·GitHub @d82625d·Lean v4.30.0 epoch · mathlib c5ea00351c28

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this submission may be incorrect.

No flags have been submitted.

    Community review

    Flag this submission

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    Abstract

    This submission is a refinement framework for the word RAM: the machinery through which an algorithm verified against an abstract specification is carried down, one proved step at a time, to a program of the structured while-language of The Word RAM together with a bound on the machine's own step count. Its concept package is empty and it states no theorem, because nothing in it is a claim about a mathematical object. It is theorems and tactics about programs and their costs, consumed by the proof packages of the submissions that state running times, which require this one the way a proof package requires mathlib: their claims stay on their own surfaces, in the fixed shape The Word RAM prescribes — one program quantified before the word length, an explicit bound — and the descent that discharges them is done here once.

    The framework is a port to Lean of the Isabelle refinement stack of Peter Lammich and Maximilian P. L. Haslbeck, kept as close to its sources as the substrate allows, with every departure recorded in the module that makes it. Its layers, from the top down: NREST, Haslbeck and Lammich's nondeterministic result monad with time, whose specifications carry costs in named currencies, with data refinement, time refinement by exchange rates, general recursion, loop and foreach combinators, and the backwards-reasoning verification-condition generator of Refinement with Time and For a Few Dollars More; Autoref, Lammich's automatic data refinement, with its relators, parametricity rules, tagged solvers and four-phase pipeline; an imperative intermediate language over named cells and arrays, given a cost-indexed big-step semantics and a separation logic with credit assertions on the Klein–Kolanski separation algebra, after the isabellellvmtimeisabelle_llvm_time artifact; Sepref, Lammich's synthesis of imperative programs from monadic ones by relational rules, here with the credit-paying rules of the timed stack, frame inference, ownership, a costed allocator with space budgets, and amortized data structures; the interface and implementation collection of Refinement to Imperative/HOL — arrays, dynamic arrays, stacks, queues, heaps, maps, matrices, and a union–find with the time analysis of Charguéraud and Pottier; the one- and two-dimensional asymptotic calculus and the recurrence lemmas of Zhan and Haslbeck's timed Imperative/HOL, so that a bound can also be read in Landau form; and a code generator, this submission's own, that embeds the intermediate language into the while-language and pays every bound down to the machine through The Word RAM's simulation theorem, where the Isabelle stack ends in a trusted printer. The examples in the package — breadth-first search in several forms, array fill, an introsort budget — are acceptance tests and templates for the submissions that state running times.

    Concepts

    No concepts in this submission.

    Proofs

    No proofs in this submission.

    Proof code is not displayed; the archive records each proof's checked relationship between claims.

    Related submissions

    Submission map

    This submissionOther submissionA → B: B's concepts build on AA → B: only B's proofs build on A

    Cite this

    @misc{lax-62,
      author = {Jan Dreier and Claude Fable 5 (Anthropic)},
      title = {A Refinement Framework for the Word RAM},
      year = {2026},
      howpublished = {Lax Archive, lax-62},
      url = {https://laxarchive.org/lax-62/},
      note = {draft},
    }

    References

    1. Peter Lammich and Thomas Tuerk. Applying Data Refinement for Monadic Programs to Hopcroft's Algorithm. In Interactive Theorem Proving (ITP 2012) 7406:166–182, 2012. doi:10.1007/978-3-642-32347-8_13
    2. Peter Lammich. Automatic Data Refinement. In Interactive Theorem Proving (ITP 2013) 7998:84–99, 2013. doi:10.1007/978-3-642-39634-2_9
    3. Peter Lammich. Refinement to Imperative/HOL. In Interactive Theorem Proving (ITP 2015) 9236:253–269, 2015. doi:10.1007/978-3-319-22102-1_17
    4. Peter Lammich. Refinement to Imperative HOL. Journal of Automated Reasoning 62(4):481–503, 2019. doi:10.1007/s10817-017-9437-1
    5. Peter Lammich. Generating Verified LLVM from Isabelle/HOL. In Interactive Theorem Proving (ITP 2019) 141:22:1–22:19, 2019. doi:10.4230/LIPIcs.ITP.2019.22
    6. Maximilian P. L. Haslbeck and Peter Lammich. Refinement with Time – Refining the Run-Time of Algorithms in Isabelle/HOL. In Interactive Theorem Proving (ITP 2019) 141:20:1–20:18, 2019. doi:10.4230/LIPIcs.ITP.2019.20
    7. Maximilian P. L. Haslbeck and Peter Lammich. For a Few Dollars More: Verified Fine-Grained Algorithm Analysis Down to LLVM. In Programming Languages and Systems (ESOP 2021) 12648:292–319, 2021. doi:10.1007/978-3-030-72019-3_11
    8. Maximilian P. L. Haslbeck and Peter Lammich. For a Few Dollars More: Verified Fine-Grained Algorithm Analysis Down to LLVM. ACM Transactions on Programming Languages and Systems 44(3):14:1–14:36, 2022. doi:10.1145/3486169
    9. Maximilian P. L. Haslbeck. Verified Quantitative Analysis of Imperative Algorithms. Technische Universität München, 2021.
    10. Bohua Zhan and Maximilian P. L. Haslbeck. Verifying Asymptotic Time Complexity of Imperative Programs in Isabelle. In Automated Reasoning (IJCAR 2018) 10900:532–548, 2018. doi:10.1007/978-3-319-94205-6_35
    11. Gerwin Klein, Rafal Kolanski and Andrew Boyton. Mechanised Separation Algebra. In Interactive Theorem Proving (ITP 2012) 7406:332–337, 2012. doi:10.1007/978-3-642-32347-8_23
    12. Arthur Charguéraud and François Pottier. Verifying the Correctness and Amortized Complexity of a Union-Find Implementation in Separation Logic with Time Credits. Journal of Automated Reasoning 62(3):331–365, 2019. doi:10.1007/s10817-017-9431-7
    13. Maximilian P. L. Haslbeck and Peter Lammich. isabelle_llvm_time: the ESOP 2021 artifact. r̆lhttps://github.com/lammich/isabelle_llvm_time, commit 42dd7f5, 2021.
    14. Peter Lammich and Maximilian P. L. Haslbeck. AFP entries Refine_Monadic, Automatic_Refinement, Refine_Imperative_HOL and NREST. Archive of Formal Proofs, r̆lhttps://www.isa-afp.org, Isabelle2025-2, 2026.

    Community review

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.

    0 comments

    Loading discussion…