author | paulson |
Sat, 03 Jan 2004 16:09:39 +0100 | |
changeset 14336 | 8f731d3cd65b |
parent 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 "(0::hypreal)<=x ==> abs x = x"; |
10750 | 27 |
by (asm_simp_tac (simpset() addsimps [hrabs_def]) 1); |
28 |
qed "hrabs_eqI1"; |
|
29 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
30 |
Goal "(0::hypreal)<x ==> abs x = x"; |
10750 | 31 |
by (asm_simp_tac (simpset() addsimps [order_less_imp_le, hrabs_eqI1]) 1); |
32 |
qed "hrabs_eqI2"; |
|
33 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
34 |
Goal "x<(0::hypreal) ==> abs x = -x"; |
10750 | 35 |
by (asm_simp_tac (simpset() addsimps [hypreal_le_def, hrabs_def]) 1); |
36 |
qed "hrabs_minus_eqI2"; |
|
37 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
38 |
Goal "x<=(0::hypreal) ==> abs x = -x"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
39 |
by (auto_tac (claset() addDs [order_antisym], simpset() addsimps [hrabs_def]));qed "hrabs_minus_eqI1"; |
10750 | 40 |
|
14336 | 41 |
Addsimps [abs_mult]; |
10750 | 42 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
43 |
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
|
44 |
by (asm_full_simp_tac (simpset() addsplits [split_if_asm]) 1); |
10750 | 45 |
qed "hrabs_add_less"; |
46 |
||
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
47 |
Goal "abs x < r ==> (0::hypreal) < r"; |
14336 | 48 |
by (blast_tac (claset() addSIs [order_le_less_trans, abs_ge_zero]) 1); |
10750 | 49 |
qed "hrabs_less_gt_zero"; |
50 |
||
51 |
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
|
52 |
by (simp_tac (simpset() addsimps [hrabs_def]) 1); |
10750 | 53 |
qed "hrabs_disj"; |
54 |
||
55 |
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
|
56 |
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
|
57 |
addsplits [split_if_asm]) 1); |
10750 | 58 |
qed "hrabs_eq_disj"; |
59 |
||
60 |
(* Needed in Geom.ML *) |
|
61 |
Goal "(y::hypreal) + - x + (y + - z) = abs (x + - z) ==> y = z | x = y"; |
|
62 |
by (asm_full_simp_tac (simpset() addsimps [hrabs_def] |
|
63 |
addsplits [split_if_asm]) 1); |
|
64 |
qed "hrabs_add_lemma_disj"; |
|
65 |
||
66 |
(* Needed in Geom.ML?? *) |
|
67 |
Goal "(x::hypreal) + - y + (z + - y) = abs (x + - z) ==> y = z | x = y"; |
|
68 |
by (asm_full_simp_tac (simpset() addsimps [hrabs_def] |
|
69 |
addsplits [split_if_asm]) 1); |
|
70 |
qed "hrabs_add_lemma_disj2"; |
|
71 |
||
72 |
||
73 |
(*---------------------------------------------------------- |
|
74 |
Relating hrabs to abs through embedding of IR into IR* |
|
75 |
----------------------------------------------------------*) |
|
76 |
Goalw [hypreal_of_real_def] |
|
77 |
"abs (hypreal_of_real r) = hypreal_of_real (abs r)"; |
|
78 |
by (auto_tac (claset(), simpset() addsimps [hypreal_hrabs])); |
|
79 |
qed "hypreal_of_real_hrabs"; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
80 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
81 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
82 |
(*---------------------------------------------------------------------------- |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
83 |
Embedding of the naturals in the hyperreals |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
84 |
----------------------------------------------------------------------------*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
85 |
|
10784 | 86 |
Goal "hypreal_of_nat (m + n) = hypreal_of_nat m + hypreal_of_nat n"; |
87 |
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
|
88 |
qed "hypreal_of_nat_add"; |
10784 | 89 |
Addsimps [hypreal_of_nat_add]; |
90 |
||
91 |
Goal "hypreal_of_nat (m * n) = hypreal_of_nat m * hypreal_of_nat n"; |
|
92 |
by (simp_tac (simpset() addsimps [hypreal_of_nat_def]) 1); |
|
93 |
qed "hypreal_of_nat_mult"; |
|
94 |
Addsimps [hypreal_of_nat_mult]; |
|
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
95 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
96 |
Goalw [hypreal_of_nat_def] |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
97 |
"(n < m) = (hypreal_of_nat n < hypreal_of_nat m)"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
98 |
by (auto_tac (claset() addIs [hypreal_add_less_mono1], simpset())); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
99 |
qed "hypreal_of_nat_less_iff"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
100 |
Addsimps [hypreal_of_nat_less_iff RS sym]; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
101 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
102 |
(*------------------------------------------------------------*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
103 |
(* naturals embedded in hyperreals *) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
104 |
(* is a hyperreal c.f. NS extension *) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
105 |
(*------------------------------------------------------------*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
106 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
107 |
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
|
108 |
"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
|
109 |
by Auto_tac; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
110 |
qed "hypreal_of_nat_iff"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
111 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
112 |
Goal "inj hypreal_of_nat"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
113 |
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
|
114 |
qed "inj_hypreal_of_nat"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
115 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
116 |
Goalw [hypreal_of_nat_def] |
11713
883d559b0b8c
sane numerals (stage 3): provide generic "1" on all number types;
wenzelm
parents:
11701
diff
changeset
|
117 |
"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
|
118 |
by (simp_tac (simpset() addsimps [real_of_nat_Suc]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
119 |
qed "hypreal_of_nat_Suc"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
120 |
|
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
121 |
(*"neg" is used in rewrite rules for binary comparisons*) |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
122 |
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
|
123 |
\ (if neg (number_of v) then 0 \ |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
124 |
\ else (number_of v :: hypreal))"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
125 |
by (simp_tac (simpset() addsimps [hypreal_of_nat_def]) 1); |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
126 |
qed "hypreal_of_nat_number_of"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
127 |
Addsimps [hypreal_of_nat_number_of]; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
128 |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
129 |
Goal "hypreal_of_nat 0 = 0"; |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
130 |
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
|
131 |
addsimps [numeral_0_eq_0 RS sym]) 1); |
10778
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
132 |
qed "hypreal_of_nat_zero"; |
2c6605049646
more tidying, especially to remove real_of_posnat
paulson
parents:
10750
diff
changeset
|
133 |
Addsimps [hypreal_of_nat_zero]; |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
134 |
|
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
135 |
Goal "hypreal_of_nat 1 = 1"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
136 |
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
|
137 |
qed "hypreal_of_nat_one"; |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11713
diff
changeset
|
138 |
Addsimps [hypreal_of_nat_one]; |