src/Tools/isac/Specify/step-specify.sml
author Walther Neuper <walther.neuper@jku.at>
Fri, 22 Jan 2021 16:03:15 +0100
changeset 60150 5973d6c80f7d
parent 60114 307fe00bbfc9
child 60154 2ab0d1523731
permissions -rw-r--r--
step 5.5: for devel. make test-example independent from session Isac

note: see "HACKthy"
walther@59747
     1
(* Title:  Specify/step-specify.sml
walther@59747
     2
   Author: Walther Neuper 2019
walther@59747
     3
   (c) due to copyright terms
walther@59747
     4
*)
walther@59747
     5
walther@59747
     6
signature STEP_SPECIFY =
walther@59747
     7
sig
walther@59791
     8
(*val do_next: Step.specify_do_next requires LI.by_tactic, which is not yet known in Step_Specify*)
walther@60020
     9
  val by_tactic_input: Tactic.input -> Calc.T -> string * Calc.state_post
walther@59981
    10
  val by_tactic: Tactic.T -> Calc.T -> string * Calc.state_post
walther@59975
    11
walther@60150
    12
  val initialisePIDEHACK: theory -> Formalise.T ->
walther@60150
    13
    term * term * References.T * O_Model.T * Proof.context
walther@60113
    14
  val initialisePIDE: Formalise.T ->
walther@60114
    15
    term * term * References.T * O_Model.T * Proof.context
walther@59946
    16
  val nxt_specify_init_calc: Formalise.T -> Calc.T * State_Steps.T
walther@59886
    17
(*/-------------------------------------------------------- ! aktivate for Test_Isac BEGIN ---\* )
walther@60020
    18
  (*NONE*)
walther@59886
    19
