(** Zeven, used for rounding to nearest, ties to even *)
Definition Zeven (n : Z) :=
  match n with
  | Zpos (xO _) => true
  | Zneg (xO _) => true
  | Z0 => true
  | _ => false
  end.

(* Specifications: *)
Theorem Zeven_mult : forall x y, Zeven (x * y) = orb (Zeven x) (Zeven y).
Theorem Zeven_opp : forall x, Zeven (- x) = Zeven x.
Theorem Zeven_ex : forall x, exists p, x = (2 * p + if Zeven x then 0 else 1)%Z.
Theorem Zeven_2xp1 : forall n, Zeven (2 * n + 1) = false.
Theorem Zeven_plus : forall x y, Zeven (x + y) = Bool.eqb (Zeven x) (Zeven y).
Theorem Zpower_plus : forall n k1 k2, (0 <= k1)%Z -> (0 <= k2)%Z -> Zpower n (k1 + k2) = (Zpower n k1 * Zpower n k2)%Z.
Theorem Zpower_Zpower_nat : forall b e, (0 <= e)%Z -> Zpower b e = Zpower_nat b (Zabs_nat e).
Theorem Zpower_nat_S : forall b e, Zpower_nat b (S e) = (b * Zpower_nat b e)%Z.
Theorem Zpower_pos_gt_0 : forall b p, (0 < b)%Z -> (0 < Zpower_pos b p)%Z.
Theorem Zeven_Zpower : forall b e, (0 < e)%Z -> Zeven (Zpower b e) = Zeven b.
Theorem Zeven_Zpower_odd : forall b e, (0 <= e)%Z -> Zeven b = false -> Zeven (Zpower b e) = false.
Theorem Zeven_mult : forall x y, Zeven (x * y) = orb (Zeven x) (Zeven y).
Theorem Zeven_opp : forall x, Zeven (- x) = Zeven x.
Theorem Zeven_ex : forall x, exists p, x = (2 * p + if Zeven x then 0 else 1)%Z.
Theorem Zeven_2xp1 : forall n, Zeven (2 * n + 1) = false.
Theorem Zeven_plus : forall x y, Zeven (x + y) = Bool.eqb (Zeven x) (Zeven y).
Theorem Zpower_plus : forall n k1 k2, (0 <= k1)%Z -> (0 <= k2)%Z -> Zpower n (k1 + k2) = (Zpower n k1 * Zpower n k2)%Z.
Theorem Zpower_Zpower_nat : forall b e, (0 <= e)%Z -> Zpower b e = Zpower_nat b (Zabs_nat e).
Theorem Zpower_nat_S : forall b e, Zpower_nat b (S e) = (b * Zpower_nat b e)%Z.
Theorem Zpower_pos_gt_0 : forall b p, (0 < b)%Z -> (0 < Zpower_pos b p)%Z.
Theorem Zeven_Zpower : forall b e, (0 < e)%Z -> Zeven (Zpower b e) = Zeven b.
Theorem Zeven_Zpower_odd : forall b e, (0 <= e)%Z -> Zeven b = false -> Zeven (Zpower b e) = false.