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