Library term

Annotated Terms syntax

In this file, we describe a slightly different syntax for terms: we add two annotations to applications. If the head of an application if a function from A to B, we had both informations in the application, in order to keep track of the conversion during the typing that would be impossible to rebuild after.
Require Import Peano_dec.

Require Import Compare_dec.

Require Import Lt.

Require Import Le.

Require Import Gt.

Require Import Plus.

Require Import Minus.

Require Import Bool.

Require Import base.


Term syntax. Notice the two additional Term in the application.
Module Type term_mod (X:term_sig).
Interactive Module Type term_mod started


Import X.


Inductive Term : Set:=
 | Var : Vars -> Term
 | Sort : Sorts -> Term
 | App : Term -> Term -> Term -> Term -> Term
 | Pi : Term -> Term -> Term
 | La :Term -> Term -> Term
.
Term is defined
Term_rect is defined
Term_ind is defined
Term_rec is defined



this notation means that the product x y is annotated by the function space A -> B.
Notation "x ·( A , B ) y" := (App x A B y) (at level 15, left associativity) : Typ_scope.

Notation "! s" := (Sort s) (at level 1) : Typ_scope.

Notation "# v" := (Var v) (at level 1) : Typ_scope.

Notation "'Π' ( U ) , V " := (Pi U V) (at level 20, U, V at level 30) : Typ_scope.
Identifier 'Π' now a keyword


Notation "'λ' [ U ] , v " := (La U v) (at level 20, U , v at level 30) : Typ_scope.
Identifier 'λ' now a keyword



Reserved Notation " t ↑ x # n " (at level 5, x at level 0, left associativity).


Delimit Scope Typ_scope with Typ.


Same as for usual terms, we need lift and subst functions, with the very same properties. They are just extended to deal with the two annotations.

Open Scope Typ_scope.


