src/ZF/Order.thy
author wenzelm
Sun Oct 07 21:19:31 2007 +0200 (2007-10-07)
changeset 24893 b8ef7afe3a6b
parent 16417 9bc16273c2d4
child 27703 cb6c513922e0
permissions -rw-r--r--
modernized specifications;
removed legacy ML bindings;
clasohm@1478
     1
(*  Title:      ZF/Order.thy
lcp@435
     2
    ID:         $Id$
clasohm@1478
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
lcp@435
     4
    Copyright   1994  University of Cambridge
lcp@435
     5
paulson@13140
     6
Results from the book "Set Theory: an Introduction to Independence Proofs"
paulson@13140
     7
        by Kenneth Kunen.  Chapter 1, section 6.
lcp@435
     8
*)
lcp@435
     9
paulson@13356
    10
header{*Partial and Total Orderings: Basic Definitions and Properties*}
paulson@13356
    11
haftmann@16417
    12
theory Order imports WF Perm begin
lcp@786
    13
wenzelm@24893
    14
definition
wenzelm@24893
    15
  part_ord :: "[i,i]=>o"          	(*Strict partial ordering*)  where
paulson@13140
    16
   "part_ord(A,r) == irrefl(A,r) & trans[A](r)"
paulson@13140
    17
wenzelm@24893
    18
definition
wenzelm@24893
    19
  linear   :: "[i,i]=>o"          	(*Strict total ordering*)  where
paulson@13140
    20
   "linear(A,r) == (ALL x:A. ALL y:A. <x,y>:r | x=y | <y,x>:r)"
paulson@13140
    21
wenzelm@24893
    22
definition
wenzelm@24893
    23
  tot_ord  :: "[i,i]=>o"          	(*Strict total ordering*)  where
paulson@13140
    24
   "tot_ord(A,r) == part_ord(A,r) & linear(A,r)"
paulson@13140
    25
wenzelm@24893
    26
definition
wenzelm@24893
    27
  well_ord :: "[i,i]=>o"          	(*Well-ordering*)  where
paulson@13140
    28
   "well_ord(A,r) == tot_ord(A,r) & wf[A](r)"
paulson@13140
    29
wenzelm@24893
    30
definition
wenzelm@24893
    31
  mono_map :: "[i,i,i,i]=>i"      	(*Order-preserving maps*)  where
paulson@13140
    32
   "mono_map(A,r,B,s) ==
paulson@13140
    33
	      {f: A->B. ALL x:A. ALL y:A. <x,y>:r --> <f`x,f`y>:s}"
paulson@13140
    34
wenzelm@24893
    35
definition
wenzelm@24893
    36
  ord_iso  :: "[i,i,i,i]=>i"		(*Order isomorphisms*)  where
paulson@13140
    37
   "ord_iso(A,r,B,s) ==
paulson@13140
    38
	      {f: bij(A,B). ALL x:A. ALL y:A. <x,y>:r <-> <f`x,f`y>:s}"
paulson@13140
    39
wenzelm@24893
    40
definition
wenzelm@24893
    41
  pred     :: "[i,i,i]=>i"		(*Set of predecessors*)  where
paulson@13140
    42
   "pred(A,x,r) == {y:A. <y,x>:r}"
paulson@13140
    43
wenzelm@24893
    44
definition
wenzelm@24893
    45
  ord_iso_map :: "[i,i,i,i]=>i"      	(*Construction for linearity theorem*)  where
paulson@13140
    46
   "ord_iso_map(A,r,B,s) ==
paulson@13615
    47
     \<Union>x\<in>A. \<Union>y\<in>B. \<Union>f \<in> ord_iso(pred(A,x,r), r, pred(B,y,s), s). {<x,y>}"
paulson@13140
    48
wenzelm@24893
    49
definition
wenzelm@24893
    50
  first :: "[i, i, i] => o"  where
paulson@2469
    51
    "first(u, X, R) == u:X & (ALL v:X. v~=u --> <u,v> : R)"
paulson@2469
    52
paulson@13140
    53
wenzelm@24893
    54
notation (xsymbols)
wenzelm@24893
    55
  ord_iso  ("(\<langle>_, _\<rangle> \<cong>/ \<langle>_, _\<rangle>)" 51)
paulson@13140
    56
paulson@13140
    57
paulson@13356
    58
subsection{*Immediate Consequences of the Definitions*}
paulson@13140
    59
paulson@13140
    60
lemma part_ord_Imp_asym:
paulson@13140
    61
    "part_ord(A,r) ==> asym(r Int A*A)"
paulson@13140
    62
by (unfold part_ord_def irrefl_def trans_on_def asym_def, blast)
paulson@13140
    63
paulson@13140
    64
lemma linearE:
paulson@13140
    65
    "[| linear(A,r);  x:A;  y:A;
paulson@13140
    66
        <x,y>:r ==> P;  x=y ==> P;  <y,x>:r ==> P |]
paulson@13140
    67
     ==> P"
paulson@13140
    68
by (simp add: linear_def, blast)
paulson@13140
    69
paulson@13140
    70
paulson@13140
    71
(** General properties of well_ord **)
paulson@13140
    72
paulson@13140
    73
lemma well_ordI:
paulson@13140
    74
    "[| wf[A](r); linear(A,r) |] ==> well_ord(A,r)"
paulson@13140
    75
apply (simp add: irrefl_def part_ord_def tot_ord_def
paulson@13140
    76
                 trans_on_def well_ord_def wf_on_not_refl)
paulson@13140
    77
apply (fast elim: linearE wf_on_asym wf_on_chain3)
paulson@13140
    78
done
paulson@13140
    79
