src/Tools/isac/Knowledge/Partial_Fractions.thy
author Walther Neuper <wneuper@ist.tugraz.at>
Thu, 07 Mar 2019 17:22:20 +0100
changeset 59512 e504168e7b01
parent 59505 a1f223658994
child 59513 deb1efba3119
permissions -rw-r--r--
[-Test_Isac] funpack: Const ("Partial_Fractions.AA",..) makes trick superfluous
neuper@42376
     1
(* Partial_Fractions 
jan@42344
     2
   author: Jan Rocnik, isac team
jan@42344
     3
   Copyright (c) isac team 2011
jan@42344
     4
   Use is subject to license terms.
jan@42344
     5
*)
wneuper@59344
     6
(* Partial Fraction Decomposition *)
jan@42344
     7
neuper@42289
     8
neuper@42376
     9
theory Partial_Fractions imports RootRatEq begin
jan@42353
    10
wneuper@59472
    11
ML\<open>
neuper@42376
    12
(*
jan@42353
    13
signature PARTFRAC =
jan@42353
    14
sig
jan@42353
    15
  val ansatz_rls : rls
jan@42353
    16
  val ansatz_rls_ : theory -> term -> (term * term list) option
jan@42353
    17
end
neuper@42376
    18
*)
wneuper@59472
    19
\<close>
jan@42353
    20
wneuper@59472
    21
subsection \<open>eval_ functions\<close>
jan@42344
    22
consts
neuper@42359
    23
  factors_from_solution :: "bool list => real"
wneuper@59512
    24
  AA                    :: real
wneuper@59512
    25
  BB                    :: real
jan@42344
    26
wneuper@59472
    27
text \<open>these might be used for variants of fac_from_sol\<close>
wneuper@59472
    28
ML \<open>
jan@42344
    29
fun mk_minus_1 T = Free("-1", T); (*TODO DELETE WITH numbers_to_string*)
jan@42344
    30
fun flip_sign t = (*TODO improve for use in factors_from_solution: -(-1) etc*)
jan@42344
    31
  let val minus_1 = t |> type_of |> mk_minus_1
jan@42344
    32
  in HOLogic.mk_binop "Groups.times_class.times" (minus_1, t) end;
wneuper@59472
    33
\<close>
neuper@42376
    34
wneuper@59472
    35
text \<open>from solutions (e.g. [z = 1, z = -2]) make linear factors (e.g. (z - 1)*(z - -2))\<close>
wneuper@59472
    36
ML \<open>
jan@42344
    37
fun fac_from_sol s =
jan@42344
    38
  let val (lhs, rhs) = HOLogic.dest_eq s
jan@42367
    39
  in HOLogic.mk_binop "Groups.minus_class.minus" (lhs, rhs) end;
jan@42344
    40
jan@42344
    41
fun mk_prod prod [] =
wneuper@59416
    42
      if prod = Rule.e_term then error "mk_prod called with []" else prod
jan@42344
    43
  | mk_prod prod (t :: []) =
wneuper@59416
    44
      if prod = Rule.e_term then t else HOLogic.mk_binop "Groups.times_class.times" (prod, t)
jan@42344
    45
  | mk_prod prod (t1 :: t2 :: ts) =
wneuper@59416
    46
        if prod = Rule.e_term 
jan@42344
    47
        then 
jan@42344
    48
           let val p = HOLogic.mk_binop "Groups.times_class.times" (t1, t2)
jan@42344
    49
           in mk_prod p ts end 
jan@42344
    50
        else 
jan@42344
    51
           let val p = HOLogic.mk_binop "Groups.times_class.times" (prod, t1)
jan@42344
    52
           in mk_prod p (t2 :: ts) end 
jan@42344
    53
jan@42344
    54
fun factors_from_solution sol = 
jan@42344
    55
  let val ts = HOLogic.dest_list sol
wneuper@59416
    56
  in mk_prod Rule.e_term (map fac_from_sol ts) end;
