From Undecidability.L Require Import ComputableTactics Lproc mixedTactics Tactics.Computable ComputableTime Lrewrite.
Local Fixpoint subst' (s : term) (k : nat) (u : term) {struct s} : term :=
match s with
| # n => if Init.Nat.eqb n k then u else # n
| app s0 t => (subst' s0 k u) (subst' t k u)
| (lam s0) => (lam (subst' s0 (S k) u))
end.
revert k;induction s;intros;simpl;try congruence.
(* dec;destruct (n =? k) eqn:eq;try reflexivity. *)
(* -apply beq_nat_false in eq. tauto. *)
(* -apply beq_nat_true in eq. exfalso; tauto.  *)
Qed.
intros. rewrite <- subst'_eq. apply H.
Qed.
Ltac redStep':=
match goal with
|- _ == _ => apply star_equiv;redStep'
| |- app (lam ?s) ?t >* _ => apply lStep;[now Lproc|reflexivity]
| |- app ?s ?t >* _ => progress (etransitivity;[apply star_step_app_proper;redStep'|]);[reflexivity]
| |- _ => reflexivity
end.
Ltac redStep2 := etransitivity;[redStep'|].
(* iLtac redSimpl' s x t:= match s with | app ?s1 ?s2 -> let s1' := resSimpl' s1 x t in let s2' := resSimpl' s2 x t in constr:(app s1' s2') | *)
Ltac Lbeta_old := cbn [subst' Init.Nat.eqb].
intros. apply subst'_cls. Lproc.
Qed.
(* Lemma subst'_enc Y  (H:registered  Y): forall y x t, subst' (enc y) x t = (enc y). intros. apply subst'_cls. Lproc. Qed. *)
Local Ltac closedRewrite2 := rewrite ?subst'_int;
match goal with
| [ |- context[subst' ?s _ _] ] =>
let cl := fresh "cl" in assert (cl:closed s) by Lproc;
let cl' := fresh "cl'" in assert (cl':= subst'_cls cl);
rewrite ?cl';clear cl;clear cl'
end.
congruence.
Qed.
congruence.
Qed.
congruence.
Qed.

Lemma clR s s' t : s' = s -> s >* t -> s' >* t.