Section Infer_Full_PTS.
Fixpoint full_ppal_type (t : term) :
forall e : env, wf e -> infer_ppal_type e t :=
fun e H =>
match t return (infer_ppal_type e t) with
| Srt s => infer_sort e s H
| Ref n => infer_ref e n H
| Abs A M => infer_abs full_ppal_type e A M H
| App u v => infer_app full_ppal_type e u v H
| Prod A B => infer_prod full_ppal_type e A B H
end.
Proof fix_add_typ full_ppal_type.
Proof fix_chk_wk full_ppal_type.
Let add_cst : forall (e : env) (t T : term), wf e -> decl_dec e (Def t T).
(* Realizer [e:env; t,T:term] Cases (tmp_add_typ e T) of Dcl_ok => (tmp_check_typ_when_wf e t T) | (Dcl_fail err) => (Chk_fail err) end. *)
intros.
elim (tmp_add_typ e T); trivial; intros.
elim (tmp_check_typ_when_wf e t T); trivial; intros.
left.
inversion_clear w.
apply wf_cst with s; trivial with pts.
right with err; auto with pts.
inversion_clear w.
left with s; trivial with pts.
right with err; auto with pts.
Qed.
(* Realizer [e:env; t:term] if (is_a_sort t) then Wft_ok else Cases (tmp_add_typ e t) of Dcl_ok => Wft_ok | (Dcl_fail err) => (Wft_fail err) end. *)
intros.
elim (is_a_sort t); intros.
left.
inversion_clear a; subst t; auto with pts.
case (tmp_add_typ e t); trivial; intros.
left.
inversion_clear w; auto with pts.
apply wft_typed with s; auto with pts.
right with err; auto with pts.
Qed.
Let check_type : forall (e : env) (t T : term), wf e -> check_dec e t T.
(* Realizer [e:env; t,T:term] Cases (tmp_check_wf_type e T) of Wft_ok => (tmp_check_typ_when_wf e t T) | (Wft_fail err) => (Chk_fail err) end. *)
intros.
case (tmp_check_wf_type e T); trivial; intros.
apply tmp_check_typ_when_wf; trivial.
right with err; auto with pts.
inversion_clear d.
apply Chke_type; trivial.
apply Chke_type2; trivial.
Qed.
Definition full_type_checker : PTS_TC :=
Build_PTS_TC (fun e t => full_ppal_type t e) check_type tmp_add_typ
add_cst tmp_check_typ_when_wf tmp_check_wf_type.

(* Decidability of judgements *)
Theorem decide_wf : forall e : env, decide (wf e).