220 programming language, called |
220 programming language, called |
221 Lucas-Interpreter~\cite{wn:lucas-interp-12}. The language and the |
221 Lucas-Interpreter~\cite{wn:lucas-interp-12}. The language and the |
222 interpreter will be briefly re-introduced in order to make the paper |
222 interpreter will be briefly re-introduced in order to make the paper |
223 self-contained. |
223 self-contained. |
224 |
224 |
225 \subparagraph{The main part} of the paper is an account of first experiences |
225 \paragraph{The main part} of the paper is an account of first experiences |
226 with programming in this TP-based language. The experience was gained |
226 with programming in this TP-based language. The experience was gained |
227 in a case study by the author. The author was considered an ideal |
227 in a case study by the author. The author was considered an ideal |
228 candidate for this study for the following reasons: as a student in |
228 candidate for this study for the following reasons: as a student in |
229 Telematics (computer science with focus on Signal Processing) he had |
229 Telematics (computer science with focus on Signal Processing) he had |
230 general knowledge in programming as well as specific domain knowledge |
230 general knowledge in programming as well as specific domain knowledge |
231 in Signal Processing; and he was not involved in the development of |
231 in Signal Processing; and he was not involved in the development of |
232 {\sisac}'s programming language and interpeter, thus a novice to the |
232 {\sisac}'s programming language and interpeter, thus a novice to the |
233 language. |
233 language. |
234 |
234 |
235 \subparagraph{The goal} of the case study was (1) some TP-based programs for |
235 \paragraph{The goal} of the case study was (1) some TP-based programs for |
236 interactive course material for a specific ``Adavanced Signal |
236 interactive course material for a specific ``Adavanced Signal |
237 Processing Lab'' in a higher semester, (2) respective program |
237 Processing Lab'' in a higher semester, (2) respective program |
238 development with as little advice from the {\sisac}-team and (3) records |
238 development with as little advice from the {\sisac}-team and (3) records |
239 and comments for the main steps of development in an Isabelle theory; |
239 and comments for the main steps of development in an Isabelle theory; |
240 this theory should provide guidelines for future programmers. An |
240 this theory should provide guidelines for future programmers. An |
703 The language for both axes is defined in the axis at the bottom, deductive |
703 The language for both axes is defined in the axis at the bottom, deductive |
704 knowledge, in {\sisac} represented by Isabelle's theories. |
704 knowledge, in {\sisac} represented by Isabelle's theories. |
705 |
705 |
706 \subsection{Preparation of Simplifiers for the Program}\label{simp} |
706 \subsection{Preparation of Simplifiers for the Program}\label{simp} |
707 |
707 |
708 \paragraph{If it is clear} how the later calculation should look like and when |
708 If it is clear how the later calculation should look like and when |
709 which mathematic rule should be applied, it can be started to find ways of |
709 which mathematic rule should be applied, it can be started to find ways of |
710 simplifications. This includes in e.g. the simplification of reational |
710 simplifications. This includes in e.g. the simplification of reational |
711 expressions or also rewrites of an expession. |
711 expressions or also rewrites of an expession. |
712 \subparagraph{Obligate is the use} of the function \texttt{drop\_questionmarks} |
712 \par |
|
713 Obligate is the use of the function \texttt{drop\_questionmarks} |
713 which excludes irrelevant symbols out of the expression. (Irrelevant symbols may |
714 which excludes irrelevant symbols out of the expression. (Irrelevant symbols may |
714 be result out of the system during the calculation. The function has to be |
715 be result out of the system during the calculation. The function has to be |
715 applied for two reasons. First two make every placeholder in a expression |
716 applied for two reasons. First two make every placeholder in a expression |
716 useable as a constant and second to provide a better view at the frontend.) |
717 useable as a constant and second to provide a better view at the frontend.) |
717 \subparagraph{Most rewrites are represented} through rulesets this |
718 \par |
|
719 Most rewrites are represented through rulesets this |
718 rulesets tell the machine which terms have to be rewritten into which |
720 rulesets tell the machine which terms have to be rewritten into which |
719 representation. In the upcoming programm a rewrite can be applied only in using |
721 representation. In the upcoming programm a rewrite can be applied only in using |
720 such rulesets on existing terms. |
722 such rulesets on existing terms. |
721 \paragraph{The core} of our implemented problem is the Z-Transformation |
723 \paragraph{The core} of our implemented problem is the Z-Transformation |
722 (remember the description of the running example, introduced by |
724 (remember the description of the running example, introduced by |
723 Fig.\ref{fig-interactive} on p.\pageref{fig-interactive}) due the fact that the |
725 Fig.\ref{fig-interactive} on p.\pageref{fig-interactive}) due the fact that the |
724 transformation itself would require higher math which isn't yet avaible in our system we decided to choose the way like it is applied in labratory and problem classes at our university - by applying transformation rules (collected in |
726 transformation itself would require higher math which isn't yet avaible in our system we decided to choose the way like it is applied in labratory and problem classes at our university - by applying transformation rules (collected in |
725 transformation tables). |
727 transformation tables). |
726 \paragraph{Rules,} in {\sisac{}}'s programming language can be designed by the |
728 \par |
727 use of axiomatizations like shown in Example~\ref{eg:ruledef}. This rules can be |
729 Rules, in {\sisac{}}'s programming language can be designed by the use of |
728 collected in a ruleset (collection of rules) and applied to a given expression |
730 axiomatization. In this axiomatization we declare how a term has to look like |
729 as follows in the next example code. |
731 (left side) to be rewritten into another form (right side). Every line of this |
|
732 axiomatizations starts with the name of the rule. |
730 |
733 |
731 %\begin{example} |
734 %\begin{example} |
|
735 {\footnotesize |
732 \label{eg:ruledef} |
736 \label{eg:ruledef} |
733 \hfill\\ |
737 % \hfill\\ |
734 \begin{verbatim} |
738 \begin{verbatim} |
735 axiomatization where |
739 axiomatization where |
736 rule1: ``1 = $\delta$[n]'' and |
740 rule1: ``1 = $\delta$[n]'' and |
737 rule2: ``|| z || > 1 ==> z / (z - 1) = u [n]'' and |
741 rule2: ``|| z || > 1 ==> z / (z - 1) = u [n]'' and |
738 rule3: ``|| z || < 1 ==> z / (z - 1) = -u [-n - 1]'' |
742 rule3: ``|| z || < 1 ==> z / (z - 1) = -u [-n - 1]''\end{verbatim} |
739 \end{verbatim} |
|
740 %\end{example} |
743 %\end{example} |
|
744 } |
|
745 |
|
746 Rules can be summarized in a ruleset (collection of rules) and afterwards tried to be applied to a given expression as puttet over in following code. |
741 |
747 |
742 %\begin{example} |
748 %\begin{example} |
743 \hfill\\ |
749 % \hfill\\ |
744 \label{eg:ruleapp} |
750 \label{eg:ruleapp} |
745 \begin{enumerate} |
751 \begin{enumerate} |
|
752 |
746 \item Store rules in ruleset: |
753 \item Store rules in ruleset: |
747 \begin{verbatim} |
754 {\footnotesize\begin{verbatim} |
748 val inverse_Z = append_rls "inverse_Z" e_rls |
755 val inverse_Z = append_rls "inverse_Z" e_rls |
749 [ Thm ("rule1",num_str @{thm rule1}), |
756 [ Thm ("rule1",num_str @{thm rule1}), |
750 Thm ("rule2",num_str @{thm rule2}), |
757 Thm ("rule2",num_str @{thm rule2}), |
751 Thm ("rule3",num_str @{thm rule3}) |
758 Thm ("rule3",num_str @{thm rule3}) |
752 ]; |
759 ];\end{verbatim}} |
753 \end{verbatim} |
760 |
754 \item Define exression: |
761 \item Define exression: |
755 \begin{verbatim} |
762 {\footnotesize\begin{verbatim} |
756 val sample_term = str2term "z/(z-1)+z/(z-</delta>)+1"; |
763 val sample_term = str2term "z/(z-1)+z/(z-</delta>)+1";\end{verbatim}} |
757 \end{verbatim} |
764 |
758 \item Apply ruleset: |
765 \item Apply ruleset: |
759 \begin{verbatim} |
766 {\footnotesize\begin{verbatim} |
760 val SOME (sample_term', asm) = |
767 val SOME (sample_term', asm) = |
761 rewrite_set_ thy true inverse_Z sample_term; |
768 rewrite_set_ thy true inverse_Z sample_term;\end{verbatim}} |
762 \end{verbatim} |
769 |
763 \end{enumerate} |
770 \end{enumerate} |
764 %\end{example} |
771 %\end{example} |
765 |
772 |
766 The use of rulesets makes it much easier to develop our designated applications, |
773 The use of rulesets makes it much easier to develop our designated applications, |
767 but the programmer has to be careful and patient. When applying rulesets |
774 but the programmer has to be careful and patient. When applying rulesets |
768 two important issues have to be mentionend: |
775 two important issues have to be mentionend: |
769 \subparagraph{How often} the rules have to be applied? In case of |
776 \begin{enumerate} |
|
777 \item How often the rules have to be applied? In case of |
770 transformations it is quite clear that we use them once but other fields |
778 transformations it is quite clear that we use them once but other fields |
771 reuqire to apply rules until a special condition is reached (e.g. |
779 reuqire to apply rules until a special condition is reached (e.g. |
772 a simplification is finished when there is nothing to be done left). |
780 a simplification is finished when there is nothing to be done left). |
773 \subparagraph{The order} in which rules are applied often takes a big effect |
781 \item The order in which rules are applied often takes a big effect |
774 and has to be evaluated for each purpose once again. |
782 and has to be evaluated for each purpose once again. |
775 \par |
783 \end{enumerate} |
776 In our special case of Signal Processing and the rules defined in |
784 In the special case of Signal Processing the rules defined in the |
777 Example~\ref{eg:ruledef} we have to apply rule~1 first of all to transform all |
785 Example upwards have to be applied in a dedicated order to transform all |
778 constants. After this step has been done it no mather which rule fit's next. |
786 constants first of all. After this first transformation step has been done it no |
|
787 mather which rule fit's next. |
779 |
788 |
780 \subsection{Preparation of ML-Functions}\label{funs} |
789 \subsection{Preparation of ML-Functions}\label{funs} |
781 The prototype's Lucas-Interpreter uses the {\sisac}-rewrite-engine for |
790 The prototype's Lucas-Interpreter uses the {\sisac}-rewrite-engine for |
782 all kinds of evaluation. Some functionality required in programming, |
791 all kinds of evaluation. Some functionality required in programming, |
783 however, cannot be accomplished by rewriting. So the prototype has a |
792 however, cannot be accomplished by rewriting. So the prototype has a |
1129 range of powerful possibilities. |
1138 range of powerful possibilities. |
1130 |
1139 |
1131 \begin{description} |
1140 \begin{description} |
1132 \item[01..02] stores the method with the given name into the system under a global |
1141 \item[01..02] stores the method with the given name into the system under a global |
1133 reference. |
1142 reference. |
1134 \item[03] specifies the topic under which the method can be used. |
1143 \item[03] specifies the topic within which context the method can be found. |
1135 \item[04..05] as the requirements for different methods can deviant we |
1144 \item[04..05] as the requirements for different methods can be deviant we |
1136 declare what is \emph{given} and and what to \emph{find} for this specific method. |
1145 declare what is \emph{given} and and what to \emph{find} for this specific method. |
1137 \item[06] \emph{rewrite order} is the order of this rls, which one theorem of is |
1146 The code again helds on the topic of the case studie, where the inverse |
1138 used for rewriting one single step. |
1147 z-transformation does a switch between a term describing a electrical filter into |
1139 \item[07] \texttt{rls} is the currently used ruleset for this method, |
1148 its step response. Also the datatype has to be declared (bool - due the fact that |
1140 \texttt{e\_rls} specifies a |
1149 we handle equations). |
1141 ruleset where conditions can be used within it. |
1150 \item[06] \emph{rewrite order} is the order of this rls (ruleset), where one |
1142 \item[08] we can add this method to a predefined tree of calculations ore leave |
1151 theorem of it is used for rewriting one single step. |
1143 it independend. |
1152 \item[07] \texttt{rls} is the currently used ruleset for this method. This set |
1144 \item[09] \texttt{srls}, can be used to evaluate list expressions in the source |
1153 has already been defined before. |
1145 \item[10] \texttt{prls} indicates predicates which can be used in model patterns. |
1154 \item[08] we would have the possiblitiy to add this method to a predefined tree of |
1146 \item[11] \texttt{crls}, gives us the possibility for checking formulas |
1155 calculations, i.eg. if it would be a sub of a bigger problem, here we leave it |
1147 lementwise |
1156 independend. |
|
1157 \item[09] The \emph{source ruleset}, can be used to evaluate list expressions in |
|
1158 the source. |
|
1159 \item[10] \emph{predicates ruleset} can be used to indicates predicates within |
|
1160 model patterns. |
|
1161 \item[11] The \emph{check ruleset} summarizes rules for checking formulas |
|
1162 elementwise. |
1148 \item[12] \emph{error patterns} which are expected in this kind of method can be |
1163 \item[12] \emph{error patterns} which are expected in this kind of method can be |
1149 specified. |
1164 pre-specified to recognize them during the method. |
1150 \item[13] \texttt{crls}, declares the canonical simplifier for the specific method |
1165 \item[13] finally the \emph{canonical ruleset}, declares the canonical simplifier |
1151 \item[14] for this time we don't specify the programm itself and keep it empty. |
1166 of the specific method. |
1152 Follow up \S\ref{progr} for informations on how to implement this \textit{main} |
1167 \item[14] for this code snipset we don't specify the programm itself and keep it |
1153 part. |
1168 empty. Follow up \S\ref{progr} for informations on how to implement this |
|
1169 \textit{main} part. |
1154 \end{description} |
1170 \end{description} |
1155 |
1171 |
1156 \subsection{Implementation of the TP-based Program}\label{progr} |
1172 \subsection{Implementation of the TP-based Program}\label{progr} |
1157 So finally all the prerequisites are described and the very topic can |
1173 So finally all the prerequisites are described and the very topic can |
1158 be addressed. The program below comes back to the running example: it |
1174 be addressed. The program below comes back to the running example: it |
1159 computes a solution for the problem from Fig.\ref{fig-interactive} on |
1175 computes a solution for the problem from Fig.\ref{fig-interactive} on |
1160 p.\pageref{fig-interactive}. The reader is reminded of |
1176 p.\pageref{fig-interactive}. The reader is reminded of |
1161 \S\ref{PL-isab}, the introduction of the programming language: |
1177 \S\ref{PL-isab}, the introduction of the programming language: |
1162 {\small\it\label{s:impl} |
1178 |
|
1179 {\footnotesize\it\label{s:impl} |
1163 \begin{tabbing} |
1180 \begin{tabbing} |
1164 123l\=123\=123\=123\=123\=123\=123\=((x\=123\=(x \=123\=123\=\kill |
1181 123l\=123\=123\=123\=123\=123\=123\=((x\=123\=(x \=123\=123\=\kill |
1165 \>{\rm 00}\>val program =\\ |
1182 \>{\rm 00}\>val program =\\ |
1166 \>{\rm 01}\> "{\tt Program} InverseZTransform (X\_eq::bool) = \\ |
1183 \>{\rm 01}\> "{\tt Program} InverseZTransform (X\_eq::bool) = \\ |
1167 \>{\rm 02}\>\> {\tt let} \\ |
1184 \>{\rm 02}\>\> {\tt let} \\ |