summaryrefslogtreecommitdiff
path: root/mips/mips_extras.v
diff options
context:
space:
mode:
authorBrian Campbell2018-07-02 17:56:23 +0100
committerBrian Campbell2018-07-02 18:49:29 +0100
commitfe5e67979d26bfa3c8c51863b24d97ab5553d56b (patch)
tree86593f222029a07ad70dd5ed752345f984abc3fd /mips/mips_extras.v
parente6b40776a3c963ad3d16b644ba283d2d955cf0b5 (diff)
Coq modulus operation that fits the type
Diffstat (limited to 'mips/mips_extras.v')
-rw-r--r--mips/mips_extras.v10
1 files changed, 10 insertions, 0 deletions
diff --git a/mips/mips_extras.v b/mips/mips_extras.v
index b9dd6138..94e4779c 100644
--- a/mips/mips_extras.v
+++ b/mips/mips_extras.v
@@ -138,6 +138,16 @@ Definition eq_bit (x : bitU) (y : bitU) : bool :=
| _,_ => false
end.
+Require Import Zeuclid.
+Definition euclid_modulo (m n : Z) `{ArithFact (n > 0)} : {z : Z & ArithFact (0 <= z <= n-1)}.
+refine (build_ex (ZEuclid.modulo m n)).
+constructor.
+destruct H.
+assert (Zabs n = n). { rewrite Zabs_eq; auto with zarith. }
+rewrite <- H at 3.
+lapply (ZEuclid.mod_always_pos m n); omega.
+Qed.
+
(* Override the more general version *)
Definition mults_vec {n} (l : mword n) (r : mword n) : mword (2 * n) := mults_vec l r.