(** Unsigned modulus over [2^n] is masking with [2^n-1]. *)

(* Specifications: *)
Lemma Ztestbit_mod_two_p:
forall n x i,
0 <= n -> 0 <= i ->
Z.testbit (x mod (two_p n)) i = if zlt i n then Z.testbit x i else false.
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.
Theorem modu_and:
forall x n logn,
is_power2 n = Some logn ->
modu x n = and x (sub n one).
Lemma Ztestbit_mod_two_p:
forall n x i,
0 <= n -> 0 <= i ->
Z.testbit (x mod (two_p n)) i = if zlt i n then Z.testbit x i else false.
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.
Theorem modu_and:
forall x n logn,
is_power2 n = Some logn ->
modu x n = and x (sub n one).