Program Instance Linker_composite_defs : Linker (list composite_definition) := {
link := link_composite_defs;
linkorder := @List.incl composite_definition
}.
Next Obligation.
apply incl_refl.
Defined.
Next Obligation.
red; intros; eauto.
Defined.
Next Obligation.
apply link_composite_def_inv in H; destruct H as (A & B & C).
split; red; intros; apply C; auto.
Defined.
(** Connections with [build_composite_env]. *)

Lemma link_add_composite_definitions:
forall l0 env0,
build_composite_env l0 = OK env0 ->
forall l env1 env1' env2,
add_composite_definitions env1 l = OK env1' ->
(forall id co, env1!id = Some co -> env2!id = Some co) ->
(forall id co, env0!id = Some co -> env2!id = Some co) ->
(forall id, env2!id = if In_dec ident_eq id (map name_composite_def l0) then env0!id else env1!id) ->
((forall cd1 cd2, In cd1 l0 -> In cd2 l -> name_composite_def cd2 = name_composite_def cd1 -> cd2 = cd1)) ->
{ env2' |
add_composite_definitions env2 (filter_redefs l0 l) = OK env2'
/\ (forall id co, env1'!id = Some co -> env2'!id = Some co)
/\ (forall id co, env0!id = Some co -> env2'!id = Some co) }.