Library ut_term

Term definition for PTS and de Bruijn manipulation .

Usual Term syntax .

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.


Module Type ut_term_mod (X: term_sig).
Interactive Module Type ut_term_mod started


  Import X.

Term syntax:
Inductive Term : Set:=
 | Var : Vars -> Term
 | Sort : Sorts -> Term
 | App : 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



Notation "x · y" := (App x y) (at level 15, left associativity) : UT_scope.

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

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

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


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



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


Delimit Scope UT_scope with UT.


Open Scope UT_scope.


In order to deal with variable bindings and captures, we need a lift function to deal with free and bounded variables.
M n # m recursivly add n to all variables that are above m in M.
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 · N => App (M n # 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) : UT_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) : UT_scope.


Some basic properties of the lift function. That is everything we will ever need to handle de Bruijn indexes

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 213)
  
  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 301) is:
 M1 · M2 = N1 · N2
subgoal 3 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 4 (ID 417) 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 909)
  
  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 918) is:
 #v = #(n + v)
subgoal 3 (ID 924) is:
 #(n + v0) = #v0
subgoal 4 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 5 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 6 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


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

subgoal 2 (ID 924) is:
 #(n + v0) = #v0
subgoal 3 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 4 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 5 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


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

subgoal 2 (ID 924) is:
 #(n + v0) = #v0
subgoal 3 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 4 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 5 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

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

subgoal 2 (ID 999) is:
 v < m
subgoal 3 (ID 924) is:
 #(n + v0) = #v0
subgoal 4 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 5 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 6 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

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

subgoal 2 (ID 924) is:
 #(n + v0) = #v0
subgoal 3 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 4 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 5 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

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

subgoal 2 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 3 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 4 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)


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

subgoal 2 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 3 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 4 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

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

subgoal 2 (ID 1039) is:
 m <= v0
subgoal 3 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 4 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 5 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

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

subgoal 2 (ID 301) is:
 M1 · M2 = N1 · N2
subgoal 3 (ID 359) is:
 Π (M1), M2 = Π (N1), N2
subgoal 4 (ID 417) is:
 λ [M1], M2 = λ [N1], N2
(dependent evars:)

trivial.
3 subgoals, subgoal 1 (ID 301)
  
  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 # m = N1 ↑ n # m · N2 ↑ n # m
  ============================
   M1 · M2 = N1 · N2

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


injection H; intros; rewrite (IHM1 N1 n m H1); rewrite (IHM2 N2 n m H0); reflexivity.
2 subgoals, subgoal 1 (ID 359)
  
  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 417) 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 417)
  
  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 1119)
  
  ============================
   forall (M : Term) (n : nat), M ↑ 0 # n = M

(dependent evars:)


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

subgoal 2 (ID 1154) is:
 !s = !s
subgoal 3 (ID 1155) is:
 M1 ↑ 0 # n · M2 ↑ 0 # n = M1 · M2
subgoal 4 (ID 1156) is:
 Π (M1 ↑ 0 # n), M2 ↑ 0 # (S n) = Π (M1), M2
subgoal 5 (ID 1157) is:
 λ [M1 ↑ 0 # n], M2 ↑ 0 # (S n) = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 1155) is:
 M1 ↑ 0 # n · M2 ↑ 0 # n = M1 · M2
subgoal 3 (ID 1156) is:
 Π (M1 ↑ 0 # n), M2 ↑ 0 # (S n) = Π (M1), M2
subgoal 4 (ID 1157) is:
 λ [M1 ↑ 0 # n], M2 ↑ 0 # (S n) = λ [M1], M2
(dependent evars:)


reflexivity.
3 subgoals, subgoal 1 (ID 1155)
  
  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 # n = M1 · M2

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


rewrite IHM1; rewrite IHM2; reflexivity.
2 subgoals, subgoal 1 (ID 1156)
  
  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 1157) is:
 λ [M1 ↑ 0 # n], M2 ↑ 0 # (S n) = λ [M1], M2
(dependent evars:)


rewrite IHM1; rewrite IHM2; reflexivity.
1 subgoals, subgoal 1 (ID 1157)
  
  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 1182)
  
  ============================
   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 1189)
  
  ============================
   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 1233)
  
  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 1234) is:
 !s = !s
subgoal 3 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 4 (ID 1236) 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 1237) 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 1248)
  
  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 1249) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 3 (ID 1234) is:
 !s = !s
subgoal 4 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 5 (ID 1236) 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 1237) 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 1260)
  
  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 1261) is:
 #(j + v) = #(j + k + v)
subgoal 3 (ID 1249) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 4 (ID 1234) is:
 !s = !s
subgoal 5 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 6 (ID 1236) 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 1237) 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 1262)
  
  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 1261) is:
 #(j + v) = #(j + k + v)
subgoal 3 (ID 1249) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 4 (ID 1234) is:
 !s = !s
subgoal 5 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 6 (ID 1236) 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 1237) 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 1266)
  
  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 1261) is:
 #(j + v) = #(j + k + v)
subgoal 3 (ID 1249) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 4 (ID 1234) is:
 !s = !s
subgoal 5 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 6 (ID 1236) 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 1237) 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 1261)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  g : j + i > j + v
  ============================
   #(j + v) = #(j + k + v)

subgoal 2 (ID 1249) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 3 (ID 1234) is:
 !s = !s
subgoal 4 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 5 (ID 1236) 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 1237) 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 1269)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  g : i > v
  ============================
   #(j + v) = #(j + k + v)

subgoal 2 (ID 1249) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 3 (ID 1234) is:
 !s = !s
subgoal 4 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 5 (ID 1236) 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 1237) 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 1270)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  l : i <= v
  g : i > v
  ============================
   v < v

subgoal 2 (ID 1249) is:
 (if le_gt_dec (j + i) v then #(k + v) else #v) = #v
subgoal 3 (ID 1234) is:
 !s = !s
subgoal 4 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 5 (ID 1236) 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 1237) 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 1249)
  
  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 1234) is:
 !s = !s
subgoal 3 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 4 (ID 1236) 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 1237) 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 1282)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  g : i > v
  l : j + i <= v
  ============================
   #(k + v) = #v

subgoal 2 (ID 1234) is:
 !s = !s
subgoal 3 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 4 (ID 1236) 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 1237) 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 1305)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  g : i > v
  l : j + i <= v
  ============================
   v < v

subgoal 2 (ID 1234) is:
 !s = !s
subgoal 3 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 4 (ID 1236) 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 1237) 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 1307)
  
  v : Vars
  i : nat
  j : nat
  k : nat
  g : i > v
  l : j + i <= v
  ============================
   i <= v

subgoal 2 (ID 1234) is:
 !s = !s
subgoal 3 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 4 (ID 1236) 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 1237) 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 1234)
  
  s : Sorts
  i : nat
  j : nat
  k : nat
  ============================
   !s = !s

