wneuper@59276
|
1 |
(* Title: generate specific entries into Ctree
|
wneuper@59276
|
2 |
Author: Walther Neuper
|
wneuper@59276
|
3 |
(c) due to copyright terms
|
wneuper@59276
|
4 |
*)
|
wneuper@59276
|
5 |
|
wneuper@59271
|
6 |
signature GENERATE_CALC_TREE =
|
wneuper@59276
|
7 |
sig
|
walther@59903
|
8 |
datatype pblmet = Method of Method.id | Problem of Problem.id | Upblmet
|
wneuper@59268
|
9 |
datatype mout =
|
wneuper@59268
|
10 |
EmptyMout
|
wneuper@59268
|
11 |
| Error' of string
|
walther@59865
|
12 |
| FormKF of TermC.as_string
|
wneuper@59316
|
13 |
| PpcKF of pblmet * Model.item Model.ppc
|
walther@59903
|
14 |
| RefinedKF of Problem.id * (Model.itm list * (bool * term) list)
|
walther@59811
|
15 |
val generate1 : Tactic.T -> Istate_Def.T * Proof.context -> Calc.T
|
walther@59846
|
16 |
-> Pos.pos' * Pos.pos' list * mout * Ctree.ctree
|
walther@59737
|
17 |
val init_istate : Tactic.input -> term -> Istate_Def.T
|
wneuper@59316
|
18 |
val init_pbl : (string * (term * 'a)) list -> Model.itm list
|
wneuper@59316
|
19 |
val init_pbl' : (string * (term * term)) list -> Model.itm list
|
walther@59908
|
20 |
val embed_deriv : State_Steps.T -> Calc.T -> Pos.pos' list * Calc.T
|
walther@59908
|
21 |
val generate_hard :
|
walther@59846
|
22 |
theory -> Tactic.T -> Pos.pos' -> Ctree.ctree -> Pos.pos' * Pos.pos' list * mout * Ctree.ctree
|
walther@59846
|
23 |
val generate : (Tactic.input * Tactic.T * (Pos.pos' * (Istate_Def.T * Proof.context))) list ->
|
walther@59908
|
24 |
Ctree.ctree * Pos.pos' list * Pos.pos' -> Ctree.ctree * Pos.pos' list * Pos.pos'
|
walther@59911
|
25 |
val generate_inconsistent_rew : Subst.input option * ThmC.T -> term -> Istate_Def.T * Proof.context ->
|
walther@59908
|
26 |
Pos.pos' -> Ctree.ctree -> Calc.T
|
wneuper@59310
|
27 |
(* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
|
walther@59639
|
28 |
val mout2str : mout -> string
|
walther@59886
|
29 |
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
|
walther@59908
|
30 |
(* NONE *)
|
walther@59886
|
31 |
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
|
wneuper@59266
|
32 |
end
|
neuper@37906
|
33 |
|
walther@59908
|
34 |
(**)
|
wneuper@59271
|
35 |
structure Generate(**): GENERATE_CALC_TREE(**) =
|
wneuper@59266
|
36 |
struct
|
walther@59908
|
37 |
(**)
|
wneuper@59276
|
38 |
open Ctree
|
walther@59695
|
39 |
open Pos
|
wneuper@59312
|
40 |
|
walther@59802
|
41 |
(* initialize istate for Detail_Set *)
|
wneuper@59571
|
42 |
fun init_istate (Tactic.Rewrite_Set rls) t =
|
walther@59802
|
43 |
let
|
walther@59881
|
44 |
val thy = ThyC.get_theory "Isac_Knowledge"
|
walther@59802
|
45 |
val args = Auto_Prog.gen thy t (assoc_rls rls) |> Program.formal_args
|
walther@59802
|
46 |
in
|
walther@59802
|
47 |
Istate_Def.Pstate (Istate_Def.e_pstate |> Istate_Def.set_env_true [(hd args, t)])
|
walther@59802
|
48 |
end
|
wneuper@59571
|
49 |
| init_istate (Tactic.Rewrite_Set_Inst (subs, rls)) t =
|
wneuper@59266
|
50 |
let
|
walther@59881
|
51 |
val thy = ThyC.get_theory "Isac_Knowledge"
|
walther@59802
|
52 |
val rls' = assoc_rls rls
|
walther@59911
|
53 |
val v = case Subst.T_from_input thy subs of
|
walther@59802
|
54 |
(_, v) :: _ => v (*...we suppose the substitution of only ONE bound variable*)
|
walther@59802
|
55 |
| _ => raise ERROR "init_istate: uncovered case"
|
walther@59802
|
56 |
val prog = Auto_Prog.gen thy t rls'
|
walther@59802
|
57 |
val args = Program.formal_args prog
|
walther@59802
|
58 |
in
|
walther@59802
|
59 |
Istate_Def.Pstate (Istate_Def.e_pstate |> Istate_Def.set_env_true (args ~~ [t, v]))
|
wneuper@59266
|
60 |
end
|
walther@59846
|
61 |
| init_istate tac _ = error ("init_istate: uncovered definition for " ^ Tactic.input_to_string tac)
|
neuper@37906
|
62 |
|
neuper@37906
|
63 |
|
wneuper@59405
|
64 |
datatype pblmet = (*%^%*)
|
wneuper@59405
|
65 |
Upblmet (*undefined*)
|
walther@59903
|
66 |
| Problem of Problem.id (*%^%*)
|
walther@59903
|
67 |
| Method of Method.id; (*%^%*)
|
wneuper@59266
|
68 |
fun pblmet2str (Problem pblID) = "Problem " ^ strs2str pblID (*%^%*)
|
walther@59903
|
69 |
| pblmet2str (Method metID) = "Method " ^ Method.id_to_string metID (*%^%*)
|
wneuper@59266
|
70 |
| pblmet2str x = error ("pblmet2str: uncovered definition " ^ pblmet2str x)
|
neuper@37906
|
71 |
|
neuper@37906
|
72 |
(*3.5.00: TODO: foppFK eliminated in interface FE-KE !!!*)
|
neuper@37906
|
73 |
datatype foppFK = (* in DG cases div 2 *)
|
neuper@37906
|
74 |
EmptyFoppFK (*DG internal*)
|
walther@59865
|
75 |
| FormFK of TermC.as_string
|
walther@59865
|
76 |
| PpcFK of TermC.as_string Model.ppc
|
wneuper@59266
|
77 |
fun foppFK2str (FormFK ct') ="FormFK " ^ ct'
|
wneuper@59316
|
78 |
| foppFK2str (PpcFK ppc) ="PpcFK " ^ Model.ppc2str ppc
|
wneuper@59266
|
79 |
| foppFK2str EmptyFoppFK ="EmptyFoppFK"
|
neuper@37906
|
80 |
|
neuper@37906
|
81 |
datatype nest = Open | Closed | Nundef;
|
neuper@37906
|
82 |
fun nest2str Open = "Open"
|
neuper@37906
|
83 |
| nest2str Closed = "Closed"
|
wneuper@59266
|
84 |
| nest2str Nundef = "Nundef"
|
neuper@37906
|
85 |
|
neuper@37906
|
86 |
type indent = int;
|
neuper@37906
|
87 |
datatype edit = EdUndef | Write | Protect;
|
neuper@37906
|
88 |
(* bridge --> kernel *)
|
neuper@37906
|
89 |
(* bridge <-> kernel *)
|
neuper@37906
|
90 |
(* needed in dialog.sml *) (* bridge <-- kernel *)
|
neuper@37906
|
91 |
fun edit2str EdUndef = "EdUndef"
|
neuper@37906
|
92 |
| edit2str Write = "Write"
|
neuper@37906
|
93 |
| edit2str Protect = "Protect";
|
neuper@37906
|
94 |
|
neuper@42023
|
95 |
datatype inout = (*FIXME.WN1105 drop this: was required for proto0 with dialog in sml*)
|
wneuper@59405
|
96 |
Error_ of string (*<--*)
|
walther@59865
|
97 |
| FormKF of cellID * edit * indent * nest * TermC.as_string (*<--*)
|
wneuper@59316
|
98 |
| PpcKF of cellID * edit * indent * nest * (pblmet * Model.item Model.ppc) (*<--*)
|
wneuper@59405
|
99 |
| RefineKF of Stool.match list (*<--*)
|
walther@59903
|
100 |
| RefinedKF of (Problem.id * ((Model.itm list) * ((bool * term) list))) (*<--*)
|
neuper@37906
|
101 |
|
wneuper@59267
|
102 |
(*
|
wneuper@59267
|
103 |
datatype mout = EmptyMout | Error' of inout | Form' of inout | Problems of inout
|
wneuper@59267
|
104 |
*)
|
neuper@37906
|
105 |
datatype mout =
|
walther@59865
|
106 |
FormKF of TermC.as_string
|
wneuper@59316
|
107 |
| PpcKF of (pblmet * Model.item Model.ppc)
|
walther@59903
|
108 |
| RefinedKF of Problem.id * (Model.itm list * (bool * term) list)
|
wneuper@59267
|
109 |
| Error' of string
|
wneuper@59267
|
110 |
| EmptyMout
|
neuper@37906
|
111 |
|
wneuper@59267
|
112 |
fun mout2str (FormKF cterm') = "FormKF " ^ cterm'
|
wneuper@59316
|
113 |
| mout2str (PpcKF (pm, itemppc)) = "PpcKF (" ^ pblmet2str pm ^ "," ^ Model.itemppc2str itemppc ^ ")"
|
wneuper@59312
|
114 |
| mout2str (RefinedKF (_, _)) = "mout2str: RefinedKF not impl."
|
wneuper@59267
|
115 |
| mout2str (Error' str) = "Error' " ^ str
|
wneuper@59267
|
116 |
| mout2str (EmptyMout ) = "EmptyMout"
|
neuper@37906
|
117 |
|
neuper@37906
|
118 |
(* init pbl with ...,dsc,empty | [] *)
|
neuper@37906
|
119 |
fun init_pbl pbt =
|
wneuper@59266
|
120 |
let
|
walther@59861
|
121 |
fun pbt2itm (f, (d, _)) = (0, [], false, f, Model.Inc ((d, []), (TermC.empty, [])))
|
wneuper@59266
|
122 |
in map pbt2itm pbt end
|
wneuper@59266
|
123 |
|
wneuper@59266
|
124 |
(* take formal parameters from pbt, for transfer from pbl/met-hierarchy *)
|
neuper@37906
|
125 |
fun init_pbl' pbt =
|
neuper@37906
|
126 |
let
|
walther@59861
|
127 |
fun pbt2itm (f, (d, t)) = (0, [], false, f, Model.Inc((d, [t]), (TermC.empty, [])))
|
wneuper@59266
|
128 |
in map pbt2itm pbt end
|
walther@59811
|
129 |
(* generate 1 ppobj in Ctree *)
|
walther@59811
|
130 |
fun generate1 (Tactic.Model_Problem' (_, itms, met)) (_, ctxt) (pt, pos as (p, _)) =
|
walther@59811
|
131 |
let
|
walther@59810
|
132 |
val pt = update_pbl pt p itms
|
walther@59810
|
133 |
val pt = update_met pt p met
|
walther@59810
|
134 |
in
|
walther@59811
|
135 |
(pos, [], PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [] []), pt)
|
walther@59810
|
136 |
end
|
walther@59811
|
137 |
| generate1 (Tactic.Add_Given' (_, itmlist)) (_, ctxt) (pt, pos as (p, p_)) =
|
walther@59811
|
138 |
(pos: pos', [], PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [][]),
|
wneuper@59266
|
139 |
case p_ of
|
wneuper@59266
|
140 |
Pbl => update_pbl pt p itmlist
|
wneuper@59266
|
141 |
| Met => update_met pt p itmlist
|
wneuper@59266
|
142 |
| _ => error ("uncovered case " ^ pos_2str p_))
|
wneuper@59266
|
143 |
(* WN110515 probably declare_constraints with input item (without dsc) --
|
wneuper@59266
|
144 |
-- important when specifying without formalisation *)
|
walther@59811
|
145 |
| generate1 (Tactic.Add_Find' (_, itmlist)) (_, ctxt) (pt, pos as (p, p_)) =
|
walther@59811
|
146 |
(pos, [], (PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [] [])),
|
wneuper@59266
|
147 |
case p_ of
|
wneuper@59266
|
148 |
Pbl => update_pbl pt p itmlist
|
wneuper@59266
|
149 |
| Met => update_met pt p itmlist
|
wneuper@59266
|
150 |
| _ => error ("uncovered case " ^ pos_2str p_))
|
neuper@41994
|
151 |
(*WN110515 probably declare_constraints with input item (without dsc)*)
|
walther@59811
|
152 |
| generate1 (Tactic.Add_Relation' (_, itmlist)) (_, ctxt) (pt, pos as (p, p_)) =
|
walther@59811
|
153 |
(pos, [], PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [] []),
|
wneuper@59266
|
154 |
case p_ of
|
wneuper@59266
|
155 |
Pbl => update_pbl pt p itmlist
|
wneuper@59266
|
156 |
| Met => update_met pt p itmlist
|
wneuper@59266
|
157 |
| _ => error ("uncovered case " ^ pos_2str p_))
|
walther@59811
|
158 |
| generate1 (Tactic.Specify_Theory' domID) (_, ctxt) (pt, pos as (p,_)) =
|
walther@59811
|
159 |
(pos, [] , PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [] []),
|
wneuper@59266
|
160 |
update_domID pt p domID)
|
walther@59811
|
161 |
| generate1 (Tactic.Specify_Problem' (pI, (_, (itms, _)))) (_, ctxt) (pt, (p, _)) =
|
wneuper@59266
|
162 |
let
|
wneuper@59266
|
163 |
val pt = update_pbl pt p itms
|
wneuper@59266
|
164 |
val pt = update_pblID pt p pI
|
wneuper@59266
|
165 |
in
|
walther@59811
|
166 |
((p, Pbl), [], PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [] []), pt)
|
wneuper@59266
|
167 |
end
|
walther@59811
|
168 |
| generate1 (Tactic.Specify_Method' (mID, oris, itms)) (_, ctxt) (pt, (p, _)) =
|
wneuper@59266
|
169 |
let
|
wneuper@59266
|
170 |
val pt = update_oris pt p oris
|
wneuper@59266
|
171 |
val pt = update_met pt p itms
|
wneuper@59266
|
172 |
val pt = update_metID pt p mID
|
wneuper@59266
|
173 |
in
|
walther@59811
|
174 |
((p, Met), [], PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [] []), pt)
|
wneuper@59266
|
175 |
end
|
walther@59811
|
176 |
| generate1 (Tactic.Refine_Tacitly' (_, pIre, domID, metID, pbl)) (_, ctxt) (pt, pos as (p, _)) =
|
wneuper@59266
|
177 |
let
|
wneuper@59266
|
178 |
val pt = update_pbl pt p pbl
|
wneuper@59266
|
179 |
val pt = update_orispec pt p (domID, pIre, metID)
|
wneuper@59266
|
180 |
in
|
walther@59811
|
181 |
(pos, [], PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [] []), pt)
|
wneuper@59266
|
182 |
end
|
walther@59811
|
183 |
| generate1 (Tactic.Refine_Problem' (pI, _)) (_, ctxt) (pt, pos as (p, _)) =
|
wneuper@59266
|
184 |
let
|
wneuper@59266
|
185 |
val (dI, _, mI) = get_obj g_spec pt p
|
wneuper@59266
|
186 |
val pt = update_spec pt p (dI, pI, mI)
|
wneuper@59266
|
187 |
in
|
walther@59811
|
188 |
(pos, [], PpcKF (Upblmet, Specify.itms2itemppc (Proof_Context.theory_of ctxt) [] []), pt)
|
wneuper@59266
|
189 |
end
|
walther@59811
|
190 |
| generate1 (Tactic.Apply_Method' (_, topt, is, _)) (_, ctxt) (pt, pos as (p, _)) =
|
wneuper@59266
|
191 |
(case topt of
|
wneuper@59266
|
192 |
SOME t =>
|
wneuper@59266
|
193 |
let val (pt, c) = cappend_form pt p (is, ctxt) t
|
wneuper@59266
|
194 |
in (pos, c, EmptyMout, pt) end
|
walther@59839
|
195 |
| NONE => (pos, [], EmptyMout, pt))
|
walther@59811
|
196 |
| generate1 (Tactic.Take' t) l (pt, (p, _)) = (* val (Take' t) = m; *)
|
wneuper@59266
|
197 |
let
|
wneuper@59266
|
198 |
val p =
|
wneuper@59266
|
199 |
let val (ps, p') = split_last p (* no connex to prev.ppobj *)
|
wneuper@59266
|
200 |
in if p' = 0 then ps @ [1] else p end
|
wneuper@59266
|
201 |
val (pt, c) = cappend_form pt p l t
|
wneuper@59266
|
202 |
in
|
walther@59868
|
203 |
((p, Frm): pos', c, FormKF (UnparseC.term t), pt)
|
wneuper@59266
|
204 |
end
|
walther@59811
|
205 |
| generate1 (Tactic.Begin_Trans' t) l (pt, (p, Frm)) =
|
wneuper@59266
|
206 |
let
|
wneuper@59266
|
207 |
val (pt, c) = cappend_form pt p l t
|
neuper@37906
|
208 |
val pt = update_branch pt p TransitiveB (*040312*)
|
wneuper@59266
|
209 |
(* replace the old PrfOjb ~~~~~ *)
|
wneuper@59266
|
210 |
val p = (lev_on o lev_dn (* starts with [...,0] *)) p
|
wneuper@59266
|
211 |
val (pt, c') = cappend_form pt p l t (*FIXME.0402 same istate ???*)
|
wneuper@59266
|
212 |
in
|
walther@59868
|
213 |
((p, Frm), c @ c', FormKF (UnparseC.term t), pt)
|
wneuper@59266
|
214 |
end
|
walther@59811
|
215 |
| generate1 (Tactic.Begin_Trans' t) l (pt, (p, Res)) =
|
wneuper@59266
|
216 |
(*append after existing PrfObj vvvvvvvvvvvvv*)
|
walther@59811
|
217 |
generate1 (Tactic.Begin_Trans' t) l (pt, (lev_on p, Frm))
|
walther@59811
|
218 |
| generate1 (Tactic.End_Trans' tasm) l (pt, (p, _)) =
|
wneuper@59266
|
219 |
let
|
wneuper@59266
|
220 |
val p' = lev_up p
|
wneuper@59266
|
221 |
val (pt, c) = append_result pt p' l tasm Complete
|
wneuper@59266
|
222 |
in
|
wneuper@59374
|
223 |
((p', Res), c, FormKF "DUMMY" (*term2str t ..ERROR (t) has not been declared*), pt)
|
wneuper@59266
|
224 |
end
|
walther@59811
|
225 |
| generate1 (Tactic.Rewrite_Inst' (_, _, _, _, subs', thm', f, (f', asm))) (is, ctxt) (pt, (p, _)) =
|
wneuper@59266
|
226 |
let
|
walther@59809
|
227 |
val (pt, c) = cappend_atomic pt p (is, ctxt) f
|
walther@59911
|
228 |
(Tactic.Rewrite_Inst (Subst.T_to_input subs', thm')) (f',asm) Complete;
|
wneuper@59266
|
229 |
val pt = update_branch pt p TransitiveB
|
wneuper@59267
|
230 |
in
|
walther@59868
|
231 |
((p, Res), c, FormKF (UnparseC.term f'), pt)
|
wneuper@59267
|
232 |
end
|
walther@59811
|
233 |
| generate1 (Tactic.Rewrite' (_, _, _, _, thm', f, (f', asm))) (is, ctxt) (pt, (p, _)) =
|
wneuper@59266
|
234 |
let
|
walther@59813
|
235 |
val (pt, c) = cappend_atomic pt p (is, ctxt) f (Tactic.Rewrite thm') (f', asm) Complete
|
wneuper@59266
|
236 |
val pt = update_branch pt p TransitiveB
|
wneuper@59266
|
237 |
in
|
walther@59868
|
238 |
((p, Res), c, FormKF (UnparseC.term f'), pt)
|
wneuper@59266
|
239 |
end
|
walther@59811
|
240 |
| generate1 (Tactic.Rewrite_Set_Inst' (_, _, subs', rls', f, (f', asm))) (is, ctxt) (pt, (p, _)) =
|
wneuper@59266
|
241 |
let
|
walther@59828
|
242 |
val (pt, c) = cappend_atomic pt p (is, ctxt) f
|
walther@59911
|
243 |
(Tactic.Rewrite_Set_Inst (Subst.T_to_input subs', Rule_Set.id rls')) (f', asm) Complete
|
wneuper@59266
|
244 |
val pt = update_branch pt p TransitiveB
|
wneuper@59266
|
245 |
in
|
walther@59868
|
246 |
((p, Res), c, FormKF (UnparseC.term f'), pt)
|
wneuper@59266
|
247 |
end
|
walther@59811
|
248 |
| generate1 (Tactic.Rewrite_Set' (_, _, rls', f, (f', asm))) (is, ctxt) (pt, (p, _)) =
|
wneuper@59266
|
249 |
let
|
walther@59828
|
250 |
val (pt, c) = cappend_atomic pt p (is, ctxt) f
|
walther@59867
|
251 |
(Tactic.Rewrite_Set (Rule_Set.id rls')) (f', asm) Complete
|
wneuper@59266
|
252 |
val pt = update_branch pt p TransitiveB
|
wneuper@59266
|
253 |
in
|
walther@59868
|
254 |
((p, Res), c, FormKF (UnparseC.term f'), pt)
|
wneuper@59266
|
255 |
end
|
walther@59843
|
256 |
| generate1 (Tactic.Check_Postcond' (_, scval)) l (pt, (p, _)) =
|
neuper@42394
|
257 |
let
|
walther@59843
|
258 |
val (pt, c) = append_result pt p l (scval, []) Complete
|
wneuper@59266
|
259 |
in
|
walther@59868
|
260 |
((p, Res), c, FormKF (UnparseC.term scval), pt)
|
wneuper@59266
|
261 |
end
|
walther@59811
|
262 |
| generate1 (Tactic.Calculate' (_, op_, f, (f', _))) l (pt, (p, _)) =
|
neuper@42394
|
263 |
let
|
wneuper@59571
|
264 |
val (pt,c) = cappend_atomic pt p l f (Tactic.Calculate op_) (f', []) Complete
|
wneuper@59266
|
265 |
in
|
walther@59868
|
266 |
((p, Res), c, FormKF (UnparseC.term f'), pt)
|
wneuper@59266
|
267 |
end
|
walther@59811
|
268 |
| generate1 (Tactic.Check_elementwise' (consts, pred, (f', asm))) l (pt, (p, _)) =
|
neuper@42394
|
269 |
let
|
wneuper@59571
|
270 |
val (pt,c) = cappend_atomic pt p l consts (Tactic.Check_elementwise pred) (f', asm) Complete
|
wneuper@59266
|
271 |
in
|
walther@59868
|
272 |
((p, Res), c, FormKF (UnparseC.term f'), pt)
|
wneuper@59266
|
273 |
end
|
walther@59811
|
274 |
| generate1 (Tactic.Or_to_List' (ors, list)) l (pt, (p, _)) =
|
neuper@42394
|
275 |
let
|
wneuper@59571
|
276 |
val (pt,c) = cappend_atomic pt p l ors Tactic.Or_to_List (list, []) Complete
|
wneuper@59266
|
277 |
in
|
walther@59868
|
278 |
((p, Res), c, FormKF (UnparseC.term list), pt)
|
wneuper@59266
|
279 |
end
|
walther@59811
|
280 |
| generate1 (Tactic.Substitute' (_, _, subte, t, t')) l (pt, (p, _)) =
|
neuper@41983
|
281 |
let
|
neuper@41983
|
282 |
val (pt,c) =
|
walther@59912
|
283 |
cappend_atomic pt p l t (Tactic.Substitute (Subst.eqs_to_input subte)) (t',[]) Complete
|
walther@59868
|
284 |
in ((p, Res), c, FormKF (UnparseC.term t'), pt)
|
wneuper@59266
|
285 |
end
|
walther@59811
|
286 |
| generate1 (Tactic.Tac_ (_, f, id, f')) l (pt, (p, _)) =
|
neuper@42394
|
287 |
let
|
wneuper@59571
|
288 |
val (pt, c) = cappend_atomic pt p l (TermC.str2term f) (Tactic.Tac id) (TermC.str2term f', []) Complete
|
wneuper@59266
|
289 |
in
|
wneuper@59267
|
290 |
((p,Res), c, FormKF f', pt)
|
wneuper@59266
|
291 |
end
|
walther@59819
|
292 |
| generate1 (Tactic.Subproblem' ((domID, pblID, metID), oris, hdl, fmz_, ctxt_specify, f))
|
walther@59810
|
293 |
(l as (_, ctxt)) (pt, (p, _)) =
|
wneuper@59266
|
294 |
let
|
walther@59819
|
295 |
val (pt, c) = cappend_problem pt p l (fmz_, (domID, pblID, metID))
|
walther@59819
|
296 |
(oris, (domID, pblID, metID), hdl, ctxt_specify)
|
walther@59879
|
297 |
val f = Syntax.string_of_term (ThyC.to_ctxt (Proof_Context.theory_of ctxt)) f
|
wneuper@59266
|
298 |
in
|
wneuper@59267
|
299 |
((p, Pbl), c, FormKF f, pt)
|
wneuper@59266
|
300 |
end
|
walther@59811
|
301 |
| generate1 m' _ _ = error ("generate1: not impl.for " ^ Tactic.string_of m')
|
bonzai@41951
|
302 |
|
neuper@42437
|
303 |
fun generate_inconsistent_rew (subs_opt, thm') f' (is, ctxt) (pos as (p,_)) pt =
|
neuper@42434
|
304 |
let
|
wneuper@59266
|
305 |
val f = get_curr_formula (pt, pos)
|
wneuper@59266
|
306 |
val pos' as (p', _) = (lev_on p, Res)
|
wneuper@59266
|
307 |
val (pt, _) = case subs_opt of
|
walther@59828
|
308 |
NONE => cappend_atomic pt p' (is, ctxt) f
|
wneuper@59571
|
309 |
(Tactic.Rewrite thm') (f', []) Inconsistent
|
walther@59828
|
310 |
| SOME subs => cappend_atomic pt p' (is, ctxt) f
|
wneuper@59571
|
311 |
(Tactic.Rewrite_Inst (subs, thm')) (f', []) Inconsistent
|
wneuper@59266
|
312 |
val pt = update_branch pt p' TransitiveB
|
neuper@42437
|
313 |
in (pt, pos') end
|
neuper@42432
|
314 |
|
walther@59828
|
315 |
fun generate_hard _(*thy*) m' (p,p_) pt =
|
neuper@37906
|
316 |
let
|
wneuper@59266
|
317 |
val p = case p_ of
|
wneuper@59266
|
318 |
Frm => p | Res => lev_on p
|
wneuper@59266
|
319 |
| _ => error ("generate_hard: call by " ^ pos'2str (p,p_))
|
walther@59810
|
320 |
in
|
walther@59846
|
321 |
generate1 m' (Istate_Def.empty, ContextC.empty) (pt, (p, p_))
|
walther@59810
|
322 |
end
|
neuper@37906
|
323 |
|
walther@59760
|
324 |
(* tacis are in reverse order from do_next/specify_: last = fst to insert *)
|
walther@59908
|
325 |
fun generate ([]: State_Steps.T) ptp = ptp
|
walther@59813
|
326 |
| generate tacis (pt, c, _: pos'(*!dropped!WN0504redesign generate/tacis?*)) =
|
wneuper@59266
|
327 |
let
|
wneuper@59266
|
328 |
val (tacis', (_, tac_, (p, is))) = split_last tacis
|
walther@59813
|
329 |
val (p',c',_,pt') = generate1 tac_ is (pt, p)
|
wneuper@59266
|
330 |
in
|
wneuper@59266
|
331 |
generate tacis' (pt', c@c', p')
|
wneuper@59266
|
332 |
end
|
neuper@37906
|
333 |
|
wneuper@59266
|
334 |
(* embed the tacis created by a '_deriv'ation; sys.form <> input.form
|
wneuper@59266
|
335 |
tacis are in order, thus are reverted for generate *)
|
walther@59813
|
336 |
fun embed_deriv tacis (pt, pos as (p, Frm)) =
|
neuper@37906
|
337 |
(*inform at Frm: replace the whole PrfObj by a Transitive-ProfObj FIXME?0402
|
neuper@37906
|
338 |
and transfer the istate (from _after_ compare_deriv) from Frm to Res*)
|
wneuper@59266
|
339 |
let
|
walther@59908
|
340 |
val (res, asm) = (State_Steps.result o last_elem) tacis
|
wneuper@59266
|
341 |
val (ist, ctxt) = case get_obj g_loc pt p of
|
wneuper@59266
|
342 |
(SOME (ist, ctxt), _) => (ist, ctxt)
|
wneuper@59266
|
343 |
| (NONE, _) => error "embed_deriv Frm: uncovered case get_obj"
|
wneuper@59266
|
344 |
val form = get_obj g_form pt p
|
walther@59813
|
345 |
(*val p = lev_on p; ---------------only difference to (..,Res) below*)
|
walther@59737
|
346 |
val tacis = (Tactic.Begin_Trans, Tactic.Begin_Trans' form, (pos, (Istate_Def.Uistate, ctxt))) ::
|
walther@59908
|
347 |
(State_Steps.insert_pos ((lev_on o lev_dn) p) tacis) @ [(Tactic.End_Trans, Tactic.End_Trans' (res, asm),
|
wneuper@59266
|
348 |
(pos_plus (length tacis) (lev_dn p, Res), (new_val res ist, ctxt)))]
|
wneuper@59269
|
349 |
val {nrls, ...} = Specify.get_met (get_obj g_metID pt (par_pblobj pt p))
|
wneuper@59266
|
350 |
val (pt, c, pos as (p, _)) = generate (rev tacis) (pt, [], (p, Res))
|
walther@59867
|
351 |
val pt = update_tac pt p (Tactic.Derive (Rule_Set.id nrls))
|
wneuper@59266
|
352 |
val pt = update_branch pt p TransitiveB
|
wneuper@59266
|
353 |
in (c, (pt, pos: pos')) end
|
wneuper@59266
|
354 |
| embed_deriv tacis (pt, (p, Res)) =
|
wneuper@59266
|
355 |
(*inform at Res: append a Transitive-PrfObj FIXME?0402 other branch-types ?
|
wneuper@59266
|
356 |
and transfer the istate (from _after_ compare_deriv) from Res to new Res*)
|
walther@59908
|
357 |
let val (res, asm) = (State_Steps.result o last_elem) tacis
|
wneuper@59266
|
358 |
val (ist, ctxt) = case get_obj g_loc pt p of
|
wneuper@59266
|
359 |
(_, SOME (ist, ctxt)) => (ist, ctxt)
|
wneuper@59266
|
360 |
| (_, NONE) => error "embed_deriv Frm: uncovered case get_obj"
|
wneuper@59266
|
361 |
val (f, _) = get_obj g_result pt p
|
wneuper@59266
|
362 |
val p = lev_on p(*---------------only difference to (..,Frm) above*);
|
walther@59737
|
363 |
val tacis = (Tactic.Begin_Trans, Tactic.Begin_Trans' f, ((p, Frm), (Istate_Def.Uistate, ctxt))) ::
|
walther@59908
|
364 |
(State_Steps.insert_pos ((lev_on o lev_dn) p) tacis) @ [(Tactic.End_Trans, Tactic.End_Trans' (res, asm),
|
wneuper@59266
|
365 |
(pos_plus (length tacis) (lev_dn p, Res), (new_val res ist, ctxt)))];
|
wneuper@59269
|
366 |
val {nrls, ...} = Specify.get_met (get_obj g_metID pt (par_pblobj pt p))
|
wneuper@59266
|
367 |
val (pt, c, pos as (p, _)) = generate (rev tacis) (pt, [], (p, Res))
|
walther@59867
|
368 |
val pt = update_tac pt p (Tactic.Derive (Rule_Set.id nrls))
|
wneuper@59266
|
369 |
val pt = update_branch pt p TransitiveB
|
wneuper@59266
|
370 |
in (c, (pt, pos)) end
|
wneuper@59266
|
371 |
| embed_deriv _ _ = error "embed_deriv: uncovered definition"
|
wneuper@59266
|
372 |
end |