test/Tools/isac/Interpret/error-pattern.sml
author wneuper <Walther.Neuper@jku.at>
Mon, 11 Dec 2023 09:24:02 +0100
changeset 60778 41abd196342a
parent 60777 df8636ffd6f8
child 60780 91b105cf194a
permissions -rw-r--r--
prepare 1: delete old code with I_Model.T (without Position.T)
walther@59909
     1
(* Title: "Interpret/error-pattern.sml"
akargl@42176
     2
   Author: Walther Neuper 060225,
neuper@37906
     3
   (c) due to copyright terms 
walther@59860
     4
Walther@60658
     5
Strange ERROR "Undefined fact: "all_left"" 
neuper@37906
     6
*)
neuper@37906
     7
neuper@37906
     8
"-----------------------------------------------------------------";
neuper@37906
     9
"table of contents -----------------------------------------------";
neuper@37906
    10
"-----------------------------------------------------------------";
neuper@37906
    11
"appendForm with miniscript with mini-subpbl:";
neuper@37906
    12
"--------- appendFormula: on Res + equ_nrls ----------------------";
neuper@37906
    13
"--------- appendFormula: on Frm + equ_nrls ----------------------";
neuper@37906
    14
"--------- appendFormula: on Res + NO deriv ----------------------";
neuper@37906
    15
"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
neuper@37906
    16
"replaceForm with miniscript with mini-subpbl:";
neuper@37906
    17
"--------- replaceFormula: on Res + = ----------------------------";
neuper@37906
    18
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
neuper@37906
    19
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
neuper@37906
    20
"--------- replaceFormula: cut calculation -----------------------";
neuper@37906
    21
"--------- replaceFormula: cut calculation -----------------------";
neuper@37906
    22
(* 040307 copied from informtest.sml ... old versions
neuper@37906
    23
"--------- maximum-example, UC: Modeling / modifyCalcHead --------";*)
neuper@37906
    24
"--------- syntax error ------------------------------------------";
neuper@37906
    25
"CAS-command:";
Walther@60571
    26
(*"--------- CAS-command on ([],Pbl) -------------------------------";*)
Walther@60571
    27
(*"--------- CAS-command on ([],Pbl) FE-interface ------------------";*)
walther@59772
    28
"--------- locate_input_term [rational,simplification] ----------------------";
Walther@60571
    29
(*"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";*)
neuper@37906
    30
"--------- Take as 1st tac, start from exp -----------------------";
Walther@60571
    31
(*"--------- implicit_take, start with <NEW> (CAS input) ---------------";*)
walther@59909
    32
"--------- build fun check_for' ------------------------------";
walther@59909
    33
"--------- build fun check_for' ?bdv -------------------------";
walther@59909
    34
"--------- build fun check_for ------------------------";
walther@59909
    35
"--------- embed fun check_for ------------------------";
Walther@60637
    36
"----------- re-build: fill_from_store without thy-hierarchy -----------------------------------";
walther@59909
    37
"--------- embed fun find_fill_patterns ---------------------------";
neuper@48895
    38
"--------- build fun is_exactly_equal, inputFillFormula ----------";
wneuper@59262
    39
"--------- fun appl_adds -----------------------------------------";
wneuper@59264
    40
"--------- fun concat_deriv --------------------------------------";
wneuper@59264
    41
"--------- handle an input formula -------------------------------";
wneuper@59264
    42
"--------- fun dropwhile' ----------------------------------------";
neuper@37906
    43
"-----------------------------------------------------------------";
neuper@37906
    44
"-----------------------------------------------------------------";
neuper@37906
    45
"-----------------------------------------------------------------";
neuper@37906
    46
neuper@37906
    47
neuper@37906
    48
"--------- appendFormula: on Res + equ_nrls ----------------------";
neuper@37906
    49
"--------- appendFormula: on Res + equ_nrls ----------------------";
neuper@37906
    50
"--------- appendFormula: on Res + equ_nrls ----------------------";
Walther@60586
    51
 val Prog sc = (#program o MethodC.from_store ctxt) ["Test", "squ-equ-test-subpbl1"];
Walther@60675
    52
 (writeln o UnparseC.term @{context}) sc;
Walther@60586
    53
 val Prog sc = (#program o MethodC.from_store ctxt) ["Test", "solve_linear"];
Walther@60675
    54
 (writeln o UnparseC.term @{context}) sc;
neuper@37906
    55
Walther@60549
    56
 States.reset ();
Walther@60571
    57
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
    58
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
    59
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
    60
 Iterator 1; moveActiveRoot 1;
wneuper@59248
    61
 autoCalculate 1 CompleteCalcHead;
Walther@60549
    62
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 = 2*)
Walther@60549
    63
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
neuper@37906
    64
Walther@60549
    65
 appendFormula 1 "- 2 * 1 + (1 + x) = 0" (*|> Future.join*); refFormula 1 (States.get_pos 1 1);
Walther@60549
    66
 val ((pt,_),_) = States.get_calc 1;
Walther@60608
    67
 val str = pr_ctree ctxt pr_short pt;
neuper@48895
    68
if str =
neuper@48895
    69
(".    ----- pblobj -----\n" ^
neuper@48895
    70
"1.   x + 1 = 2\n" ^
walther@60324
    71
"2.   x + 1 + - 1 * 2 = 0\n" ^
walther@60324
    72
"2.1.   x + 1 + - 1 * 2 = 0\n" ^
walther@60324
    73
"2.2.   1 + x + - 1 * 2 = 0\n" ^
walther@60324
    74
"2.3.   1 + (x + - 1 * 2) = 0\n" ^
walther@60324
    75
"2.4.   1 + (x + - 2) = 0\n" ^
walther@60324
    76
"2.5.   1 + (x + - 2 * 1) = 0\n" ^
walther@60324
    77
"2.6.   1 + x + - 2 * 1 = 0\n" ) then ()
neuper@48895
    78
else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
neuper@37906
    79
neuper@37906
    80
 moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
walther@60324
    81
 moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + - 1 * 2 = 0*)
neuper@37906
    82
neuper@37906
    83
 (*the seven steps of detailed derivation*)
neuper@37906
    84
 moveDown 1 ([1  ],Res); refFormula 1 ([2,1],Frm); 
neuper@37906
    85
 moveDown 1 ([2,1],Frm); refFormula 1 ([2,1],Res);
neuper@37906
    86
 moveDown 1 ([2,1],Res); refFormula 1 ([2,2],Res);
neuper@37906
    87
 moveDown 1 ([2,2],Res); refFormula 1 ([2,3],Res); 
neuper@37906
    88
 moveDown 1 ([2,3],Res); refFormula 1 ([2,4],Res);
neuper@37906
    89
 moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
neuper@37906
    90
 moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
Walther@60549
    91
 val ((pt,_),_) = States.get_calc 1;
Walther@60675
    92
 if "- 2 * 1 + (1 + x) = 0" = UnparseC.term @{context} (fst (get_obj g_result pt [2,6])) then()
neuper@38031
    93
 else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
neuper@37906
    94
neuper@37906
    95
 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
neuper@48895
    96
(* <ERROR> error in kernel </ERROR> ALREADY IN 2009-2*)
neuper@48895
    97
(*========== inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 =============
Walther@60549
    98
 val (_,(tac,_,_)::_) = States.get_calc 1;
neuper@37906
    99
 if tac = Rewrite_Set "Test_simplify" then ()
neuper@38031
   100
 else error "inform.sml: diff.behav.appendFormula: on Res + equ 3";
neuper@48895
   101
============ inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 ============*)
akargl@42209
   102
wneuper@59248
   103
 autoCalculate 1 CompleteCalc;
Walther@60549
   104
 val ((pt,_),_) = States.get_calc 1;
Walther@60675
   105
 if "[x = 1]" = UnparseC.term @{context} (fst (get_obj g_result pt [])) then ()
neuper@38031
   106
 else error "inform.sml: diff.behav.appendFormula: on Res + equ 4";
wneuper@59248
   107
 (* autoCalculate 1 CompleteCalc;
Walther@60549
   108
   val ((pt,p),_) = States.get_calc 1;
neuper@37906
   109
   (writeln o istates2str) (get_obj g_loc pt [ ]);  
neuper@37906
   110
   (writeln o istates2str) (get_obj g_loc pt [1]);  
neuper@37906
   111
   (writeln o istates2str) (get_obj g_loc pt [2]);  
neuper@37906
   112
   (writeln o istates2str) (get_obj g_loc pt [3]);  
neuper@37906
   113
   (writeln o istates2str) (get_obj g_loc pt [3,1]);  
neuper@37906
   114
   (writeln o istates2str) (get_obj g_loc pt [3,2]);  
neuper@37906
   115
   (writeln o istates2str) (get_obj g_loc pt [4]);  
neuper@37906
   116
neuper@37906
   117
   *)
neuper@37906
   118
"----------------------------------------------------------";
akargl@42176
   119
Walther@60500
   120
 val fod = Derive.do_one (Proof_Context.init_global @{theory "Isac_Knowledge"}) Atools_erls 
walther@59852
   121
		       ((#rules o Rule_Set.rep) Test_simplify)
Walther@60594
   122
		       (sqrt_right false) NONE 
Walther@60660
   123
		       (ParseC.parse_test @{context} "x + 1 + - 1 * 2 = 0");
Walther@60611
   124
 (writeln o (Derive.trtas2str ctxt)) fod;
neuper@37906
   125
Walther@60500
   126
 val ifod = Derive.do_one (Proof_Context.init_global @{theory "Isac_Knowledge"}) Atools_erls 
walther@59852
   127
		       ((#rules o Rule_Set.rep) Test_simplify)
Walther@60594
   128
		       (sqrt_right false) NONE 
Walther@60660
   129
		       (ParseC.parse_test @{context} "- 2 * 1 + (1 + x) = 0");
Walther@60611
   130
 (writeln o (Derive.trtas2str ctxt)) ifod;
akargl@42176
   131
 fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
neuper@37906
   132
 val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
Walther@60630
   133
 val der = fod' @ (map (Derive.rev_deriv' ctxt) rifod');
Walther@60611
   134
 (writeln o (Derive.trtas2str ctxt)) der;
neuper@37906
   135
 "----------------------------------------------------------";
wneuper@59252
   136
DEconstrCalcTree 1;
neuper@37906
   137
neuper@37906
   138
"--------- appendFormula: on Frm + equ_nrls ----------------------";
neuper@37906
   139
"--------- appendFormula: on Frm + equ_nrls ----------------------";
neuper@37906
   140
"--------- appendFormula: on Frm + equ_nrls ----------------------";
Walther@60549
   141
 States.reset ();
Walther@60571
   142
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   143
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   144
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   145
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   146
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   147
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1) (*x + 1 = 2*);
Walther@60549
   148
 appendFormula 1 "2+ - 1 + x = 2" (*|> Future.join*); refFormula 1 (States.get_pos 1 1);
neuper@37906
   149
neuper@37906
   150
 moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
neuper@37906
   151
neuper@37906
   152
 moveDown 1 ([1  ],Frm); refFormula 1 ([1,1],Frm); 
neuper@37906
   153
 moveDown 1 ([1,1],Frm); refFormula 1 ([1,1],Res); 
neuper@37906
   154
 moveDown 1 ([1,1],Res); refFormula 1 ([1,2],Res); 
neuper@37906
   155
 moveDown 1 ([1,2],Res); refFormula 1 ([1,3],Res); 
neuper@37906
   156
 moveDown 1 ([1,3],Res); refFormula 1 ([1,4],Res); 
neuper@37906
   157
 moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res); 
neuper@37906
   158
 moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res); 
Walther@60549
   159
 val ((pt,_),_) = States.get_calc 1;
Walther@60675
   160
 if "2 + - 1 + x = 2" = UnparseC.term @{context} (fst (get_obj g_result pt [1,6])) then()
neuper@38031
   161
 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
neuper@37906
   162
neuper@37906
   163
 fetchProposedTactic 1; (*takes Iterator 1 _1_*)
Walther@60549
   164
 val (_,(tac,_,_)::_) = States.get_calc 1;
wneuper@59253
   165
 case tac of Rewrite_Set "norm_equation" => ()
wneuper@59253
   166
 | _ => error "inform.sml: diff.behav.appendFormula: on Frm + equ 2";
wneuper@59248
   167
 autoCalculate 1 CompleteCalc;
Walther@60549
   168
 val ((pt,_),_) = States.get_calc 1;
Walther@60675
   169
 if "[x = 1]" = UnparseC.term @{context} (fst (get_obj g_result pt [])) then ()
neuper@38031
   170
 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
wneuper@59252
   171
DEconstrCalcTree 1;
neuper@37906
   172
neuper@37906
   173
"--------- appendFormula: on Res + NO deriv ----------------------";
neuper@37906
   174
"--------- appendFormula: on Res + NO deriv ----------------------";
neuper@37906
   175
"--------- appendFormula: on Res + NO deriv ----------------------";
Walther@60549
   176
 States.reset ();
Walther@60571
   177
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   178
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   179
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   180
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   181
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   182
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 = 2*)
Walther@60549
   183
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
neuper@37906
   184
wneuper@59123
   185
 appendFormula 1 "x = 2" (*|> Future.join*);