subgoal 2 (ID 1235) is:
 M1 ↑ j # i ↑ k # (j + i) · M2 ↑ j # i ↑ k # (j + i) =
 M1 ↑ (j + k) # i · M2 ↑ (j + k) # i
subgoal 3 (ID 1236) 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 1237) 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 1235)
  
  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 # i ↑ k # (j + i) =
   M1 ↑ (j + k) # i · M2 ↑ (j + k) # i

subgoal 2 (ID 1236) 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 1237) 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;reflexivity.
2 subgoals, subgoal 1 (ID 1236)
  
  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 1237) 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 1237)
  
  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 1396)
  
  ============================
   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 1450)
  
  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 1451) is:
 !s = !s
subgoal 3 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 4 (ID 1453) 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 1454) 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 1473)
  
  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 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1485)
  
  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 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1494)
  
  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 1495) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 5 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 6 (ID 1451) is:
 !s = !s
subgoal 7 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 8 (ID 1453) 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 1454) 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 1504)
  
  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 1505) is:
 #(k + (j + v)) = #(k + v)
subgoal 3 (ID 1495) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 6 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 7 (ID 1451) is:
 !s = !s
subgoal 8 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 9 (ID 1453) 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 1454) 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 1507)
  
  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 1505) is:
 #(k + (j + v)) = #(k + v)
subgoal 3 (ID 1495) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 6 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 7 (ID 1451) is:
 !s = !s
subgoal 8 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 9 (ID 1453) 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 1454) 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 1511)
  
  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 1505) is:
 #(k + (j + v)) = #(k + v)
subgoal 3 (ID 1495) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 6 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 7 (ID 1451) is:
 !s = !s
subgoal 8 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 9 (ID 1453) 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 1454) 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 1505)
  
  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 1495) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 5 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 6 (ID 1451) is:
 !s = !s
subgoal 7 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 8 (ID 1453) 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 1454) 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 1513)
  
  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 1495) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 5 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 6 (ID 1451) is:
 !s = !s
subgoal 7 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 8 (ID 1453) 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 1454) 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 1514)
  
  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 1515) is:
 i <= v
subgoal 3 (ID 1495) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 6 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 7 (ID 1451) is:
 !s = !s
subgoal 8 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 9 (ID 1453) 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 1454) 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 1515)
  
  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 1495) is:
 #(j + v) = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 5 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 6 (ID 1451) is:
 !s = !s
subgoal 7 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 8 (ID 1453) 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 1454) 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 1495)
  
  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 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1554)
  
  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 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1555)
  
  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 1474) is:
 #(j + v) ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1474)
  
  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 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1558)
  
  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 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1567)
  
  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 1568) is:
 #(j + v) = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1570)
  
  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 1568) is:
 #(j + v) = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1571)
  
  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 1568) is:
 #(j + v) = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1568)
  
  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 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1582)
  
  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 1583) is:
 #(j + v) = #v
subgoal 3 (ID 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1583)
  
  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 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1584)
  
  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 1483) is:
 #v ↑ k # (j + n) = #(k + v) ↑ j # i
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1483)
  
  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 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1587)
  
  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 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1596)
  
  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 1597) is:
 #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1598)
  
  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 1597) is:
 #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1599)
  
  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 1600) is:
 i <= n
subgoal 3 (ID 1597) is:
 #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 4 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 5 (ID 1451) is:
 !s = !s
subgoal 6 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 7 (ID 1453) 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 1454) 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 1600)
  
  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 1597) is:
 #v = (if le_gt_dec i (k + v) then #(j + (k + v)) else #(k + v))
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1597)
  
  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 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1603)
  
  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 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1604)
  
  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 1605) is:
 n <= v
subgoal 3 (ID 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1605)
  
  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 1484) is:
 #v ↑ k # (j + n) = #v ↑ j # i
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1484)
  
  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 1451) is:
 !s = !s
subgoal 3 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 4 (ID 1453) 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 1454) 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 1608)
  
  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 1451) is:
 !s = !s
subgoal 3 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 4 (ID 1453) 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 1454) 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 1617)
  
  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 1618) is:
 #v = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1619)
  
  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 1618) is:
 #v = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1620)
  
  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 1621) is:
 n <= v
subgoal 3 (ID 1618) is:
 #v = (if le_gt_dec i v then #(j + v) else #v)
subgoal 4 (ID 1451) is:
 !s = !s
subgoal 5 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 6 (ID 1453) 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 1454) 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 1621)
  
  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 1618) is:
 #v = (if le_gt_dec i v then #(j + v) else #v)
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1618)
  
  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 1451) is:
 !s = !s
subgoal 3 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 4 (ID 1453) 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 1454) 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 1656)
  
  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 1657) is:
 #v = #v
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1658)
  
  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 1657) is:
 #v = #v
subgoal 3 (ID 1451) is:
 !s = !s
subgoal 4 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 5 (ID 1453) 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 1454) 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 1657)
  
  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 1451) is:
 !s = !s
subgoal 3 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 4 (ID 1453) 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 1454) 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 1451)
  
  s : Sorts
  i : nat
  j : nat
  k : nat
  n : nat
  H : i <= n
  ============================
   !s = !s

subgoal 2 (ID 1452) is:
 M1 ↑ j # i ↑ k # (j + n) · M2 ↑ j # i ↑ k # (j + n) =
 M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i
subgoal 3 (ID 1453) 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 1454) 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 1452)
  
  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 # i ↑ k # (j + n) =
   M1 ↑ k # n ↑ j # i · M2 ↑ k # n ↑ j # i

subgoal 2 (ID 1453) 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 1454) 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; rewrite IHM2; intuition; reflexivity.
2 subgoals, subgoal 1 (ID 1453)
  
  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 1454) 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 1679)
  
  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 1454) 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 1697)
  
  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 1454) 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 1454)
  
  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 1729)
  
  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 1747)
  
  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 1785)
  
  ============================
   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 1844)
  
  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 1845) is:
 !s = !s
subgoal 3 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 4 (ID 1847) 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 1848) 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 1859)
  
  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 1860) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 3 (ID 1845) is:
 !s = !s
subgoal 4 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 5 (ID 1847) 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 1848) 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 1870)
  
  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 1860) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 3 (ID 1845) is:
 !s = !s
subgoal 4 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 5 (ID 1847) 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 1848) 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 1918)
  
  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 1860) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 3 (ID 1845) is:
 !s = !s
subgoal 4 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 5 (ID 1847) 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 1848) 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 1919)
  
  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 1920) is:
 k <= i + n
subgoal 3 (ID 1860) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 4 (ID 1845) is:
 !s = !s
subgoal 5 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 6 (ID 1847) 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 1848) 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 1921)
  
  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 1922) is:
 n + v < k
subgoal 3 (ID 1920) is:
 k <= i + n
subgoal 4 (ID 1860) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 5 (ID 1845) is:
 !s = !s
subgoal 6 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 7 (ID 1847) 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 1848) 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 1923)
  
  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 1922) is:
 n + v < k
subgoal 3 (ID 1920) is:
 k <= i + n
subgoal 4 (ID 1860) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 5 (ID 1845) is:
 !s = !s
subgoal 6 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 7 (ID 1847) 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 1848) 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 1922)
  
  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 1920) is:
 k <= i + n
subgoal 3 (ID 1860) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 4 (ID 1845) is:
 !s = !s
subgoal 5 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 6 (ID 1847) 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 1848) 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 1920)
  
  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 1860) is:
 (if le_gt_dec k v then #(j + v) else #v) = #v
subgoal 3 (ID 1845) is:
 !s = !s
subgoal 4 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 5 (ID 1847) 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 1848) 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 1860)
  
  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 1845) is:
 !s = !s
subgoal 3 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 4 (ID 1847) 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 1848) 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 1950)
  
  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 1845) is:
 !s = !s
subgoal 3 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 4 (ID 1847) 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 1848) 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 1976)
  
  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 1845) is:
 !s = !s
subgoal 3 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 4 (ID 1847) 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 1848) 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 1977)
  
  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 1978) is:
 i <= k
subgoal 3 (ID 1845) is:
 !s = !s
subgoal 4 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 5 (ID 1847) 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 1848) 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 1979)
  
  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 1980) is:
 v < i
subgoal 3 (ID 1978) is:
 i <= k
subgoal 4 (ID 1845) is:
 !s = !s
subgoal 5 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 6 (ID 1847) 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 1848) 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 1980)
  
  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 1978) is:
 i <= k
subgoal 3 (ID 1845) is:
 !s = !s
subgoal 4 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 5 (ID 1847) 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 1848) 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 1978)
  
  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 1845) is:
 !s = !s
subgoal 3 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 4 (ID 1847) 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 1848) 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 1845)
  
  s : Sorts
  i : nat
  k : nat
  j : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   !s = !s

subgoal 2 (ID 1846) is:
 M1 ↑ n # i ↑ j # k · M2 ↑ n # i ↑ j # k =
 M1 ↑ (j + n) # i · M2 ↑ (j + n) # i
subgoal 3 (ID 1847) 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 1848) 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 1846)
  
  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 # i ↑ j # k =
   M1 ↑ (j + n) # i · M2 ↑ (j + n) # i

subgoal 2 (ID 1847) 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 1848) 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 1847)
  
  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 1848) 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 2022)
  
  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 1848) 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 2225)
  
  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 1848) 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 1848)
  
  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 2258)
  
  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 2461)
  
  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 2479)
  
  ============================
   forall (M : Term) (n m : nat), M ↑ m ↑ n = M ↑ (n + m)

(dependent evars:)


intros.
1 subgoals, subgoal 1 (ID 2482)
  
  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



We will consider the usual implicit substitution without variable capture (this is where the lift operator comes in handy). M [ n N ] replace the variable n in M by the term N.
Reserved Notation "t [ x ← u ]" (at level 5, x 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 · N => (M [ 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) : UT_scope.
subst_rec is recursively defined (decreasing on 2nd argument)



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


Some basic properties of the substitution function. Again, we will only need a few functions to deal with indexes.

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 2505)
  
  ============================
   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 2537)
  
  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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2553) 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 2554)
  
  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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2553) 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 2557)
  
  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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2553) 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 2571)
  
  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 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2582)
  
  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 2583) is:
 #v ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2584)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  l0 : S (j + i) <= v
  ============================
   v < v

subgoal 2 (ID 2583) is:
 #v ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2586)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  k : nat
  l : v < j
  l0 : S (j + i) <= v
  ============================
   j <= v

subgoal 2 (ID 2583) is:
 #v ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2583)
  
  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 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2621)
  
  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 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2630)
  
  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 2631) 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 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2632)
  
  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 2631) 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 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2634)
  
  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 2631) 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 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2631)
  
  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 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2678)
  
  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 2679) is:
 #v = N ↑ k # i ↑ j
subgoal 3 (ID 2680) is:
 #v = #(v - 1)
subgoal 4 (ID 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 2553) 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 2679)
  
  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 2680) is:
 #v = #(v - 1)
subgoal 3 (ID 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2687)
  
  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 2680) is:
 #v = #(v - 1)
subgoal 3 (ID 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2680)
  
  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 2572) 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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2572)
  
  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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2700)
  
  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 2701) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2706)
  
  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 2701) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2707)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : S (j + i) <= j
  ============================
   j < j

subgoal 2 (ID 2701) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2708)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : S (j + i) <= j
  ============================
   j < S (j + i)

subgoal 2 (ID 2709) is:
 S (j + i) <= j
subgoal 3 (ID 2701) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2709)
  
  N : Term
  i : nat
  j : nat
  k : nat
  l : S (j + i) <= j
  ============================
   S (j + i) <= j

subgoal 2 (ID 2701) is:
 N ↑ j ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2701)
  
  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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2749)
  
  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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2763)
  
  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 2764) is:
 N ↑ j ↑ k # (j + i) = N ↑ k # i ↑ j
subgoal 3 (ID 2765) is:
 N ↑ j ↑ k # (j + i) = #(v - 1)
subgoal 4 (ID 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2771)
  
  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 2764) is:
 N ↑ j ↑ k # (j + i) = N ↑ k # i ↑ j
subgoal 3 (ID 2765) is:
 N ↑ j ↑ k # (j + i) = #(v - 1)
subgoal 4 (ID 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2764)
  
  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 2765) is:
 N ↑ j ↑ k # (j + i) = #(v - 1)
subgoal 3 (ID 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2765)
  
  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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2788)
  
  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 2573) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2573)
  
  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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2553) 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 2798)
  
  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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2800)
  
  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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2809)
  
  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 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2824)
  
  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 2825) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 3 (ID 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 4 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 6 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 2553) 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 2827)
  
  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 2825) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 3 (ID 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 4 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 6 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 2553) 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 2828)
  
  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 2829) is:
 v <= j
subgoal 3 (ID 2825) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 4 (ID 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 5 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 7 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 10 (ID 2553) 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 2829)
  
  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 2825) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 3 (ID 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 4 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 6 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 2553) 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 2825)
  
  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 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 3 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2883)
  
  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 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 3 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2884)
  
  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 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 3 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2885)
  
  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 2886) is:
 S (k + v + i) <= v
subgoal 3 (ID 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 4 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 6 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 9 (ID 2553) 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 2886)
  
  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 2826) is:
 #(k + (v - 1)) = #(k + v - 1)
subgoal 3 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2826)
  
  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 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2950)
  
  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 2956) is:
 #(k + (S v - 1)) = #(k + S v - 1)
