test/Pure/PIDE/xml.ML
author wneuper <Walther.Neuper@jku.at>
Thu, 20 Oct 2022 10:23:38 +0200
changeset 60571 19a172de0bb5
parent 60217 1d9fee958a46
child 60771 1b072aab8f4e
permissions -rw-r--r--
followup 6a: tests run from @{context} without sessions
wenzelm@60217
     1
(* Title:  $ISABELLE_ISAC_TEST/Pure/PIDE/xml.ML
wneuper@59115
     2
   Author: Walther Neuper 1505
wneuper@59115
     3
   (c) copyright due to lincense terms.
wneuper@59115
     4
*)
wneuper@59153
     5
"------------------------------------------------------------------------------------------------";
wneuper@59153
     6
"table of contents -----------------------------------------------------------------------------";
wneuper@59153
     7
"------------------------------------------------------------------------------------------------";
wneuper@59153
     8
"----------- test example for migration \"isabelle tty \" --> libisabelle -----------------------";
wneuper@59153
     9
"------------------------------------------------------------------------------------------------";
wneuper@59153
    10
"------------------------------------------------------------------------------------------------";
wneuper@59115
    11
wneuper@59115
    12
"----------- test example for migration \"isabelle tty \" --> libisabelle -----------------------";
wneuper@59115
    13
"----------- test example for migration \"isabelle tty \" --> libisabelle -----------------------";
wneuper@59115
    14
"----------- test example for migration \"isabelle tty \" --> libisabelle -----------------------";
wneuper@59153
    15
"see https://github.com/wneuper/libisabelle/blob/master/doc/test--isac-Java--isac-kernel.txt";
wneuper@59115
    16
wneuper@59115
    17
(* see ~/proto4/libisabelle/doc/test--isac-jav--isac-kernel.txt *)
wneuper@59115
    18
(*------- step 1 -----------------------------------------------------
wneuper@59115
    19
#I: Formalization
wneuper@59115
    20
    isac-java/src/java/isac/util/Formalization.java
wneuper@59115
    21
#O: int
Walther@60571
    22
ML {* CalcTree @{context} [(["equality (x+1=(2::real))", "solveFor x", "solutions L"],("Test",["sqroot-test","univariate","equation","test"],["Test","squ-equ-test-subpbl1"]))]; * }
wneuper@59115
    23
*)
wneuper@59115
    24
val calcid = 111
wneuper@59115
    25
val result =
wneuper@59115
    26
  XML.Elem (("CALCTREE", []), [
wneuper@59115
    27
    XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)])]);
wneuper@59115
    28
xmlstr 0 result = "<CALCTREE>\n  <CALCID>\n    111\n  </CALCID>\n</CALCTREE>";
wneuper@59115
    29
writeln (xmlstr 0 result);
wneuper@59115
    30
wneuper@59115
    31
(*------- step 2 -----------------------------------------------------
wneuper@59115
    32
#I: int
wneuper@59115
    33
#O: (int, int)
wneuper@59115
    34
ML {* Iterator 1; * }
wneuper@59115
    35
*)
wneuper@59115
    36
val userid = 222
wneuper@59115
    37
val result =
wneuper@59115
    38
  XML.Elem (("ADDUSER", []), [
wneuper@59115
    39
    XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
wneuper@59115
    40
      XML.Elem (("USERID", []), [XML.Text (string_of_int userid)])]);
wneuper@59115
    41
xmlstr 0 result = "<ADDUSER>\n  <CALCID>\n    111\n  </CALCID>\n  <USERID>\n    222\n  </USERID>\n</ADDUSER>\n";
wneuper@59115
    42
writeln (xmlstr 0 result);
wneuper@59115
    43
wneuper@59115
    44
(*------- step 3 -----------------------------------------------------
wneuper@59115
    45
#I: int
wneuper@59115
    46
#O: (int, ICalcIterator)
wneuper@59115
    47
    isac-java/src/java/isac/interfaces/ICalcIterator.java
wneuper@59115
    48
ML {* moveActiveRoot 1; * }
wneuper@59115
    49
*)
wneuper@59115
    50
val pos as (is, kind) = ([], "Pbl")
wneuper@59115
    51
val result =
wneuper@59115
    52
  XML.Elem (("CALCITERATOR", []), [
wneuper@59115
    53
    XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
wneuper@59115
    54
    XML.Elem (("POSITION", []), [
wneuper@59115
    55
      XML.Elem (("INTLIST", []), is),
wneuper@59122
    56
        XML.Elem (("POS", []), [XML.Text kind])])]);
wneuper@59115
    57
