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