| 1 |
From Coq Require Import ZArith. |
| 2 |
From Coq Require Import Morphisms. |
| 3 |
Require Import Crypto.Util.ZRange. |
| 4 |
Require Import Crypto.Util.ZRange.Operations. |
| 5 |
Require Import Crypto.Util.ZRange.BasicLemmas. |
| 6 |
Require Import Crypto.Util.ZRange.CornersMonotoneBounds. |
| 7 |
Require Import Crypto.Util.ZRange.LandLorBounds. |
| 8 |
Require Import Crypto.Util.ZUtil.Definitions. |
| 9 |
Require Import Crypto.Util.ZUtil.Morphisms. |
| 10 |
Require Import Crypto.Util.ZUtil.CC. |
| 11 |
Require Import Crypto.Util.Notations. |
| 12 |
|
| 13 |
Module ZRange. |
| 14 |
Local Ltac t := |
| 15 |
lazymatch goal with |
| 16 |
| [ |- is_bounded_by_bool (?f _) (ZRange.two_corners ?f _) = true ] |
| 17 |
=> apply (@ZRange.monotoneb_two_corners_gen f) |
| 18 |
| [ |- is_bounded_by_bool (?f _ _) (ZRange.four_corners ?f _ _) = true ] |
| 19 |
=> apply (@ZRange.monotoneb_four_corners_gen f) |
| 20 |
| [ |- is_bounded_by_bool (?f _ _) (ZRange.four_corners_and_zero ?f _ _) = true ] |
| 21 |
=> apply (@ZRange.monotoneb_four_corners_and_zero_gen f) |
| 22 |
end; |
| 23 |
eauto with zarith; |
| 24 |
repeat match goal with |
| 25 |
| [ |- forall x : Z, _ ] => let x := fresh "x" in intro x; destruct x |
| 26 |
end; |
| 27 |
eauto with zarith. |
| 28 |
|
| 29 |
Lemma is_bounded_by_bool_log2 |
| 30 |
x x_bs |
| 31 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 32 |
: is_bounded_by_bool (Z.log2 x) (ZRange.log2 x_bs) = true. |
| 33 |
Proof. t. Qed. |
| 34 |
|
| 35 |
Lemma is_bounded_by_bool_log2_up |
| 36 |
x x_bs |
| 37 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 38 |
: is_bounded_by_bool (Z.log2_up x) (ZRange.log2_up x_bs) = true. |
| 39 |
Proof. t. Qed. |
| 40 |
|
| 41 |
Lemma is_bounded_by_bool_add |
| 42 |
x x_bs y y_bs |
| 43 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 44 |
(Hboundedy : is_bounded_by_bool y y_bs = true) |
| 45 |
: is_bounded_by_bool (Z.add x y) (ZRange.add x_bs y_bs) = true. |
| 46 |
Proof. t. Qed. |
| 47 |
|
| 48 |
Lemma is_bounded_by_bool_sub |
| 49 |
x x_bs y y_bs |
| 50 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 51 |
(Hboundedy : is_bounded_by_bool y y_bs = true) |
| 52 |
: is_bounded_by_bool (Z.sub x y) (ZRange.sub x_bs y_bs) = true. |
| 53 |
Proof. t. Qed. |
| 54 |
|
| 55 |
Lemma is_bounded_by_bool_mul |
| 56 |
x x_bs y y_bs |
| 57 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 58 |
(Hboundedy : is_bounded_by_bool y y_bs = true) |
| 59 |
: is_bounded_by_bool (Z.mul x y) (ZRange.mul x_bs y_bs) = true. |
| 60 |
Proof. t. Qed. |
| 61 |
|
| 62 |
Lemma is_bounded_by_bool_div |
| 63 |
x x_bs y y_bs |
| 64 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 65 |
(Hboundedy : is_bounded_by_bool y y_bs = true) |
| 66 |
: is_bounded_by_bool (Z.div x y) (ZRange.div x_bs y_bs) = true. |
| 67 |
Proof. t. Qed. |
| 68 |
|
| 69 |
Lemma is_bounded_by_bool_shiftr |
| 70 |
x x_bs y y_bs |
| 71 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 72 |
(Hboundedy : is_bounded_by_bool y y_bs = true) |
| 73 |
: is_bounded_by_bool (Z.shiftr x y) (ZRange.shiftr x_bs y_bs) = true. |
| 74 |
Proof. t. Qed. |
| 75 |
|
| 76 |
Lemma is_bounded_by_bool_shiftl |
| 77 |
x x_bs y y_bs |
| 78 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 79 |
(Hboundedy : is_bounded_by_bool y y_bs = true) |
| 80 |
: is_bounded_by_bool (Z.shiftl x y) (ZRange.shiftl x_bs y_bs) = true. |
| 81 |
Proof. t. Qed. |
| 82 |
|
| 83 |
Lemma is_bounded_by_bool_cc_m |
| 84 |
s x x_bs |
| 85 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 86 |
: is_bounded_by_bool (Z.cc_m s x) (ZRange.cc_m s x_bs) = true. |
| 87 |
Proof. t. Qed. |
| 88 |
|
| 89 |
Lemma is_bounded_by_bool_land |
| 90 |
x x_bs y y_bs |
| 91 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 92 |
(Hboundedy : is_bounded_by_bool y y_bs = true) |
| 93 |
: is_bounded_by_bool (Z.land x y) (ZRange.land x_bs y_bs) = true. |
| 94 |
Proof. now apply ZRange.is_bounded_by_bool_land_bounds. Qed. |
| 95 |
|
| 96 |
Lemma is_bounded_by_bool_lor |
| 97 |
x x_bs y y_bs |
| 98 |
(Hboundedx : is_bounded_by_bool x x_bs = true) |
| 99 |
(Hboundedy : is_bounded_by_bool y y_bs = true) |
| 100 |
: is_bounded_by_bool (Z.lor x y) (ZRange.lor x_bs y_bs) = true. |
| 101 |
Proof. now apply ZRange.is_bounded_by_bool_lor_bounds. Qed. |
| 102 |
End ZRange. |