Section gcd_lcm.
Infix "div" := divides (at level 70, no associativity).
Hint Resolve divides_0 divides_refl divides_mult divides_1 : core.
Definition is_gcd p q r := r div p /\ r div q /\ forall k, k div p -> k div q -> k div r.
Definition is_lcm p q r := p div r /\ q div r /\ forall k, p div k -> q div k -> r div k.
Fact is_gcd_sym p q r : is_gcd p q r -> is_gcd q p r.
Fact is_gcd_minus p q r : p <= q -> is_gcd p q r -> is_gcd p (q-p) r.
Fact is_gcd_plus p q r : is_gcd p q r -> is_gcd p (q+p) r.
Fact is_gcd_div p q : p div q -> is_gcd p q p.
Hint Resolve divides_1 : core.
End bezout_rel_prime.
(* We need the simple form of Bezout above to show this *)
Fact is_rel_prime_div p q k : is_gcd p q 1 -> p div q*k -> p div k.
Fact is_rel_prime_div_r p q k : is_gcd p q 1 -> p div k*q -> p div k.
Fact is_rel_prime_lcm p q : is_gcd p q 1 -> is_lcm p q (p*q).
Hint Resolve divides_1 divides_mult_compat is_gcd_refl : core.
Fact is_gcd_0 p q : is_gcd p q 0 -> p = 0 /\ q = 0.
Fact is_gcd_rel_prime p q g : is_gcd p q g -> exists a b, p = a*g /\ q = b*g /\ is_gcd a b 1.
Fact is_lcm_mult p q l k : is_lcm p q l -> is_lcm (k*p) (k*q) (k*l).

Theorem is_gcd_lcm_mult p q g l : is_gcd p q g -> is_lcm p q l -> p*q = g*l.