17 |
17 |
18 A predomain is a cpo that, when lifted, becomes a domain. |
18 A predomain is a cpo that, when lifted, becomes a domain. |
19 *} |
19 *} |
20 |
20 |
21 class predomain = cpo + |
21 class predomain = cpo + |
22 fixes liftdefl :: "('a::cpo) itself \<Rightarrow> defl" |
22 fixes liftdefl :: "('a::cpo) itself \<Rightarrow> udom defl" |
23 fixes liftemb :: "'a\<^sub>\<bottom> \<rightarrow> udom" |
23 fixes liftemb :: "'a\<^sub>\<bottom> \<rightarrow> udom" |
24 fixes liftprj :: "udom \<rightarrow> 'a\<^sub>\<bottom>" |
24 fixes liftprj :: "udom \<rightarrow> 'a\<^sub>\<bottom>" |
25 assumes predomain_ep: "ep_pair liftemb liftprj" |
25 assumes predomain_ep: "ep_pair liftemb liftprj" |
26 assumes cast_liftdefl: "cast\<cdot>(liftdefl TYPE('a::cpo)) = liftemb oo liftprj" |
26 assumes cast_liftdefl: "cast\<cdot>(liftdefl TYPE('a::cpo)) = liftemb oo liftprj" |
27 |
27 |
29 translations "LIFTDEFL('t)" \<rightleftharpoons> "CONST liftdefl TYPE('t)" |
29 translations "LIFTDEFL('t)" \<rightleftharpoons> "CONST liftdefl TYPE('t)" |
30 |
30 |
31 class "domain" = predomain + pcpo + |
31 class "domain" = predomain + pcpo + |
32 fixes emb :: "'a::cpo \<rightarrow> udom" |
32 fixes emb :: "'a::cpo \<rightarrow> udom" |
33 fixes prj :: "udom \<rightarrow> 'a::cpo" |
33 fixes prj :: "udom \<rightarrow> 'a::cpo" |
34 fixes defl :: "'a itself \<Rightarrow> defl" |
34 fixes defl :: "'a itself \<Rightarrow> udom defl" |
35 assumes ep_pair_emb_prj: "ep_pair emb prj" |
35 assumes ep_pair_emb_prj: "ep_pair emb prj" |
36 assumes cast_DEFL: "cast\<cdot>(defl TYPE('a)) = emb oo prj" |
36 assumes cast_DEFL: "cast\<cdot>(defl TYPE('a)) = emb oo prj" |
37 |
37 |
38 syntax "_DEFL" :: "type \<Rightarrow> defl" ("(1DEFL/(1'(_')))") |
38 syntax "_DEFL" :: "type \<Rightarrow> logic" ("(1DEFL/(1'(_')))") |
39 translations "DEFL('t)" \<rightleftharpoons> "CONST defl TYPE('t)" |
39 translations "DEFL('t)" \<rightleftharpoons> "CONST defl TYPE('t)" |
40 |
40 |
41 interpretation "domain": pcpo_ep_pair emb prj |
41 interpretation "domain": pcpo_ep_pair emb prj |
42 unfolding pcpo_ep_pair_def |
42 unfolding pcpo_ep_pair_def |
43 by (rule ep_pair_emb_prj) |
43 by (rule ep_pair_emb_prj) |
49 lemmas prj_strict = domain.p_strict |
49 lemmas prj_strict = domain.p_strict |
50 |
50 |
51 subsection {* Domains are bifinite *} |
51 subsection {* Domains are bifinite *} |
52 |
52 |
53 lemma approx_chain_ep_cast: |
53 lemma approx_chain_ep_cast: |
54 assumes ep: "ep_pair (e::'a \<rightarrow> udom) (p::udom \<rightarrow> 'a)" |
54 assumes ep: "ep_pair (e::'a::pcpo \<rightarrow> udom) (p::udom \<rightarrow> 'a)" |
55 assumes cast_t: "cast\<cdot>t = e oo p" |
55 assumes cast_t: "cast\<cdot>t = e oo p" |
56 shows "\<exists>(a::nat \<Rightarrow> 'a \<rightarrow> 'a). approx_chain a" |
56 shows "\<exists>(a::nat \<Rightarrow> 'a::pcpo \<rightarrow> 'a). approx_chain a" |
57 proof - |
57 proof - |
58 interpret ep_pair e p by fact |
58 interpret ep_pair e p by fact |
59 obtain Y where Y: "\<forall>i. Y i \<sqsubseteq> Y (Suc i)" |
59 obtain Y where Y: "\<forall>i. Y i \<sqsubseteq> Y (Suc i)" |
60 and t: "t = (\<Squnion>i. defl_principal (Y i))" |
60 and t: "t = (\<Squnion>i. defl_principal (Y i))" |
61 by (rule defl.obtain_principal_chain) |
61 by (rule defl.obtain_principal_chain) |
142 |
142 |
143 default_sort bifinite |
143 default_sort bifinite |
144 |
144 |
145 definition |
145 definition |
146 defl_fun1 :: |
146 defl_fun1 :: |
147 "(nat \<Rightarrow> 'a \<rightarrow> 'a) \<Rightarrow> ((udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a)) \<Rightarrow> (defl \<rightarrow> defl)" |
147 "(nat \<Rightarrow> 'a \<rightarrow> 'a) \<Rightarrow> ((udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a)) \<Rightarrow> (udom defl \<rightarrow> udom defl)" |
148 where |
148 where |
149 "defl_fun1 approx f = |
149 "defl_fun1 approx f = |
150 defl.basis_fun (\<lambda>a. |
150 defl.basis_fun (\<lambda>a. |
151 defl_principal (Abs_fin_defl |
151 defl_principal (Abs_fin_defl |
152 (udom_emb approx oo f\<cdot>(Rep_fin_defl a) oo udom_prj approx)))" |
152 (udom_emb approx oo f\<cdot>(Rep_fin_defl a) oo udom_prj approx)))" |
153 |
153 |
154 definition |
154 definition |
155 defl_fun2 :: |
155 defl_fun2 :: |
156 "(nat \<Rightarrow> 'a \<rightarrow> 'a) \<Rightarrow> ((udom \<rightarrow> udom) \<rightarrow> (udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a)) |
156 "(nat \<Rightarrow> 'a \<rightarrow> 'a) \<Rightarrow> ((udom \<rightarrow> udom) \<rightarrow> (udom \<rightarrow> udom) \<rightarrow> ('a \<rightarrow> 'a)) |
157 \<Rightarrow> (defl \<rightarrow> defl \<rightarrow> defl)" |
157 \<Rightarrow> (udom defl \<rightarrow> udom defl \<rightarrow> udom defl)" |
158 where |
158 where |
159 "defl_fun2 approx f = |
159 "defl_fun2 approx f = |
160 defl.basis_fun (\<lambda>a. |
160 defl.basis_fun (\<lambda>a. |
161 defl.basis_fun (\<lambda>b. |
161 defl.basis_fun (\<lambda>b. |
162 defl_principal (Abs_fin_defl |
162 defl_principal (Abs_fin_defl |
211 Rep_fin_defl_mono |
211 Rep_fin_defl_mono |
212 cast_defl_principal |
212 cast_defl_principal |
213 Abs_fin_defl_inverse [unfolded mem_Collect_eq, OF 1]) |
213 Abs_fin_defl_inverse [unfolded mem_Collect_eq, OF 1]) |
214 qed |
214 qed |
215 |
215 |
216 definition u_defl :: "defl \<rightarrow> defl" |
216 definition u_defl :: "udom defl \<rightarrow> udom defl" |
217 where "u_defl = defl_fun1 u_approx u_map" |
217 where "u_defl = defl_fun1 u_approx u_map" |
218 |
218 |
219 definition sfun_defl :: "defl \<rightarrow> defl \<rightarrow> defl" |
219 definition sfun_defl :: "udom defl \<rightarrow> udom defl \<rightarrow> udom defl" |
220 where "sfun_defl = defl_fun2 sfun_approx sfun_map" |
220 where "sfun_defl = defl_fun2 sfun_approx sfun_map" |
221 |
221 |
222 definition prod_defl :: "defl \<rightarrow> defl \<rightarrow> defl" |
222 definition prod_defl :: "udom defl \<rightarrow> udom defl \<rightarrow> udom defl" |
223 where "prod_defl = defl_fun2 prod_approx cprod_map" |
223 where "prod_defl = defl_fun2 prod_approx cprod_map" |
224 |
224 |
225 definition sprod_defl :: "defl \<rightarrow> defl \<rightarrow> defl" |
225 definition sprod_defl :: "udom defl \<rightarrow> udom defl \<rightarrow> udom defl" |
226 where "sprod_defl = defl_fun2 sprod_approx sprod_map" |
226 where "sprod_defl = defl_fun2 sprod_approx sprod_map" |
227 |
227 |
228 definition ssum_defl :: "defl \<rightarrow> defl \<rightarrow> defl" |
228 definition ssum_defl :: "udom defl \<rightarrow> udom defl \<rightarrow> udom defl" |
229 where "ssum_defl = defl_fun2 ssum_approx ssum_map" |
229 where "ssum_defl = defl_fun2 ssum_approx ssum_map" |
230 |
230 |
231 lemma cast_u_defl: |
231 lemma cast_u_defl: |
232 "cast\<cdot>(u_defl\<cdot>A) = |
232 "cast\<cdot>(u_defl\<cdot>A) = |
233 udom_emb u_approx oo u_map\<cdot>(cast\<cdot>A) oo udom_prj u_approx" |
233 udom_emb u_approx oo u_map\<cdot>(cast\<cdot>A) oo udom_prj u_approx" |
274 |
274 |
275 text {* Temporarily relax type constraints. *} |
275 text {* Temporarily relax type constraints. *} |
276 |
276 |
277 setup {* |
277 setup {* |
278 fold Sign.add_const_constraint |
278 fold Sign.add_const_constraint |
279 [ (@{const_name defl}, SOME @{typ "'a::pcpo itself \<Rightarrow> defl"}) |
279 [ (@{const_name defl}, SOME @{typ "'a::pcpo itself \<Rightarrow> udom defl"}) |
280 , (@{const_name emb}, SOME @{typ "'a::pcpo \<rightarrow> udom"}) |
280 , (@{const_name emb}, SOME @{typ "'a::pcpo \<rightarrow> udom"}) |
281 , (@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::pcpo"}) |
281 , (@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::pcpo"}) |
282 , (@{const_name liftdefl}, SOME @{typ "'a::pcpo itself \<Rightarrow> defl"}) |
282 , (@{const_name liftdefl}, SOME @{typ "'a::pcpo itself \<Rightarrow> udom defl"}) |
283 , (@{const_name liftemb}, SOME @{typ "'a::pcpo u \<rightarrow> udom"}) |
283 , (@{const_name liftemb}, SOME @{typ "'a::pcpo u \<rightarrow> udom"}) |
284 , (@{const_name liftprj}, SOME @{typ "udom \<rightarrow> 'a::pcpo u"}) ] |
284 , (@{const_name liftprj}, SOME @{typ "udom \<rightarrow> 'a::pcpo u"}) ] |
285 *} |
285 *} |
286 |
286 |
287 default_sort pcpo |
287 default_sort pcpo |
305 |
305 |
306 text {* Restore original type constraints. *} |
306 text {* Restore original type constraints. *} |
307 |
307 |
308 setup {* |
308 setup {* |
309 fold Sign.add_const_constraint |
309 fold Sign.add_const_constraint |
310 [ (@{const_name defl}, SOME @{typ "'a::domain itself \<Rightarrow> defl"}) |
310 [ (@{const_name defl}, SOME @{typ "'a::domain itself \<Rightarrow> udom defl"}) |
311 , (@{const_name emb}, SOME @{typ "'a::domain \<rightarrow> udom"}) |
311 , (@{const_name emb}, SOME @{typ "'a::domain \<rightarrow> udom"}) |
312 , (@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::domain"}) |
312 , (@{const_name prj}, SOME @{typ "udom \<rightarrow> 'a::domain"}) |
313 , (@{const_name liftdefl}, SOME @{typ "'a::predomain itself \<Rightarrow> defl"}) |
313 , (@{const_name liftdefl}, SOME @{typ "'a::predomain itself \<Rightarrow> udom defl"}) |
314 , (@{const_name liftemb}, SOME @{typ "'a::predomain u \<rightarrow> udom"}) |
314 , (@{const_name liftemb}, SOME @{typ "'a::predomain u \<rightarrow> udom"}) |
315 , (@{const_name liftprj}, SOME @{typ "udom \<rightarrow> 'a::predomain u"}) ] |
315 , (@{const_name liftprj}, SOME @{typ "udom \<rightarrow> 'a::predomain u"}) ] |
316 *} |
316 *} |
317 |
317 |
318 subsection {* Class instance proofs *} |
318 subsection {* Class instance proofs *} |