| author | nipkow | 
| Fri, 28 Feb 2014 18:09:37 +0100 | |
| changeset 55807 | fd31d0e70eb8 | 
| parent 55088 | 57c82e01022b | 
| child 57247 | 8191ccf6a1bd | 
| permissions | -rw-r--r-- | 
| 31596 | 1 | (* Author: Florian Haftmann, TU Muenchen *) | 
| 26348 | 2 | |
| 3 | header {* Finite types as explicit enumerations *}
 | |
| 4 | ||
| 5 | theory Enum | |
| 49972 
f11f8905d9fd
incorporated constant chars into instantiation proof for enum;
 haftmann parents: 
49950diff
changeset | 6 | imports Map | 
| 26348 | 7 | begin | 
| 8 | ||
| 9 | subsection {* Class @{text enum} *}
 | |
| 10 | ||
| 29797 | 11 | class enum = | 
| 26348 | 12 | fixes enum :: "'a list" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 13 |   fixes enum_all :: "('a \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 14 |   fixes enum_ex :: "('a \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 33635 | 15 | assumes UNIV_enum: "UNIV = set enum" | 
| 26444 | 16 | and enum_distinct: "distinct enum" | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 17 | assumes enum_all_UNIV: "enum_all P \<longleftrightarrow> Ball UNIV P" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 18 | assumes enum_ex_UNIV: "enum_ex P \<longleftrightarrow> Bex UNIV P" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 19 |    -- {* tailored towards simple instantiation *}
 | 
| 26348 | 20 | begin | 
| 21 | ||
| 29797 | 22 | subclass finite proof | 
| 23 | qed (simp add: UNIV_enum) | |
| 26444 | 24 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 25 | lemma enum_UNIV: | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 26 | "set enum = UNIV" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 27 | by (simp only: UNIV_enum) | 
| 26444 | 28 | |
| 40683 | 29 | lemma in_enum: "x \<in> set enum" | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 30 | by (simp add: enum_UNIV) | 
| 26348 | 31 | |
| 32 | lemma enum_eq_I: | |
| 33 | assumes "\<And>x. x \<in> set xs" | |
| 34 | shows "set enum = set xs" | |
| 35 | proof - | |
| 36 | from assms UNIV_eq_I have "UNIV = set xs" by auto | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 37 | with enum_UNIV show ?thesis by simp | 
| 26348 | 38 | qed | 
| 39 | ||
| 49972 
f11f8905d9fd
incorporated constant chars into instantiation proof for enum;
 haftmann parents: 
49950diff
changeset | 40 | lemma card_UNIV_length_enum: | 
| 
f11f8905d9fd
incorporated constant chars into instantiation proof for enum;
 haftmann parents: 
49950diff
changeset | 41 | "card (UNIV :: 'a set) = length enum" | 
| 
f11f8905d9fd
incorporated constant chars into instantiation proof for enum;
 haftmann parents: 
49950diff
changeset | 42 | by (simp add: UNIV_enum distinct_card enum_distinct) | 
| 
f11f8905d9fd
incorporated constant chars into instantiation proof for enum;
 haftmann parents: 
49950diff
changeset | 43 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 44 | lemma enum_all [simp]: | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 45 | "enum_all = HOL.All" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 46 | by (simp add: fun_eq_iff enum_all_UNIV) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 47 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 48 | lemma enum_ex [simp]: | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 49 | "enum_ex = HOL.Ex" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 50 | by (simp add: fun_eq_iff enum_ex_UNIV) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 51 | |
| 26348 | 52 | end | 
| 53 | ||
| 54 | ||
| 49949 | 55 | subsection {* Implementations using @{class enum} *}
 | 
| 56 | ||
| 57 | subsubsection {* Unbounded operations and quantifiers *}
 | |
| 58 | ||
| 59 | lemma Collect_code [code]: | |
| 60 | "Collect P = set (filter P enum)" | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 61 | by (simp add: enum_UNIV) | 
| 49949 | 62 | |
| 50567 
768a3fbe4149
providing a custom code equation for vimage to overwrite the vimage definition that would be rewritten by set_comprehension_pointfree simproc in the code preprocessor to an non-terminating code equation
 bulwahn parents: 
49972diff
changeset | 63 | lemma vimage_code [code]: | 
| 
768a3fbe4149
providing a custom code equation for vimage to overwrite the vimage definition that would be rewritten by set_comprehension_pointfree simproc in the code preprocessor to an non-terminating code equation
 bulwahn parents: 
49972diff
changeset | 64 | "f -` B = set (filter (%x. f x : B) enum_class.enum)" | 
| 
768a3fbe4149
providing a custom code equation for vimage to overwrite the vimage definition that would be rewritten by set_comprehension_pointfree simproc in the code preprocessor to an non-terminating code equation
 bulwahn parents: 
49972diff
changeset | 65 | unfolding vimage_def Collect_code .. | 
| 
768a3fbe4149
providing a custom code equation for vimage to overwrite the vimage definition that would be rewritten by set_comprehension_pointfree simproc in the code preprocessor to an non-terminating code equation
 bulwahn parents: 
49972diff
changeset | 66 | |
| 49949 | 67 | definition card_UNIV :: "'a itself \<Rightarrow> nat" | 
| 68 | where | |
| 69 |   [code del]: "card_UNIV TYPE('a) = card (UNIV :: 'a set)"
 | |
| 70 | ||
| 71 | lemma [code]: | |
| 72 |   "card_UNIV TYPE('a :: enum) = card (set (Enum.enum :: 'a list))"
 | |
| 73 | by (simp only: card_UNIV_def enum_UNIV) | |
| 74 | ||
| 75 | lemma all_code [code]: "(\<forall>x. P x) \<longleftrightarrow> enum_all P" | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 76 | by simp | 
| 49949 | 77 | |
| 78 | lemma exists_code [code]: "(\<exists>x. P x) \<longleftrightarrow> enum_ex P" | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 79 | by simp | 
| 49949 | 80 | |
| 81 | lemma exists1_code [code]: "(\<exists>!x. P x) \<longleftrightarrow> list_ex1 P enum" | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 82 | by (auto simp add: list_ex1_iff enum_UNIV) | 
| 49949 | 83 | |
| 84 | ||
| 85 | subsubsection {* An executable choice operator *}
 | |
| 86 | ||
| 87 | definition | |
| 88 | [code del]: "enum_the = The" | |
| 89 | ||
| 90 | lemma [code]: | |
| 91 | "The P = (case filter P enum of [x] => x | _ => enum_the P)" | |
| 92 | proof - | |
| 93 |   {
 | |
| 94 | fix a | |
| 95 | assume filter_enum: "filter P enum = [a]" | |
| 96 | have "The P = a" | |
| 97 | proof (rule the_equality) | |
| 98 | fix x | |
| 99 | assume "P x" | |
| 100 | show "x = a" | |
| 101 | proof (rule ccontr) | |
| 102 | assume "x \<noteq> a" | |
| 103 | from filter_enum obtain us vs | |
| 104 | where enum_eq: "enum = us @ [a] @ vs" | |
| 105 | and "\<forall> x \<in> set us. \<not> P x" | |
| 106 | and "\<forall> x \<in> set vs. \<not> P x" | |
| 107 | and "P a" | |
| 108 | by (auto simp add: filter_eq_Cons_iff) (simp only: filter_empty_conv[symmetric]) | |
| 109 | with `P x` in_enum[of x, unfolded enum_eq] `x \<noteq> a` show "False" by auto | |
| 110 | qed | |
| 111 | next | |
| 112 | from filter_enum show "P a" by (auto simp add: filter_eq_Cons_iff) | |
| 113 | qed | |
| 114 | } | |
| 115 | from this show ?thesis | |
| 116 | unfolding enum_the_def by (auto split: list.split) | |
| 117 | qed | |
| 118 | ||
| 54890 
cb892d835803
fundamental treatment of undefined vs. universally partial replaces code_abort
 haftmann parents: 
54295diff
changeset | 119 | declare [[code abort: enum_the]] | 
| 52435 
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
 haftmann parents: 
50567diff
changeset | 120 | |
| 
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
 haftmann parents: 
50567diff
changeset | 121 | code_printing | 
| 
6646bb548c6b
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
 haftmann parents: 
50567diff
changeset | 122 | constant enum_the \<rightharpoonup> (Eval) "(fn '_ => raise Match)" | 
| 49949 | 123 | |
| 124 | ||
| 125 | subsubsection {* Equality and order on functions *}
 | |
| 26348 | 126 | |
| 38857 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 haftmann parents: 
37765diff
changeset | 127 | instantiation "fun" :: (enum, equal) equal | 
| 26513 | 128 | begin | 
| 26348 | 129 | |
| 26513 | 130 | definition | 
| 38857 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 haftmann parents: 
37765diff
changeset | 131 | "HOL.equal f g \<longleftrightarrow> (\<forall>x \<in> set enum. f x = g x)" | 
| 26513 | 132 | |
| 31464 | 133 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 134 | qed (simp_all add: equal_fun_def fun_eq_iff enum_UNIV) | 
| 26513 | 135 | |
| 136 | end | |
| 26348 | 137 | |
| 40898 
882e860a1e83
changed order of lemmas to overwrite the general code equation with the nbe-specific one
 bulwahn parents: 
40683diff
changeset | 138 | lemma [code]: | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 139 | "HOL.equal f g \<longleftrightarrow> enum_all (%x. f x = g x)" | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 140 | by (auto simp add: equal fun_eq_iff) | 
| 40898 
882e860a1e83
changed order of lemmas to overwrite the general code equation with the nbe-specific one
 bulwahn parents: 
40683diff
changeset | 141 | |
| 38857 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 haftmann parents: 
37765diff
changeset | 142 | lemma [code nbe]: | 
| 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 haftmann parents: 
37765diff
changeset | 143 | "HOL.equal (f :: _ \<Rightarrow> _) f \<longleftrightarrow> True" | 
| 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 haftmann parents: 
37765diff
changeset | 144 | by (fact equal_refl) | 
| 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 haftmann parents: 
37765diff
changeset | 145 | |
| 28562 | 146 | lemma order_fun [code]: | 
| 26348 | 147 | fixes f g :: "'a\<Colon>enum \<Rightarrow> 'b\<Colon>order" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 148 | shows "f \<le> g \<longleftrightarrow> enum_all (\<lambda>x. f x \<le> g x)" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 149 | and "f < g \<longleftrightarrow> f \<le> g \<and> enum_ex (\<lambda>x. f x \<noteq> g x)" | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 150 | by (simp_all add: fun_eq_iff le_fun_def order_less_le) | 
| 26968 | 151 | |
| 152 | ||
| 49949 | 153 | subsubsection {* Operations on relations *}
 | 
| 154 | ||
| 155 | lemma [code]: | |
| 156 | "Id = image (\<lambda>x. (x, x)) (set Enum.enum)" | |
| 157 | by (auto intro: imageI in_enum) | |
| 26968 | 158 | |
| 54148 | 159 | lemma tranclp_unfold [code]: | 
| 49949 | 160 |   "tranclp r a b \<longleftrightarrow> (a, b) \<in> trancl {(x, y). r x y}"
 | 
| 161 | by (simp add: trancl_def) | |
| 162 | ||
| 54148 | 163 | lemma rtranclp_rtrancl_eq [code]: | 
| 49949 | 164 |   "rtranclp r x y \<longleftrightarrow> (x, y) \<in> rtrancl {(x, y). r x y}"
 | 
| 165 | by (simp add: rtrancl_def) | |
| 26968 | 166 | |
| 49949 | 167 | lemma max_ext_eq [code]: | 
| 168 |   "max_ext R = {(X, Y). finite X \<and> finite Y \<and> Y \<noteq> {} \<and> (\<forall>x. x \<in> X \<longrightarrow> (\<exists>xa \<in> Y. (x, xa) \<in> R))}"
 | |
| 169 | by (auto simp add: max_ext.simps) | |
| 170 | ||
| 171 | lemma max_extp_eq [code]: | |
| 172 |   "max_extp r x y \<longleftrightarrow> (x, y) \<in> max_ext {(x, y). r x y}"
 | |
| 173 | by (simp add: max_ext_def) | |
| 26348 | 174 | |
| 49949 | 175 | lemma mlex_eq [code]: | 
| 176 |   "f <*mlex*> R = {(x, y). f x < f y \<or> (f x \<le> f y \<and> (x, y) \<in> R)}"
 | |
| 177 | by (auto simp add: mlex_prod_def) | |
| 178 | ||
| 55088 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 179 | |
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 180 | subsubsection {* Bounded accessible part *}
 | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 181 | |
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 182 | primrec bacc :: "('a \<times> 'a) set \<Rightarrow> nat \<Rightarrow> 'a set" 
 | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 183 | where | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 184 |   "bacc r 0 = {x. \<forall> y. (y, x) \<notin> r}"
 | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 185 | | "bacc r (Suc n) = (bacc r n \<union> {x. \<forall>y. (y, x) \<in> r \<longrightarrow> y \<in> bacc r n})"
 | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 186 | |
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 187 | lemma bacc_subseteq_acc: | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 188 | "bacc r n \<subseteq> Wellfounded.acc r" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 189 | by (induct n) (auto intro: acc.intros) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 190 | |
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 191 | lemma bacc_mono: | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 192 | "n \<le> m \<Longrightarrow> bacc r n \<subseteq> bacc r m" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 193 | by (induct rule: dec_induct) auto | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 194 | |
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 195 | lemma bacc_upper_bound: | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 196 |   "bacc (r :: ('a \<times> 'a) set)  (card (UNIV :: 'a::finite set)) = (\<Union>n. bacc r n)"
 | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 197 | proof - | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 198 | have "mono (bacc r)" unfolding mono_def by (simp add: bacc_mono) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 199 | moreover have "\<forall>n. bacc r n = bacc r (Suc n) \<longrightarrow> bacc r (Suc n) = bacc r (Suc (Suc n))" by auto | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 200 | moreover have "finite (range (bacc r))" by auto | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 201 | ultimately show ?thesis | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 202 | by (intro finite_mono_strict_prefix_implies_finite_fixpoint) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 203 | (auto intro: finite_mono_remains_stable_implies_strict_prefix) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 204 | qed | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 205 | |
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 206 | lemma acc_subseteq_bacc: | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 207 | assumes "finite r" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 208 | shows "Wellfounded.acc r \<subseteq> (\<Union>n. bacc r n)" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 209 | proof | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 210 | fix x | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 211 | assume "x : Wellfounded.acc r" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 212 | then have "\<exists> n. x : bacc r n" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 213 | proof (induct x arbitrary: rule: acc.induct) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 214 | case (accI x) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 215 | then have "\<forall>y. \<exists> n. (y, x) \<in> r --> y : bacc r n" by simp | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 216 | from choice[OF this] obtain n where n: "\<forall>y. (y, x) \<in> r \<longrightarrow> y \<in> bacc r (n y)" .. | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 217 | obtain n where "\<And>y. (y, x) : r \<Longrightarrow> y : bacc r n" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 218 | proof | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 219 | fix y assume y: "(y, x) : r" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 220 | with n have "y : bacc r (n y)" by auto | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 221 | moreover have "n y <= Max ((%(y, x). n y) ` r)" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 222 | using y `finite r` by (auto intro!: Max_ge) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 223 | note bacc_mono[OF this, of r] | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 224 | ultimately show "y : bacc r (Max ((%(y, x). n y) ` r))" by auto | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 225 | qed | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 226 | then show ?case | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 227 | by (auto simp add: Let_def intro!: exI[of _ "Suc n"]) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 228 | qed | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 229 | then show "x : (UN n. bacc r n)" by auto | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 230 | qed | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 231 | |
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 232 | lemma acc_bacc_eq: | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 233 |   fixes A :: "('a :: finite \<times> 'a) set"
 | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 234 | assumes "finite A" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 235 | shows "Wellfounded.acc A = bacc A (card (UNIV :: 'a set))" | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 236 | using assms by (metis acc_subseteq_bacc bacc_subseteq_acc bacc_upper_bound order_eq_iff) | 
| 
57c82e01022b
moved 'bacc' back to 'Enum' (cf. 744934b818c7) -- reduces baggage loaded by 'Hilbert_Choice'
 blanchet parents: 
54890diff
changeset | 237 | |
| 49949 | 238 | lemma [code]: | 
| 239 |   fixes xs :: "('a::finite \<times> 'a) list"
 | |
| 54295 | 240 |   shows "Wellfounded.acc (set xs) = bacc (set xs) (card_UNIV TYPE('a))"
 | 
| 49949 | 241 | by (simp add: card_UNIV_def acc_bacc_eq) | 
| 242 | ||
| 26348 | 243 | |
| 49949 | 244 | subsection {* Default instances for @{class enum} *}
 | 
| 26348 | 245 | |
| 26444 | 246 | lemma map_of_zip_enum_is_Some: | 
| 247 | assumes "length ys = length (enum \<Colon> 'a\<Colon>enum list)" | |
| 248 | shows "\<exists>y. map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x = Some y" | |
| 249 | proof - | |
| 250 | from assms have "x \<in> set (enum \<Colon> 'a\<Colon>enum list) \<longleftrightarrow> | |
| 251 | (\<exists>y. map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x = Some y)" | |
| 252 | by (auto intro!: map_of_zip_is_Some) | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 253 | then show ?thesis using enum_UNIV by auto | 
| 26444 | 254 | qed | 
| 255 | ||
| 256 | lemma map_of_zip_enum_inject: | |
| 257 | fixes xs ys :: "'b\<Colon>enum list" | |
| 258 | assumes length: "length xs = length (enum \<Colon> 'a\<Colon>enum list)" | |
| 259 | "length ys = length (enum \<Colon> 'a\<Colon>enum list)" | |
| 260 | and map_of: "the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) = the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys)" | |
| 261 | shows "xs = ys" | |
| 262 | proof - | |
| 263 | have "map_of (zip (enum \<Colon> 'a list) xs) = map_of (zip (enum \<Colon> 'a list) ys)" | |
| 264 | proof | |
| 265 | fix x :: 'a | |
| 266 | from length map_of_zip_enum_is_Some obtain y1 y2 | |
| 267 | where "map_of (zip (enum \<Colon> 'a list) xs) x = Some y1" | |
| 268 | and "map_of (zip (enum \<Colon> 'a list) ys) x = Some y2" by blast | |
| 47230 | 269 | moreover from map_of | 
| 270 | have "the (map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) x) = the (map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x)" | |
| 26444 | 271 | by (auto dest: fun_cong) | 
| 272 | ultimately show "map_of (zip (enum \<Colon> 'a\<Colon>enum list) xs) x = map_of (zip (enum \<Colon> 'a\<Colon>enum list) ys) x" | |
| 273 | by simp | |
| 274 | qed | |
| 275 | with length enum_distinct show "xs = ys" by (rule map_of_zip_inject) | |
| 276 | qed | |
| 277 | ||
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 278 | definition all_n_lists :: "(('a :: enum) list \<Rightarrow> bool) \<Rightarrow> nat \<Rightarrow> bool"
 | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 279 | where | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 280 | "all_n_lists P n \<longleftrightarrow> (\<forall>xs \<in> set (List.n_lists n enum). P xs)" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 281 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 282 | lemma [code]: | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 283 | "all_n_lists P n \<longleftrightarrow> (if n = 0 then P [] else enum_all (%x. all_n_lists (%xs. P (x # xs)) (n - 1)))" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 284 | unfolding all_n_lists_def enum_all | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 285 | by (cases n) (auto simp add: enum_UNIV) | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 286 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 287 | definition ex_n_lists :: "(('a :: enum) list \<Rightarrow> bool) \<Rightarrow> nat \<Rightarrow> bool"
 | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 288 | where | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 289 | "ex_n_lists P n \<longleftrightarrow> (\<exists>xs \<in> set (List.n_lists n enum). P xs)" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 290 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 291 | lemma [code]: | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 292 | "ex_n_lists P n \<longleftrightarrow> (if n = 0 then P [] else enum_ex (%x. ex_n_lists (%xs. P (x # xs)) (n - 1)))" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 293 | unfolding ex_n_lists_def enum_ex | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 294 | by (cases n) (auto simp add: enum_UNIV) | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 295 | |
| 26444 | 296 | instantiation "fun" :: (enum, enum) enum | 
| 297 | begin | |
| 298 | ||
| 299 | definition | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
48123diff
changeset | 300 | "enum = map (\<lambda>ys. the o map_of (zip (enum\<Colon>'a list) ys)) (List.n_lists (length (enum\<Colon>'a\<Colon>enum list)) enum)" | 
| 26444 | 301 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 302 | definition | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 303 | "enum_all P = all_n_lists (\<lambda>bs. P (the o map_of (zip enum bs))) (length (enum :: 'a list))" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 304 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 305 | definition | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 306 | "enum_ex P = ex_n_lists (\<lambda>bs. P (the o map_of (zip enum bs))) (length (enum :: 'a list))" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 307 | |
| 26444 | 308 | instance proof | 
| 309 |   show "UNIV = set (enum \<Colon> ('a \<Rightarrow> 'b) list)"
 | |
| 310 | proof (rule UNIV_eq_I) | |
| 311 | fix f :: "'a \<Rightarrow> 'b" | |
| 312 | have "f = the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) (map f enum))" | |
| 40683 | 313 | by (auto simp add: map_of_zip_map fun_eq_iff intro: in_enum) | 
| 26444 | 314 | then show "f \<in> set enum" | 
| 40683 | 315 | by (auto simp add: enum_fun_def set_n_lists intro: in_enum) | 
| 26444 | 316 | qed | 
| 317 | next | |
| 318 | from map_of_zip_enum_inject | |
| 319 |   show "distinct (enum \<Colon> ('a \<Rightarrow> 'b) list)"
 | |
| 320 | by (auto intro!: inj_onI simp add: enum_fun_def | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 321 | distinct_map distinct_n_lists enum_distinct set_n_lists) | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 322 | next | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 323 | fix P | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 324 |   show "enum_all (P :: ('a \<Rightarrow> 'b) \<Rightarrow> bool) = Ball UNIV P"
 | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 325 | proof | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 326 | assume "enum_all P" | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 327 | show "Ball UNIV P" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 328 | proof | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 329 | fix f :: "'a \<Rightarrow> 'b" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 330 | have f: "f = the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) (map f enum))" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 331 | by (auto simp add: map_of_zip_map fun_eq_iff intro: in_enum) | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 332 | from `enum_all P` have "P (the \<circ> map_of (zip enum (map f enum)))" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 333 | unfolding enum_all_fun_def all_n_lists_def | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 334 | apply (simp add: set_n_lists) | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 335 | apply (erule_tac x="map f enum" in allE) | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 336 | apply (auto intro!: in_enum) | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 337 | done | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 338 | from this f show "P f" by auto | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 339 | qed | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 340 | next | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 341 | assume "Ball UNIV P" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 342 | from this show "enum_all P" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 343 | unfolding enum_all_fun_def all_n_lists_def by auto | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 344 | qed | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 345 | next | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 346 | fix P | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 347 |   show "enum_ex (P :: ('a \<Rightarrow> 'b) \<Rightarrow> bool) = Bex UNIV P"
 | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 348 | proof | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 349 | assume "enum_ex P" | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 350 | from this show "Bex UNIV P" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 351 | unfolding enum_ex_fun_def ex_n_lists_def by auto | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 352 | next | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 353 | assume "Bex UNIV P" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 354 | from this obtain f where "P f" .. | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 355 | have f: "f = the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) (map f enum))" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 356 | by (auto simp add: map_of_zip_map fun_eq_iff intro: in_enum) | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 357 | from `P f` this have "P (the \<circ> map_of (zip (enum \<Colon> 'a\<Colon>enum list) (map f enum)))" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 358 | by auto | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 359 | from this show "enum_ex P" | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 360 | unfolding enum_ex_fun_def ex_n_lists_def | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 361 | apply (auto simp add: set_n_lists) | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 362 | apply (rule_tac x="map f enum" in exI) | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 363 | apply (auto intro!: in_enum) | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 364 | done | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 365 | qed | 
| 26444 | 366 | qed | 
| 367 | ||
| 368 | end | |
| 369 | ||
| 38857 
97775f3e8722
renamed class/constant eq to equal; tuned some instantiations
 haftmann parents: 
37765diff
changeset | 370 | lemma enum_fun_code [code]: "enum = (let enum_a = (enum \<Colon> 'a\<Colon>{enum, equal} list)
 | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
48123diff
changeset | 371 | in map (\<lambda>ys. the o map_of (zip enum_a ys)) (List.n_lists (length enum_a) enum))" | 
| 28245 
9767dd8e1e54
celver code lemma avoid type ambiguity problem with Haskell
 haftmann parents: 
