| author | wenzelm | 
| Tue, 05 Nov 2024 22:05:50 +0100 | |
| changeset 81350 | 1818358373e2 | 
| parent 81116 | 0fb1e2dd4122 | 
| child 83334 | 97662e2e7f9e | 
| permissions | -rw-r--r-- | 
| 
73546
 
7cb3fefef79e
confluent preprocessing for floats in presence of target language numerals
 
haftmann 
parents: 
73537 
diff
changeset
 | 
1  | 
(* Author: Johannes Hoelzl, TU Muenchen  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
2  | 
Coercions removed by Dmitriy Traytel *)  | 
| 30122 | 3  | 
|
| 40892 | 4  | 
theory Approximation  | 
| 
41413
 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 
wenzelm 
parents: 
41024 
diff
changeset
 | 
5  | 
imports  | 
| 
 
64cd30d6b0b8
explicit file specifications -- avoid secondary load path;
 
wenzelm 
parents: 
41024 
diff
changeset
 | 
6  | 
Complex_Main  | 
| 
65582
 
a1bc1b020cf2
tuned Approximation: separated general material from oracle
 
eberlm <eberlm@in.tum.de> 
parents: 
65578 
diff
changeset
 | 
7  | 
Approximation_Bounds  | 
| 
73546
 
7cb3fefef79e
confluent preprocessing for floats in presence of target language numerals
 
haftmann 
parents: 
73537 
diff
changeset
 | 
8  | 
"HOL-Library.Code_Target_Numeral_Float"  | 
| 56923 | 9  | 
keywords "approximate" :: diag  | 
| 29805 | 10  | 
begin  | 
11  | 
||
12  | 
section "Implement floatarith"  | 
|
13  | 
||
14  | 
subsection "Define syntax and semantics"  | 
|
15  | 
||
| 58310 | 16  | 
datatype floatarith  | 
| 29805 | 17  | 
= Add floatarith floatarith  | 
18  | 
| Minus floatarith  | 
|
19  | 
| Mult floatarith floatarith  | 
|
20  | 
| Inverse floatarith  | 
|
21  | 
| Cos floatarith  | 
|
22  | 
| Arctan floatarith  | 
|
23  | 
| Abs floatarith  | 
|
24  | 
| Max floatarith floatarith  | 
|
25  | 
| Min floatarith floatarith  | 
|
26  | 
| Pi  | 
|
27  | 
| Sqrt floatarith  | 
|
28  | 
| Exp floatarith  | 
|
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
29  | 
| Powr floatarith floatarith  | 
| 29805 | 30  | 
| Ln floatarith  | 
31  | 
| Power floatarith nat  | 
|
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
32  | 
| Floor floatarith  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
33  | 
| Var nat  | 
| 29805 | 34  | 
| Num float  | 
35  | 
||
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
36  | 
fun interpret_floatarith :: "floatarith \<Rightarrow> real list \<Rightarrow> real" where  | 
| 
31098
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
37  | 
"interpret_floatarith (Add a b) vs = (interpret_floatarith a vs) + (interpret_floatarith b vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
38  | 
"interpret_floatarith (Minus a) vs = - (interpret_floatarith a vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
39  | 
"interpret_floatarith (Mult a b) vs = (interpret_floatarith a vs) * (interpret_floatarith b vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
40  | 
"interpret_floatarith (Inverse a) vs = inverse (interpret_floatarith a vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
41  | 
"interpret_floatarith (Cos a) vs = cos (interpret_floatarith a vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
42  | 
"interpret_floatarith (Arctan a) vs = arctan (interpret_floatarith a vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
43  | 
"interpret_floatarith (Min a b) vs = min (interpret_floatarith a vs) (interpret_floatarith b vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
44  | 
"interpret_floatarith (Max a b) vs = max (interpret_floatarith a vs) (interpret_floatarith b vs)" |  | 
| 61945 | 45  | 
"interpret_floatarith (Abs a) vs = \<bar>interpret_floatarith a vs\<bar>" |  | 
| 
31098
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
46  | 
"interpret_floatarith Pi vs = pi" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
47  | 
"interpret_floatarith (Sqrt a) vs = sqrt (interpret_floatarith a vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
48  | 
"interpret_floatarith (Exp a) vs = exp (interpret_floatarith a vs)" |  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
49  | 
"interpret_floatarith (Powr a b) vs = interpret_floatarith a vs powr interpret_floatarith b vs" |  | 
| 
31098
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
50  | 
"interpret_floatarith (Ln a) vs = ln (interpret_floatarith a vs)" |  | 
| 
 
73dd67adf90a
replaced Ifloat => real_of_float and real, renamed ApproxEq => inequality, uneq => interpret_inequality, uneq' => approx_inequality, Ifloatarith => interpret_floatarith
 
hoelzl 
parents: 
30971 
diff
changeset
 | 
51  | 
"interpret_floatarith (Power a n) vs = (interpret_floatarith a vs)^n" |  | 
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
52  | 
"interpret_floatarith (Floor a) vs = floor (interpret_floatarith a vs)" |  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
53  | 
"interpret_floatarith (Num f) vs = f" |  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
54  | 
"interpret_floatarith (Var n) vs = vs ! n"  | 
| 29805 | 55  | 
|
| 60680 | 56  | 
lemma interpret_floatarith_divide:  | 
57  | 
"interpret_floatarith (Mult a (Inverse b)) vs =  | 
|
58  | 
(interpret_floatarith a vs) / (interpret_floatarith b vs)"  | 
|
| 
36778
 
739a9379e29b
avoid using real-specific versions of generic lemmas
 
huffman 
parents: 
36531 
diff
changeset
 | 
59  | 
unfolding divide_inverse interpret_floatarith.simps ..  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
60  | 
|
| 60680 | 61  | 
lemma interpret_floatarith_diff:  | 
62  | 
"interpret_floatarith (Add a (Minus b)) vs =  | 
|
63  | 
(interpret_floatarith a vs) - (interpret_floatarith b vs)"  | 
|
| 
54230
 
b1d955791529
more simplification rules on unary and binary minus
 
haftmann 
parents: 
53077 
diff
changeset
 | 
64  | 
unfolding interpret_floatarith.simps by simp  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
65  | 
|
| 60680 | 66  | 
lemma interpret_floatarith_sin:  | 
67  | 
"interpret_floatarith (Cos (Add (Mult Pi (Num (Float 1 (- 1)))) (Minus a))) vs =  | 
|
68  | 
sin (interpret_floatarith a vs)"  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
69  | 
unfolding sin_cos_eq interpret_floatarith.simps  | 
| 60680 | 70  | 
interpret_floatarith_divide interpret_floatarith_diff  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
71  | 
by auto  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
72  | 
|
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
73  | 
|
| 29805 | 74  | 
subsection "Implement approximation function"  | 
75  | 
||
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
76  | 
fun lift_bin :: "(float interval) option \<Rightarrow> (float interval) option \<Rightarrow> (float interval \<Rightarrow> float interval \<Rightarrow> (float interval) option) \<Rightarrow> (float interval) option" where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
77  | 
"lift_bin (Some ivl1) (Some ivl2) f = f ivl1 ivl2" |  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
78  | 
"lift_bin a b f = None"  | 
| 
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
79  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
80  | 
fun lift_bin' :: "(float interval) option \<Rightarrow> (float interval) option \<Rightarrow> (float interval \<Rightarrow> float interval \<Rightarrow> float interval) \<Rightarrow> (float interval) option" where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
81  | 
"lift_bin' (Some ivl1) (Some ivl2) f = Some (f ivl1 ivl2)" |  | 
| 29805 | 82  | 
"lift_bin' a b f = None"  | 
83  | 
||
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
84  | 
fun lift_un :: "float interval option \<Rightarrow> (float interval \<Rightarrow> float interval option) \<Rightarrow> float interval option" where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
85  | 
"lift_un (Some ivl) f = f ivl" |  | 
| 29805 | 86  | 
"lift_un b f = None"  | 
87  | 
||
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
88  | 
lemma lift_un_eq:\<comment> \<open>TODO\<close> "lift_un x f = Option.bind x f"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
89  | 
by (cases x) auto  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
90  | 
|
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
91  | 
fun lift_un' :: "(float interval) option \<Rightarrow> (float interval \<Rightarrow> (float interval)) \<Rightarrow> (float interval) option" where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
92  | 
"lift_un' (Some ivl1) f = Some (f ivl1)" |  | 
| 29805 | 93  | 
"lift_un' b f = None"  | 
94  | 
||
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
95  | 
definition bounded_by :: "real list \<Rightarrow> (float interval) option list \<Rightarrow> bool" where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
96  | 
"bounded_by xs vs \<longleftrightarrow> (\<forall> i < length vs. case vs ! i of None \<Rightarrow> True | Some ivl \<Rightarrow> xs ! i \<in>\<^sub>r ivl)"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
97  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
98  | 
lemma bounded_byE:  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
99  | 
assumes "bounded_by xs vs"  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
100  | 
shows "\<And> i. i < length vs \<Longrightarrow> case vs ! i of None \<Rightarrow> True  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
101  | 
| Some ivl \<Rightarrow> xs ! i \<in>\<^sub>r ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
102  | 
using assms  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
103  | 
by (auto simp: bounded_by_def)  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
104  | 
|
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
105  | 
lemma bounded_by_update:  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
106  | 
assumes "bounded_by xs vs"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
107  | 
and bnd: "xs ! i \<in>\<^sub>r ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
108  | 
shows "bounded_by xs (vs[i := Some ivl])"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
109  | 
using assms  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
110  | 
by (cases "i < length vs") (auto simp: bounded_by_def nth_list_update split: option.splits)  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
111  | 
|
| 60680 | 112  | 
lemma bounded_by_None: "bounded_by xs (replicate (length xs) None)"  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
113  | 
unfolding bounded_by_def by auto  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
114  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
115  | 
fun approx approx' :: "nat \<Rightarrow> floatarith \<Rightarrow> (float interval) option list \<Rightarrow> (float interval) option"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
116  | 
where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
117  | 
"approx' prec a bs = (case (approx prec a bs) of Some ivl \<Rightarrow> Some (round_interval prec ivl) | None \<Rightarrow> None)" |  | 
| 
73537
 
56db8559eadb
fixed problematic addition operation in the 'approximation' package (previous version used much too high precision sometimes)
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71037 
diff
changeset
 | 