Walther@60549
   186
 val ((pt,p),_) = States.get_calc 1;
Walther@60608
   187
 val str = pr_ctree ctxt pr_short pt;
neuper@37906
   188
 writeln str;
neuper@37906
   189
 if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n" andalso p = ([1], Res)
neuper@37906
   190
 then ()
neuper@38031
   191
 else error "inform.sml: diff.behav.appendFormula: Res + NOder 1";
neuper@37906
   192
neuper@37906
   193
 fetchProposedTactic 1;
Walther@60549
   194
 val (_,(tac,_,_)::_) = States.get_calc 1;
wneuper@59253
   195
 case tac of Rewrite_Set "Test_simplify" => ()
wneuper@59253
   196
 | _ => error "inform.sml: diff.behav.appendFormula: Res + NOder 2";
wneuper@59248
   197
 autoCalculate 1 CompleteCalc;
Walther@60549
   198
 val ((pt,_),_) = States.get_calc 1;
Walther@60675
   199
 if "[x = 1]" = UnparseC.term @{context} (fst (get_obj g_result pt [])) then ()
neuper@38031
   200
 else error "inform.sml: diff.behav.appendFormula: on Frm + equ 3";
wneuper@59252
   201
DEconstrCalcTree 1;
neuper@37906
   202
neuper@37906
   203
"--------- appendFormula: on Res + late deriv --------------------";
neuper@37906
   204
"--------- appendFormula: on Res + late deriv --------------------";
neuper@37906
   205
"--------- appendFormula: on Res + late deriv --------------------";
walther@59794
   206
(*cp with "fun me" to test/../lucas-interpreter.sml:
walther@59794
   207
 re-build: fun locate_input_term ---------------------------------------------------"; 
walther@59794
   208
*)
Walther@60549
   209
 States.reset ();
Walther@60571
   210
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   211
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   212
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   213
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   214
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   215
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 = 2*)
Walther@60549
   216
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
neuper@37906
   217
wneuper@59123
   218
 appendFormula 1 "x = 1" (*|> Future.join*);
Walther@60549
   219
 val ((pt,p),_) = States.get_calc 1;
Walther@60608
   220
 val str = pr_ctree ctxt pr_short pt;
neuper@37906
   221
 writeln str;
walther@60324
   222
 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
   223
 then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
neuper@38031
   224
 else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
akargl@42176
   225
neuper@37906
   226
 fetchProposedTactic 1;
Walther@60549
   227
 val (_,(tac,_,_)::_) = States.get_calc 1;
wneuper@59253
   228
 case tac of Check_Postcond ["LINEAR", "univariate", "equation", "test"] => ()
wneuper@59253
   229
 | _ => error "inform.sml: diff.behav.appendFormula: Res + late d 2";
wneuper@59248
   230
 autoCalculate 1 CompleteCalc;
Walther@60549
   231
 val ((pt,_),_) = States.get_calc 1;
Walther@60675
   232
 if "[x = 1]" = UnparseC.term @{context} (fst (get_obj g_result pt [])) then ()
neuper@38031
   233
 else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
wneuper@59252
   234
DEconstrCalcTree 1;
neuper@37906
   235
walther@60324
   236
"--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
walther@60324
   237
"--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
walther@60324
   238
"--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
Walther@60549
   239
 States.reset ();
Walther@60571
   240
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   241
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   242
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   243
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   244
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   245
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 = 2*)
Walther@60549
   246
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
wneuper@59123
   247
 appendFormula 1 "[x = 3 + -2*1]" (*|> Future.join*);
Walther@60549
   248
 val ((pt,p),_) = States.get_calc 1;
Walther@60608
   249
 val str = pr_ctree ctxt pr_short pt;
neuper@37906
   250
 writeln str;
walther@60324
   251
 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
   252
 else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
wneuper@59248
   253
 autoCalculate 1 CompleteCalc;
Walther@60549
   254
 val ((pt,p),_) = States.get_calc 1;
Walther@60675
   255
 if "[x = 3 + - 2 * 1]" = UnparseC.term @{context} (fst (get_obj g_result pt [])) then ()
neuper@37906
   256
 (*       ~~~~~~~~~~ simplify as last step in any script ?!*)
neuper@38031
   257
 else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
wneuper@59252
   258
DEconstrCalcTree 1;
neuper@37906
   259
neuper@37906
   260
"--------- replaceFormula: on Res + = ----------------------------";
neuper@37906
   261
"--------- replaceFormula: on Res + = ----------------------------";
neuper@37906
   262
"--------- replaceFormula: on Res + = ----------------------------";
Walther@60549
   263
 States.reset ();
Walther@60571
   264
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   265
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   266
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   267
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   268
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   269
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 = 2*)
Walther@60549
   270
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
Walther@60549
   271
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*- 1 + x*);
neuper@37906
   272
Walther@60549
   273
 replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (States.get_pos 1 1);
Walther@60549
   274
 val ((pt,_),_) = States.get_calc 1;
Walther@60608
   275
 val str = pr_ctree ctxt pr_short pt;
akargl@42176
   276
neuper@48895
   277
(* before AK110725 this was
neuper@48895
   278
".    ----- pblobj -----\n
neuper@48895
   279
1.   x + 1 = 2\n
walther@60324
   280
2.   x + 1 + - 1 * 2 = 0\n
walther@60324
   281
2.1.   x + 1 + - 1 * 2 = 0\n
walther@60324
   282
2.2.   1 + x + - 1 * 2 = 0\n
walther@60324
   283
2.3.   1 + (x + - 1 * 2) = 0\n
neuper@48895
   284
2.4.   1 + (x + -2) = 0\n
neuper@48895
   285
2.5.   1 + (x + -2 * 1) = 0\n
neuper@48895
   286
2.6.   1 + x + -2 * 1 = 0\n";
neuper@48895
   287
*)
Walther@60523
   288
if str =
neuper@48895
   289
".    ----- pblobj -----\n"^
neuper@48895
   290
"1.   x + 1 = 2\n"^
walther@60324
   291
"2.   x + 1 + - 1 * 2 = 0\n"^
walther@60324
   292
"2.1.   x + 1 + - 1 * 2 = 0\n"^
walther@60324
   293
"2.2.   1 + x + - 1 * 2 = 0\n"^
walther@60324
   294
"2.3.   1 + (x + - 1 * 2) = 0\n"^
walther@60324
   295
"2.4.   1 + (x + - 2) = 0\n"^
walther@60324
   296
"2.5.   1 + (x + - 2 * 1) = 0\n"^
walther@60324
   297
"2.6.   1 + x + - 2 * 1 = 0\n" then()
neuper@48895
   298
else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
akargl@42176
   299
wneuper@59248
   300
 autoCalculate 1 CompleteCalc;
Walther@60549
   301
 val ((pt,pos as (p,_)),_) = States.get_calc 1;
Walther@60675
   302
 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term @{context} o fst) (get_obj g_result pt p) then()
neuper@38031
   303
 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
wneuper@59252
   304
DEconstrCalcTree 1;
neuper@37906
   305
neuper@37906
   306
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
neuper@37906
   307
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
neuper@37906
   308
"--------- replaceFormula: on Res + = 1st Nd ---------------------";
Walther@60549
   309
 States.reset ();
Walther@60571
   310
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   311
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   312
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   313
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   314
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   315
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 = 2*)
Walther@60549
   316
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
neuper@37906
   317
Walther@60549
   318
 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (States.get_pos 1 1);
Walther@60549
   319
 val ((pt,_),_) = States.get_calc 1;
Walther@60608
   320
 val str = pr_ctree ctxt pr_short pt;
neuper@37906
   321
 writeln str;
walther@60324
   322
 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
   323
 else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
wneuper@59248
   324
 autoCalculate 1 CompleteCalc;
Walther@60549
   325
 val ((pt,pos as (p,_)),_) = States.get_calc 1;
Walther@60675
   326
 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term @{context} o fst)(get_obj g_result pt p) then()
neuper@38031
   327
 else error "inform.sml: diff.behav.replaceFormula: on Res + = 2";
wneuper@59252
   328
DEconstrCalcTree 1;
neuper@37906
   329
neuper@37906
   330
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
neuper@37906
   331
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
neuper@37906
   332
"--------- replaceFormula: on Frm + = 1st Nd ---------------------";
Walther@60549
   333
 States.reset (); 
Walther@60571
   334
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   335
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   336
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   337
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   338
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   339
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 = 2*)
neuper@37906
   340
Walther@60549
   341
 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (States.get_pos 1 1);
Walther@60549
   342
 val ((pt,_),_) = States.get_calc 1;
Walther@60608
   343
 val str = pr_ctree ctxt pr_short pt;
walther@60340
   344
 writeln str;
walther@60324
   345
 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
   346
 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
wneuper@59248
   347
 autoCalculate 1 CompleteCalc;
Walther@60549
   348
 val ((pt,pos as (p,_)),_) = States.get_calc 1;
Walther@60675
   349
 if pos = ([],Res) andalso "[x = 1]" = (UnparseC.term @{context} o fst)(get_obj g_result pt p) then()
neuper@38031
   350
 else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 2";
wneuper@59252
   351
DEconstrCalcTree 1;
neuper@37906
   352
neuper@37906
   353
"--------- replaceFormula: cut calculation -----------------------";
neuper@37906
   354
"--------- replaceFormula: cut calculation -----------------------";
neuper@37906
   355
"--------- replaceFormula: cut calculation -----------------------";
Walther@60549
   356
 States.reset ();
Walther@60571
   357
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   358
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   359
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   360
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   361
 autoCalculate 1 CompleteCalc;
neuper@37906
   362
 moveActiveRoot 1; moveActiveDown 1;
Walther@60549
   363
 if States.get_pos 1 1 = ([1], Frm) then ()
neuper@38031
   364
 else error "inform.sml: diff.behav. cut calculation 1";
neuper@37906
   365
Walther@60549
   366
 replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (States.get_pos 1 1);
Walther@60549
   367
 val ((pt,p),_) = States.get_calc 1;
Walther@60608
   368
 val str = pr_ctree ctxt pr_short pt;
neuper@37906
   369
 writeln str;
neuper@37906
   370
 if p = ([1], Res) then ()
neuper@38031
   371
 else error "inform.sml: diff.behav. cut calculation 2";
neuper@37906
   372
neuper@37906
   373
neuper@37906
   374
