src/ZF/Constructible/L_axioms.thy
author paulson
Mon Jul 08 17:51:56 2002 +0200 (2002-07-08)
changeset 13316 d16629fd0f95
parent 13314 84b9de3cbc91
child 13323 2c287f50c9f3
permissions -rw-r--r--
more and simpler separation proofs
paulson@13306
     1
header {*The Class L Satisfies the ZF Axioms*}
paulson@13223
     2
paulson@13314
     3
theory L_axioms = Formula + Relative + Reflection + MetaExists:
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_F0 :: "[i=>o,i] => i"
paulson@13291
   193
    "L_F0(P,y) == \<mu>b. (\<exists>z. L(z) \<and> P(<y,z>)) --> (\<exists>z\<in>Lset(b). P(<y,z>))"
paulson@13291
   194
paulson@13291
   195
  L_FF :: "[i=>o,i] => i"
paulson@13291
   196
    "L_FF(P)   == \<lambda>a. \<Union>y\<in>Lset(a). L_F0(P,y)"
paulson@13291
   197
paulson@13291
   198
  L_ClEx :: "[i=>o,i] => o"
paulson@13291
   199
    "L_ClEx(P) == \<lambda>a. Limit(a) \<and> normalize(L_FF(P),a) = a"
paulson@13291
   200
paulson@13291
   201
paulson@13314
   202
text{*We must use the meta-existential quantifier; otherwise the reflection
paulson@13314
   203
      terms become enormous!*} 
paulson@13314
   204
constdefs
paulson@13314
   205
  L_Reflects :: "[i=>o,[i,i]=>o] => prop"      ("(3REFLECTS/ [_,/ _])")
paulson@13314
   206
    "REFLECTS[P,Q] == (??Cl. Closed_Unbounded(Cl) &
paulson@13314
   207
                           (\<forall>a. Cl(a) --> (\<forall>x \<in> Lset(a). P(x) <-> Q(a,x))))"
paulson@13291
   208
paulson@13291
   209
paulson@13314
   210
theorem Triv_reflection:
paulson@13314
   211
     "REFLECTS[P, \<lambda>a x. P(x)]"
paulson@13314
   212
apply (simp add: L_Reflects_def) 
paulson@13314
   213
apply (rule meta_exI) 
paulson@13314
   214
apply (rule Closed_Unbounded_Ord) 
paulson@13314
   215
done
paulson@13314
   216
paulson@13314
   217
theorem Not_reflection:
paulson@13314
   218
     "REFLECTS[P,Q] ==> REFLECTS[\<lambda>x. ~P(x), \<lambda>a x. ~Q(a,x)]"
paulson@13314
   219
apply (unfold L_Reflects_def) 
paulson@13314
   220
apply (erule meta_exE) 
paulson@13314
   221
apply (rule_tac x=Cl in meta_exI, simp) 
paulson@13314
   222
done
paulson@13314
   223
paulson@13314
   224
theorem And_reflection:
paulson@13314
   225
     "[| REFLECTS[P,Q]; REFLECTS[P',Q'] |] 
paulson@13314
   226
      ==> REFLECTS[\<lambda>x. P(x) \<and> P'(x), \<lambda>a x. Q(a,x) \<and> Q'(a,x)]"
paulson@13314
   227
apply (unfold L_Reflects_def) 
paulson@13314
   228
apply (elim meta_exE) 
paulson@13314
   229
apply (rule_tac x="\<lambda>a. Cl(a) \<and> Cla(a)" in meta_exI) 
paulson@13314
   230
apply (simp add: Closed_Unbounded_Int, blast) 
paulson@13314
   231
done
paulson@13314
   232
paulson@13314
   233
theorem Or_reflection:
paulson@13314
   234
     "[| REFLECTS[P,Q]; REFLECTS[P',Q'] |] 
paulson@13314
   235
      ==> REFLECTS[\<lambda>x. P(x) \<or> P'(x), \<lambda>a x. Q(a,x) \<or> Q'(a,x)]"
paulson@13314
   236
apply (unfold L_Reflects_def) 
paulson@13314
   237
apply (elim meta_exE) 
paulson@13314
   238
apply (rule_tac x="\<lambda>a. Cl(a) \<and> Cla(a)" in meta_exI) 
paulson@13314
   239
apply (simp add: Closed_Unbounded_Int, blast) 
paulson@13314
   240
done
paulson@13314
   241
paulson@13314
   242
theorem Imp_reflection:
paulson@13314
   243
     "[| REFLECTS[P,Q]; REFLECTS[P',Q'] |] 
paulson@13314
   244
      ==> REFLECTS[\<lambda>x. P(x) --> P'(x), \<lambda>a x. Q(a,x) --> Q'(a,x)]"
paulson@13314
   245
apply (unfold L_Reflects_def) 
paulson@13314
   246
apply (elim meta_exE) 
paulson@13314
   247
apply (rule_tac x="\<lambda>a. Cl(a) \<and> Cla(a)" in meta_exI) 
paulson@13314
   248
apply (simp add: Closed_Unbounded_Int, blast) 
paulson@13314
   249
done
paulson@13314
   250
paulson@13314
   251
theorem Iff_reflection:
paulson@13314
   252
     "[| REFLECTS[P,Q]; REFLECTS[P',Q'] |] 
paulson@13314
   253
      ==> REFLECTS[\<lambda>x. P(x) <-> P'(x), \<lambda>a x. Q(a,x) <-> Q'(a,x)]"
paulson@13314
   254
apply (unfold L_Reflects_def) 
paulson@13314
   255
apply (elim meta_exE) 
paulson@13314
   256
apply (rule_tac x="\<lambda>a. Cl(a) \<and> Cla(a)" in meta_exI) 
paulson@13314
   257
apply (simp add: Closed_Unbounded_Int, blast) 
paulson@13314
   258
done
paulson@13314
   259
paulson@13314
   260
paulson@13314
   261
theorem Ex_reflection:
paulson@13314
   262
     "REFLECTS[\<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))]
paulson@13314
   263
      ==> REFLECTS[\<lambda>x. \<exists>z. L(z) \<and> P(x,z), \<lambda>a x. \<exists>z\<in>Lset(a). Q(a,x,z)]"
paulson@13291
   264
apply (unfold L_Reflects_def L_ClEx_def L_FF_def L_F0_def L_def) 
paulson@13314
   265
apply (elim meta_exE) 
paulson@13314
   266
apply (rule meta_exI)
paulson@13291
   267
apply (rule reflection.Ex_reflection [OF Lset_mono_le Lset_cont Pair_in_Lset],
paulson@13291
   268
       assumption+)
paulson@13291
   269
done
paulson@13291
   270
paulson@13314
   271
theorem All_reflection:
paulson@13314
   272
     "REFLECTS[\<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))]
paulson@13314
   273
      ==> REFLECTS[\<lambda>x. \<forall>z. L(z) --> P(x,z), \<lambda>a x. \<forall>z\<in>Lset(a). Q(a,x,z)]" 
paulson@13291
   274
apply (unfold L_Reflects_def L_ClEx_def L_FF_def L_F0_def L_def) 
paulson@13314
   275
apply (elim meta_exE) 
paulson@13314
   276
apply (rule meta_exI)
paulson@13291
   277
apply (rule reflection.All_reflection [OF Lset_mono_le Lset_cont Pair_in_Lset],
paulson@13291
   278
       assumption+)
