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