proposition: Lemma sext_size: forall sz n (w: word (sz + n)), sz <> 0 -> (- Z.of_nat (pow2 (sz - 1)) <= wordToZ w < Z.of_nat (pow2 (sz - 1)))%Z -> exists sw, w = sext sw n.
proof: Proof. intros. destruct sz; [exfalso; auto|clear H]. simpl in *. replace (sz - 0) with sz in H0 by lia. apply word_exists_bound in H0. destruct H0 as [sw ?]. exists sw. apply wordToZ_inj. change (S (sz + n)) with (S sz + n). rewrite sext_wordToZ. auto. 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