agriesma@328
|
1 |
(* use"ME/generate.sml";
|
agriesma@328
|
2 |
use"generate.sml";
|
wneuper@1360
|
3 |
*)
|
wneuper@1408
|
4 |
(*.initialize istate for Detail_Set.*)
|
wneuper@1408
|
5 |
fun init_istate (Rewrite_Set rls) =
|
wneuper@1408
|
6 |
(case assoc_rls rls of
|
wneuper@1408
|
7 |
Rrls {scr=sc as Rfuns {init_state=ii,...},...} => (RrlsState (ii t))
|
wneuper@1408
|
8 |
| Rls {scr=Script s,...} =>
|
wneuper@1408
|
9 |
(* val Rls {scr=Script s,...} = assoc_rls rls;
|
wneuper@1408
|
10 |
*)
|
wneuper@1408
|
11 |
(ScrState ([(one_scr_arg s, t)], [], None, e_term, Sundef, true))
|
wneuper@1408
|
12 |
| Seq {srls=srls,scr=Script s,...} =>
|
wneuper@1408
|
13 |
(ScrState ([(one_scr_arg s, t)], [], None, e_term, Sundef, true)))
|
wneuper@1408
|
14 |
| init_istate (Rewrite_Set_Inst (subs, rls)) =
|
wneuper@1408
|
15 |
let val (_, v)::_ = subs2subst (assoc_thy "Isac.thy") subs
|
wneuper@1408
|
16 |
in case assoc_rls rls of
|
wneuper@1408
|
17 |
Rls {scr=Script s,...} =>
|
wneuper@1408
|
18 |
let val (a1, a2) = two_scr_arg s
|
wneuper@1408
|
19 |
in (ScrState ([(a1, v), (a2, t)],[], None, e_term, Sundef,true)) end
|
wneuper@1408
|
20 |
| Seq {scr=Script s,...} =>
|
wneuper@1408
|
21 |
let val (a1, a2) = two_scr_arg s
|
wneuper@1408
|
22 |
in (ScrState ([(a1, v), (a2, t)],[], None, e_term, Sundef,true)) end
|
wneuper@1408
|
23 |
end;
|
agriesma@328
|
24 |
|
wneuper@1360
|
25 |
type taci =
|
wneuper@1360
|
26 |
(tac * (*for comparison with input tac*)
|
wneuper@1360
|
27 |
tac_ * (*for ptree generation*)
|
wneuper@1360
|
28 |
(pos' * (*after applying tac_, for ptree generation*)
|
wneuper@1971
|
29 |
istate)); (*after applying tac_, for ptree generation*)
|
wneuper@1360
|
30 |
val e_taci = (Empty_Tac, Empty_Tac_, (e_pos', e_istate)): taci;
|
wneuper@1360
|
31 |
(* val (tac, tac_, (pos', istate))::_ = tacis';
|
wneuper@1360
|
32 |
*)
|
wneuper@1360
|
33 |
fun taci2str ((tac, tac_, (pos', istate)):taci) =
|
wneuper@1360
|
34 |
"( "^tac2str tac^", "^tac_2str tac_^", ( "^pos'2str pos'
|
wneuper@1360
|
35 |
^", "^istate2str istate^" ))";
|
wneuper@1360
|
36 |
fun tacis2str tacis = (strs2str o (map (linefeed o taci2str))) tacis;
|
agriesma@328
|
37 |
|
wneuper@816
|
38 |
datatype pblmet = (*%^%*)
|
wneuper@816
|
39 |
Upblmet (*undefined*)
|
wneuper@816
|
40 |
| Problem of pblID (*%^%*)
|
wneuper@816
|
41 |
| Method of metID; (*%^%*)
|
wneuper@816
|
42 |
fun pblmet2str (Problem pblID) = "Problem "^(strs2str pblID)(*%^%*)
|
wneuper@816
|
43 |
| pblmet2str (Method metID) = "Method "^(metID2str metID);(*%^%*)
|
wneuper@816
|
44 |
(*%^%*) (*26.6. moved to sequent.sml: fun ~~~~~~~~~; was here below*)
|
agriesma@328
|
45 |
|
agriesma@328
|
46 |
|
wneuper@816
|
47 |
(* copy from 03.60.usecases.sml 15.11.99 *)
|
wneuper@816
|
48 |
datatype user_cmd =
|
wneuper@816
|
49 |
Accept | NotAccept | Example
|
wneuper@816
|
50 |
| YourTurn | MyTurn (* internal use only 7.6.02 java-sml*)
|
wneuper@816
|
51 |
| Rules
|
wneuper@816
|
52 |
| DontKnow (*| HowComes | WhatFor 7.6.02 java-sml*)
|
wneuper@816
|
53 |
| Undo (*| Back | Forward 7.6.02 java-sml*)
|
wneuper@816
|
54 |
| EndProof | EndSession
|
wneuper@816
|
55 |
| ActivePlus | ActiveMinus | SpeedPlus | SpeedMinus
|
wneuper@816
|
56 |
(*Stepwidth...7.6.02 java-sml*)
|
wneuper@816
|
57 |
| Auto | NotAuto | Details;
|
wneuper@816
|
58 |
(* for test-print-outs *)
|
wneuper@816
|
59 |
fun user_cmd2str Accept ="Accept"
|
wneuper@816
|
60 |
| user_cmd2str NotAccept ="NotAccept"
|
wneuper@816
|
61 |
| user_cmd2str Example ="Example"
|
wneuper@816
|
62 |
| user_cmd2str MyTurn ="MyTurn"
|
wneuper@816
|
63 |
| user_cmd2str YourTurn ="YourTurn"
|
wneuper@816
|
64 |
| user_cmd2str Rules ="Rules"
|
wneuper@816
|
65 |
(*| user_cmd2str HowComes ="HowComes"*)
|
wneuper@816
|
66 |
| user_cmd2str DontKnow ="DontKnow"
|
wneuper@816
|
67 |
(*| user_cmd2str WhatFor ="WhatFor"
|
wneuper@816
|
68 |
| user_cmd2str Back ="Back"*)
|
wneuper@816
|
69 |
| user_cmd2str Undo ="Undo"
|
wneuper@816
|
70 |
(*| user_cmd2str Forward ="Forward"*)
|
wneuper@816
|
71 |
| user_cmd2str EndProof ="EndProof"
|
wneuper@816
|
72 |
| user_cmd2str EndSession ="EndSession"
|
wneuper@816
|
73 |
| user_cmd2str ActivePlus = "ActivePlus"
|
wneuper@816
|
74 |
| user_cmd2str ActiveMinus = "ActiveMinus"
|
wneuper@816
|
75 |
| user_cmd2str SpeedPlus = "SpeedPlus"
|
wneuper@816
|
76 |
| user_cmd2str SpeedMinus = "SpeedMinus"
|
wneuper@816
|
77 |
| user_cmd2str Auto = "Auto"
|
wneuper@816
|
78 |
| user_cmd2str NotAuto = "NotAuto"
|
wneuper@816
|
79 |
| user_cmd2str Details = "Details";
|
wneuper@816
|
80 |
|
wneuper@816
|
81 |
|
wneuper@816
|
82 |
|
wneuper@816
|
83 |
(*3.5.00: TODO: foppFK eliminated in interface FE-KE !!!*)
|
wneuper@816
|
84 |
datatype foppFK = (* in DG cases div 2 *)
|
wneuper@816
|
85 |
EmptyFoppFK (*DG internal*)
|
wneuper@816
|
86 |
| FormFK of cterm'
|
wneuper@816
|
87 |
| PpcFK of cterm' ppc;
|
wneuper@816
|
88 |
fun foppFK2str (FormFK ct') ="FormFK "^ct'
|
wneuper@816
|
89 |
| foppFK2str (PpcFK ppc) ="PpcFK "^(ppc2str ppc)
|
wneuper@816
|
90 |
| foppFK2str EmptyFoppFK ="EmptyFoppFK";
|
wneuper@816
|
91 |
|
wneuper@816
|
92 |
|
wneuper@816
|
93 |
datatype nest = Open | Closed | Nundef;
|
wneuper@816
|
94 |
fun nest2str Open = "Open"
|
wneuper@816
|
95 |
| nest2str Closed = "Closed"
|
wneuper@816
|
96 |
| nest2str Nundef = "Nundef";
|
wneuper@816
|
97 |
|
wneuper@816
|
98 |
type indent = int;
|
wneuper@816
|
99 |
datatype edit = EdUndef | Write | Protect;
|
wneuper@816
|
100 |
(* bridge --> kernel *)
|
wneuper@816
|
101 |
(* bridge <-> kernel *)
|
wneuper@816
|
102 |
(* needed in dialog.sml *) (* bridge <-- kernel *)
|
wneuper@816
|
103 |
fun edit2str EdUndef = "EdUndef"
|
wneuper@816
|
104 |
| edit2str Write = "Write"
|
wneuper@816
|
105 |
| edit2str Protect = "Protect";
|
wneuper@816
|
106 |
|
wneuper@816
|
107 |
|
wneuper@816
|
108 |
datatype inout =
|
wneuper@816
|
109 |
New_User | End_User (*<->*)
|
wneuper@816
|
110 |
| New_Proof | End_Proof (*<->*)
|
wneuper@816
|
111 |
| Command of user_cmd (*-->*)
|
wneuper@816
|
112 |
| Request of string | Message of string (*<--*)
|
wneuper@816
|
113 |
| Error_ of string | System of string (*<--*)
|
wneuper@816
|
114 |
| FoPpcFK of foppFK (*-->*)
|
wneuper@816
|
115 |
| FormKF of cellID * edit * indent * nest * cterm' (*<--*)
|
wneuper@816
|
116 |
| PpcKF of cellID * edit * indent * nest * (pblmet * item ppc) (*<--*)
|
wneuper@816
|
117 |
| RuleFK of tac (*-->*)
|
wneuper@816
|
118 |
| RuleKF of edit * tac (*<--*)
|
wneuper@1050
|
119 |
| RefinedKF of (pblID * ((itm list) * ((bool * term) list))) (*<--*)
|
wneuper@816
|
120 |
| Select of tac list (*<--*)
|
wneuper@816
|
121 |
| RefineKF of match list (*<--*)
|
wneuper@816
|
122 |
| Speed of int (*<--*)
|
wneuper@816
|
123 |
| Active of int (*<--*)
|
wneuper@816
|
124 |
| Domain of domID; (*<--*)
|
wneuper@816
|
125 |
|
wneuper@816
|
126 |
fun inout2str End_Proof = "End_Proof"
|
wneuper@816
|
127 |
| inout2str (Command user_cmd) = "Command "^(user_cmd2str user_cmd)
|
wneuper@816
|
128 |
| inout2str (Request s) = "Request "^s
|
wneuper@816
|
129 |
| inout2str (Message s) = "Message "^s
|
wneuper@816
|
130 |
| inout2str (Error_ s) = "Error_ "^s
|
wneuper@816
|
131 |
| inout2str (System s) = "System "^s
|
wneuper@816
|
132 |
| inout2str (FoPpcFK foppFK) = "FoPpcFK "^(foppFK2str foppFK)
|
wneuper@816
|
133 |
| inout2str (FormKF (cellID, edit, indent, nest, ct')) =
|
wneuper@816
|
134 |
"FormKF ("^(string_of_int cellID)^","
|
wneuper@816
|
135 |
^(edit2str edit)^","^(string_of_int indent)^","
|
wneuper@816
|
136 |
^(nest2str nest)^",("
|
wneuper@816
|
137 |
^ct' ^")"
|
wneuper@816
|
138 |
| inout2str (PpcKF (cellID, edit, indent, nest, (pm,itemppc))) =
|
wneuper@816
|
139 |
"PpcKF ("^(string_of_int cellID)^","
|
wneuper@816
|
140 |
^(edit2str edit)^","^(string_of_int indent)^","
|
wneuper@816
|
141 |
^(nest2str nest)^",("
|
wneuper@816
|
142 |
^(pblmet2str pm)^","^(itemppc2str itemppc)^"))"
|
wneuper@816
|
143 |
| inout2str (RuleKF (edit,tac)) = "RuleKF "^
|
wneuper@816
|
144 |
pair2str(edit2str edit,tac2str tac)
|
wneuper@816
|
145 |
| inout2str (RuleFK tac) = "RuleFK "^(tac2str tac)
|
wneuper@816
|
146 |
| inout2str (Select tacs)=
|
wneuper@816
|
147 |
"Select "^((strs2str' o (map tac2str)) tacs)
|
wneuper@816
|
148 |
| inout2str (RefineKF ms) = "RefineKF "^(matchs2str ms)
|
wneuper@816
|
149 |
| inout2str (Speed i) = "Speed "^(string_of_int i)
|
wneuper@816
|
150 |
| inout2str (Active i) = "Active "^(string_of_int i)
|
wneuper@816
|
151 |
| inout2str (Domain dI) = "Domain "^dI;
|
wneuper@816
|
152 |
fun inouts2str ios = (strs2str' o (map inout2str)) ios;
|
wneuper@816
|
153 |
|
wneuper@819
|
154 |
datatype mout =
|
wneuper@816
|
155 |
Form' of inout (* packing cterm' | cterm' ppc *)
|
wneuper@816
|
156 |
| Problems of inout (* passes specify (and solve) *)
|
wneuper@816
|
157 |
| Error' of inout
|
wneuper@816
|
158 |
| EmptyMout;
|
wneuper@819
|
159 |
|
wneuper@816
|
160 |
fun mout2str (Form' inout) ="Form' "^(inout2str inout)
|
wneuper@816
|
161 |
| mout2str (Error' inout) ="Error' "^(inout2str inout)
|
wneuper@816
|
162 |
| mout2str (EmptyMout ) ="EmptyMout";
|
wneuper@816
|
163 |
|
wneuper@1408
|
164 |
(*fun Form'2str (Form' )*)
|
wneuper@1408
|
165 |
|
wneuper@816
|
166 |
|
wneuper@825
|
167 |
|
wneuper@825
|
168 |
|
wneuper@825
|
169 |
|
wneuper@816
|
170 |
(* init pbl with ...,dsc,empty | [] *)
|
wneuper@816
|
171 |
fun init_pbl pbt =
|
wneuper@816
|
172 |
let
|
wneuper@816
|
173 |
fun pbt2itm (f,(d,t)) =
|
wneuper@816
|
174 |
((0,[],false,f,Inc((d,[]),(e_term,[]))):itm);
|
wneuper@816
|
175 |
in map pbt2itm pbt end;
|
wneuper@1297
|
176 |
(*take formal parameters from pbt, for transfer from pbl/met-hierarchy*)
|
wneuper@1297
|
177 |
fun init_pbl' pbt =
|
wneuper@1297
|
178 |
let
|
wneuper@1297
|
179 |
fun pbt2itm (f,(d,t)) =
|
wneuper@1297
|
180 |
((0,[],false,f,Inc((d,[t]),(e_term,[]))):itm);
|
wneuper@1297
|
181 |
in map pbt2itm pbt end;
|
wneuper@816
|
182 |
|
agriesma@328
|
183 |
|
agriesma@328
|
184 |
(*generate 1 ppobj in ptree*)
|
wneuper@816
|
185 |
fun generate1 thy (Add_Given' (_, itmlist)) Uistate (pos as (p,p_)) pt =
|
wneuper@1971
|
186 |
(pos:pos',[],Form' (PpcKF (0,EdUndef,0,Nundef,
|
wneuper@1971
|
187 |
(Upblmet,itms2itemppc thy [][]))),
|
wneuper@816
|
188 |
case p_ of Pbl => update_pbl pt p itmlist
|
wneuper@816
|
189 |
| Met => update_met pt p itmlist)
|
wneuper@816
|
190 |
| generate1 thy (Add_Find' (_, itmlist)) Uistate (pos as (p,p_)) pt =
|
wneuper@816
|
191 |
(pos,[],Form' (PpcKF (0,EdUndef,0,Nundef,(Upblmet,itms2itemppc thy [][]))),
|
wneuper@816
|
192 |
case p_ of Pbl => update_pbl pt p itmlist
|
wneuper@816
|
193 |
| Met => update_met pt p itmlist)
|
wneuper@816
|
194 |
| generate1 thy (Add_Relation' (_, itmlist)) Uistate (pos as (p,p_)) pt =
|
wneuper@816
|
195 |
(pos,[],Form' (PpcKF (0,EdUndef,0,Nundef,(Upblmet,itms2itemppc thy [][]))),
|
wneuper@816
|
196 |
case p_ of Pbl => update_pbl pt p itmlist
|
wneuper@816
|
197 |
| Met => update_met pt p itmlist)
|
wneuper@816
|
198 |
|
wneuper@839
|
199 |
| generate1 thy (Specify_Theory' domID) Uistate (pos as (p,_)) pt =
|
wneuper@816
|
200 |
(pos,[],Form' (PpcKF (0,EdUndef,0,Nundef,(Upblmet,itms2itemppc thy [][]))),
|
wneuper@816
|
201 |
update_domID pt p domID)
|
wneuper@816
|
202 |
|
wneuper@816
|
203 |
| generate1 thy (Specify_Problem' (pI, (ok, (itms, pre)))) Uistate
|
wneuper@816
|
204 |
(pos as (p,_)) pt =
|
wneuper@816
|
205 |
let val pt = update_pbl pt p itms
|
wneuper@816
|
206 |
val pt = update_pblID pt p pI
|
wneuper@1250
|
207 |
in ((p,Pbl),[],
|
wneuper@816
|
208 |
Form' (PpcKF (0,EdUndef,0,Nundef,(Upblmet,itms2itemppc thy [][]))),
|
wneuper@816
|
209 |
pt) end
|
wneuper@816
|
210 |
|
wneuper@816
|
211 |
| generate1 thy (Specify_Method' (mID, oris, itms)) Uistate
|
wneuper@816
|
212 |
(pos as (p,_)) pt =
|
wneuper@816
|
213 |
let val pt = update_oris pt p oris
|
wneuper@816
|
214 |
val pt = update_met pt p itms
|
wneuper@816
|
215 |
val pt = update_metID pt p mID
|
wneuper@816
|
216 |
in ((p,Met),[],
|
wneuper@816
|
217 |
Form' (PpcKF (0,EdUndef,0,Nundef,(Upblmet,itms2itemppc thy [][]))),
|
wneuper@816
|
218 |
pt) end
|
wneuper@816
|
219 |
|
wneuper@856
|
220 |
| generate1 thy (Model_Problem' (_, itms)) Uistate (pos as (p,_)) pt =
|
wneuper@856
|
221 |
(* val (itms,pos as (p,_)) = (pbl, pos);
|
wneuper@856
|
222 |
*)
|
wneuper@856
|
223 |
let val pt = update_pbl pt p itms
|
wneuper@856
|
224 |
in (pos,[],Form'(PpcKF(0,EdUndef,0,Nundef,
|
wneuper@856
|
225 |
(Upblmet,itms2itemppc thy [][]))), pt) end
|
wneuper@816
|
226 |
|
wneuper@816
|
227 |
| generate1 thy (Refine_Tacitly' (pI,pIre,domID,metID,pbl))
|
wneuper@816
|
228 |
Uistate (pos as (p,_)) pt =
|
wneuper@816
|
229 |
let val pt = update_pbl pt p pbl
|
wneuper@816
|
230 |
val pt = update_orispec pt p (domID,pIre,metID)
|
wneuper@816
|
231 |
in (pos,[],
|
wneuper@816
|
232 |
Form'(PpcKF(0,EdUndef,0,Nundef,(Upblmet,itms2itemppc thy [][]))),
|
wneuper@816
|
233 |
pt) end
|
wneuper@816
|
234 |
|
wneuper@1050
|
235 |
| generate1 thy (Refine_Problem' (pI,_)) Uistate (pos as (p,_)) pt =
|
wneuper@1050
|
236 |
let val (dI,_,mI) = get_obj g_spec pt p
|
wneuper@1050
|
237 |
val pt = update_spec pt p (dI, pI, mI)
|
wneuper@1050
|
238 |
in (pos,[],
|
wneuper@1050
|
239 |
Form'(PpcKF(0,EdUndef,0,Nundef,(Upblmet,itms2itemppc thy [][]))),pt)
|
wneuper@1050
|
240 |
end
|
wneuper@816
|
241 |
|
wneuper@1590
|
242 |
| generate1 thy (Apply_Method' (_,topt, is)) _ (pos as (p,p_)) pt =
|
wneuper@2146
|
243 |
(writeln("###generate1 Apply_Method': pos = "^pos'2str (p,p_));
|
wneuper@2146
|
244 |
writeln("###generate1 Apply_Method': topt= "^termopt2str topt);
|
wneuper@2146
|
245 |
writeln("###generate1 Apply_Method': is = "^istate2str is);
|
wneuper@2109
|
246 |
case topt of
|
wneuper@1590
|
247 |
Some t =>
|
wneuper@816
|
248 |
let val (pt,_) = cappend_form pt p is t
|
wneuper@2146
|
249 |
val _= writeln("###generate1 Apply_Method: after cappend")
|
wneuper@2109
|
250 |
in (pos,[(*WN0502: pblnd generated without children*)], EmptyMout,pt)
|
wneuper@2109
|
251 |
end
|
wneuper@816
|
252 |
| None =>
|
wneuper@1590
|
253 |
(pos,[],EmptyMout,update_env pt p (Some is)))
|
wneuper@816
|
254 |
|
wneuper@816
|
255 |
| generate1 thy (Take' t) l (p,p_) pt = (* val (Take' t) = m; *)
|
neuper@750
|
256 |
let val p = let val (ps,p') = split_last p(*no connex to prev.ppobj*)
|
agriesma@328
|
257 |
in if p'=0 then ps@[1] else p end;
|
neuper@750
|
258 |
val (pt,c) = cappend_form pt p l t;
|
agriesma@328
|
259 |
in ((p,Frm):pos', c,
|
neuper@750
|
260 |
Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str t)), pt) end
|
agriesma@328
|
261 |
|
agriesma@328
|
262 |
(* val (l, (p,p_)) = (RrlsState is, p);
|
agriesma@328
|
263 |
*)
|
wneuper@1360
|
264 |
| generate1 thy (Begin_Trans' t) l (p,Frm) pt =
|
wneuper@1408
|
265 |
let val (pt,c) = cappend_form pt p l t
|
wneuper@1408
|
266 |
val pt = update_branch pt p TransitiveB (*040312*)
|
wneuper@1360
|
267 |
(*replace the old PrfOjb ~~~~~*)
|
wneuper@1360
|
268 |
val p = (lev_on o lev_dn(*starts with [...,0]*)) p;
|
wneuper@1360
|
269 |
val (pt,c) = cappend_form pt p l t;(*FIXME.0402 same istate ???*)
|
neuper@750
|
270 |
in ((p,Frm), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str t)),
|
neuper@750
|
271 |
pt) end
|
wneuper@1408
|
272 |
|
wneuper@1360
|
273 |
| generate1 thy (Begin_Trans' t) l (p ,Res) pt =
|
wneuper@1360
|
274 |
(*append after existing PrfObj _________*)
|
wneuper@1360
|
275 |
generate1 thy (Begin_Trans' t) l (lev_on p,Frm) pt
|
agriesma@328
|
276 |
|
wneuper@1360
|
277 |
| generate1 thy (End_Trans' tasm) l (p,p_) pt =
|
wneuper@1360
|
278 |
let val p' = lev_up p
|
wneuper@1360
|
279 |
val (pt,c) = append_result pt p' l tasm Complete;
|
neuper@750
|
280 |
in ((p',Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str t)),
|
neuper@750
|
281 |
pt) end
|
agriesma@328
|
282 |
|
neuper@750
|
283 |
| generate1 thy (Rewrite_Inst' (_,_,_,_,subs',thm',f,(f',asm))) l (p,p_) pt =
|
wneuper@2109
|
284 |
let val _= writeln("###generate1 Rewrite_Inst': pos= "^pos'2str (p,p_));
|
wneuper@2109
|
285 |
val (pt,c) = cappend_atomic pt p l f
|
neuper@750
|
286 |
(Rewrite_Inst (subst2subs subs',thm')) (f',asm) Complete;
|
wneuper@1408
|
287 |
val pt = update_branch pt p TransitiveB (*040312*)
|
neuper@750
|
288 |
(*val pt = union_asm pt (par_pblobj pt p) (map (rpair p) asm);9.6.03??*)
|
neuper@750
|
289 |
in ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str f')),
|
neuper@750
|
290 |
pt) end
|
agriesma@328
|
291 |
|
agriesma@328
|
292 |
| generate1 thy (Rewrite' (thy',ord',rls',pa,thm',f,(f',asm))) l (p,p_) pt =
|
wneuper@2109
|
293 |
let val _= writeln("###generate1 Rewrite': pos= "^pos'2str (p,p_))
|
wneuper@2109
|
294 |
val (pt,c) = cappend_atomic pt p l f (Rewrite thm') (f',asm) Complete
|
wneuper@1408
|
295 |
val pt = update_branch pt p TransitiveB (*040312*)
|
neuper@750
|
296 |
(*val pt = union_asm pt (par_pblobj pt p) (map (rpair p) asm);9.6.03??*)
|
neuper@750
|
297 |
in ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str f')),
|
neuper@750
|
298 |
pt)end
|
agriesma@328
|
299 |
|
wneuper@1360
|
300 |
| generate1 thy (Rewrite_Asm' all) l p pt =
|
wneuper@1360
|
301 |
generate1 thy (Rewrite' all) l p pt
|
agriesma@328
|
302 |
|
agriesma@328
|
303 |
| generate1 thy (Rewrite_Set_Inst' (_,_,subs',rls',f,(f',asm))) l (p,p_) pt =
|
wneuper@2035
|
304 |
(* val (thy, Rewrite_Set_Inst' (_,_,subs',rls',f,(f',asm)), l, (p,p_), pt) =
|
wneuper@2035
|
305 |
(assoc_thy "Isac.thy", tac_, is, pos, pt);
|
wneuper@2035
|
306 |
*)
|
wneuper@2109
|
307 |
let val _= writeln("###generate1 Rewrite_Set_Inst': pos= "^pos'2str (p,p_))
|
wneuper@2109
|
308 |
val (pt,c) = cappend_atomic pt p l f
|
wneuper@1408
|
309 |
(Rewrite_Set_Inst (subst2subs subs',id_rls rls')) (f',asm) Complete
|
wneuper@1408
|
310 |
val pt = update_branch pt p TransitiveB (*040312*)
|
neuper@750
|
311 |
(*val pt = union_asm pt (par_pblobj pt p) (map (rpair p) asm');9.6.03??*)
|
neuper@750
|
312 |
in ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str f')),
|
neuper@750
|
313 |
pt) end
|
agriesma@328
|
314 |
|
wneuper@1408
|
315 |
| generate1 thy (Detail_Set_Inst' (_,_,subs,rls,f,(f',asm))) l (p,p_) pt =
|
wneuper@1408
|
316 |
let val (pt,c) = cappend_form pt p l f
|
wneuper@1408
|
317 |
val pt = update_branch pt p TransitiveB (*040312*)
|
wneuper@1408
|
318 |
|
wneuper@1408
|
319 |
val is = init_istate (Rewrite_Set_Inst (subst2subs subs, id_rls rls))
|
wneuper@1590
|
320 |
val tac_ = Apply_Method' (e_metID, Some t, is)
|
wneuper@1408
|
321 |
val pos' = ((lev_on o lev_dn) p, Frm)
|
wneuper@1408
|
322 |
in (*implicit Take*) generate1 thy tac_ is pos' pt end
|
wneuper@1408
|
323 |
|
agriesma@328
|
324 |
| generate1 thy (Rewrite_Set' (_,_,rls',f,(f',asm))) l (p,p_) pt =
|
wneuper@2109
|
325 |
let val _= writeln("###generate1 Rewrite_Set': pos= "^pos'2str (p,p_))
|
wneuper@2109
|
326 |
val (pt,c) = cappend_atomic pt p l f
|
wneuper@1408
|
327 |
(Rewrite_Set (id_rls rls')) (f',asm) Complete
|
wneuper@1408
|
328 |
val pt = update_branch pt p TransitiveB (*040312*)
|
neuper@750
|
329 |
(*val pt = union_asm pt (par_pblobj pt p) (map (rpair p) asm');9.6.03??*)
|
neuper@750
|
330 |
in ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str f')),
|
neuper@750
|
331 |
pt) end
|
agriesma@328
|
332 |
|
wneuper@1408
|
333 |
| generate1 thy (Detail_Set' (_,_,rls,f,(f',asm))) l (p,p_) pt =
|
wneuper@1408
|
334 |
let val (pt,c) = cappend_form pt p l f
|
wneuper@1408
|
335 |
val pt = update_branch pt p TransitiveB (*040312*)
|
wneuper@1408
|
336 |
|
wneuper@1408
|
337 |
val is = init_istate (Rewrite_Set (id_rls rls))
|
wneuper@1590
|
338 |
val tac_ = Apply_Method' (e_metID, Some t, is)
|
wneuper@1408
|
339 |
val pos' = ((lev_on o lev_dn) p, Frm)
|
wneuper@1408
|
340 |
in (*implicit Take*) generate1 thy tac_ is pos' pt end
|
wneuper@1408
|
341 |
|
neuper@732
|
342 |
| generate1 thy (Check_Postcond' (pI,(scval,asm))) l (p,p_) pt =
|
wneuper@2109
|
343 |
let val _= writeln("###generate1 Check_Postcond': pos= "^pos'2str (p,p_))
|
wneuper@2109
|
344 |
(*val (l',_) = get_obj g_loc pt p..don't overwrite with l from subpbl*)
|
wneuper@1408
|
345 |
val (pt,c) = append_result pt p l (scval,map str2term asm) Complete
|
neuper@750
|
346 |
in ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p),
|
wneuper@1408
|
347 |
Nundef, term2str scval)), pt) end
|
agriesma@328
|
348 |
|
agriesma@328
|
349 |
| generate1 thy (Calculate' (thy',op_,f,(f',thm'))) l (p,p_) pt =
|
wneuper@1408
|
350 |
let val (pt,c) = cappend_atomic pt p l f (Calculate op_) (f',[]) Complete;
|
neuper@750
|
351 |
in ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str f')),
|
neuper@750
|
352 |
pt)end
|
agriesma@328
|
353 |
|
neuper@732
|
354 |
| generate1 thy (Check_elementwise' (consts,pred,(f',asm))) l (p,p_) pt =
|
wneuper@2109
|
355 |
let val _=writeln("###generate1 Check_elementwise': pos= "^pos'2str (p,p_))
|
wneuper@2109
|
356 |
val (pt,c) = cappend_atomic pt p l consts
|
neuper@750
|
357 |
(Check_elementwise pred) (f',asm) Complete;
|
neuper@750
|
358 |
in ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, term2str f')),
|
neuper@750
|
359 |
pt)end
|
agriesma@328
|
360 |
|
agriesma@328
|
361 |
| generate1 thy (Or_to_List' (ors,list)) l (p,p_) pt =
|
neuper@750
|
362 |
let val (pt,c) = cappend_atomic pt p l ors
|
neuper@750
|
363 |
Or_to_List (list,[]) Complete;
|
neuper@750
|
364 |
in ((p,Res), c, Form' (FormKF(~1,EdUndef,(length p), Nundef, term2str list)),
|
neuper@750
|
365 |
pt)end
|
agriesma@328
|
366 |
|
wneuper@807
|
367 |
| generate1 thy (Tac_ (_,f,id,f')) l (p,p_) pt =
|
neuper@750
|
368 |
let val (pt,c) = cappend_atomic pt p l (str2term f)
|
wneuper@807
|
369 |
(Tac id) (str2term f',[]) Complete;
|
agriesma@328
|
370 |
in ((p,Res), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, f')), pt)end
|
agriesma@328
|
371 |
|
wneuper@1122
|
372 |
| generate1 thy (Subproblem' ((domID, pblID, metID), oris, hdl, fmz_, f))
|
wneuper@1122
|
373 |
l (p,p_) pt =
|
wneuper@2109
|
374 |
let val _=writeln("###generate1 Subproblem': pos= "^pos'2str (p,p_))
|
wneuper@2109
|
375 |
val (pt,c) = cappend_problem pt p l (fmz_, (domID, pblID, metID))
|
wneuper@1122
|
376 |
(oris, (domID, pblID, metID), hdl);
|
wneuper@856
|
377 |
(*val pbl = init_pbl ((#ppc o get_pbt) pblID);
|
wneuper@856
|
378 |
val pt = update_pblppc pt p pbl;--------4.9.03->Model_Problem*)
|
agriesma@328
|
379 |
(*val _= writeln("### generate1: is([3],Frm)= "^
|
agriesma@328
|
380 |
(istate2str (get_istate pt ([3],Frm))));*)
|
agriesma@328
|
381 |
val f = Sign.string_of_term (sign_of thy) f;
|
agriesma@328
|
382 |
in ((p,Pbl), c, Form' (FormKF (~1,EdUndef,(length p), Nundef, f)), pt) end
|
agriesma@328
|
383 |
|
agriesma@328
|
384 |
| generate1 thy m' _ _ _ =
|
wneuper@807
|
385 |
raise error ("generate1: not impl.for "^(tac_2str m'))
|
agriesma@328
|
386 |
;
|
agriesma@328
|
387 |
|
agriesma@328
|
388 |
|
agriesma@328
|
389 |
fun generate_hard thy m' (p,p_) pt =
|
agriesma@328
|
390 |
let
|
agriesma@328
|
391 |
val p = case p_ of Frm => p | Res => lev_on p
|
agriesma@328
|
392 |
| _ => raise error ("generate_hard: call by "^(pos'2str (p,p_)));
|
agriesma@328
|
393 |
in generate1 thy m' e_istate (p,p_) pt end;
|
wneuper@1360
|
394 |
|
wneuper@1360
|
395 |
(*tacis are in reverse order from nxt_solve_/specify_: last = hd*)
|
wneuper@1446
|
396 |
fun generate ([]: taci list) ptp =
|
wneuper@1446
|
397 |
(writeln("### generate END-------------------------------");
|
wneuper@1446
|
398 |
ptp)
|
wneuper@1408
|
399 |
(* val (tacis, (pt, _)) = (tacis, ptp);
|
wneuper@1408
|
400 |
*)
|
wneuper@1971
|
401 |
| generate tacis (pt, c, _:pos'(*!!dropped!!*)) =
|
wneuper@1360
|
402 |
let val (tacis', (_, tac_, (p, is))) = split_last tacis
|
wneuper@1971
|
403 |
val (p',c',_,pt') = generate1 (assoc_thy "Isac.thy") tac_ is p pt
|
wneuper@1971
|
404 |
in generate tacis' (pt', c@c', p') end;
|
wneuper@1360
|
405 |
|
wneuper@1408
|
406 |
|
wneuper@1408
|
407 |
|
wneuper@1360
|
408 |
(*. a '_deriv'ation is constructed during 'reverse rewring' by an Rrls *
|
wneuper@1360
|
409 |
* of for connecting a user-input formula with the current calc-state. *
|
wneuper@1360
|
410 |
*# It is somewhat incompatible with the rest of the math-engine: *
|
wneuper@1360
|
411 |
* (1) it is not created by a script *
|
wneuper@1360
|
412 |
* (2) thus there cannot be another user-input within a derivation *
|
wneuper@1360
|
413 |
*# It suffers particularily from the not-well-foundedness of the math-engine*
|
wneuper@1360
|
414 |
* (1) FIXME other branchtyptes than Transitive will change 'embed_deriv' *
|
wneuper@1360
|
415 |
* (2) FIXME and eventually 'compare_step' (ie. the script interpreter) *
|
wneuper@1360
|
416 |
* (3) FIXME and eventually 'lev_back' *
|
wneuper@1360
|
417 |
*# Some improvements are evident FIXME.040215 '_deriv'ation: *
|
wneuper@1360
|
418 |
* (1) FIXME nest Rls_ in 'make_deriv' *
|
wneuper@1360
|
419 |
* (2) FIXME do the not-reversed part in 'make_deriv' by scripts -- thus *
|
wneuper@1360
|
420 |
* user-input will become possible in this part of a derivation *
|
wneuper@1360
|
421 |
* (3) FIXME do (2) only if a derivation has been found -- for efficiency, *
|
wneuper@1360
|
422 |
* while a non-derivable inform requires to step until End_Proof' *
|
wneuper@1360
|
423 |
* (4) FIXME find criteria on when _not_ to step until End_Proof' *
|
wneuper@1360
|
424 |
* (5) FIXME
|
wneuper@1360
|
425 |
.*)
|
wneuper@1360
|
426 |
(*.update pos in tacis for embedding by generate.*)
|
wneuper@1360
|
427 |
(* val
|
wneuper@1360
|
428 |
*)
|
wneuper@1360
|
429 |
fun insert_pos _ [] = []
|
wneuper@1360
|
430 |
| insert_pos (p:pos) (((tac,tac_,(_, ist))::tacis):taci list) =
|
wneuper@1360
|
431 |
((tac,tac_,((p, Res), ist)):taci)
|
wneuper@1360
|
432 |
::((insert_pos (lev_on p) tacis):taci list);
|
wneuper@1360
|
433 |
|
wneuper@1360
|
434 |
(*.embed the tacis created by a '_deriv'ation;
|
wneuper@1360
|
435 |
tacis are in order, thus are reverted for generate.*)
|
wneuper@1399
|
436 |
(* val (tacis, (pt, pos as (p, Frm))) = (tacis', ptp);
|
wneuper@1399
|
437 |
*)
|
wneuper@1360
|
438 |
fun embed_deriv (*[] ptp = ptp ...sys.form = input.form... excluded in inform
|
wneuper@1360
|
439 |
| embed_deriv *)tacis (pt, pos as (p, Frm)) =
|
wneuper@1360
|
440 |
(*inform at Frm: replace the whole PrfObj by a Transitive-ProfObj FIXME?0402
|
wneuper@1360
|
441 |
and transfer the istate (from _after_ compare_deriv) from Frm to Res*)
|
wneuper@1360
|
442 |
let val (_, Rewrite'(_,_,_,_,_,_,(res, asm)), _) = last_elem tacis
|
wneuper@1408
|
443 |
val (Some ist,_) = get_obj g_loc pt p
|
wneuper@1408
|
444 |
val form = get_obj g_form pt p
|
wneuper@1399
|
445 |
(*val p = lev_on p; ---------------only difference*)
|
wneuper@1360
|
446 |
val tacis = (Begin_Trans, Begin_Trans' form, (pos, Uistate))
|
wneuper@1399
|
447 |
::(insert_pos ((lev_on o lev_dn) p) tacis)
|
wneuper@1360
|
448 |
@ [(End_Trans, End_Trans' (res, asm),
|
wneuper@1399
|
449 |
(pos_plus (length tacis) (lev_dn p, Res),
|
wneuper@1399
|
450 |
new_val res ist))]
|
wneuper@1360
|
451 |
val {nrls,...} = get_met (get_obj g_metID pt (par_pblobj pt p))
|
wneuper@2035
|
452 |
val (pt, c, pos as (p,_)) = generate (rev tacis) (pt, [], (p, Res))
|
wneuper@1360
|
453 |
val pt = update_tac pt p (Derive (id_rls nrls))
|
wneuper@1399
|
454 |
(*FIXME.040216 struct.ctree*)
|
wneuper@1399
|
455 |
val pt = update_branch pt p TransitiveB
|
wneuper@2035
|
456 |
in (c, (pt, pos)) end
|
wneuper@1360
|
457 |
|
wneuper@1360
|
458 |
(* val (tacis, (pt, pos as (p, Res))) = (tacis', ptp);
|
wneuper@1360
|
459 |
*)
|
wneuper@1360
|
460 |
| embed_deriv tacis (pt, (p, Res)) =
|
wneuper@2146
|
461 |
(*inform at Res: append a Transitive-PrfObj FIXME?0402 other branch-types ?
|
wneuper@1360
|
462 |
and transfer the istate (from _after_ compare_deriv) from Res to new Res*)
|
wneuper@1360
|
463 |
let val (_, Rewrite'(_,_,_,_,_,_,(res, asm)), _) = last_elem tacis;
|
wneuper@1408
|
464 |
val (_, Some ist) = get_obj g_loc pt p
|
wneuper@1408
|
465 |
val (f,a) = get_obj g_result pt p
|
wneuper@1399
|
466 |
val p = lev_on p;(*---------------only difference*)
|
wneuper@1360
|
467 |
val tacis = (Begin_Trans, Begin_Trans' f, ((p, Frm), Uistate))
|
wneuper@1360
|
468 |
::(insert_pos ((lev_on o lev_dn) p) tacis)
|
wneuper@1360
|
469 |
@ [(End_Trans, End_Trans' (res, asm),
|
wneuper@1399
|
470 |
(pos_plus (length tacis) (lev_dn p, Res),
|
wneuper@1399
|
471 |
new_val res ist))];
|
wneuper@1360
|
472 |
val {nrls,...} = get_met (get_obj g_metID pt (par_pblobj pt p))
|
wneuper@2035
|
473 |
val (pt, c, pos as (p,_)) = generate (rev tacis) (pt, [], (p, Res))
|
wneuper@1360
|
474 |
val pt = update_tac pt p (Derive (id_rls nrls))
|
wneuper@1399
|
475 |
(*FIXME.040216 struct.ctree*)
|
wneuper@1399
|
476 |
val pt = update_branch pt p TransitiveB
|
wneuper@2035
|
477 |
in (c, (pt, pos)) end;
|
wneuper@1408
|
478 |
(*
|
wneuper@1408
|
479 |
val (_, Some ist) = get_obj g_loc pt p
|
wneuper@1408
|
480 |
val (f,a) = get_obj g_result pt p
|
wneuper@1408
|
481 |
|
wneuper@1408
|
482 |
|
wneuper@1408
|
483 |
*) |