src/HOL/Metis_Examples/Tarski.thy
author haftmann
Mon Jun 05 15:59:41 2017 +0200 (2017-06-05)
changeset 66010 2f7d39285a1a
parent 64913 3a9eb793fa10
child 66453 cc19f7ca2ed6
permissions -rw-r--r--
executable domain membership checks
blanchet@41141
     1
(*  Title:      HOL/Metis_Examples/Tarski.thy
blanchet@43197
     2
    Author:     Lawrence C. Paulson, Cambridge University Computer Laboratory
blanchet@41144
     3
    Author:     Jasmin Blanchette, TU Muenchen
paulson@23449
     4
blanchet@43197
     5
Metis example featuring the full theorem of Tarski.
paulson@23449
     6
*)
paulson@23449
     7
wenzelm@63167
     8
section \<open>Metis Example Featuring the Full Theorem of Tarski\<close>
paulson@23449
     9
haftmann@27368
    10
theory Tarski
wenzelm@41413
    11
imports Main "~~/src/HOL/Library/FuncSet"
haftmann@27368
    12
begin
paulson@23449
    13
blanchet@50705
    14
declare [[metis_new_skolem]]
blanchet@42103
    15
paulson@23449
    16
(*Many of these higher-order problems appear to be impossible using the
paulson@23449
    17
current linkup. They often seem to need either higher-order unification
paulson@23449
    18
or explicit reasoning about connectives such as conjunction. The numerous
paulson@23449
    19
set comprehensions are to blame.*)
paulson@23449
    20
paulson@23449
    21
record 'a potype =
paulson@23449
    22
  pset  :: "'a set"
paulson@23449
    23
  order :: "('a * 'a) set"
paulson@23449
    24
haftmann@35416
    25
definition monotone :: "['a => 'a, 'a set, ('a *'a)set] => bool" where
paulson@23449
    26
  "monotone f A r == \<forall>x\<in>A. \<forall>y\<in>A. (x, y): r --> ((f x), (f y)) : r"
paulson@23449
    27
haftmann@35416
    28
definition least :: "['a => bool, 'a potype] => 'a" where
paulson@23449
    29
  "least P po == @ x. x: pset po & P x &
paulson@23449
    30
                       (\<forall>y \<in> pset po. P y --> (x,y): order po)"
paulson@23449
    31
haftmann@35416
    32
definition greatest :: "['a => bool, 'a potype] => 'a" where
paulson@23449
    33
  "greatest P po == @ x. x: pset po & P x &
paulson@23449
    34
                          (\<forall>y \<in> pset po. P y --> (y,x): order po)"
paulson@23449
    35
haftmann@35416
    36
definition lub  :: "['a set, 'a potype] => 'a" where
wenzelm@64913
    37
  "lub S po == least (\<lambda>x. \<forall>y\<in>S. (y,x): order po) po"
paulson@23449
    38
haftmann@35416
    39
definition glb  :: "['a set, 'a potype] => 'a" where
wenzelm@64913
    40
  "glb S po == greatest (\<lambda>x. \<forall>y\<in>S. (x,y): order po) po"
paulson@23449
    41
haftmann@35416
    42
definition isLub :: "['a set, 'a potype, 'a] => bool" where
wenzelm@64913
    43
  "isLub S po == \<lambda>L. (L: pset po & (\<forall>y\<in>S. (y,L): order po) &
paulson@23449
    44
                   (\<forall>z\<in>pset po. (\<forall>y\<in>S. (y,z): order po) --> (L,z): order po))"
paulson@23449
    45
haftmann@35416
    46
definition isGlb :: "['a set, 'a potype, 'a] => bool" where
wenzelm@64913
    47
  "isGlb S po == \<lambda>G. (G: pset po & (\<forall>y\<in>S. (G,y): order po) &
paulson@23449
    48
                 (\<forall>z \<in> pset po. (\<forall>y\<in>S. (z,y): order po) --> (z,G): order po))"
paulson@23449
    49
haftmann@35416
    50
definition "fix"    :: "[('a => 'a), 'a set] => 'a set" where
paulson@23449
    51
  "fix f A  == {x. x: A & f x = x}"
paulson@23449
    52
haftmann@35416
    53
definition interval :: "[('a*'a) set,'a, 'a ] => 'a set" where
paulson@23449
    54
  "interval r a b == {x. (a,x): r & (x,b): r}"
paulson@23449
    55
haftmann@35416
    56
definition Bot :: "'a potype => 'a" where
wenzelm@64913
    57
  "Bot po == least (\<lambda>x. True) po"
paulson@23449
    58
haftmann@35416
    59
definition Top :: "'a potype => 'a" where
wenzelm@64913
    60
  "Top po == greatest (\<lambda>x. True) po"
paulson@23449
    61
haftmann@35416
    62
definition PartialOrder :: "('a potype) set" where
nipkow@30198
    63
  "PartialOrder == {P. refl_on (pset P) (order P) & antisym (order P) &
paulson@23449
    64
                       trans (order P)}"
paulson@23449
    65
haftmann@35416
    66
definition CompleteLattice :: "('a potype) set" where
paulson@23449
    67
  "CompleteLattice == {cl. cl: PartialOrder &
paulson@23449
    68
                        (\<forall>S. S \<subseteq> pset cl --> (\<exists>L. isLub S cl L)) &
paulson@23449
    69
                        (\<forall>S. S \<subseteq> pset cl --> (\<exists>G. isGlb S cl G))}"
paulson@23449
    70
haftmann@35416
    71
definition induced :: "['a set, ('a * 'a) set] => ('a *'a)set" where
paulson@23449
    72
  "induced A r == {(a,b). a : A & b: A & (a,b): r}"
paulson@23449
    73
haftmann@35416
    74
definition sublattice :: "('a potype * 'a set)set" where
paulson@23449
    75
  "sublattice ==
paulson@23449
    76
      SIGMA cl: CompleteLattice.
paulson@23449
    77
          {S. S \<subseteq> pset cl &
paulson@23449
    78
           (| pset = S, order = induced S (order cl) |): CompleteLattice }"
paulson@23449
    79
wenzelm@35054
    80
abbreviation
wenzelm@35054
    81
  sublattice_syntax :: "['a set, 'a potype] => bool" ("_ <<= _" [51, 50] 50)
wenzelm@35054
    82
  where "S <<= cl \<equiv> S : sublattice `` {cl}"
paulson@23449
    83
haftmann@35416
    84
definition dual :: "'a potype => 'a potype" where
paulson@23449
    85
  "dual po == (| pset = pset po, order = converse (order po) |)"
paulson@23449
    86
haftmann@27681
    87
locale PO =
paulson@23449
    88
  fixes cl :: "'a potype"
paulson@23449
    89
    and A  :: "'a set"
paulson@23449
    90
    and r  :: "('a * 'a) set"
paulson@23449
    91
  assumes cl_po:  "cl : PartialOrder"
paulson@23449
    92
  defines A_def: "A == pset cl"
paulson@23449
    93
     and  r_def: "r == order cl"
paulson@23449
    94
haftmann@27681
    95
locale CL = PO +
paulson@23449
    96
  assumes cl_co:  "cl : CompleteLattice"
paulson@23449
    97
haftmann@27681
    98
definition CLF_set :: "('a potype * ('a => 'a)) set" where
haftmann@27681
    99
  "CLF_set = (SIGMA cl: CompleteLattice.
wenzelm@61384
   100
            {f. f: pset cl \<rightarrow> pset cl & monotone f (pset cl) (order cl)})"
haftmann@27681
   101
haftmann@27681
   102
locale CLF = CL +
paulson@23449
   103
  fixes f :: "'a => 'a"
paulson@23449
   104
    and P :: "'a set"
haftmann@27681
   105
  assumes f_cl:  "(cl,f) : CLF_set" (*was the equivalent "f : CLF``{cl}"*)
paulson@23449
   106
  defines P_def: "P == fix f A"
paulson@23449
   107
haftmann@27681
   108
locale Tarski = CLF +
paulson@23449
   109
  fixes Y     :: "'a set"
paulson@23449
   110
    and intY1 :: "'a set"
paulson@23449
   111
    and v     :: "'a"
paulson@23449
   112
  assumes
paulson@23449
   113
    Y_ss: "Y \<subseteq> P"
paulson@23449
   114
  defines
paulson@23449
   115
    intY1_def: "intY1 == interval r (lub Y cl) (Top cl)"
wenzelm@64913
   116
    and v_def: "v == glb {x. ((\<lambda>x \<in> intY1. f x) x, x): induced intY1 r &
paulson@23449
   117
                             x: intY1}
paulson@23449
   118
                      (| pset=intY1, order=induced intY1 r|)"
paulson@23449
   119
wenzelm@63167
   120
subsection \<open>Partial Order\<close>
paulson@23449
   121
nipkow@30198
   122
lemma (in PO) PO_imp_refl_on: "refl_on A r"
paulson@23449
   123
apply (insert cl_po)
paulson@23449
   124
apply (simp add: PartialOrder_def A_def r_def)
paulson@23449
   125
done
paulson@23449
   126
paulson@23449
   127
lemma (in PO) PO_imp_sym: "antisym r"
paulson@23449
   128
apply (insert cl_po)
paulson@23449
   129
apply (simp add: PartialOrder_def r_def)
paulson@23449
   130
done
paulson@23449
   131
paulson@23449
   132
lemma (in PO) PO_imp_trans: "trans r"
paulson@23449
   133
apply (insert cl_po)
paulson@23449
   134
apply (simp add: PartialOrder_def r_def)
paulson@23449
   135
done
paulson@23449
   136
paulson@23449
   137
lemma (in PO) reflE: "x \<in> A ==> (x, x) \<in> r"
paulson@23449
   138
apply (insert cl_po)
nipkow@30198
   139
apply (simp add: PartialOrder_def refl_on_def A_def r_def)
paulson@23449
   140
done
paulson@23449
   141
paulson@23449
   142
lemma (in PO) antisymE: "[| (a, b) \<in> r; (b, a) \<in> r |] ==> a = b"
paulson@23449
   143
apply (insert cl_po)
paulson@23449
   144
apply (simp add: PartialOrder_def antisym_def r_def)
paulson@23449
   145
done
paulson@23449
   146
paulson@23449
   147
lemma (in PO) transE: "[| (a, b) \<in> r; (b, c) \<in> r|] ==> (a,c) \<in> r"
paulson@23449
   148
apply (insert cl_po)
paulson@23449
   149
apply (simp add: PartialOrder_def r_def)
paulson@23449
   150
apply (unfold trans_def, fast)
paulson@23449
   151
done
paulson@23449
   152
paulson@23449
   153
lemma (in PO) monotoneE:
paulson@23449
   154
     "[| monotone f A r;  x \<in> A; y \<in> A; (x, y) \<in> r |] ==> (f x, f y) \<in> r"
paulson@23449
   155
by (simp add: monotone_def)
paulson@23449
   156
paulson@23449
   157
lemma (in PO) po_subset_po:
paulson@23449
   158
     "S \<subseteq> A ==> (| pset = S, order = induced S r |) \<in> PartialOrder"
paulson@23449
   159
apply (simp (no_asm) add: PartialOrder_def)
paulson@23449
   160
apply auto
wenzelm@63167
   161
\<comment> \<open>refl\<close>
nipkow@30198
   162
apply (simp add: refl_on_def induced_def)
paulson@23449
   163
apply (blast intro: reflE)
wenzelm@63167
   164
\<comment> \<open>antisym\<close>
paulson@23449
   165
apply (simp add: antisym_def induced_def)
paulson@23449
   166
apply (blast intro: antisymE)
wenzelm@63167
   167
\<comment> \<open>trans\<close>
paulson@23449
   168
apply (simp add: trans_def induced_def)
paulson@23449
   169
apply (blast intro: transE)
paulson@23449
   170
done
paulson@23449
   171
paulson@23449
   172
lemma (in PO) indE: "[| (x, y) \<in> induced S r; S \<subseteq> A |] ==> (x, y) \<in> r"
paulson@23449
   173
by (simp add: add: induced_def)
paulson@23449
   174
paulson@23449
   175
lemma (in PO) indI: "[| (x, y) \<in> r; x \<in> S; y \<in> S |] ==> (x, y) \<in> induced S r"
paulson@23449
   176
by (simp add: add: induced_def)
paulson@23449
   177
paulson@23449
   178
lemma (in CL) CL_imp_ex_isLub: "S \<subseteq> A ==> \<exists>L. isLub S cl L"
paulson@23449
   179
apply (insert cl_co)
paulson@23449
   180
apply (simp add: CompleteLattice_def A_def)
paulson@23449
   181
done
paulson@23449
   182
paulson@23449
   183
declare (in CL) cl_co [simp]
paulson@23449
   184
paulson@23449
   185
lemma isLub_lub: "(\<exists>L. isLub S cl L) = isLub S cl (lub S cl)"
paulson@23449
   186
by (simp add: lub_def least_def isLub_def some_eq_ex [symmetric])
paulson@23449
   187
paulson@23449
   188
lemma isGlb_glb: "(\<exists>G. isGlb S cl G) = isGlb S cl (glb S cl)"
paulson@23449
   189
by (simp add: glb_def greatest_def isGlb_def some_eq_ex [symmetric])
paulson@23449
   190
paulson@23449
   191
lemma isGlb_dual_isLub: "isGlb S cl = isLub S (dual cl)"
haftmann@46752
   192
by (simp add: isLub_def isGlb_def dual_def converse_unfold)
paulson@23449
   193
paulson@23449
   194
lemma isLub_dual_isGlb: "isLub S cl = isGlb S (dual cl)"
haftmann@46752
   195
by (simp add: isLub_def isGlb_def dual_def converse_unfold)
paulson@23449
   196
paulson@23449
   197
lemma (in PO) dualPO: "dual cl \<in> PartialOrder"
paulson@23449
   198
apply (insert cl_po)
haftmann@45970
   199
apply (simp add: PartialOrder_def dual_def)
paulson@23449
   200
done
paulson@23449
   201
paulson@23449
   202
lemma Rdual:
paulson@23449
   203
     "\<forall>S. (S \<subseteq> A -->( \<exists>L. isLub S (| pset = A, order = r|) L))
paulson@23449
   204
      ==> \<forall>S. (S \<subseteq> A --> (\<exists>G. isGlb S (| pset = A, order = r|) G))"
paulson@23449
   205
apply safe
paulson@23449
   206
apply (rule_tac x = "lub {y. y \<in> A & (\<forall>k \<in> S. (y, k) \<in> r)}
paulson@23449
   207
                      (|pset = A, order = r|) " in exI)
paulson@23449
   208
apply (drule_tac x = "{y. y \<in> A & (\<forall>k \<in> S. (y,k) \<in> r) }" in spec)
paulson@23449
   209
apply (drule mp, fast)
paulson@23449
   210
apply (simp add: isLub_lub isGlb_def)
paulson@23449
   211
apply (simp add: isLub_def, blast)
paulson@23449
   212
done
paulson@23449
   213
paulson@23449
   214
lemma lub_dual_glb: "lub S cl = glb S (dual cl)"
haftmann@46752
   215
by (simp add: lub_def glb_def least_def greatest_def dual_def converse_unfold)
paulson@23449
   216
paulson@23449
   217
lemma glb_dual_lub: "glb S cl = lub S (dual cl)"
haftmann@46752
   218
by (simp add: lub_def glb_def least_def greatest_def dual_def converse_unfold)
paulson@23449
   219
paulson@23449
   220
lemma CL_subset_PO: "CompleteLattice \<subseteq> PartialOrder"
paulson@23449
   221
by (simp add: PartialOrder_def CompleteLattice_def, fast)
paulson@23449
   222
paulson@23449
   223
lemmas CL_imp_PO = CL_subset_PO [THEN subsetD]
paulson@23449
   224
nipkow@30198
   225
declare PO.PO_imp_refl_on  [OF PO.intro [OF CL_imp_PO], simp]
haftmann@27681
   226
declare PO.PO_imp_sym   [OF PO.intro [OF CL_imp_PO], simp]
haftmann@27681
   227
declare PO.PO_imp_trans [OF PO.intro [OF CL_imp_PO], simp]
paulson@23449
   228
nipkow@30198
   229
lemma (in CL) CO_refl_on: "refl_on A r"
nipkow@30198
   230
by (rule PO_imp_refl_on)
paulson@23449
   231
paulson@23449
   232
lemma (in CL) CO_antisym: "antisym r"
paulson@23449
   233
by (rule PO_imp_sym)
paulson@23449
   234
paulson@23449
   235
lemma (in CL) CO_trans: "trans r"
paulson@23449
   236
by (rule PO_imp_trans)
paulson@23449
   237
paulson@23449
   238
lemma CompleteLatticeI:
paulson@23449
   239
     "[| po \<in> PartialOrder; (\<forall>S. S \<subseteq> pset po --> (\<exists>L. isLub S po L));
paulson@23449
   240
         (\<forall>S. S \<subseteq> pset po --> (\<exists>G. isGlb S po G))|]
paulson@23449
   241
      ==> po \<in> CompleteLattice"
paulson@23449
   242
apply (unfold CompleteLattice_def, blast)
paulson@23449
   243
done
paulson@23449
   244
paulson@23449
   245
lemma (in CL) CL_dualCL: "dual cl \<in> CompleteLattice"
paulson@23449
   246
apply (insert cl_co)
paulson@23449
   247
apply (simp add: CompleteLattice_def dual_def)
paulson@23449
   248
apply (fold dual_def)
paulson@23449
   249
apply (simp add: isLub_dual_isGlb [symmetric] isGlb_dual_isLub [symmetric]
paulson@23449
   250
                 dualPO)
paulson@23449
   251
done
paulson@23449
   252
paulson@23449
   253
lemma (in PO) dualA_iff: "pset (dual cl) = pset cl"
paulson@23449
   254
by (simp add: dual_def)
paulson@23449
   255
paulson@23449
   256
lemma (in PO) dualr_iff: "((x, y) \<in> (order(dual cl))) = ((y, x) \<in> order cl)"
paulson@23449
   257
by (simp add: dual_def)
paulson@23449
   258
paulson@23449
   259
lemma (in PO) monotone_dual:
blanchet@43197
   260
     "monotone f (pset cl) (order cl)
paulson@23449
   261
     ==> monotone f (pset (dual cl)) (order(dual cl))"
paulson@23449
   262
by (simp add: monotone_def dualA_iff dualr_iff)
paulson@23449
   263
paulson@23449
   264
lemma (in PO) interval_dual:
paulson@23449
   265
     "[| x \<in> A; y \<in> A|] ==> interval r x y = interval (order(dual cl)) y x"
paulson@23449
   266
apply (simp add: interval_def dualr_iff)
paulson@23449
   267
apply (fold r_def, fast)
paulson@23449
   268
done
paulson@23449
   269
paulson@23449
   270
lemma (in PO) interval_not_empty:
paulson@23449
   271
     "[| trans r; interval r a b \<noteq> {} |] ==> (a, b) \<in> r"
paulson@23449
   272
apply (simp add: interval_def)
paulson@23449
   273
apply (unfold trans_def, blast)
paulson@23449
   274
done
paulson@23449
   275
paulson@23449
   276
lemma (in PO) interval_imp_mem: "x \<in> interval r a b ==> (a, x) \<in> r"
paulson@23449
   277
by (simp add: interval_def)
paulson@23449
   278
paulson@23449
   279
lemma (in PO) left_in_interval:
paulson@23449
   280
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |] ==> a \<in> interval r a b"
paulson@23449
   281
apply (simp (no_asm_simp) add: interval_def)
paulson@23449
   282
apply (simp add: PO_imp_trans interval_not_empty)
paulson@23449
   283
apply (simp add: reflE)
paulson@23449
   284
done
paulson@23449
   285
paulson@23449
   286
lemma (in PO) right_in_interval:
paulson@23449
   287
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |] ==> b \<in> interval r a b"
paulson@23449
   288
apply (simp (no_asm_simp) add: interval_def)
paulson@23449
   289
apply (simp add: PO_imp_trans interval_not_empty)
paulson@23449
   290
apply (simp add: reflE)
paulson@23449
   291
done
paulson@23449
   292
wenzelm@63167
   293
subsection \<open>sublattice\<close>
paulson@23449
   294
paulson@23449
   295
lemma (in PO) sublattice_imp_CL:
paulson@23449
   296
     "S <<= cl  ==> (| pset = S, order = induced S r |) \<in> CompleteLattice"
paulson@23449
   297
by (simp add: sublattice_def CompleteLattice_def A_def r_def)
paulson@23449
   298
paulson@23449
   299
lemma (in CL) sublatticeI:
paulson@23449
   300
     "[| S \<subseteq> A; (| pset = S, order = induced S r |) \<in> CompleteLattice |]
paulson@23449
   301
      ==> S <<= cl"
paulson@23449
   302
by (simp add: sublattice_def A_def r_def)
paulson@23449
   303
wenzelm@63167
   304
subsection \<open>lub\<close>
paulson@23449
   305
paulson@23449
   306
lemma (in CL) lub_unique: "[| S \<subseteq> A; isLub S cl x; isLub S cl L|] ==> x = L"
paulson@23449
   307
apply (rule antisymE)
paulson@23449
   308
apply (auto simp add: isLub_def r_def)
paulson@23449
   309
done
paulson@23449
   310
paulson@23449
   311
lemma (in CL) lub_upper: "[|S \<subseteq> A; x \<in> S|] ==> (x, lub S cl) \<in> r"
paulson@23449
   312
apply (rule CL_imp_ex_isLub [THEN exE], assumption)
paulson@23449
   313
apply (unfold lub_def least_def)
paulson@23449
   314
apply (rule some_equality [THEN ssubst])
paulson@23449
   315
  apply (simp add: isLub_def)
paulson@23449
   316
 apply (simp add: lub_unique A_def isLub_def)
paulson@23449
   317
apply (simp add: isLub_def r_def)
paulson@23449
   318
done
paulson@23449
   319
paulson@23449
   320
lemma (in CL) lub_least:
paulson@23449
   321
     "[| S \<subseteq> A; L \<in> A; \<forall>x \<in> S. (x,L) \<in> r |] ==> (lub S cl, L) \<in> r"
paulson@23449
   322
apply (rule CL_imp_ex_isLub [THEN exE], assumption)
paulson@23449
   323
apply (unfold lub_def least_def)
paulson@23449
   324
apply (rule_tac s=x in some_equality [THEN ssubst])
paulson@23449
   325
  apply (simp add: isLub_def)
paulson@23449
   326
 apply (simp add: lub_unique A_def isLub_def)
paulson@23449
   327
apply (simp add: isLub_def r_def A_def)
paulson@23449
   328
done
paulson@23449
   329
paulson@23449
   330
lemma (in CL) lub_in_lattice: "S \<subseteq> A ==> lub S cl \<in> A"
paulson@23449
   331
apply (rule CL_imp_ex_isLub [THEN exE], assumption)
paulson@23449
   332
apply (unfold lub_def least_def)
paulson@23449
   333
apply (subst some_equality)
paulson@23449
   334
apply (simp add: isLub_def)
paulson@23449
   335
prefer 2 apply (simp add: isLub_def A_def)
paulson@23449
   336
apply (simp add: lub_unique A_def isLub_def)
paulson@23449
   337
done
paulson@23449
   338
paulson@23449
   339
lemma (in CL) lubI:
paulson@23449
   340
     "[| S \<subseteq> A; L \<in> A; \<forall>x \<in> S. (x,L) \<in> r;
paulson@23449
   341
         \<forall>z \<in> A. (\<forall>y \<in> S. (y,z) \<in> r) --> (L,z) \<in> r |] ==> L = lub S cl"
paulson@23449
   342
apply (rule lub_unique, assumption)
paulson@23449
   343
apply (simp add: isLub_def A_def r_def)
paulson@23449
   344
apply (unfold isLub_def)
paulson@23449
   345
apply (rule conjI)
paulson@23449
   346
apply (fold A_def r_def)
paulson@23449
   347
apply (rule lub_in_lattice, assumption)
paulson@23449
   348
apply (simp add: lub_upper lub_least)
paulson@23449
   349
done
paulson@23449
   350
paulson@23449
   351
lemma (in CL) lubIa: "[| S \<subseteq> A; isLub S cl L |] ==> L = lub S cl"
paulson@23449
   352
by (simp add: lubI isLub_def A_def r_def)
paulson@23449
   353
paulson@23449
   354
lemma (in CL) isLub_in_lattice: "isLub S cl L ==> L \<in> A"
paulson@23449
   355
by (simp add: isLub_def  A_def)
paulson@23449
   356
paulson@23449
   357
lemma (in CL) isLub_upper: "[|isLub S cl L; y \<in> S|] ==> (y, L) \<in> r"
paulson@23449
   358
by (simp add: isLub_def r_def)
paulson@23449
   359
paulson@23449
   360
lemma (in CL) isLub_least:
paulson@23449
   361
     "[| isLub S cl L; z \<in> A; \<forall>y \<in> S. (y, z) \<in> r|] ==> (L, z) \<in> r"
paulson@23449
   362
by (simp add: isLub_def A_def r_def)
paulson@23449
   363
paulson@23449
   364
lemma (in CL) isLubI:
paulson@23449
   365
     "[| L \<in> A; \<forall>y \<in> S. (y, L) \<in> r;
paulson@23449
   366
         (\<forall>z \<in> A. (\<forall>y \<in> S. (y, z):r) --> (L, z) \<in> r)|] ==> isLub S cl L"
paulson@23449
   367
by (simp add: isLub_def A_def r_def)
paulson@23449
   368
wenzelm@63167
   369
subsection \<open>glb\<close>
paulson@23449
   370
paulson@23449
   371
lemma (in CL) glb_in_lattice: "S \<subseteq> A ==> glb S cl \<in> A"
paulson@23449
   372
apply (subst glb_dual_lub)
paulson@23449
   373
apply (simp add: A_def)
paulson@23449
   374
apply (rule dualA_iff [THEN subst])
paulson@23449
   375
apply (rule CL.lub_in_lattice)
haftmann@27681
   376
apply (rule CL.intro)
haftmann@27681
   377
apply (rule PO.intro)
paulson@23449
   378
apply (rule dualPO)
haftmann@27681
   379
apply (rule CL_axioms.intro)
paulson@23449
   380
apply (rule CL_dualCL)
paulson@23449
   381
apply (simp add: dualA_iff)
paulson@23449
   382
done
paulson@23449
   383
paulson@23449
   384
lemma (in CL) glb_lower: "[|S \<subseteq> A; x \<in> S|] ==> (glb S cl, x) \<in> r"
paulson@23449
   385
apply (subst glb_dual_lub)
paulson@23449
   386
apply (simp add: r_def)
paulson@23449
   387
apply (rule dualr_iff [THEN subst])
paulson@23449
   388
apply (rule CL.lub_upper)
haftmann@27681
   389
apply (rule CL.intro)
haftmann@27681
   390
apply (rule PO.intro)
paulson@23449
   391
apply (rule dualPO)
haftmann@27681
   392
apply (rule CL_axioms.intro)
paulson@23449
   393
apply (rule CL_dualCL)
paulson@23449
   394
apply (simp add: dualA_iff A_def, assumption)
paulson@23449
   395
done
paulson@23449
   396
wenzelm@63167
   397
text \<open>
paulson@23449
   398
  Reduce the sublattice property by using substructural properties;