Fixpoint lift_rec (n:nat) (k:nat) (T:Term) {struct T} := match T with
   | # x => if le_gt_dec k x then Var (n+x) else Var x
   | ! s => Sort s
   | M ·(A, B) N=> App (M n # k) (A n # k) (B n # (S k)) (N n # k)
   | Π ( A ), B => Π (A n # k), (B n # (S k))
   | λ [ A ], M => λ [A n # k], (M n # (S k))
 end
   where "t ↑ n # k" := (lift_rec n k t) : Typ_scope.
lift_rec is recursively defined (decreasing on 3rd argument)



Notation " t ↑ n " := (lift_rec n 0 t) (at level 5, n at level 0, left associativity) : Typ_scope.


Lemma inv_lift : forall M N n m , M n # m = N n # m -> M = N.
1 subgoals, subgoal 1 (ID 9)
  
  ============================
   forall (M N : Term) (n m : nat), M ↑ n # m = N ↑ n # m -> M = N

(dependent evars:)


intros M; induction M; destruct N; intros;
simpl in *; try (discriminate || intuition); (try (destruct (le_gt_dec m v) ; discriminate)).
4 subgoals, subgoal 1 (ID 229)
  
  v : Vars
  v0 : Vars
  n : nat
  m : nat
  H : (if le_gt_dec m v then #(n + v) else #v) =
      (if le_gt_dec m v0 then #(n + v0) else #v0)
  ============================
   #v = #v0

subgoal 2 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 3 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 4 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


destruct (le_gt_dec m v); destruct (le_gt_dec m v0) ; injection H; intros; subst; intuition.
6 subgoals, subgoal 1 (ID 967)
  
  v : Vars
  v0 : Vars
  n : nat
  m : nat
  l : m <= v
  l0 : m <= v0
  H : #(n + v) = #(n + v0)
  H0 : n + v = n + v0
  ============================
   #v = #v0

subgoal 2 (ID 976) is:
 #v = #(n + v)
subgoal 3 (ID 982) is:
 #(n + v0) = #v0
subgoal 4 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 5 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 6 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


apply plus_reg_l in H0; rewrite H0; trivial.
5 subgoals, subgoal 1 (ID 976)
  
  v : Vars
  n : nat
  m : nat
  l : m <= v
  g : m > n + v
  H : #(n + v) = #(n + v)
  ============================
   #v = #(n + v)

subgoal 2 (ID 982) is:
 #(n + v0) = #v0
subgoal 3 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 4 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 5 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


elim (lt_irrefl m).
5 subgoals, subgoal 1 (ID 1055)
  
  v : Vars
  n : nat
  m : nat
  l : m <= v
  g : m > n + v
  H : #(n + v) = #(n + v)
  ============================
   m < m

subgoal 2 (ID 982) is:
 #(n + v0) = #v0
subgoal 3 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 4 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 5 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

apply le_lt_trans with v.
6 subgoals, subgoal 1 (ID 1056)
  
  v : Vars
  n : nat
  m : nat
  l : m <= v
  g : m > n + v
  H : #(n + v) = #(n + v)
  ============================
   m <= v

subgoal 2 (ID 1057) is:
 v < m
subgoal 3 (ID 982) is:
 #(n + v0) = #v0
subgoal 4 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 5 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 6 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

trivial.
5 subgoals, subgoal 1 (ID 1057)
  
  v : Vars
  n : nat
  m : nat
  l : m <= v
  g : m > n + v
  H : #(n + v) = #(n + v)
  ============================
   v < m

subgoal 2 (ID 982) is:
 #(n + v0) = #v0
subgoal 3 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 4 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 5 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

induction n; intuition.
4 subgoals, subgoal 1 (ID 982)
  
  v0 : Vars
  n : nat
  m : nat
  l : m <= v0
  g : m > n + v0
  H : #(n + v0) = #(n + v0)
  ============================
   #(n + v0) = #v0

subgoal 2 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 3 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 4 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


elim (lt_irrefl v0).
4 subgoals, subgoal 1 (ID 1095)
  
  v0 : Vars
  n : nat
  m : nat
  l : m <= v0
  g : m > n + v0
  H : #(n + v0) = #(n + v0)
  ============================
   v0 < v0

subgoal 2 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 3 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 4 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

apply lt_le_trans with m.
5 subgoals, subgoal 1 (ID 1096)
  
  v0 : Vars
  n : nat
  m : nat
  l : m <= v0
  g : m > n + v0
  H : #(n + v0) = #(n + v0)
  ============================
   v0 < m

subgoal 2 (ID 1097) is:
 m <= v0
subgoal 3 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 4 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 5 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

induction n; intuition.
4 subgoals, subgoal 1 (ID 1097)
  
  v0 : Vars
  n : nat
  m : nat
  l : m <= v0
  g : m > n + v0
  H : #(n + v0) = #(n + v0)
  ============================
   m <= v0

subgoal 2 (ID 335) is:
 M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4
subgoal 3 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 4 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

trivial.
3 subgoals, subgoal 1 (ID 335)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (n m : nat), M1 ↑ n # m = N ↑ n # m -> M1 = N
  IHM2 : forall (N : Term) (n m : nat), M2 ↑ n # m = N ↑ n # m -> M2 = N
  IHM3 : forall (N : Term) (n m : nat), M3 ↑ n # m = N ↑ n # m -> M3 = N
  IHM4 : forall (N : Term) (n m : nat), M4 ↑ n # m = N ↑ n # m -> M4 = N
  N1 : Term
  N2 : Term
  N3 : Term
  N4 : Term
  n : nat
  m : nat
  H : M1 ↑ n # m ·( M2 ↑ n # m, M3 ↑ n # (S m))M4 ↑ n # m =
      N1 ↑ n # m ·( N2 ↑ n # m, N3 ↑ n # (S m))N4 ↑ n # m
  ============================
   M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4

subgoal 2 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 3 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


injection H; intros; subst; clear H.
3 subgoals, subgoal 1 (ID 1155)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (n m : nat), M1 ↑ n # m = N ↑ n # m -> M1 = N
  IHM2 : forall (N : Term) (n m : nat), M2 ↑ n # m = N ↑ n # m -> M2 = N
  IHM3 : forall (N : Term) (n m : nat), M3 ↑ n # m = N ↑ n # m -> M3 = N
  IHM4 : forall (N : Term) (n m : nat), M4 ↑ n # m = N ↑ n # m -> M4 = N
  N1 : Term
  N2 : Term
  N3 : Term
  N4 : Term
  n : nat
  m : nat
  H0 : M4 ↑ n # m = N4 ↑ n # m
  H1 : M3 ↑ n # (S m) = N3 ↑ n # (S m)
  H2 : M2 ↑ n # m = N2 ↑ n # m
  H3 : M1 ↑ n # m = N1 ↑ n # m
  ============================
   M1 ·( M2, M3)M4 = N1 ·( N2, N3)N4

subgoal 2 (ID 403) is:
 Π (M1), M2 = Π (N1), N2
subgoal 3 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

rewrite (IHM1 N1 n m H3); rewrite (IHM2 N2 n m H2);
  rewrite (IHM3 N3 n (S m) H1); rewrite (IHM4 N4 n m H0); reflexivity.
2 subgoals, subgoal 1 (ID 403)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (n m : nat), M1 ↑ n # m = N ↑ n # m -> M1 = N
  IHM2 : forall (N : Term) (n m : nat), M2 ↑ n # m = N ↑ n # m -> M2 = N
  N1 : Term
  N2 : Term
  n : nat
  m : nat
  H : Π (M1 ↑ n # m), M2 ↑ n # (S m) = Π (N1 ↑ n # m), N2 ↑ n # (S m)
  ============================
   Π (M1), M2 = Π (N1), N2

subgoal 2 (ID 463) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


injection H; intros; rewrite (IHM1 N1 n m H1); rewrite (IHM2 N2 n (S m) H0); reflexivity.
1 subgoals, subgoal 1 (ID 463)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (n m : nat), M1 ↑ n # m = N ↑ n # m -> M1 = N
  IHM2 : forall (N : Term) (n m : nat), M2 ↑ n # m = N ↑ n # m -> M2 = N
  N1 : Term
  N2 : Term
  n : nat
  m : nat
  H : λ [M1 ↑ n # m], M2 ↑ n # (S m) = λ [N1 ↑ n # m], N2 ↑ n # (S m)
  ============================
   λ [M1], M2 = λ [N1], N2

(dependent evars:)


injection H; intros; rewrite (IHM1 N1 n m H1); rewrite (IHM2 N2 n (S m) H0); reflexivity.
No more subgoals.
(dependent evars:)


Qed.
inv_lift is defined



Lemma lift_rec0 : forall M n, M 0 # n = M.
1 subgoals, subgoal 1 (ID 1190)
  
  ============================
   forall (M : Term) (n : nat), M ↑ 0 # n = M

(dependent evars:)


induction M; intros; simpl.
5 subgoals, subgoal 1 (ID 1230)
  
  v : Vars
  n : nat
  ============================
   (if le_gt_dec n v then #v else #v) = #v

subgoal 2 (ID 1231) is:
 !s = !s
subgoal 3 (ID 1232) is:
 M1 ↑ 0 # n ·( M2 ↑ 0 # n, M3 ↑ 0 # (S n))M4 ↑ 0 # n = M1 ·( M2, M3)M4
subgoal 4 (ID 1233) is:
 Π (M1 ↑ 0 # n), M2 ↑ 0 # (S n) = Π (M1), M2
subgoal 5 (ID 1234) is:
 λ [M1 ↑ 0 # n], M2 ↑ 0 # (S n) = λ [M1], M2
(dependent evars:)


destruct (le_gt_dec n v); reflexivity.
4 subgoals, subgoal 1 (ID 1231)
  
  s : Sorts
  n : nat
  ============================
   !s = !s

subgoal 2 (ID 1232) is:
 M1 ↑ 0 # n ·( M2 ↑ 0 # n, M3 ↑ 0 # (S n))M4 ↑ 0 # n = M1 ·( M2, M3)M4
subgoal 3 (ID 1233) is:
 Π (M1 ↑ 0 # n), M2 ↑ 0 # (S n) = Π (M1), M2
subgoal 4 (ID 1234) is:
 λ [M1 ↑ 0 # n], M2 ↑ 0 # (S n) = λ [M1], M2
(dependent evars:)


reflexivity.
3 subgoals, subgoal 1 (ID 1232)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall n : nat, M1 ↑ 0 # n = M1
  IHM2 : forall n : nat, M2 ↑ 0 # n = M2
  IHM3 : forall n : nat, M3 ↑ 0 # n = M3
  IHM4 : forall n : nat, M4 ↑ 0 # n = M4
  n : nat
  ============================
   M1 ↑ 0 # n ·( M2 ↑ 0 # n, M3 ↑ 0 # (S n))M4 ↑ 0 # n = M1 ·( M2, M3)M4

subgoal 2 (ID 1233) is:
 Π (M1 ↑ 0 # n), M2 ↑ 0 # (S n) = Π (M1), M2
subgoal 3 (ID 1234) is:
 λ [M1 ↑ 0 # n], M2 ↑ 0 # (S n) = λ [M1], M2
(dependent evars:)


rewrite IHM1; rewrite IHM2; rewrite IHM3; rewrite IHM4; reflexivity.
2 subgoals, subgoal 1 (ID 1233)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 0 # n = M1
  IHM2 : forall n : nat, M2 ↑ 0 # n = M2
  n : nat
  ============================
   Π (M1 ↑ 0 # n), M2 ↑ 0 # (S n) = Π (M1), M2

subgoal 2 (ID 1234) is:
 λ [M1 ↑ 0 # n], M2 ↑ 0 # (S n) = λ [M1], M2
(dependent evars:)


rewrite IHM1; rewrite IHM2; reflexivity.
1 subgoals, subgoal 1 (ID 1234)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 0 # n = M1
  IHM2 : forall n : nat, M2 ↑ 0 # n = M2
  n : nat
  ============================
   λ [M1 ↑ 0 # n], M2 ↑ 0 # (S n) = λ [M1], M2

(dependent evars:)


rewrite IHM1; rewrite IHM2; reflexivity.
No more subgoals.
(dependent evars:)


Qed.
lift_rec0 is defined



Lemma lift0 : forall M, M 0 = M .
1 subgoals, subgoal 1 (ID 1261)
  
  ============================
   forall M : Term, M ↑ 0 = M

(dependent evars:)


intros; apply lift_rec0.
No more subgoals.
(dependent evars:)


Qed.
lift0 is defined



Lemma liftP1 : forall M i j k, (M j # i) k # (j+i) = M (j+k) # i.
1 subgoals, subgoal 1 (ID 1268)
  
  ============================
   forall (M : Term) (i j k : nat), M ↑ j # i ↑ k # (j + i) = M ↑ (j + k) # i

(dependent evars:)


intros M; induction M; intros;simpl.
5 subgoals, subgoal 1 (ID 1318)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  ============================
   (if le_gt_dec i v then #(j + v) else #v) ↑ k # (j + i) =
   (if le_gt_dec i v then #(j + k + v) else #v)

subgoal 2 (ID 1319) is:
 !s = !s
subgoal 3 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 4 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 5 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


destruct (le_gt_dec i v); simpl.
6 subgoals, subgoal 1 (ID 1333)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  ============================
   (if le_gt_dec (j + i) (j + v) then #(k + (j + v)) else #(j + v)) =
   #(j + k + v)

subgoal 2 (ID 1334) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 3 (ID 1319) is:
 !s = !s
subgoal 4 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 5 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 6 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


destruct (le_gt_dec (j+i) (j+v)); simpl.
7 subgoals, subgoal 1 (ID 1345)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  l0 : j + i <= j + v
  ============================
   #(k + (j + v)) = #(j + k + v)

subgoal 2 (ID 1346) is:
 #(j + v) = #(j + k + v)
subgoal 3 (ID 1334) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 4 (ID 1319) is:
 !s = !s
subgoal 5 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 6 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 7 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


rewrite plus_assoc.
7 subgoals, subgoal 1 (ID 1347)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  l0 : j + i <= j + v
  ============================
   #(k + j + v) = #(j + k + v)

subgoal 2 (ID 1346) is:
 #(j + v) = #(j + k + v)
subgoal 3 (ID 1334) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 4 (ID 1319) is:
 !s = !s
subgoal 5 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 6 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 7 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)

replace (k+j) with (j+k) by (apply plus_comm).
7 subgoals, subgoal 1 (ID 1351)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  l0 : j + i <= j + v
  ============================
   #(j + k + v) = #(j + k + v)

subgoal 2 (ID 1346) is:
 #(j + v) = #(j + k + v)
subgoal 3 (ID 1334) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 4 (ID 1319) is:
 !s = !s
subgoal 5 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 6 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 7 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 1346)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  g : j + i > j + v
  ============================
   #(j + v) = #(j + k + v)

subgoal 2 (ID 1334) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 3 (ID 1319) is:
 !s = !s
subgoal 4 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 5 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 6 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


apply plus_gt_reg_l in g.
6 subgoals, subgoal 1 (ID 1354)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  g : i > v
  ============================
   #(j + v) = #(j + k + v)

subgoal 2 (ID 1334) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 3 (ID 1319) is:
 !s = !s
subgoal 4 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 5 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 6 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)

elim (lt_irrefl v).
6 subgoals, subgoal 1 (ID 1355)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  g : i > v
  ============================
   v < v

subgoal 2 (ID 1334) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 3 (ID 1319) is:
 !s = !s
subgoal 4 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 5 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 6 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


apply lt_le_trans with i; intuition.
5 subgoals, subgoal 1 (ID 1334)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  g : i > v
  ============================
   (if le_gt_dec (j + i) v then #(k + v) else #v) = #v

subgoal 2 (ID 1319) is:
 !s = !s
subgoal 3 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 4 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 5 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


simpl; destruct (le_gt_dec (j+i)); intuition.
5 subgoals, subgoal 1 (ID 1367)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  g : i > v
  l : j + i <= v
  ============================
   #(k + v) = #v

subgoal 2 (ID 1319) is:
 !s = !s
subgoal 3 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 4 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 5 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


elim (lt_irrefl v).
5 subgoals, subgoal 1 (ID 1390)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  g : i > v
  l : j + i <= v
  ============================
   v < v

subgoal 2 (ID 1319) is:
 !s = !s
subgoal 3 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 4 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 5 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


apply lt_le_trans with i; intuition.
5 subgoals, subgoal 1 (ID 1392)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  g : i > v
  l : j + i <= v
  ============================
   i <= v

subgoal 2 (ID 1319) is:
 !s = !s
subgoal 3 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 4 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 5 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)

induction j; intuition.
4 subgoals, subgoal 1 (ID 1319)
  
  s : Sorts
  i : nat
  j : nat
  k : nat
  ============================
   !s = !s

subgoal 2 (ID 1320) is:
 M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
 M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))M4 ↑ (j + k) # i
subgoal 3 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 4 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


reflexivity.
3 subgoals, subgoal 1 (ID 1320)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k : nat, M1 ↑ j # i ↑ k # (j + i) = M1 ↑ (j + k) # i
  IHM2 : forall i j k : nat, M2 ↑ j # i ↑ k # (j + i) = M2 ↑ (j + k) # i
  IHM3 : forall i j k : nat, M3 ↑ j # i ↑ k # (j + i) = M3 ↑ (j + k) # i
  IHM4 : forall i j k : nat, M4 ↑ j # i ↑ k # (j + i) = M4 ↑ (j + k) # i
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ j # i ↑ k # (j + i) ·( M2 ↑ j # i ↑ k # (j + i),
   M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))
   M4 ↑ (j + k) # i

subgoal 2 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 3 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


rewrite IHM1.
3 subgoals, subgoal 1 (ID 1434)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k : nat, M1 ↑ j # i ↑ k # (j + i) = M1 ↑ (j + k) # i
  IHM2 : forall i j k : nat, M2 ↑ j # i ↑ k # (j + i) = M2 ↑ (j + k) # i
  IHM3 : forall i j k : nat, M3 ↑ j # i ↑ k # (j + i) = M3 ↑ (j + k) # i
  IHM4 : forall i j k : nat, M4 ↑ j # i ↑ k # (j + i) = M4 ↑ (j + k) # i
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ (j + k) # i ·( M2 ↑ j # i ↑ k # (j + i),
   M3 ↑ j # (S i) ↑ k # (S (j + i)))M4 ↑ j # i ↑ k # (j + i) =
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))
   M4 ↑ (j + k) # i

subgoal 2 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 3 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)

rewrite IHM2.
3 subgoals, subgoal 1 (ID 1435)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k : nat, M1 ↑ j # i ↑ k # (j + i) = M1 ↑ (j + k) # i
  IHM2 : forall i j k : nat, M2 ↑ j # i ↑ k # (j + i) = M2 ↑ (j + k) # i
  IHM3 : forall i j k : nat, M3 ↑ j # i ↑ k # (j + i) = M3 ↑ (j + k) # i
  IHM4 : forall i j k : nat, M4 ↑ j # i ↑ k # (j + i) = M4 ↑ (j + k) # i
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ j # (S i) ↑ k # (S (j + i)))
   M4 ↑ j # i ↑ k # (j + i) =
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))
   M4 ↑ (j + k) # i

subgoal 2 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 3 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)

rewrite IHM4.
3 subgoals, subgoal 1 (ID 1436)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k : nat, M1 ↑ j # i ↑ k # (j + i) = M1 ↑ (j + k) # i
  IHM2 : forall i j k : nat, M2 ↑ j # i ↑ k # (j + i) = M2 ↑ (j + k) # i
  IHM3 : forall i j k : nat, M3 ↑ j # i ↑ k # (j + i) = M3 ↑ (j + k) # i
  IHM4 : forall i j k : nat, M4 ↑ j # i ↑ k # (j + i) = M4 ↑ (j + k) # i
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ j # (S i) ↑ k # (S (j + i)))
   M4 ↑ (j + k) # i =
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ (j + k) # (S i))
   M4 ↑ (j + k) # i

subgoal 2 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 3 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)

rewrite <- IHM3.
3 subgoals, subgoal 1 (ID 1437)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k : nat, M1 ↑ j # i ↑ k # (j + i) = M1 ↑ (j + k) # i
  IHM2 : forall i j k : nat, M2 ↑ j # i ↑ k # (j + i) = M2 ↑ (j + k) # i
  IHM3 : forall i j k : nat, M3 ↑ j # i ↑ k # (j + i) = M3 ↑ (j + k) # i
  IHM4 : forall i j k : nat, M4 ↑ j # i ↑ k # (j + i) = M4 ↑ (j + k) # i
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ j # (S i) ↑ k # (S (j + i)))
   M4 ↑ (j + k) # i =
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ j # (S i) ↑ k # (j + S i))
   M4 ↑ (j + k) # i

subgoal 2 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 3 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


replace (j+S i) with (S(j+i)) by intuition.
3 subgoals, subgoal 1 (ID 1441)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k : nat, M1 ↑ j # i ↑ k # (j + i) = M1 ↑ (j + k) # i
  IHM2 : forall i j k : nat, M2 ↑ j # i ↑ k # (j + i) = M2 ↑ (j + k) # i
  IHM3 : forall i j k : nat, M3 ↑ j # i ↑ k # (j + i) = M3 ↑ (j + k) # i
  IHM4 : forall i j k : nat, M4 ↑ j # i ↑ k # (j + i) = M4 ↑ (j + k) # i
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ j # (S i) ↑ k # (S (j + i)))
   M4 ↑ (j + k) # i =
   M1 ↑ (j + k) # i ·( M2 ↑ (j + k) # i, M3 ↑ j # (S i) ↑ k # (S (j + i)))
   M4 ↑ (j + k) # i

subgoal 2 (ID 1321) is:
 Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)
subgoal 3 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)

trivial.
2 subgoals, subgoal 1 (ID 1321)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i j k : nat, M1 ↑ j # i ↑ k # (j + i) = M1 ↑ (j + k) # i
  IHM2 : forall i j k : nat, M2 ↑ j # i ↑ k # (j + i) = M2 ↑ (j + k) # i
  i : nat
  j : nat
  k : nat
  ============================
   Π (M1 ↑ j # i ↑ k # (j + i)), M2 ↑ j # (S i) ↑ k # (S (j + i)) =
   Π (M1 ↑ (j + k) # i), M2 ↑ (j + k) # (S i)

subgoal 2 (ID 1322) is:
 λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
 λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)
(dependent evars:)


rewrite IHM1; rewrite <-IHM2 ;replace (j+S i) with (S(j+i)) by intuition; reflexivity.
1 subgoals, subgoal 1 (ID 1322)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i j k : nat, M1 ↑ j # i ↑ k # (j + i) = M1 ↑ (j + k) # i
  IHM2 : forall i j k : nat, M2 ↑ j # i ↑ k # (j + i) = M2 ↑ (j + k) # i
  i : nat
  j : nat
  k : nat
  ============================
   λ [M1 ↑ j # i ↑ k # (j + i)], M2 ↑ j # (S i) ↑ k # (S (j + i)) =
   λ [M1 ↑ (j + k) # i], M2 ↑ (j + k) # (S i)

(dependent evars:)


rewrite IHM1; rewrite <- IHM2 ;replace (j+S i) with (S(j+i)) by intuition; reflexivity.
No more subgoals.
(dependent evars:)


Qed.
liftP1 is defined



Lemma liftP2: forall M i j k n, i <= n ->
  (M j # i) k # (j+n) = (M k # n) j # i.
1 subgoals, subgoal 1 (ID 1502)
  
  ============================
   forall (M : Term) (i j k n : nat),
   i <= n -> M ↑ j # i ↑ k # (j + n) = M ↑ k # n ↑ j # i

(dependent evars:)


intro M; induction M; intros; simpl.
5 subgoals, subgoal 1 (ID 1562)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   (if le_gt_dec i v then #(j + v) else #v) ↑ k # (j + n) =
   (if le_gt_dec n v then #(k + v) else #v) ↑ j # i

subgoal 2 (ID 1563) is:
 !s = !s
subgoal 3 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 4 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 5 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


destruct (le_gt_dec i v); destruct (le_gt_dec n v).
8 subgoals, subgoal 1 (ID 1585)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  ============================
   #(j + v) ↑ k # (j + n) = #(k + v) ↑ j # i

subgoal 2 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


simpl.
8 subgoals, subgoal 1 (ID 1597)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  ============================
   (if le_gt_dec (j + n) (j + v) then #(k + (j + v)) else #(j + v)) =
   (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))

subgoal 2 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


destruct le_gt_dec.
9 subgoals, subgoal 1 (ID 1606)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  l1 : j + n <= j + v
  ============================
   #(k + (j + v)) =
   (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))

subgoal 2 (ID 1607) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 5 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 6 (ID 1563) is:
 !s = !s
subgoal 7 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 8 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 9 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

destruct le_gt_dec.
10 subgoals, subgoal 1 (ID 1616)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  l1 : j + n <= j + v
  l2 : i <= k + v
  ============================
   #(k + (j + v)) = #(j + (k + v))

subgoal 2 (ID 1617) is:
 #(k + (j + v)) = #(k + v)
subgoal 3 (ID 1607) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 6 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 7 (ID 1563) is:
 !s = !s
subgoal 8 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 9 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 10 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


rewrite 2! plus_assoc.
10 subgoals, subgoal 1 (ID 1619)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  l1 : j + n <= j + v
  l2 : i <= k + v
  ============================
   #(k + j + v) = #(j + k + v)

subgoal 2 (ID 1617) is:
 #(k + (j + v)) = #(k + v)
subgoal 3 (ID 1607) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 6 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 7 (ID 1563) is:
 !s = !s
subgoal 8 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 9 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 10 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

replace (k+j) with (j+k) by (apply plus_comm).
10 subgoals, subgoal 1 (ID 1623)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  l1 : j + n <= j + v
  l2 : i <= k + v
  ============================
   #(j + k + v) = #(j + k + v)

subgoal 2 (ID 1617) is:
 #(k + (j + v)) = #(k + v)
subgoal 3 (ID 1607) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 6 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 7 (ID 1563) is:
 !s = !s
subgoal 8 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 9 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 10 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

trivial.
9 subgoals, subgoal 1 (ID 1617)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  l1 : j + n <= j + v
  g : i > k + v
  ============================
   #(k + (j + v)) = #(k + v)

subgoal 2 (ID 1607) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 5 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 6 (ID 1563) is:
 !s = !s
subgoal 7 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 8 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 9 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


elim (lt_irrefl v).
9 subgoals, subgoal 1 (ID 1625)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  l1 : j + n <= j + v
  g : i > k + v
  ============================
   v < v

subgoal 2 (ID 1607) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 5 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 6 (ID 1563) is:
 !s = !s
subgoal 7 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 8 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 9 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

apply lt_le_trans with i.
10 subgoals, subgoal 1 (ID 1626)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  l1 : j + n <= j + v
  g : i > k + v
  ============================
   v < i

subgoal 2 (ID 1627) is:
 i <= v
subgoal 3 (ID 1607) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 6 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 7 (ID 1563) is:
 !s = !s
subgoal 8 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 9 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 10 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

induction k; intuition.
9 subgoals, subgoal 1 (ID 1627)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  l1 : j + n <= j + v
  g : i > k + v
  ============================
   i <= v

subgoal 2 (ID 1607) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 5 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 6 (ID 1563) is:
 !s = !s
subgoal 7 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 8 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 9 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

trivial.
8 subgoals, subgoal 1 (ID 1607)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  g : j + n > j + v
  ============================
   #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))

subgoal 2 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


apply plus_gt_reg_l in g.
8 subgoals, subgoal 1 (ID 1666)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  g : n > v
  ============================
   #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))

subgoal 2 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl v).
8 subgoals, subgoal 1 (ID 1667)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n <= v
  g : n > v
  ============================
   v < v

subgoal 2 (ID 1586) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


apply lt_le_trans with n; intuition.
7 subgoals, subgoal 1 (ID 1586)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  ============================
   #(j + v) ↑ k # (j + n) = #v ↑ j # i

subgoal 2 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


simpl.
7 subgoals, subgoal 1 (ID 1670)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  ============================
   (if le_gt_dec (j + n) (j + v) then #(k + (j + v)) else #(j + v)) =
   (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


destruct le_gt_dec.
8 subgoals, subgoal 1 (ID 1679)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  l0 : j + n <= j + v
  ============================
   #(k + (j + v)) = (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 1680) is:
 #(j + v) = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

apply plus_le_reg_l in l0.
8 subgoals, subgoal 1 (ID 1682)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  l0 : n <= v
  ============================
   #(k + (j + v)) = (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 1680) is:
 #(j + v) = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl v).
8 subgoals, subgoal 1 (ID 1683)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  l0 : n <= v
  ============================
   v < v

subgoal 2 (ID 1680) is:
 #(j + v) = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


apply lt_le_trans with n; intuition.
7 subgoals, subgoal 1 (ID 1680)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  g0 : j + n > j + v
  ============================
   #(j + v) = (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

destruct le_gt_dec.
8 subgoals, subgoal 1 (ID 1694)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  g0 : j + n > j + v
  l0 : i <= v
  ============================
   #(j + v) = #(j + v)

subgoal 2 (ID 1695) is:
 #(j + v) = #v
subgoal 3 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

trivial.
7 subgoals, subgoal 1 (ID 1695)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  g0 : j + n > j + v
  g1 : i > v
  ============================
   #(j + v) = #v

subgoal 2 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


elim (lt_irrefl v).
7 subgoals, subgoal 1 (ID 1696)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  l : i <= v
  g : n > v
  g0 : j + n > j + v
  g1 : i > v
  ============================
   v < v

subgoal 2 (ID 1595) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

apply lt_le_trans with i; intuition.
6 subgoals, subgoal 1 (ID 1595)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  ============================
   #v ↑ k # (j + n) = #(k + v) ↑ j # i

subgoal 2 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


simpl.
6 subgoals, subgoal 1 (ID 1699)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  ============================
   (if le_gt_dec (j + n) v then #(k + v) else #v) =
   (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))

subgoal 2 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

destruct le_gt_dec.
7 subgoals, subgoal 1 (ID 1708)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  l0 : j + n <= v
  ============================
   #(k + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))

subgoal 2 (ID 1709) is:
 #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl n).
7 subgoals, subgoal 1 (ID 1710)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  l0 : j + n <= v
  ============================
   n < n

subgoal 2 (ID 1709) is:
 #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

apply lt_le_trans with i.
8 subgoals, subgoal 1 (ID 1711)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  l0 : j + n <= v
  ============================
   n < i

subgoal 2 (ID 1712) is:
 i <= n
subgoal 3 (ID 1709) is:
 #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1563) is:
 !s = !s
subgoal 6 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 7 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 8 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


apply le_lt_trans with v; intuition.
7 subgoals, subgoal 1 (ID 1712)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  l0 : j + n <= v
  ============================
   i <= n

subgoal 2 (ID 1709) is:
 #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 1709)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  g0 : j + n > v
  ============================
   #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))

subgoal 2 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl v).
6 subgoals, subgoal 1 (ID 1715)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  g0 : j + n > v
  ============================
   v < v

subgoal 2 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


apply lt_le_trans with n.
7 subgoals, subgoal 1 (ID 1716)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  g0 : j + n > v
  ============================
   v < n

subgoal 2 (ID 1717) is:
 n <= v
subgoal 3 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

apply lt_le_trans with i; intuition.
6 subgoals, subgoal 1 (ID 1717)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  l : n <= v
  g0 : j + n > v
  ============================
   n <= v

subgoal 2 (ID 1596) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

trivial.
5 subgoals, subgoal 1 (ID 1596)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  ============================
   #v ↑ k # (j + n) = #v ↑ j # i

subgoal 2 (ID 1563) is:
 !s = !s
subgoal 3 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 4 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 5 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


simpl.
5 subgoals, subgoal 1 (ID 1720)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  ============================
   (if le_gt_dec (j + n) v then #(k + v) else #v) =
   (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 1563) is:
 !s = !s
subgoal 3 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 4 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 5 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

destruct le_gt_dec.
6 subgoals, subgoal 1 (ID 1729)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  l : j + n <= v
  ============================
   #(k + v) = (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 1730) is:
 #v = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl v).
6 subgoals, subgoal 1 (ID 1731)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  l : j + n <= v
  ============================
   v < v

subgoal 2 (ID 1730) is:
 #v = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

apply lt_le_trans with n.
7 subgoals, subgoal 1 (ID 1732)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  l : j + n <= v
  ============================
   v < n

subgoal 2 (ID 1733) is:
 n <= v
subgoal 3 (ID 1730) is:
 #v = (if le_gt_dec i v then #(j + v) else #v)
subgoal 4 (ID 1563) is:
 !s = !s
subgoal 5 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 6 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 7 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


intuition.
6 subgoals, subgoal 1 (ID 1733)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  l : j + n <= v
  ============================
   n <= v

subgoal 2 (ID 1730) is:
 #v = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

induction j; intuition.
5 subgoals, subgoal 1 (ID 1730)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  g1 : j + n > v
  ============================
   #v = (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 1563) is:
 !s = !s
subgoal 3 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 4 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 5 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

destruct le_gt_dec.
6 subgoals, subgoal 1 (ID 1768)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  g1 : j + n > v
  l : i <= v
  ============================
   #v = #(j + v)

subgoal 2 (ID 1769) is:
 #v = #v
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl i).
6 subgoals, subgoal 1 (ID 1770)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  g1 : j + n > v
  l : i <= v
  ============================
   i < i

subgoal 2 (ID 1769) is:
 #v = #v
subgoal 3 (ID 1563) is:
 !s = !s
subgoal 4 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 5 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 6 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


apply le_lt_trans with v; intuition.
5 subgoals, subgoal 1 (ID 1769)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  g : i > v
  g0 : n > v
  g1 : j + n > v
  g2 : i > v
  ============================
   #v = #v

subgoal 2 (ID 1563) is:
 !s = !s
subgoal 3 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 4 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 5 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

trivial.
4 subgoals, subgoal 1 (ID 1563)
  
  s : Sorts
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   !s = !s

subgoal 2 (ID 1564) is:
 M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
 M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
 M4 ↑ k # n ↑ j # i
subgoal 3 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 4 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


trivial.
3 subgoals, subgoal 1 (ID 1564)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  IHM3 : forall i j k n : nat,
         i <= n -> M3 ↑ j # i ↑ k # (j + n) = M3 ↑ k # n ↑ j # i
  IHM4 : forall i j k n : nat,
         i <= n -> M4 ↑ j # i ↑ k # (j + n) = M4 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   M1 ↑ j # i ↑ k # (j + n) ·( M2 ↑ j # i ↑ k # (j + n),
   M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
   M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
   M4 ↑ k # n ↑ j # i

subgoal 2 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 3 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)



rewrite IHM1; intuition.
3 subgoals, subgoal 1 (ID 1773)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  IHM3 : forall i j k n : nat,
         i <= n -> M3 ↑ j # i ↑ k # (j + n) = M3 ↑ k # n ↑ j # i
  IHM4 : forall i j k n : nat,
         i <= n -> M4 ↑ j # i ↑ k # (j + n) = M4 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   M1 ↑ k # n ↑ j # i ·( M2 ↑ j # i ↑ k # (j + n),
   M3 ↑ j # (S i) ↑ k # (S (j + n)))M4 ↑ j # i ↑ k # (j + n) =
   M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
   M4 ↑ k # n ↑ j # i

subgoal 2 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 3 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

replace (S(j+n)) with (j+S n) by intuition.
3 subgoals, subgoal 1 (ID 1795)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  IHM3 : forall i j k n : nat,
         i <= n -> M3 ↑ j # i ↑ k # (j + n) = M3 ↑ k # n ↑ j # i
  IHM4 : forall i j k n : nat,
         i <= n -> M4 ↑ j # i ↑ k # (j + n) = M4 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   M1 ↑ k # n ↑ j # i ·( M2 ↑ j # i ↑ k # (j + n),
   M3 ↑ j # (S i) ↑ k # (j + S n))M4 ↑ j # i ↑ k # (j + n) =
   M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
   M4 ↑ k # n ↑ j # i

subgoal 2 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 3 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


rewrite IHM2; intuition.
3 subgoals, subgoal 1 (ID 1816)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  IHM3 : forall i j k n : nat,
         i <= n -> M3 ↑ j # i ↑ k # (j + n) = M3 ↑ k # n ↑ j # i
  IHM4 : forall i j k n : nat,
         i <= n -> M4 ↑ j # i ↑ k # (j + n) = M4 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ j # (S i) ↑ k # (j + S n))
   M4 ↑ j # i ↑ k # (j + n) =
   M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
   M4 ↑ k # n ↑ j # i

subgoal 2 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 3 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

rewrite IHM3; intuition.
3 subgoals, subgoal 1 (ID 1835)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  IHM3 : forall i j k n : nat,
         i <= n -> M3 ↑ j # i ↑ k # (j + n) = M3 ↑ k # n ↑ j # i
  IHM4 : forall i j k n : nat,
         i <= n -> M4 ↑ j # i ↑ k # (j + n) = M4 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
   M4 ↑ j # i ↑ k # (j + n) =
   M1 ↑ k # n ↑ j # i ·( M2 ↑ k # n ↑ j # i, M3 ↑ k # (S n) ↑ j # (S i))
   M4 ↑ k # n ↑ j # i

subgoal 2 (ID 1565) is:
 Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)
subgoal 3 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)

rewrite IHM4; intuition.
2 subgoals, subgoal 1 (ID 1565)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   Π (M1 ↑ j # i ↑ k # (j + n)), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
   Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)

subgoal 2 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


rewrite IHM1; intuition.
2 subgoals, subgoal 1 (ID 1873)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   Π (M1 ↑ k # n ↑ j # i), M2 ↑ j # (S i) ↑ k # (S (j + n)) =
   Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)

subgoal 2 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


replace (S(j+n)) with (j+S n) by intuition.
2 subgoals, subgoal 1 (ID 1891)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   Π (M1 ↑ k # n ↑ j # i), M2 ↑ j # (S i) ↑ k # (j + S n) =
   Π (M1 ↑ k # n ↑ j # i), M2 ↑ k # (S n) ↑ j # (S i)

subgoal 2 (ID 1566) is:
 λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
 λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)
(dependent evars:)


rewrite (IHM2 (S i) j k (S n)); intuition.
1 subgoals, subgoal 1 (ID 1566)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   λ [M1 ↑ j # i ↑ k # (j + n)], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
   λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)

(dependent evars:)


rewrite IHM1; intuition.
1 subgoals, subgoal 1 (ID 1923)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   λ [M1 ↑ k # n ↑ j # i], M2 ↑ j # (S i) ↑ k # (S (j + n)) =
   λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)

(dependent evars:)


replace (S(j+n)) with (j+S n) by intuition.
1 subgoals, subgoal 1 (ID 1941)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i j k n : nat,
         i <= n -> M1 ↑ j # i ↑ k # (j + n) = M1 ↑ k # n ↑ j # i
  IHM2 : forall i j k n : nat,
         i <= n -> M2 ↑ j # i ↑ k # (j + n) = M2 ↑ k # n ↑ j # i
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   λ [M1 ↑ k # n ↑ j # i], M2 ↑ j # (S i) ↑ k # (j + S n) =
   λ [M1 ↑ k # n ↑ j # i], M2 ↑ k # (S n) ↑ j # (S i)

(dependent evars:)


rewrite (IHM2 (S i) j k (S n) ); intuition.
No more subgoals.
(dependent evars:)


Qed.
liftP2 is defined



Lemma liftP3 : forall M i k j n , i <= k -> k <= (i+n) ->
  (M n # i) j # k = M (j+n) # i.
1 subgoals, subgoal 1 (ID 1979)
  
  ============================
   forall (M : Term) (i k j n : nat),
   i <= k -> k <= i + n -> M ↑ n # i ↑ j # k = M ↑ (j + n) # i

(dependent evars:)


intro M; induction M; intros; simpl.
5 subgoals, subgoal 1 (ID 2044)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   (if le_gt_dec i v then #(n + v) else #v) ↑ j # k =
   (if le_gt_dec i v then #(j + n + v) else #v)

subgoal 2 (ID 2045) is:
 !s = !s
subgoal 3 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 4 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 5 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


destruct (le_gt_dec i v); simpl.
6 subgoals, subgoal 1 (ID 2059)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  ============================
   (if le_gt_dec k (n + v) then #(j + (n + v)) else #(n + v)) = #(j + n + v)

subgoal 2 (ID 2060) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 3 (ID 2045) is:
 !s = !s
subgoal 4 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 5 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 6 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


destruct (le_gt_dec k (n+v)); intuition.
6 subgoals, subgoal 1 (ID 2070)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  g : k > n + v
  ============================
   #(n + v) = #(j + n + v)

subgoal 2 (ID 2060) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 3 (ID 2045) is:
 !s = !s
subgoal 4 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 5 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 6 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


elim (lt_irrefl (i+n)).
6 subgoals, subgoal 1 (ID 2118)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  g : k > n + v
  ============================
   i + n < i + n

subgoal 2 (ID 2060) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 3 (ID 2045) is:
 !s = !s
subgoal 4 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 5 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 6 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

apply lt_le_trans with k.
7 subgoals, subgoal 1 (ID 2119)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  g : k > n + v
  ============================
   i + n < k

subgoal 2 (ID 2120) is:
 k <= i + n
subgoal 3 (ID 2060) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 4 (ID 2045) is:
 !s = !s
subgoal 5 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 6 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 7 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


apply le_lt_trans with (n+v).
8 subgoals, subgoal 1 (ID 2121)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  g : k > n + v
  ============================
   i + n <= n + v

subgoal 2 (ID 2122) is:
 n + v < k
subgoal 3 (ID 2120) is:
 k <= i + n
subgoal 4 (ID 2060) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 5 (ID 2045) is:
 !s = !s
subgoal 6 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 7 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 8 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

rewrite plus_comm.
8 subgoals, subgoal 1 (ID 2123)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  g : k > n + v
  ============================
   n + i <= n + v

subgoal 2 (ID 2122) is:
 n + v < k
subgoal 3 (ID 2120) is:
 k <= i + n
subgoal 4 (ID 2060) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 5 (ID 2045) is:
 !s = !s
subgoal 6 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 7 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 8 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

intuition.
7 subgoals, subgoal 1 (ID 2122)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  g : k > n + v
  ============================
   n + v < k

subgoal 2 (ID 2120) is:
 k <= i + n
subgoal 3 (ID 2060) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 4 (ID 2045) is:
 !s = !s
subgoal 5 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 6 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 7 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

intuition.
6 subgoals, subgoal 1 (ID 2120)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  g : k > n + v
  ============================
   k <= i + n

subgoal 2 (ID 2060) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 3 (ID 2045) is:
 !s = !s
subgoal 4 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 5 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 6 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

trivial.
5 subgoals, subgoal 1 (ID 2060)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  ============================
   (if le_gt_dec k v then #(j + v) else #v) = #v

subgoal 2 (ID 2045) is:
 !s = !s
subgoal 3 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 4 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 5 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


destruct (le_gt_dec k v); intuition.
5 subgoals, subgoal 1 (ID 2150)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k <= v
  ============================
   #(j + v) = #v

subgoal 2 (ID 2045) is:
 !s = !s
subgoal 3 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 4 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 5 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

elim (lt_irrefl k).
5 subgoals, subgoal 1 (ID 2176)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k <= v
  ============================
   k < k

subgoal 2 (ID 2045) is:
 !s = !s
subgoal 3 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 4 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 5 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


apply lt_le_trans with i.
6 subgoals, subgoal 1 (ID 2177)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k <= v
  ============================
   k < i

subgoal 2 (ID 2178) is:
 i <= k
subgoal 3 (ID 2045) is:
 !s = !s
subgoal 4 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 5 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 6 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

apply le_lt_trans with v.
7 subgoals, subgoal 1 (ID 2179)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k <= v
  ============================
   k <= v

subgoal 2 (ID 2180) is:
 v < i
subgoal 3 (ID 2178) is:
 i <= k
subgoal 4 (ID 2045) is:
 !s = !s
subgoal 5 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 6 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 7 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 2180)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k <= v
  ============================
   v < i

subgoal 2 (ID 2178) is:
 i <= k
subgoal 3 (ID 2045) is:
 !s = !s
subgoal 4 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 5 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 6 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

intuition.
5 subgoals, subgoal 1 (ID 2178)
  
  v : Vars
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k <= v
  ============================
   i <= k

subgoal 2 (ID 2045) is:
 !s = !s
subgoal 3 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 4 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 5 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

trivial.
4 subgoals, subgoal 1 (ID 2045)
  
  s : Sorts
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   !s = !s

subgoal 2 (ID 2046) is:
 M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
 M4 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))M4 ↑ (j + n) # i
subgoal 3 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 4 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


reflexivity.
3 subgoals, subgoal 1 (ID 2046)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  IHM3 : forall i k j n : nat,
         i <= k -> k <= i + n -> M3 ↑ n # i ↑ j # k = M3 ↑ (j + n) # i
  IHM4 : forall i k j n : nat,
         i <= k -> k <= i + n -> M4 ↑ n # i ↑ j # k = M4 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   M1 ↑ n # i ↑ j # k ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
   M4 ↑ n # i ↑ j # k =
   M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))
   M4 ↑ (j + n) # i

subgoal 2 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 3 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


rewrite IHM1; intuition.
3 subgoals, subgoal 1 (ID 2182)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  IHM3 : forall i k j n : nat,
         i <= k -> k <= i + n -> M3 ↑ n # i ↑ j # k = M3 ↑ (j + n) # i
  IHM4 : forall i k j n : nat,
         i <= k -> k <= i + n -> M4 ↑ n # i ↑ j # k = M4 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   M1 ↑ (j + n) # i ·( M2 ↑ n # i ↑ j # k, M3 ↑ n # (S i) ↑ j # (S k))
   M4 ↑ n # i ↑ j # k =
   M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))
   M4 ↑ (j + n) # i

subgoal 2 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 3 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

rewrite IHM2; intuition.
3 subgoals, subgoal 1 (ID 2203)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  IHM3 : forall i k j n : nat,
         i <= k -> k <= i + n -> M3 ↑ n # i ↑ j # k = M3 ↑ (j + n) # i
  IHM4 : forall i k j n : nat,
         i <= k -> k <= i + n -> M4 ↑ n # i ↑ j # k = M4 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ n # (S i) ↑ j # (S k))
   M4 ↑ n # i ↑ j # k =
   M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))
   M4 ↑ (j + n) # i

subgoal 2 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 3 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

rewrite IHM3; intuition.
4 subgoals, subgoal 1 (ID 2224)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  IHM3 : forall i k j n : nat,
         i <= k -> k <= i + n -> M3 ↑ n # i ↑ j # k = M3 ↑ (j + n) # i
  IHM4 : forall i k j n : nat,
         i <= k -> k <= i + n -> M4 ↑ n # i ↑ j # k = M4 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))
   M4 ↑ n # i ↑ j # k =
   M1 ↑ (j + n) # i ·( M2 ↑ (j + n) # i, M3 ↑ (j + n) # (S i))
   M4 ↑ (j + n) # i

subgoal 2 (ID 2226) is:
 S k <= S i + n
subgoal 3 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 4 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

rewrite IHM4; intuition.
3 subgoals, subgoal 1 (ID 2226)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  IHM3 : forall i k j n : nat,
         i <= k -> k <= i + n -> M3 ↑ n # i ↑ j # k = M3 ↑ (j + n) # i
  IHM4 : forall i k j n : nat,
         i <= k -> k <= i + n -> M4 ↑ n # i ↑ j # k = M4 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S i + n

subgoal 2 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 3 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


 change (S i + n) with (S (i+n)).
3 subgoals, subgoal 1 (ID 2458)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  IHM3 : forall i k j n : nat,
         i <= k -> k <= i + n -> M3 ↑ n # i ↑ j # k = M3 ↑ (j + n) # i
  IHM4 : forall i k j n : nat,
         i <= k -> k <= i + n -> M4 ↑ n # i ↑ j # k = M4 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S (i + n)

subgoal 2 (ID 2047) is:
 Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
 Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)
subgoal 3 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

intuition.
2 subgoals, subgoal 1 (ID 2047)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   Π (M1 ↑ n # i ↑ j # k), M2 ↑ n # (S i) ↑ j # (S k) =
   Π (M1 ↑ (j + n) # i), M2 ↑ (j + n) # (S i)

subgoal 2 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)


rewrite IHM1; intuition;rewrite IHM2; intuition.
2 subgoals, subgoal 1 (ID 2495)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S i + n

subgoal 2 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

change (S i + n) with (S (i+n)).
2 subgoals, subgoal 1 (ID 2698)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S (i + n)

subgoal 2 (ID 2048) is:
 λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
 λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)
(dependent evars:)

intuition.
1 subgoals, subgoal 1 (ID 2048)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   λ [M1 ↑ n # i ↑ j # k], M2 ↑ n # (S i) ↑ j # (S k) =
   λ [M1 ↑ (j + n) # i], M2 ↑ (j + n) # (S i)

(dependent evars:)


rewrite IHM1; intuition; rewrite IHM2; intuition.
1 subgoals, subgoal 1 (ID 2731)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S i + n

(dependent evars:)

change (S i + n) with (S (i+n)).
1 subgoals, subgoal 1 (ID 2934)
  
  M1 : Term
  M2 : Term
  IHM1 : forall i k j n : nat,
         i <= k -> k <= i + n -> M1 ↑ n # i ↑ j # k = M1 ↑ (j + n) # i
  IHM2 : forall i k j n : nat,
         i <= k -> k <= i + n -> M2 ↑ n # i ↑ j # k = M2 ↑ (j + n) # i
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S (i + n)

(dependent evars:)

intuition.
No more subgoals.
(dependent evars:)


Qed.
liftP3 is defined



Lemma lift_lift : forall M n m, (M m) n = M (n+m).
1 subgoals, subgoal 1 (ID 2952)
  
  ============================
   forall (M : Term) (n m : nat), M ↑ m ↑ n = M ↑ (n + m)

(dependent evars:)


intros.
1 subgoals, subgoal 1 (ID 2955)
  
  M : Term
  n : nat
  m : nat
  ============================
   M ↑ m ↑ n = M ↑ (n + m)

(dependent evars:)


apply liftP3; intuition.
No more subgoals.
(dependent evars:)


Qed.
lift_lift is defined



Reserved Notation "M [ n ← N ]" (at level 5, n at level 0, left associativity).


Fixpoint subst_rec U T n {struct T} :=
 match T with
  | # x => match (lt_eq_lt_dec x n) with
      | inleft (left _) => # x
      | inleft (right _) => U n
      | inright _ => # (x - 1)
      end
  | ! s => ! s
  | M ·(A,B) N => (M [ n U ]) ·(A[n U], B [ S n U]) ( N [ n U ])
  | Π ( A ), B => Π ( A [ n U ] ), (B [ S n U ])
  | λ [ A ], M => λ [ A [ n U ] ], (M [ S n U ])
end
    where " t [ n ← w ] " := (subst_rec w t n) : Typ_scope.
subst_rec is recursively defined (decreasing on 2nd argument)



Notation " t [ ← w ] " := (subst_rec w t 0) (at level 5) : Typ_scope.


Lemma expand_term_with_subst : forall M n, (M 1 # (S n)) [ n #0 ] = M.
1 subgoals, subgoal 1 (ID 2975)
  
  ============================
   forall (M : Term) (n : nat), M ↑ 1 # (S n) [n ← #0] = M

(dependent evars:)


induction M; intros.
5 subgoals, subgoal 1 (ID 3010)
  
  v : Vars
  n : nat
  ============================
   #v ↑ 1 # (S n) [n ← #0] = #v

subgoal 2 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 4 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


unfold lift_rec.
5 subgoals, subgoal 1 (ID 3015)
  
  v : Vars
  n : nat
  ============================
   (if le_gt_dec (S n) v then #(1 + v) else #v) [n ← #0] = #v

subgoal 2 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 4 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


destruct (le_gt_dec (S n) v).
6 subgoals, subgoal 1 (ID 3024)
  
  v : Vars
  n : nat
  l : S n <= v
  ============================
   #(1 + v) [n ← #0] = #v

subgoal 2 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 3 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 5 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

unfold subst_rec.
6 subgoals, subgoal 1 (ID 3026)
  
  v : Vars
  n : nat
  l : S n <= v
  ============================
   match lt_eq_lt_dec (1 + v) n with
   | inleft (left _) => #(1 + v)
   | inleft (right _) => #0 ↑ n
   | inright _ => #(1 + v - 1)
   end = #v

subgoal 2 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 3 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 5 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


destruct (lt_eq_lt_dec (1+v) n) as [[] | ].
8 subgoals, subgoal 1 (ID 3040)
  
  v : Vars
  n : nat
  l : S n <= v
  l0 : 1 + v < n
  ============================
   #(1 + v) = #v

subgoal 2 (ID 3041) is:
 #0 ↑ n = #v
subgoal 3 (ID 3042) is:
 #(1 + v - 1) = #v
subgoal 4 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 5 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 6 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 7 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 8 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


apply le_not_lt in l.
8 subgoals, subgoal 1 (ID 3044)
  
  v : Vars
  n : nat
  l : ~ v < S n
  l0 : 1 + v < n
  ============================
   #(1 + v) = #v

subgoal 2 (ID 3041) is:
 #0 ↑ n = #v
subgoal 3 (ID 3042) is:
 #(1 + v - 1) = #v
subgoal 4 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 5 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 6 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 7 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 8 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

elim l.
8 subgoals, subgoal 1 (ID 3045)
  
  v : Vars
  n : nat
  l : ~ v < S n
  l0 : 1 + v < n
  ============================
   v < S n

subgoal 2 (ID 3041) is:
 #0 ↑ n = #v
subgoal 3 (ID 3042) is:
 #(1 + v - 1) = #v
subgoal 4 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 5 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 6 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 7 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 8 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

intuition.
7 subgoals, subgoal 1 (ID 3041)
  
  v : Vars
  n : nat
  l : S n <= v
  e : 1 + v = n
  ============================
   #0 ↑ n = #v

subgoal 2 (ID 3042) is:
 #(1 + v - 1) = #v
subgoal 3 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 4 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 5 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 6 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 7 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


elim (lt_irrefl v).
7 subgoals, subgoal 1 (ID 3067)
  
  v : Vars
  n : nat
  l : S n <= v
  e : 1 + v = n
  ============================
   v < v

subgoal 2 (ID 3042) is:
 #(1 + v - 1) = #v
subgoal 3 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 4 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 5 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 6 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 7 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

apply lt_le_trans with (S (S v)).
8 subgoals, subgoal 1 (ID 3068)
  
  v : Vars
  n : nat
  l : S n <= v
  e : 1 + v = n
  ============================
   v < S (S v)

subgoal 2 (ID 3069) is:
 S (S v) <= v
subgoal 3 (ID 3042) is:
 #(1 + v - 1) = #v
subgoal 4 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 5 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 6 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 7 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 8 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

intuition.
7 subgoals, subgoal 1 (ID 3069)
  
  v : Vars
  n : nat
  l : S n <= v
  e : 1 + v = n
  ============================
   S (S v) <= v

subgoal 2 (ID 3042) is:
 #(1 + v - 1) = #v
subgoal 3 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 4 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 5 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 6 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 7 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

subst; trivial.
6 subgoals, subgoal 1 (ID 3042)
  
  v : Vars
  n : nat
  l : S n <= v
  l0 : n < 1 + v
  ============================
   #(1 + v - 1) = #v

subgoal 2 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 3 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 5 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


change (1+v) with (S v).
6 subgoals, subgoal 1 (ID 3084)
  
  v : Vars
  n : nat
  l : S n <= v
  l0 : n < 1 + v
  ============================
   #(S v - 1) = #v

subgoal 2 (ID 3025) is:
 #v [n ← #0] = #v
subgoal 3 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 5 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

destruct v; simpl; trivial.
5 subgoals, subgoal 1 (ID 3025)
  
  v : Vars
  n : nat
  g : S n > v
  ============================
   #v [n ← #0] = #v

subgoal 2 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 4 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl.
5 subgoals, subgoal 1 (ID 3099)
  
  v : Vars
  n : nat
  g : S n > v
  ============================
   match lt_eq_lt_dec v n with
   | inleft (left _) => #v
   | inleft (right _) => #(n + 0)
   | inright _ => #(v - 1)
   end = #v

subgoal 2 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 4 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


destruct (lt_eq_lt_dec v n) as [[] | ].
7 subgoals, subgoal 1 (ID 3113)
  
  v : Vars
  n : nat
  g : S n > v
  l : v < n
  ============================
   #v = #v

subgoal 2 (ID 3114) is:
 #(n + 0) = #v
subgoal 3 (ID 3115) is:
 #(v - 1) = #v
subgoal 4 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 5 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 6 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 7 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


trivial.
6 subgoals, subgoal 1 (ID 3114)
  
  v : Vars
  n : nat
  g : S n > v
  e : v = n
  ============================
   #(n + 0) = #v

subgoal 2 (ID 3115) is:
 #(v - 1) = #v
subgoal 3 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 5 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl; subst; trivial.
6 subgoals, subgoal 1 (ID 3121)
  
  n : nat
  g : S n > n
  ============================
   #(n + 0) = #n

subgoal 2 (ID 3115) is:
 #(v - 1) = #v
subgoal 3 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 5 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


rewrite <- plus_n_O.
6 subgoals, subgoal 1 (ID 3122)
  
  n : nat
  g : S n > n
  ============================
   #n = #n

subgoal 2 (ID 3115) is:
 #(v - 1) = #v
subgoal 3 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 5 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

trivial.
5 subgoals, subgoal 1 (ID 3115)
  
  v : Vars
  n : nat
  g : S n > v
  l : n < v
  ============================
   #(v - 1) = #v

subgoal 2 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 4 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


elim (lt_irrefl n).
5 subgoals, subgoal 1 (ID 3123)
  
  v : Vars
  n : nat
  g : S n > v
  l : n < v
  ============================
   n < n

subgoal 2 (ID 3011) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 4 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

apply lt_le_trans with v; intuition.
4 subgoals, subgoal 1 (ID 3011)
  
  s : Sorts
  n : nat
  ============================
   !s ↑ 1 # (S n) [n ← #0] = !s

subgoal 2 (ID 3012) is:
 (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4
subgoal 3 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 4 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl; trivial.
3 subgoals, subgoal 1 (ID 3012)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  IHM3 : forall n : nat, M3 ↑ 1 # (S n) [n ← #0] = M3
  IHM4 : forall n : nat, M4 ↑ 1 # (S n) [n ← #0] = M4
  n : nat
  ============================
   (M1 ·( M2, M3)M4) ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4

subgoal 2 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl.
3 subgoals, subgoal 1 (ID 3133)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  IHM3 : forall n : nat, M3 ↑ 1 # (S n) [n ← #0] = M3
  IHM4 : forall n : nat, M4 ↑ 1 # (S n) [n ← #0] = M4
  n : nat
  ============================
   M1 ↑ 1 # (S n) [n ← #0] ·( M2 ↑ 1 # (S n) [n ← #0],
   M3 ↑ 1 # (S (S n)) [(S n) ← #0])M4 ↑ 1 # (S n) [n ← #0] = 
   M1 ·( M2, M3)M4

subgoal 2 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM1.
3 subgoals, subgoal 1 (ID 3134)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  IHM3 : forall n : nat, M3 ↑ 1 # (S n) [n ← #0] = M3
  IHM4 : forall n : nat, M4 ↑ 1 # (S n) [n ← #0] = M4
  n : nat
  ============================
   M1 ·( M2 ↑ 1 # (S n) [n ← #0], M3 ↑ 1 # (S (S n)) [(S n) ← #0])
   M4 ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4

subgoal 2 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM2.
3 subgoals, subgoal 1 (ID 3135)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  IHM3 : forall n : nat, M3 ↑ 1 # (S n) [n ← #0] = M3
  IHM4 : forall n : nat, M4 ↑ 1 # (S n) [n ← #0] = M4
  n : nat
  ============================
   M1 ·( M2, M3 ↑ 1 # (S (S n)) [(S n) ← #0])M4 ↑ 1 # (S n) [n ← #0] =
   M1 ·( M2, M3)M4

subgoal 2 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM3.
3 subgoals, subgoal 1 (ID 3136)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  IHM3 : forall n : nat, M3 ↑ 1 # (S n) [n ← #0] = M3
  IHM4 : forall n : nat, M4 ↑ 1 # (S n) [n ← #0] = M4
  n : nat
  ============================
   M1 ·( M2, M3)M4 ↑ 1 # (S n) [n ← #0] = M1 ·( M2, M3)M4

subgoal 2 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM4.
3 subgoals, subgoal 1 (ID 3137)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  IHM3 : forall n : nat, M3 ↑ 1 # (S n) [n ← #0] = M3
  IHM4 : forall n : nat, M4 ↑ 1 # (S n) [n ← #0] = M4
  n : nat
  ============================
   M1 ·( M2, M3)M4 = M1 ·( M2, M3)M4

subgoal 2 (ID 3013) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

reflexivity.
2 subgoals, subgoal 1 (ID 3013)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  n : nat
  ============================
   (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2

subgoal 2 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl.
2 subgoals, subgoal 1 (ID 3139)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  n : nat
  ============================
   Π (M1 ↑ 1 # (S n) [n ← #0]), M2 ↑ 1 # (S (S n)) [(S n) ← #0] = Π (M1), M2

subgoal 2 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM1.
2 subgoals, subgoal 1 (ID 3140)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  n : nat
  ============================
   Π (M1), M2 ↑ 1 # (S (S n)) [(S n) ← #0] = Π (M1), M2

subgoal 2 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM2.
2 subgoals, subgoal 1 (ID 3141)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  n : nat
  ============================
   Π (M1), M2 = Π (M1), M2

subgoal 2 (ID 3014) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

reflexivity.
1 subgoals, subgoal 1 (ID 3014)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  n : nat
  ============================
   (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2

(dependent evars:)


simpl.
1 subgoals, subgoal 1 (ID 3143)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  n : nat
  ============================
   λ [M1 ↑ 1 # (S n) [n ← #0]], M2 ↑ 1 # (S (S n)) [(S n) ← #0] = λ [M1], M2

(dependent evars:)

rewrite IHM1.
1 subgoals, subgoal 1 (ID 3144)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  n : nat
  ============================
   λ [M1], M2 ↑ 1 # (S (S n)) [(S n) ← #0] = λ [M1], M2

(dependent evars:)

rewrite IHM2.
1 subgoals, subgoal 1 (ID 3145)
  
  M1 : Term
  M2 : Term
  IHM1 : forall n : nat, M1 ↑ 1 # (S n) [n ← #0] = M1
  IHM2 : forall n : nat, M2 ↑ 1 # (S n) [n ← #0] = M2
  n : nat
  ============================
   λ [M1], M2 = λ [M1], M2

(dependent evars:)

reflexivity.
No more subgoals.
(dependent evars:)


Qed.
expand_term_with_subst is defined



Lemma substP1: forall M N i j k ,
  ( M [ j N] ) k # (j+i) = (M k # (S (j+i))) [ j (N k # i ) ].
1 subgoals, subgoal 1 (ID 3153)
  
  ============================
   forall (M N : Term) (i j k : nat),
   M [j ← N] ↑ k # (j + i) = M ↑ k # (S (j + i)) [j ← N ↑ k # i]

(dependent evars:)


intros M; induction M; intros.
5 subgoals, subgoal 1 (ID 3191)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   #v [j ← N] ↑ k # (j + i) = #v ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl (#v [j N] k # (j+i)).
5 subgoals, subgoal 1 (ID 3208)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ j
   | inright _ => #(v - 1)
   end ↑ k # (j + i) = #v ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


change (#v k # (S (j+i))) with (if le_gt_dec (S (j+i)) v then #(k+v) else #v).
5 subgoals, subgoal 1 (ID 3211)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ j
   | inright _ => #(v - 1)
   end ↑ k # (j + i) =
   (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]

subgoal 2 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (lt_eq_lt_dec v j) as [[] | ].
7 subgoals, subgoal 1 (ID 3225)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  ============================
   #v ↑ k # (j + i) =
   (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]

subgoal 2 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (le_gt_dec (S (j+i)) v).
8 subgoals, subgoal 1 (ID 3236)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  l0 : S (j + i) <= v
  ============================
   #v ↑ k # (j + i) = #(k + v) [j ← N ↑ k # i]

subgoal 2 (ID 3237) is:
 #v ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


elim (lt_irrefl v).
8 subgoals, subgoal 1 (ID 3238)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  l0 : S (j + i) <= v
  ============================
   v < v

subgoal 2 (ID 3237) is:
 #v ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_le_trans with j; intuition.
8 subgoals, subgoal 1 (ID 3240)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  l0 : S (j + i) <= v
  ============================
   j <= v

subgoal 2 (ID 3237) is:
 #v ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


apply le_trans with (S (j+i)); intuition.
7 subgoals, subgoal 1 (ID 3237)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  ============================
   #v ↑ k # (j + i) = #v [j ← N ↑ k # i]

subgoal 2 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl.
7 subgoals, subgoal 1 (ID 3275)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  ============================
   (if le_gt_dec (j + i) v then #(k + v) else #v) =
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (le_gt_dec (j+i) v).
8 subgoals, subgoal 1 (ID 3284)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  l0 : j + i <= v
  ============================
   #(k + v) =
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 3285) is:
 #v =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


elim (lt_irrefl v).
8 subgoals, subgoal 1 (ID 3286)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  l0 : j + i <= v
  ============================
   v < v

subgoal 2 (ID 3285) is:
 #v =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_le_trans with j; intuition.
8 subgoals, subgoal 1 (ID 3288)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  l0 : j + i <= v
  ============================
   j <= v

subgoal 2 (ID 3285) is:
 #v =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply le_trans with (j+i); intuition.
7 subgoals, subgoal 1 (ID 3285)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  g0 : j + i > v
  ============================
   #v =
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (lt_eq_lt_dec v j) as [[] | ].
9 subgoals, subgoal 1 (ID 3332)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  g0 : j + i > v
  l0 : v < j
  ============================
   #v = #v

subgoal 2 (ID 3333) is:
 #v = N ↑ k # i ↑ j
subgoal 3 (ID 3334) is:
 #v = #(v - 1)
subgoal 4 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 6 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

trivial.
8 subgoals, subgoal 1 (ID 3333)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  g0 : j + i > v
  e : v = j
  ============================
   #v = N ↑ k # i ↑ j

subgoal 2 (ID 3334) is:
 #v = #(v - 1)
subgoal 3 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


subst.
8 subgoals, subgoal 1 (ID 3341)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < j
  g : S (j + i) > j
  g0 : j + i > j
  ============================
   #j = N ↑ k # i ↑ j

subgoal 2 (ID 3334) is:
 #v = #(v - 1)
subgoal 3 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

elim (lt_irrefl j);trivial.
7 subgoals, subgoal 1 (ID 3334)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  g : S (j + i) > v
  g0 : j + i > v
  l0 : j < v
  ============================
   #v = #(v - 1)

subgoal 2 (ID 3226) is:
 N ↑ j ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


elim (lt_irrefl j); apply lt_trans with v; trivial.
6 subgoals, subgoal 1 (ID 3226)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  e : v = j
  ============================
   N ↑ j ↑ k # (j + i) =
   (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]

subgoal 2 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (le_gt_dec (S(j+i)) v).
7 subgoals, subgoal 1 (ID 3354)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  e : v = j
  l : S (j + i) <= v
  ============================
   N ↑ j ↑ k # (j + i) = #(k + v) [j ← N ↑ k # i]

subgoal 2 (ID 3355) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

subst.
7 subgoals, subgoal 1 (ID 3360)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : S (j + i) <= j
  ============================
   N ↑ j ↑ k # (j + i) = #(k + j) [j ← N ↑ k # i]

subgoal 2 (ID 3355) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


elim (lt_irrefl j).
7 subgoals, subgoal 1 (ID 3361)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : S (j + i) <= j
  ============================
   j < j

subgoal 2 (ID 3355) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_le_trans with (S (j+i)).
8 subgoals, subgoal 1 (ID 3362)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : S (j + i) <= j
  ============================
   j < S (j + i)

subgoal 2 (ID 3363) is:
 S (j + i) <= j
subgoal 3 (ID 3355) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

intuition.
7 subgoals, subgoal 1 (ID 3363)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : S (j + i) <= j
  ============================
   S (j + i) <= j

subgoal 2 (ID 3355) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 3355)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  e : v = j
  g : S (j + i) > v
  ============================
   N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]

subgoal 2 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl.
6 subgoals, subgoal 1 (ID 3403)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  e : v = j
  g : S (j + i) > v
  ============================
   N ↑ j ↑ k # (j + i) =
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

destruct (lt_eq_lt_dec v j) as [[] | ].
8 subgoals, subgoal 1 (ID 3417)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  e : v = j
  g : S (j + i) > v
  l : v < j
  ============================
   N ↑ j ↑ k # (j + i) = #v

subgoal 2 (ID 3418) is:
 N ↑ j ↑ k # (j + i) = N ↑ k # i ↑ j
subgoal 3 (ID 3419) is:
 N ↑ j ↑ k # (j + i) = #(v - 1)
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


subst.
8 subgoals, subgoal 1 (ID 3425)
  
  N : Term
  i : nat
  j : nat
  k : nat
  g : S (j + i) > j
  l : j < j
  ============================
   N ↑ j ↑ k # (j + i) = #j

subgoal 2 (ID 3418) is:
 N ↑ j ↑ k # (j + i) = N ↑ k # i ↑ j
subgoal 3 (ID 3419) is:
 N ↑ j ↑ k # (j + i) = #(v - 1)
subgoal 4 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

elim (lt_irrefl j); trivial.
7 subgoals, subgoal 1 (ID 3418)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  e : v = j
  g : S (j + i) > v
  e0 : v = j
  ============================
   N ↑ j ↑ k # (j + i) = N ↑ k # i ↑ j

subgoal 2 (ID 3419) is:
 N ↑ j ↑ k # (j + i) = #(v - 1)
subgoal 3 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


apply liftP2; intuition.
6 subgoals, subgoal 1 (ID 3419)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  e : v = j
  g : S (j + i) > v
  l : j < v
  ============================
   N ↑ j ↑ k # (j + i) = #(v - 1)

subgoal 2 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


subst.
6 subgoals, subgoal 1 (ID 3442)
  
  N : Term
  i : nat
  j : nat
  k : nat
  g : S (j + i) > j
  l : j < j
  ============================
   N ↑ j ↑ k # (j + i) = #(j - 1)

subgoal 2 (ID 3227) is:
 #(v - 1) ↑ k # (j + i) =
 (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

elim (lt_irrefl j); trivial.
5 subgoals, subgoal 1 (ID 3227)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  ============================
   #(v - 1) ↑ k # (j + i) =
   (if le_gt_dec (S (j + i)) v then #(k + v) else #v) [j ← N ↑ k # i]

subgoal 2 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (le_gt_dec (S (j+i)) v).
6 subgoals, subgoal 1 (ID 3452)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  ============================
   #(v - 1) ↑ k # (j + i) = #(k + v) [j ← N ↑ k # i]

subgoal 2 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl.
6 subgoals, subgoal 1 (ID 3454)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  ============================
   (if le_gt_dec (j + i) (v - 1) then #(k + (v - 1)) else #(v - 1)) =
   match lt_eq_lt_dec (k + v) j with
   | inleft (left _) => #(k + v)
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(k + v - 1)
   end

subgoal 2 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (le_gt_dec (j+i) (v-1)).
7 subgoals, subgoal 1 (ID 3463)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  l1 : j + i <= v - 1
  ============================
   #(k + (v - 1)) =
   match lt_eq_lt_dec (k + v) j with
   | inleft (left _) => #(k + v)
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(k + v - 1)
   end

subgoal 2 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

destruct (lt_eq_lt_dec (k+v) j) as [[] | ].
9 subgoals, subgoal 1 (ID 3478)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  l1 : j + i <= v - 1
  l2 : k + v < j
  ============================
   #(k + (v - 1)) = #(k + v)

subgoal 2 (ID 3479) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 3 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 4 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 5 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 6 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


elim (lt_irrefl j).
9 subgoals, subgoal 1 (ID 3481)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  l1 : j + i <= v - 1
  l2 : k + v < j
  ============================
   j < j

subgoal 2 (ID 3479) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 3 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 4 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 5 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 6 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_le_trans with v.
10 subgoals, subgoal 1 (ID 3482)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  l1 : j + i <= v - 1
  l2 : k + v < j
  ============================
   j < v

subgoal 2 (ID 3483) is:
 v <= j
subgoal 3 (ID 3479) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 4 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 5 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 6 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 7 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 10 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

trivial.
9 subgoals, subgoal 1 (ID 3483)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  l1 : j + i <= v - 1
  l2 : k + v < j
  ============================
   v <= j

subgoal 2 (ID 3479) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 3 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 4 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 5 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 6 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

induction k; intuition.
8 subgoals, subgoal 1 (ID 3479)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  l1 : j + i <= v - 1
  e : k + v = j
  ============================
   #(k + (v - 1)) = N ↑ k # i ↑ j

subgoal 2 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 3 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 4 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


subst.
8 subgoals, subgoal 1 (ID 3537)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  l : k + v < v
  l0 : S (k + v + i) <= v
  l1 : k + v + i <= v - 1
  ============================
   #(k + (v - 1)) = N ↑ k # i ↑ (k + v)

subgoal 2 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 3 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 4 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

elim (lt_irrefl v).
8 subgoals, subgoal 1 (ID 3538)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  l : k + v < v
  l0 : S (k + v + i) <= v
  l1 : k + v + i <= v - 1
  ============================
   v < v

subgoal 2 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 3 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 4 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_le_trans with (S(k+v+i)).
9 subgoals, subgoal 1 (ID 3539)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  l : k + v < v
  l0 : S (k + v + i) <= v
  l1 : k + v + i <= v - 1
  ============================
   v < S (k + v + i)

subgoal 2 (ID 3540) is:
 S (k + v + i) <= v
subgoal 3 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 4 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 5 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 6 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

intuition.
8 subgoals, subgoal 1 (ID 3540)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  l : k + v < v
  l0 : S (k + v + i) <= v
  l1 : k + v + i <= v - 1
  ============================
   S (k + v + i) <= v

subgoal 2 (ID 3480) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 3 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 4 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

trivial.
7 subgoals, subgoal 1 (ID 3480)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  l1 : j + i <= v - 1
  l2 : j < k + v
  ============================
   #(k + (v - 1)) = #(k + v - 1)

subgoal 2 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct v.
8 subgoals, subgoal 1 (ID 3604)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < 0
  l0 : S (j + i) <= 0
  l1 : j + i <= 0 - 1
  l2 : j < k + 0
  ============================
   #(k + (0 - 1)) = #(k + 0 - 1)

subgoal 2 (ID 3610) is:
 #(k + (S v - 1)) = #(k + S v - 1)
subgoal 3 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 4 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_n_O in l; elim l.
7 subgoals, subgoal 1 (ID 3610)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  l0 : S (j + i) <= S v
  l1 : j + i <= S v - 1
  l2 : j < k + S v
  ============================
   #(k + (S v - 1)) = #(k + S v - 1)

subgoal 2 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

rewrite <- 2! pred_of_minus.
7 subgoals, subgoal 1 (ID 3614)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  l0 : S (j + i) <= S v
  l1 : j + i <= S v - 1
  l2 : j < k + S v
  ============================
   #(k + pred (S v)) = #(pred (k + S v))

subgoal 2 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

replace (k+ S v) with (S (k+v)) by intuition.
7 subgoals, subgoal 1 (ID 3618)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  l0 : S (j + i) <= S v
  l1 : j + i <= S v - 1
  l2 : j < k + S v
  ============================
   #(k + pred (S v)) = #(pred (S (k + v)))

subgoal 2 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl.
7 subgoals, subgoal 1 (ID 3633)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  l0 : S (j + i) <= S v
  l1 : j + i <= S v - 1
  l2 : j < k + S v
  ============================
   #(k + v) = #(k + v)

subgoal 2 (ID 3464) is:
 #(v - 1) =
 match lt_eq_lt_dec (k + v) j with
 | inleft (left _) => #(k + v)
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(k + v - 1)
 end
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 3464)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  g : j + i > v - 1
  ============================
   #(v - 1) =
   match lt_eq_lt_dec (k + v) j with
   | inleft (left _) => #(k + v)
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(k + v - 1)
   end

subgoal 2 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


elim (lt_irrefl v).
6 subgoals, subgoal 1 (ID 3634)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  g : j + i > v - 1
  ============================
   v < v

subgoal 2 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_le_trans with (S (j+i)).
7 subgoals, subgoal 1 (ID 3635)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  g : j + i > v - 1
  ============================
   v < S (j + i)

subgoal 2 (ID 3636) is:
 S (j + i) <= v
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

destruct v.
8 subgoals, subgoal 1 (ID 3645)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < 0
  l0 : S (j + i) <= 0
  g : j + i > 0 - 1
  ============================
   0 < S (j + i)

subgoal 2 (ID 3650) is:
 S v < S (j + i)
subgoal 3 (ID 3636) is:
 S (j + i) <= v
subgoal 4 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_n_O in l; elim l.
7 subgoals, subgoal 1 (ID 3650)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  l0 : S (j + i) <= S v
  g : j + i > S v - 1
  ============================
   S v < S (j + i)

subgoal 2 (ID 3636) is:
 S (j + i) <= v
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


rewrite <- pred_of_minus in g.
7 subgoals, subgoal 1 (ID 3654)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  l0 : S (j + i) <= S v
  g : j + i > pred (S v)
  ============================
   S v < S (j + i)

subgoal 2 (ID 3636) is:
 S (j + i) <= v
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

simpl in g.
7 subgoals, subgoal 1 (ID 3655)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  l0 : S (j + i) <= S v
  g : j + i > v
  ============================
   S v < S (j + i)

subgoal 2 (ID 3636) is:
 S (j + i) <= v
subgoal 3 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

intuition.
6 subgoals, subgoal 1 (ID 3636)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  l0 : S (j + i) <= v
  g : j + i > v - 1
  ============================
   S (j + i) <= v

subgoal 2 (ID 3453) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

trivial.
5 subgoals, subgoal 1 (ID 3453)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  ============================
   #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]

subgoal 2 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl.
5 subgoals, subgoal 1 (ID 3668)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  ============================
   (if le_gt_dec (j + i) (v - 1) then #(k + (v - 1)) else #(v - 1)) =
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (le_gt_dec (j+i) (v-1)).
6 subgoals, subgoal 1 (ID 3677)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  l0 : j + i <= v - 1
  ============================
   #(k + (v - 1)) =
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

destruct (lt_eq_lt_dec v j) as [[] | ].
8 subgoals, subgoal 1 (ID 3692)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  l0 : j + i <= v - 1
  l1 : v < j
  ============================
   #(k + (v - 1)) = #v

subgoal 2 (ID 3693) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 3 (ID 3694) is:
 #(k + (v - 1)) = #(v - 1)
subgoal 4 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 5 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


elim (lt_irrefl j); apply lt_trans with v; trivial.
7 subgoals, subgoal 1 (ID 3693)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  l0 : j + i <= v - 1
  e : v = j
  ============================
   #(k + (v - 1)) = N ↑ k # i ↑ j

subgoal 2 (ID 3694) is:
 #(k + (v - 1)) = #(v - 1)
subgoal 3 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


subst.
7 subgoals, subgoal 1 (ID 3704)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < j
  g : S (j + i) > j
  l0 : j + i <= j - 1
  ============================
   #(k + (j - 1)) = N ↑ k # i ↑ j

subgoal 2 (ID 3694) is:
 #(k + (v - 1)) = #(v - 1)
subgoal 3 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

elim (lt_irrefl j); trivial.
6 subgoals, subgoal 1 (ID 3694)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  l0 : j + i <= v - 1
  l1 : j < v
  ============================
   #(k + (v - 1)) = #(v - 1)

subgoal 2 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


elim (lt_irrefl v).
6 subgoals, subgoal 1 (ID 3706)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  l0 : j + i <= v - 1
  l1 : j < v
  ============================
   v < v

subgoal 2 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_le_trans with (S (j+i)).
7 subgoals, subgoal 1 (ID 3707)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  l0 : j + i <= v - 1
  l1 : j < v
  ============================
   v < S (j + i)

subgoal 2 (ID 3708) is:
 S (j + i) <= v
subgoal 3 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

intuition.
6 subgoals, subgoal 1 (ID 3708)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  l0 : j + i <= v - 1
  l1 : j < v
  ============================
   S (j + i) <= v

subgoal 2 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct v.
7 subgoals, subgoal 1 (ID 3718)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < 0
  g : S (j + i) > 0
  l0 : j + i <= 0 - 1
  l1 : j < 0
  ============================
   S (j + i) <= 0

subgoal 2 (ID 3724) is:
 S (j + i) <= S v
subgoal 3 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

apply lt_n_O in l; elim l.
6 subgoals, subgoal 1 (ID 3724)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  g : S (j + i) > S v
  l0 : j + i <= S v - 1
  l1 : j < S v
  ============================
   S (j + i) <= S v

subgoal 2 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

rewrite <- pred_of_minus in l0.
6 subgoals, subgoal 1 (ID 3728)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  g : S (j + i) > S v
  l0 : j + i <= pred (S v)
  l1 : j < S v
  ============================
   S (j + i) <= S v

subgoal 2 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

simpl in l0.
6 subgoals, subgoal 1 (ID 3729)
  
  v : nat
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < S v
  g : S (j + i) > S v
  l0 : j + i <= v
  l1 : j < S v
  ============================
   S (j + i) <= S v

subgoal 2 (ID 3678) is:
 #(v - 1) =
 match lt_eq_lt_dec v j with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ k # i ↑ j
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

intuition.
5 subgoals, subgoal 1 (ID 3678)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  g0 : j + i > v - 1
  ============================
   #(v - 1) =
   match lt_eq_lt_dec v j with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ k # i ↑ j
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


destruct (lt_eq_lt_dec) as [[] | ].
7 subgoals, subgoal 1 (ID 3755)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  g0 : j + i > v - 1
  l0 : v < j
  ============================
   #(v - 1) = #v

subgoal 2 (ID 3756) is:
 #(v - 1) = N ↑ k # i ↑ j
subgoal 3 (ID 3757) is:
 #(v - 1) = #(v - 1)
subgoal 4 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

elim (lt_irrefl j); apply lt_trans with v; trivial.
6 subgoals, subgoal 1 (ID 3756)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  g0 : j + i > v - 1
  e : v = j
  ============================
   #(v - 1) = N ↑ k # i ↑ j

subgoal 2 (ID 3757) is:
 #(v - 1) = #(v - 1)
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


subst.
6 subgoals, subgoal 1 (ID 3767)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < j
  g : S (j + i) > j
  g0 : j + i > j - 1
  ============================
   #(j - 1) = N ↑ k # i ↑ j

subgoal 2 (ID 3757) is:
 #(v - 1) = #(v - 1)
subgoal 3 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

elim (lt_irrefl j); trivial.
5 subgoals, subgoal 1 (ID 3757)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : j < v
  g : S (j + i) > v
  g0 : j + i > v - 1
  l0 : j < v
  ============================
   #(v - 1) = #(v - 1)

subgoal 2 (ID 3195) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

trivial.
4 subgoals, subgoal 1 (ID 3195)
  
  s : Sorts
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3199) is:
 (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
 (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl; trivial.
3 subgoals, subgoal 1 (ID 3199)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM3 : forall (N : Term) (i j k : nat),
         M3 [j ← N] ↑ k # (j + i) = M3 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM4 : forall (N : Term) (i j k : nat),
         M4 [j ← N] ↑ k # (j + i) = M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   (M1 ·( M2, M3)M4) [j ← N] ↑ k # (j + i) =
   (M1 ·( M2, M3)M4) ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl.
3 subgoals, subgoal 1 (ID 3770)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM3 : forall (N : Term) (i j k : nat),
         M3 [j ← N] ↑ k # (j + i) = M3 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM4 : forall (N : Term) (i j k : nat),
         M4 [j ← N] ↑ k # (j + i) = M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   M1 [j ← N] ↑ k # (j + i) ·( M2 [j ← N] ↑ k # (j + i),
   M3 [(S j) ← N] ↑ k # (S (j + i)))M4 [j ← N] ↑ k # (j + i) =
   M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
   ·( M2 ↑ k # (S (j + i)) [j ← N ↑ k # i],
   M3 ↑ k # (S (S (j + i))) [(S j) ← N ↑ k # i])
   M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

rewrite IHM1; intuition; rewrite IHM2; intuition.
3 subgoals, subgoal 1 (ID 3788)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM3 : forall (N : Term) (i j k : nat),
         M3 [j ← N] ↑ k # (j + i) = M3 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM4 : forall (N : Term) (i j k : nat),
         M4 [j ← N] ↑ k # (j + i) = M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
   ·( M2 ↑ k # (S (j + i)) [j ← N ↑ k # i], M3 [(S j) ← N] ↑ k # (S (j + i)))
   M4 [j ← N] ↑ k # (j + i) =
   M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
   ·( M2 ↑ k # (S (j + i)) [j ← N ↑ k # i],
   M3 ↑ k # (S (S (j + i))) [(S j) ← N ↑ k # i])
   M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)

rewrite IHM4; intuition.
3 subgoals, subgoal 1 (ID 3805)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM3 : forall (N : Term) (i j k : nat),
         M3 [j ← N] ↑ k # (j + i) = M3 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM4 : forall (N : Term) (i j k : nat),
         M4 [j ← N] ↑ k # (j + i) = M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
   ·( M2 ↑ k # (S (j + i)) [j ← N ↑ k # i], M3 [(S j) ← N] ↑ k # (S (j + i)))
   M4 ↑ k # (S (j + i)) [j ← N ↑ k # i] =
   M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
   ·( M2 ↑ k # (S (j + i)) [j ← N ↑ k # i],
   M3 ↑ k # (S (S (j + i))) [(S j) ← N ↑ k # i])
   M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


replace (S(S(j+i))) with (S((S j)+i)) by intuition.
3 subgoals, subgoal 1 (ID 3825)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM3 : forall (N : Term) (i j k : nat),
         M3 [j ← N] ↑ k # (j + i) = M3 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM4 : forall (N : Term) (i j k : nat),
         M4 [j ← N] ↑ k # (j + i) = M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
   ·( M2 ↑ k # (S (j + i)) [j ← N ↑ k # i], M3 [(S j) ← N] ↑ k # (S (j + i)))
   M4 ↑ k # (S (j + i)) [j ← N ↑ k # i] =
   M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
   ·( M2 ↑ k # (S (j + i)) [j ← N ↑ k # i],
   M3 ↑ k # (S (S j + i)) [(S j) ← N ↑ k # i])
   M4 ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3203) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


rewrite <- (IHM3 N i (S j) k ); intuition.
2 subgoals, subgoal 1 (ID 3203)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   (Π (M1), M2) [j ← N] ↑ k # (j + i) =
   (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]

subgoal 2 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl; rewrite IHM1; intuition.
2 subgoals, subgoal 1 (ID 3831)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   Π (M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]), M2 [(S j) ← N] ↑ k # (S (j + i)) =
   Π (M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]),
   M2 ↑ k # (S (S (j + i))) [(S j) ← N ↑ k # i]

subgoal 2 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


replace (S(S(j+i))) with (S((S j)+i)) by intuition.
2 subgoals, subgoal 1 (ID 3847)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   Π (M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]), M2 [(S j) ← N] ↑ k # (S (j + i)) =
   Π (M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]),
   M2 ↑ k # (S (S j + i)) [(S j) ← N ↑ k # i]

subgoal 2 (ID 3207) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


rewrite <- (IHM2 N i (S j) k ); intuition.
1 subgoals, subgoal 1 (ID 3207)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   (λ [M1], M2) [j ← N] ↑ k # (j + i) =
   (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]

(dependent evars:)


simpl; rewrite IHM1; intuition.
1 subgoals, subgoal 1 (ID 3853)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   λ [M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]], M2 [(S j) ← N] ↑ k # (S (j + i)) =
   λ [M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]],
   M2 ↑ k # (S (S (j + i))) [(S j) ← N ↑ k # i]

(dependent evars:)


replace (S(S(j+i))) with ((S ((S j)+i))) by intuition.
1 subgoals, subgoal 1 (ID 3869)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j k : nat),
         M1 [j ← N] ↑ k # (j + i) = M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  IHM2 : forall (N : Term) (i j k : nat),
         M2 [j ← N] ↑ k # (j + i) = M2 ↑ k # (S (j + i)) [j ← N ↑ k # i]
  N : Term
  i : nat
  j : nat
  k : nat
  ============================
   λ [M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]], M2 [(S j) ← N] ↑ k # (S (j + i)) =
   λ [M1 ↑ k # (S (j + i)) [j ← N ↑ k # i]],
   M2 ↑ k # (S (S j + i)) [(S j) ← N ↑ k # i]

(dependent evars:)


rewrite <- (IHM2 N i (S j) k ); intuition.
No more subgoals.
(dependent evars:)


Qed.
substP1 is defined



Lemma substP2: forall M N i j n, i <= n ->
  (M j # i ) [ j+n N ] = ( M [ n N]) j # i .
1 subgoals, subgoal 1 (ID 3880)
  
  ============================
   forall (M N : Term) (i j n : nat),
   i <= n -> M ↑ j # i [(j + n) ← N] = M [n ← N] ↑ j # i

(dependent evars:)


intro M; induction M; intros; simpl.
5 subgoals, subgoal 1 (ID 3940)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   (if le_gt_dec i v then #(j + v) else #v) [(j + n) ← N] =
   match lt_eq_lt_dec v n with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ n
   | inright _ => #(v - 1)
   end ↑ j # i

subgoal 2 (ID 3941) is:
 !s = !s
subgoal 3 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 4 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 5 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


destruct (le_gt_dec i v); destruct (lt_eq_lt_dec v n) as [[] | ].
10 subgoals, subgoal 1 (ID 3968)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  ============================
   #(j + v) [(j + n) ← N] = #v ↑ j # i

subgoal 2 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


simpl.
10 subgoals, subgoal 1 (ID 3987)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


destruct (le_gt_dec i v).
11 subgoals, subgoal 1 (ID 3996)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  l1 : i <= v
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = #(j + v)

subgoal 2 (ID 3997) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #v
subgoal 3 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3941) is:
 !s = !s
subgoal 9 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 10 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 11 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

destruct (lt_eq_lt_dec (j+v) (j+n)) as [[] | ].
13 subgoals, subgoal 1 (ID 4011)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  l1 : i <= v
  l2 : j + v < j + n
  ============================
   #(j + v) = #(j + v)

subgoal 2 (ID 4012) is:
 N ↑ (j + n) = #(j + v)
subgoal 3 (ID 4013) is:
 #(j + v - 1) = #(j + v)
subgoal 4 (ID 3997) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #v
subgoal 5 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 8 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 9 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 10 (ID 3941) is:
 !s = !s
subgoal 11 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 12 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 13 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


reflexivity.
12 subgoals, subgoal 1 (ID 4012)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  l1 : i <= v
  e : j + v = j + n
  ============================
   N ↑ (j + n) = #(j + v)

subgoal 2 (ID 4013) is:
 #(j + v - 1) = #(j + v)
subgoal 3 (ID 3997) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #v
subgoal 4 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 7 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 8 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 9 (ID 3941) is:
 !s = !s
subgoal 10 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 11 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 12 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


apply plus_reg_l in e.
12 subgoals, subgoal 1 (ID 4016)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  l1 : i <= v
  e : v = n
  ============================
   N ↑ (j + n) = #(j + v)

subgoal 2 (ID 4013) is:
 #(j + v - 1) = #(j + v)
subgoal 3 (ID 3997) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #v
subgoal 4 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 7 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 8 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 9 (ID 3941) is:
 !s = !s
subgoal 10 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 11 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 12 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

subst.
12 subgoals, subgoal 1 (ID 4023)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= n
  l0 : n < n
  l1 : i <= n
  ============================
   N ↑ (j + n) = #(j + n)

subgoal 2 (ID 4013) is:
 #(j + v - 1) = #(j + v)
subgoal 3 (ID 3997) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #v
subgoal 4 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 7 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 8 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 9 (ID 3941) is:
 !s = !s
subgoal 10 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 11 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 12 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl n); trivial.
11 subgoals, subgoal 1 (ID 4013)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  l1 : i <= v
  l2 : j + n < j + v
  ============================
   #(j + v - 1) = #(j + v)

subgoal 2 (ID 3997) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #v
subgoal 3 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3941) is:
 !s = !s
subgoal 9 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 10 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 11 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


apply plus_lt_reg_l in l2.
11 subgoals, subgoal 1 (ID 4026)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  l1 : i <= v
  l2 : n < v
  ============================
   #(j + v - 1) = #(j + v)

subgoal 2 (ID 3997) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #v
subgoal 3 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3941) is:
 !s = !s
subgoal 9 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 10 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 11 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

elim (lt_asym v n); trivial.
10 subgoals, subgoal 1 (ID 3997)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  g : i > v
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = #v

subgoal 2 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


elim (lt_irrefl i).
10 subgoals, subgoal 1 (ID 4029)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : v < n
  g : i > v
  ============================
   i < i

subgoal 2 (ID 3969) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply le_lt_trans with v; intuition.
9 subgoals, subgoal 1 (ID 3969)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  e : v = n
  ============================
   #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i

subgoal 2 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

subst.
9 subgoals, subgoal 1 (ID 4036)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= n
  ============================
   #(j + n) [(j + n) ← N] = N ↑ n ↑ j # i

subgoal 2 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


simpl.
9 subgoals, subgoal 1 (ID 4037)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= n
  ============================
   match lt_eq_lt_dec (j + n) (j + n) with
   | inleft (left _) => #(j + n)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + n - 1)
   end = N ↑ n ↑ j # i

subgoal 2 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


destruct (lt_eq_lt_dec (j+n) (j+n)) as [[] | ].
11 subgoals, subgoal 1 (ID 4051)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= n
  l0 : j + n < j + n
  ============================
   #(j + n) = N ↑ n ↑ j # i

subgoal 2 (ID 4052) is:
 N ↑ (j + n) = N ↑ n ↑ j # i
subgoal 3 (ID 4053) is:
 #(j + n - 1) = N ↑ n ↑ j # i
subgoal 4 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3941) is:
 !s = !s
subgoal 9 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 10 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 11 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


apply lt_irrefl in l0; elim l0.
10 subgoals, subgoal 1 (ID 4052)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= n
  e : j + n = j + n
  ============================
   N ↑ (j + n) = N ↑ n ↑ j # i

subgoal 2 (ID 4053) is:
 #(j + n - 1) = N ↑ n ↑ j # i
subgoal 3 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


symmetry.
10 subgoals, subgoal 1 (ID 4057)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= n
  e : j + n = j + n
  ============================
   N ↑ n ↑ j # i = N ↑ (j + n)

subgoal 2 (ID 4053) is:
 #(j + n - 1) = N ↑ n ↑ j # i
subgoal 3 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


apply liftP3; intuition.
9 subgoals, subgoal 1 (ID 4053)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= n
  l0 : j + n < j + n
  ============================
   #(j + n - 1) = N ↑ n ↑ j # i

subgoal 2 (ID 3970) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


apply lt_irrefl in l0; elim l0.
8 subgoals, subgoal 1 (ID 3970)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  ============================
   #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


simpl.
8 subgoals, subgoal 1 (ID 4070)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = (if le_gt_dec i (v - 1) then #(j + (v - 1)) else #(v - 1))

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


destruct (le_gt_dec i (v-1)).
9 subgoals, subgoal 1 (ID 4079)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  l1 : i <= v - 1
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = #(j + (v - 1))

subgoal 2 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

destruct (lt_eq_lt_dec (j+v) (j+n))as [[] | ].
11 subgoals, subgoal 1 (ID 4094)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  l1 : i <= v - 1
  l2 : j + v < j + n
  ============================
   #(j + v) = #(j + (v - 1))

subgoal 2 (ID 4095) is:
 N ↑ (j + n) = #(j + (v - 1))
subgoal 3 (ID 4096) is:
 #(j + v - 1) = #(j + (v - 1))
subgoal 4 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 5 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3941) is:
 !s = !s
subgoal 9 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 10 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 11 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


apply plus_lt_reg_l in l2.
11 subgoals, subgoal 1 (ID 4098)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  l1 : i <= v - 1
  l2 : v < n
  ============================
   #(j + v) = #(j + (v - 1))

subgoal 2 (ID 4095) is:
 N ↑ (j + n) = #(j + (v - 1))
subgoal 3 (ID 4096) is:
 #(j + v - 1) = #(j + (v - 1))
subgoal 4 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 5 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3941) is:
 !s = !s
subgoal 9 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 10 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 11 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

elim (lt_asym v n ); trivial.
10 subgoals, subgoal 1 (ID 4095)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  l1 : i <= v - 1
  e : j + v = j + n
  ============================
   N ↑ (j + n) = #(j + (v - 1))

subgoal 2 (ID 4096) is:
 #(j + v - 1) = #(j + (v - 1))
subgoal 3 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


apply plus_reg_l in e; subst.
10 subgoals, subgoal 1 (ID 4109)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= n
  l0 : n < n
  l1 : i <= n - 1
  ============================
   N ↑ (j + n) = #(j + (n - 1))

subgoal 2 (ID 4096) is:
 #(j + v - 1) = #(j + (v - 1))
subgoal 3 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl n); trivial.
9 subgoals, subgoal 1 (ID 4096)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  l1 : i <= v - 1
  l2 : j + n < j + v
  ============================
   #(j + v - 1) = #(j + (v - 1))

subgoal 2 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


destruct v.
10 subgoals, subgoal 1 (ID 4120)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= 0
  l0 : n < 0
  l1 : i <= 0 - 1
  l2 : j + n < j + 0
  ============================
   #(j + 0 - 1) = #(j + (0 - 1))

subgoal 2 (ID 4126) is:
 #(j + S v - 1) = #(j + (S v - 1))
subgoal 3 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 4 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3941) is:
 !s = !s
subgoal 8 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 9 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 10 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply lt_n_O in l0; elim l0.
9 subgoals, subgoal 1 (ID 4126)
  
  v : nat
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= S v
  l0 : n < S v
  l1 : i <= S v - 1
  l2 : j + n < j + S v
  ============================
   #(j + S v - 1) = #(j + (S v - 1))

subgoal 2 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

rewrite <- 2! pred_of_minus.
9 subgoals, subgoal 1 (ID 4130)
  
  v : nat
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= S v
  l0 : n < S v
  l1 : i <= S v - 1
  l2 : j + n < j + S v
  ============================
   #(pred (j + S v)) = #(j + pred (S v))

subgoal 2 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

replace (j+ S v) with (S (j+v)) by intuition.
9 subgoals, subgoal 1 (ID 4134)
  
  v : nat
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= S v
  l0 : n < S v
  l1 : i <= S v - 1
  l2 : j + n < j + S v
  ============================
   #(pred (S (j + v))) = #(j + pred (S v))

subgoal 2 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


simpl.
9 subgoals, subgoal 1 (ID 4150)
  
  v : nat
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= S v
  l0 : n < S v
  l1 : i <= S v - 1
  l2 : j + n < j + S v
  ============================
   #(j + v) = #(j + v)

subgoal 2 (ID 4080) is:
 match lt_eq_lt_dec (j + v) (j + n) with
 | inleft (left _) => #(j + v)
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(j + v - 1)
 end = #(v - 1)
subgoal 3 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

trivial.
8 subgoals, subgoal 1 (ID 4080)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  g : i > v - 1
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = #(v - 1)

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


unfold gt in g.
8 subgoals, subgoal 1 (ID 4151)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  g : v - 1 < i
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = #(v - 1)

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

unfold lt in g.
8 subgoals, subgoal 1 (ID 4152)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  g : S (v - 1) <= i
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = #(v - 1)

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

rewrite <- pred_of_minus in g.
8 subgoals, subgoal 1 (ID 4154)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  g : S (pred v) <= i
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = #(v - 1)

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


rewrite <- (S_pred v n l0) in g.
8 subgoals, subgoal 1 (ID 4156)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  g : v <= i
  ============================
   match lt_eq_lt_dec (j + v) (j + n) with
   | inleft (left _) => #(j + v)
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(j + v - 1)
   end = #(v - 1)

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


elim (lt_irrefl n).
8 subgoals, subgoal 1 (ID 4157)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  g : v <= i
  ============================
   n < n

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply lt_le_trans with v; trivial.
8 subgoals, subgoal 1 (ID 4159)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  l : i <= v
  l0 : n < v
  g : v <= i
  ============================
   v <= n

subgoal 2 (ID 3984) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply le_trans with i; trivial.
7 subgoals, subgoal 1 (ID 3984)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  ============================
   #v [(j + n) ← N] = #v ↑ j # i

subgoal 2 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3941) is:
 !s = !s
subgoal 5 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 6 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 7 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


simpl.
7 subgoals, subgoal 1 (ID 4162)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  ============================
   match lt_eq_lt_dec v (j + n) with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(v - 1)
   end = (if le_gt_dec i v then #(j + v) else #v)

subgoal 2 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3941) is:
 !s = !s
subgoal 5 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 6 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 7 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


destruct (le_gt_dec i v).
8 subgoals, subgoal 1 (ID 4171)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  l0 : i <= v
  ============================
   match lt_eq_lt_dec v (j + n) with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(v - 1)
   end = #(j + v)

subgoal 2 (ID 4172) is:
 match lt_eq_lt_dec v (j + n) with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(v - 1)
 end = #v
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl i).
8 subgoals, subgoal 1 (ID 4173)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  l0 : i <= v
  ============================
   i < i

subgoal 2 (ID 4172) is:
 match lt_eq_lt_dec v (j + n) with
 | inleft (left _) => #v
 | inleft (right _) => N ↑ (j + n)
 | inright _ => #(v - 1)
 end = #v
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply le_lt_trans with v; trivial.
7 subgoals, subgoal 1 (ID 4172)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  g0 : i > v
  ============================
   match lt_eq_lt_dec v (j + n) with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(v - 1)
   end = #v

subgoal 2 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3941) is:
 !s = !s
subgoal 5 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 6 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 7 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


destruct (lt_eq_lt_dec v (j+n)) as [[] | ].
9 subgoals, subgoal 1 (ID 4189)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  g0 : i > v
  l0 : v < j + n
  ============================
   #v = #v

subgoal 2 (ID 4190) is:
 N ↑ (j + n) = #v
subgoal 3 (ID 4191) is:
 #(v - 1) = #v
subgoal 4 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3941) is:
 !s = !s
subgoal 7 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 8 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 9 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

reflexivity.
8 subgoals, subgoal 1 (ID 4190)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  g0 : i > v
  e : v = j + n
  ============================
   N ↑ (j + n) = #v

subgoal 2 (ID 4191) is:
 #(v - 1) = #v
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


subst.
8 subgoals, subgoal 1 (ID 4199)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > j + n
  l : j + n < n
  g0 : i > j + n
  ============================
   N ↑ (j + n) = #(j + n)

subgoal 2 (ID 4191) is:
 #(v - 1) = #v
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl n).
8 subgoals, subgoal 1 (ID 4200)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > j + n
  l : j + n < n
  g0 : i > j + n
  ============================
   n < n

subgoal 2 (ID 4191) is:
 #(v - 1) = #v
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply le_lt_trans with (j+n); intuition.
7 subgoals, subgoal 1 (ID 4191)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  g0 : i > v
  l0 : j + n < v
  ============================
   #(v - 1) = #v

subgoal 2 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3941) is:
 !s = !s
subgoal 5 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 6 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 7 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


elim (lt_irrefl n).
7 subgoals, subgoal 1 (ID 4212)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  g0 : i > v
  l0 : j + n < v
  ============================
   n < n

subgoal 2 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3941) is:
 !s = !s
subgoal 5 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 6 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 7 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply lt_trans with v.
8 subgoals, subgoal 1 (ID 4213)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  g0 : i > v
  l0 : j + n < v
  ============================
   n < v

subgoal 2 (ID 4214) is:
 v < n
subgoal 3 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3941) is:
 !s = !s
subgoal 6 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 7 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 8 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply le_lt_trans with (j+n); intuition.
7 subgoals, subgoal 1 (ID 4214)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : v < n
  g0 : i > v
  l0 : j + n < v
  ============================
   v < n

subgoal 2 (ID 3985) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3941) is:
 !s = !s
subgoal 5 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 6 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 7 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 3985)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  e : v = n
  ============================
   #v [(j + n) ← N] = N ↑ n ↑ j # i

subgoal 2 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3941) is:
 !s = !s
subgoal 4 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 5 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 6 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


simpl.
6 subgoals, subgoal 1 (ID 4228)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  e : v = n
  ============================
   match lt_eq_lt_dec v (j + n) with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(v - 1)
   end = N ↑ n ↑ j # i

subgoal 2 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3941) is:
 !s = !s
subgoal 4 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 5 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 6 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

subst.
6 subgoals, subgoal 1 (ID 4233)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > n
  ============================
   match lt_eq_lt_dec n (j + n) with
   | inleft (left _) => #n
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(n - 1)
   end = N ↑ n ↑ j # i

subgoal 2 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3941) is:
 !s = !s
subgoal 4 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 5 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 6 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


elim (lt_irrefl n).
6 subgoals, subgoal 1 (ID 4234)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > n
  ============================
   n < n

subgoal 2 (ID 3986) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3941) is:
 !s = !s
subgoal 4 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 5 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 6 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply lt_le_trans with i; intuition.
5 subgoals, subgoal 1 (ID 3986)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : n < v
  ============================
   #v [(j + n) ← N] = #(v - 1) ↑ j # i

subgoal 2 (ID 3941) is:
 !s = !s
subgoal 3 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 4 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 5 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


simpl.
5 subgoals, subgoal 1 (ID 4237)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : n < v
  ============================
   match lt_eq_lt_dec v (j + n) with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ (j + n)
   | inright _ => #(v - 1)
   end = (if le_gt_dec i (v - 1) then #(j + (v - 1)) else #(v - 1))

subgoal 2 (ID 3941) is:
 !s = !s
subgoal 3 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 4 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 5 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

elim (lt_irrefl n).
5 subgoals, subgoal 1 (ID 4238)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : n < v
  ============================
   n < n

subgoal 2 (ID 3941) is:
 !s = !s
subgoal 3 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 4 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 5 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

apply lt_le_trans with v; intuition.
5 subgoals, subgoal 1 (ID 4240)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : n < v
  ============================
   v <= n

subgoal 2 (ID 3941) is:
 !s = !s
subgoal 3 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 4 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 5 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


apply le_trans with i; intuition.
4 subgoals, subgoal 1 (ID 3941)
  
  s : Sorts
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   !s = !s

subgoal 2 (ID 3942) is:
 M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
 M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
 M4 [n ← N] ↑ j # i
subgoal 3 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 4 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


trivial.
3 subgoals, subgoal 1 (ID 3942)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j n : nat),
         i <= n -> M1 ↑ j # i [(j + n) ← N] = M1 [n ← N] ↑ j # i
  IHM2 : forall (N : Term) (i j n : nat),
         i <= n -> M2 ↑ j # i [(j + n) ← N] = M2 [n ← N] ↑ j # i
  IHM3 : forall (N : Term) (i j n : nat),
         i <= n -> M3 ↑ j # i [(j + n) ← N] = M3 [n ← N] ↑ j # i
  IHM4 : forall (N : Term) (i j n : nat),
         i <= n -> M4 ↑ j # i [(j + n) ← N] = M4 [n ← N] ↑ j # i
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   M1 ↑ j # i [(j + n) ← N] ·( M2 ↑ j # i [(j + n) ← N],
   M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
   M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
   M4 [n ← N] ↑ j # i

