1 (* Title: HOLCF/Sprod.thy
2 Author: Franz Regensburger
6 header {* The type of strict products *}
14 subsection {* Definition of strict product type *}
16 pcpodef ('a, 'b) sprod (infixr "**" 20) =
17 "{p::'a \<times> 'b. p = \<bottom> \<or> (fst p \<noteq> \<bottom> \<and> snd p \<noteq> \<bottom>)}"
20 instance sprod :: ("{chfin,pcpo}", "{chfin,pcpo}") chfin
21 by (rule typedef_chfin [OF type_definition_sprod below_sprod_def])
23 type_notation (xsymbols)
24 sprod ("(_ \<otimes>/ _)" [21,20] 20)
25 type_notation (HTML output)
26 sprod ("(_ \<otimes>/ _)" [21,20] 20)
28 subsection {* Definitions of constants *}
31 sfst :: "('a ** 'b) \<rightarrow> 'a" where
32 "sfst = (\<Lambda> p. fst (Rep_sprod p))"
35 ssnd :: "('a ** 'b) \<rightarrow> 'b" where
36 "ssnd = (\<Lambda> p. snd (Rep_sprod p))"
39 spair :: "'a \<rightarrow> 'b \<rightarrow> ('a ** 'b)" where
40 "spair = (\<Lambda> a b. Abs_sprod (seq\<cdot>b\<cdot>a, seq\<cdot>a\<cdot>b))"
43 ssplit :: "('a \<rightarrow> 'b \<rightarrow> 'c) \<rightarrow> ('a ** 'b) \<rightarrow> 'c" where
44 "ssplit = (\<Lambda> f p. seq\<cdot>p\<cdot>(f\<cdot>(sfst\<cdot>p)\<cdot>(ssnd\<cdot>p)))"
47 "_stuple" :: "['a, args] => 'a ** 'b" ("(1'(:_,/ _:'))")
49 "(:x, y, z:)" == "(:x, (:y, z:):)"
50 "(:x, y:)" == "CONST spair\<cdot>x\<cdot>y"
53 "\<Lambda>(CONST spair\<cdot>x\<cdot>y). t" == "CONST ssplit\<cdot>(\<Lambda> x y. t)"
55 subsection {* Case analysis *}
57 lemma spair_sprod: "(seq\<cdot>b\<cdot>a, seq\<cdot>a\<cdot>b) \<in> sprod"
58 by (simp add: sprod_def seq_conv_if)
60 lemma Rep_sprod_spair: "Rep_sprod (:a, b:) = (seq\<cdot>b\<cdot>a, seq\<cdot>a\<cdot>b)"
61 by (simp add: spair_def cont_Abs_sprod Abs_sprod_inverse spair_sprod)
63 lemmas Rep_sprod_simps =
64 Rep_sprod_inject [symmetric] below_sprod_def
65 Pair_fst_snd_eq below_prod_def
66 Rep_sprod_strict Rep_sprod_spair
68 lemma sprodE [case_names bottom spair, cases type: sprod]:
69 obtains "p = \<bottom>" | x y where "p = (:x, y:)" and "x \<noteq> \<bottom>" and "y \<noteq> \<bottom>"
70 using Rep_sprod [of p] by (auto simp add: sprod_def Rep_sprod_simps)
72 lemma sprod_induct [case_names bottom spair, induct type: sprod]:
73 "\<lbrakk>P \<bottom>; \<And>x y. \<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> P (:x, y:)\<rbrakk> \<Longrightarrow> P x"
74 by (cases x, simp_all)
76 subsection {* Properties of \emph{spair} *}
78 lemma spair_strict1 [simp]: "(:\<bottom>, y:) = \<bottom>"
79 by (simp add: Rep_sprod_simps)
81 lemma spair_strict2 [simp]: "(:x, \<bottom>:) = \<bottom>"
82 by (simp add: Rep_sprod_simps)
84 lemma spair_bottom_iff [simp]: "((:x, y:) = \<bottom>) = (x = \<bottom> \<or> y = \<bottom>)"
85 by (simp add: Rep_sprod_simps seq_conv_if)
87 lemma spair_below_iff:
88 "((:a, b:) \<sqsubseteq> (:c, d:)) = (a = \<bottom> \<or> b = \<bottom> \<or> (a \<sqsubseteq> c \<and> b \<sqsubseteq> d))"
89 by (simp add: Rep_sprod_simps seq_conv_if)
92 "((:a, b:) = (:c, d:)) =
93 (a = c \<and> b = d \<or> (a = \<bottom> \<or> b = \<bottom>) \<and> (c = \<bottom> \<or> d = \<bottom>))"
94 by (simp add: Rep_sprod_simps seq_conv_if)
96 lemma spair_strict: "x = \<bottom> \<or> y = \<bottom> \<Longrightarrow> (:x, y:) = \<bottom>"
99 lemma spair_strict_rev: "(:x, y:) \<noteq> \<bottom> \<Longrightarrow> x \<noteq> \<bottom> \<and> y \<noteq> \<bottom>"
102 lemma spair_defined: "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<noteq> \<bottom>"
105 lemma spair_defined_rev: "(:x, y:) = \<bottom> \<Longrightarrow> x = \<bottom> \<or> y = \<bottom>"
109 "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> (:x, y:) \<sqsubseteq> (:a, b:) = (x \<sqsubseteq> a \<and> y \<sqsubseteq> b)"
110 by (simp add: spair_below_iff)
113 "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ((:x, y:) = (:a, b:)) = (x = a \<and> y = b)"
114 by (simp add: spair_eq_iff)
117 "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>; (:x, y:) = (:a, b:)\<rbrakk> \<Longrightarrow> x = a \<and> y = b"
118 by (rule spair_eq [THEN iffD1])
120 lemma inst_sprod_pcpo2: "UU = (:UU,UU:)"
123 lemma sprodE2: "(\<And>x y. p = (:x, y:) \<Longrightarrow> Q) \<Longrightarrow> Q"
124 by (cases p, simp only: inst_sprod_pcpo2, simp)
126 subsection {* Properties of \emph{sfst} and \emph{ssnd} *}
128 lemma sfst_strict [simp]: "sfst\<cdot>\<bottom> = \<bottom>"
129 by (simp add: sfst_def cont_Rep_sprod Rep_sprod_strict)
131 lemma ssnd_strict [simp]: "ssnd\<cdot>\<bottom> = \<bottom>"
132 by (simp add: ssnd_def cont_Rep_sprod Rep_sprod_strict)
134 lemma sfst_spair [simp]: "y \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>(:x, y:) = x"
135 by (simp add: sfst_def cont_Rep_sprod Rep_sprod_spair)
137 lemma ssnd_spair [simp]: "x \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>(:x, y:) = y"
138 by (simp add: ssnd_def cont_Rep_sprod Rep_sprod_spair)
140 lemma sfst_bottom_iff [simp]: "(sfst\<cdot>p = \<bottom>) = (p = \<bottom>)"
141 by (cases p, simp_all)
143 lemma ssnd_bottom_iff [simp]: "(ssnd\<cdot>p = \<bottom>) = (p = \<bottom>)"
144 by (cases p, simp_all)
146 lemma sfst_defined: "p \<noteq> \<bottom> \<Longrightarrow> sfst\<cdot>p \<noteq> \<bottom>"
149 lemma ssnd_defined: "p \<noteq> \<bottom> \<Longrightarrow> ssnd\<cdot>p \<noteq> \<bottom>"
152 lemma spair_sfst_ssnd: "(:sfst\<cdot>p, ssnd\<cdot>p:) = p"
153 by (cases p, simp_all)
155 lemma below_sprod: "(x \<sqsubseteq> y) = (sfst\<cdot>x \<sqsubseteq> sfst\<cdot>y \<and> ssnd\<cdot>x \<sqsubseteq> ssnd\<cdot>y)"
156 by (simp add: Rep_sprod_simps sfst_def ssnd_def cont_Rep_sprod)
158 lemma eq_sprod: "(x = y) = (sfst\<cdot>x = sfst\<cdot>y \<and> ssnd\<cdot>x = ssnd\<cdot>y)"
159 by (auto simp add: po_eq_conv below_sprod)
161 lemma sfst_below_iff: "sfst\<cdot>x \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> (:y, ssnd\<cdot>x:)"
162 apply (cases "x = \<bottom>", simp, cases "y = \<bottom>", simp)
163 apply (simp add: below_sprod)
166 lemma ssnd_below_iff: "ssnd\<cdot>x \<sqsubseteq> y \<longleftrightarrow> x \<sqsubseteq> (:sfst\<cdot>x, y:)"
167 apply (cases "x = \<bottom>", simp, cases "y = \<bottom>", simp)
168 apply (simp add: below_sprod)
171 subsection {* Compactness *}
173 lemma compact_sfst: "compact x \<Longrightarrow> compact (sfst\<cdot>x)"
174 by (rule compactI, simp add: sfst_below_iff)
176 lemma compact_ssnd: "compact x \<Longrightarrow> compact (ssnd\<cdot>x)"
177 by (rule compactI, simp add: ssnd_below_iff)
179 lemma compact_spair: "\<lbrakk>compact x; compact y\<rbrakk> \<Longrightarrow> compact (:x, y:)"
180 by (rule compact_sprod, simp add: Rep_sprod_spair seq_conv_if)
182 lemma compact_spair_iff:
183 "compact (:x, y:) = (x = \<bottom> \<or> y = \<bottom> \<or> (compact x \<and> compact y))"
184 apply (safe elim!: compact_spair)
185 apply (drule compact_sfst, simp)
186 apply (drule compact_ssnd, simp)
191 subsection {* Properties of \emph{ssplit} *}
193 lemma ssplit1 [simp]: "ssplit\<cdot>f\<cdot>\<bottom> = \<bottom>"
194 by (simp add: ssplit_def)
196 lemma ssplit2 [simp]: "\<lbrakk>x \<noteq> \<bottom>; y \<noteq> \<bottom>\<rbrakk> \<Longrightarrow> ssplit\<cdot>f\<cdot>(:x, y:) = f\<cdot>x\<cdot>y"
197 by (simp add: ssplit_def)
199 lemma ssplit3 [simp]: "ssplit\<cdot>spair\<cdot>z = z"
200 by (cases z, simp_all)
202 subsection {* Strict product preserves flatness *}
204 instance sprod :: (flat, flat) flat
206 fix x y :: "'a \<otimes> 'b"
207 assume "x \<sqsubseteq> y" thus "x = \<bottom> \<or> x = y"
208 apply (induct x, simp)
209 apply (induct y, simp)
210 apply (simp add: spair_below_iff flat_below_iff)