(* Contribution to the Coq Library   V6.3 (July 1999)                    *)
(****************************************************************************)
(*                 The Calculus of Inductive Constructions                  *)
(*                                                                          *)
(*                                Projet Coq                                *)
(*                                                                          *)
(*                     INRIA                        ENS-CNRS                *)
(*              Rocquencourt                        Lyon                    *)
(*                                                                          *)
(*                                Coq V5.10                                 *)
(*                              Nov 25th 1994                               *)
(*                                                                          *)
(****************************************************************************)
(*                                  Zadd.v                                  *)
(****************************************************************************)
Require Export Arith.
Require Export Nat_complements.
Require Export Lci.
Require Export groups.
Require Export rings.
Require Export Zbase.
Require Export Z_succ_pred.
(* Addition on Z, (Z, +) is a group *)
(*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)).*)
(* this definition introduces unnecessary names *)
Fixpoint addpos (x2 : Z) (n : nat) {struct n} : Z :=
match n with
| O => succZ x2
| S n0 => succZ (addpos x2 n0)
end.
Fixpoint addneg (x2 : Z) (n : nat) {struct n} : Z :=
match n with
| O => predZ x2
| S n0 => predZ (addneg x2 n0)
end.
Definition addZ (x1 x2 : Z) :=
match x1 with
| OZ => x2
| pos n => addpos x2 n
| neg n => addneg x2 n
end.

Lemma addZ_eq5 :
forall (n1 : nat) (y : Z), addZ (neg (S n1)) y = predZ (addZ (neg n1) y).