unfold ltof;unfold f;intros.
case (lt_eq_lt_dec (fst x) (snd x));intro.
case s;intro.
case (eq_nat_dec (fst x) 0);intro.
rewrite e;exists (snd x);apply gcd_zero.
elim (H ((fst x),(remainder_euclide (snd x) (fst x) n)));simpl.
intro d;intro.
exists d.
apply gcd_sym.
elim (gcd_euclide d (snd x) (fst x) n);auto.
generalize (rem_euclide (snd x) (fst x) n);try omega.
rewrite e;exists (snd x);apply gcd_refl.
case (eq_nat_dec (snd x) 0);intro.
rewrite e;exists (fst x);apply gcd_sym;apply gcd_zero.
elim (H ((snd x),(remainder_euclide (fst x) (snd x) n)));simpl.
intro d;intro.
exists d.
elim (gcd_euclide d (fst x) (snd x) n);auto.
generalize (rem_euclide (fst x) (snd x) n);try omega.
Qed.

(** efficient algorithm to compute gcd(a,b) *)
Theorem gcd_exists_bis : forall (a b:nat),{d:nat | (is_gcd d a b)}.
intros.