Corollary Ztestbit_two_p_m1:
  forall n i, 0 <= n -> 0 <= i ->
  Z.testbit (two_p n - 1) i = if zlt i n then true else false.

Lemma Zsign_ext_spec: forall n x i, 0 <= i -> 0 < n -> Z.testbit (Zsign_ext n x) i = Z.testbit x (if zlt i n then i else n - 1).