src/HOLCF/Bifinite.thy
changeset 39974 b525988432e9
parent 39973 c62b4ff97bfc
child 39985 310f98585107
equal deleted inserted replaced
39973:c62b4ff97bfc 39974:b525988432e9
     6 
     6 
     7 theory Bifinite
     7 theory Bifinite
     8 imports Deflation
     8 imports Deflation
     9 begin
     9 begin
    10 
    10 
    11 subsection {* Omega-profinite and bifinite domains *}
    11 subsection {* Map operator for product type *}
    12 
       
    13 class profinite =
       
    14   fixes approx :: "nat \<Rightarrow> 'a \<rightarrow> 'a"
       
    15   assumes chain_approx [simp]: "chain approx"
       
    16   assumes lub_approx_app [simp]: "(\<Squnion>i. approx i\<cdot>x) = x"
       
    17   assumes approx_idem: "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
       
    18   assumes finite_fixes_approx: "finite {x. approx i\<cdot>x = x}"
       
    19 
       
    20 class bifinite = profinite + pcpo
       
    21 
       
    22 lemma approx_below: "approx i\<cdot>x \<sqsubseteq> x"
       
    23 proof -
       
    24   have "chain (\<lambda>i. approx i\<cdot>x)" by simp
       
    25   hence "approx i\<cdot>x \<sqsubseteq> (\<Squnion>i. approx i\<cdot>x)" by (rule is_ub_thelub)
       
    26   thus "approx i\<cdot>x \<sqsubseteq> x" by simp
       
    27 qed
       
    28 
       
    29 lemma finite_deflation_approx: "finite_deflation (approx i)"
       
    30 proof
       
    31   fix x :: 'a
       
    32   show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
       
    33     by (rule approx_idem)
       
    34   show "approx i\<cdot>x \<sqsubseteq> x"
       
    35     by (rule approx_below)
       
    36   show "finite {x. approx i\<cdot>x = x}"
       
    37     by (rule finite_fixes_approx)
       
    38 qed
       
    39 
       
    40 interpretation approx: finite_deflation "approx i"
       
    41 by (rule finite_deflation_approx)
       
    42 
       
    43 lemma (in deflation) deflation: "deflation d" ..
       
    44 
       
    45 lemma deflation_approx: "deflation (approx i)"
       
    46 by (rule approx.deflation)
       
    47 
       
    48 lemma lub_approx [simp]: "(\<Squnion>i. approx i) = (\<Lambda> x. x)"
       
    49 by (rule ext_cfun, simp add: contlub_cfun_fun)
       
    50 
       
    51 lemma approx_strict [simp]: "approx i\<cdot>\<bottom> = \<bottom>"
       
    52 by (rule UU_I, rule approx_below)
       
    53 
       
    54 lemma approx_approx1:
       
    55   "i \<le> j \<Longrightarrow> approx i\<cdot>(approx j\<cdot>x) = approx i\<cdot>x"
       
    56 apply (rule deflation_below_comp1 [OF deflation_approx deflation_approx])
       
    57 apply (erule chain_mono [OF chain_approx])
       
    58 done
       
    59 
       
    60 lemma approx_approx2:
       
    61   "j \<le> i \<Longrightarrow> approx i\<cdot>(approx j\<cdot>x) = approx j\<cdot>x"
       
    62 apply (rule deflation_below_comp2 [OF deflation_approx deflation_approx])
       
    63 apply (erule chain_mono [OF chain_approx])
       
    64 done
       
    65 
       
    66 lemma approx_approx [simp]:
       
    67   "approx i\<cdot>(approx j\<cdot>x) = approx (min i j)\<cdot>x"
       
    68 apply (rule_tac x=i and y=j in linorder_le_cases)
       
    69 apply (simp add: approx_approx1 min_def)
       
    70 apply (simp add: approx_approx2 min_def)
       
    71 done
       
    72 
       
    73 lemma finite_image_approx: "finite ((\<lambda>x. approx n\<cdot>x) ` A)"
       
    74 by (rule approx.finite_image)
       
    75 
       
    76 lemma finite_range_approx: "finite (range (\<lambda>x. approx i\<cdot>x))"
       
    77 by (rule approx.finite_range)
       
    78 
       
    79 lemma compact_approx [simp]: "compact (approx n\<cdot>x)"
       
    80 by (rule approx.compact)
       
    81 
       
    82 lemma profinite_compact_eq_approx: "compact x \<Longrightarrow> \<exists>i. approx i\<cdot>x = x"
       
    83 by (rule admD2, simp_all)
       
    84 
       
    85 lemma profinite_compact_iff: "compact x \<longleftrightarrow> (\<exists>n. approx n\<cdot>x = x)"
       
    86  apply (rule iffI)
       
    87   apply (erule profinite_compact_eq_approx)
       
    88  apply (erule exE)
       
    89  apply (erule subst)
       
    90  apply (rule compact_approx)
       
    91 done
       
    92 
       
    93 lemma approx_induct:
       
    94   assumes adm: "adm P" and P: "\<And>n x. P (approx n\<cdot>x)"
       
    95   shows "P x"
       
    96 proof -
       
    97   have "P (\<Squnion>n. approx n\<cdot>x)"
       
    98     by (rule admD [OF adm], simp, simp add: P)
       
    99   thus "P x" by simp
       
   100 qed
       
   101 
       
   102 lemma profinite_below_ext: "(\<And>i. approx i\<cdot>x \<sqsubseteq> approx i\<cdot>y) \<Longrightarrow> x \<sqsubseteq> y"
       
   103 apply (subgoal_tac "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> (\<Squnion>i. approx i\<cdot>y)", simp)
       
   104 apply (rule lub_mono, simp, simp, simp)
       
   105 done
       
   106 
       
   107 subsection {* Instance for product type *}
       
   108 
    12 
   109 definition
    13 definition
   110   cprod_map :: "('a \<rightarrow> 'b) \<rightarrow> ('c \<rightarrow> 'd) \<rightarrow> 'a \<times> 'c \<rightarrow> 'b \<times> 'd"
    14   cprod_map :: "('a \<rightarrow> 'b) \<rightarrow> ('c \<rightarrow> 'd) \<rightarrow> 'a \<times> 'c \<rightarrow> 'b \<times> 'd"
   111 where
    15 where
   112   "cprod_map = (\<Lambda> f g p. (f\<cdot>(fst p), g\<cdot>(snd p)))"
    16   "cprod_map = (\<Lambda> f g p. (f\<cdot>(fst p), g\<cdot>(snd p)))"
   159     by clarsimp
    63     by clarsimp
   160   thus "finite {p. cprod_map\<cdot>d1\<cdot>d2\<cdot>p = p}"
    64   thus "finite {p. cprod_map\<cdot>d1\<cdot>d2\<cdot>p = p}"
   161     by (rule finite_subset, simp add: d1.finite_fixes d2.finite_fixes)
    65     by (rule finite_subset, simp add: d1.finite_fixes d2.finite_fixes)
   162 qed
    66 qed
   163 
    67 
   164 instantiation prod :: (profinite, profinite) profinite
    68 subsection {* Map operator for continuous function space *}
   165 begin
       
   166 
       
   167 definition
       
   168   approx_prod_def:
       
   169     "approx = (\<lambda>n. cprod_map\<cdot>(approx n)\<cdot>(approx n))"
       
   170 
       
   171 instance proof
       
   172   fix i :: nat and x :: "'a \<times> 'b"
       
   173   show "chain (approx :: nat \<Rightarrow> 'a \<times> 'b \<rightarrow> 'a \<times> 'b)"
       
   174     unfolding approx_prod_def by simp
       
   175   show "(\<Squnion>i. approx i\<cdot>x) = x"
       
   176     unfolding approx_prod_def cprod_map_def
       
   177     by (simp add: lub_distribs thelub_Pair)
       
   178   show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
       
   179     unfolding approx_prod_def cprod_map_def by simp
       
   180   have "{x::'a \<times> 'b. approx i\<cdot>x = x} \<subseteq>
       
   181         {x::'a. approx i\<cdot>x = x} \<times> {x::'b. approx i\<cdot>x = x}"
       
   182     unfolding approx_prod_def by clarsimp
       
   183   thus "finite {x::'a \<times> 'b. approx i\<cdot>x = x}"
       
   184     by (rule finite_subset,
       
   185         intro finite_cartesian_product finite_fixes_approx)
       
   186 qed
       
   187 
       
   188 end
       
   189 
       
   190 instance prod :: (bifinite, bifinite) bifinite ..
       
   191 
       
   192 lemma approx_Pair [simp]:
       
   193   "approx i\<cdot>(x, y) = (approx i\<cdot>x, approx i\<cdot>y)"
       
   194 unfolding approx_prod_def by simp
       
   195 
       
   196 lemma fst_approx: "fst (approx i\<cdot>p) = approx i\<cdot>(fst p)"
       
   197 by (induct p, simp)
       
   198 
       
   199 lemma snd_approx: "snd (approx i\<cdot>p) = approx i\<cdot>(snd p)"
       
   200 by (induct p, simp)
       
   201 
       
   202 
       
   203 subsection {* Instance for continuous function space *}
       
   204 
    69 
   205 definition
    70 definition
   206   cfun_map :: "('b \<rightarrow> 'a) \<rightarrow> ('c \<rightarrow> 'd) \<rightarrow> ('a \<rightarrow> 'c) \<rightarrow> ('b \<rightarrow> 'd)"
    71   cfun_map :: "('b \<rightarrow> 'a) \<rightarrow> ('c \<rightarrow> 'd) \<rightarrow> ('a \<rightarrow> 'c) \<rightarrow> ('b \<rightarrow> 'd)"
   207 where
    72 where
   208   "cfun_map = (\<Lambda> a b f x. b\<cdot>(f\<cdot>(a\<cdot>x)))"
    73   "cfun_map = (\<Lambda> a b f x. b\<cdot>(f\<cdot>(a\<cdot>x)))"
   303 apply (simp add: cfun_map_def deflation.idem eta_cfun)
   168 apply (simp add: cfun_map_def deflation.idem eta_cfun)
   304 apply (rule finite_deflation.compact)
   169 apply (rule finite_deflation.compact)
   305 apply (simp only: finite_deflation_cfun_map)
   170 apply (simp only: finite_deflation_cfun_map)
   306 done
   171 done
   307 
   172 
   308 instantiation cfun :: (profinite, profinite) profinite
       
   309 begin
       
   310 
       
   311 definition
       
   312   approx_cfun_def:
       
   313     "approx = (\<lambda>n. cfun_map\<cdot>(approx n)\<cdot>(approx n))"
       
   314 
       
   315 instance proof
       
   316   show "chain (approx :: nat \<Rightarrow> ('a \<rightarrow> 'b) \<rightarrow> ('a \<rightarrow> 'b))"
       
   317     unfolding approx_cfun_def by simp
       
   318 next
       
   319   fix x :: "'a \<rightarrow> 'b"
       
   320   show "(\<Squnion>i. approx i\<cdot>x) = x"
       
   321     unfolding approx_cfun_def cfun_map_def
       
   322     by (simp add: lub_distribs eta_cfun)
       
   323 next
       
   324   fix i :: nat and x :: "'a \<rightarrow> 'b"
       
   325   show "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
       
   326     unfolding approx_cfun_def cfun_map_def by simp
       
   327 next
       
   328   fix i :: nat
       
   329   show "finite {x::'a \<rightarrow> 'b. approx i\<cdot>x = x}"
       
   330     unfolding approx_cfun_def
       
   331     by (intro finite_deflation.finite_fixes
       
   332               finite_deflation_cfun_map
       
   333               finite_deflation_approx)
       
   334 qed
       
   335 
       
   336 end
   173 end
   337 
       
   338 instance cfun :: (profinite, bifinite) bifinite ..
       
   339 
       
   340 lemma approx_cfun: "approx n\<cdot>f\<cdot>x = approx n\<cdot>(f\<cdot>(approx n\<cdot>x))"
       
   341 by (simp add: approx_cfun_def)
       
   342 
       
   343 end