118  | 
"approx prec (Add a b) bs = lift_bin' (approx' prec a bs) (approx' prec b bs) (plus_float_interval prec)" |  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
119  | 
"approx prec (Minus a) bs = lift_un' (approx' prec a bs) uminus" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
120  | 
"approx prec (Mult a b) bs = lift_bin' (approx' prec a bs) (approx' prec b bs) (mult_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
121  | 
"approx prec (Inverse a) bs = lift_un (approx' prec a bs) (inverse_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
122  | 
"approx prec (Cos a) bs = lift_un' (approx' prec a bs) (cos_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
123  | 
"approx prec Pi bs = Some (pi_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
124  | 
"approx prec (Min a b) bs = lift_bin' (approx' prec a bs) (approx' prec b bs) (min_interval)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
125  | 
"approx prec (Max a b) bs = lift_bin' (approx' prec a bs) (approx' prec b bs) (max_interval)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
126  | 
"approx prec (Abs a) bs = lift_un' (approx' prec a bs) (abs_interval)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
127  | 
"approx prec (Arctan a) bs = lift_un' (approx' prec a bs) (arctan_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
128  | 
"approx prec (Sqrt a) bs = lift_un' (approx' prec a bs) (sqrt_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
129  | 
"approx prec (Exp a) bs = lift_un' (approx' prec a bs) (exp_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
130  | 
"approx prec (Powr a b) bs = lift_bin (approx' prec a bs) (approx' prec b bs) (powr_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
131  | 
"approx prec (Ln a) bs = lift_un (approx' prec a bs) (ln_float_interval prec)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
132  | 
"approx prec (Power a n) bs = lift_un' (approx' prec a bs) (power_float_interval prec n)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
133  | 
"approx prec (Floor a) bs = lift_un' (approx' prec a bs) (floor_float_interval)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
134  | 
"approx prec (Num f) bs = Some (interval_of f)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
135  | 
"approx prec (Var i) bs = (if i < length bs then bs ! i else None)"  | 
| 29805 | 136  | 
|
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
137  | 
lemma approx_approx':  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
138  | 
assumes Pa: "\<And>ivl. approx prec a vs = Some ivl \<Longrightarrow> interpret_floatarith a xs \<in>\<^sub>r ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
139  | 
and approx': "approx' prec a vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
140  | 
shows "interpret_floatarith a xs \<in>\<^sub>r ivl"  | 
| 29805 | 141  | 
proof -  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
142  | 
obtain ivl' where S: "approx prec a vs = Some ivl'" and ivl_def: "ivl = round_interval prec ivl'"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
143  | 
using approx' unfolding approx'.simps by (cases "approx prec a vs") auto  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
144  | 
show ?thesis  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
145  | 
by (auto simp: ivl_def intro!: in_round_intervalI Pa[OF S])  | 
| 29805 | 146  | 
qed  | 
147  | 
||
148  | 
lemma approx:  | 
|
149  | 
assumes "bounded_by xs vs"  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
150  | 
and "approx prec arith vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
151  | 
shows "interpret_floatarith arith xs \<in>\<^sub>r ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
152  | 
using \<open>approx prec arith vs = Some ivl\<close>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
153  | 
using \<open>bounded_by xs vs\<close>[THEN bounded_byE]  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
154  | 
by (induct arith arbitrary: ivl)  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
155  | 
(force split: option.splits if_splits  | 
| 
73537
 
56db8559eadb
fixed problematic addition operation in the 'approximation' package (previous version used much too high precision sometimes)
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
71037 
diff
changeset
 | 
156  | 
intro!: plus_float_intervalI mult_float_intervalI uminus_in_float_intervalI  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
157  | 
inverse_float_interval_eqI abs_in_float_intervalI  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
158  | 
min_intervalI max_intervalI  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
159  | 
cos_float_intervalI  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
160  | 
arctan_float_intervalI pi_float_interval sqrt_float_intervalI exp_float_intervalI  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
161  | 
powr_float_interval_eqI ln_float_interval_eqI power_float_intervalI floor_float_intervalI  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
162  | 
intro: in_round_intervalI)+  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
163  | 
|
| 58310 | 164  | 
datatype form = Bound floatarith floatarith floatarith form  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
165  | 
| Assign floatarith floatarith form  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
166  | 
| Less floatarith floatarith  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
167  | 
| LessEqual floatarith floatarith  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
168  | 
| AtLeastAtMost floatarith floatarith floatarith  | 
| 58986 | 169  | 
| Conj form form  | 
170  | 
| Disj form form  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
171  | 
|
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
172  | 
fun interpret_form :: "form \<Rightarrow> real list \<Rightarrow> bool" where  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
173  | 
"interpret_form (Bound x a b f) vs = (interpret_floatarith x vs \<in> { interpret_floatarith a vs .. interpret_floatarith b vs } \<longrightarrow> interpret_form f vs)" |
 | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
174  | 
"interpret_form (Assign x a f) vs = (interpret_floatarith x vs = interpret_floatarith a vs \<longrightarrow> interpret_form f vs)" |  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
175  | 
"interpret_form (Less a b) vs = (interpret_floatarith a vs < interpret_floatarith b vs)" |  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
176  | 
"interpret_form (LessEqual a b) vs = (interpret_floatarith a vs \<le> interpret_floatarith b vs)" |  | 
| 58986 | 177  | 
"interpret_form (AtLeastAtMost x a b) vs = (interpret_floatarith x vs \<in> { interpret_floatarith a vs .. interpret_floatarith b vs })" |
 | 
178  | 
"interpret_form (Conj f g) vs \<longleftrightarrow> interpret_form f vs \<and> interpret_form g vs" |  | 
|
179  | 
"interpret_form (Disj f g) vs \<longleftrightarrow> interpret_form f vs \<or> interpret_form g vs"  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
180  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
181  | 
fun approx_form' and approx_form :: "nat \<Rightarrow> form \<Rightarrow> (float interval) option list \<Rightarrow> nat list \<Rightarrow> bool" where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
182  | 
"approx_form' prec f 0 n ivl bs ss = approx_form prec f (bs[n := Some ivl]) ss" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
183  | 
"approx_form' prec f (Suc s) n ivl bs ss =  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
184  | 
(let (ivl1, ivl2) = split_float_interval ivl  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
185  | 
in (if approx_form' prec f s n ivl1 bs ss then approx_form' prec f s n ivl2 bs ss else False))" |  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
186  | 
"approx_form prec (Bound (Var n) a b f) bs ss =  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
187  | 
(case (approx prec a bs, approx prec b bs)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
188  | 
of (Some ivl1, Some ivl2) \<Rightarrow> approx_form' prec f (ss ! n) n (sup ivl1 ivl2) bs ss  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
189  | 
| _ \<Rightarrow> False)" |  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
190  | 
"approx_form prec (Assign (Var n) a f) bs ss =  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
191  | 
(case (approx prec a bs)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
192  | 
of (Some ivl) \<Rightarrow> approx_form' prec f (ss ! n) n ivl bs ss  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
193  | 
| _ \<Rightarrow> False)" |  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
194  | 
"approx_form prec (Less a b) bs ss =  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
195  | 
(case (approx prec a bs, approx prec b bs)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
196  | 
of (Some ivl, Some ivl') \<Rightarrow> float_plus_up prec (upper ivl) (-lower ivl') < 0  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
197  | 
| _ \<Rightarrow> False)" |  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
198  | 
"approx_form prec (LessEqual a b) bs ss =  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
199  | 
(case (approx prec a bs, approx prec b bs)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
200  | 
of (Some ivl, Some ivl') \<Rightarrow> float_plus_up prec (upper ivl) (-lower ivl') \<le> 0  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
201  | 
| _ \<Rightarrow> False)" |  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
202  | 
"approx_form prec (AtLeastAtMost x a b) bs ss =  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
203  | 
(case (approx prec x bs, approx prec a bs, approx prec b bs)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
204  | 
of (Some ivlx, Some ivl, Some ivl') \<Rightarrow>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
205  | 
float_plus_up prec (upper ivl) (-lower ivlx) \<le> 0 \<and>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
206  | 
float_plus_up prec (upper ivlx) (-lower ivl') \<le> 0  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
207  | 
| _ \<Rightarrow> False)" |  | 
| 58986 | 208  | 
"approx_form prec (Conj a b) bs ss \<longleftrightarrow> approx_form prec a bs ss \<and> approx_form prec b bs ss" |  | 
209  | 
"approx_form prec (Disj a b) bs ss \<longleftrightarrow> approx_form prec a bs ss \<or> approx_form prec b bs ss" |  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
210  | 
"approx_form _ _ _ _ = False"  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
211  | 
|
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
212  | 
lemma lazy_conj: "(if A then B else False) = (A \<and> B)" by simp  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
213  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
214  | 
lemma approx_form_approx_form':  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
215  | 
assumes "approx_form' prec f s n ivl bs ss"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
216  | 
and "(x::real) \<in>\<^sub>r ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
217  | 
obtains ivl' where "x \<in>\<^sub>r ivl'"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
218  | 
and "approx_form prec f (bs[n := Some ivl']) ss"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
219  | 
using assms proof (induct s arbitrary: ivl)  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
220  | 
case 0  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
221  | 
from this(1)[of ivl] this(2,3)  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
222  | 
show thesis by auto  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
223  | 
next  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
224  | 
case (Suc s)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
225  | 
then obtain ivl1 ivl2 where ivl_split: "split_float_interval ivl = (ivl1, ivl2)"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
226  | 
by (fastforce dest: split_float_intervalD)  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
227  | 
from split_float_interval_realD[OF this \<open>x \<in>\<^sub>r ivl\<close>]  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
228  | 
consider "x \<in>\<^sub>r ivl1" | "x \<in>\<^sub>r ivl2"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
229  | 
by atomize_elim  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
230  | 
then show thesis  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
231  | 
proof cases  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
232  | 
case *: 1  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
233  | 
from Suc.hyps[OF _ _ *] Suc.prems  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
234  | 
show ?thesis  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
235  | 
by (simp add: lazy_conj ivl_split split: prod.splits)  | 
| 29805 | 236  | 
next  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
237  | 
case *: 2  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
238  | 
from Suc.hyps[OF _ _ *] Suc.prems  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
239  | 
show ?thesis  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
240  | 
by (simp add: lazy_conj ivl_split split: prod.splits)  | 
| 29805 | 241  | 
qed  | 
242  | 
qed  | 
|
243  | 
||
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
244  | 
lemma approx_form_aux:  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
245  | 
assumes "approx_form prec f vs ss"  | 
| 49351 | 246  | 
and "bounded_by xs vs"  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
247  | 
shows "interpret_form f xs"  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
248  | 
using assms proof (induct f arbitrary: vs)  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
249  | 
case (Bound x a b f)  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
250  | 
then obtain n  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
251  | 
where x_eq: "x = Var n" by (cases x) auto  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
252  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
253  | 
with Bound.prems obtain ivl1 ivl2  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
254  | 
where l_eq: "approx prec a vs = Some ivl1"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
255  | 
and u_eq: "approx prec b vs = Some ivl2"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
256  | 
and approx_form': "approx_form' prec f (ss ! n) n (sup ivl1 ivl2) vs ss"  | 
| 
37411
 
c88c44156083
removed simplifier congruence rule of "prod_case"
 
haftmann 
parents: 
37391 
diff
changeset
 | 
257  | 
by (cases "approx prec a vs", simp) (cases "approx prec b vs", auto)  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
258  | 
|
| 60680 | 259  | 
have "interpret_form f xs"  | 
260  | 
    if "xs ! n \<in> { interpret_floatarith a xs .. interpret_floatarith b xs }"
 | 
|
261  | 
proof -  | 
|
262  | 
from approx[OF Bound.prems(2) l_eq] and approx[OF Bound.prems(2) u_eq] that  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
263  | 
have "xs ! n \<in>\<^sub>r (sup ivl1 ivl2)"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
264  | 
by (auto simp: set_of_eq sup_float_def max_def inf_float_def min_def)  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
265  | 
|
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
266  | 
from approx_form_approx_form'[OF approx_form' this]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
267  | 
obtain ivlx where bnds: "xs ! n \<in>\<^sub>r ivlx"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
268  | 
and approx_form: "approx_form prec f (vs[n := Some ivlx]) ss" .  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
269  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
270  | 
from \<open>bounded_by xs vs\<close> bnds have "bounded_by xs (vs[n := Some ivlx])"  | 
| 60680 | 271  | 
by (rule bounded_by_update)  | 
272  | 
with Bound.hyps[OF approx_form] show ?thesis  | 
|
273  | 
by blast  | 
|
274  | 
qed  | 
|
275  | 
thus ?case  | 
|
276  | 
using interpret_form.simps x_eq and interpret_floatarith.simps by simp  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
277  | 
next  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
278  | 
case (Assign x a f)  | 
| 60680 | 279  | 
then obtain n where x_eq: "x = Var n"  | 
280  | 
by (cases x) auto  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
281  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
282  | 
with Assign.prems obtain ivl  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
283  | 
where bnd_eq: "approx prec a vs = Some ivl"  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
284  | 
and x_eq: "x = Var n"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
285  | 
and approx_form': "approx_form' prec f (ss ! n) n ivl vs ss"  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
286  | 
by (cases "approx prec a vs") auto  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
287  | 
|
| 60680 | 288  | 
have "interpret_form f xs"  | 
289  | 
if bnds: "xs ! n = interpret_floatarith a xs"  | 
|
290  | 
proof -  | 
|
291  | 
from approx[OF Assign.prems(2) bnd_eq] bnds  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
292  | 
have "xs ! n \<in>\<^sub>r ivl" by auto  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
293  | 
from approx_form_approx_form'[OF approx_form' this]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
294  | 
obtain ivlx where bnds: "xs ! n \<in>\<^sub>r ivlx"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
295  | 
and approx_form: "approx_form prec f (vs[n := Some ivlx]) ss" .  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
296  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
297  | 
from \<open>bounded_by xs vs\<close> bnds have "bounded_by xs (vs[n := Some ivlx])"  | 
| 60680 | 298  | 
by (rule bounded_by_update)  | 
299  | 
with Assign.hyps[OF approx_form] show ?thesis  | 
|
300  | 
by blast  | 
|
301  | 
qed  | 
|
302  | 
thus ?case  | 
|
303  | 
using interpret_form.simps x_eq and interpret_floatarith.simps by simp  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
304  | 
next  | 
| 29805 | 305  | 
case (Less a b)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
306  | 
then obtain ivl ivl'  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
307  | 
where l_eq: "approx prec a vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
308  | 
and u_eq: "approx prec b vs = Some ivl'"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
309  | 
and inequality: "real_of_float (float_plus_up prec (upper ivl) (-lower ivl')) < 0"  | 
| 60680 | 310  | 
by (cases "approx prec a vs", auto, cases "approx prec b vs", auto)  | 
| 
58985
 
