src/ZF/Constructible/Wellorderings.thy
 changeset 13223 45be08fbdcff child 13245 714f7a423a15
```     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/ZF/Constructible/Wellorderings.thy	Wed Jun 19 11:48:01 2002 +0200
1.3 @@ -0,0 +1,626 @@
1.5 +
1.6 +theory Wellorderings = Relative:
1.7 +
1.8 +text{*We define functions analogous to @{term ordermap} @{term ordertype}
1.9 +      but without using recursion.  Instead, there is a direct appeal
1.10 +      to Replacement.  This will be the basis for a version relativized
1.11 +      to some class @{text M}.  The main result is Theorem I 7.6 in Kunen,
1.12 +      page 17.*}
1.13 +
1.14 +
1.15 +subsection{*Wellorderings*}
1.16 +
1.17 +constdefs
1.18 +  irreflexive :: "[i=>o,i,i]=>o"
1.19 +    "irreflexive(M,A,r) == \<forall>x\<in>A. M(x) --> <x,x> \<notin> r"
1.20 +
1.21 +  transitive_rel :: "[i=>o,i,i]=>o"
1.22 +    "transitive_rel(M,A,r) ==
1.23 +	\<forall>x\<in>A. M(x) --> (\<forall>y\<in>A. M(y) --> (\<forall>z\<in>A. M(z) -->
1.24 +                          <x,y>\<in>r --> <y,z>\<in>r --> <x,z>\<in>r))"
1.25 +
1.26 +  linear_rel :: "[i=>o,i,i]=>o"
1.27 +    "linear_rel(M,A,r) ==
1.28 +	\<forall>x\<in>A. M(x) --> (\<forall>y\<in>A. M(y) --> <x,y>\<in>r | x=y | <y,x>\<in>r)"
1.29 +
1.30 +  wellfounded :: "[i=>o,i]=>o"
1.31 +    --{*EVERY non-empty set has an @{text r}-minimal element*}
1.32 +    "wellfounded(M,r) ==
1.33 +	\<forall>x. M(x) --> ~ empty(M,x)
1.34 +                 --> (\<exists>y\<in>x. M(y) & ~(\<exists>z\<in>x. M(z) & <z,y> \<in> r))"
1.35 +  wellfounded_on :: "[i=>o,i,i]=>o"
1.36 +    --{*every non-empty SUBSET OF @{text A} has an @{text r}-minimal element*}
1.37 +    "wellfounded_on(M,A,r) ==
1.38 +	\<forall>x. M(x) --> ~ empty(M,x) --> subset(M,x,A)
1.39 +                 --> (\<exists>y\<in>x. M(y) & ~(\<exists>z\<in>x. M(z) & <z,y> \<in> r))"
1.40 +
1.41 +  wellordered :: "[i=>o,i,i]=>o"
1.42 +    --{*every non-empty subset of @{text A} has an @{text r}-minimal element*}
1.43 +    "wellordered(M,A,r) ==
1.44 +	transitive_rel(M,A,r) & linear_rel(M,A,r) & wellfounded_on(M,A,r)"
1.45 +
1.46 +
1.47 +subsubsection {*Trivial absoluteness proofs*}
1.48 +
1.49 +lemma (in M_axioms) irreflexive_abs [simp]:
1.50 +     "M(A) ==> irreflexive(M,A,r) <-> irrefl(A,r)"
1.51 +by (simp add: irreflexive_def irrefl_def)
1.52 +
1.53 +lemma (in M_axioms) transitive_rel_abs [simp]:
1.54 +     "M(A) ==> transitive_rel(M,A,r) <-> trans[A](r)"
1.55 +by (simp add: transitive_rel_def trans_on_def)
1.56 +
1.57 +lemma (in M_axioms) linear_rel_abs [simp]:
1.58 +     "M(A) ==> linear_rel(M,A,r) <-> linear(A,r)"
1.59 +by (simp add: linear_rel_def linear_def)
1.60 +
1.61 +lemma (in M_axioms) wellordered_is_trans_on:
1.62 +    "[| wellordered(M,A,r); M(A) |] ==> trans[A](r)"
1.63 +by (auto simp add: wellordered_def )
1.64 +
1.65 +lemma (in M_axioms) wellordered_is_linear:
1.66 +    "[| wellordered(M,A,r); M(A) |] ==> linear(A,r)"
1.67 +by (auto simp add: wellordered_def )
1.68 +
1.69 +lemma (in M_axioms) wellordered_is_wellfounded_on:
1.70 +    "[| wellordered(M,A,r); M(A) |] ==> wellfounded_on(M,A,r)"
1.71 +by (auto simp add: wellordered_def )
1.72 +
1.73 +lemma (in M_axioms) wellfounded_imp_wellfounded_on:
1.74 +    "[| wellfounded(M,r); M(A) |] ==> wellfounded_on(M,A,r)"
1.75 +by (auto simp add: wellfounded_def wellfounded_on_def)
1.76 +
1.77 +
1.78 +subsubsection {*Well-founded relations*}
1.79 +
1.80 +lemma  (in M_axioms) wellfounded_on_iff_wellfounded:
1.81 +     "wellfounded_on(M,A,r) <-> wellfounded(M, r \<inter> A*A)"
1.82 +apply (simp add: wellfounded_on_def wellfounded_def, safe)
1.83 + apply blast
1.84 +apply (drule_tac x=x in spec, blast)
1.85 +done
1.86 +
1.87 +lemma (in M_axioms) wellfounded_on_induct:
1.88 +     "[| a\<in>A;  wellfounded_on(M,A,r);  M(A);
1.89 +       separation(M, \<lambda>x. x\<in>A --> ~P(x));
1.90 +       \<forall>x\<in>A. M(x) & (\<forall>y\<in>A. <y,x> \<in> r --> P(y)) --> P(x) |]
1.91 +      ==> P(a)";
1.92 +apply (simp (no_asm_use) add: wellfounded_on_def)
1.93 +apply (drule_tac x="{z\<in>A. z\<in>A --> ~P(z)}" in spec)
1.94 +apply (blast intro: transM)
1.95 +done
1.96 +
1.97 +text{*The assumption @{term "r \<subseteq> A*A"} justifies strengthening the induction
1.98 +      hypothesis by removing the restriction to @{term A}.*}
1.99 +lemma (in M_axioms) wellfounded_on_induct2:
1.100 +     "[| a\<in>A;  wellfounded_on(M,A,r);  M(A);  r \<subseteq> A*A;
1.101 +       separation(M, \<lambda>x. x\<in>A --> ~P(x));
1.102 +       \<forall>x\<in>A. M(x) & (\<forall>y. <y,x> \<in> r --> P(y)) --> P(x) |]
1.103 +      ==> P(a)";
1.104 +by (rule wellfounded_on_induct, assumption+, blast)
1.105 +
1.106 +
1.107 +subsubsection {*Kunen's lemma IV 3.14, page 123*}
1.108 +
1.109 +lemma (in M_axioms) linear_imp_relativized:
1.110 +     "linear(A,r) ==> linear_rel(M,A,r)"
1.111 +by (simp add: linear_def linear_rel_def)
1.112 +
1.113 +lemma (in M_axioms) trans_on_imp_relativized:
1.114 +     "trans[A](r) ==> transitive_rel(M,A,r)"
1.115 +by (unfold transitive_rel_def trans_on_def, blast)
1.116 +
1.117 +lemma (in M_axioms) wf_on_imp_relativized:
1.118 +     "wf[A](r) ==> wellfounded_on(M,A,r)"
1.119 +apply (simp add: wellfounded_on_def wf_def wf_on_def, clarify)
1.120 +apply (drule_tac x="x" in spec, blast)
1.121 +done
1.122 +
1.123 +lemma (in M_axioms) wf_imp_relativized:
1.124 +     "wf(r) ==> wellfounded(M,r)"
1.125 +apply (simp add: wellfounded_def wf_def, clarify)
1.126 +apply (drule_tac x="x" in spec, blast)
1.127 +done
1.128 +
1.129 +lemma (in M_axioms) well_ord_imp_relativized:
1.130 +     "well_ord(A,r) ==> wellordered(M,A,r)"
1.131 +by (simp add: wellordered_def well_ord_def tot_ord_def part_ord_def
1.132 +       linear_imp_relativized trans_on_imp_relativized wf_on_imp_relativized)
1.133 +
1.134 +
1.135 +subsection{* Relativized versions of order-isomorphisms and order types *}
1.136 +
1.137 +lemma (in M_axioms) order_isomorphism_abs [simp]:
1.138 +     "[| M(A); M(B); M(f) |]
1.139 +      ==> order_isomorphism(M,A,r,B,s,f) <-> f \<in> ord_iso(A,r,B,s)"
1.140 +by (simp add: typed_apply_abs [OF bij_is_fun] apply_closed
1.141 +              order_isomorphism_def ord_iso_def)
1.142 +
1.143 +
1.144 +lemma (in M_axioms) pred_set_abs [simp]:
1.145 +     "[| M(r); M(B) |] ==> pred_set(M,A,x,r,B) <-> B = Order.pred(A,x,r)"
1.146 +apply (simp add: pred_set_def Order.pred_def)
1.147 +apply (blast dest: transM)
1.148 +done
1.149 +
1.150 +lemma (in M_axioms) pred_closed [intro]:
1.151 +     "[| M(A); M(r); M(x) |] ==> M(Order.pred(A,x,r))"
1.153 +apply (insert pred_separation [of r x], simp, blast)
1.154 +done
1.155 +
1.156 +lemma (in M_axioms) membership_abs [simp]:
1.157 +     "[| M(r); M(A) |] ==> membership(M,A,r) <-> r = Memrel(A)"
1.158 +apply (simp add: membership_def Memrel_def, safe)
1.159 +  apply (rule equalityI)
1.160 +   apply clarify
1.161 +   apply (frule transM, assumption)
1.162 +   apply blast
1.163 +  apply clarify
1.164 +  apply (subgoal_tac "M(<xb,ya>)", blast)
1.165 +  apply (blast dest: transM)
1.166 + apply auto
1.167 +done
1.168 +
1.169 +lemma (in M_axioms) M_Memrel_iff:
1.170 +     "M(A) ==>
1.171 +      Memrel(A) = {z \<in> A*A. \<exists>x. M(x) \<and> (\<exists>y. M(y) \<and> z = \<langle>x,y\<rangle> \<and> x \<in> y)}"
1.173 +apply (blast dest: transM)
1.174 +done
1.175 +
1.176 +lemma (in M_axioms) Memrel_closed [intro]:
1.177 +     "M(A) ==> M(Memrel(A))"
1.179 +apply (insert Memrel_separation, simp, blast)
1.180 +done
1.181 +
1.182 +
1.183 +subsection {* Main results of Kunen, Chapter 1 section 6 *}
1.184 +
1.185 +text{*Subset properties-- proved outside the locale*}
1.186 +
1.187 +lemma linear_rel_subset:
1.188 +    "[| linear_rel(M,A,r);  B<=A |] ==> linear_rel(M,B,r)"
1.189 +by (unfold linear_rel_def, blast)
1.190 +
1.191 +lemma transitive_rel_subset:
1.192 +    "[| transitive_rel(M,A,r);  B<=A |] ==> transitive_rel(M,B,r)"
1.193 +by (unfold transitive_rel_def, blast)
1.194 +
1.195 +lemma wellfounded_on_subset:
1.196 +    "[| wellfounded_on(M,A,r);  B<=A |] ==> wellfounded_on(M,B,r)"
1.197 +by (unfold wellfounded_on_def subset_def, blast)
1.198 +
1.199 +lemma wellordered_subset:
1.200 +    "[| wellordered(M,A,r);  B<=A |] ==> wellordered(M,B,r)"
1.201 +apply (unfold wellordered_def)
1.202 +apply (blast intro: linear_rel_subset transitive_rel_subset
1.203 +		    wellfounded_on_subset)
1.204 +done
1.205 +
1.206 +text{*Inductive argument for Kunen's Lemma 6.1, etc.
1.207 +      Simple proof from Halmos, page 72*}
1.208 +lemma  (in M_axioms) wellordered_iso_subset_lemma:
1.209 +     "[| wellordered(M,A,r);  f \<in> ord_iso(A,r, A',r);  A'<= A;  y \<in> A;
1.210 +       M(A);  M(f);  M(r) |] ==> ~ <f`y, y> \<in> r"
1.211 +apply (unfold wellordered_def ord_iso_def)
1.212 +apply (elim conjE CollectE)
1.213 +apply (erule wellfounded_on_induct, assumption+)
1.214 + apply (insert well_ord_iso_separation [of A f r])
1.215 + apply (simp add: typed_apply_abs [OF bij_is_fun] apply_closed, clarify)
1.216 +apply (drule_tac a = x in bij_is_fun [THEN apply_type], assumption, blast)
1.217 +done
1.218 +
1.219 +
1.220 +text{*Kunen's Lemma 6.1: there's no order-isomorphism to an initial segment
1.221 +      of a well-ordering*}
1.222 +lemma (in M_axioms) wellordered_iso_predD:
1.223 +     "[| wellordered(M,A,r);  f \<in> ord_iso(A, r, Order.pred(A,x,r), r);
1.224 +       M(A);  M(f);  M(r) |] ==> x \<notin> A"
1.225 +apply (rule notI)
1.226 +apply (frule wellordered_iso_subset_lemma, assumption)
1.227 +apply (auto elim: predE)
1.228 +(*Now we know  ~ (f`x < x) *)
1.229 +apply (drule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type], assumption)
1.230 +(*Now we also know f`x  \<in> pred(A,x,r);  contradiction! *)
1.232 +done
1.233 +
1.234 +
1.235 +lemma (in M_axioms) wellordered_iso_pred_eq_lemma:
1.236 +     "[| f \<in> \<langle>Order.pred(A,y,r), r\<rangle> \<cong> \<langle>Order.pred(A,x,r), r\<rangle>;
1.237 +       wellordered(M,A,r); x\<in>A; y\<in>A; M(A); M(f); M(r) |] ==> <x,y> \<notin> r"
1.238 +apply (frule wellordered_is_trans_on, assumption)
1.239 +apply (rule notI)
1.240 +apply (drule_tac x2=y and x=x and r2=r in
1.241 +         wellordered_subset [OF _ pred_subset, THEN wellordered_iso_predD])
1.243 +apply (blast intro: predI dest: transM)+
1.244 +done
1.245 +
1.246 +
1.247 +text{*Simple consequence of Lemma 6.1*}
1.248 +lemma (in M_axioms) wellordered_iso_pred_eq:
1.249 +     "[| wellordered(M,A,r);
1.250 +       f \<in> ord_iso(Order.pred(A,a,r), r, Order.pred(A,c,r), r);
1.251 +       M(A);  M(f);  M(r);  a\<in>A;  c\<in>A |] ==> a=c"
1.252 +apply (frule wellordered_is_trans_on, assumption)
1.253 +apply (frule wellordered_is_linear, assumption)
1.254 +apply (erule_tac x=a and y=c in linearE, auto)
1.255 +apply (drule ord_iso_sym)
1.256 +(*two symmetric cases*)
1.257 +apply (blast dest: wellordered_iso_pred_eq_lemma)+
1.258 +done
1.259 +
1.260 +lemma (in M_axioms) wellfounded_on_asym:
1.261 +     "[| wellfounded_on(M,A,r);  <a,x>\<in>r;  a\<in>A; x\<in>A;  M(A) |] ==> <x,a>\<notin>r"
1.263 +apply (drule_tac x="{x,a}" in spec)
1.265 +apply (blast dest: transM)
1.266 +done
1.267 +
1.268 +lemma (in M_axioms) wellordered_asym:
1.269 +     "[| wellordered(M,A,r);  <a,x>\<in>r;  a\<in>A; x\<in>A;  M(A) |] ==> <x,a>\<notin>r"
1.270 +by (simp add: wellordered_def, blast dest: wellfounded_on_asym)
1.271 +
1.272 +
1.273 +text{*Surely a shorter proof using lemmas in @{text Order}?
1.274 +     Like well_ord_iso_preserving?*}
1.275 +lemma (in M_axioms) ord_iso_pred_imp_lt:
1.276 +     "[| f \<in> ord_iso(Order.pred(A,x,r), r, i, Memrel(i));
1.277 +       g \<in> ord_iso(Order.pred(A,y,r), r, j, Memrel(j));
1.278 +       wellordered(M,A,r);  x \<in> A;  y \<in> A; M(A); M(r); M(f); M(g); M(j);
1.279 +       Ord(i); Ord(j); \<langle>x,y\<rangle> \<in> r |]
1.280 +      ==> i < j"
1.281 +apply (frule wellordered_is_trans_on, assumption)
1.282 +apply (frule_tac y=y in transM, assumption)
1.283 +apply (rule_tac i=i and j=j in Ord_linear_lt, auto)
1.284 +txt{*case @{term "i=j"} yields a contradiction*}
1.285 + apply (rule_tac x1=x and A1="Order.pred(A,y,r)" in
1.286 +          wellordered_iso_predD [THEN notE])
1.287 +   apply (blast intro: wellordered_subset [OF _ pred_subset])
1.288 +  apply (simp add: trans_pred_pred_eq)
1.289 +  apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans)
1.290 + apply (simp_all add: pred_iff pred_closed converse_closed comp_closed)
1.291 +txt{*case @{term "j<i"} also yields a contradiction*}
1.292 +apply (frule restrict_ord_iso2, assumption+)
1.293 +apply (frule ord_iso_sym [THEN ord_iso_is_bij, THEN bij_is_fun])
1.294 +apply (frule apply_type, blast intro: ltD)
1.295 +  --{*thus @{term "converse(f)`j \<in> Order.pred(A,x,r)"}*}
1.297 +apply (subgoal_tac
1.298 +       "\<exists>h. M(h) & h \<in> ord_iso(Order.pred(A,y,r), r,
1.299 +                               Order.pred(A, converse(f)`j, r), r)")
1.300 + apply (clarify, frule wellordered_iso_pred_eq, assumption+)
1.301 + apply (blast dest: wellordered_asym)
1.302 +apply (intro exI conjI)
1.303 + prefer 2 apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans)+
1.304 +done
1.305 +
1.306 +
1.307 +lemma ord_iso_converse1:
1.308 +     "[| f: ord_iso(A,r,B,s);  <b, f`a>: s;  a:A;  b:B |]
1.309 +      ==> <converse(f) ` b, a> : r"
1.310 +apply (frule ord_iso_converse, assumption+)
1.311 +apply (blast intro: ord_iso_is_bij [THEN bij_is_fun, THEN apply_funtype])
1.312 +apply (simp add: left_inverse_bij [OF ord_iso_is_bij])
1.313 +done
1.314 +
1.315 +
1.316 +subsection {* Order Types: A Direct Construction by Replacement*}
1.317 +
1.318 +text{*This follows Kunen's Theorem I 7.6, page 17.*}
1.319 +
1.320 +constdefs
1.321 +
1.322 +  obase :: "[i=>o,i,i,i] => o"
1.323 +       --{*the domain of @{text om}, eventually shown to equal @{text A}*}
1.324 +   "obase(M,A,r,z) ==
1.325 +	\<forall>a. M(a) -->
1.326 +         (a \<in> z <->
1.327 +          (a\<in>A & (\<exists>x g mx par. M(x) & M(g) & M(mx) & M(par) & ordinal(M,x) &
1.328 +                               membership(M,x,mx) & pred_set(M,A,a,r,par) &
1.329 +                               order_isomorphism(M,par,r,x,mx,g))))"
1.330 +
1.331 +
1.332 +  omap :: "[i=>o,i,i,i] => o"
1.333 +    --{*the function that maps wosets to order types*}
1.334 +   "omap(M,A,r,f) ==
1.335 +	\<forall>z. M(z) -->
1.336 +         (z \<in> f <->
1.337 +          (\<exists>a\<in>A. M(a) &
1.338 +           (\<exists>x g mx par. M(x) & M(g) & M(mx) & M(par) & ordinal(M,x) &
1.339 +                         pair(M,a,x,z) & membership(M,x,mx) &
1.340 +                         pred_set(M,A,a,r,par) &
1.341 +                         order_isomorphism(M,par,r,x,mx,g))))"
1.342 +
1.343 +
1.344 +  otype :: "[i=>o,i,i,i] => o"  --{*the order types themselves*}
1.345 +   "otype(M,A,r,i) == \<exists>f. M(f) & omap(M,A,r,f) & is_range(M,f,i)"
1.346 +
1.347 +
1.348 +
1.349 +lemma (in M_axioms) obase_iff:
1.350 +     "[| M(A); M(r); M(z) |]
1.351 +      ==> obase(M,A,r,z) <->
1.352 +          z = {a\<in>A. \<exists>x g. M(x) & M(g) & Ord(x) &
1.353 +                          g \<in> ord_iso(Order.pred(A,a,r),r,x,Memrel(x))}"
1.354 +apply (simp add: obase_def Memrel_closed pred_closed)
1.355 +apply (rule iffI)
1.356 + prefer 2 apply blast
1.357 +apply (rule equalityI)
1.358 + apply (clarify, frule transM, assumption, rotate_tac -1, simp)
1.359 +apply (clarify, frule transM, assumption, force)
1.360 +done
1.361 +
1.362 +text{*Can also be proved with the premise @{term "M(z)"} instead of
1.363 +      @{term "M(f)"}, but that version is less useful.*}
1.364 +lemma (in M_axioms) omap_iff:
1.365 +     "[| omap(M,A,r,f); M(A); M(r); M(f) |]
1.366 +      ==> z \<in> f <->
1.367 +      (\<exists>a\<in>A. \<exists>x g. M(x) & M(g) & z = <a,x> & Ord(x) &
1.368 +                   g \<in> ord_iso(Order.pred(A,a,r),r,x,Memrel(x)))"
1.369 +apply (rotate_tac 1)
1.370 +apply (simp add: omap_def Memrel_closed pred_closed)
1.371 +apply (rule iffI)
1.372 +apply (drule_tac x=z in spec, blast dest: transM)+
1.373 +done
1.374 +
1.375 +lemma (in M_axioms) omap_unique:
1.376 +     "[| omap(M,A,r,f); omap(M,A,r,f'); M(A); M(r); M(f); M(f') |] ==> f' = f"
1.377 +apply (rule equality_iffI)
1.379 +done
1.380 +
1.381 +lemma (in M_axioms) omap_yields_Ord:
1.382 +     "[| omap(M,A,r,f); \<langle>a,x\<rangle> \<in> f; M(a); M(x) |]  ==> Ord(x)"
1.383 +apply (simp add: omap_def, blast)
1.384 +done
1.385 +
1.386 +lemma (in M_axioms) otype_iff:
1.387 +     "[| otype(M,A,r,i); M(A); M(r); M(i) |]
1.388 +      ==> x \<in> i <->
1.389 +          (\<exists>a\<in>A. \<exists>g. M(x) & M(g) & Ord(x) &
1.390 +                     g \<in> ord_iso(Order.pred(A,a,r),r,x,Memrel(x)))"
1.391 +apply (simp add: otype_def, auto)
1.392 +  apply (blast dest: transM)
1.393 + apply (blast dest!: omap_iff intro: transM)
1.394 +apply (rename_tac a g)
1.395 +apply (rule_tac a=a in rangeI)
1.396 +apply (frule transM, assumption)
1.397 +apply (simp add: omap_iff, blast)
1.398 +done
1.399 +
1.400 +lemma (in M_axioms) otype_eq_range:
1.401 +     "[| omap(M,A,r,f); otype(M,A,r,i); M(A); M(r); M(f); M(i) |] ==> i = range(f)"
1.402 +apply (auto simp add: otype_def omap_iff)
1.403 +apply (blast dest: omap_unique)
1.404 +done
1.405 +
1.406 +
1.407 +lemma (in M_axioms) Ord_otype:
1.408 +     "[| otype(M,A,r,i); trans[A](r); M(A); M(r); M(i) |] ==> Ord(i)"
1.409 +apply (rotate_tac 1)
1.410 +apply (rule OrdI)
1.411 +prefer 2
1.412 +    apply (simp add: Ord_def otype_def omap_def)
1.413 +    apply clarify
1.414 +    apply (frule pair_components_in_M, assumption)
1.415 +    apply blast
1.416 +apply (auto simp add: Transset_def otype_iff)
1.417 + apply (blast intro: transM)
1.418 +apply (rename_tac y a g)
1.419 +apply (frule ord_iso_sym [THEN ord_iso_is_bij, THEN bij_is_fun,
1.420 +			  THEN apply_funtype],  assumption)
1.421 +apply (rule_tac x="converse(g)`y" in bexI)
1.422 + apply (frule_tac a="converse(g) ` y" in ord_iso_restrict_pred, assumption)
1.423 +apply (safe elim!: predE)
1.424 +apply (intro conjI exI)
1.425 +prefer 3
1.426 +  apply (blast intro: restrict_ord_iso ord_iso_sym ltI)
1.427 + apply (blast intro: transM)
1.428 + apply (blast intro: Ord_in_Ord)
1.429 +done
1.430 +
1.431 +lemma (in M_axioms) domain_omap:
1.432 +     "[| omap(M,A,r,f);  obase(M,A,r,B); M(A); M(r); M(B); M(f) |]
1.433 +      ==> domain(f) = B"
1.434 +apply (rotate_tac 2)
1.435 +apply (simp add: domain_closed obase_iff)
1.436 +apply (rule equality_iffI)
1.437 +apply (simp add: domain_iff omap_iff, blast)
1.438 +done
1.439 +
1.440 +lemma (in M_axioms) omap_subset:
1.441 +     "[| omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
1.442 +       M(A); M(r); M(f); M(B); M(i) |] ==> f \<subseteq> B * i"
1.443 +apply (rotate_tac 3, clarify)
1.444 +apply (simp add: omap_iff obase_iff)
1.445 +apply (force simp add: otype_iff)
1.446 +done
1.447 +
1.448 +lemma (in M_axioms) omap_funtype:
1.449 +     "[| omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
1.450 +       M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> B -> i"
1.451 +apply (rotate_tac 3)
1.452 +apply (simp add: domain_omap omap_subset Pi_iff function_def omap_iff)
1.453 +apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans)
1.454 +done
1.455 +
1.456 +
1.457 +lemma (in M_axioms) wellordered_omap_bij:
1.458 +     "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
1.459 +       M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> bij(B,i)"
1.460 +apply (insert omap_funtype [of A r f B i])
1.461 +apply (auto simp add: bij_def inj_def)
1.462 +prefer 2  apply (blast intro: fun_is_surj dest: otype_eq_range)
1.463 +apply (frule_tac a="w" in apply_Pair, assumption)
1.464 +apply (frule_tac a="x" in apply_Pair, assumption)
1.466 +apply (blast intro: wellordered_iso_pred_eq ord_iso_sym ord_iso_trans)
1.467 +done
1.468 +
1.469 +
1.470 +text{*This is not the final result: we must show @{term "oB(A,r) = A"}*}
1.471 +lemma (in M_axioms) omap_ord_iso:
1.472 +     "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
1.473 +       M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> ord_iso(B,r,i,Memrel(i))"
1.474 +apply (rule ord_isoI)
1.475 + apply (erule wellordered_omap_bij, assumption+)
1.476 +apply (insert omap_funtype [of A r f B i], simp)
1.477 +apply (frule_tac a="x" in apply_Pair, assumption)
1.478 +apply (frule_tac a="y" in apply_Pair, assumption)
1.479 +apply (auto simp add: omap_iff)
1.480 + txt{*direction 1: assuming @{term "\<langle>x,y\<rangle> \<in> r"}*}
1.481 + apply (blast intro: ltD ord_iso_pred_imp_lt)
1.482 + txt{*direction 2: proving @{term "\<langle>x,y\<rangle> \<in> r"} using linearity of @{term r}*}
1.483 +apply (rename_tac x y g ga)
1.484 +apply (frule wellordered_is_linear, assumption,
1.485 +       erule_tac x=x and y=y in linearE, assumption+)
1.487 +apply (blast elim: mem_irrefl)
1.488 +txt{*the case @{term "\<langle>y,x\<rangle> \<in> r"}: handle like the opposite direction*}
1.489 +apply (blast dest: ord_iso_pred_imp_lt ltD elim: mem_asym)
1.490 +done
1.491 +
1.492 +lemma (in M_axioms) Ord_omap_image_pred:
1.493 +     "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
1.494 +       M(A); M(r); M(f); M(B); M(i); b \<in> A |] ==> Ord(f `` Order.pred(A,b,r))"
1.495 +apply (frule wellordered_is_trans_on, assumption)
1.496 +apply (rule OrdI)
1.497 +	prefer 2 apply (simp add: image_iff omap_iff Ord_def, blast)
1.498 +txt{*Hard part is to show that the image is a transitive set.*}
1.499 +apply (rotate_tac 3)
1.500 +apply (simp add: Transset_def, clarify)
1.501 +apply (simp add: image_iff pred_iff apply_iff [OF omap_funtype [of A r f B i]])
1.502 +apply (rename_tac c j, clarify)
1.503 +apply (frule omap_funtype [of A r f B, THEN apply_funtype], assumption+)
1.504 +apply (subgoal_tac "j : i")
1.505 +	prefer 2 apply (blast intro: Ord_trans Ord_otype)
1.506 +apply (subgoal_tac "converse(f) ` j : B")
1.507 +	prefer 2
1.508 +	apply (blast dest: wellordered_omap_bij [THEN bij_converse_bij,
1.509 +                                      THEN bij_is_fun, THEN apply_funtype])
1.510 +apply (rule_tac x="converse(f) ` j" in bexI)
1.511 + apply (simp add: right_inverse_bij [OF wellordered_omap_bij])
1.512 +apply (intro predI conjI)
1.513 + apply (erule_tac b=c in trans_onD)
1.514 + apply (rule ord_iso_converse1 [OF omap_ord_iso [of A r f B i]])
1.515 +apply (auto simp add: obase_iff)
1.516 +done
1.517 +
1.518 +lemma (in M_axioms) restrict_omap_ord_iso:
1.519 +     "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
1.520 +       D \<subseteq> B; M(A); M(r); M(f); M(B); M(i) |]
1.521 +      ==> restrict(f,D) \<in> (\<langle>D,r\<rangle> \<cong> \<langle>f``D, Memrel(f``D)\<rangle>)"
1.522 +apply (frule ord_iso_restrict_image [OF omap_ord_iso [of A r f B i]],
1.523 +       assumption+)
1.524 +apply (drule ord_iso_sym [THEN subset_ord_iso_Memrel])
1.525 +apply (blast dest: subsetD [OF omap_subset])
1.526 +apply (drule ord_iso_sym, simp)
1.527 +done
1.528 +
1.529 +lemma (in M_axioms) obase_equals:
1.530 +     "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
1.531 +       M(A); M(r); M(f); M(B); M(i) |] ==> B = A"
1.532 +apply (rotate_tac 4)
1.533 +apply (rule equalityI, force simp add: obase_iff, clarify)
1.534 +apply (subst obase_iff [of A r B, THEN iffD1], assumption+, simp)
1.535 +apply (frule wellordered_is_wellfounded_on, assumption)
1.536 +apply (erule wellfounded_on_induct, assumption+)
1.537 + apply (insert obase_equals_separation, simp add: Memrel_closed pred_closed, clarify)
1.538 +apply (rename_tac b)
1.539 +apply (subgoal_tac "Order.pred(A,b,r) <= B")
1.540 + prefer 2 apply (force simp add: pred_iff obase_iff)
1.541 +apply (intro conjI exI)
1.542 +    prefer 4 apply (blast intro: restrict_omap_ord_iso)
1.543 +apply (blast intro: Ord_omap_image_pred)+
1.544 +done
1.545 +
1.546 +
1.547 +
1.548 +text{*Main result: @{term om} gives the order-isomorphism
1.549 +      @{term "\<langle>A,r\<rangle> \<cong> \<langle>i, Memrel(i)\<rangle>"} *}
1.550 +theorem (in M_axioms) omap_ord_iso_otype:
1.551 +     "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
1.552 +       M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> ord_iso(A, r, i, Memrel(i))"
1.553 +apply (frule omap_ord_iso, assumption+)
1.554 +apply (frule obase_equals, assumption+, blast)
1.555 +done
1.556 +
1.557 +lemma (in M_axioms) obase_exists:
1.558 +     "[| M(A); M(r) |] ==> \<exists>z. M(z) & obase(M,A,r,z)"
1.560 +apply (insert obase_separation [of A r])
1.562 +done
1.563 +
1.564 +lemma (in M_axioms) omap_exists:
1.565 +     "[| M(A); M(r) |] ==> \<exists>z. M(z) & omap(M,A,r,z)"
1.566 +apply (insert obase_exists [of A r])
1.568 +apply (insert omap_replacement [of A r])
1.569 +apply (simp add: strong_replacement_def, clarify)
1.570 +apply (drule_tac x=z in spec, clarify)
1.571 +apply (simp add: Memrel_closed pred_closed obase_iff)
1.572 +apply (erule impE)
1.573 + apply (clarsimp simp add: univalent_def)
1.574 + apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans, clarify)
1.575 +apply (rule_tac x=Y in exI)
1.576 +apply (simp add: Memrel_closed pred_closed obase_iff, blast)
1.577 +done
1.578 +
1.579 +lemma (in M_axioms) otype_exists:
1.580 +     "[| wellordered(M,A,r); M(A); M(r) |] ==> \<exists>i. M(i) & otype(M,A,r,i)"
1.581 +apply (insert omap_exists [of A r])
1.582 +apply (simp add: otype_def, clarify)
1.583 +apply (rule_tac x="range(z)" in exI)
1.584 +apply blast
1.585 +done
1.586 +
1.587 +theorem (in M_axioms) omap_ord_iso_otype:
1.588 +     "[| wellordered(M,A,r); M(A); M(r) |]
1.589 +      ==> \<exists>f. M(f) & (\<exists>i. M(i) & Ord(i) & f \<in> ord_iso(A, r, i, Memrel(i)))"
1.590 +apply (insert obase_exists [of A r] omap_exists [of A r] otype_exists [of A r], simp, clarify)
1.591 +apply (subgoal_tac "Ord(i)", blast intro: omap_ord_iso_otype)
1.592 +apply (rule Ord_otype)
1.593 +    apply (force simp add: otype_def range_closed)
1.594 +   apply (simp_all add: wellordered_is_trans_on)
1.595 +done
1.596 +
1.597 +lemma (in M_axioms) ordertype_exists:
1.598 +     "[| wellordered(M,A,r); M(A); M(r) |]
1.599 +      ==> \<exists>f. M(f) & (\<exists>i. M(i) & Ord(i) & f \<in> ord_iso(A, r, i, Memrel(i)))"
1.600 +apply (insert obase_exists [of A r] omap_exists [of A r] otype_exists [of A r], simp, clarify)
1.601 +apply (subgoal_tac "Ord(i)", blast intro: omap_ord_iso_otype)
1.602 +apply (rule Ord_otype)
1.603 +    apply (force simp add: otype_def range_closed)
1.604 +   apply (simp_all add: wellordered_is_trans_on)
1.605 +done
1.606 +
1.607 +
1.608 +lemma (in M_axioms) relativized_imp_well_ord:
1.609 +     "[| wellordered(M,A,r); M(A); M(r) |] ==> well_ord(A,r)"
1.610 +apply (insert ordertype_exists [of A r], simp)
1.611 +apply (blast intro: well_ord_ord_iso well_ord_Memrel )
1.612 +done
1.613 +
1.614 +subsection {*Kunen's theorem 5.4, poage 127*}
1.615 +
1.616 +text{*(a) The notion of Wellordering is absolute*}
1.617 +theorem (in M_axioms) well_ord_abs [simp]:
1.618 +     "[| M(A); M(r) |] ==> wellordered(M,A,r) <-> well_ord(A,r)"
1.619 +by (blast intro: well_ord_imp_relativized relativized_imp_well_ord)
1.620 +
1.621 +
1.622 +text{*(b) Order types are absolute*}
1.623 +lemma (in M_axioms)
1.624 +     "[| wellordered(M,A,r); f \<in> ord_iso(A, r, i, Memrel(i));
1.625 +       M(A); M(r); M(f); M(i); Ord(i) |] ==> i = ordertype(A,r)"
1.626 +by (blast intro: Ord_ordertype relativized_imp_well_ord ordertype_ord_iso
1.627 +                 Ord_iso_implies_eq ord_iso_sym ord_iso_trans)
1.628 +
1.629 +end
```