| 1 |
From Coq Require Import Bool. |
| 2 |
From Coq Require Import ZArith. |
| 3 |
|
| 4 |
Require Import Crypto.Util.ZUtil.Definitions. |
| 5 |
Require Import Crypto.Util.ZUtil.Testbit. |
| 6 |
|
| 7 |
Require Import Crypto.Util.ZUtil.Tactics.SolveTestbit. |
| 8 |
|
| 9 |
Local Open Scope Z_scope. |
| 10 |
|
| 11 |
Module Z. |
| 12 |
Lemma ones_from_spec m k i |
| 13 |
(Hk : 0 <= k) : |
| 14 |
Z.testbit (Z.ones_from m k) i = if (i <? 0) then false else ((m - k) <=? i) && (i <? m). |
| 15 |
Proof. unfold Z.ones_from; Z.solve_testbit. Qed. |
| 16 |
|
| 17 |
Lemma ones_from_spec_full m k i : |
| 18 |
Z.testbit (Z.ones_from m k) i = if (i <? 0) then false else ((m - k) <=? i) && ((i <? m) || (k <? 0)). |
| 19 |
Proof. unfold Z.ones_from; Z.solve_testbit. Qed. |
| 20 |
|
| 21 |
#[global] |
| 22 |
Hint Rewrite ones_from_spec : testbit_rewrite. |
| 23 |
|
| 24 |
Lemma ones_from_0 m : Z.ones_from m 0 = 0. |
| 25 |
Proof. Z.solve_using_testbit. Qed. |
| 26 |
End Z. |