neuper@37906
|
1 |
(* application of differential calculus
|
neuper@37954
|
2 |
Walther Neuper 2002
|
neuper@37954
|
3 |
(c) due to copyright terms
|
neuper@37906
|
4 |
*)
|
neuper@37906
|
5 |
|
neuper@37954
|
6 |
theory DiffApp imports Diff begin
|
neuper@37906
|
7 |
|
neuper@37906
|
8 |
consts
|
neuper@37906
|
9 |
|
neuper@37906
|
10 |
dummy :: real
|
neuper@37906
|
11 |
|
wenzelm@60380
|
12 |
fun filterVar :: \<open>real \<Rightarrow> 'a list \<Rightarrow> 'a list\<close>
|
wenzelm@60380
|
13 |
where
|
wenzelm@60380
|
14 |
filterVar_Nil: \<open>filterVar v [] = []\<close>
|
wenzelm@60380
|
15 |
| filterVar_Const: \<open>filterVar v (x # xs) =
|
wenzelm@60380
|
16 |
(if v \<in> set (Vars x) then x # (filterVar v xs) else filterVar v xs)\<close>
|
walther@60377
|
17 |
|
walther@60377
|
18 |
|
wneuper@59472
|
19 |
text \<open>WN.6.5.03: old decisions in this file partially are being changed
|
neuper@37954
|
20 |
in a quick-and-dirty way to make scripts run: Maximum_value,
|
neuper@37954
|
21 |
Make_fun_by_new_variable, Make_fun_by_explicit.
|
neuper@37954
|
22 |
found to be reconsidered:
|
walther@60125
|
23 |
- descriptions (Input_Descript.thy)
|
neuper@37954
|
24 |
- penv: really need term list; or just rerun the whole example with num/var
|
walther@59848
|
25 |
- mk_arg, arguments_from_model ... env in script different from penv ?
|
neuper@37954
|
26 |
- L = SubProblem eq ... show some vars on the worksheet ? (other means for
|
neuper@37954
|
27 |
referencing are labels (no on worksheet))
|
neuper@37954
|
28 |
|
walther@59848
|
29 |
WN.6.5.03 quick-and-dirty: mk_arg, arguments_from_model just make most convenient env
|
neuper@37954
|
30 |
from penv as is.
|
wneuper@59472
|
31 |
\<close>
|
neuper@37954
|
32 |
|
wneuper@59472
|
33 |
ML \<open>
|
s1210629013@55444
|
34 |
val eval_rls = prep_rls' (
|
walther@59851
|
35 |
Rule_Def.Repeat {id = "eval_rls", preconds = [], rew_ord = ("termlessI", termlessI),
|
walther@59852
|
36 |
erls = Rule_Set.empty, srls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@60358
|
37 |
rules = [
|
walther@60358
|
38 |
\<^rule_thm>\<open>refl\<close>,
|
wenzelm@60297
|
39 |
\<^rule_thm>\<open>order_refl\<close>,
|
wenzelm@60297
|
40 |
\<^rule_thm>\<open>radd_left_cancel_le\<close>,
|
wenzelm@60297
|
41 |
\<^rule_thm>\<open>not_true\<close>,
|
wenzelm@60297
|
42 |
\<^rule_thm>\<open>not_false\<close>,
|
wenzelm@60297
|
43 |
\<^rule_thm>\<open>and_true\<close>,
|
wenzelm@60297
|
44 |
\<^rule_thm>\<open>and_false\<close>,
|
wenzelm@60297
|
45 |
\<^rule_thm>\<open>or_true\<close>,
|
wenzelm@60297
|
46 |
\<^rule_thm>\<open>or_false\<close>,
|
wenzelm@60297
|
47 |
\<^rule_thm>\<open>and_commute\<close>,
|
wenzelm@60297
|
48 |
\<^rule_thm>\<open>or_commute\<close>,
|
neuper@52139
|
49 |
|
wenzelm@60294
|
50 |
\<^rule_eval>\<open>less\<close> (Prog_Expr.eval_equ "#less_"),
|
wenzelm@60294
|
51 |
\<^rule_eval>\<open>less_eq\<close> (Prog_Expr.eval_equ "#less_equal_"),
|
neuper@52139
|
52 |
|
wenzelm@60294
|
53 |
\<^rule_eval>\<open>Prog_Expr.ident\<close> (Prog_Expr.eval_ident "#ident_"),
|
walther@60385
|
54 |
\<^rule_eval>\<open>Prog_Expr.is_num\<close> (Prog_Expr.eval_is_num "#is_num_"),
|
wenzelm@60294
|
55 |
\<^rule_eval>\<open>Prog_Expr.occurs_in\<close> (Prog_Expr.eval_occurs_in ""),
|
wenzelm@60294
|
56 |
\<^rule_eval>\<open>Prog_Expr.matches\<close> (Prog_Expr.eval_matches "")],
|
walther@59878
|
57 |
scr = Rule.Empty_Prog
|
wneuper@59406
|
58 |
});
|
wneuper@59472
|
59 |
\<close>
|
wenzelm@60289
|
60 |
rule_set_knowledge eval_rls = \<open>eval_rls\<close>
|
neuper@37954
|
61 |
|
wenzelm@60306
|
62 |
(** problems **)
|
wenzelm@60306
|
63 |
|
wenzelm@60306
|
64 |
problem pbl_fun_max : "maximum_of/function" =
|
wenzelm@60306
|
65 |
\<open>Rule_Set.empty\<close>
|
wenzelm@60306
|
66 |
Given: "fixedValues f_ix"
|
wenzelm@60306
|
67 |
Find: "maximum m_m" "valuesFor v_s"
|
wenzelm@60306
|
68 |
Relate: "relations r_s"
|
wenzelm@60306
|
69 |
|
wenzelm@60306
|
70 |
problem pbl_fun_make : "make/function" =
|
wenzelm@60306
|
71 |
\<open>Rule_Set.empty\<close>
|
wenzelm@60306
|
72 |
Given: "functionOf f_f" "boundVariable v_v" "equalities eqs"
|
wenzelm@60306
|
73 |
Find: "functionEq f_1"
|
wenzelm@60306
|
74 |
|
wenzelm@60306
|
75 |
problem pbl_fun_max_expl : "by_explicit/make/function" =
|
wenzelm@60306
|
76 |
\<open>Rule_Set.empty\<close>
|
Walther@60449
|
77 |
Method_Ref: "DiffApp/make_fun_by_explicit"
|
wenzelm@60306
|
78 |
Given: "functionOf f_f" "boundVariable v_v" "equalities eqs"
|
wenzelm@60306
|
79 |
Find: "functionEq f_1"
|
wenzelm@60306
|
80 |
|
wenzelm@60306
|
81 |
problem pbl_fun_max_newvar : "by_new_variable/make/function" =
|
wenzelm@60306
|
82 |
\<open>Rule_Set.empty\<close>
|
Walther@60449
|
83 |
Method_Ref: "DiffApp/make_fun_by_new_variable"
|
wenzelm@60306
|
84 |
Given: "functionOf f_f" "boundVariable v_v" "equalities eqs"
|
wenzelm@60306
|
85 |
(*WN.12.5.03: precond for distinction still missing*)
|
wenzelm@60306
|
86 |
Find: "functionEq f_1"
|
wenzelm@60306
|
87 |
|
wenzelm@60306
|
88 |
problem pbl_fun_max_interv : "on_interval/maximum_of/function" =
|
wenzelm@60306
|
89 |
\<open>Rule_Set.empty\<close>
|
wenzelm@60306
|
90 |
Given: "functionEq t_t" "boundVariable v_v" "interval i_tv"
|
wenzelm@60306
|
91 |
(*WN.12.5.03: precond for distinction still missing*)
|
wenzelm@60306
|
92 |
Find: "maxArgument v_0"
|
wenzelm@60306
|
93 |
|
wenzelm@60306
|
94 |
problem pbl_tool : "tool" =
|
wenzelm@60306
|
95 |
\<open>Rule_Set.empty\<close>
|
wenzelm@60306
|
96 |
|
wenzelm@60306
|
97 |
problem pbl_tool_findvals : "find_values/tool" =
|
wenzelm@60306
|
98 |
\<open>Rule_Set.empty\<close>
|
wenzelm@60306
|
99 |
Given: "maxArgument m_ax" "functionEq f_f" "boundVariable v_v"
|
wenzelm@60306
|
100 |
Find: "valuesFor v_ls"
|
wenzelm@60306
|
101 |
Relate: "additionalRels r_s"
|
s1210629013@55380
|
102 |
|
neuper@37954
|
103 |
|
neuper@37954
|
104 |
(** methods, scripts not yet implemented **)
|
wenzelm@60303
|
105 |
|
wenzelm@60303
|
106 |
method met_diffapp : "DiffApp" =
|
wenzelm@60303
|
107 |
\<open>{rew_ord'="tless_true", rls'=Atools_erls,calc = [], srls = Rule_Set.empty, prls = Rule_Set.empty,
|
wenzelm@60303
|
108 |
crls = Atools_erls, errpats = [], nrls = norm_Rational (*, asm_rls=[],asm_thm=[]*)}\<close>
|
wneuper@59545
|
109 |
|
wneuper@59504
|
110 |
partial_function (tailrec) maximum_value ::
|
wneuper@59504
|
111 |
"bool list \<Rightarrow> real \<Rightarrow> bool list \<Rightarrow> real \<Rightarrow> real set \<Rightarrow> bool \<Rightarrow> bool list"
|
wneuper@59504
|
112 |
where
|
wneuper@59504
|
113 |
"maximum_value f_ix m_m r_s v_v itv_v e_rr =
|
wneuper@59504
|
114 |
(let e_e = (hd o (filterVar m_m)) r_s;
|
walther@60121
|
115 |
t_t = if 1 < Length r_s
|
wneuper@59504
|
116 |
then SubProblem (''DiffApp'', [''make'', ''function''],[''no_met''])
|
wneuper@59504
|
117 |
[REAL m_m, REAL v_v, BOOL_LIST r_s]
|
wneuper@59504
|
118 |
else (hd r_s);
|
wneuper@59504
|
119 |
m_x = SubProblem (''DiffApp'', [''on_interval'', ''maximum_of'', ''function''],
|
wneuper@59504
|
120 |
[''DiffApp'', ''max_on_interval_by_calculus''])
|
wneuper@59504
|
121 |
[BOOL t_t, REAL v_v, REAL_SET itv_v]
|
wneuper@59592
|
122 |
in SubProblem (''DiffApp'',[''find_values'', ''tool''], [''Isac_Knowledge'', ''find_values''])
|
wneuper@59504
|
123 |
[REAL m_x, REAL (rhs t_t), REAL v_v, REAL m_m, BOOL_LIST (dropWhile (ident e_e) r_s)])"
|
wenzelm@60303
|
124 |
|
wenzelm@60303
|
125 |
method met_diffapp_max : "DiffApp/max_by_calculus" =
|
wenzelm@60303
|
126 |
\<open>{rew_ord'="tless_true",rls'=eval_rls,calc=[],srls=prog_expr,prls=Rule_Set.empty, crls = eval_rls,
|
wenzelm@60303
|
127 |
errpats = [], nrls = norm_Rational (*, asm_rls=[],asm_thm=[]*)}\<close>
|
wenzelm@60303
|
128 |
Program: maximum_value.simps
|
wenzelm@60303
|
129 |
Given: "fixedValues f_ix" "maximum m_m" "relations r_s" "boundVariable v_v"
|
wenzelm@60303
|
130 |
"interval i_tv" "errorBound e_rr"
|
wenzelm@60303
|
131 |
Find: "valuesFor v_s"
|
wenzelm@60303
|
132 |
Relate:
|
wneuper@59545
|
133 |
|
wneuper@59504
|
134 |
partial_function (tailrec) make_fun_by_new_variable :: "real => real => bool list => bool"
|
wneuper@59504
|
135 |
where
|
wneuper@59504
|
136 |
"make_fun_by_new_variable f_f v_v eqs =
|
wneuper@59504
|
137 |
(let h_h = (hd o (filterVar f_f)) eqs;
|
wneuper@59504
|
138 |
e_s = dropWhile (ident h_h) eqs;
|
wneuper@59504
|
139 |
v_s = dropWhile (ident f_f) (Vars h_h);
|
wneuper@59504
|
140 |
v_1 = NTH 1 v_s;
|
wneuper@59504
|
141 |
v_2 = NTH 2 v_s;
|
wneuper@59504
|
142 |
e_1 = (hd o (filterVar v_1)) e_s;
|
wneuper@59504
|
143 |
e_2 = (hd o (filterVar v_2)) e_s;
|
wneuper@59504
|
144 |
s_1 = SubProblem (''DiffApp'', [''univariate'', ''equation''], [''no_met''])
|
wneuper@59504
|
145 |
[BOOL e_1, REAL v_1];
|
wneuper@59504
|
146 |
s_2 = SubProblem (''DiffApp'', [''univariate'', ''equation''], [''no_met''])
|
wneuper@59504
|
147 |
[BOOL e_2, REAL v_2]
|
wneuper@59504
|
148 |
in Substitute [(v_1 = (rhs o hd) s_1), (v_2 = (rhs o hd) s_2)] h_h)"
|
wenzelm@60303
|
149 |
|
wenzelm@60303
|
150 |
method met_diffapp_funnew : "DiffApp/make_fun_by_new_variable" =
|
wenzelm@60303
|
151 |
\<open>{rew_ord'="tless_true",rls'=eval_rls,srls=prog_expr,prls=Rule_Set.empty, calc=[], crls = eval_rls,
|
wenzelm@60303
|
152 |
errpats = [], nrls = norm_Rational(*,asm_rls=[],asm_thm=[]*)}\<close>
|
wenzelm@60303
|
153 |
Program: make_fun_by_new_variable.simps
|
wenzelm@60303
|
154 |
Given: "functionOf f_f" "boundVariable v_v" "equalities eqs"
|
wenzelm@60303
|
155 |
Find: "functionEq f_1"
|
wneuper@59545
|
156 |
|
wneuper@59504
|
157 |
partial_function (tailrec) make_fun_by_explicit :: "real => real => bool list => bool"
|
wneuper@59504
|
158 |
where
|
wneuper@59504
|
159 |
"make_fun_by_explicit f_f v_v eqs =
|
wneuper@59504
|
160 |
(let h_h = (hd o (filterVar f_f)) eqs;
|
wneuper@59504
|
161 |
e_1 = hd (dropWhile (ident h_h) eqs);
|
wneuper@59504
|
162 |
v_s = dropWhile (ident f_f) (Vars h_h);
|
wneuper@59504
|
163 |
v_1 = hd (dropWhile (ident v_v) v_s);
|
wneuper@59504
|
164 |
s_1 = SubProblem(''DiffApp'', [''univariate'', ''equation''], [''no_met''])
|
wneuper@59504
|
165 |
[BOOL e_1, REAL v_1]
|
wneuper@59504
|
166 |
in Substitute [(v_1 = (rhs o hd) s_1)] h_h) "
|
wenzelm@60303
|
167 |
|
wenzelm@60303
|
168 |
method met_diffapp_funexp : "DiffApp/make_fun_by_explicit" =
|
wenzelm@60303
|
169 |
\<open>{rew_ord'="tless_true",rls'=eval_rls,calc=[],srls=prog_expr,prls=Rule_Set.empty, crls = eval_rls,
|
wenzelm@60303
|
170 |
errpats = [], nrls = norm_Rational (*, asm_rls=[],asm_thm=[]*)}\<close>
|
wenzelm@60303
|
171 |
Program: make_fun_by_explicit.simps
|
wenzelm@60303
|
172 |
Given: "functionOf f_f" "boundVariable v_v" "equalities eqs"
|
wenzelm@60303
|
173 |
Find: "functionEq f_1"
|
wenzelm@60303
|
174 |
|
wenzelm@60303
|
175 |
method met_diffapp_max_oninterval : "DiffApp/max_on_interval_by_calculus" =
|
wenzelm@60303
|
176 |
\<open>{rew_ord'="tless_true",rls'=eval_rls,calc=[],srls = Rule_Set.empty,prls=Rule_Set.empty, crls = eval_rls,
|
wenzelm@60303
|
177 |
errpats = [], nrls = norm_Rational (*, asm_rls=[],asm_thm=[]*)}\<close>
|
wenzelm@60303
|
178 |
Given: "functionEq t_t" "boundVariable v_v" "interval i_tv" (*"errorBound e_rr"*)
|
wenzelm@60303
|
179 |
Find: "maxArgument v_0"
|
wenzelm@60303
|
180 |
|
wenzelm@60303
|
181 |
method met_diffapp_findvals : "DiffApp/find_values" =
|
wenzelm@60303
|
182 |
\<open>{rew_ord'="tless_true",rls'=eval_rls,calc=[],srls = Rule_Set.empty,prls=Rule_Set.empty, crls = eval_rls,
|
wenzelm@60303
|
183 |
errpats = [], nrls = norm_Rational(*, asm_rls = [], asm_thm = []*)}\<close>
|
wenzelm@60303
|
184 |
|
wneuper@59472
|
185 |
ML \<open>
|
walther@60377
|
186 |
\<close> ML \<open>
|
walther@60358
|
187 |
val prog_expr = Rule_Set.append_rules "prog_expr" prog_expr [
|
walther@60358
|
188 |
\<^rule_thm>\<open>filterVar_Const\<close>,
|
wenzelm@60297
|
189 |
\<^rule_thm>\<open>filterVar_Nil\<close>];
|
wneuper@59472
|
190 |
\<close>
|
wenzelm@60289
|
191 |
rule_set_knowledge prog_expr = \<open>prog_expr\<close>
|
wenzelm@60286
|
192 |
ML \<open>
|
walther@60278
|
193 |
\<close> ML \<open>
|
walther@60278
|
194 |
\<close> ML \<open>
|
walther@60278
|
195 |
\<close>
|
walther@60125
|
196 |
end
|