bf498e0af9e3
truncate intermediate results in horner to improve performance of approximate;
 
immler 
parents: 
58982 
diff
changeset
 | 
311  | 
from le_less_trans[OF float_plus_up inequality]  | 
| 
 
bf498e0af9e3
truncate intermediate results in horner to improve performance of approximate;
 
immler 
parents: 
58982 
diff
changeset
 | 
312  | 
approx[OF Less.prems(2) l_eq] approx[OF Less.prems(2) u_eq]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
313  | 
show ?case by (auto simp: set_of_eq)  | 
| 29805 | 314  | 
next  | 
315  | 
case (LessEqual a b)  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
316  | 
then obtain ivl ivl'  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
317  | 
where l_eq: "approx prec a vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
318  | 
and u_eq: "approx prec b vs = Some ivl'"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
319  | 
and inequality: "real_of_float (float_plus_up prec (upper ivl) (-lower ivl')) \<le> 0"  | 
| 60680 | 320  | 
by (cases "approx prec a vs", auto, cases "approx prec b vs", auto)  | 
| 
58985
 
bf498e0af9e3
truncate intermediate results in horner to improve performance of approximate;
 
immler 
parents: 
58982 
diff
changeset
 | 
321  | 
from order_trans[OF float_plus_up inequality]  | 
| 
 
bf498e0af9e3
truncate intermediate results in horner to improve performance of approximate;
 
immler 
parents: 
58982 
diff
changeset
 | 
322  | 
approx[OF LessEqual.prems(2) l_eq] approx[OF LessEqual.prems(2) u_eq]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
323  | 
show ?case by (auto simp: set_of_eq)  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
324  | 
next  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
325  | 
case (AtLeastAtMost x a b)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
326  | 
then obtain ivlx ivl ivl'  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
327  | 
where x_eq: "approx prec x vs = Some ivlx"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
328  | 
and l_eq: "approx prec a vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
329  | 
and u_eq: "approx prec b vs = Some ivl'"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
330  | 
and inequality: "real_of_float (float_plus_up prec (upper ivl) (-lower ivlx)) \<le> 0"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
331  | 
"real_of_float (float_plus_up prec (upper ivlx) (-lower ivl')) \<le> 0"  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
332  | 
by (cases "approx prec x vs", auto,  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
333  | 
cases "approx prec a vs", auto,  | 
| 
56073
 
29e308b56d23
enhanced simplifier solver for preconditions of rewrite rule, can now deal with conjunctions
 
nipkow 
parents: 
55506 
diff
changeset
 | 
334  | 
cases "approx prec b vs", auto)  | 
| 
58985
 
bf498e0af9e3
truncate intermediate results in horner to improve performance of approximate;
 
immler 
parents: 
58982 
diff
changeset
 | 
335  | 
from order_trans[OF float_plus_up inequality(1)] order_trans[OF float_plus_up inequality(2)]  | 
| 
 
bf498e0af9e3
truncate intermediate results in horner to improve performance of approximate;
 
immler 
parents: 
58982 
diff
changeset
 | 
336  | 
approx[OF AtLeastAtMost.prems(2) l_eq] approx[OF AtLeastAtMost.prems(2) u_eq] approx[OF AtLeastAtMost.prems(2) x_eq]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
337  | 
show ?case by (auto simp: set_of_eq)  | 
| 58986 | 338  | 
qed auto  | 
| 29805 | 339  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
340  | 
lemma approx_form:  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
341  | 
assumes "n = length xs"  | 
| 60680 | 342  | 
and "approx_form prec f (replicate n None) ss"  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
343  | 
shows "interpret_form f xs"  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
344  | 
using approx_form_aux[OF _ bounded_by_None] assms by auto  | 
| 29805 | 345  | 
|
| 60680 | 346  | 
|
| 60533 | 347  | 
subsection \<open>Implementing Taylor series expansion\<close>  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
348  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
349  | 
fun isDERIV :: "nat \<Rightarrow> floatarith \<Rightarrow> real list \<Rightarrow> bool" where  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
350  | 
"isDERIV x (Add a b) vs = (isDERIV x a vs \<and> isDERIV x b vs)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
351  | 
"isDERIV x (Mult a b) vs = (isDERIV x a vs \<and> isDERIV x b vs)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
352  | 
"isDERIV x (Minus a) vs = isDERIV x a vs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
353  | 
"isDERIV x (Inverse a) vs = (isDERIV x a vs \<and> interpret_floatarith a vs \<noteq> 0)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
354  | 
"isDERIV x (Cos a) vs = isDERIV x a vs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
355  | 
"isDERIV x (Arctan a) vs = isDERIV x a vs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
356  | 
"isDERIV x (Min a b) vs = False" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
357  | 
"isDERIV x (Max a b) vs = False" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
358  | 
"isDERIV x (Abs a) vs = False" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
359  | 
"isDERIV x Pi vs = True" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
360  | 
"isDERIV x (Sqrt a) vs = (isDERIV x a vs \<and> interpret_floatarith a vs > 0)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
361  | 
"isDERIV x (Exp a) vs = isDERIV x a vs" |  | 
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
362  | 
"isDERIV x (Powr a b) vs =  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
363  | 
(isDERIV x a vs \<and> isDERIV x b vs \<and> interpret_floatarith a vs > 0)" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
364  | 
"isDERIV x (Ln a) vs = (isDERIV x a vs \<and> interpret_floatarith a vs > 0)" |  | 
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
365  | 
"isDERIV x (Floor a) vs = (isDERIV x a vs \<and> interpret_floatarith a vs \<notin> \<int>)" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
366  | 
"isDERIV x (Power a 0) vs = True" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
367  | 
"isDERIV x (Power a (Suc n)) vs = isDERIV x a vs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
368  | 
"isDERIV x (Num f) vs = True" |  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
369  | 
"isDERIV x (Var n) vs = True"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
370  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
371  | 
fun DERIV_floatarith :: "nat \<Rightarrow> floatarith \<Rightarrow> floatarith" where  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
372  | 
"DERIV_floatarith x (Add a b) = Add (DERIV_floatarith x a) (DERIV_floatarith x b)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
373  | 
"DERIV_floatarith x (Mult a b) = Add (Mult a (DERIV_floatarith x b)) (Mult (DERIV_floatarith x a) b)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
374  | 
"DERIV_floatarith x (Minus a) = Minus (DERIV_floatarith x a)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
375  | 
"DERIV_floatarith x (Inverse a) = Minus (Mult (DERIV_floatarith x a) (Inverse (Power a 2)))" |  | 
| 
58410
 
6d46ad54a2ab
explicit separation of signed and unsigned numerals using existing lexical categories num and xnum
 
haftmann 
parents: 
58310 
diff
changeset
 | 
376  | 
"DERIV_floatarith x (Cos a) = Minus (Mult (Cos (Add (Mult Pi (Num (Float 1 (- 1)))) (Minus a))) (DERIV_floatarith x a))" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
377  | 
"DERIV_floatarith x (Arctan a) = Mult (Inverse (Add (Num 1) (Power a 2))) (DERIV_floatarith x a)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
378  | 
"DERIV_floatarith x (Min a b) = Num 0" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
379  | 
"DERIV_floatarith x (Max a b) = Num 0" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
380  | 
"DERIV_floatarith x (Abs a) = Num 0" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
381  | 
"DERIV_floatarith x Pi = Num 0" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
382  | 
"DERIV_floatarith x (Sqrt a) = (Mult (Inverse (Mult (Sqrt a) (Num 2))) (DERIV_floatarith x a))" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
383  | 
"DERIV_floatarith x (Exp a) = Mult (Exp a) (DERIV_floatarith x a)" |  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
384  | 
"DERIV_floatarith x (Powr a b) =  | 
| 
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
385  | 
Mult (Powr a b) (Add (Mult (DERIV_floatarith x b) (Ln a)) (Mult (Mult (DERIV_floatarith x a) b) (Inverse a)))" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
386  | 
"DERIV_floatarith x (Ln a) = Mult (Inverse a) (DERIV_floatarith x a)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
387  | 
"DERIV_floatarith x (Power a 0) = Num 0" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
388  | 
"DERIV_floatarith x (Power a (Suc n)) = Mult (Num (Float (int (Suc n)) 0)) (Mult (Power a n) (DERIV_floatarith x a))" |  | 
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
389  | 
"DERIV_floatarith x (Floor a) = Num 0" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
390  | 
"DERIV_floatarith x (Num f) = Num 0" |  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
391  | 
"DERIV_floatarith x (Var n) = (if x = n then Num 1 else Num 0)"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
392  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
393  | 
lemma DERIV_floatarith:  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
394  | 
assumes "n < length vs"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
395  | 
assumes isDERIV: "isDERIV n f (vs[n := x])"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
396  | 
shows "DERIV (\<lambda> x'. interpret_floatarith f (vs[n := x'])) x :>  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
397  | 
interpret_floatarith (DERIV_floatarith n f) (vs[n := x])"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
398  | 
(is "DERIV (?i f) x :> _")  | 
| 49351 | 399  | 
using isDERIV  | 
400  | 
proof (induct f arbitrary: x)  | 
|
401  | 
case (Inverse a)  | 
|
402  | 
thus ?case  | 
|
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56195 
diff
changeset
 | 
403  | 
by (auto intro!: derivative_eq_intros simp add: algebra_simps power2_eq_square)  | 
| 49351 | 404  | 
next  | 
405  | 
case (Cos a)  | 
|
406  | 
thus ?case  | 
|
| 56382 | 407  | 
by (auto intro!: derivative_eq_intros  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
408  | 
simp del: interpret_floatarith.simps(5)  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
409  | 
simp add: interpret_floatarith_sin interpret_floatarith.simps(5)[of a])  | 
| 49351 | 410  | 
next  | 
411  | 
case (Power a n)  | 
|
412  | 
thus ?case  | 
|
| 
61609
 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 
paulson <lp15@cam.ac.uk> 
parents: 
60680 
diff
changeset
 | 
413  | 
by (cases n) (auto intro!: derivative_eq_intros simp del: power_Suc)  | 
| 49351 | 414  | 
next  | 
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
415  | 
case (Floor a)  | 
| 
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
416  | 
thus ?case  | 
| 
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
417  | 
by (auto intro!: derivative_eq_intros DERIV_isCont floor_has_real_derivative)  | 
| 
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
418  | 
next  | 
| 49351 | 419  | 
case (Ln a)  | 
| 56382 | 420  | 
thus ?case by (auto intro!: derivative_eq_intros simp add: divide_inverse)  | 
| 49351 | 421  | 
next  | 
422  | 
case (Var i)  | 
|
| 60533 | 423  | 
thus ?case using \<open>n < length vs\<close> by auto  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
424  | 
next  | 
| 
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
425  | 
case (Powr a b)  | 
| 
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
426  | 
note [derivative_intros] = has_real_derivative_powr'  | 
| 
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
427  | 
from Powr show ?case  | 
| 
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
428  | 
by (auto intro!: derivative_eq_intros simp: field_simps)  | 
| 
56381
 
