agriesma@328
|
1 |
(* use"../ME/solve.sml";
|
agriesma@328
|
2 |
use"ME/solve.sml";
|
agriesma@328
|
3 |
use"solve.sml";
|
wneuper@1971
|
4 |
|
wneuper@1971
|
5 |
|
wneuper@1971
|
6 |
|
wneuper@1971
|
7 |
|
wneuper@1971
|
8 |
|
wneuper@1971
|
9 |
|
agriesma@328
|
10 |
W.N.10.12.99
|
agriesma@328
|
11 |
|
agriesma@328
|
12 |
cd ~/Isabelle/Zerlege-Isa98-1/src/HOL/
|
agriesma@328
|
13 |
/src/HOL> sml @SMLload=HOL-plus
|
agriesma@328
|
14 |
cd"~/MathEngine99/src/";
|
agriesma@328
|
15 |
use"ROOT.sml";
|
agriesma@328
|
16 |
*)
|
agriesma@328
|
17 |
|
agriesma@328
|
18 |
fun safe (ScrState (_,_,_,_,s,_)) = s
|
agriesma@328
|
19 |
| safe (RrlsState _) = Safe;
|
agriesma@328
|
20 |
|
agriesma@328
|
21 |
type mstID = string;
|
wneuper@807
|
22 |
type tac'_ = mstID * tac; (*DG <-> ME*)
|
wneuper@807
|
23 |
val e_tac'_ = ("Empty_Tac", Empty_Tac):tac'_;
|
agriesma@328
|
24 |
|
wneuper@807
|
25 |
fun mk_tac'_ m = case m of
|
agriesma@328
|
26 |
Init_Proof (ppc, spec) => ("Init_Proof", Init_Proof (ppc, spec ))
|
agriesma@328
|
27 |
| Model_Problem pblID => ("Model_Problem", Model_Problem pblID)
|
agriesma@328
|
28 |
| Refine_Tacitly pblID => ("Refine_Tacitly", Refine_Tacitly pblID)
|
agriesma@328
|
29 |
| Refine_Problem pblID => ("Refine_Problem", Refine_Problem pblID)
|
agriesma@328
|
30 |
| Add_Given cterm' => ("Add_Given", Add_Given cterm')
|
agriesma@328
|
31 |
| Del_Given cterm' => ("Del_Given", Del_Given cterm')
|
agriesma@328
|
32 |
| Add_Find cterm' => ("Add_Find", Add_Find cterm')
|
agriesma@328
|
33 |
| Del_Find cterm' => ("Del_Find", Del_Find cterm')
|
agriesma@328
|
34 |
| Add_Relation cterm' => ("Add_Relation", Add_Relation cterm')
|
agriesma@328
|
35 |
| Del_Relation cterm' => ("Del_Relation", Del_Relation cterm')
|
agriesma@328
|
36 |
|
wneuper@839
|
37 |
| Specify_Theory domID => ("Specify_Theory", Specify_Theory domID)
|
agriesma@328
|
38 |
| Specify_Problem pblID => ("Specify_Problem", Specify_Problem pblID)
|
agriesma@328
|
39 |
| Specify_Method metID => ("Specify_Method", Specify_Method metID)
|
agriesma@328
|
40 |
| Apply_Method metID => ("Apply_Method", Apply_Method metID)
|
agriesma@328
|
41 |
| Check_Postcond pblID => ("Check_Postcond", Check_Postcond pblID)
|
agriesma@328
|
42 |
| Free_Solve => ("Free_Solve",Free_Solve)
|
agriesma@328
|
43 |
|
agriesma@328
|
44 |
| Rewrite_Inst (subs, thm') => ("Rewrite_Inst", Rewrite_Inst (subs, thm'))
|
agriesma@328
|
45 |
| Rewrite thm' => ("Rewrite", Rewrite thm')
|
agriesma@328
|
46 |
| Rewrite_Asm thm' => ("Rewrite_Asm", Rewrite_Asm thm')
|
agriesma@328
|
47 |
| Rewrite_Set_Inst (subs, rls')
|
agriesma@328
|
48 |
=> ("Rewrite_Set_Inst", Rewrite_Set_Inst (subs, rls'))
|
agriesma@328
|
49 |
| Rewrite_Set rls' => ("Rewrite_Set", Rewrite_Set rls')
|
agriesma@328
|
50 |
| End_Ruleset => ("End_Ruleset", End_Ruleset)
|
agriesma@328
|
51 |
|
agriesma@328
|
52 |
| End_Detail => ("End_Detail", End_Detail)
|
agriesma@328
|
53 |
| Detail_Set rls' => ("Detail_Set", Detail_Set rls')
|
agriesma@328
|
54 |
| Detail_Set_Inst (s, rls') => ("Detail_Set_Inst", Detail_Set_Inst (s, rls'))
|
agriesma@328
|
55 |
|
agriesma@328
|
56 |
| Calculate op_ => ("Calculate", Calculate op_)
|
agriesma@328
|
57 |
| Substitute subs => ("Substitute", Substitute subs)
|
agriesma@328
|
58 |
| Apply_Assumption cts' => ("Apply_Assumption", Apply_Assumption cts')
|
agriesma@328
|
59 |
|
agriesma@328
|
60 |
| Take cterm' => ("Take", Take cterm')
|
agriesma@328
|
61 |
| Take_Inst cterm' => ("Take_Inst", Take_Inst cterm')
|
agriesma@328
|
62 |
| Group (con, ints) => ("Group", Group (con, ints))
|
agriesma@328
|
63 |
| Subproblem (domID, pblID) => ("Subproblem", Subproblem (domID, pblID))
|
agriesma@328
|
64 |
(*
|
agriesma@328
|
65 |
| Subproblem_Full(spec,cts')=> ("Subproblem_Full", Subproblem_Full(spec,cts'))
|
agriesma@328
|
66 |
*)
|
agriesma@328
|
67 |
| End_Subproblem => ("End_Subproblem",End_Subproblem)
|
agriesma@328
|
68 |
| CAScmd cterm' => ("CAScmd", CAScmd cterm')
|
agriesma@328
|
69 |
|
agriesma@328
|
70 |
| Split_And => ("Split_And", Split_And)
|
agriesma@328
|
71 |
| Conclude_And => ("Conclude_And", Conclude_And)
|
agriesma@328
|
72 |
| Split_Or => ("Split_Or", Split_Or)
|
agriesma@328
|
73 |
| Conclude_Or => ("Conclude_Or", Conclude_Or)
|
agriesma@328
|
74 |
| Begin_Trans => ("Begin_Trans", Begin_Trans)
|
agriesma@328
|
75 |
| End_Trans => ("End_Trans", End_Trans)
|
agriesma@328
|
76 |
| Begin_Sequ => ("Begin_Sequ", Begin_Sequ)
|
agriesma@328
|
77 |
| End_Sequ => ("End_Sequ", Begin_Sequ)
|
agriesma@328
|
78 |
| Split_Intersect => ("Split_Intersect", Split_Intersect)
|
agriesma@328
|
79 |
| End_Intersect => ("End_Intersect", End_Intersect)
|
agriesma@328
|
80 |
| Check_elementwise cterm' => ("Check_elementwise", Check_elementwise cterm')
|
agriesma@328
|
81 |
| Or_to_List => ("Or_to_List", Or_to_List)
|
agriesma@328
|
82 |
| Collect_Trues => ("Collect_Results", Collect_Trues)
|
agriesma@328
|
83 |
|
wneuper@807
|
84 |
| Empty_Tac => ("Empty_Tac",Empty_Tac)
|
wneuper@807
|
85 |
| Tac string => ("Tac",Tac string)
|
agriesma@328
|
86 |
| User => ("User",User)
|
agriesma@328
|
87 |
| End_Proof' => ("End_Proof'",End_Proof');
|
agriesma@328
|
88 |
|
agriesma@328
|
89 |
(*Detail*)
|
wneuper@807
|
90 |
val empty_tac'_ = (mk_tac'_ Empty_Tac):tac'_;
|
agriesma@328
|
91 |
|
wneuper@807
|
92 |
fun mk_tac ((_,m):tac'_) = m;
|
wneuper@807
|
93 |
fun mk_mstID ((mI,_):tac'_) = mI;
|
agriesma@328
|
94 |
|
wneuper@807
|
95 |
fun tac'_2str ((ID,ms):tac'_) = ID ^ (tac2str ms);
|
wneuper@807
|
96 |
(* TODO: tac2str, tac'_2str NOT tested *)
|
agriesma@328
|
97 |
|
agriesma@328
|
98 |
|
agriesma@328
|
99 |
|
agriesma@328
|
100 |
type squ = ptree; (* TODO: safe etc. *)
|
agriesma@328
|
101 |
|
agriesma@328
|
102 |
(*13.9.02--------------
|
agriesma@328
|
103 |
type ctr = (loc * pos) list;
|
agriesma@328
|
104 |
val ops = [("plus","op +"),("minus","op -"),("times","op *"),
|
agriesma@328
|
105 |
("cancel","cancel"),("pow","pow"),("sqrt","sqrt")];
|
agriesma@328
|
106 |
fun op_intern op_ =
|
agriesma@328
|
107 |
case assoc (ops,op_) of
|
agriesma@328
|
108 |
Some op' => op' | None => raise error ("op_intern: no op= "^op_);
|
agriesma@328
|
109 |
-----------------------*)
|
agriesma@328
|
110 |
|
agriesma@328
|
111 |
|
agriesma@328
|
112 |
|
agriesma@328
|
113 |
(* use"ME/solve.sml";
|
agriesma@328
|
114 |
use"solve.sml";
|
agriesma@328
|
115 |
|
agriesma@328
|
116 |
val ttt = (term_of o the o (parse thy))"Substitute [(bdv,x)] g";
|
agriesma@328
|
117 |
val ttt = (term_of o the o (parse thy))"Rewrite thmid True g";
|
agriesma@328
|
118 |
|
agriesma@328
|
119 |
Const ("Script.Rewrite'_Inst",_) $ sub $ Free (thm',_) $ Const (pa,_) $ f'
|
agriesma@328
|
120 |
*)
|
agriesma@328
|
121 |
|
agriesma@328
|
122 |
|
agriesma@328
|
123 |
|
agriesma@328
|
124 |
val specsteps = ["Init_Proof","Refine_Tacitly","Refine_Problem",
|
agriesma@328
|
125 |
"Model_Problem",(*"Match_Problem",*)
|
agriesma@328
|
126 |
"Add_Given","Del_Given","Add_Find","Del_Find",
|
agriesma@328
|
127 |
"Add_Relation","Del_Relation",
|
wneuper@839
|
128 |
"Specify_Theory","Specify_Problem","Specify_Method"];
|
agriesma@328
|
129 |
|
wneuper@825
|
130 |
"-----------------------------------------------------------------------";
|
agriesma@328
|
131 |
|
wneuper@1408
|
132 |
|
wneuper@1408
|
133 |
fun step2taci ((tac_, _, pt, p, _):step) = (*FIXXME.040312: redesign step*)
|
wneuper@1408
|
134 |
(tac_2tac tac_, tac_, (p, get_istate pt p)):taci;
|
wneuper@1408
|
135 |
|
wneuper@1408
|
136 |
|
wneuper@1408
|
137 |
|
wneuper@816
|
138 |
(* val ("Apply_Method",Apply_Method' (mI,_))=(mI,m);
|
wneuper@2918
|
139 |
val (("Apply_Method",Apply_Method' (mI,_,_)), pos as (p,_))=(m, pos);
|
agriesma@328
|
140 |
*)
|
wneuper@1592
|
141 |
fun solve ("Apply_Method",Apply_Method' (mI,_,_)) (pt:ptree,(pos as (p,_))) =
|
agriesma@328
|
142 |
let val {srls,...} = get_met mI;
|
agriesma@328
|
143 |
val PblObj{meth=itms,...} = get_obj I pt p;
|
agriesma@328
|
144 |
val thy' = get_obj g_domID pt p;
|
agriesma@328
|
145 |
val thy = assoc_thy thy';
|
agriesma@328
|
146 |
val (is as ScrState (env,_,_,_,_,_), scr) = init_scrstate thy itms mI;
|
agriesma@328
|
147 |
val ini = init_form thy scr env;
|
wneuper@1446
|
148 |
val p = lev_dn p;
|
agriesma@328
|
149 |
in
|
wneuper@1971
|
150 |
case ini of
|
wneuper@1971
|
151 |
Some t => (* val Some t = ini;
|
wneuper@1971
|
152 |
*)
|
wneuper@1971
|
153 |
let val (pos,c,_,pt) =
|
wneuper@1971
|
154 |
generate1 thy (Apply_Method' (mI, Some t, is))
|
wneuper@1971
|
155 |
is (lev_on p, Frm)(*implicit Take*) pt;
|
wneuper@1971
|
156 |
in ("ok",([(Apply_Method mI, Apply_Method' (mI, Some t, is),
|
wneuper@1971
|
157 |
((lev_on p, Frm), is))], c, (pt,pos)):calcstate') end
|
wneuper@1971
|
158 |
|
wneuper@1971
|
159 |
| None =>
|
wneuper@1971
|
160 |
("ok",([(Apply_Method mI,Apply_Method'(mI,None,e_istate),(pos, is))],
|
wneuper@1971
|
161 |
[], (update_env pt (fst pos) (Some is),pos)))
|
agriesma@328
|
162 |
end
|
agriesma@328
|
163 |
|
wneuper@1408
|
164 |
| solve ("Free_Solve", Free_Solve') (pt,po as (p,_)) =
|
wneuper@1250
|
165 |
let (*val _=writeln"###solve Free_Solve";*)
|
agriesma@328
|
166 |
val p' = lev_dn_ (p,Res);
|
agriesma@328
|
167 |
val pt = update_metID pt (par_pblobj pt p) e_metID;
|
wneuper@1408
|
168 |
in ("ok", ((*(p',Uistate,Empty_Tac_), EmptyMout, Empty_Tac, Unsafe,*)
|
wneuper@1971
|
169 |
[(Empty_Tac, Empty_Tac_, (po, Uistate))], [], (pt,p'))) end
|
agriesma@328
|
170 |
|
wneuper@1408
|
171 |
(* val(("Check_Postcond",Check_Postcond' (pI,_)),pos as (p,p_)) =(m,pos);
|
agriesma@328
|
172 |
*)
|
wneuper@1408
|
173 |
| solve ("Check_Postcond",Check_Postcond' (pI,_)) (pt,(pos as (p,p_))) =
|
agriesma@328
|
174 |
let (*val _=writeln"###solve Check_Postcond";*)
|
neuper@732
|
175 |
val pp = par_pblobj pt p
|
wneuper@807
|
176 |
val asm = (case get_obj g_tac pt p of
|
neuper@732
|
177 |
Check_elementwise _ => (*collects and instantiates asms*)
|
neuper@732
|
178 |
(snd o (get_obj g_result pt)) p
|
neuper@732
|
179 |
| _ => ((map fst) o (get_assumptions_ pt)) (p,p_))
|
neuper@732
|
180 |
handle _ => [] (*WN.27.5.03 asms in subpbls not completely clear*)
|
agriesma@328
|
181 |
val metID = get_obj g_metID pt pp;
|
agriesma@328
|
182 |
val {srls=srls,scr=sc,...} = get_met metID;
|
agriesma@328
|
183 |
val is as ScrState (E,l,a,_,_,b) = get_istate pt (p,p_);
|
agriesma@328
|
184 |
(*val _= writeln("### solve Check_postc, subpbl pos= "^(pos'2str (p,p_)));
|
agriesma@328
|
185 |
val _= writeln("### solve Check_postc, is= "^(istate2str is));*)
|
agriesma@328
|
186 |
val thy' = get_obj g_domID pt pp;
|
agriesma@328
|
187 |
val thy = assoc_thy thy';
|
wneuper@825
|
188 |
val (_,_,(scval,scsaf)) = next_tac (thy',srls) (pt,(p,p_)) sc is;
|
agriesma@328
|
189 |
(*val _= writeln("### solve Check_postc, scval= "^(term2str scval));*)
|
wneuper@1408
|
190 |
|
wneuper@1408
|
191 |
in if pp = [] then
|
wneuper@825
|
192 |
let val is = ScrState (E,l,a,scval,scsaf,b)
|
wneuper@1408
|
193 |
val tac_ = Check_Postcond'(pI,(scval, map term2str asm))
|
wneuper@1446
|
194 |
val (pos,ps,f,pt) = generate1 thy tac_ is (pp,Res) pt;
|
wneuper@1408
|
195 |
in ("ok", ((*(([],Res),is,End_Proof''), f, End_Proof', scsaf,*)
|
wneuper@1971
|
196 |
[(Check_Postcond pI, tac_, ((pp,Res),is))], ps,(pt,pos))) end
|
agriesma@328
|
197 |
else
|
agriesma@328
|
198 |
let
|
agriesma@328
|
199 |
(*resume script of parpbl, transfer value of subpbl-script*)
|
wneuper@819
|
200 |
val ppp = par_pblobj pt (lev_up p);
|
agriesma@328
|
201 |
val thy' = get_obj g_domID pt ppp;
|
agriesma@328
|
202 |
val thy = assoc_thy thy';
|
agriesma@328
|
203 |
val metID = get_obj g_metID pt ppp;
|
agriesma@328
|
204 |
val sc = (#scr o get_met) metID;
|
agriesma@328
|
205 |
val is as ScrState (E,l,a,_,_,b) = get_istate pt (pp(*!/p/*),Frm);
|
agriesma@328
|
206 |
(*val _=writeln("### solve Check_postc, parpbl pos= "^(pos'2str(pp,Frm)));
|
agriesma@328
|
207 |
val _=writeln("### solve Check_postc, is(pt)= "^(istate2str is));
|
agriesma@328
|
208 |
val _=writeln("### solve Check_postc, is'= "^
|
agriesma@328
|
209 |
(istate2str (E,l,a,scval,scsaf,b)));*)
|
neuper@750
|
210 |
val ((p,p_),ps,f,pt) =
|
neuper@750
|
211 |
generate1 thy (Check_Postcond' (pI, (scval, map term2str asm)))
|
agriesma@328
|
212 |
(ScrState (E,l,a,scval,scsaf,b)) (pp,Res) pt;
|
agriesma@328
|
213 |
(*val _=writeln("### solve Check_postc, is(pt')= "^
|
wneuper@1408
|
214 |
(istate2str (get_istate pt ([3],Res))));
|
wneuper@825
|
215 |
val (nx,is',_) = next_tac (thy',srls) (pt,(p,p_)) sc
|
wneuper@1408
|
216 |
(ScrState (E,l,a,scval,scsaf,b));*)
|
wneuper@1408
|
217 |
in ("ok",(*((pp,Res),is',nx), f, tac_2tac nx, scsaf,*)
|
wneuper@1408
|
218 |
([(Check_Postcond pI, Check_Postcond'(pI,(scval, map term2str asm)),
|
wneuper@1971
|
219 |
((pp,Res), ScrState (E,l,a,scval,scsaf,b)))],ps,(pt,(p,p_))))
|
wneuper@1408
|
220 |
end
|
agriesma@328
|
221 |
end
|
wneuper@1408
|
222 |
(* val (msg, cs') =
|
wneuper@1408
|
223 |
("ok",([(Check_Postcond pI,Check_Postcond'(pI, (scval, map term2str asm))),
|
wneuper@1408
|
224 |
((pp,Res),(ScrState (E,l,a,scval,scsaf,b)))], (pt,(p,p_))));
|
wneuper@1408
|
225 |
val (_,(pt',p')) = cs';
|
wneuper@1408
|
226 |
(writeln o istate2str) (get_istate pt' p');
|
wneuper@1408
|
227 |
(term2str o fst) (get_obj g_result pt' (fst p'));
|
wneuper@1408
|
228 |
*)
|
wneuper@1408
|
229 |
|
agriesma@328
|
230 |
(* writeln(istate2str(get_istate pt (p,p_)));
|
agriesma@328
|
231 |
*)
|
wneuper@1408
|
232 |
| solve (_,End_Proof'') (pt, (p,p_)) =
|
wneuper@1408
|
233 |
("end-proof",
|
wneuper@1408
|
234 |
((*(([],Res),Uistate,Empty_Tac_), EmptyMout, Empty_Tac, Safe,*)
|
wneuper@1971
|
235 |
[(Empty_Tac,Empty_Tac_,(([],Res),Uistate))],[],(pt,(p,p_))))
|
agriesma@328
|
236 |
|
wneuper@1408
|
237 |
(*-----------vvvvvvvvvvv could be done by generate1 ?!?*)
|
wneuper@1408
|
238 |
| solve (_,End_Detail' t) (pt,(p,p_)) =
|
agriesma@328
|
239 |
let val pr as (p',_) = (lev_up p, Res)
|
agriesma@328
|
240 |
val pp = par_pblobj pt p
|
neuper@703
|
241 |
val r = (fst o (get_obj g_result pt)) p'
|
wneuper@825
|
242 |
(*Rewrite_Set* done at Detail_Set*: this result is already in ptree*)
|
agriesma@328
|
243 |
val thy' = get_obj g_domID pt pp
|
agriesma@328
|
244 |
val (srls, is, sc) = from_pblobj' thy' pr pt
|
wneuper@825
|
245 |
val (tac_,is',_) = next_tac (thy',srls) (pt,pr) sc is
|
wneuper@1408
|
246 |
in ("ok", ((*((pp,Frm(*???*)),is,tac_),
|
wneuper@825
|
247 |
Form' (FormKF (~1, EdUndef, length p', Nundef, term2str r)),
|
wneuper@1408
|
248 |
tac_2tac tac_, Sundef,*)
|
wneuper@1408
|
249 |
[(End_Detail, End_Detail' t ,
|
wneuper@1971
|
250 |
((p,p_), get_istate pt (p,p_)))], [], (pt,pr))) end
|
wneuper@1408
|
251 |
|
wneuper@1408
|
252 |
| solve (mI,m) (pt, po as (p,p_)) =
|
wneuper@1408
|
253 |
(* val ((mI,m), po as (p,p_)) = (m, pos);
|
wneuper@856
|
254 |
*)
|
agriesma@328
|
255 |
if e_metID = get_obj g_metID pt (par_pblobj pt p)(*29.8.02:
|
agriesma@328
|
256 |
could be detail, too !!*)
|
agriesma@328
|
257 |
then let val ((p,p_),ps,f,pt) =
|
agriesma@328
|
258 |
generate1 (assoc_thy (get_obj g_domID pt (par_pblobj pt p)))
|
agriesma@328
|
259 |
m e_istate (p,p_) pt;
|
wneuper@1408
|
260 |
in ("no-method-specified", (*Free_Solve*)
|
wneuper@1408
|
261 |
((*((p,p_),Uistate,Empty_Tac_),f, Empty_Tac, Unsafe,*)
|
wneuper@1971
|
262 |
[(Empty_Tac,Empty_Tac_, ((p,p_),Uistate))], ps, (pt,(p,p_)))) end
|
agriesma@328
|
263 |
else
|
neuper@711
|
264 |
let
|
neuper@711
|
265 |
val thy' = get_obj g_domID pt (par_pblobj pt p);
|
agriesma@328
|
266 |
val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt;
|
agriesma@328
|
267 |
(*val _= writeln("### solve, before locate_gen p="^(pos'2str(p,p_)));*)
|
agriesma@328
|
268 |
val d = e_rls; (*FIXME: canon.simplifier for domain is missing
|
agriesma@328
|
269 |
8.01: generate from domID?*)
|
agriesma@328
|
270 |
in case locate_gen (thy',srls) m (pt,(p,p_)) (sc,d) is of
|
wneuper@1408
|
271 |
Steps (is', ss as (m',f',pt',p',c')::_) =>
|
wneuper@1408
|
272 |
(* val Steps (is', ss as (m',f',pt',p',c')::_) =
|
wneuper@856
|
273 |
locate_gen (thy',srls) m (pt,(p,p_)) (sc,d) is;
|
wneuper@856
|
274 |
*)
|
wneuper@1408
|
275 |
let (*val _= writeln("### solve, after locate_gen: is= ")
|
wneuper@1408
|
276 |
val _= writeln(istate2str is')*)
|
wneuper@1408
|
277 |
(*val nxt_ =
|
wneuper@1408
|
278 |
case p' of (*change from solve to model subpbl*)
|
wneuper@825
|
279 |
(_,Pbl) => nxt_model_pbl m' (pt',p')
|
wneuper@1408
|
280 |
| _ => fst3 (next_tac (thy',srls) (pt',p') sc is');*)
|
wneuper@825
|
281 |
(*27.8.02:next_tac may change to other branches in pt FIXXXXME*)
|
wneuper@1408
|
282 |
in ("ok", ((*(p',is',nxt_), f', tac_2tac nxt_, safe is',*)
|
wneuper@1971
|
283 |
map step2taci ss, c', (pt',p'))) end
|
agriesma@328
|
284 |
| NotLocatable =>
|
agriesma@328
|
285 |
let val (p,ps,f,pt) =
|
agriesma@328
|
286 |
generate_hard (assoc_thy "Isac.thy") m (p,p_) pt;
|
wneuper@1408
|
287 |
in ("not-found-in-script",
|
wneuper@1408
|
288 |
((*(p,Uistate,Empty_Tac_),f, Empty_Tac, Unsafe,*)
|
wneuper@1971
|
289 |
[(tac_2tac m, m, (po,is))], ps, (pt,p))) end
|
agriesma@328
|
290 |
end;
|
agriesma@328
|
291 |
|
wneuper@1297
|
292 |
(* nxt_solv (Apply_Method' vvv FIXME: get args in applicable_in *)
|
wneuper@1592
|
293 |
fun nxt_solv (Apply_Method' (mI,_,_)) _ (pt:ptree, pos as (p,_)) =
|
wneuper@1297
|
294 |
(* val (mI, (pt:ptree, pos as (p,_))) = (mI, ptp);
|
wneuper@1297
|
295 |
*)
|
wneuper@1297
|
296 |
let val {srls,ppc,...} = get_met mI;
|
wneuper@1297
|
297 |
val PblObj{meth=itms,origin=(oris,_,_),probl,...} = get_obj I pt p;
|
wneuper@1297
|
298 |
val itms = if itms <> [] then itms
|
wneuper@1297
|
299 |
else complete_metitms oris probl [] ppc
|
wneuper@839
|
300 |
val thy' = get_obj g_domID pt p;
|
wneuper@839
|
301 |
val thy = assoc_thy thy';
|
wneuper@839
|
302 |
val (is as ScrState (env,_,_,_,_,_), scr) = init_scrstate thy itms mI;
|
wneuper@839
|
303 |
val ini = init_form thy scr env;
|
wneuper@1446
|
304 |
val p = lev_dn p;
|
wneuper@839
|
305 |
in
|
wneuper@839
|
306 |
case ini of
|
wneuper@839
|
307 |
Some t => (* val Some t = ini;
|
wneuper@839
|
308 |
*)
|
wneuper@1592
|
309 |
let val tac_ = Apply_Method' (mI, Some t, is);
|
wneuper@1971
|
310 |
val (pos,c,_,pt) = (*implicit Take*)
|
wneuper@1446
|
311 |
generate1 thy tac_ is (lev_on p,Frm) pt
|
wneuper@1446
|
312 |
(*val _= ("### nxt_solv Apply_Method, pos= "^pos'2str (lev_on p,Frm));*)
|
wneuper@1971
|
313 |
in ([(Apply_Method mI, tac_, ((lev_on p, Frm), is))],
|
wneuper@1971
|
314 |
c, (pt, pos)):calcstate' end
|
wneuper@839
|
315 |
| None =>
|
wneuper@1971
|
316 |
([(Apply_Method mI, Apply_Method' (mI, None, e_istate), (pos, is))], [],
|
wneuper@1592
|
317 |
(update_env pt (fst pos) (Some is), pos))
|
wneuper@839
|
318 |
end
|
wneuper@1971
|
319 |
|
wneuper@839
|
320 |
(* val ("Check_Postcond",Check_Postcond' (pI,_)) = (mI,m);
|
wneuper@839
|
321 |
*)
|
wneuper@1250
|
322 |
| nxt_solv (Check_Postcond' (pI,_)) _ (pt, pos as (p,p_)) =
|
wneuper@839
|
323 |
let (*val _=writeln"###solve Check_Postcond";*)
|
wneuper@839
|
324 |
val pp = par_pblobj pt p
|
wneuper@839
|
325 |
val asm = (case get_obj g_tac pt p of
|
wneuper@839
|
326 |
Check_elementwise _ => (*collects and instantiates asms*)
|
wneuper@839
|
327 |
(snd o (get_obj g_result pt)) p
|
wneuper@839
|
328 |
| _ => ((map fst) o (get_assumptions_ pt)) (p,p_))
|
wneuper@839
|
329 |
handle _ => [] (*WN.27.5.03 asms in subpbls not completely clear*)
|
wneuper@839
|
330 |
val metID = get_obj g_metID pt pp;
|
wneuper@839
|
331 |
val {srls=srls,scr=sc,...} = get_met metID;
|
wneuper@839
|
332 |
val is as ScrState (E,l,a,_,_,b) = get_istate pt (p,p_);
|
wneuper@839
|
333 |
(*val _= writeln("### solve Check_postc, subpbl pos= "^(pos'2str (p,p_)));
|
wneuper@839
|
334 |
val _= writeln("### solve Check_postc, is= "^(istate2str is));*)
|
wneuper@839
|
335 |
val thy' = get_obj g_domID pt pp;
|
wneuper@839
|
336 |
val thy = assoc_thy thy';
|
wneuper@839
|
337 |
val (_,_,(scval,scsaf)) = next_tac (thy',srls) (pt,(p,p_)) sc is;
|
wneuper@839
|
338 |
(*val _= writeln("### solve Check_postc, scval= "^(term2str scval));*)
|
wneuper@839
|
339 |
in if pp = [] then
|
wneuper@839
|
340 |
let val is = ScrState (E,l,a,scval,scsaf,b)
|
wneuper@1250
|
341 |
val tac_ = Check_Postcond'(pI,(scval, map term2str asm))
|
wneuper@1250
|
342 |
(*val _= writeln"### nxt_solv2 Apply_Method: stored is =";
|
wneuper@1250
|
343 |
val _= writeln(istate2str is);*)
|
wneuper@839
|
344 |
val ((p,p_),ps,f,pt) =
|
wneuper@1250
|
345 |
generate1 thy tac_ is (pp,Res) pt;
|
wneuper@1971
|
346 |
in ([(Check_Postcond pI, tac_, ((pp,Res), is))],ps,(pt, (p,p_))) end
|
wneuper@839
|
347 |
else
|
wneuper@839
|
348 |
let
|
wneuper@839
|
349 |
(*resume script of parpbl, transfer value of subpbl-script*)
|
wneuper@839
|
350 |
val ppp = par_pblobj pt (lev_up p);
|
wneuper@839
|
351 |
val thy' = get_obj g_domID pt ppp;
|
wneuper@839
|
352 |
val thy = assoc_thy thy';
|
wneuper@839
|
353 |
val metID = get_obj g_metID pt ppp;
|
wneuper@839
|
354 |
val sc = (#scr o get_met) metID;
|
wneuper@1250
|
355 |
val is as ScrState (E,l,a,_,_,b) = get_istate pt (pp(*!/p/*),Frm)
|
wneuper@1250
|
356 |
val tac_ = Check_Postcond' (pI, (scval, map term2str asm))
|
wneuper@1250
|
357 |
val is = ScrState (E,l,a,scval,scsaf,b)
|
wneuper@1250
|
358 |
(*val _= writeln"### nxt_solv3 Apply_Method: stored is =";
|
wneuper@1250
|
359 |
val _= writeln(istate2str is);*)
|
wneuper@1250
|
360 |
val ((p,p_),ps,f,pt) = generate1 thy tac_ is (pp, Res) pt;
|
wneuper@1250
|
361 |
val (nx,is',_) = next_tac (thy',srls) (pt,(p,p_)) sc is;
|
wneuper@1971
|
362 |
in ([(Check_Postcond pI, tac_, ((pp, Res), is))], ps, (pt, (p,p_))) end
|
wneuper@839
|
363 |
end
|
wneuper@839
|
364 |
(* writeln(istate2str(get_istate pt (p,p_)));
|
wneuper@839
|
365 |
*)
|
wneuper@839
|
366 |
|
wneuper@839
|
367 |
(*.start interpreter and do one rewrite.*)
|
wneuper@839
|
368 |
(* val (_,Detail_Set'(thy',rls,t)) = (mI,m); val p = (p,p_);
|
wneuper@839
|
369 |
solve ("",Detail_Set'(thy', rls, t)) p pt;
|
wneuper@1250
|
370 |
| nxt_solv (Detail_Set'(thy', rls, t)) _ (pt, p) = **********
|
wneuper@856
|
371 |
---> FE-interface/sml.sml
|
wneuper@839
|
372 |
|
wneuper@1250
|
373 |
| nxt_solv (End_Detail' t) _ (pt, (p,p_)) = **********
|
wneuper@839
|
374 |
let val pr as (p',_) = (lev_up p, Res)
|
wneuper@839
|
375 |
val pp = par_pblobj pt p
|
wneuper@839
|
376 |
val r = (fst o (get_obj g_result pt)) p'
|
wneuper@839
|
377 |
(*Rewrite_Set* done at Detail_Set*: this result is already in ptree*)
|
wneuper@839
|
378 |
val thy' = get_obj g_domID pt pp
|
wneuper@839
|
379 |
val (srls, is, sc) = from_pblobj' thy' pr pt
|
wneuper@839
|
380 |
val (tac_,is',_) = next_tac (thy',srls) (pt,pr) sc is
|
wneuper@839
|
381 |
in (pr, ((pp,Frm(*???*)),is,tac_),
|
wneuper@839
|
382 |
Form' (FormKF (~1, EdUndef, length p', Nundef, term2str r)),
|
wneuper@856
|
383 |
tac_2tac tac_, Sundef, pt) end
|
wneuper@856
|
384 |
*)
|
wneuper@1971
|
385 |
| nxt_solv (End_Proof'') _ ptp = ([], [], ptp)
|
wneuper@1329
|
386 |
|
wneuper@1329
|
387 |
| nxt_solv tac_ is (pt, pos as (p,p_)) =
|
wneuper@2036
|
388 |
(* val (pt, pos as (p,p_)) = ptp;
|
wneuper@2036
|
389 |
*)
|
wneuper@1329
|
390 |
let val pos = case pos of (p,Res) => (lev_on p,Res) | _ => pos
|
wneuper@1329
|
391 |
(*val _= writeln"### nxt_solv4 Apply_Method: stored is =";
|
wneuper@1329
|
392 |
val _= writeln(istate2str is);*)
|
wneuper@1971
|
393 |
val (pos',c,_,pt) = generate1 (assoc_thy "Isac.thy") tac_ is pos pt;
|
wneuper@1971
|
394 |
in ([(tac_2tac tac_, tac_, (pos,is))], c, (pt, pos')) end;
|
wneuper@1329
|
395 |
|
wneuper@1329
|
396 |
|
wneuper@1329
|
397 |
(*(p,p_), (([],Res),Uistate,Empty_Tac_), EmptyMout, Empty_Tac, Safe, pt*)
|
wneuper@1329
|
398 |
|
wneuper@856
|
399 |
|
wneuper@1250
|
400 |
(*.find the next tac from the script, nxt_solv will update the ptree.*)
|
wneuper@1250
|
401 |
fun nxt_solve_ (ptp as (pt, pos as (p,p_))) =
|
wneuper@1250
|
402 |
(* val (pt,pos as (p,p_)) = ptp;
|
wneuper@1971
|
403 |
val (pt,pos as (p,p_)) = ptp';
|
wneuper@1971
|
404 |
val (pt,pos as (p,p_)) = ptp'';
|
wneuper@1250
|
405 |
*)
|
wneuper@1250
|
406 |
if e_metID = get_obj g_metID pt (par_pblobj pt p)
|
wneuper@1971
|
407 |
then ([], [], (pt,(p,p_))):calcstate'
|
wneuper@1250
|
408 |
else let val thy' = get_obj g_domID pt (par_pblobj pt p);
|
wneuper@1250
|
409 |
val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt;
|
wneuper@1329
|
410 |
val (tac_,is,(t,_)) = next_tac (thy',srls) (pt,pos) sc is;
|
wneuper@1250
|
411 |
(*here ^^^ return finished/helpless/ok !*)
|
wneuper@1250
|
412 |
(* val (tac_',is',_) = next_tac (thy',srls) (pt,pos) sc is;
|
wneuper@1250
|
413 |
val Subproblem' (_,ooos,_,_,_) = tac_';
|
wneuper@1250
|
414 |
writeln (oris2str ooos);
|
wneuper@1250
|
415 |
*)
|
wneuper@1329
|
416 |
in case tac_ of
|
wneuper@1360
|
417 |
End_Detail' _ => ([(End_Detail,
|
wneuper@1360
|
418 |
End_Detail' (t,[(*FIXME.040215*)]),
|
wneuper@1971
|
419 |
(pos, is))], [], (pt, pos))
|
wneuper@1329
|
420 |
| _ => nxt_solv tac_ is ptp end;
|
wneuper@856
|
421 |
|
wneuper@1267
|
422 |
datatype auto =
|
wneuper@1297
|
423 |
Step of int (*1 do #int steps; may stop in model/specify:
|
wneuper@1267
|
424 |
IS VERY INEFFICIENT IN MODEL/SPECIY*)
|
wneuper@1267
|
425 |
| CompleteModel (*2 complete modeling
|
wneuper@1267
|
426 |
if model complete, finish specifying + start solving*)
|
wneuper@1267
|
427 |
| CompleteCalcHead (*3 complete model/specify in one go + start solving*)
|
wneuper@1267
|
428 |
| CompleteToSubpbl (*4 stop at the next begin of a subproblem,
|
wneuper@1267
|
429 |
if none, complete the actual (sub)problem*)
|
wneuper@1267
|
430 |
| CompleteSubpbl (*5 complete the actual (sub)problem (incl.ev.subproblems)*)
|
wneuper@1267
|
431 |
| CompleteCalc; (*6 complete the calculation as a whole*)
|
wneuper@1267
|
432 |
fun autoord (Step _ ) = 1
|
wneuper@1267
|
433 |
| autoord CompleteModel = 2
|
wneuper@1267
|
434 |
| autoord CompleteCalcHead = 3
|
wneuper@1267
|
435 |
| autoord CompleteToSubpbl = 4
|
wneuper@1267
|
436 |
| autoord CompleteSubpbl = 5
|
wneuper@1267
|
437 |
| autoord CompleteCalc = 6;
|
wneuper@1329
|
438 |
(* val ptp as (_, p) = ptp;
|
wneuper@1329
|
439 |
val ptp as (_, p) = (pt, pos); val auto = CompleteSubpbl;
|
wneuper@1971
|
440 |
val (auto, ptp as (_, p)) = (CompleteSubpbl, (pt', pos'));
|
wneuper@2036
|
441 |
|
wneuper@2036
|
442 |
val (c, (ptp as (_, p))) = ((c@c'), ptp);
|
wneuper@1329
|
443 |
*)
|
wneuper@1971
|
444 |
fun complete_solve auto c (ptp as (_, p): ptree * pos') =
|
wneuper@1971
|
445 |
if p = ([], Res) then ("end-of-calculation", [], ptp) else
|
wneuper@1250
|
446 |
case nxt_solve_ ptp of
|
wneuper@1971
|
447 |
((Subproblem _, tac_, (_, is))::_, c', ptp') =>
|
wneuper@1250
|
448 |
(* val ptp' = ptp''';
|
wneuper@1250
|
449 |
*)
|
wneuper@1971
|
450 |
if autoord auto < 5 then ("ok", c@c', ptp)
|
wneuper@1250
|
451 |
else let val ptp = all_modspec ptp';
|
wneuper@1971
|
452 |
val (_, c'', ptp) = all_solve auto (c@c') ptp;
|
wneuper@1971
|
453 |
in complete_solve auto (c@c'@c'') ptp end
|
wneuper@1971
|
454 |
| ((Check_Postcond _, tac_, (_, is))::_, c', ptp' as (_, p')) =>
|
wneuper@1971
|
455 |
if autoord auto < 6 orelse p' = ([],Res) then ("ok", c@c', ptp')
|
wneuper@1971
|
456 |
else complete_solve auto (c@c') ptp'
|
wneuper@1971
|
457 |
| ((End_Detail, _, _)::_, c', ptp') =>
|
wneuper@1971
|
458 |
if autoord auto < 6 then ("ok", c@c', ptp')
|
wneuper@1971
|
459 |
else complete_solve auto (c@c') ptp'
|
wneuper@1971
|
460 |
| (_, c', ptp') => complete_solve auto (c@c') ptp'
|
wneuper@2036
|
461 |
(* val (tacis, c', ptp') = nxt_solve_ ptp;
|
wneuper@2036
|
462 |
val (tacis, c', ptp'') = nxt_solve_ ptp';
|
wneuper@2036
|
463 |
val (tacis, c', ptp''') = nxt_solve_ ptp'';
|
wneuper@2036
|
464 |
val (tacis, c', ptp'''') = nxt_solve_ ptp''';
|
wneuper@2036
|
465 |
val (tacis, c', ptp''''') = nxt_solve_ ptp'''';
|
wneuper@1250
|
466 |
*)
|
wneuper@1971
|
467 |
and all_solve auto c (ptp as (pt, (p,_)): ptree * pos') =
|
wneuper@1250
|
468 |
(* val (ptp as (pt, (p,_))) = ptp;
|
wneuper@1250
|
469 |
val (ptp as (pt, (p,_))) = ptp';
|
wneuper@1297
|
470 |
val (ptp as (pt, (p,_))) = (pt, pos);
|
wneuper@1250
|
471 |
*)
|
wneuper@1250
|
472 |
let val (_,_,mI) = get_obj g_spec pt p;
|
wneuper@1971
|
473 |
val (_, c', ptp) = nxt_solv (Apply_Method' (mI, None, e_istate))
|
wneuper@1329
|
474 |
e_istate ptp;
|
wneuper@1971
|
475 |
in complete_solve auto (c@c') ptp end;
|
wneuper@839
|
476 |
|
agriesma@328
|
477 |
|
wneuper@1329
|
478 |
(*. detail steps done internally by Rewrite_Set*
|
wneuper@1971
|
479 |
into ctree by use of a script .*)
|
wneuper@1329
|
480 |
(* val (p,p_) = pos;
|
wneuper@1329
|
481 |
*)
|
wneuper@1971
|
482 |
fun detailrls pt ((p,p_):pos') =
|
wneuper@1329
|
483 |
let val t = get_obj g_form pt p
|
wneuper@1408
|
484 |
val is = init_istate (get_obj g_tac pt p)
|
wneuper@1329
|
485 |
val tac_ = Apply_Method' (e_metID(*WN.0402: see generate1 !?!*),
|
wneuper@1592
|
486 |
Some t, is);
|
wneuper@1408
|
487 |
val pos' = ((lev_on o lev_dn) p, Frm);
|
wneuper@1408
|
488 |
val (_,_,_,pt') = (*implicit Take*) generate1 thy tac_ is pos' pt;
|
wneuper@1971
|
489 |
val (_, _, (pt'',_)) = complete_solve CompleteSubpbl [] (pt', pos');
|
wneuper@1408
|
490 |
val newnds =children (get_nd pt'' p)
|
wneuper@1408
|
491 |
val pt''' = ins_chn newnds pt p (*complete_solve cuts branches after*)
|
wneuper@1408
|
492 |
(*val nd = get_nd pt p; val cn = children nd;*)
|
wneuper@1971
|
493 |
in ("detailrls", pt'''(*, get_formress [] ((lev_on o lev_dn) p) cn*),
|
wneuper@1971
|
494 |
(p @ [length newnds], Res):pos') end;
|
wneuper@1329
|
495 |
|
wneuper@1329
|
496 |
|
wneuper@1329
|
497 |
|
agriesma@328
|
498 |
(* val(mI,m)=m;val ppp=p;(*!!!*)val(p,p_)=pos;val(_,pt,_)=ppp(*!!!*);
|
wneuper@807
|
499 |
get_form ((mI,m):tac'_) ((p,p_):pos') ppp;
|
agriesma@328
|
500 |
*)
|
wneuper@807
|
501 |
fun get_form ((mI,m):tac'_) ((p,p_):pos') pt =
|
agriesma@328
|
502 |
case applicable_in (p,p_) pt m of
|
agriesma@328
|
503 |
Notappl e => Error' (Error_ e)
|
agriesma@328
|
504 |
| Appl m =>
|
agriesma@328
|
505 |
(* val Appl m=applicable_in (p,p_) pt m;
|
agriesma@328
|
506 |
*)
|
agriesma@328
|
507 |
if mI mem specsteps
|
agriesma@328
|
508 |
then let val (_,_,f,_,_,_) = specify m (p,p_) [] pt
|
agriesma@328
|
509 |
in f end
|
wneuper@1408
|
510 |
else let val (*_,_,f,_,_,_*)_ = solve (mI,m) (pt,(p,p_))
|
wneuper@1408
|
511 |
in (*f*) EmptyMout end;
|
wneuper@825
|
512 |
|