subgoal 2 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 3 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)



rewrite IHM1; intuition.
3 subgoals, subgoal 1 (ID 4273)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j n : nat),
         i <= n -> M1 ↑ j # i [(j + n) ← N] = M1 [n ← N] ↑ j # i
  IHM2 : forall (N : Term) (i j n : nat),
         i <= n -> M2 ↑ j # i [(j + n) ← N] = M2 [n ← N] ↑ j # i
  IHM3 : forall (N : Term) (i j n : nat),
         i <= n -> M3 ↑ j # i [(j + n) ← N] = M3 [n ← N] ↑ j # i
  IHM4 : forall (N : Term) (i j n : nat),
         i <= n -> M4 ↑ j # i [(j + n) ← N] = M4 [n ← N] ↑ j # i
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   M1 [n ← N] ↑ j # i ·( M2 ↑ j # i [(j + n) ← N],
   M3 ↑ j # (S i) [(S (j + n)) ← N])M4 ↑ j # i [(j + n) ← N] =
   M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
   M4 [n ← N] ↑ j # i

subgoal 2 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 3 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

replace (S(j+n)) with (j+(S n)) by intuition.
3 subgoals, subgoal 1 (ID 4295)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j n : nat),
         i <= n -> M1 ↑ j # i [(j + n) ← N] = M1 [n ← N] ↑ j # i
  IHM2 : forall (N : Term) (i j n : nat),
         i <= n -> M2 ↑ j # i [(j + n) ← N] = M2 [n ← N] ↑ j # i
  IHM3 : forall (N : Term) (i j n : nat),
         i <= n -> M3 ↑ j # i [(j + n) ← N] = M3 [n ← N] ↑ j # i
  IHM4 : forall (N : Term) (i j n : nat),
         i <= n -> M4 ↑ j # i [(j + n) ← N] = M4 [n ← N] ↑ j # i
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   M1 [n ← N] ↑ j # i ·( M2 ↑ j # i [(j + n) ← N],
   M3 ↑ j # (S i) [(j + S n) ← N])M4 ↑ j # i [(j + n) ← N] =
   M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
   M4 [n ← N] ↑ j # i