27487diff
changeset | 372 | by (simp add: enum_fun_def Let_def) | 
| 26444 | 373 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 374 | lemma enum_all_fun_code [code]: | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 375 |   "enum_all P = (let enum_a = (enum :: 'a::{enum, equal} list)
 | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 376 | in all_n_lists (\<lambda>bs. P (the o map_of (zip enum_a bs))) (length enum_a))" | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 377 | by (simp only: enum_all_fun_def Let_def) | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 378 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 379 | lemma enum_ex_fun_code [code]: | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 380 |   "enum_ex P = (let enum_a = (enum :: 'a::{enum, equal} list)
 | 
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 381 | in ex_n_lists (\<lambda>bs. P (the o map_of (zip enum_a bs))) (length enum_a))" | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 382 | by (simp only: enum_ex_fun_def Let_def) | 
| 45963 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 383 | |
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 384 | instantiation set :: (enum) enum | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 385 | begin | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 386 | |
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 387 | definition | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 388 | "enum = map set (sublists enum)" | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 389 | |
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 390 | definition | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 391 | "enum_all P \<longleftrightarrow> (\<forall>A\<in>set enum. P (A::'a set))" | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 392 | |
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 393 | definition | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 394 | "enum_ex P \<longleftrightarrow> (\<exists>A\<in>set enum. P (A::'a set))" | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 395 | |
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 396 | instance proof | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 397 | qed (simp_all add: enum_set_def enum_all_set_def enum_ex_set_def sublists_powset distinct_set_sublists | 
| 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 398 | enum_distinct enum_UNIV) | 
| 29024 | 399 | |
| 400 | end | |
| 401 | ||
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 402 | instantiation unit :: enum | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 403 | begin | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 404 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 405 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 406 | "enum = [()]" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 407 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 408 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 409 | "enum_all P = P ()" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 410 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 411 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 412 | "enum_ex P = P ()" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 413 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 414 | instance proof | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 415 | qed (auto simp add: enum_unit_def enum_all_unit_def enum_ex_unit_def) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 416 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 417 | end | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 418 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 419 | instantiation bool :: enum | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 420 | begin | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 421 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 422 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 423 | "enum = [False, True]" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 424 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 425 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 426 | "enum_all P \<longleftrightarrow> P False \<and> P True" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 427 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 428 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 429 | "enum_ex P \<longleftrightarrow> P False \<or> P True" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 430 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 431 | instance proof | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 432 | qed (simp_all only: enum_bool_def enum_all_bool_def enum_ex_bool_def UNIV_bool, simp_all) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 433 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 434 | end | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 435 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 436 | instantiation prod :: (enum, enum) enum | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 437 | begin | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 438 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 439 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 440 | "enum = List.product enum enum" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 441 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 442 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 443 | "enum_all P = enum_all (%x. enum_all (%y. P (x, y)))" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 444 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 445 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 446 | "enum_ex P = enum_ex (%x. enum_ex (%y. P (x, y)))" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 447 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 448 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 449 | instance by default | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 450 | (simp_all add: enum_prod_def product_list_set distinct_product | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 451 | enum_UNIV enum_distinct enum_all_prod_def enum_ex_prod_def) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 452 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 453 | end | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 454 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 455 | instantiation sum :: (enum, enum) enum | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 456 | begin | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 457 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 458 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 459 | "enum = map Inl enum @ map Inr enum" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 460 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 461 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 462 | "enum_all P \<longleftrightarrow> enum_all (\<lambda>x. P (Inl x)) \<and> enum_all (\<lambda>x. P (Inr x))" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 463 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 464 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 465 | "enum_ex P \<longleftrightarrow> enum_ex (\<lambda>x. P (Inl x)) \<or> enum_ex (\<lambda>x. P (Inr x))" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 466 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 467 | instance proof | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 468 | qed (simp_all only: enum_sum_def enum_all_sum_def enum_ex_sum_def UNIV_sum, | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 469 | auto simp add: enum_UNIV distinct_map enum_distinct) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 470 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 471 | end | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 472 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 473 | instantiation option :: (enum) enum | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 474 | begin | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 475 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 476 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 477 | "enum = None # map Some enum" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 478 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 479 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 480 | "enum_all P \<longleftrightarrow> P None \<and> enum_all (\<lambda>x. P (Some x))" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 481 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 482 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 483 | "enum_ex P \<longleftrightarrow> P None \<or> enum_ex (\<lambda>x. P (Some x))" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 484 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 485 | instance proof | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 486 | qed (simp_all only: enum_option_def enum_all_option_def enum_ex_option_def UNIV_option_conv, | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 487 | auto simp add: distinct_map enum_UNIV enum_distinct) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 488 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 489 | end | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 490 | |
| 45963 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 491 | |
| 40647 | 492 | subsection {* Small finite types *}
 | 
| 493 | ||
| 494 | text {* We define small finite types for the use in Quickcheck *}
 | |
| 495 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 496 | datatype finite_1 = a\<^sub>1 | 
| 40647 | 497 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 498 | notation (output) a\<^sub>1  ("a\<^sub>1")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 499 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 500 | lemma UNIV_finite_1: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 501 |   "UNIV = {a\<^sub>1}"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 502 | by (auto intro: finite_1.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 503 | |
| 40647 | 504 | instantiation finite_1 :: enum | 
| 505 | begin | |
| 506 | ||
| 507 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 508 | "enum = [a\<^sub>1]" | 
| 40647 | 509 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 510 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 511 | "enum_all P = P a\<^sub>1" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 512 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 513 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 514 | "enum_ex P = P a\<^sub>1" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 515 | |
| 40647 | 516 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 517 | qed (simp_all only: enum_finite_1_def enum_all_finite_1_def enum_ex_finite_1_def UNIV_finite_1, simp_all) | 
| 40647 | 518 | |
| 29024 | 519 | end | 
| 40647 | 520 | |
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 521 | instantiation finite_1 :: linorder | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 522 | begin | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 523 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 524 | definition less_finite_1 :: "finite_1 \<Rightarrow> finite_1 \<Rightarrow> bool" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 525 | where | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 526 | "x < (y :: finite_1) \<longleftrightarrow> False" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 527 | |
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 528 | definition less_eq_finite_1 :: "finite_1 \<Rightarrow> finite_1 \<Rightarrow> bool" | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 529 | where | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 530 | "x \<le> (y :: finite_1) \<longleftrightarrow> True" | 
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 531 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 532 | instance | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 533 | apply (intro_classes) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 534 | apply (auto simp add: less_finite_1_def less_eq_finite_1_def) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 535 | apply (metis finite_1.exhaust) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 536 | done | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 537 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 538 | end | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 539 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 540 | hide_const (open) a\<^sub>1 | 
| 40657 | 541 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 542 | datatype finite_2 = a\<^sub>1 | a\<^sub>2 | 
| 40647 | 543 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 544 | notation (output) a\<^sub>1  ("a\<^sub>1")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 545 | notation (output) a\<^sub>2  ("a\<^sub>2")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 546 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 547 | lemma UNIV_finite_2: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 548 |   "UNIV = {a\<^sub>1, a\<^sub>2}"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 549 | by (auto intro: finite_2.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 550 | |
| 40647 | 551 | instantiation finite_2 :: enum | 
| 552 | begin | |
| 553 | ||
| 554 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 555 | "enum = [a\<^sub>1, a\<^sub>2]" | 
| 40647 | 556 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 557 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 558 | "enum_all P \<longleftrightarrow> P a\<^sub>1 \<and> P a\<^sub>2" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 559 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 560 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 561 | "enum_ex P \<longleftrightarrow> P a\<^sub>1 \<or> P a\<^sub>2" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 562 | |
| 40647 | 563 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 564 | qed (simp_all only: enum_finite_2_def enum_all_finite_2_def enum_ex_finite_2_def UNIV_finite_2, simp_all) | 
| 40647 | 565 | |
| 566 | end | |
| 567 | ||
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 568 | instantiation finite_2 :: linorder | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 569 | begin | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 570 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 571 | definition less_finite_2 :: "finite_2 \<Rightarrow> finite_2 \<Rightarrow> bool" | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 572 | where | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 573 | "x < y \<longleftrightarrow> x = a\<^sub>1 \<and> y = a\<^sub>2" | 
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 574 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 575 | definition less_eq_finite_2 :: "finite_2 \<Rightarrow> finite_2 \<Rightarrow> bool" | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 576 | where | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 577 | "x \<le> y \<longleftrightarrow> x = y \<or> x < (y :: finite_2)" | 
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 578 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 579 | instance | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 580 | apply (intro_classes) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 581 | apply (auto simp add: less_finite_2_def less_eq_finite_2_def) | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 582 | apply (metis finite_2.nchotomy)+ | 
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 583 | done | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 584 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 585 | end | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 586 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 587 | hide_const (open) a\<^sub>1 a\<^sub>2 | 
| 40657 | 588 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 589 | datatype finite_3 = a\<^sub>1 | a\<^sub>2 | a\<^sub>3 | 
| 40647 | 590 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 591 | notation (output) a\<^sub>1  ("a\<^sub>1")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 592 | notation (output) a\<^sub>2  ("a\<^sub>2")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 593 | notation (output) a\<^sub>3  ("a\<^sub>3")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 594 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 595 | lemma UNIV_finite_3: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 596 |   "UNIV = {a\<^sub>1, a\<^sub>2, a\<^sub>3}"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 597 | by (auto intro: finite_3.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 598 | |
| 40647 | 599 | instantiation finite_3 :: enum | 
| 600 | begin | |
| 601 | ||
| 602 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 603 | "enum = [a\<^sub>1, a\<^sub>2, a\<^sub>3]" | 
| 40647 | 604 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 605 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 606 | "enum_all P \<longleftrightarrow> P a\<^sub>1 \<and> P a\<^sub>2 \<and> P a\<^sub>3" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 607 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 608 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 609 | "enum_ex P \<longleftrightarrow> P a\<^sub>1 \<or> P a\<^sub>2 \<or> P a\<^sub>3" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 610 | |
| 40647 | 611 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 612 | qed (simp_all only: enum_finite_3_def enum_all_finite_3_def enum_ex_finite_3_def UNIV_finite_3, simp_all) | 
| 40647 | 613 | |
| 614 | end | |
| 615 | ||
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 616 | instantiation finite_3 :: linorder | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 617 | begin | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 618 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 619 | definition less_finite_3 :: "finite_3 \<Rightarrow> finite_3 \<Rightarrow> bool" | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 620 | where | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 621 | "x < y = (case x of a\<^sub>1 \<Rightarrow> y \<noteq> a\<^sub>1 | a\<^sub>2 \<Rightarrow> y = a\<^sub>3 | a\<^sub>3 \<Rightarrow> False)" | 
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 622 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 623 | definition less_eq_finite_3 :: "finite_3 \<Rightarrow> finite_3 \<Rightarrow> bool" | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 624 | where | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 625 | "x \<le> y \<longleftrightarrow> x = y \<or> x < (y :: finite_3)" | 
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 626 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 627 | instance proof (intro_classes) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 628 | qed (auto simp add: less_finite_3_def less_eq_finite_3_def split: finite_3.split_asm) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 629 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 630 | end | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 631 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 632 | hide_const (open) a\<^sub>1 a\<^sub>2 a\<^sub>3 | 
| 40657 | 633 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 634 | datatype finite_4 = a\<^sub>1 | a\<^sub>2 | a\<^sub>3 | a\<^sub>4 | 
| 40647 | 635 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 636 | notation (output) a\<^sub>1  ("a\<^sub>1")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 637 | notation (output) a\<^sub>2  ("a\<^sub>2")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 638 | notation (output) a\<^sub>3  ("a\<^sub>3")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 639 | notation (output) a\<^sub>4  ("a\<^sub>4")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 640 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 641 | lemma UNIV_finite_4: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 642 |   "UNIV = {a\<^sub>1, a\<^sub>2, a\<^sub>3, a\<^sub>4}"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 643 | by (auto intro: finite_4.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 644 | |
| 40647 | 645 | instantiation finite_4 :: enum | 
| 646 | begin | |
| 647 | ||
| 648 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 649 | "enum = [a\<^sub>1, a\<^sub>2, a\<^sub>3, a\<^sub>4]" | 
| 40647 | 650 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 651 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 652 | "enum_all P \<longleftrightarrow> P a\<^sub>1 \<and> P a\<^sub>2 \<and> P a\<^sub>3 \<and> P a\<^sub>4" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 653 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 654 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 655 | "enum_ex P \<longleftrightarrow> P a\<^sub>1 \<or> P a\<^sub>2 \<or> P a\<^sub>3 \<or> P a\<^sub>4" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 656 | |
| 40647 | 657 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 658 | qed (simp_all only: enum_finite_4_def enum_all_finite_4_def enum_ex_finite_4_def UNIV_finite_4, simp_all) | 
| 40647 | 659 | |
| 660 | end | |
| 661 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 662 | hide_const (open) a\<^sub>1 a\<^sub>2 a\<^sub>3 a\<^sub>4 | 
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 663 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 664 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 665 | datatype finite_5 = a\<^sub>1 | a\<^sub>2 | a\<^sub>3 | a\<^sub>4 | a\<^sub>5 | 
| 40647 | 666 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 667 | notation (output) a\<^sub>1  ("a\<^sub>1")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 668 | notation (output) a\<^sub>2  ("a\<^sub>2")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 669 | notation (output) a\<^sub>3  ("a\<^sub>3")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 670 | notation (output) a\<^sub>4  ("a\<^sub>4")
 | 
| 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 671 | notation (output) a\<^sub>5  ("a\<^sub>5")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 672 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 673 | lemma UNIV_finite_5: | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 674 |   "UNIV = {a\<^sub>1, a\<^sub>2, a\<^sub>3, a\<^sub>4, a\<^sub>5}"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 675 | by (auto intro: finite_5.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 676 | |
| 40647 | 677 | instantiation finite_5 :: enum | 
| 678 | begin | |
| 679 | ||
| 680 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 681 | "enum = [a\<^sub>1, a\<^sub>2, a\<^sub>3, a\<^sub>4, a\<^sub>5]" | 
| 40647 | 682 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 683 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 684 | "enum_all P \<longleftrightarrow> P a\<^sub>1 \<and> P a\<^sub>2 \<and> P a\<^sub>3 \<and> P a\<^sub>4 \<and> P a\<^sub>5" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 685 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 686 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 687 | "enum_ex P \<longleftrightarrow> P a\<^sub>1 \<or> P a\<^sub>2 \<or> P a\<^sub>3 \<or> P a\<^sub>4 \<or> P a\<^sub>5" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 688 | |
| 40647 | 689 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 690 | qed (simp_all only: enum_finite_5_def enum_all_finite_5_def enum_ex_finite_5_def UNIV_finite_5, simp_all) | 
| 40647 | 691 | |
| 692 | end | |
| 693 | ||
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 694 | hide_const (open) a\<^sub>1 a\<^sub>2 a\<^sub>3 a\<^sub>4 a\<^sub>5 | 
| 46352 
73b03235799a
an executable version of accessible part (only for finite types yet)
 bulwahn parents: 
46336diff
changeset | 695 | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
48123diff
changeset | 696 | |
| 46352 
73b03235799a
an executable version of accessible part (only for finite types yet)
 bulwahn parents: 
46336diff
changeset | 697 | subsection {* Closing up *}
 | 
| 40657 | 698 | |
| 41085 
a549ff1d4070
adding a smarter enumeration scheme for finite functions
 bulwahn parents: 
41078diff
changeset | 699 | hide_type (open) finite_1 finite_2 finite_3 finite_4 finite_5 | 
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
48123diff
changeset | 700 | hide_const (open) enum enum_all enum_ex all_n_lists ex_n_lists ntrancl | 
| 40647 | 701 | |
| 702 | end |