From mathcomp.ssreflect
From mathcomp
From fcsl
From DiSeL
From DiSeL
Set Implicit Arguments.
Unset Strict Implicit.
(*****************************************************************************  [Unary Hoare-style specifications and auxiliary lemmas].  This file borrows basic definition of binary-to-unary Hoare triple encoding (i.e., logvar and binarify definitions) from the development of FCSL by Nanevski et al.  (FCSL is available at http://software.imdea.org/fcsl)   *****************************************************************************)
(* Spec s is parametrized by a ghost variable of type A *)
Definition logvar {B A} (s : A -> spec B) : spec B :=
(fun i => exists x : A, (s x).1 i,
fun y i m => forall x : A, (s x).2 y i m).
(* Representing q as a unary postcondition, including the precondition *)
Definition binarify {A} (p : pre) (q : cont A) : spec A :=
(p, fun i y m => p i -> q y m).
Notation "'DHT' [ this , W ] ( p , q ) " :=
(DTbin this W (binarify p q)) (at level 0,
format "'[hv ' DHT  [ this , W ]  ( '[' p , '/' q ']' ) ']'").
(* A unary Hoare-style specification  *)
Notation "{ x .. y }, 'DHT' [ this , W ] ( p , q )" :=
(DTbin this W (logvar (fun x => .. (logvar (fun y => binarify p q)) .. )))
(at level 0, x binder, y binder, right associativity,
format "'[hv ' { x .. y }, '/ ' DHT  [ this , W ]  ( '[' p , '/' q ']' ) ']'").
Section BasicRules.
Variable this : nid.

(* Specifications: *)
(* We can always assume coherence of the state *)
Lemma vrf_coh W A (e : DT this W A) i r :
(i \In Coh W -> verify i e r) -> verify i e r.
(* stability of preconditions *)
Lemma vrf_pre W A (e : DT this W A) i i' (k : cont A) :
verify i e k -> network_rely W this i i' -> verify i' e k.
(* stability of postconditions *)
Lemma vrf_post W A (e : DT this W A) i (k : cont A) :
verify i e k ->
verify i e (fun x m => forall m', network_rely W this m m' -> k x m').
(* An inference rule for the sequential composition *)
Lemma bind_rule W A B (e1 : DT this W A) (e2 : A -> DT this W B) i
(q : cont A) (r : cont B) :
verify i e1 q ->
(forall y j, q y j -> j \In Coh W  -> verify j (e2 y) r) ->
verify i (bind e1 e2) r.