492 val it = fn : subst -> Term.term * Term.term -> bool |
492 val it = fn : subst -> Term.term * Term.term -> bool |
493 \end{verbatim} |
493 \end{verbatim} |
494 |
494 |
495 Das bool Argument gibt Ihnen die M\"oglichkeit die Kontrolle zu den zugeh\"origen Unterordunungen zur\"uck zu verfolgen, damit sich die Unterordnungen, die 'true' sind als strings anzeigen lassen. |
495 Das bool Argument gibt Ihnen die M\"oglichkeit die Kontrolle zu den zugeh\"origen Unterordunungen zur\"uck zu verfolgen, damit sich die Unterordnungen, die 'true' sind als strings anzeigen lassen. |
496 |
496 |
|
497 {\section{Geordnetes Rewriting}} |
|
498 Beim Rewriting entstehen Probleme in den meisten elementaren Bereichen. Es gibt ein ''law of commutativity`` das genau solche Probleme mit '+' und '*' verursacht. Diese Probleme können nur durch geordnetes Rewriting gel\"ost werden, da hier ein Term nur umgeschrieben wird, wenn ein kleinerer dadurch entsteht. |
|
499 \paragraph{Versuchen Sie es!} Das geordnete Rewriting ist eine Technik, um ein normales Polynom aus ganzzahligen Termen zu schaffen. |
|
500 Geordnetes Rewriting endet mit Klammern, aber auf Grund der weggelassenen Verbindung. |
|
501 |
|
502 |
|
503 \chapter{Die Hirarchie von Problemen} |
|
504 \section{''Matching``} |
|
505 Matching ist eine Technik von Rewriting, die von \isac verwendet wird, um ein Problem und den passenden Problemtyp daf\"ur zu finden. Die folgende Funktion, die \"uberpr\"uft, ob matching möglich ist, hat diese Signatur: |
|
506 {\footnotesize\begin{verbatim} |
|
507 > matches; |
|
508 val it = fn : Theory.theory -> Term.term -> Term.term -> bool |
|
509 \end{verbatim} |
|
510 Die folgende Gleichung wird in Operatoren und freie Variablen zerlegt. |
|
511 {\footnotesize\begin{verbatim} |
|
512 > val t = (term_of o the o (parse thy)) "3 * x^^^2 = 1"; |
|
513 val t = |
|
514 Const ("op =", "[RealDef.real, RealDef.real] => bool") $ |
|
515 (Const ("op *", "[RealDef.real, RealDef.real] => RealDef.real") $ |
|
516 Free ("3", "RealDef.real") $ |
|
517 (Const |
|
518 ("Atools.pow", |
|
519 "[RealDef.real, RealDef.real] => RealDef.real") $ |
|
520 Free ("x", "RealDef.real") $ Free ("2", " RealDef.real"))) $ |
|
521 Free ("1", "RealDef.real") : Term.term |
|
522 \end{verbatim} |
|
523 Nun wird ein Modell erstellt, das sich nicht auf bestimmte Zahlen bezieht, sondern nur eine generelle Zerlegung durchführt. |
|
524 {\footnotesize\begin{verbatim} |
|
525 > val p = (term_of o the o (parse thy)) "a * b^^^2 = c"; |
|
526 val p = |
|
527 Const ("op =", "[RealDef.real, RealDef.real] => bool") $ |
|
528 (Const ("op *", "[RealDef.real, RealDef.real] => RealDef.real") $ |
|
529 Free ("a", "RealDef.real") $ |
|
530 (Const |
|
531 ("Atools.pow", |
|
532 "[RealDef.real, RealDef.real] => RealDef.real") $ |
|
533 Free ("b", "RealDef.real") $ Free ("2", "RealDef.real"))) $ |
|
534 Free ("c", "RealDef.real") : Term.term |
|
535 \end{verbatim} |
|
536 Dieses Modell enth\"allt sogenannte \textit{scheme variables}. |
|
537 {\footnotesize\begin{verbatim} |
|
538 > atomt p; |
|
539 "*** -------------" |
|
540 "*** Const (op =)" |
|
541 "*** . Const (op *)""*** . . Free (a, )" |
|
542 "*** . . Const (Atools.pow)" |
|
543 "*** . . . Free (b, )" |
|
544 "*** . . . Free (2, )" |
|
545 "*** . Free (c, )" |
|
546 "\n" |
|
547 val it = "\n" : string |
|
548 \end{verbatim} |
|
549 Das Modell wird durch den Befehl free2var erstellt. |
|
550 {\footnotesize\begin{verbatim} |
|
551 > free2var; |
|
552 val it = fn : Term.term -> Term.term |
|
553 > val pat = free2var p; |
|
554 val pat = |
|
555 Const ("op =", "[RealDef.real, RealDef.real] => bool") $ |
|
556 (Const ("op *", "[RealDef.real, RealDef.real] => RealDef.real") $ |
|
557 Var (("a", 0), "RealDef.real") $ |
|
558 (Const |
|
559 ("Atools.pow", |
|
560 "[RealDef.real, RealDef.real] => RealDef.real") $ |
|
561 Var (("b", 0), "RealDef.real") $ |
|
562 Free ("2", "RealDef.real"))) $ Var (("c", 0), "RealDef.real") |
|
563 : Term.term |
|
564 > Sign.string_of_term (sign_of thy) pat; |
|
565 val it = "?a * ?b ^^^ 2 = ?c" : string |
|
566 \end{verbatim} |
|
567 Durch atomt pat wird der Term aufgespalten und so in eine Form gebracht, die f\"ur die weiteren Schritte ben\"otigt werden. |
|
568 {\footnotesize\begin{verbatim} |
|
569 > atomt pat; |
|
570 "*** -------------" |
|
571 "*** Const (op =)" |
|
572 "*** . Const (op *)" |
|
573 "*** . . Var ((a, 0), )" |
|
574 "*** . . Const (Atools.pow)" |
|
575 "*** . . . Var ((b, 0), )" |
|
576 "*** . . . Free (2, )" |
|
577 "*** . Var ((c, 0), )" |
|
578 "\n" |
|
579 val it = "\n" : string |
|
580 \end{verbatim} |
|
581 Jetzt kann das Matching f\"ur die beiden vorigen Terme angewendet werden. |
|
582 {\footnotesize\begin{verbatim} |
|
583 > matches thy t pat; |
|
584 val it = true : bool |
|
585 > val t2 = (term_of o the o (parse thy)) "x^^^2 = 1"; |
|
586 val t2 = |
|
587 Const ("op =", "[RealDef.real, RealDef.real] => bool") $ |
|
588 (Const |
|
589 ("Atools.pow", |
|
590 "[RealDef.real, RealDef.real] => RealDef.real") $ |
|
591 Free ("x", "RealDef.real") $ Free ("2", "RealDef.real")) $ |
|
592 Free ("1", "RealDef.real") : Term.term |
|
593 > matches thy t2 pat; |
|
594 val it = false : bool |
|
595 > val pat2 = (term_of o the o (parse thy)) "?u^^^2 = ?v"; |
|
596 val pat2 = |
|
597 Const ("op =", "[RealDef.real, RealDef.real] => bool") $ |
|
598 (Const |
|
599 ("Atools.pow", |
|
600 "[RealDef.real, RealDef.real] => RealDef.real") $ |
|
601 Var (("u", 0), "RealDef.real") $ Free ("2", "RealDef.real")) $ |
|
602 Var (("v", 0), "RealDef.real") : Term.term |
|
603 > matches thy t2 pat2; |
|
604 val it = true : bool |
|
605 \end{verbatim} |
|
606 |
|
607 \section{Zugriff auf die Hierarchie} |
|
608 Man verwendet folgenden Befehl, um sich Zugang zur Hierarchie von Problemtypen zu verschaffen. |
|
609 {\footnotesize\begin{verbatim} |
|
610 > show_ptyps; |
|
611 val it = fn : unit -> unit |
|
612 > show_ptyps(); |
|
613 [ |
|
614 ["e_pblID"], |
|
615 ["simplification", "polynomial"], |
|
616 ["simplification", "rational"], |
|
617 ["vereinfachen", "polynom", "plus_minus"], |
|
618 ["vereinfachen", "polynom", "klammer"], |
|
619 ["vereinfachen", "polynom", "binom_klammer"], |
|
620 ["probe", "polynom"], |
|
621 ["probe", "bruch"], |
|
622 ["equation", "univariate", "linear"], |
|
623 ["equation", "univariate", "root", "sq", "rat"], |
|
624 ["equation", "univariate", "root", "normalize"], |
|
625 ["equation", "univariate", "rational"], |
|
626 ["equation", "univariate", "polynomial", "degree_0"], |
|
627 ["equation", "univariate", "polynomial", "degree_1"], |
|
628 ["equation", "univariate", "polynomial", "degree_2", "sq_only"], |
|
629 ["equation", "univariate", "polynomial", " |
|
630 degree_2", "bdv_only"], |
|
631 ["equation", "univariate", "polynomial", "degree_2", "pqFormula"], |
|
632 ["equation", "univariate", "polynomial", "degree_2", "abcFormula"], |
|
633 ["equation", "univariate", "polynomial", "degree_3"], |
|
634 ["equation", "univariate", "polynomial", "degree_4"], |
|
635 ["equation", "univariate", "polynomial", "normalize"], |
|
636 ["equation", "univariate", "expanded", "degree_2"], |
|
637 ["equation", "makeFunctionTo"], |
|
638 ["function", "derivative_of", "named"], |
|
639 ["function", "maximum_of", "on_interval"], |
|
640 ["function", "make", "by_explicit"], |
|
641 ["function", "make", "by_new_variable"], |
|
642 ["function", "integrate", "named"], |
|
643 ["tool", "find_values"], |
|
644 ["system", "linear", "2x2", "triangular"], |
|
645 ["system", "linear", "2x2", "normalize"], |
|
646 ["system", "linear", "3x3"], |
|
647 ["system", "linear", "4x4", "triangular"], |
|
648 ["system", "linear", "4x4", "normalize"], |
|
649 ["Biegelinien", " |
|
650 MomentBestimmte"], |
|
651 ["Biegelinien", "MomentGegebene"], |
|
652 ["Biegelinien", "einfache"], |
|
653 ["Biegelinien", "QuerkraftUndMomentBestimmte"], |
|
654 ["Biegelinien", "vonBelastungZu"], |
|
655 ["Biegelinien", "setzeRandbedingungen"], |
|
656 ["Berechnung", "numerischSymbolische"], |
|
657 ["test", "equation", "univariate", "linear"], |
|
658 ["test", "equation", "univariate", "plain_square"], |
|
659 ["test", "equation", "univariate", "polynomial", "degree_two", "pq_formula"], |
|
660 ["test", "equation", "univariate", "polynomial", "degree_two", "abc_formula"], |
|
661 ["test", "equation", "univariate", "squareroot"], |
|
662 ["test", "equation", "univariate", "normalize"], |
|
663 ["test", "equation", "univariate", "sqroot-test"] |
|
664 ] |
|
665 val it = () : unit |
|
666 \end{verbatim} |
|
667 |
|
668 \section{Die passende ''Formalization`` f\"ur den Problemtyp} |
|
669 Eine andere Art des Matching ist es die richtige ''Formalization`` zum jeweiligen Problemtyp zu finden. Wenn es eine ''Formalization`` gibt, dann kann \isac{} selbstst\"andig die Probleme l\"osen. |
|
670 |
|
671 \section{Problem - Refinement} |
|
672 Will man die Hierarchie der Probleme aufstellen, so ist darauf zu achten, dass man die verschiedenen Branches so konstruiert, dass das Problem - Refinement automatisch durchgef\"uhrt werden kann. F\"ur diese Anwendung wird die Hierarchie nach folgenden Regeln aufgestellt: |
|
673 $F$ ist eine Formalization und $P$ und $P_i,\:i=1\cdots n$ sind Problemtypen, wobei $P_i$ ein spezieller Problemtyp ist, im Bezug auf $P$, dann gilt: |
|
674 {\small |
|
675 \begin{enumerate} |
|
676 \item wenn für $F$ der Problemtyp $P_i$ passt, dann passt auch $P$ |
|
677 \item wenn zu $F$ der Problemtyp P passt, dann sollte es nicht mehr als ein $P_i$ geben, das zu $F$ passt. |
|
678 \item alle $F$ , die zu $P$ passen, m\"ussen auch zu $P_n$ passen |
|
679 \end{enumerate} |
|
680 Zuerst ein Beispiel für die ersten zwei Punkte: |
|
681 {\footnotesize\begin{verbatim} |
|
682 > refine; |
|
683 val it = fn : fmz_ -> pblID -> SpecifyTools.match list |
|
684 > val fmz = ["equality (sqrt(9 + 4 * x)=sqrt x |
|
685 + sqrt (5 + x))", |
|
686 # "soleFor x","errorBound (eps=0)", |
|
687 # "solutions L"]; |
|
688 val fmz = |
|
689 ["equality (sqrt(9 + 4 * x)=sqrt x + sqrt (5 + x))", "soleFor x", |
|
690 "errorBound (eps=0)", ...] : string list |
|
691 > refine fmz ["univariate","equation"]; |
|
692 *** pass ["equation","univariate"] |
|
693 *** comp_dts: ??.empty $ soleFor x |
|
694 Exception- ERROR raised |
|
695 \end{verbatim} |
|
696 Wenn die ersten zwei Regeln nicht angewendet werden k\"onnen, wird die dritte verwendet: |
|
697 {\footnotesize\begin{verbatim} |
|
698 > val fmz = ["equality (x + 1 = 2)", |
|
699 # "solveFor x","errorBound (eps=0)", |
|
700 # "solutions L"]; |
|
701 val fmz = ["equality (x + 1 = 2)", "solveFor x", "errorBound (eps=0)", ...] |
|
702 : string list |
|
703 > refine fmz ["univariate","equation"]; |
|
704 *** pass ["equation","univariate"] |
|
705 *** pass ["equation","univariate","linear"] |
|
706 *** pass ["equation","univariate","root"] |
|
707 *** pass ["equation","univariate","rational"] |
|
708 *** pass ["equation","univariate","polynomial" ] |
|
709 *** pass ["equation","univariate","polynomial","degree_0"] |
|
710 *** pass ["equation","univariate","polynomial","degree_1"] |
|
711 *** pass ["equation","univariate","polynomial","degree_2"] |
|
712 *** pass ["equation","univariate","polynomial","degree_3"] |
|
713 *** pass ["equation","univariate","polynomial","degree_4"] |
|
714 *** pass ["equation","univariate","polynomial","normalize"] |
|
715 val it = |
|
716 [Matches |
|
717 (["univariate", "equation"], |
|
718 {Find = [Correct "solutions L"], With = [...], ...}), |
|
719 NoMatch (["linear", "univariate", ...], {Find = [...], ...}), |
|
720 NoMatch (["root", ...], ...), ...] : SpecifyTools.match list |
|
721 \end{verbatim} |
|
722 Der Problemtyp $P_n$ verwandelt x + 1 = 2 in die normale Form -1 + x = 0. Diese suche nach der jeweiligen Problemhierarchie kann mit Hilfe von einem ''proof state`` durchgeführt werden (siehe nächstes Kapitel). |
497 |
723 |
498 |
724 |
499 \chapter{Methods} |
725 \chapter{Methods} |
500 Methods werden dazu verwendet, Probleme von \texttt{type} zu l\"osen. Sie sind in einer anderen Programmiersprache beschrieben. Die Sprache sieht einfach aus, hat aber im Hintergrund einen enormen Pr\"ufauffwand. So muss sich der Programmierer nicht mit technischen Details befassen, gleichzeitig k\"onnen aber auch keine falschen Anweisungen eingegeben werden. |
726 Methods werden dazu verwendet, Probleme von \texttt{type} zu l\"osen. Sie sind in einer anderen Programmiersprache beschrieben. Die Sprache sieht einfach aus, hat aber im Hintergrund einen enormen Pr\"ufauffwand. So muss sich der Programmierer nicht mit technischen Details befassen, gleichzeitig k\"onnen aber auch keine falschen Anweisungen eingegeben werden. |
501 |
|
502 \section{Der ''Syntax`` des Scriptes} |
727 \section{Der ''Syntax`` des Scriptes} |
503 Syntax beschreibt den Zusammenhang der einzelnen Zeichen und Zeichenfolgen mit den Theorien. |
728 Syntax beschreibt den Zusammenhang der einzelnen Zeichen und Zeichenfolgen mit den Theorien. |
504 Er kann so definiert werden: |
729 Er kann so definiert werden: |
505 \begin{tabbing} |
730 \begin{tabbing} |
506 123\=123\=expr ::=\=$|\;\;$\=\kill |
731 123\=123\=expr ::=\=$|\;\;$\=\kill |
536 \item{expr {\tt @@} expr id} |
761 \item{expr {\tt @@} expr id} |
537 \item xxx |
762 \item xxx |
538 \end{description} |
763 \end{description} |
539 |
764 |
540 |
765 |
541 hallo |
766 |
|
767 \chapter{Befehle von \isac{}} |
|
768 In diesem Kapitel werden alle schon zur Verf\"ugung stehenden Schritte aufgelistet. Diese Liste kann sich auf Grund von weiteren Entwicklungen von \isac{} noch \"andern. |
|
769 \newline \textbf{Init\_Proof\_Hid (dialogmode, formalization, specifictaion} gibt die eingegebenen Befehle weiter an die mathematic engine, wobei die beiden letzten Begriffe die Beispiele automatisch speichern. Es ist nicht vorgesehen, dass der Sch\"uler die Taktik verwendet. |
|
770 \newline \textbf{Init\_Proof} bildet mit einem ''proof tree`` ein leeres Modell. |
|
771 \newline \textbf{Model\_Problem problem} bestimmt ein problemtype, das wom\"oglich in der ''hierachy`` gefunden wurde, und verwendet es f\"u das Umformen. |
|
772 \newline \textbf{Add\_Given, Add\_Find, Add\_Relation formula} f\"ugt eine Formel in ein bestimmtes Feld eines Modells ein. Dies ist notwendig, solange noch kein Objekt f\"ur den Benutzer vorhanden ist, in dem man die Formel eingeben kann, und nicht die gew\"unschte Taktik und Formel von einer Liste w\"ahlen will. |
|
773 \newline \textbf{Specify\_Theorie theory, Specify\_Problem proble, Specify\_Method method} gibt das entsprechende Element des Basiswissens an. |
|
774 \newline \textbf{Refine\_Problem problem} sucht nach einem Problem in der hierachy, das auf das vorhandene zutrifft. |
|
775 \newline \textbf{Apply\_Method method} beendet das Modell und die Beschreibung. Danach wird die L\"osungmeldung ge\"offnet. |
|
776 \newline \textbf{Free\_Solve} beginnt eine L\"osungsmeldung ohne die Hilfe eine method. |
|
777 \newline \textbf{Rewrite theorem} bef\"ordert ein theorem in die aktuelle Formel und wandelt es demenetsprechend um. Wenn dies nicht m\"oglich ist, kommt eine Meldung mit ''error``. |
|
778 \newline \textbf{Rewrite\_Asm theorem} hat die gleiche Funktion wie Rewrite, speichert jedoch eine endg\"ultige Vorraussetzung des Theorems, anstatt diese zu sch\"atzen. |
|
779 \newline \textbf{Rewrite\_Set ruleset} hat \"ahnliche Funktionen wie Rewrite, gilt aber f\"ur einen ganzen Satz von Theorems, dem rule set. |
|
780 \newline \textbf{Rewrite\_Inst (substitution, theorem), Rewrite\_Set\_Inst (substitution, rule set)} ist vergleichbar mit besonderen Taktiken, ersetzt aber Konstanten in der Theorem, bevor es zu einer Anwendung kommt. |
|
781 |
|
782 |
|
783 |
542 |
784 |
543 |
785 |
544 |
786 |
545 |
787 |
546 |
788 |
547 |
789 |
548 \newpage |
790 \newpage |
549 ------------------------------- ALTER TEXT ------------------------------- |
791 ------------------------------- ALTER TEXT ------------------------------- |
550 |
|
551 \chapter{The hierarchy of problem types}\label{pbt} |
|
552 \section{The standard-function for 'matching'} |
|
553 Matching \cite{nipk:rew-all-that} is a technique used within rewriting, and used by \isac{} also for (a generalized) 'matching' a problem with a problem type. The function which tests for matching has the following signature: |
|
554 {\footnotesize\begin{verbatim} |
|
555 ML> matches; |
|
556 val it = fn : theory -> term -> term -> bool |
|
557 \end{verbatim}}%size |
|
558 where the first of the two {\tt term} arguments is the particular term to be tested, and the second one is the pattern: |
|
559 {\footnotesize\begin{verbatim} |
|
560 ML> val t = (term_of o the o (parse thy)) "#3 * x^^^#2 = #1"; |
|
561 val t = Const (#,#) $ (# $ # $ (# $ #)) $ Free ("#1","RealDef.real") : term |
|
562 ML> |
|
563 ML> val p = (term_of o the o (parse thy)) "a * b^^^#2 = c"; |
|
564 val p = Const (#,#) $ (# $ # $ (# $ #)) $ Free ("c","RealDef.real") : term |
|
565 ML> atomt p; |
|
566 *** ------------- |
|
567 *** Const ( op =) |
|
568 *** . Const ( op *) |
|
569 *** . . Free ( a, ) |
|
570 *** . . Const ( RatArith.pow) |
|
571 *** . . . Free ( b, ) |
|
572 *** . . . Free ( #2, ) |
|
573 *** . Free ( c, ) |
|
574 val it = () : unit |
|
575 ML> |
|
576 ML> free2var; |
|
577 val it = fn : term -> term |
|
578 ML> |
|
579 ML> val pat = free2var p; |
|
580 val pat = Const (#,#) $ (# $ # $ (# $ #)) $ Var ((#,#),"RealDef.real") : term |
|
581 ML> Sign.string_of_term (sign_of thy) pat; |
|
582 val it = "?a * ?b ^^^ #2 = ?c" : cterm' |
|
583 ML> atomt pat; |
|
584 *** ------------- |
|
585 *** Const ( op =) |
|
586 *** . Const ( op *) |
|
587 *** . . Var ((a, 0), ) |
|
588 *** . . Const ( RatArith.pow) |
|
589 *** . . . Var ((b, 0), ) |
|
590 *** . . . Free ( #2, ) |
|
591 *** . Var ((c, 0), ) |
|
592 val it = () : unit |
|
593 \end{verbatim}}%size % $ |
|
594 Note that the pattern {\tt pat} contains so-called {\it scheme variables} decorated with a {\tt ?} (analoguous to theorems). The pattern is generated by the function {\tt free2var}. This format of the pattern is necessary in order to obtain results like these: |
|
595 {\footnotesize\begin{verbatim} |
|
596 ML> matches thy t pat; |
|
597 val it = true : bool |
|
598 ML> |
|
599 ML> val t2 = (term_of o the o (parse thy)) "x^^^#2 = #1"; |
|
600 val t2 = Const (#,#) $ (# $ # $ Free #) $ Free ("#1","RealDef.real") : term |
|
601 ML> matches thy t2 pat; |
|
602 val it = false : bool |
|
603 ML> |
|
604 ML> val pat2 = (term_of o the o (parse thy)) "?u^^^#2 = ?v"; |
|
605 val pat2 = Const (#,#) $ (# $ # $ Free #) $ Var ((#,#),"RealDef.real") : term |
|
606 ML> matches thy t2 pat2; |
|
607 val it = true : bool |
|
608 \end{verbatim}}%size % $ |
|
609 |
|
610 \section{Accessing the hierarchy} |
|
611 The hierarchy of problem types is encapsulated; it can be accessed by the following functions. {\tt show\_ptyps} retrieves all leaves of the hierarchy (here in an early version for testing): |
|
612 {\footnotesize\begin{verbatim} |
|
613 ML> show_ptyps; |
|
614 val it = fn : unit -> unit |
|
615 ML> show_ptyps(); |
|
616 [ |
|
617 ["e_pblID"], |
|
618 ["equation", "univariate", "linear"], |
|
619 ["equation", "univariate", "plain_square"], |
|
620 ["equation", "univariate", "polynomial", "degree_two", "pq_formula"], |
|
621 ["equation", "univariate", "polynomial", "degree_two", "abc_formula"], |
|
622 ["equation", "univariate", "squareroot"], |
|
623 ["equation", "univariate", "normalize"], |
|
624 ["equation", "univariate", "sqroot-test"], |
|
625 ["function", "derivative_of"], |
|
626 ["function", "maximum_of", "on_interval"], |
|
627 ["function", "make"], |
|
628 ["tool", "find_values"], |
|
629 ["functional", "inssort"] |
|
630 ] |
|
631 val it = () : unit |
|
632 \end{verbatim}}%size |
|
633 The retrieve function for individual problem types is {\tt get\_pbt} |
|
634 \footnote{A function providing better readable output is in preparation}. Note that its argument, the 'problem identifier' {\tt pblID}, has the strings listed in reverse order w.r.t. the hierarchy, i.e. from the leave to the root. This order makes the {\tt pblID} closer to a natural description: |
|
635 {\footnotesize\begin{verbatim} |
|
636 ML> get_pbt; |
|
637 val it = fn : pblID -> pbt |
|
638 ML> get_pbt ["squareroot", "univariate", "equation"]; |
|
639 val it = |
|
640 {met=[("SqRoot.thy","square_equation")], |
|
641 ppc=[("#Given",(Const (#,#),Free (#,#))), |
|
642 ("#Given",(Const (#,#),Free (#,#))), |
|
643 ("#Given",(Const (#,#),Free (#,#))), |
|
644 ("#Find",(Const (#,#),Free (#,#)))], |
|
645 thy={ProtoPure, CPure, HOL, Ord, Set, subset, equalities, mono, Vimage, Fun, |
|
646 Prod, Lfp, Relation, Trancl, WF, NatDef, Gfp, Sum, Inductive, Nat, |
|
647 Arith, Divides, Power, Finite, Equiv, IntDef, Int, Univ, Datatype, |
|
648 Numeral, Bin, IntArith, WF_Rel, Recdef, IntDiv, NatBin, List, Option, |
|
649 Map, Record, RelPow, Sexp, String, Calculation, SVC_Oracle, Main, |
|
650 Zorn, Filter, PNat, PRat, PReal, RealDef, RealOrd, RealInt, RealBin, |
|
651 HyperDef, Descript, ListG, Tools, Script, Typefix, Atools, RatArith, |
|
652 SqRoot}, |
|
653 where_=[Const ("SqRoot.contains'_root","bool => bool") $ |
|
654 Free ("e_","bool")]} : pbt |
|
655 \end{verbatim}}%size %$ |
|
656 where the records fields hold the following data: |
|
657 \begin{description} |
|
658 \item [\tt thy]: the theory necessary for parsing the formulas |
|
659 \item [\tt ppc]: the items of the problem type, divided into those {\tt Given}, the precondition {\tt Where} and the output item(s) {\tt Find}. The items of {\tt Given} and {\tt Find} are all headed by so-called descriptions, which determine the type. These descriptions are defined in {\tt [isac-src]/Isa99/Descript.thy}. |
|
660 \item [\tt met]: the list of methods solving this problem type.\\ |
|
661 \end{description} |
|
662 |
|
663 The following function adds or replaces a problem type (after having it prepared using {\tt prep\_pbt}) |
|
664 {\footnotesize\begin{verbatim} |
|
665 ML> store_pbt; |
|
666 val it = fn : pbt * pblID -> unit |
|
667 ML> store_pbt |
|
668 (prep_pbt SqRoot.thy |
|
669 (["newtype","univariate","equation"], |
|
670 [("#Given" ,["equality e_","solveFor v_","errorBound err_"]), |
|
671 ("#Where" ,["contains_root (e_::bool)"]), |
|
672 ("#Find" ,["solutions v_i_"]) |
|
673 ], |
|
674 [("SqRoot.thy","square_equation")])); |
|
675 val it = () : unit |
|
676 \end{verbatim}}%size |
|
677 When adding a new type with argument {\tt pblID}, an immediate parent must already exist in the hierarchy (this is the one with the tail of {\tt pblID}). |
|
678 |
|
679 \section{Internals of the datastructure} |
|
680 This subsection only serves for the implementation of the hierarchy browser and can be skipped by the authors of math knowledge. |
|
681 |
|
682 A problem type is described by the following record type (in the file {\tt [isac-src]/globals.sml}, the respective functions are in {\tt [isac-src]/ME/ptyps.sml}), and held in a global reference variable: |
|
683 {\footnotesize\begin{verbatim} |
|
684 type pbt = |
|
685 {thy : theory, (* the nearest to the root, |
|
686 which allows to compile that pbt *) |
|
687 where_: term list, (* where - predicates *) |
|
688 ppc : ((string * (* fields "#Given","#Find" *) |
|
689 (term * (* description *) |
|
690 term)) (* id *) |
|
691 list), |
|
692 met : metID list}; (* methods solving the pbt *) |
|
693 datatype ptyp = |
|
694 Ptyp of string * (* key within pblID *) |
|
695 pbt list * (* several pbts with different domIDs*) |
|
696 ptyp list; |
|
697 val e_Ptyp = Ptyp ("empty",[],[]); |
|
698 |
|
699 type ptyps = ptyp list; |
|
700 val ptyps = ref ([e_Ptyp]:ptyps); |
|
701 \end{verbatim}}%size |
|
702 The predicates in {\tt where\_} (i.e. the preconditions) usually are defined in the respective theory in {\tt[isac-src]/knowledge}. Most of the predicates are not defined by rewriting, but by SML-code contained in the respective {\tt *.ML} file. |
|
703 |
|
704 Each item is headed by a so-called description which provides some guidance for interactive input. The descriptions are defined in {\tt[isac-src]/Isa99/Descript.thy}. |
|
705 |
|
706 |
|
707 |
|
708 \section{Match a formalization with a problem type}\label{pbl} |
|
709 A formalization is {\it match}ed with a problem type which yields a problem. A formal description of this kind of {\it match}ing can be found in \\{\tt ftp://ft.ist.tugraz.at/projects/isac/publ/calculemus01.ps.gz}. A formalization of an equation is e.g. |
|
710 {\footnotesize\begin{verbatim} |
|
711 ML> val fmz = ["equality (#1 + #2 * x = #0)", |
|
712 "solveFor x", |
|
713 "solutions L"] : fmz; |
|
714 val fmz = ["equality (#1 + #2 * x = #0)","solveFor x","solutions L"] : fmz |
|
715 \end{verbatim}}%size |
|
716 Given a formalization (and a specification of the problem, i.e. a theory, a problemtype, and a method) \isac{} can solve the respective problem automatically. The formalization must match the problem type for this purpose: |
|
717 {\footnotesize\begin{verbatim} |
|
718 ML> match_pbl; |
|
719 val it = fn : fmz -> pbt -> match' |
|
720 ML> |
|
721 ML> match_pbl fmz (get_pbt ["univariate","equation"]); |
|
722 val it = |
|
723 Matches' |
|
724 {Find=[Correct "solutions L"], |
|
725 Given=[Correct "equality (#1 + #2 * x = #0)",Correct "solveFor x"], |
|
726 Relate=[],Where=[Correct "matches (?a = ?b) (#1 + #2 * x = #0)"],With=[]} |
|
727 : match' |
|
728 ML> |
|
729 ML> match_pbl fmz (get_pbt ["linear","univariate","equation"]); |
|
730 val it = |
|
731 Matches' |
|
732 {Find=[Correct "solutions L"], |
|
733 Given=[Correct "equality (#1 + #2 * x = #0)",Correct "solveFor x"], |
|
734 Relate=[], |
|
735 Where=[Correct |
|
736 "matches ( x = #0) (#1 + #2 * x = #0) | |
|
737 matches ( ?b * x = #0) (#1 + #2 * x = #0) | |
|
738 matches (?a + x = #0) (#1 + #2 * x = #0) | |
|
739 matches (?a + ?b * x = #0) (#1 + #2 * x = #0)"], |
|
740 With=[]} : match' |
|
741 ML> |
|
742 ML> match_pbl fmz (get_pbt ["squareroot","univariate","equation"]); |
|
743 val it = |
|
744 NoMatch' |
|
745 {Find=[Correct "solutions L"], |
|
746 Given=[Correct "equality (#1 + #2 * x = #0)",Correct "solveFor x", |
|
747 Missing "errorBound err_"],Relate=[], |
|
748 Where=[False "contains_root #1 + #2 * x = #0 "],With=[]} : match' |
|
749 \end{verbatim}}%size |
|
750 The above formalization does not match the problem type \\{\tt["squareroot","univariate","equation"]} which is explained by the tags: |
|
751 \begin{tabbing} |
|
752 123\=\kill |
|
753 \> {\tt Missing:} the item is missing in the formalization as required by the problem type\\ |
|
754 \> {\tt Superfl:} the item is not required by the problem type\\ |
|
755 \> {\tt Correct:} the item is correct, or the precondition ({\tt Where}) is true\\ |
|
756 \> {\tt False:} the precondition ({\tt Where}) is false\\ |
|
757 \> {\tt Incompl:} the item is incomlete, or not yet input.\\ |
|
758 \end{tabbing} |
|
759 |
|
760 |
|
761 |
|
762 \section{Refine a problem specification} |
|
763 The challenge in constructing the problem hierarchy is, to design the branches in such a way, that problem refinement can be done automatically (as it is done in algebra system e.g. by a internal hierarchy of equations). |
|
764 |
|
765 For this purpose the hierarchy must be built using the following rules: Let $F$ be a formalization and $P$ and $P_i,\:i=1\cdots n$ problem types, where the $P_i$ are specialized problem types w.r.t. $P$ (i.e. $P$ is a parent node of $P_i$), then |
|
766 {\small |
|
767 \begin{enumerate} |
|
768 \item for all $F$ matching some $P_i$ must follow, that $F$ matches $P$ |
|
769 \item an $F$ matching $P$ should not have more than {\em one} $P_i,\:i=1\cdots n-1$ with $F$ matching $P_i$ (if there are more than one $P_i$, the first one will be taken) |
|
770 \item for all $F$ matching some $P$ must follow, that $F$ matches $P_n$\\ |
|
771 \end{enumerate}}%small |
|
772 \noindent Let us give an example for the point (1.) and (2.) first: |
|
773 {\footnotesize\begin{verbatim} |
|
774 ML> refine; |
|
775 val it = fn : fmz -> pblID -> match list |
|
776 ML> |
|
777 ML> val fmz = ["equality (sqrt(#9+#4*x)=sqrt x + sqrt(#5+x))", |
|
778 "solveFor x","errorBound (eps=#0)", |
|
779 "solutions L"]; |
|
780 ML> |
|
781 ML> refine fmz ["univariate","equation"]; |
|
782 *** pass ["equation","univariate"] |
|
783 *** pass ["equation","univariate","linear"] |
|
784 *** pass ["equation","univariate","plain_square"] |
|
785 *** pass ["equation","univariate","polynomial"] |
|
786 *** pass ["equation","univariate","squareroot"] |
|
787 val it = |
|
788 [Matches |
|
789 (["univariate","equation"], |
|
790 {Find=[Correct "solutions L"], |
|
791 Given=[Correct "equality (sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x))", |
|
792 Correct "solveFor x",Superfl "errorBound (eps = #0)"],Relate=[], |
|
793 Where=[Correct |
|
794 "matches (?a = ?b) (sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x))"], |
|
795 With=[]}), |
|
796 NoMatch |
|
797 (["linear","univariate","equation"], |
|
798 {Find=[Correct "solutions L"], |
|
799 Given=[Correct "equality (sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x))", |
|
800 Correct "solveFor x",Superfl "errorBound (eps = #0)"],Relate=[], |
|
801 Where=[False "(?a + ?b * x = #0) (sqrt (#9 + #4 * x#"], |
|
802 With=[]}), |
|
803 NoMatch |
|
804 (["plain_square","univariate","equation"], |
|
805 {Find=[Correct "solutions L"], |
|
806 Given=[Correct "equality (sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x))", |
|
807 Correct "solveFor x",Superfl "errorBound (eps = #0)"],Relate=[], |
|
808 Where=[False |
|
809 "matches (?a + ?b * x ^^^ #2 = #0)"], |
|
810 With=[]}), |
|
811 NoMatch |
|
812 (["polynomial","univariate","equation"], |
|
813 {Find=[Correct "solutions L"], |
|
814 Given=[Correct "equality (sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x))", |
|
815 Correct "solveFor x",Superfl "errorBound (eps = #0)"],Relate=[], |
|
816 Where=[False |
|
817 "is_polynomial_in sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x) x"], |
|
818 With=[]}), |
|
819 Matches |
|
820 (["squareroot","univariate","equation"], |
|
821 {Find=[Correct "solutions L"], |
|
822 Given=[Correct "equality (sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x))", |
|
823 Correct "solveFor x",Correct "errorBound (eps = #0)"],Relate=[], |
|
824 Where=[Correct |
|
825 "contains_root sqrt (#9 + #4 * x) = sqrt x + sqrt (#5 + x) "], |
|
826 With=[]})] : match list |
|
827 \end{verbatim}}%size}%footnotesize\label{refine} |
|
828 This example shows, that in order to refine an {\tt["univariate","equation"]}, the formalization must match respective respective problem type (rule (1.)) and one of the descendants which should match selectively (rule (2.)). |
|
829 |
|
830 If no one of the descendants of {\tt["univariate","equation"]} match, rule (3.) comes into play: The {\em last} problem type on this level ($P_n$) provides for a special 'problem type' {\tt["normalize"]}. This node calls a method transforming the equation to a (or another) normal form, which then may match. Look at this example: |
|
831 {\footnotesize\begin{verbatim} |
|
832 ML> val fmz = ["equality (x+#1=#2)", |
|
833 "solveFor x","errorBound (eps=#0)", |
|
834 "solutions L"]; |
|
835 [...] |
|
836 ML> |
|
837 ML> refine fmz ["univariate","equation"]; |
|
838 *** pass ["equation","univariate"] |
|
839 *** pass ["equation","univariate","linear"] |
|
840 *** pass ["equation","univariate","plain_square"] |
|
841 *** pass ["equation","univariate","polynomial"] |
|
842 *** pass ["equation","univariate","squareroot"] |
|
843 *** pass ["equation","univariate","normalize"] |
|
844 val it = |
|
845 [Matches |
|
846 (["univariate","equation"], |
|
847 {Find=[Correct "solutions L"], |
|
848 Given=[Correct "equality (x + #1 = #2)",Correct "solveFor x", |
|
849 Superfl "errorBound (eps = #0)"],Relate=[], |
|
850 Where=[Correct "matches (?a = ?b) (x + #1 = #2)"],With=[]}), |
|
851 NoMatch |
|
852 (["linear","univariate","equation"], |
|
853 [...] |
|
854 With=[]}), |
|
855 NoMatch |
|
856 (["squareroot","univariate","equation"], |
|
857 {Find=[Correct "solutions L"], |
|
858 Given=[Correct "equality (x + #1 = #2)",Correct "solveFor x", |
|
859 Correct "errorBound (eps = #0)"],Relate=[], |
|
860 Where=[False "contains_root x + #1 = #2 "],With=[]}), |
|
861 Matches |
|
862 (["normalize","univariate","equation"], |
|
863 {Find=[Correct "solutions L"], |
|
864 Given=[Correct "equality (x + #1 = #2)",Correct "solveFor x", |
|
865 Superfl "errorBound (eps = #0)"],Relate=[],Where=[],With=[]})] |
|
866 : match list |
|
867 \end{verbatim}}%size |
|
868 The problem type $P_n$, {\tt["normalize","univariate","equation"]}, will transform the equation {\tt x + \#1 = \#2} to the normal form {\tt \#-1 + x = \#0}, which then will match {\tt["linear","univariate","equation"]}. |
|
869 |
|
870 This recursive search on the problem hierarchy can be done within a proof state. This leads to the next section. |
|
871 |
|
872 |
|
873 \chapter{Methods}\label{met} |
|
874 A problem type can have one ore more methods solving a respective problem. A method is described by means of another new program language. The language itself looks like a simple functional language, but constructs an imperative proof-state behind the scenes (thus liberating the programer from dealing with technical details and also prohibiting incorrect construction of the proof tree). The interpreter of 'scripts' written in this language evaluates the scriptexpressions, and also delivers certain parts of the script itself for discussion with the user. |
|
875 |
|
876 \section{The scripts' syntax} |
|
877 The syntax of scripts follows the definition given in Backus-normal-form: |
|
878 {\it |
|
879 \begin{tabbing} |
|
880 123\=123\=expr ::=\=$|\;\;$\=\kill |
|
881 \>script ::= {\tt Script} id arg$\,^*$ = body\\ |
|
882 \>\>arg ::= id $\;|\;\;($ ( id :: type ) $)$\\ |
|
883 \>\>body ::= expr\\ |
|
884 \>\>expr ::= \>\>{\tt let} id = expr $($ ; id = expr$)^*$ {\tt in} expr\\ |
|
885 \>\>\>$|\;$\>{\tt if} prop {\tt then} expr {\tt else} expr\\ |
|
886 \>\>\>$|\;$\>listexpr\\ |
|
887 \>\>\>$|\;$\>id\\ |
|
888 \>\>\>$|\;$\>seqex id\\ |
|
889 \>\>seqex ::= \>\>{\tt While} prop {\tt Do} seqex\\ |
|
890 \>\>\>$|\;$\>{\tt Repeat} seqex\\ |
|
891 \>\>\>$|\;$\>{\tt Try} seqex\\ |
|
892 \>\>\>$|\;$\>seqex {\tt Or} seqex\\ |
|
893 \>\>\>$|\;$\>seqex {\tt @@} seqex\\ |
|
894 \>\>\>$|\;$\>tac $($ id $|$ listexpr $)^*$\\ |
|
895 \>\>type ::= id\\ |
|
896 \>\>tac ::= id |
|
897 \end{tabbing}} |
|
898 where {\it id} is an identifier with the usual syntax, {\it prop} is a proposition constructed by Isabelles logical operators (see \cite{Isa-obj} {\tt [isabelle]/src/HOL/HOL.thy}), {\it listexpr} (called {\bf list-expression}) is constructed by Isabelles list functions like {\tt hd, tl, nth} described in {\tt [isabelle]/src/HOL/List.thy}, and {\it type} are (virtually) all types declared in Isabelles version 99. |
|
899 |
|
900 Expressions containing some of the keywords {\tt let}, {\tt if} etc. are called {\bf script-expressions}. |
|
901 |
|
902 Tactics {\it tac} are (curried) functions. For clarity and simplicity reasons, {\it listexpr} must not contain a {\it tac}, and {\it tac}s must not be nested, |
|
903 |
|
904 |
|
905 \section{Control the flow of evaluation} |
|
906 The flow of control is managed by the following script-expressions called {\it tacticals}. |
|
907 \begin{description} |
|
908 \item{{\tt while} prop {\tt Do} expr id} |
|
909 \item{{\tt if} prop {\tt then} expr {\tt else} expr} |
|
910 \end{description} |
|
911 While the the above script-expressions trigger the flow of control by evaluating the current formula, the other expressions depend on the applicability of the tactics within their respective subexpressions (which in turn depends on the proofstate) |
|
912 \begin{description} |
|
913 \item{{\tt Repeat} expr id} |
|
914 \item{{\tt Try} expr id} |
|
915 \item{expr {\tt Or} expr id} |
|
916 \item{expr {\tt @@} expr id} |
|
917 \end{description} |
|
918 |
|
919 \begin{description} |
|
920 \item xxx |
|
921 |
|
922 \end{description} |
|
923 |
792 |
924 \chapter{Do a calculational proof} |
793 \chapter{Do a calculational proof} |
925 First we list all the tactics available so far (this list may be extended during further development of \isac). |
794 First we list all the tactics available so far (this list may be extended during further development of \isac). |
926 |
795 |
927 \section{Tactics for doing steps in calculations} |
796 \section{Tactics for doing steps in calculations} |