wenzelm@63167
   399
  abandoned see \<open>Tarski_4.ML\<close>.
wenzelm@63167
   400
\<close>
paulson@23449
   401
paulson@23449
   402
declare (in CLF) f_cl [simp]
paulson@23449
   403
paulson@23449
   404
lemma (in CLF) [simp]:
wenzelm@61384
   405
    "f: pset cl \<rightarrow> pset cl & monotone f (pset cl) (order cl)"
blanchet@42762
   406
proof -
blanchet@42762
   407
  have "\<forall>u v. (v, u) \<in> CLF_set \<longrightarrow> u \<in> {R \<in> pset v \<rightarrow> pset v. monotone R (pset v) (order v)}"
blanchet@42762
   408
    unfolding CLF_set_def using SigmaE2 by blast
blanchet@42762
   409
  hence F1: "\<forall>u v. (v, u) \<in> CLF_set \<longrightarrow> u \<in> pset v \<rightarrow> pset v \<and> monotone u (pset v) (order v)"
blanchet@42762
   410
    using CollectE by blast
blanchet@42762
   411
  hence "Tarski.monotone f (pset cl) (order cl)" by (metis f_cl)
blanchet@42762
   412
  hence "(cl, f) \<in> CLF_set \<and> Tarski.monotone f (pset cl) (order cl)"
blanchet@42762
   413
    by (metis f_cl)
blanchet@42762
   414
  thus "f \<in> pset cl \<rightarrow> pset cl \<and> Tarski.monotone f (pset cl) (order cl)"
blanchet@42762
   415
    using F1 by metis
blanchet@42762
   416
qed
paulson@23449
   417
wenzelm@61384
   418
lemma (in CLF) f_in_funcset: "f \<in> A \<rightarrow> A"
paulson@23449
   419
by (simp add: A_def)
paulson@23449
   420
paulson@23449
   421
lemma (in CLF) monotone_f: "monotone f A r"
paulson@23449
   422
by (simp add: A_def r_def)
paulson@23449
   423
paulson@23449
   424
(*never proved, 2007-01-22*)
blanchet@45705
   425
haftmann@27681
   426
declare (in CLF) CLF_set_def [simp] CL_dualCL [simp] monotone_dual [simp] dualA_iff [simp]
haftmann@27681
   427
blanchet@42762
   428
lemma (in CLF) CLF_dual: "(dual cl, f) \<in> CLF_set"
paulson@23449
   429
apply (simp del: dualA_iff)
paulson@23449
   430
apply (simp)
blanchet@43197
   431
done
haftmann@27681
   432
haftmann@27681
   433
declare (in CLF) CLF_set_def[simp del] CL_dualCL[simp del] monotone_dual[simp del]
paulson@23449
   434
          dualA_iff[simp del]
paulson@23449
   435
wenzelm@63167
   436
subsection \<open>fixed points\<close>
paulson@23449
   437
paulson@23449
   438
lemma fix_subset: "fix f A \<subseteq> A"
paulson@23449
   439
by (simp add: fix_def, fast)
paulson@23449
   440
paulson@23449
   441
lemma fix_imp_eq: "x \<in> fix f A ==> f x = x"
paulson@23449
   442
by (simp add: fix_def)
paulson@23449
   443
paulson@23449
   444
lemma fixf_subset:
wenzelm@64913
   445
     "[| A \<subseteq> B; x \<in> fix (\<lambda>y \<in> A. f y) A |] ==> x \<in> fix f B"
paulson@23449
   446
by (simp add: fix_def, auto)
paulson@23449
   447
wenzelm@63167
   448
subsection \<open>lemmas for Tarski, lub\<close>
paulson@23449
   449
paulson@23449
   450
(*never proved, 2007-01-22*)
blanchet@45705
   451
blanchet@45705
   452
declare CL.lub_least[intro] CLF.f_in_funcset[intro] funcset_mem[intro] CL.lub_in_lattice[intro] PO.transE[intro] PO.monotoneE[intro] CLF.monotone_f[intro] CL.lub_upper[intro]
blanchet@45705
   453
paulson@23449
   454
lemma (in CLF) lubH_le_flubH:
paulson@23449
   455
     "H = {x. (x, f x) \<in> r & x \<in> A} ==> (lub H cl, f (lub H cl)) \<in> r"
paulson@23449
   456
apply (rule lub_least, fast)
paulson@23449
   457
apply (rule f_in_funcset [THEN funcset_mem])
paulson@23449
   458
apply (rule lub_in_lattice, fast)
wenzelm@63167
   459
\<comment> \<open>\<open>\<forall>x:H. (x, f (lub H r)) \<in> r\<close>\<close>
paulson@23449
   460
apply (rule ballI)
paulson@23449
   461
(*never proved, 2007-01-22*)
paulson@23449
   462
apply (rule transE)
wenzelm@63167
   463
\<comment> \<open>instantiates \<open>(x, ?z) \<in> order cl to (x, f x)\<close>,\<close>
wenzelm@63167
   464
\<comment> \<open>because of the definition of \<open>H\<close>\<close>
paulson@23449
   465
apply fast
wenzelm@63167
   466
\<comment> \<open>so it remains to show \<open>(f x, f (lub H cl)) \<in> r\<close>\<close>
paulson@23449
   467
apply (rule_tac f = "f" in monotoneE)
paulson@23449
   468
apply (rule monotone_f, fast)
paulson@23449
   469
apply (rule lub_in_lattice, fast)
paulson@23449
   470
apply (rule lub_upper, fast)
paulson@23449
   471
apply assumption
paulson@23449
   472
done
blanchet@45705
   473
blanchet@45705
   474
declare CL.lub_least[rule del] CLF.f_in_funcset[rule del]
blanchet@45705
   475
        funcset_mem[rule del] CL.lub_in_lattice[rule del]
blanchet@45705
   476
        PO.transE[rule del] PO.monotoneE[rule del]
blanchet@45705
   477
        CLF.monotone_f[rule del] CL.lub_upper[rule del]
paulson@23449
   478
paulson@23449
   479
(*never proved, 2007-01-22*)
blanchet@45705
   480
blanchet@45705
   481
declare CLF.f_in_funcset[intro] funcset_mem[intro] CL.lub_in_lattice[intro]
blanchet@45705
   482
     PO.monotoneE[intro] CLF.monotone_f[intro] CL.lub_upper[intro]
blanchet@45705
   483
     CLF.lubH_le_flubH[simp]
blanchet@45705
   484
paulson@23449
   485
lemma (in CLF) flubH_le_lubH:
paulson@23449
   486
     "[|  H = {x. (x, f x) \<in> r & x \<in> A} |] ==> (f (lub H cl), lub H cl) \<in> r"
paulson@23449
   487
apply (rule lub_upper, fast)
paulson@23449
   488
apply (rule_tac t = "H" in ssubst, assumption)
paulson@23449
   489
apply (rule CollectI)
blanchet@47040
   490
by (metis (lifting) CO_refl_on lubH_le_flubH monotone_def monotone_f refl_onD1 refl_onD2)
paulson@23449
   491
blanchet@45705
   492
declare CLF.f_in_funcset[rule del] funcset_mem[rule del]
blanchet@45705
   493
        CL.lub_in_lattice[rule del] PO.monotoneE[rule del]
blanchet@45705
   494
        CLF.monotone_f[rule del] CL.lub_upper[rule del]
blanchet@45705
   495
        CLF.lubH_le_flubH[simp del]
paulson@23449
   496
paulson@23449
   497
(*never proved, 2007-01-22*)
blanchet@45705
   498
blanchet@37622
   499
(* Single-step version fails. The conjecture clauses refer to local abstraction
blanchet@37622
   500
functions (Frees). *)
paulson@23449
   501
lemma (in CLF) lubH_is_fixp:
paulson@23449
   502
     "H = {x. (x, f x) \<in> r & x \<in> A} ==> lub H cl \<in> fix f A"
paulson@23449
   503
apply (simp add: fix_def)
paulson@23449
   504
apply (rule conjI)
blanchet@36554
   505
proof -
blanchet@36554
   506
  assume A1: "H = {x. (x, f x) \<in> r \<and> x \<in> A}"
blanchet@42762
   507
  have F1: "\<forall>u v. v \<inter> u \<subseteq> u" by (metis Int_commute Int_lower1)
blanchet@42762
   508
  have "{R. (R, f R) \<in> r} \<inter> {R. R \<in> A} = H" using A1 by (metis Collect_conj_eq)
blanchet@42762
   509
  hence "H \<subseteq> {R. R \<in> A}" using F1 by metis
blanchet@42762
   510
  hence "H \<subseteq> A" by (metis Collect_mem_eq)
blanchet@42762
   511
  hence "lub H cl \<in> A" by (metis lub_in_lattice)
blanchet@42762
   512
  thus "lub {x. (x, f x) \<in> r \<and> x \<in> A} cl \<in> A" using A1 by metis
blanchet@36554
   513
next
blanchet@36554
   514
  assume A1: "H = {x. (x, f x) \<in> r \<and> x \<in> A}"
haftmann@45970
   515
  have F1: "\<forall>v. {R. R \<in> v} = v" by (metis Collect_mem_eq)
haftmann@45970
   516
  have F2: "\<forall>w u. {R. R \<in> u \<and> R \<in> w} = u \<inter> w"
