src/HOL/ex/Tarski.thy
author paulson
Wed May 08 09:08:16 2002 +0200 (2002-05-08)
changeset 13115 0a6fbdedcde2
parent 12459 6978ab7cac64
child 13383 041d78bf9403
permissions -rw-r--r--
Tidied and converted to Isar by lcp
wenzelm@7112
     1
(*  Title:      HOL/ex/Tarski
wenzelm@7112
     2
    ID:         $Id$
wenzelm@7112
     3
    Author:     Florian Kammueller, Cambridge University Computer Laboratory
wenzelm@7112
     4
    Copyright   1999  University of Cambridge
wenzelm@7112
     5
wenzelm@7112
     6
Minimal version of lattice theory plus the full theorem of Tarski:
wenzelm@7112
     7
   The fixedpoints of a complete lattice themselves form a complete lattice.
wenzelm@7112
     8
wenzelm@7112
     9
Illustrates first-class theories, using the Sigma representation of structures
paulson@13115
    10
paulson@13115
    11
Tidied and converted to Isar by lcp
wenzelm@7112
    12
*)
wenzelm@7112
    13
paulson@13115
    14
theory Tarski = Main:
wenzelm@7112
    15
wenzelm@7112
    16
record 'a potype = 
wenzelm@7112
    17
  pset  :: "'a set"
wenzelm@7112
    18
  order :: "('a * 'a) set"
wenzelm@7112
    19
wenzelm@7112
    20
syntax
paulson@13115
    21
  "@pset"  :: "'a potype => 'a set"            ("_ .<A>"  [90] 90)
wenzelm@7112
    22
  "@order" :: "'a potype => ('a *'a)set"       ("_ .<r>"  [90] 90) 
wenzelm@7112
    23
wenzelm@7112
    24
translations
wenzelm@7112
    25
  "po.<A>" == "pset po"
wenzelm@7112
    26
  "po.<r>" == "order po"
wenzelm@7112
    27
wenzelm@7112
    28
constdefs
wenzelm@7112
    29
  monotone :: "['a => 'a, 'a set, ('a *'a)set] => bool"
paulson@13115
    30
    "monotone f A r == \<forall>x\<in>A. \<forall>y\<in>A. (x, y): r --> ((f x), (f y)) : r"
wenzelm@7112
    31
wenzelm@7112
    32
  least :: "['a => bool, 'a potype] => 'a"
wenzelm@7112
    33
   "least P po == @ x. x: po.<A> & P x &
paulson@13115
    34
                       (\<forall>y \<in> po.<A>. P y --> (x,y): po.<r>)"
wenzelm@7112
    35
wenzelm@7112
    36
  greatest :: "['a => bool, 'a potype] => 'a"
wenzelm@7112
    37
   "greatest P po == @ x. x: po.<A> & P x &
paulson@13115
    38
                          (\<forall>y \<in> po.<A>. P y --> (y,x): po.<r>)"
wenzelm@7112
    39
wenzelm@7112
    40
  lub  :: "['a set, 'a potype] => 'a"
paulson@13115
    41
   "lub S po == least (%x. \<forall>y\<in>S. (y,x): po.<r>) po"
wenzelm@7112
    42
wenzelm@7112
    43
  glb  :: "['a set, 'a potype] => 'a"
paulson@13115
    44
   "glb S po == greatest (%x. \<forall>y\<in>S. (x,y): po.<r>) po"
wenzelm@7112
    45
paulson@13115
    46
  isLub :: "['a set, 'a potype, 'a] => bool"
paulson@13115
    47
   "isLub S po == %L. (L: po.<A> & (\<forall>y\<in>S. (y,L): po.<r>) &
paulson@13115
    48
                      (\<forall>z\<in>po.<A>. (\<forall>y\<in>S. (y,z): po.<r>) --> (L,z): po.<r>))"
wenzelm@7112
    49
paulson@13115
    50
  isGlb :: "['a set, 'a potype, 'a] => bool"
paulson@13115
    51
   "isGlb S po == %G. (G: po.<A> & (\<forall>y\<in>S. (G,y): po.<r>) &
paulson@13115
    52
                     (\<forall>z \<in> po.<A>. (\<forall>y\<in>S. (z,y): po.<r>) --> (z,G): po.<r>))"
wenzelm@7112
    53
paulson@13115
    54
  "fix"    :: "[('a => 'a), 'a set] => 'a set"
wenzelm@7112
    55
   "fix f A  == {x. x: A & f x = x}"
wenzelm@7112
    56
wenzelm@7112
    57
  interval :: "[('a*'a) set,'a, 'a ] => 'a set"
wenzelm@7112
    58
   "interval r a b == {x. (a,x): r & (x,b): r}"
wenzelm@7112
    59
wenzelm@7112
    60
wenzelm@7112
    61
constdefs
wenzelm@7112
    62
  Bot :: "'a potype => 'a"
wenzelm@7112
    63
   "Bot po == least (%x. True) po"
wenzelm@7112
    64
wenzelm@7112
    65
  Top :: "'a potype => 'a"
wenzelm@7112
    66
   "Top po == greatest (%x. True) po"
wenzelm@7112
    67
wenzelm@7112
    68
  PartialOrder :: "('a potype) set"
wenzelm@7112
    69
   "PartialOrder == {P. refl (P.<A>) (P.<r>) & antisym (P.<r>) &
wenzelm@7112
    70
		        trans (P.<r>)}"
wenzelm@7112
    71
wenzelm@7112
    72
  CompleteLattice :: "('a potype) set"
wenzelm@7112
    73
   "CompleteLattice == {cl. cl: PartialOrder & 
paulson@13115
    74
			(\<forall>S. S <= cl.<A> --> (\<exists>L. isLub S cl L)) &
paulson@13115
    75
			(\<forall>S. S <= cl.<A> --> (\<exists>G. isGlb S cl G))}"
wenzelm@7112
    76
wenzelm@7112
    77
  CLF :: "('a potype * ('a => 'a)) set"
wenzelm@7112
    78
   "CLF == SIGMA cl: CompleteLattice.
wenzelm@7112
    79
             {f. f: cl.<A> funcset cl.<A> & monotone f (cl.<A>) (cl.<r>)}"
wenzelm@7112
    80
  
wenzelm@7112
    81
  induced :: "['a set, ('a * 'a) set] => ('a *'a)set"
wenzelm@7112
    82
   "induced A r == {(a,b). a : A & b: A & (a,b): r}"
wenzelm@7112
    83
wenzelm@7112
    84
wenzelm@7112
    85
wenzelm@7112
    86
wenzelm@7112
    87
constdefs
wenzelm@7112
    88
  sublattice :: "('a potype * 'a set)set"
wenzelm@7112
    89
   "sublattice == 
wenzelm@7112
    90
      SIGMA cl: CompleteLattice.
wenzelm@7112
    91
          {S. S <= cl.<A> &
wenzelm@7112
    92
	   (| pset = S, order = induced S (cl.<r>) |): CompleteLattice }"
wenzelm@7112
    93
wenzelm@7112
    94
syntax
wenzelm@7112
    95
  "@SL"  :: "['a set, 'a potype] => bool" ("_ <<= _" [51,50]50)
wenzelm@7112
    96
wenzelm@7112
    97
translations
nipkow@10834
    98
  "S <<= cl" == "S : sublattice `` {cl}"
wenzelm@7112
    99
wenzelm@7112
   100
constdefs
wenzelm@7112
   101
  dual :: "'a potype => 'a potype"
wenzelm@7112
   102
   "dual po == (| pset = po.<A>, order = converse (po.<r>) |)"
wenzelm@7112
   103
