(* Title: HOL/HOLCF/Library/Sum_Cpo.thy Author: Brian Huffman *)
section‹The cpo of disjoint sums›
theory Sum_Cpo imports HOLCF begin
subsection‹Ordering on sum type›
instantiation sum :: (below, below) below begin
definition below_sum_def: "x ⊑ y ≡ case x of Inl a ==> (case y of Inl b ==> a ⊑ b | Inr b ==> False) | Inr a ==> (case y of Inl b ==> False | Inr b ==> a ⊑ 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; ∧a b. [x = Inl a; y = Inl b; a ⊑ b]==> R; ∧a b. [x = Inr a; y = Inr b; a ⊑ b]==> R] ==> R" by (cases x, safe elim!: sum_below_elims, auto)
subsection‹Sum type is a complete partial order›
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‹Continuity of map function.›
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)
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 und die Messung sind noch experimentell.