paulson@13140
    80
lemma well_ord_is_wf:
paulson@13140
    81
    "well_ord(A,r) ==> wf[A](r)"
paulson@13140
    82
by (unfold well_ord_def, safe)
paulson@13140
    83
paulson@13140
    84
lemma well_ord_is_trans_on:
paulson@13140
    85
    "well_ord(A,r) ==> trans[A](r)"
paulson@13140
    86
by (unfold well_ord_def tot_ord_def part_ord_def, safe)
paulson@13140
    87
paulson@13140
    88
lemma well_ord_is_linear: "well_ord(A,r) ==> linear(A,r)"
paulson@13140
    89
by (unfold well_ord_def tot_ord_def, blast)
paulson@13140
    90
paulson@13140
    91
paulson@13140
    92
(** Derived rules for pred(A,x,r) **)
paulson@13140
    93
paulson@13140
    94
lemma pred_iff: "y : pred(A,x,r) <-> <y,x>:r & y:A"
paulson@13140
    95
by (unfold pred_def, blast)
paulson@13140
    96
paulson@13140
    97
lemmas predI = conjI [THEN pred_iff [THEN iffD2]]
paulson@13140
    98
paulson@13140
    99
lemma predE: "[| y: pred(A,x,r);  [| y:A; <y,x>:r |] ==> P |] ==> P"
paulson@13140
   100
by (simp add: pred_def)
paulson@13140
   101
paulson@13140
   102
lemma pred_subset_under: "pred(A,x,r) <= r -`` {x}"
paulson@13140
   103
by (simp add: pred_def, blast)
paulson@13140
   104
paulson@13140
   105
lemma pred_subset: "pred(A,x,r) <= A"
paulson@13140
   106
by (simp add: pred_def, blast)
paulson@13140
   107
paulson@13140
   108
lemma pred_pred_eq:
paulson@13140
   109
    "pred(pred(A,x,r), y, r) = pred(A,x,r) Int pred(A,y,r)"
paulson@13140
   110
by (simp add: pred_def, blast)
paulson@13140
   111
paulson@13140
   112
lemma trans_pred_pred_eq:
paulson@13140
   113
    "[| trans[A](r);  <y,x>:r;  x:A;  y:A |]
paulson@13140
   114
     ==> pred(pred(A,x,r), y, r) = pred(A,y,r)"
paulson@13140
   115
by (unfold trans_on_def pred_def, blast)
paulson@13140
   116
paulson@13140
   117
paulson@13356
   118
