Notation bs := (list bool).
Definition unary (v : bs) := forallb id v.
(** * Boolean interpretation of bitstrings *)
Definition bs2bool (v:bs) : bool := hd false v.
Definition bool2bs (b:bool) : bs :=
if b then true::nil else nil.
(** * Binary interpretation of bitstrings *)
Fixpoint bs2nat (v:bs) : nat :=
match v with
| nil => 0
| false :: v' => 2 * bs2nat v'
| true  :: v' => S (2 * bs2nat v')
end.
Fixpoint succ_bs (v : bs) : bs :=
match v with
| nil => [true]
| false :: v' => true :: v'
| true :: v' => false :: succ_bs v'
end.

Lemma succ_bs_correct v : bs2nat (succ_bs v) = bs2nat v + 1.