src/ZF/Constructible/Datatype_absolute.thy
author paulson
Thu Jul 18 15:21:42 2002 +0200 (2002-07-18)
changeset 13395 4eb948d1eb4e
parent 13386 f3e9e8b21aba
child 13397 6e5f4d911435
permissions -rw-r--r--
absoluteness for "formula" and "eclose"
paulson@13306
     1
header {*Absoluteness Properties for Recursive Datatypes*}
paulson@13306
     2
paulson@13269
     3
theory Datatype_absolute = Formula + WF_absolute:
paulson@13268
     4
paulson@13268
     5
paulson@13268
     6
subsection{*The lfp of a continuous function can be expressed as a union*}
paulson@13268
     7
paulson@13268
     8
constdefs
paulson@13385
     9
  directed :: "i=>o"
paulson@13385
    10
   "directed(A) == A\<noteq>0 & (\<forall>x\<in>A. \<forall>y\<in>A. x \<union> y \<in> A)"
paulson@13385
    11
paulson@13385
    12
  contin :: "(i=>i) => o"
paulson@13385
    13
   "contin(h) == (\<forall>A. directed(A) --> h(\<Union>A) = (\<Union>X\<in>A. h(X)))"
paulson@13268
    14
paulson@13268
    15
lemma bnd_mono_iterates_subset: "[|bnd_mono(D, h); n \<in> nat|] ==> h^n (0) <= D"
paulson@13268
    16
apply (induct_tac n) 
paulson@13268
    17
 apply (simp_all add: bnd_mono_def, blast) 
paulson@13268
    18
done
paulson@13268
    19
paulson@13385
    20
lemma bnd_mono_increasing [rule_format]:
paulson@13385
    21
     "[|i \<in> nat; j \<in> nat; bnd_mono(D,h)|] ==> i \<le> j --> h^i(0) \<subseteq> h^j(0)"
paulson@13385
    22
apply (rule_tac m=i and n=j in diff_induct, simp_all)
paulson@13385
    23
apply (blast del: subsetI
paulson@13385
    24
	     intro: bnd_mono_iterates_subset bnd_monoD2 [of concl: h] ) 
paulson@13385
    25
done
paulson@13385
    26
paulson@13385
    27
lemma directed_iterates: "bnd_mono(D,h) ==> directed({h^n (0). n\<in>nat})"
paulson@13385
    28
apply (simp add: directed_def, clarify) 
paulson@13385
    29
apply (rename_tac i j)
paulson@13385
    30
apply (rule_tac x="i \<union> j" in bexI) 
paulson@13385
    31
apply (rule_tac i = i and j = j in Ord_linear_le)
paulson@13385
    32
apply (simp_all add: subset_Un_iff [THEN iffD1] le_imp_subset
paulson@13385
    33
                     subset_Un_iff2 [THEN iffD1])
paulson@13385
    34
apply (simp_all add: subset_Un_iff [THEN iff_sym] bnd_mono_increasing
paulson@13385
    35
                     subset_Un_iff2 [THEN iff_sym])
paulson@13385
    36
done
paulson@13385
    37
paulson@13268
    38
paulson@13268
    39
lemma contin_iterates_eq: 
paulson@13385
    40
    "[|bnd_mono(D, h); contin(h)|] 
paulson@13385
    41
     ==> h(\<Union>n\<in>nat. h^n (0)) = (\<Union>n\<in>nat. h^n (0))"
paulson@13385
    42
apply (simp add: contin_def directed_iterates) 
paulson@13268
    43
apply (rule trans) 
paulson@13268
    44
apply (rule equalityI) 
paulson@13385
    45
 apply (simp_all add: UN_subset_iff)
paulson@13268
    46
 apply safe
paulson@13268
    47
 apply (erule_tac [2] natE) 
paulson@13268
    48
  apply (rule_tac a="succ(x)" in UN_I) 
paulson@13268
    49
   apply simp_all 
paulson@13268
    50
apply blast 
paulson@13268
    51
done
paulson@13268
    52
paulson@13268
    53
lemma lfp_subset_Union:
paulson@13268
    54
     "[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) <= (\<Union>n\<in>nat. h^n(0))"
paulson@13268
    55
apply (rule lfp_lowerbound) 
paulson@13268
    56
 apply (simp add: contin_iterates_eq) 
paulson@13268
    57
apply (simp add: contin_def bnd_mono_iterates_subset UN_subset_iff) 
paulson@13268
    58
done
paulson@13268
    59
paulson@13268
    60
lemma Union_subset_lfp:
paulson@13268
    61
     "bnd_mono(D,h) ==> (\<Union>n\<in>nat. h^n(0)) <= lfp(D,h)"
paulson@13268
    62
apply (simp add: UN_subset_iff)
paulson@13268
    63
apply (rule ballI)  
paulson@13339
    64
apply (induct_tac n, simp_all) 
paulson@13268
    65
apply (rule subset_trans [of _ "h(lfp(D,h))"])
paulson@13268
    66
 apply (blast dest: bnd_monoD2 [OF _ _ lfp_subset] )  
paulson@13268
    67
apply (erule lfp_lemma2) 
paulson@13268
    68
done
paulson@13268
    69
paulson@13268
    70
lemma lfp_eq_Union:
paulson@13268
    71
     "[|bnd_mono(D, h); contin(h)|] ==> lfp(D,h) = (\<Union>n\<in>nat. h^n(0))"
paulson@13268
    72
by (blast del: subsetI 
paulson@13268
    73
          intro: lfp_subset_Union Union_subset_lfp)
paulson@13268
    74
paulson@13268
    75
paulson@13385
    76
subsubsection{*Some Standard Datatype Constructions Preserve Continuity*}
paulson@13385
    77
paulson@13385
    78
lemma contin_imp_mono: "[|X\<subseteq>Y; contin(F)|] ==> F(X) \<subseteq> F(Y)"
paulson@13385
    79
apply (simp add: contin_def) 
paulson@13385
    80
apply (drule_tac x="{X,Y}" in spec) 
paulson@13385
    81
apply (simp add: directed_def subset_Un_iff2 Un_commute) 
paulson@13385
    82
done
paulson@13385
    83
paulson@13385
    84
lemma sum_contin: "[|contin(F); contin(G)|] ==> contin(\<lambda>X. F(X) + G(X))"
paulson@13385
    85
by (simp add: contin_def, blast)
paulson@13385
    86
paulson@13385
    87
lemma prod_contin: "[|contin(F); contin(G)|] ==> contin(\<lambda>X. F(X) * G(X))" 
paulson@13385
    88
apply (subgoal_tac "\<forall>B C. F(B) \<subseteq> F(B \<union> C)")
paulson@13385
    89
 prefer 2 apply (simp add: Un_upper1 contin_imp_mono) 
paulson@13385
    90
apply (subgoal_tac "\<forall>B C. G(C) \<subseteq> G(B \<union> C)")
paulson@13385
    91
 prefer 2 apply (simp add: Un_upper2 contin_imp_mono) 
paulson@13385
    92
apply (simp add: contin_def, clarify) 
paulson@13385
    93
apply (rule equalityI) 
paulson@13385
    94
 prefer 2 apply blast 
paulson@13385
    95
apply clarify 
paulson@13385
    96
apply (rename_tac B C) 
paulson@13385
    97
apply (rule_tac a="B \<union> C" in UN_I) 
paulson@13385
    98
 apply (simp add: directed_def, blast)  
paulson@13385
    99
done
paulson@13385
   100
paulson@13385
   101
lemma const_contin: "contin(\<lambda>X. A)"
paulson@13385
   102
by (simp add: contin_def directed_def)
paulson@13385
   103
paulson@13385
   104
lemma id_contin: "contin(\<lambda>X. X)"
paulson@13385
   105
by (simp add: contin_def)
paulson@13385
   106
paulson@13385
   107
paulson@13385
   108
paulson@13268
   109
subsection {*Absoluteness for "Iterates"*}
paulson@13268
   110
paulson@13353
   111
constdefs
paulson@13353
   112
paulson@13353
   113
  iterates_MH :: "[i=>o, [i,i]=>o, i, i, i, i] => o"
paulson@13353
   114
   "iterates_MH(M,isF,v,n,g,z) ==
paulson@13353
   115
        is_nat_case(M, v, \<lambda>m u. \<exists>gm[M]. fun_apply(M,g,m,gm) & isF(gm,u),
paulson@13353
   116
                    n, z)"
paulson@13353
   117
paulson@13353
   118
  iterates_replacement :: "[i=>o, [i,i]=>o, i] => o"
paulson@13353
   119
   "iterates_replacement(M,isF,v) ==
paulson@13363
   120
      \<forall>n[M]. n\<in>nat --> 
paulson@13353
   121
         wfrec_replacement(M, iterates_MH(M,isF,v), Memrel(succ(n)))"
paulson@13353
   122
paulson@13353
   123
lemma (in M_axioms) iterates_MH_abs:
paulson@13353
   124
  "[| relativize1(M,isF,F); M(n); M(g); M(z) |] 
paulson@13353
   125
   ==> iterates_MH(M,isF,v,n,g,z) <-> z = nat_case(v, \<lambda>m. F(g`m), n)"
paulson@13363
   126
by (simp add: nat_case_abs [of _ "\<lambda>m. F(g ` m)"]
paulson@13363
   127
              relativize1_def iterates_MH_def)  
paulson@13353
   128
paulson@13353
   129
lemma (in M_axioms) iterates_imp_wfrec_replacement:
paulson@13353
   130
  "[|relativize1(M,isF,F); n \<in> nat; iterates_replacement(M,isF,v)|] 
