author | wenzelm |
Mon, 25 Feb 2002 20:48:14 +0100 | |
changeset 12937 | 0c4fd7529467 |
parent 12483 | 0a01efff43e9 |
child 13462 | 56610e2ba220 |
permissions | -rw-r--r-- |
10722 | 1 |
(* Title: HOL/Real/RealArith.ML |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1999 University of Cambridge |
|
5 |
||
6 |
Assorted facts that need binary literals and the arithmetic decision procedure |
|
7 |
||
8 |
Also, common factor cancellation |
|
9 |
*) |
|
10 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
11 |
Goal "x - - y = x + (y::real)"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
12 |
by (Simp_tac 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
13 |
qed "real_diff_minus_eq"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
14 |
Addsimps [real_diff_minus_eq]; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
15 |
|
10722 | 16 |
(** Division and inverse **) |
17 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
18 |
Goal "0/x = (0::real)"; |
10722 | 19 |
by (simp_tac (simpset() addsimps [real_divide_def]) 1); |
20 |
qed "real_0_divide"; |
|
21 |
Addsimps [real_0_divide]; |
|
22 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
23 |
Goal "((0::real) < inverse x) = (0 < x)"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
24 |
by (case_tac "x=0" 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
25 |
by (asm_simp_tac (HOL_ss addsimps [INVERSE_ZERO]) 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
26 |
by (auto_tac (claset() addDs [real_inverse_less_0], |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
27 |
simpset() addsimps [linorder_neq_iff, real_inverse_gt_0])); |
10722 | 28 |
qed "real_0_less_inverse_iff"; |
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
29 |
Addsimps [real_0_less_inverse_iff]; |
10722 | 30 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
31 |
Goal "(inverse x < (0::real)) = (x < 0)"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
32 |
by (case_tac "x=0" 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
33 |
by (asm_simp_tac (HOL_ss addsimps [INVERSE_ZERO]) 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
34 |
by (auto_tac (claset() addDs [real_inverse_less_0], |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
35 |
simpset() addsimps [linorder_neq_iff, real_inverse_gt_0])); |
10722 | 36 |
qed "real_inverse_less_0_iff"; |
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
37 |
Addsimps [real_inverse_less_0_iff]; |
10722 | 38 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
39 |
Goal "((0::real) <= inverse x) = (0 <= x)"; |
10722 | 40 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); |
41 |
qed "real_0_le_inverse_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
42 |
Addsimps [real_0_le_inverse_iff]; |
10722 | 43 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
44 |
Goal "(inverse x <= (0::real)) = (x <= 0)"; |
10722 | 45 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); |
46 |
qed "real_inverse_le_0_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
47 |
Addsimps [real_inverse_le_0_iff]; |
10722 | 48 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
49 |
Goalw [real_divide_def] "x/(0::real) = 0"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
50 |
by (stac INVERSE_ZERO 1); |
10722 | 51 |
by (Simp_tac 1); |
52 |
qed "REAL_DIVIDE_ZERO"; |
|
53 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
54 |
Goal "inverse (x::real) = 1/x"; |
10722 | 55 |
by (simp_tac (simpset() addsimps [real_divide_def]) 1); |
56 |
qed "real_inverse_eq_divide"; |
|
57 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
58 |
Goal "((0::real) < x/y) = (0 < x & 0 < y | x < 0 & y < 0)"; |
10722 | 59 |
by (simp_tac (simpset() addsimps [real_divide_def, real_0_less_mult_iff]) 1); |
60 |
qed "real_0_less_divide_iff"; |
|
61 |
Addsimps [inst "x" "number_of ?w" real_0_less_divide_iff]; |
|
62 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
63 |
Goal "(x/y < (0::real)) = (0 < x & y < 0 | x < 0 & 0 < y)"; |
10722 | 64 |
by (simp_tac (simpset() addsimps [real_divide_def, real_mult_less_0_iff]) 1); |
65 |
qed "real_divide_less_0_iff"; |
|
66 |
Addsimps [inst "x" "number_of ?w" real_divide_less_0_iff]; |
|
67 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
68 |
Goal "((0::real) <= x/y) = ((x <= 0 | 0 <= y) & (0 <= x | y <= 0))"; |
10722 | 69 |
by (simp_tac (simpset() addsimps [real_divide_def, real_0_le_mult_iff]) 1); |
70 |
by Auto_tac; |
|
71 |
qed "real_0_le_divide_iff"; |
|
72 |
Addsimps [inst "x" "number_of ?w" real_0_le_divide_iff]; |
|
73 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
74 |
Goal "(x/y <= (0::real)) = ((x <= 0 | y <= 0) & (0 <= x | 0 <= y))"; |
10722 | 75 |
by (simp_tac (simpset() addsimps [real_divide_def, real_mult_le_0_iff]) 1); |
76 |
by Auto_tac; |
|
77 |
qed "real_divide_le_0_iff"; |
|
78 |
Addsimps [inst "x" "number_of ?w" real_divide_le_0_iff]; |
|
79 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
80 |
Goal "(inverse(x::real) = 0) = (x = 0)"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
81 |
by (auto_tac (claset(), simpset() addsimps [INVERSE_ZERO])); |
10722 | 82 |
by (rtac ccontr 1); |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
83 |
by (blast_tac (claset() addDs [real_inverse_not_zero]) 1); |
10722 | 84 |
qed "real_inverse_zero_iff"; |
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
85 |
Addsimps [real_inverse_zero_iff]; |
10722 | 86 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
87 |
Goal "(x/y = 0) = (x=0 | y=(0::real))"; |
10722 | 88 |
by (auto_tac (claset(), simpset() addsimps [real_divide_def])); |
89 |
qed "real_divide_eq_0_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
90 |
Addsimps [real_divide_eq_0_iff]; |
10722 | 91 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
92 |
Goal "h ~= (0::real) ==> h/h = 1"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
93 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_inv_left]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
94 |
qed "real_divide_self_eq"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
95 |
Addsimps [real_divide_self_eq]; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
96 |
|
10722 | 97 |
|
98 |
(**** Factor cancellation theorems for "real" ****) |
|
99 |
||
100 |
(** Cancellation laws for k*m < k*n and m*k < n*k, also for <= and =, |
|
101 |
but not (yet?) for k*m < n*k. **) |
|
12483
0a01efff43e9
new rewrite rules for use by arith_tac to take care of uminus.
nipkow
parents:
12018
diff
changeset
|
102 |
(* unused?? bind_thm ("real_mult_minus_right", real_minus_mult_eq2 RS sym); *) |
10722 | 103 |
|
104 |
Goal "(-y < -x) = ((x::real) < y)"; |
|
105 |
by (arith_tac 1); |
|
106 |
qed "real_minus_less_minus"; |
|
107 |
Addsimps [real_minus_less_minus]; |
|
108 |
||
109 |
Goal "[| i<j; k < (0::real) |] ==> j*k < i*k"; |
|
110 |
by (rtac (real_minus_less_minus RS iffD1) 1); |
|
12483
0a01efff43e9
new rewrite rules for use by arith_tac to take care of uminus.
nipkow
parents:
12018
diff
changeset
|
111 |
by (auto_tac (claset(), |
0a01efff43e9
new rewrite rules for use by arith_tac to take care of uminus.
nipkow
parents:
12018
diff
changeset
|
112 |
simpset() delsimps [real_mult_minus_eq2] |
10722 | 113 |
addsimps [real_minus_mult_eq2])); |
114 |
qed "real_mult_less_mono1_neg"; |
|
115 |
||
116 |
Goal "[| i<j; k < (0::real) |] ==> k*j < k*i"; |
|
117 |
by (rtac (real_minus_less_minus RS iffD1) 1); |
|
118 |
by (auto_tac (claset(), |
|
12483
0a01efff43e9
new rewrite rules for use by arith_tac to take care of uminus.
nipkow
parents:
12018
diff
changeset
|
119 |
simpset() delsimps [real_mult_minus_eq1] |
0a01efff43e9
new rewrite rules for use by arith_tac to take care of uminus.
nipkow
parents:
12018
diff
changeset
|
120 |
addsimps [real_minus_mult_eq1])); |
10722 | 121 |
qed "real_mult_less_mono2_neg"; |
122 |
||
123 |
Goal "[| i <= j; k <= (0::real) |] ==> j*k <= i*k"; |
|
124 |
by (auto_tac (claset(), |
|
125 |
simpset() addsimps [order_le_less, real_mult_less_mono1_neg])); |
|
126 |
qed "real_mult_le_mono1_neg"; |
|
127 |
||
128 |
Goal "[| i <= j; k <= (0::real) |] ==> k*j <= k*i"; |
|
129 |
by (dtac real_mult_le_mono1_neg 1); |
|
130 |
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [real_mult_commute]))); |
|
131 |
qed "real_mult_le_mono2_neg"; |
|
132 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
133 |
Goal "(m*k < n*k) = (((0::real) < k & m<n) | (k < 0 & n<m))"; |
10722 | 134 |
by (case_tac "k = (0::real)" 1); |
135 |
by (auto_tac (claset(), |
|
136 |
simpset() addsimps [linorder_neq_iff, |
|
137 |
real_mult_less_mono1, real_mult_less_mono1_neg])); |
|
138 |
by (auto_tac (claset(), |
|
139 |
simpset() addsimps [linorder_not_less, |
|
140 |
inst "y1" "m*k" (linorder_not_le RS sym), |
|
141 |
inst "y1" "m" (linorder_not_le RS sym)])); |
|
142 |
by (TRYALL (etac notE)); |
|
143 |
by (auto_tac (claset(), |
|
144 |
simpset() addsimps [order_less_imp_le, real_mult_le_mono1, |
|
145 |
real_mult_le_mono1_neg])); |
|
146 |
qed "real_mult_less_cancel2"; |
|
147 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
148 |
Goal "(m*k <= n*k) = (((0::real) < k --> m<=n) & (k < 0 --> n<=m))"; |
10722 | 149 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym, |
150 |
real_mult_less_cancel2]) 1); |
|
151 |
qed "real_mult_le_cancel2"; |
|
152 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
153 |
Goal "(k*m < k*n) = (((0::real) < k & m<n) | (k < 0 & n<m))"; |
10722 | 154 |
by (simp_tac (simpset() addsimps [inst "z" "k" real_mult_commute, |
155 |
real_mult_less_cancel2]) 1); |
|
156 |
qed "real_mult_less_cancel1"; |
|
157 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
158 |
Goal "!!k::real. (k*m <= k*n) = ((0 < k --> m<=n) & (k < 0 --> n<=m))"; |
10722 | 159 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym, |
160 |
real_mult_less_cancel1]) 1); |
|
161 |
qed "real_mult_le_cancel1"; |
|
162 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
163 |
Goal "!!k::real. (k*m = k*n) = (k = 0 | m=n)"; |
10722 | 164 |
by (case_tac "k=0" 1); |
165 |
by (auto_tac (claset(), simpset() addsimps [real_mult_left_cancel])); |
|
166 |
qed "real_mult_eq_cancel1"; |
|
167 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
168 |
Goal "!!k::real. (m*k = n*k) = (k = 0 | m=n)"; |
10722 | 169 |
by (case_tac "k=0" 1); |
170 |
by (auto_tac (claset(), simpset() addsimps [real_mult_right_cancel])); |
|
171 |
qed "real_mult_eq_cancel2"; |
|
172 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
173 |
Goal "!!k::real. k~=0 ==> (k*m) / (k*n) = (m/n)"; |
10722 | 174 |
by (asm_simp_tac |
175 |
(simpset() addsimps [real_divide_def, real_inverse_distrib]) 1); |
|
176 |
by (subgoal_tac "k * m * (inverse k * inverse n) = \ |
|
177 |
\ (k * inverse k) * (m * inverse n)" 1); |
|
178 |
by (asm_full_simp_tac (simpset() addsimps []) 1); |
|
179 |
by (asm_full_simp_tac (HOL_ss addsimps real_mult_ac) 1); |
|
180 |
qed "real_mult_div_cancel1"; |
|
181 |
||
182 |
(*For ExtractCommonTerm*) |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
183 |
Goal "(k*m) / (k*n) = (if k = (0::real) then 0 else m/n)"; |
10722 | 184 |
by (simp_tac (simpset() addsimps [real_mult_div_cancel1]) 1); |
185 |
qed "real_mult_div_cancel_disj"; |
|
186 |
||
187 |
||
188 |
local |
|
189 |
open Real_Numeral_Simprocs |
|
190 |
in |
|
191 |
||
192 |
val rel_real_number_of = [eq_real_number_of, less_real_number_of, |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
193 |
le_real_number_of_eq_not_less] |
10722 | 194 |
|
195 |
structure CancelNumeralFactorCommon = |
|
196 |
struct |
|
197 |
val mk_coeff = mk_coeff |
|
198 |
val dest_coeff = dest_coeff 1 |
|
199 |
val trans_tac = trans_tac |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
200 |
val norm_tac = |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
201 |
ALLGOALS (simp_tac (HOL_ss addsimps real_minus_from_mult_simps @ mult_1s)) |
10722 | 202 |
THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@real_mult_minus_simps)) |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
203 |
THEN ALLGOALS (simp_tac (HOL_ss addsimps real_mult_ac)) |
10722 | 204 |
val numeral_simp_tac = |
205 |
ALLGOALS (simp_tac (HOL_ss addsimps rel_real_number_of@bin_simps)) |
|
206 |
val simplify_meta_eq = simplify_meta_eq |
|
207 |
end |
|
208 |
||
209 |
structure DivCancelNumeralFactor = CancelNumeralFactorFun |
|
210 |
(open CancelNumeralFactorCommon |
|
211 |
val prove_conv = prove_conv "realdiv_cancel_numeral_factor" |
|
212 |
val mk_bal = HOLogic.mk_binop "HOL.divide" |
|
213 |
val dest_bal = HOLogic.dest_bin "HOL.divide" HOLogic.realT |
|
214 |
val cancel = real_mult_div_cancel1 RS trans |
|
215 |
val neg_exchanges = false |
|
216 |
) |
|
217 |
||
218 |
structure EqCancelNumeralFactor = CancelNumeralFactorFun |
|
219 |
(open CancelNumeralFactorCommon |
|
220 |
val prove_conv = prove_conv "realeq_cancel_numeral_factor" |
|
221 |
val mk_bal = HOLogic.mk_eq |
|
222 |
val dest_bal = HOLogic.dest_bin "op =" HOLogic.realT |
|
223 |
val cancel = real_mult_eq_cancel1 RS trans |
|
224 |
val neg_exchanges = false |
|
225 |
) |
|
226 |
||
227 |
structure LessCancelNumeralFactor = CancelNumeralFactorFun |
|
228 |
(open CancelNumeralFactorCommon |
|
229 |
val prove_conv = prove_conv "realless_cancel_numeral_factor" |
|
230 |
val mk_bal = HOLogic.mk_binrel "op <" |
|
231 |
val dest_bal = HOLogic.dest_bin "op <" HOLogic.realT |
|
232 |
val cancel = real_mult_less_cancel1 RS trans |
|
233 |
val neg_exchanges = true |
|
234 |
) |
|
235 |
||
236 |
structure LeCancelNumeralFactor = CancelNumeralFactorFun |
|
237 |
(open CancelNumeralFactorCommon |
|
238 |
val prove_conv = prove_conv "realle_cancel_numeral_factor" |
|
239 |
val mk_bal = HOLogic.mk_binrel "op <=" |
|
240 |
val dest_bal = HOLogic.dest_bin "op <=" HOLogic.realT |
|
241 |
val cancel = real_mult_le_cancel1 RS trans |
|
242 |
val neg_exchanges = true |
|
243 |
) |
|
244 |
||
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
245 |
val real_cancel_numeral_factors_relations = |
10722 | 246 |
map prep_simproc |
247 |
[("realeq_cancel_numeral_factor", |
|
248 |
prep_pats ["(l::real) * m = n", "(l::real) = m * n"], |
|
249 |
EqCancelNumeralFactor.proc), |
|
250 |
("realless_cancel_numeral_factor", |
|
251 |
prep_pats ["(l::real) * m < n", "(l::real) < m * n"], |
|
252 |
LessCancelNumeralFactor.proc), |
|
253 |
("realle_cancel_numeral_factor", |
|
254 |
prep_pats ["(l::real) * m <= n", "(l::real) <= m * n"], |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
255 |
LeCancelNumeralFactor.proc)] |
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
256 |
|
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
257 |
val real_cancel_numeral_factors_divide = prep_simproc |
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
258 |
("realdiv_cancel_numeral_factor", |
10825
47c4a76b0c7a
additional pattern allows reduction of fractions to lowest terms
paulson
parents:
10784
diff
changeset
|
259 |
prep_pats ["((l::real) * m) / n", "(l::real) / (m * n)", |
47c4a76b0c7a
additional pattern allows reduction of fractions to lowest terms
paulson
parents:
10784
diff
changeset
|
260 |
"((number_of v)::real) / (number_of w)"], |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
261 |
DivCancelNumeralFactor.proc) |
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
262 |
|
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
263 |
val real_cancel_numeral_factors = |
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
264 |
real_cancel_numeral_factors_relations @ |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
265 |
[real_cancel_numeral_factors_divide] |
10722 | 266 |
|
267 |
end; |
|
268 |
||
269 |
Addsimprocs real_cancel_numeral_factors; |
|
270 |
||
271 |
||
272 |
(*examples: |
|
273 |
print_depth 22; |
|
274 |
set timing; |
|
275 |
set trace_simp; |
|
276 |
fun test s = (Goal s; by (Simp_tac 1)); |
|
277 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
278 |
test "0 <= (y::real) * -2"; |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
279 |
test "9*x = 12 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
280 |
test "(9*x) / (12 * (y::real)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
281 |
test "9*x < 12 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
282 |
test "9*x <= 12 * (y::real)"; |
10722 | 283 |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
284 |
test "-99*x = 132 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
285 |
test "(-99*x) / (132 * (y::real)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
286 |
test "-99*x < 132 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
287 |
test "-99*x <= 132 * (y::real)"; |
10722 | 288 |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
289 |
test "999*x = -396 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
290 |
test "(999*x) / (-396 * (y::real)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
291 |
test "999*x < -396 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
292 |
test "999*x <= -396 * (y::real)"; |
10722 | 293 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
294 |
test "(- ((2::real) * x) <= 2 * y)"; |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
295 |
test "-99*x = -81 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
296 |
test "(-99*x) / (-81 * (y::real)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
297 |
test "-99*x <= -81 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
298 |
test "-99*x < -81 * (y::real)"; |
10722 | 299 |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
300 |
test "-2 * x = -1 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
301 |
test "-2 * x = -(y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
302 |
test "(-2 * x) / (-1 * (y::real)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
303 |
test "-2 * x < -(y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
304 |
test "-2 * x <= -1 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
305 |
test "-x < -23 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
306 |
test "-x <= -23 * (y::real)"; |
10722 | 307 |
*) |
308 |
||
309 |
||
310 |
(** Declarations for ExtractCommonTerm **) |
|
311 |
||
312 |
local |
|
313 |
open Real_Numeral_Simprocs |
|
314 |
in |
|
315 |
||
316 |
structure CancelFactorCommon = |
|
317 |
struct |
|
318 |
val mk_sum = long_mk_prod |
|
319 |
val dest_sum = dest_prod |
|
320 |
val mk_coeff = mk_coeff |
|
321 |
val dest_coeff = dest_coeff |
|
322 |
val find_first = find_first [] |
|
323 |
val trans_tac = trans_tac |
|
324 |
val norm_tac = ALLGOALS (simp_tac (HOL_ss addsimps mult_1s@real_mult_ac)) |
|
325 |
end; |
|
326 |
||
327 |
structure EqCancelFactor = ExtractCommonTermFun |
|
328 |
(open CancelFactorCommon |
|
329 |
val prove_conv = prove_conv "real_eq_cancel_factor" |
|
330 |
val mk_bal = HOLogic.mk_eq |
|
331 |
val dest_bal = HOLogic.dest_bin "op =" HOLogic.realT |
|
332 |
val simplify_meta_eq = cancel_simplify_meta_eq real_mult_eq_cancel1 |
|
333 |
); |
|
334 |
||
335 |
||
336 |
structure DivideCancelFactor = ExtractCommonTermFun |
|
337 |
(open CancelFactorCommon |
|
338 |
val prove_conv = prove_conv "real_divide_cancel_factor" |
|
339 |
val mk_bal = HOLogic.mk_binop "HOL.divide" |
|
340 |
val dest_bal = HOLogic.dest_bin "HOL.divide" HOLogic.realT |
|
341 |
val simplify_meta_eq = cancel_simplify_meta_eq real_mult_div_cancel_disj |
|
342 |
); |
|
343 |
||
344 |
val real_cancel_factor = |
|
345 |
map prep_simproc |
|
346 |
[("real_eq_cancel_factor", |
|
347 |
prep_pats ["(l::real) * m = n", "(l::real) = m * n"], |
|
348 |
EqCancelFactor.proc), |
|
349 |
("real_divide_cancel_factor", |
|
350 |
prep_pats ["((l::real) * m) / n", "(l::real) / (m * n)"], |
|
351 |
DivideCancelFactor.proc)]; |
|
352 |
||
353 |
end; |
|
354 |
||
355 |
Addsimprocs real_cancel_factor; |
|
356 |
||
357 |
||
358 |
(*examples: |
|
359 |
print_depth 22; |
|
360 |
set timing; |
|
361 |
set trace_simp; |
|
362 |
fun test s = (Goal s; by (Asm_simp_tac 1)); |
|
363 |
||
364 |
test "x*k = k*(y::real)"; |
|
365 |
test "k = k*(y::real)"; |
|
366 |
test "a*(b*c) = (b::real)"; |
|
367 |
test "a*(b*c) = d*(b::real)*(x*a)"; |
|
368 |
||
369 |
||
370 |
test "(x*k) / (k*(y::real)) = (uu::real)"; |
|
371 |
test "(k) / (k*(y::real)) = (uu::real)"; |
|
372 |
test "(a*(b*c)) / ((b::real)) = (uu::real)"; |
|
373 |
test "(a*(b*c)) / (d*(b::real)*(x*a)) = (uu::real)"; |
|
374 |
||
375 |
(*FIXME: what do we do about this?*) |
|
376 |
test "a*(b*c)/(y*z) = d*(b::real)*(x*a)/z"; |
|
377 |
*) |
|
378 |
||
379 |
||
380 |
(*** Simplification of inequalities involving literal divisors ***) |
|
381 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
382 |
Goal "0<z ==> ((x::real) <= y/z) = (x*z <= y)"; |
10722 | 383 |
by (subgoal_tac "(x*z <= y) = (x*z <= (y/z)*z)" 1); |
384 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
385 |
by (etac ssubst 1); |
|
386 |
by (stac real_mult_le_cancel2 1); |
|
387 |
by (Asm_simp_tac 1); |
|
388 |
qed "pos_real_le_divide_eq"; |
|
389 |
Addsimps [inst "z" "number_of ?w" pos_real_le_divide_eq]; |
|
390 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
391 |
Goal "z<0 ==> ((x::real) <= y/z) = (y <= x*z)"; |
10722 | 392 |
by (subgoal_tac "(y <= x*z) = ((y/z)*z <= x*z)" 1); |
393 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
394 |
by (etac ssubst 1); |
|
395 |
by (stac real_mult_le_cancel2 1); |
|
396 |
by (Asm_simp_tac 1); |
|
397 |
qed "neg_real_le_divide_eq"; |
|
398 |
Addsimps [inst "z" "number_of ?w" neg_real_le_divide_eq]; |
|
399 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
400 |
Goal "0<z ==> (y/z <= (x::real)) = (y <= x*z)"; |
10722 | 401 |
by (subgoal_tac "(y <= x*z) = ((y/z)*z <= x*z)" 1); |
402 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
403 |
by (etac ssubst 1); |
|
404 |
by (stac real_mult_le_cancel2 1); |
|
405 |
by (Asm_simp_tac 1); |
|
406 |
qed "pos_real_divide_le_eq"; |
|
407 |
Addsimps [inst "z" "number_of ?w" pos_real_divide_le_eq]; |
|
408 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
409 |
Goal "z<0 ==> (y/z <= (x::real)) = (x*z <= y)"; |
10722 | 410 |
by (subgoal_tac "(x*z <= y) = (x*z <= (y/z)*z)" 1); |
411 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
412 |
by (etac ssubst 1); |
|
413 |
by (stac real_mult_le_cancel2 1); |
|
414 |
by (Asm_simp_tac 1); |
|
415 |
qed "neg_real_divide_le_eq"; |
|
416 |
Addsimps [inst "z" "number_of ?w" neg_real_divide_le_eq]; |
|
417 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
418 |
Goal "0<z ==> ((x::real) < y/z) = (x*z < y)"; |
10722 | 419 |
by (subgoal_tac "(x*z < y) = (x*z < (y/z)*z)" 1); |
420 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
421 |
by (etac ssubst 1); |
|
422 |
by (stac real_mult_less_cancel2 1); |
|
423 |
by (Asm_simp_tac 1); |
|
424 |
qed "pos_real_less_divide_eq"; |
|
425 |
Addsimps [inst "z" "number_of ?w" pos_real_less_divide_eq]; |
|
426 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
427 |
Goal "z<0 ==> ((x::real) < y/z) = (y < x*z)"; |
10722 | 428 |
by (subgoal_tac "(y < x*z) = ((y/z)*z < x*z)" 1); |
429 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
430 |
by (etac ssubst 1); |
|
431 |
by (stac real_mult_less_cancel2 1); |
|
432 |
by (Asm_simp_tac 1); |
|
433 |
qed "neg_real_less_divide_eq"; |
|
434 |
Addsimps [inst "z" "number_of ?w" neg_real_less_divide_eq]; |
|
435 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
436 |
Goal "0<z ==> (y/z < (x::real)) = (y < x*z)"; |
10722 | 437 |
by (subgoal_tac "(y < x*z) = ((y/z)*z < x*z)" 1); |
438 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
439 |
by (etac ssubst 1); |
|
440 |
by (stac real_mult_less_cancel2 1); |
|
441 |
by (Asm_simp_tac 1); |
|
442 |
qed "pos_real_divide_less_eq"; |
|
443 |
Addsimps [inst "z" "number_of ?w" pos_real_divide_less_eq]; |
|
444 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
445 |
Goal "z<0 ==> (y/z < (x::real)) = (x*z < y)"; |
10722 | 446 |
by (subgoal_tac "(x*z < y) = (x*z < (y/z)*z)" 1); |
447 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
448 |
by (etac ssubst 1); |
|
449 |
by (stac real_mult_less_cancel2 1); |
|
450 |
by (Asm_simp_tac 1); |
|
451 |
qed "neg_real_divide_less_eq"; |
|
452 |
Addsimps [inst "z" "number_of ?w" neg_real_divide_less_eq]; |
|
453 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
454 |
Goal "z~=0 ==> ((x::real) = y/z) = (x*z = y)"; |
10722 | 455 |
by (subgoal_tac "(x*z = y) = (x*z = (y/z)*z)" 1); |
456 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
457 |
by (etac ssubst 1); |
|
458 |
by (stac real_mult_eq_cancel2 1); |
|
459 |
by (Asm_simp_tac 1); |
|
460 |
qed "real_eq_divide_eq"; |
|
461 |
Addsimps [inst "z" "number_of ?w" real_eq_divide_eq]; |
|
462 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
463 |
Goal "z~=0 ==> (y/z = (x::real)) = (y = x*z)"; |
10722 | 464 |
by (subgoal_tac "(y = x*z) = ((y/z)*z = x*z)" 1); |
465 |
by (asm_simp_tac (simpset() addsimps [real_divide_def, real_mult_assoc]) 2); |
|
466 |
by (etac ssubst 1); |
|
467 |
by (stac real_mult_eq_cancel2 1); |
|
468 |
by (Asm_simp_tac 1); |
|
469 |
qed "real_divide_eq_eq"; |
|
470 |
Addsimps [inst "z" "number_of ?w" real_divide_eq_eq]; |
|
471 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
472 |
Goal "(m/k = n/k) = (k = 0 | m = (n::real))"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
473 |
by (case_tac "k=0" 1); |
10722 | 474 |
by (asm_simp_tac (simpset() addsimps [REAL_DIVIDE_ZERO]) 1); |
475 |
by (asm_simp_tac (simpset() addsimps [real_divide_eq_eq, real_eq_divide_eq, |
|
476 |
real_mult_eq_cancel2]) 1); |
|
477 |
qed "real_divide_eq_cancel2"; |
|
478 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
479 |
Goal "(k/m = k/n) = (k = 0 | m = (n::real))"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
480 |
by (case_tac "m=0 | n = 0" 1); |
10722 | 481 |
by (auto_tac (claset(), |
482 |
simpset() addsimps [REAL_DIVIDE_ZERO, real_divide_eq_eq, |
|
483 |
real_eq_divide_eq, real_mult_eq_cancel1])); |
|
484 |
qed "real_divide_eq_cancel1"; |
|
485 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
486 |
(*Moved from RealOrd.ML to use 0 *) |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
487 |
Goal "[| 0 < r; 0 < x|] ==> (inverse x < inverse (r::real)) = (r < x)"; |
10722 | 488 |
by (auto_tac (claset() addIs [real_inverse_less_swap], simpset())); |
489 |
by (res_inst_tac [("t","r")] (real_inverse_inverse RS subst) 1); |
|
490 |
by (res_inst_tac [("t","x")] (real_inverse_inverse RS subst) 1); |
|
491 |
by (auto_tac (claset() addIs [real_inverse_less_swap], |
|
492 |
simpset() delsimps [real_inverse_inverse] |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
493 |
addsimps [real_inverse_gt_0])); |
10722 | 494 |
qed "real_inverse_less_iff"; |
495 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
496 |
Goal "[| 0 < r; 0 < x|] ==> (inverse x <= inverse r) = (r <= (x::real))"; |
10722 | 497 |
by (asm_simp_tac (simpset() addsimps [linorder_not_less RS sym, |
498 |
real_inverse_less_iff]) 1); |
|
499 |
qed "real_inverse_le_iff"; |
|
500 |
||
501 |
(** Division by 1, -1 **) |
|
502 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
503 |
Goal "(x::real)/1 = x"; |
10722 | 504 |
by (simp_tac (simpset() addsimps [real_divide_def]) 1); |
505 |
qed "real_divide_1"; |
|
506 |
Addsimps [real_divide_1]; |
|
507 |
||
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
508 |
Goal "x/-1 = -(x::real)"; |
10722 | 509 |
by (Simp_tac 1); |
510 |
qed "real_divide_minus1"; |
|
511 |
Addsimps [real_divide_minus1]; |
|
512 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
513 |
Goal "-1/(x::real) = - (1/x)"; |
10722 | 514 |
by (simp_tac (simpset() addsimps [real_divide_def, real_minus_inverse]) 1); |
515 |
qed "real_minus1_divide"; |
|
516 |
Addsimps [real_minus1_divide]; |
|
517 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
518 |
Goal "[| (0::real) < d1; 0 < d2 |] ==> EX e. 0 < e & e < d1 & e < d2"; |
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
519 |
by (res_inst_tac [("x","(min d1 d2)/2")] exI 1); |
10722 | 520 |
by (asm_simp_tac (simpset() addsimps [min_def]) 1); |
521 |
qed "real_lbound_gt_zero"; |
|
522 |
||
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
523 |
Goal "(inverse x = inverse y) = (x = (y::real))"; |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
524 |
by (case_tac "x=0 | y=0" 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
525 |
by (auto_tac (claset(), |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
526 |
simpset() addsimps [real_inverse_eq_divide, |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
527 |
DIVISION_BY_ZERO])); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
528 |
by (dres_inst_tac [("f","%u. x*y*u")] arg_cong 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
529 |
by (Asm_full_simp_tac 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
530 |
qed "real_inverse_eq_iff"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
531 |
Addsimps [real_inverse_eq_iff]; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
532 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
533 |
Goal "(z/x = z/y) = (z = 0 | x = (y::real))"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
534 |
by (case_tac "x=0 | y=0" 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
535 |
by (auto_tac (claset(), |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
536 |
simpset() addsimps [DIVISION_BY_ZERO])); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
537 |
by (dres_inst_tac [("f","%u. x*y*u")] arg_cong 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
538 |
by Auto_tac; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
539 |
qed "real_divide_eq_iff"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
540 |
Addsimps [real_divide_eq_iff]; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
541 |
|
10722 | 542 |
|
543 |
(*** General rewrites to improve automation, like those for type "int" ***) |
|
544 |
||
545 |
(** The next several equations can make the simplifier loop! **) |
|
546 |
||
547 |
Goal "(x < - y) = (y < - (x::real))"; |
|
548 |
by Auto_tac; |
|
549 |
qed "real_less_minus"; |
|
550 |
||
551 |
Goal "(- x < y) = (- y < (x::real))"; |
|
552 |
by Auto_tac; |
|
553 |
qed "real_minus_less"; |
|
554 |
||
555 |
Goal "(x <= - y) = (y <= - (x::real))"; |
|
556 |
by Auto_tac; |
|
557 |
qed "real_le_minus"; |
|
558 |
||
559 |
Goal "(- x <= y) = (- y <= (x::real))"; |
|
560 |
by Auto_tac; |
|
561 |
qed "real_minus_le"; |
|
562 |
||
563 |
Goal "(x = - y) = (y = - (x::real))"; |
|
564 |
by Auto_tac; |
|
565 |
qed "real_equation_minus"; |
|
566 |
||
567 |
Goal "(- x = y) = (- (y::real) = x)"; |
|
568 |
by Auto_tac; |
|
569 |
qed "real_minus_equation"; |
|
570 |
||
571 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
572 |
Goal "(x + - a = (0::real)) = (x=a)"; |
10722 | 573 |
by (arith_tac 1); |
574 |
qed "real_add_minus_iff"; |
|
575 |
Addsimps [real_add_minus_iff]; |
|
576 |
||
577 |
Goal "(-b = -a) = (b = (a::real))"; |
|
578 |
by (arith_tac 1); |
|
579 |
qed "real_minus_eq_cancel"; |
|
580 |
Addsimps [real_minus_eq_cancel]; |
|
581 |
||
582 |
||
583 |
(*Distributive laws for literals*) |
|
584 |
Addsimps (map (inst "w" "number_of ?v") |
|
585 |
[real_add_mult_distrib, real_add_mult_distrib2, |
|
586 |
real_diff_mult_distrib, real_diff_mult_distrib2]); |
|
587 |
||
588 |
Addsimps (map (inst "x" "number_of ?v") |
|
589 |
[real_less_minus, real_le_minus, real_equation_minus]); |
|
590 |
Addsimps (map (inst "y" "number_of ?v") |
|
591 |
[real_minus_less, real_minus_le, real_minus_equation]); |
|
592 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
593 |
(*Equations and inequations involving 1*) |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
594 |
Addsimps (map (simplify (simpset()) o inst "x" "1") |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
595 |
[real_less_minus, real_le_minus, real_equation_minus]); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
596 |
Addsimps (map (simplify (simpset()) o inst "y" "1") |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
597 |
[real_minus_less, real_minus_le, real_minus_equation]); |
10722 | 598 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
599 |
(*** Simprules combining x+y and 0 ***) |
10722 | 600 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
601 |
Goal "(x+y = (0::real)) = (y = -x)"; |
10722 | 602 |
by Auto_tac; |
603 |
qed "real_add_eq_0_iff"; |
|
604 |
AddIffs [real_add_eq_0_iff]; |
|
605 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
606 |
Goal "(x+y < (0::real)) = (y < -x)"; |
10722 | 607 |
by Auto_tac; |
608 |
qed "real_add_less_0_iff"; |
|
609 |
AddIffs [real_add_less_0_iff]; |
|
610 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
611 |
Goal "((0::real) < x+y) = (-x < y)"; |
10722 | 612 |
by Auto_tac; |
613 |
qed "real_0_less_add_iff"; |
|
614 |
AddIffs [real_0_less_add_iff]; |
|
615 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
616 |
Goal "(x+y <= (0::real)) = (y <= -x)"; |
10722 | 617 |
by Auto_tac; |
618 |
qed "real_add_le_0_iff"; |
|
619 |
AddIffs [real_add_le_0_iff]; |
|
620 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
621 |
Goal "((0::real) <= x+y) = (-x <= y)"; |
10722 | 622 |
by Auto_tac; |
623 |
qed "real_0_le_add_iff"; |
|
624 |
AddIffs [real_0_le_add_iff]; |
|
625 |
||
626 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
627 |
(** Simprules combining x-y and 0; see also real_less_iff_diff_less_0, etc., |
10722 | 628 |
in RealBin |
629 |
**) |
|
630 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
631 |
Goal "((0::real) < x-y) = (y < x)"; |
10722 | 632 |
by Auto_tac; |
633 |
qed "real_0_less_diff_iff"; |
|
634 |
AddIffs [real_0_less_diff_iff]; |
|
635 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
636 |
Goal "((0::real) <= x-y) = (y <= x)"; |
10722 | 637 |
by Auto_tac; |
638 |
qed "real_0_le_diff_iff"; |
|
639 |
AddIffs [real_0_le_diff_iff]; |
|
640 |
||
641 |
(* |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
642 |
FIXME: we should have this, as for type int, but many proofs would break. |
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
643 |
It replaces x+-y by x-y. |
10722 | 644 |
Addsimps [symmetric real_diff_def]; |
645 |
*) |
|
646 |
||
647 |
Goal "-(x-y) = y - (x::real)"; |
|
648 |
by (arith_tac 1); |
|
649 |
qed "real_minus_diff_eq"; |
|
650 |
Addsimps [real_minus_diff_eq]; |
|
651 |
||
652 |
||
653 |
(*** Density of the Reals ***) |
|
654 |
||
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
655 |
Goal "x < y ==> x < (x+y) / (2::real)"; |
10722 | 656 |
by Auto_tac; |
657 |
qed "real_less_half_sum"; |
|
658 |
||
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
659 |
Goal "x < y ==> (x+y)/(2::real) < y"; |
10722 | 660 |
by Auto_tac; |
661 |
qed "real_gt_half_sum"; |
|
662 |
||
663 |
Goal "x < y ==> EX r::real. x < r & r < y"; |
|
664 |
by (blast_tac (claset() addSIs [real_less_half_sum, real_gt_half_sum]) 1); |
|
665 |
qed "real_dense"; |
|
666 |
||
667 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
668 |
(*Replaces "inverse #nn" by 1/#nn *) |
10722 | 669 |
Addsimps [inst "x" "number_of ?w" real_inverse_eq_divide]; |
670 |
||
671 |