paulson@10751
|
1 |
(* Title: HOL/Hyperreal/HyperBin.ML
|
paulson@10751
|
2 |
ID: $Id$
|
paulson@10751
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
paulson@10751
|
4 |
Copyright 2000 University of Cambridge
|
paulson@10751
|
5 |
|
paulson@10751
|
6 |
Binary arithmetic for the hypreals (integer literals only).
|
paulson@10751
|
7 |
*)
|
paulson@10751
|
8 |
|
paulson@10751
|
9 |
(** hypreal_of_real (coercion from int to real) **)
|
paulson@10751
|
10 |
|
paulson@10751
|
11 |
Goal "hypreal_of_real (number_of w) = number_of w";
|
paulson@10751
|
12 |
by (simp_tac (simpset() addsimps [hypreal_number_of_def]) 1);
|
paulson@10751
|
13 |
qed "hypreal_number_of";
|
paulson@10751
|
14 |
Addsimps [hypreal_number_of];
|
paulson@10751
|
15 |
|
wenzelm@11701
|
16 |
Goalw [hypreal_number_of_def] "(0::hypreal) = Numeral0";
|
paulson@10751
|
17 |
by (simp_tac (simpset() addsimps [hypreal_of_real_zero RS sym]) 1);
|
paulson@10751
|
18 |
qed "zero_eq_numeral_0";
|
paulson@10751
|
19 |
|
wenzelm@11701
|
20 |
Goalw [hypreal_number_of_def] "1hr = Numeral1";
|
paulson@10751
|
21 |
by (simp_tac (simpset() addsimps [hypreal_of_real_one RS sym]) 1);
|
paulson@10751
|
22 |
qed "one_eq_numeral_1";
|
paulson@10751
|
23 |
|
paulson@10751
|
24 |
(** Addition **)
|
paulson@10751
|
25 |
|
paulson@10751
|
26 |
Goal "(number_of v :: hypreal) + number_of v' = number_of (bin_add v v')";
|
paulson@10751
|
27 |
by (simp_tac
|
paulson@10751
|
28 |
(HOL_ss addsimps [hypreal_number_of_def,
|
paulson@10751
|
29 |
hypreal_of_real_add RS sym, add_real_number_of]) 1);
|
paulson@10751
|
30 |
qed "add_hypreal_number_of";
|
paulson@10751
|
31 |
Addsimps [add_hypreal_number_of];
|
paulson@10751
|
32 |
|
paulson@10751
|
33 |
|
paulson@10751
|
34 |
(** Subtraction **)
|
paulson@10751
|
35 |
|
paulson@10751
|
36 |
Goalw [hypreal_number_of_def]
|
paulson@10751
|
37 |
"- (number_of w :: hypreal) = number_of (bin_minus w)";
|
paulson@10751
|
38 |
by (simp_tac
|
paulson@10751
|
39 |
(HOL_ss addsimps [minus_real_number_of, hypreal_of_real_minus RS sym]) 1);
|
paulson@10751
|
40 |
qed "minus_hypreal_number_of";
|
paulson@10751
|
41 |
Addsimps [minus_hypreal_number_of];
|
paulson@10751
|
42 |
|
paulson@10751
|
43 |
Goalw [hypreal_number_of_def, hypreal_diff_def]
|
paulson@10751
|
44 |
"(number_of v :: hypreal) - number_of w = \
|
paulson@10751
|
45 |
\ number_of (bin_add v (bin_minus w))";
|
paulson@10751
|
46 |
by (Simp_tac 1);
|
paulson@10751
|
47 |
qed "diff_hypreal_number_of";
|
paulson@10751
|
48 |
Addsimps [diff_hypreal_number_of];
|
paulson@10751
|
49 |
|
paulson@10751
|
50 |
|
paulson@10751
|
51 |
(** Multiplication **)
|
paulson@10751
|
52 |
|
paulson@10751
|
53 |
Goal "(number_of v :: hypreal) * number_of v' = number_of (bin_mult v v')";
|
paulson@10751
|
54 |
by (simp_tac
|
paulson@10751
|
55 |
(HOL_ss addsimps [hypreal_number_of_def,
|
paulson@10751
|
56 |
hypreal_of_real_mult RS sym, mult_real_number_of]) 1);
|
paulson@10751
|
57 |
qed "mult_hypreal_number_of";
|
paulson@10751
|
58 |
Addsimps [mult_hypreal_number_of];
|
paulson@10751
|
59 |
|
wenzelm@11701
|
60 |
Goal "(# 2::hypreal) = Numeral1 + Numeral1";
|
paulson@10751
|
61 |
by (Simp_tac 1);
|
paulson@10751
|
62 |
val lemma = result();
|
paulson@10751
|
63 |
|
paulson@10751
|
64 |
(*For specialist use: NOT as default simprules*)
|
wenzelm@11701
|
65 |
Goal "# 2 * z = (z+z::hypreal)";
|
paulson@10751
|
66 |
by (simp_tac (simpset ()
|
paulson@10751
|
67 |
addsimps [lemma, hypreal_add_mult_distrib,
|
paulson@10751
|
68 |
one_eq_numeral_1 RS sym]) 1);
|
paulson@10751
|
69 |
qed "hypreal_mult_2";
|
paulson@10751
|
70 |
|
wenzelm@11701
|
71 |
Goal "z * # 2 = (z+z::hypreal)";
|
paulson@10751
|
72 |
by (stac hypreal_mult_commute 1 THEN rtac hypreal_mult_2 1);
|
paulson@10751
|
73 |
qed "hypreal_mult_2_right";
|
paulson@10751
|
74 |
|
paulson@10751
|
75 |
|
paulson@10751
|
76 |
(*** Comparisons ***)
|
paulson@10751
|
77 |
|
paulson@10751
|
78 |
(** Equals (=) **)
|
paulson@10751
|
79 |
|
paulson@10751
|
80 |
Goal "((number_of v :: hypreal) = number_of v') = \
|
paulson@10751
|
81 |
\ iszero (number_of (bin_add v (bin_minus v')))";
|
paulson@10751
|
82 |
by (simp_tac
|
paulson@10751
|
83 |
(HOL_ss addsimps [hypreal_number_of_def,
|
paulson@10751
|
84 |
hypreal_of_real_eq_iff, eq_real_number_of]) 1);
|
paulson@10751
|
85 |
qed "eq_hypreal_number_of";
|
paulson@10751
|
86 |
Addsimps [eq_hypreal_number_of];
|
paulson@10751
|
87 |
|
paulson@10751
|
88 |
(** Less-than (<) **)
|
paulson@10751
|
89 |
|
paulson@10751
|
90 |
(*"neg" is used in rewrite rules for binary comparisons*)
|
paulson@10751
|
91 |
Goal "((number_of v :: hypreal) < number_of v') = \
|
paulson@10751
|
92 |
\ neg (number_of (bin_add v (bin_minus v')))";
|
paulson@10751
|
93 |
by (simp_tac
|
paulson@10751
|
94 |
(HOL_ss addsimps [hypreal_number_of_def, hypreal_of_real_less_iff,
|
paulson@10751
|
95 |
less_real_number_of]) 1);
|
paulson@10751
|
96 |
qed "less_hypreal_number_of";
|
paulson@10751
|
97 |
Addsimps [less_hypreal_number_of];
|
paulson@10751
|
98 |
|
paulson@10751
|
99 |
|
paulson@10751
|
100 |
(** Less-than-or-equals (<=) **)
|
paulson@10751
|
101 |
|
paulson@10751
|
102 |
Goal "(number_of x <= (number_of y::hypreal)) = \
|
paulson@10751
|
103 |
\ (~ number_of y < (number_of x::hypreal))";
|
paulson@10751
|
104 |
by (rtac (linorder_not_less RS sym) 1);
|
paulson@10751
|
105 |
qed "le_hypreal_number_of_eq_not_less";
|
paulson@10751
|
106 |
Addsimps [le_hypreal_number_of_eq_not_less];
|
paulson@10751
|
107 |
|
paulson@10751
|
108 |
(*** New versions of existing theorems involving 0, 1hr ***)
|
paulson@10751
|
109 |
|
wenzelm@11701
|
110 |
Goal "- Numeral1 = (# -1::hypreal)";
|
paulson@10751
|
111 |
by (Simp_tac 1);
|
paulson@10751
|
112 |
qed "minus_numeral_one";
|
paulson@10751
|
113 |
|
wenzelm@11701
|
114 |
(*Maps 0 to Numeral0 and 1hr to Numeral1 and -1hr to # -1*)
|
paulson@10751
|
115 |
val hypreal_numeral_ss =
|
paulson@10751
|
116 |
real_numeral_ss addsimps [zero_eq_numeral_0, one_eq_numeral_1,
|
paulson@10751
|
117 |
minus_numeral_one];
|
paulson@10751
|
118 |
|
paulson@10751
|
119 |
fun rename_numerals th =
|
paulson@10751
|
120 |
asm_full_simplify hypreal_numeral_ss (Thm.transfer (the_context ()) th);
|
paulson@10751
|
121 |
|
paulson@10751
|
122 |
|
paulson@10751
|
123 |
(*Now insert some identities previously stated for 0 and 1hr*)
|
paulson@10751
|
124 |
|
paulson@10751
|
125 |
(** HyperDef **)
|
paulson@10751
|
126 |
|
paulson@10751
|
127 |
Addsimps (map rename_numerals
|
paulson@10751
|
128 |
[hypreal_minus_zero, hypreal_minus_zero_iff,
|
paulson@10751
|
129 |
hypreal_add_zero_left, hypreal_add_zero_right,
|
paulson@10751
|
130 |
hypreal_diff_zero, hypreal_diff_zero_right,
|
paulson@10751
|
131 |
hypreal_mult_0_right, hypreal_mult_0,
|
paulson@10751
|
132 |
hypreal_mult_1_right, hypreal_mult_1,
|
paulson@10751
|
133 |
hypreal_inverse_1, hypreal_minus_zero_less_iff]);
|
paulson@10751
|
134 |
|
paulson@10751
|
135 |
bind_thm ("hypreal_0_less_mult_iff",
|
paulson@10751
|
136 |
rename_numerals hypreal_zero_less_mult_iff);
|
paulson@10751
|
137 |
bind_thm ("hypreal_0_le_mult_iff",
|
paulson@10751
|
138 |
rename_numerals hypreal_zero_le_mult_iff);
|
paulson@10751
|
139 |
bind_thm ("hypreal_mult_less_0_iff",
|
paulson@10751
|
140 |
rename_numerals hypreal_mult_less_zero_iff);
|
paulson@10751
|
141 |
bind_thm ("hypreal_mult_le_0_iff",
|
paulson@10751
|
142 |
rename_numerals hypreal_mult_le_zero_iff);
|
paulson@10751
|
143 |
|
paulson@10751
|
144 |
bind_thm ("hypreal_inverse_less_0", rename_numerals hypreal_inverse_less_zero);
|
paulson@10751
|
145 |
bind_thm ("hypreal_inverse_gt_0", rename_numerals hypreal_inverse_gt_zero);
|
paulson@10751
|
146 |
|
paulson@10751
|
147 |
Addsimps [zero_eq_numeral_0,one_eq_numeral_1];
|
paulson@10751
|
148 |
|
paulson@10751
|
149 |
|
paulson@10751
|
150 |
(** Simplification of arithmetic when nested to the right **)
|
paulson@10751
|
151 |
|
paulson@10751
|
152 |
Goal "number_of v + (number_of w + z) = (number_of(bin_add v w) + z::hypreal)";
|
paulson@10751
|
153 |
by Auto_tac;
|
paulson@10751
|
154 |
qed "hypreal_add_number_of_left";
|
paulson@10751
|
155 |
|
paulson@10751
|
156 |
Goal "number_of v *(number_of w * z) = (number_of(bin_mult v w) * z::hypreal)";
|
paulson@10751
|
157 |
by (simp_tac (simpset() addsimps [hypreal_mult_assoc RS sym]) 1);
|
paulson@10751
|
158 |
qed "hypreal_mult_number_of_left";
|
paulson@10751
|
159 |
|
paulson@10751
|
160 |
Goalw [hypreal_diff_def]
|
paulson@10751
|
161 |
"number_of v + (number_of w - c) = number_of(bin_add v w) - (c::hypreal)";
|
paulson@10751
|
162 |
by (rtac hypreal_add_number_of_left 1);
|
paulson@10751
|
163 |
qed "hypreal_add_number_of_diff1";
|
paulson@10751
|
164 |
|
paulson@10751
|
165 |
Goal "number_of v + (c - number_of w) = \
|
paulson@10751
|
166 |
\ number_of (bin_add v (bin_minus w)) + (c::hypreal)";
|
paulson@10751
|
167 |
by (stac (diff_hypreal_number_of RS sym) 1);
|
paulson@10751
|
168 |
by Auto_tac;
|
paulson@10751
|
169 |
qed "hypreal_add_number_of_diff2";
|
paulson@10751
|
170 |
|
paulson@10751
|
171 |
Addsimps [hypreal_add_number_of_left, hypreal_mult_number_of_left,
|
paulson@10751
|
172 |
hypreal_add_number_of_diff1, hypreal_add_number_of_diff2];
|
paulson@10751
|
173 |
|
paulson@10751
|
174 |
|
paulson@10751
|
175 |
(**** Simprocs for numeric literals ****)
|
paulson@10751
|
176 |
|
paulson@10751
|
177 |
(** Combining of literal coefficients in sums of products **)
|
paulson@10751
|
178 |
|
wenzelm@11701
|
179 |
Goal "(x < y) = (x-y < (Numeral0::hypreal))";
|
paulson@10751
|
180 |
by (simp_tac (simpset() addsimps [hypreal_diff_less_eq]) 1);
|
paulson@10751
|
181 |
qed "hypreal_less_iff_diff_less_0";
|
paulson@10751
|
182 |
|
wenzelm@11701
|
183 |
Goal "(x = y) = (x-y = (Numeral0::hypreal))";
|
paulson@10751
|
184 |
by (simp_tac (simpset() addsimps [hypreal_diff_eq_eq]) 1);
|
paulson@10751
|
185 |
qed "hypreal_eq_iff_diff_eq_0";
|
paulson@10751
|
186 |
|
wenzelm@11701
|
187 |
Goal "(x <= y) = (x-y <= (Numeral0::hypreal))";
|
paulson@10751
|
188 |
by (simp_tac (simpset() addsimps [hypreal_diff_le_eq]) 1);
|
paulson@10751
|
189 |
qed "hypreal_le_iff_diff_le_0";
|
paulson@10751
|
190 |
|
paulson@10751
|
191 |
|
paulson@10751
|
192 |
(** For combine_numerals **)
|
paulson@10751
|
193 |
|
paulson@10751
|
194 |
Goal "i*u + (j*u + k) = (i+j)*u + (k::hypreal)";
|
paulson@10751
|
195 |
by (asm_simp_tac (simpset() addsimps [hypreal_add_mult_distrib]) 1);
|
paulson@10751
|
196 |
qed "left_hypreal_add_mult_distrib";
|
paulson@10751
|
197 |
|
paulson@10751
|
198 |
|
paulson@10751
|
199 |
(** For cancel_numerals **)
|
paulson@10751
|
200 |
|
paulson@10751
|
201 |
val rel_iff_rel_0_rls =
|
paulson@10751
|
202 |
map (inst "y" "?u+?v")
|
paulson@10751
|
203 |
[hypreal_less_iff_diff_less_0, hypreal_eq_iff_diff_eq_0,
|
paulson@10751
|
204 |
hypreal_le_iff_diff_le_0] @
|
paulson@10751
|
205 |
map (inst "y" "n")
|
paulson@10751
|
206 |
[hypreal_less_iff_diff_less_0, hypreal_eq_iff_diff_eq_0,
|
paulson@10751
|
207 |
hypreal_le_iff_diff_le_0];
|
paulson@10751
|
208 |
|
paulson@10751
|
209 |
Goal "!!i::hypreal. (i*u + m = j*u + n) = ((i-j)*u + m = n)";
|
paulson@10751
|
210 |
by (asm_simp_tac
|
paulson@10751
|
211 |
(simpset() addsimps [hypreal_diff_def, hypreal_add_mult_distrib]@
|
paulson@10751
|
212 |
hypreal_add_ac@rel_iff_rel_0_rls) 1);
|
paulson@10751
|
213 |
qed "hypreal_eq_add_iff1";
|
paulson@10751
|
214 |
|
paulson@10751
|
215 |
Goal "!!i::hypreal. (i*u + m = j*u + n) = (m = (j-i)*u + n)";
|
paulson@10751
|
216 |
by (asm_simp_tac
|
paulson@10751
|
217 |
(simpset() addsimps [hypreal_diff_def, hypreal_add_mult_distrib]@
|
paulson@10751
|
218 |
hypreal_add_ac@rel_iff_rel_0_rls) 1);
|
paulson@10751
|
219 |
qed "hypreal_eq_add_iff2";
|
paulson@10751
|
220 |
|
paulson@10751
|
221 |
Goal "!!i::hypreal. (i*u + m < j*u + n) = ((i-j)*u + m < n)";
|
paulson@10751
|
222 |
by (asm_simp_tac
|
paulson@10751
|
223 |
(simpset() addsimps [hypreal_diff_def, hypreal_add_mult_distrib]@
|
paulson@10751
|
224 |
hypreal_add_ac@rel_iff_rel_0_rls) 1);
|
paulson@10751
|
225 |
qed "hypreal_less_add_iff1";
|
paulson@10751
|
226 |
|
paulson@10751
|
227 |
Goal "!!i::hypreal. (i*u + m < j*u + n) = (m < (j-i)*u + n)";
|
paulson@10751
|
228 |
by (asm_simp_tac
|
paulson@10751
|
229 |
(simpset() addsimps [hypreal_diff_def, hypreal_add_mult_distrib]@
|
paulson@10751
|
230 |
hypreal_add_ac@rel_iff_rel_0_rls) 1);
|
paulson@10751
|
231 |
qed "hypreal_less_add_iff2";
|
paulson@10751
|
232 |
|
paulson@10751
|
233 |
Goal "!!i::hypreal. (i*u + m <= j*u + n) = ((i-j)*u + m <= n)";
|
paulson@10751
|
234 |
by (asm_simp_tac
|
paulson@10751
|
235 |
(simpset() addsimps [hypreal_diff_def, hypreal_add_mult_distrib]@
|
paulson@10751
|
236 |
hypreal_add_ac@rel_iff_rel_0_rls) 1);
|
paulson@10751
|
237 |
qed "hypreal_le_add_iff1";
|
paulson@10751
|
238 |
|
paulson@10751
|
239 |
Goal "!!i::hypreal. (i*u + m <= j*u + n) = (m <= (j-i)*u + n)";
|
paulson@10751
|
240 |
by (asm_simp_tac
|
paulson@10751
|
241 |
(simpset() addsimps [hypreal_diff_def, hypreal_add_mult_distrib]@
|
paulson@10751
|
242 |
hypreal_add_ac@rel_iff_rel_0_rls) 1);
|
paulson@10751
|
243 |
qed "hypreal_le_add_iff2";
|
paulson@10751
|
244 |
|
wenzelm@11701
|
245 |
Goal "(z::hypreal) * # -1 = -z";
|
paulson@10751
|
246 |
by (stac (minus_numeral_one RS sym) 1);
|
paulson@10751
|
247 |
by (stac (hypreal_minus_mult_eq2 RS sym) 1);
|
paulson@10751
|
248 |
by Auto_tac;
|
paulson@10751
|
249 |
qed "hypreal_mult_minus_1_right";
|
paulson@10751
|
250 |
Addsimps [hypreal_mult_minus_1_right];
|
paulson@10751
|
251 |
|
wenzelm@11701
|
252 |
Goal "# -1 * (z::hypreal) = -z";
|
paulson@10751
|
253 |
by (simp_tac (simpset() addsimps [hypreal_mult_commute]) 1);
|
paulson@10751
|
254 |
qed "hypreal_mult_minus_1";
|
paulson@10751
|
255 |
Addsimps [hypreal_mult_minus_1];
|
paulson@10751
|
256 |
|
paulson@10751
|
257 |
|
paulson@10751
|
258 |
|
paulson@10751
|
259 |
structure Hyperreal_Numeral_Simprocs =
|
paulson@10751
|
260 |
struct
|
paulson@10751
|
261 |
|
paulson@10751
|
262 |
(*Utilities*)
|
paulson@10751
|
263 |
|
paulson@10751
|
264 |
|
paulson@10751
|
265 |
val hyprealT = Type("HyperDef.hypreal",[]);
|
paulson@10751
|
266 |
|
paulson@10751
|
267 |
fun mk_numeral n = HOLogic.number_of_const hyprealT $ HOLogic.mk_bin n;
|
paulson@10751
|
268 |
|
paulson@10751
|
269 |
val dest_numeral = Real_Numeral_Simprocs.dest_numeral;
|
paulson@10751
|
270 |
|
paulson@10751
|
271 |
val find_first_numeral = Real_Numeral_Simprocs.find_first_numeral;
|
paulson@10751
|
272 |
|
paulson@10751
|
273 |
val zero = mk_numeral 0;
|
paulson@10751
|
274 |
val mk_plus = HOLogic.mk_binop "op +";
|
paulson@10751
|
275 |
|
paulson@10751
|
276 |
val uminus_const = Const ("uminus", hyprealT --> hyprealT);
|
paulson@10751
|
277 |
|
wenzelm@11701
|
278 |
(*Thus mk_sum[t] yields t+Numeral0; longer sums don't have a trailing zero*)
|
paulson@10751
|
279 |
fun mk_sum [] = zero
|
paulson@10751
|
280 |
| mk_sum [t,u] = mk_plus (t, u)
|
paulson@10751
|
281 |
| mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
|
paulson@10751
|
282 |
|
paulson@10751
|
283 |
(*this version ALWAYS includes a trailing zero*)
|
paulson@10751
|
284 |
fun long_mk_sum [] = zero
|
paulson@10751
|
285 |
| long_mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
|
paulson@10751
|
286 |
|
paulson@10751
|
287 |
val dest_plus = HOLogic.dest_bin "op +" hyprealT;
|
paulson@10751
|
288 |
|
paulson@10751
|
289 |
(*decompose additions AND subtractions as a sum*)
|
paulson@10751
|
290 |
fun dest_summing (pos, Const ("op +", _) $ t $ u, ts) =
|
paulson@10751
|
291 |
dest_summing (pos, t, dest_summing (pos, u, ts))
|
paulson@10751
|
292 |
| dest_summing (pos, Const ("op -", _) $ t $ u, ts) =
|
paulson@10751
|
293 |
dest_summing (pos, t, dest_summing (not pos, u, ts))
|
paulson@10751
|
294 |
| dest_summing (pos, t, ts) =
|
paulson@10751
|
295 |
if pos then t::ts else uminus_const$t :: ts;
|
paulson@10751
|
296 |
|
paulson@10751
|
297 |
fun dest_sum t = dest_summing (true, t, []);
|
paulson@10751
|
298 |
|
paulson@10751
|
299 |
val mk_diff = HOLogic.mk_binop "op -";
|
paulson@10751
|
300 |
val dest_diff = HOLogic.dest_bin "op -" hyprealT;
|
paulson@10751
|
301 |
|
paulson@10751
|
302 |
val one = mk_numeral 1;
|
paulson@10751
|
303 |
val mk_times = HOLogic.mk_binop "op *";
|
paulson@10751
|
304 |
|
paulson@10751
|
305 |
fun mk_prod [] = one
|
paulson@10751
|
306 |
| mk_prod [t] = t
|
paulson@10751
|
307 |
| mk_prod (t :: ts) = if t = one then mk_prod ts
|
paulson@10751
|
308 |
else mk_times (t, mk_prod ts);
|
paulson@10751
|
309 |
|
paulson@10751
|
310 |
val dest_times = HOLogic.dest_bin "op *" hyprealT;
|
paulson@10751
|
311 |
|
paulson@10751
|
312 |
fun dest_prod t =
|
paulson@10751
|
313 |
let val (t,u) = dest_times t
|
paulson@10751
|
314 |
in dest_prod t @ dest_prod u end
|
paulson@10751
|
315 |
handle TERM _ => [t];
|
paulson@10751
|
316 |
|
paulson@10751
|
317 |
(*DON'T do the obvious simplifications; that would create special cases*)
|
paulson@10751
|
318 |
fun mk_coeff (k, ts) = mk_times (mk_numeral k, ts);
|
paulson@10751
|
319 |
|
paulson@10751
|
320 |
(*Express t as a product of (possibly) a numeral with other sorted terms*)
|
paulson@10751
|
321 |
fun dest_coeff sign (Const ("uminus", _) $ t) = dest_coeff (~sign) t
|
paulson@10751
|
322 |
| dest_coeff sign t =
|
paulson@10751
|
323 |
let val ts = sort Term.term_ord (dest_prod t)
|
paulson@10751
|
324 |
val (n, ts') = find_first_numeral [] ts
|
paulson@10751
|
325 |
handle TERM _ => (1, ts)
|
paulson@10751
|
326 |
in (sign*n, mk_prod ts') end;
|
paulson@10751
|
327 |
|
paulson@10751
|
328 |
(*Find first coefficient-term THAT MATCHES u*)
|
paulson@10751
|
329 |
fun find_first_coeff past u [] = raise TERM("find_first_coeff", [])
|
paulson@10751
|
330 |
| find_first_coeff past u (t::terms) =
|
paulson@10751
|
331 |
let val (n,u') = dest_coeff 1 t
|
paulson@10751
|
332 |
in if u aconv u' then (n, rev past @ terms)
|
paulson@10751
|
333 |
else find_first_coeff (t::past) u terms
|
paulson@10751
|
334 |
end
|
paulson@10751
|
335 |
handle TERM _ => find_first_coeff (t::past) u terms;
|
paulson@10751
|
336 |
|
paulson@10751
|
337 |
|
wenzelm@11701
|
338 |
(*Simplify Numeral1*n and n*Numeral1 to n*)
|
paulson@10751
|
339 |
val add_0s = map rename_numerals
|
paulson@10751
|
340 |
[hypreal_add_zero_left, hypreal_add_zero_right];
|
paulson@10751
|
341 |
val mult_plus_1s = map rename_numerals
|
paulson@10751
|
342 |
[hypreal_mult_1, hypreal_mult_1_right];
|
paulson@10751
|
343 |
val mult_minus_1s = map rename_numerals
|
paulson@10751
|
344 |
[hypreal_mult_minus_1, hypreal_mult_minus_1_right];
|
paulson@10751
|
345 |
val mult_1s = mult_plus_1s @ mult_minus_1s;
|
paulson@10751
|
346 |
|
paulson@10751
|
347 |
(*To perform binary arithmetic*)
|
paulson@10751
|
348 |
val bin_simps =
|
paulson@10751
|
349 |
[add_hypreal_number_of, hypreal_add_number_of_left,
|
paulson@10751
|
350 |
minus_hypreal_number_of, diff_hypreal_number_of, mult_hypreal_number_of,
|
paulson@10751
|
351 |
hypreal_mult_number_of_left] @ bin_arith_simps @ bin_rel_simps;
|
paulson@10751
|
352 |
|
paulson@10751
|
353 |
(*To evaluate binary negations of coefficients*)
|
paulson@10751
|
354 |
val hypreal_minus_simps = NCons_simps @
|
paulson@10751
|
355 |
[minus_hypreal_number_of,
|
paulson@10751
|
356 |
bin_minus_1, bin_minus_0, bin_minus_Pls, bin_minus_Min,
|
paulson@10751
|
357 |
bin_pred_1, bin_pred_0, bin_pred_Pls, bin_pred_Min];
|
paulson@10751
|
358 |
|
paulson@10751
|
359 |
(*To let us treat subtraction as addition*)
|
paulson@10751
|
360 |
val diff_simps = [hypreal_diff_def, hypreal_minus_add_distrib,
|
paulson@10751
|
361 |
hypreal_minus_minus];
|
paulson@10751
|
362 |
|
paulson@10751
|
363 |
(*push the unary minus down: - x * y = x * - y *)
|
paulson@10751
|
364 |
val hypreal_minus_mult_eq_1_to_2 =
|
paulson@10751
|
365 |
[hypreal_minus_mult_eq1 RS sym, hypreal_minus_mult_eq2] MRS trans
|
paulson@10751
|
366 |
|> standard;
|
paulson@10751
|
367 |
|
paulson@10751
|
368 |
(*to extract again any uncancelled minuses*)
|
paulson@10751
|
369 |
val hypreal_minus_from_mult_simps =
|
paulson@10751
|
370 |
[hypreal_minus_minus, hypreal_minus_mult_eq1 RS sym,
|
paulson@10751
|
371 |
hypreal_minus_mult_eq2 RS sym];
|
paulson@10751
|
372 |
|
paulson@10751
|
373 |
(*combine unary minus with numeric literals, however nested within a product*)
|
paulson@10751
|
374 |
val hypreal_mult_minus_simps =
|
paulson@10751
|
375 |
[hypreal_mult_assoc, hypreal_minus_mult_eq1, hypreal_minus_mult_eq_1_to_2];
|
paulson@10751
|
376 |
|
paulson@10751
|
377 |
(*Apply the given rewrite (if present) just once*)
|
paulson@10751
|
378 |
fun trans_tac None = all_tac
|
paulson@10751
|
379 |
| trans_tac (Some th) = ALLGOALS (rtac (th RS trans));
|
paulson@10751
|
380 |
|
paulson@10751
|
381 |
fun prove_conv name tacs sg (hyps: thm list) (t,u) =
|
paulson@10751
|
382 |
if t aconv u then None
|
paulson@10751
|
383 |
else
|
paulson@10751
|
384 |
let val ct = cterm_of sg (HOLogic.mk_Trueprop (HOLogic.mk_eq (t, u)))
|
paulson@10751
|
385 |
in Some
|
paulson@10751
|
386 |
(prove_goalw_cterm [] ct (K tacs)
|
paulson@10751
|
387 |
handle ERROR => error
|
paulson@10751
|
388 |
("The error(s) above occurred while trying to prove " ^
|
paulson@10751
|
389 |
string_of_cterm ct ^ "\nInternal failure of simproc " ^ name))
|
paulson@10751
|
390 |
end;
|
paulson@10751
|
391 |
|
paulson@10751
|
392 |
(*version without the hyps argument*)
|
paulson@10751
|
393 |
fun prove_conv_nohyps name tacs sg = prove_conv name tacs sg [];
|
paulson@10751
|
394 |
|
paulson@10751
|
395 |
(*Final simplification: cancel + and * *)
|
paulson@10751
|
396 |
val simplify_meta_eq =
|
paulson@10751
|
397 |
Int_Numeral_Simprocs.simplify_meta_eq
|
paulson@10751
|
398 |
[hypreal_add_zero_left, hypreal_add_zero_right,
|
paulson@10751
|
399 |
hypreal_mult_0, hypreal_mult_0_right, hypreal_mult_1,
|
paulson@10751
|
400 |
hypreal_mult_1_right];
|
paulson@10751
|
401 |
|
paulson@10751
|
402 |
val prep_simproc = Real_Numeral_Simprocs.prep_simproc;
|
paulson@10751
|
403 |
val prep_pats = map Real_Numeral_Simprocs.prep_pat;
|
paulson@10751
|
404 |
|
paulson@10751
|
405 |
structure CancelNumeralsCommon =
|
paulson@10751
|
406 |
struct
|
paulson@10751
|
407 |
val mk_sum = mk_sum
|
paulson@10751
|
408 |
val dest_sum = dest_sum
|
paulson@10751
|
409 |
val mk_coeff = mk_coeff
|
paulson@10751
|
410 |
val dest_coeff = dest_coeff 1
|
paulson@10751
|
411 |
val find_first_coeff = find_first_coeff []
|
paulson@10751
|
412 |
val trans_tac = trans_tac
|
paulson@10751
|
413 |
val norm_tac =
|
paulson@10751
|
414 |
ALLGOALS (simp_tac (HOL_ss addsimps add_0s@mult_1s@diff_simps@
|
paulson@10751
|
415 |
hypreal_minus_simps@hypreal_add_ac))
|
paulson@10751
|
416 |
THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@hypreal_mult_minus_simps))
|
paulson@10751
|
417 |
THEN ALLGOALS
|
paulson@10751
|
418 |
(simp_tac (HOL_ss addsimps hypreal_minus_from_mult_simps@
|
paulson@10751
|
419 |
hypreal_add_ac@hypreal_mult_ac))
|
paulson@10751
|
420 |
val numeral_simp_tac = ALLGOALS (simp_tac (HOL_ss addsimps add_0s@bin_simps))
|
paulson@10751
|
421 |
val simplify_meta_eq = simplify_meta_eq
|
paulson@10751
|
422 |
end;
|
paulson@10751
|
423 |
|
paulson@10751
|
424 |
|
paulson@10751
|
425 |
structure EqCancelNumerals = CancelNumeralsFun
|
paulson@10751
|
426 |
(open CancelNumeralsCommon
|
paulson@10751
|
427 |
val prove_conv = prove_conv "hyprealeq_cancel_numerals"
|
paulson@10751
|
428 |
val mk_bal = HOLogic.mk_eq
|
paulson@10751
|
429 |
val dest_bal = HOLogic.dest_bin "op =" hyprealT
|
paulson@10751
|
430 |
val bal_add1 = hypreal_eq_add_iff1 RS trans
|
paulson@10751
|
431 |
val bal_add2 = hypreal_eq_add_iff2 RS trans
|
paulson@10751
|
432 |
);
|
paulson@10751
|
433 |
|
paulson@10751
|
434 |
structure LessCancelNumerals = CancelNumeralsFun
|
paulson@10751
|
435 |
(open CancelNumeralsCommon
|
paulson@10751
|
436 |
val prove_conv = prove_conv "hyprealless_cancel_numerals"
|
paulson@10751
|
437 |
val mk_bal = HOLogic.mk_binrel "op <"
|
paulson@10751
|
438 |
val dest_bal = HOLogic.dest_bin "op <" hyprealT
|
paulson@10751
|
439 |
val bal_add1 = hypreal_less_add_iff1 RS trans
|
paulson@10751
|
440 |
val bal_add2 = hypreal_less_add_iff2 RS trans
|
paulson@10751
|
441 |
);
|
paulson@10751
|
442 |
|
paulson@10751
|
443 |
structure LeCancelNumerals = CancelNumeralsFun
|
paulson@10751
|
444 |
(open CancelNumeralsCommon
|
paulson@10751
|
445 |
val prove_conv = prove_conv "hyprealle_cancel_numerals"
|
paulson@10751
|
446 |
val mk_bal = HOLogic.mk_binrel "op <="
|
paulson@10751
|
447 |
val dest_bal = HOLogic.dest_bin "op <=" hyprealT
|
paulson@10751
|
448 |
val bal_add1 = hypreal_le_add_iff1 RS trans
|
paulson@10751
|
449 |
val bal_add2 = hypreal_le_add_iff2 RS trans
|
paulson@10751
|
450 |
);
|
paulson@10751
|
451 |
|
paulson@10751
|
452 |
val cancel_numerals =
|
paulson@10751
|
453 |
map prep_simproc
|
paulson@10751
|
454 |
[("hyprealeq_cancel_numerals",
|
paulson@10751
|
455 |
prep_pats ["(l::hypreal) + m = n", "(l::hypreal) = m + n",
|
paulson@10751
|
456 |
"(l::hypreal) - m = n", "(l::hypreal) = m - n",
|
paulson@10751
|
457 |
"(l::hypreal) * m = n", "(l::hypreal) = m * n"],
|
paulson@10751
|
458 |
EqCancelNumerals.proc),
|
paulson@10751
|
459 |
("hyprealless_cancel_numerals",
|
paulson@10751
|
460 |
prep_pats ["(l::hypreal) + m < n", "(l::hypreal) < m + n",
|
paulson@10751
|
461 |
"(l::hypreal) - m < n", "(l::hypreal) < m - n",
|
paulson@10751
|
462 |
"(l::hypreal) * m < n", "(l::hypreal) < m * n"],
|
paulson@10751
|
463 |
LessCancelNumerals.proc),
|
paulson@10751
|
464 |
("hyprealle_cancel_numerals",
|
paulson@10751
|
465 |
prep_pats ["(l::hypreal) + m <= n", "(l::hypreal) <= m + n",
|
paulson@10751
|
466 |
"(l::hypreal) - m <= n", "(l::hypreal) <= m - n",
|
paulson@10751
|
467 |
"(l::hypreal) * m <= n", "(l::hypreal) <= m * n"],
|
paulson@10751
|
468 |
LeCancelNumerals.proc)];
|
paulson@10751
|
469 |
|
paulson@10751
|
470 |
|
paulson@10751
|
471 |
structure CombineNumeralsData =
|
paulson@10751
|
472 |
struct
|
paulson@10751
|
473 |
val add = op + : int*int -> int
|
wenzelm@11701
|
474 |
val mk_sum = long_mk_sum (*to work for e.g. # 2*x + # 3*x *)
|
paulson@10751
|
475 |
val dest_sum = dest_sum
|
paulson@10751
|
476 |
val mk_coeff = mk_coeff
|
paulson@10751
|
477 |
val dest_coeff = dest_coeff 1
|
paulson@10751
|
478 |
val left_distrib = left_hypreal_add_mult_distrib RS trans
|
paulson@10751
|
479 |
val prove_conv = prove_conv_nohyps "hypreal_combine_numerals"
|
paulson@10751
|
480 |
val trans_tac = trans_tac
|
paulson@10751
|
481 |
val norm_tac =
|
paulson@10751
|
482 |
ALLGOALS (simp_tac (HOL_ss addsimps add_0s@mult_1s@diff_simps@
|
paulson@10751
|
483 |
hypreal_minus_simps@hypreal_add_ac))
|
paulson@10751
|
484 |
THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@hypreal_mult_minus_simps))
|
paulson@10751
|
485 |
THEN ALLGOALS (simp_tac (HOL_ss addsimps hypreal_minus_from_mult_simps@
|
paulson@10751
|
486 |
hypreal_add_ac@hypreal_mult_ac))
|
paulson@10751
|
487 |
val numeral_simp_tac = ALLGOALS
|
paulson@10751
|
488 |
(simp_tac (HOL_ss addsimps add_0s@bin_simps))
|
paulson@10751
|
489 |
val simplify_meta_eq = simplify_meta_eq
|
paulson@10751
|
490 |
end;
|
paulson@10751
|
491 |
|
paulson@10751
|
492 |
structure CombineNumerals = CombineNumeralsFun(CombineNumeralsData);
|
paulson@10751
|
493 |
|
paulson@10751
|
494 |
val combine_numerals =
|
paulson@10751
|
495 |
prep_simproc ("hypreal_combine_numerals",
|
paulson@10751
|
496 |
prep_pats ["(i::hypreal) + j", "(i::hypreal) - j"],
|
paulson@10751
|
497 |
CombineNumerals.proc);
|
paulson@10751
|
498 |
|
paulson@10751
|
499 |
|
paulson@10751
|
500 |
(** Declarations for ExtractCommonTerm **)
|
paulson@10751
|
501 |
|
paulson@10751
|
502 |
(*this version ALWAYS includes a trailing one*)
|
paulson@10751
|
503 |
fun long_mk_prod [] = one
|
paulson@10751
|
504 |
| long_mk_prod (t :: ts) = mk_times (t, mk_prod ts);
|
paulson@10751
|
505 |
|
paulson@10751
|
506 |
(*Find first term that matches u*)
|
paulson@10751
|
507 |
fun find_first past u [] = raise TERM("find_first", [])
|
paulson@10751
|
508 |
| find_first past u (t::terms) =
|
paulson@10751
|
509 |
if u aconv t then (rev past @ terms)
|
paulson@10751
|
510 |
else find_first (t::past) u terms
|
paulson@10751
|
511 |
handle TERM _ => find_first (t::past) u terms;
|
paulson@10751
|
512 |
|
paulson@10751
|
513 |
(*Final simplification: cancel + and * *)
|
paulson@10751
|
514 |
fun cancel_simplify_meta_eq cancel_th th =
|
paulson@10751
|
515 |
Int_Numeral_Simprocs.simplify_meta_eq
|
paulson@10751
|
516 |
[hypreal_mult_1, hypreal_mult_1_right]
|
paulson@10751
|
517 |
(([th, cancel_th]) MRS trans);
|
paulson@10751
|
518 |
|
paulson@10751
|
519 |
end;
|
paulson@10751
|
520 |
|
paulson@10751
|
521 |
Addsimprocs Hyperreal_Numeral_Simprocs.cancel_numerals;
|
paulson@10751
|
522 |
Addsimprocs [Hyperreal_Numeral_Simprocs.combine_numerals];
|
paulson@10751
|
523 |
|
paulson@10751
|
524 |
(*The Abel_Cancel simprocs are now obsolete*)
|
paulson@10751
|
525 |
Delsimprocs [Hyperreal_Cancel.sum_conv, Hyperreal_Cancel.rel_conv];
|
paulson@10751
|
526 |
|
paulson@10751
|
527 |
(*examples:
|
paulson@10751
|
528 |
print_depth 22;
|
paulson@10751
|
529 |
set timing;
|
paulson@10751
|
530 |
set trace_simp;
|
paulson@10751
|
531 |
fun test s = (Goal s, by (Simp_tac 1));
|
paulson@10751
|
532 |
|
wenzelm@11701
|
533 |
test "l + # 2 + # 2 + # 2 + (l + # 2) + (oo + # 2) = (uu::hypreal)";
|
wenzelm@11701
|
534 |
test "# 2*u = (u::hypreal)";
|
wenzelm@11701
|
535 |
test "(i + j + # 12 + (k::hypreal)) - # 15 = y";
|
wenzelm@11701
|
536 |
test "(i + j + # 12 + (k::hypreal)) - # 5 = y";
|
paulson@10751
|
537 |
|
paulson@10751
|
538 |
test "y - b < (b::hypreal)";
|
wenzelm@11701
|
539 |
test "y - (# 3*b + c) < (b::hypreal) - # 2*c";
|
paulson@10751
|
540 |
|
wenzelm@11701
|
541 |
test "(# 2*x - (u*v) + y) - v*# 3*u = (w::hypreal)";
|
wenzelm@11701
|
542 |
test "(# 2*x*u*v + (u*v)*# 4 + y) - v*u*# 4 = (w::hypreal)";
|
wenzelm@11701
|
543 |
test "(# 2*x*u*v + (u*v)*# 4 + y) - v*u = (w::hypreal)";
|
wenzelm@11701
|
544 |
test "u*v - (x*u*v + (u*v)*# 4 + y) = (w::hypreal)";
|
paulson@10751
|
545 |
|
wenzelm@11701
|
546 |
test "(i + j + # 12 + (k::hypreal)) = u + # 15 + y";
|
wenzelm@11701
|
547 |
test "(i + j*# 2 + # 12 + (k::hypreal)) = j + # 5 + y";
|
paulson@10751
|
548 |
|
wenzelm@11701
|
549 |
test "# 2*y + # 3*z + # 6*w + # 2*y + # 3*z + # 2*u = # 2*y' + # 3*z' + # 6*w' + # 2*y' + # 3*z' + u + (vv::hypreal)";
|
paulson@10751
|
550 |
|
paulson@10751
|
551 |
test "a + -(b+c) + b = (d::hypreal)";
|
paulson@10751
|
552 |
test "a + -(b+c) - b = (d::hypreal)";
|
paulson@10751
|
553 |
|
paulson@10751
|
554 |
(*negative numerals*)
|
wenzelm@11701
|
555 |
test "(i + j + # -2 + (k::hypreal)) - (u + # 5 + y) = zz";
|
wenzelm@11701
|
556 |
test "(i + j + # -3 + (k::hypreal)) < u + # 5 + y";
|
wenzelm@11701
|
557 |
test "(i + j + # 3 + (k::hypreal)) < u + # -6 + y";
|
wenzelm@11701
|
558 |
test "(i + j + # -12 + (k::hypreal)) - # 15 = y";
|
wenzelm@11701
|
559 |
test "(i + j + # 12 + (k::hypreal)) - # -15 = y";
|
wenzelm@11701
|
560 |
test "(i + j + # -12 + (k::hypreal)) - # -15 = y";
|
paulson@10751
|
561 |
*)
|
paulson@10751
|
562 |
|
paulson@10751
|
563 |
|
paulson@10751
|
564 |
(** Constant folding for hypreal plus and times **)
|
paulson@10751
|
565 |
|
paulson@10751
|
566 |
(*We do not need
|
paulson@10751
|
567 |
structure Hyperreal_Plus_Assoc = Assoc_Fold (Hyperreal_Plus_Assoc_Data);
|
paulson@10751
|
568 |
because combine_numerals does the same thing*)
|
paulson@10751
|
569 |
|
paulson@10751
|
570 |
structure Hyperreal_Times_Assoc_Data : ASSOC_FOLD_DATA =
|
paulson@10751
|
571 |
struct
|
paulson@10751
|
572 |
val ss = HOL_ss
|
paulson@10751
|
573 |
val eq_reflection = eq_reflection
|
paulson@10751
|
574 |
val sg_ref = Sign.self_ref (Theory.sign_of (the_context ()))
|
paulson@10751
|
575 |
val T = Hyperreal_Numeral_Simprocs.hyprealT
|
paulson@10751
|
576 |
val plus = Const ("op *", [T,T] ---> T)
|
paulson@10751
|
577 |
val add_ac = hypreal_mult_ac
|
paulson@10751
|
578 |
end;
|
paulson@10751
|
579 |
|
paulson@10751
|
580 |
structure Hyperreal_Times_Assoc = Assoc_Fold (Hyperreal_Times_Assoc_Data);
|
paulson@10751
|
581 |
|
paulson@10751
|
582 |
Addsimprocs [Hyperreal_Times_Assoc.conv];
|
paulson@10751
|
583 |
|
paulson@10751
|
584 |
Addsimps [rename_numerals hypreal_of_real_zero_iff];
|
paulson@10751
|
585 |
|
paulson@10751
|
586 |
(*Simplification of x-y < 0, etc.*)
|
paulson@10751
|
587 |
AddIffs [hypreal_less_iff_diff_less_0 RS sym];
|
paulson@10751
|
588 |
AddIffs [hypreal_eq_iff_diff_eq_0 RS sym];
|
paulson@10751
|
589 |
AddIffs [hypreal_le_iff_diff_le_0 RS sym];
|
paulson@10751
|
590 |
|
paulson@10751
|
591 |
|
paulson@10751
|
592 |
(** number_of related to hypreal_of_real **)
|
paulson@10751
|
593 |
|
paulson@10751
|
594 |
Goal "(number_of w < hypreal_of_real z) = (number_of w < z)";
|
paulson@10751
|
595 |
by (stac (hypreal_of_real_less_iff RS sym) 1);
|
paulson@10751
|
596 |
by (Simp_tac 1);
|
paulson@10751
|
597 |
qed "number_of_less_hypreal_of_real_iff";
|
paulson@10751
|
598 |
Addsimps [number_of_less_hypreal_of_real_iff];
|
paulson@10751
|
599 |
|
paulson@10751
|
600 |
Goal "(number_of w <= hypreal_of_real z) = (number_of w <= z)";
|
paulson@10751
|
601 |
by (stac (hypreal_of_real_le_iff RS sym) 1);
|
paulson@10751
|
602 |
by (Simp_tac 1);
|
paulson@10751
|
603 |
qed "number_of_le_hypreal_of_real_iff";
|
paulson@10751
|
604 |
Addsimps [number_of_le_hypreal_of_real_iff];
|
paulson@10751
|
605 |
|
paulson@10751
|
606 |
Goal "(hypreal_of_real z < number_of w) = (z < number_of w)";
|
paulson@10751
|
607 |
by (stac (hypreal_of_real_less_iff RS sym) 1);
|
paulson@10751
|
608 |
by (Simp_tac 1);
|
paulson@10751
|
609 |
qed "hypreal_of_real_less_number_of_iff";
|
paulson@10751
|
610 |
Addsimps [hypreal_of_real_less_number_of_iff];
|
paulson@10751
|
611 |
|
paulson@10751
|
612 |
Goal "(hypreal_of_real z <= number_of w) = (z <= number_of w)";
|
paulson@10751
|
613 |
by (stac (hypreal_of_real_le_iff RS sym) 1);
|
paulson@10751
|
614 |
by (Simp_tac 1);
|
paulson@10751
|
615 |
qed "hypreal_of_real_le_number_of_iff";
|
paulson@10751
|
616 |
Addsimps [hypreal_of_real_le_number_of_iff];
|
paulson@10751
|
617 |
|
paulson@10784
|
618 |
(** <= monotonicity results: needed for arithmetic **)
|
paulson@10784
|
619 |
|
paulson@10784
|
620 |
Goal "[| i <= j; (0::hypreal) <= k |] ==> i*k <= j*k";
|
paulson@10784
|
621 |
by (auto_tac (claset(),
|
paulson@10784
|
622 |
simpset() addsimps [order_le_less, hypreal_mult_less_mono1]));
|
paulson@10784
|
623 |
qed "hypreal_mult_le_mono1";
|
paulson@10784
|
624 |
|
paulson@10784
|
625 |
Goal "[| i <= j; (0::hypreal) <= k |] ==> k*i <= k*j";
|
paulson@10784
|
626 |
by (dtac hypreal_mult_le_mono1 1);
|
paulson@10784
|
627 |
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [hypreal_mult_commute])));
|
paulson@10784
|
628 |
qed "hypreal_mult_le_mono2";
|
paulson@10784
|
629 |
|
paulson@10784
|
630 |
Goal "[| u <= v; x <= y; 0 <= v; (0::hypreal) <= x |] ==> u * x <= v * y";
|
paulson@10784
|
631 |
by (etac (hypreal_mult_le_mono1 RS order_trans) 1);
|
paulson@10784
|
632 |
by (assume_tac 1);
|
paulson@10784
|
633 |
by (etac hypreal_mult_le_mono2 1);
|
paulson@10784
|
634 |
by (assume_tac 1);
|
paulson@10784
|
635 |
qed "hypreal_mult_le_mono";
|
paulson@10784
|
636 |
|