Definition pfactor p e := p ^ e.Definition cons_pfactor (p e : nat) pd := ifnz e ((p, e) :: pd) pd.Notation "n `_ pi" := (partn n pi) : nat_scope.Definition primes n := unzip1 (prime_decomp n).Definition nat_pred := simpl_pred nat.Definition pi_unwrapped_arg := nat.Definition pi_wrapped_arg := wrapped nat.Coercion unwrap_pi_arg (wa : pi_wrapped_arg) : pi_unwrapped_arg := unwrap wa.Coercion pi_arg_of_nat (n : nat) := Wrap n : pi_wrapped_arg.Definition pdiv n := head 1 (primes n).Definition max_pdiv n := last 1 (primes n).Definition totient n := foldr add_totient_factor (n > 0) (prime_decomp n).

(* Specifications: *)
Lemma prime_gt1 p : prime p -> 1 < p.
Lemma prime_gt0 p : prime p -> 0 < p.
Lemma even_prime p : prime p -> p = 2 \/ odd p.
Lemma prime_oddPn p : prime p -> reflect (p = 2) (~~ odd p).
Lemma odd_prime_gt2 p : odd p -> prime p -> p > 2.
Lemma sorted_primes n : sorted ltn (primes n).
Lemma eq_primes m n : (primes m =i primes n) <-> (primes m = primes n).
Lemma primes_uniq n : uniq (primes n).
Lemma pdiv_prime n : 1 < n -> prime (pdiv n).
Lemma max_pdiv_prime n : n > 1 -> prime (max_pdiv n).
Lemma pdiv_leq n : 0 < n -> pdiv n <= n.
Lemma max_pdiv_leq n : 0 < n -> max_pdiv n <= n.
Lemma pdiv_gt0 n : 0 < pdiv n.
Lemma max_pdiv_gt0 n : 0 < max_pdiv n.
Lemma ltn_pdiv2_prime n : 0 < n -> n < pdiv n ^ 2 -> prime n.
Lemma primes_exp m n : n > 0 -> primes (m ^ n) = primes m.
Lemma coprime_has_primes m n : m > 0 -> n > 0 -> coprime m n = ~~ has (mem (primes m)) (primes n).
Lemma pdiv_id p : prime p -> pdiv p = p.
Lemma prime_above m : {p | m < p & prime p}.