paulson@13353
   131
   ==> wfrec_replacement(M, \<lambda>n f z. z = nat_case(v, \<lambda>m. F(f`m), n), 
paulson@13353
   132
                       Memrel(succ(n)))" 
paulson@13353
   133
by (simp add: iterates_replacement_def iterates_MH_abs)
paulson@13353
   134
paulson@13353
   135
theorem (in M_trancl) iterates_abs:
paulson@13353
   136
  "[| iterates_replacement(M,isF,v); relativize1(M,isF,F);
paulson@13353
   137
      n \<in> nat; M(v); M(z); \<forall>x[M]. M(F(x)) |] 
paulson@13353
   138
   ==> is_wfrec(M, iterates_MH(M,isF,v), Memrel(succ(n)), n, z) <->
paulson@13353
   139
       z = iterates(F,n,v)" 
paulson@13353
   140
apply (frule iterates_imp_wfrec_replacement, assumption+)
paulson@13353
   141
apply (simp add: wf_Memrel trans_Memrel relation_Memrel nat_into_M
paulson@13353
   142
                 relativize2_def iterates_MH_abs 
paulson@13353
   143
                 iterates_nat_def recursor_def transrec_def 
paulson@13353
   144
                 eclose_sing_Ord_eq nat_into_M
paulson@13353
   145
         trans_wfrec_abs [of _ _ _ _ "\<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n)"])
paulson@13353
   146
done
paulson@13353
   147
paulson@13268
   148
paulson@13268
   149
lemma (in M_wfrank) iterates_closed [intro,simp]:
paulson@13353
   150
  "[| iterates_replacement(M,isF,v); relativize1(M,isF,F);
paulson@13353
   151
      n \<in> nat; M(v); \<forall>x[M]. M(F(x)) |] 
paulson@13268
   152
   ==> M(iterates(F,n,v))"
paulson@13353
   153
apply (frule iterates_imp_wfrec_replacement, assumption+)
paulson@13353
   154
apply (simp add: wf_Memrel trans_Memrel relation_Memrel nat_into_M
paulson@13353
   155
                 relativize2_def iterates_MH_abs 
paulson@13353
   156
                 iterates_nat_def recursor_def transrec_def 
paulson@13353
   157
                 eclose_sing_Ord_eq nat_into_M
paulson@13353
   158
         trans_wfrec_closed [of _ _ _ "\<lambda>n g. nat_case(v, \<lambda>m. F(g`m), n)"])
paulson@13353
   159
done
paulson@13268
   160
paulson@13268
   161
paulson@13386
   162
subsection {*lists without univ*}
paulson@13386
   163
paulson@13386
   164
lemmas datatype_univs = Inl_in_univ Inr_in_univ 
paulson@13386
   165
                        Pair_in_univ nat_into_univ A_into_univ 
paulson@13386
   166
paulson@13386
   167
lemma list_fun_bnd_mono: "bnd_mono(univ(A), \<lambda>X. {0} + A*X)"
paulson@13386
   168
apply (rule bnd_monoI)
paulson@13386
   169
 apply (intro subset_refl zero_subset_univ A_subset_univ 
paulson@13386
   170
	      sum_subset_univ Sigma_subset_univ) 
paulson@13386
   171
apply (rule subset_refl sum_mono Sigma_mono | assumption)+
paulson@13386
   172
done
paulson@13386
   173
paulson@13386
   174
lemma list_fun_contin: "contin(\<lambda>X. {0} + A*X)"
paulson@13386
   175
by (intro sum_contin prod_contin id_contin const_contin) 
paulson@13386
   176
paulson@13386
   177
text{*Re-expresses lists using sum and product*}
paulson@13386
   178
lemma list_eq_lfp2: "list(A) = lfp(univ(A), \<lambda>X. {0} + A*X)"
paulson@13386
   179
apply (simp add: list_def) 
paulson@13386
   180
apply (rule equalityI) 
paulson@13386
   181
 apply (rule lfp_lowerbound) 
paulson@13386
   182
  prefer 2 apply (rule lfp_subset)
paulson@13386
   183
 apply (clarify, subst lfp_unfold [OF list_fun_bnd_mono])
paulson@13386
   184
 apply (simp add: Nil_def Cons_def)
paulson@13386
   185
 apply blast 
paulson@13386
   186
txt{*Opposite inclusion*}
paulson@13386
   187
apply (rule lfp_lowerbound) 
paulson@13386
   188
 prefer 2 apply (rule lfp_subset) 
paulson@13386
   189
apply (clarify, subst lfp_unfold [OF list.bnd_mono]) 
paulson@13386
   190
apply (simp add: Nil_def Cons_def)
paulson@13386
   191
apply (blast intro: datatype_univs
paulson@13386
   192
             dest: lfp_subset [THEN subsetD])
paulson@13386
   193
done
paulson@13386
   194
paulson@13386
   195
text{*Re-expresses lists using "iterates", no univ.*}
paulson@13386
   196
lemma list_eq_Union:
paulson@13386
   197
     "list(A) = (\<Union>n\<in>nat. (\<lambda>X. {0} + A*X) ^ n (0))"
paulson@13386
   198
by (simp add: list_eq_lfp2 lfp_eq_Union list_fun_bnd_mono list_fun_contin)
paulson@13386
   199
paulson@13386
   200
paulson@13350
   201
constdefs
paulson@13350
   202
  is_list_functor :: "[i=>o,i,i,i] => o"
paulson@13350
   203
    "is_list_functor(M,A,X,Z) == 
paulson@13350
   204
        \<exists>n1[M]. \<exists>AX[M]. 
paulson@13350
   205
         number1(M,n1) & cartprod(M,A,X,AX) & is_sum(M,n1,AX,Z)"
paulson@13350
   206
paulson@13350
   207
lemma (in M_axioms) list_functor_abs [simp]: 
paulson@13350
   208
     "[| M(A); M(X); M(Z) |] ==> is_list_functor(M,A,X,Z) <-> (Z = {0} + A*X)"
paulson@13350
   209
by (simp add: is_list_functor_def singleton_0 nat_into_M)
paulson@13350
   210
paulson@13350
   211
paulson@13386
   212
subsection {*formulas without univ*}
paulson@13386
   213
paulson@13386
   214
lemma formula_fun_bnd_mono:
paulson@13386
   215
     "bnd_mono(univ(0), \<lambda>X. ((nat*nat) + (nat*nat)) + (X + (X*X + X)))"
paulson@13386
   216
apply (rule bnd_monoI)
paulson@13386
   217
 apply (intro subset_refl zero_subset_univ A_subset_univ 
paulson@13386
   218
	      sum_subset_univ Sigma_subset_univ nat_subset_univ) 
paulson@13386
   219
apply (rule subset_refl sum_mono Sigma_mono | assumption)+
paulson@13386
   220
done
paulson@13386
   221
paulson@13386
   222
lemma formula_fun_contin:
paulson@13386
   223
     "contin(\<lambda>X. ((nat*nat) + (nat*nat)) + (X + (X*X + X)))"
paulson@13386
   224
by (intro sum_contin prod_contin id_contin const_contin) 
paulson@13386
   225
paulson@13386
   226
paulson@13386
   227
text{*Re-expresses formulas using sum and product*}
paulson@13386
   228
lemma formula_eq_lfp2:
paulson@13386
   229
    "formula = lfp(univ(0), \<lambda>X. ((nat*nat) + (nat*nat)) + (X + (X*X + X)))"
paulson@13386
   230
apply (simp add: formula_def) 
paulson@13386
   231
apply (rule equalityI) 
paulson@13386
   232
 apply (rule lfp_lowerbound) 
paulson@13386
   233
  prefer 2 apply (rule lfp_subset)
paulson@13386
   234
 apply (clarify, subst lfp_unfold [OF formula_fun_bnd_mono])
paulson@13386
   235
 apply (simp add: Member_def Equal_def Neg_def And_def Forall_def)
paulson@13386
   236
 apply blast 
paulson@13386
   237
txt{*Opposite inclusion*}
paulson@13386
   238
apply (rule lfp_lowerbound) 
paulson@13386
   239
 prefer 2 apply (rule lfp_subset, clarify) 
paulson@13386
   240
apply (subst lfp_unfold [OF formula.bnd_mono, simplified]) 
paulson@13386
   241
apply (simp add: Member_def Equal_def Neg_def And_def Forall_def)  
paulson@13386
   242
apply (elim sumE SigmaE, simp_all) 
paulson@13386
   243
apply (blast intro: datatype_univs dest: lfp_subset [THEN subsetD])+  
paulson@13386
   244
done
paulson@13386
   245
paulson@13386
   246
text{*Re-expresses formulas using "iterates", no univ.*}
paulson@13386
   247
lemma formula_eq_Union:
paulson@13386
   248
     "formula = 
paulson@13386
   249
      (\<Union>n\<in>nat. (\<lambda>X. ((nat*nat) + (nat*nat)) + (X + (X*X + X))) ^ n (0))"
paulson@13386
   250
by (simp add: formula_eq_lfp2 lfp_eq_Union formula_fun_bnd_mono 
paulson@13386
   251
              formula_fun_contin)
paulson@13386
   252
paulson@13386
   253
paulson@13386
   254
constdefs
paulson@13386
   255
  is_formula_functor :: "[i=>o,i,i] => o"
paulson@13386
   256
    "is_formula_functor(M,X,Z) == 
paulson@13386
   257
        \<exists>nat'[M]. \<exists>natnat[M]. \<exists>natnatsum[M]. \<exists>XX[M]. \<exists>X3[M]. \<exists>X4[M]. 
paulson@13386
   258
          omega(M,nat') & cartprod(M,nat',nat',natnat) & 
paulson@13386
   259
          is_sum(M,natnat,natnat,natnatsum) &
paulson@13386
   260
          cartprod(M,X,X,XX) & is_sum(M,XX,X,X3) & is_sum(M,X,X3,X4) &
paulson@13386
   261
          is_sum(M,natnatsum,X4,Z)"
paulson@13386
   262
paulson@13386
   263
lemma (in M_axioms) formula_functor_abs [simp]: 
paulson@13386
   264
     "[| M(X); M(Z) |] 
paulson@13386
   265
      ==> is_formula_functor(M,X,Z) <-> 
paulson@13386
   266
          Z = ((nat*nat) + (nat*nat)) + (X + (X*X + X))"
paulson@13386
   267
by (simp add: is_formula_functor_def) 
paulson@13386
   268
paulson@13386
   269
paulson@13386
   270
subsection{*@{term M} Contains the List and Formula Datatypes*}
paulson@13395
   271
paulson@13395
   272
constdefs
paulson@13395
   273
  is_list_n :: "[i=>o,i,i,i] => o"
paulson@13395
   274
    "is_list_n(M,A,n,Z) == 
paulson@13395
   275
      \<exists>zero[M]. \<exists>sn[M]. \<exists>msn[M]. 
paulson@13395
   276
       empty(M,zero) & 
paulson@13395
   277
       successor(M,n,sn) & membership(M,sn,msn) &
paulson@13395
   278
       is_wfrec(M, iterates_MH(M, is_list_functor(M,A),zero), msn, n, Z)"
paulson@13395
   279
  
paulson@13395
   280
  mem_list :: "[i=>o,i,i] => o"
paulson@13395
   281
    "mem_list(M,A,l) == 
paulson@13395
   282
      \<exists>n[M]. \<exists>listn[M]. 
paulson@13395
   283
       finite_ordinal(M,n) & is_list_n(M,A,n,listn) & l \<in> listn"
paulson@13395
   284
paulson@13395
   285
  is_list :: "[i=>o,i,i] => o"
paulson@13395
   286
    "is_list(M,A,Z) == \<forall>l[M]. l \<in> Z <-> mem_list(M,A,l)"
paulson@13395
   287
paulson@13395
   288
constdefs
paulson@13395
   289
  is_formula_n :: "[i=>o,i,i] => o"
paulson@13395
   290
    "is_formula_n(M,n,Z) == 
paulson@13395
   291
      \<exists>zero[M]. \<exists>sn[M]. \<exists>msn[M]. 
paulson@13395
   292
       empty(M,zero) & 
paulson@13395
   293
       successor(M,n,sn) & membership(M,sn,msn) &
paulson@13395
   294
       is_wfrec(M, iterates_MH(M, is_formula_functor(M),zero), msn, n, Z)"
paulson@13395
   295
  
paulson@13395
   296
  mem_formula :: "[i=>o,i] => o"
paulson@13395
   297
    "mem_formula(M,p) == 
paulson@13395
   298
      \<exists>n[M]. \<exists>formn[M]. 
paulson@13395
   299
       finite_ordinal(M,n) & is_formula_n(M,n,formn) & p \<in> formn"
paulson@13395
   300
paulson@13395
   301
  is_formula :: "[i=>o,i] => o"
paulson@13395
   302
    "is_formula(M,Z) == \<forall>p[M]. p \<in> Z <-> mem_formula(M,p)"
paulson@13395
   303
wenzelm@13382
   304
locale (open) M_datatypes = M_wfrank +
paulson@13353
   305
 assumes list_replacement1: 
paulson@13363
   306
   "M(A) ==> iterates_replacement(M, is_list_functor(M,A), 0)"
paulson@13353
   307
  and list_replacement2: 
paulson@13363
   308
   "M(A) ==> strong_replacement(M, 
paulson@13353
   309
         \<lambda>n y. n\<in>nat & 
paulson@13353
   310
               (\<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
paulson@13363
   311
               is_wfrec(M, iterates_MH(M,is_list_functor(M,A), 0), 
paulson@13353
   312
                        msn, n, y)))"
paulson@13386
   313
  and formula_replacement1: 
paulson@13386
   314
   "iterates_replacement(M, is_formula_functor(M), 0)"
paulson@13386
   315
  and formula_replacement2: 
paulson@13386
   316
   "strong_replacement(M, 
paulson@13386
   317
         \<lambda>n y. n\<in>nat & 
paulson@13386
   318
               (\<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
paulson@13386
   319
               is_wfrec(M, iterates_MH(M,is_formula_functor(M), 0), 
paulson@13386
   320
                        msn, n, y)))"
