neuper@48895
|
1 |
(* theory collecting all knowledge defined for the isac mathengine
|
neuper@42400
|
2 |
WN.11.00
|
neuper@42400
|
3 |
*)
|
neuper@42400
|
4 |
|
neuper@42400
|
5 |
theory Build_Thydata
|
neuper@55460
|
6 |
imports
|
neuper@55460
|
7 |
Isac "~~/src/Tools/isac/Interpret/Interpret"
|
neuper@55408
|
8 |
Test_Build_Thydata (*for test/../build_thydata.sml, thy_hierarchy.sml*)
|
neuper@42400
|
9 |
begin
|
neuper@42400
|
10 |
|
neuper@55405
|
11 |
subsection {* Build <Theory>-Data *}
|
neuper@55405
|
12 |
text {*
|
neuper@55405
|
13 |
<Theory>-Data represent Isac's "deductive knowledge" (whereas <Problems> and <Methods>
|
neuper@55405
|
14 |
represent application-oriented and algorithmic knowledge respectively.) <Theory>-Data
|
neuper@55405
|
15 |
comprise theories from ProgLang and from Knowledge.
|
neuper@55405
|
16 |
Note, that for bootstrapping Isac "Build_Thydata" theories are available only
|
wneuper@59352
|
17 |
via "@{theory Pure}" and "Theory.ancestors_of" but not via "Thy_Info_get_theory"
|
neuper@55405
|
18 |
(while the latter is available in Test_Some.thy loaded from session Isac).
|
neuper@55405
|
19 |
*}
|
neuper@55405
|
20 |
subsubsection {* Get and group the theories defined in Isac *}
|
neuper@42400
|
21 |
ML {*
|
neuper@55456
|
22 |
(* we don't use "fun isacthys ()" etc HERE,
|
neuper@55456
|
23 |
because Thy_Info.get_theory only works with session Isac, not with Build_Isac.thy *)
|
neuper@55405
|
24 |
val knowledge_parent = @{theory}
|
neuper@55405
|
25 |
val proglang_parent = @{theory ProgLang}
|
neuper@42400
|
26 |
|
neuper@55405
|
27 |
val allthys = Theory.ancestors_of @{theory};
|
wneuper@59335
|
28 |
val allthys = filter_out (member Context.eq_thy (* thys for isac bootstrap *)
|
neuper@55405
|
29 |
[(*@{theory ProgLang}: required in isacthys' below*) @{theory Interpret}, @{theory xmlsrc},
|
wneuper@59396
|
30 |
@{theory Frontend}, knowledge_parent]) allthys (*["Isac", ..., "Isac"]*)
|
neuper@42400
|
31 |
|
wneuper@59396
|
32 |
val isabthys' = (*["Complex_Main", "Taylor", .., "Isac"]*)
|
wneuper@59335
|
33 |
drop ((find_index (curry Context.eq_thy @{theory Complex_Main}) allthys), allthys);
|
neuper@55405
|
34 |
val isacthys' = (*["Isac", "Inverse_Z_Transform", .., "KEStore"]*)
|
wneuper@59335
|
35 |
take ((find_index (curry Context.eq_thy @{theory Complex_Main}) allthys), allthys);
|
neuper@42400
|
36 |
|
neuper@55405
|
37 |
val knowthys' = (*["Isac", .., "Descript", "Delete"]*)
|
wneuper@59335
|
38 |
take ((find_index (curry Context.eq_thy proglang_parent) isacthys'), isacthys');
|
neuper@55405
|
39 |
val progthys' = (*["Script", "Tools", "ListC", "KEStore"]*)
|
wneuper@59335
|
40 |
drop ((find_index (curry Context.eq_thy proglang_parent) isacthys') + 1(*ProgLang*), isacthys');
|
neuper@55405
|
41 |
*}
|
neuper@42400
|
42 |
|
neuper@55405
|
43 |
subsubsection {* From rule-sets collect theorems, which have been taken from Isabelle *}
|
neuper@55405
|
44 |
ML {*
|
neuper@55484
|
45 |
val isacrlsthms = (*length = 460*)
|
wneuper@59406
|
46 |
thms_of_rlss @{theory} (KEStore_Elems.get_rlss knowledge_parent) : (Celem.thmID * thm) list
|
neuper@42400
|
47 |
|
neuper@55484
|
48 |
val rlsthmsNOTisac = isacrlsthms (*length = 36*)
|
neuper@55405
|
49 |
|> filter (fn (deriv, _) =>
|
wneuper@59406
|
50 |
member op= (map Context.theory_name isabthys') (Celem.thyID_of_derivation_name deriv))
|
wneuper@59406
|
51 |
: (Celem.thmID * thm) list
|
neuper@55405
|
52 |
*}
|
neuper@55405
|
53 |
|
neuper@55405
|
54 |
subsubsection {* Collect data in a (key, data) list and insert data into the tree *}
|
neuper@55405
|
55 |
text {*
|
neuper@55405
|
56 |
The sequence in the (key, data) list is arbitrary, because insertion using the key
|
neuper@55405
|
57 |
is random. The sequence of the root nodes "IsacKnowledge", "Isabelle"
|
neuper@55405
|
58 |
and "IsacScripts" is determined in KEStore.thy.
|
neuper@55405
|
59 |
*}
|
neuper@55405
|
60 |
ML {*
|
neuper@55406
|
61 |
val thydata_list =
|
neuper@55405
|
62 |
collect_part "IsacKnowledge" knowledge_parent knowthys' @
|
neuper@55405
|
63 |
(map (collect_isab "Isabelle") rlsthmsNOTisac) @
|
neuper@55405
|
64 |
collect_part "IsacScripts" proglang_parent progthys'
|
wneuper@59406
|
65 |
: (Celem.theID * Celem.thydata) list
|
neuper@55435
|
66 |
*}
|
neuper@55490
|
67 |
setup {* KEStore_Elems.add_thes (map (fn (a, b) => (b, a)) thydata_list) *}
|
neuper@42429
|
68 |
|
neuper@55405
|
69 |
section {* interface for dialog-authoring *}
|
neuper@55411
|
70 |
subsection {* Add error patterns *}
|
neuper@55411
|
71 |
subsubsection {* Error patterns for differentiation *}
|
neuper@55411
|
72 |
|
s1210629013@55378
|
73 |
setup {* KEStore_Elems.add_mets
|
s1210629013@55442
|
74 |
[update_metpair @{theory Diff} ["diff","differentiate_on_R"]
|
s1210629013@55378
|
75 |
[("chain-rule-diff-both",
|
wneuper@59390
|
76 |
[TermC.parse_patt @{theory Diff} "d_d ?bdv (sin ?u) = cos (d_d ?bdv ?u)",
|
wneuper@59390
|
77 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (cos ?u) = - sin (d_d ?bdv ?u)",
|
wneuper@59390
|
78 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (?u ^^^ ?n) = ?n * ?u ^^^ (?n - 1)",
|
wneuper@59390
|
79 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (LogExp.ln ?u) = 1 / ?u",
|
wneuper@59390
|
80 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (LogExp.ln ?u) = 1 / d_d ?bdv ?u"],
|
s1210629013@55378
|
81 |
[@{thm diff_sin_chain}, @{thm diff_cos_chain}, @{thm diff_pow_chain}, @{thm diff_ln_chain},
|
s1210629013@55378
|
82 |
@{thm diff_exp_chain}])]]
|
s1210629013@55378
|
83 |
*}
|
neuper@42453
|
84 |
|
neuper@55425
|
85 |
setup {*
|
neuper@55448
|
86 |
KEStore_Elems.insert_fillpats
|
neuper@55448
|
87 |
[(["IsacKnowledge", "Diff", "Theorems", "diff_sin_chain"],
|
neuper@55425
|
88 |
([("fill-d_d-arg",
|
wneuper@59390
|
89 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (sin ?u) = cos ?u * d_d ?bdv _", "chain-rule-diff-both"),
|
neuper@55425
|
90 |
("fill-both-args",
|
wneuper@59390
|
91 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (sin _) = cos ?u * d_d ?bdv _", "chain-rule-diff-both"),
|
neuper@55425
|
92 |
("fill-d_d",
|
wneuper@59390
|
93 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (sin ?u) = cos ?u * _ ?bdv ?u", "chain-rule-diff-both"),
|
neuper@55425
|
94 |
("fill-inner-deriv",
|
wneuper@59390
|
95 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (sin ?u) = cos ?u * _", "chain-rule-diff-both"),
|
neuper@55425
|
96 |
("fill-all",
|
wneuper@59406
|
97 |
TermC.parse_patt @{theory Diff} "d_d ?bdv (sin ?u) = _", "chain-rule-diff-both")]: Celem.fillpat list))
|
neuper@55425
|
98 |
]
|
neuper@55425
|
99 |
*}
|
neuper@55411
|
100 |
|
neuper@55411
|
101 |
subsubsection {* Error patterns for calculation with rationals *}
|
neuper@55411
|
102 |
|
s1210629013@55378
|
103 |
setup {* KEStore_Elems.add_mets
|
s1210629013@55442
|
104 |
[update_metpair @{theory Rational} ["simplification", "of_rationals"]
|
s1210629013@55378
|
105 |
[("addition-of-fractions",
|
wneuper@59390
|
106 |
[TermC.parse_patt @{theory Rational} "(?a / ?b + ?c / ?d) = (?a + ?c)/(?b + ?d)",
|
wneuper@59390
|
107 |
TermC.parse_patt @{theory Rational} "(?a / ?b + ?c / ?d) = (?a + ?c)/(?b * ?d)",
|
wneuper@59390
|
108 |
TermC.parse_patt @{theory Rational} "(?a / ?b + ?c / ?d) = (?c * ?a)/(?d * ?b)",
|
wneuper@59390
|
109 |
TermC.parse_patt @{theory Rational} "?a + (?b /?c)= (?a + ?b)/ ?c",
|
wneuper@59390
|
110 |
TermC.parse_patt @{theory Rational} "?a + (?b /?c)= (?a * ?b)/ ?c"],
|
s1210629013@55378
|
111 |
[@{thm rat_add}, @{thm rat_add_assoc}, @{thm rat_add1}, @{thm rat_add1_assoc},
|
s1210629013@55378
|
112 |
@{thm rat_add2}, @{thm rat_add2_assoc}, @{thm rat_add3}, @{thm rat_add3_assoc}])]]
|
s1210629013@55378
|
113 |
*}
|
neuper@42516
|
114 |
|
s1210629013@55378
|
115 |
ML {*
|
neuper@42516
|
116 |
(*TODO insert_fillpats ["IsacKnowledge", "Rational", "Theorems", "???"]*)
|
neuper@42516
|
117 |
|
neuper@42516
|
118 |
(* TODO insert_errpats overwrites instead of appending
|
neuper@42516
|
119 |
insert_errpats ["simplification","of_rationals"]
|
neuper@42516
|
120 |
(("cancel", (*see master thesis gdarocy*)
|
neuper@48895
|
121 |
[(*a*)parse_patt @{theory Rational} "(?a + ?b)/?a = ?b",
|
neuper@48895
|
122 |
(*b*)parse_patt @{theory Rational} "(?a + ?b)/?b = ?a",
|
neuper@48895
|
123 |
(*c*)parse_patt @{theory Rational} "(?a + ?b)/(?b + ?c) = ?a / ?c",
|
neuper@48895
|
124 |
(*d*)parse_patt @{theory Rational} "(?a + ?c)/(?b + ?c) = ?a / ?b",
|
neuper@48895
|
125 |
(*e*)parse_patt @{theory Rational} "(?a + ?c)/(?b + ?c) = ?a / ?c",
|
neuper@48895
|
126 |
(*f*)parse_patt @{theory Rational} "(?a + ?b)/(?c + ?a) = ?b / ?c",
|
neuper@48895
|
127 |
(*g*)parse_patt @{theory Rational} "(?a*?b + ?c)/?a = ?b + ?c",
|
neuper@48895
|
128 |
(*h*)parse_patt @{theory Rational} "(?a*?b + ?c)/?b = ?a + ?c",
|
neuper@48895
|
129 |
(*i*)parse_patt @{theory Rational} "(?a + ?b*?c)/?b = ?a + ?c",
|
neuper@48895
|
130 |
(*j*)parse_patt @{theory Rational} "(?a + ?b*?c)/?b = ?a + ?b",
|
neuper@48895
|
131 |
(*k*)parse_patt @{theory Rational} "(?a + ?b*?e)/(?c + ?d*?e) = (?a + ?b)/(?c + ?d)"],
|
neuper@42516
|
132 |
[@{thm real_times_divide_1_eq}, (*TODO*) @{thm real_times_divide_1_eq}]));
|
neuper@42516
|
133 |
|
neuper@42445
|
134 |
val fillpats = [
|
neuper@42445
|
135 |
("fill-cancel-left-num",
|
neuper@42445
|
136 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * ?c) = _ / ?c", "cancel"),
|
neuper@42445
|
137 |
("fill-cancel-left-den",
|
neuper@42445
|
138 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * ?c) = ?b / _", "cancel"),
|
neuper@42445
|
139 |
("fill-cancel-none",
|
neuper@42445
|
140 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * ?c) = ?b / ?c", "cancel"),
|
neuper@42445
|
141 |
|
neuper@42445
|
142 |
("fill-cancel-left-add-num1",
|
neuper@42445
|
143 |
parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * ?d) = (_ + ?c) / ?d", "cancel"),
|
neuper@42445
|
144 |
("fill-cancel-left-add-num2",
|
neuper@42445
|
145 |
parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * ?d) = (?b + _) / ?d", "cancel"),
|
neuper@42445
|
146 |
("fill-cancel-left-add-num3",
|
neuper@42445
|
147 |
parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * ?d) = (_ + _) / ?d", "cancel"),
|
neuper@42445
|
148 |
("fill-cancel-left-add-num4",
|
neuper@42445
|
149 |
parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * ?d) = (?b + ?c) / _", "cancel"),
|
neuper@42445
|
150 |
("fill-cancel-left-add-num5",
|
neuper@42445
|
151 |
parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * ?d) = (_ + ?c) / _", "cancel"),
|
neuper@42445
|
152 |
("fill-cancel-left-add-num6",
|
neuper@42445
|
153 |
parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * ?d) = (?b + _) / _", "cancel"),
|
neuper@42445
|
154 |
("fill-cancel-left-add-none",
|
neuper@42445
|
155 |
parse_patt @{theory Rational} "(?a * (?b + ?c)) / (?a * ?d) = (?b + ?c) / ?d", "cancel"),
|
neuper@42445
|
156 |
|
neuper@42445
|
157 |
("fill-cancel-left-add-den1",
|
neuper@42445
|
158 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * (?c + ?d)) = ?b / (?c + ?d)", "cancel"),
|
neuper@42445
|
159 |
("fill-cancel-left-add-den2",
|
neuper@42445
|
160 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * (?c + ?d)) = ?b / (?c + ?d)", "cancel"),
|
neuper@42445
|
161 |
("fill-cancel-left-add-den3",
|
neuper@42445
|
162 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * (?c + ?d)) = ?b / (?c + ?d)", "cancel"),
|
neuper@42445
|
163 |
("fill-cancel-left-add-den4",
|
neuper@42445
|
164 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * (?c + ?d)) = ?b / (?c + ?d)", "cancel"),
|
neuper@42445
|
165 |
("fill-cancel-left-add-den5",
|
neuper@42445
|
166 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * (?c + ?d)) = ?b / (?c + ?d)", "cancel"),
|
neuper@42445
|
167 |
("fill-cancel-left-add-den6",
|
neuper@42445
|
168 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * (?c + ?d)) = ?b / (?c + ?d)", "cancel"),
|
neuper@42445
|
169 |
("fill-cancel-left-add-none",
|
neuper@42445
|
170 |
parse_patt @{theory Rational} "(?a * ?b) / (?a * (?c + ?d)) = ?b / (?c + ?d)", "cancel")
|
neuper@42445
|
171 |
]: fillpat list;
|
neuper@42445
|
172 |
*)
|
neuper@42445
|
173 |
|
neuper@55462
|
174 |
(* still ununsed; planned for stepToErrorpattern: this is just a reminder...
|
neuper@55435
|
175 |
|
s1210629013@55442
|
176 |
insert_errpatIDs @{theory} ["IsacKnowledge", "Diff", "Rulesets", "norm_diff"]
|
neuper@42454
|
177 |
(["chain-rule-diff-both", "cancel"]: errpatID list);
|
neuper@55462
|
178 |
[[[ERROR *** app_py: not found: ["IsacKnowledge","Diff","Rulesets","norm_diff"]
|
neuper@55462
|
179 |
since KEStore_Elems.set_ref_thy has been shifted below;
|
neuper@55462
|
180 |
this ERROR will vanish during re-engineering towards KEStore_Elems.]]]
|
neuper@42453
|
181 |
|
neuper@55462
|
182 |
...and all other related rls by hand;
|
neuper@42453
|
183 |
TODO: lift errpattIDs from theorems to respective rls AUTOMATICALLY *)
|
neuper@42400
|
184 |
*}
|
neuper@48886
|
185 |
|
neuper@55411
|
186 |
subsection {* Generate XML representation from SML (data in KEStore) *}
|
neuper@55411
|
187 |
text {*
|
neuper@55411
|
188 |
See the wiki
|
neuper@55411
|
189 |
http://www.ist.tugraz.at/isac/Generate_representations_for_ISAC_Knowledge#Step_1:_Generate_XML_representation_from_SML
|
neuper@55411
|
190 |
|
neuper@55411
|
191 |
val path = "/tmp/xmldata/";
|
neuper@55411
|
192 |
thy_hierarchy2file (path ^ "thy/");
|
neuper@55411
|
193 |
thes2file (path ^ "thy/");
|
neuper@55411
|
194 |
pbl_hierarchy2file (path ^ "pbl/");
|
neuper@55411
|
195 |
pbls2file (path ^ "pbl/");
|
neuper@55411
|
196 |
met_hierarchy2file (path ^ "met/");
|
neuper@55411
|
197 |
mets2file (path ^ "met/");
|
neuper@55411
|
198 |
|
neuper@55411
|
199 |
Adjust ''val path'' (for details see wiki) and copy line for line
|
neuper@55493
|
200 |
into an ML-block.
|
neuper@55493
|
201 |
Scroll down the Output window and look for potential error messages.
|
neuper@55411
|
202 |
*}
|
neuper@55455
|
203 |
|
neuper@55455
|
204 |
section {* Link KEStore_Elems to completed IsacKnowledge *}
|
neuper@55455
|
205 |
ML {* KEStore_Elems.set_ref_thy @{theory} *}
|
neuper@55435
|
206 |
|
neuper@42400
|
207 |
end
|