proposition: Lemma sext_wplus_exist: forall sz (w1 w2: word sz) n, exists w: word (S sz), existT word _ (sext w1 (S n) ^+ sext w2 (S n)) = existT word _ (sext w n).
proof: Proof. intros; eexists. apply wordToZ_existT; [lia|]. rewrite sext_wplus_wordToZ_distr by discriminate. do 3 rewrite sext_wordToZ. assert (- Z.of_nat (pow2 sz) <= wordToZ w1 + wordToZ w2 < Z.of_nat (pow2 sz))%Z. { clear n. dependent destruction w1. { rewrite (shatter_word w2); cbn; lia. } { remember (WS b w1) as ww1; clear Heqww1 w1 b. pose proof (wordToZ_size' ww1). pose proof (wordToZ_size' w2). destruct H, H0. split. { simpl; do 2 rewrite Nat2Z.inj_add; lia. } { simpl; do 2 rewrite Nat2Z.inj_add; lia. } } } apply wordToZ_ZToWord in H. rewrite <-H. 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