Skip to content

Commit 17f9fb3

Browse files
committed
1 parent 8c2ee91 commit 17f9fb3

File tree

11 files changed

+45
-424
lines changed

11 files changed

+45
-424
lines changed

rupicola

Submodule rupicola updated 1 file

src/Arithmetic/BarrettReduction.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Module Fancy.
314314
Proof.
315315
intros. subst a b. autorewrite with push_Zmul.
316316
ring_simplify_subterms. rewrite Z.pow_2_r.
317-
rewrite Z.div_add_exact by (push_Zmod; autorewrite with zsimplify; lia).
317+
rewrite Z.div_add_exact by (push_Zmod; rewrite ?Zmod_0_l; lia).
318318
repeat match goal with
319319
| |- context [d * ?a * ?b * ?c] =>
320320
replace (d * a * b * c) with (a * b * c * d) by ring

src/Arithmetic/BarrettReduction/HAC.v

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Section barrett.
6161

6262
Lemma r_mod_3m_eq_orig : r_mod_3m = r_mod_3m_orig.
6363
Proof using base_pos k_big_enough m_pos m_small offset_nonneg r1 r2.
64+
clear μ_good x_nonneg.
6465
assert (0 <= r1 < b^(k+offset)) by (subst r1; auto with zarith).
6566
assert (0 <= r2 < b^(k+offset)) by (subst r2; auto with zarith).
6667
subst r_mod_3m r_mod_3m_orig; cbv zeta.

src/Arithmetic/Core.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ Module Positional.
11061106
Lemma length_sub a b
11071107
: length a = n -> length b = n ->
11081108
length (sub a b) = n.
1109-
Proof using length_balance. intros; cbv [sub scmul negate_snd]; repeat distr_length. Qed.
1109+
Proof using length_balance. clear dependent s. intros; cbv [sub scmul negate_snd]; repeat distr_length. Qed.
11101110
Hint Rewrite length_sub : distr_length.
11111111
Definition opp (a:list Z) : list Z
11121112
:= sub (zeros n) a.
@@ -1119,7 +1119,7 @@ Module Positional.
11191119
Proof using m_nz s_nz weight_0 weight_nz eval_balance length_balance. intros; cbv [opp]; push; distr_length; auto. Qed.
11201120
Lemma length_opp a
11211121
: length a = n -> length (opp a) = n.
1122-
Proof using length_balance. cbv [opp]; intros; repeat distr_length. Qed.
1122+
Proof using length_balance. clear dependent s. cbv [opp]; intros; repeat distr_length. Qed.
11231123
End sub.
11241124
Hint Rewrite @eval_scmul @eval_opp @eval_sub : push_eval.
11251125
Hint Rewrite @length_scmul @length_sub @length_opp : distr_length.

src/Arithmetic/SolinasReduction.v

+15-3
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,7 @@ Module SolinasReduction.
12151215
eval weight (2 * n) (mul_no_reduce base n p q) =
12161216
eval weight n p * Positional.eval weight n q.
12171217
Proof using base_nz n_gt_1 wprops.
1218+
clear dependent s.
12181219
intros p q.
12191220
cbv [mul_no_reduce].
12201221
break_match.
@@ -1260,6 +1261,7 @@ Module SolinasReduction.
12601261
Theorem length_mul_no_reduce : forall p q,
12611262
length (mul_no_reduce base n p q) = (2 * n)%nat.
12621263
Proof using base_nz n_gt_1 wprops.
1264+
clear dependent s.
12631265
intros; unfold mul_no_reduce; break_match; push.
12641266
Qed.
12651267
Hint Rewrite length_mul_no_reduce : push_length.
@@ -1322,6 +1324,7 @@ Module SolinasReduction.
13221324
(combine (map weight (seq 0 n)) (firstn n p),
13231325
(combine (map weight (seq 0 (m1 - n))) (skipn n p))).
13241326
Proof using n_gt_1 wprops.
1327+
clear dependent s.
13251328
intros m1 p ? ?.
13261329
replace m1 with (n + (m1 - n))%nat at 1 by lia.
13271330
rewrite <-(firstn_skipn n p) at 1.
@@ -2432,13 +2435,13 @@ Module SolinasReduction.
24322435
Lemma sat_mul_comm (p q : list (Z * Z)) :
24332436
Associational.eval (Associational.sat_mul base p q) =
24342437
Associational.eval (Associational.sat_mul base q p).
2435-
Proof using base_nz n_gt_1. push; lia. Qed.
2438+
Proof using base_nz n_gt_1. clear dependent s. push; lia. Qed.
24362439

24372440
Lemma sat_mul_distr (p q1 q2 : list (Z * Z)) :
24382441
Associational.eval (Associational.sat_mul base p (q1 ++ q2)) =
24392442
Associational.eval (Associational.sat_mul base p q1) +
24402443
Associational.eval (Associational.sat_mul base p q2).
2441-
Proof using base_nz n_gt_1. push; lia. Qed.
2444+
Proof using base_nz n_gt_1. clear dependent s. push; lia. Qed.
24422445

24432446
Lemma cons_to_app {A} a (p : list A) :
24442447
a :: p = [a] ++ p.
@@ -2451,6 +2454,7 @@ Module SolinasReduction.
24512454
eval weight m (fst (Rows.flatten' weight state inp)) =
24522455
(Rows.eval weight m inp + eval weight m (fst state) + weight m * snd state) mod weight m.
24532456
Proof using n_gt_1 wprops.
2457+
clear dependent s.
24542458
intros.
24552459
rewrite Rows.flatten'_correct with (n:=m) by auto.
24562460
push.
@@ -2463,13 +2467,14 @@ Module SolinasReduction.
24632467

24642468
Lemma sum_one x :
24652469
sum [x] = x.
2466-
Proof. cbn; lia. Qed.
2470+
Proof. clear dependent s; cbn; lia. Qed.
24672471

24682472
Lemma square_indiv_cons (p : list (Z * Z)) (a : Z * Z) :
24692473
Associational.eval (sqr_indiv base (a :: p)) =
24702474
Associational.eval (sqr_indiv base [a]) +
24712475
Associational.eval (sqr_indiv base p).
24722476
Proof using base_nz n_gt_1.
2477+
clear dependent s.
24732478
cbv [sqr_indiv sqr_indiv'].
24742479
cbn [fold_right].
24752480
push.
@@ -2480,6 +2485,7 @@ Module SolinasReduction.
24802485
Associational.eval (sqr_indiv base (p ++ q)) =
24812486
Associational.eval (sqr_indiv base p) + Associational.eval (sqr_indiv base q).
24822487
Proof using base_nz n_gt_1.
2488+
clear dependent s.
24832489
generalize dependent q.
24842490
induction p as [| a p IHp] using rev_ind; intros q.
24852491
push.
@@ -2497,6 +2503,7 @@ Module SolinasReduction.
24972503
(Associational.eval (sat_mul base [(weight 2, x1)] [(weight 2, x1)]) +
24982504
Associational.eval (sat_mul base [(weight 3, x2)] [(weight 3, x2)])))).
24992505
Proof using base_nz wprops n_gt_1.
2506+
clear dependent s.
25002507
intros x x0 x1 x2 q H.
25012508
rewrite H.
25022509
cbv [to_associational].
@@ -2519,6 +2526,7 @@ Module SolinasReduction.
25192526
p = x :: x0 :: x1 :: x2 :: q ->
25202527
length (square1 base (to_associational weight 4 p)) = 8%nat.
25212528
Proof using base_nz wprops n_gt_1.
2529+
clear dependent s.
25222530
intros x x0 x1 x2 q H.
25232531
cbv [square1].
25242532
push.
@@ -2547,6 +2555,7 @@ Module SolinasReduction.
25472555
(Associational.eval (sat_mul base [(weight 3, x2)] [(weight 1, x0)]) +
25482556
Associational.eval (sat_mul base [(weight 3, x2)] [(weight 2, x1)]))).
25492557
Proof using base_nz wprops n_gt_1.
2558+
clear dependent s.
25502559
intros x x0 x1 x2 q bound H H1.
25512560
rewrite H1.
25522561
cbv [to_associational].
@@ -2612,6 +2621,7 @@ Module SolinasReduction.
26122621
p = x :: x0 :: x1 :: x2 :: q ->
26132622
0 <= eval weight 8 (square1 base (to_associational weight 4 p)) < weight 7.
26142623
Proof using base_nz wprops n_gt_1.
2624+
clear dependent s.
26152625
intros x x0 x1 x2 q bound H H0.
26162626
erewrite eval_square1; [| eauto | eauto].
26172627
rewrite H0 in H.
@@ -2635,6 +2645,7 @@ Module SolinasReduction.
26352645
Theorem eval_square_no_reduce (p : list Z) :
26362646
eval weight (2 * n) (square_no_reduce base n p) = (eval weight n p) * (eval weight n p).
26372647
Proof using base_nz wprops n_gt_1.
2648+
clear dependent s.
26382649
rewrite <-eval_mul_no_reduce with (base:=base) by lia.
26392650
cbv [square_no_reduce].
26402651
break_match.
@@ -2729,6 +2740,7 @@ Module SolinasReduction.
27292740
Theorem length_square_no_reduce (p : list Z):
27302741
length (square_no_reduce base n p) = (2 * n)%nat.
27312742
Proof using base_nz wprops n_gt_1.
2743+
clear dependent s.
27322744
cbv [square_no_reduce].
27332745
break_match.
27342746
rewrite Nat.eqb_eq in Heqb.

src/Arithmetic/WordByWordMontgomery.v

+2-1
Original file line numberDiff line numberDiff line change
@@ -1020,11 +1020,12 @@ Module WordByWordMontgomery.
10201020
Qed.
10211021
Lemma sub_bound : 0 <= eval (sub Av Bv) < eval N.
10221022
Proof using small_Bv small_Av R_numlimbs_nz Bv_bound Av_bound small_N r_big' partition_Proper lgr_big N_nz N_lt_R.
1023+
clear dependent ri; clear dependent k.
10231024
generalize eval_sub; break_innermost_match; Z.ltb_to_lt; lia.
10241025
Qed.
10251026
Lemma opp_bound : 0 <= eval (opp Av) < eval N.
10261027
Proof using small_Av R_numlimbs_nz Av_bound small_N r_big' partition_Proper lgr_big N_nz N_lt_R.
1027-
clear Bv small_Bv Bv_bound.
1028+
clear Bv small_Bv Bv_bound k k_correct ri ri_correct.
10281029
generalize eval_opp; break_innermost_match; Z.ltb_to_lt; lia.
10291030
Qed.
10301031
End add_sub.

src/Curves/TableMult/TableMult.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ Section TableMult.
12431243
intros.
12441244
unfold positify.
12451245
pose proof oddify_bounds e.
1246-
intuition.
1246+
intuition auto with core.
12471247
- apply Z.div_pos; lia.
12481248
- apply Z.div_lt_upper_bound; lia.
12491249
Qed.

src/Util/NumTheoryUtil.v

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Lemma x_nonneg: 0 <= x. Proof using prime_p x_id. clear -prime_p x_id. Z.prime_b
5858

5959
Lemma x_id_inv : x = (p - 1) / 2.
6060
Proof using x_id.
61+
clear neq_p_2.
6162
intros; apply Zeq_plus_swap in x_id.
6263
replace (p - 1) with (2 * ((p - 1) / 2)) in x_id by
6364
(symmetry; apply Z_div_exact_2; [lia | rewrite <- x_id; apply Z_mod_mult]).

src/Util/SideConditions/Autosolve.v

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
Require Import Crypto.Util.Decidable.
22
Require Import Crypto.Util.SideConditions.CorePackages.
3-
Require Import Crypto.Util.SideConditions.ModInvPackage.
43
Require Import Crypto.Util.SideConditions.ReductionPackages.
54
Require Import Crypto.Util.SideConditions.RingPackage.
65

76
Ltac autosolve_gen autosolve_tac ring_intros_tac else_tac :=
87
CorePackages.preautosolve ();
98
CorePackages.Internal.autosolve ltac:(fun _ =>
10-
ModInvPackage.autosolve ltac:(fun _ =>
119
ReductionPackages.autosolve autosolve_tac ltac:(fun _ =>
1210
RingPackage.autosolve_gen_intros ring_intros_tac ltac:(fun _ =>
1311
CorePackages.autosolve else_tac
14-
)))).
12+
))).
1513

1614
Ltac autosolve_gen_intros ring_intros_tac else_tac :=
1715
autosolve_gen ltac:(autosolve_gen_intros ring_intros_tac) ring_intros_tac else_tac.

src/Util/SideConditions/ModInvPackage.v

-24
This file was deleted.

0 commit comments

Comments
 (0)