neuper@41943
|
1 |
(* Title: test/../generate.sml
|
neuper@41943
|
2 |
Author: Walther Neuper 110320
|
neuper@41943
|
3 |
(c) copyright due to lincense terms.
|
neuper@41943
|
4 |
*)
|
neuper@42321
|
5 |
|
neuper@42321
|
6 |
"-----------------------------------------------------------------";
|
neuper@42321
|
7 |
"table of contents -----------------------------------------------";
|
neuper@42321
|
8 |
"-----------------------------------------------------------------";
|
neuper@42436
|
9 |
"--------- embed fun generate_inconsistent_rew -------------------";
|
neuper@42321
|
10 |
"-----------------------------------------------------------------";
|
neuper@42321
|
11 |
"-----------------------------------------------------------------";
|
neuper@42321
|
12 |
"-----------------------------------------------------------------";
|
neuper@42321
|
13 |
|
neuper@42436
|
14 |
"--------- embed fun generate_inconsistent_rew -------------------";
|
neuper@42436
|
15 |
"--------- embed fun generate_inconsistent_rew -------------------";
|
neuper@42436
|
16 |
"--------- embed fun generate_inconsistent_rew -------------------";
|
s1210629013@55445
|
17 |
reset_states ();
|
neuper@42436
|
18 |
CalcTree
|
neuper@42436
|
19 |
[(["functionTerm (x ^ 2 + sin (x ^ 4))", "differentiateFor x", "derivative f_f'"],
|
neuper@42436
|
20 |
("Isac", ["derivative_of","function"], ["diff","differentiate_on_R"]))];
|
neuper@42436
|
21 |
Iterator 1;
|
neuper@42436
|
22 |
moveActiveRoot 1;
|
wneuper@59248
|
23 |
autoCalculate 1 CompleteCalcHead;
|
wneuper@59248
|
24 |
autoCalculate 1 (Step 1);
|
wneuper@59248
|
25 |
autoCalculate 1 (Step 1);(*([1], Res), d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))*)
|
wneuper@59123
|
26 |
appendFormula 1 "d_d x (x ^ 2) + cos (4 * x ^ 3)" (*|> Future.join*);
|
neuper@42436
|
27 |
(* the check for errpat is maximally liberal (whole term modulo "nrls" from "type met"),
|
neuper@42436
|
28 |
would recognize "cos (4 * x ^ (4 - 1)) + 2 * x" as well.
|
neuper@42436
|
29 |
results in <CALCMESSAGE> error pattern #chain-rule-diff-both# </CALCMESSAGE>
|
neuper@42436
|
30 |
instead of <CALCMESSAGE> no derivation found </CALCMESSAGE> *)
|
neuper@48891
|
31 |
(*========== inhibit exn WN1130621 Isabelle2012-->13 !thehier! ====================
|
neuper@42436
|
32 |
findFillpatterns 1 "chain-rule-diff-both";
|
neuper@42436
|
33 |
(*<CALCMESSAGE> fill patterns #fill-d_d-arg#d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =
|
neuper@42436
|
34 |
d_d x (x ^^^ 2) + cos (x ^^^ 4) * d_d x ?_dummy_1#fill-both-args#...#...#... *)
|
neuper@42436
|
35 |
|
neuper@42436
|
36 |
"~~~~~ fun requestFillformula, args:"; val (cI, (errpatID, fillpatID)) =
|
neuper@42436
|
37 |
(1, ("chain-rule-diff-both", "fill-both-args"));
|
neuper@42436
|
38 |
val ((pt, _), _) = get_calc cI
|
neuper@42436
|
39 |
val pos as (p, _) = get_pos cI 1;
|
neuper@42436
|
40 |
val fillforms = find_fillpatterns (pt, pos) errpatID;
|
neuper@42436
|
41 |
|
neuper@42437
|
42 |
if pos = ([1], Res) then () else error "generate_inconsistent_rew changed 1";
|
neuper@42436
|
43 |
|
neuper@42436
|
44 |
val (_, fillform, thm, sube_opt) :: _ = filter ((curry op = fillpatID) o
|
neuper@42436
|
45 |
(#1: (fillpatID * term * thm * (subs option) -> fillpatID))) fillforms;
|
neuper@42436
|
46 |
|
neuper@42436
|
47 |
"~~~~~ fun generate_inconsistent_rew, args:";
|
neuper@42436
|
48 |
val ((subs_opt, thm'), f', (is, ctxt), pos, pt) =
|
neuper@42436
|
49 |
((sube_opt, thm'_of_thm thm), fillform, (get_loc pt pos), pos, pt);
|
neuper@42436
|
50 |
|
neuper@42436
|
51 |
val f = get_curr_formula (pt, pos);
|
neuper@42436
|
52 |
val pos' as (p', _) = (lev_on p, Res);
|
neuper@42436
|
53 |
|
neuper@42437
|
54 |
if pos = ([1], Res) then () else error "generate_inconsistent_rew changed 2a";
|
neuper@42436
|
55 |
if term2str f = "d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4))"
|
neuper@42437
|
56 |
then () else error "generate_inconsistent_rew changed 2b";
|
neuper@42436
|
57 |
|
neuper@42436
|
58 |
val (pt,c) =
|
neuper@42436
|
59 |
case subs_opt of
|
neuper@42436
|
60 |
NONE => cappend_atomic pt p' (is, insert_assumptions [] ctxt) f
|
neuper@42436
|
61 |
(Rewrite thm') (f', []) Inconsistent
|
neuper@42436
|
62 |
| SOME subs => cappend_atomic pt p' (is, insert_assumptions [] ctxt) f
|
neuper@42436
|
63 |
(Rewrite_Inst (subs, thm')) (f', []) Inconsistent
|
neuper@42437
|
64 |
val pt = update_branch pt p' TransitiveB;
|
neuper@42437
|
65 |
|
neuper@42437
|
66 |
if get_obj g_tac pt p' = Rewrite_Inst (["(bdv, x)"], ("diff_sin_chain", ""))
|
neuper@42437
|
67 |
andalso pos = ([1], Res) andalso pos' = ([2], Res) andalso p' = [2]
|
neuper@42437
|
68 |
then () else error "generate_inconsistent_rew changed 3";
|
neuper@42436
|
69 |
|
neuper@42436
|
70 |
"~~~~~ to requestFillformula return val:"; val (pt, pos') = (pt, pos');
|
neuper@42436
|
71 |
(*val (pt, pos') = generate_inconsistent_rew (sube_opt, thm'_of_thm thm)
|
neuper@42436
|
72 |
(fillform, []) (get_loc pt pos) pos' pt*)
|
neuper@42436
|
73 |
upd_calc cI ((pt, pos'), []); upd_ipos cI 1 pos';
|
neuper@42436
|
74 |
|
neuper@42436
|
75 |
"~~~~~ final check:";
|
neuper@42437
|
76 |
val ((pt, _),_) = get_calc 1;
|
neuper@42436
|
77 |
val p = get_pos 1 1;
|
neuper@42437
|
78 |
val (Form f, _, asms) = pt_extract (pt, p);
|
neuper@42437
|
79 |
if p = ([2], Res) andalso
|
neuper@42437
|
80 |
get_obj g_tac pt (fst p) = Rewrite_Inst (["(bdv, x)"], ("diff_sin_chain", "")) andalso
|
neuper@42437
|
81 |
term2str f =
|
neuper@42456
|
82 |
"d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos ?u * d_d x ?_dummy_2"
|
neuper@42450
|
83 |
(*WAS with old findFillpatterns:
|
neuper@42451
|
84 |
"d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos ?_dummy_2 * d_d x ?_dummy_3"
|
neuper@42456
|
85 |
WN120731 replaced
|
neuper@42456
|
86 |
"d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos ?u * d_d x ?_dummy_2"
|
neuper@42456
|
87 |
WN120804 replaced
|
neuper@42456
|
88 |
"d_d x (x ^^^ 2) + d_d x (sin (x ^^^ 4)) =\nd_d x (x ^^^ 2) + cos ?_dummy_1 * d_d x ?_dummy_2"*)
|
neuper@42451
|
89 |
then () else error "generate_inconsistent_rew changed: fill-formula?";
|
neuper@42436
|
90 |
|
neuper@42436
|
91 |
show_pt pt; (*ATTENTION: omits the last step, if pt is incomplete, ([2], Res) EXISTS !*)
|
neuper@48891
|
92 |
============ inhibit exn WN1130621 Isabelle2012-->13 !thehier! ==================*)
|
neuper@48891
|
93 |
|