src/ZF/Resid/Substitution.thy
author wenzelm
Sat, 30 May 2009 13:42:40 +0200
changeset 31302 12677a808d43
parent 24893 b8ef7afe3a6b
child 32960 69916a850301
permissions -rw-r--r--
proper signature constraint; modernized method setup;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9284
85a5355faa91 removal of (harmless) circular definitions
paulson
parents: 6068
diff changeset
     1
(*  Title:      ZF/Resid/Substitution.thy
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     2
    ID:         $Id$
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     3
    Author:     Ole Rasmussen
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     4
    Copyright   1995  University of Cambridge
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     5
    Logic Image: ZF
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     6
*)
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13339
diff changeset
     8
theory Substitution imports Redex begin
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
     9
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    10
(** The clumsy _aux functions are required because other arguments vary
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    11
    in the recursive calls ***)
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    12
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    13
consts
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    14
  lift_aux      :: "i=>i"
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    15
primrec
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    16
  "lift_aux(Var(i)) = (\<lambda>k \<in> nat. if i<k then Var(i) else Var(succ(i)))"
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    17
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    18
  "lift_aux(Fun(t)) = (\<lambda>k \<in> nat. Fun(lift_aux(t) ` succ(k)))"
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    19
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    20
  "lift_aux(App(b,f,a)) = (\<lambda>k \<in> nat. App(b, lift_aux(f)`k, lift_aux(a)`k))"
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    21
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24892
diff changeset
    22
