author | wenzelm |
Sat, 06 Oct 2001 00:02:46 +0200 | |
changeset 11704 | 3c50a2cd6f00 |
parent 11701 | 3d51fbf81c17 |
child 12018 | ec054019c910 |
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 |
||
11 |
(** Division and inverse **) |
|
12 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
13 |
Goal "Numeral0/x = (Numeral0::real)"; |
10722 | 14 |
by (simp_tac (simpset() addsimps [real_divide_def]) 1); |
15 |
qed "real_0_divide"; |
|
16 |
Addsimps [real_0_divide]; |
|
17 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
18 |
Goal "((Numeral0::real) < inverse x) = (Numeral0 < x)"; |
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
19 |
by (case_tac "x=Numeral0" 1); |
10722 | 20 |
by (asm_simp_tac (HOL_ss addsimps [rename_numerals INVERSE_ZERO]) 1); |
21 |
by (auto_tac (claset() addDs [rename_numerals real_inverse_less_zero], |
|
22 |
simpset() addsimps [linorder_neq_iff, |
|
23 |
rename_numerals real_inverse_gt_zero])); |
|
24 |
qed "real_0_less_inverse_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
25 |
Addsimps [real_0_less_inverse_iff]; |
10722 | 26 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
27 |
Goal "(inverse x < (Numeral0::real)) = (x < Numeral0)"; |
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
28 |
by (case_tac "x=Numeral0" 1); |
10722 | 29 |
by (asm_simp_tac (HOL_ss addsimps [rename_numerals INVERSE_ZERO]) 1); |
30 |
by (auto_tac (claset() addDs [rename_numerals real_inverse_less_zero], |
|
31 |
simpset() addsimps [linorder_neq_iff, |
|
32 |
rename_numerals real_inverse_gt_zero])); |
|
33 |
qed "real_inverse_less_0_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
34 |
Addsimps [real_inverse_less_0_iff]; |
10722 | 35 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
36 |
Goal "((Numeral0::real) <= inverse x) = (Numeral0 <= x)"; |
10722 | 37 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); |
38 |
qed "real_0_le_inverse_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
39 |
Addsimps [real_0_le_inverse_iff]; |
10722 | 40 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
41 |
Goal "(inverse x <= (Numeral0::real)) = (x <= Numeral0)"; |
10722 | 42 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym]) 1); |
43 |
qed "real_inverse_le_0_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
44 |
Addsimps [real_inverse_le_0_iff]; |
10722 | 45 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
46 |
Goalw [real_divide_def] "x/(Numeral0::real) = Numeral0"; |
10722 | 47 |
by (stac (rename_numerals INVERSE_ZERO) 1); |
48 |
by (Simp_tac 1); |
|
49 |
qed "REAL_DIVIDE_ZERO"; |
|
50 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
51 |
Goal "inverse (x::real) = Numeral1/x"; |
10722 | 52 |
by (simp_tac (simpset() addsimps [real_divide_def]) 1); |
53 |
qed "real_inverse_eq_divide"; |
|
54 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
55 |
Goal "((Numeral0::real) < x/y) = (Numeral0 < x & Numeral0 < y | x < Numeral0 & y < Numeral0)"; |
10722 | 56 |
by (simp_tac (simpset() addsimps [real_divide_def, real_0_less_mult_iff]) 1); |
57 |
qed "real_0_less_divide_iff"; |
|
58 |
Addsimps [inst "x" "number_of ?w" real_0_less_divide_iff]; |
|
59 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
60 |
Goal "(x/y < (Numeral0::real)) = (Numeral0 < x & y < Numeral0 | x < Numeral0 & Numeral0 < y)"; |
10722 | 61 |
by (simp_tac (simpset() addsimps [real_divide_def, real_mult_less_0_iff]) 1); |
62 |
qed "real_divide_less_0_iff"; |
|
63 |
Addsimps [inst "x" "number_of ?w" real_divide_less_0_iff]; |
|
64 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
65 |
Goal "((Numeral0::real) <= x/y) = ((x <= Numeral0 | Numeral0 <= y) & (Numeral0 <= x | y <= Numeral0))"; |
10722 | 66 |
by (simp_tac (simpset() addsimps [real_divide_def, real_0_le_mult_iff]) 1); |
67 |
by Auto_tac; |
|
68 |
qed "real_0_le_divide_iff"; |
|
69 |
Addsimps [inst "x" "number_of ?w" real_0_le_divide_iff]; |
|
70 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
71 |
Goal "(x/y <= (Numeral0::real)) = ((x <= Numeral0 | y <= Numeral0) & (Numeral0 <= x | Numeral0 <= y))"; |
10722 | 72 |
by (simp_tac (simpset() addsimps [real_divide_def, real_mult_le_0_iff]) 1); |
73 |
by Auto_tac; |
|
74 |
qed "real_divide_le_0_iff"; |
|
75 |
Addsimps [inst "x" "number_of ?w" real_divide_le_0_iff]; |
|
76 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
77 |
Goal "(inverse(x::real) = Numeral0) = (x = Numeral0)"; |
10722 | 78 |
by (auto_tac (claset(), simpset() addsimps [rename_numerals INVERSE_ZERO])); |
79 |
by (rtac ccontr 1); |
|
80 |
by (blast_tac (claset() addDs [rename_numerals real_inverse_not_zero]) 1); |
|
81 |
qed "real_inverse_zero_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
82 |
Addsimps [real_inverse_zero_iff]; |
10722 | 83 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
84 |
Goal "(x/y = Numeral0) = (x=Numeral0 | y=(Numeral0::real))"; |
10722 | 85 |
by (auto_tac (claset(), simpset() addsimps [real_divide_def])); |
86 |
qed "real_divide_eq_0_iff"; |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
87 |
Addsimps [real_divide_eq_0_iff]; |
10722 | 88 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
89 |
Goal "h ~= (Numeral0::real) ==> h/h = Numeral1"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
90 |
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
|
91 |
qed "real_divide_self_eq"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
92 |
Addsimps [real_divide_self_eq]; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
93 |
|
10722 | 94 |
|
95 |
(**** Factor cancellation theorems for "real" ****) |
|
96 |
||
97 |
(** Cancellation laws for k*m < k*n and m*k < n*k, also for <= and =, |
|
98 |
but not (yet?) for k*m < n*k. **) |
|
99 |
||
100 |
bind_thm ("real_mult_minus_right", real_minus_mult_eq2 RS sym); |
|
101 |
||
102 |
Goal "(-y < -x) = ((x::real) < y)"; |
|
103 |
by (arith_tac 1); |
|
104 |
qed "real_minus_less_minus"; |
|
105 |
Addsimps [real_minus_less_minus]; |
|
106 |
||
107 |
Goal "[| i<j; k < (0::real) |] ==> j*k < i*k"; |
|
108 |
by (rtac (real_minus_less_minus RS iffD1) 1); |
|
109 |
by (auto_tac (claset(), |
|
110 |
simpset() delsimps [real_minus_mult_eq2 RS sym] |
|
111 |
addsimps [real_minus_mult_eq2])); |
|
112 |
qed "real_mult_less_mono1_neg"; |
|
113 |
||
114 |
Goal "[| i<j; k < (0::real) |] ==> k*j < k*i"; |
|
115 |
by (rtac (real_minus_less_minus RS iffD1) 1); |
|
116 |
by (auto_tac (claset(), |
|
117 |
simpset() delsimps [real_minus_mult_eq1 RS sym] |
|
118 |
addsimps [real_minus_mult_eq1]));; |
|
119 |
qed "real_mult_less_mono2_neg"; |
|
120 |
||
121 |
Goal "[| i <= j; k <= (0::real) |] ==> j*k <= i*k"; |
|
122 |
by (auto_tac (claset(), |
|
123 |
simpset() addsimps [order_le_less, real_mult_less_mono1_neg])); |
|
124 |
qed "real_mult_le_mono1_neg"; |
|
125 |
||
126 |
Goal "[| i <= j; k <= (0::real) |] ==> k*j <= k*i"; |
|
127 |
by (dtac real_mult_le_mono1_neg 1); |
|
128 |
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [real_mult_commute]))); |
|
129 |
qed "real_mult_le_mono2_neg"; |
|
130 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
131 |
Goal "(m*k < n*k) = (((Numeral0::real) < k & m<n) | (k < Numeral0 & n<m))"; |
10722 | 132 |
by (case_tac "k = (0::real)" 1); |
133 |
by (auto_tac (claset(), |
|
134 |
simpset() addsimps [linorder_neq_iff, |
|
135 |
real_mult_less_mono1, real_mult_less_mono1_neg])); |
|
136 |
by (auto_tac (claset(), |
|
137 |
simpset() addsimps [linorder_not_less, |
|
138 |
inst "y1" "m*k" (linorder_not_le RS sym), |
|
139 |
inst "y1" "m" (linorder_not_le RS sym)])); |
|
140 |
by (TRYALL (etac notE)); |
|
141 |
by (auto_tac (claset(), |
|
142 |
simpset() addsimps [order_less_imp_le, real_mult_le_mono1, |
|
143 |
real_mult_le_mono1_neg])); |
|
144 |
qed "real_mult_less_cancel2"; |
|
145 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
146 |
Goal "(m*k <= n*k) = (((Numeral0::real) < k --> m<=n) & (k < Numeral0 --> n<=m))"; |
10722 | 147 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym, |
148 |
real_mult_less_cancel2]) 1); |
|
149 |
qed "real_mult_le_cancel2"; |
|
150 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
151 |
Goal "(k*m < k*n) = (((Numeral0::real) < k & m<n) | (k < Numeral0 & n<m))"; |
10722 | 152 |
by (simp_tac (simpset() addsimps [inst "z" "k" real_mult_commute, |
153 |
real_mult_less_cancel2]) 1); |
|
154 |
qed "real_mult_less_cancel1"; |
|
155 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
156 |
Goal "!!k::real. (k*m <= k*n) = ((Numeral0 < k --> m<=n) & (k < Numeral0 --> n<=m))"; |
10722 | 157 |
by (simp_tac (simpset() addsimps [linorder_not_less RS sym, |
158 |
real_mult_less_cancel1]) 1); |
|
159 |
qed "real_mult_le_cancel1"; |
|
160 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
161 |
Goal "!!k::real. (k*m = k*n) = (k = Numeral0 | m=n)"; |
10722 | 162 |
by (case_tac "k=0" 1); |
163 |
by (auto_tac (claset(), simpset() addsimps [real_mult_left_cancel])); |
|
164 |
qed "real_mult_eq_cancel1"; |
|
165 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
166 |
Goal "!!k::real. (m*k = n*k) = (k = Numeral0 | m=n)"; |
10722 | 167 |
by (case_tac "k=0" 1); |
168 |
by (auto_tac (claset(), simpset() addsimps [real_mult_right_cancel])); |
|
169 |
qed "real_mult_eq_cancel2"; |
|
170 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
171 |
Goal "!!k::real. k~=Numeral0 ==> (k*m) / (k*n) = (m/n)"; |
10722 | 172 |
by (asm_simp_tac |
173 |
(simpset() addsimps [real_divide_def, real_inverse_distrib]) 1); |
|
174 |
by (subgoal_tac "k * m * (inverse k * inverse n) = \ |
|
175 |
\ (k * inverse k) * (m * inverse n)" 1); |
|
176 |
by (asm_full_simp_tac (simpset() addsimps []) 1); |
|
177 |
by (asm_full_simp_tac (HOL_ss addsimps real_mult_ac) 1); |
|
178 |
qed "real_mult_div_cancel1"; |
|
179 |
||
180 |
(*For ExtractCommonTerm*) |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
181 |
Goal "(k*m) / (k*n) = (if k = (Numeral0::real) then Numeral0 else m/n)"; |
10722 | 182 |
by (simp_tac (simpset() addsimps [real_mult_div_cancel1]) 1); |
183 |
qed "real_mult_div_cancel_disj"; |
|
184 |
||
185 |
||
186 |
local |
|
187 |
open Real_Numeral_Simprocs |
|
188 |
in |
|
189 |
||
190 |
val rel_real_number_of = [eq_real_number_of, less_real_number_of, |
|
191 |
le_real_number_of_eq_not_less]; |
|
192 |
||
193 |
structure CancelNumeralFactorCommon = |
|
194 |
struct |
|
195 |
val mk_coeff = mk_coeff |
|
196 |
val dest_coeff = dest_coeff 1 |
|
197 |
val trans_tac = trans_tac |
|
198 |
val norm_tac = ALLGOALS (simp_tac (HOL_ss addsimps mult_plus_1s)) |
|
199 |
THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@real_mult_minus_simps)) |
|
200 |
THEN ALLGOALS |
|
201 |
(simp_tac |
|
202 |
(HOL_ss addsimps [eq_real_number_of, mult_real_number_of, |
|
203 |
real_mult_number_of_left]@ |
|
204 |
real_minus_from_mult_simps @ real_mult_ac)) |
|
205 |
val numeral_simp_tac = |
|
206 |
ALLGOALS (simp_tac (HOL_ss addsimps rel_real_number_of@bin_simps)) |
|
207 |
val simplify_meta_eq = simplify_meta_eq |
|
208 |
end |
|
209 |
||
210 |
structure DivCancelNumeralFactor = CancelNumeralFactorFun |
|
211 |
(open CancelNumeralFactorCommon |
|
212 |
val prove_conv = prove_conv "realdiv_cancel_numeral_factor" |
|
213 |
val mk_bal = HOLogic.mk_binop "HOL.divide" |
|
214 |
val dest_bal = HOLogic.dest_bin "HOL.divide" HOLogic.realT |
|
215 |
val cancel = real_mult_div_cancel1 RS trans |
|
216 |
val neg_exchanges = false |
|
217 |
) |
|
218 |
||
219 |
structure EqCancelNumeralFactor = CancelNumeralFactorFun |
|
220 |
(open CancelNumeralFactorCommon |
|
221 |
val prove_conv = prove_conv "realeq_cancel_numeral_factor" |
|
222 |
val mk_bal = HOLogic.mk_eq |
|
223 |
val dest_bal = HOLogic.dest_bin "op =" HOLogic.realT |
|
224 |
val cancel = real_mult_eq_cancel1 RS trans |
|
225 |
val neg_exchanges = false |
|
226 |
) |
|
227 |
||
228 |
structure LessCancelNumeralFactor = CancelNumeralFactorFun |
|
229 |
(open CancelNumeralFactorCommon |
|
230 |
val prove_conv = prove_conv "realless_cancel_numeral_factor" |
|
231 |
val mk_bal = HOLogic.mk_binrel "op <" |
|
232 |
val dest_bal = HOLogic.dest_bin "op <" HOLogic.realT |
|
233 |
val cancel = real_mult_less_cancel1 RS trans |
|
234 |
val neg_exchanges = true |
|
235 |
) |
|
236 |
||
237 |
structure LeCancelNumeralFactor = CancelNumeralFactorFun |
|
238 |
(open CancelNumeralFactorCommon |
|
239 |
val prove_conv = prove_conv "realle_cancel_numeral_factor" |
|
240 |
val mk_bal = HOLogic.mk_binrel "op <=" |
|
241 |
val dest_bal = HOLogic.dest_bin "op <=" HOLogic.realT |
|
242 |
val cancel = real_mult_le_cancel1 RS trans |
|
243 |
val neg_exchanges = true |
|
244 |
) |
|
245 |
||
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
246 |
val real_cancel_numeral_factors_relations = |
10722 | 247 |
map prep_simproc |
248 |
[("realeq_cancel_numeral_factor", |
|
249 |
prep_pats ["(l::real) * m = n", "(l::real) = m * n"], |
|
250 |
EqCancelNumeralFactor.proc), |
|
251 |
("realless_cancel_numeral_factor", |
|
252 |
prep_pats ["(l::real) * m < n", "(l::real) < m * n"], |
|
253 |
LessCancelNumeralFactor.proc), |
|
254 |
("realle_cancel_numeral_factor", |
|
255 |
prep_pats ["(l::real) * m <= n", "(l::real) <= m * n"], |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
256 |
LeCancelNumeralFactor.proc)]; |
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
257 |
|
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
258 |
val real_cancel_numeral_factors_divide = prep_simproc |
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
259 |
("realdiv_cancel_numeral_factor", |
10825
47c4a76b0c7a
additional pattern allows reduction of fractions to lowest terms
paulson
parents:
10784
diff
changeset
|
260 |
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
|
261 |
"((number_of v)::real) / (number_of w)"], |
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
262 |
DivCancelNumeralFactor.proc); |
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
263 |
|
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
264 |
val real_cancel_numeral_factors = |
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
265 |
real_cancel_numeral_factors_relations @ |
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
266 |
[real_cancel_numeral_factors_divide]; |
10722 | 267 |
|
268 |
end; |
|
269 |
||
270 |
Addsimprocs real_cancel_numeral_factors; |
|
271 |
||
272 |
||
273 |
(*examples: |
|
274 |
print_depth 22; |
|
275 |
set timing; |
|
276 |
set trace_simp; |
|
277 |
fun test s = (Goal s; by (Simp_tac 1)); |
|
278 |
||
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
279 |
test "Numeral0 <= (y::real) * -2"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
280 |
test "9*x = 12 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
281 |
test "(9*x) / (12 * (y::real)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
282 |
test "9*x < 12 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
283 |
test "9*x <= 12 * (y::real)"; |
10722 | 284 |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
285 |
test "-99*x = 132 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
286 |
test "(-99*x) / (132 * (y::real)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
287 |
test "-99*x < 132 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
288 |
test "-99*x <= 132 * (y::real)"; |
10722 | 289 |
|
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
290 |
test "999*x = -396 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
291 |
test "(999*x) / (-396 * (y::real)) = z"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
292 |
test "999*x < -396 * (y::real)"; |
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
293 |
test "999*x <= -396 * (y::real)"; |
10722 | 294 |
|
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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
382 |
Goal "Numeral0<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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
391 |
Goal "z<Numeral0 ==> ((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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
400 |
Goal "Numeral0<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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
409 |
Goal "z<Numeral0 ==> (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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
418 |
Goal "Numeral0<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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
427 |
Goal "z<Numeral0 ==> ((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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
436 |
Goal "Numeral0<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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
445 |
Goal "z<Numeral0 ==> (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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
454 |
Goal "z~=Numeral0 ==> ((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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
463 |
Goal "z~=Numeral0 ==> (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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
472 |
Goal "(m/k = n/k) = (k = Numeral0 | m = (n::real))"; |
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
473 |
by (case_tac "k=Numeral0" 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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
479 |
Goal "(k/m = k/n) = (k = Numeral0 | m = (n::real))"; |
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
480 |
by (case_tac "m=Numeral0 | n = Numeral0" 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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
486 |
(*Moved from RealOrd.ML to use Numeral0 *) |
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
487 |
Goal "[| Numeral0 < r; Numeral0 < 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] |
|
493 |
addsimps [real_inverse_gt_zero])); |
|
494 |
qed "real_inverse_less_iff"; |
|
495 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
496 |
Goal "[| Numeral0 < r; Numeral0 < 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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
503 |
Goal "(x::real)/Numeral1 = 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 |
||
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
513 |
Goal "-1/(x::real) = - (Numeral1/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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
518 |
Goal "[| (Numeral0::real) < d1; Numeral0 < d2 |] ==> EX e. Numeral0 < 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))"; |
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
524 |
by (case_tac "x=Numeral0 | y=Numeral0" 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, |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
527 |
rename_numerals DIVISION_BY_ZERO])); |
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 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
533 |
Goal "(z/x = z/y) = (z = Numeral0 | x = (y::real))"; |
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
534 |
by (case_tac "x=Numeral0 | y=Numeral0" 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
535 |
by (auto_tac (claset(), |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10752
diff
changeset
|
536 |
simpset() addsimps [rename_numerals DIVISION_BY_ZERO])); |
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 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
572 |
Goal "(x + - a = (Numeral0::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 |
||
593 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
594 |
(*** Simprules combining x+y and Numeral0 ***) |
10722 | 595 |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
596 |
Goal "(x+y = (Numeral0::real)) = (y = -x)"; |
10722 | 597 |
by Auto_tac; |
598 |
qed "real_add_eq_0_iff"; |
|
599 |
AddIffs [real_add_eq_0_iff]; |
|
600 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
601 |
Goal "(x+y < (Numeral0::real)) = (y < -x)"; |
10722 | 602 |
by Auto_tac; |
603 |
qed "real_add_less_0_iff"; |
|
604 |
AddIffs [real_add_less_0_iff]; |
|
605 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
606 |
Goal "((Numeral0::real) < x+y) = (-x < y)"; |
10722 | 607 |
by Auto_tac; |
608 |
qed "real_0_less_add_iff"; |
|
609 |
AddIffs [real_0_less_add_iff]; |
|
610 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
611 |
Goal "(x+y <= (Numeral0::real)) = (y <= -x)"; |
10722 | 612 |
by Auto_tac; |
613 |
qed "real_add_le_0_iff"; |
|
614 |
AddIffs [real_add_le_0_iff]; |
|
615 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
616 |
Goal "((Numeral0::real) <= x+y) = (-x <= y)"; |
10722 | 617 |
by Auto_tac; |
618 |
qed "real_0_le_add_iff"; |
|
619 |
AddIffs [real_0_le_add_iff]; |
|
620 |
||
621 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
622 |
(** Simprules combining x-y and Numeral0; see also real_less_iff_diff_less_0, etc., |
10722 | 623 |
in RealBin |
624 |
**) |
|
625 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
626 |
Goal "((Numeral0::real) < x-y) = (y < x)"; |
10722 | 627 |
by Auto_tac; |
628 |
qed "real_0_less_diff_iff"; |
|
629 |
AddIffs [real_0_less_diff_iff]; |
|
630 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
631 |
Goal "((Numeral0::real) <= x-y) = (y <= x)"; |
10722 | 632 |
by Auto_tac; |
633 |
qed "real_0_le_diff_iff"; |
|
634 |
AddIffs [real_0_le_diff_iff]; |
|
635 |
||
636 |
(* |
|
10752
c4f1bf2acf4c
tidying, and separation of HOL-Hyperreal from HOL-Real
paulson
parents:
10722
diff
changeset
|
637 |
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
|
638 |
It replaces x+-y by x-y. |
10722 | 639 |
Addsimps [symmetric real_diff_def]; |
640 |
*) |
|
641 |
||
642 |
Goal "-(x-y) = y - (x::real)"; |
|
643 |
by (arith_tac 1); |
|
644 |
qed "real_minus_diff_eq"; |
|
645 |
Addsimps [real_minus_diff_eq]; |
|
646 |
||
647 |
||
648 |
(*** Density of the Reals ***) |
|
649 |
||
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
650 |
Goal "x < y ==> x < (x+y) / (2::real)"; |
10722 | 651 |
by Auto_tac; |
652 |
qed "real_less_half_sum"; |
|
653 |
||
11704
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents:
11701
diff
changeset
|
654 |
Goal "x < y ==> (x+y)/(2::real) < y"; |
10722 | 655 |
by Auto_tac; |
656 |
qed "real_gt_half_sum"; |
|
657 |
||
658 |
Goal "x < y ==> EX r::real. x < r & r < y"; |
|
659 |
by (blast_tac (claset() addSIs [real_less_half_sum, real_gt_half_sum]) 1); |
|
660 |
qed "real_dense"; |
|
661 |
||
662 |
||
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
10825
diff
changeset
|
663 |
(*Replaces "inverse #nn" by Numeral1/#nn *) |
10722 | 664 |
Addsimps [inst "x" "number_of ?w" real_inverse_eq_divide]; |
665 |
||
666 |