702 \end{center} |
702 \end{center} |
703 \end{figure} |
703 \end{figure} |
704 The language for both axes is defined in the axis at the bottom, deductive |
704 The language for both axes is defined in the axis at the bottom, deductive |
705 knowledge, in {\sisac} represented by Isabelle's theories. |
705 knowledge, in {\sisac} represented by Isabelle's theories. |
706 |
706 |
707 \subsection{Specification of the Problem}\label{spec} |
|
708 %WN <--> \chapter 7 der Thesis |
|
709 %WN die Argumentation unten sollte sich NUR auf Verifikation beziehen.. |
|
710 |
|
711 The problem of the running example is textually described in |
|
712 Fig.\ref{fig-interactive} on p.\pageref{fig-interactive}. The {\em |
|
713 formal} specification of this problem, in traditional mathematical |
|
714 notation, could look like is this: |
|
715 |
|
716 %WN Hier brauchen wir die Spezifikation des 'running example' ... |
|
717 %JR Habe input, output und precond vom Beispiel eingefügt brauche aber Hilfe bei |
|
718 %JR der post condition - die existiert für uns ja eigentlich nicht aka |
|
719 %JR haben sie bis jetzt nicht beachtet WN... |
|
720 %WN2 Mein Vorschlag ist, das TODO zu lassen und deutlich zu kommentieren. |
|
721 %JR2 done |
|
722 |
|
723 \label{eg:neuper2} |
|
724 {\small\begin{tabbing} |
|
725 123,\=postcond \=: \= $\forall \,A^\prime\, u^\prime \,v^\prime.\,$\=\kill |
|
726 \hfill \\ |
|
727 Specification:\\ |
|
728 \>input \>: filterExpression $X=\frac{3}{(z-\frac{1}{4}+-\frac{1}{8}*\frac{1}{z}}$\\ |
|
729 \>precond \>: filterExpression continius on $\mathbb{R}$ \\ |
|
730 \>output \>: stepResponse $x[n]$ \\ |
|
731 \>postcond \>: TODO - (Mind the following remark)\\ \end{tabbing}} |
|
732 |
|
733 \begin{remark} |
|
734 Defining the postcondition requires a high amount mathematical |
|
735 knowledge, the difficult part in our case is not to set up this condition |
|
736 nor it is more to define it in a way the interpreter is able to handle it. |
|
737 Due the fact that implementing that mechanisms is quite the same amount as |
|
738 creating the programm itself, it is not avaible in our prototype. |
|
739 \label{rm:postcond} |
|
740 \end{remark} |
|
741 |
|
742 \paragraph{The implementation} of the formal specification in the present |
|
743 prototype, still bar-bones without support for authoring: |
|
744 %WN Kopie von Inverse_Z_Transform.thy, leicht versch"onert: |
|
745 {\footnotesize\label{exp-spec} |
|
746 \begin{verbatim} |
|
747 01 store_specification |
|
748 02 (prepare_specification |
|
749 03 ["Jan Rocnik"] |
|
750 04 "pbl_SP_Ztrans_inv" |
|
751 05 thy |
|
752 06 ( ["Inverse", "Z_Transform", "SignalProcessing"], |
|
753 07 [ ("#Given", ["filterExpression X_eq"]), |
|
754 08 ("#Pre" , ["X_eq is_continuous"]), |
|
755 19 ("#Find" , ["stepResponse n_eq"]), |
|
756 10 ("#Post" , [" TODO "])], |
|
757 11 append_rls Erls [Calc ("Atools.is_continuous", eval_is_continuous)], |
|
758 12 NONE, |
|
759 13 [["SignalProcessing","Z_Transform","Inverse"]])); |
|
760 \end{verbatim}} |
|
761 Although the above details are partly very technical, we explain them |
|
762 in order to document some intricacies of TP-based programming in the |
|
763 present state of the {\sisac} prototype: |
|
764 \begin{description} |
|
765 \item[01..02]\textit{store\_specification:} stores the result of the |
|
766 function \textit{prep\_specification} in a global reference |
|
767 \textit{Unsynchronized.ref}, which causes principal conflicts with |
|
768 Isabelle's asyncronous document model~\cite{Wenzel-11:doc-orient} and |
|
769 parallel execution~\cite{Makarius-09:parall-proof} and is under |
|
770 reconstruction already. |
|
771 |
|
772 \textit{prep\_pbt:} translates the specification to an internal format |
|
773 which allows efficient processing; see for instance line {\rm 07} |
|
774 below. |
|
775 \item[03..04] are the ``mathematics author'' holding the copy-rights |
|
776 and a unique identifier for the specification within {\sisac}, |
|
777 complare line {\rm 06}. |
|
778 \item[05] is the Isabelle \textit{theory} required to parse the |
|
779 specification in lines {\rm 07..10}. |
|
780 \item[06] is a key into the tree of all specifications as presented to |
|
781 the user (where some branches might be hidden by the dialog |
|
782 component). |
|
783 \item[07..10] are the specification with input, pre-condition, output |
|
784 and post-condition respectively; the post-condition is not handled in |
|
785 the prototype presently. (Follow up Remark~\ref{rm:postcond}) |
|
786 \item[11] creates a term rewriting system (abbreviated \textit{rls} in |
|
787 {\sisac}) which evaluates the pre-condition for the actual input data. |
|
788 Only if the evaluation yields \textit{True}, a program con be started. |
|
789 \item[12]\textit{NONE:} could be \textit{SOME ``solve ...''} for a |
|
790 problem associated to a function from Computer Algebra (like an |
|
791 equation solver) which is not the case here. |
|
792 \item[13] is the specific key into the tree of programs addressing a |
|
793 method which is able to find a solution which satiesfies the |
|
794 post-condition of the specification. |
|
795 \end{description} |
|
796 |
|
797 |
|
798 %WN die folgenden Erkl"arungen finden sich durch "grep -r 'datatype pbt' *" |
|
799 %WN ... |
|
800 % type pbt = |
|
801 % {guh : guh, (*unique within this isac-knowledge*) |
|
802 % mathauthors: string list, (*copyright*) |
|
803 % init : pblID, (*to start refinement with*) |
|
804 % thy : theory, (* which allows to compile that pbt |
|
805 % TODO: search generalized for subthy (ref.p.69*) |
|
806 % (*^^^ WN050912 NOT used during application of the problem, |
|
807 % because applied terms may be from 'subthy' as well as from super; |
|
808 % thus we take 'maxthy'; see match_ags !*) |
|
809 % cas : term option,(*'CAS-command'*) |
|
810 % prls : rls, (* for preds in where_*) |
|
811 % where_: term list, (* where - predicates*) |
|
812 % ppc : pat list, |
|
813 % (*this is the model-pattern; |
|
814 % it contains "#Given","#Where","#Find","#Relate"-patterns |
|
815 % for constraints on identifiers see "fun cpy_nam"*) |
|
816 % met : metID list}; (* methods solving the pbt*) |
|
817 % |
|
818 %WN weil dieser Code sehr unaufger"aumt ist, habe ich die Erkl"arungen |
|
819 %WN oben selbst geschrieben. |
|
820 |
|
821 |
|
822 |
|
823 |
|
824 %WN das w"urde ich in \sec\label{progr} verschieben und |
|
825 %WN das SubProblem partial fractions zum Erkl"aren verwenden. |
|
826 % Such a specification is checked before the execution of a program is |
|
827 % started, the same applies for sub-programs. In the following example |
|
828 % (Example~\ref{eg:subprob}) shows the call of such a subproblem: |
|
829 % |
|
830 % \vbox{ |
|
831 % \begin{example} |
|
832 % \label{eg:subprob} |
|
833 % \hfill \\ |
|
834 % {\ttfamily \begin{tabbing} |
|
835 % ``(L\_L::bool list) = (\=SubProblem (\=Test','' \\ |
|
836 % ``\>\>[linear,univariate,equation,test],'' \\ |
|
837 % ``\>\>[Test,solve\_linear])'' \\ |
|
838 % ``\>[BOOL equ, REAL z])'' \\ |
|
839 % \end{tabbing} |
|
840 % } |
|
841 % {\small\textit{ |
|
842 % \noindent If a program requires a result which has to be |
|
843 % calculated first we can use a subproblem to do so. In our specific |
|
844 % case we wanted to calculate the zeros of a fraction and used a |
|
845 % subproblem to calculate the zeros of the denominator polynom. |
|
846 % }} |
|
847 % \end{example} |
|
848 % } |
|
849 |
|
850 \subsection{Implementation of the Method}\label{meth} |
|
851 |
|
852 \paragraph{todo} |
|
853 |
|
854 \begin{example} |
|
855 \begin{verbatim} |
|
856 |
|
857 01 store_met |
|
858 02 (prep_met thy "met_SP_Ztrans_inv" [] e_metID |
|
859 03 (["SignalProcessing", "Z_Transform", "Inverse"], |
|
860 04 [("#Given" ,["filterExpression (X_eq::bool)"]), |
|
861 05 ("#Find" ,["stepResponse (n_eq::bool)"])], |
|
862 06 {rew_ord'="tless_true", |
|
863 07 rls'= e_rls, |
|
864 08 calc = [], |
|
865 09 srls = e_rls, |
|
866 10 prls = e_rls, |
|
867 11 crls = e_rls, |
|
868 12 errpats = [], |
|
869 13 nrls = e_rls}, |
|
870 14 "empty_script" |
|
871 15 )); |
|
872 \end{verbatim} |
|
873 \end{example} |
|
874 |
|
875 |
|
876 \subsection{Preparation of Simplifiers for the Program}\label{simp} |
707 \subsection{Preparation of Simplifiers for the Program}\label{simp} |
877 |
708 |
878 \paragraph{If it is clear} how the later calculation should look like and when |
709 \paragraph{If it is clear} how the later calculation should look like and when |
879 which mathematic rule should be applied, it can be started to find ways of |
710 which mathematic rule should be applied, it can be started to find ways of |
880 simplifications. This includes in e.g. the simplification of reational |
711 simplifications. This includes in e.g. the simplification of reational |
1036 \item[04] checks if the resulting variable is the correct one (in this case |
867 \item[04] checks if the resulting variable is the correct one (in this case |
1037 ``b'' the denominator) and returns. |
868 ``b'' the denominator) and returns. |
1038 \item[05] handels the error case and reports that the function is not able to |
869 \item[05] handels the error case and reports that the function is not able to |
1039 solve the given problem. |
870 solve the given problem. |
1040 \end{description} |
871 \end{description} |
|
872 |
|
873 \subsection{Specification of the Problem}\label{spec} |
|
874 %WN <--> \chapter 7 der Thesis |
|
875 %WN die Argumentation unten sollte sich NUR auf Verifikation beziehen.. |
|
876 |
|
877 The problem of the running example is textually described in |
|
878 Fig.\ref{fig-interactive} on p.\pageref{fig-interactive}. The {\em |
|
879 formal} specification of this problem, in traditional mathematical |
|
880 notation, could look like is this: |
|
881 |
|
882 %WN Hier brauchen wir die Spezifikation des 'running example' ... |
|
883 %JR Habe input, output und precond vom Beispiel eingefügt brauche aber Hilfe bei |
|
884 %JR der post condition - die existiert für uns ja eigentlich nicht aka |
|
885 %JR haben sie bis jetzt nicht beachtet WN... |
|
886 %WN2 Mein Vorschlag ist, das TODO zu lassen und deutlich zu kommentieren. |
|
887 %JR2 done |
|
888 |
|
889 \label{eg:neuper2} |
|
890 {\small\begin{tabbing} |
|
891 123,\=postcond \=: \= $\forall \,A^\prime\, u^\prime \,v^\prime.\,$\=\kill |
|
892 \hfill \\ |
|
893 Specification:\\ |
|
894 \>input \>: filterExpression $X=\frac{3}{(z-\frac{1}{4}+-\frac{1}{8}*\frac{1}{z}}$\\ |
|
895 \>precond \>: filterExpression continius on $\mathbb{R}$ \\ |
|
896 \>output \>: stepResponse $x[n]$ \\ |
|
897 \>postcond \>: TODO - (Mind the following remark)\\ \end{tabbing}} |
|
898 |
|
899 \begin{remark} |
|
900 Defining the postcondition requires a high amount mathematical |
|
901 knowledge, the difficult part in our case is not to set up this condition |
|
902 nor it is more to define it in a way the interpreter is able to handle it. |
|
903 Due the fact that implementing that mechanisms is quite the same amount as |
|
904 creating the programm itself, it is not avaible in our prototype. |
|
905 \label{rm:postcond} |
|
906 \end{remark} |
|
907 |
|
908 \paragraph{The implementation} of the formal specification in the present |
|
909 prototype, still bar-bones without support for authoring: |
|
910 %WN Kopie von Inverse_Z_Transform.thy, leicht versch"onert: |
|
911 {\footnotesize\label{exp-spec} |
|
912 \begin{verbatim} |
|
913 01 store_specification |
|
914 02 (prepare_specification |
|
915 03 ["Jan Rocnik"] |
|
916 04 "pbl_SP_Ztrans_inv" |
|
917 05 thy |
|
918 06 ( ["Inverse", "Z_Transform", "SignalProcessing"], |
|
919 07 [ ("#Given", ["filterExpression X_eq"]), |
|
920 08 ("#Pre" , ["X_eq is_continuous"]), |
|
921 19 ("#Find" , ["stepResponse n_eq"]), |
|
922 10 ("#Post" , [" TODO "])], |
|
923 11 append_rls Erls [Calc ("Atools.is_continuous", eval_is_continuous)], |
|
924 12 NONE, |
|
925 13 [["SignalProcessing","Z_Transform","Inverse"]])); |
|
926 \end{verbatim}} |
|
927 Although the above details are partly very technical, we explain them |
|
928 in order to document some intricacies of TP-based programming in the |
|
929 present state of the {\sisac} prototype: |
|
930 \begin{description} |
|
931 \item[01..02]\textit{store\_specification:} stores the result of the |
|
932 function \textit{prep\_specification} in a global reference |
|
933 \textit{Unsynchronized.ref}, which causes principal conflicts with |
|
934 Isabelle's asyncronous document model~\cite{Wenzel-11:doc-orient} and |
|
935 parallel execution~\cite{Makarius-09:parall-proof} and is under |
|
936 reconstruction already. |
|
937 |
|
938 \textit{prep\_pbt:} translates the specification to an internal format |
|
939 which allows efficient processing; see for instance line {\rm 07} |
|
940 below. |
|
941 \item[03..04] are the ``mathematics author'' holding the copy-rights |
|
942 and a unique identifier for the specification within {\sisac}, |
|
943 complare line {\rm 06}. |
|
944 \item[05] is the Isabelle \textit{theory} required to parse the |
|
945 specification in lines {\rm 07..10}. |
|
946 \item[06] is a key into the tree of all specifications as presented to |
|
947 the user (where some branches might be hidden by the dialog |
|
948 component). |
|
949 \item[07..10] are the specification with input, pre-condition, output |
|
950 and post-condition respectively; the post-condition is not handled in |
|
951 the prototype presently. (Follow up Remark~\ref{rm:postcond}) |
|
952 \item[11] creates a term rewriting system (abbreviated \textit{rls} in |
|
953 {\sisac}) which evaluates the pre-condition for the actual input data. |
|
954 Only if the evaluation yields \textit{True}, a program con be started. |
|
955 \item[12]\textit{NONE:} could be \textit{SOME ``solve ...''} for a |
|
956 problem associated to a function from Computer Algebra (like an |
|
957 equation solver) which is not the case here. |
|
958 \item[13] is the specific key into the tree of programs addressing a |
|
959 method which is able to find a solution which satiesfies the |
|
960 post-condition of the specification. |
|
961 \end{description} |
|
962 |
|
963 |
|
964 %WN die folgenden Erkl"arungen finden sich durch "grep -r 'datatype pbt' *" |
|
965 %WN ... |
|
966 % type pbt = |
|
967 % {guh : guh, (*unique within this isac-knowledge*) |
|
968 % mathauthors: string list, (*copyright*) |
|
969 % init : pblID, (*to start refinement with*) |
|
970 % thy : theory, (* which allows to compile that pbt |
|
971 % TODO: search generalized for subthy (ref.p.69*) |
|
972 % (*^^^ WN050912 NOT used during application of the problem, |
|
973 % because applied terms may be from 'subthy' as well as from super; |
|
974 % thus we take 'maxthy'; see match_ags !*) |
|
975 % cas : term option,(*'CAS-command'*) |
|
976 % prls : rls, (* for preds in where_*) |
|
977 % where_: term list, (* where - predicates*) |
|
978 % ppc : pat list, |
|
979 % (*this is the model-pattern; |
|
980 % it contains "#Given","#Where","#Find","#Relate"-patterns |
|
981 % for constraints on identifiers see "fun cpy_nam"*) |
|
982 % met : metID list}; (* methods solving the pbt*) |
|
983 % |
|
984 %WN weil dieser Code sehr unaufger"aumt ist, habe ich die Erkl"arungen |
|
985 %WN oben selbst geschrieben. |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 %WN das w"urde ich in \sec\label{progr} verschieben und |
|
991 %WN das SubProblem partial fractions zum Erkl"aren verwenden. |
|
992 % Such a specification is checked before the execution of a program is |
|
993 % started, the same applies for sub-programs. In the following example |
|
994 % (Example~\ref{eg:subprob}) shows the call of such a subproblem: |
|
995 % |
|
996 % \vbox{ |
|
997 % \begin{example} |
|
998 % \label{eg:subprob} |
|
999 % \hfill \\ |
|
1000 % {\ttfamily \begin{tabbing} |
|
1001 % ``(L\_L::bool list) = (\=SubProblem (\=Test','' \\ |
|
1002 % ``\>\>[linear,univariate,equation,test],'' \\ |
|
1003 % ``\>\>[Test,solve\_linear])'' \\ |
|
1004 % ``\>[BOOL equ, REAL z])'' \\ |
|
1005 % \end{tabbing} |
|
1006 % } |
|
1007 % {\small\textit{ |
|
1008 % \noindent If a program requires a result which has to be |
|
1009 % calculated first we can use a subproblem to do so. In our specific |
|
1010 % case we wanted to calculate the zeros of a fraction and used a |
|
1011 % subproblem to calculate the zeros of the denominator polynom. |
|
1012 % }} |
|
1013 % \end{example} |
|
1014 % } |
|
1015 |
|
1016 \subsection{Implementation of the Method}\label{meth} |
|
1017 |
|
1018 \paragraph{todo} |
|
1019 |
|
1020 \begin{example} |
|
1021 \begin{verbatim} |
|
1022 |
|
1023 01 store_met |
|
1024 02 (prep_met thy "met_SP_Ztrans_inv" [] e_metID |
|
1025 03 (["SignalProcessing", "Z_Transform", "Inverse"], |
|
1026 04 [("#Given" ,["filterExpression (X_eq::bool)"]), |
|
1027 05 ("#Find" ,["stepResponse (n_eq::bool)"])], |
|
1028 06 {rew_ord'="tless_true", |
|
1029 07 rls'= e_rls, |
|
1030 08 calc = [], |
|
1031 09 srls = e_rls, |
|
1032 10 prls = e_rls, |
|
1033 11 crls = e_rls, |
|
1034 12 errpats = [], |
|
1035 13 nrls = e_rls}, |
|
1036 14 "empty_script" |
|
1037 15 )); |
|
1038 \end{verbatim} |
|
1039 \end{example} |
1041 |
1040 |
1042 \subsection{Implementation of the TP-based Program}\label{progr} |
1041 \subsection{Implementation of the TP-based Program}\label{progr} |
1043 So finally all the prerequisites are described and the very topic can |
1042 So finally all the prerequisites are described and the very topic can |
1044 be addressed. The program below comes back to the running example: it |
1043 be addressed. The program below comes back to the running example: it |
1045 computes a solution for the problem from Fig.\ref{fig-interactive} on |
1044 computes a solution for the problem from Fig.\ref{fig-interactive} on |