End EvalDoR.
(* ret lemmas need no reflection, as they operate on any heap; still *)
(* rename them for uniformity *)
Definition val_retR := val_ret.
Definition try_retR := try_ret.
Definition bnd_retR := bnd_ret.
Section EvalReadR.
Variables (A B : Type).

(* Specifications: *)
Lemma val_readR v x i (f : update (x :-> v) i) (r : cont A) :
(def f -> r (Val v) f) ->
verify (read_s A x) f r.
Lemma val_gh1R (r : cont A) :
let: Q := fun y i m => forall x, i \In p x -> q x y i m in
(i \In p t -> P i) ->
(forall x m, q t (Val x) i m -> def (f m) -> r (Val x) (f m)) ->
(forall e m, q t (Exn e) i m -> def (f m) -> r (Exn e) (f m)) ->
i \In p t ->
verify (P, Q) (f i) r.
Lemma try_ghR (r : cont B) :
let: s := (fun i => exists x, i \In p x,
fun y i m => forall x, i \In p x -> q x y i m) in
(forall x m, q t (Val x) i m -> verify (s1 x) (f m) r) ->
(forall e m, q t (Exn e) i m -> verify (s2 e) (f m) r) ->
i \In p t ->
verify (try_s s s1 s2) (f i) r.
Lemma try_gh1R (r : cont B) :
let: Q := fun y i m => forall x, i \In p x -> q x y i m in
(i \In p t -> P i) ->
(forall x m, q t (Val x) i m -> verify (s1 x) (f m) r) ->
(forall e m, q t (Exn e) i m -> verify (s2 e) (f m) r) ->
i \In p t ->
verify (try_s (P, Q) s1 s2) (f i) r.
Lemma bnd_ghR (r : cont B) :
let: s := (fun i => exists x, i \In p x,
fun y i m => forall x, i \In p x -> q x y i m) in
(forall x m, q t (Val x) i m -> verify (s1 x) (f m) r) ->
(forall e m, q t (Exn e) i m -> def (f m) -> r (Exn e) (f m)) ->
i \In p t ->
verify (bind_s s s1) (f i) r.
Lemma bnd_gh1R (r : cont B) :
let: Q := fun y i m => forall x, i \In p x -> q x y i m in
(i \In p t -> P i) ->
(forall x m, q t (Val x) i m -> verify (s1 x) (f m) r) ->
(forall e m, q t (Exn e) i m -> def (f m) -> r (Exn e) (f m)) ->
i \In p t ->
verify (bind_s (P, Q) s1) (f i) r.