Definition asZ (x : bool) : Z := if x then 1 else 0.

(* Specifications: *)
Lemma asZT: asZ true = 1. reflexivity. Qed.
Lemma asZF: asZ false = 0. reflexivity. Qed.
Definition convertByteBits bits (b : byte) : Prop :=
exists (b0 b1 b2 b3 b4 b5 b6 b7 : bool),
bits = [b0; b1; b2; b3; b4; b5; b6; b7] /\
Byte.unsigned b =  (1 * (asZ b0) + 2 * (asZ b1) + 4 * (asZ b2) + 8 * (asZ b3)
+ 16 * (asZ b4) + 32 * (asZ b5) + 64 * (asZ b6) + 128 * (asZ b7)).
Lemma testbit_b2z_nonzero:
forall i, i<>0 -> forall b, Z.testbit (Z.b2z b) i = false.
Lemma testbit_shiftl_8:
forall a0 a1 a2 a3 a4 a5 a6 a7,
forall i,
Z.testbit (Z.shiftl (Z.b2z a0) 0 + Z.shiftl (Z.b2z a1) 1
+ Z.shiftl (Z.b2z a2) 2 + Z.shiftl (Z.b2z a3) 3
+ Z.shiftl (Z.b2z a4) 4 + Z.shiftl (Z.b2z a5) 5
+ Z.shiftl (Z.b2z a6) 6 + Z.shiftl (Z.b2z a7) 7)  i=
Z.testbit (Z.shiftl (Z.b2z a0) 0) i ||
Z.testbit (Z.shiftl (Z.b2z a1) 1) i ||
Z.testbit (Z.shiftl (Z.b2z a2) 2) i ||
Z.testbit (Z.shiftl (Z.b2z a3) 3) i ||
Z.testbit (Z.shiftl (Z.b2z a4) 4) i ||
Z.testbit (Z.shiftl (Z.b2z a5) 5) i ||
Z.testbit (Z.shiftl (Z.b2z a6) 6) i ||
Z.testbit (Z.shiftl (Z.b2z a7) 7) i.
Lemma xor_correspondence :
forall (b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 : bool)
(byte0 byte1 : byte),
convertByteBits [b0; b1; b2; b3; b4; b5; b6; b7] byte0 ->
convertByteBits [b8; b9; b10; b11; b12; b13; b14; b15] byte1 ->
convertByteBits
[xorb b0 b8; xorb b1 b9; xorb b2 b10; xorb b3 b11;
xorb b4 b12; xorb b5 b13; xorb b6 b14; xorb b7 b15]
(Byte.xor byte0 byte1).