src/ZF/Constructible/Wellorderings.thy
author paulson
Wed Aug 21 15:57:24 2002 +0200 (2002-08-21)
changeset 13513 b9e14471629c
parent 13505 52a16cb7fefb
child 13564 1500a2e48d44
permissions -rw-r--r--
tweaks
     1 (*  Title:      ZF/Constructible/Wellorderings.thy
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   2002  University of Cambridge
     5 *)
     6 
     7 header {*Relativized Wellorderings*}
     8 
     9 theory Wellorderings = Relative:
    10 
    11 text{*We define functions analogous to @{term ordermap} @{term ordertype} 
    12       but without using recursion.  Instead, there is a direct appeal
    13       to Replacement.  This will be the basis for a version relativized
    14       to some class @{text M}.  The main result is Theorem I 7.6 in Kunen,
    15       page 17.*}
    16 
    17 
    18 subsection{*Wellorderings*}
    19 
    20 constdefs
    21   irreflexive :: "[i=>o,i,i]=>o"
    22     "irreflexive(M,A,r) == \<forall>x[M]. x\<in>A --> <x,x> \<notin> r"
    23   
    24   transitive_rel :: "[i=>o,i,i]=>o"
    25     "transitive_rel(M,A,r) == 
    26 	\<forall>x[M]. x\<in>A --> (\<forall>y[M]. y\<in>A --> (\<forall>z[M]. z\<in>A --> 
    27                           <x,y>\<in>r --> <y,z>\<in>r --> <x,z>\<in>r))"
    28 
    29   linear_rel :: "[i=>o,i,i]=>o"
    30     "linear_rel(M,A,r) == 
    31 	\<forall>x[M]. x\<in>A --> (\<forall>y[M]. y\<in>A --> <x,y>\<in>r | x=y | <y,x>\<in>r)"
    32 
    33   wellfounded :: "[i=>o,i]=>o"
    34     --{*EVERY non-empty set has an @{text r}-minimal element*}
    35     "wellfounded(M,r) == 
    36 	\<forall>x[M]. ~ empty(M,x) 
    37                  --> (\<exists>y[M]. y\<in>x & ~(\<exists>z[M]. z\<in>x & <z,y> \<in> r))"
    38   wellfounded_on :: "[i=>o,i,i]=>o"
    39     --{*every non-empty SUBSET OF @{text A} has an @{text r}-minimal element*}
    40     "wellfounded_on(M,A,r) == 
    41 	\<forall>x[M]. ~ empty(M,x) --> subset(M,x,A)
    42                  --> (\<exists>y[M]. y\<in>x & ~(\<exists>z[M]. z\<in>x & <z,y> \<in> r))"
    43 
    44   wellordered :: "[i=>o,i,i]=>o"
    45     --{*linear and wellfounded on @{text A}*}
    46     "wellordered(M,A,r) == 
    47 	transitive_rel(M,A,r) & linear_rel(M,A,r) & wellfounded_on(M,A,r)"
    48 
    49 
    50 subsubsection {*Trivial absoluteness proofs*}
    51 
    52 lemma (in M_axioms) irreflexive_abs [simp]: 
    53      "M(A) ==> irreflexive(M,A,r) <-> irrefl(A,r)"
    54 by (simp add: irreflexive_def irrefl_def)
    55 
    56 lemma (in M_axioms) transitive_rel_abs [simp]: 
    57      "M(A) ==> transitive_rel(M,A,r) <-> trans[A](r)"
    58 by (simp add: transitive_rel_def trans_on_def)
    59 
    60 lemma (in M_axioms) linear_rel_abs [simp]: 
    61      "M(A) ==> linear_rel(M,A,r) <-> linear(A,r)"
    62 by (simp add: linear_rel_def linear_def)
    63 
    64 lemma (in M_axioms) wellordered_is_trans_on: 
    65     "[| wellordered(M,A,r); M(A) |] ==> trans[A](r)"
    66 by (auto simp add: wellordered_def)
    67 
    68 lemma (in M_axioms) wellordered_is_linear: 
    69     "[| wellordered(M,A,r); M(A) |] ==> linear(A,r)"
    70 by (auto simp add: wellordered_def)
    71 
    72 lemma (in M_axioms) wellordered_is_wellfounded_on: 
    73     "[| wellordered(M,A,r); M(A) |] ==> wellfounded_on(M,A,r)"
    74 by (auto simp add: wellordered_def)
    75 
    76 lemma (in M_axioms) wellfounded_imp_wellfounded_on: 
    77     "[| wellfounded(M,r); M(A) |] ==> wellfounded_on(M,A,r)"
    78 by (auto simp add: wellfounded_def wellfounded_on_def)
    79 
    80 lemma (in M_axioms) wellfounded_on_subset_A:
    81      "[| wellfounded_on(M,A,r);  B<=A |] ==> wellfounded_on(M,B,r)"
    82 by (simp add: wellfounded_on_def, blast)
    83 
    84 
    85 subsubsection {*Well-founded relations*}
    86 
    87 lemma  (in M_axioms) wellfounded_on_iff_wellfounded:
    88      "wellfounded_on(M,A,r) <-> wellfounded(M, r \<inter> A*A)"
    89 apply (simp add: wellfounded_on_def wellfounded_def, safe)
    90  apply blast 
    91 apply (drule_tac x=x in rspec, assumption, blast) 
    92 done
    93 
    94 lemma (in M_axioms) wellfounded_on_imp_wellfounded:
    95      "[|wellfounded_on(M,A,r); r \<subseteq> A*A|] ==> wellfounded(M,r)"
    96 by (simp add: wellfounded_on_iff_wellfounded subset_Int_iff)
    97 
    98 lemma (in M_axioms) wellfounded_on_field_imp_wellfounded:
    99      "wellfounded_on(M, field(r), r) ==> wellfounded(M,r)"
   100 by (simp add: wellfounded_def wellfounded_on_iff_wellfounded, fast)
   101 
   102 lemma (in M_axioms) wellfounded_iff_wellfounded_on_field:
   103      "M(r) ==> wellfounded(M,r) <-> wellfounded_on(M, field(r), r)"
   104 by (blast intro: wellfounded_imp_wellfounded_on
   105                  wellfounded_on_field_imp_wellfounded)
   106 
   107 (*Consider the least z in domain(r) such that P(z) does not hold...*)
   108 lemma (in M_axioms) wellfounded_induct: 
   109      "[| wellfounded(M,r); M(a); M(r); separation(M, \<lambda>x. ~P(x));  
   110          \<forall>x. M(x) & (\<forall>y. <y,x> \<in> r --> P(y)) --> P(x) |]
   111       ==> P(a)";
   112 apply (simp (no_asm_use) add: wellfounded_def)
   113 apply (drule_tac x="{z \<in> domain(r). ~P(z)}" in rspec)
   114 apply (blast dest: transM)+
   115 done
   116 
   117 lemma (in M_axioms) wellfounded_on_induct: 
   118      "[| a\<in>A;  wellfounded_on(M,A,r);  M(A);  
   119        separation(M, \<lambda>x. x\<in>A --> ~P(x));  
   120        \<forall>x\<in>A. M(x) & (\<forall>y\<in>A. <y,x> \<in> r --> P(y)) --> P(x) |]
   121       ==> P(a)";
   122 apply (simp (no_asm_use) add: wellfounded_on_def)
   123 apply (drule_tac x="{z\<in>A. z\<in>A --> ~P(z)}" in rspec)
   124 apply (blast intro: transM)+
   125 done
   126 
   127 text{*The assumption @{term "r \<subseteq> A*A"} justifies strengthening the induction
   128       hypothesis by removing the restriction to @{term A}.*}
   129 lemma (in M_axioms) wellfounded_on_induct2: 
   130      "[| a\<in>A;  wellfounded_on(M,A,r);  M(A);  r \<subseteq> A*A;  
   131        separation(M, \<lambda>x. x\<in>A --> ~P(x));  
   132        \<forall>x\<in>A. M(x) & (\<forall>y. <y,x> \<in> r --> P(y)) --> P(x) |]
   133       ==> P(a)";
   134 by (rule wellfounded_on_induct, assumption+, blast)
   135 
   136 
   137 subsubsection {*Kunen's lemma IV 3.14, page 123*}
   138 
   139 lemma (in M_axioms) linear_imp_relativized: 
   140      "linear(A,r) ==> linear_rel(M,A,r)" 
   141 by (simp add: linear_def linear_rel_def) 
   142 
   143 lemma (in M_axioms) trans_on_imp_relativized: 
   144      "trans[A](r) ==> transitive_rel(M,A,r)" 
   145 by (unfold transitive_rel_def trans_on_def, blast) 
   146 
   147 lemma (in M_axioms) wf_on_imp_relativized: 
   148      "wf[A](r) ==> wellfounded_on(M,A,r)" 
   149 apply (simp add: wellfounded_on_def wf_def wf_on_def, clarify) 
   150 apply (drule_tac x=x in spec, blast) 
   151 done
   152 
   153 lemma (in M_axioms) wf_imp_relativized: 
   154      "wf(r) ==> wellfounded(M,r)" 
   155 apply (simp add: wellfounded_def wf_def, clarify) 
   156 apply (drule_tac x=x in spec, blast) 
   157 done
   158 
   159 lemma (in M_axioms) well_ord_imp_relativized: 
   160      "well_ord(A,r) ==> wellordered(M,A,r)" 
   161 by (simp add: wellordered_def well_ord_def tot_ord_def part_ord_def
   162        linear_imp_relativized trans_on_imp_relativized wf_on_imp_relativized)
   163 
   164 
   165 subsection{* Relativized versions of order-isomorphisms and order types *}
   166 
   167 lemma (in M_axioms) order_isomorphism_abs [simp]: 
   168      "[| M(A); M(B); M(f) |] 
   169       ==> order_isomorphism(M,A,r,B,s,f) <-> f \<in> ord_iso(A,r,B,s)"
   170 by (simp add: apply_closed order_isomorphism_def ord_iso_def)
   171 
   172 lemma (in M_axioms) pred_set_abs [simp]: 
   173      "[| M(r); M(B) |] ==> pred_set(M,A,x,r,B) <-> B = Order.pred(A,x,r)"
   174 apply (simp add: pred_set_def Order.pred_def)
   175 apply (blast dest: transM) 
   176 done
   177 
   178 lemma (in M_axioms) pred_closed [intro,simp]: 
   179      "[| M(A); M(r); M(x) |] ==> M(Order.pred(A,x,r))"
   180 apply (simp add: Order.pred_def) 
   181 apply (insert pred_separation [of r x], simp) 
   182 done
   183 
   184 lemma (in M_axioms) membership_abs [simp]: 
   185      "[| M(r); M(A) |] ==> membership(M,A,r) <-> r = Memrel(A)"
   186 apply (simp add: membership_def Memrel_def, safe)
   187   apply (rule equalityI) 
   188    apply clarify 
   189    apply (frule transM, assumption)
   190    apply blast
   191   apply clarify 
   192   apply (subgoal_tac "M(<xb,ya>)", blast) 
   193   apply (blast dest: transM) 
   194  apply auto 
   195 done
   196 
   197 lemma (in M_axioms) M_Memrel_iff:
   198      "M(A) ==> 
   199       Memrel(A) = {z \<in> A*A. \<exists>x[M]. \<exists>y[M]. z = \<langle>x,y\<rangle> & x \<in> y}"
   200 apply (simp add: Memrel_def) 
   201 apply (blast dest: transM)
   202 done 
   203 
   204 lemma (in M_axioms) Memrel_closed [intro,simp]: 
   205      "M(A) ==> M(Memrel(A))"
   206 apply (simp add: M_Memrel_iff) 
   207 apply (insert Memrel_separation, simp)
   208 done
   209 
   210 
   211 subsection {* Main results of Kunen, Chapter 1 section 6 *}
   212 
   213 text{*Subset properties-- proved outside the locale*}
   214 
   215 lemma linear_rel_subset: 
   216     "[| linear_rel(M,A,r);  B<=A |] ==> linear_rel(M,B,r)"
   217 by (unfold linear_rel_def, blast)
   218 
   219 lemma transitive_rel_subset: 
   220     "[| transitive_rel(M,A,r);  B<=A |] ==> transitive_rel(M,B,r)"
   221 by (unfold transitive_rel_def, blast)
   222 
   223 lemma wellfounded_on_subset: 
   224     "[| wellfounded_on(M,A,r);  B<=A |] ==> wellfounded_on(M,B,r)"
   225 by (unfold wellfounded_on_def subset_def, blast)
   226 
   227 lemma wellordered_subset: 
   228     "[| wellordered(M,A,r);  B<=A |] ==> wellordered(M,B,r)"
   229 apply (unfold wellordered_def)
   230 apply (blast intro: linear_rel_subset transitive_rel_subset 
   231 		    wellfounded_on_subset)
   232 done
   233 
   234 text{*Inductive argument for Kunen's Lemma 6.1, etc.
   235       Simple proof from Halmos, page 72*}
   236 lemma  (in M_axioms) wellordered_iso_subset_lemma: 
   237      "[| wellordered(M,A,r);  f \<in> ord_iso(A,r, A',r);  A'<= A;  y \<in> A;  
   238        M(A);  M(f);  M(r) |] ==> ~ <f`y, y> \<in> r"
   239 apply (unfold wellordered_def ord_iso_def)
   240 apply (elim conjE CollectE) 
   241 apply (erule wellfounded_on_induct, assumption+)
   242  apply (insert well_ord_iso_separation [of A f r])
   243  apply (simp, clarify) 
   244 apply (drule_tac a = x in bij_is_fun [THEN apply_type], assumption, blast)
   245 done
   246 
   247 
   248 text{*Kunen's Lemma 6.1: there's no order-isomorphism to an initial segment
   249       of a well-ordering*}
   250 lemma (in M_axioms) wellordered_iso_predD:
   251      "[| wellordered(M,A,r);  f \<in> ord_iso(A, r, Order.pred(A,x,r), r);  
   252        M(A);  M(f);  M(r) |] ==> x \<notin> A"
   253 apply (rule notI) 
   254 apply (frule wellordered_iso_subset_lemma, assumption)
   255 apply (auto elim: predE)  
   256 (*Now we know  ~ (f`x < x) *)
   257 apply (drule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type], assumption)
   258 (*Now we also know f`x  \<in> pred(A,x,r);  contradiction! *)
   259 apply (simp add: Order.pred_def)
   260 done
   261 
   262 
   263 lemma (in M_axioms) wellordered_iso_pred_eq_lemma:
   264      "[| f \<in> \<langle>Order.pred(A,y,r), r\<rangle> \<cong> \<langle>Order.pred(A,x,r), r\<rangle>;
   265        wellordered(M,A,r); x\<in>A; y\<in>A; M(A); M(f); M(r) |] ==> <x,y> \<notin> r"
   266 apply (frule wellordered_is_trans_on, assumption)
   267 apply (rule notI) 
   268 apply (drule_tac x2=y and x=x and r2=r in 
   269          wellordered_subset [OF _ pred_subset, THEN wellordered_iso_predD]) 
   270 apply (simp add: trans_pred_pred_eq) 
   271 apply (blast intro: predI dest: transM)+
   272 done
   273 
   274 
   275 text{*Simple consequence of Lemma 6.1*}
   276 lemma (in M_axioms) wellordered_iso_pred_eq:
   277      "[| wellordered(M,A,r);
   278        f \<in> ord_iso(Order.pred(A,a,r), r, Order.pred(A,c,r), r);   
   279        M(A);  M(f);  M(r);  a\<in>A;  c\<in>A |] ==> a=c"
   280 apply (frule wellordered_is_trans_on, assumption)
   281 apply (frule wellordered_is_linear, assumption)
   282 apply (erule_tac x=a and y=c in linearE, auto) 
   283 apply (drule ord_iso_sym)
   284 (*two symmetric cases*)
   285 apply (blast dest: wellordered_iso_pred_eq_lemma)+ 
   286 done
   287 
   288 lemma (in M_axioms) wellfounded_on_asym:
   289      "[| wellfounded_on(M,A,r);  <a,x>\<in>r;  a\<in>A; x\<in>A;  M(A) |] ==> <x,a>\<notin>r"
   290 apply (simp add: wellfounded_on_def) 
   291 apply (drule_tac x="{x,a}" in rspec) 
   292 apply (blast dest: transM)+
   293 done
   294 
   295 lemma (in M_axioms) wellordered_asym:
   296      "[| wellordered(M,A,r);  <a,x>\<in>r;  a\<in>A; x\<in>A;  M(A) |] ==> <x,a>\<notin>r"
   297 by (simp add: wellordered_def, blast dest: wellfounded_on_asym)
   298 
   299 
   300 text{*Surely a shorter proof using lemmas in @{text Order}?
   301      Like @{text well_ord_iso_preserving}?*}
   302 lemma (in M_axioms) ord_iso_pred_imp_lt:
   303      "[| f \<in> ord_iso(Order.pred(A,x,r), r, i, Memrel(i));
   304        g \<in> ord_iso(Order.pred(A,y,r), r, j, Memrel(j));
   305        wellordered(M,A,r);  x \<in> A;  y \<in> A; M(A); M(r); M(f); M(g); M(j);
   306        Ord(i); Ord(j); \<langle>x,y\<rangle> \<in> r |]
   307       ==> i < j"
   308 apply (frule wellordered_is_trans_on, assumption)
   309 apply (frule_tac y=y in transM, assumption) 
   310 apply (rule_tac i=i and j=j in Ord_linear_lt, auto)  
   311 txt{*case @{term "i=j"} yields a contradiction*}
   312  apply (rule_tac x1=x and A1="Order.pred(A,y,r)" in 
   313           wellordered_iso_predD [THEN notE]) 
   314    apply (blast intro: wellordered_subset [OF _ pred_subset]) 
   315   apply (simp add: trans_pred_pred_eq)
   316   apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans) 
   317  apply (simp_all add: pred_iff pred_closed converse_closed comp_closed)
   318 txt{*case @{term "j<i"} also yields a contradiction*}
   319 apply (frule restrict_ord_iso2, assumption+) 
   320 apply (frule ord_iso_sym [THEN ord_iso_is_bij, THEN bij_is_fun]) 
   321 apply (frule apply_type, blast intro: ltD) 
   322   --{*thus @{term "converse(f)`j \<in> Order.pred(A,x,r)"}*}
   323 apply (simp add: pred_iff) 
   324 apply (subgoal_tac
   325        "\<exists>h[M]. h \<in> ord_iso(Order.pred(A,y,r), r, 
   326                                Order.pred(A, converse(f)`j, r), r)")
   327  apply (clarify, frule wellordered_iso_pred_eq, assumption+)
   328  apply (blast dest: wellordered_asym)  
   329 apply (intro rexI)
   330  apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans)+
   331 done
   332 
   333 
   334 lemma ord_iso_converse1:
   335      "[| f: ord_iso(A,r,B,s);  <b, f`a>: s;  a:A;  b:B |] 
   336       ==> <converse(f) ` b, a> : r"
   337 apply (frule ord_iso_converse, assumption+) 
   338 apply (blast intro: ord_iso_is_bij [THEN bij_is_fun, THEN apply_funtype]) 
   339 apply (simp add: left_inverse_bij [OF ord_iso_is_bij])
   340 done
   341 
   342 
   343 subsection {* Order Types: A Direct Construction by Replacement*}
   344 
   345 text{*This follows Kunen's Theorem I 7.6, page 17.*}
   346 
   347 constdefs
   348   
   349   obase :: "[i=>o,i,i,i] => o"
   350        --{*the domain of @{text om}, eventually shown to equal @{text A}*}
   351    "obase(M,A,r,z) == 
   352 	\<forall>a[M]. 
   353          a \<in> z <-> 
   354           (a\<in>A & (\<exists>x[M]. \<exists>g[M]. \<exists>mx[M]. \<exists>par[M]. 
   355                    ordinal(M,x) & membership(M,x,mx) & pred_set(M,A,a,r,par) &
   356                    order_isomorphism(M,par,r,x,mx,g)))"
   357 
   358 
   359   omap :: "[i=>o,i,i,i] => o"  
   360     --{*the function that maps wosets to order types*}
   361    "omap(M,A,r,f) == 
   362 	\<forall>z[M].
   363          z \<in> f <-> 
   364           (\<exists>a[M]. a\<in>A & 
   365            (\<exists>x[M]. \<exists>g[M]. \<exists>mx[M]. \<exists>par[M]. 
   366                 ordinal(M,x) & pair(M,a,x,z) & membership(M,x,mx) & 
   367                 pred_set(M,A,a,r,par) & order_isomorphism(M,par,r,x,mx,g)))"
   368 
   369 
   370   otype :: "[i=>o,i,i,i] => o"  --{*the order types themselves*}
   371    "otype(M,A,r,i) == \<exists>f[M]. omap(M,A,r,f) & is_range(M,f,i)"
   372 
   373 
   374 
   375 lemma (in M_axioms) obase_iff:
   376      "[| M(A); M(r); M(z) |] 
   377       ==> obase(M,A,r,z) <-> 
   378           z = {a\<in>A. \<exists>x[M]. \<exists>g[M]. Ord(x) & 
   379                           g \<in> ord_iso(Order.pred(A,a,r),r,x,Memrel(x))}"
   380 apply (simp add: obase_def Memrel_closed pred_closed)
   381 apply (rule iffI) 
   382  prefer 2 apply blast 
   383 apply (rule equalityI) 
   384  apply (clarify, frule transM, assumption, rotate_tac -1, simp) 
   385 apply (clarify, frule transM, assumption, force)
   386 done
   387 
   388 text{*Can also be proved with the premise @{term "M(z)"} instead of
   389       @{term "M(f)"}, but that version is less useful.*}
   390 lemma (in M_axioms) omap_iff:
   391      "[| omap(M,A,r,f); M(A); M(r); M(f) |] 
   392       ==> z \<in> f <->
   393       (\<exists>a\<in>A. \<exists>x[M]. \<exists>g[M]. z = <a,x> & Ord(x) & 
   394                         g \<in> ord_iso(Order.pred(A,a,r),r,x,Memrel(x)))"
   395 apply (rotate_tac 1) 
   396 apply (simp add: omap_def Memrel_closed pred_closed) 
   397 apply (rule iffI)
   398  apply (drule_tac [2] x=z in rspec)
   399  apply (drule_tac x=z in rspec)
   400  apply (blast dest: transM)+
   401 done
   402 
   403 lemma (in M_axioms) omap_unique:
   404      "[| omap(M,A,r,f); omap(M,A,r,f'); M(A); M(r); M(f); M(f') |] ==> f' = f" 
   405 apply (rule equality_iffI) 
   406 apply (simp add: omap_iff) 
   407 done
   408 
   409 lemma (in M_axioms) omap_yields_Ord:
   410      "[| omap(M,A,r,f); \<langle>a,x\<rangle> \<in> f; M(a); M(x) |]  ==> Ord(x)"
   411 apply (simp add: omap_def, blast) 
   412 done
   413 
   414 lemma (in M_axioms) otype_iff:
   415      "[| otype(M,A,r,i); M(A); M(r); M(i) |] 
   416       ==> x \<in> i <-> 
   417           (M(x) & Ord(x) & 
   418            (\<exists>a\<in>A. \<exists>g[M]. g \<in> ord_iso(Order.pred(A,a,r),r,x,Memrel(x))))"
   419 apply (auto simp add: omap_iff otype_def)
   420  apply (blast intro: transM) 
   421 apply (rule rangeI) 
   422 apply (frule transM, assumption)
   423 apply (simp add: omap_iff, blast)
   424 done
   425 
   426 lemma (in M_axioms) otype_eq_range:
   427      "[| omap(M,A,r,f); otype(M,A,r,i); M(A); M(r); M(f); M(i) |] 
   428       ==> i = range(f)"
   429 apply (auto simp add: otype_def omap_iff)
   430 apply (blast dest: omap_unique) 
   431 done
   432 
   433 
   434 lemma (in M_axioms) Ord_otype:
   435      "[| otype(M,A,r,i); trans[A](r); M(A); M(r); M(i) |] ==> Ord(i)"
   436 apply (rotate_tac 1) 
   437 apply (rule OrdI) 
   438 prefer 2 
   439     apply (simp add: Ord_def otype_def omap_def) 
   440     apply clarify 
   441     apply (frule pair_components_in_M, assumption) 
   442     apply blast 
   443 apply (auto simp add: Transset_def otype_iff) 
   444   apply (blast intro: transM)
   445  apply (blast intro: Ord_in_Ord) 
   446 apply (rename_tac y a g)
   447 apply (frule ord_iso_sym [THEN ord_iso_is_bij, THEN bij_is_fun, 
   448 			  THEN apply_funtype],  assumption)  
   449 apply (rule_tac x="converse(g)`y" in bexI)
   450  apply (frule_tac a="converse(g) ` y" in ord_iso_restrict_pred, assumption) 
   451 apply (safe elim!: predE) 
   452 apply (blast intro: restrict_ord_iso ord_iso_sym ltI dest: transM)
   453 done
   454 
   455 lemma (in M_axioms) domain_omap:
   456      "[| omap(M,A,r,f);  obase(M,A,r,B); M(A); M(r); M(B); M(f) |] 
   457       ==> domain(f) = B"
   458 apply (rotate_tac 2) 
   459 apply (simp add: domain_closed obase_iff) 
   460 apply (rule equality_iffI) 
   461 apply (simp add: domain_iff omap_iff, blast) 
   462 done
   463 
   464 lemma (in M_axioms) omap_subset: 
   465      "[| omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   466        M(A); M(r); M(f); M(B); M(i) |] ==> f \<subseteq> B * i"
   467 apply (rotate_tac 3, clarify) 
   468 apply (simp add: omap_iff obase_iff) 
   469 apply (force simp add: otype_iff) 
   470 done
   471 
   472 lemma (in M_axioms) omap_funtype: 
   473      "[| omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   474        M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> B -> i"
   475 apply (rotate_tac 3) 
   476 apply (simp add: domain_omap omap_subset Pi_iff function_def omap_iff) 
   477 apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans) 
   478 done
   479 
   480 
   481 lemma (in M_axioms) wellordered_omap_bij:
   482      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   483        M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> bij(B,i)"
   484 apply (insert omap_funtype [of A r f B i]) 
   485 apply (auto simp add: bij_def inj_def) 
   486 prefer 2  apply (blast intro: fun_is_surj dest: otype_eq_range) 
   487 apply (frule_tac a=w in apply_Pair, assumption) 
   488 apply (frule_tac a=x in apply_Pair, assumption) 
   489 apply (simp add: omap_iff) 
   490 apply (blast intro: wellordered_iso_pred_eq ord_iso_sym ord_iso_trans) 
   491 done
   492 
   493 
   494 text{*This is not the final result: we must show @{term "oB(A,r) = A"}*}
   495 lemma (in M_axioms) omap_ord_iso:
   496      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   497        M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> ord_iso(B,r,i,Memrel(i))"
   498 apply (rule ord_isoI)
   499  apply (erule wellordered_omap_bij, assumption+) 
   500 apply (insert omap_funtype [of A r f B i], simp) 
   501 apply (frule_tac a=x in apply_Pair, assumption) 
   502 apply (frule_tac a=y in apply_Pair, assumption) 
   503 apply (auto simp add: omap_iff)
   504  txt{*direction 1: assuming @{term "\<langle>x,y\<rangle> \<in> r"}*}
   505  apply (blast intro: ltD ord_iso_pred_imp_lt)
   506  txt{*direction 2: proving @{term "\<langle>x,y\<rangle> \<in> r"} using linearity of @{term r}*}
   507 apply (rename_tac x y g ga) 
   508 apply (frule wellordered_is_linear, assumption, 
   509        erule_tac x=x and y=y in linearE, assumption+) 
   510 txt{*the case @{term "x=y"} leads to immediate contradiction*} 
   511 apply (blast elim: mem_irrefl) 
   512 txt{*the case @{term "\<langle>y,x\<rangle> \<in> r"}: handle like the opposite direction*}
   513 apply (blast dest: ord_iso_pred_imp_lt ltD elim: mem_asym) 
   514 done
   515 
   516 lemma (in M_axioms) Ord_omap_image_pred:
   517      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   518        M(A); M(r); M(f); M(B); M(i); b \<in> A |] ==> Ord(f `` Order.pred(A,b,r))"
   519 apply (frule wellordered_is_trans_on, assumption)
   520 apply (rule OrdI) 
   521 	prefer 2 apply (simp add: image_iff omap_iff Ord_def, blast) 
   522 txt{*Hard part is to show that the image is a transitive set.*}
   523 apply (rotate_tac 3)
   524 apply (simp add: Transset_def, clarify) 
   525 apply (simp add: image_iff pred_iff apply_iff [OF omap_funtype [of A r f B i]])
   526 apply (rename_tac c j, clarify)
   527 apply (frule omap_funtype [of A r f B, THEN apply_funtype], assumption+)
   528 apply (subgoal_tac "j : i") 
   529 	prefer 2 apply (blast intro: Ord_trans Ord_otype)
   530 apply (subgoal_tac "converse(f) ` j : B") 
   531 	prefer 2 
   532 	apply (blast dest: wellordered_omap_bij [THEN bij_converse_bij, 
   533                                       THEN bij_is_fun, THEN apply_funtype])
   534 apply (rule_tac x="converse(f) ` j" in bexI) 
   535  apply (simp add: right_inverse_bij [OF wellordered_omap_bij]) 
   536 apply (intro predI conjI)
   537  apply (erule_tac b=c in trans_onD) 
   538  apply (rule ord_iso_converse1 [OF omap_ord_iso [of A r f B i]])
   539 apply (auto simp add: obase_iff)
   540 done
   541 
   542 lemma (in M_axioms) restrict_omap_ord_iso:
   543      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   544        D \<subseteq> B; M(A); M(r); M(f); M(B); M(i) |] 
   545       ==> restrict(f,D) \<in> (\<langle>D,r\<rangle> \<cong> \<langle>f``D, Memrel(f``D)\<rangle>)"
   546 apply (frule ord_iso_restrict_image [OF omap_ord_iso [of A r f B i]], 
   547        assumption+)
   548 apply (drule ord_iso_sym [THEN subset_ord_iso_Memrel]) 
   549 apply (blast dest: subsetD [OF omap_subset]) 
   550 apply (drule ord_iso_sym, simp) 
   551 done
   552 
   553 lemma (in M_axioms) obase_equals: 
   554      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
   555        M(A); M(r); M(f); M(B); M(i) |] ==> B = A"
   556 apply (rotate_tac 4)
   557 apply (rule equalityI, force simp add: obase_iff, clarify) 
   558 apply (subst obase_iff [of A r B, THEN iffD1], assumption+, simp) 
   559 apply (frule wellordered_is_wellfounded_on, assumption)
   560 apply (erule wellfounded_on_induct, assumption+)
   561  apply (frule obase_equals_separation [of A r], assumption) 
   562  apply (simp, clarify) 
   563 apply (rename_tac b) 
   564 apply (subgoal_tac "Order.pred(A,b,r) <= B") 
   565  apply (blast intro!: restrict_omap_ord_iso Ord_omap_image_pred)
   566 apply (force simp add: pred_iff obase_iff)  
   567 done
   568 
   569 
   570 
   571 text{*Main result: @{term om} gives the order-isomorphism 
   572       @{term "\<langle>A,r\<rangle> \<cong> \<langle>i, Memrel(i)\<rangle>"} *}
   573 theorem (in M_axioms) omap_ord_iso_otype:
   574      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
   575        M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> ord_iso(A, r, i, Memrel(i))"
   576 apply (frule omap_ord_iso, assumption+) 
   577 apply (frule obase_equals, assumption+, blast) 
   578 done 
   579 
   580 lemma (in M_axioms) obase_exists:
   581      "[| M(A); M(r) |] ==> \<exists>z[M]. obase(M,A,r,z)"
   582 apply (simp add: obase_def) 
   583 apply (insert obase_separation [of A r])
   584 apply (simp add: separation_def)  
   585 done
   586 
   587 lemma (in M_axioms) omap_exists:
   588      "[| M(A); M(r) |] ==> \<exists>z[M]. omap(M,A,r,z)"
   589 apply (insert obase_exists [of A r]) 
   590 apply (simp add: omap_def) 
   591 apply (insert omap_replacement [of A r])
   592 apply (simp add: strong_replacement_def, clarify) 
   593 apply (drule_tac x=x in rspec, clarify) 
   594 apply (simp add: Memrel_closed pred_closed obase_iff)
   595 apply (erule impE) 
   596  apply (clarsimp simp add: univalent_def)
   597  apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans, clarify)  
   598 apply (rule_tac x=Y in rexI) 
   599 apply (simp add: Memrel_closed pred_closed obase_iff, blast, assumption)
   600 done
   601 
   602 declare rall_simps [simp] rex_simps [simp]
   603 
   604 lemma (in M_axioms) otype_exists:
   605      "[| wellordered(M,A,r); M(A); M(r) |] ==> \<exists>i[M]. otype(M,A,r,i)"
   606 apply (insert omap_exists [of A r])  
   607 apply (simp add: otype_def, safe)
   608 apply (rule_tac x="range(x)" in rexI) 
   609 apply blast+
   610 done
   611 
   612 theorem (in M_axioms) omap_ord_iso_otype':
   613      "[| wellordered(M,A,r); M(A); M(r) |]
   614       ==> \<exists>f[M]. (\<exists>i[M]. Ord(i) & f \<in> ord_iso(A, r, i, Memrel(i)))"
   615 apply (insert obase_exists [of A r] omap_exists [of A r] otype_exists [of A r], simp, clarify)
   616 apply (rename_tac i) 
   617 apply (subgoal_tac "Ord(i)", blast intro: omap_ord_iso_otype) 
   618 apply (rule Ord_otype) 
   619     apply (force simp add: otype_def range_closed) 
   620    apply (simp_all add: wellordered_is_trans_on) 
   621 done
   622 
   623 lemma (in M_axioms) ordertype_exists:
   624      "[| wellordered(M,A,r); M(A); M(r) |]
   625       ==> \<exists>f[M]. (\<exists>i[M]. Ord(i) & f \<in> ord_iso(A, r, i, Memrel(i)))"
   626 apply (insert obase_exists [of A r] omap_exists [of A r] otype_exists [of A r], simp, clarify)
   627 apply (rename_tac i) 
   628 apply (subgoal_tac "Ord(i)", blast intro: omap_ord_iso_otype')
   629 apply (rule Ord_otype) 
   630     apply (force simp add: otype_def range_closed) 
   631    apply (simp_all add: wellordered_is_trans_on) 
   632 done
   633 
   634 
   635 lemma (in M_axioms) relativized_imp_well_ord: 
   636      "[| wellordered(M,A,r); M(A); M(r) |] ==> well_ord(A,r)" 
   637 apply (insert ordertype_exists [of A r], simp)
   638 apply (blast intro: well_ord_ord_iso well_ord_Memrel)  
   639 done
   640 
   641 subsection {*Kunen's theorem 5.4, poage 127*}
   642 
   643 text{*(a) The notion of Wellordering is absolute*}
   644 theorem (in M_axioms) well_ord_abs [simp]: 
   645      "[| M(A); M(r) |] ==> wellordered(M,A,r) <-> well_ord(A,r)" 
   646 by (blast intro: well_ord_imp_relativized relativized_imp_well_ord)  
   647 
   648 
   649 text{*(b) Order types are absolute*}
   650 lemma (in M_axioms) 
   651      "[| wellordered(M,A,r); f \<in> ord_iso(A, r, i, Memrel(i));
   652        M(A); M(r); M(f); M(i); Ord(i) |] ==> i = ordertype(A,r)"
   653 by (blast intro: Ord_ordertype relativized_imp_well_ord ordertype_ord_iso
   654                  Ord_iso_implies_eq ord_iso_sym ord_iso_trans)
   655 
   656 end