test/Tools/isac/xmlsrc/mathml.sml
author Walther Neuper <wneuper@ist.tugraz.at>
Fri, 05 Feb 2016 16:05:11 +0100
changeset 59214 5ce72a592f7f
parent 59213 80d2d4d80618
child 59224 bb8ceff84b96
permissions -rw-r--r--
testdata for scala-side of libisabelle + terms
akargl@42176
     1
(* Title: tests for mathml.sml
akargl@42176
     2
   Author: Walther Neuper 060311
neuper@37906
     3
   (c) isac-team 2006
neuper@37906
     4
*)
neuper@37906
     5
"-----------------------------------------------------------------";
neuper@37906
     6
"table of contents -----------------------------------------------";
neuper@37906
     7
"-----------------------------------------------------------------";
neuper@37906
     8
"within struct ---------------------------------------------------";
neuper@37906
     9
"-----------------------------------------------------------------";
neuper@37906
    10
"--------- encode ^^^ -> ^ ---------------------------------------";
neuper@37906
    11
"--------- encode < -> &lt and > -> &gt --------------------------";
wneuper@59177
    12
"--------- fun rm_doublets '-4 * b ^^^^^^^^^ 2 / (...' -----------";
wneuper@59177
    13
"--------- fun decode '-4 * b ^^^^^^^^^ 2 / (...' ----------------";
wneuper@59213
    14
"--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
wneuper@59214
    15
"--------- create testdata for TestPIDE.java#testTermTransfer ----";
neuper@37906
    16
"-----------------------------------------------------------------";
neuper@37906
    17
"exported from struct --------------------------------------------";
neuper@37906
    18
"-----------------------------------------------------------------";
neuper@37906
    19
"--------- ... ---------------------------------------------------";
neuper@37906
    20
"-----------------------------------------------------------------";
neuper@37906
    21
neuper@37906
    22
neuper@37906
    23
neuper@37906
    24
"-----------------------------------------------------------------";
neuper@37906
    25
"within struct ---------------------------------------------------";
neuper@37906
    26
"-----------------------------------------------------------------";
neuper@37906
    27
(*==================================================================*)
neuper@37906
    28
neuper@37906
    29
"--------- encode ^^^ -> ^ ---------------------------------------";
neuper@37906
    30
"--------- encode ^^^ -> ^ ---------------------------------------";
neuper@37906
    31
"--------- encode ^^^ -> ^ ---------------------------------------";
neuper@37906
    32
val str = "a^^^2+b^^^2=c^^^2";
neuper@37906
    33
if decode str = "a^2+b^2=c^2" then ()
neuper@38031
    34
else error "mathml.sml: diff.behav. in encode ^^^ -> ^";
neuper@37906
    35
akargl@42176
    36
"--------- encode < -> &lt; and > -> &gt; --------------------------";
akargl@42176
    37
"--------- encode < -> &lt; and > -> &gt; --------------------------";
akargl@42176
    38
"--------- encode < -> &lt; and > -> &gt; --------------------------";
neuper@37906
    39
val str = "?bdv occurs_in ?b; 0 < ?n |] ==> ?a / ?b ^ ?n = ?a * ?b ^ - ?n";
akargl@42176
    40
if decode str = "?bdv occurs_in ?b; 0 &lt; ?n |] ==&gt; ?a / ?b ^ ?n = ?a * ?b ^ - ?n" then ()
akargl@42176
    41
else error "mathml.sml: diff.behav. in encode '<' and '>'";
neuper@37906
    42
akargl@42176
    43
