author | paulson |
Thu, 25 Dec 2003 22:48:32 +0100 | |
changeset 14329 | ff3210fe968f |
parent 14321 | 55c688d2eefa |
child 14334 | 6137d24eef79 |
permissions | -rw-r--r-- |
14321 | 1 |
(* Title: HOL/Real/real_arith0.ML |
10722 | 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 real. |
|
7 |
*) |
|
8 |
||
14321 | 9 |
|
10 |
||
10722 | 11 |
local |
12 |
||
13 |
(* reduce contradictory <= to False *) |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
14 |
val add_rules = |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
15 |
[order_less_irrefl, real_numeral_0_eq_0, real_numeral_1_eq_1, |
13554
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
16 |
real_minus_1_eq_m1, |
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
17 |
add_real_number_of, minus_real_number_of, diff_real_number_of, |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
18 |
mult_real_number_of, eq_real_number_of, less_real_number_of, |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
19 |
le_real_number_of_eq_not_less, real_diff_def, |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
20 |
real_minus_add_distrib, real_minus_minus, real_mult_assoc, |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
21 |
real_minus_zero, |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
22 |
real_add_zero_left, real_add_zero_right, |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
23 |
real_add_minus, real_add_minus_left, |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
24 |
real_mult_0, real_mult_0_right, |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
25 |
real_mult_1, real_mult_1_right, |
12483
0a01efff43e9
new rewrite rules for use by arith_tac to take care of uminus.
nipkow
parents:
12018
diff
changeset
|
26 |
real_mult_minus_eq1, real_mult_minus_eq2]; |
10722 | 27 |
|
28 |
val simprocs = [Real_Times_Assoc.conv, Real_Numeral_Simprocs.combine_numerals]@ |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
29 |
Real_Numeral_Simprocs.cancel_numerals @ |
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
30 |
Real_Numeral_Simprocs.eval_numerals; |
10722 | 31 |
|
32 |
val mono_ss = simpset() addsimps |
|
33 |
[real_add_le_mono,real_add_less_mono, |
|
34 |
real_add_less_le_mono,real_add_le_less_mono]; |
|
35 |
||
36 |
val add_mono_thms_real = |
|
37 |
map (fn s => prove_goal (the_context ()) s |
|
38 |
(fn prems => [cut_facts_tac prems 1, asm_simp_tac mono_ss 1])) |
|
39 |
["(i <= j) & (k <= l) ==> i + k <= j + (l::real)", |
|
40 |
"(i = j) & (k <= l) ==> i + k <= j + (l::real)", |
|
41 |
"(i <= j) & (k = l) ==> i + k <= j + (l::real)", |
|
42 |
"(i = j) & (k = l) ==> i + k = j + (l::real)", |
|
43 |
"(i < j) & (k = l) ==> i + k < j + (l::real)", |
|
44 |
"(i = j) & (k < l) ==> i + k < j + (l::real)", |
|
45 |
"(i < j) & (k <= l) ==> i + k < j + (l::real)", |
|
46 |
"(i <= j) & (k < l) ==> i + k < j + (l::real)", |
|
47 |
"(i < j) & (k < l) ==> i + k < j + (l::real)"]; |
|
48 |
||
49 |
fun cvar(th,_ $ (_ $ _ $ var)) = cterm_of (#sign(rep_thm th)) var; |
|
50 |
||
51 |
val real_mult_mono_thms = |
|
52 |
[(rotate_prems 1 real_mult_less_mono2, |
|
53 |
cvar(real_mult_less_mono2, hd(prems_of real_mult_less_mono2))), |
|
54 |
(real_mult_le_mono2, |
|
55 |
cvar(real_mult_le_mono2, hd(tl(prems_of real_mult_le_mono2))))] |
|
56 |
||
57 |
in |
|
58 |
||
13462 | 59 |
val fast_real_arith_simproc = Simplifier.simproc (Theory.sign_of (the_context ())) |
60 |
"fast_real_arith" ["(m::real) < n","(m::real) <= n", "(m::real) = n"] |
|
61 |
Fast_Arith.lin_arith_prover; |
|
10722 | 62 |
|
63 |
val real_arith_setup = |
|
64 |
[Fast_Arith.map_data (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, simpset} => |
|
65 |
{add_mono_thms = add_mono_thms @ add_mono_thms_real, |
|
66 |
mult_mono_thms = mult_mono_thms @ real_mult_mono_thms, |
|
67 |
inj_thms = inj_thms, (*FIXME: add real*) |
|
68 |
lessD = lessD, (*We don't change LA_Data_Ref.lessD because the real ordering is dense!*) |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
69 |
simpset = simpset addsimps add_rules |
10722 | 70 |
addsimprocs simprocs}), |
71 |
arith_discrete ("RealDef.real",false), |
|
72 |
Simplifier.change_simpset_of (op addsimprocs) [fast_real_arith_simproc]]; |
|
73 |
||
10760 | 74 |
(* some thms for injection nat => real: |
75 |
real_of_nat_zero |
|
12018
ec054019c910
Numerals and simprocs for types real and hypreal. The abstract
paulson
parents:
11704
diff
changeset
|
76 |
?zero_eq_numeral_0 |
10760 | 77 |
real_of_nat_add |
78 |
*) |
|
79 |
||
10722 | 80 |
end; |
81 |
||
82 |
||
83 |
(* Some test data [omitting examples that assume the ordering to be discrete!] |
|
84 |
Goal "!!a::real. [| a <= b; c <= d; x+y<z |] ==> a+c <= b+d"; |
|
85 |
by (fast_arith_tac 1); |
|
86 |
qed ""; |
|
87 |
||
88 |
Goal "!!a::real. [| a <= b; b+b <= c |] ==> a+a <= c"; |
|
89 |
by (fast_arith_tac 1); |
|
90 |
qed ""; |
|
91 |
||
92 |
Goal "!!a::real. [| a+b <= i+j; a<=b; i<=j |] ==> a+a <= j+j"; |
|
93 |
by (fast_arith_tac 1); |
|
94 |
qed ""; |
|
95 |
||
96 |
Goal "!!a::real. a+b+c <= i+j+k & a<=b & b<=c & i<=j & j<=k --> a+a+a <= k+k+k"; |
|
97 |
by (arith_tac 1); |
|
98 |
qed ""; |
|
99 |
||
100 |
Goal "!!a::real. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \ |
|
101 |
\ ==> a <= l"; |
|
102 |
by (fast_arith_tac 1); |
|
103 |
qed ""; |
|
104 |
||
105 |
Goal "!!a::real. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \ |
|
106 |
\ ==> a+a+a+a <= l+l+l+l"; |
|
107 |
by (fast_arith_tac 1); |
|
108 |
qed ""; |
|
109 |
||
110 |
Goal "!!a::real. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \ |
|
111 |
\ ==> a+a+a+a+a <= l+l+l+l+i"; |
|
112 |
by (fast_arith_tac 1); |
|
113 |
qed ""; |
|
114 |
||
115 |
Goal "!!a::real. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \ |
|
116 |
\ ==> a+a+a+a+a+a <= l+l+l+l+i+l"; |
|
117 |
by (fast_arith_tac 1); |
|
118 |
qed ""; |
|
119 |
||
120 |
Goal "!!a::real. [| 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
|
121 |
\ ==> 6*a <= 5*l+i"; |
10722 | 122 |
by (fast_arith_tac 1); |
123 |
qed ""; |
|
13554
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
124 |
|
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
125 |
Goal "a<=b ==> a < b+(1::real)"; |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
126 |
by (fast_arith_tac 1); |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
127 |
qed ""; |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
128 |
|
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
129 |
Goal "a<=b ==> a-(3::real) < b"; |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
130 |
by (fast_arith_tac 1); |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
131 |
qed ""; |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
132 |
|
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
133 |
Goal "a<=b ==> a-(1::real) < b"; |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
134 |
by (fast_arith_tac 1); |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
135 |
qed ""; |
4679359bb218
Added missing rewrite rule and some arith examples
paulson
parents:
13462
diff
changeset
|
136 |
|
10722 | 137 |
*) |