proposition: Lemma wordToNat_wlshift: forall sz (w: word sz) n, wordToNat (wlshift w n) = Nat.mul (Nat.modulo (wordToNat w) (pow2 (sz - n))) (pow2 n).
proof: Proof. intros; destruct (le_dec n sz). - unfold wlshift; intros. rewrite wordToNat_split1. unfold eq_rec_r, eq_rec. rewrite wordToNat_eq_rect. rewrite wordToNat_combine. rewrite wordToNat_wzero; simpl. replace (pow2 sz) with (pow2 (sz - n + n)) by (f_equal; lia). rewrite pow2_add_mul. rewrite Nat.mul_comm with (n:= pow2 (sz - n)). rewrite Nat.mul_mod_distr_l; [|pose proof (zero_lt_pow2 (sz - n)); lia |pose proof (zero_lt_pow2 n); lia]. apply Nat.mul_comm. - assert (n > sz)%nat by lia. rewrite wlshift_gt by assumption. replace (sz - n) with 0 by lia. rewrite wordToNat_wzero; simpl; 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