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