paulson@13291
   279
done
paulson@13291
   280
paulson@13314
   281
theorem Rex_reflection:
paulson@13314
   282
     "REFLECTS[ \<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))]
paulson@13314
   283
      ==> REFLECTS[\<lambda>x. \<exists>z[L]. P(x,z), \<lambda>a x. \<exists>z\<in>Lset(a). Q(a,x,z)]"
paulson@13314
   284
apply (unfold rex_def) 
paulson@13314
   285
apply (intro And_reflection Ex_reflection, assumption)
paulson@13314
   286
done
paulson@13291
   287
paulson@13314
   288
theorem Rall_reflection:
paulson@13314
   289
     "REFLECTS[\<lambda>x. P(fst(x),snd(x)), \<lambda>a x. Q(a,fst(x),snd(x))]
paulson@13314
   290
      ==> REFLECTS[\<lambda>x. \<forall>z[L]. P(x,z), \<lambda>a x. \<forall>z\<in>Lset(a). Q(a,x,z)]" 
paulson@13314
   291
apply (unfold rall_def) 
paulson@13314
   292
apply (intro Imp_reflection All_reflection, assumption)
paulson@13314
   293
done
paulson@13314
   294
paulson@13314
   295
lemmas FOL_reflection = 
paulson@13314
   296
        Triv_reflection Not_reflection And_reflection Or_reflection
paulson@13314
   297
        Imp_reflection Iff_reflection Ex_reflection All_reflection
paulson@13314
   298
        Rex_reflection Rall_reflection
paulson@13291
   299
paulson@13291
   300
lemma ReflectsD:
paulson@13314
   301
     "[|REFLECTS[P,Q]; Ord(i)|] 
paulson@13291
   302
      ==> \<exists>j. i<j & (\<forall>x \<in> Lset(j). P(x) <-> Q(j,x))"
paulson@13314
   303
apply (unfold L_Reflects_def Closed_Unbounded_def) 
paulson@13314
   304
apply (elim meta_exE, clarify) 
paulson@13291
   305
apply (blast dest!: UnboundedD) 
paulson@13291
   306
done
paulson@13291
   307
paulson@13291
   308
lemma ReflectsE:
paulson@13314
   309
     "[| REFLECTS[P,Q]; Ord(i);
paulson@13291
   310
         !!j. [|i<j;  \<forall>x \<in> Lset(j). P(x) <-> Q(j,x)|] ==> R |]
paulson@13291
   311
      ==> R"
paulson@13316
   312
apply (drule ReflectsD, assumption, blast) 
paulson@13314
   313
done
paulson@13291
   314
paulson@13291
   315
lemma Collect_mem_eq: "{x\<in>A. x\<in>B} = A \<inter> B";
paulson@13291
   316
by blast
paulson@13291
   317
paulson@13291
   318
paulson@13298
   319
subsection{*Internalized formulas for some relativized ones*}
paulson@13298
   320
paulson@13306
   321
lemmas setclass_simps = rall_setclass_is_ball rex_setclass_is_bex
paulson@13306
   322
paulson@13306
   323
subsubsection{*Some numbers to help write de Bruijn indices*}
paulson@13306
   324
paulson@13306
   325
syntax
paulson@13306
   326
    "3" :: i   ("3")
paulson@13306
   327
    "4" :: i   ("4")
paulson@13306
   328
    "5" :: i   ("5")
paulson@13306
   329
    "6" :: i   ("6")
paulson@13306
   330
    "7" :: i   ("7")
paulson@13306
   331
    "8" :: i   ("8")
paulson@13306
   332
    "9" :: i   ("9")
paulson@13306
   333
paulson@13306
   334
translations
paulson@13306
   335
   "3"  == "succ(2)"
paulson@13306
   336
   "4"  == "succ(3)"
paulson@13306
   337
   "5"  == "succ(4)"
paulson@13306
   338
   "6"  == "succ(5)"
paulson@13306
   339
   "7"  == "succ(6)"
paulson@13306
   340
   "8"  == "succ(7)"
paulson@13306
   341
   "9"  == "succ(8)"
paulson@13306
   342
paulson@13298
   343
subsubsection{*Unordered pairs*}
paulson@13298
   344
paulson@13298
   345
constdefs upair_fm :: "[i,i,i]=>i"
paulson@13298
   346
    "upair_fm(x,y,z) == 
paulson@13298
   347
       And(Member(x,z), 
paulson@13298
   348
           And(Member(y,z),
paulson@13298
   349
               Forall(Implies(Member(0,succ(z)), 
paulson@13298
   350
                              Or(Equal(0,succ(x)), Equal(0,succ(y)))))))"
paulson@13298
   351
paulson@13298
   352
lemma upair_type [TC]:
paulson@13298
   353
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> upair_fm(x,y,z) \<in> formula"
paulson@13298
   354
by (simp add: upair_fm_def) 
paulson@13298
   355
paulson@13298
   356
