| 1 |
From Coq Require Import ZArith. |
| 2 |
From Coq Require Import Lia. |
| 3 |
From Coq Require Import List. |
| 4 |
Require Import Crypto.Util.ZUtil.Land. |
| 5 |
Require Import Crypto.Util.ZUtil.Hints.Core. |
| 6 |
Local Open Scope bool_scope. Local Open Scope Z_scope. |
| 7 |
|
| 8 |
Module Z. |
| 9 |
Lemma fold_right_land_m1_cps v ls |
| 10 |
: fold_right Z.land v ls |
| 11 |
= Z.land (fold_right Z.land (-1) ls) v. |
| 12 |
Proof. |
| 13 |
induction ls as [|?? IH]; cbn [fold_right]. |
| 14 |
{ now rewrite Z.land_m1'_l. } |
| 15 |
{ rewrite <- !Z.land_assoc, IH; reflexivity. } |
| 16 |
Qed. |
| 17 |
|
| 18 |
Lemma fold_right_land_ones_id sz ls |
| 19 |
: Z.land (fold_right Z.land (Z.ones sz) ls) (Z.ones sz) |
| 20 |
= Z.land (fold_right Z.land (-1) ls) (Z.ones sz). |
| 21 |
Proof. |
| 22 |
rewrite fold_right_land_m1_cps, <- Z.land_assoc, Z.land_diag. |
| 23 |
reflexivity. |
| 24 |
Qed. |
| 25 |
End Z. |