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.
Fixpoint nat2bs (n:nat) : bs :=
match n with
| 0 => nil
| S n' => succ_bs (nat2bs n')
end.

Lemma bs2nat_nil :
bs2nat nil = 0.