subsection{*Restricting an Ordering's Domain*}
paulson@13356
   119
paulson@13140
   120
(** The ordering's properties hold over all subsets of its domain
paulson@13140
   121
    [including initial segments of the form pred(A,x,r) **)
paulson@13140
   122
paulson@13140
   123
(*Note: a relation s such that s<=r need not be a partial ordering*)
paulson@13140
   124
lemma part_ord_subset:
paulson@13140
   125
    "[| part_ord(A,r);  B<=A |] ==> part_ord(B,r)"
paulson@13140
   126
by (unfold part_ord_def irrefl_def trans_on_def, blast)
paulson@13140
   127
paulson@13140
   128
lemma linear_subset:
paulson@13140
   129
    "[| linear(A,r);  B<=A |] ==> linear(B,r)"
paulson@13140
   130
by (unfold linear_def, blast)
paulson@13140
   131
paulson@13140
   132
lemma tot_ord_subset:
paulson@13140
   133
    "[| tot_ord(A,r);  B<=A |] ==> tot_ord(B,r)"
paulson@13140
   134
apply (unfold tot_ord_def)
paulson@13140
   135
apply (fast elim!: part_ord_subset linear_subset)
paulson@13140
   136
done
paulson@13140
   137
paulson@13140
   138
lemma well_ord_subset:
paulson@13140
   139
    "[| well_ord(A,r);  B<=A |] ==> well_ord(B,r)"
paulson@13140
   140
apply (unfold well_ord_def)
paulson@13140
   141
apply (fast elim!: tot_ord_subset wf_on_subset_A)
paulson@13140
   142
done
paulson@13140
   143
paulson@13140
   144
paulson@13140
   145
(** Relations restricted to a smaller domain, by Krzysztof Grabczewski **)
paulson@13140
   146
paulson@13140
   147
lemma irrefl_Int_iff: "irrefl(A,r Int A*A) <-> irrefl(A,r)"
paulson@13140
   148
by (unfold irrefl_def, blast)
paulson@13140
   149
paulson@13140
   150
lemma trans_on_Int_iff: "trans[A](r Int A*A) <-> trans[A](r)"
paulson@13140
   151
by (unfold trans_on_def, blast)
paulson@13140
   152
paulson@13140
   153
lemma part_ord_Int_iff: "part_ord(A,r Int A*A) <-> part_ord(A,r)"
paulson@13140
   154
apply (unfold part_ord_def)
paulson@13140
   155
apply (simp add: irrefl_Int_iff trans_on_Int_iff)
paulson@13140
   156
done
paulson@13140
   157
paulson@13140
   158
lemma linear_Int_iff: "linear(A,r Int A*A) <-> linear(A,r)"
paulson@13140
   159
by (unfold linear_def, blast)
paulson@13140
   160
paulson@13140
   161
lemma tot_ord_Int_iff: "tot_ord(A,r Int A*A) <-> tot_ord(A,r)"
paulson@13140
   162
apply (unfold tot_ord_def)
paulson@13140
   163
apply (simp add: part_ord_Int_iff linear_Int_iff)
paulson@13140
   164
done
paulson@13140
   165
paulson@13140
   166
lemma wf_on_Int_iff: "wf[A](r Int A*A) <-> wf[A](r)"
wenzelm@24893
   167
apply (unfold wf_on_def wf_def, fast) (*10 times faster than blast!*)
paulson@13140
   168
done
paulson@13140
   169
paulson@13140
   170
lemma well_ord_Int_iff: "well_ord(A,r Int A*A) <-> well_ord(A,r)"
paulson@13140
   171
apply (unfold well_ord_def)
paulson@13140
   172
apply (simp add: tot_ord_Int_iff wf_on_Int_iff)
paulson@13140
   173
done
paulson@13140
   174
paulson@13140
   175
paulson@13356
   176
subsection{*Empty and Unit Domains*}
paulson@13356
   177
paulson@13701
   178
(*The empty relation is well-founded*)
paulson@13701
   179
lemma wf_on_any_0: "wf[A](0)"
paulson@13701
   180
by (simp add: wf_on_def wf_def, fast)
paulson@13701
   181
paulson@13701
   182
subsubsection{*Relations over the Empty Set*}
paulson@13140
   183
paulson@13140
   184
lemma irrefl_0: "irrefl(0,r)"
paulson@13140
   185
by (unfold irrefl_def, blast)
paulson@13140
   186
paulson@13140
   187
lemma trans_on_0: "trans[0](r)"
paulson@13140
   188
by (unfold trans_on_def, blast)
paulson@13140
   189
paulson@13140
   190
lemma part_ord_0: "part_ord(0,r)"
paulson@13140
   191
apply (unfold part_ord_def)
paulson@13140
   192
apply (simp add: irrefl_0 trans_on_0)
paulson@13140
   193
done
paulson@13140
   194
paulson@13140
   195
lemma linear_0: "linear(0,r)"
paulson@13140
   196
by (unfold linear_def, blast)
paulson@13140
   197
paulson@13140
   198
lemma tot_ord_0: "tot_ord(0,r)"
paulson@13140
   199
apply (unfold tot_ord_def)
paulson@13140
   200
apply (simp add: part_ord_0 linear_0)
paulson@13140
   201
done
paulson@13140
   202
paulson@13140
   203
lemma wf_on_0: "wf[0](r)"
paulson@13140
   204
by (unfold wf_on_def wf_def, blast)
paulson@13140
   205
paulson@13140
   206
lemma well_ord_0: "well_ord(0,r)"
paulson@13140
   207
apply (unfold well_ord_def)
paulson@13140
   208
apply (simp add: tot_ord_0 wf_on_0)
paulson@13140
   209
done
paulson@13140
   210
paulson@13140
   211
paulson@13701
   212
subsubsection{*The Empty Relation Well-Orders the Unit Set*}
paulson@13701
   213
paulson@13701
   214
text{*by Grabczewski*}
paulson@13140
   215
paulson@13140
   216
lemma tot_ord_unit: "tot_ord({a},0)"
paulson@13140
   217
by (simp add: irrefl_def trans_on_def part_ord_def linear_def tot_ord_def)
paulson@13140
   218
paulson@13140
   219
lemma well_ord_unit: "well_ord({a},0)"
paulson@13140
   220
apply (unfold well_ord_def)
paulson@13701
   221
apply (simp add: tot_ord_unit wf_on_any_0)
paulson@13140
   222
done
paulson@13140
   223
paulson@13140
   224
paulson@13356
   225
subsection{*Order-Isomorphisms*}
paulson@13356
   226
paulson@13356
   227
text{*Suppes calls them "similarities"*}
paulson@13356
   228
paulson@13140
   229
(** Order-preserving (monotone) maps **)
paulson@13140
   230
paulson@13140
   231
lemma mono_map_is_fun: "f: mono_map(A,r,B,s) ==> f: A->B"
paulson@13140
   232
by (simp add: mono_map_def)
paulson@13140
   233
paulson@13140
   234
lemma mono_map_is_inj:
paulson@13140
   235
    "[| linear(A,r);  wf[B](s);  f: mono_map(A,r,B,s) |] ==> f: inj(A,B)"
paulson@13140
   236
apply (unfold mono_map_def inj_def, clarify)
paulson@13140
   237
apply (erule_tac x=w and y=x in linearE, assumption+)
paulson@13140
   238
apply (force intro: apply_type dest: wf_on_not_refl)+
paulson@13140
   239
done
paulson@13140
   240
paulson@13140
   241
lemma ord_isoI:
paulson@13140
   242
    "[| f: bij(A, B);
paulson@13140
   243
        !!x y. [| x:A; y:A |] ==> <x, y> : r <-> <f`x, f`y> : s |]
paulson@13140
   244
     ==> f: ord_iso(A,r,B,s)"
paulson@13140
   245
by (simp add: ord_iso_def)
paulson@13140
   246
paulson@13140
   247
lemma ord_iso_is_mono_map:
paulson@13140
   248
    "f: ord_iso(A,r,B,s) ==> f: mono_map(A,r,B,s)"
paulson@13140
   249
apply (simp add: ord_iso_def mono_map_def)
paulson@13140
   250
apply (blast dest!: bij_is_fun)
paulson@13140
   251
done
paulson@13140
   252
paulson@13140
   253
lemma ord_iso_is_bij:
paulson@13140
   254
    "f: ord_iso(A,r,B,s) ==> f: bij(A,B)"
paulson@13140
   255
by (simp add: ord_iso_def)
paulson@13140
   256
paulson@13140
   257
(*Needed?  But ord_iso_converse is!*)
paulson@13140
   258
lemma ord_iso_apply:
paulson@13140
   259
    "[| f: ord_iso(A,r,B,s);  <x,y>: r;  x:A;  y:A |] ==> <f`x, f`y> : s"
berghofe@13611
   260
by (simp add: ord_iso_def)
paulson@13140
   261
paulson@13140
   262
lemma ord_iso_converse:
paulson@13140
   263
    "[| f: ord_iso(A,r,B,s);  <x,y>: s;  x:B;  y:B |]
paulson@13140
   264
     ==> <converse(f) ` x, converse(f) ` y> : r"
paulson@13140
   265
apply (simp add: ord_iso_def, clarify)
paulson@13140
   266
apply (erule bspec [THEN bspec, THEN iffD2])
paulson@13140
   267
apply (erule asm_rl bij_converse_bij [THEN bij_is_fun, THEN apply_type])+
paulson@13140
   268
apply (auto simp add: right_inverse_bij)
paulson@13140
   269
done
paulson@13140
   270
paulson@13140
   271
paulson@13140
   272
(** Symmetry and Transitivity Rules **)
paulson@13140
   273
paulson@13140
   274
(*Reflexivity of similarity*)
paulson@13140
   275
lemma ord_iso_refl: "id(A): ord_iso(A,r,A,r)"
paulson@13140
   276
by (rule id_bij [THEN ord_isoI], simp)
paulson@13140
   277
paulson@13140
   278
(*Symmetry of similarity*)
paulson@13140
   279
lemma ord_iso_sym: "f: ord_iso(A,r,B,s) ==> converse(f): ord_iso(B,s,A,r)"
paulson@13140
   280
apply (simp add: ord_iso_def)
paulson@13140
   281
apply (auto simp add: right_inverse_bij bij_converse_bij
paulson@13140
   282
                      bij_is_fun [THEN apply_funtype])
paulson@13140
   283
done
paulson@13140
   284
paulson@13140
   285
(*Transitivity of similarity*)
paulson@13140
   286
lemma mono_map_trans:
paulson@13140
   287
    "[| g: mono_map(A,r,B,s);  f: mono_map(B,s,C,t) |]
paulson@13140
   288
     ==> (f O g): mono_map(A,r,C,t)"
paulson@13140
   289
apply (unfold mono_map_def)
paulson@13140
   290
apply (auto simp add: comp_fun)
paulson@13140
   291
done
paulson@13140
   292
paulson@13140
   293
(*Transitivity of similarity: the order-isomorphism relation*)
paulson@13140
   294
lemma ord_iso_trans:
paulson@13140
   295
    "[| g: ord_iso(A,r,B,s);  f: ord_iso(B,s,C,t) |]
paulson@13140
   296
     ==> (f O g): ord_iso(A,r,C,t)"
paulson@13140
   297
apply (unfold ord_iso_def, clarify)
paulson@13140
   298
apply (frule bij_is_fun [of f])
paulson@13140
   299
apply (frule bij_is_fun [of g])
paulson@13140
   300
apply (auto simp add: comp_bij)
paulson@13140
   301
done
paulson@13140
   302
paulson@13140
   303
(** Two monotone maps can make an order-isomorphism **)
paulson@13140
   304
paulson@13140
   305
lemma mono_ord_isoI:
paulson@13140
   306
    "[| f: mono_map(A,r,B,s);  g: mono_map(B,s,A,r);
paulson@13140
   307
        f O g = id(B);  g O f = id(A) |] ==> f: ord_iso(A,r,B,s)"
