aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jason Gross <jagro@google.com>2016-08-01 16:39:16 -0700
committerGravatar Jason Gross <jagro@google.com>2016-08-01 16:39:21 -0700
commit24f3cd9c17b07e242f6fb8fdca61b467c8343be5 (patch)
treeaffb6e5afb59f723c504ec7a847864689996a7e6 /src
parent4fe4323eddb4f9e0ff9d7f923921f1ae6967a668 (diff)
Add pull_Zmod tactic
Diffstat (limited to 'src')
-rw-r--r--src/Util/ZUtil.v19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Util/ZUtil.v b/src/Util/ZUtil.v
index 3ab0b25f7..7a654d48f 100644
--- a/src/Util/ZUtil.v
+++ b/src/Util/ZUtil.v
@@ -1312,3 +1312,22 @@ Ltac push_Zmod_hyps :=
| [ H : context[(?x * ?y) mod ?z] |- _ ]
=> rewrite (Z.mul_mod_r_push x y z) in H by (Z.NoZMod || lia)
end.
+
+Ltac has_no_mod x z :=
+ lazymatch x with
+ | context[_ mod z] => fail
+ | _ => idtac
+ end.
+Ltac pull_Zmod :=
+ repeat match goal with
+ | [ |- context[((?x mod ?z) * (?y mod ?z)) mod ?z] ]
+ => has_no_mod x z; has_no_mod y z;
+ rewrite <- (Z.mul_mod x y z) by lia
+ | [ |- context[((?x mod ?z) * ?y) mod ?z] ]
+ => has_no_mod x z; has_no_mod y z;
+ rewrite <- (Z.mul_mod_l x y z) by lia
+ | [ |- context[(?x * (?y mod ?z)) mod ?z] ]
+ => has_no_mod x z; has_no_mod y z;
+ rewrite <- (Z.mul_mod_r x y z) by lia
+ | _ => progress autorewrite with pull_Zmod
+ end.