test/Tools/isac/Test_Theory.thy
changeset 60577 ca9f84786137
parent 60576 11dd56e2a6b8
child 60578 baf06b1b2aaa
equal deleted inserted replaced
60576:11dd56e2a6b8 60577:ca9f84786137
    75 
    75 
    76 section \<open>=============== 100-init-rootpbl.sml ===========================\<close>
    76 section \<open>=============== 100-init-rootpbl.sml ===========================\<close>
    77 ML \<open>
    77 ML \<open>
    78 \<close> ML \<open>
    78 \<close> ML \<open>
    79 \<close> ML \<open>
    79 \<close> ML \<open>
    80 (* Title:  100-init-rootpbl.sml
       
    81    Author: Walther Neuper 1105
       
    82    (c) copyright due to lincense terms.
       
    83 *)
       
    84 
       
    85 "----------- Minisubplb/100-init-rootpbl.sml ---------------------";
       
    86 "----------- Minisubplb/100-init-rootpbl.sml ---------------------";
       
    87 "----------- Minisubplb/100-init-rootpbl.sml ---------------------";
       
    88 \<close> ML \<open>
       
    89 val (_(*example text*), 
       
    90   (model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: 
       
    91      "Extremum (A = 2 * u * v - u \<up> 2)" :: 
       
    92      "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
       
    93      "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
       
    94      "SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" :: 
       
    95      "FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" :: 
       
    96      "Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
       
    97      "ErrorBound (\<epsilon> = (0::real))" :: []), 
       
    98    refs as ("Diff_App", 
       
    99      ["univariate_calculus", "Optimisation"],
       
   100      ["Optimisation", "by_univariate_calculus"])))
       
   101   = Store.get (KEStore_Elems.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"]
       
   102 \<close> ML \<open>
       
   103  Test_Code.init_calc @{context} [(model, refs)];
       
   104 \<close> ML \<open>
       
   105 "~~~~~ fun init_calc , args:"; val (ctxt, [(model, refs as (thy_id, _, _))])
       
   106   = (@{context}, [(model, refs)]);
       
   107     val ctxt = thy_id |> ThyC.get_theory_PIDE ctxt |> Proof_Context.init_global
       
   108     val ((pt''', p'''), tacis''') = (* keep for continuation *)
       
   109 
       
   110 Step_Specify.nxt_specify_init_calc ctxt (model, refs);
       
   111 "~~~~~ fun nxt_specify_init_calc , args:"; val (ctxt, (model, (dI, pI, mI))) = (ctxt, (model, refs));
       
   112 
       
   113 Step_Specify.initialise ctxt (model, refs);
       
   114 "~~~~~ fun initialise , args:"; val (ctxt, (fmz, (dI, pI, mI))) = (ctxt, (model, refs));
       
   115 	    val thy = ThyC.get_theory_PIDE ctxt dI
       
   116 	    val ctxt = Proof_Context.init_global thy (* ctxt restricted to Formalise *)
       
   117 	    val (pI, (pors, pctxt), mI) = 
       
   118 	      if mI = ["no_met"] 
       
   119 	      then raise error "else not covered by test"
       
   120 	      else
       
   121 	        let
       
   122 	          val pors = Problem.from_store ctxt pI |> #ppc |> O_Model.init thy fmz; (*..TermC.parseNEW'*)
       
   123             val pctxt = ContextC.initialise' thy fmz;                (*..DUPLICATE ermC.parseNEW'*)
       
   124 	        in (pI, (pors, pctxt), mI) end;
       
   125 
       
   126 (*-------------------- stop step into Step_Specify.nxt_specify_init_calc ---------------------*)
       
   127 "~~~~~ continue fun init_calc , args:"; val ((pt, p), tacis)
       
   128   = ((pt''', p'''), tacis''');
       
   129 	  val tac = case tacis of [] => Tactic.Empty_Tac | _ => (#1 o hd) tacis;
       
   130 
       
   131  Test_Code.TESTg_form ctxt (pt,p);
       
   132 "~~~~~ fun TESTg_form , args:"; val (ctxt, ptp) = (ctxt, (pt,p));
       
   133     val (form, _, _) =  ME_Misc.pt_extract ctxt ptp;
       
   134 val Ctree.ModSpec (_, p_, _, gfr, pre, _) =
       
   135     (*case*) form (*of*);
       
   136 val Pos.Pbl =
       
   137       (*case*) p_ (*of*);
       
   138     Test_Out.Problem [];
       
   139     Test_Out.MethodC [];
       
   140 
       
   141 (*val return =*)
       
   142   Test_Out.PpcKF (Test_Out.Problem [], 
       
   143    P_Model.from (Proof_Context.theory_of ctxt) gfr pre);
       
   144 "~~~~~ fun from , args:"; val (thy, itms, pre) = ((Proof_Context.theory_of ctxt), gfr, pre);
       
   145 
       
   146 (*//------------------ inserted hidden code ------------------------------------------------\\*)
       
   147 fun item_from_feedback (_: theory) (I_Model.Cor ((d, ts), _)) = P_Model.Correct (UnparseC.term (Input_Descript.join (d, ts)))
       
   148   | item_from_feedback _ (I_Model.Syn c) = P_Model.SyntaxE c
       
   149   | item_from_feedback _ (I_Model.Typ c) = P_Model.TypeE c
       
   150   | item_from_feedback _ (I_Model.Inc ((d, ts), _)) = P_Model.Incompl (UnparseC.term (Input_Descript.join (d, ts)))
       
   151   | item_from_feedback _ (I_Model.Sup (d, ts)) = P_Model.Superfl (UnparseC.term (Input_Descript.join (d, ts)))
       
   152   | item_from_feedback _ (I_Model.Mis (d, pid)) = P_Model.Missing (UnparseC.term d ^ " " ^ UnparseC.term pid)
       
   153   | item_from_feedback _ _ = raise ERROR "item_from_feedback: uncovered definition"
       
   154 fun add_sel_ppc (_: theory) sel {Given = gi, Where = wh, Find = fi, With = wi, Relate = re} x =
       
   155   case sel of
       
   156     "#Given" => {Given = gi @ [x], Where = wh, Find = fi, With = wi,Relate = re}
       
   157   | "#Where" => {Given = gi, Where = wh @ [x], Find = fi, With = wi, Relate = re}
       
   158   | "#Find"  => {Given = gi, Where = wh, Find = fi @ [x], With = wi, Relate = re}
       
   159   | "#Relate"=> {Given = gi, Where = wh, Find = fi, With = wi, Relate = re @ [x]}
       
   160   | "#undef" => {Given = gi @ [x], Where = wh, Find = fi, With = wi, Relate = re} (*ori2itmSup*)
       
   161   | _  => raise ERROR ("add_sel_ppc tried to select by \"" ^ sel ^ "\"")
       
   162 fun add_where {Given = gi, Where = _, Find = fi, With = wi, Relate = re} wh =
       
   163   {Given = gi, Where = wh, Find= fi ,With = wi, Relate = re}
       
   164 fun boolterm2item ctxt (true, term) = P_Model.Correct (UnparseC.term_in_ctxt ctxt term)
       
   165   | boolterm2item ctxt(false, term) = P_Model.False (UnparseC.term_in_ctxt ctxt term);
       
   166 (*\\------------------ inserted hidden code ------------------------------------------------//*)
       
   167 
       
   168     fun coll ppc [] = ppc
       
   169       | coll ppc ((_, _, _, field, itm_)::itms) =
       
   170         coll (add_sel_ppc thy field ppc (item_from_feedback thy itm_)) itms;
       
   171     val gfr = coll P_Model.empty itms;
       
   172 
       
   173 (*val return =*)
       
   174            add_where gfr (map (boolterm2item (Proof_Context.init_global thy)) pre);
       
   175 "~~~~~ fun add_where , args:"; val ({Given = gi, Where = _, Find = fi, With = wi, Relate = re}, wh)
       
   176   = (gfr, (map 
       
   177           (boolterm2item ctxt) pre));
       
   178 "~~~~~ fun boolterm2item , args:"; val () = ();
       
   179 (*\\------------------ step into nxt_specify_init_calc -------------------------------------//*)
       
   180 
       
   181 \<close> ML \<open>
    80 \<close> ML \<open>
   182 \<close> ML \<open>
    81 \<close> ML \<open>
   183 \<close> ML \<open>
    82 \<close> ML \<open>
   184 \<close> ML \<open>
    83 \<close> ML \<open>
   185 \<close>
    84 \<close>