wenzelm@7112
   104
locale PO = 
paulson@13115
   105
  fixes cl :: "'a potype"
paulson@13115
   106
    and A  :: "'a set"
paulson@13115
   107
    and r  :: "('a * 'a) set"
paulson@13115
   108
  assumes cl_po:  "cl : PartialOrder"
paulson@13115
   109
  defines A_def: "A == cl.<A>"
paulson@13115
   110
     and  r_def: "r == cl.<r>"
wenzelm@7112
   111
wenzelm@7112
   112
locale CL = PO +
paulson@13115
   113
  assumes cl_co:  "cl : CompleteLattice"
wenzelm@7112
   114
wenzelm@7112
   115
locale CLF = CL +
paulson@13115
   116
  fixes f :: "'a => 'a"
paulson@13115
   117
    and P :: "'a set"
paulson@13115
   118
  assumes f_cl:  "(cl,f) : CLF" (*was the equivalent "f : CLF``{cl}"*)
paulson@13115
   119
  defines P_def: "P == fix f A"
wenzelm@7112
   120
wenzelm@7112
   121
wenzelm@7112
   122
locale Tarski = CLF + 
paulson@13115
   123
  fixes Y     :: "'a set"
paulson@13115
   124
    and intY1 :: "'a set"
paulson@13115
   125
    and v     :: "'a"
paulson@13115
   126
  assumes
paulson@13115
   127
    Y_ss: "Y <= P"
paulson@13115
   128
  defines
paulson@13115
   129
    intY1_def: "intY1 == interval r (lub Y cl) (Top cl)"
paulson@13115
   130
    and v_def: "v == glb {x. ((%x: intY1. f x) x, x): induced intY1 r & 
paulson@13115
   131
                             x: intY1}
paulson@13115
   132
		      (| pset=intY1, order=induced intY1 r|)"
paulson@13115
   133
paulson@13115
   134
paulson@13115
   135
paulson@13115
   136
(* Partial Order *)
paulson@13115
   137
paulson@13115
   138
lemma (in PO) PO_imp_refl: "refl A r"
paulson@13115
   139
apply (insert cl_po) 
paulson@13115
   140
apply (simp add: PartialOrder_def A_def r_def)
paulson@13115
   141
done
paulson@13115
   142
paulson@13115
   143
lemma (in PO) PO_imp_sym: "antisym r"
paulson@13115
   144
apply (insert cl_po) 
paulson@13115
   145
apply (simp add: PartialOrder_def A_def r_def)
paulson@13115
   146
done
paulson@13115
   147
paulson@13115
   148
lemma (in PO) PO_imp_trans: "trans r"
paulson@13115
   149
apply (insert cl_po) 
paulson@13115
   150
apply (simp add: PartialOrder_def A_def r_def)
paulson@13115
   151
done
paulson@13115
   152
paulson@13115
   153
lemma (in PO) reflE: "[| refl A r; x \<in> A|] ==> (x, x) \<in> r"
paulson@13115
   154
apply (insert cl_po) 
paulson@13115
   155
apply (simp add: PartialOrder_def refl_def)
paulson@13115
   156
done
paulson@13115
   157
paulson@13115
   158
lemma (in PO) antisymE: "[| antisym r; (a, b) \<in> r; (b, a) \<in> r |] ==> a = b"
paulson@13115
   159
apply (insert cl_po) 
paulson@13115
   160
apply (simp add: PartialOrder_def antisym_def)
paulson@13115
   161
done
paulson@13115
   162
paulson@13115
   163
lemma (in PO) transE: "[| trans r; (a, b) \<in> r; (b, c) \<in> r|] ==> (a,c) \<in> r"
paulson@13115
   164
apply (insert cl_po) 
paulson@13115
   165
apply (simp add: PartialOrder_def)
paulson@13115
   166
apply (unfold trans_def, fast)
paulson@13115
   167
done
paulson@13115
   168
paulson@13115
   169
lemma (in PO) monotoneE:
paulson@13115
   170
     "[| monotone f A r;  x \<in> A; y \<in> A; (x, y) \<in> r |] ==> (f x, f y) \<in> r"
paulson@13115
   171
by (simp add: monotone_def)
paulson@13115
   172
paulson@13115
   173
lemma (in PO) po_subset_po:
paulson@13115
   174
     "S <= A ==> (| pset = S, order = induced S r |) \<in> PartialOrder"
paulson@13115
   175
apply (simp (no_asm) add: PartialOrder_def)
paulson@13115
   176
apply auto
paulson@13115
   177
(* refl *)
paulson@13115
   178
apply (simp add: refl_def induced_def)
paulson@13115
   179
apply (blast intro: PO_imp_refl [THEN reflE])
paulson@13115
   180
(* antisym *)
paulson@13115
   181
apply (simp add: antisym_def induced_def)
paulson@13115
   182
apply (blast intro: PO_imp_sym [THEN antisymE])
paulson@13115
   183
(* trans *)
paulson@13115
   184
apply (simp add: trans_def induced_def)
paulson@13115
   185
apply (blast intro: PO_imp_trans [THEN transE])
paulson@13115
   186
done
paulson@13115
   187
paulson@13115
   188
lemma (in PO) indE: "[| (x, y) \<in> induced S r; S <= A |] ==> (x, y) \<in> r"
paulson@13115
   189
by (simp add: add: induced_def)
paulson@13115
   190
paulson@13115
   191
lemma (in PO) indI: "[| (x, y) \<in> r; x \<in> S; y \<in> S |] ==> (x, y) \<in> induced S r"
paulson@13115
   192
by (simp add: add: induced_def)
paulson@13115
   193
paulson@13115
   194
lemma (in CL) CL_imp_ex_isLub: "S <= A ==> \<exists>L. isLub S cl L" 
paulson@13115
   195
apply (insert cl_co) 
paulson@13115
   196
apply (simp add: CompleteLattice_def A_def)
paulson@13115
   197
done
paulson@13115
   198
paulson@13115
   199
declare (in CL) cl_co [simp]
paulson@13115
   200
paulson@13115
   201
lemma isLub_lub: "(\<exists>L. isLub S cl L) = isLub S cl (lub S cl)"
paulson@13115
   202
by (simp add: lub_def least_def isLub_def some_eq_ex [symmetric])
paulson@13115
   203
paulson@13115
   204
lemma isGlb_glb: "(\<exists>G. isGlb S cl G) = isGlb S cl (glb S cl)"
paulson@13115
   205
by (simp add: glb_def greatest_def isGlb_def some_eq_ex [symmetric])
paulson@13115
   206
paulson@13115
   207
lemma isGlb_dual_isLub: "isGlb S cl = isLub S (dual cl)"
paulson@13115
   208
by (simp add: isLub_def isGlb_def dual_def converse_def)
paulson@13115
   209
paulson@13115
   210
lemma isLub_dual_isGlb: "isLub S cl = isGlb S (dual cl)"
paulson@13115
   211
by (simp add: isLub_def isGlb_def dual_def converse_def)
paulson@13115
   212
paulson@13115
   213
lemma (in PO) dualPO: "dual cl \<in> PartialOrder"
paulson@13115
   214
apply (insert cl_po) 
paulson@13115
   215
apply (simp add: PartialOrder_def dual_def refl_converse 
paulson@13115
   216
                 trans_converse antisym_converse)
paulson@13115
   217
done
paulson@13115
   218
paulson@13115
   219
lemma Rdual:
paulson@13115
   220
     "\<forall>S. (S <= A -->( \<exists>L. isLub S (| pset = A, order = r|) L))  
paulson@13115
   221
      ==> \<forall>S. (S <= A --> (\<exists>G. isGlb S (| pset = A, order = r|) G))"
