src/ZF/Constructible/L_axioms.thy
author wenzelm
Tue Nov 07 19:40:13 2006 +0100 (2006-11-07)
changeset 21233 5a5c8ea5f66a
parent 16417 9bc16273c2d4
child 21404 eb85850d3eb7
permissions -rw-r--r--
tuned specifications;
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
haftmann@16417
     8
theory L_axioms imports Formula Relative Reflection MetaExists begin
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*}
wenzelm@21233
   117
definition
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!*}
wenzelm@21233
   130
definition
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
wenzelm@21233
   268
abbreviation
wenzelm@21233
   269
  digit3 :: i   ("3")
wenzelm@21233
   270
  "3 == succ(2)"
wenzelm@21233
   271
  digit4 :: i   ("4")
wenzelm@21233
   272
  "4 == succ(3)"
wenzelm@21233
   273
  digit5 :: i   ("5")
wenzelm@21233
   274
  "5 == succ(4)"
wenzelm@21233
   275
  digit6 :: i   ("6")
wenzelm@21233
   276
  "6 == succ(5)"
wenzelm@21233
   277
  digit7 :: i   ("7")
wenzelm@21233
   278
  "7 == succ(6)"
wenzelm@21233
   279
  digit8 :: i   ("8")
wenzelm@21233
   280
  "8 == succ(7)"
wenzelm@21233
   281
  digit9 :: i   ("9")
wenzelm@21233
   282
  "9 == succ(8)"
paulson@13306
   283
paulson@13323
   284
paulson@13339
   285
subsubsection{*The Empty Set, Internalized*}
paulson@13323
   286
wenzelm@21233
   287
definition empty_fm :: "i=>i"
paulson@13323
   288
    "empty_fm(x) == Forall(Neg(Member(0,succ(x))))"
paulson@13323
   289
paulson@13323
   290
lemma empty_type [TC]:
paulson@13323
   291
     "x \<in> nat ==> empty_fm(x) \<in> formula"
wenzelm@13429
   292
by (simp add: empty_fm_def)
paulson@13323
   293
paulson@13323
   294
lemma sats_empty_fm [simp]:
paulson@13323
   295
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13807
   296
    ==> sats(A, empty_fm(x), env) <-> empty(##A, nth(x,env))"
paulson@13323
   297
by (simp add: empty_fm_def empty_def)
paulson@13323
   298
paulson@13323
   299
lemma empty_iff_sats:
wenzelm@13429
   300
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13323
   301
          i \<in> nat; env \<in> list(A)|]
