(** * constant function *)
Program Fixpoint constant (v:bs) : { e : BC | arities e = ok_arities 0 0 /\ sem e nil nil = v } :=
match v with
| nil => BC.zero
| b :: v' => BC.comp 0 0 (BC.succ b) nil [constant v']
end.
Next Obligation.
simpl.
tauto.
Qed.
Next Obligation.
simpl.
intros bs_to_BC v b v' Hv.
subst v.
destruct (bs_to_BC v') as [e [H1 H2] ].
simpl.
rewrite H1, H2.
tauto.
Defined.
(** * Recursion on the length of a bitstring, i.e., ignoring the value 0 or 1 of bits *)
Definition rec2 g h := rec g h h.

(* Specifications: *)
Lemma rec2_correct v1 v2 g h0 h1 :
unary (hd nil v1) = true ->
sem (rec g h0 h1) v1 v2 = sem (rec2 g h1) v1 v2.
Lemma rec2_simpl g h i z l1 l2 :
sem (rec2 g h) ((i :: z) :: l1) l2 = sem h (z :: l1) (sem_rec (sem g) (sem h) (sem h) z l1 l2 :: l2).