Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some ZUtil/Land/Fold.v lemmas #1487

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Util/ZUtil.v
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Require Crypto.Util.ZUtil.Hints.PullPush.
Require Crypto.Util.ZUtil.Hints.ZArith.
Require Crypto.Util.ZUtil.Hints.Ztestbit.
Require Crypto.Util.ZUtil.Land.
Require Crypto.Util.ZUtil.Land.Fold.
Require Crypto.Util.ZUtil.LandLorBounds.
Require Crypto.Util.ZUtil.LandLorShiftBounds.
Require Crypto.Util.ZUtil.Lor.
Expand Down
25 changes: 25 additions & 0 deletions src/Util/ZUtil/Land/Fold.v
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.