test/Tools/isac/BridgeLibisabelle/mathml.sml
author wneuper <walther.neuper@jku.at>
Tue, 20 Apr 2021 16:58:44 +0200
changeset 60242 73ee61385493
parent 60230 0ca0f9363ad3
child 60244 ac7426ab0491
permissions -rw-r--r--
replace power ^^^ by \<up>
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
"-----------------------------------------------------------------";
walther@60242
    10
"--------- encode \<up> -> ^ ---------------------------------------";
neuper@37906
    11
"--------- encode < -> &lt and > -> &gt --------------------------";
walther@60242
    12
"--------- fun rm_doublets '-4 * b \<up>\<up>\<up> 2 / (...' -----------";
walther@60242
    13
"--------- fun decode '-4 * b \<up>\<up>\<up> 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
walther@60242
    29
"--------- encode \<up> -> ^ ---------------------------------------";
walther@60242
    30
"--------- encode \<up> -> ^ ---------------------------------------";
walther@60242
    31
"--------- encode \<up> -> ^ ---------------------------------------";
walther@60242
    32
val str = "a\<up>2+b\<up>2=c\<up>2";
walther@60242
    33
if decode str = "a\<up>2+b\<up>2=c\<up>2" then ()
walther@60242
    34
else error "mathml.sml: diff.behav. in encode \<up> -> ^";
neuper@37906
    35
akargl@42176
    36
"--------- encode < -> &lt; and > -> &gt; --------------------------";
akargl@42176
    37
"--------- encode < -> &lt; and > -> &gt; --------------------------";
akargl@42176
    38
"--------- encode < -> &lt; and > -> &gt; --------------------------";
walther@60242
    39
val str = "?bdv occurs_in ?b; 0 < ?n |] ==> ?a / ?b  \<up>  ?n = ?a * ?b  \<up>  - ?n";
walther@60242
    40
if decode str = "?bdv occurs_in ?b; 0 &lt; ?n |] ==&gt; ?a / ?b  \<up>  ?n = ?a * ?b  \<up>  - ?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 ------";
walther@60230
    45
formula2xml 1 (TermC.str2term str);
neuper@37906
    46
akargl@42176
    47
