src/HOL/Algebra/Lattice.thy
author wenzelm
Fri, 23 Apr 2004 21:46:04 +0200
changeset 14666 65f8680c3f16
parent 14651 02b8f3bcf7fe
child 14693 4deda204e1d8
permissions -rw-r--r--
improved notation;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
     1
(*
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
     2
  Title:     Orders and Lattices
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
     3
  Id:        $Id$
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
     4
  Author:    Clemens Ballarin, started 7 November 2003
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
     5
  Copyright: Clemens Ballarin
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
     6
*)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
     7
14577
dbb95b825244 tuned document;
wenzelm
parents: 14551
diff changeset
     8
header {* Order and Lattices *}
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
     9
14577
dbb95b825244 tuned document;
wenzelm
parents: 14551
diff changeset
    10
theory Lattice = Group:
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    11
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    12
subsection {* Partial Orders *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    13
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    14
record 'a order = "'a partial_object" +
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    15
  le :: "['a, 'a] => bool" (infixl "\<sqsubseteq>\<index>" 50)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    16
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    17
locale order_syntax = struct L
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    18
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    19
locale partial_order = order_syntax +
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    20
  assumes refl [intro, simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    21
                  "x \<in> carrier L ==> x \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    22
    and anti_sym [intro]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    23
                  "[| x \<sqsubseteq> y; y \<sqsubseteq> x; x \<in> carrier L; y \<in> carrier L |] ==> x = y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    24
    and trans [trans]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    25
                  "[| x \<sqsubseteq> y; y \<sqsubseteq> z;
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    26
                   x \<in> carrier L; y \<in> carrier L; z \<in> carrier L |] ==> x \<sqsubseteq> z"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    27
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    28
constdefs (structure L)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    29
  less :: "[_, 'a, 'a] => bool" (infixl "\<sqsubset>\<index>" 50)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    30
  "x \<sqsubset> y == x \<sqsubseteq> y & x ~= y"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    31
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    32
  -- {* Upper and lower bounds of a set. *}
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    33
  Upper :: "[_, 'a set] => 'a set"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    34
  "Upper L A == {u. (ALL x. x \<in> A \<inter> carrier L --> le L x u)} \<inter>
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    35
                carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    36
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    37
  Lower :: "[_, 'a set] => 'a set"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    38
  "Lower L A == {l. (ALL x. x \<in> A \<inter> carrier L --> le L l x)} \<inter>
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    39
                carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    40
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    41
  -- {* Least and greatest, as predicate. *}
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    42
  least :: "[_, 'a, 'a set] => bool"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    43
  "least L l A == A \<subseteq> carrier L & l \<in> A & (ALL x : A. le L l x)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    44
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    45
  greatest :: "[_, 'a, 'a set] => bool"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    46
  "greatest L g A == A \<subseteq> carrier L & g \<in> A & (ALL x : A. le L x g)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    47
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    48
  -- {* Supremum and infimum *}
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    49
  sup :: "[_, 'a set] => 'a" ("\<Squnion>\<index>_" [90] 90)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    50
  "\<Squnion>A == THE x. least L x (Upper L A)"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    51
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    52
  inf :: "[_, 'a set] => 'a" ("\<Sqinter>\<index>_" [90] 90)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    53
  "\<Sqinter>A == THE x. greatest L x (Lower L A)"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    54
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    55
  join :: "[_, 'a, 'a] => 'a" (infixl "\<squnion>\<index>" 65)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    56
  "x \<squnion> y == sup L {x, y}"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    57
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    58
  meet :: "[_, 'a, 'a] => 'a" (infixl "\<sqinter>\<index>" 65)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    59
  "x \<sqinter> y == inf L {x, y}"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    60
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    61
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    62
subsubsection {* Upper *}
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    63
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    64
lemma Upper_closed [intro, simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    65
  "Upper L A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    66
  by (unfold Upper_def) clarify
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    67
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    68
lemma UpperD [dest]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    69
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    70
  shows "[| u \<in> Upper L A; x \<in> A; A \<subseteq> carrier L |] ==> x \<sqsubseteq> u"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    71
  by (unfold Upper_def) blast 
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    72
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    73
lemma Upper_memI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    74
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    75
  shows "[| !! y. y \<in> A ==> y \<sqsubseteq> x; x \<in> carrier L |] ==> x \<in> Upper L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    76
  by (unfold Upper_def) blast 
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    77
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    78
lemma Upper_antimono:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    79
  "A \<subseteq> B ==> Upper L B \<subseteq> Upper L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    80
  by (unfold Upper_def) blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    81
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    82
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
    83
subsubsection {* Lower *}
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    84
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    85
lemma Lower_closed [intro, simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    86
  "Lower L A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    87
  by (unfold Lower_def) clarify
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    88
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    89
lemma LowerD [dest]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    90
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    91
  shows "[| l \<in> Lower L A; x \<in> A; A \<subseteq> carrier L |] ==> l \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    92
  by (unfold Lower_def) blast 
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    93
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    94
lemma Lower_memI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    95
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    96
  shows "[| !! y. y \<in> A ==> x \<sqsubseteq> y; x \<in> carrier L |] ==> x \<in> Lower L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    97
  by (unfold Lower_def) blast 
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    98
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
    99
lemma Lower_antimono:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   100
  "A \<subseteq> B ==> Lower L B \<subseteq> Lower L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   101
  by (unfold Lower_def) blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   102
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   103
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   104
subsubsection {* least *}
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   105
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   106
lemma least_carrier [intro, simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   107
  shows "least L l A ==> l \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   108
  by (unfold least_def) fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   109
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   110
lemma least_mem:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   111
  "least L l A ==> l \<in> A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   112
  by (unfold least_def) fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   113
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   114
lemma (in partial_order) least_unique:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   115
  "[| least L x A; least L y A |] ==> x = y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   116
  by (unfold least_def) blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   117
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   118
lemma least_le:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   119
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   120
  shows "[| least L x A; a \<in> A |] ==> x \<sqsubseteq> a"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   121
  by (unfold least_def) fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   122
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   123
lemma least_UpperI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   124
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   125
  assumes above: "!! x. x \<in> A ==> x \<sqsubseteq> s"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   126
    and below: "!! y. y \<in> Upper L A ==> s \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   127
    and L: "A \<subseteq> carrier L" "s \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   128
  shows "least L s (Upper L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   129
proof (unfold least_def, intro conjI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   130
  show "Upper L A \<subseteq> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   131
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   132
  from above L show "s \<in> Upper L A" by (simp add: Upper_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   133
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   134
  from below show "ALL x : Upper L A. s \<sqsubseteq> x" by fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   135
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   136
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   137
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   138
subsubsection {* greatest *}
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   139
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   140
lemma greatest_carrier [intro, simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   141
  shows "greatest L l A ==> l \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   142
  by (unfold greatest_def) fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   143
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   144
lemma greatest_mem:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   145
  "greatest L l A ==> l \<in> A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   146
  by (unfold greatest_def) fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   147
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   148
lemma (in partial_order) greatest_unique:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   149
  "[| greatest L x A; greatest L y A |] ==> x = y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   150
  by (unfold greatest_def) blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   151
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   152
lemma greatest_le:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   153
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   154
  shows "[| greatest L x A; a \<in> A |] ==> a \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   155
  by (unfold greatest_def) fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   156
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   157
lemma greatest_LowerI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   158
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   159
  assumes below: "!! x. x \<in> A ==> i \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   160
    and above: "!! y. y \<in> Lower L A ==> y \<sqsubseteq> i"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   161
    and L: "A \<subseteq> carrier L" "i \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   162
  shows "greatest L i (Lower L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   163
proof (unfold greatest_def, intro conjI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   164
  show "Lower L A \<subseteq> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   165
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   166
  from below L show "i \<in> Lower L A" by (simp add: Lower_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   167
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   168
  from above show "ALL x : Lower L A. x \<sqsubseteq> i" by fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   169
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   170
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   171
subsection {* Lattices *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   172
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   173
locale lattice = partial_order +
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   174
  assumes sup_of_two_exists:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   175
    "[| x \<in> carrier L; y \<in> carrier L |] ==> EX s. least L s (Upper L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   176
    and inf_of_two_exists:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   177
    "[| x \<in> carrier L; y \<in> carrier L |] ==> EX s. greatest L s (Lower L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   178
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   179
lemma least_Upper_above:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   180
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   181
  shows "[| least L s (Upper L A); x \<in> A; A \<subseteq> carrier L |] ==> x \<sqsubseteq> s"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   182
  by (unfold least_def) blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   183
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   184
lemma greatest_Lower_above:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   185
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   186
  shows "[| greatest L i (Lower L A); x \<in> A; A \<subseteq> carrier L |] ==> i \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   187
  by (unfold greatest_def) blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   188
14666
65f8680c3f16 improved notation;
wenzelm
parents: 14651
diff changeset
   189
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   190
subsubsection {* Supremum *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   191
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   192
lemma (in lattice) joinI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   193
  "[| !!l. least L l (Upper L {x, y}) ==> P l; x \<in> carrier L; y \<in> carrier L |]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   194
  ==> P (x \<squnion> y)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   195
proof (unfold join_def sup_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   196
  assume L: "x \<in> carrier L" "y \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   197
    and P: "!!l. least L l (Upper L {x, y}) ==> P l"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   198
  with sup_of_two_exists obtain s where "least L s (Upper L {x, y})" by fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   199
  with L show "P (THE l. least L l (Upper L {x, y}))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   200
  by (fast intro: theI2 least_unique P)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   201
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   202
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   203
lemma (in lattice) join_closed [simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   204
  "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<squnion> y \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   205
  by (rule joinI) (rule least_carrier)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   206
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   207
lemma (in partial_order) sup_of_singletonI:      (* only reflexivity needed ? *)
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   208
  "x \<in> carrier L ==> least L x (Upper L {x})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   209
  by (rule least_UpperI) fast+
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   210
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   211
lemma (in partial_order) sup_of_singleton [simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   212
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   213
  shows "x \<in> carrier L ==> \<Squnion> {x} = x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   214
  by (unfold sup_def) (blast intro: least_unique least_UpperI sup_of_singletonI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   215
14666
65f8680c3f16 improved notation;
wenzelm
parents: 14651
diff changeset
   216
65f8680c3f16 improved notation;
wenzelm
parents: 14651
diff changeset
   217
text {* Condition on @{text A}: supremum exists. *}
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   218
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   219
lemma (in lattice) sup_insertI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   220
  "[| !!s. least L s (Upper L (insert x A)) ==> P s;
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   221
  least L a (Upper L A); x \<in> carrier L; A \<subseteq> carrier L |]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   222
  ==> P (\<Squnion> (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   223
proof (unfold sup_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   224
  assume L: "x \<in> carrier L" "A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   225
    and P: "!!l. least L l (Upper L (insert x A)) ==> P l"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   226
    and least_a: "least L a (Upper L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   227
  from L least_a have La: "a \<in> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   228
  from L sup_of_two_exists least_a
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   229
  obtain s where least_s: "least L s (Upper L {a, x})" by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   230
  show "P (THE l. least L l (Upper L (insert x A)))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   231
  proof (rule theI2 [where a = s])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   232
    show "least L s (Upper L (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   233
    proof (rule least_UpperI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   234
      fix z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   235
      assume xA: "z \<in> insert x A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   236
      show "z \<sqsubseteq> s"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   237
      proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   238
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   239
	  assume "z = x" then have ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   240
	    by (simp add: least_Upper_above [OF least_s] L La)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   241
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   242
	moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   243
        {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   244
	  assume "z \<in> A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   245
          with L least_s least_a have ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   246
	    by (rule_tac trans [where y = a]) (auto dest: least_Upper_above)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   247
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   248
      moreover note xA
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   249
      ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   250
    qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   251
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   252
    fix y
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   253
    assume y: "y \<in> Upper L (insert x A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   254
    show "s \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   255
    proof (rule least_le [OF least_s], rule Upper_memI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   256
      fix z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   257
      assume z: "z \<in> {a, x}"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   258
      show "z \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   259
      proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   260
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   261
          have y': "y \<in> Upper L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   262
	    apply (rule subsetD [where A = "Upper L (insert x A)"])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   263
	    apply (rule Upper_antimono) apply clarify apply assumption
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   264
	    done
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   265
	  assume "z = a"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   266
	  with y' least_a have ?thesis by (fast dest: least_le)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   267
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   268
	moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   269
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   270
           assume "z = x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   271
           with y L have ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   272
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   273
        moreover note z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   274
        ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   275
      qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   276
    qed (rule Upper_closed [THEN subsetD])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   277
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   278
    from L show "insert x A \<subseteq> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   279
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   280
    from least_s show "s \<in> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   281
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   282
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   283
    fix l
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   284
    assume least_l: "least L l (Upper L (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   285
    show "l = s"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   286
    proof (rule least_unique)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   287
      show "least L s (Upper L (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   288
      proof (rule least_UpperI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   289
	fix z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   290
	assume xA: "z \<in> insert x A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   291
	show "z \<sqsubseteq> s"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   292
      proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   293
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   294
	  assume "z = x" then have ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   295
	    by (simp add: least_Upper_above [OF least_s] L La)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   296
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   297
	moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   298
        {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   299
	  assume "z \<in> A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   300
          with L least_s least_a have ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   301
	    by (rule_tac trans [where y = a]) (auto dest: least_Upper_above)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   302
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   303
	  moreover note xA
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   304
	  ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   305
	qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   306
      next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   307
	fix y
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   308
	assume y: "y \<in> Upper L (insert x A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   309
	show "s \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   310
	proof (rule least_le [OF least_s], rule Upper_memI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   311
	  fix z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   312
	  assume z: "z \<in> {a, x}"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   313
	  show "z \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   314
	  proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   315
	    {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   316
          have y': "y \<in> Upper L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   317
	    apply (rule subsetD [where A = "Upper L (insert x A)"])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   318
	    apply (rule Upper_antimono) apply clarify apply assumption
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   319
	    done
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   320
	  assume "z = a"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   321
	  with y' least_a have ?thesis by (fast dest: least_le)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   322
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   323
	moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   324
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   325
           assume "z = x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   326
           with y L have ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   327
            }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   328
            moreover note z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   329
            ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   330
	  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   331
	qed (rule Upper_closed [THEN subsetD])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   332
      next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   333
	from L show "insert x A \<subseteq> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   334
      next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   335
	from least_s show "s \<in> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   336
      qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   337
    qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   338
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   339
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   340
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   341
lemma (in lattice) finite_sup_least:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   342
  "[| finite A; A \<subseteq> carrier L; A ~= {} |] ==> least L (\<Squnion> A) (Upper L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   343
proof (induct set: Finites)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   344
  case empty then show ?case by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   345
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   346
  case (insert A x)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   347
  show ?case
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   348
  proof (cases "A = {}")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   349
    case True
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   350
    with insert show ?thesis by (simp add: sup_of_singletonI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   351
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   352
    case False
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   353
    from insert show ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   354
    proof (rule_tac sup_insertI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   355
      from False insert show "least L (\<Squnion> A) (Upper L A)" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   356
    qed simp_all
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   357
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   358
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   359
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   360
lemma (in lattice) finite_sup_insertI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   361
  assumes P: "!!l. least L l (Upper L (insert x A)) ==> P l"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   362
    and xA: "finite A" "x \<in> carrier L" "A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   363
  shows "P (\<Squnion> (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   364
proof (cases "A = {}")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   365
  case True with P and xA show ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   366
    by (simp add: sup_of_singletonI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   367
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   368
  case False with P and xA show ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   369
    by (simp add: sup_insertI finite_sup_least)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   370
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   371
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   372
lemma (in lattice) finite_sup_closed:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   373
  "[| finite A; A \<subseteq> carrier L; A ~= {} |] ==> \<Squnion> A \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   374
proof (induct set: Finites)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   375
  case empty then show ?case by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   376
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   377
  case (insert A x) then show ?case
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   378
    by (rule_tac finite_sup_insertI) (simp_all)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   379
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   380
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   381
lemma (in lattice) join_left:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   382
  "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqsubseteq> x \<squnion> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   383
  by (rule joinI [folded join_def]) (blast dest: least_mem )
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   384
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   385
lemma (in lattice) join_right:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   386
  "[| x \<in> carrier L; y \<in> carrier L |] ==> y \<sqsubseteq> x \<squnion> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   387
  by (rule joinI [folded join_def]) (blast dest: least_mem )
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   388
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   389
lemma (in lattice) sup_of_two_least:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   390
  "[| x \<in> carrier L; y \<in> carrier L |] ==> least L (\<Squnion> {x, y}) (Upper L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   391
proof (unfold sup_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   392
  assume L: "x \<in> carrier L" "y \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   393
  with sup_of_two_exists obtain s where "least L s (Upper L {x, y})" by fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   394
  with L show "least L (THE xa. least L xa (Upper L {x, y})) (Upper L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   395
  by (fast intro: theI2 least_unique)  (* blast fails *)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   396
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   397
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   398
lemma (in lattice) join_le:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   399
  assumes sub: "x \<sqsubseteq> z" "y \<sqsubseteq> z"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   400
    and L: "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   401
  shows "x \<squnion> y \<sqsubseteq> z"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   402
proof (rule joinI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   403
  fix s
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   404
  assume "least L s (Upper L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   405
  with sub L show "s \<sqsubseteq> z" by (fast elim: least_le intro: Upper_memI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   406
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   407
  
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   408
lemma (in lattice) join_assoc_lemma:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   409
  assumes L: "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   410
  shows "x \<squnion> (y \<squnion> z) = \<Squnion> {x, y, z}"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   411
proof (rule finite_sup_insertI)
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   412
  -- {* The textbook argument in Jacobson I, p 457 *}
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   413
  fix s
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   414
  assume sup: "least L s (Upper L {x, y, z})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   415
  show "x \<squnion> (y \<squnion> z) = s"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   416
  proof (rule anti_sym)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   417
    from sup L show "x \<squnion> (y \<squnion> z) \<sqsubseteq> s"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   418
      by (fastsimp intro!: join_le elim: least_Upper_above)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   419
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   420
    from sup L show "s \<sqsubseteq> x \<squnion> (y \<squnion> z)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   421
    by (erule_tac least_le)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   422
      (blast intro!: Upper_memI intro: trans join_left join_right join_closed)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   423
  qed (simp_all add: L least_carrier [OF sup])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   424
qed (simp_all add: L)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   425
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   426
lemma join_comm:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   427
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   428
  shows "x \<squnion> y = y \<squnion> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   429
  by (unfold join_def) (simp add: insert_commute)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   430
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   431
lemma (in lattice) join_assoc:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   432
  assumes L: "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   433
  shows "(x \<squnion> y) \<squnion> z = x \<squnion> (y \<squnion> z)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   434
proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   435
  have "(x \<squnion> y) \<squnion> z = z \<squnion> (x \<squnion> y)" by (simp only: join_comm)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   436
  also from L have "... = \<Squnion> {z, x, y}" by (simp add: join_assoc_lemma)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   437
  also from L have "... = \<Squnion> {x, y, z}" by (simp add: insert_commute)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   438
  also from L have "... = x \<squnion> (y \<squnion> z)" by (simp add: join_assoc_lemma)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   439
  finally show ?thesis .
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   440
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   441
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   442
subsubsection {* Infimum *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   443
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   444
lemma (in lattice) meetI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   445
  "[| !!i. greatest L i (Lower L {x, y}) ==> P i;
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   446
  x \<in> carrier L; y \<in> carrier L |]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   447
  ==> P (x \<sqinter> y)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   448
proof (unfold meet_def inf_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   449
  assume L: "x \<in> carrier L" "y \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   450
    and P: "!!g. greatest L g (Lower L {x, y}) ==> P g"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   451
  with inf_of_two_exists obtain i where "greatest L i (Lower L {x, y})" by fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   452
  with L show "P (THE g. greatest L g (Lower L {x, y}))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   453
  by (fast intro: theI2 greatest_unique P)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   454
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   455
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   456
lemma (in lattice) meet_closed [simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   457
  "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqinter> y \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   458
  by (rule meetI) (rule greatest_carrier)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   459
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   460
lemma (in partial_order) inf_of_singletonI:      (* only reflexivity needed ? *)
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   461
  "x \<in> carrier L ==> greatest L x (Lower L {x})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   462
  by (rule greatest_LowerI) fast+
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   463
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   464
lemma (in partial_order) inf_of_singleton [simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   465
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   466
  shows "x \<in> carrier L ==> \<Sqinter> {x} = x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   467
  by (unfold inf_def) (blast intro: greatest_unique greatest_LowerI inf_of_singletonI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   468
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   469
text {* Condition on A: infimum exists. *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   470
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   471
lemma (in lattice) inf_insertI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   472
  "[| !!i. greatest L i (Lower L (insert x A)) ==> P i;
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   473
  greatest L a (Lower L A); x \<in> carrier L; A \<subseteq> carrier L |]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   474
  ==> P (\<Sqinter> (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   475
proof (unfold inf_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   476
  assume L: "x \<in> carrier L" "A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   477
    and P: "!!g. greatest L g (Lower L (insert x A)) ==> P g"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   478
    and greatest_a: "greatest L a (Lower L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   479
  from L greatest_a have La: "a \<in> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   480
  from L inf_of_two_exists greatest_a
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   481
  obtain i where greatest_i: "greatest L i (Lower L {a, x})" by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   482
  show "P (THE g. greatest L g (Lower L (insert x A)))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   483
  proof (rule theI2 [where a = i])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   484
    show "greatest L i (Lower L (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   485
    proof (rule greatest_LowerI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   486
      fix z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   487
      assume xA: "z \<in> insert x A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   488
      show "i \<sqsubseteq> z"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   489
      proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   490
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   491
	  assume "z = x" then have ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   492
	    by (simp add: greatest_Lower_above [OF greatest_i] L La)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   493
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   494
	moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   495
        {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   496
	  assume "z \<in> A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   497
          with L greatest_i greatest_a have ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   498
	    by (rule_tac trans [where y = a]) (auto dest: greatest_Lower_above)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   499
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   500
      moreover note xA
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   501
      ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   502
    qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   503
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   504
    fix y
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   505
    assume y: "y \<in> Lower L (insert x A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   506
    show "y \<sqsubseteq> i"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   507
    proof (rule greatest_le [OF greatest_i], rule Lower_memI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   508
      fix z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   509
      assume z: "z \<in> {a, x}"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   510
      show "y \<sqsubseteq> z"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   511
      proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   512
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   513
          have y': "y \<in> Lower L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   514
	    apply (rule subsetD [where A = "Lower L (insert x A)"])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   515
	    apply (rule Lower_antimono) apply clarify apply assumption
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   516
	    done
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   517
	  assume "z = a"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   518
	  with y' greatest_a have ?thesis by (fast dest: greatest_le)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   519
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   520
	moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   521
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   522
           assume "z = x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   523
           with y L have ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   524
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   525
        moreover note z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   526
        ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   527
      qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   528
    qed (rule Lower_closed [THEN subsetD])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   529
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   530
    from L show "insert x A \<subseteq> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   531
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   532
    from greatest_i show "i \<in> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   533
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   534
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   535
    fix g
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   536
    assume greatest_g: "greatest L g (Lower L (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   537
    show "g = i"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   538
    proof (rule greatest_unique)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   539
      show "greatest L i (Lower L (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   540
      proof (rule greatest_LowerI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   541
	fix z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   542
	assume xA: "z \<in> insert x A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   543
	show "i \<sqsubseteq> z"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   544
      proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   545
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   546
	  assume "z = x" then have ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   547
	    by (simp add: greatest_Lower_above [OF greatest_i] L La)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   548
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   549
	moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   550
        {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   551
	  assume "z \<in> A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   552
          with L greatest_i greatest_a have ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   553
	    by (rule_tac trans [where y = a]) (auto dest: greatest_Lower_above)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   554
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   555
	  moreover note xA
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   556
	  ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   557
	qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   558
      next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   559
	fix y
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   560
	assume y: "y \<in> Lower L (insert x A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   561
	show "y \<sqsubseteq> i"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   562
	proof (rule greatest_le [OF greatest_i], rule Lower_memI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   563
	  fix z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   564
	  assume z: "z \<in> {a, x}"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   565
	  show "y \<sqsubseteq> z"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   566
	  proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   567
	    {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   568
          have y': "y \<in> Lower L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   569
	    apply (rule subsetD [where A = "Lower L (insert x A)"])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   570
	    apply (rule Lower_antimono) apply clarify apply assumption
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   571
	    done
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   572
	  assume "z = a"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   573
	  with y' greatest_a have ?thesis by (fast dest: greatest_le)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   574
        }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   575
	moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   576
	{
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   577
           assume "z = x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   578
           with y L have ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   579
            }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   580
            moreover note z
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   581
            ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   582
	  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   583
	qed (rule Lower_closed [THEN subsetD])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   584
      next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   585
	from L show "insert x A \<subseteq> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   586
      next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   587
	from greatest_i show "i \<in> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   588
      qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   589
    qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   590
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   591
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   592
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   593
lemma (in lattice) finite_inf_greatest:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   594
  "[| finite A; A \<subseteq> carrier L; A ~= {} |] ==> greatest L (\<Sqinter> A) (Lower L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   595
proof (induct set: Finites)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   596
  case empty then show ?case by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   597
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   598
  case (insert A x)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   599
  show ?case
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   600
  proof (cases "A = {}")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   601
    case True
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   602
    with insert show ?thesis by (simp add: inf_of_singletonI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   603
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   604
    case False
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   605
    from insert show ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   606
    proof (rule_tac inf_insertI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   607
      from False insert show "greatest L (\<Sqinter> A) (Lower L A)" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   608
    qed simp_all
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   609
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   610
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   611
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   612
lemma (in lattice) finite_inf_insertI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   613
  assumes P: "!!i. greatest L i (Lower L (insert x A)) ==> P i"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   614
    and xA: "finite A" "x \<in> carrier L" "A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   615
  shows "P (\<Sqinter> (insert x A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   616
proof (cases "A = {}")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   617
  case True with P and xA show ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   618
    by (simp add: inf_of_singletonI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   619
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   620
  case False with P and xA show ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   621
    by (simp add: inf_insertI finite_inf_greatest)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   622
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   623
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   624
lemma (in lattice) finite_inf_closed:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   625
  "[| finite A; A \<subseteq> carrier L; A ~= {} |] ==> \<Sqinter> A \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   626
proof (induct set: Finites)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   627
  case empty then show ?case by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   628
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   629
  case (insert A x) then show ?case
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   630
    by (rule_tac finite_inf_insertI) (simp_all)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   631
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   632
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   633
lemma (in lattice) meet_left:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   634
  "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqinter> y \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   635
  by (rule meetI [folded meet_def]) (blast dest: greatest_mem )
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   636
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   637
lemma (in lattice) meet_right:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   638
  "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqinter> y \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   639
  by (rule meetI [folded meet_def]) (blast dest: greatest_mem )
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   640
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   641
lemma (in lattice) inf_of_two_greatest:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   642
  "[| x \<in> carrier L; y \<in> carrier L |] ==>
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   643
  greatest L (\<Sqinter> {x, y}) (Lower L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   644
proof (unfold inf_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   645
  assume L: "x \<in> carrier L" "y \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   646
  with inf_of_two_exists obtain s where "greatest L s (Lower L {x, y})" by fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   647
  with L
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   648
  show "greatest L (THE xa. greatest L xa (Lower L {x, y})) (Lower L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   649
  by (fast intro: theI2 greatest_unique)  (* blast fails *)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   650
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   651
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   652
lemma (in lattice) meet_le:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   653
  assumes sub: "z \<sqsubseteq> x" "z \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   654
    and L: "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   655
  shows "z \<sqsubseteq> x \<sqinter> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   656
proof (rule meetI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   657
  fix i
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   658
  assume "greatest L i (Lower L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   659
  with sub L show "z \<sqsubseteq> i" by (fast elim: greatest_le intro: Lower_memI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   660
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   661
  
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   662
lemma (in lattice) meet_assoc_lemma:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   663
  assumes L: "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   664
  shows "x \<sqinter> (y \<sqinter> z) = \<Sqinter> {x, y, z}"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   665
proof (rule finite_inf_insertI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   666
  txt {* The textbook argument in Jacobson I, p 457 *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   667
  fix i
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   668
  assume inf: "greatest L i (Lower L {x, y, z})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   669
  show "x \<sqinter> (y \<sqinter> z) = i"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   670
  proof (rule anti_sym)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   671
    from inf L show "i \<sqsubseteq> x \<sqinter> (y \<sqinter> z)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   672
      by (fastsimp intro!: meet_le elim: greatest_Lower_above)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   673
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   674
    from inf L show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> i"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   675
    by (erule_tac greatest_le)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   676
      (blast intro!: Lower_memI intro: trans meet_left meet_right meet_closed)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   677
  qed (simp_all add: L greatest_carrier [OF inf])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   678
qed (simp_all add: L)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   679
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   680
lemma meet_comm:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   681
  includes order_syntax
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   682
  shows "x \<sqinter> y = y \<sqinter> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   683
  by (unfold meet_def) (simp add: insert_commute)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   684
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   685
lemma (in lattice) meet_assoc:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   686
  assumes L: "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   687
  shows "(x \<sqinter> y) \<sqinter> z = x \<sqinter> (y \<sqinter> z)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   688
proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   689
  have "(x \<sqinter> y) \<sqinter> z = z \<sqinter> (x \<sqinter> y)" by (simp only: meet_comm)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   690
  also from L have "... = \<Sqinter> {z, x, y}" by (simp add: meet_assoc_lemma)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   691
  also from L have "... = \<Sqinter> {x, y, z}" by (simp add: insert_commute)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   692
  also from L have "... = x \<sqinter> (y \<sqinter> z)" by (simp add: meet_assoc_lemma)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   693
  finally show ?thesis .
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   694
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   695
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   696
subsection {* Total Orders *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   697
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   698
locale total_order = lattice +
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   699
  assumes total: "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqsubseteq> y | y \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   700
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   701
text {* Introduction rule: the usual definition of total order *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   702
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   703
lemma (in partial_order) total_orderI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   704
  assumes total: "!!x y. [| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqsubseteq> y | y \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   705
  shows "total_order L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   706
proof (rule total_order.intro)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   707
  show "lattice_axioms L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   708
  proof (rule lattice_axioms.intro)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   709
    fix x y
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   710
    assume L: "x \<in> carrier L" "y \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   711
    show "EX s. least L s (Upper L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   712
    proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   713
      note total L
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   714
      moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   715
      {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   716
	assume "x \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   717
        with L have "least L y (Upper L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   718
	  by (rule_tac least_UpperI) auto
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   719
      }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   720
      moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   721
      {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   722
	assume "y \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   723
        with L have "least L x (Upper L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   724
	  by (rule_tac least_UpperI) auto
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   725
      }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   726
      ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   727
    qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   728
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   729
    fix x y
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   730
    assume L: "x \<in> carrier L" "y \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   731
    show "EX i. greatest L i (Lower L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   732
    proof -
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   733
      note total L
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   734
      moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   735
      {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   736
	assume "y \<sqsubseteq> x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   737
        with L have "greatest L y (Lower L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   738
	  by (rule_tac greatest_LowerI) auto
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   739
      }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   740
      moreover
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   741
      {
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   742
	assume "x \<sqsubseteq> y"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   743
        with L have "greatest L x (Lower L {x, y})"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   744
	  by (rule_tac greatest_LowerI) auto
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   745
      }
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   746
      ultimately show ?thesis by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   747
    qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   748
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   749
qed (assumption | rule total_order_axioms.intro)+
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   750
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   751
subsection {* Complete lattices *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   752
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   753
locale complete_lattice = lattice +
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   754
  assumes sup_exists:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   755
    "[| A \<subseteq> carrier L |] ==> EX s. least L s (Upper L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   756
    and inf_exists:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   757
    "[| A \<subseteq> carrier L |] ==> EX i. greatest L i (Lower L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   758
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   759
text {* Introduction rule: the usual definition of complete lattice *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   760
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   761
lemma (in partial_order) complete_latticeI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   762
  assumes sup_exists:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   763
    "!!A. [| A \<subseteq> carrier L |] ==> EX s. least L s (Upper L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   764
    and inf_exists:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   765
    "!!A. [| A \<subseteq> carrier L |] ==> EX i. greatest L i (Lower L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   766
  shows "complete_lattice L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   767
proof (rule complete_lattice.intro)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   768
  show "lattice_axioms L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   769
  by (rule lattice_axioms.intro) (blast intro: sup_exists inf_exists)+
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   770
qed (assumption | rule complete_lattice_axioms.intro)+
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   771
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   772
constdefs (structure L)
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   773
  top :: "_ => 'a" ("\<top>\<index>")
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   774
  "\<top> == sup L (carrier L)"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   775
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   776
  bottom :: "_ => 'a" ("\<bottom>\<index>")
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   777
  "\<bottom> == inf L (carrier L)"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   778
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   779
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   780
lemma (in complete_lattice) supI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   781
  "[| !!l. least L l (Upper L A) ==> P l; A \<subseteq> carrier L |]
14651
02b8f3bcf7fe improved notation;
wenzelm
parents: 14577
diff changeset
   782
  ==> P (\<Squnion>A)"
14551
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   783
proof (unfold sup_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   784
  assume L: "A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   785
    and P: "!!l. least L l (Upper L A) ==> P l"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   786
  with sup_exists obtain s where "least L s (Upper L A)" by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   787
  with L show "P (THE l. least L l (Upper L A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   788
  by (fast intro: theI2 least_unique P)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   789
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   790
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   791
lemma (in complete_lattice) sup_closed [simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   792
  "A \<subseteq> carrier L ==> \<Squnion> A \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   793
  by (rule supI) simp_all
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   794
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   795
lemma (in complete_lattice) top_closed [simp, intro]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   796
  "\<top> \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   797
  by (unfold top_def) simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   798
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   799
lemma (in complete_lattice) infI:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   800
  "[| !!i. greatest L i (Lower L A) ==> P i; A \<subseteq> carrier L |]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   801
  ==> P (\<Sqinter> A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   802
proof (unfold inf_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   803
  assume L: "A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   804
    and P: "!!l. greatest L l (Lower L A) ==> P l"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   805
  with inf_exists obtain s where "greatest L s (Lower L A)" by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   806
  with L show "P (THE l. greatest L l (Lower L A))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   807
  by (fast intro: theI2 greatest_unique P)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   808
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   809
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   810
lemma (in complete_lattice) inf_closed [simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   811
  "A \<subseteq> carrier L ==> \<Sqinter> A \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   812
  by (rule infI) simp_all
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   813
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   814
lemma (in complete_lattice) bottom_closed [simp, intro]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   815
  "\<bottom> \<in> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   816
  by (unfold bottom_def) simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   817
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   818
text {* Jacobson: Theorem 8.1 *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   819
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   820
lemma Lower_empty [simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   821
  "Lower L {} = carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   822
  by (unfold Lower_def) simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   823
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   824
lemma Upper_empty [simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   825
  "Upper L {} = carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   826
  by (unfold Upper_def) simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   827
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   828
theorem (in partial_order) complete_lattice_criterion1:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   829
  assumes top_exists: "EX g. greatest L g (carrier L)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   830
    and inf_exists:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   831
      "!!A. [| A \<subseteq> carrier L; A ~= {} |] ==> EX i. greatest L i (Lower L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   832
  shows "complete_lattice L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   833
proof (rule complete_latticeI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   834
  from top_exists obtain top where top: "greatest L top (carrier L)" ..
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   835
  fix A
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   836
  assume L: "A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   837
  let ?B = "Upper L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   838
  from L top have "top \<in> ?B" by (fast intro!: Upper_memI intro: greatest_le)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   839
  then have B_non_empty: "?B ~= {}" by fast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   840
  have B_L: "?B \<subseteq> carrier L" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   841
  from inf_exists [OF B_L B_non_empty]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   842
  obtain b where b_inf_B: "greatest L b (Lower L ?B)" ..
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   843
  have "least L b (Upper L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   844
apply (rule least_UpperI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   845
   apply (rule greatest_le [where A = "Lower L ?B"]) 
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   846
    apply (rule b_inf_B)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   847
   apply (rule Lower_memI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   848
    apply (erule UpperD)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   849
     apply assumption
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   850
    apply (rule L)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   851
   apply (fast intro: L [THEN subsetD])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   852
  apply (erule greatest_Lower_above [OF b_inf_B])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   853
  apply simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   854
 apply (rule L)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   855
apply (rule greatest_carrier [OF b_inf_B]) (* rename rule: _closed *)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   856
done
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   857
  then show "EX s. least L s (Upper L A)" ..
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   858
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   859
  fix A
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   860
  assume L: "A \<subseteq> carrier L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   861
  show "EX i. greatest L i (Lower L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   862
  proof (cases "A = {}")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   863
    case True then show ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   864
      by (simp add: top_exists)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   865
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   866
    case False with L show ?thesis
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   867
      by (rule inf_exists)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   868
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   869
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   870
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   871
(* TODO: prove dual version *)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   872
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   873
subsection {* Examples *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   874
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   875
subsubsection {* Powerset of a set is a complete lattice *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   876
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   877
theorem powerset_is_complete_lattice:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   878
  "complete_lattice (| carrier = Pow A, le = op \<subseteq> |)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   879
  (is "complete_lattice ?L")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   880
proof (rule partial_order.complete_latticeI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   881
  show "partial_order ?L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   882
    by (rule partial_order.intro) auto
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   883
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   884
  fix B
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   885
  assume "B \<subseteq> carrier ?L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   886
  then have "least ?L (\<Union> B) (Upper ?L B)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   887
    by (fastsimp intro!: least_UpperI simp: Upper_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   888
  then show "EX s. least ?L s (Upper ?L B)" ..
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   889
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   890
  fix B
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   891
  assume "B \<subseteq> carrier ?L"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   892
  then have "greatest ?L (\<Inter> B \<inter> A) (Lower ?L B)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   893
    txt {* @{term "\<Inter> B"} is not the infimum of @{term B}:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   894
      @{term "\<Inter> {} = UNIV"} which is in general bigger than @{term "A"}! *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   895
    by (fastsimp intro!: greatest_LowerI simp: Lower_def)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   896
  then show "EX i. greatest ?L i (Lower ?L B)" ..
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   897
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   898
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   899
subsubsection {* Lattice of subgroups of a group *}
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   900
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   901
theorem (in group) subgroups_partial_order:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   902
  "partial_order (| carrier = {H. subgroup H G}, le = op \<subseteq> |)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   903
  by (rule partial_order.intro) simp_all
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   904
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   905
lemma (in group) subgroup_self:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   906
  "subgroup (carrier G) G"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   907
  by (rule subgroupI) auto
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   908
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   909
lemma (in group) subgroup_imp_group:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   910
  "subgroup H G ==> group (G(| carrier := H |))"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   911
  using subgroup.groupI [OF _ group.intro] .
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   912
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   913
lemma (in group) is_monoid [intro, simp]:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   914
  "monoid G"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   915
  by (rule monoid.intro)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   916
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   917
lemma (in group) subgroup_inv_equality:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   918
  "[| subgroup H G; x \<in> H |] ==> m_inv (G (| carrier := H |)) x = inv x"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   919
apply (rule_tac inv_equality [THEN sym])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   920
  apply (rule group.l_inv [OF subgroup_imp_group, simplified])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   921
   apply assumption+
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   922
 apply (rule subsetD [OF subgroup.subset])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   923
  apply assumption+
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   924
apply (rule subsetD [OF subgroup.subset])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   925
 apply assumption
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   926
apply (rule_tac group.inv_closed [OF subgroup_imp_group, simplified])
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   927
  apply assumption+
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   928
done
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   929
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   930
theorem (in group) subgroups_Inter:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   931
  assumes subgr: "(!!H. H \<in> A ==> subgroup H G)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   932
    and not_empty: "A ~= {}"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   933
  shows "subgroup (\<Inter>A) G"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   934
proof (rule subgroupI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   935
  from subgr [THEN subgroup.subset] and not_empty
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   936
  show "\<Inter>A \<subseteq> carrier G" by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   937
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   938
  from subgr [THEN subgroup.one_closed]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   939
  show "\<Inter>A ~= {}" by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   940
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   941
  fix x assume "x \<in> \<Inter>A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   942
  with subgr [THEN subgroup.m_inv_closed]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   943
  show "inv x \<in> \<Inter>A" by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   944
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   945
  fix x y assume "x \<in> \<Inter>A" "y \<in> \<Inter>A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   946
  with subgr [THEN subgroup.m_closed]
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   947
  show "x \<otimes> y \<in> \<Inter>A" by blast
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   948
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   949
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   950
theorem (in group) subgroups_complete_lattice:
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   951
  "complete_lattice (| carrier = {H. subgroup H G}, le = op \<subseteq> |)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   952
    (is "complete_lattice ?L")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   953
proof (rule partial_order.complete_lattice_criterion1)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   954
  show "partial_order ?L" by (rule subgroups_partial_order)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   955
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   956
  have "greatest ?L (carrier G) (carrier ?L)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   957
    by (unfold greatest_def) (simp add: subgroup.subset subgroup_self)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   958
  then show "EX G. greatest ?L G (carrier ?L)" ..
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   959
next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   960
  fix A
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   961
  assume L: "A \<subseteq> carrier ?L" and non_empty: "A ~= {}"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   962
  then have Int_subgroup: "subgroup (\<Inter>A) G"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   963
    by (fastsimp intro: subgroups_Inter)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   964
  have "greatest ?L (\<Inter>A) (Lower ?L A)"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   965
    (is "greatest ?L ?Int _")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   966
  proof (rule greatest_LowerI)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   967
    fix H
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   968
    assume H: "H \<in> A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   969
    with L have subgroupH: "subgroup H G" by auto
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   970
    from subgroupH have submagmaH: "submagma H G" by (rule subgroup.axioms)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   971
    from subgroupH have groupH: "group (G (| carrier := H |))" (is "group ?H")
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   972
      by (rule subgroup_imp_group)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   973
    from groupH have monoidH: "monoid ?H"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   974
      by (rule group.is_monoid)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   975
    from H have Int_subset: "?Int \<subseteq> H" by fastsimp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   976
    then show "le ?L ?Int H" by simp
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   977
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   978
    fix H
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   979
    assume H: "H \<in> Lower ?L A"
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   980
    with L Int_subgroup show "le ?L H ?Int" by (fastsimp intro: Inter_greatest)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   981
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   982
    show "A \<subseteq> carrier ?L" by (rule L)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   983
  next
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   984
    show "?Int \<in> carrier ?L" by simp (rule Int_subgroup)
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   985
  qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   986
  then show "EX I. greatest ?L I (Lower ?L A)" ..
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   987
qed
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   988
2cb6ff394bfb Various changes to HOL-Algebra;
ballarin
parents:
diff changeset
   989
end