1 (* Title: Specify/step-specify.sml
2 Author: Walther Neuper 2019
3 (c) due to copyright terms
6 signature STEP_SPECIFY =
8 val by_tactic: Tactic.input -> Calc.T -> Chead.calcstate'
9 (*val do_next: Step.specify_do_next requires Lucin.by_tactic, which is not yet known in Step_Specify*)
14 structure Step_Specify(**): STEP_SPECIFY(**) =
21 (* was fun Math_Engine.nxt_specify_ *)
22 fun by_tactic (tac as Tactic.Model_Problem) (pt, pos as (p, _)) =
24 val (oris, ospec, probl, spec, ctxt) = case get_obj I pt p of
25 PblObj {origin = (oris, ospec, _), probl, spec, ctxt, ...} => (oris, ospec, probl, spec, ctxt)
26 | _ => error "by_tactic Model_Problem; uncovered case get_obj"
27 val (dI, pI, mI) = some_spec ospec spec
28 val thy = Celem.assoc_thy dI
29 val mpc = (#ppc o Specify.get_met) mI (* just for reuse complete_mod_ *)
30 val {cas, ppc, ...} = Specify.get_pbt pI
31 val pbl = Generate.init_pbl ppc (* fill in descriptions *)
32 (*----------------if you think, this should be done by the Dialog
33 in the java front-end, search there for WN060225-modelProblem----*)
34 val (pbl, met) = case cas of
36 | _ => complete_mod_ (oris, mpc, ppc, probl)
37 (*----------------------------------------------------------------*)
38 val tac_ = Tactic.Model_Problem' (pI, pbl, met)
39 val (pos,c,_,pt) = Generate.generate1 thy tac_ (Istate_Def.Uistate, ctxt) pos pt
40 in ([(tac, tac_, (pos, (Istate_Def.Uistate, ContextC.e_ctxt)))], c, (pt,pos)) end
41 | by_tactic (Tactic.Add_Given ct) ptp = nxt_specif_additem "#Given" ct ptp
42 | by_tactic (Tactic.Add_Find ct) ptp = nxt_specif_additem "#Find" ct ptp
43 | by_tactic (Tactic.Add_Relation ct) ptp = nxt_specif_additem"#Relate" ct ptp
44 (*. called only if no_met is specified .*)
45 | by_tactic (Tactic.Refine_Tacitly pI) (ptp as (pt, pos as (p,_))) =
47 val (oris, dI, ctxt) = case get_obj I pt p of
48 (PblObj {origin = (oris, (dI, _, _), _), ctxt, ...}) => (oris, dI, ctxt)
49 | _ => error "by_tactic Refine_Tacitly: uncovered case get_obj"
50 val opt = Specify.refine_ori oris pI
55 val {met, ...} = Specify.get_pbt pI'
56 (*val pt = update_pbl pt p pbl ..done by Model_Problem*)
57 val mI = if length met = 0 then Celem.e_metID else hd met
58 val thy = Celem.assoc_thy dI
60 Generate.generate1 thy (Tactic.Refine_Tacitly' (pI, pI', dI, mI,(*pbl*)[])) (Istate_Def.Uistate, ctxt) pos pt
62 ([(Tactic.Refine_Tacitly pI, Tactic.Refine_Tacitly' (pI,pI',dI,mI,(*pbl*)[]),
63 (pos, (Istate_Def.Uistate, ContextC.e_ctxt)))], c, (pt,pos))
65 | NONE => ([], [], ptp)
67 | by_tactic (Tactic.Refine_Problem pI) (ptp as (pt, pos as (p,_))) =
69 val (dI, dI', probl, ctxt) = case get_obj I pt p of
70 PblObj {origin= (_, (dI, _, _), _), spec = (dI', _, _), probl, ctxt, ...} =>
71 (dI, dI', probl, ctxt)
72 | _ => error "by_tactic Refine_Problem: uncovered case get_obj"
73 val thy = if dI' = Rule.e_domID then dI else dI'
75 case Specify.refine_pbl (Celem.assoc_thy thy) pI probl of
79 val (pos,c,_,pt) = Generate.generate1 (Celem.assoc_thy thy) (Tactic.Refine_Problem' rfd) (Istate_Def.Uistate, ctxt) pos pt
81 ([(Tactic.Refine_Problem pI, Tactic.Refine_Problem' rfd, (pos, (Istate_Def.Uistate, ContextC.e_ctxt)))], c, (pt,pos))
84 | by_tactic (Tactic.Specify_Problem pI) (pt, pos as (p,_)) =
86 val (oris, dI, dI', pI', probl, ctxt) = case get_obj I pt p of
87 PblObj {origin = (oris, (dI,_,_),_), spec = (dI',pI',_), probl, ctxt, ...} =>
88 (oris, dI, dI', pI', probl, ctxt)
90 val thy = Celem.assoc_thy (if dI' = Rule.e_domID then dI else dI');
91 val {ppc,where_,prls,...} = Specify.get_pbt pI
93 if pI' = Celem.e_pblID andalso pI = Celem.e_pblID
94 then (false, (Generate.init_pbl ppc, []))
95 else Specify.match_itms_oris thy probl (ppc,where_,prls) oris
96 (*FIXXXME~~~~~~~~~~~~~~~: take pbl and compare with new pI WN.8.03*)
97 val (c, pt) = case Generate.generate1 thy (Tactic.Specify_Problem' (pI, pbl)) (Istate_Def.Uistate, ctxt) pos pt of
98 ((_, Pbl), c, _, pt) => (c, pt)
101 ([(Tactic.Specify_Problem pI, Tactic.Specify_Problem' (pI, pbl), (pos, (Istate_Def.Uistate, ContextC.e_ctxt)))], c, (pt,pos))
103 (* transfers oris (not required in pbl) to met-model for script-env
104 FIXME.WN.8.03: application of several mIDs to SAME model? *)
105 | by_tactic (Tactic.Specify_Method mID) (pt, pos as (p,_)) =
107 val (oris, pbl, dI, met, ctxt) = case get_obj I pt p of
108 PblObj {origin = (oris, _, _), probl = pbl, spec = (dI, _, _), meth=met, ctxt, ...}
109 => (oris, pbl, dI, met, ctxt)
110 | _ => error "by_tactic Specify_Method: uncovered case get_obj"
111 val {ppc,pre,prls,...} = Specify.get_met mID
112 val thy = Celem.assoc_thy dI
113 val oris = Specify.add_field' thy ppc oris
114 val met = if met=[] then pbl else met (* WN0602 what if more itms in met? *)
115 val (_, (itms, _)) = Specify.match_itms_oris thy met (ppc,pre,prls ) oris
116 val itms = Specify.hack_until_review_Specify_2 mID itms
117 val (pos, c, _, pt) =
118 Generate.generate1 thy (Tactic.Specify_Method' (mID, oris, itms)) (Istate_Def.Uistate, ctxt) pos pt
120 ([(Tactic.Specify_Method mID, Tactic.Specify_Method' (mID, oris, itms), (pos, (Istate_Def.Uistate, ContextC.e_ctxt)))], c, (pt, pos))
122 | by_tactic (Tactic.Specify_Theory dI) (pt, pos as (_, Pbl)) =
124 val ctxt = get_ctxt pt pos
125 val (pos, c, _, pt) =
126 Generate.generate1 (Celem.assoc_thy "Isac_Knowledge") (Tactic.Specify_Theory' dI) (Istate_Def.Uistate, ctxt) pos pt
127 in (*FIXXXME: check if pbl can still be parsed*)
128 ([(Tactic.Specify_Theory dI, Tactic.Specify_Theory' dI, (pos, (Istate_Def.Uistate, ctxt)))], c,
131 | by_tactic (Tactic.Specify_Theory dI) (pt, pos as (_, Met)) =
133 val ctxt = get_ctxt pt pos
134 val (pos, c, _, pt) = Generate.generate1 (Celem.assoc_thy "Isac_Knowledge") (Tactic.Specify_Theory' dI) (Istate_Def.Uistate, ctxt) pos pt
135 in (*FIXXXME: check if met can still be parsed*)
136 ([(Tactic.Specify_Theory dI, Tactic.Specify_Theory' dI, (pos, (Istate_Def.Uistate, ctxt)))], c, (pt, pos))
138 | by_tactic m' _ = error ("by_tactic: not impl. for " ^ Tactic.tac2str m')