Timeline editing by reset and replay #
This is the elementary rebuilding transformation motivated by retroactive data structures
Demaine, Iacono, and Langerman. A timeline edit is followed by an explicit reset and
replay of the edited history. It is not an efficient rollback algorithm, and Retroactive.spec
has no query operation, historical or present: every edit returns Unit. The correctness of
Retroactive.implementation therefore says only that each edit issues admissible backend calls
and preserves the representation invariant: the backend stores the edited timeline, and its
ordinary state is that timeline replayed from the initial state. Editing an admissible timeline
can make later operations invalid, so admissibility checks the entire edited history.
Main definitions #
TimelineEdit,TimelineEdit.apply,TimelineEdit.Valid: insertion and deletion by position, with timeline application and range validity.Retroactive.spec: the abstract timeline-editing specification.Retroactive.BackendOp,Retroactive.backend: primitive operations and interface exposing edit, reset, and ordinary operations.Retroactive.replay,Retroactive.methods,Retroactive.implementation: the replay client, method table, and reusable rebuilding module.Retroactive.primitiveCharge: combined resource charge for editing, reset, and ordinary calls.
Main results #
Retroactive.replay_run: replay has exactly the ordinary history's state and operations.Retroactive.operation_charge: costs include editing, reset, and the entire replay.Retroactive.realized_bound: the same bound transports to every backend realization.Retroactive.realized_linear_bound: an ordinary-operation bound gives linear replay overhead.
The edit primitive includes storing the timeline and exposing the edited list to its caller.
A backend must certify this primitive's resource weight; list copying is not assumed constant
time. Like all StateTransitionSpec.Client results, the resource claims count explicit backend
operations and
leave pure Lean controller computation uncharged. There is no fixed Word-RAM compiler here.
References #
An edit position names a gap for insertion and an existing entry for deletion.
- insert {Op : Type} (position : ℕ) (operation : Op) : TimelineEdit Op
- erase {Op : Type} (position : ℕ) : TimelineEdit Op
Edit the operation sequence. Valid excludes out-of-range positions.
Insertion allows the final gap; deletion requires an existing entry.
A dynamic specification of admissible timeline edits.
Primitive operations required by rebuilding; editing returns the entire new timeline.
Return types for BackendOp D.Op.
The rebuilding backend tracks the stored timeline and current ordinary state separately.
Every admissible ordinary history is admissible when executed through the backend.
Rebuilding correctness is independent of the implementation of reset, edit, and execution.
Separate charges for timeline editing, resetting, and ordinary operations.
The full operation charge retains both editing and resetting overhead.
Resource bounds transport to any realization of the backend interface.
This certificate then composes across arbitrary admissible timeline edits via Bound.client.
A uniform ordinary-operation bound gives linear replay overhead. Editing and resetting remain explicit, and the resulting certificate applies to every concrete operation execution.