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