test/Tools/isac/Minisubpbl/300-init-subpbl.sml
author Walther Neuper <walther.neuper@jku.at>
Wed, 15 Jan 2020 11:47:38 +0100
changeset 59767 c4acd312bd53
parent 59755 fbaff8cf0179
child 59772 d6bab1992c6a
permissions -rw-r--r--
preps for IJCAR paper
wneuper@59546
     1
(* Title:  "Minisubpbl/300-init-subpbl.sml"
neuper@41985
     2
   Author: Walther Neuper 1105
neuper@41985
     3
   (c) copyright due to lincense terms.
neuper@41985
     4
*)
neuper@41985
     5
wneuper@59569
     6
"----------- Minisubpbl/300-init-subpbl.sml ----------------------";
wneuper@59569
     7
"----------- Minisubpbl/300-init-subpbl.sml ----------------------";
wneuper@59569
     8
"----------- Minisubpbl/300-init-subpbl.sml ----------------------";
neuper@41985
     9
val fmz = ["equality (x+1=(2::real))", "solveFor x","solutions L"];
neuper@41985
    10
val (dI',pI',mI') =
neuper@41985
    11
  ("Test", ["sqroot-test","univariate","equation","test"],
neuper@41985
    12
   ["Test","squ-equ-test-subpbl1"]);
neuper@41985
    13
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
neuper@41985
    14
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41986
    15
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41986
    16
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41986
    17
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41986
    18
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
neuper@41986
    19
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
wneuper@59582
    20
(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Apply_Method ["Test", "squ-equ-test-subpbl1"]*)
wneuper@59582
    21
(*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt =  Rewrite_Set "norm_equation"*)
wneuper@59582
    22
(*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt =  Rewrite_Set "Test_simplify" *)
wneuper@59582
    23
(*[2], Res*)val (p''',_,f,nxt''',_,pt''') = me nxt p [] pt; (*nxt = ("Subproblem"*)
wneuper@59582
    24
(*//--1 begin step into relevant call -----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----\\
wneuper@59582
    25
      1 relevant for updating ctxt                                                              *)
walther@59749
    26
"~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt''', p''', [], pt''');
wneuper@59582
    27
wneuper@59582
    28
"~~~~~ fun locatetac , args:"; val (tac, ptp as (pt, p)) = (tac, (pt''',p'''));
walther@59755
    29
  val Appl m = applicable_in p pt tac;
walther@59755
    30
  (*if*) Tactic.for_specify' m; (*false*)
neuper@42092
    31
(*val Updated (cs' as (_,_,(_,p'))) =  loc_solve_ (mI,m) ptp;*)
walther@59749
    32
"~~~~~ fun loc_solve_, args:"; val (m, (pt,pos)) = (m, ptp);
walther@59751
    33
