proposition: Lemma ZToWord_Npow2_sub_z : forall (sz : nat) (z : Z) (k: Z), ZToWord sz (z - k * Z.of_N (Npow2 sz)) = ZToWord sz z.
proof: Proof. intros. destruct k. - simpl. f_equal. lia. - rewrite <- positive_nat_Z. apply ZToWord_Npow2_sub_k. - rewrite <- Pos2Z.opp_pos. replace (z - - Z.pos p * Z.of_N (Npow2 sz))%Z with (z + Z.pos p * Z.of_N (Npow2 sz))%Z by nia. rewrite <- positive_nat_Z. apply ZToWord_Npow2_add_k. 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