paulson@13115
   222
apply safe
paulson@13115
   223
apply (rule_tac x = "lub {y. y \<in> A & (\<forall>k \<in> S. (y, k) \<in> r)}
paulson@13115
   224
                      (|pset = A, order = r|) " in exI)
paulson@13115
   225
apply (drule_tac x = "{y. y \<in> A & (\<forall>k \<in> S. (y,k) \<in> r) }" in spec)
paulson@13115
   226
apply (drule mp, fast)
paulson@13115
   227
apply (simp add: isLub_lub isGlb_def)
paulson@13115
   228
apply (simp add: isLub_def, blast)
paulson@13115
   229
done
paulson@13115
   230
paulson@13115
   231
lemma lub_dual_glb: "lub S cl = glb S (dual cl)"
paulson@13115
   232
by (simp add: lub_def glb_def least_def greatest_def dual_def converse_def)
paulson@13115
   233
paulson@13115
   234
lemma glb_dual_lub: "glb S cl = lub S (dual cl)"
paulson@13115
   235
by (simp add: lub_def glb_def least_def greatest_def dual_def converse_def)
paulson@13115
   236
paulson@13115
   237
lemma CL_subset_PO: "CompleteLattice <= PartialOrder"
paulson@13115
   238
by (simp add: PartialOrder_def CompleteLattice_def, fast)
paulson@13115
   239
paulson@13115
   240
lemmas CL_imp_PO = CL_subset_PO [THEN subsetD]
paulson@13115
   241
paulson@13115
   242
declare CL_imp_PO [THEN Tarski.PO_imp_refl, simp]
paulson@13115
   243
declare CL_imp_PO [THEN Tarski.PO_imp_sym, simp]
paulson@13115
   244
declare CL_imp_PO [THEN Tarski.PO_imp_trans, simp]
paulson@13115
   245
paulson@13115
   246
lemma (in CL) CO_refl: "refl A r"
paulson@13115
   247
by (rule PO_imp_refl)
paulson@13115
   248
paulson@13115
   249
lemma (in CL) CO_antisym: "antisym r"
paulson@13115
   250
by (rule PO_imp_sym)
paulson@13115
   251
paulson@13115
   252
lemma (in CL) CO_trans: "trans r"
paulson@13115
   253
by (rule PO_imp_trans)
paulson@13115
   254
paulson@13115
   255
lemma CompleteLatticeI:
paulson@13115
   256
     "[| po \<in> PartialOrder; (\<forall>S. S <= po.<A> --> (\<exists>L. isLub S po L)); 
paulson@13115
   257
         (\<forall>S. S <= po.<A> --> (\<exists>G. isGlb S po G))|] 
paulson@13115
   258
      ==> po \<in> CompleteLattice"
paulson@13115
   259
apply (unfold CompleteLattice_def, blast) 
paulson@13115
   260
done
paulson@13115
   261
paulson@13115
   262
lemma (in CL) CL_dualCL: "dual cl \<in> CompleteLattice"
paulson@13115
   263
apply (insert cl_co) 
paulson@13115
   264
apply (simp add: CompleteLattice_def dual_def)
paulson@13115
   265
apply (fold dual_def) 
paulson@13115
   266
apply (simp add: isLub_dual_isGlb [symmetric] isGlb_dual_isLub [symmetric] 
paulson@13115
   267
                 dualPO)
paulson@13115
   268
done
paulson@13115
   269
paulson@13115
   270
lemma (in PO) dualA_iff: "(dual cl.<A>) = cl.<A>"
paulson@13115
   271
by (simp add: dual_def)
paulson@13115
   272
paulson@13115
   273
lemma (in PO) dualr_iff: "((x, y) \<in> (dual cl.<r>)) = ((y, x) \<in> cl.<r>)"
paulson@13115
   274
by (simp add: dual_def)
paulson@13115
   275
paulson@13115
   276
lemma (in PO) monotone_dual:
paulson@13115
   277
     "monotone f (cl.<A>) (cl.<r>) ==> monotone f (dual cl.<A>) (dual cl.<r>)"
paulson@13115
   278
apply (simp add: monotone_def dualA_iff dualr_iff)
paulson@13115
   279
done
paulson@13115
   280
paulson@13115
   281
lemma (in PO) interval_dual:
paulson@13115
   282
     "[| x \<in> A; y \<in> A|] ==> interval r x y = interval (dual cl.<r>) y x"
paulson@13115
   283
apply (simp add: interval_def dualr_iff)
paulson@13115
   284
apply (fold r_def, fast)
paulson@13115
   285
done
paulson@13115
   286
paulson@13115
   287
lemma (in PO) interval_not_empty:
paulson@13115
   288
     "[| trans r; interval r a b \<noteq> {} |] ==> (a, b) \<in> r"
paulson@13115
   289
apply (simp add: interval_def)
paulson@13115
   290
apply (unfold trans_def, blast)
paulson@13115
   291
done
paulson@13115
   292
paulson@13115
   293
lemma (in PO) interval_imp_mem: "x \<in> interval r a b ==> (a, x) \<in> r"
paulson@13115
   294
by (simp add: interval_def)
paulson@13115
   295
paulson@13115
   296
lemma (in PO) left_in_interval:
paulson@13115
   297
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |] ==> a \<in> interval r a b"
paulson@13115
   298
apply (simp (no_asm_simp) add: interval_def)
paulson@13115
   299
apply (simp add: PO_imp_trans interval_not_empty)
paulson@13115
   300
apply (simp add: PO_imp_refl [THEN reflE])
paulson@13115
   301
done
paulson@13115
   302
paulson@13115
   303
lemma (in PO) right_in_interval:
paulson@13115
   304
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |] ==> b \<in> interval r a b"
paulson@13115
   305
apply (simp (no_asm_simp) add: interval_def)
paulson@13115
   306
apply (simp add: PO_imp_trans interval_not_empty)
paulson@13115
   307
apply (simp add: PO_imp_refl [THEN reflE])
paulson@13115
   308
done
paulson@13115
   309
paulson@13115
   310
(* sublattice *)
paulson@13115
   311
lemma (in PO) sublattice_imp_CL:
paulson@13115
   312
     "S <<= cl  ==> (| pset = S, order = induced S r |) \<in> CompleteLattice"
paulson@13115
   313
by (simp add: sublattice_def CompleteLattice_def A_def r_def)
paulson@13115
   314
paulson@13115
   315
lemma (in CL) sublatticeI:
paulson@13115
   316
     "[| S <= A; (| pset = S, order = induced S r |) \<in> CompleteLattice |] 
paulson@13115
   317
      ==> S <<= cl"
paulson@13115
   318
by (simp add: sublattice_def A_def r_def)
paulson@13115
   319
paulson@13115
   320
(* lub *)
paulson@13115
   321
lemma (in CL) lub_unique: "[| S <= A; isLub S cl x; isLub S cl L|] ==> x = L"
paulson@13115
   322
apply (rule antisymE)
paulson@13115
   323
apply (rule CO_antisym)
paulson@13115
   324
apply (auto simp add: isLub_def r_def)
paulson@13115
   325
done
paulson@13115
   326
paulson@13115
   327
lemma (in CL) lub_upper: "[|S <= A; x \<in> S|] ==> (x, lub S cl) \<in> r"
paulson@13115
   328
apply (rule CL_imp_ex_isLub [THEN exE], assumption)
paulson@13115
   329
apply (unfold lub_def least_def)
paulson@13115
   330
apply (rule some_equality [THEN ssubst])
paulson@13115
   331
  apply (simp add: isLub_def)