definition
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24892
diff changeset
    23
  lift_rec      :: "[i,i]=> i"  where
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    24
    "lift_rec(r,k) == lift_aux(r)`k"
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
    25
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    26
abbreviation
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    27
  lift :: "i=>i" where
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    28
  "lift(r) == lift_rec(r,0)"
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    29
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    30
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    31
consts
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    32
  subst_aux     :: "i=>i"
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    33
primrec
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    34
  "subst_aux(Var(i)) =
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    35
     (\<lambda>r \<in> redexes. \<lambda>k \<in> nat. if k<i then Var(i #- 1)
6068
2d8f3e1f1151 if-then-else syntax for ZF
paulson
parents: 6046
diff changeset
    36
				else if k=i then r else Var(i))"
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    37
  "subst_aux(Fun(t)) =
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    38
     (\<lambda>r \<in> redexes. \<lambda>k \<in> nat. Fun(subst_aux(t) ` lift(r) ` succ(k)))"
6046
2c8a8be36c94 converted to use new primrec section
paulson
parents: 5514
diff changeset
    39
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    40
  "subst_aux(App(b,f,a)) =
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    41
     (\<lambda>r \<in> redexes. \<lambda>k \<in> nat. App(b, subst_aux(f)`r`k, subst_aux(a)`r`k))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    42
24893
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24892
diff changeset
    43
definition
b8ef7afe3a6b modernized specifications;
wenzelm
parents: 24892
diff changeset
    44
  subst_rec     :: "[i,i,i]=> i"	(**NOTE THE ARGUMENT ORDER BELOW**)  where
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    45
    "subst_rec(u,r,k) == subst_aux(r)`u`k"
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    46
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    47
abbreviation
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    48
  subst :: "[i,i]=>i"  (infixl "'/" 70)  where
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    49
  "u/v == subst_rec(u,v,0)"
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    50
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
    51
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    52
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    53
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    54
(*   Arithmetic extensions                                                   *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    55
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    56
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    57
lemma gt_not_eq: "p < n ==> n\<noteq>p"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    58
by blast
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    59
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    60
lemma succ_pred [rule_format, simp]: "j \<in> nat ==> i < j --> succ(j #- 1) = j"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    61
by (induct_tac "j", auto)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    62
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    63
lemma lt_pred: "[|succ(x)<n; n \<in> nat|] ==> x < n #- 1 "
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    64
apply (rule succ_leE)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    65
apply (simp add: succ_pred)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    66
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    67
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    68
lemma gt_pred: "[|n < succ(x); p<n; n \<in> nat|] ==> n #- 1 < x "
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    69
apply (rule succ_leE)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    70
apply (simp add: succ_pred)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    71
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    72
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    73
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    74
declare not_lt_iff_le [simp] if_P [simp] if_not_P [simp]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    75
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    76
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    77
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    78
(*     lift_rec equality rules                                               *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    79
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    80
lemma lift_rec_Var:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    81
     "n \<in> nat ==> lift_rec(Var(i),n) = (if i<n then Var(i) else Var(succ(i)))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    82
by (simp add: lift_rec_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    83
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    84
lemma lift_rec_le [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    85
     "[|i \<in> nat; k\<le>i|] ==> lift_rec(Var(i),k) = Var(succ(i))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    86
by (simp add: lift_rec_def le_in_nat)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    87
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    88
lemma lift_rec_gt [simp]: "[| k \<in> nat; i<k |] ==> lift_rec(Var(i),k) = Var(i)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    89
by (simp add: lift_rec_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    90
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    91
lemma lift_rec_Fun [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    92
     "k \<in> nat ==> lift_rec(Fun(t),k) = Fun(lift_rec(t,succ(k)))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    93
by (simp add: lift_rec_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    94
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    95
lemma lift_rec_App [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    96
     "k \<in> nat ==> lift_rec(App(b,f,a),k) = App(b,lift_rec(f,k),lift_rec(a,k))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    97
by (simp add: lift_rec_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    98
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
    99
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   100
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   101
(*    substitution quality rules                                             *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   102
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   103
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   104
lemma subst_Var:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   105
     "[|k \<in> nat; u \<in> redexes|]
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   106
      ==> subst_rec(u,Var(i),k) =
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   107
          (if k<i then Var(i #- 1) else if k=i then u else Var(i))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   108
by (simp add: subst_rec_def gt_not_eq leI)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   109
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   110
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   111
lemma subst_eq [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   112
     "[|n \<in> nat; u \<in> redexes|] ==> subst_rec(u,Var(n),n) = u"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   113
by (simp add: subst_rec_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   114
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   115
lemma subst_gt [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   116
     "[|u \<in> redexes; p \<in> nat; p<n|] ==> subst_rec(u,Var(n),p) = Var(n #- 1)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   117
by (simp add: subst_rec_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   118
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   119
lemma subst_lt [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   120
     "[|u \<in> redexes; p \<in> nat; n<p|] ==> subst_rec(u,Var(n),p) = Var(n)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   121
by (simp add: subst_rec_def gt_not_eq leI lt_nat_in_nat)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   122
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   123
lemma subst_Fun [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   124
     "[|p \<in> nat; u \<in> redexes|]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   125
      ==> subst_rec(u,Fun(t),p) = Fun(subst_rec(lift(u),t,succ(p))) "
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   126
by (simp add: subst_rec_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   127
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   128
lemma subst_App [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   129
     "[|p \<in> nat; u \<in> redexes|]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   130
      ==> subst_rec(u,App(b,f,a),p) = App(b,subst_rec(u,f,p),subst_rec(u,a,p))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   131
by (simp add: subst_rec_def)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   132
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   133
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   134
lemma lift_rec_type [rule_format, simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   135
     "u \<in> redexes ==> \<forall>k \<in> nat. lift_rec(u,k) \<in> redexes"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   136
apply (erule redexes.induct)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   137
apply (simp_all add: lift_rec_Var lift_rec_Fun lift_rec_App)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   138
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   139
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   140
lemma subst_type [rule_format, simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   141
     "v \<in> redexes ==>  \<forall>n \<in> nat. \<forall>u \<in> redexes. subst_rec(u,v,n) \<in> redexes"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   142
apply (erule redexes.induct)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   143
apply (simp_all add: subst_Var lift_rec_type)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   144
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   145
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   146
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   147
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   148
(*    lift and  substitution proofs                                          *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   149
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   150
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   151
(*The i\<in>nat is redundant*)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   152
lemma lift_lift_rec [rule_format]:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   153
     "u \<in> redexes
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   154
      ==> \<forall>n \<in> nat. \<forall>i \<in> nat. i\<le>n -->
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   155
           (lift_rec(lift_rec(u,i),succ(n)) = lift_rec(lift_rec(u,n),i))"
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   156
apply (erule redexes.induct, auto)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   157
apply (case_tac "n < i")
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   158
apply (frule lt_trans2, assumption)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   159
apply (simp_all add: lift_rec_Var leI)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   160
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   161
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   162
lemma lift_lift:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   163
     "[|u \<in> redexes; n \<in> nat|]
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   164
      ==> lift_rec(lift(u),succ(n)) = lift(lift_rec(u,n))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   165
by (simp add: lift_lift_rec)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   166
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   167
lemma lt_not_m1_lt: "\<lbrakk>m < n; n \<in> nat; m \<in> nat\<rbrakk>\<Longrightarrow> ~ n #- 1 < m"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   168
by (erule natE, auto)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   169
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   170
lemma lift_rec_subst_rec [rule_format]:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   171
     "v \<in> redexes ==>
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   172
       \<forall>n \<in> nat. \<forall>m \<in> nat. \<forall>u \<in> redexes. n\<le>m-->
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   173
          lift_rec(subst_rec(u,v,n),m) =
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   174
               subst_rec(lift_rec(u,m),lift_rec(v,succ(m)),n)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   175
apply (erule redexes.induct, simp_all (no_asm_simp) add: lift_lift)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   176
apply safe
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   177
apply (rename_tac n n' m u)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   178
apply (case_tac "n < n'")
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   179
 apply (frule_tac j = n' in lt_trans2, assumption)
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   180
 apply (simp add: leI, simp)
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   181
apply (erule_tac j=n in leE)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   182
apply (auto simp add: lift_rec_Var subst_Var leI lt_not_m1_lt)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   183
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   184
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   185
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   186
lemma lift_subst:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   187
     "[|v \<in> redexes; u \<in> redexes; n \<in> nat|]
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   188
      ==> lift_rec(u/v,n) = lift_rec(u,n)/lift_rec(v,succ(n))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   189
by (simp add: lift_rec_subst_rec)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   190
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   191
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   192
lemma lift_rec_subst_rec_lt [rule_format]:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   193
     "v \<in> redexes ==>
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   194
       \<forall>n \<in> nat. \<forall>m \<in> nat. \<forall>u \<in> redexes. m\<le>n-->
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   195
          lift_rec(subst_rec(u,v,n),m) =
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   196
               subst_rec(lift_rec(u,m),lift_rec(v,m),succ(n))"
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   197
apply (erule redexes.induct, simp_all (no_asm_simp) add: lift_lift)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   198
apply safe
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   199
apply (rename_tac n n' m u)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   200
apply (case_tac "n < n'")
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   201
apply (case_tac "n < m")
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   202
apply (simp_all add: leI)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   203
apply (erule_tac i=n' in leE)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   204
apply (frule lt_trans1, assumption)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   205
apply (simp_all add: succ_pred leI gt_pred)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   206
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   207
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   208
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   209
lemma subst_rec_lift_rec [rule_format]:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   210
     "u \<in> redexes ==>
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   211
        \<forall>n \<in> nat. \<forall>v \<in> redexes. subst_rec(v,lift_rec(u,n),n) = u"
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   212
apply (erule redexes.induct, auto)
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   213
apply (case_tac "n < na", auto)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   214
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   215
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   216
lemma subst_rec_subst_rec [rule_format]:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   217
     "v \<in> redexes ==>
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   218
        \<forall>m \<in> nat. \<forall>n \<in> nat. \<forall>u \<in> redexes. \<forall>w \<in> redexes. m\<le>n -->
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   219
	  subst_rec(subst_rec(w,u,n),subst_rec(lift_rec(w,m),v,succ(n)),m) =
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   220
	  subst_rec(w,subst_rec(u,v,m),n)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   221
apply (erule redexes.induct)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   222
apply (simp_all add: lift_lift [symmetric] lift_rec_subst_rec_lt, safe)
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   223
apply (rename_tac n' u w)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   224
apply (case_tac "n \<le> succ(n') ")
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   225
 apply (erule_tac i = n in leE)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   226
 apply (simp_all add: succ_pred subst_rec_lift_rec leI)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   227
 apply (case_tac "n < m")
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   228
  apply (frule lt_trans2, assumption, simp add: gt_pred)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   229
 apply simp
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   230
 apply (erule_tac j = n in leE, simp add: gt_pred)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   231
 apply (simp add: subst_rec_lift_rec)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   232
(*final case*)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   233
apply (frule nat_into_Ord [THEN le_refl, THEN lt_trans], assumption)
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   234
apply (erule leE)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12593
diff changeset
   235
 apply (frule succ_leI [THEN lt_trans], assumption)
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   236
 apply (frule_tac i = m in nat_into_Ord [THEN le_refl, THEN lt_trans],
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   237
        assumption)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   238
 apply (simp_all add: succ_pred lt_pred)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   239
done
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   240
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   241
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   242
lemma substitution:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   243
     "[|v \<in> redexes; u \<in> redexes; w \<in> redexes; n \<in> nat|]
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   244
      ==> subst_rec(w,u,n)/subst_rec(lift(w),v,succ(n)) = subst_rec(w,u/v,n)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   245
by (simp add: subst_rec_subst_rec)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   246
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   247
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   248
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   249
(*          Preservation lemmas                                              *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   250
(*          Substitution preserves comp and regular                          *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   251
(* ------------------------------------------------------------------------- *)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   252
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   253
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   254
lemma lift_rec_preserve_comp [rule_format, simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   255
     "u ~ v ==> \<forall>m \<in> nat. lift_rec(u,m) ~ lift_rec(v,m)"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   256
by (erule Scomp.induct, simp_all add: comp_refl)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   257
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   258
lemma subst_rec_preserve_comp [rule_format, simp]:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   259
     "u2 ~ v2 ==> \<forall>m \<in> nat. \<forall>u1 \<in> redexes. \<forall>v1 \<in> redexes.
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   260
                  u1 ~ v1--> subst_rec(u1,u2,m) ~ subst_rec(v1,v2,m)"
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   261
by (erule Scomp.induct,
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   262
    simp_all add: subst_Var lift_rec_preserve_comp comp_refl)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   263
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   264
lemma lift_rec_preserve_reg [simp]:
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   265
     "regular(u) ==> \<forall>m \<in> nat. regular(lift_rec(u,m))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   266
by (erule Sreg.induct, simp_all add: lift_rec_Var)
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   267
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   268
lemma subst_rec_preserve_reg [simp]:
24892
c663e675e177 replaced some 'translations' by 'abbreviation';
wenzelm
parents: 22808
diff changeset
   269
     "regular(v) ==>
12593
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   270
        \<forall>m \<in> nat. \<forall>u \<in> redexes. regular(u)-->regular(subst_rec(u,v,m))"
cd35fe5947d4 Resid converted to Isar/ZF
paulson
parents: 11319
diff changeset
   271
by (erule Sreg.induct, simp_all add: subst_Var lift_rec_preserve_reg)
1048
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
   272
5ba0314f8214 New example by Ole Rasmussen
lcp
parents:
diff changeset
   273
end