subgoal 3 (ID 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2956)
  
  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 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2960)
  
  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 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2964)
  
  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 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2979)
  
  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 2810) 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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2810)
  
  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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2980)
  
  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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2981)
  
  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 2982) is:
 S (j + i) <= v
subgoal 3 (ID 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2991)
  
  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 2996) is:
 S v < S (j + i)
subgoal 3 (ID 2982) is:
 S (j + i) <= v
subgoal 4 (ID 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 5 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 2996)
  
  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 2982) is:
 S (j + i) <= v
subgoal 3 (ID 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 3000)
  
  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 2982) is:
 S (j + i) <= v
subgoal 3 (ID 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 3001)
  
  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 2982) is:
 S (j + i) <= v
subgoal 3 (ID 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 2982)
  
  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 2799) is:
 #(v - 1) ↑ k # (j + i) = #v [j ← N ↑ k # i]
subgoal 3 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 2799)
  
  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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2553) 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 3014)
  
  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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2553) 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 3023)
  
  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 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3038)
  
  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 3039) is:
 #(k + (v - 1)) = N ↑ k # i ↑ j
subgoal 3 (ID 3040) is:
 #(k + (v - 1)) = #(v - 1)
subgoal 4 (ID 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 8 (ID 2553) 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 3039)
  
  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 3040) is:
 #(k + (v - 1)) = #(v - 1)
subgoal 3 (ID 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 3050)
  
  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 3040) is:
 #(k + (v - 1)) = #(v - 1)
subgoal 3 (ID 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 3040)
  
  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 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3052)
  
  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 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3053)
  
  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 3054) is:
 S (j + i) <= v
subgoal 3 (ID 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 3054)
  
  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 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3064)
  
  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 3070) is:
 S (j + i) <= S v
subgoal 3 (ID 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 3070)
  
  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 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3074)
  
  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 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3075)
  
  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 3024) 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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3024)
  
  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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2553) 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 3101)
  
  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 3102) is:
 #(v - 1) = N ↑ k # i ↑ j
subgoal 3 (ID 3103) is:
 #(v - 1) = #(v - 1)
subgoal 4 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 7 (ID 2553) 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 3102)
  
  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 3103) is:
 #(v - 1) = #(v - 1)
subgoal 3 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3113)
  
  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 3103) is:
 #(v - 1) = #(v - 1)
subgoal 3 (ID 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 6 (ID 2553) 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 3103)
  
  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 2541) is:
 !s [j ← N] ↑ k # (j + i) = !s ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 5 (ID 2553) 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 2541)
  
  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 2545) is:
 (M1 · M2) [j ← N] ↑ k # (j + i) =
 (M1 · M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 4 (ID 2553) 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 2545)
  
  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 2549) is:
 (Π (M1), M2) [j ← N] ↑ k # (j + i) =
 (Π (M1), M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
subgoal 3 (ID 2553) is:
 (λ [M1], M2) [j ← N] ↑ k # (j + i) =
 (λ [M1], M2) ↑ k # (S (j + i)) [j ← N ↑ k # i]
(dependent evars:)


simpl; rewrite IHM1; intuition; rewrite IHM2; intuition.
2 subgoals, subgoal 1 (ID 2549)
  
  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 2553) 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 3133)
  
  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 2553) 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 3149)
  
  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 2553) 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 2553)
  
  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 3155)
  
  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 3171)
  
  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 3182)
  
  ============================
   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 3236)
  
  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 3237) is:
 !s = !s
subgoal 3 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 4 (ID 3239) 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 3240) 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 3264)
  
  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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3283)
  
  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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3292)
  
  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 3293) 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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3237) is:
 !s = !s
subgoal 9 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 10 (ID 3239) 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 3240) 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 3307)
  
  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 3308) is:
 N ↑ (j + n) = #(j + v)
subgoal 3 (ID 3309) is:
 #(j + v - 1) = #(j + v)
subgoal 4 (ID 3293) 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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 8 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 9 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 10 (ID 3237) is:
 !s = !s
subgoal 11 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 12 (ID 3239) 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 3240) 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 3308)
  
  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 3309) is:
 #(j + v - 1) = #(j + v)
subgoal 3 (ID 3293) 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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 7 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 8 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 9 (ID 3237) is:
 !s = !s
subgoal 10 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 11 (ID 3239) 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 3240) 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 3312)
  
  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 3309) is:
 #(j + v - 1) = #(j + v)
subgoal 3 (ID 3293) 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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 7 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 8 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 9 (ID 3237) is:
 !s = !s
subgoal 10 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 11 (ID 3239) 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 3240) 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 3319)
  
  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 3309) is:
 #(j + v - 1) = #(j + v)
subgoal 3 (ID 3293) 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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 7 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 8 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 9 (ID 3237) is:
 !s = !s
subgoal 10 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 11 (ID 3239) 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 3240) 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 3309)
  
  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 3293) 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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3237) is:
 !s = !s
subgoal 9 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 10 (ID 3239) 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 3240) 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 3322)
  
  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 3293) 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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3237) is:
 !s = !s
subgoal 9 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 10 (ID 3239) 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 3240) 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 3293)
  
  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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3325)
  
  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 3265) is:
 #(j + v) [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3265)
  
  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 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3332)
  
  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 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3333)
  
  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 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3347)
  
  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 3348) is:
 N ↑ (j + n) = N ↑ n ↑ j # i
subgoal 3 (ID 3349) is:
 #(j + n - 1) = N ↑ n ↑ j # i
subgoal 4 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3237) is:
 !s = !s
subgoal 9 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 10 (ID 3239) 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 3240) 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 3348)
  
  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 3349) is:
 #(j + n - 1) = N ↑ n ↑ j # i
subgoal 3 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3353)
  
  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 3349) is:
 #(j + n - 1) = N ↑ n ↑ j # i
subgoal 3 (ID 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3349)
  
  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 3266) is:
 #(j + v) [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3266)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3366)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3375)
  
  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 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3390)
  
  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 3391) is:
 N ↑ (j + n) = #(j + (v - 1))
subgoal 3 (ID 3392) is:
 #(j + v - 1) = #(j + (v - 1))
subgoal 4 (ID 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3237) is:
 !s = !s
subgoal 9 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 10 (ID 3239) 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 3240) 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 3394)
  
  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 3391) is:
 N ↑ (j + n) = #(j + (v - 1))
subgoal 3 (ID 3392) is:
 #(j + v - 1) = #(j + (v - 1))
subgoal 4 (ID 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 6 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 7 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 8 (ID 3237) is:
 !s = !s
subgoal 9 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 10 (ID 3239) 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 3240) 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 3391)
  
  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 3392) is:
 #(j + v - 1) = #(j + (v - 1))
subgoal 3 (ID 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3405)
  
  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 3392) is:
 #(j + v - 1) = #(j + (v - 1))
