(* Definition of the hoare relation and rules *)
Definition hoare (t:terminationMeasure) (n':nat) (G R P:pred world) (c:instruction) (Q:pred world) :=
forall t', termMeasure_incr t t' ->
forall p n k stk,
(forall s, G (p,(s,t'))) ->
(forall r', guards n R stk       (p,(r',t'))) ->
(forall r', guards n Q (k::stk)  (p,(r',t'))) ->
(forall r,  guards (n'+n) P ((c ;; k)::stk) (p,(r,t'))).

Lemma hoare_if : forall t x v s1 s2 G R P Q,
P |-- store_op (fun r => match r#v with
| Some (value_label l) => l = L 0
| Some (value_cons _ _) => True
| _ => False
end) ->
hoare t x G R (P && store_op (fun r => r#v = Some (value_label (L 0)))) s1 Q ->
hoare t x G R (P && store_op (fun r => exists x1, exists x2, r#v = Some (value_cons x1 x2))) s2 Q ->
hoare t x G R P (instr_if_nil v s1 s2) Q.