neuper@37906
|
1 |
(* integration over the reals
|
neuper@37906
|
2 |
author: Walther Neuper
|
neuper@37906
|
3 |
050814, 08:51
|
neuper@37906
|
4 |
(c) due to copyright terms
|
neuper@37906
|
5 |
*)
|
neuper@37906
|
6 |
|
neuper@37954
|
7 |
theory Integrate imports Diff begin
|
neuper@37906
|
8 |
|
neuper@37906
|
9 |
consts
|
neuper@37906
|
10 |
|
neuper@37906
|
11 |
Integral :: "[real, real]=> real" ("Integral _ D _" 91)
|
walther@60278
|
12 |
(*new_c :: "real => real" ("new_c _" 66)*)
|
walther@60278
|
13 |
is_f_x :: "real => bool" ("_ is'_f'_x" 10)
|
neuper@37906
|
14 |
|
neuper@37906
|
15 |
(*descriptions in the related problems*)
|
neuper@37996
|
16 |
integrateBy :: "real => una"
|
neuper@37996
|
17 |
antiDerivative :: "real => una"
|
neuper@37996
|
18 |
antiDerivativeName :: "(real => real) => una"
|
neuper@37906
|
19 |
|
walther@60260
|
20 |
(*the CAS-command, eg. "Integrate (2*x \<up> 3, x)"*)
|
neuper@37906
|
21 |
Integrate :: "[real * real] => real"
|
neuper@37906
|
22 |
|
neuper@52148
|
23 |
axiomatization where
|
neuper@37906
|
24 |
(*stated as axioms, todo: prove as theorems
|
neuper@37906
|
25 |
'bdv' is a constant handled on the meta-level
|
neuper@37906
|
26 |
specifically as a 'bound variable' *)
|
neuper@37906
|
27 |
|
walther@60269
|
28 |
(*Ambiguous input\<^here> produces 3 parse trees -----------------------------\\*)
|
neuper@52148
|
29 |
integral_const: "Not (bdv occurs_in u) ==> Integral u D bdv = u * bdv" and
|
walther@60242
|
30 |
integral_var: "Integral bdv D bdv = bdv \<up> 2 / 2" and
|
neuper@37906
|
31 |
|
neuper@37983
|
32 |
integral_add: "Integral (u + v) D bdv =
|
neuper@52148
|
33 |
(Integral u D bdv) + (Integral v D bdv)" and
|
neuper@37983
|
34 |
integral_mult: "[| Not (bdv occurs_in u); bdv occurs_in v |] ==>
|
neuper@52148
|
35 |
Integral (u * v) D bdv = u * (Integral v D bdv)" and
|
neuper@37906
|
36 |
(*WN080222: this goes into sub-terms, too ...
|
neuper@37983
|
37 |
call_for_new_c: "[| Not (matches (u + new_c v) a); Not (a is_f_x) |] ==>
|
neuper@37954
|
38 |
a = a + new_c a"
|
neuper@37906
|
39 |
*)
|
walther@60242
|
40 |
integral_pow: "Integral bdv \<up> n D bdv = bdv \<up> (n+1) / (n + 1)"
|
walther@60269
|
41 |
(*Ambiguous input\<^here> produces 3 parse trees -----------------------------//*)
|
neuper@37906
|
42 |
|
wneuper@59472
|
43 |
ML \<open>
|
neuper@37954
|
44 |
(** eval functions **)
|
neuper@37954
|
45 |
|
neuper@37954
|
46 |
val c = Free ("c", HOLogic.realT);
|
walther@59878
|
47 |
(*.create a new unique variable 'c..' in a term; for use by Rule.Eval in a rls;
|
neuper@37954
|
48 |
an alternative to do this would be '(Try (Calculate new_c_) (new_c es__))'
|
neuper@37954
|
49 |
in the script; this will be possible if currying doesnt take the value
|
neuper@37954
|
50 |
from a variable, but the value '(new_c es__)' itself.*)
|
neuper@37954
|
51 |
fun new_c term =
|
neuper@37954
|
52 |
let fun selc var =
|
neuper@40836
|
53 |
case (Symbol.explode o id_of) var of
|
neuper@37954
|
54 |
"c"::[] => true
|
walther@59875
|
55 |
| "c"::"_"::is => (case (TermC.int_opt_of_string o implode) is of
|
neuper@37954
|
56 |
SOME _ => true
|
neuper@37954
|
57 |
| NONE => false)
|
neuper@37954
|
58 |
| _ => false;
|
neuper@40836
|
59 |
fun get_coeff c = case (Symbol.explode o id_of) c of
|
walther@59875
|
60 |
"c"::"_"::is => (the o TermC.int_opt_of_string o implode) is
|
neuper@37954
|
61 |
| _ => 0;
|
wneuper@59389
|
62 |
val cs = filter selc (TermC.vars term);
|
neuper@37954
|
63 |
in
|
neuper@37954
|
64 |
case cs of
|
neuper@37954
|
65 |
[] => c
|
walther@60269
|
66 |
| [_] => Free ("c_2", HOLogic.realT)
|
neuper@37954
|
67 |
| cs =>
|
neuper@37954
|
68 |
let val max_coeff = maxl (map get_coeff cs)
|
neuper@37954
|
69 |
in Free ("c_"^string_of_int (max_coeff + 1), HOLogic.realT) end
|
neuper@37954
|
70 |
end;
|
neuper@37954
|
71 |
|
neuper@37954
|
72 |
(*WN080222
|
walther@60278
|
73 |
(*("new_c", ("Integrate.new_c", eval_new_c "#new_c_"))*)
|
walther@60278
|
74 |
fun eval_new_c _ _ (p as (Const ("Integrate.new_c",_) $ t)) _ =
|
walther@59868
|
75 |
SOME ((UnparseC.term p) ^ " = " ^ UnparseC.term (new_c p),
|
neuper@37954
|
76 |
Trueprop $ (mk_equality (p, new_c p)))
|
neuper@37954
|
77 |
| eval_new_c _ _ _ _ = NONE;
|
neuper@37954
|
78 |
*)
|
neuper@37954
|
79 |
|
neuper@37954
|
80 |
(*WN080222:*)
|
walther@60278
|
81 |
(*("add_new_c", ("Integrate.add_new_c", eval_add_new_c "#add_new_c_"))
|
neuper@37954
|
82 |
add a new c to a term or a fun-equation;
|
neuper@37954
|
83 |
this is _not in_ the term, because only applied to _whole_ term*)
|
walther@60278
|
84 |
fun eval_add_new_c (_:string) "Integrate.add_new_c" p (_:theory) =
|
neuper@37954
|
85 |
let val p' = case p of
|
neuper@41922
|
86 |
Const ("HOL.eq", T) $ lh $ rh =>
|
wneuper@59389
|
87 |
Const ("HOL.eq", T) $ lh $ TermC.mk_add rh (new_c rh)
|
wneuper@59389
|
88 |
| p => TermC.mk_add p (new_c p)
|
walther@59868
|
89 |
in SOME ((UnparseC.term p) ^ " = " ^ UnparseC.term p',
|
wneuper@59390
|
90 |
HOLogic.Trueprop $ (TermC.mk_equality (p, p')))
|
neuper@37954
|
91 |
end
|
neuper@37954
|
92 |
| eval_add_new_c _ _ _ _ = NONE;
|
neuper@37954
|
93 |
|
neuper@37954
|
94 |
|
walther@60278
|
95 |
(*("is_f_x", ("Integrate.is_f_x", eval_is_f_x "is_f_x_"))*)
|
walther@60278
|
96 |
fun eval_is_f_x _ _(p as (Const ("Integrate.is_f_x", _)
|
neuper@37954
|
97 |
$ arg)) _ =
|
wneuper@59389
|
98 |
if TermC.is_f_x arg
|
walther@59868
|
99 |
then SOME ((UnparseC.term p) ^ " = True",
|
wneuper@59390
|
100 |
HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
|
walther@59868
|
101 |
else SOME ((UnparseC.term p) ^ " = False",
|
wneuper@59390
|
102 |
HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
|
neuper@37954
|
103 |
| eval_is_f_x _ _ _ _ = NONE;
|
wneuper@59472
|
104 |
\<close>
|
wneuper@59472
|
105 |
setup \<open>KEStore_Elems.add_calcs
|
walther@60278
|
106 |
[("add_new_c", ("Integrate.add_new_c", eval_add_new_c "add_new_c_")),
|
walther@60278
|
107 |
("is_f_x", ("Integrate.is_f_x", eval_is_f_x "is_f_idextifier_"))]\<close>
|
wneuper@59472
|
108 |
ML \<open>
|
neuper@37954
|
109 |
(** rulesets **)
|
neuper@37954
|
110 |
|
neuper@37954
|
111 |
(*.rulesets for integration.*)
|
neuper@37954
|
112 |
val integration_rules =
|
walther@59851
|
113 |
Rule_Def.Repeat {id="integration_rules", preconds = [],
|
neuper@37954
|
114 |
rew_ord = ("termlessI",termlessI),
|
walther@59851
|
115 |
erls = Rule_Def.Repeat {id="conditions_in_integration_rules",
|
neuper@37954
|
116 |
preconds = [],
|
neuper@37954
|
117 |
rew_ord = ("termlessI",termlessI),
|
walther@59851
|
118 |
erls = Rule_Set.Empty,
|
walther@59851
|
119 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
neuper@37954
|
120 |
rules = [(*for rewriting conditions in Thm's*)
|
wenzelm@60294
|
121 |
\<^rule_eval>\<open>Prog_Expr.occurs_in\<close> (Prog_Expr.eval_occurs_in "#occurs_in_"),
|
wenzelm@60297
|
122 |
\<^rule_thm>\<open>not_true\<close>,
|
wenzelm@60298
|
123 |
\<^rule_thm>\<open>not_false\<close>
|
neuper@37954
|
124 |
],
|
walther@59878
|
125 |
scr = Rule.Empty_Prog},
|
walther@59851
|
126 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
neuper@37954
|
127 |
rules = [
|
wenzelm@60297
|
128 |
\<^rule_thm>\<open>integral_const\<close>,
|
wenzelm@60297
|
129 |
\<^rule_thm>\<open>integral_var\<close>,
|
wenzelm@60297
|
130 |
\<^rule_thm>\<open>integral_add\<close>,
|
wenzelm@60297
|
131 |
\<^rule_thm>\<open>integral_mult\<close>,
|
wenzelm@60297
|
132 |
\<^rule_thm>\<open>integral_pow\<close>,
|
wenzelm@60294
|
133 |
\<^rule_eval>\<open>plus\<close> (**)(eval_binop "#add_")(*for n+1*)
|
neuper@37954
|
134 |
],
|
walther@59878
|
135 |
scr = Rule.Empty_Prog};
|
wneuper@59472
|
136 |
\<close>
|
wneuper@59472
|
137 |
ML \<open>
|
neuper@37954
|
138 |
val add_new_c =
|
walther@59878
|
139 |
Rule_Set.Sequence {id="add_new_c", preconds = [],
|
neuper@37954
|
140 |
rew_ord = ("termlessI",termlessI),
|
walther@59851
|
141 |
erls = Rule_Def.Repeat {id="conditions_in_add_new_c",
|
neuper@37954
|
142 |
preconds = [],
|
neuper@37954
|
143 |
rew_ord = ("termlessI",termlessI),
|
walther@59851
|
144 |
erls = Rule_Set.Empty,
|
walther@59851
|
145 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
wenzelm@60294
|
146 |
rules = [\<^rule_eval>\<open>Prog_Expr.matches\<close> (Prog_Expr.eval_matches""),
|
wenzelm@60294
|
147 |
\<^rule_eval>\<open>Integrate.is_f_x\<close> (eval_is_f_x "is_f_x_"),
|
wenzelm@60297
|
148 |
\<^rule_thm>\<open>not_true\<close>,
|
wenzelm@60297
|
149 |
\<^rule_thm>\<open>not_false\<close>
|
neuper@37954
|
150 |
],
|
walther@59878
|
151 |
scr = Rule.Empty_Prog},
|
walther@59851
|
152 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
wenzelm@60297
|
153 |
rules = [ (*\<^rule_thm>\<open>call_for_new_c\<close>,*)
|
walther@60278
|
154 |
Rule.Cal1 ("Integrate.add_new_c", eval_add_new_c "new_c_")
|
neuper@37954
|
155 |
],
|
walther@59878
|
156 |
scr = Rule.Empty_Prog};
|
wneuper@59472
|
157 |
\<close>
|
wneuper@59472
|
158 |
ML \<open>
|
neuper@37954
|
159 |
|
neuper@37954
|
160 |
(*.rulesets for simplifying Integrals.*)
|
neuper@37954
|
161 |
|
neuper@37954
|
162 |
(*.for simplify_Integral adapted from 'norm_Rational_rls'.*)
|
neuper@37954
|
163 |
val norm_Rational_rls_noadd_fractions =
|
walther@59851
|
164 |
Rule_Def.Repeat {id = "norm_Rational_rls_noadd_fractions", preconds = [],
|
walther@59857
|
165 |
rew_ord = ("dummy_ord",Rewrite_Ord.dummy_ord),
|
walther@59851
|
166 |
erls = norm_rat_erls, srls = Rule_Set.Empty, calc = [], errpatts = [],
|
wneuper@59416
|
167 |
rules = [(*Rule.Rls_ add_fractions_p_rls,!!!*)
|
wneuper@59416
|
168 |
Rule.Rls_ (*rat_mult_div_pow original corrected WN051028*)
|
walther@59851
|
169 |
(Rule_Def.Repeat {id = "rat_mult_div_pow", preconds = [],
|
walther@59857
|
170 |
rew_ord = ("dummy_ord",Rewrite_Ord.dummy_ord),
|
walther@59852
|
171 |
erls = (*FIXME.WN051028 Rule_Set.empty,*)
|
walther@59852
|
172 |
Rule_Set.append_rules "Rule_Set.empty-is_polyexp" Rule_Set.empty
|
wenzelm@60294
|
173 |
[\<^rule_eval>\<open>is_polyexp\<close> (eval_is_polyexp "")],
|
walther@59851
|
174 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
wenzelm@60297
|
175 |
rules = [\<^rule_thm>\<open>rat_mult\<close>,
|
neuper@37954
|
176 |
(*"?a / ?b * (?c / ?d) = ?a * ?c / (?b * ?d)"*)
|
wenzelm@60297
|
177 |
\<^rule_thm>\<open>rat_mult_poly_l\<close>,
|
neuper@37954
|
178 |
(*"?c is_polyexp ==> ?c * (?a / ?b) = ?c * ?a / ?b"*)
|
wenzelm@60297
|
179 |
\<^rule_thm>\<open>rat_mult_poly_r\<close>,
|
neuper@37954
|
180 |
(*"?c is_polyexp ==> ?a / ?b * ?c = ?a * ?c / ?b"*)
|
neuper@37954
|
181 |
|
wenzelm@60298
|
182 |
\<^rule_thm>\<open>real_divide_divide1_mg\<close>,
|
neuper@37954
|
183 |
(*"y ~= 0 ==> (u / v) / (y / z) = (u * z) / (y * v)"*)
|
wenzelm@60298
|
184 |
\<^rule_thm>\<open>divide_divide_eq_right\<close>,
|
neuper@37954
|
185 |
(*"?x / (?y / ?z) = ?x * ?z / ?y"*)
|
wenzelm@60298
|
186 |
\<^rule_thm>\<open>divide_divide_eq_left\<close>,
|
neuper@37954
|
187 |
(*"?x / ?y / ?z = ?x / (?y * ?z)"*)
|
wenzelm@60294
|
188 |
\<^rule_eval>\<open>divide\<close> (Prog_Expr.eval_cancel "#divide_e"),
|
neuper@37954
|
189 |
|
wenzelm@60297
|
190 |
\<^rule_thm>\<open>rat_power\<close>
|
walther@60260
|
191 |
(*"(?a / ?b) \<up> ?n = ?a \<up> ?n / ?b \<up> ?n"*)
|
neuper@37954
|
192 |
],
|
walther@59878
|
193 |
scr = Rule.Empty_Prog
|
neuper@37954
|
194 |
}),
|
wneuper@59416
|
195 |
Rule.Rls_ make_rat_poly_with_parentheses,
|
wneuper@59416
|
196 |
Rule.Rls_ cancel_p_rls,(*FIXME:cancel_p does NOT order sometimes*)
|
wneuper@59416
|
197 |
Rule.Rls_ rat_reduce_1
|
neuper@37954
|
198 |
],
|
walther@59878
|
199 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
200 |
};
|
neuper@37954
|
201 |
|
neuper@37954
|
202 |
(*.for simplify_Integral adapted from 'norm_Rational'.*)
|
neuper@37954
|
203 |
val norm_Rational_noadd_fractions =
|
walther@59878
|
204 |
Rule_Set.Sequence {id = "norm_Rational_noadd_fractions", preconds = [],
|
walther@59857
|
205 |
rew_ord = ("dummy_ord",Rewrite_Ord.dummy_ord),
|
walther@59851
|
206 |
erls = norm_rat_erls, srls = Rule_Set.Empty, calc = [], errpatts = [],
|
wneuper@59416
|
207 |
rules = [Rule.Rls_ discard_minus,
|
wneuper@59416
|
208 |
Rule.Rls_ rat_mult_poly,(* removes double fractions like a/b/c *)
|
wneuper@59416
|
209 |
Rule.Rls_ make_rat_poly_with_parentheses, (*WN0510 also in(#)below*)
|
wneuper@59416
|
210 |
Rule.Rls_ cancel_p_rls, (*FIXME.MG:cancel_p does NOT order sometim*)
|
wneuper@59416
|
211 |
Rule.Rls_ norm_Rational_rls_noadd_fractions,(* the main rls (#) *)
|
wneuper@59416
|
212 |
Rule.Rls_ discard_parentheses1 (* mult only *)
|
neuper@37954
|
213 |
],
|
walther@59878
|
214 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
215 |
};
|
neuper@37954
|
216 |
|
neuper@37954
|
217 |
(*.simplify terms before and after Integration such that
|
neuper@37954
|
218 |
..a.x^2/2 + b.x^3/3.. is made to ..a/2.x^2 + b/3.x^3.. (and NO
|
neuper@37954
|
219 |
common denominator as done by norm_Rational or make_ratpoly_in.
|
neuper@37954
|
220 |
This is a copy from 'make_ratpoly_in' with respective reduction of rules and
|
neuper@37954
|
221 |
*1* expand the term, ie. distribute * and / over +
|
neuper@37954
|
222 |
.*)
|
neuper@37954
|
223 |
val separate_bdv2 =
|
walther@59852
|
224 |
Rule_Set.append_rules "separate_bdv2"
|
neuper@37954
|
225 |
collect_bdv
|
wenzelm@60297
|
226 |
[\<^rule_thm>\<open>separate_bdv\<close>,
|
neuper@37954
|
227 |
(*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
|
wenzelm@60297
|
228 |
\<^rule_thm>\<open>separate_bdv_n\<close>,
|
wenzelm@60297
|
229 |
\<^rule_thm>\<open>separate_1_bdv\<close>,
|
neuper@37954
|
230 |
(*"?bdv / ?b = (1 / ?b) * ?bdv"*)
|
wenzelm@60297
|
231 |
\<^rule_thm>\<open>separate_1_bdv_n\<close>(*,
|
walther@60260
|
232 |
(*"?bdv \<up> ?n / ?b = 1 / ?b * ?bdv \<up> ?n"*)
|
wenzelm@60298
|
233 |
*****\<^rule_thm>\<open>add_divide_distrib\<close>
|
neuper@37954
|
234 |
(*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"*)----------*)
|
neuper@37954
|
235 |
];
|
neuper@37954
|
236 |
val simplify_Integral =
|
walther@59878
|
237 |
Rule_Set.Sequence {id = "simplify_Integral", preconds = []:term list,
|
walther@59857
|
238 |
rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
|
walther@59851
|
239 |
erls = Atools_erls, srls = Rule_Set.Empty,
|
neuper@42451
|
240 |
calc = [], errpatts = [],
|
wenzelm@60297
|
241 |
rules = [\<^rule_thm>\<open>distrib_right\<close>,
|
neuper@37954
|
242 |
(*"(?z1.0 + ?z2.0) * ?w = ?z1.0 * ?w + ?z2.0 * ?w"*)
|
wenzelm@60297
|
243 |
\<^rule_thm>\<open>add_divide_distrib\<close>,
|
neuper@37954
|
244 |
(*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"*)
|
neuper@37954
|
245 |
(*^^^^^ *1* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*)
|
wneuper@59416
|
246 |
Rule.Rls_ norm_Rational_noadd_fractions,
|
wneuper@59416
|
247 |
Rule.Rls_ order_add_mult_in,
|
wneuper@59416
|
248 |
Rule.Rls_ discard_parentheses,
|
wneuper@59416
|
249 |
(*Rule.Rls_ collect_bdv, from make_polynomial_in*)
|
wneuper@59416
|
250 |
Rule.Rls_ separate_bdv2,
|
wenzelm@60294
|
251 |
\<^rule_eval>\<open>divide\<close> (Prog_Expr.eval_cancel "#divide_e")
|
neuper@37954
|
252 |
],
|
walther@59878
|
253 |
scr = Rule.Empty_Prog};
|
neuper@37954
|
254 |
|
neuper@37954
|
255 |
|
neuper@37954
|
256 |
(*simplify terms before and after Integration such that
|
neuper@37954
|
257 |
..a.x^2/2 + b.x^3/3.. is made to ..a/2.x^2 + b/3.x^3.. (and NO
|
neuper@37954
|
258 |
common denominator as done by norm_Rational or make_ratpoly_in.
|
neuper@37954
|
259 |
This is a copy from 'make_polynomial_in' with insertions from
|
neuper@37954
|
260 |
'make_ratpoly_in'
|
neuper@37954
|
261 |
THIS IS KEPT FOR COMPARISON ............................................
|
s1210629013@55444
|
262 |
* val simplify_Integral = prep_rls'(
|
walther@59878
|
263 |
* Rule_Set.Sequence {id = "", preconds = []:term list,
|
walther@59857
|
264 |
* rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
|
walther@59851
|
265 |
* erls = Atools_erls, srls = Rule_Set.Empty,
|
neuper@37954
|
266 |
* calc = [], (*asm_thm = [],*)
|
wneuper@59416
|
267 |
* rules = [Rule.Rls_ expand_poly,
|
wneuper@59416
|
268 |
* Rule.Rls_ order_add_mult_in,
|
wneuper@59416
|
269 |
* Rule.Rls_ simplify_power,
|
wneuper@59416
|
270 |
* Rule.Rls_ collect_numerals,
|
wneuper@59416
|
271 |
* Rule.Rls_ reduce_012,
|
wenzelm@60297
|
272 |
* \<^rule_thm>\<open>realpow_oneI\<close>,
|
wneuper@59416
|
273 |
* Rule.Rls_ discard_parentheses,
|
wneuper@59416
|
274 |
* Rule.Rls_ collect_bdv,
|
neuper@37954
|
275 |
* (*below inserted from 'make_ratpoly_in'*)
|
walther@59852
|
276 |
* Rule.Rls_ (Rule_Set.append_rules "separate_bdv"
|
neuper@37954
|
277 |
* collect_bdv
|
wenzelm@60297
|
278 |
* [\<^rule_thm>\<open>separate_bdv\<close>,
|
neuper@37954
|
279 |
* (*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
|
wenzelm@60297
|
280 |
* \<^rule_thm>\<open>separate_bdv_n\<close>,
|
wenzelm@60297
|
281 |
* \<^rule_thm>\<open>separate_1_bdv\<close>,
|
neuper@37954
|
282 |
* (*"?bdv / ?b = (1 / ?b) * ?bdv"*)
|
wenzelm@60297
|
283 |
* \<^rule_thm>\<open>separate_1_bdv_n\<close>(*,
|
walther@60260
|
284 |
* (*"?bdv \<up> ?n / ?b = 1 / ?b * ?bdv \<up> ?n"*)
|
wenzelm@60298
|
285 |
* \<^rule_thm>\<open>add_divide_distrib\<close>
|
neuper@37954
|
286 |
* (*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"*)*)
|
neuper@37954
|
287 |
* ]),
|
wenzelm@60294
|
288 |
* \<^rule_eval>\<open>divide\<close> (eval_cancel "#divide_e")
|
neuper@37954
|
289 |
* ],
|
walther@59878
|
290 |
* scr = Rule.Empty_Prog
|
wneuper@59406
|
291 |
* });
|
neuper@37954
|
292 |
.......................................................................*)
|
neuper@37954
|
293 |
|
neuper@37954
|
294 |
val integration =
|
walther@59878
|
295 |
Rule_Set.Sequence {id="integration", preconds = [],
|
neuper@37954
|
296 |
rew_ord = ("termlessI",termlessI),
|
walther@59851
|
297 |
erls = Rule_Def.Repeat {id="conditions_in_integration",
|
neuper@37954
|
298 |
preconds = [],
|
neuper@37954
|
299 |
rew_ord = ("termlessI",termlessI),
|
walther@59851
|
300 |
erls = Rule_Set.Empty,
|
walther@59851
|
301 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
neuper@37954
|
302 |
rules = [],
|
walther@59878
|
303 |
scr = Rule.Empty_Prog},
|
walther@59851
|
304 |
srls = Rule_Set.Empty, calc = [], errpatts = [],
|
wneuper@59416
|
305 |
rules = [ Rule.Rls_ integration_rules,
|
wneuper@59416
|
306 |
Rule.Rls_ add_new_c,
|
wneuper@59416
|
307 |
Rule.Rls_ simplify_Integral
|
neuper@37954
|
308 |
],
|
walther@59878
|
309 |
scr = Rule.Empty_Prog};
|
s1210629013@55444
|
310 |
|
walther@59618
|
311 |
val prep_rls' = Auto_Prog.prep_rls @{theory};
|
wneuper@59472
|
312 |
\<close>
|
wenzelm@60289
|
313 |
rule_set_knowledge
|
wenzelm@60286
|
314 |
integration_rules = \<open>prep_rls' integration_rules\<close> and
|
wenzelm@60286
|
315 |
add_new_c = \<open>prep_rls' add_new_c\<close> and
|
wenzelm@60286
|
316 |
simplify_Integral = \<open>prep_rls' simplify_Integral\<close> and
|
wenzelm@60286
|
317 |
integration = \<open>prep_rls' integration\<close> and
|
wenzelm@60286
|
318 |
separate_bdv2 = \<open>prep_rls' separate_bdv2\<close> and
|
wenzelm@60286
|
319 |
norm_Rational_noadd_fractions = \<open>prep_rls' norm_Rational_noadd_fractions\<close> and
|
wenzelm@60286
|
320 |
norm_Rational_rls_noadd_fractions = \<open>prep_rls' norm_Rational_rls_noadd_fractions\<close>
|
neuper@37954
|
321 |
|
neuper@37954
|
322 |
(** problems **)
|
wenzelm@60306
|
323 |
|
wenzelm@60306
|
324 |
problem pbl_fun_integ : "integrate/function" =
|
wenzelm@60306
|
325 |
\<open>Rule_Set.append_rules "empty" Rule_Set.empty [(*for preds in where_*)]\<close>
|
wenzelm@60306
|
326 |
Method: "diff/integration"
|
wenzelm@60306
|
327 |
CAS: "Integrate (f_f, v_v)"
|
wenzelm@60306
|
328 |
Given: "functionTerm f_f" "integrateBy v_v"
|
wenzelm@60306
|
329 |
Find: "antiDerivative F_F"
|
wenzelm@60306
|
330 |
|
wenzelm@60306
|
331 |
problem pbl_fun_integ_nam : "named/integrate/function" =
|
wenzelm@60306
|
332 |
(*here "named" is used differently from Differentiation"*)
|
wenzelm@60306
|
333 |
\<open>Rule_Set.append_rules "empty" Rule_Set.empty [(*for preds in where_*)]\<close>
|
wenzelm@60306
|
334 |
Method: "diff/integration/named"
|
wenzelm@60306
|
335 |
CAS: "Integrate (f_f, v_v)"
|
wenzelm@60306
|
336 |
Given: "functionTerm f_f" "integrateBy v_v"
|
wenzelm@60306
|
337 |
Find: "antiDerivativeName F_F"
|
s1210629013@55380
|
338 |
|
neuper@37954
|
339 |
(** methods **)
|
wneuper@59545
|
340 |
|
wneuper@59504
|
341 |
partial_function (tailrec) integrate :: "real \<Rightarrow> real \<Rightarrow> real"
|
wneuper@59504
|
342 |
where
|
walther@59635
|
343 |
"integrate f_f v_v = (
|
walther@59635
|
344 |
let
|
walther@59635
|
345 |
t_t = Take (Integral f_f D v_v)
|
walther@59635
|
346 |
in
|
walther@59635
|
347 |
(Rewrite_Set_Inst [(''bdv'', v_v)] ''integration'') t_t)"
|
wenzelm@60303
|
348 |
|
wenzelm@60303
|
349 |
method met_diffint : "diff/integration" =
|
wenzelm@60303
|
350 |
\<open>{rew_ord'="tless_true", rls'=Atools_erls, calc = [], srls = Rule_Set.empty, prls=Rule_Set.empty,
|
wenzelm@60303
|
351 |
crls = Atools_erls, errpats = [], nrls = Rule_Set.empty}\<close>
|
wenzelm@60303
|
352 |
Program: integrate.simps
|
wenzelm@60303
|
353 |
Given: "functionTerm f_f" "integrateBy v_v"
|
wenzelm@60303
|
354 |
Find: "antiDerivative F_F"
|
wneuper@59545
|
355 |
|
wneuper@59504
|
356 |
partial_function (tailrec) intergrate_named :: "real \<Rightarrow> real \<Rightarrow> (real \<Rightarrow> real) \<Rightarrow> bool"
|
walther@59635
|
357 |
where
|
walther@59635
|
358 |
"intergrate_named f_f v_v F_F =(
|
walther@59635
|
359 |
let
|
walther@59635
|
360 |
t_t = Take (F_F v_v = Integral f_f D v_v)
|
walther@59635
|
361 |
in (
|
walther@59637
|
362 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''simplify_Integral'')) #>
|
walther@59635
|
363 |
(Rewrite_Set_Inst [(''bdv'', v_v)] ''integration'')
|
walther@59635
|
364 |
) t_t)"
|
wenzelm@60303
|
365 |
|
wenzelm@60303
|
366 |
method met_diffint_named : "diff/integration/named" =
|
wenzelm@60303
|
367 |
\<open>{rew_ord'="tless_true", rls'=Atools_erls, calc = [], srls = Rule_Set.empty, prls=Rule_Set.empty,
|
wenzelm@60303
|
368 |
crls = Atools_erls, errpats = [], nrls = Rule_Set.empty}\<close>
|
wenzelm@60303
|
369 |
Program: intergrate_named.simps
|
wenzelm@60303
|
370 |
Given: "functionTerm f_f" "integrateBy v_v"
|
wenzelm@60303
|
371 |
Find: "antiDerivativeName F_F"
|
wenzelm@60303
|
372 |
|
wenzelm@60303
|
373 |
ML \<open>
|
walther@60278
|
374 |
\<close> ML \<open>
|
wneuper@59472
|
375 |
\<close>
|
neuper@37954
|
376 |
|
neuper@37906
|
377 |
end |