Section Beta_Whnf.
Fixpoint whnf_beta (t : term) : Prop :=
match t with
| App u v => whnf_beta u /\ (forall T t : term, u <> Abs T t)
| _ => True
end.
Hint Unfold whnf_beta: pts.
simple induction 1; simpl in |- *; intros; auto with arith pts.
generalize H1.
elim H0; simpl in |- *; auto with arith pts.
simple induction 1; simpl in |- *; intros.
inversion_clear H3.
elim H5 with T M; auto with arith pts.
intros.
inversion_clear H4.
split; auto with arith pts.
red in |- *; intros.
generalize H5.
inversion_clear H4 in H2.
generalize H6.
inversion_clear H2; simpl in |- *; intros.
generalize H7.
inversion_clear H4; simpl in |- *; intros.
inversion_clear H4.
elim H9 with T0 M; auto with arith pts.
elim H2 with M t0; auto with arith pts.
elim H2 with T M; auto with arith pts.
Qed.
red in |- *; intros.
generalize H.
elim H0.
simple induction 1.
simple induction 1; simpl in |- *; intros.
inversion_clear H3.
elim H5 with T M; auto with arith pts.
red in |- *; red in |- *; intros.
inversion_clear H5.
red in |- *; red in |- *; intros.
inversion_clear H5.
red in |- *; red in |- *; intros.
generalize H2.
inversion_clear H5.
intros.
generalize H4.
inversion_clear H5; simpl in |- *; intros.
inversion_clear H5.
generalize H7.
inversion_clear H6.
simpl in |- *; intros.
inversion_clear H5.
elim H9 with T0 M0; auto with arith pts.
inversion_clear H5.
elim H8 with M0 M; auto with arith pts.
inversion_clear H5.
elim H8 with T M0; auto with arith pts.
red in |- *; red in |- *; intros.
generalize H4.
inversion_clear H5; simpl in |- *; intros.
inversion_clear H5.
elim H7 with T M; auto with arith pts.
red in |- *; red in |- *; intros.
inversion_clear H5.
red in |- *; red in |- *; intros.
inversion_clear H5.
red in |- *; red in |- *; intros.
generalize H1.
inversion_clear H2; simpl in |- *; intros.
inversion_clear H2.
elim H4 with T M; auto with arith pts.
intros.
apply H4.
apply beta_red_whnf with e x; auto with arith pts.
Qed.
simple induction args; simpl in |- *; intros; auto with arith pts.
apply whnf_head_normal; auto with arith pts.
apply H; intros.
simpl in |- *; auto with arith pts.
discriminate.
Qed.
Let f1 (a : approx) :=
match a with
| (e, (t, args)) => existT (fun _ => value) (e, app_list args t) (e, t)
end.
Definition whnf_ord (x y : approx) :=
lexprod value (fun _ => value) (R_exp beta) (fun _ => subterm)
(f1 x) (f1 y).
simple induction l; simpl in |- *; intros; auto with arith pts.
Qed.
Hint Resolve beta_app_list_ctxt: pts.

Lemma beta_whnf_rec :
forall (e : env) (t : term) (args : list term),
sn (ctxt beta) e (app_list args t) ->
{u : term | red beta e (app_list args t) u &  head_normal beta e u}.