induction l;simpl;intros.
left;exists 1;rewrite power_one;trivial.
destruct a.
assert (n<>0);try omega.
generalize (quo_rem_euclide n1 n H1);intro.
case (eq_nat_dec (remainder_euclide n1 n H1) 0);intro.
rewrite e in H2;rewrite plus_comm in H2;simpl in H2.
case IHl;intros;trivial.
inversion H;trivial.
elim s;intro y;intro.
rewrite H2.
left;rewrite p;rewrite (mult_comm n);rewrite <- power_power_lemma1;rewrite <- power_mult_lemma1;exists (power n0 (quotient_euclide n1 n H1)*y);trivial.
elim s;intro p;intro.
elim p0;intro q;intro.
elim p1;intro r;intro.
elim p2;intro k;intro.
elim p3;intros.
elim H4;intros.
elim H6;intros.
elim H8;intros.
right.
exists p;exists q;exists r.
rewrite H9;rewrite mult_comm;rewrite <- mult_assoc.
exists (k*(power n0 n1)).
split;trivial.
split;trivial.
split;trivial.
split;trivial.
apply rel_prime_mult;trivial.
inversion H.
rewrite H9 in H17.
elim (mult_rel_prime n0 (power p (q*n+r)) k H17);intros.
apply rel_prime_power;apply rel_prime_sym;apply power_rel_prime with (q*n+r);trivial.
rewrite plus_comm;auto with arith.
right.
exists n0;exists (quotient_euclide n1 n H1);exists (remainder_euclide n1 n H1).
rewrite (mult_comm (quotient_euclide n1 n H1));rewrite <- H2.
exists (refactor l).
elim (in_wf ((n0,n1)::l) n0 n1);intros.
split;trivial.
split;trivial.
destruct (remainder_euclide n1 n H1);try tauto;auto with arith.
split;trivial.
apply rem_euclide.
split;trivial.
inversion H;trivial.
simpl;tauto.
trivial.
Qed.

(* Specifications: *)
(** let n be a natural number and m>1 then either n=x^m or there is a prime number p and three numbers q,r and k such that n = p^(q*m+r)*k with 0<r<m and gcd(p,k)=1 *)
Lemma is_power_m_dec : forall (n m:nat),(m>0)->{x:nat | n=(power x m)}+{p:nat & {q:nat & {r:nat & {k:nat | (is_prime p)/\(0<r)/\(r<m)/\n=(power p (q*m+r))*k/\(rel_prime p k)}}}}.
intros n m;intro H.