(* 040307 copied from informtest.sml; ... old version 
neuper@37906
   375
 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
neuper@37906
   376
 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
neuper@37906
   377
 "---------------- maximum-example, UC: Modeling / modifyCalcHead -";
neuper@37906
   378
neuper@37906
   379
 val p = ([],Pbl);
walther@59997
   380
 val elems = ["fixedValues [r=Arbfix]", "maximum A", "valuesFor [a,b]",
walther@60242
   381
	      "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
walther@60242
   382
	      "relations [A=a*b, (a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]",
wneuper@59582
   383
        "relations [A=a*b, a/2=r*sin alpha, b/2=r*cos (alpha::real)]",
walther@60242
   384
	      (* \<up>  these are the elements for the root-problem (in variants)*)
neuper@37906
   385
              (*vvv these are elements required for subproblems*)
walther@59997
   386
	      "boundVariable a", "boundVariable b", "boundVariable alpha",
neuper@37906
   387
	      "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
   388
	      "interval {x::real. 0 <= x & x <= 2*r}",
neuper@37906
   389
	      "interval {x::real. 0 <= x & x <= pi}",
neuper@37906
   390
	      "errorBound (eps=(0::real))"]
neuper@37906
   391
 (*specifying is not interesting for this example*)
Walther@60458
   392
 val spec = ("Diff_App", ["maximum_of", "function"], 
Walther@60458
   393
	     ["Diff_App", "max_by_calculus"]);
neuper@37906
   394
 (*the empty model with descriptions for user-guidance by Model_Problem*)
neuper@37906
   395
 val empty_model = [Given ["fixedValues []"],
neuper@37906
   396
		    Find ["maximum", "valuesFor"],
neuper@37906
   397
		    Relate ["relations []"]];
neuper@37906
   398
neuper@37906
   399
neuper@37906
   400
 (*!!!!!!!!!!!!!!!!! DON'T USE me FOR FINDING nxt !!!!!!!!!!!!!!!!!!*)
Walther@60571
   401
 val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context} [(elems, spec)];
neuper@37906
   402
 (*val nxt = ("Model_Problem", ...*)
walther@59942
   403
 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl; 
neuper@37906
   404
neuper@37906
   405
 val (p,_,f,nxt,_,pt) = me nxt p c pt;
neuper@37906
   406
 (*nxt = Add_Given "fixedValues [r = Arbfix]"*)
walther@59942
   407
 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl; 
neuper@37906
   408
(*[
neuper@37906
   409
(0 ,[] ,false ,#Given ,Inc fixedValues [] ,(??.empty, [])),
neuper@37906
   410
(0 ,[] ,false ,#Find ,Inc maximum ,(??.empty, [])),
neuper@37906
   411
(0 ,[] ,false ,#Find ,Inc valuesFor ,(??.empty, [])),
neuper@37906
   412
(0 ,[] ,false ,#Relate ,Inc relations [] ,(??.empty, []))]*)
neuper@37906
   413
neuper@37906
   414
 (*the empty CalcHead is checked w.r.t the model and re-established as such*)
walther@59976
   415
 val (b,pt,ocalhd) = input_icalhd pt (p,"", empty_model, Pbl, References.empty);
walther@59942
   416
 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl; 
walther@59879
   417
 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(\"ThyC.id_empty\", [\"e_pblID\"], [\"e_metID\"]) )" then () else error "informtest.sml: diff.behav. max 1";
neuper@37906
   418
neuper@37906
   419
 (*there is one input to the model (could be more)*)
neuper@37906
   420
 val (b,pt,ocalhd) = 
neuper@37906
   421
     input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
neuper@37906
   422
			     Find ["maximum", "valuesFor"],
walther@59976
   423
			     Relate ["relations"]], Pbl, References.empty);
walther@59942
   424
 val pbl = get_obj g_pbl pt (fst p); (writeln o (I_Model.to_string ctxt)) pbl; 
walther@59879
   425
 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(\"ThyC.id_empty\", [\"e_pblID\"], [\"e_metID\"]) )" then () 
neuper@38031
   426
 else error "informtest.sml: diff.behav. max 2";
neuper@37906
   427
neuper@37906
   428
 (*this input is complete in variant 3, but the ME doesn't recognize FIXXXXME
neuper@37906
   429
 val (b,pt''''',ocalhd) = 
neuper@37906
   430
     input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
neuper@37906
   431
			     Find ["maximum A", "valuesFor [a,b]"],
neuper@37906
   432
			     Relate ["relations [A=a*b, a/2=r*sin alpha, \
walther@59976
   433
				     \b/2=r*cos alpha]"]], Pbl, References.empty);
walther@59942
   434
 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (I_Model.to_string ctxt)) pbl; 
walther@60242
   435
 if ocalhd2str ocalhd = ------------ \<up> \<up> \<up> ^ missing !!!*)
neuper@37906
   436
neuper@37906
   437
 (*this input is complete in variant 1 (variant 3 does not work yet)*)
neuper@37906
   438
 val (b,pt''''',ocalhd) = 
neuper@37906
   439
     input_icalhd pt (p,"", [Given ["fixedValues [r=Arbfix]"],
neuper@37906
   440
			     Find ["maximum A", "valuesFor [a,b]"],
neuper@37906
   441
			     Relate ["relations [A=a*b, \
walther@60242
   442
				     \(a/2) \<up> 2 + (b/2) \<up> 2 = r \<up> 2]"]], 
walther@59976
   443
		      Pbl, References.empty);
walther@59942
   444
 val pbl = get_obj g_pbl pt''''' (fst p); (writeln o (I_Model.to_string ctxt)) pbl; 
neuper@37906
   445
neuper@37906
   446
 modifycalcheadOK2xml 111 (bool2str b) ocalhd;
neuper@37906
   447
*)
wneuper@59252
   448
DEconstrCalcTree 1;
neuper@37906
   449
neuper@37906
   450
"--------- syntax error ------------------------------------------";
neuper@37906
   451
"--------- syntax error ------------------------------------------";
neuper@37906
   452
"--------- syntax error ------------------------------------------";
Walther@60549
   453
 States.reset ();
Walther@60571
   454
 CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
walther@59997
   455
	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
walther@59997
   456
	     ["Test", "squ-equ-test-subpbl1"]))];
neuper@37906
   457
 Iterator 1; moveActiveRoot 1;
wneuper@59248
   458
 autoCalculate 1 CompleteCalcHead;
Walther@60549
   459
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 = 2*)
Walther@60549
   460
 autoCalculate 1 (Steps 1); refFormula 1 (States.get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
neuper@37906
   461
Walther@60658
   462
(*appendFormula 1 " x - "; ..ERROR Inner syntax error: unexpected end of input
Walther@60658
   463
                                   Failed to parse term *)
Walther@60549
   464
 val ((pt,_),_) = States.get_calc 1;
Walther@60608
   465
 val str = pr_ctree ctxt pr_short pt;
neuper@37906
   466
 writeln str;
neuper@37906
   467
 if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n" then ()
neuper@38031
   468
 else error "inform.sml: diff.behav.appendFormula: syntax error";
wneuper@59252
   469
DEconstrCalcTree 1;
neuper@37906
   470
Walther@60571
   471
(*POSTPONE CORRECTION AT END OF TRANSITION TO Isabelle/PIDE/Isac (~ Cas_Cmd)
neuper@37906
   472
"--------- CAS-command on ([],Pbl) -------------------------------";
neuper@37906
   473
"--------- CAS-command on ([],Pbl) -------------------------------";
neuper@37906
   474
"--------- CAS-command on ([],Pbl) -------------------------------";
neuper@37906
   475
val (p,_,f,nxt,_,pt) = 
Walther@60571
   476
    Test_Code.init_calc @{context} [([], References.empty)];
walther@60340
   477
val ifo = "solve(x+1=2,x)";
walther@60340
   478
val (_,(_,c,(pt,p))) = Step_Solve.by_term (pt,p) "solve(x+1=2,x)";
Walther@60571
   479
( *
walther@60242
   480
  This trick           \<up> \<up> \<up> micked input of \<up> \<up> \<up> \<up>  \<up> ^^ in the front-end.
walther@59921
   481
  The trick worked in changeset fbaff8cf0179, it does not work in 59c5dd27d589 anymore
walther@59921
   482
  (TODO hg bisect ?) and raises the ERROR Undefined fact: "xfoldr_Nil".
walther@59921
   483
walther@59921
   484
  Compare tests "CAS-command" in test/../inssort.sml etc.
walther@59921
   485
  ---------------------------------------------------------------------------------------------
walther@59983
   486
Test_Tool.show_pt pt;
walther@59997
   487
val nxt = (Apply_Method ["Test", "squ-equ-test-subpbl1"]);
neuper@37906
   488
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@37906
   489
if p = ([1], Frm) andalso f2str f = "x + 1 = 2" then ()
neuper@38031
   490
else error "inform.sml: diff.behav. CAScmd ([],Pbl)";
wneuper@59252
   491
DEconstrCalcTree 1;
walther@59921
   492
-----------------------------------------------------------------------------------------------*)
neuper@37906
   493
Walther@60571
   494
(*POSTPONE CORRECTION AT END OF TRANSITION TO Isabelle/PIDE/Isac (~ Cas_Cmd)
neuper@37906
   495
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
neuper@37906
   496
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
neuper@37906
   497
"--------- CAS-command on ([],Pbl) FE-interface ------------------";
Walther@60549
   498
States.reset ();
Walther@60571
   499
CalcTree @{context} [([], References.empty)];
neuper@37906
   500
Iterator 1;
neuper@37906
   501
moveActiveRoot 1;
walther@60340
   502
replaceFormula 1 "solve(x+1=2,x)";
wneuper@59248
   503
autoCalculate 1 CompleteCalc;
Walther@60549
   504
val ((pt,p),_) = States.get_calc 1;
walther@59983
   505
Test_Tool.show_pt pt;
neuper@37906
   506
if p = ([], Res) then ()
neuper@38031
   507
else error "inform.sml: diff.behav. CAScmd ([],Pbl) FE-interface";
wneuper@59252
   508
DEconstrCalcTree 1;
Walther@60571
   509
-----------------------------------------------------------------------------------------------*)
neuper@37906
   510
wneuper@59562
   511
"--------- inform [rational,simplification] ----------------------";
wneuper@59562
   512
"--------- inform [rational,simplification] ----------------------";
wneuper@59562
   513
"--------- inform [rational,simplification] ----------------------";
Walther@60549
   514
States.reset ();
Walther@60571
   515
CalcTree @{context} [(["Term (a * x / (b * x) + c * x / (d * x) + e / f)", "normalform N"],
neuper@52105
   516
	("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
neuper@37906
   517
Iterator 1; moveActiveRoot 1;
wneuper@59248
   518
autoCalculate 1 CompleteCalcHead;
neuper@52105
   519
walther@60324
   520
"--- (- 1) give a preview on the calculation without any input";
neuper@52105
   521
(*
wneuper@59248
   522
autoCalculate 1 CompleteCalc;
Walther@60549
   523
val ((pt, p), _) = States.get_calc 1;
walther@59983
   524
Test_Tool.show_pt pt;
neuper@52105
   525
[
neuper@52105
   526
(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
neuper@52105
   527
(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
neuper@52105
   528
(([1], Res), a / b + c / d + e / f),                             <--- (1) input arbitrary
neuper@52105
   529
(([2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   530
(([3], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
neuper@52105
   531
(([4], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)), <--- (2) input next
neuper@52105
   532
(([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))]  <--- (3) is also final result
neuper@52105
   533
                                                                          EXAMPLE NOT OPTIMAL
neuper@52105
   534
*)
neuper@52105
   535
"--- (0) user input as the *first* step does not work, thus impdo at least 1 step";
walther@59747
   536
autoCalculate 1 (Steps 1);
walther@59747
   537
autoCalculate 1 (Steps 1);
Walther@60549
   538
val ((pt, p), _) = States.get_calc 1;
walther@59983
   539
(*Test_Tool.show_pt pt;
neuper@52105
   540
[
neuper@52105
   541
(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
neuper@52105
   542
(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
neuper@52105
   543
(([1], Res), a / b + c / d + e / f)] 
neuper@52105
   544
*)
neuper@52105
   545
"--- (1) input an arbitrary next formula";
wneuper@59123
   546
appendFormula 1 "((a * d) + (c * b)) / (b * d) + e / f" (*|> Future.join*);
Walther@60549
   547
val ((pt, p), _) = States.get_calc 1;
walther@59983
   548
(*Test_Tool.show_pt pt;
neuper@52105
   549
[
neuper@52105
   550
(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
neuper@52105
   551
(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
neuper@52105
   552
(([1], Res), a / b + c / d + e / f),
neuper@52105
   553
(([2,1], Frm), a / b + c / d + e / f),
neuper@52105
   554
(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   555
(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   556
(([2], Res), (a * d + c * b) / (b * d) + e / f)] 
neuper@52105
   557
*)
Walther@60549
   558
val ((pt,p),_) = States.get_calc 1;
neuper@52105
   559
if p = ([2], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
neuper@38031
   560
else error ("inform.sml: [rational,simplification] 1");
neuper@37906
   561
neuper@52105
   562
"--- (2) input the next formula that would be presented by mat-engine";
neuper@52105
   563
(* generate a preview:
walther@59747
   564
autoCalculate 1 (Steps 1);
Walther@60549
   565
val ((pt, p), _) = States.get_calc 1;
walther@59983
   566
Test_Tool.show_pt pt;
neuper@52105
   567
[
neuper@52105
   568
(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
neuper@52105
   569
(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
neuper@52105
   570
(([1], Res), a / b + c / d + e / f),
neuper@52105
   571
(([2,1], Frm), a / b + c / d + e / f),
neuper@52105
   572
(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   573
(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   574
(([2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   575
(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))]   <--- input this
neuper@52105
   576
*)
wneuper@59123
   577
appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
Walther@60549
   578
val ((pt, p), _) = States.get_calc 1;
walther@59983
   579
(*Test_Tool.show_pt pt;
neuper@52105
   580
[
neuper@52105
   581
(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
neuper@52105
   582
(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
neuper@52105
   583
(([1], Res), a / b + c / d + e / f),
neuper@52105
   584
(([2,1], Frm), a / b + c / d + e / f),
neuper@52105
   585
(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   586
(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   587
(([2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   588
(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] 
neuper@52105
   589
*)
neuper@52105
   590
if p = ([3], Res) andalso (length o children o (get_nd pt)) (fst p) = 0 then ()
neuper@38031
   591
else error ("inform.sml: [rational,simplification] 2");
neuper@37906
   592
neuper@52105
   593
"--- (3) input the exact final result";
wneuper@59123
   594
appendFormula 1 "(b * d * e + b * c * f + a * d * f) / (b * d * f)" (*|> Future.join*);
Walther@60549
   595
val ((pt, p), _) = States.get_calc 1;
walther@59983
   596
(*Test_Tool.show_pt pt;
neuper@52105
   597
[
neuper@52105
   598
(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
neuper@52105
   599
(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
neuper@52105
   600
(([1], Res), a / b + c / d + e / f),
neuper@52105
   601
(([2,1], Frm), a / b + c / d + e / f),
neuper@52105
   602
(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   603
(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   604
(([2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   605
(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   606
(([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   607
(([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
neuper@52105
   608
(([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   609
(([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f))] 
neuper@52105
   610
*)
neuper@52105
   611
if p = ([4], Res) andalso (length o children o (get_nd pt)) (fst p) = 2 then ()
neuper@38031
   612
else error ("inform.sml: [rational,simplification] 3");
neuper@52105
   613
neuper@52105
   614
"--- (4) finish the calculation + check the postcondition (in the future)";
wneuper@59248
   615
autoCalculate 1 CompleteCalc;
Walther@60549
   616
val ((pt, p), _) = States.get_calc 1;
neuper@52105
   617
val (t, asm) = get_obj g_result pt [];
Walther@60675
   618
if UnparseC.term @{context} t = "(a * d * f + b * c * f + b * d * e) / (b * d * f)" andalso
Walther@60675
   619
UnparseC.terms @{context} asm =(*"[\"b * d * f \<noteq> 0\",\"d \<noteq> 0\",\"b \<noteq> 0\",\"a * x / (b * x) + c * x / (d * x) + e / f is_ratpolyexp\"]"*)
walther@59921
   620
                    "[]" (*..found broken in child of 33913fe24685, error covered by  CAS-command *)
neuper@52105
   621
then () else error "inform [rational,simplification] changed at end";
walther@59983
   622
(*Test_Tool.show_pt pt;
neuper@52105
   623
[
neuper@52105
   624
(([], Frm), Simplify (a * x / (b * x) + c * x / (d * x) + e / f)),
neuper@52105
   625
(([1], Frm), a * x / (b * x) + c * x / (d * x) + e / f),
neuper@52105
   626
(([1], Res), a / b + c / d + e / f),
neuper@52105
   627
(([2,1], Frm), a / b + c / d + e / f),
neuper@52105
   628
(([2,1], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   629
(([2,2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   630
(([2], Res), (a * d + c * b) / (b * d) + e / f),
neuper@52105
   631
(([3], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   632
(([4,1], Frm), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   633
(([4,1], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
neuper@52105
   634
(([4,2], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   635
(([4], Res), (b * d * e + b * c * f + a * d * f) / (b * d * f)),
neuper@52105
   636
(([5], Res), (a * (d * f) + b * (c * f) + b * (d * e)) / (b * (d * f))),
neuper@52105
   637
(([6], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f)),
neuper@52105
   638
(([], Res), (a * d * f + b * c * f + b * d * e) / (b * d * f))] 
neuper@52105
   639
*)
wneuper@59252
   640
DEconstrCalcTree 1;
neuper@37906
   641
Walther@60571
   642
(*POSTPONE CORRECTION AT END OF TRANSITION TO Isabelle/PIDE/Isac (~ Cas_Cmd)
neuper@37906
   643
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
neuper@37906
   644
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
neuper@37906
   645
"--------- Take as 1st tac, start with <NEW> (CAS input) ---------";
Walther@60660
   646
val t = ParseC.parse_test @{context} "Diff (x \<up> 2 + x + 1, x)";
walther@60336
   647
case t of Const (\<^const_name>\<open>Diff\<close>, _) $ _ => ()
neuper@37906
   648
	| _ => raise 
neuper@37906
   649
	      error "diff.sml behav.changed for CAS Diff (..., x)";
Walther@60650
   650
TermC.atom_trace_detail @{context} t;
neuper@37906
   651
"-----------------------------------------------------------------";
Walther@60549
   652
(*1>*)States.reset ();
Walther@60571
   653
(*2>*)CalcTree @{context} [([], References.empty)];
neuper@37906
   654
(*3>*)Iterator 1;moveActiveRoot 1;
neuper@37906
   655
"----- here the Headline has been finished";
neuper@37906
   656
(*4>*)moveActiveFormula 1 ([],Pbl);
walther@60242
   657
(*5>*)replaceFormula 1 "Diff (x \<up> 2 + x + 1, x)";
Walther@60549
   658
val ((pt,_),_) = States.get_calc 1;
walther@59921
   659
val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
neuper@37926
   660
val (SOME istate, NONE) = loc;
wneuper@59348
   661
(*default_print_depth 5;*)
neuper@37906
   662
writeln"-----------------------------------------------------------";
neuper@37906
   663
spec;
walther@59942
   664
writeln (I_Model.to_string ctxt probl);
walther@59942
   665
writeln (I_Model.to_string ctxt meth);
Walther@60646
   666
writeln (Istate.string_of ctxt (fst istate));
neuper@37906
   667
neuper@37906
   668
refFormula 1 ([],Pbl) (*--> correct CalcHead*);
neuper@37906
   669
 (*081016 NOT necessary (but leave it in Java):*)
wneuper@59248
   670
(*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
neuper@37906
   671
"----- here the CalcHead has been completed --- ONCE MORE ?????";
neuper@37906
   672
Walther@60766
   673
(**difference II**)
Walther@60549
   674
val ((pt,p),_) = States.get_calc 1;
neuper@37906
   675
(*val p = ([], Pbl)*)
walther@59921
   676
val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
neuper@37926
   677
val (SOME istate, NONE) = loc;
Walther@60646
   678
(*default_print_depth 5;*) writeln (Istate.string_of ctxt (fst istate));  (*default_print_depth 3;*)
wneuper@59583
   679
(*Pstate ([],
neuper@37926
   680
 [], NONE,
neuper@37906
   681
 ??.empty, Sundef, false)*)
wneuper@59348
   682
(*default_print_depth 5;*) spec; (*default_print_depth 3;*)
wneuper@59592
   683
(*("Isac_Knowledge",
neuper@37906
   684
      ["derivative_of", "function"],
neuper@37906
   685
      ["diff", "differentiate_on_R"]) : spec*)
walther@59942
   686
writeln (I_Model.to_string ctxt probl);
neuper@37906
   687
(*[
walther@60242
   688
(1 ,[1] ,true ,#Given ,Cor functionTerm (x \<up> 2 + x + 1) ,(f_, [x \<up> 2 + x + 1])),
neuper@37906
   689
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
akargl@42176
   690
(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
walther@59942
   691
writeln (I_Model.to_string ctxt meth);
neuper@37906
   692
(*[
walther@60242
   693
(1 ,[1] ,true ,#Given ,Cor functionTerm (x \<up> 2 + x + 1) ,(f_, [x \<up> 2 + x + 1])),
neuper@37906
   694
(2 ,[1] ,true ,#Given ,Cor differentiateFor x ,(v_, [x])),
akargl@42176
   695
(3 ,[1] ,true ,#Find ,Cor derivative f_'_f ,(f_'_f, [f_'_f]))]*)
neuper@37906
   696
writeln"-----------------------------------------------------------";
neuper@37906
   697
(*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
neuper@37906
   698
(*WN081028 fixed <ERROR> helpless </ERROR> by inform returning ...(.,Met)*)
wneuper@59248
   699
autoCalculate 1 CompleteCalc;
Walther@60549
   700
val ((pt,p),_) = States.get_calc 1;
walther@59983
   701
val Form res = (#1 o ME_Misc.pt_extract) (pt, ([],Res));
walther@59983
   702
Test_Tool.show_pt pt;
walther@60242
   703
Walther@60675
   704
if p = ([], Res) andalso UnparseC.term @{context} res = "1 + 2 * x" then ()
walther@60242
   705
else error "diff.sml behav.changed for Diff (x \<up> 2 + x + 1, x)";
wneuper@59252
   706
DEconstrCalcTree 1;
Walther@60571
   707
-----------------------------------------------------------------------------------------------*)
neuper@37906
   708
neuper@37906
   709
"--------- Take as 1st tac, start from exp -----------------------";
neuper@37906
   710
"--------- Take as 1st tac, start from exp -----------------------";
neuper@37906
   711
"--------- Take as 1st tac, start from exp -----------------------";
neuper@37906
   712
(*the following input is copied from BridgeLog Java <==> SML,
neuper@37906
   713
  omitting unnecessary inputs*)
Walther@60549
   714
(*1>*)States.reset ();
Walther@60571
   715
(*2>*)CalcTree @{context} [(["functionTerm (x \<up> 2 + x + 1)", "differentiateFor x", "derivative f_'_f"],("Isac_Knowledge",["derivative_of", "function"],["diff", "differentiate_on_R"]))];
neuper@37906
   716
(*3>*)Iterator 1; moveActiveRoot 1;
neuper@37906
   717
wneuper@59248
   718
(*6>*)(*completeCalcHead*)autoCalculate 1 CompleteCalcHead;
Walther@60766
   719
(**difference II**)
Walther@60549
   720
val ((pt,_),_) = States.get_calc 1;
walther@59921
   721
val PblObj {probl, meth, spec, fmz, loc, ...} = get_obj I pt [];
neuper@37926
   722
val (SOME istate, NONE) = loc;
Walther@60778
   723
Walther@60778
   724
val "Pstate ([], [], empty, NONE, \n??.empty, ORundef, false, false)"
Walther@60778
   725
 = fst istate |> Istate.string_of ctxt
Walther@60778
   726
val ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]) = spec;
Walther@60778
   727
val "[\n(1, [1], true ,#Given, (Cor_POS functionTerm (x \<up> 2 + x + 1) , pen2str, Position.T)), \n(2, [1], true ,#Given, (Cor_POS differentiateFor x , pen2str, Position.T)), \n(3, [1], true ,#Find, (Cor_POS derivative f_'_f , pen2str, Position.T))]"
Walther@60778
   728
 = probl |> I_Model.OLD_to_POS  |> I_Model.to_string_POS ctxt
Walther@60778
   729
val "[\n(1, [1], true ,#Given, (Cor_POS functionTerm (x \<up> 2 + x + 1) , pen2str, Position.T)), \n(2, [1], true ,#Given, (Cor_POS differentiateFor x , pen2str, Position.T)), \n(3, [1], true ,#Find, (Cor_POS derivative f_'_f , pen2str, Position.T))]"
Walther@60778
   730
 = meth |> I_Model.OLD_to_POS  |> I_Model.to_string_POS ctxt;
Walther@60778
   731
neuper@37906
   732
(*7>*)fetchProposedTactic 1 (*--> Apply_Method*);
walther@59747
   733
autoCalculate 1 (Steps 1);
Walther@60549
   734
val ((pt,p),_) = States.get_calc 1;
Walther@60577
   735
val Form res = (#1 o (ME_Misc.pt_extract ctxt)) (pt, p);
Walther@60675
   736
if UnparseC.term @{context} res = "d_d x (x \<up> 2 + x + 1)" then ()
walther@60242
   737
else error "diff.sml Diff (x \<up> 2 + x + 1, x) from exp";
wneuper@59252
   738
DEconstrCalcTree 1;
neuper@37906
   739
Walther@60571
   740
(*POSTPONE CORRECTION AT END OF TRANSITION TO Isabelle/PIDE/Isac (~ Cas_Cmd)
walther@59845
   741
"--------- implicit_take, start with <NEW> (CAS input) ---------------";
walther@59845
   742
"--------- implicit_take, start with <NEW> (CAS input) ---------------";
walther@59845
   743
"--------- implicit_take, start with <NEW> (CAS input) ---------------";
Walther@60549
   744
States.reset ();
Walther@60571
   745
CalcTree @{context} [([], References.empty)];
neuper@37906
   746
(*[[from sml: > @@@@@begin@@@@@
neuper@37906
   747
[[from sml:  1 
neuper@37906
   748
[[from sml: <CALCTREE>
neuper@37906
   749
[[from sml:    <CALCID> 1 </CALCID>
neuper@37906
   750
[[from sml: </CALCTREE>
neuper@37906
   751
[[from sml: @@@@@end@@@@@*)
neuper@37906
   752
Iterator 1;
neuper@37906
   753
(*[[from sml: > @@@@@begin@@@@@
neuper@37906
   754
[[from sml:  1 
neuper@37906
   755
[[from sml: <ADDUSER>
neuper@37906
   756
[[from sml:   <CALCID> 1 </CALCID>
neuper@37906
   757
[[from sml:   <USERID> 1 </USERID>
neuper@37906
   758
[[from sml: </ADDUSER>
neuper@37906
   759
[[from sml: @@@@@end@@@@@*)
neuper@37906
   760
moveActiveRoot 1;
neuper@37906
   761
(*[[from sml: > @@@@@begin@@@@@
neuper@37906
   762
[[from sml:  1 
neuper@37906
   763
[[from sml: <CALCITERATOR>
neuper@37906
   764
[[from sml:   <CALCID> 1 </CALCID>
neuper@37906
   765
[[from sml:   <POSITION>
neuper@37906
   766
[[from sml:     <INTLIST>
neuper@37906
   767
[[from sml:     </INTLIST>
neuper@37906
   768
[[from sml:     <POS> Pbl </POS>
neuper@37906
   769
[[from sml:   </POSITION>
neuper@37906
   770
[[from sml: </CALCITERATOR>
neuper@37906
   771
[[from sml: @@@@@end@@@@@*)
neuper@37906
   772
getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false;
neuper@37906
   773
(*[[from sml: > @@@@@begin@@@@@                STILL CORRECT
neuper@37906
   774
[[from sml:  1 
neuper@37906
   775
[[from sml: <GETELEMENTSFROMTO>
neuper@37906
   776
[[from sml:   <CALCID> 1 </CALCID>
neuper@37906
   777
[[from sml:   <FORMHEADS>
neuper@37906
   778
[[from sml:     <CALCFORMULA>
neuper@37906
   779
[[from sml:       <POSITION>
neuper@37906
   780
[[from sml:         <INTLIST>
neuper@37906
   781
[[from sml:         </INTLIST>
neuper@37906
   782
[[from sml:         <POS> Pbl </POS>
neuper@37906
   783
[[from sml:       </POSITION>
neuper@37906
   784
[[from sml:       <FORMULA>
neuper@37906
   785
[[from sml:         <MATHML>
neuper@37906
   786
[[from sml:           <ISA> ________________________________________________ </ISA>
neuper@37906
   787
[[from sml:         </MATHML>
neuper@37906
   788
[[from sml: 
neuper@37906
   789
[[from sml:       </FORMULA>
neuper@37906
   790
[[from sml:     </CALCFORMULA>
neuper@37906
   791
[[from sml:   </FORMHEADS>
neuper@37906
   792
[[from sml: </GETELEMENTSFROMTO>
neuper@37906
   793
[[from sml: @@@@@end@@@@@*)
neuper@37906
   794
refFormula 1 ([],Pbl);
neuper@37906
   795
(*[[from sml: > @@@@@begin@@@@@                STILL CORRECT
neuper@37906
   796
[[from sml:  1 
neuper@37906
   797
[[from sml: <REFFORMULA>
neuper@37906
   798
[[from sml:   <CALCID> 1 </CALCID>
neuper@37906
   799
[[from sml:   <CALCHEAD status = "incorrect">
neuper@37906
   800
[[from sml:     <POSITION>
neuper@37906
   801
[[from sml:       <INTLIST>
neuper@37906
   802
[[from sml:       </INTLIST>
neuper@37906
   803
[[from sml:       <POS> Pbl </POS>
neuper@37906
   804
[[from sml:     </POSITION>
neuper@37906
   805
[[from sml:     <HEAD>
neuper@37906
   806
[[from sml:       <MATHML>
walther@59879
   807
[[from sml:         <ISA> Problem (ThyC.id_empty, [e_pblID]) </ISA>
neuper@37906
   808
[[from sml:       </MATHML>
neuper@37906
   809
[[from sml:     </HEAD>
neuper@37906
   810
[[from sml:     <MODEL>
neuper@37906
   811
[[from sml:       <GIVEN>  </GIVEN>
neuper@37906
   812
[[from sml:       <WHERE>  </WHERE>
neuper@37906
   813
[[from sml:       <FIND>  </FIND>
neuper@37906
   814
[[from sml:       <RELATE>  </RELATE>
neuper@37906
   815
[[from sml:     </MODEL>
neuper@37906
   816
[[from sml:     <BELONGSTO> Pbl </BELONGSTO>
neuper@37906
   817
[[from sml:     <SPECIFICATION>
walther@59879
   818
[[from sml:       <THEORYID> ThyC.id_empty </THEORYID>
neuper@37906
   819
[[from sml:       <PROBLEMID>
neuper@37906
   820
[[from sml:         <STRINGLIST>
walther@59903
   821
[[from sml:           <STRING> Problem.id_empty </STRING>
neuper@37906
   822
[[from sml:         </STRINGLIST>
neuper@37906
   823
[[from sml:       </PROBLEMID>
neuper@37906
   824
[[from sml:       <METHODID>
neuper@37906
   825
[[from sml:         <STRINGLIST>
neuper@37906
   826
[[from sml:           <STRING> e_metID </STRING>
neuper@37906
   827
[[from sml:         </STRINGLIST>
neuper@37906
   828
[[from sml:       </METHODID>
neuper@37906
   829
[[from sml:     </SPECIFICATION>
neuper@37906
   830
[[from sml:   </CALCHEAD>
neuper@37906
   831
[[from sml: </REFFORMULA>
neuper@37906
   832
[[from sml: @@@@@end@@@@@*)
neuper@37906
   833
moveActiveFormula 1 ([],Pbl);
neuper@37906
   834
(*[[from sml: > @@@@@begin@@@@@
neuper@37906
   835
[[from sml:  1 
neuper@37906
   836
[[from sml: <CALCITERATOR>
neuper@37906
   837
[[from sml:   <CALCID> 1 </CALCID>
neuper@37906
   838
[[from sml:   <POSITION>
neuper@37906
   839
[[from sml:     <INTLIST>
neuper@37906
   840
[[from sml:     </INTLIST>
neuper@37906
   841
[[from sml:     <POS> Pbl </POS>
neuper@37906
   842
[[from sml:   </POSITION>
neuper@37906
   843
[[from sml: </CALCITERATOR>
neuper@37906
   844
[[from sml: @@@@@end@@@@@*)
neuper@37906
   845
replaceFormula 1 "Simplify (1+2)";
neuper@37906
   846
(*[[from sml: > @@@@@begin@@@@@
neuper@37906
   847
[[from sml:  1 
neuper@37906
   848
[[from sml: <REPLACEFORMULA>
neuper@37906
   849
[[from sml:   <CALCID> 1 </CALCID>
neuper@37906
   850
[[from sml:   <CALCCHANGED>
neuper@37906
   851
[[from sml:     <UNCHANGED>
neuper@37906
   852
[[from sml:       <INTLIST>
neuper@37906
   853
[[from sml:       </INTLIST>
neuper@37906
   854
[[from sml:       <POS> Pbl </POS>
neuper@37906
   855
[[from sml:     </UNCHANGED>
neuper@37906
   856
[[from sml:     <DELETED>
neuper@37906
   857
[[from sml:       <INTLIST>
neuper@37906
   858
[[from sml:       </INTLIST>
neuper@37906
   859
[[from sml:       <POS> Pbl </POS>
neuper@37906
   860
[[from sml:     </DELETED>
neuper@37906
   861
[[from sml:     <GENERATED>
neuper@37906
   862
[[from sml:       <INTLIST>
neuper@37906
   863
[[from sml:       </INTLIST>
neuper@37906
   864
[[from sml:       <POS> Met </POS>                           DIFFERENCE: Pbl
neuper@37906
   865
[[from sml:     </GENERATED>
neuper@37906
   866
[[from sml:   </CALCCHANGED>
neuper@37906
   867
[[from sml: </REPLACEFORMULA>
neuper@37906
   868
[[from sml: @@@@@end@@@@@*)
neuper@37906
   869
getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false(*              DIFFERENCE: Pbl*);
neuper@37906
   870
(*@@@@@begin@@@@@
neuper@37906
   871
 1
neuper@37906
   872
<GETELEMENTSFROMTO>
neuper@37906
   873
  <CALCID> 1 </CALCID>
neuper@37906
   874
  <FORMHEADS>
neuper@37906
   875
    <CALCFORMULA>
neuper@37906
   876
      <POSITION>
neuper@37906
   877
        <INTLIST>
neuper@37906
   878
        </INTLIST>
neuper@37906
   879
        <POS> Pbl </POS>
neuper@37906
   880
      </POSITION>
neuper@37906
   881
      <FORMULA>
neuper@37906
   882
        <MATHML>
neuper@37906
   883
          <ISA> Simplify (1 + 2) </ISA>                      WORKS !!!!!
neuper@37906
   884
        </MATHML>
neuper@37906
   885
      </FORMULA>
neuper@37906
   886
    </CALCFORMULA>
neuper@37906
   887
  </FORMHEADS>
neuper@37906
   888
</GETELEMENTSFROMTO>
neuper@37906
   889
@@@@@end@@@@@*)
neuper@37906
   890
getFormulaeFromTo 1 ([],Pbl) ([],Met) 0 false;
neuper@37906
   891
(*[[from sml: > @@@@@begin@@@@@
neuper@37906
   892
[[from sml:  1 
neuper@37906
   893
[[from sml: <SYSERROR>
neuper@37906
   894
[[from sml:   <CALCID> 1 </CALCID>
neuper@37906
   895
[[from sml:   <ERROR> error in getFormulaeFromTo </ERROR>
neuper@37906
   896
[[from sml: </SYSERROR>
neuper@37906
   897
[[from sml: @@@@@end@@@@@*)
neuper@37906
   898
(*step into getFormulaeFromTo --- bug corrected...*)
Walther@60571
   899
-----------------------------------------------------------------------------------------------*)
neuper@42423
   900
walther@59909
   901
"--------- build fun check_for' ------------------------------";
walther@59909
   902
"--------- build fun check_for' ------------------------------";
walther@59909
   903
"--------- build fun check_for' ------------------------------";
Walther@60660
   904
val subst = [(ParseC.parse_test @{context} "bdv", ParseC.parse_test @{context} "x")]: subst;
neuper@42423
   905
val rls = norm_Rational
Walther@60662
   906
val SOME pat = ParseC.patt_opt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
Walther@60660
   907
val (res, inf) = (ParseC.parse_test @{context} "(2 + 3)/(3 + 4)", ParseC.parse_test @{context} "2 / 4");
Walther@60660
   908
val (res, inf) = (ParseC.parse_test @{context} "(2 + 3)/(3 + 4)", ParseC.parse_test @{context} "1 / 2");
neuper@42423
   909
walther@60230
   910
val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern TermC.matches in res*)
Walther@60509
   911
  rew_sub ctxt 1 [] Rewrite_Ord.function_empty Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
neuper@42423
   912
if rewritten then NONE else SOME "e_errpatID";
neuper@42423
   913
Walther@60500
   914
val norm_res = case rewrite_set_ ctxt false rls res' of
neuper@42423
   915
  NONE => res'
neuper@42423
   916
| SOME (norm_res, _) => norm_res
neuper@42423
   917
Walther@60500
   918
val norm_inf = case rewrite_set_ ctxt false rls inf of
neuper@42423
   919
  NONE => inf
neuper@42423
   920
| SOME (norm_inf, _) => norm_inf;
neuper@42423
   921
neuper@42423
   922
res' = inf;
neuper@42423
   923
norm_res = norm_inf;
neuper@42423
   924
Walther@60662
   925
val SOME pat = ParseC.patt_opt @{theory} "(?a + ?b)/?a = ?b";
Walther@60660
   926
val (res, inf) = (ParseC.parse_test @{context} "(2 + 3)/2", ParseC.parse_test @{context} "3");
Walther@60523
   927
if check_for' ctxt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
neuper@42423
   928
then () else error "error patt example1 changed";
neuper@42423
   929
Walther@60662
   930
val SOME pat = ParseC.patt_opt @{theory} "(?a + ?b)/(?a + ?c) = ?b / ?c";
Walther@60660
   931
val (res, inf) = (ParseC.parse_test @{context} "(2 + 3)/(2 + 4)", ParseC.parse_test @{context} "3 / 4");
Walther@60523
   932
if check_for' ctxt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
neuper@42423
   933
then () else error "error patt example2 changed";
neuper@42423
   934
Walther@60662
   935
val SOME pat = ParseC.patt_opt @{theory} "(?a + ?b)/(?b + ?c) = ?a / ?c";
Walther@60660
   936
val (res, inf) = (ParseC.parse_test @{context} "(2 + 3)/(3 + 4)", ParseC.parse_test @{context} "2 / 4");
Walther@60523
   937
if check_for' ctxt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
neuper@42423
   938
then () else error "error patt example3 changed";
neuper@42423
   939
Walther@60660
   940
val inf =  ParseC.parse_test @{context} "1 / 2";
Walther@60523
   941
if check_for' ctxt (res, inf) subst ("errpatID", pat) rls = SOME "errpatID"
neuper@42423
   942
then () else error "error patt example3 changed";
neuper@42423
   943
walther@59909
   944
"--------- build fun check_for' ?bdv -------------------------";
walther@59909
   945
"--------- build fun check_for' ?bdv -------------------------";
walther@59909
   946
"--------- build fun check_for' ?bdv -------------------------";
Walther@60500
   947
val ctxt = Proof_Context.init_global @{theory}
Walther@60660
   948
val subst = [(ParseC.parse_test @{context} "bdv", ParseC.parse_test @{context} "x")]: subst;
Walther@60660
   949
val t = ParseC.parse_test @{context} "d_d x (x \<up> 2 + sin (x \<up> 4))";
Walther@60500
   950
val SOME (t, _) = rewrite_set_inst_ ctxt false subst norm_diff t;
Walther@60675
   951
if UnparseC.term @{context} t = "2 * x + cos (x \<up> 4) * 4 * x \<up> 3" then ()
walther@59909
   952
else error "build fun check_for' ?bdv changed 1"; 
neuper@42423
   953
neuper@42426
   954
val rls = norm_diff
Walther@60662
   955
val SOME pat = ParseC.patt_opt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)"; 
Walther@60660
   956
val (res, inf) = (ParseC.parse_test @{context} "2 * x + d_d x (sin (x \<up> 4))", ParseC.parse_test @{context} "2 * x + cos (4 * x \<up> 3)");
neuper@42426
   957
walther@60230
   958
val (res', _, _, rewritten) = (*rewritten: the lhs of the pattern TermC.matches in res*)
Walther@60509
   959
  rew_sub ctxt 1 subst Rewrite_Ord.function_empty Rule_Set.empty false [] (HOLogic.Trueprop $ pat) res;
Walther@60675
   960
if UnparseC.term @{context} res' = "2 * x + cos (d_d x (x \<up> 4))" andalso rewritten then ()
walther@59909
   961
else error "build fun check_for' ?bdv changed 2";
neuper@42426
   962
Walther@60500
   963
val norm_res = case rewrite_set_inst_ ctxt false subst rls  res' of
neuper@42426
   964
  NONE => res'
neuper@42426
   965
| SOME (norm_res, _) => norm_res;
Walther@60675
   966
if UnparseC.term @{context} norm_res = "2 * x + cos (4 * x \<up> 3)" then ()
walther@59909
   967
else error "build fun check_for' ?bdv changed 3";
neuper@42426
   968
Walther@60500
   969
val norm_inf = case rewrite_set_inst_ ctxt false subst rls inf of
neuper@42426
   970
  NONE => inf
neuper@42426
   971
| SOME (norm_inf, _) => norm_inf;
Walther@60675
   972
if UnparseC.term @{context} norm_inf = "2 * x + cos (4 * x \<up> 3)" then ()
walther@59909
   973
else error "build fun check_for' ?bdv changed 4";
neuper@42426
   974
neuper@42426
   975
res' = inf;
neuper@42426
   976
if norm_res = norm_inf then ()
walther@59909
   977
else error "build fun check_for' ?bdv changed 5";
neuper@42426
   978
Walther@60523
   979
if Error_Pattern.check_for' ctxt (res, inf) (subst: subst) ("errpatID": Error_Pattern.id, pat) rls = SOME "errpatID"
neuper@42426
   980
then () else error "error patt example1 changed";
neuper@42426
   981
walther@59909
   982
"--------- build fun check_for ------------------------";
walther@59909
   983
"--------- build fun check_for ------------------------";
walther@59909
   984
"--------- build fun check_for ------------------------";
neuper@42428
   985
val (res, inf) =
Walther@60660
   986
  (ParseC.parse_test @{context} "d_d x (x \<up> 2) + d_d x (sin (x \<up>  4))",
Walther@60660
   987
   ParseC.parse_test @{context} "d_d x (x \<up> 2) + cos (4 * x \<up> 3)");
Walther@60586
   988
val {errpats, rew_rls = rls, program = Prog prog, ...} = MethodC.from_store ctxt ["diff", "differentiate_on_R"]
neuper@42426
   989
Walther@60660
   990
val env = [(ParseC.parse_test @{context} "v_v", ParseC.parse_test @{context} "x")];
neuper@42428
   991
val errpats =
walther@59971
   992
  [Error_Pattern.empty, (*generalised for testing*)
neuper@42428
   993
   ("chain-rule-diff-both",
Walther@60662
   994
     [ParseC.patt_opt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)" |> the,
Walther@60662
   995
      ParseC.patt_opt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)" |> the,
Walther@60662
   996
      ParseC.patt_opt @{theory} "d_d ?bdv (?u \<up> ?n) = ?n * ?u \<up> (?n - 1)" |> the,
Walther@60662
   997
      ParseC.patt_opt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u" |> the,
Walther@60662
   998
      ParseC.patt_opt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u" |> the],
neuper@42428
   999
     [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain}, 
walther@59921
  1000
      @{thm diff_ln_chain}, @{thm  diff_exp_chain}])];
Walther@60523
  1001
case Error_Pattern.check_for ctxt (res, inf) (prog, env) (errpats, rls) of SOME _ => () 
walther@59844
  1002
| NONE => error "Error_Pattern.check_for broken";
wneuper@59252
  1003
DEconstrCalcTree 1;
neuper@42428
  1004
walther@59909
  1005
"--------- embed fun check_for ------------------------";
walther@59909
  1006
"--------- embed fun check_for ------------------------";
walther@59909
  1007
"--------- embed fun check_for ------------------------";
Walther@60549
  1008
States.reset ();     
Walther@60571
  1009
CalcTree @{context}
walther@60242
  1010
[(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"], 
walther@59997
  1011
  ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
neuper@42428
  1012
Iterator 1;
neuper@42428
  1013
moveActiveRoot 1;
wneuper@59248
  1014
autoCalculate 1 CompleteCalcHead;
walther@59747
  1015
autoCalculate 1 (Steps 1);
walther@60242
  1016
autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
walther@60242
  1017
(*autoCalculate 1 (Steps 1);([2], Res), d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> \<up>  4)*)
neuper@42428
  1018
walther@60242
  1019
"~~~~~ fun appendFormula , args:"; val (cI, (ifo:TermC.as_string)) = (1, "d_d x (x \<up> 2) + cos (4 * x \<up> 3)");
walther@59868
  1020
"~~~~~ fun appendFormula' , args:"; val (cI, (ifo: TermC.as_string)) = (cI, ifo);
Walther@60549
  1021
    val cs = States.get_calc cI
Walther@60549
  1022
    val pos = States.get_pos cI 1;
walther@59844
  1023
(*+*)if pos = ([1], Res) then () else error "inform with (positive) Error_Pattern.check_for broken 1";
walther@59798
  1024
    val ("ok", cs' as (_, _, ptp)) = (*case*) Step.do_next pos cs (*of*);
walther@59798
  1025
      (*case*) Step_Solve.by_term ptp (encode ifo) (*of*); (*ERROR WAS: "no derivation found"*)
walther@59981
  1026
"~~~~~ fun Step_Solve.by_term , args:"; val (((*next_*)cs as (_, _, (pt, pos as (p, _))): Calc.state_post), istr)
wneuper@59562
  1027
  = (cs', (encode ifo));
wneuper@59562
  1028
    val ctxt = get_ctxt pt pos (*see TODO.thy*)
Walther@60663
  1029
    val SOME f_in = (*case*) ParseC.term_opt ctxt istr (*of*);
wneuper@59562
  1030
        val pos_pred = lev_back' pos
wneuper@59562
  1031
    	  val f_pred = Ctree.get_curr_formula (pt, pos_pred);
wneuper@59562
  1032
        (*if*) f_pred = f_in; (*else*)
walther@59982
  1033
          val NONE = (*case*) CAS_Cmd.input f_in (*of*);
walther@59795
  1034
       (*old* )val (_, _, metID) = get_obj g_spec pt (par_pblobj pt p)
Walther@60586
  1035
       (*old*)val {program = prog, ...} = MethodC.from_store ctxt metID
walther@59807
  1036
       (*old*)val istate = get_istate_LI pt pos
walther@59795
  1037
       (*old*)val ctxt = get_ctxt pt pos
walther@59795
  1038
       ( *old*)
walther@59795
  1039
       val LI.Not_Derivable =
walther@59795
  1040
             (*case*) LI.locate_input_term (pt, pos) f_in (*of*);
Walther@60631
  1041
                val met_id = Ctree.get_obj Ctree.g_metID pt (Ctree.par_pblobj pt p)
Walther@60631
  1042
            		  val (errpats, rew_rls, prog) = case MethodC.from_store' (Know_Store.get_via_last_thy "Build_Thydata") met_id of
Walther@60586
  1043
              		    {errpats, rew_rls, program = Rule.Prog prog, ...} => (errpats, rew_rls, prog)
Walther@60559
  1044
              		  | _ => error "inform: uncovered case of MethodC.from_store ctxt"
wneuper@59562
  1045
;
Walther@60648
  1046
(*+*)if Error_Pattern.s_to_string ctxt errpats = "[(\"chain-rule-diff-both\",\n[d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u), d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u), d_d ?bdv (?u \<up> ?n) = ?n * ?u \<up> (?n - 1)],\n[\"d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u\", \"d_d ?bdv (cos ?u) = - sin ?u * d_d ?bdv ?u\", \"d_d ?bdv (?u \<up> ?n) = ?n * ?u \<up> (?n - 1) * d_d ?bdv ?u\"]]"
walther@59844
  1047
(*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 3";
neuper@42428
  1048
walther@59807
  1049
            		  val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
wneuper@59562
  1050
;
Walther@60675
  1051
(*+*)if UnparseC.term @{context} f_pred = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" andalso
Walther@60675
  1052
(*+*)   UnparseC.term @{context} f_in = "d_d x (x \<up> 2) + cos (4 * x \<up> 3)"
walther@59844
  1053
(*+*)then () else error "inform with (positive) Error_Pattern.check_for broken 2";
neuper@42428
  1054
Walther@60586
  1055
             val SOME "chain-rule-diff-both" = (*case*) Error_Pattern.check_for ctxt (f_pred, f_in) (prog, env) (errpats, rew_rls) (*of*);
neuper@42428
  1056
neuper@42428
  1057
"--- final check:";
walther@59798
  1058
(*+*)val (_, _, ptp') = cs';
walther@59798
  1059
case Step_Solve.by_term ptp' (encode ifo) of
neuper@42428
  1060
  ("error pattern #chain-rule-diff-both#", calcstate') => ()
walther@59844
  1061
| _ => error "inform with (positive) Error_Pattern.check_for broken"
neuper@42428
  1062
neuper@48895
  1063
Walther@60631
  1064
"----------- re-build: fill_from_store without thy-hierarchy -----------------------------------";
Walther@60631
  1065
"----------- re-build: fill_from_store without thy-hierarchy -----------------------------------";
Walther@60631
  1066
"----------- re-build: fill_from_store without thy-hierarchy -----------------------------------";
Walther@60631
  1067
open Error_Pattern
Walther@60631
  1068
val c = []: int list
Walther@60631
  1069
val (p,_,f,nxt,_,pt) = Test_Code.init_calc @{context}
Walther@60631
  1070
[(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"], 
Walther@60631
  1071
  ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
Walther@60631
  1072
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60631
  1073
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60631
  1074
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60631
  1075
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60631
  1076
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60631
  1077
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60631
  1078
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Apply_Method ["diff", "differentiate_on_R"]*)
Walther@60631
  1079
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Rewrite_Inst (["(''bdv'', x)"], ("diff_sum", "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v"))*)
Walther@60631
  1080
  val ([1], Frm) = p;
Walther@60631
  1081
  val "d_d x (x \<up> 2 + sin (x \<up> 4))" = f2str f;
Walther@60631
  1082
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Rewrite_Inst (["(''bdv'', x)"], ("diff_sin_chain", "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u"))*)
Walther@60631
  1083
  val ([1], Res) = p;
Walther@60631
  1084
  val "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" = f2str f
Walther@60631
  1085
Walther@60631
  1086
val return_of_me     = me nxt p c pt; (*nxt = Rewrite_Inst (["(''bdv'', x)"], ("diff_pow", "d_d ?bdv (?bdv \<up> ?n) = ?n * ?bdv \<up> (?n - 1)"))*)
Walther@60631
  1087
  val ([1], Res) = p
Walther@60631
  1088
  val "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" = f2str f;
Walther@60631
  1089
  (*  "d_d x (x \<up> 2) +        cos (x \<up> 4)" .. wrong user input within next step *)
Walther@60631
  1090
(*//------------------ step into find_fill_patterns ----------------------------------------\\*)
Walther@60631
  1091
(* INSTEAD OF STEPPING INTO me WE DO SO FOR Kernel.findFillpatterns cI errpatID =
Walther@60631
  1092
  let
Walther@60631
  1093
    val ((pt, _), _) = States.get_calc cI
Walther@60631
  1094
		val pos = States.get_pos cI 1;
Walther@60631
  1095
		val fillpats = Error_Pattern.find_fill_patterns (pt, pos) errpatID
Walther@60631
  1096
*)
Walther@60631
  1097
"~~~~~ fun findFillpatterns , args:"; val (pt, p, errpatID) = (pt, p, "chain-rule-diff-both");
Walther@60631
  1098
"~~~~~ fun find_fill_patterns , args:"; val ((pt, pos as (p, _)), id) = ((pt, p), errpatID);
Walther@60631
  1099
(*old-------\* )
Walther@60631
  1100
    val f_curr = Ctree.get_curr_formula (pt, pos);
Walther@60631
  1101
    val pp = Ctree.par_pblobj pt p
Walther@60631
  1102
    val (errpats, prog) = case MethodC.from_store ctxt (Ctree.get_obj Ctree.g_metID pt pp) of
Walther@60631
  1103
      {errpats, program = Rule.Prog prog, ...} => (errpats, prog)
Walther@60631
  1104
    | _ => error "find_fill_patterns: uncovered case of MethodC.from_store ctxt"
Walther@60631
  1105
( *new-------\*)
Walther@60631
  1106
    val ctxt = Ctree.get_ctxt pt pos
Walther@60631
  1107
    val f_curr = Ctree.get_curr_formula (pt, pos)
Walther@60631
  1108
    val met_id = Ctree.get_obj Ctree.g_metID pt (Ctree.par_pblobj pt p)
Walther@60631
  1109
    val (errpats, prog) = case MethodC.from_store' (Know_Store.get_via_last_thy "Build_Thydata") met_id of
Walther@60631
  1110
      {errpats, program = Rule.Prog prog, ...} => (errpats, prog)
Walther@60631
  1111
    | _ => error "find_fill_patterns: uncovered case of MethodC.from_store ctxt"
Walther@60631
  1112
(*new-------/*)
Walther@60631
  1113
Walther@60631
  1114
(*+*)val 1 = length errpats(*ONLY WITH from_store' @{theory (*!!!*)Build_Thydata}*)
Walther@60631
  1115
    val {env, ...} = Ctree.get_istate_LI pt pos |> Istate.the_pstate
Walther@60631
  1116
    val subst = Subst.for_bdv ctxt prog env
Walther@60631
  1117
    val errpatthms = errpats
Walther@60631
  1118
      |> filter ((curry op = errpatID) o (#1: Error_Pattern.T -> Error_Pattern.id))
Walther@60631
  1119
      |> map (#3: Error_Pattern.T -> thm list)
Walther@60631
  1120
      |> flat;
Walther@60631
  1121
Walther@60631
  1122
(*+*)val 3 = length errpatthms;
Walther@60631
  1123
(*+*)val 5 = length (get_fill_ins @{theory} "diff_sin_chain");
Walther@60631
  1124
Walther@60631
  1125
(*case*) map (
Walther@60631
  1126
           fill_from_store ctxt subst f_curr errpatID) errpatthms |> flat (*of*);
Walther@60631
  1127
"~~~~~ fun fill_from_store , args:"; val (ctxt, subst, form, (*id*)errpat_id, thm) =
Walther@60631
  1128
  (ctxt, subst, f_curr, errpatID, hd errpatthms);
Walther@60631
  1129
    val thm_id_long = Thm.get_name_hint thm
Walther@60631
  1130
Walther@60631
  1131
(*+*)val "Diff.diff_sin_chain" = thm_id_long;
Walther@60681
  1132
(*+*)val "diff_sin_chain" = ThmC.cut_longid thm_id_long;
Walther@60631
  1133
Walther@60681
  1134
    val thm_id = ThmC.cut_longid thm_id_long
Walther@60631
  1135
    val fill_ins =
Walther@60631
  1136
Walther@60631
  1137
Error_Pattern.get_fill_ins (Proof_Context.theory_of ctxt) thm_id;
Walther@60631
  1138
"~~~~~ fun get_fill_ins , args:"; val (thy, thm_id) =
Walther@60631
  1139
  ((Proof_Context.theory_of ctxt), thm_id);
Walther@60631
  1140
  (*case*) AList.lookup (op =) (get_fill_inss thy) thm_id (*of*);
Walther@60631
  1141
val ERROR "fill_ins for thm \"diff_sin_chain\" missing in theory \"Isac_Knowledge\" (and ancestors)\nTODO exception hierarchy needs to be established." =
Walther@60631
  1142
  ERROR ("fill_ins for thm \"" ^ thm_id ^ "\" missing in theory \"" ^ 
Walther@60631
  1143
    (thy |> ThyC.id_of) ^ "\" (and ancestors)" ^
Walther@60631
  1144
    "\nTODO exception hierarchy needs to be established.");
Walther@60631
  1145
Walther@60631
  1146
(*return to fill_from_store..*)
Walther@60631
  1147
    val some = map (fill_form ctxt subst (thm, form) errpat_id) fill_ins;
Walther@60631
  1148
val return_fill_from_store = some |> filter is_some |> map the;
Walther@60631
  1149
Walther@60631
  1150
(* final test ... ----------------------------------------------------------------------------*)
Walther@60631
  1151
(*+*)if length return_fill_from_store = 5 then
Walther@60631
  1152
(*+*)  case return_fill_from_store of
Walther@60675
  1153
(*+*)    ("fill-d_d-arg", tm, thm, subsopt) :: _ => if UnparseC.term @{context} tm = 
Walther@60631
  1154
(*+*)      "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) =\nd_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1"
Walther@60631
  1155
(*+*)      then () else error "find_fill_patterns changed 2a"
Walther@60631
  1156
(*+*)  | _ => error "find_fill_patterns changed 2b"
Walther@60631
  1157
(*+*)else error "find_fill_patterns changed 2c";
Walther@60631
  1158
(*-------------------- stop step into find_fill_patterns -------------------------------------*)
Walther@60631
  1159
(*\\------------------ step into find_fill_patterns ----------------------------------------//*)
Walther@60631
  1160
Walther@60631
  1161
val (p,_,f,nxt,_,pt) = return_of_me
Walther@60631
  1162
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Rewrite_Inst (["(''bdv'', x)"], ("diff_pow", "d_d ?bdv (?bdv \<up> ?n) = ?n * ?bdv \<up> (?n - 1)"))*)
Walther@60631
  1163
  val ([3], Res) = p
Walther@60631
  1164
  val "d_d x (x \<up> 2) + cos (x \<up> 4) * (4 * x \<up> (4 - 1))" = f2str f;
Walther@60631
  1165
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60631
  1166
val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = Check_Postcond ["derivative_of", "function"]*)
Walther@60631
  1167
val (p,_,f,nxt,_,pt) = me nxt p c pt;
Walther@60631
  1168
  val ([], Res) = p;
Walther@60631
  1169
  val "2 * x + cos (x \<up> 4) * 4 * x \<up> 3" = f2str f
Walther@60631
  1170
  val End_Proof' = nxt;
Walther@60631
  1171
Walther@60631
  1172
walther@59909
  1173
"--------- embed fun find_fill_patterns ---------------------------";
walther@59909
  1174
"--------- embed fun find_fill_patterns ---------------------------";
walther@59909
  1175
"--------- embed fun find_fill_patterns ---------------------------";
Walther@60549
  1176
States.reset ();
Walther@60571
  1177
CalcTree @{context}
walther@60242
  1178
[(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"], 
walther@59997
  1179
  ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
neuper@42430
  1180
Iterator 1;
neuper@42430
  1181
moveActiveRoot 1;
wneuper@59248
  1182
autoCalculate 1 CompleteCalcHead;
walther@59747
  1183
autoCalculate 1 (Steps 1);
walther@60242
  1184
autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
Walther@60631
  1185
appendFormula 1 "d_d x (x \<up> 2) + cos (4 * x \<up> 3)";
neuper@42430
  1186
  (*<CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>*)
neuper@42432
  1187
  (*or
neuper@42432
  1188
    <CALCMESSAGE> no derivation found </CALCMESSAGE>*)
neuper@42433
  1189
"~~~~~ fun findFillpatterns, args:"; val (cI, errpatID) = (1, "chain-rule-diff-both");
Walther@60549
  1190
  val ((pt, _), _) = States.get_calc cI
Walther@60549
  1191
				val pos = States.get_pos cI 1;
neuper@42430
  1192
Walther@60631
  1193
val return_from_find_fill_patterns = find_fill_patterns (pt, pos) errpatID;
Walther@60631
  1194
DEconstrCalcTree 1;
neuper@42430
  1195
Walther@60631
  1196
(* final test ... ----------------------------------------------------------------------------*)
Walther@60631
  1197
val 6 = length return_from_find_fill_patterns
Walther@60631
  1198
val (fill_in_id, term, thm, subst) :: _ = return_from_find_fill_patterns
neuper@42430
  1199
Walther@60631
  1200
val "fill-d_d-arg" = fill_in_id
Walther@60631
  1201
val "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4)) =\nd_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1" =
Walther@60675
  1202
  UnparseC.term @{context} term
Walther@60631
  1203
val "Diff.diff_sin_chain" = Thm.get_name_hint thm
Walther@60631
  1204
val "[(''bdv'', x)]" = subst |> the |> Subst.string_of_input;
neuper@42430
  1205
neuper@42450
  1206
neuper@42437
  1207
"--------- build fun is_exactly_equal, inputFillFormula ----------";
neuper@42437
  1208
"--------- build fun is_exactly_equal, inputFillFormula ----------";
neuper@42437
  1209
"--------- build fun is_exactly_equal, inputFillFormula ----------";
Walther@60549
  1210
States.reset ();
Walther@60571
  1211
CalcTree @{context}
walther@60242
  1212
[(["functionTerm (x \<up> 2 + sin (x \<up> 4))", "differentiateFor x", "derivative f_f'"], 
walther@59997
  1213
  ("Isac_Knowledge", ["derivative_of", "function"], ["diff", "differentiate_on_R"]))];
neuper@42437
  1214
Iterator 1;
neuper@42437
  1215
moveActiveRoot 1;
wneuper@59248
  1216
autoCalculate 1 CompleteCalcHead;
walther@59747
  1217
autoCalculate 1 (Steps 1);
walther@60242
  1218
autoCalculate 1 (Steps 1);(*([1], Res), d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))*)
walther@60242
  1219
appendFormula 1 "d_d x (x \<up> 2) + cos (4 * x \<up> 3)" (*|> Future.join*); (*<<<<<<<=========================*)
Walther@60586
  1220
(* the check for errpat is maximally liberal (whole term modulo "rew_rls" from "type met"),
walther@60242
  1221
  would recognize "cos (4 * x \<up> (4 - 1)) + 2 * x" as well.
neuper@42437
  1222
  results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
neuper@42437
  1223
  instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
Walther@60549
  1224
  val ((pt,pos), _) = States.get_calc 1;
Walther@60549
  1225
  val p = States.get_pos 1 1;
Walther@60577
  1226
  val (Form f, _, asms) = ME_Misc.pt_extract ctxt (pt, p);
neuper@42437
  1227
Walther@60675
  1228
  if p = ([1], Res) andalso UnparseC.term @{context} f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" then
wneuper@59497
  1229
    case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"], 
wneuper@59253
  1230
      ("diff_sum", thm)) =>
Walther@60675
  1231
      if (UnparseC.term @{context} o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
walther@59909
  1232
      else error "embed fun fill_form changed 11"
walther@59909
  1233
    | _ => error "embed fun fill_form changed 12"
walther@59909
  1234
  else error "embed fun fill_form changed 13";
neuper@42437
  1235
neuper@42437
  1236
findFillpatterns 1 "chain-rule-diff-both"; (*<<<<<<<=================================*)
walther@60242
  1237
(*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x \<up> 2) + d_d x (sin (x \<up>  4)) =
walther@60242
  1238
  d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
Walther@60549
  1239
  val ((pt,pos),_) = States.get_calc 1;
Walther@60549
  1240
  val p = States.get_pos 1 1;
neuper@42437
  1241
Walther@60577
  1242
  val (Form f, _, asms) = ME_Misc.pt_extract ctxt (pt, p);
Walther@60675
  1243
  if p = ([1], Res) andalso UnparseC.term @{context} f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))" then
wneuper@59497
  1244
    case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"], 
wneuper@59253
  1245
      ("diff_sum", thm)) =>
Walther@60675
  1246
      if (UnparseC.term @{context} o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
walther@59909
  1247
      else error "embed fun fill_form changed 21"
walther@59909
  1248
    | _ => error "embed fun fill_form changed 22"
walther@59909
  1249
  else error "embed fun fill_form changed 23";
neuper@42437
  1250
neuper@42437
  1251
requestFillformula 1 ("chain-rule-diff-both", "fill-both-args");(*<<<<<<<============*)
neuper@42437
  1252
  (*<AUTOCALC> ([1], Res) ([2], Res) ([2], Res) </AUTOCALC>*)
Walther@60549
  1253
  val ((pt,pos),_) = States.get_calc 1;
Walther@60549
  1254
  val p = States.get_pos 1 1;
Walther@60577
  1255
  val (Form f, _, asms) = ME_Misc.pt_extract ctxt (pt, p);
wneuper@59253
  1256
  if p = ([1], Res) andalso existpt [2] pt
Walther@60675
  1257
    andalso UnparseC.term @{context} f = "d_d x (x \<up> 2) + d_d x (sin (x \<up> 4))"
wneuper@59497
  1258
  then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"], 
wneuper@59253
  1259
      ("diff_sum", thm)) =>
Walther@60675
  1260
      if (UnparseC.term @{context} o Thm.prop_of) thm = "d_d ?bdv (?u + ?v) = d_d ?bdv ?u + d_d ?bdv ?v" then ()
walther@59909
  1261
      else error "embed fun fill_form changed 31"
walther@59909
  1262
    | _ => error "embed fun fill_form changed 32"
walther@59909
  1263
  else error "embed fun fill_form changed 33";
neuper@42437
  1264
neuper@42437
  1265
(* input a formula which exactly fills the gaps in a "fillformula"
neuper@42437
  1266
   presented to the learner immediately before by "requestFillformula (errpatID, fillpatID)":
neuper@42437
  1267
   errpatID: lhs of the respective thm = lhs of fillformula with fillpatID.
neuper@42437
  1268
   the respective thm is in the ctree ................
neuper@42437
  1269
*)
neuper@42437
  1270
"~~~~~ fun inputFillFormula, args:"; val (cI, ifo) =
walther@60242
  1271
  (1, "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)");
Walther@60549
  1272
    val ((pt, _), _) = States.get_calc cI
Walther@60549
  1273
    val pos = States.get_pos cI 1;
neuper@42437
  1274
neuper@42437
  1275
"~~~~~ fun is_exactly_equal, args:"; val ((pt, pos as (p, p_)), istr) = ((pt, pos), ifo);
Walther@60676
  1276
  val SOME ifo = ParseC.term_opt (ThyC.get_theory @{context} "Isac_Knowledge" |> Proof_Context.init_global) istr
neuper@42437
  1277
  val p' = lev_on p;
neuper@42437
  1278
  val tac = get_obj g_tac pt p';
wneuper@59497
  1279
val Rewrite_Inst ([bbb as "(''bdv'', x)"], ("diff_sin_chain", ttt)) = tac;
Walther@60675
  1280
if (UnparseC.term @{context} o Thm.prop_of) ttt = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
wneuper@59252
  1281
else error "inputFillFormula changed 10";
walther@59921
  1282
  val Applicable.Yes rew = Step.check tac (pt, pos);
neuper@42437
  1283
  val Rewrite_Inst' (_, _, _, _, _, _, _, (res, _)) = rew;
neuper@42437
  1284
neuper@42437
  1285
"~~~~~ to inputFillFormula return val:"; val ("ok", tac) = ("ok", tac);
walther@59804
  1286
  val ("ok", (_, c, ptp as (_,p'))) = Step.by_tactic tac (pt, pos);
Walther@60549
  1287
    States.upd_calc cI (ptp, []);
Walther@60549
  1288
    States.upd_ipos cI 1 p';
neuper@42437
  1289
    autocalculateOK2xml cI pos (if null c then p' else last_elem c) p';
neuper@42437
  1290
neuper@42437
  1291
"~~~~~ final check:";
Walther@60549
  1292
val ((pt, _),_) = States.get_calc 1;
Walther@60549
  1293
val p = States.get_pos 1 1;
Walther@60577
  1294
val (Form f, _, asms) = ME_Misc.pt_extract ctxt (pt, p);
Walther@60675
  1295
  if p = ([2], Res) andalso UnparseC.term @{context} f = "d_d x (x \<up> 2) + cos (x \<up> 4) * d_d x (x \<up> 4)"
wneuper@59497
  1296
  then case get_obj g_tac pt (fst p) of Rewrite_Inst (["(''bdv'', x)"], 
wneuper@59253
  1297
      ("diff_sin_chain", thm)) =>
Walther@60675
  1298
      if (UnparseC.term @{context} o Thm.prop_of) thm = "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv ?u" then ()
wneuper@59253
  1299
      else error "inputFillFormula changed 111"
wneuper@59253
  1300
    | _ => error "inputFillFormula changed 112"
wneuper@59253
  1301
  else error "inputFillFormula changed 113";
neuper@42437
  1302
wneuper@59262
  1303
"--------- fun appl_adds -----------------------------------------";
wneuper@59262
  1304
"--------- fun appl_adds -----------------------------------------";
wneuper@59262
  1305
"--------- fun appl_adds -----------------------------------------";
Walther@60586
  1306
(* val (dI, oris, model, pbt, selct::ss) = 
Walther@60586
  1307
       (dI, pors, probl, model, map itms2fstr probl);
wneuper@59262
  1308
   ...vvv
wneuper@59262
  1309
   *)
Walther@60586
  1310
(* val (dI, oris, model, pbt, (selct::ss))=
Walther@60777
  1311
       (#1 (References.select_input ospec spec), oris, []:I_Model.T_POS,
Walther@60586
  1312
	((#model o Problem.from_store) (#2 (References.select_input ospec spec))),(imodel2fstr imodel));
Walther@60586
  1313
   val iii = appl_adds dI oris model pbt (selct::ss); 
walther@59942
  1314
   tracing(I_Model.to_string thy iii);
wneuper@59262
  1315
Walther@60586
  1316
 val itm = add_single' dI oris model pbt selct;
Walther@60586
  1317
 val model = I_Model.add itm model;
wneuper@59262
  1318
wneuper@59262
  1319
 val _::selct::ss = (selct::ss);
Walther@60586
  1320
 val itm = add_single' dI oris model pbt selct;
Walther@60586
  1321
 val model = I_Model.add itm model;
wneuper@59262
  1322
wneuper@59262
  1323
 val _::selct::ss = (selct::ss);
Walther@60586
  1324
 val itm = add_single' dI oris model pbt selct;
Walther@60586
  1325
 val model = I_Model.add itm model;
Walther@60586
  1326
 tracing(I_Model.to_string thy model);
wneuper@59262
  1327
wneuper@59262
  1328
 val _::selct::ss = (selct::ss);
Walther@60586
  1329
 val itm = add_single' dI oris model pbt selct;
Walther@60586
  1330
 val model = I_Model.add itm model;
wneuper@59262
  1331
   *)
wneuper@59264
  1332
"--------- fun concat_deriv --------------------------------------";
wneuper@59264
  1333
"--------- fun concat_deriv --------------------------------------";
wneuper@59264
  1334
"--------- fun concat_deriv --------------------------------------";
wneuper@59264
  1335
(*
Walther@60586
  1336
 val ({rew_ord, asm_rls, rules,...}, fo, ifo) = 
Walther@60660
  1337
     (Rule_Set.rep Test_simplify, ParseC.parse_test @{context} "x+1+ - 1*2=0", ParseC.parse_test @{context} "-2*1+(x+1)=0");
walther@59906
  1338
 (tracing o Derive.trtas2str) fod';
wneuper@59264
  1339
> ["
walther@60324
  1340
(x + 1 + - 1 * 2 = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (x + 1) = 0, []))", "
walther@60324
  1341
(- 1 * 2 + (x + 1) = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (1 + x) = 0, []))", "
walther@60324
  1342
(- 1 * 2 + (1 + x) = 0, Thm ("radd_left_commute", "?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (- 1 * 2 + x) = 0, []))", "
walther@60324
  1343
(1 + (- 1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))", "- 1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
wneuper@59264
  1344
val it = () : unit
walther@59906
  1345
 (tracing o Derive.trtas2str) (map Derive.rev_deriv' rifod');
wneuper@59264
  1346
> ["
walther@59997
  1347
(1 + (-2 + x) = 0, Thm ("sym_#mult_Float ((~2,0), (0,0)) __ ((1,0), (0,0))", "-2 = -2 * 1"), (1 + (-2 * 1 + x) = 0, []))", "
walther@59997
  1348
(1 + (-2 * 1 + x) = 0, Thm ("sym_radd_left_commute", "?y + (?x + ?z) = ?x + (?y + ?z)"), (-2 * 1 + (1 + x) = 0, []))", "
walther@59997
  1349
(-2 * 1 + (1 + x) = 0, Thm ("sym_radd_commute", "?n + ?m = ?m + ?n"), (-2 * 1 + (x + 1) = 0, []))"]
wneuper@59264
  1350
val it = () : unit
wneuper@59264
  1351
*)
wneuper@59264
  1352
"--------- handle an input formula -------------------------------";
wneuper@59264
  1353
"--------- handle an input formula -------------------------------";
wneuper@59264
  1354
"--------- handle an input formula -------------------------------";
wneuper@59264
  1355
(*
wneuper@59264
  1356
Untersuchung zur Formeleingabe (appendFormula, replaceFormla) zu einer Anregung von Alan Krempler:
wneuper@59264
  1357
Welche RICHTIGEN Formeln koennen NICHT abgeleitet werden, 
wneuper@59264
  1358
wenn Abteilungen nur auf gleichem Level gesucht werden ?
wneuper@59264
  1359
WN.040216 
wneuper@59264
  1360
wneuper@59264
  1361
Beispiele zum Equationsolver von Richard Lang aus /src/sml/kbtest/rlang.sml
wneuper@59264
  1362
wneuper@59264
  1363
------------------------------------------------------------------------------
wneuper@59264
  1364
"Schalk I s.87 Bsp 52a ((5*x)/(x - 2) - x/(x+2)=4)";
wneuper@59264
  1365
------------------------------------------------------------------------------
wneuper@59264
  1366
1. "5 * x / (x - 2) - x / (x + 2) = 4"
wneuper@59264
  1367
...
walther@60242
  1368
4. "12 * x + 4 * x \<up> 2 = 4 * (-4 + x \<up> 2)",Subproblem["normalise", "poly"..
wneuper@59264
  1369
...
wneuper@59264
  1370
4.3. "16 + 12 * x = 0", Subproblem["degree_1", "polynomial", "univariate"..
wneuper@59264
  1371
...
wneuper@59264
  1372
4.3.3. "[x = -4 / 3]")), Check_elementwise "Assumptions"
wneuper@59264
  1373
...
wneuper@59264
  1374
"[x = -4 / 3]"
wneuper@59264
  1375
------------------------------------------------------------------------------
wneuper@59264
  1376
(1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
wneuper@59264
  1377
wneuper@59264
  1378
(4.1)..(4.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 4.3.n]
wneuper@59264
  1379
------------------------------------------------------------------------------
wneuper@59264
  1380
wneuper@59264
  1381
wneuper@59264
  1382
------------------------------------------------------------------------------
walther@60242
  1383
"Schalk I s.87 Bsp 55b (x/(x \<up> 2 - 6*x+9) - 1/(x \<up> 2 - 3*x) =1/x)";
wneuper@59264
  1384
------------------------------------------------------------------------------
walther@60242
  1385
1. "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) = 1 / x"
wneuper@59264
  1386
...
walther@60324
  1387
4. "(3 + (- 1 * x + x \<up> 2)) * x = 1 * (9 * x + (x \<up> 3 + -6 * x \<up> 2))"
wneuper@59367
  1388
                         Subproblem["normalise", "polynomial", "univariate"..
wneuper@59264
  1389
...
walther@60242
  1390
4.4. "-6 * x + 5 * x \<up> 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
wneuper@59264
  1391
...
wneuper@59264
  1392
4.4.4. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
wneuper@59264
  1393
4.4.5. "[x = 0, x = 6 / 5]"
wneuper@59264
  1394
...
wneuper@59264
  1395
5. "[x = 0, x = 6 / 5]", Check_elementwise "Assumptions"
wneuper@59264
  1396
   "[x = 6 / 5]"
wneuper@59264
  1397
------------------------------------------------------------------------------
wneuper@59264
  1398
(1)..(4): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite schiebt [Ableitung waere in 4.4.x]
wneuper@59264
  1399
wneuper@59264
  1400
(4.1)..(4.4.5): keine 'richtige' Eingabe kann abgeleitet werden, die dem Ergebnis "[x = 6 / 5]" aequivalent ist [Ableitung waere in 5.]
wneuper@59264
  1401
------------------------------------------------------------------------------
wneuper@59264
  1402
wneuper@59264
  1403
wneuper@59264
  1404
------------------------------------------------------------------------------
wneuper@59264
  1405
"Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
wneuper@59264
  1406
------------------------------------------------------------------------------
wneuper@59264
  1407
1. "sqrt (x + 1) + sqrt (4 * x + 4) = sqrt (9 * x + 9)"
wneuper@59264
  1408
...
wneuper@59264
  1409
6. "13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"
wneuper@59489
  1410
                             Subproblem["sq", "rootX", "univariate", "equation"]
wneuper@59264
  1411
...
walther@60242
  1412
6.6. "144 + 288 * x + 144 * x \<up> 2 = 144 + x \<up> 2 + 288 * x + 143 * x \<up> 2"
wneuper@59367
  1413
                Subproblem["normalise", "polynomial", "univariate", "equation"]
walther@60242
  1414
...6.6.3 "0 = 0"    Subproblem["degree_0", "polynomial", "univariate", "equation"]
wneuper@59264
  1415
...                                       Or_to_List
wneuper@59264
  1416
6.6.3.2 "UniversalList"
wneuper@59264
  1417
------------------------------------------------------------------------------
wneuper@59264
  1418
(1)..(6): keine 'richtige' Eingabe kann abgeleitet werden, die eine der Wurzeln auf die andere Seite verschieb [Ableitung ware in 6.6.n]
wneuper@59264
  1419
wneuper@59264
  1420
(6.1)..(6.3): keine 'richtige' Eingabe kann abgeleitet werden, die einen Summanden auf die andere Seite verschiebt [Ableitung ware in 6.6.n]
wneuper@59264
  1421
------------------------------------------------------------------------------
wneuper@59264
  1422
*)
wneuper@59264
  1423
(*sh. comments auf 498*)
wneuper@59264
  1424
"--------- fun dropwhile' ----------------------------------------";
wneuper@59264
  1425
"--------- fun dropwhile' ----------------------------------------";
wneuper@59264
  1426
"--------- fun dropwhile' ----------------------------------------";
wneuper@59264
  1427
(*
wneuper@59264
  1428
 fun equal a b = a=b;
wneuper@59264
  1429
 val foder = [0,1,2,3,4,5]; val ifoder = [11,12,3,4,5];
wneuper@59264
  1430
 val r_foder = rev foder;  val r_ifoder = rev ifoder;
wneuper@59264
  1431
 dropwhile' equal r_foder r_ifoder;
wneuper@59264
  1432
> vval it = ([0, 1, 2, 3], [3, 12, 11]) : int list * int list
wneuper@59264
  1433
wneuper@59264
  1434
 val foder = [3,4,5]; val ifoder = [11,12,3,4,5];
wneuper@59264
  1435
 val r_foder = rev foder;  val r_ifoder = rev ifoder;
wneuper@59264
  1436
 dropwhile' equal r_foder r_ifoder;
wneuper@59264
  1437
> val it = ([3], [3, 12, 11]) : int list * int list
wneuper@59264
  1438
wneuper@59264
  1439
 val foder = [5]; val ifoder = [11,12,3,4,5];
wneuper@59264
  1440
 val r_foder = rev foder;  val r_ifoder = rev ifoder;
wneuper@59264
  1441
 dropwhile' equal r_foder r_ifoder;
wneuper@59264
  1442
> val it = ([5], [5, 4, 3, 12, 11]) : int list * int list
wneuper@59264
  1443
wneuper@59264
  1444
 val foder = [10,11,12,13,14,15]; val ifoder = [11,12,3,4,5];
wneuper@59264
  1445
 val r_foder = rev foder;  val r_ifoder = rev ifoder;
wneuper@59264
  1446
 dropwhile' equal r_foder r_ifoder;
wneuper@59264
  1447
> *** dropwhile': did not start with equal elements*)