paulson@13115
   332
 apply (simp add: lub_unique A_def isLub_def) 
paulson@13115
   333
apply (simp add: isLub_def r_def)
paulson@13115
   334
done
paulson@13115
   335
paulson@13115
   336
lemma (in CL) lub_least:
paulson@13115
   337
     "[| S <= A; L \<in> A; \<forall>x \<in> S. (x,L) \<in> r |] ==> (lub S cl, L) \<in> r"
paulson@13115
   338
apply (rule CL_imp_ex_isLub [THEN exE], assumption)
paulson@13115
   339
apply (unfold lub_def least_def)
paulson@13115
   340
apply (rule_tac s=x in some_equality [THEN ssubst])
paulson@13115
   341
  apply (simp add: isLub_def)
paulson@13115
   342
 apply (simp add: lub_unique A_def isLub_def) 
paulson@13115
   343
apply (simp add: isLub_def r_def A_def)
paulson@13115
   344
done
paulson@13115
   345
paulson@13115
   346
lemma (in CL) lub_in_lattice: "S <= A ==> lub S cl \<in> A"
paulson@13115
   347
apply (rule CL_imp_ex_isLub [THEN exE], assumption)
paulson@13115
   348
apply (unfold lub_def least_def)
paulson@13115
   349
apply (subst some_equality)
paulson@13115
   350
apply (simp add: isLub_def)
paulson@13115
   351
prefer 2 apply (simp add: isLub_def A_def)
paulson@13115
   352
apply (simp add: lub_unique A_def isLub_def) 
paulson@13115
   353
done
paulson@13115
   354
paulson@13115
   355
lemma (in CL) lubI:
paulson@13115
   356
     "[| S <= A; L \<in> A; \<forall>x \<in> S. (x,L) \<in> r; 
paulson@13115
   357
         \<forall>z \<in> A. (\<forall>y \<in> S. (y,z) \<in> r) --> (L,z) \<in> r |] ==> L = lub S cl"
paulson@13115
   358
apply (rule lub_unique, assumption)
paulson@13115
   359
apply (simp add: isLub_def A_def r_def)
paulson@13115
   360
apply (unfold isLub_def)
paulson@13115
   361
apply (rule conjI)
paulson@13115
   362
apply (fold A_def r_def)
paulson@13115
   363
apply (rule lub_in_lattice, assumption)
paulson@13115
   364
apply (simp add: lub_upper lub_least)
paulson@13115
   365
done
paulson@13115
   366
paulson@13115
   367
lemma (in CL) lubIa: "[| S <= A; isLub S cl L |] ==> L = lub S cl"
paulson@13115
   368
by (simp add: lubI isLub_def A_def r_def)
paulson@13115
   369
paulson@13115
   370
lemma (in CL) isLub_in_lattice: "isLub S cl L ==> L \<in> A"
paulson@13115
   371
by (simp add: isLub_def  A_def)
paulson@13115
   372
paulson@13115
   373
lemma (in CL) isLub_upper: "[|isLub S cl L; y \<in> S|] ==> (y, L) \<in> r"
paulson@13115
   374
by (simp add: isLub_def r_def)
paulson@13115
   375
paulson@13115
   376
lemma (in CL) isLub_least:
paulson@13115
   377
     "[| isLub S cl L; z \<in> A; \<forall>y \<in> S. (y, z) \<in> r|] ==> (L, z) \<in> r"
paulson@13115
   378
by (simp add: isLub_def A_def r_def)
paulson@13115
   379
paulson@13115
   380
lemma (in CL) isLubI:
paulson@13115
   381
     "[| L \<in> A; \<forall>y \<in> S. (y, L) \<in> r;  
paulson@13115
   382
         (\<forall>z \<in> A. (\<forall>y \<in> S. (y, z):r) --> (L, z) \<in> r)|] ==> isLub S cl L"
paulson@13115
   383
by (simp add: isLub_def A_def r_def)
paulson@13115
   384
paulson@13115
   385
(* glb *)
paulson@13115
   386
lemma (in CL) glb_in_lattice: "S <= A ==> glb S cl \<in> A"
paulson@13115
   387
apply (subst glb_dual_lub)
paulson@13115
   388
apply (simp add: A_def)
paulson@13115
   389
apply (rule dualA_iff [THEN subst])
paulson@13115
   390
apply (rule Tarski.lub_in_lattice)
paulson@13115
   391
apply (rule dualPO) 
paulson@13115
   392
apply (rule CL_dualCL)
paulson@13115
   393
apply (simp add: dualA_iff)
paulson@13115
   394
done
paulson@13115
   395
paulson@13115
   396
lemma (in CL) glb_lower: "[|S <= A; x \<in> S|] ==> (glb S cl, x) \<in> r"
paulson@13115
   397
apply (subst glb_dual_lub)
paulson@13115
   398
apply (simp add: r_def)
paulson@13115
   399
apply (rule dualr_iff [THEN subst])
paulson@13115
   400
apply (rule Tarski.lub_upper [rule_format])
paulson@13115
   401
apply (rule dualPO) 
paulson@13115
   402
apply (rule CL_dualCL)
paulson@13115
   403
apply (simp add: dualA_iff A_def, assumption)
paulson@13115
   404
done
paulson@13115
   405
paulson@13115
   406
(* Reduce the sublattice property by using substructural properties*)
paulson@13115
   407
(* abandoned see Tarski_4.ML *)
paulson@13115
   408
paulson@13115
   409
lemma (in CLF) [simp]:
paulson@13115
   410
    "f: cl.<A> funcset cl.<A> & monotone f (cl.<A>) (cl.<r>)"
paulson@13115
   411
apply (insert f_cl) 
paulson@13115
   412
apply (simp add: CLF_def) 
paulson@13115
   413
done
paulson@13115
   414
paulson@13115
   415
declare (in CLF) f_cl [simp]
paulson@13115
   416
paulson@13115
   417
paulson@13115
   418
lemma (in CLF) f_in_funcset: "f \<in> A funcset A"
paulson@13115
   419
by (simp add: A_def)
paulson@13115
   420
paulson@13115
   421
lemma (in CLF) monotone_f: "monotone f A r"
paulson@13115
   422
by (simp add: A_def r_def)
paulson@13115
   423
paulson@13115
   424
lemma (in CLF) CLF_dual: "(cl,f) \<in> CLF ==> (dual cl, f) \<in> CLF"
paulson@13115
   425
apply (simp add: CLF_def  CL_dualCL monotone_dual)
paulson@13115
   426
apply (simp add: dualA_iff)
paulson@13115
   427
done
paulson@13115
   428
paulson@13115
   429
(* fixed points *)
paulson@13115
   430
lemma fix_subset: "fix f A <= A"
paulson@13115
   431
by (simp add: fix_def, fast)
paulson@13115
   432
paulson@13115
   433
lemma fix_imp_eq: "x \<in> fix f A ==> f x = x"
paulson@13115
   434
by (simp add: fix_def)
paulson@13115
   435
paulson@13115
   436
lemma fixf_subset:
paulson@13115
   437
     "[| A <= B; x \<in> fix (%y: A. f y) A |] ==> x \<in> fix f B"
paulson@13115
   438
apply (simp add: fix_def, auto) 
paulson@13115
   439
done
paulson@13115
   440
paulson@13115
   441
(* lemmas for Tarski, lub *)
paulson@13115
   442
lemma (in CLF) lubH_le_flubH:
paulson@13115
   443
     "H = {x. (x, f x) \<in> r & x \<in> A} ==> (lub H cl, f (lub H cl)) \<in> r"
paulson@13115
   444
apply (rule lub_least, fast)
paulson@13115
   445
