Section Confluence_Beta_Delta.
Inductive bd_par_red1 : env -> term -> term -> Prop :=
| par_betad :
forall (e : env) (M M' T : term),
bd_par_red1 (Ax T :: e) M M' ->
forall N N' : term,
bd_par_red1 e N N' -> bd_par_red1 e (App (Abs T M) N) (subst N' M')
| par_delta :
forall (e : env) (d T N : term) (n : nat),
bd_par_red1 e (lift (S n) d) N ->
item (Def d T) e n -> bd_par_red1 e (Ref n) N
| sort_par_red :
forall (e : env) (s : sort), bd_par_red1 e (Srt s) (Srt s)
| ref_par_red : forall (e : env) (n : nat), bd_par_red1 e (Ref n) (Ref n)
| abs_par_red :
forall (e : env) (M M' T T' : term),
bd_par_red1 (Ax T' :: e) M M' ->
bd_par_red1 e T T' -> bd_par_red1 e (Abs T M) (Abs T' M')
| app_par_red :
forall (e : env) (M M' : term),
bd_par_red1 e M M' ->
forall N N' : term,
bd_par_red1 e N N' -> bd_par_red1 e (App M N) (App M' N')
| prod_par_red :
forall (e : env) (M M' : term),
bd_par_red1 e M M' ->
forall N N' : term,
bd_par_red1 (Ax M' :: e) N N' ->
bd_par_red1 e (Prod M N) (Prod M' N').
Hint Resolve par_betad sort_par_red ref_par_red abs_par_red app_par_red
prod_par_red: pts.
simple induction M; auto with arith pts.
Qed.
Hint Resolve refl_bd_par_red1: pts.
simple induction 1; auto with arith pts; intros.
elim H0; intros; auto with arith pts.
elim H1; auto with arith pts.
elim H1; intros.
apply par_delta with d T; auto with arith pts.
Qed.
simple induction 1; intros; auto with arith pts.
apply red_trans with (App (Abs T M') N'); auto 10 with arith pts.
red in |- *; red in |- *.
apply rt_step.
apply ctx_rule.
left; auto with arith pts.
apply red_trans with (lift (S n) d); auto with arith pts.
red in |- *; red in |- *.
apply rt_step.
apply ctx_rule.
right.
apply delta_intro with T; auto with arith pts.
Qed.
red in |- *.
simple induction 1; intros; auto with arith pts.
elim red_item with R' n (Def d T) e0 f; intros; auto with arith pts.
apply par_delta with d T; auto with arith pts.
elim item_trunc with decl n e0 (Def d T); intros; auto with arith pts.
elim H4 with x0; intros; auto with arith pts.
inversion_clear H6.
generalize H9.
inversion_clear H8; intros.
apply par_delta with d U; auto with arith pts.
Qed.
red in |- *.
simple induction 1; simpl in |- *; intros; auto with arith pts.
rewrite distr_lift_subst; auto with arith pts.
apply par_betad; auto with arith pts.
replace (Ax (lift_rec 1 T k)) with (lift_decl 1 (Ax T) k);
auto with arith pts.
elim (le_gt_dec k n); intros.
apply par_delta with d T; auto with arith pts.
unfold lift in |- *.
replace (S (S n)) with (1 + S n); auto with arith pts.
elim simpl_lift_rec with d (S n) 0 1 k; auto with arith pts.
simpl in |- *; auto with arith pts.
apply ins_item_ge with (1 := H3); auto with arith pts.
apply par_delta with (lift_rec 1 d (k - S n)) (lift_rec 1 T (k - S n));
auto with arith pts.
unfold lift in |- *.
rewrite permute_lift_rec; auto with arith pts.
replace (S n + (k - S n)) with k; auto with arith pts.
change (item (lift_decl 1 (Def d T) (k - S n)) f n) in |- *.
apply ins_item_lt with (1 := H3); auto with arith pts.
apply abs_par_red; auto with arith pts.
replace (Ax (lift_rec 1 T' k)) with (lift_decl 1 (Ax T') k);
auto with arith pts.
apply prod_par_red; auto with arith pts.
replace (Ax (lift_rec 1 M' k)) with (lift_decl 1 (Ax M') k);
auto with arith pts.
Qed.
Hint Resolve bd_par_red1_lift: pts.
simple induction v; simpl in |- *; intros; auto with arith pts.
elim (lt_eq_lt_dec n0 n); intros; auto with arith pts.
elim a; intros; auto with arith pts.
apply iter_R_lift with g; auto with arith pts.
Qed.

Lemma bd_par_red1_subst_rec :
forall (d : decl) (x y t u : term) (e g : env),
bd_par_red1 g x y ->
bd_par_red1 e t u ->
forall (n : nat) (f : env),
sub_in_env g d x n e f ->
bd_par_red1 f (subst_rec x t n) (subst_rec y u n).