| author | immler | 
| Fri, 20 May 2016 22:01:39 +0200 | |
| changeset 63103 | 2394b0db133f | 
| parent 62390 | 842917225d56 | 
| child 63950 | cdc1e59aa513 | 
| permissions | -rw-r--r-- | 
| 31596 | 1 | (* Author: Florian Haftmann, TU Muenchen *) | 
| 26348 | 2 | |
| 60758 | 3 | section \<open>Finite types as explicit enumerations\<close> | 
| 26348 | 4 | |
| 5 | theory Enum | |
| 58101 | 6 | imports Map Groups_List | 
| 26348 | 7 | begin | 
| 8 | ||
| 61799 | 9 | subsection \<open>Class \<open>enum\<close>\<close> | 
| 26348 | 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" | 
| 61799 | 19 | \<comment> \<open>tailored towards simple instantiation\<close> | 
| 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 | ||
| 60758 | 55 | subsection \<open>Implementations using @{class enum}\<close>
 | 
| 49949 | 56 | |
| 60758 | 57 | subsubsection \<open>Unbounded operations and quantifiers\<close> | 
| 49949 | 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 | ||
| 60758 | 85 | subsubsection \<open>An executable choice operator\<close> | 
| 49949 | 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]) | |
| 60758 | 109 | with \<open>P x\<close> in_enum[of x, unfolded enum_eq] \<open>x \<noteq> a\<close> show "False" by auto | 
| 49949 | 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 | ||
| 60758 | 125 | subsubsection \<open>Equality and order on functions\<close> | 
| 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]: | 
| 61076 | 147 | fixes f g :: "'a::enum \<Rightarrow> 'b::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 | ||
| 60758 | 153 | subsubsection \<open>Operations on relations\<close> | 
| 49949 | 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 | |
| 60758 | 180 | subsubsection \<open>Bounded accessible part\<close> | 
| 55088 
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)" | 
| 60758 | 222 | using y \<open>finite r\<close> by (auto intro!: Max_ge) | 
| 55088 
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 | |
| 60758 | 244 | subsection \<open>Default instances for @{class enum}\<close>
 | 
| 26348 | 245 | |
| 26444 | 246 | lemma map_of_zip_enum_is_Some: | 
| 61076 | 247 | assumes "length ys = length (enum :: 'a::enum list)" | 
| 248 | shows "\<exists>y. map_of (zip (enum :: 'a::enum list) ys) x = Some y" | |
| 26444 | 249 | proof - | 
| 61076 | 250 | from assms have "x \<in> set (enum :: 'a::enum list) \<longleftrightarrow> | 
| 251 | (\<exists>y. map_of (zip (enum :: 'a::enum list) ys) x = Some y)" | |
| 26444 | 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: | |
| 61076 | 257 | fixes xs ys :: "'b::enum list" | 
| 258 | assumes length: "length xs = length (enum :: 'a::enum list)" | |
| 259 | "length ys = length (enum :: 'a::enum list)" | |
| 260 | and map_of: "the \<circ> map_of (zip (enum :: 'a::enum list) xs) = the \<circ> map_of (zip (enum :: 'a::enum list) ys)" | |
| 26444 | 261 | shows "xs = ys" | 
| 262 | proof - | |
| 61076 | 263 | have "map_of (zip (enum :: 'a list) xs) = map_of (zip (enum :: 'a list) ys)" | 
| 26444 | 264 | proof | 
| 265 | fix x :: 'a | |
| 266 | from length map_of_zip_enum_is_Some obtain y1 y2 | |
| 61076 | 267 | where "map_of (zip (enum :: 'a list) xs) x = Some y1" | 
| 268 | and "map_of (zip (enum :: 'a list) ys) x = Some y2" by blast | |
| 47230 | 269 | moreover from map_of | 
| 61076 | 270 | have "the (map_of (zip (enum :: 'a::enum list) xs) x) = the (map_of (zip (enum :: 'a::enum list) ys) x)" | 
| 26444 | 271 | by (auto dest: fun_cong) | 
| 61076 | 272 | ultimately show "map_of (zip (enum :: 'a::enum list) xs) x = map_of (zip (enum :: 'a::enum list) ys) x" | 
| 26444 | 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 | |
| 61076 | 300 | "enum = map (\<lambda>ys. the o map_of (zip (enum::'a list) ys)) (List.n_lists (length (enum::'a::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 | 
| 61076 | 309 |   show "UNIV = set (enum :: ('a \<Rightarrow> 'b) list)"
 | 
| 26444 | 310 | proof (rule UNIV_eq_I) | 
| 311 | fix f :: "'a \<Rightarrow> 'b" | |
| 61076 | 312 | have "f = the \<circ> map_of (zip (enum :: 'a::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 | |
| 61076 | 319 |   show "distinct (enum :: ('a \<Rightarrow> 'b) list)"
 | 
| 26444 | 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" | 
| 61076 | 330 | have f: "f = the \<circ> map_of (zip (enum :: 'a::enum list) (map f enum))" | 
| 41078 
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) | 
| 60758 | 332 | from \<open>enum_all P\<close> have "P (the \<circ> map_of (zip enum (map f enum)))" | 
| 41078 
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" .. | 
| 61076 | 355 | have f: "f = the \<circ> map_of (zip (enum :: 'a::enum list) (map f enum))" | 
| 41078 
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) | 
| 61076 | 357 | from \<open>P f\<close> this have "P (the \<circ> map_of (zip (enum :: 'a::enum list) (map f enum)))" | 
| 41078 
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 | ||
| 61076 | 370 | lemma enum_fun_code [code]: "enum = (let enum_a = (enum :: 'a::{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 | |
| 61169 | 449 | instance | 
| 450 | by standard | |
| 451 | (simp_all add: enum_prod_def distinct_product | |
| 452 | enum_UNIV enum_distinct enum_all_prod_def enum_ex_prod_def) | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 453 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 454 | end | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 455 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 456 | instantiation sum :: (enum, enum) enum | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 457 | begin | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 458 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 459 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 460 | "enum = map Inl enum @ map Inr enum" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 461 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 462 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 463 | "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 | 464 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 465 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 466 | "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 | 467 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 468 | instance proof | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 469 | 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 | 470 | auto simp add: enum_UNIV distinct_map enum_distinct) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 471 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 472 | end | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 473 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 474 | instantiation option :: (enum) enum | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 475 | begin | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 476 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 477 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 478 | "enum = None # map Some enum" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 479 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 480 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 481 | "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 | 482 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 483 | definition | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 484 | "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 | 485 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 486 | instance proof | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 487 | 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 | 488 | auto simp add: distinct_map enum_UNIV enum_distinct) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 489 | |
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 490 | end | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 491 | |
| 45963 
1c7e6454883e
enum type class instance for `set`; dropped misfitting code lemma for trancl
 haftmann parents: 
