1 (* Title: TODO/state-step.sml
3 (c) due to copyright terms
5 Deprecated; the idea was to hold steps complete such, that they can be replayed.
8 signature STATE_STEPS =
11 val single_empty : single
13 val to_string : T -> string
14 val result : single -> (term * term list)
15 val make_single: Rewrite_Ord.rew_ord' * 'a -> Rule_Set.T -> term * Rule.rule * (term * term list) ->
16 Tactic.input * Tactic.T * (Pos.pos' * (Istate_Def.T * Proof.context))
17 val insert_pos : Pos.pos -> T -> T
18 (* ---- for tests only: shifted from below to remove the Warning "unused" at fun.def. --------- *)
20 (*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
22 ( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
26 structure State_Steps(**): STATE_STEPS(**) =
30 (*/------- to State_Steps from Generate -------\*)
31 (* a single holds alle information required to build a node in the calc-tree;
32 a single is assumed to be used efficiently such that the calc-tree
33 resulting from applying a single need not be stored separately;
34 see "type calcstate" *)
35 (*TODO.WN0504 redesign ??? or redesign generate ?? see "fun generate"
36 TODO.WN0512 ? redesign this _list_:
37 # only used for [Apply_Method + (Take or Subproblem)], i.e. for initacs
38 # the latter problem may be resolved automatically if "fun autocalc" is
39 not any more used for the specify-phase and for changing the phases*)
41 (Tactic.input * (* for comparison with input tac *)
42 Tactic.T * (* for ctree generation *)
43 (Pos.pos' * (* after applying tac_, for ctree generation *)
44 (Istate_Def.T * Proof.context))) (* after applying tac_, for ctree generation *)
45 val single_empty = (Tactic.Empty_Tac, Tactic.Empty_Tac_, (Pos.e_pos', (Istate_Def.empty, ContextC.empty))): single
46 fun taci2str ((tac, tac_, (pos', (istate, _))):single) =
47 "( " ^ Tactic.input_to_string tac ^ ", " ^ Tactic.string_of tac_ ^ ", ( " ^ Pos.pos'2str pos' ^ ", " ^
48 Istate_Def.string_of istate ^ " ))"
52 fun to_string tacis = (strs2str o (map (linefeed o taci2str))) tacis
53 fun result (_, Tactic.Rewrite' (_, _, _, _, _, _,(res, asm)), _) = (res, asm)
54 | result (_, Tactic.Rewrite_Set' (_, _, _, _, (res, asm)), _) = (res, asm)
55 | result (_, tac_, _) = error ("result: called with" ^ Tactic.string_of tac_)
56 (*\------- to State_Steps from Generate -------/*)
57 (*/------- to State_Steps from Error_Pattern -------\*)
58 fun make_single ro erls (t, r as Rule.Thm (id, thm), (t', a)) =
59 (Tactic.Rewrite (id, thm),
60 Tactic.Rewrite' ("Isac_Knowledge", fst ro, erls, false, ThmC.from_rule r, t, (t', a)),
61 (Pos.e_pos'(*to be updated before generate tacis!!!*), (Istate_Def.Uistate, ContextC.empty)))
62 | make_single _ _ (t, r as Rule.Rls_ rls, (t', a)) =
63 (Tactic.Rewrite_Set (Rule_Set.id_from_rule r),
64 Tactic.Rewrite_Set' ("Isac_Knowledge", false, rls, t, (t', a)),
65 (Pos.e_pos'(*to be updated before generate tacis!!!*), (Istate_Def.Uistate, ContextC.empty)))
66 | make_single _ _ (t, r, _) = error ("make_single: not impl. for " ^ Rule.to_string r ^ " at " ^ UnparseC.term t)
67 (*\------- to State_Steps from Error_Pattern -------/*)
69 (* update pos in tacis for embedding by generate *)
70 fun insert_pos (_: Pos.pos) [] = []
71 | insert_pos (p: Pos.pos) (((tac, tac_, (_, ist)): single) :: tacis) =
72 ((tac, tac_, ((p, Pos.Res), ist)): single) :: (insert_pos (Pos.lev_on p) tacis)