0556204bc230
merged DERIV_intros, has_derivative_intros into derivative_intros
 
hoelzl 
parents: 
56195 
diff
changeset
 | 
429  | 
qed (auto intro!: derivative_eq_intros)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
430  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
431  | 
declare approx.simps[simp del]  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
432  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
433  | 
fun isDERIV_approx :: "nat \<Rightarrow> nat \<Rightarrow> floatarith \<Rightarrow> (float interval) option list \<Rightarrow> bool" where  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
434  | 
"isDERIV_approx prec x (Add a b) vs = (isDERIV_approx prec x a vs \<and> isDERIV_approx prec x b vs)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
435  | 
"isDERIV_approx prec x (Mult a b) vs = (isDERIV_approx prec x a vs \<and> isDERIV_approx prec x b vs)" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
436  | 
"isDERIV_approx prec x (Minus a) vs = isDERIV_approx prec x a vs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
437  | 
"isDERIV_approx prec x (Inverse a) vs =  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
438  | 
(isDERIV_approx prec x a vs \<and> (case approx prec a vs of Some ivl \<Rightarrow> 0 < lower ivl \<or> upper ivl < 0 | None \<Rightarrow> False))" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
439  | 
"isDERIV_approx prec x (Cos a) vs = isDERIV_approx prec x a vs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
440  | 
"isDERIV_approx prec x (Arctan a) vs = isDERIV_approx prec x a vs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
441  | 
"isDERIV_approx prec x (Min a b) vs = False" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
442  | 
"isDERIV_approx prec x (Max a b) vs = False" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
443  | 
"isDERIV_approx prec x (Abs a) vs = False" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
444  | 
"isDERIV_approx prec x Pi vs = True" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
445  | 
"isDERIV_approx prec x (Sqrt a) vs =  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
446  | 
(isDERIV_approx prec x a vs \<and> (case approx prec a vs of Some ivl \<Rightarrow> 0 < lower ivl | None \<Rightarrow> False))" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
447  | 
"isDERIV_approx prec x (Exp a) vs = isDERIV_approx prec x a vs" |  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
448  | 
"isDERIV_approx prec x (Powr a b) vs =  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
449  | 
(isDERIV_approx prec x a vs \<and> isDERIV_approx prec x b vs \<and> (case approx prec a vs of Some ivl \<Rightarrow> 0 < lower ivl | None \<Rightarrow> False))" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
450  | 
"isDERIV_approx prec x (Ln a) vs =  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
451  | 
(isDERIV_approx prec x a vs \<and> (case approx prec a vs of Some ivl \<Rightarrow> 0 < lower ivl | None \<Rightarrow> False))" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
452  | 
"isDERIV_approx prec x (Power a 0) vs = True" |  | 
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
453  | 
"isDERIV_approx prec x (Floor a) vs =  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
454  | 
(isDERIV_approx prec x a vs \<and> (case approx prec a vs of Some ivl \<Rightarrow> lower ivl > floor (upper ivl) \<and> upper ivl < ceiling (lower ivl) | None \<Rightarrow> False))" |  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
455  | 
"isDERIV_approx prec x (Power a (Suc n)) vs = isDERIV_approx prec x a vs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
456  | 
"isDERIV_approx prec x (Num f) vs = True" |  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
457  | 
"isDERIV_approx prec x (Var n) vs = True"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
458  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
459  | 
lemma isDERIV_approx:  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
460  | 
assumes "bounded_by xs vs"  | 
| 49351 | 461  | 
and isDERIV_approx: "isDERIV_approx prec x f vs"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
462  | 
shows "isDERIV x f xs"  | 
| 49351 | 463  | 
using isDERIV_approx  | 
464  | 
proof (induct f)  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
465  | 
case (Inverse a)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
466  | 
then obtain ivl where approx_Some: "approx prec a vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
467  | 
and *: "0 < lower ivl \<or> upper ivl < 0"  | 
| 49351 | 468  | 
by (cases "approx prec a vs") auto  | 
| 60533 | 469  | 
with approx[OF \<open>bounded_by xs vs\<close> approx_Some]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
470  | 
have "interpret_floatarith a xs \<noteq> 0" by (auto simp: set_of_eq)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
471  | 
thus ?case using Inverse by auto  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
472  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
473  | 
case (Ln a)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
474  | 
then obtain ivl where approx_Some: "approx prec a vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
475  | 
and *: "0 < lower ivl"  | 
| 49351 | 476  | 
by (cases "approx prec a vs") auto  | 
| 60533 | 477  | 
with approx[OF \<open>bounded_by xs vs\<close> approx_Some]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
478  | 
have "0 < interpret_floatarith a xs" by (auto simp: set_of_eq)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
479  | 
thus ?case using Ln by auto  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
480  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
481  | 
case (Sqrt a)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
482  | 
then obtain ivl where approx_Some: "approx prec a vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
483  | 
and *: "0 < lower ivl"  | 
| 49351 | 484  | 
by (cases "approx prec a vs") auto  | 
| 60533 | 485  | 
with approx[OF \<open>bounded_by xs vs\<close> approx_Some]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
486  | 
have "0 < interpret_floatarith a xs" by (auto simp: set_of_eq)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
487  | 
thus ?case using Sqrt by auto  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
488  | 
next  | 
| 60680 | 489  | 
case (Power a n)  | 
490  | 
thus ?case by (cases n) auto  | 
|
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
491  | 
next  | 
| 
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
492  | 
case (Powr a b)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
493  | 
from Powr obtain ivl1 where a: "approx prec a vs = Some ivl1"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
494  | 
and pos: "0 < lower ivl1"  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
495  | 
by (cases "approx prec a vs") auto  | 
| 
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
496  | 
with approx[OF \<open>bounded_by xs vs\<close> a]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
497  | 
have "0 < interpret_floatarith a xs" by (auto simp: set_of_eq)  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
498  | 
with Powr show ?case by auto  | 
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
499  | 
next  | 
| 
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
500  | 
case (Floor a)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
501  | 
then obtain ivl where approx_Some: "approx prec a vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
502  | 
and "real_of_int \<lfloor>real_of_float (upper ivl)\<rfloor> < real_of_float (lower ivl)"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
503  | 
"real_of_float (upper ivl) < real_of_int \<lceil>real_of_float (lower ivl)\<rceil>"  | 
| 
63263
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
504  | 
and "isDERIV x a xs"  | 
| 
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
505  | 
by (cases "approx prec a vs") auto  | 
| 
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
506  | 
with approx[OF \<open>bounded_by xs vs\<close> approx_Some] le_floor_iff  | 
| 
 
c6c95d64607a
approximation, derivative, and continuity of floor and ceiling
 
immler 
parents: 
63248 
diff
changeset
 | 
507  | 
show ?case  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
508  | 
by (force elim!: Ints_cases simp: set_of_eq)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
509  | 
qed auto  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
510  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
511  | 
lemma bounded_by_update_var:  | 
| 60680 | 512  | 
assumes "bounded_by xs vs"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
513  | 
and "vs ! i = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
514  | 
and bnd: "x \<in>\<^sub>r ivl"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
515  | 
shows "bounded_by (xs[i := x]) vs"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
516  | 
using assms  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
517  | 
using nth_list_update  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
518  | 
by (cases "i < length xs")  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
519  | 
(force simp: bounded_by_def split: option.splits)+  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
520  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
521  | 
lemma isDERIV_approx':  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
522  | 
assumes "bounded_by xs vs"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
523  | 
and vs_x: "vs ! x = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
524  | 
and X_in: "X \<in>\<^sub>r ivl"  | 
| 49351 | 525  | 
and approx: "isDERIV_approx prec x f vs"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
526  | 
shows "isDERIV x f (xs[x := X])"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
527  | 
proof -  | 
| 60680 | 528  | 
from bounded_by_update_var[OF \<open>bounded_by xs vs\<close> vs_x X_in] approx  | 
529  | 
show ?thesis by (rule isDERIV_approx)  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
530  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
531  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
532  | 
lemma DERIV_approx:  | 
| 60680 | 533  | 
assumes "n < length xs"  | 
534  | 
and bnd: "bounded_by xs vs"  | 
|
| 49351 | 535  | 
and isD: "isDERIV_approx prec n f vs"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
536  | 
and app: "approx prec (DERIV_floatarith n f) vs = Some ivl" (is "approx _ ?D _ = _")  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
537  | 
shows "\<exists>(x::real). x \<in>\<^sub>r ivl \<and>  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
538  | 
DERIV (\<lambda> x. interpret_floatarith f (xs[n := x])) (xs!n) :> x"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
539  | 
(is "\<exists> x. _ \<and> DERIV (?i f) _ :> _")  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
540  | 
proof (rule exI[of _ "?i ?D (xs!n)"], rule conjI)  | 
| 60680 | 541  | 
let "?i f" = "\<lambda>x. interpret_floatarith f (xs[n := x])"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
542  | 
from approx[OF bnd app]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
543  | 
show "?i ?D (xs!n) \<in>\<^sub>r ivl"  | 
| 60533 | 544  | 
using \<open>n < length xs\<close> by auto  | 
545  | 
from DERIV_floatarith[OF \<open>n < length xs\<close>, of f "xs!n"] isDERIV_approx[OF bnd isD]  | 
|
| 60680 | 546  | 
show "DERIV (?i f) (xs!n) :> (?i ?D (xs!n))"  | 
547  | 
by simp  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
548  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
549  | 
|
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
550  | 
lemma lift_bin_aux:  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
551  | 
assumes lift_bin_Some: "lift_bin a b f = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
552  | 
obtains ivl1 ivl2  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
553  | 
where "a = Some ivl1"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
554  | 
and "b = Some ivl2"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
555  | 
and "f ivl1 ivl2 = Some ivl"  | 
| 49351 | 556  | 
using assms by (cases a, simp, cases b, simp, auto)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
557  | 
|
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
558  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
559  | 
fun approx_tse where  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
560  | 
"approx_tse prec n 0 c k f bs = approx prec f bs" |  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
561  | 
"approx_tse prec n (Suc s) c k f bs =  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
562  | 
(if isDERIV_approx prec n f bs then  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
563  | 
lift_bin (approx prec f (bs[n := Some (interval_of c)]))  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
564  | 
(approx_tse prec n s c (Suc k) (DERIV_floatarith n f) bs)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
565  | 
(\<lambda>ivl1 ivl2. approx prec  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
566  | 
(Add (Var 0)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
567  | 
(Mult (Inverse (Num (Float (int k) 0)))  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
568  | 
(Mult (Add (Var (Suc (Suc 0))) (Minus (Num c)))  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
569  | 
(Var (Suc 0))))) [Some ivl1, Some ivl2, bs!n])  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
570  | 
else approx prec f bs)"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
571  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
572  | 
lemma bounded_by_Cons:  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
573  | 
assumes bnd: "bounded_by xs vs"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
574  | 
and x: "x \<in>\<^sub>r ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
575  | 
shows "bounded_by (x#xs) ((Some ivl)#vs)"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
576  | 
proof -  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
577  | 
have "case ((Some ivl)#vs) ! i of Some ivl \<Rightarrow> (x#xs)!i \<in>\<^sub>r ivl | None \<Rightarrow> True"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
578  | 
if *: "i < length ((Some ivl)#vs)" for i  | 
| 60680 | 579  | 
proof (cases i)  | 
580  | 
case 0  | 
|
581  | 
with x show ?thesis by auto  | 
|
582  | 
next  | 
|
583  | 
case (Suc i)  | 
|
584  | 
with * have "i < length vs" by auto  | 
|
585  | 
from bnd[THEN bounded_byE, OF this]  | 
|
586  | 
show ?thesis unfolding Suc nth_Cons_Suc .  | 
|
587  | 
qed  | 
|
588  | 
thus ?thesis  | 
|
589  | 
by (auto simp add: bounded_by_def)  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
590  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
591  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
592  | 
lemma approx_tse_generic:  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
593  | 
assumes "bounded_by xs vs"  | 
| 60680 | 594  | 
and bnd_c: "bounded_by (xs[x := c]) vs"  | 
595  | 
and "x < length vs" and "x < length xs"  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
596  | 
and bnd_x: "vs ! x = Some ivlx"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
597  | 
and ate: "approx_tse prec x s c k f vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
598  | 
shows "\<exists> n. (\<forall> m < n. \<forall> (z::real) \<in> set_of (real_interval ivlx).  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
599  | 
DERIV (\<lambda> y. interpret_floatarith ((DERIV_floatarith x ^^ m) f) (xs[x := y])) z :>  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
600  | 
(interpret_floatarith ((DERIV_floatarith x ^^ (Suc m)) f) (xs[x := z])))  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
601  | 
   \<and> (\<forall> (t::real) \<in> set_of (real_interval ivlx).  (\<Sum> i = 0..<n. inverse (real (\<Prod> j \<in> {k..<k+i}. j)) *
 | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
602  | 
interpret_floatarith ((DERIV_floatarith x ^^ i) f) (xs[x := c]) *  | 
| 
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
603  | 
(xs!x - c)^i) +  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
604  | 
      inverse (real (\<Prod> j \<in> {k..<k+n}. j)) *
 | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
605  | 
interpret_floatarith ((DERIV_floatarith x ^^ n) f) (xs[x := t]) *  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
606  | 
(xs!x - c)^n \<in>\<^sub>r ivl)" (is "\<exists> n. ?taylor f k ivl n")  | 
| 60680 | 607  | 
using ate  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
608  | 
proof (induct s arbitrary: k f ivl)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
609  | 
case 0  | 
| 49351 | 610  | 
  {
 | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
611  | 
fix t::real assume "t \<in>\<^sub>r ivlx"  | 
| 60533 | 612  | 
note bounded_by_update_var[OF \<open>bounded_by xs vs\<close> bnd_x this]  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
613  | 
from approx[OF this 0[unfolded approx_tse.simps]]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
614  | 
have "(interpret_floatarith f (xs[x := t])) \<in>\<^sub>r ivl"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
615  | 
by (auto simp add: algebra_simps)  | 
| 49351 | 616  | 
}  | 
617  | 
thus ?case by (auto intro!: exI[of _ 0])  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
618  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
619  | 
case (Suc s)  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
620  | 
show ?case  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
621  | 
proof (cases "isDERIV_approx prec x f vs")  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
622  | 
case False  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
623  | 
note ap = Suc.prems[unfolded approx_tse.simps if_not_P[OF False]]  | 
| 49351 | 624  | 
    {
 | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
625  | 
fix t::real assume "t \<in>\<^sub>r ivlx"  | 
| 60533 | 626  | 
note bounded_by_update_var[OF \<open>bounded_by xs vs\<close> bnd_x this]  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
627  | 
from approx[OF this ap]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
628  | 
have "(interpret_floatarith f (xs[x := t])) \<in>\<^sub>r ivl"  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32920 
diff
changeset
 | 
629  | 
by (auto simp add: algebra_simps)  | 
| 49351 | 630  | 
}  | 
631  | 
thus ?thesis by (auto intro!: exI[of _ 0])  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
632  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
633  | 
case True  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
634  | 
with Suc.prems  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
635  | 
obtain ivl1 ivl2  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
636  | 
where a: "approx prec f (vs[x := Some (interval_of c)]) = Some ivl1"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
637  | 
and ate: "approx_tse prec x s c (Suc k) (DERIV_floatarith x f) vs = Some ivl2"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
638  | 
and final: "approx prec  | 
| 49351 | 639  | 
(Add (Var 0)  | 
640  | 
(Mult (Inverse (Num (Float (int k) 0)))  | 
|
641  | 
(Mult (Add (Var (Suc (Suc 0))) (Minus (Num c)))  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
642  | 
(Var (Suc 0))))) [Some ivl1, Some ivl2, vs!x] = Some ivl"  | 
| 
62200
 
