File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ If the conclusion is a probabilistic Hoare logic statement judgement whose progr
118118 weakest precondition of the random assignment.
119119
120120 This weakest precondition is defined with respect to an event `E `,
121- which can be provided explicitly. When $E$ is not
121+ which can be provided explicitly. When `E`` is not
122122 specified, it is inferred from the current postcondition.
123123
124124.. ecproof ::
@@ -274,4 +274,32 @@ the sampling statement on the `{side}` program.
274274Variant: `rnd ` (eHL)
275275------------------------------------------------------------------------
276276
277- To do.
277+ If the conclusion is an expectation Hoare logic statement judgement whose program ends
278+ with a random assignment, then `rnd ` consumes that random assignment,
279+ and replaces the postcondition by the expectation over the distribution of the sampled variable
280+ of the original postcondition.
281+
282+ .. ecproof ::
283+ :title: Expectation Hoare logic example
284+
285+ require import AllCore Distr DBool Real Xreal.
286+
287+ module M = {
288+ proc f(x : bool) : bool = {
289+ var y : bool;
290+
291+ y <$ {0,1};
292+
293+ return (x = y);
294+ }
295+ }.
296+
297+ pred p : glob M.
298+
299+ lemma L : ehoare [M.f : (1%r/2%r)%xr ==> res%xr].
300+ proof.
301+ proc.
302+ (*$ *)rnd.
303+ (* The post is now an expectation. *)
304+ skip => *;rewrite Ep_dbool;smt().
305+ qed.
You can’t perform that action at this time.
0 commit comments