test/Tools/isac/Minisubpbl/600-postcond-NEXT_STEP.sml
author Walther Neuper <walther.neuper@jku.at>
Wed, 18 Mar 2020 15:23:15 +0100
changeset 59831 edf1643edde5
parent 59807 c384f7ab263d
child 59839 0688613fc053
permissions -rw-r--r--
prep. cleanup LItool.resume_prog
walther@59781
     1
(* Title:  "Minisubpbl/600-postcond-NEXT_STEP.sml"
walther@59781
     2
   Author: Walther Neuper 200121
walther@59781
     3
   (c) copyright due to lincense terms.
walther@59781
     4
*)
walther@59781
     5
walther@59787
     6
"----------- Minisubplb/600-postcond-NEXT_STEP.sml -------------------------------------------";
walther@59787
     7
"----------- Minisubplb/600-postcond-NEXT_STEP.sml -------------------------------------------";
walther@59787
     8
"----------- Minisubplb/600-postcond-NEXT_STEP.sml -------------------------------------------";
walther@59781
     9
val fmz = ["equality (x+1=(2::real))", "solveFor x","solutions L"];
walther@59781
    10
val (dI',pI',mI') =
walther@59781
    11
  ("Test", ["sqroot-test","univariate","equation","test"],
walther@59781
    12
   ["Test","squ-equ-test-subpbl1"]);
walther@59781
    13
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59787
    14
(*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Model_Problem*)
walther@59787
    15
(*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Theory*)
walther@59787
    16
(*[], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Problem ["sqroot-test", "univariate", "equation", "test"*)
walther@59787
    17
(*[], Met*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Method ["Test", "squ-equ-test-subpbl1"]*)
walther@59787
    18
walther@59807
    19
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    20
 = "([], [], e_rls, NONE, \n??.empty, ORundef, false, false)"
walther@59787
    21
then () else error "pstate changed after ([], Met)";
walther@59787
    22
walther@59787
    23
(*[1], Frm*)val (_, ([(tac''''', _, _)], _, (pt''''', p'''''))) =(**) Step.do_next p ((pt, e_pos'), []);(*Apply_Method ["Test", "squ-equ-test-subpbl1"]*)
walther@59787
    24
walther@59807
    25
(*+*)if (get_istate_LI pt''''' p''''' |> the_pstate |> pstate2str)
walther@59787
    26
 = "([\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"], [], e_rls, NONE, \n??.empty, ORundef, false, true)"
walther@59787
    27
then () else error "pstate changed after ([1], Frm)"; (*this shall be corrected ...^^^^^^^^^: a tac has been found !!!*)
walther@59787
    28
walther@59787
    29
(*[1], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p''''' ((pt''''', e_pos'), []);(*Rewrite_Set "norm_equation"*)
walther@59787
    30
walther@59807
    31
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    32
(*= "([\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"], [R,L,R,L,L,R,R], e_rls, SOMEe_e, \nx + 1 + -1 * 2 = 0, ORundef, false, false)"*)
walther@59787
    33
  = "([\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"], [R,L,R,L,L,R,R], e_rls, SOME e_e, \nx + 1 + -1 * 2 = 0, ORundef, true, false)"
walther@59787
    34
then () else error "pstate changed after ([1], Res)"; (*this shall be corrected .............................^^^^^^^^^*)
walther@59787
    35
walther@59787
    36
(*[2], Res*)val (_, ([(tac, _, _)], _, (pt, p))) =(**) Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set "Test_simplify"*)
walther@59787
    37
walther@59807
    38
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    39
(*= "([\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"], [R,L,R,L,R,R], e_rls, SOMEe_e, \n-1 + x = 0, ORundef, false, false)"*)
walther@59787
    40
  = "([\"\n(e_e, x + 1 = 2)\",\"\n(v_v, x)\"], [R,L,R,L,R,R], e_rls, SOME e_e, \n-1 + x = 0, ORundef, true, false)"
walther@59787
    41
then () else error "pstate changed after ([2], Res)"; (*this shall be corrected ...................^^^^^^^^^*)
walther@59787
    42
walther@59787
    43
(*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
walther@59787
    44
walther@59807
    45
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    46
(*= "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,R,D,L,R], e_rls, NONE, \nSubproblem\n (''Test'',\n  ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n   ''test''), ORundef, false, false)"*)
walther@59787
    47
  = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,R,D,L,R], e_rls, NONE, \nSubproblem\n (''Test'',\n  ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n   ''test''), ORundef, true, false)"
walther@59787
    48
then () else error "pstate changed after ([3], Pbl)";
walther@59787
    49
walther@59787
    50
(*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Model_Problem*)
walther@59787
    51
(*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Theory "Test"*)
walther@59787
    52
(*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Problem ["LINEAR", "univariate", "equation", "test"]*)
walther@59787
    53
(*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Method ["Test", "solve_linear"]*)
walther@59787
    54
walther@59807
    55
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    56
(*= "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,R,D,L,R], e_rls, NONE, \nSubproblem\n (''Test'',\n  ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n   ''test''), ORundef, false, false)"*)
walther@59787
    57
  = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,R,D,L,R], e_rls, NONE, \nSubproblem\n (''Test'',\n  ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n   ''test''), ORundef, true, false)"
walther@59787
    58
then () else error "pstate changed after ([3], Pbl)";
walther@59787
    59
walther@59787
    60
(*[3, 1], Frm*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Apply_Method ["Test", "solve_linear"]*)
walther@59787
    61
walther@59807
    62
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    63
 = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [], e_rls, NONE, \n??.empty, ORundef, false, true)"
walther@59787
    64
then () else error "pstate changed after ([3, 1], Frm)";
walther@59787
    65
walther@59787
    66
(*[3, 1], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv")*)
walther@59787
    67
walther@59807
    68
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    69
(*= "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], e_rls, SOMEe_e, \nx = 0 + -1 * -1, ORundef, false, false)"*)
walther@59787
    70
  = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,L,R], e_rls, SOME e_e, \nx = 0 + -1 * -1, ORundef, true, false)"
walther@59787
    71
then () else error "pstate changed after ([3, 1], Res)";
walther@59787
    72
walther@59787
    73
(*[3, 2], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set "Test_simplify"*)
walther@59787
    74
walther@59807
    75
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    76
(*= "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,R], e_rls, SOMEe_e, \nx = 1, ORundef, false, false)"*)
walther@59787
    77
  = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,L,R,L,R,R], e_rls, SOME e_e, \nx = 1, ORundef, true, false)"
walther@59787
    78
then () else error "pstate changed after ([3, 2], Res)"; (*this shall be corrected ............^^^^^^^^^*)
walther@59787
    79
walther@59787
    80
(*[3], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Check_Postcond ["LINEAR", "univariate", "equation", "test"]*)
walther@59787
    81
walther@59807
    82
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    83
 = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\"], [R,R,D,L,R], e_rls, NONE, \n[x = 1], ORundef, true, false)"
walther@59787
    84
then () else error "pstate changed after ([3], Res)";
walther@59787
    85
walther@59787
    86
(*[4], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Check_elementwise "Assumptions"*)
walther@59787
    87
walther@59807
    88
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    89
(*= "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\",\"\n(L_L, [x = 1])\"], [R,R,D,R,D], e_rls, NONE, \n[x = 1], ORundef, false, false)"*)
walther@59787
    90
  = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\",\"\n(L_L, [x = 1])\"], [R,R,D,R,D], e_rls, NONE, \n[x = 1], ORundef, true, false)"
walther@59787
    91
then () else error "pstate changed after ([4], Res)"; (*this shall be corrected ..................................^^^^^^^^^*)
walther@59787
    92
walther@59787
    93
(*[], Res* )val ("ok", ([(tac, _, _)], _, (pt, p))) =( **) Step.do_next p ((pt, e_pos'), []);(*Check_Postcond ["sqroot-test", "univariate", "equation", "test"]*)
walther@59787
    94
walther@59807
    95
(*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
walther@59787
    96
(*= "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\",\"\n(L_L, [x = 1])\"], [R,R,D,R,D], e_rls, NONE, \n[x = 1], ORundef, false, false)"*)
walther@59787
    97
  = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\",\"\n(L_L, [x = 1])\"], [R,R,D,R,D], e_rls, NONE, \n[x = 1], ORundef, true, false)"
walther@59787
    98
then () else error "pstate changed after ([], Res)"; (*this shall be corrected ...................................^^^^^^^^^*)
walther@59787
    99
walther@59787
   100
"~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, e_pos'), []));
walther@59787
   101
  val pIopt = Ctree.get_pblID (pt, ip);
walther@59787
   102
    (*if*) ip = ([], Pos.Res) (*else*);
walther@59787
   103
      val _ = (*case*) tacis (*of*);
walther@59787
   104
      val SOME _ = (*case*) pIopt (*of*);
walther@59787
   105
    (*if*) member op = [Pos.Pbl, Pos.Met] p_ 
walther@59787
   106
  	         andalso is_none (Ctree.get_obj Ctree.g_env pt (fst p)) (*else*);
walther@59787
   107
walther@59787
   108
Step_Solve.do_next (pt, ip);
walther@59787
   109
"~~~~~ and do_next , args:"; val (ptp as (pt, pos as (p, p_))) = (pt, ip);
walther@59787
   110
    (*if*) Celem.e_metID = get_obj g_metID pt (par_pblobj pt p) (*else*);
walther@59787
   111
        val thy' = get_obj g_domID pt (par_pblobj pt p);
walther@59831
   112
	      val ((ist, ctxt), sc) = LItool.resume_prog thy' (p,p_) pt;
walther@59787
   113
walther@59787
   114
(*+*)istate2str ist
walther@59787
   115
 = "Pstate ([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\",\"\n(L_L, [x = 1])\"], [R,R,D,R,D], e_rls, NONE, \n[x = 1],"
walther@59787
   116
  ^ " ORundef, true, false)"; (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~true ok*)
walther@59787
   117
walther@59791
   118
  (*case*) LI.find_next_step sc (pt, pos) ist ctxt (*of*);
walther@59787
   119
"~~~~~ fun find_next_step , args:"; val ((Rule.Prog prog), (ptp as(pt, (p, _))), (Pstate ist), ctxt)
walther@59787
   120
  = (sc, (pt, pos), ist, ctxt);
walther@59787
   121
walther@59787
   122
  (*case*) scan_to_tactic (prog, (ptp, ctxt)) (Pstate ist) (*of*);
walther@59787
   123
"~~~~~ fun scan_to_tactic , args:"; val ((prog, cc), (Pstate (ist as {path, ...}))) = ((prog, (ptp, ctxt)), (Pstate ist));
walther@59787
   124
  (*if*) path = [] (*else*);
walther@59787
   125
walther@59787
   126
  val Term_Val _ =
walther@59787
   127
           go_scan_up (prog, cc) (trans_scan_up ist);
walther@59787
   128
"~~~~~ fun go_scan_up , args:"; val ((pcc as (sc, _)), (ist as {path, act_arg, found_accept, ...}))
walther@59787
   129
  = ((prog, cc), (trans_scan_up ist));
walther@59787
   130
    (*if*) 1 < length path (*then*);
walther@59787
   131
walther@59787
   132
  val Term_Val _ =
walther@59787
   133
           scan_up pcc (ist |> path_up) (go_up path sc);
walther@59787
   134
"~~~~~ and scan_up , args:"; val (pcc, ist, (Abs _(*2*))) = (pcc, (ist |> path_up), (go_up path sc));
walther@59787
   135
walther@59787
   136
  val Term_Val _ =
walther@59787
   137
           go_scan_up pcc ist;
walther@59787
   138
"~~~~~ fun go_scan_up , args:"; val ((pcc as (sc, _)), (ist as {path, act_arg, found_accept, ...}))
walther@59787
   139
  = (pcc, ist);
walther@59787
   140
    (*if*) 1 < length path (*then*);
walther@59787
   141
walther@59787
   142
  val Term_Val _ =
walther@59787
   143
             go_scan_up pcc ist;
walther@59787
   144
"~~~~~ and scan_up , args:"; val (pcc, ist, (Const ("HOL.Let"(*3*),_) $ _ $ (Abs _)))
walther@59787
   145
  = (pcc, (ist |> path_up), (go_up path sc));
walther@59787
   146
walther@59787
   147
(*/--------------------- final test ---------------------------------------------------------\\*)
walther@59787
   148
if pstate2str ist
walther@59787
   149
 = "([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\",\"\n(L_L, [x = 1])\"], [R,R,D], e_rls, NONE, \n[x = 1],"^
walther@59787
   150
  " ORundef, true, false)"
walther@59787
   151
then () else error "";