(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(*Recursive Definition addZ : Z -> Z -> Z := OZ   y => y | (pos O)   y => (succZ y) | (pos (S n1))   y => (succZ (addZ (pos n1) y)) | (neg O)   y => (predZ y) | (neg (S n1))   y => (predZ (addZ (neg n1) y)). *)
Fixpoint add1 (x2 : Z) (n : nat) {struct n} : Z :=
match n with
| O => succZ x2
| S n0 => succZ (add1 x2 n0)
end
with add2 (x2 : Z) (n : nat) {struct n} : Z :=
match n with
| O => predZ x2
| S n0 => predZ (add2 x2 n0)
end.
Definition addZ (x1 x2 : Z) : Z :=
match x1 with
| OZ => x2
| pos n => add1 x2 n
| neg n => add2 x2 n
end.

(* Specifications: *)
Lemma addZ_eq1 : forall y : Z, addZ OZ y = y.
Lemma addZ_eq2 : forall y : Z, addZ (pos 0) y = succZ y.
Lemma addZ_eq3 :
forall (n1 : nat) (y : Z), addZ (pos (S n1)) y = succZ (addZ (pos n1) y).
Lemma addZ_eq4 : forall y : Z, addZ (neg 0) y = predZ y.
Lemma addZ_eq5 :
forall (n1 : nat) (y : Z), addZ (neg (S n1)) y = predZ (addZ (neg n1) y).
Lemma succ_addZ_l : forall x y : Z, addZ (succZ x) y = succZ (addZ x y).
intro x; elim x; auto with arith.