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