src/HOL/Algebra/Lattice.thy
changeset 14651 02b8f3bcf7fe
parent 14577 dbb95b825244
child 14666 65f8680c3f16
equal deleted inserted replaced
14650:0390abdd1e62 14651:02b8f3bcf7fe
    23                   "[| x \<sqsubseteq> y; y \<sqsubseteq> x; x \<in> carrier L; y \<in> carrier L |] ==> x = y"
    23                   "[| x \<sqsubseteq> y; y \<sqsubseteq> x; x \<in> carrier L; y \<in> carrier L |] ==> x = y"
    24     and trans [trans]:
    24     and trans [trans]:
    25                   "[| x \<sqsubseteq> y; y \<sqsubseteq> z;
    25                   "[| x \<sqsubseteq> y; y \<sqsubseteq> z;
    26                    x \<in> carrier L; y \<in> carrier L; z \<in> carrier L |] ==> x \<sqsubseteq> z"
    26                    x \<in> carrier L; y \<in> carrier L; z \<in> carrier L |] ==> x \<sqsubseteq> z"
    27 
    27 
    28 constdefs
    28 constdefs (structure L)
    29   less :: "[('a, 'm) order_scheme, 'a, 'a] => bool" (infixl "\<sqsubset>\<index>" 50)
    29   less :: "[_, 'a, 'a] => bool" (infixl "\<sqsubset>\<index>" 50)
    30   "less L x y == le L x y & x ~= y"
    30   "x \<sqsubset> y == x \<sqsubseteq> y & x ~= y"
    31 
    31 
    32   (* Upper and lower bounds of a set. *)
    32   -- {* Upper and lower bounds of a set. *}
    33   Upper :: "[('a, 'm) order_scheme, 'a set] => 'a set"
    33   Upper :: "[_, 'a set] => 'a set"
    34   "Upper L A == {u. (ALL x. x \<in> A \<inter> carrier L --> le L x u)} \<inter>
    34   "Upper L A == {u. (ALL x. x \<in> A \<inter> carrier L --> le L x u)} \<inter>
    35                 carrier L"
    35                 carrier L"
    36 
    36 
    37   Lower :: "[('a, 'm) order_scheme, 'a set] => 'a set"
    37   Lower :: "[_, 'a set] => 'a set"
    38   "Lower L A == {l. (ALL x. x \<in> A \<inter> carrier L --> le L l x)} \<inter>
    38   "Lower L A == {l. (ALL x. x \<in> A \<inter> carrier L --> le L l x)} \<inter>
    39                 carrier L"
    39                 carrier L"
    40 
    40 
    41   (* Least and greatest, as predicate. *)
    41   -- {* Least and greatest, as predicate. *}
    42   least :: "[('a, 'm) order_scheme, 'a, 'a set] => bool"
    42   least :: "[_, 'a, 'a set] => bool"
    43   "least L l A == A \<subseteq> carrier L & l \<in> A & (ALL x : A. le L l x)"
    43   "least L l A == A \<subseteq> carrier L & l \<in> A & (ALL x : A. le L l x)"
    44 
    44 
    45   greatest :: "[('a, 'm) order_scheme, 'a, 'a set] => bool"
    45   greatest :: "[_, 'a, 'a set] => bool"
    46   "greatest L g A == A \<subseteq> carrier L & g \<in> A & (ALL x : A. le L x g)"
    46   "greatest L g A == A \<subseteq> carrier L & g \<in> A & (ALL x : A. le L x g)"
    47 
    47 
    48   (* Supremum and infimum *)
    48   -- {* Supremum and infimum *}
    49   sup :: "[('a, 'm) order_scheme, 'a set] => 'a" ("\<Squnion>\<index>_" [90] 90)
    49   sup :: "[_, 'a set] => 'a" ("\<Squnion>\<index>_" [90] 90)
    50   "sup L A == THE x. least L x (Upper L A)"
    50   "\<Squnion>A == THE x. least L x (Upper L A)"
    51 
    51 
    52   inf :: "[('a, 'm) order_scheme, 'a set] => 'a" ("\<Sqinter>\<index>_" [90] 90)
    52   inf :: "[_, 'a set] => 'a" ("\<Sqinter>\<index>_" [90] 90)
    53   "inf L A == THE x. greatest L x (Lower L A)"
    53   "\<Sqinter>A == THE x. greatest L x (Lower L A)"
    54 
    54 
    55   join :: "[('a, 'm) order_scheme, 'a, 'a] => 'a" (infixl "\<squnion>\<index>" 65)
    55   join :: "[_, 'a, 'a] => 'a" (infixl "\<squnion>\<index>" 65)
    56   "join L x y == sup L {x, y}"
    56   "x \<squnion> y == sup L {x, y}"
    57 
    57 
    58   meet :: "[('a, 'm) order_scheme, 'a, 'a] => 'a" (infixl "\<sqinter>\<index>" 65)
    58   meet :: "[_, 'a, 'a] => 'a" (infixl "\<sqinter>\<index>" 65)
    59   "meet L x y == inf L {x, y}"
    59   "x \<sqinter> y == inf L {x, y}"
    60 
    60 
    61 (* Upper *)
    61 
       
    62 subsubsection {* Upper *}
    62 
    63 
    63 lemma Upper_closed [intro, simp]:
    64 lemma Upper_closed [intro, simp]:
    64   "Upper L A \<subseteq> carrier L"
    65   "Upper L A \<subseteq> carrier L"
    65   by (unfold Upper_def) clarify
    66   by (unfold Upper_def) clarify
    66 
    67 
    76 
    77 
    77 lemma Upper_antimono:
    78 lemma Upper_antimono:
    78   "A \<subseteq> B ==> Upper L B \<subseteq> Upper L A"
    79   "A \<subseteq> B ==> Upper L B \<subseteq> Upper L A"
    79   by (unfold Upper_def) blast
    80   by (unfold Upper_def) blast
    80 
    81 
    81 (* Lower *)
    82 
       
    83 subsubsection {* Lower *}
    82 
    84 
    83 lemma Lower_closed [intro, simp]:
    85 lemma Lower_closed [intro, simp]:
    84   "Lower L A \<subseteq> carrier L"
    86   "Lower L A \<subseteq> carrier L"
    85   by (unfold Lower_def) clarify
    87   by (unfold Lower_def) clarify
    86 
    88 
    96 
    98 
    97 lemma Lower_antimono:
    99 lemma Lower_antimono:
    98   "A \<subseteq> B ==> Lower L B \<subseteq> Lower L A"
   100   "A \<subseteq> B ==> Lower L B \<subseteq> Lower L A"
    99   by (unfold Lower_def) blast
   101   by (unfold Lower_def) blast
   100 
   102 
   101 (* least *)
   103 
       
   104 subsubsection {* least *}
   102 
   105 
   103 lemma least_carrier [intro, simp]:
   106 lemma least_carrier [intro, simp]:
   104   shows "least L l A ==> l \<in> carrier L"
   107   shows "least L l A ==> l \<in> carrier L"
   105   by (unfold least_def) fast
   108   by (unfold least_def) fast
   106 
   109 
   129   from above L show "s \<in> Upper L A" by (simp add: Upper_def)
   132   from above L show "s \<in> Upper L A" by (simp add: Upper_def)
   130 next
   133 next
   131   from below show "ALL x : Upper L A. s \<sqsubseteq> x" by fast
   134   from below show "ALL x : Upper L A. s \<sqsubseteq> x" by fast
   132 qed
   135 qed
   133 
   136 
   134 (* greatest *)
   137 
       
   138 subsubsection {* greatest *}
   135 
   139 
   136 lemma greatest_carrier [intro, simp]:
   140 lemma greatest_carrier [intro, simp]:
   137   shows "greatest L l A ==> l \<in> carrier L"
   141   shows "greatest L l A ==> l \<in> carrier L"
   138   by (unfold greatest_def) fast
   142   by (unfold greatest_def) fast
   139 
   143 
   197 
   201 
   198 lemma (in lattice) join_closed [simp]:
   202 lemma (in lattice) join_closed [simp]:
   199   "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<squnion> y \<in> carrier L"
   203   "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<squnion> y \<in> carrier L"
   200   by (rule joinI) (rule least_carrier)
   204   by (rule joinI) (rule least_carrier)
   201 
   205 
   202 lemma (in partial_order) sup_of_singletonI:
   206 lemma (in partial_order) sup_of_singletonI:      (* only reflexivity needed ? *)
   203   (* only reflexivity needed ? *)
       
   204   "x \<in> carrier L ==> least L x (Upper L {x})"
   207   "x \<in> carrier L ==> least L x (Upper L {x})"
   205   by (rule least_UpperI) fast+
   208   by (rule least_UpperI) fast+
   206 
   209 
   207 lemma (in partial_order) sup_of_singleton [simp]:
   210 lemma (in partial_order) sup_of_singleton [simp]:
   208   includes order_syntax
   211   includes order_syntax
   402   
   405   
   403 lemma (in lattice) join_assoc_lemma:
   406 lemma (in lattice) join_assoc_lemma:
   404   assumes L: "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
   407   assumes L: "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
   405   shows "x \<squnion> (y \<squnion> z) = \<Squnion> {x, y, z}"
   408   shows "x \<squnion> (y \<squnion> z) = \<Squnion> {x, y, z}"
   406 proof (rule finite_sup_insertI)
   409 proof (rule finite_sup_insertI)
   407   (* The textbook argument in Jacobson I, p 457 *)
   410   -- {* The textbook argument in Jacobson I, p 457 *}
   408   fix s
   411   fix s
   409   assume sup: "least L s (Upper L {x, y, z})"
   412   assume sup: "least L s (Upper L {x, y, z})"
   410   show "x \<squnion> (y \<squnion> z) = s"
   413   show "x \<squnion> (y \<squnion> z) = s"
   411   proof (rule anti_sym)
   414   proof (rule anti_sym)
   412     from sup L show "x \<squnion> (y \<squnion> z) \<sqsubseteq> s"
   415     from sup L show "x \<squnion> (y \<squnion> z) \<sqsubseteq> s"
   450 
   453 
   451 lemma (in lattice) meet_closed [simp]:
   454 lemma (in lattice) meet_closed [simp]:
   452   "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqinter> y \<in> carrier L"
   455   "[| x \<in> carrier L; y \<in> carrier L |] ==> x \<sqinter> y \<in> carrier L"
   453   by (rule meetI) (rule greatest_carrier)
   456   by (rule meetI) (rule greatest_carrier)
   454 
   457 
   455 lemma (in partial_order) inf_of_singletonI:
   458 lemma (in partial_order) inf_of_singletonI:      (* only reflexivity needed ? *)
   456   (* only reflexivity needed ? *)
       
   457   "x \<in> carrier L ==> greatest L x (Lower L {x})"
   459   "x \<in> carrier L ==> greatest L x (Lower L {x})"
   458   by (rule greatest_LowerI) fast+
   460   by (rule greatest_LowerI) fast+
   459 
   461 
   460 lemma (in partial_order) inf_of_singleton [simp]:
   462 lemma (in partial_order) inf_of_singleton [simp]:
   461   includes order_syntax
   463   includes order_syntax
   763 proof (rule complete_lattice.intro)
   765 proof (rule complete_lattice.intro)
   764   show "lattice_axioms L"
   766   show "lattice_axioms L"
   765   by (rule lattice_axioms.intro) (blast intro: sup_exists inf_exists)+
   767   by (rule lattice_axioms.intro) (blast intro: sup_exists inf_exists)+
   766 qed (assumption | rule complete_lattice_axioms.intro)+
   768 qed (assumption | rule complete_lattice_axioms.intro)+
   767 
   769 
   768 constdefs
   770 constdefs (structure L)
   769   top :: "('a, 'm) order_scheme => 'a" ("\<top>\<index>")
   771   top :: "_ => 'a" ("\<top>\<index>")
   770   "top L == sup L (carrier L)"
   772   "\<top> == sup L (carrier L)"
   771 
   773 
   772   bottom :: "('a, 'm) order_scheme => 'a" ("\<bottom>\<index>")
   774   bottom :: "_ => 'a" ("\<bottom>\<index>")
   773   "bottom L == inf L (carrier L)"
   775   "\<bottom> == inf L (carrier L)"
   774 
   776 
   775 
   777 
   776 lemma (in complete_lattice) supI:
   778 lemma (in complete_lattice) supI:
   777   "[| !!l. least L l (Upper L A) ==> P l; A \<subseteq> carrier L |]
   779   "[| !!l. least L l (Upper L A) ==> P l; A \<subseteq> carrier L |]
   778   ==> P (\<Squnion> A)"
   780   ==> P (\<Squnion>A)"
   779 proof (unfold sup_def)
   781 proof (unfold sup_def)
   780   assume L: "A \<subseteq> carrier L"
   782   assume L: "A \<subseteq> carrier L"
   781     and P: "!!l. least L l (Upper L A) ==> P l"
   783     and P: "!!l. least L l (Upper L A) ==> P l"
   782   with sup_exists obtain s where "least L s (Upper L A)" by blast
   784   with sup_exists obtain s where "least L s (Upper L A)" by blast
   783   with L show "P (THE l. least L l (Upper L A))"
   785   with L show "P (THE l. least L l (Upper L A))"