subgoal 2 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 3 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)

rewrite IHM3; intuition.
3 subgoals, subgoal 1 (ID 4316)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i j n : nat),
         i <= n -> M1 ↑ j # i [(j + n) ← N] = M1 [n ← N] ↑ j # i
  IHM2 : forall (N : Term) (i j n : nat),
         i <= n -> M2 ↑ j # i [(j + n) ← N] = M2 [n ← N] ↑ j # i
  IHM3 : forall (N : Term) (i j n : nat),
         i <= n -> M3 ↑ j # i [(j + n) ← N] = M3 [n ← N] ↑ j # i
  IHM4 : forall (N : Term) (i j n : nat),
         i <= n -> M4 ↑ j # i [(j + n) ← N] = M4 [n ← N] ↑ j # i
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   M1 [n ← N] ↑ j # i ·( M2 ↑ j # i [(j + n) ← N],
   M3 [(S n) ← N] ↑ j # (S i))M4 ↑ j # i [(j + n) ← N] =
   M1 [n ← N] ↑ j # i ·( M2 [n ← N] ↑ j # i, M3 [(S n) ← N] ↑ j # (S i))
   M4 [n ← N] ↑ j # i

subgoal 2 (ID 3943) is:
 Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
 Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)
subgoal 3 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


rewrite IHM2; intuition; rewrite IHM4; intuition.
2 subgoals, subgoal 1 (ID 3943)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j n : nat),
         i <= n -> M1 ↑ j # i [(j + n) ← N] = M1 [n ← N] ↑ j # i
  IHM2 : forall (N : Term) (i j n : nat),
         i <= n -> M2 ↑ j # i [(j + n) ← N] = M2 [n ← N] ↑ j # i
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(S (j + n)) ← N] =
   Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)

