Module SortBodyProof := Mergesort.Sort(BodyProofOrder).
Definition Gprog_of_proof (p: semax_body_proof) :=
match p with
| @mk_body _ G _ _ _ _ _ => G
| @mk_external _ _ _ _ _ _ _ _ _ _ => nil
end.
Fixpoint delete_dups' id f (al: funspecs) : funspecs :=
match al with
| (id',f')::al' => if ident_eq id id' then delete_dups' id f al'
else (id,f)::delete_dups' id' f' al'
| nil => (id,f)::nil
end.
Definition delete_dups (al: funspecs) : funspecs :=
match al with
| (id,f)::al' => delete_dups' id f al'
| nil => nil
end.
Definition merge_Gprogs_of (module: list semax_body_proof) :=
delete_dups
(SortFunspec.sort
(List.fold_right (fun m G => Gprog_of_proof m ++ G) (nil: funspecs) module)).

(*Repetion of a lemma in forward.v*)
Lemma semax_body_subsumption' cs cs' V V' F F' f spec
(SF: @semax_body V F cs f spec)
(CSUB: cspecs_sub cs cs')
(COMPLETE : Forall (fun it : ident * type => complete_type (@cenv_cs cs) (snd it) = true) (fn_vars f))
(TS: tycontext_sub (func_tycontext f V F nil) (func_tycontext f V' F' nil)):
@semax_body V' F' cs' f spec.