Fixpoint conv n s (e : BCI) : BC :=
match e with
| zeroI => comp n s zero nil nil
| projIn i => proj n s i
| projIs i => proj n s (n + i)
| succI b => comp n s (succ b) nil [proj n s n]
| predI => comp n s pred nil [proj n s n]
| condI => comp n s cond nil
[proj n s n; proj n s (S n); proj n s (S (S n)); proj n s (S (S (S n)))]
| recI g h0 h1 => rec (conv (n-1) s g)
(conv n (S s) h0)
(conv n (S s) h1)
| compI g ln ls =>
comp n s (conv (length ln) (length ls) g)
(map (conv n 0) ln) (map (conv n s) ls)
end.
Definition zeroI_e := compI zeroI nil nil.
Definition leftI (d:nat)(x:TypeI) : nat :=
match x with
| I n _ => n
| E _ => d
end.
Definition rightI (d:nat)(x:TypeI) : nat :=
match x with
| I _ n => n
| E _ => d
end.
Opaque maxl.
Definition conv_bci_to_bc (e : BCI) : option BC :=
match inf e with
| I n s => Some (conv n s e)
| _ => None
end.

Lemma conv_bci_to_bc_correct : forall (e : BCI) (e' : BC) (vnl vsl : list bs),
conv_bci_to_bc e = Some e' ->
sem e' vnl vsl = semI e vnl vsl.