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