(** * Swapping of two arguments

  - arities: (2, 0)
*)

Definition inv_e (e : BC) : BC :=
  comp 2 0 e (proj 2 0 1 :: proj 2 0 0 :: nil) nil.(** * Conversion from arities (1, 1) to (2, 0) *)

Definition from_11_to_20 (e : BC) : BC :=
  comp 2 0 e (proj 2 0 0 :: nil) (proj 2 0 1 :: nil).(** * Concatenation of bitstrings

  - arities: (1, 1)
*)

Definition app_e : BC :=
  rec (proj 0 1 0)
      (comp 1 2 (succ false) nil ((proj 1 2 1) :: nil))
      (comp 1 2 (succ true) nil ((proj 1 2 1) :: nil)).(** * 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).
Lemma rec2_sem_rec g h z l1 l2 : sem (rec2 g h) (z :: l1) l2 = sem_rec (sem g) (sem h) (sem h) z l1 l2.
Lemma arities_cond2 n s x g h0 h1 (Hx : arities x = ok_arities n s) (Hg : arities g = ok_arities n s) (Hh0 : arities h0 = ok_arities n (S s)) (Hh1 : arities h1 = ok_arities n (S s)) : arities (cond2 n s x g h0 h1) = ok_arities n s.