67792e4a5486
Made Approximation work for powr again
 
Manuel Eberl <eberlm@in.tum.de> 
parents: 
61969 
diff
changeset
 | 
643  | 
by (auto elim!: lift_bin_aux)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
644  | 
|
| 60533 | 645  | 
from bnd_c \<open>x < length xs\<close>  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
646  | 
have bnd: "bounded_by (xs[x:=c]) (vs[x:= Some (interval_of c)])"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
647  | 
by (auto intro!: bounded_by_update)  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
648  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
649  | 
from approx[OF this a]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
650  | 
have f_c: "interpret_floatarith ((DERIV_floatarith x ^^ 0) f) (xs[x := c]) \<in>\<^sub>r ivl1"  | 
| 
61609
 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 
paulson <lp15@cam.ac.uk> 
parents: 
60680 
diff
changeset
 | 
651  | 
(is "?f 0 (real_of_float c) \<in> _")  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
652  | 
by auto  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
653  | 
|
| 60680 | 654  | 
have funpow_Suc[symmetric]: "(f ^^ Suc n) x = (f ^^ n) (f x)"  | 
655  | 
for f :: "'a \<Rightarrow> 'a" and n :: nat and x :: 'a  | 
|
656  | 
by (induct n) auto  | 
|
657  | 
from Suc.hyps[OF ate, unfolded this] obtain n  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
658  | 
where DERIV_hyp: "\<And>m z. \<lbrakk> m < n ; (z::real) \<in>\<^sub>r ivlx \<rbrakk> \<Longrightarrow>  | 
| 60680 | 659  | 
DERIV (?f (Suc m)) z :> ?f (Suc (Suc m)) z"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
660  | 
and hyp: "\<forall>t \<in> set_of (real_interval ivlx).  | 
| 60680 | 661  | 
        (\<Sum> i = 0..<n. inverse (real (\<Prod> j \<in> {Suc k..<Suc k + i}. j)) * ?f (Suc i) c * (xs!x - c)^i) +
 | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
662  | 
          inverse (real (\<Prod> j \<in> {Suc k..<Suc k + n}. j)) * ?f (Suc n) t * (xs!x - c)^n \<in>\<^sub>r ivl2"
 | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
