author  wenzelm 
Tue, 19 Jun 2007 23:15:23 +0200  
changeset 23417  42c1a89b45c1 
parent 23263  0c227412b285 
child 23881  851c74f1bb69 
permissions  rwrr 
15524  1 
(* Title: HOL/Orderings.thy 
2 
ID: $Id$ 

3 
Author: Tobias Nipkow, Markus Wenzel, and Larry Paulson 

4 
*) 

5 

21329  6 
header {* Syntactic and abstract orders *} 
15524  7 

8 
theory Orderings 

23247  9 
imports HOL 
23263  10 
uses 
11 
(*"~~/src/Provers/quasi.ML"*) 

12 
"~~/src/Provers/order.ML" 

15524  13 
begin 
14 

21329  15 
subsection {* Order syntax *} 
15524  16 

22473  17 
class ord = type + 
21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

18 
fixes less_eq :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubseteq>" 50) 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

19 
and less :: "'a \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<sqsubset>" 50) 
21204  20 
begin 
21 

22 
notation 

21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

23 
less_eq ("op \<^loc><=") and 
21620  24 
less_eq ("(_/ \<^loc><= _)" [51, 51] 50) and 
21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

25 
less ("op \<^loc><") and 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

26 
less ("(_/ \<^loc>< _)" [51, 51] 50) 
21620  27 

21204  28 
notation (xsymbols) 
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21383
diff
changeset

29 
less_eq ("op \<^loc>\<le>") and 
21259
63ab016c99ca
modified less/less_eq syntax to avoid "x < y < z" etc.;
wenzelm
parents:
21248
diff
changeset

30 
less_eq ("(_/ \<^loc>\<le> _)" [51, 51] 50) 
15524  31 

21204  32 
notation (HTML output) 
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21383
diff
changeset

33 
less_eq ("op \<^loc>\<le>") and 
21259
63ab016c99ca
modified less/less_eq syntax to avoid "x < y < z" etc.;
wenzelm
parents:
21248
diff
changeset

34 
less_eq ("(_/ \<^loc>\<le> _)" [51, 51] 50) 
21204  35 

36 
abbreviation (input) 

21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

37 
greater (infix "\<^loc>>" 50) where 
21620  38 
"x \<^loc>> y \<equiv> y \<^loc>< x" 
39 

21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

40 
abbreviation (input) 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

41 
greater_eq (infix "\<^loc>>=" 50) where 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

42 
"x \<^loc>>= y \<equiv> y \<^loc><= x" 
21204  43 

21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

44 
notation (input) 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

45 
greater_eq (infix "\<^loc>\<ge>" 50) 
21204  46 

22738  47 
text {* 
48 
syntactic min/max  these definitions reach 

49 
their usual semantics in class linorder ahead. 

50 
*} 

51 

52 
definition 

53 
min :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where 

22841  54 
"min a b = (if a \<^loc>\<le> b then a else b)" 
22738  55 

56 
definition 

57 
max :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" where 

22841  58 
"max a b = (if a \<^loc>\<le> b then b else a)" 
22738  59 

21204  60 
end 
61 

62 
notation 

21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

63 
less_eq ("op <=") and 
21620  64 
less_eq ("(_/ <= _)" [51, 51] 50) and 
21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

65 
less ("op <") and 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

66 
less ("(_/ < _)" [51, 51] 50) 
21204  67 

68 
notation (xsymbols) 

21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21383
diff
changeset

69 
less_eq ("op \<le>") and 
21259
63ab016c99ca
modified less/less_eq syntax to avoid "x < y < z" etc.;
wenzelm
parents:
21248
diff
changeset

70 
less_eq ("(_/ \<le> _)" [51, 51] 50) 
15524  71 

21204  72 
notation (HTML output) 
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21383
diff
changeset

73 
less_eq ("op \<le>") and 
21259
63ab016c99ca
modified less/less_eq syntax to avoid "x < y < z" etc.;
wenzelm
parents:
21248
diff
changeset

74 
less_eq ("(_/ \<le> _)" [51, 51] 50) 
20714  75 

19536  76 
abbreviation (input) 
21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

77 
greater (infix ">" 50) where 
21620  78 
"x > y \<equiv> y < x" 
79 

21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

80 
abbreviation (input) 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

81 
greater_eq (infix ">=" 50) where 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

82 
"x >= y \<equiv> y <= x" 
21620  83 

21656
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

84 
notation (input) 
43d709faa9dc
restored notation for less/less_eq (observe proper order of mixfix annotations!);
wenzelm
parents:
21620
diff
changeset

85 
greater_eq (infix "\<ge>" 50) 
15524  86 

23087  87 
lemmas min_def [code func, code unfold, code inline del] = min_def [folded ord_class.min] 
88 
lemmas max_def [code func, code unfold, code inline del] = max_def [folded ord_class.max] 

22738  89 

15524  90 

22841  91 
subsection {* Partial orders *} 
15524  92 

22841  93 
class order = ord + 
22316  94 
assumes less_le: "x \<sqsubset> y \<longleftrightarrow> x \<sqsubseteq> y \<and> x \<noteq> y" 
22384
33a46e6c7f04
prefix of class interpretation not mandatory any longer
haftmann
parents:
22377
diff
changeset

95 
and order_refl [iff]: "x \<sqsubseteq> x" 
33a46e6c7f04
prefix of class interpretation not mandatory any longer
haftmann
parents:
22377
diff
changeset

96 
and order_trans: "x \<sqsubseteq> y \<Longrightarrow> y \<sqsubseteq> z \<Longrightarrow> x \<sqsubseteq> z" 
22841  97 
assumes antisym: "x \<sqsubseteq> y \<Longrightarrow> y \<sqsubseteq> x \<Longrightarrow> x = y" 
98 

21248  99 
begin 
100 

15524  101 
text {* Reflexivity. *} 
102 

22841  103 
lemma eq_refl: "x = y \<Longrightarrow> x \<^loc>\<le> y" 
15524  104 
 {* This form is useful with the classical reasoner. *} 
23212  105 
by (erule ssubst) (rule order_refl) 
15524  106 

22841  107 
lemma less_irrefl [iff]: "\<not> x \<^loc>< x" 
23212  108 
by (simp add: less_le) 
15524  109 

22841  110 
lemma le_less: "x \<^loc>\<le> y \<longleftrightarrow> x \<^loc>< y \<or> x = y" 
15524  111 
 {* NOT suitable for iff, since it can cause PROOF FAILED. *} 
23212  112 
by (simp add: less_le) blast 
15524  113 

22841  114 
lemma le_imp_less_or_eq: "x \<^loc>\<le> y \<Longrightarrow> x \<^loc>< y \<or> x = y" 
23212  115 
unfolding less_le by blast 
15524  116 

