add Product_Cpo.thy
authorhuffman
Wed Jan 14 17:12:21 2009 -0800 (2009-01-14)
changeset 295312eb29775b0b6
parent 29530 9905b660612b
child 29532 59bee7985149
add Product_Cpo.thy
src/HOLCF/Product_Cpo.thy
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOLCF/Product_Cpo.thy	Wed Jan 14 17:12:21 2009 -0800
     1.3 @@ -0,0 +1,203 @@
     1.4 +(*  Title:      HOLCF/Product_Cpo.thy
     1.5 +    Author:     Franz Regensburger
     1.6 +*)
     1.7 +
     1.8 +header {* The cpo of cartesian products *}
     1.9 +
    1.10 +theory Product_Cpo
    1.11 +imports Ffun
    1.12 +begin
    1.13 +
    1.14 +defaultsort cpo
    1.15 +
    1.16 +subsection {* Type @{typ unit} is a pcpo *}
    1.17 +
    1.18 +instantiation unit :: sq_ord
    1.19 +begin
    1.20 +
    1.21 +definition
    1.22 +  less_unit_def [simp]: "x \<sqsubseteq> (y::unit) \<equiv> True"
    1.23 +
    1.24 +instance ..
    1.25 +end
    1.26 +
    1.27 +instance unit :: discrete_cpo
    1.28 +by intro_classes simp
    1.29 +
    1.30 +instance unit :: finite_po ..
    1.31 +
    1.32 +instance unit :: pcpo
    1.33 +by intro_classes simp
    1.34 +
    1.35 +
    1.36 +subsection {* Product type is a partial order *}
    1.37 +
    1.38 +instantiation "*" :: (sq_ord, sq_ord) sq_ord
    1.39 +begin
    1.40 +
    1.41 +definition
    1.42 +  less_cprod_def: "(op \<sqsubseteq>) \<equiv> \<lambda>p1 p2. (fst p1 \<sqsubseteq> fst p2 \<and> snd p1 \<sqsubseteq> snd p2)"
    1.43 +
    1.44 +instance ..
    1.45 +end
    1.46 +
    1.47 +instance "*" :: (po, po) po
    1.48 +proof
    1.49 +  fix x :: "'a \<times> 'b"
    1.50 +  show "x \<sqsubseteq> x"
    1.51 +    unfolding less_cprod_def by simp
    1.52 +next
    1.53 +  fix x y :: "'a \<times> 'b"
    1.54 +  assume "x \<sqsubseteq> y" "y \<sqsubseteq> x" thus "x = y"
    1.55 +    unfolding less_cprod_def Pair_fst_snd_eq
    1.56 +    by (fast intro: antisym_less)
    1.57 +next
    1.58 +  fix x y z :: "'a \<times> 'b"
    1.59 +  assume "x \<sqsubseteq> y" "y \<sqsubseteq> z" thus "x \<sqsubseteq> z"
    1.60 +    unfolding less_cprod_def
    1.61 +    by (fast intro: trans_less)
    1.62 +qed
    1.63 +
    1.64 +subsection {* Monotonicity of @{text "(_,_)"}, @{term fst}, @{term snd} *}
    1.65 +
    1.66 +lemma prod_lessI: "\<lbrakk>fst p \<sqsubseteq> fst q; snd p \<sqsubseteq> snd q\<rbrakk> \<Longrightarrow> p \<sqsubseteq> q"
    1.67 +unfolding less_cprod_def by simp
    1.68 +
    1.69 +lemma Pair_less_iff [simp]: "(a, b) \<sqsubseteq> (c, d) = (a \<sqsubseteq> c \<and> b \<sqsubseteq> d)"
    1.70 +unfolding less_cprod_def by simp
    1.71 +
    1.72 +text {* Pair @{text "(_,_)"}  is monotone in both arguments *}
    1.73 +
    1.74 +lemma monofun_pair1: "monofun (\<lambda>x. (x, y))"
    1.75 +by (simp add: monofun_def)
    1.76 +
    1.77 +lemma monofun_pair2: "monofun (\<lambda>y. (x, y))"
    1.78 +by (simp add: monofun_def)
    1.79 +
    1.80 +lemma monofun_pair:
    1.81 +  "\<lbrakk>x1 \<sqsubseteq> x2; y1 \<sqsubseteq> y2\<rbrakk> \<Longrightarrow> (x1, y1) \<sqsubseteq> (x2, y2)"
    1.82 +by simp
    1.83 +
    1.84 +text {* @{term fst} and @{term snd} are monotone *}
    1.85 +
    1.86 +lemma monofun_fst: "monofun fst"
    1.87 +by (simp add: monofun_def less_cprod_def)
    1.88 +
    1.89 +lemma monofun_snd: "monofun snd"
    1.90 +by (simp add: monofun_def less_cprod_def)
    1.91 +
    1.92 +subsection {* Product type is a cpo *}
    1.93 +
    1.94 +lemma is_lub_Pair:
    1.95 +  "\<lbrakk>range X <<| x; range Y <<| y\<rbrakk> \<Longrightarrow> range (\<lambda>i. (X i, Y i)) <<| (x, y)"
    1.96 +apply (rule is_lubI [OF ub_rangeI])
    1.97 +apply (simp add: less_cprod_def is_ub_lub)
    1.98 +apply (frule ub2ub_monofun [OF monofun_fst])
    1.99 +apply (drule ub2ub_monofun [OF monofun_snd])
   1.100 +apply (simp add: less_cprod_def is_lub_lub)
   1.101 +done
   1.102 +
   1.103 +lemma lub_cprod:
   1.104 +  fixes S :: "nat \<Rightarrow> ('a::cpo \<times> 'b::cpo)"
   1.105 +  assumes S: "chain S"
   1.106 +  shows "range S <<| (\<Squnion>i. fst (S i), \<Squnion>i. snd (S i))"
   1.107 +proof -
   1.108 +  have "chain (\<lambda>i. fst (S i))"
   1.109 +    using monofun_fst S by (rule ch2ch_monofun)
   1.110 +  hence 1: "range (\<lambda>i. fst (S i)) <<| (\<Squnion>i. fst (S i))"
   1.111 +    by (rule cpo_lubI)
   1.112 +  have "chain (\<lambda>i. snd (S i))"
   1.113 +    using monofun_snd S by (rule ch2ch_monofun)
   1.114 +  hence 2: "range (\<lambda>i. snd (S i)) <<| (\<Squnion>i. snd (S i))"
   1.115 +    by (rule cpo_lubI)
   1.116 +  show "range S <<| (\<Squnion>i. fst (S i), \<Squnion>i. snd (S i))"
   1.117 +    using is_lub_Pair [OF 1 2] by simp
   1.118 +qed
   1.119 +
   1.120 +lemma thelub_cprod:
   1.121 +  "chain (S::nat \<Rightarrow> 'a::cpo \<times> 'b::cpo)
   1.122 +    \<Longrightarrow> (\<Squnion>i. S i) = (\<Squnion>i. fst (S i), \<Squnion>i. snd (S i))"
   1.123 +by (rule lub_cprod [THEN thelubI])
   1.124 +
   1.125 +instance "*" :: (cpo, cpo) cpo
   1.126 +proof
   1.127 +  fix S :: "nat \<Rightarrow> ('a \<times> 'b)"
   1.128 +  assume "chain S"
   1.129 +  hence "range S <<| (\<Squnion>i. fst (S i), \<Squnion>i. snd (S i))"
   1.130 +    by (rule lub_cprod)
   1.131 +  thus "\<exists>x. range S <<| x" ..
   1.132 +qed
   1.133 +
   1.134 +instance "*" :: (finite_po, finite_po) finite_po ..
   1.135 +
   1.136 +instance "*" :: (discrete_cpo, discrete_cpo) discrete_cpo
   1.137 +proof
   1.138 +  fix x y :: "'a \<times> 'b"
   1.139 +  show "x \<sqsubseteq> y \<longleftrightarrow> x = y"
   1.140 +    unfolding less_cprod_def Pair_fst_snd_eq
   1.141 +    by simp
   1.142 +qed
   1.143 +
   1.144 +subsection {* Product type is pointed *}
   1.145 +
   1.146 +lemma minimal_cprod: "(\<bottom>, \<bottom>) \<sqsubseteq> p"
   1.147 +by (simp add: less_cprod_def)
   1.148 +
   1.149 +instance "*" :: (pcpo, pcpo) pcpo
   1.150 +by intro_classes (fast intro: minimal_cprod)
   1.151 +
   1.152 +lemma inst_cprod_pcpo: "\<bottom> = (\<bottom>, \<bottom>)"
   1.153 +by (rule minimal_cprod [THEN UU_I, symmetric])
   1.154 +
   1.155 +
   1.156 +subsection {* Continuity of @{text "(_,_)"}, @{term fst}, @{term snd} *}
   1.157 +
   1.158 +lemma cont_pair1: "cont (\<lambda>x. (x, y))"
   1.159 +apply (rule contI)
   1.160 +apply (rule is_lub_Pair)
   1.161 +apply (erule cpo_lubI)
   1.162 +apply (rule lub_const)
   1.163 +done
   1.164 +
   1.165 +lemma cont_pair2: "cont (\<lambda>y. (x, y))"
   1.166 +apply (rule contI)
   1.167 +apply (rule is_lub_Pair)
   1.168 +apply (rule lub_const)
   1.169 +apply (erule cpo_lubI)
   1.170 +done
   1.171 +
   1.172 +lemma contlub_fst: "contlub fst"
   1.173 +apply (rule contlubI)
   1.174 +apply (simp add: thelub_cprod)
   1.175 +done
   1.176 +
   1.177 +lemma contlub_snd: "contlub snd"
   1.178 +apply (rule contlubI)
   1.179 +apply (simp add: thelub_cprod)
   1.180 +done
   1.181 +
   1.182 +lemma cont_fst: "cont fst"
   1.183 +apply (rule monocontlub2cont)
   1.184 +apply (rule monofun_fst)
   1.185 +apply (rule contlub_fst)
   1.186 +done
   1.187 +
   1.188 +lemma cont_snd: "cont snd"
   1.189 +apply (rule monocontlub2cont)
   1.190 +apply (rule monofun_snd)
   1.191 +apply (rule contlub_snd)
   1.192 +done
   1.193 +
   1.194 +lemma cont2cont_Pair [cont2cont]:
   1.195 +  assumes f: "cont (\<lambda>x. f x)"
   1.196 +  assumes g: "cont (\<lambda>x. g x)"
   1.197 +  shows "cont (\<lambda>x. (f x, g x))"
   1.198 +apply (rule cont2cont_app2 [OF cont2cont_lambda cont_pair2 g])
   1.199 +apply (rule cont2cont_app2 [OF cont_const cont_pair1 f])
   1.200 +done
   1.201 +
   1.202 +lemmas cont2cont_fst [cont2cont] = cont2cont_app3 [OF cont_fst]
   1.203 +
   1.204 +lemmas cont2cont_snd [cont2cont] = cont2cont_app3 [OF cont_snd]
   1.205 +
   1.206 +end