apply (rule f_in_funcset [THEN funcset_mem])
paulson@13115
   446
apply (rule lub_in_lattice, fast)
paulson@13115
   447
(* \<forall>x:H. (x, f (lub H r)) \<in> r *)
paulson@13115
   448
apply (rule ballI)
paulson@13115
   449
apply (rule transE)
paulson@13115
   450
apply (rule CO_trans)
paulson@13115
   451
(* instantiates (x, ???z) \<in> cl.<r> to (x, f x), because of the def of H *)
paulson@13115
   452
apply fast
paulson@13115
   453
(* so it remains to show (f x, f (lub H cl)) \<in> r *)
paulson@13115
   454
apply (rule_tac f = "f" in monotoneE)
paulson@13115
   455
apply (rule monotone_f, fast)
paulson@13115
   456
apply (rule lub_in_lattice, fast)
paulson@13115
   457
apply (rule lub_upper, fast)
paulson@13115
   458
apply assumption
paulson@13115
   459
done
paulson@13115
   460
paulson@13115
   461
lemma (in CLF) flubH_le_lubH:
paulson@13115
   462
     "[|  H = {x. (x, f x) \<in> r & x \<in> A} |] ==> (f (lub H cl), lub H cl) \<in> r"
paulson@13115
   463
apply (rule lub_upper, fast)
paulson@13115
   464
apply (rule_tac t = "H" in ssubst, assumption)
paulson@13115
   465
apply (rule CollectI)
paulson@13115
   466
apply (rule conjI)
paulson@13115
   467
apply (rule_tac [2] f_in_funcset [THEN funcset_mem])
paulson@13115
   468
apply (rule_tac [2] lub_in_lattice)
paulson@13115
   469
prefer 2 apply fast
paulson@13115
   470
apply (rule_tac f = "f" in monotoneE)
paulson@13115
   471
apply (rule monotone_f)
paulson@13115
   472
  apply (blast intro: lub_in_lattice) 
paulson@13115
   473
 apply (blast intro: lub_in_lattice f_in_funcset [THEN funcset_mem]) 
paulson@13115
   474
apply (simp add: lubH_le_flubH)
paulson@13115
   475
done
paulson@13115
   476
paulson@13115
   477
lemma (in CLF) lubH_is_fixp:
paulson@13115
   478
     "H = {x. (x, f x) \<in> r & x \<in> A} ==> lub H cl \<in> fix f A"
paulson@13115
   479
apply (simp add: fix_def)
paulson@13115
   480
apply (rule conjI)
paulson@13115
   481
apply (rule lub_in_lattice, fast)
paulson@13115
   482
apply (rule antisymE)
paulson@13115
   483
apply (rule CO_antisym)
paulson@13115
   484
apply (simp add: flubH_le_lubH)
paulson@13115
   485
apply (simp add: lubH_le_flubH)
paulson@13115
   486
done
paulson@13115
   487
paulson@13115
   488
lemma (in CLF) fix_in_H:
paulson@13115
   489
     "[| H = {x. (x, f x) \<in> r & x \<in> A};  x \<in> P |] ==> x \<in> H"
paulson@13115
   490
by (simp add: P_def fix_imp_eq [of _ f A] reflE CO_refl 
paulson@13115
   491
                    fix_subset [of f A, THEN subsetD]) 
paulson@13115
   492
paulson@13115
   493
lemma (in CLF) fixf_le_lubH:
paulson@13115
   494
     "H = {x. (x, f x) \<in> r & x \<in> A} ==> \<forall>x \<in> fix f A. (x, lub H cl) \<in> r"
paulson@13115
   495
apply (rule ballI)
paulson@13115
   496
apply (rule lub_upper, fast)
paulson@13115
   497
apply (rule fix_in_H)
paulson@13115
   498
apply (simp_all add: P_def) 
paulson@13115
   499
done
paulson@13115
   500
paulson@13115
   501
lemma (in CLF) lubH_least_fixf:
paulson@13115
   502
     "H = {x. (x, f x) \<in> r & x \<in> A} 
paulson@13115
   503
      ==> \<forall>L. (\<forall>y \<in> fix f A. (y,L) \<in> r) --> (lub H cl, L) \<in> r"
paulson@13115
   504
apply (rule allI)
paulson@13115
   505
apply (rule impI)
paulson@13115
   506
apply (erule bspec)
paulson@13115
   507
apply (rule lubH_is_fixp, assumption)
paulson@13115
   508
done
paulson@13115
   509
paulson@13115
   510
(* Tarski fixpoint theorem 1, first part *)
paulson@13115
   511
lemma (in CLF) T_thm_1_lub: "lub P cl = lub {x. (x, f x) \<in> r & x \<in> A} cl"
paulson@13115
   512
apply (rule sym)
paulson@13115
   513
apply (simp add: P_def) 
paulson@13115
   514
apply (rule lubI)
paulson@13115
   515
apply (rule fix_subset)
paulson@13115
   516
apply (rule lub_in_lattice, fast)
paulson@13115
   517
apply (simp add: fixf_le_lubH)
paulson@13115
   518
apply (simp add: lubH_least_fixf)
paulson@13115
   519
done
paulson@13115
   520
paulson@13115
   521
(* Tarski for glb *)
paulson@13115
   522
lemma (in CLF) glbH_is_fixp: "H = {x. (f x, x) \<in> r & x \<in> A} ==> glb H cl \<in> P"
paulson@13115
   523
apply (simp add: glb_dual_lub P_def A_def r_def)
paulson@13115
   524
apply (rule dualA_iff [THEN subst])
paulson@13115
   525
apply (rule Tarski.lubH_is_fixp)
paulson@13115
   526
apply (rule dualPO) 
paulson@13115
   527
apply (rule CL_dualCL)
paulson@13115
   528
apply (rule f_cl [THEN CLF_dual])
paulson@13115
   529
apply (simp add: dualr_iff dualA_iff)
paulson@13115
   530
done
paulson@13115
   531
paulson@13115
   532
lemma (in CLF) T_thm_1_glb: "glb P cl = glb {x. (f x, x) \<in> r & x \<in> A} cl"
paulson@13115
   533
apply (simp add: glb_dual_lub P_def A_def r_def)
paulson@13115
   534
apply (rule dualA_iff [THEN subst])
paulson@13115
   535
apply (simp add: Tarski.T_thm_1_lub [of _ f, OF dualPO CL_dualCL] 
paulson@13115
   536
                 dualPO CL_dualCL CLF_dual dualr_iff)
paulson@13115
   537
done
paulson@13115
   538
paulson@13115
   539
(* interval *)
paulson@13115
   540
lemma (in CLF) rel_imp_elem: "(x, y) \<in> r ==> x \<in> A"
paulson@13115
   541
apply (insert CO_refl) 
paulson@13115
   542
apply (simp add: refl_def, blast) 
paulson@13115
   543
done
paulson@13115
   544
paulson@13115
   545
lemma (in CLF) interval_subset: "[| a \<in> A; b \<in> A |] ==> interval r a b <= A"
paulson@13115
   546
apply (simp add: interval_def)
paulson@13115
   547
apply (blast intro: rel_imp_elem)
paulson@13115
   548
done
paulson@13115
   549
paulson@13115
   550
lemma (in CLF) intervalI:
paulson@13115
   551
     "[| (a, x) \<in> r; (x, b) \<in> r |] ==> x \<in> interval r a b"
paulson@13115
   552
apply (simp add: interval_def)
paulson@13115
   553
done
paulson@13115
   554
paulson@13115
   555
lemma (in CLF) interval_lemma1:
paulson@13115
   556
     "[| S <= interval r a b; x \<in> S |] ==> (a, x) \<in> r"
