Library Coq.Arith.Cantor
Implementation of the Cantor pairing and its inverse function 
Bijections between nat * nat and nat 
 
 Cantor pairing to_nat 
Cantor pairing inverse of_nat 
Definition of_nat (n : nat) : nat * nat :=
nat_rec _ (0, 0) (fun _ '(x, y) =>
match x with | S x => (x, S y) | _ => (S y, 0) end) n.
of_nat is the left inverse for to_nat 
to_nat is injective 
to_nat is the left inverse for of_nat 
of_nat is injective 
Polynomial specifications of to_nat 
Lemma to_nat_spec x y :
to_nat (x, y) * 2 = y * 2 + (y + x) * S (y + x).
Lemma to_nat_spec2 x y :
to_nat (x, y) = y + (y + x) * S (y + x) / 2.
to_nat is non-decreasing in (the sum of) pair components 
    
  