neuper@42289
|
1 |
theory Partial_Fractions imports Rational begin
|
neuper@42289
|
2 |
|
neuper@42289
|
3 |
subsection {*get the denominator out of a fraction*}
|
neuper@42289
|
4 |
text {*this function can be put into rule sets*}
|
neuper@42289
|
5 |
ML {*
|
neuper@42289
|
6 |
(*("get_denominator", ("Rational.get'_denominator", eval_get_denominator ""))*)
|
neuper@42289
|
7 |
fun eval_get_denominator (thmid:string) _
|
neuper@42289
|
8 |
(t as (Const("Rings.inverse_class.divide", _) $ num $ denom)) thy =
|
neuper@42289
|
9 |
SOME (mk_thmid thmid ""
|
neuper@42289
|
10 |
(Print_Mode.setmp [] (Syntax.string_of_term (thy2ctxt thy)) denom) "",
|
neuper@42289
|
11 |
Trueprop $ (mk_equality (t, denom)))
|
neuper@42289
|
12 |
| eval_get_denominator _ _ _ _ = NONE;
|
neuper@42289
|
13 |
*}
|
jan@42291
|
14 |
|
jan@42291
|
15 |
|
jan@42291
|
16 |
|
jan@42291
|
17 |
subsection {*get the argument out of a fraction*}
|
jan@42291
|
18 |
|
jan@42291
|
19 |
ML {*
|
jan@42291
|
20 |
(*("get_argument", ("Rational.get'_argument", eval_get_argument ""))*)
|
jan@42291
|
21 |
|
jan@42291
|
22 |
(*
|
jan@42291
|
23 |
fun eval_get_argument "Atools.argument'_in"
|
jan@42291
|
24 |
(t as (Const ("Atools.argument'_in", _) $ (f $ arg))) _ =
|
jan@42291
|
25 |
if is_Free arg (*could be something to be simplified before*)
|
jan@42291
|
26 |
then SOME (term2str t ^ " = " ^ term2str arg,
|
jan@42291
|
27 |
Trueprop $ (mk_equality (t, arg)))
|
jan@42291
|
28 |
else NONE
|
jan@42291
|
29 |
| eval_argument_in _ _ _ _ = NONE;
|
jan@42291
|
30 |
*)
|
jan@42291
|
31 |
|
jan@42291
|
32 |
*}
|
jan@42291
|
33 |
|
jan@42291
|
34 |
subsection{*rule set for partial fractions*}
|
neuper@42289
|
35 |
ML {*
|
neuper@42289
|
36 |
val partial_fraction =
|
neuper@42289
|
37 |
Rls {id="partial_fraction", preconds = [], rew_ord = ("termlessI",termlessI),
|
neuper@42289
|
38 |
erls = Erls, srls = Erls, calc = [],
|
neuper@42289
|
39 |
rules = [
|
jan@42291
|
40 |
Calc ("Rings.inverse_class.divide", eval_get_denominator "#", eval_get_argument "X")
|
neuper@42289
|
41 |
],
|
neuper@42289
|
42 |
scr = EmptyScr};
|
neuper@42289
|
43 |
*}
|
jan@42291
|
44 |
|
jan@42291
|
45 |
subsection{*store the rule set for math engine*}
|
neuper@42289
|
46 |
ML {*
|
neuper@42289
|
47 |
overwritelthy @{theory} (!ruleset',
|
neuper@42289
|
48 |
[("partial_fraction", prep_rls partial_fraction)
|
neuper@42289
|
49 |
]);
|
neuper@42289
|
50 |
*}
|
neuper@42289
|
51 |
|
neuper@42289
|
52 |
end |