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