subgoal 2 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


replace (S(j+n)) with (j+(S n)) by intuition.
2 subgoals, subgoal 1 (ID 4376)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j n : nat),
         i <= n -> M1 ↑ j # i [(j + n) ← N] = M1 [n ← N] ↑ j # i
  IHM2 : forall (N : Term) (i j n : nat),
         i <= n -> M2 ↑ j # i [(j + n) ← N] = M2 [n ← N] ↑ j # i
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   Π (M1 ↑ j # i [(j + n) ← N]), M2 ↑ j # (S i) [(j + S n) ← N] =
   Π (M1 [n ← N] ↑ j # i), M2 [(S n) ← N] ↑ j # (S i)

subgoal 2 (ID 3944) is:
 λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
 λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)
(dependent evars:)


rewrite IHM1; intuition;
rewrite <- (IHM2 N (S i) j (S n)); intuition.
1 subgoals, subgoal 1 (ID 3944)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j n : nat),
         i <= n -> M1 ↑ j # i [(j + n) ← N] = M1 [n ← N] ↑ j # i
  IHM2 : forall (N : Term) (i j n : nat),
         i <= n -> M2 ↑ j # i [(j + n) ← N] = M2 [n ← N] ↑ j # i
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(S (j + n)) ← N] =
   λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)

(dependent evars:)


replace (S(j+n)) with (j+(S n)) by intuition.
1 subgoals, subgoal 1 (ID 4426)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i j n : nat),
         i <= n -> M1 ↑ j # i [(j + n) ← N] = M1 [n ← N] ↑ j # i
  IHM2 : forall (N : Term) (i j n : nat),
         i <= n -> M2 ↑ j # i [(j + n) ← N] = M2 [n ← N] ↑ j # i
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   λ [M1 ↑ j # i [(j + n) ← N]], M2 ↑ j # (S i) [(j + S n) ← N] =
   λ [M1 [n ← N] ↑ j # i], M2 [(S n) ← N] ↑ j # (S i)

(dependent evars:)


rewrite IHM1; intuition;
rewrite <- (IHM2 N (S i) j (S n)); intuition.
No more subgoals.
(dependent evars:)


Qed.
substP2 is defined



Lemma substP3: forall M N i k n, i <= k -> k <= i+n ->
  (M (S n) # i) [ k N] = M n # i.
1 subgoals, subgoal 1 (ID 4479)
  
  ============================
   forall (M N : Term) (i k n : nat),
   i <= k -> k <= i + n -> M ↑ (S n) # i [k ← N] = M ↑ n # i

(dependent evars:)


intro M; induction M; intros; simpl.
5 subgoals, subgoal 1 (ID 4544)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   (if le_gt_dec i v then #(S (n + v)) else #v) [k ← N] =
   (if le_gt_dec i v then #(n + v) else #v)

subgoal 2 (ID 4545) is:
 !s = !s
subgoal 3 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 4 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 5 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


destruct (le_gt_dec i v).
6 subgoals, subgoal 1 (ID 4557)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  ============================
   #(S (n + v)) [k ← N] = #(n + v)

subgoal 2 (ID 4558) is:
 #v [k ← N] = #v
subgoal 3 (ID 4545) is:
 !s = !s
subgoal 4 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 5 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 6 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


unfold subst_rec.
6 subgoals, subgoal 1 (ID 4559)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  ============================
   match lt_eq_lt_dec (S (n + v)) k with
   | inleft (left _) => #(S (n + v))
   | inleft (right _) => N ↑ k
   | inright _ => #(S (n + v) - 1)
   end = #(n + v)

subgoal 2 (ID 4558) is:
 #v [k ← N] = #v
subgoal 3 (ID 4545) is:
 !s = !s
subgoal 4 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 5 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 6 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


destruct (lt_eq_lt_dec (S(n+v)) k) as [[] | ].
8 subgoals, subgoal 1 (ID 4573)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  l0 : S (n + v) < k
  ============================
   #(S (n + v)) = #(n + v)

subgoal 2 (ID 4574) is:
 N ↑ k = #(n + v)
subgoal 3 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 4 (ID 4558) is:
 #v [k ← N] = #v
subgoal 5 (ID 4545) is:
 !s = !s
subgoal 6 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 7 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 8 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


elim (lt_irrefl (i+n)).
8 subgoals, subgoal 1 (ID 4576)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  l0 : S (n + v) < k
  ============================
   i + n < i + n

subgoal 2 (ID 4574) is:
 N ↑ k = #(n + v)
subgoal 3 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 4 (ID 4558) is:
 #v [k ← N] = #v
subgoal 5 (ID 4545) is:
 !s = !s
subgoal 6 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 7 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 8 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

apply lt_le_trans with k; intuition.
8 subgoals, subgoal 1 (ID 4577)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  l0 : S (n + v) < k
  ============================
   i + n < k

subgoal 2 (ID 4574) is:
 N ↑ k = #(n + v)
subgoal 3 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 4 (ID 4558) is:
 #v [k ← N] = #v
subgoal 5 (ID 4545) is:
 !s = !s
subgoal 6 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 7 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 8 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


apply le_lt_trans with (v+n).
9 subgoals, subgoal 1 (ID 4635)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  l0 : S (n + v) < k
  ============================
   i + n <= v + n

subgoal 2 (ID 4636) is:
 v + n < k
subgoal 3 (ID 4574) is:
 N ↑ k = #(n + v)
subgoal 4 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 5 (ID 4558) is:
 #v [k ← N] = #v
subgoal 6 (ID 4545) is:
 !s = !s
subgoal 7 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 8 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 9 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

intuition.
8 subgoals, subgoal 1 (ID 4636)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  l0 : S (n + v) < k
  ============================
   v + n < k

subgoal 2 (ID 4574) is:
 N ↑ k = #(n + v)
subgoal 3 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 4 (ID 4558) is:
 #v [k ← N] = #v
subgoal 5 (ID 4545) is:
 !s = !s
subgoal 6 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 7 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 8 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

rewrite plus_comm; intuition.
7 subgoals, subgoal 1 (ID 4574)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  e : S (n + v) = k
  ============================
   N ↑ k = #(n + v)

subgoal 2 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 4558) is:
 #v [k ← N] = #v
subgoal 4 (ID 4545) is:
 !s = !s
subgoal 5 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 6 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 7 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


subst.
7 subgoals, subgoal 1 (ID 4684)
  
  v : Vars
  N : Term
  i : nat
  n : nat
  l : i <= v
  H : i <= S (n + v)
  H0 : S (n + v) <= i + n
  ============================
   N ↑ (S (n + v)) = #(n + v)

subgoal 2 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 4558) is:
 #v [k ← N] = #v
subgoal 4 (ID 4545) is:
 !s = !s
subgoal 5 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 6 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 7 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

replace (i+n) with (n+i) in H0 by (apply plus_comm) .
7 subgoals, subgoal 1 (ID 4689)
  
  v : Vars
  N : Term
  i : nat
  n : nat
  l : i <= v
  H : i <= S (n + v)
  H0 : S (n + v) <= n + i
  ============================
   N ↑ (S (n + v)) = #(n + v)

subgoal 2 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 4558) is:
 #v [k ← N] = #v
subgoal 4 (ID 4545) is:
 !s = !s
subgoal 5 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 6 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 7 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

replace (S (n+v)) with (n + S v) in H0 by intuition.
7 subgoals, subgoal 1 (ID 4695)
  
  v : Vars
  N : Term
  i : nat
  n : nat
  l : i <= v
  H : i <= S (n + v)
  H0 : n + S v <= n + i
  ============================
   N ↑ (S (n + v)) = #(n + v)

subgoal 2 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 4558) is:
 #v [k ← N] = #v
subgoal 4 (ID 4545) is:
 !s = !s
subgoal 5 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 6 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 7 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


apply plus_le_reg_l in H0.
7 subgoals, subgoal 1 (ID 4711)
  
  v : Vars
  N : Term
  i : nat
  n : nat
  l : i <= v
  H : i <= S (n + v)
  H0 : S v <= i
  ============================
   N ↑ (S (n + v)) = #(n + v)

subgoal 2 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 4558) is:
 #v [k ← N] = #v
