test/Tools/isac/BridgeLibisabelle/mathml.sml
author wneuper <Walther.Neuper@jku.at>
Wed, 11 Jan 2023 11:38:01 +0100
changeset 60650 06ec8abfd3bc
parent 60309 70a1d102660d
permissions -rw-r--r--
eliminate use of Thy_Info 12: TermC partially
     1 (* Title: tests for mathml.sml
     2    Author: Walther Neuper 060311
     3    (c) isac-team 2006
     4 *)
     5 "-----------------------------------------------------------------";
     6 "table of contents -----------------------------------------------";
     7 "-----------------------------------------------------------------";
     8 "within struct ---------------------------------------------------";
     9 "-----------------------------------------------------------------";
    10 "--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
    11 "--------- create testdata for TestPIDE.java#testTermTransfer ----";
    12 "-----------------------------------------------------------------";
    13 "exported from struct --------------------------------------------";
    14 "-----------------------------------------------------------------";
    15 "--------- ... ---------------------------------------------------";
    16 "-----------------------------------------------------------------";
    17 
    18 
    19 
    20 "-----------------------------------------------------------------";
    21 "within struct ---------------------------------------------------";
    22 "-----------------------------------------------------------------";
    23 (*==================================================================*)
    24 
    25 
    26 "--------- fun xmlstr --------------------------------------------";
    27 "--------- fun xmlstr --------------------------------------------";
    28 "--------- fun xmlstr --------------------------------------------";
    29 val term = @{term "aaa + bbb::real"};
    30 val str = term |> xml_of_term_NEW |> xmlstr 0;
    31 if str =
    32 "(FORMULA)\n. (ISA)\n. . aaa + bbb\n. (/ISA)\n. (TERM)\n aaa + bbb\n(/TERM)\n(/FORMULA)\n"
    33 then () else error "term |> xml_of_term_NEW |> xmlstr ..changed";
    34 writeln str;
    35 
    36 "--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
    37 "--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
    38 "--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
    39 (* xml_of_term_NEW o xml_to_term_NEW = id ... not valid, 
    40   as long as the latter (going: frontend \<longrightarrow> kernel) does only carry "ISA" string.
    41 val t = @{term "aaa + bbb::real"};
    42 if t = (t |> xml_of_term_NEW |> xml_to_term_NEW) then ()
    43 else error "xml_of_term_NEW |> xml_to_term_NEW changed"
    44 *)
    45 
    46 "--------- create testdata for TestPIDE.java#testTermTransfer ----";
    47 "--------- create testdata for TestPIDE.java#testTermTransfer ----";
    48 "--------- create testdata for TestPIDE.java#testTermTransfer ----";
    49 val t = @{term "aaa + bbb::real"};
    50 val ttt = HOLogic.mk_eq (t, Const ("processed_by_Isabelle_Isac", type_of t))
    51 (* check the term structure *)
    52 val Const (\<^const_name>\<open>HOL.eq\<close>, T1) $
    53      (Const (\<^const_name>\<open>plus\<close>, T2) $ 
    54         Free ("aaa", T3) $ 
    55         Free ("bbb", _)) $
    56       Const ("processed_by_Isabelle_Isac", _) = ttt;
    57 
    58 (* check the type structure *)
    59 TermC.atom_typ @{context} T3;
    60 Type (\<^type_name>\<open>real\<close>, []);
    61 
    62 TermC.atom_typ @{context} T2;
    63 (*
    64 *** Type (fun,[
    65 *** . Type (Real.real,[])
    66 *** . Type (fun,[
    67 *** . . Type (Real.real,[])
    68 *** . . Type (Real.real,[])
    69 *** . . ]
    70 *** . ]
    71 with this \<up> build the typ ...*)
    72 Type (\<^type_name>\<open>fun\<close>, [
    73   Type (\<^type_name>\<open>real\<close>, []), 
    74   Type (\<^type_name>\<open>fun\<close>, [
    75     Type (\<^type_name>\<open>real\<close>, []), 
    76     Type (\<^type_name>\<open>real\<close>, [])])]);
    77 
    78 TermC.atom_typ @{context} T1;
    79 (*
    80 *** Type (fun,[
    81 *** . Type (Real.real,[])
    82 *** . Type (fun,[
    83 *** . . Type (Real.real,[])
    84 *** . . Type (HOL.bool,[])
    85 *** . . ]
    86 *** . ]
    87 with this \<up> build the typ ...*)
    88 Type (\<^type_name>\<open>fun\<close>, [
    89   Type (\<^type_name>\<open>real\<close>, []), 
    90   Type (\<^type_name>\<open>fun\<close>, [
    91     Type (\<^type_name>\<open>real\<close>, []), 
    92     Type (\<^type_name>\<open>bool\<close>, [])])]);
    93 
    94 (* now compose term + typ *)
    95 val Const (\<^const_name>\<open>HOL.eq\<close>, Type (\<^type_name>\<open>fun\<close>, [
    96                        Type (\<^type_name>\<open>real\<close>, []), 
    97                        Type (\<^type_name>\<open>fun\<close>, [
    98                          Type (\<^type_name>\<open>real\<close>, []), 
    99                          Type (\<^type_name>\<open>bool\<close>, [])])])) $
   100      (Const (\<^const_name>\<open>plus\<close>, Type (\<^type_name>\<open>fun\<close>, [
   101                                          Type (\<^type_name>\<open>real\<close>, []), 
   102                                          Type (\<^type_name>\<open>fun\<close>, [
   103                                            Type (\<^type_name>\<open>real\<close>, []), 
   104                                            Type (\<^type_name>\<open>real\<close>, [])])])) $ 
   105         Free ("aaa", Type (\<^type_name>\<open>real\<close>, [])) $ 
   106         Free ("bbb", Type (\<^type_name>\<open>real\<close>, []))) $
   107       Const ("processed_by_Isabelle_Isac", Type (\<^type_name>\<open>real\<close>, [])) = ttt;
   108 
   109 (* match out the original term from result*)
   110 val Const (\<^const_name>\<open>HOL.eq\<close>, Type (\<^type_name>\<open>fun\<close>, [
   111                        Type (\<^type_name>\<open>real\<close>, []), 
   112                        Type (\<^type_name>\<open>fun\<close>, [
   113                          Type (\<^type_name>\<open>real\<close>, []), 
   114                          Type (\<^type_name>\<open>bool\<close>, [])])])) $
   115       t' $
   116       Const ("processed_by_Isabelle_Isac", Type (\<^type_name>\<open>real\<close>, [])) = ttt;
   117 if t = t' then () else error "something with test_term changed"