neuper@37906
|
1 |
(* simplification of terms
|
neuper@37906
|
2 |
author: Walther Neuper 050912
|
neuper@37906
|
3 |
(c) due to copyright terms
|
neuper@37906
|
4 |
*)
|
neuper@37906
|
5 |
|
wneuper@59424
|
6 |
theory Simplify imports Base_Tools begin
|
neuper@37906
|
7 |
|
neuper@37906
|
8 |
consts
|
neuper@37906
|
9 |
|
neuper@37906
|
10 |
(*descriptions in the related problem*)
|
neuper@38083
|
11 |
Term :: "real => una"
|
neuper@38083
|
12 |
(*TERM --> Const ("Pure.term", "RealDef.real => prop") (*!!!*) $
|
neuper@38083
|
13 |
Free ("ttt", "RealDef.real")
|
neuper@38083
|
14 |
term --> Free ("term", "RealDef.real => RealDef.real") $
|
neuper@38083
|
15 |
Free ("ttt", "RealDef.real")
|
neuper@38083
|
16 |
but 'term' is a keyword in *.thy*)
|
neuper@37950
|
17 |
normalform :: "real => una"
|
neuper@37906
|
18 |
|
neuper@37906
|
19 |
(*the CAS-command*)
|
neuper@37906
|
20 |
Simplify :: "real => real" (*"Simplify (1+2a+3+4a)*)
|
neuper@37906
|
21 |
Vereinfache :: "real => real" (*"Vereinfache (1+2a+3+4a)*)
|
neuper@37906
|
22 |
|
wneuper@59472
|
23 |
ML \<open>
|
neuper@37972
|
24 |
val thy = @{theory};
|
wneuper@59472
|
25 |
\<close>
|
neuper@37950
|
26 |
(** problems **)
|
wneuper@59472
|
27 |
setup \<open>KEStore_Elems.add_pbts
|
walther@59973
|
28 |
[(Problem.prep_input thy "pbl_simp" [] Problem.id_empty
|
s1210629013@55339
|
29 |
(["simplification"],
|
s1210629013@55339
|
30 |
[("#Given" ,["Term t_t"]),
|
s1210629013@55339
|
31 |
("#Find" ,["normalform n_n"])],
|
walther@59852
|
32 |
Rule_Set.append_rules "empty" Rule_Set.empty [(*for preds in where_*)], SOME "Simplify t_t", [])),
|
walther@59973
|
33 |
(Problem.prep_input thy "pbl_vereinfache" [] Problem.id_empty
|
s1210629013@55339
|
34 |
(["vereinfachen"],
|
s1210629013@55339
|
35 |
[("#Given", ["Term t_t"]),
|
s1210629013@55339
|
36 |
("#Find", ["normalform n_n"])],
|
walther@59852
|
37 |
Rule_Set.append_rules "empty" Rule_Set.empty [(*for preds in where_*)], SOME "Vereinfache t_t", []))]\<close>
|
neuper@37950
|
38 |
|
neuper@37950
|
39 |
(** methods **)
|
wneuper@59472
|
40 |
setup \<open>KEStore_Elems.add_mets
|
walther@60154
|
41 |
[MethodC.prep_input thy "met_tsimp" [] MethodC.id_empty
|
s1210629013@55373
|
42 |
(["simplification"],
|
s1210629013@55373
|
43 |
[("#Given" ,["Term t_t"]),
|
s1210629013@55373
|
44 |
("#Find" ,["normalform n_n"])],
|
walther@59852
|
45 |
{rew_ord'="tless_true", rls'= Rule_Set.empty, calc = [], srls = Rule_Set.empty, prls=Rule_Set.empty, crls = Rule_Set.empty,
|
walther@59852
|
46 |
errpats = [], nrls = Rule_Set.empty},
|
wneuper@59545
|
47 |
@{thm refl})]
|
wneuper@59472
|
48 |
\<close>
|
s1210629013@55373
|
49 |
|
wneuper@59472
|
50 |
ML \<open>
|
neuper@37950
|
51 |
|
neuper@37950
|
52 |
(** CAS-command **)
|
neuper@37950
|
53 |
|
neuper@37950
|
54 |
(*.function for handling the cas-input "Simplify (2*a + 3*a)":
|
wneuper@59279
|
55 |
make a model which is already in ctree-internal format.*)
|
neuper@37950
|
56 |
(* val (h,argl) = strip_comb (str2term "Simplify (2*a + 3*a)");
|
wneuper@59352
|
57 |
val (h,argl) = strip_comb ((Thm.term_of o the o (parse (Thy_Info_get_theory "Simplify")))
|
neuper@37950
|
58 |
"Simplify (2*a + 3*a)");
|
neuper@37950
|
59 |
*)
|
neuper@37950
|
60 |
fun argl2dtss t =
|
wneuper@59389
|
61 |
[((Thm.term_of o the o (TermC.parse thy)) "Term", t),
|
wneuper@59389
|
62 |
((Thm.term_of o the o (TermC.parse thy)) "normalform",
|
wneuper@59389
|
63 |
[(Thm.term_of o the o (TermC.parse thy)) "N"])
|
neuper@37950
|
64 |
]
|
walther@59962
|
65 |
(*| argl2dtss _ = raise ERROR "Simplify.ML: wrong argument for argl2dtss"*);
|
wneuper@59472
|
66 |
\<close>
|
wneuper@59472
|
67 |
setup \<open>KEStore_Elems.add_cas
|
wneuper@59389
|
68 |
[((Thm.term_of o the o (TermC.parse thy)) "Simplify",
|
wneuper@59592
|
69 |
(("Isac_Knowledge", ["simplification"], ["no_met"]), argl2dtss)),
|
wneuper@59389
|
70 |
((Thm.term_of o the o (TermC.parse thy)) "Vereinfache",
|
wneuper@59592
|
71 |
(("Isac_Knowledge", ["vereinfachen"], ["no_met"]), argl2dtss))]\<close>
|
neuper@37906
|
72 |
|
neuper@37906
|
73 |
end |