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