proposition: Lemma wordToN_NToWord: forall sz n, exists k, wordToN (NToWord sz n) = (n - k * Npow2 sz)%N /\ (k * Npow2 sz <= n)%N.
proof: Proof. intros. rewrite wordToN_nat, NToWord_nat. pose proof (wordToNat_natToWord sz (N.to_nat n)). destruct H as [k [? ?]]. exists (N.of_nat k). split. - apply N2Nat.inj. rewrite Nat2N.id, N2Nat.inj_sub, N2Nat.inj_mul. rewrite Nat2N.id. rewrite Npow2_nat. assumption. - rewrite nat_compare_le, Nat2N.inj_compare in H0. rewrite Nat2N.inj_mul, <-Npow2_nat in H0. do 2 rewrite N2Nat.id in H0. assumption. Qed.
imports: Coq.Classes.Morphisms Coq.Classes.Morphisms_Prop Coq.Classes.Equivalence Coq.Arith.PeanoNat Coq.ZArith.BinInt  Coq.Arith.Arith Coq.NArith.NArith Coq.Bool.Bool Coq.ZArith.ZArith Coq.Logic.Eqdep_dec Coq.Logic.EqdepFacts Coq.Program.Tactics Coq.Program.Equality Coq.setoid_ring.Ring Coq.setoid_ring.Ring_polynom bbv.Nomega bbv.ZLib bbv.NatLib bbv.NLib bbv.N_Z_nat_conversions bbv.DepEq bbv.DepEqNat bbv.ReservedNotations Coq.micromega.Lia