Definition logn p m := if prime p then logn_rec p m m else 0.

(* Specifications: *)
Lemma ltn_log0 p n : n < p -> logn p n = 0.
Lemma logn0 p : logn p 0 = 0.
Lemma logn1 p : logn p 1 = 0.
Lemma pfactor_gt0 p n : 0 < p ^ logn p n.
Lemma pfactor_coprime p n : prime p -> n > 0 -> {m | coprime p m & n = m * p ^ logn p n}.
Lemma pfactorK p n : prime p -> logn p (p ^ n) = n.
Lemma pfactorKpdiv p n : prime p -> logn (pdiv (p ^ n)) (p ^ n) = n.
Lemma ltn_logl p n : 0 < n -> logn p n < n.
Lemma logn_Gauss p m n : coprime p m -> logn p (m * n) = logn p n.
Lemma lognM p m n : 0 < m -> 0 < n -> logn p (m * n) = logn p m + logn p n.
Lemma lognX p m n : logn p (m ^ n) = n * logn p m.
Lemma trunc_logP p n : 1 < p -> 0 < n -> p ^ trunc_log p n <= n.
Lemma trunc_log_max p k j : 1 < p -> p ^ j <= k -> j <= trunc_log p k.