walther@59747
|
1 |
(* Title: Specify/step-specify.sml
|
walther@59747
|
2 |
Author: Walther Neuper 2019
|
walther@59747
|
3 |
(c) due to copyright terms
|
walther@59747
|
4 |
*)
|
walther@59747
|
5 |
|
walther@59747
|
6 |
signature STEP_SPECIFY =
|
walther@59747
|
7 |
sig
|
walther@59791
|
8 |
(*val do_next: Step.specify_do_next requires LI.by_tactic, which is not yet known in Step_Specify*)
|
walther@59806
|
9 |
val by_tactic_input: Tactic.input -> Calc.T -> Chead.calcstate'
|
walther@59806
|
10 |
val by_tactic: Tactic.T -> Calc.T -> string * Chead.calcstate'
|
walther@59810
|
11 |
(* ---- keep, probably required later in devel. ----------------------------------------------- *)
|
walther@59810
|
12 |
val nxt_specify_init_calc: Selem.fmz
|
walther@59810
|
13 |
-> Calc.T * (Tactic.input * Tactic.T * (Pos.pos' * (Istate_Def.T * Proof.context))) list
|
walther@59810
|
14 |
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
|
walther@59810
|
15 |
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
|
walther@59747
|
16 |
|
walther@59747
|
17 |
end
|
walther@59747
|
18 |
|
walther@59747
|
19 |
(**)
|
walther@59747
|
20 |
structure Step_Specify(**): STEP_SPECIFY(**) =
|
walther@59747
|
21 |
struct
|
walther@59747
|
22 |
(**)
|
walther@59763
|
23 |
open Pos
|
walther@59763
|
24 |
open Ctree
|
walther@59763
|
25 |
open Chead
|
walther@59747
|
26 |
|
walther@59763
|
27 |
(* was fun Math_Engine.nxt_specify_ *)
|
walther@59806
|
28 |
fun by_tactic_input (tac as Tactic.Model_Problem) (pt, pos as (p, _)) =
|
walther@59763
|
29 |
let
|
walther@59763
|
30 |
val (oris, ospec, probl, spec, ctxt) = case get_obj I pt p of
|
walther@59763
|
31 |
PblObj {origin = (oris, ospec, _), probl, spec, ctxt, ...} => (oris, ospec, probl, spec, ctxt)
|
walther@59806
|
32 |
| _ => error "by_tactic_input Model_Problem; uncovered case get_obj"
|
walther@59763
|
33 |
val (dI, pI, mI) = some_spec ospec spec
|
walther@59763
|
34 |
val thy = Celem.assoc_thy dI
|
walther@59763
|
35 |
val mpc = (#ppc o Specify.get_met) mI (* just for reuse complete_mod_ *)
|
walther@59763
|
36 |
val {cas, ppc, ...} = Specify.get_pbt pI
|
walther@59763
|
37 |
val pbl = Generate.init_pbl ppc (* fill in descriptions *)
|
walther@59763
|
38 |
(*----------------if you think, this should be done by the Dialog
|
walther@59763
|
39 |
in the java front-end, search there for WN060225-modelProblem----*)
|
walther@59763
|
40 |
val (pbl, met) = case cas of
|
walther@59763
|
41 |
NONE => (pbl, [])
|
walther@59763
|
42 |
| _ => complete_mod_ (oris, mpc, ppc, probl)
|
walther@59763
|
43 |
(*----------------------------------------------------------------*)
|
walther@59763
|
44 |
val tac_ = Tactic.Model_Problem' (pI, pbl, met)
|
walther@59811
|
45 |
val (pos,c,_,pt) = Generate.generate1 tac_ (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59846
|
46 |
in ([(tac, tac_, (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos)) end
|
walther@59806
|
47 |
| by_tactic_input (Tactic.Add_Given ct) ptp = nxt_specif_additem "#Given" ct ptp
|
walther@59806
|
48 |
| by_tactic_input (Tactic.Add_Find ct) ptp = nxt_specif_additem "#Find" ct ptp
|
walther@59806
|
49 |
| by_tactic_input (Tactic.Add_Relation ct) ptp = nxt_specif_additem"#Relate" ct ptp
|
walther@59763
|
50 |
(*. called only if no_met is specified .*)
|
walther@59810
|
51 |
| by_tactic_input (Tactic.Refine_Tacitly pI) (ptp as (pt, pos as (p, _))) =
|
walther@59763
|
52 |
let
|
walther@59763
|
53 |
val (oris, dI, ctxt) = case get_obj I pt p of
|
walther@59763
|
54 |
(PblObj {origin = (oris, (dI, _, _), _), ctxt, ...}) => (oris, dI, ctxt)
|
walther@59806
|
55 |
| _ => error "by_tactic_input Refine_Tacitly: uncovered case get_obj"
|
walther@59763
|
56 |
val opt = Specify.refine_ori oris pI
|
walther@59763
|
57 |
in
|
walther@59763
|
58 |
case opt of
|
walther@59763
|
59 |
SOME pI' =>
|
walther@59763
|
60 |
let
|
walther@59763
|
61 |
val {met, ...} = Specify.get_pbt pI'
|
walther@59763
|
62 |
(*val pt = update_pbl pt p pbl ..done by Model_Problem*)
|
walther@59763
|
63 |
val mI = if length met = 0 then Celem.e_metID else hd met
|
walther@59763
|
64 |
val thy = Celem.assoc_thy dI
|
walther@59763
|
65 |
val (pos, c, _, pt) =
|
walther@59811
|
66 |
Generate.generate1 (Tactic.Refine_Tacitly' (pI, pI', dI, mI,(*pbl*)[])) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
67 |
in
|
walther@59763
|
68 |
([(Tactic.Refine_Tacitly pI, Tactic.Refine_Tacitly' (pI,pI',dI,mI,(*pbl*)[]),
|
walther@59846
|
69 |
(pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos))
|
walther@59763
|
70 |
end
|
walther@59763
|
71 |
| NONE => ([], [], ptp)
|
walther@59763
|
72 |
end
|
walther@59806
|
73 |
| by_tactic_input (Tactic.Refine_Problem pI) (ptp as (pt, pos as (p,_))) =
|
walther@59763
|
74 |
let
|
walther@59763
|
75 |
val (dI, dI', probl, ctxt) = case get_obj I pt p of
|
walther@59763
|
76 |
PblObj {origin= (_, (dI, _, _), _), spec = (dI', _, _), probl, ctxt, ...} =>
|
walther@59763
|
77 |
(dI, dI', probl, ctxt)
|
walther@59806
|
78 |
| _ => error "by_tactic_input Refine_Problem: uncovered case get_obj"
|
walther@59763
|
79 |
val thy = if dI' = Rule.e_domID then dI else dI'
|
walther@59763
|
80 |
in
|
walther@59763
|
81 |
case Specify.refine_pbl (Celem.assoc_thy thy) pI probl of
|
walther@59763
|
82 |
NONE => ([], [], ptp)
|
walther@59763
|
83 |
| SOME rfd =>
|
walther@59763
|
84 |
let
|
walther@59811
|
85 |
val (pos,c,_,pt) = Generate.generate1 (Tactic.Refine_Problem' rfd) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
86 |
in
|
walther@59846
|
87 |
([(Tactic.Refine_Problem pI, Tactic.Refine_Problem' rfd, (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos))
|
walther@59763
|
88 |
end
|
walther@59763
|
89 |
end
|
walther@59806
|
90 |
| by_tactic_input (Tactic.Specify_Problem pI) (pt, pos as (p,_)) =
|
walther@59763
|
91 |
let
|
walther@59763
|
92 |
val (oris, dI, dI', pI', probl, ctxt) = case get_obj I pt p of
|
walther@59763
|
93 |
PblObj {origin = (oris, (dI,_,_),_), spec = (dI',pI',_), probl, ctxt, ...} =>
|
walther@59763
|
94 |
(oris, dI, dI', pI', probl, ctxt)
|
walther@59763
|
95 |
| _ => error ""
|
walther@59763
|
96 |
val thy = Celem.assoc_thy (if dI' = Rule.e_domID then dI else dI');
|
walther@59763
|
97 |
val {ppc,where_,prls,...} = Specify.get_pbt pI
|
walther@59763
|
98 |
val pbl =
|
walther@59763
|
99 |
if pI' = Celem.e_pblID andalso pI = Celem.e_pblID
|
walther@59763
|
100 |
then (false, (Generate.init_pbl ppc, []))
|
walther@59763
|
101 |
else Specify.match_itms_oris thy probl (ppc,where_,prls) oris
|
walther@59763
|
102 |
(*FIXXXME~~~~~~~~~~~~~~~: take pbl and compare with new pI WN.8.03*)
|
walther@59810
|
103 |
val (c, pt) =
|
walther@59811
|
104 |
case Generate.generate1 (Tactic.Specify_Problem' (pI, pbl)) (Istate_Def.Uistate, ctxt) (pt, pos) of
|
walther@59810
|
105 |
((_, Pbl), c, _, pt) => (c, pt)
|
walther@59810
|
106 |
| _ => error ""
|
walther@59763
|
107 |
in
|
walther@59846
|
108 |
([(Tactic.Specify_Problem pI, Tactic.Specify_Problem' (pI, pbl), (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt, pos))
|
walther@59763
|
109 |
end
|
walther@59763
|
110 |
(* transfers oris (not required in pbl) to met-model for script-env
|
walther@59763
|
111 |
FIXME.WN.8.03: application of several mIDs to SAME model? *)
|
walther@59806
|
112 |
| by_tactic_input (Tactic.Specify_Method mID) (pt, pos as (p,_)) =
|
walther@59763
|
113 |
let
|
walther@59763
|
114 |
val (oris, pbl, dI, met, ctxt) = case get_obj I pt p of
|
walther@59763
|
115 |
PblObj {origin = (oris, _, _), probl = pbl, spec = (dI, _, _), meth=met, ctxt, ...}
|
walther@59763
|
116 |
=> (oris, pbl, dI, met, ctxt)
|
walther@59806
|
117 |
| _ => error "by_tactic_input Specify_Method: uncovered case get_obj"
|
walther@59763
|
118 |
val {ppc,pre,prls,...} = Specify.get_met mID
|
walther@59763
|
119 |
val thy = Celem.assoc_thy dI
|
walther@59763
|
120 |
val oris = Specify.add_field' thy ppc oris
|
walther@59763
|
121 |
val met = if met=[] then pbl else met (* WN0602 what if more itms in met? *)
|
walther@59763
|
122 |
val (_, (itms, _)) = Specify.match_itms_oris thy met (ppc,pre,prls ) oris
|
walther@59763
|
123 |
val itms = Specify.hack_until_review_Specify_2 mID itms
|
walther@59763
|
124 |
val (pos, c, _, pt) =
|
walther@59811
|
125 |
Generate.generate1 (Tactic.Specify_Method' (mID, oris, itms)) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
126 |
in
|
walther@59846
|
127 |
([(Tactic.Specify_Method mID, Tactic.Specify_Method' (mID, oris, itms), (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt, pos))
|
walther@59763
|
128 |
end
|
walther@59806
|
129 |
| by_tactic_input (Tactic.Specify_Theory dI) (pt, pos as (_, Pbl)) =
|
walther@59763
|
130 |
let
|
walther@59763
|
131 |
val ctxt = get_ctxt pt pos
|
walther@59763
|
132 |
val (pos, c, _, pt) =
|
walther@59811
|
133 |
Generate.generate1 (Tactic.Specify_Theory' dI) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
134 |
in (*FIXXXME: check if pbl can still be parsed*)
|
walther@59763
|
135 |
([(Tactic.Specify_Theory dI, Tactic.Specify_Theory' dI, (pos, (Istate_Def.Uistate, ctxt)))], c,
|
walther@59763
|
136 |
(pt, pos))
|
walther@59763
|
137 |
end
|
walther@59806
|
138 |
| by_tactic_input (Tactic.Specify_Theory dI) (pt, pos as (_, Met)) =
|
walther@59763
|
139 |
let
|
walther@59763
|
140 |
val ctxt = get_ctxt pt pos
|
walther@59811
|
141 |
val (pos, c, _, pt) = Generate.generate1 (Tactic.Specify_Theory' dI) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
142 |
in (*FIXXXME: check if met can still be parsed*)
|
walther@59763
|
143 |
([(Tactic.Specify_Theory dI, Tactic.Specify_Theory' dI, (pos, (Istate_Def.Uistate, ctxt)))], c, (pt, pos))
|
walther@59763
|
144 |
end
|
walther@59846
|
145 |
| by_tactic_input m' _ = error ("by_tactic_input: not impl. for " ^ Tactic.input_to_string m')
|
walther@59806
|
146 |
(* was fun Math_Engine.nxt_specify_ *)
|
walther@59806
|
147 |
|
walther@59806
|
148 |
|
walther@59806
|
149 |
(* was fun Chead.specify *)
|
walther@59806
|
150 |
fun by_tactic (Tactic.Init_Proof' (fmz, spec' as (dI', pI', mI'))) _ =
|
walther@59806
|
151 |
let (* either """"""""""""""" all empty or complete *)
|
walther@59806
|
152 |
val thy = Celem.assoc_thy dI'
|
walther@59806
|
153 |
val (oris, ctxt) =
|
walther@59806
|
154 |
if dI' = Rule.e_domID orelse pI' = Celem.e_pblID (*andalso? WN110511*)
|
walther@59846
|
155 |
then ([], ContextC.empty)
|
walther@59806
|
156 |
else pI' |> #ppc o Specify.get_pbt |> Specify.prep_ori fmz thy
|
walther@59806
|
157 |
(* these are deprecated vvvvvvvvvvvvvvvvvvvvvvvvvv*)
|
walther@59846
|
158 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty) (fmz, spec')
|
walther@59819
|
159 |
(oris, (dI',pI',mI'), Rule.e_term, ctxt)
|
walther@59846
|
160 |
val pt = update_loc' pt [] (SOME (Istate_Def.empty, ctxt), NONE)
|
walther@59806
|
161 |
in
|
walther@59806
|
162 |
case mI' of
|
walther@59806
|
163 |
["no_met"] => ("Refine_Tacitly", ([], [], (pt, ([], Pbl))))
|
walther@59806
|
164 |
| _ => ("ok", ([], [], (pt, ([], Pbl))))
|
walther@59806
|
165 |
end
|
walther@59806
|
166 |
(* ONLY for STARTING modeling phase *)
|
walther@59806
|
167 |
| by_tactic (Tactic.Model_Problem' (_, pbl, met)) (pt, pos as (p, _)) =
|
walther@59806
|
168 |
let
|
walther@59806
|
169 |
val (oris, dI',pI',mI', dI, ctxt) = case get_obj I pt p of
|
walther@59806
|
170 |
PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, _, _), ctxt, ...} =>
|
walther@59806
|
171 |
(oris, dI',pI',mI', dI, ctxt)
|
walther@59806
|
172 |
| _ => error "Step_Solve.by_tactic (Model_Problem': uncovered case get_obj"
|
walther@59806
|
173 |
val thy' = if dI = Rule.e_domID then dI' else dI
|
walther@59806
|
174 |
val thy = Celem.assoc_thy thy'
|
walther@59806
|
175 |
val {ppc, prls, where_, ...} = Specify.get_pbt pI'
|
walther@59806
|
176 |
val pre = Stool.check_preconds thy prls where_ pbl
|
walther@59806
|
177 |
val pb = foldl and_ (true, map fst pre)
|
walther@59806
|
178 |
val ((p, _), _, _, pt) =
|
walther@59811
|
179 |
Generate.generate1 (Tactic.Model_Problem'([],pbl,met)) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59806
|
180 |
val (_, _) = Chead.nxt_spec Pbl pb oris (dI', pI', mI') (pbl, met)
|
walther@59806
|
181 |
(ppc,(#ppc o Specify.get_met) mI') (dI',pI',mI');
|
walther@59806
|
182 |
in
|
walther@59806
|
183 |
("ok", ([], [], (pt, (p, Pbl))))
|
walther@59806
|
184 |
end
|
walther@59806
|
185 |
(* called only if no_met is specified *)
|
walther@59806
|
186 |
| by_tactic (Tactic.Refine_Tacitly' (pI, pIre, _, _, _)) (pt, pos) =
|
walther@59806
|
187 |
let
|
walther@59806
|
188 |
(* val (dI', ctxt) = case get_obj I pt p of
|
walther@59806
|
189 |
PblObj {origin= (_, (dI', _, _), _), ctxt, ...} => (dI', ctxt)
|
walther@59806
|
190 |
| _ => error "Step_Solve.by_tactic (Refine_Tacitly': uncovered case get_obj"*)
|
walther@59806
|
191 |
val {met, thy,...} = Specify.get_pbt pIre
|
walther@59806
|
192 |
val (domID, metID) = (Rule.string_of_thy thy, if length met = 0 then Celem.e_metID else hd met)
|
walther@59806
|
193 |
val ((p,_), _, _, pt) =
|
walther@59811
|
194 |
Generate.generate1 (Tactic.Refine_Tacitly' (pI, pIre, domID, metID, [(*pbl*)]))
|
walther@59846
|
195 |
(Istate_Def.Uistate, ContextC.empty) (pt, pos)
|
walther@59806
|
196 |
(* deprecated^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *)
|
walther@59806
|
197 |
(* val (pbl, pre, _) = ([], [], false)*)
|
walther@59806
|
198 |
in
|
walther@59806
|
199 |
("ok", ([], [], (pt,(p, Pbl))))
|
walther@59806
|
200 |
end
|
walther@59806
|
201 |
| by_tactic (Tactic.Refine_Problem' rfd) (pt, pos) =
|
walther@59806
|
202 |
let
|
walther@59806
|
203 |
val ctxt = get_ctxt pt pos
|
walther@59806
|
204 |
val (pos, _, _, pt) =
|
walther@59811
|
205 |
Generate.generate1 (Tactic.Refine_Problem' rfd) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59806
|
206 |
in
|
walther@59806
|
207 |
("ok", ([], [], (pt,pos)))
|
walther@59806
|
208 |
end
|
walther@59806
|
209 |
(*WN110515 initialise ctxt again from itms and add preconds*)
|
walther@59810
|
210 |
| by_tactic (Tactic.Specify_Problem' (pI, (ok, (itms, pre)))) (pt, pos as (p, _)) =
|
walther@59806
|
211 |
let
|
walther@59810
|
212 |
val (_, _, _, _, dI, _, ctxt, _) = case get_obj I pt p of
|
walther@59806
|
213 |
PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, _, mI), ctxt, meth = met, ...} =>
|
walther@59806
|
214 |
(oris, dI', pI', mI', dI, mI, ctxt, met)
|
walther@59806
|
215 |
| _ => error "Step_Solve.by_tactic (Specify_Problem': uncovered case get_obj"
|
walther@59806
|
216 |
val thy = Celem.assoc_thy dI
|
walther@59806
|
217 |
val (p, pt) =
|
walther@59811
|
218 |
case Generate.generate1 (Tactic.Specify_Problem' (pI, (ok, (itms, pre)))) (Istate_Def.Uistate, ctxt) (pt, pos) of
|
walther@59806
|
219 |
((p, Pbl), _, _, pt) => (p, pt)
|
walther@59806
|
220 |
| _ => error "Step_Solve.by_tactic (Specify_Problem': uncovered case generate1 (WARNING WHY ?)"
|
walther@59806
|
221 |
in
|
walther@59806
|
222 |
("ok", ([], [], (pt, (p, Pbl))))
|
walther@59806
|
223 |
end
|
walther@59806
|
224 |
(*WN110515 initialise ctxt again from itms and add preconds*)
|
walther@59806
|
225 |
| by_tactic (Tactic.Specify_Method' (mID, _, _)) (pt,pos as (p, _)) =
|
walther@59806
|
226 |
let
|
walther@59810
|
227 |
val (oris, _, _, mI', dI, _, pbl, met, ctxt) = case get_obj I pt p of
|
walther@59806
|
228 |
PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, pI, _), probl = pbl, meth = met, ctxt, ...} =>
|
walther@59806
|
229 |
(oris, dI', pI', mI', dI, pI, pbl, met, ctxt)
|
walther@59806
|
230 |
| _ => error "Step_Solve.by_tactic (Specify_Problem': uncovered case get_obj"
|
walther@59806
|
231 |
val {ppc, pre, prls,...} = Specify.get_met mID
|
walther@59806
|
232 |
val thy = Celem.assoc_thy dI
|
walther@59806
|
233 |
val oris = Specify.add_field' thy ppc oris
|
walther@59806
|
234 |
val met = if met = [] then pbl else met
|
walther@59810
|
235 |
val (_, (itms, _)) = Specify.match_itms_oris thy met (ppc, pre, prls) oris
|
walther@59806
|
236 |
val itms = Specify.hack_until_review_Specify_1 mI' itms
|
walther@59806
|
237 |
val (pos, _, _, pt) =
|
walther@59811
|
238 |
Generate.generate1 (Tactic.Specify_Method' (mID, oris, itms)) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59806
|
239 |
in
|
walther@59806
|
240 |
("ok", ([], [], (pt, pos)))
|
walther@59806
|
241 |
end
|
walther@59806
|
242 |
| by_tactic (Tactic.Add_Given' (ct, _)) (pt, p) = Chead.specify_additem "#Given" ct (pt, p)
|
walther@59806
|
243 |
| by_tactic (Tactic.Add_Find' (ct, _)) (pt, p) = Chead.specify_additem "#Find" ct (pt, p)
|
walther@59806
|
244 |
| by_tactic (Tactic.Add_Relation' (ct, _)) (pt, p) = Chead.specify_additem"#Relate" ct (pt, p)
|
walther@59810
|
245 |
| by_tactic (Tactic.Specify_Theory' domID) (pt, (p,p_)) =
|
walther@59806
|
246 |
let
|
walther@59806
|
247 |
val p_ = case p_ of Met => Met | _ => Pbl
|
walther@59806
|
248 |
val thy = Celem.assoc_thy domID
|
walther@59806
|
249 |
val (oris, dI', pI', mI', dI, pI, mI, pbl, met, ctxt) = case get_obj I pt p of
|
walther@59806
|
250 |
PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, pI, mI), probl = pbl, meth = met, ctxt, ...} =>
|
walther@59806
|
251 |
(oris, dI', pI', mI', dI, pI, mI, pbl, met, ctxt)
|
walther@59806
|
252 |
| _ => error "Step_Solve.by_tactic (Specify_Theory': uncovered case get_obj"
|
walther@59810
|
253 |
val _ = case p_ of Met => met | _ => pbl
|
walther@59806
|
254 |
val cpI = if pI = Celem.e_pblID then pI' else pI
|
walther@59806
|
255 |
val {prls = per, ppc, where_ = pwh, ...} = Specify.get_pbt cpI
|
walther@59806
|
256 |
val cmI = if mI = Celem.e_metID then mI' else mI
|
walther@59806
|
257 |
val {prls = mer, ppc = mpc, pre= mwh, ...} = Specify.get_met cmI
|
walther@59806
|
258 |
val pre = case p_ of
|
walther@59806
|
259 |
Met => (Stool.check_preconds thy mer mwh met)
|
walther@59806
|
260 |
| _ => (Stool.check_preconds thy per pwh pbl)
|
walther@59806
|
261 |
val pb = foldl and_ (true, map fst pre)
|
walther@59806
|
262 |
in
|
walther@59806
|
263 |
if domID = dI
|
walther@59806
|
264 |
then
|
walther@59810
|
265 |
let val (p_, _) = nxt_spec p_ pb oris (dI', pI', mI') (pbl, met) (ppc, mpc) (dI, pI, mI)
|
walther@59806
|
266 |
in
|
walther@59806
|
267 |
("ok", ([], [], (pt, (p, p_))))
|
walther@59806
|
268 |
end
|
walther@59806
|
269 |
else (*FIXME: check ppc wrt. (new!) domID ..? still parsable?*)
|
walther@59806
|
270 |
let
|
walther@59811
|
271 |
val ((p, p_), _, _, pt) = Generate.generate1 (Tactic.Specify_Theory' domID) (Istate_Def.Uistate, ctxt) (pt, (p,p_))
|
walther@59810
|
272 |
val (p_, _) = nxt_spec p_ pb oris (dI', pI', mI') (pbl, met) (ppc, mpc) (domID, pI, mI)
|
walther@59806
|
273 |
in
|
walther@59806
|
274 |
("ok", ([], [], (pt, (p, p_))))
|
walther@59806
|
275 |
end
|
walther@59806
|
276 |
end
|
walther@59806
|
277 |
| by_tactic _ _ = raise ERROR "Step_Specify.by_tactic uncovered pattern in fun.def"
|
walther@59806
|
278 |
(* was fun Chead.specify *)
|
walther@59806
|
279 |
|
walther@59806
|
280 |
(* create a calc-tree with oris via an cas.refined pbl *)
|
walther@59806
|
281 |
fun nxt_specify_init_calc ([], (dI, pI, mI)) =
|
walther@59806
|
282 |
if pI <> []
|
walther@59806
|
283 |
then (* from pbl-browser or from CAS cmd with pI=[e_pblID] *)
|
walther@59806
|
284 |
let
|
walther@59806
|
285 |
val {cas, met, ppc, thy, ...} = Specify.get_pbt pI
|
walther@59806
|
286 |
val dI = if dI = "" then Rule.theory2theory' thy else dI
|
walther@59806
|
287 |
val mI = if mI = [] then hd met else mI
|
walther@59806
|
288 |
val hdl = case cas of NONE => Auto_Prog.pblterm dI pI | SOME t => t
|
walther@59846
|
289 |
val (pt,_) = cappend_problem e_ctree [] (Istate_Def.Uistate, ContextC.empty) ([], (dI, pI, mI))
|
walther@59846
|
290 |
([], (dI,pI,mI), hdl, ContextC.empty)
|
walther@59806
|
291 |
val pt = update_spec pt [] (dI, pI, mI)
|
walther@59806
|
292 |
val pits = Generate.init_pbl' ppc
|
walther@59806
|
293 |
val pt = update_pbl pt [] pits
|
walther@59806
|
294 |
in ((pt, ([] , Pbl)), []) end
|
walther@59806
|
295 |
else
|
walther@59806
|
296 |
if mI <> []
|
walther@59806
|
297 |
then (* from met-browser *)
|
walther@59806
|
298 |
let
|
walther@59806
|
299 |
val {ppc, ...} = Specify.get_met mI
|
walther@59806
|
300 |
val dI = if dI = "" then "Isac_Knowledge" else dI
|
walther@59846
|
301 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty)
|
walther@59846
|
302 |
([], (dI, pI, mI)) ([], (dI, pI, mI), Rule.e_term, ContextC.empty)
|
walther@59806
|
303 |
val pt = update_spec pt [] (dI, pI, mI)
|
walther@59806
|
304 |
val mits = Generate.init_pbl' ppc
|
walther@59806
|
305 |
val pt = update_met pt [] mits
|
walther@59806
|
306 |
in ((pt, ([], Met)), []) end
|
walther@59806
|
307 |
else (* new example, pepare for interactive modeling *)
|
walther@59806
|
308 |
let
|
walther@59846
|
309 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty)
|
walther@59846
|
310 |
([], Celem.e_spec) ([], Celem.e_spec, Rule.e_term, ContextC.empty)
|
walther@59806
|
311 |
in ((pt, ([], Pbl)), []) end
|
walther@59806
|
312 |
| nxt_specify_init_calc (fmz, (dI, pI, mI)) =
|
walther@59806
|
313 |
let (* both """"""""""""""""""""""""" either empty or complete *)
|
walther@59806
|
314 |
val thy = Celem.assoc_thy dI
|
walther@59806
|
315 |
val (pI, (pors, pctxt), mI) =
|
walther@59806
|
316 |
if mI = ["no_met"]
|
walther@59806
|
317 |
then
|
walther@59806
|
318 |
let
|
walther@59806
|
319 |
val (pors, pctxt) = Specify.get_pbt pI |> #ppc |> Specify.prep_ori fmz thy;
|
walther@59806
|
320 |
val pI' = Specify.refine_ori' pors pI;
|
walther@59806
|
321 |
in (pI', (pors(*refinement over models with diff.precond only*), pctxt),
|
walther@59806
|
322 |
(hd o #met o Specify.get_pbt) pI')
|
walther@59806
|
323 |
end
|
walther@59806
|
324 |
else (pI, Specify.get_pbt pI |> #ppc |> Specify.prep_ori fmz thy, mI)
|
walther@59806
|
325 |
val {cas, ppc, thy = thy', ...} = Specify.get_pbt pI (*take dI from _refined_ pbl*)
|
walther@59806
|
326 |
val dI = Rule.theory2theory' (Stool.common_subthy (thy, thy'))
|
walther@59806
|
327 |
val hdl = case cas of
|
walther@59806
|
328 |
NONE => Auto_Prog.pblterm dI pI
|
walther@59806
|
329 |
| SOME t => subst_atomic ((vars_of_pbl_' ppc) ~~~ vals_of_oris pors) t
|
walther@59846
|
330 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, pctxt)
|
walther@59819
|
331 |
(fmz, (dI, pI, mI)) (pors, (dI, pI, mI), hdl, pctxt)
|
walther@59806
|
332 |
in
|
walther@59806
|
333 |
((pt, ([], Pbl)), fst3 (by_tactic_input Tactic.Model_Problem (pt, ([], Pbl))))
|
walther@59806
|
334 |
end
|
walther@59763
|
335 |
|
walther@59763
|
336 |
(**)end(**)
|