1 (* tools for applications of differetiation
3 use"Knowledge/DiffApp.ML";
4 use"../Knowledge/DiffApp.ML";
7 WN.6.5.03: old decisions in this file partially are being changed
8 in a quick-and-dirty way to make scripts run: Maximum_value,
9 Make_fun_by_new_variable, Make_fun_by_explicit.
10 found to be reconsidered:
11 - descriptions (Descript.thy)
12 - penv: really need term list; or just rerun the whole example with num/var
13 - mk_arg, itms2args ... env in script different from penv ?
14 - L = SubProblem eq ... show some vars on the worksheet ? (other means for
15 referencing are labels (no on worksheet))
17 WN.6.5.03 quick-and-dirty: mk_arg, itms2args just make most convenient env
22 (** interface isabelle -- isac **)
24 theory' := overwritel (!theory', [("DiffApp.thy",DiffApp.thy)]);
26 val eval_rls = prep_rls(
27 Rls {id="eval_rls",preconds = [], rew_ord = ("termlessI",termlessI),
28 erls = e_rls, srls = Erls, calc = [], (*asm_thm = [],*)
29 rules = [Thm ("refl",num_str refl),
30 Thm ("le_refl",num_str le_refl),
31 Thm ("radd_left_cancel_le",num_str radd_left_cancel_le),
32 Thm ("not_true",num_str not_true),
33 Thm ("not_false",num_str not_false),
34 Thm ("and_true",and_true),
35 Thm ("and_false",and_false),
36 Thm ("or_true",or_true),
37 Thm ("or_false",or_false),
38 Thm ("and_commute",num_str and_commute),
39 Thm ("or_commute",num_str or_commute),
41 Calc ("op <",eval_equ "#less_"),
42 Calc ("op <=",eval_equ "#less_equal_"),
44 Calc ("Atools.ident",eval_ident "#ident_"),
45 Calc ("Atools.is'_const",eval_const "#is_const_"),
46 Calc ("Atools.occurs'_in",eval_occurs_in ""),
47 Calc ("Tools.matches",eval_matches "")
49 scr = Script ((term_of o the o (parse thy))
52 ruleset' := overwritelthy thy
54 [("eval_rls",Atools_erls)(*FIXXXME:del with rls.rls'*)
61 (prep_pbt (theory "DiffApp") "pbl_fun_max" [] e_pblID
62 (["maximum_of","function"],
63 [("#Given" ,["fixedValues fix_"]),
64 ("#Find" ,["maximum m_","valuesFor vs_"]),
65 ("#Relate",["relations rs_"])
70 (prep_pbt (theory "DiffApp") "pbl_fun_make" [] e_pblID
71 (["make","function"]:pblID,
72 [("#Given" ,["functionOf f_","boundVariable v_","equalities eqs_"]),
73 ("#Find" ,["functionEq f_1_"])
77 (prep_pbt (theory "DiffApp") "pbl_fun_max_expl" [] e_pblID
78 (["by_explicit","make","function"]:pblID,
79 [("#Given" ,["functionOf f_","boundVariable v_","equalities eqs_"]),
80 ("#Find" ,["functionEq f_1_"])
82 e_rls, NONE, [["DiffApp","make_fun_by_explicit"]]));
84 (prep_pbt (theory "DiffApp") "pbl_fun_max_newvar" [] e_pblID
85 (["by_new_variable","make","function"]:pblID,
86 [("#Given" ,["functionOf f_","boundVariable v_","equalities eqs_"]),
87 (*WN.12.5.03: precond for distinction still missing*)
88 ("#Find" ,["functionEq f_1_"])
90 e_rls, NONE, [["DiffApp","make_fun_by_new_variable"]]));
93 (prep_pbt (theory "DiffApp") "pbl_fun_max_interv" [] e_pblID
94 (["on_interval","maximum_of","function"]:pblID,
95 [("#Given" ,["functionEq t_","boundVariable v_","interval itv_"]),
96 (*WN.12.5.03: precond for distinction still missing*)
97 ("#Find" ,["maxArgument v_0_"])
102 (prep_pbt (theory "DiffApp") "pbl_tool" [] e_pblID
108 (prep_pbt (theory "DiffApp") "pbl_tool_findvals" [] e_pblID
109 (["find_values","tool"]:pblID,
110 [("#Given" ,["maxArgument ma_","functionEq f_","boundVariable v_"]),
111 ("#Find" ,["valuesFor vls_"]),
112 ("#Relate",["additionalRels rs_"])
117 (** methods, scripts not yet implemented **)
120 (prep_met Diff.thy "met_diffapp" [] e_metID
123 {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
124 crls = Atools_erls, nrls=norm_Rational
125 (*, asm_rls=[],asm_thm=[]*)}, "empty_script"));
127 (prep_met (theory "DiffApp") "met_diffapp_max" [] e_metID
128 (["DiffApp","max_by_calculus"]:metID,
129 [("#Given" ,["fixedValues fix_","maximum m_","relations rs_",
130 "boundVariable v_","interval itv_","errorBound err_"]),
131 ("#Find" ,["valuesFor vs_"]),
134 {rew_ord'="tless_true",rls'=eval_rls,calc=[],srls=list_rls,prls=e_rls,
135 crls = eval_rls, nrls=norm_Rational
136 (*, asm_rls=[],asm_thm=[]*)},
137 "Script Maximum_value(fix_::bool list)(m_::real) (rs_::bool list) " ^
138 " (v_::real) (itv_::real set) (err_::bool) = " ^
139 " (let e_ = (hd o (filterVar m_)) rs_; " ^
140 " t_ = (if 1 < length_ rs_ " ^
141 " then (SubProblem (DiffApp_,[make,function],[no_met]) " ^
142 " [real_ m_, real_ v_, bool_list_ rs_]) " ^
143 " else (hd rs_)); " ^
145 "SubProblem(DiffApp_,[on_interval,maximum_of,function], " ^
146 " [DiffApp,max_on_interval_by_calculus]) " ^
147 " [bool_ t_, real_ v_, real_set_ itv_] " ^
148 " in ((SubProblem (DiffApp_,[find_values,tool],[Isac,find_values]) " ^
149 " [real_ mx_, real_ (Rhs t_), real_ v_, real_ m_, " ^
150 " bool_list_ (dropWhile (ident e_) rs_)])::bool list)) "
153 (prep_met (theory "DiffApp") "met_diffapp_funnew" [] e_metID
154 (["DiffApp","make_fun_by_new_variable"]:metID,
155 [("#Given" ,["functionOf f_","boundVariable v_","equalities eqs_"]),
156 ("#Find" ,["functionEq f_1_"])
158 {rew_ord'="tless_true",rls'=eval_rls,srls=list_rls,prls=e_rls,
159 calc=[], crls = eval_rls, nrls=norm_Rational(*,asm_rls=[],asm_thm=[]*)},
160 "Script Make_fun_by_new_variable (f_::real) (v_::real) " ^
161 " (eqs_::bool list) = " ^
162 "(let h_ = (hd o (filterVar f_)) eqs_; " ^
163 " es_ = dropWhile (ident h_) eqs_; " ^
164 " vs_ = dropWhile (ident f_) (Vars h_); " ^
165 " v_1 = nth_ 1 vs_; " ^
166 " v_2 = nth_ 2 vs_; " ^
167 " e_1 = (hd o (filterVar v_1)) es_; " ^
168 " e_2 = (hd o (filterVar v_2)) es_; " ^
169 " (s_1::bool list) = " ^
170 " (SubProblem (DiffApp_,[univariate,equation],[no_met])" ^
171 " [bool_ e_1, real_ v_1]); " ^
172 " (s_2::bool list) = " ^
173 " (SubProblem (DiffApp_,[univariate,equation],[no_met])" ^
174 " [bool_ e_2, real_ v_2])" ^
175 "in Substitute [(v_1 = (rhs o hd) s_1),(v_2 = (rhs o hd) s_2)] h_)"
178 (prep_met (theory "DiffApp") "met_diffapp_funexp" [] e_metID
179 (["DiffApp","make_fun_by_explicit"]:metID,
180 [("#Given" ,["functionOf f_","boundVariable v_","equalities eqs_"]),
181 ("#Find" ,["functionEq f_1_"])
183 {rew_ord'="tless_true",rls'=eval_rls,calc=[],srls=list_rls,prls=e_rls,
184 crls = eval_rls, nrls=norm_Rational
185 (*, asm_rls=[],asm_thm=[]*)},
186 "Script Make_fun_by_explicit (f_::real) (v_::real) " ^
187 " (eqs_::bool list) = " ^
188 " (let h_ = (hd o (filterVar f_)) eqs_; " ^
189 " e_1 = hd (dropWhile (ident h_) eqs_); " ^
190 " vs_ = dropWhile (ident f_) (Vars h_); " ^
191 " v_1 = hd (dropWhile (ident v_) vs_); " ^
192 " (s_1::bool list)= " ^
193 " (SubProblem(DiffApp_,[univariate,equation],[no_met])" ^
194 " [bool_ e_1, real_ v_1]) " ^
195 " in Substitute [(v_1 = (rhs o hd) s_1)] h_) "
198 (prep_met (theory "DiffApp") "met_diffapp_max_oninterval" [] e_metID
199 (["DiffApp","max_on_interval_by_calculus"]:metID,
200 [("#Given" ,["functionEq t_","boundVariable v_","interval itv_"(*,
201 "errorBound err_"*)]),
202 ("#Find" ,["maxArgument v_0_"])
204 {rew_ord'="tless_true",rls'=eval_rls,calc=[],srls = e_rls,prls=e_rls,
205 crls = eval_rls, nrls=norm_Rational
206 (*, asm_rls=[],asm_thm=[]*)},
210 (prep_met (theory "DiffApp") "met_diffapp_findvals" [] e_metID
211 (["DiffApp","find_values"]:metID,
213 {rew_ord'="tless_true",rls'=eval_rls,calc=[],srls = e_rls,prls=e_rls,
214 crls = eval_rls, nrls=norm_Rational(*,
215 asm_rls=[],asm_thm=[]*)},
218 val list_rls = append_rls "list_rls" list_rls
219 [Thm ("filterVar_Const", num_str filterVar_Const),
220 Thm ("filterVar_Nil", num_str filterVar_Nil)
222 ruleset' := overwritelthy thy (!ruleset',
223 [("list_rls",list_rls)