(*val (msg, cs') =*)
walther@59751
    34
           Step_Solve.by_tactic m (pt, pos);
walther@59751
    35
"~~~~~ fun Step_Solve.by_tactic , args:"; val (m, (pt, po as (p,p_))) = (m, (pt, pos));
neuper@42092
    36
e_metID = get_obj g_metID pt (par_pblobj pt p) (*false*);
neuper@42092
    37
	      val thy' = get_obj g_domID pt (par_pblobj pt p);
neuper@42092
    38
	      val (srls, is, sc) = from_pblobj_or_detail' thy' (p,p_) pt;
wneuper@59569
    39
wneuper@59569
    40
    locate_input_tactic sc (pt, po) (fst is) (snd is) m;
walther@59692
    41
"~~~~~ fun locate_input_tactic , args:"; val (Rule.Prog progr, cstate, istate, ctxt, tac)
wneuper@59569
    42
     = (sc, (pt, po), (fst is), (snd is), m);
wneuper@59569
    43
walther@59718
    44
  val Accept_Tac1 (_, _, Subproblem' (_, _, _, _, _, _)) = (*case*)
walther@59692
    45
           scan_to_tactic1 (prog, (cstate, ctxt, tac)) istate (*of*);
walther@59692
    46
"~~~~~ fun scan_to_tactic1 , args:"; val ((prog, (cctt as ((_, p), _, _))),
walther@59686
    47
     (Istate.Pstate (ist as {path, ...})))
walther@59692
    48
  = ((progr, (cstate, ctxt, tac)), istate);
walther@59686
    49
   (*if*) path = [] orelse ((last_elem o fst) p = 0 andalso snd p = Res) (*else*);
wneuper@59582
    50
walther@59692
    51
           go_scan_up1 (progr, cctt) ist;
walther@59692
    52
"~~~~~ and go_scan_up1, args:"; val ((yyy as (prog, _)), (ist as {path, ...}))
walther@59692
    53
  = ((prog, cctt), ist);
walther@59686
    54
   (*if*) 1 < length path (*true*);
neuper@42092
    55
walther@59767
    56
           scan_up1 yyy (ist |> path_up) (at_location (path_up' path) prog);
walther@59691
    57
"~~~~~ fun scan_up1, args:"; val (yyy, ist, (Const ("Tactical.Try"(*2*), _) $ _))
walther@59767
    58
  = (yyy, (ist |> path_up), (at_location (path_up' path) prog));
neuper@41986
    59
walther@59691
    60
           go_scan_up1 yyy ist;
walther@59692
    61
"~~~~~ and go_scan_up1, args:"; val ((yyy as (prog, _)), (ist as {path, ...}))
walther@59686
    62
  = (yyy, ist);
walther@59686
    63
   (*if*) 1 < length path (*true*);
wneuper@59582
    64
walther@59767
    65
           scan_up1 yyy (ist |> path_up) (at_location (path_up' path) prog);
walther@59691
    66
"~~~~~ fun scan_up1 , args:"; val (yyy, ist, (Const ("Tactical.Chain"(*2*), _) $ _ $ _))
walther@59767
    67
  = (yyy, (ist |> path_up), (at_location (path_up' path) prog));
wneuper@59582
    68
walther@59691
    69
           go_scan_up1 yyy ist (*2*: comes from e2*);
walther@59692
    70
"~~~~~ and go_scan_up1, args:"; val ((yyy as (prog, _)), (ist as {path, ...}))
walther@59686
    71
  = (yyy, ist);
walther@59686
    72
   (*if*) 1 < length path (*true*);
wneuper@59582
    73
walther@59767
    74
           scan_up1 yyy (ist |> path_up) (at_location (path_up' path) prog);
walther@59691
    75
"~~~~~ fun scan_up1 , args:"; val (yyy, ist, (Const ("Tactical.Chain"(*1*), _) $ _ $ _ $ _))
walther@59767
    76
  = (yyy, (ist |> path_up), (at_location (path_up' path) prog));
wneuper@59582
    77
walther@59691
    78
       go_scan_up1 yyy ist (*all has been done in (*2*) below*);
walther@59692
    79
"~~~~~ and go_scan_up1, args:"; val ((yyy as (prog, _)), (ist as {path, ...}))
walther@59686
    80
  = (yyy, ist);
walther@59686
    81
   (*if*) 1 < length path (*true*);
wneuper@59582
    82
walther@59767
    83
           scan_up1 yyy (ist |> path_up) (at_location (path_up' path) prog);
walther@59692
    84
"~~~~~ fun scan_up1 , args:"; val ((yyy as (prog, xxx as (cstate, _, _))), ist, (Const ("HOL.Let"(*1*), _) $ _))
walther@59767
    85
  = ( yyy, (ist |> path_up), (at_location (path_up' path) prog));
walther@59692
    86
      val (i, body) = check_Let_up ist prog
walther@59686
    87
;
walther@59718
    88
  (*case*) scan_dn1 xxx (ist |> path_up_down [R, D] |> upd_env i |> set_or ORundef) body (*of*);
walther@59691
    89
"~~~~~ fun scan_dn1 , args:"; val (xxx, ist, (Const ("HOL.Let", _) $ e $ (Abs (id, T, b))))
walther@59718
    90
  = (xxx, (ist |> path_up_down [R, D] |> upd_env i |> set_or ORundef), body);
walther@59686
    91
walther@59691
    92
  (*case*) scan_dn1 xxx (ist |> path_down [L, R]) e (*of*);
walther@59657
    93
    (*======= end of scanning tacticals, a leaf =======*)
walther@59722
    94
"~~~~~ fun scan_dn1 , args:"; val (((pt, p), ctxt, tac), (ist as {eval, or, ...}), t)
walther@59686
    95
  = (xxx, (ist |> path_down [L, R]), e);
wneuper@59582
    96
walther@59721
    97
val (Program.Tac _, NONE) = (*case*)
walther@59722
    98
           interpret_leaf "locate" ctxt eval (get_subst ist) t (*of*);
walther@59718
    99
"~~~~~ fun interpret_leaf , args:"; val (call, thy, srls, (E, (a, v)), t)
walther@59722
   100
  = ("locate", ctxt, eval, (get_subst ist), t);
wneuper@59582
   101
walther@59729
   102
    val (Program.Tac stac, a) = (*case*) Prog_Tac.eval_leaf E a v t (*of*);
walther@59718
   103
"~~~~~ fun eval_leaf , args:"; val (E, _, _, (t as (Const ("Prog_Tac.SubProblem", _) $ _ $ _)))
wneuper@59582
   104
  = (E, a, v, t);
wneuper@59582
   105
walther@59722
   106
     (Program.Tac (subst_atomic E t), NONE); (*return value*)
walther@59722
   107
"~~~~~ from eval_leaf to interpret_leaf return val:"; val ((Program.Tac stac, a'))
walther@59722
   108
  = ((Program.Tac (subst_atomic E t), NONE : term option));
wneuper@59582
   109
        val stac' =
walther@59722
   110
            Rewrite.eval_prog_expr (Proof_Context.theory_of ctxt) srls 
walther@59722
   111
              (subst_atomic (Env.update_opt E (a,v)) stac);
wneuper@59582
   112
walther@59717
   113
                                 (*return value*) (a', Program.Tac stac');
walther@59718
   114
"~~~~~ from interpret_leaf to scan_dn1 return val:"; val (a', Program.Tac stac)
walther@59717
   115
  = ((a' : term option, Program.Tac stac'));
walther@59657
   116
           val Lucin.Ass (m, v', ctxt) = (*case*) Lucin.associate pt ctxt (m, stac) (*of*);
wneuper@59582
   117
walther@59691
   118
(*+*)if is_e_ctxt ctxt then error "ERROR: scan_dn1 returns e_ctxt" else ();
wneuper@59582
   119
(*\\--1 end step into relevant call ----------------------------------------------------------//*)
wneuper@59582
   120
wneuper@59582
   121
val (p,_,f,nxt,_,pt) = me nxt''' p''' [1] pt''';
wneuper@59582
   122
wneuper@59582
   123
if p = ([3], Pbl) andalso not (get_ctxt pt p |> is_e_ctxt)
wneuper@59582
   124
then
walther@59749
   125
  case nxt of (Model_Problem) => ()
wneuper@59582
   126
  | _ => error "minisubpbl: CalcTreeTEST has no nxt = Model_Problem"
wneuper@59582
   127
else error "Minisubpbl/300-init-subpbl.sml changed";