src/HOL/HOLCF/Compact_Basis.thy
changeset 62175 8ffc4d0e652d
parent 59797 f313ca9fbba0
equal deleted inserted replaced
62174:fae6233c5f37 62175:8ffc4d0e652d
     1 (*  Title:      HOL/HOLCF/Compact_Basis.thy
     1 (*  Title:      HOL/HOLCF/Compact_Basis.thy
     2     Author:     Brian Huffman
     2     Author:     Brian Huffman
     3 *)
     3 *)
     4 
     4 
     5 section {* A compact basis for powerdomains *}
     5 section \<open>A compact basis for powerdomains\<close>
     6 
     6 
     7 theory Compact_Basis
     7 theory Compact_Basis
     8 imports Universal
     8 imports Universal
     9 begin
     9 begin
    10 
    10 
    11 default_sort bifinite
    11 default_sort bifinite
    12 
    12 
    13 subsection {* A compact basis for powerdomains *}
    13 subsection \<open>A compact basis for powerdomains\<close>
    14 
    14 
    15 definition "pd_basis = {S::'a compact_basis set. finite S \<and> S \<noteq> {}}"
    15 definition "pd_basis = {S::'a compact_basis set. finite S \<and> S \<noteq> {}}"
    16 
    16 
    17 typedef 'a pd_basis = "pd_basis :: 'a compact_basis set set"
    17 typedef 'a pd_basis = "pd_basis :: 'a compact_basis set set"
    18   unfolding pd_basis_def
    18   unfolding pd_basis_def
    24 by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp
    24 by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp
    25 
    25 
    26 lemma Rep_pd_basis_nonempty [simp]: "Rep_pd_basis u \<noteq> {}"
    26 lemma Rep_pd_basis_nonempty [simp]: "Rep_pd_basis u \<noteq> {}"
    27 by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp
    27 by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp
    28 
    28 
    29 text {* The powerdomain basis type is countable. *}
    29 text \<open>The powerdomain basis type is countable.\<close>
    30 
    30 
    31 lemma pd_basis_countable: "\<exists>f::'a pd_basis \<Rightarrow> nat. inj f"
    31 lemma pd_basis_countable: "\<exists>f::'a pd_basis \<Rightarrow> nat. inj f"
    32 proof -
    32 proof -
    33   obtain g :: "'a compact_basis \<Rightarrow> nat" where "inj g"
    33   obtain g :: "'a compact_basis \<Rightarrow> nat" where "inj g"
    34     using compact_basis.countable ..
    34     using compact_basis.countable ..
    38     by (simp add: inj_on_def set_encode_eq image_g_eq Rep_pd_basis_inject)
    38     by (simp add: inj_on_def set_encode_eq image_g_eq Rep_pd_basis_inject)
    39   thus ?thesis by - (rule exI)
    39   thus ?thesis by - (rule exI)
    40   (* FIXME: why doesn't ".." or "by (rule exI)" work? *)
    40   (* FIXME: why doesn't ".." or "by (rule exI)" work? *)
    41 qed
    41 qed
    42 
    42 
    43 subsection {* Unit and plus constructors *}
    43 subsection \<open>Unit and plus constructors\<close>
    44 
    44 
    45 definition
    45 definition
    46   PDUnit :: "'a compact_basis \<Rightarrow> 'a pd_basis" where
    46   PDUnit :: "'a compact_basis \<Rightarrow> 'a pd_basis" where
    47   "PDUnit = (\<lambda>x. Abs_pd_basis {x})"
    47   "PDUnit = (\<lambda>x. Abs_pd_basis {x})"
    48 
    48 
    89   shows "P x"
    89   shows "P x"
    90 apply (induct x rule: pd_basis_induct1)
    90 apply (induct x rule: pd_basis_induct1)
    91 apply (rule PDUnit, erule PDPlus [OF PDUnit])
    91 apply (rule PDUnit, erule PDPlus [OF PDUnit])
    92 done
    92 done
    93 
    93 
    94 subsection {* Fold operator *}
    94 subsection \<open>Fold operator\<close>
    95 
    95 
    96 definition
    96 definition
    97   fold_pd ::
    97   fold_pd ::
    98     "('a compact_basis \<Rightarrow> 'b::type) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a pd_basis \<Rightarrow> 'b"
    98     "('a compact_basis \<Rightarrow> 'b::type) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a pd_basis \<Rightarrow> 'b"
    99   where "fold_pd g f t = semilattice_set.F f (g ` Rep_pd_basis t)"
    99   where "fold_pd g f t = semilattice_set.F f (g ` Rep_pd_basis t)"