Skip to content

Commit 27ec7c1

Browse files
mbbarbosafdupress
authored andcommitted
expectation logic
1 parent d1e9eff commit 27ec7c1

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

doc/tactics/rnd.rst

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff 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.
274274
Variant: `rnd` (eHL)
275275
------------------------------------------------------------------------
276276

277-
To do.
277+
If the conclusion is an expectation Hoare logic statement judgement whose
278+
program ends with a random assignment, then `rnd` consumes that random
279+
assignment, and replaces the postcondition by the expectation of the original
280+
postcondition in the distribution of the sampled variable.
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.

0 commit comments

Comments
 (0)