intros.
pattern e, t, args in |- *.
apply (Acc3_rec (R:=whnf_ord)).
clear H e t args.
intros e t args.
case t; intros.
exists (app_list args (Srt s)); auto with arith pts.
apply whnf_app_list; simpl in |- *; intros; auto with arith pts.
discriminate.
exists (app_list args (Ref n)); auto with arith pts.
apply whnf_app_list; simpl in |- *; intros; auto with arith pts.
discriminate.
generalize H.
case args; simpl in |- *; intros.
exists (Abs t0 t1); simpl in |- *; auto with arith pts.
apply whnf_head_normal; auto with arith pts.
simpl in |- *; auto with arith pts.
elim H0 with e (subst t2 t1) l; simpl in |- *; intros; auto with arith pts.
exists x; auto with arith pts.
apply red_trans with (app_list l (subst t2 t1)); auto with arith pts.
red in |- *; red in |- *.
apply rt_step.
auto with arith pts.
red in |- *; simpl in |- *.
left.
apply Rex_intro.
auto with arith pts.
elim H with e t0 (t1 :: args); intros; auto with arith pts.
exists x; auto with arith pts.
red in |- *; simpl in |- *; right; auto with arith pts.
exists (app_list args (Prod t0 t1)); simpl in |- *; auto with arith pts.
apply whnf_app_list; simpl in |- *; intros; auto with arith pts.
discriminate.
apply Acc_Acc3.
unfold whnf_ord in |- *.
apply (Acc_inverse_image approx (sigS (fun (_:value) => value))).
simpl in |- *.
apply acc_A_B_lexprod; intros.
elim H; intros.
apply Acc_intro; intros; auto with arith pts.
inversion_clear H2; auto with arith pts.
exact wf_subterm.
apply wf_subterm.
Qed.

(* Specifications: *)
Theorem beta_whnf :
forall (e : env) (t : term),
sn (ctxt beta) e t -> {u : term | red beta e t u &  head_normal beta e u}.