( *\--- ! aktivate for Test_Isac END ----------------------------------------------------------/*)
walther@59747
    20
walther@59747
    21
end
walther@59747
    22
walther@59747
    23
(**)
walther@59747
    24
structure Step_Specify(**): STEP_SPECIFY(**) =
walther@59747
    25
struct
walther@59747
    26
(**)
walther@59763
    27
open Pos
walther@59763
    28
open Ctree
walther@59977
    29
open Specification
walther@59747
    30
walther@59806
    31
fun by_tactic_input (tac as Tactic.Model_Problem) (pt, pos as (p, _)) =
walther@59763
    32
    let
walther@59763
    33
      val (oris, ospec, probl, spec, ctxt) = case get_obj I pt p of
walther@59763
    34
        PblObj {origin = (oris, ospec, _), probl, spec, ctxt, ...} => (oris, ospec, probl, spec, ctxt)
walther@59962
    35
      | _ => raise ERROR "by_tactic_input Model_Problem; uncovered case get_obj"
walther@59995
    36
      val (_, pI, mI) = References.select ospec spec
walther@59988
    37
      val mpc = (#ppc o Method.from_store) mI (* just for reuse I_Model.complete_method *)
walther@59970
    38
      val {cas, ppc, ...} = Problem.from_store pI
walther@59958
    39
      val pbl = I_Model.init ppc (* fill in descriptions *)
walther@59763
    40
      (*----------------if you think, this should be done by the Dialog 
walther@59763
    41
       in the java front-end, search there for WN060225-modelProblem----*)
walther@59763
    42
      val (pbl, met) = case cas of
walther@59763
    43
        NONE => (pbl, [])
walther@59988
    44
  		| _ => I_Model.complete_method (oris, mpc, ppc, probl)
walther@59763
    45
      (*----------------------------------------------------------------*)
walther@59763
    46
      val tac_ = Tactic.Model_Problem' (pI, pbl, met)
walther@59933
    47
      val (pos,c,_,pt) = Specify_Step.add tac_ (Istate_Def.Uistate, ctxt) (pt, pos)
walther@60020
    48
    in
walther@60020
    49
      ("ok",([(tac, tac_, (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos)))
walther@60020
    50
    end
walther@60021
    51
  | by_tactic_input (Tactic.Add_Given ct) ptp = Specify.by_Add_ "#Given" ct ptp
walther@60021
    52
  | by_tactic_input (Tactic.Add_Find  ct) ptp = Specify.by_Add_ "#Find"  ct ptp
walther@60021
    53
  | by_tactic_input (Tactic.Add_Relation ct) ptp = Specify.by_Add_"#Relate" ct ptp
walther@60021
    54
walther@60020
    55
    (* called with Method.id_empty *)     
walther@59810
    56
  | by_tactic_input (Tactic.Refine_Tacitly pI) (ptp as (pt, pos as (p, _))) =
walther@59763
    57
    let 
walther@59763
    58
      val (oris, dI, ctxt) = case get_obj I pt p of
walther@59763
    59
        (PblObj {origin = (oris, (dI, _, _), _), ctxt, ...}) => (oris, dI, ctxt)
walther@59962
    60
      | _ => raise ERROR "by_tactic_input Refine_Tacitly: uncovered case get_obj"
walther@59968
    61
      val opt = Refine.refine_ori oris pI
walther@59763
    62
    in 
walther@59763
    63
      case opt of
walther@59763
    64
	      SOME pI' => 
walther@59763
    65
	        let 
walther@59970
    66
            val {met, ...} = Problem.from_store pI'
walther@59763
    67
	          (*val pt = update_pbl pt p pbl ..done by Model_Problem*)
walther@59903
    68
	          val mI = if length met = 0 then Method.id_empty else hd met
walther@59763
    69
	          val (pos, c, _, pt) = 
walther@59933
    70
		          Specify_Step.add (Tactic.Refine_Tacitly' (pI, pI', dI, mI,(*pbl*)[])) (Istate_Def.Uistate, ctxt) (pt, pos)
walther@59763
    71
	        in
walther@60020
    72
	          ("ok", ([(Tactic.Refine_Tacitly pI, Tactic.Refine_Tacitly' (pI,pI',dI,mI,(*pbl*)[]),
walther@60020
    73
	              (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos)))
walther@59763
    74
          end
walther@60021
    75
	    | NONE => ("failure", ([], [], ptp))
walther@59763
    76
    end
walther@59806
    77
  | by_tactic_input (Tactic.Refine_Problem pI) (ptp as (pt, pos as (p,_))) =
walther@59763
    78
    let
walther@59763
    79
      val (dI, dI', probl, ctxt) = case get_obj I pt p of
walther@59763
    80
        PblObj {origin= (_, (dI, _, _), _), spec = (dI', _, _), probl, ctxt, ...} =>
walther@59763
    81
          (dI, dI', probl, ctxt)
walther@59962
    82
      | _ => raise ERROR "by_tactic_input Refine_Problem: uncovered case get_obj"
walther@59879
    83
	    val thy = if dI' = ThyC.id_empty then dI else dI'
walther@59763
    84
    in 
walther@59960
    85
      case Refine.problem (ThyC.get_theory thy) pI probl of
walther@60021
    86
	      NONE => ("failure", ([], [], ptp))
walther@59763
    87
	    | SOME rfd => 
walther@59763
    88
	      let 
walther@59933
    89
          val (pos,c,_,pt) = Specify_Step.add (Tactic.Refine_Problem' rfd) (Istate_Def.Uistate, ctxt) (pt, pos)
walther@59763
    90
	      in
walther@60020
    91
	        ("ok", ([(Tactic.Refine_Problem pI, Tactic.Refine_Problem' rfd,
walther@60020
    92
            (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt,pos)))
walther@59763
    93
        end
walther@59763
    94
    end
walther@60020
    95
  | by_tactic_input (Tactic.Specify_Problem pI) (pt, pos as (p, _)) =
walther@59763
    96
    let
walther@59763
    97
      val (oris, dI, dI', pI', probl, ctxt) = case get_obj I pt p of
walther@59763
    98
        PblObj {origin = (oris, (dI,_,_),_), spec = (dI',pI',_), probl, ctxt, ...} =>
walther@59763
    99
          (oris, dI, dI', pI', probl, ctxt)
walther@59962
   100
      | _ => raise ERROR ""
walther@59881
   101
	    val thy = ThyC.get_theory (if dI' = ThyC.id_empty then dI else dI');
walther@59970
   102
      val {ppc,where_,prls,...} = Problem.from_store pI
walther@59763
   103
	    val pbl = 
walther@59903
   104
	      if pI' = Problem.id_empty andalso pI = Problem.id_empty
walther@59958
   105
	      then (false, (I_Model.init ppc, []))
walther@59984
   106
	      else M_Match.match_itms_oris thy probl (ppc,where_,prls) oris
walther@59763
   107
	      (*FIXXXME~~~~~~~~~~~~~~~: take pbl and compare with new pI WN.8.03*)
walther@59810
   108
	    val (c, pt) =
walther@59933
   109
	      case Specify_Step.add (Tactic.Specify_Problem' (pI, pbl)) (Istate_Def.Uistate, ctxt) (pt, pos) of
walther@59810
   110
  	      ((_, Pbl), c, _, pt) => (c, pt)
walther@59962
   111
  	    | _ => raise ERROR ""
walther@59763
   112
    in
walther@60020
   113
      ("ok", ([(Tactic.Specify_Problem pI, Tactic.Specify_Problem' (pI, pbl),
walther@60020
   114
        (pos, (Istate_Def.Uistate, ContextC.empty)))], c, (pt, pos)))
walther@59763
   115
    end
walther@60014
   116
  | by_tactic_input (Tactic.Specify_Method id) (pt, pos) =
walther@59763
   117
    let
walther@60014
   118
      val (o_model, ctxt, i_model) = Specify_Step.complete_for id (pt, pos)
walther@60014
   119
      val (pos, _, _, pt) = Specify_Step.add (Tactic.Specify_Method' (id, o_model, i_model))
walther@60014
   120
        (Istate_Def.Uistate, ctxt) (pt, pos)
walther@60011
   121
    in
walther@60020
   122
      ("ok", ([(Tactic.Specify_Method id, Tactic.Specify_Method' (id, o_model, i_model),
walther@60020
   123
        (pos, (Istate_Def.Uistate, ContextC.empty)))], [], (pt, pos)))
walther@59763
   124
    end    
walther@59806
   125
  | by_tactic_input (Tactic.Specify_Theory dI) (pt, pos as (_, Pbl)) =
walther@59763
   126
    let
walther@59763
   127
      val ctxt = get_ctxt pt pos
walther@60014
   128
	    val (pos, c, _, pt) =            
walther@59933
   129
	      Specify_Step.add (Tactic.Specify_Theory' dI)  (Istate_Def.Uistate, ctxt) (pt, pos)
walther@59763
   130
    in (*FIXXXME: check if pbl can still be parsed*)
walther@60020
   131
	    ("ok", ([(Tactic.Specify_Theory dI, Tactic.Specify_Theory' dI,
walther@60020
   132
        (pos, (Istate_Def.Uistate, ctxt)))], c, (pt, pos)))
walther@59763
   133
    end
walther@59806
   134
  | by_tactic_input (Tactic.Specify_Theory dI) (pt, pos as (_, Met)) =
walther@59763
   135
    let
walther@59763
   136
      val ctxt = get_ctxt pt pos
walther@59933
   137
	    val (pos, c, _, pt) = Specify_Step.add (Tactic.Specify_Theory' dI) (Istate_Def.Uistate, ctxt) (pt, pos)
walther@59763
   138
    in  (*FIXXXME: check if met can still be parsed*)
walther@60020
   139
	    ("ok", ([(Tactic.Specify_Theory dI, Tactic.Specify_Theory' dI,
walther@60020
   140
        (pos, (Istate_Def.Uistate, ctxt)))], c, (pt, pos)))
walther@59763
   141
    end
walther@59962
   142
  | by_tactic_input m' _ = raise ERROR ("by_tactic_input: not impl. for " ^ Tactic.input_to_string m')
walther@60020
   143
(**)
walther@60020
   144
walther@59806
   145
walther@60015
   146
fun by_tactic (Tactic.Model_Problem' (id, pbl, met)) (pt, pos)  =
walther@59806
   147
    let 
walther@60015
   148
      val ((p, _), _, _, pt) = Specify_Step.add (Tactic.Model_Problem'(id, pbl, met))
walther@60015
   149
        (Istate_Def.Uistate, ContextC.empty) (pt, pos)
walther@60015
   150
(* deprecated^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *)
walther@59806
   151
    in
walther@59806
   152
      ("ok", ([], [], (pt, (p, Pbl))))
walther@59806
   153
    end
walther@59806
   154
    (* called only if no_met is specified *)     
walther@59806
   155
  | by_tactic (Tactic.Refine_Tacitly' (pI, pIre, _, _, _)) (pt, pos) =
walther@59806
   156
      let
walther@59970
   157
        val {met, thy,...} = Problem.from_store pIre
walther@59903
   158
        val (domID, metID) = (Context.theory_name thy, if length met = 0 then Method.id_empty else hd met)
walther@59806
   159
        val ((p,_), _, _, pt) = 
walther@59933
   160
	        Specify_Step.add (Tactic.Refine_Tacitly' (pI, pIre, domID, metID, [(*pbl*)]))
walther@59846
   161
            (Istate_Def.Uistate, ContextC.empty) (pt, pos)
walther@59806
   162
(* deprecated^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *)
walther@59806
   163
      in 
walther@59806
   164
        ("ok", ([], [], (pt,(p, Pbl))))
walther@59806
   165
      end
walther@60021
   166
  | by_tactic (Tactic.Refine_Problem' (rfd as (id, _))) (pt, pos)  =
walther@59806
   167
      let
walther@59806
   168
        val ctxt = get_ctxt pt pos
walther@59806
   169
        val (pos, _, _, pt) =
walther@59933
   170
          Specify_Step.add (Tactic.Refine_Problem' rfd) (Istate_Def.Uistate, ctxt) (pt, pos)
walther@59806
   171
      in
walther@60021
   172
        ("ok", ([(Tactic.Refine_Problem id, Tactic.Refine_Problem' rfd,
walther@60021
   173
            (pos, (Istate_Def.Uistate,ctxt)))], [], (pt, pos)))
walther@59806
   174
      end
walther@59810
   175
  | by_tactic (Tactic.Specify_Problem' (pI, (ok, (itms, pre)))) (pt, pos as (p, _)) =
walther@59806
   176
      let
walther@59995
   177
        val (_, _, _, _, _, _, ctxt, _) = case get_obj I pt p of
walther@59806
   178
          PblObj {origin= (oris, (dI', pI', mI'), _), spec= (dI, _, mI), ctxt, meth = met, ...} =>
walther@59806
   179
            (oris, dI', pI', mI', dI, mI, ctxt, met)
walther@59962
   180
        | _ => raise ERROR "Step_Solve.by_tactic (Specify_Problem': uncovered case get_obj"
walther@59806
   181
        val (p, pt) =
walther@59933
   182
          case  Specify_Step.add (Tactic.Specify_Problem' (pI, (ok, (itms, pre)))) (Istate_Def.Uistate, ctxt) (pt, pos) of
walther@59806
   183
            ((p, Pbl), _, _, pt) => (p, pt)
walther@59962
   184
          | _ => raise ERROR "Step_Solve.by_tactic (Specify_Problem': uncovered case generate1 (WARNING WHY ?)"
walther@59806
   185
      in
walther@59806
   186
        ("ok", ([], [], (pt, (p, Pbl))))
walther@59806
   187
      end    
walther@60014
   188
  | by_tactic (Tactic.Specify_Method' (id, _, _)) (pt, pos) =
walther@59806
   189
      let
walther@60014
   190
        val (o_model, ctxt, i_model) = Specify_Step.complete_for id (pt, pos)
walther@60014
   191
        val (pos, _, _, pt) = Specify_Step.add (Tactic.Specify_Method' (id, o_model, i_model))
walther@60014
   192
          (Istate_Def.Uistate, ctxt) (pt, pos)
walther@60011
   193
      in
walther@59806
   194
        ("ok", ([], [], (pt, pos)))
walther@60014
   195
      end
walther@60016
   196
  | by_tactic (Tactic.Add_Given' (ct, _)) (pt, p)  = Specify.by_Add_ "#Given" ct (pt, p)
walther@60016
   197
  | by_tactic (Tactic.Add_Find'  (ct, _)) (pt, p) = Specify.by_Add_ "#Find" ct (pt, p)
walther@60016
   198
  | by_tactic (Tactic.Add_Relation' (ct, _)) (pt, p) = Specify.by_Add_"#Relate" ct (pt, p)
walther@60020
   199
    (*strange old code, redes*)
walther@60015
   200
  | by_tactic (Tactic.Specify_Theory' domID) (pt, (p, p_)) =
walther@59806
   201
      let
walther@59806
   202
        val p_ = case p_ of Met => Met | _ => Pbl
walther@60015
   203
        val {spec = (dI, _, _), ctxt, ...} = Calc.specify_data (pt, (p, p_))
walther@59806
   204
      in
walther@60015
   205
        if domID = dI then
walther@60015
   206
          ("ok", ([], [], (pt, (p, p_))))
walther@59806
   207
        else (*FIXME: check ppc wrt. (new!) domID ..? still parsable?*)
walther@59806
   208
	        let 
walther@60015
   209
	          val ((p, p_), _, _, pt) = Specify_Step.add (Tactic.Specify_Theory' domID)
walther@60015
   210
	            (Istate_Def.Uistate, ctxt) (pt, (p, p_))
walther@59806
   211
	        in
walther@59806
   212
            ("ok", ([], [], (pt, (p, p_))))
walther@59990
   213
          end                
walther@59806
   214
      end
walther@59806
   215
  | by_tactic _ _ = raise ERROR "Step_Specify.by_tactic uncovered pattern in fun.def"
walther@59806
   216
walther@60150
   217
fun initialisePIDEHACK HACKthy (fmz, (dI, pI, mI)) = 
walther@60150
   218
    let
walther@60150
   219
(**)  val thy = HACKthy(**)
walther@60150
   220
(** )  val thy = ThyC.get_theory dI( **)
walther@60150
   221
	    val (pI, (pors, pctxt), mI) = 
walther@60150
   222
	      if mI = ["no_met"] 
walther@60150
   223
	      then 
walther@60150
   224
          let 
walther@60150
   225
            val pors = Problem.from_store pI |> #ppc |> O_Model.init fmz thy; (*..TermC.parseNEW'*)
walther@60150
   226
            val pctxt = ContextC.initialise' thy fmz;                (*..DUPLICATE ermC.parseNEW'*)
walther@60150
   227
		        val pI' = Refine.refine_ori' pors pI;
walther@60150
   228
		      in (pI', (pors (*refinement over models with diff.precond only*), pctxt),
walther@60150
   229
		        (hd o #met o Problem.from_store) pI')
walther@60150
   230
		      end
walther@60150
   231
	      else
walther@60150
   232
	        let
walther@60150
   233
	          val pors = Problem.from_store pI |> #ppc |> O_Model.init fmz thy; (*..TermC.parseNEW'*)
walther@60150
   234
            val pctxt = ContextC.initialise' thy fmz;                (*..DUPLICATE ermC.parseNEW'*)
walther@60150
   235
	        in (pI, (pors, pctxt), mI) end;
walther@60150
   236
	    val {cas, ppc, thy = thy', ...} = Problem.from_store pI (*take dI from _refined_ pbl*)
walther@60150
   237
	    val dI = Context.theory_name (ThyC.sub_common (thy, thy'))
walther@60150
   238
	    val hdl = case cas of
walther@60150
   239
		    NONE => Auto_Prog.pblterm dI pI
walther@60150
   240
		  | SOME t => subst_atomic ((Model_Pattern.variables ppc) ~~~ O_Model.values pors) t
walther@60150
   241
	    val hdlPIDE = case cas of
walther@60150
   242
		    NONE => Auto_Prog.pbltermPIDE dI pI
walther@60150
   243
		  | SOME t => subst_atomic ((Model_Pattern.variables ppc) ~~~ O_Model.values pors) t
walther@60150
   244
    in
walther@60150
   245
      (hdlPIDE, hdl, (dI, pI, mI), pors, pctxt)
walther@60150
   246
    end;
walther@59806
   247
(* create a calc-tree with oris via an cas.refined pbl *)
walther@60111
   248
(*  initialisePI <- nxt_specify_init_calc *)
walther@60111
   249
fun initialisePIDE (fmz, (dI, pI, mI)) = 
walther@60111
   250
    let
walther@60111
   251
	    val thy = ThyC.get_theory dI
walther@60111
   252
	    val (pI, (pors, pctxt), mI) = 
walther@60111
   253
	      if mI = ["no_met"] 
walther@60111
   254
	      then 
walther@60111
   255
          let 
walther@60112
   256
            val pors = Problem.from_store pI |> #ppc |> O_Model.init fmz thy; (*..TermC.parseNEW'*)
walther@60112
   257
            val pctxt = ContextC.initialise' thy fmz;                (*..DUPLICATE ermC.parseNEW'*)
walther@60111
   258
		        val pI' = Refine.refine_ori' pors pI;
walther@60111
   259
		      in (pI', (pors (*refinement over models with diff.precond only*), pctxt),
walther@60111
   260
		        (hd o #met o Problem.from_store) pI')
walther@60111
   261
		      end
walther@60111
   262
	      else
walther@60111
   263
	        let
walther@60112
   264
	          val pors = Problem.from_store pI |> #ppc |> O_Model.init fmz thy; (*..TermC.parseNEW'*)
walther@60112
   265
            val pctxt = ContextC.initialise' thy fmz;                (*..DUPLICATE ermC.parseNEW'*)
walther@60111
   266
	        in (pI, (pors, pctxt), mI) end;
walther@60111
   267
	    val {cas, ppc, thy = thy', ...} = Problem.from_store pI (*take dI from _refined_ pbl*)
walther@60111
   268
	    val dI = Context.theory_name (ThyC.sub_common (thy, thy'))
walther@60111
   269
	    val hdl = case cas of
walther@60111
   270
		    NONE => Auto_Prog.pblterm dI pI
walther@60111
   271
		  | SOME t => subst_atomic ((Model_Pattern.variables ppc) ~~~ O_Model.values pors) t
walther@60113
   272
	    val hdlPIDE = case cas of
walther@60113
   273
		    NONE => Auto_Prog.pbltermPIDE dI pI
walther@60113
   274
		  | SOME t => subst_atomic ((Model_Pattern.variables ppc) ~~~ O_Model.values pors) t
walther@60111
   275
    in
walther@60114
   276
      (hdlPIDE, hdl, (dI, pI, mI), pors, pctxt)
walther@60111
   277
    end;
walther@60111
   278
(*  nxt_specify_init_calc \<rightarrow> initialise *)
walther@60111
   279
fun nxt_specify_init_calc ([], (dI, pI, mI)) = (*this will probably be dropped with PIDE*)
walther@59806
   280
    if pI <> [] 
walther@59806
   281
    then (* from pbl-browser or from CAS cmd with pI=[e_pblID] *)
walther@59806
   282
	    let 
walther@59970
   283
        val {cas, met, ppc, thy, ...} = Problem.from_store pI
walther@59880
   284
	      val dI = if dI = "" then Context.theory_name thy else dI
walther@59806
   285
	      val mI = if mI = [] then hd met else mI
walther@59806
   286
	      val hdl = case cas of NONE => Auto_Prog.pblterm dI pI | SOME t => t
walther@59952
   287
	      val (pt, _) = cappend_problem e_ctree [] (Istate_Def.Uistate, ContextC.empty) ([], (dI, pI, mI))
walther@59846
   288
				  ([], (dI,pI,mI), hdl, ContextC.empty)
walther@59806
   289
	      val pt = update_spec pt [] (dI, pI, mI)
walther@59958
   290
	      val pits = I_Model.init ppc
walther@59806
   291
	      val pt = update_pbl pt [] pits
walther@59806
   292
	    in ((pt, ([] , Pbl)), []) end
walther@59806
   293
    else 
walther@59806
   294
      if mI <> [] 
walther@59806
   295
      then (* from met-browser *)
walther@59806
   296
	      let 
walther@59970
   297
          val {ppc, ...} = Method.from_store mI
walther@59806
   298
	        val dI = if dI = "" then "Isac_Knowledge" else dI
walther@59846
   299
	        val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty)
walther@59861
   300
	          ([], (dI, pI, mI)) ([], (dI, pI, mI), TermC.empty, ContextC.empty)
walther@59806
   301
	        val pt = update_spec pt [] (dI, pI, mI)
walther@59958
   302
	        val mits = I_Model.init ppc
walther@59806
   303
	        val pt = update_met pt [] mits
walther@59806
   304
	      in ((pt, ([], Met)), []) end
walther@59806
   305
      else (* new example, pepare for interactive modeling *)
walther@59806
   306
	      let
walther@59846
   307
	        val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, ContextC.empty) 
walther@59976
   308
	          ([], References.empty) ([], References.empty, TermC.empty, ContextC.empty)
walther@59806
   309
	      in ((pt, ([], Pbl)), []) end
walther@59806
   310
  | nxt_specify_init_calc (fmz, (dI, pI, mI)) = 
walther@60111
   311
    let            (* both ^^^  ^^^^^^^^^^^^  are either empty or complete *)
walther@60114
   312
	    val (_, hdl, (dI, pI, mI), pors, pctxt) = initialisePIDE (fmz, (dI, pI, mI))
walther@59846
   313
      val (pt, _) = cappend_problem e_ctree [] (Istate_Def.empty, pctxt)
walther@59819
   314
        (fmz, (dI, pI, mI)) (pors, (dI, pI, mI), hdl, pctxt)
walther@59806
   315
    in
walther@60020
   316
      ((pt, ([], Pbl)), (fst3 o snd) (by_tactic_input Tactic.Model_Problem (pt, ([], Pbl))))
walther@59806
   317
    end
walther@59763
   318
walther@59763
   319
(**)end(**)