walther@59763
|
1 |
signature SPECIFY_NEW =
|
walther@59763
|
2 |
sig
|
walther@59763
|
3 |
val find_next_tactic: Ctree.state -> string * (Pos.pos_ * Tactic.input)
|
walther@59763
|
4 |
|
walther@59763
|
5 |
end
|
walther@59763
|
6 |
|
walther@59763
|
7 |
(**)
|
walther@59763
|
8 |
structure SpecifyNEW(**): SPECIFY_NEW(**) =
|
walther@59763
|
9 |
struct
|
walther@59763
|
10 |
(**)
|
walther@59763
|
11 |
open Pos
|
walther@59763
|
12 |
open Chead
|
walther@59763
|
13 |
|
walther@59763
|
14 |
(* was Chead.nxt_spec *)
|
walther@59763
|
15 |
fun find_next_tactic (pt, (p, p_)) =
|
walther@59763
|
16 |
let
|
walther@59763
|
17 |
val (pblobj, met, origin, oris, dI', pI', mI', pbl, dI, pI, mI) =
|
walther@59763
|
18 |
case Ctree.get_obj I pt p of
|
walther@59763
|
19 |
pblobj as (Ctree.PblObj {meth, origin = origin as (oris, (dI', pI', mI'), _),
|
walther@59763
|
20 |
probl, spec = (dI, pI, mI), ...}) => (pblobj, meth, origin, oris, dI', pI', mI', probl, dI, pI, mI)
|
walther@59763
|
21 |
| Ctree.PrfObj _ => error "nxt_specify_: not on PrfObj"
|
walther@59763
|
22 |
in
|
walther@59763
|
23 |
if Ctree.just_created_ pblobj (*by Subproblem*) andalso origin <> Ctree.e_origin
|
walther@59763
|
24 |
then
|
walther@59763
|
25 |
case mI' of
|
walther@59763
|
26 |
["no_met"] => ("ok", (Pbl, Tactic.Refine_Tacitly pI'))
|
walther@59763
|
27 |
| _ => ("ok", (Pbl, Tactic.Model_Problem))
|
walther@59763
|
28 |
else
|
walther@59763
|
29 |
let
|
walther@59763
|
30 |
val cpI = if pI = Celem.e_pblID then pI' else pI;
|
walther@59763
|
31 |
val cmI = if mI = Celem.e_metID then mI' else mI;
|
walther@59763
|
32 |
val {ppc = pbt, prls, where_, ...} = Specify.get_pbt cpI;
|
walther@59763
|
33 |
val pre = Stool.check_preconds "thy 100820" prls where_ pbl;
|
walther@59763
|
34 |
val preok = foldl and_ (true, map fst pre);
|
walther@59763
|
35 |
(*FIXME.WN0308: ~~~~~: just check true in itms of pbl/met?*)
|
walther@59763
|
36 |
val mpc = (#ppc o Specify.get_met) cmI
|
walther@59763
|
37 |
in
|
walther@59763
|
38 |
case p_ of
|
walther@59763
|
39 |
Pbl =>
|
walther@59763
|
40 |
(if dI' = Rule.e_domID andalso dI = Rule.e_domID then ("dummy", (Pbl, Tactic.Specify_Theory dI'))
|
walther@59763
|
41 |
else if pI' = Celem.e_pblID andalso pI = Celem.e_pblID then ("dummy", (Pbl, Tactic.Specify_Problem pI'))
|
walther@59763
|
42 |
else
|
walther@59763
|
43 |
case find_first (is_error o #5) pbl of
|
walther@59763
|
44 |
SOME (_, _, _, fd, itm_) =>
|
walther@59763
|
45 |
("dummy", (Pbl, mk_delete (Celem.assoc_thy (if dI = Rule.e_domID then dI' else dI)) fd itm_))
|
walther@59763
|
46 |
| NONE =>
|
walther@59763
|
47 |
(case nxt_add (Celem.assoc_thy (if dI = Rule.e_domID then dI' else dI)) oris pbt pbl of
|
walther@59763
|
48 |
SOME (fd, ct') => ("dummy", (Pbl, mk_additem fd ct'))
|
walther@59763
|
49 |
| NONE => (*pbl-items complete*)
|
walther@59763
|
50 |
if not preok then ("dummy", (Pbl, Tactic.Refine_Problem pI'))
|
walther@59763
|
51 |
else if dI = Rule.e_domID then ("dummy", (Pbl, Tactic.Specify_Theory dI'))
|
walther@59763
|
52 |
else if pI = Celem.e_pblID then ("dummy", (Pbl, Tactic.Specify_Problem pI'))
|
walther@59763
|
53 |
else if mI = Celem.e_metID then ("dummy", (Pbl, Tactic.Specify_Method mI'))
|
walther@59763
|
54 |
else
|
walther@59763
|
55 |
case find_first (is_error o #5) met of
|
walther@59763
|
56 |
SOME (_, _, _, fd, itm_) => ("dummy", (Met, mk_delete (Celem.assoc_thy dI) fd itm_))
|
walther@59763
|
57 |
| NONE =>
|
walther@59763
|
58 |
(case nxt_add (Celem.assoc_thy dI) oris mpc met of
|
walther@59763
|
59 |
SOME (fd, ct') => ("dummy", (Met, mk_additem fd ct')) (*30.8.01: pre?!?*)
|
walther@59763
|
60 |
| NONE => ("dummy", (Met, Tactic.Apply_Method mI)))))
|
walther@59763
|
61 |
| Met =>
|
walther@59763
|
62 |
(case find_first (is_error o #5) met of
|
walther@59763
|
63 |
SOME (_,_,_,fd,itm_) => ("dummy", (Met, mk_delete (Celem.assoc_thy (if dI = Rule.e_domID then dI' else dI)) fd itm_))
|
walther@59763
|
64 |
| NONE =>
|
walther@59763
|
65 |
case nxt_add (Celem.assoc_thy (if dI = Rule.e_domID then dI' else dI)) oris mpc met of
|
walther@59763
|
66 |
SOME (fd,ct') => ("dummy", (Met, mk_additem fd ct'))
|
walther@59763
|
67 |
| NONE =>
|
walther@59763
|
68 |
(if dI = Rule.e_domID then ("dummy", (Met, Tactic.Specify_Theory dI'))
|
walther@59763
|
69 |
else if pI = Celem.e_pblID then ("dummy", (Met, Tactic.Specify_Problem pI'))
|
walther@59763
|
70 |
else if not preok then ("dummy", (Met, Tactic.Specify_Method mI))
|
walther@59763
|
71 |
else ("dummy", (Met, Tactic.Apply_Method mI))))
|
walther@59763
|
72 |
| p_ => raise ERROR ("Specify.find_next_tactic called with " ^ Pos.pos_2str p_)
|
walther@59763
|
73 |
end
|
walther@59763
|
74 |
end
|
walther@59763
|
75 |
|
walther@59763
|
76 |
end
|