paulson@13350
   321
paulson@13395
   322
paulson@13395
   323
subsubsection{*Absoluteness of the List Construction*}
paulson@13395
   324
paulson@13348
   325
lemma (in M_datatypes) list_replacement2': 
paulson@13353
   326
  "M(A) ==> strong_replacement(M, \<lambda>n y. n\<in>nat & y = (\<lambda>X. {0} + A * X)^n (0))"
paulson@13353
   327
apply (insert list_replacement2 [of A]) 
paulson@13353
   328
apply (rule strong_replacement_cong [THEN iffD1])  
paulson@13353
   329
apply (rule conj_cong [OF iff_refl iterates_abs [of "is_list_functor(M,A)"]]) 
paulson@13363
   330
apply (simp_all add: list_replacement1 relativize1_def) 
paulson@13353
   331
done
paulson@13268
   332
paulson@13268
   333
lemma (in M_datatypes) list_closed [intro,simp]:
paulson@13268
   334
     "M(A) ==> M(list(A))"
paulson@13353
   335
apply (insert list_replacement1)
paulson@13353
   336
by  (simp add: RepFun_closed2 list_eq_Union 
paulson@13353
   337
               list_replacement2' relativize1_def
paulson@13353
   338
               iterates_closed [of "is_list_functor(M,A)"])
