1 theory Partial_Fractions imports Rational begin
3 subsection {*get the denominator out of a fraction*}
4 text {*this function can be put into rule sets*}
6 (*("get_denominator", ("Rational.get'_denominator", eval_get_denominator ""))*)
7 fun eval_get_denominator (thmid:string) _
8 (t as (Const("Rings.inverse_class.divide", _) $ num $ denom)) thy =
9 SOME (mk_thmid thmid ""
10 (Print_Mode.setmp [] (Syntax.string_of_term (thy2ctxt thy)) denom) "",
11 Trueprop $ (mk_equality (t, denom)))
12 | eval_get_denominator _ _ _ _ = NONE;
17 subsection {*get the argument out of a fraction*}
20 (*("get_argument", ("Rational.get'_argument", eval_get_argument ""))*)
23 fun eval_get_argument "Atools.argument'_in"
24 (t as (Const ("Atools.argument'_in", _) $ (f $ arg))) _ =
25 if is_Free arg (*could be something to be simplified before*)
26 then SOME (term2str t ^ " = " ^ term2str arg,
27 Trueprop $ (mk_equality (t, arg)))
29 | eval_argument_in _ _ _ _ = NONE;
34 subsection{*rule set for partial fractions*}
36 val partial_fraction =
37 Rls {id="partial_fraction", preconds = [], rew_ord = ("termlessI",termlessI),
38 erls = Erls, srls = Erls, calc = [],
40 Calc ("Rings.inverse_class.divide", eval_get_denominator "#", eval_get_argument "X")
45 subsection{*store the rule set for math engine*}
47 overwritelthy @{theory} (!ruleset',
48 [("partial_fraction", prep_rls partial_fraction)