test/Tools/isac/Knowledge/partial_fractions.sml
author Jan Rocnik <jan.rocnik@student.tugraz.at>
Thu, 08 Dec 2011 23:37:50 +0100
changeset 42352 52ffa99930b2
parent 42315 c2e6ac4a5d04
child 42359 b9d382f20232
permissions -rwxr-xr-x
tuned and working (factors from solution)
     1 (* Title:  partial fraction decomposition
     2    Author: Jan Rocnik
     3    (c) due to copyright terms
     4 *)
     5 
     6 "--------------------------------------------------------";
     7 "table of contents --------------------------------------";
     8 "--------------------------------------------------------";
     9 "----------- Test of function factors_from_solution ---------";
    10 "--------------------------------------------------------";
    11 "----------- why helpless here ? ------------------------";
    12 "----------- why not nxt = Model_Problem here ? ---------";
    13 "--------------------------------------------------------";
    14 "--------------------------------------------------------";
    15 "--------------------------------------------------------";
    16 
    17 
    18 "----------- why helpless here ? ------------------------";
    19 "----------- why helpless here ? ------------------------";
    20 "----------- why helpless here ? ------------------------";
    21 val fmz = ["filterExpression (X z = 3 / (z - 1/4 + -1/8 * (1/(z::real))))", 
    22   "stepResponse (x[n::real]::bool)"];
    23 val (dI,pI,mI) = ("Isac", ["inverse", "Z_Transform", "SignalProcessing"], 
    24   ["SignalProcessing","Z_Transform","inverse"]);
    25 val (p,_,f,nxt,_,pt)  = CalcTreeTEST [(fmz, (dI,pI,mI))]; 
    26 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Add_Given";
    27 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Add_Find";
    28 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Specify_Theory";
    29 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Specify_Problem";
    30 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Specify_Method";
    31 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "nxt = Apply_Method";
    32 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "nxt = Rewrite (ruleZY, Inverse_Z_Transform.ruleZY) --> X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))";
    33 val (p''',_,f,nxt''',_,pt''') = me nxt p [] pt; "nxt = Rewrite_Set norm_Rational --> X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))";
    34 "~~~~~ fun me, args:"; val ((_,tac), (p:pos'), _, (pt:ptree)) = (nxt, p, [], pt);
    35 val ("ok", (_, _, ptp)) = locatetac tac (pt,p)
    36 val (pt, p) = ptp;
    37 "~~~~~ fun step, args:"; val (((ip as (_,p_)):pos'), ((ptp as (pt,p), tacis):calcstate)) = 
    38                            (p, ((pt, e_pos'),[]));
    39 val pIopt = get_pblID (pt,ip);
    40 ip = ([],Res); "false";
    41 tacis; " = []";
    42 pIopt; (* = SOME ["inverse", "Z_Transform", "SignalProcessing"]*)
    43 member op = [Pbl,Met] p_ andalso is_none (get_obj g_env pt (fst p)); "false";
    44 (*nxt_solve_ (pt,ip); "WAS isalist2list applied to NON-list 'no_meth'"
    45    THIS MEANS: replace no_meth by [no_meth] in Script.*)
    46 (*WAS val ("helpless",_) = step p ((pt, e_pos'),[]) *)
    47 (*WAS val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Empty_Tac instead SubProblem";*)
    48 
    49 "----------- why not nxt = Model_Problem here ? ---------";
    50 "----------- why not nxt = Model_Problem here ? ---------";
    51 "----------- why not nxt = Model_Problem here ? ---------";
    52 val (p,_,f,nxt,_,pt) = me nxt''' p''' [] pt'''; 
    53 "~~~~~ fun me, args:"; val (((_,tac):tac'_), (p:pos'), _, (pt:ptree)) = (nxt, p, c, pt);
    54 val ("ok", (_, _, ptp)) = locatetac tac (pt,p);
    55 val (pt, p) = ptp;
    56 "~~~~~ fun step, args:"; val (((ip as (_,p_)):pos'), ((ptp as (pt,p), tacis):calcstate)) =
    57                            (p, ((pt, e_pos'),[]));
    58 val pIopt = get_pblID (pt,ip);
    59 ip = ([],Res); " = false";
    60 tacis; " = []";                                         
    61 pIopt (* = SOME ["inverse", "Z_Transform", "SignalProcessing"]*);
    62 member op = [Pbl,Met] p_ andalso is_none (get_obj g_env pt (fst p)); " = false";
    63 (*                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ leads into
    64 nxt_solve_, which is definitely WRONG (should be nxt_specify_ for FIND_ADD).
    65 This ERROR seems to be introduced together with ctxt, concerns Apply_Method without init_form.
    66 See TODO.txt
    67 *)
    68 
    69 "----------- Test of function factors_from_solution ---------";
    70 "----------- Test of function factors_from_solution ---------";
    71 "----------- Test of function factors_from_solution ---------";
    72 
    73 val SOME t = parseNEW ctxt "factors_from_solution [(z::real) = 1 / 2, z = -1 / 4]";
    74 val SOME (_, t') = eval_factors_from_solution "" 0 t thy;
    75 if term2str t' =
    76  "factors_from_solution [z = 1 / 2, z = -1 / 4] =\n(z + -1 * (1 / 2)) * (z + -1 * (-1 / 4))"
    77 then () else error "factors_from_solution broken";
    78 
    79