@@ -1215,6 +1215,7 @@ Module SolinasReduction.
1215
1215
eval weight (2 * n) (mul_no_reduce base n p q) =
1216
1216
eval weight n p * Positional.eval weight n q.
1217
1217
Proof using base_nz n_gt_1 wprops.
1218
+ clear dependent s.
1218
1219
intros p q.
1219
1220
cbv [mul_no_reduce].
1220
1221
break_match.
@@ -1260,6 +1261,7 @@ Module SolinasReduction.
1260
1261
Theorem length_mul_no_reduce : forall p q,
1261
1262
length (mul_no_reduce base n p q) = (2 * n)%nat.
1262
1263
Proof using base_nz n_gt_1 wprops.
1264
+ clear dependent s.
1263
1265
intros; unfold mul_no_reduce; break_match; push.
1264
1266
Qed .
1265
1267
Hint Rewrite length_mul_no_reduce : push_length.
@@ -1322,6 +1324,7 @@ Module SolinasReduction.
1322
1324
(combine (map weight (seq 0 n)) (firstn n p),
1323
1325
(combine (map weight (seq 0 (m1 - n))) (skipn n p))).
1324
1326
Proof using n_gt_1 wprops.
1327
+ clear dependent s.
1325
1328
intros m1 p ? ?.
1326
1329
replace m1 with (n + (m1 - n))%nat at 1 by lia.
1327
1330
rewrite <-(firstn_skipn n p) at 1.
@@ -2432,13 +2435,13 @@ Module SolinasReduction.
2432
2435
Lemma sat_mul_comm (p q : list (Z * Z)) :
2433
2436
Associational.eval (Associational.sat_mul base p q) =
2434
2437
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 .
2436
2439
2437
2440
Lemma sat_mul_distr (p q1 q2 : list (Z * Z)) :
2438
2441
Associational.eval (Associational.sat_mul base p (q1 ++ q2)) =
2439
2442
Associational.eval (Associational.sat_mul base p q1) +
2440
2443
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 .
2442
2445
2443
2446
Lemma cons_to_app {A} a (p : list A) :
2444
2447
a :: p = [a] ++ p.
@@ -2451,6 +2454,7 @@ Module SolinasReduction.
2451
2454
eval weight m (fst (Rows.flatten' weight state inp)) =
2452
2455
(Rows.eval weight m inp + eval weight m (fst state) + weight m * snd state) mod weight m.
2453
2456
Proof using n_gt_1 wprops.
2457
+ clear dependent s.
2454
2458
intros.
2455
2459
rewrite Rows.flatten'_correct with (n:=m) by auto.
2456
2460
push.
@@ -2463,13 +2467,14 @@ Module SolinasReduction.
2463
2467
2464
2468
Lemma sum_one x :
2465
2469
sum [x] = x.
2466
- Proof . cbn; lia. Qed .
2470
+ Proof . clear dependent s; cbn; lia. Qed .
2467
2471
2468
2472
Lemma square_indiv_cons (p : list (Z * Z)) (a : Z * Z) :
2469
2473
Associational.eval (sqr_indiv base (a :: p)) =
2470
2474
Associational.eval (sqr_indiv base [a]) +
2471
2475
Associational.eval (sqr_indiv base p).
2472
2476
Proof using base_nz n_gt_1.
2477
+ clear dependent s.
2473
2478
cbv [sqr_indiv sqr_indiv'].
2474
2479
cbn [fold_right].
2475
2480
push.
@@ -2480,6 +2485,7 @@ Module SolinasReduction.
2480
2485
Associational.eval (sqr_indiv base (p ++ q)) =
2481
2486
Associational.eval (sqr_indiv base p) + Associational.eval (sqr_indiv base q).
2482
2487
Proof using base_nz n_gt_1.
2488
+ clear dependent s.
2483
2489
generalize dependent q.
2484
2490
induction p as [| a p IHp] using rev_ind; intros q.
2485
2491
push.
@@ -2497,6 +2503,7 @@ Module SolinasReduction.
2497
2503
(Associational.eval (sat_mul base [(weight 2, x1)] [(weight 2, x1)]) +
2498
2504
Associational.eval (sat_mul base [(weight 3, x2)] [(weight 3, x2)])))).
2499
2505
Proof using base_nz wprops n_gt_1.
2506
+ clear dependent s.
2500
2507
intros x x0 x1 x2 q H.
2501
2508
rewrite H.
2502
2509
cbv [to_associational].
@@ -2519,6 +2526,7 @@ Module SolinasReduction.
2519
2526
p = x :: x0 :: x1 :: x2 :: q ->
2520
2527
length (square1 base (to_associational weight 4 p)) = 8%nat.
2521
2528
Proof using base_nz wprops n_gt_1.
2529
+ clear dependent s.
2522
2530
intros x x0 x1 x2 q H.
2523
2531
cbv [square1].
2524
2532
push.
@@ -2547,6 +2555,7 @@ Module SolinasReduction.
2547
2555
(Associational.eval (sat_mul base [(weight 3, x2)] [(weight 1, x0)]) +
2548
2556
Associational.eval (sat_mul base [(weight 3, x2)] [(weight 2, x1)]))).
2549
2557
Proof using base_nz wprops n_gt_1.
2558
+ clear dependent s.
2550
2559
intros x x0 x1 x2 q bound H H1.
2551
2560
rewrite H1.
2552
2561
cbv [to_associational].
@@ -2612,6 +2621,7 @@ Module SolinasReduction.
2612
2621
p = x :: x0 :: x1 :: x2 :: q ->
2613
2622
0 <= eval weight 8 (square1 base (to_associational weight 4 p)) < weight 7.
2614
2623
Proof using base_nz wprops n_gt_1.
2624
+ clear dependent s.
2615
2625
intros x x0 x1 x2 q bound H H0.
2616
2626
erewrite eval_square1; [| eauto | eauto ].
2617
2627
rewrite H0 in H.
@@ -2635,6 +2645,7 @@ Module SolinasReduction.
2635
2645
Theorem eval_square_no_reduce (p : list Z) :
2636
2646
eval weight (2 * n) (square_no_reduce base n p) = (eval weight n p) * (eval weight n p).
2637
2647
Proof using base_nz wprops n_gt_1.
2648
+ clear dependent s.
2638
2649
rewrite <-eval_mul_no_reduce with (base:=base) by lia.
2639
2650
cbv [square_no_reduce].
2640
2651
break_match.
@@ -2729,6 +2740,7 @@ Module SolinasReduction.
2729
2740
Theorem length_square_no_reduce (p : list Z):
2730
2741
length (square_no_reduce base n p) = (2 * n)%nat.
2731
2742
Proof using base_nz wprops n_gt_1.
2743
+ clear dependent s.
2732
2744
cbv [square_no_reduce].
2733
2745
break_match.
2734
2746
rewrite Nat.eqb_eq in Heqb.
0 commit comments