proposition: Lemma uwordToZ_ZToWord_full (sz : nat) (width_nonneg : (0 < sz)%nat) (z : Z) : uwordToZ (ZToWord sz z) = z mod 2 ^ Z.of_nat sz.
proof: Proof. rewrite <-(ZToWord_Npow2_sub_z sz z (-Z.abs z)). rewrite Z_of_N_Npow2. rewrite uwordToZ_ZToWord_mod, <-Zminus_mod_idemp_r, Z_mod_mult, Z.sub_0_r; trivial. eapply Zle_minus_le_0. rewrite Z.mul_opp_l. replace z with (-(-z)) at 2 by Lia.lia. rewrite <-Z.opp_le_mono. etransitivity; cycle 1. { eapply Z.mul_le_mono_nonneg_l; [Lia.lia|]. eapply Z.pow_le_mono_r; [Lia.lia|]. instantiate (1:= 1); Lia.lia. } change (2^1) with 2. Lia.lia. 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