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