SE 504   Formal Methods and Models
Some laws and properties of Hoare triples and the wp predicate transformer

The numbering of the laws is based loosely upon where they appear in the Kaldewaij book, using section numbers and ordering.

(2.0.7) Relationship between Hoare triples and wp: {P} S {Q}   ≡   [P wp.S.Q]

General Properties/Laws of Hoare triples:

(2.0.0)Excluded Miracle: {P} S {false}   ≡   [P ≡ false]
(2.0.1)Termination: {P} S {true}   ≡   "S is guaranteed to terminate if executed beginning in a state satisfying P"
(2.0.2)Strengthening the Precondition: [P' ⇒ P]   ⇒   ({P} S {Q} ⇒ {P'} S {Q})
Equivalently (by (3.65)), [P' ⇒ P] ∧ {P} S {Q}  ⇒  {P'} S {Q}
(2.0.3)Weakening the Postcondition: [Q ⇒ Q']   ⇒   ({P} S {Q} ⇒ {P} S {Q'})
Equivalently (by (3.65)), [Q ⇒ Q'] ∧ {P} S {Q}  ⇒  {P} S {Q'}
(2.0.4)Postcondition Conjunctivity: {P} S {Q1} ∧ {P} S {Q2}   ≡   {P} S {Q1 ∧ Q2}
(2.0.5)Precondition Disjunctivity: {P1} S {Q} ∧ {P2} S {Q}   ≡   {P1 ∨ P2} S {Q}
(2.0.6)Postcondition Disjunctivity: {P} S {Q} ∨ {P} S {R}   ⇒   {P} S {Q ∨ R}
(2.3.0)Hoare triple Catenation: (∃R |: {P} S0 {R} ∧ {R} S1 {Q})   ≡   {P} S0; S1 {Q}
Consequently, {P} S0 {R} ∧ {R} S1 {Q}   ⇒   {P} S0; S1 {Q}

General Properties/Laws of wp:

(2.0.8)Excluded Miracle:[¬wp.S.false]
(2.0.9)Distributivity of Conjunction: [wp.S.Q1 ∧ wp.S.Q2   ≡   wp.S.(Q1 ∧ Q2)]
(2.0.10)Monotonicity: [Q1 ⇒ Q2]   ⇒   [wp.S.Q1 ⇒ wp.S.Q2]
(2.0.11)Distributivity of Disjunction: [wp.S.Q1 ∨ wp.S.Q2   ⇒   wp.S.(Q1 ∨ Q2)]
(If S is deterministic, ⇒ above can be strengthened to ≡)
(2.3.1)wp Catenation: [wp.(S0; S1).Q   ≡   wp.S0.(wp.S1.Q)]

Properties/Laws of wp and Hoare Triples wrt DGCL:

wp skip Law (WPsL): [wp.skip.Q ≡ Q]

Applying (2.0.7) to this, we get
Hoare Triple skip Law (HTsL): {P} skip {Q}   ≡   [P ⇒ Q]

wp Assignment Law (WPAL): [wp.(x := E).Q  ≡  def.E ∧ Q(x:=E)]

Applying (2.0.7) to this, we get
Hoare Triple Assignment Law (HTAL): {P} x:=E {Q}  ≡  [P ⇒ def.E ∧ Q(x:=E)]

wp Selection Law (WPSL): Let IF be the program

if B1 → S1 [] ... [] Bn → Sn fi

Then [wp.IF.Q  ≡  BB ∧ (∀i | 1≤i≤n : Bi ⇒ wp.Si.Q)], where BB : (∃i | 1≤i≤n : Bi)

Applying (2.0.7) (and some other logic) to this, we get
Hoare Triple Selection Law (HTifL): {P} IF {Q}  ≡  [P ⇒ BB] ∧ (∀i | 1≤i≤n : {P ∧ Bi} Si {Q})

wp Catenation Law (WPCL): [wp.(S1;S2).Q  ≡  wp.S1.(wp.S2.Q)]

Applying (2.0.7) to this, we get
Hoare Triple Catenation Law (HTCatL): {P} S1;S2 {Q}  ≡  {P} S1 {wp.S2.Q}