author | paulson |
Fri, 19 Dec 2003 10:38:39 +0100 | |
changeset 14303 | 995212a00a50 |
parent 14299 | 0b5c0b0a3eba |
child 14331 | 8dbbb7cf3637 |
permissions | -rw-r--r-- |
10750 | 1 |
(* Title : HRealAbs.ML |
2 |
Author : Jacques D. Fleuriot |
|
3 |
Copyright : 1998 University of Cambridge |
|
4 |
Description : Absolute value function for the hyperreals |
|
5 |
Similar to RealAbs.thy |
|
6 |
*) |
|
7 |
||
8 |
(*------------------------------------------------------------ |
|
9 |
absolute value on hyperreals as pointwise operation on |
|
10 |
equivalence class representative |
|
11 |
------------------------------------------------------------*) |
|
12 |
||
13 |
Goalw [hrabs_def] |
|
14 |
"abs (number_of v :: hypreal) = \ |
|
15 |
\ (if neg (number_of v) then number_of (bin_minus v) \ |
|
16 |
\ else number_of v)"; |
|
17 |
by (Simp_tac 1); |
|
18 |
qed "hrabs_number_of"; |
|
19 |
Addsimps [hrabs_number_of]; |
|
20 |
||
21 |
(*------------------------------------------------------------ |
|
22 |
Properties of the absolute value function over the reals |
|
23 |
(adapted version of previously proved theorems about abs) |
|
24 |
------------------------------------------------------------*) |
|
25 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
26 |
Goal "abs (0::hypreal) = 0"; |
10750 | 27 |
by (simp_tac (simpset() addsimps [hrabs_def]) 1); |
28 |
qed "hrabs_zero"; |
|
29 |
Addsimps [hrabs_zero]; |
|
30 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
31 |
Goal "abs (1::hypreal) = 1"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
32 |
by (simp_tac (simpset() addsimps [hrabs_def]) 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
33 |
qed "hrabs_one"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
34 |
Addsimps [hrabs_one]; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
35 |
|
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
36 |
Goal "(0::hypreal)<=x ==> abs x = x"; |
10750 | 37 |
by (asm_simp_tac (simpset() addsimps [hrabs_def]) 1); |
38 |
qed "hrabs_eqI1"; |
|
39 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
40 |
Goal "(0::hypreal)<x ==> abs x = x"; |
10750 | 41 |
by (asm_simp_tac (simpset() addsimps [order_less_imp_le, hrabs_eqI1]) 1); |
42 |
qed "hrabs_eqI2"; |
|
43 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
44 |
Goal "x<(0::hypreal) ==> abs x = -x"; |
10750 | 45 |
by (asm_simp_tac (simpset() addsimps [hypreal_le_def, hrabs_def]) 1); |
46 |
qed "hrabs_minus_eqI2"; |
|
47 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
48 |
Goal "x<=(0::hypreal) ==> abs x = -x"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
49 |
by (auto_tac (claset() addDs [order_antisym], simpset() addsimps [hrabs_def]));qed "hrabs_minus_eqI1"; |
10750 | 50 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
51 |
Goal "(0::hypreal)<= abs x"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
52 |
by (simp_tac (simpset() addsimps [hrabs_def]) 1); |
10750 | 53 |
qed "hrabs_ge_zero"; |
54 |
||
55 |
Goal "abs(abs x) = abs (x::hypreal)"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
56 |
by (simp_tac (simpset() addsimps [hrabs_def]) 1); |
10750 | 57 |
qed "hrabs_idempotent"; |
58 |
Addsimps [hrabs_idempotent]; |
|
59 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
60 |
Goalw [hrabs_def] "(abs x = (0::hypreal)) = (x=0)"; |
10750 | 61 |
by (Simp_tac 1); |
62 |
qed "hrabs_zero_iff"; |
|
63 |
AddIffs [hrabs_zero_iff]; |
|
64 |
||
65 |
Goalw [hrabs_def] "(x::hypreal) <= abs x"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
66 |
by (Simp_tac 1); |
10750 | 67 |
qed "hrabs_ge_self"; |
68 |
||
69 |
Goalw [hrabs_def] "-(x::hypreal) <= abs x"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
70 |
by (Simp_tac 1); |
10750 | 71 |
qed "hrabs_ge_minus_self"; |
72 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
73 |
(* proof by "transfer" *) |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
74 |
Goal "abs(x*(y::hypreal)) = (abs x)*(abs y)"; |
10750 | 75 |
by (res_inst_tac [("z","x")] eq_Abs_hypreal 1); |
76 |
by (res_inst_tac [("z","y")] eq_Abs_hypreal 1); |
|
77 |
by (auto_tac (claset(), |
|
78 |
simpset() addsimps [hypreal_hrabs, hypreal_mult,abs_mult])); |
|
79 |
qed "hrabs_mult"; |
|
80 |
Addsimps [hrabs_mult]; |
|
81 |
||
82 |
Goal "abs(inverse(x)) = inverse(abs(x::hypreal))"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
83 |
by (simp_tac (simpset() addsimps [hypreal_minus_inverse, hrabs_def]) 1); |
10750 | 84 |
qed "hrabs_inverse"; |
85 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
86 |
Goalw [hrabs_def] "abs(x+(y::hypreal)) <= abs x + abs y"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
87 |
by (Simp_tac 1); |
10750 | 88 |
qed "hrabs_triangle_ineq"; |
89 |
||
90 |
Goal "abs((w::hypreal) + x + y) <= abs(w) + abs(x) + abs(y)"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
91 |
by (simp_tac (simpset() addsimps [hrabs_triangle_ineq RS order_trans]) 1); |
10750 | 92 |
qed "hrabs_triangle_ineq_three"; |
93 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
94 |
Goalw [hrabs_def] "abs(-x) = abs((x::hypreal))"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
95 |
by (Simp_tac 1); |
10750 | 96 |
qed "hrabs_minus_cancel"; |
97 |
Addsimps [hrabs_minus_cancel]; |
|
98 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
99 |
Goalw [hrabs_def] "[| abs x < r; abs y < s |] ==> abs(x+y) < r + (s::hypreal)"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
100 |
by (asm_full_simp_tac (simpset() addsplits [split_if_asm]) 1); |
10750 | 101 |
qed "hrabs_add_less"; |
102 |
||
103 |
Goal "[| abs x<r; abs y<s |] ==> abs x * abs y < r * (s::hypreal)"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
104 |
by (subgoal_tac "0 < r" 1); |
10750 | 105 |
by (asm_full_simp_tac (simpset() addsimps [hrabs_def] |
106 |
addsplits [split_if_asm]) 2); |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
107 |
by (case_tac "y = 0" 1); |
10750 | 108 |
by (asm_full_simp_tac (simpset() addsimps [hypreal_0_less_mult_iff]) 1); |
109 |
by (rtac hypreal_mult_less_mono 1); |
|
110 |
by (auto_tac (claset(), |
|
111 |
simpset() addsimps [hrabs_def, linorder_neq_iff] |
|
112 |
addsplits [split_if_asm])); |
|
113 |
qed "hrabs_mult_less"; |
|
114 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
115 |
Goal "((0::hypreal) < abs x) = (x ~= 0)"; |
10750 | 116 |
by (simp_tac (simpset() addsimps [hrabs_def]) 1); |
117 |
by (arith_tac 1); |
|
118 |
qed "hypreal_0_less_abs_iff"; |
|
119 |
Addsimps [hypreal_0_less_abs_iff]; |
|
120 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
121 |
Goal "abs x < r ==> (0::hypreal) < r"; |
10750 | 122 |
by (blast_tac (claset() addSIs [order_le_less_trans, hrabs_ge_zero]) 1); |
123 |
qed "hrabs_less_gt_zero"; |
|
124 |
||
125 |
Goal "abs x = (x::hypreal) | abs x = -x"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
126 |
by (simp_tac (simpset() addsimps [hrabs_def]) 1); |
10750 | 127 |
qed "hrabs_disj"; |
128 |
||
129 |
Goal "abs x = (y::hypreal) ==> x = y | -x = y"; |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
130 |
by (asm_full_simp_tac (simpset() addsimps [hrabs_def] |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
131 |
addsplits [split_if_asm]) 1); |
10750 | 132 |
qed "hrabs_eq_disj"; |
133 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
134 |
Goalw [hrabs_def] "(abs x < (r::hypreal)) = (-r < x & x < r)"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
135 |
by Auto_tac; |
10750 | 136 |
qed "hrabs_interval_iff"; |
137 |
||
138 |
Goal "(abs x < (r::hypreal)) = (- x < r & x < r)"; |
|
139 |
by (auto_tac (claset(), simpset() addsimps [hrabs_interval_iff])); |
|
140 |
qed "hrabs_interval_iff2"; |
|
141 |
||
142 |
||
143 |
(* Needed in Geom.ML *) |
|
144 |
Goal "(y::hypreal) + - x + (y + - z) = abs (x + - z) ==> y = z | x = y"; |
|
145 |
by (asm_full_simp_tac (simpset() addsimps [hrabs_def] |
|
146 |
addsplits [split_if_asm]) 1); |
|
147 |
qed "hrabs_add_lemma_disj"; |
|
148 |
||
149 |
Goal "abs((x::hypreal) + -y) = abs (y + -x)"; |
|
150 |
by (simp_tac (simpset() addsimps [hrabs_def]) 1); |
|
151 |
qed "hrabs_minus_add_cancel"; |
|
152 |
||
153 |
(* Needed in Geom.ML?? *) |
|
154 |
Goal "(x::hypreal) + - y + (z + - y) = abs (x + - z) ==> y = z | x = y"; |
|
155 |
by (asm_full_simp_tac (simpset() addsimps [hrabs_def] |
|
156 |
addsplits [split_if_asm]) 1); |
|
157 |
qed "hrabs_add_lemma_disj2"; |
|
158 |
||
159 |
||
160 |
(*---------------------------------------------------------- |
|
161 |
Relating hrabs to abs through embedding of IR into IR* |
|
162 |
----------------------------------------------------------*) |
|
163 |
Goalw [hypreal_of_real_def] |
|
164 |
"abs (hypreal_of_real r) = hypreal_of_real (abs r)"; |
|
165 |
by (auto_tac (claset(), simpset() addsimps [hypreal_hrabs])); |
|
166 |
qed "hypreal_of_real_hrabs"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
167 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
168 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
169 |
(*---------------------------------------------------------------------------- |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
170 |
Embedding of the naturals in the hyperreals |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
171 |
----------------------------------------------------------------------------*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
172 |
|
10784 | 173 |
Goal "hypreal_of_nat (m + n) = hypreal_of_nat m + hypreal_of_nat n"; |
174 |
by (simp_tac (simpset() addsimps [hypreal_of_nat_def]) 1); |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
175 |
qed "hypreal_of_nat_add"; |
10784 | 176 |
Addsimps [hypreal_of_nat_add]; |
177 |
||
178 |
Goal "hypreal_of_nat (m * n) = hypreal_of_nat m * hypreal_of_nat n"; |
|
179 |
by (simp_tac (simpset() addsimps [hypreal_of_nat_def]) 1); |
|
180 |
qed "hypreal_of_nat_mult"; |
|
181 |
Addsimps [hypreal_of_nat_mult]; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
182 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
183 |
Goalw [hypreal_of_nat_def] |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
184 |
"(n < m) = (hypreal_of_nat n < hypreal_of_nat m)"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
185 |
by (auto_tac (claset() addIs [hypreal_add_less_mono1], simpset())); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
186 |
qed "hypreal_of_nat_less_iff"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
187 |
Addsimps [hypreal_of_nat_less_iff RS sym]; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
188 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
189 |
(*------------------------------------------------------------*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
190 |
(* naturals embedded in hyperreals *) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
191 |
(* is a hyperreal c.f. NS extension *) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
192 |
(*------------------------------------------------------------*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
193 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
194 |
Goalw [hypreal_of_nat_def, hypreal_of_real_def, real_of_nat_def] |
10919
144ede948e58
renamings: real_of_nat, real_of_int -> (overloaded) real
paulson
parents:
10834
diff
changeset
|
195 |
"hypreal_of_nat m = Abs_hypreal(hyprel``{%n. real m})"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
196 |
by Auto_tac; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
197 |
qed "hypreal_of_nat_iff"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
198 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
199 |
Goal "inj hypreal_of_nat"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
200 |
by (simp_tac (simpset() addsimps [inj_on_def, hypreal_of_nat_def]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
201 |
qed "inj_hypreal_of_nat"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
202 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
203 |
Goalw [hypreal_of_nat_def] |
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
204 |
"hypreal_of_nat (Suc n) = hypreal_of_nat n + (1::hypreal)"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
205 |
by (simp_tac (simpset() addsimps [real_of_nat_Suc]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
206 |
qed "hypreal_of_nat_Suc"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
207 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
208 |
(*"neg" is used in rewrite rules for binary comparisons*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
209 |
Goal "hypreal_of_nat (number_of v :: nat) = \ |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
210 |
\ (if neg (number_of v) then 0 \ |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
211 |
\ else (number_of v :: hypreal))"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
212 |
by (simp_tac (simpset() addsimps [hypreal_of_nat_def]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
213 |
qed "hypreal_of_nat_number_of"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
214 |
Addsimps [hypreal_of_nat_number_of]; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
215 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
216 |
Goal "hypreal_of_nat 0 = 0"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
217 |
by (simp_tac (simpset() delsimps [numeral_0_eq_0] |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
218 |
addsimps [numeral_0_eq_0 RS sym]) 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
219 |
qed "hypreal_of_nat_zero"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
220 |
Addsimps [hypreal_of_nat_zero]; |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
221 |
|
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
222 |
Goal "hypreal_of_nat 1 = 1"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
223 |
by (simp_tac (simpset() addsimps [hypreal_of_nat_Suc]) 1); |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
224 |
qed "hypreal_of_nat_one"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
225 |
Addsimps [hypreal_of_nat_one]; |