test/Tools/isac/ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform.thy
changeset 42381 8b94d811cb41
parent 42377 da3a55182442
child 42388 65da7356f5cd
equal deleted inserted replaced
42380:a8471740e3b0 42381:8b94d811cb41
     3    (c) copyright due to license terms.
     3    (c) copyright due to license terms.
     4 12345678901234567890123456789012345678901234567890123456789012345678901234567890
     4 12345678901234567890123456789012345678901234567890123456789012345678901234567890
     5         10        20        30        40        50        60        70        80
     5         10        20        30        40        50        60        70        80
     6 *)
     6 *)
     7 
     7 
     8 header{* Build_Inverse_Z_Transform *}
       
     9 
       
    10 theory Build_Inverse_Z_Transform imports Isac
     8 theory Build_Inverse_Z_Transform imports Isac
    11   
     9   
    12 begin
    10 begin
    13 
    11 
    14 text{* We stepwise build \ttfamily Inverse\_Z\_Transform.thy \normalfont as an 
    12 text{* We stepwise build \ttfamily Inverse\_Z\_Transform.thy \normalfont as an 
    15   exercise. Because subsection~\ref{sec:stepcheck} requires 
    13   exercise. Because Subsection~\ref{sec:stepcheck} requires 
    16   \ttfamily Inverse\_Z\_Transform.thy \normalfont as a subtheory of \ttfamily 
    14   \ttfamily Inverse\_Z\_Transform.thy \normalfont as a subtheory of \ttfamily 
    17   Isac.thy\normalfont, the setup has been changed from \ttfamily theory 
    15   Isac.thy\normalfont, the setup has been changed from \ttfamily theory 
    18   Inverse\_Z\_Transform imports Isac \normalfont to the above one.
    16   Inverse\_Z\_Transform imports Isac \normalfont to the above one.
    19   \par \noindent
    17   \par \noindent
    20   \begin{center} 
    18   \begin{center} 
    21   \textbf{ATTENTION WITH NAMES OF IDENTIFIERS WHEN GOING INTO INTERNALS}
    19   \textbf{Attention with the names of identifiers when going into internals!}
    22   \end{center}
    20   \end{center}
    23   Here in this theory there are the internal names twice, for instance we have
    21   Here in this theory there are the internal names twice, for instance we have
    24   \ttfamily (Thm.derivation\_name @{thm rule1} = 
    22   \ttfamily (Thm.derivation\_name @{thm rule1} = 
    25   "Build\_Inverse\_Z\_Transform.rule1") = true; \normalfont
    23   "Build\_Inverse\_Z\_Transform.rule1") = true; \normalfont
    26   but actually in us will be \ttfamily Inverse\_Z\_Transform.rule1 \normalfont
    24   but actually in us will be \ttfamily Inverse\_Z\_Transform.rule1 \normalfont
   344   atomty solutions;
   342   atomty solutions;
   345 *}
   343 *}
   346 
   344 
   347 subsubsection {*Get Solutions out of a List*}
   345 subsubsection {*Get Solutions out of a List*}
   348 text {*\noindent In {\sisac}'s TP-based programming language: 
   346 text {*\noindent In {\sisac}'s TP-based programming language: 
   349        \ttfamily let\$ \$s\_1 = NTH 1\$ solutions; \$s\_2 = NTH 2...\$ \normalfont
   347 \begin{verbatim}
   350        can be useful.*}
   348   let $ $ s_1 = NTH 1 $ solutions; $ s_2 = NTH 2... $
       
   349 \end{verbatim}
       
   350        can be useful.
       
   351        *}
   351 
   352 
   352 ML {*
   353 ML {*
   353   val Const ("List.list.Cons", _) $ s_1 $ (Const ("List.list.Cons", _)
   354   val Const ("List.list.Cons", _) $ s_1 $ (Const ("List.list.Cons", _)
   354         $ s_2 $ Const ("List.list.Nil", _)) = solutions;
   355         $ s_2 $ Const ("List.list.Nil", _)) = solutions;
   355   term2str s_1;
   356   term2str s_1;
   358 
   359 
   359 text{*\noindent The ansatz for the \em Partial Fraction Decomposition \normalfont
   360 text{*\noindent The ansatz for the \em Partial Fraction Decomposition \normalfont
   360       requires to get the denominators of the partial fractions out of the 
   361       requires to get the denominators of the partial fractions out of the 
   361       Solutions as:
   362       Solutions as:
   362       \begin{itemize}
   363       \begin{itemize}
   363       \item $ \text{Denominator} _{1} = z - \text{Zeropoint}_{1}$
   364         \item $Denominator_{1}=z-Zeropoint_{1}$
   364       \item $ \text{Denominator} _{2} = z - \text{Zeropoint}_{2}$
   365         \item $Denominator_{2}=z-Zeropoint_{2}$
   365       \item \ldots
   366         \item \ldots
   366       \end{itemize}*}
   367       \end{itemize}
       
   368 *}
   367       
   369       
   368 ML {*
   370 ML {*
   369   val xx = HOLogic.dest_eq s_1;
   371   val xx = HOLogic.dest_eq s_1;
   370   val s_1' = HOLogic.mk_binop "Groups.minus_class.minus" xx;
   372   val s_1' = HOLogic.mk_binop "Groups.minus_class.minus" xx;
   371   val xx = HOLogic.dest_eq s_2;
   373   val xx = HOLogic.dest_eq s_2;
   432 *} *)
   434 *} *)
   433 text {*\noindent This function needs to be packed such that it can be evaluated
   435 text {*\noindent This function needs to be packed such that it can be evaluated
   434         by the Lucas-Interpreter. Therefor we moved the function to the
   436         by the Lucas-Interpreter. Therefor we moved the function to the
   435         corresponding \ttfamily Equation.thy \normalfont in our case
   437         corresponding \ttfamily Equation.thy \normalfont in our case
   436         \ttfamily PartialFractions.thy \normalfont. The necessary steps
   438         \ttfamily PartialFractions.thy \normalfont. The necessary steps
   437         are quit the same as we have done with \ttfamliy get\_denominator 
   439         are quit the same as we have done with \ttfamily get\_denominator 
   438         \normalfont before.*}
   440         \normalfont before.*}
   439 ML {*
   441 ML {*
   440   (*("factors_from_solution",
   442   (*("factors_from_solution",
   441     ("Partial_Fractions.factors_from_solution",
   443     ("Partial_Fractions.factors_from_solution",
   442       eval_factors_from_solution ""))*)
   444       eval_factors_from_solution ""))*)
   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}
   553       partial\_fractions.sml \normalfont is used in \ttfamily Test\_Isac.thy 
   568       partial\_fractions.sml \normalfont is used in \ttfamily Test\_Isac.thy 
   554       \normalfont
   569       \normalfont
   555       \begin{center}use \ttfamily "Knowledge/partial\_fractions.sml"
   570       \begin{center}use \ttfamily "Knowledge/partial\_fractions.sml"
   556       \normalfont \end{center}
   571       \normalfont \end{center}
   557       and \ttfamily Partial\_Fractions.thy \normalfont is part is part of
   572       and \ttfamily Partial\_Fractions.thy \normalfont is part is part of
   558       {\sisac} by evaluating\\
   573       {\sisac} by evaluating
   559 
   574 
   560       \par \noindent \ttfamily val thy = @\lbrace theory~Isac \rbrace;
   575 \begin{verbatim}
   561       \normalfont \\
   576   val thy = @{theory Isac};
   562 
   577 \end{verbatim}
   563       \par \noindent \normalfont After rebuilding {\sisac} again it worked.
   578 
       
   579       After rebuilding {\sisac} again it worked.
   564 *}
   580 *}
   565 
   581 
   566 subsubsection {*Build Expression*}
   582 subsubsection {*Build Expression*}
   567 text {*\noindent In {\sisac}'s TP-based programming language we can build
   583 text {*\noindent In {\sisac}'s TP-based programming language we can build
   568        expressions by:\\
   584        expressions by:\\
   696         Thm ("equival_trans_2nd_order",num_str @{thm equival_trans_2nd_order})
   712         Thm ("equival_trans_2nd_order",num_str @{thm equival_trans_2nd_order})
   697               ], 
   713               ], 
   698       scr = EmptyScr});
   714       scr = EmptyScr});
   699 *}
   715 *}
   700 
   716 
   701 text{*\noindent We apply the ruleset\lodts*}
   717 text{*\noindent We apply the ruleset\ldots*}
   702 
   718 
   703 ML {*
   719 ML {*
   704   val SOME (ttttt,_) = 
   720   val SOME (ttttt,_) = 
   705     rewrite_set_ @{theory Isac} false ansatz_rls expr';
   721     rewrite_set_ @{theory Isac} false ansatz_rls expr';
   706 *}
   722 *}
   717 text{*\noindent Now it's up to get the two coefficients A and B, which will be
   733 text{*\noindent Now it's up to get the two coefficients A and B, which will be
   718       the numerators of our partial fractions. Continue following up the 
   734       the numerators of our partial fractions. Continue following up the 
   719       Calculation in Section~\ref{sec:calc:ztrans} Subproblem~1.*}
   735       Calculation in Section~\ref{sec:calc:ztrans} Subproblem~1.*}
   720       
   736       
   721 text{*\noindent To get the first coefficient we substitute $z$ with the first
   737 text{*\noindent To get the first coefficient we substitute $z$ with the first
   722       zero-point we determined in section~\ref{sec:solveq}.*}
   738       zero-point we determined in Section~\ref{sec:solveq}.*}
   723 
   739 
   724 ML {*
   740 ML {*
   725   val SOME (eq4_1,_) =
   741   val SOME (eq4_1,_) =
   726     rewrite_terms_ @{theory Isac} e_rew_ord e_rls [s_1] eq3'';
   742     rewrite_terms_ @{theory Isac} e_rew_ord e_rls [s_1] eq3'';
   727   term2str eq4_1;
   743   term2str eq4_1;
   797       interpreter knows.*}
   813       interpreter knows.*}
   798 
   814 
   799 ML {*thy*}
   815 ML {*thy*}
   800 
   816 
   801 text{*\noindent To get the second coefficient we substitute $z$ with the second
   817 text{*\noindent To get the second coefficient we substitute $z$ with the second
   802       zero-point we determined in section~\ref{sec:solveq}.*}
   818       zero-point we determined in Section~\ref{sec:solveq}.*}
   803 
   819 
   804 ML {*
   820 ML {*
   805   val SOME (eq4b_1,_) =
   821   val SOME (eq4b_1,_) =
   806     rewrite_terms_ @{theory Isac} e_rew_ord e_rls [s_2] eq3'';
   822     rewrite_terms_ @{theory Isac} e_rew_ord e_rls [s_2] eq3'';
   807   term2str eq4b_1;
   823   term2str eq4b_1;
   882    (["Z_Transform","SignalProcessing"], [], e_rls, NONE, []));
   898    (["Z_Transform","SignalProcessing"], [], e_rls, NONE, []));
   883 *}
   899 *}
   884 
   900 
   885 text{*\noindent For the suddenly created node we have to define the input
   901 text{*\noindent For the suddenly created node we have to define the input
   886        and output parameters. We already prepared their definition in
   902        and output parameters. We already prepared their definition in
   887        section~\ref{sec:deffdes}.*}
   903        Section~\ref{sec:deffdes}.*}
   888 
   904 
   889 ML {*
   905 ML {*
   890   store_pbt
   906   store_pbt
   891    (prep_pbt thy "pbl_SP_Ztrans_inv" [] e_pblID
   907    (prep_pbt thy "pbl_SP_Ztrans_inv" [] e_pblID
   892    (["inverse", "Z_Transform", "SignalProcessing"],
   908    (["inverse", "Z_Transform", "SignalProcessing"],
   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 *}
  1057       side. The equation itself consists of this denominator and tries to find
  1073       side. The equation itself consists of this denominator and tries to find
  1058       a $z$ for this the denominator is equal to zero.*}
  1074       a $z$ for this the denominator is equal to zero.*}
  1059 
  1075 
  1060 ML {*
  1076 ML {*
  1061   val str = 
  1077   val str = 
  1062     "Script InverseZTransform (X_eq::bool) =" ^ 
  1078     "Script InverseZTransform (X_eq::bool) =                         "^
  1063     " (let X = Take X_eq;" ^
  1079     " (let X = Take X_eq;                                            "^
  1064     "      X' = Rewrite ruleZY False X;" ^ 
  1080     "      X' = Rewrite ruleZY False X;                              "^
  1065     "      X' = (Rewrite_Set norm_Rational False) X';" ^ 
  1081     "      X' = (Rewrite_Set norm_Rational False) X';                "^
  1066     "      (X'_z::real) = lhs X';" ^
  1082     "      (X'_z::real) = lhs X';                                    "^
  1067     "      (z::real) = argument_in X'_z;" ^
  1083     "      (z::real) = argument_in X'_z;                             "^
  1068     "      (funterm::real) = rhs X';" ^ 
  1084     "      (funterm::real) = rhs X';                                 "^
  1069     "      (denom::real) = get_denominator funterm;" ^ 
  1085     "      (denom::real) = get_denominator funterm;                  "^
  1070     (*
  1086     (*
  1071      * get_denominator
  1087      * get_denominator
  1072      *)
  1088      *)
  1073     "      (equ::bool) = (denom = (0::real));" ^
  1089     "      (equ::bool) = (denom = (0::real));                        "^
  1074     "      (L_L::bool list) =                                    " ^
  1090     "      (L_L::bool list) =                                        "^
  1075     "            (SubProblem (Test',                             " ^
  1091     "            (SubProblem (Test',                                 "^
  1076     "                         [linear,univariate,equation,test], " ^
  1092     "                         [linear,univariate,equation,test],     "^
  1077     "                         [Test,solve_linear])               " ^
  1093     "                         [Test,solve_linear])                   "^
  1078     "                         [BOOL equ, REAL z])                " ^
  1094     "                         [BOOL equ, REAL z])                    "^
  1079     "  in X)";
  1095     "  in X)";
  1080 
  1096 
  1081   parse thy str;
  1097   parse thy str;
  1082   val sc = ((inst_abs thy) o term_of o the o (parse thy)) str;
  1098   val sc = ((inst_abs thy) o term_of o the o (parse thy)) str;
  1083   atomty sc;
  1099   atomty sc;
  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 *}
  1342 
  1360 
  1343 text {*\noindent Instead of \ttfamily nxt = Model\_Problem \normalfont above
  1361 text {*\noindent Instead of \ttfamily nxt = Model\_Problem \normalfont above
  1344        we had \ttfamily Empty\_Tac; \normalfont the search for the reason 
  1362        we had \ttfamily Empty\_Tac; \normalfont the search for the reason 
  1345        considered the following points:\begin{itemize}
  1363        considered the following points:\begin{itemize}
  1346        \item Difference in the arguments
  1364        \item Difference in the arguments
  1347        \item Comparison with subsection~ref{sec:solveq}: There solving this
  1365        \item Comparison with Subsection~\ref{sec:solveq}: There solving this
  1348          equation works, so there must be some difference in the arguments
  1366          equation works, so there must be some difference in the arguments
  1349          of the Subproblem: RIGHT: we had \ttfamily [no\_meth] \normalfont
  1367          of the Subproblem: RIGHT: we had \ttfamily [no\_meth] \normalfont
  1350          instead of \ttfamily [no\_met] \normalfont ;-)
  1368          instead of \ttfamily [no\_met] \normalfont ;-)
  1351        \end{itemize}*}
  1369        \end{itemize}*}
  1352 
  1370 
  1365        \normalfont The search for the reason considered the following points:
  1383        \normalfont The search for the reason considered the following points:
  1366        \begin{itemize}
  1384        \begin{itemize}
  1367        \item Was there an error message? NO -- ok
  1385        \item Was there an error message? NO -- ok
  1368        \item Has \ttfamily nxt = Add\_Find \normalfont been inserted in pt:\\
  1386        \item Has \ttfamily nxt = Add\_Find \normalfont been inserted in pt:\\
  1369          \ttfamily get\_obj g\_pbl pt (fst p);\normalfont? YES -- ok
  1387          \ttfamily get\_obj g\_pbl pt (fst p);\normalfont? YES -- ok
  1370        \item What is the returned formula: 
  1388        \item What is the returned formula:
  1371          \ttfamily print\_depth 999; f; print\_depth 999;\\
  1389 \begin{verbatim}
  1372          \lbrace Find = \lbrack Correct "solutions z\_i"\rbrack,
  1390 print_depth 999; f; print_depth 999;
  1373            With = \lbrack\rbrack,\\
  1391 { Find = [ Correct "solutions z_i"],
  1374          Given = \lbrack Correct "equality (-1 + -2 * z + 8 * z ^^^ 2 = 0)",
  1392   With = [],
  1375            Correct "solveFor z"\rbrack,\\
  1393   Given = [Correct "equality (-1 + -2*z + 8*z ^^^ 2 = 0)",
  1376          Where = \lbrack \ldots \rbrack,
  1394            Correct "solveFor z"],
  1377      Relate = \lbrack\rbrack\rbrace $ \normalfont\\
  1395   Where = [...],
       
  1396   Relate = [] }
       
  1397 \end{verbatim}
  1378      \normalfont The only False is the reason: the Where (the precondition) is
  1398      \normalfont The only False is the reason: the Where (the precondition) is
  1379      False for good reasons: The precondition seems to check for linear
  1399      False for good reasons: The precondition seems to check for linear
  1380      equations, not for the one we want to solve! Removed this error by
  1400      equations, not for the one we want to solve! Removed this error by
  1381      correcting the Script from \ttfamily SubProblem (PolyEq',
  1401      correcting the Script from \ttfamily SubProblem (PolyEq',
  1382      \lbrack linear,univariate,equation,
  1402      \lbrack linear,univariate,equation,
  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