(*========== inhibit exn AK110725 ================================================
neuper@37906
    44
"----- check 'manually' the xml-output of calling functions ------";
akargl@42176
    45
formula2xml 1 (str2term str);
neuper@37906
    46
akargl@42176
    47
(* AK110725 
akargl@42176
    48
(*str2term str; (* ERROR: Inner syntax error at "; 0 < ?n |] ==> ?a / ?b ^ ?n = ?a * ?b ^ - ?n"
akargl@42176
    49
                   Failed to parse term*)*)
akargl@42176
    50
"~~~~~ fun str2term, args:"; val (str) = (str);
akargl@42176
    51
Thy_Info.get_theory "Isac";
akargl@42176
    52
akargl@42176
    53
parse_patt;
akargl@42176
    54
parse_patt (Thy_Info.get_theory "Isac");
akargl@42176
    55
(*parse_patt (Thy_Info.get_theory "Isac") str; (* ERROR: Inner syntax error at "; 0 < ?n |] ==> ?a / ?b ^ ?n = ?a * ?b ^ - ?n"
akargl@42176
    56
Failed to parse term*)*)
akargl@42176
    57
akargl@42176
    58
"~~~~~ fun parse_patt, args:"; val (thy, str) = ((Thy_Info.get_theory "Isac"), str);
akargl@42176
    59
(thy, str) 
akargl@42176
    60
|>> thy2ctxt
neuper@48761
    61
(*|-> Proof_Context.read_term_pattern (*ERROR: Inner syntax error at "; 0 < ?n |] ==> ?a / ?b ^ ?n = ?a * ?b ^ - ?n"
akargl@42176
    62
Failed to parse term*)*)
akargl@42176
    63
neuper@48761
    64
Proof_Context.read_term_pattern;
akargl@42176
    65
(@{theory "Isac"}, str) |>> thy2ctxt;
neuper@48761
    66
"~~~~~ fun Proof_Context.read_term_pattern, args:"; val () = ();
akargl@42176
    67
(*AK110725 To be continued...*)
akargl@42176
    68
*)
neuper@37906
    69
(*==================================================================*)
neuper@37906
    70
"-----------------------------------------------------------------";
neuper@37906
    71
"exported from struct --------------------------------------------";
neuper@37906
    72
"-----------------------------------------------------------------";
akargl@42176
    73
========== inhibit exn AK110725 ================================================*)
wneuper@59177
    74
wneuper@59177
    75
"--------- fun rm_doublets '-4 * b ^^^^^^^^^ 2 / (...' -----------";
wneuper@59177
    76
"--------- fun rm_doublets '-4 * b ^^^^^^^^^ 2 / (...' -----------";
wneuper@59177
    77
"--------- fun rm_doublets '-4 * b ^^^^^^^^^ 2 / (...' -----------";
wneuper@59177
    78
val c = "^";
wneuper@59177
    79
val cs = ["^","^","^","d","e"];
wneuper@59177
    80
if rm_doublets c [] cs = Symbol.explode "^de" 
wneuper@59177
    81
then () else error "rm_doublets '^^^de' CHANGED";
wneuper@59177
    82
wneuper@59177
    83
val cs = ["a","b","^","^","^","d","e"];
wneuper@59177
    84
if rm_doublets c [] cs = Symbol.explode "ab^de" 
wneuper@59177
    85
then () else error "rm_doublets 'ab^^^de' CHANGED";
wneuper@59177
    86
wneuper@59177
    87
val cstr = 
wneuper@59177
    88
"-4 * b ^^^^^^^^^ 2 / (a + b) + 4 * a ^^^^^^^^^ 2 / (a + b) -4 * b ^ 2 / (a + b) + 4 * a ^ 2 / (a + b)";
wneuper@59177
    89
val cs = Symbol.explode cstr;
wneuper@59177
    90
if rm_doublets c [] cs = Symbol.explode 
wneuper@59177
    91
  "-4 * b ^ 2 / (a + b) + 4 * a ^ 2 / (a + b) -4 * b ^ 2 / (a + b) + 4 * a ^ 2 / (a + b)"
wneuper@59177
    92
then () else error "rm_doublets '-4 * b ^^^^^..' CHANGED";
wneuper@59177
    93
wneuper@59177
    94
"--------- fun decode '-4 * b ^^^^^^^^^ 2 / (...' ----------------";
wneuper@59177
    95
"--------- fun decode '-4 * b ^^^^^^^^^ 2 / (...' ----------------";
wneuper@59177
    96
"--------- fun decode '-4 * b ^^^^^^^^^ 2 / (...' ----------------";
wneuper@59177
    97
if encode cstr = 
wneuper@59177
    98
"-4 * b ^^^ 2 / (a + b) + 4 * a ^^^ 2 / (a + b) -4 * b ^^^ 2 / (a + b) + 4 * a ^^^ 2 / (a + b)"
wneuper@59177
    99
then () else error "encode '-4 * b ^^^^^..' CHANGED";
wneuper@59177
   100
wneuper@59213
   101
"--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
wneuper@59213
   102
"--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
wneuper@59213
   103
"--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
wneuper@59213
   104
val t = @{term "aaa + bbb::real"};
wneuper@59213
   105
if t = (t |> xml_of_term_NEW |> xml_to_term_NEW) then ()
wneuper@59213
   106
else error "xml_of_term_NEW |> xml_to_term_NEW changed"
wneuper@59214
   107
wneuper@59214
   108
"--------- create testdata for TestPIDE.java#testTermTransfer ----";
wneuper@59214
   109
