In the classical IMP language, the definition of weakest precondition is:
definition "wp c Q s ≡ ∃t. (c,s) ⇒ t ∧ Q t"
This is stating that from state s, after executing c we get to a state satisfying Q. My question comes when handling the selection construct in the language of guarded commands (see selection command in Wikipedia). My guess is that in this case one needs to define:
definition "wp c Q s ≡ ∃t. (c,s) ⇒ t ∧ (∀ t'. (c,s) ⇒ t' ⟶ Q t)"
I wonder if this is correct. Currently, I'm having problems proving the weakest precondition definition for the sequential composition of commands:
"wp (c1;;c2) Q s = wp c1 (wp c2 Q) s"
So, I'm beginning to think my definition is wrong.
Does anybody see what am I doing wrong?