walther@59763
|
1 |
signature SPECIFY_NEW =
|
walther@59763
|
2 |
sig
|
walther@59775
|
3 |
val find_next_step: Calc.T -> string * (Pos.pos_ * Tactic.input)
|
walther@59764
|
4 |
val nxt_specify_init_calc : Selem.fmz -> Chead.calcstate
|
walther@59806
|
5 |
(* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
|
walther@59806
|
6 |
(*NONE*)
|
walther@59806
|
7 |
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
|
walther@59806
|
8 |
(*NONE*)
|
walther@59806
|
9 |
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
|
walther@59763
|
10 |
end
|
walther@59763
|
11 |
|
walther@59763
|
12 |
(**)
|
walther@59763
|
13 |
structure SpecifyNEW(**): SPECIFY_NEW(**) =
|
walther@59763
|
14 |
struct
|
walther@59763
|
15 |
(**)
|
walther@59763
|
16 |
open Pos
|
walther@59764
|
17 |
open Ctree
|
walther@59763
|
18 |
open Chead
|
walther@59763
|
19 |
|
walther@59763
|
20 |
(* was Chead.nxt_spec *)
|
walther@59772
|
21 |
fun find_next_step (pt, (p, p_)) =
|
walther@59763
|
22 |
let
|
walther@59763
|
23 |
val (pblobj, met, origin, oris, dI', pI', mI', pbl, dI, pI, mI) =
|
walther@59763
|
24 |
case Ctree.get_obj I pt p of
|
walther@59763
|
25 |
pblobj as (Ctree.PblObj {meth, origin = origin as (oris, (dI', pI', mI'), _),
|
walther@59763
|
26 |
probl, spec = (dI, pI, mI), ...}) => (pblobj, meth, origin, oris, dI', pI', mI', probl, dI, pI, mI)
|
walther@59763
|
27 |
| Ctree.PrfObj _ => error "nxt_specify_: not on PrfObj"
|
walther@59763
|
28 |
in
|
walther@59763
|
29 |
if Ctree.just_created_ pblobj (*by Subproblem*) andalso origin <> Ctree.e_origin
|
walther@59763
|
30 |
then
|
walther@59763
|
31 |
case mI' of
|
walther@59763
|
32 |
["no_met"] => ("ok", (Pbl, Tactic.Refine_Tacitly pI'))
|
walther@59763
|
33 |
| _ => ("ok", (Pbl, Tactic.Model_Problem))
|
walther@59763
|
34 |
else
|
walther@59763
|
35 |
let
|
walther@59763
|
36 |
val cpI = if pI = Celem.e_pblID then pI' else pI;
|
walther@59763
|
37 |
val cmI = if mI = Celem.e_metID then mI' else mI;
|
walther@59763
|
38 |
val {ppc = pbt, prls, where_, ...} = Specify.get_pbt cpI;
|
walther@59763
|
39 |
val pre = Stool.check_preconds "thy 100820" prls where_ pbl;
|
walther@59763
|
40 |
val preok = foldl and_ (true, map fst pre);
|
walther@59763
|
41 |
(*FIXME.WN0308: ~~~~~: just check true in itms of pbl/met?*)
|
walther@59763
|
42 |
val mpc = (#ppc o Specify.get_met) cmI
|
walther@59763
|
43 |
in
|
walther@59763
|
44 |
case p_ of
|
walther@59763
|
45 |
Pbl =>
|
walther@59854
|
46 |
(if dI' = ThyC.e_domID andalso dI = ThyC.e_domID then ("dummy", (Pbl, Tactic.Specify_Theory dI'))
|
walther@59763
|
47 |
else if pI' = Celem.e_pblID andalso pI = Celem.e_pblID then ("dummy", (Pbl, Tactic.Specify_Problem pI'))
|
walther@59763
|
48 |
else
|
walther@59763
|
49 |
case find_first (is_error o #5) pbl of
|
walther@59763
|
50 |
SOME (_, _, _, fd, itm_) =>
|
walther@59854
|
51 |
("dummy", (Pbl, mk_delete (Celem.assoc_thy (if dI = ThyC.e_domID then dI' else dI)) fd itm_))
|
walther@59763
|
52 |
| NONE =>
|
walther@59854
|
53 |
(case nxt_add (Celem.assoc_thy (if dI = ThyC.e_domID then dI' else dI)) oris pbt pbl of
|
walther@59763
|
54 |
SOME (fd, ct') => ("dummy", (Pbl, mk_additem fd ct'))
|
walther@59763
|
55 |
| NONE => (*pbl-items complete*)
|
walther@59763
|
56 |
if not preok then ("dummy", (Pbl, Tactic.Refine_Problem pI'))
|
walther@59854
|
57 |
else if dI = ThyC.e_domID then ("dummy", (Pbl, Tactic.Specify_Theory dI'))
|
walther@59763
|
58 |
else if pI = Celem.e_pblID then ("dummy", (Pbl, Tactic.Specify_Problem pI'))
|
walther@59763
|
59 |
else if mI = Celem.e_metID then ("dummy", (Pbl, Tactic.Specify_Method mI'))
|
walther@59763
|
60 |
else
|
walther@59763
|
61 |
case find_first (is_error o #5) met of
|
walther@59763
|
62 |
SOME (_, _, _, fd, itm_) => ("dummy", (Met, mk_delete (Celem.assoc_thy dI) fd itm_))
|
walther@59763
|
63 |
| NONE =>
|
walther@59763
|
64 |
(case nxt_add (Celem.assoc_thy dI) oris mpc met of
|
walther@59763
|
65 |
SOME (fd, ct') => ("dummy", (Met, mk_additem fd ct')) (*30.8.01: pre?!?*)
|
walther@59763
|
66 |
| NONE => ("dummy", (Met, Tactic.Apply_Method mI)))))
|
walther@59763
|
67 |
| Met =>
|
walther@59763
|
68 |
(case find_first (is_error o #5) met of
|
walther@59854
|
69 |
SOME (_,_,_,fd,itm_) => ("dummy", (Met, mk_delete (Celem.assoc_thy (if dI = ThyC.e_domID then dI' else dI)) fd itm_))
|
walther@59763
|
70 |
| NONE =>
|
walther@59854
|
71 |
case nxt_add (Celem.assoc_thy (if dI = ThyC.e_domID then dI' else dI)) oris mpc met of
|
walther@59763
|
72 |
SOME (fd,ct') => ("dummy", (Met, mk_additem fd ct'))
|
walther@59763
|
73 |
| NONE =>
|
walther@59854
|
74 |
(if dI = ThyC.e_domID then ("dummy", (Met, Tactic.Specify_Theory dI'))
|
walther@59763
|
75 |
else if pI = Celem.e_pblID then ("dummy", (Met, Tactic.Specify_Problem pI'))
|
walther@59763
|
76 |
else if not preok then ("dummy", (Met, Tactic.Specify_Method mI))
|
walther@59763
|
77 |
else ("dummy", (Met, Tactic.Apply_Method mI))))
|
walther@59772
|
78 |
| p_ => raise ERROR ("Specify.find_next_step called with " ^ Pos.pos_2str p_)
|
walther@59763
|
79 |
end
|
walther@59763
|
80 |
end
|
walther@59763
|
81 |
|
walther@59764
|
82 |
(* create a calc-tree with oris via an cas.refined pbl *)
|
walther@59764
|
83 |
fun nxt_specify_init_calc ([], (dI, pI, mI)) =
|
walther@59764
|
84 |
if pI <> []
|
walther@59764
|
85 |
then (* from pbl-browser or from CAS cmd with pI=[e_pblID] *)
|
walther@59764
|
86 |
let
|
walther@59764
|
87 |
val {cas, met, ppc, thy, ...} = Specify.get_pbt pI
|
walther@59854
|
88 |
val dI = if dI = "" then ThyC.theory2theory' thy else dI
|
walther@59764
|
89 |
val mI = if mI = [] then hd met else mI
|
walther@59764
|
90 |
val hdl = case cas of NONE => Auto_Prog.pblterm dI pI | SOME t => t
|
walther@59846
|
91 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.Uistate, ContextC.empty) ([], (dI, pI, mI))
|
walther@59846
|
92 |
([], (dI,pI,mI), hdl, ContextC.empty)
|
walther@59764
|
93 |
val pt = update_spec pt [] (dI, pI, mI)
|
walther@59764
|
94 |
val pits = Generate.init_pbl' ppc
|
walther@59764
|
95 |
val pt = update_pbl pt [] pits
|
walther@59764
|
96 |
in ((pt, ([] , Pbl)), []) end
|
walther@59764
|
97 |
else
|
walther@59764
|
98 |
if mI <> []
|
walther@59764
|
99 |
then (* from met-browser *)
|
walther@59764
|
100 |
let
|
walther@59764
|
101 |
val {ppc, ...} = Specify.get_met mI
|
walther@59764
|
102 |
val dI = if dI = "" then "Isac_Knowledge" else dI
|
walther@59846
|
103 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty) ([], (dI, pI, mI))
|
walther@59846
|
104 |
([], (dI, pI, mI), Rule.e_term, ContextC.empty)
|
walther@59764
|
105 |
val pt = update_spec pt [] (dI, pI, mI)
|
walther@59764
|
106 |
val mits = Generate.init_pbl' ppc
|
walther@59764
|
107 |
val pt = update_met pt [] mits
|
walther@59764
|
108 |
in ((pt, ([], Met)), []) end
|
walther@59764
|
109 |
else (* new example, pepare for interactive modeling *)
|
walther@59764
|
110 |
let
|
walther@59846
|
111 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty)
|
walther@59846
|
112 |
([], Celem.e_spec) ([], Celem.e_spec, Rule.e_term, ContextC.empty)
|
walther@59764
|
113 |
in ((pt, ([], Pbl)), []) end
|
walther@59764
|
114 |
| nxt_specify_init_calc (fmz, (dI, pI, mI)) =
|
walther@59764
|
115 |
let (* both """"""""""""""""""""""""" either empty or complete *)
|
walther@59764
|
116 |
val thy = Celem.assoc_thy dI
|
walther@59764
|
117 |
val (pI, (pors, pctxt), mI) =
|
walther@59764
|
118 |
if mI = ["no_met"]
|
walther@59764
|
119 |
then
|
walther@59764
|
120 |
let
|
walther@59764
|
121 |
val (pors, pctxt) = Specify.get_pbt pI |> #ppc |> Specify.prep_ori fmz thy;
|
walther@59764
|
122 |
val pI' = Specify.refine_ori' pors pI;
|
walther@59764
|
123 |
in (pI', (pors(*refinement over models with diff.precond only*), pctxt),
|
walther@59764
|
124 |
(hd o #met o Specify.get_pbt) pI')
|
walther@59764
|
125 |
end
|
walther@59764
|
126 |
else (pI, Specify.get_pbt pI |> #ppc |> Specify.prep_ori fmz thy, mI)
|
walther@59764
|
127 |
val {cas, ppc, thy = thy', ...} = Specify.get_pbt pI (*take dI from _refined_ pbl*)
|
walther@59854
|
128 |
val dI = ThyC.theory2theory' (Stool.common_subthy (thy, thy'))
|
walther@59764
|
129 |
val hdl = case cas of
|
walther@59764
|
130 |
NONE => Auto_Prog.pblterm dI pI
|
walther@59764
|
131 |
| SOME t => subst_atomic ((vars_of_pbl_' ppc) ~~~ vals_of_oris pors) t
|
walther@59846
|
132 |
val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, pctxt) (fmz, (dI, pI, mI))
|
walther@59819
|
133 |
(pors, (dI, pI, mI), hdl, pctxt)
|
walther@59764
|
134 |
in
|
walther@59806
|
135 |
((pt, ([], Pbl)), fst3 (Step_Specify.by_tactic_input Tactic.Model_Problem (pt, ([], Pbl))))
|
walther@59764
|
136 |
end
|
walther@59764
|
137 |
|
walther@59763
|
138 |
end
|