"--------- create testdata for TestPIDE.java#testTermTransfer ----";
wneuper@59214
   110
"--------- create testdata for TestPIDE.java#testTermTransfer ----";
wneuper@59214
   111
val t = @{term "aaa + bbb::real"};
wneuper@59214
   112
val ttt = HOLogic.mk_eq (t, Const ("processed_by_Isabelle_Isac", type_of t))
wneuper@59214
   113
(* check the term structure *)
wneuper@59214
   114
val Const ("HOL.eq", T1) $
wneuper@59214
   115
     (Const ("Groups.plus_class.plus", T2) $ 
wneuper@59214
   116
        Free ("aaa", T3) $ 
wneuper@59214
   117
        Free ("bbb", _)) $
wneuper@59214
   118
      Const ("processed_by_Isabelle_Isac", _) = ttt;
wneuper@59214
   119
wneuper@59214
   120
(* check the type structure *)
wneuper@59214
   121
atomtyp T3;
wneuper@59214
   122
Type ("Real.real", []);
wneuper@59214
   123
wneuper@59214
   124
atomtyp T2;
wneuper@59214
   125
(*
wneuper@59214
   126
*** Type (fun,[
wneuper@59214
   127
*** . Type (Real.real,[])
wneuper@59214
   128
*** . Type (fun,[
wneuper@59214
   129
*** . . Type (Real.real,[])
wneuper@59214
   130
*** . . Type (Real.real,[])
wneuper@59214
   131
*** . . ]
wneuper@59214
   132
*** . ]
wneuper@59214
   133
with this ^^^ build the typ ...*)
wneuper@59214
   134
Type ("fun", [
wneuper@59214
   135
  Type ("Real.real", []), 
wneuper@59214
   136
  Type ("fun", [
wneuper@59214
   137
    Type ("Real.real", []), 
wneuper@59214
   138
    Type ("Real.real", [])])]);
wneuper@59214
   139
wneuper@59214
   140
atomtyp T1;
wneuper@59214
   141
(*
wneuper@59214
   142
*** Type (fun,[
wneuper@59214
   143
*** . Type (Real.real,[])
wneuper@59214
   144
*** . Type (fun,[
wneuper@59214
   145
*** . . Type (Real.real,[])
wneuper@59214
   146
*** . . Type (HOL.bool,[])
wneuper@59214
   147
*** . . ]
wneuper@59214
   148
*** . ]
wneuper@59214
   149
with this ^^^ build the typ ...*)
wneuper@59214
   150
Type ("fun", [
wneuper@59214
   151
  Type ("Real.real", []), 
wneuper@59214
   152
  Type ("fun", [
wneuper@59214
   153
    Type ("Real.real", []), 
wneuper@59214
   154
    Type ("HOL.bool", [])])]);
wneuper@59214
   155
wneuper@59214
   156
(* now compose term + typ *)
wneuper@59214
   157
val Const ("HOL.eq", Type ("fun", [
wneuper@59214
   158
                       Type ("Real.real", []), 
wneuper@59214
   159
                       Type ("fun", [
wneuper@59214
   160
                         Type ("Real.real", []), 
wneuper@59214
   161
                         Type ("HOL.bool", [])])])) $
wneuper@59214
   162
     (Const ("Groups.plus_class.plus", Type ("fun", [
wneuper@59214
   163
                                         Type ("Real.real", []), 
wneuper@59214
   164
                                         Type ("fun", [
wneuper@59214
   165
                                           Type ("Real.real", []), 
wneuper@59214
   166
                                           Type ("Real.real", [])])])) $ 
wneuper@59214
   167
        Free ("aaa", Type ("Real.real", [])) $ 
wneuper@59214
   168
        Free ("bbb", Type ("Real.real", []))) $
wneuper@59214
   169
      Const ("processed_by_Isabelle_Isac", Type ("Real.real", [])) = ttt;
wneuper@59214
   170
wneuper@59214
   171
(* match out the original term from result*)
wneuper@59214
   172
val Const ("HOL.eq", Type ("fun", [
wneuper@59214
   173
                       Type ("Real.real", []), 
wneuper@59214
   174
                       Type ("fun", [
wneuper@59214
   175
                         Type ("Real.real", []), 
wneuper@59214
   176
                         Type ("HOL.bool", [])])])) $
wneuper@59214
   177
      t' $
wneuper@59214
   178
      Const ("processed_by_Isabelle_Isac", Type ("Real.real", [])) = ttt;
wneuper@59214
   179
if t = t' then () else error "something with test_term changed"