paulson@13115
   557
apply (unfold interval_def, fast)
paulson@13115
   558
done
paulson@13115
   559
paulson@13115
   560
lemma (in CLF) interval_lemma2:
paulson@13115
   561
     "[| S <= interval r a b; x \<in> S |] ==> (x, b) \<in> r"
paulson@13115
   562
apply (unfold interval_def, fast)
paulson@13115
   563
done
paulson@13115
   564
paulson@13115
   565
lemma (in CLF) a_less_lub:
paulson@13115
   566
     "[| S <= A; S \<noteq> {}; 
paulson@13115
   567
         \<forall>x \<in> S. (a,x) \<in> r; \<forall>y \<in> S. (y, L) \<in> r |] ==> (a,L) \<in> r"
paulson@13115
   568
by (blast intro: transE PO_imp_trans)
paulson@13115
   569
paulson@13115
   570
lemma (in CLF) glb_less_b:
paulson@13115
   571
     "[| S <= A; S \<noteq> {}; 
paulson@13115
   572
         \<forall>x \<in> S. (x,b) \<in> r; \<forall>y \<in> S. (G, y) \<in> r |] ==> (G,b) \<in> r"
paulson@13115
   573
by (blast intro: transE PO_imp_trans)
paulson@13115
   574
paulson@13115
   575
lemma (in CLF) S_intv_cl:
paulson@13115
   576
     "[| a \<in> A; b \<in> A; S <= interval r a b |]==> S <= A"
paulson@13115
   577
by (simp add: subset_trans [OF _ interval_subset])
paulson@13115
   578
paulson@13115
   579
lemma (in CLF) L_in_interval:
paulson@13115
   580
     "[| a \<in> A; b \<in> A; S <= interval r a b;  
paulson@13115
   581
         S \<noteq> {}; isLub S cl L; interval r a b \<noteq> {} |] ==> L \<in> interval r a b"
paulson@13115
   582
apply (rule intervalI)
paulson@13115
   583
apply (rule a_less_lub)
paulson@13115
   584
prefer 2 apply assumption
paulson@13115
   585
apply (simp add: S_intv_cl)
paulson@13115
   586
apply (rule ballI)
paulson@13115
   587
apply (simp add: interval_lemma1)
paulson@13115
   588
apply (simp add: isLub_upper)
paulson@13115
   589
(* (L, b) \<in> r *)
paulson@13115
   590
apply (simp add: isLub_least interval_lemma2)
paulson@13115
   591
done
paulson@13115
   592
paulson@13115
   593
lemma (in CLF) G_in_interval:
paulson@13115
   594
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {}; S <= interval r a b; isGlb S cl G;
paulson@13115
   595
         S \<noteq> {} |] ==> G \<in> interval r a b"
paulson@13115
   596
apply (simp add: interval_dual)
paulson@13115
   597
apply (simp add: Tarski.L_in_interval [of _ f] 
paulson@13115
   598
                 dualA_iff A_def dualPO CL_dualCL CLF_dual isGlb_dual_isLub)
paulson@13115
   599
done
paulson@13115
   600
paulson@13115
   601
lemma (in CLF) intervalPO:
paulson@13115
   602
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |] 
paulson@13115
   603
      ==> (| pset = interval r a b, order = induced (interval r a b) r |)
paulson@13115
   604
          \<in> PartialOrder"
paulson@13115
   605
apply (rule po_subset_po)
paulson@13115
   606
apply (simp add: interval_subset)
paulson@13115
   607
done
paulson@13115
   608
paulson@13115
   609
lemma (in CLF) intv_CL_lub:
paulson@13115
   610
 "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |] 
paulson@13115
   611
  ==> \<forall>S. S <= interval r a b --> 
paulson@13115
   612
          (\<exists>L. isLub S (| pset = interval r a b, 
paulson@13115
   613
                          order = induced (interval r a b) r |)  L)"
paulson@13115
   614
apply (intro strip)
paulson@13115
   615
apply (frule S_intv_cl [THEN CL_imp_ex_isLub])
paulson@13115
   616
prefer 2 apply assumption
paulson@13115
   617
apply assumption
paulson@13115
   618
apply (erule exE)
paulson@13115
   619
(* define the lub for the interval as *)
paulson@13115
   620
apply (rule_tac x = "if S = {} then a else L" in exI)
paulson@13115
   621
apply (simp (no_asm_simp) add: isLub_def split del: split_if)
paulson@13115
   622
apply (intro impI conjI) 
paulson@13115
   623
(* (if S = {} then a else L) \<in> interval r a b *)
paulson@13115
   624
apply (simp add: CL_imp_PO L_in_interval)
paulson@13115
   625
apply (simp add: left_in_interval)
paulson@13115
   626
(* lub prop 1 *)
paulson@13115
   627
apply (case_tac "S = {}")
paulson@13115
   628
(* S = {}, y \<in> S = False => everything *)
paulson@13115
   629
apply fast
paulson@13115
   630
(* S \<noteq> {} *)
paulson@13115
   631
apply simp
paulson@13115
   632
(* \<forall>y:S. (y, L) \<in> induced (interval r a b) r *)
paulson@13115
   633
apply (rule ballI)
paulson@13115
   634
apply (simp add: induced_def  L_in_interval)
paulson@13115
   635
apply (rule conjI)
paulson@13115
   636
apply (rule subsetD)
paulson@13115
   637
apply (simp add: S_intv_cl, assumption)
paulson@13115
   638
apply (simp add: isLub_upper)
paulson@13115
   639
(* \<forall>z:interval r a b. (\<forall>y:S. (y, z) \<in> induced (interval r a b) r -->
paulson@13115
   640
      (if S = {} then a else L, z) \<in> induced (interval r a b) r *)
paulson@13115
   641
apply (rule ballI)
paulson@13115
   642
apply (rule impI)
paulson@13115
   643
apply (case_tac "S = {}")
paulson@13115
   644
(* S = {} *)
paulson@13115
   645
apply simp
paulson@13115
   646
apply (simp add: induced_def  interval_def)
paulson@13115
   647
apply (rule conjI)
paulson@13115
   648
apply (rule reflE)
paulson@13115
   649
apply (rule CO_refl, assumption)
paulson@13115
   650
apply (rule interval_not_empty)
paulson@13115
   651
apply (rule CO_trans)
paulson@13115
   652
apply (simp add: interval_def)
paulson@13115
   653
(* S \<noteq> {} *)
paulson@13115
   654
apply simp
paulson@13115
   655
apply (simp add: induced_def  L_in_interval)
paulson@13115
   656
apply (rule isLub_least, assumption)
paulson@13115
   657
apply (rule subsetD)
paulson@13115
   658
prefer 2 apply assumption
paulson@13115
   659
apply (simp add: S_intv_cl, fast)
paulson@13115
   660
done
paulson@13115
   661
paulson@13115
   662
lemmas (in CLF) intv_CL_glb = intv_CL_lub [THEN Rdual]
paulson@13115
   663
paulson@13115
   664
lemma (in CLF) interval_is_sublattice:
paulson@13115
   665
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |] 
paulson@13115
   666
        ==> interval r a b <<= cl"
paulson@13115
   667
apply (rule sublatticeI)
paulson@13115
   668
apply (simp add: interval_subset)
paulson@13115
   669
apply (rule CompleteLatticeI)
paulson@13115
   670
apply (simp add: intervalPO)
paulson@13115
   671
 apply (simp add: intv_CL_lub)
paulson@13115
   672
apply (simp add: intv_CL_glb)
paulson@13115
   673
done
paulson@13115
   674
paulson@13115
   675