22841  117 
lemma less_imp_le: "x \<^loc>< y \<Longrightarrow> x \<^loc>\<le> y" 
23212  118 
unfolding less_le by blast 
21248  119 

22841  120 
lemma less_imp_neq: "x \<^loc>< y \<Longrightarrow> x \<noteq> y" 
23212  121 
by (erule contrapos_pn, erule subst, rule less_irrefl) 
21329  122 

123 

124 
text {* Useful for simplification, but too risky to include by default. *} 

125 

22841  126 
lemma less_imp_not_eq: "x \<^loc>< y \<Longrightarrow> (x = y) \<longleftrightarrow> False" 
23212  127 
by auto 
21329  128 

22841  129 
lemma less_imp_not_eq2: "x \<^loc>< y \<Longrightarrow> (y = x) \<longleftrightarrow> False" 
23212  130 
by auto 
21329  131 

132 

133 
text {* Transitivity rules for calculational reasoning *} 

134 

22841  135 
lemma neq_le_trans: "a \<noteq> b \<Longrightarrow> a \<^loc>\<le> b \<Longrightarrow> a \<^loc>< b" 
23212  136 
by (simp add: less_le) 
21329  137 

22841  138 
lemma le_neq_trans: "a \<^loc>\<le> b \<Longrightarrow> a \<noteq> b \<Longrightarrow> a \<^loc>< b" 
23212  139 
by (simp add: less_le) 
21329  140 

15524  141 

142 
text {* Asymmetry. *} 

143 

22841  144 
lemma less_not_sym: "x \<^loc>< y \<Longrightarrow> \<not> (y \<^loc>< x)" 
23212  145 
by (simp add: less_le antisym) 
15524  146 

22841  147 
lemma less_asym: "x \<^loc>< y \<Longrightarrow> (\<not> P \<Longrightarrow> y \<^loc>< x) \<Longrightarrow> P" 
23212  148 
by (drule less_not_sym, erule contrapos_np) simp 
15524  149 

22841  150 
lemma eq_iff: "x = y \<longleftrightarrow> x \<^loc>\<le> y \<and> y \<^loc>\<le> x" 
23212  151 
by (blast intro: antisym) 
15524  152 

22841  153 
lemma antisym_conv: "y \<^loc>\<le> x \<Longrightarrow> x \<^loc>\<le> y \<longleftrightarrow> x = y" 
23212  154 
by (blast intro: antisym) 
15524  155 

22841  156 
lemma less_imp_neq: "x \<^loc>< y \<Longrightarrow> x \<noteq> y" 
23212  157 
by (erule contrapos_pn, erule subst, rule less_irrefl) 
21248  158 

21083  159 

15524  160 
text {* Transitivity. *} 
161 

22841  162 
lemma less_trans: "x \<^loc>< y \<Longrightarrow> y \<^loc>< z \<Longrightarrow> x \<^loc>< z" 
23212  163 
by (simp add: less_le) (blast intro: order_trans antisym) 
15524  164 

22841  165 
lemma le_less_trans: "x \<^loc>\<le> y \<Longrightarrow> y \<^loc>< z \<Longrightarrow> x \<^loc>< z" 
23212  166 
by (simp add: less_le) (blast intro: order_trans antisym) 
15524  167 

22841  168 
lemma less_le_trans: "x \<^loc>< y \<Longrightarrow> y \<^loc>\<le> z \<Longrightarrow> x \<^loc>< z" 
23212  169 
by (simp add: less_le) (blast intro: order_trans antisym) 
15524  170 

171 

172 
text {* Useful for simplification, but too risky to include by default. *} 

173 

22841  174 
lemma less_imp_not_less: "x \<^loc>< y \<Longrightarrow> (\<not> y \<^loc>< x) \<longleftrightarrow> True" 
23212  175 
by (blast elim: less_asym) 
15524  176 

22841  177 
lemma less_imp_triv: "x \<^loc>< y \<Longrightarrow> (y \<^loc>< x \<longrightarrow> P) \<longleftrightarrow> True" 
23212  178 
by (blast elim: less_asym) 
15524  179 

21248  180 

21083  181 
text {* Transitivity rules for calculational reasoning *} 
15524  182 

22841  183 
lemma less_asym': "a \<^loc>< b \<Longrightarrow> b \<^loc>< a \<Longrightarrow> P" 
23212  184 
by (rule less_asym) 
21248  185 

22916  186 

187 
text {* Reverse order *} 

188 

189 
lemma order_reverse: 

23018
1d29bc31b0cb
no special treatment in naming of locale predicates stemming form classes
haftmann
parents:
22997
diff
changeset

190 
"order (\<lambda>x y. y \<^loc>\<le> x) (\<lambda>x y. y \<^loc>< x)" 
23212  191 
by unfold_locales 
192 
(simp add: less_le, auto intro: antisym order_trans) 

22916  193 

21248  194 
end 
15524  195 

21329  196 

197 
subsection {* Linear (total) orders *} 

198 

22316  199 
class linorder = order + 
21216
1c8580913738
made locale partial_order compatible with axclass order; changed import order; consecutive changes
haftmann
parents:
21204
diff
changeset

200 
assumes linear: "x \<sqsubseteq> y \<or> y \<sqsubseteq> x" 
21248  201 
begin 
202 

22841  203 
lemma less_linear: "x \<^loc>< y \<or> x = y \<or> y \<^loc>< x" 
23212  204 
unfolding less_le using less_le linear by blast 
21248  205 

22841  206 
lemma le_less_linear: "x \<^loc>\<le> y \<or> y \<^loc>< x" 
23212  207 
by (simp add: le_less less_linear) 
21248  208 

209 
lemma le_cases [case_names le ge]: 

22841  210 
"(x \<^loc>\<le> y \<Longrightarrow> P) \<Longrightarrow> (y \<^loc>\<le> x \<Longrightarrow> P) \<Longrightarrow> P" 
23212  211 
using linear by blast 
21248  212 

22384
33a46e6c7f04
prefix of class interpretation not mandatory any longer
haftmann
parents:
22377
diff
changeset

213 
lemma linorder_cases [case_names less equal greater]: 
23212  214 
"(x \<^loc>< y \<Longrightarrow> P) \<Longrightarrow> (x = y \<Longrightarrow> P) \<Longrightarrow> (y \<^loc>< x \<Longrightarrow> P) \<Longrightarrow> P" 
215 
using less_linear by blast 

21248  216 

22841  217 
lemma not_less: "\<not> x \<^loc>< y \<longleftrightarrow> y \<^loc>\<le> x" 
23212  218 
apply (simp add: less_le) 
219 
using linear apply (blast intro: antisym) 

220 
done 

221 

222 
lemma not_less_iff_gr_or_eq: 

