293 by (rule subsetI, case_tac x, simp_all) |
293 by (rule subsetI, case_tac x, simp_all) |
294 thus "finite {x. ssum_map\<cdot>d1\<cdot>d2\<cdot>x = x}" |
294 thus "finite {x. ssum_map\<cdot>d1\<cdot>d2\<cdot>x = x}" |
295 by (rule finite_subset, simp add: d1.finite_fixes d2.finite_fixes) |
295 by (rule finite_subset, simp add: d1.finite_fixes d2.finite_fixes) |
296 qed |
296 qed |
297 |
297 |
298 subsection {* Strict sum is a bifinite domain *} |
298 subsection {* Strict sum is an SFP domain *} |
299 |
299 |
300 instantiation ssum :: (bifinite, bifinite) bifinite |
300 definition |
|
301 ssum_approx :: "nat \<Rightarrow> udom \<oplus> udom \<rightarrow> udom \<oplus> udom" |
|
302 where |
|
303 "ssum_approx = (\<lambda>i. ssum_map\<cdot>(udom_approx i)\<cdot>(udom_approx i))" |
|
304 |
|
305 lemma ssum_approx: "approx_chain ssum_approx" |
|
306 proof (rule approx_chain.intro) |
|
307 show "chain (\<lambda>i. ssum_approx i)" |
|
308 unfolding ssum_approx_def by simp |
|
309 show "(\<Squnion>i. ssum_approx i) = ID" |
|
310 unfolding ssum_approx_def |
|
311 by (simp add: lub_distribs ssum_map_ID) |
|
312 show "\<And>i. finite_deflation (ssum_approx i)" |
|
313 unfolding ssum_approx_def |
|
314 by (intro finite_deflation_ssum_map finite_deflation_udom_approx) |
|
315 qed |
|
316 |
|
317 definition ssum_sfp :: "sfp \<rightarrow> sfp \<rightarrow> sfp" |
|
318 where "ssum_sfp = sfp_fun2 ssum_approx ssum_map" |
|
319 |
|
320 lemma cast_ssum_sfp: |
|
321 "cast\<cdot>(ssum_sfp\<cdot>A\<cdot>B) = |
|
322 udom_emb ssum_approx oo ssum_map\<cdot>(cast\<cdot>A)\<cdot>(cast\<cdot>B) oo udom_prj ssum_approx" |
|
323 unfolding ssum_sfp_def |
|
324 apply (rule cast_sfp_fun2 [OF ssum_approx]) |
|
325 apply (erule (1) finite_deflation_ssum_map) |
|
326 done |
|
327 |
|
328 instantiation ssum :: (sfp, sfp) sfp |
301 begin |
329 begin |
302 |
330 |
303 definition |
331 definition |
304 approx_ssum_def: |
332 "emb = udom_emb ssum_approx oo ssum_map\<cdot>emb\<cdot>emb" |
305 "approx = (\<lambda>n. ssum_map\<cdot>(approx n)\<cdot>(approx n))" |
333 |
306 |
334 definition |
307 lemma approx_sinl [simp]: "approx i\<cdot>(sinl\<cdot>x) = sinl\<cdot>(approx i\<cdot>x)" |
335 "prj = ssum_map\<cdot>prj\<cdot>prj oo udom_prj ssum_approx" |
308 unfolding approx_ssum_def by (cases "x = \<bottom>") simp_all |
336 |
309 |
337 definition |
310 lemma approx_sinr [simp]: "approx i\<cdot>(sinr\<cdot>x) = sinr\<cdot>(approx i\<cdot>x)" |
338 "sfp (t::('a \<oplus> 'b) itself) = ssum_sfp\<cdot>SFP('a)\<cdot>SFP('b)" |
311 unfolding approx_ssum_def by (cases "x = \<bottom>") simp_all |
|
312 |
339 |
313 instance proof |
340 instance proof |
314 fix i :: nat and x :: "'a \<oplus> 'b" |
341 show "ep_pair emb (prj :: udom \<rightarrow> 'a \<oplus> 'b)" |
315 show "chain (approx :: nat \<Rightarrow> 'a \<oplus> 'b \<rightarrow> 'a \<oplus> 'b)" |
342 unfolding emb_ssum_def prj_ssum_def |
316 unfolding approx_ssum_def by simp |
343 using ep_pair_udom [OF ssum_approx] |
317 show "(\<Squnion>i. approx i\<cdot>x) = x" |
344 by (intro ep_pair_comp ep_pair_ssum_map ep_pair_emb_prj) |
318 unfolding approx_ssum_def |
345 next |
319 by (cases x, simp_all add: lub_distribs) |
346 show "cast\<cdot>SFP('a \<oplus> 'b) = emb oo (prj :: udom \<rightarrow> 'a \<oplus> 'b)" |
320 show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x" |
347 unfolding emb_ssum_def prj_ssum_def sfp_ssum_def cast_ssum_sfp |
321 by (cases x, simp add: approx_ssum_def, simp, simp) |
348 by (simp add: cast_SFP oo_def expand_cfun_eq ssum_map_map) |
322 show "finite {x::'a \<oplus> 'b. approx i\<cdot>x = x}" |
|
323 unfolding approx_ssum_def |
|
324 by (intro finite_deflation.finite_fixes |
|
325 finite_deflation_ssum_map |
|
326 finite_deflation_approx) |
|
327 qed |
349 qed |
328 |
350 |
329 end |
351 end |
330 |
352 |
|
353 text {* SFP of type constructor = type combinator *} |
|
354 |
|
355 lemma SFP_ssum: "SFP('a::sfp \<oplus> 'b::sfp) = ssum_sfp\<cdot>SFP('a)\<cdot>SFP('b)" |
|
356 by (rule sfp_ssum_def) |
|
357 |
331 end |
358 end |