Section composite_reorder.
Context (cenv: composite_env)
(cenv_consistent: composite_env_consistent cenv).
Definition rebuild_composite_elements := CompositeRankSort.sort (PTree.elements cenv).
Inductive ordered_and_complete: list (positive * composite) -> Prop :=
| ordered_and_complete_nil: ordered_and_complete nil
| ordered_and_complete_cons: forall i co l,
(forall i' co',
cenv ! i' = Some co' ->
(co_rank co' < co_rank co)%nat ->
In (i', co') l) ->
ordered_and_complete l ->
ordered_and_complete ((i, co) :: l).

Theorem RCT_ordered: ordered_composite rebuild_composite_elements.