Memory facts across calls #
A proof about a word-RAM program carries memory invariants and cell values across calls: each
subprogram specification gives a result state y together with either a whole-memory equation
y.mem = x.mem, a frame ∀ a, P₁ a → … → y.mem a = x.mem a, a Set.EqOn y.mem x.mem R, a
Modifies writes x.mem y.mem, or a store-free execution Exec w c x y n / ExecWithin w c x y T.
Writing frame chains by hand repeats arithmetic disjointness proofs (by wram_omega) and manual
.trans pipelines across intermediate states.
This file provides Code.StoreFree (kernel-decidable store-freeness giving Exec.mem_eq and
ExecWithin.mem_eq) and mem_frame, the memory-framing twin of regs_frame
(CslibFrontier/Computability/WordRAM/SymbolicExec/Frame.lean).
Main definitions #
Cslib.WordRAM.Op.StoreFree,Cslib.WordRAM.Code.StoreFree: decidable predicates stating that an instruction or structured program contains noOp.store.mem_frame: the tactic proving whole-memory equationsz.mem = x.mem, pointwise readsz.mem a = v/z.mem a = x.mem a, quantified frames∀ a, P a → z.mem a = x.mem a,Set.EqOn,Modifies, conjunctions, andProp-valued structures (plus user-selected unfoldedPropdefinitions viamem_frame [TableRep, ...]).
Main results #
Cslib.WordRAM.Exec.mem_eq,Cslib.WordRAM.ExecWithin.mem_eq: executions of store-free programs preserve memory identically.Cslib.WordRAM.Op.storeFree_rename,Cslib.WordRAM.Code.storeFree_rename: register renaming preserves store-freeness.
Store-free programs #
Reading the word width over Basis.exact is store-free.
A renamed store-free program is store-free.
Decompose a goal through And, Prop-valued structures, and user-selected unfoldDefs
Prop definitions, plus Modifies / Set.EqOn / universal quantifiers.
Try to close a single atomic subgoal g. Returns none on success or some (orig, left)
plus stuck entries for diagnostics.
Attempt to close g with mem_frame, restoring the state and returning false on failure.
mem_frame proves a fact about memory after a sequence of stores or calls from the frames
among the hypotheses:
- an exact memory equality
z.mem = x.mem(ory.mem = m); - a single cell read
z.mem a = v,z.mem a = x.mem a, orz.mem a = ?v(inferring?v); - a quantified frame
∀ a, P₁ a → … → z.mem a = x.mem a,Set.EqOn z.mem x.mem R, orModifies F x.mem z.mem; - an indexed slice equality
∀ i, P i → z.mem (base + i) = f i; - a conjunction or
Prop-valued structure of any of the above (splitting fields recursively).
Optional hints mem_frame [h₁, h₂, DefName] supply either extra fact terms / polymorphic frame
lemmas (such as insertMem_of_outside) or def names to unfold when splitting goals and
hypotheses (such as TableRep or restoreAfterHashInitData).
It follows each memory map or read back through:
- whole-memory equations
h : y.mem = x.memand state equationsh : y = x; - store-free execution hypotheses
he : Exec w c x y n/ExecWithin w c x y T(or anyJwith aJ.mem_eqlemma), decidingCode.StoreFree cin the kernel whencis closed and structurally whenccontains parameters; - pointwise frames
∀ a, P a → y.mem a = x.mem a,Set.EqOn, andModifies; Data.set,Data.comap,Data.extend,Data.havoc,Data.write,Function.update, andlet-bound states;- concrete cell values
h : x.mem a = vand indexed slice equations∀ i, P i → x.mem (base + i) = f i.
Frame premises (a ≠ b, a < base ∨ base + n ≤ a, a ∉ b.footprint, a ∉ Finset.Ico l u,
a ∈ Set.Ico l u, …) are discharged by closed evaluation, hypotheses, omega, and silent
@[wram_arith] unfolding without triggering linter.unnecessaryWramOmega.