223 
"\<not>(x \<^loc>< y) \<longleftrightarrow> (x \<^loc>> y  x = y)" 

224 
apply(simp add:not_less le_less) 

225 
apply blast 

226 
done 

15524  227 

22841  228 
lemma not_le: "\<not> x \<^loc>\<le> y \<longleftrightarrow> y \<^loc>< x" 
23212  229 
apply (simp add: less_le) 
230 
using linear apply (blast intro: antisym) 

231 
done 

15524  232 

22841  233 
lemma neq_iff: "x \<noteq> y \<longleftrightarrow> x \<^loc>< y \<or> y \<^loc>< x" 
23212  234 
by (cut_tac x = x and y = y in less_linear, auto) 
15524  235 

22841  236 
lemma neqE: "x \<noteq> y \<Longrightarrow> (x \<^loc>< y \<Longrightarrow> R) \<Longrightarrow> (y \<^loc>< x \<Longrightarrow> R) \<Longrightarrow> R" 
23212  237 
by (simp add: neq_iff) blast 
15524  238 

22841  239 
lemma antisym_conv1: "\<not> x \<^loc>< y \<Longrightarrow> x \<^loc>\<le> y \<longleftrightarrow> x = y" 
23212  240 
by (blast intro: antisym dest: not_less [THEN iffD1]) 
15524  241 

22841  242 
lemma antisym_conv2: "x \<^loc>\<le> y \<Longrightarrow> \<not> x \<^loc>< y \<longleftrightarrow> x = y" 
23212  243 
by (blast intro: antisym dest: not_less [THEN iffD1]) 
15524  244 

22841  245 
lemma antisym_conv3: "\<not> y \<^loc>< x \<Longrightarrow> \<not> x \<^loc>< y \<longleftrightarrow> x = y" 
23212  246 
by (blast intro: antisym dest: not_less [THEN iffD1]) 
15524  247 

16796  248 
text{*Replacing the old Nat.leI*} 
22841  249 
lemma leI: "\<not> x \<^loc>< y \<Longrightarrow> y \<^loc>\<le> x" 
23212  250 
unfolding not_less . 
16796  251 

22841  252 
lemma leD: "y \<^loc>\<le> x \<Longrightarrow> \<not> x \<^loc>< y" 
23212  253 
unfolding not_less . 
16796  254 

255 
(*FIXME inappropriate name (or delete altogether)*) 

22841  256 
lemma not_leE: "\<not> y \<^loc>\<le> x \<Longrightarrow> x \<^loc>< y" 
23212  257 
unfolding not_le . 
21248  258 

22916  259 

260 
text {* Reverse order *} 

261 

262 
lemma linorder_reverse: 

23018
1d29bc31b0cb
no special treatment in naming of locale predicates stemming form classes
haftmann
parents:
22997
diff
changeset

263 
"linorder (\<lambda>x y. y \<^loc>\<le> x) (\<lambda>x y. y \<^loc>< x)" 
23212  264 
by unfold_locales 
265 
(simp add: less_le, auto intro: antisym order_trans simp add: linear) 

22916  266 

267 

22738  268 
text {* min/max properties *} 
22384
33a46e6c7f04
prefix of class interpretation not mandatory any longer
haftmann
parents:
22377
diff
changeset

269 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

270 
lemma min_le_iff_disj: 
22841  271 
"min x y \<^loc>\<le> z \<longleftrightarrow> x \<^loc>\<le> z \<or> y \<^loc>\<le> z" 
23212  272 
unfolding min_def using linear by (auto intro: order_trans) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

273 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

274 
lemma le_max_iff_disj: 
22841  275 
"z \<^loc>\<le> max x y \<longleftrightarrow> z \<^loc>\<le> x \<or> z \<^loc>\<le> y" 
23212  276 
unfolding max_def using linear by (auto intro: order_trans) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

277 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

278 
lemma min_less_iff_disj: 
22841  279 
"min x y \<^loc>< z \<longleftrightarrow> x \<^loc>< z \<or> y \<^loc>< z" 
23212  280 
unfolding min_def le_less using less_linear by (auto intro: less_trans) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

281 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

282 
lemma less_max_iff_disj: 
22841  283 
"z \<^loc>< max x y \<longleftrightarrow> z \<^loc>< x \<or> z \<^loc>< y" 
23212  284 
unfolding max_def le_less using less_linear by (auto intro: less_trans) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

285 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

286 
lemma min_less_iff_conj [simp]: 
22841  287 
"z \<^loc>< min x y \<longleftrightarrow> z \<^loc>< x \<and> z \<^loc>< y" 
23212  288 
unfolding min_def le_less using less_linear by (auto intro: less_trans) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

289 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

290 
lemma max_less_iff_conj [simp]: 
22841  291 
"max x y \<^loc>< z \<longleftrightarrow> x \<^loc>< z \<and> y \<^loc>< z" 
23212  292 
unfolding max_def le_less using less_linear by (auto intro: less_trans) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

293 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

294 
lemma split_min: 
22841  295 
"P (min i j) \<longleftrightarrow> (i \<^loc>\<le> j \<longrightarrow> P i) \<and> (\<not> i \<^loc>\<le> j \<longrightarrow> P j)" 
23212  296 
by (simp add: min_def) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

297 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

298 
lemma split_max: 
22841  299 
"P (max i j) \<longleftrightarrow> (i \<^loc>\<le> j \<longrightarrow> P j) \<and> (\<not> i \<^loc>\<le> j \<longrightarrow> P i)" 
23212  300 
by (simp add: max_def) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

301 

21248  302 
end 
303 

22916  304 
subsection {* Name duplicates  including min/max interpretation *} 
21248  305 

22384
33a46e6c7f04
prefix of class interpretation not mandatory any longer
haftmann
parents:
22377
diff
changeset

306 
lemmas order_less_le = less_le 
22841  307 
lemmas order_eq_refl = order_class.eq_refl 
308 
lemmas order_less_irrefl = order_class.less_irrefl 

309 
lemmas order_le_less = order_class.le_less 

310 
lemmas order_le_imp_less_or_eq = order_class.le_imp_less_or_eq 

311 
lemmas order_less_imp_le = order_class.less_imp_le 

312 
lemmas order_less_imp_not_eq = order_class.less_imp_not_eq 

313 
lemmas order_less_imp_not_eq2 = order_class.less_imp_not_eq2 

314 
lemmas order_neq_le_trans = order_class.neq_le_trans 

315 
lemmas order_le_neq_trans = order_class.le_neq_trans 

22316  316 

22384
33a46e6c7f04
prefix of class interpretation not mandatory any longer
haftmann
parents:
22377
diff
changeset