paulson@13140
   308
apply (simp add: ord_iso_def mono_map_def, safe)
paulson@13140
   309
apply (intro fg_imp_bijective, auto)
paulson@13140
   310
apply (subgoal_tac "<g` (f`x), g` (f`y) > : r")
paulson@13140
   311
apply (simp add: comp_eq_id_iff [THEN iffD1])
paulson@13140
   312
apply (blast intro: apply_funtype)
paulson@13140
   313
done
paulson@13140
   314
paulson@13140
   315
lemma well_ord_mono_ord_isoI:
paulson@13140
   316
     "[| well_ord(A,r);  well_ord(B,s);
paulson@13140
   317
         f: mono_map(A,r,B,s);  converse(f): mono_map(B,s,A,r) |]
paulson@13140
   318
      ==> f: ord_iso(A,r,B,s)"
paulson@13140
   319
apply (intro mono_ord_isoI, auto)
paulson@13140
   320
apply (frule mono_map_is_fun [THEN fun_is_rel])
paulson@13140
   321
apply (erule converse_converse [THEN subst], rule left_comp_inverse)
paulson@13140
   322
apply (blast intro: left_comp_inverse mono_map_is_inj well_ord_is_linear
paulson@13140
   323
                    well_ord_is_wf)+
paulson@13140
   324
done
paulson@13140
   325
paulson@13140
   326
paulson@13140
   327
