walther@59920
|
1 |
(* Title: Specify/solve-step.sml
|
walther@59920
|
2 |
Author: Walther Neuper
|
walther@59920
|
3 |
(c) due to copyright terms
|
walther@59920
|
4 |
|
walther@59920
|
5 |
Code for the solve-phase in analogy to structure Specify_Step for the specify-phase.
|
walther@59920
|
6 |
*)
|
walther@59920
|
7 |
|
walther@59920
|
8 |
signature SOLVE_STEP =
|
walther@59920
|
9 |
sig
|
walther@59921
|
10 |
val check: Tactic.input -> Calc.T -> Applicable.T
|
walther@59931
|
11 |
val add: Tactic.T -> Istate_Def.T * Proof.context -> Calc.T -> Generate.test_out
|
walther@59932
|
12 |
val add_general: Tactic.T -> Istate_Def.T * Proof.context -> Calc.T -> Generate.test_out
|
walther@59932
|
13 |
val s_add_general: State_Steps.T ->
|
walther@59932
|
14 |
Ctree.ctree * Pos.pos' list * Pos.pos' -> Ctree.ctree * Pos.pos' list * Pos.pos'
|
walther@59933
|
15 |
val add_hard:
|
walther@59933
|
16 |
theory -> Tactic.T -> Pos.pos' -> Ctree.ctree -> Generate.test_out
|
walther@59932
|
17 |
|
walther@59921
|
18 |
(* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
|
walther@59921
|
19 |
(*NONE*)
|
walther@59921
|
20 |
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
|
walther@59921
|
21 |
(*NONE*)
|
walther@59921
|
22 |
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
|
walther@59920
|
23 |
end
|
walther@59920
|
24 |
|
walther@59920
|
25 |
(**)
|
walther@59920
|
26 |
structure Solve_Step(** ): SOLVE_STEP( **) =
|
walther@59920
|
27 |
struct
|
walther@59920
|
28 |
(**)
|
walther@59920
|
29 |
|
walther@59922
|
30 |
(*
|
walther@59922
|
31 |
check tactics (input by the user, mostly) for applicability
|
walther@59922
|
32 |
and determine as much of the result of the tactic as possible initially.
|
walther@59922
|
33 |
*)
|
walther@59932
|
34 |
fun check (Tactic.Apply_Method mI) (pt, (p, _)) =
|
walther@59932
|
35 |
let
|
walther@59932
|
36 |
val (dI, pI, probl, ctxt) = case Ctree.get_obj I pt p of
|
walther@59932
|
37 |
Ctree.PblObj {origin = (_, (dI, pI, _), _), probl, ctxt, ...} => (dI, pI, probl, ctxt)
|
walther@59932
|
38 |
| _ => raise ERROR "Specify_Step.check Apply_Method: uncovered case Ctree.get_obj"
|
walther@59932
|
39 |
val {where_, ...} = Specify.get_pbt pI
|
walther@59932
|
40 |
val pres = map (Model.mk_env probl |> subst_atomic) where_
|
walther@59932
|
41 |
val ctxt = if ContextC.is_empty ctxt (*vvvvvvvvvvvvvv DO THAT EARLIER?!?*)
|
walther@59932
|
42 |
then ThyC.get_theory dI |> Proof_Context.init_global |> ContextC.insert_assumptions pres
|
walther@59932
|
43 |
else ctxt
|
walther@59932
|
44 |
in
|
walther@59932
|
45 |
Applicable.Yes (Tactic.Apply_Method' (mI, NONE, Istate_Def.empty (*filled later*), ctxt))
|
walther@59932
|
46 |
end
|
walther@59932
|
47 |
| check (Tactic.Calculate op_) (cs as (pt, (p, _))) =
|
walther@59923
|
48 |
let
|
walther@59928
|
49 |
val (msg, thy', isa_fn) = ApplicableOLD.from_pblobj_or_detail_calc op_ p pt;
|
walther@59928
|
50 |
val f = Calc.current_formula cs;
|
walther@59923
|
51 |
in
|
walther@59923
|
52 |
if msg = "OK"
|
walther@59923
|
53 |
then
|
walther@59923
|
54 |
case Rewrite.calculate_ (ThyC.get_theory thy') isa_fn f of
|
walther@59923
|
55 |
SOME (f', (id, thm))
|
walther@59923
|
56 |
=> Applicable.Yes (Tactic.Calculate' (thy', op_, f, (f', (id, thm))))
|
walther@59929
|
57 |
| NONE => Applicable.No ("'calculate " ^ op_ ^ "' not applicable")
|
walther@59923
|
58 |
else Applicable.No msg
|
walther@59923
|
59 |
end
|
walther@59928
|
60 |
| check (Tactic.Check_Postcond pI) (_, _) = (*TODO: only applicable, if evaluating to True*)
|
walther@59928
|
61 |
Applicable.Yes (Tactic.Check_Postcond' (pI, TermC.empty))
|
walther@59928
|
62 |
| check (Tactic.Check_elementwise pred) cs =
|
walther@59923
|
63 |
let
|
walther@59928
|
64 |
val f = Calc.current_formula cs;
|
walther@59923
|
65 |
in
|
walther@59928
|
66 |
Applicable.Yes (Tactic.Check_elementwise' (f, pred, (f, [])))
|
walther@59923
|
67 |
end
|
walther@59923
|
68 |
| check Tactic.Empty_Tac _ = Applicable.No "Empty_Tac is not applicable"
|
walther@59929
|
69 |
| check (Tactic.Free_Solve) _ = Applicable.Yes (Tactic.Free_Solve')
|
walther@59929
|
70 |
| check Tactic.Or_to_List cs =
|
walther@59928
|
71 |
let
|
walther@59929
|
72 |
val f = Calc.current_formula cs;
|
walther@59929
|
73 |
val ls = Prog_Expr.or2list f;
|
walther@59929
|
74 |
in
|
walther@59929
|
75 |
Applicable.Yes (Tactic.Or_to_List' (f, ls))
|
walther@59923
|
76 |
end
|
walther@59929
|
77 |
| check (Tactic.Rewrite thm) (cs as (pt, (p, _))) =
|
walther@59923
|
78 |
let
|
walther@59929
|
79 |
val (msg, thy', ro, rls', _) = ApplicableOLD.from_pblobj_or_detail_thm thm p pt;
|
walther@59923
|
80 |
val thy = ThyC.get_theory thy';
|
walther@59928
|
81 |
val f = Calc.current_formula cs;
|
walther@59923
|
82 |
in
|
walther@59923
|
83 |
if msg = "OK"
|
walther@59923
|
84 |
then
|
walther@59929
|
85 |
case Rewrite.rewrite_ thy (Rewrite_Ord.assoc_rew_ord ro) rls' false (snd thm) f of
|
walther@59929
|
86 |
SOME (f',asm) => Applicable.Yes (Tactic.Rewrite' (thy', ro, rls', false, thm, f, (f', asm)))
|
walther@59929
|
87 |
| NONE => Applicable.No ((thm |> fst |> quote) ^ " not applicable")
|
walther@59923
|
88 |
else Applicable.No msg
|
walther@59923
|
89 |
end
|
walther@59929
|
90 |
| check (Tactic.Rewrite_Inst (subs, thm)) (cs as (pt, (p, _))) =
|
walther@59921
|
91 |
let
|
walther@59921
|
92 |
val pp = Ctree.par_pblobj pt p;
|
walther@59921
|
93 |
val thy' = Ctree.get_obj Ctree.g_domID pt pp;
|
walther@59921
|
94 |
val thy = ThyC.get_theory thy';
|
walther@59921
|
95 |
val {rew_ord' = ro', erls = erls, ...} = Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp);
|
walther@59928
|
96 |
val f = Calc.current_formula cs;
|
walther@59929
|
97 |
val subst = Subst.T_from_input thy subs; (*TODO: input requires parse _: _ -> _ option*)
|
walther@59921
|
98 |
in
|
walther@59929
|
99 |
case Rewrite.rewrite_inst_ thy (Rewrite_Ord.assoc_rew_ord ro') erls false subst (snd thm) f of
|
walther@59929
|
100 |
SOME (f', asm) =>
|
walther@59929
|
101 |
Applicable.Yes (Tactic.Rewrite_Inst' (thy', ro', erls, false, subst, thm, f, (f', asm)))
|
walther@59929
|
102 |
| NONE => Applicable.No (fst thm ^ " not applicable")
|
walther@59921
|
103 |
end
|
walther@59928
|
104 |
| check (Tactic.Rewrite_Set rls) (cs as (pt, (p, _))) =
|
walther@59921
|
105 |
let
|
walther@59923
|
106 |
val pp = Ctree.par_pblobj pt p;
|
walther@59921
|
107 |
val thy' = Ctree.get_obj Ctree.g_domID pt pp;
|
walther@59928
|
108 |
val f = Calc.current_formula cs;
|
walther@59923
|
109 |
in
|
walther@59923
|
110 |
case Rewrite.rewrite_set_ (ThyC.get_theory thy') false (assoc_rls rls) f of
|
walther@59921
|
111 |
SOME (f', asm)
|
walther@59923
|
112 |
=> Applicable.Yes (Tactic.Rewrite_Set' (thy', false, assoc_rls rls, f, (f', asm)))
|
walther@59923
|
113 |
| NONE => Applicable.No (rls ^ " not applicable")
|
walther@59921
|
114 |
end
|
walther@59929
|
115 |
| check (Tactic.Rewrite_Set_Inst (subs, rls)) (cs as (pt, (p, _))) =
|
walther@59921
|
116 |
let
|
walther@59921
|
117 |
val pp = Ctree.par_pblobj pt p;
|
walther@59921
|
118 |
val thy' = Ctree.get_obj Ctree.g_domID pt pp;
|
walther@59921
|
119 |
val thy = ThyC.get_theory thy';
|
walther@59928
|
120 |
val f = Calc.current_formula cs;
|
walther@59929
|
121 |
val subst = Subst.T_from_input thy subs; (*TODO: input requires parse _: _ -> _ option*)
|
walther@59921
|
122 |
in
|
walther@59928
|
123 |
case Rewrite.rewrite_set_inst_ thy false subst (assoc_rls rls) f of
|
walther@59928
|
124 |
SOME (f', asm)
|
walther@59921
|
125 |
=> Applicable.Yes (Tactic.Rewrite_Set_Inst' (thy', false, subst, assoc_rls rls, f, (f', asm)))
|
walther@59921
|
126 |
| NONE => Applicable.No (rls ^ " not applicable")
|
walther@59921
|
127 |
end
|
walther@59928
|
128 |
| check (Tactic.Subproblem (domID, pblID)) (_, _) =
|
walther@59928
|
129 |
Applicable.Yes (Tactic.Subproblem' ((domID, pblID, Method.id_empty), [],
|
walther@59928
|
130 |
TermC.empty, [], ContextC.empty, Auto_Prog.subpbl domID pblID))
|
walther@59929
|
131 |
| check (Tactic.Substitute sube) (cs as (pt, (p, _))) =
|
walther@59928
|
132 |
let
|
walther@59928
|
133 |
val pp = Ctree.par_pblobj pt p
|
walther@59928
|
134 |
val thy = ThyC.get_theory (Ctree.get_obj Ctree.g_domID pt pp)
|
walther@59928
|
135 |
val f = Calc.current_formula cs;
|
walther@59928
|
136 |
val {rew_ord', erls, ...} = Specify.get_met (Ctree.get_obj Ctree.g_metID pt pp)
|
walther@59929
|
137 |
val subte = Subst.input_to_terms sube (*TODO: input requires parse _: _ -> _ option*)
|
walther@59928
|
138 |
val subst = Subst.T_from_string_eqs thy sube
|
walther@59928
|
139 |
val ro = Rewrite_Ord.assoc_rew_ord rew_ord'
|
walther@59928
|
140 |
in
|
walther@59928
|
141 |
if foldl and_ (true, map TermC.contains_Var subte)
|
walther@59928
|
142 |
then (*1*)
|
walther@59928
|
143 |
let val f' = subst_atomic subst f
|
walther@59928
|
144 |
in if f = f'
|
walther@59928
|
145 |
then Applicable.No (Subst.string_eqs_to_string sube ^ " not applicable")
|
walther@59928
|
146 |
else Applicable.Yes (Tactic.Substitute' (ro, erls, subte, f, f'))
|
walther@59928
|
147 |
end
|
walther@59928
|
148 |
else (*2*)
|
walther@59928
|
149 |
case Rewrite.rewrite_terms_ thy ro erls subte f of
|
walther@59928
|
150 |
SOME (f', _) => Applicable.Yes (Tactic.Substitute' (ro, erls, subte, f, f'))
|
walther@59928
|
151 |
| NONE => Applicable.No (Subst.string_eqs_to_string sube ^ " not applicable")
|
walther@59928
|
152 |
end
|
walther@59928
|
153 |
| check (Tactic.Tac id) (cs as (pt, (p, _))) =
|
walther@59929
|
154 |
let
|
walther@59929
|
155 |
val pp = Ctree.par_pblobj pt p;
|
walther@59929
|
156 |
val thy' = Ctree.get_obj Ctree.g_domID pt pp;
|
walther@59929
|
157 |
val thy = ThyC.get_theory thy';
|
walther@59929
|
158 |
val f = Calc.current_formula cs;
|
walther@59929
|
159 |
in case id of
|
walther@59929
|
160 |
"subproblem_equation_dummy" =>
|
walther@59929
|
161 |
if TermC.is_expliceq f
|
walther@59929
|
162 |
then Applicable.Yes (Tactic.Tac_ (thy, UnparseC.term f, id, "subproblem_equation_dummy (" ^ UnparseC.term f ^ ")"))
|
walther@59929
|
163 |
else Applicable.No "applicable only to equations made explicit"
|
walther@59929
|
164 |
| "solve_equation_dummy" =>
|
walther@59929
|
165 |
let val (id', f') = ApplicableOLD.split_dummy (UnparseC.term f);
|
walther@59929
|
166 |
in
|
walther@59929
|
167 |
if id' <> "subproblem_equation_dummy"
|
walther@59929
|
168 |
then Applicable.No "no subproblem"
|
walther@59929
|
169 |
else if (ThyC.to_ctxt thy, f') |-> TermC.parseNEW |> the |> TermC.is_expliceq
|
walther@59929
|
170 |
then Applicable.Yes (Tactic.Tac_ (thy, UnparseC.term f, id, "[" ^ f' ^ "]"))
|
walther@59929
|
171 |
else error ("Solve_Step.check: f= " ^ f')
|
walther@59929
|
172 |
end
|
walther@59929
|
173 |
| _ => Applicable.Yes (Tactic.Tac_ (thy, UnparseC.term f, id, UnparseC.term f))
|
walther@59921
|
174 |
end
|
walther@59923
|
175 |
| check (Tactic.Take str) _ = Applicable.Yes (Tactic.Take' (TermC.str2term str)) (* always applicable ?*)
|
walther@59929
|
176 |
| check (Tactic.Begin_Trans) cs =
|
walther@59929
|
177 |
Applicable.Yes (Tactic.Begin_Trans' (Calc.current_formula cs))
|
walther@59923
|
178 |
| check (Tactic.End_Trans) (pt, (p, p_)) = (*TODO: check parent branches*)
|
walther@59923
|
179 |
if p_ = Pos.Res
|
walther@59923
|
180 |
then Applicable.Yes (Tactic.End_Trans' (Ctree.get_obj Ctree.g_result pt p))
|
walther@59923
|
181 |
else Applicable.No "'End_Trans' is not applicable at the beginning of a transitive sequence"
|
walther@59921
|
182 |
| check Tactic.End_Proof' _ = Applicable.Yes Tactic.End_Proof''
|
walther@59921
|
183 |
| check m _ = raise ERROR ("Solve_Step.check called for " ^ Tactic.input_to_string m);
|
walther@59920
|
184 |
|
walther@59932
|
185 |
fun add (Tactic.Apply_Method' (_, topt, is, _)) (_, ctxt) (pt, pos as (p, _)) =
|
walther@59932
|
186 |
(case topt of
|
walther@59932
|
187 |
SOME t =>
|
walther@59932
|
188 |
let val (pt, c) = Ctree.cappend_form pt p (is, ctxt) t
|
walther@59932
|
189 |
in (pos, c, Generate.EmptyMout, pt) end
|
walther@59932
|
190 |
| NONE => (pos, [], Generate.EmptyMout, pt))
|
walther@59932
|
191 |
| add (Tactic.Take' t) l (pt, (p, _)) = (* val (Take' t) = m; *)
|
walther@59931
|
192 |
let
|
walther@59931
|
193 |
val p =
|
walther@59931
|
194 |
let val (ps, p') = split_last p (* no connex to prev.ppobj *)
|
walther@59931
|
195 |
in if p' = 0 then ps @ [1] else p end
|
walther@59931
|
196 |
val (pt, c) = Ctree.cappend_form pt p l t
|
walther@59931
|
197 |
in
|
walther@59931
|
198 |
((p, Pos.Frm), c, Generate.FormKF (UnparseC.term t), pt)
|
walther@59931
|
199 |
end
|
walther@59931
|
200 |
| add (Tactic.Begin_Trans' t) l (pt, (p, Pos.Frm)) =
|
walther@59931
|
201 |
let
|
walther@59931
|
202 |
val (pt, c) = Ctree.cappend_form pt p l t
|
walther@59931
|
203 |
val pt = Ctree.update_branch pt p Ctree.TransitiveB (*040312*)
|
walther@59931
|
204 |
(* replace the old PrfOjb ~~~~~ *)
|
walther@59931
|
205 |
val p = (Pos.lev_on o Pos.lev_dn (* starts with [...,0] *)) p
|
walther@59931
|
206 |
val (pt, c') = Ctree.cappend_form pt p l t (*FIXME.0402 same istate ???*)
|
walther@59931
|
207 |
in
|
walther@59931
|
208 |
((p, Pos.Frm), c @ c', Generate.FormKF (UnparseC.term t), pt)
|
walther@59931
|
209 |
end
|
walther@59931
|
210 |
| add (Tactic.Begin_Trans' t) l (pt, (p, Pos.Res)) =
|
walther@59931
|
211 |
(*append after existing PrfObj vvvvvvvvvvvvv*)
|
walther@59931
|
212 |
add (Tactic.Begin_Trans' t) l (pt, (Pos.lev_on p, Pos.Frm))
|
walther@59931
|
213 |
| add (Tactic.End_Trans' tasm) l (pt, (p, _)) =
|
walther@59931
|
214 |
let
|
walther@59931
|
215 |
val p' = Pos.lev_up p
|
walther@59931
|
216 |
val (pt, c) = Ctree.append_result pt p' l tasm Ctree.Complete
|
walther@59931
|
217 |
in
|
walther@59931
|
218 |
((p', Pos.Res), c, Generate.FormKF "DUMMY" (*term2str t ..ERROR (t) has not been declared*), pt)
|
walther@59931
|
219 |
end
|
walther@59931
|
220 |
| add (Tactic.Rewrite_Inst' (_, _, _, _, subs', thm', f, (f', asm))) (is, ctxt) (pt, (p, _)) =
|
walther@59931
|
221 |
let
|
walther@59931
|
222 |
val (pt, c) = Ctree.cappend_atomic pt p (is, ctxt) f
|
walther@59931
|
223 |
(Tactic.Rewrite_Inst (Subst.T_to_input subs', thm')) (f',asm) Ctree.Complete;
|
walther@59931
|
224 |
val pt = Ctree.update_branch pt p Ctree.TransitiveB
|
walther@59931
|
225 |
in
|
walther@59931
|
226 |
((p, Pos.Res), c, Generate.FormKF (UnparseC.term f'), pt)
|
walther@59931
|
227 |
end
|
walther@59931
|
228 |
| add (Tactic.Rewrite' (_, _, _, _, thm', f, (f', asm))) (is, ctxt) (pt, (p, _)) =
|
walther@59931
|
229 |
let
|
walther@59931
|
230 |
val (pt, c) = Ctree.cappend_atomic pt p (is, ctxt) f (Tactic.Rewrite thm') (f', asm) Ctree.Complete
|
walther@59931
|
231 |
val pt = Ctree.update_branch pt p Ctree.TransitiveB
|
walther@59931
|
232 |
in
|
walther@59931
|
233 |
((p, Pos.Res), c, Generate.FormKF (UnparseC.term f'), pt)
|
walther@59931
|
234 |
end
|
walther@59931
|
235 |
| add (Tactic.Rewrite_Set_Inst' (_, _, subs', rls', f, (f', asm))) (is, ctxt) (pt, (p, _)) =
|
walther@59931
|
236 |
let
|
walther@59931
|
237 |
val (pt, c) = Ctree.cappend_atomic pt p (is, ctxt) f
|
walther@59931
|
238 |
(Tactic.Rewrite_Set_Inst (Subst.T_to_input subs', Rule_Set.id rls')) (f', asm) Ctree.Complete
|
walther@59931
|
239 |
val pt = Ctree.update_branch pt p Ctree.TransitiveB
|
walther@59931
|
240 |
in
|
walther@59931
|
241 |
((p, Pos.Res), c, Generate.FormKF (UnparseC.term f'), pt)
|
walther@59931
|
242 |
end
|
walther@59931
|
243 |
| add (Tactic.Rewrite_Set' (_, _, rls', f, (f', asm))) (is, ctxt) (pt, (p, _)) =
|
walther@59931
|
244 |
let
|
walther@59931
|
245 |
val (pt, c) = Ctree.cappend_atomic pt p (is, ctxt) f
|
walther@59931
|
246 |
(Tactic.Rewrite_Set (Rule_Set.id rls')) (f', asm) Ctree.Complete
|
walther@59931
|
247 |
val pt = Ctree.update_branch pt p Ctree.TransitiveB
|
walther@59931
|
248 |
in
|
walther@59931
|
249 |
((p, Pos.Res), c, Generate.FormKF (UnparseC.term f'), pt)
|
walther@59931
|
250 |
end
|
walther@59931
|
251 |
| add (Tactic.Check_Postcond' (_, scval)) l (pt, (p, _)) =
|
walther@59931
|
252 |
let
|
walther@59931
|
253 |
val (pt, c) = Ctree.append_result pt p l (scval, []) Ctree.Complete
|
walther@59931
|
254 |
in
|
walther@59931
|
255 |
((p, Pos.Res), c, Generate.FormKF (UnparseC.term scval), pt)
|
walther@59931
|
256 |
end
|
walther@59931
|
257 |
| add (Tactic.Calculate' (_, op_, f, (f', _))) l (pt, (p, _)) =
|
walther@59931
|
258 |
let
|
walther@59931
|
259 |
val (pt,c) = Ctree.cappend_atomic pt p l f (Tactic.Calculate op_) (f', []) Ctree.Complete
|
walther@59931
|
260 |
in
|
walther@59931
|
261 |
((p, Pos.Res), c, Generate.FormKF (UnparseC.term f'), pt)
|
walther@59931
|
262 |
end
|
walther@59931
|
263 |
| add (Tactic.Check_elementwise' (consts, pred, (f', asm))) l (pt, (p, _)) =
|
walther@59931
|
264 |
let
|
walther@59931
|
265 |
val (pt,c) = Ctree.cappend_atomic pt p l consts (Tactic.Check_elementwise pred) (f', asm) Ctree.Complete
|
walther@59931
|
266 |
in
|
walther@59931
|
267 |
((p, Pos.Res), c, Generate.FormKF (UnparseC.term f'), pt)
|
walther@59931
|
268 |
end
|
walther@59931
|
269 |
| add (Tactic.Or_to_List' (ors, list)) l (pt, (p, _)) =
|
walther@59931
|
270 |
let
|
walther@59931
|
271 |
val (pt,c) = Ctree.cappend_atomic pt p l ors Tactic.Or_to_List (list, []) Ctree.Complete
|
walther@59931
|
272 |
in
|
walther@59931
|
273 |
((p, Pos.Res), c, Generate.FormKF (UnparseC.term list), pt)
|
walther@59931
|
274 |
end
|
walther@59931
|
275 |
| add (Tactic.Substitute' (_, _, subte, t, t')) l (pt, (p, _)) =
|
walther@59931
|
276 |
let
|
walther@59931
|
277 |
val (pt,c) =
|
walther@59931
|
278 |
Ctree.cappend_atomic pt p l t (Tactic.Substitute (Subst.eqs_to_input subte)) (t',[]) Ctree.Complete
|
walther@59931
|
279 |
in ((p, Pos.Res), c, Generate.FormKF (UnparseC.term t'), pt)
|
walther@59931
|
280 |
end
|
walther@59931
|
281 |
| add (Tactic.Tac_ (_, f, id, f')) l (pt, (p, _)) =
|
walther@59931
|
282 |
let
|
walther@59931
|
283 |
val (pt, c) = Ctree.cappend_atomic pt p l (TermC.str2term f) (Tactic.Tac id) (TermC.str2term f', []) Ctree.Complete
|
walther@59931
|
284 |
in
|
walther@59931
|
285 |
((p,Pos.Res), c, Generate.FormKF f', pt)
|
walther@59931
|
286 |
end
|
walther@59931
|
287 |
| add (Tactic.Subproblem' ((domID, pblID, metID), oris, hdl, fmz_, ctxt_specify, f))
|
walther@59931
|
288 |
(l as (_, ctxt)) (pt, (p, _)) =
|
walther@59932
|
289 |
let
|
walther@59932
|
290 |
val (pt, c) = Ctree.cappend_problem pt p l (fmz_, (domID, pblID, metID))
|
walther@59932
|
291 |
(oris, (domID, pblID, metID), hdl, ctxt_specify)
|
walther@59932
|
292 |
val f = Syntax.string_of_term (ThyC.to_ctxt (Proof_Context.theory_of ctxt)) f
|
walther@59932
|
293 |
in
|
walther@59932
|
294 |
((p, Pos.Pbl), c, Generate.FormKF f, pt)
|
walther@59932
|
295 |
end
|
walther@59932
|
296 |
| add m' _ (_, pos) =
|
walther@59932
|
297 |
raise ERROR ("Solve_Step.add: not impl.for " ^ Tactic.string_of m' ^ " at " ^ Pos.pos'2str pos)
|
walther@59932
|
298 |
|
walther@59932
|
299 |
(* LI switches between solve-phase and specify-phase *)
|
walther@59932
|
300 |
fun add_general tac ic cs =
|
walther@59932
|
301 |
if Tactic.for_specify' tac
|
walther@59933
|
302 |
then Specify_Step.add tac ic cs
|
walther@59932
|
303 |
else add tac ic cs
|
walther@59932
|
304 |
|
walther@59933
|
305 |
(* the order of State_Steps is reversed: insert last element first *)
|
walther@59932
|
306 |
fun s_add_general [] ptp = ptp
|
walther@59932
|
307 |
| s_add_general tacis (pt, c, _) =
|
walther@59931
|
308 |
let
|
walther@59932
|
309 |
val (tacis', (_, tac_, (p, is))) = split_last tacis
|
walther@59933
|
310 |
val (p', c', _, pt') = add_general tac_ is (pt, p)
|
walther@59931
|
311 |
in
|
walther@59932
|
312 |
s_add_general tacis' (pt', c@c', p')
|
walther@59931
|
313 |
end
|
walther@59932
|
314 |
|
walther@59933
|
315 |
(* a still undeveloped concept: do a calculation without LI *)
|
walther@59933
|
316 |
fun add_hard _(*thy*) m' (p, p_) pt =
|
walther@59933
|
317 |
let
|
walther@59933
|
318 |
val p = case p_ of
|
walther@59933
|
319 |
Pos.Frm => p | Pos.Res => Pos.lev_on p
|
walther@59933
|
320 |
| _ => error ("generate_hard: call by " ^ Pos.pos'2str (p,p_))
|
walther@59933
|
321 |
in
|
walther@59933
|
322 |
add_general m' (Istate_Def.empty, ContextC.empty) (pt, (p, p_))
|
walther@59933
|
323 |
end
|
walther@59931
|
324 |
|
walther@59920
|
325 |
(**)end(**);
|