A minimal program logic
Library · Source module
A minimal program logic
Weakest preconditions by definition, since the run is deterministic: NLAlib.Ops.Wp md I τ s ρ Q m says that the run of s from m satisfies Q, in the mode md. One rule per constructor, each mode-generic; a call is replaced by its contract (NLAlib.Ops.wp_call, and NLAlib.Ops.wp_call_rel in NLAlib.Ops.Rules for the contracts in operand form); a loop needs an invariant (NLAlib.Ops.wp_loop, NLAlib.Ops.wp_whileFuel).
Frame: contracts state the memory after a call as an update of the memory before (NLAlib.Ops.Mem.upd, NLAlib.Ops.Mem.updBlock), so what a call keeps is read off by the store lemmas (NLAlib.Ops.Store.get_upd_of_ne, NLAlib.Ops.Store.get_updBlock_of_buf_ne, NLAlib.Ops.Store.get_append_of_lt for scratch on top), and facts about one run are combined by NLAlib.Ops.Wp.and.
This is the part of the logic the examples need; the full logic sits on the same definitions.
Main results
* NLAlib.Ops.wp_seq, NLAlib.Ops.wp_call, NLAlib.Ops.wp_loop, NLAlib.Ops.wp_alloc, NLAlib.Ops.wp_ite, NLAlib.Ops.wp_bindIdx, NLAlib.Ops.wp_frame: the rules. * NLAlib.Ops.wp_whileFuel: the loop with early exit, with an invariant indexed by the rounds done; the continuation is proved at the round of the exit and at the cap. * NLAlib.Ops.wp_ifZero, NLAlib.Ops.wp_ifPos: branches on a size. * NLAlib.Ops.wp_abort_liberal: in liberal mode a failing run satisfies everything.
Declarations
- NLAlib.Ops.Wp
- NLAlib.Ops.Wp.and
- NLAlib.Ops.Wp.mono
- NLAlib.Ops.holds_iter
- NLAlib.Ops.holds_testAt
- NLAlib.Ops.holds_whileIter
- NLAlib.Ops.run_of_wp
- NLAlib.Ops.wp_abort_liberal
- NLAlib.Ops.wp_alloc
- NLAlib.Ops.wp_bindIdx
- NLAlib.Ops.wp_call
- NLAlib.Ops.wp_frame
- NLAlib.Ops.wp_ifPos
- NLAlib.Ops.wp_ifZero
- NLAlib.Ops.wp_ite
- NLAlib.Ops.wp_liberal_iff
- NLAlib.Ops.wp_loop
- NLAlib.Ops.wp_note_iff
- NLAlib.Ops.wp_of_run
- NLAlib.Ops.wp_seq
- NLAlib.Ops.wp_skip
- NLAlib.Ops.wp_total_iff
- NLAlib.Ops.wp_whileFuel