45144diff
changeset | 492 | |
| 60758 | 493 | subsection \<open>Small finite types\<close> | 
| 40647 | 494 | |
| 60758 | 495 | text \<open>We define small finite types for use in Quickcheck\<close> | 
| 40647 | 496 | |
| 58659 
6c9821c32dd5
Local_Interpretation is superseded by Plugin with formal Plugin_Name management, avoiding undeclared strings;
 wenzelm parents: 
58646diff
changeset | 497 | datatype (plugins only: code "quickcheck" extraction) finite_1 = | 
| 58350 
919149921e46
added 'extraction' plugins -- this might help 'HOL-Proofs'
 blanchet parents: 
58334diff
changeset | 498 | a\<^sub>1 | 
| 40647 | 499 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 500 | notation (output) a\<^sub>1  ("a\<^sub>1")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 501 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 502 | 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 | 503 |   "UNIV = {a\<^sub>1}"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 504 | by (auto intro: finite_1.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 505 | |
| 40647 | 506 | instantiation finite_1 :: enum | 
| 507 | begin | |
| 508 | ||
| 509 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 510 | "enum = [a\<^sub>1]" | 
| 40647 | 511 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 512 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 513 | "enum_all P = P a\<^sub>1" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 514 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 515 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 516 | "enum_ex P = P a\<^sub>1" | 
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 517 | |
| 40647 | 518 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 519 | qed (simp_all only: enum_finite_1_def enum_all_finite_1_def enum_ex_finite_1_def UNIV_finite_1, simp_all) | 
| 40647 | 520 | |
| 29024 | 521 | end | 
| 40647 | 522 | |
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 523 | instantiation finite_1 :: linorder | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 524 | begin | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 525 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 526 | definition less_finite_1 :: "finite_1 \<Rightarrow> finite_1 \<Rightarrow> bool" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 527 | where | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 528 | "x < (y :: finite_1) \<longleftrightarrow> False" | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 529 | |
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 530 | 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 | 531 | where | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 532 | "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 | 533 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 534 | instance | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 535 | apply (intro_classes) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 536 | 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 | 537 | apply (metis finite_1.exhaust) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 538 | done | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 539 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 540 | end | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 541 | |
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 542 | instance finite_1 :: "{dense_linorder, wellorder}"
 | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 543 | by intro_classes (simp_all add: less_finite_1_def) | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 544 | |
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 545 | instantiation finite_1 :: complete_lattice | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 546 | begin | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 547 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 548 | definition [simp]: "Inf = (\<lambda>_. a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 549 | definition [simp]: "Sup = (\<lambda>_. a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 550 | definition [simp]: "bot = a\<^sub>1" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 551 | definition [simp]: "top = a\<^sub>1" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 552 | definition [simp]: "inf = (\<lambda>_ _. a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 553 | definition [simp]: "sup = (\<lambda>_ _. a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 554 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 555 | instance by intro_classes(simp_all add: less_eq_finite_1_def) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 556 | end | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 557 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 558 | instance finite_1 :: complete_distrib_lattice | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
61799diff
changeset | 559 | by standard simp_all | 
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 560 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 561 | instance finite_1 :: complete_linorder .. | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 562 | |
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 563 | lemma finite_1_eq: "x = a\<^sub>1" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 564 | by(cases x) simp | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 565 | |
| 60758 | 566 | simproc_setup finite_1_eq ("x::finite_1") = \<open>
 | 
| 59582 | 567 | fn _ => fn _ => fn ct => | 
| 568 | (case Thm.term_of ct of | |
| 569 |       Const (@{const_name a\<^sub>1}, _) => NONE
 | |
| 570 |     | _ => SOME (mk_meta_eq @{thm finite_1_eq}))
 | |
| 60758 | 571 | \<close> | 
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 572 | |
| 59582 | 573 | instantiation finite_1 :: complete_boolean_algebra | 
| 574 | begin | |
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 575 | definition [simp]: "op - = (\<lambda>_ _. a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 576 | definition [simp]: "uminus = (\<lambda>_. a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 577 | instance by intro_classes simp_all | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 578 | end | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 579 | |
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 580 | instantiation finite_1 :: | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 581 |   "{linordered_ring_strict, linordered_comm_semiring_strict, ordered_comm_ring,
 | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 582 | ordered_cancel_comm_monoid_diff, comm_monoid_mult, ordered_ring_abs, | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 583 | one, Divides.div, sgn_if, inverse}" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 584 | begin | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 585 | definition [simp]: "Groups.zero = a\<^sub>1" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 586 | definition [simp]: "Groups.one = a\<^sub>1" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 587 | definition [simp]: "op + = (\<lambda>_ _. a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 588 | definition [simp]: "op * = (\<lambda>_ _. a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 589 | definition [simp]: "op mod = (\<lambda>_ _. a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 590 | definition [simp]: "abs = (\<lambda>_. a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 591 | definition [simp]: "sgn = (\<lambda>_. a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 592 | definition [simp]: "inverse = (\<lambda>_. a\<^sub>1)" | 
| 60352 
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
 haftmann parents: 
59867diff
changeset | 593 | definition [simp]: "divide = (\<lambda>_ _. a\<^sub>1)" | 
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 594 | |
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 595 | instance by intro_classes(simp_all add: less_finite_1_def) | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 596 | end | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 597 | |
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 598 | declare [[simproc del: finite_1_eq]] | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 599 | hide_const (open) a\<^sub>1 | 
| 40657 | 600 | |
| 58659 
6c9821c32dd5
Local_Interpretation is superseded by Plugin with formal Plugin_Name management, avoiding undeclared strings;
 wenzelm parents: 
58646diff
changeset | 601 | datatype (plugins only: code "quickcheck" extraction) finite_2 = | 
| 58350 
919149921e46
added 'extraction' plugins -- this might help 'HOL-Proofs'
 blanchet parents: 
58334diff
changeset | 602 | a\<^sub>1 | a\<^sub>2 | 
| 40647 | 603 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 604 | 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 | 605 | notation (output) a\<^sub>2  ("a\<^sub>2")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 606 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 607 | 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 | 608 |   "UNIV = {a\<^sub>1, a\<^sub>2}"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 609 | by (auto intro: finite_2.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 610 | |
| 40647 | 611 | instantiation finite_2 :: enum | 
| 612 | begin | |
| 613 | ||
| 614 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 615 | "enum = [a\<^sub>1, a\<^sub>2]" | 
| 40647 | 616 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 617 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 618 | "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 | 619 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 620 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 621 | "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 | 622 | |
| 40647 | 623 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 624 | qed (simp_all only: enum_finite_2_def enum_all_finite_2_def enum_ex_finite_2_def UNIV_finite_2, simp_all) | 
| 40647 | 625 | |
| 626 | end | |
| 627 | ||
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 628 | instantiation finite_2 :: linorder | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 629 | begin | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 630 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 631 | 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 | 632 | where | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 633 | "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 | 634 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 635 | 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 | 636 | where | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 637 | "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 | 638 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 639 | instance | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 640 | apply (intro_classes) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 641 | 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 | 642 | apply (metis finite_2.nchotomy)+ | 
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 643 | done | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 644 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 645 | end | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 646 | |
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 647 | instance finite_2 :: wellorder | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 648 | by(rule wf_wellorderI)(simp add: less_finite_2_def, intro_classes) | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 649 | |
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 650 | instantiation finite_2 :: complete_lattice | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 651 | begin | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 652 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 653 | definition "\<Sqinter>A = (if a\<^sub>1 \<in> A then a\<^sub>1 else a\<^sub>2)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 654 | definition "\<Squnion>A = (if a\<^sub>2 \<in> A then a\<^sub>2 else a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 655 | definition [simp]: "bot = a\<^sub>1" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 656 | definition [simp]: "top = a\<^sub>2" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 657 | definition "x \<sqinter> y = (if x = a\<^sub>1 \<or> y = a\<^sub>1 then a\<^sub>1 else a\<^sub>2)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 658 | definition "x \<squnion> y = (if x = a\<^sub>2 \<or> y = a\<^sub>2 then a\<^sub>2 else a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 659 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 660 | lemma neq_finite_2_a\<^sub>1_iff [simp]: "x \<noteq> a\<^sub>1 \<longleftrightarrow> x = a\<^sub>2" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 661 | by(cases x) simp_all | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 662 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 663 | lemma neq_finite_2_a\<^sub>1_iff' [simp]: "a\<^sub>1 \<noteq> x \<longleftrightarrow> x = a\<^sub>2" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 664 | by(cases x) simp_all | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 665 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 666 | lemma neq_finite_2_a\<^sub>2_iff [simp]: "x \<noteq> a\<^sub>2 \<longleftrightarrow> x = a\<^sub>1" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 667 | by(cases x) simp_all | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 668 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 669 | lemma neq_finite_2_a\<^sub>2_iff' [simp]: "a\<^sub>2 \<noteq> x \<longleftrightarrow> x = a\<^sub>1" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 670 | by(cases x) simp_all | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 671 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 672 | instance | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 673 | proof | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 674 | fix x :: finite_2 and A | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 675 | assume "x \<in> A" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 676 | then show "\<Sqinter>A \<le> x" "x \<le> \<Squnion>A" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 677 | by(case_tac [!] x)(auto simp add: less_eq_finite_2_def less_finite_2_def Inf_finite_2_def Sup_finite_2_def) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 678 | qed(auto simp add: less_eq_finite_2_def less_finite_2_def inf_finite_2_def sup_finite_2_def Inf_finite_2_def Sup_finite_2_def) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 679 | end | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 680 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 681 | instance finite_2 :: complete_distrib_lattice | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
61799diff
changeset | 682 | by standard (auto simp add: sup_finite_2_def inf_finite_2_def Inf_finite_2_def Sup_finite_2_def) | 
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 683 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 684 | instance finite_2 :: complete_linorder .. | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 685 | |
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59582diff
changeset | 686 | instantiation finite_2 :: "{field, abs_if, ring_div, sgn_if, semiring_div}" begin
 | 
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 687 | definition [simp]: "0 = a\<^sub>1" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 688 | definition [simp]: "1 = a\<^sub>2" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 689 | definition "x + y = (case (x, y) of (a\<^sub>1, a\<^sub>1) \<Rightarrow> a\<^sub>1 | (a\<^sub>2, a\<^sub>2) \<Rightarrow> a\<^sub>1 | _ \<Rightarrow> a\<^sub>2)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 690 | definition "uminus = (\<lambda>x :: finite_2. x)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 691 | definition "op - = (op + :: finite_2 \<Rightarrow> _)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 692 | definition "x * y = (case (x, y) of (a\<^sub>2, a\<^sub>2) \<Rightarrow> a\<^sub>2 | _ \<Rightarrow> a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 693 | definition "inverse = (\<lambda>x :: finite_2. x)" | 
| 60352 
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
 haftmann parents: 
59867diff
changeset | 694 | definition "divide = (op * :: finite_2 \<Rightarrow> _)" | 
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 695 | definition "abs = (\<lambda>x :: finite_2. x)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 696 | definition "x mod y = (case (x, y) of (a\<^sub>2, a\<^sub>1) \<Rightarrow> a\<^sub>2 | _ \<Rightarrow> a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 697 | definition "sgn = (\<lambda>x :: finite_2. x)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 698 | instance | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 699 | by intro_classes | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 700 | (simp_all add: plus_finite_2_def uminus_finite_2_def minus_finite_2_def times_finite_2_def | 
| 60352 
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
 haftmann parents: 
59867diff
changeset | 701 | inverse_finite_2_def divide_finite_2_def abs_finite_2_def mod_finite_2_def sgn_finite_2_def | 
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 702 | split: finite_2.splits) | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 703 | end | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 704 | |
| 58646 
cd63a4b12a33
specialized specification: avoid trivial instances
 haftmann parents: 
58350diff
changeset | 705 | lemma two_finite_2 [simp]: | 
| 
cd63a4b12a33
specialized specification: avoid trivial instances
 haftmann parents: 
58350diff
changeset | 706 | "2 = a\<^sub>1" | 
| 
cd63a4b12a33
specialized specification: avoid trivial instances
 haftmann parents: 
58350diff
changeset | 707 | by (simp add: numeral.simps plus_finite_2_def) | 
| 
cd63a4b12a33
specialized specification: avoid trivial instances
 haftmann parents: 
58350diff
changeset | 708 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 709 | hide_const (open) a\<^sub>1 a\<^sub>2 | 
| 40657 | 710 | |
| 58659 
6c9821c32dd5
Local_Interpretation is superseded by Plugin with formal Plugin_Name management, avoiding undeclared strings;
 wenzelm parents: 
58646diff
changeset | 711 | datatype (plugins only: code "quickcheck" extraction) finite_3 = | 
| 58350 
919149921e46
added 'extraction' plugins -- this might help 'HOL-Proofs'
 blanchet parents: 
58334diff
changeset | 712 | a\<^sub>1 | a\<^sub>2 | a\<^sub>3 | 
| 40647 | 713 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 714 | 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 | 715 | 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 | 716 | notation (output) a\<^sub>3  ("a\<^sub>3")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 717 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 718 | 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 | 719 |   "UNIV = {a\<^sub>1, a\<^sub>2, a\<^sub>3}"
 | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 720 | by (auto intro: finite_3.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 721 | |
| 40647 | 722 | instantiation finite_3 :: enum | 
| 723 | begin | |
| 724 | ||
| 725 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 726 | "enum = [a\<^sub>1, a\<^sub>2, a\<^sub>3]" | 
| 40647 | 727 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 728 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 729 | "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 | 730 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 731 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 732 | "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 | 733 | |
| 40647 | 734 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 735 | qed (simp_all only: enum_finite_3_def enum_all_finite_3_def enum_ex_finite_3_def UNIV_finite_3, simp_all) | 
| 40647 | 736 | |
| 737 | end | |
| 738 | ||
| 40651 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 739 | instantiation finite_3 :: linorder | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 740 | begin | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 741 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 742 | 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 | 743 | where | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 744 | "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 | 745 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 746 | 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 | 747 | where | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 748 | "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 | 749 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 750 | instance proof (intro_classes) | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 751 | 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 | 752 | |
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 753 | end | 
| 
9752ba7348b5
adding code equation for function equality; adding some instantiations for the finite types
 bulwahn parents: 
40650diff
changeset | 754 | |
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 755 | instance finite_3 :: wellorder | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 756 | proof(rule wf_wellorderI) | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 757 |   have "inv_image less_than (case_finite_3 0 1 2) = {(x, y). x < y}"
 | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 758 | by(auto simp add: less_finite_3_def split: finite_3.splits) | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 759 | from this[symmetric] show "wf \<dots>" by simp | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 760 | qed intro_classes | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 761 | |
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 762 | instantiation finite_3 :: complete_lattice | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 763 | begin | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 764 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 765 | definition "\<Sqinter>A = (if a\<^sub>1 \<in> A then a\<^sub>1 else if a\<^sub>2 \<in> A then a\<^sub>2 else a\<^sub>3)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 766 | definition "\<Squnion>A = (if a\<^sub>3 \<in> A then a\<^sub>3 else if a\<^sub>2 \<in> A then a\<^sub>2 else a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 767 | definition [simp]: "bot = a\<^sub>1" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 768 | definition [simp]: "top = a\<^sub>3" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 769 | definition [simp]: "inf = (min :: finite_3 \<Rightarrow> _)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 770 | definition [simp]: "sup = (max :: finite_3 \<Rightarrow> _)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 771 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 772 | instance | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 773 | proof | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 774 | fix x :: finite_3 and A | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 775 | assume "x \<in> A" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 776 | then show "\<Sqinter>A \<le> x" "x \<le> \<Squnion>A" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 777 | by(case_tac [!] x)(auto simp add: Inf_finite_3_def Sup_finite_3_def less_eq_finite_3_def less_finite_3_def) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 778 | next | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 779 | fix A and z :: finite_3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 780 | assume "\<And>x. x \<in> A \<Longrightarrow> z \<le> x" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 781 | then show "z \<le> \<Sqinter>A" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 782 | by(cases z)(auto simp add: Inf_finite_3_def less_eq_finite_3_def less_finite_3_def) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 783 | next | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 784 | fix A and z :: finite_3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 785 | assume *: "\<And>x. x \<in> A \<Longrightarrow> x \<le> z" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 786 | show "\<Squnion>A \<le> z" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 787 | by(auto simp add: Sup_finite_3_def less_eq_finite_3_def less_finite_3_def dest: *) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 788 | qed(auto simp add: Inf_finite_3_def Sup_finite_3_def) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 789 | end | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 790 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 791 | instance finite_3 :: complete_distrib_lattice | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 792 | proof | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 793 | fix a :: finite_3 and B | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 794 | show "a \<squnion> \<Sqinter>B = (\<Sqinter>b\<in>B. a \<squnion> b)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 795 | proof(cases a "\<Sqinter>B" rule: finite_3.exhaust[case_product finite_3.exhaust]) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 796 | case a\<^sub>2_a\<^sub>3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 797 | then have "\<And>x. x \<in> B \<Longrightarrow> x = a\<^sub>3" | 
| 62390 | 798 | by(case_tac x)(auto simp add: Inf_finite_3_def split: if_split_asm) | 
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 799 | then show ?thesis using a\<^sub>2_a\<^sub>3 | 
| 62390 | 800 | by(auto simp add: Inf_finite_3_def max_def less_eq_finite_3_def less_finite_3_def split: if_split_asm) | 
| 801 | qed (auto simp add: Inf_finite_3_def max_def less_finite_3_def less_eq_finite_3_def split: if_split_asm) | |
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 802 | show "a \<sqinter> \<Squnion>B = (\<Squnion>b\<in>B. a \<sqinter> b)" | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
61799diff
changeset | 803 | by (cases a "\<Squnion>B" rule: finite_3.exhaust[case_product finite_3.exhaust]) | 
| 62390 | 804 | (auto simp add: Sup_finite_3_def min_def less_finite_3_def less_eq_finite_3_def split: if_split_asm) | 
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 805 | qed | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 806 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 807 | instance finite_3 :: complete_linorder .. | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 808 | |
| 59867 
58043346ca64
given up separate type classes demanding `inverse 0 = 0`
 haftmann parents: 
59582diff
changeset | 809 | instantiation finite_3 :: "{field, abs_if, ring_div, semiring_div, sgn_if}" begin
 | 
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 810 | definition [simp]: "0 = a\<^sub>1" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 811 | definition [simp]: "1 = a\<^sub>2" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 812 | definition | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 813 | "x + y = (case (x, y) of | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 814 | (a\<^sub>1, a\<^sub>1) \<Rightarrow> a\<^sub>1 | (a\<^sub>2, a\<^sub>3) \<Rightarrow> a\<^sub>1 | (a\<^sub>3, a\<^sub>2) \<Rightarrow> a\<^sub>1 | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 815 | | (a\<^sub>1, a\<^sub>2) \<Rightarrow> a\<^sub>2 | (a\<^sub>2, a\<^sub>1) \<Rightarrow> a\<^sub>2 | (a\<^sub>3, a\<^sub>3) \<Rightarrow> a\<^sub>2 | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 816 | | _ \<Rightarrow> a\<^sub>3)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 817 | definition "- x = (case x of a\<^sub>1 \<Rightarrow> a\<^sub>1 | a\<^sub>2 \<Rightarrow> a\<^sub>3 | a\<^sub>3 \<Rightarrow> a\<^sub>2)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 818 | definition "x - y = x + (- y :: finite_3)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 819 | definition "x * y = (case (x, y) of (a\<^sub>2, a\<^sub>2) \<Rightarrow> a\<^sub>2 | (a\<^sub>3, a\<^sub>3) \<Rightarrow> a\<^sub>2 | (a\<^sub>2, a\<^sub>3) \<Rightarrow> a\<^sub>3 | (a\<^sub>3, a\<^sub>2) \<Rightarrow> a\<^sub>3 | _ \<Rightarrow> a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 820 | definition "inverse = (\<lambda>x :: finite_3. x)" | 
| 60429 
d3d1e185cd63
uniform _ div _ as infix syntax for ring division
 haftmann parents: 
60352diff
changeset | 821 | definition "x div y = x * inverse (y :: finite_3)" | 
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 822 | definition "abs = (\<lambda>x :: finite_3. x)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 823 | definition "x mod y = (case (x, y) of (a\<^sub>2, a\<^sub>1) \<Rightarrow> a\<^sub>2 | (a\<^sub>3, a\<^sub>1) \<Rightarrow> a\<^sub>3 | _ \<Rightarrow> a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 824 | definition "sgn = (\<lambda>x. case x of a\<^sub>1 \<Rightarrow> a\<^sub>1 | _ \<Rightarrow> a\<^sub>2)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 825 | instance | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 826 | by intro_classes | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 827 | (simp_all add: plus_finite_3_def uminus_finite_3_def minus_finite_3_def times_finite_3_def | 
| 60352 
d46de31a50c4
separate class for division operator, with particular syntax added in more specific classes
 haftmann parents: 
59867diff
changeset | 828 | inverse_finite_3_def divide_finite_3_def abs_finite_3_def mod_finite_3_def sgn_finite_3_def | 
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 829 | less_finite_3_def | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 830 | split: finite_3.splits) | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 831 | end | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 832 | |
| 58646 
cd63a4b12a33
specialized specification: avoid trivial instances
 haftmann parents: 
58350diff
changeset | 833 | |
| 
cd63a4b12a33
specialized specification: avoid trivial instances
 haftmann parents: 
58350diff
changeset | 834 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 835 | hide_const (open) a\<^sub>1 a\<^sub>2 a\<^sub>3 | 
| 40657 | 836 | |
| 58659 
6c9821c32dd5
Local_Interpretation is superseded by Plugin with formal Plugin_Name management, avoiding undeclared strings;
 wenzelm parents: 
58646diff
changeset | 837 | datatype (plugins only: code "quickcheck" extraction) finite_4 = | 
| 58350 
919149921e46
added 'extraction' plugins -- this might help 'HOL-Proofs'
 blanchet parents: 
58334diff
changeset | 838 | a\<^sub>1 | a\<^sub>2 | a\<^sub>3 | a\<^sub>4 | 
| 40647 | 839 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 840 | 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 | 841 | 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 | 842 | 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 | 843 | notation (output) a\<^sub>4  ("a\<^sub>4")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 844 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 845 | 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 | 846 |   "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 | 847 | by (auto intro: finite_4.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 848 | |
| 40647 | 849 | instantiation finite_4 :: enum | 
| 850 | begin | |
| 851 | ||
| 852 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 853 | "enum = [a\<^sub>1, a\<^sub>2, a\<^sub>3, a\<^sub>4]" | 
| 40647 | 854 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 855 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 856 | "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 | 857 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 858 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 859 | "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 | 860 | |
| 40647 | 861 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 862 | qed (simp_all only: enum_finite_4_def enum_all_finite_4_def enum_ex_finite_4_def UNIV_finite_4, simp_all) | 
| 40647 | 863 | |
| 864 | end | |
| 865 | ||
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 866 | instantiation finite_4 :: complete_lattice begin | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 867 | |
| 60758 | 868 | text \<open>@{term a\<^sub>1} $<$ @{term a\<^sub>2},@{term a\<^sub>3} $<$ @{term a\<^sub>4},
 | 
| 869 |   but @{term a\<^sub>2} and @{term a\<^sub>3} are incomparable.\<close>
 | |
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 870 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 871 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 872 | "x < y \<longleftrightarrow> (case (x, y) of | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 873 | (a\<^sub>1, a\<^sub>1) \<Rightarrow> False | (a\<^sub>1, _) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 874 | | (a\<^sub>2, a\<^sub>4) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 875 | | (a\<^sub>3, a\<^sub>4) \<Rightarrow> True | _ \<Rightarrow> False)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 876 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 877 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 878 | "x \<le> y \<longleftrightarrow> (case (x, y) of | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 879 | (a\<^sub>1, _) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 880 | | (a\<^sub>2, a\<^sub>2) \<Rightarrow> True | (a\<^sub>2, a\<^sub>4) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 881 | | (a\<^sub>3, a\<^sub>3) \<Rightarrow> True | (a\<^sub>3, a\<^sub>4) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 882 | | (a\<^sub>4, a\<^sub>4) \<Rightarrow> True | _ \<Rightarrow> False)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 883 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 884 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 885 | "\<Sqinter>A = (if a\<^sub>1 \<in> A \<or> a\<^sub>2 \<in> A \<and> a\<^sub>3 \<in> A then a\<^sub>1 else if a\<^sub>2 \<in> A then a\<^sub>2 else if a\<^sub>3 \<in> A then a\<^sub>3 else a\<^sub>4)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 886 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 887 | "\<Squnion>A = (if a\<^sub>4 \<in> A \<or> a\<^sub>2 \<in> A \<and> a\<^sub>3 \<in> A then a\<^sub>4 else if a\<^sub>2 \<in> A then a\<^sub>2 else if a\<^sub>3 \<in> A then a\<^sub>3 else a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 888 | definition [simp]: "bot = a\<^sub>1" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 889 | definition [simp]: "top = a\<^sub>4" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 890 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 891 | "x \<sqinter> y = (case (x, y) of | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 892 | (a\<^sub>1, _) \<Rightarrow> a\<^sub>1 | (_, a\<^sub>1) \<Rightarrow> a\<^sub>1 | (a\<^sub>2, a\<^sub>3) \<Rightarrow> a\<^sub>1 | (a\<^sub>3, a\<^sub>2) \<Rightarrow> a\<^sub>1 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 893 | | (a\<^sub>2, _) \<Rightarrow> a\<^sub>2 | (_, a\<^sub>2) \<Rightarrow> a\<^sub>2 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 894 | | (a\<^sub>3, _) \<Rightarrow> a\<^sub>3 | (_, a\<^sub>3) \<Rightarrow> a\<^sub>3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 895 | | _ \<Rightarrow> a\<^sub>4)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 896 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 897 | "x \<squnion> y = (case (x, y) of | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 898 | (a\<^sub>4, _) \<Rightarrow> a\<^sub>4 | (_, a\<^sub>4) \<Rightarrow> a\<^sub>4 | (a\<^sub>2, a\<^sub>3) \<Rightarrow> a\<^sub>4 | (a\<^sub>3, a\<^sub>2) \<Rightarrow> a\<^sub>4 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 899 | | (a\<^sub>2, _) \<Rightarrow> a\<^sub>2 | (_, a\<^sub>2) \<Rightarrow> a\<^sub>2 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 900 | | (a\<^sub>3, _) \<Rightarrow> a\<^sub>3 | (_, a\<^sub>3) \<Rightarrow> a\<^sub>3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 901 | | _ \<Rightarrow> a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 902 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 903 | instance | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 904 | proof | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 905 | fix A and z :: finite_4 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 906 | assume *: "\<And>x. x \<in> A \<Longrightarrow> x \<le> z" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 907 | show "\<Squnion>A \<le> z" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 908 | by(auto simp add: Sup_finite_4_def less_eq_finite_4_def dest!: * split: finite_4.splits) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 909 | next | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 910 | fix A and z :: finite_4 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 911 | assume *: "\<And>x. x \<in> A \<Longrightarrow> z \<le> x" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 912 | show "z \<le> \<Sqinter>A" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 913 | by(auto simp add: Inf_finite_4_def less_eq_finite_4_def dest!: * split: finite_4.splits) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 914 | qed(auto simp add: less_finite_4_def less_eq_finite_4_def Inf_finite_4_def Sup_finite_4_def inf_finite_4_def sup_finite_4_def split: finite_4.splits) | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 915 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 916 | end | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 917 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 918 | instance finite_4 :: complete_distrib_lattice | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 919 | proof | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 920 | fix a :: finite_4 and B | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 921 | show "a \<squnion> \<Sqinter>B = (\<Sqinter>b\<in>B. a \<squnion> b)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 922 | by(cases a "\<Sqinter>B" rule: finite_4.exhaust[case_product finite_4.exhaust]) | 
| 62390 | 923 | (auto simp add: sup_finite_4_def Inf_finite_4_def split: finite_4.splits if_split_asm) | 
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 924 | show "a \<sqinter> \<Squnion>B = (\<Squnion>b\<in>B. a \<sqinter> b)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 925 | by(cases a "\<Squnion>B" rule: finite_4.exhaust[case_product finite_4.exhaust]) | 
| 62390 | 926 | (auto simp add: inf_finite_4_def Sup_finite_4_def split: finite_4.splits if_split_asm) | 
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 927 | qed | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 928 | |
| 57922 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 929 | instantiation finite_4 :: complete_boolean_algebra begin | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 930 | definition "- x = (case x of a\<^sub>1 \<Rightarrow> a\<^sub>4 | a\<^sub>2 \<Rightarrow> a\<^sub>3 | a\<^sub>3 \<Rightarrow> a\<^sub>2 | a\<^sub>4 \<Rightarrow> a\<^sub>1)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 931 | definition "x - y = x \<sqinter> - (y :: finite_4)" | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 932 | instance | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 933 | by intro_classes | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 934 | (simp_all add: inf_finite_4_def sup_finite_4_def uminus_finite_4_def minus_finite_4_def split: finite_4.splits) | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 935 | end | 
| 
dc78785427d0
add algebraic type class instances for Enum.finite* types
 Andreas Lochbihler parents: 
57818diff
changeset | 936 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 937 | 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 | 938 | |
| 58659 
6c9821c32dd5
Local_Interpretation is superseded by Plugin with formal Plugin_Name management, avoiding undeclared strings;
 wenzelm parents: 
58646diff
changeset | 939 | datatype (plugins only: code "quickcheck" extraction) finite_5 = | 
| 58350 
919149921e46
added 'extraction' plugins -- this might help 'HOL-Proofs'
 blanchet parents: 
58334diff
changeset | 940 | a\<^sub>1 | a\<^sub>2 | a\<^sub>3 | a\<^sub>4 | a\<^sub>5 | 
| 40647 | 941 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 942 | 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 | 943 | 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 | 944 | 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 | 945 | 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 | 946 | notation (output) a\<^sub>5  ("a\<^sub>5")
 | 
| 40900 
1d5f76d79856
adding shorter output syntax for the finite types of quickcheck
 bulwahn parents: 
40898diff
changeset | 947 | |
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 948 | 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 | 949 |   "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 | 950 | by (auto intro: finite_5.exhaust) | 
| 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 951 | |
| 40647 | 952 | instantiation finite_5 :: enum | 
| 953 | begin | |
| 954 | ||
| 955 | definition | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 956 | "enum = [a\<^sub>1, a\<^sub>2, a\<^sub>3, a\<^sub>4, a\<^sub>5]" | 
| 40647 | 957 | |
| 41078 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 958 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 959 | "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 | 960 | |
| 
051251fde456
adding more efficient implementations for quantifiers in Enum
 bulwahn parents: 
40900diff
changeset | 961 | definition | 
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 962 | "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 | 963 | |
| 40647 | 964 | instance proof | 
| 49950 
cd882d53ba6b
tailored enum specification towards simple instantiation;
 haftmann parents: 
49949diff
changeset | 965 | qed (simp_all only: enum_finite_5_def enum_all_finite_5_def enum_ex_finite_5_def UNIV_finite_5, simp_all) | 
| 40647 | 966 | |
| 967 | end | |
| 968 | ||
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 969 | instantiation finite_5 :: complete_lattice | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 970 | begin | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 971 | |
| 60758 | 972 | text \<open>The non-distributive pentagon lattice $N_5$\<close> | 
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 973 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 974 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 975 | "x < y \<longleftrightarrow> (case (x, y) of | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 976 | (a\<^sub>1, a\<^sub>1) \<Rightarrow> False | (a\<^sub>1, _) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 977 | | (a\<^sub>2, a\<^sub>3) \<Rightarrow> True | (a\<^sub>2, a\<^sub>5) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 978 | | (a\<^sub>3, a\<^sub>5) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 979 | | (a\<^sub>4, a\<^sub>5) \<Rightarrow> True | _ \<Rightarrow> False)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 980 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 981 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 982 | "x \<le> y \<longleftrightarrow> (case (x, y) of | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 983 | (a\<^sub>1, _) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 984 | | (a\<^sub>2, a\<^sub>2) \<Rightarrow> True | (a\<^sub>2, a\<^sub>3) \<Rightarrow> True | (a\<^sub>2, a\<^sub>5) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 985 | | (a\<^sub>3, a\<^sub>3) \<Rightarrow> True | (a\<^sub>3, a\<^sub>5) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 986 | | (a\<^sub>4, a\<^sub>4) \<Rightarrow> True | (a\<^sub>4, a\<^sub>5) \<Rightarrow> True | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 987 | | (a\<^sub>5, a\<^sub>5) \<Rightarrow> True | _ \<Rightarrow> False)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 988 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 989 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 990 | "\<Sqinter>A = | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 991 | (if a\<^sub>1 \<in> A \<or> a\<^sub>4 \<in> A \<and> (a\<^sub>2 \<in> A \<or> a\<^sub>3 \<in> A) then a\<^sub>1 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 992 | else if a\<^sub>2 \<in> A then a\<^sub>2 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 993 | else if a\<^sub>3 \<in> A then a\<^sub>3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 994 | else if a\<^sub>4 \<in> A then a\<^sub>4 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 995 | else a\<^sub>5)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 996 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 997 | "\<Squnion>A = | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 998 | (if a\<^sub>5 \<in> A \<or> a\<^sub>4 \<in> A \<and> (a\<^sub>2 \<in> A \<or> a\<^sub>3 \<in> A) then a\<^sub>5 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 999 | else if a\<^sub>3 \<in> A then a\<^sub>3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1000 | else if a\<^sub>2 \<in> A then a\<^sub>2 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1001 | else if a\<^sub>4 \<in> A then a\<^sub>4 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1002 | else a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1003 | definition [simp]: "bot = a\<^sub>1" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1004 | definition [simp]: "top = a\<^sub>5" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1005 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1006 | "x \<sqinter> y = (case (x, y) of | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1007 | (a\<^sub>1, _) \<Rightarrow> a\<^sub>1 | (_, a\<^sub>1) \<Rightarrow> a\<^sub>1 | (a\<^sub>2, a\<^sub>4) \<Rightarrow> a\<^sub>1 | (a\<^sub>4, a\<^sub>2) \<Rightarrow> a\<^sub>1 | (a\<^sub>3, a\<^sub>4) \<Rightarrow> a\<^sub>1 | (a\<^sub>4, a\<^sub>3) \<Rightarrow> a\<^sub>1 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1008 | | (a\<^sub>2, _) \<Rightarrow> a\<^sub>2 | (_, a\<^sub>2) \<Rightarrow> a\<^sub>2 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1009 | | (a\<^sub>3, _) \<Rightarrow> a\<^sub>3 | (_, a\<^sub>3) \<Rightarrow> a\<^sub>3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1010 | | (a\<^sub>4, _) \<Rightarrow> a\<^sub>4 | (_, a\<^sub>4) \<Rightarrow> a\<^sub>4 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1011 | | _ \<Rightarrow> a\<^sub>5)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1012 | definition | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1013 | "x \<squnion> y = (case (x, y) of | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1014 | (a\<^sub>5, _) \<Rightarrow> a\<^sub>5 | (_, a\<^sub>5) \<Rightarrow> a\<^sub>5 | (a\<^sub>2, a\<^sub>4) \<Rightarrow> a\<^sub>5 | (a\<^sub>4, a\<^sub>2) \<Rightarrow> a\<^sub>5 | (a\<^sub>3, a\<^sub>4) \<Rightarrow> a\<^sub>5 | (a\<^sub>4, a\<^sub>3) \<Rightarrow> a\<^sub>5 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1015 | | (a\<^sub>3, _) \<Rightarrow> a\<^sub>3 | (_, a\<^sub>3) \<Rightarrow> a\<^sub>3 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1016 | | (a\<^sub>2, _) \<Rightarrow> a\<^sub>2 | (_, a\<^sub>2) \<Rightarrow> a\<^sub>2 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1017 | | (a\<^sub>4, _) \<Rightarrow> a\<^sub>4 | (_, a\<^sub>4) \<Rightarrow> a\<^sub>4 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1018 | | _ \<Rightarrow> a\<^sub>1)" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1019 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1020 | instance | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1021 | proof intro_classes | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1022 | fix A and z :: finite_5 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1023 | assume *: "\<And>x. x \<in> A \<Longrightarrow> z \<le> x" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1024 | show "z \<le> \<Sqinter>A" | 
| 62390 | 1025 | by(auto simp add: less_eq_finite_5_def Inf_finite_5_def split: finite_5.splits if_split_asm dest!: *) | 
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1026 | next | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1027 | fix A and z :: finite_5 | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1028 | assume *: "\<And>x. x \<in> A \<Longrightarrow> x \<le> z" | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1029 | show "\<Squnion>A \<le> z" | 
| 62390 | 1030 | by(auto simp add: less_eq_finite_5_def Sup_finite_5_def split: finite_5.splits if_split_asm dest!: *) | 
| 1031 | qed(auto simp add: less_eq_finite_5_def less_finite_5_def inf_finite_5_def sup_finite_5_def Inf_finite_5_def Sup_finite_5_def split: finite_5.splits if_split_asm) | |
| 57818 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1032 | |
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1033 | end | 
| 
51aa30c9ee4e
add complete_lattice instances for Enum.finite_* types such that quickcheck deals with lattice class operations
 Andreas Lochbihler parents: 
57247diff
changeset | 1034 | |
| 53015 
a1119cf551e8
standardized symbols via "isabelle update_sub_sup", excluding src/Pure and src/Tools/WWW_Find;
 wenzelm parents: 
52435diff
changeset | 1035 | 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 | 1036 | |
| 49948 
744934b818c7
moved quite generic material from theory Enum to more appropriate places
 haftmann parents: 
48123diff
changeset | 1037 | |
| 60758 | 1038 | subsection \<open>Closing up\<close> | 
| 40657 | 1039 | |
| 41085 
a549ff1d4070
adding a smarter enumeration scheme for finite functions
 bulwahn parents: 
41078diff
changeset | 1040 | 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 | 1041 | hide_const (open) enum enum_all enum_ex all_n_lists ex_n_lists ntrancl | 
| 40647 | 1042 | |
| 1043 | end |