Skip to content

Commit ca29c89

Browse files
committed
start removing our blessing from alt-ergo
1 parent 10ebb3a commit ca29c89

27 files changed

+348
-118
lines changed

easycrypt.project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[general]
2-
32
43

examples/ChaChaPoly/chacha_poly.ec

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -807,10 +807,13 @@ proof.
807807
rewrite (hrec (size (drop block_size p))) 2://; 1: smt(size_drop gt0_block_size).
808808
rewrite -{4}(cat_take_drop block_size p); congr.
809809
rewrite -!take_xor_map2_xor; apply (eq_from_nth Byte.zero).
810-
+ smt (size_map2 Block.bytes_of_blockP size_cat size_take gt0_block_size size_ge0).
810+
+ rewrite size_take 1:#smt:(gt0_block_size).
811+
rewrite size_map2 size_cat size_map2 bytes_of_blockP.
812+
by rewrite /min; smt(size_ge0).
811813
move=> j hj.
812814
have [hj1 hj2] : j < block_size /\ j < size p.
813-
+ smt (size_map2 Block.bytes_of_blockP size_cat size_take gt0_block_size size_ge0).
815+
+ move: hj; rewrite size_map2 size_cat size_map2 bytes_of_blockP /min.
816+
smt(size_ge0).
814817
rewrite
815818
(nth_map2 Byte.zero Byte.zero)
816819
?(size_cat, size_map2, Block.bytes_of_blockP) 1:#smt:(size_ge0).
@@ -878,7 +881,9 @@ proof.
878881
move=> _; rewrite /dblock; apply eq_distr => b.
879882
rewrite !dmap1E.
880883
apply (eq_trans _ (mu1 (dpoly `*` dextra_block) ((topair b).`1, (topair b).`2))); last first.
881-
+ congr; apply fun_ext; smt (topairK).
884+
+ congr; apply: fun_ext=> x @/(\o) @/pred1.
885+
rewrite -{3}topairK; case: (topair b)=> />.
886+
by move: (can_inj _ _ ofpairK)=> /#.
882887
rewrite dprod1E (_:block_size = poly_size + extra_block_size) //.
883888
rewrite dlist_add 1:ge0_poly_size 1:ge0_extra_block_size dmapE.
884889
rewrite !dmap1E /(\o) -dprodE &(mu_eq_support) => -[l1 l2] /supp_dprod /= [h1 h2].
@@ -946,7 +951,9 @@ proof.
946951
move=> _; rewrite /dpoly; apply eq_distr => b.
947952
rewrite !dmap1E.
948953
apply (eq_trans _ (mu1 (dpoly_in `*` dpoly_out) ((topair b).`1, (topair b).`2))); last first.
949-
+ congr; apply fun_ext; smt (topairK).
954+
+ congr; apply: fun_ext=> x @/(\o) @/pred1.
955+
rewrite -{3}(topairK b); case: (topair b)=> />.
956+
by move: (can_inj _ _ ofpairK)=> /#.
950957
rewrite dprod1E (_:poly_size = poly_in_size + poly_out_size) //.
951958
rewrite dlist_add 1:ge0_poly_in_size 1:ge0_poly_out_size dmapE.
952959
rewrite !dmap1E /(\o) -dprodE &(mu_eq_support) => -[l1 l2] /supp_dprod /= [h1 h2].
@@ -1752,7 +1759,30 @@ section PROOFS.
17521759
let r = oget ROin.m{1}.[(n, C.ofintd 0)] in
17531760
let s = oget ROout.m{1}.[(n, C.ofintd 0)] in
17541761
s = t - poly1305_eval r (topol a c))); last first.
1755-
+ auto => /> ; smt (undup_uniq size_undup size_map).
1762+
(** TODO DUPRESSOIR: CLEAN THIS UP **)
1763+
+ auto=> /> &1 &2 + not_bad; rewrite not_bad=> />.
1764+
move=> inv_count inv_domRO inv_domSRO1 eq_domSRO2 inv_domSRO2 size_lenc inv_ndec inv_log inv_sc inv0 inv1 inv2 inv3 inv4.
1765+
split; 1:smt(undup_uniq).
1766+
split=> [/#|].
1767+
split; 1:smt(size_undup size_map).
1768+
split=> [/#|].
1769+
split=> [/#|].
1770+
move=> j ge0_j gtj_size lc_j x1 x2 x3.
1771+
pose n0 := nth witness (undup (map (fun (p : ciphertext)=> p.`1) Mem.lc{2})) j.
1772+
case _: (UFCMA.log.[n0]{2}).
1773+
+ smt().
1774+
move=> /> log_nth.
1775+
split=> [/#|].
1776+
case _: (SplitC2.I2.RO.m{1}.[n0, C.ofintd 0]).
1777+
+ smt().
1778+
case _: (RO.m{2}.[n0, C.ofintd 0]).
1779+
+ smt().
1780+
move=> />.
1781+
move: (inv2 n0 _); 1:smt().
1782+
rewrite log_nth=> /> _ _ x0 m2_n0 x4 i2_n0.
1783+
move: (inv4 n0 _).
1784+
+ exact: (inv_domSRO1 _ (C.ofintd 0)).
1785+
by rewrite log_nth i2_n0 m2_n0.
17561786

17571787
(* + auto => /> *; have [#] * :=H H0. *)
17581788
(* rewrite H3/=. *)
@@ -2086,12 +2116,13 @@ section PROOFS.
20862116
- have:=allP (fun (n0 : nonce) => (n0, C.ofintd 0) \notin ROout.m{2}) l2.
20872117
have-> /= -> //=:=filter_all (fun (n0 : nonce) => (n0, C.ofintd 0) \notin SplitC2.I2.RO.m{2}) l.
20882118
by rewrite mem_nth //=.
2089-
rewrite (drop_nth witness i{2} l2) //= drop0 //=; do ! split=> /> *.
2119+
rewrite (drop_nth witness i{2} l2) //= drop0 //=; do ! split=> />.
20902120
+ smt().
20912121
+ smt(mem_set).
2092-
+ rewrite get_set_neqE /=; smt(mem_nth).
2093-
+ smt(mem_set).
2122+
+ move=> *; rewrite get_set_neqE /=; smt(mem_nth).
20942123
+ smt(mem_set).
2124+
+ move=> n0; rewrite mem_set; case=> [/#|/>].
2125+
by right; exists i{2}=> /#.
20952126
+ smt(mem_set size_drop size_ge0 size_eq0).
20962127
+ smt(mem_set size_drop size_ge0 size_eq0).
20972128
qed.

examples/MEE-CBC/RCPA_CMA.ec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ theory EtM.
336336
type leaks <- leaks,
337337
op leak <- leak,
338338
op dC (l:leaks) <- (dC l) `*` (MUnit.dunit witness<:tag>)
339-
proof * by smt.
339+
proof * by smt(dprod_ll dC_ll dunit_ll).
340340

341341
(** The black-box construction is as follows **)
342342
module EtM(E:SKEa.Enc_Scheme, M:MACa.MAC_Scheme): Enc_Scheme = {

examples/PIR.ec

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ proof. by exists [] s. qed.
2222
2323
lemma sxor2_cons (s s':int list) (i j:int):
2424
sxor2 s s' i => sxor2 (j::s) (j::s') i.
25-
proof. smt (). qed.
25+
proof.
26+
move=> [].
27+
move=> [] s1 s2 [] -> ->.
28+
by left; exists (j :: s1) s2.
29+
+ move=> [] s1 s2 [] -> ->.
30+
by right; exists (j :: s1) s2.
31+
qed.
2632
2733
(* The database *)
2834
op a : int -> word.
@@ -72,7 +78,7 @@ proof.
7278
while (j <= N /\ if j <= i then PIR.s = PIR.s' else sxor2 PIR.s PIR.s' i).
7379
+ wp;rnd;skip => /= &m [[_]] + HjN.
7480
have -> /= : j{m} + 1 <= N by smt ().
75-
case: (j{m} <= i{m}) => Hji;2: by smt ().
81+
case: (j{m} <= i{m})=> Hji; 2:smt(sxor2_cons).
7682
move=> -> b _;case: (j{m} = i{m}) => [->> | /#].
7783
by rewrite (_ : !(i{m}+1 <= i{m})) 1:/# /=; smt (sxor_cons).
7884
by auto => /#.

examples/ehoare/qselect/partition.eca

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ lemma index_count x l: sorted (<=) l => uniq l => x \in l => index x l = count (
100100
proof.
101101
elim: l => // y l hrec /> hp hnin hu.
102102
case: (x = y) => [<<- _ | hne /= hin] /=.
103-
+ by rewrite index_cons /= count_pred0_eq_in //=; smt (order_path_min allP le_trans lt_nle).
103+
+ rewrite index_cons /= count_pred0_eq_in //=; 2:smt(lt_nle).
104+
move=> x0 x0_in_l; move: (order_path_min (<=) le_trans x l hp).
105+
by rewrite allP=> /(_ _ x0_in_l); rewrite lt_nle.
104106
rewrite index_cons hne /= hrec //; 1: by apply: path_sorted hp.
105107
smt (order_path_min allP le_trans).
106108
qed.

examples/hashed_elgamal_std.ec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ section Security.
192192
- Pr[ES1(ESAdv(A)).main() @ &m : res]|.
193193
proof.
194194
rewrite (cpa_ddh0 &m) (ddh1_es1 &m) (es0_Gb &m) (Gb_half &m).
195-
smt(@Real).
195+
smt(StdOrder.RealOrder.ler_dist_add).
196196
qed.
197197
end section Security.
198198

theories/algebra/DynMatrix.eca

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ lemma offunvK pv: tofunv (offunv pv) = vclamp pv.
7373
proof. by rewrite /tofunv /offunv eqv_repr vclamp_idemp. qed.
7474

7575
lemma vectorW (P : vector -> bool):
76-
(forall pv, P (offunv pv)) => forall v, P v by smt(tofunvK).
76+
(forall pv, P (offunv pv)) => forall v, P v.
77+
proof. by move=> P_pv v; rewrite -tofunvK; apply: P_pv. qed.
7778

7879
(* Dimension of the vector *)
7980
op size v = (tofunv v).`2.
@@ -593,8 +594,10 @@ qed.
593594
lemma dvector1E (d : R distr) (v : vector) : mu1 (dvector d (size v)) v =
594595
BRM.bigi predT (fun i => mu1 d v.[i]) 0 (size v).
595596
proof.
596-
rewrite -{2}[v]tolistK dmapE /(\o) /pred1.
597-
rewrite (@mu_eq _ _ (pred1 (tolist v))); 1: smt(oflist_inj).
597+
rewrite -{2}[v]tolistK dmapE /(\o) /pred1.
598+
rewrite (@mu_eq _ _ (pred1 (tolist v))).
599+
+ move=> x; rewrite eq_iff /pred1 /=; split=> />.
600+
exact: oflist_inj.
598601
rewrite dlist1E 1:/# size_tolist max0size /=.
599602
by rewrite BRM.big_mapT /(\o) &BRM.eq_big.
600603
qed.
@@ -694,7 +697,8 @@ proof. by rewrite /tofunm /offunm eqv_repr. qed.
694697
hint simplify offunmK.
695698

696699
lemma matrixW (P : matrix -> bool) : (forall pm, P (offunm pm)) =>
697-
forall m, P m by smt(tofunmK).
700+
forall m, P m.
701+
proof. by move=> P_pm m; rewrite -tofunmK; exact: P_pm. qed.
698702

699703
(* Number of rows and columns of matrices *)
700704
op rows m = (tofunm m).`2.
@@ -1451,16 +1455,17 @@ qed.
14511455
lemma catmrA (m1 m2 m3: matrix): ((m1 || m2) || m3) = (m1 || (m2 || m3)).
14521456
proof.
14531457
rewrite eq_matrixP.
1454-
split => [| i j bound]; 1: smt(size_catmr).
1458+
split => [| i j bound]; 1:smt(size_catmr rows_catmr cols_catmr).
14551459
rewrite 4!get_catmr cols_catmr // addrA.
1456-
algebra.
1460+
by algebra.
14571461
qed.
14581462

14591463
lemma catmrDr (m1 m2 m3: matrix): m1 * (m2 || m3) = ((m1 * m2) || (m1 * m3)).
14601464
proof.
14611465
rewrite eq_matrixP.
14621466
rewrite rows_mulmx cols_mulmx cols_catmr.
1463-
split => [| i j bound]; 1: smt(size_mulmx size_catmr).
1467+
split => [| i j bound].
1468+
+ by rewrite !size_catmr !rows_mulmx !cols_mulmx /#.
14641469
rewrite get_catmr 3!get_mulmx.
14651470
case (j < cols m2) => bound2.
14661471
- rewrite [col m3 _]col0E 1:/# dotpv0 addr0 !dotpE 2!size_col rows_catmr.
@@ -1667,7 +1672,9 @@ case (j < n) => j_bound.
16671672
+ smt(size_catmr size_subm).
16681673
by rewrite addr0.
16691674
- rewrite getm0E; 1: smt(size_catmr size_subm).
1670-
rewrite add0r get_subm; smt(size_catmr size_subm).
1675+
rewrite add0r get_subm; [3:smt()].
1676+
+ smt(rows_catmr rows_subm).
1677+
+ smt(cols_catmr cols_subm).
16711678
qed.
16721679

16731680
lemma subm_colmx (m: matrix) l :
@@ -1908,7 +1915,8 @@ move => r_ge0 c_ge0; split => [m_supp|]; last first.
19081915
- case => -[r_m c_m] m_d; rewrite /support -r_m -c_m dmatrix1E.
19091916
apply prodr_gt0_seq => i i_row _ /=.
19101917
by apply prodr_gt0_seq => j j_col _ /=; apply m_d; smt(mem_iota).
1911-
have [r_m c_m] : size m = (r,c) by smt(size_dmatrix).
1918+
have [r_m c_m] : size m = (r,c).
1919+
+ exact: (size_dmatrix d).
19121920
split => [//|i j range_ij]; move: m_supp.
19131921
rewrite -r_m -c_m /support dmatrix1E => gt0_big.
19141922
pose G i0 := (fun (j0 : int) => mu1 d m.[i0, j0]).

theories/analysis/RealFLub.ec

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ by smt().
2525
lemma flub_upper_bound (F : 'a -> real) x :
2626
has_fub F => F x <= flub F.
2727
proof.
28-
move => H. apply lub_upper_bound; 2: by exists x.
29-
by split; [ by exists (F x) x | smt() ].
28+
move => H; apply lub_upper_bound; 2: by exists x.
29+
split.
30+
+ by exists (F x) x.
31+
by case: H=> r is_fub_F_r; exists r=> /#.
3032
qed.
3133

3234
lemma flub_le_ub (F : 'a -> real) r :
@@ -53,17 +55,21 @@ lemma flubZ (f: 'a -> real) c : has_fub f =>
5355
c >= 0%r => flub (fun x => c * f x) = c * flub f.
5456
proof.
5557
move => fub_f c_ge0 @/flub; pose E := fun r => exists a, f a = r.
56-
have -> : (fun r => exists a, c * f a = r) = scale_rset E c by smt().
58+
have -> : (fun r => exists a, c * f a = r) = scale_rset E c.
59+
+ apply: fun_ext=> x; rewrite eq_iff; split.
60+
+ by move=> [] a xP; exists (f a); rewrite xP=> //=; exists a.
61+
+ by move=> /> a; exists a.
5762
by rewrite lub_scale //; apply has_fub_lub.
5863
qed.
5964

6065
lemma flub_const c :
6166
flub (fun _ : 'a => c) = c.
6267
proof.
6368
apply eqr_le; split; first apply flub_le_ub => /#.
64-
move => _; apply (@flub_upper_bound (fun _ => c) witness) => /#.
69+
move=> _; apply (@flub_upper_bound (fun _=> c) witness).
70+
by exists c=> /#.
6571
qed.
6672
6773
lemma has_fubZ (f: 'a -> real) c: has_fub f =>
6874
c >= 0%r => has_fub (fun x => c * f x).
69-
proof. move => [ym ub_ym] ge0_c; exists (c * ym) => /#. qed.
75+
proof. by move => [ym ub_ym] ge0_c; exists (c * ym) => /#. qed.

theories/analysis/RealFun.ec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ proof. smt (). qed.
3535

3636
lemma convexD f1 f2 a b:
3737
convex f1 a b => convex f2 a b => convex (fun x => f1 x + f2 x) a b.
38-
proof. smt (). qed.
38+
proof. by move=> + + x x_in01; smt(). qed.
3939

4040
lemma convexZ c f a b: 0%r <= c =>
4141
convex f a b => convex (fun x => c * f x) a b.

theories/analysis/RealLub.ec

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ qed.
8181
(* -------------------------------------------------------------------- *)
8282
lemma lub1 x : lub (pred1 x) = x.
8383
proof.
84-
apply eqr_le; split; [apply lub_le_ub => /#|move => _].
85-
apply lub_upper_bound; smt().
84+
have haslub_1x: (has_lub (pred1 x)).
85+
+ by rewrite /has_lub; split; exists x=> /#.
86+
apply: eqr_le; split.
87+
+ by apply: lub_le_ub=> //#.
88+
by move=> _; apply: lub_upper_bound.
8689
qed.
8790

8891
(* -------------------------------------------------------------------- *)
@@ -102,7 +105,8 @@ qed.
102105
lemma has_lub_scale E c : 0%r <= c =>
103106
has_lub E => has_lub (scale_rset E c).
104107
proof.
105-
move => c_ge0 [[x Ex] ?]; split; 1: smt().
108+
move=> c_ge0 [[x Ex] ?]; split.
109+
+ by exists (c * x) x.
106110
exists (c * lub E) => cx; smt(lub_upper_bound).
107111
qed.
108112

@@ -115,7 +119,9 @@ apply eqr_le; split => [|_].
115119
- apply lub_le_ub; first by apply has_lub_scale.
116120
smt(lub_upper_bound).
117121
rewrite -ler_pdivl_mull //; apply lub_le_ub => // x Ex.
118-
by rewrite ler_pdivl_mull //; smt(lub_upper_bound has_lub_scale).
122+
rewrite ler_pdivl_mull //; apply: lub_upper_bound.
123+
+ exact: has_lub_scale.
124+
by exists x.
119125
qed.
120126

121127
(* -------------------------------------------------------------------- *)

theories/analysis/RealSeries.ec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,8 @@ lemma summable_inj (h : 'a -> 'b) (s : 'b -> real) :
965965
injective h => summable s => summable (s \o h).
966966
proof.
967967
move => inj_h [M] sum_s; exists M => J uniq_J.
968-
have R := sum_s (map h J) _; 1: rewrite map_inj_in_uniq /#.
968+
have R := sum_s (map h J) _.
969+
+ by rewrite map_inj_in_uniq=> // x y _ _ /inj_h.
969970
apply (ler_trans _ _ R) => {R}; rewrite big_map /(\o)/= big_mkcond.
970971
exact Bigreal.ler_sum.
971972
qed.

theories/crypto/PROM.ec

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,22 @@ fel 1 (fsize RO.m) (fun x => x%r * Pc) q (fcoll f RO.m)
287287
- inline*; auto; smt(fsize_empty mem_empty).
288288
- proc; inline*; (rcondt 2; first by auto); wp.
289289
rnd (fun r => exists u, u \in RO.m /\ f (oget RO.m.[u]) = f r).
290-
skip => &hr; rewrite andaE => /> 3? I ?; split; 2: smt(get_setE).
291-
apply mu_mem_le_fsize => u /I /(dmap_supp _ f) /fcollP /= /(_ x{hr}).
292-
rewrite dmap1E. apply: StdOrder.RealOrder.ler_trans.
293-
by apply mu_sub => /#.
290+
auto=> /> &0 ge0_size_m ltq_size_m nocoll I x_notin_m; split=> [|_].
291+
+ apply mu_mem_le_fsize => u /I /(dmap_supp _ f) /fcollP /= /(_ x{0}).
292+
rewrite dmap1E; apply: StdOrder.RealOrder.ler_trans.
293+
by apply: mu_sub=> @/pred1 @/(\o) /> x ->.
294+
move=> v _ i j; rewrite !mem_set.
295+
move=> i_in_mVx j_in_mVx i_neq_j; rewrite !get_setE.
296+
case: (i = x{0}); case: (j = x{0})=> />.
297+
+ by move=> _ coll_v; exists j=> /#.
298+
+ by move=> _ coll_v; exists i=> /#.
299+
move=> j_neq_x i_neq_x eq_f.
300+
move: nocoll=> /negb_exists /= /(_ i) /negb_exists /= /(_ j).
301+
rewrite i_neq_j eq_f.
302+
move: i_in_mVx; rewrite i_neq_x=> /= -> /=.
303+
by move: j_in_mVx; rewrite j_neq_x=> /= -> /=.
294304
- move => c; proc; auto => />; smt(get_setE fsize_set).
295-
- move => b c. proc. by auto.
305+
- move => b c; proc; by auto.
296306
qed.
297307

298308
end section Collision.

0 commit comments

Comments
 (0)