src/HOL/Lattices.thy
changeset 25062 af5ef0d4d655
parent 24749 151b3758f576
child 25102 db3e412c4cb1
equal deleted inserted replaced
25061:250e1da3204b 25062:af5ef0d4d655
    31 begin
    31 begin
    32 
    32 
    33 lemmas antisym_intro [intro!] = antisym
    33 lemmas antisym_intro [intro!] = antisym
    34 lemmas (in -) [rule del] = antisym_intro
    34 lemmas (in -) [rule del] = antisym_intro
    35 
    35 
    36 lemma le_infI1[intro]: "a \<sqsubseteq> x \<Longrightarrow> a \<sqinter> b \<sqsubseteq> x"
    36 lemma le_infI1[intro]:
    37 apply(subgoal_tac "a \<sqinter> b \<sqsubseteq> a")
    37   assumes "a \<sqsubseteq> x"
    38  apply(blast intro: order_trans)
    38   shows "a \<sqinter> b \<sqsubseteq> x"
    39 apply simp
    39 proof (rule order_trans)
    40 done
    40   show "a \<sqinter> b \<sqsubseteq> a" and "a \<sqsubseteq> x" using assms by simp
       
    41 qed
    41 lemmas (in -) [rule del] = le_infI1
    42 lemmas (in -) [rule del] = le_infI1
    42 
    43 
    43 lemma le_infI2[intro]: "b \<sqsubseteq> x \<Longrightarrow> a \<sqinter> b \<sqsubseteq> x"
    44 lemma le_infI2[intro]:
    44 apply(subgoal_tac "a \<sqinter> b \<sqsubseteq> b")
    45   assumes "b \<sqsubseteq> x"
    45  apply(blast intro: order_trans)
    46   shows "a \<sqinter> b \<sqsubseteq> x"
    46 apply simp
    47 proof (rule order_trans)
    47 done
    48   show "a \<sqinter> b \<sqsubseteq> b" and "b \<sqsubseteq> x" using assms by simp
       
    49 qed
    48 lemmas (in -) [rule del] = le_infI2
    50 lemmas (in -) [rule del] = le_infI2
    49 
    51 
    50 lemma le_infI[intro!]: "x \<sqsubseteq> a \<Longrightarrow> x \<sqsubseteq> b \<Longrightarrow> x \<sqsubseteq> a \<sqinter> b"
    52 lemma le_infI[intro!]: "x \<sqsubseteq> a \<Longrightarrow> x \<sqsubseteq> b \<Longrightarrow> x \<sqsubseteq> a \<sqinter> b"
    51 by(blast intro: inf_greatest)
    53 by(blast intro: inf_greatest)
    52 lemmas (in -) [rule del] = le_infI
    54 lemmas (in -) [rule del] = le_infI
    73 
    75 
    74 lemmas antisym_intro [intro!] = antisym
    76 lemmas antisym_intro [intro!] = antisym
    75 lemmas (in -) [rule del] = antisym_intro
    77 lemmas (in -) [rule del] = antisym_intro
    76 
    78 
    77 lemma le_supI1[intro]: "x \<sqsubseteq> a \<Longrightarrow> x \<sqsubseteq> a \<squnion> b"
    79 lemma le_supI1[intro]: "x \<sqsubseteq> a \<Longrightarrow> x \<sqsubseteq> a \<squnion> b"
    78 apply(subgoal_tac "a \<sqsubseteq> a \<squnion> b")
    80   by (rule order_trans) auto
    79  apply(blast intro: order_trans)
       
    80 apply simp
       
    81 done
       
    82 lemmas (in -) [rule del] = le_supI1
    81 lemmas (in -) [rule del] = le_supI1
    83 
    82 
    84 lemma le_supI2[intro]: "x \<sqsubseteq> b \<Longrightarrow> x \<sqsubseteq> a \<squnion> b"
    83 lemma le_supI2[intro]: "x \<sqsubseteq> b \<Longrightarrow> x \<sqsubseteq> a \<squnion> b"
    85 apply(subgoal_tac "b \<sqsubseteq> a \<squnion> b")
    84   by (rule order_trans) auto 
    86  apply(blast intro: order_trans)
       
    87 apply simp
       
    88 done
       
    89 lemmas (in -) [rule del] = le_supI2
    85 lemmas (in -) [rule del] = le_supI2
    90 
    86 
    91 lemma le_supI[intro!]: "a \<sqsubseteq> x \<Longrightarrow> b \<sqsubseteq> x \<Longrightarrow> a \<squnion> b \<sqsubseteq> x"
    87 lemma le_supI[intro!]: "a \<sqsubseteq> x \<Longrightarrow> b \<sqsubseteq> x \<Longrightarrow> a \<squnion> b \<sqsubseteq> x"
    92 by(blast intro: sup_least)
    88 by(blast intro: sup_least)
    93 lemmas (in -) [rule del] = le_supI
    89 lemmas (in -) [rule del] = le_supI
   253 
   249 
   254 subsection {* Uniqueness of inf and sup *}
   250 subsection {* Uniqueness of inf and sup *}
   255 
   251 
   256 lemma (in lower_semilattice) inf_unique:
   252 lemma (in lower_semilattice) inf_unique:
   257   fixes f (infixl "\<triangle>" 70)
   253   fixes f (infixl "\<triangle>" 70)
   258   assumes le1: "\<And>x y. x \<triangle> y \<^loc>\<le> x" and le2: "\<And>x y. x \<triangle> y \<^loc>\<le> y"
   254   assumes le1: "\<And>x y. x \<triangle> y \<le> x" and le2: "\<And>x y. x \<triangle> y \<le> y"
   259   and greatest: "\<And>x y z. x \<^loc>\<le> y \<Longrightarrow> x \<^loc>\<le> z \<Longrightarrow> x \<^loc>\<le> y \<triangle> z"
   255   and greatest: "\<And>x y z. x \<le> y \<Longrightarrow> x \<le> z \<Longrightarrow> x \<le> y \<triangle> z"
   260   shows "x \<sqinter> y = x \<triangle> y"
   256   shows "x \<sqinter> y = x \<triangle> y"
   261 proof (rule antisym)
   257 proof (rule antisym)
   262   show "x \<triangle> y \<^loc>\<le> x \<sqinter> y" by (rule le_infI) (rule le1, rule le2)
   258   show "x \<triangle> y \<le> x \<sqinter> y" by (rule le_infI) (rule le1, rule le2)
   263 next
   259 next
   264   have leI: "\<And>x y z. x \<^loc>\<le> y \<Longrightarrow> x \<^loc>\<le> z \<Longrightarrow> x \<^loc>\<le> y \<triangle> z" by (blast intro: greatest)
   260   have leI: "\<And>x y z. x \<le> y \<Longrightarrow> x \<le> z \<Longrightarrow> x \<le> y \<triangle> z" by (blast intro: greatest)
   265   show "x \<sqinter> y \<^loc>\<le> x \<triangle> y" by (rule leI) simp_all
   261   show "x \<sqinter> y \<le> x \<triangle> y" by (rule leI) simp_all
   266 qed
   262 qed
   267 
   263 
   268 lemma (in upper_semilattice) sup_unique:
   264 lemma (in upper_semilattice) sup_unique:
   269   fixes f (infixl "\<nabla>" 70)
   265   fixes f (infixl "\<nabla>" 70)
   270   assumes ge1 [simp]: "\<And>x y. x \<^loc>\<le> x \<nabla> y" and ge2: "\<And>x y. y \<^loc>\<le> x \<nabla> y"
   266   assumes ge1 [simp]: "\<And>x y. x \<le> x \<nabla> y" and ge2: "\<And>x y. y \<le> x \<nabla> y"
   271   and least: "\<And>x y z. y \<^loc>\<le> x \<Longrightarrow> z \<^loc>\<le> x \<Longrightarrow> y \<nabla> z \<^loc>\<le> x"
   267   and least: "\<And>x y z. y \<le> x \<Longrightarrow> z \<le> x \<Longrightarrow> y \<nabla> z \<le> x"
   272   shows "x \<squnion> y = x \<nabla> y"
   268   shows "x \<squnion> y = x \<nabla> y"
   273 proof (rule antisym)
   269 proof (rule antisym)
   274   show "x \<squnion> y \<^loc>\<le> x \<nabla> y" by (rule le_supI) (rule ge1, rule ge2)
   270   show "x \<squnion> y \<le> x \<nabla> y" by (rule le_supI) (rule ge1, rule ge2)
   275 next
   271 next
   276   have leI: "\<And>x y z. x \<^loc>\<le> z \<Longrightarrow> y \<^loc>\<le> z \<Longrightarrow> x \<nabla> y \<^loc>\<le> z" by (blast intro: least)
   272   have leI: "\<And>x y z. x \<le> z \<Longrightarrow> y \<le> z \<Longrightarrow> x \<nabla> y \<le> z" by (blast intro: least)
   277   show "x \<nabla> y \<^loc>\<le> x \<squnion> y" by (rule leI) simp_all
   273   show "x \<nabla> y \<le> x \<squnion> y" by (rule leI) simp_all
   278 qed
   274 qed
   279   
   275   
   280 
   276 
   281 subsection {* @{const min}/@{const max} on linear orders as
   277 subsection {* @{const min}/@{const max} on linear orders as
   282   special case of @{const inf}/@{const sup} *}
   278   special case of @{const inf}/@{const sup} *}
   283 
   279 
   284 lemma (in linorder) distrib_lattice_min_max:
   280 lemma (in linorder) distrib_lattice_min_max:
   285   "distrib_lattice (op \<^loc>\<le>) (op \<^loc><) min max"
   281   "distrib_lattice (op \<le>) (op <) min max"
   286 proof unfold_locales
   282 proof unfold_locales
   287   have aux: "\<And>x y \<Colon> 'a. x \<^loc>< y \<Longrightarrow> y \<^loc>\<le> x \<Longrightarrow> x = y"
   283   have aux: "\<And>x y \<Colon> 'a. x < y \<Longrightarrow> y \<le> x \<Longrightarrow> x = y"
   288     by (auto simp add: less_le antisym)
   284     by (auto simp add: less_le antisym)
   289   fix x y z
   285   fix x y z
   290   show "max x (min y z) = min (max x y) (max x z)"
   286   show "max x (min y z) = min (max x y) (max x z)"
   291   unfolding min_def max_def
   287   unfolding min_def max_def
   292   by auto
   288   by auto
   331      and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A"
   327      and Inf_greatest: "(\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x) \<Longrightarrow> z \<sqsubseteq> \<Sqinter>A"
   332   assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A"
   328   assumes Sup_upper: "x \<in> A \<Longrightarrow> x \<sqsubseteq> \<Squnion>A"
   333      and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z"
   329      and Sup_least: "(\<And>x. x \<in> A \<Longrightarrow> x \<sqsubseteq> z) \<Longrightarrow> \<Squnion>A \<sqsubseteq> z"
   334 begin
   330 begin
   335 
   331 
   336 lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<^loc>\<le> a}"
   332 lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<le> a}"
   337   by (auto intro: Inf_lower Inf_greatest Sup_upper Sup_least)
   333   by (auto intro: Inf_lower Inf_greatest Sup_upper Sup_least)
   338 
   334 
   339 lemma Sup_Inf:  "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<^loc>\<le> b}"
   335 lemma Sup_Inf:  "\<Squnion>A = \<Sqinter>{b. \<forall>a \<in> A. a \<le> b}"
   340   by (auto intro: Inf_lower Inf_greatest Sup_upper Sup_least)
   336   by (auto intro: Inf_lower Inf_greatest Sup_upper Sup_least)
   341 
   337 
   342 lemma Inf_Univ: "\<Sqinter>UNIV = \<Squnion>{}"
   338 lemma Inf_Univ: "\<Sqinter>UNIV = \<Squnion>{}"
   343   unfolding Sup_Inf by auto
   339   unfolding Sup_Inf by auto
   344 
   340 
   409 definition
   405 definition
   410   bot :: 'a
   406   bot :: 'a
   411 where
   407 where
   412   "bot = Sup {}"
   408   "bot = Sup {}"
   413 
   409 
   414 lemma top_greatest [simp]: "x \<^loc>\<le> top"
   410 lemma top_greatest [simp]: "x \<le> top"
   415   by (unfold top_def, rule Inf_greatest, simp)
   411   by (unfold top_def, rule Inf_greatest, simp)
   416 
   412 
   417 lemma bot_least [simp]: "bot \<^loc>\<le> x"
   413 lemma bot_least [simp]: "bot \<le> x"
   418   by (unfold bot_def, rule Sup_least, simp)
   414   by (unfold bot_def, rule Sup_least, simp)
   419 
   415 
   420 definition
   416 definition
   421   SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a"
   417   SUPR :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'a"
   422 where
   418 where
   582 text {* redundant bindings *}
   578 text {* redundant bindings *}
   583 
   579 
   584 lemmas inf_aci = inf_ACI
   580 lemmas inf_aci = inf_ACI
   585 lemmas sup_aci = sup_ACI
   581 lemmas sup_aci = sup_ACI
   586 
   582 
   587 end
   583 no_notation
       
   584   inf (infixl "\<sqinter>" 70)
       
   585 
       
   586 no_notation
       
   587   sup (infixl "\<squnion>" 65)
       
   588 
       
   589 no_notation
       
   590   Inf ("\<Sqinter>_" [900] 900)
       
   591 
       
   592 no_notation
       
   593   Sup ("\<Squnion>_" [900] 900)
       
   594 
       
   595 end