(********************************************************************)
(* Instanciation des operateurs des listes polymorph(iqu)es         *)
Definition BV := list bool.Definition nilbv : BV := nil.Definition consbv : bool -> BV -> BV := cons (A:=bool).Definition appbv : BV -> BV -> BV := app (A:=bool).Definition lengthbv : BV -> nat := length (A:=bool).Definition lenbv : BV -> nat -> Prop := len bool.Definition BV_null (n : nat) : BV := list_const bool n false.Definition truncbv : BV -> nat -> BV := trunc bool.Definition stripbv : BV -> nat -> BV := strip bool.Definition field : BV -> nat -> nat -> BV := sublist bool.Definition abit : BV -> nat -> BV := elemlist bool.Definition bitset : BV -> nat -> bool -> BV := replace bool.Definition BVnot (v : BV) : BV := map bool bool v negb.(********************************************************************)

Fixpoint BV_to_nat (v : BV) : nat :=
  match v return nat with
  | nil => 0
  | b :: w => bool_to_nat b + (BV_to_nat w + BV_to_nat w)
  end.

(* Specifications: *)
Lemma BV_to_nat_eq1 : BV_to_nat nilbv = 0.
Lemma BV_to_nat_eq2 : forall (b : bool) (w : BV), BV_to_nat (consbv b w) = bool_to_nat b + (BV_to_nat w + BV_to_nat w).
Lemma BV_to_nat_app : forall (l n : BV) (ll : nat), (******************) lenbv l ll -> BV_to_nat (appbv l n) = BV_to_nat l + power2 ll * BV_to_nat n.
Lemma BV_to_nat_app2 : forall l n : BV, (*******************) BV_to_nat (appbv l n) = BV_to_nat l + power2 (lengthbv l) * BV_to_nat n.
Lemma BV_null_nat : forall n : nat, BV_to_nat (BV_null n) = 0.
Lemma length_BV_null : forall n : nat, lengthbv (BV_null n) = n.