paulson@13395
   339
lemma (in M_datatypes) is_list_n_abs [simp]:
paulson@13395
   340
     "[|M(A); n\<in>nat; M(Z)|] 
paulson@13395
   341
      ==> is_list_n(M,A,n,Z) <-> Z = (\<lambda>X. {0} + A * X)^n (0)"
paulson@13395
   342
apply (insert list_replacement1)
paulson@13395
   343
apply (simp add: is_list_n_def relativize1_def nat_into_M
paulson@13395
   344
                 iterates_abs [of "is_list_functor(M,A)" _ "\<lambda>X. {0} + A*X"])
paulson@13395
   345
done
paulson@13268
   346
paulson@13395
   347
lemma (in M_datatypes) mem_list_abs [simp]:
paulson@13395
   348
     "M(A) ==> mem_list(M,A,l) <-> l \<in> list(A)"
paulson@13395
   349
apply (insert list_replacement1)
paulson@13395
   350
apply (simp add: mem_list_def relativize1_def list_eq_Union
paulson@13395
   351
                 iterates_closed [of "is_list_functor(M,A)"]) 
paulson@13395
   352
done
paulson@13395
   353
paulson@13395
   354
lemma (in M_datatypes) list_abs [simp]:
paulson@13395
   355
     "[|M(A); M(Z)|] ==> is_list(M,A,Z) <-> Z = list(A)"
