src/ZF/Constructible/Wellorderings.thy
author berghofe
Mon Sep 30 16:47:03 2002 +0200 (2002-09-30)
changeset 13611 2edf034c902a
parent 13564 1500a2e48d44
child 13615 449a70d88b38
permissions -rw-r--r--
Adapted to new simplifier.
     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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) 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_basic) omap_yields_Ord:
   410      "[| omap(M,A,r,f); \<langle>a,x\<rangle> \<in> f; M(a); M(x) |]  ==> Ord(x)"
   411   by (simp add: omap_def)
   412 
   413 lemma (in M_basic) otype_iff:
   414      "[| otype(M,A,r,i); M(A); M(r); M(i) |] 
   415       ==> x \<in> i <-> 
   416           (M(x) & Ord(x) & 
   417            (\<exists>a\<in>A. \<exists>g[M]. g \<in> ord_iso(Order.pred(A,a,r),r,x,Memrel(x))))"
   418 apply (auto simp add: omap_iff otype_def)
   419  apply (blast intro: transM) 
   420 apply (rule rangeI) 
   421 apply (frule transM, assumption)
   422 apply (simp add: omap_iff, blast)
   423 done
   424 
   425 lemma (in M_basic) otype_eq_range:
   426      "[| omap(M,A,r,f); otype(M,A,r,i); M(A); M(r); M(f); M(i) |] 
   427       ==> i = range(f)"
   428 apply (auto simp add: otype_def omap_iff)
   429 apply (blast dest: omap_unique) 
   430 done
   431 
   432 
   433 lemma (in M_basic) Ord_otype:
   434      "[| otype(M,A,r,i); trans[A](r); M(A); M(r); M(i) |] ==> Ord(i)"
   435 apply (rotate_tac 1) 
   436 apply (rule OrdI) 
   437 prefer 2 
   438     apply (simp add: Ord_def otype_def omap_def) 
   439     apply clarify 
   440     apply (frule pair_components_in_M, assumption) 
   441     apply blast 
   442 apply (auto simp add: Transset_def otype_iff) 
   443   apply (blast intro: transM)
   444  apply (blast intro: Ord_in_Ord) 
   445 apply (rename_tac y a g)
   446 apply (frule ord_iso_sym [THEN ord_iso_is_bij, THEN bij_is_fun, 
   447 			  THEN apply_funtype],  assumption)  
   448 apply (rule_tac x="converse(g)`y" in bexI)
   449  apply (frule_tac a="converse(g) ` y" in ord_iso_restrict_pred, assumption) 
   450 apply (safe elim!: predE) 
   451 apply (blast intro: restrict_ord_iso ord_iso_sym ltI dest: transM)
   452 done
   453 
   454 lemma (in M_basic) domain_omap:
   455      "[| omap(M,A,r,f);  obase(M,A,r,B); M(A); M(r); M(B); M(f) |] 
   456       ==> domain(f) = B"
   457 apply (rotate_tac 2) 
   458 apply (simp add: domain_closed obase_iff) 
   459 apply (rule equality_iffI) 
   460 apply (simp add: domain_iff omap_iff, blast) 
   461 done
   462 
   463 lemma (in M_basic) omap_subset: 
   464      "[| omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   465        M(A); M(r); M(f); M(B); M(i) |] ==> f \<subseteq> B * i"
   466 apply (rotate_tac 3, clarify) 
   467 apply (simp add: omap_iff obase_iff) 
   468 apply (force simp add: otype_iff) 
   469 done
   470 
   471 lemma (in M_basic) omap_funtype: 
   472      "[| omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   473        M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> B -> i"
   474 apply (rotate_tac 3) 
   475 apply (simp add: domain_omap omap_subset Pi_iff function_def omap_iff) 
   476 apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans) 
   477 done
   478 
   479 
   480 lemma (in M_basic) wellordered_omap_bij:
   481      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   482        M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> bij(B,i)"
   483 apply (insert omap_funtype [of A r f B i]) 
   484 apply (auto simp add: bij_def inj_def) 
   485 prefer 2  apply (blast intro: fun_is_surj dest: otype_eq_range) 
   486 apply (frule_tac a=w in apply_Pair, assumption) 
   487 apply (frule_tac a=x in apply_Pair, assumption) 
   488 apply (simp add: omap_iff) 
   489 apply (blast intro: wellordered_iso_pred_eq ord_iso_sym ord_iso_trans) 
   490 done
   491 
   492 
   493 text{*This is not the final result: we must show @{term "oB(A,r) = A"}*}
   494 lemma (in M_basic) omap_ord_iso:
   495      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   496        M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> ord_iso(B,r,i,Memrel(i))"
   497 apply (rule ord_isoI)
   498  apply (erule wellordered_omap_bij, assumption+) 
   499 apply (insert omap_funtype [of A r f B i], simp) 
   500 apply (frule_tac a=x in apply_Pair, assumption) 
   501 apply (frule_tac a=y in apply_Pair, assumption) 
   502 apply (auto simp add: omap_iff)
   503  txt{*direction 1: assuming @{term "\<langle>x,y\<rangle> \<in> r"}*}
   504  apply (blast intro: ltD ord_iso_pred_imp_lt)
   505  txt{*direction 2: proving @{term "\<langle>x,y\<rangle> \<in> r"} using linearity of @{term r}*}
   506 apply (rename_tac x y g ga) 
   507 apply (frule wellordered_is_linear, assumption, 
   508        erule_tac x=x and y=y in linearE, assumption+) 
   509 txt{*the case @{term "x=y"} leads to immediate contradiction*} 
   510 apply (blast elim: mem_irrefl) 
   511 txt{*the case @{term "\<langle>y,x\<rangle> \<in> r"}: handle like the opposite direction*}
   512 apply (blast dest: ord_iso_pred_imp_lt ltD elim: mem_asym) 
   513 done
   514 
   515 lemma (in M_basic) Ord_omap_image_pred:
   516      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   517        M(A); M(r); M(f); M(B); M(i); b \<in> A |] ==> Ord(f `` Order.pred(A,b,r))"
   518 apply (frule wellordered_is_trans_on, assumption)
   519 apply (rule OrdI) 
   520 	prefer 2 apply (simp add: image_iff omap_iff Ord_def, blast) 
   521 txt{*Hard part is to show that the image is a transitive set.*}
   522 apply (rotate_tac 3)
   523 apply (simp add: Transset_def, clarify) 
   524 apply (simp add: image_iff pred_iff apply_iff [OF omap_funtype [of A r f B i]])
   525 apply (rename_tac c j, clarify)
   526 apply (frule omap_funtype [of A r f B, THEN apply_funtype], assumption+)
   527 apply (subgoal_tac "j : i") 
   528 	prefer 2 apply (blast intro: Ord_trans Ord_otype)
   529 apply (subgoal_tac "converse(f) ` j : B") 
   530 	prefer 2 
   531 	apply (blast dest: wellordered_omap_bij [THEN bij_converse_bij, 
   532                                       THEN bij_is_fun, THEN apply_funtype])
   533 apply (rule_tac x="converse(f) ` j" in bexI) 
   534  apply (simp add: right_inverse_bij [OF wellordered_omap_bij]) 
   535 apply (intro predI conjI)
   536  apply (erule_tac b=c in trans_onD) 
   537  apply (rule ord_iso_converse1 [OF omap_ord_iso [of A r f B i]])
   538 apply (auto simp add: obase_iff)
   539 done
   540 
   541 lemma (in M_basic) restrict_omap_ord_iso:
   542      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i); 
   543        D \<subseteq> B; M(A); M(r); M(f); M(B); M(i) |] 
   544       ==> restrict(f,D) \<in> (\<langle>D,r\<rangle> \<cong> \<langle>f``D, Memrel(f``D)\<rangle>)"
   545 apply (frule ord_iso_restrict_image [OF omap_ord_iso [of A r f B i]], 
   546        assumption+)
   547 apply (drule ord_iso_sym [THEN subset_ord_iso_Memrel]) 
   548 apply (blast dest: subsetD [OF omap_subset]) 
   549 apply (drule ord_iso_sym, simp) 
   550 done
   551 
   552 lemma (in M_basic) obase_equals: 
   553      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
   554        M(A); M(r); M(f); M(B); M(i) |] ==> B = A"
   555 apply (rotate_tac 4)
   556 apply (rule equalityI, force simp add: obase_iff, clarify) 
   557 apply (subst obase_iff [of A r B, THEN iffD1], assumption+, simp) 
   558 apply (frule wellordered_is_wellfounded_on, assumption)
   559 apply (erule wellfounded_on_induct, assumption+)
   560  apply (frule obase_equals_separation [of A r], assumption) 
   561  apply (simp, clarify) 
   562 apply (rename_tac b) 
   563 apply (subgoal_tac "Order.pred(A,b,r) <= B") 
   564  apply (blast intro!: restrict_omap_ord_iso Ord_omap_image_pred)
   565 apply (force simp add: pred_iff obase_iff)  
   566 done
   567 
   568 
   569 
   570 text{*Main result: @{term om} gives the order-isomorphism 
   571       @{term "\<langle>A,r\<rangle> \<cong> \<langle>i, Memrel(i)\<rangle>"} *}
   572 theorem (in M_basic) omap_ord_iso_otype:
   573      "[| wellordered(M,A,r); omap(M,A,r,f); obase(M,A,r,B); otype(M,A,r,i);
   574        M(A); M(r); M(f); M(B); M(i) |] ==> f \<in> ord_iso(A, r, i, Memrel(i))"
   575 apply (frule omap_ord_iso, assumption+) 
   576 apply (frule obase_equals, assumption+, blast) 
   577 done 
   578 
   579 lemma (in M_basic) obase_exists:
   580      "[| M(A); M(r) |] ==> \<exists>z[M]. obase(M,A,r,z)"
   581 apply (simp add: obase_def) 
   582 apply (insert obase_separation [of A r])
   583 apply (simp add: separation_def)  
   584 done
   585 
   586 lemma (in M_basic) omap_exists:
   587      "[| M(A); M(r) |] ==> \<exists>z[M]. omap(M,A,r,z)"
   588 apply (insert obase_exists [of A r]) 
   589 apply (simp add: omap_def) 
   590 apply (insert omap_replacement [of A r])
   591 apply (simp add: strong_replacement_def, clarify) 
   592 apply (drule_tac x=x in rspec, clarify) 
   593 apply (simp add: Memrel_closed pred_closed obase_iff)
   594 apply (erule impE) 
   595  apply (clarsimp simp add: univalent_def)
   596  apply (blast intro: Ord_iso_implies_eq ord_iso_sym ord_iso_trans, clarify)  
   597 apply (rule_tac x=Y in rexI) 
   598 apply (simp add: Memrel_closed pred_closed obase_iff, blast, assumption)
   599 done
   600 
   601 declare rall_simps [simp] rex_simps [simp]
   602 
   603 lemma (in M_basic) otype_exists:
   604      "[| wellordered(M,A,r); M(A); M(r) |] ==> \<exists>i[M]. otype(M,A,r,i)"
   605 apply (insert omap_exists [of A r])  
   606 apply (simp add: otype_def, safe)
   607 apply (rule_tac x="range(x)" in rexI) 
   608 apply blast+
   609 done
   610 
   611 theorem (in M_basic) omap_ord_iso_otype':
   612      "[| wellordered(M,A,r); M(A); M(r) |]
   613       ==> \<exists>f[M]. (\<exists>i[M]. Ord(i) & f \<in> ord_iso(A, r, i, Memrel(i)))"
   614 apply (insert obase_exists [of A r] omap_exists [of A r] otype_exists [of A r], simp, clarify)
   615 apply (rename_tac i) 
   616 apply (subgoal_tac "Ord(i)", blast intro: omap_ord_iso_otype) 
   617 apply (rule Ord_otype) 
   618     apply (force simp add: otype_def range_closed) 
   619    apply (simp_all add: wellordered_is_trans_on) 
   620 done
   621 
   622 lemma (in M_basic) ordertype_exists:
   623      "[| wellordered(M,A,r); M(A); M(r) |]
   624       ==> \<exists>f[M]. (\<exists>i[M]. Ord(i) & f \<in> ord_iso(A, r, i, Memrel(i)))"
   625 apply (insert obase_exists [of A r] omap_exists [of A r] otype_exists [of A r], simp, clarify)
   626 apply (rename_tac i) 
   627 apply (subgoal_tac "Ord(i)", blast intro: omap_ord_iso_otype')
   628 apply (rule Ord_otype) 
   629     apply (force simp add: otype_def range_closed) 
   630    apply (simp_all add: wellordered_is_trans_on) 
   631 done
   632 
   633 
   634 lemma (in M_basic) relativized_imp_well_ord: 
   635      "[| wellordered(M,A,r); M(A); M(r) |] ==> well_ord(A,r)" 
   636 apply (insert ordertype_exists [of A r], simp)
   637 apply (blast intro: well_ord_ord_iso well_ord_Memrel)  
   638 done
   639 
   640 subsection {*Kunen's theorem 5.4, poage 127*}
   641 
   642 text{*(a) The notion of Wellordering is absolute*}
   643 theorem (in M_basic) well_ord_abs [simp]: 
   644      "[| M(A); M(r) |] ==> wellordered(M,A,r) <-> well_ord(A,r)" 
   645 by (blast intro: well_ord_imp_relativized relativized_imp_well_ord)  
   646 
   647 
   648 text{*(b) Order types are absolute*}
   649 lemma (in M_basic) 
   650      "[| wellordered(M,A,r); f \<in> ord_iso(A, r, i, Memrel(i));
   651        M(A); M(r); M(f); M(i); Ord(i) |] ==> i = ordertype(A,r)"
   652 by (blast intro: Ord_ordertype relativized_imp_well_ord ordertype_ord_iso
   653                  Ord_iso_implies_eq ord_iso_sym ord_iso_trans)
   654 
   655 end