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@59981
|
9 |
val by_tactic_input: Tactic.input -> Calc.T -> Calc.state_post
|
walther@59981
|
10 |
val by_tactic: Tactic.T -> Calc.T -> string * Calc.state_post
|
walther@59975
|
11 |
|
walther@59975
|
12 |
val hack_until_review_Specify_1: Method.id -> I_Model.T -> I_Model.T
|
walther@59975
|
13 |
val hack_until_review_Specify_2: Method.id -> I_Model.T -> I_Model.T
|
walther@59810
|
14 |
(* ---- keep, probably required later in devel. ----------------------------------------------- *)
|
walther@59946
|
15 |
val nxt_specify_init_calc: Formalise.T -> Calc.T * State_Steps.T
|
walther@59886
|
16 |
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
|
walther@59886
|
17 |
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
|
walther@59747
|
18 |
|
walther@59747
|
19 |
end
|
walther@59747
|
20 |
|
walther@59747
|
21 |
(**)
|
walther@59747
|
22 |
structure Step_Specify(**): STEP_SPECIFY(**) =
|
walther@59747
|
23 |
struct
|
walther@59747
|
24 |
(**)
|
walther@59763
|
25 |
open Pos
|
walther@59763
|
26 |
open Ctree
|
walther@59977
|
27 |
open Specification
|
walther@59747
|
28 |
|
walther@59975
|
29 |
(*
|
walther@59975
|
30 |
hack until review of Specify:
|
walther@59975
|
31 |
introduction of Lucas-Interpretation to Isabelle's functioj package enforced
|
walther@59975
|
32 |
to make additional variables on the right hand side to arguments of programs.
|
walther@59975
|
33 |
These additional arguments are partially handled by these hacks.
|
walther@59975
|
34 |
*)
|
walther@59975
|
35 |
fun hack_until_review_Specify_1 metID itms =
|
walther@59975
|
36 |
if metID = ["Biegelinien", "ausBelastung"]
|
walther@59975
|
37 |
then itms @
|
walther@59975
|
38 |
[(4, [1], true, "#Given", I_Model.Cor ((Const ("Biegelinie.Biegelinie", Type ("fun", [Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]), Type ("Input_Descript.una", [])])),
|
walther@59975
|
39 |
[Free ("y", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]))]),
|
walther@59975
|
40 |
(Free ("id_fun", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])])),
|
walther@59975
|
41 |
[Free ("y", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]))] ))),
|
walther@59975
|
42 |
(5, [1], true, "#Given", I_Model.Cor ((Const ("Biegelinie.AbleitungBiegelinie", Type ("fun", [Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]), Type ("Input_Descript.una", [])])),
|
walther@59975
|
43 |
[Free ("dy", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]))]),
|
walther@59975
|
44 |
(Free ("id_abl", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])])),
|
walther@59975
|
45 |
[Free ("dy", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]))] )))]
|
walther@59975
|
46 |
else itms
|
walther@59975
|
47 |
|
walther@59975
|
48 |
fun hack_until_review_Specify_2 metID itms =
|
walther@59975
|
49 |
if metID = ["IntegrierenUndKonstanteBestimmen2"]
|
walther@59975
|
50 |
then itms @
|
walther@59975
|
51 |
[(4, [1], true, "#Given", I_Model.Cor ((Const ("Biegelinie.Biegelinie", Type ("fun", [Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]), Type ("Input_Descript.una", [])])),
|
walther@59975
|
52 |
[Free ("y", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]))]),
|
walther@59975
|
53 |
(Free ("id_fun", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])])),
|
walther@59975
|
54 |
[Free ("y", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]))] ))),
|
walther@59975
|
55 |
(5, [1], true, "#Given", I_Model.Cor ((Const ("Biegelinie.AbleitungBiegelinie", Type ("fun", [Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]), Type ("Input_Descript.una", [])])),
|
walther@59975
|
56 |
[Free ("dy", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]))]),
|
walther@59975
|
57 |
(Free ("id_abl", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])])),
|
walther@59975
|
58 |
[Free ("dy", Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]))] )))]
|
walther@59975
|
59 |
else itms
|
walther@59975
|
60 |
|
walther@59975
|
61 |
|
walther@59806
|
62 |
fun by_tactic_input (tac as Tactic.Model_Problem) (pt, pos as (p, _)) =
|
walther@59763
|
63 |
let
|
walther@59763
|
64 |
val (oris, ospec, probl, spec, ctxt) = case get_obj I pt p of
|
walther@59763
|
65 |
PblObj {origin = (oris, ospec, _), probl, spec, ctxt, ...} => (oris, ospec, probl, spec, ctxt)
|
walther@59962
|
66 |
| _ => raise ERROR "by_tactic_input Model_Problem; uncovered case get_obj"
|
walther@59983
|
67 |
val (dI, pI, mI) = References.select ospec spec
|
walther@59881
|
68 |
val thy = ThyC.get_theory dI
|
walther@59970
|
69 |
val mpc = (#ppc o Method.from_store) mI (* just for reuse complete_mod_ *)
|
walther@59970
|
70 |
val {cas, ppc, ...} = Problem.from_store pI
|
walther@59958
|
71 |
val pbl = I_Model.init ppc (* fill in descriptions *)
|
walther@59763
|
72 |
(*----------------if you think, this should be done by the Dialog
|
walther@59763
|
73 |
in the java front-end, search there for WN060225-modelProblem----*)
|
walther@59763
|
74 |
val (pbl, met) = case cas of
|
walther@59763
|
75 |
NONE => (pbl, [])
|
walther@59763
|
76 |
| _ => complete_mod_ (oris, mpc, ppc, probl)
|
walther@59763
|
77 |
(*----------------------------------------------------------------*)
|
walther@59763
|
78 |
val tac_ = Tactic.Model_Problem' (pI, pbl, met)
|
walther@59933
|
79 |
val (pos,c,_,pt) = Specify_Step.add tac_ (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59846
|
80 |
in ([(tac, tac_, (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos)) end
|
walther@59806
|
81 |
| by_tactic_input (Tactic.Add_Given ct) ptp = nxt_specif_additem "#Given" ct ptp
|
walther@59806
|
82 |
| by_tactic_input (Tactic.Add_Find ct) ptp = nxt_specif_additem "#Find" ct ptp
|
walther@59806
|
83 |
| by_tactic_input (Tactic.Add_Relation ct) ptp = nxt_specif_additem"#Relate" ct ptp
|
walther@59763
|
84 |
(*. called only if no_met is specified .*)
|
walther@59810
|
85 |
| by_tactic_input (Tactic.Refine_Tacitly pI) (ptp as (pt, pos as (p, _))) =
|
walther@59763
|
86 |
let
|
walther@59763
|
87 |
val (oris, dI, ctxt) = case get_obj I pt p of
|
walther@59763
|
88 |
(PblObj {origin = (oris, (dI, _, _), _), ctxt, ...}) => (oris, dI, ctxt)
|
walther@59962
|
89 |
| _ => raise ERROR "by_tactic_input Refine_Tacitly: uncovered case get_obj"
|
walther@59968
|
90 |
val opt = Refine.refine_ori oris pI
|
walther@59763
|
91 |
in
|
walther@59763
|
92 |
case opt of
|
walther@59763
|
93 |
SOME pI' =>
|
walther@59763
|
94 |
let
|
walther@59970
|
95 |
val {met, ...} = Problem.from_store pI'
|
walther@59763
|
96 |
(*val pt = update_pbl pt p pbl ..done by Model_Problem*)
|
walther@59903
|
97 |
val mI = if length met = 0 then Method.id_empty else hd met
|
walther@59881
|
98 |
val thy = ThyC.get_theory dI
|
walther@59763
|
99 |
val (pos, c, _, pt) =
|
walther@59933
|
100 |
Specify_Step.add (Tactic.Refine_Tacitly' (pI, pI', dI, mI,(*pbl*)[])) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
101 |
in
|
walther@59763
|
102 |
([(Tactic.Refine_Tacitly pI, Tactic.Refine_Tacitly' (pI,pI',dI,mI,(*pbl*)[]),
|
walther@59846
|
103 |
(pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos))
|
walther@59763
|
104 |
end
|
walther@59763
|
105 |
| NONE => ([], [], ptp)
|
walther@59763
|
106 |
end
|
walther@59806
|
107 |
| by_tactic_input (Tactic.Refine_Problem pI) (ptp as (pt, pos as (p,_))) =
|
walther@59763
|
108 |
let
|
walther@59763
|
109 |
val (dI, dI', probl, ctxt) = case get_obj I pt p of
|
walther@59763
|
110 |
PblObj {origin= (_, (dI, _, _), _), spec = (dI', _, _), probl, ctxt, ...} =>
|
walther@59763
|
111 |
(dI, dI', probl, ctxt)
|
walther@59962
|
112 |
| _ => raise ERROR "by_tactic_input Refine_Problem: uncovered case get_obj"
|
walther@59879
|
113 |
val thy = if dI' = ThyC.id_empty then dI else dI'
|
walther@59763
|
114 |
in
|
walther@59960
|
115 |
case Refine.problem (ThyC.get_theory thy) pI probl of
|
walther@59763
|
116 |
NONE => ([], [], ptp)
|
walther@59763
|
117 |
| SOME rfd =>
|
walther@59763
|
118 |
let
|
walther@59933
|
119 |
val (pos,c,_,pt) = Specify_Step.add (Tactic.Refine_Problem' rfd) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
120 |
in
|
walther@59846
|
121 |
([(Tactic.Refine_Problem pI, Tactic.Refine_Problem' rfd, (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos))
|
walther@59763
|
122 |
end
|
walther@59763
|
123 |
end
|
walther@59806
|
124 |
| by_tactic_input (Tactic.Specify_Problem pI) (pt, pos as (p,_)) =
|
walther@59763
|
125 |
let
|
walther@59763
|
126 |
val (oris, dI, dI', pI', probl, ctxt) = case get_obj I pt p of
|
walther@59763
|
127 |
PblObj {origin = (oris, (dI,_,_),_), spec = (dI',pI',_), probl, ctxt, ...} =>
|
walther@59763
|
128 |
(oris, dI, dI', pI', probl, ctxt)
|
walther@59962
|
129 |
| _ => raise ERROR ""
|
walther@59881
|
130 |
val thy = ThyC.get_theory (if dI' = ThyC.id_empty then dI else dI');
|
walther@59970
|
131 |
val {ppc,where_,prls,...} = Problem.from_store pI
|
walther@59763
|
132 |
val pbl =
|
walther@59903
|
133 |
if pI' = Problem.id_empty andalso pI = Problem.id_empty
|
walther@59958
|
134 |
then (false, (I_Model.init ppc, []))
|
walther@59984
|
135 |
else M_Match.match_itms_oris thy probl (ppc,where_,prls) oris
|
walther@59763
|
136 |
(*FIXXXME~~~~~~~~~~~~~~~: take pbl and compare with new pI WN.8.03*)
|
walther@59810
|
137 |
val (c, pt) =
|
walther@59933
|
138 |
case Specify_Step.add (Tactic.Specify_Problem' (pI, pbl)) (Istate_Def.Uistate, ctxt) (pt, pos) of
|
walther@59810
|
139 |
((_, Pbl), c, _, pt) => (c, pt)
|
walther@59962
|
140 |
| _ => raise ERROR ""
|
walther@59763
|
141 |
in
|
walther@59846
|
142 |
([(Tactic.Specify_Problem pI, Tactic.Specify_Problem' (pI, pbl), (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt, pos))
|
walther@59763
|
143 |
end
|
walther@59763
|
144 |
(* transfers oris (not required in pbl) to met-model for script-env
|
walther@59763
|
145 |
FIXME.WN.8.03: application of several mIDs to SAME model? *)
|
walther@59806
|
146 |
| by_tactic_input (Tactic.Specify_Method mID) (pt, pos as (p,_)) =
|
walther@59763
|
147 |
let
|
walther@59763
|
148 |
val (oris, pbl, dI, met, ctxt) = case get_obj I pt p of
|
walther@59763
|
149 |
PblObj {origin = (oris, _, _), probl = pbl, spec = (dI, _, _), meth=met, ctxt, ...}
|
walther@59763
|
150 |
=> (oris, pbl, dI, met, ctxt)
|
walther@59962
|
151 |
| _ => raise ERROR "by_tactic_input Specify_Method: uncovered case get_obj"
|
walther@59970
|
152 |
val {ppc,pre,prls,...} = Method.from_store mID
|
walther@59881
|
153 |
val thy = ThyC.get_theory dI
|
walther@59960
|
154 |
val oris = O_Model.add thy ppc oris
|
walther@59763
|
155 |
val met = if met=[] then pbl else met (* WN0602 what if more itms in met? *)
|
walther@59984
|
156 |
val (_, (itms, _)) = M_Match.match_itms_oris thy met (ppc,pre,prls ) oris
|
walther@59975
|
157 |
val itms = hack_until_review_Specify_2 mID itms
|
walther@59763
|
158 |
val (pos, c, _, pt) =
|
walther@59933
|
159 |
Specify_Step.add (Tactic.Specify_Method' (mID, oris, itms)) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
160 |
in
|
walther@59846
|
161 |
([(Tactic.Specify_Method mID, Tactic.Specify_Method' (mID, oris, itms), (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt, pos))
|
walther@59763
|
162 |
end
|
walther@59806
|
163 |
| by_tactic_input (Tactic.Specify_Theory dI) (pt, pos as (_, Pbl)) =
|
walther@59763
|
164 |
let
|
walther@59763
|
165 |
val ctxt = get_ctxt pt pos
|
walther@59763
|
166 |
val (pos, c, _, pt) =
|
walther@59933
|
167 |
Specify_Step.add (Tactic.Specify_Theory' dI) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
168 |
in (*FIXXXME: check if pbl can still be parsed*)
|
walther@59763
|
169 |
([(Tactic.Specify_Theory dI, Tactic.Specify_Theory' dI, (pos, (Istate_Def.Uistate, ctxt)))], c,
|
walther@59763
|
170 |
(pt, pos))
|
walther@59763
|
171 |
end
|
walther@59806
|
172 |
| by_tactic_input (Tactic.Specify_Theory dI) (pt, pos as (_, Met)) =
|
walther@59763
|
173 |
let
|
walther@59763
|
174 |
val ctxt = get_ctxt pt pos
|
walther@59933
|
175 |
val (pos, c, _, pt) = Specify_Step.add (Tactic.Specify_Theory' dI) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59763
|
176 |
in (*FIXXXME: check if met can still be parsed*)
|
walther@59763
|
177 |
([(Tactic.Specify_Theory dI, Tactic.Specify_Theory' dI, (pos, (Istate_Def.Uistate, ctxt)))], c, (pt, pos))
|
walther@59763
|
178 |
end
|
walther@59962
|
179 |
| by_tactic_input m' _ = raise ERROR ("by_tactic_input: not impl. for " ^ Tactic.input_to_string m')
|
walther@59806
|
180 |
(* was fun Math_Engine.nxt_specify_ *)
|
walther@59806
|
181 |
|
walther@59806
|
182 |
|
walther@59977
|
183 |
(* was fun Specification.specify *)
|
walther@59926
|
184 |
fun by_tactic (Tactic.Model_Problem' (_, pbl, met)) (pt, pos as (p, _)) =
|
walther@59806
|
185 |
let
|
walther@59806
|
186 |
val (oris, dI',pI',mI', dI, ctxt) = case get_obj I pt p of
|
walther@59806
|
187 |
PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, _, _), ctxt, ...} =>
|
walther@59806
|
188 |
(oris, dI',pI',mI', dI, ctxt)
|
walther@59962
|
189 |
| _ => raise ERROR "Step_Solve.by_tactic (Model_Problem': uncovered case get_obj"
|
walther@59879
|
190 |
val thy' = if dI = ThyC.id_empty then dI' else dI
|
walther@59881
|
191 |
val thy = ThyC.get_theory thy'
|
walther@59970
|
192 |
val {ppc, prls, where_, ...} = Problem.from_store pI'
|
walther@59965
|
193 |
val pre = Pre_Conds.check' thy prls where_ pbl
|
walther@59806
|
194 |
val pb = foldl and_ (true, map fst pre)
|
walther@59806
|
195 |
val ((p, _), _, _, pt) =
|
walther@59933
|
196 |
Specify_Step.add (Tactic.Model_Problem'([],pbl,met)) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59977
|
197 |
val (_, _) = Specification.nxt_spec Pbl pb oris (dI', pI', mI') (pbl, met)
|
walther@59970
|
198 |
(ppc,(#ppc o Method.from_store) mI') (dI',pI',mI');
|
walther@59806
|
199 |
in
|
walther@59806
|
200 |
("ok", ([], [], (pt, (p, Pbl))))
|
walther@59806
|
201 |
end
|
walther@59806
|
202 |
(* called only if no_met is specified *)
|
walther@59806
|
203 |
| by_tactic (Tactic.Refine_Tacitly' (pI, pIre, _, _, _)) (pt, pos) =
|
walther@59806
|
204 |
let
|
walther@59806
|
205 |
(* val (dI', ctxt) = case get_obj I pt p of
|
walther@59806
|
206 |
PblObj {origin= (_, (dI', _, _), _), ctxt, ...} => (dI', ctxt)
|
walther@59962
|
207 |
| _ => raise ERROR "Step_Solve.by_tactic (Refine_Tacitly': uncovered case get_obj"*)
|
walther@59970
|
208 |
val {met, thy,...} = Problem.from_store pIre
|
walther@59903
|
209 |
val (domID, metID) = (Context.theory_name thy, if length met = 0 then Method.id_empty else hd met)
|
walther@59806
|
210 |
val ((p,_), _, _, pt) =
|
walther@59933
|
211 |
Specify_Step.add (Tactic.Refine_Tacitly' (pI, pIre, domID, metID, [(*pbl*)]))
|
walther@59846
|
212 |
(Istate_Def.Uistate, ContextC.empty) (pt, pos)
|
walther@59806
|
213 |
(* deprecated^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *)
|
walther@59806
|
214 |
(* val (pbl, pre, _) = ([], [], false)*)
|
walther@59806
|
215 |
in
|
walther@59806
|
216 |
("ok", ([], [], (pt,(p, Pbl))))
|
walther@59806
|
217 |
end
|
walther@59806
|
218 |
| by_tactic (Tactic.Refine_Problem' rfd) (pt, pos) =
|
walther@59806
|
219 |
let
|
walther@59806
|
220 |
val ctxt = get_ctxt pt pos
|
walther@59806
|
221 |
val (pos, _, _, pt) =
|
walther@59933
|
222 |
Specify_Step.add (Tactic.Refine_Problem' rfd) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59806
|
223 |
in
|
walther@59806
|
224 |
("ok", ([], [], (pt,pos)))
|
walther@59806
|
225 |
end
|
walther@59806
|
226 |
(*WN110515 initialise ctxt again from itms and add preconds*)
|
walther@59810
|
227 |
| by_tactic (Tactic.Specify_Problem' (pI, (ok, (itms, pre)))) (pt, pos as (p, _)) =
|
walther@59806
|
228 |
let
|
walther@59810
|
229 |
val (_, _, _, _, dI, _, ctxt, _) = case get_obj I pt p of
|
walther@59806
|
230 |
PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, _, mI), ctxt, meth = met, ...} =>
|
walther@59806
|
231 |
(oris, dI', pI', mI', dI, mI, ctxt, met)
|
walther@59962
|
232 |
| _ => raise ERROR "Step_Solve.by_tactic (Specify_Problem': uncovered case get_obj"
|
walther@59881
|
233 |
val thy = ThyC.get_theory dI
|
walther@59806
|
234 |
val (p, pt) =
|
walther@59933
|
235 |
case Specify_Step.add (Tactic.Specify_Problem' (pI, (ok, (itms, pre)))) (Istate_Def.Uistate, ctxt) (pt, pos) of
|
walther@59806
|
236 |
((p, Pbl), _, _, pt) => (p, pt)
|
walther@59962
|
237 |
| _ => raise ERROR "Step_Solve.by_tactic (Specify_Problem': uncovered case generate1 (WARNING WHY ?)"
|
walther@59806
|
238 |
in
|
walther@59806
|
239 |
("ok", ([], [], (pt, (p, Pbl))))
|
walther@59806
|
240 |
end
|
walther@59806
|
241 |
(*WN110515 initialise ctxt again from itms and add preconds*)
|
walther@59806
|
242 |
| by_tactic (Tactic.Specify_Method' (mID, _, _)) (pt,pos as (p, _)) =
|
walther@59806
|
243 |
let
|
walther@59810
|
244 |
val (oris, _, _, mI', dI, _, pbl, met, ctxt) = case get_obj I pt p of
|
walther@59806
|
245 |
PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, pI, _), probl = pbl, meth = met, ctxt, ...} =>
|
walther@59806
|
246 |
(oris, dI', pI', mI', dI, pI, pbl, met, ctxt)
|
walther@59962
|
247 |
| _ => raise ERROR "Step_Solve.by_tactic (Specify_Problem': uncovered case get_obj"
|
walther@59970
|
248 |
val {ppc, pre, prls,...} = Method.from_store mID
|
walther@59881
|
249 |
val thy = ThyC.get_theory dI
|
walther@59960
|
250 |
val oris = O_Model.add thy ppc oris
|
walther@59806
|
251 |
val met = if met = [] then pbl else met
|
walther@59984
|
252 |
val (_, (itms, _)) = M_Match.match_itms_oris thy met (ppc, pre, prls) oris
|
walther@59975
|
253 |
val itms = hack_until_review_Specify_1 mI' itms
|
walther@59806
|
254 |
val (pos, _, _, pt) =
|
walther@59933
|
255 |
Specify_Step.add (Tactic.Specify_Method' (mID, oris, itms)) (Istate_Def.Uistate, ctxt) (pt, pos)
|
walther@59806
|
256 |
in
|
walther@59806
|
257 |
("ok", ([], [], (pt, pos)))
|
walther@59806
|
258 |
end
|
walther@59977
|
259 |
| by_tactic (Tactic.Add_Given' (ct, _)) (pt, p) = Specification.specify_additem "#Given" ct (pt, p)
|
walther@59977
|
260 |
| by_tactic (Tactic.Add_Find' (ct, _)) (pt, p) = Specification.specify_additem "#Find" ct (pt, p)
|
walther@59977
|
261 |
| by_tactic (Tactic.Add_Relation' (ct, _)) (pt, p) = Specification.specify_additem"#Relate" ct (pt, p)
|
walther@59810
|
262 |
| by_tactic (Tactic.Specify_Theory' domID) (pt, (p,p_)) =
|
walther@59806
|
263 |
let
|
walther@59806
|
264 |
val p_ = case p_ of Met => Met | _ => Pbl
|
walther@59881
|
265 |
val thy = ThyC.get_theory domID
|
walther@59806
|
266 |
val (oris, dI', pI', mI', dI, pI, mI, pbl, met, ctxt) = case get_obj I pt p of
|
walther@59806
|
267 |
PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, pI, mI), probl = pbl, meth = met, ctxt, ...} =>
|
walther@59806
|
268 |
(oris, dI', pI', mI', dI, pI, mI, pbl, met, ctxt)
|
walther@59962
|
269 |
| _ => raise ERROR "Step_Solve.by_tactic (Specify_Theory': uncovered case get_obj"
|
walther@59810
|
270 |
val _ = case p_ of Met => met | _ => pbl
|
walther@59903
|
271 |
val cpI = if pI = Problem.id_empty then pI' else pI
|
walther@59970
|
272 |
val {prls = per, ppc, where_ = pwh, ...} = Problem.from_store cpI
|
walther@59903
|
273 |
val cmI = if mI = Method.id_empty then mI' else mI
|
walther@59970
|
274 |
val {prls = mer, ppc = mpc, pre= mwh, ...} = Method.from_store cmI
|
walther@59806
|
275 |
val pre = case p_ of
|
walther@59965
|
276 |
Met => (Pre_Conds.check' thy mer mwh met)
|
walther@59965
|
277 |
| _ => (Pre_Conds.check' thy per pwh pbl)
|
walther@59806
|
278 |
val pb = foldl and_ (true, map fst pre)
|
walther@59806
|
279 |
in
|
walther@59806
|
280 |
if domID = dI
|
walther@59806
|
281 |
then
|
walther@59810
|
282 |
let val (p_, _) = nxt_spec p_ pb oris (dI', pI', mI') (pbl, met) (ppc, mpc) (dI, pI, mI)
|
walther@59806
|
283 |
in
|
walther@59806
|
284 |
("ok", ([], [], (pt, (p, p_))))
|
walther@59806
|
285 |
end
|
walther@59806
|
286 |
else (*FIXME: check ppc wrt. (new!) domID ..? still parsable?*)
|
walther@59806
|
287 |
let
|
walther@59933
|
288 |
val ((p, p_), _, _, pt) = Specify_Step.add (Tactic.Specify_Theory' domID) (Istate_Def.Uistate, ctxt) (pt, (p,p_))
|
walther@59810
|
289 |
val (p_, _) = nxt_spec p_ pb oris (dI', pI', mI') (pbl, met) (ppc, mpc) (domID, pI, mI)
|
walther@59806
|
290 |
in
|
walther@59806
|
291 |
("ok", ([], [], (pt, (p, p_))))
|
walther@59806
|
292 |
end
|
walther@59806
|
293 |
end
|
walther@59806
|
294 |
| by_tactic _ _ = raise ERROR "Step_Specify.by_tactic uncovered pattern in fun.def"
|
walther@59977
|
295 |
(* was fun Specification.specify *)
|
walther@59806
|
296 |
|
walther@59806
|
297 |
(* create a calc-tree with oris via an cas.refined pbl *)
|
walther@59806
|
298 |
fun nxt_specify_init_calc ([], (dI, pI, mI)) =
|
walther@59806
|
299 |
if pI <> []
|
walther@59806
|
300 |
then (* from pbl-browser or from CAS cmd with pI=[e_pblID] *)
|
walther@59806
|
301 |
let
|
walther@59970
|
302 |
val {cas, met, ppc, thy, ...} = Problem.from_store pI
|
walther@59880
|
303 |
val dI = if dI = "" then Context.theory_name thy else dI
|
walther@59806
|
304 |
val mI = if mI = [] then hd met else mI
|
walther@59806
|
305 |
val hdl = case cas of NONE => Auto_Prog.pblterm dI pI | SOME t => t
|
walther@59952
|
306 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.Uistate, ContextC.empty) ([], (dI, pI, mI))
|
walther@59846
|
307 |
([], (dI,pI,mI), hdl, ContextC.empty)
|
walther@59806
|
308 |
val pt = update_spec pt [] (dI, pI, mI)
|
walther@59958
|
309 |
val pits = I_Model.init ppc
|
walther@59806
|
310 |
val pt = update_pbl pt [] pits
|
walther@59806
|
311 |
in ((pt, ([] , Pbl)), []) end
|
walther@59806
|
312 |
else
|
walther@59806
|
313 |
if mI <> []
|
walther@59806
|
314 |
then (* from met-browser *)
|
walther@59806
|
315 |
let
|
walther@59970
|
316 |
val {ppc, ...} = Method.from_store mI
|
walther@59806
|
317 |
val dI = if dI = "" then "Isac_Knowledge" else dI
|
walther@59846
|
318 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty)
|
walther@59861
|
319 |
([], (dI, pI, mI)) ([], (dI, pI, mI), TermC.empty, ContextC.empty)
|
walther@59806
|
320 |
val pt = update_spec pt [] (dI, pI, mI)
|
walther@59958
|
321 |
val mits = I_Model.init ppc
|
walther@59806
|
322 |
val pt = update_met pt [] mits
|
walther@59806
|
323 |
in ((pt, ([], Met)), []) end
|
walther@59806
|
324 |
else (* new example, pepare for interactive modeling *)
|
walther@59806
|
325 |
let
|
walther@59846
|
326 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty)
|
walther@59976
|
327 |
([], References.empty) ([], References.empty, TermC.empty, ContextC.empty)
|
walther@59806
|
328 |
in ((pt, ([], Pbl)), []) end
|
walther@59806
|
329 |
| nxt_specify_init_calc (fmz, (dI, pI, mI)) =
|
walther@59806
|
330 |
let (* both """"""""""""""""""""""""" either empty or complete *)
|
walther@59881
|
331 |
val thy = ThyC.get_theory dI
|
walther@59806
|
332 |
val (pI, (pors, pctxt), mI) =
|
walther@59806
|
333 |
if mI = ["no_met"]
|
walther@59806
|
334 |
then
|
walther@59806
|
335 |
let
|
walther@59970
|
336 |
val (pors(*, pctxt*)) = Problem.from_store pI |> #ppc |> O_Model.init fmz thy;
|
walther@59952
|
337 |
val pctxt = ContextC.initialise' thy fmz;
|
walther@59968
|
338 |
val pI' = Refine.refine_ori' pors pI;
|
walther@59806
|
339 |
in (pI', (pors(*refinement over models with diff.precond only*), pctxt),
|
walther@59970
|
340 |
(hd o #met o Problem.from_store) pI')
|
walther@59806
|
341 |
end
|
walther@59952
|
342 |
else
|
walther@59952
|
343 |
let
|
walther@59970
|
344 |
val pors = Problem.from_store pI |> #ppc |> O_Model.init fmz thy;
|
walther@59952
|
345 |
val pctxt = ContextC.initialise' thy fmz;
|
walther@59952
|
346 |
in (pI, (pors, pctxt), mI) end;
|
walther@59970
|
347 |
val {cas, ppc, thy = thy', ...} = Problem.from_store pI (*take dI from _refined_ pbl*)
|
walther@59965
|
348 |
val dI = Context.theory_name (ThyC.sub_common (thy, thy'))
|
walther@59806
|
349 |
val hdl = case cas of
|
walther@59806
|
350 |
NONE => Auto_Prog.pblterm dI pI
|
walther@59987
|
351 |
| SOME t => subst_atomic ((Model_Pattern.variables ppc) ~~~ O_Model.values pors) t
|
walther@59846
|
352 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, pctxt)
|
walther@59819
|
353 |
(fmz, (dI, pI, mI)) (pors, (dI, pI, mI), hdl, pctxt)
|
walther@59806
|
354 |
in
|
walther@59806
|
355 |
((pt, ([], Pbl)), fst3 (by_tactic_input Tactic.Model_Problem (pt, ([], Pbl))))
|
walther@59806
|
356 |
end
|
walther@59763
|
357 |
|
walther@59763
|
358 |
(**)end(**)
|