# HG changeset patch # User wneuper # Date 1665294262 -7200 # Node ID f92963a33fe383c042bf4c537a8ac7a90343f49b # Parent 90ea835c07b304a729111aa0315e8f7c12f880d0 eliminate term2str in test/* diff -r 90ea835c07b3 -r f92963a33fe3 src/Tools/isac/BaseDefinitions/termC.sml --- a/src/Tools/isac/BaseDefinitions/termC.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/src/Tools/isac/BaseDefinitions/termC.sml Sun Oct 09 07:44:22 2022 +0200 @@ -589,7 +589,7 @@ fun parse_patt_test thy str = (thy, str) |>> Proof_Context.init_global |-> Proof_Context.read_term_pattern -(**)|> typ_a2real; (** )TODO drop*) + |> Model_Pattern.adapt_term_to_type (Proof_Context.init_global thy) fun str2term str = parse_patt (ThyC.get_theory "Isac_Knowledge") str diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/ADDTESTS/All_Ctxt.thy --- a/test/Tools/isac/ADDTESTS/All_Ctxt.thy Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/ADDTESTS/All_Ctxt.thy Sun Oct 09 07:44:22 2022 +0200 @@ -116,8 +116,8 @@ ML \ "artifically inject assumptions"; val (SOME (iform, cform), SOME (ires, cres)) = Ctree.get_obj Ctree.g_loc pt (fst p); - val ctxt = ContextC.insert_assumptions [TermC.str2term "x < sub_asm_out", - TermC.str2term "a < sub_asm_local"] cres; + val ctxt = ContextC.insert_assumptions [TermC.parse_test @{context} "x < sub_asm_out", + TermC.parse_test @{context} "a < sub_asm_local"] cres; val pt = Ctree.update_loc' pt (fst p) (SOME (iform, cform), SOME (ires, ctxt)); \ diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/ADDTESTS/course/CADGME/example_2.thy --- a/test/Tools/isac/ADDTESTS/course/CADGME/example_2.thy Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/ADDTESTS/course/CADGME/example_2.thy Sun Oct 09 07:44:22 2022 +0200 @@ -43,7 +43,7 @@ text\Apply the Ruleset to a term\ ML \ - val t = str2term "z / (z - 1) + z / (z - \) + 1::real"; + val t = parse_test @{context} "z / (z - 1) + z / (z - \) + 1::real"; val SOME (t', asm) = rewrite_set_ thy true transform t; \ diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform.thy --- a/test/Tools/isac/ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform.thy Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform.thy Sun Oct 09 07:44:22 2022 +0200 @@ -80,7 +80,7 @@ ]; \ ML \ - val t = TermC.str2term "z / (z - 1) + z / (z - \) + 1::real"; + val t = TermC.parse_test @{context} "z / (z - 1) + z / (z - \) + 1::real"; \ ML \ val SOME (t', asm) = Rewrite.rewrite_set_ thy true inverse_Z t; (*rewrite__set_ called with 'Erls' for '|| z || < 1'*) @@ -408,17 +408,17 @@ probably keep these test in test/Tools/isac/... (*mk_prod TermC.empty [];*) -val prod = mk_prod TermC.empty [str2term "x + 123"]; +val prod = mk_prod TermC.empty [parse_test @{context} "x + 123"]; UnparseC.term prod = "x + 123"; -val sol = str2term "[z = 1 / 2, z = -1 / 4]"; +val sol = parse_test @{context} "[z = 1 / 2, z = -1 / 4]"; val sols = HOLogic.dest_list sol; val facs = map fac_from_sol sols; val prod = mk_prod TermC.empty facs; UnparseC.term prod = "(z + -1 * (1 / 2)) * (z + -1 * (-1 / 4))"; val prod = - mk_prod TermC.empty [str2term "x + 1", str2term "x + 2", str2term "x + 3"]; + mk_prod TermC.empty [parse_test @{context} "x + 1", parse_test @{context} "x + 2", parse_test @{context} "x + 3"]; UnparseC.term prod = "(x + 1) * (x + 2) * (x + 3)"; *} *) ML \ @@ -427,7 +427,7 @@ in mk_prod TermC.empty (map fac_from_sol ts) end; \ (* ML {* -val sol = str2term "[z = 1 / 2, z = -1 / 4]"; +val sol = parse_test @{context} "[z = 1 / 2, z = -1 / 4]"; val fs = factors_from_solution sol; UnparseC.term fs = "(z + -1 * (1 / 2)) * (z + -1 * (-1 / 4))" *} *) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/ADDTESTS/course/ml_quickstart/ML4_Datastructure.thy --- a/test/Tools/isac/ADDTESTS/course/ml_quickstart/ML4_Datastructure.thy Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/ADDTESTS/course/ml_quickstart/ML4_Datastructure.thy Sun Oct 09 07:44:22 2022 +0200 @@ -41,8 +41,8 @@ section \Preview to Isabelle's terms\ ML \ -str2term; -str2term "234 * bbb + ccc"; +parse_test @{context}; +parse_test @{context} "234 * bbb + ccc"; \ ML \ diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/BaseDefinitions/calcelems.sml --- a/test/Tools/isac/BaseDefinitions/calcelems.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/BaseDefinitions/calcelems.sml Sun Oct 09 07:44:22 2022 +0200 @@ -154,7 +154,7 @@ "----------- fun subst2str' --------------------------------------------------------------------"; "----------- fun subst2str' --------------------------------------------------------------------"; "----------- fun subst2str' --------------------------------------------------------------------"; -(*> subst2str' [(TermC.str2term "bdv", TermC.str2term "x"), - (TermC.str2term "bdv_2", TermC.str2term "y")]; +(*> subst2str' [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x"), + (TermC.parse_test @{context} "bdv_2", TermC.parse_test @{context} "y")]; val it = "[(bdv, x)]" : string *) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/BaseDefinitions/contextC.sml --- a/test/Tools/isac/BaseDefinitions/contextC.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/BaseDefinitions/contextC.sml Sun Oct 09 07:44:22 2022 +0200 @@ -64,9 +64,9 @@ "----------- fun transfer_asms_from_to ---------------------------------------------------------"; val ctxt = Proof_Context.init_global @{theory "Isac_Knowledge"} val from_ctxt = ContextC.insert_assumptions - [TermC.str2term "a < (fro::int)", TermC.str2term "b < (fro::int)"] ctxt + [TermC.parse_test @{context} "a < (fro::int)", TermC.parse_test @{context} "b < (fro::int)"] ctxt val to_ctxt = ContextC.insert_assumptions - [TermC.str2term "b < (to::int)", TermC.str2term "c < (to::int)"] ctxt + [TermC.parse_test @{context} "b < (to::int)", TermC.parse_test @{context} "c < (to::int)"] ctxt val new_ctxt = transfer_asms_from_to from_ctxt to_ctxt; if UnparseC.terms_to_strings (get_assumptions new_ctxt) = ["b < fro", "b < to", "c < to"] then () else error "fun transfer_asms_from_to changed" @@ -76,34 +76,34 @@ "----------- fun avoid_contradict --------------------------------------------------------------"; "----------- fun avoid_contradict --------------------------------------------------------------"; val preds = [ -(*0.pre*)TermC.str2term "x / (x \ 2 - 6 * x + 9) - 1 / (x \ 2 - 3 * x) =\n1 / x is_ratequation_in x", -(*1.pre*)TermC.str2term ("\ matches (?a = 0)\n ((3 + - 1 * x + x \ 2) * x =\n 1 * (9 * x + -6 * x \ 2 + x \ 3)) \\n" +(*0.pre*)TermC.parse_test @{context} "x / (x \ 2 - 6 * x + 9) - 1 / (x \ 2 - 3 * x) =\n1 / x is_ratequation_in x", +(*1.pre*)TermC.parse_patt_test @{theory} ("\ matches (?a = 0)\n ((3 + - 1 * x + x \ 2) * x =\n 1 * (9 * x + -6 * x \ 2 + x \ 3)) \\n" (*1.pre*) ^ "\ lhs ((3 + - 1 * x + x \ 2) * x =\n 1 * (9 * x + -6 * x \ 2 + x \ 3)) is_poly_in x"), -(*0.asm*)TermC.str2term "x \ 0", (* <-------------- "x \ 0" would contradict "x = 0" ---\*) -(*0.asm*)TermC.str2term "9 * x + -6 * x \ 2 + x \ 3 \ 0" +(*0.asm*)TermC.parse_test @{context} "x \ 0", (* <-------------- "x \ 0" would contradict "x = 0" ---\*) +(*0.asm*)TermC.parse_test @{context} "9 * x + -6 * x \ 2 + x \ 3 \ 0" ]; -val t = TermC.str2term "[x = 0, x = 6 / 5]"; +val t = TermC.parse_test @{context} "[x = 0, x = 6 / 5]"; val (t', for_asm) = avoid_contradict t preds; if UnparseC.term t' = "[x = 6 / 5]" andalso map UnparseC.term for_asm = ["x = 6 / 5"] then () else error "avoid_contradict [x = 0, x = 6 / 5] CHANGED"; -val t = TermC.str2term "x = 0"; +val t = TermC.parse_test @{context} "x = 0"; val (t', for_asm) = avoid_contradict t preds; if UnparseC.term t' = "bool_undef" andalso map UnparseC.term for_asm = [] then () else error "avoid_contradict x = 0 CHANGED"; (* "x \ 0" in preds *) -val t = TermC.str2term "x = 1"; +val t = TermC.parse_test @{context} "x = 1"; val (t', for_asm) = avoid_contradict t preds; if UnparseC.term t' = "x = 1" andalso map UnparseC.term for_asm = ["x = 1"] then () else error "avoid_contradict x = 1 CHANGED"; (* "x \ 1" NOT in preds *) -val t = TermC.str2term "a + b"; +val t = TermC.parse_test @{context} "a + b"; val (t', for_asm) = avoid_contradict t preds; if UnparseC.term t' = "a + b" andalso map UnparseC.term for_asm = [] then () else error "avoid_contradict a + b CHANGED"; (* NOT a predicate *) -val t = TermC.str2term "[a + b]"; +val t = TermC.parse_test @{context} "[a + b]"; val (t', for_asm) = avoid_contradict t preds; if UnparseC.term t' = "[a + b]" andalso map UnparseC.term for_asm = [] then () else error "avoid_contradict [a + b] CHANGED"; (* NOT a predicate *) @@ -115,12 +115,12 @@ val ctxt = Proof_Context.init_global @{theory "Isac_Knowledge"} val sub_ctxt = ContextC.insert_assumptions - [TermC.str2term "a < (fro::int)", TermC.str2term "b < (fro::int)"] ctxt -val prog_res = TermC.str2term "[x_1 = 1, x_2 = (2::int), x_3 = 3]"; + [TermC.parse_test @{context} "a < (fro::int)", TermC.parse_test @{context} "b < (fro::int)"] ctxt +val prog_res = TermC.parse_test @{context} "[x_1 = 1, x_2 = (2::int), x_3 = 3]"; (* NO contradiction ..*) val caller_ctxt = ContextC.insert_assumptions - [TermC.str2term "b < (to::int)", TermC.str2term "c < (to::int)"] ctxt + [TermC.parse_test @{context} "b < (to::int)", TermC.parse_test @{context} "c < (to::int)"] ctxt val (t, new_ctxt) = subpbl_to_caller sub_ctxt prog_res caller_ctxt; if UnparseC.term t = "[x_1 = 1, x_2 = 2, x_3 = 3]" andalso map UnparseC.term (get_assumptions new_ctxt) = @@ -129,7 +129,7 @@ (* a contradiction ..*) val caller_ctxt = ContextC.insert_assumptions - [TermC.str2term "b < (to::int)", TermC.str2term "x_2 \ (2::int)"] ctxt + [TermC.parse_test @{context} "b < (to::int)", TermC.parse_test @{context} "x_2 \ (2::int)"] ctxt val (t, new_ctxt) = subpbl_to_caller sub_ctxt prog_res caller_ctxt; if UnparseC.term t = "[x_1 = 1, x_3 = 3]" andalso map UnparseC.term (get_assumptions new_ctxt) = diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/BaseDefinitions/rewrite-order.sml --- a/test/Tools/isac/BaseDefinitions/rewrite-order.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/BaseDefinitions/rewrite-order.sml Sun Oct 09 07:44:22 2022 +0200 @@ -17,7 +17,7 @@ "-------- identify difference in term-order between isa=NEW, isa2+OLD --------------------------"; "-------- identify difference in term-order between isa=NEW, isa2+OLD --------------------------"; "-------- identify difference in term-order between isa=NEW, isa2+OLD --------------------------"; -val form = TermC.str2term "x + -2 ::real" +val form = TermC.parse_test @{context} "x + -2 ::real" val Repeat {rew_ord = ("sqrt_right", rew_ord_), erls, ...} = Test_simplify; val ctxt = Proof_Context.init_global @{theory Test}; (*Rewrite.trace_on := false; (*true false*)*) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/BaseDefinitions/substitution.sml --- a/test/Tools/isac/BaseDefinitions/substitution.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/BaseDefinitions/substitution.sml Sun Oct 09 07:44:22 2022 +0200 @@ -101,7 +101,7 @@ Subst.program_to_input: Subst.program -> string list; val {scr = Prog prog, ...} = MethodC.from_store ctxt ["diff", "differentiate_on_R"]; -val env = [(TermC.str2term "v_v", TermC.str2term "x")] : Subst.T; +val env = [(TermC.parse_test @{context} "v_v", TermC.parse_test @{context} "x")] : Subst.T; "~~~~~ fun for_bdv, args:"; val (prog, env) = (prog, env); fun scan (Const _) = NONE diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/BaseDefinitions/termC.sml --- a/test/Tools/isac/BaseDefinitions/termC.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/BaseDefinitions/termC.sml Sun Oct 09 07:44:22 2022 +0200 @@ -186,7 +186,7 @@ "\ ?bdv occurs_in ?a \\n(?a + ?bdv = 0) = (?bdv = - 1 * ?a)" then () else error "termC.sml d1_isolate_add2"; - val subst = [(TermC.str2term "bdv", TermC.str2term "x")]; + val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]; val t = (Eval.norm o Thm.prop_of) @{thm d1_isolate_add2}; val t' = TermC.inst_bdv subst t; if UnparseC.term t' = "\ x occurs_in ?a \ (?a + x = 0) = (x = - 1 * ?a)" @@ -199,10 +199,10 @@ (*default_print_depth 5;*) val subst = - [(TermC.str2term "bdv_1", TermC.str2term "c"), - (TermC.str2term "bdv_2", TermC.str2term "c_2"), - (TermC.str2term "bdv_3", TermC.str2term "c_3"), - (TermC.str2term "bdv_4", TermC.str2term "c_4")]; + [(TermC.parse_test @{context} "bdv_1", TermC.parse_test @{context} "c"), + (TermC.parse_test @{context} "bdv_2", TermC.parse_test @{context} "c_2"), + (TermC.parse_test @{context} "bdv_3", TermC.parse_test @{context} "c_3"), + (TermC.parse_test @{context} "bdv_4", TermC.parse_test @{context} "c_4")]; val t = (Eval.norm o Thm.prop_of) @{thm separate_bdvs_add}; val t' = TermC.inst_bdv subst t; @@ -213,9 +213,9 @@ "----------- subst_atomic_all ---------------------------"; "----------- subst_atomic_all ---------------------------"; "----------- subst_atomic_all ---------------------------"; - val t = TermC.str2term "(tl vs_vs) from vs_vs occur_exactly_in (NTH 1 (es_es::bool list))"; - val env = [(TermC.str2term "vs_vs::real list", TermC.str2term "[c, c_2]"), - (TermC.str2term "es_es::bool list", TermC.str2term "[c_2 = 0, c + c_2 = 1]")]; + val t = TermC.parse_test @{context} "(tl vs_vs) from vs_vs occur_exactly_in (NTH 1 (es_es::bool list))"; + val env = [(TermC.parse_test @{context} "vs_vs::real list", TermC.parse_test @{context} "[c, c_2]"), + (TermC.parse_test @{context} "es_es::bool list", TermC.parse_test @{context} "[c_2 = 0, c + c_2 = 1]")]; val (all_Free_subst, t') = TermC.subst_atomic_all env t; if all_Free_subst andalso @@ -231,8 +231,8 @@ "----------- Pattern.match ------------------------------"; "----------- Pattern.match ------------------------------"; "----------- Pattern.match ------------------------------"; - val t = TermC.str2term "3 * x\2 = (1::real)"; - val pat = (TermC.free2var o TermC.str2term) "a * b\2 = (c::real)"; + val t = TermC.parse_test @{context} "3 * x\2 = (1::real)"; + val pat = (TermC.free2var o TermC.parse_test @{context}) "a * b\2 = (c::real)"; (* ! \ \ ^^!... necessary for Pattern.match, see Logic.varify_global below*) val insts = Pattern.match @{theory "Isac_Knowledge"} (pat, t) (Vartab.empty, Vartab.empty); (*default_print_depth 3; 999*) insts; @@ -243,7 +243,7 @@ (("c", 0), ("Real.real", Free ("1", "Real.real")))})*) "----- throws exn MATCH..."; -(* val t = TermC.str2term "x"; +(* val t = TermC.parse_test @{context} "x"; (Pattern.match @{theory "Isac_Knowledge"} (pat, t) (Vartab.empty, Vartab.empty)) handle MATCH => ???; *) @@ -283,7 +283,7 @@ else (); "----- test 2: Nok"; - val pa = Logic.varify_global (TermC.str2term "a = (0::real)");(*<<<<<<<-------------*) + val pa = Logic.varify_global (TermC.parse_test @{context} "a = (0::real)");(*<<<<<<<-------------*) tracing "paLo2=..."; TermC.atomty pa; tracing "...=paLo2"; (*** *** Const (op =, real => real => bool) @@ -291,11 +291,11 @@ *** . Var ((0, 0), real) ***) "----- test 2a true"; - val tm = TermC.str2term "-8 - 2 * x + x ^ 2 = (0::real)"; (*<<<<<<<-------------*) + val tm = TermC.parse_test @{context} "-8 - 2 * x + x ^ 2 = (0::real)"; (*<<<<<<<-------------*) if TermC.matches thy tm pa then () else error "termC.sml diff.behav. in TermC.matches true 2"; "----- test 2b false"; - val tm = TermC.str2term "-8 - 2 * x + x ^ 2 = (3::real)"; (*<<<<<<<-------------*) + val tm = TermC.parse_test @{context} "-8 - 2 * x + x ^ 2 = (3::real)"; (*<<<<<<<-------------*) if TermC.matches thy tm pa then error "termC.sml diff.behav. in TermC.matches false 2" else (); (* i.e. !!!!!!!!!!!!!!!!! THIS KIND OF PATTERN IS NOT RELIABLE !!!!!!!!!!!!!!!!! @@ -303,7 +303,7 @@ else ();*) "----- test 3: OK"; - val pa = TermC.free2var (TermC.str2term "a = (0::real)");(*<<<<<<<-------------*) + val pa = TermC.free2var (TermC.parse_test @{context} "a = (0::real)");(*<<<<<<<-------------*) tracing "paF2=..."; TermC.atomty pa; tracing "...=paF2"; (*** *** Const (op =, real => real => bool) @@ -311,22 +311,22 @@ *** . Free (0, real) ***) "----- test 3a true"; - val tm = TermC.str2term "-8 - 2 * x + x ^ 2 = (0::real)"; (*<<<<<<<-------------*) + val tm = TermC.parse_test @{context} "-8 - 2 * x + x ^ 2 = (0::real)"; (*<<<<<<<-------------*) if TermC.matches thy tm pa then () else error "termC.sml diff.behav. in TermC.matches true 3"; "----- test 3b false"; - val tm = TermC.str2term "-8 - 2 * x + x ^ 2 = (3::real)"; (*<<<<<<<-------------*) + val tm = TermC.parse_test @{context} "-8 - 2 * x + x ^ 2 = (3::real)"; (*<<<<<<<-------------*) if TermC.matches thy tm pa then error "termC.sml diff.behav. in TermC.matches false 3" else (); "----- test 4=3 with specific data"; - val pa = TermC.free2var (TermC.str2term "M_b 0"); + val pa = TermC.free2var (TermC.parse_test @{context} "M_b 0"); "----- test 4a true"; - val tm = TermC.str2term "M_b 0"; + val tm = TermC.parse_test @{context} "M_b 0"; if TermC.matches thy tm pa then () else error "termC.sml diff.behav. in TermC.matches true 4"; "----- test 4b false"; - val tm = TermC.str2term "M_b x"; + val tm = TermC.parse_test @{context} "M_b x"; if TermC.matches thy tm pa then error "termC.sml diff.behav. in TermC.matches false 4" else (); @@ -537,10 +537,10 @@ "----------- fun TermC.is_bdv_subst ------------------------------------------------------------------"; "----------- fun TermC.is_bdv_subst ------------------------------------------------------------------"; "----------- fun TermC.is_bdv_subst ------------------------------------------------------------------"; -if TermC.is_bdv_subst (TermC.str2term "[(''bdv'', v_v)]") then () +if TermC.is_bdv_subst (TermC.parse_test @{context} "[(''bdv'', v_v)]") then () else error "TermC.is_bdv_subst canged 1"; -if TermC.is_bdv_subst (TermC.str2term "[(''bdv_1'', v_s1),(''bdv_2'', v_s2)]") then () +if TermC.is_bdv_subst (TermC.parse_test @{context} "[(''bdv_1'', v_s1),(''bdv_2'', v_s2)]") then () else error "TermC.is_bdv_subst canged 2"; "----------- fun str_of_int --------------------------------------------------------------------"; @@ -581,41 +581,41 @@ case ThmC_Def.int_opt_of_string "-123" of SOME ~123 => () | _ => raise error "ThmC_Def.int_opt_of_string -123 changed"; -val t = TermC.str2term "1"; +val t = TermC.parse_test @{context} "1"; if TermC.is_num t = true then () else error "TermC.is_num 1"; -val t = TermC.str2term "-1"; +val t = TermC.parse_test @{context} "-1"; if TermC.is_num t = true then () else error "TermC.is_num -1"; -val t = TermC.str2term "a123"; +val t = TermC.parse_test @{context} "a123"; if TermC.is_num t = false then () else error "TermC.is_num a123"; "----------- fun TermC.is_f_x ------------------------------------------------------------------------"; "----------- fun TermC.is_f_x ------------------------------------------------------------------------"; "----------- fun TermC.is_f_x ------------------------------------------------------------------------"; -val t = TermC.str2term "q_0/2 * L * x"; +val t = TermC.parse_test @{context} "q_0/2 * L * x"; if TermC.is_f_x t = false then () else error "TermC.is_f_x q_0/2 * L * x"; -val t = TermC.str2term "M_b x"; +val t = TermC.parse_test @{context} "M_b x"; if TermC.is_f_x t = true then () else error "M_b x"; "----------- fun list2isalist, fun isalist2list ------------------------------------------------"; "----------- fun list2isalist, fun isalist2list ------------------------------------------------"; "----------- fun list2isalist, fun isalist2list ------------------------------------------------"; -val t = TermC.str2term "R=(R::real)"; +val t = TermC.parse_test @{context} "R=(R::real)"; val T = type_of t; val ss = TermC.list2isalist T [t,t,t]; if UnparseC.term ss = "[R = R, R = R, R = R]" then () else error "list2isalist 1"; -val t = TermC.str2term "[a=b,c=d,e=f]"; +val t = TermC.parse_test @{context} "[a=b,c=d,e=f]"; val il = TermC.isalist2list t; if UnparseC.terms il = "[\"a = b\", \"c = d\", \"e = f\"]" then () else error "isalist2list 2"; -val t = TermC.str2term "[a=b,c=d,e=f]"; +val t = TermC.parse_test @{context} "[a=b,c=d,e=f]"; val il = TermC.isalist2list t; if UnparseC.terms il = "[\"a = b\", \"c = d\", \"e = f\"]" then () else error "isalist2list 3"; -val t = TermC.str2term "ss___s::bool list"; +val t = TermC.parse_test @{context} "ss___s::bool list"; (TermC.isalist2list t; error "isalist2list 1") handle TERM ("isalist2list applied to NON-list: ", _) =>(); "----------- fun TermC.strip_imp_prems', fun TermC.ins_concl -----------------------------------------------"; @@ -647,7 +647,7 @@ val t = TermC.mk_factroot "SqRoot.sqrt" T 2 3; if UnparseC.term t = "2 * ??.SqRoot.sqrt 3" then () else error "mk_factroot"; -val t = TermC.str2term "aaa + bbb"; +val t = TermC.parse_test @{context} "aaa + bbb"; val op_ as Const (\<^const_name>\plus\, Top) $ Free ("aaa", T1) $ Free ("bbb", T2) = t; val t' = TermC.mk_num_op_num T1 T2 (\<^const_name>\plus\, Top) 2 3; if UnparseC.term t' = "2 + 3" then () else error "mk_num_op_num"; @@ -664,11 +664,11 @@ "----------- fun TermC.is_list -----------------------------------------------------------------------"; "----------- fun TermC.is_list -----------------------------------------------------------------------"; val (SOME ct) = TermC.parseNEW ctxt "lll::real list"; -val t = TermC.str2term "lll::real list"; +val t = TermC.parse_test @{context} "lll::real list"; val ty = Term.type_of ct; if TermC.is_list t = false then () else error "TermC.is_list lll::real list"; -val t = TermC.str2term "[a, b, c]"; +val t = TermC.parse_test @{context} "[a, b, c]"; val ty = Term.type_of ct; if TermC.is_list t = true then () else error "TermC.is_list [a, b, c]"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Interpret/error-pattern.sml --- a/test/Tools/isac/Interpret/error-pattern.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Interpret/error-pattern.sml Sun Oct 09 07:44:22 2022 +0200 @@ -119,13 +119,13 @@ val fod = Derive.do_one (Proof_Context.init_global @{theory "Isac_Knowledge"}) Atools_erls ((#rules o Rule_Set.rep) Test_simplify) (sqrt_right false (@{theory "Pure"})) NONE - (TermC.str2term "x + 1 + - 1 * 2 = 0"); + (TermC.parse_test @{context} "x + 1 + - 1 * 2 = 0"); (writeln o Derive.trtas2str) fod; val ifod = Derive.do_one (Proof_Context.init_global @{theory "Isac_Knowledge"}) Atools_erls ((#rules o Rule_Set.rep) Test_simplify) (sqrt_right false (@{theory "Pure"})) NONE - (TermC.str2term "- 2 * 1 + (1 + x) = 0"); + (TermC.parse_test @{context} "- 2 * 1 + (1 + x) = 0"); (writeln o Derive.trtas2str) ifod; fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2; val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod); @@ -637,7 +637,7 @@ "--------- Take as 1st tac, start with (CAS input) ---------"; "--------- Take as 1st tac, start with (CAS input) ---------"; "--------- Take as 1st tac, start with (CAS input) ---------"; -val t = TermC.str2term "Diff (x \ 2 + x + 1, x)"; +val t = TermC.parse_test @{context} "Diff (x \ 2 + x + 1, x)"; case t of Const (\<^const_name>\Diff\, _) $ _ => () | _ => raise error "diff.sml behav.changed for CAS Diff (..., x)"; @@ -902,11 +902,11 @@ "--------- build fun check_for' ------------------------------"; "--------- build fun check_for' ------------------------------"; "--------- build fun check_for' ------------------------------"; -val subst = [(TermC.str2term "bdv", TermC.str2term "x")]: subst; +val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]: subst; val rls = norm_Rational val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c"; -val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "2 / 4"); -val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "1 / 2"); +val (res, inf) = (TermC.parse_test @{context} "(2 + 3)/(3 + 4)", TermC.parse_test @{context} "2 / 4"); +val (res, inf) = (TermC.parse_test @{context} "(2 + 3)/(3 + 4)", TermC.parse_test @{context} "1 / 2"); val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern TermC.matches in res*) rew_sub ctxt 1 [] Rewrite_Ord.function_empty Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res; @@ -924,21 +924,21 @@ norm_res = norm_inf; val pat = TermC.parse_patt @{theory} "(?a + ?b)/?a = ?b"; -val (res, inf) = (TermC.str2term "(2 + 3)/2", TermC.str2term "3"); +val (res, inf) = (TermC.parse_test @{context} "(2 + 3)/2", TermC.parse_test @{context} "3"); if check_for' ctxt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID" then () else error "error patt example1 changed"; val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c"; -val (res, inf) = (TermC.str2term "(2 + 3)/(2 + 4)", TermC.str2term "3 / 4"); +val (res, inf) = (TermC.parse_test @{context} "(2 + 3)/(2 + 4)", TermC.parse_test @{context} "3 / 4"); if check_for' ctxt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID" then () else error "error patt example2 changed"; val pat = TermC.parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c"; -val (res, inf) = (TermC.str2term "(2 + 3)/(3 + 4)", TermC.str2term "2 / 4"); +val (res, inf) = (TermC.parse_test @{context} "(2 + 3)/(3 + 4)", TermC.parse_test @{context} "2 / 4"); if check_for' ctxt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID" then () else error "error patt example3 changed"; -val inf = TermC.str2term "1 / 2"; +val inf = TermC.parse_test @{context} "1 / 2"; if check_for' ctxt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID" then () else error "error patt example3 changed"; @@ -946,15 +946,15 @@ "--------- build fun check_for' ?bdv -------------------------"; "--------- build fun check_for' ?bdv -------------------------"; val ctxt = Proof_Context.init_global @{theory} -val subst = [(TermC.str2term "bdv", TermC.str2term "x")]: subst; -val t = TermC.str2term "d_d x (x \ 2 + sin (x \ 4))"; +val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]: subst; +val t = TermC.parse_test @{context} "d_d x (x \ 2 + sin (x \ 4))"; val SOME (t, _) = rewrite_set_inst_ ctxt false subst norm_diff t; if UnparseC.term t = "2 * x + cos (x \ 4) * 4 * x \ 3" then () else error "build fun check_for' ?bdv changed 1"; val rls = norm_diff val pat = TermC.parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)"; -val (res, inf) = (TermC.str2term "2 * x + d_d x (sin (x \ 4))", TermC.str2term "2 * x + cos (4 * x \ 3)"); +val (res, inf) = (TermC.parse_test @{context} "2 * x + d_d x (sin (x \ 4))", TermC.parse_test @{context} "2 * x + cos (4 * x \ 3)"); val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern TermC.matches in res*) rew_sub ctxt 1 subst Rewrite_Ord.function_empty Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res; @@ -984,11 +984,11 @@ "--------- build fun check_for ------------------------"; "--------- build fun check_for ------------------------"; val (res, inf) = - (TermC.str2term "d_d x (x \ 2) + d_d x (sin (x \ 4))", - TermC.str2term "d_d x (x \ 2) + cos (4 * x \ 3)"); + (TermC.parse_test @{context} "d_d x (x \ 2) + d_d x (sin (x \ 4))", + TermC.parse_test @{context} "d_d x (x \ 2) + cos (4 * x \ 3)"); val {errpats, nrls = rls, scr = Prog prog, ...} = MethodC.from_store ctxt ["diff", "differentiate_on_R"] -val env = [(TermC.str2term "v_v", TermC.str2term "x")]; +val env = [(TermC.parse_test @{context} "v_v", TermC.parse_test @{context} "x")]; val errpats = [Error_Pattern.empty, (*generalised for testing*) ("chain-rule-diff-both", @@ -1277,7 +1277,7 @@ "--------- fun concat_deriv --------------------------------------"; (* val ({rew_ord, erls, rules,...}, fo, ifo) = - (Rule_Set.rep Test_simplify, TermC.str2term "x+1+ - 1*2=0", TermC.str2term "-2*1+(x+1)=0"); + (Rule_Set.rep Test_simplify, TermC.parse_test @{context} "x+1+ - 1*2=0", TermC.parse_test @{context} "-2*1+(x+1)=0"); (tracing o Derive.trtas2str) fod'; > [" (x + 1 + - 1 * 2 = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (x + 1) = 0, []))", " diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/algein.sml --- a/test/Tools/isac/Knowledge/algein.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/algein.sml Sun Oct 09 07:44:22 2022 +0200 @@ -102,7 +102,7 @@ val rew_ord = Rewrite_Ord.function_empty; val erls = Rule_Set.Empty; val thm = ThmC.thm_from_thy thy "sym_mult_zero_right"; -val t = TermC.str2term "0 = (0::real)"; +val t = TermC.parse_test @{context} "0 = (0::real)"; val SOME (t',_) = rewrite_ ctxt rew_ord erls false thm t; UnparseC.term t' = "0 = ?a1 * 0"; (* = true*) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/biegelinie-1.sml --- a/test/Tools/isac/Knowledge/biegelinie-1.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/biegelinie-1.sml Sun Oct 09 07:44:22 2022 +0200 @@ -29,23 +29,22 @@ val thy = @{theory "Biegelinie"}; val ctxt = ThyC.id_to_ctxt "Biegelinie"; -fun str2term str = TermC.parseNEW' ctxt str; fun term2s t = UnparseC.term_by_thyID "Biegelinie" t; fun rewrit thm str = fst (the (rewrite_ ctxt tless_true Rule_Set.empty true thm str)); "----------- the rules -------------------------------------------"; "----------- the rules -------------------------------------------"; "----------- the rules -------------------------------------------"; -val t = rewrit @{thm Belastung_Querkraft} (TermC.str2term "- qq x = - q_0"); term2s t; +val t = rewrit @{thm Belastung_Querkraft} (TermC.parse_test @{context} "- qq x = - q_0"); term2s t; if term2s t = "Q' x = - q_0" then () else error "/biegelinie.sml: Belastung_Querkraft"; -val t = rewrit @{thm Querkraft_Moment} (TermC.str2term "Q x = - q_0 * x + c"); term2s t; +val t = rewrit @{thm Querkraft_Moment} (TermC.parse_test @{context} "Q x = - q_0 * x + c"); term2s t; if term2s t = "?M_b' x = - q_0 * x + c" then () (*if term2s t = "M_b' x = - q_0 * x + c" then () cf.fbe1652b0df8 new handling of quotes in mixfix*) else error "/biegelinie.sml: Querkraft_Moment"; -val t = rewrit @{thm Moment_Neigung} (TermC.str2term "M_b x = -q_0 * x \ 2/2 + q_0/2 *L*x"); +val t = rewrit @{thm Moment_Neigung} (TermC.parse_test @{context} "M_b x = -q_0 * x \ 2/2 + q_0/2 *L*x"); term2s t; if term2s t = "- EI * y'' x = - q_0 * x \ 2 / 2 + q_0 / 2 * L * x" then () else error "biegelinie.sml: Moment_Neigung"; @@ -71,13 +70,13 @@ Eval("Prog_Expr.argument_in", eval_argument_in "Prog_Expr.argument_in") ], scr = Empty_Prog}; -val rm_ = TermC.str2term"[M_b 0 = 0, M_b L = 0]"; -val M__ = TermC.str2term"M_b x = - 1 * x \ 2 / 2 + x * c + c_2"; +val rm_ = TermC.parse_test @{context}"[M_b 0 = 0, M_b L = 0]"; +val M__ = TermC.parse_test @{context}"M_b x = - 1 * x \ 2 / 2 + x * c + c_2"; val SOME (e1__,_) = rewrite_set_ ctxt false srls - (TermC.str2term "(NTH::[real,bool list]=>bool) 1 " $ rm_); + (TermC.parse_test @{context} "(NTH::[real,bool list]=>bool) 1 " $ rm_); if UnparseC.term e1__ = "M_b 0 = 0" then () else error "biegelinie.sml simplify NTH 1 rm_"; -val SOME (x1__,_) = rewrite_set_ ctxt false srls (TermC.str2term "argument_in (lhs (M_b 0 = 0))"); +val SOME (x1__,_) = rewrite_set_ ctxt false srls (TermC.parse_test @{context} "argument_in (lhs (M_b 0 = 0))"); if UnparseC.term x1__ = "0" then () else error "biegelinie.sml simplify argument_in (lhs (M_b 0 = 0)"; @@ -115,8 +114,8 @@ "----------- investigate normalforms in biegelinien --------------"; "----------- investigate normalforms in biegelinien --------------"; "----- coming from integration, kept for later improvements:"; -val Q = TermC.str2term "Q x = c + - 1 * q_0 * x"; -val M_b = TermC.str2term "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \ 2"; -val y' = TermC.str2term "y' x = c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \ 2 + - 1 * q_0 / 6 * x \ 3)"; -val y = TermC.str2term "y x = c_4 + c_3 * x +\n1 / (- 1 * EI) * (c_2 / 2 * x \ 2 + c / 6 * x \ 3 + - 1 * q_0 / 24 * x \ 4)"; +val Q = TermC.parse_test @{context} "Q x = c + - 1 * q_0 * x"; +val M_b = TermC.parse_test @{context} "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \ 2"; +val y' = TermC.parse_test @{context} "y' x = c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \ 2 + - 1 * q_0 / 6 * x \ 3)"; +val y = TermC.parse_test @{context} "y x = c_4 + c_3 * x +\n1 / (- 1 * EI) * (c_2 / 2 * x \ 2 + c / 6 * x \ 3 + - 1 * q_0 / 24 * x \ 4)"; (* \ 1 / (- 1 * EI) NOT distributed - ok! \ \ \ \ \ \ \ ^^*) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/diff-app.sml --- a/test/Tools/isac/Knowledge/diff-app.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/diff-app.sml Sun Oct 09 07:44:22 2022 +0200 @@ -455,7 +455,7 @@ "--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------"; "--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------"; "--------------------- 30.4.03: maximum .. rewrite_set_ prog_expr ---------"; -TermC.str2term +TermC.parse_test @{context} "Program Maximum_value(f_ix::bool list)(m_m::real) (r_s::bool list)\ \ (v_v::real) (itv_v::real set) (err_r::bool) = \ \ (let e_e = (hd o (filterVar m_m)) r_s; \ @@ -470,22 +470,22 @@ \ [REAL mx_x, REAL (Rhs t_t), REAL v_v, REAL m_m, \ \ BOOL_LIST (dropWhile (ident e_e) r_s)])::bool list))"; -val f_ix = (TermC.str2term "f_ix::bool list", - TermC.str2term "[r=Arbfix]"); -val m_m = (TermC.str2term "m_m::real", - TermC.str2term "A"); -val r_s = (TermC.str2term "rs_s::bool list", - TermC.str2term "[A = a*b, (a/2) \ 2 + (b/2) \ 2 = r \ 2]"); -val v_v = (TermC.str2term "v_v::real", - TermC.str2term "b"); -val itv_v = (TermC.str2term "itv_v::real set", - TermC.str2term "{x::real. 0 <= x & x <= 2*r}"); -val err_r = (TermC.str2term "err_r::bool", - TermC.str2term "eps=0"); +val f_ix = (TermC.parse_test @{context} "f_ix::bool list", + TermC.parse_test @{context} "[r=Arbfix]"); +val m_m = (TermC.parse_test @{context} "m_m::real", + TermC.parse_test @{context} "A"); +val r_s = (TermC.parse_test @{context} "rs_s::bool list", + TermC.parse_test @{context} "[A = a*b, (a/2) \ 2 + (b/2) \ 2 = r \ 2]"); +val v_v = (TermC.parse_test @{context} "v_v::real", + TermC.parse_test @{context} "b"); +val itv_v = (TermC.parse_test @{context} "itv_v::real set", + TermC.parse_test @{context} "{x::real. 0 <= x & x <= 2*r}"); +val err_r = (TermC.parse_test @{context} "err_r::bool", + TermC.parse_test @{context} "eps=0"); val env = [f_ix, m_m, r_s ,v_v, itv_v, err_r]; (*--- 1.line in script ---*) -val t = TermC.str2term "(hd o (filterVar m_m)) (r_s::bool list)"; +val t = TermC.parse_test @{context} "(hd o (filterVar m_m)) (r_s::bool list)"; val s = subst_atomic env t; UnparseC.term s; "(hd o filterVar A) [A = a * b, (a / 2) \ 2 + (b / 2) \ 2 = r \ 2]"; @@ -494,10 +494,10 @@ val s'' = UnparseC.term s'; if s''="A = a * b" then () else error "new behaviour with prog_expr 1.1."; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "e_e::bool",TermC.str2term "A = a * b")]; +val env = env @ [(TermC.parse_test @{context} "e_e::bool",TermC.parse_test @{context} "A = a * b")]; (*--- 2.line: condition alone ---*) -val t = TermC.str2term "1 < length_h (r_s::bool list)"; +val t = TermC.parse_test @{context} "1 < length_h (r_s::bool list)"; val s = subst_atomic env t; UnparseC.term s; "1 < length_h [A = a * b, (a / 2) \ 2 + (b / 2) \ 2 = r \ 2]"; @@ -508,7 +508,7 @@ === inhibit exn 110726=============================================================*) (*--- 2.line in script ---*) -val t = TermC.str2term +val t = TermC.parse_test @{context} "(if 1 < length_h r_s \ \ then (SubProblem (Reals_s,[make,function],[no_met])\ \ [REAL m_m, REAL v_v, BOOL_LIST r_s])\ @@ -529,15 +529,15 @@ \ BOOL_LIST [A = a * b, (a / 2) \ 2 + (b / 2) \ 2 = r \ 2]]" then () else error "new behaviour with prog_expr 1.3."; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "t_t::bool", - TermC.str2term "A = (2*sqrt(r \ 2-(b/2) \ 2)) * b")]; +val env = env @ [(TermC.parse_test @{context} "t_t::bool", + TermC.parse_test @{context} "A = (2*sqrt(r \ 2-(b/2) \ 2)) * b")]; "---------------------- 1.5.03: Make_fun_by_explicit ---------------------"; "---------------------- 1.5.03: Make_fun_by_explicit ---------------------"; "---------------------- 1.5.03: Make_fun_by_explicit ---------------------"; -TermC.str2term +TermC.parse_test @{context} "Program Make_fun_by_explicit (f_f::real) (v_v::real) \ \ (eqs::bool list) = \ \ (let h_h = (hd o (filterVar f_f)) eqs; \ @@ -547,32 +547,32 @@ \ (s_1::bool list)=(SubProblem(Reals_s,[univar,equation],[no_met])\ \ [BOOL e_1, REAL v_1])\ \ in Substitute [(v_1 = (rhs o hd) s_1)] h_h)"; -val f_f = (TermC.str2term "f_f::real", - TermC.str2term "A"); -val v_v = (TermC.str2term "v_v::real", - TermC.str2term "b"); -val eqs=(TermC.str2term "eqs::bool list", - TermC.str2term "[A = a * b, (a / 2) \ 2 + (b / 2) \ 2 = r \ 2]"); +val f_f = (TermC.parse_test @{context} "f_f::real", + TermC.parse_test @{context} "A"); +val v_v = (TermC.parse_test @{context} "v_v::real", + TermC.parse_test @{context} "b"); +val eqs=(TermC.parse_test @{context} "eqs::bool list", + TermC.parse_test @{context} "[A = a * b, (a / 2) \ 2 + (b / 2) \ 2 = r \ 2]"); val env = [f_f, v_v, eqs]; (*--- 1.line in script ---*) -val t = TermC.str2term "(hd o (filterVar v_v)) (eqs::bool list)"; +val t = TermC.parse_test @{context} "(hd o (filterVar v_v)) (eqs::bool list)"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term +val t = TermC.parse_test @{context} "(hd o filterVar b) [A = a * b, (a / 2) \ 2 + (b / 2) \ 2 = r \ 2]"; val SOME (t',_) = rewrite_set_ ctxt false prog_expr t; val s' = UnparseC.term t'; (*=== inhibit exn 110726============================================================= if s' = "A = a * b" then () else error "new behaviour with prog_expr 2.1"; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "h_h::bool", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "h_h::bool", TermC.parse_test @{context} s')]; (*--- 2.line in script ---*) -val t = TermC.str2term "hd (dropWhile (ident h_h) (eqs::bool list))"; +val t = TermC.parse_test @{context} "hd (dropWhile (ident h_h) (eqs::bool list))"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term +val t = TermC.parse_test @{context} "hd (dropWhile (ident (A = a * b))\ \ [A = a * b, (a / 2) \ 2 + (b / 2) \ 2 = r \ 2])"; (*=== inhibit exn 110726============================================================= @@ -583,47 +583,47 @@ if s' = "(a / 2) \ 2 + (b / 2) \ 2 = r \ 2" then () else error "new behaviour with prog_expr 2.2"; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "e_1::bool", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "e_1::bool", TermC.parse_test @{context} s')]; (*--- 3.line in script ---*) -val t = TermC.str2term "dropWhile (ident f_f) (Vars (h_h::bool))"; +val t = TermC.parse_test @{context} "dropWhile (ident f_f) (Vars (h_h::bool))"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term "dropWhile (ident A) (Vars (A = a * b))"; +val t = TermC.parse_test @{context} "dropWhile (ident A) (Vars (A = a * b))"; (*=== inhibit exn 110726============================================================= val SOME (t',_) = rewrite_set_ thy false prog_expr t; val s' = UnparseC.term t'; if s' = "[a, b]" then () else error "new behaviour with prog_expr 2.3"; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "vs_s::real list", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "vs_s::real list", TermC.parse_test @{context} s')]; (*--- 4.line in script ---*) -val t = TermC.str2term "hd (dropWhile (ident v_v) v_s)"; +val t = TermC.parse_test @{context} "hd (dropWhile (ident v_v) v_s)"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term "hd (dropWhile (ident b) [a, b])"; +val t = TermC.parse_test @{context} "hd (dropWhile (ident b) [a, b])"; (*=== inhibit exn 110726============================================================= val SOME (t',_) = rewrite_set_ thy false prog_expr t; val s' = UnparseC.term t'; if s' = "a" then () else error "new behaviour with prog_expr 2.4."; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "v_1::real", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "v_1::real", TermC.parse_test @{context} s')]; (*--- 5.line in script ---*) -val t = TermC.str2term "(SubProblem(Reals_s,[univar,equation],[no_met])\ +val t = TermC.parse_test @{context} "(SubProblem(Reals_s,[univar,equation],[no_met])\ \ [BOOL e_1, REAL v_1])"; val s = subst_atomic env t; UnparseC.term s; "SubProblem (Reals_s, [univar, equation], [no_met])\n\ \ [BOOL ((a / 2) \ 2 + (b / 2) \ 2 = r \ 2), REAL a]"; -val env = env @ [(TermC.str2term "s_1::bool list", - TermC.str2term "[a = 2 * sqrt (r \ 2 - (b/2) \ 2)]")]; +val env = env @ [(TermC.parse_test @{context} "s_1::bool list", + TermC.parse_test @{context} "[a = 2 * sqrt (r \ 2 - (b/2) \ 2)]")]; (*--- 6.line in script ---*) -val t = TermC.str2term "Substitute [(v_1 = (rhs o hd) (s_1::bool list))] (h_h::bool)"; +val t = TermC.parse_test @{context} "Substitute [(v_1 = (rhs o hd) (s_1::bool list))] (h_h::bool)"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term +val t = TermC.parse_test @{context} "Substitute [(a = (rhs o hd) [a = 2 * sqrt (r \ 2 - (b / 2) \ 2)])]\n\ \ (A = a * b)"; (*=== inhibit exn 110726============================================================= @@ -638,7 +638,7 @@ "---------------------- 2.5.03: Make_fun_by_new_variable -----------------"; "---------------------- 2.5.03: Make_fun_by_new_variable -----------------"; "---------------------- 2.5.03: Make_fun_by_new_variable -----------------"; -TermC.str2term +TermC.parse_test @{context} "Program Make_fun_by_new_variable (f_f::real) (v_v::real) \ \ (eqs::bool list) = \ \(let h_h = (hd o (filterVar f_f)) eqs; \ @@ -653,32 +653,32 @@ \ (s_2::bool list) = (SubProblem (Reals_s,[univar,equation],[no_met])\ \ [BOOL e_2, REAL v_2])\ \in Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] h_h)"; -val f_ = (TermC.str2term "f_f::real", - TermC.str2term "A"); -val v_v = (TermC.str2term "v_v::real", - TermC.str2term "alpha"); -val eqs=(TermC.str2term "eqs::bool list", - TermC.str2term "[A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]"); +val f_ = (TermC.parse_test @{context} "f_f::real", + TermC.parse_test @{context} "A"); +val v_v = (TermC.parse_test @{context} "v_v::real", + TermC.parse_test @{context} "alpha"); +val eqs=(TermC.parse_test @{context} "eqs::bool list", + TermC.parse_test @{context} "[A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]"); val env = [f_f, v_v, eqs]; (*--- 1.line in script ---*) -val t = TermC.str2term "(hd o (filterVar (f_f::real))) (eqs::bool list)"; +val t = TermC.parse_test @{context} "(hd o (filterVar (f_f::real))) (eqs::bool list)"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term +val t = TermC.parse_test @{context} "(hd o filterVar A) [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]"; val SOME (t',_) = rewrite_set_ ctxt false prog_expr t; val s' = UnparseC.term t'; (*=== inhibit exn 110726============================================================= if s' = "A = a * b" then() else error "new behaviour with prog_expr 3.1."; -val env = env @ [(TermC.str2term "h_h::bool", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "h_h::bool", TermC.parse_test @{context} s')]; === inhibit exn 110726=============================================================*) (*--- 2.line in script ---*) -val t = TermC.str2term "dropWhile (ident (h_h::bool)) (eqs::bool list)"; +val t = TermC.parse_test @{context} "dropWhile (ident (h_h::bool)) (eqs::bool list)"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term +val t = TermC.parse_test @{context} "dropWhile (ident (A = a * b))\ \ [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]"; (*=== inhibit exn 110726============================================================= @@ -687,49 +687,49 @@ if s' = "[a / 2 = r * sin alpha, b / 2 = r * cos alpha]" then () else error "new behaviour with prog_expr 3.2."; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "es_s::bool list", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "es_s::bool list", TermC.parse_test @{context} s')]; (*--- 3.line in script ---*) -val t = TermC.str2term "dropWhile (ident (f_f::real)) (Vars (h_h::bool))"; +val t = TermC.parse_test @{context} "dropWhile (ident (f_f::real)) (Vars (h_h::bool))"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term "dropWhile (ident A) (Vars (A = a * b))"; +val t = TermC.parse_test @{context} "dropWhile (ident A) (Vars (A = a * b))"; (*=== inhibit exn 110726============================================================= val SOME (t',_) = rewrite_set_ thy false prog_expr t; val s' = UnparseC.term t'; if s' = "[a, b]" then () else error "new behaviour with prog_expr 3.3."; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "vs_s::real list", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "vs_s::real list", TermC.parse_test @{context} s')]; (*--- 4.line in script ---*) -val t = TermC.str2term "nth_h 1 v_s"; +val t = TermC.parse_test @{context} "nth_h 1 v_s"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term "nth_h 1 [a, b]"; +val t = TermC.parse_test @{context} "nth_h 1 [a, b]"; (*=== inhibit exn 110726============================================================= val SOME (t',_) = rewrite_set_ thy false prog_expr t; val s' = UnparseC.term t'; if s' = "a" then () else error "new behaviour with prog_expr 3.4."; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "v_1", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "v_1", TermC.parse_test @{context} s')]; (*--- 5.line in script ---*) -val t = TermC.str2term "nth_h 2 v_s"; +val t = TermC.parse_test @{context} "nth_h 2 v_s"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term "nth_h 2 [a, b]"; +val t = TermC.parse_test @{context} "nth_h 2 [a, b]"; (*=== inhibit exn 110726============================================================= val SOME (t',_) = rewrite_set_ thy false prog_expr t; val s' = UnparseC.term t'; if s' = "b" then () else error "new behaviour with prog_expr 3.5."; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "v_2", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "v_2", TermC.parse_test @{context} s')]; (*--- 6.line in script ---*) -val t = TermC.str2term "(hd o (filterVar v_1)) (es_s::bool list)"; +val t = TermC.parse_test @{context} "(hd o (filterVar v_1)) (es_s::bool list)"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term +val t = TermC.parse_test @{context} "(hd o filterVar a) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]"; val SOME (t',_) = rewrite_set_ ctxt false prog_expr t; val s' = UnparseC.term t'; @@ -737,14 +737,14 @@ if s' = "a / 2 = r * sin alpha" then () else error "new behaviour with prog_expr 3.6."; === inhibit exn 110726=============================================================*) -val e_1 = TermC.str2term "e_1::bool"; -val env = env @ [(e_1, TermC.str2term s')]; +val e_1 = TermC.parse_test @{context} "e_1::bool"; +val env = env @ [(e_1, TermC.parse_test @{context} s')]; (*--- 7.line in script ---*) -val t = TermC.str2term "(hd o (filterVar v_2)) (es_s::bool list)"; +val t = TermC.parse_test @{context} "(hd o (filterVar v_2)) (es_s::bool list)"; val s = subst_atomic env t; UnparseC.term s; -val t = TermC.str2term +val t = TermC.parse_test @{context} "(hd o filterVar b) [a / 2 = r * sin alpha, b / 2 = r * cos alpha]"; val SOME (t',_) = rewrite_set_ ctxt false prog_expr t; val s' = UnparseC.term t'; @@ -752,30 +752,30 @@ if s' = "b / 2 = r * cos alpha" then () else error "new behaviour with prog_expr 3.7."; === inhibit exn 110726=============================================================*) -val env = env @ [(TermC.str2term "e_2::bool", TermC.str2term s')]; +val env = env @ [(TermC.parse_test @{context} "e_2::bool", TermC.parse_test @{context} s')]; (*--- 8.line in script ---*) -val t = TermC.str2term "(SubProblem (Reals_s,[univar,equation],[no_met])\ +val t = TermC.parse_test @{context} "(SubProblem (Reals_s,[univar,equation],[no_met])\ \ [BOOL e_1, REAL v_1])"; val s = subst_atomic env t; UnparseC.term s; "SubProblem (Reals_s, [univar, equation], [no_met])\ \ [BOOL (a / 2 = r * sin alpha), REAL a]"; -val s_1 = TermC.str2term "[a = 2*r*sin alpha]"; -val env = env @ [(TermC.str2term "s_1::bool list", s_1)]; +val s_1 = TermC.parse_test @{context} "[a = 2*r*sin alpha]"; +val env = env @ [(TermC.parse_test @{context} "s_1::bool list", s_1)]; (*--- 9.line in script ---*) -val t = TermC.str2term "(SubProblem (Reals_s,[univar,equation],[no_met])\ +val t = TermC.parse_test @{context} "(SubProblem (Reals_s,[univar,equation],[no_met])\ \ [BOOL e_2, REAL v_2])"; val s = subst_atomic env t; UnparseC.term s; "SubProblem (Reals_s, [univar, equation], [no_met])\ \ [BOOL (b / 2 = r * cos alpha), REAL b]"; -val s_2 = TermC.str2term "[b = 2*r*cos alpha]"; -val env = env @ [(TermC.str2term "s_2::bool list", s_2)]; +val s_2 = TermC.parse_test @{context} "[b = 2*r*cos alpha]"; +val env = env @ [(TermC.parse_test @{context} "s_2::bool list", s_2)]; (*--- 10.line in script ---*) -val t = TermC.str2term +val t = TermC.parse_test @{context} "Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] (h_h::bool)"; val s = subst_atomic env t; UnparseC.term s; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/diff.sml --- a/test/Tools/isac/Knowledge/diff.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/diff.sml Sun Oct 09 07:44:22 2022 +0200 @@ -218,11 +218,11 @@ "----------- primed id ----------------------------------"; "----------- primed id ----------------------------------"; val ctxt = Proof_Context.init_global @{theory Isac_Knowledge}; -val f_ = TermC.str2term "f_f::bool"; -val f = TermC.str2term "A = s * (a - s)"; -val v_ = TermC.str2term "v_v"; -val v = TermC.str2term "s"; -val screxp0 = TermC.str2term "Take ((primed (lhs f_f)) = d_d v_v (rhs f_f))"; +val f_ = TermC.parse_test @{context} "f_f::bool"; +val f = TermC.parse_test @{context} "A = s * (a - s)"; +val v_ = TermC.parse_test @{context} "v_v"; +val v = TermC.parse_test @{context} "s"; +val screxp0 = TermC.parse_test @{context} "Take ((primed (lhs f_f)) = d_d v_v (rhs f_f))"; TermC.atomty screxp0; val screxp1 = subst_atomic [(f_, f), (v_, v)] screxp0; @@ -268,32 +268,32 @@ "----------- diff_conv, sym_diff_conv -------------------"; "----------- diff_conv, sym_diff_conv -------------------"; "----------- diff_conv, sym_diff_conv -------------------"; -val subs = [(TermC.str2term "bdv", TermC.str2term "x")]; +val subs = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]; val rls = diff_conv; -val t = TermC.str2term "2/x \ 2"; +val t = TermC.parse_test @{context} "2/x \ 2"; val SOME (t,_) = rewrite_set_inst_ ctxt false subs rls t; UnparseC.term t; if UnparseC.term t = "2 * x \ - 2" then () else error "diff.sml 1/x"; -val t = TermC.str2term "sqrt (x \ 3)"; +val t = TermC.parse_test @{context} "sqrt (x \ 3)"; val SOME (t,_) = rewrite_set_inst_ ctxt false subs rls t; UnparseC.term t; if UnparseC.term t = "x \ (3 / 2)" then () else error "diff.sml x \ 1/2"; -val t = TermC.str2term "2 / sqrt x \ 3"; +val t = TermC.parse_test @{context} "2 / sqrt x \ 3"; val SOME (t,_) = rewrite_set_inst_ ctxt false subs rls t; UnparseC.term t; if UnparseC.term t = "2 * x \ (- 3 / 2)" then () else error "diff.sml x \ - 1/2"; val rls = diff_sym_conv; -val t = TermC.str2term "2 * x \ - 2"; +val t = TermC.parse_test @{context} "2 * x \ - 2"; val SOME (t, _) = rewrite_set_inst_ ctxt false subs rls t; UnparseC.term t; if UnparseC.term t = "2 / x \ 2" then () else error "diff.sml sym 1/x"; -val t = TermC.str2term "x \ (3 / 2)"; +val t = TermC.parse_test @{context} "x \ (3 / 2)"; val SOME (t,_) = rewrite_set_inst_ ctxt false subs rls t; UnparseC.term t; if UnparseC.term t = "sqrt (x \ 3)" then ((*..wrong rewrite*)) else error"diff.sml sym x \ 1/x"; -val t = TermC.str2term "2 * x \ (-3 / 2)"; +val t = TermC.parse_test @{context} "2 * x \ (-3 / 2)"; val SOME (t,_) = rewrite_set_inst_ ctxt false subs rls t; UnparseC.term t; if UnparseC.term t ="2 / sqrt (x \ 3)"then()else error"diff.sml sym x \ - 1/x"; @@ -388,14 +388,14 @@ "----------- tests for examples -------------------------"; "----------- tests for examples -------------------------"; "----- TermC.parse errors"; -(*TermC.str2term "F = sqrt( y \ 2 - O) * (z + O \ 2)"; -TermC.str2term "O"; -TermC.str2term "OO"; ---errors*) -TermC.str2term "OOO"; +(*TermC.parse_test @{context} "F = sqrt( y \ 2 - O) * (z + O \ 2)"; +TermC.parse_test @{context} "O"; +TermC.parse_test @{context} "OO"; ---errors*) +TermC.parse_test @{context} "OOO"; "----- thm 'diff_prod_const'"; -val subs = [(TermC.str2term "bdv", TermC.str2term "l")]; -val f = TermC.str2term "G' = d_d l (l * sqrt (7 * s \ 2 - l \ 2))"; +val subs = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "l")]; +val f = TermC.parse_test @{context} "G' = d_d l (l * sqrt (7 * s \ 2 - l \ 2))"; "------------inform for x \ 2+x+1 -------------------------"; "------------inform for x \ 2+x+1 -------------------------"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/eqsystem-1.sml --- a/test/Tools/isac/Knowledge/eqsystem-1.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/eqsystem-1.sml Sun Oct 09 07:44:22 2022 +0200 @@ -33,46 +33,46 @@ "----------- occur_exactly_in ------------------------------------"; "----------- occur_exactly_in ------------------------------------"; "----------- occur_exactly_in ------------------------------------"; -val all = [TermC.str2term"c", TermC.str2term"c_2", TermC.str2term"c_3"]; -val t = TermC.str2term"0 = - 1 * q_0 * L \ 2 / 2 + L * c + c_2"; +val all = [TermC.parse_test @{context}"c", TermC.parse_test @{context}"c_2", TermC.parse_test @{context}"c_3"]; +val t = TermC.parse_test @{context}"0 = - 1 * q_0 * L \ 2 / 2 + L * c + c_2"; -if occur_exactly_in [TermC.str2term"c", TermC.str2term"c_2"] all t +if occur_exactly_in [TermC.parse_test @{context}"c", TermC.parse_test @{context}"c_2"] all t then () else error "eqsystem.sml occur_exactly_in 1"; -if not (occur_exactly_in [TermC.str2term"c", TermC.str2term"c_2", TermC.str2term"c_3"] all t) +if not (occur_exactly_in [TermC.parse_test @{context}"c", TermC.parse_test @{context}"c_2", TermC.parse_test @{context}"c_3"] all t) then () else error "eqsystem.sml occur_exactly_in 2"; -if not (occur_exactly_in [TermC.str2term"c_2"] all t) +if not (occur_exactly_in [TermC.parse_test @{context}"c_2"] all t) then () else error "eqsystem.sml occur_exactly_in 3"; -val t = TermC.str2term"[c,c_2] from [c,c_2,c_3] occur_exactly_in - 1 * q_0 * L \ 2 / 2 + L * c + c_2"; +val t = TermC.parse_test @{context}"[c,c_2] from [c,c_2,c_3] occur_exactly_in - 1 * q_0 * L \ 2 / 2 + L * c + c_2"; eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0; val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0; if str = "[c, c_2] from [c, c_2,\n" ^ " c_3] occur_exactly_in - 1 * q_0 * L \ 2 / 2 + L * c + c_2 = True" then () else error "eval_occur_exactly_in [c, c_2]"; -val t = TermC.str2term ("[c,c_2,c_3] from [c,c_2,c_3] occur_exactly_in " ^ +val t = TermC.parse_test @{context} ("[c,c_2,c_3] from [c,c_2,c_3] occur_exactly_in " ^ "- 1 * q_0 * L \ 2 / 2 + L * c + c_2"); val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0; if str = "[c, c_2,\n c_3] from [c, c_2,\n" ^ " c_3] occur_exactly_in - 1 * q_0 * L \ 2 / 2 + L * c + c_2 = False" then () else error "eval_occur_exactly_in [c, c_2, c_3]"; -val t = TermC.str2term"[c_2] from [c,c_2,c_3] occur_exactly_in \ +val t = TermC.parse_test @{context}"[c_2] from [c,c_2,c_3] occur_exactly_in \ \- 1 * q_0 * L \ 2 / 2 + L * c + c_2"; val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0; if str = "[c_2] from [c, c_2,\n" ^ " c_3] occur_exactly_in - 1 * q_0 * L \ 2 / 2 + L * c + c_2 = False" then () else error "eval_occur_exactly_in [c, c_2, c_3]"; -val t = TermC.str2term"[] from [c,c_2,c_3] occur_exactly_in 0"; +val t = TermC.parse_test @{context}"[] from [c,c_2,c_3] occur_exactly_in 0"; val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0; if str = "[] from [c, c_2, c_3] occur_exactly_in 0 = True" then () else error "eval_occur_exactly_in [c, c_2, c_3]"; val t = - TermC.str2term + TermC.parse_test @{context} "[] from [c, c_2, c_3, c_4] occur_exactly_in - 1 * (q_0 * L \ 2) /2"; val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0; if str = "[] from [c, c_2, c_3, c_4] occur_exactly_in \ @@ -82,7 +82,7 @@ "----------- problems --------------------------------------------"; "----------- problems --------------------------------------------"; "----------- problems --------------------------------------------"; -val t = TermC.str2term "Length [x+y=1,y=2] = 2"; +val t = TermC.parse_test @{context} "Length [x+y=1,y=2] = 2"; TermC.atomty t; val testrls = Rule_Set.append_rules "testrls" Rule_Set.empty [(Thm ("LENGTH_NIL", @{thm LENGTH_NIL})), @@ -99,10 +99,10 @@ val SOME t = TermC.parseNEW ctxt "solution LL"; TermC.atomty t; -val t = TermC.str2term +val t = TermC.parse_test @{context} "(tl (tl (tl v_s))) from v_s occur_exactly_in (NTH 1 (e_s::bool list))"; TermC.atomty t; -val t = TermC.str2term ("(tl (tl (tl [c, c_2, c_3, c_4]))) from [c, c_2, c_3, c_4] occur_exactly_in " ^ +val t = TermC.parse_test @{context} ("(tl (tl (tl [c, c_2, c_3, c_4]))) from [c, c_2, c_3, c_4] occur_exactly_in " ^ "(NTH 1 [c_4 = 1, 2 = 2, 3 = 3, 4 = 4])"); (*----- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----\\ assume flawed test setup hidden by "handle _ => ..." @@ -126,39 +126,39 @@ "----------- rewrite-order ord_simplify_System -------------------"; "M_b x = c * x + - 1 * q_0 * (x \ 2 / 2) + c_2"; "--- add.commute ---"; (* ... add.commute cf. b42e334c97ee *) -if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \ 2 / 2)", - TermC.str2term"c * x") then () +if ord_simplify_System false thy [] (TermC.parse_test @{context}"- 1 * q_0 * (x \ 2 / 2)", + TermC.parse_test @{context}"c * x") then () else error "integrate.sml, (- 1 * q_0 * (x \ 2 / 2)) < (c * x) not#1"; -if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \ 2 / 2)", - TermC.str2term"c_2") then () +if ord_simplify_System false thy [] (TermC.parse_test @{context}"- 1 * q_0 * (x \ 2 / 2)", + TermC.parse_test @{context}"c_2") then () else error "integrate.sml, (- 1 * q_0 * (x \ 2 / 2)) < (c_2) not#2"; -if ord_simplify_System false thy [] (TermC.str2term"c * x", - TermC.str2term"c_2") then () +if ord_simplify_System false thy [] (TermC.parse_test @{context}"c * x", + TermC.parse_test @{context}"c_2") then () else error "integrate.sml, (c * x) < (c_2) not#3"; "--- mult.commute ---"; -if ord_simplify_System false thy [] (TermC.str2term"x * c", - TermC.str2term"c * x") then () +if ord_simplify_System false thy [] (TermC.parse_test @{context}"x * c", + TermC.parse_test @{context}"c * x") then () else error "integrate.sml, (x * c) < (c * x) not#4"; -if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \ 2 / 2) * c", - TermC.str2term"- 1 * q_0 * c * (x \ 2 / 2)") +if ord_simplify_System false thy [] (TermC.parse_test @{context}"- 1 * q_0 * (x \ 2 / 2) * c", + TermC.parse_test @{context}"- 1 * q_0 * c * (x \ 2 / 2)") then () else error "integrate.sml, (. * .) < (. * .) not#5"; -if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \ 2 / 2) * c", - TermC.str2term"c * - 1 * q_0 * (x \ 2 / 2)") +if ord_simplify_System false thy [] (TermC.parse_test @{context}"- 1 * q_0 * (x \ 2 / 2) * c", + TermC.parse_test @{context}"c * - 1 * q_0 * (x \ 2 / 2)") then () else error "integrate.sml, (. * .) < (. * .) not#6"; "----------- rewrite in [EqSystem,normalise,2x2] -----------------"; "----------- rewrite in [EqSystem,normalise,2x2] -----------------"; "----------- rewrite in [EqSystem,normalise,2x2] -----------------"; -val t = TermC.str2term"[0 = - 1 * q_0 * L \ 2 / 2 + L * c + c_2,\ +val t = TermC.parse_test @{context}"[0 = - 1 * q_0 * L \ 2 / 2 + L * c + c_2,\ \0 = - 1 * q_0 * 0 \ 2 / 2 + 0 * c + c_2]"; -val bdvs = [(TermC.str2term"bdv_1",TermC.str2term"c"), - (TermC.str2term"bdv_2",TermC.str2term"c_2")]; +val bdvs = [(TermC.parse_test @{context}"bdv_1",TermC.parse_test @{context}"c"), + (TermC.parse_test @{context}"bdv_2",TermC.parse_test @{context}"c_2")]; val SOME (t,_) = rewrite_set_inst_ ctxt true bdvs simplify_System_parenthesized t; if UnparseC.term t = "[0 = - 1 * q_0 * L \ 2 / 2 + (L * c + c_2), 0 = c_2]" then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.1"; @@ -182,7 +182,7 @@ val thy = @{theory "Isac_Knowledge"} (*because of Undeclared constant "Biegelinie.EI*); val ctxt = Proof_Context.init_global thy; val t = - TermC.str2term"[0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 \ 3 + \ + TermC.parse_test @{context}"[0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 \ 3 + \ \ - 1 * q_0 / 24 * 0 \ 4),\ \ 0 = c_2 + c * L + 1 / EI * (L * q_0 / 12 * L \ 3 + \ \ - 1 * q_0 / 24 * L \ 4)]"; @@ -218,10 +218,10 @@ "----------- rewrite in [EqSystem,top_down_substitution,2x2] -----"; "----------- rewrite in [EqSystem,top_down_substitution,2x2] -----"; "----------- rewrite in [EqSystem,top_down_substitution,2x2] -----"; -val e1__ = TermC.str2term "c_2 = 77"; -val e2__ = TermC.str2term "L * c + c_2 = q_0 * L \ 2 / 2"; -val bdvs = [(TermC.str2term"bdv_1",TermC.str2term"c"), - (TermC.str2term"bdv_2",TermC.str2term"c_2")]; +val e1__ = TermC.parse_test @{context} "c_2 = 77"; +val e2__ = TermC.parse_test @{context} "L * c + c_2 = q_0 * L \ 2 / 2"; +val bdvs = [(TermC.parse_test @{context}"bdv_1",TermC.parse_test @{context}"c"), + (TermC.parse_test @{context}"bdv_2",TermC.parse_test @{context}"c_2")]; val SOME (e2__,_) = rewrite_terms_ ctxt Rewrite_Ord.function_empty Rule_Set.Empty [e1__] e2__; if UnparseC.term e2__ = "L * c + 77 = q_0 * L \ 2 / 2" then () else error "eqsystem.sml top_down_substitution,2x2] subst"; @@ -235,15 +235,15 @@ if UnparseC.term e2__ = "c = (q_0 * L \ 2 / 2 + - 1 * 77) / L" then () else error "eqsystem.sml top_down_substitution,2x2] isolate"; -val t = TermC.str2term "[c_2 = 77, c = (q_0 * L \ 2 / 2 + - 1 * 77) / L]"; +val t = TermC.parse_test @{context} "[c_2 = 77, c = (q_0 * L \ 2 / 2 + - 1 * 77) / L]"; val SOME (t,_) = rewrite_set_ ctxt true order_system t; if UnparseC.term t = "[c = (q_0 * L \ 2 / 2 + - 1 * 77) / L, c_2 = 77]" then () else error "eqsystem.sml top_down_substitution,2x2] order_system"; if not (ord_simplify_System false thy [] - (TermC.str2term"[c_2 = 77, c = (q_0 * L \ 2 / 2 + - 1 * 77) / L]", - TermC.str2term"[c = (q_0 * L \ 2 / 2 + - 1 * 77) / L, c_2 = 77]")) + (TermC.parse_test @{context}"[c_2 = 77, c = (q_0 * L \ 2 / 2 + - 1 * 77) / L]", + TermC.parse_test @{context}"[c = (q_0 * L \ 2 / 2 + - 1 * 77) / L, c_2 = 77]")) then () else error "eqsystem.sml, order_result rew_ord"; @@ -251,15 +251,15 @@ "----------- rewrite in [EqSystem,normalise,4x4] -----------------"; "----------- rewrite in [EqSystem,normalise,4x4] -----------------"; (*STOPPED.WN06?: revise rewrite in [EqSystem,normalise,4x4] from before 0609*) -val t = TermC.str2term ( +val t = TermC.parse_test @{context} ( "[(0::real) = - 1 * q_0 * 0 \ 2 / 2 + 0 * c_3 + c_4, " ^ "(0::real) = - 1 * q_0 * L \ 2 / 2 + L * c_3 + c_4, " ^ "c + c_2 + c_3 + c_4 = 0, " ^ "c_2 + c_3 + c_4 = 0]"); -val bdvs = [(TermC.str2term"bdv_1::real",TermC.str2term"c::real"), - (TermC.str2term"bdv_2::real",TermC.str2term"c_2::real"), - (TermC.str2term"bdv_3::real",TermC.str2term"c_3::real"), - (TermC.str2term"bdv_4::real",TermC.str2term"c_4::real")]; +val bdvs = [(TermC.parse_test @{context}"bdv_1::real",TermC.parse_test @{context}"c::real"), + (TermC.parse_test @{context}"bdv_2::real",TermC.parse_test @{context}"c_2::real"), + (TermC.parse_test @{context}"bdv_3::real",TermC.parse_test @{context}"c_3::real"), + (TermC.parse_test @{context}"bdv_4::real",TermC.parse_test @{context}"c_4::real")]; val SOME (t, _) = rewrite_set_inst_ ctxt true bdvs simplify_System_parenthesized t; if UnparseC.term t = "[0 = c_4, 0 = - 1 * q_0 * L \ 2 / 2 + (L * c_3 + c_4),\n c + (c_2 + (c_3 + c_4)) = 0, c_2 + (c_3 + c_4) = 0]" @@ -367,7 +367,7 @@ (*... resulted in False "[c, c_2] from_ [c, c_2] occur_exactly_in nth_ 2\n [c_2 = 0, L * c + c_2 = q_0 * L \ 2 / 2]"]*) -val t = TermC.str2term ("[c, c_2] from [c, c_2] occur_exactly_in NTH 2" ^ +val t = TermC.parse_test @{context} ("[c, c_2] from [c, c_2] occur_exactly_in NTH 2" ^ "[c_2 = 0, L * c + c_2 = q_0 * L \ 2 / 2]"); val SOME (t', _) = rewrite_set_ ctxt false prls_triangular t; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/eqsystem-2.sml --- a/test/Tools/isac/Knowledge/eqsystem-2.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/eqsystem-2.sml Sun Oct 09 07:44:22 2022 +0200 @@ -108,8 +108,8 @@ "----------- all systems from Biegelinie -------------------------"; val thy = @{theory Isac_Knowledge} val subst = - [(TermC.str2term "bdv_1", TermC.str2term "c"), (TermC.str2term "bdv_2", TermC.str2term "c_2"), - (TermC.str2term "bdv_3", TermC.str2term "c_3"), (TermC.str2term "bdv_4", TermC.str2term "c_4")]; + [(TermC.parse_test @{context} "bdv_1", TermC.parse_test @{context} "c"), (TermC.parse_test @{context} "bdv_2", TermC.parse_test @{context} "c_2"), + (TermC.parse_test @{context} "bdv_3", TermC.parse_test @{context} "c_3"), (TermC.parse_test @{context} "bdv_4", TermC.parse_test @{context} "c_4")]; "------- Bsp 7.27"; States.reset (); @@ -125,7 +125,7 @@ c c_2 c_3 c_4 c c_2 1->2: c c_2 c_4 c c_2 c c_2 c_3 c_4 [2':c, 1:c_2, 3:c_4] -> 4:c_3*) -val t = TermC.str2term +val t = TermC.parse_test @{context} ("[0 = c_4, " ^ "0 = c_4 + L * c_3 +(12 * L \ 2 * c_2 + 4 * L \ 3 * c + - 1 * L \ 4 * q_0) / (- 24 * EI), " ^ "0 = c_2, " ^ @@ -136,7 +136,7 @@ then () else error "Bsp 7.27"; "----- Bsp 7.27 go through the rewrites in met_eqsys_norm_4x4"; -val t = TermC.str2term "0 = (2 * c_2 + 2 * L * c + - 1 * L \ 2 * q_0) / 2"; +val t = TermC.parse_test @{context} "0 = (2 * c_2 + 2 * L * c + - 1 * L \ 2 * q_0) / 2"; val NONE = rewrite_set_ ctxt false norm_Rational t; val SOME (t,_) = rewrite_set_inst_ ctxt false subst simplify_System_parenthesized t; @@ -181,7 +181,7 @@ c c_2 c_3 c_4 c c_2 c_3 1:c_3 -> 2:c c_2 2: c c_2 c_3 c_4 c c_2 c_3 c c_2 c_3 c_4 3:c_4 -> 4:c c_2 c_3 1:c_3 -> 4:c c_2*) -val t = TermC.str2term +val t = TermC.parse_test @{context} ("[0 = c_4 + 0 / (- 1 * EI), " ^ "0 = c_4 + L * c_3 + (12 * L \ 2 * c_2 + 4 * L \ 3 * c + - 1 * L \ 4 * q_0) / (- 24 * EI), " ^ "0 = c_3 + 0 / (- 1 * EI), " ^ @@ -203,7 +203,7 @@ c_4 | STOPPED.WN06? test methods @@@@@@@@@@@@@@@@@@@@@@@*) "----- 7.70 go through the rewrites in met_eqsys_norm_4x4"; -val t = TermC.str2term +val t = TermC.parse_test @{context} ("[L * q_0 = c, " ^ "0 = (2 * c_2 + 2 * L * c + - 1 * L \ 2 * q_0) / 2, " ^ "0 = c_4, " ^ @@ -321,7 +321,7 @@ c_4 | c_3 |2:c_3 -> 4' :c c_2 c_4 | | c c_2 c_3 c_4 | c_4 |3' | | c_3 |c c_2 c_3 c_4 |3:c_4 -> 4'':c c_2 |4'':c c_2 | *) -val t = TermC.str2term"[0 = (2 * c_2 + 2 * L * c + - 1 * L \ 2 * q_0) / 2, \ +val t = TermC.parse_test @{context}"[0 = (2 * c_2 + 2 * L * c + - 1 * L \ 2 * q_0) / 2, \ \ 0 = c_4 + 0 / (- 1 * EI), \ \ 0 = c_4 + L * c_3 +(12 * L \ 2 * c_2 + 4 * L \ 3 * c + - 1 * L \ 4 * q_0) /(- 24 * EI),\ \ 0 = c_3 + 0 / (- 1 * EI)]"; @@ -356,7 +356,7 @@ c c_2 | |1:c_2 -> 2':c |c_2 c c_4 | | | c c_2 c_3 c_4 | |3:c_4 -> 4':c c_2 c_3 |c_2 c c_3*) -val t = TermC.str2term"[0 = c_2, \ +val t = TermC.parse_test @{context}"[0 = c_2, \ \ 0 = (6 * c_2 + 6 * L * c + - 1 * L \ 2 * q_0) / 6, \ \ 0 = c_4 + 0 / (- 1 * EI), \ \ 0 = c_4 + L * c_3 + (60 * L \ 2 * c_2 + 20 * L \ 3 * c + - 1 * L \ 4 * q_0) / (- 120 * EI)]"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/integrate.sml --- a/test/Tools/isac/Knowledge/integrate.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/integrate.sml Sun Oct 09 07:44:22 2022 +0200 @@ -51,14 +51,14 @@ "----------- parsing ------------------------------------"; "----------- parsing ------------------------------------"; "----------- parsing ------------------------------------"; -val t = TermC.str2term "Integral x D x"; -val t = TermC.str2term "Integral x \ 2 D x"; +val t = TermC.parse_test @{context} "Integral x D x"; +val t = TermC.parse_test @{context} "Integral x \ 2 D x"; case t of Const (\<^const_name>\Integral\, _) $ (Const (\<^const_name>\realpow\, _) $ Free _ $ _) $ Free ("x", _) => () | _ => error "integrate.sml: parsing: Integral x \ 2 D x"; -val t = TermC.str2term "ff x is_f_x"; +val t = TermC.parse_test @{context} "ff x is_f_x"; case t of Const (\<^const_name>\is_f_x\, _) $ _ => () | _ => error "integrate.sml: parsing: ff x is_f_x"; @@ -66,26 +66,26 @@ "----------- integrate by rewriting ---------------------"; "----------- integrate by rewriting ---------------------"; "----------- integrate by rewriting ---------------------"; -val str = rewrit @{thm "integral_const"} (TermC.str2term "Integral 1 D x"); +val str = rewrit @{thm "integral_const"} (TermC.parse_test @{context} "Integral 1 D x"); if term2s str = "1 * x" then () else error "integrate.sml Integral 1 D x"; -val str = rewrit @{thm "integral_const"} (TermC.str2term "Integral M'/EJ D x"); +val str = rewrit @{thm "integral_const"} (TermC.parse_test @{context} "Integral M'/EJ D x"); if term2s str = "M' / EJ * x" then () else error "Integral M'/EJ D x BY integral_const"; -val str = rewrit @{thm "integral_var"} (TermC.str2term "Integral x D x"); +val str = rewrit @{thm "integral_var"} (TermC.parse_test @{context} "Integral x D x"); if term2s str = "x \ 2 / 2" then () else error "Integral x D x BY integral_var"; -val str = rewrit @{thm "integral_add"} (TermC.str2term "Integral x + 1 D x"); +val str = rewrit @{thm "integral_add"} (TermC.parse_test @{context} "Integral x + 1 D x"); if term2s str = "Integral x D x + Integral 1 D x" then () else error "Integral x + 1 D x BY integral_add"; -val str = rewrit @{thm "integral_mult"} (TermC.str2term "Integral M'/EJ * x \ 3 D x"); +val str = rewrit @{thm "integral_mult"} (TermC.parse_test @{context} "Integral M'/EJ * x \ 3 D x"); if term2s str = "M' / EJ * Integral x \ 3 D x" then () else error "Integral M'/EJ * x \ 3 D x BY integral_mult"; -val str = rewrit @{thm "integral_pow"} (TermC.str2term "Integral x \ 3 D x"); +val str = rewrit @{thm "integral_pow"} (TermC.parse_test @{context} "Integral x \ 3 D x"); if term2s str = "x \ (3 + 1) / (3 + 1)" then () else error "integrate.sml Integral x \ 3 D x"; @@ -93,7 +93,7 @@ "----------- test add_new_c, TermC.is_f_x ---------------------"; "----------- test add_new_c, TermC.is_f_x ---------------------"; "----------- test add_new_c, TermC.is_f_x ---------------------"; -val term = TermC.str2term "x \ 2 * c + c_2"; +val term = TermC.parse_test @{context} "x \ 2 * c + c_2"; val cc = new_c term; if UnparseC.term cc = "c_3" then () else error "integrate.sml: new_c ???"; @@ -108,7 +108,7 @@ if UnparseC.term t' = "x \ 2 * c + c_2 + c_3" then () else error "intergrate.sml: diff. rewrite_set add_new_c 1"; -val term = TermC.str2term "ff x = x \ 2*c + c_2"; +val term = TermC.parse_test @{context} "ff x = x \ 2*c + c_2"; val SOME (t',_) = rewrite_set_ ctxt true add_new_c term; if UnparseC.term t' = "ff x = x \ 2 * c + c_2 + c_3" then () else error "intergrate.sml: diff. rewrite_set add_new_c 2"; @@ -173,9 +173,9 @@ "----------- simplify by ruleset reducing make_ratpoly_in"; val thy = @{theory "Isac_Knowledge"}; val ctxt = Proof_Context.init_global thy; -val subst = [(TermC.str2term "bdv ::real", TermC.str2term "x ::real")]; (*DOESN'T HELP*) +val subst = [(TermC.parse_test @{context} "bdv ::real", TermC.parse_test @{context} "x ::real")]; (*DOESN'T HELP*) "===== test 1"; -val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \ 2 / 2)"; +val t = TermC.parse_test @{context} "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \ 2 / 2)"; "----- stepwise from the rulesets in simplify_Integral and below-----"; val rls = norm_Rational_noadd_fractions; @@ -196,7 +196,7 @@ else error "integrate.sml simplify by ruleset discard_parenth.. #3"; "===== test 4"; -val subs = [(TermC.str2term "bdv::real", TermC.str2term "x::real")]; +val subs = [(TermC.parse_test @{context} "bdv::real", TermC.parse_test @{context} "x::real")]; val rls = (Rule_Set.append_rules "separate_bdv" collect_bdv [Thm ("separate_bdv", @{thm separate_bdv}), @@ -221,7 +221,7 @@ else error "integrate.sml simplify by ruleset separate_bdv.. #4"; "===== test 5"; -val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \ 2 / 2)"; +val t = TermC.parse_test @{context} "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \ 2 / 2)"; val rls = simplify_Integral; val SOME (t,[]) = rewrite_set_inst_ ctxt true subs rls t; (* given was: "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \ 2 / 2)" *) @@ -231,10 +231,10 @@ "........... 2nd integral ........................................"; "........... 2nd integral ........................................"; "........... 2nd integral ........................................"; -val subs = [(TermC.str2term "bdv::real", TermC.str2term "x::real")]; +val subs = [(TermC.parse_test @{context} "bdv::real", TermC.parse_test @{context} "x::real")]; val thy = @{theory Biegelinie}; -val t = TermC.str2term +val t = TermC.parse_test @{context} "Integral 1 / EI * (L * q_0 / 2 * (x \ 2 / 2) + - 1 * q_0 / 2 * (x \ 3 / 3)) D x"; val rls = simplify_Integral; @@ -309,7 +309,7 @@ "----------- rewrite 3rd integration in 7.27 ------------"; "----------- rewrite 3rd integration in 7.27 ------------"; "----------- rewrite 3rd integration in 7.27 ------------"; -val t = TermC.str2term "Integral 1 / EI * ((L * q_0 * x + - 1 * q_0 * x \ 2) / 2) D x"; +val t = TermC.parse_test @{context} "Integral 1 / EI * ((L * q_0 * x + - 1 * q_0 * x \ 2) / 2) D x"; val SOME(t, _)= rewrite_set_inst_ ctxt true subs simplify_Integral t; if UnparseC.term t = "Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \ 2) D x" @@ -358,7 +358,7 @@ if F1_ = F2_ then () else error "integrate.sml: unequal find's"; val ((dsc as Const (\<^const_name>\antiDerivativeName\, _)) - $ Free ("ff", F3_type)) = TermC.str2term "antiDerivativeName ff"; + $ Free ("ff", F3_type)) = TermC.parse_test @{context} "antiDerivativeName ff"; if Input_Descript.is_a dsc then () else error "integrate.sml: no description"; if F1_type = F3_type then () else error "integrate.sml: unequal types in find's"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/logexp.sml --- a/test/Tools/isac/Knowledge/logexp.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/logexp.sml Sun Oct 09 07:44:22 2022 +0200 @@ -29,9 +29,9 @@ ["equation", "test"]; *) *) -val t = TermC.str2term "(2 log x)"; -val t = TermC.str2term "(2 log x) = 3"; -val t = TermC.str2term "matches ((?a log x) = ?b) ((2 log x) = 3)"; +val t = TermC.parse_test @{context} "(2 log x)"; +val t = TermC.parse_test @{context} "(2 log x) = 3"; +val t = TermC.parse_test @{context} "matches ((?a log x) = ?b) ((2 log x) = 3)"; TermC.atomty t; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/partial_fractions.sml --- a/test/Tools/isac/Knowledge/partial_fractions.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/partial_fractions.sml Sun Oct 09 07:44:22 2022 +0200 @@ -272,7 +272,7 @@ "----------- progr.vers.2: check erls for multiply_ansatz"; "----------- progr.vers.2: check erls for multiply_ansatz"; (*test for outcommented 3 lines in script: is norm_Rational strong enough?*) -val t = TermC.str2term "(3 / ((- 1 + - 2 * z + 8 * z \ 2) *3/24)) = (3 / ((z - 1 / 2) * (z - - 1 / 4)))"; +val t = TermC.parse_test @{context} "(3 / ((- 1 + - 2 * z + 8 * z \ 2) *3/24)) = (3 / ((z - 1 / 2) * (z - - 1 / 4)))"; val SOME (t', _) = rewrite_set_ @{theory Isac_Knowledge} true ansatz_rls t; UnparseC.term t' = "3 / ((- 1 + - 2 * z + 8 * z \ 2) * 3 / 24) =\n?A / (z - 1 / 2) + ?B / (z - - 1 / 4)"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/poly-1.sml --- a/test/Tools/isac/Knowledge/poly-1.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/poly-1.sml Sun Oct 09 07:44:22 2022 +0200 @@ -30,16 +30,16 @@ "-------- fun is_polyexp -----------------------------------------------------------------------"; "-------- fun is_polyexp -----------------------------------------------------------------------"; "-------- fun is_polyexp -----------------------------------------------------------------------"; -val t = TermC.str2term "x / x"; +val t = TermC.parse_test @{context} "x / x"; if is_polyexp t then error "NOT is_polyexp (x / x)" else (); -val t = TermC.str2term "- 1 * A * 3"; +val t = TermC.parse_test @{context} "- 1 * A * 3"; if is_polyexp t then () else error "is_polyexp (- 1 * A * 3)"; -val t = TermC.str2term "- 1 * AA * 3"; +val t = TermC.parse_test @{context} "- 1 * AA * 3"; if is_polyexp t then () else error "is_polyexp (- 1 * AA * 3)"; -val t = TermC.str2term "x * x + x * y + (- 1 * y * x + - 1 * y * y)::real"; +val t = TermC.parse_test @{context} "x * x + x * y + (- 1 * y * x + - 1 * y * y)::real"; if is_polyexp t then () else error "is_polyexp (x * x + x * y + (- 1 * y * x + - 1 * y * y))"; "-------- fun has_degree_in --------------------------------------------------------------------"; @@ -264,7 +264,7 @@ "-------- fun is_addUnordered (x \ 2 * y \ 2 + x \ 3 * y) --------------------------------------"; "-------- fun is_addUnordered (x \ 2 * y \ 2 + x \ 3 * y) --------------------------------------"; val ctxt = Proof_Context.init_global @{theory} -val t = TermC.str2term "x \ 2 * y \ 2 + x * x \ 2 * y"; +val t = TermC.parse_test @{context} "x \ 2 * y \ 2 + x * x \ 2 * y"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; UnparseC.term t = "x \ 2 * y \ 2 + x \ 3 * y"; if UnparseC.term t = "x \ 3 * y + x \ 2 * y \ 2" then () @@ -280,9 +280,9 @@ ####### calc. to: False (*isa*) True (*isa2*) ( **) - if is_addUnordered (TermC.str2term "x \ 2 * y \ 2 + x \ 3 * y ::real") then () + if is_addUnordered (TermC.parse_test @{context} "x \ 2 * y \ 2 + x \ 3 * y ::real") then () else error"is_addUnordered x \ 2 * y \ 2 + x \ 3 * y"; (*isa == isa2*) -"~~~~~ fun is_addUnordered , args:"; val (t) = (TermC.str2term "x \ 2 * y \ 2 + x \ 3 * y ::real"); +"~~~~~ fun is_addUnordered , args:"; val (t) = (TermC.parse_test @{context} "x \ 2 * y \ 2 + x \ 3 * y ::real"); ((is_polyexp t) andalso not (t = sort_monoms t)) = false; (*isa == isa2*) (*+*) if is_polyexp t = true then () else error "is_polyexp x \ 2 * y \ 2 + x \ 3 * y"; @@ -412,32 +412,32 @@ "-------- check make_polynomial with simple terms ----------------------------------------------"; "-------- check make_polynomial with simple terms ----------------------------------------------"; "----- check 1 ---"; -val t = TermC.str2term "2*3*a"; +val t = TermC.parse_test @{context} "2*3*a"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; if UnparseC.term t = "6 * a" then () else error "check make_polynomial 1"; "----- check 2 ---"; -val t = TermC.str2term "2*a + 3*a"; +val t = TermC.parse_test @{context} "2*a + 3*a"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; if UnparseC.term t = "5 * a" then () else error "check make_polynomial 2"; "----- check 3 ---"; -val t = TermC.str2term "2*a + 3*a + 3*a"; +val t = TermC.parse_test @{context} "2*a + 3*a + 3*a"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; if UnparseC.term t = "8 * a" then () else error "check make_polynomial 3"; "----- check 4 ---"; -val t = TermC.str2term "3*a - 2*a"; +val t = TermC.parse_test @{context} "3*a - 2*a"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; if UnparseC.term t = "a" then () else error "check make_polynomial 4"; "----- check 5 ---"; -val t = TermC.str2term "4*(3*a - 2*a)"; +val t = TermC.parse_test @{context} "4*(3*a - 2*a)"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; if UnparseC.term t = "4 * a" then () else error "check make_polynomial 5"; "----- check 6 ---"; -val t = TermC.str2term "4*(3*a \ 2 - 2*a \ 2)"; +val t = TermC.parse_test @{context} "4*(3*a \ 2 - 2*a \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; if UnparseC.term t = "4 * a \ 2" then () else error "check make_polynomial 6"; @@ -446,7 +446,7 @@ "-------- fun is_multUnordered (x \ 2 * x) -----------------------------------------------------"; val thy = @{theory "Isac_Knowledge"}; "===== works for a simple example, see rewrite.sml -- fun app_rev ==="; -val t = TermC.str2term "x \ 2 * x"; +val t = TermC.parse_test @{context} "x \ 2 * x"; val SOME (t', _) = rewrite_set_ ctxt true order_mult_ t; if UnparseC.term t' = "x * x \ 2" then () else error "poly.sml Poly.is_multUnordered doesn't work"; @@ -458,7 +458,7 @@ ####### try calc: Poly.is_multUnordered' ======= calc. to: False !!!!!!!!!!!!! INSTEAD OF TRUE in 2002 !!!!!!!!!!!!! *) -val t = TermC.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))"; +val t = TermC.parse_test @{context} "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 ---"; val tsort = sort_variables t; @@ -469,7 +469,7 @@ if is_multUnordered t then () else error "poly.sml diff. is_multUnordered 1"; "----- eval_is_multUnordered ---"; -val tm = TermC.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"; +val tm = TermC.parse_test @{context} "(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"; case eval_is_multUnordered "testid" "" tm @{context} of SOME (_, Const (\<^const_name>\Trueprop\, _) $ (Const (\<^const_name>\HOL.eq\, _) $ @@ -486,7 +486,7 @@ "-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------"; "-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------"; val thy = @{theory "Isac_Knowledge"}; -val t as (_ $ arg) = TermC.str2term "(3 * a + - 2 * a) is_multUnordered"; +val t as (_ $ arg) = TermC.parse_test @{context} "(3 * a + - 2 * a) is_multUnordered"; (*+*)if UnparseC.term (sort_variables arg) = "3 * a + - 2 * a" andalso is_polyexp arg = true (*+*) andalso not (is_multUnordered arg) @@ -501,7 +501,7 @@ | _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED"; "----- is_multUnordered --- (- 2 * a) is_multUnordered = False"; -val t as (_ $ arg) = TermC.str2term "(- 2 * a) is_multUnordered"; +val t as (_ $ arg) = TermC.parse_test @{context} "(- 2 * a) is_multUnordered"; (*+*)if UnparseC.term (sort_variables arg) = "- 2 * a" andalso is_polyexp arg = true (*+*) andalso not (is_multUnordered arg) @@ -515,7 +515,7 @@ | _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED"; "----- is_multUnordered --- (a) is_multUnordered = False"; -val t as (_ $ arg) = TermC.str2term "(a) is_multUnordered"; +val t as (_ $ arg) = TermC.parse_test @{context} "(a) is_multUnordered"; (*+*)if UnparseC.term (sort_variables arg) = "a" andalso is_polyexp arg = true (*+*) andalso not (is_multUnordered arg) @@ -529,7 +529,7 @@ | _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED"; "----- is_multUnordered --- (- 2) is_multUnordered = False"; -val t as (_ $ arg) = TermC.str2term "(- 2) is_multUnordered"; +val t as (_ $ arg) = TermC.parse_test @{context} "(- 2) is_multUnordered"; (*+*)if UnparseC.term (sort_variables arg) = "- 2" andalso is_polyexp arg = true (*+*) andalso not (is_multUnordered arg) @@ -567,7 +567,7 @@ O:x \ 3 + - 1 * (3 * (a * x \ 2)) + - 1 \ 2 * (3 * (a \ 2 * x)) + - 1 \ 3 * a \ 3 -------------------------------------------------------------------------------------------------<> *) -val t = TermC.str2term "x \ 3 + 3 * x \ 2 * (- 1 * a) + 3 * x * ((- 1) \ 2 * a \ 2) + (- 1) \ 3 * a \ 3"; +val t = TermC.parse_test @{context} "x \ 3 + 3 * x \ 2 * (- 1 * a) + 3 * x * ((- 1) \ 2 * a \ 2) + (- 1) \ 3 * a \ 3"; (* "~~~~~ fun is_multUnordered "~~~~~~~ fun sort_variables @@ -636,7 +636,7 @@ "-------- fun is_multUnordered b * a * a ------------------------------------------------------"; "-------- fun is_multUnordered b * a * a ------------------------------------------------------"; "-------- fun is_multUnordered b * a * a ------------------------------------------------------"; -val t = TermC.str2term "b * a * a"; +val t = TermC.parse_test @{context} "b * a * a"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if UnparseC.term t = "a \ 2 * b" then () else error "poly.sml: diff.behav. in make_polynomial 21"; @@ -659,7 +659,7 @@ "-------- fun is_multUnordered 2*3*a -----------------------------------------------------------"; "-------- fun is_multUnordered 2*3*a -----------------------------------------------------------"; "-------- fun is_multUnordered 2*3*a -----------------------------------------------------------"; -val t = TermC.str2term "2*3*a"; +val t = TermC.parse_test @{context} "2*3*a"; val SOME (t', _) = rewrite_set_ ctxt false make_polynomial t; (*+*)if UnparseC.term t' = "6 * a" then () else error "rewrite_set_ 2*3*a CHANGED"; (* @@ -673,7 +673,7 @@ ####### calc. to: True (*isa*) False (*isa2*) *) -val t = TermC.str2term "(6 * a) is_multUnordered"; +val t = TermC.parse_test @{context} "(6 * a) is_multUnordered"; val SOME (_, t') = eval_is_multUnordered "xxx" () t @{context}; @@ -702,7 +702,7 @@ val ctxt = Proof_Context.init_global thy; val SOME (f',_) = rewrite_set_ ctxt false norm_Poly -(TermC.str2term "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben"); +(TermC.parse_test @{context} "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben"); if UnparseC.term f' = "L = 2 * 2 * k + 2 * - 4 * q + senkrecht + oben" then ((*norm_Poly NOT COMPLETE -- TODO MG*)) else error "norm_Poly changed behavior"; @@ -720,7 +720,7 @@ ### rls: order_add_ on: L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben *) "~~~~~ fun sort_monoms , args:"; val (t) = - (TermC.str2term "L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben"); + (TermC.parse_test @{context} "L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben"); (*+*)val t' = sort_monoms t; (*+*)UnparseC.term t' = "L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben"; (*isa*) @@ -729,37 +729,37 @@ "-------- complex examples from textbook Schalk I ----------------------------------------------"; "-------- complex examples from textbook Schalk I ----------------------------------------------"; "-------- complex examples from textbook Schalk I ----------------------------------------------"; -val t = TermC.str2term "1 + 2 * x \ 4 + 2 * - 2 * x \ 4 + x \ 8"; +val t = TermC.parse_test @{context} "1 + 2 * x \ 4 + 2 * - 2 * x \ 4 + x \ 8"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if (UnparseC.term t) = "1 + - 2 * x \ 4 + x \ 8" then () else error "poly.sml: diff.behav. in make_polynomial 9b"; "-----SPB Schalk I p.64 No.296a ---"; -val t = TermC.str2term "(x - a) \ 3"; +val t = TermC.parse_test @{context} "(x - a) \ 3"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if (UnparseC.term t) = "- 1 * a \ 3 + 3 * a \ 2 * x + - 3 * a * x \ 2 + x \ 3" then () else error "poly.sml: diff.behav. in make_polynomial 10"; "-----SPB Schalk I p.64 No.296c ---"; -val t = TermC.str2term "(-3*x - 4*y) \ 3"; +val t = TermC.parse_test @{context} "(-3*x - 4*y) \ 3"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if (UnparseC.term t) = "- 27 * x \ 3 + - 108 * x \ 2 * y + - 144 * x * y \ 2 +\n- 64 * y \ 3" then () else error "poly.sml: diff.behav. in make_polynomial 11"; "-----SPB Schalk I p.62 No.242c ---"; -val t = TermC.str2term "x \ (- 4)*(x \ (- 4)*y \ (- 2)) \ (- 1)*y \ (- 2)"; +val t = TermC.parse_test @{context} "x \ (- 4)*(x \ (- 4)*y \ (- 2)) \ (- 1)*y \ (- 2)"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if (UnparseC.term t) = "1" then () else error "poly.sml: diff.behav. in make_polynomial 12"; "-----SPB Schalk I p.60 No.209a ---"; -val t = TermC.str2term "a \ (7-x) * a \ x"; +val t = TermC.parse_test @{context} "a \ (7-x) * a \ x"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if UnparseC.term t = "a \ 7" then () else error "poly.sml: diff.behav. in make_polynomial 13"; "-----SPB Schalk I p.60 No.209d ---"; -val t = TermC.str2term "d \ x * d \ (x+1) * d \ (2 - 2*x)"; +val t = TermC.parse_test @{context} "d \ x * d \ (x+1) * d \ (2 - 2*x)"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if UnparseC.term t = "d \ 3" then () else error "poly.sml: diff.behav. in make_polynomial 14"; @@ -769,23 +769,23 @@ "-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------"; "-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------"; "-----SPO ---"; -val t = TermC.str2term "a \ 2*a \ (- 2)"; +val t = TermC.parse_test @{context} "a \ 2*a \ (- 2)"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if UnparseC.term t = "1" then () else error "poly.sml: diff.behav. in make_polynomial 15"; "-----SPO ---"; -val t = TermC.str2term "a \ 2*b*b \ (- 1)"; +val t = TermC.parse_test @{context} "a \ 2*b*b \ (- 1)"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if UnparseC.term t = "a \ 2" then () else error "poly.sml: diff.behav. in make_polynomial 18"; "-----SPO ---"; -val t = TermC.str2term "a \ 2*a \ (- 2)"; +val t = TermC.parse_test @{context} "a \ 2*a \ (- 2)"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if (UnparseC.term t) = "1" then () else error "poly.sml: diff.behav. in make_polynomial 19"; "-----SPO ---"; -val t = TermC.str2term "b + a - b"; +val t = TermC.parse_test @{context} "b + a - b"; val SOME (t,_) = rewrite_set_ ctxt false make_polynomial t; UnparseC.term t; if (UnparseC.term t) = "a" then () else error "poly.sml: diff.behav. in make_polynomial 20"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/poly-2.sml --- a/test/Tools/isac/Knowledge/poly-2.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/poly-2.sml Sun Oct 09 07:44:22 2022 +0200 @@ -255,7 +255,7 @@ "~~~~~~~~~~~~~ fun get_basStr used twice --^^ "~~~~~~~~~~~~~ fun get_potStr used twice --^^ *) -val t = TermC.str2term "(1 + 2 * x \ 4 + - 4 * x \ 4 + x \ 8) is_addUnordered"; +val t = TermC.parse_test @{context} "(1 + 2 * x \ 4 + - 4 * x \ 4 + x \ 8) is_addUnordered"; eval_is_addUnordered "xxx" "yyy" t @{context}; "~~~~~ fun eval_is_addUnordered , args:"; val ((thmid:string), _, @@ -420,20 +420,20 @@ "-------- examples from textbook Schalk I ------------------------------------------------------"; "-------- examples from textbook Schalk I ------------------------------------------------------"; "-----SPB Schalk I p.63 No.267b ---"; -val t = TermC.str2term "(5*x \ 2 + 3) * (2*x \ 7 + 3) - (3*x \ 5 + 8) * (6*x \ 4 - 1)"; +val t = TermC.parse_test @{context} "(5*x \ 2 + 3) * (2*x \ 7 + 3) - (3*x \ 5 + 8) * (6*x \ 4 - 1)"; val SOME (t, _) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "17 + 15 * x \ 2 + - 48 * x \ 4 + 3 * x \ 5 + 6 * x \ 7 +\n- 8 * x \ 9" then () else error "poly.sml: diff.behav. in make_polynomial 1"; "-----SPB Schalk I p.63 No.275b ---"; -val t = TermC.str2term "(3*x \ 2 - 2*x*y + y \ 2) * (x \ 2 - 2*y \ 2)"; +val t = TermC.parse_test @{context} "(3*x \ 2 - 2*x*y + y \ 2) * (x \ 2 - 2*y \ 2)"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; if UnparseC.term t = "3 * x \ 4 + - 2 * x \ 3 * y + - 5 * x \ 2 * y \ 2 +\n4 * x * y \ 3 +\n- 2 * y \ 4" then () else error "poly.sml: diff.behav. in make_polynomial 2"; "-----SPB Schalk I p.63 No.279b ---"; -val t = TermC.str2term "(x-a)*(x-b)*(x-c)*(x-d)"; +val t = TermC.parse_test @{context} "(x-a)*(x-b)*(x-c)*(x-d)"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; if UnparseC.term t = ("a * b * c * d + - 1 * a * b * c * x + - 1 * a * b * d * x +\na * b * x \ 2 +\n" ^ @@ -444,32 +444,32 @@ (*associate poly*) "-----SPB Schalk I p.63 No.291 ---"; -val t = TermC.str2term "(5+96*x \ 3+8*x*(-4+(7- 3*x)*4*x))*(5*(2- 3*x)- (- 15*x*(-8*x- 5)))"; +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)))"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; if UnparseC.term t = "50 + - 770 * x + 4520 * x \ 2 + - 16320 * x \ 3 +\n- 26880 * x \ 4" then () else error "poly.sml: diff.behav. in make_polynomial 4"; "-----SPB Schalk I p.64 No.295c ---"; -val t = TermC.str2term "(13*a \ 4*b \ 9*c - 12*a \ 3*b \ 6*c \ 9) \ 2"; +val t = TermC.parse_test @{context} "(13*a \ 4*b \ 9*c - 12*a \ 3*b \ 6*c \ 9) \ 2"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; if UnparseC.term t = "169 * a \ 8 * b \ 18 * c \ 2 +\n- 312 * a \ 7 * b \ 15 * c \ 10 +\n144 * a \ 6 * b \ 12 * c \ 18" then ()else error "poly.sml: diff.behav. in make_polynomial 5"; "-----SPB Schalk I p.64 No.299a ---"; -val t = TermC.str2term "(x - y)*(x + y)"; +val t = TermC.parse_test @{context} "(x - y)*(x + y)"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; if UnparseC.term t = "x \ 2 + - 1 * y \ 2" then () else error "poly.sml: diff.behav. in make_polynomial 6"; "-----SPB Schalk I p.64 No.300c ---"; -val t = TermC.str2term "(3*x \ 2*y - 1)*(3*x \ 2*y + 1)"; +val t = TermC.parse_test @{context} "(3*x \ 2*y - 1)*(3*x \ 2*y + 1)"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; if UnparseC.term t = "- 1 + 9 * x \ 4 * y \ 2" then () else error "poly.sml: diff.behav. in make_polynomial 7"; "-----SPB Schalk I p.64 No.302 ---"; -val t = TermC.str2term +val t = TermC.parse_test @{context} "(13*x \ 2 + 5)*(13*x \ 2 - 5) - (5*x \ 2 + 3)*(5*x \ 2 - 3) - (12*x \ 2 + 4)*(12*x \ 2 - 4)"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; if UnparseC.term t = "0" @@ -477,47 +477,47 @@ (* RL?MG?: Bei Berechnung sollte 3 mal real_plus_minus_binom1_p aus expand_poly verwendet werden *) "-----SPB Schalk I p.64 No.306a ---"; -val t = TermC.str2term "((x \ 2 + 1)*(x \ 2 - 1)) \ 2"; +val t = TermC.parse_test @{context} "((x \ 2 + 1)*(x \ 2 - 1)) \ 2"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "1 + 2 * x \ 4 + 2 * - 2 * x \ 4 + x \ 8" then () else error "poly.sml: diff.behav. in 2 * x \ 4 + 2 * - 2 * x \ 4 = - 2 * x \ 4"; (*WN071729 when reducing "rls reduce_012_" for Schaerding, the above resulted in the term below ... but reduces from then correctly*) -val t = TermC.str2term "1 + 2 * x \ 4 + 2 * - 2 * x \ 4 + x \ 8"; +val t = TermC.parse_test @{context} "1 + 2 * x \ 4 + 2 * - 2 * x \ 4 + x \ 8"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "1 + - 2 * x \ 4 + x \ 8" then () else error "poly.sml: diff.behav. in make_polynomial 9b"; "-----SPB Schalk I p.64 No.296a ---"; -val t = TermC.str2term "(x - a) \ 3"; +val t = TermC.parse_test @{context} "(x - a) \ 3"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; -val NONE = eval_is_even "aaa" "bbb" (TermC.str2term "3::real") "ccc"; +val NONE = eval_is_even "aaa" "bbb" (TermC.parse_test @{context} "3::real") "ccc"; if UnparseC.term t = "- 1 * a \ 3 + 3 * a \ 2 * x + - 3 * a * x \ 2 + x \ 3" then () else error "poly.sml: diff.behav. in make_polynomial 10"; "-----SPB Schalk I p.64 No.296c ---"; -val t = TermC.str2term "(-3*x - 4*y) \ 3"; +val t = TermC.parse_test @{context} "(-3*x - 4*y) \ 3"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "- 27 * x \ 3 + - 108 * x \ 2 * y + - 144 * x * y \ 2 +\n- 64 * y \ 3" then () else error "poly.sml: diff.behav. in make_polynomial 11"; "-----SPB Schalk I p.62 No.242c ---"; -val t = TermC.str2term "x \ (-4)*(x \ (-4)*y \ (- 2)) \ (- 1)*y \ (- 2)"; +val t = TermC.parse_test @{context} "x \ (-4)*(x \ (-4)*y \ (- 2)) \ (- 1)*y \ (- 2)"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "1" then () else error "poly.sml: diff.behav. in make_polynomial 12"; "-----SPB Schalk I p.60 No.209a ---"; -val t = TermC.str2term "a \ (7-x) * a \ x"; +val t = TermC.parse_test @{context} "a \ (7-x) * a \ x"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "a \ 7" then () else error "poly.sml: diff.behav. in make_polynomial 13"; "-----SPB Schalk I p.60 No.209d ---"; -val t = TermC.str2term "d \ x * d \ (x+1) * d \ (2 - 2*x)"; +val t = TermC.parse_test @{context} "d \ x * d \ (x+1) * d \ (2 - 2*x)"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "d \ 3" then () else error "poly.sml: diff.behav. in make_polynomial 14"; @@ -526,7 +526,7 @@ "-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------"; "-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------"; "-----Schalk I p.64 No.303 ---"; -val t = TermC.str2term "(a + 2*b)*(a \ 2 + 4*b \ 2)*(a - 2*b) - (a - 6*b)*(a \ 2 + 36*b \ 2)*(a + 6*b)"; +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)"; (*SOMETIMES LOOPS---------------------------------------------------------------------------\\*) val SOME (t, _) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "1280 * b \ 4" @@ -538,49 +538,49 @@ "-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------"; "-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------"; "-----SPO ---"; -val t = TermC.str2term "a + a + a"; +val t = TermC.parse_test @{context} "a + a + a"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "3 * a" then () else error "poly.sml: diff.behav. in make_polynomial 16"; "-----SPO ---"; -val t = TermC.str2term "a + b + b + b"; +val t = TermC.parse_test @{context} "a + b + b + b"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "a + 3 * b" then () else error "poly.sml: diff.behav. in make_polynomial 17"; "-----SPO ---"; -val t = TermC.str2term "b * a * a"; +val t = TermC.parse_test @{context} "b * a * a"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "a \ 2 * b" then () else error "poly.sml: diff.behav. in make_polynomial 21"; "-----SPO ---"; -val t = TermC.str2term "(a \ 2) \ 3"; +val t = TermC.parse_test @{context} "(a \ 2) \ 3"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "a \ 6" then () else error "poly.sml: diff.behav. in make_polynomial 22"; "-----SPO ---"; -val t = TermC.str2term "x \ 2 * y \ 2 + x * x \ 2 * y"; +val t = TermC.parse_test @{context} "x \ 2 * y \ 2 + x * x \ 2 * y"; val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t; if UnparseC.term t = "x \ 3 * y + x \ 2 * y \ 2" then () else error "poly.sml: diff.behav. in make_polynomial 23"; "-----SPO ---"; -val t = TermC.str2term "a * b * b \ (- 1) + a"; +val t = TermC.parse_test @{context} "a * b * b \ (- 1) + a"; val SOME (t,_) = rewrite_set_ @{context} false make_polynomial t; UnparseC.term t; if UnparseC.term t = "2 * a" then () else error "poly.sml: diff.behav. in make_polynomial 25"; "-----SPO ---"; -val t = TermC.str2term "a*c*b \ (2*n) + 3*a + 5*b \ (2*n)*c*b"; +val t = TermC.parse_test @{context} "a*c*b \ (2*n) + 3*a + 5*b \ (2*n)*c*b"; val SOME (t,_) = rewrite_set_ @{context} false make_polynomial t; UnparseC.term t; if UnparseC.term t = "3 * a + 5 * b \ (1 + 2 * n) * c + a * b \ (2 * n) * c" then () else error "poly.sml: diff.behav. in make_polynomial 26"; (*MG030627 -------------vvv-: Verschachtelte Terme -----------*) "-----SPO ---"; -val t = TermC.str2term "(1 + (x*y*a) + x) \ (1 + (x*y*a) + x)"; +val t = TermC.parse_test @{context} "(1 + (x*y*a) + x) \ (1 + (x*y*a) + x)"; val SOME (t,_) = rewrite_set_ @{context} false make_polynomial t; if UnparseC.term t = "(1 + x + a * x * y) \ (1 + x + a * x * y)" then () else error "poly.sml: diff.behav. in make_polynomial 27";(*SPO*) -val t = TermC.str2term "(1 + x*(y*z)*zz) \ (1 + x*(y*z)*zz)"; +val t = TermC.parse_test @{context} "(1 + x*(y*z)*zz) \ (1 + x*(y*z)*zz)"; val SOME (t,_) = rewrite_set_ @{context} false make_polynomial t; if UnparseC.term t = "(1 + x * y * z * zz) \ (1 + x * y * z * zz)" then () else error "poly.sml: diff.behav. in make_polynomial 28"; @@ -611,7 +611,7 @@ (*default_print_depth 7;*) val prls = (#prls o Problem.from_store @{context}) ["polynomial", "simplification"]; (*default_print_depth 3;*) -val t = TermC.str2term "((5*x \ 2 + 3) * (2*x \ 7 + 3) - (3*x \ 5 + 8) * (6*x \ 4 - 1)) is_polyexp"; +val t = TermC.parse_test @{context} "((5*x \ 2 + 3) * (2*x \ 7 + 3) - (3*x \ 5 + 8) * (6*x \ 4 - 1)) is_polyexp"; val SOME (t',_) = rewrite_set_ thy false prls t; if t' = @{term True} then () else error "poly.sml: diff.behav. in check pbl 'polynomial.."; @@ -690,14 +690,14 @@ "-------- ord_make_polynomial ------------------------------------------------------------------"; "-------- ord_make_polynomial ------------------------------------------------------------------"; "-------- ord_make_polynomial ------------------------------------------------------------------"; -val t1 = TermC.str2term "2 * b + (3 * a + 3 * b)"; -val t2 = TermC.str2term "(3 * a + 3 * b) + 2 * b"; +val t1 = TermC.parse_test @{context} "2 * b + (3 * a + 3 * b)"; +val t2 = TermC.parse_test @{context} "(3 * a + 3 * b) + 2 * b"; if ord_make_polynomial true @{theory} [] (t1, t2) then () else error "poly.sml: diff.behav. in ord_make_polynomial"; (*SO: WHY IS THERE NO REWRITING ...*) -val term = TermC.str2term "2*b + (3*a + 3*b)"; +val term = TermC.parse_test @{context} "2*b + (3*a + 3*b)"; (*+++*)val NONE = rewrite_set_ (Proof_Context.init_global @{theory "Isac_Knowledge"}) false order_add_mult term; (* WHY IS THERE NO REWRITING ?!? diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/polyeq-1.sml --- a/test/Tools/isac/Knowledge/polyeq-1.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/polyeq-1.sml Sun Oct 09 07:44:22 2022 +0200 @@ -323,16 +323,16 @@ (** )end;( *local*) -val subs = [(TermC.str2term "bdv::real", TermC.str2term "x::real")]; +val subs = [(TermC.parse_test @{context} "bdv::real", TermC.parse_test @{context} "x::real")]; if ord_make_polynomial_in false(*true*) @{theory} subs (t1, t2) then () else error "still GREATER?"; -val x = TermC.str2term "x ::real"; +val x = TermC.parse_test @{context} "x ::real"; -val t1 = TermC.numerals_to_Free (TermC.str2term "L * q_0 * x \ 2 / 4 ::real"); +val t1 = TermC.numerals_to_Free (TermC.parse_test @{context} "L * q_0 * x \ 2 / 4 ::real"); if 2006 = size_of_term' 1 false(*true*) x t1 then () else error "size_of_term' (L * q_0 * x \ 2) CHANGED)"; -val t2 = TermC.numerals_to_Free (TermC.str2term "- 1 * (q_0 * x \ 3) :: real"); +val t2 = TermC.numerals_to_Free (TermC.parse_test @{context} "- 1 * (q_0 * x \ 3) :: real"); if 3004 = size_of_term' 1 false(*true*) x t2 then () else error "size_of_term' (- 1 * (q_0 * x \ 3)) CHANGED"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/polyeq-2.sml --- a/test/Tools/isac/Knowledge/polyeq-2.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/polyeq-2.sml Sun Oct 09 07:44:22 2022 +0200 @@ -218,22 +218,22 @@ val ctxt = @{context}; (*Punkte aus dem TestBericht, die ich in rlang.sml nicht zuordnen konnte:*) (*WN.19.3.03 ---v-*) -(*3(b)*)val (bdv,v) = (TermC.str2term "''bdv''", TermC.str2term "R1"); -val t = TermC.str2term "- 1 * (R * R2) + R2 * R1 + - 1 * (R * R1) = 0"; +(*3(b)*)val (bdv,v) = (TermC.parse_test @{context} "''bdv''", TermC.parse_test @{context} "R1"); +val t = TermC.parse_test @{context} "- 1 * (R * R2) + R2 * R1 + - 1 * (R * R1) = 0"; val SOME (t',_) = rewrite_set_inst_ ctxt false [(bdv,v)] make_polynomial_in t; if UnparseC.term t' = "- 1 * R * R2 + R2 * R1 + - 1 * R * R1 = 0" then () else error "make_polynomial_in (- 1 * (R * R2) + R2 * R1 + - 1 * (R * R1) = 0)"; "- 1 * R * R2 + (R2 + - 1 * R) * R1 = 0"; (*WN.19.3.03 ---^-*) -(*3(c)*)val (bdv,v) = (TermC.str2term "bdv", TermC.str2term "p"); -val t = TermC.str2term "y \ 2 + - 2 * (x * p) = 0"; +(*3(c)*)val (bdv,v) = (TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "p"); +val t = TermC.parse_test @{context} "y \ 2 + - 2 * (x * p) = 0"; val SOME (t',_) = rewrite_set_inst_ ctxt false [(bdv,v)] make_polynomial_in t; if UnparseC.term t' = "y \ 2 + - 2 * x * p = 0" then () else error "make_polynomial_in (y \ 2 + - 2 * (x * p) = 0)"; -(*3(d)*)val (bdv,v) = (TermC.str2term "''bdv''", TermC.str2term "x2"); -val t = TermC.str2term +(*3(d)*)val (bdv,v) = (TermC.parse_test @{context} "''bdv''", TermC.parse_test @{context} "x2"); +val t = TermC.parse_test @{context} "A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + - 1 * (x1 * (y2 * (1 / 2))) + - 1 * (x3 * (y1 * (1 / 2 ))) + y1 * (1 / 2 * x2) + - 1 * (y3 * (1 / 2 * x2)) = 0"; val SOME (t',_) = rewrite_set_inst_ ctxt false [(bdv,v)] make_polynomial_in t; if UnparseC.term t' = @@ -249,13 +249,13 @@ else error "make_ratpoly_in (A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + - 1..."; "A + x1 * y3 * (1 / 2) + x3 * y2 * (1 / 2) + - 1 * x1 * y2 * (1 / 2) + - 1 * x3 * y1 * (1 / 2) + (y1 * (1 / 2) + - 1 * y3 * (1 / 2)) * x2 = 0"; -(*3(e)*)val (bdv,v) = (TermC.str2term "bdv", TermC.str2term "a"); -val t = TermC.str2term +(*3(e)*)val (bdv,v) = (TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "a"); +val t = TermC.parse_test @{context} "A \ 2 + c \ 2 * (c / d) \ 2 + (-4 * (c / d) \ 2) * a \ 2 = 0"; val NONE = rewrite_set_inst_ ctxt false [(bdv,v)] make_polynomial_in t; (* the invisible parentheses are as expected *) -val t = TermC.str2term "(x + 1) * (x + 2) - (3 * x - 2) \ 2 - ((2 * x - 1) \ 2 + (3 * x - 1) * (x + 1)) = 0"; +val t = TermC.parse_test @{context} "(x + 1) * (x + 2) - (3 * x - 2) \ 2 - ((2 * x - 1) \ 2 + (3 * x - 1) * (x + 1)) = 0"; rewrite_set_ ctxt false expand_binoms t; @@ -278,8 +278,8 @@ "----------- rls d2_polyeq_bdv_only_simplify ---------------------"; "----------- rls d2_polyeq_bdv_only_simplify ---------------------"; "----------- rls d2_polyeq_bdv_only_simplify ---------------------"; -val t = TermC.str2term "-6 * x + 5 * x \ 2 = (0::real)"; -val subst = [(TermC.str2term "(bdv::real)", TermC.str2term "(x::real)")]; +val t = TermC.parse_test @{context} "-6 * x + 5 * x \ 2 = (0::real)"; +val subst = [(TermC.parse_test @{context} "(bdv::real)", TermC.parse_test @{context} "(x::real)")]; val SOME (t''''', _) = rewrite_set_inst_ ctxt true subst d2_polyeq_bdv_only_simplify t; (* steps in rls d2_polyeq_bdv_only_simplify:*) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/polyminus.sml --- a/test/Tools/isac/Knowledge/polyminus.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/polyminus.sml Sun Oct 09 07:44:22 2022 +0200 @@ -36,21 +36,21 @@ "----------- fun identifier --------------------------------------------------------------------"; "----------- fun identifier --------------------------------------------------------------------"; "----------- fun identifier --------------------------------------------------------------------"; -if identifier (TermC.str2term "12 ::real") = "12" then () else error "identifier 1"; -if identifier (TermC.str2term +if identifier (TermC.parse_test @{context} "12 ::real") = "12" then () else error "identifier 1"; +if identifier (TermC.parse_test @{context} "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g ::real") = "|||||||||||||" then () else error "identifier 1a"; -if identifier (TermC.str2term "a ::real") = "a" then () else error "identifier 2"; -if identifier (TermC.str2term "3 * a ::real") = "a" then () else error "identifier 3"; +if identifier (TermC.parse_test @{context} "a ::real") = "a" then () else error "identifier 2"; +if identifier (TermC.parse_test @{context} "3 * a ::real") = "a" then () else error "identifier 3"; -if identifier (TermC.str2term "a \ 2 ::real") = "a" then () else error "identifier 4"; -if identifier (TermC.str2term "3*a \ 2 ::real") = "a" then () else error "identifier 5"; -if identifier (TermC.str2term "a * b ::real") = "b" then () else error "identifier 5b"; +if identifier (TermC.parse_test @{context} "a \ 2 ::real") = "a" then () else error "identifier 4"; +if identifier (TermC.parse_test @{context} "3*a \ 2 ::real") = "a" then () else error "identifier 5"; +if identifier (TermC.parse_test @{context} "a * b ::real") = "b" then () else error "identifier 5b"; (*these are strange (see "specific monomials" in comment to fun.def.)..*) -if identifier (TermC.str2term "a*b ::real") = "b" then () else error "identifier 6"; -if identifier (TermC.str2term "(3*a*b) ::real") = "b" then () else error "identifier 7"; +if identifier (TermC.parse_test @{context} "a*b ::real") = "b" then () else error "identifier 6"; +if identifier (TermC.parse_test @{context} "(3*a*b) ::real") = "b" then () else error "identifier 7"; "----------- fun eval_kleiner, fun kleiner -----------------------------------------------------"; @@ -62,33 +62,33 @@ "12" < "3"; (*true !!!*) " a kleiner b ==> (b + a) = (a + b)"; -TermC.str2term "aaa"; -TermC.str2term "222 * aaa"; +TermC.parse_test @{context} "aaa"; +TermC.parse_test @{context} "222 * aaa"; -case eval_kleiner 0 0 (TermC.str2term "123 kleiner 32") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "123 kleiner 32") 0 of SOME ("123 kleiner 32 = False", _) => () | _ => error "polyminus.sml: 12 kleiner 9 = False"; -case eval_kleiner 0 0 (TermC.str2term "a kleiner b") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "a kleiner b") 0 of SOME ("a kleiner b = True", _) => () | _ => error "polyminus.sml: a kleiner b = True"; -case eval_kleiner 0 0 (TermC.str2term "(10*g) kleiner f") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(10*g) kleiner f") 0 of SOME ("10 * g kleiner f = False", _) => () | _ => error "polyminus.sml: 10 * g kleiner f = False"; -case eval_kleiner 0 0 (TermC.str2term "(a \ 2) kleiner b") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(a \ 2) kleiner b") 0 of SOME ("a \ 2 kleiner b = True", _) => () | _ => error "polyminus.sml: a \ 2 kleiner b = True"; -case eval_kleiner 0 0 (TermC.str2term "(3*a \ 2) kleiner b") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(3*a \ 2) kleiner b") 0 of SOME ("3 * a \ 2 kleiner b = True", _) => () | _ => error "polyminus.sml: 3 * a \ 2 kleiner b = True"; -case eval_kleiner 0 0 (TermC.str2term "(a*b) kleiner c") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(a*b) kleiner c") 0 of SOME ("a * b kleiner c = True", _) => () | _ => error "polyminus.sml: a * b kleiner b = True"; -case eval_kleiner 0 0 (TermC.str2term "(3*a*b) kleiner c") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(3*a*b) kleiner c") 0 of SOME ("3 * a * b kleiner c = True", _) => () | _ => error "polyminus.sml: 3 * a * b kleiner b = True"; -val t = TermC.str2term "12 kleiner 5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * (g::real)"; +val t = TermC.parse_test @{context} "12 kleiner 5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * (g::real)"; val SOME ("12 kleiner 5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g = True", _) = eval_kleiner "aaa" "bbb" t "ccc"; "~~~~~ fun eval_kleiner , args:"; val (_, _, (p as (Const (\<^const_name>\kleiner\,_) $ a $ b)), _) = @@ -106,61 +106,61 @@ "----------- fun ist_monom ---------------------------------------------------------------------"; "----------- fun ist_monom ---------------------------------------------------------------------"; "----------- fun ist_monom ---------------------------------------------------------------------"; -val t = TermC.str2term "0 ::real"; +val t = TermC.parse_test @{context} "0 ::real"; if ist_monom t then () else error "ist_monom 1"; -val t = TermC.str2term "a"; +val t = TermC.parse_test @{context} "a"; if ist_monom t then () else error "ist_monom 2"; -val t = TermC.str2term "2 * a"; +val t = TermC.parse_test @{context} "2 * a"; if ist_monom t then () else error "ist_monom 3"; -val t = TermC.str2term "2 * a * b"; +val t = TermC.parse_test @{context} "2 * a * b"; if ist_monom t then () else error "ist_monom 4"; -val t = TermC.str2term "a * b"; +val t = TermC.parse_test @{context} "a * b"; if ist_monom t then () else error "ist_monom 5"; (*not covered before NEW numerals*) -val t = TermC.str2term "2 * a \ 2 * b"; +val t = TermC.parse_test @{context} "2 * a \ 2 * b"; if ist_monom t then () else error "ist_monom 6"; (*not covered before NEW numerals*) -val t = TermC.str2term "a \ 2 * b \ 3"; +val t = TermC.parse_test @{context} "a \ 2 * b \ 3"; if ist_monom t then () else error "ist_monom 7"; -val t = TermC.str2term "a \ 2 * 4 * b \ 3 * 5"; +val t = TermC.parse_test @{context} "a \ 2 * 4 * b \ 3 * 5"; if ist_monom t then () else error "ist_monom 8"; "----------- fun eval_ist_monom ----------------------------------"; "----------- fun eval_ist_monom ----------------------------------"; "----------- fun eval_ist_monom ----------------------------------"; -case eval_ist_monom 0 0 (TermC.str2term "12 ist_monom") 0 of +case eval_ist_monom 0 0 (TermC.parse_test @{context} "12 ist_monom") 0 of SOME ("12 ist_monom = True", _) => () | _ => error "polyminus.sml: 12 ist_monom = True"; -case eval_ist_monom 0 0 (TermC.str2term "a ist_monom") 0 of +case eval_ist_monom 0 0 (TermC.parse_test @{context} "a ist_monom") 0 of SOME ("a ist_monom = True", _) => () | _ => error "polyminus.sml: a ist_monom = True"; -case eval_ist_monom 0 0 (TermC.str2term "(3*a) ist_monom") 0 of +case eval_ist_monom 0 0 (TermC.parse_test @{context} "(3*a) ist_monom") 0 of SOME ("3 * a ist_monom = True", _) => () | _ => error "polyminus.sml: 3 * a ist_monom = True"; -case eval_ist_monom 0 0 (TermC.str2term "(a \ 2) ist_monom") 0 of +case eval_ist_monom 0 0 (TermC.parse_test @{context} "(a \ 2) ist_monom") 0 of SOME ("a \ 2 ist_monom = True", _) => () | _ => error "polyminus.sml: a \ 2 ist_monom = True"; -case eval_ist_monom 0 0 (TermC.str2term "(3*a \ 2) ist_monom") 0 of +case eval_ist_monom 0 0 (TermC.parse_test @{context} "(3*a \ 2) ist_monom") 0 of SOME ("3 * a \ 2 ist_monom = True", _) => () | _ => error "polyminus.sml: 3*a \ 2 ist_monom = True"; -case eval_ist_monom 0 0 (TermC.str2term "(a*b) ist_monom") 0 of +case eval_ist_monom 0 0 (TermC.parse_test @{context} "(a*b) ist_monom") 0 of SOME ("a * b ist_monom = True", _) => () | _ => error "polyminus.sml: a*b ist_monom = True"; -case eval_ist_monom 0 0 (TermC.str2term "(3*a*b) ist_monom") 0 of +case eval_ist_monom 0 0 (TermC.parse_test @{context} "(3*a*b) ist_monom") 0 of SOME ("3 * a * b ist_monom = True", _) => () | _ => error "polyminus.sml: 3*a*b ist_monom = True"; @@ -170,14 +170,14 @@ "----------- watch order_add_mult -------------------------------"; "----- with these simple variables it works..."; val ctxt = @{context}; -val t = TermC.str2term "((a + d) + c) + b"; +val t = TermC.parse_test @{context} "((a + d) + c) + b"; val SOME (t,_) = rewrite_set_ ctxt false order_add_mult t; UnparseC.term t; if UnparseC.term t = "a + (b + (c + d))" then () else error "polyminus.sml 1 watch order_add_mult"; "----- the same stepwise..."; val od = ord_make_polynomial true (@{theory "Poly"}); -val t = TermC.str2term "((a + d) + c) + b"; +val t = TermC.parse_test @{context} "((a + d) + c) + b"; "((a + d) + c) + b"; val SOME (t,_) = rewrite_ ctxt od Rule_Set.empty true @{thm add.commute} t; UnparseC.term t; "b + ((a + d) + c)"; @@ -191,7 +191,7 @@ else error "polyminus.sml 2 watch order_add_mult"; "----- if parentheses are right, left_commute is (almost) sufficient..."; -val t = TermC.str2term "a + (d + (c + b))"; +val t = TermC.parse_test @{context} "a + (d + (c + b))"; "a + (d + (c + b))"; val SOME (t,_) = rewrite_ ctxt od Rule_Set.empty true @{thm add.left_commute} t;UnparseC.term t; "a + (c + (d + b))"; @@ -202,14 +202,14 @@ "----- but we do not want the parentheses at right; thus: cond.rew."; "WN0712707 complicated monomials do not yet work ..."; -val t = TermC.str2term "((5*a + 4*d) + 3*c) + 2*b"; +val t = TermC.parse_test @{context} "((5*a + 4*d) + 3*c) + 2*b"; val SOME (t,_) = rewrite_set_ ctxt false order_add_mult t; UnparseC.term t; if UnparseC.term t = "2 * b + (3 * c + (4 * d + 5 * a))" then () else error "polyminus.sml: order_add_mult changed"; "----- here we see rew_sub going into subterm with ord.rew...."; val od = ord_make_polynomial false (@{theory "Poly"}); -val t = TermC.str2term "b + a + c + d"; +val t = TermC.parse_test @{context} "b + a + c + d"; val SOME (t,_) = rewrite_ ctxt od Rule_Set.empty false @{thm add.commute} t; UnparseC.term t; val SOME (t,_) = rewrite_ ctxt od Rule_Set.empty false @{thm add.commute} t; UnparseC.term t; (*@@@ rew_sub gosub: t = d + (b + a + c) @@ -225,34 +225,34 @@ "12" < "3"; (*true !!!*) " a kleiner b ==> (b + a) = (a + b)"; -TermC.str2term "aaa"; -TermC.str2term "222 * aaa"; +TermC.parse_test @{context} "aaa"; +TermC.parse_test @{context} "222 * aaa"; -case eval_kleiner 0 0 (TermC.str2term "123 kleiner 32") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "123 kleiner 32") 0 of SOME ("123 kleiner 32 = False", _) => () | _ => error "polyminus.sml: 12 kleiner 9 = False"; -case eval_kleiner 0 0 (TermC.str2term "a kleiner b") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "a kleiner b") 0 of SOME ("a kleiner b = True", _) => () | _ => error "polyminus.sml: a kleiner b = True"; -case eval_kleiner 0 0 (TermC.str2term "(10*g) kleiner f") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(10*g) kleiner f") 0 of SOME ("10 * g kleiner f = False", _) => () | _ => error "polyminus.sml: 10 * g kleiner f = False"; -case eval_kleiner 0 0 (TermC.str2term "(a \ 2) kleiner b") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(a \ 2) kleiner b") 0 of SOME ("a \ 2 kleiner b = True", _) => () | _ => error "polyminus.sml: a \ 2 kleiner b = True"; -case eval_kleiner 0 0 (TermC.str2term "(3*a \ 2) kleiner b") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(3*a \ 2) kleiner b") 0 of SOME ("3 * a \ 2 kleiner b = True", _) => () | _ => error "polyminus.sml: 3 * a \ 2 kleiner b = True"; -case eval_kleiner 0 0 (TermC.str2term "(a*b) kleiner c") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(a*b) kleiner c") 0 of SOME ("a * b kleiner c = True", _) => () | _ => error "polyminus.sml: a * b kleiner b = True"; -case eval_kleiner 0 0 (TermC.str2term "(3*a*b) kleiner c") 0 of +case eval_kleiner 0 0 (TermC.parse_test @{context} "(3*a*b) kleiner c") 0 of SOME ("3 * a * b kleiner c = True", _) => () | _ => error "polyminus.sml: 3 * a * b kleiner b = True"; @@ -260,52 +260,52 @@ val od = Rewrite_Ord.function_empty; val erls = erls_ordne_alphabetisch; -val t = TermC.str2term "b + a"; +val t = TermC.parse_test @{context} "b + a"; val SOME (t,_) = rewrite_ ctxt od erls false @{thm tausche_plus} t; UnparseC.term t; if UnparseC.term t = "a + b" then () else error "polyminus.sml: ordne_alphabetisch1 b + a"; val erls = Atools_erls; -val t = TermC.str2term "2*a + 3*a"; +val t = TermC.parse_test @{context} "2*a + 3*a"; val SOME (t,_) = rewrite_ ctxt od erls false @{thm real_num_collect} t; UnparseC.term t; "======= test rewrite_, rewrite_set_"; (*Rewrite.trace_on := true; ..stopped Test_Isac.thy*) val erls = erls_ordne_alphabetisch; -val t = TermC.str2term "b + a"; +val t = TermC.parse_test @{context} "b + a"; val SOME (t,_) = rewrite_set_ ctxt false ordne_alphabetisch t; UnparseC.term t; if UnparseC.term t = "a + b" then () else error "polyminus.sml: ordne_alphabetisch a + b"; -val t = TermC.str2term "2*b + a"; +val t = TermC.parse_test @{context} "2*b + a"; val SOME (t,_) = rewrite_set_ ctxt false ordne_alphabetisch t; UnparseC.term t; if UnparseC.term t = "a + 2 * b" then () else error "polyminus.sml: ordne_alphabetisch a + 2 * b"; -val t = TermC.str2term "a + c + b"; +val t = TermC.parse_test @{context} "a + c + b"; val SOME (t,_) = rewrite_set_ ctxt false ordne_alphabetisch t; UnparseC.term t; if UnparseC.term t = "a + b + c" then () else error "polyminus.sml: ordne_alphabetisch a + b + c"; "======= rewrite goes into subterms"; -val t = TermC.str2term "a + c + b + d ::real"; +val t = TermC.parse_test @{context} "a + c + b + d ::real"; val SOME (t,_) = rewrite_ ctxt od erls false @{thm tausche_plus_plus} t; UnparseC.term t; if UnparseC.term t = "a + b + c + d" then () else error "polyminus.sml: ordne_alphabetisch1 a + b + c + d"; -val t = TermC.str2term "a + c + d + b"; +val t = TermC.parse_test @{context} "a + c + d + b"; val SOME (t,_) = rewrite_set_ ctxt false ordne_alphabetisch t; UnparseC.term t; if UnparseC.term t = "a + b + c + d" then () else error "polyminus.sml: ordne_alphabetisch2 a + b + c + d"; "======= here we see rew_sub going into subterm with cond.rew...."; -val t = TermC.str2term "b + a + c + d"; +val t = TermC.parse_test @{context} "b + a + c + d"; val SOME (t,_) = rewrite_ ctxt od erls false @{thm tausche_plus} t; UnparseC.term t; if UnparseC.term t = "a + b + c + d" then () else error "polyminus.sml: ordne_alphabetisch3 a + b + c + d"; "======= compile rls for the most complicated terms"; -val t = TermC.str2term "5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12"; +val t = TermC.parse_test @{context} "5*e + 6*f - 8*g - 9 - 7*e - 4*f + 10*g + 12"; "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12"; val SOME (t,_) = rewrite_set_ ctxt false ordne_alphabetisch t; if UnparseC.term t = "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g" @@ -316,7 +316,7 @@ "----------- build fasse_zusammen --------------------------------"; "----------- build fasse_zusammen --------------------------------"; "----------- build fasse_zusammen --------------------------------"; -val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g"; +val t = TermC.parse_test @{context} "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g"; val SOME (t,_) = rewrite_set_ ctxt false fasse_zusammen t; if UnparseC.term t = "3 + - 2 * e + 2 * f + 2 * g" then () else error "polyminus.sml: fasse_zusammen finished"; @@ -324,7 +324,7 @@ "----------- build verschoenere ----------------------------------"; "----------- build verschoenere ----------------------------------"; "----------- build verschoenere ----------------------------------"; -val t = TermC.str2term "3 + - 2 * e + 2 * f + 2 * g"; +val t = TermC.parse_test @{context} "3 + - 2 * e + 2 * f + 2 * g"; val SOME (t,_) = rewrite_set_ ctxt false verschoenere t; if UnparseC.term t = "3 - 2 * e + 2 * f + 2 * g" then () else error "polyminus.sml: verschoenere 3 + - 2 * e ..."; @@ -524,16 +524,16 @@ "----- 2 \ "; (*Rewrite.trace_on := true; ..stopped Test_Isac.thy*) val erls = erls_ordne_alphabetisch; -val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g"; +val t = TermC.parse_test @{context} "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g"; val SOME (t',_) = rewrite_ ctxt Rewrite_Ord.function_empty erls false @{thm tausche_minus} t; UnparseC.term t'; "- 9 + 12 + 5 * e - 7 * e + (- 4 + 6) * f - 8 * g + 10 * g"; -val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g"; +val t = TermC.parse_test @{context} "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g"; val NONE = rewrite_ ctxt Rewrite_Ord.function_empty erls false @{thm tausche_minus_plus} t; -val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g"; +val t = TermC.parse_test @{context} "- 9 + 12 + 5 * e - 7 * e + (6 - 4) * f - 8 * g + 10 * g"; val SOME (t',_) = rewrite_set_ ctxt false ordne_alphabetisch t; UnparseC.term t'; "- 9 + 12 + 5 * e - 7 * e - 8 * g + 10 * g + (- 4 + 6) * f"; @@ -598,7 +598,7 @@ "----------- pbl binom polynom vereinfachen p.39 -----------------"; val thy = @{theory}; val rls = klammern_ausmultiplizieren; -val t = TermC.str2term "(3 * a + 2) * (4 * a - 1::real)"; +val t = TermC.parse_test @{context} "(3 * a + 2) * (4 * a - 1::real)"; val SOME (t,_) = rewrite_set_ ctxt false rls t; UnparseC.term t; "3 * a * (4 * a) - 3 * a * 1 + (2 * (4 * a) - 2 * 1)"; val rls = discard_parentheses; @@ -608,7 +608,7 @@ val SOME (t,_) = rewrite_set_ ctxt false rls t; UnparseC.term t; "3 * 4 * a * a - 1 * 3 * a + (2 * 4 * a - 1 * 2)"; (* -val t = TermC.str2term "3 * a * 4 * a"; +val t = TermC.parse_test @{context} "3 * a * 4 * a"; val rls = ordne_monome; val SOME (t,_) = rewrite_set_ ctxt false rls t; UnparseC.term t; *) @@ -664,7 +664,7 @@ "----- go into details, if it seems not to work -----"; "--- does the predicate evaluate correctly ?"; -val t = TermC.str2term +val t = TermC.parse_patt_test @{theory} "matchsub (?a * (?b - ?c)) (8 * (a - q) + a - 2 * q + 3 * (a - 2 * (q::real)))"; val ma = eval_matchsub "" "Prog_Expr.matchsub" t ctxt; case ma of @@ -688,7 +688,7 @@ val SOME (t', _) = rewrite_set_ ctxt false prls t; "--- does the respective prls rewrite the whole predicate ?"; -val t = TermC.str2term +val t = TermC.parse_patt_test @{theory} "Not (matchsub (?a * (?b + ?c)) (8 * (a - q) + a - 2 * q) | \ \ matchsub (?a * (?b - ?c)) (8 * (a - q) + a - 2 * q) | \ \ matchsub ((?b + ?c) * ?a) (8 * (a - q) + a - 2 * q) | \ diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/rateq.sml --- a/test/Tools/isac/Knowledge/rateq.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/rateq.sml Sun Oct 09 07:44:22 2022 +0200 @@ -160,7 +160,7 @@ val Applicable.Yes (Check_elementwise' (curr_form, pred, (res, asms))) = check p''''' pt''''' m'''''; UnparseC.term curr_form = "[x = 1 / 5]"; pred = "Assumptions"; -res = TermC.str2term "[]::bool list"; +res = TermC.parse_test @{context} "[]::bool list"; asms = []; val (p,_,f,nxt,_,pt) = me nxt''' p''' [] pt'''; (*<<<----- this caused the error*) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/rational-1.sml --- a/test/Tools/isac/Knowledge/rational-1.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/rational-1.sml Sun Oct 09 07:44:22 2022 +0200 @@ -24,26 +24,26 @@ "-------- fun poly_of_term ---------------------------------------------------------------------"; "-------- fun poly_of_term ---------------------------------------------------------------------"; val thy = @{theory Isac_Knowledge}; -val vs = TermC.vars_of (TermC.str2term "12 * x \ 3 * y \ 4 * z \ 6"); +val vs = TermC.vars_of (TermC.parse_test @{context} "12 * x \ 3 * y \ 4 * z \ 6"); -val t = TermC.str2term "0 ::real"; +val t = TermC.parse_test @{context} "0 ::real"; if poly_of_term vs t = SOME [(0, [0, 0, 0])] then () else error "poly_of_term 0 changed"; -val t = TermC.str2term "-3 + - 2 * x ::real"; +val t = TermC.parse_test @{context} "-3 + - 2 * x ::real"; if poly_of_term vs t = SOME [(~3, [0, 0, 0]), (~2, [1, 0, 0])] then () else error "poly_of_term uminus changed"; -if poly_of_term vs (TermC.str2term "12::real") = SOME [(12, [0, 0, 0])] +if poly_of_term vs (TermC.parse_test @{context} "12::real") = SOME [(12, [0, 0, 0])] then () else error "poly_of_term 1 changed"; -if poly_of_term vs (TermC.str2term "x::real") = SOME [(1, [1, 0, 0])] +if poly_of_term vs (TermC.parse_test @{context} "x::real") = SOME [(1, [1, 0, 0])] then () else error "poly_of_term 2 changed"; -if poly_of_term vs (TermC.str2term "12 * x \ 3") = SOME [(12, [3, 0, 0])] +if poly_of_term vs (TermC.parse_test @{context} "12 * x \ 3") = SOME [(12, [3, 0, 0])] then () else error "poly_of_term 3 changed"; "~~~~~ fun poly_of_term , args:"; val (vs, t) = - (vs, (TermC.str2term "12 * x \ 3")); + (vs, (TermC.parse_test @{context} "12 * x \ 3")); monom_of_term vs (1, replicate (length vs) 0) t;(*poly malformed 1 with x \ 3*) "~~~~~ fun monom_of_term , args:"; val (vs, (c, es), (Const (\<^const_name>\times\, _) $ m1 $ m2)) = @@ -59,30 +59,30 @@ if (c, num |> HOLogic.dest_numeral |> list_update es (find_index (curry op = t) vs)) = (12, [3, 0, 0]) then () else error "monom_of_term (realpow): return value CHANGED"; -if poly_of_term vs (TermC.str2term "12 * x \ 3 * y \ 4 * z \ 6") = SOME [(12, [3, 4, 6])] +if poly_of_term vs (TermC.parse_test @{context} "12 * x \ 3 * y \ 4 * z \ 6") = SOME [(12, [3, 4, 6])] then () else error "poly_of_term 4 changed"; -if poly_of_term vs (TermC.str2term "1 + 2 * x \ 3 * y \ 4 * z \ 6 + y") = +if poly_of_term vs (TermC.parse_test @{context} "1 + 2 * x \ 3 * y \ 4 * z \ 6 + y") = SOME [(1, [0, 0, 0]), (1, [0, 1, 0]), (2, [3, 4, 6])] then () else error "poly_of_term 5 changed"; (*poly_of_term is quite liberal:*) (*the coefficient may be somewhere, the order of variables and the parentheses within a monomial are arbitrary*) -if poly_of_term vs (TermC.str2term "y \ 4 * (x \ 3 * 12 * z \ 6)") = SOME [(12, [3, 4, 6])] +if poly_of_term vs (TermC.parse_test @{context} "y \ 4 * (x \ 3 * 12 * z \ 6)") = SOME [(12, [3, 4, 6])] then () else error "poly_of_term 6 changed"; (*there may even be more than 1 coefficient:*) -if poly_of_term vs (TermC.str2term "2 * y \ 4 * (x \ 3 * 6 * z \ 6)") = SOME [(12, [3, 4, 6])] +if poly_of_term vs (TermC.parse_test @{context} "2 * y \ 4 * (x \ 3 * 6 * z \ 6)") = SOME [(12, [3, 4, 6])] then () else error "poly_of_term 7 changed"; (*the order and the parentheses within monomials are arbitrary:*) -if poly_of_term vs (TermC.str2term "2 * x \ 3 * y \ 4 * z \ 6 + (7 * y \ 8 + 1)") +if poly_of_term vs (TermC.parse_test @{context} "2 * x \ 3 * y \ 4 * z \ 6 + (7 * y \ 8 + 1)") = SOME [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 6])] then () else error "poly_of_term 8 changed"; (*from --- rls norm_Rational downto fun gcd_poly ---*) -val t = TermC.str2term (*copy from above: "::real" is not required due to " \ "*) +val t = TermC.parse_test @{context} (*copy from above: "::real" is not required due to " \ "*) ("(- 12 + 4 * y + 3 * x \ 2 + - 1 * (x \ 2 * y)) /" ^ "(- 18 + -9 * x + 2 * y \ 2 + x * y \ 2)"); "~~~~~ fun cancel_p_, args:"; val (t) = (t); @@ -99,9 +99,9 @@ "-------- fun is_poly --------------------------------------------------------------------------"; "-------- fun is_poly --------------------------------------------------------------------------"; "-------- fun is_poly --------------------------------------------------------------------------"; -if is_poly (TermC.str2term "2 * x \ 3 * y \ 4 * z \ 6 + 7 * y \ 8 + 1") +if is_poly (TermC.parse_test @{context} "2 * x \ 3 * y \ 4 * z \ 6 + 7 * y \ 8 + 1") then () else error "is_poly 1 changed"; -if not (is_poly (TermC.str2term "2 * (x \ 3 * y \ 4 * z \ 6 + 7) * y \ 8 + 1")) +if not (is_poly (TermC.parse_test @{context} "2 * (x \ 3 * y \ 4 * z \ 6 + 7) * y \ 8 + 1")) then () else error "is_poly 2 changed"; "-------- fun is_ratpolyexp --------------------------------------------------------------------"; @@ -122,7 +122,7 @@ "-------- fun term_of_poly ---------------------------------------------------------------------"; "-------- fun term_of_poly ---------------------------------------------------------------------"; val expT = HOLogic.realT -val Free (_, baseT) = (hd o vars o TermC.str2term) "12 * x \ 3 * y \ 4 * z \ 6"; +val Free (_, baseT) = (hd o vars o TermC.parse_test @{context}) "12 * x \ 3 * y \ 4 * z \ 6"; val p = [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 5])] val vs = TermC.vars_of (the (parseNEW ctxt "12 * x \ 3 * y \ 4 * z \ 6")) (*precondition for [(c, es),...]: legth es = length vs*) @@ -137,7 +137,7 @@ val ctxt = Proof_Context.init_global thy (*------- standard case: *) -val t = TermC.str2term "2 / 3 + 1 / 6 ::real"; +val t = TermC.parse_test @{context} "2 / 3 + 1 / 6 ::real"; "~~~~~ fun add_fraction_p_ , args:"; val ((_: theory), t) = (thy, t); val SOME ((n1, d1), (n2, d2)) = (*case*) check_frac_sum t (*of*); @@ -175,7 +175,7 @@ (*------- 0 / m + 0 / n 20 years old bug found here: *) -val t = TermC.str2term "0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 \ 3 + - 1 * q_0 / 24 * 0 \ 4)"; +val t = TermC.parse_test @{context} "0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 \ 3 + - 1 * q_0 / 24 * 0 \ 4)"; val SOME (t', _) = rewrite_set_ ctxt true norm_Rational t; (* : @@ -195,7 +195,7 @@ *) if UnparseC.term t' = "0 = c_2" then () else error "norm_Rational CHANGED"; (*isa2*) -val t = TermC.str2term "0 / 12 + 0 / 24 ::real"; +val t = TermC.parse_test @{context} "0 / 12 + 0 / 24 ::real"; add_fraction_p_ @{theory} t; "~~~~~ fun add_fraction_p_ , args:"; val ((_: theory), t) = (thy, t); val SOME ((n1, d1), (n2, d2)) = @@ -268,16 +268,16 @@ "-------- complex examples: rls norm_Rational --------------------------------------------------"; "-------- complex examples: rls norm_Rational --------------------------------------------------"; "-------- complex examples: rls norm_Rational --------------------------------------------------"; -val t = TermC.str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0"; +val t = TermC.parse_test @{context} "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0"; val SOME (t', _) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "1 / 18 = 0" then () else error "rational.sml 1"; -val t = TermC.str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0"; +val t = TermC.parse_test @{context} "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0"; val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "(237 + 65 * x) / 36 = 0" then () else error "rational.sml 2"; -val t = TermC.str2term "(1/2 + (5*x)/2) \ 2 - ((13*x)/2 - 5/2) \ 2 - (6*x) \ 2 + 29"; +val t = TermC.parse_test @{context} "(1/2 + (5*x)/2) \ 2 - ((13*x)/2 - 5/2) \ 2 - (6*x) \ 2 + 29"; val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "23 + 35 * x + - 72 * x \ 2" then () else error "rational.sml 3"; @@ -286,20 +286,20 @@ "-------- complex examples cancellation from: Mathematik 1 Schalk ------------------------------"; "-------- complex examples cancellation from: Mathematik 1 Schalk ------------------------------"; (*Schalk I, p.60 Nr. 215c *) -val t = TermC.str2term "(a + b) \ 4 * (x - y) / ((x - y) \ 3 * (a + b) \ 2)"; +val t = TermC.parse_test @{context} "(a + b) \ 4 * (x - y) / ((x - y) \ 3 * (a + b) \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(a \ 2 + 2 * a * b + b \ 2) / (x \ 2 + - 2 * x * y + y \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 7"; (*SRC Schalk I, p.66 Nr. 381b *) -val t = TermC.str2term +val t = TermC.parse_test @{context} "(4*x \ 2 - 20*x + 25)/(2*x - 5) \ 3"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "1 / (- 5 + 2 * x)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 9"; (*Schalk I, p.60 Nr. 215c *) -val t = TermC.str2term "(a + b) \ 4 * (x - y) / ((x - y) \ 3 * (a + b) \ 2)"; +val t = TermC.parse_test @{context} "(a + b) \ 4 * (x - y) / ((x - y) \ 3 * (a + b) \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(a \ 2 + 2 * a * b + b \ 2) / (x \ 2 + - 2 * x * y + y \ 2)" then () else error "Schalk I, p.60 Nr. 215c: with Isabelle2002 cancellation incomplete, changed"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/rational-2.sml --- a/test/Tools/isac/Knowledge/rational-2.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/rational-2.sml Sun Oct 09 07:44:22 2022 +0200 @@ -44,7 +44,7 @@ "-------- integration lev.1 fun factout_p_ -----------------------------------"; "-------- integration lev.1 fun factout_p_ -----------------------------------"; "-------- integration lev.1 fun factout_p_ -----------------------------------"; -val t = TermC.str2term "(x \ 2 + - 1*y \ 2) / (x \ 2 + - 1*x*y)" +val t = TermC.parse_test @{context} "(x \ 2 + - 1*y \ 2) / (x \ 2 + - 1*x*y)" val SOME (t', asm) = factout_p_ thy t; if UnparseC.term t' = "(x + y) * (x + - 1 * y) / (x * (x + - 1 * y))" then () else error ("factout_p_ term 1 changed: " ^ UnparseC.term t') @@ -52,10 +52,10 @@ if UnparseC.terms asm = "[\"x \ 0\", \"x + - 1 * y \ 0\"]" then () else error "factout_p_ asm 1 changed" ; -val t = TermC.str2term "nothing + to_cancel ::real"; +val t = TermC.parse_test @{context} "nothing + to_cancel ::real"; if NONE = factout_p_ thy t then () else error "factout_p_ doesn't report non-applicable"; ; -val t = TermC.str2term "((3 * x \ 2 + 6 *x + 3) / (2*x + 2))"; +val t = TermC.parse_test @{context} "((3 * x \ 2 + 6 *x + 3) / (2*x + 2))"; val SOME (t', asm) = factout_p_ thy t; if UnparseC.term t' = "(3 + 3 * x) * (1 + x) / (2 * (1 + x))" andalso UnparseC.terms asm = "[\"1 + x \ 0\"]" @@ -64,15 +64,15 @@ "-------- integration lev.1 fun cancel_p_ ------------------------------------"; "-------- integration lev.1 fun cancel_p_ ------------------------------------"; "-------- integration lev.1 fun cancel_p_ ------------------------------------"; -val t = TermC.str2term "(x \ 2 + - 1*y \ 2) / (x \ 2 + - 1*x*y)" +val t = TermC.parse_test @{context} "(x \ 2 + - 1*y \ 2) / (x \ 2 + - 1*x*y)" val SOME (t', asm) = cancel_p_ thy t; if (UnparseC.term t', UnparseC.terms asm) = ("(x + y) / x", "[\"x \ 0\"]") then () else error ("cancel_p_ (t', asm) 1 changed: " ^ UnparseC.term t') ; -val t = TermC.str2term "nothing + to_cancel ::real"; +val t = TermC.parse_test @{context} "nothing + to_cancel ::real"; if NONE = cancel_p_ thy t then () else error "cancel_p_ doesn't report non-applicable"; ; -val t = TermC.str2term "((3 * x \ 2 + 6 *x + 3) / (2*x + 2))"; +val t = TermC.parse_test @{context} "((3 * x \ 2 + 6 *x + 3) / (2*x + 2))"; val SOME (t', asm) = cancel_p_ thy t; if UnparseC.term t' = "(3 + 3 * x) / 2" andalso UnparseC.terms asm = "[]" then () else error "cancel_p_ 1 changed"; @@ -80,7 +80,7 @@ "-------- integration lev.1 fun common_nominator_p_ --------------------------"; "-------- integration lev.1 fun common_nominator_p_ --------------------------"; "-------- integration lev.1 fun common_nominator_p_ --------------------------"; -val t = TermC.str2term ("y / (a*x + b*x + c*x) " ^ +val t = TermC.parse_test @{context} ("y / (a*x + b*x + c*x) " ^ (* n1 d1 *) "+ a / (x*y)"); (* n2 d2 *) @@ -95,7 +95,7 @@ then () else error "common_nominator_p_ asm 1 changed" "-------- example in mail Nipkow"; -val t = TermC.str2term "x/(x \ 2 + - 1*y \ 2) + y/(x \ 2 + - 1*x*y)"; +val t = TermC.parse_test @{context} "x/(x \ 2 + - 1*y \ 2) + y/(x \ 2 + - 1*x*y)"; val SOME (t', asm) = common_nominator_p_ thy t; if UnparseC.term t' = "x * x / ((x + - 1 * y) * ((x + y) * x)) +\ny * (x + y) / ((x + - 1 * y) * ((x + y) * x))" @@ -105,10 +105,10 @@ then () else error "common_nominator_p_ asm 2 changed" "-------- example: applicable tested by SML code"; -val t = TermC.str2term "nothing / to_add"; +val t = TermC.parse_test @{context} "nothing / to_add"; if NONE = common_nominator_p_ thy t then () else error "common_nominator_p_ term 3 changed"; ; -val t = TermC.str2term "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))"; +val t = TermC.parse_test @{context} "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))"; val SOME (t', asm) = common_nominator_p_ thy t; if UnparseC.term t' = "(x + - 1) * (- 1 + x) / ((1 + x) * (- 1 + x)) +\n(x + 1) * (1 + x) / ((1 + x) * (- 1 + x))" @@ -118,7 +118,7 @@ "-------- integration lev.1 fun add_fraction_p_ ------------------------------"; "-------- integration lev.1 fun add_fraction_p_ ------------------------------"; "-------- integration lev.1 fun add_fraction_p_ ------------------------------"; -val t = TermC.str2term "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))"; +val t = TermC.parse_test @{context} "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))"; val SOME (t', asm) = add_fraction_p_ thy t; if UnparseC.term t' = "(2 + 2 * x \ 2) / (- 1 + x \ 2)" then () else error "add_fraction_p_ 3 changed"; @@ -126,10 +126,10 @@ if UnparseC.terms asm = "[\"- 1 + x \ 2 \ 0\"]" then () else error "add_fraction_p_ 3 changed"; ; -val t = TermC.str2term "nothing / to_add"; +val t = TermC.parse_test @{context} "nothing / to_add"; if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ term 3 changed"; ; -val t = TermC.str2term "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))"; +val t = TermC.parse_test @{context} "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))"; val SOME (t', asm) = add_fraction_p_ thy t; if UnparseC.term t' = "(2 + 2 * x \ 2) / (- 1 + x \ 2)" andalso UnparseC.terms asm = "[\"- 1 + x \ 2 \ 0\"]" @@ -142,7 +142,7 @@ (which does not to work, because substitution is not done -- compare rew_sub!); keep this sequence for the case, factout_p, cancel_p, common_nominator_p, add_fraction_p (again) get prepat = [] changed to <>[]. *) -val t = TermC.str2term "(x \ 2 + - 1*y \ 2) / (x \ 2 + - 1*x*y)"; +val t = TermC.parse_test @{context} "(x \ 2 + - 1*y \ 2) / (x \ 2 + - 1*x*y)"; (*rewrite_set_ @{theory Isac_Knowledge} true cancel t = NONE; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*) "~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (thy, false, cancel_p, t); @@ -219,13 +219,13 @@ "-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------"; "-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------"; "-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------"; -val t = TermC.str2term "(12 * x * y) / (8 * y \ 2 )"; +val t = TermC.parse_test @{context} "(12 * x * y) / (8 * y \ 2 )"; (* "-------- example 187a": exception Div raised... val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*) -val t = TermC.str2term "(8 * x \ 2 * y * z ) / (18 * x * y \ 2 * z )"; +val t = TermC.parse_test @{context} "(8 * x \ 2 * y * z ) / (18 * x * y \ 2 * z )"; (* "-------- example 187b": doesn't terminate... val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*) -val t = TermC.str2term "(9 * x \ 5 * y \ 2 * z \ 4) / (15 * x \ 6 * y \ 3 * z )"; +val t = TermC.parse_test @{context} "(9 * x \ 5 * y \ 2 * z \ 4) / (15 * x \ 6 * y \ 3 * z )"; (* "-------- example 187c": doesn't terminate... val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*) "~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (@{theory Isac_Knowledge}, false, cancel_p, t); @@ -274,14 +274,14 @@ "-------- rls norm_Rational downto fun gcd_poly ------------------------------"; "-------- rls norm_Rational downto fun gcd_poly ------------------------------"; "-------- rls norm_Rational downto fun gcd_poly ------------------------------"; -val t = TermC.str2term "(x \ 2 - 4)*(3 - y) / ((y \ 2 - 9)*(2+x))"; +val t = TermC.parse_test @{context} "(x \ 2 - 4)*(3 - y) / ((y \ 2 - 9)*(2+x))"; (* trace_rewrite stops with ...: (and then jEdit hangs).. rewrite_set_ thy false norm_Rational t; : ### rls: cancel_p on: (- 12 + 4 * y + 3 * x \ 2 + - 1 * (x \ 2 * y)) / (- 18 + -9 * x + 2 * y \ 2 + x * y \ 2) *) -val t = TermC.str2term (*copy from above: "::real" is not required due to " \ "*) +val t = TermC.parse_test @{context} (*copy from above: "::real" is not required due to " \ "*) ("(- 12 + 4 * y + 3 * x \ 2 + - 1 * (x \ 2 * y)) /" ^ "(- 18 + -9 * x + 2 * y \ 2 + x * y \ 2)"); (*cancel_p_ thy t; @@ -307,7 +307,7 @@ "-------- rls norm_Rational downto fun add_fraction_p_ -----------------------"; val thy = @{theory Isac_Knowledge}; "----- SK060904- 2a non-termination of add_fraction_p_"; -val t = TermC.str2term (" (a + b * x) / (a + - 1 * (b * x)) + " ^ +val t = TermC.parse_test @{context} (" (a + b * x) / (a + - 1 * (b * x)) + " ^ " (- 1 * a + b * x) / (a + b * x) "); (* rewrite_set_ thy false norm_Rational t exception Div raised*) @@ -429,7 +429,7 @@ (* Rewrite.trace_on: add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + - 1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *) (* |||||||||||||||||||||||||||| *) -val t = TermC.str2term (* ||||||||||||||||||||||||| *) +val t = TermC.parse_test @{context} (* ||||||||||||||||||||||||| *) "AA / 4 + (BB / 2 + - 1 * BB / 2)"; "~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t); val SOME ((n1, d1), (n2, d2)) = (*case*) check_frac_sum t (*of*); @@ -456,26 +456,26 @@ "-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----"; val thy = @{theory "Rational"}; "-------- WN"; -val t = TermC.str2term "(2 + -3 * x) / 9"; +val t = TermC.parse_test @{context} "(2 + -3 * x) / 9"; if NONE = rewrite_set_ ctxt false cancel_p t then () else error "rewrite_set_ cancel_p must return NONE, if the term cannot be cancelled"; "-------- example 186a"; -val t = TermC.str2term "(14 * x * y) / (x * y)"; - is_expanded (TermC.str2term "14 * x * y"); - is_expanded (TermC.str2term "x * y"); +val t = TermC.parse_test @{context} "(14 * x * y) / (x * y)"; + is_expanded (TermC.parse_test @{context} "14 * x * y"); + is_expanded (TermC.parse_test @{context} "x * y"); val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("14 / 1", "[]") then () else error "rational.sml cancel Schalk 186a"; "-------- example 186b"; -val t = TermC.str2term "(60 * a * b) / ( 15 * a * b )"; +val t = TermC.parse_test @{context} "(60 * a * b) / ( 15 * a * b )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("4 / 1", "[]") then () else error "rational.sml cancel Schalk 186b"; "-------- example 186c"; -val t = TermC.str2term "(144 * a \ 2 * b * c) / (12 * a * b * c)"; +val t = TermC.parse_test @{context} "(144 * a \ 2 * b * c) / (12 * a * b * c)"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("12 * a / 1", "[]") then () else error "rational.sml cancel Schalk 186c"; @@ -483,7 +483,7 @@ (* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! exception Div raised !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! see --- fun rewrite_set_ downto fun gcd_poly --- "-------- example 187a"; -val t = TermC.str2term "(12 * x * y) / (8 * y \ 2 )"; +val t = TermC.parse_test @{context} "(12 * x * y) / (8 * y \ 2 )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("3 * x / (2 * y)", "[\"4 * y ~= 0\"]") then () else error "rational.sml cancel Schalk 187a"; @@ -492,7 +492,7 @@ (* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! see --- fun rewrite_set_ downto fun gcd_poly --- "-------- example 187b"; -val t = TermC.str2term "(8 * x \ 2 * y * z ) / (18 * x * y \ 2 * z )"; +val t = TermC.parse_test @{context} "(8 * x \ 2 * y * z ) / (18 * x * y \ 2 * z )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("4 * x / (9 * y)", "[\"2 * (z * (y * x)) ~= 0\"]") then () else error "rational.sml cancel Schalk 187b"; @@ -501,7 +501,7 @@ (* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! see --- fun rewrite_set_ downto fun gcd_poly --- "-------- example 187c"; -val t = TermC.str2term "(9 * x \ 5 * y \ 2 * z \ 4) / (15 * x \ 6 * y \ 3 * z )"; +val t = TermC.parse_test @{context} "(9 * x \ 5 * y \ 2 * z \ 4) / (15 * x \ 6 * y \ 3 * z )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("3 * z \ 3 / (5 * (y * x))", "[\"3 * (z * (y \ 2 * x \ 5)) ~= 0\"]") @@ -509,119 +509,119 @@ *) "-------- example 188a"; -val t = TermC.str2term "(-8 + 8 * x) / (-9 + 9 * x)"; - is_expanded (TermC.str2term "8 * x + -8"); +val t = TermC.parse_test @{context} "(-8 + 8 * x) / (-9 + 9 * x)"; + is_expanded (TermC.parse_test @{context} "8 * x + -8"); val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("8 / 9", "[]") then () else error "rational.sml cancel Schalk 188a"; -val t = TermC.str2term "(8*((- 1) + x))/(9*((- 1) + x))"; +val t = TermC.parse_test @{context} "(8*((- 1) + x))/(9*((- 1) + x))"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; if (UnparseC.term t', UnparseC.terms asm) = ("8 / 9", "[]") then () else error "rational.sml cancel Schalk make_polynomial 1"; "-------- example 188b"; -val t = TermC.str2term "(- 15 + 5 * x) / (- 18 + 6 * x)"; +val t = TermC.parse_test @{context} "(- 15 + 5 * x) / (- 18 + 6 * x)"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("5 / 6", "[]") then () else error "rational.sml cancel Schalk 188b"; "-------- example 188c"; -val t = TermC.str2term "(a + - 1 * b) / (b + - 1 * a)"; +val t = TermC.parse_test @{context} "(a + - 1 * b) / (b + - 1 * a)"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("- 1 / 1", "[]") then () else error "rational.sml cancel Schalk 188c"; -is_expanded (TermC.str2term "a + - 1 * b") = true; -val t = TermC.str2term "((- 1)*(b + (- 1) * a))/(1*(b + (- 1) * a))"; +is_expanded (TermC.parse_test @{context} "a + - 1 * b") = true; +val t = TermC.parse_test @{context} "((- 1)*(b + (- 1) * a))/(1*(b + (- 1) * a))"; val SOME (t', asm) = rewrite_set_ ctxt false make_polynomial t; if (UnparseC.term t', UnparseC.terms asm) = ("(a + - 1 * b) / (- 1 * a + b)", "[]") then () else error "rational.sml cancel Schalk make_polynomial 2"; "-------- example 190a"; -val t = TermC.str2term "( 27 * a \ 3 + 9 * a \ 2 + 3 * a + 1 ) / ( 27 * a \ 3 + 18 * a \ 2 + 3 * a )"; +val t = TermC.parse_test @{context} "( 27 * a \ 3 + 9 * a \ 2 + 3 * a + 1 ) / ( 27 * a \ 3 + 18 * a \ 2 + 3 * a )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("(1 + 9 * a \ 2) / (3 * a + 9 * a \ 2)", "[\"3 * a + 9 * a \ 2 \ 0\"]") then () else error "rational.sml cancel Schalk 190a"; "-------- example 190c"; -val t = TermC.str2term "((1 + 9 * a \ 2)*(1 + 3 * a))/((3 * a + 9 * a \ 2)*(1 + 3 * a))"; +val t = TermC.parse_test @{context} "((1 + 9 * a \ 2)*(1 + 3 * a))/((3 * a + 9 * a \ 2)*(1 + 3 * a))"; val SOME (t', asm) = rewrite_set_ ctxt false make_polynomial t; if (UnparseC.term t', UnparseC.terms asm) = ("(1 + 3 * a + 9 * a \ 2 + 27 * a \ 3) /\n(3 * a + 18 * a \ 2 + 27 * a \ 3)", "[]") then () else error "rational.sml make_polynomial Schalk 190c"; "-------- example 191a"; -val t = TermC.str2term "( x \ 2 + - 1 * y \ 2 ) / ( x + y )"; - is_expanded (TermC.str2term "x \ 2 + - 1 * y \ 2") = false; (*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*) - is_expanded (TermC.str2term "x + y") = true; +val t = TermC.parse_test @{context} "( x \ 2 + - 1 * y \ 2 ) / ( x + y )"; + is_expanded (TermC.parse_test @{context} "x \ 2 + - 1 * y \ 2") = false; (*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*) + is_expanded (TermC.parse_test @{context} "x + y") = true; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("(x + - 1 * y) / 1", "[]") then () else error "rational.sml make_polynomial Schalk 191a"; "-------- example 191b"; -val t = TermC.str2term "((x + (- 1) * y)*(x + y))/((1)*(x + y))"; +val t = TermC.parse_test @{context} "((x + (- 1) * y)*(x + y))/((1)*(x + y))"; val SOME (t', asm) = rewrite_set_ ctxt false make_polynomial t; if (UnparseC.term t', UnparseC.terms asm) = ("(x \ 2 + - 1 * y \ 2) / (x + y)", "[]") then () else error "rational.sml make_polynomial Schalk 191b"; "-------- example 191c"; -val t = TermC.str2term "( 9 * x \ 2 + -30 * x + 25 ) / ( 9 * x \ 2 + - 25 )"; - is_expanded (TermC.str2term "9 * x \ 2 + -30 * x + 25") = true; - is_expanded (TermC.str2term "25 + -30*x + 9*x \ 2") = true; - is_expanded (TermC.str2term "- 25 + 9*x \ 2") = true; +val t = TermC.parse_test @{context} "( 9 * x \ 2 + -30 * x + 25 ) / ( 9 * x \ 2 + - 25 )"; + is_expanded (TermC.parse_test @{context} "9 * x \ 2 + -30 * x + 25") = true; + is_expanded (TermC.parse_test @{context} "25 + -30*x + 9*x \ 2") = true; + is_expanded (TermC.parse_test @{context} "- 25 + 9*x \ 2") = true; -val t = TermC.str2term "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))"; +val t = TermC.parse_test @{context} "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))"; val SOME (t', asm) = rewrite_set_ ctxt false make_polynomial t; if (UnparseC.term t', UnparseC.terms asm) = ("(25 + - 30 * x + 9 * x \ 2) / (- 25 + 9 * x \ 2)", "[]") then () else error "rational.sml make_polynomial Schalk 191c"; "-------- example 192b"; -val t = TermC.str2term "( 7 * x \ 3 + - 1 * x \ 2 * y ) / ( 7 * x * y \ 2 + - 1 * y \ 3 )"; +val t = TermC.parse_test @{context} "( 7 * x \ 3 + - 1 * x \ 2 * y ) / ( 7 * x * y \ 2 + - 1 * y \ 3 )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("x \ 2 / y \ 2", "[\"y \ 2 \ 0\"]") then () else error "rational.sml cancel_p Schalk 192b"; -val t = TermC.str2term "((x \ 2)*(7 * x + (- 1) * y))/((y \ 2)*(7 * x + (- 1) * y))"; +val t = TermC.parse_test @{context} "((x \ 2)*(7 * x + (- 1) * y))/((y \ 2)*(7 * x + (- 1) * y))"; val SOME (t', asm) = rewrite_set_ ctxt false make_polynomial t; if (UnparseC.term t', UnparseC.terms asm) = ("(7 * x \ 3 + - 1 * x \ 2 * y) /\n(7 * x * y \ 2 + - 1 * y \ 3)", "[]") then () else error "rational.sml make_polynomial Schalk 192b"; -val t = TermC.str2term "((x \ 2)*(7 * x + (- 1) * y))/((y \ 2)*(7 * x + (- 1) * y))"; +val t = TermC.parse_test @{context} "((x \ 2)*(7 * x + (- 1) * y))/((y \ 2)*(7 * x + (- 1) * y))"; val SOME (t', asm) = rewrite_set_ ctxt false make_polynomial t; if (UnparseC.term t', UnparseC.terms asm) = ("(7 * x \ 3 + - 1 * x \ 2 * y) /\n(7 * x * y \ 2 + - 1 * y \ 3)", "[]") then () else error "rational.sml make_polynomial Schalk WN050929 not working"; "-------- example 193a"; -val t = TermC.str2term "( x \ 2 + -6 * x + 9 ) / ( x \ 2 + -9 )"; +val t = TermC.parse_test @{context} "( x \ 2 + -6 * x + 9 ) / ( x \ 2 + -9 )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("(- 3 + x) / (3 + x)", "[\"3 + x \ 0\"]") then () else error "rational.sml cancel_p Schalk 193a"; "-------- example 193b"; -val t = TermC.str2term "( x \ 2 + -8 * x + 16 ) / ( 2 * x \ 2 + -32 )"; +val t = TermC.parse_test @{context} "( x \ 2 + -8 * x + 16 ) / ( 2 * x \ 2 + -32 )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("(- 4 + x) / (8 + 2 * x)", "[\"8 + 2 * x \ 0\"]") then () else error "rational.sml cancel_p Schalk 193b"; "-------- example 193c"; -val t = TermC.str2term "( 2 * x + -50 * x \ 3 ) / ( 25 * x \ 2 + - 10 * x + 1 )"; +val t = TermC.parse_test @{context} "( 2 * x + -50 * x \ 3 ) / ( 25 * x \ 2 + - 10 * x + 1 )"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("(2 * x + 10 * x \ 2) / (1 + - 5 * x)", "[\"1 + - 5 * x \ 0\"]") then () else error "rational.sml cancel_p Schalk 193c"; (*WN: improved with new numerals*) -val t = TermC.str2term "(- 25 + 9*x \ 2)/(5 + 3*x)"; +val t = TermC.parse_test @{context} "(- 25 + 9*x \ 2)/(5 + 3*x)"; val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = ("(- 5 + 3 * x) / 1", "[]") then () else error "rational.sml cancel WN 1"; "-------- example heuberger"; -val t = TermC.str2term ("(x \ 4 + x * y + x \ 3 * y + y \ 2) / " ^ +val t = TermC.parse_test @{context} ("(x \ 4 + x * y + x \ 3 * y + y \ 2) / " ^ "(x + 5 * x \ 2 + y + 5 * x * y + x \ 2 * y \ 3 + x * y \ 4)"); val SOME (t', asm) = rewrite_set_ ctxt false cancel_p t; if (UnparseC.term t', UnparseC.terms asm) = @@ -636,7 +636,7 @@ "-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------"; "-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------"; "-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------"; -val t = TermC.str2term ("123 = (a*x)/(b*x) + (c*x)/(d*x) + (e*x)/(f*x::real)"); +val t = TermC.parse_test @{context} ("123 = (a*x)/(b*x) + (c*x)/(d*x) + (e*x)/(f*x::real)"); "-------- gcd_poly integration level 1: works on exact term"; if NONE = cancel_p_ thy t then () else error "cancel_p_ works on exact fraction"; if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ works on exact fraction"; @@ -701,7 +701,7 @@ "-------- reverse rewrite ----------------------------------------------------"; "-------- reverse rewrite ----------------------------------------------------"; (** the term for which reverse rewriting is demonstrated **) -val t = TermC.str2term "(9 + - 1 * x \ 2) / (9 + 6 * x + x \ 2)"; +val t = TermC.parse_test @{context} "(9 + - 1 * x \ 2) / (9 + 6 * x + x \ 2)"; val Rrls {scr = Rfuns {init_state = ini, locate_rule = loc, next_rule = nex, normal_form = nor, ...},...} = cancel_p; @@ -807,7 +807,7 @@ special cases.*) (*the term for which reverse rewriting is demonstrated*) -val t = TermC.str2term "(9 + (- 1)*x \ 2) / (9 + ((-6)*x + x \ 2))"; +val t = TermC.parse_test @{context} "(9 + (- 1)*x \ 2) / (9 + ((-6)*x + x \ 2))"; val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc, next_rule=nex,normal_form=nor,...},...} = cancel_p; @@ -846,46 +846,46 @@ "-------- examples: rls norm_Rational ----------------------------------------"; "-------- examples: rls norm_Rational ----------------------------------------"; "-------- examples: rls norm_Rational ----------------------------------------"; -val t = TermC.str2term "Not (6*x is_atom)"; +val t = TermC.parse_test @{context} "Not (6*x is_atom)"; val SOME (t',_) = rewrite_set_ ctxt false powers_erls t; UnparseC.term t'; "HOL.True"; -val t = TermC.str2term "1 < 2"; +val t = TermC.parse_test @{context} "1 < 2"; val SOME (t',_) = rewrite_set_ ctxt false powers_erls t; UnparseC.term t'; "HOL.True"; -val t = TermC.str2term "(6*x) \ 2"; +val t = TermC.parse_test @{context} "(6*x) \ 2"; val SOME (t',_) = rewrite_ ctxt Rewrite_Ord.function_empty powers_erls false @{thm realpow_def_atom} t; if UnparseC.term t' = "6 * x * (6 * x) \ (2 + - 1)" then () else error "rational.sml powers_erls (6*x) \ 2"; -val t = TermC.str2term "- 1 * (- 2 * (5 / 2 * (13 * x / 2)))"; +val t = TermC.parse_test @{context} "- 1 * (- 2 * (5 / 2 * (13 * x / 2)))"; val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "65 * x / 2" then () else error "rational.sml 4"; -val t = TermC.str2term "1 - ((13*x)/2 - 5/2) \ 2"; +val t = TermC.parse_test @{context} "1 - ((13*x)/2 - 5/2) \ 2"; val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "(- 21 + 130 * x + - 169 * x \ 2) / 4" then () else error "rational.sml 5"; (*SRAM Schalk I, p.92 Nr. 609a*) -val t = TermC.str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54"; +val t = TermC.parse_test @{context} "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54"; val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "(- 255 + 112 * x) / 135" then () else error "rational.sml 6"; (*SRAM Schalk I, p.92 Nr. 610c*) -val t = TermC.str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2"; +val t = TermC.parse_test @{context} "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2"; val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "(3 + x) / - 2" then () else error "rational.sml 7"; (*SRAM Schalk I, p.92 Nr. 476a*) -val t = TermC.str2term "(x \ 2/(1 - x \ 2) + 1)/(x/(1 - x) + 1) * (1 + x)"; +val t = TermC.parse_test @{context} "(x \ 2/(1 - x \ 2) + 1)/(x/(1 - x) + 1) * (1 + x)"; (*. a/b : c/d translated to a/b * d/c .*) val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "1" then () else error "rational.sml 8"; (*Schalk I, p.92 Nr. 472a*) -val t = TermC.str2term "((8*x \ 2 - 32*y \ 2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))"; +val t = TermC.parse_test @{context} "((8*x \ 2 - 32*y \ 2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))"; val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "x + y" then () else error "rational.sml p.92 Nr. 472a"; @@ -893,11 +893,11 @@ (*WN130910 add_fractions_p exception Div raised + history: ### WN.2.6.03 from rlang.sml 56a -val t = TermC.str2term "(a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a \ 2 + - 1 * b \ 2)"; +val t = TermC.parse_test @{context} "(a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a \ 2 + - 1 * b \ 2)"; val NONE = rewrite_set_ ctxt false add_fractions_p t; THE ERROR ALREADY OCCURS IN THIS PART: -val t = TermC.str2term "(a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x)"; +val t = TermC.parse_test @{context} "(a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x)"; val NONE = add_fraction_p_ ctxt t; SEE Test_Some.thy: section {* add_fractions_p downto exception Div raised === @@ -907,13 +907,13 @@ "-------- rational numerals --------------------------------------------------"; "-------- rational numerals --------------------------------------------------"; (*SRA Schalk I, p.40 Nr. 164b *) -val t = TermC.str2term "(47/6 - 76/9 + 13/4)/(35/12)"; +val t = TermC.parse_test @{context} "(47/6 - 76/9 + 13/4)/(35/12)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "19 / 21" then () else error "rational.sml: diff.behav. in norm_Rational_mg 1"; (*SRA Schalk I, p.40 Nr. 166a *) -val t = TermC.str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)"; +val t = TermC.parse_test @{context} "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "45 / 2" then () else error "rational.sml: diff.behav. in norm_Rational_mg 2"; @@ -922,55 +922,55 @@ "-------- examples cancellation from: Mathematik 1 Schalk --------------------"; "-------- examples cancellation from: Mathematik 1 Schalk --------------------"; (* e190c Stefan K.*) -val t = TermC.str2term "((1 + 9*a \ 2) * (1 + 3*a)) / ((3*a + 9*a \ 2) * (1 + 3*a))"; +val t = TermC.parse_test @{context} "((1 + 9*a \ 2) * (1 + 3*a)) / ((3*a + 9*a \ 2) * (1 + 3*a))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(1 + 9 * a \ 2) / (3 * a + 9 * a \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 3"; (* e192b Stefan K.*) -val t = TermC.str2term "(x \ 2 * (7*x + (- 1)*y)) / (y \ 2 * (7*x + (- 1)*y))"; +val t = TermC.parse_test @{context} "(x \ 2 * (7*x + (- 1)*y)) / (y \ 2 * (7*x + (- 1)*y))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "x \ 2 / y \ 2" then () else error "rational.sml: diff.behav. in norm_Rational_mg 4"; (*SRC Schalk I, p.66 Nr. 379c *) -val t = TermC.str2term "(a - b)/(b - a)"; +val t = TermC.parse_test @{context} "(a - b)/(b - a)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "- 1" then () else error "rational.sml: diff.behav. in norm_Rational_mg 5"; (*SRC Schalk I, p.66 Nr. 380b *) -val t = TermC.str2term "15*(3*x + 3) * (4*x + 9) / (12*(2*x + 7) * (5*x + 5))"; +val t = TermC.parse_test @{context} "15*(3*x + 3) * (4*x + 9) / (12*(2*x + 7) * (5*x + 5))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(27 + 12 * x) / (28 + 8 * x)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 6"; (* e190c Stefan K.*) -val t = TermC.str2term "((1 + 9*a \ 2) * (1 + 3*a)) / ((3*a + 9*a \ 2) * (1 + 3 * a))"; +val t = TermC.parse_test @{context} "((1 + 9*a \ 2) * (1 + 3*a)) / ((3*a + 9*a \ 2) * (1 + 3 * a))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(1 + 9 * a \ 2) / (3 * a + 9 * a \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 3"; (* e192b Stefan K.*) -val t = TermC.str2term "(x \ 2 * (7*x + (- 1)*y)) / (y \ 2 * (7*x + (- 1)*y))"; +val t = TermC.parse_test @{context} "(x \ 2 * (7*x + (- 1)*y)) / (y \ 2 * (7*x + (- 1)*y))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "x \ 2 / y \ 2" then () else error "rational.sml: diff.behav. in norm_Rational_mg 4"; (*SRC Schalk I, p.66 Nr. 379c *) -val t = TermC.str2term "(a - b) / (b - a)"; +val t = TermC.parse_test @{context} "(a - b) / (b - a)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "- 1" then () else error "rational.sml: diff.behav. in norm_Rational_mg 5"; (*SRC Schalk I, p.66 Nr. 380b *) -val t = TermC.str2term "15*(3*x + 3) * (4*x + 9) / (12*(2*x + 7) * (5*x + 5))"; +val t = TermC.parse_test @{context} "15*(3*x + 3) * (4*x + 9) / (12*(2*x + 7) * (5*x + 5))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(27 + 12 * x) / (28 + 8 * x)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 6"; (* extreme example from somewhere *) -val t = TermC.str2term +val t = TermC.parse_test @{context} ("(a \ 4 * x + - 1*a \ 4 * y + 4*a \ 3 * b * x + -4*a \ 3 * b * y + " ^ "6*a \ 2 * b \ 2 * x + -6*a \ 2 * b \ 2 * y + 4*a * b \ 3 * x + -4*a * b \ 3 * y + " ^ "b \ 4 * x + - 1*b \ 4 * y) " ^ @@ -983,33 +983,33 @@ (*Schalk I, p.66 Nr. 381a *) (* ATTENTION: here the rls is very slow. In Isabelle2002 this required 2 min *) -val t = TermC.str2term "18*(a + b) \ 3 * (a - b) \ 2 / (72*(a - b) \ 3 * (a + b) \ 2)"; +val t = TermC.parse_test @{context} "18*(a + b) \ 3 * (a - b) \ 2 / (72*(a - b) \ 3 * (a + b) \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(a + b) / (4 * a + - 4 * b)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 8"; (*SRC Schalk I, p.66 Nr. 381b *) -val t = TermC.str2term "(4*x \ 2 - 20*x + 25) / (2*x - 5) \ 3"; +val t = TermC.parse_test @{context} "(4*x \ 2 - 20*x + 25) / (2*x - 5) \ 3"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "1 / (- 5 + 2 * x)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 9"; (*SRC Schalk I, p.66 Nr. 381c *) -val t = TermC.str2term "(27*a \ 3 + 9*a \ 2+3*a+1) / (27*a \ 3 + 18*a \ 2+3*a)"; +val t = TermC.parse_test @{context} "(27*a \ 3 + 9*a \ 2+3*a+1) / (27*a \ 3 + 18*a \ 2+3*a)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(1 + 9 * a \ 2) / (3 * a + 9 * a \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 10"; (*SRC Schalk I, p.66 Nr. 383a *) -val t = TermC.str2term "(5*a \ 2 - 5*a*b) / (a - b) \ 2"; +val t = TermC.parse_test @{context} "(5*a \ 2 - 5*a*b) / (a - b) \ 2"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "- 5 * a / (- 1 * a + b)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 11"; "----- NOT TERMINATING ?: worked before 0707xx"; -val t = TermC.str2term "(a \ 2 - 1)*(b + 1) / ((b \ 2 - 1)*(a+1))"; +val t = TermC.parse_test @{context} "(a \ 2 - 1)*(b + 1) / ((b \ 2 - 1)*(a+1))"; (* WN130911 "exception Div raised" by - cancel_p_ thy (TermC.str2term ("(- 1 + - 1 * b + a \ 2 + a \ 2 * b) /" ^ + cancel_p_ thy (TermC.parse_test @{context} ("(- 1 + - 1 * b + a \ 2 + a \ 2 * b) /" ^ "(- 1 + - 1 * a + b \ 2 + a * b \ 2)")) val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; @@ -1021,20 +1021,20 @@ "-------- examples common denominator from: Mathematik 1 Schalk --------------"; "-------- examples common denominator from: Mathematik 1 Schalk --------------"; (*SRA Schalk I, p.67 Nr. 403a *) -val t = TermC.str2term "4/x - 3/y - 1"; +val t = TermC.parse_test @{context} "4/x - 3/y - 1"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(- 3 * x + 4 * y + - 1 * x * y) / (x * y)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 12"; -val t = TermC.str2term "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a \ 2+3*b*c)/(a*b*c)"; +val t = TermC.parse_test @{context} "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a \ 2+3*b*c)/(a*b*c)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "4 / c" then () else error "rational.sml: diff.behav. in norm_Rational_mg 13"; (*SRA Schalk I, p.67 Nr. 410b *) -val t = TermC.str2term "1/(x+1) + 1/(x+2) - 2/(x+3)"; +val t = TermC.parse_test @{context} "1/(x+1) + 1/(x+2) - 2/(x+3)"; (* WN130911 non-termination due to non-termination of - cancel_p_ thy (TermC.str2term "(5 + 3 * x) / (6 + 11 * x + 6 * x \ 2 + x \ 3)") + cancel_p_ thy (TermC.parse_test @{context} "(5 + 3 * x) / (6 + 11 * x + 6 * x \ 2 + x \ 3)") val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(5 + 3 * x) / (6 + 11 * x + 6 * x \ 2 + x \ 3)" @@ -1042,22 +1042,22 @@ *) (*SRA Schalk I, p.67 Nr. 413b *) -val t = TermC.str2term "(1 + x)/(1 - x) - (1 - x)/(1 + x) + 2*x/(1 - x \ 2)"; +val t = TermC.parse_test @{context} "(1 + x)/(1 - x) - (1 - x)/(1 + x) + 2*x/(1 - x \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "6 * x / (1 + - 1 * x \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 15"; (*SRA Schalk I, p.68 Nr. 414a *) -val t = TermC.str2term "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))"; +val t = TermC.parse_test @{context} "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t ="(- 2 + - 5 * x + 2 * x \ 2) / (2 + - 3 * x + x \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 16"; (*SRA Schalk I, p.68 Nr. 428b *) -val t = TermC.str2term +val t = TermC.parse_test @{context} "1/(a - b) \ 2 + 1/(a + b) \ 2 - 2/(a \ 2 - b \ 2) - 4*(b \ 2 - 1)/(a \ 2 - b \ 2) \ 2"; (* WN130911 non-termination due to non-termination of - cancel_p_ thy (TermC.str2term "(4 + -4 * b \ 2) / (a \ 4 + - 2 * (a \ 2 * b \ 2) + b \ 4)") + cancel_p_ thy (TermC.parse_test @{context} "(4 + -4 * b \ 2) / (a \ 4 + - 2 * (a \ 2 * b \ 2) + b \ 4)") val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "4 / (a \ 4 + - 2 * a \ 2 * b \ 2 + b \ 4)" @@ -1065,14 +1065,14 @@ *) (*SRA Schalk I, p.68 Nr. 430b *) -val t = TermC.str2term +val t = TermC.parse_test @{context} "a \ 2/(a - 3*b) - 108*a*b \ 3/((a+3*b)*(a \ 2 - 9*b \ 2)) - 9*b \ 2*(a - 3*b)/(a+3*b) \ 2"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "a + 3 * b" then () else error "rational.sml: diff.behav. in norm_Rational_mg 19"; (*SRA Schalk I, p.68 Nr. 432 *) -val t = TermC.str2term +val t = TermC.parse_test @{context} ("(a \ 2 + a*b) / (a \ 2 - b \ 2) - (b \ 2 - a*b) / (b \ 2 - a \ 2) + " ^ "a \ 2*(a - b) / (a \ 3 - a \ 2*b) - 2*a*(a \ 2 - b \ 2) / (a \ 3 - a*b \ 2) - " ^ "2*b \ 2 / (a \ 2 - b \ 2)"); @@ -1081,7 +1081,7 @@ then () else error "rational.sml: diff.behav. in norm_Rational_mg 20"; (* some example *) -val t = TermC.str2term "3*a / (a*b) + x/y"; +val t = TermC.parse_test @{context} "3*a / (a*b) + x/y"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(3 * y + b * x) / (b * y)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 21"; @@ -1091,19 +1091,19 @@ "-------- examples multiply and cancel from: Mathematik 1 Schalk -------------"; "-------- examples multiply and cancel from: Mathematik 1 Schalk -------------"; (*------- SRM Schalk I, p.68 Nr. 436a *) -val t = TermC.str2term "3*(x+y) / (15*(x - y)) * 25*(x - y) \ 2 / (18*(x + y) \ 2)"; +val t = TermC.parse_test @{context} "3*(x+y) / (15*(x - y)) * 25*(x - y) \ 2 / (18*(x + y) \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(- 5 * x + 5 * y) / (- 18 * x + - 18 * y)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 22"; (*------- SRM.test Schalk I, p.68 Nr. 436b *) -val t = TermC.str2term "5*a*(a - b) \ 2*(a + b) \ 3/(7*b*(a - b) \ 3) * 7*b/(a + b) \ 3"; +val t = TermC.parse_test @{context} "5*a*(a - b) \ 2*(a + b) \ 3/(7*b*(a - b) \ 3) * 7*b/(a + b) \ 3"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "5 * a / (a + - 1 * b)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 23"; (*------- Schalk I, p.68 Nr. 437a *) -val t = TermC.str2term "(3*a - 4*b) / (4*c+3*e) * (3*a+4*b)/(9*a \ 2 - 16*b \ 2)"; +val t = TermC.parse_test @{context} "(3*a - 4*b) / (4*c+3*e) * (3*a+4*b)/(9*a \ 2 - 16*b \ 2)"; (* raises an exception for unclear reasons: val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; : @@ -1112,7 +1112,7 @@ exception Div raised BUT -val t = TermC.str2term +val t = TermC.parse_test @{context} ("(9 * a \ 2 + - 16 * b \ 2) / (4 * c + 3 * e) /" ^ "(9 * a \ 2 + - 16 * b \ 2)"); NONE = cancel_p_ thy t; @@ -1122,14 +1122,14 @@ *) "----- S.K. corrected non-termination 060904"; -val t = TermC.str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a \ 2 - 16*b \ 2))"; +val t = TermC.parse_test @{context} "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a \ 2 - 16*b \ 2))"; val SOME (t, _) = rewrite_set_ ctxt false make_polynomial t; if UnparseC.term t = "(9 * a \ 2 + - 16 * b \ 2) /\n(36 * a \ 2 * c + 27 * a \ 2 * e + - 64 * b \ 2 * c +\n - 48 * b \ 2 * e)" then () else error "rational.sml: S.K.8..corrected 060904-6"; "----- S.K. corrected non-termination of cancel_p_"; -val t'' = TermC.str2term ("(9 * a \ 2 + - 16 * b \ 2) /" ^ +val t'' = TermC.parse_test @{context} ("(9 * a \ 2 + - 16 * b \ 2) /" ^ "(36 * a \ 2 * c + (27 * a \ 2 * e + (-64 * b \ 2 * c + -48 * b \ 2 * e)))"); (* /--- DOES NOT TERMINATE AT TRANSITION isabisac15 --> Isabelle2017 --------------------------\ val SOME (t',_) = rewrite_set_ ctxt false cancel_p t''; @@ -1138,7 +1138,7 @@ \--- DOES NOT TERMINATE AT TRANSITION isabisac15 --> Isabelle2017 --------------------------/*) (*------- Schalk I, p.68 Nr. 437b*) -val t = TermC.str2term "(a + b)/(x \ 2 - y \ 2) * ((x - y) \ 2/(a \ 2 - b \ 2))"; +val t = TermC.parse_test @{context} "(a + b)/(x \ 2 - y \ 2) * ((x - y) \ 2/(a \ 2 - b \ 2))"; (*val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; : #### rls: cancel_p on: (a * x \ 2 + - 2 * (a * (x * y)) + a * y \ 2 + b * x \ 2 + @@ -1150,25 +1150,25 @@ *) (*------- SRM Schalk I, p.68 Nr. 438a *) -val t = TermC.str2term "x*y / (x*y - y \ 2) * (x \ 2 - x*y)"; +val t = TermC.parse_test @{context} "x*y / (x*y - y \ 2) * (x \ 2 - x*y)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "x \ 2" then () else error "rational.sml: diff.behav. in norm_Rational_mg 24"; (*------- SRM Schalk I, p.68 Nr. 439b *) -val t = TermC.str2term "(4*x \ 2 + 4*x + 1) * ((x \ 2 - 2*x \ 3) / (4*x \ 2 + 2*x))"; +val t = TermC.parse_test @{context} "(4*x \ 2 + 4*x + 1) * ((x \ 2 - 2*x \ 3) / (4*x \ 2 + 2*x))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(x + - 4 * x \ 3) / 2" then () else error "rational.sml: diff.behav. in norm_Rational_mg 25"; (*------- SRM Schalk I, p.68 Nr. 440a *) -val t = TermC.str2term "(x \ 2 - 2*x) / (x \ 2 - 3*x) * (x - 3) \ 2 / (x \ 2 - 4)"; +val t = TermC.parse_test @{context} "(x \ 2 - 2*x) / (x \ 2 - 3*x) * (x - 3) \ 2 / (x \ 2 - 4)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(- 3 + x) / (2 + x)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 26"; "----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx"; -val t = TermC.str2term "(a \ 3 - 9*a) / (a \ 3*b - a*b \ 3) * (a \ 2*b + a*b \ 2) / (a+3)"; +val t = TermC.parse_test @{context} "(a \ 3 - 9*a) / (a \ 3*b - a*b \ 3) * (a \ 2*b + a*b \ 2) / (a+3)"; (* WN130911 non-termination for unclear reasons: val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; @@ -1179,7 +1179,7 @@ (a \ 3 * b + - 1 * (a * b \ 3)) / (3 + a) BUT THIS IS CORRECTLY RECOGNISED -val t = TermC.str2term +val t = TermC.parse_test @{context} ("(-9 * (a \ 3 * b) + -9 * (a \ 2 * b \ 2) + a \ 5 * b + a \ 4 * b \ 2) /" ^ "(a \ 3 * b + - 1 * (a * b \ 3)) / (3 + (a::real))"); AS @@ -1190,9 +1190,9 @@ *) "----- SK12 works since 0707xx"; -val t = TermC.str2term "(a \ 3 - 9*a) * (a \ 2*b+a*b \ 2) / ((a \ 3*b - a*b \ 3) * (a+3))"; +val t = TermC.parse_test @{context} "(a \ 3 - 9*a) * (a \ 2*b+a*b \ 2) / ((a \ 3*b - a*b \ 3) * (a+3))"; (* WN130911 non-termination due to non-termination of - cancel_p_ thy (TermC.str2term "(4 + -4 * b \ 2) / (a \ 4 + - 2 * (a \ 2 * b \ 2) + b \ 4)") + cancel_p_ thy (TermC.parse_test @{context} "(4 + -4 * b \ 2) / (a \ 4 + - 2 * (a \ 2 * b \ 2) + b \ 4)") val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t' = "(-3 * a + a \ 2) / (a + - 1 * b)" then () @@ -1203,53 +1203,53 @@ "-------- examples common denominator and multiplication from: Schalk --------"; "-------- examples common denominator and multiplication from: Schalk --------"; (*------- SRAM Schalk I, p.69 Nr. 441b *) -val t = TermC.str2term "(4*a/3 + 3*b \ 2/a \ 3 + b/(4*a))*(4*b/(3*a))"; +val t = TermC.parse_test @{context} "(4*a/3 + 3*b \ 2/a \ 3 + b/(4*a))*(4*b/(3*a))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(36 * b \ 3 + 3 * a \ 2 * b \ 2 + 16 * a \ 4 * b) /\n(9 * a \ 4)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 28"; (*------- SRAM Schalk I, p.69 Nr. 442b *) -val t = TermC.str2term ("(15*a \ 2/x \ 3 - 5*b \ 4/x \ 2 + 25*c \ 2/x) * " ^ +val t = TermC.parse_test @{context} ("(15*a \ 2/x \ 3 - 5*b \ 4/x \ 2 + 25*c \ 2/x) * " ^ "(x \ 3/(5*a*b \ 3*c \ 3)) + 1/c \ 3 * (b*x/a - 3*a/b \ 3)"); val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "5 * x \ 2 / (a * b \ 3 * c)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 29"; (*------- SRAM Schalk I, p.69 Nr. 443b *) -val t = TermC.str2term "(a/2 + b/3) * (b/3 - a/2)"; +val t = TermC.parse_test @{context} "(a/2 + b/3) * (b/3 - a/2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(- 9 * a \ 2 + 4 * b \ 2) / 36" then () else error "rational.sml: diff.behav. in norm_Rational_mg 30"; (*------- SRAM Schalk I, p.69 Nr. 445b *) -val t = TermC.str2term "(a \ 2/9 + 2*a/(3*b) + 4/b \ 2)*(a/3 - 2/b) + 8/b \ 3"; +val t = TermC.parse_test @{context} "(a \ 2/9 + 2*a/(3*b) + 4/b \ 2)*(a/3 - 2/b) + 8/b \ 3"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "a \ 3 / 27" then () else error "rational.sml: diff.behav. in norm_Rational_mg 31"; (*------- SRAM Schalk I, p.69 Nr. 446b *) -val t = TermC.str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x \ 2 - 16*y \ 2)"; +val t = TermC.parse_test @{context} "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x \ 2 - 16*y \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = (*"30 * x \ 2 + -9 * x * y + - 20 * y \ 2" ..isabisac15 | Isabelle2017..*) "(- 30 * x \ 2 + 9 * x * y + 20 * y \ 2) / - 1" then () else error "rational.sml: diff.behav. in norm_Rational_mg 32"; (*------- SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*) -val t = TermC.str2term +val t = TermC.parse_test @{context} "(2*x \ 2/(3*y)+x/y \ 2)*(4*x \ 4/(9*y \ 2)+x \ 2/y \ 4)*(2*x \ 2/(3*y) - x/y \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(- 81 * x \ 4 + 16 * x \ 8 * y \ 4) / (81 * y \ 8)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 33"; (*------- SRAM Schalk I, p.69 Nr. 450a *) -val t = TermC.str2term +val t = TermC.parse_test @{context} "(4*x/(3*y)+2*y/(3*x)) \ 2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(52 * x \ 2 + 16 * y \ 2) / (9 * y \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 34"; (*------- SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*) -val t = TermC.str2term +val t = TermC.parse_test @{context} ("(15*a \ 4/(a*x \ 3) - 5*a*((b \ 4 - 5*c \ 2*x) / x \ 2)) * " ^ "(x \ 3/(5*a*b \ 3*c \ 3)) + a/c \ 3 * (x*(b/a) - 3*b*(a/b \ 4))"); val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; @@ -1261,21 +1261,21 @@ "-------- examples double fractions from: Mathematik 1 Schalk ----------------"; "-------- examples double fractions from: Mathematik 1 Schalk ----------------"; "----- SRD Schalk I, p.69 Nr. 454b"; -val t = TermC.str2term "((2 - x)/(2*a)) / (2*a/(x - 2))"; +val t = TermC.parse_test @{context} "((2 - x)/(2*a)) / (2*a/(x - 2))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(- 4 + 4 * x + - 1 * x \ 2) / (4 * a \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 35"; "----- SRD Schalk I, p.69 Nr. 455a"; -val t = TermC.str2term "(a \ 2 + 1)/(a \ 2 - 1) / ((a+1)/(a - 1))"; +val t = TermC.parse_test @{context} "(a \ 2 + 1)/(a \ 2 - 1) / ((a+1)/(a - 1))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(1 + a \ 2) / (1 + 2 * a + a \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 36"; "----- Schalk I, p.69 Nr. 455b"; -val t = TermC.str2term "(x \ 2 - 4)/(y \ 2 - 9)/((2+x)/(3 - y))"; +val t = TermC.parse_test @{context} "(x \ 2 - 4)/(y \ 2 - 9)/((2+x)/(3 - y))"; (* WN130911 non-termination due to non-termination of - cancel_p_ thy (TermC.str2term ("(- 12 + 4 * y + 3 * x \ 2 + - 1 * (x \ 2 * y)) /" ^ + cancel_p_ thy (TermC.parse_test @{context} ("(- 12 + 4 * y + 3 * x \ 2 + - 1 * (x \ 2 * y)) /" ^ "(- 18 + -9 * x + 2 * y \ 2 + x * y \ 2)")) val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; @@ -1284,9 +1284,9 @@ *) "----- SK060904- 1a non-termination of cancel_p_ ?: worked before 0707xx"; -val t = TermC.str2term "(x \ 2 - 4)*(3 - y) / ((y \ 2 - 9)*(2+x))"; +val t = TermC.parse_test @{context} "(x \ 2 - 4)*(3 - y) / ((y \ 2 - 9)*(2+x))"; (* WN130911 non-termination due to non-termination of - cancel_p_ thy (TermC.str2term ("(- 12 + 4 * y + 3 * x \ 2 + - 1 * (x \ 2 * y)) /" ^ + cancel_p_ thy (TermC.parse_test @{context} ("(- 12 + 4 * y + 3 * x \ 2 + - 1 * (x \ 2 * y)) /" ^ "(- 18 + -9 * x + 2 * y \ 2 + x * y \ 2)")) val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; @@ -1295,25 +1295,25 @@ *) "----- ?: worked before 0707xx"; -val t = TermC.str2term "(3 + - 1 * y) / (-9 + y \ 2)"; +val t = TermC.parse_test @{context} "(3 + - 1 * y) / (-9 + y \ 2)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "- 1 / (3 + y)" then () else error "rational.sml: - 1 / (3 + y) norm_Rational"; "----- SRD Schalk I, p.69 Nr. 456b"; -val t = TermC.str2term "(b \ 3 - b \ 2) / (b \ 2+b) / (b \ 2 - 1)"; +val t = TermC.parse_test @{context} "(b \ 3 - b \ 2) / (b \ 2+b) / (b \ 2 - 1)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "b / (1 + 2 * b + b \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 38"; "----- SRD Schalk I, p.69 Nr. 457b"; -val t = TermC.str2term "(16*a \ 2 - 9*b \ 2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a \ 2 - 9*a \ 2*b \ 2))"; +val t = TermC.parse_test @{context} "(16*a \ 2 - 9*b \ 2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a \ 2 - 9*a \ 2*b \ 2))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "8 * a \ 2 + - 6 * a * b + - 12 * a \ 2 * b + 9 * a * b \ 2" then () else error "rational.sml: diff.behav. in norm_Rational_mg 39"; "----- Schalk I, p.69 Nr. 458b works since 0707"; -val t = TermC.str2term "(2*a \ 2*x - a \ 2) / (a*x - b*x) / (b \ 2*(2*x - 1) / (x*(a - b)))"; +val t = TermC.parse_test @{context} "(2*a \ 2*x - a \ 2) / (a*x - b*x) / (b \ 2*(2*x - 1) / (x*(a - b)))"; (*val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; : ### rls: cancel_p on: (- 1 * a \ 2 + 2 * (a \ 2 * x)) / (a * x + - 1 * (b * x)) / @@ -1321,7 +1321,7 @@ exception Div raised BUT -val t = TermC.str2term +val t = TermC.parse_test @{context} ("(- 1 * a \ 2 + 2 * (a \ 2 * x)) / (a * x + - 1 * (b * x)) /" ^ "((- 1 * b \ 2 + 2 * (b \ 2 * x)) / (a * x + - 1 * (b * x)))"); NONE = cancel_p_ thy t; @@ -1331,18 +1331,18 @@ *) "----- SRD Schalk I, p.69 Nr. 459b"; -val t = TermC.str2term "(a \ 2 - b \ 2)/(a*b) / (4*(a+b) \ 2/a)"; +val t = TermC.parse_test @{context} "(a \ 2 - b \ 2)/(a*b) / (4*(a+b) \ 2/a)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(a + - 1 * b) / (4 * a * b + 4 * b \ 2)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 41"; "----- Schalk I, p.69 Nr. 460b nonterm.SK"; -val t = TermC.str2term "(9*(x \ 2 - 8*x + 16) / (4*(y \ 2 - 2*y + 1))) / ((3*x - 12) / (16*y - 16))"; +val t = TermC.parse_test @{context} "(9*(x \ 2 - 8*x + 16) / (4*(y \ 2 - 2*y + 1))) / ((3*x - 12) / (16*y - 16))"; (*val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; exception Div raised BUT -val t = TermC.str2term +val t = TermC.parse_test @{context} ("(144 + -72 * x + 9 * x \ 2) / (4 + -8 * y + 4 * y \ 2) /" ^ "((- 12 + 3 * x) / (- 16 + 16 * y))"); NONE = cancel_p_ thy t; @@ -1352,40 +1352,40 @@ *) "----- some variant of the above; was non-terminating before"; -val t = TermC.str2term "9*(x \ 2 - 8*x+16)*(16*y - 16)/(4*(y \ 2 - 2*y+1)*(3*x - 12))"; +val t = TermC.parse_test @{context} "9*(x \ 2 - 8*x+16)*(16*y - 16)/(4*(y \ 2 - 2*y+1)*(3*x - 12))"; val SOME (t , _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(48 + - 12 * x) / (1 + - 1 * y)" then () else error "some variant of the above; was non-terminating before"; "----- SRD Schalk I, p.70 Nr. 472a"; -val t = TermC.str2term ("((8*x \ 2 - 32*y \ 2) / (2*x + 4*y)) / ((4*x - 8*y) / (x + y))"); +val t = TermC.parse_test @{context} ("((8*x \ 2 - 32*y \ 2) / (2*x + 4*y)) / ((4*x - 8*y) / (x + y))"); val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "x + y" then () else error "rational.sml: diff.behav. in norm_Rational_mg 43"; "----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec"; -val t = TermC.str2term ("(a - (a*b + b \ 2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^ +val t = TermC.parse_test @{context} ("(a - (a*b + b \ 2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^ "((a - a \ 2/(a+b))/(a+(a*b)/(a - b)))"); val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(2 * a \ 3 + 2 * a \ 2 * b) / (a \ 2 * b + b \ 3)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 51"; (*SRD Schalk I, p.69 Nr. 461a *) -val t = TermC.str2term "(2/(x+3) + 2/(x - 3)) / (8*x/(x \ 2 - 9))"; +val t = TermC.parse_test @{context} "(2/(x+3) + 2/(x - 3)) / (8*x/(x \ 2 - 9))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "1 / 2" then () else error "rational.sml: diff.behav. in norm_Rational_mg 44"; (*SRD Schalk I, p.69 Nr. 464b *) -val t = TermC.str2term "(a - a/(a - 2)) / (a + a/(a - 2))"; +val t = TermC.parse_test @{context} "(a - a/(a - 2)) / (a + a/(a - 2))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(- 3 + a) / (- 1 + a)" then () else error "rational.sml: diff.behav. in norm_Rational_mg 45"; (*SRD Schalk I, p.69 Nr. 465b *) -val t = TermC.str2term "((x+3*y)/9 + (4*y \ 2 - 9*z \ 2)/(16*x)) / (x/9 + y/6 + z/4)"; +val t = TermC.parse_test @{context} "((x+3*y)/9 + (4*y \ 2 - 9*z \ 2)/(16*x)) / (x/9 + y/6 + z/4)"; (* WN130911 non-termination due to non-termination of - cancel_p_ thy (TermC.str2term + cancel_p_ thy (TermC.parse_test @{context} ("("(576 * x \ 2 + 1728 * (x * y) + 1296 * y \ 2 + - 2916 * z \ 2) /" ^ "(576 * x \ 2 + 864 * (x * y) + 1296 * (x * z))")) @@ -1395,13 +1395,13 @@ *) (*SRD Schalk I, p.69 Nr. 466b *) -val t = TermC.str2term "((1 - 7*(x - 2)/(x \ 2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x \ 2 - 25))"; +val t = TermC.parse_test @{context} "((1 - 7*(x - 2)/(x \ 2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x \ 2 - 25))"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "(25 + - 10 * x + x \ 2) / 18" then () else error "rational.sml: diff.behav. in norm_Rational_mg 47"; (*SRD Schalk I, p.70 Nr. 469 *) -val t = TermC.str2term ("3*b \ 2 / (4*a \ 2 - 8*a*b + 4*b \ 2) / " ^ +val t = TermC.parse_test @{context} ("3*b \ 2 / (4*a \ 2 - 8*a*b + 4*b \ 2) / " ^ "(a / (a \ 2*b - b \ 3) + (a - b) / (4*a*b \ 2 + 4*b \ 3) - 1 / (4*b \ 2))"); val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t = "- 3 * b \ 3 / (- 2 * a + 2 * b)" @@ -1558,13 +1558,13 @@ "-------- investigate rulesets for cancel_p ----------------------------------"; "-------- investigate rulesets for cancel_p ----------------------------------"; val thy = @{theory "Rational"}; -val t = TermC.str2term "(a \ 2 + - 1*b \ 2) / (a \ 2 + - 2*a*b + b \ 2)"; -val tt = TermC.str2term "(1 * a + 1 * b) * (1 * a + - 1 * b)"(*numerator only*); +val t = TermC.parse_test @{context} "(a \ 2 + - 1*b \ 2) / (a \ 2 + - 2*a*b + b \ 2)"; +val tt = TermC.parse_test @{context} "(1 * a + 1 * b) * (1 * a + - 1 * b)"(*numerator only*); "----- with rewrite_set_"; val SOME (tt',asm) = rewrite_set_ ctxt false make_polynomial tt; if UnparseC.term tt'= "a \ 2 + - 1 * b \ 2" then () else error "rls chancel_p 1"; -val tt = TermC.str2term "((1 * a + - 1 * b) * (1 * a + - 1 * b))"(*denominator only*); +val tt = TermC.parse_test @{context} "((1 * a + - 1 * b) * (1 * a + - 1 * b))"(*denominator only*); val SOME (tt',asm) = rewrite_set_ ctxt false make_polynomial tt; if UnparseC.term tt' = "a \ 2 + - 2 * a * b + b \ 2" then () else error "rls chancel_p 2"; @@ -1585,12 +1585,12 @@ (*default_print_depth 99;*) map (UnparseC.term o #1 o #3) der; (*default_print_depth 3;*) val der = Derive.do_one ctxt Atools_erls rules ro NONE - (TermC.str2term "(1 * a + 1 * b) * (1 * a + - 1 * b)"); + (TermC.parse_test @{context} "(1 * a + 1 * b) * (1 * a + - 1 * b)"); (*default_print_depth 99;*) writeln (Derive.deriv2str der); (*default_print_depth 3;*) val {rules, rew_ord=(_,ro),...} = Rule_Set.rep (get_rls @{context} "rev_rew_p"); val der = Derive.do_one ctxt Atools_erls rules ro NONE - (TermC.str2term "(1 * a + - 1 * b) * (1 * a + - 1 * b)"); + (TermC.parse_test @{context} "(1 * a + - 1 * b) * (1 * a + - 1 * b)"); (*default_print_depth 99;*) writeln (Derive.deriv2str der); (*default_print_depth 3;*) (*default_print_depth 99;*) map (UnparseC.term o #1) der; (*default_print_depth 3;*) (*WN060829 ...postponed*) @@ -1638,21 +1638,21 @@ "-------- WN1309xx non-terminating rls norm_Rational -------------------------"; "-------- WN1309xx non-terminating rls norm_Rational -------------------------"; (*------- Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*) -val t = TermC.str2term +val t = TermC.parse_test @{context} ("((12*x*y / (9*x \ 2 - y \ 2)) / (1 / (3*x - y) \ 2 - 1 / (3*x + y) \ 2)) * " ^ "((1/(x - 5*y) \ 2 - 1/(x + 5*y) \ 2) / (20*x*y / (x \ 2 - 25*y \ 2)))"); (*1st factor separately simplified *) -val t = TermC.str2term "((12*x*y / (9*x \ 2 - y \ 2)) / (1 / (3*x - y) \ 2 - 1 / (3*x + y) \ 2))"; +val t = TermC.parse_test @{context} "((12*x*y / (9*x \ 2 - y \ 2)) / (1 / (3*x - y) \ 2 - 1 / (3*x + y) \ 2))"; val SOME (t', _) = rewrite_set_ ctxt false norm_Rational t; if UnparseC.term t' = "(- 9 * x \ 2 + y \ 2) / - 1" then () else error "Nr. 480b lhs changed"; (*2nd factor separately simplified *) -val t = TermC.str2term "((1/(x - 5*y) \ 2 - 1/(x + 5*y) \ 2) / (20*x*y / (x \ 2 - 25*y \ 2)))"; +val t = TermC.parse_test @{context} "((1/(x - 5*y) \ 2 - 1/(x + 5*y) \ 2) / (20*x*y / (x \ 2 - 25*y \ 2)))"; val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t'; if UnparseC.term t' = "- 1 / (- 1 * x \ 2 + 25 * y \ 2)" then () else error "Nr. 480b rhs changed"; "-------- Schalk I, p.70 Nr. 477a: terms are exploding ?!?"; -val t = TermC.str2term ("b*y/(b - 2*y)/((b \ 2 - y \ 2)/(b+2*y)) /" ^ +val t = TermC.parse_test @{context} ("b*y/(b - 2*y)/((b \ 2 - y \ 2)/(b+2*y)) /" ^ "(b \ 2*y + b*y \ 2) * (a+x) \ 2 / ((b \ 2 - 4*y \ 2) * (a+2*x) \ 2)"); (*val SOME (t',_) = rewrite_set_ ctxt false norm_Rational t; : @@ -1667,7 +1667,7 @@ exception Div raised BUT -val t = TermC.str2term +val t = TermC.parse_test @{context} ("(a \ 2 * (b * y) + 2 * (a * (b * (x * y))) + b * (x \ 2 * y)) /" ^ "(b + - 2 * y) /" ^ "((b \ 2 + - 1 * y \ 2) / (b + 2 * y)) /" ^ @@ -1680,7 +1680,7 @@ *) (*------- Schalk I, p.70 Nr. 476b in 2003 this worked using 10 sec. *) -val t = TermC.str2term +val t = TermC.parse_test @{context} ("((a \ 2 - b \ 2)/(2*a*b) + 2*a*b/(a \ 2 - b \ 2)) / ((a \ 2 + b \ 2)/(2*a*b) + 1) / " ^ "((a \ 2 + b \ 2) \ 2 / (a + b) \ 2)"); (* Rewrite.trace_on := true; (*true false*) @@ -1704,7 +1704,7 @@ *) "-------- Schalk I, p.70 Nr. 480a: terms are exploding ?!?"; -val t = TermC.str2term ("(1/x + 1/y + 1/z) / (1/x - 1/y - 1/z) / " ^ +val t = TermC.parse_test @{context} ("(1/x + 1/y + 1/z) / (1/x - 1/y - 1/z) / " ^ "(2*x \ 2 / (x \ 2 - z \ 2) / (x / (x + z) + x / (x - z)))"); (* Rewrite.trace_on := true; (*true false*) rewrite_set_ ctxt false norm_Rational t; @@ -1722,14 +1722,14 @@ *) "-------- Schalk I, p.60 Nr. 215d: terms are exploding, internal loop does not terminate"; -val t = TermC.str2term "(a-b) \ 3 * (x+y) \ 4 / ((x+y) \ 2 * (a-b) \ 5)"; +val t = TermC.parse_test @{context} "(a-b) \ 3 * (x+y) \ 4 / ((x+y) \ 2 * (a-b) \ 5)"; (* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt: -val t = TermC.str2term "(a-b) \ 3 * (x+y) \ 4"; +val t = TermC.parse_test @{context} "(a-b) \ 3 * (x+y) \ 4"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t; "a \ 3 * x \ 4 + 4 * a \ 3 * x \ 3 * y +6 * a \ 3 * x \ 2 * y \ 2 +4 * a \ 3 * x * y \ 3 +a \ 3 * y \ 4 +-3 * a \ 2 * b * x \ 4 +- 12 * a \ 2 * b * x \ 3 * y +- 18 * a \ 2 * b * x \ 2 * y \ 2 +- 12 * a \ 2 * b * x * y \ 3 +-3 * a \ 2 * b * y \ 4 +3 * a * b \ 2 * x \ 4 +12 * a * b \ 2 * x \ 3 * y +18 * a * b \ 2 * x \ 2 * y \ 2 +12 * a * b \ 2 * x * y \ 3 +3 * a * b \ 2 * y \ 4 +- 1 * b \ 3 * x \ 4 +-4 * b \ 3 * x \ 3 * y +-6 * b \ 3 * x \ 2 * y \ 2 +-4 * b \ 3 * x * y \ 3 +- 1 * b \ 3 * y \ 4"; -val t = TermC.str2term "((x+y) \ 2 * (a-b) \ 5)"; +val t = TermC.parse_test @{context} "((x+y) \ 2 * (a-b) \ 5)"; val SOME (t, _) = rewrite_set_ ctxt false norm_Rational t; UnparseC.term t; "a \ 5 * x \ 2 + 2 * a \ 5 * x * y + a \ 5 * y \ 2 +-5 * a \ 4 * b * x \ 2 +- 10 * a \ 4 * b * x * y +-5 * a \ 4 * b * y \ 2 +10 * a \ 3 * b \ 2 * x \ 2 +20 * a \ 3 * b \ 2 * x * y +10 * a \ 3 * b \ 2 * y \ 2 +- 10 * a \ 2 * b \ 3 * x \ 2 +- 20 * a \ 2 * b \ 3 * x * y +- 10 * a \ 2 * b \ 3 * y \ 2 +5 * a * b \ 4 * x \ 2 +10 * a * b \ 4 * x * y +5 * a * b \ 4 * y \ 2 +- 1 * b \ 5 * x \ 2 +- 2 * b \ 5 * x * y +- 1 * b \ 5 * y \ 2"; @@ -1737,7 +1737,7 @@ anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*) "-------- Schalk I, p.70 Nr. 480b: terms are exploding, Rewrite.trace_on stops at"; -val t = TermC.str2term ("((12*x*y/(9*x \ 2 - y \ 2))/" ^ +val t = TermC.parse_test @{context} ("((12*x*y/(9*x \ 2 - y \ 2))/" ^ "(1/(3*x - y) \ 2 - 1/(3*x + y) \ 2)) *" ^ "(1/(x - 5*y) \ 2 - 1/(x + 5*y) \ 2)/" ^ "(20*x*y/(x \ 2 - 25*y \ 2))"); diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/rlang.sml --- a/test/Tools/isac/Knowledge/rlang.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/rlang.sml Sun Oct 09 07:44:22 2022 +0200 @@ -193,8 +193,8 @@ [ (bdv, v) ] make_ratpoly_in t; if UnparseC.term t' = "3 / 5 * x" then () else error "rlang.sml: 1"; -val t = TermC.str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0"; -val subst = [(TermC.str2term "bdv", TermC.str2term "x")]; +val t = TermC.parse_test @{context} "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0"; +val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]; val SOME (t',_) = rewrite_set_inst_ thy false subst make_ratpoly_in t; if UnparseC.term t' = "1 / 18 = 0" then () else error "rlang.sml: 2"; (*WN---^ *) @@ -226,8 +226,8 @@ (*WN---v *) -val t = TermC.str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0"; -val subst = [(TermC.str2term "bdv", TermC.str2term "x")]; +val t = TermC.parse_test @{context} "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0"; +val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]; val SOME (t',_) = rewrite_set_inst_ thy false subst make_ratpoly_in t; UnparseC.term t'; if UnparseC.term t' = "79 / 12 + 65 / 36 * x = 0" then () @@ -338,14 +338,14 @@ | _ => error "rlang.sml: diff.behav. in Schalk I s.87 Bsp 44a [x = 1]"; (*WN---v *) -val t = TermC.str2term "(1/2 + (5*x)/2) \ 2 - ((13*x)/2 - 5/2) \ 2 - (6*x) \ 2 + 29"; -val subst = [(TermC.str2term "bdv", TermC.str2term "x")]; +val t = TermC.parse_test @{context} "(1/2 + (5*x)/2) \ 2 - ((13*x)/2 - 5/2) \ 2 - (6*x) \ 2 + 29"; +val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]; val SOME (t',_) = rewrite_set_inst_ thy false subst make_ratpoly_in t; if UnparseC.term t' = "23 + 35 * x + -72 * x \ 2" then () else error "rlang.sml: 4"; -val t = TermC.str2term "(1/2 + (5*x)/2) \ 2 - ((13*x)/2 - 5/2) \ 2 + (6*x) \ 2 - 29"; -val subst = [(TermC.str2term "bdv", TermC.str2term "x")]; +val t = TermC.parse_test @{context} "(1/2 + (5*x)/2) \ 2 - ((13*x)/2 - 5/2) \ 2 + (6*x) \ 2 - 29"; +val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]; val SOME (t',_) = rewrite_set_inst_ thy false subst make_ratpoly_in t; if UnparseC.term t' = "-35 + 35 * x" then () else error "rlang.sml: 4.1"; @@ -486,7 +486,7 @@ "[v = (u * v0 + v0 * w + - 1 * f * w) / f]")) => () | _ => error "rlang.sml: diff.behav. in Schalk I s.89 Bsp 90a (1) [v=...]"; if Ctree.get_assumptions pt p = - [TermC.str2term"(u * v0 + v0 * w + - 1 * f * w) / f + w ~= 0"] then () + [TermC.parse_test @{context}"(u * v0 + v0 * w + - 1 * f * w) / f + w ~= 0"] then () else error "rlang.sml: diff.behav. in I s.89 Bsp 90a (1) [v=...] asm"; @@ -530,8 +530,8 @@ case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[w = (u * v0 + - 1 * f * v) / (f + - 1 * v0)]")) => () | _ => error "rlang.sml: diff.behav. in Schalk I Bsp 90a(2)"; if Ctree.get_assumptions pt p = -[TermC.str2term"v + (u * v0 + - 1 * f * v) / (f + - 1 * v0) ~= 0", - TermC.str2term"f + - 1 * v0 ~= 0"] +[TermC.parse_test @{context}"v + (u * v0 + - 1 * f * v) / (f + - 1 * v0) ~= 0", + TermC.parse_test @{context}"f + - 1 * v0 ~= 0"] then writeln "asm should be simplified ???" else error "rlang.sml: diff.behav. in Schalk I Bsp 90a(2) asm"; @@ -571,9 +571,9 @@ val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt; case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[R1 = R * R2 / (R2 + - 1 * R)]")) => () | _ => error "rlang.sml: diff.behav. in 98a(1) [R1 = ...]"; -if Ctree.get_assumptions pt p = [TermC.str2term"R * R2 * R2 ~= (R2 + - 1 * R) * 0", - TermC.str2term"R2 + - 1 * R ~= 0", - TermC.str2term"R2 + - 1 * R ~= 0"] +if Ctree.get_assumptions pt p = [TermC.parse_test @{context}"R * R2 * R2 ~= (R2 + - 1 * R) * 0", + TermC.parse_test @{context}"R2 + - 1 * R ~= 0", + TermC.parse_test @{context}"R2 + - 1 * R ~= 0"] then writeln "asm should be simplified" else error "rlang.sml: diff.behav. in 98a(1) asm"; @@ -602,7 +602,7 @@ val (p,_,f,nxt,_,pt) = me nxt p [1] pt; case f of Form' (Test_Out.FormKF (_,_,0,_,"[p = y \ 2 / (2 * x)]")) => () | _ => error "rlang.sml: diff.behav. in Schalk I s.89 Bsp 104a (1) [p = y^2/(2*x)]"; -if Ctree.get_assumptions pt p = [TermC.str2term"- 2 * x ~= 0"] +if Ctree.get_assumptions pt p = [TermC.parse_test @{context}"- 2 * x ~= 0"] then writeln"should be x ~= 0\nshould be x ~= 0\nshould be x ~= 0\n" else error "rlang.sml: diff.behav. in I s.89 Bsp 104a(1) asm"; @@ -632,8 +632,8 @@ val (p,_,f,nxt,_,pt) = me nxt p [1] pt; case f of Form' (Test_Out.FormKF (_,_,0,_,"[y = sqrt (2 * p * x), y = - 1 * sqrt (2 * p * x)]")) => () | _ => error "rlang.sml: diff.behav. Schalk I s.89 Bsp 104a(2) [x = ]"; -if Ctree.get_assumptions pt p = [TermC.str2term"0 <= - 1 * (- 2 * p * x)", - TermC.str2term"0 <= - 1 * (- 2 * p * x)"] +if Ctree.get_assumptions pt p = [TermC.parse_test @{context}"0 <= - 1 * (- 2 * p * x)", + TermC.parse_test @{context}"0 <= - 1 * (- 2 * p * x)"] then writeln "asm should be simplified\nshould be simplified" else error "rlang.sml: diff.behav. in I s.89 Bsp 104a(2) asm"; @@ -678,10 +678,10 @@ | _ => error "rlang.sml: diff.behav. in Schalk I s.89 Bsp 118a(2) [x = ]"; val asms = Ctree.get_assumptions pt p; if asms = - [TermC.str2term"0 * b \ 2 <= - 1 * (a \ 2 * y \ 2 + - 1 * a \ 2 * b \ 2)", - TermC.str2term"b \ 2 ~= 0", - TermC.str2term"0 * b \ 2 <= - 1 * (a \ 2 * y \ 2 + - 1 * a \ 2 * b \ 2)", - TermC.str2term"b \ 2 ~= 0"] then writeln"should be simplified MG" + [TermC.parse_test @{context}"0 * b \ 2 <= - 1 * (a \ 2 * y \ 2 + - 1 * a \ 2 * b \ 2)", + TermC.parse_test @{context}"b \ 2 ~= 0", + TermC.parse_test @{context}"0 * b \ 2 <= - 1 * (a \ 2 * y \ 2 + - 1 * a \ 2 * b \ 2)", + TermC.parse_test @{context}"b \ 2 ~= 0"] then writeln"should be simplified MG" else error "rlang.sml: diff.behav. in Schalk I s.89 Bsp 118a(2) asms"; (*----------------- Schalk I s.102 Bsp 268(1) ------------------------*) @@ -709,7 +709,7 @@ val (p,_,f,nxt,_,pt) = me nxt p [1] pt; case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x2 =\n (- 2 * A + x1 * y2 + x3 * y1 + - 1 * x1 * y3 + - 1 * x3 * y2) /\n (y1 + - 1 * y3)]")) => () | _ => error "rlang.sml: diff.behav. Schalk I s.102 Bsp 268(1) [x2=...]"; -if Ctree.get_assumptions pt p = [TermC.str2term"y1 / 2 + - 1 * y3 / 2 ~= 0"] then () +if Ctree.get_assumptions pt p = [TermC.parse_test @{context}"y1 / 2 + - 1 * y3 / 2 ~= 0"] then () else error "rlang.sml: diff.behav. in I s.102 Bsp 268(1) asm"; (*-------------------- Schalk II ----------------------------*) @@ -824,11 +824,11 @@ \0 <= 1 / 9]" (*WN050916 before correction 'rewrite__set_ called with 'Rule_Set.Empty' for ..' thus: maybe the rls for the asms is Rule_Set.Empty ??: - [(TermC.str2term"0 <= (25 * (1 / 9) + - 1 * (16 + 49 * (1 / 9))) * -56", []), - (TermC.str2term"9 ~= 0", []), - (TermC.str2term"0 <= (-5 + 7 * sqrt (1 / 9) + 1) * 5", []), - (TermC.str2term"9 ~= 0", []), - (TermC.str2term"0 <= (25 * (1 / 9) + - 1 * (16 + 49 * (1 / 9))) * -56", [])]*) + [(TermC.parse_test @{context}"0 <= (25 * (1 / 9) + - 1 * (16 + 49 * (1 / 9))) * -56", []), + (TermC.parse_test @{context}"9 ~= 0", []), + (TermC.parse_test @{context}"0 <= (-5 + 7 * sqrt (1 / 9) + 1) * 5", []), + (TermC.parse_test @{context}"9 ~= 0", []), + (TermC.parse_test @{context}"0 <= (25 * (1 / 9) + - 1 * (16 + 49 * (1 / 9))) * -56", [])]*) then "should get True * False!!!" else error "rlang.sml: diff.behav. in II 68a asms"; @@ -1329,7 +1329,7 @@ a * b / (a \ 2 + - 1 * b \ 2)" -val t = TermC.str2term"(a + b * x) / (a + - 1 * (b * x)) + - 1 * (a + - 1 * (b * x)) / (a + b * x) =\n4 * a * b / (a \ 2 + - 1 * b \ 2)"; +val t = TermC.parse_test @{context}"(a + b * x) / (a + - 1 * (b * x)) + - 1 * (a + - 1 * (b * x)) / (a + b * x) =\n4 * a * b / (a \ 2 + - 1 * b \ 2)"; Rewrite.trace_on := false; (*true false*) val SOME (t',asm) = rewrite_set_ thy false norm_Rational t; UnparseC.term t'; @@ -1496,14 +1496,14 @@ "[x = (- 2 * a + 4 * b + sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4,\n x =\n (- 2 * a + 4 * b + - 1 * sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4]")) then writeln "simplify MG" else error "rlang.sml: diff.behav. in II 62b [x=...]"; val asms = Ctree.get_assumptions pt p; -if asms = [TermC.str2term"0 <= ((- 2 * a + 4 * b + sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4 + a) \ 2 + ((- 2 * a + 4 * b + sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4 - 2 * b) \ 2", - TermC.str2term"0 <= a + 2 * b", - TermC.str2term"8 * (-4 * a * b) <= (-4 * b + 2 * a) \ 2", - TermC.str2term"8 * (-4 * a * b) <= (-4 * b + 2 * a) \ 2", - TermC.str2term"0 <= ((- 2 * a + 4 * b + - 1 * sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4 + a) \ 2 + ((- 2 * a + 4 * b + - 1 * sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4 - 2 * b) \ 2", - TermC.str2term"0 <= a + 2 * b", - TermC.str2term"8 * (-4 * a * b) <= (-4 * b + 2 * a) \ 2", - TermC.str2term"8 * (-4 * a * b) <= (-4 * b + 2 * a) \ 2"] +if asms = [TermC.parse_test @{context}"0 <= ((- 2 * a + 4 * b + sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4 + a) \ 2 + ((- 2 * a + 4 * b + sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4 - 2 * b) \ 2", + TermC.parse_test @{context}"0 <= a + 2 * b", + TermC.parse_test @{context}"8 * (-4 * a * b) <= (-4 * b + 2 * a) \ 2", + TermC.parse_test @{context}"8 * (-4 * a * b) <= (-4 * b + 2 * a) \ 2", + TermC.parse_test @{context}"0 <= ((- 2 * a + 4 * b + - 1 * sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4 + a) \ 2 + ((- 2 * a + 4 * b + - 1 * sqrt (16 * a * b + 16 * b \ 2 + 4 * a \ 2)) / 4 - 2 * b) \ 2", + TermC.parse_test @{context}"0 <= a + 2 * b", + TermC.parse_test @{context}"8 * (-4 * a * b) <= (-4 * b + 2 * a) \ 2", + TermC.parse_test @{context}"8 * (-4 * a * b) <= (-4 * b + 2 * a) \ 2"] then writeln "should be simplified MG" else error "rlang.sml: diff.behav. in II 62b asms"; @@ -1523,8 +1523,8 @@ (* val f = Form' (Test_Out.FormKF (~1,EdUndef,1,Nundef,"(2 * x + 1) * x \ 2 = 0")) normiert nicht ... korr.WN: -val t = TermC.str2term "(2*x+1)*x \ 2 = 0"; -val subst = [(TermC.str2term "bdv", TermC.str2term "x")]; +val t = TermC.parse_test @{context} "(2*x+1)*x \ 2 = 0"; +val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]; val SOME (t',_) = rewrite_set_inst_ thy false subst make_ratpoly_in t; if UnparseC.term t' = "x \ 2 + 2 * x \ 3 = 0" then () else error "rlang.sml: 7"; @@ -1547,7 +1547,7 @@ (*------------------------------vvv-Rewrite_Set "rat_eliminate"--------- > Rewrite.trace_on:=true; (*true false*) -> val t = TermC.str2term +> val t = TermC.parse_test @{context} "(3 + - 1 * x + 1 * x \ 2) / (9 * x + -6 * x \ 2 + 1 * x \ 3) = 1 / x"; > val SOME (t',asm) = rewrite_ thy dummy_ord rateq_erls true rat_mult_denominator_both t; @@ -1595,8 +1595,8 @@ then writeln"simplify result\nsimplify result\nsimplify result" else error "rlang.sml: diff.behav. in Pythagoras"; val asms = Ctree.get_assumptions pt p; -(*if asms = [TermC.str2term"0 <= -4 * (b \ 2 / 4 + -4 * r \ 2 / 4)", - TermC.str2term"0 <= -4 * (b \ 2 / 4 + -4 * r \ 2 / 4)"]*) +(*if asms = [TermC.parse_test @{context}"0 <= -4 * (b \ 2 / 4 + -4 * r \ 2 / 4)", + TermC.parse_test @{context}"0 <= -4 * (b \ 2 / 4 + -4 * r \ 2 / 4)"]*) if UnparseC.terms (*WN1104changed*) asms = "[0 <= -4 * (b \ 2 / 4 + - 1 * r \ 2 / 1),\ \0 <= -4 * (b \ 2 / 4 + - 1 * r \ 2 / 1)]" diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/root.sml --- a/test/Tools/isac/Knowledge/root.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/root.sml Sun Oct 09 07:44:22 2022 +0200 @@ -15,14 +15,14 @@ "----------- rls Root_erls ------------------------------"; "----------- rls Root_erls ------------------------------"; "----------- rls Root_erls ------------------------------"; -val t = TermC.str2term "sqrt 1"; +val t = TermC.parse_test @{context} "sqrt 1"; val SOME (t',_) = rewrite_set_ ctxt false Root_erls t; if UnparseC.term t' = "1" then () else error "root.sml: diff.behav. sqrt 1"; -val t = TermC.str2term "sqrt (- 1)"; +val t = TermC.parse_test @{context} "sqrt (- 1)"; val NONE = rewrite_set_ ctxt false Root_erls t; -val t = TermC.str2term "sqrt 0"; +val t = TermC.parse_test @{context} "sqrt 0"; val SOME (t',_) = rewrite_set_ ctxt false Root_erls t; if UnparseC.term t' = "0" then () else error "root.sml: diff.behav. sqrt 1"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/rooteq.sml --- a/test/Tools/isac/Knowledge/rooteq.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/rooteq.sml Sun Oct 09 07:44:22 2022 +0200 @@ -136,7 +136,7 @@ | _ => error "rooteq.sml: diff.behav. [x = 1 / 25]"; if UnparseC.terms (*WN1104changed*) (Ctree.get_assumptions pt p) = "[0 <= 1 / 25]" (*WN050916 before correction 'rewrite__set_ called with 'Rule_Set.Empty' for ..: - [(TermC.str2term"25 ~= 0",[])] *) + [(TermC.parse_test @{context}"25 ~= 0",[])] *) then writeln "should be True\n\ \should be True\n\ \should be True\n" @@ -204,7 +204,7 @@ val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt; case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 4]")) => () | _ => error "rooteq.sml: diff.behav. [x = 4]"; -if Ctree.get_assumptions pt p = [TermC.str2term"0 <= 12 * sqrt 2 * 4"] +if Ctree.get_assumptions pt p = [TermC.parse_test @{context}"0 <= 12 * sqrt 2 * 4"] then writeln "should be True\nshould be True\nshould be True\n\ \should be True\nshould be True\nshould be True\n" else error "rooteq.sml: diff.behav. with 0 <= 12 * sqrt 2 * 4"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/rootrateq.sml --- a/test/Tools/isac/Knowledge/rootrateq.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/rootrateq.sml Sun Oct 09 07:44:22 2022 +0200 @@ -114,8 +114,8 @@ "check_elementwise: no set 1 = 2 + - 2 * sqrt x"*) (*---- 2nd try: we investigate the script ["RootEq", "solve_sq_root_equation"] found via pbl*) -val t = TermC.str2term "((lhs e_e) is_sqrtTerm_in v_v) | ((rhs e_e) is_sqrtTerm_in v_v)"; -val t = TermC.str2term ("((lhs (1 = 2 * (1 + - 1 * sqrt x))) is_sqrtTerm_in x) |" ^ +val t = TermC.parse_test @{context} "((lhs e_e) is_sqrtTerm_in v_v) | ((rhs e_e) is_sqrtTerm_in v_v)"; +val t = TermC.parse_test @{context} ("((lhs (1 = 2 * (1 + - 1 * sqrt x))) is_sqrtTerm_in x) |" ^ " ((rhs (1 = 2 * (1 + - 1 * sqrt x))) is_sqrtTerm_in x)"); val SOME (t, _) = rewrite_set_ thy true rooteq_srls t; UnparseC.term t = "True | True"; (*...was same in 2002 (NOT "True"); so program seems to take diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/system.sml --- a/test/Tools/isac/Knowledge/system.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/system.sml Sun Oct 09 07:44:22 2022 +0200 @@ -19,14 +19,14 @@ "----------- normalise system ------------------------------------"; "----------- normalise system ------------------------------------"; "----------- normalise system ------------------------------------"; -val t = TermC.str2term "[0 = c*0 + - 1*q_0*(0 \ 2 / 2) + c_2,\ +val t = TermC.parse_test @{context} "[0 = c*0 + - 1*q_0*(0 \ 2 / 2) + c_2,\ \ 0 = c*L + - 1*q_0*(L \ 2 / 2) + c_2]"; val SOME (t,_) = rewrite_set_ thy false norm_Poly t; if UnparseC.term t = "[0 = - 1 * q_0 * (0 / 2) + c_2, 0 = L * c + - 1 * q_0 * (L \ 2 / 2) + c_2]" then () else error "system.sml, diff.behav. in norm_Poly"; -val t = TermC.str2term "[0 = c*0 + - 1*q_0*(0 \ 2 / 2) + c_2,\ +val t = TermC.parse_test @{context} "[0 = c*0 + - 1*q_0*(0 \ 2 / 2) + c_2,\ \ 0 = c*L + - 1*q_0*(L \ 2 / 2) + c_2]"; val SOME (t,_) = rewrite_set_ thy false norm_Rational t; if UnparseC.term t = @@ -34,7 +34,7 @@ then () else error "system.sml, diff.behav. in norm_Rational"; -val t = TermC.str2term "nth_ 1 [0 = c*0 + - 1*q_0*(0 \ 2 / 2) + c_2,\ +val t = TermC.parse_test @{context} "nth_ 1 [0 = c*0 + - 1*q_0*(0 \ 2 / 2) + c_2,\ \ 0 = c*L + - 1*q_0*(L \ 2 / 2) + c_2]"; val SOME (t,_) = rewrite_set_ thy false prog_expr t; if UnparseC.term t = "0 = c * 0 + - 1 * q_0 * (0 \ 2 / 2) + c_2" diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Knowledge/wn.sml --- a/test/Tools/isac/Knowledge/wn.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Knowledge/wn.sml Sun Oct 09 07:44:22 2022 +0200 @@ -4,7 +4,7 @@ various test dependent on IsacKnowledge/ outside Test.thy, Test.ML*) - val t = TermC.str2term "solve (a*x + b = c, x)"; + val t = TermC.parse_test @{context} "solve (a*x + b = c, x)"; TermC.atomty t; (* "\n*** -------------" diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/MathEngBasic/ctree.sml --- a/test/Tools/isac/MathEngBasic/ctree.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/MathEngBasic/ctree.sml Sun Oct 09 07:44:22 2022 +0200 @@ -103,7 +103,7 @@ "ctree.sml-------------- cut_tree new (from ctree above)----------"; val (pt', cuts) = cut_tree pt ([1],Frm); "ctree.sml-------------- cappend on complete ctree from above ----"; -val (pt', cuts) = cappend_form pt [1] (Istate.empty, ContextC.empty) (TermC.str2term "Inform[1]"); +val (pt', cuts) = cappend_form pt [1] (Istate.empty, ContextC.empty) (TermC.parse_test @{context} "Inform[1]"); "----------------------------------------------------------------/"; val (p,_,f,nxt,_,pt) = me nxt p [1] pt(*cappend_form: pos =[1]*); @@ -419,7 +419,7 @@ "-------------- cappend (from ctree above)------------------------"; "-------------- cappend (from ctree above)------------------------"; "-------------- cappend (from ctree above)------------------------"; -val (pt',cuts) = cappend_form pt [3,2,1] Istate.empty (TermC.str2term "newnew"); +val (pt',cuts) = cappend_form pt [3,2,1] Istate.empty (TermC.parse_test @{context} "newnew"); if cuts = [([3, 2, 1], Res), ([3, 2, 2], Res), ([3, 2], Res), @@ -432,8 +432,8 @@ UnparseC.term (fst (get_obj g_result pt' [3,2,1])) = "??.empty" then () else error "ctree.sml: diff:behav. in cappend 1"; -val (pt',cuts) = cappend_atomic pt [3,2,1] Istate.empty (TermC.str2term "newform") - (Tac "test") (TermC.str2term "newresult",[]) Complete; +val (pt',cuts) = cappend_atomic pt [3,2,1] Istate.empty (TermC.parse_test @{context} "newform") + (Tac "test") (TermC.parse_test @{context} "newresult",[]) Complete; if cuts = [([3, 2, 1], Res), (*?????????????*) ([3, 2, 2], Res), ([3, 2], Res), @@ -471,7 +471,7 @@ (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt(**)cappend_form: pos =[1]*); val p = ([1], Frm); -val (pt,cuts) = cappend_form pt (fst p) Istate.empty (TermC.str2term "x + 1 = 2"); +val (pt,cuts) = cappend_form pt (fst p) Istate.empty (TermC.parse_test @{context} "x + 1 = 2"); val form = get_obj g_form pt (fst p); val (res,_) = get_obj g_result pt (fst p); if UnparseC.term form = "x + 1 = 2" andalso res = TermC.empty then () else @@ -482,8 +482,8 @@ (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt(**)cappend_atomic: pos =[1]*); val p = ([1], Res); val (pt,cuts) = - cappend_atomic pt (fst p) Istate.empty (TermC.str2term "x + 1 = 2") - Empty_Tac (TermC.str2term "x + 1 + - 1 * 2 = 0",[]) Incomplete; + cappend_atomic pt (fst p) Istate.empty (TermC.parse_test @{context} "x + 1 = 2") + Empty_Tac (TermC.parse_test @{context} "x + 1 + - 1 * 2 = 0",[]) Incomplete; val form = get_obj g_form pt (fst p); val (res,_) = get_obj g_result pt (fst p); if UnparseC.term form = "x + 1 = 2" andalso UnparseC.term res = "x + 1 + - 1 * 2 = 0" @@ -494,8 +494,8 @@ (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt(**)cappend_atomic: pos =[2]*); val p = ([2], Res); val (pt,cuts) = - cappend_atomic pt (fst p) Istate.empty (TermC.str2term "x + 1 + - 1 * 2 = 0") - Empty_Tac (TermC.str2term "- 1 + x = 0",[]) Incomplete; + cappend_atomic pt (fst p) Istate.empty (TermC.parse_test @{context} "x + 1 + - 1 * 2 = 0") + Empty_Tac (TermC.parse_test @{context} "- 1 + x = 0",[]) Incomplete; val form = get_obj g_form pt (fst p); val (res,_) = get_obj g_result pt (fst p); if UnparseC.term form = "x + 1 + - 1 * 2 = 0" andalso UnparseC.term res = "- 1 + x = 0" @@ -516,7 +516,7 @@ (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt(**)cappend_form: pos =[3,1]*); val p = ([3, 1], Frm); -val (pt,cuts) = cappend_form pt (fst p) Istate.empty (TermC.str2term "- 1 + x = 0"); +val (pt,cuts) = cappend_form pt (fst p) Istate.empty (TermC.parse_test @{context} "- 1 + x = 0"); val form = get_obj g_form pt (fst p); val (res,_) = get_obj g_result pt (fst p); if UnparseC.term form = "- 1 + x = 0" andalso res = TermC.empty then () else @@ -527,8 +527,8 @@ (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(**)cappend_atomic: pos =[3,1]*) val p = ([3, 1], Res); val (pt,cuts) = - cappend_atomic pt (fst p) Istate.empty (TermC.str2term "- 1 + x = 0") - Empty_Tac (TermC.str2term "x = 0 + - 1 * - 1",[]) Incomplete; + cappend_atomic pt (fst p) Istate.empty (TermC.parse_test @{context} "- 1 + x = 0") + Empty_Tac (TermC.parse_test @{context} "x = 0 + - 1 * - 1",[]) Incomplete; val form = get_obj g_form pt (fst p); val (res,_) = get_obj g_result pt (fst p); if UnparseC.term form = "- 1 + x = 0" andalso UnparseC.term res = "x = 0 + - 1 * - 1" then() @@ -1160,8 +1160,8 @@ "---(2) on S(606)..S(608)--------"; (*========== inhibit exn AK110726 ============================================== (* ERROR: Can't unify istate to istate * Proof.context *) -val (pt', cuts) = cappend_atomic pt [1] Istate.empty (TermC.str2term "Inform[1]") - (Tac "test") (TermC.str2term "Inres[1]",[]) Complete; +val (pt', cuts) = cappend_atomic pt [1] Istate.empty (TermC.parse_test @{context} "Inform[1]") + (Tac "test") (TermC.parse_test @{context} "Inres[1]",[]) Complete; (*default_print_depth 99;*) cuts; @@ -1182,8 +1182,8 @@ Test_Tool.show_pt pt'; "---(3) on S(606)..S(608)--------"; Test_Tool.show_pt pt; -val (pt', cuts) = cappend_atomic pt [2] Istate.empty (TermC.str2term "Inform[2]") - (Tac "test") (TermC.str2term "Inres[2]",[]) Complete; +val (pt', cuts) = cappend_atomic pt [2] Istate.empty (TermC.parse_test @{context} "Inform[2]") + (Tac "test") (TermC.parse_test @{context} "Inres[2]",[]) Complete; (*default_print_depth 99;*) cuts; (*default_print_depth 3;*) @@ -1220,7 +1220,7 @@ "---(4) on S(606)..S(608)--------"; val (pt', cuts) = cappend_problem pt [3] Istate.empty ([],References.empty) - ([],References.empty, TermC.str2term "Inhead[3]", ContextC.empty); + ([],References.empty, TermC.parse_test @{context} "Inhead[3]", ContextC.empty); (*default_print_depth 99;*) cuts; (*default_print_depth 3;*) @@ -1245,8 +1245,8 @@ *) "---(6- 1) on S(606)..S(608)--------"; -val (pt', cuts) = cappend_atomic pt [3,1] Istate.empty (TermC.str2term "Inform[3,1]") - (Tac "test") (TermC.str2term "Inres[3,1]",[]) Complete; +val (pt', cuts) = cappend_atomic pt [3,1] Istate.empty (TermC.parse_test @{context} "Inform[3,1]") + (Tac "test") (TermC.parse_test @{context} "Inres[3,1]",[]) Complete; (*default_print_depth 99;*) cuts; (*default_print_depth 3;*) @@ -1271,8 +1271,8 @@ error "ctree.sml: diff:behav. in complete pt: append_atomic[3,1] Inform"; "---(6) on S(606)..S(608)--------"; -val (pt', cuts) = cappend_atomic pt [3,2] Istate.empty (TermC.str2term "Inform[3,2]") - (Tac "test") (TermC.str2term "Inres[3,2]",[]) Complete; +val (pt', cuts) = cappend_atomic pt [3,2] Istate.empty (TermC.parse_test @{context} "Inform[3,2]") + (Tac "test") (TermC.parse_test @{context} "Inres[3,2]",[]) Complete; (*default_print_depth 99;*) cuts; (*default_print_depth 3;*) @@ -1296,8 +1296,8 @@ "---(6++) on S(606)..S(608)--------"; (**) -val (pt', cuts) = cappend_atomic pt [3,2,1] Istate.empty (TermC.str2term "Inform[3,2,1]") - (Tac "test") (TermC.str2term "Inres[3,2,1]",[]) Complete; +val (pt', cuts) = cappend_atomic pt [3,2,1] Istate.empty (TermC.parse_test @{context} "Inform[3,2,1]") + (Tac "test") (TermC.parse_test @{context} "Inres[3,2,1]",[]) Complete; (*default_print_depth 99;*) cuts; (*default_print_depth 1;*) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/MathEngBasic/mstools.sml --- a/test/Tools/isac/MathEngBasic/mstools.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/MathEngBasic/mstools.sml Sun Oct 09 07:44:22 2022 +0200 @@ -20,38 +20,38 @@ "----------- fun Input_Descript.join -- fun Input_Descript.split -------------------------------"; "----------- fun Input_Descript.join -- fun Input_Descript.split -------------------------------"; "----------- fun Input_Descript.join -- fun Input_Descript.split -------------------------------"; -(*val t = TermC.str2term "maximum A"; +(*val t = TermC.parse_test @{context} "maximum A"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); val it = "maximum A" : cterm -> val t = TermC.str2term "fixedValues [r=Arbfix]"; +> val t = TermC.parse_test @{context} "fixedValues [r=Arbfix]"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "fixedValues [r = Arbfix]" -> val t = TermC.str2term "valuesFor [a]"; +> val t = TermC.parse_test @{context} "valuesFor [a]"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "valuesFor [a]" -> val t = TermC.str2term "valuesFor [a,b]"; +> val t = TermC.parse_test @{context} "valuesFor [a,b]"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "valuesFor [a, b]" -> val t = TermC.str2term "relations [A=a*b, (a/2) \ 2 + (b/2) \ 2 = r \ 2]"; +> val t = TermC.parse_test @{context} "relations [A=a*b, (a/2) \ 2 + (b/2) \ 2 = r \ 2]"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); relations [A = a * b, (a / 2) \ 2 + (b / 2) \ 2 = r \ 2]" -> val t = TermC.str2term "boundVariable a"; +> val t = TermC.parse_test @{context} "boundVariable a"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "boundVariable a" -> val t = TermC.str2term "interval {x::real. 0 <= x & x <= 2*r}"; +> val t = TermC.parse_test @{context} "interval {x::real. 0 <= x & x <= 2*r}"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "interval {x. 0 <= x & x <= 2 * r}" -> val t = TermC.str2term "equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))"; +> val t = TermC.parse_test @{context} "equality (sqrt(9+4*x)=sqrt x + sqrt(5+x))"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "equality (sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x))" -> val t = TermC.str2term "solveFor x"; +> val t = TermC.parse_test @{context} "solveFor x"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "solveFor x" -> val t = TermC.str2term "errorBound (eps=0)"; +> val t = TermC.parse_test @{context} "errorBound (eps=0)"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "errorBound (eps = 0)" -> val t = TermC.str2term "solutions L"; +> val t = TermC.parse_test @{context} "solutions L"; > val (d,ts) = Input_Descript.split thy t; Input_Descript.join thy (d,ts); "solutions L" @@ -105,7 +105,7 @@ "----------- fun pbl_ids -----------------------------------------------------------------------"; "----------- fun pbl_ids -----------------------------------------------------------------------"; (* -val t as t1 $ t2 = TermC.str2term "antiDerivativeName M_b"; +val t as t1 $ t2 = TermC.parse_test @{context} "antiDerivativeName M_b"; pbl_ids ctxt t1 t2; val t = (Thm.term_of o the o (TermC.parse thy)) "fixedValues [r=Arbfix]"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/MathEngBasic/rewrite.sml --- a/test/Tools/isac/MathEngBasic/rewrite.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/MathEngBasic/rewrite.sml Sun Oct 09 07:44:22 2022 +0200 @@ -245,8 +245,8 @@ "----------- step through 'fun rewrite_terms_' ------------------------------------------------"; "----- step 0: args for rewrite_terms_, local fun"; val (thy, ord, erls, equs, t) = - (@{theory "Biegelinie"}, Rewrite_Ord.function_empty, Rule_Set.Empty, [TermC.str2term "x = 0"], - TermC.str2term "M_b x = -1 * q_0 * x \ 2 / 2 + x * c + c_2"); + (@{theory "Biegelinie"}, Rewrite_Ord.function_empty, Rule_Set.Empty, [TermC.parse_test @{context} "x = 0"], + TermC.parse_test @{context} "M_b x = -1 * q_0 * x \ 2 / 2 + x * c + c_2"); "----- step 1: args for rew_"; val ((t', asm'), (rules as r::rs), t) = ((TermC.empty, []), equs, t); "----- step 2: rew_sub"; @@ -259,15 +259,15 @@ if UnparseC.term t' = "M_b 0 = - 1 * q_0 * 0 \ 2 / 2 + 0 * c + c_2" then () else error "rewrite.sml rewrite_terms_ [x = 0]"; -val equs = [TermC.str2term "M_b 0 = 0"]; -val t = TermC.str2term "M_b 0 = - 1 * q_0 * 0 \ 2 / 2 + 0 * c + c_2"; +val equs = [TermC.parse_test @{context} "M_b 0 = 0"]; +val t = TermC.parse_test @{context} "M_b 0 = - 1 * q_0 * 0 \ 2 / 2 + 0 * c + c_2"; val SOME (t', _) = rewrite_terms_ ctxt Rewrite_Ord.function_empty Rule_Set.Empty equs t; writeln "---------- rewrite_terms_ 2---------------------------"; if UnparseC.term t' = "0 = - 1 * q_0 * 0 \ 2 / 2 + 0 * c + c_2" then () else error "rewrite.sml rewrite_terms_ [M_b 0 = 0]"; -val equs = [TermC.str2term "x = 0", TermC.str2term"M_b 0 = 0"]; -val t = TermC.str2term "M_b x = - 1 * q_0 * x \ 2 / 2 + x * c + c_2"; +val equs = [TermC.parse_test @{context} "x = 0", TermC.parse_test @{context}"M_b 0 = 0"]; +val t = TermC.parse_test @{context} "M_b x = - 1 * q_0 * x \ 2 / 2 + x * c + c_2"; val SOME (t', _) = rewrite_terms_ ctxt Rewrite_Ord.function_empty Rule_Set.Empty equs t; writeln "---------- rewrite_terms_ 3---------------------------"; if UnparseC.term t' = "0 = - 1 * q_0 * 0 \ 2 / 2 + 0 * c + c_2" then () @@ -278,11 +278,11 @@ "----------- rewrite_inst_ bdvs ----------------------------------------------------------------"; "----------- rewrite_inst_ bdvs ----------------------------------------------------------------"; (*see smltest/Scripts/term_G.sml: inst_bdv 2*) -val t = TermC.str2term"-1 * (q_0 * L \ 2) / 2 + (L * c_3 + c_4) = 0"; -val bdvs = [(TermC.str2term"bdv_1",TermC.str2term"c"), - (TermC.str2term"bdv_2",TermC.str2term"c_2"), - (TermC.str2term"bdv_3",TermC.str2term"c_3"), - (TermC.str2term"bdv_4",TermC.str2term"c_4")]; +val t = TermC.parse_test @{context}"-1 * (q_0 * L \ 2) / 2 + (L * c_3 + c_4) = 0"; +val bdvs = [(TermC.parse_test @{context}"bdv_1",TermC.parse_test @{context}"c"), + (TermC.parse_test @{context}"bdv_2",TermC.parse_test @{context}"c_2"), + (TermC.parse_test @{context}"bdv_3",TermC.parse_test @{context}"c_3"), + (TermC.parse_test @{context}"bdv_4",TermC.parse_test @{context}"c_4")]; (*------------ outcommented WN071210, after inclusion into ROOT.ML val SOME (t,_) = rewrite_inst_ thy e_rew_ord @@ -317,7 +317,7 @@ (or not: hen the Rrls not applied); if pre1 and pre2 evaluate to @{term True} in this environment, then the Rrls is applied. *) -val t = TermC.str2term "(a + b) / c ::real"; +val t = TermC.parse_test @{context} "(a + b) / c ::real"; val pat = TermC.parse_patt thy "?r / ?s ::real"; val pres = [TermC.parse_patt thy "?r is_expanded", TermC.parse_patt thy "?s is_expanded"]; val prepat = [(pres, pat)]; @@ -335,7 +335,7 @@ "===== Rational.thy: add_fractions_p ==="; (* if each pat* TermC.matches with the current term, the Rrls is applied (there are no preconditions to be checked, they are @{term True}) *) -val t = TermC.str2term "a / b + 1 / 2"; +val t = TermC.parse_test @{context} "a / b + 1 / 2"; val pat = TermC.parse_patt thy "?r / ?s + ?u / ?v"; val pres = [@{term True}]; val prepat = [(pres, pat)]; @@ -349,7 +349,7 @@ "===== Poly.thy: order_mult_ ==="; (* ?p matched with the current term gives an environment, which evaluates (the instantiated) "p is_multUnordered" to true*) -val t = TermC.str2term "x \ 2 * x"; +val t = TermC.parse_test @{context} "x \ 2 * x"; val pat = TermC.parse_patt thy "?p :: real" val pres = [TermC.parse_patt thy "?p is_multUnordered"]; val prepat = [(pres, pat)]; @@ -369,10 +369,10 @@ "----------- fun app_rev, Rrls, ----------------------------------------------------------------"; "----------- fun app_rev, Rrls, ----------------------------------------------------------------"; "----------- fun app_rev, Rrls, ----------------------------------------------------------------"; -val t = TermC.str2term "x \ 2 * x"; +val t = TermC.parse_test @{context} "x \ 2 * x"; if is_multUnordered t then () else error "rewrite.sml diff. is_multUnordered 2"; -val tm = TermC.str2term "(x \ 2 * x) is_multUnordered"; +val tm = TermC.parse_test @{context} "(x \ 2 * x) is_multUnordered"; (*+*)case eval_is_multUnordered "testid" "" tm ctxt of (*+*) SOME @@ -453,7 +453,7 @@ tracing "=== poly.sml: scan_ chk prepat end"; "----- chk ---"; -(*reestablish...*) val t = TermC.str2term "x \ 2 * x"; +(*reestablish...*) val t = TermC.parse_test @{context} "x \ 2 * x"; val [(pres, pat)] = prepat; val subst: Type.tyenv * Envir.tenv = Pattern.match thy (pat, t) @@ -465,7 +465,7 @@ if UnparseC.terms asms = "[\"x \ 2 * x is_multUnordered\"]" then () else error "rewrite.sml: diff. is_multUnordered, asms"; val (thy, i, asms, bdv, rls) = - (thy, (i+1), [TermC.str2term "(x \ 2 * x) is_multUnordered"], + (thy, (i+1), [TermC.parse_test @{context} "(x \ 2 * x) is_multUnordered"], [] : Subst.T, erls); case eval__true ctxt i asms bdv rls of ([], true) => () @@ -477,7 +477,7 @@ val thm = @{thm div_by_1}; val prop = Thm.prop_of thm; TermC.atomty prop; (*Type 'a*) -val t = TermC.str2term "(2*x)/1"; (*Type real*) +val t = TermC.parse_test @{context} "(2*x)/1"; (*Type real*) val (thy, ro, er, inst) = (@{theory "Isac_Knowledge"}, tless_true, eval_rls, [(@{term "bdv::real"}, @{term "x::real"})]); @@ -680,7 +680,7 @@ (* norm_equation is defined in Test.thy, other rls see Knowledg/**) val thy = @{theory}; val rls = norm_equation; -val term = TermC.str2term "x + 1 = 2"; +val term = TermC.parse_test @{context} "x + 1 = 2"; (**)val SOME (t, asm) = rewrite_set_ ctxt false rls term; (** )##### try thm: "root_ge0" diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/OLDTESTS/interface-xml.sml --- a/test/Tools/isac/OLDTESTS/interface-xml.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/OLDTESTS/interface-xml.sml Sun Oct 09 07:44:22 2022 +0200 @@ -3,10 +3,10 @@ *) (*see javatest.isac.util.TermC.parse.TestXMLParserDigest#testParseRefFormula*) -refformulaOK2xml 1 ([1],Frm) (Form (TermC.str2term "x+1=2")); +refformulaOK2xml 1 ([1],Frm) (Form (TermC.parse_test @{context} "x+1=2")); (*see javatest.isac.util.TermC.parse.TestXMLParserDigest#testParseRefCalcHead*) refformulaOK2xml 1 ([1],Pbl) (ModSpec Specification_Def.empty); -getintervalOK 1 [(([2],Res), TermC.str2term "x = 4"), - (([3],Pbl), TermC.str2term "e_headline"), - (([3,1],Frm), TermC.str2term "-1+x=0")]; +getintervalOK 1 [(([2],Res), TermC.parse_test @{context} "x = 4"), + (([3],Pbl), TermC.parse_test @{context} "e_headline"), + (([3,1],Frm), TermC.parse_test @{context} "-1+x=0")]; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/OLDTESTS/root-equ.sml --- a/test/Tools/isac/OLDTESTS/root-equ.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/OLDTESTS/root-equ.sml Sun Oct 09 07:44:22 2022 +0200 @@ -186,7 +186,7 @@ val rls = Test_simplify; val (t,_) = the (rewrite_set_ thy false rls t); val rls = isolate_bdv; -val subst = [(TermC.str2term "bdv", TermC.str2term "x")]; +val subst = [(TermC.parse_test @{context} "bdv", TermC.parse_test @{context} "x")]; val (t,_) = the (rewrite_set_inst_ thy false subst rls t); val rls = Test_simplify; val (t,_) = the (rewrite_set_ thy false rls t); @@ -247,7 +247,7 @@ " _________________ rewrite + cappend _________________ "; " _________________ rewrite + cappend _________________ "; val thy' = "Test"; -val ct = TermC.str2term"sqrt(9+4*x)=sqrt x + sqrt(5+x)"; +val ct = TermC.parse_test @{context}"sqrt(9+4*x)=sqrt x + sqrt(5+x)"; val ctl = ["sqrt(9+4*x)=sqrt x + sqrt(5+x)", "x::real", "0"]; val oris = O_Model.init thy ctl ((#ppc o Problem.from_store) @@ -290,70 +290,70 @@ val pos = (lev_on o lev_dn) pos; val thm = ("square_equation_left", ""); val ctold = ct; val (ct,asm) = the (rewrite thy' "tless_true" ("tval_rls") true thm (UnparseC.term ct)); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac (fst thm)) (TermC.str2term ct,[])Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac (fst thm)) (TermC.parse_test @{context} ct,[])Complete; (*val pt = union_asm pt [] (map (rpair []) asm);*) val pos = lev_on pos; -val rls = ("Test_simplify"); val ctold = TermC.str2term ct; +val rls = ("Test_simplify"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set thy' false rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_on pos; -val rls = ("rearrange_assoc"); val ctold = TermC.str2term ct; +val rls = ("rearrange_assoc"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set thy' false rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_on pos; -val rls = ("isolate_root"); val ctold = TermC.str2term ct; +val rls = ("isolate_root"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set thy' false rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_on pos; -val rls = ("Test_simplify"); val ctold = TermC.str2term ct; +val rls = ("Test_simplify"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set thy' false rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_on pos; -val thm = ("square_equation_left", ""); val ctold = TermC.str2term ct; +val thm = ("square_equation_left", ""); val ctold = TermC.parse_test @{context} ct; val (ct,asm) = the (rewrite thy' "tless_true" "tval_rls" true thm ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; (*val pt = union_asm pt [] (map (rpair []) asm);*) val pos = lev_up pos; -val (pt,_) = append_result pt pos Istate.empty (TermC.str2term ct,[]) Complete; +val (pt,_) = append_result pt pos Istate.empty (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_on pos; -val rls = ("Test_simplify"); val ctold = TermC.str2term ct; +val rls = ("Test_simplify"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set thy' false rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_on pos; -val rls = ("norm_equation"); val ctold = TermC.str2term ct; +val rls = ("norm_equation"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set thy' false rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_on pos; -val rls = ("Test_simplify"); val ctold = TermC.str2term ct; +val rls = ("Test_simplify"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set thy' false rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; (* --- see comments in interface_ME_ISA/instantiate'' val rlsdat' = instantiate_rls' thy' [("bdv", "x")] ("isolate_bdv"); val (ct,_) = the (rewrite_set thy' false ("#isolate_bdv",rlsdat') ct); *) val pos = lev_on pos; -val rls = ("isolate_bdv"); val ctold = TermC.str2term ct; +val rls = ("isolate_bdv"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set_inst thy' false [("bdv", "x")] rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_on pos; -val rls = ("Test_simplify"); val ctold = TermC.str2term ct; +val rls = ("Test_simplify"); val ctold = TermC.parse_test @{context} ct; val (ct,_) = the (rewrite_set thy' false rls ct); -val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.str2term ct,[]) Complete; +val (pt,_) = cappend_atomic pt pos loc ctold (Tac rls) (TermC.parse_test @{context} ct,[]) Complete; val pos = lev_up pos; -val (pt,pos) = append_result pt pos Istate.empty (TermC.str2term ct,[]) Complete; +val (pt,pos) = append_result pt pos Istate.empty (TermC.parse_test @{context} ct,[]) Complete; Ctree.get_assumptions pt ([],Res); writeln (pr_ctree pr_short pt); @@ -529,7 +529,7 @@ val (p,_,f,nxt,_,pt) = me nxt p c pt; (*.9.6.03 - val t = TermC.str2term "sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x)"; + val t = TermC.parse_test @{context} "sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x)"; val SOME (t',asm) = rewrite_set_ thy false rls t; UnparseC.term t'; Rewrite.trace_on:=false; (*true false*) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/OLDTESTS/script.sml --- a/test/Tools/isac/OLDTESTS/script.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/OLDTESTS/script.sml Sun Oct 09 07:44:22 2022 +0200 @@ -271,7 +271,7 @@ ([],(User', [], [], TermC.empty, TermC.empty,Sundef))]:ets; val l0 = []; " --------------- 1. ---------------------------------------------"; -val (pt,_) = cappend_atomic pt[1]Istate.empty TermC.empty(Rewrite("test", ""))(TermC.str2term ct,[])Complete; +val (pt,_) = cappend_atomic pt[1]Istate.empty TermC.empty(Rewrite("test", ""))(TermC.parse_test @{context} ct,[])Complete; (*12.10.03:*** Unknown theorem(s) "rroot_square_inv" val Applicable.Yes m' = Step.check (Rewrite("rroot_square_inv", "")) (pt, p); *) diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/ProgLang/auto_prog.sml --- a/test/Tools/isac/ProgLang/auto_prog.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/ProgLang/auto_prog.sml Sun Oct 09 07:44:22 2022 +0200 @@ -51,9 +51,9 @@ if UnparseC.terms (formal_args auto_script) = "[\"t_t\", \"v\"]" then () else error "formal_args of auto-gen.script changed"; - Istate.init_detail (Rewrite_Set_Inst (["(''bdv'', x)"], "integration_rules")) (TermC.str2term "someTermWithBdv"); + Istate.init_detail (Rewrite_Set_Inst (["(''bdv'', x)"], "integration_rules")) (TermC.parse_test @{context} "someTermWithBdv"); "~~~~~ fun init_detail , args:"; val ((Tactic.Rewrite_Set_Inst (subs, rls)), t) - = ((Rewrite_Set_Inst (["(''bdv'', x)"], "integration_rules")), TermC.str2term "someTermWithBdv"); + = ((Rewrite_Set_Inst (["(''bdv'', x)"], "integration_rules")), TermC.parse_test @{context} "someTermWithBdv"); val v = case Subst.T_from_input ctxt subs of (_, v) :: _ => v; (*case*) get_rls ctxt rls (*of*); diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/ProgLang/evaluate.sml --- a/test/Tools/isac/ProgLang/evaluate.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/ProgLang/evaluate.sml Sun Oct 09 07:44:22 2022 +0200 @@ -47,7 +47,7 @@ "----------- fun calculate_ --------------------------------------------------------------------"; "----------- fun calculate_ --------------------------------------------------------------------"; (* fun rewrite__set_ \ fun rew_once works the same way *) -val t = TermC.str2term "((1+2)*4/3) \ 2"; +val t = TermC.parse_test @{context} "((1+2)*4/3) \ 2"; val thy = @{theory}; val ctxt = Proof_Context.init_global @{theory} val times = ("Groups.times_class.times", Calc_Binop.numeric "#mult_") : string * Eval.ml_fun; @@ -145,7 +145,7 @@ rewrite_set_ ctxt false tval_rls t; (*val it = SOME (Const (\<^const_name>\True\, "bool"),[]) ... works*) - val t = TermC.str2term "2 * x is_num"; + val t = TermC.parse_test @{context} "2 * x is_num"; val NONE = eval_is_num "" "" t (@{theory "Isac_Knowledge"}); @@ -320,7 +320,7 @@ val (thy, op_, ef, arg) = (thy, "EqSystem.occur_exactly_in", get_calc (@{theory "EqSystem"} |> Proof_Context.init_global) "occur_exactly_in" |> snd |> snd, - TermC.str2term + TermC.parse_test @{context} "[] from [c, c_2, c_3, c_4] occur_exactly_in - 1 * (q_0 * L \ 2) / 2" ); val SOME (str, simpl) = get_pair ctxt op_ ef arg; @@ -332,7 +332,7 @@ "----------- calculate (2 * x is_num) -------------------"; "----------- calculate (2 * x is_num) -------------------"; "----------- calculate (2 * x is_num) -------------------"; -val t = TermC.str2term "(2::real) * x is_num"; +val t = TermC.parse_test @{context} "(2::real) * x is_num"; val SOME (str, t') = eval_is_num "" "Prog_Expr.is_num" t @{theory Test}; if UnparseC.term t' = "(2 * x is_num) = False" then () @@ -471,7 +471,7 @@ "----------- fun adhoc_thm \ exception TYPE --------------------------------------------------"; "----------- fun adhoc_thm \ exception TYPE --------------------------------------------------"; "----------- fun adhoc_thm \ exception TYPE --------------------------------------------------"; -val t = TermC.str2term "sqrt 4"; +val t = TermC.parse_test @{context} "sqrt 4"; Eval.adhoc_thm @{context} ("NthRoot.sqrt", eval_sqrt "#sqrt_") t; "~~~~~ fun adhoc_thm , args:"; val (thy, (op_, eval_fn), ct) = diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/ProgLang/listC.sml --- a/test/Tools/isac/ProgLang/listC.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/ProgLang/listC.sml Sun Oct 09 07:44:22 2022 +0200 @@ -47,7 +47,7 @@ val ctxt = Proof_Context.init_global @{theory} val prog_expr = get_rls @{context} "prog_expr" -val t = TermC.str2term "NTH 1 [a,b,c,d,e]"; +val t = TermC.parse_test @{context} "NTH 1 [a,b,c,d,e]"; TermC.atomty t; val thm = Thm.prop_of @{thm NTH_NIL}; TermC.atomty thm; @@ -55,8 +55,8 @@ if UnparseC.term t' = "a" then () else error "NTH 1 [a,b,c,d,e] = a ..changed"; -val t = TermC.str2term "NTH 3 [a,b,c,d,e]"; -case TermC.str2term "NTH 3 [a,b,c,d,e]" of +val t = TermC.parse_test @{context} "NTH 3 [a,b,c,d,e]"; +case TermC.parse_test @{context} "NTH 3 [a,b,c,d,e]" of Const (\<^const_name>\NTH\, _) $ (Const (\<^const_name>\numeral\, _) $ (Const (\<^const_name>\num.Bit1\, _) $ Const (\<^const_name>\num.One\, _))) $ (Const (\<^const_name>\Cons\, _) $ Free ("a", _) $ (Const (\<^const_name>\Cons\, _) $ Free ("b", _) $ @@ -71,7 +71,7 @@ else error "NTH 3 [a,b,c,d,e] = NTH (3 + - 1) [b, c, d, e] ..changed"; (* now the argument "(3 + - 1)" etc needs to be evaluated in the assumption of NTH_CONS *) -val t = TermC.str2term "NTH 3 [a,b,c,d,e]"; +val t = TermC.parse_test @{context} "NTH 3 [a,b,c,d,e]"; TermC.atomty t; val SOME (t', _) = rewrite_set_ ctxt false prog_expr t; @@ -84,7 +84,7 @@ val prog_expr = get_rls @{context} "prog_expr" val thy = @{theory ListC}; -val t = TermC.str2term "Length [1, 1, 1]"; +val t = TermC.parse_test @{context} "Length [1, 1, 1]"; val SOME (t, asm) = rewrite_ ctxt tless_true tval_rls false @{thm LENGTH_CONS} t; UnparseC.term t = "1 + Length [1, 1]"; val SOME (t, asm) = rewrite_ ctxt tless_true tval_rls false @{thm LENGTH_CONS} t; @@ -97,12 +97,12 @@ if UnparseC.term t = "1 + (1 + (1 + 0))" then () else error "Length [1, 1, 1] = 1 + (1 + (1 + 0)) ..changed"; -val t = TermC.str2term "Length [1, 1, 1]"; +val t = TermC.parse_test @{context} "Length [1, 1, 1]"; val SOME (t, asm) = rewrite_set_ ctxt false prog_expr t; if UnparseC.term t = "3" then () else error "Length [1, 1, 1] = 3 ..prog_expr changed"; -val t = TermC.str2term "Length [1, 1, 1]"; +val t = TermC.parse_test @{context} "Length [1, 1, 1]"; val t = eval_prog_expr ctxt prog_expr t; case t of Const (\<^const_name>\numeral\, _) $ (Const (\<^const_name>\num.Bit1\, _) $ Const (\<^const_name>\num.One\, _)) => () diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/ProgLang/prog_expr.sml --- a/test/Tools/isac/ProgLang/prog_expr.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/ProgLang/prog_expr.sml Sun Oct 09 07:44:22 2022 +0200 @@ -58,7 +58,7 @@ "-------- fun eval_is_even ---------------------------------------------------------------------"; "-------- fun eval_is_even ---------------------------------------------------------------------"; "-------- fun eval_is_even ---------------------------------------------------------------------"; -val t = TermC.str2term "2 is_even"; +val t = TermC.parse_test @{context} "2 is_even"; eval_is_even "aaa" "Prog_Expr.is_even" t "ccc"; "~~~~~ fun eval_is_even , args:"; val ((thmid:string), "Prog_Expr.is_even", (t as (Const _ $ arg)), _) = ("aaa", "Prog_Expr.is_even", t, "ccc"); @@ -71,14 +71,14 @@ if UnparseC.term t' = "(2 is_even) = True" then () else error "(2 is_even) = True CHANGED"; -val t = TermC.str2term "3 is_even"; +val t = TermC.parse_test @{context} "3 is_even"; case eval_is_even "aaa" "Prog_Expr.is_even" t "ccc" of SOME (str, t') => if str = "aaa_" andalso UnparseC.term t' = "(3 is_even) = False" then () else error "eval_is_even (3 is_even) CHANGED 1" | NONE => error "eval_is_even (3 is_even) CHANGED 2"; -val t = TermC.str2term "a ::real"; +val t = TermC.parse_test @{context} "a ::real"; val NONE = eval_is_even "aaa" "Prog_Expr.is_even" t "ccc"; case eval_is_even "aaa" "Prog_Expr.is_even" t "ccc" of @@ -95,27 +95,27 @@ SOME (Const (\<^const_name>\True\, _), []) => () | _ => error "2 is_num CHANGED"; -val t = TermC.str2term "2 * x is_num"; +val t = TermC.parse_test @{context} "2 * x is_num"; val SOME (str, t') = eval_is_num "" "Prog_Expr.is_num" t (@{theory "Isac_Knowledge"}); if UnparseC.term t' = "(2 * x is_num) = False" then () else error "(2 * x is_num) = False CHANGED"; -val t = TermC.str2term "- 2 is_num"; +val t = TermC.parse_test @{context} "- 2 is_num"; val SOME (str, t') = eval_is_num "" "Prog_Expr.is_num" t (@{theory "Isac_Knowledge"}); if UnparseC.term t' = "(- 2 is_num) = True" then () else error "(- 2 is_num) = False CHANGED"; -val t = TermC.str2term "- 1 is_num"; +val t = TermC.parse_test @{context} "- 1 is_num"; val SOME (str, t') = eval_is_num "" "Prog_Expr.is_num" t (@{theory "Isac_Knowledge"}); if UnparseC.term t' = "(- 1 is_num) = True" then () else error "(- 1 is_num) = False CHANGED"; -val t = TermC.str2term "0 is_num"; +val t = TermC.parse_test @{context} "0 is_num"; val SOME (str, t') = eval_is_num "" "Prog_Expr.is_num" t (@{theory "Isac_Knowledge"}); if UnparseC.term t' = "(0 is_num) = True" then () else error "(0 is_num) = False CHANGED"; -val t = TermC.str2term "AA is_num"; +val t = TermC.parse_test @{context} "AA is_num"; val SOME (str, t') = eval_is_num "" "Prog_Expr.is_num" t (@{theory "Isac_Knowledge"}); if UnparseC.term t' = "(AA is_num) = False" then () else error "(0 is_num) = False CHANGED"; @@ -204,20 +204,20 @@ val thy = @{theory} val ctxt = (ThyC.id_to_ctxt "Isac_Knowledge") -val t = TermC.str2term "x = 0"; +val t = TermC.parse_test @{context} "x = 0"; val NONE(*= indetermined*) = eval_equal "equal_" \<^const_name>\HOL.eq\ t ctxt; -val t = TermC.str2term "(x + 1) = (x + 1)"; +val t = TermC.parse_test @{context} "(x + 1) = (x + 1)"; val (Const _(*op0,t0*) $ t1 $ t2 ) = t val SOME ("equal_(x + 1)_(x + 1)", t') = eval_equal "equal_" \<^const_name>\HOL.eq\ t ctxt; if UnparseC.term t' = "(x + 1 = x + 1) = True" then () else error "(x + 1) = (x + 1) CHANGED"; -val t as Const _ $ v $ c = TermC.str2term "1 = 0"; +val t as Const _ $ v $ c = TermC.parse_test @{context} "1 = 0"; val false = variable_constant_pair (v, c); val SOME ("equal_(1)_(0)", t') = eval_equal "equal_" \<^const_name>\HOL.eq\ t ctxt; if UnparseC.term t' = "(1 = 0) = False" then () else error "1 = 0 CHANGED"; -val t = TermC.str2term "0 = 0"; +val t = TermC.parse_test @{context} "0 = 0"; val SOME ("equal_(0)_(0)", t') = eval_equal "equal_" \<^const_name>\HOL.eq\ t ctxt; if UnparseC.term t' = "(0 = 0) = True" then () else error "0 = 0 CHANGED"; @@ -228,7 +228,7 @@ val t = @{term "x::real"}; if occurs_in t t then "OK" else error "occurs_in x x -> f ..changed"; -val t = TermC.str2term "x occurs_in x"; +val t = TermC.parse_test @{context} "x occurs_in x"; val SOME (str, t') = eval_occurs_in 0 "Prog_Expr.occurs_in" t 0; if UnparseC.term t' = "x occurs_in x = True" then () else error "x occurs_in x = True ..changed"; @@ -337,7 +337,7 @@ "---------fun eval_argument_of -----------------------------------------------------------------"; "---------fun eval_argument_of -----------------------------------------------------------------"; "---------fun eval_argument_of -----------------------------------------------------------------"; -val t = TermC.str2term "argument_in (M_b x)"; +val t = TermC.parse_test @{context} "argument_in (M_b x)"; val SOME (str, t') = eval_argument_in "0" "Prog_Expr.argument_in" t 0; if UnparseC.term t' = "(argument_in M_b x) = x" then () else error "atools.sml:(argument_in M_b x) = x ???"; @@ -450,10 +450,10 @@ "-------- fun matchsub -------------------------------------------------------------------------"; "-------- fun matchsub -------------------------------------------------------------------------"; "-------- fun matchsub -------------------------------------------------------------------------"; -if matchsub thy (TermC.str2term "(a + (b + c))") (TermC.str2term "?x + (?y + ?z)") +if matchsub thy (TermC.parse_test @{context} "(a + (b + c))") (TermC.parse_patt_test @{theory} "?x + (?y + ?z)") then () else error "tools.sml matchsub a + (b + c)"; -if matchsub thy (TermC.str2term "(a + (b + c)) + d") (TermC.str2term "?x + (?y + ?z)") +if matchsub thy (TermC.parse_test @{context} "(a + (b + c)) + d") (TermC.parse_patt_test @{theory} "?x + (?y + ?z)") then () else error "tools.sml matchsub (a + (b + c)) + d"; @@ -465,9 +465,9 @@ | _ => error "TermC.UniversalList changed 1"; case or2list @{term False} of Const (\<^const_name>\Nil\, _) => () | _ => error "TermC.UniversalList changed 2"; -val t = (TermC.str2term "x=3"); +val t = (TermC.parse_test @{context} "x=3"); if UnparseC.term (or2list t) = "[x = 3]" then () else error "or2list changed"; -val t = (TermC.str2term "x=3 | x=-3 | x=0"); +val t = (TermC.parse_test @{context} "x=3 | x=-3 | x=0"); if UnparseC.term (or2list t) = "[x = 3, x = - 3, x = 0]" then () else error "HOL.eq ? HOL.disj ? changed"; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Specify/m-match.sml --- a/test/Tools/isac/Specify/m-match.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Specify/m-match.sml Sun Oct 09 07:44:22 2022 +0200 @@ -60,7 +60,7 @@ Free (dI',_) $ (Const (\<^const_name>\Pair\,_) $ pI' $ mI')) $ ags' = (*...copied from LItool.tac_from_prog*) - TermC.str2term ( + TermC.parse_test @{context} ( "SubProblem (EqSystemX, [LINEAR, system], [no_met]) " ^ " [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L \ 2 / 2]," ^ " REAL_LIST [c, c_2]]"); @@ -85,7 +85,7 @@ Free (dI',_) $ (Const (\<^const_name>\Pair\,_) $ pI' $ mI')) $ ags' = (*...copied from LItool.tac_from_prog*) - TermC.str2term ( + TermC.parse_test @{context} ( "SubProblem (EqSystemX, [LINEAR, system], [no_met]) " ^ " [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L \ 2 / 2]," ^ " REAL_LIST [c, c_2], BOOL_LIST ss''']"); @@ -111,7 +111,7 @@ Free (dI',_) $ (Const (\<^const_name>\Pair\,_) $ pI' $ mI')) $ ags' = (*...copied from LItool.tac_from_prog*) - TermC.str2term ( + TermC.parse_test @{context} ( "SubProblem (EqSystemX, [LINEAR, system], [no_met]) " ^ " [REAL_LIST [c, c_2]]"); val ags = isalist2list ags'; @@ -151,7 +151,7 @@ Free (dI',_) $ (Const (\<^const_name>\Pair\,_) $ pI' $ mI')) $ ags' = (*...copied from LItool.tac_from_prog*) - TermC.str2term ( + TermC.parse_test @{context} ( "SubProblem (EqSystemX, [LINEAR, system], [no_met]) " ^ " [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L \ 2 / 2]," ^ " REAL_LIST [c, c_2]]"); @@ -176,7 +176,7 @@ Free (dI',_) $ (Const (\<^const_name>\Pair\,_) $ pI' $ mI')) $ ags' = (*...copied from LItool.tac_from_prog*) - TermC.str2term ( + TermC.parse_test @{context} ( "SubProblem (EqSystemX, [LINEAR, system], [no_met]) " ^ " [BOOL_LIST [c_2 = 0, L * c + c_2 = q_0 * L \ 2 / 2]," ^ " REAL_LIST [c, c_2], BOOL_LIST ss''']"); @@ -202,7 +202,7 @@ Free (dI',_) $ (Const (\<^const_name>\Pair\,_) $ pI' $ mI')) $ ags' = (*...copied from LItool.tac_from_prog*) - TermC.str2term ( + TermC.parse_test @{context} ( "SubProblem (EqSystemX, [LINEAR, system], [no_met]) " ^ " [REAL_LIST [c, c_2]]"); val ags = isalist2list ags'; @@ -247,7 +247,7 @@ Free (dI',_) $ (Const (\<^const_name>\Pair\,_) $ pI' $ mI')) $ ags' = (*...copied from LItool.tac_from_prog*) - TermC.str2term ( + TermC.parse_test @{context} ( "SubProblem (TestX,[univariate,equation,test]," ^ " [no_met]) [BOOL (x+1=2), REAL x]"); val AGS = isalist2list ags'; @@ -265,7 +265,7 @@ Free (dI',_) $ (Const (\<^const_name>\Pair\,_) $ pI' $ mI')) $ ags' = (*...copied from LItool.tac_from_prog*) - TermC.str2term ( + TermC.parse_test @{context} ( "SubProblem (TestX,[univariate,equation,test]," ^ " [no_met]) [BOOL (x+1=2), REAL x]"); val AGS = isalist2list ags'; diff -r 90ea835c07b3 -r f92963a33fe3 test/Tools/isac/Specify/o-model.sml --- a/test/Tools/isac/Specify/o-model.sml Sun Oct 09 06:53:03 2022 +0200 +++ b/test/Tools/isac/Specify/o-model.sml Sun Oct 09 07:44:22 2022 +0200 @@ -257,7 +257,7 @@ val pbt = [("#Given", (@{term "equality"}, @{term "e_e :: bool"})), ("#Given", (@{term "solveFor"}, @{term "v_v :: real"} ))]; (*the model specific for an example*) -val oris = [([1], "#Given", @{term "equality"} , [TermC.str2term "x+1= 2"]), +val oris = [([1], "#Given", @{term "equality"} , [TermC.parse_test @{context} "x+1= 2"]), ([1], "#Given", @{term "solveFor"} , [@{term "x :: real"} ])]; val cy = [("#Find", (@{term "solutions"}, @{term "v_v'i' :: bool list"}))]; (*...all must be true*) @@ -274,7 +274,7 @@ val pbt = [("#Given", (@{term "equalities"}, @{term "e_s :: bool list"})), ("#Given", (@{term "solveForVars v_s"}, @{term "v_s :: bool list"} ))]; (*the model specific for an example*) -val oris = [([1], "#Given", @{term "equalities"} ,[TermC.str2term "[x_1+1=2,x_2=0]"]), +val oris = [([1], "#Given", @{term "equalities"} ,[TermC.parse_test @{context} "[x_1+1=2,x_2=0]"]), ([1], "#Given", @{term "solveForVars"} , [@{term "[x_1,x_2]::real list"}])]; val cy = [("#Find", (@{term "solution"}, @{term "ss''' :: bool list"})) (*could be more than 1*)];