(* AK110725 
walther@60242
    48
(*TermC.str2term str; (* ERROR: Inner syntax error at "; 0 < ?n |] ==> ?a / ?b  \<up>  ?n = ?a * ?b  \<up>  - ?n"
walther@60230
    49
                   Failed to TermC.parse term*)*)
walther@60230
    50
"~~~~~ fun TermC.str2term, args:"; val (str) = (str);
walther@59879
    51
ThyC.get_theory "Isac_Knowledge";
akargl@42176
    52
walther@60230
    53
TermC.parse_patt;
walther@60230
    54
TermC.parse_patt (ThyC.get_theory "Isac_Knowledge");
walther@60242
    55
(*TermC.parse_patt (ThyC.get_theory "Isac_Knowledge") str; (* ERROR: Inner syntax error at "; 0 < ?n |] ==> ?a / ?b  \<up>  ?n = ?a * ?b  \<up>  - ?n"
walther@60230
    56
Failed to TermC.parse term*)*)
akargl@42176
    57
walther@60230
    58
"~~~~~ fun TermC.parse_patt, args:"; val (thy, str) = ((ThyC.get_theory "Isac_Knowledge"), str);
akargl@42176
    59
(thy, str) 
walther@59879
    60
|>> ThyC.to_ctxt
walther@60242
    61
(*|-> Proof_Context.read_term_pattern (*ERROR: Inner syntax error at "; 0 < ?n |] ==> ?a / ?b  \<up>  ?n = ?a * ?b  \<up>  - ?n"
walther@60230
    62
Failed to TermC.parse term*)*)
akargl@42176
    63
neuper@48761
    64
Proof_Context.read_term_pattern;
walther@59879
    65
(@{theory "Isac_Knowledge"}, str) |>> ThyC.to_ctxt;
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@59224
    75
"--------- fun xmlstr --------------------------------------------";
wneuper@59224
    76
"--------- fun xmlstr --------------------------------------------";
wneuper@59224
    77
"--------- fun xmlstr --------------------------------------------";
wneuper@59224
    78
val term = @{term "aaa + bbb::real"};
wneuper@59224
    79
val str = term |> xml_of_term_NEW |> xmlstr 0;
wneuper@59224
    80
if str =
walther@59617
    81
"(FORMULA)\n. (ISA)\n. . aaa + bbb\n. (/ISA)\n. (TERM)\n aaa + bbb\n(/TERM)\n(/FORMULA)\n"
wneuper@59224
    82
then () else error "term |> xml_of_term_NEW |> xmlstr ..changed";
wneuper@59224
    83
writeln str;
wneuper@59224
    84
wneuper@59213
    85
"--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
wneuper@59213
    86
"--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
wneuper@59213
    87
"--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
wneuper@59224
    88
(* xml_of_term_NEW o xml_to_term_NEW = id ... not valid, 
wneuper@59224
    89
  as long as the latter (going: frontend \<longrightarrow> kernel) does only carry "ISA" string.
wneuper@59213
    90
val t = @{term "aaa + bbb::real"};
wneuper@59213
    91
if t = (t |> xml_of_term_NEW |> xml_to_term_NEW) then ()
wneuper@59213
    92
else error "xml_of_term_NEW |> xml_to_term_NEW changed"
wneuper@59224
    93
*)
wneuper@59214
    94
wneuper@59214
    95
"--------- create testdata for TestPIDE.java#testTermTransfer ----";
wneuper@59214
    96
"--------- create testdata for TestPIDE.java#testTermTransfer ----";
wneuper@59214
    97
"--------- create testdata for TestPIDE.java#testTermTransfer ----";
wneuper@59214
    98
val t = @{term "aaa + bbb::real"};
wneuper@59214
    99
val ttt = HOLogic.mk_eq (t, Const ("processed_by_Isabelle_Isac", type_of t))
wneuper@59214
   100
(* check the term structure *)
wneuper@59214
   101
val Const ("HOL.eq", T1) $
wneuper@59214
   102
     (Const ("Groups.plus_class.plus", T2) $ 
wneuper@59214
   103
        Free ("aaa", T3) $ 
wneuper@59214
   104
        Free ("bbb", _)) $
wneuper@59214
   105
      Const ("processed_by_Isabelle_Isac", _) = ttt;
wneuper@59214
   106
wneuper@59214
   107
(* check the type structure *)
wneuper@59214
   108
atomtyp T3;
wneuper@59214
   109
Type ("Real.real", []);
wneuper@59214
   110
wneuper@59214
   111
atomtyp T2;
wneuper@59214
   112
(*
wneuper@59214
   113
*** Type (fun,[
wneuper@59214
   114
*** . Type (Real.real,[])
wneuper@59214
   115
*** . Type (fun,[
wneuper@59214
   116
*** . . Type (Real.real,[])
wneuper@59214
   117
*** . . Type (Real.real,[])
wneuper@59214
   118
*** . . ]
wneuper@59214
   119
*** . ]
walther@60242
   120
with this \<up> build the typ ...*)
wneuper@59214
   121
Type ("fun", [
wneuper@59214
   122
  Type ("Real.real", []), 
wneuper@59214
   123
  Type ("fun", [
wneuper@59214
   124
    Type ("Real.real", []), 
wneuper@59214
   125
    Type ("Real.real", [])])]);
wneuper@59214
   126
wneuper@59214
   127
atomtyp T1;
wneuper@59214
   128
(*
wneuper@59214
   129
*** Type (fun,[
wneuper@59214
   130
*** . Type (Real.real,[])
wneuper@59214
   131
*** . Type (fun,[
wneuper@59214
   132
*** . . Type (Real.real,[])
wneuper@59214
   133
*** . . Type (HOL.bool,[])
wneuper@59214
   134
*** . . ]
wneuper@59214
   135
*** . ]
walther@60242
   136
with this \<up> build the typ ...*)
wneuper@59214
   137
Type ("fun", [
wneuper@59214
   138
  Type ("Real.real", []), 
wneuper@59214
   139
  Type ("fun", [
wneuper@59214
   140
    Type ("Real.real", []), 
wneuper@59214
   141
    Type ("HOL.bool", [])])]);
wneuper@59214
   142
wneuper@59214
   143
(* now compose term + typ *)
wneuper@59214
   144
val Const ("HOL.eq", Type ("fun", [
wneuper@59214
   145
                       Type ("Real.real", []), 
wneuper@59214
   146
                       Type ("fun", [
wneuper@59214
   147
                         Type ("Real.real", []), 
wneuper@59214
   148
                         Type ("HOL.bool", [])])])) $
wneuper@59214
   149
     (Const ("Groups.plus_class.plus", Type ("fun", [
wneuper@59214
   150
                                         Type ("Real.real", []), 
wneuper@59214
   151
                                         Type ("fun", [
wneuper@59214
   152
                                           Type ("Real.real", []), 
wneuper@59214
   153
                                           Type ("Real.real", [])])])) $ 
wneuper@59214
   154
        Free ("aaa", Type ("Real.real", [])) $ 
wneuper@59214
   155
        Free ("bbb", Type ("Real.real", []))) $
wneuper@59214
   156
      Const ("processed_by_Isabelle_Isac", Type ("Real.real", [])) = ttt;
wneuper@59214
   157
wneuper@59214
   158
(* match out the original term from result*)
wneuper@59214
   159
val Const ("HOL.eq", Type ("fun", [
wneuper@59214
   160
                       Type ("Real.real", []), 
wneuper@59214
   161
                       Type ("fun", [
wneuper@59214
   162
                         Type ("Real.real", []), 
wneuper@59214
   163
                         Type ("HOL.bool", [])])])) $
wneuper@59214
   164
      t' $
wneuper@59214
   165
      Const ("processed_by_Isabelle_Isac", Type ("Real.real", [])) = ttt;
wneuper@59214
   166
if t = t' then () else error "something with test_term changed"