aboutsummaryrefslogtreecommitdiff
path: root/src/Util
diff options
context:
space:
mode:
authorGravatar jadep <jadep@mit.edu>2019-03-12 15:53:08 -0400
committerGravatar jadephilipoom <jade.philipoom@gmail.com>2019-03-26 08:35:33 -0400
commitb18cfd89e1e8760185d9f50dd777c1c8096cf807 (patch)
treecab07339dfdc665a2f71491aad714252f2006a54 /src/Util
parenta201b0a8e525cab5c3cb019ccd707b7367aa3ecc (diff)
improve zero_bounds tactic
Diffstat (limited to 'src/Util')
-rw-r--r--src/Util/ZUtil/Tactics/ZeroBounds.v18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/Util/ZUtil/Tactics/ZeroBounds.v b/src/Util/ZUtil/Tactics/ZeroBounds.v
index 86501d84b..c81343b55 100644
--- a/src/Util/ZUtil/Tactics/ZeroBounds.v
+++ b/src/Util/ZUtil/Tactics/ZeroBounds.v
@@ -1,11 +1,12 @@
Require Import Coq.ZArith.ZArith Coq.omega.Omega.
Require Import Crypto.Util.ZUtil.Tactics.PrimeBound.
Require Import Crypto.Util.ZUtil.Div.
+Require Import Crypto.Util.ZUtil.Le.
Local Open Scope Z_scope.
Module Z.
(* prove that combinations of known positive/nonnegative numbers are positive/nonnegative *)
- Ltac zero_bounds' :=
+ Ltac zero_bounds'' :=
repeat match goal with
| [ |- 0 <= _ + _] => apply Z.add_nonneg_nonneg
| [ |- 0 <= _ - _] => apply Z.le_0_sub
@@ -14,14 +15,25 @@ Module Z.
| [ |- 0 <= _ ^ _ ] => apply Z.pow_nonneg
| [ |- 0 <= Z.shiftr _ _] => apply Z.shiftr_nonneg
| [ |- 0 <= _ mod _] => apply Z.mod_pos_bound
- | [ |- 0 < _ + _] => try solve [apply Z.add_pos_nonneg; zero_bounds'];
- try solve [apply Z.add_nonneg_pos; zero_bounds']
+ | [ |- 0 < _ + _] => try solve [apply Z.add_pos_nonneg; zero_bounds''];
+ try solve [apply Z.add_nonneg_pos; zero_bounds'']
| [ |- 0 < _ - _] => apply Z.lt_0_sub
| [ |- 0 < _ * _] => apply Z.lt_0_mul; left; split
| [ |- 0 < _ / _] => apply Z.div_str_pos
| [ |- 0 < _ ^ _ ] => apply Z.pow_pos_nonneg
end; try omega; try Z.prime_bound; auto.
+ Ltac zero_bounds' :=
+ repeat match goal with
+ | |- ?a <> 0 => apply Z.positive_is_nonzero
+ | |- ?a > 0 => apply Z.lt_gt
+ | |- ?a >= 0 => apply Z.le_ge
+ end;
+ try match goal with
+ | |- 0 < ?a => zero_bounds''
+ | |- 0 <= ?a => zero_bounds''
+ end.
+
Ltac zero_bounds := try omega; try Z.prime_bound; zero_bounds'.
Hint Extern 1 => progress zero_bounds : zero_bounds.