663  | 
(is "\<forall> t \<in> _. ?X (Suc k) f n t \<in> _")  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
664  | 
by blast  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
665  | 
|
| 60680 | 666  | 
have DERIV: "DERIV (?f m) z :> ?f (Suc m) z"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
667  | 
if "m < Suc n" and bnd_z: "z \<in>\<^sub>r ivlx" for m and z::real  | 
| 60680 | 668  | 
proof (cases m)  | 
669  | 
case 0  | 
|
670  | 
with DERIV_floatarith[OF \<open>x < length xs\<close>  | 
|
671  | 
isDERIV_approx'[OF \<open>bounded_by xs vs\<close> bnd_x bnd_z True]]  | 
|
672  | 
show ?thesis by simp  | 
|
673  | 
next  | 
|
674  | 
case (Suc m')  | 
|
675  | 
hence "m' < n"  | 
|
676  | 
using \<open>m < Suc n\<close> by auto  | 
|
677  | 
from DERIV_hyp[OF this bnd_z] show ?thesis  | 
|
678  | 
using Suc by simp  | 
|
679  | 
qed  | 
|
680  | 
||
681  | 
    have "\<And>k i. k < i \<Longrightarrow> {k ..< i} = insert k {Suc k ..< i}" by auto
 | 
|
| 64272 | 682  | 
    hence prod_head_Suc: "\<And>k i. \<Prod>{k ..< k + Suc i} = k * \<Prod>{Suc k ..< Suc k + i}"
 | 
| 60680 | 683  | 
by auto  | 
| 64267 | 684  | 
    have sum_move0: "\<And>k F. sum F {0..<Suc k} = F 0 + sum (\<lambda> k. F (Suc k)) {0..<k}"
 | 
| 
70113
 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 
paulson <lp15@cam.ac.uk> 
parents: 
70097 
diff
changeset
 | 
685  | 
unfolding sum.shift_bounds_Suc_ivl[symmetric]  | 
| 
70097
 
4005298550a6
The last big tranche of Homology material: invariance of domain; renamings to use generic sum/prod lemmas from their locale
 
paulson <lp15@cam.ac.uk> 
parents: 
69835 
diff
changeset
 | 
686  | 
unfolding sum.atLeast_Suc_lessThan[OF zero_less_Suc] ..  | 
| 63040 | 687  | 
define C where "C = xs!x - c"  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
688  | 
|
| 49351 | 689  | 
    {
 | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
690  | 
fix t::real assume t: "t \<in>\<^sub>r ivlx"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
691  | 
hence "bounded_by [xs!x] [vs!x]"  | 
| 60533 | 692  | 
using \<open>bounded_by xs vs\<close>[THEN bounded_byE, OF \<open>x < length vs\<close>]  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32920 
diff
changeset
 | 
693  | 
by (cases "vs!x", auto simp add: bounded_by_def)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
694  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
695  | 
with hyp[THEN bspec, OF t] f_c  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
696  | 
have "bounded_by [?f 0 c, ?X (Suc k) f n t, xs!x] [Some ivl1, Some ivl2, vs!x]"  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32920 
diff
changeset
 | 
697  | 
by (auto intro!: bounded_by_Cons)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
698  | 
from approx[OF this final, unfolded atLeastAtMost_iff[symmetric]]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
699  | 
have "?X (Suc k) f n t * (xs!x - real_of_float c) * inverse k + ?f 0 c \<in>\<^sub>r ivl"  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32920 
diff
changeset
 | 
700  | 
by (auto simp add: algebra_simps)  | 
| 
61609
 
77b453bd616f
Coercion "real" now has type nat => real only and is no longer overloaded. Type class "real_of" is gone. Many duplicate theorems removed.
 
paulson <lp15@cam.ac.uk> 
parents: 
60680 
diff
changeset
 | 
701  | 
also have "?X (Suc k) f n t * (xs!x - real_of_float c) * inverse (real k) + ?f 0 c =  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
702  | 
               (\<Sum> i = 0..<Suc n. inverse (real (\<Prod> j \<in> {k..<k+i}. j)) * ?f i c * (xs!x - c)^i) +
 | 
| 
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
703  | 
               inverse (real (\<Prod> j \<in> {k..<k+Suc n}. j)) * ?f (Suc n) t * (xs!x - c)^Suc n" (is "_ = ?T")
 | 
| 64272 | 704  | 
unfolding funpow_Suc C_def[symmetric] sum_move0 prod_head_Suc  | 
| 35082 | 705  | 
by (auto simp add: algebra_simps)  | 
| 64267 | 706  | 
(simp only: mult.left_commute [of _ "inverse (real k)"] sum_distrib_left [symmetric])  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
707  | 
finally have "?T \<in>\<^sub>r ivl" .  | 
| 49351 | 708  | 
}  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
709  | 
thus ?thesis using DERIV by blast  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
710  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
711  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
712  | 
|
| 64272 | 713  | 
lemma prod_fact: "real (\<Prod> {1..<1 + k}) = fact (k :: nat)"
 | 
714  | 
by (simp add: fact_prod atLeastLessThanSuc_atLeastAtMost)  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
715  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
716  | 
lemma approx_tse:  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
717  | 
assumes "bounded_by xs vs"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
718  | 
and bnd_x: "vs ! x = Some ivlx"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
719  | 
and bnd_c: "real_of_float c \<in>\<^sub>r ivlx"  | 
| 49351 | 720  | 
and "x < length vs" and "x < length xs"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
721  | 
and ate: "approx_tse prec x s c 1 f vs = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
722  | 
shows "interpret_floatarith f xs \<in>\<^sub>r ivl"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
723  | 
proof -  | 
| 63040 | 724  | 
define F where [abs_def]: "F n z =  | 
725  | 
interpret_floatarith ((DERIV_floatarith x ^^ n) f) (xs[x := z])" for n z  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
726  | 
hence F0: "F 0 = (\<lambda> z. interpret_floatarith f (xs[x := z]))" by auto  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
727  | 
|
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
728  | 
hence "bounded_by (xs[x := c]) vs" and "x < length vs" "x < length xs"  | 
| 60533 | 729  | 
using \<open>bounded_by xs vs\<close> bnd_x bnd_c \<open>x < length vs\<close> \<open>x < length xs\<close>  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
730  | 
by (auto intro!: bounded_by_update_var)  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
731  | 
|
| 60533 | 732  | 
from approx_tse_generic[OF \<open>bounded_by xs vs\<close> this bnd_x ate]  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
733  | 
obtain n  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
734  | 
where DERIV: "\<forall> m z. m < n \<and> real_of_float (lower ivlx) \<le> z \<and> z \<le> real_of_float (upper ivlx) \<longrightarrow> DERIV (F m) z :> F (Suc m) z"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
735  | 
and hyp: "\<And> (t::real). t \<in>\<^sub>r ivlx \<Longrightarrow>  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
736  | 
(\<Sum> j = 0..<n. inverse(fact j) * F j c * (xs!x - c)^j) +  | 
| 
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
737  | 
inverse ((fact n)) * F n t * (xs!x - c)^n  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
738  | 
\<in>\<^sub>r ivl" (is "\<And> t. _ \<Longrightarrow> ?taylor t \<in> _")  | 
| 64272 | 739  | 
unfolding F_def atLeastAtMost_iff[symmetric] prod_fact  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
740  | 
by (auto simp: set_of_eq Ball_def)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
741  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
742  | 
have bnd_xs: "xs ! x \<in>\<^sub>r ivlx"  | 
| 60533 | 743  | 
using \<open>bounded_by xs vs\<close>[THEN bounded_byE, OF \<open>x < length vs\<close>] bnd_x by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
744  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
745  | 
show ?thesis  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
746  | 
proof (cases n)  | 
| 60680 | 747  | 
case 0  | 
748  | 
thus ?thesis  | 
|
749  | 
using hyp[OF bnd_xs] unfolding F_def by auto  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
750  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
751  | 
case (Suc n')  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
752  | 
show ?thesis  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
753  | 
proof (cases "xs ! x = c")  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
754  | 
case True  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
755  | 
from True[symmetric] hyp[OF bnd_xs] Suc show ?thesis  | 
| 
70113
 
c8deb8ba6d05
Fixing the main Homology theory; also moving a lot of sum/prod lemmas into their generic context
 
paulson <lp15@cam.ac.uk> 
parents: 
70097 
diff
changeset
 | 
756  | 
unfolding F_def Suc sum.atLeast_Suc_lessThan[OF zero_less_Suc] sum.shift_bounds_Suc_ivl  | 
| 60680 | 757  | 
by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
758  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
759  | 
case False  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
760  | 
have "lower ivlx \<le> real_of_float c" "real_of_float c \<le> upper ivlx" "lower ivlx \<le> xs!x" "xs!x \<le> upper ivlx"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
761  | 
using Suc bnd_c \<open>bounded_by xs vs\<close>[THEN bounded_byE, OF \<open>x < length vs\<close>] bnd_x  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
762  | 
by (auto simp: set_of_eq)  | 
| 69529 | 763  | 
from Taylor[OF zero_less_Suc, of F, OF F0 DERIV[unfolded Suc] this False]  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
764  | 
obtain t::real where t_bnd: "if xs ! x < c then xs ! x < t \<and> t < c else c < t \<and> t < xs ! x"  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32920 
diff
changeset
 | 
765  | 
and fl_eq: "interpret_floatarith f (xs[x := xs ! x]) =  | 
| 
59730
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
766  | 
(\<Sum>m = 0..<Suc n'. F m c / (fact m) * (xs ! x - c) ^ m) +  | 
| 
 
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
 
paulson <lp15@cam.ac.uk> 
parents: 
59658 
diff
changeset
 | 
767  | 
F (Suc n') t / (fact (Suc n')) * (xs ! x - c) ^ Suc n'"  | 
| 56195 | 768  | 
unfolding atLeast0LessThan by blast  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
769  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
770  | 
from t_bnd bnd_xs bnd_c have *: "t \<in>\<^sub>r ivlx"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
771  | 
by (cases "xs ! x < c") (auto simp: set_of_eq)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
772  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
773  | 
have "interpret_floatarith f (xs[x := xs ! x]) = ?taylor t"  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32920 
diff
changeset
 | 
774  | 
unfolding fl_eq Suc by (auto simp add: algebra_simps divide_inverse)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
775  | 
also have "\<dots> \<in>\<^sub>r ivl"  | 
| 60680 | 776  | 
using * by (rule hyp)  | 
777  | 
finally show ?thesis  | 
|
778  | 
by simp  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
779  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
780  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
781  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
782  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
783  | 
fun approx_tse_form' where  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
784  | 
"approx_tse_form' prec t f 0 ivl cmp =  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
785  | 
(case approx_tse prec 0 t (mid ivl) 1 f [Some ivl]  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
786  | 
of Some ivl \<Rightarrow> cmp ivl | None \<Rightarrow> False)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
787  | 
"approx_tse_form' prec t f (Suc s) ivl cmp =  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
788  | 
(let (ivl1, ivl2) = split_float_interval ivl  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
789  | 
in (if approx_tse_form' prec t f s ivl1 cmp then  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
790  | 
approx_tse_form' prec t f s ivl2 cmp else False))"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
791  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
792  | 
lemma approx_tse_form':  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
793  | 
fixes x :: real  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
794  | 
assumes "approx_tse_form' prec t f s ivl cmp"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
795  | 
and "x \<in>\<^sub>r ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
796  | 
shows "\<exists>ivl' ivly. x \<in>\<^sub>r ivl' \<and> ivl' \<le> ivl \<and> cmp ivly \<and>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
797  | 
approx_tse prec 0 t (mid ivl') 1 f [Some ivl'] = Some ivly"  | 
| 60680 | 798  | 
using assms  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
799  | 
proof (induct s arbitrary: ivl)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
800  | 
case 0  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
801  | 
then obtain ivly  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
802  | 
where *: "approx_tse prec 0 t (mid ivl) 1 f [Some ivl] = Some ivly"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
803  | 
and **: "cmp ivly" by (auto elim!: case_optionE)  | 
| 46545 | 804  | 
with 0 show ?case by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
805  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
806  | 
case (Suc s)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
807  | 
let ?ivl1 = "fst (split_float_interval ivl)"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
808  | 
let ?ivl2 = "snd (split_float_interval ivl)"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
809  | 
from Suc.prems  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
810  | 
have l: "approx_tse_form' prec t f s ?ivl1 cmp"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
811  | 
and u: "approx_tse_form' prec t f s ?ivl2 cmp"  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
812  | 
by (auto simp add: Let_def lazy_conj)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
813  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
814  | 
have subintervals: "?ivl1 \<le> ivl" "?ivl2 \<le> ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
815  | 
using mid_le  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
816  | 
by (auto simp: less_eq_interval_def split_float_interval_bounds)  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
817  | 
|
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
818  | 
from split_float_interval_realD[OF _ \<open>x \<in>\<^sub>r ivl\<close>] consider "x \<in>\<^sub>r ?ivl1" | "x \<in>\<^sub>r ?ivl2"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
819  | 
by (auto simp: prod_eq_iff)  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
820  | 
then show ?case  | 
| 60680 | 821  | 
proof cases  | 
822  | 
case 1  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
823  | 
from Suc.hyps[OF l this]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
824  | 
obtain ivl' ivly where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
825  | 
"x \<in>\<^sub>r ivl' \<and> ivl' \<le> fst (split_float_interval ivl) \<and> cmp ivly \<and>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
826  | 
approx_tse prec 0 t (mid ivl') 1 f [Some ivl'] = Some ivly"  | 
| 60680 | 827  | 
by blast  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
828  | 
then show ?thesis  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
829  | 
using subintervals  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
830  | 
by (auto)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
831  | 
next  | 
| 60680 | 832  | 
case 2  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
833  | 
from Suc.hyps[OF u this]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
834  | 
obtain ivl' ivly where  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
835  | 
"x \<in>\<^sub>r ivl' \<and> ivl' \<le> snd (split_float_interval ivl) \<and> cmp ivly \<and>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
836  | 
approx_tse prec 0 t (mid ivl') 1 f [Some ivl'] = Some ivly"  | 
| 60680 | 837  | 
by blast  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
838  | 
then show ?thesis  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
839  | 
using subintervals  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
840  | 
by (auto)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
841  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
842  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
843  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
844  | 
lemma approx_tse_form'_less:  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
845  | 
fixes x :: real  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
846  | 
assumes tse: "approx_tse_form' prec t (Add a (Minus b)) s ivl (\<lambda> ivl. 0 < lower ivl)"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
847  | 
and x: "x \<in>\<^sub>r ivl"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
848  | 
shows "interpret_floatarith b [x] < interpret_floatarith a [x]"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
849  | 
proof -  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
850  | 
from approx_tse_form'[OF tse x]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
851  | 
obtain ivl' ivly  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
852  | 
where x': "x \<in>\<^sub>r ivl'"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
853  | 
and "ivl' \<le> ivl" and "0 < lower ivly"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
854  | 
and tse: "approx_tse prec 0 t (mid ivl') 1 (Add a (Minus b)) [Some ivl'] = Some ivly"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
855  | 
by blast  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
856  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
857  | 
hence "bounded_by [x] [Some ivl']"  | 
| 60680 | 858  | 
by (auto simp add: bounded_by_def)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
859  | 
from approx_tse[OF this _ _ _ _ tse, of ivl'] x' mid_le  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
860  | 
have "lower ivly \<le> interpret_floatarith a [x] - interpret_floatarith b [x]"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
861  | 
by (auto simp: set_of_eq)  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
862  | 
from order_less_le_trans[OF _ this, of 0] \<open>0 < lower ivly\<close> show ?thesis  | 
| 60680 | 863  | 
by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
864  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
865  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
866  | 
lemma approx_tse_form'_le:  | 
| 
40881
 
e84f82418e09
Use coercions in Approximation (by Dmitriy Traytel).
 
hoelzl 
parents: 
39556 
diff
changeset
 | 
867  | 
fixes x :: real  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
868  | 
assumes tse: "approx_tse_form' prec t (Add a (Minus b)) s ivl (\<lambda> ivl. 0 \<le> lower ivl)"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
869  | 
and x: "x \<in>\<^sub>r ivl"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
870  | 
shows "interpret_floatarith b [x] \<le> interpret_floatarith a [x]"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
871  | 
proof -  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
872  | 
from approx_tse_form'[OF tse x]  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
873  | 
obtain ivl' ivly  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
874  | 
where x': "x \<in>\<^sub>r ivl'"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
875  | 
and "ivl' \<le> ivl" and "0 \<le> lower ivly"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
876  | 
and tse: "approx_tse prec 0 t (mid ivl') 1 (Add a (Minus b)) [Some (ivl')] = Some ivly"  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
877  | 
by blast  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
878  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
879  | 
hence "bounded_by [x] [Some ivl']" by (auto simp add: bounded_by_def)  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
880  | 
from approx_tse[OF this _ _ _ _ tse, of ivl'] x' mid_le  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
881  | 
have "lower ivly \<le> interpret_floatarith a [x] - interpret_floatarith b [x]"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
882  | 
by (auto simp: set_of_eq)  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
883  | 
from order_trans[OF _ this, of 0] \<open>0 \<le> lower ivly\<close> show ?thesis  | 
| 60680 | 884  | 
by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
885  | 
qed  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
886  | 
|
| 58986 | 887  | 
fun approx_tse_concl where  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
888  | 
"approx_tse_concl prec t (Less lf rt) s ivl ivl' \<longleftrightarrow>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
889  | 
approx_tse_form' prec t (Add rt (Minus lf)) s (sup ivl ivl') (\<lambda> ivl. 0 < lower ivl)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
890  | 
"approx_tse_concl prec t (LessEqual lf rt) s ivl ivl' \<longleftrightarrow>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
891  | 
approx_tse_form' prec t (Add rt (Minus lf)) s (sup ivl ivl') (\<lambda> ivl. 0 \<le> lower ivl)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
892  | 
"approx_tse_concl prec t (AtLeastAtMost x lf rt) s ivl ivl' \<longleftrightarrow>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
893  | 
(if approx_tse_form' prec t (Add x (Minus lf)) s (sup ivl ivl') (\<lambda> ivl. 0 \<le> lower ivl) then  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
894  | 
approx_tse_form' prec t (Add rt (Minus x)) s (sup ivl ivl') (\<lambda> ivl. 0 \<le> lower ivl) else False)" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
895  | 
"approx_tse_concl prec t (Conj f g) s ivl ivl' \<longleftrightarrow>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
896  | 
approx_tse_concl prec t f s ivl ivl' \<and> approx_tse_concl prec t g s ivl ivl'" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
897  | 
"approx_tse_concl prec t (Disj f g) s ivl ivl' \<longleftrightarrow>  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
898  | 
approx_tse_concl prec t f s ivl ivl' \<or> approx_tse_concl prec t g s ivl ivl'" |  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
899  | 
"approx_tse_concl _ _ _ _ _ _ \<longleftrightarrow> False"  | 
| 58986 | 900  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
901  | 
definition  | 
| 60680 | 902  | 
"approx_tse_form prec t s f =  | 
903  | 
(case f of  | 
|
904  | 
Bound x a b f \<Rightarrow>  | 
|
905  | 
x = Var 0 \<and>  | 
|
906  | 
(case (approx prec a [None], approx prec b [None]) of  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
907  | 
(Some ivl, Some ivl') \<Rightarrow> approx_tse_concl prec t f s ivl ivl'  | 
| 60680 | 908  | 
| _ \<Rightarrow> False)  | 
909  | 
| _ \<Rightarrow> False)"  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
910  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
911  | 
lemma approx_tse_form:  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
912  | 
assumes "approx_tse_form prec t s f"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
913  | 
shows "interpret_form f [x]"  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
914  | 
proof (cases f)  | 
| 60680 | 915  | 
case f_def: (Bound i a b f')  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
916  | 
with assms obtain ivl ivl'  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
917  | 
where a: "approx prec a [None] = Some ivl"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
918  | 
and b: "approx prec b [None] = Some ivl'"  | 
| 
55413
 
a8e96847523c
adapted theories to '{case,rec}_{list,option}' names
 
blanchet 
parents: 
54782 
diff
changeset
 | 
919  | 
unfolding approx_tse_form_def by (auto elim!: case_optionE)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
920  | 
|
| 60680 | 921  | 
from f_def assms have "i = Var 0"  | 
922  | 
unfolding approx_tse_form_def by auto  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
923  | 
hence i: "interpret_floatarith i [x] = x" by auto  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
924  | 
|
| 60680 | 925  | 
  {
 | 
926  | 
let ?f = "\<lambda>z. interpret_floatarith z [x]"  | 
|
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
927  | 
    assume "?f i \<in> { ?f a .. ?f b }"
 | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
928  | 
with approx[OF _ a, of "[x]"] approx[OF _ b, of "[x]"]  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
929  | 
have bnd: "x \<in>\<^sub>r sup ivl ivl'" unfolding bounded_by_def i  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
930  | 
by (auto simp: set_of_eq sup_float_def inf_float_def min_def max_def)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
931  | 
|
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
932  | 
have "interpret_form f' [x]"  | 
| 60680 | 933  | 
using assms[unfolded f_def]  | 
| 58986 | 934  | 
proof (induct f')  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
935  | 
case (Less lf rt)  | 
| 58986 | 936  | 
with a b  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
937  | 
have "approx_tse_form' prec t (Add rt (Minus lf)) s (sup ivl ivl') (\<lambda> ivl. 0 < lower ivl)"  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32920 
diff
changeset
 | 
938  | 
unfolding approx_tse_form_def by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
939  | 
from approx_tse_form'_less[OF this bnd]  | 
| 58986 | 940  | 
show ?case using Less by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
941  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
942  | 
case (LessEqual lf rt)  | 
| 60680 | 943  | 
with f_def a b assms  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
944  | 
have "approx_tse_form' prec t (Add rt (Minus lf)) s (sup ivl ivl') (\<lambda> ivl. 0 \<le> lower ivl)"  | 
| 
32960
 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 
wenzelm 
parents: 
32920 
diff
changeset
 | 
945  | 
unfolding approx_tse_form_def by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
946  | 
from approx_tse_form'_le[OF this bnd]  | 
| 58986 | 947  | 
show ?case using LessEqual by auto  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
948  | 
next  | 
| 
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
949  | 
case (AtLeastAtMost x lf rt)  | 
| 60680 | 950  | 
with f_def a b assms  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
951  | 
have "approx_tse_form' prec t (Add rt (Minus x)) s (sup ivl ivl') (\<lambda> ivl. 0 \<le> lower ivl)"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
952  | 
and "approx_tse_form' prec t (Add x (Minus lf)) s (sup ivl ivl') (\<lambda> ivl. 0 \<le> lower ivl)"  | 
| 62390 | 953  | 
unfolding approx_tse_form_def lazy_conj by (auto split: if_split_asm)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
954  | 
from approx_tse_form'_le[OF this(1) bnd] approx_tse_form'_le[OF this(2) bnd]  | 
| 58986 | 955  | 
show ?case using AtLeastAtMost by auto  | 
956  | 
qed (auto simp: f_def approx_tse_form_def elim!: case_optionE)  | 
|
| 60680 | 957  | 
}  | 
958  | 
thus ?thesis unfolding f_def by auto  | 
|
| 58986 | 959  | 
qed (insert assms, auto simp add: approx_tse_form_def)  | 
| 
31863
 
e391eee8bf14
Implemented taylor series expansion for approximation
 
hoelzl 
parents: 
31811 
diff
changeset
 | 
960  | 
|
| 69597 | 961  | 
text \<open>\<^term>\<open>approx_form_eval\<close> is only used for the {\tt value}-command.\<close>
 | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
962  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
963  | 
fun approx_form_eval :: "nat \<Rightarrow> form \<Rightarrow> (float interval) option list \<Rightarrow> (float interval) option list" where  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
964  | 
"approx_form_eval prec (Bound (Var n) a b f) bs =  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
965  | 
(case (approx prec a bs, approx prec b bs)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
966  | 
of (Some ivl1, Some ivl2) \<Rightarrow> approx_form_eval prec f (bs[n := Some (sup ivl1 ivl2)])  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
967  | 
| _ \<Rightarrow> bs)" |  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
968  | 
"approx_form_eval prec (Assign (Var n) a f) bs =  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
969  | 
(case (approx prec a bs)  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
970  | 
of (Some ivl) \<Rightarrow> approx_form_eval prec f (bs[n := Some ivl])  | 
| 
32919
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
971  | 
| _ \<Rightarrow> bs)" |  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
972  | 
"approx_form_eval prec (Less a b) bs = bs @ [approx prec a bs, approx prec b bs]" |  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
973  | 
"approx_form_eval prec (LessEqual a b) bs = bs @ [approx prec a bs, approx prec b bs]" |  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
974  | 
"approx_form_eval prec (AtLeastAtMost x a b) bs =  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
975  | 
bs @ [approx prec x bs, approx prec a bs, approx prec b bs]" |  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
976  | 
"approx_form_eval _ _ bs = bs"  | 
| 
 
37adfa07b54b
approximation now fails earlier when using interval splitting; value [approximate] now supports bounded variables; renamed Var -> Atom for better readability
 
hoelzl 
parents: 
32650 
diff
changeset
 | 
977  | 
|
| 60680 | 978  | 
|
| 60533 | 979  | 
subsection \<open>Implement proof method \texttt{approximation}\<close>
 | 
| 29805 | 980  | 
|
| 
71034
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
981  | 
ML \<open>  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
982  | 
val _ = \<comment> \<open>Trusting the oracle \<close>@{oracle_name "holds_by_evaluation"}
 | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
983  | 
signature APPROXIMATION_COMPUTATION = sig  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
984  | 
val approx_bool: Proof.context -> term -> term  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
985  | 
val approx_arith: Proof.context -> term -> term  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
986  | 
val approx_form_eval: Proof.context -> term -> term  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
987  | 
val approx_conv: Proof.context -> conv  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
988  | 
end  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
989  | 
|
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
990  | 
structure Approximation_Computation : APPROXIMATION_COMPUTATION = struct  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
991  | 
|
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
992  | 
fun approx_conv ctxt ct =  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
993  | 
    @{computation_check
 | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
994  | 
terms: Trueprop  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
995  | 
"0 :: nat" "1 :: nat" "2 :: nat" "3 :: nat" Suc  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
996  | 
"(+)::nat\<Rightarrow>nat\<Rightarrow>nat" "(-)::nat\<Rightarrow>nat\<Rightarrow>nat" "(*)::nat\<Rightarrow>nat\<Rightarrow>nat"  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
997  | 
"0 :: int" "1 :: int" "2 :: int" "3 :: int" "-1 :: int"  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
998  | 
"(+)::int\<Rightarrow>int\<Rightarrow>int" "(-)::int\<Rightarrow>int\<Rightarrow>int" "(*)::int\<Rightarrow>int\<Rightarrow>int" "uminus::int\<Rightarrow>int"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
999  | 
"replicate :: _ \<Rightarrow> (float interval) option \<Rightarrow> _"  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1000  | 
"interval_of::float\<Rightarrow>float interval"  | 
| 
71034
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1001  | 
approx'  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1002  | 
approx_form  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1003  | 
approx_tse_form  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1004  | 
approx_form_eval  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1005  | 
datatypes: bool  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1006  | 
int  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1007  | 
nat  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1008  | 
integer  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1009  | 
"nat list"  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1010  | 
float  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1011  | 
"(float interval) option list"  | 
| 
71034
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1012  | 
floatarith  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1013  | 
form  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1014  | 
} ctxt ct  | 
| 
36985
 
41c5d4002f60
spelt out normalizer explicitly -- avoid dynamic reference to code generator configuration; avoid using old Codegen.eval_term
 
haftmann 
parents: 
36960 
diff
changeset
 | 
1015  | 
|
| 74397 | 1016  | 
fun term_of_bool true = \<^Const>\<open>True\<close>  | 
1017  | 
| term_of_bool false = \<^Const>\<open>False\<close>;  | 
|
| 
36985
 
41c5d4002f60
spelt out normalizer explicitly -- avoid dynamic reference to code generator configuration; avoid using old Codegen.eval_term
 
haftmann 
parents: 
36960 
diff
changeset
 | 
1018  | 
|
| 74397 | 1019  | 
  val mk_int = HOLogic.mk_number \<^Type>\<open>int\<close> o @{code integer_of_int};
 | 
| 
51143
 
0a2371e7ced3
two target language numeral types: integer and natural, as replacement for code_numeral;
 
haftmann 
parents: 
49962 
diff
changeset
 | 
1020  | 
|
| 
36985
 
41c5d4002f60
spelt out normalizer explicitly -- avoid dynamic reference to code generator configuration; avoid using old Codegen.eval_term
 
haftmann 
parents: 
36960 
diff
changeset
 | 
1021  | 
  fun term_of_float (@{code Float} (k, l)) =
 | 
| 74397 | 1022  | 
\<^Const>\<open>Float for \<open>mk_int k\<close> \<open>mk_int l\<close>\<close>;  | 
| 
36985
 
41c5d4002f60
spelt out normalizer explicitly -- avoid dynamic reference to code generator configuration; avoid using old Codegen.eval_term
 
haftmann 
parents: 
36960 
diff
changeset
 | 
1023  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1024  | 
  fun term_of_float_interval x = @{term "Interval::_\<Rightarrow>float interval"} $
 | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1025  | 
HOLogic.mk_prod  | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1026  | 
      (apply2 term_of_float (@{code lowerF} x, @{code upperF} x))
 | 
| 
36985
 
41c5d4002f60
spelt out normalizer explicitly -- avoid dynamic reference to code generator configuration; avoid using old Codegen.eval_term
 
haftmann 
parents: 
36960 
diff
changeset
 | 
1027  | 
|
| 74397 | 1028  | 
fun term_of_float_interval_option NONE = \<^Const>\<open>None \<^typ>\<open>float interval option\<close>\<close>  | 
1029  | 
| term_of_float_interval_option (SOME ff) =  | 
|
1030  | 
\<^Const>\<open>Some \<^typ>\<open>float interval\<close> for \<open>term_of_float_interval ff\<close>\<close>;  | 
|
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1031  | 
|
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1032  | 
val term_of_float_interval_option_list =  | 
| 74397 | 1033  | 
HOLogic.mk_list \<^typ>\<open>float interval option\<close> o map term_of_float_interval_option;  | 
| 
36985
 
41c5d4002f60
spelt out normalizer explicitly -- avoid dynamic reference to code generator configuration; avoid using old Codegen.eval_term
 
haftmann 
parents: 
36960 
diff
changeset
 | 
1034  | 
|
| 
71034
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1035  | 
  val approx_bool = @{computation bool}
 | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1036  | 
(fn _ => fn x => case x of SOME b => term_of_bool b  | 
| 
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1037  | 
| NONE => error "Computation approx_bool failed.")  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1038  | 
  val approx_arith = @{computation "float interval option"}
 | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1039  | 
(fn _ => fn x => case x of SOME ffo => term_of_float_interval_option ffo  | 
| 
71034
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1040  | 
| NONE => error "Computation approx_arith failed.")  | 
| 
71037
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1041  | 
  val approx_form_eval = @{computation "float interval option list"}
 | 
| 
 
f630f2e707a6
refactor Approximation.thy to use more abstract type of intervals
 
immler 
parents: 
71034 
diff
changeset
 | 
1042  | 
(fn _ => fn x => case x of SOME ffos => term_of_float_interval_option_list ffos  | 
| 
71034
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1043  | 
| NONE => error "Computation approx_form_eval failed.")  | 
| 
36985
 
41c5d4002f60
spelt out normalizer explicitly -- avoid dynamic reference to code generator configuration; avoid using old Codegen.eval_term
 
haftmann 
parents: 
36960 
diff
changeset
 | 
1044  | 
|
| 
71034
 
e0755162093f
replace approximation oracle by less ad-hoc @{computation}s
 
immler 
parents: 
70113 
diff
changeset
 | 
1045  | 
end  | 
| 60533 | 1046  | 
\<close>  | 
| 
31099
 
03314c427b34
optimized Approximation by precompiling approx_inequality
 
hoelzl 
parents: 
31098 
diff
changeset
 | 
1047  | 
|
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
1048  | 
lemma intervalE: "a \<le> x \<and> x \<le> b \<Longrightarrow> \<lbrakk> x \<in> { a .. b } \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"
 | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
1049  | 
by auto  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
1050  | 
|
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
1051  | 
lemma meta_eqE: "x \<equiv> a \<Longrightarrow> \<lbrakk> x = a \<Longrightarrow> P\<rbrakk> \<Longrightarrow> P"  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
1052  | 
by auto  | 
| 
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
1053  | 
|
| 
63929
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1054  | 
named_theorems approximation_preproc  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1055  | 
|
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1056  | 
lemma approximation_preproc_floatarith[approximation_preproc]:  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1057  | 
"0 = real_of_float 0"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1058  | 
"1 = real_of_float 1"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1059  | 
"0 = Float 0 0"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1060  | 
"1 = Float 1 0"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1061  | 
"numeral a = Float (numeral a) 0"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1062  | 
"numeral a = real_of_float (numeral a)"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1063  | 
"x - y = x + - y"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1064  | 
"x / y = x * inverse y"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1065  | 
"ceiling x = - floor (- x)"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1066  | 
"log x y = ln y * inverse (ln x)"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1067  | 
"sin x = cos (pi / 2 - x)"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1068  | 
"tan x = sin x / cos x"  | 
| 
63931
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1069  | 
by (simp_all add: inverse_eq_divide ceiling_def log_def sin_cos_eq tan_def real_of_float_eq)  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1070  | 
|
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1071  | 
lemma approximation_preproc_int[approximation_preproc]:  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1072  | 
"real_of_int 0 = real_of_float 0"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1073  | 
"real_of_int 1 = real_of_float 1"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1074  | 
"real_of_int (i + j) = real_of_int i + real_of_int j"  | 
| 
63929
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1075  | 
"real_of_int (- i) = - real_of_int i"  | 
| 
63931
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1076  | 
"real_of_int (i - j) = real_of_int i - real_of_int j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1077  | 
"real_of_int (i * j) = real_of_int i * real_of_int j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1078  | 
"real_of_int (i div j) = real_of_int (floor (real_of_int i / real_of_int j))"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1079  | 
"real_of_int (min i j) = min (real_of_int i) (real_of_int j)"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1080  | 
"real_of_int (max i j) = max (real_of_int i) (real_of_int j)"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1081  | 
"real_of_int (abs i) = abs (real_of_int i)"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1082  | 
"real_of_int (i ^ n) = (real_of_int i) ^ n"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1083  | 
"real_of_int (numeral a) = real_of_float (numeral a)"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1084  | 
"i mod j = i - i div j * j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1085  | 
"i = j \<longleftrightarrow> real_of_int i = real_of_int j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1086  | 
"i \<le> j \<longleftrightarrow> real_of_int i \<le> real_of_int j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1087  | 
"i < j \<longleftrightarrow> real_of_int i < real_of_int j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1088  | 
  "i \<in> {j .. k} \<longleftrightarrow> real_of_int i \<in> {real_of_int j .. real_of_int k}"
 | 
| 64246 | 1089  | 
by (simp_all add: floor_divide_of_int_eq minus_div_mult_eq_mod [symmetric])  | 
| 
63931
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1090  | 
|
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1091  | 
lemma approximation_preproc_nat[approximation_preproc]:  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1092  | 
"real 0 = real_of_float 0"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1093  | 
"real 1 = real_of_float 1"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1094  | 
"real (i + j) = real i + real j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1095  | 
"real (i - j) = max (real i - real j) 0"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1096  | 
"real (i * j) = real i * real j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1097  | 
"real (i div j) = real_of_int (floor (real i / real j))"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1098  | 
"real (min i j) = min (real i) (real j)"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1099  | 
"real (max i j) = max (real i) (real j)"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1100  | 
"real (i ^ n) = (real i) ^ n"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1101  | 
"real (numeral a) = real_of_float (numeral a)"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1102  | 
"i mod j = i - i div j * j"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1103  | 
"n = m \<longleftrightarrow> real n = real m"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1104  | 
"n \<le> m \<longleftrightarrow> real n \<le> real m"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1105  | 
"n < m \<longleftrightarrow> real n < real m"  | 
| 
 
f17a1c60ac39
approximation: preprocessing for nat/int expressions
 
immler 
parents: 
63929 
diff
changeset
 | 
1106  | 
  "n \<in> {m .. l} \<longleftrightarrow> real n \<in> {real m .. real l}"
 | 
| 64243 | 1107  | 
by (simp_all add: real_div_nat_eq_floor_of_divide minus_div_mult_eq_mod [symmetric])  | 
| 
63929
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1108  | 
|
| 69605 | 1109  | 
ML_file \<open>approximation.ML\<close>  | 
| 59850 | 1110  | 
|
| 60533 | 1111  | 
method_setup approximation = \<open>  | 
| 60680 | 1112  | 
let  | 
1113  | 
val free =  | 
|
1114  | 
Args.context -- Args.term >> (fn (_, Free (n, _)) => n | (ctxt, t) =>  | 
|
1115  | 
        error ("Bad free variable: " ^ Syntax.string_of_term ctxt t));
 | 
|
| 59850 | 1116  | 
in  | 
| 60680 | 1117  | 
Scan.lift Parse.nat --  | 
| 59850 | 1118  | 
Scan.optional (Scan.lift (Args.$$$ "splitting" |-- Args.colon)  | 
| 60680 | 1119  | 
|-- Parse.and_list' (free --| Scan.lift (Args.$$$ "=") -- Scan.lift Parse.nat)) [] --  | 
1120  | 
Scan.option (Scan.lift (Args.$$$ "taylor" |-- Args.colon) |--  | 
|
1121  | 
(free |-- Scan.lift (Args.$$$ "=") |-- Scan.lift Parse.nat)) >>  | 
|
| 59850 | 1122  | 
(fn ((prec, splitting), taylor) => fn ctxt =>  | 
1123  | 
SIMPLE_METHOD' (Approximation.approximation_tac prec splitting taylor ctxt))  | 
|
1124  | 
end  | 
|
| 60533 | 1125  | 
\<close> "real number approximation"  | 
| 
31811
 
64dea9a15031
Improved computation of bounds and implemented interval splitting for 'approximation'.
 
hoelzl 
parents: 
31810 
diff
changeset
 | 
1126  | 
|
| 58988 | 1127  | 
|
1128  | 
section "Quickcheck Generator"  | 
|
1129  | 
||
| 
63929
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1130  | 
lemma approximation_preproc_push_neg[approximation_preproc]:  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1131  | 
fixes a b::real  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1132  | 
shows  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1133  | 
"\<not> (a < b) \<longleftrightarrow> b \<le> a"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1134  | 
"\<not> (a \<le> b) \<longleftrightarrow> b < a"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1135  | 
"\<not> (a = b) \<longleftrightarrow> b < a \<or> a < b"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1136  | 
"\<not> (p \<and> q) \<longleftrightarrow> \<not> p \<or> \<not> q"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1137  | 
"\<not> (p \<or> q) \<longleftrightarrow> \<not> p \<and> \<not> q"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1138  | 
"\<not> \<not> q \<longleftrightarrow> q"  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1139  | 
by auto  | 
| 
 
b673e7221b16
approximation: rewrite for reduction to base expressions
 
immler 
parents: 
63918 
diff
changeset
 | 
1140  | 
|
| 69605 | 1141  | 
ML_file \<open>approximation_generator.ML\<close>  | 
| 58988 | 1142  | 
setup "Approximation_Generator.setup"  | 
1143  | 
||
| 69830 | 1144  | 
section "Avoid pollution of name space"  | 
1145  | 
||
| 81107 | 1146  | 
bundle floatarith_syntax  | 
| 81100 | 1147  | 
begin  | 
| 
80914
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1148  | 
notation Add (\<open>Add\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1149  | 
notation Minus (\<open>Minus\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1150  | 
notation Mult (\<open>Mult\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1151  | 
notation Inverse (\<open>Inverse\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1152  | 
notation Cos (\<open>Cos\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1153  | 
notation Arctan (\<open>Arctan\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1154  | 
notation Abs (\<open>Abs\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1155  | 
notation Max (\<open>Max\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1156  | 
notation Min (\<open>Min\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1157  | 
notation Pi (\<open>Pi\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1158  | 
notation Sqrt (\<open>Sqrt\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1159  | 
notation Exp (\<open>Exp\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1160  | 
notation Powr (\<open>Powr\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1161  | 
notation Ln (\<open>Ln\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1162  | 
notation Power (\<open>Power\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1163  | 
notation Floor (\<open>Floor\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1164  | 
notation Var (\<open>Var\<close>)  | 
| 
 
d97fdabd9e2b
standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
 
wenzelm 
parents: 
80034 
diff
changeset
 | 
1165  | 
notation Num (\<open>Num\<close>)  | 
| 69835 | 1166  | 
end  | 
1167  | 
||
| 69830 | 1168  | 
hide_const (open)  | 
1169  | 
Add  | 
|
1170  | 
Minus  | 
|
1171  | 
Mult  | 
|
1172  | 
Inverse  | 
|
1173  | 
Cos  | 
|
1174  | 
Arctan  | 
|
1175  | 
Abs  | 
|
1176  | 
Max  | 
|
1177  | 
Min  | 
|
1178  | 
Pi  | 
|
1179  | 
Sqrt  | 
|
1180  | 
Exp  | 
|
1181  | 
Powr  | 
|
1182  | 
Ln  | 
|
1183  | 
Power  | 
|
1184  | 
Floor  | 
|
1185  | 
Var  | 
|
1186  | 
Num  | 
|
1187  | 
||
| 29805 | 1188  | 
end  |