317 
lemmas order_antisym = antisym 
22316  318 
lemmas order_less_not_sym = order_class.less_not_sym 
319 
lemmas order_less_asym = order_class.less_asym 

320 
lemmas order_eq_iff = order_class.eq_iff 

321 
lemmas order_antisym_conv = order_class.antisym_conv 

322 
lemmas order_less_trans = order_class.less_trans 

323 
lemmas order_le_less_trans = order_class.le_less_trans 

324 
lemmas order_less_le_trans = order_class.less_le_trans 

325 
lemmas order_less_imp_not_less = order_class.less_imp_not_less 

326 
lemmas order_less_imp_triv = order_class.less_imp_triv 

327 
lemmas order_less_asym' = order_class.less_asym' 

328 

22384
33a46e6c7f04
prefix of class interpretation not mandatory any longer
haftmann
parents:
22377
diff
changeset

329 
lemmas linorder_linear = linear 
22316  330 
lemmas linorder_less_linear = linorder_class.less_linear 
331 
lemmas linorder_le_less_linear = linorder_class.le_less_linear 

332 
lemmas linorder_le_cases = linorder_class.le_cases 

333 
lemmas linorder_not_less = linorder_class.not_less 

334 
lemmas linorder_not_le = linorder_class.not_le 

335 
lemmas linorder_neq_iff = linorder_class.neq_iff 

336 
lemmas linorder_neqE = linorder_class.neqE 

337 
lemmas linorder_antisym_conv1 = linorder_class.antisym_conv1 

338 
lemmas linorder_antisym_conv2 = linorder_class.antisym_conv2 

339 
lemmas linorder_antisym_conv3 = linorder_class.antisym_conv3 

16796  340 

23087  341 
lemmas min_le_iff_disj = linorder_class.min_le_iff_disj [folded ord_class.min] 
342 
lemmas le_max_iff_disj = linorder_class.le_max_iff_disj [folded ord_class.max] 

343 
lemmas min_less_iff_disj = linorder_class.min_less_iff_disj [folded ord_class.min] 

344 
lemmas less_max_iff_disj = linorder_class.less_max_iff_disj [folded ord_class.max] 

345 
lemmas min_less_iff_conj [simp] = linorder_class.min_less_iff_conj [folded ord_class.min] 

346 
lemmas max_less_iff_conj [simp] = linorder_class.max_less_iff_conj [folded ord_class.max] 

347 
lemmas split_min = linorder_class.split_min [folded ord_class.min] 

348 
lemmas split_max = linorder_class.split_max [folded ord_class.max] 

22916  349 

21083  350 

351 
subsection {* Reasoning tools setup *} 

352 

21091  353 
ML {* 
354 
local 

355 

356 
fun decomp_gen sort thy (Trueprop $ t) = 

21248  357 
let 
358 
fun of_sort t = 

359 
let 

360 
val T = type_of t 

361 
in 

21091  362 
(* exclude numeric types: linear arithmetic subsumes transitivity *) 
21248  363 
T <> HOLogic.natT andalso T <> HOLogic.intT 
364 
andalso T <> HOLogic.realT andalso Sign.of_sort thy (T, sort) 

365 
end; 

22916  366 
fun dec (Const (@{const_name Not}, _) $ t) = (case dec t 
21248  367 
of NONE => NONE 
368 
 SOME (t1, rel, t2) => SOME (t1, "~" ^ rel, t2)) 

22916  369 
 dec (Const (@{const_name "op ="}, _) $ t1 $ t2) = 
21248  370 
if of_sort t1 
371 
then SOME (t1, "=", t2) 

372 
else NONE 

22997  373 
 dec (Const (@{const_name Orderings.less_eq}, _) $ t1 $ t2) = 
21248  374 
if of_sort t1 
375 
then SOME (t1, "<=", t2) 

376 
else NONE 

22997  377 
 dec (Const (@{const_name Orderings.less}, _) $ t1 $ t2) = 
21248  378 
if of_sort t1 
379 
then SOME (t1, "<", t2) 

380 
else NONE 

381 
 dec _ = NONE; 

21091  382 
in dec t end; 
383 

384 
in 

385 

22841  386 
(* sorry  there is no preorder class 
21248  387 
structure Quasi_Tac = Quasi_Tac_Fun ( 
388 
struct 

389 
val le_trans = thm "order_trans"; 

390 
val le_refl = thm "order_refl"; 

391 
val eqD1 = thm "order_eq_refl"; 

392 
val eqD2 = thm "sym" RS thm "order_eq_refl"; 

393 
val less_reflE = thm "order_less_irrefl" RS thm "notE"; 

394 
val less_imp_le = thm "order_less_imp_le"; 

395 
val le_neq_trans = thm "order_le_neq_trans"; 

396 
val neq_le_trans = thm "order_neq_le_trans"; 

397 
val less_imp_neq = thm "less_imp_neq"; 

22738  398 
val decomp_trans = decomp_gen ["Orderings.preorder"]; 
399 
val decomp_quasi = decomp_gen ["Orderings.preorder"]; 

22841  400 
end);*) 
21091  401 

402 
structure Order_Tac = Order_Tac_Fun ( 

21248  403 
struct 
404 
val less_reflE = thm "order_less_irrefl" RS thm "notE"; 

405 
val le_refl = thm "order_refl"; 

406 
val less_imp_le = thm "order_less_imp_le"; 

407 
val not_lessI = thm "linorder_not_less" RS thm "iffD2"; 

408 
val not_leI = thm "linorder_not_le" RS thm "iffD2"; 

409 
val not_lessD = thm "linorder_not_less" RS thm "iffD1"; 

410 
val not_leD = thm "linorder_not_le" RS thm "iffD1"; 

411 
val eqI = thm "order_antisym"; 

412 
val eqD1 = thm "order_eq_refl"; 

413 
val eqD2 = thm "sym" RS thm "order_eq_refl"; 

414 
val less_trans = thm "order_less_trans"; 

415 
val less_le_trans = thm "order_less_le_trans"; 

416 
val le_less_trans = thm "order_le_less_trans"; 

417 
val le_trans = thm "order_trans"; 

418 
val le_neq_trans = thm "order_le_neq_trans"; 

419 
val neq_le_trans = thm "order_neq_le_trans"; 

420 
val less_imp_neq = thm "less_imp_neq"; 

421 
val eq_neq_eq_imp_neq = thm "eq_neq_eq_imp_neq"; 

422 
val not_sym = thm "not_sym"; 

423 
val decomp_part = decomp_gen ["Orderings.order"]; 

424 
val decomp_lin = decomp_gen ["Orderings.linorder"]; 

425 
end); 

21091  426 

427 
end; 

428 
*} 

429 

