(* Title: HOL/HOLCF/Library/Sum_Cpo.thy Author: Brian Huffman
*)
section \<open>The cpo of disjoint sums\<close>
theory Sum_Cpo imports HOLCF begin
subsection \<open>Ordering on sum type\<close>
instantiation sum :: (below, below) below begin
definition below_sum_def: "x \ y \ case x of
Inl a \<Rightarrow> (case y of Inl b \<Rightarrow> a \<sqsubseteq> b | Inr b \<Rightarrow> False) |
Inr a \<Rightarrow> (case y of Inl b \<Rightarrow> False | Inr b \<Rightarrow> a \<sqsubseteq> b)"
instance .. end
lemma Inl_below_Inl [simp]: "Inl x \ Inl y \ x \ y" unfolding below_sum_def by simp
lemma Inr_below_Inr [simp]: "Inr x \ Inr y \ x \ y" unfolding below_sum_def by simp
lemma Inl_below_Inr [simp]: "\ Inl x \ Inr y" unfolding below_sum_def by simp
lemma Inr_below_Inl [simp]: "\ Inr x \ Inl y" unfolding below_sum_def by simp
lemma Inl_mono: "x \ y \ Inl x \ Inl y" by simp
lemma Inr_mono: "x \ y \ Inr x \ Inr y" by simp
lemma Inl_belowE: "\Inl a \ x; \b. \x = Inl b; a \ b\ \ R\ \ R" by (cases x, simp_all)
lemma Inr_belowE: "\Inr a \ x; \b. \x = Inr b; a \ b\ \ R\ \ R" by (cases x, simp_all)
lemmas sum_below_elims = Inl_belowE Inr_belowE
lemma sum_below_cases: "\x \ y; \<And>a b. \<lbrakk>x = Inl a; y = Inl b; a \<sqsubseteq> b\<rbrakk> \<Longrightarrow> R; \<And>a b. \<lbrakk>x = Inr a; y = Inr b; a \<sqsubseteq> b\<rbrakk> \<Longrightarrow> R\<rbrakk> \<Longrightarrow> R" by (cases x, safe elim!: sum_below_elims, auto)
subsection \<open>Sum type is a complete partial order\<close>
instance sum :: (po, po) po proof fix x :: "'a + 'b" show"x \ x" by (induct x, simp_all) next fix x y :: "'a + 'b" assume"x \ y" and "y \ x" thus "x = y" by (induct x, auto elim!: sum_below_elims intro: below_antisym) next fix x y z :: "'a + 'b" assume"x \ y" and "y \ z" thus "x \ z" by (induct x, auto elim!: sum_below_elims intro: below_trans) qed
lemma monofun_inv_Inl: "monofun (\p. THE a. p = Inl a)" by (rule monofunI, erule sum_below_cases, simp_all)
lemma monofun_inv_Inr: "monofun (\p. THE b. p = Inr b)" by (rule monofunI, erule sum_below_cases, simp_all)
lemma sum_chain_cases: assumes Y: "chain Y" assumes A: "\A. \chain A; Y = (\i. Inl (A i))\ \ R" assumes B: "\B. \chain B; Y = (\i. Inr (B i))\ \ R" shows"R" apply (cases "Y 0") apply (rule A) apply (rule ch2ch_monofun [OF monofun_inv_Inl Y]) apply (rule ext) apply (cut_tac j=i in chain_mono [OF Y le0], simp) apply (erule Inl_belowE, simp) apply (rule B) apply (rule ch2ch_monofun [OF monofun_inv_Inr Y]) apply (rule ext) apply (cut_tac j=i in chain_mono [OF Y le0], simp) apply (erule Inr_belowE, simp) done
lemma cont_case_sum1: assumes f: "\a. cont (\x. f x a)" assumes g: "\b. cont (\x. g x b)" shows"cont (\x. case y of Inl a \ f x a | Inr b \ g x b)" by (induct y, simp add: f, simp add: g)
lemma cont2cont_case_sum: assumes f1: "\a. cont (\x. f x a)" and f2: "\x. cont (\a. f x a)" assumes g1: "\b. cont (\x. g x b)" and g2: "\x. cont (\b. g x b)" assumes h: "cont (\x. h x)" shows"cont (\x. case h x of Inl a \ f x a | Inr b \ g x b)" apply (rule cont_apply [OF h]) apply (rule cont_case_sum2 [OF f2 g2]) apply (rule cont_case_sum1 [OF f1 g1]) done
lemma cont2cont_case_sum' [simp, cont2cont]: assumes f: "cont (\p. f (fst p) (snd p))" assumes g: "cont (\p. g (fst p) (snd p))" assumes h: "cont (\x. h x)" shows"cont (\x. case h x of Inl a \ f x a | Inr b \ g x b)" using assms by (simp add: cont2cont_case_sum prod_cont_iff)
text\<open>Continuity of map function.\<close>
lemma map_sum_eq: "map_sum f g = case_sum (\a. Inl (f a)) (\b. Inr (g b))" by (rule ext, case_tac x, simp_all)
lemma cont2cont_map_sum [simp, cont2cont]: assumes f: "cont (\(x, y). f x y)" assumes g: "cont (\(x, y). g x y)" assumes h: "cont (\x. h x)" shows"cont (\x. map_sum (\y. f x y) (\y. g x y) (h x))" using assms by (simp add: map_sum_eq prod_cont_iff)
subsection \<open>Compactness and chain-finiteness\<close>
subsection \<open>Disjoint sum is a predomain\<close>
definition "encode_sum_u =
(\<Lambda>(up\<cdot>x). case x of Inl a \<Rightarrow> sinl\<cdot>(up\<cdot>a) | Inr b \<Rightarrow> sinr\<cdot>(up\<cdot>b))"
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.