subgoal 3 (ID 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3392)
  
  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 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3416)
  
  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 3422) is:
 #(j + S v - 1) = #(j + (S v - 1))
subgoal 3 (ID 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 5 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 6 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 7 (ID 3237) is:
 !s = !s
subgoal 8 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 9 (ID 3239) 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 3240) 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 3422)
  
  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 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3426)
  
  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 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3430)
  
  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 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3446)
  
  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 3376) 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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3376)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3447)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3448)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3450)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3452)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3453)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3455)
  
  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 3280) is:
 #v [(j + n) ← N] = #v ↑ j # i
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3280)
  
  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 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3237) is:
 !s = !s
subgoal 5 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 6 (ID 3239) 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 3240) 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 3458)
  
  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 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3237) is:
 !s = !s
subgoal 5 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 6 (ID 3239) 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 3240) 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 3467)
  
  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 3468) 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 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3469)
  
  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 3468) 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 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3468)
  
  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 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3237) is:
 !s = !s
subgoal 5 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 6 (ID 3239) 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 3240) 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 3485)
  
  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 3486) is:
 N ↑ (j + n) = #v
subgoal 3 (ID 3487) is:
 #(v - 1) = #v
subgoal 4 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 5 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 6 (ID 3237) is:
 !s = !s
subgoal 7 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 8 (ID 3239) 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 3240) 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 3486)
  
  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 3487) is:
 #(v - 1) = #v
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3495)
  
  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 3487) is:
 #(v - 1) = #v
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3496)
  
  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 3487) is:
 #(v - 1) = #v
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3487)
  
  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 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3237) is:
 !s = !s
subgoal 5 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 6 (ID 3239) 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 3240) 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 3508)
  
  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 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3237) is:
 !s = !s
subgoal 5 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 6 (ID 3239) 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 3240) 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 3509)
  
  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 3510) is:
 v < n
subgoal 3 (ID 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 4 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 5 (ID 3237) is:
 !s = !s
subgoal 6 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 7 (ID 3239) 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 3240) 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 3510)
  
  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 3281) is:
 #v [(j + n) ← N] = N ↑ n ↑ j # i
subgoal 3 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 4 (ID 3237) is:
 !s = !s
subgoal 5 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 6 (ID 3239) 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 3240) 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 3281)
  
  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 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3237) is:
 !s = !s
subgoal 4 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 5 (ID 3239) 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 3240) 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 3524)
  
  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 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3237) is:
 !s = !s
subgoal 4 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 5 (ID 3239) 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 3240) 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 3529)
  
  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 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3237) is:
 !s = !s
subgoal 4 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 5 (ID 3239) 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 3240) 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 3530)
  
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > n
  ============================
   n < n

subgoal 2 (ID 3282) is:
 #v [(j + n) ← N] = #(v - 1) ↑ j # i
subgoal 3 (ID 3237) is:
 !s = !s
subgoal 4 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 5 (ID 3239) 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 3240) 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 3282)
  
  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 3237) is:
 !s = !s
subgoal 3 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 4 (ID 3239) 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 3240) 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 3533)
  
  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 3237) is:
 !s = !s
subgoal 3 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 4 (ID 3239) 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 3240) 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 3534)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : n < v
  ============================
   n < n

subgoal 2 (ID 3237) is:
 !s = !s
subgoal 3 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 4 (ID 3239) 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 3240) 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 3536)
  
  v : Vars
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  g : i > v
  l : n < v
  ============================
   v <= n

subgoal 2 (ID 3237) is:
 !s = !s
subgoal 3 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 4 (ID 3239) 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 3240) 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 3237)
  
  s : Sorts
  N : Term
  i : nat
  j : nat
  n : nat
  H : i <= n
  ============================
   !s = !s

subgoal 2 (ID 3238) is:
 M1 ↑ j # i [(j + n) ← N] · M2 ↑ j # i [(j + n) ← N] =
 M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i
subgoal 3 (ID 3239) 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 3240) 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 3238)
  
  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 # i [(j + n) ← N] =
   M1 [n ← N] ↑ j # i · M2 [n ← N] ↑ j # i

subgoal 2 (ID 3239) 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 3240) 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; intuition.
2 subgoals, subgoal 1 (ID 3239)
  
  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 3240) 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.
2 subgoals, subgoal 1 (ID 3602)
  
  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 [n ← N] ↑ j # i), M2 ↑ j # (S i) [(S (j + n)) ← N] =
   Π (M1 [n ← N] ↑ j # i), M2 ↑ j # (S i) [(j + S n) ← N]

subgoal 2 (ID 3240) 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 3632)
  
  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 [n ← N] ↑ j # i), M2 ↑ j # (S i) [(j + S n) ← N] =
   Π (M1 [n ← N] ↑ j # i), M2 ↑ j # (S i) [(j + S n) ← N]

subgoal 2 (ID 3240) 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.
1 subgoals, subgoal 1 (ID 3240)
  
  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:)


rewrite IHM1; intuition;
rewrite <- (IHM2 N (S i) j (S n)); intuition.
1 subgoals, subgoal 1 (ID 3665)
  
  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 [n ← N] ↑ j # i], M2 ↑ j # (S i) [(S (j + n)) ← N] =
   λ [M1 [n ← N] ↑ j # i], M2 ↑ j # (S i) [(j + S n) ← N]

(dependent evars:)


replace (S(j+n)) with (j+(S n)) by intuition.
1 subgoals, subgoal 1 (ID 3695)
  
  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 [n ← N] ↑ j # i], M2 ↑ j # (S i) [(j + S n) ← N] =
   λ [M1 [n ← N] ↑ j # i], M2 ↑ j # (S i) [(j + S n) ← N]

(dependent evars:)


reflexivity.
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 3719)
  
  ============================
   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 3778)
  
  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 3779) is:
 !s = !s
subgoal 3 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 4 (ID 3781) 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 3782) 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 3791)
  
  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 3792) is:
 #v [k ← N] = #v
subgoal 3 (ID 3779) is:
 !s = !s
subgoal 4 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 5 (ID 3781) 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 3782) 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 3793)
  
  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 3792) is:
 #v [k ← N] = #v
subgoal 3 (ID 3779) is:
 !s = !s
subgoal 4 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 5 (ID 3781) 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 3782) 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 3807)
  
  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 3808) is:
 N ↑ k = #(n + v)
subgoal 3 (ID 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 4 (ID 3792) is:
 #v [k ← N] = #v
subgoal 5 (ID 3779) is:
 !s = !s
subgoal 6 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 7 (ID 3781) 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 3782) 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 3810)
  
  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 3808) is:
 N ↑ k = #(n + v)
subgoal 3 (ID 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 4 (ID 3792) is:
 #v [k ← N] = #v
subgoal 5 (ID 3779) is:
 !s = !s
subgoal 6 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 7 (ID 3781) 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 3782) 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 3811)
  
  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 3808) is:
 N ↑ k = #(n + v)
subgoal 3 (ID 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 4 (ID 3792) is:
 #v [k ← N] = #v
subgoal 5 (ID 3779) is:
 !s = !s
subgoal 6 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 7 (ID 3781) 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 3782) 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 3869)
  
  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 3870) is:
 v + n < k
subgoal 3 (ID 3808) is:
 N ↑ k = #(n + v)
subgoal 4 (ID 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 5 (ID 3792) is:
 #v [k ← N] = #v
subgoal 6 (ID 3779) is:
 !s = !s
subgoal 7 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 8 (ID 3781) 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 3782) 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 3870)
  
  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 3808) is:
 N ↑ k = #(n + v)
subgoal 3 (ID 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 4 (ID 3792) is:
 #v [k ← N] = #v
subgoal 5 (ID 3779) is:
 !s = !s
subgoal 6 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 7 (ID 3781) 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 3782) 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 3808)
  
  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 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 3792) is:
 #v [k ← N] = #v
subgoal 4 (ID 3779) is:
 !s = !s
subgoal 5 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 6 (ID 3781) 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 3782) 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 3918)
  
  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 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 3792) is:
 #v [k ← N] = #v
subgoal 4 (ID 3779) is:
 !s = !s
subgoal 5 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 6 (ID 3781) 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 3782) 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 3923)
  
  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 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 3792) is:
 #v [k ← N] = #v
subgoal 4 (ID 3779) is:
 !s = !s
subgoal 5 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 6 (ID 3781) 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 3782) 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 3929)
  
  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 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 3792) is:
 #v [k ← N] = #v
subgoal 4 (ID 3779) is:
 !s = !s
subgoal 5 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 6 (ID 3781) 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 3782) 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 3945)
  
  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 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 3792) is:
 #v [k ← N] = #v
subgoal 4 (ID 3779) is:
 !s = !s
subgoal 5 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 6 (ID 3781) 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 3782) 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 3946)
  
  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 3809) is:
 #(S (n + v) - 1) = #(n + v)
subgoal 3 (ID 3792) is:
 #v [k ← N] = #v
subgoal 4 (ID 3779) is:
 !s = !s
subgoal 5 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 6 (ID 3781) 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 3782) 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 3809)
  
  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 3792) is:
 #v [k ← N] = #v
subgoal 3 (ID 3779) is:
 !s = !s
subgoal 4 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 5 (ID 3781) 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 3782) 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 3949)
  
  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 3792) is:
 #v [k ← N] = #v
subgoal 3 (ID 3779) is:
 !s = !s
subgoal 4 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 5 (ID 3781) 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 3782) 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 3950)
  
  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 3792) is:
 #v [k ← N] = #v
subgoal 3 (ID 3779) is:
 !s = !s
subgoal 4 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 5 (ID 3781) 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 3782) 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 3792)
  
  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 3779) is:
 !s = !s
subgoal 3 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 4 (ID 3781) 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 3782) 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 3951)
  
  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 3779) is:
 !s = !s
subgoal 3 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 4 (ID 3781) 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 3782) 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 3965)
  
  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 3966) is:
 N ↑ k = #v
subgoal 3 (ID 3967) is:
 #(v - 1) = #v
subgoal 4 (ID 3779) is:
 !s = !s
subgoal 5 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 6 (ID 3781) 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 3782) 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 3966)
  
  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 3967) is:
 #(v - 1) = #v
subgoal 3 (ID 3779) is:
 !s = !s
subgoal 4 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 5 (ID 3781) 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 3782) 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 3973)
  
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > k
  ============================
   N ↑ k = #k

subgoal 2 (ID 3967) is:
 #(v - 1) = #v
subgoal 3 (ID 3779) is:
 !s = !s
subgoal 4 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 5 (ID 3781) 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 3782) 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 3974)
  
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  g : i > k
  ============================
   i < i

subgoal 2 (ID 3967) is:
 #(v - 1) = #v
subgoal 3 (ID 3779) is:
 !s = !s
subgoal 4 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 5 (ID 3781) 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 3782) 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 3967)
  
  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 3779) is:
 !s = !s
subgoal 3 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 4 (ID 3781) 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 3782) 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 3977)
  
  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 3779) is:
 !s = !s
subgoal 3 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 4 (ID 3781) 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 3782) 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 3979)
  
  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 3779) is:
 !s = !s
subgoal 3 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 4 (ID 3781) 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 3782) 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 3779)
  
  s : Sorts
  N : Term
  i : nat
  k : nat
  n : nat
  H : i <= k
  H0 : k <= i + n
  ============================
   !s = !s

subgoal 2 (ID 3780) is:
 M1 ↑ (S n) # i [k ← N] · M2 ↑ (S n) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i
subgoal 3 (ID 3781) 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 3782) 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 3780)
  
  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) # i [k ← N] = M1 ↑ n # i · M2 ↑ n # i

subgoal 2 (ID 3781) 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 3782) 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; intuition.
2 subgoals, subgoal 1 (ID 3781)
  
  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 3782) 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 4023)
  
  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 3782) 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 4226)
  
  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 3782) 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 3782)
  
  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 4259)
  
  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 4462)
  
  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 4482)
  
  ============================
   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 4531)
  
  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 4532) is:
 !s = !s
subgoal 3 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 4534) 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 4535) 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 4565)
  
  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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 4532) is:
 !s = !s
subgoal 11 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 4534) 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 4535) 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 4600)
  
  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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 4532) is:
 !s = !s
subgoal 11 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 4534) 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 4535) 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 4614)
  
  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 4615) 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 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 10 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 11 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 12 (ID 4532) is:
 !s = !s
subgoal 13 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 14 (ID 4534) 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 4535) 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 4630)
  
  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 4631) is:
 #v = N [j ← P] ↑ i
subgoal 3 (ID 4632) is:
 #v = #(v - 1)
subgoal 4 (ID 4615) 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 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 12 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 13 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 14 (ID 4532) is:
 !s = !s
subgoal 15 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 16 (ID 4534) 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 4535) 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 4631)
  
  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 4632) is:
 #v = #(v - 1)
subgoal 3 (ID 4615) 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 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 11 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 12 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 13 (ID 4532) is:
 !s = !s
subgoal 14 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 15 (ID 4534) 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 4535) 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 4639)
  
  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 4632) is:
 #v = #(v - 1)
subgoal 3 (ID 4615) 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 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 11 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 12 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 13 (ID 4532) is:
 !s = !s
subgoal 14 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 15 (ID 4534) 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 4535) 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 4632)
  
  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 4615) 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 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 10 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 11 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 12 (ID 4532) is:
 !s = !s
subgoal 13 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 14 (ID 4534) 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 4535) 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 4615)
  
  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 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 4532) is:
 !s = !s
subgoal 12 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 13 (ID 4534) 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 4535) 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 4649)
  
  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 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 4532) is:
 !s = !s
