neuper@38067
|
1 |
(*
|
neuper@38067
|
2 |
/usr/local/isabisac/bin/isabelle jedit -l Isac T2_Rewriting.thy &
|
neuper@38067
|
3 |
*)
|
neuper@38067
|
4 |
|
neuper@38067
|
5 |
theory T2_Rewriting imports Isac begin
|
neuper@38067
|
6 |
|
neuper@38067
|
7 |
section {* Rewriting *}
|
neuper@38067
|
8 |
|
neuper@38067
|
9 |
text {* \emph{Rewriting} is a technique of Symbolic Computation, which is appropriate
|
neuper@38067
|
10 |
to make a 'transparent system', because it is intuitively comprehensible. For a thourogh
|
neuper@38067
|
11 |
introduction see the book of Tobias Nipkow,
|
neuper@38067
|
12 |
http://www4.informatik.tu-muenchen.de/~nipkow/TRaAT/
|
neuper@38067
|
13 |
|
neuper@38067
|
14 |
section {* Introduction to rewriting *}
|
neuper@38067
|
15 |
|
neuper@38067
|
16 |
text {* Rewriting creates calculations which look like written by hand; see the
|
neuper@38067
|
17 |
ISAC tutoring system ! ISAC finds the rules automatically. Here we start by
|
neuper@38067
|
18 |
|
neuper@38067
|
19 |
Just to show, how simple rewriting is
|
neuper@38067
|
20 |
|
neuper@38067
|
21 |
=======================================================================================
|
neuper@38067
|
22 |
???????????????????? star with diff --- this allows trial and error from the beginning,
|
neuper@38067
|
23 |
!!!!!!!!!!!!!!!!!!!! if all the thems are given: here +?+ .thy (code or html?)
|
neuper@38067
|
24 |
=======================================================================================
|
neuper@38067
|
25 |
|
neuper@38067
|
26 |
The following
|
neuper@38067
|
27 |
|
neuper@38067
|
28 |
Please, skip the following ML-section in the first go ...*}
|
neuper@38067
|
29 |
|
neuper@38067
|
30 |
ML {*
|
neuper@38067
|
31 |
print_depth 5;
|
neuper@38067
|
32 |
val (thy, ro, er, inst) = (theory "Isac", tless_true, eval_rls, [("bdv", "x::real")]);
|
neuper@38067
|
33 |
*}
|
neuper@38067
|
34 |
|
neuper@38067
|
35 |
ML {*
|
neuper@38067
|
36 |
val t = (term_of o the o (parse thy)) "2 * a + 3 * (a - b)";
|
neuper@38067
|
37 |
*}
|
neuper@38067
|
38 |
|
neuper@38067
|
39 |
ML {*
|
neuper@38067
|
40 |
val SOME (t, _) = rewrite_ thy ro er true (@{thm "klammer_mult_minus"}) t; term2str t;
|
neuper@38067
|
41 |
val SOME (t, _) = rewrite_ thy ro er true (@{thm "klammer_plus_minus"}) t; term2str t;
|
neuper@38067
|
42 |
val SOME (t, _) = rewrite_ thy ro er true (@{thm "real_num_collect"}) t; term2str t;
|
neuper@38067
|
43 |
*}
|
neuper@38067
|
44 |
|
neuper@38067
|
45 |
ML {*
|
neuper@38067
|
46 |
("PLUS" , ("Groups.plus_class.plus", eval_binop "#add_"));
|
neuper@38067
|
47 |
get_calculation_ thy ;
|
neuper@38067
|
48 |
calculate_ thy ;
|
neuper@38067
|
49 |
*}
|
neuper@38067
|
50 |
|
neuper@38067
|
51 |
ML {*
|
neuper@38067
|
52 |
111
|
neuper@38067
|
53 |
*}
|
neuper@38067
|
54 |
|
neuper@38067
|
55 |
text {* ... and let's start with an example:
|
neuper@38067
|
56 |
*}
|
neuper@38067
|
57 |
|
neuper@38067
|
58 |
ML {* val t = parse (theory "PolyMinus") "2 * a + 3 * a + 4 * b";
|
neuper@38067
|
59 |
|
neuper@38067
|
60 |
*}
|
neuper@38067
|
61 |
|
neuper@38067
|
62 |
end
|