aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jason Gross <jagro@google.com>2018-08-24 22:12:31 -0400
committerGravatar Jason Gross <jagro@google.com>2018-08-24 22:12:31 -0400
commit0ed1016e3a072bc43461798863a6e811233e05fd (patch)
treeee2b3486dad611d2c21e75d55c2b1f21ea249770 /src
parent6e1cc16a0874df57a33293c9b5805f95c61b0146 (diff)
Minor rshi tweaks
Diffstat (limited to 'src')
-rw-r--r--src/Util/ZUtil/Rshi.v8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Util/ZUtil/Rshi.v b/src/Util/ZUtil/Rshi.v
index 132c7d8a6..fff2b68df 100644
--- a/src/Util/ZUtil/Rshi.v
+++ b/src/Util/ZUtil/Rshi.v
@@ -5,6 +5,7 @@ Require Import Crypto.Util.ZUtil.ZSimplify.Core.
Require Import Crypto.Util.ZUtil.ZSimplify.Simple.
Require Import Crypto.Util.ZUtil.Definitions.
Require Import Crypto.Util.ZUtil.Tactics.LtbToLt.
+Require Import Crypto.Util.ZUtil.Tactics.PullPush.Modulo.
Require Import Crypto.Util.ZUtil.Hints.PullPush.
Local Open Scope Z_scope.
@@ -26,6 +27,13 @@ Module Z.
| _ => omega
end.
Qed.
+
+ Lemma rshi_correct_full_alt : forall s a b n,
+ Z.rshi s a b n = if (0 <=? n)
+ then ((b + a * s) / 2 ^ n) mod s
+ else (b * 2 ^ (-n)) mod s.
+ Proof. intros; rewrite rshi_correct_full; push_Zmod; pull_Zmod; autorewrite with zsimplify_const; reflexivity. Qed.
+
Lemma rshi_correct : forall s a b n, 0 <= n -> s <> 0 ->
Z.rshi s a b n = ((b + a * s) / 2 ^ n) mod s.
Proof. intros; rewrite rshi_correct_full; break_match; Z.ltb_to_lt; omega. Qed.