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