src/HOL/Library/Option_ord.thy
changeset 56166 9a241bc276cd
parent 52729 412c9e0381a1
child 58881 b9556a055632
equal deleted inserted replaced
56165:dd89ce51d2c8 56166:9a241bc276cd
   290   "A \<noteq> {} \<Longrightarrow> Some (\<Squnion>A) = \<Squnion>(Some ` A)"
   290   "A \<noteq> {} \<Longrightarrow> Some (\<Squnion>A) = \<Squnion>(Some ` A)"
   291   by (auto simp add: Sup_option_def)
   291   by (auto simp add: Sup_option_def)
   292 
   292 
   293 lemma Some_INF:
   293 lemma Some_INF:
   294   "Some (\<Sqinter>x\<in>A. f x) = (\<Sqinter>x\<in>A. Some (f x))"
   294   "Some (\<Sqinter>x\<in>A. f x) = (\<Sqinter>x\<in>A. Some (f x))"
   295   by (simp add: INF_def Some_Inf image_image)
   295   using Some_Inf [of "f ` A"] by (simp add: comp_def)
   296 
   296 
   297 lemma Some_SUP:
   297 lemma Some_SUP:
   298   "A \<noteq> {} \<Longrightarrow> Some (\<Squnion>x\<in>A. f x) = (\<Squnion>x\<in>A. Some (f x))"
   298   "A \<noteq> {} \<Longrightarrow> Some (\<Squnion>x\<in>A. f x) = (\<Squnion>x\<in>A. Some (f x))"
   299   by (simp add: SUP_def Some_Sup image_image)
   299   using Some_Sup [of "f ` A"] by (simp add: comp_def)
   300 
   300 
   301 instantiation option :: (complete_distrib_lattice) complete_distrib_lattice
   301 instantiation option :: (complete_distrib_lattice) complete_distrib_lattice
   302 begin
   302 begin
   303 
   303 
   304 instance proof
   304 instance proof
   317       with True Some show ?thesis by simp
   317       with True Some show ?thesis by simp
   318     next
   318     next
   319       case False then have B: "{x \<in> B. \<exists>y. x = Some y} = B" by auto (metis not_Some_eq)
   319       case False then have B: "{x \<in> B. \<exists>y. x = Some y} = B" by auto (metis not_Some_eq)
   320       from sup_Inf have "Some c \<squnion> Some (\<Sqinter>Option.these B) = Some (\<Sqinter>b\<in>Option.these B. c \<squnion> b)" by simp
   320       from sup_Inf have "Some c \<squnion> Some (\<Sqinter>Option.these B) = Some (\<Sqinter>b\<in>Option.these B. c \<squnion> b)" by simp
   321       then have "Some c \<squnion> \<Sqinter>(Some ` Option.these B) = (\<Sqinter>x\<in>Some ` Option.these B. Some c \<squnion> x)"
   321       then have "Some c \<squnion> \<Sqinter>(Some ` Option.these B) = (\<Sqinter>x\<in>Some ` Option.these B. Some c \<squnion> x)"
   322         by (simp add: Some_INF Some_Inf)
   322         by (simp add: Some_INF Some_Inf comp_def)
   323       with Some B show ?thesis by (simp add: Some_image_these_eq)
   323       with Some B show ?thesis by (simp add: Some_image_these_eq)
   324     qed
   324     qed
   325   qed
   325   qed
   326   show "a \<sqinter> \<Squnion>B = (\<Squnion>b\<in>B. a \<sqinter> b)"
   326   show "a \<sqinter> \<Squnion>B = (\<Squnion>b\<in>B. a \<sqinter> b)"
   327   proof (cases a)
   327   proof (cases a)
   330   next
   330   next
   331     case (Some c)
   331     case (Some c)
   332     show ?thesis
   332     show ?thesis
   333     proof (cases "B = {} \<or> B = {None}")
   333     proof (cases "B = {} \<or> B = {None}")
   334       case True
   334       case True
   335       then show ?thesis by (auto simp add: SUP_def)
   335       then show ?thesis by auto
   336     next
   336     next
   337       have B: "B = {x \<in> B. \<exists>y. x = Some y} \<union> {x \<in> B. x = None}"
   337       have B: "B = {x \<in> B. \<exists>y. x = Some y} \<union> {x \<in> B. x = None}"
   338         by auto
   338         by auto
   339       then have Sup_B: "\<Squnion>B = \<Squnion>({x \<in> B. \<exists>y. x = Some y} \<union> {x \<in> B. x = None})"
   339       then have Sup_B: "\<Squnion>B = \<Squnion>({x \<in> B. \<exists>y. x = Some y} \<union> {x \<in> B. x = None})"
   340         and SUP_B: "\<And>f. (\<Squnion>x \<in> B. f x) = (\<Squnion>x \<in> {x \<in> B. \<exists>y. x = Some y} \<union> {x \<in> B. x = None}. f x)"
   340         and SUP_B: "\<And>f. (\<Squnion>x \<in> B. f x) = (\<Squnion>x \<in> {x \<in> B. \<exists>y. x = Some y} \<union> {x \<in> B. x = None}. f x)"
   345         by (simp add: bot_option_def [symmetric])
   345         by (simp add: bot_option_def [symmetric])
   346       case False then have "Option.these B \<noteq> {}" by (simp add: these_not_empty_eq)
   346       case False then have "Option.these B \<noteq> {}" by (simp add: these_not_empty_eq)
   347       moreover from inf_Sup have "Some c \<sqinter> Some (\<Squnion>Option.these B) = Some (\<Squnion>b\<in>Option.these B. c \<sqinter> b)"
   347       moreover from inf_Sup have "Some c \<sqinter> Some (\<Squnion>Option.these B) = Some (\<Squnion>b\<in>Option.these B. c \<sqinter> b)"
   348         by simp
   348         by simp
   349       ultimately have "Some c \<sqinter> \<Squnion>(Some ` Option.these B) = (\<Squnion>x\<in>Some ` Option.these B. Some c \<sqinter> x)"
   349       ultimately have "Some c \<sqinter> \<Squnion>(Some ` Option.these B) = (\<Squnion>x\<in>Some ` Option.these B. Some c \<sqinter> x)"
   350         by (simp add: Some_SUP Some_Sup)
   350         by (simp add: Some_SUP Some_Sup comp_def)
   351       with Some show ?thesis
   351       with Some show ?thesis
   352         by (simp add: Some_image_these_eq Sup_B SUP_B Sup_None SUP_None SUP_union Sup_union_distrib)
   352         by (simp add: Some_image_these_eq Sup_B SUP_B Sup_None SUP_None SUP_union Sup_union_distrib)
   353     qed
   353     qed
   354   qed
   354   qed
   355 qed
   355 qed