(** Order-isomorphisms preserve the ordering's properties **)
paulson@13140
   328
paulson@13140
   329
lemma part_ord_ord_iso:
paulson@13140
   330
    "[| part_ord(B,s);  f: ord_iso(A,r,B,s) |] ==> part_ord(A,r)"
paulson@13140
   331
apply (simp add: part_ord_def irrefl_def trans_on_def ord_iso_def)
paulson@13140
   332
apply (fast intro: bij_is_fun [THEN apply_type])
paulson@13140
   333
done
paulson@13140
   334
paulson@13140
   335
lemma linear_ord_iso:
paulson@13140
   336
    "[| linear(B,s);  f: ord_iso(A,r,B,s) |] ==> linear(A,r)"
paulson@13140
   337
apply (simp add: linear_def ord_iso_def, safe)
paulson@13339
   338
apply (drule_tac x1 = "f`x" and x = "f`y" in bspec [THEN bspec])
paulson@13140
   339
apply (safe elim!: bij_is_fun [THEN apply_type])
paulson@13140
   340
apply (drule_tac t = "op ` (converse (f))" in subst_context)
paulson@13140
   341
apply (simp add: left_inverse_bij)
paulson@13140
   342
done
paulson@13140
   343
paulson@13140
   344
lemma wf_on_ord_iso:
paulson@13140
   345
    "[| wf[B](s);  f: ord_iso(A,r,B,s) |] ==> wf[A](r)"
paulson@13140
   346
apply (simp add: wf_on_def wf_def ord_iso_def, safe)
paulson@13140
   347
apply (drule_tac x = "{f`z. z:Z Int A}" in spec)
paulson@13140
   348
apply (safe intro!: equalityI)
paulson@13140
   349
apply (blast dest!: equalityD1 intro: bij_is_fun [THEN apply_type])+
paulson@13140
   350
done
paulson@13140
   351
paulson@13140
   352
lemma well_ord_ord_iso:
paulson@13140
   353
    "[| well_ord(B,s);  f: ord_iso(A,r,B,s) |] ==> well_ord(A,r)"
paulson@13140
   354
apply (unfold well_ord_def tot_ord_def)
paulson@13140
   355
apply (fast elim!: part_ord_ord_iso linear_ord_iso wf_on_ord_iso)
paulson@13140
   356
done
paulson@9683
   357
paulson@9683
   358
paulson@13356
   359
subsection{*Main results of Kunen, Chapter 1 section 6*}
paulson@13140
   360
paulson@13140
   361
(*Inductive argument for Kunen's Lemma 6.1, etc.
paulson@13140
   362
  Simple proof from Halmos, page 72*)
paulson@13140
   363
lemma well_ord_iso_subset_lemma:
paulson@13140
   364
     "[| well_ord(A,r);  f: ord_iso(A,r, A',r);  A'<= A;  y: A |]
paulson@13140
   365
      ==> ~ <f`y, y>: r"
paulson@13140
   366
apply (simp add: well_ord_def ord_iso_def)
paulson@13140
   367
apply (elim conjE CollectE)
paulson@13140
   368
apply (rule_tac a=y in wf_on_induct, assumption+)
paulson@13140
   369
apply (blast dest: bij_is_fun [THEN apply_type])
paulson@13140
   370
done
paulson@13140
   371
paulson@13140
   372
(*Kunen's Lemma 6.1: there's no order-isomorphism to an initial segment
paulson@13140
   373
                     of a well-ordering*)
paulson@13140
   374
lemma well_ord_iso_predE:
paulson@13140
   375
     "[| well_ord(A,r);  f : ord_iso(A, r, pred(A,x,r), r);  x:A |] ==> P"
paulson@13140
   376
apply (insert well_ord_iso_subset_lemma [of A r f "pred(A,x,r)" x])
paulson@13140
   377
apply (simp add: pred_subset)
paulson@13140
   378
(*Now we know  f`x < x *)
paulson@13140
   379
apply (drule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type], assumption)
paulson@13140
   380
(*Now we also know f`x : pred(A,x,r);  contradiction! *)
paulson@13140
   381
apply (simp add: well_ord_def pred_def)
paulson@13140
   382
done
paulson@13140
   383
paulson@13140
   384
(*Simple consequence of Lemma 6.1*)
paulson@13140
   385
lemma well_ord_iso_pred_eq:
paulson@13140
   386
     "[| well_ord(A,r);  f : ord_iso(pred(A,a,r), r, pred(A,c,r), r);
paulson@13140
   387
         a:A;  c:A |] ==> a=c"
paulson@13140
   388
apply (frule well_ord_is_trans_on)
paulson@13140
   389
apply (frule well_ord_is_linear)
paulson@13140
   390
apply (erule_tac x=a and y=c in linearE, assumption+)
paulson@13140
   391
apply (drule ord_iso_sym)
paulson@13140
   392
(*two symmetric cases*)
paulson@13140
   393
apply (auto elim!: well_ord_subset [OF _ pred_subset, THEN well_ord_iso_predE]
paulson@13140
   394
            intro!: predI
paulson@13140
   395
            simp add: trans_pred_pred_eq)
paulson@13140
   396
done
paulson@13140
   397
paulson@13140
   398
(*Does not assume r is a wellordering!*)
paulson@13140
   399
lemma ord_iso_image_pred:
paulson@13140
   400
     "[|f : ord_iso(A,r,B,s);  a:A|] ==> f `` pred(A,a,r) = pred(B, f`a, s)"
paulson@13140
   401
apply (unfold ord_iso_def pred_def)
paulson@13140
   402
apply (erule CollectE)
paulson@13140
   403
apply (simp (no_asm_simp) add: image_fun [OF bij_is_fun Collect_subset])
paulson@13140
   404
apply (rule equalityI)
paulson@13140
   405
apply (safe elim!: bij_is_fun [THEN apply_type])
paulson@13140
   406
apply (rule RepFun_eqI)
paulson@13140
   407
apply (blast intro!: right_inverse_bij [symmetric])
paulson@13140
   408
apply (auto simp add: right_inverse_bij  bij_is_fun [THEN apply_funtype])
paulson@13140
   409
done
paulson@13140
   410
paulson@13212
   411
lemma ord_iso_restrict_image:
paulson@13212
   412
     "[| f : ord_iso(A,r,B,s);  C<=A |] 
paulson@13212
   413
      ==> restrict(f,C) : ord_iso(C, r, f``C, s)"
paulson@13212
   414
apply (simp add: ord_iso_def) 
paulson@13212
   415
