akargl@42176: (* Title: tests on inform.sml akargl@42176: Author: Walther Neuper 060225, neuper@37906: (c) due to copyright terms neuper@37906: neuper@37906: use"../smltest/ME/inform.sml"; neuper@37906: use"inform.sml"; neuper@37906: *) neuper@37906: neuper@37906: "-----------------------------------------------------------------"; neuper@37906: "table of contents -----------------------------------------------"; neuper@37906: "-----------------------------------------------------------------"; neuper@37906: "appendForm with miniscript with mini-subpbl:"; neuper@37906: "--------- appendFormula: on Res + equ_nrls ----------------------"; neuper@37906: "--------- appendFormula: on Frm + equ_nrls ----------------------"; neuper@37906: "--------- appendFormula: on Res + NO deriv ----------------------"; neuper@37906: "--------- appendFormula: on Res + late deriv --------------------"; neuper@37906: "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--"; neuper@37906: "replaceForm with miniscript with mini-subpbl:"; neuper@37906: "--------- replaceFormula: on Res + = ----------------------------"; neuper@37906: "--------- replaceFormula: on Res + = 1st Nd ---------------------"; neuper@37906: "--------- replaceFormula: on Frm + = 1st Nd ---------------------"; neuper@37906: "--------- replaceFormula: cut calculation -----------------------"; neuper@37906: "--------- replaceFormula: cut calculation -----------------------"; neuper@37906: (* 040307 copied from informtest.sml ... old versions neuper@37906: "--------- maximum-example, UC: Modeling / modifyCalcHead --------";*) neuper@37906: "--------- syntax error ------------------------------------------"; neuper@37906: "CAS-command:"; neuper@37906: "--------- CAS-command on ([],Pbl) -------------------------------"; neuper@37906: "--------- CAS-command on ([],Pbl) FE-interface ------------------"; neuper@37906: "--------- inform [rational,simplification] ----------------------"; neuper@37906: "--------- Take as 1st tac, start with (CAS input) ---------"; neuper@37906: "--------- Take as 1st tac, start from exp -----------------------"; neuper@37906: "--------- init_form, start with (CAS input) ---------------"; neuper@42423: "--------- build fun check_err_patt ------------------------------"; neuper@42426: "--------- build fun check_err_patt ?bdv -------------------------"; neuper@42428: "--------- build fun check_error_patterns ------------------------"; neuper@42428: "--------- embed fun check_error_patterns ------------------------"; neuper@42430: "--------- embed fun find_fillpatterns ---------------------------"; neuper@42432: "--------- embed fun get_fillform --------------------------------"; neuper@37906: "-----------------------------------------------------------------"; neuper@37906: "-----------------------------------------------------------------"; neuper@37906: "-----------------------------------------------------------------"; neuper@37906: neuper@37906: neuper@37906: neuper@37906: neuper@37906: neuper@37906: neuper@37906: "--------- appendFormula: on Res + equ_nrls ----------------------"; neuper@37906: "--------- appendFormula: on Res + equ_nrls ----------------------"; neuper@37906: "--------- appendFormula: on Res + equ_nrls ----------------------"; akargl@42176: neuper@37906: val Script sc = (#scr o get_met) ["Test","squ-equ-test-subpbl1"]; neuper@37906: (writeln o term2str) sc; neuper@37906: val Script sc = (#scr o get_met) ["Test","solve_linear"]; neuper@37906: (writeln o term2str) sc; neuper@37906: neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*) neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*); neuper@37906: neuper@37906: appendFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1); neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; akargl@42176: neuper@37906: writeln str; akargl@42209: (*============ inhibit exn AK110726 ============================================== akargl@42176: (* 2nd string should be the same as 1st one *) akargl@42176: ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. 1 + x + -1 * 2 = 0\n2.3. 1 + (x + -1 * 2) = 0\n2.4. 1 + (x + -2) = 0\n2.5. 1 + (x + -2 * 1) = 0\n2.6. 1 + x + -2 * 1 = 0\n"; akargl@42176: ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n"; neuper@37906: if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n" then () akargl@42209: else error "inform.sml: diff.behav.appendFormula: on Res + equ 1"; akargl@42209: ============ inhibit exn AK110726 ==============================================*) neuper@37906: neuper@37906: moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*) neuper@37906: moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*) neuper@37906: neuper@37906: (*the seven steps of detailed derivation*) neuper@37906: moveDown 1 ([1 ],Res); refFormula 1 ([2,1],Frm); neuper@37906: moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res); neuper@37906: moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res); neuper@37906: moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res); neuper@37906: moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res); neuper@37906: moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res); neuper@37906: moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res); neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: if "-2 * 1 + (1 + x) = 0" = term2str (fst (get_obj g_result pt [2,6])) then() neuper@38031: else error "inform.sml: diff.behav.appendFormula: on Res + equ 2"; neuper@37906: neuper@37906: fetchProposedTactic 1; (*takes Iterator 1 _1_*) akargl@42209: akargl@42176: (*============ inhibit exn AK110725 ============================================== akargl@42176: (* ERROR: exception Bind raised *) neuper@37906: val (_,(tac,_,_)::_) = get_calc 1; neuper@37906: if tac = Rewrite_Set "Test_simplify" then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: on Res + equ 3"; akargl@42176: ============ inhibit exn AK110725 ==============================================*) akargl@42209: neuper@37906: autoCalculate 1 CompleteCalc; neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: on Res + equ 4"; neuper@37906: (* autoCalculate 1 CompleteCalc; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: (writeln o istates2str) (get_obj g_loc pt [ ]); neuper@37906: (writeln o istates2str) (get_obj g_loc pt [1]); neuper@37906: (writeln o istates2str) (get_obj g_loc pt [2]); neuper@37906: (writeln o istates2str) (get_obj g_loc pt [3]); neuper@37906: (writeln o istates2str) (get_obj g_loc pt [3,1]); neuper@37906: (writeln o istates2str) (get_obj g_loc pt [3,2]); neuper@37906: (writeln o istates2str) (get_obj g_loc pt [4]); neuper@37906: neuper@37906: *) neuper@37906: "----------------------------------------------------------"; akargl@42176: akargl@42176: val fod = make_deriv (@{theory "Isac"}) Atools_erls neuper@37906: ((#rules o rep_rls) Test_simplify) akargl@42176: (sqrt_right false (@{theory "Pure"})) NONE neuper@37906: (str2term "x + 1 + -1 * 2 = 0"); neuper@37906: (writeln o trtas2str) fod; neuper@37906: akargl@42176: val ifod = make_deriv (@{theory "Isac"}) Atools_erls neuper@37906: ((#rules o rep_rls) Test_simplify) akargl@42176: (sqrt_right false (@{theory "Pure"})) NONE neuper@37906: (str2term "-2 * 1 + (1 + x) = 0"); neuper@37906: (writeln o trtas2str) ifod; akargl@42176: fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2; neuper@37906: val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod); neuper@37906: val der = fod' @ (map rev_deriv' rifod'); neuper@37906: (writeln o trtas2str) der; neuper@37906: "----------------------------------------------------------"; neuper@37906: neuper@37906: neuper@37906: "--------- appendFormula: on Frm + equ_nrls ----------------------"; neuper@37906: "--------- appendFormula: on Frm + equ_nrls ----------------------"; neuper@37906: "--------- appendFormula: on Frm + equ_nrls ----------------------"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*); neuper@37906: appendFormula 1 "2+ -1 + x = 2"; refFormula 1 (get_pos 1 1); neuper@37906: neuper@37906: moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*); neuper@37906: neuper@37906: moveDown 1 ([1 ],Frm); refFormula 1 ([1,1],Frm); neuper@37906: moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res); neuper@37906: moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res); neuper@37906: moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res); neuper@37906: moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res); neuper@37906: moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res); neuper@37906: moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res); neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: if "2 + -1 + x = 2" = term2str (fst (get_obj g_result pt [1,6])) then() neuper@38031: else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1"; neuper@37906: neuper@37906: fetchProposedTactic 1; (*takes Iterator 1 _1_*) neuper@37906: val (_,(tac,_,_)::_) = get_calc 1; neuper@37906: if tac = Rewrite_Set "norm_equation" then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: on Frm + equ 2"; neuper@37906: autoCalculate 1 CompleteCalc; neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3"; neuper@37906: neuper@37906: neuper@37906: "--------- appendFormula: on Res + NO deriv ----------------------"; neuper@37906: "--------- appendFormula: on Res + NO deriv ----------------------"; neuper@37906: "--------- appendFormula: on Res + NO deriv ----------------------"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*) neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*); neuper@37906: neuper@37906: appendFormula 1 "x = 2"; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; neuper@37906: writeln str; neuper@37906: if str = ". ----- pblobj -----\n1. x + 1 = 2\n" andalso p = ([1], Res) neuper@37906: then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: Res + NOder 1"; neuper@37906: neuper@37906: fetchProposedTactic 1; neuper@37906: val (_,(tac,_,_)::_) = get_calc 1; neuper@37906: if tac = Rewrite_Set "Test_simplify" then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: Res + NOder 2"; neuper@37906: autoCalculate 1 CompleteCalc; neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3"; neuper@37906: neuper@37906: neuper@37906: "--------- appendFormula: on Res + late deriv --------------------"; neuper@37906: "--------- appendFormula: on Res + late deriv --------------------"; neuper@37906: "--------- appendFormula: on Res + late deriv --------------------"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*) neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*); neuper@37906: neuper@37906: appendFormula 1 "x = 1"; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; neuper@37906: writeln str; neuper@37906: if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n3. ----- pblobj -----\n3.1. -1 + x = 0\n3.2. x = 0 + -1 * -1\n3.2.1. x = 0 + -1 * -1\n3.2.2. x = 0 + 1\n" andalso p = ([3,2], Res) neuper@37906: then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*) neuper@38031: else error "inform.sml: diff.behav.appendFormula: Res + late d 1"; akargl@42176: neuper@37906: fetchProposedTactic 1; neuper@37906: val (_,(tac,_,_)::_) = get_calc 1; neuper@37906: if tac = Check_Postcond ["linear", "univariate", "equation", "test"] then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: Res + late d 2"; neuper@37906: autoCalculate 1 CompleteCalc; neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: if "[x = 1]" = term2str (fst (get_obj g_result pt [])) then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: Res + late d 3"; neuper@37906: neuper@37906: neuper@37906: "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--"; neuper@37906: "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--"; neuper@37906: "--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*) neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*); neuper@37906: appendFormula 1 "[x = 3 + -2*1]"; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; neuper@37906: writeln str; neuper@37906: if str=". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n3. ----- pblobj -----\n3.1. -1 + x = 0\n3.2. x = 0 + -1 * -1\n4. [x = 1]\n4.1. [x = 1]\n4.2. [x = -2 + 3]\n4.3. [x = 3 + -2]\n" then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: Res + latEE 1"; neuper@37906: autoCalculate 1 CompleteCalc; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: if "[x = 3 + -2 * 1]" = term2str (fst (get_obj g_result pt [])) then () neuper@37906: (* ~~~~~~~~~~ simplify as last step in any script ?!*) neuper@38031: else error "inform.sml: diff.behav.appendFormula: Res + latEE 2"; neuper@37906: neuper@37906: neuper@37906: neuper@37906: "--------- replaceFormula: on Res + = ----------------------------"; neuper@37906: "--------- replaceFormula: on Res + = ----------------------------"; neuper@37906: "--------- replaceFormula: on Res + = ----------------------------"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*) neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*); neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*-1 + x*); neuper@37906: neuper@37906: replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1); neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; neuper@37906: writeln str; akargl@42176: akargl@42176: (*============ inhibit exn AK110725 ============================================== akargl@42176: (* 2nd string should be the same as 1st one *) akargl@42176: ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. 1 + x + -1 * 2 = 0\n2.3. 1 + (x + -1 * 2) = 0\n2.4. 1 + (x + -2) = 0\n2.5. 1 + (x + -2 * 1) = 0\n2.6. 1 + x + -2 * 1 = 0\n"; akargl@42176: ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n"; akargl@42176: if str = ". ----- pblobj -----\n1. x + 1 = 2\n2. x + 1 + -1 * 2 = 0\n2.1. x + 1 + -1 * 2 = 0\n2.2. -1 * 2 + (x + 1) = 0\n2.3. -1 * 2 + (1 + x) = 0\n2.4. 1 + (-1 * 2 + x) = 0\n2.5. 1 + (-2 + x) = 0\n2.6. 1 + (-2 * 1 + x) = 0\n" then() neuper@38031: else error "inform.sml: diff.behav.replaceFormula: on Res += 1"; akargl@42176: ============ inhibit exn AK110725 ==============================================*) akargl@42176: neuper@37906: autoCalculate 1 CompleteCalc; akargl@42176: val ((pt,pos as (p,_)),_) = get_calc 1; akargl@42176: if pos = ([],Res) andalso "[x = 1]" = (term2str o fst) (get_obj g_result pt p) then() neuper@38031: else error "inform.sml: diff.behav.replaceFormula: on Res + = 2"; neuper@37906: neuper@37906: neuper@37906: "--------- replaceFormula: on Res + = 1st Nd ---------------------"; neuper@37906: "--------- replaceFormula: on Res + = 1st Nd ---------------------"; neuper@37906: "--------- replaceFormula: on Res + = 1st Nd ---------------------"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*) neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*); neuper@37906: neuper@37906: replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1); neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; neuper@37906: writeln str; akargl@42176: if str= ". ----- pblobj -----\n1. x + 1 = 2\n1.1. x + 1 = 2\n1.2. 1 + x = 2\n1.3. 1 + x = -2 + 4\n1.4. x + 1 = -2 + 4\n" then () neuper@38031: else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1"; neuper@37906: autoCalculate 1 CompleteCalc; akargl@42176: val ((pt,pos as (p,_)),_) = get_calc 1; akargl@42176: if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then() neuper@38031: else error "inform.sml: diff.behav.replaceFormula: on Res + = 2"; neuper@37906: neuper@37906: neuper@37906: "--------- replaceFormula: on Frm + = 1st Nd ---------------------"; neuper@37906: "--------- replaceFormula: on Frm + = 1st Nd ---------------------"; neuper@37906: "--------- replaceFormula: on Frm + = 1st Nd ---------------------"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*) neuper@37906: neuper@37906: replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1); neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; neuper@37906: writeln str; akargl@42176: if str= ". ----- pblobj -----\n1. x + 1 = 2\n1.1. x + 1 = 2\n1.2. 1 + x = 2\n1.3. 1 + x = -2 + 4\n1.4. x + 1 = -2 + 4\n" then () neuper@38031: else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1"; neuper@37906: autoCalculate 1 CompleteCalc; akargl@42176: val ((pt,pos as (p,_)),_) = get_calc 1; akargl@42176: if pos = ([],Res) andalso "[x = 1]" = (term2str o fst)(get_obj g_result pt p) then() neuper@38031: else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2"; neuper@37906: neuper@37906: neuper@37906: "--------- replaceFormula: cut calculation -----------------------"; neuper@37906: "--------- replaceFormula: cut calculation -----------------------"; neuper@37906: "--------- replaceFormula: cut calculation -----------------------"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalc; neuper@37906: moveActiveRoot 1; moveActiveDown 1; neuper@37906: if get_pos 1 1 = ([1], Frm) then () neuper@38031: else error "inform.sml: diff.behav. cut calculation 1"; neuper@37906: neuper@37906: replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1); neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; neuper@37906: writeln str; neuper@37906: if p = ([1], Res) then () neuper@38031: else error "inform.sml: diff.behav. cut calculation 2"; neuper@37906: neuper@37906: neuper@37906: (* 040307 copied from informtest.sml; ... old version neuper@37906: "---------------- maximum-example, UC: Modeling / modifyCalcHead -"; neuper@37906: "---------------- maximum-example, UC: Modeling / modifyCalcHead -"; neuper@37906: "---------------- maximum-example, UC: Modeling / modifyCalcHead -"; neuper@37906: neuper@37906: val p = ([],Pbl); neuper@37906: val elems = ["fixedValues [r=Arbfix]","maximum A","valuesFor [a,b]", neuper@37906: "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]", neuper@37906: "relations [A=a*b, (a/2)^^^2 + (b/2)^^^2 = r^^^2]", neuper@37906: "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos alpha]", neuper@37906: (*^^^ these are the elements for the root-problem (in variants)*) neuper@37906: (*vvv these are elements required for subproblems*) neuper@37906: "boundVariable a","boundVariable b","boundVariable alpha", neuper@37906: "interval {x::real. 0 <= x & x <= 2*r}", neuper@37906: "interval {x::real. 0 <= x & x <= 2*r}", neuper@37906: "interval {x::real. 0 <= x & x <= pi}", neuper@37906: "errorBound (eps=(0::real))"] neuper@37906: (*specifying is not interesting for this example*) neuper@38058: val spec = ("DiffApp", ["maximum_of","function"], neuper@37906: ["DiffApp","max_by_calculus"]); neuper@37906: (*the empty model with descriptions for user-guidance by Model_Problem*) neuper@37906: val empty_model = [Given ["fixedValues []"], neuper@37906: Find ["maximum", "valuesFor"], neuper@37906: Relate ["relations []"]]; neuper@37906: neuper@37906: neuper@37906: (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*) neuper@37906: val (p,_,f,nxt,_,pt) = CalcTreeTEST [(elems, spec)]; neuper@37906: (*val nxt = ("Model_Problem", ...*) neuper@37924: val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; neuper@37906: neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p c pt; neuper@37906: (*nxt = Add_Given "fixedValues [r = Arbfix]"*) neuper@37924: val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; neuper@37906: (*[ neuper@37906: (0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])), neuper@37906: (0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])), neuper@37906: (0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])), neuper@37906: (0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*) neuper@37906: neuper@37906: (*the empty CalcHead is checked w.r.t the model and re-established as such*) neuper@37906: val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, e_spec); neuper@37924: val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; neuper@38031: if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"e_domID\", [\"e_pblID\"], [\"e_metID\"]) )" then () else error "informtest.sml: diff.behav. max 1"; neuper@37906: neuper@37906: (*there is one input to the model (could be more)*) neuper@37906: val (b,pt,ocalhd) = neuper@37906: input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"], neuper@37906: Find ["maximum", "valuesFor"], neuper@37906: Relate ["relations"]], Pbl, e_spec); neuper@37924: val pbl = get_obj g_pbl pt (fst p); (writeln o (itms2str_ ctxt)) pbl; neuper@37906: if ocalhd2str ocalhd = "(Pbl, ??.empty, [\n(1 ,[1,2,3] ,true ,#Given ,Cor fixedValues [r = Arbfix] ,(fix_, [[r = Arbfix]])),\n(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),\n(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),\n(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))], [], \n(\"e_domID\", [\"e_pblID\"], [\"e_metID\"]) )" then () neuper@38031: else error "informtest.sml: diff.behav. max 2"; neuper@37906: neuper@37906: (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME neuper@37906: val (b,pt''''',ocalhd) = neuper@37906: input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"], neuper@37906: Find ["maximum A", "valuesFor [a,b]"], neuper@37906: Relate ["relations [A=a*b, a/2=r*sin alpha, \ neuper@37906: \b/2=r*cos alpha]"]], Pbl, e_spec); neuper@37924: val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl; neuper@37906: if ocalhd2str ocalhd = ------------^^^^^^^^^^ missing !!!*) neuper@37906: neuper@37906: (*this input is complete in variant 1 (variant 3 does not work yet)*) neuper@37906: val (b,pt''''',ocalhd) = neuper@37906: input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"], neuper@37906: Find ["maximum A", "valuesFor [a,b]"], neuper@37906: Relate ["relations [A=a*b, \ neuper@37906: \(a/2)^^^2 + (b/2)^^^2 = r^^^2]"]], neuper@37906: Pbl, e_spec); neuper@37924: val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (itms2str_ ctxt)) pbl; neuper@37906: neuper@37906: modifycalcheadOK2xml 111 (bool2str b) ocalhd; neuper@37906: *) neuper@37906: neuper@37906: "--------- syntax error ------------------------------------------"; neuper@37906: "--------- syntax error ------------------------------------------"; neuper@37906: "--------- syntax error ------------------------------------------"; neuper@37906: states:=[]; neuper@41970: CalcTree [(["equality (x+1=(2::real))", "solveFor x","solutions L"], neuper@41970: ("Test", ["sqroot-test","univariate","equation","test"], neuper@37906: ["Test","squ-equ-test-subpbl1"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*) neuper@37906: autoCalculate 1 (Step 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*); neuper@37906: neuper@37906: appendFormula 1 " x - "; (* syntax error in ' x - ' *) neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: val str = pr_ptree pr_short pt; neuper@37906: writeln str; neuper@37906: if str = ". ----- pblobj -----\n1. x + 1 = 2\n" then () neuper@38031: else error "inform.sml: diff.behav.appendFormula: syntax error"; neuper@37906: neuper@37906: neuper@37906: "--------- CAS-command on ([],Pbl) -------------------------------"; neuper@37906: "--------- CAS-command on ([],Pbl) -------------------------------"; neuper@37906: "--------- CAS-command on ([],Pbl) -------------------------------"; neuper@37906: val (p,_,f,nxt,_,pt) = neuper@37906: CalcTreeTEST [([], ("e_domID", ["e_pblID"], ["e_metID"]))]; neuper@37906: val ifo = "solve(x+1=2,x)"; neuper@37906: val (_,(_,c,(pt,p))) = inform ([],[],(pt,p)) "solve(x+1=2,x)"; neuper@37906: show_pt pt; neuper@37906: val nxt = ("Apply_Method",Apply_Method ["Test","squ-equ-test-subpbl1"]); neuper@37906: val (p,_,f,nxt,_,pt) = me nxt p [] pt; neuper@37906: if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then () neuper@38031: else error "inform.sml: diff.behav. CAScmd ([],Pbl)"; neuper@37906: neuper@37906: neuper@37906: "--------- CAS-command on ([],Pbl) FE-interface ------------------"; neuper@37906: "--------- CAS-command on ([],Pbl) FE-interface ------------------"; neuper@37906: "--------- CAS-command on ([],Pbl) FE-interface ------------------"; neuper@37906: states:=[]; neuper@37906: CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))]; neuper@37906: Iterator 1; neuper@37906: moveActiveRoot 1; neuper@37906: replaceFormula 1 "solve(x+1=2,x)"; neuper@37906: autoCalculate 1 CompleteCalc; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: show_pt pt; neuper@37906: if p = ([], Res) then () neuper@38031: else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface"; neuper@37906: neuper@37906: neuper@37906: "--------- inform [rational,simplification] ----------------------"; neuper@37906: "--------- inform [rational,simplification] ----------------------"; neuper@37906: "--------- inform [rational,simplification] ----------------------"; neuper@37906: states:=[]; neuper@38083: CalcTree [(["Term (4/x - 3/y - 1)", "normalform N"], neuper@38058: ("Rational",["rational","simplification"], neuper@37906: ["simplification","of_rationals"]))]; neuper@37906: Iterator 1; moveActiveRoot 1; neuper@37906: autoCalculate 1 CompleteCalcHead; neuper@37906: autoCalculate 1 (Step 1); neuper@37906: autoCalculate 1 (Step 1); neuper@37906: autoCalculate 1 (Step 1); neuper@37906: autoCalculate 1 (Step 1); neuper@37906: "--- input the next formula that _should_ be presented by mat-engine"; neuper@37906: appendFormula 1 "(4 * y + -3 * x) / (x * y) + -1"; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then () neuper@38031: else error ("inform.sml: [rational,simplification] 1"); neuper@37906: neuper@37906: "--- input the next formula that would be presented by mat-engine"; neuper@37906: (*autoCalculate 1 (Step 1);*) neuper@37906: appendFormula 1 "(4 * y + -3 * x + -1 * (x * y)) / (x * y)"; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: if p = ([5], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then () neuper@38031: else error ("inform.sml: [rational,simplification] 2"); neuper@37906: neuper@37906: "--- input the exact final result";(*TODO: Exception- LIST "last_elem" raised*) neuper@37906: appendFormula 1 "(-3 * x + 4 * y + -1 * x * y) / (x * y)"; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: if p = ([6], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then () neuper@38031: else error ("inform.sml: [rational,simplification] 3"); neuper@37906: show_pt pt; neuper@37906: neuper@37906: "--------- Take as 1st tac, start with (CAS input) ---------"; neuper@37906: "--------- Take as 1st tac, start with (CAS input) ---------"; neuper@37906: "--------- Take as 1st tac, start with (CAS input) ---------"; neuper@37906: val t = str2term "Diff (x^^^2 + x + 1, x)"; neuper@37906: case t of Const ("Diff.Diff", _) $ _ => () neuper@37906: | _ => raise neuper@37906: error "diff.sml behav.changed for CAS Diff (..., x)"; neuper@37906: atomty t; neuper@37906: "-----------------------------------------------------------------"; neuper@37906: (*1>*)states:=[]; neuper@37906: (*2>*)CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))]; neuper@37906: (*3>*)Iterator 1;moveActiveRoot 1; neuper@37906: "----- here the Headline has been finished"; neuper@37906: (*4>*)moveActiveFormula 1 ([],Pbl); neuper@37906: (*5>*)replaceFormula 1 "Diff (x^2 + x + 1, x)"; neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt []; neuper@37926: val NONE = env; neuper@37926: val (SOME istate, NONE) = loc; neuper@37906: print_depth 5; neuper@37906: writeln"-----------------------------------------------------------"; neuper@37906: spec; neuper@37924: writeln (itms2str_ ctxt probl); neuper@37924: writeln (itms2str_ ctxt meth); akargl@42209: akargl@42176: (*============ inhibit exn AK110725 ============================================== akargl@42209: (* ERROR: Argument: istate : istate * Proof.context Reason: akargl@42209: Can't unify istate to istate * Proof.context *) neuper@37906: writeln (istate2str istate); akargl@42176: ============ inhibit exn AK110725 ==============================================*) neuper@37906: neuper@37906: print_depth 3; neuper@37906: neuper@37906: refFormula 1 ([],Pbl) (*--> correct CalcHead*); neuper@37906: (*081016 NOT necessary (but leave it in Java):*) neuper@37906: (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead; neuper@37906: "----- here the CalcHead has been completed --- ONCE MORE ?????"; neuper@37906: neuper@37906: (***difference II***) neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: (*val p = ([], Pbl)*) neuper@37906: val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt []; neuper@37926: val NONE = env; neuper@37926: val (SOME istate, NONE) = loc; akargl@42176: (*============ inhibit exn AK110725 ============================================== akargl@42176: (* ERROR: Argument: istate : istate * Proof.context Reason: Can't unify istate to istate * Proof.context *) neuper@37906: print_depth 5; writeln (istate2str istate); print_depth 3; akargl@42176: ============ inhibit exn AK110725 ==============================================*) neuper@37906: (*ScrState ([], neuper@37926: [], NONE, neuper@37906: ??.empty, Sundef, false)*) neuper@37906: print_depth 5; spec; print_depth 3; neuper@38050: (*("Isac", neuper@37906: ["derivative_of", "function"], neuper@37906: ["diff", "differentiate_on_R"]) : spec*) neuper@37924: writeln (itms2str_ ctxt probl); neuper@37906: (*[ neuper@37906: (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])), neuper@37906: (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])), akargl@42176: (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*) neuper@37924: writeln (itms2str_ ctxt meth); neuper@37906: (*[ neuper@37906: (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])), neuper@37906: (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])), akargl@42176: (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*) neuper@37906: writeln"-----------------------------------------------------------"; neuper@37906: (*7>*)fetchProposedTactic 1 (*--> Apply_Method*); neuper@37906: (*WN081028 fixed helpless by inform returning ...(.,Met)*) neuper@37906: autoCalculate 1 CompleteCalc; neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: val Form res = (#1 o pt_extract) (pt, ([],Res)); neuper@37906: show_pt pt; neuper@37906: if p = ([], Res) andalso term2str res = "1 + 2 * x" then () neuper@38031: else error "diff.sml behav.changed for Diff (x^2 + x + 1, x)"; neuper@37906: neuper@37906: neuper@37906: "--------- Take as 1st tac, start from exp -----------------------"; neuper@37906: "--------- Take as 1st tac, start from exp -----------------------"; neuper@37906: "--------- Take as 1st tac, start from exp -----------------------"; neuper@37906: (*the following input is copied from BridgeLog Java <==> SML, neuper@37906: omitting unnecessary inputs*) neuper@37906: (*1>*)states:=[]; akargl@42176: (*2>*)CalcTree [(["functionTerm (x^2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac",["derivative_of","function"],["diff","differentiate_on_R"]))]; neuper@37906: (*3>*)Iterator 1; moveActiveRoot 1; neuper@37906: neuper@37906: (*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead; neuper@37906: (***difference II***) neuper@37906: val ((pt,_),_) = get_calc 1; neuper@37906: val PblObj {probl, meth, spec, fmz, env, loc, ...} = get_obj I pt []; neuper@37926: val NONE = env; neuper@37926: val (SOME istate, NONE) = loc; akargl@42176: (*============ inhibit exn AK110725 ============================================== akargl@42176: (* ERROR: Argument: istate : istate * Proof.context Reason: Can't unify istate to istate * Proof.context *) neuper@37906: print_depth 5; writeln (istate2str istate); print_depth 3; akargl@42176: ============ inhibit exn AK110725 ==============================================*) neuper@37906: (*ScrState ([], neuper@37926: [], NONE, neuper@37906: ??.empty, Sundef, false)*) neuper@37906: print_depth 5; spec; print_depth 3; neuper@38050: (*("Isac", neuper@37906: ["derivative_of", "function"], neuper@37906: ["diff", "differentiate_on_R"]) : spec*) neuper@37924: writeln (itms2str_ ctxt probl); neuper@37906: (*[ neuper@37906: (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])), neuper@37906: (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])), akargl@42176: (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*) neuper@37924: writeln (itms2str_ ctxt meth); neuper@37906: (*[ neuper@37906: (1 ,[1] ,true ,#Given ,Cor functionTerm (x ^^^ 2 + x + 1) ,(f_, [x ^^^ 2 + x + 1])), neuper@37906: (2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])), akargl@42176: (3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*) neuper@37906: writeln"-----------------------------------------------------------"; neuper@37906: (*7>*)fetchProposedTactic 1 (*--> Apply_Method*); neuper@37906: autoCalculate 1 (Step 1); neuper@37906: val ((pt,p),_) = get_calc 1; neuper@37906: val Form res = (#1 o pt_extract) (pt, p); neuper@37906: if term2str res = "d_d x (x ^^^ 2 + x + 1)" then () neuper@38031: else error "diff.sml Diff (x^2 + x + 1, x) from exp"; neuper@37906: neuper@37906: neuper@37906: "--------- init_form, start with (CAS input) ---------------"; neuper@37906: "--------- init_form, start with (CAS input) ---------------"; neuper@37906: "--------- init_form, start with (CAS input) ---------------"; neuper@37906: states:=[]; neuper@37906: CalcTree [([], ("e_domID", ["e_pblID"], ["e_metID"]))]; neuper@37906: (*[[from sml: > @@@@@begin@@@@@ neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: @@@@@end@@@@@*) neuper@37906: Iterator 1; neuper@37906: (*[[from sml: > @@@@@begin@@@@@ neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: 1 neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: @@@@@end@@@@@*) neuper@37906: moveActiveRoot 1; neuper@37906: (*[[from sml: > @@@@@begin@@@@@ neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Pbl neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: @@@@@end@@@@@*) neuper@37906: getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false; neuper@37906: (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Pbl neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: ________________________________________________ neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: @@@@@end@@@@@*) neuper@37906: refFormula 1 ([],Pbl); neuper@37906: (*[[from sml: > @@@@@begin@@@@@ STILL CORRECT neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Pbl neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Problem (e_domID, [e_pblID]) neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Pbl neuper@37906: [[from sml: neuper@37906: [[from sml: e_domID neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: e_pblID neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: e_metID neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: @@@@@end@@@@@*) neuper@37906: moveActiveFormula 1 ([],Pbl); neuper@37906: (*[[from sml: > @@@@@begin@@@@@ neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Pbl neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: @@@@@end@@@@@*) neuper@37906: replaceFormula 1 "Simplify (1+2)"; neuper@37906: (*[[from sml: > @@@@@begin@@@@@ neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Pbl neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Pbl neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: Met DIFFERENCE: Pbl neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: neuper@37906: [[from sml: @@@@@end@@@@@*) neuper@37906: getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(* DIFFERENCE: Pbl*); neuper@37906: (*@@@@@begin@@@@@ neuper@37906: 1 neuper@37906: neuper@37906: 1 neuper@37906: neuper@37906: neuper@37906: neuper@37906: neuper@37906: neuper@37906: Pbl neuper@37906: neuper@37906: neuper@37906: neuper@37906: Simplify (1 + 2) WORKS !!!!! neuper@37906: neuper@37906: neuper@37906: neuper@37906: neuper@37906: neuper@37906: @@@@@end@@@@@*) neuper@37906: getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false; neuper@37906: (*[[from sml: > @@@@@begin@@@@@ neuper@37906: [[from sml: 1 neuper@37906: [[from sml: neuper@37906: [[from sml: 1 neuper@37906: [[from sml: error in getFormulaeFromTo neuper@37906: [[from sml: neuper@37906: [[from sml: @@@@@end@@@@@*) neuper@37906: (*step into getFormulaeFromTo --- bug corrected...*) neuper@42423: neuper@42423: "--------- build fun check_err_patt ------------------------------"; neuper@42423: "--------- build fun check_err_patt ------------------------------"; neuper@42423: "--------- build fun check_err_patt ------------------------------"; neuper@42426: val subst = [(str2term "bdv", str2term "x")]: subst; neuper@42423: val rls = norm_Rational neuper@42423: val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c"; neuper@42423: val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4"); neuper@42423: val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "1 / 2"); neuper@42423: neuper@42426: val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*) neuper@42423: rew_sub thy 1 [] e_rew_ord e_rls false [] (Trueprop $ pat) res; neuper@42423: if rewritten then NONE else SOME "e_errpatID"; neuper@42423: neuper@42423: val norm_res = case rewrite_set_ (Isac()) false rls res' of neuper@42423: NONE => res' neuper@42423: | SOME (norm_res, _) => norm_res neuper@42423: neuper@42423: val norm_inf = case rewrite_set_ (Isac()) false rls inf of neuper@42423: NONE => inf neuper@42423: | SOME (norm_inf, _) => norm_inf; neuper@42423: neuper@42423: res' = inf; neuper@42423: norm_res = norm_inf; neuper@42423: neuper@42423: val pat = parse_patt @{theory} "(?a + ?b)/?a = ?b"; neuper@42423: val (res, inf) = (str2term "(2 + 3)/2", str2term "3"); neuper@42426: if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID" neuper@42423: then () else error "error patt example1 changed"; neuper@42423: neuper@42423: val pat = parse_patt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c"; neuper@42423: val (res, inf) = (str2term "(2 + 3)/(2 + 4)", str2term "3 / 4"); neuper@42426: if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID" neuper@42423: then () else error "error patt example2 changed"; neuper@42423: neuper@42423: val pat = parse_patt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c"; neuper@42423: val (res, inf) = (str2term "(2 + 3)/(3 + 4)", str2term "2 / 4"); neuper@42426: if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID" neuper@42423: then () else error "error patt example3 changed"; neuper@42423: neuper@42423: val inf = str2term "1 / 2"; neuper@42426: if check_err_patt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID" neuper@42423: then () else error "error patt example3 changed"; neuper@42423: neuper@42426: "--------- build fun check_err_patt ?bdv -------------------------"; neuper@42426: "--------- build fun check_err_patt ?bdv -------------------------"; neuper@42426: "--------- build fun check_err_patt ?bdv -------------------------"; neuper@42426: val subst = [(str2term "bdv", str2term "x")]: subst; neuper@42426: val t = str2term "d_d x (x ^^^ 2 + sin (x ^^^ 4))"; neuper@42426: val SOME (t, _) = rewrite_set_inst_ thy false subst norm_diff t; neuper@42426: if term2str t = "2 * x + cos (x ^^^ 4) * 4 * x ^^^ 3" then () neuper@42426: else error "build fun check_err_patt ?bdv changed 1"; neuper@42423: neuper@42426: val rls = norm_diff neuper@42426: val pat = parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)"; neuper@42426: val (res, inf) = (str2term "2 * x + d_d x (sin (x ^^^ 4))", str2term "2 * x + cos (4 * x ^^^ 3)"); neuper@42426: neuper@42426: val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern matches in res*) neuper@42426: rew_sub thy 1 subst e_rew_ord e_rls false [] (Trueprop $ pat) res; neuper@42426: if term2str res' = "2 * x + cos (d_d x (x ^^^ 4))" andalso rewritten then () neuper@42426: else error "build fun check_err_patt ?bdv changed 2"; neuper@42426: neuper@42426: val norm_res = case rewrite_set_inst_ (Isac()) false subst rls res' of neuper@42426: NONE => res' neuper@42426: | SOME (norm_res, _) => norm_res; neuper@42426: if term2str norm_res = "2 * x + cos (4 * x ^^^ 3)" then () neuper@42426: else error "build fun check_err_patt ?bdv changed 3"; neuper@42426: neuper@42426: val norm_inf = case rewrite_set_inst_ (Isac()) false subst rls inf of neuper@42426: NONE => inf neuper@42426: | SOME (norm_inf, _) => norm_inf; neuper@42426: if term2str norm_inf = "2 * x + cos (4 * x ^^^ 3)" then () neuper@42426: else error "build fun check_err_patt ?bdv changed 4"; neuper@42426: neuper@42426: res' = inf; neuper@42426: if norm_res = norm_inf then () neuper@42426: else error "build fun check_err_patt ?bdv changed 5"; neuper@42426: neuper@42426: if check_err_patt (res, inf) (subst: subst) ("errpatID": errpatID, pat) rls = SOME "errpatID" neuper@42426: then () else error "error patt example1 changed"; neuper@42426: neuper@42428: "--------- build fun check_error_patterns ------------------------"; neuper@42428: "--------- build fun check_error_patterns ------------------------"; neuper@42428: "--------- build fun check_error_patterns ------------------------"; neuper@42428: val (res, inf) = neuper@42428: (str2term "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))", neuper@42428: str2term "d_d x (x ^^^ 2) + cos (4 * x ^^^ 3)"); neuper@42428: val {errpats, nrls = rls, scr = Script prog, ...} = get_met ["diff", "differentiate_on_R"] neuper@42426: neuper@42428: val env = [(str2term "v_v", str2term "x")]; neuper@42428: val errpats = neuper@42428: [e_errpat, (*generalised for testing*) neuper@42428: ("chain-rule-diff-both", neuper@42428: [parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)", neuper@42428: parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)", neuper@42428: parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)", neuper@42428: parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u", neuper@42428: parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"], neuper@42428: [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain}, neuper@42428: @{thm diff_ln_chain}, @{thm diff_exp_chain}])]: errpat list; neuper@42428: neuper@42428: case check_error_patterns (res, inf) (prog, env) (errpats, rls) of SOME _ => () neuper@42428: | NONE => error "check_error_patterns broken"; neuper@42428: neuper@42428: neuper@42428: "--------- embed fun check_error_patterns ------------------------"; neuper@42428: "--------- embed fun check_error_patterns ------------------------"; neuper@42428: "--------- embed fun check_error_patterns ------------------------"; neuper@42428: states:=[]; neuper@42428: CalcTree neuper@42428: [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"], neuper@42428: ("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))]; neuper@42428: Iterator 1; neuper@42428: moveActiveRoot 1; neuper@42428: autoCalculate 1 CompleteCalcHead; neuper@42428: autoCalculate 1 (Step 1); neuper@42428: autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*) neuper@42428: (*autoCalculate 1 (Step 1);([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)*) neuper@42428: neuper@42428: "~~~~~ fun appendFormula, args:"; val (cI, (ifo:cterm')) = (1, "d_d x (x ^ 2) + cos (4 * x ^ 3)"); neuper@42428: val cs = get_calc cI neuper@42428: val pos as (_,p_) = get_pos cI 1; (*pos = ([1], Res)*) neuper@42428: val cs' = neuper@42428: case step pos cs of neuper@42428: ("ok", cs') => cs'; neuper@42428: neuper@42428: val (_, _, (pt, ([2], Res))) = cs'; neuper@42428: (*show_pt pt; neuper@42428: [(([], Frm), Diff (x ^^^ 2 + sin (x ^^^ 4), x)), neuper@42428: (([1], Frm), d_d x (x ^^^ 2 + sin (x ^^^ 4))), neuper@42428: (([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))), <<=== input follos: "...+ cos(4.x^3)" neuper@42428: (([2], Res), d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4))] *) neuper@42428: neuper@42428: "~~~~~ fun inform, args:"; val ((cs as (_, _, ptp as (pt, pos as (p, p_))): calcstate'), istr) = neuper@42428: (cs', (encode ifo)); neuper@42428: val SOME f_in = parse (assoc_thy "Isac") istr neuper@42428: val f_in = term_of f_in neuper@42428: val pos_pred = lev_back' pos neuper@42428: (* f_pred ---"step pos cs"---> f_succ in appendFormula neuper@42428: TODO.WN120517: one starting point for redesign of pos' *) neuper@42432: val (f_pred, f_succ) = (get_curr_formula (pt, pos_pred), get_curr_formula (pt, pos)); neuper@42428: neuper@42428: term2str f_pred = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"; neuper@42428: term2str f_succ = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x (x ^^^ 4)"; neuper@42428: neuper@42428: f_succ = f_in; (* = false*) neuper@42428: cas_input f_in; (* = NONE*) neuper@42428: val msg_calcstate' = compare_step ([], [], (pt, pos_pred)) f_in neuper@42428: val ("no derivation found", calcstate') = msg_calcstate'; neuper@42428: val pp = par_pblobj pt p neuper@42428: val {errpats, nrls, scr = Script prog, ...} = get_met (get_obj g_metID pt pp) neuper@42428: val ScrState (env, _, _, _, _, _) = get_istate pt pos; neuper@42428: case check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) of neuper@42428: SOME errpatID => ("error pattern #" ^ errpatID ^ "#", calcstate') neuper@42428: | NONE => msg_calcstate'; neuper@42428: neuper@42428: "~~~~~ from inform return val:"; val () = (); neuper@42428: case check_error_patterns (f_pred, f_in) (prog, env) (errpats, nrls) of neuper@42428: SOME errpatID => () neuper@42428: | NONE => error "check_error_patterns broken"; neuper@42428: neuper@42428: "--- final check:"; neuper@42428: case inform cs' (encode ifo) of neuper@42428: ("error pattern #chain-rule-diff-both#", calcstate') => () neuper@42428: | _ => error "inform with (positive) check_error_patterns broken" neuper@42428: neuper@42430: "--------- embed fun find_fillpatterns ---------------------------"; neuper@42430: "--------- embed fun find_fillpatterns ---------------------------"; neuper@42430: "--------- embed fun find_fillpatterns ---------------------------"; neuper@42430: states:=[]; neuper@42430: CalcTree neuper@42430: [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"], neuper@42430: ("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))]; neuper@42430: Iterator 1; neuper@42430: moveActiveRoot 1; neuper@42430: autoCalculate 1 CompleteCalcHead; neuper@42430: autoCalculate 1 (Step 1); neuper@42430: autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*) neuper@42430: appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)"; neuper@42430: (* error pattern #chain-rule-diff-both# *) neuper@42432: (*or neuper@42432: no derivation found *) neuper@42430: neuper@42430: "~~~~~ fun FindFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both"); neuper@42430: val ((pt, _), _) = get_calc cI neuper@42430: val pos = get_pos cI 1; neuper@42432: "~~~~~ fun find_fillpatterns, args:"; val ((pt, pos as (p, _)), errpatID) = ((pt, pos), errpatID); neuper@42432: val f_curr = get_curr_formula (pt, pos); (* = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"*) neuper@42430: val pp = par_pblobj pt p neuper@42430: val {errpats, scr = Script prog, ...} = get_met (get_obj g_metID pt pp) neuper@42430: val ScrState (env, _, _, _, _, _) = get_istate pt pos neuper@42430: val subst = get_bdv_subst prog env neuper@42430: val errpatthms = errpats neuper@42430: |> filter ((curry op = errpatID) o (#1: errpat -> errpatID)) neuper@42430: |> map (#3: errpat -> thm list) neuper@42430: |> flat; neuper@42430: neuper@42430: case map (get_fillpats subst f_curr errpatID) errpatthms |> flat of neuper@42432: ("fill-d_d-arg", tm) :: _ => if term2str tm = neuper@42432: "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" neuper@42432: then () else error "find_fillpatterns changed 1a" neuper@42432: | _ => error "find_fillpatterns changed 1b" neuper@42430: neuper@42430: "~~~~~ fun get_fillpats, args:"; val (subst, form, errpatID, thm) = neuper@42432: (subst, f_curr, errpatID, hd (*simulate beginning of "map"*) errpatthms); neuper@42430: val thmDeriv = Thm.get_name_hint thm neuper@42430: val (part, thyID) = thy_containing_thm thmDeriv neuper@42430: val theID = [part, thyID, "Theorems", thmID_of_derivation_name thmDeriv] neuper@42430: val Hthm {fillpats, ...} = get_the theID neuper@42430: val some = map (get_fillform subst form errpatID) fillpats; neuper@42430: neuper@42430: case some |> filter is_some |> map the of neuper@42432: ("fill-d_d-arg", tm) :: _ => if term2str tm = neuper@42432: "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" neuper@42432: then () else error "find_fillpatterns changed 2a" neuper@42432: | _ => error "find_fillpatterns changed 2b" neuper@42430: neuper@42432: "~~~~~ fun get_fillform, args:"; val (subst, form, errpatID, ((fillpatID, pat, erpaID): fillpat)) = neuper@42432: (subst, form, errpatID, hd (*simulate beginning of "map"*) fillpats); neuper@42432: val (form', _, _, rewritten) = neuper@42432: rew_sub (Isac()) 1 subst e_rew_ord e_rls false [] (Trueprop $ pat) form; neuper@42432: neuper@42432: if term2str form' = "d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" then () neuper@42432: else error "find_fillpatterns changed 3"; neuper@42432: neuper@42432: "~~~~~ to FindFillpatterns return val:"; val (fillpats) = neuper@42432: (map (get_fillpats subst f_curr errpatID) errpatthms |> flat) (*only from "hd errpatthms"*); neuper@42432: neuper@42432: val msg = "fill patterns " ^ ((map (apsnd term2str) fillpats) |> map pair2str_ |> strs2str_); neuper@42432: if msg = neuper@42432: "fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^ neuper@42432: " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1" ^ neuper@42432: "#fill-both-args#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^ neuper@42432: " =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" ^ neuper@42432: "#fill-d_d#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^ neuper@42432: " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1 x (x ^^^ 4)" ^ neuper@42432: "#fill-inner-deriv#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))" ^ neuper@42432: " =\nd_d x (x ^^^ 2) + cos (x ^^^ 4) * ?_dummy_1" ^ neuper@42432: "#fill-all#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) = d_d x (x ^^^ 2) + ?_dummy_1#" neuper@42432: then () else error "find_fillpatterns changed 4"; neuper@42432: neuper@42432: neuper@42432: "--------- embed fun get_fillform --------------------------------"; neuper@42432: "--------- embed fun get_fillform --------------------------------"; neuper@42432: "--------- embed fun get_fillform --------------------------------"; neuper@42432: states := []; neuper@42432: CalcTree neuper@42432: [(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"], neuper@42432: ("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))]; neuper@42432: Iterator 1; neuper@42432: moveActiveRoot 1; neuper@42432: autoCalculate 1 CompleteCalcHead; neuper@42432: autoCalculate 1 (Step 1); neuper@42432: autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*) neuper@42432: appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)"; neuper@42432: (* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"), neuper@42432: would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well. neuper@42432: results in error pattern #chain-rule-diff-both# neuper@42432: instead of no derivation found *) neuper@42432: FindFillpatterns 1 "chain-rule-diff-both"; neuper@42432: (* fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) = neuper@42432: d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *) neuper@42432: neuper@42432: "~~~~~ fun requestFillformula, args:"; val (cI, (errpatID, fillpatID)) = neuper@42432: (1, ("chain-rule-diff-both", "fill-both-args")); neuper@42432: val ((pt, _), _) = get_calc cI neuper@42432: val pos = get_pos cI 1; (* = ([1], Res)*) neuper@42432: neuper@42432: "~~~~~ fun get_fillformula, args:"; val ((pt, pos as (p, _)), (errpatID, fillpatID)) = neuper@42432: ((pt, pos), (errpatID, fillpatID)); neuper@42432: val fillforms = find_fillpatterns (pt, pos) errpatID neuper@42432: val fillforms = neuper@42432: filter ((curry op = fillpatID) o (#1: (fillpatID * term -> fillpatID))) fillforms; neuper@42432: neuper@42432: val [(fillpatID, fillform)] = fillforms; neuper@42432: case (fillpatID, fillform) of neuper@42432: ("fill-both-args", tm) => if term2str tm = neuper@42432: "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" neuper@42432: then () else error "get_fillformula changed 1a" neuper@42432: | _ => error "get_fillformula changed 1b"; neuper@42432: neuper@42432: val f_curr = get_curr_formula (pt, pos); (*already done in find_fillpatterns, too*) neuper@42432: term2str f_curr = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"; neuper@42432: neuper@42432: "~~~~~ fun generate_inconsistent, args:"; neuper@42432: val (_, (Rewrite' (_,_,_,_, thm', f, (f', asm))), (is, ctxt), (p,_), pt) = neuper@42432: (0, neuper@42432: (Rewrite' ("","",e_rls,true, (fillpatID, ""(*errpatthm known in find_fillpatterns*)), neuper@42432: f_curr, (fillform, []))), neuper@42432: (get_loc pt pos), (lev_on p, Und), pt); neuper@42432: if p = [2] then () else error "generate_inconsistent changed 1"; neuper@42432: neuper@42432: val (pt,c) = cappend_atomic pt p (is, insert_assumptions asm ctxt) f neuper@42432: (Rewrite thm') (f', asm) Inconsistent neuper@42432: val pt = update_branch pt p TransitiveB; neuper@42432: neuper@42432: "~~~~~ to get_fillformula return val:"; val (pos', _, _, pt) = neuper@42432: ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str f')), pt); neuper@42432: if pos' = ([2], Res) then () else error "generate_inconsistent changed 2"; neuper@42432: neuper@42432: upd_calc cI ((pt, pos'), []); upd_ipos cI 1 pos'; neuper@42432: autocalculateOK2xml cI pos pos' pos'; neuper@42432: neuper@42432: "~~~~~ final check:"; neuper@42432: val ((pt,pos),_) = get_calc 1; neuper@42432: val p = get_pos 1 1; neuper@42432: val (Form f, tac, asms) = pt_extract (pt, p); neuper@42432: if p = ([2], Res) andalso term2str f = neuper@42432: "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3" neuper@42432: then () else error ""; neuper@42432: neuper@42432: show_pt pt; (*ATTENTION: omits the last step, if pt is incomplete, ([2], Res) EXISTS !*) neuper@42432: