-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some ZUtil/Land/Fold.v lemmas (#1487)
- Loading branch information
1 parent
c1d2772
commit 9bb2e2a
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Require Import Coq.ZArith.ZArith. | ||
Require Import Coq.micromega.Lia. | ||
Require Import Coq.Lists.List. | ||
Require Import Crypto.Util.ZUtil.Land. | ||
Require Import Crypto.Util.ZUtil.Hints.Core. | ||
Local Open Scope bool_scope. Local Open Scope Z_scope. | ||
|
||
Module Z. | ||
Lemma fold_right_land_m1_cps v ls | ||
: fold_right Z.land v ls | ||
= Z.land (fold_right Z.land (-1) ls) v. | ||
Proof. | ||
induction ls as [|?? IH]; cbn [fold_right]. | ||
{ now rewrite Z.land_m1'_l. } | ||
{ rewrite <- !Z.land_assoc, IH; reflexivity. } | ||
Qed. | ||
|
||
Lemma fold_right_land_ones_id sz ls | ||
: Z.land (fold_right Z.land (Z.ones sz) ls) (Z.ones sz) | ||
= Z.land (fold_right Z.land (-1) ls) (Z.ones sz). | ||
Proof. | ||
rewrite fold_right_land_m1_cps, <- Z.land_assoc, Z.land_diag. | ||
reflexivity. | ||
Qed. | ||
End Z. |