Definition
A forward simulation is a relation between implementation states and specification states that proves, step by step, that an implementation keeps to its specification: starting from related initial states, every implementation step is matched by zero or more specification steps that show the same observable events, the events visible outside the system, and end in a state related to the new implementation state. Observable refinement is the property proved: the specification allows every sequence of observable events that the implementation can produce.
Where it fits
Main entry: Refinement (§3.32).
The Refinement entry gives the full method. Forward names the direction of the proof: it follows an implementation run from its start, one step at a time, and builds beside it a specification run with the same observable events. The opposite direction, a backward simulation, works back from the end of a run; it can succeed where no forward simulation exists, which happens when the specification commits to a choice earlier than the implementation does. Observable names what is compared. Whoever states the claim chooses the observable events, such as the values that reads return; all other steps are silent, and a different choice states a different claim.
A silent implementation step may be matched by zero specification steps: the implementation state changes while the related specification state stays the same. Such a step is called a stuttering step. Stuttering lets many concrete steps, steps of the implementation, correspond to one abstract step, a step of the specification: all of them but one stutter, and the remaining one, the commit step, is matched by the abstract step.
Example. The specification holds one setting, , and its step replaces it by at once. The implementation keeps the setting in persistent storage, which keeps its content without power, in two slots and a 4-byte selector that names the slot in use; slot 0 holds , and the selector holds 0. Writes 1 to 3 put the 12 bytes of into slot 1, 4 bytes at a time, and write 4 sets the selector to 1. The abstraction function, which maps each implementation state to the specification state it represents, returns the content of the slot that the selector names. It returns after writes 1 to 3, which therefore stutter, and after write 4, which is matched by . Four concrete writes correspond to one abstract step.
A reset, the loss and return of power, is a step of both descriptions and must be matched too. After a reset that follows write 2, the selector still names slot 0 and the device reads , which the specification allows, since its update has not happened yet. This relies on two facts that the fault model §1.30 must state: the writes reach storage in program order, and a reset during write 4 cannot cause a torn write §8.19 of the selector, a write cut off partway that leaves it neither 0 nor 1. An observer who reads slot 1 directly sees writes 1 to 3, which match no specification event, so the claim holds only for the chosen observable events.
The simulation proves a safety property §1.11: nothing forbidden is ever shown. An implementation that rewrites slot 1 forever also passes, so proving that the update finishes needs a measure that falls with each stuttering step and cannot fall forever, such as the number of writes left.
Questions answered
Can one abstract step correspond to many concrete writes?
Yes. One step of the specification, the abstract description, can correspond to many writes of the implementation, the concrete description, when every write but one changes nothing an observer can see and the remaining one, the commit write, makes the whole change visible at once. In a forward simulation, the step-by-step proof that the implementation keeps to the specification, the earlier writes are matched by no specification step and the commit write by the one abstract step.
This needs three conditions: a reset during the commit write leaves the old value or the new one; a reset after any earlier write leads to a state the specification allows, normally the old value; and no observable event reveals the intermediate states, such as raw reads of half-written storage. Proving that the change completes also needs a bound on the number of writes before the commit write.
Related entries: Linearization point (§8.6), Compiler correctness (§3.40), Crash consistency (§8.4), Commit record and selector (§8.21).