xmlstr 0 result = "<CALCITERATOR>\n  <CALCID>\n    111\n  </CALCID>\n  <POSITION>\n    <INTLIST>\n    </INTLIST>\n    <POS>\n      Pbl\n    </POS>\n  </POSITION>\n</CALCITERATOR>\n";
wneuper@59115
    58
writeln (xmlstr 0 result);
wneuper@59115
    59
wneuper@59115
    60
(*------- step 4 -----------------------------------------------------
wneuper@59115
    61
#I: (int, ICalcIterator, ICalcIterator, int, string)
wneuper@59115
    62
#O: (int, FormHeadsContainer)
wneuper@59115
    63
    isac-java/src/java/isac/util/formulae/FormHeadsContainer.java, is a list of ...
wneuper@59115
    64
    isac-java/src/java/isac/util/formulae/CalcFormula.java         and ...
wneuper@59115
    65
    isac-java/src/java/isac/util/formulae/CalcHead.java
wneuper@59115
    66
ML {* getFormulaeFromTo 1 ([],Pbl) ([],Pbl) 0 false; * }
wneuper@59115
    67
*)
wneuper@59115
    68
val pos as (is, kind) = ([], "Pbl")
wneuper@59115
    69
val calcformula as (pos, formula) = (pos, "solve (x + 1 = 2, x)")
wneuper@59115
    70
val formheads = [calcformula (*, calchead .. see below*)]
wneuper@59115
    71
val result =
wneuper@59115
    72
  XML.Elem (("GETELEMENTSFROMTO", []), [
wneuper@59115
    73
    XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
wneuper@59115
    74
    XML.Elem (("FORMHEADS", []), [
wneuper@59115
    75
      XML.Elem (("CALCFORMULA", []),  [
wneuper@59115
    76
        XML.Elem (("POSITION", []), [
wneuper@59115
    77
          XML.Elem (("INTLIST", []), is),
wneuper@59115
    78
          XML.Elem (("POS", []), [XML.Text kind])]),
wneuper@59115
    79
        XML.Elem (("FORMULA", []), [
wneuper@59115
    80
          XML.Elem (("MATHML", []), [
wneuper@59115
    81
            XML.Elem (("ISA", []), [XML.Text formula])])])])])]);
wneuper@59115
    82
xmlstr 0 result = "<GETELEMENTSFROMTO>\n  <CALCID>\n    111\n  </CALCID>\n  <FORMHEADS>\n    <CALCFORMULA>\n      <POSITION>\n        <INTLIST>\n        </INTLIST>\n        <POS>\n          Pbl\n        </POS>\n      </POSITION>\n      <FORMULA>\n        <MATHML>\n          <ISA>\n            solve (x + 1 = 2, x)\n          </ISA>\n        </MATHML>\n      </FORMULA>\n    </CALCFORMULA>\n  </FORMHEADS>\n</GETELEMENTSFROMTO>\n";
wneuper@59115
    83
writeln (xmlstr 0 result);
wneuper@59115
    84
wneuper@59115
    85
(*------- step 5 -----------------------------------------------------
wneuper@59115
    86
ML {* refFormula 1 ([],Pbl); * }
wneuper@59115
    87
  ------- step 6 -----------------------------------------------------
wneuper@59115
    88
#I: (int, ICalcIterator)
wneuper@59115
    89
#O: (int, CalcHead)
wneuper@59115
    90
    isac-java/src/java/isac/util/formulae/CalcHead.java
wneuper@59115
    91
ML {* refFormula 1 ([],Pbl); * }
wneuper@59115
    92
*)
wneuper@59115
    93
val head = "solve (x + 1 = 2, x)"
wneuper@59115
    94
val given = [] : ((string * string) * string) list
wneuper@59115
    95
val item as (attr, form) = (("status", "false"), "precond_rootpbl v_v")
wneuper@59115
    96
val where_ as items = [item]
wneuper@59115
    97
val find = [] : ((string * string) * string) list
wneuper@59115
    98
val relate = [] : ((string * string) * string) list
wneuper@59115
    99
val model = (given, where_, find, relate)
wneuper@59115
   100
val belongsto = "Pbl"
wneuper@59115
   101
val specification as (theoryid, problemid, methodid) = (["e_domID"], ["e_pblID"], ["e_metID"])
wneuper@59115
   102
val calchead = (("status", "incorrect"), (pos, head, model, belongsto, specification))
wneuper@59115
   103
