neuper@37906: (* testexamples for Poly, polynomials
neuper@37906: author: Matthias Goldgruber 2003
neuper@37906: (c) due to copyright terms
neuper@37906:
neuper@37906: use"../smltest/IsacKnowledge/poly.sml";
neuper@37906: use"poly.sml";
neuper@37906: ****************************************************************.*)
neuper@37906:
neuper@37906: (******************************************************************
neuper@37906: WN060104 'SPB' came into 'exp_IsacCore_Simp_Poly_Book.xml'
neuper@37906: 'SPO' came into 'exp_IsacCore_Simp_Poly_Other.xml'
neuper@37906: *******************************************************************)
neuper@37906: "-----------------------------------------------------------------";
neuper@37906: "table of contents -----------------------------------------------";
neuper@37906: "-----------------------------------------------------------------";
neuper@37906: "-------- investigate new uniary minus ---------------------------";
neuper@37906: "-------- Bsple aus Schalk I -------------------------------------";
neuper@37906: "-------- Script 'simplification for_polynomials' ----------------";
neuper@37906: "-------- check pbl 'polynomial simplification' -----------------";
neuper@37906: "-------- me 'polynomial simplification' Schalk I p.63 No.267b ---";
neuper@37906: "-------- norm_Poly NOT COMPLETE ---------------------------------";
neuper@37906: "-------- ord_make_polynomial ------------------------------------";
neuper@37906: "-----------------------------------------------------------------";
neuper@37906: "-----------------------------------------------------------------";
neuper@37906: "-----------------------------------------------------------------";
neuper@37906:
neuper@37906:
neuper@37906: "-------- investigate new uniary minus ---------------------------";
neuper@37906: "-------- investigate new uniary minus ---------------------------";
neuper@37906: "-------- investigate new uniary minus ---------------------------";
neuper@37906: val t = (#prop o rep_thm) real_diff_0; (*"0 - ?x = - ?x"*)
neuper@37906: atomty t;
neuper@37906: (*** -------------
neuper@37906: *** Const ( Trueprop, bool => prop)
neuper@37906: *** . Const ( op =, [real, real] => bool)
neuper@37906: *** . . Const ( op -, [real, real] => real)
neuper@37906: *** . . . Const ( 0, real)
neuper@37906: *** . . . Var ((x, 0), real)
neuper@37906: *** . . Const ( uminus, real => real)
neuper@37906: *** . . . Var ((x, 0), real) *)
neuper@37906:
neuper@37906: val t = (term_of o the o (parse thy)) "-1";
neuper@37906: atomty t;
neuper@37906: (*** -------------
neuper@37906: *** Free ( -1, real) *)
neuper@37906: val t = (term_of o the o (parse thy)) "- 1";
neuper@37906: atomty t;
neuper@37906: (*** -------------
neuper@37906: *** Const ( uminus, real => real)
neuper@37906: *** . Free ( 1, real) *)
neuper@37906:
neuper@37906: val t = (term_of o the o (parse thy)) "-x"; (*1-x syntyx error !!!*)
neuper@37906: atomty t;
neuper@37906: (**** -------------
neuper@37906: *** Free ( -x, real)*)
neuper@37906: val t = (term_of o the o (parse thy)) "- x";
neuper@37906: atomty t;
neuper@37906: (**** -------------
neuper@37906: *** Free ( -x, real) !!!!!!!!!!!!!!!!!!!!!!!! is the same !!!*)
neuper@37906: val t = (term_of o the o (parse thy)) "-(x)";
neuper@37906: atomty t;
neuper@37906: (**** -------------
neuper@37906: *** Free ( -x, real)*)
neuper@37906:
neuper@37906:
neuper@37906: "-------- Bsple aus Schalk I -------------------------------------";
neuper@37906: "-------- Bsple aus Schalk I -------------------------------------";
neuper@37906: "-------- Bsple aus Schalk I -------------------------------------";
neuper@37906: (*SPB Schalk I p.63 No.267b*)
neuper@37906: val t = str2term
neuper@37906: "(5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) =
neuper@37906: "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
neuper@37906: then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 1";
neuper@37906:
neuper@37906: (*SPB Schalk I p.63 No.275b*)
neuper@37906: val t = str2term
neuper@37906: "(3*x^^^2 - 2*x*y + y^^^2) * (x^^^2 - 2*y^^^2)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906: term2str t;
neuper@37906: if (term2str t) =
neuper@37906: "3 * x ^^^ 4 + -2 * x ^^^ 3 * y + -5 * x ^^^ 2 * y ^^^ 2 + \
neuper@37906: \4 * x * y ^^^ 3 +\n-2 * y ^^^ 4"
neuper@37906: then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 2";
neuper@37906:
neuper@37906: (*SPB Schalk I p.63 No.279b*)
neuper@37906: val t = str2term
neuper@37906: "(x-a)*(x-b)*(x-c)*(x-d)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906: term2str t;
neuper@37906: (* Richtig! *)
neuper@37906: if (term2str t) =
neuper@37906: "a * b * c * d + -1 * a * b * c * x + -1 * a * b * d * x + a * b * x ^^^ 2 +\n-1 * a * c * d * x +\na * c * x ^^^ 2 +\na * d * x ^^^ 2 +\n-1 * a * x ^^^ 3 +\n-1 * b * c * d * x +\nb * c * x ^^^ 2 +\nb * d * x ^^^ 2 +\n-1 * b * x ^^^ 3 +\nc * d * x ^^^ 2 +\n-1 * c * x ^^^ 3 +\n-1 * d * x ^^^ 3 +\nx ^^^ 4"
neuper@37906: then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 3";
neuper@37906:
neuper@37906: (*SPB Schalk I p.63 No.291*)
neuper@37906: val t = str2term
neuper@37906: "(5+96*x^^^3+8*x*(-4+(7- 3*x)*4*x))*(5*(2- 3*x)- (-15*x*(-8*x- 5)))";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906: term2str t;
neuper@37906: if (term2str t) =
neuper@37906: "50 + -770 * x + 4520 * x ^^^ 2 + -16320 * x ^^^ 3 + -26880 * x ^^^ 4"
neuper@37906: then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 4";
neuper@37906:
neuper@37906: (*SPB Schalk I p.64 No.295c*)
neuper@37906: val t = str2term
neuper@37906: "(13*a^^^4*b^^^9*c - 12*a^^^3*b^^^6*c^^^9)^^^2";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906: term2str t;
neuper@37906: if (term2str t) =
neuper@37906: "169 * a ^^^ 8 * b ^^^ 18 * c ^^^ 2 + -312 * a ^^^ 7 * b ^^^ 15 * c ^^^ 10\
neuper@37906: \ +\n144 * a ^^^ 6 * b ^^^ 12 * c ^^^ 18"
neuper@37906: then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 5";
neuper@37906:
neuper@37906: (*SPB Schalk I p.64 No.299a*)
neuper@37906: val t = str2term
neuper@37906: "(x - y)*(x + y)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906: term2str t;
neuper@37906: if (term2str t) =
neuper@37906: "x ^^^ 2 + -1 * y ^^^ 2"
neuper@37906: then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 6";
neuper@37906:
neuper@37906: (*SPB Schalk I p.64 No.300c*)
neuper@37906: val t = str2term
neuper@37906: "(3*x^^^2*y - 1)*(3*x^^^2*y + 1)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906: term2str t;
neuper@37906: if (term2str t) =
neuper@37906: "-1 + 9 * x ^^^ 4 * y ^^^ 2"
neuper@37906: then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 7";
neuper@37906:
neuper@37906: (*SPB Schalk I p.64 No.302*)
neuper@37906: val t = str2term
neuper@37906: "(13*x^^^2 + 5)*(13*x^^^2 - 5) - (5*x^^^2 + 3)*(5*x^^^2 - 3) - (12*x^^^2 + 4)*(12*x^^^2 - 4)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "0" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 8";
neuper@37906: (* Bei Berechnung sollte 3 mal real_plus_minus_binom1_p aus expand_poly verwendet werden *)
neuper@37906:
neuper@37906:
neuper@37906: (*SPB Schalk I p.64 No.306a*)
neuper@37906: val t = str2term "((x^^^2 + 1)*(x^^^2 - 1))^^^2";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "1 + 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 + x ^^^ 8" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial: not confluent \
neuper@37906: \2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 = -2 * x ^^^ 4 works again";
neuper@37906:
neuper@37906:
neuper@37906: (*WN071729 when reducing "rls reduce_012_" for Schaerding,
neuper@37906: the above resulted in the term below ... but reduces from then correctly*)
neuper@37906: val t = str2term "1 + 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 + x ^^^ 8";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "1 + -2 * x ^^^ 4 + x ^^^ 8" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 9b";
neuper@37906:
neuper@37906: (*SPB Schalk I p.64 No.296a*)
neuper@37906: val t = str2term "(x - a)^^^3";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "-1 * a ^^^ 3 + 3 * a ^^^ 2 * x + -3 * a * x ^^^ 2 + x ^^^ 3"
neuper@37906: then () else raise error "poly.sml: diff.behav. in make_polynomial 10";
neuper@37906:
neuper@37906: (*SPB Schalk I p.64 No.296c*)
neuper@37906: val t = str2term "(-3*x - 4*y)^^^3";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) =
neuper@37906: "-27 * x ^^^ 3 + -108 * x ^^^ 2 * y + -144 * x * y ^^^ 2 + -64 * y ^^^ 3"
neuper@37906: then () else raise error "poly.sml: diff.behav. in make_polynomial 11";
neuper@37906:
neuper@37906: (*SPB Schalk I p.62 No.242c*)
neuper@37906: val t = str2term "x^^^(-4)*(x^^^(-4)*y^^^(-2))^^^(-1)*y^^^(-2)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "1" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 12";
neuper@37906:
neuper@37906: (*SPB Schalk I p.60 No.209a*)
neuper@37906: val t = str2term "a^^^(7-x) * a^^^x";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "a ^^^ 7" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 13";
neuper@37906:
neuper@37906: (*SPB Schalk I p.60 No.209d*)
neuper@37906: val t = str2term "d^^^x * d^^^(x+1) * d^^^(2 - 2*x)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "d ^^^ 3" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 14";
neuper@37906:
neuper@37906:
neuper@37906: (*---------------------------------------------------------------------*)
neuper@37906: (*------------------ Bsple bei denen es Probleme gibt------------------*)
neuper@37906: (*---------------------------------------------------------------------*)
neuper@37906:
neuper@37906: (*Schalk I p.64 No.303*)
neuper@37906: val t = str2term "(a + 2*b)*(a^^^2 + 4*b^^^2)*(a - 2*b) - (a - 6*b)*(a^^^2 + 36*b^^^2)*(a + 6*b)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "1280 * b ^^^ 4" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 14b";
neuper@37906: (* Richtig - aber Binomische Formel wurde nicht verwendet! *)
neuper@37906:
neuper@37906:
neuper@37906: (*--------------------------------------------------------------------*)
neuper@37906: (*----------------------- Eigene Beispiele ---------------------------*)
neuper@37906: (*--------------------------------------------------------------------*)
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "a^^^2*a^^^(-2)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "1" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 15";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "a + a + a";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "3 * a" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 16";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "a + b + b + b";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "a + 3 * b" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 17";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "a^^^2*b*b^^^(-1)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "a ^^^ 2" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 18";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "a^^^2*a^^^(-2)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "1" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 19";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "b + a - b";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "a" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 20";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "b * a * a";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "a ^^^ 2 * b" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 21";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "(a^^^2)^^^3";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "a ^^^ 6" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 22";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "x^^^2 * y^^^2 + x * x^^^2 * y";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if term2str t = "x ^^^ 3 * y + x ^^^ 2 * y ^^^ 2" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 23";
neuper@37906: (*SPO*)
neuper@37906: val t = (term_of o the o (parse thy)) "a^^^2 * (-a)^^^2";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "a ^^^ 4" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 24";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "a * b * b^^^(-1) + a";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "2 * a" then ()
neuper@37906: else raise error "poly.sml: diff.behav. in make_polynomial 25";
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "a*c*b^^^(2*n) + 3*a + 5*b^^^(2*n)*c*b";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t; term2str t;
neuper@37906: if (term2str t) = "3 * a + 5 * b ^^^ (1 + 2 * n) * c + a * b ^^^ (2 * n) * c"
neuper@37906: then () else raise error "poly.sml: diff.behav. in make_polynomial 26";
neuper@37906:
neuper@37906:
neuper@37906: (*MG.27.6.03 -------------vvv-: Verschachtelte Terme -----------*)
neuper@37906: (*SPO*)
neuper@37906: val t = str2term "(1 + (x*y*a) + x)^^^(1 + (x*y*a) + x)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906: term2str t;
neuper@37906: if term2str t = "(1 + x + a * x * y) ^^^ (1 + x + a * x * y)"
neuper@37906: then () else raise error "poly.sml: diff.behav. in make_polynomial 27";(*SPO*)
neuper@37906: val t = str2term "(1 + x*(y*z)*zz)^^^(1 + x*(y*z)*zz)";
neuper@37906: val Some (t,_) = rewrite_set_ thy false make_polynomial t;
neuper@37906: term2str t;
neuper@37906: if term2str t = "(1 + x * y * z * zz) ^^^ (1 + x * y * z * zz)"
neuper@37906: then () else raise error "poly.sml: diff.behav. in make_polynomial 28";
neuper@37906:
neuper@37906: "-------- Script 'simplification for_polynomials' ----------------";
neuper@37906: "-------- Script 'simplification for_polynomials' ----------------";
neuper@37906: "-------- Script 'simplification for_polynomials' ----------------";
neuper@37906: val str =
neuper@37906: "Script SimplifyScript (t_::real) = \
neuper@37906: \ ((Rewrite_Set norm_Poly False) t_)";
neuper@37906: val sc = ((inst_abs thy) o term_of o the o (parse thy)) str;
neuper@37906: atomty sc;
neuper@37906:
neuper@37906:
neuper@37906: "-------- check pbl 'polynomial simplification' -----------------";
neuper@37906: "-------- check pbl 'polynomial simplification' -----------------";
neuper@37906: "-------- check pbl 'polynomial simplification' -----------------";
neuper@37906: val fmz = ["term ((5*x^^^2 + 3) * (2*x^^^7 + 3) \
neuper@37906: \- (3*x^^^5 + 8) * (6*x^^^4 - 1))",
neuper@37906: "normalform N"];
neuper@37906: (*0*)
neuper@37906: case refine fmz ["polynomial","simplification"]of
neuper@37906: [Matches (["polynomial", "simplification"], _)] => ()
neuper@37906: | _ => raise error "poly.sml diff.behav. in check pbl, refine";
neuper@37906: (*...if there is an error, then ...*)
neuper@37906:
neuper@37906: (*1*)
neuper@37906: print_depth 7;
neuper@37906: val pbt = get_pbt ["polynomial","simplification"];
neuper@37906: print_depth 3;
neuper@37906: (*if there is ...
neuper@37906: > val NoMatch' {Given=gi, Where=wh, Find=fi,...} = match_pbl fmz pbt;
neuper@37906: ... then trace_rewrite:*)
neuper@37906:
neuper@37906: (*2*)
neuper@37906: trace_rewrite:=true;
neuper@37906: match_pbl fmz pbt;
neuper@37906: trace_rewrite:=false;
neuper@37906: (*... if there is no rewrite, then there is something wrong with prls*)
neuper@37906:
neuper@37906: (*3*)
neuper@37906: print_depth 7;
neuper@37906: val prls = (#prls o get_pbt) ["polynomial","simplification"];
neuper@37906: print_depth 3;
neuper@37906: val t = str2term "((5*x^^^2 + 3) * (2*x^^^7 + 3) \
neuper@37906: \- (3*x^^^5 + 8) * (6*x^^^4 - 1)) is_polyexp";
neuper@37906: trace_rewrite:=true;
neuper@37906: val Some (t',_) = rewrite_set_ thy false prls t;
neuper@37906: trace_rewrite:=false;
neuper@37906: if t' = HOLogic.true_const then ()
neuper@37906: else raise error "poly.sml: diff.behav. in check pbl 'polynomial..";
neuper@37906: (*... if this works, but (*1*) does still NOT work, check types:*)
neuper@37906:
neuper@37906: (*4*)
neuper@37906: show_types:=true;
neuper@37906: (*
neuper@37906: > val NoMatch' {Given=gi, Where=wh, Find=fi,...} = match_pbl fmz pbt;
neuper@37906: val wh = [False "(t_::real => real) (is_polyexp::real)"]
neuper@37906: ......................^^^^^^^^^^^^...............^^^^*)
neuper@37906: val Matches' _ = match_pbl fmz pbt;
neuper@37906: show_types:=false;
neuper@37906:
neuper@37906:
neuper@37906: "-------- me 'polynomial simplification' Schalk I p.63 No.267b ---";
neuper@37906: "-------- me 'polynomial simplification' Schalk I p.63 No.267b ---";
neuper@37906: "-------- me 'polynomial simplification' Schalk I p.63 No.267b ---";
neuper@37906: val fmz = ["term ((5*x^^^2 + 3) * (2*x^^^7 + 3) \
neuper@37906: \- (3*x^^^5 + 8) * (6*x^^^4 - 1))",
neuper@37906: "normalform N"];
neuper@37906: val (dI',pI',mI') =
neuper@37906: ("Poly.thy",["polynomial","simplification"],
neuper@37906: ["simplification","for_polynomials"]);
neuper@37906: val p = e_pos'; val c = [];
neuper@37906: val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37924: (writeln o (itms2str_ ctxt)) (get_obj g_pbl pt (fst p));
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
neuper@37906: if f2str f =
neuper@37906: "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
neuper@37906: then () else raise error "poly.sml diff.behav. in me Schalk I p.63 No.267b";
neuper@37906:
neuper@37906:
neuper@37906: "-------- interSteps for Schalk 299a -----------------------------";
neuper@37906: "-------- interSteps for Schalk 299a -----------------------------";
neuper@37906: "-------- interSteps for Schalk 299a -----------------------------";
neuper@37906: states:=[];
neuper@37906: CalcTree
neuper@37906: [(["term ((x - y)*(x + y))", "normalform N"],
neuper@37906: ("Poly.thy",["polynomial","simplification"],
neuper@37906: ["simplification","for_polynomials"]))];
neuper@37906: Iterator 1;
neuper@37906: moveActiveRoot 1;
neuper@37906: autoCalculate 1 CompleteCalc;
neuper@37906: val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@37906:
neuper@37906: interSteps 1 ([1],Res)(* syserror in detailstep *);
neuper@37906: val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@37906: if existpt' ([1,1], Frm) pt then ()
neuper@37906: else raise error "poly.sml: interSteps doesnt work again 1";
neuper@37906:
neuper@37906: interSteps 1 ([1,1],Res)(* syserror in detailstep *);
neuper@37906: val ((pt,p),_) = get_calc 1; show_pt pt;
neuper@37906: if existpt' ([1,1,1], Frm) pt then ()
neuper@37906: else raise error "poly.sml: interSteps doesnt work again 2";
neuper@37906:
neuper@37906:
neuper@37906: "-------- norm_Poly NOT COMPLETE ---------------------------------";
neuper@37906: "-------- norm_Poly NOT COMPLETE ---------------------------------";
neuper@37906: "-------- norm_Poly NOT COMPLETE ---------------------------------";
neuper@37906: trace_rewrite:=true;
neuper@37906: val Some (f',_) = rewrite_set_ thy false norm_Poly
neuper@37906: (str2term "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben")(*see poly.sml: -- norm_Poly NOT COMPLETE -- TODO MG*);
neuper@37906: trace_rewrite:=false;
neuper@37906: term2str f';
neuper@37906:
neuper@37906: "-------- ord_make_polynomial ------------------------------------";
neuper@37906: "-------- ord_make_polynomial ------------------------------------";
neuper@37906: "-------- ord_make_polynomial ------------------------------------";
neuper@37906: val t1 = str2term "2 * b + (3 * a + 3 * b)";
neuper@37906: val t2 = str2term "3 * a + 3 * b + 2 * b";
neuper@37906:
neuper@37906: if ord_make_polynomial true Poly.thy [] (t1, t2) then ()
neuper@37906: else raise error "poly.sml: diff.behav. in ord_make_polynomial";
neuper@37906:
neuper@37906: (*WN071202: ^^^ why then is there no rewriting ...*)
neuper@37906: val term = str2term "2*b + (3*a + 3*b)";
neuper@37906: val None = rewrite_set_ Isac.thy false order_add_mult term;
neuper@37906:
neuper@37906: (*or why is there no rewriting this way...*)
neuper@37906: val t1 = str2term "2 * b + (3 * a + 3 * b)";
neuper@37906: val t2 = str2term "3 * a + (2 * b + 3 * b)";
neuper@37906:
neuper@37906:
neuper@37906: