452 handle _ => NONE) |
454 handle _ => NONE) |
453 | eval_factors_from_solution _ _ _ _ = NONE; |
455 | eval_factors_from_solution _ _ _ _ = NONE; |
454 *} |
456 *} |
455 |
457 |
456 text {*\noindent The tracing output of the calc tree after applying this |
458 text {*\noindent The tracing output of the calc tree after applying this |
457 function was \ttfamily 24 / factors\_from\_solution |
459 function was: |
458 [z = 1/ 2, z = -1 / 4])] \normalfont and the next step \ttfamily |
460 \begin{verbatim} |
459 val nxt = ("Empty\_Tac", ...): tac'\_)\normalfont. These observations |
461 24 / factors_from_solution [z = 1/ 2, z = -1 / 4])] |
460 indicate, that the Lucas-Interpreter (LIP) does not know how to |
462 \end{verbatim} |
461 evaluate\\ \ttfamily factors\_from\_solution, \normalfont so we knew |
463 and the next step: |
462 that there is something wrong or missing.*} |
464 \begin{verbatim} |
|
465 val nxt = ("Empty_Tac", ...): tac'_) |
|
466 \end{verbatim} |
|
467 These observations indicate, that the Lucas-Interpreter (LIP) |
|
468 does not know how to evaluate \ttfamily factors\_from\_solution |
|
469 \normalfont, so we knew that there is something wrong or missing. |
|
470 *} |
463 |
471 |
464 text{*\noindent First we isolate the difficulty in the program as follows:\\ |
472 text{*\noindent First we isolate the difficulty in the program as follows: |
465 \ttfamily \par \noindent |
473 \begin{verbatim} |
466 "(L\_L::bool list) = (SubProblem (PolyEq',"\^\\ |
474 " (L_L::bool list) = (SubProblem (PolyEq', " ^ |
467 "[abcFormula,degree\_2,polynomial,univariate,equation],[no\_met])"\^\\ |
475 " [abcFormula, degree_2, polynomial, " ^ |
468 "[BOOL equ, REAL zzz]);"\^\\ |
476 " univariate,equation], " ^ |
469 "(facs::real) = factors\_from\_solution L\_L;"\^\\ |
477 " [no_met]) " ^ |
470 "(foo::real) = Take facs"\^\\ |
478 " [BOOL equ, REAL zzz]); " ^ |
|
479 " (facs::real) = factors_from_solution L_L; " ^ |
|
480 " (foo::real) = Take facs " ^ |
|
481 \end{verbatim} |
|
482 |
|
483 \par \noindent And see the tracing output: |
|
484 |
|
485 \begin{verbatim} |
|
486 [(([], Frm), Problem (Isac, [inverse, |
|
487 Z_Transform, |
|
488 SignalProcessing])), |
|
489 (([1], Frm), X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))), |
|
490 (([1], Res), ?X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))), |
|
491 (([2], Res), ?X' z = 24 / (-1 + -2 * z + 8 * z ^^^ 2)), |
|
492 (([3], Pbl), solve (-1 + -2 * z + 8 * z ^^^ 2 = 0, z)), |
|
493 (([3,1], Frm), -1 + -2 * z + 8 * z ^^^ 2 = 0), |
|
494 (([3,1], Res), z = (- -2 + sqrt (-2 ^^^ 2 - 4 * 8 * -1)) / (2 * 8)| |
|
495 z = (- -2 - sqrt (-2 ^^^ 2 - 4 * 8 * -1)) / (2 * 8)), |
|
496 (([3,2], Res), z = 1 / 2 | z = -1 / 4), |
|
497 (([3,3], Res), [ z = 1 / 2, z = -1 / 4]), |
|
498 (([3,4], Res), [ z = 1 / 2, z = -1 / 4]), |
|
499 (([3], Res), [ z = 1 / 2, z = -1 / 4]), |
|
500 (([4], Frm), factors_from_solution [z = 1 / 2, z = -1 / 4])] |
|
501 \end{verbatim} |
|
502 |
|
503 \par \noindent In particular that: |
|
504 |
|
505 \begin{verbatim} |
|
506 (([3], Pbl), solve (-1 + -2 * z + 8 * z ^^^ 2 = 0, z)), |
|
507 \end{verbatim} |
|
508 \par \noindent Shows the equation which has been created in |
|
509 the program by: |
|
510 \begin{verbatim} |
|
511 "(denom::real) = get_denominator funterm; " ^ |
|
512 (* get_denominator *) |
|
513 "(equ::bool) = (denom = (0::real)); " ^ |
|
514 \end{verbatim} |
471 |
515 |
472 \normalfont \par \noindent And see the tracing output:\\ |
516 \noindent \ttfamily get\_denominator \normalfont has been evaluated successfully, |
473 \ttfamily \par \noindent \lbrack\\ |
|
474 ((\lbrack\rbrack, Frm), Problem |
|
475 (Isac, \lbrack inverse, Z\_Transform, SignalProcessing\rbrack)),\\ |
|
476 ((\lbrack 1\rbrack, Frm), X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))),\\ |
|
477 ((\lbrack 1\rbrack, Res), |
|
478 ?X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))),\\ |
|
479 ((\lbrack 2\rbrack, Res), |
|
480 ?X' z = 24 / (-1 + -2 * z + 8 * z \^\^\^ ~2)),\\ |
|
481 ((\lbrack 3\rbrack, Pbl), |
|
482 solve (-1 + -2 * z + 8 * z \^\^\^ ~2 = 0, z)),\\ |
|
483 ((\lbrack 3,1\rbrack, Frm), -1 + -2 * z + 8 * z \^\^\^ ~2 = 0),\\ |
|
484 ((\lbrack 3,1\rbrack, Res), |
|
485 z = (- -2 + sqrt (-2 \^\^\^ ~2 - 4 * 8 * -1)) / (2 * 8)|\\ |
|
486 z = (- -2 - sqrt (-2 \^\^\^ ~2 - 4 * 8 * -1)) / (2 * 8)),\\ |
|
487 ((\lbrack 3,2\rbrack, Res), z = 1 / 2 | z = -1 / 4),\\ |
|
488 ((\lbrack 3,3\rbrack, Res), \lbrack z = 1 / 2, z = -1 / 4\rbrack),\\ |
|
489 ((\lbrack 3,4\rbrack, Res), \lbrack z = 1 / 2, z = -1 / 4\rbrack),\\ |
|
490 ((\lbrack 3\rbrack, Res), \lbrack z = 1 / 2, z = -1 / 4\rbrack),\\ |
|
491 ((\lbrack 4\rbrack, Frm), |
|
492 factors\_from\_solution \lbrackz = 1 / 2, z = -1 / 4])\\ |
|
493 \rbrack\\ |
|
494 |
|
495 \normalfont \noindent In particular that:\\ |
|
496 \ttfamily \par \noindent ((\lbrack 3\rbrack, Pbl), |
|
497 solve (-1 + -2 * z + 8 * z \^\^\^ ~2 = 0, z)),\\ |
|
498 \normalfont \par \noindent Shows the equation which has been created in |
|
499 the program by: \ttfamily \\ |
|
500 |
|
501 \noindent "(denom::real) = get\_denominator funterm;"\^ |
|
502 ~(*get\_denominator*)\\ |
|
503 "(equ::bool) = (denom = (0::real));"\^\\ |
|
504 |
|
505 \noindent get\_denominator \normalfont has been evaluated successfully, |
|
506 but not\\ \ttfamily factors\_from\_solution.\normalfont |
517 but not\\ \ttfamily factors\_from\_solution.\normalfont |
507 So we stepwise compare with an analogous case, \ttfamily get\_denominator |
518 So we stepwise compare with an analogous case, \ttfamily get\_denominator |
508 \normalfont successfully done above: We know that LIP evaluates |
519 \normalfont successfully done above: We know that LIP evaluates |
509 expressions in the program by use of the \emph{srls}, so we try to get |
520 expressions in the program by use of the \emph{srls}, so we try to get |
510 the original \emph{srls}.\\ |
521 the original \emph{srls}.\\ |
511 |
522 |
512 \noindent \ttfamily val \lbrace srls,\ldots\rbrace\ttfamily |
523 \begin{verbatim} |
513 = get\_met \lbrack "SignalProcessing", |
524 val {srls,...} = get_met ["SignalProcessing", |
514 "Z\_Transform","inverse"\rbrack;\\ |
525 "Z_Transform", |
|
526 "inverse"]; |
|
527 \end{verbatim} |
515 |
528 |
516 \par \noindent \normalfont Create 2 good example terms\\ |
529 \par \noindent Create 2 good example terms: |
517 \ttfamily \par \noindent val SOME t1 =\\ |
530 |
518 parseNEW ctxt "get\_denominator ((111::real) / 222)"; |
531 \begin{verbatim} |
519 \par \noindent val SOME t2 =\\ |
532 val SOME t1 = |
520 parseNEW ctxt "factors\_from\_solution \lbrack(z::real) |
533 parseNEW ctxt "get_denominator ((111::real) / 222)"; |
521 = 1/2, z = -1/4\rbrack";\\ |
534 val SOME t2 = |
522 |
535 parseNEW ctxt "factors_from_solution [(z::real)=1/2, z=-1/4]"; |
523 \par \noindent \normalfont Rewrite the terms using srls:\\ |
536 \end{verbatim} |
|
537 |
|
538 \par \noindent Rewrite the terms using srls:\\ |
524 \ttfamily \par \noindent rewrite\_set\_ thy true srls t1;\\ |
539 \ttfamily \par \noindent rewrite\_set\_ thy true srls t1;\\ |
525 rewrite\_set\_ thy true srls t2;\\ |
540 rewrite\_set\_ thy true srls t2;\\ |
526 \par \noindent \normalfont Now we see a difference: \texttt{t1} gives |
541 \par \noindent \normalfont Now we see a difference: \texttt{t1} gives |
527 \texttt{SOME} but \texttt{t2} gives \texttt{NONE}. We look at the |
542 \texttt{SOME} but \texttt{t2} gives \texttt{NONE}. We look at the |
528 \emph{srls}:\\ |
543 \emph{srls}: |
529 |
544 \begin{verbatim} |
530 \par \noindent \ttfamily val srls = Rls \lbrace id = |
545 val srls = |
531 "srls\_InverseZTransform", rules =\\ |
546 Rls{id = "srls_InverseZTransform", |
532 \lbrack Calc("Rational.get\_numerator",\\ |
547 rules = [Calc("Rational.get_numerator", |
533 eval\_get\_numerator "Rational.get\_numerator"),\\ |
548 eval_get_numerator "Rational.get_numerator"), |
534 Calc("Partial\_Fractions.factors\_from\_solution",\\ |
549 Calc("Partial_Fractions.factors_from_solution", |
535 eval\_factors\_from\_solution |
550 eval_factors_from_solution |
536 "Partial\_Fractions.factors\_from\_solution")\rbrack\rbrace\\ |
551 "Partial_Fractions.factors_from_solution")]} |
537 |
552 \end{verbatim} |
538 \par \noindent \normalfont Here everthing is perfect. So the error can |
553 \par \noindent Here everthing is perfect. So the error can |
539 only be in the SML code of \ttfamily eval\_factors\_from\_solution. |
554 only be in the SML code of \ttfamily eval\_factors\_from\_solution. |
540 \normalfont We try to check the code with an existing test; since the |
555 \normalfont We try to check the code with an existing test; since the |
541 \emph{code} is in |
556 \emph{code} is in |
542 \begin{center}\ttfamily src/Tools/isac/Knowledge/Partial\_Fractions.thy |
557 \begin{center}\ttfamily src/Tools/isac/Knowledge/Partial\_Fractions.thy |
543 \normalfont\end{center} |
558 \normalfont\end{center} |
988 building scripts that way work.*} |
1004 building scripts that way work.*} |
989 |
1005 |
990 subsection {*Stepwise Extend the Program*} |
1006 subsection {*Stepwise Extend the Program*} |
991 ML {* |
1007 ML {* |
992 val str = |
1008 val str = |
993 "Script InverseZTransform (Xeq::bool) =" ^ |
1009 "Script InverseZTransform (Xeq::bool) = "^ |
994 " Xeq"; |
1010 " Xeq"; |
995 *} |
1011 *} |
996 |
1012 |
997 text{*\noindent Next we put some instructions in the script and try if we are |
1013 text{*\noindent Next we put some instructions in the script and try if we are |
998 able to solve our first equation.*} |
1014 able to solve our first equation.*} |
999 |
1015 |
1000 ML {* |
1016 ML {* |
1001 val str = |
1017 val str = |
1002 "Script InverseZTransform (Xeq::bool) =" ^ |
1018 "Script InverseZTransform (Xeq::bool) = "^ |
1003 (* |
1019 (* |
1004 * 1/z) instead of z ^^^ -1 |
1020 * 1/z) instead of z ^^^ -1 |
1005 *) |
1021 *) |
1006 " (let X = Take Xeq;" ^ |
1022 " (let X = Take Xeq; "^ |
1007 " X' = Rewrite ruleZY False X;" ^ |
1023 " X' = Rewrite ruleZY False X; "^ |
1008 (* |
1024 (* |
1009 * z * denominator |
1025 * z * denominator |
1010 *) |
1026 *) |
1011 " X' = (Rewrite_Set norm_Rational False) X'" ^ |
1027 " X' = (Rewrite_Set norm_Rational False) X' "^ |
1012 (* |
1028 (* |
1013 * simplify |
1029 * simplify |
1014 *) |
1030 *) |
1015 " in X)"; |
1031 " in X)"; |
1016 (* |
1032 (* |
1017 * NONE |
1033 * NONE |
1018 *) |
1034 *) |
1019 "Script InverseZTransform (Xeq::bool) =" ^ |
1035 "Script InverseZTransform (Xeq::bool) = "^ |
1020 (* |
1036 (* |
1021 * (1/z) instead of z ^^^ -1 |
1037 * (1/z) instead of z ^^^ -1 |
1022 *) |
1038 *) |
1023 " (let X = Take Xeq;" ^ |
1039 " (let X = Take Xeq; "^ |
1024 " X' = Rewrite ruleZY False X;" ^ |
1040 " X' = Rewrite ruleZY False X; "^ |
1025 (* |
1041 (* |
1026 * z * denominator |
1042 * z * denominator |
1027 *) |
1043 *) |
1028 " X' = (Rewrite_Set norm_Rational False) X';" ^ |
1044 " X' = (Rewrite_Set norm_Rational False) X'; "^ |
1029 (* |
1045 (* |
1030 * simplify |
1046 * simplify |
1031 *) |
1047 *) |
1032 " X' = (SubProblem (Isac',[pqFormula,degree_2," ^ |
1048 " X' = (SubProblem (Isac',[pqFormula,degree_2, "^ |
1033 " polynomial,univariate,equation]," ^ |
1049 " polynomial,univariate,equation], "^ |
1034 " [no_met]) " ^ |
1050 " [no_met]) "^ |
1035 " [BOOL e_e, REAL v_v])" ^ |
1051 " [BOOL e_e, REAL v_v]) "^ |
1036 " in X)"; |
1052 " in X)"; |
1037 *} |
1053 *} |
1038 |
1054 |
1039 text{*\noindent To solve the equation it is necessary to drop the left hand |
1055 text{*\noindent To solve the equation it is necessary to drop the left hand |
1040 side, now we only need the denominator of the right hand side. The first |
1056 side, now we only need the denominator of the right hand side. The first |
1041 equation solves the zeros of our expression.*} |
1057 equation solves the zeros of our expression.*} |
1042 |
1058 |
1043 ML {* |
1059 ML {* |
1044 val str = |
1060 val str = |
1045 "Script InverseZTransform (Xeq::bool) =" ^ |
1061 "Script InverseZTransform (Xeq::bool) = "^ |
1046 " (let X = Take Xeq;" ^ |
1062 " (let X = Take Xeq; "^ |
1047 " X' = Rewrite ruleZY False X;" ^ |
1063 " X' = Rewrite ruleZY False X; "^ |
1048 " X' = (Rewrite_Set norm_Rational False) X';" ^ |
1064 " X' = (Rewrite_Set norm_Rational False) X'; "^ |
1049 " funterm = rhs X'" ^ |
1065 " funterm = rhs X' "^ |
1050 (* |
1066 (* |
1051 * drop X'= for equation solving |
1067 * drop X'= for equation solving |
1052 *) |
1068 *) |
1053 " in X)"; |
1069 " in X)"; |
1054 *} |
1070 *} |
1085 |
1101 |
1086 text {*\noindent This ruleset contains all functions that are in the script; |
1102 text {*\noindent This ruleset contains all functions that are in the script; |
1087 The evaluation of the functions is done by rewriting using this ruleset.*} |
1103 The evaluation of the functions is done by rewriting using this ruleset.*} |
1088 |
1104 |
1089 ML {* |
1105 ML {* |
1090 val srls = Rls {id="srls_InverseZTransform", |
1106 val srls = |
1091 preconds = [], |
1107 Rls {id="srls_InverseZTransform", |
1092 rew_ord = ("termlessI",termlessI), |
1108 preconds = [], |
1093 erls = append_rls "erls_in_srls_InverseZTransform" e_rls |
1109 rew_ord = ("termlessI",termlessI), |
1094 [(*for asm in NTH_CONS ...*) |
1110 erls = append_rls "erls_in_srls_InverseZTransform" e_rls |
1095 Calc ("Orderings.ord_class.less",eval_equ "#less_"), |
1111 [(*for asm in NTH_CONS ...*) |
1096 (*2nd NTH_CONS pushes n+-1 into asms*) |
1112 Calc ("Orderings.ord_class.less",eval_equ "#less_"), |
1097 Calc("Groups.plus_class.plus", eval_binop "#add_") |
1113 (*2nd NTH_CONS pushes n+-1 into asms*) |
1098 ], |
1114 Calc("Groups.plus_class.plus", eval_binop "#add_") |
1099 srls = Erls, calc = [], |
1115 ], |
1100 rules = [ |
1116 srls = Erls, calc = [], |
1101 Thm ("NTH_CONS",num_str @{thm NTH_CONS}), |
1117 rules = [ |
1102 Calc("Groups.plus_class.plus", |
1118 Thm ("NTH_CONS",num_str @{thm NTH_CONS}), |
1103 eval_binop "#add_"), |
1119 Calc("Groups.plus_class.plus", |
1104 Thm ("NTH_NIL",num_str @{thm NTH_NIL}), |
1120 eval_binop "#add_"), |
1105 Calc("Tools.lhs", eval_lhs"eval_lhs_"), |
1121 Thm ("NTH_NIL",num_str @{thm NTH_NIL}), |
1106 Calc("Tools.rhs", eval_rhs"eval_rhs_"), |
1122 Calc("Tools.lhs", eval_lhs"eval_lhs_"), |
1107 Calc("Atools.argument'_in", |
1123 Calc("Tools.rhs", eval_rhs"eval_rhs_"), |
1108 eval_argument_in "Atools.argument'_in"), |
1124 Calc("Atools.argument'_in", |
1109 Calc("Rational.get_denominator", |
1125 eval_argument_in "Atools.argument'_in"), |
1110 eval_get_denominator "#get_denominator"), |
1126 Calc("Rational.get_denominator", |
1111 Calc("Rational.get_numerator", |
1127 eval_get_denominator "#get_denominator"), |
1112 eval_get_numerator "#get_numerator"), |
1128 Calc("Rational.get_numerator", |
1113 Calc("Partial_Fractions.factors_from_solution", |
1129 eval_get_numerator "#get_numerator"), |
1114 eval_factors_from_solution |
1130 Calc("Partial_Fractions.factors_from_solution", |
1115 "#factors_from_solution"), |
1131 eval_factors_from_solution |
1116 Calc("Partial_Fractions.drop_questionmarks", |
1132 "#factors_from_solution"), |
1117 eval_drop_questionmarks "#drop_?") |
1133 Calc("Partial_Fractions.drop_questionmarks", |
1118 ], |
1134 eval_drop_questionmarks "#drop_?") |
1119 scr = EmptyScr |
1135 ], |
1120 }; |
1136 scr = EmptyScr}; |
1121 *} |
1137 *} |
1122 |
1138 |
1123 |
1139 |
1124 subsection {*Store Final Version of Program for Execution*} |
1140 subsection {*Store Final Version of Program for Execution*} |
1125 |
1141 |
1126 text{*\noindent After we also tested how to write scripts and run them, |
1142 text{*\noindent After we also tested how to write scripts and run them, |
1127 we start creating the final version of our script and store it into |
1143 we start creating the final version of our script and store it into |
1128 the method for which we created a node in section~\ref{sec:cparentnode} |
1144 the method for which we created a node in Section~\ref{sec:cparentnode} |
1129 Note that we also did this stepwise, but we didn't kept every |
1145 Note that we also did this stepwise, but we didn't kept every |
1130 subversion.*} |
1146 subversion.*} |
1131 |
1147 |
1132 ML {* |
1148 ML {* |
1133 store_met( |
1149 store_met( |
1301 *} |
1317 *} |
1302 |
1318 |
1303 text {*\noindent Instead of \ttfamily nxt = Subproblem \normalfont above we had |
1319 text {*\noindent Instead of \ttfamily nxt = Subproblem \normalfont above we had |
1304 \ttfamily Empty\_Tac; \normalfont the search for the reason considered |
1320 \ttfamily Empty\_Tac; \normalfont the search for the reason considered |
1305 the following points:\begin{itemize} |
1321 the following points:\begin{itemize} |
1306 \item What shows \ttfamily show\_pt pt;\normalfont\ldots?\\ |
1322 \item What shows \ttfamily show\_pt pt;\normalfont\ldots? |
1307 \ttfamily ((\lbrack 2\rbrack, Res), ?X' z = 24 / |
1323 \begin{verbatim}(([2], Res), ?X' z = 24 / (-1 + -2 * z + 8 * z ^^^ 2))]\end{verbatim} |
1308 (-1 + -2 * z + 8 * z \^\^\^ ~2))\rbrack\normalfont\\ |
|
1309 The calculation is ok but no \ttfamily next \normalfont step found: |
1324 The calculation is ok but no \ttfamily next \normalfont step found: |
1310 Should be\\ \ttfamily nxt = Subproblem\normalfont! |
1325 Should be\\ \ttfamily nxt = Subproblem\normalfont! |
1311 \item What shows \ttfamily trace\_script := true; \normalfont we read |
1326 \item What shows \ttfamily trace\_script := true; \normalfont we read |
1312 bottom up\ldots\\ |
1327 bottom up\ldots |
1313 \ttfamily @@@next leaf 'SubProbfrom\\ |
1328 \begin{verbatim} |
1314 (PolyEq',\\ |
1329 @@@next leaf 'SubProblem |
1315 \lbrack abcFormula, degree\_2, polynomial, univariate, |
1330 (PolyEq',[abcFormula, degree_2, polynomial, |
1316 equation\rbrack,\\ |
1331 univariate, equation], no_meth) |
1317 no\_meth)\\ |
1332 [BOOL equ, REAL z]' |
1318 \lbrack BOOL equ, REAL z\rbrack' ---> STac 'SubProblem\\ |
1333 ---> STac 'SubProblem (PolyEq', |
1319 (PolyEq',\\ |
1334 [abcFormula, degree_2, polynomial, |
1320 [abcFormula, degree\_2, polynomial, univariate, equation],\\ |
1335 univariate, equation], no_meth) |
1321 no\_meth)\\ |
1336 [BOOL (-1 + -2 * z + 8 * z \^\^\^ ~2 = 0), REAL z]' |
1322 \lbrack BOOL (-1 + -2 * z + 8 * z \^\^\^ ~2 = 0), |
1337 \end{verbatim} |
1323 REAL z\rbrack'\normalfont\\ |
|
1324 We see the SubProblem with correct arguments from searching next |
1338 We see the SubProblem with correct arguments from searching next |
1325 step (program text !!!--->!!! STac (script tactic) with arguments |
1339 step (program text !!!--->!!! STac (script tactic) with arguments |
1326 evaluated.) |
1340 evaluated.) |
1327 \item Do we have the right Script \ldots difference in the |
1341 \item Do we have the right Script \ldots difference in the |
1328 arguments in the arguments\ldots\\ |
1342 arguments in the arguments\ldots |
1329 \ttfamily val Script s =\\ |
1343 \begin{verbatim} |
1330 (#scr o get\_met) ["SignalProcessing","Z\_Transform","inverse"];\\ |
1344 val Script s = |
1331 writeln (term2str s);\normalfont\\ |
1345 (#scr o get_met) ["SignalProcessing", |
|
1346 "Z_Transform", |
|
1347 "inverse"]; |
|
1348 writeln (term2str s); |
|
1349 \end{verbatim} |
1332 \ldots shows the right script. Difference in the arguments. |
1350 \ldots shows the right script. Difference in the arguments. |
1333 \item Test --- Why helpless here ? --- shows: \ttfamily replace |
1351 \item Test --- Why helpless here ? --- shows: \ttfamily replace |
1334 no\_meth by [no\_meth] \normalfont in Script |
1352 no\_meth by [no\_meth] \normalfont in Script |
1335 \end{itemize} |
1353 \end{itemize} |
1336 *} |
1354 *} |
1506 We could transfer all knowledge in \ttfamily Build\_Inverse\_Z\_Transform.thy |
1526 We could transfer all knowledge in \ttfamily Build\_Inverse\_Z\_Transform.thy |
1507 \normalfont first to the \ttfamily Knowledge/Inverse\_Z\_Transform.thy |
1527 \normalfont first to the \ttfamily Knowledge/Inverse\_Z\_Transform.thy |
1508 \normalfont and then modularise. In this case TODO problems?!? |
1528 \normalfont and then modularise. In this case TODO problems?!? |
1509 |
1529 |
1510 We chose another way and go bottom up: first we build the sub-problem in |
1530 We chose another way and go bottom up: first we build the sub-problem in |
1511 \ttfamily Partial\_Fractions.thy \normalfont with the term |
1531 \ttfamily Partial\_Fractions.thy \normalfont with the term: |
1512 |
1532 |
1513 $$\frac{3}{x\cdot(z - \fract{1}{4} + \frac{-1}{8}\cdot\fract{1}{z})}$$ |
1533 $$\frac{3}{x\cdot(z - \frac{1}{4} + \frac{-1}{8}\cdot\frac{1}{z})}$$ |
1514 |
1534 |
1515 (how this still can be improved see \ttfamily Partial\_Fractions.thy \normalfont), |
1535 \noindent (how this still can be improved see \ttfamily Partial\_Fractions.thy\normalfont), |
1516 and re-use all stuff prepared in \ttfamily Build\_Inverse\_Z\_Transform.thy: |
1536 and re-use all stuff prepared in \ttfamily Build\_Inverse\_Z\_Transform.thy: |
1517 The knowledge will be transferred to \ttfamily src/../Partial\_Fractions.thy |
1537 \normalfont The knowledge will be transferred to \ttfamily src/../Partial\_Fractions.thy |
1518 \normalfont and the respective tests to \ttfamily test/../sartial\_fractions.sml. |
1538 \normalfont and the respective tests to: |
|
1539 \begin{center}\ttfamily test/../sartial\_fractions.sml\normalfont\end{center} |
1519 *} |
1540 *} |
1520 |
1541 |
1521 subsection {* Transfer to Partial\_Fractions.thy *} |
1542 subsection {* Transfer to Partial\_Fractions.thy *} |
1522 text {* |
1543 text {* |
1523 First we transfer both, knowledge and tests into \ttfamily src/../Partial\_Fractions.thy |
1544 First we transfer both, knowledge and tests into: |
1524 \normalfont in order to immediately have the test results. |
1545 \begin{center}\ttfamily src/../Partial\_Fractions.thy\normalfont\end{center} |
1525 |
1546 in order to immediately have the test results. |
1526 We copy \ttfamily factors_from_solution, drop_questionmarks, |
1547 |
1527 ansatz_2nd_order \normalfont and rule-sets --- no problem. |
1548 We copy \ttfamily factors\_from\_solution, drop\_questionmarks,\\ |
1528 Also \ttfamily store_pbt .. "pbl_simp_rat_partfrac" |
1549 ansatz\_2nd\_order \normalfont and rule-sets --- no problem. |
|
1550 |
|
1551 Also \ttfamily store\_pbt ..\\ "pbl\_simp\_rat\_partfrac" |
1529 \normalfont is easy. |
1552 \normalfont is easy. |
1530 |
1553 |
1531 But then we copy from (1) \ttfamily Build\_Inverse\_Z\_Transform.thy |
1554 But then we copy from:\\ |
1532 store_met .. "met_SP_Ztrans_inv" to (2) \ttfamily Partial\_Fractions.thy |
1555 (1) \ttfamily Build\_Inverse\_Z\_Transform.thy store\_met\ldots "met\_SP\_Ztrans\_inv" |
1533 store_met .. "met_SP_Ztrans_inv" |
1556 \normalfont\\ to\\ |
1534 \normalfont and cut out the respective part from the program. First we ensure that |
1557 (2) \ttfamily Partial\_Fractions.thy store\_met\ldots "met\_SP\_Ztrans\_inv" |
|
1558 \normalfont\\ and cut out the respective part from the program. First we ensure that |
1535 the string is correct. When we insert the string into (2) |
1559 the string is correct. When we insert the string into (2) |
1536 \ttfamily store_met .. "met_partial_fraction" \normalfont --- and get an error. |
1560 \ttfamily store\_met .. "met\_partial\_fraction" \normalfont --- and get an error. |
1537 *} |
1561 *} |
1538 |
1562 |
1539 subsubsection {* 'Programming' in \sisac}'s TP-based Language *} |
1563 subsubsection {* 'Programming' in ISAC's TP-based Language *} |
1540 text {* |
1564 text {* |
1541 At the present state writing programs in {\sisac} is particularly cumbersome. |
1565 At the present state writing programs in {\sisac} is particularly cumbersome. |
1542 So we give hints how to cope with the many obstacles. Below we describe the |
1566 So we give hints how to cope with the many obstacles. Below we describe the |
1543 steps we did in making (2) run. |
1567 steps we did in making (2) run. |
1544 |
1568 |
1545 \begin{enumerate} |
1569 \begin{enumerate} |
1546 \item We check if the \textbf{string} containing the program is correct. |
1570 \item We check if the \textbf{string} containing the program is correct. |
1547 \item We check if the \textbf{types in the program} are correct. |
1571 \item We check if the \textbf{types in the program} are correct. |
1548 For this purpose we start start with the first and last lines |
1572 For this purpose we start start with the first and last lines |
1549 \begin{verbatim} |
1573 \begin{verbatim} |
1550 "PartFracScript (f_f::real) (v_v::real) = " ^ |
1574 "PartFracScript (f_f::real) (v_v::real) = " ^ |
1551 " (let X = Take f_f; " ^ |
1575 " (let X = Take f_f; " ^ |
1552 " pbz = ((Substitute []) X) " ^ |
1576 " pbz = ((Substitute []) X) " ^ |
1553 " in pbz)" |
1577 " in pbz)" |
1554 \end{verbatim} |
1578 \end{verbatim} |
1555 The last but one line helps not to bother with ';'. |
1579 The last but one line helps not to bother with ';'. |
1556 \item Then we add line by line. Already the first line causes the error. |
1580 \item Then we add line by line. Already the first line causes the error. |
1557 So we investigate it by |
1581 So we investigate it by |
1558 \begin{verbatim} |
1582 \begin{verbatim} |
1559 val ctxt = ProofContext.init_global @{theory}; |
1583 val ctxt = ProofContext.init_global @ { theory } ; |
1560 val SOME t = parseNEW ctxt "(num_orig::real) = get_numerator (rhs f_f)"; |
1584 val SOME t = |
1561 \end{verbatim} |
1585 parseNEW ctxt "(num_orig::real) = |
|
1586 get_numerator(rhs f_f)"; |
|
1587 \end{verbatim} |
1562 and see a type clash: \ttfamily rhs \normalfont from (1) requires type |
1588 and see a type clash: \ttfamily rhs \normalfont from (1) requires type |
1563 \ttfamily bool \normalfont while (2) wants to have \ttfamily (f_f::real). |
1589 \ttfamily bool \normalfont while (2) wants to have \ttfamily (f\_f::real). |
1564 \normalfont Of course, we don't need \ttfamily rhs \normalfont anymore. |
1590 \normalfont Of course, we don't need \ttfamily rhs \normalfont anymore. |
1565 \item Type-checking can be very tedious. One might even inspect the |
1591 \item Type-checking can be very tedious. One might even inspect the |
1566 parse-tree of the program with \sisac's specific debug tools: |
1592 parse-tree of the program with {\sisac}'s specific debug tools: |
1567 \begin{verbatim} |
1593 \begin{verbatim} |
1568 val {scr = Script t,...} = get_met ["simplification","of_rationals","to_partial_fraction"]; |
1594 val {scr = Script t,...} = |
1569 atomty_thy @{theory} t; |
1595 get_met ["simplification", |
1570 \end{verbatim} |
1596 "of_rationals", |
|
1597 "to_partial_fraction"]; |
|
1598 atomty_thy @ { theory } t ; |
|
1599 \end{verbatim} |
1571 \item We check if the \textbf{semantics of the program} by stepwise evaluation |
1600 \item We check if the \textbf{semantics of the program} by stepwise evaluation |
1572 of the program. Evaluation is done by the Lucas-Interpreter, which works |
1601 of the program. Evaluation is done by the Lucas-Interpreter, which works |
1573 using the knowledge in theory Isac; so we have to re-build Isac. And the |
1602 using the knowledge in theory Isac; so we have to re-build Isac. And the |
1574 test are performed simplest in a file which is loaded with Isac. |
1603 test are performed simplest in a file which is loaded with Isac. |
1575 See \ttfamily tests/../partial_fractions.sml \normalfont. |
1604 See \ttfamily tests/../partial\_fractions.sml \normalfont. |
1576 \end{enumerate} |
1605 \end{enumerate} |
1577 *} |
1606 *} |
1578 |
1607 |
1579 subsection {* Transfer to Inverse\_Z\_Transform.thy *} |
1608 subsection {* Transfer to Inverse\_Z\_Transform.thy *} |
1580 text {* |
1609 text {* |
1581 |
1610 Unfortunately it was not possible to complete this task. Because we ran out of time\ldots |
1582 *} |
1611 *} |
1583 |
1612 |
1584 |
1613 |
1585 end |
1614 end |
1586 |
1615 |