Section prime_rect.
Variables (P : nat -> Type)
(HP0 : P 0)
(HP1 : P 1)
(HPp : forall p, prime p -> P p)
(HPm : forall x y, P x -> P y -> P (x*y)).
End prime_rect.
Fact rel_prime_mult a b c : is_gcd a c 1 -> is_gcd b c 1 -> is_gcd (a*b) c 1.
Fact is_rel_prime_mult p q l : is_gcd p q 1 -> is_gcd p l 1 -> is_gcd p (q*l) 1.
Fact is_rel_prime_expo p q l : is_gcd p q 1 -> is_gcd p (mscal mult 1 l q) 1.
(* Every positive number is the product of a list of primes *)
Notation lprod := (fold_right mult 1).
Fact lprod_ge_1 l : Forall prime l -> 1 <= lprod l.
Fact lprod_app l m : lprod (l++m) = lprod l * lprod m.
Hint Resolve lprod_ge_1 prime_ge_2 : core.
Fact prime_in_decomp p l : prime p -> Forall prime l -> p <d lprod l -> In p l.
(* Prime decomposition is unique up-to permutation *)

Theorem prime_decomp_uniq l m : Forall prime l -> Forall prime m -> lprod l = lprod m -> l ~p m.