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