lemmas (in CLF) interv_is_compl_latt = 
paulson@13115
   676
    interval_is_sublattice [THEN sublattice_imp_CL]
paulson@13115
   677
paulson@13115
   678
(* Top and Bottom *)
paulson@13115
   679
lemma (in CLF) Top_dual_Bot: "Top cl = Bot (dual cl)"
paulson@13115
   680
by (simp add: Top_def Bot_def least_def greatest_def dualA_iff dualr_iff)
paulson@13115
   681
paulson@13115
   682
lemma (in CLF) Bot_dual_Top: "Bot cl = Top (dual cl)"
paulson@13115
   683
by (simp add: Top_def Bot_def least_def greatest_def dualA_iff dualr_iff)
paulson@13115
   684
paulson@13115
   685
lemma (in CLF) Bot_in_lattice: "Bot cl \<in> A"
paulson@13115
   686
apply (simp add: Bot_def least_def)
paulson@13115
   687
apply (rule someI2)
paulson@13115
   688
apply (fold A_def)
paulson@13115
   689
apply (erule_tac [2] conjunct1)
paulson@13115
   690
apply (rule conjI)
paulson@13115
   691
apply (rule glb_in_lattice)
paulson@13115
   692
apply (rule subset_refl)
paulson@13115
   693
apply (fold r_def)
paulson@13115
   694
apply (simp add: glb_lower)
paulson@13115
   695
done
paulson@13115
   696
paulson@13115
   697
lemma (in CLF) Top_in_lattice: "Top cl \<in> A"
paulson@13115
   698
apply (simp add: Top_dual_Bot A_def)
paulson@13115
   699
apply (rule dualA_iff [THEN subst])  
paulson@13115
   700
apply (blast intro!: Tarski.Bot_in_lattice dualPO CL_dualCL CLF_dual f_cl) 
paulson@13115
   701
done
paulson@13115
   702
paulson@13115
   703
lemma (in CLF) Top_prop: "x \<in> A ==> (x, Top cl) \<in> r"
paulson@13115
   704
apply (simp add: Top_def greatest_def)
paulson@13115
   705
apply (rule someI2)
paulson@13115
   706
apply (fold r_def  A_def)
paulson@13115
   707
prefer 2 apply fast
paulson@13115
   708
apply (intro conjI ballI)
paulson@13115
   709
apply (rule_tac [2] lub_upper)
paulson@13115
   710
apply (auto simp add: lub_in_lattice)
paulson@13115
   711
done
paulson@13115
   712
paulson@13115
   713
lemma (in CLF) Bot_prop: "x \<in> A ==> (Bot cl, x) \<in> r"
paulson@13115
   714
apply (simp add: Bot_dual_Top r_def)
paulson@13115
   715
apply (rule dualr_iff [THEN subst])
paulson@13115
   716
apply (simp add: Tarski.Top_prop [of _ f] 
paulson@13115
   717
                 dualA_iff A_def dualPO CL_dualCL CLF_dual)
paulson@13115
   718
done
paulson@13115
   719
paulson@13115
   720
lemma (in CLF) Top_intv_not_empty: "x \<in> A  ==> interval r x (Top cl) \<noteq> {}"
paulson@13115
   721
apply (rule notI)
paulson@13115
   722
apply (drule_tac a = "Top cl" in equals0D)
paulson@13115
   723
apply (simp add: interval_def)
paulson@13115
   724
apply (simp add: refl_def Top_in_lattice Top_prop)
paulson@13115
   725
done
paulson@13115
   726
paulson@13115
   727
lemma (in CLF) Bot_intv_not_empty: "x \<in> A ==> interval r (Bot cl) x \<noteq> {}"
paulson@13115
   728
apply (simp add: Bot_dual_Top)
paulson@13115
   729
apply (subst interval_dual)
paulson@13115
   730
prefer 2 apply assumption
paulson@13115
   731
apply (simp add: A_def)
paulson@13115
   732
apply (rule dualA_iff [THEN subst])
paulson@13115
   733
apply (blast intro!: Tarski.Top_in_lattice
paulson@13115
   734
                 f_cl dualPO CL_dualCL CLF_dual)
paulson@13115
   735
apply (simp add: Tarski.Top_intv_not_empty [of _ f] 
paulson@13115
   736
                 dualA_iff A_def dualPO CL_dualCL CLF_dual)
paulson@13115
   737
done
paulson@13115
   738
paulson@13115
   739
(* fixed points form a partial order *)
paulson@13115
   740
lemma (in CLF) fixf_po: "(| pset = P, order = induced P r|) \<in> PartialOrder"
paulson@13115
   741
by (simp add: P_def fix_subset po_subset_po)
paulson@13115
   742
paulson@13115
   743
lemma (in Tarski) Y_subset_A: "Y <= A"
paulson@13115
   744
apply (rule subset_trans [OF _ fix_subset])
paulson@13115
   745
apply (rule Y_ss [simplified P_def])
paulson@13115
   746
done
paulson@13115
   747
paulson@13115
   748
lemma (in Tarski) lubY_in_A: "lub Y cl \<in> A"
paulson@13115
   749
by (simp add: Y_subset_A [THEN lub_in_lattice])
paulson@13115
   750
paulson@13115
   751
lemma (in Tarski) lubY_le_flubY: "(lub Y cl, f (lub Y cl)) \<in> r"
paulson@13115
   752
apply (rule lub_least)
paulson@13115
   753
apply (rule Y_subset_A)
paulson@13115
   754
apply (rule f_in_funcset [THEN funcset_mem])
paulson@13115
   755
apply (rule lubY_in_A)
paulson@13115
   756
(* Y <= P ==> f x = x *)
paulson@13115
   757
apply (rule ballI)
paulson@13115
   758
apply (rule_tac t = "x" in fix_imp_eq [THEN subst])
paulson@13115
   759
apply (erule Y_ss [simplified P_def, THEN subsetD])
paulson@13115
   760
(* reduce (f x, f (lub Y cl)) \<in> r to (x, lub Y cl) \<in> r by monotonicity *)
paulson@13115
   761
apply (rule_tac f = "f" in monotoneE)
paulson@13115
   762
apply (rule monotone_f)
paulson@13115
   763
apply (simp add: Y_subset_A [THEN subsetD])
paulson@13115
   764
apply (rule lubY_in_A)
paulson@13115
   765
apply (simp add: lub_upper Y_subset_A)
paulson@13115
   766
done
paulson@13115
   767
paulson@13115
   768
lemma (in Tarski) intY1_subset: "intY1 <= A"
paulson@13115
   769
apply (unfold intY1_def)
paulson@13115
   770
apply (rule interval_subset)
paulson@13115
   771
apply (rule lubY_in_A)
paulson@13115
   772
apply (rule Top_in_lattice)
paulson@13115
   773
done
paulson@13115
   774
paulson@13115
   775
lemmas (in Tarski) intY1_elem = intY1_subset [THEN subsetD]
paulson@13115
   776
paulson@13115
   777
lemma (in Tarski) intY1_f_closed: "x \<in> intY1 \<Longrightarrow> f x \<in> intY1"
paulson@13115
   778
apply (simp add: intY1_def  interval_def)
paulson@13115
   779
apply (rule conjI)
paulson@13115
   780
apply (rule transE)
paulson@13115
   781
apply (rule CO_trans)
paulson@13115
   782
apply (rule lubY_le_flubY)
paulson@13115
   783
(* (f (lub Y cl), f x) \<in> r *)
paulson@13115
   784
apply (rule_tac f=f in monotoneE)
paulson@13115
   785
apply (rule monotone_f)
paulson@13115
   786
