test/Tools/isac/BridgeLibisabelle/pbl-met-hierarchy.sml
author Walther Neuper <walther.neuper@jku.at>
Wed, 03 Feb 2021 16:39:44 +0100
changeset 60154 2ab0d1523731
parent 59997 46fe5a8c3911
child 60230 0ca0f9363ad3
permissions -rw-r--r--
Isac's MethodC not shadowing Isabelle's Method
     1 (* Title: tests for sml/xmlsrc/pbl-met-hierarchy.sml
     2    Author: Walther Neuper 060209
     3    (c) isac-team 2006
     4 
     5 use"../smltest/xmlsrc/pbl-met-hierarchy.sml";
     6 use"pbl-met-hierarchy.sml";
     7 
     8 CAUTION with testing *2file functions -- they are actually writing !!!
     9 *)
    10 
    11 val thy = @{theory "Isac_Knowledge"};
    12 
    13 "-----------------------------------------------------------------";
    14 "table of contents -----------------------------------------------";
    15 "-----------------------------------------------------------------";
    16 "----- pbl2xml ---------------------------------------------------";
    17 "----- ERROR Illegal reference to internal variable: 'Pure_' -----";
    18 "----- fun pbl2term ----------------------------------------------";
    19 "----- fun insert_errpats ----------------------------------------";
    20 "-----------------------------------------------------------------";
    21 "-----------------------------------------------------------------";
    22 "-----------------------------------------------------------------";
    23 
    24 
    25 
    26 "----- pbl2xml ---------------------------------------------------";
    27 "----- pbl2xml ---------------------------------------------------";
    28 "----- pbl2xml ---------------------------------------------------";
    29 (*what to do if from 'pbls2file "../../xmldata/pbl/";' you get the error
    30 
    31 ### pbl2file: id = ["Biegelinie"]
    32 *** Type unification failed: Clash of types "fun" and "Program.ID".
    33 *** Type error in application: Incompatible operand type.
    34 ***
    35 *** Operator:  Problem :: ID * ID list => ??'a
    36 *** Operand:   (Biegelinie, [Biegelinie]) ::
    37 ***   ((real => real) => una) * ((real => real) => una) list
    38 ***
    39 Exception- OPTION raised
    40 *)
    41 
    42 if  Pbl_Met_Hierarchy.pbl2xml ["Biegelinien"] (Problem.from_store ["Biegelinien"]) =
    43   "<NODECONTENT>\n"^
    44   "  <GUH> pbl_bieg </GUH>\n"^
    45   "  <STRINGLIST>\n"^
    46   "    <STRING> Biegelinien </STRING>\n"^
    47   "  </STRINGLIST>\n  <META> </META>\n"^
    48   "  <HEADLINE>\n"^
    49   "    <MATHML>\n"^
    50   "      <ISA> Problem (Biegelinie', [Biegelinien]) </ISA>\n"^
    51   "    </MATHML>\n"^
    52   "  </HEADLINE>\n"^
    53 
    54   "  <GIVEN>\n"^
    55   "    <MATHML>\n"^
    56   "      <ISA> Traegerlaenge l_l </ISA>\n"^
    57   "    </MATHML>\n"^
    58   "    <MATHML>\n"^
    59   "      <ISA> Streckenlast q_q </ISA>\n"^
    60   "    </MATHML>  </GIVEN>\n  <WHERE>  </WHERE>\n"^
    61   "  <FIND>\n"^
    62   "    <MATHML>\n"^
    63   "      <ISA> Biegelinie b_b </ISA>\n"^
    64   "    </MATHML>  </FIND>\n"^
    65   "  <RELATE>\n"^
    66   "    <MATHML>\n"^
    67   "      <ISA> Randbedingungen r_b </ISA>\n"^
    68   "    </MATHML>  </RELATE>\n"^
    69 
    70   "  <EXPLANATIONS> </EXPLANATIONS>\n"^
    71   "  <THEORY>\n"^
    72   "    <KESTOREREF>\n"^
    73   "      <TAG> Theorem </TAG>\n"^
    74   "      <ID>  </ID>\n"^
    75   "      <GUH> thy_isac_Biegelinie-thm- </GUH>\n"^
    76   "    </KESTOREREF>\n"^
    77   "  </THEORY>\n"^
    78 
    79   "  <METHODS>\n"^
    80   "    <KESTOREREF>\n"^
    81   "      <TAG> MethodC</TAG>\n"^
    82   "      <ID> [IntegrierenUndKonstanteBestimmen2] </ID>\n"^
    83   "      <GUH> met_biege_2 </GUH>\n"^
    84   "    </KESTOREREF>\n"^
    85   "  </METHODS>\n"^
    86 
    87   "  <EVALPRECOND> empty </EVALPRECOND>\n"^
    88   "  <MATHAUTHORS>\n"^
    89   "  </MATHAUTHORS>\n"^
    90   "  <COURSEDESIGNS>\n"^
    91   "    <STRING> isac team 2006 </STRING>\n"^
    92   "  </COURSEDESIGNS>\n"^
    93   "</NODECONTENT>"
    94 then () else error "fun pbl2xml 'Biegelinien' changed";
    95 
    96 (* val id = ["Biegelinie"];
    97    val {(*guh,*)cas,met,ppc,prls,thy,where_} = Problem.from_store ["Biegelinie"];
    98    AND STEP THROUGH pbl2xml ...
    99 
   100    term2xml i (pbl2term thy id);
   101    pbl2term thy id;
   102   *)
   103 (* val (thy, pblRD) = (thy, id);
   104    AND STEP THROUGH pbl2term...
   105 
   106    val str = ("Problem (" ^ 
   107 	   (get_thy o theory2domID) thy ^ ", " ^
   108 	   (strs2str' o rev) pblRD ^ ")");
   109   str2term str;
   110   str2term "Biegelinie";
   111   str2term "Biegelinien";
   112   *)
   113 (*Const
   114       ("Biegelinie.Biegelinie",
   115        "("Real.real => "Real.real) => Tools.una") : Term.term
   116 ..I.E. THE "Program.ID" _WAS_ ALREADY OCCUPIED BY A 'description'*)
   117 
   118 
   119 "----- ERROR Illegal reference to internal variable: 'Pure_' -----";
   120 "----- ERROR Illegal reference to internal variable: 'Pure_' -----";
   121 "----- ERROR Illegal reference to internal variable: 'Pure_' -----";
   122 val path = "/tmp/"; 
   123 "~~~~~ fun pbls2file, args:"; val (p: Pbl_Met_Hierarchy.filepath) = (path ^ "pbl/");
   124 get_ptyps (); (*not = []*)
   125 "~~~~~ fun nodes, args:"; val (pa, ids, po, wfn, (n::ns)) =
   126   (p, []: string list, [0], Pbl_Met_Hierarchy.pbl2file, (get_ptyps ()));
   127 "~~~~~ fun node, args:"; val (pa: Pbl_Met_Hierarchy.filepath, ids, po, wfn, Store.Node (id,[n],ns)) = (pa, ids, po, wfn, n);
   128 val po' = lev_on po;
   129 wfn (*= pbl2file*)
   130 "~~~~~ fun pbl2file, args:"; val ((path:Pbl_Met_Hierarchy.filepath), (pos:pos), (id: MethodC.id), (pbl as {guh,...})) =
   131   (pa, po', (ids@[id]), n);
   132 strs2str id = "[\"e_pblID\"]"; (*true*)
   133 pos2str pos = "[1]"; (*true*)
   134 path ^ Thy_Present.guh2filename guh = "/tmp/pbl/pbl_empty.xml"; (*true*)
   135 "~~~~~ fun pbl2xml, args:"; val (id: Problem.id, {guh,mathauthors,init,cas,met,ppc,prls,thy,where_}) =
   136   (id, pbl);
   137 "~~~~~ fun pbl2term, args:"; val (thy, (pblRD:Problem.id_reverse)) = (thy, id);
   138 if ("Problem (" ^  Context.theory_name thy ^ "', " ^ (strs2str' o rev) pblRD ^ ")") =
   139   "Problem (Pure', [empty_probl_id])"
   140 then () else error "fun pbl2term changed";
   141 
   142 
   143 "----- fun pbl2term ----------------------------------------------";
   144 "----- fun pbl2term ----------------------------------------------";
   145 "----- fun pbl2term ----------------------------------------------";
   146 (*see WN120405a.TODO.txt*)
   147 if UnparseC.term (Pbl_Met_Hierarchy.pbl2term (ThyC.get_theory "Isac_Knowledge") ["equations", "univariate", "normalise"]) =
   148   "Problem (Isac_Knowledge', [normalise, univariate, equations])"
   149 then () else error "fun pbl2term changed";
   150 
   151 "----- fun insert_errpats ----------------------------------------";
   152 "----- fun insert_errpats ----------------------------------------";
   153 "----- fun insert_errpats ----------------------------------------";
   154 (* vv--- here intermediate save/restore does not work and affects other tests ---vv
   155          see test/../calcelems.sml --- Unsynchronized.ref doesn't work any more ---
   156 
   157 val errpatstest =
   158   [("chain-rule-diff-both",
   159     [parse_patt @{theory} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
   160      parse_patt @{theory} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
   161      parse_patt @{theory} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
   162      parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
   163      parse_patt @{theory} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
   164     [@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain}, 
   165      @{thm diff_ln_chain}, @{thm  diff_exp_chain}])];
   166 
   167 insert_errpats ["diff", "differentiate_on_R"] errpatstest;
   168 
   169 val {errpats, ...} = MethodC.from_store ["diff", "differentiate_on_R"];
   170 case errpats of
   171   ("chain-rule-diff-both", _, _) :: _ => ()
   172 | _ => error "insert_errpats chain-rule-diff-both changed";
   173 ^^^^^--- here intermediate save/restore does not work and affects other tests ---^^*)
   174