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