test/Tools/isac/Minisubpbl/100-init-rootpbl.sml
author wneuper <Walther.Neuper@jku.at>
Wed, 25 Jan 2023 15:52:33 +0100
changeset 60651 b7a2ad3b3d45
parent 60588 9a116f94c5a6
child 60652 75003e8f96ab
permissions -rw-r--r--
ContextC.build_while_parsing, improves O_Model.init_PIDE
     1 (* Title:  100-init-rootpbl.sml
     2    Author: Walther Neuper 1105
     3    (c) copyright due to lincense terms.
     4 *)
     5 
     6 "----------- Minisubplb/100-init-rootpbl.sml ---------------------";
     7 "----------- Minisubplb/100-init-rootpbl.sml ---------------------";
     8 "----------- Minisubplb/100-init-rootpbl.sml ---------------------";
     9 val (_(*example text*), 
    10   (model as ("Constants [r = (7::real)]" :: "Maximum A" :: "AdditionalValues [u, v]" :: 
    11      "Extremum (A = 2 * u * v - u \<up> 2)" :: 
    12      "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
    13      "SideConditions [((u::real) / 2) \<up> 2 + (2 / v) \<up> 2 = r \<up> 2]" :: 
    14      "SideConditions [(u::real) / 2 = r * sin \<alpha>, 2 / v = r * cos \<alpha>]" :: 
    15      "FunctionVariable a" :: "FunctionVariable b" :: "FunctionVariable \<alpha>" :: 
    16      "Domain {0 <..< r}" :: "Domain {0 <..< r}" :: "Domain {0 <..< \<pi> / 2}" ::
    17      "ErrorBound (\<epsilon> = (0::real))" :: []), 
    18    refs as ("Diff_App", 
    19      ["univariate_calculus", "Optimisation"],
    20      ["Optimisation", "by_univariate_calculus"])))
    21   = Store.get (Know_Store.get_expls @{theory}) ["Diff_App-No.123a"] ["Diff_App-No.123a"];
    22 
    23  Test_Code.init_calc @{context} [(model, refs)];
    24 "~~~~~ fun init_calc , args:"; val (ctxt, [(model, refs as (thy_id, _, _))])
    25   = (@{context}, [(model, refs)]);
    26 (*old* )val ctxt = thy_id |> ThyC.get_theory_PIDE ctxt |> Proof_Context.init_global
    27 ( *new*)val thy = thy_id |> ThyC.get_theory_PIDE ctxt  (*^^^^^^^^^^^^^^^^^^^^^^^^^ misleading*)
    28 
    29 (**)val return_nxt_specify_init_calc_PIDE =(**)
    30 Step_Specify.nxt_specify_init_calc_PIDE thy (model, refs);
    31 "~~~~~ fun nxt_specify_init_calc , args:"; val (ctxt, (model, (dI, pI, mI))) = (ctxt, (model, refs));
    32 
    33 Step_Specify.initialise_PIDE thy (model, refs);
    34 "~~~~~ fun initialise , args:"; val (ctxt, (fmz, (dI, pI, mI))) = (ctxt, (model, refs));
    35 (*old* )val thy = ThyC.get_theory_PIDE ctxt dI( *old*)
    36 	    val ctxt = Proof_Context.init_global thy (* ctxt restricted to Formalise.refs *)
    37 	    val (pI, (pors, pctxt), mI) = 
    38         if mI = ["no_met"] 
    39         then raise error "else not covered by test"
    40         else
    41           let
    42 (*old* )     val pors = Problem.from_store ctxt pI |> #model |> O_Model.init thy fmz; (*..TermC.parseNEW'*)
    43 (*old*)     val pctxt = ContextC.initialise' thy fmz;                (*..DUPLICATE ermC.parseNEW'*)
    44 (*old*)   in (pI, (pors, pctxt), mI) end;
    45 ( *new*)     val (pors, pctxt) = Problem.from_store ctxt pI |> #model |> O_Model.init_PIDE thy fmz;
    46           in (pI, (pors, pctxt), mI) end;
    47 
    48 (*+*)val Free ("r", Type ("Real.real", [])) = Syntax.read_term pctxt "r";
    49 (*+*)val Free ("u", Type ("Real.real", [])) = Syntax.read_term pctxt "u";
    50 (*-------------------- stop step into Step_Specify.nxt_specify_init_calc ---------------------*)
    51 
    52 val ((pt, p), tacis) = return_nxt_specify_init_calc_PIDE(* kept for continuation *);
    53 "~~~~~ continue fun init_calc , args:"; val ((pt, p), tacis)
    54   = ((pt, p), tacis);
    55 	  val tac = case tacis of [] => Tactic.Empty_Tac | _ => (#1 o hd) tacis;
    56 
    57  Test_Code.TESTg_form ctxt (pt,p);
    58 "~~~~~ fun TESTg_form , args:"; val (ctxt, ptp) = (ctxt, (pt,p));
    59     val (form, _, _) =  ME_Misc.pt_extract ctxt ptp;
    60 val Ctree.ModSpec (_, p_, _, gfr, where_, _) =
    61     (*case*) form (*of*);
    62 val Pos.Pbl =
    63       (*case*) p_ (*of*);
    64     Test_Out.Problem [];
    65     Test_Out.MethodC [];
    66 
    67 (*val return =*)
    68   Test_Out.PpcKF (Test_Out.Problem [], 
    69    P_Model.from (Proof_Context.theory_of ctxt) gfr where_);
    70 "~~~~~ fun from , args:"; val (thy, itms, where_) = ((Proof_Context.theory_of ctxt), gfr, where_);
    71 
    72 (*//------------------ inserted hidden code ------------------------------------------------\\*)
    73 fun item_from_feedback thy (I_Model.Cor ((d, ts), _)) = P_Model.Correct (UnparseC.term_in_thy thy (Input_Descript.join (d, ts)))
    74   | item_from_feedback _ (I_Model.Syn c) = P_Model.SyntaxE c
    75   | item_from_feedback _ (I_Model.Typ c) = P_Model.TypeE c
    76   | item_from_feedback thy (I_Model.Inc ((d, ts), _)) = P_Model.Incompl (UnparseC.term_in_thy thy  (Input_Descript.join (d, ts)))
    77   | item_from_feedback thy (I_Model.Sup (d, ts)) = P_Model.Superfl (UnparseC.term_in_thy thy  (Input_Descript.join (d, ts)))
    78   | item_from_feedback thy (I_Model.Mis (d, pid)) = P_Model.Missing (UnparseC.term_in_thy thy d ^ " " ^ UnparseC.term_in_thy thy  pid)
    79   | item_from_feedback _ _ = raise ERROR "item_from_feedback: uncovered definition"
    80 fun add_sel_ppc (_: theory) sel {Given = gi, Where = wh, Find = fi, With = wi, Relate = re} x =
    81   case sel of
    82     "#Given" => {Given = gi @ [x], Where = wh, Find = fi, With = wi,Relate = re}
    83   | "#Where" => {Given = gi, Where = wh @ [x], Find = fi, With = wi, Relate = re}
    84   | "#Find"  => {Given = gi, Where = wh, Find = fi @ [x], With = wi, Relate = re}
    85   | "#Relate"=> {Given = gi, Where = wh, Find = fi, With = wi, Relate = re @ [x]}
    86   | "#undef" => {Given = gi @ [x], Where = wh, Find = fi, With = wi, Relate = re} (*ori2itmSup*)
    87   | _  => raise ERROR ("add_sel_ppc tried to select by \"" ^ sel ^ "\"")
    88 fun add_where {Given = gi, Where = _, Find = fi, With = wi, Relate = re} wh =
    89   {Given = gi, Where = wh, Find= fi ,With = wi, Relate = re}
    90 fun boolterm2item ctxt (true, term) = P_Model.Correct (UnparseC.term_in_ctxt ctxt term)
    91   | boolterm2item ctxt(false, term) = P_Model.False (UnparseC.term_in_ctxt ctxt term);
    92 (*\\------------------ inserted hidden code ------------------------------------------------//*)
    93 
    94     fun coll model [] = model
    95       | coll model ((_, _, _, field, itm_)::itms) =
    96         coll (add_sel_ppc thy field model (item_from_feedback thy itm_)) itms;
    97     val gfr = coll P_Model.empty itms;
    98 
    99 (*val return =*)
   100            add_where gfr (map (boolterm2item (Proof_Context.init_global thy)) where_);
   101 "~~~~~ fun add_where , args:"; val ({Given = gi, Where = _, Find = fi, With = wi, Relate = re}, wh)
   102   = (gfr, (map 
   103           (boolterm2item ctxt) where_));
   104 "~~~~~ fun boolterm2item , args:"; val () = ();
   105 (*\\------------------ step into nxt_specify_init_calc -------------------------------------//*)