lemma arity_upair_fm [simp]:
paulson@13298
   357
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13298
   358
      ==> arity(upair_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13298
   359
by (simp add: upair_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13298
   360
paulson@13298
   361
lemma sats_upair_fm [simp]:
paulson@13298
   362
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13298
   363
    ==> sats(A, upair_fm(x,y,z), env) <-> 
paulson@13298
   364
            upair(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13298
   365
by (simp add: upair_fm_def upair_def)
paulson@13298
   366
paulson@13298
   367
lemma upair_iff_sats:
paulson@13298
   368
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13298
   369
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13298
   370
       ==> upair(**A, x, y, z) <-> sats(A, upair_fm(i,j,k), env)"
paulson@13298
   371
by (simp add: sats_upair_fm)
paulson@13298
   372
paulson@13298
   373
text{*Useful? At least it refers to "real" unordered pairs*}
paulson@13298
   374
lemma sats_upair_fm2 [simp]:
paulson@13298
   375
   "[| x \<in> nat; y \<in> nat; z < length(env); env \<in> list(A); Transset(A)|]
paulson@13298
   376
    ==> sats(A, upair_fm(x,y,z), env) <-> 
paulson@13298
   377
        nth(z,env) = {nth(x,env), nth(y,env)}"
paulson@13298
   378
apply (frule lt_length_in_nat, assumption)  
paulson@13298
   379
apply (simp add: upair_fm_def Transset_def, auto) 
paulson@13298
   380
apply (blast intro: nth_type) 
paulson@13298
   381
done
paulson@13298
   382
paulson@13314
   383
theorem upair_reflection:
paulson@13314
   384
     "REFLECTS[\<lambda>x. upair(L,f(x),g(x),h(x)), 
paulson@13314
   385
               \<lambda>i x. upair(**Lset(i),f(x),g(x),h(x))]" 
paulson@13314
   386
apply (simp add: upair_def)
paulson@13314
   387
apply (intro FOL_reflection)  
paulson@13314
   388
done
paulson@13306
   389
paulson@13298
   390
subsubsection{*Ordered pairs*}
paulson@13298
   391
paulson@13298
   392
constdefs pair_fm :: "[i,i,i]=>i"
paulson@13298
   393
    "pair_fm(x,y,z) == 
paulson@13298
   394
       Exists(And(upair_fm(succ(x),succ(x),0),
paulson@13298
   395
              Exists(And(upair_fm(succ(succ(x)),succ(succ(y)),0),
paulson@13298
   396
                         upair_fm(1,0,succ(succ(z)))))))"
paulson@13298
   397
paulson@13298
   398
lemma pair_type [TC]:
paulson@13298
   399
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> pair_fm(x,y,z) \<in> formula"
paulson@13298
   400
by (simp add: pair_fm_def) 
paulson@13298
   401
paulson@13298
   402
lemma arity_pair_fm [simp]:
paulson@13298
   403
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13298
   404
      ==> arity(pair_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13298
   405
by (simp add: pair_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13298
   406
paulson@13298
   407
lemma sats_pair_fm [simp]:
paulson@13298
   408
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13298
   409
    ==> sats(A, pair_fm(x,y,z), env) <-> 
paulson@13298
   410
        pair(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13298
   411
by (simp add: pair_fm_def pair_def)
paulson@13298
   412
paulson@13298
   413
lemma pair_iff_sats:
paulson@13298
   414
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13298
   415
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13298
   416
       ==> pair(**A, x, y, z) <-> sats(A, pair_fm(i,j,k), env)"
paulson@13298
   417
by (simp add: sats_pair_fm)
paulson@13298
   418
paulson@13314
   419
theorem pair_reflection:
paulson@13314
   420
     "REFLECTS[\<lambda>x. pair(L,f(x),g(x),h(x)), 
paulson@13314
   421
               \<lambda>i x. pair(**Lset(i),f(x),g(x),h(x))]"
paulson@13314
   422
apply (simp only: pair_def setclass_simps)
paulson@13314
   423
apply (intro FOL_reflection upair_reflection)  
paulson@13314
   424
done
paulson@13306
   425
paulson@13306
   426
paulson@13306
   427
subsubsection{*Binary Unions*}
paulson@13298
   428
paulson@13306
   429
constdefs union_fm :: "[i,i,i]=>i"
paulson@13306
   430
    "union_fm(x,y,z) == 
paulson@13306
   431
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   432
                  Or(Member(0,succ(x)),Member(0,succ(y)))))"
paulson@13306
   433
paulson@13306
   434
lemma union_type [TC]:
paulson@13306
   435
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> union_fm(x,y,z) \<in> formula"
paulson@13306
   436
by (simp add: union_fm_def) 
paulson@13306
   437
paulson@13306
   438
lemma arity_union_fm [simp]:
paulson@13306
   439
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13306
   440
      ==> arity(union_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13306
   441
by (simp add: union_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13298
   442
paulson@13306
   443
lemma sats_union_fm [simp]:
paulson@13306
   444
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13306
   445
    ==> sats(A, union_fm(x,y,z), env) <-> 
paulson@13306
   446
        union(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   447
by (simp add: union_fm_def union_def)
paulson@13306
   448
paulson@13306
   449
lemma union_iff_sats:
paulson@13306
   450
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13306
   451
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13306
   452
       ==> union(**A, x, y, z) <-> sats(A, union_fm(i,j,k), env)"
paulson@13306
   453
by (simp add: sats_union_fm)
paulson@13298
   454
paulson@13314
   455
theorem union_reflection:
paulson@13314
   456
     "REFLECTS[\<lambda>x. union(L,f(x),g(x),h(x)), 
paulson@13314
   457
               \<lambda>i x. union(**Lset(i),f(x),g(x),h(x))]"
paulson@13314
   458
apply (simp only: union_def setclass_simps)
paulson@13314
   459
apply (intro FOL_reflection)  
paulson@13314
   460
done
paulson@13306
   461
paulson@13298
   462
paulson@13306
   463
subsubsection{*`Cons' for sets*}
paulson@13306
   464
paulson@13306
   465
constdefs cons_fm :: "[i,i,i]=>i"
paulson@13306
   466
    "cons_fm(x,y,z) == 
paulson@13306
   467
       Exists(And(upair_fm(succ(x),succ(x),0),
paulson@13306
   468
                  union_fm(0,succ(y),succ(z))))"
paulson@13298
   469
paulson@13298
   470
paulson@13306
   471
lemma cons_type [TC]:
paulson@13306
   472
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> cons_fm(x,y,z) \<in> formula"
paulson@13306
   473
by (simp add: cons_fm_def) 
paulson@13306
   474
paulson@13306
   475
lemma arity_cons_fm [simp]:
paulson@13306
   476
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13306
   477
      ==> arity(cons_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13306
   478
by (simp add: cons_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   479
paulson@13306
   480
lemma sats_cons_fm [simp]:
paulson@13306
   481
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13306
   482
    ==> sats(A, cons_fm(x,y,z), env) <-> 
paulson@13306
   483
        is_cons(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   484
by (simp add: cons_fm_def is_cons_def)
paulson@13306
   485
paulson@13306
   486
lemma cons_iff_sats:
paulson@13306
   487
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13306
   488
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13306
   489
       ==> is_cons(**A, x, y, z) <-> sats(A, cons_fm(i,j,k), env)"
paulson@13306
   490
by simp
paulson@13306
   491
paulson@13314
   492
theorem cons_reflection:
paulson@13314
   493
     "REFLECTS[\<lambda>x. is_cons(L,f(x),g(x),h(x)), 
paulson@13314
   494
               \<lambda>i x. is_cons(**Lset(i),f(x),g(x),h(x))]"
paulson@13314
   495
apply (simp only: is_cons_def setclass_simps)
paulson@13314
   496
apply (intro FOL_reflection upair_reflection union_reflection)  
paulson@13314
   497
done
paulson@13298
   498
paulson@13298
   499
paulson@13306
   500
subsubsection{*Function Applications*}
paulson@13306
   501
paulson@13306
   502
constdefs fun_apply_fm :: "[i,i,i]=>i"
paulson@13306
   503
    "fun_apply_fm(f,x,y) == 
paulson@13306
   504
       Forall(Iff(Exists(And(Member(0,succ(succ(f))),
paulson@13306
   505
                             pair_fm(succ(succ(x)), 1, 0))),
paulson@13306
   506
                  Equal(succ(y),0)))"
paulson@13298
   507
paulson@13306
   508
lemma fun_apply_type [TC]:
paulson@13306
   509
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> fun_apply_fm(x,y,z) \<in> formula"
paulson@13306
   510
by (simp add: fun_apply_fm_def) 
paulson@13306
   511
paulson@13306
   512
lemma arity_fun_apply_fm [simp]:
paulson@13306
   513
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13306
   514
      ==> arity(fun_apply_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13306
   515
by (simp add: fun_apply_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13298
   516
paulson@13306
   517
lemma sats_fun_apply_fm [simp]:
paulson@13306
   518
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13306
   519
    ==> sats(A, fun_apply_fm(x,y,z), env) <-> 
paulson@13306
   520
        fun_apply(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   521
by (simp add: fun_apply_fm_def fun_apply_def)
paulson@13306
   522
paulson@13306
   523
lemma fun_apply_iff_sats:
paulson@13306
   524
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13306
   525
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13306
   526
       ==> fun_apply(**A, x, y, z) <-> sats(A, fun_apply_fm(i,j,k), env)"
paulson@13306
   527
by simp
paulson@13306
   528
paulson@13314
   529
theorem fun_apply_reflection:
paulson@13314
   530
     "REFLECTS[\<lambda>x. fun_apply(L,f(x),g(x),h(x)), 
paulson@13314
   531
               \<lambda>i x. fun_apply(**Lset(i),f(x),g(x),h(x))]" 
paulson@13314
   532
apply (simp only: fun_apply_def setclass_simps)
paulson@13314
   533
apply (intro FOL_reflection pair_reflection)  
paulson@13314
   534
done
paulson@13298
   535
paulson@13298
   536
paulson@13306
   537
subsubsection{*Variants of Satisfaction Definitions for Ordinals, etc.*}
paulson@13306
   538
paulson@13306
   539
text{*Differs from the one in Formula by using "ordinal" rather than "Ord"*}
paulson@13306
   540
paulson@13306
   541
paulson@13306
   542
lemma sats_subset_fm':
paulson@13306
   543
   "[|x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13306
   544
    ==> sats(A, subset_fm(x,y), env) <-> subset(**A, nth(x,env), nth(y,env))" 
paulson@13306
   545
by (simp add: subset_fm_def subset_def) 
paulson@13298
   546
paulson@13314
   547
theorem subset_reflection:
paulson@13314
   548
     "REFLECTS[\<lambda>x. subset(L,f(x),g(x)), 
paulson@13314
   549
               \<lambda>i x. subset(**Lset(i),f(x),g(x))]" 
paulson@13314
   550
apply (simp only: subset_def setclass_simps)
paulson@13314
   551
apply (intro FOL_reflection)  
paulson@13314
   552
done
paulson@13306
   553
paulson@13306
   554
lemma sats_transset_fm':
paulson@13306
   555
   "[|x \<in> nat; env \<in> list(A)|]
paulson@13306
   556
    ==> sats(A, transset_fm(x), env) <-> transitive_set(**A, nth(x,env))"
paulson@13306
   557
by (simp add: sats_subset_fm' transset_fm_def transitive_set_def) 
paulson@13298
   558
paulson@13314
   559
theorem transitive_set_reflection:
paulson@13314
   560
     "REFLECTS[\<lambda>x. transitive_set(L,f(x)),
paulson@13314
   561
               \<lambda>i x. transitive_set(**Lset(i),f(x))]"
paulson@13314
   562
apply (simp only: transitive_set_def setclass_simps)
paulson@13314
   563
apply (intro FOL_reflection subset_reflection)  
paulson@13314
   564
done
paulson@13306
   565
paulson@13306
   566
lemma sats_ordinal_fm':
paulson@13306
   567
   "[|x \<in> nat; env \<in> list(A)|]
paulson@13306
   568
    ==> sats(A, ordinal_fm(x), env) <-> ordinal(**A,nth(x,env))"
paulson@13306
   569
by (simp add: sats_transset_fm' ordinal_fm_def ordinal_def)
paulson@13306
   570
paulson@13306
   571
lemma ordinal_iff_sats:
paulson@13306
   572
      "[| nth(i,env) = x;  i \<in> nat; env \<in> list(A)|]
paulson@13306
   573
       ==> ordinal(**A, x) <-> sats(A, ordinal_fm(i), env)"
paulson@13306
   574
by (simp add: sats_ordinal_fm')
paulson@13306
   575
paulson@13314
   576
theorem ordinal_reflection:
paulson@13314
   577
     "REFLECTS[\<lambda>x. ordinal(L,f(x)), \<lambda>i x. ordinal(**Lset(i),f(x))]"
paulson@13314
   578
apply (simp only: ordinal_def setclass_simps)
paulson@13314
   579
apply (intro FOL_reflection transitive_set_reflection)  
paulson@13314
   580
done
paulson@13298
   581
paulson@13298
   582
paulson@13306
   583
subsubsection{*Membership Relation*}
paulson@13298
   584
paulson@13306
   585
constdefs Memrel_fm :: "[i,i]=>i"
paulson@13306
   586
    "Memrel_fm(A,r) == 
paulson@13306
   587
       Forall(Iff(Member(0,succ(r)),
paulson@13306
   588
                  Exists(And(Member(0,succ(succ(A))),
paulson@13306
   589
                             Exists(And(Member(0,succ(succ(succ(A)))),
paulson@13306
   590
                                        And(Member(1,0),
paulson@13306
   591
                                            pair_fm(1,0,2))))))))"
paulson@13306
   592
paulson@13306
   593
lemma Memrel_type [TC]:
paulson@13306
   594
     "[| x \<in> nat; y \<in> nat |] ==> Memrel_fm(x,y) \<in> formula"
paulson@13306
   595
by (simp add: Memrel_fm_def) 
paulson@13298
   596
paulson@13306
   597
lemma arity_Memrel_fm [simp]:
paulson@13306
   598
     "[| x \<in> nat; y \<in> nat |] 
paulson@13306
   599
      ==> arity(Memrel_fm(x,y)) = succ(x) \<union> succ(y)"
paulson@13306
   600
by (simp add: Memrel_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   601
paulson@13306
   602
lemma sats_Memrel_fm [simp]:
paulson@13306
   603
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13306
   604
    ==> sats(A, Memrel_fm(x,y), env) <-> 
paulson@13306
   605
        membership(**A, nth(x,env), nth(y,env))"
paulson@13306
   606
by (simp add: Memrel_fm_def membership_def)
paulson@13298
   607
paulson@13306
   608
lemma Memrel_iff_sats:
paulson@13306
   609
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   610
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13306
   611
       ==> membership(**A, x, y) <-> sats(A, Memrel_fm(i,j), env)"
paulson@13306
   612
by simp
paulson@13304
   613
paulson@13314
   614
theorem membership_reflection:
paulson@13314
   615
     "REFLECTS[\<lambda>x. membership(L,f(x),g(x)), 
paulson@13314
   616
               \<lambda>i x. membership(**Lset(i),f(x),g(x))]"
paulson@13314
   617
apply (simp only: membership_def setclass_simps)
paulson@13314
   618
apply (intro FOL_reflection pair_reflection)  
paulson@13314
   619
done
paulson@13304
   620
paulson@13306
   621
subsubsection{*Predecessor Set*}
paulson@13304
   622
paulson@13306
   623
constdefs pred_set_fm :: "[i,i,i,i]=>i"
paulson@13306
   624
    "pred_set_fm(A,x,r,B) == 
paulson@13306
   625
       Forall(Iff(Member(0,succ(B)),
paulson@13306
   626
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   627
                             And(Member(1,succ(succ(A))),
paulson@13306
   628
                                 pair_fm(1,succ(succ(x)),0))))))"
paulson@13306
   629
paulson@13306
   630
paulson@13306
   631
lemma pred_set_type [TC]:
paulson@13306
   632
     "[| A \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat |] 
paulson@13306
   633
      ==> pred_set_fm(A,x,r,B) \<in> formula"
paulson@13306
   634
by (simp add: pred_set_fm_def) 
paulson@13304
   635
paulson@13306
   636
lemma arity_pred_set_fm [simp]:
paulson@13306
   637
   "[| A \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat |] 
paulson@13306
   638
    ==> arity(pred_set_fm(A,x,r,B)) = succ(A) \<union> succ(x) \<union> succ(r) \<union> succ(B)"
paulson@13306
   639
by (simp add: pred_set_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   640
paulson@13306
   641
lemma sats_pred_set_fm [simp]:
paulson@13306
   642
   "[| U \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat; env \<in> list(A)|]
paulson@13306
   643
    ==> sats(A, pred_set_fm(U,x,r,B), env) <-> 
paulson@13306
   644
        pred_set(**A, nth(U,env), nth(x,env), nth(r,env), nth(B,env))"
paulson@13306
   645
by (simp add: pred_set_fm_def pred_set_def)
paulson@13306
   646
paulson@13306
   647
lemma pred_set_iff_sats:
paulson@13306
   648
      "[| nth(i,env) = U; nth(j,env) = x; nth(k,env) = r; nth(l,env) = B; 
paulson@13306
   649
          i \<in> nat; j \<in> nat; k \<in> nat; l \<in> nat; env \<in> list(A)|]
paulson@13306
   650
       ==> pred_set(**A,U,x,r,B) <-> sats(A, pred_set_fm(i,j,k,l), env)"
paulson@13306
   651
by (simp add: sats_pred_set_fm)
paulson@13306
   652
paulson@13314
   653
theorem pred_set_reflection:
paulson@13314
   654
     "REFLECTS[\<lambda>x. pred_set(L,f(x),g(x),h(x),b(x)), 
paulson@13314
   655
               \<lambda>i x. pred_set(**Lset(i),f(x),g(x),h(x),b(x))]" 
paulson@13314
   656
apply (simp only: pred_set_def setclass_simps)
paulson@13314
   657
apply (intro FOL_reflection pair_reflection)  
paulson@13314
   658
done
paulson@13304
   659
paulson@13304
   660
paulson@13298
   661
paulson@13306
   662
subsubsection{*Domain*}
paulson@13306
   663
paulson@13306
   664
(* "is_domain(M,r,z) == 
paulson@13306
   665
	\<forall>x[M]. (x \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>y[M]. pair(M,x,y,w))))" *)
paulson@13306
   666
constdefs domain_fm :: "[i,i]=>i"
paulson@13306
   667
    "domain_fm(r,z) == 
paulson@13306
   668
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   669
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   670
                             Exists(pair_fm(2,0,1))))))"
paulson@13306
   671
paulson@13306
   672
lemma domain_type [TC]:
paulson@13306
   673
     "[| x \<in> nat; y \<in> nat |] ==> domain_fm(x,y) \<in> formula"
paulson@13306
   674
by (simp add: domain_fm_def) 
paulson@13306
   675
paulson@13306
   676
lemma arity_domain_fm [simp]:
paulson@13306
   677
     "[| x \<in> nat; y \<in> nat |] 
paulson@13306
   678
      ==> arity(domain_fm(x,y)) = succ(x) \<union> succ(y)"
paulson@13306
   679
by (simp add: domain_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   680
paulson@13306
   681
lemma sats_domain_fm [simp]:
paulson@13306
   682
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13306
   683
    ==> sats(A, domain_fm(x,y), env) <-> 
paulson@13306
   684
        is_domain(**A, nth(x,env), nth(y,env))"
paulson@13306
   685
by (simp add: domain_fm_def is_domain_def)
paulson@13306
   686
paulson@13306
   687
lemma domain_iff_sats:
paulson@13306
   688
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   689
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13306
   690
       ==> is_domain(**A, x, y) <-> sats(A, domain_fm(i,j), env)"
paulson@13306
   691
by simp
paulson@13306
   692
paulson@13314
   693
theorem domain_reflection:
paulson@13314
   694
     "REFLECTS[\<lambda>x. is_domain(L,f(x),g(x)), 
paulson@13314
   695
               \<lambda>i x. is_domain(**Lset(i),f(x),g(x))]"
paulson@13314
   696
apply (simp only: is_domain_def setclass_simps)
paulson@13314
   697
apply (intro FOL_reflection pair_reflection)  
paulson@13314
   698
done
paulson@13306
   699
paulson@13306
   700
paulson@13306
   701
subsubsection{*Range*}
paulson@13306
   702
paulson@13306
   703
(* "is_range(M,r,z) == 
paulson@13306
   704
	\<forall>y[M]. (y \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>x[M]. pair(M,x,y,w))))" *)
paulson@13306
   705
constdefs range_fm :: "[i,i]=>i"
paulson@13306
   706
    "range_fm(r,z) == 
paulson@13306
   707
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   708
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   709
                             Exists(pair_fm(0,2,1))))))"
paulson@13306
   710
paulson@13306
   711
lemma range_type [TC]:
paulson@13306
   712
     "[| x \<in> nat; y \<in> nat |] ==> range_fm(x,y) \<in> formula"
paulson@13306
   713
by (simp add: range_fm_def) 
paulson@13306
   714
paulson@13306
   715
lemma arity_range_fm [simp]:
paulson@13306
   716
     "[| x \<in> nat; y \<in> nat |] 
paulson@13306
   717
      ==> arity(range_fm(x,y)) = succ(x) \<union> succ(y)"
paulson@13306
   718
by (simp add: range_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   719
paulson@13306
   720
lemma sats_range_fm [simp]:
paulson@13306
   721
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13306
   722
    ==> sats(A, range_fm(x,y), env) <-> 
paulson@13306
   723
        is_range(**A, nth(x,env), nth(y,env))"
paulson@13306
   724
by (simp add: range_fm_def is_range_def)
paulson@13306
   725
paulson@13306
   726
lemma range_iff_sats:
paulson@13306
   727
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   728
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13306
   729
       ==> is_range(**A, x, y) <-> sats(A, range_fm(i,j), env)"
paulson@13306
   730
by simp
paulson@13306
   731
paulson@13314
   732
theorem range_reflection:
paulson@13314
   733
     "REFLECTS[\<lambda>x. is_range(L,f(x),g(x)), 
paulson@13314
   734
               \<lambda>i x. is_range(**Lset(i),f(x),g(x))]"
paulson@13314
   735
apply (simp only: is_range_def setclass_simps)
paulson@13314
   736
apply (intro FOL_reflection pair_reflection)  
paulson@13314
   737
done
paulson@13306
   738
paulson@13306
   739
 
paulson@13306
   740
subsubsection{*Image*}
paulson@13306
   741
paulson@13306
   742
(* "image(M,r,A,z) == 
paulson@13306
   743
        \<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
   744
constdefs image_fm :: "[i,i,i]=>i"
paulson@13306
   745
    "image_fm(r,A,z) == 
paulson@13306
   746
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   747
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   748
                             Exists(And(Member(0,succ(succ(succ(A)))),
paulson@13306
   749
	 			        pair_fm(0,2,1)))))))"
paulson@13306
   750
paulson@13306
   751
lemma image_type [TC]:
paulson@13306
   752
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> image_fm(x,y,z) \<in> formula"
paulson@13306
   753
by (simp add: image_fm_def) 
paulson@13306
   754
paulson@13306
   755
lemma arity_image_fm [simp]:
paulson@13306
   756
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13306
   757
      ==> arity(image_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13306
   758
by (simp add: image_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   759
paulson@13306
   760
lemma sats_image_fm [simp]:
paulson@13306
   761
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13306
   762
    ==> sats(A, image_fm(x,y,z), env) <-> 
paulson@13306
   763
        image(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   764
by (simp add: image_fm_def image_def)
paulson@13306
   765
paulson@13306
   766
lemma image_iff_sats:
paulson@13306
   767
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13306
   768
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13306
   769
       ==> image(**A, x, y, z) <-> sats(A, image_fm(i,j,k), env)"
paulson@13306
   770
by (simp add: sats_image_fm)
paulson@13306
   771
paulson@13314
   772
theorem image_reflection:
paulson@13314
   773
     "REFLECTS[\<lambda>x. image(L,f(x),g(x),h(x)), 
paulson@13314
   774
               \<lambda>i x. image(**Lset(i),f(x),g(x),h(x))]"
paulson@13314
   775
apply (simp only: image_def setclass_simps)
paulson@13314
   776
apply (intro FOL_reflection pair_reflection)  
paulson@13314
   777
done
paulson@13306
   778
paulson@13306
   779
paulson@13306
   780
subsubsection{*The Concept of Relation*}
paulson@13306
   781
paulson@13306
   782
(* "is_relation(M,r) == 
paulson@13306
   783
        (\<forall>z[M]. z\<in>r --> (\<exists>x[M]. \<exists>y[M]. pair(M,x,y,z)))" *)
paulson@13306
   784
constdefs relation_fm :: "i=>i"
paulson@13306
   785
    "relation_fm(r) == 
paulson@13306
   786
       Forall(Implies(Member(0,succ(r)), Exists(Exists(pair_fm(1,0,2)))))"
paulson@13306
   787
paulson@13306
   788
lemma relation_type [TC]:
paulson@13306
   789
     "[| x \<in> nat |] ==> relation_fm(x) \<in> formula"
paulson@13306
   790
by (simp add: relation_fm_def) 
paulson@13306
   791
paulson@13306
   792
lemma arity_relation_fm [simp]:
paulson@13306
   793
     "x \<in> nat ==> arity(relation_fm(x)) = succ(x)"
paulson@13306
   794
by (simp add: relation_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   795
paulson@13306
   796
lemma sats_relation_fm [simp]:
paulson@13306
   797
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13306
   798
    ==> sats(A, relation_fm(x), env) <-> is_relation(**A, nth(x,env))"
paulson@13306
   799
by (simp add: relation_fm_def is_relation_def)
paulson@13306
   800
paulson@13306
   801
lemma relation_iff_sats:
paulson@13306
   802
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   803
          i \<in> nat; env \<in> list(A)|]
paulson@13306
   804
       ==> is_relation(**A, x) <-> sats(A, relation_fm(i), env)"
paulson@13306
   805
by simp
paulson@13306
   806
paulson@13314
   807
theorem is_relation_reflection:
paulson@13314
   808
     "REFLECTS[\<lambda>x. is_relation(L,f(x)), 
paulson@13314
   809
               \<lambda>i x. is_relation(**Lset(i),f(x))]"
paulson@13314
   810
apply (simp only: is_relation_def setclass_simps)
paulson@13314
   811
apply (intro FOL_reflection pair_reflection)  
paulson@13314
   812
done
paulson@13306
   813
paulson@13306
   814
paulson@13306
   815
subsubsection{*The Concept of Function*}
paulson@13306
   816
paulson@13306
   817
(* "is_function(M,r) == 
paulson@13306
   818
	\<forall>x[M]. \<forall>y[M]. \<forall>y'[M]. \<forall>p[M]. \<forall>p'[M]. 
paulson@13306
   819
           pair(M,x,y,p) --> pair(M,x,y',p') --> p\<in>r --> p'\<in>r --> y=y'" *)
paulson@13306
   820
constdefs function_fm :: "i=>i"
paulson@13306
   821
    "function_fm(r) == 
paulson@13306
   822
       Forall(Forall(Forall(Forall(Forall(
paulson@13306
   823
         Implies(pair_fm(4,3,1),
paulson@13306
   824
                 Implies(pair_fm(4,2,0),
paulson@13306
   825
                         Implies(Member(1,r#+5),
paulson@13306
   826
                                 Implies(Member(0,r#+5), Equal(3,2))))))))))"
paulson@13306
   827
paulson@13306
   828
lemma function_type [TC]:
paulson@13306
   829
     "[| x \<in> nat |] ==> function_fm(x) \<in> formula"
paulson@13306
   830
by (simp add: function_fm_def) 
paulson@13306
   831
paulson@13306
   832
lemma arity_function_fm [simp]:
paulson@13306
   833
     "x \<in> nat ==> arity(function_fm(x)) = succ(x)"
paulson@13306
   834
by (simp add: function_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13306
   835
paulson@13306
   836
lemma sats_function_fm [simp]:
paulson@13306
   837
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13306
   838
    ==> sats(A, function_fm(x), env) <-> is_function(**A, nth(x,env))"
paulson@13306
   839
by (simp add: function_fm_def is_function_def)
paulson@13306
   840
paulson@13306
   841
lemma function_iff_sats:
paulson@13306
   842
      "[| nth(i,env) = x; nth(j,env) = y; 
paulson@13306
   843
          i \<in> nat; env \<in> list(A)|]
paulson@13306
   844
       ==> is_function(**A, x) <-> sats(A, function_fm(i), env)"
paulson@13306
   845
by simp
paulson@13306
   846
paulson@13314
   847
theorem is_function_reflection:
paulson@13314
   848
     "REFLECTS[\<lambda>x. is_function(L,f(x)), 
paulson@13314
   849
               \<lambda>i x. is_function(**Lset(i),f(x))]"
paulson@13314
   850
apply (simp only: is_function_def setclass_simps)
paulson@13314
   851
apply (intro FOL_reflection pair_reflection)  
paulson@13314
   852
done
paulson@13298
   853
paulson@13298
   854
paulson@13309
   855
subsubsection{*Typed Functions*}
paulson@13309
   856
paulson@13309
   857
(* "typed_function(M,A,B,r) == 
paulson@13309
   858
        is_function(M,r) & is_relation(M,r) & is_domain(M,r,A) &
paulson@13309
   859
        (\<forall>u[M]. u\<in>r --> (\<forall>x[M]. \<forall>y[M]. pair(M,x,y,u) --> y\<in>B))" *)
paulson@13309
   860
paulson@13309
   861
constdefs typed_function_fm :: "[i,i,i]=>i"
paulson@13309
   862
    "typed_function_fm(A,B,r) == 
paulson@13309
   863
       And(function_fm(r),
paulson@13309
   864
         And(relation_fm(r),
paulson@13309
   865
           And(domain_fm(r,A),
paulson@13309
   866
             Forall(Implies(Member(0,succ(r)),
paulson@13309
   867
                  Forall(Forall(Implies(pair_fm(1,0,2),Member(0,B#+3)))))))))"
paulson@13309
   868
paulson@13309
   869
lemma typed_function_type [TC]:
paulson@13309
   870
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> typed_function_fm(x,y,z) \<in> formula"
paulson@13309
   871
by (simp add: typed_function_fm_def) 
paulson@13309
   872
paulson@13309
   873
lemma arity_typed_function_fm [simp]:
paulson@13309
   874
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13309
   875
      ==> arity(typed_function_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13309
   876
by (simp add: typed_function_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13309
   877
paulson@13309
   878
lemma sats_typed_function_fm [simp]:
paulson@13309
   879
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13309
   880
    ==> sats(A, typed_function_fm(x,y,z), env) <-> 
paulson@13309
   881
        typed_function(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13309
   882
by (simp add: typed_function_fm_def typed_function_def)
paulson@13309
   883
paulson@13309
   884
lemma typed_function_iff_sats:
paulson@13309
   885
  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13309
   886
      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13309
   887
   ==> typed_function(**A, x, y, z) <-> sats(A, typed_function_fm(i,j,k), env)"
paulson@13309
   888
by simp
paulson@13309
   889
paulson@13314
   890
lemmas function_reflection = 
paulson@13314
   891
        upair_reflection pair_reflection union_reflection
paulson@13314
   892
	cons_reflection fun_apply_reflection subset_reflection
paulson@13314
   893
	transitive_set_reflection ordinal_reflection membership_reflection
paulson@13314
   894
	pred_set_reflection domain_reflection range_reflection image_reflection
paulson@13314
   895
	is_relation_reflection is_function_reflection
paulson@13309
   896
paulson@13309
   897
paulson@13314
   898
theorem typed_function_reflection:
paulson@13314
   899
     "REFLECTS[\<lambda>x. typed_function(L,f(x),g(x),h(x)), 
paulson@13314
   900
               \<lambda>i x. typed_function(**Lset(i),f(x),g(x),h(x))]"
paulson@13314
   901
apply (simp only: typed_function_def setclass_simps)
paulson@13314
   902
apply (intro FOL_reflection function_reflection)  
paulson@13314
   903
done
paulson@13314
   904
paulson@13309
   905
paulson@13309
   906
subsubsection{*Injections*}
paulson@13309
   907
paulson@13309
   908
(* "injection(M,A,B,f) == 
paulson@13309
   909
	typed_function(M,A,B,f) &
paulson@13309
   910
        (\<forall>x[M]. \<forall>x'[M]. \<forall>y[M]. \<forall>p[M]. \<forall>p'[M]. 
paulson@13309
   911
          pair(M,x,y,p) --> pair(M,x',y,p') --> p\<in>f --> p'\<in>f --> x=x')" *)
paulson@13309
   912
constdefs injection_fm :: "[i,i,i]=>i"
paulson@13309
   913
 "injection_fm(A,B,f) == 
paulson@13309
   914
    And(typed_function_fm(A,B,f),
paulson@13309
   915
       Forall(Forall(Forall(Forall(Forall(
paulson@13309
   916
         Implies(pair_fm(4,2,1),
paulson@13309
   917
                 Implies(pair_fm(3,2,0),
paulson@13309
   918
                         Implies(Member(1,f#+5),
paulson@13309
   919
                                 Implies(Member(0,f#+5), Equal(4,3)))))))))))"
paulson@13309
   920
paulson@13309
   921
paulson@13309
   922
lemma injection_type [TC]:
paulson@13309
   923
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> injection_fm(x,y,z) \<in> formula"
paulson@13309
   924
by (simp add: injection_fm_def) 
paulson@13309
   925
paulson@13309
   926
lemma arity_injection_fm [simp]:
paulson@13309
   927
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13309
   928
      ==> arity(injection_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13309
   929
by (simp add: injection_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13309
   930
paulson@13309
   931
lemma sats_injection_fm [simp]:
paulson@13309
   932
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13309
   933
    ==> sats(A, injection_fm(x,y,z), env) <-> 
paulson@13309
   934
        injection(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13309
   935
by (simp add: injection_fm_def injection_def)
paulson@13309
   936
paulson@13309
   937
lemma injection_iff_sats:
paulson@13309
   938
  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13309
   939
      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13309
   940
   ==> injection(**A, x, y, z) <-> sats(A, injection_fm(i,j,k), env)"
paulson@13309
   941
by simp
paulson@13309
   942
paulson@13314
   943
theorem injection_reflection:
paulson@13314
   944
     "REFLECTS[\<lambda>x. injection(L,f(x),g(x),h(x)), 
paulson@13314
   945
               \<lambda>i x. injection(**Lset(i),f(x),g(x),h(x))]"
paulson@13314
   946
apply (simp only: injection_def setclass_simps)
paulson@13314
   947
apply (intro FOL_reflection function_reflection typed_function_reflection)  
paulson@13314
   948
done
paulson@13309
   949
paulson@13309
   950
paulson@13309
   951
subsubsection{*Surjections*}
paulson@13309
   952
paulson@13309
   953
(*  surjection :: "[i=>o,i,i,i] => o"
paulson@13309
   954
    "surjection(M,A,B,f) == 
paulson@13309
   955
        typed_function(M,A,B,f) &
paulson@13309
   956
        (\<forall>y[M]. y\<in>B --> (\<exists>x[M]. x\<in>A & fun_apply(M,f,x,y)))" *)
paulson@13309
   957
constdefs surjection_fm :: "[i,i,i]=>i"
paulson@13309
   958
 "surjection_fm(A,B,f) == 
paulson@13309
   959
    And(typed_function_fm(A,B,f),
paulson@13309
   960
       Forall(Implies(Member(0,succ(B)),
paulson@13309
   961
                      Exists(And(Member(0,succ(succ(A))),
paulson@13309
   962
                                 fun_apply_fm(succ(succ(f)),0,1))))))"
paulson@13309
   963
paulson@13309
   964
lemma surjection_type [TC]:
paulson@13309
   965
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> surjection_fm(x,y,z) \<in> formula"
paulson@13309
   966
by (simp add: surjection_fm_def) 
paulson@13309
   967
paulson@13309
   968
lemma arity_surjection_fm [simp]:
paulson@13309
   969
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13309
   970
      ==> arity(surjection_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13309
   971
by (simp add: surjection_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13309
   972
paulson@13309
   973
lemma sats_surjection_fm [simp]:
paulson@13309
   974
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13309
   975
    ==> sats(A, surjection_fm(x,y,z), env) <-> 
paulson@13309
   976
        surjection(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13309
   977
by (simp add: surjection_fm_def surjection_def)
paulson@13309
   978
paulson@13309
   979
lemma surjection_iff_sats:
paulson@13309
   980
  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13309
   981
      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13309
   982
   ==> surjection(**A, x, y, z) <-> sats(A, surjection_fm(i,j,k), env)"
paulson@13309
   983
by simp
paulson@13309
   984
paulson@13314
   985
theorem surjection_reflection:
paulson@13314
   986
     "REFLECTS[\<lambda>x. surjection(L,f(x),g(x),h(x)), 
paulson@13314
   987
               \<lambda>i x. surjection(**Lset(i),f(x),g(x),h(x))]"
paulson@13314
   988
apply (simp only: surjection_def setclass_simps)
paulson@13314
   989
apply (intro FOL_reflection function_reflection typed_function_reflection)  
paulson@13314
   990
done
paulson@13309
   991
paulson@13309
   992
paulson@13309
   993
paulson@13309
   994
subsubsection{*Bijections*}
paulson@13309
   995
paulson@13309
   996
(*   bijection :: "[i=>o,i,i,i] => o"
paulson@13309
   997
    "bijection(M,A,B,f) == injection(M,A,B,f) & surjection(M,A,B,f)" *)
paulson@13309
   998
constdefs bijection_fm :: "[i,i,i]=>i"
paulson@13309
   999
 "bijection_fm(A,B,f) == And(injection_fm(A,B,f), surjection_fm(A,B,f))"
paulson@13309
  1000
paulson@13309
  1001
lemma bijection_type [TC]:
paulson@13309
  1002
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> bijection_fm(x,y,z) \<in> formula"
paulson@13309
  1003
by (simp add: bijection_fm_def) 
paulson@13309
  1004
paulson@13309
  1005
lemma arity_bijection_fm [simp]:
paulson@13309
  1006
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] 
paulson@13309
  1007
      ==> arity(bijection_fm(x,y,z)) = succ(x) \<union> succ(y) \<union> succ(z)"
paulson@13309
  1008
by (simp add: bijection_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13309
  1009
paulson@13309
  1010
lemma sats_bijection_fm [simp]:
paulson@13309
  1011
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
paulson@13309
  1012
    ==> sats(A, bijection_fm(x,y,z), env) <-> 
paulson@13309
  1013
        bijection(**A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13309
  1014
by (simp add: bijection_fm_def bijection_def)
paulson@13309
  1015
paulson@13309
  1016
lemma bijection_iff_sats:
paulson@13309
  1017
  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z; 
paulson@13309
  1018
      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13309
  1019
   ==> bijection(**A, x, y, z) <-> sats(A, bijection_fm(i,j,k), env)"
paulson@13309
  1020
by simp
paulson@13309
  1021
paulson@13314
  1022
theorem bijection_reflection:
paulson@13314
  1023
     "REFLECTS[\<lambda>x. bijection(L,f(x),g(x),h(x)), 
paulson@13314
  1024
               \<lambda>i x. bijection(**Lset(i),f(x),g(x),h(x))]"
paulson@13314
  1025
apply (simp only: bijection_def setclass_simps)
paulson@13314
  1026
apply (intro And_reflection injection_reflection surjection_reflection)  
paulson@13314
  1027
done
paulson@13309
  1028
paulson@13309
  1029
paulson@13309
  1030
subsubsection{*Order-Isomorphisms*}
paulson@13309
  1031
paulson@13309
  1032
(*  order_isomorphism :: "[i=>o,i,i,i,i,i] => o"
paulson@13309
  1033
   "order_isomorphism(M,A,r,B,s,f) == 
paulson@13309
  1034
        bijection(M,A,B,f) & 
paulson@13309
  1035
        (\<forall>x[M]. x\<in>A --> (\<forall>y[M]. y\<in>A -->
paulson@13309
  1036
          (\<forall>p[M]. \<forall>fx[M]. \<forall>fy[M]. \<forall>q[M].
paulson@13309
  1037
            pair(M,x,y,p) --> fun_apply(M,f,x,fx) --> fun_apply(M,f,y,fy) --> 
paulson@13309
  1038
            pair(M,fx,fy,q) --> (p\<in>r <-> q\<in>s))))"
paulson@13309
  1039
  *)
paulson@13309
  1040
paulson@13309
  1041
constdefs order_isomorphism_fm :: "[i,i,i,i,i]=>i"
paulson@13309
  1042
 "order_isomorphism_fm(A,r,B,s,f) == 
paulson@13309
  1043
   And(bijection_fm(A,B,f), 
paulson@13309
  1044
     Forall(Implies(Member(0,succ(A)),
paulson@13309
  1045
       Forall(Implies(Member(0,succ(succ(A))),
paulson@13309
  1046
         Forall(Forall(Forall(Forall(
paulson@13309
  1047
           Implies(pair_fm(5,4,3),
paulson@13309
  1048
             Implies(fun_apply_fm(f#+6,5,2),
paulson@13309
  1049
               Implies(fun_apply_fm(f#+6,4,1),
paulson@13309
  1050
                 Implies(pair_fm(2,1,0), 
paulson@13309
  1051
                   Iff(Member(3,r#+6), Member(0,s#+6)))))))))))))))"
paulson@13309
  1052
paulson@13309
  1053
lemma order_isomorphism_type [TC]:
paulson@13309
  1054
     "[| A \<in> nat; r \<in> nat; B \<in> nat; s \<in> nat; f \<in> nat |]  
paulson@13309
  1055
      ==> order_isomorphism_fm(A,r,B,s,f) \<in> formula"
paulson@13309
  1056
by (simp add: order_isomorphism_fm_def) 
paulson@13309
  1057
paulson@13309
  1058
lemma arity_order_isomorphism_fm [simp]:
paulson@13309
  1059
     "[| A \<in> nat; r \<in> nat; B \<in> nat; s \<in> nat; f \<in> nat |] 
paulson@13309
  1060
      ==> arity(order_isomorphism_fm(A,r,B,s,f)) = 
paulson@13309
  1061
          succ(A) \<union> succ(r) \<union> succ(B) \<union> succ(s) \<union> succ(f)" 
paulson@13309
  1062
by (simp add: order_isomorphism_fm_def succ_Un_distrib [symmetric] Un_ac) 
paulson@13309
  1063
paulson@13309
  1064
lemma sats_order_isomorphism_fm [simp]:
paulson@13309
  1065
   "[| U \<in> nat; r \<in> nat; B \<in> nat; s \<in> nat; f \<in> nat; env \<in> list(A)|]
paulson@13309
  1066
    ==> sats(A, order_isomorphism_fm(U,r,B,s,f), env) <-> 
paulson@13309
  1067
        order_isomorphism(**A, nth(U,env), nth(r,env), nth(B,env), 
paulson@13309
  1068
                               nth(s,env), nth(f,env))"
paulson@13309
  1069
by (simp add: order_isomorphism_fm_def order_isomorphism_def)
paulson@13309
  1070
paulson@13309
  1071
lemma order_isomorphism_iff_sats:
paulson@13309
  1072
  "[| nth(i,env) = U; nth(j,env) = r; nth(k,env) = B; nth(j',env) = s; 
paulson@13309
  1073
      nth(k',env) = f; 
paulson@13309
  1074
      i \<in> nat; j \<in> nat; k \<in> nat; j' \<in> nat; k' \<in> nat; env \<in> list(A)|]
paulson@13309
  1075
   ==> order_isomorphism(**A,U,r,B,s,f) <-> 
paulson@13309
  1076
       sats(A, order_isomorphism_fm(i,j,k,j',k'), env)" 
paulson@13309
  1077
by simp
paulson@13309
  1078
paulson@13314
  1079
theorem order_isomorphism_reflection:
paulson@13314
  1080
     "REFLECTS[\<lambda>x. order_isomorphism(L,f(x),g(x),h(x),g'(x),h'(x)), 
paulson@13314
  1081
               \<lambda>i x. order_isomorphism(**Lset(i),f(x),g(x),h(x),g'(x),h'(x))]"
paulson@13314
  1082
apply (simp only: order_isomorphism_def setclass_simps)
paulson@13314
  1083
apply (intro FOL_reflection function_reflection bijection_reflection)  
paulson@13314
  1084
done
paulson@13309
  1085
paulson@13316
  1086
lemmas fun_plus_reflection =
paulson@13316
  1087
        typed_function_reflection injection_reflection surjection_reflection
paulson@13316
  1088
        bijection_reflection order_isomorphism_reflection
paulson@13316
  1089
paulson@13316
  1090
lemmas fun_plus_iff_sats = upair_iff_sats pair_iff_sats union_iff_sats
paulson@13316
  1091
	cons_iff_sats fun_apply_iff_sats ordinal_iff_sats Memrel_iff_sats
paulson@13316
  1092
	pred_set_iff_sats domain_iff_sats range_iff_sats image_iff_sats
paulson@13316
  1093
	relation_iff_sats function_iff_sats typed_function_iff_sats 
paulson@13316
  1094
        injection_iff_sats surjection_iff_sats bijection_iff_sats 
paulson@13316
  1095
        order_isomorphism_iff_sats
paulson@13316
  1096
paulson@13223
  1097
end