simple induction 1; intros.
inversion_clear H0; red in |- *; intros.
Inversion_typ H0.
Inversion_typ H5.
elim H2 with (1 := H3) (2 := H8).
Inversion_typ H0.
elim H2 with (1 := H3) (2 := H5).
Inversion_typ H0.
elim H2 with (1 := H3) (2 := H4).
Inversion_typ H0.
elim H2 with (1 := H3) (2 := H5).
inversion_clear H3.
inversion_clear H0; red in |- *; intros.
Inversion_typ H0.
elim H2 with (1 := H4) (2 := H3).
Inversion_typ H0.
elim H2 with (1 := H4) (2 := H6).
inversion_clear H0; trivial.
inversion_clear H0.
red in |- *; intros.
Inversion_typ H0.
generalize H2.
elim H3; intros; auto with arith.
simpl in H5.
cut (~ 0 > length l); auto with arith.
inversion_clear H0.
red in |- *; intros.
Inversion_typ H0.
Inversion_typ H4.
elim (pa_topsort_untyped the_algos _ _ _ _ (pp_least H1 H3) H8); intros.
elim H2 with (Srt x).
constructor; trivial.
apply typ_wf with (1 := H0).
inversion_clear H0.
red in |- *; intros.
Inversion_typ H0.
Inversion_typ H4.
elim H2 with (1 := H7).
inversion_clear H0.
red in |- *; intros.
Inversion_typ H0.
elim H2 with (1 := H4).
inversion_clear H0.
red in |- *; intros.
Inversion_typ H0.
apply H4.
apply typ_conv_wf with V; trivial.
generalize (type_correctness _ _ _ H1); intros.
inversion_clear H8.
Inversion_typ H9.
left with s1; trivial.
apply (inv_prod_l _ (pa_inv_prod the_algos) _ _ _ _ _ (H2 _ _ H6)).
inversion_clear H0.
red in |- *; intros.
Inversion_typ H0.
elim H2 with (1 := H4).
inversion_clear H0.
inversion_clear H1.
red in |- *; intros.
Inversion_typ H1.
elim H2 with (1 := H5).
Qed.
Inductive chk_error (m t : term) : type_error -> Prop :=
| Chke_subj :
forall err : type_error, inf_error m err -> chk_error m t err
| Chke_type :
forall err : type_error,
inf_error t err ->
~ (exists s : sort, t = Srt s) -> chk_error m t err
| Chke_type2 :
forall k : term,
~ (exists s : sort, t = Srt s) -> chk_error m t (Not_a_type t k)
| Chke_exp : forall at_ : term, chk_error m t (Expected_type m at_ t).
Hint Resolve Chke_subj Chke_type Chke_exp: pts.

Lemma chk_error_no_type :
forall (e : env) (m t : term) (err : type_error),
chk_error m t err -> expln e err -> ~ typ e m t.