aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jason Gross <jagro@google.com>2016-07-21 13:49:52 -0700
committerGravatar Jason Gross <jagro@google.com>2016-07-21 13:49:52 -0700
commitf4e35faa34145ab24aad021025b7d0d6e7f2214c (patch)
tree80812a88cb938682fe35f808e2db7c26f50a1641 /src
parentf2ff0b784cf671c608ece8ce081fecf8d24622f1 (diff)
Add more ZUtil
Diffstat (limited to 'src')
-rw-r--r--src/Util/ZUtil.v16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Util/ZUtil.v b/src/Util/ZUtil.v
index 370628b3c..d0aa12e58 100644
--- a/src/Util/ZUtil.v
+++ b/src/Util/ZUtil.v
@@ -984,6 +984,22 @@ Module Z.
Qed.
Hint Rewrite Z.div_mul_skip Z.div_mul_skip' using lia : zsimplify.
+
+ Lemma div_small_neg x y : 0 < -x < y -> x / y = -1.
+ Proof.
+ intro H; rewrite <- (Z.opp_involutive x).
+ rewrite Z.div_opp_l_complete by lia.
+ generalize dependent (-x); clear x; intros x H.
+ autorewrite with zsimplify; break_match; lia.
+ Qed.
+ Hint Rewrite div_small_neg using lia : zsimplify.
+
+ Lemma div_sub_small x y z : 0 <= x < z -> 0 <= y < z -> (x - y) / z = if x <? y then -1 else 0.
+ Proof.
+ pose proof (Zlt_cases x y).
+ intros; break_match; autorewrite with zsimplify; lia.
+ Qed.
+ Hint Rewrite div_small_neg using lia : zsimplify.
End Z.
Module Export BoundsTactics.