proposition: Lemma ZToWord_wordToZ: forall sz (w: word sz), ZToWord sz (wordToZ w) = w.
proof: Proof. unfold ZToWord, wordToZ; intros. remember (wmsb w false) as msb; destruct msb. - remember (wordToN (wneg w)) as ww. destruct ww. + assert (wneg w = wzero _). { apply wordToN_inj; rewrite <-Heqww. rewrite wordToN_nat. rewrite roundTrip_0. reflexivity. } rewrite wzero'_def. rewrite <-wneg_idempotent, H. apply eq_sym, wzero_wneg. + assert (wneg w = NToWord _ (N.pos p)). { apply wordToN_inj; rewrite Heqww. rewrite NToWord_wordToN. reflexivity. } rewrite <-wneg_idempotent, H. reflexivity. - remember (wordToN w) as ww. destruct ww. + assert (w = wzero _); subst. { apply wordToN_inj; rewrite <-Heqww. rewrite wordToN_nat. rewrite roundTrip_0. reflexivity. } apply wzero'_def. + assert (w = NToWord _ (N.pos p)); subst. { apply wordToN_inj; rewrite Heqww. rewrite NToWord_wordToN. reflexivity. } reflexivity. 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