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