Section ListEnumerabilityOrderedSystems.
Variable (X: Const).
Hypothesis (enumX: enumT X).
Fixpoint L_ordsys k (n: nat) : list (ordsysuni X k) :=
match n with
| 0 => nil
| S n => L_ordsys k n
++ [Build_ordsysuni _ _ _ _ _ (eqs_ordertyping_nil X Gamma k) | Gamma ∈ L_T n]
++ [Build_ordsysuni _ _ _ _ _
(eqs_ordertyping_cons _ _ _ _ _ _ _ _ H1 H2 (@cast _ (fun f => eqs_ordertyping  _ f _ E L) Gamma Gamma' H EQ)) |
(@Build_ordsysuni _ _ Gamma E L H, @Build_orduni _ _ Gamma' s t A H1 H2)
∈ (L_ordsys k n × L_T n) where EQ: Gamma = Gamma']
end.
Scheme eqs_ordertyping_strong_ind := Induction for eqs_ordertyping Sort Prop.
Instance enumT_ordsys n:
enumT (ordsysuni X n).
Proof with eauto using cum_ge'.
exists (L_ordsys n).
- eauto.
- intros [Gamma E L H]. induction H using eqs_ordertyping_strong_ind.
+ destruct (el_T Gamma) as [x]; exists (S x); cbn; in_app 2.
now in_collect Gamma.
+ destruct (el_T (Build_orduni Gamma s t A o o0)) as [x1].
destruct IHeqs_ordertyping as [x2]. exists (1 + x1 + x2).
cbn; in_app 3. eapply in_flat_map. exists (Build_ordsysuni _ _ _ _ _ H, Build_orduni Gamma s t A o o0).
split. eapply in_prod...
destruct dec; intuition.
subst. left. f_equal. f_equal.
unfold cast. rewrite <-Eqdep_dec.eq_rect_eq_dec; eauto.
eapply eq_dec.
Qed.
End ListEnumerabilityOrderedSystems.

Theorem enumerable_orderedsystemunification n (X: Const): 1 <= n -> enumerable__T X -> enumerable (@SOU X n).