Ltac zero_or_not a :=
  destruct (Z.eq_dec a 0);
  [subst; rewrite ?Zmod_0_l, ?Zdiv_0_l, ?Zmod_0_r, ?Zdiv_0_r;
   auto with zarith|].

(* Specifications: *)
Lemma Zmod_1_r: forall a, a mod 1 = 0.
Lemma Zdiv_1_r: forall a, a/1 = a.
Lemma Zdiv_1_l: forall a, 1 < a -> 1/a = 0.
Lemma Zmod_1_l: forall a, 1 < a -> 1 mod a = 1.
Lemma Z_div_same_full : forall a:Z, a<>0 -> a/a = 1.
Lemma Z_mod_same_full : forall a, a mod a = 0.
Lemma Z_mod_mult : forall a b, (a*b) mod b = 0.
Lemma Z_div_mult_full : forall a b:Z, b <> 0 -> (a*b)/b = a.
Lemma Z_div_pos: forall a b, b > 0 -> 0 <= a -> 0 <= a/b.
Lemma Z_div_ge0: forall a b, b > 0 -> a >= 0 -> a/b >=0.
Lemma Z_div_nonneg_nonneg : forall a b, 0 <= a -> 0 <= b -> 0 <= a / b.
Lemma Z_mod_nonneg_nonneg : forall a b, 0 <= a -> 0 <= b -> 0 <= a mod b.
Lemma Z_div_lt : forall a b:Z, b >= 2 -> a > 0 -> a/b < a.
Theorem Zdiv_small: forall a b, 0 <= a < b -> a/b = 0.
Theorem Zmod_small: forall a n, 0 <= a < n -> a mod n = a.
Lemma Z_div_ge : forall a b c:Z, c > 0 -> a >= b -> a/c >= b/c.
Lemma Z_div_le : forall a b c:Z, c > 0 -> a <= b -> a/c <= b/c.
Lemma Z_mult_div_ge : forall a b:Z, b > 0 -> b*(a/b) <= a.
Lemma Z_mult_div_ge_neg : forall a b:Z, b < 0 -> b*(a/b) >= a.
Lemma Z_div_exact_full_1 : forall a b:Z, a = b*(a/b) -> a mod b = 0.
Lemma Z_div_exact_full_2 : forall a b:Z, b <> 0 -> a mod b = 0 -> a = b*(a/b).
Theorem Zmod_le: forall a b, 0 < b -> 0 <= a -> a mod b <= a.
Theorem Zdiv_lt_upper_bound: forall a b q, 0 < b -> a < q*b -> a/b < q.
Theorem Zdiv_le_upper_bound: forall a b q, 0 < b -> a <= q*b -> a/b <= q.
Theorem Zdiv_le_lower_bound: forall a b q, 0 < b -> q*b <= a -> q <= a/b.
Lemma Zdiv_le_compat_l: forall p q r, 0 <= p -> 0 < q < r -> p / r <= p / q.
Theorem Zdiv_sgn: forall a b, 0 <= Z.sgn (a/b) * Z.sgn a * Z.sgn b.
Lemma Z_mod_plus_full : forall a b c:Z, (a + b * c) mod c = a mod c.
Lemma Z_div_plus_full : forall a b c:Z, c <> 0 -> (a + b * c) / c = a / c + b.
Theorem Z_div_plus_full_l: forall a b c : Z, b <> 0 -> (a * b + c) / b = a + c / b.
Lemma Zdiv_opp_opp : forall a b:Z, (-a)/(-b) = a/b.
Lemma Zmod_opp_opp : forall a b:Z, (-a) mod (-b) = - (a mod b).
Lemma Z_mod_zero_opp_full : forall a b:Z, a mod b = 0 -> (-a) mod b = 0.
Lemma Z_mod_nz_opp_full : forall a b:Z, a mod b <> 0 -> (-a) mod b = b - (a mod b).
Lemma Z_mod_zero_opp_r : forall a b:Z, a mod b = 0 -> a mod (-b) = 0.
Lemma Z_mod_nz_opp_r : forall a b:Z, a mod b <> 0 -> a mod (-b) = (a mod b) - b.
Lemma Z_div_zero_opp_full : forall a b:Z, a mod b = 0 -> (-a)/b = -(a/b).
Lemma Z_div_nz_opp_full : forall a b:Z, b <> 0 -> a mod b <> 0 -> (-a)/b = -(a/b)-1.
Lemma Z_div_zero_opp_r : forall a b:Z, a mod b = 0 -> a/(-b) = -(a/b).
Lemma Z_div_nz_opp_r : forall a b:Z, b <> 0 -> a mod b <> 0 -> a/(-b) = -(a/b)-1.
Lemma Zdiv_mult_cancel_r : forall a b c:Z, c <> 0 -> (a*c)/(b*c) = a/b.
Lemma Zdiv_mult_cancel_l : forall a b c:Z, c<>0 -> (c*a)/(c*b) = a/b.
Lemma Zmult_mod_distr_l: forall a b c, (c*a) mod (c*b) = c * (a mod b).
Lemma Zmult_mod_distr_r: forall a b c, (a*c) mod (b*c) = (a mod b) * c.
Theorem Zmod_mod: forall a n, (a mod n) mod n = a mod n.
Theorem Zmult_mod: forall a b n, (a * b) mod n = ((a mod n) * (b mod n)) mod n.
Theorem Zplus_mod: forall a b n, (a + b) mod n = (a mod n + b mod n) mod n.
Theorem Zminus_mod: forall a b n, (a - b) mod n = (a mod n - b mod n) mod n.
Lemma Zplus_mod_idemp_l: forall a b n, (a mod n + b) mod n = (a + b) mod n.
Lemma Zplus_mod_idemp_r: forall a b n, (b + a mod n) mod n = (b + a) mod n.
Lemma Zminus_mod_idemp_l: forall a b n, (a mod n - b) mod n = (a - b) mod n.
Lemma Zminus_mod_idemp_r: forall a b n, (a - b mod n) mod n = (a - b) mod n.
Lemma Zmult_mod_idemp_l: forall a b n, (a mod n * b) mod n = (a * b) mod n.
Lemma Zmult_mod_idemp_r: forall a b n, (b * (a mod n)) mod n = (b * a) mod n.