Successful patch replay is undone in reverse order
complete
Independent generic proof by induction on the operation list. Failure is absorbing. For a successful head operation, apply the induction hypothesis to the remaining replay and then the explicit per-operation inverse obligation. Reverse-list append and fold composition put the head's inverse last. Locally kernel checked with Hunchroom's pinned Lean core runtime. This does not prove that arbitrary destructive operations admit an undo interpreter.
Lean proof and verification output
by
intro State Op step undo inverse
have failure : ∀ (ops : List Op), ops.foldl (fun prior op => prior.bind (step op)) none = none := by
intro ops
induction ops with
| nil => rfl
| cons op ops ih => simpa only [List.foldl_cons, Option.bind_none] using ih
intro ops
induction ops with
| nil =>
intro s t h
simpa only [List.foldl_nil, List.reverse_nil] using h.symm
| cons op ops ih =>
intro s t h
change ops.foldl (fun prior op => prior.bind (step op)) (step op s) = some t at h
cases first : step op s with
| none =>
rw [first, failure] at h
cases h
| some mid =>
have tail := ih mid t (by simpa only [first] using h)
simp only [List.reverse_cons, List.foldl_append, List.foldl_cons, List.foldl_nil]
rw [tail]
exact inverse op s mid firstPreview only · 0.00 MiB. Download the full file below.
Checked against statement 7eb0403369b4.
Independent checker: not_run. What this means
'_private.0.OA_target' depends on axioms: [propext, Quot.sound] OA_target : OA_statement
Axioms: propext, Quot.sound