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