neuper@37906
|
1 |
(* use"ME/appl.sml";
|
neuper@37906
|
2 |
use"appl.sml";
|
neuper@37936
|
3 |
|
neuper@37936
|
4 |
12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
neuper@37936
|
5 |
10 20 30 40 50 60 70 80
|
neuper@37936
|
6 |
*)
|
neuper@37906
|
7 |
val e_cterm' = empty_cterm';
|
neuper@37906
|
8 |
|
neuper@37906
|
9 |
|
neuper@37906
|
10 |
fun rew_info (Rls {erls,rew_ord=(rew_ord',_),calc=ca, ...}) =
|
neuper@37906
|
11 |
(rew_ord':rew_ord',erls,ca)
|
neuper@37906
|
12 |
| rew_info (Seq {erls,rew_ord=(rew_ord',_),calc=ca, ...}) =
|
neuper@37906
|
13 |
(rew_ord',erls,ca)
|
neuper@37906
|
14 |
| rew_info (Rrls {erls,rew_ord=(rew_ord',_),calc=ca, ...}) =
|
neuper@37906
|
15 |
(rew_ord',erls, ca)
|
neuper@38031
|
16 |
| rew_info rls = error ("rew_info called with '"^rls2str rls^"'");
|
neuper@37906
|
17 |
|
neuper@37906
|
18 |
(*FIXME.3.4.03:re-organize from_pblobj_or_detail_thm after rls' --> rls*)
|
neuper@37906
|
19 |
fun from_pblobj_or_detail_thm thm' p pt =
|
neuper@52155
|
20 |
let
|
neuper@52155
|
21 |
val (pbl, p', rls') = par_pbl_det pt p
|
neuper@52155
|
22 |
in
|
neuper@52155
|
23 |
if pbl
|
neuper@52155
|
24 |
then
|
neuper@52155
|
25 |
let
|
neuper@52155
|
26 |
val thy' = get_obj g_domID pt p'
|
wneuper@59269
|
27 |
val {rew_ord', erls, ...} = Specify.get_met (get_obj g_metID pt p')
|
neuper@52155
|
28 |
in ("OK", thy', rew_ord', erls, false) end
|
neuper@52155
|
29 |
else
|
neuper@52155
|
30 |
let
|
neuper@52155
|
31 |
val thy' = get_obj g_domID pt (par_pblobj pt p)
|
neuper@52155
|
32 |
val (rew_ord', erls, _) = rew_info rls'
|
neuper@52155
|
33 |
in ("OK",thy',rew_ord',erls,false) end
|
neuper@52155
|
34 |
end;
|
neuper@37906
|
35 |
(*FIXME.3.4.03:re-organize from_pblobj_or_detail_calc after rls' --> rls*)
|
neuper@37906
|
36 |
fun from_pblobj_or_detail_calc scrop p pt =
|
neuper@52155
|
37 |
let
|
neuper@52155
|
38 |
val (pbl,p',rls') = par_pbl_det pt p
|
neuper@52155
|
39 |
in
|
neuper@52155
|
40 |
if pbl
|
neuper@52155
|
41 |
then
|
neuper@52155
|
42 |
let
|
neuper@52155
|
43 |
val thy' = get_obj g_domID pt p'
|
wneuper@59269
|
44 |
val {calc = scr_isa_fns,...} = Specify.get_met (get_obj g_metID pt p')
|
neuper@52155
|
45 |
val opt = assoc (scr_isa_fns, scrop)
|
neuper@52155
|
46 |
in
|
neuper@52155
|
47 |
case opt of
|
neuper@52155
|
48 |
SOME isa_fn => ("OK",thy',isa_fn)
|
neuper@52155
|
49 |
| NONE => ("applicable_in Calculate: unknown '" ^ scrop ^ "'", "", ("", e_evalfn))
|
neuper@52155
|
50 |
end
|
neuper@52155
|
51 |
else
|
neuper@52155
|
52 |
let
|
neuper@52155
|
53 |
val thy' = get_obj g_domID pt (par_pblobj pt p);
|
neuper@37906
|
54 |
val (_,_,(*_,*)scr_isa_fns) = rew_info rls'(*rls*)
|
neuper@52155
|
55 |
in
|
neuper@52155
|
56 |
case assoc (scr_isa_fns, scrop) of
|
neuper@52155
|
57 |
SOME isa_fn => ("OK",thy',isa_fn)
|
neuper@52155
|
58 |
| NONE => ("applicable_in Calculate: unknown '" ^ scrop ^ "'", "", ("", e_evalfn))
|
neuper@52155
|
59 |
end
|
neuper@52155
|
60 |
end;
|
neuper@37906
|
61 |
|
neuper@37906
|
62 |
val op_and = Const ("op &", [bool, bool] ---> bool);
|
wneuper@59184
|
63 |
(*> (Thm.global_cterm_of thy) (op_and $ Free("a",bool) $ Free("b",bool));
|
neuper@37906
|
64 |
val it = "a & b" : cterm
|
neuper@37906
|
65 |
*)
|
neuper@37906
|
66 |
fun mk_and a b = op_and $ a $ b;
|
wneuper@59184
|
67 |
(*> (Thm.global_cterm_of thy)
|
neuper@37906
|
68 |
(mk_and (Free("a",bool)) (Free("b",bool)));
|
neuper@37906
|
69 |
val it = "a & b" : cterm*)
|
neuper@37906
|
70 |
|
neuper@48760
|
71 |
fun mk_and [] = @{term True}
|
neuper@37906
|
72 |
| mk_and (t::[]) = t
|
neuper@37906
|
73 |
| mk_and (t::ts) =
|
neuper@37906
|
74 |
let fun mk t' (t::[]) = op_and $ t' $ t
|
neuper@37906
|
75 |
| mk t' (t::ts) = mk (op_and $ t' $ t) ts
|
neuper@37906
|
76 |
in mk t ts end;
|
wneuper@59186
|
77 |
(*> val pred = map (Thm.term_of o the o (parse thy))
|
neuper@37906
|
78 |
["#0 <= #9 + #4 * x","#0 <= sqrt x + sqrt (#-3 + x)"];
|
wneuper@59184
|
79 |
> (Thm.global_cterm_of thy) (mk_and pred);
|
neuper@37906
|
80 |
val it = "#0 <= #9 + #4 * x & #0 <= sqrt x + sqrt (#-3 + x)" : cterm*)
|
neuper@37906
|
81 |
|
neuper@37906
|
82 |
|
neuper@37906
|
83 |
|
neuper@37906
|
84 |
|
neuper@37906
|
85 |
(*for Check_elementwise in applicable_in: [x=1,..] Assumptions -> (x,0<=x&..)*)
|
neuper@37906
|
86 |
fun mk_set thy pt p (Const ("List.list.Nil",_)) pred = (e_term, [])
|
neuper@37906
|
87 |
|
neuper@37906
|
88 |
| mk_set thy pt p (Const ("Tools.UniversalList",_)) pred =
|
neuper@37906
|
89 |
(e_term, if pred <> Const ("Script.Assumptions",bool)
|
neuper@37906
|
90 |
then [pred]
|
e0726734@41957
|
91 |
else get_assumptions_ pt (p,Res))
|
neuper@37906
|
92 |
|
wneuper@59186
|
93 |
(* val pred = (Thm.term_of o the o (parse thy)) pred;
|
neuper@37906
|
94 |
val consts as Const ("List.list.Cons",_) $ eq $ _ = ft;
|
neuper@37906
|
95 |
mk_set thy pt p consts pred;
|
neuper@37906
|
96 |
*)
|
neuper@37906
|
97 |
| mk_set thy pt p (consts as Const ("List.list.Cons",_) $ eq $ _) pred =
|
neuper@37906
|
98 |
let val (bdv,_) = HOLogic.dest_eq eq;
|
neuper@37906
|
99 |
val pred = if pred <> Const ("Script.Assumptions",bool)
|
neuper@37906
|
100 |
then [pred]
|
e0726734@41957
|
101 |
else get_assumptions_ pt (p,Res)
|
neuper@37906
|
102 |
in (bdv, pred) end
|
neuper@37906
|
103 |
|
neuper@37906
|
104 |
| mk_set thy _ _ l _ =
|
neuper@38053
|
105 |
error ("check_elementwise: no set " ^ term2str l);
|
neuper@37906
|
106 |
(*> val consts = str2term "[x=#4]";
|
neuper@37906
|
107 |
> val pred = str2term "Assumptions";
|
neuper@37906
|
108 |
> val pt = union_asm pt p
|
neuper@37906
|
109 |
[("#0 <= sqrt x + sqrt (#5 + x)",[11]),("#0 <= #9 + #4 * x",[22]),
|
neuper@37906
|
110 |
("#0 <= x ^^^ #2 + #5 * x",[33]),("#0 <= #2 + x",[44])];
|
neuper@37906
|
111 |
> val p = [];
|
neuper@37906
|
112 |
> val (sss,ttt) = mk_set thy pt p consts pred;
|
neuper@38053
|
113 |
> (term2str sss, term2str ttt);
|
neuper@37906
|
114 |
val it = ("x","((#0 <= sqrt x + sqrt (#5 + x) & #0 <= #9 + #4 * x) & ...
|
neuper@37906
|
115 |
|
neuper@37906
|
116 |
val consts = str2term "UniversalList";
|
neuper@37906
|
117 |
val pred = str2term "Assumptions";
|
neuper@37906
|
118 |
|
neuper@37906
|
119 |
*)
|
neuper@37906
|
120 |
|
neuper@37906
|
121 |
|
neuper@37906
|
122 |
|
neuper@37906
|
123 |
(*check a list (/set) of constants [c_1,..,c_n] for c_i:set (: in)*)
|
neuper@37906
|
124 |
(* val (erls,consts,(bdv,pred)) = (erl,ft,vp);
|
neuper@37906
|
125 |
val (consts,(bdv,pred)) = (ft,vp);
|
neuper@37906
|
126 |
*)
|
neuper@37906
|
127 |
fun check_elementwise thy erls all_results (bdv, asm) =
|
neuper@37906
|
128 |
let (*bdv extracted from ~~~~~~~~~~~ in mk_set already*)
|
neuper@37906
|
129 |
fun check sub =
|
neuper@37906
|
130 |
let val inst_ = map (subst_atomic [sub]) asm
|
neuper@37906
|
131 |
in case eval__true thy 1 inst_ [] erls of
|
neuper@37906
|
132 |
(asm', true) => ([HOLogic.mk_eq sub], asm')
|
neuper@37906
|
133 |
| (_, false) => ([],[])
|
neuper@37906
|
134 |
end;
|
neuper@38015
|
135 |
(*val _= tracing("### check_elementwise: res= "^(term2str all_results)^
|
neuper@37906
|
136 |
", bdv= "^(term2str bdv)^", asm= "^(terms2str asm));*)
|
neuper@37906
|
137 |
val c' = isalist2list all_results
|
neuper@37906
|
138 |
val c'' = map (snd o HOLogic.dest_eq) c' (*assumes [x=1,x=2,..]*)
|
neuper@37906
|
139 |
val subs = map (pair bdv) c''
|
neuper@37906
|
140 |
in if asm = [] then (all_results, [])
|
neuper@37906
|
141 |
else ((apfst ((list2isalist bool) o flat)) o
|
neuper@37906
|
142 |
(apsnd flat) o split_list o (map check)) subs end;
|
neuper@37906
|
143 |
(* 20.5.03
|
neuper@37906
|
144 |
> val all_results = str2term "[x=a+b,x=b,x=3]";
|
neuper@37906
|
145 |
> val bdv = str2term "x";
|
neuper@37906
|
146 |
> val asm = str2term "(x ~= a) & (x ~= b)";
|
neuper@37906
|
147 |
> val erls = e_rls;
|
neuper@37906
|
148 |
> val (t, ts) = check_elementwise thy erls all_results (bdv, asm);
|
neuper@38015
|
149 |
> term2str t; tracing(terms2str ts);
|
neuper@37906
|
150 |
val it = "[x = a + b, x = b, x = c]" : string
|
neuper@37906
|
151 |
["a + b ~= a & a + b ~= b","b ~= a & b ~= b","c ~= a & c ~= b"]
|
neuper@37906
|
152 |
... with appropriate erls this should be:
|
neuper@37906
|
153 |
val it = "[x = a + b, x = c]" : string
|
neuper@37906
|
154 |
["b ~= 0 & a ~= 0", "3 ~= a & 3 ~= b"]
|
neuper@37906
|
155 |
////// because b ~= b False*)
|
neuper@37906
|
156 |
|
neuper@37906
|
157 |
|
neuper@37906
|
158 |
|
neuper@37906
|
159 |
(*before 5.03-----
|
neuper@37906
|
160 |
> val ct = "((#0 <= #18 & #0 <= sqrt (#5 + #3) + sqrt (#5 - #3)) &\
|
neuper@37906
|
161 |
\ #0 <= #25 + #-1 * #3 ^^^ #2) & #0 <= #4";
|
neuper@38050
|
162 |
> val SOME(ct',_) = rewrite_set "Isac" false "eval_rls" ct;
|
neuper@41928
|
163 |
val ct' = "HOL.True" : cterm'
|
neuper@37906
|
164 |
|
neuper@37906
|
165 |
> val ct = "((#0 <= #18 & #0 <= sqrt (#5 + #-3) + sqrt (#5 - #-3)) &\
|
neuper@37906
|
166 |
\ #0 <= #25 + #-1 * #-3 ^^^ #2) & #0 <= #4";
|
neuper@38050
|
167 |
> val SOME(ct',_) = rewrite_set "Isac" false "eval_rls" ct;
|
neuper@41928
|
168 |
val ct' = "HOL.True" : cterm'
|
neuper@37906
|
169 |
|
neuper@37906
|
170 |
|
wneuper@59186
|
171 |
> val const = (Thm.term_of o the o (parse thy)) "(#3::real)";
|
neuper@37906
|
172 |
> val pred' = subst_atomic [(bdv,const)] pred;
|
neuper@37906
|
173 |
|
neuper@37906
|
174 |
|
wneuper@59186
|
175 |
> val consts = (Thm.term_of o the o (parse thy)) "[x = #-3, x = #3]";
|
wneuper@59186
|
176 |
> val bdv = (Thm.term_of o the o (parse thy)) "(x::real)";
|
wneuper@59186
|
177 |
> val pred = (Thm.term_of o the o (parse thy))
|
neuper@37906
|
178 |
"((#0 <= #18 & #0 <= sqrt (#5 + x) + sqrt (#5 - x)) & #0 <= #25 + #-1 * x ^^^ #2) & #0 <= #4";
|
neuper@37906
|
179 |
> val ttt = check_elementwise thy consts (bdv, pred);
|
wneuper@59184
|
180 |
> (Thm.global_cterm_of thy) ttt;
|
neuper@37906
|
181 |
val it = "[x = #-3, x = #3]" : cterm
|
neuper@37906
|
182 |
|
wneuper@59186
|
183 |
> val consts = (Thm.term_of o the o (parse thy)) "[x = #4]";
|
wneuper@59186
|
184 |
> val bdv = (Thm.term_of o the o (parse thy)) "(x::real)";
|
wneuper@59186
|
185 |
> val pred = (Thm.term_of o the o (parse thy))
|
neuper@37906
|
186 |
"#0 <= sqrt x + sqrt (#5 + x) & #0 <= #9 + #4 * x & #0 <= x ^^^ #2 + #5 * x & #0 <= #2 + x";
|
neuper@37906
|
187 |
> val ttt = check_elementwise thy consts (bdv,pred);
|
wneuper@59184
|
188 |
> (Thm.global_cterm_of thy) ttt;
|
neuper@37906
|
189 |
val it = "[x = #4]" : cterm
|
neuper@37906
|
190 |
|
wneuper@59186
|
191 |
> val consts = (Thm.term_of o the o (parse thy)) "[x = #-12 // #5]";
|
wneuper@59186
|
192 |
> val bdv = (Thm.term_of o the o (parse thy)) "(x::real)";
|
wneuper@59186
|
193 |
> val pred = (Thm.term_of o the o (parse thy))
|
neuper@37906
|
194 |
" #0 <= sqrt x + sqrt (#-3 + x) & #0 <= #9 + #4 * x & #0 <= x ^^^ #2 + #-3 * x & #0 <= #6 + x";
|
neuper@37906
|
195 |
> val ttt = check_elementwise thy consts (bdv,pred);
|
wneuper@59184
|
196 |
> (Thm.global_cterm_of thy) ttt;
|
neuper@37906
|
197 |
val it = "[]" : cterm*)
|
neuper@37906
|
198 |
|
neuper@37906
|
199 |
|
neuper@37906
|
200 |
(* 14.1.01: for Tac-dummies in root-equ only: skip str until "("*)
|
neuper@37906
|
201 |
fun split_dummy str =
|
neuper@37906
|
202 |
let fun scan s' [] = (implode s', "")
|
neuper@37906
|
203 |
| scan s' (s::ss) = if s=" " then (implode s', implode ss)
|
neuper@37906
|
204 |
else scan (s'@[s]) ss;
|
neuper@40836
|
205 |
in ((scan []) o Symbol.explode) str end;
|
neuper@37906
|
206 |
(* split_dummy "subproblem_equation_dummy (x=-#5//#12)";
|
neuper@37906
|
207 |
val it = ("subproblem_equation_dummy","(x=-#5//#12)") : string * string
|
neuper@37906
|
208 |
> split_dummy "x=-#5//#12";
|
neuper@37906
|
209 |
val it = ("x=-#5//#12","") : string * string*)
|
neuper@37906
|
210 |
|
neuper@37906
|
211 |
|
neuper@37906
|
212 |
|
neuper@37906
|
213 |
|
neuper@37906
|
214 |
(*.applicability of a tacic wrt. a calc-state (ptree,pos').
|
neuper@41980
|
215 |
additionally used by next_tac in the script-interpreter for script-tacs.
|
neuper@37906
|
216 |
tests for applicability are so expensive, that results (rewrites!)
|
neuper@37906
|
217 |
are kept in the return-value of 'type tac_'.
|
neuper@37906
|
218 |
.*)
|
wneuper@59265
|
219 |
fun applicable_in (_:pos') _ (Init_Proof (ct', spec)) = Chead.Appl (Init_Proof' (ct', spec))
|
neuper@37906
|
220 |
|
neuper@37906
|
221 |
| applicable_in (p,p_) pt Model_Problem =
|
neuper@41975
|
222 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
223 |
then Chead.Notappl ((tac2str Model_Problem) ^ " not for pos " ^ (pos'2str (p,p_)))
|
neuper@41975
|
224 |
else
|
neuper@41975
|
225 |
let
|
neuper@41975
|
226 |
val (PblObj{origin=(_,(_,pI',_),_),...}) = get_obj I pt p
|
wneuper@59269
|
227 |
val {ppc,...} = Specify.get_pbt pI'
|
wneuper@59266
|
228 |
val pbl = Ctree.init_pbl ppc
|
wneuper@59265
|
229 |
in Chead.Appl (Model_Problem' (pI', pbl, [])) end
|
neuper@41975
|
230 |
|
neuper@37906
|
231 |
| applicable_in (p,p_) pt (Refine_Tacitly pI) =
|
neuper@41975
|
232 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
233 |
then Chead.Notappl ((tac2str (Refine_Tacitly pI)) ^ " not for pos " ^ (pos'2str (p,p_)))
|
neuper@41975
|
234 |
else
|
neuper@41975
|
235 |
let
|
neuper@41975
|
236 |
val (PblObj {origin = (oris, (dI',_,_),_), ...}) = get_obj I pt p;
|
wneuper@59269
|
237 |
val opt = Specify.refine_ori oris pI;
|
neuper@41975
|
238 |
in case opt of
|
neuper@41975
|
239 |
SOME pblID =>
|
wneuper@59265
|
240 |
Chead.Appl (Refine_Tacitly' (pI, pblID,
|
neuper@41975
|
241 |
e_domID, e_metID, [](*filled in specify*)))
|
wneuper@59265
|
242 |
| NONE => Chead.Notappl ((tac2str (Refine_Tacitly pI)) ^ " not applicable")
|
neuper@41975
|
243 |
end
|
neuper@41975
|
244 |
|
neuper@37906
|
245 |
| applicable_in (p,p_) pt (Refine_Problem pI) =
|
neuper@37906
|
246 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
247 |
then Chead.Notappl ((tac2str (Refine_Problem pI))^
|
neuper@37906
|
248 |
" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
249 |
else
|
neuper@37906
|
250 |
let val (PblObj {origin=(_,(dI,_,_),_),spec=(dI',_,_),
|
neuper@37906
|
251 |
probl=itms, ...}) = get_obj I pt p;
|
neuper@37906
|
252 |
val thy = if dI' = e_domID then dI else dI';
|
wneuper@59269
|
253 |
val rfopt = Specify.refine_pbl (assoc_thy thy) pI itms;
|
neuper@37906
|
254 |
in case rfopt of
|
wneuper@59265
|
255 |
NONE => Chead.Notappl ((tac2str (Refine_Problem pI))^" not applicable")
|
neuper@37926
|
256 |
| SOME (rf as (pI',_)) =>
|
neuper@37906
|
257 |
if pI' = pI
|
wneuper@59265
|
258 |
then Chead.Notappl ((tac2str (Refine_Problem pI))^" not applicable")
|
wneuper@59265
|
259 |
else Chead.Appl (Refine_Problem' rf)
|
neuper@37906
|
260 |
end
|
neuper@37906
|
261 |
|
neuper@37906
|
262 |
(*the specify-tacs have cterm' instead term:
|
neuper@37906
|
263 |
parse+error here!!!: see appl_add*)
|
neuper@37906
|
264 |
| applicable_in (p,p_) pt (Add_Given ct') =
|
neuper@37906
|
265 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
266 |
then Chead.Notappl ((tac2str (Add_Given ct'))^
|
neuper@37906
|
267 |
" not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
268 |
else Chead.Appl (Add_Given' (ct', [(*filled in specify_additem*)]))
|
neuper@37906
|
269 |
(*Add_.. should reject (dsc //) (see fmz=[] in sqrt*)
|
neuper@37906
|
270 |
|
neuper@37906
|
271 |
| applicable_in (p,p_) pt (Del_Given ct') =
|
neuper@37906
|
272 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
273 |
then Chead.Notappl ((tac2str (Del_Given ct'))^
|
neuper@37906
|
274 |
" not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
275 |
else Chead.Appl (Del_Given' ct')
|
neuper@37906
|
276 |
|
neuper@37906
|
277 |
| applicable_in (p,p_) pt (Add_Find ct') =
|
neuper@37906
|
278 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
279 |
then Chead.Notappl ((tac2str (Add_Find ct'))^
|
neuper@37906
|
280 |
" not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
281 |
else Chead.Appl (Add_Find' (ct', [(*filled in specify_additem*)]))
|
neuper@37906
|
282 |
|
neuper@37906
|
283 |
| applicable_in (p,p_) pt (Del_Find ct') =
|
neuper@37906
|
284 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
285 |
then Chead.Notappl ((tac2str (Del_Find ct'))^
|
neuper@37906
|
286 |
" not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
287 |
else Chead.Appl (Del_Find' ct')
|
neuper@37906
|
288 |
|
neuper@37906
|
289 |
| applicable_in (p,p_) pt (Add_Relation ct') =
|
neuper@37906
|
290 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
291 |
then Chead.Notappl ((tac2str (Add_Relation ct'))^
|
neuper@37906
|
292 |
" not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
293 |
else Chead.Appl (Add_Relation' (ct', [(*filled in specify_additem*)]))
|
neuper@37906
|
294 |
|
neuper@37906
|
295 |
| applicable_in (p,p_) pt (Del_Relation ct') =
|
neuper@37906
|
296 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
297 |
then Chead.Notappl ((tac2str (Del_Relation ct'))^
|
neuper@37906
|
298 |
" not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
299 |
else Chead.Appl (Del_Relation' ct')
|
neuper@37906
|
300 |
|
neuper@37906
|
301 |
| applicable_in (p,p_) pt (Specify_Theory dI) =
|
neuper@37906
|
302 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
303 |
then Chead.Notappl ((tac2str (Specify_Theory dI))^
|
neuper@37906
|
304 |
" not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
305 |
else Chead.Appl (Specify_Theory' dI)
|
neuper@37906
|
306 |
(* val (p,p_) = p; val Specify_Problem pID = m;
|
neuper@37906
|
307 |
val Specify_Problem pID = m;
|
neuper@37906
|
308 |
*)
|
neuper@37906
|
309 |
| applicable_in (p,p_) pt (Specify_Problem pID) =
|
neuper@37906
|
310 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
311 |
then Chead.Notappl ((tac2str (Specify_Problem pID))^
|
neuper@37906
|
312 |
" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
313 |
else
|
neuper@37906
|
314 |
let val (PblObj {origin=(oris,(dI,pI,_),_),spec=(dI',pI',_),
|
neuper@37906
|
315 |
probl=itms, ...}) = get_obj I pt p;
|
neuper@37906
|
316 |
val thy = assoc_thy (if dI' = e_domID then dI else dI');
|
wneuper@59269
|
317 |
val {ppc,where_,prls,...} = Specify.get_pbt pID;
|
neuper@37906
|
318 |
val pbl = if pI'=e_pblID andalso pI=e_pblID
|
wneuper@59266
|
319 |
then (false, (Ctree.init_pbl ppc, []))
|
wneuper@59269
|
320 |
else Specify.match_itms_oris thy itms (ppc,where_,prls) oris;
|
wneuper@59265
|
321 |
in Chead.Appl (Specify_Problem' (pID, pbl)) end
|
neuper@37906
|
322 |
(* val Specify_Method mID = nxt; val (p,p_) = p;
|
neuper@37906
|
323 |
*)
|
neuper@37906
|
324 |
| applicable_in (p,p_) pt (Specify_Method mID) =
|
neuper@37906
|
325 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
326 |
then Chead.Notappl ((tac2str (Specify_Method mID))^
|
neuper@37906
|
327 |
" not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
328 |
else Chead.Appl (Specify_Method' (mID,[(*filled in specify*)],
|
neuper@37906
|
329 |
[(*filled in specify*)]))
|
neuper@37906
|
330 |
|
neuper@37906
|
331 |
| applicable_in (p,p_) pt (Apply_Method mI) =
|
neuper@41992
|
332 |
if not (is_pblobj (get_obj I pt p)) orelse p_ = Res
|
wneuper@59265
|
333 |
then Chead.Notappl ((tac2str (Apply_Method mI)) ^ " not for pos " ^ (pos'2str (p,p_)))
|
neuper@41992
|
334 |
else
|
neuper@41992
|
335 |
let
|
neuper@41992
|
336 |
val (PblObj{origin = (_, (dI, pI, _), _), probl, ctxt, ...}) = get_obj I pt p;
|
wneuper@59269
|
337 |
val {where_, ...} = Specify.get_pbt pI
|
neuper@41992
|
338 |
val pres = map (mk_env probl |> subst_atomic) where_
|
neuper@41992
|
339 |
val ctxt =
|
neuper@41992
|
340 |
if is_e_ctxt ctxt
|
neuper@48761
|
341 |
then assoc_thy dI |> Proof_Context.init_global |> insert_assumptions pres
|
neuper@41992
|
342 |
else ctxt
|
neuper@42018
|
343 |
(*TODO.WN110416 here do evalprecond according to fun check_preconds'
|
wneuper@59265
|
344 |
and then decide on Chead.Notappl/Appl accordingly once more.
|
neuper@42018
|
345 |
Implement after all tests are running, since this changes
|
neuper@42018
|
346 |
overall system behavior*)
|
wneuper@59265
|
347 |
in Chead.Appl (Apply_Method' (mI, NONE, e_istate (*filled in solve*), ctxt)) end
|
neuper@37906
|
348 |
|
neuper@37906
|
349 |
| applicable_in (p,p_) pt (Check_Postcond pI) =
|
neuper@42018
|
350 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
351 |
then Chead.Notappl ((tac2str (Check_Postcond pI)) ^ " not for pos "^(pos'2str (p,p_)))
|
wneuper@59265
|
352 |
else Chead.Appl (Check_Postcond' (pI, (e_term, [(*fun solve assignes the returnvalue of scr*)])))
|
neuper@37906
|
353 |
|
neuper@37906
|
354 |
(*these are always applicable*)
|
wneuper@59265
|
355 |
| applicable_in (p,p_) _ (Take str) = Chead.Appl (Take' (str2term str))
|
wneuper@59265
|
356 |
| applicable_in (p,p_) _ (Free_Solve) = Chead.Appl (Free_Solve')
|
neuper@37906
|
357 |
|
wneuper@59250
|
358 |
| applicable_in (p, p_) pt (m as Rewrite_Inst (subs, thm'')) =
|
neuper@42394
|
359 |
if member op = [Pbl, Met] p_
|
wneuper@59265
|
360 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@42394
|
361 |
else
|
neuper@42394
|
362 |
let
|
neuper@42394
|
363 |
val pp = par_pblobj pt p;
|
neuper@42394
|
364 |
val thy' = (get_obj g_domID pt pp): theory';
|
neuper@42394
|
365 |
val thy = assoc_thy thy';
|
wneuper@59269
|
366 |
val {rew_ord' = ro', erls = erls, ...} = Specify.get_met (get_obj g_metID pt pp);
|
neuper@42394
|
367 |
val (f, p) = case p_ of (*p 12.4.00 unnecessary*)
|
neuper@42394
|
368 |
Frm => (get_obj g_form pt p, p)
|
neuper@42394
|
369 |
| Res => ((fst o (get_obj g_result pt)) p, lev_on p)
|
neuper@42394
|
370 |
| _ => error ("applicable_in: call by " ^ pos'2str (p,p_));
|
neuper@42394
|
371 |
in
|
neuper@42394
|
372 |
let
|
neuper@42394
|
373 |
val subst = subs2subst thy subs;
|
neuper@42394
|
374 |
val subs' = subst2subs' subst;
|
wneuper@59253
|
375 |
in case rewrite_inst_ thy (assoc_rew_ord ro') erls false subst (snd thm'') f of
|
neuper@42394
|
376 |
SOME (f',asm) =>
|
wneuper@59265
|
377 |
Chead.Appl (Rewrite_Inst' (thy', ro', erls, false, subst, thm'', f, (f', asm)))
|
wneuper@59265
|
378 |
| NONE => Chead.Notappl ((fst thm'')^" not applicable")
|
neuper@42394
|
379 |
end
|
wneuper@59265
|
380 |
handle _ => Chead.Notappl ("syntax error in "^(subs2str subs))
|
neuper@42394
|
381 |
end
|
neuper@37906
|
382 |
|
wneuper@59250
|
383 |
| applicable_in (p,p_) pt (m as Rewrite thm'') =
|
neuper@37935
|
384 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
385 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
386 |
else
|
wneuper@59250
|
387 |
let val (msg,thy',ro,rls',(*put_asm*)_)= from_pblobj_or_detail_thm thm'' p pt;
|
neuper@37906
|
388 |
val thy = assoc_thy thy';
|
neuper@37906
|
389 |
val f = case p_ of
|
neuper@37906
|
390 |
Frm => get_obj g_form pt p
|
neuper@37906
|
391 |
| Res => (fst o (get_obj g_result pt)) p
|
neuper@38031
|
392 |
| _ => error ("applicable_in Rewrite: call by "^
|
neuper@37906
|
393 |
(pos'2str (p,p_)));
|
neuper@37906
|
394 |
in if msg = "OK"
|
neuper@37906
|
395 |
then
|
wneuper@59253
|
396 |
case rewrite_ thy (assoc_rew_ord ro) rls' false (snd thm'') f of
|
wneuper@59265
|
397 |
SOME (f',asm) => Chead.Appl (Rewrite' (thy', ro, rls', false, thm'', f, (f', asm)))
|
wneuper@59265
|
398 |
| NONE => Chead.Notappl ("'" ^ fst thm'' ^"' not applicable")
|
wneuper@59265
|
399 |
else Chead.Notappl msg
|
neuper@37906
|
400 |
end
|
neuper@37906
|
401 |
|
wneuper@59250
|
402 |
| applicable_in (p,p_) pt (m as Rewrite_Asm thm'') =
|
neuper@37935
|
403 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
404 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
405 |
else
|
neuper@37906
|
406 |
let
|
neuper@37906
|
407 |
val pp = par_pblobj pt p;
|
neuper@37906
|
408 |
val thy' = (get_obj g_domID pt pp):theory';
|
neuper@37906
|
409 |
val thy = assoc_thy thy';
|
wneuper@59269
|
410 |
val {rew_ord'=ro',erls=erls,...} = Specify.get_met (get_obj g_metID pt pp);
|
neuper@37906
|
411 |
(*val put_asm = true;*)
|
wneuper@59250
|
412 |
val (f, _) = case p_ of
|
neuper@37906
|
413 |
Frm => (get_obj g_form pt p, p)
|
neuper@37906
|
414 |
| Res => ((fst o (get_obj g_result pt)) p, lev_on p)
|
neuper@38031
|
415 |
| _ => error ("applicable_in: call by "^
|
neuper@37906
|
416 |
(pos'2str (p,p_)));
|
wneuper@59253
|
417 |
in case rewrite_ thy (assoc_rew_ord ro') erls false (snd thm'') f of
|
wneuper@59265
|
418 |
SOME (f',asm) => Chead.Appl (
|
wneuper@59253
|
419 |
Rewrite' (thy', ro', erls, false, thm'', f, (f', asm)))
|
wneuper@59265
|
420 |
| NONE => Chead.Notappl ("'" ^ fst thm'' ^ "' not applicable") end
|
neuper@37906
|
421 |
|
neuper@37906
|
422 |
| applicable_in (p,p_) pt (m as Detail_Set_Inst (subs, rls)) =
|
neuper@37935
|
423 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
424 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
425 |
else
|
neuper@37906
|
426 |
let
|
neuper@37906
|
427 |
val pp = par_pblobj pt p;
|
neuper@37906
|
428 |
val thy' = (get_obj g_domID pt pp):theory';
|
neuper@37906
|
429 |
val thy = assoc_thy thy';
|
wneuper@59269
|
430 |
val {rew_ord'=ro',...} = Specify.get_met (get_obj g_metID pt pp);
|
neuper@37906
|
431 |
val f = case p_ of Frm => get_obj g_form pt p
|
neuper@37906
|
432 |
| Res => (fst o (get_obj g_result pt)) p
|
neuper@38031
|
433 |
| _ => error ("applicable_in: call by "^
|
neuper@37906
|
434 |
(pos'2str (p,p_)));
|
neuper@37906
|
435 |
in
|
neuper@37906
|
436 |
let val subst = subs2subst thy subs
|
neuper@37906
|
437 |
val subs' = subst2subs' subst
|
neuper@37906
|
438 |
in case rewrite_set_inst_ thy false subst (assoc_rls rls) f of
|
wneuper@59265
|
439 |
SOME (f',asm) => Chead.Appl (
|
neuper@37906
|
440 |
Detail_Set_Inst' (thy',false,subst,assoc_rls rls, f, (f', asm)))
|
wneuper@59265
|
441 |
| NONE => Chead.Notappl (rls^" not applicable") end
|
wneuper@59265
|
442 |
handle _ => Chead.Notappl ("syntax error in "^(subs2str subs)) end
|
neuper@37906
|
443 |
|
neuper@37906
|
444 |
| applicable_in (p,p_) pt (m as Rewrite_Set_Inst (subs, rls)) =
|
neuper@37935
|
445 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
446 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
447 |
else
|
neuper@37906
|
448 |
let
|
neuper@37906
|
449 |
val pp = par_pblobj pt p;
|
neuper@37906
|
450 |
val thy' = (get_obj g_domID pt pp):theory';
|
neuper@37906
|
451 |
val thy = assoc_thy thy';
|
wneuper@59269
|
452 |
val {rew_ord'=ro',(*asm_rls=asm_rls,*)...} = Specify.get_met (get_obj g_metID pt pp);
|
neuper@37906
|
453 |
val (f,p) = case p_ of (*p 12.4.00 unnecessary*)
|
neuper@37906
|
454 |
Frm => (get_obj g_form pt p, p)
|
neuper@37906
|
455 |
| Res => ((fst o (get_obj g_result pt)) p, lev_on p)
|
neuper@38031
|
456 |
| _ => error ("applicable_in: call by "^
|
neuper@37906
|
457 |
(pos'2str (p,p_)));
|
neuper@37906
|
458 |
in
|
neuper@37906
|
459 |
let val subst = subs2subst thy subs;
|
neuper@37906
|
460 |
val subs' = subst2subs' subst;
|
neuper@37906
|
461 |
in case rewrite_set_inst_ thy (*put_asm*)false subst (assoc_rls rls) f of
|
wneuper@59265
|
462 |
SOME (f',asm) => Chead.Appl (
|
neuper@37906
|
463 |
Rewrite_Set_Inst' (thy',(*put_asm*)false,subst,assoc_rls rls, f, (f', asm)))
|
wneuper@59265
|
464 |
| NONE => Chead.Notappl (rls^" not applicable") end
|
wneuper@59265
|
465 |
handle _ => Chead.Notappl ("syntax error in "^(subs2str subs)) end
|
neuper@37906
|
466 |
|
neuper@37906
|
467 |
| applicable_in (p,p_) pt (m as Rewrite_Set rls) =
|
neuper@37935
|
468 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
469 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
470 |
else
|
neuper@37906
|
471 |
let
|
neuper@37906
|
472 |
val pp = par_pblobj pt p;
|
neuper@37906
|
473 |
val thy' = (get_obj g_domID pt pp):theory';
|
neuper@37906
|
474 |
val (f,p) = case p_ of (*p 12.4.00 unnecessary*)
|
neuper@37906
|
475 |
Frm => (get_obj g_form pt p, p)
|
neuper@37906
|
476 |
| Res => ((fst o (get_obj g_result pt)) p, lev_on p)
|
neuper@38031
|
477 |
| _ => error ("applicable_in: call by "^
|
neuper@37906
|
478 |
(pos'2str (p,p_)));
|
neuper@37930
|
479 |
in case rewrite_set_ (assoc_thy thy') false (assoc_rls rls) f of
|
neuper@37926
|
480 |
SOME (f',asm) =>
|
neuper@38015
|
481 |
((*tracing("#.# applicable_in Rewrite_Set,2f'= "^f');*)
|
wneuper@59265
|
482 |
Chead.Appl (Rewrite_Set' (thy',(*put_asm*)false,assoc_rls rls, f, (f', asm)))
|
neuper@37906
|
483 |
)
|
wneuper@59265
|
484 |
| NONE => Chead.Notappl (rls^" not applicable") end
|
neuper@37906
|
485 |
|
neuper@37906
|
486 |
| applicable_in (p,p_) pt (m as Detail_Set rls) =
|
neuper@37935
|
487 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
488 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
489 |
else
|
neuper@37906
|
490 |
let val pp = par_pblobj pt p
|
neuper@37906
|
491 |
val thy' = (get_obj g_domID pt pp):theory'
|
neuper@37906
|
492 |
val f = case p_ of
|
neuper@37906
|
493 |
Frm => get_obj g_form pt p
|
neuper@37906
|
494 |
| Res => (fst o (get_obj g_result pt)) p
|
neuper@38031
|
495 |
| _ => error ("applicable_in: call by "^
|
neuper@37906
|
496 |
(pos'2str (p,p_)));
|
neuper@37906
|
497 |
in case rewrite_set_ (assoc_thy thy') false (assoc_rls rls) f of
|
neuper@37926
|
498 |
SOME (f',asm) =>
|
wneuper@59265
|
499 |
Chead.Appl (Detail_Set' (thy',false,assoc_rls rls, f, (f',asm)))
|
wneuper@59265
|
500 |
| NONE => Chead.Notappl (rls^" not applicable") end
|
neuper@37906
|
501 |
|
neuper@37906
|
502 |
|
neuper@37906
|
503 |
| applicable_in p pt (End_Ruleset) =
|
neuper@38031
|
504 |
error ("applicable_in: not impl. for "^
|
neuper@37906
|
505 |
(tac2str End_Ruleset))
|
neuper@37906
|
506 |
|
neuper@37906
|
507 |
(* val ((p,p_), pt, (m as Calculate op_)) = (p, pt, m);
|
neuper@37906
|
508 |
*)
|
neuper@37906
|
509 |
| applicable_in (p,p_) pt (m as Calculate op_) =
|
neuper@37935
|
510 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
511 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
512 |
else
|
neuper@37906
|
513 |
let
|
neuper@37906
|
514 |
val (msg,thy',isa_fn) = from_pblobj_or_detail_calc op_ p pt;
|
neuper@37906
|
515 |
val f = case p_ of
|
neuper@37906
|
516 |
Frm => get_obj g_form pt p
|
neuper@37906
|
517 |
| Res => (fst o (get_obj g_result pt)) p
|
neuper@37906
|
518 |
in if msg = "OK" then
|
neuper@37906
|
519 |
case calculate_ (assoc_thy thy') isa_fn f of
|
neuper@37926
|
520 |
SOME (f', (id, thm)) =>
|
wneuper@59265
|
521 |
Chead.Appl (Calculate' (thy',op_, f, (f', (id, string_of_thmI thm))))
|
wneuper@59265
|
522 |
| NONE => Chead.Notappl ("'calculate "^op_^"' not applicable")
|
wneuper@59265
|
523 |
else Chead.Notappl msg
|
neuper@37906
|
524 |
end
|
neuper@37906
|
525 |
|
neuper@37906
|
526 |
(*Substitute combines two different kind of "substitution":
|
neuper@37906
|
527 |
(1) subst_atomic: for ?a..?z
|
neuper@37906
|
528 |
(2) Pattern.match: for solving equational systems
|
neuper@37906
|
529 |
(which raises exn for ?a..?z)*)
|
neuper@37906
|
530 |
| applicable_in (p,p_) pt (m as Substitute sube) =
|
neuper@42360
|
531 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
532 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@42360
|
533 |
else
|
neuper@42360
|
534 |
let
|
neuper@42360
|
535 |
val pp = par_pblobj pt p
|
neuper@42360
|
536 |
val thy = assoc_thy (get_obj g_domID pt pp)
|
neuper@42360
|
537 |
val f = case p_ of
|
neuper@42360
|
538 |
Frm => get_obj g_form pt p
|
neuper@42360
|
539 |
| Res => (fst o (get_obj g_result pt)) p
|
wneuper@59269
|
540 |
val {rew_ord',erls,...} = Specify.get_met (get_obj g_metID pt pp)
|
neuper@42360
|
541 |
val subte = sube2subte sube
|
neuper@42360
|
542 |
val subst = sube2subst thy sube
|
neuper@42360
|
543 |
val ro = assoc_rew_ord rew_ord'
|
neuper@42360
|
544 |
in
|
neuper@42360
|
545 |
if foldl and_ (true, map contains_Var subte)
|
neuper@42360
|
546 |
(*1*)
|
neuper@42360
|
547 |
then
|
neuper@42360
|
548 |
let val f' = subst_atomic subst f
|
wneuper@59265
|
549 |
in if f = f' then Chead.Notappl (sube2str sube^" not applicable")
|
wneuper@59265
|
550 |
else Chead.Appl (Substitute' (ro, erls, subte, f, f'))
|
neuper@42360
|
551 |
end
|
neuper@42360
|
552 |
(*2*)
|
neuper@42360
|
553 |
else
|
neuper@42360
|
554 |
case rewrite_terms_ thy ro erls subte f of
|
wneuper@59265
|
555 |
SOME (f', _) => Chead.Appl (Substitute' (ro, erls, subte, f, f'))
|
wneuper@59265
|
556 |
| NONE => Chead.Notappl (sube2str sube^" not applicable")
|
neuper@42360
|
557 |
end
|
neuper@37906
|
558 |
|
neuper@37906
|
559 |
| applicable_in p pt (Apply_Assumption cts') =
|
neuper@41993
|
560 |
(error ("applicable_in: not impl. for " ^ (tac2str (Apply_Assumption cts'))))
|
neuper@37906
|
561 |
|
neuper@37906
|
562 |
(*'logical' applicability wrt. script in locate: Inconsistent?*)
|
neuper@37906
|
563 |
| applicable_in (p,p_) pt (m as Take ct') =
|
neuper@41993
|
564 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
565 |
then Chead.Notappl (tac2str m ^ " not for pos " ^ pos'2str (p,p_))
|
neuper@41993
|
566 |
else
|
neuper@41993
|
567 |
let val thy' = get_obj g_domID pt (par_pblobj pt p);
|
neuper@41993
|
568 |
in (case parseNEW (assoc_thy thy' |> thy2ctxt) ct' of
|
wneuper@59265
|
569 |
SOME ct => Chead.Appl (Take' ct)
|
wneuper@59265
|
570 |
| NONE => Chead.Notappl ("syntax error in " ^ ct'))
|
neuper@41993
|
571 |
end
|
neuper@37906
|
572 |
|
neuper@37906
|
573 |
| applicable_in p pt (Take_Inst ct') =
|
neuper@41993
|
574 |
error ("applicable_in: not impl. for " ^ tac2str (Take_Inst ct'))
|
neuper@37906
|
575 |
| applicable_in p pt (Group (con, ints)) =
|
neuper@41993
|
576 |
error ("applicable_in: not impl. for " ^ tac2str (Group (con, ints)))
|
neuper@37906
|
577 |
|
neuper@37906
|
578 |
| applicable_in (p,p_) pt (m as Subproblem (domID, pblID)) =
|
neuper@37935
|
579 |
if member op = [Pbl,Met] p_
|
neuper@41993
|
580 |
then (*maybe Apply_Method has already been done FIXME.WN150511: declare_constraints*)
|
neuper@41993
|
581 |
case get_obj g_env pt p of
|
neuper@41993
|
582 |
SOME is =>
|
wneuper@59265
|
583 |
Chead.Appl (Subproblem' ((domID, pblID, e_metID), [],
|
neuper@41993
|
584 |
e_term, [], e_ctxt(*FIXME.WN150511*), subpbl domID pblID))
|
wneuper@59265
|
585 |
| NONE => Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
586 |
else (*somewhere later in the script*)
|
wneuper@59265
|
587 |
Chead.Appl (Subproblem' ((domID, pblID, e_metID), [],
|
neuper@41993
|
588 |
e_term, [], e_ctxt, subpbl domID pblID))
|
neuper@37906
|
589 |
|
neuper@37906
|
590 |
| applicable_in p pt (End_Subproblem) =
|
neuper@41993
|
591 |
error ("applicable_in: not impl. for " ^ tac2str End_Subproblem)
|
neuper@37906
|
592 |
| applicable_in p pt (CAScmd ct') =
|
neuper@41993
|
593 |
error ("applicable_in: not impl. for " ^ tac2str (CAScmd ct'))
|
neuper@37906
|
594 |
| applicable_in p pt (Split_And) =
|
neuper@41993
|
595 |
error ("applicable_in: not impl. for " ^ tac2str Split_And)
|
neuper@37906
|
596 |
| applicable_in p pt (Conclude_And) =
|
neuper@41993
|
597 |
error ("applicable_in: not impl. for " ^ tac2str Conclude_And)
|
neuper@37906
|
598 |
| applicable_in p pt (Split_Or) =
|
neuper@41993
|
599 |
error ("applicable_in: not impl. for " ^ tac2str Split_Or)
|
neuper@37906
|
600 |
| applicable_in p pt (Conclude_Or) =
|
neuper@41993
|
601 |
error ("applicable_in: not impl. for " ^ tac2str Conclude_Or)
|
neuper@37906
|
602 |
|
neuper@37906
|
603 |
| applicable_in (p,p_) pt (Begin_Trans) =
|
neuper@37906
|
604 |
let
|
neuper@37906
|
605 |
val (f,p) = case p_ of (*p 12.4.00 unnecessary*)
|
neuper@37906
|
606 |
(*_____ implizit Take in gen*)
|
neuper@37906
|
607 |
Frm => (get_obj g_form pt p, (lev_on o lev_dn) p)
|
neuper@37906
|
608 |
| Res => ((fst o (get_obj g_result pt)) p, (lev_on o lev_dn o lev_on) p)
|
neuper@38031
|
609 |
| _ => error ("applicable_in: call by "^
|
neuper@37906
|
610 |
(pos'2str (p,p_)));
|
neuper@37906
|
611 |
val thy' = get_obj g_domID pt (par_pblobj pt p);
|
wneuper@59265
|
612 |
in (Chead.Appl (Begin_Trans' f))
|
neuper@38031
|
613 |
handle _ => error ("applicable_in: Begin_Trans finds \
|
neuper@37906
|
614 |
\syntaxerror in '"^(term2str f)^"'") end
|
neuper@37906
|
615 |
|
neuper@37906
|
616 |
(*TODO: check parent branches*)
|
neuper@37906
|
617 |
| applicable_in (p,p_) pt (End_Trans) =
|
neuper@37906
|
618 |
let val thy' = get_obj g_domID pt (par_pblobj pt p);
|
neuper@37906
|
619 |
in if p_ = Res
|
wneuper@59265
|
620 |
then Chead.Appl (End_Trans' (get_obj g_result pt p))
|
wneuper@59265
|
621 |
else Chead.Notappl "'End_Trans' is not applicable at the beginning of a transitive sequence"
|
neuper@42394
|
622 |
(*TODO: check parent branches*)
|
neuper@37906
|
623 |
end
|
neuper@42394
|
624 |
| applicable_in p pt (Begin_Sequ) =
|
neuper@42394
|
625 |
error ("applicable_in: not impl. for " ^ tac2str (Begin_Sequ))
|
neuper@42394
|
626 |
| applicable_in p pt (End_Sequ) =
|
neuper@42394
|
627 |
error ("applicable_in: not impl. for " ^ tac2str (End_Sequ))
|
neuper@42394
|
628 |
| applicable_in p pt (Split_Intersect) =
|
neuper@42394
|
629 |
error ("applicable_in: not impl. for " ^ tac2str (Split_Intersect))
|
neuper@42394
|
630 |
| applicable_in p pt (End_Intersect) =
|
neuper@42394
|
631 |
error ("applicable_in: not impl. for " ^ tac2str (End_Intersect))
|
neuper@37906
|
632 |
|
neuper@37906
|
633 |
| applicable_in (p,p_) pt (m as Check_elementwise pred) =
|
neuper@42394
|
634 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
635 |
then Chead.Notappl ((tac2str m)^" not for pos "^(pos'2str (p,p_)))
|
neuper@42394
|
636 |
else
|
neuper@42394
|
637 |
let
|
neuper@42394
|
638 |
val pp = par_pblobj pt p;
|
neuper@42394
|
639 |
val thy' = (get_obj g_domID pt pp):theory';
|
neuper@42394
|
640 |
val thy = assoc_thy thy'
|
neuper@42394
|
641 |
val metID = (get_obj g_metID pt pp)
|
wneuper@59269
|
642 |
val {crls,...} = Specify.get_met metID
|
neuper@42394
|
643 |
val (f,asm) = case p_ of Frm => (get_obj g_form pt p , [])
|
neuper@42394
|
644 |
| Res => get_obj g_result pt p;
|
neuper@42394
|
645 |
val vp = (thy2ctxt thy, pred) |-> parseNEW |> the |> mk_set thy pt p f;
|
neuper@42394
|
646 |
in case f of
|
neuper@42394
|
647 |
Const ("List.list.Cons",_) $ _ $ _ =>
|
wneuper@59265
|
648 |
Chead.Appl (Check_elementwise' (f, pred, check_elementwise thy crls f vp))
|
neuper@42394
|
649 |
| Const ("Tools.UniversalList",_) =>
|
wneuper@59265
|
650 |
Chead.Appl (Check_elementwise' (f, pred, (f,asm)))
|
neuper@42394
|
651 |
| Const ("List.list.Nil",_) =>
|
wneuper@59265
|
652 |
Chead.Appl (Check_elementwise' (f, pred, (f, asm)))
|
wneuper@59265
|
653 |
| _ => Chead.Notappl ("Check_elementwise not applicable: "^(term2str f)^" should be constants")
|
neuper@42394
|
654 |
end
|
neuper@37906
|
655 |
|
neuper@37906
|
656 |
| applicable_in (p,p_) pt Or_to_List =
|
neuper@37935
|
657 |
if member op = [Pbl,Met] p_
|
wneuper@59265
|
658 |
then Chead.Notappl ((tac2str Or_to_List)^" not for pos "^(pos'2str (p,p_)))
|
neuper@37906
|
659 |
else
|
neuper@37906
|
660 |
let
|
neuper@37906
|
661 |
val pp = par_pblobj pt p;
|
neuper@37906
|
662 |
val thy' = (get_obj g_domID pt pp):theory';
|
neuper@37906
|
663 |
val thy = assoc_thy thy';
|
neuper@37906
|
664 |
val f = case p_ of
|
neuper@37906
|
665 |
Frm => get_obj g_form pt p
|
neuper@37906
|
666 |
| Res => (fst o (get_obj g_result pt)) p;
|
neuper@37906
|
667 |
in (let val ls = or2list f
|
wneuper@59265
|
668 |
in Chead.Appl (Or_to_List' (f, ls)) end)
|
wneuper@59265
|
669 |
handle _ => Chead.Notappl ("'Or_to_List' not applicable to "^(term2str f))
|
neuper@37906
|
670 |
end
|
neuper@37906
|
671 |
|
neuper@37906
|
672 |
| applicable_in p pt (Collect_Trues) =
|
neuper@38031
|
673 |
error ("applicable_in: not impl. for "^
|
neuper@37906
|
674 |
(tac2str (Collect_Trues)))
|
neuper@37906
|
675 |
|
neuper@37906
|
676 |
| applicable_in p pt (Empty_Tac) =
|
wneuper@59265
|
677 |
Chead.Notappl "Empty_Tac is not applicable"
|
neuper@37906
|
678 |
|
neuper@41933
|
679 |
| applicable_in (p,p_) pt (Tac id) =
|
neuper@37906
|
680 |
let
|
neuper@37906
|
681 |
val pp = par_pblobj pt p;
|
neuper@37906
|
682 |
val thy' = (get_obj g_domID pt pp):theory';
|
neuper@37906
|
683 |
val thy = assoc_thy thy';
|
neuper@37906
|
684 |
val f = case p_ of
|
neuper@37906
|
685 |
Frm => get_obj g_form pt p
|
neuper@41933
|
686 |
| Pbl => error "applicable_in (p,Pbl) pt (Tac id): not at Pbl"
|
neuper@37906
|
687 |
| Res => (fst o (get_obj g_result pt)) p;
|
neuper@37906
|
688 |
in case id of
|
neuper@37906
|
689 |
"subproblem_equation_dummy" =>
|
neuper@37906
|
690 |
if is_expliceq f
|
wneuper@59265
|
691 |
then Chead.Appl (Tac_ (thy, term2str f, id,
|
neuper@37906
|
692 |
"subproblem_equation_dummy ("^(term2str f)^")"))
|
wneuper@59265
|
693 |
else Chead.Notappl "applicable only to equations made explicit"
|
neuper@37906
|
694 |
| "solve_equation_dummy" =>
|
neuper@38015
|
695 |
let (*val _= tracing("### applicable_in: solve_equation_dummy: f= "
|
neuper@37906
|
696 |
^f);*)
|
neuper@37906
|
697 |
val (id',f') = split_dummy (term2str f);
|
neuper@38015
|
698 |
(*val _= tracing("### applicable_in: f'= "^f');*)
|
wneuper@59186
|
699 |
(*val _= (Thm.term_of o the o (parse thy)) f';*)
|
neuper@38015
|
700 |
(*val _= tracing"### applicable_in: solve_equation_dummy";*)
|
wneuper@59265
|
701 |
in if id' <> "subproblem_equation_dummy" then Chead.Notappl "no subproblem"
|
bonzai@41952
|
702 |
else if (thy2ctxt thy, f') |-> parseNEW |> the |> is_expliceq
|
wneuper@59265
|
703 |
then Chead.Appl (Tac_ (thy, term2str f, id, "[" ^ f' ^ "]"))
|
neuper@37906
|
704 |
else error ("applicable_in: f= " ^ f') end
|
wneuper@59265
|
705 |
| _ => Chead.Appl (Tac_ (thy, term2str f, id, term2str f)) end
|
neuper@37906
|
706 |
|
wneuper@59265
|
707 |
| applicable_in p pt End_Proof' = Chead.Appl End_Proof''
|
neuper@37906
|
708 |
|
neuper@37906
|
709 |
| applicable_in _ _ m =
|
neuper@38031
|
710 |
error ("applicable_in called for "^(tac2str m));
|
neuper@37906
|
711 |
|
neuper@37906
|
712 |
(*WN060614 unused*)
|
neuper@37906
|
713 |
fun tac2tac_ pt p m =
|
neuper@37906
|
714 |
case applicable_in p pt m of
|
wneuper@59265
|
715 |
Chead.Appl (m') => m'
|
wneuper@59265
|
716 |
| Chead.Notappl _ => error ("tac2mstp': fails with"^
|
neuper@37906
|
717 |
(tac2str m));
|
neuper@37906
|
718 |
|