Section Int31_Specs.
Local Open Scope Z_scope.
Notation "[| x |]" := (phi x)  (at level 0, x at level 99).
Local Notation wB := (2 ^ (Z.of_nat size)).
Notation "[+| c |]" :=
(interp_carry 1 wB phi c)  (at level 0, c at level 99).
Notation "[-| c |]" :=
(interp_carry (-1) wB phi c)  (at level 0, c at level 99).
Notation "[|| x ||]" :=
(zn2z_to_Z wB phi x)  (at level 0, x at level 99).
(** Subtraction *)
(** Multiplication *)
(** Division *)
Fixpoint addmuldiv31_alt n i j :=
match n with
| O => i
| S n => addmuldiv31_alt n (sneakl (firstl j) i) (shiftl j)
end.
(** Shift operations *)
Fixpoint head031_alt n x :=
match n with
| O => 0%nat
| S n => match firstl x with
| D0 => S (head031_alt n (shiftl x))
| D1 => 0%nat
end
end.
Fixpoint tail031_alt n x :=
match n with
| O => 0%nat
| S n => match firstr x with
| D0 => S (tail031_alt n (shiftr x))
| D1 => 0%nat
end
end.

Lemma tail031_equiv :
forall x, [|tail031 x|] = Z.of_nat (tail031_alt size x).