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