equal
deleted
inserted
replaced
118 |
118 |
119 subsection {* Some instances of the type class of complete lattices *} |
119 subsection {* Some instances of the type class of complete lattices *} |
120 |
120 |
121 subsubsection {* Booleans *} |
121 subsubsection {* Booleans *} |
122 |
122 |
123 instance bool :: ord .. |
|
124 |
|
125 defs |
|
126 le_bool_def: "P <= Q == P \<longrightarrow> Q" |
|
127 less_bool_def: "P < Q == (P::bool) <= Q \<and> P \<noteq> Q" |
|
128 |
|
129 theorem le_boolI: "(P \<Longrightarrow> Q) \<Longrightarrow> P <= Q" |
|
130 by (simp add: le_bool_def) |
|
131 |
|
132 theorem le_boolI': "P \<longrightarrow> Q \<Longrightarrow> P <= Q" |
|
133 by (simp add: le_bool_def) |
|
134 |
|
135 theorem le_boolE: "P <= Q \<Longrightarrow> P \<Longrightarrow> (Q \<Longrightarrow> R) \<Longrightarrow> R" |
|
136 by (simp add: le_bool_def) |
|
137 |
|
138 theorem le_boolD: "P <= Q \<Longrightarrow> P \<longrightarrow> Q" |
|
139 by (simp add: le_bool_def) |
|
140 |
|
141 instance bool :: order |
|
142 apply intro_classes |
|
143 apply (unfold le_bool_def less_bool_def) |
|
144 apply iprover+ |
|
145 done |
|
146 |
|
147 defs Meet_bool_def: "Meet A == ALL x:A. x" |
123 defs Meet_bool_def: "Meet A == ALL x:A. x" |
148 |
124 |
149 instance bool :: comp_lat |
125 instance bool :: comp_lat |
150 apply intro_classes |
126 apply intro_classes |
151 apply (unfold Meet_bool_def) |
127 apply (unfold Meet_bool_def) |
199 apply assumption+ |
175 apply assumption+ |
200 done |
176 done |
201 |
177 |
202 subsubsection {* Functions *} |
178 subsubsection {* Functions *} |
203 |
179 |
204 instance "fun" :: (type, ord) ord .. |
|
205 |
|
206 defs |
|
207 le_fun_def: "f <= g == \<forall>x. f x <= g x" |
|
208 less_fun_def: "f < g == (f::'a\<Rightarrow>'b::ord) <= g \<and> f \<noteq> g" |
|
209 |
|
210 theorem le_funI: "(\<And>x. f x <= g x) \<Longrightarrow> f <= g" |
|
211 by (simp add: le_fun_def) |
|
212 |
|
213 theorem le_funE: "f <= g \<Longrightarrow> (f x <= g x \<Longrightarrow> P) \<Longrightarrow> P" |
|
214 by (simp add: le_fun_def) |
|
215 |
|
216 theorem le_funD: "f <= g \<Longrightarrow> f x <= g x" |
|
217 by (simp add: le_fun_def) |
|
218 |
|
219 text {* |
180 text {* |
220 Handy introduction and elimination rules for @{text "\<le>"} |
181 Handy introduction and elimination rules for @{text "\<le>"} |
221 on unary and binary predicates |
182 on unary and binary predicates |
222 *} |
183 *} |
223 |
184 |
247 |
208 |
248 lemma predicate2D [elim]: "P \<le> Q \<Longrightarrow> P x y \<Longrightarrow> Q x y" |
209 lemma predicate2D [elim]: "P \<le> Q \<Longrightarrow> P x y \<Longrightarrow> Q x y" |
249 apply (erule le_funE)+ |
210 apply (erule le_funE)+ |
250 apply (erule le_boolE) |
211 apply (erule le_boolE) |
251 apply assumption+ |
212 apply assumption+ |
252 done |
|
253 |
|
254 instance "fun" :: (type, order) order |
|
255 apply intro_classes |
|
256 apply (rule le_funI) |
|
257 apply (rule order_refl) |
|
258 apply (rule le_funI) |
|
259 apply (erule le_funE)+ |
|
260 apply (erule order_trans) |
|
261 apply assumption |
|
262 apply (rule ext) |
|
263 apply (erule le_funE)+ |
|
264 apply (erule order_antisym) |
|
265 apply assumption |
|
266 apply (simp add: less_fun_def) |
|
267 done |
213 done |
268 |
214 |
269 defs Meet_fun_def: "Meet A == (\<lambda>x. Meet {y. EX f:A. y = f x})" |
215 defs Meet_fun_def: "Meet A == (\<lambda>x. Meet {y. EX f:A. y = f x})" |
270 |
216 |
271 instance "fun" :: (type, comp_lat) comp_lat |
217 instance "fun" :: (type, comp_lat) comp_lat |