src/ZF/Constructible/L_axioms.thy
author paulson
Fri Jul 05 18:33:50 2002 +0200 (2002-07-05)
changeset 13306 6eebcddee32b
parent 13304 43ef6c6dd906
child 13309 a6adee8ea75a
permissions -rw-r--r--
more internalized formulas and separation proofs
paulson@13306
     1
header {*The Class L Satisfies the ZF Axioms*}
paulson@13223
     2
paulson@13269
     3
theory L_axioms = Formula + Relative + Reflection:
paulson@13223
     4
paulson@13223
     5
paulson@13223
     6
text {* The class L satisfies the premises of locale @{text M_axioms} *}
paulson@13223
     7
paulson@13223
     8
lemma transL: "[| y\<in>x; L(x) |] ==> L(y)"
paulson@13223
     9
apply (insert Transset_Lset) 
paulson@13223
    10
apply (simp add: Transset_def L_def, blast) 
paulson@13223
    11
done
paulson@13223
    12
paulson@13223
    13
lemma nonempty: "L(0)"
paulson@13223
    14
apply (simp add: L_def) 
paulson@13223
    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)
paulson@13299
    20
apply (rule_tac x="{x,y}" in rexI)  
paulson@13299
    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)
paulson@13299
    26
apply (rule_tac x="Union(x)" in rexI)  
paulson@13299
    27
apply (simp_all add: Union_in_L, auto) 
paulson@13223
    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)
paulson@13299
    33
apply (rule_tac x="{y \<in> Pow(x). L(y)}" in rexI)  
paulson@13299
    34
apply (simp_all add: LPow_in_L, auto)
paulson@13223
    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:
paulson@13223
    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)"
paulson@13223
    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
paulson@13223
    49
apply clarify 
paulson@13223
    50
apply (rule_tac a="x" in UN_I)  
paulson@13223
    51
 apply (simp_all add: Replace_iff univalent_def) 
paulson@13223
    52
apply (blast dest: transL L_I) 
paulson@13223
    53
done
paulson@13223
    54
paulson@13223
    55
lemma LReplace_in_L: 
paulson@13223
    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"
paulson@13223
    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)
paulson@13268
    65
apply (frule LReplace_in_L, assumption+, clarify) 
paulson@13299
    66
apply (rule_tac x=Y in rexI)   
paulson@13299
    67
apply (simp_all add: Replace_iff univalent_def, blast) 
paulson@13223
    68
done
paulson@13223
    69
paulson@13291
    70
subsection{*Instantiation of the locale @{text M_triv_axioms}*}
paulson@13291
    71
paulson@13291
    72
lemma Lset_mono_le: "mono_le_subset(Lset)"
paulson@13291
    73
by (simp add: mono_le_subset_def le_imp_subset Lset_mono) 
paulson@13291
    74
paulson@13291
    75
lemma Lset_cont: "cont_Ord(Lset)"
paulson@13291
    76
by (simp add: cont_Ord_def Limit_Lset_eq OUnion_def Limit_is_Ord) 
paulson@13291
    77
paulson@13291
    78
lemmas Pair_in_Lset = Formula.Pair_in_LLimit;
paulson@13291
    79
paulson@13291
    80
lemmas L_nat = Ord_in_L [OF Ord_nat];
paulson@13291
    81
paulson@13291
    82
ML
paulson@13291
    83
{*
paulson@13291
    84
val transL = thm "transL";
paulson@13291
    85
val nonempty = thm "nonempty";
paulson@13291
    86
val upair_ax = thm "upair_ax";
paulson@13291
    87
val Union_ax = thm "Union_ax";
paulson@13291
    88
val power_ax = thm "power_ax";
paulson@13291
    89
val replacement = thm "replacement";
paulson@13291
    90
val L_nat = thm "L_nat";
paulson@13291
    91
paulson@13291
    92
fun kill_flex_triv_prems st = Seq.hd ((REPEAT_FIRST assume_tac) st);
paulson@13291
    93
paulson@13291
    94
fun trivaxL th =
paulson@13291
    95
    kill_flex_triv_prems 
paulson@13291
    96
       ([transL, nonempty, upair_ax, Union_ax, power_ax, replacement, L_nat] 
paulson@13291
    97
        MRS (inst "M" "L" th));
paulson@13291
    98
paulson@13291
    99
bind_thm ("ball_abs", trivaxL (thm "M_triv_axioms.ball_abs"));
paulson@13291
   100
bind_thm ("rall_abs", trivaxL (thm "M_triv_axioms.rall_abs"));
paulson@13291
   101
bind_thm ("bex_abs", trivaxL (thm "M_triv_axioms.bex_abs"));
paulson@13291
   102
bind_thm ("rex_abs", trivaxL (thm "M_triv_axioms.rex_abs"));
paulson@13291
   103
bind_thm ("ball_iff_equiv", trivaxL (thm "M_triv_axioms.ball_iff_equiv"));
paulson@13291
   104
bind_thm ("M_equalityI", trivaxL (thm "M_triv_axioms.M_equalityI"));
paulson@13291
   105
bind_thm ("empty_abs", trivaxL (thm "M_triv_axioms.empty_abs"));
paulson@13291
   106
bind_thm ("subset_abs", trivaxL (thm "M_triv_axioms.subset_abs"));
paulson@13291
   107
bind_thm ("upair_abs", trivaxL (thm "M_triv_axioms.upair_abs"));
paulson@13291
   108
bind_thm ("upair_in_M_iff", trivaxL (thm "M_triv_axioms.upair_in_M_iff"));
paulson@13291
   109
bind_thm ("singleton_in_M_iff", trivaxL (thm "M_triv_axioms.singleton_in_M_iff"));
paulson@13291
   110
bind_thm ("pair_abs", trivaxL (thm "M_triv_axioms.pair_abs"));
paulson@13291
   111
bind_thm ("pair_in_M_iff", trivaxL (thm "M_triv_axioms.pair_in_M_iff"));
paulson@13291
   112
bind_thm ("pair_components_in_M", trivaxL (thm "M_triv_axioms.pair_components_in_M"));
paulson@13291
   113
bind_thm ("cartprod_abs", trivaxL (thm "M_triv_axioms.cartprod_abs"));
paulson@13291
   114
bind_thm ("union_abs", trivaxL (thm "M_triv_axioms.union_abs"));
paulson@13291
   115
bind_thm ("inter_abs", trivaxL (thm "M_triv_axioms.inter_abs"));
paulson@13291
   116
bind_thm ("setdiff_abs", trivaxL (thm "M_triv_axioms.setdiff_abs"));
paulson@13291
   117
bind_thm ("Union_abs", trivaxL (thm "M_triv_axioms.Union_abs"));
paulson@13291
   118
bind_thm ("Union_closed", trivaxL (thm "M_triv_axioms.Union_closed"));
paulson@13291
   119
bind_thm ("Un_closed", trivaxL (thm "M_triv_axioms.Un_closed"));
paulson@13291
   120
bind_thm ("cons_closed", trivaxL (thm "M_triv_axioms.cons_closed"));
paulson@13291
   121
bind_thm ("successor_abs", trivaxL (thm "M_triv_axioms.successor_abs"));
paulson@13291
   122
bind_thm ("succ_in_M_iff", trivaxL (thm "M_triv_axioms.succ_in_M_iff"));
paulson@13291
   123
bind_thm ("separation_closed", trivaxL (thm "M_triv_axioms.separation_closed"));
paulson@13291
   124
bind_thm ("strong_replacementI", trivaxL (thm "M_triv_axioms.strong_replacementI"));
paulson@13291
   125
bind_thm ("strong_replacement_closed", trivaxL (thm "M_triv_axioms.strong_replacement_closed"));
paulson@13291
   126
bind_thm ("RepFun_closed", trivaxL (thm "M_triv_axioms.RepFun_closed"));
paulson@13291
   127
bind_thm ("lam_closed", trivaxL (thm "M_triv_axioms.lam_closed"));
paulson@13291
   128
bind_thm ("image_abs", trivaxL (thm "M_triv_axioms.image_abs"));
paulson@13291
   129
bind_thm ("powerset_Pow", trivaxL (thm "M_triv_axioms.powerset_Pow"));
paulson@13291
   130
bind_thm ("powerset_imp_subset_Pow", trivaxL (thm "M_triv_axioms.powerset_imp_subset_Pow"));
paulson@13291
   131
bind_thm ("nat_into_M", trivaxL (thm "M_triv_axioms.nat_into_M"));
paulson@13291
   132
bind_thm ("nat_case_closed", trivaxL (thm "M_triv_axioms.nat_case_closed"));
paulson@13291
   133
bind_thm ("Inl_in_M_iff", trivaxL (thm "M_triv_axioms.Inl_in_M_iff"));
paulson@13291
   134
bind_thm ("Inr_in_M_iff", trivaxL (thm "M_triv_axioms.Inr_in_M_iff"));
paulson@13291
   135
bind_thm ("lt_closed", trivaxL (thm "M_triv_axioms.lt_closed"));
paulson@13291
   136
bind_thm ("transitive_set_abs", trivaxL (thm "M_triv_axioms.transitive_set_abs"));
paulson@13291
   137
bind_thm ("ordinal_abs", trivaxL (thm "M_triv_axioms.ordinal_abs"));
paulson@13291
   138
bind_thm ("limit_ordinal_abs", trivaxL (thm "M_triv_axioms.limit_ordinal_abs"));
paulson@13291
   139
bind_thm ("successor_ordinal_abs", trivaxL (thm "M_triv_axioms.successor_ordinal_abs"));
paulson@13291
   140
bind_thm ("finite_ordinal_abs", trivaxL (thm "M_triv_axioms.finite_ordinal_abs"));
paulson@13291
   141
bind_thm ("omega_abs", trivaxL (thm "M_triv_axioms.omega_abs"));
paulson@13291
   142
bind_thm ("number1_abs", trivaxL (thm "M_triv_axioms.number1_abs"));
paulson@13291
   143
bind_thm ("number1_abs", trivaxL (thm "M_triv_axioms.number1_abs"));
paulson@13291
   144
bind_thm ("number3_abs", trivaxL (thm "M_triv_axioms.number3_abs"));
paulson@13291
   145
*}
paulson@13291
   146
paulson@13291
   147
declare ball_abs [simp] 
paulson@13291
   148
declare rall_abs [simp] 
paulson@13291
   149
declare bex_abs [simp] 
paulson@13291
   150
declare rex_abs [simp] 
paulson@13291
   151
declare empty_abs [simp] 
paulson@13291
   152
declare subset_abs [simp] 
paulson@13291
   153
declare upair_abs [simp] 
paulson@13291
   154
declare upair_in_M_iff [iff]
paulson@13291
   155
declare singleton_in_M_iff [iff]
paulson@13291
   156
declare pair_abs [simp] 
paulson@13291
   157
declare pair_in_M_iff [iff]
paulson@13291
   158
declare cartprod_abs [simp] 
paulson@13291
   159
declare union_abs [simp] 
paulson@13291
   160
declare inter_abs [simp] 
paulson@13291
   161
declare setdiff_abs [simp] 
paulson@13291
   162
declare Union_abs [simp] 
paulson@13291
   163
declare Union_closed [intro,simp]
paulson@13291
   164
declare Un_closed [intro,simp]
paulson@13291
   165
declare cons_closed [intro,simp]
paulson@13291
   166
declare successor_abs [simp] 
paulson@13291
   167
declare succ_in_M_iff [iff]
paulson@13291
   168
declare separation_closed [intro,simp]
paulson@13306
   169
declare strong_replacementI
paulson@13291
   170
declare strong_replacement_closed [intro,simp]
paulson@13291
   171
declare RepFun_closed [intro,simp]
paulson@13291
   172
declare lam_closed [intro,simp]
paulson@13291
   173
declare image_abs [simp] 
paulson@13291
   174
declare nat_into_M [intro]
paulson@13291
   175
declare Inl_in_M_iff [iff]
paulson@13291
   176
declare Inr_in_M_iff [iff]
paulson@13291
   177
declare transitive_set_abs [simp] 
paulson@13291
   178
declare ordinal_abs [simp] 
paulson@13291
   179
declare limit_ordinal_abs [simp] 
paulson@13291
   180
declare successor_ordinal_abs [simp] 
paulson@13291
   181
declare finite_ordinal_abs [simp] 
paulson@13291
   182
declare omega_abs [simp] 
paulson@13291
   183
declare number1_abs [simp] 
paulson@13291
   184
declare number1_abs [simp] 
paulson@13291
   185
declare number3_abs [simp]
paulson@13291
   186
paulson@13291
   187
paulson@13291
   188
subsection{*Instantiation of the locale @{text reflection}*}
paulson@13291
   189
paulson@13291
   190
text{*instances of locale constants*}
paulson@13291
   191
constdefs
paulson@13291
   192
  L_Reflects :: "[i=>o,i=>o,[i,i]=>o] => o"
paulson@13291
   193
    "L_Reflects(Cl,P,Q) == Closed_Unbounded(Cl) &
