proposition: Lemma sext_combine: forall sz n (w: word (sz + n)) sz1 (w1: word sz1) sz2 (Hsz2: sz2 <> 0) (w2: word sz2), existT word _ w = existT word _ (combine w1 (sext w2 n)) -> exists sw, w = sext sw n /\ existT word _ sw = existT word _ (combine w1 w2).
proof: Proof. intros; unfold sext in H. remember (wmsb w2 false) as msb2; destruct msb2. - rewrite combine_assoc_existT in H. assert (sz = sz1 + sz2) by (apply eq_sigT_fst in H; lia); subst. destruct_existT. exists (combine w1 w2). split; [|reflexivity]. unfold sext. dependent destruction w2; [discriminate|]. rewrite wmsb_combine with (b2:= false) by discriminate. rewrite <-Heqmsb2. reflexivity. - rewrite combine_assoc_existT in H. assert (sz = sz1 + sz2) by (apply eq_sigT_fst in H; lia); subst. destruct_existT. exists (combine w1 w2). split; [|reflexivity]. unfold sext. dependent destruction w2; [intuition idtac|]. rewrite wmsb_combine with (b2:= false) by discriminate. rewrite <-Heqmsb2. 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