subgoal 4 (ID 4545) is:
 !s = !s
subgoal 5 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 6 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 7 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

elim (lt_irrefl i).
7 subgoals, subgoal 1 (ID 4712)
  
  v : Vars
  N : Term
  i : nat
  n : nat
  l : i <= v
  H : i <= S (n + v)
  H0 : S v <= i
  ============================
   i < i

subgoal 2 (ID 4575) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 4558) is:
 #v [k ← N] = #v
subgoal 4 (ID 4545) is:
 !s = !s
subgoal 5 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 6 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 7 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

apply le_lt_trans with v; intuition.
6 subgoals, subgoal 1 (ID 4575)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  l0 : k < S (n + v)
  ============================
   #(S (n + v) - 1) = #(n + v)

subgoal 2 (ID 4558) is:
 #v [k ← N] = #v
subgoal 3 (ID 4545) is:
 !s = !s
subgoal 4 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 5 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 6 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


simpl.
6 subgoals, subgoal 1 (ID 4715)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  l0 : k < S (n + v)
  ============================
   #(n + v - 0) = #(n + v)

subgoal 2 (ID 4558) is:
 #v [k ← N] = #v
subgoal 3 (ID 4545) is:
 !s = !s
subgoal 4 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 5 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 6 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

rewrite <- minus_n_O.
6 subgoals, subgoal 1 (ID 4716)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  l : i <= v
  l0 : k < S (n + v)
  ============================
   #(n + v) = #(n + v)

subgoal 2 (ID 4558) is:
 #v [k ← N] = #v
subgoal 3 (ID 4545) is:
 !s = !s
subgoal 4 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 5 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 6 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

trivial.
5 subgoals, subgoal 1 (ID 4558)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  ============================
   #v [k ← N] = #v

subgoal 2 (ID 4545) is:
 !s = !s
subgoal 3 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 4 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 5 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


simpl.
5 subgoals, subgoal 1 (ID 4717)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  ============================
   match lt_eq_lt_dec v k with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ k
   | inright _ => #(v - 1)
   end = #v

subgoal 2 (ID 4545) is:
 !s = !s
subgoal 3 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 4 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 5 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

destruct (lt_eq_lt_dec v k) as [[] | ].
7 subgoals, subgoal 1 (ID 4731)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : v < k
  ============================
   #v = #v

subgoal 2 (ID 4732) is:
 N ↑ k = #v
subgoal 3 (ID 4733) is:
 #(v - 1) = #v
subgoal 4 (ID 4545) is:
 !s = !s
subgoal 5 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 6 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 7 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


reflexivity.
6 subgoals, subgoal 1 (ID 4732)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  e : v = k
  ============================
   N ↑ k = #v

subgoal 2 (ID 4733) is:
 #(v - 1) = #v
subgoal 3 (ID 4545) is:
 !s = !s
subgoal 4 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 5 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 6 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

subst.
6 subgoals, subgoal 1 (ID 4739)
  
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > k
  ============================
   N ↑ k = #k

subgoal 2 (ID 4733) is:
 #(v - 1) = #v
subgoal 3 (ID 4545) is:
 !s = !s
subgoal 4 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 5 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 6 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

elim (lt_irrefl i).
6 subgoals, subgoal 1 (ID 4740)
  
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > k
  ============================
   i < i

subgoal 2 (ID 4733) is:
 #(v - 1) = #v
subgoal 3 (ID 4545) is:
 !s = !s
subgoal 4 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 5 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 6 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

apply le_lt_trans with k; intuition.
5 subgoals, subgoal 1 (ID 4733)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k < v
  ============================
   #(v - 1) = #v

subgoal 2 (ID 4545) is:
 !s = !s
subgoal 3 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 4 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 5 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


elim (lt_irrefl k).
5 subgoals, subgoal 1 (ID 4743)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k < v
  ============================
   k < k

subgoal 2 (ID 4545) is:
 !s = !s
subgoal 3 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 4 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 5 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

apply lt_trans with v; trivial.
5 subgoals, subgoal 1 (ID 4745)
  
  v : Vars
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > v
  l : k < v
  ============================
   v < k

subgoal 2 (ID 4545) is:
 !s = !s
subgoal 3 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 4 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 5 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

apply lt_le_trans with i; intuition.
4 subgoals, subgoal 1 (ID 4545)
  
  s : Sorts
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   !s = !s

subgoal 2 (ID 4546) is:
 M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
 M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
 M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i
subgoal 3 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 4 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)



reflexivity.
3 subgoals, subgoal 1 (ID 4546)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  IHM3 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M3 ↑ (S n) # i [k ← N] = M3 ↑ n # i
  IHM4 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M4 ↑ (S n) # i [k ← N] = M4 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   M1 ↑ (S n) # i [k ← N] ·( M2 ↑ (S n) # i [k ← N],
   M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ (S n) # i [k ← N] =
   M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i

subgoal 2 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 3 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


rewrite IHM1; intuition;rewrite IHM4; intuition.
3 subgoals, subgoal 1 (ID 4770)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  IHM3 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M3 ↑ (S n) # i [k ← N] = M3 ↑ n # i
  IHM4 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M4 ↑ (S n) # i [k ← N] = M4 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   M1 ↑ n # i ·( M2 ↑ (S n) # i [k ← N], M3 ↑ (S n) # (S i) [(S k) ← N])
   M4 ↑ n # i = M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i

subgoal 2 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 3 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


rewrite IHM2; intuition.
3 subgoals, subgoal 1 (ID 4791)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  IHM3 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M3 ↑ (S n) # i [k ← N] = M3 ↑ n # i
  IHM4 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M4 ↑ (S n) # i [k ← N] = M4 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ n # i =
   M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i

subgoal 2 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 3 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

change (S i + n) with (S (i+n)).
3 subgoals, subgoal 1 (ID 4813)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  IHM3 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M3 ↑ (S n) # i [k ← N] = M3 ↑ n # i
  IHM4 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M4 ↑ (S n) # i [k ← N] = M4 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ (S n) # (S i) [(S k) ← N])M4 ↑ n # i =
   M1 ↑ n # i ·( M2 ↑ n # i, M3 ↑ n # (S i))M4 ↑ n # i

subgoal 2 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 3 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

rewrite IHM3; intuition.
3 subgoals, subgoal 1 (ID 4816)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  IHM3 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M3 ↑ (S n) # i [k ← N] = M3 ↑ n # i
  IHM4 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M4 ↑ (S n) # i [k ← N] = M4 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S i + n

subgoal 2 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 3 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


change (S i + n) with (S (i+n)).
3 subgoals, subgoal 1 (ID 5027)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  IHM3 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M3 ↑ (S n) # i [k ← N] = M3 ↑ n # i
  IHM4 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M4 ↑ (S n) # i [k ← N] = M4 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S (i + n)

subgoal 2 (ID 4547) is:
 Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
 Π (M1 ↑ n # i), M2 ↑ n # (S i)
subgoal 3 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

intuition.
2 subgoals, subgoal 1 (ID 4547)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   Π (M1 ↑ (S n) # i [k ← N]), M2 ↑ (S n) # (S i) [(S k) ← N] =
   Π (M1 ↑ n # i), M2 ↑ n # (S i)

subgoal 2 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


rewrite IHM1; intuition; rewrite <- (IHM2 N (S i) (S k) n); intuition.
2 subgoals, subgoal 1 (ID 5064)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S i + n

subgoal 2 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)


change (S i + n) with (S (i+n)).
2 subgoals, subgoal 1 (ID 5267)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S (i + n)

subgoal 2 (ID 4548) is:
 λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
 λ [M1 ↑ n # i], M2 ↑ n # (S i)
(dependent evars:)

intuition.
1 subgoals, subgoal 1 (ID 4548)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   λ [M1 ↑ (S n) # i [k ← N]], M2 ↑ (S n) # (S i) [(S k) ← N] =
   λ [M1 ↑ n # i], M2 ↑ n # (S i)

(dependent evars:)


rewrite IHM1; intuition; rewrite <- (IHM2 N (S i) (S k) n); intuition.
1 subgoals, subgoal 1 (ID 5300)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S i + n

(dependent evars:)


change (S i + n) with (S (i+n)).
1 subgoals, subgoal 1 (ID 5503)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M1 ↑ (S n) # i [k ← N] = M1 ↑ n # i
  IHM2 : forall (N : Term) (i k n : nat),
         i <= k -> k <= i + n -> M2 ↑ (S n) # i [k ← N] = M2 ↑ n # i
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   S k <= S (i + n)

(dependent evars:)

intuition.
No more subgoals.
(dependent evars:)


Qed.
substP3 is defined



Lemma substP4: forall M N P i j,
   (M [ i N]) [i+j P] = (M [S(i+j) P]) [i N[j P]].
1 subgoals, subgoal 1 (ID 5523)
  
  ============================
   forall (M N P : Term) (i j : nat),
   M [i ← N] [(i + j) ← P] = M [(S (i + j)) ← P] [i ← N [j ← P]]

(dependent evars:)


intro M; induction M; intros; simpl.
5 subgoals, subgoal 1 (ID 5578)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N ↑ i
   | inright _ => #(v - 1)
   end [(i + j) ← P] =
   match lt_eq_lt_dec v (S (i + j)) with
   | inleft (left _) => #v
   | inleft (right _) => P ↑ (S (i + j))
   | inright _ => #(v - 1)
   end [i ← N [j ← P]]

subgoal 2 (ID 5579) is:
 !s = !s
subgoal 3 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 5 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


destruct (lt_eq_lt_dec v i) as [[] | ] ; destruct (lt_eq_lt_dec v (S(i+j))) as [[] | ].
13 subgoals, subgoal 1 (ID 5612)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  ============================
   #v [(i + j) ← P] = #v [i ← N [j ← P]]

subgoal 2 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 5579) is:
 !s = !s
subgoal 11 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 13 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


simpl.
13 subgoals, subgoal 1 (ID 5647)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  ============================
   match lt_eq_lt_dec v (i + j) with
   | inleft (left _) => #v
   | inleft (right _) => P ↑ (i + j)
   | inright _ => #(v - 1)
   end =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 5579) is:
 !s = !s
subgoal 11 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 13 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


destruct (lt_eq_lt_dec v (i+j)) as [[] | ].
15 subgoals, subgoal 1 (ID 5661)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  l1 : v < i + j
  ============================
   #v =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 5662) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 10 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 11 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 12 (ID 5579) is:
 !s = !s
subgoal 13 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 14 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 15 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

destruct (lt_eq_lt_dec v i) as [[] | ].
17 subgoals, subgoal 1 (ID 5677)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  l1 : v < i + j
  l2 : v < i
  ============================
   #v = #v

subgoal 2 (ID 5678) is:
 #v = N [j ← P] ↑ i
subgoal 3 (ID 5679) is:
 #v = #(v - 1)
subgoal 4 (ID 5662) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 5 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 6 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 12 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 13 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 14 (ID 5579) is:
 !s = !s
subgoal 15 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 16 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 17 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


trivial.
16 subgoals, subgoal 1 (ID 5678)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  l1 : v < i + j
  e : v = i
  ============================
   #v = N [j ← P] ↑ i

subgoal 2 (ID 5679) is:
 #v = #(v - 1)
subgoal 3 (ID 5662) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 5 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 11 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 12 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 13 (ID 5579) is:
 !s = !s
subgoal 14 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 15 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 16 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


subst.
16 subgoals, subgoal 1 (ID 5686)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < i
  l0 : i < S (i + j)
  l1 : i < i + j
  ============================
   #i = N [j ← P] ↑ i

subgoal 2 (ID 5679) is:
 #v = #(v - 1)
subgoal 3 (ID 5662) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 5 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 11 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 12 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 13 (ID 5579) is:
 !s = !s
subgoal 14 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 15 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 16 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply lt_irrefl in l; elim l.
15 subgoals, subgoal 1 (ID 5679)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  l1 : v < i + j
  l2 : i < v
  ============================
   #v = #(v - 1)

subgoal 2 (ID 5662) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 10 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 11 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 12 (ID 5579) is:
 !s = !s
subgoal 13 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 14 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 15 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim ( lt_asym v i); trivial.
14 subgoals, subgoal 1 (ID 5662)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  e : v = i + j
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 5579) is:
 !s = !s
subgoal 12 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 13 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 14 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


subst.
14 subgoals, subgoal 1 (ID 5696)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i + j < i
  l0 : i + j < S (i + j)
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec (i + j) i with
   | inleft (left _) => #(i + j)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(i + j - 1)
   end

subgoal 2 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 5579) is:
 !s = !s
subgoal 12 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 13 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 14 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite plus_comm in l.
14 subgoals, subgoal 1 (ID 5698)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : j + i < i
  l0 : i + j < S (i + j)
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec (i + j) i with
   | inleft (left _) => #(i + j)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(i + j - 1)
   end

subgoal 2 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 5579) is:
 !s = !s
subgoal 12 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 13 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 14 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_irrefl i).
14 subgoals, subgoal 1 (ID 5699)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : j + i < i
  l0 : i + j < S (i + j)
  ============================
   i < i

subgoal 2 (ID 5663) is:
 #(v - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 5579) is:
 !s = !s
subgoal 12 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 13 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 14 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

induction j; simpl in *; intuition.
13 subgoals, subgoal 1 (ID 5663)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  l1 : i + j < v
  ============================
   #(v - 1) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 5579) is:
 !s = !s
subgoal 11 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 13 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_irrefl i).
13 subgoals, subgoal 1 (ID 5750)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  l1 : i + j < v
  ============================
   i < i

subgoal 2 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 5579) is:
 !s = !s
subgoal 11 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 13 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply le_lt_trans with v;intuition.
13 subgoals, subgoal 1 (ID 5751)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  l1 : i + j < v
  ============================
   i <= v

subgoal 2 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 5579) is:
 !s = !s
subgoal 11 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 13 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite plus_comm in l1; intuition.
13 subgoals, subgoal 1 (ID 5773)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : v < S (i + j)
  l1 : j + i < v
  ============================
   i <= v

subgoal 2 (ID 5613) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 5579) is:
 !s = !s
subgoal 11 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 13 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

induction j; simpl in *; intuition.
12 subgoals, subgoal 1 (ID 5613)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  e : v = S (i + j)
  ============================
   #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 5579) is:
 !s = !s
subgoal 10 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 11 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 12 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


subst.
12 subgoals, subgoal 1 (ID 5869)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : S (i + j) < i
  ============================
   #(S (i + j)) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 5579) is:
 !s = !s
subgoal 10 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 11 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 12 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_irrefl i).
12 subgoals, subgoal 1 (ID 5870)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : S (i + j) < i
  ============================
   i < i

subgoal 2 (ID 5614) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 5579) is:
 !s = !s
subgoal 10 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 11 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 12 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply lt_trans with (S (i+j)); intuition.
11 subgoals, subgoal 1 (ID 5614)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : S (i + j) < v
  ============================
   #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]

subgoal 2 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5579) is:
 !s = !s
subgoal 9 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 11 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_irrefl i).
11 subgoals, subgoal 1 (ID 5912)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : S (i + j) < v
  ============================
   i < i

subgoal 2 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5579) is:
 !s = !s
subgoal 9 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 11 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply lt_trans with (S (i+j)); intuition.
11 subgoals, subgoal 1 (ID 5914)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : S (i + j) < v
  ============================
   S (i + j) < i

subgoal 2 (ID 5628) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5579) is:
 !s = !s
subgoal 9 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 11 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply lt_trans with v; trivial.
10 subgoals, subgoal 1 (ID 5628)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  e : v = i
  l : v < S (i + j)
  ============================
   N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]

subgoal 2 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5579) is:
 !s = !s
subgoal 8 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 10 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


simpl.
10 subgoals, subgoal 1 (ID 6012)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  e : v = i
  l : v < S (i + j)
  ============================
   N ↑ i [(i + j) ← P] =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5579) is:
 !s = !s
subgoal 8 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 10 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

subst.
10 subgoals, subgoal 1 (ID 6017)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  ============================
   N ↑ i [(i + j) ← P] =
   match lt_eq_lt_dec i i with
   | inleft (left _) => #i
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(i - 1)
   end

subgoal 2 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5579) is:
 !s = !s
subgoal 8 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 10 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

destruct (lt_eq_lt_dec i i) as [[] | ].
12 subgoals, subgoal 1 (ID 6031)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  l0 : i < i
  ============================
   N ↑ i [(i + j) ← P] = #i

subgoal 2 (ID 6032) is:
 N ↑ i [(i + j) ← P] = N [j ← P] ↑ i
subgoal 3 (ID 6033) is:
 N ↑ i [(i + j) ← P] = #(i - 1)
subgoal 4 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 5579) is:
 !s = !s
subgoal 10 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 11 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 12 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_irrefl i); trivial.
11 subgoals, subgoal 1 (ID 6032)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  e : i = i
  ============================
   N ↑ i [(i + j) ← P] = N [j ← P] ↑ i

subgoal 2 (ID 6033) is:
 N ↑ i [(i + j) ← P] = #(i - 1)
subgoal 3 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5579) is:
 !s = !s
subgoal 9 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 11 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply substP2; intuition.
10 subgoals, subgoal 1 (ID 6033)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  l0 : i < i
  ============================
   N ↑ i [(i + j) ← P] = #(i - 1)

subgoal 2 (ID 5629) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5579) is:
 !s = !s
subgoal 8 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 10 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_irrefl i); trivial.
9 subgoals, subgoal 1 (ID 5629)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  e : v = i
  e0 : v = S (i + j)
  ============================
   N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5579) is:
 !s = !s
subgoal 7 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 9 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


subst.
9 subgoals, subgoal 1 (ID 6048)
  
  N : Term
  P : Term
  i : nat
  j : nat
  e0 : i = S (i + j)
  ============================
   N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5579) is:
 !s = !s
subgoal 7 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 9 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite plus_comm in e0.
9 subgoals, subgoal 1 (ID 6050)
  
  N : Term
  P : Term
  i : nat
  j : nat
  e0 : i = S (j + i)
  ============================
   N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5579) is:
 !s = !s
subgoal 7 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 9 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply succ_plus_discr in e0.
9 subgoals, subgoal 1 (ID 6052)
  
  N : Term
  P : Term
  i : nat
  j : nat
  e0 : False
  ============================
   N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5630) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5579) is:
 !s = !s
subgoal 7 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 9 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim e0.
8 subgoals, subgoal 1 (ID 5630)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  e : v = i
  l : S (i + j) < v
  ============================
   N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]

subgoal 2 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


subst.
8 subgoals, subgoal 1 (ID 6057)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : S (i + j) < i
  ============================
   N ↑ i [(i + j) ← P] = #(i - 1) [i ← N [j ← P]]

subgoal 2 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_irrefl i).
8 subgoals, subgoal 1 (ID 6058)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : S (i + j) < i
  ============================
   i < i

subgoal 2 (ID 5644) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply le_lt_trans with (i+j); intuition.
7 subgoals, subgoal 1 (ID 5644)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  ============================
   #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]

subgoal 2 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


simpl.
7 subgoals, subgoal 1 (ID 6086)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  ============================
   match lt_eq_lt_dec (v - 1) (i + j) with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => P ↑ (i + j)
   | inright _ => #(v - 1 - 1)
   end =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


destruct (lt_eq_lt_dec (v-1) (i+j)) as [[] | ].
9 subgoals, subgoal 1 (ID 6100)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : v - 1 < i + j
  ============================
   #(v - 1) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 6101) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5579) is:
 !s = !s
subgoal 7 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 9 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

destruct (lt_eq_lt_dec v i) as [[] | ].
11 subgoals, subgoal 1 (ID 6116)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : v - 1 < i + j
  l2 : v < i
  ============================
   #(v - 1) = #v

subgoal 2 (ID 6117) is:
 #(v - 1) = N [j ← P] ↑ i
subgoal 3 (ID 6118) is:
 #(v - 1) = #(v - 1)
subgoal 4 (ID 6101) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 5 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 6 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 5579) is:
 !s = !s
subgoal 9 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 11 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_asym v i); trivial.
10 subgoals, subgoal 1 (ID 6117)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : v - 1 < i + j
  e : v = i
  ============================
   #(v - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6118) is:
 #(v - 1) = #(v - 1)
subgoal 3 (ID 6101) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 5 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5579) is:
 !s = !s
subgoal 8 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 10 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

