Inductive is_gcdZ : Z -> Z -> Z -> Prop :=
  | gcd_OZ : forall b : Z, is_gcdZ 0%Z b (Zabs b)
  | gcd_mod :
      forall b a d q r : Z,
      b <> 0%Z ->
      (0 <= r < Zabs b)%Z ->
      a = (b * q + r)%Z -> is_gcdZ r b d -> is_gcdZ b a d.Inductive is_gcdZ : Z -> Z -> Z -> Prop :=
  | gcd_OZ : forall b : Z, is_gcdZ 0%Z b (Zabs b)
  | gcd_mod :
      forall b a d q r : Z,
      b <> 0%Z ->
      (0 <= r < Zabs b)%Z ->
      a = (b * q + r)%Z -> is_gcdZ r b d -> is_gcdZ b a d.Inductive is_gcdZ : Z -> Z -> Z -> Prop :=
  | gcd_OZ : forall b : Z, is_gcdZ 0%Z b (Zabs b)
  | gcd_mod :
      forall b a d q r : Z,
      b <> 0%Z ->
      (0 <= r < Zabs b)%Z ->
      a = (b * q + r)%Z -> is_gcdZ r b d -> is_gcdZ b a d.Definition have_gcdZ (a b : Z) := {d : Z | is_gcdZ a b d}.Definition gcdZ_i (a b : Z) := exist (is_gcdZ a b).Definition P (a : Z) := forall b : Z, have_gcdZ a b.

Lemma gcdZ_is_gcd : forall a b d : Z, is_gcdZ a b d -> is_gcd Z IdZ Zmult 0%Z a b d.