haftmann@45970
   517
    by (metis Collect_conj_eq Collect_mem_eq)
haftmann@45970
   518
  have F3: "\<forall>x v. {R. v R \<in> x} = v -` x" by (metis vimage_def)
blanchet@36554
   519
  hence F4: "A \<inter> (\<lambda>R. (R, f R)) -` r = H" using A1 by auto
wenzelm@64913
   520
  hence F5: "(f (lub H cl), lub H cl) \<in> r"
haftmann@45970
   521
    by (metis A1 flubH_le_lubH)
blanchet@36554
   522
  have F6: "(lub H cl, f (lub H cl)) \<in> r"
haftmann@45970
   523
    by (metis A1 lubH_le_flubH)
blanchet@36554
   524
  have "(lub H cl, f (lub H cl)) \<in> r \<longrightarrow> f (lub H cl) = lub H cl"
blanchet@36554
   525
    using F5 by (metis antisymE)
blanchet@36554
   526
  hence "f (lub H cl) = lub H cl" using F6 by metis
blanchet@36554
   527
  thus "H = {x. (x, f x) \<in> r \<and> x \<in> A}
blanchet@36554
   528
        \<Longrightarrow> f (lub {x. (x, f x) \<in> r \<and> x \<in> A} cl) =
blanchet@36554
   529
           lub {x. (x, f x) \<in> r \<and> x \<in> A} cl"
haftmann@45970
   530
    by metis
paulson@24827
   531
qed
paulson@23449
   532
paulson@25710
   533
lemma (in CLF) (*lubH_is_fixp:*)
paulson@23449
   534
     "H = {x. (x, f x) \<in> r & x \<in> A} ==> lub H cl \<in> fix f A"
paulson@23449
   535
apply (simp add: fix_def)
paulson@23449
   536
apply (rule conjI)
nipkow@30198
   537
apply (metis CO_refl_on lubH_le_flubH refl_onD1)
paulson@23449
   538
apply (metis antisymE flubH_le_lubH lubH_le_flubH)
paulson@23449
   539
done
paulson@23449
   540
paulson@23449
   541
lemma (in CLF) fix_in_H:
paulson@23449
   542
     "[| H = {x. (x, f x) \<in> r & x \<in> A};  x \<in> P |] ==> x \<in> H"
nipkow@30198
   543
by (simp add: P_def fix_imp_eq [of _ f A] reflE CO_refl_on
paulson@23449
   544
                    fix_subset [of f A, THEN subsetD])
paulson@23449
   545
paulson@23449
   546
lemma (in CLF) fixf_le_lubH:
paulson@23449
   547
     "H = {x. (x, f x) \<in> r & x \<in> A} ==> \<forall>x \<in> fix f A. (x, lub H cl) \<in> r"
paulson@23449
   548
apply (rule ballI)
paulson@23449
   549
apply (rule lub_upper, fast)
paulson@23449
   550
apply (rule fix_in_H)
paulson@23449
   551
apply (simp_all add: P_def)
paulson@23449
   552
done
paulson@23449
   553
paulson@23449
   554
lemma (in CLF) lubH_least_fixf:
paulson@23449
   555
     "H = {x. (x, f x) \<in> r & x \<in> A}
paulson@23449
   556
      ==> \<forall>L. (\<forall>y \<in> fix f A. (y,L) \<in> r) --> (lub H cl, L) \<in> r"
paulson@23449
   557
apply (metis P_def lubH_is_fixp)
paulson@23449
   558
done
paulson@23449
   559
wenzelm@63167
   560
subsection \<open>Tarski fixpoint theorem 1, first part\<close>
blanchet@45705
   561
blanchet@45705
   562
declare CL.lubI[intro] fix_subset[intro] CL.lub_in_lattice[intro]
blanchet@45705
   563
        CLF.fixf_le_lubH[simp] CLF.lubH_least_fixf[simp]
blanchet@45705
   564
paulson@23449
   565
lemma (in CLF) T_thm_1_lub: "lub P cl = lub {x. (x, f x) \<in> r & x \<in> A} cl"
paulson@23449
   566
(*sledgehammer;*)
paulson@23449
   567
apply (rule sym)
paulson@23449
   568
apply (simp add: P_def)
paulson@23449
   569
apply (rule lubI)
wenzelm@58944
   570
apply (simp add: fix_subset)
wenzelm@58944
   571
using fix_subset lubH_is_fixp apply fastforce
wenzelm@58944
   572
apply (simp add: fixf_le_lubH)
wenzelm@58944
   573
using lubH_is_fixp apply blast
wenzelm@58944
   574
done
paulson@23449
   575
blanchet@45705
   576
declare CL.lubI[rule del] fix_subset[rule del] CL.lub_in_lattice[rule del]
blanchet@45705
   577
        CLF.fixf_le_lubH[simp del] CLF.lubH_least_fixf[simp del]
paulson@23449
   578
paulson@23449
   579
(*never proved, 2007-01-22*)
blanchet@45705
   580
blanchet@45705
   581
declare glb_dual_lub[simp] PO.dualA_iff[intro] CLF.lubH_is_fixp[intro]
blanchet@45705
   582
        PO.dualPO[intro] CL.CL_dualCL[intro] PO.dualr_iff[simp]
blanchet@45705
   583
paulson@23449
   584
lemma (in CLF) glbH_is_fixp: "H = {x. (f x, x) \<in> r & x \<in> A} ==> glb H cl \<in> P"
wenzelm@63167
   585
  \<comment> \<open>Tarski for glb\<close>
paulson@23449
   586
(*sledgehammer;*)
paulson@23449
   587
apply (simp add: glb_dual_lub P_def A_def r_def)
paulson@23449
   588
apply (rule dualA_iff [THEN subst])
paulson@23449
   589
apply (rule CLF.lubH_is_fixp)
haftmann@27681
   590
apply (rule CLF.intro)
haftmann@27681
   591
apply (rule CL.intro)
haftmann@27681
   592
apply (rule PO.intro)
paulson@23449
   593
apply (rule dualPO)
haftmann@27681
   594
apply (rule CL_axioms.intro)
paulson@23449
   595
apply (rule CL_dualCL)
haftmann@27681
   596
apply (rule CLF_axioms.intro)
paulson@23449
   597
apply (rule CLF_dual)
paulson@23449
   598
apply (simp add: dualr_iff dualA_iff)
paulson@23449
   599
done
paulson@23449
   600
blanchet@45705
   601
declare glb_dual_lub[simp del] PO.dualA_iff[rule del] CLF.lubH_is_fixp[rule del]
blanchet@45705
   602
        PO.dualPO[rule del] CL.CL_dualCL[rule del] PO.dualr_iff[simp del]
paulson@23449
   603
paulson@23449
   604
(*never proved, 2007-01-22*)
blanchet@45705
   605
paulson@23449
   606
lemma (in CLF) T_thm_1_glb: "glb P cl = glb {x. (f x, x) \<in> r & x \<in> A} cl"
paulson@23449
   607
(*sledgehammer;*)
paulson@23449
   608
apply (simp add: glb_dual_lub P_def A_def r_def)
paulson@23449
   609
apply (rule dualA_iff [THEN subst])
paulson@23449
   610
(*never proved, 2007-01-22*)
paulson@23449
   611
(*sledgehammer;*)
haftmann@27681
   612
apply (simp add: CLF.T_thm_1_lub [of _ f, OF CLF.intro, OF CL.intro CLF_axioms.intro, OF PO.intro CL_axioms.intro,
haftmann@27681
   613
  OF dualPO CL_dualCL] dualPO CL_dualCL CLF_dual dualr_iff)
paulson@23449
   614
done
paulson@23449
   615
wenzelm@63167
   616
subsection \<open>interval\<close>
paulson@23449
   617
blanchet@45705
   618
declare (in CLF) CO_refl_on[simp] refl_on_def [simp]
paulson@23449
   619
paulson@23449
   620
lemma (in CLF) rel_imp_elem: "(x, y) \<in> r ==> x \<in> A"
nipkow@30198
   621
by (metis CO_refl_on refl_onD1)
blanchet@45705
   622
blanchet@45705
   623
declare (in CLF) CO_refl_on[simp del]  refl_on_def [simp del]
paulson@23449
   624
blanchet@45705
   625
declare (in CLF) rel_imp_elem[intro]
blanchet@45705
   626
declare interval_def [simp]
blanchet@45705
   627
paulson@23449
   628
lemma (in CLF) interval_subset: "[| a \<in> A; b \<in> A |] ==> interval r a b \<subseteq> A"
nipkow@30198
   629
by (metis CO_refl_on interval_imp_mem refl_onD refl_onD2 rel_imp_elem subset_eq)
paulson@23449
   630
blanchet@45705
   631
declare (in CLF) rel_imp_elem[rule del]
blanchet@45705
   632
declare interval_def [simp del]
paulson@23449
   633
paulson@23449
   634
lemma (in CLF) intervalI:
paulson@23449
   635
     "[| (a, x) \<in> r; (x, b) \<in> r |] ==> x \<in> interval r a b"
paulson@23449
   636
by (simp add: interval_def)
paulson@23449
   637
paulson@23449
   638
lemma (in CLF) interval_lemma1:
paulson@23449
   639
     "[| S \<subseteq> interval r a b; x \<in> S |] ==> (a, x) \<in> r"
