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