paulson@13807
   302
       ==> empty(##A, x) <-> sats(A, empty_fm(i), env)"
paulson@13323
   303
by simp
paulson@13323
   304
paulson@13323
   305
theorem empty_reflection:
wenzelm@13429
   306
     "REFLECTS[\<lambda>x. empty(L,f(x)),
paulson@13807
   307
               \<lambda>i x. empty(##Lset(i),f(x))]"
paulson@13655
   308
apply (simp only: empty_def)
wenzelm@13429
   309
apply (intro FOL_reflections)
paulson@13323
   310
done
paulson@13323
   311
paulson@13385
   312
text{*Not used.  But maybe useful?*}
paulson@13385
   313
lemma Transset_sats_empty_fm_eq_0:
paulson@13385
   314
   "[| n \<in> nat; env \<in> list(A); Transset(A)|]
paulson@13385
   315
    ==> sats(A, empty_fm(n), env) <-> nth(n,env) = 0"
paulson@13385
   316
apply (simp add: empty_fm_def empty_def Transset_def, auto)
wenzelm@13429
   317
apply (case_tac "n < length(env)")
wenzelm@13429
   318
apply (frule nth_type, assumption+, blast)
wenzelm@13429
   319
apply (simp_all add: not_lt_iff_le nth_eq_0)
paulson@13385
   320
done
paulson@13385
   321
paulson@13323
   322
paulson@13339
   323
subsubsection{*Unordered Pairs, Internalized*}
paulson@13298
   324
wenzelm@21233
   325
definition upair_fm :: "[i,i,i]=>i"
wenzelm@13429
   326
    "upair_fm(x,y,z) ==
wenzelm@13429
   327
       And(Member(x,z),
paulson@13298
   328
           And(Member(y,z),
wenzelm@13429
   329
               Forall(Implies(Member(0,succ(z)),
paulson@13298
   330
                              Or(Equal(0,succ(x)), Equal(0,succ(y)))))))"
paulson@13298
   331
paulson@13298
   332
lemma upair_type [TC]:
paulson@13298
   333
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> upair_fm(x,y,z) \<in> formula"
wenzelm@13429
   334
by (simp add: upair_fm_def)
paulson@13298
   335
paulson@13298
   336
lemma sats_upair_fm [simp]:
paulson@13298
   337
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
   338
    ==> sats(A, upair_fm(x,y,z), env) <->
paulson@13807
   339
            upair(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13298
   340
by (simp add: upair_fm_def upair_def)
paulson@13298
   341
paulson@13298
   342
lemma upair_iff_sats:
wenzelm@13429
   343
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13298
   344
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
   345
       ==> upair(##A, x, y, z) <-> sats(A, upair_fm(i,j,k), env)"
paulson@13298
   346
by (simp add: sats_upair_fm)
paulson@13298
   347
paulson@13298
   348
text{*Useful? At least it refers to "real" unordered pairs*}
paulson@13298
   349
lemma sats_upair_fm2 [simp]:
paulson@13298
   350
   "[| x \<in> nat; y \<in> nat; z < length(env); env \<in> list(A); Transset(A)|]
wenzelm@13429
   351
    ==> sats(A, upair_fm(x,y,z), env) <->
paulson@13298
   352
        nth(z,env) = {nth(x,env), nth(y,env)}"
wenzelm@13429
   353
apply (frule lt_length_in_nat, assumption)
wenzelm@13429
   354
apply (simp add: upair_fm_def Transset_def, auto)
wenzelm@13429
   355
apply (blast intro: nth_type)
paulson@13298
   356
done
paulson@13298
   357
paulson@13314
   358
theorem upair_reflection:
wenzelm@13429
   359
     "REFLECTS[\<lambda>x. upair(L,f(x),g(x),h(x)),
paulson@13807
   360
               \<lambda>i x. upair(##Lset(i),f(x),g(x),h(x))]"
paulson@13314
   361
apply (simp add: upair_def)
wenzelm@13429
   362
apply (intro FOL_reflections)
paulson@13314
   363
done
paulson@13306
   364
paulson@13339
   365
subsubsection{*Ordered pairs, Internalized*}
paulson@13298
   366
wenzelm@21233
   367
definition pair_fm :: "[i,i,i]=>i"
wenzelm@13429
   368
    "pair_fm(x,y,z) ==
paulson@13298
   369
       Exists(And(upair_fm(succ(x),succ(x),0),
paulson@13298
   370
              Exists(And(upair_fm(succ(succ(x)),succ(succ(y)),0),
paulson@13298
   371
                         upair_fm(1,0,succ(succ(z)))))))"
paulson@13298
   372
paulson@13298
   373
lemma pair_type [TC]:
paulson@13298
   374
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> pair_fm(x,y,z) \<in> formula"
wenzelm@13429
   375
by (simp add: pair_fm_def)
paulson@13298
   376
paulson@13298
   377
lemma sats_pair_fm [simp]:
paulson@13298
   378
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
   379
    ==> sats(A, pair_fm(x,y,z), env) <->
paulson@13807
   380
        pair(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13298
   381
by (simp add: pair_fm_def pair_def)
paulson@13298
   382
paulson@13298
   383
lemma pair_iff_sats:
wenzelm@13429
   384
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13298
   385
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
   386
       ==> pair(##A, x, y, z) <-> sats(A, pair_fm(i,j,k), env)"
paulson@13298
   387
by (simp add: sats_pair_fm)
paulson@13298
   388
paulson@13314
   389
theorem pair_reflection:
wenzelm@13429
   390
     "REFLECTS[\<lambda>x. pair(L,f(x),g(x),h(x)),
paulson@13807
   391
               \<lambda>i x. pair(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
   392
apply (simp only: pair_def)
wenzelm@13429
   393
apply (intro FOL_reflections upair_reflection)
paulson@13314
   394
done
paulson@13306
   395
paulson@13306
   396
paulson@13339
   397
subsubsection{*Binary Unions, Internalized*}
paulson@13298
   398
wenzelm@21233
   399
definition union_fm :: "[i,i,i]=>i"
wenzelm@13429
   400
    "union_fm(x,y,z) ==
paulson@13306
   401
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   402
                  Or(Member(0,succ(x)),Member(0,succ(y)))))"
paulson@13306
   403
paulson@13306
   404
lemma union_type [TC]:
paulson@13306
   405
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> union_fm(x,y,z) \<in> formula"
wenzelm@13429
   406
by (simp add: union_fm_def)
paulson@13306
   407
paulson@13306
   408
lemma sats_union_fm [simp]:
paulson@13306
   409
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
   410
    ==> sats(A, union_fm(x,y,z), env) <->
paulson@13807
   411
        union(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   412
by (simp add: union_fm_def union_def)
paulson@13306
   413
paulson@13306
   414
lemma union_iff_sats:
wenzelm@13429
   415
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13306
   416
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
   417
       ==> union(##A, x, y, z) <-> sats(A, union_fm(i,j,k), env)"
paulson@13306
   418
by (simp add: sats_union_fm)
paulson@13298
   419
paulson@13314
   420
theorem union_reflection:
wenzelm@13429
   421
     "REFLECTS[\<lambda>x. union(L,f(x),g(x),h(x)),
paulson@13807
   422
               \<lambda>i x. union(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
   423
apply (simp only: union_def)
wenzelm@13429
   424
apply (intro FOL_reflections)
paulson@13314
   425
done
paulson@13306
   426
paulson@13298
   427
paulson@13339
   428
subsubsection{*Set ``Cons,'' Internalized*}
paulson@13306
   429
wenzelm@21233
   430
definition cons_fm :: "[i,i,i]=>i"
wenzelm@13429
   431
    "cons_fm(x,y,z) ==
paulson@13306
   432
       Exists(And(upair_fm(succ(x),succ(x),0),
paulson@13306
   433
                  union_fm(0,succ(y),succ(z))))"
paulson@13298
   434
paulson@13298
   435
paulson@13306
   436
lemma cons_type [TC]:
paulson@13306
   437
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> cons_fm(x,y,z) \<in> formula"
wenzelm@13429
   438
by (simp add: cons_fm_def)
paulson@13306
   439
paulson@13306
   440
lemma sats_cons_fm [simp]:
paulson@13306
   441
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
   442
    ==> sats(A, cons_fm(x,y,z), env) <->
paulson@13807
   443
        is_cons(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13306
   444
by (simp add: cons_fm_def is_cons_def)
paulson@13306
   445
paulson@13306
   446
lemma cons_iff_sats:
wenzelm@13429
   447
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13306
   448
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
   449
       ==> is_cons(##A, x, y, z) <-> sats(A, cons_fm(i,j,k), env)"
paulson@13306
   450
by simp
paulson@13306
   451
paulson@13314
   452
theorem cons_reflection:
wenzelm@13429
   453
     "REFLECTS[\<lambda>x. is_cons(L,f(x),g(x),h(x)),
paulson@13807
   454
               \<lambda>i x. is_cons(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
   455
apply (simp only: is_cons_def)
wenzelm@13429
   456
apply (intro FOL_reflections upair_reflection union_reflection)
paulson@13323
   457
done
paulson@13323
   458
paulson@13323
   459
paulson@13339
   460
subsubsection{*Successor Function, Internalized*}
paulson@13323
   461
wenzelm@21233
   462
definition succ_fm :: "[i,i]=>i"
paulson@13323
   463
    "succ_fm(x,y) == cons_fm(x,x,y)"
paulson@13323
   464
paulson@13323
   465
lemma succ_type [TC]:
paulson@13323
   466
     "[| x \<in> nat; y \<in> nat |] ==> succ_fm(x,y) \<in> formula"
wenzelm@13429
   467
by (simp add: succ_fm_def)
paulson@13323
   468
paulson@13323
   469
lemma sats_succ_fm [simp]:
paulson@13323
   470
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
wenzelm@13429
   471
    ==> sats(A, succ_fm(x,y), env) <->
paulson@13807
   472
        successor(##A, nth(x,env), nth(y,env))"
paulson@13323
   473
by (simp add: succ_fm_def successor_def)
paulson@13323
   474
paulson@13323
   475
lemma successor_iff_sats:
wenzelm@13429
   476
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13323
   477
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13807
   478
       ==> successor(##A, x, y) <-> sats(A, succ_fm(i,j), env)"
paulson@13323
   479
by simp
paulson@13323
   480
paulson@13323
   481
theorem successor_reflection:
wenzelm@13429
   482
     "REFLECTS[\<lambda>x. successor(L,f(x),g(x)),
paulson@13807
   483
               \<lambda>i x. successor(##Lset(i),f(x),g(x))]"
paulson@13655
   484
apply (simp only: successor_def)
wenzelm@13429
   485
apply (intro cons_reflection)
paulson@13314
   486
done
paulson@13298
   487
paulson@13298
   488
paulson@13363
   489
subsubsection{*The Number 1, Internalized*}
paulson@13363
   490
paulson@13363
   491
(* "number1(M,a) == (\<exists>x[M]. empty(M,x) & successor(M,x,a))" *)
wenzelm@21233
   492
definition number1_fm :: "i=>i"
paulson@13363
   493
    "number1_fm(a) == Exists(And(empty_fm(0), succ_fm(0,succ(a))))"
paulson@13363
   494
paulson@13363
   495
lemma number1_type [TC]:
paulson@13363
   496
     "x \<in> nat ==> number1_fm(x) \<in> formula"
wenzelm@13429
   497
by (simp add: number1_fm_def)
paulson@13363
   498
paulson@13363
   499
lemma sats_number1_fm [simp]:
paulson@13363
   500
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13807
   501
    ==> sats(A, number1_fm(x), env) <-> number1(##A, nth(x,env))"
paulson@13363
   502
by (simp add: number1_fm_def number1_def)
paulson@13363
   503
paulson@13363
   504
lemma number1_iff_sats:
wenzelm@13429
   505
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13363
   506
          i \<in> nat; env \<in> list(A)|]
paulson@13807
   507
       ==> number1(##A, x) <-> sats(A, number1_fm(i), env)"
paulson@13363
   508
by simp
paulson@13363
   509
paulson@13363
   510
theorem number1_reflection:
wenzelm@13429
   511
     "REFLECTS[\<lambda>x. number1(L,f(x)),
paulson@13807
   512
               \<lambda>i x. number1(##Lset(i),f(x))]"
paulson@13655
   513
apply (simp only: number1_def)
paulson@13363
   514
apply (intro FOL_reflections empty_reflection successor_reflection)
paulson@13363
   515
done
paulson@13363
   516
paulson@13363
   517
paulson@13352
   518
subsubsection{*Big Union, Internalized*}
paulson@13306
   519
paulson@13352
   520
(*  "big_union(M,A,z) == \<forall>x[M]. x \<in> z <-> (\<exists>y[M]. y\<in>A & x \<in> y)" *)
wenzelm@21233
   521
definition big_union_fm :: "[i,i]=>i"
wenzelm@13429
   522
    "big_union_fm(A,z) ==
paulson@13352
   523
       Forall(Iff(Member(0,succ(z)),
paulson@13352
   524
                  Exists(And(Member(0,succ(succ(A))), Member(1,0)))))"
paulson@13298
   525
paulson@13352
   526
lemma big_union_type [TC]:
paulson@13352
   527
     "[| x \<in> nat; y \<in> nat |] ==> big_union_fm(x,y) \<in> formula"
wenzelm@13429
   528
by (simp add: big_union_fm_def)
paulson@13306
   529
paulson@13352
   530
lemma sats_big_union_fm [simp]:
paulson@13352
   531
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
wenzelm@13429
   532
    ==> sats(A, big_union_fm(x,y), env) <->
paulson@13807
   533
        big_union(##A, nth(x,env), nth(y,env))"
paulson@13352
   534
by (simp add: big_union_fm_def big_union_def)
paulson@13306
   535
paulson@13352
   536
lemma big_union_iff_sats:
wenzelm@13429
   537
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13352
   538
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13807
   539
       ==> big_union(##A, x, y) <-> sats(A, big_union_fm(i,j), env)"
paulson@13306
   540
by simp
paulson@13306
   541
paulson@13352
   542
theorem big_union_reflection:
wenzelm@13429
   543
     "REFLECTS[\<lambda>x. big_union(L,f(x),g(x)),
paulson@13807
   544
               \<lambda>i x. big_union(##Lset(i),f(x),g(x))]"
paulson@13655
   545
apply (simp only: big_union_def)
wenzelm@13429
   546
apply (intro FOL_reflections)
paulson@13314
   547
done
paulson@13298
   548
paulson@13298
   549
paulson@13306
   550
subsubsection{*Variants of Satisfaction Definitions for Ordinals, etc.*}
paulson@13306
   551
paulson@13651
   552
text{*The @{text sats} theorems below are standard versions of the ones proved
paulson@13651
   553
in theory @{text Formula}.  They relate elements of type @{term formula} to
paulson@13651
   554
relativized concepts such as @{term subset} or @{term ordinal} rather than to
paulson@13651
   555
real concepts such as @{term Ord}.  Now that we have instantiated the locale
paulson@13651
   556
@{text M_trivial}, we no longer require the earlier versions.*}
paulson@13306
   557
paulson@13306
   558
lemma sats_subset_fm':
paulson@13306
   559
   "[|x \<in> nat; y \<in> nat; env \<in> list(A)|]
paulson@13807
   560
    ==> sats(A, subset_fm(x,y), env) <-> subset(##A, nth(x,env), nth(y,env))"
wenzelm@13429
   561
by (simp add: subset_fm_def Relative.subset_def)
paulson@13298
   562
paulson@13314
   563
theorem subset_reflection:
wenzelm@13429
   564
     "REFLECTS[\<lambda>x. subset(L,f(x),g(x)),
paulson@13807
   565
               \<lambda>i x. subset(##Lset(i),f(x),g(x))]"
paulson@13655
   566
apply (simp only: Relative.subset_def)
wenzelm@13429
   567
apply (intro FOL_reflections)
paulson@13314
   568
done
paulson@13306
   569
paulson@13306
   570
lemma sats_transset_fm':
paulson@13306
   571
   "[|x \<in> nat; env \<in> list(A)|]
paulson@13807
   572
    ==> sats(A, transset_fm(x), env) <-> transitive_set(##A, nth(x,env))"
wenzelm@13429
   573
by (simp add: sats_subset_fm' transset_fm_def transitive_set_def)
paulson@13298
   574
paulson@13314
   575
theorem transitive_set_reflection:
paulson@13314
   576
     "REFLECTS[\<lambda>x. transitive_set(L,f(x)),
paulson@13807
   577
               \<lambda>i x. transitive_set(##Lset(i),f(x))]"
paulson@13655
   578
apply (simp only: transitive_set_def)
wenzelm@13429
   579
apply (intro FOL_reflections subset_reflection)
paulson@13314
   580
done
paulson@13306
   581
paulson@13306
   582
lemma sats_ordinal_fm':
paulson@13306
   583
   "[|x \<in> nat; env \<in> list(A)|]
paulson@13807
   584
    ==> sats(A, ordinal_fm(x), env) <-> ordinal(##A,nth(x,env))"
paulson@13306
   585
by (simp add: sats_transset_fm' ordinal_fm_def ordinal_def)
paulson@13306
   586
paulson@13306
   587
lemma ordinal_iff_sats:
paulson@13306
   588
      "[| nth(i,env) = x;  i \<in> nat; env \<in> list(A)|]
paulson@13807
   589
       ==> ordinal(##A, x) <-> sats(A, ordinal_fm(i), env)"
paulson@13306
   590
by (simp add: sats_ordinal_fm')
paulson@13306
   591
paulson@13314
   592
theorem ordinal_reflection:
paulson@13807
   593
     "REFLECTS[\<lambda>x. ordinal(L,f(x)), \<lambda>i x. ordinal(##Lset(i),f(x))]"
paulson@13655
   594
apply (simp only: ordinal_def)
wenzelm@13429
   595
apply (intro FOL_reflections transitive_set_reflection)
paulson@13314
   596
done
paulson@13298
   597
paulson@13298
   598
paulson@13339
   599
subsubsection{*Membership Relation, Internalized*}
paulson@13298
   600
wenzelm@21233
   601
definition Memrel_fm :: "[i,i]=>i"
wenzelm@13429
   602
    "Memrel_fm(A,r) ==
paulson@13306
   603
       Forall(Iff(Member(0,succ(r)),
paulson@13306
   604
                  Exists(And(Member(0,succ(succ(A))),
paulson@13306
   605
                             Exists(And(Member(0,succ(succ(succ(A)))),
paulson@13306
   606
                                        And(Member(1,0),
paulson@13306
   607
                                            pair_fm(1,0,2))))))))"
paulson@13306
   608
paulson@13306
   609
lemma Memrel_type [TC]:
paulson@13306
   610
     "[| x \<in> nat; y \<in> nat |] ==> Memrel_fm(x,y) \<in> formula"
wenzelm@13429
   611
by (simp add: Memrel_fm_def)
paulson@13298
   612
paulson@13306
   613
lemma sats_Memrel_fm [simp]:
paulson@13306
   614
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
wenzelm@13429
   615
    ==> sats(A, Memrel_fm(x,y), env) <->
paulson@13807
   616
        membership(##A, nth(x,env), nth(y,env))"
paulson@13306
   617
by (simp add: Memrel_fm_def membership_def)
paulson@13298
   618
paulson@13306
   619
lemma Memrel_iff_sats:
wenzelm@13429
   620
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13306
   621
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13807
   622
       ==> membership(##A, x, y) <-> sats(A, Memrel_fm(i,j), env)"
paulson@13306
   623
by simp
paulson@13304
   624
paulson@13314
   625
theorem membership_reflection:
wenzelm@13429
   626
     "REFLECTS[\<lambda>x. membership(L,f(x),g(x)),
paulson@13807
   627
               \<lambda>i x. membership(##Lset(i),f(x),g(x))]"
paulson@13655
   628
apply (simp only: membership_def)
wenzelm@13429
   629
apply (intro FOL_reflections pair_reflection)
paulson@13314
   630
done
paulson@13304
   631
paulson@13339
   632
subsubsection{*Predecessor Set, Internalized*}
paulson@13304
   633
wenzelm@21233
   634
definition pred_set_fm :: "[i,i,i,i]=>i"
wenzelm@13429
   635
    "pred_set_fm(A,x,r,B) ==
paulson@13306
   636
       Forall(Iff(Member(0,succ(B)),
paulson@13306
   637
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   638
                             And(Member(1,succ(succ(A))),
paulson@13306
   639
                                 pair_fm(1,succ(succ(x)),0))))))"
paulson@13306
   640
paulson@13306
   641
paulson@13306
   642
lemma pred_set_type [TC]:
wenzelm@13429
   643
     "[| A \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat |]
paulson@13306
   644
      ==> pred_set_fm(A,x,r,B) \<in> formula"
wenzelm@13429
   645
by (simp add: pred_set_fm_def)
paulson@13304
   646
paulson@13306
   647
lemma sats_pred_set_fm [simp]:
paulson@13306
   648
   "[| U \<in> nat; x \<in> nat; r \<in> nat; B \<in> nat; env \<in> list(A)|]
wenzelm@13429
   649
    ==> sats(A, pred_set_fm(U,x,r,B), env) <->
paulson@13807
   650
        pred_set(##A, nth(U,env), nth(x,env), nth(r,env), nth(B,env))"
paulson@13306
   651
by (simp add: pred_set_fm_def pred_set_def)
paulson@13306
   652
paulson@13306
   653
lemma pred_set_iff_sats:
wenzelm@13429
   654
      "[| nth(i,env) = U; nth(j,env) = x; nth(k,env) = r; nth(l,env) = B;
paulson@13306
   655
          i \<in> nat; j \<in> nat; k \<in> nat; l \<in> nat; env \<in> list(A)|]
paulson@13807
   656
       ==> pred_set(##A,U,x,r,B) <-> sats(A, pred_set_fm(i,j,k,l), env)"
paulson@13306
   657
by (simp add: sats_pred_set_fm)
paulson@13306
   658
paulson@13314
   659
theorem pred_set_reflection:
wenzelm@13429
   660
     "REFLECTS[\<lambda>x. pred_set(L,f(x),g(x),h(x),b(x)),
paulson@13807
   661
               \<lambda>i x. pred_set(##Lset(i),f(x),g(x),h(x),b(x))]"
paulson@13655
   662
apply (simp only: pred_set_def)
wenzelm@13429
   663
apply (intro FOL_reflections pair_reflection)
paulson@13314
   664
done
paulson@13304
   665
paulson@13304
   666
paulson@13298
   667
paulson@13339
   668
subsubsection{*Domain of a Relation, Internalized*}
paulson@13306
   669
wenzelm@13429
   670
(* "is_domain(M,r,z) ==
wenzelm@13429
   671
        \<forall>x[M]. (x \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>y[M]. pair(M,x,y,w))))" *)
wenzelm@21233
   672
definition domain_fm :: "[i,i]=>i"
wenzelm@13429
   673
    "domain_fm(r,z) ==
paulson@13306
   674
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   675
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   676
                             Exists(pair_fm(2,0,1))))))"
paulson@13306
   677
paulson@13306
   678
lemma domain_type [TC]:
paulson@13306
   679
     "[| x \<in> nat; y \<in> nat |] ==> domain_fm(x,y) \<in> formula"
wenzelm@13429
   680
by (simp add: domain_fm_def)
paulson@13306
   681
paulson@13306
   682
lemma sats_domain_fm [simp]:
paulson@13306
   683
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
wenzelm@13429
   684
    ==> sats(A, domain_fm(x,y), env) <->
paulson@13807
   685
        is_domain(##A, nth(x,env), nth(y,env))"
paulson@13306
   686
by (simp add: domain_fm_def is_domain_def)
paulson@13306
   687
paulson@13306
   688
lemma domain_iff_sats:
wenzelm@13429
   689
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13306
   690
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13807
   691
       ==> is_domain(##A, x, y) <-> sats(A, domain_fm(i,j), env)"
paulson@13306
   692
by simp
paulson@13306
   693
paulson@13314
   694
theorem domain_reflection:
wenzelm@13429
   695
     "REFLECTS[\<lambda>x. is_domain(L,f(x),g(x)),
paulson@13807
   696
               \<lambda>i x. is_domain(##Lset(i),f(x),g(x))]"
paulson@13655
   697
apply (simp only: is_domain_def)
wenzelm@13429
   698
apply (intro FOL_reflections pair_reflection)
paulson@13314
   699
done
paulson@13306
   700
paulson@13306
   701
paulson@13339
   702
subsubsection{*Range of a Relation, Internalized*}
paulson@13306
   703
wenzelm@13429
   704
(* "is_range(M,r,z) ==
wenzelm@13429
   705
        \<forall>y[M]. (y \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>x[M]. pair(M,x,y,w))))" *)
wenzelm@21233
   706
definition range_fm :: "[i,i]=>i"
wenzelm@13429
   707
    "range_fm(r,z) ==
paulson@13306
   708
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   709
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   710
                             Exists(pair_fm(0,2,1))))))"
paulson@13306
   711
paulson@13306
   712
lemma range_type [TC]:
paulson@13306
   713
     "[| x \<in> nat; y \<in> nat |] ==> range_fm(x,y) \<in> formula"
wenzelm@13429
   714
by (simp add: range_fm_def)
paulson@13306
   715
paulson@13306
   716
lemma sats_range_fm [simp]:
paulson@13306
   717
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
wenzelm@13429
   718
    ==> sats(A, range_fm(x,y), env) <->
paulson@13807
   719
        is_range(##A, nth(x,env), nth(y,env))"
paulson@13306
   720
by (simp add: range_fm_def is_range_def)
paulson@13306
   721
paulson@13306
   722
lemma range_iff_sats:
wenzelm@13429
   723
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13306
   724
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13807
   725
       ==> is_range(##A, x, y) <-> sats(A, range_fm(i,j), env)"
paulson@13306
   726
by simp
paulson@13306
   727
paulson@13314
   728
theorem range_reflection:
wenzelm@13429
   729
     "REFLECTS[\<lambda>x. is_range(L,f(x),g(x)),
paulson@13807
   730
               \<lambda>i x. is_range(##Lset(i),f(x),g(x))]"
paulson@13655
   731
apply (simp only: is_range_def)
wenzelm@13429
   732
apply (intro FOL_reflections pair_reflection)
paulson@13314
   733
done
paulson@13306
   734
wenzelm@13429
   735
paulson@13339
   736
subsubsection{*Field of a Relation, Internalized*}
paulson@13323
   737
wenzelm@13429
   738
(* "is_field(M,r,z) ==
wenzelm@13429
   739
        \<exists>dr[M]. is_domain(M,r,dr) &
paulson@13323
   740
            (\<exists>rr[M]. is_range(M,r,rr) & union(M,dr,rr,z))" *)
wenzelm@21233
   741
definition field_fm :: "[i,i]=>i"
wenzelm@13429
   742
    "field_fm(r,z) ==
wenzelm@13429
   743
       Exists(And(domain_fm(succ(r),0),
wenzelm@13429
   744
              Exists(And(range_fm(succ(succ(r)),0),
paulson@13323
   745
                         union_fm(1,0,succ(succ(z)))))))"
paulson@13323
   746
paulson@13323
   747
lemma field_type [TC]:
paulson@13323
   748
     "[| x \<in> nat; y \<in> nat |] ==> field_fm(x,y) \<in> formula"
wenzelm@13429
   749
by (simp add: field_fm_def)
paulson@13323
   750
paulson@13323
   751
lemma sats_field_fm [simp]:
paulson@13323
   752
   "[| x \<in> nat; y \<in> nat; env \<in> list(A)|]
wenzelm@13429
   753
    ==> sats(A, field_fm(x,y), env) <->
paulson@13807
   754
        is_field(##A, nth(x,env), nth(y,env))"
paulson@13323
   755
by (simp add: field_fm_def is_field_def)
paulson@13323
   756
paulson@13323
   757
lemma field_iff_sats:
wenzelm@13429
   758
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13323
   759
          i \<in> nat; j \<in> nat; env \<in> list(A)|]
paulson@13807
   760
       ==> is_field(##A, x, y) <-> sats(A, field_fm(i,j), env)"
paulson@13323
   761
by simp
paulson@13323
   762
paulson@13323
   763
theorem field_reflection:
wenzelm@13429
   764
     "REFLECTS[\<lambda>x. is_field(L,f(x),g(x)),
paulson@13807
   765
               \<lambda>i x. is_field(##Lset(i),f(x),g(x))]"
paulson@13655
   766
apply (simp only: is_field_def)
paulson@13323
   767
apply (intro FOL_reflections domain_reflection range_reflection
paulson@13323
   768
             union_reflection)
paulson@13323
   769
done
paulson@13323
   770
paulson@13323
   771
paulson@13339
   772
subsubsection{*Image under a Relation, Internalized*}
paulson@13306
   773
wenzelm@13429
   774
(* "image(M,r,A,z) ==
paulson@13306
   775
        \<forall>y[M]. (y \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>x[M]. x\<in>A & pair(M,x,y,w))))" *)
wenzelm@21233
   776
definition image_fm :: "[i,i,i]=>i"
wenzelm@13429
   777
    "image_fm(r,A,z) ==
paulson@13306
   778
       Forall(Iff(Member(0,succ(z)),
paulson@13306
   779
                  Exists(And(Member(0,succ(succ(r))),
paulson@13306
   780
                             Exists(And(Member(0,succ(succ(succ(A)))),
wenzelm@13429
   781
                                        pair_fm(0,2,1)))))))"
paulson@13306
   782
paulson@13306
   783
lemma image_type [TC]:
paulson@13306
   784
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> image_fm(x,y,z) \<in> formula"
wenzelm@13429
   785
by (simp add: image_fm_def)
paulson@13306
   786
paulson@13306
   787
lemma sats_image_fm [simp]:
paulson@13306
   788
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
   789
    ==> sats(A, image_fm(x,y,z), env) <->
paulson@13807
   790
        image(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13323
   791
by (simp add: image_fm_def Relative.image_def)
paulson@13306
   792
paulson@13306
   793
lemma image_iff_sats:
wenzelm@13429
   794
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13306
   795
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
   796
       ==> image(##A, x, y, z) <-> sats(A, image_fm(i,j,k), env)"
paulson@13306
   797
by (simp add: sats_image_fm)
paulson@13306
   798
paulson@13314
   799
theorem image_reflection:
wenzelm@13429
   800
     "REFLECTS[\<lambda>x. image(L,f(x),g(x),h(x)),
paulson@13807
   801
               \<lambda>i x. image(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
   802
apply (simp only: Relative.image_def)
wenzelm@13429
   803
apply (intro FOL_reflections pair_reflection)
paulson@13314
   804
done
paulson@13306
   805
paulson@13306
   806
paulson@13348
   807
subsubsection{*Pre-Image under a Relation, Internalized*}
paulson@13348
   808
wenzelm@13429
   809
(* "pre_image(M,r,A,z) ==
wenzelm@13429
   810
        \<forall>x[M]. x \<in> z <-> (\<exists>w[M]. w\<in>r & (\<exists>y[M]. y\<in>A & pair(M,x,y,w)))" *)
wenzelm@21233
   811
definition pre_image_fm :: "[i,i,i]=>i"
wenzelm@13429
   812
    "pre_image_fm(r,A,z) ==
paulson@13348
   813
       Forall(Iff(Member(0,succ(z)),
paulson@13348
   814
                  Exists(And(Member(0,succ(succ(r))),
paulson@13348
   815
                             Exists(And(Member(0,succ(succ(succ(A)))),
wenzelm@13429
   816
                                        pair_fm(2,0,1)))))))"
paulson@13348
   817
paulson@13348
   818
lemma pre_image_type [TC]:
paulson@13348
   819
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> pre_image_fm(x,y,z) \<in> formula"
wenzelm@13429
   820
by (simp add: pre_image_fm_def)
paulson@13348
   821
paulson@13348
   822
lemma sats_pre_image_fm [simp]:
paulson@13348
   823
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
   824
    ==> sats(A, pre_image_fm(x,y,z), env) <->
paulson@13807
   825
        pre_image(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13348
   826
by (simp add: pre_image_fm_def Relative.pre_image_def)
paulson@13348
   827
paulson@13348
   828
lemma pre_image_iff_sats:
wenzelm@13429
   829
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13348
   830
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
   831
       ==> pre_image(##A, x, y, z) <-> sats(A, pre_image_fm(i,j,k), env)"
paulson@13348
   832
by (simp add: sats_pre_image_fm)
paulson@13348
   833
paulson@13348
   834
theorem pre_image_reflection:
wenzelm@13429
   835
     "REFLECTS[\<lambda>x. pre_image(L,f(x),g(x),h(x)),
paulson@13807
   836
               \<lambda>i x. pre_image(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
   837
apply (simp only: Relative.pre_image_def)
wenzelm@13429
   838
apply (intro FOL_reflections pair_reflection)
paulson@13348
   839
done
paulson@13348
   840
paulson@13348
   841
paulson@13352
   842
subsubsection{*Function Application, Internalized*}
paulson@13352
   843
wenzelm@13429
   844
(* "fun_apply(M,f,x,y) ==
wenzelm@13429
   845
        (\<exists>xs[M]. \<exists>fxs[M].
paulson@13352
   846
         upair(M,x,x,xs) & image(M,f,xs,fxs) & big_union(M,fxs,y))" *)
wenzelm@21233
   847
definition fun_apply_fm :: "[i,i,i]=>i"
wenzelm@13429
   848
    "fun_apply_fm(f,x,y) ==
paulson@13352
   849
       Exists(Exists(And(upair_fm(succ(succ(x)), succ(succ(x)), 1),
wenzelm@13429
   850
                         And(image_fm(succ(succ(f)), 1, 0),
paulson@13352
   851
                             big_union_fm(0,succ(succ(y)))))))"
paulson@13352
   852
paulson@13352
   853
lemma fun_apply_type [TC]:
paulson@13352
   854
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> fun_apply_fm(x,y,z) \<in> formula"
wenzelm@13429
   855
by (simp add: fun_apply_fm_def)
paulson@13352
   856
paulson@13352
   857
lemma sats_fun_apply_fm [simp]:
paulson@13352
   858
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
   859
    ==> sats(A, fun_apply_fm(x,y,z), env) <->
paulson@13807
   860
        fun_apply(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13352
   861
by (simp add: fun_apply_fm_def fun_apply_def)
paulson@13352
   862
paulson@13352
   863
lemma fun_apply_iff_sats:
wenzelm@13429
   864
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13352
   865
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
   866
       ==> fun_apply(##A, x, y, z) <-> sats(A, fun_apply_fm(i,j,k), env)"
paulson@13352
   867
by simp
paulson@13352
   868
paulson@13352
   869
theorem fun_apply_reflection:
wenzelm@13429
   870
     "REFLECTS[\<lambda>x. fun_apply(L,f(x),g(x),h(x)),
paulson@13807
   871
               \<lambda>i x. fun_apply(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
   872
apply (simp only: fun_apply_def)
paulson@13352
   873
apply (intro FOL_reflections upair_reflection image_reflection
wenzelm@13429
   874
             big_union_reflection)
paulson@13352
   875
done
paulson@13352
   876
paulson@13352
   877
paulson@13339
   878
subsubsection{*The Concept of Relation, Internalized*}
paulson@13306
   879
wenzelm@13429
   880
(* "is_relation(M,r) ==
paulson@13306
   881
        (\<forall>z[M]. z\<in>r --> (\<exists>x[M]. \<exists>y[M]. pair(M,x,y,z)))" *)
wenzelm@21233
   882
definition relation_fm :: "i=>i"
wenzelm@13429
   883
    "relation_fm(r) ==
paulson@13306
   884
       Forall(Implies(Member(0,succ(r)), Exists(Exists(pair_fm(1,0,2)))))"
paulson@13306
   885
paulson@13306
   886
lemma relation_type [TC]:
paulson@13306
   887
     "[| x \<in> nat |] ==> relation_fm(x) \<in> formula"
wenzelm@13429
   888
by (simp add: relation_fm_def)
paulson@13306
   889
paulson@13306
   890
lemma sats_relation_fm [simp]:
paulson@13306
   891
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13807
   892
    ==> sats(A, relation_fm(x), env) <-> is_relation(##A, nth(x,env))"
paulson@13306
   893
by (simp add: relation_fm_def is_relation_def)
paulson@13306
   894
paulson@13306
   895
lemma relation_iff_sats:
wenzelm@13429
   896
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13306
   897
          i \<in> nat; env \<in> list(A)|]
paulson@13807
   898
       ==> is_relation(##A, x) <-> sats(A, relation_fm(i), env)"
paulson@13306
   899
by simp
paulson@13306
   900
paulson@13314
   901
theorem is_relation_reflection:
wenzelm@13429
   902
     "REFLECTS[\<lambda>x. is_relation(L,f(x)),
paulson@13807
   903
               \<lambda>i x. is_relation(##Lset(i),f(x))]"
paulson@13655
   904
apply (simp only: is_relation_def)
wenzelm@13429
   905
apply (intro FOL_reflections pair_reflection)
paulson@13314
   906
done
paulson@13306
   907
paulson@13306
   908
paulson@13339
   909
subsubsection{*The Concept of Function, Internalized*}
paulson@13306
   910
wenzelm@13429
   911
(* "is_function(M,r) ==
wenzelm@13429
   912
        \<forall>x[M]. \<forall>y[M]. \<forall>y'[M]. \<forall>p[M]. \<forall>p'[M].
paulson@13306
   913
           pair(M,x,y,p) --> pair(M,x,y',p') --> p\<in>r --> p'\<in>r --> y=y'" *)
wenzelm@21233
   914
definition function_fm :: "i=>i"
wenzelm@13429
   915
    "function_fm(r) ==
paulson@13306
   916
       Forall(Forall(Forall(Forall(Forall(
paulson@13306
   917
         Implies(pair_fm(4,3,1),
paulson@13306
   918
                 Implies(pair_fm(4,2,0),
paulson@13306
   919
                         Implies(Member(1,r#+5),
paulson@13306
   920
                                 Implies(Member(0,r#+5), Equal(3,2))))))))))"
paulson@13306
   921
paulson@13306
   922
lemma function_type [TC]:
paulson@13306
   923
     "[| x \<in> nat |] ==> function_fm(x) \<in> formula"
wenzelm@13429
   924
by (simp add: function_fm_def)
paulson@13306
   925
paulson@13306
   926
lemma sats_function_fm [simp]:
paulson@13306
   927
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13807
   928
    ==> sats(A, function_fm(x), env) <-> is_function(##A, nth(x,env))"
paulson@13306
   929
by (simp add: function_fm_def is_function_def)
paulson@13306
   930
paulson@13505
   931
lemma is_function_iff_sats:
wenzelm@13429
   932
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13306
   933
          i \<in> nat; env \<in> list(A)|]
paulson@13807
   934
       ==> is_function(##A, x) <-> sats(A, function_fm(i), env)"
paulson@13306
   935
by simp
paulson@13306
   936
paulson@13314
   937
theorem is_function_reflection:
wenzelm@13429
   938
     "REFLECTS[\<lambda>x. is_function(L,f(x)),
paulson@13807
   939
               \<lambda>i x. is_function(##Lset(i),f(x))]"
paulson@13655
   940
apply (simp only: is_function_def)
wenzelm@13429
   941
apply (intro FOL_reflections pair_reflection)
paulson@13314
   942
done
paulson@13298
   943
paulson@13298
   944
paulson@13339
   945
subsubsection{*Typed Functions, Internalized*}
paulson@13309
   946
wenzelm@13429
   947
(* "typed_function(M,A,B,r) ==
paulson@13309
   948
        is_function(M,r) & is_relation(M,r) & is_domain(M,r,A) &
paulson@13309
   949
        (\<forall>u[M]. u\<in>r --> (\<forall>x[M]. \<forall>y[M]. pair(M,x,y,u) --> y\<in>B))" *)
paulson@13309
   950
wenzelm@21233
   951
definition typed_function_fm :: "[i,i,i]=>i"
wenzelm@13429
   952
    "typed_function_fm(A,B,r) ==
paulson@13309
   953
       And(function_fm(r),
paulson@13309
   954
         And(relation_fm(r),
paulson@13309
   955
           And(domain_fm(r,A),
paulson@13309
   956
             Forall(Implies(Member(0,succ(r)),
paulson@13309
   957
                  Forall(Forall(Implies(pair_fm(1,0,2),Member(0,B#+3)))))))))"
paulson@13309
   958
paulson@13309
   959
lemma typed_function_type [TC]:
paulson@13309
   960
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> typed_function_fm(x,y,z) \<in> formula"
wenzelm@13429
   961
by (simp add: typed_function_fm_def)
paulson@13309
   962
paulson@13309
   963
lemma sats_typed_function_fm [simp]:
paulson@13309
   964
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
   965
    ==> sats(A, typed_function_fm(x,y,z), env) <->
paulson@13807
   966
        typed_function(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13309
   967
by (simp add: typed_function_fm_def typed_function_def)
paulson@13309
   968
paulson@13309
   969
lemma typed_function_iff_sats:
wenzelm@13429
   970
  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13309
   971
      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
   972
   ==> typed_function(##A, x, y, z) <-> sats(A, typed_function_fm(i,j,k), env)"
paulson@13309
   973
by simp
paulson@13309
   974
wenzelm@13429
   975
lemmas function_reflections =
paulson@13363
   976
        empty_reflection number1_reflection
wenzelm@13429
   977
        upair_reflection pair_reflection union_reflection
wenzelm@13429
   978
        big_union_reflection cons_reflection successor_reflection
paulson@13323
   979
        fun_apply_reflection subset_reflection
wenzelm@13429
   980
        transitive_set_reflection membership_reflection
wenzelm@13429
   981
        pred_set_reflection domain_reflection range_reflection field_reflection
paulson@13348
   982
        image_reflection pre_image_reflection
wenzelm@13429
   983
        is_relation_reflection is_function_reflection
paulson@13309
   984
wenzelm@13429
   985
lemmas function_iff_sats =
wenzelm@13429
   986
        empty_iff_sats number1_iff_sats
wenzelm@13429
   987
        upair_iff_sats pair_iff_sats union_iff_sats
paulson@13505
   988
        big_union_iff_sats cons_iff_sats successor_iff_sats
paulson@13323
   989
        fun_apply_iff_sats  Memrel_iff_sats
wenzelm@13429
   990
        pred_set_iff_sats domain_iff_sats range_iff_sats field_iff_sats
wenzelm@13429
   991
        image_iff_sats pre_image_iff_sats
paulson@13505
   992
        relation_iff_sats is_function_iff_sats
paulson@13323
   993
paulson@13309
   994
paulson@13314
   995
theorem typed_function_reflection:
wenzelm@13429
   996
     "REFLECTS[\<lambda>x. typed_function(L,f(x),g(x),h(x)),
paulson@13807
   997
               \<lambda>i x. typed_function(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
   998
apply (simp only: typed_function_def)
wenzelm@13429
   999
apply (intro FOL_reflections function_reflections)
paulson@13323
  1000
done
paulson@13323
  1001
paulson@13323
  1002
paulson@13339
  1003
subsubsection{*Composition of Relations, Internalized*}
paulson@13323
  1004
wenzelm@13429
  1005
(* "composition(M,r,s,t) ==
wenzelm@13429
  1006
        \<forall>p[M]. p \<in> t <->
wenzelm@13429
  1007
               (\<exists>x[M]. \<exists>y[M]. \<exists>z[M]. \<exists>xy[M]. \<exists>yz[M].
wenzelm@13429
  1008
                pair(M,x,z,p) & pair(M,x,y,xy) & pair(M,y,z,yz) &
paulson@13323
  1009
                xy \<in> s & yz \<in> r)" *)
wenzelm@21233
  1010
definition composition_fm :: "[i,i,i]=>i"
wenzelm@13429
  1011
  "composition_fm(r,s,t) ==
paulson@13323
  1012
     Forall(Iff(Member(0,succ(t)),
wenzelm@13429
  1013
             Exists(Exists(Exists(Exists(Exists(
paulson@13323
  1014
              And(pair_fm(4,2,5),
paulson@13323
  1015
               And(pair_fm(4,3,1),
paulson@13323
  1016
                And(pair_fm(3,2,0),
paulson@13323
  1017
                 And(Member(1,s#+6), Member(0,r#+6))))))))))))"
paulson@13323
  1018
paulson@13323
  1019
lemma composition_type [TC]:
paulson@13323
  1020
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> composition_fm(x,y,z) \<in> formula"
wenzelm@13429
  1021
by (simp add: composition_fm_def)
paulson@13323
  1022
paulson@13323
  1023
lemma sats_composition_fm [simp]:
paulson@13323
  1024
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
  1025
    ==> sats(A, composition_fm(x,y,z), env) <->
paulson@13807
  1026
        composition(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13323
  1027
by (simp add: composition_fm_def composition_def)
paulson@13323
  1028
paulson@13323
  1029
lemma composition_iff_sats:
wenzelm@13429
  1030
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13323
  1031
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
  1032
       ==> composition(##A, x, y, z) <-> sats(A, composition_fm(i,j,k), env)"
paulson@13323
  1033
by simp
paulson@13323
  1034
paulson@13323
  1035
theorem composition_reflection:
wenzelm@13429
  1036
     "REFLECTS[\<lambda>x. composition(L,f(x),g(x),h(x)),
paulson@13807
  1037
               \<lambda>i x. composition(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
  1038
apply (simp only: composition_def)
wenzelm@13429
  1039
apply (intro FOL_reflections pair_reflection)
paulson@13314
  1040
done
paulson@13314
  1041
paulson@13309
  1042
paulson@13339
  1043
subsubsection{*Injections, Internalized*}
paulson@13309
  1044
wenzelm@13429
  1045
(* "injection(M,A,B,f) ==
wenzelm@13429
  1046
        typed_function(M,A,B,f) &
wenzelm@13429
  1047
        (\<forall>x[M]. \<forall>x'[M]. \<forall>y[M]. \<forall>p[M]. \<forall>p'[M].
paulson@13309
  1048
          pair(M,x,y,p) --> pair(M,x',y,p') --> p\<in>f --> p'\<in>f --> x=x')" *)
wenzelm@21233
  1049
definition injection_fm :: "[i,i,i]=>i"
wenzelm@13429
  1050
 "injection_fm(A,B,f) ==
paulson@13309
  1051
    And(typed_function_fm(A,B,f),
paulson@13309
  1052
       Forall(Forall(Forall(Forall(Forall(
paulson@13309
  1053
         Implies(pair_fm(4,2,1),
paulson@13309
  1054
                 Implies(pair_fm(3,2,0),
paulson@13309
  1055
                         Implies(Member(1,f#+5),
paulson@13309
  1056
                                 Implies(Member(0,f#+5), Equal(4,3)))))))))))"
paulson@13309
  1057
paulson@13309
  1058
paulson@13309
  1059
lemma injection_type [TC]:
paulson@13309
  1060
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> injection_fm(x,y,z) \<in> formula"
wenzelm@13429
  1061
by (simp add: injection_fm_def)
paulson@13309
  1062
paulson@13309
  1063
lemma sats_injection_fm [simp]:
paulson@13309
  1064
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
  1065
    ==> sats(A, injection_fm(x,y,z), env) <->
paulson@13807
  1066
        injection(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13309
  1067
by (simp add: injection_fm_def injection_def)
paulson@13309
  1068
paulson@13309
  1069
lemma injection_iff_sats:
wenzelm@13429
  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@13807
  1072
   ==> injection(##A, x, y, z) <-> sats(A, injection_fm(i,j,k), env)"
paulson@13309
  1073
by simp
paulson@13309
  1074
paulson@13314
  1075
theorem injection_reflection:
wenzelm@13429
  1076
     "REFLECTS[\<lambda>x. injection(L,f(x),g(x),h(x)),
paulson@13807
  1077
               \<lambda>i x. injection(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
  1078
apply (simp only: injection_def)
wenzelm@13429
  1079
apply (intro FOL_reflections function_reflections typed_function_reflection)
paulson@13314
  1080
done
paulson@13309
  1081
paulson@13309
  1082
paulson@13339
  1083
subsubsection{*Surjections, Internalized*}
paulson@13309
  1084
paulson@13309
  1085
(*  surjection :: "[i=>o,i,i,i] => o"
wenzelm@13429
  1086
    "surjection(M,A,B,f) ==
paulson@13309
  1087
        typed_function(M,A,B,f) &
paulson@13309
  1088
        (\<forall>y[M]. y\<in>B --> (\<exists>x[M]. x\<in>A & fun_apply(M,f,x,y)))" *)
wenzelm@21233
  1089
definition surjection_fm :: "[i,i,i]=>i"
wenzelm@13429
  1090
 "surjection_fm(A,B,f) ==
paulson@13309
  1091
    And(typed_function_fm(A,B,f),
paulson@13309
  1092
       Forall(Implies(Member(0,succ(B)),
paulson@13309
  1093
                      Exists(And(Member(0,succ(succ(A))),
paulson@13309
  1094
                                 fun_apply_fm(succ(succ(f)),0,1))))))"
paulson@13309
  1095
paulson@13309
  1096
lemma surjection_type [TC]:
paulson@13309
  1097
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> surjection_fm(x,y,z) \<in> formula"
wenzelm@13429
  1098
by (simp add: surjection_fm_def)
paulson@13309
  1099
paulson@13309
  1100
lemma sats_surjection_fm [simp]:
paulson@13309
  1101
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
  1102
    ==> sats(A, surjection_fm(x,y,z), env) <->
paulson@13807
  1103
        surjection(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13309
  1104
by (simp add: surjection_fm_def surjection_def)
paulson@13309
  1105
paulson@13309
  1106
lemma surjection_iff_sats:
wenzelm@13429
  1107
  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13309
  1108
      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
  1109
   ==> surjection(##A, x, y, z) <-> sats(A, surjection_fm(i,j,k), env)"
paulson@13309
  1110
by simp
paulson@13309
  1111
paulson@13314
  1112
theorem surjection_reflection:
wenzelm@13429
  1113
     "REFLECTS[\<lambda>x. surjection(L,f(x),g(x),h(x)),
paulson@13807
  1114
               \<lambda>i x. surjection(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
  1115
apply (simp only: surjection_def)
wenzelm@13429
  1116
apply (intro FOL_reflections function_reflections typed_function_reflection)
paulson@13314
  1117
done
paulson@13309
  1118
paulson@13309
  1119
paulson@13309
  1120
paulson@13339
  1121
subsubsection{*Bijections, Internalized*}
paulson@13309
  1122
paulson@13309
  1123
(*   bijection :: "[i=>o,i,i,i] => o"
paulson@13309
  1124
    "bijection(M,A,B,f) == injection(M,A,B,f) & surjection(M,A,B,f)" *)
wenzelm@21233
  1125
definition bijection_fm :: "[i,i,i]=>i"
paulson@13309
  1126
 "bijection_fm(A,B,f) == And(injection_fm(A,B,f), surjection_fm(A,B,f))"
paulson@13309
  1127
paulson@13309
  1128
lemma bijection_type [TC]:
paulson@13309
  1129
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> bijection_fm(x,y,z) \<in> formula"
wenzelm@13429
  1130
by (simp add: bijection_fm_def)
paulson@13309
  1131
paulson@13309
  1132
lemma sats_bijection_fm [simp]:
paulson@13309
  1133
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
  1134
    ==> sats(A, bijection_fm(x,y,z), env) <->
paulson@13807
  1135
        bijection(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13309
  1136
by (simp add: bijection_fm_def bijection_def)
paulson@13309
  1137
paulson@13309
  1138
lemma bijection_iff_sats:
wenzelm@13429
  1139
  "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13309
  1140
      i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
  1141
   ==> bijection(##A, x, y, z) <-> sats(A, bijection_fm(i,j,k), env)"
paulson@13309
  1142
by simp
paulson@13309
  1143
paulson@13314
  1144
theorem bijection_reflection:
wenzelm@13429
  1145
     "REFLECTS[\<lambda>x. bijection(L,f(x),g(x),h(x)),
paulson@13807
  1146
               \<lambda>i x. bijection(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
  1147
apply (simp only: bijection_def)
wenzelm@13429
  1148
apply (intro And_reflection injection_reflection surjection_reflection)
paulson@13314
  1149
done
paulson@13309
  1150
paulson@13309
  1151
paulson@13348
  1152
subsubsection{*Restriction of a Relation, Internalized*}
paulson@13348
  1153
paulson@13348
  1154
wenzelm@13429
  1155
(* "restriction(M,r,A,z) ==
wenzelm@13429
  1156
        \<forall>x[M]. x \<in> z <-> (x \<in> r & (\<exists>u[M]. u\<in>A & (\<exists>v[M]. pair(M,u,v,x))))" *)
wenzelm@21233
  1157
definition restriction_fm :: "[i,i,i]=>i"
wenzelm@13429
  1158
    "restriction_fm(r,A,z) ==
paulson@13348
  1159
       Forall(Iff(Member(0,succ(z)),
paulson@13348
  1160
                  And(Member(0,succ(r)),
paulson@13348
  1161
                      Exists(And(Member(0,succ(succ(A))),
paulson@13348
  1162
                                 Exists(pair_fm(1,0,2)))))))"
paulson@13348
  1163
paulson@13348
  1164
lemma restriction_type [TC]:
paulson@13348
  1165
     "[| x \<in> nat; y \<in> nat; z \<in> nat |] ==> restriction_fm(x,y,z) \<in> formula"
wenzelm@13429
  1166
by (simp add: restriction_fm_def)
paulson@13348
  1167
paulson@13348
  1168
lemma sats_restriction_fm [simp]:
paulson@13348
  1169
   "[| x \<in> nat; y \<in> nat; z \<in> nat; env \<in> list(A)|]
wenzelm@13429
  1170
    ==> sats(A, restriction_fm(x,y,z), env) <->
paulson@13807
  1171
        restriction(##A, nth(x,env), nth(y,env), nth(z,env))"
paulson@13348
  1172
by (simp add: restriction_fm_def restriction_def)
paulson@13348
  1173
paulson@13348
  1174
lemma restriction_iff_sats:
wenzelm@13429
  1175
      "[| nth(i,env) = x; nth(j,env) = y; nth(k,env) = z;
paulson@13348
  1176
          i \<in> nat; j \<in> nat; k \<in> nat; env \<in> list(A)|]
paulson@13807
  1177
       ==> restriction(##A, x, y, z) <-> sats(A, restriction_fm(i,j,k), env)"
paulson@13348
  1178
by simp
paulson@13348
  1179
paulson@13348
  1180
theorem restriction_reflection:
wenzelm@13429
  1181
     "REFLECTS[\<lambda>x. restriction(L,f(x),g(x),h(x)),
paulson@13807
  1182
               \<lambda>i x. restriction(##Lset(i),f(x),g(x),h(x))]"
paulson@13655
  1183
apply (simp only: restriction_def)
wenzelm@13429
  1184
apply (intro FOL_reflections pair_reflection)
paulson@13348
  1185
done
paulson@13348
  1186
paulson@13339
  1187
subsubsection{*Order-Isomorphisms, Internalized*}
paulson@13309
  1188
paulson@13309
  1189
(*  order_isomorphism :: "[i=>o,i,i,i,i,i] => o"
wenzelm@13429
  1190
   "order_isomorphism(M,A,r,B,s,f) ==
wenzelm@13429
  1191
        bijection(M,A,B,f) &
paulson@13309
  1192
        (\<forall>x[M]. x\<in>A --> (\<forall>y[M]. y\<in>A -->
paulson@13309
  1193
          (\<forall>p[M]. \<forall>fx[M]. \<forall>fy[M]. \<forall>q[M].
wenzelm@13429
  1194
            pair(M,x,y,p) --> fun_apply(M,f,x,fx) --> fun_apply(M,f,y,fy) -->
paulson@13309
  1195
            pair(M,fx,fy,q) --> (p\<in>r <-> q\<in>s))))"
paulson@13309
  1196
  *)
paulson@13309
  1197
wenzelm@21233
  1198
definition order_isomorphism_fm :: "[i,i,i,i,i]=>i"
wenzelm@13429
  1199
 "order_isomorphism_fm(A,r,B,s,f) ==
wenzelm@13429
  1200
   And(bijection_fm(A,B,f),
paulson@13309
  1201
     Forall(Implies(Member(0,succ(A)),
paulson@13309
  1202
       Forall(Implies(Member(0,succ(succ(A))),
paulson@13309
  1203
         Forall(Forall(Forall(Forall(
paulson@13309
  1204
           Implies(pair_fm(5,4,3),
paulson@13309
  1205
             Implies(fun_apply_fm(f#+6,5,2),
paulson@13309
  1206
               Implies(fun_apply_fm(f#+6,4,1),
wenzelm@13429
  1207
                 Implies(pair_fm(2,1,0),
paulson@13309
  1208
                   Iff(Member(3,r#+6), Member(0,s#+6)))))))))))))))"
paulson@13309
  1209
paulson@13309
  1210
lemma order_isomorphism_type [TC]:
wenzelm@13429
  1211
     "[| A \<in> nat; r \<in> nat; B \<in> nat; s \<in> nat; f \<in> nat |]
paulson@13309
  1212
      ==> order_isomorphism_fm(A,r,B,s,f) \<in> formula"
wenzelm@13429
  1213
by (simp add: order_isomorphism_fm_def)
paulson@13309
  1214
paulson@13309
  1215
lemma sats_order_isomorphism_fm [simp]:
paulson@13309
  1216
   "[| U \<in> nat; r \<in> nat; B \<in> nat; s \<in> nat; f \<in> nat; env \<in> list(A)|]
wenzelm@13429
  1217
    ==> sats(A, order_isomorphism_fm(U,r,B,s,f), env) <->
paulson@13807
  1218
        order_isomorphism(##A, nth(U,env), nth(r,env), nth(B,env),
paulson@13309
  1219
                               nth(s,env), nth(f,env))"
paulson@13309
  1220
by (simp add: order_isomorphism_fm_def order_isomorphism_def)
paulson@13309
  1221
paulson@13309
  1222
lemma order_isomorphism_iff_sats:
wenzelm@13429
  1223
  "[| nth(i,env) = U; nth(j,env) = r; nth(k,env) = B; nth(j',env) = s;
wenzelm@13429
  1224
      nth(k',env) = f;
paulson@13309
  1225
      i \<in> nat; j \<in> nat; k \<in> nat; j' \<in> nat; k' \<in> nat; env \<in> list(A)|]
paulson@13807
  1226
   ==> order_isomorphism(##A,U,r,B,s,f) <->
wenzelm@13429
  1227
       sats(A, order_isomorphism_fm(i,j,k,j',k'), env)"
paulson@13309
  1228
by simp
paulson@13309
  1229
paulson@13314
  1230
theorem order_isomorphism_reflection:
wenzelm@13429
  1231
     "REFLECTS[\<lambda>x. order_isomorphism(L,f(x),g(x),h(x),g'(x),h'(x)),
paulson@13807
  1232
               \<lambda>i x. order_isomorphism(##Lset(i),f(x),g(x),h(x),g'(x),h'(x))]"
paulson@13655
  1233
apply (simp only: order_isomorphism_def)
wenzelm@13429
  1234
apply (intro FOL_reflections function_reflections bijection_reflection)
paulson@13323
  1235
done
paulson@13323
  1236
paulson@13339
  1237
subsubsection{*Limit Ordinals, Internalized*}
paulson@13323
  1238
paulson@13323
  1239
text{*A limit ordinal is a non-empty, successor-closed ordinal*}
paulson@13323
  1240
wenzelm@13429
  1241
(* "limit_ordinal(M,a) ==
wenzelm@13429
  1242
        ordinal(M,a) & ~ empty(M,a) &
paulson@13323
  1243
        (\<forall>x[M]. x\<in>a --> (\<exists>y[M]. y\<in>a & successor(M,x,y)))" *)
paulson@13323
  1244
wenzelm@21233
  1245
definition limit_ordinal_fm :: "i=>i"
wenzelm@13429
  1246
    "limit_ordinal_fm(x) ==
paulson@13323
  1247
        And(ordinal_fm(x),
paulson@13323
  1248
            And(Neg(empty_fm(x)),
wenzelm@13429
  1249
                Forall(Implies(Member(0,succ(x)),
paulson@13323
  1250
                               Exists(And(Member(0,succ(succ(x))),
paulson@13323
  1251
                                          succ_fm(1,0)))))))"
paulson@13323
  1252
paulson@13323
  1253
lemma limit_ordinal_type [TC]:
paulson@13323
  1254
     "x \<in> nat ==> limit_ordinal_fm(x) \<in> formula"
wenzelm@13429
  1255
by (simp add: limit_ordinal_fm_def)
paulson@13323
  1256
paulson@13323
  1257
lemma sats_limit_ordinal_fm [simp]:
paulson@13323
  1258
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13807
  1259
    ==> sats(A, limit_ordinal_fm(x), env) <-> limit_ordinal(##A, nth(x,env))"
paulson@13323
  1260
by (simp add: limit_ordinal_fm_def limit_ordinal_def sats_ordinal_fm')
paulson@13323
  1261
paulson@13323
  1262
lemma limit_ordinal_iff_sats:
wenzelm@13429
  1263
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13323
  1264
          i \<in> nat; env \<in> list(A)|]
paulson@13807
  1265
       ==> limit_ordinal(##A, x) <-> sats(A, limit_ordinal_fm(i), env)"
paulson@13323
  1266
by simp
paulson@13323
  1267
paulson@13323
  1268
theorem limit_ordinal_reflection:
wenzelm@13429
  1269
     "REFLECTS[\<lambda>x. limit_ordinal(L,f(x)),
paulson@13807
  1270
               \<lambda>i x. limit_ordinal(##Lset(i),f(x))]"
paulson@13655
  1271
apply (simp only: limit_ordinal_def)
wenzelm@13429
  1272
apply (intro FOL_reflections ordinal_reflection
wenzelm@13429
  1273
             empty_reflection successor_reflection)
paulson@13314
  1274
done
paulson@13309
  1275
paulson@13493
  1276
subsubsection{*Finite Ordinals: The Predicate ``Is A Natural Number''*}
paulson@13493
  1277
paulson@13493
  1278
(*     "finite_ordinal(M,a) == 
paulson@13493
  1279
	ordinal(M,a) & ~ limit_ordinal(M,a) & 
paulson@13493
  1280
        (\<forall>x[M]. x\<in>a --> ~ limit_ordinal(M,x))" *)
wenzelm@21233
  1281
definition finite_ordinal_fm :: "i=>i"
paulson@13493
  1282
    "finite_ordinal_fm(x) ==
paulson@13493
  1283
       And(ordinal_fm(x),
paulson@13493
  1284
          And(Neg(limit_ordinal_fm(x)),
paulson@13493
  1285
           Forall(Implies(Member(0,succ(x)),
paulson@13493
  1286
                          Neg(limit_ordinal_fm(0))))))"
paulson@13493
  1287
paulson@13493
  1288
lemma finite_ordinal_type [TC]:
paulson@13493
  1289
     "x \<in> nat ==> finite_ordinal_fm(x) \<in> formula"
paulson@13493
  1290
by (simp add: finite_ordinal_fm_def)
paulson@13493
  1291
paulson@13493
  1292
lemma sats_finite_ordinal_fm [simp]:
paulson@13493
  1293
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13807
  1294
    ==> sats(A, finite_ordinal_fm(x), env) <-> finite_ordinal(##A, nth(x,env))"
paulson@13493
  1295
by (simp add: finite_ordinal_fm_def sats_ordinal_fm' finite_ordinal_def)
paulson@13493
  1296
paulson@13493
  1297
lemma finite_ordinal_iff_sats:
paulson@13493
  1298
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13493
  1299
          i \<in> nat; env \<in> list(A)|]
paulson@13807
  1300
       ==> finite_ordinal(##A, x) <-> sats(A, finite_ordinal_fm(i), env)"
paulson@13493
  1301
by simp
paulson@13493
  1302
paulson@13493
  1303
theorem finite_ordinal_reflection:
paulson@13493
  1304
     "REFLECTS[\<lambda>x. finite_ordinal(L,f(x)),
paulson@13807
  1305
               \<lambda>i x. finite_ordinal(##Lset(i),f(x))]"
paulson@13655
  1306
apply (simp only: finite_ordinal_def)
paulson@13493
  1307
apply (intro FOL_reflections ordinal_reflection limit_ordinal_reflection)
paulson@13493
  1308
done
paulson@13493
  1309
paulson@13493
  1310
paulson@13323
  1311
subsubsection{*Omega: The Set of Natural Numbers*}
paulson@13323
  1312
paulson@13323
  1313
(* omega(M,a) == limit_ordinal(M,a) & (\<forall>x[M]. x\<in>a --> ~ limit_ordinal(M,x)) *)
wenzelm@21233
  1314
definition omega_fm :: "i=>i"
wenzelm@13429
  1315
    "omega_fm(x) ==
paulson@13323
  1316
       And(limit_ordinal_fm(x),
paulson@13323
  1317
           Forall(Implies(Member(0,succ(x)),
paulson@13323
  1318
                          Neg(limit_ordinal_fm(0)))))"
paulson@13323
  1319
paulson@13323
  1320
lemma omega_type [TC]:
paulson@13323
  1321
     "x \<in> nat ==> omega_fm(x) \<in> formula"
wenzelm@13429
  1322
by (simp add: omega_fm_def)
paulson@13323
  1323
paulson@13323
  1324
lemma sats_omega_fm [simp]:
paulson@13323
  1325
   "[| x \<in> nat; env \<in> list(A)|]
paulson@13807
  1326
    ==> sats(A, omega_fm(x), env) <-> omega(##A, nth(x,env))"
paulson@13323
  1327
by (simp add: omega_fm_def omega_def)
paulson@13316
  1328
paulson@13323
  1329
lemma omega_iff_sats:
wenzelm@13429
  1330
      "[| nth(i,env) = x; nth(j,env) = y;
paulson@13323
  1331
          i \<in> nat; env \<in> list(A)|]
paulson@13807
  1332
       ==> omega(##A, x) <-> sats(A, omega_fm(i), env)"
paulson@13323
  1333
by simp
paulson@13323
  1334
paulson@13323
  1335
theorem omega_reflection:
wenzelm@13429
  1336
     "REFLECTS[\<lambda>x. omega(L,f(x)),
paulson@13807
  1337
               \<lambda>i x. omega(##Lset(i),f(x))]"
paulson@13655
  1338
apply (simp only: omega_def)
wenzelm@13429
  1339
apply (intro FOL_reflections limit_ordinal_reflection)
paulson@13323
  1340
done
paulson@13323
  1341
paulson@13323
  1342
paulson@13323
  1343
lemmas fun_plus_reflections =
paulson@13323
  1344
        typed_function_reflection composition_reflection
paulson@13323
  1345
        injection_reflection surjection_reflection
paulson@13348
  1346
        bijection_reflection restriction_reflection
paulson@13496
  1347
        order_isomorphism_reflection finite_ordinal_reflection 
paulson@13323
  1348
        ordinal_reflection limit_ordinal_reflection omega_reflection
paulson@13323
  1349
wenzelm@13429
  1350
lemmas fun_plus_iff_sats =
wenzelm@13429
  1351
        typed_function_iff_sats composition_iff_sats
wenzelm@13429
  1352
        injection_iff_sats surjection_iff_sats
wenzelm@13429
  1353
        bijection_iff_sats restriction_iff_sats
paulson@13496
  1354
        order_isomorphism_iff_sats finite_ordinal_iff_sats
paulson@13323
  1355
        ordinal_iff_sats limit_ordinal_iff_sats omega_iff_sats
paulson@13316
  1356
paulson@13223
  1357
end