forked from mit-plv/fiat-crypto
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4005d1
commit b797484
Showing
2 changed files
with
22 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,21 @@ | ||
Require Import Coq.ZArith.ZArith. | ||
Require Import Crypto.Util.ZUtil.Divide. | ||
Local Open Scope Z_scope. | ||
|
||
Module Z. | ||
(** [rewrite_mod_divide] is a better version of [rewrite <- Z.mod_div_mod_full | ||
by rewrite_mod_divide_solver]; it backtracks across occurences | ||
that the solver fails to solve the side-conditions on. *) | ||
Ltac rewrite_mod_divide_solver := assumption. | ||
Ltac rewrite_mod_divide := | ||
repeat match goal with | ||
| [ |- context[(?a mod ?m) mod ?n] ] | ||
=> rewrite <- (@Z.mod_div_mod_full a m n) by rewrite_mod_divide_solver | ||
end. | ||
Ltac rewrite_mod_divide_in_hyps := | ||
repeat match goal with | ||
| [ H : context[(?a mod ?m) mod ?n] |- _ ] | ||
=> rewrite <- (@Z.mod_div_mod_full a m n) in H by rewrite_mod_divide_solver | ||
end. | ||
Ltac rewrite_mod_divide_in_all := repeat (rewrite_mod_divide || rewrite_mod_divide_in_hyps). | ||
End Z. |