Symbolic execution of structured pointer-machine programs #
Correctness proofs of structured programs follow the program text. WP c x Q is the
weakest-precondition form of ExecWithin (Cslib.Program.WP at the pointer machine), and the
tactic pm_exec runs its rules: it executes data instructions and conditionals on a symbolic
state and stops at loops and subprograms, which continue with WP.loopUntil, WP.loop and
WP.call.
Two kinds of facts never need stating in a specification, because they are read off the program
text and decided by pm_frame:
Code.ptrDests c,Code.dataDests c: the registers that the instructions ofcassign; executions keep every other register (ExecWithin.ptr_keep,ExecWithin.data_keep);Code.KeepsHeap c: no instruction ofcstores or creates, so executions keep all records (ExecWithin.heap_eq);Code.KeepsSize c,Code.fieldDests c: no instruction creates a record, and the data fields that instructions store into; executions keep the number of records and every other data field (ExecWithin.length_eq,ExecWithin.field_keep).
For a small program with a fixed text, pm_frame evaluates these. For a large one, or one whose
text depends on a parameter, they follow by simp from the frames of its subprograms
(Code.dataDests_seq and the like).
Main definitions #
WP: weakest preconditions for the pointer machine.Code.ptrDests,Code.dataDests,Code.KeepsHeap: frames read off the program text.
Tactics #
pm_exec,pm_exec [lemmas](scoped): on a goalWP c x Q, executes the data instructions and conditionals ofc. The state reached is kept in assignment form by the simp setpm_simpsand the given lemmas, which typically say which record a register specifies. A program given by name is a stop, where its specification applies (WP.call), unless its name is among the lemmas. A conditional takes the alternative that the simplified test decides, and otherwise splits.pm_frame(scoped): decides a frame condition,c.ptrDests ⊆ ws,c.dataDests ⊆ wsorc.KeepsHeap, from the program text.
Data instructions as assignments #
Frames read off the program text #
The data field a data instruction stores into, if any.
The data fields that the instructions of the program store into.
Frames of composite programs #
The frames of a program are those of its parts, so a large program, or one whose text is not
fixed, such as a store per field of a record, gets its frames by simp from lemmas about its
subprograms instead of by evaluating its whole text.
Executions keep the pointer registers outside any list containing those the program assigns.
Executions keep the data registers outside any list containing those the program assigns.
Executions of a program that creates no record keep every data field it does not store into, at every address.
Tactics #
pm_exec executes the data instructions and conditionals of the program in a goal
WP c x Q, keeping the state reached in assignment form with the simp set pm_simps and the
given lemmas. It stops at loops and at programs given by name, unless the name is among the
given lemmas, in which case the program is unfolded and executed; at the end of the program it
leaves the postcondition. A conditional takes the alternative that the simplified test decides,
and otherwise splits into both, with the test or its negation as hypothesis ht.