Skip to content

Commit e2f9f50

Browse files
used is_finite_for instead of new operator
1 parent fa163ec commit e2f9f50

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

theories/modules/TotalProb.ec

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@
22
distributions with finite support, and then specializes it to
33
`DBool.dbool`, `drange` and `duniform`. ^*)
44

5-
require import AllCore List StdOrder StdBigop Distr DBool.
5+
require import AllCore List StdOrder StdBigop Distr DBool Finite.
66
require EventPartitioning.
77
import RealOrder Bigreal BRA.
88

9-
(*& Are the elements in the support of a distribution the
10-
same as the elements of a list? &*)
11-
12-
op support_is (d : 'a distr) (xs : 'a list) : bool =
13-
forall (y : 'a), y \in d <=> y \in xs.
14-
159
(*& General abstract theory &*)
1610

1711
abstract theory TotalGeneral.
@@ -102,13 +96,13 @@ hoare; call (_ : true); auto; smt().
10296
qed.
10397
10498
lemma total_prob' (dt' : t distr) (supp : t list) (i' : input) &m :
105-
is_lossless dt' => uniq supp => support_is dt' supp =>
99+
is_lossless dt' => is_finite_for (support dt') supp =>
106100
Pr[Rand(M).f(dt', i') @ &m : res] =
107101
big predT
108102
(fun x' => mu1 dt' x' * Pr[M.main(i', x') @ &m : res])
109103
supp.
110104
proof.
111-
move => dt'_ll uniq_supp support_is_dt'_supp.
105+
move => dt'_ll [uniq_supp supp_iff].
112106
have -> :
113107
Pr[Rand(M).f(dt', i') @ &m : res] = Pr[RandAux.f(dt', i') @ &m : res].
114108
byequiv (_ : ={dt, i, glob M} ==> ={res}) => //; proc; sim.
@@ -134,13 +128,13 @@ end section.
134128
(*& total probability lemma for distributions with finite support &*)
135129
136130
lemma total_prob (M <: T) (dt : t distr) (supp : t list) (i : input) &m :
137-
is_lossless dt => uniq supp => support_is dt supp =>
131+
is_lossless dt => is_finite_for (support dt) supp =>
138132
Pr[Rand(M).f(dt, i) @ &m : res] =
139133
big predT
140134
(fun (x : t) => mu1 dt x * Pr[M.main(i, x) @ &m : res])
141135
supp.
142136
proof.
143-
move => dt_ll uniq_supp support_is_dt_supp.
137+
move => dt_ll iff_supp_dt_supp.
144138
by apply (total_prob' M).
145139
qed.
146140

@@ -205,10 +199,8 @@ proof.
205199
move => lt_m_n.
206200
rewrite (total_prob M (drange m n) (range m n)).
207201
by rewrite drange_ll.
208-
by rewrite range_uniq.
209-
rewrite /support_is => j; split => [j_in_drange | j_in_range].
210-
rewrite mem_range; by rewrite supp_drange in j_in_drange.
211-
rewrite supp_drange; by rewrite mem_range in j_in_range.
202+
rewrite /is_finite_for.
203+
smt(range_uniq mem_range supp_drange).
212204
rewrite (big_weight_simp M) //; by move => j /mem_range.
213205
qed.
214206

@@ -255,8 +247,7 @@ proof.
255247
move => uniq_xs xs_ne_nil.
256248
rewrite (total_prob M (duniform xs) xs).
257249
by rewrite duniform_ll.
258-
by rewrite uniq_xs.
259-
rewrite /support_is => y; smt(supp_duniform).
250+
smt(supp_duniform).
260251
by rewrite (big_weight_simp M).
261252
qed.
262253

0 commit comments

Comments
 (0)