paulson@23449
   640
by (unfold interval_def, fast)
paulson@23449
   641
paulson@23449
   642
lemma (in CLF) interval_lemma2:
paulson@23449
   643
     "[| S \<subseteq> interval r a b; x \<in> S |] ==> (x, b) \<in> r"
paulson@23449
   644
by (unfold interval_def, fast)
paulson@23449
   645
paulson@23449
   646
lemma (in CLF) a_less_lub:
paulson@23449
   647
     "[| S \<subseteq> A; S \<noteq> {};
paulson@23449
   648
         \<forall>x \<in> S. (a,x) \<in> r; \<forall>y \<in> S. (y, L) \<in> r |] ==> (a,L) \<in> r"
paulson@23449
   649
by (blast intro: transE)
paulson@23449
   650
paulson@23449
   651
lemma (in CLF) glb_less_b:
paulson@23449
   652
     "[| S \<subseteq> A; S \<noteq> {};
paulson@23449
   653
         \<forall>x \<in> S. (x,b) \<in> r; \<forall>y \<in> S. (G, y) \<in> r |] ==> (G,b) \<in> r"
paulson@23449
   654
by (blast intro: transE)
paulson@23449
   655
paulson@23449
   656
lemma (in CLF) S_intv_cl:
paulson@23449
   657
     "[| a \<in> A; b \<in> A; S \<subseteq> interval r a b |]==> S \<subseteq> A"
paulson@23449
   658
by (simp add: subset_trans [OF _ interval_subset])
paulson@23449
   659
blanchet@45705
   660
paulson@23449
   661
lemma (in CLF) L_in_interval:
paulson@23449
   662
     "[| a \<in> A; b \<in> A; S \<subseteq> interval r a b;
blanchet@43197
   663
         S \<noteq> {}; isLub S cl L; interval r a b \<noteq> {} |] ==> L \<in> interval r a b"
paulson@23449
   664
(*WON'T TERMINATE
paulson@23449
   665
apply (metis CO_trans intervalI interval_lemma1 interval_lemma2 isLub_least isLub_upper subset_empty subset_iff trans_def)
paulson@23449
   666
*)
paulson@23449
   667
apply (rule intervalI)
paulson@23449
   668
apply (rule a_less_lub)
paulson@23449
   669
prefer 2 apply assumption
paulson@23449
   670
apply (simp add: S_intv_cl)
paulson@23449
   671
apply (rule ballI)
paulson@23449
   672
apply (simp add: interval_lemma1)
paulson@23449
   673
apply (simp add: isLub_upper)
wenzelm@63167
   674
\<comment> \<open>\<open>(L, b) \<in> r\<close>\<close>
paulson@23449
   675
apply (simp add: isLub_least interval_lemma2)
paulson@23449
   676
done
paulson@23449
   677
paulson@23449
   678
(*never proved, 2007-01-22*)
blanchet@45705
   679
paulson@23449
   680
lemma (in CLF) G_in_interval:
paulson@23449
   681
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {}; S \<subseteq> interval r a b; isGlb S cl G;
paulson@23449
   682
         S \<noteq> {} |] ==> G \<in> interval r a b"
paulson@23449
   683
apply (simp add: interval_dual)
haftmann@27681
   684
apply (simp add: CLF.L_in_interval [of _ f, OF CLF.intro, OF CL.intro CLF_axioms.intro, OF PO.intro CL_axioms.intro]
paulson@23449
   685
                 dualA_iff A_def dualPO CL_dualCL CLF_dual isGlb_dual_isLub)
paulson@23449
   686
done
paulson@23449
   687
blanchet@45705
   688
paulson@23449
   689
lemma (in CLF) intervalPO:
paulson@23449
   690
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |]
paulson@23449
   691
      ==> (| pset = interval r a b, order = induced (interval r a b) r |)
paulson@23449
   692
          \<in> PartialOrder"
blanchet@36554
   693
proof -
blanchet@36554
   694
  assume A1: "a \<in> A"
blanchet@36554
   695
  assume "b \<in> A"
blanchet@36554
   696
  hence "\<forall>u. u \<in> A \<longrightarrow> interval r u b \<subseteq> A" by (metis interval_subset)
blanchet@36554
   697
  hence "interval r a b \<subseteq> A" using A1 by metis
blanchet@36554
   698
  hence "interval r a b \<subseteq> A" by metis
blanchet@36554
   699
  thus ?thesis by (metis po_subset_po)
paulson@23449
   700
qed
paulson@23449
   701
paulson@23449
   702
lemma (in CLF) intv_CL_lub:
paulson@23449
   703
 "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |]
paulson@23449
   704
  ==> \<forall>S. S \<subseteq> interval r a b -->
paulson@23449
   705
          (\<exists>L. isLub S (| pset = interval r a b,
paulson@23449
   706
                          order = induced (interval r a b) r |)  L)"
paulson@23449
   707
apply (intro strip)
paulson@23449
   708
apply (frule S_intv_cl [THEN CL_imp_ex_isLub])
paulson@23449
   709
prefer 2 apply assumption
paulson@23449
   710
apply assumption
paulson@23449
   711
apply (erule exE)
wenzelm@63167
   712
\<comment> \<open>define the lub for the interval as\<close>
paulson@23449
   713
apply (rule_tac x = "if S = {} then a else L" in exI)
nipkow@62390
   714
apply (simp (no_asm_simp) add: isLub_def split del: if_split)
paulson@23449
   715
apply (intro impI conjI)
wenzelm@63167
   716
\<comment> \<open>\<open>(if S = {} then a else L) \<in> interval r a b\<close>\<close>
paulson@23449
   717
apply (simp add: CL_imp_PO L_in_interval)
paulson@23449
   718
apply (simp add: left_in_interval)
wenzelm@63167
   719
\<comment> \<open>lub prop 1\<close>
paulson@23449
   720
apply (case_tac "S = {}")
wenzelm@63167
   721
\<comment> \<open>\<open>S = {}, y \<in> S = False => everything\<close>\<close>
paulson@23449
   722
apply fast
wenzelm@63167
   723
\<comment> \<open>\<open>S \<noteq> {}\<close>\<close>
paulson@23449
   724
apply simp
wenzelm@63167
   725
\<comment> \<open>\<open>\<forall>y:S. (y, L) \<in> induced (interval r a b) r\<close>\<close>
paulson@23449
   726
apply (rule ballI)
paulson@23449
   727
apply (simp add: induced_def  L_in_interval)
paulson@23449
   728
apply (rule conjI)
paulson@23449
   729
apply (rule subsetD)
paulson@23449
   730
apply (simp add: S_intv_cl, assumption)
paulson@23449
   731
apply (simp add: isLub_upper)
wenzelm@63167
   732
\<comment> \<open>\<open>\<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\<close>\<close>
paulson@23449
   733
apply (rule ballI)
paulson@23449
   734
apply (rule impI)
paulson@23449
   735
apply (case_tac "S = {}")
wenzelm@63167
   736
\<comment> \<open>\<open>S = {}\<close>\<close>
paulson@23449
   737
apply simp
paulson@23449
   738
apply (simp add: induced_def  interval_def)
paulson@23449
   739
apply (rule conjI)
paulson@23449
   740
apply (rule reflE, assumption)
paulson@23449
   741
apply (rule interval_not_empty)
paulson@23449
   742
apply (rule CO_trans)
paulson@23449
   743
apply (simp add: interval_def)
wenzelm@63167
   744
\<comment> \<open>\<open>S \<noteq> {}\<close>\<close>
paulson@23449
   745
apply simp
paulson@23449
   746
apply (simp add: induced_def  L_in_interval)
paulson@23449
   747
apply (rule isLub_least, assumption)
paulson@23449
   748
apply (rule subsetD)
paulson@23449
   749
prefer 2 apply assumption
paulson@23449
   750
apply (simp add: S_intv_cl, fast)
paulson@23449
   751
done
paulson@23449
   752
paulson@23449
   753
lemmas (in CLF) intv_CL_glb = intv_CL_lub [THEN Rdual]
paulson@23449
   754
paulson@23449
   755
(*never proved, 2007-01-22*)
blanchet@45705
   756
paulson@23449
   757
lemma (in CLF) interval_is_sublattice:
paulson@23449
   758
     "[| a \<in> A; b \<in> A; interval r a b \<noteq> {} |]
paulson@23449
   759
        ==> interval r a b <<= cl"
paulson@23449
   760
(*sledgehammer *)
paulson@23449
   761
apply (rule sublatticeI)
paulson@23449
   762
apply (simp add: interval_subset)
paulson@23449
   763
(*never proved, 2007-01-22*)
paulson@23449
   764
(*sledgehammer *)
paulson@23449
   765
apply (rule CompleteLatticeI)
paulson@23449
   766
apply (simp add: intervalPO)
paulson@23449
   767
 apply (simp add: intv_CL_lub)
paulson@23449
   768
apply (simp add: intv_CL_glb)
paulson@23449
   769
done
paulson@23449
   770
paulson@23449
   771
lemmas (in CLF) interv_is_compl_latt =
paulson@23449
   772
    interval_is_sublattice [THEN sublattice_imp_CL]
paulson@23449
   773
wenzelm@63167
   774
