doc-src/isac/jrocnik/eJMT-paper/jrocnik_eJMT.tex
changeset 42469 264803a0c13e
parent 42468 5f8f02e1ea9f
child 42470 aafbbd5a85a5
equal deleted inserted replaced
42468:5f8f02e1ea9f 42469:264803a0c13e
   690 %WN die Argumentation unten sollte sich NUR auf Verifikation beziehen..
   690 %WN die Argumentation unten sollte sich NUR auf Verifikation beziehen..
   691 
   691 
   692 The problem of the running example is textually described in
   692 The problem of the running example is textually described in
   693 Fig.\ref{fig-interactive} on p.\pageref{fig-interactive}. The {\em
   693 Fig.\ref{fig-interactive} on p.\pageref{fig-interactive}. The {\em
   694 formal} specification of this problem, in traditional mathematical
   694 formal} specification of this problem, in traditional mathematical
   695 notation, could look lik is this:
   695 notation, could look like is this:
   696 
   696 
   697 %WN Hier brauchen wir die Spezifikation des 'running example' ...
   697 %WN Hier brauchen wir die Spezifikation des 'running example' ...
   698 
   698 
   699 %JR Habe input, output und precond vom Beispiel eingefügt brauche aber Hilfe bei
   699 %JR Habe input, output und precond vom Beispiel eingefügt brauche aber Hilfe bei
   700 %JR der post condition - die existiert für uns ja eigentlich nicht aka
   700 %JR der post condition - die existiert für uns ja eigentlich nicht aka
   707   \hfill \\
   707   \hfill \\
   708   Specification:\\
   708   Specification:\\
   709     \>input    \>: filterExpression $X=\frac{3}{(z-\frac{1}{4}+-\frac{1}{8}*\frac{1}{z}}$\\
   709     \>input    \>: filterExpression $X=\frac{3}{(z-\frac{1}{4}+-\frac{1}{8}*\frac{1}{z}}$\\
   710   \>precond  \>: filterExpression continius on $\mathbb{R}$ \\
   710   \>precond  \>: filterExpression continius on $\mathbb{R}$ \\
   711   \>output   \>: stepResponse $x[n]$ \\
   711   \>output   \>: stepResponse $x[n]$ \\
   712   \>postcond \>:{\small  $\;A=2uv-u^2 \;\land\; (\frac{u}{2})^2+(\frac{v}{2})^2=r^2 \;\land$}\\
   712   \>postcond \>: TODO - (Mind the following remark)\\ \end{tabbing}}
   713   \>     \>\>{\small $\;\forall \;A^\prime\; u^\prime \;v^\prime.\;(A^\prime=2u^\prime v^\prime-(u^\prime)^2 \land
   713 
   714   (\frac{u^\prime}{2})^2+(\frac{v^\prime}{2})^2=r^2) \Longrightarrow A^\prime \leq A$} \\
   714   \paragraph{Remark on post-conditions:} Defining the postcondition requires a
   715   \end{tabbing}
   715    high amount mathematical knowledge, the difficult part in our case is not to
   716   }
   716    set up this condition nor it is more to define it in a way the interpreter is
   717 
   717    able to handle it. Due the fact that implementing that mechanisms is quite 
   718 And this is the implementation of the formal specification in the present
   718    the same amount as creating the programm itself, it is not avaible in our
       
   719    prototype.\label{rm:postcond}
       
   720 
       
   721 \paragraph{The implementation} of the formal specification in the present
   719 prototype, still bar-bones without support for authoring:
   722 prototype, still bar-bones without support for authoring:
   720 %WN Kopie von Inverse_Z_Transform.thy, leicht versch"onert:
   723 %WN Kopie von Inverse_Z_Transform.thy, leicht versch"onert:
   721 {\footnotesize
   724 {\footnotesize
   722 \begin{verbatim}
   725 \begin{verbatim}
   723    01  store_specification
   726    01  store_specification
   756 \item[06] is a key into the tree of all specifications as presented to
   759 \item[06] is a key into the tree of all specifications as presented to
   757 the user (where some branches might be hidden by the dialog
   760 the user (where some branches might be hidden by the dialog
   758 component).
   761 component).
   759 \item[07..10] are the specification with input, pre-condition, output
   762 \item[07..10] are the specification with input, pre-condition, output
   760 and post-condition respectively; the post-condition is not handled in
   763 and post-condition respectively; the post-condition is not handled in
   761 the prototype presently.
   764 the prototype presently. (Follow up Remark in Section~\ref{rm:postcond})
   762 \item[11] creates a term rewriting system (abbreviated \textit{rls} in
   765 \item[11] creates a term rewriting system (abbreviated \textit{rls} in
   763 {\sisac}) which evaluates the pre-condition for the actual input data.
   766 {\sisac}) which evaluates the pre-condition for the actual input data.
   764 Only if the evaluation yields \textit{True}, a program con be started.
   767 Only if the evaluation yields \textit{True}, a program con be started.
   765 \item[12]\textit{NONE:} could be \textit{SOME ``solve ...''} for a
   768 \item[12]\textit{NONE:} could be \textit{SOME ``solve ...''} for a
   766 problem associated to a function from Computer Algebra (like an
   769 problem associated to a function from Computer Algebra (like an
   825 
   828 
   826 \subsection{Implementation of the Method}\label{meth}
   829 \subsection{Implementation of the Method}\label{meth}
   827 %WN <--> \chapter 7 der Thesis
   830 %WN <--> \chapter 7 der Thesis
   828 TODO
   831 TODO
   829 \subsection{Preparation of Simplifiers for the Program}\label{simp}
   832 \subsection{Preparation of Simplifiers for the Program}\label{simp}
   830 TODO
   833 
       
   834 %JR: ich denke wir können diesen punkt weglassen, methoden wie
       
   835 %JR: drop_questionmarks und ähnliche sind im arical nicht ersichtlich und im 
       
   836 %JR: grunde nicht relevant (ihre erstellung gleich wie functionen im nächsten
       
   837 %JR: Punkt)
       
   838 
   831 \subsection{Preparation of ML-Functions}\label{funs}
   839 \subsection{Preparation of ML-Functions}\label{funs}
   832 %WN <--> Thesis 6.1 -- 6.3: jene ausw"ahlen, die Du f"ur \label{progr}
   840 
   833 %WN brauchst
   841 \paragraph{Explicit Problems} require explicit methods to solve them, and within
   834 TODO
   842 this methods we have some explicit steps to do. This steps can be unique for
       
   843 a special problem or refindable in other problems. No mather what case, such
       
   844 steps often require some technical functions behind. For the solving process
       
   845 of the Inverse Z Transformation and the corresponding partial fraction it was
       
   846 neccessary to build helping functions like \texttt{get\_denominator},
       
   847 \texttt{get\_numerator} or \texttt{argument\_in}. First two functions help us
       
   848 to filter the deonimonator or numerator out of a fraction, last one helps us to
       
   849 get to know the bound variable in a equation.
       
   850 \par
       
   851 By taking \texttt{get\_denominator} we want to explain how to implement new
       
   852 functions into the existing system and how we can later use them in our program.
       
   853 
       
   854 \subsubsection{Find a place to Store the Function}
       
   855 The whole system builds up on a well defined structure of Knowledge. This
       
   856 Knowledge sets up at\ttfamily src/Tools/isac/Knowledge\normalfont. For the
       
   857 implementation of the Function \texttt{get\_denominator}, which let us now
       
   858 the denominator of a fraction we have choosen the Theory (file)
       
   859 \texttt{Rational.thy}.
       
   860 
       
   861 \subsubsection{Write down the new Function}
       
   862 
       
   863 \begin{example}
       
   864 \begin{verbatim}
       
   865 
       
   866 ML {*
       
   867 (*
       
   868  *("get_denominator",
       
   869  *  ("Rational.get_denominator", eval_get_denominator ""))
       
   870  *)
       
   871 fun eval_get_denominator (thmid:string) _ 
       
   872           (t as Const ("Rational.get_denominator", _) $
       
   873               (Const ("Rings.inverse_class.divide", _) $num 
       
   874                 $denom)) thy = 
       
   875         SOME (mk_thmid thmid "" 
       
   876             (Print_Mode.setmp [] 
       
   877               (Syntax.string_of_term (thy2ctxt thy)) denom) "", 
       
   878             Trueprop $ (mk_equality (t, denom)))
       
   879   | eval_get_denominator _ _ _ _ = NONE; 
       
   880 *}\end{verbatim}
       
   881 \end{example}
       
   882 
       
   883 
       
   884 \subsubsection{Add a test for the new Function}
       
   885 \subsubsection{Use the new Function}
       
   886 
       
   887 
       
   888 
   835 \subsection{Implementation of the TP-based Program}\label{progr}
   889 \subsection{Implementation of the TP-based Program}\label{progr}
   836 %WN <--> \chapter 8 der Thesis
   890 %WN <--> \chapter 8 der Thesis
   837 .\\.\\.\\
   891 .\\.\\.\\
   838 
   892 
   839 {\small\it\begin{tabbing}
   893 {\small\it\begin{tabbing}
   880 
   934 
   881 .\\.\\.\\
   935 .\\.\\.\\
   882 
   936 
   883 \section{Workflow of Programming in the Prototype}\label{workflow}
   937 \section{Workflow of Programming in the Prototype}\label{workflow}
   884 
   938 
   885 \cite{makar-jedit-12}
       
   886 
       
   887 \subsection{Preparations and Trials}\label{flow-prep}
   939 \subsection{Preparations and Trials}\label{flow-prep}
   888 TODO Build\_Inverse\_Z\_Transform.thy ... ``imports PolyEq DiffApp Partial\_Fractions''
   940 TODO Build\_Inverse\_Z\_Transform.thy ... ``imports PolyEq DiffApp Partial\_Fractions''
   889 .\\.\\.\\
   941 .\\.\\.\\
   890 
   942 
       
   943 %JR: Hier sollte eigentlich stehen was nun bei 4.3.1 ist. Habe das erst kürzlich
       
   944 %JR: eingefügt; das war der beinn unserer Arbeit in
       
   945 %JR: Build_Inverse_Z_Transformation und beschreibt die meiner Meinung nach bei
       
   946 %JR: jedem neuen Programm nötigen Schritte.
       
   947 
   891 \subsection{Implementation in Isabelle/{\isac}}\label{flow-impl}
   948 \subsection{Implementation in Isabelle/{\isac}}\label{flow-impl}
   892 TODO Build\_Inverse\_Z\_Transform.thy ... ``imports Isac''
   949 
   893 .\\.\\.\\
   950 \paragraph{At the beginning} of the implementation it is good to decide on one
   894 
   951 way the problem should be solved. We also did this for our Z-Transformation
   895 below: calculation on the left; on the right are the tactics in the
   952 Problem and have choosen the way it is also thaugt in the Signal Processing
   896 program which created the respective formula on the left.
   953 Problem classes.
       
   954 \subparagraph{By writing down} each of this neccesarry steps we are describing
       
   955 one line of our upcoming program. In the following example we show the 
       
   956 Calculation on the left and on the right the tactics in the program which
       
   957 created the respective formula on the left.
       
   958 
       
   959 \begin{example}
       
   960 \hfill\\
   897 {\small\it
   961 {\small\it
   898 \begin{tabbing}
   962 \begin{tabbing}
   899 123l\=123\=123\=123\=123\=123\=123\=123\=123\=123\=123\=123\=\kill
   963 123l\=123\=123\=123\=123\=123\=123\=123\=123\=123\=123\=123\=\kill
   900 \>{\rm 01}\> $\bullet$  \> {\tt Problem } (Inverse\_Z\_Transform, [Inverse, Z\_Transform, SignalProcessing])       \`\\
   964 \>{\rm 01}\> $\bullet$  \> {\tt Problem } (Inverse\_Z\_Transform, [Inverse, Z\_Transform, SignalProcessing])       \`\\
   901 \>{\rm 02}\>\> $\vdash\;\;X z = \frac{3}{z - \frac{1}{4} - \frac{1}{8} \cdot z^{-1}}$       \`{\footnotesize {\tt Take} X\_eq}\\
   965 \>{\rm 02}\>\> $\vdash\;\;X z = \frac{3}{z - \frac{1}{4} - \frac{1}{8} \cdot z^{-1}}$       \`{\footnotesize {\tt Take} X\_eq}\\
   912 \>{\rm 12}\>\> $X^\prime z = {\cal Z}^{-1} (\frac{4}{z - \frac{1}{2}} + \frac{-4}{z - \frac{-1}{4}})$ \`{\footnotesize {\tt Take} ((X'::real =$>$ bool) z = ZZ\_1 part\_frac)}\\
   976 \>{\rm 12}\>\> $X^\prime z = {\cal Z}^{-1} (\frac{4}{z - \frac{1}{2}} + \frac{-4}{z - \frac{-1}{4}})$ \`{\footnotesize {\tt Take} ((X'::real =$>$ bool) z = ZZ\_1 part\_frac)}\\
   913 \>{\rm 13}\>\> $X^\prime z = {\cal Z}^{-1} (4\cdot\frac{z}{z - \frac{1}{2}} + -4\cdot\frac{z}{z - \frac{-1}{4}})$ \`{\footnotesize{\tt Rewrite\_Set} ruleYZ X'\_eq }\\
   977 \>{\rm 13}\>\> $X^\prime z = {\cal Z}^{-1} (4\cdot\frac{z}{z - \frac{1}{2}} + -4\cdot\frac{z}{z - \frac{-1}{4}})$ \`{\footnotesize{\tt Rewrite\_Set} ruleYZ X'\_eq }\\
   914 \>{\rm 14}\>\> $X^\prime z = 4\cdot(\frac{1}{2})^n \cdot u [n] + -4\cdot(\frac{-1}{4})^n \cdot u [n]$  \`{\footnotesize {\tt Rewrite\_Set} inverse\_z X'\_eq}\\
   978 \>{\rm 14}\>\> $X^\prime z = 4\cdot(\frac{1}{2})^n \cdot u [n] + -4\cdot(\frac{-1}{4})^n \cdot u [n]$  \`{\footnotesize {\tt Rewrite\_Set} inverse\_z X'\_eq}\\
   915 \>{\rm 15}\> \dots\> $X^\prime z = 4\cdot(\frac{1}{2})^n \cdot u [n] + -4\cdot(\frac{-1}{4})^n \cdot u [n]$ \`{\footnotesize {\tt Check\_Postcond}}
   979 \>{\rm 15}\> \dots\> $X^\prime z = 4\cdot(\frac{1}{2})^n \cdot u [n] + -4\cdot(\frac{-1}{4})^n \cdot u [n]$ \`{\footnotesize {\tt Check\_Postcond}}
   916 \end{tabbing}}
   980 \end{tabbing}}
       
   981 
       
   982 \end{example}
       
   983 
   917 % ORIGINAL FROM Inverse_Z_Transform.thy
   984 % ORIGINAL FROM Inverse_Z_Transform.thy
   918 %    "Script InverseZTransform (X_eq::bool) =            "^(*([], Frm), Problem (Isac, [Inverse, Z_Transform, SignalProcessing])*)
   985 %    "Script InverseZTransform (X_eq::bool) =            "^(*([], Frm), Problem (Isac, [Inverse, Z_Transform, SignalProcessing])*)
   919 %    "(let X = Take X_eq;                                "^(*([1], Frm), X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))*)
   986 %    "(let X = Take X_eq;                                "^(*([1], Frm), X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))*)
   920 %    "  X' = Rewrite ruleZY False X;                     "^(*([1], Res), ?X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))*)
   987 %    "  X' = Rewrite ruleZY False X;                     "^(*([1], Res), ?X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))*)
   921 %    "  (X'_z::real) = lhs X';                           "^(*            ?X' z*)
   988 %    "  (X'_z::real) = lhs X';                           "^(*            ?X' z*)
  1030 In our special case of Signal Processing and the rules defined in
  1097 In our special case of Signal Processing and the rules defined in
  1031 Example~\ref{eg:ruledef} we have to apply rule~1 first of all to transform all
  1098 Example~\ref{eg:ruledef} we have to apply rule~1 first of all to transform all
  1032 constants. After this step has been done it no mather which rule fit's next.
  1099 constants. After this step has been done it no mather which rule fit's next.
  1033 
  1100 
  1034 \subsubsection{Helping Functions}
  1101 \subsubsection{Helping Functions}
  1035 %get denom, argument in
  1102 
       
  1103 \paragraph{New Programms require,} often new ways to get through. This new ways
       
  1104 means that we handle functions that have not been in use yet, they can be 
       
  1105 something special and unique for a programm or something famous but unneeded in
       
  1106 the system yet. In our dedicated example it was for example neccessary to split
       
  1107 a fraction into numerator and denominator; the creation of such function and
       
  1108 even others is described in upper Sections~\ref{simp} and \ref{funs}.
       
  1109 
  1036 \subsubsection{Trials on equation solving}
  1110 \subsubsection{Trials on equation solving}
  1037 %simple eq and problem with double fractions/negative exponents
  1111 %simple eq and problem with double fractions/negative exponents
  1038 
  1112 \paragraph{The Inverse Z-Transformation} makes it neccessary to solve
  1039 
  1113 equations degree one and two. Solving equations in the first degree is no 
       
  1114 problem, wether for a student nor for our machine; but even second degree
       
  1115 equations can lead to big troubles. The origin of this troubles leads from
       
  1116 the build up process of our equation solving functions; they have been
       
  1117 implemented some time ago and of course they are not as good as we want them to
       
  1118 be. Wether or not following we only want to show how cruel it is to build up new
       
  1119 work on not well fundamentials.
       
  1120 \subparagraph{A simple equation solving,} can be set up as shown in the next
       
  1121 example:
       
  1122 
       
  1123 \begin{example}
       
  1124 \begin{verbatim}
       
  1125   
       
  1126   val fmz =
       
  1127     ["equality (-1 + -2 * z + 8 * z ^^^ 2 = (0::real))",
       
  1128      "solveFor z",
       
  1129      "solutions L"];                                    
       
  1130 
       
  1131   val (dI',pI',mI') =
       
  1132     ("Isac", 
       
  1133       ["abcFormula","degree_2","polynomial","univariate","equation"],
       
  1134       ["no_met"]);\end{verbatim}
       
  1135 \end{example}
       
  1136 
       
  1137 Here we want to solve the equation: $-1+-2\cdot z+8\cdot z^{2}=0$. (To give
       
  1138 a short overview on the commands; at first we set up the equation and tell the
       
  1139 machine what's the bound variable and where to store the solution. Second step 
       
  1140 is to define the equation type and determine if we want to use a special method
       
  1141 to solve this type.) Simple checks tell us that the we will get two results for
       
  1142 this equation and this results will be real.
       
  1143 So far it is easy for us and for our machine to solve, but
       
  1144 mentioned that a unvariate equation second order can have three different types
       
  1145 of solutions it is getting worth.
       
  1146 \subparagraph{The solving of} all this types of solutions is not yet supported.
       
  1147 Luckily it was needed for us; but something which has been needed in this 
       
  1148 context, would have been the solving of an euation looking like:
       
  1149 $-z^{-2}+-2\cdot z^{-1}+8=0$ which is basically the same equation as mentioned
       
  1150 before (remember that befor it was no problem to handle for the machine) but
       
  1151 now, after a simple equivalent transformation, we are not able to solve
       
  1152 it anymore.
       
  1153 \subparagraph{Error messages} we get when we try to solve something like upside
       
  1154 were very confusing and also leads us to no special hint about a problem.
       
  1155 \par The fault behind is, that we have no well error handling on one side and
       
  1156 no sufficient formed equation solving on the other side. This two facts are
       
  1157 making the implemention of new material very difficult.
  1040 
  1158 
  1041 \subsection{Formalization of missing knowledge in Isabelle}
  1159 \subsection{Formalization of missing knowledge in Isabelle}
  1042 
  1160 
  1043 \paragraph{A problem} behind is the mechanization of mathematic
  1161 \paragraph{A problem} behind is the mechanization of mathematic
  1044 theories in TP-bases languages. There is still a huge gap between
  1162 theories in TP-bases languages. There is still a huge gap between