21083  430 
setup {* 
431 
let 

432 

433 
fun prp t thm = (#prop (rep_thm thm) = t); 

15524  434 

21083  435 
fun prove_antisym_le sg ss ((le as Const(_,T)) $ r $ s) = 
436 
let val prems = prems_of_ss ss; 

22916  437 
val less = Const (@{const_name less}, T); 
21083  438 
val t = HOLogic.mk_Trueprop(le $ s $ r); 
439 
in case find_first (prp t) prems of 

440 
NONE => 

441 
let val t = HOLogic.mk_Trueprop(HOLogic.Not $ (less $ r $ s)) 

442 
in case find_first (prp t) prems of 

443 
NONE => NONE 

22738  444 
 SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_antisym_conv1})) 
21083  445 
end 
22738  446 
 SOME thm => SOME(mk_meta_eq(thm RS @{thm order_antisym_conv})) 
21083  447 
end 
448 
handle THM _ => NONE; 

15524  449 

21083  450 
fun prove_antisym_less sg ss (NotC $ ((less as Const(_,T)) $ r $ s)) = 
451 
let val prems = prems_of_ss ss; 

22916  452 
val le = Const (@{const_name less_eq}, T); 
21083  453 
val t = HOLogic.mk_Trueprop(le $ r $ s); 
454 
in case find_first (prp t) prems of 

455 
NONE => 

456 
let val t = HOLogic.mk_Trueprop(NotC $ (less $ s $ r)) 

457 
in case find_first (prp t) prems of 

458 
NONE => NONE 

22738  459 
 SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_antisym_conv3})) 
21083  460 
end 
22738  461 
 SOME thm => SOME(mk_meta_eq(thm RS @{thm linorder_antisym_conv2})) 
21083  462 
end 
463 
handle THM _ => NONE; 

15524  464 

21248  465 
fun add_simprocs procs thy = 
466 
(Simplifier.change_simpset_of thy (fn ss => ss 

467 
addsimprocs (map (fn (name, raw_ts, proc) => 

468 
Simplifier.simproc thy name raw_ts proc)) procs); thy); 

469 
fun add_solver name tac thy = 

470 
(Simplifier.change_simpset_of thy (fn ss => ss addSolver 

471 
(mk_solver name (K tac))); thy); 

21083  472 

473 
in 

21248  474 
add_simprocs [ 
475 
("antisym le", ["(x::'a::order) <= y"], prove_antisym_le), 

476 
("antisym less", ["~ (x::'a::linorder) < y"], prove_antisym_less) 

477 
] 

478 
#> add_solver "Trans_linear" Order_Tac.linear_tac 

479 
#> add_solver "Trans_partial" Order_Tac.partial_tac 

480 
(* Adding the transitivity reasoners also as safe solvers showed a slight 

481 
speed up, but the reasoning strength appears to be not higher (at least 

482 
no breaking of additional proofs in the entire HOL distribution, as 

483 
of 5 March 2004, was observed). *) 

21083  484 
end 
485 
*} 

15524  486 

487 

21083  488 
subsection {* Bounded quantifiers *} 
489 

490 
syntax 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

