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 |
|
neuper@37950
|
6 |
theory Simplify imports Atools 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 |
|
neuper@37906
|
23 |
(*Script-name*)
|
neuper@37906
|
24 |
SimplifyScript :: "[real, real] => real"
|
neuper@37906
|
25 |
("((Script SimplifyScript (_ =))// (_))" 9)
|
neuper@37906
|
26 |
|
neuper@37950
|
27 |
ML {*
|
neuper@37972
|
28 |
val thy = @{theory};
|
neuper@37950
|
29 |
|
neuper@37950
|
30 |
(** problems **)
|
neuper@37950
|
31 |
store_pbt
|
neuper@37972
|
32 |
(prep_pbt thy "pbl_simp" [] e_pblID
|
neuper@37950
|
33 |
(["simplification"],
|
neuper@38083
|
34 |
[("#Given" ,["Term t_t"]),
|
neuper@37968
|
35 |
("#Find" ,["normalform n_n"])
|
neuper@37950
|
36 |
],
|
neuper@37950
|
37 |
append_rls "e_rls" e_rls [(*for preds in where_*)],
|
neuper@37968
|
38 |
SOME "Simplify t_t",
|
neuper@37950
|
39 |
[]));
|
neuper@37950
|
40 |
|
neuper@37950
|
41 |
store_pbt
|
neuper@37972
|
42 |
(prep_pbt thy "pbl_vereinfache" [] e_pblID
|
neuper@37950
|
43 |
(["vereinfachen"],
|
neuper@38083
|
44 |
[("#Given" ,["Term t_t"]),
|
neuper@37968
|
45 |
("#Find" ,["normalform n_n"])
|
neuper@37950
|
46 |
],
|
neuper@37950
|
47 |
append_rls "e_rls" e_rls [(*for preds in where_*)],
|
neuper@37968
|
48 |
SOME "Vereinfache t_t",
|
neuper@37950
|
49 |
[]));
|
neuper@42425
|
50 |
*}
|
neuper@42425
|
51 |
ML {*
|
neuper@37950
|
52 |
|
neuper@37950
|
53 |
(** methods **)
|
neuper@37950
|
54 |
|
neuper@37950
|
55 |
store_met
|
neuper@42425
|
56 |
(prep_met thy "met_tsimp" [] e_metID
|
neuper@42425
|
57 |
(["simplification"],
|
neuper@42425
|
58 |
[("#Given" ,["Term t_t"]),
|
neuper@42425
|
59 |
("#Find" ,["normalform n_n"])],
|
neuper@42425
|
60 |
{rew_ord'="tless_true", rls'= e_rls, calc = [], srls = e_rls, prls=e_rls,
|
neuper@42425
|
61 |
crls = e_rls, errpats = [], nrls = e_rls},
|
neuper@42425
|
62 |
"empty_script"));
|
neuper@42425
|
63 |
*}
|
neuper@42425
|
64 |
ML {*
|
neuper@37950
|
65 |
|
neuper@37950
|
66 |
(** CAS-command **)
|
neuper@37950
|
67 |
|
neuper@37950
|
68 |
(*.function for handling the cas-input "Simplify (2*a + 3*a)":
|
neuper@37950
|
69 |
make a model which is already in ptree-internal format.*)
|
neuper@37950
|
70 |
(* val (h,argl) = strip_comb (str2term "Simplify (2*a + 3*a)");
|
neuper@40836
|
71 |
val (h,argl) = strip_comb ((term_of o the o (parse (Thy_Info.get_theory "Simplify")))
|
neuper@37950
|
72 |
"Simplify (2*a + 3*a)");
|
neuper@37950
|
73 |
*)
|
neuper@37950
|
74 |
fun argl2dtss t =
|
neuper@38083
|
75 |
[((term_of o the o (parse thy)) "Term", t),
|
neuper@37972
|
76 |
((term_of o the o (parse thy)) "normalform",
|
neuper@37972
|
77 |
[(term_of o the o (parse thy)) "N"])
|
neuper@37950
|
78 |
]
|
neuper@38031
|
79 |
| argl2dtss _ = error "Simplify.ML: wrong argument for argl2dtss";
|
neuper@37950
|
80 |
|
neuper@37950
|
81 |
castab :=
|
neuper@37950
|
82 |
overwritel (!castab,
|
neuper@37972
|
83 |
[((term_of o the o (parse thy)) "Simplify",
|
neuper@37968
|
84 |
(("Isac", ["simplification"], ["no_met"]),
|
neuper@37950
|
85 |
argl2dtss)),
|
neuper@37972
|
86 |
((term_of o the o (parse thy)) "Vereinfache",
|
neuper@37968
|
87 |
(("Isac", ["vereinfachen"], ["no_met"]),
|
neuper@37950
|
88 |
argl2dtss))
|
neuper@37950
|
89 |
]);
|
neuper@37950
|
90 |
*}
|
neuper@37906
|
91 |
|
neuper@37906
|
92 |
end |