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