paulson@13395
   356
apply (simp add: is_list_def, safe)
paulson@13395
   357
apply (rule M_equalityI, simp_all)
paulson@13395
   358
done
paulson@13395
   359
paulson@13395
   360
subsubsection{*Absoluteness of Formulas*}
paulson@13293
   361
paulson@13386
   362
lemma (in M_datatypes) formula_replacement2': 
paulson@13386
   363
  "strong_replacement(M, \<lambda>n y. n\<in>nat & y = (\<lambda>X. ((nat*nat) + (nat*nat)) + (X + (X*X + X)))^n (0))"
paulson@13386
   364
apply (insert formula_replacement2) 
paulson@13386
   365
apply (rule strong_replacement_cong [THEN iffD1])  
paulson@13386
   366
apply (rule conj_cong [OF iff_refl iterates_abs [of "is_formula_functor(M)"]]) 
paulson@13386
   367
apply (simp_all add: formula_replacement1 relativize1_def) 
paulson@13386
   368
done
paulson@13386
   369
paulson@13386
   370
lemma (in M_datatypes) formula_closed [intro,simp]:
paulson@13386
   371
     "M(formula)"
paulson@13386
   372
apply (insert formula_replacement1)
paulson@13386
   373
apply  (simp add: RepFun_closed2 formula_eq_Union 
paulson@13386
   374
                  formula_replacement2' relativize1_def
paulson@13386
   375
                  iterates_closed [of "is_formula_functor(M)"])
paulson@13386
   376
done
paulson@13386
   377
paulson@13395
   378
lemma (in M_datatypes) is_formula_n_abs [simp]:
paulson@13395
   379
     "[|n\<in>nat; M(Z)|] 
paulson@13395
   380
      ==> is_formula_n(M,n,Z) <-> 
paulson@13395
   381
          Z = (\<lambda>X. ((nat*nat) + (nat*nat)) + (X + (X*X + X)))^n (0)"
paulson@13395
   382
apply (insert formula_replacement1)
paulson@13395
   383
apply (simp add: is_formula_n_def relativize1_def nat_into_M
paulson@13395
   384
                 iterates_abs [of "is_formula_functor(M)" _ 
paulson@13395
   385
                        "\<lambda>X. ((nat*nat) + (nat*nat)) + (X + (X*X + X))"])
paulson@13395
   386
done
paulson@13395
   387
paulson@13395
   388
lemma (in M_datatypes) mem_formula_abs [simp]:
paulson@13395
   389
     "mem_formula(M,l) <-> l \<in> formula"
paulson@13395
   390
apply (insert formula_replacement1)
paulson@13395
   391
apply (simp add: mem_formula_def relativize1_def formula_eq_Union
paulson@13395
   392
                 iterates_closed [of "is_formula_functor(M)"]) 
paulson@13395
   393
done
paulson@13395
   394
paulson@13395
   395
lemma (in M_datatypes) formula_abs [simp]:
paulson@13395
   396
     "[|M(Z)|] ==> is_formula(M,Z) <-> Z = formula"
paulson@13395
   397
apply (simp add: is_formula_def, safe)
paulson@13395
   398
apply (rule M_equalityI, simp_all)
paulson@13395
   399
done
paulson@13395
   400
paulson@13395
   401
paulson@13395
   402
subsection{*Absoluteness for @{text \<epsilon>}-Closure: the @{term eclose} Operator*}
paulson@13395
   403
paulson@13395
   404
text{*Re-expresses eclose using "iterates"*}
paulson@13395
   405
lemma eclose_eq_Union:
paulson@13395
   406
     "eclose(A) = (\<Union>n\<in>nat. Union^n (A))"
paulson@13395
   407
apply (simp add: eclose_def) 
paulson@13395
   408
apply (rule UN_cong) 
paulson@13395
   409
apply (rule refl)
paulson@13395
   410
apply (induct_tac n)
paulson@13395
   411
apply (simp add: nat_rec_0)  
paulson@13395
   412
apply (simp add: nat_rec_succ) 
paulson@13395
   413
done
paulson@13395
   414
paulson@13395
   415
constdefs
paulson@13395
   416
  is_eclose_n :: "[i=>o,i,i,i] => o"
paulson@13395
   417
    "is_eclose_n(M,A,n,Z) == 
paulson@13395
   418
      \<exists>sn[M]. \<exists>msn[M]. 
paulson@13395
   419
       successor(M,n,sn) & membership(M,sn,msn) &
paulson@13395
   420
       is_wfrec(M, iterates_MH(M, big_union(M), A), msn, n, Z)"
paulson@13395
   421
  
paulson@13395
   422
  mem_eclose :: "[i=>o,i,i] => o"
paulson@13395
   423
    "mem_eclose(M,A,l) == 
paulson@13395
   424
      \<exists>n[M]. \<exists>eclosen[M]. 
paulson@13395
   425
       finite_ordinal(M,n) & is_eclose_n(M,A,n,eclosen) & l \<in> eclosen"
paulson@13395
   426
paulson@13395
   427
  is_eclose :: "[i=>o,i,i] => o"
paulson@13395
   428
    "is_eclose(M,A,Z) == \<forall>u[M]. u \<in> Z <-> mem_eclose(M,A,u)"
paulson@13395
   429
paulson@13395
   430
paulson@13395
   431
locale (open) M_eclose = M_wfrank +
paulson@13395
   432
 assumes eclose_replacement1: 
paulson@13395
   433
   "M(A) ==> iterates_replacement(M, big_union(M), A)"
paulson@13395
   434
  and eclose_replacement2: 
paulson@13395
   435
   "M(A) ==> strong_replacement(M, 
paulson@13395
   436
         \<lambda>n y. n\<in>nat & 
paulson@13395
   437
               (\<exists>sn[M]. \<exists>msn[M]. successor(M,n,sn) & membership(M,sn,msn) &
paulson@13395
   438
               is_wfrec(M, iterates_MH(M,big_union(M), A), 
paulson@13395
   439
                        msn, n, y)))"
paulson@13395
   440
paulson@13395
   441
lemma (in M_eclose) eclose_replacement2': 
paulson@13395
   442
  "M(A) ==> strong_replacement(M, \<lambda>n y. n\<in>nat & y = Union^n (A))"
paulson@13395
   443
apply (insert eclose_replacement2 [of A]) 
paulson@13395
   444
apply (rule strong_replacement_cong [THEN iffD1])  
paulson@13395
   445
apply (rule conj_cong [OF iff_refl iterates_abs [of "big_union(M)"]]) 
paulson@13395
   446
apply (simp_all add: eclose_replacement1 relativize1_def) 
paulson@13395
   447
done
paulson@13395
   448
paulson@13395
   449
lemma (in M_eclose) eclose_closed [intro,simp]:
paulson@13395
   450
     "M(A) ==> M(eclose(A))"
paulson@13395
   451
apply (insert eclose_replacement1)
paulson@13395
   452
by  (simp add: RepFun_closed2 eclose_eq_Union 
paulson@13395
   453
               eclose_replacement2' relativize1_def
paulson@13395
   454
               iterates_closed [of "big_union(M)"])
paulson@13395
   455
paulson@13395
   456
lemma (in M_eclose) is_eclose_n_abs [simp]:
paulson@13395
   457
     "[|M(A); n\<in>nat; M(Z)|] ==> is_eclose_n(M,A,n,Z) <-> Z = Union^n (A)"
