(********************************************************************)
(* 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.

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.