val result =
wneuper@59115
   104
  XML.Elem (("REFFORMULA", []), [
wneuper@59115
   105
    XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
wneuper@59115
   106
    XML.Elem (("CALCHEAD", [("status", "\"incorrect\"")]), [
wneuper@59115
   107
      XML.Elem (("POSITION", []), [
wneuper@59115
   108
        XML.Elem (("INTLIST", []), is),
wneuper@59115
   109
        XML.Elem (("POS", []), [XML.Text kind])]),
wneuper@59115
   110
      XML.Elem (("HEAD", []), [
wneuper@59115
   111
        XML.Elem (("MATHML", []), [
wneuper@59115
   112
          XML.Elem (("ISA", []), [XML.Text formula])])]),
wneuper@59115
   113
      XML.Elem (("MODEL", []), [
wneuper@59115
   114
        XML.Elem (("GIVEN", []), []),
wneuper@59115
   115
        XML.Elem (("WHERE", []), [
wneuper@59115
   116
          XML.Elem (("ITEM", [("status", "\"false\"")]), [
wneuper@59115
   117
            XML.Elem (("MATHML", []), [
wneuper@59115
   118
              XML.Elem (("ISA", []), [XML.Text "precond_rootpbl v_v"])])])]),
wneuper@59115
   119
        XML.Elem (("FIND", []), []),
wneuper@59115
   120
        XML.Elem (("RELATE", []), [])]),
wneuper@59115
   121
      XML.Elem (("BELONGSTO", []), [XML.Text "Pbl"]),
wneuper@59115
   122
      XML.Elem (("SPECIFICATION", []), [
wneuper@59115
   123
        XML.Elem (("THEORYID", []), [XML.Text "e_domID"]),
wneuper@59115
   124
        XML.Elem (("PROBLEMID", []), [
wneuper@59115
   125
          XML.Elem (("STRINGLIST", []), [
wneuper@59115
   126
            XML.Elem (("STRING", []), [XML.Text "e_pblID"])])]),
wneuper@59115
   127
        XML.Elem (("METHODID", []), [
wneuper@59115
   128
          XML.Elem (("STRINGLIST", []), [
wneuper@59115
   129
            XML.Elem (("STRING", []), [XML.Text "e_metID"])])])])])]);
wneuper@59115
   130
xmlstr 0 result = "<REFFORMULA>\n  <CALCID>\n    111\n  </CALCID>\n  <CALCHEAD status \"incorrect\">\n    <POSITION>\n      <INTLIST>\n      </INTLIST>\n      <POS>\n        Pbl\n      </POS>\n    </POSITION>\n    <HEAD>\n      <MATHML>\n        <ISA>\n          solve (x + 1 = 2, x)\n        </ISA>\n      </MATHML>\n    </HEAD>\n    <MODEL>\n      <GIVEN>\n      </GIVEN>\n      <WHERE>\n        <ITEM status \"false\">\n          <MATHML>\n            <ISA>\n              precond_rootpbl v_v\n            </ISA>\n          </MATHML>\n        </ITEM>\n      </WHERE>\n      <FIND>\n      </FIND>\n      <RELATE>\n      </RELATE>\n    </MODEL>\n    <BELONGSTO>\n      Pbl\n    </BELONGSTO>\n    <SPECIFICATION>\n      <THEORYID>\n        e_domID\n      </THEORYID>\n      <PROBLEMID>\n        <STRINGLIST>\n          <STRING>\n            e_pblID\n          </STRING>\n        </STRINGLIST>\n      </PROBLEMID>\n      <METHODID>\n        <STRINGLIST>\n          <STRING>\n            e_metID\n          </STRING>\n        </STRINGLIST>\n      </METHODID>\n    </SPECIFICATION>\n ...";
wneuper@59115
   131
writeln (xmlstr 0 result);
wneuper@59115
   132
wneuper@59115
   133
(*------- step 7 -----------------------------------------------------
wneuper@59115
   134
#I: (int, string)
wneuper@59115
   135
#O: (int, CalcChanged)
wneuper@59115
   136
	isac-java/src/java/isac/util/CalcChanged.java
wneuper@59115
   137
 ML {* autoCalculate 1 CompleteCalc; * }
wneuper@59115
   138
*)
wneuper@59115
   139
val pos as (is, kind) = ([], "Pbl")
wneuper@59115
   140
val result =
wneuper@59115
   141
  XML.Elem (("AUTOCALC", []), [
wneuper@59115
   142
    XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
wneuper@59115
   143
    XML.Elem (("CALCCHANGED", []),  [
wneuper@59115
   144
      XML.Elem (("UNCHANGED", []), [
wneuper@59115
   145
        XML.Elem (("INTLIST", []), is),
wneuper@59115
   146
        XML.Elem (("POS", []), [XML.Text kind])]),
wneuper@59115
   147
      XML.Elem (("DELETED", []), [
wneuper@59115
   148
        XML.Elem (("INTLIST", []), is),
wneuper@59115
   149
        XML.Elem (("POS", []), [XML.Text kind])]),
wneuper@59115
   150
     XML.Elem (("GENERATED", []), [
wneuper@59115
   151
        XML.Elem (("INTLIST", []), is),
wneuper@59115
   152
        XML.Elem (("POS", []), [XML.Text "Res"])])])]);
