Skip to content

Commit b844b34

Browse files
committed
Move a lemma to util
1 parent 2872ecd commit b844b34

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Assembly/WithBedrock/Proofs.v

+1-10
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ Local Open Scope list_scope.
6666
(* TODO: move to global settings *)
6767
Local Set Keyed Unification.
6868

69-
Local Lemma land_ones_eq_of_bounded v n
70-
(H : (0 <= v < 2 ^ (Z.of_N n))%Z)
71-
: Z.land v (Z.ones (Z.of_N n)) = v.
72-
Proof.
73-
rewrite Z.land_ones by lia.
74-
rewrite Z.mod_small by lia.
75-
reflexivity.
76-
Qed.
77-
7869
Import Map.Interface Map.Separation. (* for coercions *)
7970
Require Import bedrock2.Array.
8071
Require Import bedrock2.ZnWords.
@@ -304,7 +295,7 @@ Proof.
304295
cbv [R_regs R_reg Tuple.fieldwise Tuple.fieldwise' eval_idx_Z] in *; cbn [fst snd].
305296
repeat apply conj; intros; inversion_option; subst; try assumption.
306297
all: change 64%Z with (Z.of_N 64).
307-
all: rewrite land_ones_eq_of_bounded; [ reflexivity | ].
298+
all: rewrite Z.land_ones_eq_of_bounded; [ reflexivity | ].
308299
all: assumption.
309300
Qed.
310301

src/Util/ZUtil/Land.v

+11-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Module Z.
6767
intros. rewrite Z.sub_1_r, <- Z.ones_equiv.
6868
apply Z.land_ones; auto with zarith.
6969
Qed.
70-
70+
7171
Lemma land_pow2_testbit a b :
7272
a &' 2^b = if Z.testbit a b then 2^b else 0.
7373
Proof.
@@ -96,6 +96,15 @@ Module Z.
9696
Proof.
9797
destruct (Z.ltb_spec b 0).
9898
- now rewrite Pow.Z.base_pow_neg, Z.land_0_r.
99-
- rewrite land_pow2_testbit, Z.div2_bits, Testbit.Z.bits_above_pow2;
99+
- rewrite land_pow2_testbit, Z.div2_bits, Testbit.Z.bits_above_pow2;
100100
try (replace (Z.succ b) with (b + 1); nia). Qed.
101+
102+
Lemma land_ones_eq_of_bounded v n
103+
(H : (0 <= v < 2 ^ (Z.of_N n))%Z)
104+
: Z.land v (Z.ones (Z.of_N n)) = v.
105+
Proof.
106+
rewrite Z.land_ones by lia.
107+
rewrite Z.mod_small by lia.
108+
reflexivity.
109+
Qed.
101110
End Z.

0 commit comments

Comments
 (0)