(* 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. *)
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).
simple induction e; intros; auto with pts.