neuper@37906: (* testexamples for Poly, polynomials
neuper@37906: author: Matthias Goldgruber 2003
neuper@37906: (c) due to copyright terms
neuper@37906:
neuper@38022: 12345678901234567890123456789012345678901234567890123456789012345678901234567890
neuper@38022: 10 20 30 40 50 60 70 80
neuper@42395: LEGEND:
neuper@42395: WN060104: examples marked with 'SPB' came into 'exp_IsacCore_Simp_Poly_Book.xml'
neuper@42395: examples marked with 'SPO' came into 'exp_IsacCore_Simp_Poly_Other.xml'
neuper@38022: *)
neuper@42395:
neuper@38022: "--------------------------------------------------------";
neuper@38022: "--------------------------------------------------------";
neuper@38022: "table of contents --------------------------------------";
neuper@38022: "--------------------------------------------------------";
wneuper@59529: "----------- fun is_polyexp --------------------------------------------------------------------";
wneuper@59522: "----------- fun has_degree_in -----------------------------------------------------------------";
wneuper@59522: "----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522: "----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522: "----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
neuper@42395: "-------- investigate (new 2002) uniary minus -----------";
neuper@38036: "-------- check make_polynomial with simple terms -------";
neuper@38036: "-------- fun is_multUnordered --------------------------";
neuper@38036: "-------- examples from textbook Schalk I ---------------";
neuper@38022: "-------- check pbl 'polynomial simplification' --------";
neuper@38022: "-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
neuper@38036: "-------- interSteps for Schalk 299a --------------------";
neuper@38022: "-------- norm_Poly NOT COMPLETE ------------------------";
neuper@38022: "-------- ord_make_polynomial ---------------------------";
neuper@38022: "--------------------------------------------------------";
neuper@38022: "--------------------------------------------------------";
neuper@38022: "--------------------------------------------------------";
neuper@37906:
neuper@37906:
wneuper@59529: "----------- fun is_polyexp --------------------------------------------------------------------";
wneuper@59529: "----------- fun is_polyexp --------------------------------------------------------------------";
wneuper@59529: "----------- fun is_polyexp --------------------------------------------------------------------";
wneuper@59529: val thy = @{theory Partial_Fractions};
wneuper@59529: val ctxt = Proof_Context.init_global thy;
wneuper@59529:
wneuper@59529: val t = (the o (parseNEW ctxt)) "x / x";
wneuper@59529: if is_polyexp t then error "NOT is_polyexp (x / x)" else ();
wneuper@59529:
wneuper@59529: val t = (the o (parseNEW ctxt)) "-1 * A * 3";
wneuper@59529: if is_polyexp t then () else error "is_polyexp (-1 * A * 3)";
wneuper@59529:
wneuper@59529: val t = (the o (parseNEW ctxt)) "-1 * AA * 3";
wneuper@59529: if is_polyexp t then () else error "is_polyexp (-1 * AA * 3)";
neuper@38022:
wneuper@59522: "----------- fun has_degree_in -----------------------------------------------------------------";
wneuper@59522: "----------- fun has_degree_in -----------------------------------------------------------------";
wneuper@59522: "----------- fun has_degree_in -----------------------------------------------------------------";
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "1";
wneuper@59522: if has_degree_in t v = 0 then () else error "has_degree_in (1) x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "1";
wneuper@59522: if has_degree_in t v = 0 then () else error "has_degree_in (1) AA";
wneuper@59522:
wneuper@59522: (*----------*)
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "a*b+c";
wneuper@59522: if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "a*b+c";
wneuper@59522: if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) AA";
wneuper@59522:
wneuper@59522: (*----------*)
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "a*x+c";
wneuper@59522: if has_degree_in t v = ~1 then () else error "has_degree_in (a*x+c) x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "a*AA+c";
wneuper@59522: if has_degree_in t v = ~1 then () else error "has_degree_in (a*AA+c) AA";
wneuper@59522:
wneuper@59522: (*----------*)
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*x^^^7";
wneuper@59522: if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*x^^^7) x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*AA^^^7";
wneuper@59522: if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*AA^^^7) AA";
wneuper@59522:
wneuper@59522: (*----------*)
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "x^^^7";
wneuper@59522: if has_degree_in t v = 7 then () else error "has_degree_in (x^^^7) x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "AA^^^7";
wneuper@59522: if has_degree_in t v = 7 then () else error "has_degree_in (AA^^^7) AA";
wneuper@59522:
wneuper@59522: (*----------*)
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*x";
wneuper@59522: if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*x) x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*AA";
wneuper@59522: if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*AA) AA";
wneuper@59522:
wneuper@59522: (*----------*)
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+x)*x";
wneuper@59522: if has_degree_in t v = ~1 then () else error "has_degree_in (a*b+x)*x() x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+AA)*AA";
wneuper@59522: if has_degree_in t v = ~1 then () else error "has_degree_in ((a*b+AA)*AA) AA";
wneuper@59522:
wneuper@59522: (*----------*)
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: if has_degree_in t v = 1 then () else error "has_degree_in (x) x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: if has_degree_in t v = 1 then () else error "has_degree_in (AA) AA";
wneuper@59522:
wneuper@59522: (*----------*)
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "ab - (a*b)*x";
wneuper@59522: if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*x) x";
wneuper@59522:
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "ab - (a*b)*AA";
wneuper@59522: if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*AA) AA";
wneuper@59522:
wneuper@59522: "----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522: "----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522: "----------- fun mono_deg_in -------------------------------------------------------------------";
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*x^^^7";
wneuper@59522: if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*x^^^7) x changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "x^^^7";
wneuper@59522: if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (x^^^7) x changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*x";
wneuper@59522: if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*x) x changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+x)*x";
wneuper@59522: if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+x)*x) x changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "x";
wneuper@59522: if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (x) x changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)";
wneuper@59522: if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) x changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "ab - (a*b)*x";
wneuper@59522: if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*x) x changed";
wneuper@59522:
wneuper@59522: (*. . . . . . . . . . . . the same with Const ("Partial_Functions.AA", _) . . . . . . . . . . . *)
wneuper@59522: val thy = @{theory Partial_Fractions}
wneuper@59522: val v = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*AA^^^7";
wneuper@59522: if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*AA^^^7) AA changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "AA^^^7";
wneuper@59522: if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (AA^^^7) AA changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)*AA";
wneuper@59522: if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*AA) AA changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+AA)*AA";
wneuper@59522: if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+AA)*AA) AA changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "AA";
wneuper@59522: if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (AA) AA changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(a*b+c)";
wneuper@59522: if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) AA changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "ab - (a*b)*AA";
wneuper@59522: if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*AA) AA changed";
wneuper@59522:
wneuper@59522: "----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
wneuper@59522: "----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
wneuper@59522: "----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
wneuper@59522: val thy = @{theory Partial_Fractions}
wneuper@59522: val expr = (Thm.term_of o the o (parse thy)) "((-8 - 2*x + x^^^2) has_degree_in x) = 2";
wneuper@59522: val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
wneuper@59522:
wneuper@59522: val expr = (Thm.term_of o the o (parse thy)) "((-8 - 2*AA + AA^^^2) has_degree_in AA) = 2";
wneuper@59522: val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
wneuper@59522:
wneuper@59522: "----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
wneuper@59522: "----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
wneuper@59522: "----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(-8 - 2*x + x^^^2) is_expanded_in x";
wneuper@59522: val SOME (id, t') = eval_is_expanded_in 0 0 t 0;
walther@59868: if UnparseC.term t' = "-8 - 2 * x + x ^^^ 2 is_expanded_in x = True"
wneuper@59522: andalso id = "-8 - 2 * x + x ^^^ 2 is_expanded_in x = True"
wneuper@59522: then () else error "eval_is_expanded_in x ..changed";
wneuper@59522:
wneuper@59522: val thy = @{theory Partial_Fractions}
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(-8 - 2*AA + AA^^^2) is_expanded_in AA";
wneuper@59522: val SOME (id, t') = eval_is_expanded_in 0 0 t 0;
walther@59868: if UnparseC.term t' = "-8 - 2 * AA + AA ^^^ 2 is_expanded_in AA = True"
wneuper@59522: andalso id = "-8 - 2 * AA + AA ^^^ 2 is_expanded_in AA = True"
wneuper@59522: then () else error "eval_is_expanded_in AA ..changed";
wneuper@59522:
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(8 + 2*x + x^^^2) is_poly_in x";
wneuper@59522: val SOME (id, t') = eval_is_poly_in 0 0 t 0;
walther@59868: if UnparseC.term t' = "8 + 2 * x + x ^^^ 2 is_poly_in x = True"
wneuper@59522: andalso id = "8 + 2 * x + x ^^^ 2 is_poly_in x = True"
wneuper@59522: then () else error "is_poly_in x ..changed";
wneuper@59522:
wneuper@59522: val t = (Thm.term_of o the o (parse thy)) "(8 + 2*AA + AA^^^2) is_poly_in AA";
wneuper@59522: val SOME (id, t') = eval_is_poly_in 0 0 t 0;
walther@59868: if UnparseC.term t' = "8 + 2 * AA + AA ^^^ 2 is_poly_in AA = True"
wneuper@59522: andalso id = "8 + 2 * AA + AA ^^^ 2 is_poly_in AA = True"
wneuper@59522: then () else error "is_poly_in AA ..changed";
wneuper@59522:
wneuper@59522:
wneuper@59522: val thy = @{theory Partial_Fractions}
wneuper@59522: val expr = (Thm.term_of o the o (parse thy)) "((-8 - 2*x + x^^^2) has_degree_in x) = 2";
wneuper@59522: val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
wneuper@59522:
wneuper@59522: val expr = (Thm.term_of o the o (parse thy)) "((-8 - 2*AA + AA^^^2) has_degree_in AA) = 2";
wneuper@59522: val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
wneuper@59522:
neuper@42395: "-------- investigate (new 2002) uniary minus -----------";
neuper@42395: "-------- investigate (new 2002) uniary minus -----------";
neuper@42395: "-------- investigate (new 2002) uniary minus -----------";
neuper@42395: (*---------------------------------------------- vvvvvvvvvvvvvv -----------------------*)
wneuper@59188: val t = (#prop o Thm.rep_thm) @{thm real_diff_0}; (*"0 - ?x = - ?x"*)
neuper@37906: atomty t;
wneuper@59117: (*
wneuper@59117: *** Const (HOL.Trueprop, bool => prop)
wneuper@59117: *** . Const (HOL.eq, real => real => bool)
wneuper@59117: *** . . Const (Groups.minus_class.minus, real => real => real)
wneuper@59117: *** . . . Const (Groups.zero_class.zero, real)
neuper@37906: *** . . . Var ((x, 0), real)
wneuper@59117: *** . . Const (Groups.uminus_class.uminus, real => real)
wneuper@59117: *** . . . Var ((x, 0), real)
wneuper@59117: *)
neuper@42395: case t of
neuper@42395: Const ("HOL.Trueprop", _) $
wneuper@59117: (Const ("HOL.eq", _) $
wneuper@59117: (Const ("Groups.minus_class.minus", _) $ Const ("Groups.zero_class.zero", _) $
wneuper@59117: Var (("x", 0), _)) $
wneuper@59117: (Const ("Groups.uminus_class.uminus", _) $ Var (("x", 0), _))) => ()
neuper@42395: | _ => error "internal representation of \"0 - ?x = - ?x\" changed";
neuper@37906:
neuper@42395: (*----------------------------------- vvvv --------------------------------------------*)
wneuper@59188: val t = (Thm.term_of o the o (parse thy)) "-1";
neuper@37906: atomty t;
neuper@37906: (*** -------------
neuper@37906: *** Free ( -1, real) *)
neuper@42395: case t of
neuper@42395: Free ("-1", _) => ()
neuper@42395: | _ => error "internal representation of \"-1\" changed";
neuper@42395: (*----------------------------------- vvvvv -------------------------------------------*)
wneuper@59188: val t = (Thm.term_of o the o (parse thy)) "- 1";
neuper@37906: atomty t;
wneuper@59117: (*
wneuper@59117: ***
wneuper@59117: *** Free (-1, real)
wneuper@59117: ***
wneuper@59117: *)
neuper@42395: case t of
wneuper@59117: Free ("-1", _) => ()
neuper@42395: | _ => error "internal representation of \"- 1\" changed";
neuper@37906:
neuper@42395: "======= these external values all have the same internal representation";
neuper@42395: (* "1-x" causes syntyx error --- binary minus detected by blank inbetween !!!*)
neuper@42395: (*----------------------------------- vvvvv -------------------------------------------*)
wneuper@59188: val t = (Thm.term_of o the o (parse thy)) "-x";
neuper@37906: atomty t;
neuper@37906: (**** -------------
neuper@37906: *** Free ( -x, real)*)
neuper@42395: case t of
neuper@42395: Const ("Groups.uminus_class.uminus", _) $ Free ("x", _) => ()
neuper@42395: | _ => error "internal representation of \"-x\" changed";
neuper@42395: (*----------------------------------- vvvvv -------------------------------------------*)
wneuper@59188: val t = (Thm.term_of o the o (parse thy)) "- x";
neuper@37906: atomty t;
neuper@37906: (**** -------------
neuper@37906: *** Free ( -x, real) !!!!!!!!!!!!!!!!!!!!!!!! is the same !!!*)
neuper@42395: case t of
neuper@42395: Const ("Groups.uminus_class.uminus", _) $ Free ("x", _) => ()
neuper@42395: | _ => error "internal representation of \"- x\" changed";
neuper@42395: (*----------------------------------- vvvvvv ------------------------------------------*)
wneuper@59188: val t = (Thm.term_of o the o (parse thy)) "-(x)";
neuper@37906: atomty t;
neuper@37906: (**** -------------
neuper@37906: *** Free ( -x, real)*)
neuper@42395: case t of
neuper@42395: Const ("Groups.uminus_class.uminus", _) $ Free ("x", _) => ()
neuper@42395: | _ => error "internal representation of \"-(x)\" changed";
neuper@37906:
neuper@38036: "-------- check make_polynomial with simple terms -------";
neuper@38036: "-------- check make_polynomial with simple terms -------";
neuper@38036: "-------- check make_polynomial with simple terms -------";
neuper@38036: "----- check 1 ---";
neuper@38036: val t = str2term "2*3*a";
neuper@38036: val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "6 * a" then () else error "check make_polynomial 1";
neuper@38036:
neuper@38036: "----- check 2 ---";
neuper@38036: val t = str2term "2*a + 3*a";
neuper@38036: val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "5 * a" then () else error "check make_polynomial 2";
neuper@38036:
neuper@38036: "----- check 3 ---";
neuper@38036: val t = str2term "2*a + 3*a + 3*a";
neuper@38036: val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "8 * a" then () else error "check make_polynomial 3";
neuper@38036:
neuper@38036: "----- check 4 ---";
neuper@38036: val t = str2term "3*a - 2*a";
neuper@38036: val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "a" then () else error "check make_polynomial 4";
neuper@38036:
neuper@38036: "----- check 5 ---";
neuper@38036: val t = str2term "4*(3*a - 2*a)";
neuper@38036: val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "4 * a" then () else error "check make_polynomial 5";
neuper@38036:
neuper@38036: "----- check 6 ---";
neuper@38036: val t = str2term "4*(3*a^^^2 - 2*a^^^2)";
neuper@38036: val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "4 * a ^^^ 2" then () else error "check make_polynomial 6";
neuper@38036:
neuper@38036: "-------- fun is_multUnordered --------------------------";
neuper@38036: "-------- fun is_multUnordered --------------------------";
neuper@38036: "-------- fun is_multUnordered --------------------------";
wneuper@59592: val thy = @{theory "Isac_Knowledge"};
neuper@38040: "===== works for a simple example, see rewrite.sml -- fun app_rev ===";
neuper@38040: val t = str2term "x^^^2 * x";
neuper@38040: val SOME (t', _) = rewrite_set_ thy true order_mult_ t;
walther@59868: if UnparseC.term t' = "x * x ^^^ 2" then ()
neuper@38040: else error "poly.sml Poly.is'_multUnordered doesn't work";
neuper@38040:
walther@59901: (* 100928 Rewrite.trace_on shows the first occurring difference in 267b:
neuper@38036: ### rls: order_mult_ on: 5 * x ^^^ 2 * (2 * x ^^^ 7) + 5 * x ^^^ 2 * 3 + (6 * x ^^^ 7 + 9) + (-1 * (3 * x ^^^ 5 * (6 * x ^^^ 4)) + -1 * (3 * x ^^^ 5 * -1) +
neuper@38036: (-48 * x ^^^ 4 + 8))
walther@59852: ###### rls: Rule_Set.empty-is_multUnordered on: p is_multUnordered
neuper@38036: ####### try calc: Poly.is'_multUnordered'
neuper@38036: ======= calc. to: False !!!!!!!!!!!!! INSTEAD OF TRUE in 2002 !!!!!!!!!!!!!
neuper@38036: *)
neuper@38036: val t = str2term "5 * x ^^^ 2 * (2 * x ^^^ 7) + 5 * x ^^^ 2 * 3 + (6 * x ^^^ 7 + 9) + (-1 * (3 * x ^^^ 5 * (6 * x ^^^ 4)) + -1 * (3 * x ^^^ 5 * -1) + (-48 * x ^^^ 4 + 8))";
neuper@38036:
neuper@38036: "----- is_multUnordered ---";
neuper@38036: val tsort = sort_variables t;
walther@59868: UnparseC.term tsort = "2 * (5 * (x ^^^ 2 * x ^^^ 7)) + 3 * (5 * x ^^^ 2) + 6 * x ^^^ 7 + 9 +\n-1 * (3 * (6 * (x ^^^ 4 * x ^^^ 5))) +\n-1 * (-1 * (3 * x ^^^ 5)) +\n-48 * x ^^^ 4 +\n8";
neuper@38036: is_polyexp t;
neuper@38036: tsort = t;
neuper@38036: is_polyexp t andalso not (t = sort_variables t);
neuper@38036: if is_multUnordered t then () else error "poly.sml diff. is_multUnordered 1";
neuper@38036:
neuper@38036: "----- eval_is_multUnordered ---";
neuper@38036: val tm = str2term "(5 * x ^^^ 2 * (2 * x ^^^ 7) + 5 * x ^^^ 2 * 3 + (6 * x ^^^ 7 + 9) + (-1 * (3 * x ^^^ 5 * (6 * x ^^^ 4)) + -1 * (3 * x ^^^ 5 * -1) + (-48 * x ^^^ 4 + 8))) is_multUnordered";
neuper@38036: case eval_is_multUnordered "testid" "" tm thy of
neuper@41924: SOME (_, Const ("HOL.Trueprop", _) $
neuper@41922: (Const ("HOL.eq", _) $
neuper@38036: (Const ("Poly.is'_multUnordered", _) $ _) $
neuper@41928: Const ("HOL.True", _))) => ()
neuper@38036: | _ => error "poly.sml diff. eval_is_multUnordered";
neuper@38036:
neuper@38040: "----- rewrite_set_ STILL DIDN'T WORK";
neuper@38040: val SOME (t, _) = rewrite_set_ thy true order_mult_ t;
walther@59868: UnparseC.term t;
neuper@38036:
neuper@38036: "-------- examples from textbook Schalk I ---------------";
neuper@38036: "-------- examples from textbook Schalk I ---------------";
neuper@38036: "-------- examples from textbook Schalk I ---------------";
neuper@38036: "-----SPB Schalk I p.63 No.267b ---";
neuper@42395: val t = str2term "(5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1)";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 1";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.63 No.275b ---";
neuper@42395: val t = str2term "(3*x^^^2 - 2*x*y + y^^^2) * (x^^^2 - 2*y^^^2)";
neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if (UnparseC.term t) = ("3 * x ^^^ 4 + -2 * x ^^^ 3 * y + -5 * x ^^^ 2 * y ^^^ 2 + " ^
neuper@42395: "4 * x * y ^^^ 3 +\n-2 * y ^^^ 4")
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 2";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.63 No.279b ---";
neuper@42395: val t = str2term "(x-a)*(x-b)*(x-c)*(x-d)";
neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if (UnparseC.term t) =
neuper@42395: ("a * b * c * d + -1 * a * b * c * x + -1 * a * b * d * x + a * b * x ^^^ 2 +\n" ^
neuper@42395: "-1 * a * c * d * x +\na * c * x ^^^ 2 +\na * d * x ^^^ 2 +\n-1 * a * x ^^^ 3 +\n" ^
neuper@42395: "-1 * b * c * d * x +\nb * c * x ^^^ 2 +\nb * d * x ^^^ 2 +\n-1 * b * x ^^^ 3 +\n" ^
neuper@42395: "c * d * x ^^^ 2 +\n-1 * c * x ^^^ 3 +\n-1 * d * x ^^^ 3 +\nx ^^^ 4")
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 3";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.63 No.291 ---";
neuper@42395: val t = str2term "(5+96*x^^^3+8*x*(-4+(7- 3*x)*4*x))*(5*(2- 3*x)- (-15*x*(-8*x- 5)))";
neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if (UnparseC.term t) = "50 + -770 * x + 4520 * x ^^^ 2 + -16320 * x ^^^ 3 + -26880 * x ^^^ 4"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 4";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.64 No.295c ---";
neuper@42395: val t = str2term "(13*a^^^4*b^^^9*c - 12*a^^^3*b^^^6*c^^^9)^^^2";
neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if (UnparseC.term t) = ("169 * a ^^^ 8 * b ^^^ 18 * c ^^^ 2 + -312 * a ^^^ 7 * b ^^^ 15 * c ^^^ 10" ^
neuper@42395: " +\n144 * a ^^^ 6 * b ^^^ 12 * c ^^^ 18")
neuper@42395: then ()else error "poly.sml: diff.behav. in make_polynomial 5";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.64 No.299a ---";
neuper@42395: val t = str2term "(x - y)*(x + y)";
neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if (UnparseC.term t) = "x ^^^ 2 + -1 * y ^^^ 2"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 6";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.64 No.300c ---";
neuper@42395: val t = str2term "(3*x^^^2*y - 1)*(3*x^^^2*y + 1)";
neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if (UnparseC.term t) = "-1 + 9 * x ^^^ 4 * y ^^^ 2"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 7";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.64 No.302 ---";
neuper@37906: val t = str2term
neuper@42395: "(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@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "0"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 8";
neuper@42395: (* RL?MG?: Bei Berechnung sollte 3 mal real_plus_minus_binom1_p aus expand_poly verwendet werden *)
neuper@37906:
neuper@38036: "-----SPB Schalk I p.64 No.306a ---";
neuper@37906: val t = str2term "((x^^^2 + 1)*(x^^^2 - 1))^^^2";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "1 + 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 + x ^^^ 8" then ()
neuper@42395: else error "poly.sml: diff.behav. in 2 * x ^^^ 4 + 2 * -2 * x ^^^ 4 = -2 * x ^^^ 4";
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";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "1 + -2 * x ^^^ 4 + x ^^^ 8"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 9b";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.64 No.296a ---";
neuper@37906: val t = str2term "(x - a)^^^3";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "-1 * a ^^^ 3 + 3 * a ^^^ 2 * x + -3 * a * x ^^^ 2 + x ^^^ 3"
neuper@38031: then () else error "poly.sml: diff.behav. in make_polynomial 10";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.64 No.296c ---";
neuper@37906: val t = str2term "(-3*x - 4*y)^^^3";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "-27 * x ^^^ 3 + -108 * x ^^^ 2 * y + -144 * x * y ^^^ 2 + -64 * y ^^^ 3"
neuper@38031: then () else error "poly.sml: diff.behav. in make_polynomial 11";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.62 No.242c ---";
neuper@37906: val t = str2term "x^^^(-4)*(x^^^(-4)*y^^^(-2))^^^(-1)*y^^^(-2)";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "1"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 12";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.60 No.209a ---";
neuper@37906: val t = str2term "a^^^(7-x) * a^^^x";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "a ^^^ 7"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 13";
neuper@37906:
neuper@38036: "-----SPB Schalk I p.60 No.209d ---";
neuper@37906: val t = str2term "d^^^x * d^^^(x+1) * d^^^(2 - 2*x)";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "d ^^^ 3"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 14";
neuper@37906:
neuper@37906: (*---------------------------------------------------------------------*)
neuper@42395: (*---------------- ?RL?Bsple bei denen es Probleme gibt----------------*)
neuper@37906: (*---------------------------------------------------------------------*)
neuper@38036: "-----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)";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "1280 * b ^^^ 4"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 14b";
neuper@37906: (* Richtig - aber Binomische Formel wurde nicht verwendet! *)
neuper@37906:
neuper@37906: (*--------------------------------------------------------------------*)
neuper@37906: (*----------------------- Eigene Beispiele ---------------------------*)
neuper@37906: (*--------------------------------------------------------------------*)
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "a^^^2*a^^^(-2)";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "1" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 15";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "a + a + a";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "3 * a" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 16";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "a + b + b + b";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "a + 3 * b" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 17";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "a^^^2*b*b^^^(-1)";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "a ^^^ 2" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 18";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "a^^^2*a^^^(-2)";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "1" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 19";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "b + a - b";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "a" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 20";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "b * a * a";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "a ^^^ 2 * b" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 21";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "(a^^^2)^^^3";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "a ^^^ 6" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 22";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "x^^^2 * y^^^2 + x * x^^^2 * y";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if UnparseC.term t = "x ^^^ 3 * y + x ^^^ 2 * y ^^^ 2" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 23";
neuper@38036: "-----SPO ---";
wneuper@59188: val t = (Thm.term_of o the o (parse thy)) "a^^^2 * (-a)^^^2";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "a ^^^ 4" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 24";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "a * b * b^^^(-1) + a";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "2 * a" then ()
neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 25";
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "a*c*b^^^(2*n) + 3*a + 5*b^^^(2*n)*c*b";
walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
walther@59868: if (UnparseC.term t) = "3 * a + 5 * b ^^^ (1 + 2 * n) * c + a * b ^^^ (2 * n) * c"
neuper@38031: then () else error "poly.sml: diff.behav. in make_polynomial 26";
neuper@37906:
neuper@42395: (*MG030627 -------------vvv-: Verschachtelte Terme -----------*)
neuper@38036: "-----SPO ---";
neuper@37906: val t = str2term "(1 + (x*y*a) + x)^^^(1 + (x*y*a) + x)";
neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "(1 + x + a * x * y) ^^^ (1 + x + a * x * y)"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 27";(*SPO*)
neuper@42395:
neuper@37906: val t = str2term "(1 + x*(y*z)*zz)^^^(1 + x*(y*z)*zz)";
neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
walther@59868: if UnparseC.term t = "(1 + x * y * z * zz) ^^^ (1 + x * y * z * zz)"
neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 28";
neuper@37906:
neuper@38036: "-------- check pbl 'polynomial simplification' --------";
neuper@38036: "-------- check pbl 'polynomial simplification' --------";
neuper@38036: "-------- check pbl 'polynomial simplification' --------";
neuper@42395: val fmz = ["Term ((5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1))", "normalform N"];
neuper@38036: "-----0 ---";
walther@59997: case Refine.refine fmz ["polynomial", "simplification"]of
walther@59984: [M_Match.Matches (["polynomial", "simplification"], _)] => ()
walther@59968: | _ => error "poly.sml diff.behav. in check pbl, Refine.refine";
neuper@37906: (*...if there is an error, then ...*)
neuper@37906:
neuper@38036: "-----1 ---";
wneuper@59348: (*default_print_depth 7;*)
walther@59997: val pbt = Problem.from_store ["polynomial", "simplification"];
wneuper@59348: (*default_print_depth 3;*)
neuper@37906: (*if there is ...
walther@59984: > val M_Match.NoMatch' {Given=gi, Where=wh, Find=fi,...} = M_Match.match_pbl fmz pbt;
walther@59901: ... then Rewrite.trace_on:*)
neuper@37906:
neuper@38036: "-----2 ---";
walther@59901: Rewrite.trace_on := false;
walther@59984: M_Match.match_pbl fmz pbt;
walther@59901: Rewrite.trace_on := false;
neuper@37906: (*... if there is no rewrite, then there is something wrong with prls*)
neuper@52101:
neuper@38036: "-----3 ---";
wneuper@59348: (*default_print_depth 7;*)
walther@59997: val prls = (#prls o Problem.from_store) ["polynomial", "simplification"];
wneuper@59348: (*default_print_depth 3;*)
neuper@42395: val t = str2term "((5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1)) is_polyexp";
neuper@37926: val SOME (t',_) = rewrite_set_ thy false prls t;
neuper@48760: if t' = @{term True} then ()
neuper@38031: else error "poly.sml: diff.behav. in check pbl 'polynomial..";
neuper@42395: (*... if this works, but --1-- does still NOT work, check types:*)
neuper@37906:
neuper@38036: "-----4 ---";
neuper@42395: (*show_types:=true;*)
neuper@37906: (*
walther@59984: > val M_Match.NoMatch' {Given=gi, Where=wh, Find=fi,...} = M_Match.match_pbl fmz pbt;
neuper@37906: val wh = [False "(t_::real => real) (is_polyexp::real)"]
neuper@37906: ......................^^^^^^^^^^^^...............^^^^*)
walther@59984: val M_Match.Matches' _ = M_Match.match_pbl fmz pbt;
neuper@42395: (*show_types:=false;*)
neuper@37906:
walther@59787:
neuper@38036: "-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
neuper@38036: "-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
neuper@38036: "-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
neuper@42395: val fmz = ["Term ((5*x^^^2 + 3) * (2*x^^^7 + 3) - (3*x^^^5 + 8) * (6*x^^^4 - 1))", "normalform N"];
neuper@37906: val (dI',pI',mI') =
walther@59997: ("Poly",["polynomial", "simplification"],
walther@59997: ["simplification", "for_polynomials"]);
neuper@37906: val p = e_pos'; val c = [];
neuper@37906: val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59787: (*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Add_Given "Term\n ((5 * x ^^^ 2 + 3) * (2 * x ^^^ 7 + 3) -\n (3 * x ^^^ 5 + 8) * (6 * x ^^^ 4 - 1))"*)
walther@59787: (*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Add_Find "normalform N"*)
walther@59787:
walther@59997: (*+* )if I_Model.to_string ctxt (get_obj g_pbl pt (fst p)) =
walther@59997: (*+*) "[\n(0 ,[] ,false ,#Find ,Inc ??.Simplify.normalform ,(??.empty, [])), \n(1 ,[1] ,true ,#Given ,Cor ??.Simplify.Term\n ((5 * x ^^^ 2 + 3) * (2 * x ^^^ 7 + 3) -\n (3 * x ^^^ 5 + 8) * (6 * x ^^^ 4 - 1)) ,(t_t, [(5 * x ^^^ 2 + 3) * (2 * x ^^^ 7 + 3) -\n(3 * x ^^^ 5 + 8) * (6 * x ^^^ 4 - 1)]))]"
walther@59943: (*+*)then () else error "No.267b: I_Model.T CHANGED";
walther@59997: ( *+ ...could not be repaired in child of 7e314dd233fd ?!?*)
walther@59787:
walther@59787: (*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*nxt = Specify_Theory "Poly"*)
walther@59787: (*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Specify_Problem ["polynomial", "simplification"]*)
walther@59787: (*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Specify_Method ["simplification", "for_polynomials"]*)
walther@59787: (*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Apply_Method ["simplification", "for_polynomials"]*)
walther@59787: (*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Rewrite_Set "norm_Poly"*)
walther@59787:
walther@59787: (*+*)if f2str f = "(5 * x ^^^ 2 + 3) * (2 * x ^^^ 7 + 3) -\n(3 * x ^^^ 5 + 8) * (6 * x ^^^ 4 - 1)"
walther@59787: (*+*)then () else error "";
walther@59787:
walther@59787: (*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Empty_Tac: ERROR DETECTED Feb.2020*)
walther@59787:
walther@59787: (*+*)if f2str f = "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
walther@59787: (*+*)then () else error "";
walther@59787:
walther@59790: (*[1], Res* )val (p,_,f,nxt,_,pt) = me nxt p c pt;( *SINCE Feb.2020 LItool.find_next_step without result*)
walther@59787:
walther@59787: (*+*)if f2str f = "17 + 15 * x ^^^ 2 + -48 * x ^^^ 4 + 3 * x ^^^ 5 + 6 * x ^^^ 7 + -8 * x ^^^ 9"
walther@59787: (*+*)then () else error "poly.sml diff.behav. in me Schalk I p.63 No.267b";
walther@59787:
neuper@37906:
neuper@38036: "-------- interSteps for Schalk 299a --------------------";
neuper@38036: "-------- interSteps for Schalk 299a --------------------";
neuper@38036: "-------- interSteps for Schalk 299a --------------------";
s1210629013@55445: reset_states ();
neuper@37906: CalcTree
neuper@42395: [(["Term ((x - y)*(x + (y::real)))", "normalform N"],
walther@59997: ("Poly",["polynomial", "simplification"],
walther@59997: ["simplification", "for_polynomials"]))];
neuper@37906: Iterator 1;
neuper@37906: moveActiveRoot 1;
wneuper@59248: autoCalculate 1 CompleteCalc;
walther@59983: val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906:
walther@59833: interSteps 1 ([1],Res)(* syserror in Detail_Step.go *);
walther@59983: val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@37906: if existpt' ([1,1], Frm) pt then ()
neuper@38031: else error "poly.sml: interSteps doesnt work again 1";
neuper@37906:
walther@59833: interSteps 1 ([1,1],Res)(* syserror in Detail_Step.go *);
walther@59983: val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
neuper@42395: (*============ inhibit exn WN120316 ==============================================
neuper@37906: if existpt' ([1,1,1], Frm) pt then ()
neuper@38031: else error "poly.sml: interSteps doesnt work again 2";
neuper@42395: ============ inhibit exn WN120316 ==============================================*)
neuper@37906:
neuper@38036: "-------- norm_Poly NOT COMPLETE ------------------------";
neuper@38036: "-------- norm_Poly NOT COMPLETE ------------------------";
neuper@38036: "-------- norm_Poly NOT COMPLETE ------------------------";
wneuper@59529: val thy = @{theory Simplify};
wneuper@59529:
wneuper@59529: val SOME (f',_) = rewrite_set_ thy false norm_Poly
neuper@42395: (str2term "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben");
walther@59868: if UnparseC.term f' = "L = 2 * 2 * (k + -2 * q) + senkrecht + oben"
neuper@42395: then ((*norm_Poly NOT COMPLETE -- TODO MG*))
neuper@42395: else error "norm_Poly changed behavior";
neuper@38036:
neuper@38036: "-------- ord_make_polynomial ---------------------------";
neuper@38036: "-------- ord_make_polynomial ---------------------------";
neuper@38036: "-------- 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@42395: if ord_make_polynomial true thy [] (t1, t2) then ()
neuper@38031: else 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)";
wneuper@59592: val NONE = rewrite_set_ (@{theory "Isac_Knowledge"}) 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: