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