subgoal 12 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 13 (ID 4534) 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 4535) 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 4651)
  
  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 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 4532) is:
 !s = !s
subgoal 12 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 13 (ID 4534) 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 4535) 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 4652)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : j + i < i
  l0 : i + j < S (i + j)
  ============================
   i < i

subgoal 2 (ID 4616) 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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 9 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 10 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 11 (ID 4532) is:
 !s = !s
subgoal 12 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 13 (ID 4534) 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 4535) 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 4616)
  
  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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 4532) is:
 !s = !s
subgoal 11 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 4534) 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 4535) 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 4703)
  
  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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 4532) is:
 !s = !s
subgoal 11 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 4534) 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 4535) 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 4704)
  
  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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 4532) is:
 !s = !s
subgoal 11 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 4534) 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 4535) 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 4726)
  
  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 4566) is:
 #v [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 8 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 9 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 10 (ID 4532) is:
 !s = !s
subgoal 11 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 12 (ID 4534) 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 4535) 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 4566)
  
  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 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 4532) is:
 !s = !s
subgoal 10 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 11 (ID 4534) 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 4535) 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 4822)
  
  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 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 4532) is:
 !s = !s
subgoal 10 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 11 (ID 4534) 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 4535) 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 4823)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : S (i + j) < i
  ============================
   i < i

subgoal 2 (ID 4567) is:
 #v [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 4532) is:
 !s = !s
subgoal 10 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 11 (ID 4534) 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 4535) 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 4567)
  
  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 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4532) is:
 !s = !s
subgoal 9 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 4534) 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 4535) 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 4865)
  
  v : Vars
  N : Term
  P : Term
  i : nat
  j : nat
  l : v < i
  l0 : S (i + j) < v
  ============================
   i < i

subgoal 2 (ID 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4532) is:
 !s = !s
subgoal 9 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 4534) 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 4535) 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 4867)
  
  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 4581) is:
 N ↑ i [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4532) is:
 !s = !s
subgoal 9 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 4534) 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 4535) 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 4581)
  
  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 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4532) is:
 !s = !s
subgoal 8 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 4534) 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 4535) 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 4965)
  
  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 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4532) is:
 !s = !s
subgoal 8 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 4534) 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 4535) 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 4970)
  
  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 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4532) is:
 !s = !s
subgoal 8 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 4534) 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 4535) 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 4984)
  
  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 4985) is:
 N ↑ i [(i + j) ← P] = N [j ← P] ↑ i
subgoal 3 (ID 4986) is:
 N ↑ i [(i + j) ← P] = #(i - 1)
subgoal 4 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 7 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 8 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 9 (ID 4532) is:
 !s = !s
subgoal 10 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 11 (ID 4534) 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 4535) 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 4985)
  
  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 4986) is:
 N ↑ i [(i + j) ← P] = #(i - 1)
subgoal 3 (ID 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 6 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4532) is:
 !s = !s
subgoal 9 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 4534) 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 4535) 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 4986)
  
  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 4582) is:
 N ↑ i [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 5 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4532) is:
 !s = !s
subgoal 8 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 4534) 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 4535) 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 4582)
  
  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 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4532) is:
 !s = !s
subgoal 7 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 4534) 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 4535) 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 5001)
  
  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 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4532) is:
 !s = !s
subgoal 7 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 4534) 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 4535) 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 5003)
  
  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 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4532) is:
 !s = !s
subgoal 7 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 4534) 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 4535) 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 5005)
  
  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 4583) is:
 N ↑ i [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 4 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4532) is:
 !s = !s
subgoal 7 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 4534) 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 4535) 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 4583)
  
  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 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 5010)
  
  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 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 5011)
  
  N : Term
  P : Term
  i : nat
  j : nat
  l : S (i + j) < i
  ============================
   i < i

subgoal 2 (ID 4597) is:
 #(v - 1) [(i + j) ← P] = #v [i ← N [j ← P]]
subgoal 3 (ID 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 4597)
  
  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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5039)
  
  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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5053)
  
  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 5054) 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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4532) is:
 !s = !s
subgoal 7 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 4534) 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 4535) 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 5069)
  
  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 5070) is:
 #(v - 1) = N [j ← P] ↑ i
subgoal 3 (ID 5071) is:
 #(v - 1) = #(v - 1)
subgoal 4 (ID 5054) 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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 7 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 8 (ID 4532) is:
 !s = !s
subgoal 9 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 10 (ID 4534) 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 4535) 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 5070)
  
  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 5071) is:
 #(v - 1) = #(v - 1)
subgoal 3 (ID 5054) 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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4532) is:
 !s = !s
subgoal 8 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 4534) 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 4535) 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 5080)
  
  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 5071) is:
 #(v - 1) = #(v - 1)
subgoal 3 (ID 5054) 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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 6 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 7 (ID 4532) is:
 !s = !s
subgoal 8 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 9 (ID 4534) 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 4535) 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 5071)
  
  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 5054) 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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 5 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 6 (ID 4532) is:
 !s = !s
subgoal 7 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 8 (ID 4534) 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 4535) 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 5054)
  
  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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 5083)
  
  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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 5085)
  
  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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 5087)
  
  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 5055) 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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 5055)
  
  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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5090)
  
  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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5091)
  
  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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5093)
  
  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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5095)
  
  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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5097)
  
  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 4598) is:
 #(v - 1) [(i + j) ← P] = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 4598)
  
  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 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5102)
  
  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 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5103)
  
  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 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5104)
  
  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 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5118)
  
  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 5119) is:
 P ↑ (i + j) = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 5120) is:
 #(i + j - 1) = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 4 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 5119)
  
  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 5120) is:
 #(i + j - 1) = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5123)
  
  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 5120) is:
 #(i + j - 1) = P ↑ (S (i + j)) [i ← N [j ← P]]
subgoal 3 (ID 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5120)
  
  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 4599) is:
 #(v - 1) [(i + j) ← P] = #(v - 1) [i ← N [j ← P]]
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 4599)
  
  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 4532) is:
 !s = !s
subgoal 3 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 4534) 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 4535) 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 5142)
  
  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 4532) is:
 !s = !s
subgoal 3 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 4534) 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 4535) 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 5156)
  
  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 5157) 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 5158) 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 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5159)
  
  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 5157) 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 5158) 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 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5160)
  
  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 5157) 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 5158) 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 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5163)
  
  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 5157) 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 5158) 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 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5165)
  
  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 5157) 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 5158) 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 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5167)
  
  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 5157) 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 5158) 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 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5157)
  
  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 5158) 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 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5169)
  
  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 5158) 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 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5171)
  
  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 5158) 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 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5173)
  
  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 5158) 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 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5179)
  
  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 5158) 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 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5158)
  
  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 4532) is:
 !s = !s
