https://github.com/EasyCrypt/easycrypt
Revision be9057ba61af06294b7f8188dd32aaf936f88595 authored by Antoine Séré on 25 February 2021, 22:39:02 UTC, committed by Antoine Séré on 25 February 2021, 22:39:02 UTC
Tip revision: be9057ba61af06294b7f8188dd32aaf936f88595 authored by Antoine Séré on 25 February 2021, 22:39:02 UTC
Merge branch 'deploy-crt' of https://github.com/EasyCrypt/easycrypt into deploy-crt
Merge branch 'deploy-crt' of https://github.com/EasyCrypt/easycrypt into deploy-crt
Tip revision: be9057b
WhileSampling.ec
require import Real Distr.
type t.
op sample: t distr.
axiom sample_ll: is_lossless sample.
op test: t -> bool.
axiom pr_ntest: 0%r < mu sample (predC test).
module Sample = {
proc sample () : t = {
var r : t;
r <$ sample;
while (test r) {
r <$ sample;
}
return r;
}
}.
lemma Sample_lossless: islossless Sample.sample.
proof.
proc; seq 1: true=> //.
+ by auto=> />; exact/sample_ll.
while true (if test r then 1 else 0) 1 (mu sample (predC test))=> //.
+ by move=> _ r; case: (test r).
+ move=> ih; seq 1: true=> //.
by auto; rewrite sample_ll.
+ by auto; rewrite sample_ll.
rewrite pr_ntest=> /= z; conseq (: true ==> !test r).
+ smt().
by rnd; auto=> />.
qed.
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...