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