-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRndEx-fill.ec
60 lines (45 loc) · 1.02 KB
/
RndEx-fill.ec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(* RndEx.ec *)
prover [""]. (* no SMT solvers *)
require import AllCore.
require import Bool. (* defines ^^ as exclusive or *)
require import Distr. (* (sub-)distributions *)
(* lossless, full, uniform distribution {0,1} on bool
lossless means sum of the weights of type is 1%r
full means every element of type is in support (has non-0 probability)
uniform means all elements in support have same weight *)
require import DBool.
module M = {
proc f() : bool = {
var b : bool;
b <$ {0,1};
return b;
}
}.
module N = {
proc f() : bool = {
var b1, b2 : bool;
b1 <$ {0,1};
b2 <$ {0,1};
return b1 ^^ b2; (* exclusive or *)
}
}.
lemma M_N_equiv :
equiv[M.f ~ N.f : true ==> ={res}].
proof.
qed.
lemma M_N_true &m :
Pr[M.f() @ &m : res] = Pr[N.f() @ &m : res].
proof.
qed.
lemma M_N_false &m :
Pr[M.f() @ &m : ! res] = Pr[N.f() @ &m : ! res].
proof.
qed.
lemma M &m :
Pr[M.f() @ &m : res] = 1%r / 2%r.
proof.
qed.
lemma N &m :
Pr[N.f() @ &m : res] = 1%r / 2%r.
proof.
qed.