proposition: Lemma zext_size: forall sz n (w: word (sz + n)), (- Z.of_nat (pow2 sz) <= wordToZ w < Z.of_nat (pow2 sz))%Z -> wmsb w false = false -> exists sw, w = zext sw n.
proof: Proof. intros. destruct n. - exists (eq_rect _ word w _ (Nat.add_comm _ _)). rewrite zext_zero. apply eq_sym, eq_rect_2. - apply word_exists_bound in H. destruct H as [ssw ?]. assert (wmsb ssw false = false). { apply wmsb_false_pos; apply wmsb_false_pos in H0. rewrite H; assumption. } eexists. apply wordToZ_inj. rewrite zext_wordToNat_equal_Z by discriminate. rewrite <-H. rewrite <-wordToZ_wordToNat_pos by assumption. rewrite wmsb_false_wordToNat_eq by assumption. 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