apply (blast intro: bij_is_inj restrict_bij) 
paulson@13212
   416
done
paulson@13212
   417
paulson@13140
   418
(*But in use, A and B may themselves be initial segments.  Then use
paulson@13140
   419
  trans_pred_pred_eq to simplify the pred(pred...) terms.  See just below.*)
paulson@13212
   420
lemma ord_iso_restrict_pred:
paulson@13212
   421
   "[| f : ord_iso(A,r,B,s);   a:A |]
paulson@13212
   422
    ==> restrict(f, pred(A,a,r)) : ord_iso(pred(A,a,r), r, pred(B, f`a, s), s)"
paulson@13212
   423
apply (simp add: ord_iso_image_pred [symmetric]) 
paulson@13212
   424
apply (blast intro: ord_iso_restrict_image elim: predE) 
paulson@13140
   425
done
paulson@13140
   426
paulson@13140
   427
(*Tricky; a lot of forward proof!*)
paulson@13140
   428
lemma well_ord_iso_preserving:
paulson@13140
   429
     "[| well_ord(A,r);  well_ord(B,s);  <a,c>: r;
paulson@13140
   430
         f : ord_iso(pred(A,a,r), r, pred(B,b,s), s);
paulson@13140
   431
         g : ord_iso(pred(A,c,r), r, pred(B,d,s), s);
paulson@13140
   432
         a:A;  c:A;  b:B;  d:B |] ==> <b,d>: s"
paulson@13140
   433
apply (frule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type], (erule asm_rl predI predE)+)
paulson@13140
   434
apply (subgoal_tac "b = g`a")
paulson@13140
   435
apply (simp (no_asm_simp))
paulson@13140
   436
apply (rule well_ord_iso_pred_eq, auto)
paulson@13140
   437
apply (frule ord_iso_restrict_pred, (erule asm_rl predI)+)
paulson@13140
   438
apply (simp add: well_ord_is_trans_on trans_pred_pred_eq)
paulson@13140
   439
apply (erule ord_iso_sym [THEN ord_iso_trans], assumption)
paulson@13140
   440
done
paulson@13140
   441
paulson@13140
   442
(*See Halmos, page 72*)
paulson@13140
   443
lemma well_ord_iso_unique_lemma:
paulson@13140
   444
     "[| well_ord(A,r);
paulson@13140
   445
         f: ord_iso(A,r, B,s);  g: ord_iso(A,r, B,s);  y: A |]
paulson@13140
   446
      ==> ~ <g`y, f`y> : s"
paulson@13140
   447
apply (frule well_ord_iso_subset_lemma)
paulson@13140
   448
apply (rule_tac f = "converse (f) " and g = g in ord_iso_trans)
paulson@13140
   449
apply auto
paulson@13140
   450
apply (blast intro: ord_iso_sym)
paulson@13140
   451
apply (frule ord_iso_is_bij [of f])
paulson@13140
   452
apply (frule ord_iso_is_bij [of g])
paulson@13140
   453
apply (frule ord_iso_converse)
paulson@13140
   454
apply (blast intro!: bij_converse_bij
paulson@13140
   455
             intro: bij_is_fun apply_funtype)+
paulson@13140
   456
apply (erule notE)
paulson@13176
   457
apply (simp add: left_inverse_bij bij_is_fun comp_fun_apply [of _ A B])
paulson@13140
   458
done
paulson@13140
   459
paulson@13140
   460
paulson@13140
   461
(*Kunen's Lemma 6.2: Order-isomorphisms between well-orderings are unique*)
paulson@13140
   462
lemma well_ord_iso_unique: "[| well_ord(A,r);
paulson@13140
   463
         f: ord_iso(A,r, B,s);  g: ord_iso(A,r, B,s) |] ==> f = g"
paulson@13140
   464
apply (rule fun_extension)
paulson@13140
   465
apply (erule ord_iso_is_bij [THEN bij_is_fun])+
paulson@13140
   466
apply (subgoal_tac "f`x : B & g`x : B & linear(B,s)")
paulson@13140
   467
 apply (simp add: linear_def)
paulson@13140
   468
 apply (blast dest: well_ord_iso_unique_lemma)
paulson@13140
   469
apply (blast intro: ord_iso_is_bij bij_is_fun apply_funtype
paulson@13140
   470
                    well_ord_is_linear well_ord_ord_iso ord_iso_sym)
paulson@13140
   471
done
paulson@13140
   472
paulson@13356
   473
subsection{*Towards Kunen's Theorem 6.3: Linearity of the Similarity Relation*}
paulson@13140
   474
paulson@13140
   475
lemma ord_iso_map_subset: "ord_iso_map(A,r,B,s) <= A*B"
paulson@13140
   476
by (unfold ord_iso_map_def, blast)
paulson@13140
   477
paulson@13140
   478
lemma domain_ord_iso_map: "domain(ord_iso_map(A,r,B,s)) <= A"
paulson@13140
   479
by (unfold ord_iso_map_def, blast)
paulson@13140
   480
paulson@13140
   481
lemma range_ord_iso_map: "range(ord_iso_map(A,r,B,s)) <= B"
paulson@13140
   482
by (unfold ord_iso_map_def, blast)
paulson@13140
   483
paulson@13140
   484
lemma converse_ord_iso_map:
paulson@13140
   485
    "converse(ord_iso_map(A,r,B,s)) = ord_iso_map(B,s,A,r)"
paulson@13140
   486
apply (unfold ord_iso_map_def)
paulson@13140
   487
apply (blast intro: ord_iso_sym)
paulson@13140
   488
done
paulson@13140
   489
paulson@13140
   490
lemma function_ord_iso_map:
paulson@13140
   491
    "well_ord(B,s) ==> function(ord_iso_map(A,r,B,s))"
paulson@13140
   492
apply (unfold ord_iso_map_def function_def)
paulson@13140
   493
apply (blast intro: well_ord_iso_pred_eq ord_iso_sym ord_iso_trans)
paulson@13140
   494
done
paulson@13140
   495
paulson@13140
   496
lemma ord_iso_map_fun: "well_ord(B,s) ==> ord_iso_map(A,r,B,s)
paulson@13140
   497
           : domain(ord_iso_map(A,r,B,s)) -> range(ord_iso_map(A,r,B,s))"
paulson@13140
   498
by (simp add: Pi_iff function_ord_iso_map
paulson@13140
   499
                 ord_iso_map_subset [THEN domain_times_range])
paulson@13140
   500
paulson@13140
   501
lemma ord_iso_map_mono_map:
paulson@13140
   502
    "[| well_ord(A,r);  well_ord(B,s) |]
paulson@13140
   503
     ==> ord_iso_map(A,r,B,s)
paulson@13140
   504
           : mono_map(domain(ord_iso_map(A,r,B,s)), r,
paulson@13140
   505
                      range(ord_iso_map(A,r,B,s)), s)"
paulson@13140
   506
apply (unfold mono_map_def)
paulson@13140
   507
apply (simp (no_asm_simp) add: ord_iso_map_fun)
paulson@13140
   508
apply safe
paulson@13140
   509
apply (subgoal_tac "x:A & ya:A & y:B & yb:B")
paulson@13140
   510
 apply (simp add: apply_equality [OF _  ord_iso_map_fun])
paulson@13140
   511
 apply (unfold ord_iso_map_def)
paulson@13140
   512
 apply (blast intro: well_ord_iso_preserving, blast)
paulson@13140
   513
done
paulson@13140
   514
paulson@13140
   515
lemma ord_iso_map_ord_iso:
paulson@13140
   516
    "[| well_ord(A,r);  well_ord(B,s) |] ==> ord_iso_map(A,r,B,s)
paulson@13140
   517
           : ord_iso(domain(ord_iso_map(A,r,B,s)), r,
paulson@13140
   518
                      range(ord_iso_map(A,r,B,s)), s)"
paulson@13140
   519
apply (rule well_ord_mono_ord_isoI)
paulson@13140
   520
   prefer 4
paulson@13140
   521
   apply (rule converse_ord_iso_map [THEN subst])
paulson@13140
   522
   apply (simp add: ord_iso_map_mono_map
paulson@13140
   523
		    ord_iso_map_subset [THEN converse_converse])
paulson@13140
   524
apply (blast intro!: domain_ord_iso_map range_ord_iso_map
paulson@13140
   525
             intro: well_ord_subset ord_iso_map_mono_map)+
paulson@13140
   526
done
paulson@13140
   527
paulson@13140
   528
paulson@13140
   529
(*One way of saying that domain(ord_iso_map(A,r,B,s)) is downwards-closed*)
paulson@13140
   530
lemma domain_ord_iso_map_subset:
paulson@13140
   531
     "[| well_ord(A,r);  well_ord(B,s);
paulson@13140
   532
         a: A;  a ~: domain(ord_iso_map(A,r,B,s)) |]
paulson@13140
   533
      ==>  domain(ord_iso_map(A,r,B,s)) <= pred(A, a, r)"
paulson@13140
   534
apply (unfold ord_iso_map_def)
paulson@13140
   535
apply (safe intro!: predI)
paulson@13140
   536
(*Case analysis on  xa vs a in r *)
paulson@13140
   537
apply (simp (no_asm_simp))
paulson@13140
   538
apply (frule_tac A = A in well_ord_is_linear)
paulson@13140
   539
apply (rename_tac b y f)
paulson@13140
   540
apply (erule_tac x=b and y=a in linearE, assumption+)
paulson@13140
   541
(*Trivial case: b=a*)
paulson@13140
   542
apply clarify
paulson@13140
   543
apply blast
paulson@13140
   544
(*Harder case: <a, xa>: r*)
paulson@13140
   545
apply (frule ord_iso_is_bij [THEN bij_is_fun, THEN apply_type],
paulson@13140
   546
       (erule asm_rl predI predE)+)
paulson@13140
   547
apply (frule ord_iso_restrict_pred)
paulson@13140
   548
 apply (simp add: pred_iff)
paulson@13140
   549
apply (simp split: split_if_asm
paulson@13140
   550
          add: well_ord_is_trans_on trans_pred_pred_eq domain_UN domain_Union, blast)
paulson@13140
   551
done
paulson@13140
   552
paulson@13140
   553
(*For the 4-way case analysis in the main result*)
paulson@13140
   554
lemma domain_ord_iso_map_cases:
paulson@13140
   555
     "[| well_ord(A,r);  well_ord(B,s) |]
paulson@13140
   556
      ==> domain(ord_iso_map(A,r,B,s)) = A |
paulson@13140
   557
          (EX x:A. domain(ord_iso_map(A,r,B,s)) = pred(A,x,r))"
paulson@13140
   558
apply (frule well_ord_is_wf)
paulson@13140
   559
apply (unfold wf_on_def wf_def)
paulson@13140
   560
apply (drule_tac x = "A-domain (ord_iso_map (A,r,B,s))" in spec)
paulson@13140
   561
apply safe
paulson@13140
   562
(*The first case: the domain equals A*)
paulson@13140
   563
apply (rule domain_ord_iso_map [THEN equalityI])
paulson@13140
   564
apply (erule Diff_eq_0_iff [THEN iffD1])
paulson@13140
   565
(*The other case: the domain equals an initial segment*)
paulson@13140
   566
apply (blast del: domainI subsetI
paulson@13140
   567
	     elim!: predE
paulson@13140
   568
	     intro!: domain_ord_iso_map_subset
paulson@13140
   569
             intro: subsetI)+
paulson@13140
   570
done
paulson@13140
   571
paulson@13140
   572
(*As above, by duality*)
paulson@13140
   573
lemma range_ord_iso_map_cases:
paulson@13140
   574
    "[| well_ord(A,r);  well_ord(B,s) |]
paulson@13140
   575
     ==> range(ord_iso_map(A,r,B,s)) = B |
paulson@13140
   576
         (EX y:B. range(ord_iso_map(A,r,B,s)) = pred(B,y,s))"
paulson@13140
   577
apply (rule converse_ord_iso_map [THEN subst])
paulson@13140
   578
apply (simp add: domain_ord_iso_map_cases)
paulson@13140
   579
done
paulson@13140
   580
paulson@13356
   581
text{*Kunen's Theorem 6.3: Fundamental Theorem for Well-Ordered Sets*}
paulson@13356
   582
theorem well_ord_trichotomy:
paulson@13140
   583
   "[| well_ord(A,r);  well_ord(B,s) |]
paulson@13140
   584
    ==> ord_iso_map(A,r,B,s) : ord_iso(A, r, B, s) |
paulson@13140
   585
        (EX x:A. ord_iso_map(A,r,B,s) : ord_iso(pred(A,x,r), r, B, s)) |
paulson@13140
   586
        (EX y:B. ord_iso_map(A,r,B,s) : ord_iso(A, r, pred(B,y,s), s))"
paulson@13140
   587
apply (frule_tac B = B in domain_ord_iso_map_cases, assumption)
paulson@13140
   588
apply (frule_tac B = B in range_ord_iso_map_cases, assumption)
paulson@13140
   589
apply (drule ord_iso_map_ord_iso, assumption)
paulson@13140
   590
apply (elim disjE bexE)
paulson@13140
   591
   apply (simp_all add: bexI)
paulson@13140
   592
apply (rule wf_on_not_refl [THEN notE])
paulson@13140
   593
  apply (erule well_ord_is_wf)
paulson@13140
   594
 apply assumption
paulson@13140
   595
apply (subgoal_tac "<x,y>: ord_iso_map (A,r,B,s) ")
paulson@13140
   596
 apply (drule rangeI)
paulson@13140
   597
 apply (simp add: pred_def)
paulson@13140
   598
apply (unfold ord_iso_map_def, blast)
paulson@13140
   599
done
paulson@13140
   600
paulson@13140
   601
paulson@13356
   602
subsection{*Miscellaneous Results by Krzysztof Grabczewski*}
paulson@13356
   603
paulson@13356
   604
(** Properties of converse(r) **)
paulson@13140
   605
paulson@13140
   606
lemma irrefl_converse: "irrefl(A,r) ==> irrefl(A,converse(r))"
paulson@13140
   607
by (unfold irrefl_def, blast)
paulson@13140
   608
paulson@13140
   609
lemma trans_on_converse: "trans[A](r) ==> trans[A](converse(r))"
paulson@13140
   610
by (unfold trans_on_def, blast)
paulson@13140
   611
paulson@13140
   612
lemma part_ord_converse: "part_ord(A,r) ==> part_ord(A,converse(r))"
paulson@13140
   613
apply (unfold part_ord_def)
paulson@13140
   614
apply (blast intro!: irrefl_converse trans_on_converse)
paulson@13140
   615
done
paulson@13140
   616
paulson@13140
   617
lemma linear_converse: "linear(A,r) ==> linear(A,converse(r))"
paulson@13140
   618
by (unfold linear_def, blast)
paulson@13140
   619
paulson@13140
   620
lemma tot_ord_converse: "tot_ord(A,r) ==> tot_ord(A,converse(r))"
paulson@13140
   621
apply (unfold tot_ord_def)
paulson@13140
   622
apply (blast intro!: part_ord_converse linear_converse)
paulson@13140
   623
done
paulson@13140
   624
paulson@13140
   625
paulson@13140
   626
(** By Krzysztof Grabczewski.
paulson@13140
   627
    Lemmas involving the first element of a well ordered set **)
paulson@13140
   628
paulson@13140
   629
lemma first_is_elem: "first(b,B,r) ==> b:B"
paulson@13140
   630
by (unfold first_def, blast)
paulson@13140
   631
paulson@13140
   632
lemma well_ord_imp_ex1_first:
paulson@13140
   633
        "[| well_ord(A,r); B<=A; B~=0 |] ==> (EX! b. first(b,B,r))"
paulson@13140
   634
apply (unfold well_ord_def wf_on_def wf_def first_def)
paulson@13140
   635
apply (elim conjE allE disjE, blast)
paulson@13140
   636
apply (erule bexE)
paulson@13140
   637
apply (rule_tac a = x in ex1I, auto)
paulson@13140
   638
apply (unfold tot_ord_def linear_def, blast)
paulson@13140
   639
done
paulson@13140
   640
paulson@13140
   641
lemma the_first_in:
paulson@13140
   642
     "[| well_ord(A,r); B<=A; B~=0 |] ==> (THE b. first(b,B,r)) : B"
paulson@13140
   643
apply (drule well_ord_imp_ex1_first, assumption+)
paulson@13140
   644
apply (rule first_is_elem)
paulson@13140
   645
apply (erule theI)
paulson@13140
   646
done
paulson@13140
   647
lcp@435
   648
end