proposition: Lemma wordToNat_natToWord_pred: forall {sz} (w: word sz), w <> wzero sz -> pred (wordToNat w) = wordToNat (w ^- (natToWord sz 1)).
proof: Proof. intros; remember (wordToNat w) as wn; destruct wn; simpl in *. - elim H. apply wordToNat_inj. rewrite roundTrip_0; auto. - apply natToWord_inj with (sz:= sz). + rewrite natToWord_wordToNat. apply wplus_cancel with (c:= (natToWord sz 1)). rewrite wminus_def, <-wplus_assoc. rewrite wplus_comm with (x:= ^~ (natToWord sz 1)). rewrite wminus_inv. rewrite wplus_comm with (x:= w). rewrite wplus_unit. rewrite wplus_comm, <-natToWord_S. apply wordToNat_inj. rewrite wordToNat_natToWord_2; auto. rewrite Heqwn. apply wordToNat_bound. + pose proof (wordToNat_bound w); lia. + apply wordToNat_bound. 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