jan@42344
    57
neuper@42376
    58
(*("factors_from_solution", ("Partial_Fractions.factors_from_solution", 
neuper@42376
    59
     eval_factors_from_solution ""))*)
jan@42352
    60
fun eval_factors_from_solution (thmid:string) _
jan@42352
    61
     (t as Const ("Partial_Fractions.factors_from_solution", _) $ sol) thy =
jan@42352
    62
       ((let val prod = factors_from_solution sol
wneuper@59416
    63
         in SOME (TermC.mk_thmid thmid (Rule.term_to_string''' thy prod) "",
wneuper@59390
    64
              HOLogic.Trueprop $ (TermC.mk_equality (t, prod)))
jan@42352
    65
         end)
jan@42352
    66
       handle _ => NONE)
jan@42352
    67
 | eval_factors_from_solution _ _ _ _ = NONE;
wneuper@59472
    68
\<close>
jan@42344
    69
wneuper@59472
    70
subsection \<open>'ansatz' for partial fractions\<close>
jan@42353
    71
axiomatization where
wneuper@59512
    72
  ansatz_2nd_order: "n / (a*b) = AA/a + BB/b" and
wneuper@59512
    73
  ansatz_3rd_order: "n / (a*b*c) = AA/a + BB/b + C/c" and
wneuper@59512
    74
  ansatz_4th_order: "n / (a*b*c*d) = AA/a + BB/b + C/c + D/d" and
neuper@42386
    75
  (*version 1*)
wneuper@59512
    76
  equival_trans_2nd_order: "(n/(a*b) = AA/a + BB/b) = (n = AA*b + BB*a)" and
wneuper@59512
    77
  equival_trans_3rd_order: "(n/(a*b*c) = AA/a + BB/b + C/c) = (n = AA*b*c + BB*a*c + C*a*b)" and
wneuper@59512
    78
  equival_trans_4th_order: "(n/(a*b*c*d) = AA/a + BB/b + C/c + D/d) = 
wneuper@59512
    79
    (n = AA*b*c*d + BB*a*c*d + C*a*b*d + D*a*b*c)" and
neuper@42386
    80
  (*version 2: not yet used, see partial_fractions.sml*)
wneuper@59512
    81
  multiply_2nd_order: "(n/x = AA/a + BB/b) = (a*b*n/x = AA*b + BB*a)" and
wneuper@59512
    82
  multiply_3rd_order: "(n/x = AA/a + BB/b + C/c) = (a*b*c*n/x = AA*b*c + BB*a*c + C*a*b)" and
neuper@42387
    83
  multiply_4th_order: 
wneuper@59512
    84
    "(n/x = AA/a + BB/b + C/c + D/d) = (a*b*c*d*n/x = AA*b*c*d + BB*a*c*d + C*a*b*d + D*a*b*c)"
neuper@42387
    85
wneuper@59472
    86
text \<open>Probably the optimal formalization woudl be ...
neuper@42387
    87
wneuper@59512
    88
  multiply_2nd_order: "x = a*b ==> (n/x = AA/a + BB/b) = (a*b*n/x = AA*b + BB*a)" and
neuper@42386
    89
  multiply_3rd_order: "x = a*b*c ==>
wneuper@59512
    90
    (n/x = AA/a + BB/b + C/c) = (a*b*c*n/x = AA*b*c + BB*a*c + C*a*b)" and
neuper@42386
    91
  multiply_4th_order: "x = a*b*c*d ==>
wneuper@59512
    92
    (n/x = AA/a + BB/b + C/c + D/d) = (a*b*c*d*n/x = AA*b*c*d + BB*a*c*d + C*a*b*d + D*a*b*c)"
jan@42353
    93
neuper@42387
    94
... because it would allow to start the ansatz as follows
neuper@42387
    95
(1) 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))) = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))
neuper@42387
    96
(2) 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))) = AA / (z - 1 / 2) + BB / (z - -1 / 4)
neuper@42387
    97
(3) (z - 1 / 2) * (z - -1 / 4) * 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))) = 
neuper@42387
    98
    (z - 1 / 2) * (z - -1 / 4) * AA / (z - 1 / 2) + BB / (z - -1 / 4)
wneuper@59512
    99
(4) 3 = AA * (z - -1 / 4) + BB * (z - 1 / 2)
neuper@42387
   100
neuper@42387
   101
... (1==>2) ansatz
neuper@42387
   102
    (2==>3) multiply_*
neuper@42387
   103
    (3==>4) norm_Rational
neuper@42387
   104
TODOs for this version ar in partial_fractions.sml "--- progr.vers.2: "
wneuper@59472
   105
\<close>
neuper@42387
   106
wneuper@59472
   107
ML \<open>
s1210629013@55444
   108
val ansatz_rls = prep_rls'(
wneuper@59416
   109
  Rule.Rls {id = "ansatz_rls", preconds = [], rew_ord = ("dummy_ord",Rule.dummy_ord), 
wneuper@59416
   110
	  erls = Rule.Erls, srls = Rule.Erls, calc = [], errpatts = [],
jan@42353
   111
	  rules = 
wneuper@59416
   112
	   [Rule.Thm ("ansatz_2nd_order",TermC.num_str @{thm ansatz_2nd_order}),
wneuper@59416
   113
	    Rule.Thm ("ansatz_3rd_order",TermC.num_str @{thm ansatz_3rd_order})
jan@42353
   114
	   ], 
wneuper@59416
   115
	 scr = Rule.EmptyScr});
jan@42353
   116
s1210629013@55444
   117
val equival_trans = prep_rls'(
wneuper@59416
   118
  Rule.Rls {id = "equival_trans", preconds = [], rew_ord = ("dummy_ord",Rule.dummy_ord), 
wneuper@59416
   119
	  erls = Rule.Erls, srls = Rule.Erls, calc = [], errpatts = [],
jan@42354
   120
	  rules = 
wneuper@59416
   121
	   [Rule.Thm ("equival_trans_2nd_order",TermC.num_str @{thm equival_trans_2nd_order}),
wneuper@59416
   122
	    Rule.Thm ("equival_trans_3rd_order",TermC.num_str @{thm equival_trans_3rd_order})
jan@42354
   123
	   ], 
wneuper@59416
   124
	 scr = Rule.EmptyScr});
neuper@42386
   125
s1210629013@55444
   126
val multiply_ansatz = prep_rls'(
wneuper@59416
   127
  Rule.Rls {id = "multiply_ansatz", preconds = [], rew_ord = ("dummy_ord",Rule.dummy_ord), 
wneuper@59416
   128
	  erls = Rule.Erls,
wneuper@59416
   129
	  srls = Rule.Erls, calc = [], errpatts = [],
neuper@42386
   130
	  rules = 
wneuper@59416
   131
	   [Rule.Thm ("multiply_2nd_order",TermC.num_str @{thm multiply_2nd_order})
neuper@42386
   132
	   ], 
wneuper@59416
   133
	 scr = Rule.EmptyScr});
wneuper@59472
   134
\<close>
jan@42354
   135
wneuper@59472
   136
text \<open>store the rule set for math engine\<close>
wneuper@59472
   137
setup \<open>KEStore_Elems.add_rlss 
neuper@52125
   138
  [("ansatz_rls", (Context.theory_name @{theory}, ansatz_rls)), 
neuper@52125
   139
  ("multiply_ansatz", (Context.theory_name @{theory}, multiply_ansatz)), 
wneuper@59472
   140
  ("equival_trans", (Context.theory_name @{theory}, equival_trans))]\<close>
jan@42344
   141
wneuper@59472
   142
subsection \<open>Specification\<close>
jan@42344
   143
neuper@42376
   144
consts
neuper@42376
   145
  decomposedFunction :: "real => una"
neuper@42376
   146
wneuper@59472
   147
ML \<open>
wneuper@59406
   148
Celem.check_guhs_unique := false; (*WN120307 REMOVE after editing*)
wneuper@59472
   149
\<close>
wneuper@59472
   150
setup \<open>KEStore_Elems.add_pbts
wneuper@59406
   151
  [(Specify.prep_pbt @{theory} "pbl_simp_rat_partfrac" [] Celem.e_pblID
s1210629013@55339
   152
      (["partial_fraction", "rational", "simplification"],
s1210629013@55339
   153
        [("#Given" ,["functionTerm t_t", "solveFor v_v"]),
s1210629013@55339
   154
          (* TODO: call this sub-problem with appropriate functionTerm: 
s1210629013@55339
   155
            leading coefficient of the denominator is 1: to be checked here! and..
s1210629013@55339
   156
            ("#Where" ,["((get_numerator t_t) has_degree_in v_v) < 
s1210629013@55339
   157
               ((get_denominator t_t) has_degree_in v_v)"]), TODO*)
s1210629013@55339
   158
          ("#Find"  ,["decomposedFunction p_p'''"])],
wneuper@59416
   159
        Rule.append_rls "e_rls" Rule.e_rls [(*for preds in where_ TODO*)], 
s1210629013@55339
   160
        NONE, 
wneuper@59472
   161
        [["simplification","of_rationals","to_partial_fraction"]]))]\<close>
jan@42354
   162
wneuper@59472
   163
subsection \<open>Method\<close>
neuper@42376
   164
consts
neuper@42376
   165
  PartFracScript  :: "[real,real,  real] => real" 
neuper@42376
   166
    ("((Script PartFracScript (_ _ =))// (_))" 9)
jan@42353
   167
wneuper@59472
   168
text \<open>rule set for functions called in the Script\<close>
wneuper@59472
   169
ML \<open>
wneuper@59416
   170
  val srls_partial_fraction = Rule.Rls {id="srls_partial_fraction", 
neuper@42376
   171
    preconds = [],
neuper@42376
   172
    rew_ord = ("termlessI",termlessI),
wneuper@59416
   173
    erls = Rule.append_rls "erls_in_srls_partial_fraction" Rule.e_rls
neuper@42376
   174
      [(*for asm in NTH_CONS ...*)
wneuper@59416
   175
       Rule.Calc ("Orderings.ord_class.less",eval_equ "#less_"),
neuper@42376
   176
       (*2nd NTH_CONS pushes n+-1 into asms*)
wneuper@59416
   177
       Rule.Calc("Groups.plus_class.plus", eval_binop "#add_")], 
wneuper@59416
   178
    srls = Rule.Erls, calc = [], errpatts = [],
neuper@42376
   179
    rules = [
wneuper@59416
   180
       Rule.Thm ("NTH_CONS",TermC.num_str @{thm NTH_CONS}),
wneuper@59416
   181
       Rule.Calc("Groups.plus_class.plus", eval_binop "#add_"),
wneuper@59416
   182
       Rule.Thm ("NTH_NIL",TermC.num_str @{thm NTH_NIL}),
wneuper@59491
   183
       Rule.Calc("Tools.lhs", Tools.eval_lhs "eval_lhs_"),
wneuper@59491
   184
       Rule.Calc("Tools.rhs", Tools.eval_rhs"eval_rhs_"),
wneuper@59416
   185
       Rule.Calc("Atools.argument'_in", eval_argument_in "Atools.argument'_in"),
wneuper@59416
   186
       Rule.Calc("Rational.get_denominator", eval_get_denominator "#get_denominator"),
wneuper@59416
   187
       Rule.Calc("Rational.get_numerator", eval_get_numerator "#get_numerator"),
wneuper@59416
   188
       Rule.Calc("Partial_Fractions.factors_from_solution",
wneuper@59512
   189
         eval_factors_from_solution "#factors_from_solution")
wneuper@59512
   190
       ],
wneuper@59416
   191
    scr = Rule.EmptyScr};
wneuper@59472
   192
\<close>
neuper@42415
   193
s1210629013@55380
   194
(* current version, error outcommented *)
wneuper@59505
   195
(*ok
wneuper@59504
   196
partial_function (tailrec) partial_fraction :: "real \<Rightarrow> real \<Rightarrow> real"
wneuper@59504
   197
  where
wneuper@59504
   198
"partial_fraction f_f zzz =              \<comment> \<open>([1], Frm), 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))\<close>
wneuper@59504
   199
(let f_f = Take f_f;                                                             \<comment> \<open>num_orig = 3\<close>
wneuper@59504
   200
  num_orig = get_numerator f_f;                  \<comment> \<open>([1], Res), 24 / (-1 + -2 * z + 8 * z ^^^ 2)\<close>
wneuper@59504
   201
  f_f = (Rewrite_Set ''norm_Rational'' False) f_f;          \<comment> \<open>denom = -1 + -2 * z + 8 * z ^^^ 2\<close>
wneuper@59504
   202
  denom = get_denominator f_f;                            \<comment> \<open>equ = -1 + -2 * z + 8 * z ^^^ 2 = 0\<close>
wneuper@59504
   203
  equ = denom = (0::real);
wneuper@59504
   204
  \<comment> \<open>-----                                  ([2], Pbl), solve (-1 + -2 * z + 8 * z ^^^ 2 = 0, z)\<close>
wneuper@59504
   205
  L_L = SubProblem (''PolyEq'',                            \<comment> \<open>([2], Res), [z = 1 / 2, z = -1 / 4\<close>
wneuper@59504
   206
    [''abcFormula'', ''degree_2'', ''polynomial'', ''univariate'', ''equation''],
wneuper@59504
   207
    [''no_met'']) [BOOL equ, REAL zzz];                      \<comment> \<open>facs: (z - 1 / 2) * (z - -1 / 4)\<close>
wneuper@59504
   208
  facs = factors_from_solution L_L;             \<comment> \<open>([3], Frm), 33 / ((z - 1 / 2) * (z - -1 / 4))\<close>
wneuper@59504
   209
  eql = Take (num_orig / facs);              \<comment> \<open>([3], Res), ?A / (z - 1 / 2) + ?B / (z - -1 / 4)\<close>
wneuper@59504
   210
  eqr = (Try (Rewrite_Set ''ansatz_rls'' False)) eql;
wneuper@59504
   211
          \<comment> \<open>([4], Frm), 3 / ((z - 1 / 2) * (z - -1 / 4)) = ?A / (z - 1 / 2) + ?B / (z - -1 / 4)\<close>
wneuper@59504
   212
  eq = Take (eql = eqr);                  \<comment> \<open>([4], Res), 3 = ?A * (z - -1 / 4) + ?B * (z - 1 / 2)\<close>
wneuper@59504
   213
  eq = (Try (Rewrite_Set ''equival_trans'' False)) eq; 
wneuper@59512
   214
                                                 \<comment> \<open>eq = 3 = AA * (z - -1 / 4) + BB * (z - 1 / 2)\<close>
wneuper@59504
   215
  z1 = rhs (NTH 1 L_L);                                                           \<comment> \<open>z2 = -1 / 4\<close>
wneuper@59512
   216
  z2 = rhs (NTH 2 L_L);                   \<comment> \<open>([5], Frm), 3 = AA * (z - -1 / 4) + BB * (z - 1 / 2)\<close>
wneuper@59512
   217
  eq_a = Take eq;                 \<comment> \<open>([5], Res), 3 = AA * (1 / 2 - -1 / 4) + BB * (1 / 2 - 1 / 2)\<close>
wneuper@59512
   218
  eq_a = Substitute [zzz = z1] eq;                                \<comment> \<open>([6], Res), 3 = 3 * AA / 4\<close>
wneuper@59504
   219
  eq_a = (Rewrite_Set ''norm_Rational'' False) eq_a;
wneuper@59512
   220
\<comment> \<open>-----                                                    ([7], Pbl), solve (3 = 3 * AA / 4, AA)\<close>
wneuper@59512
   221
                                                                          \<comment> \<open>([7], Res), [AA = 4]\<close>
wneuper@59504
   222
  sol_a = SubProblem (''Isac'', [''univariate'',''equation''], [''no_met''])
wneuper@59512
   223
      [BOOL eq_a, REAL (AA::real)] ;                                                     \<comment> \<open>a = 4\<close>
wneuper@59512
   224
  a = rhs (NTH 1 sol_a);                   \<comment> \<open>([8], Frm), 3 = AA * (z - -1 / 4) + BB * (z - 1 / 2)\<close>
wneuper@59512
   225
  eq_b = Take eq;                \<comment> \<open>([8], Res), 3 = AA * (-1 / 4 - -1 / 4) + BB * (-1 / 4 - 1 / 2)\<close>
wneuper@59512
   226
  eq_b = Substitute [zzz = z2] eq_b;                               \<comment> \<open>([9], Res), 3 = -3 * BB / 4\<close>
wneuper@59512
   227
  eq_b = (Rewrite_Set ''norm_Rational'' False) eq_b;   \<comment> \<open>([10], Pbl), solve (3 = -3 * BB / 4, BB)\<close>
wneuper@59512
   228
  sol_b = SubProblem (''Isac'',                                         \<comment> \<open>([10], Res), [BB = -4]\<close>
wneuper@59504
   229
      [''univariate'',''equation''], [''no_met''])
wneuper@59512
   230
    [BOOL eq_b, REAL (BB::real)];                                                       \<comment> \<open>b = -4\<close>
wneuper@59512
   231
  b = rhs (NTH 1 sol_b);                             \<comment> \<open>eqr = AA / (z - 1 / 2) + BB / (z - -1 / 4)\<close>
wneuper@59504
   232
  pbz = Take eqr;                            \<comment> \<open>([11], Res), 4 / (z - 1 / 2) + -4 / (z - -1 / 4)\<close>
wneuper@59512
   233
  pbz = Substitute [AA = a, BB = b] pbz        \<comment> \<open>([], Res), 4 / (z - 1 / 2) + -4 / (z - -1 / 4)\<close>
wneuper@59504
   234
in pbz)                                                                                "
wneuper@59505
   235
*)
wneuper@59472
   236
setup \<open>KEStore_Elems.add_mets
wneuper@59473
   237
    [Specify.prep_met @{theory} "met_partial_fraction" [] Celem.e_metID
s1210629013@55373
   238
      (["simplification","of_rationals","to_partial_fraction"], 
s1210629013@55373
   239
        [("#Given" ,["functionTerm t_t", "solveFor v_v"]),
s1210629013@55373
   240
          (*("#Where" ,["((get_numerator t_t) has_degree_in v_v) < 
s1210629013@55373
   241
            ((get_denominator t_t) has_degree_in v_v)"]), TODO*)
s1210629013@55373
   242
          ("#Find"  ,["decomposedFunction p_p'''"])],
s1210629013@55373
   243
        (*f_f = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)), zzz: z*)
wneuper@59416
   244
        {rew_ord'="tless_true", rls'= Rule.e_rls, calc = [], srls = srls_partial_fraction, prls = Rule.e_rls,
wneuper@59416
   245
          crls = Rule.e_rls, errpats = [], nrls = Rule.e_rls},
s1210629013@55373
   246
        (*([], Frm), Problem (Partial_Fractions, [partial_fraction, rational, simplification])*)
s1210629013@55373
   247
        "Script PartFracScript (f_f::real) (zzz::real) =   " ^
s1210629013@55373
   248
          (*([1], Frm), 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))*)
s1210629013@55373
   249
          "(let f_f = Take f_f;                              " ^
s1210629013@55373
   250
          (*           num_orig = 3*)
s1210629013@55373
   251
          "  (num_orig::real) = get_numerator f_f;           " ^
s1210629013@55373
   252
          (*([1], Res), 24 / (-1 + -2 * z + 8 * z ^^^ 2)*)
wneuper@59489
   253
          "  f_f = (Rewrite_Set ''norm_Rational'' False) f_f;    " ^
s1210629013@55373
   254
          (*           denom = -1 + -2 * z + 8 * z ^^^ 2*)
s1210629013@55373
   255
          "  (denom::real) = get_denominator f_f;            " ^
s1210629013@55373
   256
          (*           equ = -1 + -2 * z + 8 * z ^^^ 2 = 0*)
s1210629013@55373
   257
          "  (equ::bool) = (denom = (0::real));              " ^
s1210629013@55373
   258
s1210629013@55373
   259
          (*([2], Pbl), solve (-1 + -2 * z + 8 * z ^^^ 2 = 0, z)*)
wneuper@59489
   260
          "  (L_L::bool list) = (SubProblem (''PolyEq'',        " ^
wneuper@59489
   261
          "    [''abcFormula'', ''degree_2'', ''polynomial'', ''univariate'', ''equation''], " ^
s1210629013@55373
   262
          (*([2], Res), [z = 1 / 2, z = -1 / 4]*)
wneuper@59489
   263
          "    [''no_met'']) [BOOL equ, REAL zzz]);              " ^
s1210629013@55373
   264
          (*           facs: (z - 1 / 2) * (z - -1 / 4)*)
s1210629013@55373
   265
          "  (facs::real) = factors_from_solution L_L;       " ^
s1210629013@55373
   266
          (*([3], Frm), 33 / ((z - 1 / 2) * (z - -1 / 4)) *) 
s1210629013@55373
   267
          "  (eql::real) = Take (num_orig / facs);           " ^
s1210629013@55373
   268
          (*([3], Res), ?A / (z - 1 / 2) + ?B / (z - -1 / 4)*)
wneuper@59489
   269
          "  (eqr::real) = (Try (Rewrite_Set ''ansatz_rls'' False)) eql;  " ^
s1210629013@55373
   270
          (*([4], Frm), 3 / ((z - 1 / 2) * (z - -1 / 4)) = ?A / (z - 1 / 2) + ?B / (z - -1 / 4)*)
s1210629013@55373
   271
          "  (eq::bool) = Take (eql = eqr);                  " ^
s1210629013@55373
   272
          (*([4], Res), 3 = ?A * (z - -1 / 4) + ?B * (z - 1 / 2)*)
wneuper@59489
   273
          "  eq = (Try (Rewrite_Set ''equival_trans'' False)) eq;" ^
wneuper@59512
   274
          (*           eq = 3 = AA * (z - -1 / 4) + BB * (z - 1 / 2)*)
s1210629013@55373
   275
          (*           z1 = 1 / 2*)
s1210629013@55373
   276
          "  (z1::real) = (rhs (NTH 1 L_L));                 " ^
s1210629013@55373
   277
          (*           z2 = -1 / 4*)
s1210629013@55373
   278
          "  (z2::real) = (rhs (NTH 2 L_L));                 " ^
wneuper@59512
   279
          (*([5], Frm), 3 = AA * (z - -1 / 4) + BB * (z - 1 / 2)*)
s1210629013@55373
   280
          "  (eq_a::bool) = Take eq;                         " ^
wneuper@59512
   281
          (*([5], Res), 3 = AA * (1 / 2 - -1 / 4) + BB * (1 / 2 - 1 / 2)*)
s1210629013@55373
   282
          "  eq_a = (Substitute [zzz = z1]) eq;              " ^
wneuper@59512
   283
          (*([6], Res), 3 = 3 * AA / 4*)
wneuper@59489
   284
          "  eq_a = (Rewrite_Set ''norm_Rational'' False) eq_a;  " ^
s1210629013@55373
   285
wneuper@59512
   286
          (*([7], Pbl), solve (3 = 3 * AA / 4, AA)*)
s1210629013@55373
   287
          "  (sol_a::bool list) =                            " ^
wneuper@59489
   288
          "    (SubProblem (''Isac'', [''univariate'',''equation''], [''no_met''])   " ^
wneuper@59512
   289
          (*([7], Res), [AA = 4]*)
wneuper@59512
   290
          "    [BOOL eq_a, REAL (AA::real)]);                 " ^
s1210629013@55373
   291
          (*           a = 4*)
s1210629013@55373
   292
          "  (a::real) = (rhs (NTH 1 sol_a));                " ^
wneuper@59512
   293
          (*([8], Frm), 3 = AA * (z - -1 / 4) + BB * (z - 1 / 2)*)
s1210629013@55373
   294
          "  (eq_b::bool) = Take eq;                         " ^
wneuper@59512
   295
          (*([8], Res), 3 = AA * (-1 / 4 - -1 / 4) + BB * (-1 / 4 - 1 / 2)*)
s1210629013@55373
   296
          "  eq_b = (Substitute [zzz = z2]) eq_b;            " ^
wneuper@59512
   297
          (*([9], Res), 3 = -3 * BB / 4*)
wneuper@59489
   298
          "  eq_b = (Rewrite_Set ''norm_Rational'' False) eq_b;  " ^
wneuper@59512
   299
          (*([10], Pbl), solve (3 = -3 * BB / 4, BB)*)
s1210629013@55373
   300
          "  (sol_b::bool list) =                            " ^
wneuper@59489
   301
          "    (SubProblem (''Isac'', [''univariate'',''equation''], [''no_met''])   " ^
wneuper@59512
   302
          (*([10], Res), [BB = -4]*)
wneuper@59512
   303
          "    [BOOL eq_b, REAL (BB::real)]);                 " ^
s1210629013@55373
   304
          (*           b = -4*)
s1210629013@55373
   305
          "  (b::real) = (rhs (NTH 1 sol_b));                " ^
wneuper@59512
   306
          (*           eqr = AA / (z - 1 / 2) + BB / (z - -1 / 4)*)
wneuper@59512
   307
          (*([11], Frm), AA / (z - 1 / 2) + BB / (z - -1 / 4)*)
s1210629013@55373
   308
          "  (pbz::real) = Take eqr;                         " ^
s1210629013@55373
   309
          (*([11], Res), 4 / (z - 1 / 2) + -4 / (z - -1 / 4)*)
wneuper@59512
   310
          "  pbz = ((Substitute [AA = a, BB = b]) pbz)         " ^
s1210629013@55373
   311
          (*([], Res), 4 / (z - 1 / 2) + -4 / (z - -1 / 4)*)
s1210629013@55373
   312
          "in pbz)"
s1210629013@55373
   313
)]
wneuper@59472
   314
\<close>
wneuper@59472
   315
ML \<open>
neuper@42376
   316
(*
neuper@42376
   317
  val fmz =                                             
neuper@42376
   318
    ["functionTerm (3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))))", 
neuper@42376
   319
      "solveFor z", "functionTerm p_p"];
neuper@42376
   320
  val (dI',pI',mI') =
neuper@42376
   321
    ("Partial_Fractions", 
neuper@42376
   322
      ["partial_fraction", "rational", "simplification"],
neuper@42376
   323
      ["simplification","of_rationals","to_partial_fraction"]);
neuper@42376
   324
  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@42376
   325
*)
wneuper@59472
   326
\<close>
neuper@42289
   327
neuper@42289
   328
end