1.1 --- a/test/Tools/isac/Interpret/inform.sml Mon Sep 16 11:28:43 2013 +0200
1.2 +++ b/test/Tools/isac/Interpret/inform.sml Mon Sep 16 12:20:00 2013 +0200
1.3 @@ -493,35 +493,132 @@
1.4 "--------- inform [rational,simplification] ----------------------";
1.5 "--------- inform [rational,simplification] ----------------------";
1.6 "--------- inform [rational,simplification] ----------------------";
1.7 -states:=[];
1.8 -CalcTree [(["Term (4/x - 3/y - 1)", "normalform N"],
1.9 - ("Rational",["rational","simplification"],
1.10 - ["simplification","of_rationals"]))];
1.11 +states := [];
1.12 +CalcTree [(["Term (a * x / (b * x) + c * x / (d * x) + e / f)", "normalform N"],
1.13 + ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
1.14 Iterator 1; moveActiveRoot 1;
1.15 autoCalculate 1 CompleteCalcHead;
1.16 +
1.17 +"--- (-1) give a preview on the calculation without any input";
1.18 +(*
1.19 +autoCalculate 1 CompleteCalc;
1.20 +val ((pt, p), _) = get_calc 1;
1.21 +show_pt pt;
1.22 +[
1.23 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
1.24 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
1.25 +(([1], Res), a / b + c / d + e / f), <--- (1) input arbitrary
1.26 +(([2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.27 +(([3], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
1.28 +(([4], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)), <--- (2) input next
1.29 +(([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))] <--- (3) is also final result
1.30 + EXAMPLE NOT OPTIMAL
1.31 +*)
1.32 +"--- (0) user input as the *first* step does not work, thus impdo at least 1 step";
1.33 autoCalculate 1 (Step 1);
1.34 autoCalculate 1 (Step 1);
1.35 -autoCalculate 1 (Step 1);
1.36 -autoCalculate 1 (Step 1);
1.37 -"--- input the next formula that _should_ be presented by mat-engine";
1.38 -appendFormula 1 "(4 * y + -3 * x) / (x * y) + -1";
1.39 +val ((pt, p), _) = get_calc 1;
1.40 +(*show_pt pt;
1.41 +[
1.42 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
1.43 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
1.44 +(([1], Res), a / b + c / d + e / f)]
1.45 +*)
1.46 +"--- (1) input an arbitrary next formula";
1.47 +appendFormula 1 "((a * d) + (c * b)) / (b * d) + e / f";
1.48 +val ((pt, p), _) = get_calc 1;
1.49 +(*show_pt pt;
1.50 +[
1.51 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
1.52 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
1.53 +(([1], Res), a / b + c / d + e / f),
1.54 +(([2,1], Frm), a / b + c / d + e / f),
1.55 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.56 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
1.57 +(([2], Res), (a * d + c * b) / (b * d) + e / f)]
1.58 +*)
1.59 val ((pt,p),_) = get_calc 1;
1.60 -if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
1.61 +if p = ([2], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
1.62 else error ("inform.sml: [rational,simplification] 1");
1.63
1.64 -"--- input the next formula that would be presented by mat-engine";
1.65 -(*autoCalculate 1 (Step 1);*)
1.66 -appendFormula 1 "(4 * y + -3 * x + -1 * (x * y)) / (x * y)";
1.67 -val ((pt,p),_) = get_calc 1;
1.68 -if p = ([5], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
1.69 +"--- (2) input the next formula that would be presented by mat-engine";
1.70 +(* generate a preview:
1.71 +autoCalculate 1 (Step 1);
1.72 +val ((pt, p), _) = get_calc 1;
1.73 +show_pt pt;
1.74 +[
1.75 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
1.76 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
1.77 +(([1], Res), a / b + c / d + e / f),
1.78 +(([2,1], Frm), a / b + c / d + e / f),
1.79 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.80 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
1.81 +(([2], Res), (a * d + c * b) / (b * d) + e / f),
1.82 +(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] <--- input this
1.83 +*)
1.84 +appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)";
1.85 +val ((pt, p), _) = get_calc 1;
1.86 +(*show_pt pt;
1.87 +[
1.88 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
1.89 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
1.90 +(([1], Res), a / b + c / d + e / f),
1.91 +(([2,1], Frm), a / b + c / d + e / f),
1.92 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.93 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
1.94 +(([2], Res), (a * d + c * b) / (b * d) + e / f),
1.95 +(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
1.96 +*)
1.97 +if p = ([3], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
1.98 else error ("inform.sml: [rational,simplification] 2");
1.99
1.100 -"--- input the exact final result";(*TODO: Exception- LIST "last_elem" raised*)
1.101 -appendFormula 1 "(-3 * x + 4 * y + -1 * x * y) / (x * y)";
1.102 -val ((pt,p),_) = get_calc 1;
1.103 -if p = ([6], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
1.104 +"--- (3) input the exact final result";
1.105 +appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)";
1.106 +val ((pt, p), _) = get_calc 1;
1.107 +(*show_pt pt;
1.108 +[
1.109 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
1.110 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
1.111 +(([1], Res), a / b + c / d + e / f),
1.112 +(([2,1], Frm), a / b + c / d + e / f),
1.113 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.114 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
1.115 +(([2], Res), (a * d + c * b) / (b * d) + e / f),
1.116 +(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.117 +(([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.118 +(([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
1.119 +(([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.120 +(([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]
1.121 +*)
1.122 +if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
1.123 else error ("inform.sml: [rational,simplification] 3");
1.124 -show_pt pt;
1.125 +
1.126 +"--- (4) finish the calculation + check the postcondition (in the future)";
1.127 +autoCalculate 1 CompleteCalc;
1.128 +val ((pt, p), _) = get_calc 1;
1.129 +val (t, asm) = get_obj g_result pt [];
1.130 +if term2str t = "(a * d * f + b * c * f + b * d * e) / (b * d * f)" andalso
1.131 +terms2str asm = "[\"b * d * f ~= 0\",\"d ~= 0\",\"b ~= 0\"," ^
1.132 + "\"a * x / (b * x) + c * x / (d * x) + e / f is_ratpolyexp\"]"
1.133 +then () else error "inform [rational,simplification] changed at end";
1.134 +(*show_pt pt;
1.135 +[
1.136 +(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
1.137 +(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
1.138 +(([1], Res), a / b + c / d + e / f),
1.139 +(([2,1], Frm), a / b + c / d + e / f),
1.140 +(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.141 +(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
1.142 +(([2], Res), (a * d + c * b) / (b * d) + e / f),
1.143 +(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.144 +(([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.145 +(([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
1.146 +(([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.147 +(([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
1.148 +(([5], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
1.149 +(([6], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)),
1.150 +(([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))]
1.151 +*)
1.152
1.153 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
1.154 "--------- Take as 1st tac, start with <NEW> (CAS input) ---------";