46 lemmas emb_prj_below = domain.e_p_below |
46 lemmas emb_prj_below = domain.e_p_below |
47 lemmas emb_eq_iff = domain.e_eq_iff |
47 lemmas emb_eq_iff = domain.e_eq_iff |
48 lemmas emb_strict = domain.e_strict |
48 lemmas emb_strict = domain.e_strict |
49 lemmas prj_strict = domain.p_strict |
49 lemmas prj_strict = domain.p_strict |
50 |
50 |
51 subsection {* Domains have a countable compact basis *} |
51 subsection {* Domains are bifinite *} |
52 |
52 |
53 text {* |
53 lemma approx_chain_ep_cast: |
54 Eventually it should be possible to generalize this to an unpointed |
54 assumes ep: "ep_pair (e::'a \<rightarrow> udom) (p::udom \<rightarrow> 'a)" |
55 variant of the domain class. |
55 assumes cast_t: "cast\<cdot>t = e oo p" |
56 *} |
56 shows "\<exists>(a::nat \<Rightarrow> 'a \<rightarrow> 'a). approx_chain a" |
57 |
|
58 interpretation compact_basis: |
|
59 ideal_completion below Rep_compact_basis "approximants::'a::domain \<Rightarrow> _" |
|
60 proof - |
57 proof - |
|
58 interpret ep_pair e p by fact |
61 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)" |
62 and DEFL: "DEFL('a) = (\<Squnion>i. defl_principal (Y i))" |
60 and t: "t = (\<Squnion>i. defl_principal (Y i))" |
63 by (rule defl.obtain_principal_chain) |
61 by (rule defl.obtain_principal_chain) |
64 def approx \<equiv> "\<lambda>i. (prj oo cast\<cdot>(defl_principal (Y i)) oo emb) :: 'a \<rightarrow> 'a" |
62 def approx \<equiv> "\<lambda>i. (p oo cast\<cdot>(defl_principal (Y i)) oo e) :: 'a \<rightarrow> 'a" |
65 interpret defl_approx: approx_chain approx |
63 have "approx_chain approx" |
66 proof (rule approx_chain.intro) |
64 proof (rule approx_chain.intro) |
67 show "chain (\<lambda>i. approx i)" |
65 show "chain (\<lambda>i. approx i)" |
68 unfolding approx_def by (simp add: Y) |
66 unfolding approx_def by (simp add: Y) |
69 show "(\<Squnion>i. approx i) = ID" |
67 show "(\<Squnion>i. approx i) = ID" |
70 unfolding approx_def |
68 unfolding approx_def |
71 by (simp add: lub_distribs Y DEFL [symmetric] cast_DEFL cfun_eq_iff) |
69 by (simp add: lub_distribs Y t [symmetric] cast_t cfun_eq_iff) |
72 show "\<And>i. finite_deflation (approx i)" |
70 show "\<And>i. finite_deflation (approx i)" |
73 unfolding approx_def |
71 unfolding approx_def |
74 apply (rule domain.finite_deflation_p_d_e) |
72 apply (rule finite_deflation_p_d_e) |
75 apply (rule finite_deflation_cast) |
73 apply (rule finite_deflation_cast) |
76 apply (rule defl.compact_principal) |
74 apply (rule defl.compact_principal) |
77 apply (rule below_trans [OF monofun_cfun_fun]) |
75 apply (rule below_trans [OF monofun_cfun_fun]) |
78 apply (rule is_ub_thelub, simp add: Y) |
76 apply (rule is_ub_thelub, simp add: Y) |
79 apply (simp add: lub_distribs Y DEFL [symmetric] cast_DEFL) |
77 apply (simp add: lub_distribs Y t [symmetric] cast_t) |
80 done |
78 done |
81 qed |
79 qed |
82 (* FIXME: why does show ?thesis fail here? *) |
80 thus "\<exists>(a::nat \<Rightarrow> 'a \<rightarrow> 'a). approx_chain a" by - (rule exI) |
83 show "ideal_completion below Rep_compact_basis (approximants::'a \<Rightarrow> _)" .. |
81 qed |
84 qed |
82 |
|
83 instance "domain" \<subseteq> bifinite |
|
84 by default (rule approx_chain_ep_cast [OF ep_pair_emb_prj cast_DEFL]) |
|
85 |
|
86 instance predomain \<subseteq> profinite |
|
87 by default (rule approx_chain_ep_cast [OF predomain_ep cast_liftdefl]) |
85 |
88 |
86 subsection {* Chains of approx functions *} |
89 subsection {* Chains of approx functions *} |
87 |
90 |
88 definition u_approx :: "nat \<Rightarrow> udom\<^sub>\<bottom> \<rightarrow> udom\<^sub>\<bottom>" |
91 definition u_approx :: "nat \<Rightarrow> udom\<^sub>\<bottom> \<rightarrow> udom\<^sub>\<bottom>" |
89 where "u_approx = (\<lambda>i. u_map\<cdot>(udom_approx i))" |
92 where "u_approx = (\<lambda>i. u_map\<cdot>(udom_approx i))" |
164 shows "cast\<cdot>(defl_fun1 approx f\<cdot>A) = udom_emb approx oo f\<cdot>(cast\<cdot>A) oo udom_prj approx" |
169 shows "cast\<cdot>(defl_fun1 approx f\<cdot>A) = udom_emb approx oo f\<cdot>(cast\<cdot>A) oo udom_prj approx" |
165 proof - |
170 proof - |
166 have 1: "\<And>a. finite_deflation |
171 have 1: "\<And>a. finite_deflation |
167 (udom_emb approx oo f\<cdot>(Rep_fin_defl a) oo udom_prj approx)" |
172 (udom_emb approx oo f\<cdot>(Rep_fin_defl a) oo udom_prj approx)" |
168 apply (rule ep_pair.finite_deflation_e_d_p) |
173 apply (rule ep_pair.finite_deflation_e_d_p) |
169 apply (rule approx_chain.ep_pair_udom [OF approx]) |
174 apply (rule ep_pair_udom [OF approx]) |
170 apply (rule f, rule finite_deflation_Rep_fin_defl) |
175 apply (rule f, rule finite_deflation_Rep_fin_defl) |
171 done |
176 done |
172 show ?thesis |
177 show ?thesis |
173 by (induct A rule: defl.principal_induct, simp) |
178 by (induct A rule: defl.principal_induct, simp) |
174 (simp only: defl_fun1_def |
179 (simp only: defl_fun1_def |
277 , (@{const_name liftdefl}, SOME @{typ "'a::pcpo itself \<Rightarrow> defl"}) |
282 , (@{const_name liftdefl}, SOME @{typ "'a::pcpo itself \<Rightarrow> defl"}) |
278 , (@{const_name liftemb}, SOME @{typ "'a::pcpo u \<rightarrow> udom"}) |
283 , (@{const_name liftemb}, SOME @{typ "'a::pcpo u \<rightarrow> udom"}) |
279 , (@{const_name liftprj}, SOME @{typ "udom \<rightarrow> 'a::pcpo u"}) ] |
284 , (@{const_name liftprj}, SOME @{typ "udom \<rightarrow> 'a::pcpo u"}) ] |
280 *} |
285 *} |
281 |
286 |
|
287 default_sort pcpo |
|
288 |
282 lemma liftdomain_class_intro: |
289 lemma liftdomain_class_intro: |
283 assumes liftemb: "(liftemb :: 'a u \<rightarrow> udom) = udom_emb u_approx oo u_map\<cdot>emb" |
290 assumes liftemb: "(liftemb :: 'a u \<rightarrow> udom) = udom_emb u_approx oo u_map\<cdot>emb" |
284 assumes liftprj: "(liftprj :: udom \<rightarrow> 'a u) = u_map\<cdot>prj oo udom_prj u_approx" |
291 assumes liftprj: "(liftprj :: udom \<rightarrow> 'a u) = u_map\<cdot>prj oo udom_prj u_approx" |
285 assumes liftdefl: "liftdefl TYPE('a) = u_defl\<cdot>DEFL('a)" |
292 assumes liftdefl: "liftdefl TYPE('a) = u_defl\<cdot>DEFL('a)" |
286 assumes ep_pair: "ep_pair emb (prj :: udom \<rightarrow> 'a)" |
293 assumes ep_pair: "ep_pair emb (prj :: udom \<rightarrow> 'a)" |
434 "DEFL('a::domain \<rightarrow>! 'b::domain) = sfun_defl\<cdot>DEFL('a)\<cdot>DEFL('b)" |
441 "DEFL('a::domain \<rightarrow>! 'b::domain) = sfun_defl\<cdot>DEFL('a)\<cdot>DEFL('b)" |
435 by (rule defl_sfun_def) |
442 by (rule defl_sfun_def) |
436 |
443 |
437 subsubsection {* Continuous function space *} |
444 subsubsection {* Continuous function space *} |
438 |
445 |
439 text {* |
|
440 Types @{typ "'a \<rightarrow> 'b"} and @{typ "'a u \<rightarrow>! 'b"} are isomorphic. |
|
441 *} |
|
442 |
|
443 definition |
|
444 "encode_cfun = (\<Lambda> f. sfun_abs\<cdot>(fup\<cdot>f))" |
|
445 |
|
446 definition |
|
447 "decode_cfun = (\<Lambda> g x. sfun_rep\<cdot>g\<cdot>(up\<cdot>x))" |
|
448 |
|
449 lemma decode_encode_cfun [simp]: "decode_cfun\<cdot>(encode_cfun\<cdot>x) = x" |
|
450 unfolding encode_cfun_def decode_cfun_def |
|
451 by (simp add: eta_cfun) |
|
452 |
|
453 lemma encode_decode_cfun [simp]: "encode_cfun\<cdot>(decode_cfun\<cdot>y) = y" |
|
454 unfolding encode_cfun_def decode_cfun_def |
|
455 apply (simp add: sfun_eq_iff strictify_cancel) |
|
456 apply (rule cfun_eqI, case_tac x, simp_all) |
|
457 done |
|
458 |
|
459 instantiation cfun :: (predomain, "domain") liftdomain |
446 instantiation cfun :: (predomain, "domain") liftdomain |
460 begin |
447 begin |
461 |
448 |
462 definition |
449 definition |
463 "emb = emb oo encode_cfun" |
450 "emb = emb oo encode_cfun" |
538 "DEFL('a::domain \<otimes> 'b::domain) = sprod_defl\<cdot>DEFL('a)\<cdot>DEFL('b)" |
525 "DEFL('a::domain \<otimes> 'b::domain) = sprod_defl\<cdot>DEFL('a)\<cdot>DEFL('b)" |
539 by (rule defl_sprod_def) |
526 by (rule defl_sprod_def) |
540 |
527 |
541 subsubsection {* Cartesian product *} |
528 subsubsection {* Cartesian product *} |
542 |
529 |
543 text {* |
|
544 Types @{typ "('a * 'b) u"} and @{typ "'a u \<otimes> 'b u"} are isomorphic. |
|
545 *} |
|
546 |
|
547 definition |
|
548 "encode_prod_u = (\<Lambda>(up\<cdot>(x, y)). (:up\<cdot>x, up\<cdot>y:))" |
|
549 |
|
550 definition |
|
551 "decode_prod_u = (\<Lambda>(:up\<cdot>x, up\<cdot>y:). up\<cdot>(x, y))" |
|
552 |
|
553 lemma decode_encode_prod_u [simp]: "decode_prod_u\<cdot>(encode_prod_u\<cdot>x) = x" |
|
554 unfolding encode_prod_u_def decode_prod_u_def |
|
555 by (case_tac x, simp, rename_tac y, case_tac y, simp) |
|
556 |
|
557 lemma encode_decode_prod_u [simp]: "encode_prod_u\<cdot>(decode_prod_u\<cdot>y) = y" |
|
558 unfolding encode_prod_u_def decode_prod_u_def |
|
559 apply (case_tac y, simp, rename_tac a b) |
|
560 apply (case_tac a, simp, case_tac b, simp, simp) |
|
561 done |
|
562 |
|
563 instantiation prod :: (predomain, predomain) predomain |
530 instantiation prod :: (predomain, predomain) predomain |
564 begin |
531 begin |
565 |
532 |
566 definition |
533 definition |
567 "liftemb = emb oo encode_prod_u" |
534 "liftemb = emb oo encode_prod_u" |
654 |
621 |
655 end |
622 end |
656 |
623 |
657 subsubsection {* Discrete cpo *} |
624 subsubsection {* Discrete cpo *} |
658 |
625 |
659 definition discr_approx :: "nat \<Rightarrow> 'a::countable discr u \<rightarrow> 'a discr u" |
|
660 where "discr_approx = (\<lambda>i. \<Lambda>(up\<cdot>x). if to_nat (undiscr x) < i then up\<cdot>x else \<bottom>)" |
|
661 |
|
662 lemma chain_discr_approx [simp]: "chain discr_approx" |
|
663 unfolding discr_approx_def |
|
664 by (rule chainI, simp add: monofun_cfun monofun_LAM) |
|
665 |
|
666 lemma lub_discr_approx [simp]: "(\<Squnion>i. discr_approx i) = ID" |
|
667 apply (rule cfun_eqI) |
|
668 apply (simp add: contlub_cfun_fun) |
|
669 apply (simp add: discr_approx_def) |
|
670 apply (case_tac x, simp) |
|
671 apply (rule lub_eqI) |
|
672 apply (rule is_lubI) |
|
673 apply (rule ub_rangeI, simp) |
|
674 apply (drule ub_rangeD) |
|
675 apply (erule rev_below_trans) |
|
676 apply simp |
|
677 apply (rule lessI) |
|
678 done |
|
679 |
|
680 lemma inj_on_undiscr [simp]: "inj_on undiscr A" |
|
681 using Discr_undiscr by (rule inj_on_inverseI) |
|
682 |
|
683 lemma finite_deflation_discr_approx: "finite_deflation (discr_approx i)" |
|
684 proof |
|
685 fix x :: "'a discr u" |
|
686 show "discr_approx i\<cdot>x \<sqsubseteq> x" |
|
687 unfolding discr_approx_def |
|
688 by (cases x, simp, simp) |
|
689 show "discr_approx i\<cdot>(discr_approx i\<cdot>x) = discr_approx i\<cdot>x" |
|
690 unfolding discr_approx_def |
|
691 by (cases x, simp, simp) |
|
692 show "finite {x::'a discr u. discr_approx i\<cdot>x = x}" |
|
693 proof (rule finite_subset) |
|
694 let ?S = "insert (\<bottom>::'a discr u) ((\<lambda>x. up\<cdot>x) ` undiscr -` to_nat -` {..<i})" |
|
695 show "{x::'a discr u. discr_approx i\<cdot>x = x} \<subseteq> ?S" |
|
696 unfolding discr_approx_def |
|
697 by (rule subsetI, case_tac x, simp, simp split: split_if_asm) |
|
698 show "finite ?S" |
|
699 by (simp add: finite_vimageI) |
|
700 qed |
|
701 qed |
|
702 |
|
703 lemma discr_approx: "approx_chain discr_approx" |
|
704 using chain_discr_approx lub_discr_approx finite_deflation_discr_approx |
|
705 by (rule approx_chain.intro) |
|
706 |
|
707 instantiation discr :: (countable) predomain |
626 instantiation discr :: (countable) predomain |
708 begin |
627 begin |
709 |
628 |
710 definition |
629 definition |
711 "liftemb = udom_emb discr_approx" |
630 "(liftemb :: 'a discr u \<rightarrow> udom) = udom_emb discr_approx" |
712 |
631 |
713 definition |
632 definition |
714 "liftprj = udom_prj discr_approx" |
633 "(liftprj :: udom \<rightarrow> 'a discr u) = udom_prj discr_approx" |
715 |
634 |
716 definition |
635 definition |
717 "liftdefl (t::'a discr itself) = |
636 "liftdefl (t::'a discr itself) = |
718 (\<Squnion>i. defl_principal (Abs_fin_defl (liftemb oo discr_approx i oo liftprj)))" |
637 (\<Squnion>i. defl_principal (Abs_fin_defl (liftemb oo discr_approx i oo (liftprj::udom \<rightarrow> 'a discr u))))" |
719 |
638 |
720 instance proof |
639 instance proof |
721 show "ep_pair liftemb (liftprj :: udom \<rightarrow> 'a discr u)" |
640 show "ep_pair liftemb (liftprj :: udom \<rightarrow> 'a discr u)" |
722 unfolding liftemb_discr_def liftprj_discr_def |
641 unfolding liftemb_discr_def liftprj_discr_def |
723 by (rule ep_pair_udom [OF discr_approx]) |
642 by (rule ep_pair_udom [OF discr_approx]) |