(** * Length-bounding condition that must hold for a Cobham expression to be valid *)
Fixpoint rec_bounded' (e : Cobham) : Prop :=
match e with
| Rec g h0 h1 j =>
rec_bounded' j  /\
rec_bounded' g /\
rec_bounded' h0 /\
rec_bounded' h1 /\
(match (arity e) with
| ok_arity n => forall l, length l = n ->
length (Sem e l) <= length (Sem j l)
| _ => True (* never happen *)
end)
| Comp n h l => rec_bounded' h /\
andl rec_bounded' l
| _ => True
end.
Fixpoint rec_bounded (e : Cobham) : Prop :=
match e with
| Rec g h0 h1 j =>
rec_bounded j  /\
rec_bounded g /\
rec_bounded h0 /\
rec_bounded h1 /\
(forall l,
length (Sem e l) <= length (Sem j l))
| Comp n h l => rec_bounded h /\
andl rec_bounded l
| _ => True
end.

(* Specifications: *)
Lemma rec_bounded_spec (e : Cobham) :
rec_bounded e -> rec_bounded' e.
Lemma rec_bounded'_spec : forall (e : Cobham) n,
arity e = ok_arity n ->
rec_bounded' e ->
rec_bounded e.