(* Add n normal arguments and s safe argument at the beginnings *)
Definition BC_dummies (n n0 s s0 : nat)(e : BC) : BC :=
comp (n+n0) (s+s0) e (map (proj (n+n0) 0)      (seq n        n0))
(map (proj (n+n0) (s+s0)) (seq (n+n0+s) s0)).
Opaque BC_dummies.
Fixpoint rec_simulation sl (e : Cobham) : pol :=
match e with
| Zero => pcst sl 0
| Proj i n => pcst sl 0
| Succ b => pcst sl 0
| Smash => (pplus (pplus (pproj sl 1) (pproj sl 1))
(pplus (pcst sl 16) (pplus (pproj sl 0) (pcst sl 2))))
| Rec g h0 h1 j =>
let bf := poly_Cobham j in
let ph := pplus (rec_simulation (S sl) h0)  (rec_simulation (S sl) h1) in
let pg := rec_simulation (sl - 1) g in
pplus (pcomp ph (pproj sl 0 :: bf :: (map (pproj sl) (seq 1 (sl - 1)))))
(pplus (pshift pg) (pplus (pproj sl 0) (pcst sl 2)))
| Comp n h l =>
pplus (pcst sl 0)
(pplus (pcomp (rec_simulation (length l) h)
(map poly_Cobham l)) (pplusl (map (rec_simulation sl) l)))
end.

Lemma pWF_rec_simulation : forall (e : Cobham) n,
arity e = ok_arity n ->
pWF (rec_simulation n e).