Definition primesGI (x : GI) :=
[seq i <- [seq GI_of_ord i| i : ordinalGI ('N x).+1] |
primeGI i && (i %| x)].

(* Specifications: *)
Lemma mem_primesGI  (p x : GI) :
(p \in primesGI x) = [&& primeGI p, x != 0 & p %| x].
Lemma eqGI_prime x y : x %= y -> primeGI x -> primeGI y.
Definition pdivGI x : GI := head 1 (primesGI x).
Lemma pdivGI_prime x : (1 < 'N x)%N -> primeGI (pdivGI x).
Lemma pdivGI_dvd x : pdivGI x %| x.
Lemma pdivGI_leq x : x != 0 -> ('N (pdivGI x) <= 'N x)%N.
Fixpoint logGI_rec p x n :=
if (p %| x) then
if n is n1.+1 then (logGI_rec p (x %/ p) n1).+1 else 0%N
else 0%N.