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