paulson@13395
   458
apply (insert eclose_replacement1)
paulson@13395
   459
apply (simp add: is_eclose_n_def relativize1_def nat_into_M
paulson@13395
   460
                 iterates_abs [of "big_union(M)" _ "Union"])
paulson@13395
   461
done
paulson@13395
   462
paulson@13395
   463
lemma (in M_eclose) mem_eclose_abs [simp]:
paulson@13395
   464
     "M(A) ==> mem_eclose(M,A,l) <-> l \<in> eclose(A)"
paulson@13395
   465
apply (insert eclose_replacement1)
paulson@13395
   466
apply (simp add: mem_eclose_def relativize1_def eclose_eq_Union
paulson@13395
   467
                 iterates_closed [of "big_union(M)"]) 
paulson@13395
   468
done
paulson@13395
   469
paulson@13395
   470
lemma (in M_eclose) eclose_abs [simp]:
paulson@13395
   471
     "[|M(A); M(Z)|] ==> is_eclose(M,A,Z) <-> Z = eclose(A)"
paulson@13395
   472
apply (simp add: is_eclose_def, safe)
paulson@13395
   473
apply (rule M_equalityI, simp_all)
paulson@13395
   474
done
paulson@13395
   475
paulson@13395
   476
paulson@13395
   477
paulson@13395
   478
paulson@13395
   479
subsection {*Absoluteness for @{term transrec}*}
paulson@13395
   480
paulson@13395
   481
paulson@13395
   482
text{* @{term "transrec(a,H) \<equiv> wfrec(Memrel(eclose({a})), a, H)"} *}
paulson@13395
   483
constdefs
paulson@13395
   484
paulson@13395
   485
  is_transrec :: "[i=>o, [i,i,i]=>o, i, i] => o"
paulson@13395
   486
   "is_transrec(M,MH,a,z) == 
paulson@13395
   487
      \<exists>sa[M]. \<exists>esa[M]. \<exists>mesa[M]. 
paulson@13395
   488
       upair(M,a,a,sa) & is_eclose(M,sa,esa) & membership(M,esa,mesa) &
paulson@13395
   489
       is_wfrec(M,MH,mesa,a,z)"
paulson@13395
   490
paulson@13395
   491
  transrec_replacement :: "[i=>o, [i,i,i]=>o, i] => o"
paulson@13395
   492
   "transrec_replacement(M,MH,a) ==
paulson@13395
   493
      \<exists>sa[M]. \<exists>esa[M]. \<exists>mesa[M]. 
paulson@13395
   494
       upair(M,a,a,sa) & is_eclose(M,sa,esa) & membership(M,esa,mesa) &
paulson@13395
   495
       wfrec_replacement(M,MH,mesa)"
paulson@13395
   496
paulson@13395
   497
(*????????????????Ordinal.thy*)
paulson@13395
   498
lemma Transset_trans_Memrel: 
paulson@13395
   499
    "\<forall>j\<in>i. Transset(j) ==> trans(Memrel(i))"
paulson@13395
   500
by (unfold Transset_def trans_def, blast)
paulson@13395
   501
paulson@13395
   502
text{*The condition @{term "Ord(i)"} lets us use the simpler 
paulson@13395
   503
  @{text "trans_wfrec_abs"} rather than @{text "trans_wfrec_abs"},
paulson@13395
   504
  which I haven't even proved yet. *}
paulson@13395
   505
theorem (in M_eclose) transrec_abs:
paulson@13395
   506
  "[|Ord(i);  M(i);  M(z);
paulson@13395
   507
     transrec_replacement(M,MH,i);  relativize2(M,MH,H);
paulson@13395
   508
     \<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|] 
paulson@13395
   509
   ==> is_transrec(M,MH,i,z) <-> z = transrec(i,H)" 
paulson@13395
   510
by (simp add: trans_wfrec_abs transrec_replacement_def is_transrec_def
paulson@13395
   511
       transrec_def eclose_sing_Ord_eq wf_Memrel trans_Memrel relation_Memrel)
paulson@13395
   512
paulson@13395
   513
paulson@13395
   514
theorem (in M_eclose) transrec_closed:
paulson@13395
   515
     "[|Ord(i);  M(i);  M(z);
paulson@13395
   516
	transrec_replacement(M,MH,i);  relativize2(M,MH,H);
paulson@13395
   517
	\<forall>x[M]. \<forall>g[M]. function(g) --> M(H(x,g))|] 
paulson@13395
   518
      ==> M(transrec(i,H))"
paulson@13395
   519
by (simp add: trans_wfrec_closed transrec_replacement_def is_transrec_def
paulson@13395
   520
       transrec_def eclose_sing_Ord_eq wf_Memrel trans_Memrel relation_Memrel)
paulson@13395
   521
paulson@13395
   522
paulson@13395
   523
paulson@13395
   524
paulson@13268
   525
end