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