subsection \<open>Top and Bottom\<close>
paulson@23449
   775
lemma (in CLF) Top_dual_Bot: "Top cl = Bot (dual cl)"
paulson@23449
   776
by (simp add: Top_def Bot_def least_def greatest_def dualA_iff dualr_iff)
paulson@23449
   777
paulson@23449
   778
lemma (in CLF) Bot_dual_Top: "Bot cl = Top (dual cl)"
paulson@23449
   779
by (simp add: Top_def Bot_def least_def greatest_def dualA_iff dualr_iff)
paulson@23449
   780
blanchet@45705
   781
paulson@23449
   782
lemma (in CLF) Bot_in_lattice: "Bot cl \<in> A"
paulson@23449
   783
(*sledgehammer; *)
paulson@23449
   784
apply (simp add: Bot_def least_def)
paulson@23449
   785
apply (rule_tac a="glb A cl" in someI2)
blanchet@43197
   786
apply (simp_all add: glb_in_lattice glb_lower
paulson@23449
   787
                     r_def [symmetric] A_def [symmetric])
paulson@23449
   788
done
paulson@23449
   789
paulson@23449
   790
(*first proved 2007-01-25 after relaxing relevance*)
blanchet@45705
   791
paulson@23449
   792
lemma (in CLF) Top_in_lattice: "Top cl \<in> A"
paulson@23449
   793
(*sledgehammer;*)
paulson@23449
   794
apply (simp add: Top_dual_Bot A_def)
paulson@23449
   795
(*first proved 2007-01-25 after relaxing relevance*)
paulson@23449
   796
(*sledgehammer*)
paulson@23449
   797
apply (rule dualA_iff [THEN subst])
haftmann@27681
   798
apply (blast intro!: CLF.Bot_in_lattice [OF CLF.intro, OF CL.intro CLF_axioms.intro, OF PO.intro CL_axioms.intro] dualPO CL_dualCL CLF_dual)
paulson@23449
   799
done
paulson@23449
   800
paulson@23449
   801
lemma (in CLF) Top_prop: "x \<in> A ==> (x, Top cl) \<in> r"
paulson@23449
   802
apply (simp add: Top_def greatest_def)
paulson@23449
   803
apply (rule_tac a="lub A cl" in someI2)
paulson@23449
   804
apply (rule someI2)
blanchet@43197
   805
apply (simp_all add: lub_in_lattice lub_upper
paulson@23449
   806
                     r_def [symmetric] A_def [symmetric])
paulson@23449
   807
done
paulson@23449
   808
paulson@23449
   809
(*never proved, 2007-01-22*)
blanchet@45705
   810
paulson@23449
   811
lemma (in CLF) Bot_prop: "x \<in> A ==> (Bot cl, x) \<in> r"
blanchet@43197
   812
(*sledgehammer*)
paulson@23449
   813
apply (simp add: Bot_dual_Top r_def)
paulson@23449
   814
apply (rule dualr_iff [THEN subst])
haftmann@27681
   815
apply (simp add: CLF.Top_prop [of _ f, OF CLF.intro, OF CL.intro CLF_axioms.intro, OF PO.intro CL_axioms.intro]
paulson@23449
   816
                 dualA_iff A_def dualPO CL_dualCL CLF_dual)
paulson@23449
   817
done
paulson@23449
   818
blanchet@45705
   819
blanchet@43197
   820
lemma (in CLF) Top_intv_not_empty: "x \<in> A  ==> interval r x (Top cl) \<noteq> {}"
paulson@23449
   821
apply (metis Top_in_lattice Top_prop empty_iff intervalI reflE)
paulson@23449
   822
done
paulson@23449
   823
blanchet@45705
   824
blanchet@43197
   825
lemma (in CLF) Bot_intv_not_empty: "x \<in> A ==> interval r (Bot cl) x \<noteq> {}"
paulson@23449
   826
apply (metis Bot_prop ex_in_conv intervalI reflE rel_imp_elem)
paulson@23449
   827
done
paulson@23449
   828
wenzelm@63167
   829
subsection \<open>fixed points form a partial order\<close>
paulson@23449
   830
paulson@23449
   831
lemma (in CLF) fixf_po: "(| pset = P, order = induced P r|) \<in> PartialOrder"
paulson@23449
   832
by (simp add: P_def fix_subset po_subset_po)
paulson@23449
   833
paulson@23449
   834
(*first proved 2007-01-25 after relaxing relevance*)
blanchet@45705
   835
blanchet@45705
   836
declare (in Tarski) P_def[simp] Y_ss [simp]
blanchet@45705
   837
declare fix_subset [intro] subset_trans [intro]
blanchet@45705
   838
paulson@23449
   839
lemma (in Tarski) Y_subset_A: "Y \<subseteq> A"
blanchet@43197
   840
(*sledgehammer*)
paulson@23449
   841
apply (rule subset_trans [OF _ fix_subset])
paulson@23449
   842
apply (rule Y_ss [simplified P_def])
paulson@23449
   843
done
paulson@23449
   844
blanchet@45705
   845
declare (in Tarski) P_def[simp del] Y_ss [simp del]
blanchet@45705
   846
declare fix_subset [rule del] subset_trans [rule del]
paulson@23449
   847
paulson@23449
   848
lemma (in Tarski) lubY_in_A: "lub Y cl \<in> A"
paulson@23449
   849
  by (rule Y_subset_A [THEN lub_in_lattice])
paulson@23449
   850
paulson@23449
   851
(*never proved, 2007-01-22*)
blanchet@45705
   852
paulson@23449
   853
lemma (in Tarski) lubY_le_flubY: "(lub Y cl, f (lub Y cl)) \<in> r"
blanchet@43197
   854
(*sledgehammer*)
paulson@23449
   855
apply (rule lub_least)
paulson@23449
   856
apply (rule Y_subset_A)
paulson@23449
   857
apply (rule f_in_funcset [THEN funcset_mem])
paulson@23449
   858
apply (rule lubY_in_A)
wenzelm@63167
   859
\<comment> \<open>\<open>Y \<subseteq> P ==> f x = x\<close>\<close>
paulson@23449
   860
apply (rule ballI)
paulson@23449
   861
(*sledgehammer *)
paulson@23449
   862
apply (rule_tac t = "x" in fix_imp_eq [THEN subst])
paulson@23449
   863
apply (erule Y_ss [simplified P_def, THEN subsetD])
wenzelm@63167
   864
\<comment> \<open>\<open>reduce (f x, f (lub Y cl)) \<in> r to (x, lub Y cl) \<in> r\<close> by monotonicity\<close>
paulson@23449
   865
(*sledgehammer*)
paulson@23449
   866
apply (rule_tac f = "f" in monotoneE)
paulson@23449
   867
apply (rule monotone_f)
paulson@23449
   868
apply (simp add: Y_subset_A [THEN subsetD])
paulson@23449
   869
apply (rule lubY_in_A)
paulson@23449
   870
apply (simp add: lub_upper Y_subset_A)
paulson@23449
   871
done
paulson@23449
   872
paulson@23449
   873
(*first proved 2007-01-25 after relaxing relevance*)
blanchet@45705
   874
paulson@23449
   875
lemma (in Tarski) intY1_subset: "intY1 \<subseteq> A"
blanchet@43197
   876
(*sledgehammer*)
paulson@23449
   877
apply (unfold intY1_def)
paulson@23449
   878
apply (rule interval_subset)
paulson@23449
   879
apply (rule lubY_in_A)
paulson@23449
   880
apply (rule Top_in_lattice)
paulson@23449
   881
done
paulson@23449
   882
paulson@23449
   883
lemmas (in Tarski) intY1_elem = intY1_subset [THEN subsetD]
paulson@23449
   884
paulson@23449
   885
(*never proved, 2007-01-22*)
blanchet@45705
   886
paulson@23449
   887
lemma (in Tarski) intY1_f_closed: "x \<in> intY1 \<Longrightarrow> f x \<in> intY1"
blanchet@43197
   888
(*sledgehammer*)
paulson@23449
   889
apply (simp add: intY1_def  interval_def)
paulson@23449
   890
apply (rule conjI)
paulson@23449
   891
apply (rule transE)
paulson@23449
   892
apply (rule lubY_le_flubY)
wenzelm@63167
   893
\<comment> \<open>\<open>(f (lub Y cl), f x) \<in> r\<close>\<close>
paulson@23449
   894
(*sledgehammer [has been proved before now...]*)
paulson@23449
   895
apply (rule_tac f=f in monotoneE)
paulson@23449
   896
apply (rule monotone_f)
paulson@23449
   897
apply (rule lubY_in_A)
paulson@23449
   898
apply (simp add: intY1_def interval_def  intY1_elem)
paulson@23449
   899
apply (simp add: intY1_def  interval_def)
wenzelm@63167
   900
\<comment> \<open>\<open>(f x, Top cl) \<in> r\<close>\<close>
paulson@23449
   901
apply (rule Top_prop)
paulson@23449
   902
apply (rule f_in_funcset [THEN funcset_mem])
paulson@23449
   903
apply (simp add: intY1_def interval_def  intY1_elem)
paulson@23449
   904
done
paulson@23449
   905
blanchet@45705
   906
wenzelm@64913
   907