subst.
10 subgoals, subgoal 1 (ID 6127)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < i
  l0 : i < S (i + j)
  l1 : i - 1 < i + j
  ============================
   #(i - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6118) is:
 #(v - 1) = #(v - 1)
subgoal 3 (ID 6101) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 5 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 5579) is:
 !s = !s
subgoal 8 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 10 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_irrefl i); trivial.
9 subgoals, subgoal 1 (ID 6118)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : v - 1 < i + j
  l2 : i < v
  ============================
   #(v - 1) = #(v - 1)

subgoal 2 (ID 6101) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 4 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 5579) is:
 !s = !s
subgoal 7 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 9 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


trivial.
8 subgoals, subgoal 1 (ID 6101)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  e : v - 1 = i + j
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- e in l0.
8 subgoals, subgoal 1 (ID 6130)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (v - 1)
  e : v - 1 = i + j
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- pred_of_minus in l0.
8 subgoals, subgoal 1 (ID 6132)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (pred v)
  e : v - 1 = i + j
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


rewrite <- (S_pred v i l) in l0.
8 subgoals, subgoal 1 (ID 6134)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < v
  e : v - 1 = i + j
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 6102) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec v i with
 | inleft (left _) => #v
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1)
 end
subgoal 3 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_irrefl v); trivial.
7 subgoals, subgoal 1 (ID 6102)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : i + j < v - 1
  ============================
   #(v - 1 - 1) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


apply lt_n_S in l1.
7 subgoals, subgoal 1 (ID 6137)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : S (i + j) < S (v - 1)
  ============================
   #(v - 1 - 1) =
   match lt_eq_lt_dec v i with
   | inleft (left _) => #v
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1)
   end

subgoal 2 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_irrefl v).
7 subgoals, subgoal 1 (ID 6138)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : S (i + j) < S (v - 1)
  ============================
   v < v

subgoal 2 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


apply lt_trans with (S(i+j)); trivial.
7 subgoals, subgoal 1 (ID 6140)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : S (i + j) < S (v - 1)
  ============================
   S (i + j) < v

subgoal 2 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


rewrite <- pred_of_minus in l1.
7 subgoals, subgoal 1 (ID 6142)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : S (i + j) < S (pred v)
  ============================
   S (i + j) < v

subgoal 2 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- (S_pred v i l) in l1.
7 subgoals, subgoal 1 (ID 6144)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : v < S (i + j)
  l1 : S (i + j) < v
  ============================
   S (i + j) < v

subgoal 2 (ID 5645) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 5645)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  e : v = S (i + j)
  ============================
   #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


subst.
6 subgoals, subgoal 1 (ID 6149)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  ============================
   #(S (i + j) - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

simpl.
6 subgoals, subgoal 1 (ID 6150)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  ============================
   match lt_eq_lt_dec (i + j - 0) (i + j) with
   | inleft (left _) => #(i + j - 0)
   | inleft (right _) => P ↑ (i + j)
   | inright _ => #(i + j - 0 - 1)
   end = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- minus_n_O.
6 subgoals, subgoal 1 (ID 6151)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  ============================
   match lt_eq_lt_dec (i + j) (i + j) with
   | inleft (left _) => #(i + j)
   | inleft (right _) => P ↑ (i + j)
   | inright _ => #(i + j - 1)
   end = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


destruct (lt_eq_lt_dec (i+j) (i+j)) as [[] | ].
8 subgoals, subgoal 1 (ID 6165)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  l0 : i + j < i + j
  ============================
   #(i + j) = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 6166) is:
 P ↑ (i + j) = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 6167) is:
 #(i + j - 1) = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_irrefl (i+j)) ; trivial.
7 subgoals, subgoal 1 (ID 6166)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  e : i + j = i + j
  ============================
   P ↑ (i + j) = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 6167) is:
 #(i + j - 1) = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


symmetry.
7 subgoals, subgoal 1 (ID 6170)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  e : i + j = i + j
  ============================
   P ↑ (S (i + j)) [i ← N [j ← P]] = P ↑ (i + j)

subgoal 2 (ID 6167) is:
 #(i + j - 1) = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply substP3; intuition.
6 subgoals, subgoal 1 (ID 6167)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  l0 : i + j < i + j
  ============================
   #(i + j - 1) = P ↑ (S (i + j)) [i ← N [j ← P]]

subgoal 2 (ID 5646) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_irrefl (i+j)) ; trivial.
5 subgoals, subgoal 1 (ID 5646)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  ============================
   #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]

subgoal 2 (ID 5579) is:
 !s = !s
subgoal 3 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 5 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


simpl.
5 subgoals, subgoal 1 (ID 6189)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  ============================
   match lt_eq_lt_dec (v - 1) (i + j) with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => P ↑ (i + j)
   | inright _ => #(v - 1 - 1)
   end =
   match lt_eq_lt_dec (v - 1) i with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1 - 1)
   end

subgoal 2 (ID 5579) is:
 !s = !s
subgoal 3 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 5 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


destruct (lt_eq_lt_dec (v-1) (i+j)) as [[] | ].
7 subgoals, subgoal 1 (ID 6203)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : v - 1 < i + j
  ============================
   #(v - 1) =
   match lt_eq_lt_dec (v - 1) i with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1 - 1)
   end

subgoal 2 (ID 6204) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_irrefl v).
7 subgoals, subgoal 1 (ID 6206)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : v - 1 < i + j
  ============================
   v < v

subgoal 2 (ID 6204) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply lt_trans with (S (i+j)) ;trivial.
7 subgoals, subgoal 1 (ID 6207)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : v - 1 < i + j
  ============================
   v < S (i + j)

subgoal 2 (ID 6204) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


apply lt_n_S in l1.
7 subgoals, subgoal 1 (ID 6210)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : S (v - 1) < S (i + j)
  ============================
   v < S (i + j)

subgoal 2 (ID 6204) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- pred_of_minus in l1.
7 subgoals, subgoal 1 (ID 6212)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : S (pred v) < S (i + j)
  ============================
   v < S (i + j)

subgoal 2 (ID 6204) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- (S_pred v i l) in l1.
7 subgoals, subgoal 1 (ID 6214)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : v < S (i + j)
  ============================
   v < S (i + j)

subgoal 2 (ID 6204) is:
 P ↑ (i + j) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 6204)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  e : v - 1 = i + j
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec (v - 1) i with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1 - 1)
   end

subgoal 2 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


apply eq_S in e.
6 subgoals, subgoal 1 (ID 6216)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  e : S (v - 1) = S (i + j)
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec (v - 1) i with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1 - 1)
   end

subgoal 2 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- pred_of_minus in e.
6 subgoals, subgoal 1 (ID 6218)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  e : S (pred v) = S (i + j)
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec (v - 1) i with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1 - 1)
   end

subgoal 2 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- (S_pred v i l) in e.
6 subgoals, subgoal 1 (ID 6220)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  e : v = S (i + j)
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec (v - 1) i with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1 - 1)
   end

subgoal 2 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


subst.
6 subgoals, subgoal 1 (ID 6226)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S (i + j)
  l0 : S (i + j) < S (i + j)
  ============================
   P ↑ (i + j) =
   match lt_eq_lt_dec (S (i + j) - 1) i with
   | inleft (left _) => #(S (i + j) - 1)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(S (i + j) - 1 - 1)
   end

subgoal 2 (ID 6205) is:
 #(v - 1 - 1) =
 match lt_eq_lt_dec (v - 1) i with
 | inleft (left _) => #(v - 1)
 | inleft (right _) => N [j ← P] ↑ i
 | inright _ => #(v - 1 - 1)
 end
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_irrefl (S(i+j))); trivial.
5 subgoals, subgoal 1 (ID 6205)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : i + j < v - 1
  ============================
   #(v - 1 - 1) =
   match lt_eq_lt_dec (v - 1) i with
   | inleft (left _) => #(v - 1)
   | inleft (right _) => N [j ← P] ↑ i
   | inright _ => #(v - 1 - 1)
   end

subgoal 2 (ID 5579) is:
 !s = !s
subgoal 3 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 5 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


destruct (lt_eq_lt_dec (v-1) i) as [[] | ].
7 subgoals, subgoal 1 (ID 6241)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : i + j < v - 1
  l2 : v - 1 < i
  ============================
   #(v - 1 - 1) = #(v - 1)

subgoal 2 (ID 6242) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


elim (lt_irrefl v).
7 subgoals, subgoal 1 (ID 6244)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : i + j < v - 1
  l2 : v - 1 < i
  ============================
   v < v

subgoal 2 (ID 6242) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply le_lt_trans with i; trivial.
7 subgoals, subgoal 1 (ID 6245)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : i + j < v - 1
  l2 : v - 1 < i
  ============================
   v <= i

subgoal 2 (ID 6242) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

destruct v.
8 subgoals, subgoal 1 (ID 6256)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < 0
  l0 : S (i + j) < 0
  l1 : i + j < 0 - 1
  l2 : 0 - 1 < i
  ============================
   0 <= i

subgoal 2 (ID 6262) is:
 S v <= i
subgoal 3 (ID 6242) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 4 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 5 (ID 5579) is:
 !s = !s
subgoal 6 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 8 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

apply lt_n_O in l; elim l.
7 subgoals, subgoal 1 (ID 6262)
  
  v : nat
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S v
  l0 : S (i + j) < S v
  l1 : i + j < S v - 1
  l2 : S v - 1 < i
  ============================
   S v <= i

subgoal 2 (ID 6242) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


rewrite <- pred_of_minus in l2.
7 subgoals, subgoal 1 (ID 6266)
  
  v : nat
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S v
  l0 : S (i + j) < S v
  l1 : i + j < S v - 1
  l2 : pred (S v) < i
  ============================
   S v <= i

subgoal 2 (ID 6242) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

simpl in l2.
7 subgoals, subgoal 1 (ID 6267)
  
  v : nat
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S v
  l0 : S (i + j) < S v
  l1 : i + j < S v - 1
  l2 : v < i
  ============================
   S v <= i

subgoal 2 (ID 6242) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

trivial.
6 subgoals, subgoal 1 (ID 6242)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : i + j < v - 1
  e : v - 1 = i
  ============================
   #(v - 1 - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


destruct v.
7 subgoals, subgoal 1 (ID 6277)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < 0
  l0 : S (i + j) < 0
  l1 : i + j < 0 - 1
  e : 0 - 1 = i
  ============================
   #(0 - 1 - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6283) is:
 #(S v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 5579) is:
 !s = !s
subgoal 5 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 7 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_n_O i); trivial.
6 subgoals, subgoal 1 (ID 6283)
  
  v : nat
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S v
  l0 : S (i + j) < S v
  l1 : i + j < S v - 1
  e : S v - 1 = i
  ============================
   #(S v - 1 - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- pred_of_minus in e.
6 subgoals, subgoal 1 (ID 6286)
  
  v : nat
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S v
  l0 : S (i + j) < S v
  l1 : i + j < S v - 1
  e : pred (S v) = i
  ============================
   #(S v - 1 - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

simpl in e.
6 subgoals, subgoal 1 (ID 6287)
  
  v : nat
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S v
  l0 : S (i + j) < S v
  l1 : i + j < S v - 1
  e : v = i
  ============================
   #(S v - 1 - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

subst.
6 subgoals, subgoal 1 (ID 6294)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S i
  l0 : S (i + j) < S i
  l1 : i + j < S i - 1
  ============================
   #(S i - 1 - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


rewrite <- pred_of_minus in l1.
6 subgoals, subgoal 1 (ID 6296)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S i
  l0 : S (i + j) < S i
  l1 : i + j < pred (S i)
  ============================
   #(S i - 1 - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

simpl in l1.
6 subgoals, subgoal 1 (ID 6297)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S i
  l0 : S (i + j) < S i
  l1 : i + j < i
  ============================
   #(S i - 1 - 1) = N [j ← P] ↑ i

subgoal 2 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

elim (lt_irrefl i).
6 subgoals, subgoal 1 (ID 6298)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < S i
  l0 : S (i + j) < S i
  l1 : i + j < i
  ============================
   i < i

subgoal 2 (ID 6243) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 5579) is:
 !s = !s
subgoal 4 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 6 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


apply le_lt_trans with (i+j); intuition.
5 subgoals, subgoal 1 (ID 6243)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : i < v
  l0 : S (i + j) < v
  l1 : i + j < v - 1
  l2 : i < v - 1
  ============================
   #(v - 1 - 1) = #(v - 1 - 1)

subgoal 2 (ID 5579) is:
 !s = !s
subgoal 3 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 5 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


trivial.
4 subgoals, subgoal 1 (ID 5579)
  
  s : Sorts
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   !s = !s

subgoal 2 (ID 5580) is:
 M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
 M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]]
 ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
 M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
 M4 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 3 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 4 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


trivial.
3 subgoals, subgoal 1 (ID 5580)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N P : Term) (i j : nat),
         M1 [i ← N] [(i + j) ← P] = M1 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM2 : forall (N P : Term) (i j : nat),
         M2 [i ← N] [(i + j) ← P] = M2 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM3 : forall (N P : Term) (i j : nat),
         M3 [i ← N] [(i + j) ← P] = M3 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM4 : forall (N P : Term) (i j : nat),
         M4 [i ← N] [(i + j) ← P] = M4 [(S (i + j)) ← P] [i ← N [j ← P]]
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   M1 [i ← N] [(i + j) ← P] ·( M2 [i ← N] [(i + j) ← P],
   M3 [(S i) ← N] [(S (i + j)) ← P])M4 [i ← N] [(i + j) ← P] =
   M1 [(S (i + j)) ← P] [i ← N [j ← P]]
   ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
   M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
   M4 [(S (i + j)) ← P] [i ← N [j ← P]]

subgoal 2 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 3 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


rewrite IHM1; rewrite IHM4; intuition.
3 subgoals, subgoal 1 (ID 6310)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N P : Term) (i j : nat),
         M1 [i ← N] [(i + j) ← P] = M1 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM2 : forall (N P : Term) (i j : nat),
         M2 [i ← N] [(i + j) ← P] = M2 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM3 : forall (N P : Term) (i j : nat),
         M3 [i ← N] [(i + j) ← P] = M3 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM4 : forall (N P : Term) (i j : nat),
         M4 [i ← N] [(i + j) ← P] = M4 [(S (i + j)) ← P] [i ← N [j ← P]]
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   M1 [(S (i + j)) ← P] [i ← N [j ← P]] ·( M2 [i ← N] [(i + j) ← P],
   M3 [(S i) ← N] [(S (i + j)) ← P])M4 [(S (i + j)) ← P] [i ← N [j ← P]] =
   M1 [(S (i + j)) ← P] [i ← N [j ← P]]
   ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
   M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
   M4 [(S (i + j)) ← P] [i ← N [j ← P]]

subgoal 2 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 3 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite IHM2; intuition.
3 subgoals, subgoal 1 (ID 6327)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N P : Term) (i j : nat),
         M1 [i ← N] [(i + j) ← P] = M1 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM2 : forall (N P : Term) (i j : nat),
         M2 [i ← N] [(i + j) ← P] = M2 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM3 : forall (N P : Term) (i j : nat),
         M3 [i ← N] [(i + j) ← P] = M3 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM4 : forall (N P : Term) (i j : nat),
         M4 [i ← N] [(i + j) ← P] = M4 [(S (i + j)) ← P] [i ← N [j ← P]]
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   M1 [(S (i + j)) ← P] [i ← N [j ← P]]
   ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]], M3 [(S i) ← N] [(S (i + j)) ← P])
   M4 [(S (i + j)) ← P] [i ← N [j ← P]] =
   M1 [(S (i + j)) ← P] [i ← N [j ← P]]
   ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
   M3 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]])
   M4 [(S (i + j)) ← P] [i ← N [j ← P]]

subgoal 2 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 3 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


replace (S(S(i+j))) with (S((S i)+ j)) by intuition.
3 subgoals, subgoal 1 (ID 6347)
  
  M1 : Term
  M2 : Term
  M3 : Term
  M4 : Term
  IHM1 : forall (N P : Term) (i j : nat),
         M1 [i ← N] [(i + j) ← P] = M1 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM2 : forall (N P : Term) (i j : nat),
         M2 [i ← N] [(i + j) ← P] = M2 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM3 : forall (N P : Term) (i j : nat),
         M3 [i ← N] [(i + j) ← P] = M3 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM4 : forall (N P : Term) (i j : nat),
         M4 [i ← N] [(i + j) ← P] = M4 [(S (i + j)) ← P] [i ← N [j ← P]]
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   M1 [(S (i + j)) ← P] [i ← N [j ← P]]
   ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]], M3 [(S i) ← N] [(S (i + j)) ← P])
   M4 [(S (i + j)) ← P] [i ← N [j ← P]] =
   M1 [(S (i + j)) ← P] [i ← N [j ← P]]
   ·( M2 [(S (i + j)) ← P] [i ← N [j ← P]],
   M3 [(S (S i + j)) ← P] [(S i) ← N [j ← P]])
   M4 [(S (i + j)) ← P] [i ← N [j ← P]]

subgoal 2 (ID 5581) is:
 Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
 Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
subgoal 3 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)

rewrite <- IHM3; intuition.
2 subgoals, subgoal 1 (ID 5581)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N P : Term) (i j : nat),
         M1 [i ← N] [(i + j) ← P] = M1 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM2 : forall (N P : Term) (i j : nat),
         M2 [i ← N] [(i + j) ← P] = M2 [(S (i + j)) ← P] [i ← N [j ← P]]
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   Π (M1 [i ← N] [(i + j) ← P]), M2 [(S i) ← N] [(S (i + j)) ← P] =
   Π (M1 [(S (i + j)) ← P] [i ← N [j ← P]]),
   M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]

subgoal 2 (ID 5582) is:
 λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
 λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
 M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]
(dependent evars:)


rewrite IHM1; replace (S(S(i+j))) with (S((S i)+ j)) by intuition;
  rewrite <- (IHM2 N P (S i)); replace (S(i+j)) with ((S i)+ j) by intuition; intuition.
1 subgoals, subgoal 1 (ID 5582)
  
  M1 : Term
  M2 : Term
  IHM1 : forall (N P : Term) (i j : nat),
         M1 [i ← N] [(i + j) ← P] = M1 [(S (i + j)) ← P] [i ← N [j ← P]]
  IHM2 : forall (N P : Term) (i j : nat),
         M2 [i ← N] [(i + j) ← P] = M2 [(S (i + j)) ← P] [i ← N [j ← P]]
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   λ [M1 [i ← N] [(i + j) ← P]], M2 [(S i) ← N] [(S (i + j)) ← P] =
   λ [M1 [(S (i + j)) ← P] [i ← N [j ← P]]],
   M2 [(S (S (i + j))) ← P] [(S i) ← N [j ← P]]

(dependent evars:)


rewrite IHM1; replace (S(S(i+j))) with (S((S i)+j)) by intuition;
  rewrite <- (IHM2 N P (S i)); replace (S(i+j)) with ((S i)+ j) by intuition; intuition.
No more subgoals.
(dependent evars:)


Qed.
substP4 is defined



Lemma subst_travers :
 forall M N P n, (M [← N]) [n P] = (M [n+1 P])[← N[n P]].
1 subgoals, subgoal 1 (ID 6387)
  
  ============================
   forall (M N P : Term) (n : nat),
   M [ ← N] [n ← P] = (M [(n + 1) ← P]) [ ← N [n ← P]]

(dependent evars:)


intros.
1 subgoals, subgoal 1 (ID 6391)
  
  M : Term
  N : Term
  P : Term
  n : nat
  ============================
   M [ ← N] [n ← P] = (M [(n + 1) ← P]) [ ← N [n ← P]]

(dependent evars:)


rewrite plus_comm.
1 subgoals, subgoal 1 (ID 6392)
  
  M : Term
  N : Term
  P : Term
  n : nat
  ============================
   M [ ← N] [n ← P] = (M [(1 + n) ← P]) [ ← N [n ← P]]

(dependent evars:)

change n with (O+n).
1 subgoals, subgoal 1 (ID 6394)
  
  M : Term
  N : Term
  P : Term
  n : nat
  ============================
   M [ ← N] [(0 + n) ← P] = (M [(1 + (0 + n)) ← P]) [ ← N [(0 + n) ← P]]

(dependent evars:)

apply substP4.
No more subgoals.
(dependent evars:)


Qed.
subst_travers is defined



End term_mod.
Module Type term_mod is defined



Index
This page has been generated by coqdoc