apply (rule lubY_in_A)
paulson@13115
   787
apply (simp add: intY1_def interval_def  intY1_elem)
paulson@13115
   788
apply (simp add: intY1_def  interval_def)
paulson@13115
   789
(* (f x, Top cl) \<in> r *)
paulson@13115
   790
apply (rule Top_prop)
paulson@13115
   791
apply (rule f_in_funcset [THEN funcset_mem])
paulson@13115
   792
apply (simp add: intY1_def interval_def  intY1_elem)
paulson@13115
   793
done
paulson@13115
   794
paulson@13115
   795
lemma (in Tarski) intY1_func: "(%x: intY1. f x) \<in> intY1 funcset intY1"
paulson@13115
   796
apply (rule restrictI)
paulson@13115
   797
apply (erule intY1_f_closed)
paulson@13115
   798
done
paulson@13115
   799
paulson@13115
   800
lemma (in Tarski) intY1_mono:
paulson@13115
   801
     "monotone (%x: intY1. f x) intY1 (induced intY1 r)"
paulson@13115
   802
apply (auto simp add: monotone_def induced_def intY1_f_closed)
paulson@13115
   803
apply (blast intro: intY1_elem monotone_f [THEN monotoneE])
paulson@13115
   804
done
paulson@13115
   805
paulson@13115
   806
lemma (in Tarski) intY1_is_cl: 
paulson@13115
   807
    "(| pset = intY1, order = induced intY1 r |) \<in> CompleteLattice"
paulson@13115
   808
apply (unfold intY1_def)
paulson@13115
   809
apply (rule interv_is_compl_latt)
paulson@13115
   810
apply (rule lubY_in_A)
paulson@13115
   811
apply (rule Top_in_lattice)
paulson@13115
   812
apply (rule Top_intv_not_empty)
paulson@13115
   813
apply (rule lubY_in_A)
paulson@13115
   814
done
paulson@13115
   815
paulson@13115
   816
lemma (in Tarski) v_in_P: "v \<in> P"
paulson@13115
   817
apply (unfold P_def)
paulson@13115
   818
apply (rule_tac A = "intY1" in fixf_subset)
paulson@13115
   819
apply (rule intY1_subset)
paulson@13115
   820
apply (simp add: Tarski.glbH_is_fixp [OF _ intY1_is_cl, simplified]
paulson@13115
   821
                 v_def CL_imp_PO intY1_is_cl CLF_def intY1_func intY1_mono)
paulson@13115
   822
done
paulson@13115
   823
paulson@13115
   824
lemma (in Tarski) z_in_interval: 
paulson@13115
   825
     "[| z \<in> P; \<forall>y\<in>Y. (y, z) \<in> induced P r |] ==> z \<in> intY1"
paulson@13115
   826
apply (unfold intY1_def P_def)
paulson@13115
   827
apply (rule intervalI)
paulson@13115
   828
prefer 2 
paulson@13115
   829
 apply (erule fix_subset [THEN subsetD, THEN Top_prop])
paulson@13115
   830
apply (rule lub_least)
paulson@13115
   831
apply (rule Y_subset_A)
paulson@13115
   832
apply (fast elim!: fix_subset [THEN subsetD])
paulson@13115
   833
apply (simp add: induced_def)
paulson@13115
   834
done
paulson@13115
   835
paulson@13115
   836
lemma (in Tarski) f'z_in_int_rel: "[| z \<in> P; \<forall>y\<in>Y. (y, z) \<in> induced P r |] 
paulson@13115
   837
      ==> ((%x: intY1. f x) z, z) \<in> induced intY1 r"
paulson@13115
   838
apply (simp add: induced_def  intY1_f_closed z_in_interval P_def)
paulson@13115
   839
apply (simp add: fix_imp_eq [of _ f A] fix_subset [of f A, THEN subsetD] 
paulson@13115
   840
                 CO_refl [THEN reflE])
paulson@13115
   841
done
paulson@13115
   842
paulson@13115
   843
lemma (in Tarski) tarski_full_lemma:
paulson@13115
   844
     "\<exists>L. isLub Y (| pset = P, order = induced P r |) L"
paulson@13115
   845
apply (rule_tac x = "v" in exI)
paulson@13115
   846
apply (simp add: isLub_def)
paulson@13115
   847
(* v \<in> P *)
paulson@13115
   848
apply (simp add: v_in_P)
paulson@13115
   849
apply (rule conjI)
paulson@13115
   850
(* v is lub *)
paulson@13115
   851
(*  1. \<forall>y:Y. (y, v) \<in> induced P r *)
paulson@13115
   852
apply (rule ballI)
paulson@13115
   853
apply (simp add: induced_def subsetD v_in_P)
paulson@13115
   854
apply (rule conjI)
paulson@13115
   855
apply (erule Y_ss [THEN subsetD])
paulson@13115
   856
apply (rule_tac b = "lub Y cl" in transE)
paulson@13115
   857
apply (rule CO_trans)
paulson@13115
   858
apply (rule lub_upper)
paulson@13115
   859
apply (rule Y_subset_A, assumption)
paulson@13115
   860
apply (rule_tac b = "Top cl" in interval_imp_mem)
paulson@13115
   861
apply (simp add: v_def)
paulson@13115
   862
apply (fold intY1_def)
paulson@13115
   863
apply (rule Tarski.glb_in_lattice [OF _ intY1_is_cl, simplified])
paulson@13115
   864
 apply (simp add: CL_imp_PO intY1_is_cl, force)
paulson@13115
   865
(* v is LEAST ub *)
paulson@13115
   866
apply clarify
paulson@13115
   867
apply (rule indI)
paulson@13115
   868
  prefer 3 apply assumption
paulson@13115
   869
 prefer 2 apply (simp add: v_in_P)
paulson@13115
   870
apply (unfold v_def)
paulson@13115
   871
apply (rule indE)
paulson@13115
   872
apply (rule_tac [2] intY1_subset)
paulson@13115
   873
apply (rule Tarski.glb_lower [OF _ intY1_is_cl, simplified])
paulson@13115
   874
  apply (simp add: CL_imp_PO intY1_is_cl) 
paulson@13115
   875
 apply force
paulson@13115
   876
apply (simp add: induced_def intY1_f_closed z_in_interval)
paulson@13115
   877
apply (simp add: P_def fix_imp_eq [of _ f A] 
paulson@13115
   878
                 fix_subset [of f A, THEN subsetD] 
paulson@13115
   879
                 CO_refl [THEN reflE])
paulson@13115
   880
done
paulson@13115
   881
paulson@13115
   882
paulson@13115
   883
lemma CompleteLatticeI_simp:
paulson@13115
   884
     "[| (| pset = A, order = r |) \<in> PartialOrder; 
paulson@13115
   885
         \<forall>S. S <= A --> (\<exists>L. isLub S (| pset = A, order = r |)  L) |]  
paulson@13115
   886
    ==> (| pset = A, order = r |) \<in> CompleteLattice"
paulson@13115
   887
by (simp add: CompleteLatticeI Rdual)
paulson@13115
   888
paulson@13115
   889
theorem (in CLF) Tarski_full:
paulson@13115
   890
     "(| pset = P, order = induced P r|) \<in> CompleteLattice"
paulson@13115
   891
apply (rule CompleteLatticeI_simp)
paulson@13115
   892
apply (rule fixf_po, clarify)
paulson@13115
   893
apply (simp add: P_def A_def r_def) 
paulson@13115
   894
apply (blast intro!: Tarski.tarski_full_lemma cl_po cl_co f_cl) 
paulson@13115
   895
done
wenzelm@7112
   896
wenzelm@7112
   897
end