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