equal
deleted
inserted
replaced
1 (* Title: HOL/Orderings.thy |
1 (* Title: HOL/Orderings.thy |
2 ID: $Id$ |
2 ID: $Id$ |
3 Author: Tobias Nipkow, Markus Wenzel, and Larry Paulson |
3 Author: Tobias Nipkow, Markus Wenzel, and Larry Paulson |
4 *) |
4 *) |
5 |
5 |
6 header {* Abstract orderings *} |
6 header {* Abstract orderings *} |
7 |
7 |
8 theory Orderings |
8 theory Orderings |
9 imports Code_Setup |
9 imports Code_Setup |
10 uses |
10 uses "~~/src/Provers/order.ML" |
11 "~~/src/Provers/order.ML" |
|
12 begin |
11 begin |
13 |
12 |
14 subsection {* Quasi orders *} |
13 subsection {* Quasi orders *} |
15 |
14 |
16 class preorder = ord + |
15 class preorder = ord + |
227 |
226 |
228 |
227 |
229 text {* min/max *} |
228 text {* min/max *} |
230 |
229 |
231 definition (in ord) min :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where |
230 definition (in ord) min :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where |
232 [code unfold, code inline del]: "min a b = (if a \<le> b then a else b)" |
231 [code del]: "min a b = (if a \<le> b then a else b)" |
233 |
232 |
234 definition (in ord) max :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where |
233 definition (in ord) max :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where |
235 [code unfold, code inline del]: "max a b = (if a \<le> b then b else a)" |
234 [code del]: "max a b = (if a \<le> b then b else a)" |
236 |
235 |
237 lemma min_le_iff_disj: |
236 lemma min_le_iff_disj: |
238 "min x y \<le> z \<longleftrightarrow> x \<le> z \<or> y \<le> z" |
237 "min x y \<le> z \<longleftrightarrow> x \<le> z \<or> y \<le> z" |
239 unfolding min_def using linear by (auto intro: order_trans) |
238 unfolding min_def using linear by (auto intro: order_trans) |
240 |
239 |
265 lemma split_max [noatp]: |
264 lemma split_max [noatp]: |
266 "P (max i j) \<longleftrightarrow> (i \<le> j \<longrightarrow> P j) \<and> (\<not> i \<le> j \<longrightarrow> P i)" |
265 "P (max i j) \<longleftrightarrow> (i \<le> j \<longrightarrow> P j) \<and> (\<not> i \<le> j \<longrightarrow> P i)" |
267 by (simp add: max_def) |
266 by (simp add: max_def) |
268 |
267 |
269 end |
268 end |
|
269 |
|
270 text {* Explicit dictionaries for code generation *} |
|
271 |
|
272 lemma min_ord_min [code, code unfold, code inline del]: |
|
273 "min = ord.min (op \<le>)" |
|
274 by (rule ext)+ (simp add: min_def ord.min_def) |
|
275 |
|
276 declare ord.min_def [code] |
|
277 |
|
278 lemma max_ord_max [code, code unfold, code inline del]: |
|
279 "max = ord.max (op \<le>)" |
|
280 by (rule ext)+ (simp add: max_def ord.max_def) |
|
281 |
|
282 declare ord.max_def [code] |
270 |
283 |
271 |
284 |
272 subsection {* Reasoning tools setup *} |
285 subsection {* Reasoning tools setup *} |
273 |
286 |
274 ML {* |
287 ML {* |