src/ZF/Constructible/L_axioms.thy
author paulson
Wed Jul 24 17:59:12 2002 +0200 (2002-07-24)
changeset 13418 7c0ba9dba978
parent 13385 31df66ca0780
child 13428 99e52e78eb65
permissions -rw-r--r--
tweaks, aiming towards relativization of "satisfies"
     1 header {*The ZF Axioms (Except Separation) in L*}
     2 
     3 theory L_axioms = Formula + Relative + Reflection + MetaExists:
     4 
     5 text {* The class L satisfies the premises of locale @{text M_triv_axioms} *}
     6 
     7 lemma transL: "[| y\<in>x; L(x) |] ==> L(y)"
     8 apply (insert Transset_Lset) 
     9 apply (simp add: Transset_def L_def, blast) 
    10 done
    11 
    12 lemma nonempty: "L(0)"
    13 apply (simp add: L_def) 
    14 apply (blast intro: zero_in_Lset) 
    15 done
    16 
    17 lemma upair_ax: "upair_ax(L)"
    18 apply (simp add: upair_ax_def upair_def, clarify)
    19 apply (rule_tac x="{x,y}" in rexI)  
    20 apply (simp_all add: doubleton_in_L) 
    21 done
    22 
    23 lemma Union_ax: "Union_ax(L)"
    24 apply (simp add: Union_ax_def big_union_def, clarify)
    25 apply (rule_tac x="Union(x)" in rexI)  
    26 apply (simp_all add: Union_in_L, auto) 
    27 apply (blast intro: transL) 
    28 done
    29 
    30 lemma power_ax: "power_ax(L)"
    31 apply (simp add: power_ax_def powerset_def Relative.subset_def, clarify)
    32 apply (rule_tac x="{y \<in> Pow(x). L(y)}" in rexI)  
    33 apply (simp_all add: LPow_in_L, auto)
    34 apply (blast intro: transL) 
    35 done
    36 
    37 subsubsection{*For L to satisfy Replacement *}
    38 
    39 (*Can't move these to Formula unless the definition of univalent is moved
    40 there too!*)
    41 
    42 lemma LReplace_in_Lset:
    43      "[|X \<in> Lset(i); univalent(L,X,Q); Ord(i)|] 
    44       ==> \<exists>j. Ord(j) & Replace(X, %x y. Q(x,y) & L(y)) \<subseteq> Lset(j)"
    45 apply (rule_tac x="\<Union>y \<in> Replace(X, %x y. Q(x,y) & L(y)). succ(lrank(y))" 
    46        in exI)
    47 apply simp
    48 apply clarify 
    49 apply (rule_tac a=x in UN_I)  
    50  apply (simp_all add: Replace_iff univalent_def) 
    51 apply (blast dest: transL L_I) 
    52 done
    53 
    54 lemma LReplace_in_L: 
    55      "[|L(X); univalent(L,X,Q)|] 
    56       ==> \<exists>Y. L(Y) & Replace(X, %x y. Q(x,y) & L(y)) \<subseteq> Y"
    57 apply (drule L_D, clarify) 
    58 apply (drule LReplace_in_Lset, assumption+)
    59 apply (blast intro: L_I Lset_in_Lset_succ)
    60 done
    61 
    62 lemma replacement: "replacement(L,P)"
    63 apply (simp add: replacement_def, clarify)
    64 apply (frule LReplace_in_L, assumption+, clarify) 
    65 apply (rule_tac x=Y in rexI)   
    66 apply (simp_all add: Replace_iff univalent_def, blast) 
    67 done
    68 
    69 subsection{*Instantiating the locale @{text M_triv_axioms}*}
    70 text{*No instances of Separation yet.*}
    71 
    72 lemma Lset_mono_le: "mono_le_subset(Lset)"
    73 by (simp add: mono_le_subset_def le_imp_subset Lset_mono) 
    74 
    75 lemma Lset_cont: "cont_Ord(Lset)"
    76 by (simp add: cont_Ord_def Limit_Lset_eq OUnion_def Limit_is_Ord) 
    77 
    78 lemmas Pair_in_Lset = Formula.Pair_in_LLimit;
    79 
    80 lemmas L_nat = Ord_in_L [OF Ord_nat];
    81 
    82 ML
    83 {*
    84 val transL = thm "transL";
    85 val nonempty = thm "nonempty";
    86 val upair_ax = thm "upair_ax";
    87 val Union_ax = thm "Union_ax";
    88 val power_ax = thm "power_ax";
    89 val replacement = thm "replacement";
    90 val L_nat = thm "L_nat";
    91 
    92 fun kill_flex_triv_prems st = Seq.hd ((REPEAT_FIRST assume_tac) st);
    93 
    94 fun triv_axioms_L th =
    95     kill_flex_triv_prems 
    96        ([transL, nonempty, upair_ax, Union_ax, power_ax, replacement, L_nat] 
    97         MRS (inst "M" "L" th));
    98 
    99 bind_thm ("rall_abs", triv_axioms_L (thm "M_triv_axioms.rall_abs"));
   100 bind_thm ("rex_abs", triv_axioms_L (thm "M_triv_axioms.rex_abs"));
   101 bind_thm ("ball_iff_equiv", triv_axioms_L (thm "M_triv_axioms.ball_iff_equiv"));
   102 bind_thm ("M_equalityI", triv_axioms_L (thm "M_triv_axioms.M_equalityI"));
   103 bind_thm ("empty_abs", triv_axioms_L (thm "M_triv_axioms.empty_abs"));
   104 bind_thm ("subset_abs", triv_axioms_L (thm "M_triv_axioms.subset_abs"));
   105 bind_thm ("upair_abs", triv_axioms_L (thm "M_triv_axioms.upair_abs"));
   106 bind_thm ("upair_in_M_iff", triv_axioms_L (thm "M_triv_axioms.upair_in_M_iff"));
   107 bind_thm ("singleton_in_M_iff", triv_axioms_L (thm "M_triv_axioms.singleton_in_M_iff"));
   108 bind_thm ("pair_abs", triv_axioms_L (thm "M_triv_axioms.pair_abs"));
   109 bind_thm ("pair_in_M_iff", triv_axioms_L (thm "M_triv_axioms.pair_in_M_iff"));
   110 bind_thm ("pair_components_in_M", triv_axioms_L (thm "M_triv_axioms.pair_components_in_M"));
   111 bind_thm ("cartprod_abs", triv_axioms_L (thm "M_triv_axioms.cartprod_abs"));
   112 bind_thm ("union_abs", triv_axioms_L (thm "M_triv_axioms.union_abs"));
   113 bind_thm ("inter_abs", triv_axioms_L (thm "M_triv_axioms.inter_abs"));
   114 bind_thm ("setdiff_abs", triv_axioms_L (thm "M_triv_axioms.setdiff_abs"));
   115 bind_thm ("Union_abs", triv_axioms_L (thm "M_triv_axioms.Union_abs"));
   116 bind_thm ("Union_closed", triv_axioms_L (thm "M_triv_axioms.Union_closed"));
   117 bind_thm ("Un_closed", triv_axioms_L (thm "M_triv_axioms.Un_closed"));
   118 bind_thm ("cons_closed", triv_axioms_L (thm "M_triv_axioms.cons_closed"));
   119 bind_thm ("successor_abs", triv_axioms_L (thm "M_triv_axioms.successor_abs"));
   120 bind_thm ("succ_in_M_iff", triv_axioms_L (thm "M_triv_axioms.succ_in_M_iff"));
   121 bind_thm ("separation_closed", triv_axioms_L (thm "M_triv_axioms.separation_closed"));
   122 bind_thm ("strong_replacementI", triv_axioms_L (thm "M_triv_axioms.strong_replacementI"));
   123 bind_thm ("strong_replacement_closed", triv_axioms_L (thm "M_triv_axioms.strong_replacement_closed"));
   124 bind_thm ("RepFun_closed", triv_axioms_L (thm "M_triv_axioms.RepFun_closed"));
   125 bind_thm ("lam_closed", triv_axioms_L (thm "M_triv_axioms.lam_closed"));
   126 bind_thm ("image_abs", triv_axioms_L (thm "M_triv_axioms.image_abs"));
   127 bind_thm ("powerset_Pow", triv_axioms_L (thm "M_triv_axioms.powerset_Pow"));
   128 bind_thm ("powerset_imp_subset_Pow", triv_axioms_L (thm "M_triv_axioms.powerset_imp_subset_Pow"));
   129 bind_thm ("nat_into_M", triv_axioms_L (thm "M_triv_axioms.nat_into_M"));
   130 bind_thm ("nat_case_closed", triv_axioms_L (thm "M_triv_axioms.nat_case_closed"));
   131 bind_thm ("Inl_in_M_iff", triv_axioms_L (thm "M_triv_axioms.Inl_in_M_iff"));
   132 bind_thm ("Inr_in_M_iff", triv_axioms_L (thm "M_triv_axioms.Inr_in_M_iff"));
   133 bind_thm ("lt_closed", triv_axioms_L (thm "M_triv_axioms.lt_closed"));
   134 bind_thm ("transitive_set_abs", triv_axioms_L (thm "M_triv_axioms.transitive_set_abs"));
   135 bind_thm ("ordinal_abs", triv_axioms_L (thm "M_triv_axioms.ordinal_abs"));
   136 bind_thm ("limit_ordinal_abs", triv_axioms_L (thm "M_triv_axioms.limit_ordinal_abs"));
   137 bind_thm ("successor_ordinal_abs", triv_axioms_L (thm "M_triv_axioms.successor_ordinal_abs"));
   138 bind_thm ("finite_ordinal_abs", triv_axioms_L (thm "M_triv_axioms.finite_ordinal_abs"));
   139 bind_thm ("omega_abs", triv_axioms_L (thm "M_triv_axioms.omega_abs"));
   140 bind_thm ("number1_abs", triv_axioms_L (thm "M_triv_axioms.number1_abs"));
   141 bind_thm ("number1_abs", triv_axioms_L (thm "M_triv_axioms.number1_abs"));
   142 bind_thm ("number3_abs", triv_axioms_L (thm "M_triv_axioms.number3_abs"));
   143 *}
   144 
   145 declare rall_abs [simp] 
   146 declare rex_abs [simp] 
   147 declare empty_abs [simp] 
   148 declare subset_abs [simp] 
   149 declare upair_abs [simp] 
   150 declare upair_in_M_iff [iff]
   151 declare singleton_in_M_iff [iff]
   152 declare pair_abs [simp] 
   153 declare pair_in_M_iff [iff]
   154 declare cartprod_abs [simp] 
   155 declare union_abs [simp] 
   156 declare inter_abs [simp] 
   157 declare setdiff_abs [simp] 
   158 declare Union_abs [simp] 
   159 declare Union_closed [intro,simp]
   160 declare Un_closed [intro,simp]
   161 declare cons_closed [intro,simp]
   162 declare successor_abs [simp] 
   163 declare succ_in_M_iff [iff]
   164 declare separation_closed [intro,simp]
   165 declare strong_replacementI
   166 declare strong_replacement_closed [intro,simp]
   167 declare RepFun_closed [intro,simp]
   168 declare lam_closed [intro,simp]
   169 declare image_abs [simp] 
   170 declare nat_into_M [intro]
   171 declare Inl_in_M_iff [iff]
   172 declare Inr_in_M_iff [iff]
   173 declare transitive_set_abs [simp] 
   174 declare ordinal_abs [simp] 
   175 declare limit_ordinal_abs [simp] 
   176 declare successor_ordinal_abs [simp] 
   177 declare finite_ordinal_abs [simp] 
   178 declare omega_abs [simp] 
   179 declare number1_abs [simp] 
   180 declare number1_abs [simp] 
   181 declare number3_abs [simp]
   182 
   183 
   184 subsection{*Instantiation of the locale @{text reflection}*}
   185 
   186 text{*instances of locale constants*}
   187 constdefs
   188   L_F0 :: "[i=>o,i] => i"
   189     "L_F0(P,y) == \<mu>b. (\<exists>z. L(z) \<and> P(<y,z>)) --> (\<exists>z\<in>Lset(b). P(<y,z>))"
   190 
   191   L_FF :: "[i=>o,i] => i"
   192     "L_FF(P)   == \<lambda>a. \<Union>y\<in>Lset(a). L_F0(P,y)"
   193 
   194   L_ClEx :: "[i=>o,i] => o"
   195     "L_ClEx(P) == \<lambda>a. Limit(a) \<and> normalize(L_FF(P),a) = a"
   196 
   197 
   198 text{*We must use the meta-existential quantifier; otherwise the reflection
   199       terms become enormous!*} 
   200 constdefs
   201   L_Reflects :: "[i=>o,[i,i]=>o] => prop"      ("(3REFLECTS/ [_,/ _])")
   202     "REFLECTS[P,Q] == (??Cl. Closed_Unbounded(Cl) &
   203                            (\<forall>a. Cl(a) --> (\<forall>x \<in> Lset(a). P(x) <-> Q(a,x))))"
   204 
   205 
   206 theorem Triv_reflection:
   207      "REFLECTS[P, \<lambda>a x. P(x)]"
   208 apply (simp add: L_Reflects_def) 
   209 apply (rule meta_exI) 
   210 apply (rule Closed_Unbounded_Ord) 
   211 done
   212 
   213 theorem Not_reflection:
   214      "REFLECTS[P,Q] ==> REFLECTS[\<lambda>x. ~P(x), \<lambda>a x. ~Q(a,x)]"
   215 apply (unfold L_Reflects_def) 
   216 apply (erule meta_exE) 
   217 apply (rule_tac x=Cl in meta_exI, simp) 
   218 done
   219 
   220 theorem And_reflection:
   221      "[| REFLECTS[P,Q]; REFLECTS[P',Q'] |] 
   222       ==> REFLECTS[\<lambda>x. P(x) \<and> P'(x), \<lambda>a x. Q(a,x) \<and> Q'(a,x)]"
   223 apply (unfold L_Reflects_def) 
   224 apply (elim meta_exE) 
   225 apply (rule_tac x="\<lambda>a. Cl(a) \<and> Cla(a)" in meta_exI) 
   226 apply (simp add: Closed_Unbounded_Int, blast) 
   227 done
   228 
   229 theorem Or_reflection:
   230      "[| REFLECTS[P,Q]; REFLECTS[P',Q'] |] 
   231       ==> REFLECTS[\<lambda>x. P(x) \<or> P'(x), \<lambda>a x. Q(a,x) \<or> Q'(a,x)]"
   232 apply (unfold L_Reflects_def) 
   233 apply (elim meta_exE) 
   234 apply (rule_tac x="\<lambda>a. Cl(a) \<and> Cla(a)" in meta_exI) 
   235 apply (simp add: Closed_Unbounded_Int, blast) 
   236 done
   237 
   238 theorem Imp_reflection:
   239      "[| REFLECTS[P,Q]; REFLECTS[P',Q'] |] 
   240       ==> REFLECTS[\<lambda>x. P(x) --> P'(x), \<lambda>a x. Q(a,x) --> Q'(a,x)]"
   241 apply (unfold L_Reflects_def) 
   242 apply (elim meta_exE) 
   243 apply (rule_tac x="\<lambda>a. Cl(a) \<and> Cla(a)" in meta_exI) 
   244 apply (simp add: Closed_Unbounded_Int, blast) 
   245 done
   246 
   247 theorem Iff_reflection:
   248      "[| REFLECTS[P,Q]; REFLECTS[P',Q'] |] 
   249       ==> REFLECTS[\<lambda>x. P(x) <-> P'(x), \<lambda>a x. Q(a,x) <-> Q'(a,x)]"
   250 apply (unfold L_Reflects_def) 
   251 apply (elim meta_exE) 
   252 apply (rule_tac x="\<lambda>a. Cl(a) \<and> Cla(a)" in meta_exI) 
   253 apply (simp add: Closed_Unbounded_Int, blast) 
   254 done
   255 
   256 
   257 theorem Ex_reflection:
   258      "REFLECTS[\<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))]
   259       ==> REFLECTS[\<lambda>x. \<exists>z. L(z) \<and> P(x,z), \<lambda>a x. \<exists>z\<in>Lset(a). Q(a,x,z)]"
   260 apply (unfold L_Reflects_def L_ClEx_def L_FF_def L_F0_def L_def) 
   261 apply (elim meta_exE) 
   262 apply (rule meta_exI)
   263 apply (rule reflection.Ex_reflection [OF Lset_mono_le Lset_cont Pair_in_Lset],
   264        assumption+)
   265 done
   266 
   267 theorem All_reflection:
   268      "REFLECTS[\<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))]
   269       ==> REFLECTS[\<lambda>x. \<forall>z. L(z) --> P(x,z), \<lambda>a x. \<forall>z\<in>Lset(a). Q(a,x,z)]" 
   270 apply (unfold L_Reflects_def L_ClEx_def L_FF_def L_F0_def L_def) 
   271 apply (elim meta_exE) 
   272 apply (rule meta_exI)
   273 apply (rule reflection.All_reflection [OF Lset_mono_le Lset_cont Pair_in_Lset],
   274        assumption+)
   275 done
   276 
   277 theorem Rex_reflection:
   278      "REFLECTS[ \<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))]
   279       ==> REFLECTS[\<lambda>x. \<exists>z[L]. P(x,z), \<lambda>a x. \<exists>z\<in>Lset(a). Q(a,x,z)]"
   280 apply (unfold rex_def) 
   281 apply (intro And_reflection Ex_reflection, assumption)
   282 done
   283 
   284 theorem Rall_reflection:
   285      "REFLECTS[\<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))]
   286       ==> REFLECTS[\<lambda>x. \<forall>z[L]. P(x,z), \<lambda>a x. \<forall>z\<in>Lset(a). Q(a,x,z)]" 
   287 apply (unfold rall_def) 
   288 apply (intro Imp_reflection All_reflection, assumption)
   289 done
   290 
   291 lemmas FOL_reflections = 
   292         Triv_reflection Not_reflection And_reflection Or_reflection
   293         Imp_reflection Iff_reflection Ex_reflection All_reflection
   294         Rex_reflection Rall_reflection
   295 
   296 lemma ReflectsD:
   297      "[|REFLECTS[P,Q]; Ord(i)|] 
   298       ==> \<exists>j. i<j & (\<forall>x \<in> Lset(j). P(x) <-> Q(j,x))"
   299 apply (unfold L_Reflects_def Closed_Unbounded_def) 
   300 apply (elim meta_exE, clarify) 
   301 apply (blast dest!: UnboundedD) 
   302 done
   303 
   304 lemma ReflectsE:
   305      "[| REFLECTS[P,Q]; Ord(i);
   306          !!j. [|i<j;  \<forall>x \<in> Lset(j). P(x) <-> Q(j,x)|] ==> R |]
   307       ==> R"
   308 apply (drule ReflectsD, assumption, blast) 
   309 done
   310 
   311 lemma Collect_mem_eq: "{x\<in>A. x\<in>B} = A \<inter> B";
   312 by blast
   313 
   314 
   315 subsection{*Internalized Formulas for some Set-Theoretic Concepts*}
   316 
   317 lemmas setclass_simps = rall_setclass_is_ball rex_setclass_is_bex
   318 
   319 subsubsection{*Some numbers to help write de Bruijn indices*}
   320 
   321 syntax
   322     "3" :: i   ("3")
   323     "4" :: i   ("4")
   324     "5" :: i   ("5")
   325     "6" :: i   ("6")
   326     "7" :: i   ("7")
   327     "8" :: i   ("8")
   328     "9" :: i   ("9")
   329 
   330 translations
   331    "3"  == "succ(2)"
   332    "4"  == "succ(3)"
   333    "5"  == "succ(4)"
   334    "6"  == "succ(5)"
   335    "7"  == "succ(6)"
   336    "8"  == "succ(7)"
   337    "9"  == "succ(8)"
   338 
   339 
   340 subsubsection{*The Empty Set, Internalized*}
   341 
   342 constdefs empty_fm :: "i=>i"
   343     "empty_fm(x) == Forall(Neg(Member(0,succ(x))))"
   344 
   345 lemma empty_type [TC]:
   346      "x \<in> nat ==> empty_fm(x) \<in> formula"
   347 by (simp add: empty_fm_def) 
   348 
   349 lemma arity_empty_fm [simp]:
   350      "x \<in> nat ==> arity(empty_fm(x)) = succ(x)"
   351 by (simp add: empty_fm_def succ_Un_distrib [symmetric] Un_ac) 
   352 
   353 lemma sats_empty_fm [simp]:
   354    "[| x \<in> nat; env \<in> list(A)|]
   355     ==> sats(A, empty_fm(x), env) <-> empty(**A, nth(x,env))"
   356 by (simp add: empty_fm_def empty_def)
   357 
   358 lemma empty_iff_sats:
   359       "[| nth(i,env) = x; nth(j,env) = y; 
   360           i \<in> nat; env \<in> list(A)|]
   361        ==> empty(**A, x) <-> sats(A, empty_fm(i), env)"
   362 by simp
   363 
   364 theorem empty_reflection:
   365      "REFLECTS[\<lambda>x. empty(L,f(x)), 
   366                \<lambda>i x. empty(**Lset(i),f(x))]"
   367 apply (simp only: empty_def setclass_simps)
   368 apply (intro FOL_reflections)  
   369 done
   370 
   371 text{*Not used.  But maybe useful?*}
   372 lemma Transset_sats_empty_fm_eq_0:
   373    "[| n \<in> nat; env \<in> list(A); Transset(A)|]
   374     ==> sats(A, empty_fm(n), env) <-> nth(n,env) = 0"
   375 apply (simp add: empty_fm_def empty_def Transset_def, auto)
   376 apply (case_tac "n < length(env)") 
   377 apply (frule nth_type, assumption+, blast)  
   378 apply (simp_all add: not_lt_iff_le nth_eq_0) 
   379 done
   380 
   381 
   382 subsubsection{*Unordered Pairs, Internalized*}
   383 
   384 constdefs upair_fm :: "[i,i,i]=>i"
   385     "upair_fm(x,y,z) == 
   386        And(Member(x,z), 
   387            And(Member(y,z),
   388                Forall(Implies(Member(0,succ(z)), 
   389                               Or(Equal(0,succ(x)), Equal(0,succ(y)))))))"
   390 
   391 lemma upair_type [TC]:
   392      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> upair_fm(x,y,z) \<in> formula"
   393 by (simp add: upair_fm_def) 
   394 
   395 lemma arity_upair_fm [simp]:
   396      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
   397       ==> arity(upair_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   398 by (simp add: upair_fm_def succ_Un_distrib [symmetric] Un_ac) 
   399 
   400 lemma sats_upair_fm [simp]:
   401    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   402     ==> sats(A, upair_fm(x,y,z), env) <-> 
   403             upair(**A, nth(x,env), nth(y,env), nth(z,env))"
   404 by (simp add: upair_fm_def upair_def)
   405 
   406 lemma upair_iff_sats:
   407       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   408           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   409        ==> upair(**A, x, y, z) <-> sats(A, upair_fm(i,j,k), env)"
   410 by (simp add: sats_upair_fm)
   411 
   412 text{*Useful? At least it refers to "real" unordered pairs*}
   413 lemma sats_upair_fm2 [simp]:
   414    "[| x \<in> nat; y \<in> nat; z < length(env); env \<in> list(A); Transset(A)|]
   415     ==> sats(A, upair_fm(x,y,z), env) <-> 
   416         nth(z,env) = {nth(x,env), nth(y,env)}"
   417 apply (frule lt_length_in_nat, assumption)  
   418 apply (simp add: upair_fm_def Transset_def, auto) 
   419 apply (blast intro: nth_type) 
   420 done
   421 
   422 theorem upair_reflection:
   423      "REFLECTS[\<lambda>x. upair(L,f(x),g(x),h(x)), 
   424                \<lambda>i x. upair(**Lset(i),f(x),g(x),h(x))]" 
   425 apply (simp add: upair_def)
   426 apply (intro FOL_reflections)  
   427 done
   428 
   429 subsubsection{*Ordered pairs, Internalized*}
   430 
   431 constdefs pair_fm :: "[i,i,i]=>i"
   432     "pair_fm(x,y,z) == 
   433        Exists(And(upair_fm(succ(x),succ(x),0),
   434               Exists(And(upair_fm(succ(succ(x)),succ(succ(y)),0),
   435                          upair_fm(1,0,succ(succ(z)))))))"
   436 
   437 lemma pair_type [TC]:
   438      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> pair_fm(x,y,z) \<in> formula"
   439 by (simp add: pair_fm_def) 
   440 
   441 lemma arity_pair_fm [simp]:
   442      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
   443       ==> arity(pair_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   444 by (simp add: pair_fm_def succ_Un_distrib [symmetric] Un_ac) 
   445 
   446 lemma sats_pair_fm [simp]:
   447    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   448     ==> sats(A, pair_fm(x,y,z), env) <-> 
   449         pair(**A, nth(x,env), nth(y,env), nth(z,env))"
   450 by (simp add: pair_fm_def pair_def)
   451 
   452 lemma pair_iff_sats:
   453       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   454           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   455        ==> pair(**A, x, y, z) <-> sats(A, pair_fm(i,j,k), env)"
   456 by (simp add: sats_pair_fm)
   457 
   458 theorem pair_reflection:
   459      "REFLECTS[\<lambda>x. pair(L,f(x),g(x),h(x)), 
   460                \<lambda>i x. pair(**Lset(i),f(x),g(x),h(x))]"
   461 apply (simp only: pair_def setclass_simps)
   462 apply (intro FOL_reflections upair_reflection)  
   463 done
   464 
   465 
   466 subsubsection{*Binary Unions, Internalized*}
   467 
   468 constdefs union_fm :: "[i,i,i]=>i"
   469     "union_fm(x,y,z) == 
   470        Forall(Iff(Member(0,succ(z)),
   471                   Or(Member(0,succ(x)),Member(0,succ(y)))))"
   472 
   473 lemma union_type [TC]:
   474      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> union_fm(x,y,z) \<in> formula"
   475 by (simp add: union_fm_def) 
   476 
   477 lemma arity_union_fm [simp]:
   478      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
   479       ==> arity(union_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   480 by (simp add: union_fm_def succ_Un_distrib [symmetric] Un_ac) 
   481 
   482 lemma sats_union_fm [simp]:
   483    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   484     ==> sats(A, union_fm(x,y,z), env) <-> 
   485         union(**A, nth(x,env), nth(y,env), nth(z,env))"
   486 by (simp add: union_fm_def union_def)
   487 
   488 lemma union_iff_sats:
   489       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   490           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   491        ==> union(**A, x, y, z) <-> sats(A, union_fm(i,j,k), env)"
   492 by (simp add: sats_union_fm)
   493 
   494 theorem union_reflection:
   495      "REFLECTS[\<lambda>x. union(L,f(x),g(x),h(x)), 
   496                \<lambda>i x. union(**Lset(i),f(x),g(x),h(x))]"
   497 apply (simp only: union_def setclass_simps)
   498 apply (intro FOL_reflections)  
   499 done
   500 
   501 
   502 subsubsection{*Set ``Cons,'' Internalized*}
   503 
   504 constdefs cons_fm :: "[i,i,i]=>i"
   505     "cons_fm(x,y,z) == 
   506        Exists(And(upair_fm(succ(x),succ(x),0),
   507                   union_fm(0,succ(y),succ(z))))"
   508 
   509 
   510 lemma cons_type [TC]:
   511      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> cons_fm(x,y,z) \<in> formula"
   512 by (simp add: cons_fm_def) 
   513 
   514 lemma arity_cons_fm [simp]:
   515      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
   516       ==> arity(cons_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   517 by (simp add: cons_fm_def succ_Un_distrib [symmetric] Un_ac) 
   518 
   519 lemma sats_cons_fm [simp]:
   520    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   521     ==> sats(A, cons_fm(x,y,z), env) <-> 
   522         is_cons(**A, nth(x,env), nth(y,env), nth(z,env))"
   523 by (simp add: cons_fm_def is_cons_def)
   524 
   525 lemma cons_iff_sats:
   526       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   527           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   528        ==> is_cons(**A, x, y, z) <-> sats(A, cons_fm(i,j,k), env)"
   529 by simp
   530 
   531 theorem cons_reflection:
   532      "REFLECTS[\<lambda>x. is_cons(L,f(x),g(x),h(x)), 
   533                \<lambda>i x. is_cons(**Lset(i),f(x),g(x),h(x))]"
   534 apply (simp only: is_cons_def setclass_simps)
   535 apply (intro FOL_reflections upair_reflection union_reflection)  
   536 done
   537 
   538 
   539 subsubsection{*Successor Function, Internalized*}
   540 
   541 constdefs succ_fm :: "[i,i]=>i"
   542     "succ_fm(x,y) == cons_fm(x,x,y)"
   543 
   544 lemma succ_type [TC]:
   545      "[| x \<in> nat; y \<in> nat |] ==> succ_fm(x,y) \<in> formula"
   546 by (simp add: succ_fm_def) 
   547 
   548 lemma arity_succ_fm [simp]:
   549      "[| x \<in> nat; y \<in> nat |] 
   550       ==> arity(succ_fm(x,y)) = succ(x) \<union> succ(y)"
   551 by (simp add: succ_fm_def)
   552 
   553 lemma sats_succ_fm [simp]:
   554    "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   555     ==> sats(A, succ_fm(x,y), env) <-> 
   556         successor(**A, nth(x,env), nth(y,env))"
   557 by (simp add: succ_fm_def successor_def)
   558 
   559 lemma successor_iff_sats:
   560       "[| nth(i,env) = x; nth(j,env) = y; 
   561           i \<in> nat; j \<in> nat; env \<in> list(A)|]
   562        ==> successor(**A, x, y) <-> sats(A, succ_fm(i,j), env)"
   563 by simp
   564 
   565 theorem successor_reflection:
   566      "REFLECTS[\<lambda>x. successor(L,f(x),g(x)), 
   567                \<lambda>i x. successor(**Lset(i),f(x),g(x))]"
   568 apply (simp only: successor_def setclass_simps)
   569 apply (intro cons_reflection)  
   570 done
   571 
   572 
   573 subsubsection{*The Number 1, Internalized*}
   574 
   575 (* "number1(M,a) == (\<exists>x[M]. empty(M,x) & successor(M,x,a))" *)
   576 constdefs number1_fm :: "i=>i"
   577     "number1_fm(a) == Exists(And(empty_fm(0), succ_fm(0,succ(a))))"
   578 
   579 lemma number1_type [TC]:
   580      "x \<in> nat ==> number1_fm(x) \<in> formula"
   581 by (simp add: number1_fm_def) 
   582 
   583 lemma arity_number1_fm [simp]:
   584      "x \<in> nat ==> arity(number1_fm(x)) = succ(x)"
   585 by (simp add: number1_fm_def succ_Un_distrib [symmetric] Un_ac) 
   586 
   587 lemma sats_number1_fm [simp]:
   588    "[| x \<in> nat; env \<in> list(A)|]
   589     ==> sats(A, number1_fm(x), env) <-> number1(**A, nth(x,env))"
   590 by (simp add: number1_fm_def number1_def)
   591 
   592 lemma number1_iff_sats:
   593       "[| nth(i,env) = x; nth(j,env) = y; 
   594           i \<in> nat; env \<in> list(A)|]
   595        ==> number1(**A, x) <-> sats(A, number1_fm(i), env)"
   596 by simp
   597 
   598 theorem number1_reflection:
   599      "REFLECTS[\<lambda>x. number1(L,f(x)), 
   600                \<lambda>i x. number1(**Lset(i),f(x))]"
   601 apply (simp only: number1_def setclass_simps)
   602 apply (intro FOL_reflections empty_reflection successor_reflection)
   603 done
   604 
   605 
   606 subsubsection{*Big Union, Internalized*}
   607 
   608 (*  "big_union(M,A,z) == \<forall>x[M]. x \<in> z <-> (\<exists>y[M]. y\<in>A & x \<in> y)" *)
   609 constdefs big_union_fm :: "[i,i]=>i"
   610     "big_union_fm(A,z) == 
   611        Forall(Iff(Member(0,succ(z)),
   612                   Exists(And(Member(0,succ(succ(A))), Member(1,0)))))"
   613 
   614 lemma big_union_type [TC]:
   615      "[| x \<in> nat; y \<in> nat |] ==> big_union_fm(x,y) \<in> formula"
   616 by (simp add: big_union_fm_def) 
   617 
   618 lemma arity_big_union_fm [simp]:
   619      "[| x \<in> nat; y \<in> nat |] 
   620       ==> arity(big_union_fm(x,y)) = succ(x) \<union> succ(y)"
   621 by (simp add: big_union_fm_def succ_Un_distrib [symmetric] Un_ac)
   622 
   623 lemma sats_big_union_fm [simp]:
   624    "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   625     ==> sats(A, big_union_fm(x,y), env) <-> 
   626         big_union(**A, nth(x,env), nth(y,env))"
   627 by (simp add: big_union_fm_def big_union_def)
   628 
   629 lemma big_union_iff_sats:
   630       "[| nth(i,env) = x; nth(j,env) = y; 
   631           i \<in> nat; j \<in> nat; env \<in> list(A)|]
   632        ==> big_union(**A, x, y) <-> sats(A, big_union_fm(i,j), env)"
   633 by simp
   634 
   635 theorem big_union_reflection:
   636      "REFLECTS[\<lambda>x. big_union(L,f(x),g(x)), 
   637                \<lambda>i x. big_union(**Lset(i),f(x),g(x))]"
   638 apply (simp only: big_union_def setclass_simps)
   639 apply (intro FOL_reflections)  
   640 done
   641 
   642 
   643 subsubsection{*Variants of Satisfaction Definitions for Ordinals, etc.*}
   644 
   645 text{*Differs from the one in Formula by using "ordinal" rather than "Ord"*}
   646 
   647 
   648 lemma sats_subset_fm':
   649    "[|x \<in> nat; y \<in> nat; env \<in> list(A)|]
   650     ==> sats(A, subset_fm(x,y), env) <-> subset(**A, nth(x,env), nth(y,env))" 
   651 by (simp add: subset_fm_def Relative.subset_def) 
   652 
   653 theorem subset_reflection:
   654      "REFLECTS[\<lambda>x. subset(L,f(x),g(x)), 
   655                \<lambda>i x. subset(**Lset(i),f(x),g(x))]" 
   656 apply (simp only: Relative.subset_def setclass_simps)
   657 apply (intro FOL_reflections)  
   658 done
   659 
   660 lemma sats_transset_fm':
   661    "[|x \<in> nat; env \<in> list(A)|]
   662     ==> sats(A, transset_fm(x), env) <-> transitive_set(**A, nth(x,env))"
   663 by (simp add: sats_subset_fm' transset_fm_def transitive_set_def) 
   664 
   665 theorem transitive_set_reflection:
   666      "REFLECTS[\<lambda>x. transitive_set(L,f(x)),
   667                \<lambda>i x. transitive_set(**Lset(i),f(x))]"
   668 apply (simp only: transitive_set_def setclass_simps)
   669 apply (intro FOL_reflections subset_reflection)  
   670 done
   671 
   672 lemma sats_ordinal_fm':
   673    "[|x \<in> nat; env \<in> list(A)|]
   674     ==> sats(A, ordinal_fm(x), env) <-> ordinal(**A,nth(x,env))"
   675 by (simp add: sats_transset_fm' ordinal_fm_def ordinal_def)
   676 
   677 lemma ordinal_iff_sats:
   678       "[| nth(i,env) = x;  i \<in> nat; env \<in> list(A)|]
   679        ==> ordinal(**A, x) <-> sats(A, ordinal_fm(i), env)"
   680 by (simp add: sats_ordinal_fm')
   681 
   682 theorem ordinal_reflection:
   683      "REFLECTS[\<lambda>x. ordinal(L,f(x)), \<lambda>i x. ordinal(**Lset(i),f(x))]"
   684 apply (simp only: ordinal_def setclass_simps)
   685 apply (intro FOL_reflections transitive_set_reflection)  
   686 done
   687 
   688 
   689 subsubsection{*Membership Relation, Internalized*}
   690 
   691 constdefs Memrel_fm :: "[i,i]=>i"
   692     "Memrel_fm(A,r) == 
   693        Forall(Iff(Member(0,succ(r)),
   694                   Exists(And(Member(0,succ(succ(A))),
   695                              Exists(And(Member(0,succ(succ(succ(A)))),
   696                                         And(Member(1,0),
   697                                             pair_fm(1,0,2))))))))"
   698 
   699 lemma Memrel_type [TC]:
   700      "[| x \<in> nat; y \<in> nat |] ==> Memrel_fm(x,y) \<in> formula"
   701 by (simp add: Memrel_fm_def) 
   702 
   703 lemma arity_Memrel_fm [simp]:
   704      "[| x \<in> nat; y \<in> nat |] 
   705       ==> arity(Memrel_fm(x,y)) = succ(x) \<union> succ(y)"
   706 by (simp add: Memrel_fm_def succ_Un_distrib [symmetric] Un_ac) 
   707 
   708 lemma sats_Memrel_fm [simp]:
   709    "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   710     ==> sats(A, Memrel_fm(x,y), env) <-> 
   711         membership(**A, nth(x,env), nth(y,env))"
   712 by (simp add: Memrel_fm_def membership_def)
   713 
   714 lemma Memrel_iff_sats:
   715       "[| nth(i,env) = x; nth(j,env) = y; 
   716           i \<in> nat; j \<in> nat; env \<in> list(A)|]
   717        ==> membership(**A, x, y) <-> sats(A, Memrel_fm(i,j), env)"
   718 by simp
   719 
   720 theorem membership_reflection:
   721      "REFLECTS[\<lambda>x. membership(L,f(x),g(x)), 
   722                \<lambda>i x. membership(**Lset(i),f(x),g(x))]"
   723 apply (simp only: membership_def setclass_simps)
   724 apply (intro FOL_reflections pair_reflection)  
   725 done
   726 
   727 subsubsection{*Predecessor Set, Internalized*}
   728 
   729 constdefs pred_set_fm :: "[i,i,i,i]=>i"
   730     "pred_set_fm(A,x,r,B) == 
   731        Forall(Iff(Member(0,succ(B)),
   732                   Exists(And(Member(0,succ(succ(r))),
   733                              And(Member(1,succ(succ(A))),
   734                                  pair_fm(1,succ(succ(x)),0))))))"
   735 
   736 
   737 lemma pred_set_type [TC]:
   738      "[| A \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat |] 
   739       ==> pred_set_fm(A,x,r,B) \<in> formula"
   740 by (simp add: pred_set_fm_def) 
   741 
   742 lemma arity_pred_set_fm [simp]:
   743    "[| A \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat |] 
   744     ==> arity(pred_set_fm(A,x,r,B)) = succ(A) \<union> succ(x) \<union> succ(r) \<union> succ(B)"
   745 by (simp add: pred_set_fm_def succ_Un_distrib [symmetric] Un_ac) 
   746 
   747 lemma sats_pred_set_fm [simp]:
   748    "[| U \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat; env \<in> list(A)|]
   749     ==> sats(A, pred_set_fm(U,x,r,B), env) <-> 
   750         pred_set(**A, nth(U,env), nth(x,env), nth(r,env), nth(B,env))"
   751 by (simp add: pred_set_fm_def pred_set_def)
   752 
   753 lemma pred_set_iff_sats:
   754       "[| nth(i,env) = U; nth(j,env) = x; nth(k,env) = r; nth(l,env) = B; 
   755           i \<in> nat; j \<in> nat; k \<in> nat; l \<in> nat; env \<in> list(A)|]
   756        ==> pred_set(**A,U,x,r,B) <-> sats(A, pred_set_fm(i,j,k,l), env)"
   757 by (simp add: sats_pred_set_fm)
   758 
   759 theorem pred_set_reflection:
   760      "REFLECTS[\<lambda>x. pred_set(L,f(x),g(x),h(x),b(x)), 
   761                \<lambda>i x. pred_set(**Lset(i),f(x),g(x),h(x),b(x))]" 
   762 apply (simp only: pred_set_def setclass_simps)
   763 apply (intro FOL_reflections pair_reflection)  
   764 done
   765 
   766 
   767 
   768 subsubsection{*Domain of a Relation, Internalized*}
   769 
   770 (* "is_domain(M,r,z) == 
   771 	\<forall>x[M]. (x \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>y[M]. pair(M,x,y,w))))" *)
   772 constdefs domain_fm :: "[i,i]=>i"
   773     "domain_fm(r,z) == 
   774        Forall(Iff(Member(0,succ(z)),
   775                   Exists(And(Member(0,succ(succ(r))),
   776                              Exists(pair_fm(2,0,1))))))"
   777 
   778 lemma domain_type [TC]:
   779      "[| x \<in> nat; y \<in> nat |] ==> domain_fm(x,y) \<in> formula"
   780 by (simp add: domain_fm_def) 
   781 
   782 lemma arity_domain_fm [simp]:
   783      "[| x \<in> nat; y \<in> nat |] 
   784       ==> arity(domain_fm(x,y)) = succ(x) \<union> succ(y)"
   785 by (simp add: domain_fm_def succ_Un_distrib [symmetric] Un_ac) 
   786 
   787 lemma sats_domain_fm [simp]:
   788    "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   789     ==> sats(A, domain_fm(x,y), env) <-> 
   790         is_domain(**A, nth(x,env), nth(y,env))"
   791 by (simp add: domain_fm_def is_domain_def)
   792 
   793 lemma domain_iff_sats:
   794       "[| nth(i,env) = x; nth(j,env) = y; 
   795           i \<in> nat; j \<in> nat; env \<in> list(A)|]
   796        ==> is_domain(**A, x, y) <-> sats(A, domain_fm(i,j), env)"
   797 by simp
   798 
   799 theorem domain_reflection:
   800      "REFLECTS[\<lambda>x. is_domain(L,f(x),g(x)), 
   801                \<lambda>i x. is_domain(**Lset(i),f(x),g(x))]"
   802 apply (simp only: is_domain_def setclass_simps)
   803 apply (intro FOL_reflections pair_reflection)  
   804 done
   805 
   806 
   807 subsubsection{*Range of a Relation, Internalized*}
   808 
   809 (* "is_range(M,r,z) == 
   810 	\<forall>y[M]. (y \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>x[M]. pair(M,x,y,w))))" *)
   811 constdefs range_fm :: "[i,i]=>i"
   812     "range_fm(r,z) == 
   813        Forall(Iff(Member(0,succ(z)),
   814                   Exists(And(Member(0,succ(succ(r))),
   815                              Exists(pair_fm(0,2,1))))))"
   816 
   817 lemma range_type [TC]:
   818      "[| x \<in> nat; y \<in> nat |] ==> range_fm(x,y) \<in> formula"
   819 by (simp add: range_fm_def) 
   820 
   821 lemma arity_range_fm [simp]:
   822      "[| x \<in> nat; y \<in> nat |] 
   823       ==> arity(range_fm(x,y)) = succ(x) \<union> succ(y)"
   824 by (simp add: range_fm_def succ_Un_distrib [symmetric] Un_ac) 
   825 
   826 lemma sats_range_fm [simp]:
   827    "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   828     ==> sats(A, range_fm(x,y), env) <-> 
   829         is_range(**A, nth(x,env), nth(y,env))"
   830 by (simp add: range_fm_def is_range_def)
   831 
   832 lemma range_iff_sats:
   833       "[| nth(i,env) = x; nth(j,env) = y; 
   834           i \<in> nat; j \<in> nat; env \<in> list(A)|]
   835        ==> is_range(**A, x, y) <-> sats(A, range_fm(i,j), env)"
   836 by simp
   837 
   838 theorem range_reflection:
   839      "REFLECTS[\<lambda>x. is_range(L,f(x),g(x)), 
   840                \<lambda>i x. is_range(**Lset(i),f(x),g(x))]"
   841 apply (simp only: is_range_def setclass_simps)
   842 apply (intro FOL_reflections pair_reflection)  
   843 done
   844 
   845  
   846 subsubsection{*Field of a Relation, Internalized*}
   847 
   848 (* "is_field(M,r,z) == 
   849 	\<exists>dr[M]. is_domain(M,r,dr) & 
   850             (\<exists>rr[M]. is_range(M,r,rr) & union(M,dr,rr,z))" *)
   851 constdefs field_fm :: "[i,i]=>i"
   852     "field_fm(r,z) == 
   853        Exists(And(domain_fm(succ(r),0), 
   854               Exists(And(range_fm(succ(succ(r)),0), 
   855                          union_fm(1,0,succ(succ(z)))))))"
   856 
   857 lemma field_type [TC]:
   858      "[| x \<in> nat; y \<in> nat |] ==> field_fm(x,y) \<in> formula"
   859 by (simp add: field_fm_def) 
   860 
   861 lemma arity_field_fm [simp]:
   862      "[| x \<in> nat; y \<in> nat |] 
   863       ==> arity(field_fm(x,y)) = succ(x) \<union> succ(y)"
   864 by (simp add: field_fm_def succ_Un_distrib [symmetric] Un_ac) 
   865 
   866 lemma sats_field_fm [simp]:
   867    "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
   868     ==> sats(A, field_fm(x,y), env) <-> 
   869         is_field(**A, nth(x,env), nth(y,env))"
   870 by (simp add: field_fm_def is_field_def)
   871 
   872 lemma field_iff_sats:
   873       "[| nth(i,env) = x; nth(j,env) = y; 
   874           i \<in> nat; j \<in> nat; env \<in> list(A)|]
   875        ==> is_field(**A, x, y) <-> sats(A, field_fm(i,j), env)"
   876 by simp
   877 
   878 theorem field_reflection:
   879      "REFLECTS[\<lambda>x. is_field(L,f(x),g(x)), 
   880                \<lambda>i x. is_field(**Lset(i),f(x),g(x))]"
   881 apply (simp only: is_field_def setclass_simps)
   882 apply (intro FOL_reflections domain_reflection range_reflection
   883              union_reflection)
   884 done
   885 
   886 
   887 subsubsection{*Image under a Relation, Internalized*}
   888 
   889 (* "image(M,r,A,z) == 
   890         \<forall>y[M]. (y \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>x[M]. x\<in>A & pair(M,x,y,w))))" *)
   891 constdefs image_fm :: "[i,i,i]=>i"
   892     "image_fm(r,A,z) == 
   893        Forall(Iff(Member(0,succ(z)),
   894                   Exists(And(Member(0,succ(succ(r))),
   895                              Exists(And(Member(0,succ(succ(succ(A)))),
   896 	 			        pair_fm(0,2,1)))))))"
   897 
   898 lemma image_type [TC]:
   899      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> image_fm(x,y,z) \<in> formula"
   900 by (simp add: image_fm_def) 
   901 
   902 lemma arity_image_fm [simp]:
   903      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
   904       ==> arity(image_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   905 by (simp add: image_fm_def succ_Un_distrib [symmetric] Un_ac) 
   906 
   907 lemma sats_image_fm [simp]:
   908    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   909     ==> sats(A, image_fm(x,y,z), env) <-> 
   910         image(**A, nth(x,env), nth(y,env), nth(z,env))"
   911 by (simp add: image_fm_def Relative.image_def)
   912 
   913 lemma image_iff_sats:
   914       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   915           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   916        ==> image(**A, x, y, z) <-> sats(A, image_fm(i,j,k), env)"
   917 by (simp add: sats_image_fm)
   918 
   919 theorem image_reflection:
   920      "REFLECTS[\<lambda>x. image(L,f(x),g(x),h(x)), 
   921                \<lambda>i x. image(**Lset(i),f(x),g(x),h(x))]"
   922 apply (simp only: Relative.image_def setclass_simps)
   923 apply (intro FOL_reflections pair_reflection)  
   924 done
   925 
   926 
   927 subsubsection{*Pre-Image under a Relation, Internalized*}
   928 
   929 (* "pre_image(M,r,A,z) == 
   930 	\<forall>x[M]. x \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>y[M]. y\<in>A & pair(M,x,y,w)))" *)
   931 constdefs pre_image_fm :: "[i,i,i]=>i"
   932     "pre_image_fm(r,A,z) == 
   933        Forall(Iff(Member(0,succ(z)),
   934                   Exists(And(Member(0,succ(succ(r))),
   935                              Exists(And(Member(0,succ(succ(succ(A)))),
   936 	 			        pair_fm(2,0,1)))))))"
   937 
   938 lemma pre_image_type [TC]:
   939      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> pre_image_fm(x,y,z) \<in> formula"
   940 by (simp add: pre_image_fm_def) 
   941 
   942 lemma arity_pre_image_fm [simp]:
   943      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
   944       ==> arity(pre_image_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   945 by (simp add: pre_image_fm_def succ_Un_distrib [symmetric] Un_ac) 
   946 
   947 lemma sats_pre_image_fm [simp]:
   948    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   949     ==> sats(A, pre_image_fm(x,y,z), env) <-> 
   950         pre_image(**A, nth(x,env), nth(y,env), nth(z,env))"
   951 by (simp add: pre_image_fm_def Relative.pre_image_def)
   952 
   953 lemma pre_image_iff_sats:
   954       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   955           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   956        ==> pre_image(**A, x, y, z) <-> sats(A, pre_image_fm(i,j,k), env)"
   957 by (simp add: sats_pre_image_fm)
   958 
   959 theorem pre_image_reflection:
   960      "REFLECTS[\<lambda>x. pre_image(L,f(x),g(x),h(x)), 
   961                \<lambda>i x. pre_image(**Lset(i),f(x),g(x),h(x))]"
   962 apply (simp only: Relative.pre_image_def setclass_simps)
   963 apply (intro FOL_reflections pair_reflection)  
   964 done
   965 
   966 
   967 subsubsection{*Function Application, Internalized*}
   968 
   969 (* "fun_apply(M,f,x,y) == 
   970         (\<exists>xs[M]. \<exists>fxs[M]. 
   971          upair(M,x,x,xs) & image(M,f,xs,fxs) & big_union(M,fxs,y))" *)
   972 constdefs fun_apply_fm :: "[i,i,i]=>i"
   973     "fun_apply_fm(f,x,y) == 
   974        Exists(Exists(And(upair_fm(succ(succ(x)), succ(succ(x)), 1),
   975                          And(image_fm(succ(succ(f)), 1, 0), 
   976                              big_union_fm(0,succ(succ(y)))))))"
   977 
   978 lemma fun_apply_type [TC]:
   979      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> fun_apply_fm(x,y,z) \<in> formula"
   980 by (simp add: fun_apply_fm_def) 
   981 
   982 lemma arity_fun_apply_fm [simp]:
   983      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
   984       ==> arity(fun_apply_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
   985 by (simp add: fun_apply_fm_def succ_Un_distrib [symmetric] Un_ac) 
   986 
   987 lemma sats_fun_apply_fm [simp]:
   988    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
   989     ==> sats(A, fun_apply_fm(x,y,z), env) <-> 
   990         fun_apply(**A, nth(x,env), nth(y,env), nth(z,env))"
   991 by (simp add: fun_apply_fm_def fun_apply_def)
   992 
   993 lemma fun_apply_iff_sats:
   994       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
   995           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
   996        ==> fun_apply(**A, x, y, z) <-> sats(A, fun_apply_fm(i,j,k), env)"
   997 by simp
   998 
   999 theorem fun_apply_reflection:
  1000      "REFLECTS[\<lambda>x. fun_apply(L,f(x),g(x),h(x)), 
  1001                \<lambda>i x. fun_apply(**Lset(i),f(x),g(x),h(x))]" 
  1002 apply (simp only: fun_apply_def setclass_simps)
  1003 apply (intro FOL_reflections upair_reflection image_reflection
  1004              big_union_reflection)  
  1005 done
  1006 
  1007 
  1008 subsubsection{*The Concept of Relation, Internalized*}
  1009 
  1010 (* "is_relation(M,r) == 
  1011         (\<forall>z[M]. z\<in>r --> (\<exists>x[M]. \<exists>y[M]. pair(M,x,y,z)))" *)
  1012 constdefs relation_fm :: "i=>i"
  1013     "relation_fm(r) == 
  1014        Forall(Implies(Member(0,succ(r)), Exists(Exists(pair_fm(1,0,2)))))"
  1015 
  1016 lemma relation_type [TC]:
  1017      "[| x \<in> nat |] ==> relation_fm(x) \<in> formula"
  1018 by (simp add: relation_fm_def) 
  1019 
  1020 lemma arity_relation_fm [simp]:
  1021      "x \<in> nat ==> arity(relation_fm(x)) = succ(x)"
  1022 by (simp add: relation_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1023 
  1024 lemma sats_relation_fm [simp]:
  1025    "[| x \<in> nat; env \<in> list(A)|]
  1026     ==> sats(A, relation_fm(x), env) <-> is_relation(**A, nth(x,env))"
  1027 by (simp add: relation_fm_def is_relation_def)
  1028 
  1029 lemma relation_iff_sats:
  1030       "[| nth(i,env) = x; nth(j,env) = y; 
  1031           i \<in> nat; env \<in> list(A)|]
  1032        ==> is_relation(**A, x) <-> sats(A, relation_fm(i), env)"
  1033 by simp
  1034 
  1035 theorem is_relation_reflection:
  1036      "REFLECTS[\<lambda>x. is_relation(L,f(x)), 
  1037                \<lambda>i x. is_relation(**Lset(i),f(x))]"
  1038 apply (simp only: is_relation_def setclass_simps)
  1039 apply (intro FOL_reflections pair_reflection)  
  1040 done
  1041 
  1042 
  1043 subsubsection{*The Concept of Function, Internalized*}
  1044 
  1045 (* "is_function(M,r) == 
  1046 	\<forall>x[M]. \<forall>y[M]. \<forall>y'[M]. \<forall>p[M]. \<forall>p'[M]. 
  1047            pair(M,x,y,p) --> pair(M,x,y',p') --> p\<in>r --> p'\<in>r --> y=y'" *)
  1048 constdefs function_fm :: "i=>i"
  1049     "function_fm(r) == 
  1050        Forall(Forall(Forall(Forall(Forall(
  1051          Implies(pair_fm(4,3,1),
  1052                  Implies(pair_fm(4,2,0),
  1053                          Implies(Member(1,r#+5),
  1054                                  Implies(Member(0,r#+5), Equal(3,2))))))))))"
  1055 
  1056 lemma function_type [TC]:
  1057      "[| x \<in> nat |] ==> function_fm(x) \<in> formula"
  1058 by (simp add: function_fm_def) 
  1059 
  1060 lemma arity_function_fm [simp]:
  1061      "x \<in> nat ==> arity(function_fm(x)) = succ(x)"
  1062 by (simp add: function_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1063 
  1064 lemma sats_function_fm [simp]:
  1065    "[| x \<in> nat; env \<in> list(A)|]
  1066     ==> sats(A, function_fm(x), env) <-> is_function(**A, nth(x,env))"
  1067 by (simp add: function_fm_def is_function_def)
  1068 
  1069 lemma function_iff_sats:
  1070       "[| nth(i,env) = x; nth(j,env) = y; 
  1071           i \<in> nat; env \<in> list(A)|]
  1072        ==> is_function(**A, x) <-> sats(A, function_fm(i), env)"
  1073 by simp
  1074 
  1075 theorem is_function_reflection:
  1076      "REFLECTS[\<lambda>x. is_function(L,f(x)), 
  1077                \<lambda>i x. is_function(**Lset(i),f(x))]"
  1078 apply (simp only: is_function_def setclass_simps)
  1079 apply (intro FOL_reflections pair_reflection)  
  1080 done
  1081 
  1082 
  1083 subsubsection{*Typed Functions, Internalized*}
  1084 
  1085 (* "typed_function(M,A,B,r) == 
  1086         is_function(M,r) & is_relation(M,r) & is_domain(M,r,A) &
  1087         (\<forall>u[M]. u\<in>r --> (\<forall>x[M]. \<forall>y[M]. pair(M,x,y,u) --> y\<in>B))" *)
  1088 
  1089 constdefs typed_function_fm :: "[i,i,i]=>i"
  1090     "typed_function_fm(A,B,r) == 
  1091        And(function_fm(r),
  1092          And(relation_fm(r),
  1093            And(domain_fm(r,A),
  1094              Forall(Implies(Member(0,succ(r)),
  1095                   Forall(Forall(Implies(pair_fm(1,0,2),Member(0,B#+3)))))))))"
  1096 
  1097 lemma typed_function_type [TC]:
  1098      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> typed_function_fm(x,y,z) \<in> formula"
  1099 by (simp add: typed_function_fm_def) 
  1100 
  1101 lemma arity_typed_function_fm [simp]:
  1102      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
  1103       ==> arity(typed_function_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
  1104 by (simp add: typed_function_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1105 
  1106 lemma sats_typed_function_fm [simp]:
  1107    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
  1108     ==> sats(A, typed_function_fm(x,y,z), env) <-> 
  1109         typed_function(**A, nth(x,env), nth(y,env), nth(z,env))"
  1110 by (simp add: typed_function_fm_def typed_function_def)
  1111 
  1112 lemma typed_function_iff_sats:
  1113   "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
  1114       i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
  1115    ==> typed_function(**A, x, y, z) <-> sats(A, typed_function_fm(i,j,k), env)"
  1116 by simp
  1117 
  1118 lemmas function_reflections = 
  1119         empty_reflection number1_reflection
  1120 	upair_reflection pair_reflection union_reflection
  1121 	big_union_reflection cons_reflection successor_reflection 
  1122         fun_apply_reflection subset_reflection
  1123 	transitive_set_reflection membership_reflection
  1124 	pred_set_reflection domain_reflection range_reflection field_reflection
  1125         image_reflection pre_image_reflection
  1126 	is_relation_reflection is_function_reflection
  1127 
  1128 lemmas function_iff_sats = 
  1129         empty_iff_sats number1_iff_sats 
  1130 	upair_iff_sats pair_iff_sats union_iff_sats
  1131 	cons_iff_sats successor_iff_sats
  1132         fun_apply_iff_sats  Memrel_iff_sats
  1133 	pred_set_iff_sats domain_iff_sats range_iff_sats field_iff_sats
  1134         image_iff_sats pre_image_iff_sats 
  1135 	relation_iff_sats function_iff_sats
  1136 
  1137 
  1138 theorem typed_function_reflection:
  1139      "REFLECTS[\<lambda>x. typed_function(L,f(x),g(x),h(x)), 
  1140                \<lambda>i x. typed_function(**Lset(i),f(x),g(x),h(x))]"
  1141 apply (simp only: typed_function_def setclass_simps)
  1142 apply (intro FOL_reflections function_reflections)  
  1143 done
  1144 
  1145 
  1146 subsubsection{*Composition of Relations, Internalized*}
  1147 
  1148 (* "composition(M,r,s,t) == 
  1149         \<forall>p[M]. p \<in> t <-> 
  1150                (\<exists>x[M]. \<exists>y[M]. \<exists>z[M]. \<exists>xy[M]. \<exists>yz[M]. 
  1151                 pair(M,x,z,p) & pair(M,x,y,xy) & pair(M,y,z,yz) & 
  1152                 xy \<in> s & yz \<in> r)" *)
  1153 constdefs composition_fm :: "[i,i,i]=>i"
  1154   "composition_fm(r,s,t) == 
  1155      Forall(Iff(Member(0,succ(t)),
  1156              Exists(Exists(Exists(Exists(Exists( 
  1157               And(pair_fm(4,2,5),
  1158                And(pair_fm(4,3,1),
  1159                 And(pair_fm(3,2,0),
  1160                  And(Member(1,s#+6), Member(0,r#+6))))))))))))"
  1161 
  1162 lemma composition_type [TC]:
  1163      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> composition_fm(x,y,z) \<in> formula"
  1164 by (simp add: composition_fm_def) 
  1165 
  1166 lemma arity_composition_fm [simp]:
  1167      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
  1168       ==> arity(composition_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
  1169 by (simp add: composition_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1170 
  1171 lemma sats_composition_fm [simp]:
  1172    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
  1173     ==> sats(A, composition_fm(x,y,z), env) <-> 
  1174         composition(**A, nth(x,env), nth(y,env), nth(z,env))"
  1175 by (simp add: composition_fm_def composition_def)
  1176 
  1177 lemma composition_iff_sats:
  1178       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
  1179           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
  1180        ==> composition(**A, x, y, z) <-> sats(A, composition_fm(i,j,k), env)"
  1181 by simp
  1182 
  1183 theorem composition_reflection:
  1184      "REFLECTS[\<lambda>x. composition(L,f(x),g(x),h(x)), 
  1185                \<lambda>i x. composition(**Lset(i),f(x),g(x),h(x))]"
  1186 apply (simp only: composition_def setclass_simps)
  1187 apply (intro FOL_reflections pair_reflection)  
  1188 done
  1189 
  1190 
  1191 subsubsection{*Injections, Internalized*}
  1192 
  1193 (* "injection(M,A,B,f) == 
  1194 	typed_function(M,A,B,f) &
  1195         (\<forall>x[M]. \<forall>x'[M]. \<forall>y[M]. \<forall>p[M]. \<forall>p'[M]. 
  1196           pair(M,x,y,p) --> pair(M,x',y,p') --> p\<in>f --> p'\<in>f --> x=x')" *)
  1197 constdefs injection_fm :: "[i,i,i]=>i"
  1198  "injection_fm(A,B,f) == 
  1199     And(typed_function_fm(A,B,f),
  1200        Forall(Forall(Forall(Forall(Forall(
  1201          Implies(pair_fm(4,2,1),
  1202                  Implies(pair_fm(3,2,0),
  1203                          Implies(Member(1,f#+5),
  1204                                  Implies(Member(0,f#+5), Equal(4,3)))))))))))"
  1205 
  1206 
  1207 lemma injection_type [TC]:
  1208      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> injection_fm(x,y,z) \<in> formula"
  1209 by (simp add: injection_fm_def) 
  1210 
  1211 lemma arity_injection_fm [simp]:
  1212      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
  1213       ==> arity(injection_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
  1214 by (simp add: injection_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1215 
  1216 lemma sats_injection_fm [simp]:
  1217    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
  1218     ==> sats(A, injection_fm(x,y,z), env) <-> 
  1219         injection(**A, nth(x,env), nth(y,env), nth(z,env))"
  1220 by (simp add: injection_fm_def injection_def)
  1221 
  1222 lemma injection_iff_sats:
  1223   "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
  1224       i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
  1225    ==> injection(**A, x, y, z) <-> sats(A, injection_fm(i,j,k), env)"
  1226 by simp
  1227 
  1228 theorem injection_reflection:
  1229      "REFLECTS[\<lambda>x. injection(L,f(x),g(x),h(x)), 
  1230                \<lambda>i x. injection(**Lset(i),f(x),g(x),h(x))]"
  1231 apply (simp only: injection_def setclass_simps)
  1232 apply (intro FOL_reflections function_reflections typed_function_reflection)  
  1233 done
  1234 
  1235 
  1236 subsubsection{*Surjections, Internalized*}
  1237 
  1238 (*  surjection :: "[i=>o,i,i,i] => o"
  1239     "surjection(M,A,B,f) == 
  1240         typed_function(M,A,B,f) &
  1241         (\<forall>y[M]. y\<in>B --> (\<exists>x[M]. x\<in>A & fun_apply(M,f,x,y)))" *)
  1242 constdefs surjection_fm :: "[i,i,i]=>i"
  1243  "surjection_fm(A,B,f) == 
  1244     And(typed_function_fm(A,B,f),
  1245        Forall(Implies(Member(0,succ(B)),
  1246                       Exists(And(Member(0,succ(succ(A))),
  1247                                  fun_apply_fm(succ(succ(f)),0,1))))))"
  1248 
  1249 lemma surjection_type [TC]:
  1250      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> surjection_fm(x,y,z) \<in> formula"
  1251 by (simp add: surjection_fm_def) 
  1252 
  1253 lemma arity_surjection_fm [simp]:
  1254      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
  1255       ==> arity(surjection_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
  1256 by (simp add: surjection_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1257 
  1258 lemma sats_surjection_fm [simp]:
  1259    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
  1260     ==> sats(A, surjection_fm(x,y,z), env) <-> 
  1261         surjection(**A, nth(x,env), nth(y,env), nth(z,env))"
  1262 by (simp add: surjection_fm_def surjection_def)
  1263 
  1264 lemma surjection_iff_sats:
  1265   "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
  1266       i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
  1267    ==> surjection(**A, x, y, z) <-> sats(A, surjection_fm(i,j,k), env)"
  1268 by simp
  1269 
  1270 theorem surjection_reflection:
  1271      "REFLECTS[\<lambda>x. surjection(L,f(x),g(x),h(x)), 
  1272                \<lambda>i x. surjection(**Lset(i),f(x),g(x),h(x))]"
  1273 apply (simp only: surjection_def setclass_simps)
  1274 apply (intro FOL_reflections function_reflections typed_function_reflection)  
  1275 done
  1276 
  1277 
  1278 
  1279 subsubsection{*Bijections, Internalized*}
  1280 
  1281 (*   bijection :: "[i=>o,i,i,i] => o"
  1282     "bijection(M,A,B,f) == injection(M,A,B,f) & surjection(M,A,B,f)" *)
  1283 constdefs bijection_fm :: "[i,i,i]=>i"
  1284  "bijection_fm(A,B,f) == And(injection_fm(A,B,f), surjection_fm(A,B,f))"
  1285 
  1286 lemma bijection_type [TC]:
  1287      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> bijection_fm(x,y,z) \<in> formula"
  1288 by (simp add: bijection_fm_def) 
  1289 
  1290 lemma arity_bijection_fm [simp]:
  1291      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
  1292       ==> arity(bijection_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
  1293 by (simp add: bijection_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1294 
  1295 lemma sats_bijection_fm [simp]:
  1296    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
  1297     ==> sats(A, bijection_fm(x,y,z), env) <-> 
  1298         bijection(**A, nth(x,env), nth(y,env), nth(z,env))"
  1299 by (simp add: bijection_fm_def bijection_def)
  1300 
  1301 lemma bijection_iff_sats:
  1302   "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
  1303       i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
  1304    ==> bijection(**A, x, y, z) <-> sats(A, bijection_fm(i,j,k), env)"
  1305 by simp
  1306 
  1307 theorem bijection_reflection:
  1308      "REFLECTS[\<lambda>x. bijection(L,f(x),g(x),h(x)), 
  1309                \<lambda>i x. bijection(**Lset(i),f(x),g(x),h(x))]"
  1310 apply (simp only: bijection_def setclass_simps)
  1311 apply (intro And_reflection injection_reflection surjection_reflection)  
  1312 done
  1313 
  1314 
  1315 subsubsection{*Restriction of a Relation, Internalized*}
  1316 
  1317 
  1318 (* "restriction(M,r,A,z) == 
  1319 	\<forall>x[M]. x \<in> z <-> (x \<in> r & (\<exists>u[M]. u\<in>A & (\<exists>v[M]. pair(M,u,v,x))))" *)
  1320 constdefs restriction_fm :: "[i,i,i]=>i"
  1321     "restriction_fm(r,A,z) == 
  1322        Forall(Iff(Member(0,succ(z)),
  1323                   And(Member(0,succ(r)),
  1324                       Exists(And(Member(0,succ(succ(A))),
  1325                                  Exists(pair_fm(1,0,2)))))))"
  1326 
  1327 lemma restriction_type [TC]:
  1328      "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> restriction_fm(x,y,z) \<in> formula"
  1329 by (simp add: restriction_fm_def) 
  1330 
  1331 lemma arity_restriction_fm [simp]:
  1332      "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
  1333       ==> arity(restriction_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
  1334 by (simp add: restriction_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1335 
  1336 lemma sats_restriction_fm [simp]:
  1337    "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
  1338     ==> sats(A, restriction_fm(x,y,z), env) <-> 
  1339         restriction(**A, nth(x,env), nth(y,env), nth(z,env))"
  1340 by (simp add: restriction_fm_def restriction_def)
  1341 
  1342 lemma restriction_iff_sats:
  1343       "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
  1344           i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
  1345        ==> restriction(**A, x, y, z) <-> sats(A, restriction_fm(i,j,k), env)"
  1346 by simp
  1347 
  1348 theorem restriction_reflection:
  1349      "REFLECTS[\<lambda>x. restriction(L,f(x),g(x),h(x)), 
  1350                \<lambda>i x. restriction(**Lset(i),f(x),g(x),h(x))]"
  1351 apply (simp only: restriction_def setclass_simps)
  1352 apply (intro FOL_reflections pair_reflection)  
  1353 done
  1354 
  1355 subsubsection{*Order-Isomorphisms, Internalized*}
  1356 
  1357 (*  order_isomorphism :: "[i=>o,i,i,i,i,i] => o"
  1358    "order_isomorphism(M,A,r,B,s,f) == 
  1359         bijection(M,A,B,f) & 
  1360         (\<forall>x[M]. x\<in>A --> (\<forall>y[M]. y\<in>A -->
  1361           (\<forall>p[M]. \<forall>fx[M]. \<forall>fy[M]. \<forall>q[M].
  1362             pair(M,x,y,p) --> fun_apply(M,f,x,fx) --> fun_apply(M,f,y,fy) --> 
  1363             pair(M,fx,fy,q) --> (p\<in>r <-> q\<in>s))))"
  1364   *)
  1365 
  1366 constdefs order_isomorphism_fm :: "[i,i,i,i,i]=>i"
  1367  "order_isomorphism_fm(A,r,B,s,f) == 
  1368    And(bijection_fm(A,B,f), 
  1369      Forall(Implies(Member(0,succ(A)),
  1370        Forall(Implies(Member(0,succ(succ(A))),
  1371          Forall(Forall(Forall(Forall(
  1372            Implies(pair_fm(5,4,3),
  1373              Implies(fun_apply_fm(f#+6,5,2),
  1374                Implies(fun_apply_fm(f#+6,4,1),
  1375                  Implies(pair_fm(2,1,0), 
  1376                    Iff(Member(3,r#+6), Member(0,s#+6)))))))))))))))"
  1377 
  1378 lemma order_isomorphism_type [TC]:
  1379      "[| A \<in> nat; r \<in> nat; B \<in> nat; s \<in> nat; f \<in> nat |]  
  1380       ==> order_isomorphism_fm(A,r,B,s,f) \<in> formula"
  1381 by (simp add: order_isomorphism_fm_def) 
  1382 
  1383 lemma arity_order_isomorphism_fm [simp]:
  1384      "[| A \<in> nat; r \<in> nat; B \<in> nat; s \<in> nat; f \<in> nat |] 
  1385       ==> arity(order_isomorphism_fm(A,r,B,s,f)) = 
  1386           succ(A) \<union> succ(r) \<union> succ(B) \<union> succ(s) \<union> succ(f)" 
  1387 by (simp add: order_isomorphism_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1388 
  1389 lemma sats_order_isomorphism_fm [simp]:
  1390    "[| U \<in> nat; r \<in> nat; B \<in> nat; s \<in> nat; f \<in> nat; env \<in> list(A)|]
  1391     ==> sats(A, order_isomorphism_fm(U,r,B,s,f), env) <-> 
  1392         order_isomorphism(**A, nth(U,env), nth(r,env), nth(B,env), 
  1393                                nth(s,env), nth(f,env))"
  1394 by (simp add: order_isomorphism_fm_def order_isomorphism_def)
  1395 
  1396 lemma order_isomorphism_iff_sats:
  1397   "[| nth(i,env) = U; nth(j,env) = r; nth(k,env) = B; nth(j',env) = s; 
  1398       nth(k',env) = f; 
  1399       i \<in> nat; j \<in> nat; k \<in> nat; j' \<in> nat; k' \<in> nat; env \<in> list(A)|]
  1400    ==> order_isomorphism(**A,U,r,B,s,f) <-> 
  1401        sats(A, order_isomorphism_fm(i,j,k,j',k'), env)" 
  1402 by simp
  1403 
  1404 theorem order_isomorphism_reflection:
  1405      "REFLECTS[\<lambda>x. order_isomorphism(L,f(x),g(x),h(x),g'(x),h'(x)), 
  1406                \<lambda>i x. order_isomorphism(**Lset(i),f(x),g(x),h(x),g'(x),h'(x))]"
  1407 apply (simp only: order_isomorphism_def setclass_simps)
  1408 apply (intro FOL_reflections function_reflections bijection_reflection)  
  1409 done
  1410 
  1411 subsubsection{*Limit Ordinals, Internalized*}
  1412 
  1413 text{*A limit ordinal is a non-empty, successor-closed ordinal*}
  1414 
  1415 (* "limit_ordinal(M,a) == 
  1416 	ordinal(M,a) & ~ empty(M,a) & 
  1417         (\<forall>x[M]. x\<in>a --> (\<exists>y[M]. y\<in>a & successor(M,x,y)))" *)
  1418 
  1419 constdefs limit_ordinal_fm :: "i=>i"
  1420     "limit_ordinal_fm(x) == 
  1421         And(ordinal_fm(x),
  1422             And(Neg(empty_fm(x)),
  1423 	        Forall(Implies(Member(0,succ(x)),
  1424                                Exists(And(Member(0,succ(succ(x))),
  1425                                           succ_fm(1,0)))))))"
  1426 
  1427 lemma limit_ordinal_type [TC]:
  1428      "x \<in> nat ==> limit_ordinal_fm(x) \<in> formula"
  1429 by (simp add: limit_ordinal_fm_def) 
  1430 
  1431 lemma arity_limit_ordinal_fm [simp]:
  1432      "x \<in> nat ==> arity(limit_ordinal_fm(x)) = succ(x)"
  1433 by (simp add: limit_ordinal_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1434 
  1435 lemma sats_limit_ordinal_fm [simp]:
  1436    "[| x \<in> nat; env \<in> list(A)|]
  1437     ==> sats(A, limit_ordinal_fm(x), env) <-> limit_ordinal(**A, nth(x,env))"
  1438 by (simp add: limit_ordinal_fm_def limit_ordinal_def sats_ordinal_fm')
  1439 
  1440 lemma limit_ordinal_iff_sats:
  1441       "[| nth(i,env) = x; nth(j,env) = y; 
  1442           i \<in> nat; env \<in> list(A)|]
  1443        ==> limit_ordinal(**A, x) <-> sats(A, limit_ordinal_fm(i), env)"
  1444 by simp
  1445 
  1446 theorem limit_ordinal_reflection:
  1447      "REFLECTS[\<lambda>x. limit_ordinal(L,f(x)), 
  1448                \<lambda>i x. limit_ordinal(**Lset(i),f(x))]"
  1449 apply (simp only: limit_ordinal_def setclass_simps)
  1450 apply (intro FOL_reflections ordinal_reflection 
  1451              empty_reflection successor_reflection)  
  1452 done
  1453 
  1454 subsubsection{*Omega: The Set of Natural Numbers*}
  1455 
  1456 (* omega(M,a) == limit_ordinal(M,a) & (\<forall>x[M]. x\<in>a --> ~ limit_ordinal(M,x)) *)
  1457 constdefs omega_fm :: "i=>i"
  1458     "omega_fm(x) == 
  1459        And(limit_ordinal_fm(x),
  1460            Forall(Implies(Member(0,succ(x)),
  1461                           Neg(limit_ordinal_fm(0)))))"
  1462 
  1463 lemma omega_type [TC]:
  1464      "x \<in> nat ==> omega_fm(x) \<in> formula"
  1465 by (simp add: omega_fm_def) 
  1466 
  1467 lemma arity_omega_fm [simp]:
  1468      "x \<in> nat ==> arity(omega_fm(x)) = succ(x)"
  1469 by (simp add: omega_fm_def succ_Un_distrib [symmetric] Un_ac) 
  1470 
  1471 lemma sats_omega_fm [simp]:
  1472    "[| x \<in> nat; env \<in> list(A)|]
  1473     ==> sats(A, omega_fm(x), env) <-> omega(**A, nth(x,env))"
  1474 by (simp add: omega_fm_def omega_def)
  1475 
  1476 lemma omega_iff_sats:
  1477       "[| nth(i,env) = x; nth(j,env) = y; 
  1478           i \<in> nat; env \<in> list(A)|]
  1479        ==> omega(**A, x) <-> sats(A, omega_fm(i), env)"
  1480 by simp
  1481 
  1482 theorem omega_reflection:
  1483      "REFLECTS[\<lambda>x. omega(L,f(x)), 
  1484                \<lambda>i x. omega(**Lset(i),f(x))]"
  1485 apply (simp only: omega_def setclass_simps)
  1486 apply (intro FOL_reflections limit_ordinal_reflection)  
  1487 done
  1488 
  1489 
  1490 lemmas fun_plus_reflections =
  1491         typed_function_reflection composition_reflection
  1492         injection_reflection surjection_reflection
  1493         bijection_reflection restriction_reflection
  1494         order_isomorphism_reflection
  1495         ordinal_reflection limit_ordinal_reflection omega_reflection
  1496 
  1497 lemmas fun_plus_iff_sats = 
  1498 	typed_function_iff_sats composition_iff_sats
  1499         injection_iff_sats surjection_iff_sats 
  1500         bijection_iff_sats restriction_iff_sats 
  1501         order_isomorphism_iff_sats
  1502         ordinal_iff_sats limit_ordinal_iff_sats omega_iff_sats
  1503 
  1504 end