| author | wenzelm | 
| Fri, 24 Jan 2025 20:05:01 +0100 | |
| changeset 81973 | 82cf33956a17 | 
| parent 81281 | c1e418161ace | 
| permissions | -rw-r--r-- | 
| 37653 | 1 | (* Title: HOL/Library/Cardinality.thy | 
| 48051 | 2 | Author: Brian Huffman, Andreas Lochbihler | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 3 | *) | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 4 | |
| 60500 | 5 | section \<open>Cardinality of types\<close> | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 6 | |
| 37653 | 7 | theory Cardinality | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 8 | imports Phantom_Type | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 9 | begin | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 10 | |
| 60500 | 11 | subsection \<open>Preliminary lemmas\<close> | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 12 | (* These should be moved elsewhere *) | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 13 | |
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 14 | lemma (in type_definition) univ: | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 15 | "UNIV = Abs ` A" | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 16 | proof | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 17 | show "Abs ` A \<subseteq> UNIV" by (rule subset_UNIV) | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 18 | show "UNIV \<subseteq> Abs ` A" | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 19 | proof | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 20 | fix x :: 'b | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 21 | have "x = Abs (Rep x)" by (rule Rep_inverse [symmetric]) | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 22 | moreover have "Rep x \<in> A" by (rule Rep) | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 23 | ultimately show "x \<in> Abs ` A" by (rule image_eqI) | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 24 | qed | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 25 | qed | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 26 | |
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 27 | lemma (in type_definition) card: "card (UNIV :: 'b set) = card A" | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 28 | by (simp add: univ card_image inj_on_def Abs_inject) | 
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 29 | |
| 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 30 | |
| 60500 | 31 | subsection \<open>Cardinalities of types\<close> | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 32 | |
| 81142 | 33 | syntax "_type_card" :: "type => nat" (\<open>(\<open>indent=1 notation=\<open>mixfix CARD\<close>\<close>CARD/(1'(_')))\<close>) | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 34 | |
| 80768 | 35 | syntax_consts "_type_card" == card | 
| 36 | ||
| 61076 | 37 | translations "CARD('t)" => "CONST card (CONST UNIV :: 't set)"
 | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 38 | |
| 60500 | 39 | print_translation \<open> | 
| 42247 
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
 wenzelm parents: 
