(* Doubling. *)

Fixpoint double_rec n := if n is n'.+1 then n'.*2%Nrec.+2 else 0
where "n .*2" := (double_rec n) : nat_rec_scope.(* Doubling. *)

Fixpoint double_rec n := if n is n'.+1 then n'.*2%Nrec.+2 else 0
where "n .*2" := (double_rec n) : nat_rec_scope.Definition double := nosimpl double_rec.

(* Specifications: *)
Lemma doubleE : double = double_rec.
Lemma double0 : 0.*2 = 0.
Lemma doubleS n : n.+1.*2 = n.*2.+2.
Lemma addnn n : n + n = n.*2.
Lemma mul2n m : 2 * m = m.*2.
Lemma muln2 m : m * 2 = m.*2.
Lemma doubleD m n : (m + n).*2 = m.*2 + n.*2.
Lemma doubleB m n : (m - n).*2 = m.*2 - n.*2.
Lemma leq_double m n : (m.*2 <= n.*2) = (m <= n).
Lemma ltn_double m n : (m.*2 < n.*2) = (m < n).
Lemma ltn_Sdouble m n : (m.*2.+1 < n.*2) = (m < n).
Lemma leq_Sdouble m n : (m.*2 <= n.*2.+1) = (m <= n).
Lemma odd_double n : odd n.*2 = false.
Lemma double_gt0 n : (0 < n.*2) = (0 < n).
Lemma doubleMl m n : (m * n).*2 = m.*2 * n.
Lemma doubleMr m n : (m * n).*2 = m * n.*2.