1 (* Title: HOL/HOLCF/Product_Cpo.thy |
1 (* Title: HOL/HOLCF/Product_Cpo.thy |
2 Author: Franz Regensburger |
2 Author: Franz Regensburger |
3 *) |
3 *) |
4 |
4 |
5 section {* The cpo of cartesian products *} |
5 section \<open>The cpo of cartesian products\<close> |
6 |
6 |
7 theory Product_Cpo |
7 theory Product_Cpo |
8 imports Adm |
8 imports Adm |
9 begin |
9 begin |
10 |
10 |
11 default_sort cpo |
11 default_sort cpo |
12 |
12 |
13 subsection {* Unit type is a pcpo *} |
13 subsection \<open>Unit type is a pcpo\<close> |
14 |
14 |
15 instantiation unit :: discrete_cpo |
15 instantiation unit :: discrete_cpo |
16 begin |
16 begin |
17 |
17 |
18 definition |
18 definition |
53 assume "x \<sqsubseteq> y" "y \<sqsubseteq> z" thus "x \<sqsubseteq> z" |
53 assume "x \<sqsubseteq> y" "y \<sqsubseteq> z" thus "x \<sqsubseteq> z" |
54 unfolding below_prod_def |
54 unfolding below_prod_def |
55 by (fast intro: below_trans) |
55 by (fast intro: below_trans) |
56 qed |
56 qed |
57 |
57 |
58 subsection {* Monotonicity of \emph{Pair}, \emph{fst}, \emph{snd} *} |
58 subsection \<open>Monotonicity of \emph{Pair}, \emph{fst}, \emph{snd}\<close> |
59 |
59 |
60 lemma prod_belowI: "\<lbrakk>fst p \<sqsubseteq> fst q; snd p \<sqsubseteq> snd q\<rbrakk> \<Longrightarrow> p \<sqsubseteq> q" |
60 lemma prod_belowI: "\<lbrakk>fst p \<sqsubseteq> fst q; snd p \<sqsubseteq> snd q\<rbrakk> \<Longrightarrow> p \<sqsubseteq> q" |
61 unfolding below_prod_def by simp |
61 unfolding below_prod_def by simp |
62 |
62 |
63 lemma Pair_below_iff [simp]: "(a, b) \<sqsubseteq> (c, d) \<longleftrightarrow> a \<sqsubseteq> c \<and> b \<sqsubseteq> d" |
63 lemma Pair_below_iff [simp]: "(a, b) \<sqsubseteq> (c, d) \<longleftrightarrow> a \<sqsubseteq> c \<and> b \<sqsubseteq> d" |
64 unfolding below_prod_def by simp |
64 unfolding below_prod_def by simp |
65 |
65 |
66 text {* Pair @{text "(_,_)"} is monotone in both arguments *} |
66 text \<open>Pair \<open>(_,_)\<close> is monotone in both arguments\<close> |
67 |
67 |
68 lemma monofun_pair1: "monofun (\<lambda>x. (x, y))" |
68 lemma monofun_pair1: "monofun (\<lambda>x. (x, y))" |
69 by (simp add: monofun_def) |
69 by (simp add: monofun_def) |
70 |
70 |
71 lemma monofun_pair2: "monofun (\<lambda>y. (x, y))" |
71 lemma monofun_pair2: "monofun (\<lambda>y. (x, y))" |
77 |
77 |
78 lemma ch2ch_Pair [simp]: |
78 lemma ch2ch_Pair [simp]: |
79 "chain X \<Longrightarrow> chain Y \<Longrightarrow> chain (\<lambda>i. (X i, Y i))" |
79 "chain X \<Longrightarrow> chain Y \<Longrightarrow> chain (\<lambda>i. (X i, Y i))" |
80 by (rule chainI, simp add: chainE) |
80 by (rule chainI, simp add: chainE) |
81 |
81 |
82 text {* @{term fst} and @{term snd} are monotone *} |
82 text \<open>@{term fst} and @{term snd} are monotone\<close> |
83 |
83 |
84 lemma fst_monofun: "x \<sqsubseteq> y \<Longrightarrow> fst x \<sqsubseteq> fst y" |
84 lemma fst_monofun: "x \<sqsubseteq> y \<Longrightarrow> fst x \<sqsubseteq> fst y" |
85 unfolding below_prod_def by simp |
85 unfolding below_prod_def by simp |
86 |
86 |
87 lemma snd_monofun: "x \<sqsubseteq> y \<Longrightarrow> snd x \<sqsubseteq> snd y" |
87 lemma snd_monofun: "x \<sqsubseteq> y \<Longrightarrow> snd x \<sqsubseteq> snd y" |
100 lemma prod_chain_cases: |
100 lemma prod_chain_cases: |
101 assumes "chain Y" |
101 assumes "chain Y" |
102 obtains A B |
102 obtains A B |
103 where "chain A" and "chain B" and "Y = (\<lambda>i. (A i, B i))" |
103 where "chain A" and "chain B" and "Y = (\<lambda>i. (A i, B i))" |
104 proof |
104 proof |
105 from `chain Y` show "chain (\<lambda>i. fst (Y i))" by (rule ch2ch_fst) |
105 from \<open>chain Y\<close> show "chain (\<lambda>i. fst (Y i))" by (rule ch2ch_fst) |
106 from `chain Y` show "chain (\<lambda>i. snd (Y i))" by (rule ch2ch_snd) |
106 from \<open>chain Y\<close> show "chain (\<lambda>i. snd (Y i))" by (rule ch2ch_snd) |
107 show "Y = (\<lambda>i. (fst (Y i), snd (Y i)))" by simp |
107 show "Y = (\<lambda>i. (fst (Y i), snd (Y i)))" by simp |
108 qed |
108 qed |
109 |
109 |
110 subsection {* Product type is a cpo *} |
110 subsection \<open>Product type is a cpo\<close> |
111 |
111 |
112 lemma is_lub_Pair: |
112 lemma is_lub_Pair: |
113 "\<lbrakk>range A <<| x; range B <<| y\<rbrakk> \<Longrightarrow> range (\<lambda>i. (A i, B i)) <<| (x, y)" |
113 "\<lbrakk>range A <<| x; range B <<| y\<rbrakk> \<Longrightarrow> range (\<lambda>i. (A i, B i)) <<| (x, y)" |
114 unfolding is_lub_def is_ub_def ball_simps below_prod_def by simp |
114 unfolding is_lub_def is_ub_def ball_simps below_prod_def by simp |
115 |
115 |
144 show "x \<sqsubseteq> y \<longleftrightarrow> x = y" |
144 show "x \<sqsubseteq> y \<longleftrightarrow> x = y" |
145 unfolding below_prod_def prod_eq_iff |
145 unfolding below_prod_def prod_eq_iff |
146 by simp |
146 by simp |
147 qed |
147 qed |
148 |
148 |
149 subsection {* Product type is pointed *} |
149 subsection \<open>Product type is pointed\<close> |
150 |
150 |
151 lemma minimal_prod: "(\<bottom>, \<bottom>) \<sqsubseteq> p" |
151 lemma minimal_prod: "(\<bottom>, \<bottom>) \<sqsubseteq> p" |
152 by (simp add: below_prod_def) |
152 by (simp add: below_prod_def) |
153 |
153 |
154 instance prod :: (pcpo, pcpo) pcpo |
154 instance prod :: (pcpo, pcpo) pcpo |
170 by simp |
170 by simp |
171 |
171 |
172 lemma split_strict [simp]: "case_prod f \<bottom> = f \<bottom> \<bottom>" |
172 lemma split_strict [simp]: "case_prod f \<bottom> = f \<bottom> \<bottom>" |
173 unfolding split_def by simp |
173 unfolding split_def by simp |
174 |
174 |
175 subsection {* Continuity of \emph{Pair}, \emph{fst}, \emph{snd} *} |
175 subsection \<open>Continuity of \emph{Pair}, \emph{fst}, \emph{snd}\<close> |
176 |
176 |
177 lemma cont_pair1: "cont (\<lambda>x. (x, y))" |
177 lemma cont_pair1: "cont (\<lambda>x. (x, y))" |
178 apply (rule contI) |
178 apply (rule contI) |
179 apply (rule is_lub_Pair) |
179 apply (rule is_lub_Pair) |
180 apply (erule cpo_lubI) |
180 apply (erule cpo_lubI) |
250 assumes f: "cont (\<lambda>p. f (fst p) (fst (snd p)) (snd (snd p)))" |
250 assumes f: "cont (\<lambda>p. f (fst p) (fst (snd p)) (snd (snd p)))" |
251 assumes g: "cont (\<lambda>x. g x)" |
251 assumes g: "cont (\<lambda>x. g x)" |
252 shows "cont (\<lambda>x. case_prod (f x) (g x))" |
252 shows "cont (\<lambda>x. case_prod (f x) (g x))" |
253 using assms by (simp add: cont2cont_case_prod prod_cont_iff) |
253 using assms by (simp add: cont2cont_case_prod prod_cont_iff) |
254 |
254 |
255 text {* The simple version (due to Joachim Breitner) is needed if |
255 text \<open>The simple version (due to Joachim Breitner) is needed if |
256 either element type of the pair is not a cpo. *} |
256 either element type of the pair is not a cpo.\<close> |
257 |
257 |
258 lemma cont2cont_split_simple [simp, cont2cont]: |
258 lemma cont2cont_split_simple [simp, cont2cont]: |
259 assumes "\<And>a b. cont (\<lambda>x. f x a b)" |
259 assumes "\<And>a b. cont (\<lambda>x. f x a b)" |
260 shows "cont (\<lambda>x. case p of (a, b) \<Rightarrow> f x a b)" |
260 shows "cont (\<lambda>x. case p of (a, b) \<Rightarrow> f x a b)" |
261 using assms by (cases p) auto |
261 using assms by (cases p) auto |
262 |
262 |
263 text {* Admissibility of predicates on product types. *} |
263 text \<open>Admissibility of predicates on product types.\<close> |
264 |
264 |
265 lemma adm_case_prod [simp]: |
265 lemma adm_case_prod [simp]: |
266 assumes "adm (\<lambda>x. P x (fst (f x)) (snd (f x)))" |
266 assumes "adm (\<lambda>x. P x (fst (f x)) (snd (f x)))" |
267 shows "adm (\<lambda>x. case f x of (a, b) \<Rightarrow> P x a b)" |
267 shows "adm (\<lambda>x. case f x of (a, b) \<Rightarrow> P x a b)" |
268 unfolding case_prod_beta using assms . |
268 unfolding case_prod_beta using assms . |
269 |
269 |
270 subsection {* Compactness and chain-finiteness *} |
270 subsection \<open>Compactness and chain-finiteness\<close> |
271 |
271 |
272 lemma fst_below_iff: "fst (x::'a \<times> 'b) \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> (y, snd x)" |
272 lemma fst_below_iff: "fst (x::'a \<times> 'b) \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> (y, snd x)" |
273 unfolding below_prod_def by simp |
273 unfolding below_prod_def by simp |
274 |
274 |
275 lemma snd_below_iff: "snd (x::'a \<times> 'b) \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> (fst x, y)" |
275 lemma snd_below_iff: "snd (x::'a \<times> 'b) \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> (fst x, y)" |