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