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 |
remove_thy"Simplify";
|
neuper@37947
|
6 |
use_thy"~/proto2/isac/src/sml/Knowledge/Simplify";
|
neuper@37906
|
7 |
|
neuper@37947
|
8 |
use_thy_only"~/proto2/isac/src/sml/Knowledge/Simplify";
|
neuper@37947
|
9 |
use_thy"~/proto2/isac/src/sml/Knowledge/Isac";
|
neuper@37906
|
10 |
*)
|
neuper@37906
|
11 |
|
neuper@37950
|
12 |
theory Simplify imports Atools begin
|
neuper@37906
|
13 |
|
neuper@37906
|
14 |
consts
|
neuper@37906
|
15 |
|
neuper@37906
|
16 |
(*descriptions in the related problem*)
|
neuper@37950
|
17 |
term :: "real => una"
|
neuper@37950
|
18 |
normalform :: "real => una"
|
neuper@37906
|
19 |
|
neuper@37906
|
20 |
(*the CAS-command*)
|
neuper@37906
|
21 |
Simplify :: "real => real" (*"Simplify (1+2a+3+4a)*)
|
neuper@37906
|
22 |
Vereinfache :: "real => real" (*"Vereinfache (1+2a+3+4a)*)
|
neuper@37906
|
23 |
|
neuper@37906
|
24 |
(*Script-name*)
|
neuper@37906
|
25 |
SimplifyScript :: "[real, real] => real"
|
neuper@37906
|
26 |
("((Script SimplifyScript (_ =))// (_))" 9)
|
neuper@37906
|
27 |
|
neuper@37950
|
28 |
ML {*
|
neuper@37950
|
29 |
|
neuper@37950
|
30 |
(** problems **)
|
neuper@37950
|
31 |
store_pbt
|
neuper@37950
|
32 |
(prep_pbt Simplify.thy "pbl_simp" [] e_pblID
|
neuper@37950
|
33 |
(["simplification"],
|
neuper@37950
|
34 |
[("#Given" ,["term t_"]),
|
neuper@37950
|
35 |
("#Find" ,["normalform n_"])
|
neuper@37950
|
36 |
],
|
neuper@37950
|
37 |
append_rls "e_rls" e_rls [(*for preds in where_*)],
|
neuper@37950
|
38 |
SOME "Simplify t_",
|
neuper@37950
|
39 |
[]));
|
neuper@37950
|
40 |
|
neuper@37950
|
41 |
store_pbt
|
neuper@37950
|
42 |
(prep_pbt Simplify.thy "pbl_vereinfache" [] e_pblID
|
neuper@37950
|
43 |
(["vereinfachen"],
|
neuper@37950
|
44 |
[("#Given" ,["term t_"]),
|
neuper@37950
|
45 |
("#Find" ,["normalform n_"])
|
neuper@37950
|
46 |
],
|
neuper@37950
|
47 |
append_rls "e_rls" e_rls [(*for preds in where_*)],
|
neuper@37950
|
48 |
SOME "Vereinfache t_",
|
neuper@37950
|
49 |
[]));
|
neuper@37950
|
50 |
|
neuper@37950
|
51 |
(** methods **)
|
neuper@37950
|
52 |
|
neuper@37950
|
53 |
store_met
|
neuper@37950
|
54 |
(prep_met Simplify.thy "met_simp" [] e_metID
|
neuper@37950
|
55 |
(["simplification"],
|
neuper@37950
|
56 |
[("#Given" ,["term t_"]),
|
neuper@37950
|
57 |
("#Find" ,["normalform n_"])
|
neuper@37950
|
58 |
],
|
neuper@37950
|
59 |
{rew_ord'="tless_true",
|
neuper@37950
|
60 |
rls'= e_rls,
|
neuper@37950
|
61 |
calc = [],
|
neuper@37950
|
62 |
srls = e_rls,
|
neuper@37950
|
63 |
prls=e_rls,
|
neuper@37950
|
64 |
crls = e_rls, nrls = e_rls},
|
neuper@37950
|
65 |
"empty_script"
|
neuper@37950
|
66 |
));
|
neuper@37950
|
67 |
|
neuper@37950
|
68 |
(** CAS-command **)
|
neuper@37950
|
69 |
|
neuper@37950
|
70 |
(*.function for handling the cas-input "Simplify (2*a + 3*a)":
|
neuper@37950
|
71 |
make a model which is already in ptree-internal format.*)
|
neuper@37950
|
72 |
(* val (h,argl) = strip_comb (str2term "Simplify (2*a + 3*a)");
|
neuper@37950
|
73 |
val (h,argl) = strip_comb ((term_of o the o (parse thy))
|
neuper@37950
|
74 |
"Simplify (2*a + 3*a)");
|
neuper@37950
|
75 |
*)
|
neuper@37950
|
76 |
fun argl2dtss t =
|
neuper@37950
|
77 |
[((term_of o the o (parse thy)) "term", t),
|
neuper@37950
|
78 |
((term_of o the o (parse thy)) "normalform",
|
neuper@37950
|
79 |
[(term_of o the o (parse thy)) "N"])
|
neuper@37950
|
80 |
]
|
neuper@37950
|
81 |
| argl2dtss _ = raise error "Simplify.ML: wrong argument for argl2dtss";
|
neuper@37950
|
82 |
|
neuper@37950
|
83 |
castab :=
|
neuper@37950
|
84 |
overwritel (!castab,
|
neuper@37950
|
85 |
[((term_of o the o (parse thy)) "Simplify",
|
neuper@37950
|
86 |
(("Isac.thy", ["simplification"], ["no_met"]),
|
neuper@37950
|
87 |
argl2dtss)),
|
neuper@37950
|
88 |
((term_of o the o (parse thy)) "Vereinfache",
|
neuper@37950
|
89 |
(("Isac.thy", ["vereinfachen"], ["no_met"]),
|
neuper@37950
|
90 |
argl2dtss))
|
neuper@37950
|
91 |
]);
|
neuper@37950
|
92 |
*}
|
neuper@37906
|
93 |
|
neuper@37906
|
94 |
end |