67 apply (subst PDPlus_commute) |
67 apply (subst PDPlus_commute) |
68 apply (simp add: 2) |
68 apply (simp add: 2) |
69 apply (simp add: upper_le_PDPlus_iff 3) |
69 apply (simp add: upper_le_PDPlus_iff 3) |
70 done |
70 done |
71 |
71 |
72 lemma pd_take_upper_chain: |
|
73 "pd_take n t \<le>\<sharp> pd_take (Suc n) t" |
|
74 apply (induct t rule: pd_basis_induct) |
|
75 apply (simp add: compact_basis.take_chain) |
|
76 apply (simp add: PDPlus_upper_mono) |
|
77 done |
|
78 |
|
79 lemma pd_take_upper_le: "pd_take i t \<le>\<sharp> t" |
|
80 apply (induct t rule: pd_basis_induct) |
|
81 apply (simp add: compact_basis.take_less) |
|
82 apply (simp add: PDPlus_upper_mono) |
|
83 done |
|
84 |
|
85 lemma pd_take_upper_mono: |
|
86 "t \<le>\<sharp> u \<Longrightarrow> pd_take n t \<le>\<sharp> pd_take n u" |
|
87 apply (erule upper_le_induct) |
|
88 apply (simp add: compact_basis.take_mono) |
|
89 apply (simp add: upper_le_PDPlus_PDUnit_iff) |
|
90 apply (simp add: upper_le_PDPlus_iff) |
|
91 done |
|
92 |
|
93 |
72 |
94 subsection {* Type definition *} |
73 subsection {* Type definition *} |
95 |
74 |
96 typedef (open) 'a upper_pd = |
75 typedef (open) 'a upper_pd = |
97 "{S::'a pd_basis set. upper_le.ideal S}" |
76 "{S::'a pd_basis set. upper_le.ideal S}" |
98 by (fast intro: upper_le.ideal_principal) |
77 by (fast intro: upper_le.ideal_principal) |
99 |
78 |
100 instantiation upper_pd :: (profinite) below |
79 instantiation upper_pd :: (sfp) below |
101 begin |
80 begin |
102 |
81 |
103 definition |
82 definition |
104 "x \<sqsubseteq> y \<longleftrightarrow> Rep_upper_pd x \<subseteq> Rep_upper_pd y" |
83 "x \<sqsubseteq> y \<longleftrightarrow> Rep_upper_pd x \<subseteq> Rep_upper_pd y" |
105 |
84 |
106 instance .. |
85 instance .. |
107 end |
86 end |
108 |
87 |
109 instance upper_pd :: (profinite) po |
88 instance upper_pd :: (sfp) po |
110 by (rule upper_le.typedef_ideal_po |
89 using type_definition_upper_pd below_upper_pd_def |
111 [OF type_definition_upper_pd below_upper_pd_def]) |
90 by (rule upper_le.typedef_ideal_po) |
112 |
91 |
113 instance upper_pd :: (profinite) cpo |
92 instance upper_pd :: (sfp) cpo |
114 by (rule upper_le.typedef_ideal_cpo |
93 using type_definition_upper_pd below_upper_pd_def |
115 [OF type_definition_upper_pd below_upper_pd_def]) |
94 by (rule upper_le.typedef_ideal_cpo) |
116 |
95 |
117 lemma Rep_upper_pd_lub: |
96 lemma Rep_upper_pd_lub: |
118 "chain Y \<Longrightarrow> Rep_upper_pd (\<Squnion>i. Y i) = (\<Union>i. Rep_upper_pd (Y i))" |
97 "chain Y \<Longrightarrow> Rep_upper_pd (\<Squnion>i. Y i) = (\<Union>i. Rep_upper_pd (Y i))" |
119 by (rule upper_le.typedef_ideal_rep_contlub |
98 using type_definition_upper_pd below_upper_pd_def |
120 [OF type_definition_upper_pd below_upper_pd_def]) |
99 by (rule upper_le.typedef_ideal_rep_contlub) |
121 |
100 |
122 lemma ideal_Rep_upper_pd: "upper_le.ideal (Rep_upper_pd xs)" |
101 lemma ideal_Rep_upper_pd: "upper_le.ideal (Rep_upper_pd xs)" |
123 by (rule Rep_upper_pd [unfolded mem_Collect_eq]) |
102 by (rule Rep_upper_pd [unfolded mem_Collect_eq]) |
124 |
103 |
125 definition |
104 definition |
130 "Rep_upper_pd (upper_principal t) = {u. u \<le>\<sharp> t}" |
109 "Rep_upper_pd (upper_principal t) = {u. u \<le>\<sharp> t}" |
131 unfolding upper_principal_def |
110 unfolding upper_principal_def |
132 by (simp add: Abs_upper_pd_inverse upper_le.ideal_principal) |
111 by (simp add: Abs_upper_pd_inverse upper_le.ideal_principal) |
133 |
112 |
134 interpretation upper_pd: |
113 interpretation upper_pd: |
135 ideal_completion upper_le pd_take upper_principal Rep_upper_pd |
114 ideal_completion upper_le upper_principal Rep_upper_pd |
136 apply unfold_locales |
115 apply unfold_locales |
137 apply (rule pd_take_upper_le) |
|
138 apply (rule pd_take_idem) |
|
139 apply (erule pd_take_upper_mono) |
|
140 apply (rule pd_take_upper_chain) |
|
141 apply (rule finite_range_pd_take) |
|
142 apply (rule pd_take_covers) |
|
143 apply (rule ideal_Rep_upper_pd) |
116 apply (rule ideal_Rep_upper_pd) |
144 apply (erule Rep_upper_pd_lub) |
117 apply (erule Rep_upper_pd_lub) |
145 apply (rule Rep_upper_principal) |
118 apply (rule Rep_upper_principal) |
146 apply (simp only: below_upper_pd_def) |
119 apply (simp only: below_upper_pd_def) |
|
120 apply (rule pd_basis_countable) |
147 done |
121 done |
148 |
122 |
149 text {* Upper powerdomain is pointed *} |
123 text {* Upper powerdomain is pointed *} |
150 |
124 |
151 lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) \<sqsubseteq> ys" |
125 lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) \<sqsubseteq> ys" |
152 by (induct ys rule: upper_pd.principal_induct, simp, simp) |
126 by (induct ys rule: upper_pd.principal_induct, simp, simp) |
153 |
127 |
154 instance upper_pd :: (bifinite) pcpo |
128 instance upper_pd :: (sfp) pcpo |
155 by intro_classes (fast intro: upper_pd_minimal) |
129 by intro_classes (fast intro: upper_pd_minimal) |
156 |
130 |
157 lemma inst_upper_pd_pcpo: "\<bottom> = upper_principal (PDUnit compact_bot)" |
131 lemma inst_upper_pd_pcpo: "\<bottom> = upper_principal (PDUnit compact_bot)" |
158 by (rule upper_pd_minimal [THEN UU_I, symmetric]) |
132 by (rule upper_pd_minimal [THEN UU_I, symmetric]) |
159 |
|
160 text {* Upper powerdomain is profinite *} |
|
161 |
|
162 instantiation upper_pd :: (profinite) profinite |
|
163 begin |
|
164 |
|
165 definition |
|
166 approx_upper_pd_def: "approx = upper_pd.completion_approx" |
|
167 |
|
168 instance |
|
169 apply (intro_classes, unfold approx_upper_pd_def) |
|
170 apply (rule upper_pd.chain_completion_approx) |
|
171 apply (rule upper_pd.lub_completion_approx) |
|
172 apply (rule upper_pd.completion_approx_idem) |
|
173 apply (rule upper_pd.finite_fixes_completion_approx) |
|
174 done |
|
175 |
|
176 end |
|
177 |
|
178 instance upper_pd :: (bifinite) bifinite .. |
|
179 |
|
180 lemma approx_upper_principal [simp]: |
|
181 "approx n\<cdot>(upper_principal t) = upper_principal (pd_take n t)" |
|
182 unfolding approx_upper_pd_def |
|
183 by (rule upper_pd.completion_approx_principal) |
|
184 |
|
185 lemma approx_eq_upper_principal: |
|
186 "\<exists>t\<in>Rep_upper_pd xs. approx n\<cdot>xs = upper_principal (pd_take n t)" |
|
187 unfolding approx_upper_pd_def |
|
188 by (rule upper_pd.completion_approx_eq_principal) |
|
189 |
133 |
190 |
134 |
191 subsection {* Monadic unit and plus *} |
135 subsection {* Monadic unit and plus *} |
192 |
136 |
193 definition |
137 definition |
219 lemma upper_plus_principal [simp]: |
163 lemma upper_plus_principal [simp]: |
220 "upper_principal t +\<sharp> upper_principal u = upper_principal (PDPlus t u)" |
164 "upper_principal t +\<sharp> upper_principal u = upper_principal (PDPlus t u)" |
221 unfolding upper_plus_def |
165 unfolding upper_plus_def |
222 by (simp add: upper_pd.basis_fun_principal |
166 by (simp add: upper_pd.basis_fun_principal |
223 upper_pd.basis_fun_mono PDPlus_upper_mono) |
167 upper_pd.basis_fun_mono PDPlus_upper_mono) |
224 |
|
225 lemma approx_upper_unit [simp]: |
|
226 "approx n\<cdot>{x}\<sharp> = {approx n\<cdot>x}\<sharp>" |
|
227 apply (induct x rule: compact_basis.principal_induct, simp) |
|
228 apply (simp add: approx_Rep_compact_basis) |
|
229 done |
|
230 |
|
231 lemma approx_upper_plus [simp]: |
|
232 "approx n\<cdot>(xs +\<sharp> ys) = (approx n\<cdot>xs) +\<sharp> (approx n\<cdot>ys)" |
|
233 by (induct xs ys rule: upper_pd.principal_induct2, simp, simp, simp) |
|
234 |
168 |
235 interpretation upper_add: semilattice upper_add proof |
169 interpretation upper_add: semilattice upper_add proof |
236 fix xs ys zs :: "'a upper_pd" |
170 fix xs ys zs :: "'a upper_pd" |
237 show "(xs +\<sharp> ys) +\<sharp> zs = xs +\<sharp> (ys +\<sharp> zs)" |
171 show "(xs +\<sharp> ys) +\<sharp> zs = xs +\<sharp> (ys +\<sharp> zs)" |
238 apply (induct xs ys arbitrary: zs rule: upper_pd.principal_induct2, simp, simp) |
172 apply (induct xs ys arbitrary: zs rule: upper_pd.principal_induct2, simp, simp) |
422 |
363 |
423 lemma upper_bind_strict [simp]: "upper_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>" |
364 lemma upper_bind_strict [simp]: "upper_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>" |
424 unfolding upper_unit_strict [symmetric] by (rule upper_bind_unit) |
365 unfolding upper_unit_strict [symmetric] by (rule upper_bind_unit) |
425 |
366 |
426 |
367 |
427 subsection {* Map and join *} |
368 subsection {* Map *} |
428 |
369 |
429 definition |
370 definition |
430 upper_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a upper_pd \<rightarrow> 'b upper_pd" where |
371 upper_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a upper_pd \<rightarrow> 'b upper_pd" where |
431 "upper_map = (\<Lambda> f xs. upper_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<sharp>))" |
372 "upper_map = (\<Lambda> f xs. upper_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<sharp>))" |
432 |
|
433 definition |
|
434 upper_join :: "'a upper_pd upper_pd \<rightarrow> 'a upper_pd" where |
|
435 "upper_join = (\<Lambda> xss. upper_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))" |
|
436 |
373 |
437 lemma upper_map_unit [simp]: |
374 lemma upper_map_unit [simp]: |
438 "upper_map\<cdot>f\<cdot>{x}\<sharp> = {f\<cdot>x}\<sharp>" |
375 "upper_map\<cdot>f\<cdot>{x}\<sharp> = {f\<cdot>x}\<sharp>" |
439 unfolding upper_map_def by simp |
376 unfolding upper_map_def by simp |
440 |
377 |
441 lemma upper_map_plus [simp]: |
378 lemma upper_map_plus [simp]: |
442 "upper_map\<cdot>f\<cdot>(xs +\<sharp> ys) = upper_map\<cdot>f\<cdot>xs +\<sharp> upper_map\<cdot>f\<cdot>ys" |
379 "upper_map\<cdot>f\<cdot>(xs +\<sharp> ys) = upper_map\<cdot>f\<cdot>xs +\<sharp> upper_map\<cdot>f\<cdot>ys" |
443 unfolding upper_map_def by simp |
380 unfolding upper_map_def by simp |
444 |
381 |
445 lemma upper_join_unit [simp]: |
|
446 "upper_join\<cdot>{xs}\<sharp> = xs" |
|
447 unfolding upper_join_def by simp |
|
448 |
|
449 lemma upper_join_plus [simp]: |
|
450 "upper_join\<cdot>(xss +\<sharp> yss) = upper_join\<cdot>xss +\<sharp> upper_join\<cdot>yss" |
|
451 unfolding upper_join_def by simp |
|
452 |
|
453 lemma upper_map_ident: "upper_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs" |
382 lemma upper_map_ident: "upper_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs" |
454 by (induct xs rule: upper_pd_induct, simp_all) |
383 by (induct xs rule: upper_pd_induct, simp_all) |
455 |
384 |
456 lemma upper_map_ID: "upper_map\<cdot>ID = ID" |
385 lemma upper_map_ID: "upper_map\<cdot>ID = ID" |
457 by (simp add: expand_cfun_eq ID_def upper_map_ident) |
386 by (simp add: expand_cfun_eq ID_def upper_map_ident) |
458 |
387 |
459 lemma upper_map_map: |
388 lemma upper_map_map: |
460 "upper_map\<cdot>f\<cdot>(upper_map\<cdot>g\<cdot>xs) = upper_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs" |
389 "upper_map\<cdot>f\<cdot>(upper_map\<cdot>g\<cdot>xs) = upper_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs" |
461 by (induct xs rule: upper_pd_induct, simp_all) |
|
462 |
|
463 lemma upper_join_map_unit: |
|
464 "upper_join\<cdot>(upper_map\<cdot>upper_unit\<cdot>xs) = xs" |
|
465 by (induct xs rule: upper_pd_induct, simp_all) |
|
466 |
|
467 lemma upper_join_map_join: |
|
468 "upper_join\<cdot>(upper_map\<cdot>upper_join\<cdot>xsss) = upper_join\<cdot>(upper_join\<cdot>xsss)" |
|
469 by (induct xsss rule: upper_pd_induct, simp_all) |
|
470 |
|
471 lemma upper_join_map_map: |
|
472 "upper_join\<cdot>(upper_map\<cdot>(upper_map\<cdot>f)\<cdot>xss) = |
|
473 upper_map\<cdot>f\<cdot>(upper_join\<cdot>xss)" |
|
474 by (induct xss rule: upper_pd_induct, simp_all) |
|
475 |
|
476 lemma upper_map_approx: "upper_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs" |
|
477 by (induct xs rule: upper_pd_induct, simp_all) |
390 by (induct xs rule: upper_pd_induct, simp_all) |
478 |
391 |
479 lemma ep_pair_upper_map: "ep_pair e p \<Longrightarrow> ep_pair (upper_map\<cdot>e) (upper_map\<cdot>p)" |
392 lemma ep_pair_upper_map: "ep_pair e p \<Longrightarrow> ep_pair (upper_map\<cdot>e) (upper_map\<cdot>p)" |
480 apply default |
393 apply default |
481 apply (induct_tac x rule: upper_pd_induct, simp_all add: ep_pair.e_inverse) |
394 apply (induct_tac x rule: upper_pd_induct, simp_all add: ep_pair.e_inverse) |
488 apply (induct_tac x rule: upper_pd_induct, simp_all add: deflation.idem) |
401 apply (induct_tac x rule: upper_pd_induct, simp_all add: deflation.idem) |
489 apply (induct_tac x rule: upper_pd_induct) |
402 apply (induct_tac x rule: upper_pd_induct) |
490 apply (simp_all add: deflation.below monofun_cfun) |
403 apply (simp_all add: deflation.below monofun_cfun) |
491 done |
404 done |
492 |
405 |
|
406 (* FIXME: long proof! *) |
|
407 lemma finite_deflation_upper_map: |
|
408 assumes "finite_deflation d" shows "finite_deflation (upper_map\<cdot>d)" |
|
409 proof (rule finite_deflation_intro) |
|
410 interpret d: finite_deflation d by fact |
|
411 have "deflation d" by fact |
|
412 thus "deflation (upper_map\<cdot>d)" by (rule deflation_upper_map) |
|
413 have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range) |
|
414 hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))" |
|
415 by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject) |
|
416 hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp |
|
417 hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" |
|
418 by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject) |
|
419 hence *: "finite (upper_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp |
|
420 hence "finite (range (\<lambda>xs. upper_map\<cdot>d\<cdot>xs))" |
|
421 apply (rule rev_finite_subset) |
|
422 apply clarsimp |
|
423 apply (induct_tac xs rule: upper_pd.principal_induct) |
|
424 apply (simp add: adm_mem_finite *) |
|
425 apply (rename_tac t, induct_tac t rule: pd_basis_induct) |
|
426 apply (simp only: upper_unit_Rep_compact_basis [symmetric] upper_map_unit) |
|
427 apply simp |
|
428 apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b") |
|
429 apply clarsimp |
|
430 apply (rule imageI) |
|
431 apply (rule vimageI2) |
|
432 apply (simp add: Rep_PDUnit) |
|
433 apply (rule range_eqI) |
|
434 apply (erule sym) |
|
435 apply (rule exI) |
|
436 apply (rule Abs_compact_basis_inverse [symmetric]) |
|
437 apply (simp add: d.compact) |
|
438 apply (simp only: upper_plus_principal [symmetric] upper_map_plus) |
|
439 apply clarsimp |
|
440 apply (rule imageI) |
|
441 apply (rule vimageI2) |
|
442 apply (simp add: Rep_PDPlus) |
|
443 done |
|
444 thus "finite {xs. upper_map\<cdot>d\<cdot>xs = xs}" |
|
445 by (rule finite_range_imp_finite_fixes) |
|
446 qed |
|
447 |
|
448 subsection {* Upper powerdomain is an SFP domain *} |
|
449 |
|
450 definition |
|
451 upper_approx :: "nat \<Rightarrow> udom upper_pd \<rightarrow> udom upper_pd" |
|
452 where |
|
453 "upper_approx = (\<lambda>i. upper_map\<cdot>(udom_approx i))" |
|
454 |
|
455 lemma upper_approx: "approx_chain upper_approx" |
|
456 proof (rule approx_chain.intro) |
|
457 show "chain (\<lambda>i. upper_approx i)" |
|
458 unfolding upper_approx_def by simp |
|
459 show "(\<Squnion>i. upper_approx i) = ID" |
|
460 unfolding upper_approx_def |
|
461 by (simp add: lub_distribs upper_map_ID) |
|
462 show "\<And>i. finite_deflation (upper_approx i)" |
|
463 unfolding upper_approx_def |
|
464 by (intro finite_deflation_upper_map finite_deflation_udom_approx) |
|
465 qed |
|
466 |
|
467 definition upper_sfp :: "sfp \<rightarrow> sfp" |
|
468 where "upper_sfp = sfp_fun1 upper_approx upper_map" |
|
469 |
|
470 lemma cast_upper_sfp: |
|
471 "cast\<cdot>(upper_sfp\<cdot>A) = |
|
472 udom_emb upper_approx oo upper_map\<cdot>(cast\<cdot>A) oo udom_prj upper_approx" |
|
473 unfolding upper_sfp_def |
|
474 apply (rule cast_sfp_fun1 [OF upper_approx]) |
|
475 apply (erule finite_deflation_upper_map) |
|
476 done |
|
477 |
|
478 instantiation upper_pd :: (sfp) sfp |
|
479 begin |
|
480 |
|
481 definition |
|
482 "emb = udom_emb upper_approx oo upper_map\<cdot>emb" |
|
483 |
|
484 definition |
|
485 "prj = upper_map\<cdot>prj oo udom_prj upper_approx" |
|
486 |
|
487 definition |
|
488 "sfp (t::'a upper_pd itself) = upper_sfp\<cdot>SFP('a)" |
|
489 |
|
490 instance proof |
|
491 show "ep_pair emb (prj :: udom \<rightarrow> 'a upper_pd)" |
|
492 unfolding emb_upper_pd_def prj_upper_pd_def |
|
493 using ep_pair_udom [OF upper_approx] |
|
494 by (intro ep_pair_comp ep_pair_upper_map ep_pair_emb_prj) |
|
495 next |
|
496 show "cast\<cdot>SFP('a upper_pd) = emb oo (prj :: udom \<rightarrow> 'a upper_pd)" |
|
497 unfolding emb_upper_pd_def prj_upper_pd_def sfp_upper_pd_def cast_upper_sfp |
|
498 by (simp add: cast_SFP oo_def expand_cfun_eq upper_map_map) |
|
499 qed |
|
500 |
493 end |
501 end |
|
502 |
|
503 text {* SFP of type constructor = type combinator *} |
|
504 |
|
505 lemma SFP_upper: "SFP('a upper_pd) = upper_sfp\<cdot>SFP('a)" |
|
506 by (rule sfp_upper_pd_def) |
|
507 |
|
508 |
|
509 subsection {* Join *} |
|
510 |
|
511 definition |
|
512 upper_join :: "'a upper_pd upper_pd \<rightarrow> 'a upper_pd" where |
|
513 "upper_join = (\<Lambda> xss. upper_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))" |
|
514 |
|
515 lemma upper_join_unit [simp]: |
|
516 "upper_join\<cdot>{xs}\<sharp> = xs" |
|
517 unfolding upper_join_def by simp |
|
518 |
|
519 lemma upper_join_plus [simp]: |
|
520 "upper_join\<cdot>(xss +\<sharp> yss) = upper_join\<cdot>xss +\<sharp> upper_join\<cdot>yss" |
|
521 unfolding upper_join_def by simp |
|
522 |
|
523 lemma upper_join_map_unit: |
|
524 "upper_join\<cdot>(upper_map\<cdot>upper_unit\<cdot>xs) = xs" |
|
525 by (induct xs rule: upper_pd_induct, simp_all) |
|
526 |
|
527 lemma upper_join_map_join: |
|
528 "upper_join\<cdot>(upper_map\<cdot>upper_join\<cdot>xsss) = upper_join\<cdot>(upper_join\<cdot>xsss)" |
|
529 by (induct xsss rule: upper_pd_induct, simp_all) |
|
530 |
|
531 lemma upper_join_map_map: |
|
532 "upper_join\<cdot>(upper_map\<cdot>(upper_map\<cdot>f)\<cdot>xss) = |
|
533 upper_map\<cdot>f\<cdot>(upper_join\<cdot>xss)" |
|
534 by (induct xss rule: upper_pd_induct, simp_all) |
|
535 |
|
536 end |