664 reasonably short and easily comprehensible, still requires lots of |
664 reasonably short and easily comprehensible, still requires lots of |
665 work (and is definitely out of scope of our case study). |
665 work (and is definitely out of scope of our case study). |
666 |
666 |
667 \paragraph{At the state-of-the-art in mechanization of knowledge} in |
667 \paragraph{At the state-of-the-art in mechanization of knowledge} in |
668 engineering sciences, the process does not stop with the mechanization of |
668 engineering sciences, the process does not stop with the mechanization of |
669 mathematics traditionally used in these sciences. Rather, ``Formal Methods''~\cite{TODO-formal-methods} |
669 mathematics traditionally used in these sciences. Rather, ``Formal Methods''. |
|
670 %% \cite{TODO-formal-methods} |
670 are expected to proceed to formal and explicit description of physical items. Signal Processing, |
671 are expected to proceed to formal and explicit description of physical items. Signal Processing, |
671 for instance is concerned with physical devices for signal acquisition |
672 for instance is concerned with physical devices for signal acquisition |
672 and reconstruction, which involve measuring a physical signal, storing |
673 and reconstruction, which involve measuring a physical signal, storing |
673 it, and possibly later rebuilding the original signal or an |
674 it, and possibly later rebuilding the original signal or an |
674 approximation thereof. For digital systems, this typically includes |
675 approximation thereof. For digital systems, this typically includes |
675 sampling and quantization; devices for signal compression, including |
676 sampling and quantization; devices for signal compression, including |
676 audio compression, image compression, and video compression, etc. |
677 audio compression, image compression, and video compression, etc. |
677 ``Domain engineering''\cite{db-domain-engineering} is concerned with |
678 ``Domain engineering'' |
|
679 %% \cite{db-domain-engineering} |
|
680 is concerned with |
678 {\em specification} of these devices' components and features; this |
681 {\em specification} of these devices' components and features; this |
679 part in the process of mechanization is only at the beginning in domains |
682 part in the process of mechanization is only at the beginning in domains |
680 like Signal Processing. |
683 like Signal Processing. |
681 |
684 |
682 \subparagraph{TP-based programming, concern of this paper,} is determined to |
685 \subparagraph{TP-based programming, concern of this paper,} is determined to |
693 Fig.\ref{fig-interactive} on p.\pageref{fig-interactive}. The {\em |
696 Fig.\ref{fig-interactive} on p.\pageref{fig-interactive}. The {\em |
694 formal} specification of this problem, in traditional mathematical |
697 formal} specification of this problem, in traditional mathematical |
695 notation, could look like is this: |
698 notation, could look like is this: |
696 |
699 |
697 %WN Hier brauchen wir die Spezifikation des 'running example' ... |
700 %WN Hier brauchen wir die Spezifikation des 'running example' ... |
698 |
|
699 %JR Habe input, output und precond vom Beispiel eingefügt brauche aber Hilfe bei |
701 %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 |
702 %JR der post condition - die existiert für uns ja eigentlich nicht aka |
701 %JR haben sie bis jetzt nicht beachtet WN... |
703 %JR haben sie bis jetzt nicht beachtet WN... |
702 %WN2 Mein Vorschlag ist, das TODO zu lassen und deutlich zu kommentieren. |
704 %WN2 Mein Vorschlag ist, das TODO zu lassen und deutlich zu kommentieren. |
|
705 %JR2 done |
703 |
706 |
704 \label{eg:neuper2} |
707 \label{eg:neuper2} |
705 {\small\begin{tabbing} |
708 {\small\begin{tabbing} |
706 123,\=postcond \=: \= $\forall \,A^\prime\, u^\prime \,v^\prime.\,$\=\kill |
709 123,\=postcond \=: \= $\forall \,A^\prime\, u^\prime \,v^\prime.\,$\=\kill |
707 \hfill \\ |
710 \hfill \\ |
709 \>input \>: filterExpression $X=\frac{3}{(z-\frac{1}{4}+-\frac{1}{8}*\frac{1}{z}}$\\ |
712 \>input \>: filterExpression $X=\frac{3}{(z-\frac{1}{4}+-\frac{1}{8}*\frac{1}{z}}$\\ |
710 \>precond \>: filterExpression continius on $\mathbb{R}$ \\ |
713 \>precond \>: filterExpression continius on $\mathbb{R}$ \\ |
711 \>output \>: stepResponse $x[n]$ \\ |
714 \>output \>: stepResponse $x[n]$ \\ |
712 \>postcond \>: TODO - (Mind the following remark)\\ \end{tabbing}} |
715 \>postcond \>: TODO - (Mind the following remark)\\ \end{tabbing}} |
713 |
716 |
714 \paragraph{Remark on post-conditions:} Defining the postcondition requires a |
717 \begin{remark} |
715 high amount mathematical knowledge, the difficult part in our case is not to |
718 Defining the postcondition requires a high amount mathematical |
716 set up this condition nor it is more to define it in a way the interpreter is |
719 knowledge, the difficult part in our case is not to set up this condition |
717 able to handle it. Due the fact that implementing that mechanisms is quite |
720 nor it is more to define it in a way the interpreter is able to handle it. |
718 the same amount as creating the programm itself, it is not avaible in our |
721 Due the fact that implementing that mechanisms is quite the same amount as |
719 prototype.\label{rm:postcond} |
722 creating the programm itself, it is not avaible in our prototype. |
|
723 \label{rm:postcond} |
|
724 \end{remark} |
720 |
725 |
721 \paragraph{The implementation} of the formal specification in the present |
726 \paragraph{The implementation} of the formal specification in the present |
722 prototype, still bar-bones without support for authoring: |
727 prototype, still bar-bones without support for authoring: |
723 %WN Kopie von Inverse_Z_Transform.thy, leicht versch"onert: |
728 %WN Kopie von Inverse_Z_Transform.thy, leicht versch"onert: |
724 {\footnotesize |
729 {\footnotesize |
759 \item[06] is a key into the tree of all specifications as presented to |
764 \item[06] is a key into the tree of all specifications as presented to |
760 the user (where some branches might be hidden by the dialog |
765 the user (where some branches might be hidden by the dialog |
761 component). |
766 component). |
762 \item[07..10] are the specification with input, pre-condition, output |
767 \item[07..10] are the specification with input, pre-condition, output |
763 and post-condition respectively; the post-condition is not handled in |
768 and post-condition respectively; the post-condition is not handled in |
764 the prototype presently. (Follow up Remark in Section~\ref{rm:postcond}) |
769 the prototype presently. (Follow up Remark~\ref{rm:postcond}) |
765 \item[11] creates a term rewriting system (abbreviated \textit{rls} in |
770 \item[11] creates a term rewriting system (abbreviated \textit{rls} in |
766 {\sisac}) which evaluates the pre-condition for the actual input data. |
771 {\sisac}) which evaluates the pre-condition for the actual input data. |
767 Only if the evaluation yields \textit{True}, a program con be started. |
772 Only if the evaluation yields \textit{True}, a program con be started. |
768 \item[12]\textit{NONE:} could be \textit{SOME ``solve ...''} for a |
773 \item[12]\textit{NONE:} could be \textit{SOME ``solve ...''} for a |
769 problem associated to a function from Computer Algebra (like an |
774 problem associated to a function from Computer Algebra (like an |
843 a special problem or refindable in other problems. No mather what case, such |
848 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 |
849 steps often require some technical functions behind. For the solving process |
845 of the Inverse Z Transformation and the corresponding partial fraction it was |
850 of the Inverse Z Transformation and the corresponding partial fraction it was |
846 neccessary to build helping functions like \texttt{get\_denominator}, |
851 neccessary to build helping functions like \texttt{get\_denominator}, |
847 \texttt{get\_numerator} or \texttt{argument\_in}. First two functions help us |
852 \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 |
853 to filter the denominator or numerator out of a fraction, last one helps us to |
849 get to know the bound variable in a equation. |
854 get to know the bound variable in a equation. |
850 \par |
855 \par |
851 By taking \texttt{get\_denominator} we want to explain how to implement new |
856 By taking \texttt{get\_denominator} as an example, we want to explain how to |
852 functions into the existing system and how we can later use them in our program. |
857 implement new functions into the existing system and how we can later use them |
|
858 in our program. |
853 |
859 |
854 \subsubsection{Find a place to Store the Function} |
860 \subsubsection{Find a place to Store the Function} |
|
861 |
855 The whole system builds up on a well defined structure of Knowledge. This |
862 The whole system builds up on a well defined structure of Knowledge. This |
856 Knowledge sets up at the Path: \ttfamily src/Tools/isac/Knowledge\normalfont. |
863 Knowledge sets up at the Path: |
|
864 \begin{center}\ttfamily src/Tools/isac/Knowledge\normalfont\end{center} |
857 For implementing the Function \texttt{get\_denominator} (which let us extract |
865 For implementing the Function \texttt{get\_denominator} (which let us extract |
858 the denominator out of a fraction) we have choosen the Theory (file) |
866 the denominator out of a fraction) we have choosen the Theory (file) |
859 \texttt{Rational.thy}. |
867 \texttt{Rational.thy}. |
860 |
868 |
861 \subsubsection{Write down the new Function} |
869 \subsubsection{Write down the new Function} |
|
870 |
862 In upper Theory we now define the new function and its purpose: |
871 In upper Theory we now define the new function and its purpose: |
863 \begin{verbatim} |
872 \begin{verbatim} |
864 get_denominator :: "real => real" |
873 get_denominator :: "real => real" |
865 \end{verbatim} |
874 \end{verbatim} |
866 This command tells the machine that a function with the name |
875 This command tells the machine that a function with the name |
867 \texttt{get\_denominator} exists which gets a real expression as argument and |
876 \texttt{get\_denominator} exists which gets a real expression as argument and |
868 returns once again a real expression. Now we are able to implement the function itself, Example~\ref{eg:getdenom} |
877 returns once again a real expression. Now we are able to implement the function |
869 shows the implementation of \texttt{get\_denominator}. |
878 itself, Example~\ref{eg:getdenom} now shows the implementation of |
|
879 \texttt{get\_denominator}. |
870 |
880 |
871 \begin{example} |
881 \begin{example} |
872 \label{eg:getdenom} |
882 \label{eg:getdenom} |
873 \begin{verbatim} |
883 \begin{verbatim} |
874 |
884 |
888 \end{example} |
898 \end{example} |
889 |
899 |
890 Line \texttt{07} and \texttt{08} are describing the mode of operation the best - |
900 Line \texttt{07} and \texttt{08} are describing the mode of operation the best - |
891 there is a fraction\\ (\ttfamily Rings.inverse\_class.divide\normalfont) |
901 there is a fraction\\ (\ttfamily Rings.inverse\_class.divide\normalfont) |
892 splittet |
902 splittet |
893 into its two parts (\texttt{ \$num \$denom}). The lines before are additionals |
903 into its two parts (\texttt{\$num \$denom}). The lines before are additionals |
894 commands for declaring the function and the lines after are modeling and |
904 commands for declaring the function and the lines after are modeling and |
895 returning a real variable out of \texttt{\$denom}. |
905 returning a real variable out of \texttt{\$denom}. |
896 |
906 |
897 \subsubsection{Add a test for the new Function} |
907 \subsubsection{Add a test for the new Function} |
898 \subsubsection{Use the new Function} |
908 |
899 |
909 \paragraph{Everytime when adding} a new function it is essential also to add |
900 |
910 a test for it. Tests for all functions are sorted in the same structure as the |
|
911 knowledge it self and can be found up from the path: |
|
912 \begin{center}\ttfamily test/Tools/isac/Knowledge\normalfont\end{center} |
|
913 This tests are nothing very special, as a first prototype the functionallity |
|
914 of a function can be checked by evaluating the result of a simple expression |
|
915 passed to the function. Example~\ref{eg:getdenomtest} shows the test for our |
|
916 \textit{just} created function \texttt{get\_denominator}. |
|
917 |
|
918 \begin{example} |
|
919 \label{eg:getdenomtest} |
|
920 \begin{verbatim} |
|
921 |
|
922 01 val thy = @{theory Isac}; |
|
923 02 val t = term_of (the (parse thy "get_denominator ((a +x)/b)")); |
|
924 03 val SOME (_, t') = eval_get_denominator "" 0 t thy; |
|
925 04 if term2str t' = "get_denominator ((a + x) / b) = b" then () |
|
926 05 else error "get_denominator ((a + x) / b) = b" \end{verbatim} |
|
927 \end{example} |
|
928 |
|
929 \begin{description} |
|
930 \item[01] checks if the proofer set up on our {\sisac{}} System. |
|
931 \item[02] passes a simple expression (fraction) to our suddenly created |
|
932 function. |
|
933 \item[04] checks if the resulting variable is the correct one (in this case |
|
934 ``b'' the denominator) and returns. |
|
935 \item[05] handels the error case and reports that the function is not able to |
|
936 solve the given problem. |
|
937 \end{description} |
901 |
938 |
902 \subsection{Implementation of the TP-based Program}\label{progr} |
939 \subsection{Implementation of the TP-based Program}\label{progr} |
903 %WN <--> \chapter 8 der Thesis |
940 |
904 .\\.\\.\\ |
941 \paragraph{After introducing} neccesarry informations about the {\sisac{}} |
905 |
942 System, the main part of a implementation in the TP-bases language can be shown. |
906 {\small\it\begin{tabbing} |
943 \par |
|
944 Solution~\ref{s:impl} shows us the implementation of the |
|
945 Inverse-Z-Transformation, a description on the code is given afterwards. |
|
946 |
|
947 \begin{solution} |
|
948 \label{s:impl} |
|
949 \begin{tabbing} |
|
950 \small\it |
907 123l\=123\=123\=123\=123\=123\=123\=123\=123\=(x \=123\=123\=\kill |
951 123l\=123\=123\=123\=123\=123\=123\=123\=123\=(x \=123\=123\=\kill |
|
952 \> \\ |
|
953 \> \\ |
908 \>{\rm 01}\> {\tt Program} InverseZTransform (X\_eq::bool) = \\ |
954 \>{\rm 01}\> {\tt Program} InverseZTransform (X\_eq::bool) = \\ |
909 \>{\rm 02}\>\> {\tt LET} \\ |
955 \>{\rm 02}\>\> {\tt LET} \\ |
910 \>{\rm 03}\>\>\> X\_eq = {\tt Take} X\_eq ; \\ |
956 \>{\rm 03}\>\>\> X\_eq = {\tt Take} X\_eq ; \\ |
911 \>{\rm 04}\>\>\> X\_eq = {\tt Rewrite} ruleZY X\_eq ; \\ |
957 \>{\rm 04}\>\>\> X\_eq = {\tt Rewrite} ruleZY X\_eq ; \\ |
912 \>{\rm 05}\>\>\> (X\_z::real) = lhs X\_eq ; \\ %no inside-out evaluation |
958 \>{\rm 05}\>\>\> (X\_z::real) = lhs X\_eq ; \\ %no inside-out evaluation |
920 |
966 |
921 \>{\rm 12}\>\>\> X'\_eq = {\tt Rewrite\_Set} ruleYZ X'\_eq ; \\ |
967 \>{\rm 12}\>\>\> X'\_eq = {\tt Rewrite\_Set} ruleYZ X'\_eq ; \\ |
922 \>{\rm 15}\>\>\> X'\_eq = {\tt Rewrite\_Set} inverse\_z X'\_eq \\ |
968 \>{\rm 15}\>\>\> X'\_eq = {\tt Rewrite\_Set} inverse\_z X'\_eq \\ |
923 \>{\rm 16}\>\> {\tt IN } \\ |
969 \>{\rm 16}\>\> {\tt IN } \\ |
924 \>{\rm 15}\>\>\> X'\_eq |
970 \>{\rm 15}\>\>\> X'\_eq |
925 \end{tabbing}} |
971 \end{tabbing} |
|
972 \end{solution} |
|
973 |
926 % ORIGINAL FROM Inverse_Z_Transform.thy |
974 % ORIGINAL FROM Inverse_Z_Transform.thy |
927 % "Script InverseZTransform (X_eq::bool) = "^(*([], Frm), Problem (Isac, [Inverse, Z_Transform, SignalProcessing])*) |
975 % "Script InverseZTransform (X_eq::bool) = "^(*([], Frm), Problem (Isac, [Inverse, Z_Transform, SignalProcessing])*) |
928 % "(let X = Take X_eq; "^(*([1], Frm), X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))*) |
976 % "(let X = Take X_eq; "^(*([1], Frm), X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))*) |
929 % " X' = Rewrite ruleZY False X; "^(*([1], Res), ?X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))*) |
977 % " X' = Rewrite ruleZY False X; "^(*([1], Res), ?X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))*) |
930 % " (X'_z::real) = lhs X'; "^(* ?X' z*) |
978 % " (X'_z::real) = lhs X'; "^(* ?X' z*) |
941 % " pbz_eq = drop_questionmarks pbz_eq; "^(* 4 * (z / (z - 1 / 2)) + -4 * (z / (z - -1 / 4))*) |
989 % " pbz_eq = drop_questionmarks pbz_eq; "^(* 4 * (z / (z - 1 / 2)) + -4 * (z / (z - -1 / 4))*) |
942 % " (X_zeq::bool) = Take (X_z = rhs pbz_eq); "^(*([4], Frm), X_z = 4 * (z / (z - 1 / 2)) + -4 * (z / (z - -1 / 4))*) |
990 % " (X_zeq::bool) = Take (X_z = rhs pbz_eq); "^(*([4], Frm), X_z = 4 * (z / (z - 1 / 2)) + -4 * (z / (z - -1 / 4))*) |
943 % " n_eq = (Rewrite_Set inverse_z False) X_zeq; "^(*([4], Res), X_z = 4 * (1 / 2) ^^^ ?n * ?u [?n] + -4 * (-1 / 4) ^^^ ?n * ?u [?n]*) |
991 % " n_eq = (Rewrite_Set inverse_z False) X_zeq; "^(*([4], Res), X_z = 4 * (1 / 2) ^^^ ?n * ?u [?n] + -4 * (-1 / 4) ^^^ ?n * ?u [?n]*) |
944 % " n_eq = drop_questionmarks n_eq "^(* X_z = 4 * (1 / 2) ^^^ n * u [n] + -4 * (-1 / 4) ^^^ n * u [n]*) |
992 % " n_eq = drop_questionmarks n_eq "^(* X_z = 4 * (1 / 2) ^^^ n * u [n] + -4 * (-1 / 4) ^^^ n * u [n]*) |
945 % "in n_eq)" (*([], Res), X_z = 4 * (1 / 2) ^^^ n * u [n] + -4 * (-1 / 4) ^^^ n * u [n]*) |
993 % "in n_eq)" (*([], Res), X_z = 4 * (1 / 2) ^^^ n * u [n] + -4 * (-1 / 4) ^^^ n * u [n]*) |
946 |
|
947 |
|
948 .\\.\\.\\ |
|
949 |
994 |
950 \section{Workflow of Programming in the Prototype}\label{workflow} |
995 \section{Workflow of Programming in the Prototype}\label{workflow} |
951 |
996 |
952 \subsection{Preparations and Trials}\label{flow-prep} |
997 \subsection{Preparations and Trials}\label{flow-prep} |
953 TODO Build\_Inverse\_Z\_Transform.thy ... ``imports PolyEq DiffApp Partial\_Fractions'' |
998 TODO Build\_Inverse\_Z\_Transform.thy ... ``imports PolyEq DiffApp Partial\_Fractions'' |