Fixpoint BV_increment (l : list bool) : BV :=
  match l with
  | nil => nilbv
  | false :: v => true :: v
  | true :: v => false :: BV_increment v
  end.Fixpoint BV_increment_carry (l : list bool) : bool :=
  match l with
  | nil => true
  | false :: v => false
  | true :: v => BV_increment_carry v
  end.Fixpoint BV_decrement (l : list bool) : BV :=
  match l with
  | nil => nilbv
  | false :: v => true :: BV_decrement v
  | true :: v => false :: v
  end.Fixpoint BV_decrement_carry (l : list bool) : bool :=
  match l with
  | nil => true
  | false :: v => BV_decrement_carry v
  | true :: v => false
  end.

(* Specifications: *)
Lemma length_BV_increment : forall v : BV, lengthbv (BV_increment v) = lengthbv v.
Lemma length_BV_decrement : forall v : BV, lengthbv (BV_decrement v) = lengthbv v.
Lemma BV_increment_limit : forall n : nat, BV_increment (list_const bool n true) = list_const bool n false.
Lemma BV_decrement_limit : forall n : nat, BV_decrement (list_const bool n false) = list_const bool n true.
Lemma BV_increment_limit_carry : forall n : nat, BV_increment_carry (list_const bool n true) = true.
Lemma BV_decrement_limit_carry : forall n : nat, BV_decrement_carry (list_const bool n false) = true.
Lemma BV_increment_adder : forall v : BV, appbv (BV_increment v) (consbv (BV_increment_carry v) nilbv) = BV_full_adder v nilbv true.
Lemma BV_increment_ok : forall v : BV, BV_to_nat (appbv (BV_increment v) (consbv (BV_increment_carry v) nilbv)) = S (BV_to_nat v).
Lemma BV_decr_incr : forall v : BV, BV_decrement (BV_increment v) = v.
Lemma BV_incr_decr : forall v : BV, BV_increment (BV_decrement v) = v.