The Replay kernel is the foundational building block of dafny-replay. It maintains aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/metareflection/dafny-replay/llms.txt
Use this file to discover all available pages before exploring further.
History = { past, present, future } data structure and provides Do, Undo, Redo, Preview, and CommitFrom operations. The kernel proves once — for any plugged-in domain — that every operation preserves the domain invariant on the present state and on every state stored in the history.
Module hierarchy
The architecture flows from specification down to the React-facing API:The History data structure
past— sequence of states before the current one (oldest first)present— the live state shown to the userfuture— states available for redo (cleared onDo)
HistInv requires that every state in past, present, and future individually satisfies the domain invariant Inv:
Domain obligations
To use the Replay kernel, a concrete domain must discharge exactly two lemmas:R1 — Initial state satisfies the invariant
R1 — Initial state satisfies the invariant
Init() must satisfy Inv. This seeds the induction.R2 — Transitions preserve the invariant
R2 — Transitions preserve the invariant
Apply followed by Normalize must produce a model that still satisfies Inv. Normalize gives the domain a hook to canonicalize state (e.g., sort IDs, trim tombstones) before storage.Kernel API
All operations in the kernel are pure functions — they take aHistory and return a new History.
Do
present onto past, computes the new state, and clears future. A new action always discards the redo branch (linear undo semantics).
Undo
present to the front of future, then pops the last element of past into present. No-ops if past is empty.
Redo
present to the end of past, then advances to the first element of future.
Preview
a to present without recording the current state to past. Useful for live preview during drag operations; the history branches are left intact.
CommitFrom
baseline (the state at the start of a drag) into past and commits the current present. Pair with Preview to implement drag-and-drop undo: preview during the drag, commit when the user releases.
Kernel theorems
These properties are proved once in the generic kernel assuming R1 and R2:RK1 — All reachable states satisfy Inv
RK1 — All reachable states satisfy Inv
For all reachable histories
h (starting from InitHistory() and applying any sequence of Do, Undo, Redo, Preview, or CommitFrom), D.Inv(h.present) holds.RK2 — Round-trip and boundary properties
RK2 — Round-trip and boundary properties
The kernel also proves structural correctness of the history:
Integration boundary (trusted)
The kernel proofs cover the Dafny transition logic. The following are not modeled or proved:- JavaScript runtime and Dafny → JS compilation correctness
- UI wiring, rendering, and React re-render semantics
- Persistence, serialization, and I/O
Verified transition logic may run inside larger unverified systems. The guarantees apply to the Dafny-generated logic itself, not the surrounding infrastructure.
Related pages
Authority kernel
Extend replay to client-server with server-authoritative state.
Domain obligations guide
Step-by-step walkthrough of writing R1 and R2 for your domain.
Kanban app
Replay kernel applied to a realistic drag-and-drop board with WIP limits.
Guarantees reference
Precise statement of what is proved, assumed, and trusted.