42245diff
changeset | 40 | let | 
| 69593 | 41 | fun card_univ_tr' ctxt [Const (\<^const_syntax>\<open>UNIV\<close>, Type (_, [T]))] = | 
| 42 | Syntax.const \<^syntax_const>\<open>_type_card\<close> $ Syntax_Phases.term_of_typ ctxt T | |
| 43 | in [(\<^const_syntax>\<open>card\<close>, card_univ_tr')] end | |
| 60500 | 44 | \<close> | 
| 24407 | 45 | |
| 48058 | 46 | lemma card_prod [simp]: "CARD('a \<times> 'b) = CARD('a) * CARD('b)"
 | 
| 26153 | 47 | unfolding UNIV_Times_UNIV [symmetric] by (simp only: card_cartesian_product) | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 48 | |
| 48060 | 49 | lemma card_UNIV_sum: "CARD('a + 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 then CARD('a) + CARD('b) else 0)"
 | 
| 50 | unfolding UNIV_Plus_UNIV[symmetric] | |
| 51 | by(auto simp add: card_eq_0_iff card_Plus simp del: UNIV_Plus_UNIV) | |
| 52 | ||
| 30001 | 53 | lemma card_sum [simp]: "CARD('a + 'b) = CARD('a::finite) + CARD('b::finite)"
 | 
| 48060 | 54 | by(simp add: card_UNIV_sum) | 
| 55 | ||
| 56 | lemma card_UNIV_option: "CARD('a option) = (if CARD('a) = 0 then 0 else CARD('a) + 1)"
 | |
| 57 | proof - | |
| 58 | have "(None :: 'a option) \<notin> range Some" by clarsimp | |
| 59 | thus ?thesis | |
| 53191 | 60 | by (simp add: UNIV_option_conv card_eq_0_iff finite_range_Some card_image) | 
| 48060 | 61 | qed | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 62 | |
| 30001 | 63 | lemma card_option [simp]: "CARD('a option) = Suc CARD('a::finite)"
 | 
| 48060 | 64 | by(simp add: card_UNIV_option) | 
| 65 | ||
| 66 | lemma card_UNIV_set: "CARD('a set) = (if CARD('a) = 0 then 0 else 2 ^ CARD('a))"
 | |
| 68406 | 67 | by(simp add: card_eq_0_iff card_Pow flip: Pow_UNIV) | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 68 | |
| 30001 | 69 | lemma card_set [simp]: "CARD('a set) = 2 ^ CARD('a::finite)"
 | 
| 48060 | 70 | by(simp add: card_UNIV_set) | 
| 24332 
e3a2b75b1cf9
boolean algebras as locales and numbers as types by Brian Huffman
 kleing parents: diff
changeset | 71 | |
| 30001 | 72 | lemma card_nat [simp]: "CARD(nat) = 0" | 
| 44142 | 73 | by (simp add: card_eq_0_iff) | 
| 30001 | 74 | |
| 48060 | 75 | lemma card_fun: "CARD('a \<Rightarrow> 'b) = (if CARD('a) \<noteq> 0 \<and> CARD('b) \<noteq> 0 \<or> CARD('b) = 1 then CARD('b) ^ CARD('a) else 0)"
 | 
| 76 | proof - | |
| 81281 | 77 |   have "CARD('a \<Rightarrow> 'b) = CARD('b) ^ CARD('a)" if "0 < CARD('a)" and "0 < CARD('b)"
 | 
| 78 | proof - | |
| 79 | from that have fina: "finite (UNIV :: 'a set)" and finb: "finite (UNIV :: 'b set)" | |
| 48060 | 80 | by(simp_all only: card_ge_0_finite) | 
| 81 | from finite_distinct_list[OF finb] obtain bs | |
| 82 | where bs: "set bs = (UNIV :: 'b set)" and distb: "distinct bs" by blast | |
| 83 | from finite_distinct_list[OF fina] obtain as | |
| 84 | where as: "set as = (UNIV :: 'a set)" and dista: "distinct as" by blast | |
| 85 |     have cb: "CARD('b) = length bs"
 | |
| 86 | unfolding bs[symmetric] distinct_card[OF distb] .. | |
| 87 |     have ca: "CARD('a) = length as"
 | |
| 88 | unfolding as[symmetric] distinct_card[OF dista] .. | |
| 67091 | 89 | let ?xs = "map (\<lambda>ys. the \<circ> map_of (zip as ys)) (List.n_lists (length as) bs)" | 
| 48060 | 90 | have "UNIV = set ?xs" | 
| 91 | proof(rule UNIV_eq_I) | |
| 92 | fix f :: "'a \<Rightarrow> 'b" | |
| 93 | from as have "f = the \<circ> map_of (zip as (map f as))" | |
| 94 | by(auto simp add: map_of_zip_map) | |
| 95 | thus "f \<in> set ?xs" using bs by(auto simp add: set_n_lists) | |
| 96 | qed | |
| 97 | moreover have "distinct ?xs" unfolding distinct_map | |
| 98 | proof(intro conjI distinct_n_lists distb inj_onI) | |
| 99 | fix xs ys :: "'b list" | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49689diff
changeset | 100 | assume xs: "xs \<in> set (List.n_lists (length as) bs)" | 
| 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
49689diff
changeset | 101 | and ys: "ys \<in> set (List.n_lists (length as) bs)" | 
| 48060 | 102 | and eq: "the \<circ> map_of (zip as xs) = the \<circ> map_of (zip as ys)" | 
| 103 | from xs ys have [simp]: "length xs = length as" "length ys = length as" | |
| 104 | by(simp_all add: length_n_lists_elem) | |
| 105 | have "map_of (zip as xs) = map_of (zip as ys)" | |
| 106 | proof | |
| 107 | fix x | |
| 108 | from as bs have "\<exists>y. map_of (zip as xs) x = Some y" "\<exists>y. map_of (zip as ys) x = Some y" | |
| 109 | by(simp_all add: map_of_zip_is_Some[symmetric]) | |
| 110 | with eq show "map_of (zip as xs) x = map_of (zip as ys) x" | |
| 111 | by(auto dest: fun_cong[where x=x]) | |
| 112 | qed | |
| 113 | with dista show "xs = ys" by(simp add: map_of_zip_inject) | |
| 114 | qed | |
| 115 | hence "card (set ?xs) = length ?xs" by(simp only: distinct_card) | |
| 116 | moreover have "length ?xs = length bs ^ length as" by(simp add: length_n_lists) | |
| 81281 | 117 | ultimately show ?thesis using cb ca by simp | 
| 118 | qed | |
| 119 |   moreover have "CARD('a \<Rightarrow> 'b) = 1" if "CARD('b) = 1"
 | |
| 120 | proof - | |
| 121 |     from that obtain b where b: "UNIV = {b :: 'b}" by(auto simp add: card_Suc_eq)
 | |
| 48060 | 122 |     have eq: "UNIV = {\<lambda>x :: 'a. b ::'b}"
 | 
| 123 | proof(rule UNIV_eq_I) | |
| 124 | fix x :: "'a \<Rightarrow> 'b" | |
| 81281 | 125 | have "x y = b" for y | 
| 126 | proof - | |
| 48060 | 127 | have "x y \<in> UNIV" .. | 
| 81281 | 128 | thus ?thesis unfolding b by simp | 
| 129 | qed | |
| 48060 | 130 |       thus "x \<in> {\<lambda>x. b}" by(auto)
 | 
| 131 | qed | |
| 81281 | 132 | show ?thesis unfolding eq by simp | 
| 133 | qed | |
| 48060 | 134 | ultimately show ?thesis | 
| 135 | by(auto simp del: One_nat_def)(auto simp add: card_eq_0_iff dest: finite_fun_UNIVD2 finite_fun_UNIVD1) | |
| 136 | qed | |
| 137 | ||
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 138 | corollary finite_UNIV_fun: | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 139 |   "finite (UNIV :: ('a \<Rightarrow> 'b) set) \<longleftrightarrow>
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 140 |    finite (UNIV :: 'a set) \<and> finite (UNIV :: 'b set) \<or> CARD('b) = 1"
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 141 | (is "?lhs \<longleftrightarrow> ?rhs") | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 142 | proof - | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 143 |   have "?lhs \<longleftrightarrow> CARD('a \<Rightarrow> 'b) > 0" by(simp add: card_gt_0_iff)
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 144 |   also have "\<dots> \<longleftrightarrow> CARD('a) > 0 \<and> CARD('b) > 0 \<or> CARD('b) = 1"
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 145 | by(simp add: card_fun) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 146 | also have "\<dots> = ?rhs" by(simp add: card_gt_0_iff) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 147 | finally show ?thesis . | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 148 | qed | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 149 | |
| 48060 | 150 | lemma card_literal: "CARD(String.literal) = 0" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 151 | by(simp add: card_eq_0_iff infinite_literal) | 
| 30001 | 152 | |
| 60500 | 153 | subsection \<open>Classes with at least 1 and 2\<close> | 
| 30001 | 154 | |
| 60500 | 155 | text \<open>Class finite already captures "at least 1"\<close> | 
| 30001 | 156 | |
| 157 | lemma zero_less_card_finite [simp]: "0 < CARD('a::finite)"
 | |
| 29997 | 158 | unfolding neq0_conv [symmetric] by simp | 
| 159 | ||
| 30001 | 160 | lemma one_le_card_finite [simp]: "Suc 0 \<le> CARD('a::finite)"
 | 
| 161 | by (simp add: less_Suc_eq_le [symmetric]) | |
| 162 | ||
| 69663 | 163 | |
| 164 | class CARD_1 = | |
| 165 |   assumes CARD_1: "CARD ('a) = 1"
 | |
| 166 | begin | |
| 167 | ||
| 168 | subclass finite | |
| 169 | proof | |
| 170 | from CARD_1 show "finite (UNIV :: 'a set)" | |
| 71258 
d67924987c34
a few new and tidier proofs (mostly about finite sets)
 paulson <lp15@cam.ac.uk> parents: 
71174diff
changeset | 171 | using finite_UNIV_fun by fastforce | 
| 69663 | 172 | qed | 
| 173 | ||
| 174 | end | |
| 175 | ||
| 60500 | 176 | text \<open>Class for cardinality "at least 2"\<close> | 
| 30001 | 177 | |
| 178 | class card2 = finite + | |
| 179 |   assumes two_le_card: "2 \<le> CARD('a)"
 | |
| 180 | ||
| 181 | lemma one_less_card: "Suc 0 < CARD('a::card2)"
 | |
| 182 | using two_le_card [where 'a='a] by simp | |
| 183 | ||
| 184 | lemma one_less_int_card: "1 < int CARD('a::card2)"
 | |
| 185 | using one_less_card [where 'a='a] by simp | |
| 186 | ||
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 187 | |
| 60500 | 188 | subsection \<open>A type class for deciding finiteness of types\<close> | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 189 | |
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 190 | type_synonym 'a finite_UNIV = "('a, bool) phantom"
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 191 | |
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 192 | class finite_UNIV = | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 193 |   fixes finite_UNIV :: "('a, bool) phantom"
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 194 |   assumes finite_UNIV: "finite_UNIV = Phantom('a) (finite (UNIV :: 'a set))"
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 195 | |
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 196 | lemma finite_UNIV_code [code_unfold]: | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 197 | "finite (UNIV :: 'a :: finite_UNIV set) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 198 | \<longleftrightarrow> of_phantom (finite_UNIV :: 'a finite_UNIV)" | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 199 | by(simp add: finite_UNIV) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 200 | |
| 60500 | 201 | subsection \<open>A type class for computing the cardinality of types\<close> | 
| 48051 | 202 | |
| 48059 | 203 | definition is_list_UNIV :: "'a list \<Rightarrow> bool" | 
| 51116 
0dac0158b8d4
implement code generation for finite, card, op = and op <= for sets always via finite_UNIV and card_UNIV, as fragile rewrites based on sorts are hard to find and debug
 Andreas Lochbihler parents: 
49948diff
changeset | 204 | where "is_list_UNIV xs = (let c = CARD('a) in if c = 0 then False else size (remdups xs) = c)"
 | 
| 48059 | 205 | |
| 206 | lemma is_list_UNIV_iff: "is_list_UNIV xs \<longleftrightarrow> set xs = UNIV" | |
| 207 | by(auto simp add: is_list_UNIV_def Let_def card_eq_0_iff List.card_set[symmetric] | |
| 208 | dest: subst[where P="finite", OF _ finite_set] card_eq_UNIV_imp_eq_UNIV) | |
| 209 | ||
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 210 | type_synonym 'a card_UNIV = "('a, nat) phantom"
 | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 211 | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 212 | class card_UNIV = finite_UNIV + | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 213 | fixes card_UNIV :: "'a card_UNIV" | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 214 |   assumes card_UNIV: "card_UNIV = Phantom('a) CARD('a)"
 | 
| 48051 | 215 | |
| 61585 | 216 | subsection \<open>Instantiations for \<open>card_UNIV\<close>\<close> | 
| 48051 | 217 | |
| 218 | instantiation nat :: card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 219 | definition "finite_UNIV = Phantom(nat) False" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 220 | definition "card_UNIV = Phantom(nat) 0" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 221 | instance by intro_classes (simp_all add: finite_UNIV_nat_def card_UNIV_nat_def) | 
| 48051 | 222 | end | 
| 223 | ||
| 224 | instantiation int :: card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 225 | definition "finite_UNIV = Phantom(int) False" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 226 | definition "card_UNIV = Phantom(int) 0" | 
| 71942 | 227 | instance by intro_classes (simp_all add: card_UNIV_int_def finite_UNIV_int_def) | 
| 48051 | 228 | end | 
| 229 | ||
| 51143 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 haftmann parents: 
51139diff
changeset | 230 | instantiation natural :: card_UNIV begin | 
| 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 haftmann parents: 
51139diff
changeset | 231 | definition "finite_UNIV = Phantom(natural) False" | 
| 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 haftmann parents: 
51139diff
changeset | 232 | definition "card_UNIV = Phantom(natural) 0" | 
| 60679 | 233 | instance | 
| 234 | by standard | |
| 235 | (auto simp add: finite_UNIV_natural_def card_UNIV_natural_def card_eq_0_iff | |
| 236 | type_definition.univ [OF type_definition_natural] natural_eq_iff | |
| 237 | dest!: finite_imageD intro: inj_onI) | |
| 51143 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 haftmann parents: 
51139diff
changeset | 238 | end | 
| 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 haftmann parents: 
51139diff
changeset | 239 | |
| 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 haftmann parents: 
51139diff
changeset | 240 | instantiation integer :: card_UNIV begin | 
| 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 haftmann parents: 
51139diff
changeset | 241 | definition "finite_UNIV = Phantom(integer) False" | 
| 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 haftmann parents: 
51139diff
changeset | 242 | definition "card_UNIV = Phantom(integer) 0" | 
| 60679 | 243 | instance | 
| 244 | by standard | |
| 245 | (auto simp add: finite_UNIV_integer_def card_UNIV_integer_def card_eq_0_iff | |
| 71174 | 246 | type_definition.univ [OF type_definition_integer] | 
| 60679 | 247 | dest!: finite_imageD intro: inj_onI) | 
| 48165 
d07a0b9601aa
instantiate card_UNIV with nibble and code_numeral
 Andreas Lochbihler parents: 
48164diff
changeset | 248 | end | 
| 
d07a0b9601aa
instantiate card_UNIV with nibble and code_numeral
 Andreas Lochbihler parents: 
48164diff
changeset | 249 | |
| 48051 | 250 | instantiation list :: (type) card_UNIV begin | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 251 | definition "finite_UNIV = Phantom('a list) False"
 | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 252 | definition "card_UNIV = Phantom('a list) 0"
 | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 253 | instance by intro_classes (simp_all add: card_UNIV_list_def finite_UNIV_list_def infinite_UNIV_listI) | 
| 48051 | 254 | end | 
| 255 | ||
| 256 | instantiation unit :: card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 257 | definition "finite_UNIV = Phantom(unit) True" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 258 | definition "card_UNIV = Phantom(unit) 1" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 259 | instance by intro_classes (simp_all add: card_UNIV_unit_def finite_UNIV_unit_def) | 
| 48051 | 260 | end | 
| 261 | ||
| 262 | instantiation bool :: card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 263 | definition "finite_UNIV = Phantom(bool) True" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 264 | definition "card_UNIV = Phantom(bool) 2" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 265 | instance by(intro_classes)(simp_all add: card_UNIV_bool_def finite_UNIV_bool_def) | 
| 48051 | 266 | end | 
| 267 | ||
| 268 | instantiation char :: card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 269 | definition "finite_UNIV = Phantom(char) True" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 270 | definition "card_UNIV = Phantom(char) 256" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 271 | instance by intro_classes (simp_all add: card_UNIV_char_def card_UNIV_char finite_UNIV_char_def) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 272 | end | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 273 | |
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 274 | instantiation prod :: (finite_UNIV, finite_UNIV) finite_UNIV begin | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 275 | definition "finite_UNIV = Phantom('a \<times> 'b) 
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 276 | (of_phantom (finite_UNIV :: 'a finite_UNIV) \<and> of_phantom (finite_UNIV :: 'b finite_UNIV))" | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 277 | instance by intro_classes (simp add: finite_UNIV_prod_def finite_UNIV finite_prod) | 
| 48051 | 278 | end | 
| 279 | ||
| 280 | instantiation prod :: (card_UNIV, card_UNIV) card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 281 | definition "card_UNIV = Phantom('a \<times> 'b) 
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 282 | (of_phantom (card_UNIV :: 'a card_UNIV) * of_phantom (card_UNIV :: 'b card_UNIV))" | 
| 48060 | 283 | instance by intro_classes (simp add: card_UNIV_prod_def card_UNIV) | 
| 48051 | 284 | end | 
| 285 | ||
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 286 | instantiation sum :: (finite_UNIV, finite_UNIV) finite_UNIV begin | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 287 | definition "finite_UNIV = Phantom('a + 'b)
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 288 | (of_phantom (finite_UNIV :: 'a finite_UNIV) \<and> of_phantom (finite_UNIV :: 'b finite_UNIV))" | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 289 | instance | 
| 68406 | 290 | by intro_classes (simp add: finite_UNIV_sum_def finite_UNIV) | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 291 | end | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 292 | |
| 48051 | 293 | instantiation sum :: (card_UNIV, card_UNIV) card_UNIV begin | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 294 | definition "card_UNIV = Phantom('a + 'b)
 | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 295 | (let ca = of_phantom (card_UNIV :: 'a card_UNIV); | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 296 | cb = of_phantom (card_UNIV :: 'b card_UNIV) | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 297 | in if ca \<noteq> 0 \<and> cb \<noteq> 0 then ca + cb else 0)" | 
| 48060 | 298 | instance by intro_classes (auto simp add: card_UNIV_sum_def card_UNIV card_UNIV_sum) | 
| 48051 | 299 | end | 
| 300 | ||
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 301 | instantiation "fun" :: (finite_UNIV, card_UNIV) finite_UNIV begin | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 302 | definition "finite_UNIV = Phantom('a \<Rightarrow> 'b)
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 303 | (let cb = of_phantom (card_UNIV :: 'b card_UNIV) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 304 | in cb = 1 \<or> of_phantom (finite_UNIV :: 'a finite_UNIV) \<and> cb \<noteq> 0)" | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 305 | instance | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 306 | by intro_classes (auto simp add: finite_UNIV_fun_def Let_def card_UNIV finite_UNIV finite_UNIV_fun card_gt_0_iff) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 307 | end | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 308 | |
| 48051 | 309 | instantiation "fun" :: (card_UNIV, card_UNIV) card_UNIV begin | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 310 | definition "card_UNIV = Phantom('a \<Rightarrow> 'b)
 | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 311 | (let ca = of_phantom (card_UNIV :: 'a card_UNIV); | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 312 | cb = of_phantom (card_UNIV :: 'b card_UNIV) | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 313 | in if ca \<noteq> 0 \<and> cb \<noteq> 0 \<or> cb = 1 then cb ^ ca else 0)" | 
| 48060 | 314 | instance by intro_classes (simp add: card_UNIV_fun_def card_UNIV Let_def card_fun) | 
| 315 | end | |
| 48051 | 316 | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 317 | instantiation option :: (finite_UNIV) finite_UNIV begin | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 318 | definition "finite_UNIV = Phantom('a option) (of_phantom (finite_UNIV :: 'a finite_UNIV))"
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 319 | instance by intro_classes (simp add: finite_UNIV_option_def finite_UNIV) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 320 | end | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 321 | |
| 48060 | 322 | instantiation option :: (card_UNIV) card_UNIV begin | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 323 | definition "card_UNIV = Phantom('a option)
 | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 324 | (let c = of_phantom (card_UNIV :: 'a card_UNIV) in if c \<noteq> 0 then Suc c else 0)" | 
| 48060 | 325 | instance by intro_classes (simp add: card_UNIV_option_def card_UNIV card_UNIV_option) | 
| 326 | end | |
| 48051 | 327 | |
| 48060 | 328 | instantiation String.literal :: card_UNIV begin | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 329 | definition "finite_UNIV = Phantom(String.literal) False" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 330 | definition "card_UNIV = Phantom(String.literal) 0" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 331 | instance | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 332 | by intro_classes (simp_all add: card_UNIV_literal_def finite_UNIV_literal_def infinite_literal card_literal) | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 333 | end | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 334 | |
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 335 | instantiation set :: (finite_UNIV) finite_UNIV begin | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 336 | definition "finite_UNIV = Phantom('a set) (of_phantom (finite_UNIV :: 'a finite_UNIV))"
 | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 337 | instance by intro_classes (simp add: finite_UNIV_set_def finite_UNIV Finite_Set.finite_set) | 
| 48060 | 338 | end | 
| 339 | ||
| 340 | instantiation set :: (card_UNIV) card_UNIV begin | |
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 341 | definition "card_UNIV = Phantom('a set)
 | 
| 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 342 | (let c = of_phantom (card_UNIV :: 'a card_UNIV) in if c = 0 then 0 else 2 ^ c)" | 
| 48060 | 343 | instance by intro_classes (simp add: card_UNIV_set_def card_UNIV_set card_UNIV) | 
| 48051 | 344 | end | 
| 345 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52147diff
changeset | 346 | lemma UNIV_finite_1: "UNIV = set [finite_1.a\<^sub>1]" | 
| 48060 | 347 | by(auto intro: finite_1.exhaust) | 
| 348 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52147diff
changeset | 349 | lemma UNIV_finite_2: "UNIV = set [finite_2.a\<^sub>1, finite_2.a\<^sub>2]" | 
| 48060 | 350 | by(auto intro: finite_2.exhaust) | 
| 48051 | 351 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52147diff
changeset | 352 | lemma UNIV_finite_3: "UNIV = set [finite_3.a\<^sub>1, finite_3.a\<^sub>2, finite_3.a\<^sub>3]" | 
| 48060 | 353 | by(auto intro: finite_3.exhaust) | 
| 48051 | 354 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52147diff
changeset | 355 | lemma UNIV_finite_4: "UNIV = set [finite_4.a\<^sub>1, finite_4.a\<^sub>2, finite_4.a\<^sub>3, finite_4.a\<^sub>4]" | 
| 48060 | 356 | by(auto intro: finite_4.exhaust) | 
| 357 | ||
| 358 | lemma UNIV_finite_5: | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52147diff
changeset | 359 | "UNIV = set [finite_5.a\<^sub>1, finite_5.a\<^sub>2, finite_5.a\<^sub>3, finite_5.a\<^sub>4, finite_5.a\<^sub>5]" | 
| 48060 | 360 | by(auto intro: finite_5.exhaust) | 
| 48051 | 361 | |
| 48060 | 362 | instantiation Enum.finite_1 :: card_UNIV begin | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 363 | definition "finite_UNIV = Phantom(Enum.finite_1) True" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 364 | definition "card_UNIV = Phantom(Enum.finite_1) 1" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 365 | instance | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 366 | by intro_classes (simp_all add: UNIV_finite_1 card_UNIV_finite_1_def finite_UNIV_finite_1_def) | 
| 48060 | 367 | end | 
| 368 | ||
| 369 | instantiation Enum.finite_2 :: card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 370 | definition "finite_UNIV = Phantom(Enum.finite_2) True" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 371 | definition "card_UNIV = Phantom(Enum.finite_2) 2" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 372 | instance | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 373 | by intro_classes (simp_all add: UNIV_finite_2 card_UNIV_finite_2_def finite_UNIV_finite_2_def) | 
| 48060 | 374 | end | 
| 48051 | 375 | |
| 48060 | 376 | instantiation Enum.finite_3 :: card_UNIV begin | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 377 | definition "finite_UNIV = Phantom(Enum.finite_3) True" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 378 | definition "card_UNIV = Phantom(Enum.finite_3) 3" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 379 | instance | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 380 | by intro_classes (simp_all add: UNIV_finite_3 card_UNIV_finite_3_def finite_UNIV_finite_3_def) | 
| 48060 | 381 | end | 
| 382 | ||
| 383 | instantiation Enum.finite_4 :: card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 384 | definition "finite_UNIV = Phantom(Enum.finite_4) True" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 385 | definition "card_UNIV = Phantom(Enum.finite_4) 4" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 386 | instance | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 387 | by intro_classes (simp_all add: UNIV_finite_4 card_UNIV_finite_4_def finite_UNIV_finite_4_def) | 
| 48060 | 388 | end | 
| 389 | ||
| 390 | instantiation Enum.finite_5 :: card_UNIV begin | |
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 391 | definition "finite_UNIV = Phantom(Enum.finite_5) True" | 
| 48164 
e97369f20c30
change card_UNIV from itself to phantom type to avoid unnecessary closures in generated code
 Andreas Lochbihler parents: 
48070diff
changeset | 392 | definition "card_UNIV = Phantom(Enum.finite_5) 5" | 
| 48176 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 393 | instance | 
| 
3d9c1ddb9f47
new type class for computing finiteness of types with instantiations
 Andreas Lochbihler parents: 
48165diff
changeset | 394 | by intro_classes (simp_all add: UNIV_finite_5 card_UNIV_finite_5_def finite_UNIV_finite_5_def) | 
| 48051 | 395 | end | 
| 396 | ||
| 61115 
3a4400985780
modernized name space management -- more uniform qualification;
 wenzelm parents: 
61076diff
changeset | 397 | end |