1 (* Title: tests for mathml.sml
2 Author: Walther Neuper 060311
5 "-----------------------------------------------------------------";
6 "table of contents -----------------------------------------------";
7 "-----------------------------------------------------------------";
8 "within struct ---------------------------------------------------";
9 "-----------------------------------------------------------------";
10 "--------- encode \<up> -> ^ ---------------------------------------";
11 "--------- encode < -> < and > -> > --------------------------";
12 "--------- fun rm_doublets '-4 * b \<up>\<up>\<up> 2 / (...' -----------";
13 "--------- fun decode '-4 * b \<up>\<up>\<up> 2 / (...' ----------------";
14 "--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
15 "--------- create testdata for TestPIDE.java#testTermTransfer ----";
16 "-----------------------------------------------------------------";
17 "exported from struct --------------------------------------------";
18 "-----------------------------------------------------------------";
19 "--------- ... ---------------------------------------------------";
20 "-----------------------------------------------------------------";
24 "-----------------------------------------------------------------";
25 "within struct ---------------------------------------------------";
26 "-----------------------------------------------------------------";
27 (*==================================================================*)
29 "--------- encode \<up> -> ^ ---------------------------------------";
30 "--------- encode \<up> -> ^ ---------------------------------------";
31 "--------- encode \<up> -> ^ ---------------------------------------";
32 val str = "a\<up>2+b\<up>2=c\<up>2";
33 if decode str = "a\<up>2+b\<up>2=c\<up>2" then ()
34 else error "mathml.sml: diff.behav. in encode \<up> -> ^";
36 "--------- encode < -> < and > -> > --------------------------";
37 "--------- encode < -> < and > -> > --------------------------";
38 "--------- encode < -> < and > -> > --------------------------";
39 val str = "?bdv occurs_in ?b; 0 < ?n |] ==> ?a / ?b \<up> ?n = ?a * ?b \<up> - ?n";
40 if decode str = "?bdv occurs_in ?b; 0 < ?n |] ==> ?a / ?b \<up> ?n = ?a * ?b \<up> - ?n" then ()
41 else error "mathml.sml: diff.behav. in encode '<' and '>'";
43 (*========== inhibit exn AK110725 ================================================
44 "----- check 'manually' the xml-output of calling functions ------";
45 formula2xml 1 (TermC.str2term str);
48 (*TermC.str2term str; (* ERROR: Inner syntax error at "; 0 < ?n |] ==> ?a / ?b \<up> ?n = ?a * ?b \<up> - ?n"
49 Failed to TermC.parse term*)*)
50 "~~~~~ fun TermC.str2term, args:"; val (str) = (str);
51 ThyC.get_theory "Isac_Knowledge";
54 TermC.parse_patt (ThyC.get_theory "Isac_Knowledge");
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"
56 Failed to TermC.parse term*)*)
58 "~~~~~ fun TermC.parse_patt, args:"; val (thy, str) = ((ThyC.get_theory "Isac_Knowledge"), str);
61 (*|-> Proof_Context.read_term_pattern (*ERROR: Inner syntax error at "; 0 < ?n |] ==> ?a / ?b \<up> ?n = ?a * ?b \<up> - ?n"
62 Failed to TermC.parse term*)*)
64 Proof_Context.read_term_pattern;
65 (@{theory "Isac_Knowledge"}, str) |>> ThyC.to_ctxt;
66 "~~~~~ fun Proof_Context.read_term_pattern, args:"; val () = ();
67 (*AK110725 To be continued...*)
69 (*==================================================================*)
70 "-----------------------------------------------------------------";
71 "exported from struct --------------------------------------------";
72 "-----------------------------------------------------------------";
73 ========== inhibit exn AK110725 ================================================*)
75 "--------- fun xmlstr --------------------------------------------";
76 "--------- fun xmlstr --------------------------------------------";
77 "--------- fun xmlstr --------------------------------------------";
78 val term = @{term "aaa + bbb::real"};
79 val str = term |> xml_of_term_NEW |> xmlstr 0;
81 "(FORMULA)\n. (ISA)\n. . aaa + bbb\n. (/ISA)\n. (TERM)\n aaa + bbb\n(/TERM)\n(/FORMULA)\n"
82 then () else error "term |> xml_of_term_NEW |> xmlstr ..changed";
85 "--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
86 "--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
87 "--------- fun xml_of_term_NEW, xml_to_term_NEW ------------------";
88 (* xml_of_term_NEW o xml_to_term_NEW = id ... not valid,
89 as long as the latter (going: frontend \<longrightarrow> kernel) does only carry "ISA" string.
90 val t = @{term "aaa + bbb::real"};
91 if t = (t |> xml_of_term_NEW |> xml_to_term_NEW) then ()
92 else error "xml_of_term_NEW |> xml_to_term_NEW changed"
95 "--------- create testdata for TestPIDE.java#testTermTransfer ----";
96 "--------- create testdata for TestPIDE.java#testTermTransfer ----";
97 "--------- create testdata for TestPIDE.java#testTermTransfer ----";
98 val t = @{term "aaa + bbb::real"};
99 val ttt = HOLogic.mk_eq (t, Const ("processed_by_Isabelle_Isac", type_of t))
100 (* check the term structure *)
101 val Const ("HOL.eq", T1) $
102 (Const ("Groups.plus_class.plus", T2) $
105 Const ("processed_by_Isabelle_Isac", _) = ttt;
107 (* check the type structure *)
109 Type ("Real.real", []);
114 *** . Type (Real.real,[])
116 *** . . Type (Real.real,[])
117 *** . . Type (Real.real,[])
120 with this \<up> build the typ ...*)
122 Type ("Real.real", []),
124 Type ("Real.real", []),
125 Type ("Real.real", [])])]);
130 *** . Type (Real.real,[])
132 *** . . Type (Real.real,[])
133 *** . . Type (HOL.bool,[])
136 with this \<up> build the typ ...*)
138 Type ("Real.real", []),
140 Type ("Real.real", []),
141 Type ("HOL.bool", [])])]);
143 (* now compose term + typ *)
144 val Const ("HOL.eq", Type ("fun", [
145 Type ("Real.real", []),
147 Type ("Real.real", []),
148 Type ("HOL.bool", [])])])) $
149 (Const ("Groups.plus_class.plus", Type ("fun", [
150 Type ("Real.real", []),
152 Type ("Real.real", []),
153 Type ("Real.real", [])])])) $
154 Free ("aaa", Type ("Real.real", [])) $
155 Free ("bbb", Type ("Real.real", []))) $
156 Const ("processed_by_Isabelle_Isac", Type ("Real.real", [])) = ttt;
158 (* match out the original term from result*)
159 val Const ("HOL.eq", Type ("fun", [
160 Type ("Real.real", []),
162 Type ("Real.real", []),
163 Type ("HOL.bool", [])])])) $
165 Const ("processed_by_Isabelle_Isac", Type ("Real.real", [])) = ttt;
166 if t = t' then () else error "something with test_term changed"