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 *)
|
|
12 |
val simps =
|
|
13 |
[order_less_irrefl, zero_eq_numeral_0, one_eq_numeral_1,
|
|
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,
|
|
17 |
hypreal_minus_add_distrib, hypreal_minus_minus, hypreal_mult_assoc];
|
|
18 |
|
|
19 |
val add_rules =
|
|
20 |
map rename_numerals
|
|
21 |
[hypreal_add_zero_left, hypreal_add_zero_right,
|
|
22 |
hypreal_add_minus, hypreal_add_minus_left,
|
|
23 |
hypreal_mult_0, hypreal_mult_0_right,
|
|
24 |
hypreal_mult_1, hypreal_mult_1_right,
|
|
25 |
hypreal_mult_minus_1, hypreal_mult_minus_1_right];
|
|
26 |
|
|
27 |
val simprocs = [Hyperreal_Times_Assoc.conv,
|
|
28 |
Hyperreal_Numeral_Simprocs.combine_numerals]@
|
|
29 |
Hyperreal_Numeral_Simprocs.cancel_numerals;
|
|
30 |
|
|
31 |
val mono_ss = simpset() addsimps
|
|
32 |
[hypreal_add_le_mono,hypreal_add_less_mono,
|
|
33 |
hypreal_add_less_le_mono,hypreal_add_le_less_mono];
|
|
34 |
|
|
35 |
val add_mono_thms_hypreal =
|
|
36 |
map (fn s => prove_goal (the_context ()) s
|
|
37 |
(fn prems => [cut_facts_tac prems 1, asm_simp_tac mono_ss 1]))
|
|
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 |
"(i < j) & (k < l) ==> i + k < j + (l::hypreal)"];
|
|
47 |
|
|
48 |
val hypreal_arith_simproc_pats =
|
|
49 |
map (fn s => Thm.read_cterm (Theory.sign_of (the_context ()))
|
|
50 |
(s, HOLogic.boolT))
|
|
51 |
["(m::hypreal) < n", "(m::hypreal) <= n", "(m::hypreal) = n"];
|
|
52 |
|
|
53 |
fun cvar(th,_ $ (_ $ _ $ var)) = cterm_of (#sign(rep_thm th)) var;
|
|
54 |
|
|
55 |
val hypreal_mult_mono_thms =
|
|
56 |
[(rotate_prems 1 hypreal_mult_less_mono2,
|
|
57 |
cvar(hypreal_mult_less_mono2, hd(prems_of hypreal_mult_less_mono2))),
|
|
58 |
(hypreal_mult_le_mono2,
|
|
59 |
cvar(hypreal_mult_le_mono2, hd(tl(prems_of hypreal_mult_le_mono2))))]
|
|
60 |
|
|
61 |
in
|
|
62 |
|
|
63 |
val fast_hypreal_arith_simproc = mk_simproc
|
|
64 |
"fast_hypreal_arith" hypreal_arith_simproc_pats Fast_Arith.lin_arith_prover;
|
|
65 |
|
|
66 |
val hypreal_arith_setup =
|
|
67 |
[Fast_Arith.map_data (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, simpset} =>
|
|
68 |
{add_mono_thms = add_mono_thms @ add_mono_thms_hypreal,
|
|
69 |
mult_mono_thms = mult_mono_thms @ hypreal_mult_mono_thms,
|
|
70 |
inj_thms = inj_thms, (*FIXME: add hypreal*)
|
|
71 |
lessD = lessD, (*We don't change LA_Data_Ref.lessD because the hypreal ordering is dense!*)
|
|
72 |
simpset = simpset addsimps (add_rules @ simps)
|
|
73 |
addsimprocs simprocs}),
|
|
74 |
arith_discrete ("HyperDef.hypreal",false),
|
|
75 |
Simplifier.change_simpset_of (op addsimprocs) [fast_hypreal_arith_simproc]];
|
|
76 |
|
|
77 |
end;
|
|
78 |
|
|
79 |
|
|
80 |
(* Some test data [omitting examples that assume the ordering to be discrete!]
|
|
81 |
Goal "!!a::hypreal. [| a <= b; c <= d; x+y<z |] ==> a+c <= b+d";
|
|
82 |
by (fast_arith_tac 1);
|
|
83 |
qed "";
|
|
84 |
|
|
85 |
Goal "!!a::hypreal. [| a <= b; b+b <= c |] ==> a+a <= c";
|
|
86 |
by (fast_arith_tac 1);
|
|
87 |
qed "";
|
|
88 |
|
|
89 |
Goal "!!a::hypreal. [| a+b <= i+j; a<=b; i<=j |] ==> a+a <= j+j";
|
|
90 |
by (fast_arith_tac 1);
|
|
91 |
qed "";
|
|
92 |
|
|
93 |
Goal "!!a::hypreal. a+b+c <= i+j+k & a<=b & b<=c & i<=j & j<=k --> a+a+a <= k+k+k";
|
|
94 |
by (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 <= 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 <= l+l+l+l";
|
|
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 <= l+l+l+l+i";
|
|
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 |] \
|
|
113 |
\ ==> a+a+a+a+a+a <= l+l+l+l+i+l";
|
|
114 |
by (fast_arith_tac 1);
|
|
115 |
qed "";
|
|
116 |
|
|
117 |
Goal "!!a::hypreal. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \
|
|
118 |
\ ==> #6*a <= #5*l+i";
|
|
119 |
by (fast_arith_tac 1);
|
|
120 |
qed "";
|
|
121 |
*)
|