| author | paulson | 
| Thu, 18 Dec 2003 15:06:24 +0100 | |
| changeset 14301 | 48dc606749bd | 
| parent 13462 | 56610e2ba220 | 
| child 14331 | 8dbbb7cf3637 | 
| permissions | -rw-r--r-- | 
| 10751 | 1  | 
(* Title: HOL/Hyperreal/hypreal_arith.ML  | 
2  | 
ID: $Id$  | 
|
3  | 
Author: Tobias Nipkow, TU Muenchen  | 
|
4  | 
Copyright 1999 TU Muenchen  | 
|
5  | 
||
6  | 
Instantiation of the generic linear arithmetic package for type hypreal.  | 
|
7  | 
*)  | 
|
8  | 
||
9  | 
local  | 
|
10  | 
||
11  | 
(* reduce contradictory <= to False *)  | 
|
| 
12018
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
12  | 
val add_rules =  | 
| 
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
13  | 
[order_less_irrefl, hypreal_numeral_0_eq_0, hypreal_numeral_1_eq_1,  | 
| 10751 | 14  | 
add_hypreal_number_of, minus_hypreal_number_of, diff_hypreal_number_of,  | 
15  | 
mult_hypreal_number_of, eq_hypreal_number_of, less_hypreal_number_of,  | 
|
16  | 
le_hypreal_number_of_eq_not_less, hypreal_diff_def,  | 
|
| 
12018
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
17  | 
hypreal_minus_add_distrib, hypreal_minus_minus, hypreal_mult_assoc,  | 
| 
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
18  | 
hypreal_minus_zero,  | 
| 
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
19  | 
hypreal_add_zero_left, hypreal_add_zero_right,  | 
| 
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
20  | 
hypreal_add_minus, hypreal_add_minus_left,  | 
| 
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
21  | 
hypreal_mult_0, hypreal_mult_0_right,  | 
| 
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
22  | 
hypreal_mult_1, hypreal_mult_1_right,  | 
| 
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
23  | 
hypreal_mult_minus_1, hypreal_mult_minus_1_right];  | 
| 10751 | 24  | 
|
25  | 
val simprocs = [Hyperreal_Times_Assoc.conv,  | 
|
26  | 
Hyperreal_Numeral_Simprocs.combine_numerals]@  | 
|
| 
12018
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
27  | 
Hyperreal_Numeral_Simprocs.cancel_numerals @  | 
| 
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
28  | 
Hyperreal_Numeral_Simprocs.eval_numerals;  | 
| 10751 | 29  | 
|
30  | 
val mono_ss = simpset() addsimps  | 
|
31  | 
[hypreal_add_le_mono,hypreal_add_less_mono,  | 
|
32  | 
hypreal_add_less_le_mono,hypreal_add_le_less_mono];  | 
|
33  | 
||
34  | 
val add_mono_thms_hypreal =  | 
|
35  | 
map (fn s => prove_goal (the_context ()) s  | 
|
36  | 
(fn prems => [cut_facts_tac prems 1, asm_simp_tac mono_ss 1]))  | 
|
37  | 
["(i <= j) & (k <= l) ==> i + k <= j + (l::hypreal)",  | 
|
38  | 
"(i = j) & (k <= l) ==> i + k <= j + (l::hypreal)",  | 
|
39  | 
"(i <= j) & (k = l) ==> i + k <= j + (l::hypreal)",  | 
|
40  | 
"(i = j) & (k = l) ==> i + k = j + (l::hypreal)",  | 
|
41  | 
"(i < j) & (k = l) ==> i + k < j + (l::hypreal)",  | 
|
42  | 
"(i = j) & (k < l) ==> i + k < j + (l::hypreal)",  | 
|
43  | 
"(i < j) & (k <= l) ==> i + k < j + (l::hypreal)",  | 
|
44  | 
"(i <= j) & (k < l) ==> i + k < j + (l::hypreal)",  | 
|
45  | 
"(i < j) & (k < l) ==> i + k < j + (l::hypreal)"];  | 
|
46  | 
||
47  | 
fun cvar(th,_ $ (_ $ _ $ var)) = cterm_of (#sign(rep_thm th)) var;  | 
|
48  | 
||
49  | 
val hypreal_mult_mono_thms =  | 
|
50  | 
[(rotate_prems 1 hypreal_mult_less_mono2,  | 
|
51  | 
cvar(hypreal_mult_less_mono2, hd(prems_of hypreal_mult_less_mono2))),  | 
|
52  | 
(hypreal_mult_le_mono2,  | 
|
53  | 
cvar(hypreal_mult_le_mono2, hd(tl(prems_of hypreal_mult_le_mono2))))]  | 
|
54  | 
||
55  | 
in  | 
|
56  | 
||
| 13462 | 57  | 
val fast_hypreal_arith_simproc =  | 
58  | 
Simplifier.simproc (Theory.sign_of (the_context ()))  | 
|
59  | 
"fast_hypreal_arith" ["(m::hypreal) < n", "(m::hypreal) <= n", "(m::hypreal) = n"]  | 
|
60  | 
Fast_Arith.lin_arith_prover;  | 
|
| 10751 | 61  | 
|
62  | 
val hypreal_arith_setup =  | 
|
63  | 
 [Fast_Arith.map_data (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, simpset} =>
 | 
|
64  | 
   {add_mono_thms = add_mono_thms @ add_mono_thms_hypreal,
 | 
|
65  | 
mult_mono_thms = mult_mono_thms @ hypreal_mult_mono_thms,  | 
|
66  | 
inj_thms = inj_thms, (*FIXME: add hypreal*)  | 
|
67  | 
lessD = lessD, (*We don't change LA_Data_Ref.lessD because the hypreal ordering is dense!*)  | 
|
| 
12018
 
ec054019c910
Numerals and simprocs for types real and hypreal.  The abstract
 
paulson 
parents: 
11704 
diff
changeset
 | 
68  | 
simpset = simpset addsimps add_rules addsimprocs simprocs}),  | 
| 10751 | 69  | 
  arith_discrete ("HyperDef.hypreal",false),
 | 
70  | 
Simplifier.change_simpset_of (op addsimprocs) [fast_hypreal_arith_simproc]];  | 
|
71  | 
||
72  | 
end;  | 
|
73  | 
||
74  | 
||
75  | 
(* Some test data [omitting examples that assume the ordering to be discrete!]  | 
|
76  | 
Goal "!!a::hypreal. [| a <= b; c <= d; x+y<z |] ==> a+c <= b+d";  | 
|
77  | 
by (fast_arith_tac 1);  | 
|
78  | 
qed "";  | 
|
79  | 
||
80  | 
Goal "!!a::hypreal. [| a <= b; b+b <= c |] ==> a+a <= c";  | 
|
81  | 
by (fast_arith_tac 1);  | 
|
82  | 
qed "";  | 
|
83  | 
||
84  | 
Goal "!!a::hypreal. [| a+b <= i+j; a<=b; i<=j |] ==> a+a <= j+j";  | 
|
85  | 
by (fast_arith_tac 1);  | 
|
86  | 
qed "";  | 
|
87  | 
||
88  | 
Goal "!!a::hypreal. a+b+c <= i+j+k & a<=b & b<=c & i<=j & j<=k --> a+a+a <= k+k+k";  | 
|
89  | 
by (arith_tac 1);  | 
|
90  | 
qed "";  | 
|
91  | 
||
92  | 
Goal "!!a::hypreal. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \  | 
|
93  | 
\ ==> a <= l";  | 
|
94  | 
by (fast_arith_tac 1);  | 
|
95  | 
qed "";  | 
|
96  | 
||
97  | 
Goal "!!a::hypreal. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \  | 
|
98  | 
\ ==> a+a+a+a <= l+l+l+l";  | 
|
99  | 
by (fast_arith_tac 1);  | 
|
100  | 
qed "";  | 
|
101  | 
||
102  | 
Goal "!!a::hypreal. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \  | 
|
103  | 
\ ==> a+a+a+a+a <= l+l+l+l+i";  | 
|
104  | 
by (fast_arith_tac 1);  | 
|
105  | 
qed "";  | 
|
106  | 
||
107  | 
Goal "!!a::hypreal. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \  | 
|
108  | 
\ ==> a+a+a+a+a+a <= l+l+l+l+i+l";  | 
|
109  | 
by (fast_arith_tac 1);  | 
|
110  | 
qed "";  | 
|
111  | 
||
112  | 
Goal "!!a::hypreal. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \  | 
|
| 
11704
 
3c50a2cd6f00
* sane numerals (stage 2): plain "num" syntax (removed "#");
 
wenzelm 
parents: 
11701 
diff
changeset
 | 
113  | 
\ ==> 6*a <= 5*l+i";  | 
| 10751 | 114  | 
by (fast_arith_tac 1);  | 
115  | 
qed "";  | 
|
116  | 
*)  |