pnat

+ is the type of positive natural numbers. It is defined as a subtype, and the VM representation of + is the same as because the proof is not stored.

nat.to_pnat

Convert a natural number to a positive natural number. The positivity assumption is inferred by dec_trivial.

nat.succ_pnat

Write a successor as an element of +.

nat.to_pnat'

Convert a natural number to a pnat. n+1 is mapped to itself, and 0 becomes 1.

pnat.decidable_eq

We now define a long list of structures on ℕ+ induced by similar structures on ℕ. Most of these behave in a completely obvious way, but there are a few things to be said about subtraction, division and powers.

pnat.has_sub

Subtraction a - b is defined in the obvious way when a > b, and by a - b = 1 if a ≤ b.

pnat.mod_div_aux

We define m % k and m / k in the same way as for nat except that when m = n * k we take m % k = k and m / k = n - 1. This ensures that m % k is always positive and m = (m % k) + k * (m / k) in all cases. Later we define a function div_exact which gives the usual m / k in the case where k divides m.