(* Copyright (C) 2005-2008 Sebastien Briais *)
(* http://lamp.epfl.ch/~sbriais/ *)
(* This library is free software; you can redistribute it and/or modify *)
(* it under the terms of the GNU Lesser General Public License as *)
(* published by the Free Software Foundation; either version 2.1 of the *)
(* License, or (at your option) any later version. *)
(* This library is distributed in the hope that it will be useful, but *)
(* WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *)
(* Lesser General Public License for more details. *)
(* You should have received a copy of the GNU Lesser General Public *)
(* License along with this library; if not, write to the Free Software *)
(* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *)
(* 02110-1301 USA *)
Unset Standard Proposition Elimination Names.
(** d is a common divisor of a and b if d | a and d | b *)
Definition is_cd (d a b : nat) := (divides a d)/\(divides b d).
(** d is a greatest common divisor of a and b if it is a maximal common divisor *)
Definition is_gcd (d a b:nat) := (is_cd d a b)/\(forall (d':nat),(is_cd d' a b)->(divides d d')).
unfold is_gcd.
intros.
elim H;elim H0;intros.
apply divides_antisym;auto.
Qed.
unfold is_gcd.
intros.
elim H;intros.
split.
red;red in H0;tauto.
intros.
apply H1.
red;red in H2;tauto.
Qed.
unfold is_gcd.
intro.
split.
red;split;[apply zero_max_div | apply divides_refl].
unfold is_cd;tauto.
Qed.
unfold is_gcd.
intros.
split.
red;split;[apply divides_refl | apply one_min_div].
unfold is_cd;tauto.
Qed.

(** if a <= b then gcd(a,b)=gcd(a,b-a) *)
Lemma gcd_minus : forall (d a b:nat),(a <= b)->((is_gcd d a b)<->(is_gcd d a (b-a))).