intros e x y sn0 sn1.
generalize sn0 sn1.
pattern e, x, y in |- *.
apply
Acc3_rec with (R := fun x y : env * (term * term) => ord_norm R (f x) (f y)).
unfold f in |- *.
clear sn0 sn1 e x y.
intros e u v.
case u.
case v; intros; try (right; red in |- *; intros; inversion_clear H0; fail).
elim eq_sort_dec with s0 s; intros.
left.
elim a; auto with arith pts.
right; red in |- *; intros.
apply b.
inversion_clear H0; trivial.
case v; intros; try (right; red in |- *; intros; inversion_clear H0; fail).
elim eq_nat_dec with n0 n; intros.
left.
elim a; auto with pts.
right; red in |- *; intros.
apply b.
inversion_clear H0; trivial.
intros A M.
case v; intros; try (right; red in |- *; intros; inversion_clear H0; fail).
cut (sn (ctxt R) e A).
cut (sn (ctxt R) e t).
intros sn2 sn3.
elim whnf with e A; intros; trivial.
elim whnf with e t; intros; trivial.
elim H with e x x0; intros.
cut (sn (ctxt R) (Ax t :: e) M).
cut (sn (ctxt R) (Ax t :: e) t0).
intros sn4 sn5.
elim whnf with (Ax t :: e) M; intros; trivial.
elim whnf with (Ax t :: e) t0; intros; trivial.
elim H with (Ax t :: e) x1 x2; intros.
left.
apply chi_abs.
apply conv_trans with x; auto with pts.
apply conv_trans with x0; auto with pts.
apply conv_trans with x1; auto with pts.
apply conv_trans with x2; auto with pts.
right; red in |- *; intros.
apply b.
inversion_clear H0.
apply inv_conv_hn with M t0; auto with pts.
apply ord_norm_intro with M; auto with pts.
apply sn_red_sn with M; auto with pts.
apply sn_red_sn with t0; auto with pts.
apply subterm_sn with e (Abs t t0); auto with pts.
apply subterm_sn with e (Abs A M); auto with pts.
right; red in |- *; intros.
apply b.
inversion_clear H0.
apply inv_conv_hn with A t; auto with pts.
apply ord_norm_intro with A; auto with pts.
apply sn_red_sn with A; auto with pts.
apply sn_red_sn with t; auto with pts.
apply subterm_sn with e (Abs t t0); auto with pts.
apply subterm_sn with e (Abs A M); auto with pts.
intros u0 v0.
case v; intros; try (right; red in |- *; intros; inversion_clear H0; fail).
cut (sn (ctxt R) e u0).
cut (sn (ctxt R) e t).
intros sn2 sn3.
elim whnf with e u0; intros; trivial.
elim whnf with e t; intros; trivial.
elim H with e x x0; intros.
cut (sn (ctxt R) e v0).
cut (sn (ctxt R) e t0).
intros sn4 sn5.
elim whnf with e v0; intros; trivial.
elim whnf with e t0; intros; trivial.
elim H with e x1 x2; intros.
left.
apply chi_app.
apply conv_trans with x; auto with pts.
apply conv_trans with x0; auto with pts.
apply conv_trans with x1; auto with pts.
apply conv_trans with x2; auto with pts.
right; red in |- *; intros.
apply b.
inversion_clear H0.
apply inv_conv_hn with v0 t0; auto with pts.
apply ord_norm_intro with v0; auto with pts.
apply sn_red_sn with v0; auto with pts.
apply sn_red_sn with t0; auto with pts.
apply subterm_sn with e (App t t0); auto with pts.
apply subterm_sn with e (App u0 v0); auto with pts.
right; red in |- *; intros.
apply b.
inversion_clear H0.
apply inv_conv_hn with u0 t; auto with pts.
apply ord_norm_intro with u0; auto with pts.
apply sn_red_sn with u0; auto with pts.
apply sn_red_sn with t; auto with pts.
apply subterm_sn with e (App t t0); auto with pts.
apply subterm_sn with e (App u0 v0); auto with pts.
intros A B.
case v; intros; try (right; red in |- *; intros; inversion_clear H0; fail).
cut (sn (ctxt R) e A).
cut (sn (ctxt R) e t).
intros sn2 sn3.
elim whnf with e A; intros; trivial.
elim whnf with e t; intros; trivial.
elim H with e x x0; intros.
cut (conv R e A t).
intros cv.
cut (sn (ctxt R) (Ax t :: e) B).
cut (sn (ctxt R) (Ax t :: e) t0).
intros sn4 sn5.
elim whnf with (Ax t :: e) B; intros; trivial.
elim whnf with (Ax t :: e) t0; intros; trivial.
elim H with (Ax t :: e) x1 x2; intros.
left.
apply chi_prod.
auto with pts.
apply conv_trans with x1; auto with pts.
apply conv_trans with x2; auto with pts.
right; red in |- *; intros.
apply b.
inversion_clear H0.
apply inv_conv_hn with B t0; auto with pts.
apply ord_norm_intro with B; auto with pts.
apply sn_red_sn with B; auto with pts.
apply sn_red_sn with t0; auto with pts.
apply subterm_sn with e (Prod t t0); auto with pts.
apply subterm_sn with e (Prod A B); auto with pts.
apply conv_trans with x; auto with pts.
apply conv_trans with x0; auto with pts.
right; red in |- *; intros.
apply b.
inversion_clear H0.
apply inv_conv_hn with A t; auto with pts.
apply ord_norm_intro with A; auto with pts.
apply sn_red_sn with A; auto with pts.
apply sn_red_sn with t; auto with pts.
apply subterm_sn with e (Prod t t0); auto with pts.
apply subterm_sn with e (Prod A B); auto with pts.
apply Acc_Acc3.
apply (Acc_inverse_image (env * (term * term)) value).
unfold ord_norm, f in |- *.
apply Acc_clos_trans.
apply sn_acc_ord_norm1; auto with pts.
Qed.

Theorem CR_WHNF_conv_dec :
forall (e : env) (x y : term),
sn (ctxt R) e x -> sn (ctxt R) e y -> decide (conv R e x y).