(** * Greatest common divisor (gcd). *)
   
(** There is no unicity of the gcd; hence we define the
    predicate [gcd a b d] expressing that [d] is a gcd of 
    [a] and [b]. (We show later that the [gcd] is actually
    unique if we discard its sign.) *)

Inductive gcd (a b d : Z) : Prop :=
    gcd_intro :
      (d | a)%Z ->
      (d | b)%Z ->
      (forall x : Z, (x | a)%Z -> (x | b)%Z -> (x | d)%Z) -> gcd a b d.(** * Greatest common divisor (gcd). *)
   
(** There is no unicity of the gcd; hence we define the
    predicate [gcd a b d] expressing that [d] is a gcd of 
    [a] and [b]. (We show later that the [gcd] is actually
    unique if we discard its sign.) *)

Inductive gcd (a b d : Z) : Prop :=
    gcd_intro :
      (d | a)%Z ->
      (d | b)%Z ->
      (forall x : Z, (x | a)%Z -> (x | b)%Z -> (x | d)%Z) -> gcd a b d.

(* Specifications: *)
Lemma gcd_sym : forall a b d : Z, gcd a b d -> gcd b a d.
Lemma gcd_0 : forall a : Z, gcd a 0 a.
Lemma gcd_minus : forall a b d : Z, gcd a (- b) d -> gcd b a d.
Lemma gcd_opp : forall a b d : Z, gcd a b d -> gcd b a (- d).
Lemma gcd_for_euclid : forall a b d q : Z, gcd b (a - q * b) d -> gcd a b d.