src/HOL/Complete_Lattices.thy
changeset 44918 6a80fbc4e72c
parent 44860 56101fa00193
child 44919 482f1807976e
equal deleted inserted replaced
44917:8df4c332cb1c 44918:6a80fbc4e72c
   124   using Sup_upper [of u A] by auto
   124   using Sup_upper [of u A] by auto
   125 
   125 
   126 lemma SUP_upper2: "i \<in> A \<Longrightarrow> u \<sqsubseteq> f i \<Longrightarrow> u \<sqsubseteq> (\<Squnion>i\<in>A. f i)"
   126 lemma SUP_upper2: "i \<in> A \<Longrightarrow> u \<sqsubseteq> f i \<Longrightarrow> u \<sqsubseteq> (\<Squnion>i\<in>A. f i)"
   127   using SUP_upper [of i A f] by auto
   127   using SUP_upper [of i A f] by auto
   128 
   128 
   129 lemma le_Inf_iff (*[simp]*): "b \<sqsubseteq> \<Sqinter>A \<longleftrightarrow> (\<forall>a\<in>A. b \<sqsubseteq> a)"
   129 lemma le_Inf_iff: "b \<sqsubseteq> \<Sqinter>A \<longleftrightarrow> (\<forall>a\<in>A. b \<sqsubseteq> a)"
   130   by (auto intro: Inf_greatest dest: Inf_lower)
   130   by (auto intro: Inf_greatest dest: Inf_lower)
   131 
   131 
   132 lemma le_INF_iff (*[simp]*): "u \<sqsubseteq> (\<Sqinter>i\<in>A. f i) \<longleftrightarrow> (\<forall>i\<in>A. u \<sqsubseteq> f i)"
   132 lemma le_INF_iff: "u \<sqsubseteq> (\<Sqinter>i\<in>A. f i) \<longleftrightarrow> (\<forall>i\<in>A. u \<sqsubseteq> f i)"
   133   by (auto simp add: INF_def le_Inf_iff)
   133   by (auto simp add: INF_def le_Inf_iff)
   134 
   134 
   135 lemma Sup_le_iff (*[simp]*): "\<Squnion>A \<sqsubseteq> b \<longleftrightarrow> (\<forall>a\<in>A. a \<sqsubseteq> b)"
   135 lemma Sup_le_iff: "\<Squnion>A \<sqsubseteq> b \<longleftrightarrow> (\<forall>a\<in>A. a \<sqsubseteq> b)"
   136   by (auto intro: Sup_least dest: Sup_upper)
   136   by (auto intro: Sup_least dest: Sup_upper)
   137 
   137 
   138 lemma SUP_le_iff (*[simp]*): "(\<Squnion>i\<in>A. f i) \<sqsubseteq> u \<longleftrightarrow> (\<forall>i\<in>A. f i \<sqsubseteq> u)"
   138 lemma SUP_le_iff: "(\<Squnion>i\<in>A. f i) \<sqsubseteq> u \<longleftrightarrow> (\<forall>i\<in>A. f i \<sqsubseteq> u)"
   139   by (auto simp add: SUP_def Sup_le_iff)
   139   by (auto simp add: SUP_def Sup_le_iff)
   140 
   140 
   141 lemma Inf_empty [simp]:
   141 lemma Inf_empty [simp]:
   142   "\<Sqinter>{} = \<top>"
   142   "\<Sqinter>{} = \<top>"
   143   by (auto intro: antisym Inf_greatest)
   143   by (auto intro: antisym Inf_greatest)
   158 
   158 
   159 lemma Sup_UNIV [simp]:
   159 lemma Sup_UNIV [simp]:
   160   "\<Squnion>UNIV = \<top>"
   160   "\<Squnion>UNIV = \<top>"
   161   by (auto intro!: antisym Sup_upper)
   161   by (auto intro!: antisym Sup_upper)
   162 
   162 
   163 lemma Inf_insert (*[simp]*): "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A"
   163 lemma Inf_insert [simp]: "\<Sqinter>insert a A = a \<sqinter> \<Sqinter>A"
   164   by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower)
   164   by (auto intro: le_infI le_infI1 le_infI2 antisym Inf_greatest Inf_lower)
   165 
   165 
   166 lemma INF_insert: "(\<Sqinter>x\<in>insert a A. f x) = f a \<sqinter> INFI A f"
   166 lemma INF_insert: "(\<Sqinter>x\<in>insert a A. f x) = f a \<sqinter> INFI A f"
   167   by (simp add: INF_def Inf_insert)
   167   by (simp add: INF_def Inf_insert)
   168 
   168 
   169 lemma Sup_insert (*[simp]*): "\<Squnion>insert a A = a \<squnion> \<Squnion>A"
   169 lemma Sup_insert [simp]: "\<Squnion>insert a A = a \<squnion> \<Squnion>A"
   170   by (auto intro: le_supI le_supI1 le_supI2 antisym Sup_least Sup_upper)
   170   by (auto intro: le_supI le_supI1 le_supI2 antisym Sup_least Sup_upper)
   171 
   171 
   172 lemma SUP_insert: "(\<Squnion>x\<in>insert a A. f x) = f a \<squnion> SUPR A f"
   172 lemma SUP_insert: "(\<Squnion>x\<in>insert a A. f x) = f a \<squnion> SUPR A f"
   173   by (simp add: SUP_def Sup_insert)
   173   by (simp add: SUP_def Sup_insert)
   174 
   174 
   175 lemma INF_image (*[simp]*): "(\<Sqinter>x\<in>f`A. g x) = (\<Sqinter>x\<in>A. g (f x))"
   175 lemma INF_image [simp]: "(\<Sqinter>x\<in>f`A. g x) = (\<Sqinter>x\<in>A. g (f x))"
   176   by (simp add: INF_def image_image)
   176   by (simp add: INF_def image_image)
   177 
   177 
   178 lemma SUP_image (*[simp]*): "(\<Squnion>x\<in>f`A. g x) = (\<Squnion>x\<in>A. g (f x))"
   178 lemma SUP_image [simp]: "(\<Squnion>x\<in>f`A. g x) = (\<Squnion>x\<in>A. g (f x))"
   179   by (simp add: SUP_def image_image)
   179   by (simp add: SUP_def image_image)
   180 
   180 
   181 lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<sqsubseteq> a}"
   181 lemma Inf_Sup: "\<Sqinter>A = \<Squnion>{b. \<forall>a \<in> A. b \<sqsubseteq> a}"
   182   by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
   182   by (auto intro: antisym Inf_lower Inf_greatest Sup_upper Sup_least)
   183 
   183 
   208   with `a \<sqsubseteq> b` show "\<Sqinter>A \<sqsubseteq> b" by auto
   208   with `a \<sqsubseteq> b` show "\<Sqinter>A \<sqsubseteq> b" by auto
   209 qed
   209 qed
   210 
   210 
   211 lemma INF_mono:
   211 lemma INF_mono:
   212   "(\<And>m. m \<in> B \<Longrightarrow> \<exists>n\<in>A. f n \<sqsubseteq> g m) \<Longrightarrow> (\<Sqinter>n\<in>A. f n) \<sqsubseteq> (\<Sqinter>n\<in>B. g n)"
   212   "(\<And>m. m \<in> B \<Longrightarrow> \<exists>n\<in>A. f n \<sqsubseteq> g m) \<Longrightarrow> (\<Sqinter>n\<in>A. f n) \<sqsubseteq> (\<Sqinter>n\<in>B. g n)"
   213   by (force intro!: Inf_mono simp: INF_def)
   213   unfolding INF_def by (rule Inf_mono) fast
   214 
   214 
   215 lemma Sup_mono:
   215 lemma Sup_mono:
   216   assumes "\<And>a. a \<in> A \<Longrightarrow> \<exists>b\<in>B. a \<sqsubseteq> b"
   216   assumes "\<And>a. a \<in> A \<Longrightarrow> \<exists>b\<in>B. a \<sqsubseteq> b"
   217   shows "\<Squnion>A \<sqsubseteq> \<Squnion>B"
   217   shows "\<Squnion>A \<sqsubseteq> \<Squnion>B"
   218 proof (rule Sup_least)
   218 proof (rule Sup_least)
   222   with `a \<sqsubseteq> b` show "a \<sqsubseteq> \<Squnion>B" by auto
   222   with `a \<sqsubseteq> b` show "a \<sqsubseteq> \<Squnion>B" by auto
   223 qed
   223 qed
   224 
   224 
   225 lemma SUP_mono:
   225 lemma SUP_mono:
   226   "(\<And>n. n \<in> A \<Longrightarrow> \<exists>m\<in>B. f n \<sqsubseteq> g m) \<Longrightarrow> (\<Squnion>n\<in>A. f n) \<sqsubseteq> (\<Squnion>n\<in>B. g n)"
   226   "(\<And>n. n \<in> A \<Longrightarrow> \<exists>m\<in>B. f n \<sqsubseteq> g m) \<Longrightarrow> (\<Squnion>n\<in>A. f n) \<sqsubseteq> (\<Squnion>n\<in>B. g n)"
   227   by (force intro!: Sup_mono simp: SUP_def)
   227   unfolding SUP_def by (rule Sup_mono) fast
   228 
   228 
   229 lemma INF_superset_mono:
   229 lemma INF_superset_mono:
   230   "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> f x \<sqsubseteq> g x) \<Longrightarrow> (\<Sqinter>x\<in>A. f x) \<sqsubseteq> (\<Sqinter>x\<in>B. g x)"
   230   "B \<subseteq> A \<Longrightarrow> (\<And>x. x \<in> B \<Longrightarrow> f x \<sqsubseteq> g x) \<Longrightarrow> (\<Sqinter>x\<in>A. f x) \<sqsubseteq> (\<Sqinter>x\<in>B. g x)"
   231   -- {* The last inclusion is POSITIVE! *}
   231   -- {* The last inclusion is POSITIVE! *}
   232   by (blast intro: INF_mono dest: subsetD)
   232   by (blast intro: INF_mono dest: subsetD)
   276   by (auto intro!: antisym SUP_mono intro: le_supI1 le_supI2 SUP_least SUP_upper)
   276   by (auto intro!: antisym SUP_mono intro: le_supI1 le_supI2 SUP_least SUP_upper)
   277 
   277 
   278 lemma INF_inf_distrib: "(\<Sqinter>a\<in>A. f a) \<sqinter> (\<Sqinter>a\<in>A. g a) = (\<Sqinter>a\<in>A. f a \<sqinter> g a)"
   278 lemma INF_inf_distrib: "(\<Sqinter>a\<in>A. f a) \<sqinter> (\<Sqinter>a\<in>A. g a) = (\<Sqinter>a\<in>A. f a \<sqinter> g a)"
   279   by (rule antisym) (rule INF_greatest, auto intro: le_infI1 le_infI2 INF_lower INF_mono)
   279   by (rule antisym) (rule INF_greatest, auto intro: le_infI1 le_infI2 INF_lower INF_mono)
   280 
   280 
   281 lemma SUP_sup_distrib: "(\<Squnion>a\<in>A. f a) \<squnion> (\<Squnion>a\<in>A. g a) = (\<Squnion>a\<in>A. f a \<squnion> g a)"
   281 lemma SUP_sup_distrib: "(\<Squnion>a\<in>A. f a) \<squnion> (\<Squnion>a\<in>A. g a) = (\<Squnion>a\<in>A. f a \<squnion> g a)" (is "?L = ?R")
   282   by (rule antisym) (auto intro: le_supI1 le_supI2 SUP_upper SUP_mono,
   282 proof (rule antisym)
   283     rule SUP_least, auto intro: le_supI1 le_supI2 SUP_upper SUP_mono)
   283   show "?L \<le> ?R" by (auto intro: le_supI1 le_supI2 SUP_upper SUP_mono)
   284 
   284 next
   285 lemma Inf_top_conv (*[simp]*) [no_atp]:
   285   show "?R \<le> ?L" by (rule SUP_least) (auto intro: le_supI1 le_supI2 SUP_upper)
       
   286 qed
       
   287 
       
   288 lemma Inf_top_conv [simp, no_atp]:
   286   "\<Sqinter>A = \<top> \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
   289   "\<Sqinter>A = \<top> \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
   287   "\<top> = \<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
   290   "\<top> = \<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
   288 proof -
   291 proof -
   289   show "\<Sqinter>A = \<top> \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
   292   show "\<Sqinter>A = \<top> \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)"
   290   proof
   293   proof
   302     qed
   305     qed
   303   qed
   306   qed
   304   then show "\<top> = \<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)" by auto
   307   then show "\<top> = \<Sqinter>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<top>)" by auto
   305 qed
   308 qed
   306 
   309 
   307 lemma INF_top_conv (*[simp]*):
   310 lemma INF_top_conv [simp]:
   308  "(\<Sqinter>x\<in>A. B x) = \<top> \<longleftrightarrow> (\<forall>x\<in>A. B x = \<top>)"
   311  "(\<Sqinter>x\<in>A. B x) = \<top> \<longleftrightarrow> (\<forall>x\<in>A. B x = \<top>)"
   309  "\<top> = (\<Sqinter>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = \<top>)"
   312  "\<top> = (\<Sqinter>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = \<top>)"
   310   by (auto simp add: INF_def Inf_top_conv)
   313   by (auto simp add: INF_def Inf_top_conv)
   311 
   314 
   312 lemma Sup_bot_conv (*[simp]*) [no_atp]:
   315 lemma Sup_bot_conv [simp, no_atp]:
   313   "\<Squnion>A = \<bottom> \<longleftrightarrow> (\<forall>x\<in>A. x = \<bottom>)" (is ?P)
   316   "\<Squnion>A = \<bottom> \<longleftrightarrow> (\<forall>x\<in>A. x = \<bottom>)" (is ?P)
   314   "\<bottom> = \<Squnion>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<bottom>)" (is ?Q)
   317   "\<bottom> = \<Squnion>A \<longleftrightarrow> (\<forall>x\<in>A. x = \<bottom>)" (is ?Q)
   315 proof -
   318 proof -
   316   interpret dual: complete_lattice Sup Inf sup "op \<ge>" "op >" inf \<top> \<bottom>
   319   interpret dual: complete_lattice Sup Inf sup "op \<ge>" "op >" inf \<top> \<bottom>
   317     by (fact dual_complete_lattice)
   320     by (fact dual_complete_lattice)
   318   from dual.Inf_top_conv show ?P and ?Q by simp_all
   321   from dual.Inf_top_conv show ?P and ?Q by simp_all
   319 qed
   322 qed
   320 
   323 
   321 lemma SUP_bot_conv (*[simp]*):
   324 lemma SUP_bot_conv [simp]:
   322  "(\<Squnion>x\<in>A. B x) = \<bottom> \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
   325  "(\<Squnion>x\<in>A. B x) = \<bottom> \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
   323  "\<bottom> = (\<Squnion>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
   326  "\<bottom> = (\<Squnion>x\<in>A. B x) \<longleftrightarrow> (\<forall>x\<in>A. B x = \<bottom>)"
   324   by (auto simp add: SUP_def Sup_bot_conv)
   327   by (auto simp add: SUP_def Sup_bot_conv)
   325 
   328 
   326 lemma INF_const [simp]: "A \<noteq> {} \<Longrightarrow> (\<Sqinter>i\<in>A. f) = f"
   329 lemma INF_const [simp]: "A \<noteq> {} \<Longrightarrow> (\<Sqinter>i\<in>A. f) = f"
   327   by (auto intro: antisym INF_lower INF_greatest)
   330   by (auto intro: antisym INF_lower INF_greatest)
   328 
   331 
   329 lemma SUP_const [simp]: "A \<noteq> {} \<Longrightarrow> (\<Squnion>i\<in>A. f) = f"
   332 lemma SUP_const [simp]: "A \<noteq> {} \<Longrightarrow> (\<Squnion>i\<in>A. f) = f"
   330   by (auto intro: antisym SUP_upper SUP_least)
   333   by (auto intro: antisym SUP_upper SUP_least)
   331 
   334 
   332 lemma INF_top (*[simp]*): "(\<Sqinter>x\<in>A. \<top>) = \<top>"
   335 lemma INF_top [simp]: "(\<Sqinter>x\<in>A. \<top>) = \<top>"
   333   by (cases "A = {}") (simp_all add: INF_empty)
   336   by (cases "A = {}") (simp_all add: INF_empty)
   334 
   337 
   335 lemma SUP_bot (*[simp]*): "(\<Squnion>x\<in>A. \<bottom>) = \<bottom>"
   338 lemma SUP_bot [simp]: "(\<Squnion>x\<in>A. \<bottom>) = \<bottom>"
   336   by (cases "A = {}") (simp_all add: SUP_empty)
   339   by (cases "A = {}") (simp_all add: SUP_empty)
   337 
   340 
   338 lemma INF_commute: "(\<Sqinter>i\<in>A. \<Sqinter>j\<in>B. f i j) = (\<Sqinter>j\<in>B. \<Sqinter>i\<in>A. f i j)"
   341 lemma INF_commute: "(\<Sqinter>i\<in>A. \<Sqinter>j\<in>B. f i j) = (\<Sqinter>j\<in>B. \<Sqinter>i\<in>A. f i j)"
   339   by (iprover intro: INF_lower INF_greatest order_trans antisym)
   342   by (iprover intro: INF_lower INF_greatest order_trans antisym)
   340 
   343 
   490 
   493 
   491 lemma dual_complete_linorder:
   494 lemma dual_complete_linorder:
   492   "class.complete_linorder Sup Inf sup (op \<ge>) (op >) inf \<top> \<bottom>"
   495   "class.complete_linorder Sup Inf sup (op \<ge>) (op >) inf \<top> \<bottom>"
   493   by (rule class.complete_linorder.intro, rule dual_complete_lattice, rule dual_linorder)
   496   by (rule class.complete_linorder.intro, rule dual_complete_lattice, rule dual_linorder)
   494 
   497 
   495 lemma Inf_less_iff (*[simp]*):
   498 lemma Inf_less_iff:
   496   "\<Sqinter>S \<sqsubset> a \<longleftrightarrow> (\<exists>x\<in>S. x \<sqsubset> a)"
   499   "\<Sqinter>S \<sqsubset> a \<longleftrightarrow> (\<exists>x\<in>S. x \<sqsubset> a)"
   497   unfolding not_le [symmetric] le_Inf_iff by auto
   500   unfolding not_le [symmetric] le_Inf_iff by auto
   498 
   501 
   499 lemma INF_less_iff (*[simp]*):
   502 lemma INF_less_iff:
   500   "(\<Sqinter>i\<in>A. f i) \<sqsubset> a \<longleftrightarrow> (\<exists>x\<in>A. f x \<sqsubset> a)"
   503   "(\<Sqinter>i\<in>A. f i) \<sqsubset> a \<longleftrightarrow> (\<exists>x\<in>A. f x \<sqsubset> a)"
   501   unfolding INF_def Inf_less_iff by auto
   504   unfolding INF_def Inf_less_iff by auto
   502 
   505 
   503 lemma less_Sup_iff (*[simp]*):
   506 lemma less_Sup_iff:
   504   "a \<sqsubset> \<Squnion>S \<longleftrightarrow> (\<exists>x\<in>S. a \<sqsubset> x)"
   507   "a \<sqsubset> \<Squnion>S \<longleftrightarrow> (\<exists>x\<in>S. a \<sqsubset> x)"
   505   unfolding not_le [symmetric] Sup_le_iff by auto
   508   unfolding not_le [symmetric] Sup_le_iff by auto
   506 
   509 
   507 lemma less_SUP_iff (*[simp]*):
   510 lemma less_SUP_iff:
   508   "a \<sqsubset> (\<Squnion>i\<in>A. f i) \<longleftrightarrow> (\<exists>x\<in>A. a \<sqsubset> f x)"
   511   "a \<sqsubset> (\<Squnion>i\<in>A. f i) \<longleftrightarrow> (\<exists>x\<in>A. a \<sqsubset> f x)"
   509   unfolding SUP_def less_Sup_iff by auto
   512   unfolding SUP_def less_Sup_iff by auto
   510 
   513 
   511 lemma Sup_eq_top_iff (*[simp]*):
   514 lemma Sup_eq_top_iff [simp]:
   512   "\<Squnion>A = \<top> \<longleftrightarrow> (\<forall>x<\<top>. \<exists>i\<in>A. x < i)"
   515   "\<Squnion>A = \<top> \<longleftrightarrow> (\<forall>x<\<top>. \<exists>i\<in>A. x < i)"
   513 proof
   516 proof
   514   assume *: "\<Squnion>A = \<top>"
   517   assume *: "\<Squnion>A = \<top>"
   515   show "(\<forall>x<\<top>. \<exists>i\<in>A. x < i)" unfolding * [symmetric]
   518   show "(\<forall>x<\<top>. \<exists>i\<in>A. x < i)" unfolding * [symmetric]
   516   proof (intro allI impI)
   519   proof (intro allI impI)
   528       using * unfolding less_Sup_iff by auto
   531       using * unfolding less_Sup_iff by auto
   529     then show False by auto
   532     then show False by auto
   530   qed
   533   qed
   531 qed
   534 qed
   532 
   535 
   533 lemma SUP_eq_top_iff (*[simp]*):
   536 lemma SUP_eq_top_iff [simp]:
   534   "(\<Squnion>i\<in>A. f i) = \<top> \<longleftrightarrow> (\<forall>x<\<top>. \<exists>i\<in>A. x < f i)"
   537   "(\<Squnion>i\<in>A. f i) = \<top> \<longleftrightarrow> (\<forall>x<\<top>. \<exists>i\<in>A. x < f i)"
   535   unfolding SUP_def Sup_eq_top_iff by auto
   538   unfolding SUP_def Sup_eq_top_iff by auto
   536 
   539 
   537 lemma Inf_eq_bot_iff (*[simp]*):
   540 lemma Inf_eq_bot_iff [simp]:
   538   "\<Sqinter>A = \<bottom> \<longleftrightarrow> (\<forall>x>\<bottom>. \<exists>i\<in>A. i < x)"
   541   "\<Sqinter>A = \<bottom> \<longleftrightarrow> (\<forall>x>\<bottom>. \<exists>i\<in>A. i < x)"
   539 proof -
   542 proof -
   540   interpret dual: complete_linorder Sup Inf sup "op \<ge>" "op >" inf \<top> \<bottom>
   543   interpret dual: complete_linorder Sup Inf sup "op \<ge>" "op >" inf \<top> \<bottom>
   541     by (fact dual_complete_linorder)
   544     by (fact dual_complete_linorder)
   542   from dual.Sup_eq_top_iff show ?thesis .
   545   from dual.Sup_eq_top_iff show ?thesis .
   543 qed
   546 qed
   544 
   547 
   545 lemma INF_eq_bot_iff (*[simp]*):
   548 lemma INF_eq_bot_iff [simp]:
   546   "(\<Sqinter>i\<in>A. f i) = \<bottom> \<longleftrightarrow> (\<forall>x>\<bottom>. \<exists>i\<in>A. f i < x)"
   549   "(\<Sqinter>i\<in>A. f i) = \<bottom> \<longleftrightarrow> (\<forall>x>\<bottom>. \<exists>i\<in>A. f i < x)"
   547   unfolding INF_def Inf_eq_bot_iff by auto
   550   unfolding INF_def Inf_eq_bot_iff by auto
   548 
   551 
   549 end
   552 end
   550 
   553