test/Tools/isac/BaseDefinitions/contextC.sml
author wneuper <walther.neuper@jku.at>
Tue, 20 Apr 2021 16:58:44 +0200
changeset 60242 73ee61385493
parent 60237 e534316f9e07
child 60330 e5e9a6c45597
permissions -rw-r--r--
replace power ^^^ by \<up>
     1 (* Title:  "ProgLang/contextC.sml"
     2    Author: Walther Neuper
     3    (c) due to copyright terms
     4 *)
     5 
     6 "-----------------------------------------------------------------------------------------------";
     7 "table of contents -----------------------------------------------------------------------------";
     8 "-----------------------------------------------------------------------------------------------";
     9 "----------- SEE ADDTESTS/All_Ctxt.thy ---------------------------------------------------------";
    10 "-----------------------------------------------------------------------------------------------";
    11 "----------- fun initialise --------------------------------------------------------------------";
    12 "----------- build fun initialise'--------------------------------------------------------------";
    13 "----------- fun get_assumptions, fun insert_assumptions----------------------------------------";
    14 "----------- fun transfer_asms_from_to ---------------------------------------------------------";
    15 "----------- fun avoid_contradict --------------------------------------------------------------";
    16 "----------- fun subpbl_to_caller --------------------------------------------------------------";
    17 "----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
    18 "-----------------------------------------------------------------------------------------------";
    19 "-----------------------------------------------------------------------------------------------";
    20 "-----------------------------------------------------------------------------------------------";
    21 
    22 
    23 "----------- fun initialise --------------------------------------------------------------------";
    24 "----------- fun initialise --------------------------------------------------------------------";
    25 "----------- fun initialise --------------------------------------------------------------------";
    26 val t = @{term "a * b + -123 * c :: real"};
    27 val ctxt = initialise "Rational" (vars t)
    28 
    29 (*----- now parsing infers the type *)
    30 val SOME t = parseNEW ctxt "x";
    31 if type_of t = HOLogic.realT then error "type inference failed 1" else ();
    32 
    33 val SOME t = parseNEW ctxt "a";
    34 if type_of t = HOLogic.realT then () else error "type inference failed 2";
    35 
    36 "----------- build fun initialise'--------------------------------------------------------------";
    37 "----------- build fun initialise'--------------------------------------------------------------";
    38 "----------- build fun initialise'--------------------------------------------------------------";
    39 val fmz = ["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
    40 	     "Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]",
    41 	     "FunktionsVariable x", "GleichungsVariablen [c, c_2, c_3, c_4]",
    42        "AbleitungBiegelinie dy"];
    43 val (thy, fmz) = (@{theory Biegelinie}, fmz);
    44 
    45 initialise' thy fmz;
    46 
    47     val ctxt = thy |> Proof_Context.init_global
    48     val ts = (map (TermC.parseNEW' ctxt) fmz) |> map TermC.vars |> flat |> distinct op =
    49     val _ = TermC.raise_type_conflicts ts;
    50 
    51 "----------- fun get_assumptions, fun insert_assumptions----------------------------------------";
    52 "----------- fun get_assumptions, fun insert_assumptions----------------------------------------";
    53 "----------- fun get_assumptions, fun insert_assumptions----------------------------------------";
    54 val ctxt = ContextC.insert_assumptions [@{term "x * v"}, @{term "2 * u"}, @{term "2 * u"}] ctxt;
    55 val ctxt = ContextC.insert_assumptions [@{term "x * v"}, @{term "2 * u"}] ctxt;
    56 val asms = ContextC.get_assumptions ctxt;
    57 if asms = [@{term "x * v"}, @{term "2 * u"}]
    58 then () else error "mstools.sml insert_/get_assumptions changed 1.";
    59 
    60 "----------- fun transfer_asms_from_to ---------------------------------------------------------";
    61 "----------- fun transfer_asms_from_to ---------------------------------------------------------";
    62 "----------- fun transfer_asms_from_to ---------------------------------------------------------";
    63 val ctxt = Proof_Context.init_global @{theory "Isac_Knowledge"}
    64 val from_ctxt = ContextC.insert_assumptions
    65   [TermC.str2term "a < (fro::int)", TermC.str2term "b < (fro::int)"] ctxt
    66 val to_ctxt = ContextC.insert_assumptions
    67   [TermC.str2term "b < (to::int)", TermC.str2term "c < (to::int)"] ctxt
    68 val new_ctxt = transfer_asms_from_to from_ctxt to_ctxt;
    69 if UnparseC.terms_to_strings (get_assumptions new_ctxt) = ["b < fro", "b < to", "c < to"]
    70 then () else error "fun transfer_asms_from_to changed"
    71 
    72 
    73 "----------- fun avoid_contradict --------------------------------------------------------------";
    74 "----------- fun avoid_contradict --------------------------------------------------------------";
    75 "----------- fun avoid_contradict --------------------------------------------------------------";
    76 val preds = [
    77 (*0.pre*)TermC.str2term "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
    78 (*1.pre*)TermC.str2term ("\<not> matches (?a = 0)\n        ((3 + -1 * x + x \<up> 2) * x =\n         1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) \<or>\n"
    79 (*1.pre*)    ^ "\<not> lhs ((3 + -1 * x + x \<up> 2) * x =\n            1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) is_poly_in x"),
    80 (*0.asm*)TermC.str2term  "x \<noteq> 0",             (* <-------------- "x \<noteq> 0" would contradict "x = 0" ---\*)
    81 (*0.asm*)TermC.str2term  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0"
    82 ];
    83 
    84 val t = TermC.str2term "[x = 0, x = 6 / 5]";
    85 val (t', for_asm) = avoid_contradict t preds;
    86 if UnparseC.term t' = "[x = 6 / 5]" andalso map UnparseC.term for_asm = ["x = 6 / 5"]
    87 then () else error "avoid_contradict [x = 0, x = 6 / 5] CHANGED";
    88 
    89 val t = TermC.str2term "x = 0";
    90 val (t', for_asm) = avoid_contradict t preds;
    91 if UnparseC.term t' = "bool_undef" andalso map UnparseC.term for_asm = []
    92 then () else error "avoid_contradict x = 0 CHANGED"; (* "x \<noteq> 0" in preds *)
    93 
    94 val t = TermC.str2term "x = 1";
    95 val (t', for_asm) = avoid_contradict t preds;
    96 if UnparseC.term t' = "x = 1" andalso map UnparseC.term for_asm = ["x = 1"]
    97 then () else error "avoid_contradict x = 1 CHANGED"; (* "x \<noteq> 1" NOT in preds *)
    98 
    99 val t = TermC.str2term "a + b";
   100 val (t', for_asm) = avoid_contradict t preds;
   101 if UnparseC.term t' = "a + b" andalso map UnparseC.term for_asm = []
   102 then () else error "avoid_contradict a + b CHANGED"; (* NOT a predicate *)
   103 
   104 val t = TermC.str2term "[a + b]";
   105 val (t', for_asm) = avoid_contradict t preds;
   106 if UnparseC.term t' = "[a + b]" andalso map UnparseC.term for_asm = []
   107 then () else error "avoid_contradict [a + b] CHANGED"; (* NOT a predicate *)
   108 
   109 
   110 "----------- fun subpbl_to_caller --------------------------------------------------------------";
   111 "----------- fun subpbl_to_caller --------------------------------------------------------------";
   112 "----------- fun subpbl_to_caller --------------------------------------------------------------";
   113 val ctxt = Proof_Context.init_global @{theory "Isac_Knowledge"}
   114 
   115 val sub_ctxt = ContextC.insert_assumptions
   116   [TermC.str2term "a < (fro::int)", TermC.str2term "b < (fro::int)"] ctxt
   117 val prog_res = TermC.str2term "[x_1 = 1, x_2 = (2::int), x_3 = 3]";
   118 
   119 (* NO contradiction ..*)
   120 val caller_ctxt = ContextC.insert_assumptions
   121   [TermC.str2term "b < (to::int)", TermC.str2term "c < (to::int)"] ctxt
   122 val (t, new_ctxt) = subpbl_to_caller sub_ctxt prog_res caller_ctxt;
   123 
   124 if UnparseC.term t = "[x_1 = 1, x_2 = 2, x_3 = 3]" andalso map UnparseC.term (get_assumptions new_ctxt) =
   125   ["b < fro", "x_1 = 1", "x_2 = 2", "x_3 = 3", "b < to", "c < to"]
   126 then () else error "fun subpbl_to_caller changed 1";
   127 
   128 (* a contradiction ..*)
   129 val caller_ctxt = ContextC.insert_assumptions
   130   [TermC.str2term "b < (to::int)", TermC.str2term "x_2 \<noteq> (2::int)"] ctxt
   131 val (t, new_ctxt) = subpbl_to_caller sub_ctxt prog_res caller_ctxt;
   132 
   133 if UnparseC.term t = "[x_1 = 1, x_3 = 3]" andalso map UnparseC.term (get_assumptions new_ctxt) =
   134   ["b < fro", "x_1 = 1", "x_3 = 3", "b < to", "x_2 \<noteq> 2"]
   135 then () else error "fun subpbl_to_caller changed 2";
   136 
   137 
   138 "----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
   139 "----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
   140 "----------- rat-equ: remove x = 0 from [x = 0, x = 6 / 5] due to contexts ---------------------";
   141 (*ER-7*) (*Schalk I s.87 Bsp 55b*)
   142 val fmz = ["equality (x/(x \<up> 2 - 6*x+9) - 1/(x \<up> 2 - 3*x) =1/x)",
   143 	   "solveFor x", "solutions L"];
   144 val spec = ("RatEq",["univariate", "equation"],["no_met"]);
   145 val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, spec)];                          (* 0. specify-phase *)
   146 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   147 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   148 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   149 
   150 (*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   151 (*+*)case nxt of  Apply_Method ["RatEq", "solve_rat_equation"] => ()
   152 (*+*)| _ => error "55b root specification broken";
   153 
   154 val (p,_,f,nxt,_,pt) = me nxt p [] pt;                                         (* 0. solve-phase*)
   155 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   156 val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "(3 + -1 * x + x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)";
   157 
   158 (*+*)if (Ctree.get_assumptions pt p |> map UnparseC.term) =
   159 (*+*)  ["x \<noteq> 0", 
   160 (*+*)  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0", 
   161 (*+*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x"]
   162 (*+*)then () else error "assumptions before 1. Subproblem CHANGED";
   163 (*+*)if p = ([3], Res) andalso f2str f = "(3 + -1 * x + x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)"
   164 (*+*)then
   165 (*+*)  ((case nxt of Subproblem ("PolyEq", ["normalise", "polynomial", "univariate", "equation"]) => ()
   166 (*+*)  | _ => error ("S.68, Bsp.: 40 nxt =" ^ Tactic.input_to_string nxt)))
   167 (*+*)else error "1. Subproblem -- call changed";
   168 
   169 val (p,_,f,nxt,_,pt) = me nxt p [] pt;                                     (* 1. specify-phase *)
   170 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   171 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   172 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   173 
   174 (*[4], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   175 case nxt of Apply_Method ["PolyEq", "normalise_poly"] => ()
   176 | _ => error "55b normalise_poly specification broken 1";
   177 
   178 val (p,_,f,nxt,_,pt) = me nxt p [] pt;                                       (* 1. solve-phase *)
   179 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   180 val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "-6 * x + 5 * x \<up> 2 = 0";
   181 
   182 if p = ([4, 3], Res) andalso f2str f = "-6 * x + 5 * x \<up> 2 = 0"
   183 then
   184   ((case nxt of Subproblem ("PolyEq", ["bdv_only", "degree_2", "polynomial", "univariate", "equation"]) => ()
   185   | _ => error ("S.68, Bsp.: 40 nxt =" ^ Tactic.input_to_string nxt)))
   186 else error "xxx";
   187 
   188 val (p,_,f,nxt,_,pt) = me nxt p [] pt;                                     (* 2. specify-phase *)
   189 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   190 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   191 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   192 
   193 (*[4, 4], Met*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>*)
   194 case nxt of Apply_Method ["PolyEq", "solve_d2_polyeq_bdvonly_equation"] => ()
   195 | _ => error "55b normalise_poly specification broken 2";
   196 
   197 val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*f = "-6 * x + 5 * x \<up> 2 = 0"*)    (* 2. solve-phase *)
   198 val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   199 
   200 (*[4, 4, 3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>Or_to_List*)
   201 (*[4, 4, 4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "[x = 0, x = 6 / 5]";
   202 (*[4, 4, 5], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*\<rightarrow>2. Check_Postcond ["bdv_only", "degree_2", "polynomial", "univariate", "equation"]*)
   203 
   204 (*     *)if eq_set op = ((Ctree.get_assumptions pt p |> map UnparseC.term), [
   205 (*0.pre*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
   206 (*1.pre*)  "\<not> matches (?a = 0)\n        ((3 + -1 * x + x \<up> 2) * x =\n         1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) \<or>\n"
   207 (*1.pre*)    ^ "\<not> lhs ((3 + -1 * x + x \<up> 2) * x =\n            1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) is_poly_in x",
   208 (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x", 
   209 (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) has_degree_in x = 2",
   210 (*0.asm*)  "x \<noteq> 0", 
   211 (*0.asm*)  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0"
   212 (*     *)])
   213 (*     *)then () else error "assumptions at end 2. Subproblem CHANGED";
   214 (*[4, 4], Res*)val (p''''',_,f,nxt''''',_,pt''''') = me nxt p [] pt;(*\<rightarrow>1. Check_Postcond ["normalise", "polynomial", "univariate", "equation"]*)
   215 
   216 (*/--------- step into 2. Check_Postcond -----------------------------------------------------\*)
   217 "~~~~~ fun me , args:"; val (tac, p, _(*NEW remove*), pt) = (nxt, p, [], pt);
   218 
   219     val ("ok", (([(Check_Postcond ["bdv_only", "degree_2", "polynomial", "univariate", "equation"], _, _)]), _, _)) = (*case*)
   220       Step.by_tactic tac (pt, p) (*of*);
   221 "~~~~~ fun by_tactic , args:"; val (m, (ptp as (pt, p))) = (tac, (pt, p));
   222     val Applicable.Yes m = (*case*) Step.check m (pt, p) (*of*);
   223 	    (*if*) Tactic.for_specify' m (*else*);
   224 
   225     val ("ok", (([(Check_Postcond ["bdv_only", "degree_2", "polynomial", "univariate", "equation"], _, _)]), _, _)) =
   226 Step_Solve.by_tactic m ptp;
   227 "~~~~~ fun by_tactic , args:"; val ((tac as Tactic.Check_Postcond' _), (ptp as (pt, p))) = (m, ptp);
   228 
   229         LI.by_tactic tac (get_istate_LI pt p, get_ctxt_LI pt p) ptp;
   230 "~~~~~ fun by_tactic , args:"; val ((Tactic.Check_Postcond' (pI, res)), (sub_ist, sub_ctxt), (pt, pos as (p, _)))
   231   = (tac, (get_istate_LI pt p, get_ctxt_LI pt p), ptp);
   232       val parent_pos = par_pblobj pt p
   233       val {scr, ...} = MethodC.from_store (get_obj g_metID pt parent_pos);
   234       val prog_res =
   235          case LI.find_next_step scr (pt, pos) sub_ist sub_ctxt of
   236 (*OLD*)    Next_Step (_, _, Tactic.Check_elementwise' (_, _, (prog_res, _))) => prog_res
   237   |(*OLD*) End_Program (_, Tactic.Check_Postcond' (_, prog_res)) => prog_res
   238 (*OLD*)  | _ => raise ERROR ("Step_Solve.by_tactic Check_Postcond " ^ strs2str' pI)
   239 (*OLD* )   vvv--- handled by ctxt \<rightarrow> drop ( *OLD*)
   240 (*OLD*)val asm = (*?!? Rfun,Rrls rm case*)(case get_obj g_tac pt p of
   241 (*OLD*)    Tactic.Check_elementwise _ => (snd o (get_obj g_result pt)) p
   242 (*OLD*)  | _ => Ctree.get_assumptions pt pos);
   243 (*OLD* )val tac = Tactic.Check_Postcond' (pI, (prog_res, asm))
   244 ( *OLD*)
   245       (*if*) parent_pos = [] (*else*);
   246 (*NEW*)   val (ist_parent, ctxt_parent) = case get_loc pt (parent_pos, Frm) of
   247 (*NEW*)     (Pstate i, c) => (i, c)
   248 (*NEW*)   | _ => error "LI.by_tactic Check_Postcond': uncovered case get_loc";
   249 
   250 (*     *)if eq_set op = (map UnparseC.term (get_assumptions ctxt_parent), [
   251 (*0.pre*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
   252 (*1.pre*)  "\<not> matches (?a = 0)\n        ((3 + -1 * x + x \<up> 2) * x =\n         1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) \<or>\n"
   253 (*1.pre*)    ^ "\<not> lhs ((3 + -1 * x + x \<up> 2) * x =\n            1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) is_poly_in x",
   254 (*0.asm*)  "x \<noteq> 0", 
   255 (*0.asm*)  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0"
   256 (*     *)])
   257 (*     *)then () else error "assumptions at xxx CHANGED";
   258 
   259 	        val (prog_res', ctxt') =
   260   ContextC.subpbl_to_caller sub_ctxt prog_res ctxt_parent;
   261 (*     *)if eq_set op = (map UnparseC.term (get_assumptions ctxt'), [
   262 (*0.pre*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
   263 (*1.pre*)  "\<not> matches (?a = 0)\n        ((3 + -1 * x + x \<up> 2) * x =\n         1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) \<or>\n"
   264 (*1.pre*)    ^ "\<not> lhs ((3 + -1 * x + x \<up> 2) * x =\n            1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) is_poly_in x",
   265 (*0.asm*)  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0",
   266 (*0.asm*)  "x \<noteq> 0",             (* <----------------------- "x \<noteq> 0" contradiction resoved ---\*)
   267 (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x", 
   268 (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) has_degree_in x = 2",
   269 (*2.res*)  (*"x \<noteq> 0",*) "x = 6 / 5" (* <---------------- "x \<noteq> 0" would contradict "x = 0" ---/*)
   270 (*     *)])
   271 (*     *)then () else error "assumptions at xxx CHANGED";
   272 
   273 "~~~~~ fun subpbl_to_caller , args:"; val (sub_ctxt, prog_res, caller_ctxt)
   274   = (sub_ctxt, prog_res, ctxt_parent);
   275 val xxxxx = caller_ctxt
   276   |> get_assumptions 
   277   |> avoid_contradict prog_res
   278   |> apsnd (insert_assumptions_cao caller_ctxt)
   279   |> apsnd (transfer_asms_from_to sub_ctxt);
   280 
   281      xxxxx (*return from xxx*);
   282 "~~~~~ from fun subpbl_to_caller \<longrightarrow>fun by_tactic , return:"; val (prog_res', ctxt')
   283   = (xxxxx);
   284 (*NEW*)   val tac = Tactic.Check_Postcond' (pI, prog_res')
   285 (*NEW*)   val ist' = Pstate (ist_parent |> set_act prog_res |> set_found)
   286 (*NEW*)   val ((p, p_), ps, _, pt) = Step.add tac (ist', ctxt') (pt, (parent_pos, Res));
   287 
   288 (*NEW*)   ("ok", ([(Tactic.input_from_T tac, tac, ((parent_pos, Res), (ist', ctxt')))], ps, (pt, (p, p_))))
   289            (*return from xxx*);
   290 "~~~~~ from fun LI.by_tactic \<longrightarrow>fun Step_Solve.by_tactic \<longrightarrow>fun Step.by_tactic \<longrightarrow>fun me, return:"; val (("ok", (_, _, (pt, p))))
   291   = ("ok", ([(Tactic.input_from_T tac, tac, ((parent_pos, Res), (ist', ctxt')))], ps, (pt, (p, p_))));
   292   val ("ok", (ts as (_, _, _) :: _, _, _)) =
   293     (*case*) Step.do_next p ((pt, Pos.e_pos'), []) (*of*);
   294   	  val tac = 
   295         case ts of 
   296           tacis as (_::_) => let val (tac, _, _) = last_elem tacis in tac end 
   297   		  | _ => if p = ([], Pos.Res) then Tactic.End_Proof' else Tactic.Empty_Tac;
   298                               
   299 "~~~~~ from fun me \<longrightarrow>toplevel , return:"; val (p''''',_,f,nxt''''',_,pt''''')
   300   = (p, [] : NEW, TESTg_form (pt, p) (* form output comes from Step.by_tactic *), 
   301   	    tac, Celem.Sundef, pt);
   302 (*\--------- step into 2. Check_Postcond -----------------------------------------------------/*)
   303 
   304 (*[4], Res*)val (p,_,f,nxt,_,pt) = me nxt''''' p''''' [] pt''''';(*\<rightarrow>IDLE LEGACY: Check_elementwise "Assumptions"*)
   305 (*[], Res*)val (p,_,f,nxt,_,pt) = me nxt''''' p''''' [] pt''''';(*\<rightarrow>End_Proof'*)
   306 
   307 (*/-------- final test -----------------------------------------------------------------------\*)
   308 if f2str f = "[x = 6 / 5]" andalso map UnparseC.term (Ctree.get_assumptions pt p) =
   309  ["x = 6 / 5", "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x",
   310   "lhs (-6 * x + 5 * x \<up> 2 = 0) has_degree_in x = 2",
   311   "\<not> matches (?a = 0)\n        ((3 + -1 * x + x \<up> 2) * x =\n         1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) \<or>\n\<not> lhs ((3 + -1 * x + x \<up> 2) * x =\n            1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) is_poly_in x",
   312   "x \<noteq> 0", "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0",
   313   "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x"]
   314 then () else error "test CHANGED";