Fixpoint countLeadingZerosWord_nat ni: word ni -> nat :=
match ni return word ni -> nat with
| 0 => fun _ => 0
| S m => fun e =>
if (weq (split2 m 1 (nat_cast (fun n => word n) (eq_sym (Nat.add_1_r m)) e)) WO~0)
then 1 + @countLeadingZerosWord_nat m (split1 m 1 (nat_cast (fun n => word n) (eq_sym (Nat.add_1_r m)) e))
else 0
end.

Lemma sext_natToWord_nat_cast: forall sz2 sz1 sz n (e: sz1 + sz2 = sz),
2 * n < pow2 sz1 ->
nat_cast word e (sext (natToWord sz1 n) sz2) = natToWord sz n.