refine
(fun x1 x2 : srt_ecc =>
match
x1, x2
return
{x3 : srt_ecc | rules_ecc x1 x2 x3 &
forall s1 s2 s3 : srt_ecc,
rules_ecc s1 s2 s3 -> univ x1 s1 -> univ x2 s2 -> univ x3 s3}
with
| Sprop, _ => exist2 _ _ x2 _ _
| Stype n, Sprop => exist2 _ _ Sprop _ _
| Stype n, Stype n' => exist2 _ _ (Stype (max_nat n n')) _ _
end).
auto with pts.
simple induction 1; intros; auto with arith pts.
apply univ_trans with (Stype m); auto with arith pts.
auto with pts.
intros.
apply univ_inv with Sprop s2; intros.
auto with arith pts.
generalize H.
inversion_clear H2; intros.
inversion_clear H2; auto with arith pts.
unfold max_nat in |- *.
elim (le_gt_dec n n'); auto with arith pts.
intros.
apply univ_inv with (Stype n) s1; intros; auto with arith pts.
apply univ_inv with (Stype n') s2; intros; auto with arith pts.
generalize H.
inversion_clear H2.
inversion_clear H3; intros.
inversion_clear H3.
cut (max_nat n n' <= p); auto with arith pts.
apply least_upper_bound_max_nat.
apply le_trans with m; auto with arith pts.
apply le_trans with m0; auto with arith pts.
Qed.
End SortsOfECC.
Definition term := term srt_ecc.
Definition env := env srt_ecc.
(* Construction du CTS *)
Definition ecc : CTS_spec srt_ecc :=
Build_CTS_spec _ axiom_ecc rules_ecc univ_ecc (beta_delta_rule _).
(* Construction du PTS issu du CTS *)
Definition ecc_pts : PTS_sub_spec srt_ecc := cts_pts_functor _ ecc.
Definition le_type : red_rule srt_ecc :=
Rule _ (Le_type _ (pts_le_type _ ecc_pts)).
Definition typ : env -> term -> term -> Prop := typ _ ecc_pts.
Definition typ_ppal : env -> term -> term -> Prop := typ_ppal _ ecc_pts.
Definition wft : env -> term -> Prop := wf_type _ ecc_pts.
Definition wf : env -> Prop := wf _ ecc_pts.
Definition sn := sn srt_ecc (ctxt _ (Rule _ (head_reduct _ ecc))).
Definition red := red _ (Rule _ (beta_delta_rule srt_ecc)).
Definition conv := conv _ (Rule _ (beta_delta_rule srt_ecc)).
Hint Unfold le_type typ wft wf sn: pts.
(* Algorithme de mise en forme normale de tete Decidabilite du sous-typage pour les types bien formes *)

Lemma whnf :
forall (e : env) (t : term),
sn e t ->
{u : term | red _ (beta_delta _) e t u &
head_normal _ (beta_delta _) e u}.