wneuper@59115
   153
xmlstr 0 result = "<AUTOCALC>\n  <CALCID>\n    111\n  </CALCID>\n  <CALCCHANGED>\n    <UNCHANGED>\n      <INTLIST>\n      </INTLIST>\n      <POS>\n        Pbl\n      </POS>\n    </UNCHANGED>\n    <DELETED>\n      <INTLIST>\n      </INTLIST>\n      <POS>\n        Pbl\n      </POS>\n    </DELETED>\n    <GENERATED>\n      <INTLIST>\n      </INTLIST>\n      <POS>\n        Res\n      </POS>\n    </GENERATED>\n  </CALCCHANGED>\n</AUTOCALC>\n";
wneuper@59115
   154
writeln (xmlstr 0 result);
wneuper@59115
   155
wneuper@59115
   156
(*------- step 8 -----------------------------------------------------
wneuper@59115
   157
ML {* getFormulaeFromTo 1 ([],Pbl) ([],Res) 0 false; * }
wneuper@59115
   158
  ------- step 9 -----------------------------------------------------
wneuper@59115
   159
ML {* getFormulaeFromTo 1 ([],Pbl) ([],Res) 0 false; * }
wneuper@59115
   160
  ------- step 10 -----------------------------------------------------
wneuper@59115
   161
#I: (int, ICalcIterator)
wneuper@59115
   162
#O: (int, CalcFormula)
wneuper@59115
   163
ML {* refFormula 1 ([],Res); * }
wneuper@59115
   164
*)
wneuper@59115
   165
val pos as (is, kind) = ([], "Res")
wneuper@59115
   166
val calcformula as (pos, formula) = (pos, "[x = 1]")
wneuper@59115
   167
val formheads = [calcformula (*, calchead .. see below*)]
wneuper@59115
   168
val result =
wneuper@59115
   169
  XML.Elem (("REFFORMULA", []), [
wneuper@59115
   170
    XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)]),
wneuper@59115
   171
    XML.Elem (("CALCFORMULA", []),  [
wneuper@59115
   172
      XML.Elem (("POSITION", []), [
wneuper@59115
   173
        XML.Elem (("INTLIST", []), is),
wneuper@59115
   174
        XML.Elem (("POS", []), [XML.Text kind])]),
wneuper@59115
   175
      XML.Elem (("FORMULA", []), [
wneuper@59115
   176
        XML.Elem (("MATHML", []), [
wneuper@59115
   177
          XML.Elem (("ISA", []), [XML.Text formula])])])])]);
wneuper@59115
   178
xmlstr 0 result = "<REFFORMULA>\n  <CALCID>\n    111\n  </CALCID>\n  <CALCFORMULA>\n    <POSITION>\n      <INTLIST>\n      </INTLIST>\n      <POS>\n        Res\n      </POS>\n    </POSITION>\n    <FORMULA>\n      <MATHML>\n        <ISA>\n          [x = 1]\n        </ISA>\n      </MATHML>\n    </FORMULA>\n  </CALCFORMULA>\n</REFFORMULA>\n";
wneuper@59115
   179
writeln (xmlstr 0 result);
wneuper@59115
   180
wneuper@59115
   181
(*------- step 11 -----------------------------------------------------
wneuper@59115
   182
ML {* refFormula 1 ([],Res); * }
wneuper@59115
   183
  ------- step 12 -----------------------------------------------------
wneuper@59115
   184
ML {* refFormula 1 ([],Res); * }
wneuper@59115
   185
  ------- step 13 -----------------------------------------------------
wneuper@59115
   186
#I: int
wneuper@59115
   187
#O: int
wneuper@59115
   188
ML {* DEconstrCalcTree 1; * }
wneuper@59115
   189
*)
wneuper@59115
   190
val result =
wneuper@59115
   191
  XML.Elem (("DELCALC", []), [
wneuper@59115
   192
    XML.Elem (("CALCID", []), [XML.Text (string_of_int calcid)])]);
wneuper@59115
   193
xmlstr 0 result = "<CALCTREE>\n  <CALCID>\n    111\n  </CALCID>\n</CALCTREE>";
wneuper@59115
   194
writeln (xmlstr 0 result);
wneuper@59115
   195
wneuper@59153
   196