src/HOLCF/Library/Sum_Cpo.thy
changeset 39974 b525988432e9
parent 39808 1410c84013b9
child 40089 8adc57fb8454
equal deleted inserted replaced
39973:c62b4ff97bfc 39974:b525988432e9
     3 *)
     3 *)
     4 
     4 
     5 header {* The cpo of disjoint sums *}
     5 header {* The cpo of disjoint sums *}
     6 
     6 
     7 theory Sum_Cpo
     7 theory Sum_Cpo
     8 imports Bifinite
     8 imports HOLCF
     9 begin
     9 begin
    10 
    10 
    11 subsection {* Ordering on sum type *}
    11 subsection {* Ordering on sum type *}
    12 
    12 
    13 instantiation sum :: (below, below) below
    13 instantiation sum :: (below, below) below
   216 instance sum :: (finite_po, finite_po) finite_po ..
   216 instance sum :: (finite_po, finite_po) finite_po ..
   217 
   217 
   218 instance sum :: (discrete_cpo, discrete_cpo) discrete_cpo
   218 instance sum :: (discrete_cpo, discrete_cpo) discrete_cpo
   219 by intro_classes (simp add: below_sum_def split: sum.split)
   219 by intro_classes (simp add: below_sum_def split: sum.split)
   220 
   220 
   221 subsection {* Sum type is a bifinite domain *}
       
   222 
       
   223 instantiation sum :: (profinite, profinite) profinite
       
   224 begin
       
   225 
       
   226 definition
       
   227   approx_sum_def: "approx =
       
   228     (\<lambda>n. \<Lambda> x. case x of Inl a \<Rightarrow> Inl (approx n\<cdot>a) | Inr b \<Rightarrow> Inr (approx n\<cdot>b))"
       
   229 
       
   230 lemma approx_Inl [simp]: "approx n\<cdot>(Inl x) = Inl (approx n\<cdot>x)"
       
   231   unfolding approx_sum_def by simp
       
   232 
       
   233 lemma approx_Inr [simp]: "approx n\<cdot>(Inr x) = Inr (approx n\<cdot>x)"
       
   234   unfolding approx_sum_def by simp
       
   235 
       
   236 instance proof
       
   237   fix i :: nat and x :: "'a + 'b"
       
   238   show "chain (approx :: nat \<Rightarrow> 'a + 'b \<rightarrow> 'a + 'b)"
       
   239     unfolding approx_sum_def
       
   240     by (rule ch2ch_LAM, case_tac x, simp_all)
       
   241   show "(\<Squnion>i. approx i\<cdot>x) = x"
       
   242     by (induct x, simp_all add: lub_Inl lub_Inr)
       
   243   show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
       
   244     by (induct x, simp_all)
       
   245   have "{x::'a + 'b. approx i\<cdot>x = x} \<subseteq>
       
   246         {x::'a. approx i\<cdot>x = x} <+> {x::'b. approx i\<cdot>x = x}"
       
   247     by (rule subsetI, case_tac x, simp_all add: InlI InrI)
       
   248   thus "finite {x::'a + 'b. approx i\<cdot>x = x}"
       
   249     by (rule finite_subset,
       
   250         intro finite_Plus finite_fixes_approx)
       
   251 qed
       
   252 
       
   253 end
   221 end
   254 
       
   255 end