subgoal 3 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 4534) 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 4535) 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 5194)
  
  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 5195) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5197)
  
  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 5195) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5198)
  
  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 5195) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5209)
  
  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 5215) is:
 S v <= i
subgoal 3 (ID 5195) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 4 (ID 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 5 (ID 4532) is:
 !s = !s
subgoal 6 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 7 (ID 4534) 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 4535) 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 5215)
  
  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 5195) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5219)
  
  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 5195) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5220)
  
  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 5195) is:
 #(v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5195)
  
  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 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5230)
  
  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 5236) is:
 #(S v - 1 - 1) = N [j ← P] ↑ i
subgoal 3 (ID 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 4 (ID 4532) is:
 !s = !s
subgoal 5 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 6 (ID 4534) 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 4535) 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 5236)
  
  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 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5239)
  
  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 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5240)
  
  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 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5247)
  
  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 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5249)
  
  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 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5250)
  
  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 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5251)
  
  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 5196) is:
 #(v - 1 - 1) = #(v - 1 - 1)
subgoal 3 (ID 4532) is:
 !s = !s
subgoal 4 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 5 (ID 4534) 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 4535) 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 5196)
  
  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 4532) is:
 !s = !s
subgoal 3 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 4 (ID 4534) 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 4535) 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 4532)
  
  s : Sorts
  N : Term
  P : Term
  i : nat
  j : nat
  ============================
   !s = !s

subgoal 2 (ID 4533) is:
 M1 [i ← N] [(i + j) ← P] · M2 [i ← N] [(i + j) ← P] =
 M1 [(S (i + j)) ← P] [i ← N [j ← P]] · M2 [(S (i + j)) ← P] [i ← N [j ← P]]
subgoal 3 (ID 4534) 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 4535) 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 4533)
  
  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 [i ← N] [(i + j) ← P] =
   M1 [(S (i + j)) ← P] [i ← N [j ← P]]
   · M2 [(S (i + j)) ← P] [i ← N [j ← P]]

subgoal 2 (ID 4534) 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 4535) 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 IHM2; intuition.
2 subgoals, subgoal 1 (ID 4534)
  
  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 4535) 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 4535)
  
  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 5300)
  
  ============================
   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 5304)
  
  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 5305)
  
  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 5307)
  
  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



Tool function usefull when eta-conversion is used, but this is not the case here.
Lemma expand_term_with_subst : forall M n, (M 1 # (S n)) [ n #0 ] = M.
1 subgoals, subgoal 1 (ID 5311)
  
  ============================
   forall (M : Term) (n : nat), M ↑ 1 # (S n) [n ← #0] = M

(dependent evars:)


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

subgoal 2 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 4 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 4 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 3 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 5 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

unfold subst_rec.
6 subgoals, subgoal 1 (ID 5356)
  
  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 5355) is:
 #v [n ← #0] = #v
subgoal 3 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 5 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 5344) 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 5370)
  
  v : Vars
  n : nat
  l : S n <= v
  l0 : 1 + v < n
  ============================
   #(1 + v) = #v

subgoal 2 (ID 5371) is:
 #0 ↑ n = #v
subgoal 3 (ID 5372) is:
 #(1 + v - 1) = #v
subgoal 4 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 5 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 6 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 7 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 8 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5371) is:
 #0 ↑ n = #v
subgoal 3 (ID 5372) is:
 #(1 + v - 1) = #v
subgoal 4 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 5 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 6 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 7 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 8 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

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

subgoal 2 (ID 5371) is:
 #0 ↑ n = #v
subgoal 3 (ID 5372) is:
 #(1 + v - 1) = #v
subgoal 4 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 5 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 6 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 7 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 8 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

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

subgoal 2 (ID 5372) is:
 #(1 + v - 1) = #v
subgoal 3 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 4 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 5 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 6 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 7 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5372) is:
 #(1 + v - 1) = #v
subgoal 3 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 4 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 5 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 6 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 7 (ID 5344) 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 5398)
  
  v : Vars
  n : nat
  l : S n <= v
  e : 1 + v = n
  ============================
   v < S (S v)

subgoal 2 (ID 5399) is:
 S (S v) <= v
subgoal 3 (ID 5372) is:
 #(1 + v - 1) = #v
subgoal 4 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 5 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 6 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 7 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 8 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

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

subgoal 2 (ID 5372) is:
 #(1 + v - 1) = #v
subgoal 3 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 4 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 5 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 6 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 7 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

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

subgoal 2 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 3 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 5 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5355) is:
 #v [n ← #0] = #v
subgoal 3 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 5 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

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

subgoal 2 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 4 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl.
5 subgoals, subgoal 1 (ID 5429)
  
  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 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 4 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 5344) 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 5443)
  
  v : Vars
  n : nat
  g : S n > v
  l : v < n
  ============================
   #v = #v

subgoal 2 (ID 5444) is:
 #(n + 0) = #v
subgoal 3 (ID 5445) is:
 #(v - 1) = #v
subgoal 4 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 5 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 6 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 7 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5445) is:
 #(v - 1) = #v
subgoal 3 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 5 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5445) is:
 #(v - 1) = #v
subgoal 3 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 5 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5445) is:
 #(v - 1) = #v
subgoal 3 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 4 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 5 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 6 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

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

subgoal 2 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 4 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


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

subgoal 2 (ID 5341) is:
 !s ↑ 1 # (S n) [n ← #0] = !s
subgoal 3 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 4 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 5 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

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

subgoal 2 (ID 5342) is:
 (M1 · M2) ↑ 1 # (S n) [n ← #0] = M1 · M2
subgoal 3 (ID 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 4 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl; trivial.
3 subgoals, subgoal 1 (ID 5342)
  
  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 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl.
3 subgoals, subgoal 1 (ID 5463)
  
  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 n) [n ← #0] = M1 · M2

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

rewrite IHM1.
3 subgoals, subgoal 1 (ID 5464)
  
  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 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM2.
3 subgoals, subgoal 1 (ID 5465)
  
  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 5343) is:
 (Π (M1), M2) ↑ 1 # (S n) [n ← #0] = Π (M1), M2
subgoal 3 (ID 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

reflexivity.
2 subgoals, subgoal 1 (ID 5343)
  
  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 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)


simpl.
2 subgoals, subgoal 1 (ID 5467)
  
  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 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM1.
2 subgoals, subgoal 1 (ID 5468)
  
  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 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

rewrite IHM2.
2 subgoals, subgoal 1 (ID 5469)
  
  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 5344) is:
 (λ [M1], M2) ↑ 1 # (S n) [n ← #0] = λ [M1], M2
(dependent evars:)

reflexivity.
1 subgoals, subgoal 1 (ID 5344)
  
  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 5471)
  
  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 5472)
  
  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 5473)
  
  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



End ut_term_mod.
Module Type ut_term_mod is defined



Index
This page has been generated by coqdoc