paulson@13291
   194
                           (\<forall>a. Cl(a) --> (\<forall>x \<in> Lset(a). P(x) <-> Q(a,x)))"
paulson@13291
   195
paulson@13291
   196
  L_F0 :: "[i=>o,i] => i"
paulson@13291
   197
    "L_F0(P,y) == \<mu>b. (\<exists>z. L(z) \<and> P(<y,z>)) --> (\<exists>z\<in>Lset(b). P(<y,z>))"
paulson@13291
   198
paulson@13291
   199
  L_FF :: "[i=>o,i] => i"
paulson@13291
   200
    "L_FF(P)   == \<lambda>a. \<Union>y\<in>Lset(a). L_F0(P,y)"
paulson@13291
   201
paulson@13291
   202
  L_ClEx :: "[i=>o,i] => o"
paulson@13291
   203
    "L_ClEx(P) == \<lambda>a. Limit(a) \<and> normalize(L_FF(P),a) = a"
paulson@13291
   204
paulson@13291
   205
theorem Triv_reflection [intro]:
paulson@13291
   206
     "L_Reflects(Ord, P, \<lambda>a x. P(x))"
paulson@13291
   207
by (simp add: L_Reflects_def)
paulson@13291
   208
paulson@13291
   209
theorem Not_reflection [intro]:
paulson@13291
   210
     "L_Reflects(Cl,P,Q) ==> L_Reflects(Cl, \<lambda>x. ~P(x), \<lambda>a x. ~Q(a,x))"
paulson@13291
   211
by (simp add: L_Reflects_def) 
paulson@13291
   212
paulson@13291
   213
theorem And_reflection [intro]:
paulson@13291
   214
     "[| L_Reflects(Cl,P,Q); L_Reflects(C',P',Q') |] 