lemma (in Tarski) intY1_func: "(\<lambda>x \<in> intY1. f x) \<in> intY1 \<rightarrow> intY1"
haftmann@27368
   908
apply (rule restrict_in_funcset)
haftmann@27368
   909
apply (metis intY1_f_closed restrict_in_funcset)
haftmann@27368
   910
done
paulson@23449
   911
blanchet@45705
   912
paulson@24855
   913
lemma (in Tarski) intY1_mono:
wenzelm@64913
   914
     "monotone (\<lambda>x \<in> intY1. f x) intY1 (induced intY1 r)"
paulson@23449
   915
(*sledgehammer *)
paulson@23449
   916
apply (auto simp add: monotone_def induced_def intY1_f_closed)
paulson@23449
   917
apply (blast intro: intY1_elem monotone_f [THEN monotoneE])
paulson@23449
   918
done
paulson@23449
   919
paulson@23449
   920
(*proof requires relaxing relevance: 2007-01-25*)
blanchet@45705
   921
paulson@23449
   922
lemma (in Tarski) intY1_is_cl:
paulson@23449
   923
    "(| pset = intY1, order = induced intY1 r |) \<in> CompleteLattice"
blanchet@43197
   924
(*sledgehammer*)
paulson@23449
   925
apply (unfold intY1_def)
paulson@23449
   926
apply (rule interv_is_compl_latt)
paulson@23449
   927
apply (rule lubY_in_A)
paulson@23449
   928
apply (rule Top_in_lattice)
paulson@23449
   929
apply (rule Top_intv_not_empty)
paulson@23449
   930
apply (rule lubY_in_A)
paulson@23449
   931
done
paulson@23449
   932
paulson@23449
   933
(*never proved, 2007-01-22*)
blanchet@45705
   934
paulson@23449
   935
lemma (in Tarski) v_in_P: "v \<in> P"
blanchet@43197
   936
(*sledgehammer*)
paulson@23449
   937
apply (unfold P_def)
paulson@23449
   938
apply (rule_tac A = "intY1" in fixf_subset)
paulson@23449
   939
apply (rule intY1_subset)
haftmann@27681
   940
apply (simp add: CLF.glbH_is_fixp [OF CLF.intro, OF CL.intro CLF_axioms.intro, OF PO.intro CL_axioms.intro, OF _ intY1_is_cl, simplified]
haftmann@27681
   941
                 v_def CL_imp_PO intY1_is_cl CLF_set_def intY1_func intY1_mono)
paulson@23449
   942
done
paulson@23449
   943
blanchet@45705
   944
paulson@23449
   945
lemma (in Tarski) z_in_interval:
paulson@23449
   946
     "[| z \<in> P; \<forall>y\<in>Y. (y, z) \<in> induced P r |] ==> z \<in> intY1"
paulson@23449
   947
(*sledgehammer *)
paulson@23449
   948
apply (unfold intY1_def P_def)
paulson@23449
   949
apply (rule intervalI)
paulson@23449
   950
prefer 2
paulson@23449
   951
 apply (erule fix_subset [THEN subsetD, THEN Top_prop])
paulson@23449
   952
apply (rule lub_least)
paulson@23449
   953
apply (rule Y_subset_A)
paulson@23449
   954
apply (fast elim!: fix_subset [THEN subsetD])
paulson@23449
   955
apply (simp add: induced_def)
paulson@23449
   956
done
paulson@23449
   957
blanchet@45705
   958
paulson@23449
   959
lemma (in Tarski) f'z_in_int_rel: "[| z \<in> P; \<forall>y\<in>Y. (y, z) \<in> induced P r |]
wenzelm@64913
   960
      ==> ((\<lambda>x \<in> intY1. f x) z, z) \<in> induced intY1 r"
wenzelm@58943
   961
using P_def fix_imp_eq indI intY1_elem reflE z_in_interval by fastforce
paulson@23449
   962
paulson@23449
   963
(*never proved, 2007-01-22*)
blanchet@45705
   964
paulson@23449
   965
lemma (in Tarski) tarski_full_lemma:
paulson@23449
   966
     "\<exists>L. isLub Y (| pset = P, order = induced P r |) L"
paulson@23449
   967
apply (rule_tac x = "v" in exI)
paulson@23449
   968
apply (simp add: isLub_def)
wenzelm@63167
   969
\<comment> \<open>\<open>v \<in> P\<close>\<close>
paulson@23449
   970
apply (simp add: v_in_P)
paulson@23449
   971
apply (rule conjI)
blanchet@43197
   972
(*sledgehammer*)
wenzelm@63167
   973
\<comment> \<open>\<open>v\<close> is lub\<close>
wenzelm@63167
   974
\<comment> \<open>\<open>1. \<forall>y:Y. (y, v) \<in> induced P r\<close>\<close>
paulson@23449
   975
apply (rule ballI)
paulson@23449
   976
apply (simp add: induced_def subsetD v_in_P)
paulson@23449
   977
apply (rule conjI)
paulson@23449
   978
apply (erule Y_ss [THEN subsetD])
paulson@23449
   979
apply (rule_tac b = "lub Y cl" in transE)
paulson@23449
   980
apply (rule lub_upper)
paulson@23449
   981
apply (rule Y_subset_A, assumption)
paulson@23449
   982
apply (rule_tac b = "Top cl" in interval_imp_mem)
paulson@23449
   983
apply (simp add: v_def)
paulson@23449
   984
apply (fold intY1_def)
haftmann@27681
   985
apply (rule CL.glb_in_lattice [OF CL.intro, OF PO.intro CL_axioms.intro, OF _ intY1_is_cl, simplified])
paulson@23449
   986
 apply (simp add: CL_imp_PO intY1_is_cl, force)
wenzelm@63167
   987
\<comment> \<open>\<open>v\<close> is LEAST ub\<close>
paulson@23449
   988
apply clarify
paulson@23449
   989
apply (rule indI)
paulson@23449
   990
  prefer 3 apply assumption
paulson@23449
   991
 prefer 2 apply (simp add: v_in_P)
paulson@23449
   992
apply (unfold v_def)
paulson@23449
   993
(*never proved, 2007-01-22*)
blanchet@43197
   994
(*sledgehammer*)
paulson@23449
   995
apply (rule indE)
paulson@23449
   996
apply (rule_tac [2] intY1_subset)
paulson@23449
   997
(*never proved, 2007-01-22*)
blanchet@43197
   998
(*sledgehammer*)
haftmann@27681
   999
apply (rule CL.glb_lower [OF CL.intro, OF PO.intro CL_axioms.intro, OF _ intY1_is_cl, simplified])
paulson@23449
  1000
  apply (simp add: CL_imp_PO intY1_is_cl)
paulson@23449
  1001
 apply force
paulson@23449
  1002
apply (simp add: induced_def intY1_f_closed z_in_interval)
paulson@23449
  1003
apply (simp add: P_def fix_imp_eq [of _ f A] reflE
paulson@23449
  1004
                 fix_subset [of f A, THEN subsetD])
paulson@23449
  1005
done
paulson@23449
  1006
paulson@23449
  1007
lemma CompleteLatticeI_simp:
paulson@23449
  1008
     "[| (| pset = A, order = r |) \<in> PartialOrder;
paulson@23449
  1009
         \<forall>S. S \<subseteq> A --> (\<exists>L. isLub S (| pset = A, order = r |)  L) |]
paulson@23449
  1010
    ==> (| pset = A, order = r |) \<in> CompleteLattice"
paulson@23449
  1011
by (simp add: CompleteLatticeI Rdual)
paulson@23449
  1012
blanchet@45705
  1013
(*never proved, 2007-01-22*)
paulson@23449
  1014
blanchet@45705
  1015
declare (in CLF) fixf_po[intro] P_def [simp] A_def [simp] r_def [simp]
blanchet@45705
  1016
             Tarski.tarski_full_lemma [intro] cl_po [intro] cl_co [intro]
blanchet@45705
  1017
             CompleteLatticeI_simp [intro]
blanchet@45705
  1018
paulson@23449
  1019
theorem (in CLF) Tarski_full:
paulson@23449
  1020
     "(| pset = P, order = induced P r|) \<in> CompleteLattice"
blanchet@43197
  1021
(*sledgehammer*)
paulson@23449
  1022
apply (rule CompleteLatticeI_simp)
paulson@23449
  1023
apply (rule fixf_po, clarify)
paulson@23449
  1024
(*never proved, 2007-01-22*)
blanchet@43197
  1025
(*sledgehammer*)
paulson@23449
  1026
apply (simp add: P_def A_def r_def)
haftmann@27681
  1027
apply (blast intro!: Tarski.tarski_full_lemma [OF Tarski.intro, OF CLF.intro Tarski_axioms.intro,
haftmann@27681
  1028
  OF CL.intro CLF_axioms.intro, OF PO.intro CL_axioms.intro] cl_po cl_co f_cl)
paulson@23449
  1029
done
blanchet@36554
  1030
blanchet@36554
  1031
declare (in CLF) fixf_po [rule del] P_def [simp del] A_def [simp del] r_def [simp del]
paulson@23449
  1032
         Tarski.tarski_full_lemma [rule del] cl_po [rule del] cl_co [rule del]
paulson@23449
  1033
         CompleteLatticeI_simp [rule del]
paulson@23449
  1034
paulson@23449
  1035
end