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