paulson@13291
   215
      ==> L_Reflects(\<lambda>a. Cl(a) \<and> C'(a), \<lambda>x. P(x) \<and> P'(x), 
paulson@13291
   216
                                      \<lambda>a x. Q(a,x) \<and> Q'(a,x))"
paulson@13291
   217
by (simp add: L_Reflects_def Closed_Unbounded_Int, blast)
paulson@13291
   218
paulson@13291
   219
theorem Or_reflection [intro]:
paulson@13291
   220
     "[| L_Reflects(Cl,P,Q); L_Reflects(C',P',Q') |] 
paulson@13291
   221
      ==> L_Reflects(\<lambda>a. Cl(a) \<and> C'(a), \<lambda>x. P(x) \<or> P'(x), 
paulson@13291
   222
                                      \<lambda>a x. Q(a,x) \<or> Q'(a,x))"
paulson@13291
   223
by (simp add: L_Reflects_def Closed_Unbounded_Int, blast)
paulson@13291
   224
paulson@13291
   225
theorem Imp_reflection [intro]:
paulson@13291
   226
     "[| L_Reflects(Cl,P,Q); L_Reflects(C',P',Q') |] 
paulson@13291
   227
      ==> L_Reflects(\<lambda>a. Cl(a) \<and> C'(a), 
paulson@13291
   228
                   \<lambda>x. P(x) --> P'(x), 
paulson@13291
   229
                   \<lambda>a x. Q(a,x) --> Q'(a,x))"
paulson@13291
   230
by (simp add: L_Reflects_def Closed_Unbounded_Int, blast)
paulson@13291
   231
paulson@13291
   232
theorem Iff_reflection [intro]:
paulson@13291
   233
     "[| L_Reflects(Cl,P,Q); L_Reflects(C',P',Q') |] 
paulson@13291
   234
      ==> L_Reflects(\<lambda>a. Cl(a) \<and> C'(a), 
paulson@13291
   235
                   \<lambda>x. P(x) <-> P'(x), 
paulson@13291
   236
                   \<lambda>a x. Q(a,x) <-> Q'(a,x))"
paulson@13291
   237
by (simp add: L_Reflects_def Closed_Unbounded_Int, blast) 
paulson@13291
   238
paulson@13291
   239
paulson@13291
   240
theorem Ex_reflection [intro]:
paulson@13291
   241
     "L_Reflects(Cl, \<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))) 
paulson@13291
   242
      ==> L_Reflects(\<lambda>a. Cl(a) \<and> L_ClEx(\<lambda>x. P(fst(x),snd(x)), a), 
paulson@13291
   243
                   \<lambda>x. \<exists>z. L(z) \<and> P(x,z), 
paulson@13291
   244
                   \<lambda>a x. \<exists>z\<in>Lset(a). Q(a,x,z))"
paulson@13291
   245
apply (unfold L_Reflects_def L_ClEx_def L_FF_def L_F0_def L_def) 
paulson@13291
   246
apply (rule reflection.Ex_reflection [OF Lset_mono_le Lset_cont Pair_in_Lset],
paulson@13291
   247
       assumption+)
paulson@13291
   248
done
paulson@13291
   249
paulson@13291
   250
theorem All_reflection [intro]:
paulson@13291
   251
     "L_Reflects(Cl,  \<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x)))
paulson@13291
   252
      ==> L_Reflects(\<lambda>a. Cl(a) \<and> L_ClEx(\<lambda>x. ~P(fst(x),snd(x)), a), 
paulson@13291
   253
                   \<lambda>x. \<forall>z. L(z) --> P(x,z), 
paulson@13291
   254
                   \<lambda>a x. \<forall>z\<in>Lset(a). Q(a,x,z))" 
paulson@13291
   255
apply (unfold L_Reflects_def L_ClEx_def L_FF_def L_F0_def L_def) 
paulson@13291
   256
apply (rule reflection.All_reflection [OF Lset_mono_le Lset_cont Pair_in_Lset],
paulson@13291
   257
       assumption+)
paulson@13291
   258
done
paulson@13291
   259
paulson@13291
   260
theorem Rex_reflection [intro]:
paulson@13291
   261
     "L_Reflects(Cl, \<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))) 
paulson@13291
   262
      ==> L_Reflects(\<lambda>a. Cl(a) \<and> L_ClEx(\<lambda>x. P(fst(x),snd(x)), a), 
paulson@13291
   263
                   \<lambda>x. \<exists>z[L]. P(x,z), 
paulson@13291
   264
                   \<lambda>a x. \<exists>z\<in>Lset(a). Q(a,x,z))"
paulson@13291
   265
by (unfold rex_def, blast) 
paulson@13291
   266
paulson@13291
   267
theorem Rall_reflection [intro]:
paulson@13291
   268
     "L_Reflects(Cl,  \<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x)))
paulson@13291
   269
      ==> L_Reflects(\<lambda>a. Cl(a) \<and> L_ClEx(\<lambda>x. ~P(fst(x),snd(x)), a), 
paulson@13291
   270
                   \<lambda>x. \<forall>z[L]. P(x,z), 
paulson@13291
   271
                   \<lambda>a x. \<forall>z\<in>Lset(a). Q(a,x,z))" 
paulson@13291
   272
by (unfold rall_def, blast) 
paulson@13291
   273
paulson@13291
   274
lemma ReflectsD:
paulson@13291
   275
     "[|L_Reflects(Cl,P,Q); Ord(i)|] 
paulson@13291
   276
      ==> \<exists>j. i<j & (\<forall>x \<in> Lset(j). P(x) <-> Q(j,x))"
paulson@13291
   277
apply (simp add: L_Reflects_def Closed_Unbounded_def, clarify)
paulson@13291
   278
apply (blast dest!: UnboundedD) 
paulson@13291
   279
done
paulson@13291
   280
paulson@13291
   281
lemma ReflectsE:
paulson@13291
   282
     "[| L_Reflects(Cl,P,Q); Ord(i);
paulson@13291
   283
         !!j. [|i<j;  \<forall>x \<in> Lset(j). P(x) <-> Q(j,x)|] ==> R |]
paulson@13291
   284
      ==> R"
paulson@13291
   285
by (blast dest!: ReflectsD) 
paulson@13291
   286
paulson@13291
   287
lemma Collect_mem_eq: "{x\<in>A. x\<in>B} = A \<inter> B";
paulson@13291
   288
by blast
paulson@13291
   289
paulson@13291
   290
paulson@13298
   291
subsection{*Internalized formulas for some relativized ones*}
paulson@13298
   292
paulson@13306
   293
lemmas setclass_simps = rall_setclass_is_ball rex_setclass_is_bex
paulson@13306
   294
paulson@13306
   295
subsubsection{*Some numbers to help write de Bruijn indices*}
paulson@13306
   296
paulson@13306
   297
syntax
paulson@13306
   298
    "3" :: i   ("3")
paulson@13306
   299
    "4" :: i   ("4")
paulson@13306
   300
    "5" :: i   ("5")
paulson@13306
   301
    "6" :: i   ("6")
paulson@13306
   302
    "7" :: i   ("7")
paulson@13306
   303
    "8" :: i   ("8")
paulson@13306
   304
    "9" :: i   ("9")
paulson@13306
   305
paulson@13306
   306
translations
paulson@13306
   307
   "3"  == "succ(2)"
paulson@13306
   308
   "4"  == "succ(3)"
paulson@13306
   309
   "5"  == "succ(4)"
paulson@13306
   310
   "6"  == "succ(5)"
paulson@13306
   311
   "7"  == "succ(6)"
paulson@13306
   312
   "8"  == "succ(7)"
paulson@13306
   313
   "9"  == "succ(8)"
paulson@13306
   314
paulson@13298
   315
subsubsection{*Unordered pairs*}
paulson@13298
   316
paulson@13298
   317
constdefs upair_fm :: "[i,i,i]=>i"
paulson@13298
   318
    "upair_fm(x,y,z) == 
paulson@13298
   319
       And(Member(x,z), 
paulson@13298
   320
           And(Member(y,z),
paulson@13298
   321
               Forall(Implies(Member(0,succ(z)), 
paulson@13298
   322
                              Or(Equal(0,succ(x)), Equal(0,succ(y)))))))"
paulson@13298
   323
paulson@13298
   324
lemma upair_type [TC]:
paulson@13298
   325
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> upair_fm(x,y,z) \<in> formula"
paulson@13298
   326
by (simp add: upair_fm_def) 
paulson@13298
   327
paulson@13298
   328
lemma arity_upair_fm [simp]:
paulson@13298
   329
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13298
   330
      ==> arity(upair_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13298
   331
by (simp add: upair_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13298
   332
paulson@13298
   333
lemma sats_upair_fm [simp]:
paulson@13298
   334
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13298
   335
    ==> sats(A, upair_fm(x,y,z), env) <-> 
paulson@13298
   336
            upair(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13298
   337
by (simp add: upair_fm_def upair_def)
paulson@13298
   338
paulson@13298
   339
lemma upair_iff_sats:
paulson@13298
   340
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13298
   341
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13298
   342
       ==> upair(**A, x, y, z) <-> sats(A, upair_fm(i,j,k), env)"
paulson@13298
   343
by (simp add: sats_upair_fm)
paulson@13298
   344
paulson@13298
   345
text{*Useful? At least it refers to "real" unordered pairs*}
paulson@13298
   346
lemma sats_upair_fm2 [simp]:
paulson@13298
   347
   "[| x \<in> nat; y \<in> nat; z < length(env); env \<in> list(A); Transset(A)|]
paulson@13298
   348
    ==> sats(A, upair_fm(x,y,z), env) <-> 
paulson@13298
   349
        nth(z,env) = {nth(x,env), nth(y,env)}"
paulson@13298
   350
apply (frule lt_length_in_nat, assumption)  
paulson@13298
   351
apply (simp add: upair_fm_def Transset_def, auto) 
paulson@13298
   352
apply (blast intro: nth_type) 
paulson@13298
   353
done
paulson@13298
   354
paulson@13306
   355
text{*The @{text simplified} attribute tidies up the reflecting class.*}
paulson@13306
   356
theorem upair_reflection [simplified,intro]:
paulson@13306
   357
     "L_Reflects(?Cl, \<lambda>x. upair(L,f(x),g(x),h(x)), 
paulson@13306
   358
                    \<lambda>i x. upair(**Lset(i),f(x),g(x),h(x)))" 
paulson@13306
   359
by (simp add: upair_def, fast) 
paulson@13306
   360
paulson@13298
   361
subsubsection{*Ordered pairs*}
paulson@13298
   362
paulson@13298
   363
constdefs pair_fm :: "[i,i,i]=>i"
paulson@13298
   364
    "pair_fm(x,y,z) == 
paulson@13298
   365
       Exists(And(upair_fm(succ(x),succ(x),0),
paulson@13298
   366
              Exists(And(upair_fm(succ(succ(x)),succ(succ(y)),0),
paulson@13298
   367
                         upair_fm(1,0,succ(succ(z)))))))"
paulson@13298
   368
paulson@13298
   369
lemma pair_type [TC]:
paulson@13298
   370
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> pair_fm(x,y,z) \<in> formula"
paulson@13298
   371
by (simp add: pair_fm_def) 
paulson@13298
   372
paulson@13298
   373
lemma arity_pair_fm [simp]:
paulson@13298
   374
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13298
   375
      ==> arity(pair_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13298
   376
by (simp add: pair_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13298
   377
paulson@13298
   378
lemma sats_pair_fm [simp]:
paulson@13298
   379
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13298
   380
    ==> sats(A, pair_fm(x,y,z), env) <-> 
paulson@13298
   381
        pair(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13298
   382
by (simp add: pair_fm_def pair_def)
paulson@13298
   383
paulson@13298
   384
lemma pair_iff_sats:
paulson@13298
   385
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13298
   386
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13298
   387
       ==> pair(**A, x, y, z) <-> sats(A, pair_fm(i,j,k), env)"
paulson@13298
   388
by (simp add: sats_pair_fm)
paulson@13298
   389
paulson@13298
   390
theorem pair_reflection [simplified,intro]:
paulson@13298
   391
     "L_Reflects(?Cl, \<lambda>x. pair(L,f(x),g(x),h(x)), 
paulson@13298
   392
                    \<lambda>i x. pair(**Lset(i),f(x),g(x),h(x)))"
paulson@13306
   393
by (simp only: pair_def setclass_simps, fast) 
paulson@13306
   394
paulson@13306
   395
paulson@13306
   396
subsubsection{*Binary Unions*}
paulson@13298
   397
paulson@13306
   398
constdefs union_fm :: "[i,i,i]=>i"
paulson@13306
   399
    "union_fm(x,y,z) == 
paulson@13306
   400
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   401
                  Or(Member(0,succ(x)),Member(0,succ(y)))))"
paulson@13306
   402
paulson@13306
   403
lemma union_type [TC]:
paulson@13306
   404
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> union_fm(x,y,z) \<in> formula"
paulson@13306
   405
by (simp add: union_fm_def) 
paulson@13306
   406
paulson@13306
   407
lemma arity_union_fm [simp]:
paulson@13306
   408
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13306
   409
      ==> arity(union_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13306
   410
by (simp add: union_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13298
   411
paulson@13306
   412
lemma sats_union_fm [simp]:
paulson@13306
   413
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13306
   414
    ==> sats(A, union_fm(x,y,z), env) <-> 
paulson@13306
   415
        union(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   416
by (simp add: union_fm_def union_def)
paulson@13306
   417
paulson@13306
   418
lemma union_iff_sats:
paulson@13306
   419
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13306
   420
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13306
   421
       ==> union(**A, x, y, z) <-> sats(A, union_fm(i,j,k), env)"
paulson@13306
   422
by (simp add: sats_union_fm)
paulson@13298
   423
paulson@13306
   424
theorem union_reflection [simplified,intro]:
paulson@13306
   425
     "L_Reflects(?Cl, \<lambda>x. union(L,f(x),g(x),h(x)), 
paulson@13306
   426
                    \<lambda>i x. union(**Lset(i),f(x),g(x),h(x)))" 
paulson@13306
   427
by (simp add: union_def, fast) 
paulson@13306
   428
paulson@13298
   429
paulson@13306
   430
subsubsection{*`Cons' for sets*}
paulson@13306
   431
paulson@13306
   432
constdefs cons_fm :: "[i,i,i]=>i"
paulson@13306
   433
    "cons_fm(x,y,z) == 
paulson@13306
   434
       Exists(And(upair_fm(succ(x),succ(x),0),
paulson@13306
   435
                  union_fm(0,succ(y),succ(z))))"
paulson@13298
   436
paulson@13298
   437
paulson@13306
   438
lemma cons_type [TC]:
paulson@13306
   439
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> cons_fm(x,y,z) \<in> formula"
paulson@13306
   440
by (simp add: cons_fm_def) 
paulson@13306
   441
paulson@13306
   442
lemma arity_cons_fm [simp]:
paulson@13306
   443
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13306
   444
      ==> arity(cons_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13306
   445
by (simp add: cons_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   446
paulson@13306
   447
lemma sats_cons_fm [simp]:
paulson@13306
   448
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13306
   449
    ==> sats(A, cons_fm(x,y,z), env) <-> 
paulson@13306
   450
        is_cons(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   451
by (simp add: cons_fm_def is_cons_def)
paulson@13306
   452
paulson@13306
   453
lemma cons_iff_sats:
paulson@13306
   454
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13306
   455
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13306
   456
       ==> is_cons(**A, x, y, z) <-> sats(A, cons_fm(i,j,k), env)"
paulson@13306
   457
by simp
paulson@13306
   458
paulson@13306
   459
theorem cons_reflection [simplified,intro]:
paulson@13306
   460
     "L_Reflects(?Cl, \<lambda>x. is_cons(L,f(x),g(x),h(x)), 
paulson@13306
   461
                    \<lambda>i x. is_cons(**Lset(i),f(x),g(x),h(x)))"
paulson@13306
   462
by (simp only: is_cons_def setclass_simps, fast)
paulson@13298
   463
paulson@13298
   464
paulson@13306
   465
subsubsection{*Function Applications*}
paulson@13306
   466
paulson@13306
   467
constdefs fun_apply_fm :: "[i,i,i]=>i"
paulson@13306
   468
    "fun_apply_fm(f,x,y) == 
paulson@13306
   469
       Forall(Iff(Exists(And(Member(0,succ(succ(f))),
paulson@13306
   470
                             pair_fm(succ(succ(x)), 1, 0))),
paulson@13306
   471
                  Equal(succ(y),0)))"
paulson@13298
   472
paulson@13306
   473
lemma fun_apply_type [TC]:
paulson@13306
   474
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> fun_apply_fm(x,y,z) \<in> formula"
paulson@13306
   475
by (simp add: fun_apply_fm_def) 
paulson@13306
   476
paulson@13306
   477
lemma arity_fun_apply_fm [simp]:
paulson@13306
   478
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13306
   479
      ==> arity(fun_apply_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13306
   480
by (simp add: fun_apply_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13298
   481
paulson@13306
   482
lemma sats_fun_apply_fm [simp]:
paulson@13306
   483
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13306
   484
    ==> sats(A, fun_apply_fm(x,y,z), env) <-> 
paulson@13306
   485
        fun_apply(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   486
by (simp add: fun_apply_fm_def fun_apply_def)
paulson@13306
   487
paulson@13306
   488
lemma fun_apply_iff_sats:
paulson@13306
   489
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13306
   490
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13306
   491
       ==> fun_apply(**A, x, y, z) <-> sats(A, fun_apply_fm(i,j,k), env)"
paulson@13306
   492
by simp
paulson@13306
   493
paulson@13306
   494
theorem fun_apply_reflection [simplified,intro]:
paulson@13306
   495
     "L_Reflects(?Cl, \<lambda>x. fun_apply(L,f(x),g(x),h(x)), 
paulson@13306
   496
                    \<lambda>i x. fun_apply(**Lset(i),f(x),g(x),h(x)))" 
paulson@13306
   497
by (simp only: fun_apply_def setclass_simps, fast)
paulson@13298
   498
paulson@13298
   499
paulson@13306
   500
subsubsection{*Variants of Satisfaction Definitions for Ordinals, etc.*}
paulson@13306
   501
paulson@13306
   502
text{*Differs from the one in Formula by using "ordinal" rather than "Ord"*}
paulson@13306
   503
paulson@13306
   504
paulson@13306
   505
lemma sats_subset_fm':
paulson@13306
   506
   "[|x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13306
   507
    ==> sats(A, subset_fm(x,y), env) <-> subset(**A, nth(x,env), nth(y,env))" 
paulson@13306
   508
by (simp add: subset_fm_def subset_def) 
paulson@13298
   509
paulson@13306
   510
theorem subset_reflection [simplified,intro]:
paulson@13306
   511
     "L_Reflects(?Cl, \<lambda>x. subset(L,f(x),g(x)), 
paulson@13306
   512
                    \<lambda>i x. subset(**Lset(i),f(x),g(x)))" 
paulson@13306
   513
by (simp add: subset_def, fast) 
paulson@13306
   514
paulson@13306
   515
lemma sats_transset_fm':
paulson@13306
   516
   "[|x \<in> nat; env \<in> list(A)|]
paulson@13306
   517
    ==> sats(A, transset_fm(x), env) <-> transitive_set(**A, nth(x,env))"
paulson@13306
   518
by (simp add: sats_subset_fm' transset_fm_def transitive_set_def) 
paulson@13298
   519
paulson@13306
   520
theorem transitive_set_reflection [simplified,intro]:
paulson@13306
   521
     "L_Reflects(?Cl, \<lambda>x. transitive_set(L,f(x)),
paulson@13306
   522
                    \<lambda>i x. transitive_set(**Lset(i),f(x)))"
paulson@13306
   523
by (simp only: transitive_set_def setclass_simps, fast)
paulson@13306
   524
paulson@13306
   525
lemma sats_ordinal_fm':
paulson@13306
   526
   "[|x \<in> nat; env \<in> list(A)|]
paulson@13306
   527
    ==> sats(A, ordinal_fm(x), env) <-> ordinal(**A,nth(x,env))"
paulson@13306
   528
by (simp add: sats_transset_fm' ordinal_fm_def ordinal_def)
paulson@13306
   529
paulson@13306
   530
lemma ordinal_iff_sats:
paulson@13306
   531
      "[| nth(i,env) = x;  i \<in> nat; env \<in> list(A)|]
paulson@13306
   532
       ==> ordinal(**A, x) <-> sats(A, ordinal_fm(i), env)"
paulson@13306
   533
by (simp add: sats_ordinal_fm')
paulson@13306
   534
paulson@13306
   535
theorem ordinal_reflection [simplified,intro]:
paulson@13306
   536
     "L_Reflects(?Cl, \<lambda>x. ordinal(L,f(x)),
paulson@13306
   537
                    \<lambda>i x. ordinal(**Lset(i),f(x)))"
paulson@13306
   538
by (simp only: ordinal_def setclass_simps, fast)
paulson@13298
   539
paulson@13298
   540
paulson@13306
   541
subsubsection{*Membership Relation*}
paulson@13298
   542
paulson@13306
   543
constdefs Memrel_fm :: "[i,i]=>i"
paulson@13306
   544
    "Memrel_fm(A,r) == 
paulson@13306
   545
       Forall(Iff(Member(0,succ(r)),
paulson@13306
   546
                  Exists(And(Member(0,succ(succ(A))),
paulson@13306
   547
                             Exists(And(Member(0,succ(succ(succ(A)))),
paulson@13306
   548
                                        And(Member(1,0),
paulson@13306
   549
                                            pair_fm(1,0,2))))))))"
paulson@13306
   550
paulson@13306
   551
lemma Memrel_type [TC]:
paulson@13306
   552
     "[| x \<in> nat; y \<in> nat |] ==> Memrel_fm(x,y) \<in> formula"
paulson@13306
   553
by (simp add: Memrel_fm_def) 
paulson@13298
   554
paulson@13306
   555
lemma arity_Memrel_fm [simp]:
paulson@13306
   556
     "[| x \<in> nat; y \<in> nat |] 
paulson@13306
   557
      ==> arity(Memrel_fm(x,y)) = succ(x) \<union> succ(y)"
paulson@13306
   558
by (simp add: Memrel_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   559
paulson@13306
   560
lemma sats_Memrel_fm [simp]:
paulson@13306
   561
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13306
   562
    ==> sats(A, Memrel_fm(x,y), env) <-> 
paulson@13306
   563
        membership(**A, nth(x,env), nth(y,env))"
paulson@13306
   564
by (simp add: Memrel_fm_def membership_def)
paulson@13298
   565
paulson@13306
   566
lemma Memrel_iff_sats:
paulson@13306
   567
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   568
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13306
   569
       ==> membership(**A, x, y) <-> sats(A, Memrel_fm(i,j), env)"
paulson@13306
   570
by simp
paulson@13304
   571
paulson@13306
   572
theorem membership_reflection [simplified,intro]:
paulson@13306
   573
     "L_Reflects(?Cl, \<lambda>x. membership(L,f(x),g(x)), 
paulson@13306
   574
                    \<lambda>i x. membership(**Lset(i),f(x),g(x)))"
paulson@13306
   575
by (simp only: membership_def setclass_simps, fast)
paulson@13304
   576
paulson@13304
   577
paulson@13306
   578
subsubsection{*Predecessor Set*}
paulson@13304
   579
paulson@13306
   580
constdefs pred_set_fm :: "[i,i,i,i]=>i"
paulson@13306
   581
    "pred_set_fm(A,x,r,B) == 
paulson@13306
   582
       Forall(Iff(Member(0,succ(B)),
paulson@13306
   583
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   584
                             And(Member(1,succ(succ(A))),
paulson@13306
   585
                                 pair_fm(1,succ(succ(x)),0))))))"
paulson@13306
   586
paulson@13306
   587
paulson@13306
   588
lemma pred_set_type [TC]:
paulson@13306
   589
     "[| A \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat |] 
paulson@13306
   590
      ==> pred_set_fm(A,x,r,B) \<in> formula"
paulson@13306
   591
by (simp add: pred_set_fm_def) 
paulson@13304
   592
paulson@13306
   593
lemma arity_pred_set_fm [simp]:
paulson@13306
   594
   "[| A \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat |] 
paulson@13306
   595
    ==> arity(pred_set_fm(A,x,r,B)) = succ(A) \<union> succ(x) \<union> succ(r) \<union> succ(B)"
paulson@13306
   596
by (simp add: pred_set_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   597
paulson@13306
   598
lemma sats_pred_set_fm [simp]:
paulson@13306
   599
   "[| U \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat; env \<in> list(A)|]
paulson@13306
   600
    ==> sats(A, pred_set_fm(U,x,r,B), env) <-> 
paulson@13306
   601
        pred_set(**A, nth(U,env), nth(x,env), nth(r,env), nth(B,env))"
paulson@13306
   602
by (simp add: pred_set_fm_def pred_set_def)
paulson@13306
   603
paulson@13306
   604
lemma pred_set_iff_sats:
paulson@13306
   605
      "[| nth(i,env) = U; nth(j,env) = x; nth(k,env) = r; nth(l,env) = B; 
paulson@13306
   606
          i \<in> nat; j \<in> nat; k \<in> nat; l \<in> nat; env \<in> list(A)|]
paulson@13306
   607
       ==> pred_set(**A,U,x,r,B) <-> sats(A, pred_set_fm(i,j,k,l), env)"
paulson@13306
   608
by (simp add: sats_pred_set_fm)
paulson@13306
   609
paulson@13306
   610
theorem pred_set_reflection [simplified,intro]:
paulson@13306
   611
     "L_Reflects(?Cl, \<lambda>x. pred_set(L,f(x),g(x),h(x),b(x)), 
paulson@13306
   612
                    \<lambda>i x. pred_set(**Lset(i),f(x),g(x),h(x),b(x)))" 
paulson@13306
   613
by (simp only: pred_set_def setclass_simps, fast) 
paulson@13304
   614
paulson@13304
   615
paulson@13298
   616
paulson@13306
   617
subsubsection{*Domain*}
paulson@13306
   618
paulson@13306
   619
(* "is_domain(M,r,z) == 
paulson@13306
   620
	\<forall>x[M]. (x \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>y[M]. pair(M,x,y,w))))" *)
paulson@13306
   621
constdefs domain_fm :: "[i,i]=>i"
paulson@13306
   622
    "domain_fm(r,z) == 
paulson@13306
   623
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   624
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   625
                             Exists(pair_fm(2,0,1))))))"
paulson@13306
   626
paulson@13306
   627
lemma domain_type [TC]:
paulson@13306
   628
     "[| x \<in> nat; y \<in> nat |] ==> domain_fm(x,y) \<in> formula"
paulson@13306
   629
by (simp add: domain_fm_def) 
paulson@13306
   630
paulson@13306
   631
lemma arity_domain_fm [simp]:
paulson@13306
   632
     "[| x \<in> nat; y \<in> nat |] 
paulson@13306
   633
      ==> arity(domain_fm(x,y)) = succ(x) \<union> succ(y)"
paulson@13306
   634
by (simp add: domain_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   635
paulson@13306
   636
lemma sats_domain_fm [simp]:
paulson@13306
   637
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13306
   638
    ==> sats(A, domain_fm(x,y), env) <-> 
paulson@13306
   639
        is_domain(**A, nth(x,env), nth(y,env))"
paulson@13306
   640
by (simp add: domain_fm_def is_domain_def)
paulson@13306
   641
paulson@13306
   642
lemma domain_iff_sats:
paulson@13306
   643
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   644
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13306
   645
       ==> is_domain(**A, x, y) <-> sats(A, domain_fm(i,j), env)"
paulson@13306
   646
by simp
paulson@13306
   647
paulson@13306
   648
theorem domain_reflection [simplified,intro]:
paulson@13306
   649
     "L_Reflects(?Cl, \<lambda>x. is_domain(L,f(x),g(x)), 
paulson@13306
   650
                    \<lambda>i x. is_domain(**Lset(i),f(x),g(x)))"
paulson@13306
   651
by (simp only: is_domain_def setclass_simps, fast)
paulson@13306
   652
paulson@13306
   653
paulson@13306
   654
subsubsection{*Range*}
paulson@13306
   655
paulson@13306
   656
(* "is_range(M,r,z) == 
paulson@13306
   657
	\<forall>y[M]. (y \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>x[M]. pair(M,x,y,w))))" *)
paulson@13306
   658
constdefs range_fm :: "[i,i]=>i"
paulson@13306
   659
    "range_fm(r,z) == 
paulson@13306
   660
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   661
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   662
                             Exists(pair_fm(0,2,1))))))"
paulson@13306
   663
paulson@13306
   664
lemma range_type [TC]:
paulson@13306
   665
     "[| x \<in> nat; y \<in> nat |] ==> range_fm(x,y) \<in> formula"
paulson@13306
   666
by (simp add: range_fm_def) 
paulson@13306
   667
paulson@13306
   668
lemma arity_range_fm [simp]:
paulson@13306
   669
     "[| x \<in> nat; y \<in> nat |] 
paulson@13306
   670
      ==> arity(range_fm(x,y)) = succ(x) \<union> succ(y)"
paulson@13306
   671
by (simp add: range_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   672
paulson@13306
   673
lemma sats_range_fm [simp]:
paulson@13306
   674
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13306
   675
    ==> sats(A, range_fm(x,y), env) <-> 
paulson@13306
   676
        is_range(**A, nth(x,env), nth(y,env))"
paulson@13306
   677
by (simp add: range_fm_def is_range_def)
paulson@13306
   678
paulson@13306
   679
lemma range_iff_sats:
paulson@13306
   680
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   681
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13306
   682
       ==> is_range(**A, x, y) <-> sats(A, range_fm(i,j), env)"
paulson@13306
   683
by simp
paulson@13306
   684
paulson@13306
   685
theorem range_reflection [simplified,intro]:
paulson@13306
   686
     "L_Reflects(?Cl, \<lambda>x. is_range(L,f(x),g(x)), 
paulson@13306
   687
                    \<lambda>i x. is_range(**Lset(i),f(x),g(x)))"
paulson@13306
   688
by (simp only: is_range_def setclass_simps, fast)
paulson@13306
   689
paulson@13306
   690
paulson@13306
   691
paulson@13306
   692
 
paulson@13306
   693
paulson@13306
   694
subsubsection{*Image*}
paulson@13306
   695
paulson@13306
   696
(* "image(M,r,A,z) == 
paulson@13306
   697
        \<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
   698
constdefs image_fm :: "[i,i,i]=>i"
paulson@13306
   699
    "image_fm(r,A,z) == 
paulson@13306
   700
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   701
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   702
                             Exists(And(Member(0,succ(succ(succ(A)))),
paulson@13306
   703
	 			        pair_fm(0,2,1)))))))"
paulson@13306
   704
paulson@13306
   705
lemma image_type [TC]:
paulson@13306
   706
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> image_fm(x,y,z) \<in> formula"
paulson@13306
   707
by (simp add: image_fm_def) 
paulson@13306
   708
paulson@13306
   709
lemma arity_image_fm [simp]:
paulson@13306
   710
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13306
   711
      ==> arity(image_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13306
   712
by (simp add: image_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   713
paulson@13306
   714
lemma sats_image_fm [simp]:
paulson@13306
   715
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13306
   716
    ==> sats(A, image_fm(x,y,z), env) <-> 
paulson@13306
   717
        image(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   718
by (simp add: image_fm_def image_def)
paulson@13306
   719
paulson@13306
   720
lemma image_iff_sats:
paulson@13306
   721
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13306
   722
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13306
   723
       ==> image(**A, x, y, z) <-> sats(A, image_fm(i,j,k), env)"
paulson@13306
   724
by (simp add: sats_image_fm)
paulson@13306
   725
paulson@13306
   726
theorem image_reflection [simplified,intro]:
paulson@13306
   727
     "L_Reflects(?Cl, \<lambda>x. image(L,f(x),g(x),h(x)), 
paulson@13306
   728
                    \<lambda>i x. image(**Lset(i),f(x),g(x),h(x)))" 
paulson@13306
   729
by (simp only: image_def setclass_simps, fast)
paulson@13306
   730
paulson@13306
   731
paulson@13306
   732
subsubsection{*The Concept of Relation*}
paulson@13306
   733
paulson@13306
   734
(* "is_relation(M,r) == 
paulson@13306
   735
        (\<forall>z[M]. z\<in>r --> (\<exists>x[M]. \<exists>y[M]. pair(M,x,y,z)))" *)
paulson@13306
   736
constdefs relation_fm :: "i=>i"
paulson@13306
   737
    "relation_fm(r) == 
paulson@13306
   738
       Forall(Implies(Member(0,succ(r)), Exists(Exists(pair_fm(1,0,2)))))"
paulson@13306
   739
paulson@13306
   740
lemma relation_type [TC]:
paulson@13306
   741
     "[| x \<in> nat |] ==> relation_fm(x) \<in> formula"
paulson@13306
   742
by (simp add: relation_fm_def) 
paulson@13306
   743
paulson@13306
   744
lemma arity_relation_fm [simp]:
paulson@13306
   745
     "x \<in> nat ==> arity(relation_fm(x)) = succ(x)"
paulson@13306
   746
by (simp add: relation_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   747
paulson@13306
   748
lemma sats_relation_fm [simp]:
paulson@13306
   749
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13306
   750
    ==> sats(A, relation_fm(x), env) <-> is_relation(**A, nth(x,env))"
paulson@13306
   751
by (simp add: relation_fm_def is_relation_def)
paulson@13306
   752
paulson@13306
   753
lemma relation_iff_sats:
paulson@13306
   754
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   755
          i \<in> nat; env \<in> list(A)|]
paulson@13306
   756
       ==> is_relation(**A, x) <-> sats(A, relation_fm(i), env)"
paulson@13306
   757
by simp
paulson@13306
   758
paulson@13306
   759
theorem is_relation_reflection [simplified,intro]:
paulson@13306
   760
     "L_Reflects(?Cl, \<lambda>x. is_relation(L,f(x)), 
paulson@13306
   761
                    \<lambda>i x. is_relation(**Lset(i),f(x)))"
paulson@13306
   762
by (simp only: is_relation_def setclass_simps, fast)
paulson@13306
   763
paulson@13306
   764
paulson@13306
   765
subsubsection{*The Concept of Function*}
paulson@13306
   766
paulson@13306
   767
(* "is_function(M,r) == 
paulson@13306
   768
	\<forall>x[M]. \<forall>y[M]. \<forall>y'[M]. \<forall>p[M]. \<forall>p'[M]. 
paulson@13306
   769
           pair(M,x,y,p) --> pair(M,x,y',p') --> p\<in>r --> p'\<in>r --> y=y'" *)
paulson@13306
   770
constdefs function_fm :: "i=>i"
paulson@13306
   771
    "function_fm(r) == 
paulson@13306
   772
       Forall(Forall(Forall(Forall(Forall(
paulson@13306
   773
         Implies(pair_fm(4,3,1),
paulson@13306
   774
                 Implies(pair_fm(4,2,0),
paulson@13306
   775
                         Implies(Member(1,r#+5),
paulson@13306
   776
                                 Implies(Member(0,r#+5), Equal(3,2))))))))))"
paulson@13306
   777
paulson@13306
   778
lemma function_type [TC]:
paulson@13306
   779
     "[| x \<in> nat |] ==> function_fm(x) \<in> formula"
paulson@13306
   780
by (simp add: function_fm_def) 
paulson@13306
   781
paulson@13306
   782
lemma arity_function_fm [simp]:
paulson@13306
   783
     "x \<in> nat ==> arity(function_fm(x)) = succ(x)"
paulson@13306
   784
by (simp add: function_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   785
paulson@13306
   786
lemma sats_function_fm [simp]:
paulson@13306
   787
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13306
   788
    ==> sats(A, function_fm(x), env) <-> is_function(**A, nth(x,env))"
paulson@13306
   789
by (simp add: function_fm_def is_function_def)
paulson@13306
   790
paulson@13306
   791
lemma function_iff_sats:
paulson@13306
   792
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   793
          i \<in> nat; env \<in> list(A)|]
paulson@13306
   794
       ==> is_function(**A, x) <-> sats(A, function_fm(i), env)"
paulson@13306
   795
by simp
paulson@13306
   796
paulson@13306
   797
theorem is_function_reflection [simplified,intro]:
paulson@13306
   798
     "L_Reflects(?Cl, \<lambda>x. is_function(L,f(x)), 
paulson@13306
   799
                    \<lambda>i x. is_function(**Lset(i),f(x)))"
paulson@13306
   800
by (simp only: is_function_def setclass_simps, fast)
paulson@13298
   801
paulson@13298
   802
paulson@13223
   803
end