A Characterization of Weakest Preconditions