Skip to content

WordRAM: symbolic execution of straight-line structured code (proof automation) #2182

Open

Description

@SamuelSchlesinger

Opened by coordinator-claude-015dlg8k (Claude Code, Opus), working on tech debt for Samuel.

Problem

WordRAM correctness proofs are hand-stepped. On main at 73d32b3c0, scripts/proof_lengths.py counts 81,731 proof-body lines under WordRAM paths, 19% of the library's 431,039. 554 of those proofs are 40 lines or longer, totalling 52,173 lines. The ten longest proofs in the library are all of this kind: FibonacciHeap/Cut.lean decreaseKeyCode_exec (849 lines), Consolidate.lean scatterBody_exec (791) and extractMinCode_exec (722), Cut.lean cutNodeCode_raw (698), plus Karger contractLoop_spec (379), van Emde Boas successor_some_spec (356) and others.

A typical proof does three things per instruction:

  1. It states the next intermediate Data by hand, e.g. let x2 := (x1.set s0 …).set s1 ….
  2. It proves one ExecWithin step with simpa only [reg facts] using ExecWithin.store ….
  3. It re-derives register and memory reads through simp only [Data.set_regs, Function.update_of_ne (by decide : r ≠ s0), …].

Invariants such as FibonacciHeap.BaseRegs, a 13-conjunct Prop, are read positionally (hbr.2.2.2.2.2.2.2.2.2.2.2.1). Structured.lean already offers forward rules and an interpreter (Code.eval, Exec.of_eval), but only three files in Algorithms/DataStructure use of_eval.

Definition of done

  • Automation. A tactic or simp set that symbolically executes loop-free structured code with symbolic register contents, producing the final Data and the instruction count. Fits and address side goals are discharged by a configurable discharger, or left as named goals. Register and memory reads after set/write reduce automatically when register names are literals.
  • Tests. The automation has tests on concrete programs, including a failure case with a readable error.
  • Pilot. One heavy module (FibonacciHeap) is migrated, with every public statement unchanged. BaseRegs-style conjunctions become structures with named fields. The PR reports the measured line reduction.
  • Guide. A short note in the WordRAM docs tells authors to use it.

Loops stay on the existing loop_invariant/loop_potential rules. This issue covers only the straight-line glue between them.

Activity

  1. SamuelSchlesinger commented on Nov 1, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Claimed by worker-claude-015dlg8k-wrexec (Claude Code, Opus), worker of coordinator-claude-015dlg8k. Branch claude/wordram-exec-2182. Plan: investigate why the long proofs avoid Code.eval, then an infrastructure+tests PR, then a stacked FibonacciHeap pilot PR (Cut.lean first).

  2. SamuelSchlesinger commented on Nov 1, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    worker-claude-015dlg8k-wrexec (Claude Code, Opus): two PRs are up.

    Still open: Consolidate.lean and BasicOps.lean, and MinPQ's positional AllocRep reads.

  3. SamuelSchlesinger commented on Nov 1, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    coordinator-claude-015dlg8k (Claude Code): direction update. Samuel has chosen the oracle-refinement design in #2205 for WordRAM. wram_exec (#2193) stays as its bottom layer, for verifying primitive memory operations and the realization kernel, and worker-claude-015dlg8k-wrexec2 is finishing its performance pass. #2195 (Cut.lean pilot) can land as an interim improvement. Further code-level migrations of large proofs (Consolidate, BasicOps, Karger, cuckoo) are paused: they will be redone through #2205's hops instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions