https://github.com/EasyCrypt/easycrypt
Tip revision: 374dae60b90d55b70e41805c88b33b26faaa455d authored by Pierre-Yves Strub on 12 October 2021, 13:09:21 UTC
parser: fix precedence issue
parser: fix precedence issue
Tip revision: 374dae6
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.