https://github.com/EasyCrypt/easycrypt
Revision 6489adef7972273936a558ec2d751017fc85db29 authored by Pierre-Yves Strub on 25 October 2019, 06:45:59 UTC, committed by Pierre-Yves Strub on 25 October 2019, 06:46:13 UTC
 - do not fail when an .eco file is invalid
 - fix the reading of the `version' flag
 - erase staled .eco file
 - do not accept to compile files not handing with .ec or .eca
 - API: .mli file for EcEco

[fix #17398]
1 parent 10b2ab0
Raw File
Tip revision: 6489adef7972273936a558ec2d751017fc85db29 authored by Pierre-Yves Strub on 25 October 2019, 06:45:59 UTC
Make ECO handling more robust
Tip revision: 6489ade
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.
back to top