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