walther@60278: (* testexamples for Poly, polynomials neuper@37906: author: Matthias Goldgruber 2003 neuper@37906: (c) due to copyright terms neuper@37906: 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: walther@60318: "-----------------------------------------------------------------------------------------------"; walther@60318: "-----------------------------------------------------------------------------------------------"; walther@60318: "table of contents -----------------------------------------------------------------------------"; walther@60318: "-----------------------------------------------------------------------------------------------"; walther@60318: "-------- survey on parallel rewrite-breakers AND code with @{print} ---------------------------"; walther@60318: "-------- thm sym_real_mult_minus1 loops with new numerals -------------------------------------"; walther@60318: "-------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) ----------------------------"; walther@60318: "-------- eval_ for is_expanded_in, is_poly_in, has_degree_in ----------------------------------"; walther@60318: "-------- investigate (new 2002) uniary minus --------------------------------------------------"; walther@60318: "-------- rebuild fun is_addUnordered (1 + 2 * x \ 4 + - 4 * x \ 4 + x \ 8) ---------------------"; walther@60318: "-------- examples from textbook Schalk I ------------------------------------------------------"; walther@60318: "-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------"; walther@60318: "-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------"; walther@60318: "-------- check pbl 'polynomial simplification' -----------------------------------------------"; walther@60318: "-------- me 'poly. simpl.' Schalk I p.63 No.267b ----------------------------------------------"; walther@60318: "-------- interSteps for Schalk 299a -----------------------------------------------------------"; walther@60318: "-------- norm_Poly NOT COMPLETE ---------------------------------------------------------------"; walther@60318: "-------- ord_make_polynomial ------------------------------------------------------------------"; walther@60318: "-----------------------------------------------------------------------------------------------"; walther@60318: "-----------------------------------------------------------------------------------------------"; walther@60318: "-----------------------------------------------------------------------------------------------"; neuper@37906: neuper@37906: walther@60318: "-------- survey on parallel rewrite-breakers AND code with @{print} ---------------------------"; walther@60318: "-------- survey on parallel rewrite-breakers AND code with @{print} ---------------------------"; walther@60318: "-------- survey on parallel rewrite-breakers AND code with @{print} ---------------------------"; walther@60318: (* indentation indicates call hierarchy: walther@60318: "~~~~~ fun is_addUnordered walther@60318: "~~~~~~~ fun is_polyexp walther@60318: "~~~~~~~ fun sort_monoms walther@60318: "~~~~~~~~~ fun sort_monList walther@60318: "~~~~~~~~~~~ fun koeff_degree_ord : term list * term list -> order walther@60318: "~~~~~~~~~~~~~ fun degree_ord : term list * term list -> order walther@60318: "~~~~~~~~~~~~~~~ fun dict_cond_ord : ('a * 'a -> order) -> ('a -> bool) -> 'a list * 'a list -> order walther@60318: "~~~~~~~~~~~~~~~~~ fun var_ord_revPow: term * term -> order walther@60318: "~~~~~~~~~~~~~~~~~~~ fun get_basStr : term -> string used twice --vv walther@60318: "~~~~~~~~~~~~~~~~~~~ fun get_potStr : term -> string used twice --vv walther@60318: "~~~~~~~~~~~~~~~ fun monom_degree : term list -> int walther@60318: "~~~~~~~~~~~~~ fun compare_koeff_ord : term list * term list -> order walther@60318: "~~~~~~~~~~~~~~~ fun get_koeff_of_mon: term list -> term option walther@60318: "~~~~~~~~~~~~~~~~~ fun koeff2ordStr : term option -> string walther@60318: "~~~~~ fun is_multUnordered walther@60318: "~~~~~~~ fun sort_variables walther@60318: "~~~~~~~~~ fun sort_varList walther@60318: "~~~~~~~~~~~ fun var_ord walther@60318: "~~~~~~~~~~~~~ fun get_basStr used twice --^^ walther@60318: "~~~~~~~~~~~~~ fun get_potStr used twice --^^ wneuper@59529: walther@60318: fun int_ord (i1, i2) = walther@60318: (@{print} {a = "int_ord (" ^ string_of_int i1 ^ ", " ^ string_of_int i2 ^ ") = ", z = Int.compare (i1, i2)}; walther@60318: Int.compare (i1, i2) walther@60318: ); walther@60318: fun var_ord (a, b) = walther@60318: (@{print} {a = "var_ord ", a_b = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")", walther@60318: sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"}; walther@60318: prod_ord string_ord string_ord walther@60318: ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b)) walther@60318: ); walther@60318: fun var_ord_revPow (a, b: term) = walther@60318: (@{print} {a = "var_ord_revPow ", at_bt = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")", walther@60318: sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"}; walther@60318: prod_ord string_ord string_ord_rev walther@60318: ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b)) walther@60318: ); walther@60318: fun sort_varList ts = walther@60318: (@{print} {a = "sort_varList", args = UnparseC.terms ts}; walther@60318: sort var_ord ts walther@60318: ); walther@60318: fun dict_cond_ord _ _ ([], []) = (@{print} {a = "dict_cond_ord ([], [])"}; EQUAL) walther@60318: | dict_cond_ord _ _ ([], _ :: _) = (@{print} {a = "dict_cond_ord ([], _ :: _)"}; LESS) walther@60318: | dict_cond_ord _ _ (_ :: _, []) = (@{print} {a = "dict_cond_ord (_ :: _, [])"}; GREATER) walther@60318: | dict_cond_ord elem_ord cond (x :: xs, y :: ys) = walther@60318: (@{print} {a = "dict_cond_ord", args = "(" ^ UnparseC.terms (x :: xs) ^ ", " ^ UnparseC.terms (y :: ys) ^ ")", walther@60318: is_nums = "(" ^ LibraryC.bool2str (cond x) ^ ", " ^ LibraryC.bool2str (cond y) ^ ")"}; walther@60318: case (cond x, cond y) of walther@60318: (false, false) => walther@60318: (case elem_ord (x, y) of walther@60318: EQUAL => dict_cond_ord elem_ord cond (xs, ys) walther@60318: | ord => ord) walther@60318: | (false, true) => dict_cond_ord elem_ord cond (x :: xs, ys) walther@60318: | (true, false) => dict_cond_ord elem_ord cond (xs, y :: ys) walther@60318: | (true, true) => dict_cond_ord elem_ord cond (xs, ys) walther@60318: ); walther@60318: fun compare_koeff_ord (xs, ys) = walther@60318: (@{print} {a = "compare_koeff_ord ", ats_bts = "(" ^ UnparseC.terms xs ^ ", " ^ UnparseC.terms ys ^ ")", walther@60318: sort_args = "(" ^ (koeff2ordStr o get_koeff_of_mon) xs ^ ", " ^ (koeff2ordStr o get_koeff_of_mon) ys ^ ")"}; walther@60318: string_ord walther@60318: ((koeff2ordStr o get_koeff_of_mon) xs, walther@60318: (koeff2ordStr o get_koeff_of_mon) ys) walther@60318: ); walther@60318: fun var_ord (a,b: term) = walther@60318: (@{print} {a = "var_ord ", a_b = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")", walther@60318: sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"}; walther@60318: prod_ord string_ord string_ord walther@60318: ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b)) walther@60318: ); walther@60318: *) walther@60318: walther@60318: walther@60318: "-------- thm sym_real_mult_minus1 loops with new numerals -------------------------------------"; walther@60318: "-------- thm sym_real_mult_minus1 loops with new numerals -------------------------------------"; walther@60318: "-------- thm sym_real_mult_minus1 loops with new numerals -------------------------------------"; walther@60318: (* thus ^^^^^^^^^^^^^^^^^^^^^^^^ excluded from rls. walther@60318: walther@60318: sym_real_mult_minus1 = "- ?z = - 1 * ?z" *) walther@60318: @{thm real_mult_minus1}; (* = "- 1 * ?z = - ?z" *) walther@60318: val thm_isac = ThmC.sym_thm @{thm real_mult_minus1}; (* = "- ?z = - 1 * ?z" *) walther@60318: val SOME t_isac = TermC.parseNEW @{context} "3 * a + - 1 * (2 * a):: real"; walther@60318: Walther@60521: val SOME (t', []) = rewrite_ @{context} tless_true Rule_Set.empty true thm_isac t_isac; walther@60329: if UnparseC.term t' = "3 * a + - 1 * 1 * (2 * a)" then ((*thm did NOT apply to Free ("- 1", _)*)) walther@60318: else error "thm - ?z = - 1 * ?z loops with new numerals"; walther@60318: walther@60318: walther@60318: "-------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) ----------------------------"; walther@60318: "-------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) ----------------------------"; walther@60318: "-------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) ----------------------------"; Walther@60521: val thy = Proof_Context.init_global @{theory Partial_Fractions} Walther@60521: val expr = TermC.parseNEW' thy "((-8 - 2*x + x \ 2) has_degree_in x) = 2"; walther@60336: val SOME (Const (\<^const_name>\True\, _), []) = rewrite_set_ thy false PolyEq_prls expr; wneuper@59522: Walther@60521: val expr = TermC.parseNEW' thy "((-8 - 2*AA + AA \ 2) has_degree_in AA) = 2"; walther@60336: val SOME (Const (\<^const_name>\True\, _), []) = rewrite_set_ thy false PolyEq_prls expr; wneuper@59522: walther@60318: "-------- eval_ for is_expanded_in, is_poly_in, has_degree_in ----------------------------------"; walther@60318: "-------- eval_ for is_expanded_in, is_poly_in, has_degree_in ----------------------------------"; walther@60318: "-------- eval_ for is_expanded_in, is_poly_in, has_degree_in ----------------------------------"; Walther@60521: val t = TermC.parseNEW' 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@60317: if UnparseC.term t' = "- 8 - 2 * x + x \ 2 is_expanded_in x = True" walther@60317: 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: Walther@60521: val thy = Proof_Context.init_global @{theory Partial_Fractions} Walther@60521: val t = TermC.parseNEW' 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@60317: if UnparseC.term t' = "- 8 - 2 * AA + AA \ 2 is_expanded_in AA = True" walther@60317: 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: Walther@60521: val t = TermC.parseNEW' 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@60242: if UnparseC.term t' = "8 + 2 * x + x \ 2 is_poly_in x = True" walther@60242: andalso id = "8 + 2 * x + x \ 2 is_poly_in x = True" wneuper@59522: then () else error "is_poly_in x ..changed"; wneuper@59522: Walther@60521: val t = TermC.parseNEW' 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@60242: if UnparseC.term t' = "8 + 2 * AA + AA \ 2 is_poly_in AA = True" walther@60242: 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: Walther@60521: val thy = Proof_Context.init_global @{theory Partial_Fractions} Walther@60521: val expr = TermC.parseNEW' thy "((-8 - 2*x + x \ 2) has_degree_in x) = 2"; wenzelm@60309: val SOME (Const (\<^const_name>\True\, _), []) = rewrite_set_ thy false PolyEq_prls expr; wneuper@59522: Walther@60521: val expr = TermC.parseNEW' thy "((-8 - 2*AA + AA \ 2) has_degree_in AA) = 2"; wenzelm@60309: val SOME (Const (\<^const_name>\True\, _), []) = rewrite_set_ thy false PolyEq_prls expr; wneuper@59522: walther@60318: "-------- investigate (new 2002) uniary minus --------------------------------------------------"; walther@60318: "-------- investigate (new 2002) uniary minus --------------------------------------------------"; walther@60318: "-------- investigate (new 2002) uniary minus --------------------------------------------------"; wenzelm@60203: val t = Thm.prop_of @{thm real_diff_0}; (*"0 - ?x = - ?x"*) Walther@60650: TermC.atom_trace_detail @{context} 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 wenzelm@60309: Const (\<^const_name>\Trueprop\, _) $ wenzelm@60309: (Const (\<^const_name>\HOL.eq\, _) $ wenzelm@60309: (Const (\<^const_name>\minus\, _) $ Const (\<^const_name>\Groups.zero\, _) $ wneuper@59117: Var (("x", 0), _)) $ wenzelm@60309: (Const (\<^const_name>\uminus\, _) $ Var (("x", 0), _))) => () neuper@42395: | _ => error "internal representation of \"0 - ?x = - ?x\" changed"; neuper@37906: walther@60318: Walther@60521: val t = TermC.parseNEW' thy "- 1"; Walther@60650: TermC.atom_trace_detail @{context} t; wneuper@59117: (* wneuper@59117: *** walther@60329: *** Free (- 1, real) wneuper@59117: *** wneuper@59117: *) neuper@42395: case t of walther@60336: Const (\<^const_name>\uminus\, _) $ Const (\<^const_name>\one_class.one\, _) => () 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 -------------------------------------------*) Walther@60521: val t = TermC.parseNEW' thy "-x"; Walther@60650: TermC.atom_trace_detail @{context} t; neuper@37906: (**** ------------- neuper@37906: *** Free ( -x, real)*) neuper@42395: case t of wenzelm@60309: Const (\<^const_name>\uminus\, _) $ Free ("x", _) => () neuper@42395: | _ => error "internal representation of \"-x\" changed"; neuper@42395: (*----------------------------------- vvvvv -------------------------------------------*) Walther@60521: val t = TermC.parseNEW' thy "- x"; Walther@60650: TermC.atom_trace_detail @{context} t; neuper@37906: (**** ------------- neuper@37906: *** Free ( -x, real) !!!!!!!!!!!!!!!!!!!!!!!! is the same !!!*) neuper@42395: case t of wenzelm@60309: Const (\<^const_name>\uminus\, _) $ Free ("x", _) => () neuper@42395: | _ => error "internal representation of \"- x\" changed"; neuper@42395: (*----------------------------------- vvvvvv ------------------------------------------*) Walther@60521: val t = TermC.parseNEW' thy "-(x)"; Walther@60650: TermC.atom_trace_detail @{context} t; neuper@37906: (**** ------------- neuper@37906: *** Free ( -x, real)*) neuper@42395: case t of wenzelm@60309: Const (\<^const_name>\uminus\, _) $ Free ("x", _) => () neuper@42395: | _ => error "internal representation of \"-(x)\" changed"; neuper@37906: walther@60318: walther@60318: "-------- rebuild fun is_addUnordered (1 + 2 * x \ 4 + - 4 * x \ 4 + x \ 8) ---------------------"; walther@60318: "-------- rebuild fun is_addUnordered (1 + 2 * x \ 4 + - 4 * x \ 4 + x \ 8) ---------------------"; walther@60318: "-------- rebuild fun is_addUnordered (1 + 2 * x \ 4 + - 4 * x \ 4 + x \ 8) ---------------------"; walther@60318: (* indentation partially indicates call hierarchy: walther@60318: "~~~~~ fun is_addUnordered walther@60318: "~~~~~~~ fun is_polyexp walther@60318: "~~~~~~~ fun sort_monoms walther@60318: "~~~~~~~~~ fun sort_monList walther@60318: "~~~~~~~~~~~ fun koeff_degree_ord walther@60318: "~~~~~~~~~~~~~ fun degree_ord walther@60318: "~~~~~~~~~~~~~~~ fun dict_cond_ord walther@60318: "~~~~~~~~~~~~~~~~~ fun var_ord_revPow walther@60318: "~~~~~~~~~~~~~~~~~~~ fun get_basStr used twice --vv walther@60318: "~~~~~~~~~~~~~~~~~~~ fun get_potStr used twice --vv walther@60318: "~~~~~~~~~~~~~~~ fun monom_degree walther@60318: "~~~~~~~~~~~~~ fun compare_koeff_ord walther@60318: "~~~~~~~~~~~~~~~ fun get_koeff_of_mon walther@60318: "~~~~~~~~~~~~~~~~~ fun koeff2ordStr walther@60318: "~~~~~ fun is_multUnordered walther@60318: "~~~~~~~ fun sort_variables walther@60318: "~~~~~~~~~ fun sort_varList walther@60318: "~~~~~~~~~~~ fun var_ord walther@60318: "~~~~~~~~~~~~~ fun get_basStr used twice --^^ walther@60318: "~~~~~~~~~~~~~ fun get_potStr used twice --^^ walther@60318: *) Walther@60565: val t = TermC.parse_test @{context} "(1 + 2 * x \ 4 + - 4 * x \ 4 + x \ 8) is_addUnordered"; walther@60318: Walther@60521: eval_is_addUnordered "xxx" "yyy" t @{context}; walther@60318: "~~~~~ fun eval_is_addUnordered , args:"; val ((thmid:string), _, walther@60336: (t as (Const (\<^const_name>\is_addUnordered\, _) $ arg)), thy) = Walther@60521: ("xxx", "yyy", t, @{context}); walther@60318: walther@60318: (*if*) is_addUnordered arg; walther@60318: "~~~~~ fun is_addUnordered , args:"; val (t) = (arg); walther@60318: ((is_polyexp t) andalso not (t = sort_monoms t)); walther@60318: walther@60318: (t = sort_monoms t); walther@60318: "~~~~~~~ fun sort_monoms , args:"; val (t) = (t); walther@60318: val ll = map monom2list (poly2list t); walther@60318: val lls = walther@60318: walther@60318: sort_monList ll; walther@60318: "~~~~~~~~~ fun sort_monList , args:"; val (ll) = (ll); walther@60318: val xxx = walther@60318: walther@60318: sort koeff_degree_ord ll(*return value*); walther@60318: "~~~~~~~~~~~ fun koeff_degree_ord , args:"; val (ll) = (ll); walther@60318: koeff_degree_ord: term list * term list -> order; walther@60318: (*we check all elements at once..*) walther@60318: val eee1 = ll |> nth 1; walther@60318: val eee2 = ll |> nth 2; walther@60318: val eee3 = ll |> nth 3; walther@60318: val eee3 = ll |> nth 3; walther@60318: val eee4 = ll |> nth 4; walther@60318: walther@60318: if UnparseC.terms eee1 = "[\"1\"]" then () else error "eee1 CHANGED"; walther@60318: if UnparseC.terms eee2 = "[\"2\", \"x \ 4\"]" then () else error "eee2 CHANGED"; walther@60318: if UnparseC.terms eee3 = "[\"- 4\", \"x \ 4\"]" then () else error "eee3 CHANGED"; walther@60318: if UnparseC.terms eee4 = "[\"x \ 8\"]" then () else error "eee4 CHANGED"; walther@60318: walther@60318: if koeff_degree_ord (eee1, eee1) = EQUAL then () else error "(eee1, eee1) CHANGED"; walther@60318: if koeff_degree_ord (eee1, eee2) = LESS then () else error "(eee1, eee2) CHANGED"; walther@60318: if koeff_degree_ord (eee1, eee3) = LESS then () else error "(eee1, eee3) CHANGED"; walther@60318: if koeff_degree_ord (eee1, eee4) = LESS then () else error "(eee1, eee4) CHANGED"; walther@60318: walther@60318: if koeff_degree_ord (eee2, eee1) = GREATER then () else error "(eee2, eee1) CHANGED"; walther@60318: if koeff_degree_ord (eee2, eee2) = EQUAL then () else error "(eee2, eee4) CHANGED"; walther@60318: if koeff_degree_ord (eee2, eee3) = LESS then () else error "(eee2, eee3) CHANGED"; walther@60318: if koeff_degree_ord (eee2, eee4) = LESS then () else error "(eee2, eee4) CHANGED"; walther@60318: walther@60318: if koeff_degree_ord (eee3, eee1) = GREATER then () else error "(eee3, eee1) CHANGED"; walther@60318: if koeff_degree_ord (eee3, eee2) = GREATER then () else error "(eee3, eee4) CHANGED"; walther@60318: if koeff_degree_ord (eee3, eee3) = EQUAL then () else error "(eee3, eee3) CHANGED"; walther@60318: if koeff_degree_ord (eee3, eee4) = LESS then () else error "(eee3, eee4) CHANGED"; walther@60318: walther@60318: if koeff_degree_ord (eee4, eee1) = GREATER then () else error "(eee4, eee1) CHANGED"; walther@60318: if koeff_degree_ord (eee4, eee2) = GREATER then () else error "(eee4, eee4) CHANGED"; walther@60318: if koeff_degree_ord (eee4, eee3) = GREATER then () else error "(eee4, eee3) CHANGED"; walther@60318: if koeff_degree_ord (eee4, eee4) = EQUAL then () else error "(eee4, eee4) CHANGED"; walther@60318: walther@60318: "~~~~~~~~~~~~~ fun degree_ord , args:"; val () = (); walther@60318: degree_ord: term list * term list -> order; walther@60318: walther@60318: if degree_ord (eee1, eee1) = EQUAL then () else error "degree_ord (eee1, eee1) CHANGED"; walther@60318: if degree_ord (eee1, eee2) = LESS then () else error "degree_ord (eee1, eee2) CHANGED"; walther@60318: if degree_ord (eee1, eee3) = LESS then () else error "degree_ord (eee1, eee3) CHANGED"; walther@60318: if degree_ord (eee1, eee4) = LESS then () else error "degree_ord (eee1, eee4) CHANGED"; walther@60318: walther@60318: if degree_ord (eee2, eee1) = GREATER then () else error "degree_ord (eee2, eee1) CHANGED"; walther@60318: if degree_ord (eee2, eee2) = EQUAL then () else error "degree_ord (eee2, eee4) CHANGED"; walther@60318: if degree_ord (eee2, eee3) = EQUAL then () else error "degree_ord (eee2, eee3) CHANGED"; walther@60318: if degree_ord (eee2, eee4) = LESS then () else error "degree_ord (eee2, eee4) CHANGED"; walther@60318: walther@60318: if degree_ord (eee3, eee1) = GREATER then () else error "degree_ord (eee3, eee1) CHANGED"; walther@60318: if degree_ord (eee3, eee2) = EQUAL then () else error "degree_ord (eee3, eee4) CHANGED"; walther@60318: if degree_ord (eee3, eee3) = EQUAL then () else error "degree_ord (eee3, eee3) CHANGED"; walther@60318: if degree_ord (eee3, eee4) = LESS then () else error "degree_ord (eee3, eee4) CHANGED"; walther@60318: walther@60318: if degree_ord (eee4, eee1) = GREATER then () else error "degree_ord (eee4, eee1) CHANGED"; walther@60318: if degree_ord (eee4, eee2) = GREATER then () else error "degree_ord (eee4, eee4) CHANGED"; walther@60318: if degree_ord (eee4, eee3) = GREATER then () else error "degree_ord (eee4, eee3) CHANGED"; walther@60318: if degree_ord (eee4, eee4) = EQUAL then () else error "degree_ord (eee4, eee4) CHANGED"; walther@60318: walther@60318: "~~~~~~~~~~~~~~~ fun dict_cond_ord , args:"; val () = (); walther@60318: dict_cond_ord: (term * term -> order) -> (term -> bool) -> term list * term list -> order; walther@60318: dict_cond_ord var_ord_revPow: (term -> bool) -> term list * term list -> order; walther@60318: dict_cond_ord var_ord_revPow is_nums: term list * term list -> order; walther@60318: val xxx = dict_cond_ord var_ord_revPow is_nums; walther@60318: (* output from: walther@60318: fun var_ord_revPow (a,b: term) = walther@60318: (@ {print} {a = "var_ord_revPow ", ab = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")"}; walther@60318: @ {print} {z = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"}; walther@60318: prod_ord string_ord string_ord_rev walther@60318: ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b))); walther@60318: *) walther@60318: if xxx (eee1, eee1) = EQUAL then () else error "dict_cond_ord ..(eee1, eee1) CHANGED"; walther@60318: if xxx (eee1, eee2) = LESS then () else error "dict_cond_ord ..(eee1, eee2) CHANGED"; walther@60318: if xxx (eee1, eee3) = LESS then () else error "dict_cond_ord ..(eee1, eee3) CHANGED"; walther@60318: if xxx (eee1, eee4) = LESS then () else error "dict_cond_ord ..(eee1, eee4) CHANGED"; walther@60318: (*-------------------------------------------------------------------------------------*) walther@60318: if xxx (eee2, eee1) = GREATER then () else error "dict_cond_ord ..(eee2, eee1) CHANGED"; walther@60318: if xxx (eee2, eee2) = EQUAL then () else error "dict_cond_ord ..(eee2, eee2) CHANGED"; walther@60318: if xxx (eee2, eee3) = EQUAL then () else error "dict_cond_ord ..(eee2, eee3) CHANGED"; walther@60318: if xxx (eee2, eee4) = GREATER then () else error "dict_cond_ord ..(eee2, eee4) CHANGED"; walther@60318: (*-------------------------------------------------------------------------------------*) walther@60318: if xxx (eee3, eee1) = GREATER then () else error "dict_cond_ord ..(eee3, eee1) CHANGED"; walther@60318: if xxx (eee3, eee2) = EQUAL then () else error "dict_cond_ord ..(eee3, eee2) CHANGED"; walther@60318: if xxx (eee3, eee3) = EQUAL then () else error "dict_cond_ord ..(eee3, eee3) CHANGED"; walther@60318: if xxx (eee3, eee4) = GREATER then () else error "dict_cond_ord ..(eee3, eee4) CHANGED"; walther@60318: (*-------------------------------------------------------------------------------------*) walther@60318: if xxx (eee4, eee1) = GREATER then () else error "dict_cond_ord ..(eee4, eee1) CHANGED"; walther@60318: if xxx (eee4, eee2) = LESS then () else error "dict_cond_ord ..(eee4, eee2) CHANGED"; walther@60318: if xxx (eee4, eee3) = LESS then () else error "dict_cond_ord ..(eee4, eee3) CHANGED"; walther@60318: if xxx (eee4, eee4) = EQUAL then () else error "dict_cond_ord ..(eee4, eee4) CHANGED"; walther@60318: (*-------------------------------------------------------------------------------------*) walther@60318: walther@60318: "~~~~~~~~~~~~~~~ fun monom_degree , args:"; val () = (); walther@60318: (* we check all at once//*) walther@60318: if monom_degree eee1 = 0 then () else error "monom_degree eee1 CHANGED"; walther@60318: if monom_degree eee2 = 4 then () else error "monom_degree eee2 CHANGED"; walther@60318: if monom_degree eee3 = 4 then () else error "monom_degree eee3 CHANGED"; walther@60318: if monom_degree eee4 = 8 then () else error "monom_degree eee4 CHANGED"; walther@60318: walther@60318: "~~~~~~~~~~~~~ fun compare_koeff_ord , args:"; val () = (); walther@60318: compare_koeff_ord: term list * term list -> order; walther@60318: (* we check all at once//*) walther@60318: if compare_koeff_ord (eee1, eee1) = EQUAL then () else error "_koeff_ord (eee1, eee1) CHANGED"; walther@60318: if compare_koeff_ord (eee1, eee2) = LESS then () else error "_koeff_ord (eee1, eee2) CHANGED"; walther@60318: if compare_koeff_ord (eee1, eee3) = LESS then () else error "_koeff_ord (eee1, eee3) CHANGED"; walther@60318: if compare_koeff_ord (eee1, eee4) = GREATER then () else error "_koeff_ord (eee1, eee4) CHANGED"; walther@60318: walther@60318: if compare_koeff_ord (eee2, eee1) = GREATER then () else error "_koeff_ord (eee2, eee1) CHANGED"; walther@60318: if compare_koeff_ord (eee2, eee2) = EQUAL then () else error "_koeff_ord (eee2, eee2) CHANGED"; walther@60318: if compare_koeff_ord (eee2, eee3) = LESS then () else error "_koeff_ord (eee2, eee3) CHANGED"; walther@60318: if compare_koeff_ord (eee2, eee4) = GREATER then () else error "_koeff_ord (eee2, eee4) CHANGED"; walther@60318: walther@60318: if compare_koeff_ord (eee3, eee1) = GREATER then () else error "_koeff_ord (eee3, eee1) CHANGED"; walther@60318: if compare_koeff_ord (eee3, eee2) = GREATER then () else error "_koeff_ord (eee3, eee2) CHANGED"; walther@60318: if compare_koeff_ord (eee3, eee3) = EQUAL then () else error "_koeff_ord (eee3, eee3) CHANGED"; walther@60318: if compare_koeff_ord (eee3, eee4) = GREATER then () else error "_koeff_ord (eee3, eee4) CHANGED"; walther@60318: walther@60318: if compare_koeff_ord (eee4, eee1) = LESS then () else error "_koeff_ord (eee4, eee1) CHANGED"; walther@60318: if compare_koeff_ord (eee4, eee2) = LESS then () else error "_koeff_ord (eee4, eee2) CHANGED"; walther@60318: if compare_koeff_ord (eee4, eee3) = LESS then () else error "_koeff_ord (eee4, eee3) CHANGED"; walther@60318: if compare_koeff_ord (eee4, eee4) = EQUAL then () else error "_koeff_ord (eee4, eee4) CHANGED"; walther@60318: walther@60318: "~~~~~~~~~~~~~~~ fun get_koeff_of_mon , args:"; val () = (); walther@60318: get_koeff_of_mon: term list -> term option; walther@60318: walther@60318: val SOME xxx1 = get_koeff_of_mon eee1; walther@60318: val SOME xxx2 = get_koeff_of_mon eee2; walther@60318: val SOME xxx3 = get_koeff_of_mon eee3; walther@60318: val NONE = get_koeff_of_mon eee4; walther@60318: walther@60318: if UnparseC.term xxx1 = "1" then () else error "get_koeff_of_mon eee1 CHANGED"; walther@60318: if UnparseC.term xxx2 = "2" then () else error "get_koeff_of_mon eee2 CHANGED"; walther@60318: if UnparseC.term xxx3 = "- 4" then () else error "get_koeff_of_mon eee3 CHANGED"; walther@60318: walther@60318: "~~~~~~~~~~~~~~~~~ fun koeff2ordStr , args:"; val () = (); walther@60318: koeff2ordStr: term option -> string; walther@60318: if koeff2ordStr (SOME xxx1) = "1" then () else error "koeff2ordStr eee1 CHANGED"; walther@60318: if koeff2ordStr (SOME xxx2) = "2" then () else error "koeff2ordStr eee2 CHANGED"; walther@60318: if koeff2ordStr (SOME xxx3) = "40" then () else error "koeff2ordStr eee3 CHANGED"; walther@60318: if koeff2ordStr NONE = "---" then () else error "koeff2ordStr eee4 CHANGED"; walther@60318: walther@60318: walther@60318: "-------- examples from textbook Schalk I ------------------------------------------------------"; walther@60318: "-------- examples from textbook Schalk I ------------------------------------------------------"; walther@60318: "-------- examples from textbook Schalk I ------------------------------------------------------"; neuper@38036: "-----SPB Schalk I p.63 No.267b ---"; Walther@60565: val t = TermC.parse_test @{context} "(5*x \ 2 + 3) * (2*x \ 7 + 3) - (3*x \ 5 + 8) * (6*x \ 4 - 1)"; walther@60318: val SOME (t, _) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60318: if UnparseC.term t = "17 + 15 * x \ 2 + - 48 * x \ 4 + 3 * x \ 5 + 6 * x \ 7 +\n- 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "(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@60318: if UnparseC.term t = walther@60318: "3 * x \ 4 + - 2 * x \ 3 * y + - 5 * x \ 2 * y \ 2 +\n4 * 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "(x-a)*(x-b)*(x-c)*(x-d)"; neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; walther@60318: if UnparseC.term t = walther@60318: ("a * b * c * d + - 1 * a * b * c * x + - 1 * a * b * d * x +\na * b * x \ 2 +\n" ^ walther@60318: "- 1 * a * c * d * x +\na * c * x \ 2 +\na * d * x \ 2 +\n- 1 * a * x \ 3 +\n" ^ walther@60318: "- 1 * b * c * d * x +\nb * c * x \ 2 +\nb * d * x \ 2 +\n- 1 * b * x \ 3 +\nc" ^ walther@60318: " * 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"; walther@60318: (*associate poly*) neuper@37906: neuper@38036: "-----SPB Schalk I p.63 No.291 ---"; Walther@60565: val t = TermC.parse_test @{context} "(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@60318: if UnparseC.term t = "50 + - 770 * x + 4520 * x \ 2 + - 16320 * x \ 3 +\n- 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "(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@60318: if UnparseC.term t = walther@60318: "169 * a \ 8 * b \ 18 * c \ 2 +\n- 312 * a \ 7 * b \ 15 * c \ 10 +\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 ---"; Walther@60565: val t = TermC.parse_test @{context} "(x - y)*(x + y)"; neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; walther@60318: 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "(3*x \ 2*y - 1)*(3*x \ 2*y + 1)"; neuper@42395: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; walther@60318: 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 ---"; Walther@60565: val t = TermC.parse_test @{context} walther@60242: "(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 ---"; Walther@60565: val t = TermC.parse_test @{context} "((x \ 2 + 1)*(x \ 2 - 1)) \ 2"; walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60318: if UnparseC.term t = "1 + 2 * x \ 4 + 2 * - 2 * x \ 4 + x \ 8" then () walther@60329: 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*) Walther@60565: val t = TermC.parse_test @{context} "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@60318: 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "(x - a) \ 3"; walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60318: Walther@60565: val NONE = eval_is_even "aaa" "bbb" (TermC.parse_test @{context} "3::real") "ccc"; walther@60318: walther@60318: 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "(-3*x - 4*y) \ 3"; walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60318: if UnparseC.term t = "- 27 * x \ 3 + - 108 * x \ 2 * y + - 144 * x * y \ 2 +\n- 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "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@60318: 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "a \ (7-x) * a \ x"; walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60242: 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "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@60242: if UnparseC.term t = "d \ 3" neuper@42395: then () else error "poly.sml: diff.behav. in make_polynomial 14"; neuper@37906: walther@60318: "-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------"; walther@60318: "-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------"; walther@60318: "-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------"; neuper@38036: "-----Schalk I p.64 No.303 ---"; Walther@60565: val t = TermC.parse_test @{context} "(a + 2*b)*(a \ 2 + 4*b \ 2)*(a - 2*b) - (a - 6*b)*(a \ 2 + 36*b \ 2)*(a + 6*b)"; walther@60318: (*SOMETIMES LOOPS---------------------------------------------------------------------------\\*) walther@60318: val SOME (t, _) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60242: 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! *) walther@60318: (*SOMETIMES LOOPS--------------------------------------------------------------------------//*) neuper@37906: walther@60318: "-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------"; walther@60318: "-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------"; walther@60318: "-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------"; neuper@38036: "-----SPO ---"; Walther@60565: val t = TermC.parse_test @{context} "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 ---"; Walther@60565: val t = TermC.parse_test @{context} "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 ---"; Walther@60565: val t = TermC.parse_test @{context} "b * a * a"; walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60242: if UnparseC.term t = "a \ 2 * b" then () neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 21"; neuper@38036: "-----SPO ---"; Walther@60565: val t = TermC.parse_test @{context} "(a \ 2) \ 3"; walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60242: if UnparseC.term t = "a \ 6" then () neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 22"; neuper@38036: "-----SPO ---"; Walther@60565: val t = TermC.parse_test @{context} "x \ 2 * y \ 2 + x * x \ 2 * y"; walther@59868: val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; walther@60242: 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "a * b * b \ (- 1) + a"; Walther@60521: val SOME (t,_) = rewrite_set_ @{context} false make_polynomial t; UnparseC.term t; walther@60318: if UnparseC.term t = "2 * a" then () neuper@38031: else error "poly.sml: diff.behav. in make_polynomial 25"; neuper@38036: "-----SPO ---"; Walther@60565: val t = TermC.parse_test @{context} "a*c*b \ (2*n) + 3*a + 5*b \ (2*n)*c*b"; Walther@60521: val SOME (t,_) = rewrite_set_ @{context} false make_polynomial t; UnparseC.term t; walther@60318: 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 ---"; Walther@60565: val t = TermC.parse_test @{context} "(1 + (x*y*a) + x) \ (1 + (x*y*a) + x)"; Walther@60521: val SOME (t,_) = rewrite_set_ @{context} false make_polynomial t; walther@60242: 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: Walther@60565: val t = TermC.parse_test @{context} "(1 + x*(y*z)*zz) \ (1 + x*(y*z)*zz)"; Walther@60521: val SOME (t,_) = rewrite_set_ @{context} false make_polynomial t; walther@60242: 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: walther@60318: "-------- check pbl 'polynomial simplification' -----------------------------------------------"; walther@60318: "-------- check pbl 'polynomial simplification' -----------------------------------------------"; walther@60318: "-------- check pbl 'polynomial simplification' -----------------------------------------------"; walther@60242: 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@60575: case Refine.xxxxx @{context} 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: walther@60329: "----- 1 ---"; wneuper@59348: (*default_print_depth 7;*) Walther@60559: val pbt = Problem.from_store @{context} ["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:*) walther@60242: walther@60329: "----- 2 ---"; walther@59984: M_Match.match_pbl fmz pbt; Walther@60586: (*... if there is no rewrite, then there is something wrong with where_rls*) neuper@52101: neuper@38036: "-----3 ---"; wneuper@59348: (*default_print_depth 7;*) Walther@60586: val where_rls = (#where_rls o Problem.from_store @{context}) ["polynomial", "simplification"]; wneuper@59348: (*default_print_depth 3;*) Walther@60565: val t = TermC.parse_test @{context} "((5*x \ 2 + 3) * (2*x \ 7 + 3) - (3*x \ 5 + 8) * (6*x \ 4 - 1)) is_polyexp"; Walther@60586: val SOME (t',_) = rewrite_set_ thy false where_rls t; neuper@48760: if t' = @{term True} then () neuper@38031: else error "poly.sml: diff.behav. in check pbl 'polynomial.."; walther@60329: (*... 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)"] walther@60242: ...................... \ \ \ \ ............... \ ^*) walther@59984: val M_Match.Matches' _ = M_Match.match_pbl fmz pbt; neuper@42395: (*show_types:=false;*) neuper@37906: walther@59787: walther@60318: "-------- me 'poly. simpl.' Schalk I p.63 No.267b ----------------------------------------------"; walther@60318: "-------- me 'poly. simpl.' Schalk I p.63 No.267b ----------------------------------------------"; walther@60318: "-------- me 'poly. simpl.' Schalk I p.63 No.267b ----------------------------------------------"; walther@60242: 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 = []; Walther@60571: val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(fmz, (dI',pI',mI'))]; walther@60242: (*[], 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@60242: (*+*) "[\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@60242: (*+*)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@60318: (*+*)if f2str f = "17 + 15 * x \ 2 + - 48 * x \ 4 + 3 * x \ 5 + 6 * x \ 7 +\n- 8 * x \ 9" walther@60329: (*+*)then () else error "poly.sml diff.behav. in me Schalk I p.63 No.267b - 1"; 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: neuper@37906: walther@60318: "-------- interSteps for Schalk 299a -----------------------------------------------------------"; walther@60318: "-------- interSteps for Schalk 299a -----------------------------------------------------------"; walther@60318: "-------- interSteps for Schalk 299a -----------------------------------------------------------"; Walther@60549: States.reset (); Walther@60571: CalcTree @{context} 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@60549: val ((pt,p),_) = States.get_calc 1; Test_Tool.show_pt pt; neuper@37906: walther@59833: interSteps 1 ([1],Res)(* syserror in Detail_Step.go *); Walther@60549: val ((pt,p),_) = States.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@60549: val ((pt,p),_) = States.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: walther@60318: "-------- ord_make_polynomial ------------------------------------------------------------------"; walther@60318: "-------- ord_make_polynomial ------------------------------------------------------------------"; walther@60318: "-------- ord_make_polynomial ------------------------------------------------------------------"; Walther@60565: val t1 = TermC.parse_test @{context} "2 * b + (3 * a + 3 * b)"; Walther@60565: val t2 = TermC.parse_test @{context} "(3 * a + 3 * b) + 2 * b"; neuper@37906: Walther@60594: if ord_make_polynomial true @{context} [] (t1, t2) then () neuper@38031: else error "poly.sml: diff.behav. in ord_make_polynomial"; walther@60318: (*SO: WHY IS THERE NO REWRITING ...*) neuper@37906: Walther@60565: val term = TermC.parse_test @{context} "2*b + (3*a + 3*b)"; Walther@60521: (*+++*)val NONE = rewrite_set_ (Proof_Context.init_global @{theory "Isac_Knowledge"}) false order_add_mult term; walther@60325: (* walther@60325: WHY IS THERE NO REWRITING ?!? walther@60325: most likely reason: Poly.thy and Rationa.thy do AC rewriting in ML, walther@60325: while order_add_mult uses isac's rewriter -- and this is used rarely! walther@60318: *) neuper@37906: