equal
deleted
inserted
replaced
73 lemma max_of_mono: |
73 lemma max_of_mono: |
74 "!x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)" |
74 "!x y. (f x <= f y) = (x <= y) ==> max (f m) (f n) = f (max m n)" |
75 apply (simp add: max_def) |
75 apply (simp add: max_def) |
76 done |
76 done |
77 |
77 |
|
78 |
|
79 (** Least value operator **) |
|
80 |
78 constdefs |
81 constdefs |
79 LeastM :: "['a => 'b::ord, 'a => bool] => 'a" |
82 LeastM :: "['a => 'b::ord, 'a => bool] => 'a" |
80 "LeastM m P == @x. P x & (!y. P y --> m x <= m y)" |
83 "LeastM m P == @x. P x & (!y. P y --> m x <= m y)" |
81 Least :: "('a::ord => bool) => 'a" (binder "LEAST " 10) |
84 Least :: "('a::ord => bool) => 'a" (binder "LEAST " 10) |
82 "Least == LeastM (%x. x)" |
85 "Least == LeastM (%x. x)" |
88 |
91 |
89 lemma LeastMI2: "[| P x; !!y. P y ==> m x <= m y; |
92 lemma LeastMI2: "[| P x; !!y. P y ==> m x <= m y; |
90 !!x. [| P x; \<forall>y. P y --> m x \<le> m y |] ==> Q x |
93 !!x. [| P x; \<forall>y. P y --> m x \<le> m y |] ==> Q x |
91 |] ==> Q (LeastM m P)"; |
94 |] ==> Q (LeastM m P)"; |
92 apply (unfold LeastM_def) |
95 apply (unfold LeastM_def) |
|
96 apply (rule someI2_ex) |
|
97 apply blast |
|
98 apply blast |
|
99 done |
|
100 |
|
101 |
|
102 (** Greatest value operator **) |
|
103 |
|
104 constdefs |
|
105 GreatestM :: "['a => 'b::ord, 'a => bool] => 'a" |
|
106 "GreatestM m P == @x. P x & (!y. P y --> m y <= m x)" |
|
107 |
|
108 Greatest :: "('a::ord => bool) => 'a" (binder "GREATEST " 10) |
|
109 "Greatest == GreatestM (%x. x)" |
|
110 |
|
111 syntax |
|
112 "@GreatestM" :: "[pttrn, 'a=>'b::ord, bool] => 'a" |
|
113 ("GREATEST _ WRT _. _" [0,4,10]10) |
|
114 |
|
115 translations |
|
116 "GREATEST x WRT m. P" == "GreatestM m (%x. P)" |
|
117 |
|
118 lemma GreatestMI2: |
|
119 "[| P x; |
|
120 !!y. P y ==> m y <= m x; |
|
121 !!x. [| P x; \<forall>y. P y --> m y \<le> m x |] ==> Q x |] |
|
122 ==> Q (GreatestM m P)"; |
|
123 apply (unfold GreatestM_def) |
93 apply (rule someI2_ex) |
124 apply (rule someI2_ex) |
94 apply blast |
125 apply blast |
95 apply blast |
126 apply blast |
96 done |
127 done |
97 |
128 |
196 |
227 |
197 lemma Least_equality: |
228 lemma Least_equality: |
198 "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"; |
229 "[| P (k::'a::order); !!x. P x ==> k <= x |] ==> (LEAST x. P x) = k"; |
199 apply (unfold Least_def) |
230 apply (unfold Least_def) |
200 apply (erule LeastM_equality) |
231 apply (erule LeastM_equality) |
|
232 apply blast |
|
233 done |
|
234 |
|
235 lemma GreatestM_equality: |
|
236 "[| P k; !!x. P x ==> m x <= m k |] |
|
237 ==> m (GREATEST x WRT m. P x) = (m k::'a::order)"; |
|
238 apply (rule_tac m=m in GreatestMI2) |
|
239 apply assumption |
|
240 apply blast |
|
241 apply (blast intro!: order_antisym) |
|
242 done |
|
243 |
|
244 lemma Greatest_equality: |
|
245 "[| P (k::'a::order); !!x. P x ==> x <= k |] ==> (GREATEST x. P x) = k"; |
|
246 apply (unfold Greatest_def) |
|
247 apply (erule GreatestM_equality) |
201 apply blast |
248 apply blast |
202 done |
249 done |
203 |
250 |
204 |
251 |
205 section "Linear/Total Orders" |
252 section "Linear/Total Orders" |
365 val max_leastL = thm "max_leastL"; |
412 val max_leastL = thm "max_leastL"; |
366 val LeastMI2 = thm "LeastMI2"; |
413 val LeastMI2 = thm "LeastMI2"; |
367 val LeastM_equality = thm "LeastM_equality"; |
414 val LeastM_equality = thm "LeastM_equality"; |
368 val Least_def = thm "Least_def"; |
415 val Least_def = thm "Least_def"; |
369 val Least_equality = thm "Least_equality"; |
416 val Least_equality = thm "Least_equality"; |
|
417 val GreatestM_def = thm "GreatestM_def"; |
|
418 val GreatestMI2 = thm "GreatestMI2"; |
|
419 val GreatestM_equality = thm "GreatestM_equality"; |
|
420 val Greatest_def = thm "Greatest_def"; |
|
421 val Greatest_equality = thm "Greatest_equality"; |
370 val min_leastR = thm "min_leastR"; |
422 val min_leastR = thm "min_leastR"; |
371 val max_leastR = thm "max_leastR"; |
423 val max_leastR = thm "max_leastR"; |
372 val order_eq_refl = thm "order_eq_refl"; |
424 val order_eq_refl = thm "order_eq_refl"; |
373 val order_less_irrefl = thm "order_less_irrefl"; |
425 val order_less_irrefl = thm "order_less_irrefl"; |
374 val order_le_less = thm "order_le_less"; |
426 val order_le_less = thm "order_le_less"; |