Definition
Strongest Postcondition
The strongest postcondition (SP), denoted as , is the most specific (most restrictive) formula such that the Hoare triple is partially correct.
Formal Semantics
In terms of the set of states , the SP represents the image of the set of states satisfying under the execution of :
Correctness Relation
A specification is partially correct if and only if the strongest postcondition implies the desired postcondition :
Base Cases
For the empty program, the strongest postcondition is simply the precondition:
Similarly to the wlp, the strongest postcondition can be used to define the axiomatic semantics of a programming language for partial correctness.
Examples
Example: Swapping Values
Let be two conditions with:
Show that following Hoare triple is partially correct:
Info
is partially correct if .
Further, we can show that the computed postcondition implies :