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