491 
"_All_less" :: "[idt, 'a, bool] => bool" ("(3ALL _<_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

492 
"_Ex_less" :: "[idt, 'a, bool] => bool" ("(3EX _<_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

493 
"_All_less_eq" :: "[idt, 'a, bool] => bool" ("(3ALL _<=_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

494 
"_Ex_less_eq" :: "[idt, 'a, bool] => bool" ("(3EX _<=_./ _)" [0, 0, 10] 10) 
21083  495 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

496 
"_All_greater" :: "[idt, 'a, bool] => bool" ("(3ALL _>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

497 
"_Ex_greater" :: "[idt, 'a, bool] => bool" ("(3EX _>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

498 
"_All_greater_eq" :: "[idt, 'a, bool] => bool" ("(3ALL _>=_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

499 
"_Ex_greater_eq" :: "[idt, 'a, bool] => bool" ("(3EX _>=_./ _)" [0, 0, 10] 10) 
21083  500 

501 
syntax (xsymbols) 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

502 
"_All_less" :: "[idt, 'a, bool] => bool" ("(3\<forall>_<_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

503 
"_Ex_less" :: "[idt, 'a, bool] => bool" ("(3\<exists>_<_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

504 
"_All_less_eq" :: "[idt, 'a, bool] => bool" ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

505 
"_Ex_less_eq" :: "[idt, 'a, bool] => bool" ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10) 
21083  506 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

507 
"_All_greater" :: "[idt, 'a, bool] => bool" ("(3\<forall>_>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

508 
"_Ex_greater" :: "[idt, 'a, bool] => bool" ("(3\<exists>_>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

509 
"_All_greater_eq" :: "[idt, 'a, bool] => bool" ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

510 
"_Ex_greater_eq" :: "[idt, 'a, bool] => bool" ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10) 
21083  511 

512 
syntax (HOL) 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

513 
"_All_less" :: "[idt, 'a, bool] => bool" ("(3! _<_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

514 
"_Ex_less" :: "[idt, 'a, bool] => bool" ("(3? _<_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

515 
"_All_less_eq" :: "[idt, 'a, bool] => bool" ("(3! _<=_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

516 
"_Ex_less_eq" :: "[idt, 'a, bool] => bool" ("(3? _<=_./ _)" [0, 0, 10] 10) 
21083  517 

518 
syntax (HTML output) 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

519 
"_All_less" :: "[idt, 'a, bool] => bool" ("(3\<forall>_<_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

520 
"_Ex_less" :: "[idt, 'a, bool] => bool" ("(3\<exists>_<_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

521 
"_All_less_eq" :: "[idt, 'a, bool] => bool" ("(3\<forall>_\<le>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

522 
"_Ex_less_eq" :: "[idt, 'a, bool] => bool" ("(3\<exists>_\<le>_./ _)" [0, 0, 10] 10) 
21083  523 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

524 
"_All_greater" :: "[idt, 'a, bool] => bool" ("(3\<forall>_>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

525 
"_Ex_greater" :: "[idt, 'a, bool] => bool" ("(3\<exists>_>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

526 
"_All_greater_eq" :: "[idt, 'a, bool] => bool" ("(3\<forall>_\<ge>_./ _)" [0, 0, 10] 10) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

527 
"_Ex_greater_eq" :: "[idt, 'a, bool] => bool" ("(3\<exists>_\<ge>_./ _)" [0, 0, 10] 10) 
21083  528 

529 
translations 

530 
"ALL x<y. P" => "ALL x. x < y \<longrightarrow> P" 

531 
"EX x<y. P" => "EX x. x < y \<and> P" 

532 
"ALL x<=y. P" => "ALL x. x <= y \<longrightarrow> P" 

533 
"EX x<=y. P" => "EX x. x <= y \<and> P" 

534 
"ALL x>y. P" => "ALL x. x > y \<longrightarrow> P" 

535 
"EX x>y. P" => "EX x. x > y \<and> P" 

536 
"ALL x>=y. P" => "ALL x. x >= y \<longrightarrow> P" 

537 
"EX x>=y. P" => "EX x. x >= y \<and> P" 

538 

539 
print_translation {* 

540 
let 

22916  541 
val All_binder = Syntax.binder_name @{const_syntax All}; 
542 
val Ex_binder = Syntax.binder_name @{const_syntax Ex}; 

22377  543 
val impl = @{const_syntax "op >"}; 
544 
val conj = @{const_syntax "op &"}; 

22916  545 
val less = @{const_syntax less}; 
546 
val less_eq = @{const_syntax less_eq}; 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

547 

f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

548 
val trans = 
21524  549 
[((All_binder, impl, less), ("_All_less", "_All_greater")), 
550 
((All_binder, impl, less_eq), ("_All_less_eq", "_All_greater_eq")), 

551 
((Ex_binder, conj, less), ("_Ex_less", "_Ex_greater")), 

552 
((Ex_binder, conj, less_eq), ("_Ex_less_eq", "_Ex_greater_eq"))]; 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

553 

22344
eddeabf16b5d
Fixed print translations for quantifiers a la "ALL x>=t. P x". These used
krauss
parents:
22316
diff
changeset

554 
fun matches_bound v t = 
eddeabf16b5d
Fixed print translations for quantifiers a la "ALL x>=t. P x". These used
krauss
parents:
22316
diff
changeset

555 
case t of (Const ("_bound", _) $ Free (v', _)) => (v = v') 
eddeabf16b5d
Fixed print translations for quantifiers a la "ALL x>=t. P x". These used
krauss
parents:
22316
diff
changeset

556 
 _ => false 
eddeabf16b5d
Fixed print translations for quantifiers a la "ALL x>=t. P x". These used
krauss
parents:
22316
diff
changeset

557 
fun contains_var v = Term.exists_subterm (fn Free (x, _) => x = v  _ => false) 
eddeabf16b5d
Fixed print translations for quantifiers a la "ALL x>=t. P x". These used
krauss
parents:
22316
diff
changeset

558 
fun mk v c n P = Syntax.const c $ Syntax.mark_bound v $ n $ P 
21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

559 

f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

560 
fun tr' q = (q, 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

561 
fn [Const ("_bound", _) $ Free (v, _), Const (c, _) $ (Const (d, _) $ t $ u) $ P] => 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

562 
(case AList.lookup (op =) trans (q, c, d) of 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

563 
NONE => raise Match 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

564 
 SOME (l, g) => 
22344
eddeabf16b5d
Fixed print translations for quantifiers a la "ALL x>=t. P x". These used
krauss
parents:
22316
diff
changeset

565 
if matches_bound v t andalso not (contains_var v u) then mk v l u P 
eddeabf16b5d
Fixed print translations for quantifiers a la "ALL x>=t. P x". These used
krauss
parents:
22316
diff
changeset

566 
else if matches_bound v u andalso not (contains_var v t) then mk v g t P 
eddeabf16b5d
Fixed print translations for quantifiers a la "ALL x>=t. P x". These used
krauss
parents:
22316
diff
changeset

567 
else raise Match) 
21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

568 
 _ => raise Match); 
21524  569 
in [tr' All_binder, tr' Ex_binder] end 
21083  570 
*} 
571 

572 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

573 
subsection {* Transitivity reasoning *} 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

574 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

575 
lemma ord_le_eq_trans: "a <= b ==> b = c ==> a <= c" 
23212  576 
by (rule subst) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

577 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

578 
lemma ord_eq_le_trans: "a = b ==> b <= c ==> a <= c" 
23212  579 
by (rule ssubst) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

580 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

581 
lemma ord_less_eq_trans: "a < b ==> b = c ==> a < c" 
23212  582 
by (rule subst) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

583 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

584 
lemma ord_eq_less_trans: "a = b ==> b < c ==> a < c" 
23212  585 
by (rule ssubst) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

586 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

587 
lemma order_less_subst2: "(a::'a::order) < b ==> f b < (c::'c::order) ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

588 
(!!x y. x < y ==> f x < f y) ==> f a < c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

589 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

590 
assume r: "!!x y. x < y ==> f x < f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

591 
assume "a < b" hence "f a < f b" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

592 
also assume "f b < c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

593 
finally (order_less_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

594 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

595 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

596 
lemma order_less_subst1: "(a::'a::order) < f b ==> (b::'b::order) < c ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

597 
(!!x y. x < y ==> f x < f y) ==> a < f c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

598 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

599 
assume r: "!!x y. x < y ==> f x < f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

600 
assume "a < f b" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

601 
also assume "b < c" hence "f b < f c" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

602 
finally (order_less_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

603 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

604 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

605 
lemma order_le_less_subst2: "(a::'a::order) <= b ==> f b < (c::'c::order) ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

606 
(!!x y. x <= y ==> f x <= f y) ==> f a < c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

607 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

608 
assume r: "!!x y. x <= y ==> f x <= f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

609 
assume "a <= b" hence "f a <= f b" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

610 
also assume "f b < c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

611 
finally (order_le_less_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

612 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

613 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

614 
lemma order_le_less_subst1: "(a::'a::order) <= f b ==> (b::'b::order) < c ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

615 
(!!x y. x < y ==> f x < f y) ==> a < f c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

616 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

617 
assume r: "!!x y. x < y ==> f x < f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

618 
assume "a <= f b" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

619 
also assume "b < c" hence "f b < f c" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

620 
finally (order_le_less_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

621 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

622 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

623 
lemma order_less_le_subst2: "(a::'a::order) < b ==> f b <= (c::'c::order) ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

624 
(!!x y. x < y ==> f x < f y) ==> f a < c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

625 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

626 
assume r: "!!x y. x < y ==> f x < f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

627 
assume "a < b" hence "f a < f b" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

628 
also assume "f b <= c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

629 
finally (order_less_le_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

630 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

631 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

632 
lemma order_less_le_subst1: "(a::'a::order) < f b ==> (b::'b::order) <= c ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

633 
(!!x y. x <= y ==> f x <= f y) ==> a < f c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

634 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

635 
assume r: "!!x y. x <= y ==> f x <= f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

636 
assume "a < f b" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

637 
also assume "b <= c" hence "f b <= f c" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

638 
finally (order_less_le_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

639 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

640 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

641 
lemma order_subst1: "(a::'a::order) <= f b ==> (b::'b::order) <= c ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

642 
(!!x y. x <= y ==> f x <= f y) ==> a <= f c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

643 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

644 
assume r: "!!x y. x <= y ==> f x <= f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

645 
assume "a <= f b" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

646 
also assume "b <= c" hence "f b <= f c" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

647 
finally (order_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

648 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

649 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

650 
lemma order_subst2: "(a::'a::order) <= b ==> f b <= (c::'c::order) ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

651 
(!!x y. x <= y ==> f x <= f y) ==> f a <= c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

652 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

653 
assume r: "!!x y. x <= y ==> f x <= f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

654 
assume "a <= b" hence "f a <= f b" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

655 
also assume "f b <= c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

656 
finally (order_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

657 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

658 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

659 
lemma ord_le_eq_subst: "a <= b ==> f b = c ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

660 
(!!x y. x <= y ==> f x <= f y) ==> f a <= c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

661 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

662 
assume r: "!!x y. x <= y ==> f x <= f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

663 
assume "a <= b" hence "f a <= f b" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

664 
also assume "f b = c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

665 
finally (ord_le_eq_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

666 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

667 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

668 
lemma ord_eq_le_subst: "a = f b ==> b <= c ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

669 
(!!x y. x <= y ==> f x <= f y) ==> a <= f c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

670 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

671 
assume r: "!!x y. x <= y ==> f x <= f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

672 
assume "a = f b" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

673 
also assume "b <= c" hence "f b <= f c" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

674 
finally (ord_eq_le_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

675 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

676 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

677 
lemma ord_less_eq_subst: "a < b ==> f b = c ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

678 
(!!x y. x < y ==> f x < f y) ==> f a < c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

679 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

680 
assume r: "!!x y. x < y ==> f x < f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

681 
assume "a < b" hence "f a < f b" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

682 
also assume "f b = c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

683 
finally (ord_less_eq_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

684 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

685 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

686 
lemma ord_eq_less_subst: "a = f b ==> b < c ==> 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

687 
(!!x y. x < y ==> f x < f y) ==> a < f c" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

688 
proof  
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

689 
assume r: "!!x y. x < y ==> f x < f y" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

690 
assume "a = f b" 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

691 
also assume "b < c" hence "f b < f c" by (rule r) 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

692 
finally (ord_eq_less_trans) show ?thesis . 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

693 
qed 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

694 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

695 
text {* 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

696 
Note that this list of rules is in reverse order of priorities. 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

697 
*} 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

698 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

699 
lemmas order_trans_rules [trans] = 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

700 
order_less_subst2 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

701 
order_less_subst1 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

702 
order_le_less_subst2 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

703 
order_le_less_subst1 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

704 
order_less_le_subst2 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

705 
order_less_le_subst1 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

706 
order_subst2 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

707 
order_subst1 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

708 
ord_le_eq_subst 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

709 
ord_eq_le_subst 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

710 
ord_less_eq_subst 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

711 
ord_eq_less_subst 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

712 
forw_subst 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

713 
back_subst 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

714 
rev_mp 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

715 
mp 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

716 
order_neq_le_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

717 
order_le_neq_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

718 
order_less_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

719 
order_less_asym' 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

720 
order_le_less_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

721 
order_less_le_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

722 
order_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

723 
order_antisym 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

724 
ord_le_eq_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

725 
ord_eq_le_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

726 
ord_less_eq_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

727 
ord_eq_less_trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

728 
trans 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

729 

21083  730 

21180
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

731 
(* FIXME cleanup *) 
f27f12bcafb8
fixed print_translation for ALL/EX and <, <=, etc.; tuned syntax names;
wenzelm
parents:
21091
diff
changeset

732 

21083  733 
text {* These support proving chains of decreasing inequalities 
734 
a >= b >= c ... in Isar proofs. *} 

735 

736 
lemma xt1: 

737 
"a = b ==> b > c ==> a > c" 

738 
"a > b ==> b = c ==> a > c" 

739 
"a = b ==> b >= c ==> a >= c" 

740 
"a >= b ==> b = c ==> a >= c" 

741 
"(x::'a::order) >= y ==> y >= x ==> x = y" 

742 
"(x::'a::order) >= y ==> y >= z ==> x >= z" 

743 
"(x::'a::order) > y ==> y >= z ==> x > z" 

744 
"(x::'a::order) >= y ==> y > z ==> x > z" 

23417  745 
"(a::'a::order) > b ==> b > a ==> P" 
21083  746 
"(x::'a::order) > y ==> y > z ==> x > z" 
747 
"(a::'a::order) >= b ==> a ~= b ==> a > b" 

748 
"(a::'a::order) ~= b ==> a >= b ==> a > b" 

749 
"a = f b ==> b > c ==> (!!x y. x > y ==> f x > f y) ==> a > f c" 

750 
"a > b ==> f b = c ==> (!!x y. x > y ==> f x > f y) ==> f a > c" 

751 
"a = f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c" 

752 
"a >= b ==> f b = c ==> (!! x y. x >= y ==> f x >= f y) ==> f a >= c" 

753 
by auto 

754 

755 
lemma xt2: 

756 
"(a::'a::order) >= f b ==> b >= c ==> (!!x y. x >= y ==> f x >= f y) ==> a >= f c" 

757 
by (subgoal_tac "f b >= f c", force, force) 

758 

759 
lemma xt3: "(a::'a::order) >= b ==> (f b::'b::order) >= c ==> 

760 
(!!x y. x >= y ==> f x >= f y) ==> f a >= c" 

761 
by (subgoal_tac "f a >= f b", force, force) 

762 

763 
lemma xt4: "(a::'a::order) > f b ==> (b::'b::order) >= c ==> 

764 
(!!x y. x >= y ==> f x >= f y) ==> a > f c" 

765 
by (subgoal_tac "f b >= f c", force, force) 

766 

767 
lemma xt5: "(a::'a::order) > b ==> (f b::'b::order) >= c==> 

768 
(!!x y. x > y ==> f x > f y) ==> f a > c" 

769 
by (subgoal_tac "f a > f b", force, force) 

770 

771 
lemma xt6: "(a::'a::order) >= f b ==> b > c ==> 

772 
(!!x y. x > y ==> f x > f y) ==> a > f c" 

773 
by (subgoal_tac "f b > f c", force, force) 

774 

775 
lemma xt7: "(a::'a::order) >= b ==> (f b::'b::order) > c ==> 

776 
(!!x y. x >= y ==> f x >= f y) ==> f a > c" 

777 
by (subgoal_tac "f a >= f b", force, force) 

778 

779 
lemma xt8: "(a::'a::order) > f b ==> (b::'b::order) > c ==> 

780 
(!!x y. x > y ==> f x > f y) ==> a > f c" 

781 
by (subgoal_tac "f b > f c", force, force) 

782 

783 
lemma xt9: "(a::'a::order) > b ==> (f b::'b::order) > c ==> 

784 
(!!x y. x > y ==> f x > f y) ==> f a > c" 

785 
by (subgoal_tac "f a > f b", force, force) 

786 

787 
lemmas xtrans = xt1 xt2 xt3 xt4 xt5 xt6 xt7 xt8 xt9 

788 

789 
(* 

790 
Since "a >= b" abbreviates "b <= a", the abbreviation "..." stands 

791 
for the wrong thing in an Isar proof. 

792 

793 
The extra transitivity rules can be used as follows: 

794 

795 
lemma "(a::'a::order) > z" 

796 
proof  

797 
have "a >= b" (is "_ >= ?rhs") 

798 
sorry 

799 
also have "?rhs >= c" (is "_ >= ?rhs") 

800 
sorry 

801 
also (xtrans) have "?rhs = d" (is "_ = ?rhs") 

802 
sorry 

803 
also (xtrans) have "?rhs >= e" (is "_ >= ?rhs") 

804 
sorry 

805 
also (xtrans) have "?rhs > f" (is "_ > ?rhs") 

806 
sorry 

807 
also (xtrans) have "?rhs > z" 

808 
sorry 

809 
finally (xtrans) show ?thesis . 

810 
qed 

811 

812 
Alternatively, one can use "declare xtrans [trans]" and then 

813 
leave out the "(xtrans)" above. 

814 
*) 

815 

21546  816 
subsection {* Order on bool *} 
817 

22886  818 
instance bool :: order 
21546  819 
le_bool_def: "P \<le> Q \<equiv> P \<longrightarrow> Q" 
820 
less_bool_def: "P < Q \<equiv> P \<le> Q \<and> P \<noteq> Q" 

22916  821 
by intro_classes (auto simp add: le_bool_def less_bool_def) 
21546  822 

823 
lemma le_boolI: "(P \<Longrightarrow> Q) \<Longrightarrow> P \<le> Q" 

23212  824 
by (simp add: le_bool_def) 
21546  825 

826 
lemma le_boolI': "P \<longrightarrow> Q \<Longrightarrow> P \<le> Q" 

23212  827 
by (simp add: le_bool_def) 
21546  828 

829 
lemma le_boolE: "P \<le> Q \<Longrightarrow> P \<Longrightarrow> (Q \<Longrightarrow> R) \<Longrightarrow> R" 

23212  830 
by (simp add: le_bool_def) 
21546  831 

832 
lemma le_boolD: "P \<le> Q \<Longrightarrow> P \<longrightarrow> Q" 

23212  833 
by (simp add: le_bool_def) 
21546  834 

22348  835 
lemma [code func]: 
836 
"False \<le> b \<longleftrightarrow> True" 

837 
"True \<le> b \<longleftrightarrow> b" 

838 
"False < b \<longleftrightarrow> b" 

839 
"True < b \<longleftrightarrow> False" 

840 
unfolding le_bool_def less_bool_def by simp_all 

841 

22424  842 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

843 
subsection {* Monotonicity, syntactic least value operator and min/max *} 
21083  844 

21216
1c8580913738
made locale partial_order compatible with axclass order; changed import order; consecutive changes
haftmann
parents:
21204
diff
changeset

845 
locale mono = 
1c8580913738
made locale partial_order compatible with axclass order; changed import order; consecutive changes
haftmann
parents:
21204
diff
changeset

846 
fixes f 
1c8580913738
made locale partial_order compatible with axclass order; changed import order; consecutive changes
haftmann
parents:
21204
diff
changeset

847 
assumes mono: "A \<le> B \<Longrightarrow> f A \<le> f B" 
1c8580913738
made locale partial_order compatible with axclass order; changed import order; consecutive changes
haftmann
parents:
21204
diff
changeset

848 

1c8580913738
made locale partial_order compatible with axclass order; changed import order; consecutive changes
haftmann
parents:
21204
diff
changeset

849 
lemmas monoI [intro?] = mono.intro 
1c8580913738
made locale partial_order compatible with axclass order; changed import order; consecutive changes
haftmann
parents:
21204
diff
changeset

850 
and monoD [dest?] = mono.mono 
21083  851 

852 
constdefs 

853 
Least :: "('a::ord => bool) => 'a" (binder "LEAST " 10) 

854 
"Least P == THE x. P x & (ALL y. P y > x <= y)" 

855 
 {* We can no longer use LeastM because the latter requires HilbertAC. *} 

856 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

857 
lemma LeastI2_order: 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

858 
"[ P (x::'a::order); 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

859 
!!y. P y ==> x <= y; 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

860 
!!x. [ P x; ALL y. P y > x \<le> y ] ==> Q x ] 
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

861 
==> Q (Least P)" 
23212  862 
apply (unfold Least_def) 
863 
apply (rule theI2) 

864 
apply (blast intro: order_antisym)+ 

865 
done 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

866 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

867 
lemma Least_equality: 
23212  868 
"[ P (k::'a::order); !!x. P x ==> k <= x ] ==> (LEAST x. P x) = k" 
869 
apply (simp add: Least_def) 

870 
apply (rule the_equality) 

871 
apply (auto intro!: order_antisym) 

872 
done 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

873 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

874 
lemma min_leastL: "(!!x. least <= x) ==> min least x = least" 
23212  875 
by (simp add: min_def) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

876 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

877 
lemma max_leastL: "(!!x. least <= x) ==> max least x = x" 
23212  878 
by (simp add: max_def) 
21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

879 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

880 
lemma min_leastR: "(\<And>x\<Colon>'a\<Colon>order. least \<le> x) \<Longrightarrow> min x least = least" 
23212  881 
apply (simp add: min_def) 
882 
apply (blast intro: order_antisym) 

883 
done 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

884 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

885 
lemma max_leastR: "(\<And>x\<Colon>'a\<Colon>order. least \<le> x) \<Longrightarrow> max x least = x" 
23212  886 
apply (simp add: max_def) 
887 
apply (blast intro: order_antisym) 

888 
done 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

889 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

890 
lemma min_of_mono: 
23212  891 
"(!!x y. (f x <= f y) = (x <= y)) ==> min (f m) (f n) = f (min m n)" 
892 
by (simp add: min_def) 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

893 

17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

894 
lemma max_of_mono: 
23212  895 
"(!!x y. (f x <= f y) = (x <= y)) ==> max (f m) (f n) = f (max m n)" 
896 
by (simp add: max_def) 

21383
17e6275e13f5
added transitivity rules, reworking of min/max lemmas
haftmann
parents:
21329
diff
changeset

897 

22548  898 

899 
subsection {* legacy ML bindings *} 

21673  900 

901 
ML {* 

22548  902 
val monoI = @{thm monoI}; 
22886  903 
*} 
21673  904 

15524  905 
end 