1 (* Title: partial fraction decomposition
3 (c) due to copyright terms
6 "--------------------------------------------------------";
7 "table of contents --------------------------------------";
8 "--------------------------------------------------------";
9 "----------- why helpless here ? ------------------------";
10 "----------- why not nxt = Model_Problem here ? ---------";
11 "----------- fun factors_from_solution ------------------";
12 "----------- Logic.unvarify_global ----------------------";
13 "----------- eval_drop_questionmarks --------------------";
14 "--------------------------------------------------------";
15 "--------------------------------------------------------";
16 "--------------------------------------------------------";
19 "----------- why helpless here ? ------------------------";
20 "----------- why helpless here ? ------------------------";
21 "----------- why helpless here ? ------------------------";
22 val fmz = ["filterExpression (X z = 3 / (z - 1/4 + -1/8 * (1/(z::real))))",
23 "stepResponse (x[n::real]::bool)"];
24 val (dI,pI,mI) = ("Isac", ["inverse", "Z_Transform", "SignalProcessing"],
25 ["SignalProcessing","Z_Transform","inverse"]);
26 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI,pI,mI))];
27 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Add_Given";
28 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Add_Find";
29 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Specify_Theory";
30 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Specify_Problem";
31 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Specify_Method";
32 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "nxt = Apply_Method";
33 val (p,_,f,nxt,_,pt) = me nxt p [] pt; "nxt = Rewrite (ruleZY, Inverse_Z_Transform.ruleZY) --> X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))";
34 val (p''',_,f,nxt''',_,pt''') = me nxt p [] pt; "nxt = Rewrite_Set norm_Rational --> X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))";
35 "~~~~~ fun me, args:"; val ((_,tac), (p:pos'), _, (pt:ptree)) = (nxt, p, [], pt);
36 val ("ok", (_, _, ptp)) = locatetac tac (pt,p)
38 "~~~~~ fun step, args:"; val (((ip as (_,p_)):pos'), ((ptp as (pt,p), tacis):calcstate)) =
39 (p, ((pt, e_pos'),[]));
40 val pIopt = get_pblID (pt,ip);
41 ip = ([],Res); "false";
43 pIopt; (* = SOME ["inverse", "Z_Transform", "SignalProcessing"]*)
44 member op = [Pbl,Met] p_ andalso is_none (get_obj g_env pt (fst p)); "false";
45 (*nxt_solve_ (pt,ip); "WAS isalist2list applied to NON-list 'no_meth'"
46 THIS MEANS: replace no_meth by [no_meth] in Script.*)
47 (*WAS val ("helpless",_) = step p ((pt, e_pos'),[]) *)
48 (*WAS val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Empty_Tac instead SubProblem";*)
50 "----------- why not nxt = Model_Problem here ? ---------";
51 "----------- why not nxt = Model_Problem here ? ---------";
52 "----------- why not nxt = Model_Problem here ? ---------";
53 val (p,_,f,nxt,_,pt) = me nxt''' p''' [] pt''';
54 "~~~~~ fun me, args:"; val (((_,tac):tac'_), (p:pos'), _, (pt:ptree)) = (nxt, p, c, pt);
55 val ("ok", (_, _, ptp)) = locatetac tac (pt,p);
57 "~~~~~ fun step, args:"; val (((ip as (_,p_)):pos'), ((ptp as (pt,p), tacis):calcstate)) =
58 (p, ((pt, e_pos'),[]));
59 val pIopt = get_pblID (pt,ip);
60 ip = ([],Res); " = false";
62 pIopt (* = SOME ["inverse", "Z_Transform", "SignalProcessing"]*);
63 member op = [Pbl,Met] p_ andalso is_none (get_obj g_env pt (fst p)); " = false";
64 (* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ leads into
65 nxt_solve_, which is definitely WRONG (should be nxt_specify_ for FIND_ADD).
66 This ERROR seems to be introduced together with ctxt, concerns Apply_Method without init_form.
70 "----------- fun factors_from_solution ------------------";
71 "----------- fun factors_from_solution ------------------";
72 "----------- fun factors_from_solution ------------------";
73 val ctxt = ProofContext.init_global @{theory Isac};
74 val SOME t = parseNEW ctxt "factors_from_solution [(z::real) = 1 / 2, z = -1 / 4]";
75 val SOME (_, t') = eval_factors_from_solution "" 0 t thy;
77 "factors_from_solution [z = 1 / 2, z = -1 / 4] =\n(z + -1 * (1 / 2)) * (z + -1 * (-1 / 4))"
78 then () else error "factors_from_solution broken";
80 "----------- Logic.unvarify_global ----------------------";
81 "----------- Logic.unvarify_global ----------------------";
82 "----------- Logic.unvarify_global ----------------------";
83 val A_var = parseNEW ctxt "A::real" |> the |> Logic.varify_global
84 val B_var = parseNEW ctxt "B::real" |> the |> Logic.varify_global
86 val denom1 = parseNEW ctxt "(z + -1 * (1 / 2))::real" |> the;
87 val denom2 = parseNEW ctxt "(z + -1 * (-1 / 4))::real" |> the;
89 val test = HOLogic.mk_binop "Groups.plus_class.plus"
90 (HOLogic.mk_binop "Rings.inverse_class.divide" (A_var, denom1),
91 HOLogic.mk_binop "Rings.inverse_class.divide" (B_var, denom2));
93 if term2str test = "?A / (z + -1 * (1 / 2)) + ?B / (z + -1 * (-1 / 4))" then ()
94 else error "HOLogic.mk_binop broken ?";
96 (* Logic.unvarify_global test
97 ---> exception TERM raised (line 539 of "logic.ML"): Illegal fixed variable: "z"
98 thus we need another fun var2free in termC.sml*)
100 "----------- eval_drop_questionmarks --------------------";
101 "----------- eval_drop_questionmarks --------------------";
102 "----------- eval_drop_questionmarks --------------------";
103 if term2str test = "?A / (z + -1 * (1 / 2)) + ?B / (z + -1 * (-1 / 4))"
104 then () else error "test setup (ctxt!) probably changed";
106 val t = Const ("Partial_Fractions.drop_questionmarks", HOLogic.realT --> HOLogic.realT) $ test;
108 val SOME (_, t') = eval_drop_questionmarks "drop_questionmarks" 0 t @{theory Isac};
109 if term2str t' = "drop_questionmarks (?A / (z + -1 * (1 / 2)) + ?B / (z + -1 * (-1 / 4))) =" ^
110 "\nA / (z + -1 * (1 / 2)) + B / (z + -1 * (-1 / 4))"
111 then () else error "eval_drop_questionmarks broken";