merged
authorwneuper <walther.neuper@jku.at>
Sun, 18 Jul 2021 18:15:27 +0200
changeset 6033140eb8aa2b0d6
parent 60316 63cecf440235
parent 60330 e5e9a6c45597
child 60332 a05877a9f19b
merged
TODO.md
src/Tools/isac/BaseDefinitions/termC.sml
src/Tools/isac/BaseDefinitions/thmC-def.sml
src/Tools/isac/Knowledge/Base_Tools.thy
src/Tools/isac/Knowledge/Diff.thy
src/Tools/isac/Knowledge/EqSystem.thy
src/Tools/isac/Knowledge/Poly.thy
src/Tools/isac/Knowledge/PolyEq.thy
src/Tools/isac/Knowledge/PolyMinus.thy
src/Tools/isac/Knowledge/Rational.thy
src/Tools/isac/Knowledge/Root.thy
src/Tools/isac/Knowledge/RootRat.thy
src/Tools/isac/Knowledge/Simplify.thy
src/Tools/isac/Knowledge/Test.thy
src/Tools/isac/MathEngBasic/rewrite.sml
src/Tools/isac/ProgLang/Calculate.thy
src/Tools/isac/ProgLang/Prog_Expr.thy
src/Tools/isac/ProgLang/evaluate.sml
test/Tools/isac/ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform.thy
test/Tools/isac/BaseDefinitions/substitution.sml
test/Tools/isac/BaseDefinitions/termC.sml
test/Tools/isac/BridgeLibisabelle/thy-hierarchy.sml
test/Tools/isac/BridgeLibisabelle/thy-present.sml
test/Tools/isac/Interpret/lucas-interpreter.sml
test/Tools/isac/Knowledge/biegelinie-1.sml
test/Tools/isac/Knowledge/diff.sml
test/Tools/isac/Knowledge/diffapp.sml
test/Tools/isac/Knowledge/eqsystem.sml
test/Tools/isac/Knowledge/integrate.sml
test/Tools/isac/Knowledge/partial_fractions.sml
test/Tools/isac/Knowledge/poly-2.sml
test/Tools/isac/Knowledge/poly.sml
test/Tools/isac/Knowledge/polyeq-1.sml
test/Tools/isac/Knowledge/rational-2.sml
test/Tools/isac/Knowledge/rational.sml
test/Tools/isac/Knowledge/rlang.sml
test/Tools/isac/Knowledge/rooteq.sml
test/Tools/isac/Knowledge/rootrat.sml
test/Tools/isac/MathEngBasic/rewrite.sml
test/Tools/isac/MathEngBasic/thmC.sml
test/Tools/isac/Minisubpbl/100-init-rootpbl.sml
test/Tools/isac/Minisubpbl/250-Rewrite_Set-from-method.sml
test/Tools/isac/Minisubpbl/600-postcond-NEXT_STEP.sml
test/Tools/isac/ProgLang/evaluate.sml
test/Tools/isac/ProgLang/listC.sml
test/Tools/isac/ProgLang/prog_expr.sml
test/Tools/isac/Specify/m-match.sml
test/Tools/isac/Specify/o-model.sml
     1.1 --- a/TODO.md	Mon Jun 21 22:08:01 2021 +0200
     1.2 +++ b/TODO.md	Sun Jul 18 18:15:27 2021 +0200
     1.3 @@ -63,4 +63,18 @@
     1.4      - sometimes this requires to use proper definitional mechanisms (e.g. 'primrec', 'fun');
     1.5      - a few "hard" cases will remain, to be reconsidered eventually (e.g. differentiation);
     1.6  
     1.7 +* WN: eliminate ThmC.numerals_to_Free, use existing Isabelle/HOL representation, DONE partially;
     1.8 +  + TOODOO are exclusive for this changeset; most follow from TOODOO.1
     1.9 +  + TOODOO.1: exception TYPE raised by Skip_Proof.make_thm 
    1.10 +  + ? how to do algebraic operations on numerals ? Presburger ? simplifier ?
    1.11 +  + clarify role of type "real" vs. "float" (see theory "HOL-Library.Float");
    1.12 +
    1.13 +* WN: DONE cleanup remaining ^^^ in comments (but sometimes it is just ASCII art), partially;
    1.14 +      Left ^^^ in doc-isac (old master-theses, etc: "x^^^#2 + #8" ... # are left, too)
    1.15 +      Left "ASCII art" in case of indicating comments pointing at facts ABOVE.
    1.16 +
    1.17  * WN: "fun pr_ord" is not required if used with @{make_string}, @{print}, @{print tracing};
    1.18 +      ???
    1.19 +
    1.20 +* WN: reduce the number of TermC.parse*;
    1.21 +    - one or two variants should suffice.
     2.1 --- a/src/Tools/isac/BaseDefinitions/BaseDefinitions.thy	Mon Jun 21 22:08:01 2021 +0200
     2.2 +++ b/src/Tools/isac/BaseDefinitions/BaseDefinitions.thy	Sun Jul 18 18:15:27 2021 +0200
     2.3 @@ -13,6 +13,18 @@
     2.4  
     2.5  ML \<open>
     2.6  \<close> ML \<open>
     2.7 +\<close> ML \<open> (**)
     2.8 +\<close> ML \<open>
     2.9 +HOLogic.dest_number: term -> typ * int;
    2.10 +HOLogic.dest_numeral: term -> int;
    2.11 +\<close> ML \<open>
    2.12 +TermC.to_string: term -> string
    2.13 +\<close> ML \<open>
    2.14 +TermC.to_string
    2.15 +\<close> ML \<open>
    2.16 +\<close> ML \<open>
    2.17 +\<close> ML \<open>
    2.18 +\<close> ML \<open>
    2.19  \<close> ML \<open>
    2.20  \<close>
    2.21  end
    2.22 \ No newline at end of file
     3.1 --- a/src/Tools/isac/BaseDefinitions/libraryC.sml	Mon Jun 21 22:08:01 2021 +0200
     3.2 +++ b/src/Tools/isac/BaseDefinitions/libraryC.sml	Sun Jul 18 18:15:27 2021 +0200
     3.3 @@ -61,6 +61,7 @@
     3.4    val pair2tri: ('a * 'b) * 'c -> 'a * 'b * 'c
     3.5    val snd3: 'a * 'b * 'c -> 'b
     3.6    val spair2str: string * string -> string
     3.7 +  val string_of_int': int -> string
     3.8  
     3.9    val split_nlast: int * 'a list -> 'a list * 'a list
    3.10    val string_to_bool: string -> bool
    3.11 @@ -175,6 +176,10 @@
    3.12  fun spair2str (s1, s2) =   "(" ^ quote s1  ^ ", " ^ quote s2 ^ ")";
    3.13  fun pair2str_ (s1, s2) =   s1 ^ "#" ^ s2;
    3.14  fun pair2str (s1, s2) =   "(" ^ s1 ^ ", " ^ s2 ^ ")";
    3.15 +(* accomodate string-representation for int to term-orders in Poly.thy and Rational.thy*)
    3.16 +fun string_of_int' i =
    3.17 +    if i >= 0 then i |> string_of_int
    3.18 +    else (i * ~1) |> string_of_int |> curry op ^ "-"
    3.19  
    3.20  val int2str = Library.string_of_int;
    3.21  fun ints2str' ints = (strs2str' o (map string_of_int)) ints;
     4.1 --- a/src/Tools/isac/BaseDefinitions/termC.sml	Mon Jun 21 22:08:01 2021 +0200
     4.2 +++ b/src/Tools/isac/BaseDefinitions/termC.sml	Sun Jul 18 18:15:27 2021 +0200
     4.3 @@ -26,17 +26,21 @@
     4.4    val inst_abs: term -> term
     4.5    val inst_bdv: (term * term) list -> term -> term
     4.6  
     4.7 +  val mk_frac: typ -> int * (int * int) -> term
     4.8 +  val numerals_to_Free: term -> term
     4.9    val term_of_num: typ -> int -> term
    4.10    val num_of_term: term -> int
    4.11 +  val to_string: term -> string
    4.12    val int_of_str: string -> int
    4.13    val isastr_of_int: int -> string
    4.14 -  val int_opt_of_string: string -> int option  (* belongs to TermC *)
    4.15 +  val int_opt_of_string: string -> int option
    4.16  
    4.17    val isalist2list: term -> term list
    4.18    val list2isalist: typ -> term list -> term
    4.19    val isapair2pair: term -> term * term (* rename to dest_pair, compare HOLogic.dest_string *)
    4.20  
    4.21    val is_atom: term -> bool
    4.22 +  val string_of_atom: term -> string
    4.23    val is_const: term -> bool
    4.24    val is_variable: term -> bool
    4.25    val is_bdv: string -> bool
    4.26 @@ -50,6 +54,7 @@
    4.27    val dest_listT: typ -> typ
    4.28    val is_num: term -> bool
    4.29    val is_num': string -> bool
    4.30 +  val string_of_num: term -> string
    4.31    val variable_constant_pair: term * term -> bool
    4.32  
    4.33    val mk_add: term -> term -> term
    4.34 @@ -63,7 +68,6 @@
    4.35    val mk_var_op_num: term -> string -> typ -> typ -> int -> term
    4.36  
    4.37    val matches: theory -> term -> term -> bool
    4.38 -  val parse_strict: theory -> string -> term
    4.39    val parse: theory -> string -> cterm option
    4.40    val parseN: theory -> string -> cterm option
    4.41    val parseNEW: Proof.context -> string -> term option
    4.42 @@ -89,13 +93,14 @@
    4.43    val uminus_to_string: term -> term
    4.44  
    4.45    val var2free: term -> term
    4.46 -  val vars: term -> term list  (* recognises numerals, should replace "fun vars_of" *)
    4.47 +  val vars: term -> term list  (* recognises numerals, should replace "fun vars_of" TODOO*)
    4.48    val vars': term list -> term list
    4.49 -  val vars_of: term -> term list   (* deprecated *)
    4.50 +  val vars_of: term -> term list   (* deprecated TODOO: see differences in test/../termC.sml*)
    4.51    val dest_list': term -> term list
    4.52    val negates: term -> term -> bool
    4.53  
    4.54  \<^isac_test>\<open>
    4.55 +  val mk_negative: typ -> term -> term
    4.56    val scala_of_term: term -> string
    4.57    val atomtyp(*<-- atom_typ TODO*): typ -> unit
    4.58    val atomty: term -> unit
    4.59 @@ -246,13 +251,46 @@
    4.60  val int_of_str = Value.parse_int;
    4.61  
    4.62  val int_opt_of_string = ThmC_Def.int_opt_of_string
    4.63 +fun is_num' str = case int_opt_of_string str of SOME _ => true | NONE => false;
    4.64  
    4.65 -fun is_num' str = case int_opt_of_string str of SOME _ => true | NONE => false;
    4.66 -fun is_num (Free (s, _)) = if is_num' s then true else false | is_num _ = false;
    4.67 -fun term_of_num ntyp n = Free (str_of_int n, ntyp);
    4.68 -fun num_of_term (t as (Free (istr, _))) = 
    4.69 -    (case int_opt_of_string istr of SOME i => i | NONE => raise TERM ("num_of_term: NOT int ", [t]))
    4.70 -  | num_of_term t = raise TERM ("num_of_term: NOT Free ", [t])
    4.71 +fun is_num (Const ("Num.numeral_class.numeral", _) $ _) = true
    4.72 +  | is_num (Const ("Groups.uminus_class.uminus", _) $
    4.73 +    (Const ("Num.numeral_class.numeral", _) $ _)) = true
    4.74 +  | is_num (Const ("Groups.one_class.one", _)) = true
    4.75 +  | is_num (Const ("Groups.uminus_class.uminus", _) $ Const ("Groups.one_class.one", _)) = true
    4.76 +  | is_num (Const ("Groups.zero_class.zero", _)) = true
    4.77 +  | is_num (Const ("Groups.uminus_class.uminus", _) $ Const ("Groups.zero_class.zero", _)) = true
    4.78 +  | is_num _ = false;
    4.79 +
    4.80 +fun string_of_num n = (n |> HOLogic.dest_number |> snd |> string_of_int)
    4.81 +
    4.82 +fun mk_negative T t = Const ("Groups.uminus_class.uminus", T --> T) $ t
    4.83 +fun mk_frac T (sg, (i1, i2)) =
    4.84 +  if sg = 1 then
    4.85 +    if i2 = 1 then HOLogic.mk_number T i1
    4.86 +    else Const ("Rings.divide_class.divide", T --> T --> T) $
    4.87 +      HOLogic.mk_number T i1 $ HOLogic.mk_number T i2
    4.88 +  else (*take negative*)
    4.89 +    if i2 = 1 then mk_negative T (HOLogic.mk_number T i1)
    4.90 +    else Const ("Rings.divide_class.divide", T --> T --> T) $
    4.91 +      mk_negative T (HOLogic.mk_number T i1) $ HOLogic.mk_number T i2
    4.92 +
    4.93 +val numerals_to_Free = (* Makarius 100308 *)
    4.94 +  let
    4.95 +    fun dest_num t =
    4.96 +      (case try HOLogic.dest_number t of
    4.97 +        SOME (T, i) => SOME (Free (signed_string_of_int i, T))
    4.98 +      | NONE => NONE);
    4.99 +    fun to_str (Abs (x, T, b)) = Abs (x, T, to_str b)
   4.100 +      | to_str (t as (u1 $ u2)) =
   4.101 +          (case dest_num t of SOME t' => t' | NONE => to_str u1 $ to_str u2)
   4.102 +      | to_str t = perhaps dest_num t;
   4.103 +  in to_str end
   4.104 +
   4.105 +val term_of_num = HOLogic.mk_number;
   4.106 +fun num_of_term t = t |> HOLogic.dest_number |> snd;
   4.107 +(* accomodate string-representation for int to term-orders *)
   4.108 +fun to_string t = t |> num_of_term |> LibraryC.string_of_int'
   4.109  
   4.110  fun is_const (Const _) = true | is_const _ = false;
   4.111  fun is_variable (t as Free _) = not (is_num t)
   4.112 @@ -273,7 +311,7 @@
   4.113  fun vars t =
   4.114    let
   4.115      fun scan vs (Const _) = vs
   4.116 -      | scan vs (t as Free (s, _)) = if is_num' s then vs else t :: vs
   4.117 +      | scan vs (t as Free _) = (*if is_num' s then vs else*) t :: vs
   4.118        | scan vs (t as Var _) = t :: vs
   4.119        | scan vs (Bound _) = vs 
   4.120        | scan vs (Abs (_, _, t)) = scan vs t
   4.121 @@ -436,10 +474,10 @@
   4.122  fun mk_factroot op_(*=thy.sqrt*) T fact root = 
   4.123    Const (\<^const_name>\<open>times\<close>, [T, T] ---> T) $ (term_of_num T fact) $
   4.124      (Const (op_, T --> T) $ term_of_num T root);
   4.125 -fun mk_var_op_num v op_ optype ntyp n = Const (op_, optype) $ v $ Free (str_of_int  n, ntyp);
   4.126 -fun mk_num_op_var v op_ optype ntyp n = Const (op_, optype) $ Free (str_of_int n, ntyp) $ v;
   4.127 +fun mk_var_op_num v op_ optype ntyp n = Const (op_, optype) $ v $ HOLogic.mk_number ntyp n;
   4.128 +fun mk_num_op_var v op_ optype ntyp n = Const (op_, optype) $ HOLogic.mk_number ntyp n $ v;
   4.129  fun mk_num_op_num T1 T2 (op_, Top) n1 n2 =
   4.130 -  Const (op_, Top) $ Free (str_of_int n1, T1) $ Free (str_of_int n2, T2);
   4.131 +  Const (op_, Top) $ HOLogic.mk_number T1 n1 $ HOLogic.mk_number T2 n2;
   4.132  fun mk_thmid thmid n1 n2 = 
   4.133    thmid ^ (strip_thy n1) ^ "_" ^ (strip_thy n2);
   4.134  fun mk_add t1 t2 =
   4.135 @@ -529,11 +567,13 @@
   4.136  fun parse_patt thy str = (thy, str)
   4.137    |>> ThyC.to_ctxt 
   4.138    |-> Proof_Context.read_term_pattern
   4.139 -  |> numbers_to_string (*TODO drop*)
   4.140 +(*|> numbers_to_string   TODO drop*)
   4.141    |> typ_a2real;       (*TODO drop*)
   4.142  fun str2term str = parse_patt (ThyC.get_theory "Isac_Knowledge") str
   4.143  
   4.144 -fun is_atom (Const ("Float.Float",_) $ _) = true
   4.145 +fun is_atom (Const ("Num.numeral_class.numeral", _) $ _) = true
   4.146 +  | is_atom (Const ("Groups.one_class.one", _)) = true
   4.147 +  | is_atom (Const ("Groups.zero_class.zero", _)) = true
   4.148    | is_atom (Const _) = true
   4.149    | is_atom (Free _) = true
   4.150    | is_atom (Var _) = true
   4.151 @@ -574,7 +614,7 @@
   4.152  val poly_consts = (* TODO: adopt syntax-const from Isabelle*)
   4.153    [\<^const_name>\<open>plus\<close>, \<^const_name>\<open>minus\<close>,
   4.154    \<^const_name>\<open>divide\<close>, \<^const_name>\<open>times\<close>,
   4.155 -  \<^const_name>\<open>powr\<close>];
   4.156 +  \<^const_name>\<open>powr\<close>],
   4.157  (* treat Free, Const, Var as variables in polynomials *)
   4.158  fun vars_of t =
   4.159    let
   4.160 @@ -617,4 +657,4 @@
   4.161    in trm' end
   4.162  
   4.163  
   4.164 -end
   4.165 \ No newline at end of file
   4.166 +end
     5.1 --- a/src/Tools/isac/BaseDefinitions/thmC-def.sml	Mon Jun 21 22:08:01 2021 +0200
     5.2 +++ b/src/Tools/isac/BaseDefinitions/thmC-def.sml	Sun Jul 18 18:15:27 2021 +0200
     5.3 @@ -50,7 +50,8 @@
     5.4  
     5.5  (** transform Isabelle's binary numerals to "Free (string, T)" **)
     5.6  
     5.7 -val num_to_Free = (* Makarius 100308 *)
     5.8 +val num_to_Free = (**)I(* Makarius 100308 *)
     5.9 +(** )
    5.10    let
    5.11      fun dest_num t =
    5.12        (case try HOLogic.dest_number t of
    5.13 @@ -61,8 +62,10 @@
    5.14            (case dest_num t of SOME t' => t' | NONE => to_str u1 $ to_str u2)
    5.15        | to_str t = perhaps dest_num t;
    5.16    in to_str end
    5.17 +( **)
    5.18  
    5.19 -val uminus_to_string =
    5.20 +val uminus_to_string = (**)I
    5.21 +(** )
    5.22    let
    5.23  	  fun dest_num t =
    5.24  	    case t of
    5.25 @@ -76,8 +79,10 @@
    5.26            (case dest_num t of SOME t' => t' | NONE => to_str u1 $ to_str u2)
    5.27        | to_str t = perhaps dest_num t;
    5.28    in to_str end;
    5.29 +( **)
    5.30  
    5.31 -fun numerals_to_Free thm =
    5.32 +fun numerals_to_Free thm = (**)thm
    5.33 +(** )
    5.34    let
    5.35      val prop = Thm.plain_prop_of thm
    5.36      val prop' = num_to_Free prop;
    5.37 @@ -87,5 +92,6 @@
    5.38        Skip_Proof.make_thm (Thm.theory_of_thm thm) prop'
    5.39        |> Thm.put_name_hint (Thm.get_name_hint thm)
    5.40    end;
    5.41 +( **)
    5.42  
    5.43  (**)end(**)
     6.1 --- a/src/Tools/isac/Build_Isac.thy	Mon Jun 21 22:08:01 2021 +0200
     6.2 +++ b/src/Tools/isac/Build_Isac.thy	Sun Jul 18 18:15:27 2021 +0200
     6.3 @@ -41,27 +41,23 @@
     6.4      ML_file contextC.sml
     6.5      ML_file environment.sml
     6.6  ( ** )    "BaseDefinitions/BaseDefinitions"( **)
     6.7 -
     6.8 -(*    theory Calculate imports "$ISABELLE_ISAC/BaseDefinitions/BaseDefinitions"
     6.9 -      $ISABELLE_ISAC/ProgLang
    6.10 +(*
    6.11 +      theory Calculate imports "$ISABELLE_ISAC/BaseDefinitions/BaseDefinitions"
    6.12 +        at $ISABELLE_ISAC/ProgLang
    6.13          ML_file evaluate.sml
    6.14 -
    6.15        theory ListC imports "$ISABELLE_ISAC/BaseDefinitions/BaseDefinitions"
    6.16 -      $ISABELLE_ISAC/ProgLang
    6.17 -    theory Prog_Expr imports Calculate ListC
    6.18 -    $ISABELLE_ISAC/ProgLang
    6.19        theory Program imports "$ISABELLE_ISAC/BaseDefinitions/BaseDefinitions"
    6.20 -      theory Prog_Tac imports "$ISABELLE_ISAC/BaseDefinitions/BaseDefinitions"
    6.21 +    theory Prog_Expr imports Calculate ListC Program
    6.22 +     theory Prog_Tac imports "$ISABELLE_ISAC/BaseDefinitions/BaseDefinitions"
    6.23        theory Tactical imports "$ISABELLE_ISAC/BaseDefinitions/BaseDefinitions"
    6.24 -    theory Auto_Prog imports Program Prog_Tac Tactical begin
    6.25 -    $ISABELLE_ISAC/ProgLang
    6.26 +    theory Auto_Prog imports Prog_Tac Tactical
    6.27    theory ProgLang imports Prog_Expr Auto_Prog
    6.28 -  $ISABELLE_ISAC/ProgLang
    6.29 +    at $ISABELLE_ISAC/ProgLang
    6.30  ( ** )    "ProgLang/ProgLang"( **)
    6.31  (*
    6.32    theory MathEngBasic imports
    6.33      "$ISABELLE_ISAC/ProgLang/ProgLang" "$ISABELLE_ISAC/Specify/Input_Descript"
    6.34 -  $ISABELLE_ISAC/MathEngBasic
    6.35 +    at $ISABELLE_ISAC/MathEngBasic
    6.36      ML_file thmC.sml
    6.37      ML_file problem.sml
    6.38      ML_file method.sml
     7.1 --- a/src/Tools/isac/Knowledge/Base_Tools.thy	Mon Jun 21 22:08:01 2021 +0200
     7.2 +++ b/src/Tools/isac/Knowledge/Base_Tools.thy	Sun Jul 18 18:15:27 2021 +0200
     7.3 @@ -6,7 +6,8 @@
     7.4  begin
     7.5  subsection \<open>theorems for Base_Tools\<close>
     7.6  
     7.7 -lemma real_unari_minus:   "- a = (-1) * (a::real)" by auto
     7.8 +lemma real_unari_minus:   "Not (a is_const) ==> - a = (-1) * (a::real)" by auto
     7.9 +(*lemma real_unari_minus:   "- a = (-1) * (a::real)" by auto LOOPS WITH NUMERALS*)
    7.10  (*Semiring_Normalization.comm_ring_1_class.ring_normalization_rules(1)*)
    7.11  
    7.12  (* should be in Rational.thy, but needed for asms in e.g. d2_pqformula1 in PolyEq, RootEq... *)
     8.1 --- a/src/Tools/isac/Knowledge/Diff.thy	Mon Jun 21 22:08:01 2021 +0200
     8.2 +++ b/src/Tools/isac/Knowledge/Diff.thy	Sun Jul 18 18:15:27 2021 +0200
     8.3 @@ -87,6 +87,8 @@
     8.4    realpow_pow_bdv: "(bdv \<up> b) \<up> c = bdv \<up> (b * c)"
     8.5  
     8.6  ML \<open>
     8.7 +val thy = @{theory};
     8.8 +
     8.9  (** eval functions **)
    8.10  
    8.11  fun primed (Const (id, T)) = Const (id ^ "'", T)
    8.12 @@ -149,7 +151,13 @@
    8.13  	 preconds = [], 
    8.14  	 rew_ord = ("termlessI",termlessI), 
    8.15  	 erls = Rule_Set.append_rules "erls_diff_sym_conv" Rule_Set.empty 
    8.16 -			   [\<^rule_eval>\<open>less\<close> (Prog_Expr.eval_equ "#less_")], 
    8.17 +			   [\<^rule_eval>\<open>less\<close> (Prog_Expr.eval_equ "#less_"), 
    8.18 +
    8.19 +           Rule.Eval ("Prog_Expr.matches", Prog_Expr.eval_matches "#matches_"),
    8.20 +	   Rule.Eval ("Prog_Expr.is_atom", Prog_Expr.eval_is_atom "#is_atom_"),
    8.21 +	   Rule.Eval ("Orderings.ord_class.less", Prog_Expr.eval_equ "#less_"),
    8.22 +	   Rule.Thm ("not_false", ThmC.numerals_to_Free @{thm not_false}),
    8.23 +	   Rule.Thm ("not_true", ThmC.numerals_to_Free @{thm not_true})], 
    8.24  	 srls = Rule_Set.Empty, calc = [], errpatts = [],
    8.25  	 rules = [\<^rule_thm>\<open>frac_sym_conv\<close>,
    8.26  		  \<^rule_thm>\<open>sqrt_sym_conv\<close>,
    8.27 @@ -404,6 +412,7 @@
    8.28    Problem: "derivative_of/function"
    8.29  
    8.30  ML \<open>
    8.31 +
    8.32  (*.handle cas-input like "Differentiate (A = s * (a - s), s)".*)
    8.33  (* val (t, pairl) = strip_comb (str2term "Differentiate (A = s * (a - s), s)");
    8.34     val [Const (\<^const_name>\<open>Pair\<close>, _) $ t $ bdv] = pairl;
     9.1 --- a/src/Tools/isac/Knowledge/EqSystem.thy	Mon Jun 21 22:08:01 2021 +0200
     9.2 +++ b/src/Tools/isac/Knowledge/EqSystem.thy	Sun Jul 18 18:15:27 2021 +0200
     9.3 @@ -49,6 +49,8 @@
     9.4      works for lists of any length, interestingly !?!*)
     9.5  
     9.6  ML \<open>
     9.7 +val thy = @{theory};
     9.8 +
     9.9  (** eval functions **)
    9.10  
    9.11  (*certain variables of a given list occur _all_ in a term
    9.12 @@ -65,7 +67,7 @@
    9.13      end;
    9.14  
    9.15  (*("occur_exactly_in", ("EqSystem.occur_exactly_in", 
    9.16 -			eval_occur_exactly_in "#eval_occur_exactly_in_"))*)
    9.17 +                        eval_occur_exactly_in "#eval_occur_exactly_in_") )*)
    9.18  fun eval_occur_exactly_in _ "EqSystem.occur_exactly_in"
    9.19  			  (p as (Const ("EqSystem.occur_exactly_in",_) 
    9.20  				       $ vs $ all $ t)) _ =
    9.21 @@ -153,8 +155,8 @@
    9.22      (term_ord' pr thy (Library.swap tu) = LESS);*)
    9.23  
    9.24  (*for the rls's*)
    9.25 -fun ord_simplify_System (pr:bool) thy _(*subst*) tu = 
    9.26 -    (term_ord' pr thy tu = LESS);
    9.27 +fun ord_simplify_System (pr:bool) thy _(*subst*) (ts, us) = 
    9.28 +    (term_ord' pr thy (TermC.numerals_to_Free ts, TermC.numerals_to_Free us) = LESS);
    9.29  (**)
    9.30  end;
    9.31  (**)
    9.32 @@ -336,7 +338,9 @@
    9.33  		     erls = Rule_Set.Empty, srls = Rule_Set.Empty, calc = [], errpatts = [],
    9.34  		     rules = [(*for precond NTH_CONS ...*)
    9.35  			      \<^rule_eval>\<open>less\<close> (Prog_Expr.eval_equ "#less_"),
    9.36 -			      \<^rule_eval>\<open>plus\<close> (**)(eval_binop "#add_")
    9.37 +			      \<^rule_eval>\<open>plus\<close> (**)(eval_binop "#add_"),
    9.38 +            Rule.Eval ("EqSystem.occur_exactly_in", 
    9.39 +              eval_occur_exactly_in "#eval_occur_exactly_in_")
    9.40  			      (*immediately repeated rewrite pushes
    9.41  					    '+' into precondition !*)
    9.42  			      ],
    10.1 --- a/src/Tools/isac/Knowledge/Isac_Knowledge.thy	Mon Jun 21 22:08:01 2021 +0200
    10.2 +++ b/src/Tools/isac/Knowledge/Isac_Knowledge.thy	Sun Jul 18 18:15:27 2021 +0200
    10.3 @@ -26,6 +26,7 @@
    10.4  ML \<open>
    10.5    val version_isac = "isac version 120504 15:33";
    10.6  \<close> ML \<open>
    10.7 +TermC.numerals_to_Free
    10.8  \<close> ML \<open>
    10.9  \<close>
   10.10  end
    11.1 --- a/src/Tools/isac/Knowledge/Poly.thy	Mon Jun 21 22:08:01 2021 +0200
    11.2 +++ b/src/Tools/isac/Knowledge/Poly.thy	Sun Jul 18 18:15:27 2021 +0200
    11.3 @@ -181,19 +181,29 @@
    11.4    [\<^const_name>\<open>plus\<close>, \<^const_name>\<open>minus\<close>,
    11.5    \<^const_name>\<open>divide\<close>, \<^const_name>\<open>times\<close>,
    11.6    \<^const_name>\<open>powr\<close>];
    11.7 +
    11.8 +val int_ord_SAVE = int_ord;
    11.9 +(*for tests on rewrite orders*)
   11.10 +fun int_ord (i1, i2) =
   11.11 +(@{print} {a = "int_ord (" ^ string_of_int i1 ^ ", " ^ string_of_int i2 ^ ") = ", z = Int.compare (i1, i2)};
   11.12 +  Int.compare (i1, i2));
   11.13 +(**)val int_ord = int_ord_SAVE; (*..outcomment for tests*)
   11.14  \<close>
   11.15  subsubsection \<open>for predicates in specifications (ML)\<close>
   11.16  ML \<open>
   11.17  (*--- auxiliary for is_expanded_in, is_poly_in, has_degree_in ---*)
   11.18 -(*. a 'monomial t in variable v' is a term t with
   11.19 +(*. a "monomial t in variable v" is a term t with
   11.20    either (1) v NOT existent in t, or (2) v contained in t,
   11.21    if (1) then degree 0
   11.22 -  if (2) then v is a factor on the very right, ev. with exponent.*)
   11.23 +  if (2) then v is a factor on the very right, casually with exponent.*)
   11.24  fun factor_right_deg (*case 2*)
   11.25 -	    (Const (\<^const_name>\<open>times\<close>, _) $ t1 $ (Const (\<^const_name>\<open>powr\<close>,_) $ vv $ Free (d, _))) v =
   11.26 -	   if vv = v andalso not (Prog_Expr.occurs_in v t1) then SOME (TermC.int_of_str d) else NONE
   11.27 -  | factor_right_deg (Const (\<^const_name>\<open>powr\<close>,_) $ vv $ Free (d,_)) v =
   11.28 -	   if (vv = v) then SOME (TermC.int_of_str d) else NONE
   11.29 +	    (Const ("Groups.times_class.times", _) $
   11.30 +        t1 $ (Const ("Transcendental.powr",_) $ vv $ num)) v =
   11.31 +	  if vv = v andalso not (Prog_Expr.occurs_in v t1) then SOME (snd (HOLogic.dest_number num))
   11.32 +    else NONE
   11.33 +  | factor_right_deg (Const ("Transcendental.powr",_) $ vv $ num) v =
   11.34 +	   if (vv = v) then SOME (snd (HOLogic.dest_number num)) else NONE
   11.35 +
   11.36    | factor_right_deg (Const (\<^const_name>\<open>times\<close>,_) $ t1 $ vv) v = 
   11.37  	   if vv = v andalso not (Prog_Expr.occurs_in v t1) then SOME 1 else NONE
   11.38    | factor_right_deg vv v =
   11.39 @@ -267,18 +277,18 @@
   11.40  
   11.41  (* liefert Variablenname (String) einer Variablen und Basis bei Potenz *)
   11.42  fun get_basStr (Const (\<^const_name>\<open>powr\<close>,_) $ Free (str, _) $ _) = str
   11.43 +  | get_basStr (Const ("Transcendental.powr",_) $ n $ _) = TermC.to_string n
   11.44    | get_basStr (Free (str, _)) = str
   11.45 -  | get_basStr _ = "|||"; (* gross gewichtet; für Brüch ect. *)
   11.46 -(*| get_basStr t = 
   11.47 -    raise ERROR("get_basStr: called with t= "^(UnparseC.term t));*)
   11.48 +  | get_basStr t =
   11.49 +    if TermC.is_num t then TermC.to_string t
   11.50 +    else "|||"; (* gross gewichtet; für Brüche ect. *)
   11.51  
   11.52  (* liefert Hochzahl (String) einer Variablen bzw Gewichtstring (zum Sortieren) *)
   11.53 -fun get_potStr (Const (\<^const_name>\<open>powr\<close>,_) $ Free _ $ Free (str, _)) = str
   11.54 -  | get_potStr (Const (\<^const_name>\<open>powr\<close>,_) $ Free _ $ _ ) = "|||" (* gross gewichtet *)
   11.55 -  | get_potStr (Free (_, _)) = "---" (* keine Hochzahl --> kleinst gewichtet *)
   11.56 +fun get_potStr (Const ("Transcendental.powr", _) $ Free _ $ Free (str, _)) = str
   11.57 +  | get_potStr (Const ("Transcendental.powr", _) $ Free _ $ t) =
   11.58 +    if TermC.is_num t then TermC.to_string t else "|||"
   11.59 +  | get_potStr (Free _) = "---" (* keine Hochzahl --> kleinst gewichtet *)
   11.60    | get_potStr _ = "||||||"; (* gross gewichtet; für Brüch ect. *)
   11.61 -(*| get_potStr t = 
   11.62 -    raise ERROR("get_potStr: called with t= "^(UnparseC.term t));*)
   11.63  
   11.64  (* Umgekehrte string_ord *)
   11.65  val string_ord_rev =  rev_order o string_ord;
   11.66 @@ -287,104 +297,131 @@
   11.67      innerhalb eines Monomes:
   11.68      - zuerst lexikographisch nach Variablenname 
   11.69      - wenn gleich: nach steigender Potenz *)
   11.70 -fun var_ord (a,b: term) = prod_ord string_ord string_ord 
   11.71 +fun var_ord (a, b) = 
   11.72 +(@{print} {a = "var_ord ", a_b = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")",
   11.73 +   sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"};
   11.74 +  prod_ord string_ord string_ord 
   11.75 +  ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b))
   11.76 +);
   11.77 +fun var_ord (a,b: term) = 
   11.78 +  prod_ord string_ord string_ord 
   11.79      ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b));
   11.80  
   11.81  (* Ordnung zum lexikographischen Vergleich zweier Variablen (oder Potenzen); 
   11.82     verwendet zum Sortieren von Monomen mittels Gesamtgradordnung:
   11.83     - zuerst lexikographisch nach Variablenname 
   11.84     - wenn gleich: nach sinkender Potenz*)
   11.85 -fun var_ord_revPow (a,b: term) = prod_ord string_ord string_ord_rev 
   11.86 +fun var_ord_revPow (a, b: term) = 
   11.87 +(@{print} {a = "var_ord_revPow ", at_bt = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")",
   11.88 +    sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"};
   11.89 +  prod_ord string_ord string_ord_rev 
   11.90 +    ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b))
   11.91 +);
   11.92 +fun var_ord_revPow (a, b: term) =
   11.93 +  prod_ord string_ord string_ord_rev 
   11.94      ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b));
   11.95  
   11.96  
   11.97  (* Ordnet ein Liste von Variablen (und Potenzen) lexikographisch *)
   11.98 +fun sort_varList ts =
   11.99 +(@{print} {a = "sort_varList", args = UnparseC.terms ts};
  11.100 +  sort var_ord ts);
  11.101  val sort_varList = sort var_ord;
  11.102  
  11.103  (* Entfernet aeussersten Operator (Wurzel) aus einem Term und schreibt 
  11.104     Argumente in eine Liste *)
  11.105  fun args u : term list =
  11.106 -    let fun stripc (f$t, ts) = stripc (f, t::ts)
  11.107 -	  | stripc (t as Free _, ts) = (t::ts)
  11.108 -	  | stripc (_, ts) = ts
  11.109 -    in stripc (u, []) end;
  11.110 +  let
  11.111 +    fun stripc (f $ t, ts) = stripc (f, t::ts)
  11.112 +  	  | stripc (t as Free _, ts) = (t::ts)
  11.113 +  	  | stripc (_, ts) = ts
  11.114 +  in stripc (u, []) end;
  11.115                                      
  11.116  (* liefert True, falls der Term (Liste von Termen) nur Zahlen 
  11.117     (keine Variablen) enthaelt *)
  11.118 -fun filter_num [] = true
  11.119 -  | filter_num [Free x] = if (TermC.is_num (Free x)) then true
  11.120 -				else false
  11.121 -  | filter_num ((Free _)::_) = false
  11.122 -  | filter_num ts =
  11.123 -    (filter_num o (filter_out TermC.is_num) o flat o (map args)) ts;
  11.124 +fun filter_num ts = fold (curry and_) (map TermC.is_num ts) true
  11.125  
  11.126  (* liefert True, falls der Term nur Zahlen (keine Variablen) enthaelt 
  11.127     dh. er ist ein numerischer Wert und entspricht einem Koeffizienten *)
  11.128  fun is_nums t = filter_num [t];
  11.129  
  11.130  (* Berechnet den Gesamtgrad eines Monoms *)
  11.131 -local 
  11.132 -    fun counter (n, []) = n
  11.133 -      | counter (n, x :: xs) = 
  11.134 -	if (is_nums x) then
  11.135 -	    counter (n, xs) 
  11.136 -	else 
  11.137 -	    (case x of 
  11.138 -		 (Const (\<^const_name>\<open>powr\<close>, _) $ Free _ $ Free (str_h, T)) => 
  11.139 -		     if (is_nums (Free (str_h, T))) then
  11.140 -			 counter (n + (the (TermC.int_opt_of_string str_h)), xs)
  11.141 -		     else counter (n + 1000, xs) (*FIXME.MG?!*)
  11.142 -	       | (Const (\<^const_name>\<open>powr\<close>, _) $ Free _ $ _ ) => 
  11.143 -		     counter (n + 1000, xs) (*FIXME.MG?!*)
  11.144 -	       | (Free _) => counter (n + 1, xs)
  11.145 -	     (*| _ => raise ERROR("monom_degree: called with factor: "^(UnparseC.term x)))*)
  11.146 -	       | _ => counter (n + 10000, xs)) (*FIXME.MG?! ... Brüche ect.*)
  11.147 -in  
  11.148 -    fun monom_degree l = counter (0, l) 
  11.149 -end;(*local*)
  11.150 +(**)local(**)
  11.151 +  fun counter (n, []) = n
  11.152 +    | counter (n, x :: xs) = 
  11.153 +	    if (is_nums x) then counter (n, xs)
  11.154 +	    else 
  11.155 +	      (case x of 
  11.156 +		      (Const ("Transcendental.powr", _) $ Free _ $ t) =>
  11.157 +            if TermC.is_num t
  11.158 +            then counter (t |> HOLogic.dest_number |> snd |> curry op + n, xs)
  11.159 +            else counter (n + 1000, xs) (*FIXME.MG?!*)
  11.160 +	      | (Const ("Num.numeral_class.numeral", _) $ num) =>
  11.161 +            counter (n + 1 + HOLogic.dest_numeral num, xs)
  11.162 +	      | _ => counter (n + 1, xs)) (*FIXME.MG?! ... Brüche ect.*)
  11.163 +(**)in(**)
  11.164 +  fun monom_degree l = counter (0, l) 
  11.165 +(**)end;(*local*)
  11.166  
  11.167  (* wie Ordnung dict_ord (lexicographische Ordnung zweier Listen, mit Vergleich 
  11.168     der Listen-Elemente mit elem_ord) - Elemente die Bedingung cond erfuellen, 
  11.169     werden jedoch dabei ignoriert (uebersprungen)  *)
  11.170 +fun dict_cond_ord _ _ ([], [])     = (@{print} {a = "dict_cond_ord ([], [])"}; EQUAL)
  11.171 +  | dict_cond_ord _ _ ([], _ :: _) = (@{print} {a = "dict_cond_ord ([], _ :: _)"}; LESS)
  11.172 +  | dict_cond_ord _ _ (_ :: _, []) = (@{print} {a = "dict_cond_ord (_ :: _, [])"}; GREATER)
  11.173 +  | dict_cond_ord elem_ord cond (x :: xs, y :: ys) =
  11.174 +    (@{print} {a = "dict_cond_ord", args = "(" ^ UnparseC.terms (x :: xs) ^ ", " ^ UnparseC.terms (y :: ys) ^ ")", 
  11.175 +      is_nums = "(" ^ LibraryC.bool2str (cond x) ^ ", " ^ LibraryC.bool2str (cond y) ^ ")"};
  11.176 +     case (cond x, cond y) of 
  11.177 +	    (false, false) =>
  11.178 +        (case elem_ord (x, y) of 
  11.179 +				  EQUAL => dict_cond_ord elem_ord cond (xs, ys) 
  11.180 +			  | ord => ord)
  11.181 +    | (false, true)  => dict_cond_ord elem_ord cond (x :: xs, ys)
  11.182 +    | (true, false)  => dict_cond_ord elem_ord cond (xs, y :: ys)
  11.183 +    | (true, true)  =>  dict_cond_ord elem_ord cond (xs, ys) );
  11.184  fun dict_cond_ord _ _ ([], []) = EQUAL
  11.185    | dict_cond_ord _ _ ([], _ :: _) = LESS
  11.186    | dict_cond_ord _ _ (_ :: _, []) = GREATER
  11.187    | dict_cond_ord elem_ord cond (x :: xs, y :: ys) =
  11.188      (case (cond x, cond y) of 
  11.189 -	 (false, false) => (case elem_ord (x, y) of 
  11.190 -				EQUAL => dict_cond_ord elem_ord cond (xs, ys) 
  11.191 -			      | ord => ord)
  11.192 -       | (false, true)  => dict_cond_ord elem_ord cond (x :: xs, ys)
  11.193 -       | (true, false)  => dict_cond_ord elem_ord cond (xs, y :: ys)
  11.194 -       | (true, true)  =>  dict_cond_ord elem_ord cond (xs, ys) );
  11.195 +	    (false, false) =>
  11.196 +        (case elem_ord (x, y) of 
  11.197 +				  EQUAL => dict_cond_ord elem_ord cond (xs, ys) 
  11.198 +			  | ord => ord)
  11.199 +    | (false, true)  => dict_cond_ord elem_ord cond (x :: xs, ys)
  11.200 +    | (true, false)  => dict_cond_ord elem_ord cond (xs, y :: ys)
  11.201 +    | (true, true)  =>  dict_cond_ord elem_ord cond (xs, ys) );
  11.202  
  11.203  (* Gesamtgradordnung zum Vergleich von Monomen (Liste von Variablen/Potenzen):
  11.204     zuerst nach Gesamtgrad, bei gleichem Gesamtgrad lexikographisch ordnen - 
  11.205     dabei werden Koeffizienten ignoriert (2*3*a \<up> 2*4*b gilt wie a \<up> 2*b) *)
  11.206  fun degree_ord (xs, ys) =
  11.207 -	    prod_ord int_ord (dict_cond_ord var_ord_revPow is_nums) 
  11.208 -	    ((monom_degree xs, xs), (monom_degree ys, ys));
  11.209 +	prod_ord int_ord (dict_cond_ord var_ord_revPow is_nums)
  11.210 +	  ((monom_degree xs, xs), (monom_degree ys, ys));
  11.211  
  11.212  fun hd_str str = substring (str, 0, 1);
  11.213  fun tl_str str = substring (str, 1, (size str) - 1);
  11.214  
  11.215  (* liefert nummerischen Koeffizienten eines Monoms oder NONE *)
  11.216 -fun get_koeff_of_mon [] =  raise ERROR("get_koeff_of_mon: called with l = []")
  11.217 -  | get_koeff_of_mon (x::_) = if is_nums x then SOME x else NONE;
  11.218 +fun get_koeff_of_mon [] = raise ERROR "get_koeff_of_mon: called with l = []"
  11.219 +  | get_koeff_of_mon (x :: _) = if is_nums x then SOME x else NONE;
  11.220  
  11.221  (* wandelt Koeffizient in (zum sortieren geeigneten) String um *)
  11.222 -fun koeff2ordStr (SOME x) = (case x of 
  11.223 -				 (Free (str, _)) => 
  11.224 -				     if (hd_str str) = "-" then (tl_str str)^"0" (* 3 < -3 *)
  11.225 -				     else str
  11.226 -			       | _ => "aaa") (* "num.Ausdruck" --> gross *)
  11.227 -  | koeff2ordStr NONE = "---"; (* "kein Koeff" --> kleinste *)
  11.228 +fun koeff2ordStr (SOME t) =
  11.229 +    if TermC.is_num t
  11.230 +    then 
  11.231 +      if (t |> HOLogic.dest_number |> snd) < 0
  11.232 +      then (t |> HOLogic.dest_number |> snd |> curry op * ~1 |> string_of_int) ^ "0"  (* 3 < -3 *)
  11.233 +      else (t |> HOLogic.dest_number |> snd |> string_of_int)
  11.234 +    else "aaa"                                                      (* "num.Ausdruck" --> gross *)
  11.235 +  | koeff2ordStr NONE = "---";                                     (* "kein Koeff" --> kleinste *)
  11.236  
  11.237  (* Order zum Vergleich von Koeffizienten (strings): 
  11.238     "kein Koeff" < "0" < "1" < "-1" < "2" < "-2" < ... < "num.Ausdruck" *)
  11.239 -fun compare_koeff_ord (xs, ys) = 
  11.240 -    string_ord ((koeff2ordStr o get_koeff_of_mon) xs,
  11.241 -		(koeff2ordStr o get_koeff_of_mon) ys);
  11.242 +fun compare_koeff_ord (xs, ys) = string_ord
  11.243 +  ((koeff2ordStr o get_koeff_of_mon) xs,
  11.244 +   (koeff2ordStr o get_koeff_of_mon) ys);
  11.245  
  11.246  (* Gesamtgradordnung degree_ord + Ordnen nach Koeffizienten falls EQUAL *)
  11.247  fun koeff_degree_ord (xs, ys) =
  11.248 @@ -430,22 +467,22 @@
  11.249  
  11.250  (* sorts the variables (faktors) of an expanded polynomial lexicographical *)
  11.251  fun sort_variables t = 
  11.252 -    let
  11.253 -	val ll =  map monom2list (poly2list t);
  11.254 -	val lls = map sort_varList ll; 
  11.255 -	val T = type_of t;
  11.256 -	val ls = map (create_monom T) lls;
  11.257 -    in create_polynom T ls end;
  11.258 +  let
  11.259 +  	val ll = map monom2list (poly2list t);
  11.260 +  	val lls = map sort_varList ll; 
  11.261 +  	val T = type_of t;
  11.262 +  	val ls = map (create_monom T) lls;
  11.263 +  in create_polynom T ls end;
  11.264  
  11.265  (* sorts the monoms of an expanded and variable-sorted polynomial 
  11.266     by total_degree *)
  11.267  fun sort_monoms t = 
  11.268 -    let
  11.269 -	val ll =  map monom2list (poly2list t);
  11.270 -	val lls = sort_monList ll;
  11.271 -	val T = type_of t;
  11.272 -	val ls = map (create_monom T) lls;
  11.273 -    in create_polynom T ls end;
  11.274 +  let
  11.275 +  	val ll =  map monom2list (poly2list t);
  11.276 +  	val lls = sort_monList ll;
  11.277 +  	val T = Term.type_of t;
  11.278 +  	val ls = map (create_monom T) lls;
  11.279 +  in create_polynom T ls end;
  11.280  \<close>
  11.281  
  11.282  subsubsection \<open>rewrite order for hard-coded AC rewriting\<close>
  11.283 @@ -462,7 +499,7 @@
  11.284    (case a of
  11.285       \<^const_name>\<open>powr\<close> => ((("|||||||||||||", 0), T), 0)    (*WN greatest string*)
  11.286     | _ => (((a, 0), T), 0))
  11.287 -  | dest_hd' (Free (a, T)) = (((a, 0), T), 1)
  11.288 +  | dest_hd' (Free (a, T)) = (((a, 0), T), 1)(*TODOO handle this as numeral, too? see EqSystem.thy*)
  11.289    | dest_hd' (Var v) = (v, 2)
  11.290    | dest_hd' (Bound i) = ((("", i), dummyT), 3)
  11.291    | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4)
  11.292 @@ -505,8 +542,8 @@
  11.293  
  11.294  in
  11.295  
  11.296 -fun ord_make_polynomial (pr:bool) thy (_: subst) tu = 
  11.297 -    (term_ord' pr thy(***) tu = LESS );
  11.298 +fun ord_make_polynomial (pr:bool) thy (_: subst) (ts, us) =
  11.299 +    (term_ord' pr thy(***) (TermC.numerals_to_Free ts, TermC.numerals_to_Free us) = LESS );
  11.300  
  11.301  end;(*local*)
  11.302  
  11.303 @@ -536,19 +573,35 @@
  11.304     this is weaker than 'is_polynomial' !.*)
  11.305  fun is_polyexp (Free _) = true
  11.306    | is_polyexp (Const _) = true (* potential danger: bdv is not considered *)
  11.307 -  | is_polyexp (Const (\<^const_name>\<open>plus\<close>,_) $ Free _ $ Free _) = true
  11.308 -  | is_polyexp (Const (\<^const_name>\<open>minus\<close>,_) $ Free _ $ Free _) = true
  11.309 -  | is_polyexp (Const (\<^const_name>\<open>times\<close>,_) $ Free _ $ Free _) = true
  11.310 -  | is_polyexp (Const (\<^const_name>\<open>powr\<close>,_) $ Free _ $ Free _) = true
  11.311 -  | is_polyexp (Const (\<^const_name>\<open>plus\<close>,_) $ t1 $ t2) = 
  11.312 -               ((is_polyexp t1) andalso (is_polyexp t2))
  11.313 -  | is_polyexp (Const (\<^const_name>\<open>minus\<close>,_) $ t1 $ t2) = 
  11.314 -               ((is_polyexp t1) andalso (is_polyexp t2))
  11.315 -  | is_polyexp (Const (\<^const_name>\<open>times\<close>,_) $ t1 $ t2) = 
  11.316 -               ((is_polyexp t1) andalso (is_polyexp t2))
  11.317 -  | is_polyexp (Const (\<^const_name>\<open>powr\<close>,_) $ t1 $ t2) = 
  11.318 -               ((is_polyexp t1) andalso (is_polyexp t2))
  11.319 -  | is_polyexp _ = false;
  11.320 +  | is_polyexp (Const ("Groups.plus_class.plus",_) $ Free _ $ num) =
  11.321 +    if TermC.is_num num then true
  11.322 +    else if TermC.is_variable num then true
  11.323 +    else is_polyexp num
  11.324 +  | is_polyexp (Const ("Groups.plus_class.plus",_) $ num $ Free _) =
  11.325 +    if TermC.is_num num then true
  11.326 +    else if TermC.is_variable num then true
  11.327 +    else is_polyexp num
  11.328 +  | is_polyexp (Const ("Groups.minus_class.minus",_) $ Free _ $ num) =
  11.329 +    if TermC.is_num num then true
  11.330 +    else if TermC.is_variable num then true
  11.331 +    else is_polyexp num
  11.332 +  | is_polyexp (Const ("Groups.times_class.times",_) $ num $ Free _) =
  11.333 +    if TermC.is_num num then true
  11.334 +    else if TermC.is_variable num then true
  11.335 +    else is_polyexp num
  11.336 +  | is_polyexp (Const ("Transcendental.powr",_) $ Free _ $ num) =
  11.337 +    if TermC.is_num num then true
  11.338 +    else if TermC.is_variable num then true
  11.339 +    else is_polyexp num
  11.340 +  | is_polyexp (Const ("Groups.plus_class.plus",_) $ t1 $ t2) = 
  11.341 +    ((is_polyexp t1) andalso (is_polyexp t2))
  11.342 +  | is_polyexp (Const ("Groups.minus_class.minus",_) $ t1 $ t2) = 
  11.343 +    ((is_polyexp t1) andalso (is_polyexp t2))
  11.344 +  | is_polyexp (Const ("Groups.times_class.times",_) $ t1 $ t2) = 
  11.345 +    ((is_polyexp t1) andalso (is_polyexp t2))
  11.346 +  | is_polyexp (Const ("Transcendental.powr",_) $ t1 $ t2) = 
  11.347 +    ((is_polyexp t1) andalso (is_polyexp t2))
  11.348 +  | is_polyexp num = TermC.is_num num;
  11.349  \<close>
  11.350  
  11.351  subsubsection \<open>for hard-coded AC rewriting\<close>
  11.352 @@ -675,20 +728,36 @@
  11.353  	       (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
  11.354  	       ], scr = Rule.Empty_Prog};
  11.355  
  11.356 +(* erls for calculate_Rational + etc *)
  11.357 +val powers_erls =
  11.358 +  Rule_Def.Repeat {id = "powers_erls", preconds = [], rew_ord = ("dummy_ord",Rewrite_Ord.dummy_ord), 
  11.359 +      erls = Rule_Set.empty, srls = Rule_Set.Empty, calc = [], errpatts = [],
  11.360 +      rules = 
  11.361 +        [Rule.Eval ("Prog_Expr.matches", Prog_Expr.eval_matches "#matches_"),
  11.362 +	       Rule.Eval ("Prog_Expr.is_atom", Prog_Expr.eval_is_atom "#is_atom_"),
  11.363 +	       Rule.Eval ("Prog_Expr.is_even", Prog_Expr.eval_is_even "#is_even_"),
  11.364 +	       Rule.Eval ("Orderings.ord_class.less", Prog_Expr.eval_equ "#less_"),
  11.365 +	       Rule.Thm ("not_false", ThmC.numerals_to_Free @{thm not_false}),
  11.366 +	       Rule.Thm ("not_true", ThmC.numerals_to_Free @{thm not_true}),
  11.367 +	       Rule.Eval ("Groups.plus_class.plus", (**)eval_binop "#add_")
  11.368 +	       ],
  11.369 +      scr = Rule.Empty_Prog
  11.370 +      };
  11.371 +
  11.372  val discard_minus =
  11.373    Rule_Def.Repeat {id = "discard_minus", preconds = [], rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
  11.374 -      erls = Rule_Set.empty, srls = Rule_Set.Empty, calc = [], errpatts = [],
  11.375 +      erls = powers_erls, srls = Rule_Set.Empty, calc = [], errpatts = [],
  11.376        rules =
  11.377         [\<^rule_thm>\<open>real_diff_minus\<close>,
  11.378            (*"a - b = a + -1 * b"*)
  11.379 -	        \<^rule_thm_sym>\<open>real_mult_minus1\<close>
  11.380 -	          (*- ?z = "-1 * ?z"*)],
  11.381 +        Rule.Thm ("real_mult_minus1_sym", ThmC.numerals_to_Free (@{thm real_mult_minus1_sym}))
  11.382 +	        (*"\<not>(z is_const) ==> - (z::real) = -1 * z"*)],
  11.383  	      scr = Rule.Empty_Prog};
  11.384  
  11.385  val expand_poly_ = 
  11.386    Rule_Def.Repeat{id = "expand_poly_", preconds = [], 
  11.387        rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
  11.388 -      erls = Rule_Set.empty,srls = Rule_Set.Empty,
  11.389 +      erls = powers_erls, srls = Rule_Set.Empty,
  11.390        calc = [], errpatts = [],
  11.391        rules =
  11.392          [\<^rule_thm>\<open>real_plus_binom_pow4\<close>,
  11.393 @@ -715,16 +784,25 @@
  11.394  	       
  11.395  	         \<^rule_thm>\<open>realpow_multI\<close>,
  11.396  	           (*"(r * s) \<up> n = r \<up> n * s \<up> n"*)
  11.397 -	         \<^rule_thm>\<open>realpow_pow\<close>
  11.398 +	         \<^rule_thm>\<open>realpow_pow\<close>,
  11.399  	           (*"(a \<up> b) \<up> c = a \<up> (b * c)"*)
  11.400 +(**)
  11.401 +	         Rule.Thm ("realpow_minus_even",ThmC.numerals_to_Free @{thm realpow_minus_even}),
  11.402 +	           (*"n is_even ==> (- r) \<up> n = r \<up> n"*)
  11.403 +	         Rule.Thm ("realpow_minus_odd",ThmC.numerals_to_Free @{thm realpow_minus_odd})
  11.404 +	           (*"Not (n is_even) ==> (- r) \<up> n = -1 * r \<up> n"*)
  11.405 +(**)
  11.406  	       ], scr = Rule.Empty_Prog};
  11.407  
  11.408  val expand_poly_rat_ = 
  11.409    Rule_Def.Repeat{id = "expand_poly_rat_", preconds = [], 
  11.410        rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
  11.411 -      erls =  Rule_Set.append_rules "Rule_Set.empty-is_polyexp" Rule_Set.empty
  11.412 -	        [\<^rule_eval>\<open>is_polyexp\<close> (eval_is_polyexp "")
  11.413 -		 ],
  11.414 +      erls =  Rule_Set.append_rules "Rule_Set.empty-expand_poly_rat_" Rule_Set.empty
  11.415 +	        [Rule.Eval ("Poly.is_polyexp", eval_is_polyexp ""),
  11.416 +	         Rule.Eval ("Prog_Expr.is_even", Prog_Expr.eval_is_even "#is_even_"),
  11.417 +	         Rule.Thm ("not_false", ThmC.numerals_to_Free @{thm not_false}),
  11.418 +	         Rule.Thm ("not_true", ThmC.numerals_to_Free @{thm not_true})
  11.419 +		      ],
  11.420        srls = Rule_Set.Empty,
  11.421        calc = [], errpatts = [],
  11.422        rules = 
  11.423 @@ -751,8 +829,12 @@
  11.424  	 \<^rule_thm>\<open>realpow_multI_poly\<close>,
  11.425  	     (*"[| r is_polyexp; s is_polyexp |] ==> 
  11.426  		            (r * s) \<up> n = r \<up> n * s \<up> n"*)
  11.427 -	  \<^rule_thm>\<open>realpow_pow\<close>
  11.428 -	      (*"(a \<up> b) \<up> c = a \<up> (b * c)"*)
  11.429 +	 Rule.Thm ("realpow_pow",ThmC.numerals_to_Free @{thm realpow_pow}),
  11.430 +	   (*"(a \<up> b) \<up> c = a \<up> (b * c)"*)
  11.431 +	 Rule.Thm ("realpow_minus_even",ThmC.numerals_to_Free @{thm realpow_minus_even}),
  11.432 +	   (*"n is_even ==> (- r) \<up> n = r \<up> n"*)
  11.433 +	 Rule.Thm ("realpow_minus_odd",ThmC.numerals_to_Free @{thm realpow_minus_odd})
  11.434 +	   (*"\<not> (n is_even) ==> (- r) \<up> n = -1 * r \<up> n"*)
  11.435  	 ], scr = Rule.Empty_Prog};
  11.436  
  11.437  val simplify_power_ = 
  11.438 @@ -875,10 +957,9 @@
  11.439  val expand_poly =
  11.440    Rule_Def.Repeat{id = "expand_poly", preconds = [], 
  11.441        rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord),
  11.442 -      erls = Rule_Set.empty,srls = Rule_Set.Empty,
  11.443 -      calc = [], errpatts = [],
  11.444 -      (*asm_thm = [],*)
  11.445 -      rules = [\<^rule_thm>\<open>distrib_right\<close>,
  11.446 +      erls = powers_erls, srls = Rule_Set.Empty, calc = [], errpatts = [],
  11.447 +      rules = 
  11.448 +        [Rule.Thm ("distrib_right" ,ThmC.numerals_to_Free @{thm distrib_right}),
  11.449  	       (*"(z1.0 + z2.0) * w = z1.0 * w + z2.0 * w"*)
  11.450  	       \<^rule_thm>\<open>distrib_left\<close>,
  11.451  	       (*"w * (z1.0 + z2.0) = w * z1.0 + w * z2.0"*)
  11.452 @@ -898,8 +979,8 @@
  11.453  	       (*"- (- ?z) = ?z"*)
  11.454  	       \<^rule_thm>\<open>real_diff_minus\<close>,
  11.455  	       (*"a - b = a + -1 * b"*)
  11.456 -	       \<^rule_thm_sym>\<open>real_mult_minus1\<close>
  11.457 -	       (*- ?z = "-1 * ?z"*)
  11.458 +	       Rule.Thm ("real_mult_minus1_sym", ThmC.numerals_to_Free (@{thm real_mult_minus1_sym}))
  11.459 +	       (*"\<not>(z is_const) ==> - (z::real) = -1 * z"*)
  11.460  
  11.461  	       (*\<^rule_thm>\<open>real_minus_add_distrib\<close>,*)
  11.462  	       (*"- (?x + ?y) = - ?x + - ?y"*)
    12.1 --- a/src/Tools/isac/Knowledge/PolyEq.thy	Mon Jun 21 22:08:01 2021 +0200
    12.2 +++ b/src/Tools/isac/Knowledge/PolyEq.thy	Sun Jul 18 18:15:27 2021 +0200
    12.3 @@ -319,28 +319,30 @@
    12.4    separate_1_bdv_n:       "bdv \<up> n / b = (1 / b) * bdv \<up> n"
    12.5  
    12.6  ML \<open>
    12.7 +val thy = @{theory};
    12.8 +
    12.9  (*-------------------------rulse-------------------------*)
   12.10  val PolyEq_prls = (*3.10.02:just the following order due to subterm evaluation*)
   12.11    Rule_Set.append_rules "PolyEq_prls" Rule_Set.empty 
   12.12 -	     [\<^rule_eval>\<open>Prog_Expr.ident\<close> (Prog_Expr.eval_ident "#ident_"),
   12.13 -	      \<^rule_eval>\<open>Prog_Expr.matches\<close> (Prog_Expr.eval_matches ""),
   12.14 -	      \<^rule_eval>\<open>Prog_Expr.lhs\<close> (Prog_Expr.eval_lhs ""),
   12.15 -	      \<^rule_eval>\<open>Prog_Expr.rhs\<close> (Prog_Expr.eval_rhs ""),
   12.16 -	      \<^rule_eval>\<open>is_expanded_in\<close> (eval_is_expanded_in ""),
   12.17 -	      \<^rule_eval>\<open>is_poly_in\<close> (eval_is_poly_in ""),
   12.18 -	      \<^rule_eval>\<open>has_degree_in\<close> (eval_has_degree_in ""),    
   12.19 -        \<^rule_eval>\<open>is_polyrat_in\<close> (eval_is_polyrat_in ""),
   12.20 -	      (*\<^rule_eval>\<open>Prog_Expr.occurs_in\<close> (Prog_Expr.eval_occurs_in ""),   *) 
   12.21 -	      (*\<^rule_eval>\<open>Prog_Expr.is_const\<close> (Prog_Expr.eval_const "#is_const_"),*)
   12.22 -	      \<^rule_eval>\<open>HOL.eq\<close> (Prog_Expr.eval_equal "#equal_"),
   12.23 -        \<^rule_eval>\<open>is_rootTerm_in\<close> (eval_is_rootTerm_in ""),
   12.24 -	      \<^rule_eval>\<open>is_ratequation_in\<close> (eval_is_ratequation_in ""),
   12.25 -	      \<^rule_thm>\<open>not_true\<close>,
   12.26 -	      \<^rule_thm>\<open>not_false\<close>,
   12.27 -	      \<^rule_thm>\<open>and_true\<close>,
   12.28 -	      \<^rule_thm>\<open>and_false\<close>,
   12.29 -	      \<^rule_thm>\<open>or_true\<close>,
   12.30 -	      \<^rule_thm>\<open>or_false\<close>
   12.31 +	     [Rule.Eval ("Prog_Expr.ident", Prog_Expr.eval_ident "#ident_"),
   12.32 +	      Rule.Eval ("Prog_Expr.matches", Prog_Expr.eval_matches "#matches_"),
   12.33 +	      Rule.Eval ("Prog_Expr.lhs", Prog_Expr.eval_lhs ""),
   12.34 +	      Rule.Eval ("Prog_Expr.rhs", Prog_Expr.eval_rhs ""),
   12.35 +	      Rule.Eval ("Poly.is_expanded_in", eval_is_expanded_in ""),
   12.36 +	      Rule.Eval ("Poly.is_poly_in", eval_is_poly_in ""),
   12.37 +	      Rule.Eval ("Poly.has_degree_in", eval_has_degree_in ""),    
   12.38 +              Rule.Eval ("Poly.is_polyrat_in", eval_is_polyrat_in ""),
   12.39 +	      (*Rule.Eval ("Prog_Expr.occurs_in", Prog_Expr.eval_occurs_in ""),   *) 
   12.40 +	      (*Rule.Eval ("Prog_Expr.is_const", Prog_Expr.eval_const "#is_const_"),*)
   12.41 +	      Rule.Eval ("HOL.eq", Prog_Expr.eval_equal "#equal_"),
   12.42 +              Rule.Eval ("RootEq.is_rootTerm_in", eval_is_rootTerm_in ""),
   12.43 +	      Rule.Eval ("RatEq.is_ratequation_in", eval_is_ratequation_in ""),
   12.44 +	      Rule.Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
   12.45 +	      Rule.Thm ("not_false",ThmC.numerals_to_Free @{thm not_false}),
   12.46 +	      Rule.Thm ("and_true",ThmC.numerals_to_Free @{thm and_true}),
   12.47 +	      Rule.Thm ("and_false",ThmC.numerals_to_Free @{thm and_false}),
   12.48 +	      Rule.Thm ("or_true",ThmC.numerals_to_Free @{thm or_true}),
   12.49 +	      Rule.Thm ("or_false",ThmC.numerals_to_Free @{thm or_false})
   12.50  	       ];
   12.51  
   12.52  val PolyEq_erls = 
   12.53 @@ -1167,18 +1169,17 @@
   12.54    | dest_hd' _ (Abs (_, T, _)) = ((("", 0), T), 4)
   12.55    | dest_hd' _ _ = raise ERROR "dest_hd': uncovered case in fun.def.";
   12.56  
   12.57 -fun size_of_term' x (Const (\<^const_name>\<open>powr\<close>,_) $ Free (var,_) $ Free (pot,_)) =
   12.58 +fun size_of_term' x (Const ("Transcendental.powr",_) $
   12.59 +      Free (var, _) $ Const ("Num.numeral_class.numeral", _) $ pot) =
   12.60      (case x of                                                          (*WN*)
   12.61 -	    (Free (xstr,_)) => 
   12.62 -		(if xstr = var then 1000*(the (TermC.int_opt_of_string pot)) else 3)
   12.63 -	  | _ => raise ERROR ("size_of_term' called with subst = "^
   12.64 -			      (UnparseC.term x)))
   12.65 -  | size_of_term' x (Free (subst,_)) =
   12.66 +	    (Free (xstr, _)) => 
   12.67 +		    (if xstr = var then 1000 * (HOLogic.dest_numeral pot) else 3)
   12.68 +	  | _ => raise ERROR ("size_of_term' called with subst = " ^ UnparseC.term x))
   12.69 +  | size_of_term' x (Free (subst, _)) =
   12.70      (case x of
   12.71 -	    (Free (xstr,_)) => (if xstr = subst then 1000 else 1)
   12.72 -	  | _ => raise ERROR ("size_of_term' called with subst = "^
   12.73 -			  (UnparseC.term x)))
   12.74 -  | size_of_term' x (Abs (_,_,body)) = 1 + size_of_term' x body
   12.75 +	    (Free (xstr, _)) => (if xstr = subst then 1000 else 1)
   12.76 +	  | _ => raise ERROR ("size_of_term' called with subst = " ^ UnparseC.term x))
   12.77 +  | size_of_term' x (Abs (_, _, body)) = 1 + size_of_term' x body
   12.78    | size_of_term' x (f$t) = size_of_term' x f  +  size_of_term' x t
   12.79    | size_of_term' _ _ = 1;
   12.80  
   12.81 @@ -1215,12 +1216,12 @@
   12.82  and terms_ord x _ pr (ts, us) = 
   12.83      list_ord (term_ord' x pr (ThyC.get_theory "Isac_Knowledge"))(ts, us);
   12.84  
   12.85 -in
   12.86 +in(*local*)
   12.87  
   12.88 -fun ord_make_polynomial_in (pr:bool) thy subst tu =
   12.89 -  ((**)tracing ("*** subs variable is: " ^ (Env.subst2str subst)); (**)
   12.90 +fun ord_make_polynomial_in (pr:bool) thy subst (ts, us) =
   12.91 +  ((** )tracing ("*** subs variable is: " ^ (Env.subst2str subst)); ( **)
   12.92  	case subst of
   12.93 -	  (_, x) :: _ => (term_ord' x pr thy tu = LESS)
   12.94 +	  (_, x) :: _ => (term_ord' x pr thy (TermC.numerals_to_Free ts, TermC.numerals_to_Free us) = LESS)
   12.95  	| _ => raise ERROR ("ord_make_polynomial_in called with subst = " ^ Env.subst2str subst))
   12.96  
   12.97  end;(*local*)
   12.98 @@ -1229,8 +1230,7 @@
   12.99  ML\<open>
  12.100  val order_add_mult_in = prep_rls'(
  12.101    Rule_Def.Repeat{id = "order_add_mult_in", preconds = [], 
  12.102 -      rew_ord = ("ord_make_polynomial_in",
  12.103 -		 ord_make_polynomial_in false @{theory "Poly"}),
  12.104 +      rew_ord = ("ord_make_polynomial_in", ord_make_polynomial_in false @{theory "Poly"}),
  12.105        erls = Rule_Set.empty,srls = Rule_Set.Empty,
  12.106        calc = [], errpatts = [],
  12.107        rules = [\<^rule_thm>\<open>mult.commute\<close>,
    13.1 --- a/src/Tools/isac/Knowledge/PolyMinus.thy	Mon Jun 21 22:08:01 2021 +0200
    13.2 +++ b/src/Tools/isac/Knowledge/PolyMinus.thy	Sun Jul 18 18:15:27 2021 +0200
    13.3 @@ -105,75 +105,55 @@
    13.4    klammer_minus_mult:          "(b - c) * a = b * a - c * a"
    13.5  
    13.6  ML \<open>
    13.7 +val thy = @{theory};
    13.8 +
    13.9  (** eval functions **)
   13.10  
   13.11  (*. get the identifier from specific monomials; see fun ist_monom .*)
   13.12 -(*HACK.WN080107*)
   13.13 -fun increase str = 
   13.14 -  let
   13.15 -    val (s, ss) = 
   13.16 -      case Symbol.explode str of
   13.17 -        s :: ss => (s, ss)
   13.18 -      | _ => raise ERROR "PolyMinus.increase: uncovered case"
   13.19 -  in implode ((chr (ord s + 1))::ss) end;
   13.20 -fun identifier (Free (id,_)) = id                            (* 2     ,   a   *)
   13.21 -  | identifier (Const (\<^const_name>\<open>times\<close>, _) $ Free (_(*num*), _) $ Free (id, _)) = 
   13.22 -    id                                                       (* 2*a   , a*b *)
   13.23 -  | identifier (Const (\<^const_name>\<open>times\<close>, _) $                          (* 3*a*b    *)
   13.24 -		     (Const (\<^const_name>\<open>times\<close>, _) $
   13.25 -			    Free (num, _) $ Free _) $ Free (id, _)) = 
   13.26 -    if TermC.is_num' num then id
   13.27 +fun identifier (Free (id, _)) = id                                               (* //2, a   *)
   13.28 +(*TOODOO*)
   13.29 +  | identifier                                                                   (* 3*a*b    *)
   13.30 +      (Const ("Groups.times_class.times", _) $ (Const ("Groups.times_class.times", _) $
   13.31 +			   num $ t) $ Free (id, _)) = 
   13.32 +    if TermC.is_num num andalso TermC.is_atom t then id
   13.33      else "|||||||||||||"
   13.34 -  | identifier (Const (\<^const_name>\<open>powr\<close>, _) $ Free (base, _) $ Free (_(*exp*), _)) =
   13.35 -    if TermC.is_num' base then "|||||||||||||"                     (* a^2      *)
   13.36 -    else (*increase*) base
   13.37 -  | identifier (Const (\<^const_name>\<open>times\<close>, _) $ Free (num, _) $          (* 3*a^2    *)
   13.38 -		     (Const (\<^const_name>\<open>powr\<close>, _) $
   13.39 -			    Free (base, _) $ Free (_(*exp*), _))) = 
   13.40 -    if TermC.is_num' num andalso not (TermC.is_num' base) then (*increase*) base
   13.41 +
   13.42 +  | identifier                                                                   (* 2*a, a*b *)
   13.43 +      (Const ("Groups.times_class.times", _) $ num $ Free (id, _)) =
   13.44 +    if TermC.is_atom num then id
   13.45      else "|||||||||||||"
   13.46    | identifier _ = "|||||||||||||"(*the "largest" string*);
   13.47  
   13.48  (*("kleiner", ("PolyMinus.kleiner", eval_kleiner ""))*)
   13.49  (* order "by alphabet" w.r.t. var: num < (var | num*var) > (var*var | ..) *)
   13.50  fun eval_kleiner _ _ (p as (Const ("PolyMinus.kleiner",_) $ a $ b)) _  =
   13.51 -     if TermC.is_num b then
   13.52 -	 if TermC.is_num a then (*123 kleiner 32 = True !!!*)
   13.53 -	     if TermC.num_of_term a < TermC.num_of_term b then 
   13.54 -		 SOME ((UnparseC.term p) ^ " = True",
   13.55 -		       HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
   13.56 -	     else SOME ((UnparseC.term p) ^ " = False",
   13.57 -			HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
   13.58 -	 else (* -1 * -2 kleiner 0 *)
   13.59 -	     SOME ((UnparseC.term p) ^ " = False",
   13.60 -		   HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
   13.61 +    if TermC.is_num b then
   13.62 +  	  if TermC.is_num a then (*123 kleiner 32 = True !!!*)
   13.63 +  	    if TermC.num_of_term a < TermC.num_of_term b then 
   13.64 +  		    SOME ((UnparseC.term p) ^ " = True", 
   13.65 +            HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
   13.66 +  	    else SOME ((UnparseC.term p) ^ " = False",
   13.67 +  			  HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
   13.68 +  	  else (* -1 * -2 kleiner 0 *)
   13.69 +  	    SOME ((UnparseC.term p) ^ " = False",
   13.70 +  		    HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
   13.71      else
   13.72 -	if identifier a < identifier b then 
   13.73 -	     SOME ((UnparseC.term p) ^ " = True",
   13.74 -		  HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
   13.75 -	else SOME ((UnparseC.term p) ^ " = False",
   13.76 -		   HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
   13.77 +    	if identifier a < identifier b then 
   13.78 +    	  SOME ((UnparseC.term p) ^ " = True",
   13.79 +    		  HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
   13.80 +    	else SOME ((UnparseC.term p) ^ " = False",
   13.81 +    		HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
   13.82    | eval_kleiner _ _ _ _ =  NONE;
   13.83  
   13.84 -fun ist_monom (Free _) = true
   13.85 -  | ist_monom (Const (\<^const_name>\<open>times\<close>, _) $ Free (num, _) $ Free _) = 
   13.86 -    if TermC.is_num' num then true else false
   13.87 -  | ist_monom _ = false;
   13.88 -(*. this function only accepts the most simple monoms  vvvvvvvvvv .*)
   13.89 -fun ist_monom (Free _) = true                          (* 2,   a   *)
   13.90 -  | ist_monom (Const (\<^const_name>\<open>times\<close>, _) $ Free _ $ Free (id, _)) = (* 2*a, a*b *)
   13.91 -    if TermC.is_num' id then false else true
   13.92 -  | ist_monom (Const (\<^const_name>\<open>times\<close>, _) $                          (* 3*a*b    *)
   13.93 -		     (Const (\<^const_name>\<open>times\<close>, _) $
   13.94 -			    Free (num, _) $ Free _) $ Free (id, _)) =
   13.95 -    if TermC.is_num' num andalso not (TermC.is_num' id) then true else false
   13.96 -  | ist_monom (Const (\<^const_name>\<open>powr\<close>, _) $ Free _ $ Free _) = 
   13.97 -    true                                                    (* a^2      *)
   13.98 -  | ist_monom (Const (\<^const_name>\<open>times\<close>, _) $ Free (num, _) $          (* 3*a^2    *)
   13.99 -		     (Const (\<^const_name>\<open>powr\<close>, _) $
  13.100 -			    Free _ $ Free _)) = 
  13.101 -    if TermC.is_num' num then true else false
  13.102 -  | ist_monom _ = false;
  13.103 +fun ist_monom t =
  13.104 +  if TermC.is_atom t then true
  13.105 +  else
  13.106 +    case t of
  13.107 +      Const ("Groups.times_class.times", _) $ t1 $ t2 =>
  13.108 +        ist_monom t1 andalso ist_monom t2
  13.109 +    | Const ("Transcendental.powr", _) $ t1 $ t2 =>
  13.110 +        ist_monom t1 andalso ist_monom t2
  13.111 +    | _ => false
  13.112  
  13.113  (* is this a univariate monomial ? *)
  13.114  (*("ist_monom", ("PolyMinus.ist_monom", eval_ist_monom ""))*)
  13.115 @@ -191,9 +171,9 @@
  13.116  (** rulesets **)
  13.117  
  13.118  val erls_ordne_alphabetisch =
  13.119 -    Rule_Set.append_rules "erls_ordne_alphabetisch" Rule_Set.empty
  13.120 -	       [\<^rule_eval>\<open>PolyMinus.kleiner\<close> (eval_kleiner ""),
  13.121 -		     \<^rule_eval>\<open>PolyMinus.ist_monom\<close> (eval_ist_monom "")
  13.122 +  Rule_Set.append_rules "erls_ordne_alphabetisch" Rule_Set.empty
  13.123 +	 [Rule.Eval ("PolyMinus.kleiner", eval_kleiner ""),
  13.124 +		Rule.Eval ("PolyMinus.ist_monom", eval_ist_monom "")
  13.125  		];
  13.126  
  13.127  val ordne_alphabetisch = 
    14.1 --- a/src/Tools/isac/Knowledge/Rational.thy	Mon Jun 21 22:08:01 2021 +0200
    14.2 +++ b/src/Tools/isac/Knowledge/Rational.thy	Sun Jul 18 18:15:27 2021 +0200
    14.3 @@ -123,19 +123,31 @@
    14.4  ML \<open>
    14.5  fun monom_of_term vs (c, es) (t as Const _) =
    14.6      (c, list_update es (find_index (curry op = t) vs) 1)
    14.7 -  | monom_of_term  vs (c, es) (t as Free (id, _)) =
    14.8 -    if TermC.is_num' id 
    14.9 -    then (id |> TermC.int_opt_of_string |> the |> curry op * c, es) (*several numerals in one monom*)
   14.10 -    else (c, list_update es (find_index (curry op = t) vs) 1)
   14.11 -  | monom_of_term  vs (c, es) (Const (\<^const_name>\<open>powr\<close>, _) $ (t as Free _) $ Free (e, _)) =
   14.12 -    (c, list_update es (find_index (curry op = t) vs) (the (TermC.int_opt_of_string e)))
   14.13 +  | monom_of_term _ (c, es) (t as (Const ("Num.numeral_class.numeral", _) $ _)) =
   14.14 +    (t |> HOLogic.dest_number |> snd |> curry op * c, es) (*several numerals in one monom*)
   14.15 +  | monom_of_term _ (c, es) (t as (Const ("Groups.uminus_class.uminus", _) $ _)) =
   14.16 +    (t |> HOLogic.dest_number |> snd |> curry op * c, es) (*several numerals in one monom*)
   14.17 +  | monom_of_term  vs (c, es) (t as Free _) =
   14.18 +    (c, list_update es (find_index (curry op = t) vs) 1)
   14.19 +  | monom_of_term  vs (c, es) (Const ("Transcendental.powr", _) $ (b as Free _) $
   14.20 +      (e as Const ("Num.numeral_class.numeral", _) $ _)) =
   14.21 +    (c, list_update es (find_index (curry op = b) vs) (e |> HOLogic.dest_number |> snd))
   14.22 +  | monom_of_term  vs (c, es) (Const ("Transcendental.powr", _) $ (b as Free _) $
   14.23 +      (e as Const ("Groups.uminus_class.uminus", _) $ _)) =
   14.24 +    (c, list_update es (find_index (curry op = b) vs) (e |> HOLogic.dest_number |> snd))
   14.25 +
   14.26    | monom_of_term vs (c, es) (Const (\<^const_name>\<open>times\<close>, _) $ m1 $ m2) =
   14.27      let val (c', es') = monom_of_term vs (c, es) m1
   14.28      in monom_of_term vs (c', es') m2 end
   14.29    | monom_of_term _ _ t = raise ERROR ("poly malformed 1 with " ^ UnparseC.term t)
   14.30  
   14.31 +(*-------v------*)
   14.32  fun monoms_of_term vs (t as Const _) =
   14.33      [monom_of_term  vs (1, replicate (length vs) 0) t]
   14.34 +  | monoms_of_term vs (t as Const ("Num.numeral_class.numeral", _) $ _) =
   14.35 +    [monom_of_term  vs (1, replicate (length vs) 0) t]
   14.36 +  | monoms_of_term vs (t as Const ("Groups.uminus_class.uminus", _) $ _) =
   14.37 +    [monom_of_term  vs (1, replicate (length vs) 0) t]
   14.38    | monoms_of_term vs (t as Free _) =
   14.39      [monom_of_term  vs (1, replicate (length vs) 0) t]
   14.40    | monoms_of_term vs (t as Const (\<^const_name>\<open>powr\<close>, _) $ _ $  _) =
   14.41 @@ -179,7 +191,7 @@
   14.42    | term_of_es baseT expT (_ :: vs) (0 :: es) = [] @ term_of_es baseT expT vs es
   14.43    | term_of_es baseT expT (v :: vs) (1 :: es) = v :: term_of_es baseT expT vs es
   14.44    | term_of_es baseT expT (v :: vs) (e :: es) =
   14.45 -    Const (\<^const_name>\<open>powr\<close>, [baseT, expT] ---> baseT) $ v $  (Free (TermC.isastr_of_int e, expT))
   14.46 +    Const ("Transcendental.powr", [baseT, expT] ---> baseT) $ v $ (HOLogic.mk_number expT e)
   14.47      :: term_of_es baseT expT vs es
   14.48    | term_of_es _ _ _ _ = raise ERROR "term_of_es: length vs <> length es"
   14.49  
   14.50 @@ -189,9 +201,10 @@
   14.51        if c = 1 
   14.52        then 
   14.53          if es' = [] (*if es = [0,0,0,...]*)
   14.54 -        then Free (TermC.isastr_of_int c, baseT)
   14.55 -        else foldl (HOLogic.mk_binop \<^const_name>\<open>times\<close>) (hd es', tl es')
   14.56 -      else foldl (HOLogic.mk_binop \<^const_name>\<open>times\<close>) (Free (TermC.isastr_of_int c, baseT), es') 
   14.57 +        then HOLogic.mk_number baseT c
   14.58 +        else foldl (HOLogic.mk_binop "Groups.times_class.times") (hd es', tl es')
   14.59 +      else foldl (HOLogic.mk_binop "Groups.times_class.times")
   14.60 +        (HOLogic.mk_number baseT c, es') 
   14.61      end
   14.62  
   14.63  fun term_of_poly baseT expT vs p =
   14.64 @@ -202,8 +215,8 @@
   14.65  subsection \<open>Apply gcd_poly for cancelling and adding fractions as terms\<close>
   14.66  ML \<open>
   14.67  fun mk_noteq_0 baseT t = 
   14.68 -  Const (\<^const_name>\<open>Not\<close>, HOLogic.boolT --> HOLogic.boolT) $ 
   14.69 -    (Const (\<^const_name>\<open>HOL.eq\<close>, [baseT, baseT] ---> HOLogic.boolT) $ t $ Free ("0", HOLogic.realT))
   14.70 +  Const ("HOL.Not", HOLogic.boolT --> HOLogic.boolT) $ 
   14.71 +    (Const ("HOL.eq", [baseT, baseT] ---> HOLogic.boolT) $ t $ HOLogic.mk_number HOLogic.realT 0)
   14.72  
   14.73  fun mk_asms baseT ts =
   14.74    let val as' = filter_out TermC.is_num ts (* asm like "2 ~= 0" is needless *)
   14.75 @@ -316,7 +329,7 @@
   14.76      (Const (\<^const_name>\<open>plus\<close>, _) $ 
   14.77        (Const (\<^const_name>\<open>divide\<close>, _) $ n1 $ d1) $ 
   14.78        nofrac)
   14.79 -    = SOME ((n1, d1), (nofrac, Free ("1", HOLogic.realT)))
   14.80 +    = SOME ((n1, d1), (nofrac, HOLogic.mk_number HOLogic.realT 1))
   14.81    | check_frac_sum _ = NONE  
   14.82  
   14.83  (* prepare a term for addition by providing the least common denominator as a product
   14.84 @@ -394,10 +407,11 @@
   14.85      (Rule_Def.Repeat {id = "calc_rat_erls", preconds = [], rew_ord = ("dummy_ord", Rewrite_Ord.dummy_ord), 
   14.86        erls = Rule_Set.empty, srls = Rule_Set.Empty, calc = [], errpatts = [],
   14.87        rules = 
   14.88 -        [\<^rule_eval>\<open>HOL.eq\<close> (Prog_Expr.eval_equal "#equal_"),
   14.89 -        \<^rule_eval>\<open>Prog_Expr.is_const\<close> (Prog_Expr.eval_const "#is_const_"),
   14.90 -        \<^rule_thm>\<open>not_true\<close>,
   14.91 -        \<^rule_thm>\<open>not_false\<close>], 
   14.92 +       [Rule.Eval ("Prog_Expr.matches", Prog_Expr.eval_matches "#matches_"),
   14.93 +        Rule.Eval ("HOL.eq", Prog_Expr.eval_equal "#equal_"),
   14.94 +        Rule.Eval ("Prog_Expr.is_const", Prog_Expr.eval_const "#is_const_"),
   14.95 +        Rule.Thm ("not_true", ThmC.numerals_to_Free @{thm not_true}),
   14.96 +        Rule.Thm ("not_false", ThmC.numerals_to_Free @{thm not_false})], 
   14.97        scr = Rule.Empty_Prog});
   14.98  
   14.99  (* simplifies expressions with numerals;
  14.100 @@ -599,19 +613,6 @@
  14.101  
  14.102  section \<open>Rulesets for general simplification\<close>
  14.103  ML \<open>
  14.104 -(*erls for calculate_Rational; make local with FIXX@ME result:term *term list*)
  14.105 -val powers_erls = prep_rls'(
  14.106 -  Rule_Def.Repeat {id = "powers_erls", preconds = [], rew_ord = ("dummy_ord",Rewrite_Ord.dummy_ord), 
  14.107 -      erls = Rule_Set.empty, srls = Rule_Set.Empty, calc = [], errpatts = [],
  14.108 -      rules = [\<^rule_eval>\<open>Prog_Expr.is_atom\<close> (Prog_Expr.eval_is_atom "#is_atom_"),
  14.109 -	       \<^rule_eval>\<open>Prog_Expr.is_even\<close> (Prog_Expr.eval_is_even "#is_even_"),
  14.110 -	       \<^rule_eval>\<open>less\<close> (Prog_Expr.eval_equ "#less_"),
  14.111 -	       \<^rule_thm>\<open>not_false\<close>,
  14.112 -	       \<^rule_thm>\<open>not_true\<close>,
  14.113 -	       \<^rule_eval>\<open>plus\<close> (**)(eval_binop "#add_")
  14.114 -	       ],
  14.115 -      scr = Rule.Empty_Prog
  14.116 -      });
  14.117  (*.all powers over + distributed; atoms over * collected, other distributed
  14.118     contains absolute minimum of thms for context in norm_Rational .*)
  14.119  val powers = prep_rls'(
    15.1 --- a/src/Tools/isac/Knowledge/Root.thy	Mon Jun 21 22:08:01 2021 +0200
    15.2 +++ b/src/Tools/isac/Knowledge/Root.thy	Sun Jul 18 18:15:27 2021 +0200
    15.3 @@ -44,34 +44,30 @@
    15.4  ML \<open>
    15.5  (*-------------------------functions---------------------*)
    15.6  (*evaluation square-root over the integers*)
    15.7 -fun eval_sqrt (_ : string) (_ : string) (t as 
    15.8 -	       (Const(op0, _) $ arg)) _(*thy*) = 
    15.9 +fun eval_sqrt (_ : string) (_ : string) (t as (Const (op0, _) $ arg)) _(*thy*) = 
   15.10      (case arg of 
   15.11 -	Free (n1,t1) =>
   15.12 -	(case TermC.int_opt_of_string n1 of
   15.13 -	     SOME ni => 
   15.14 -	     if ni < 0 then NONE
   15.15 -	     else
   15.16 -		 let val fact = Eval.squfact ni;
   15.17 -		 in if fact*fact = ni 
   15.18 -		    then SOME ("#sqrt #"^(string_of_int ni)^" = #"
   15.19 -			       ^(string_of_int (if ni = 0 then 0
   15.20 -						else ni div fact)),
   15.21 -			       HOLogic.Trueprop $ TermC.mk_equality (t, TermC.term_of_num t1 fact))
   15.22 -		    else if fact = 1 then NONE
   15.23 -		    else SOME ("#sqrt #"^(string_of_int ni)^" = sqrt (#"
   15.24 -			       ^(string_of_int fact)^" * #"
   15.25 -			       ^(string_of_int fact)^" * #"
   15.26 -			       ^(string_of_int (ni div (fact*fact))^")"),
   15.27 -			       HOLogic.Trueprop $ 
   15.28 -					(TermC.mk_equality 
   15.29 -					     (t, 
   15.30 -					      (TermC.mk_factroot op0 t1 fact 
   15.31 -						(ni div (fact*fact))))))
   15.32 -	         end
   15.33 -	   | NONE => NONE)
   15.34 -      | _ => NONE)
   15.35 -
   15.36 +  	  (Const ("Num.numeral_class.numeral", T) $ num) =>
   15.37 +        let val ni = HOLogic.dest_numeral num
   15.38 +        in
   15.39 +    	    if ni < 0 then NONE
   15.40 +    	    else
   15.41 +    		    let val fact = Eval.squfact ni;
   15.42 +    		    in
   15.43 +              if fact * fact = ni 
   15.44 +    		      then
   15.45 +                SOME ("#sqrt #" ^ string_of_int ni ^ " = #"
   15.46 +    			          ^ string_of_int (if ni = 0 then 0 else ni div fact),
   15.47 +    			        HOLogic.Trueprop $ TermC.mk_equality (t, TermC.term_of_num T fact))
   15.48 +    		      else if fact = 1 then NONE
   15.49 +      		    else
   15.50 +                SOME ("#sqrt #" ^ string_of_int ni ^ " = sqrt (#"
   15.51 +      		          ^ string_of_int fact ^ " * #" ^ string_of_int fact ^ " * #"
   15.52 +      		          ^ string_of_int (ni div (fact * fact)) ^ ")",
   15.53 +      		        HOLogic.Trueprop $ TermC.mk_equality 
   15.54 +                    (t, (TermC.mk_factroot op0 T fact (ni div (fact*fact)))))
   15.55 +    	      end
   15.56 +  	    end
   15.57 +    | _ => NONE)
   15.58    | eval_sqrt _ _ _ _ = NONE;
   15.59  (*val (thmid, op_, t as Const(op0,t0) $ arg) = ("", "", str2term "sqrt 0");
   15.60  > eval_sqrt thmid op_ t thy;
   15.61 @@ -93,7 +89,7 @@
   15.62  fun dest_hd' (Const (a, T)) =                          (* ~ term.ML *)
   15.63    (case a of \<^const_name>\<open>sqrt\<close>  => ((("|||", 0), T), 0)      (*WN greatest *)
   15.64  	   | _ => (((a, 0), T), 0))
   15.65 -  | dest_hd' (Free (a, T)) = (((a, 0), T), 1)
   15.66 +  | dest_hd' (Free (a, T)) = (((a, 0), T), 1)(*TODOO handle this as numeral, too? see EqSystem.thy*)
   15.67    | dest_hd' (Var v) = (v, 2)
   15.68    | dest_hd' (Bound i) = ((("", i), dummyT), 3)
   15.69    | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4)
   15.70 @@ -149,8 +145,8 @@
   15.71     thy:
   15.72     subst: no bound variables, only Root.sqrt
   15.73     tu: the terms to compare (t1, t2) ... *)
   15.74 -fun sqrt_right (pr:bool) thy (_: subst) tu = 
   15.75 -    (term_ord' pr thy(***) tu = LESS );
   15.76 +fun sqrt_right (pr:bool) thy (_: subst) (ts, us) = 
   15.77 +    (term_ord' pr thy(***) (TermC.numerals_to_Free ts, TermC.numerals_to_Free us) = LESS );
   15.78  end;
   15.79  
   15.80  Rewrite_Ord.rew_ord' := overwritel (! Rewrite_Ord.rew_ord',
    16.1 --- a/src/Tools/isac/Knowledge/RootRat.thy	Mon Jun 21 22:08:01 2021 +0200
    16.2 +++ b/src/Tools/isac/Knowledge/RootRat.thy	Sun Jul 18 18:15:27 2021 +0200
    16.3 @@ -6,6 +6,8 @@
    16.4  theory RootRat imports Root Rational begin
    16.5  
    16.6  ML \<open>
    16.7 +val thy = @{theory};
    16.8 +
    16.9  val rootrat_erls = 
   16.10    Rule_Set.merge "rootrat_erls" Root_erls
   16.11      (Rule_Set.merge "" rational_erls
   16.12 @@ -18,9 +20,9 @@
   16.13  		      (* w*(z1.0 + z2.0) = w * z1.0 + w * z2.0 *)
   16.14  		     \<^rule_thm>\<open>mult_1_left\<close>,
   16.15  		      (* 1 * z = z *)
   16.16 -		     \<^rule_thm_sym>\<open>real_mult_minus1\<close>,
   16.17 -		       (* "- z1 = -1 * z1"  *)
   16.18 -		     \<^rule_eval>\<open>sqrt\<close> (eval_sqrt "#sqrt_")
   16.19 +		      Rule.Thm ("real_mult_minus1_sym", ThmC.numerals_to_Free (@{thm real_mult_minus1_sym})),
   16.20 +	        (*"\<not>(z is_const) ==> - (z::real) = -1 * z"*)
   16.21 +		     Rule.Eval ("NthRoot.sqrt", eval_sqrt "#sqrt_")
   16.22  		     ];
   16.23  
   16.24  val prep_rls' = Auto_Prog.prep_rls @{theory};
    17.1 --- a/src/Tools/isac/Knowledge/Simplify.thy	Mon Jun 21 22:08:01 2021 +0200
    17.2 +++ b/src/Tools/isac/Knowledge/Simplify.thy	Sun Jul 18 18:15:27 2021 +0200
    17.3 @@ -8,12 +8,7 @@
    17.4  consts
    17.5  
    17.6    (*descriptions in the related problem*)
    17.7 -  Term        :: "real => una"
    17.8 -(*TERM -->   Const ("Pure.term", "RealDef.real => prop")  (*!!!*) $ 
    17.9 -               Free ("ttt", "RealDef.real")
   17.10 -  term -->   Free ("term", "RealDef.real => RealDef.real") $
   17.11 -               Free ("ttt", "RealDef.real")
   17.12 -    but 'term' is a keyword in *.thy*)
   17.13 +  Term        :: "real => una"   (*"term" is a keyword in *.thy*)
   17.14    normalform  :: "real => una"
   17.15  
   17.16    (*the CAS-command*)
    18.1 --- a/src/Tools/isac/Knowledge/Test.thy	Mon Jun 21 22:08:01 2021 +0200
    18.2 +++ b/src/Tools/isac/Knowledge/Test.thy	Sun Jul 18 18:15:27 2021 +0200
    18.3 @@ -59,8 +59,9 @@
    18.4    | atom((Const ("Bin.integ_of_bin",_)) $ _) = true
    18.5    | atom _ = false;
    18.6  
    18.7 -fun varids (Const (s, Type (_,[]))) = [strip_thy s]
    18.8 -  | varids (Free (s, Type (_,[]))) = if TermC.is_num' s then [] else [strip_thy s]  
    18.9 +fun varids (Const ("Num.numeral_class.numeral", _) $ _) = []
   18.10 +  | varids (Const (s, Type (_,[]))) = [strip_thy s]
   18.11 +  | varids (Free (s, Type (_,[]))) = [strip_thy s]  
   18.12    | varids (Var((s, _),Type (_,[]))) = [strip_thy s]
   18.13  (*| varids (_      (s,"?DUMMY"   )) =   ..ML-error *)
   18.14    | varids((Const ("Bin.integ_of_bin",_)) $ _)= [](*8.01: superfluous?*)
   18.15 @@ -293,7 +294,7 @@
   18.16      (case a of
   18.17        \<^const_name>\<open>powr\<close> => ((("|||||||||||||", 0), T), 0)           (*WN greatest *)
   18.18    | _ => (((a, 0), T), 0))
   18.19 -  | dest_hd' (Free (a, T)) = (((a, 0), T), 1)
   18.20 +  | dest_hd' (Free (a, T)) = (((a, 0), T), 1)(*TODOO handle this as numeral, too? see EqSystem.thy*)
   18.21    | dest_hd' (Var v) = (v, 2)
   18.22    | dest_hd' (Bound i) = ((("", i), dummyT), 3)
   18.23    | dest_hd' (Abs (_, T, _)) = ((("", 0), T), 4)
   18.24 @@ -344,8 +345,8 @@
   18.25      list_ord (term_ord' pr (ThyC.get_theory "Isac_Knowledge"))(ts, us);
   18.26  in
   18.27  
   18.28 -fun ord_make_polytest (pr:bool) thy (_: subst) tu = 
   18.29 -    (term_ord' pr thy(***) tu = LESS );
   18.30 +fun ord_make_polytest (pr:bool) thy (_: subst) (ts, us) = 
   18.31 +    (term_ord' pr thy(***) (TermC.numerals_to_Free ts, TermC.numerals_to_Free us) = LESS );
   18.32  
   18.33  end;(*local*)
   18.34  \<close> 
   18.35 @@ -469,7 +470,7 @@
   18.36  (* expects * distributed over + *)
   18.37  val Test_simplify =
   18.38    Rule_Def.Repeat{id = "Test_simplify", preconds = [], 
   18.39 -      rew_ord = ("sqrt_right",sqrt_right false @{theory "Pure"}),
   18.40 +      rew_ord = ("sqrt_right", sqrt_right false @{theory "Pure"}),
   18.41        erls = tval_rls, srls = Rule_Set.empty, 
   18.42        calc=[(*since 040209 filled by prep_rls'*)], errpatts = [],
   18.43        rules = [
    19.1 --- a/src/Tools/isac/MathEngBasic/rewrite.sml	Mon Jun 21 22:08:01 2021 +0200
    19.2 +++ b/src/Tools/isac/MathEngBasic/rewrite.sml	Sun Jul 18 18:15:27 2021 +0200
    19.3 @@ -62,7 +62,6 @@
    19.4  fun trace_eq2 i str thy t t' =
    19.5    trace i (" " ^ str ^ ": \"" ^
    19.6      UnparseC.term_in_thy thy t ^ "\" > \"" ^ UnparseC.term_in_thy thy t' ^ "\"");
    19.7 -
    19.8  fun trace1 i str =
    19.9    if ! trace_on andalso i < ! depth then tracing (idt "#" (i + 1) ^ str) else ()
   19.10  fun trace_in1 i str thmid =
   19.11 @@ -99,9 +98,9 @@
   19.12        let val (simpl_p', nofalse) = eval__true thy (i + 1) p' bdv rls 	     
   19.13  	    in
   19.14  	      if nofalse
   19.15 -        then (trace_in4 i "asms accepted" thy p' simpl_p'; (t',simpl_p'))(* uncond.rew.from above*)
   19.16 +        then (trace_in4 i "asms accepted" thy p' simpl_p'; (t', simpl_p'))(*uncond.rew.from above*)
   19.17          else (trace_in5 i "asms false" thy p'; raise NO_REWRITE)   (* don't go into subtm.of cond*)
   19.18 -	    end
   19.19 +	    end                                    
   19.20    in
   19.21      if TermC.perm lhs rhs andalso not (tless bdv (t', t))                     (*ordered rewriting*)
   19.22      then (trace_eq2 i "not >" thy t t'; raise NO_REWRITE)
   19.23 @@ -124,7 +123,7 @@
   19.24            let val (t1', asm1, lrd, rew1) = rew_sub thy i bdv tless rls put_asm (lrd @ [TermC.L]) r t1
   19.25            in if rew1 then (t1' $ t2, asm1, lrd, true) else (t1 $ t2,[], lrd, false) end
   19.26      end)
   19.27 -and eval__true thy i asms bdv rls =           (* simplify asumptions until one evaluates to false*)
   19.28 +and eval__true thy i asms bdv rls =            (* rewrite asumptions until one evaluates to false*)
   19.29    if asms = [@{term True}] orelse asms = [] then ([], true)
   19.30    else (* this allows to check Rrls with prepat = ([@{term True}], pat) *)
   19.31      if asms = [@{term False}] then ([], false)
   19.32 @@ -140,7 +139,7 @@
   19.33              (*asm false .. thm not applied ^^^; continue until False vvv*)
   19.34              else chk (indets @ [t] @ a') asms);
   19.35        in chk [] asms end
   19.36 -and rewrite__set_ thy _ _ _ Rule_Set.Empty t =                          (* rewrite with a rule set*)
   19.37 +and rewrite__set_ thy _ _ _ Rule_Set.Empty t =                         (* rewrite with a rule set*)
   19.38      raise ERROR ("rewrite__set_ called with 'Erls' for '" ^ UnparseC.term_in_thy thy t ^ "'")
   19.39    | rewrite__set_ thy i _ _ (rrls as Rule_Set.Rrls _) t =    (* rewrite with a 'reverse rule set'*)
   19.40      let
   19.41 @@ -251,10 +250,10 @@
   19.42          end
   19.43      end;
   19.44  
   19.45 -(* rewriting without argument [] for rew_ord;  WN110603: shouldnt asm<>[] lead to false? *)
   19.46 +(* rewriting without argument [] for rew_ord *)
   19.47  fun eval_true thy terms rls = (snd o (eval__true thy 1 terms [])) rls;
   19.48  
   19.49 -(* rewriting without internal argument [] *)
   19.50 +(* rewriting without internal arguments 1, [] *)
   19.51  fun rewrite_ thy rew_ord erls bool thm term = rewrite__ thy 1 [] rew_ord erls bool thm term;
   19.52  fun rewrite_set_ thy bool rls term = rewrite__set_ thy 1 bool [] rls term;
   19.53  
    20.1 --- a/src/Tools/isac/ProgLang/Calculate.thy	Mon Jun 21 22:08:01 2021 +0200
    20.2 +++ b/src/Tools/isac/ProgLang/Calculate.thy	Sun Jul 18 18:15:27 2021 +0200
    20.3 @@ -25,56 +25,38 @@
    20.4  \<close> ML \<open>
    20.5  (*** evaluate binary associative operations ***)
    20.6  
    20.7 -fun eval_binop (_(*thmid*) : string) (op_: string)
    20.8 -      (t as (Const (op0, t0) $ (Const (op0', _) $ v $ t1) $ t2)) _ =  (* binary . (v.n1).n2 *)
    20.9 -    if op0 = op0' then
   20.10 -      case (Eval.numeral t1, Eval.numeral t2) of
   20.11 -        (SOME n1, SOME n2) =>
   20.12 -          let 
   20.13 -            val (T1, _, _) = TermC.dest_binop_typ t0
   20.14 -            val res = 
   20.15 -              Eval.calcul (if op0 = \<^const_name>\<open>minus\<close> then \<^const_name>\<open>plus\<close> else op0)n1 n2
   20.16 -              (*WN071229 \<^const_name>\<open>divide\<close> never tried*)
   20.17 -            val rhs = Eval.var_op_float v op_ t0 T1 res
   20.18 -            val prop = HOLogic.Trueprop $ (TermC.mk_equality (t, rhs))
   20.19 -          in SOME ("#: " ^ UnparseC.term prop, prop) end
   20.20 -      | _ => NONE
   20.21 +fun eval_binop _ _
   20.22 +      (t as ((opp as Const (op0, _)) $ (Const (op0', _) $ v $ t1) $ t2)) _ =(* binary . (v.n1).n2 *)
   20.23 +    if op0 = op0' andalso TermC.is_num t1 andalso TermC.is_num t2 then
   20.24 +      let
   20.25 +        val op' = if op0 = "Groups.minus_class.minus" then "Groups.plus_class.plus" else op0
   20.26 +        val res = Eval.calcul op' (t1, t2);
   20.27 +        val prop = HOLogic.Trueprop $ (HOLogic.mk_eq (t, opp $ v $ res));
   20.28 +      in SOME ("#: " ^ UnparseC.term prop, prop) end
   20.29      else NONE
   20.30 -  | eval_binop _ (op_ : string) 
   20.31 -      (t as (Const (op0, t0) $ t1 $ (Const (op0', _) $ t2 $ v))) _ =  (* binary . n1.(n2.v) *)
   20.32 -    if op0 = op0' then
   20.33 -      case (Eval.numeral t1, Eval.numeral t2) of
   20.34 -        (SOME n1, SOME n2) =>
   20.35 -          if op0 = \<^const_name>\<open>minus\<close> then NONE 
   20.36 -          else let 
   20.37 -            val (T1, _, _) = TermC.dest_binop_typ t0
   20.38 -            val res = Eval.calcul op0 n1 n2
   20.39 -            val rhs = Eval.float_op_var v op_ t0 T1 res
   20.40 -            val prop = HOLogic.Trueprop $ (TermC.mk_equality (t, rhs))
   20.41 -          in SOME ("#: " ^ UnparseC.term prop, prop) end
   20.42 -      | _ => NONE
   20.43 +  | eval_binop _ (_ : string) 
   20.44 +      (t as ((opp as Const (op0, _)) $ t1 $ (Const (op0', _) $ t2 $ v))) _ =(* binary . n1.(n2.v) *)
   20.45 +    if op0 = op0' andalso op0 <> "Groups.minus_class.minus"
   20.46 +        andalso TermC.is_num t1 andalso TermC.is_num t2 then
   20.47 +      let
   20.48 +        val res = Eval.calcul op0 (t1, t2);
   20.49 +        val prop = HOLogic.Trueprop $ (HOLogic.mk_eq (t, opp $ res $ v));
   20.50 +      in
   20.51 +        SOME ("#: " ^ UnparseC.term prop, prop)
   20.52 +      end
   20.53      else NONE
   20.54 -  | eval_binop _ _ (t as (Const (op0, t0) $ t1 $ t2)) _ =   (* binary . n1.n2 *)
   20.55 -    (case (Eval.numeral t1, Eval.numeral t2) of
   20.56 -      (SOME n1, SOME n2) =>
   20.57 -        let 
   20.58 -          val (_, _, Trange) = TermC.dest_binop_typ t0;
   20.59 -          val res = Eval.calcul op0 n1 n2;
   20.60 -          val rhs = Eval.term_of_float Trange res;
   20.61 -          val prop = HOLogic.Trueprop $ (TermC.mk_equality (t, rhs));
   20.62 -        in SOME ("#: " ^ UnparseC.term prop, prop) end
   20.63 -    | _ => NONE)
   20.64 +  | eval_binop _ _ (t as (Const (op0, _) $ t1 $ t2)) _ =                       (* binary . n1.n2 *)
   20.65 +    if TermC.is_num t1 andalso TermC.is_num t2 then
   20.66 +      let
   20.67 +        val res = Eval.calcul op0 (t1, t2);
   20.68 +        val prop = HOLogic.Trueprop $ (HOLogic.mk_eq (t, res));
   20.69 +      in
   20.70 +        SOME ("#: " ^ UnparseC.term prop, prop)
   20.71 +      end
   20.72 +    else NONE
   20.73    | eval_binop _ _ _ _ = NONE; 
   20.74 -(*
   20.75 -> val SOME (thmid, t) = eval_binop "#add_" \<^const_name>\<open>plus\<close> (str2term "-1 + 2") thy;
   20.76 -> UnparseC.term t;
   20.77 -val it = "-1 + 2 = 1"
   20.78 -> val t = str2term "-1 * (-1 * a)";
   20.79 -> val SOME (thmid, t) = eval_binop "#mult_" \<^const_name>\<open>times\<close> t thy;
   20.80 -> UnparseC.term t;
   20.81 -val it = "-1 * (-1 * a) = 1 * a"*)
   20.82  \<close> ML \<open>
   20.83  \<close> ML \<open>
   20.84  \<close>
   20.85  
   20.86 -end
   20.87 \ No newline at end of file
   20.88 +end
    21.1 --- a/src/Tools/isac/ProgLang/Prog_Expr.thy	Mon Jun 21 22:08:01 2021 +0200
    21.2 +++ b/src/Tools/isac/ProgLang/Prog_Expr.thy	Sun Jul 18 18:15:27 2021 +0200
    21.3 @@ -279,43 +279,45 @@
    21.4    | eval_some_occur_in _ _ _ _ = NONE;
    21.5  
    21.6  (*("is_atom",("Prog_Expr.is_atom", Prog_Expr.eval_is_atom "#is_atom_"))*)
    21.7 -fun eval_is_atom (thmid:string) "Prog_Expr.is_atom"
    21.8 -		 (t as (Const _ $ arg)) _ = 
    21.9 -    (case arg of 
   21.10 -	 Free (n,_) => SOME (TermC.mk_thmid thmid n "", 
   21.11 -			      HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
   21.12 -       | _ => SOME (TermC.mk_thmid thmid "" "", 
   21.13 -		    HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False}))))
   21.14 +fun eval_is_atom (thmid:string) "Prog_Expr.is_atom" (t as (Const _ $ arg)) _ = 
   21.15 +    if TermC.is_atom arg
   21.16 +    then SOME (TermC.mk_thmid thmid (TermC.string_of_atom arg) "", 
   21.17 +			HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
   21.18 +    else SOME (TermC.mk_thmid thmid (TermC.string_of_atom arg) "", 
   21.19 +		  HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
   21.20    | eval_is_atom _ _ _ _ = NONE;
   21.21  
   21.22  fun even i = (i div 2) * 2 = i;
   21.23  (*("is_even",("Prog_Expr.is_even", eval_is_even "#is_even_"))*)
   21.24 -fun eval_is_even (thmid:string) "Prog_Expr.is_even"
   21.25 -		 (t as (Const _ $ arg)) _ = 
   21.26 -    (case arg of 
   21.27 -	Free (n,_) =>
   21.28 -	 (case ThmC_Def.int_opt_of_string n of
   21.29 -	      SOME i =>
   21.30 -	      if even i then SOME (TermC.mk_thmid thmid n "", 
   21.31 -				   HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
   21.32 +fun eval_is_even (thmid:string) "Prog_Expr.is_even" (t as (Const _ $ arg)) _ = 
   21.33 +    if TermC.is_num arg
   21.34 +    then
   21.35 +      let
   21.36 +        val i = arg |> HOLogic.dest_number |> snd
   21.37 +      in
   21.38 +	      if even i 
   21.39 +        then SOME (TermC.mk_thmid thmid (string_of_int i) "", 
   21.40 +				  HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
   21.41  	      else SOME (TermC.mk_thmid thmid "" "", 
   21.42 -			 HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
   21.43 -	    | _ => NONE)
   21.44 -       | _ => NONE)
   21.45 +			    HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
   21.46 +      end
   21.47 +    else NONE
   21.48    | eval_is_even _ _ _ _ = NONE; 
   21.49  
   21.50 -(*evaluate 'is_const'*)
   21.51  (*("is_const",("Prog_Expr.is_const", Prog_Expr.eval_const "#is_const_"))*)
   21.52 -fun eval_const (thmid:string) _ (t as (Const _ $ arg)) _ = 
   21.53 -    (case arg of 
   21.54 -       Const (n1, _) =>
   21.55 -	     SOME (TermC.mk_thmid thmid n1 "", HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
   21.56 -     | Free (n1, _) =>
   21.57 -	     if TermC.is_num' n1
   21.58 -	     then SOME (TermC.mk_thmid thmid n1 "", HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
   21.59 -	     else SOME (TermC.mk_thmid thmid n1 "", HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
   21.60 -     | _ => (*NONE*)
   21.61 -       SOME (TermC.mk_thmid thmid (UnparseC.term arg) "", HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False}))))
   21.62 +fun eval_const thmid _ (t as (Const ("Prog_Expr.is_const", _) $ Const ("Partial_Fractions.AA", _))) _ =
   21.63 +    (*TODO get rid of this special case*)
   21.64 +    SOME (TermC.mk_thmid thmid (UnparseC.term t) "",
   21.65 +      HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
   21.66 +  | eval_const thmid _ (t as (Const ("Prog_Expr.is_const", _) $ Const _)) _ =
   21.67 +    SOME (TermC.mk_thmid thmid (UnparseC.term t) "",
   21.68 +      HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
   21.69 +  | eval_const thmid _ (t as (Const ("Prog_Expr.is_const", _) $ n)) _ =
   21.70 +	   if TermC.is_num n
   21.71 +	   then SOME (TermC.mk_thmid thmid (TermC.string_of_num n) "",
   21.72 +       HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
   21.73 +	   else SOME (TermC.mk_thmid thmid (UnparseC.term n) "",
   21.74 +       HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
   21.75    | eval_const _ _ _ _ = NONE; 
   21.76  
   21.77  (*. evaluate binary, associative, commutative operators: *,+,^ .*)
   21.78 @@ -336,17 +338,20 @@
   21.79  (*.evaluate < and <= for numerals.*)
   21.80  (*("le"      ,(\<^const_name>\<open>less\<close>        , Prog_Expr.eval_equ "#less_")),
   21.81    ("leq"     ,(\<^const_name>\<open>less_eq\<close>       , Prog_Expr.eval_equ "#less_equal_"))*)
   21.82 -fun eval_equ (thmid:string) (_(*op_*)) (t as 
   21.83 -	       (Const (op0, _) $ Free (n1, _) $ Free(n2, _))) _ = 
   21.84 -    (case (ThmC_Def.int_opt_of_string n1, ThmC_Def.int_opt_of_string n2) of
   21.85 -	 (SOME n1', SOME n2') =>
   21.86 -  if Eval.calc_equ (strip_thy op0) (n1', n2')
   21.87 -    then SOME (TermC.mk_thmid thmid n1 n2, 
   21.88 -	  HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
   21.89 -  else SOME (TermC.mk_thmid thmid n1 n2,  
   21.90 -	  HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
   21.91 -       | _ => NONE)
   21.92 -    
   21.93 +
   21.94 +fun eval_equ (thmid:string) (_(*op_*)) (t as (Const (op0, _)) $ t1 $ t2) _ =
   21.95 +    if TermC.is_num t1 andalso TermC.is_num t2 then
   21.96 +      let
   21.97 +        val n1 = t1 |> HOLogic.dest_number |> snd 
   21.98 +        val n2 = t2 |> HOLogic.dest_number |> snd 
   21.99 +      in
  21.100 +        if Eval.calc_equ (strip_thy op0) (n1, n2)
  21.101 +        then SOME (TermC.mk_thmid thmid (string_of_int n1) (string_of_int n2), 
  21.102 +    	    HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})))
  21.103 +        else SOME (TermC.mk_thmid thmid (string_of_int n1) (string_of_int n2),  
  21.104 +    	   HOLogic.Trueprop $ (TermC.mk_equality (t, @{term False})))
  21.105 +      end
  21.106 +    else NONE
  21.107    | eval_equ _ _ _ _ = NONE;
  21.108  
  21.109  
  21.110 @@ -428,26 +433,22 @@
  21.111    | eval_equal _ _ _ _ = NONE;                                                   (* error-exit *)
  21.112  
  21.113  (*. evaluate HOL.divide .*)
  21.114 -(*("DIVIDE" ,(\<^const_name>\<open>divide\<close>  , eval_cancel "#divide_e"))*)
  21.115 -fun eval_cancel (thmid: string) \<^const_name>\<open>divide\<close> (t as 
  21.116 -	       (Const (op0,t0) $ Free (n1, _) $ Free(n2, _))) _ = 
  21.117 -    (case (ThmC_Def.int_opt_of_string n1, ThmC_Def.int_opt_of_string n2) of
  21.118 -    	(SOME n1', SOME n2') =>
  21.119 -        let 
  21.120 -          val sg = Eval.sign_mult n1' n2';
  21.121 -          val (T1,T2,Trange) = TermC.dest_binop_typ t0;
  21.122 -          val gcd' = Eval.gcd (abs n1') (abs n2');
  21.123 -        in if gcd' = abs n2' 
  21.124 -           then let val rhs = TermC.term_of_num Trange (sg * (abs n1') div gcd')
  21.125 -    	        val prop = HOLogic.Trueprop $ (TermC.mk_equality (t, rhs))
  21.126 -    	    in SOME (TermC.mk_thmid thmid n1 n2, prop) end     
  21.127 -           else if 0 < n2' andalso gcd' = 1 then NONE
  21.128 -           else let val rhs = TermC.mk_num_op_num T1 T2 (op0,t0) (sg * (abs n1') div gcd')
  21.129 -    	  			   ((abs n2') div gcd')
  21.130 -    	        val prop = HOLogic.Trueprop $ (TermC.mk_equality (t, rhs))
  21.131 -    	    in SOME (TermC.mk_thmid thmid n1 n2, prop) end
  21.132 -        end
  21.133 -      | _ => ((*tracing"#>@ eval_cancel NONE";*)NONE))
  21.134 +(*("DIVIDE" ,("Rings.divide_class.divide"  , eval_cancel "#divide_e"))*)
  21.135 +fun eval_cancel thmid "Rings.divide_class.divide" (t as (Const _ $ t1 $ t2)) _ = 
  21.136 +    if TermC.is_num t1 andalso TermC.is_num t2 then
  21.137 +      let
  21.138 +        val (T, _) = HOLogic.dest_number t1;
  21.139 +        val (i1, i2) = (Eval.int_of_numeral t1, Eval.int_of_numeral t2);
  21.140 +        val res_int as (_, (i1', i2')) = Eval.cancel_int (i1, i2);
  21.141 +      in
  21.142 +        if (i1', i2') = (i1, i2) then NONE
  21.143 +        else
  21.144 +          let
  21.145 +            val res = TermC.mk_frac T res_int;
  21.146 +            val prop = HOLogic.Trueprop $ (HOLogic.mk_eq (t, res));
  21.147 +          in SOME (TermC.mk_thmid thmid (string_of_int i1) (string_of_int i2), prop) end
  21.148 +      end
  21.149 +    else NONE
  21.150    | eval_cancel _ _ _ _ = NONE;
  21.151  
  21.152  (* get the argument from a function-definition *)
    22.1 --- a/src/Tools/isac/ProgLang/evaluate.sml	Mon Jun 21 22:08:01 2021 +0200
    22.2 +++ b/src/Tools/isac/ProgLang/evaluate.sml	Sun Jul 18 18:15:27 2021 +0200
    22.3 @@ -14,16 +14,22 @@
    22.4    val squfact: int -> int
    22.5    val gcd: int -> int -> int
    22.6    val sqrt: int -> int
    22.7 +  val cancel_int: int * int -> int * (int * int)
    22.8    val adhoc_thm: theory -> string * Eval_Def.eval_fn -> term -> (string * thm) option
    22.9    val adhoc_thm1_: theory -> Eval_Def.cal -> term -> (string * thm) option
   22.10    val norm: term -> term
   22.11    val popt2str: ('a * term) option -> string
   22.12 +(** )
   22.13    val numeral: term -> ((int * int) * (int * int)) option
   22.14 -  val calcul: string -> float -> float -> float
   22.15 +( **)
   22.16 +  val calcul: string -> term * term -> term
   22.17 +(** )
   22.18    val term_of_float: typ -> float -> term
   22.19    val var_op_float: term -> string -> typ -> typ ->float -> term
   22.20    val float_op_var: term -> string -> typ -> typ -> float -> term
   22.21 +( **)
   22.22    val trace_on: bool Unsynchronized.ref
   22.23 +  val int_of_numeral: term -> int
   22.24  \<^isac_test>\<open>
   22.25    val get_pair: theory -> string -> Eval_Def.eval_fn -> term -> (string * term) option
   22.26    val mk_rule: term list * term * term -> term
   22.27 @@ -61,6 +67,14 @@
   22.28  	else if n = 0 then 0 else 1;
   22.29  fun sign_mult n1 n2 = (sign n1) * (sign n2);
   22.30  
   22.31 +fun cancel_int (i1, i2) =
   22.32 +  let
   22.33 +    val sg = sign_mult i1 i2;
   22.34 +    val gcd' = gcd (abs i1) (abs i2);
   22.35 +  in
   22.36 +    (sg, ((abs i1) div gcd', (abs i2) div gcd'))
   22.37 +  end;
   22.38 +
   22.39  infix dvd;
   22.40  fun d dvd n = n mod d = 0;
   22.41  fun divisors n =
   22.42 @@ -109,14 +123,14 @@
   22.43  fun trace_calc4 str t1 t2 =
   22.44    if ! trace_on then writeln ("### " ^ str ^ UnparseC.term t1 ^ " $ " ^ UnparseC.term t2) else ()
   22.45  
   22.46 -fun get_pair thy op_ (ef: Eval_Def.eval_fn) (t as (Const (op0, _) $ arg)) =                (* unary fns *)
   22.47 +fun get_pair thy op_ (ef: Eval_Def.eval_fn) (t as (Const (op0, _) $ arg)) =       (* unary fns *)
   22.48      if op_ = op0 then 
   22.49        let val popt = ef op_ t thy 
   22.50        in case popt of SOME _ => popt | NONE => get_pair thy op_ ef arg end
   22.51      else get_pair thy op_ ef arg
   22.52    | get_pair thy "Prog_Expr.ident" ef (t as (Const ("Prog_Expr.ident", _) $ _ $ _ )) =
   22.53 -    ef "Prog_Expr.ident" t thy                                                      (* not nested *)
   22.54 -  | get_pair thy op_ ef (t as (Const (op0,_) $ t1 $ t2)) =                      (* binary funs *)
   22.55 +    ef "Prog_Expr.ident" t thy                                                   (* not nested *)
   22.56 +  | get_pair thy op_ ef (t as (Const (op0, _) $ t1 $ t2)) =                     (* binary funs *)
   22.57      (trace_calc1 "1.. get_pair: binop = " op_;
   22.58      if op_ = op0 then 
   22.59        let
   22.60 @@ -165,7 +179,7 @@
   22.61  fun adhoc_thm1_ thy (op_, eval_fn) ct =
   22.62    case eval_fn op_ ct thy of
   22.63  	  NONE => NONE
   22.64 -  | SOME (thmid,t) => SOME (thmid, Skip_Proof.make_thm thy t);
   22.65 +  | SOME (thmid, t) => SOME (thmid, Skip_Proof.make_thm thy t);
   22.66  
   22.67  (** for ordered and conditional rewriting **)
   22.68  
   22.69 @@ -194,49 +208,46 @@
   22.70      else (*3*) mk_rule (prems, concl, @{term True})
   22.71    end;
   22.72  
   22.73 -(* convert int and float to internal floatingpoint prepresentation.*)
   22.74 +(* convert int and float to internal floatingpoint prepresentation *)
   22.75 +(** )
   22.76  fun numeral (Free (str, _)) = 
   22.77      (case ThmC_Def.int_opt_of_string str of
   22.78 -	 SOME i => SOME ((i, 0), (0, 0))
   22.79 -       | NONE => NONE)
   22.80 +	    SOME i => SOME ((i, 0), (0, 0))
   22.81 +    | NONE => NONE)
   22.82    | numeral (Const ("Float.Float", _) $
   22.83 -		   (Const (\<^const_name>\<open>Pair\<close>, _) $
   22.84 -			  (Const (\<^const_name>\<open>Pair\<close>, _) $ Free (v1, _) $ Free (v2,_)) $
   22.85 -			  (Const (\<^const_name>\<open>Pair\<close>, _) $ Free (p1, _) $ Free (p2,_))))=
   22.86 +		   (Const ("Product_Type.Pair", _) $
   22.87 +			  (Const ("Product_Type.Pair", _) $ Free (v1, _) $ Free (v2,_)) $
   22.88 +			  (Const ("Product_Type.Pair", _) $ Free (p1, _) $ Free (p2,_)))) =
   22.89      (case (ThmC_Def.int_opt_of_string v1, ThmC_Def.int_opt_of_string v2, ThmC_Def.int_opt_of_string p1, ThmC_Def.int_opt_of_string p2) of
   22.90 -	(SOME v1', SOME v2', SOME p1', SOME p2') =>
   22.91 -	SOME ((v1', v2'), (p1', p2'))
   22.92 -      | _ => NONE)
   22.93 +	    (SOME v1', SOME v2', SOME p1', SOME p2') => SOME ((v1', v2'), (p1', p2'))
   22.94 +    | _ => NONE)
   22.95    | numeral _ = NONE;
   22.96 +( **)
   22.97  
   22.98  (*** handle numerals in eval_binop ***)
   22.99 -(* TODO rebuild fun calcul, fun term_of_float,fun var_op_float, fun float_op_var:
  22.100 -   Float ((a, b), _:int * int, (c, d), _:int * int) has been deleted already *)
  22.101  
  22.102 -(* used for calculating built in binary operations in Isabelle2002.
  22.103 -   integer numerals n are ((n,0),(0,0)) i.e. precision is (0,0) *)
  22.104 -fun calcul \<^const_name>\<open>plus\<close> ((a, b), _:int * int) ((c, d), _:int * int)  = (*FIXME.WN1008 drop Float.calc, var_op_float, float_op_var, term_of_float*)
  22.105 -    if b < d 
  22.106 -    then ((a + c * power 10 (d - b), b), (0, 0))(*FIXXXME precision*)
  22.107 -    else ((a * power 10 (b - d) + c, d), (0, 0))(*FIXXXME precision*)
  22.108 -  | calcul \<^const_name>\<open>minus\<close> ((a, 0), _) ((c, 0), _) =       (*FIXXXME float + prec.*)
  22.109 -    ((a - c,0),(0,0))
  22.110 -  | calcul \<^const_name>\<open>times\<close> ((a, b), _) ((c, d), _) =       (*FIXXXME precision*)
  22.111 -    ((a * c, b + d), (0, 0))
  22.112 -  | calcul \<^const_name>\<open>divide\<close> ((a, 0), _) ((c, 0), _) = (*FIXXXME float + prec.*)
  22.113 -    ((a div c, 0), (0, 0))
  22.114 -  | calcul \<^const_name>\<open>powr\<close> ((a, _), _) ((c, _), _) = (*FIXXXME Float + prec.*)
  22.115 -    ((power a c, 0), (0, 0))
  22.116 -  | calcul op_ ((a, b), (p11, p12)) ((c, d), (p21, p22)) = 
  22.117 -    raise ERROR ("calcul: not impl. for Float (("^
  22.118 -		 (string_of_int a  )^", "^(string_of_int b  )^"), ("^
  22.119 -		 (string_of_int p11)^", "^(string_of_int p12)^")) "^op_^" (("^
  22.120 -		 (string_of_int c  )^", "^(string_of_int d  )^"), ("^
  22.121 -		 (string_of_int p21)^", "^(string_of_int p22)^"))");
  22.122 -(*> calcul \<^const_name>\<open>plus\<close> ((~1,0),(0,0)) ((2,0),(0,0)); 
  22.123 -val it = ((1,0),(0,0))*)
  22.124 +(* preliminary HACK *)
  22.125 +fun int_of_numeral (Const ("Groups.zero_class.zero", _)) = 0
  22.126 +  | int_of_numeral (Const ("Groups.one_class.one", _)) = 1
  22.127 +  | int_of_numeral (Const ("Groups.uminus_class.uminus", _) $ t) = ~1 * int_of_numeral t
  22.128 +  | int_of_numeral (Const ("Num.numeral_class.numeral", _) $ n) = HOLogic.dest_numeral n
  22.129 +  | int_of_numeral t = raise TERM ("int_of_numeral", [t]);
  22.130 +
  22.131 +fun calcul op_ (t1, t2) =
  22.132 +  let
  22.133 +    val (T, _) = HOLogic.dest_number t1
  22.134 +    val (i1, i2) = (int_of_numeral t1, int_of_numeral t2)
  22.135 +    val result =
  22.136 +      case op_ of
  22.137 +        "Groups.plus_class.plus" => i1 + i2      (* preliminary HACK *)
  22.138 +      | "Groups.minus_class.minus" => i1 - i2    (* preliminary HACK *)
  22.139 +      | "Groups.times_class.times" => i1 * i2    (* preliminary HACK *)
  22.140 +      | "Transcendental.powr" => power i1 i2     (* preliminary HACK *)
  22.141 +      | str => raise ERROR ("calcul not impl.for op_ " ^ str)
  22.142 +  in HOLogic.mk_number T result end;
  22.143  
  22.144  (*.convert internal floatingpoint prepresentation to int and float.*)
  22.145 +(** )
  22.146  fun term_of_float T ((val1,    0), (         0,          0)) =
  22.147      TermC.term_of_num T val1
  22.148    | term_of_float T ((val1, val2), (precision1, precision2)) =
  22.149 @@ -247,6 +258,7 @@
  22.150  		      (TermC.pairt (Free (TermC.str_of_int precision1, T))
  22.151  			     (Free (TermC.str_of_int precision2, T))))
  22.152      end;
  22.153 +( **)
  22.154  (*> val t = str2term "Float ((1,2),(0,0))";
  22.155  > val Const ("Float.Float", fT) $ _ = t;
  22.156  > atomtyp fT;
  22.157 @@ -260,6 +272,7 @@
  22.158  val it = true : bool*)
  22.159  
  22.160  (*.assoc. convert internal floatingpoint prepresentation to int and float.*)
  22.161 +(** )
  22.162  fun var_op_float v op_ optype ntyp ((v1, 0), (0, 0)) =
  22.163      TermC.mk_var_op_num v op_ optype ntyp v1
  22.164    | var_op_float v op_ optype T ((v1, v2), (p1, p2)) =
  22.165 @@ -271,6 +284,7 @@
  22.166  			     (TermC.pairt (Free (TermC.str_of_int p1, T))
  22.167  				    (Free (TermC.str_of_int p2, T)))))
  22.168      end;
  22.169 +( **)
  22.170  (*> val t = str2term "a + b";
  22.171  > val Const (\<^const_name>\<open>plus\<close>, optype) $ _ $ _ = t;
  22.172  > val t = str2term "v + Float ((11,-1),(0,0))";val v = str2term "v";
  22.173 @@ -278,6 +292,7 @@
  22.174  val it = true : bool*)
  22.175  
  22.176  (*.assoc. convert internal floatingpoint prepresentation to int and float.*)
  22.177 +(** )
  22.178  fun float_op_var v op_ optype ntyp ((v1, 0), (0, 0)) =
  22.179      TermC.mk_num_op_var v op_ optype ntyp v1
  22.180    | float_op_var v op_ optype T ((v1, v2), (p1, p2)) =
    23.1 --- a/src/Tools/isac/Specify/refine.sml	Mon Jun 21 22:08:01 2021 +0200
    23.2 +++ b/src/Tools/isac/Specify/refine.sml	Sun Jul 18 18:15:27 2021 +0200
    23.3 @@ -126,7 +126,8 @@
    23.4    end;
    23.5  
    23.6  fun problem thy pblID itms =
    23.7 -  case refined_ ((Store.apply (get_ptyps ())) (refin'' thy ((rev o tl) pblID) itms []) pblID (rev pblID)) of
    23.8 +  case refined_ ((Store.apply (get_ptyps ())) (refin'' thy ((rev o tl) pblID) itms [])
    23.9 +      pblID (rev pblID)) of
   23.10  	  NONE => NONE
   23.11    | SOME (Match_ (rfd as (pI', _))) => if pblID = pI' then NONE else SOME rfd
   23.12    | _ => raise ERROR "Refine.problem: uncovered case refined_";
    24.1 --- a/test/Pure/Isar/Test_Parsers.thy	Mon Jun 21 22:08:01 2021 +0200
    24.2 +++ b/test/Pure/Isar/Test_Parsers.thy	Sun Jul 18 18:15:27 2021 +0200
    24.3 @@ -145,7 +145,7 @@
    24.4  (Args.$$$ "theory" -- Args.name);
    24.5  parse (Args.$$$ "theory" -- Args.name);
    24.6  (*
    24.7 -parse (Args.$$$ "theory")                GOON ?!?!?
    24.8 +parse (Args.$$$ "theory")                ?!?!?
    24.9    "theory";
   24.10  
   24.11  parse (Args.$$$ "theory")
   24.12 @@ -440,8 +440,8 @@
   24.13  parse (body "") "top bullet top";
   24.14  \<close>
   24.15  
   24.16 -section \<open>GOON\<close>
   24.17 -subsection \<open>GOON\<close>
   24.18 +section \<open>xxx\<close>
   24.19 +subsection \<open>xxx\<close>
   24.20  
   24.21  
   24.22  end
   24.23 \ No newline at end of file
    25.1 --- a/test/Tools/isac/ADDTESTS/All_Ctxt.thy	Mon Jun 21 22:08:01 2021 +0200
    25.2 +++ b/test/Tools/isac/ADDTESTS/All_Ctxt.thy	Sun Jul 18 18:15:27 2021 +0200
    25.3 @@ -95,7 +95,7 @@
    25.4  
    25.5  ML \<open>
    25.6    if eq_set op = (UnparseC.terms_to_strings (Ctree.get_assumptions pt p),
    25.7 -    ["matches (?a = ?b) (-1 + x = 0)", "precond_rootmet x"])
    25.8 +    ["matches (?a = ?b) (- 1 + x = 0)", "precond_rootmet x"])
    25.9    then () else error "All_Ctx: asms after start interpretation of SubProblem";
   25.10  \<close>
   25.11  
   25.12 @@ -127,9 +127,8 @@
   25.13  \<close>
   25.14  
   25.15  ML \<open>
   25.16 -\<close> ML \<open>
   25.17    if eq_set op = (UnparseC.terms_to_strings (Ctree.get_assumptions pt p),
   25.18 -    ["matches (?a = ?b) (-1 + x = 0)", "x < sub_asm_out", "x = 1", "precond_rootmet x"])
   25.19 +    ["matches (?a = ?b) (- 1 + x = 0)", "x < sub_asm_out", "x = 1", "precond_rootmet x"])
   25.20    then () else error "All_Ctx: asms after finishing SubProblem";
   25.21  \<close>
   25.22  
   25.23 @@ -147,9 +146,8 @@
   25.24  \<close>
   25.25  
   25.26  ML \<open>
   25.27 -\<close> ML \<open>
   25.28    if eq_set op = (UnparseC.terms_to_strings (Ctree.get_assumptions pt p),
   25.29 -    ["matches (?a = ?b) (-1 + x = 0)", "x < sub_asm_out", "x = 1", "precond_rootmet x"])
   25.30 +    ["matches (?a = ?b) (- 1 + x = 0)", "x < sub_asm_out", "x = 1", "precond_rootmet x"])
   25.31    then () else error "All_Ctx at final result";
   25.32  \<close>
   25.33  
    26.1 --- a/test/Tools/isac/ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform.thy	Mon Jun 21 22:08:01 2021 +0200
    26.2 +++ b/test/Tools/isac/ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform.thy	Sun Jul 18 18:15:27 2021 +0200
    26.3 @@ -654,7 +654,7 @@
    26.4        of simplification occurs right here, in the next step.\<close>
    26.5  
    26.6  ML \<open>
    26.7 -  Rewrite.trace_on := false;
    26.8 +  Rewrite.trace_on := false; (*true false*)
    26.9    val SOME fract1 =
   26.10      parseNEW ctxt "(z - 1/2)*(z - -1/4) * (A/(z - 1/2) + B/(z - -1/4))";
   26.11    (*
   26.12 @@ -1244,7 +1244,7 @@
   26.13        tree and check if every node implements that what we have wanted.\<close>
   26.14        
   26.15  ML \<open>
   26.16 -  Rewrite.trace_on := false; (*true*)
   26.17 +  Rewrite.trace_on := false; (*true false*)
   26.18    LItool.trace_on := false; (*true*)
   26.19    print_depth 9;
   26.20    
    27.1 --- a/test/Tools/isac/ADDTESTS/course/phst11/T2_Rewriting.thy	Mon Jun 21 22:08:01 2021 +0200
    27.2 +++ b/test/Tools/isac/ADDTESTS/course/phst11/T2_Rewriting.thy	Sun Jul 18 18:15:27 2021 +0200
    27.3 @@ -55,7 +55,7 @@
    27.4  \<close>
    27.5  ML \<open>
    27.6  val SOME (t, _) = Rewrite.rewrite_set_ thy true make_polynomial t; UnparseC.term t;
    27.7 -Rewrite.trace_on := false;
    27.8 +Rewrite.trace_on := false; (*true false*)
    27.9  \<close>
   27.10  
   27.11  section \<open>Note on bound variables\<close>
   27.12 @@ -157,11 +157,11 @@
   27.13  text \<open>The simplifiers are quite busy when finding the above results. you can
   27.14    watch them at work by setting the switch 'Rewrite.trace_on:\<close>
   27.15  ML \<open>
   27.16 -Rewrite.trace_on := false;
   27.17 +Rewrite.trace_on := false; (*true false*)
   27.18  tracing "+++begin++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
   27.19  val SOME (t, _) = Rewrite.rewrite_set_ thy true norm_Rational t2; UnparseC.term t;
   27.20  tracing "+++end++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++";
   27.21 -Rewrite.trace_on := false;
   27.22 +Rewrite.trace_on := false; (*true false*)
   27.23  \<close>
   27.24  text \<open>You see what happend when you click the checkbox <Tracing> on the bar
   27.25    separating this window from the Output-window.
    28.1 --- a/test/Tools/isac/BaseDefinitions/contextC.sml	Mon Jun 21 22:08:01 2021 +0200
    28.2 +++ b/test/Tools/isac/BaseDefinitions/contextC.sml	Sun Jul 18 18:15:27 2021 +0200
    28.3 @@ -23,7 +23,7 @@
    28.4  "----------- fun initialise --------------------------------------------------------------------";
    28.5  "----------- fun initialise --------------------------------------------------------------------";
    28.6  "----------- fun initialise --------------------------------------------------------------------";
    28.7 -val t = @{term "a * b + -123 * c :: real"};
    28.8 +val t = @{term "a * b + - 123 * c :: real"};
    28.9  val ctxt = initialise "Rational" (vars t)
   28.10  
   28.11  (*----- now parsing infers the type *)
   28.12 @@ -75,8 +75,8 @@
   28.13  "----------- fun avoid_contradict --------------------------------------------------------------";
   28.14  val preds = [
   28.15  (*0.pre*)TermC.str2term "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
   28.16 -(*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"
   28.17 -(*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"),
   28.18 +(*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"
   28.19 +(*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"),
   28.20  (*0.asm*)TermC.str2term  "x \<noteq> 0",             (* <-------------- "x \<noteq> 0" would contradict "x = 0" ---\*)
   28.21  (*0.asm*)TermC.str2term  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0"
   28.22  ];
   28.23 @@ -153,14 +153,14 @@
   28.24  
   28.25  val (p,_,f,nxt,_,pt) = me nxt p [] pt;                                         (* 0. solve-phase*)
   28.26  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   28.27 -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)";
   28.28 +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)";
   28.29  
   28.30  (*+*)if (Ctree.get_assumptions pt p |> map UnparseC.term) =
   28.31  (*+*)  ["x \<noteq> 0", 
   28.32 -(*+*)  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0", 
   28.33 +(*+*)  "9 * x + - 6 * x \<up> 2 + x \<up> 3 \<noteq> 0", 
   28.34  (*+*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x"]
   28.35  (*+*)then () else error "assumptions before 1. Subproblem CHANGED";
   28.36 -(*+*)if p = ([3], Res) andalso f2str f = "(3 + -1 * x + x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)"
   28.37 +(*+*)if p = ([3], Res) andalso f2str f = "(3 + - 1 * x + x \<up> 2) * x = 1 * (9 * x + - 6 * x \<up> 2 + x \<up> 3)"
   28.38  (*+*)then
   28.39  (*+*)  ((case nxt of Subproblem ("PolyEq", ["normalise", "polynomial", "univariate", "equation"]) => ()
   28.40  (*+*)  | _ => error ("S.68, Bsp.: 40 nxt =" ^ Tactic.input_to_string nxt)))
   28.41 @@ -177,6 +177,18 @@
   28.42  
   28.43  val (p,_,f,nxt,_,pt) = me nxt p [] pt;                                       (* 1. solve-phase *)
   28.44  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   28.45 +
   28.46 +
   28.47 +(* TOODOO make_ratpoly: "- 6 * x + 5 * x \<up> 2 = 0"  \<longrightarrow>  "- (6 * x) + 5 * x \<up> 2 = 0" ------------\\
   28.48 +NO NO -----------------^^^^^^^^^^^^^^^^^, rather:
   28.49 +##  rls: reduce_012 on: - 6 * x + 5 * x \<up> 2 = 0 
   28.50 +###  try thm: "mult_1_left" 
   28.51 +###  try thm: "minus_mult_left" 
   28.52 +####  eval asms: "- 6 * x = - (6 * x)" 
   28.53 +                 ^^^^^^^^ HERE APPLIES minus_mult_left SINCE NEW numerals
   28.54 +###  rewrites to: "- (6 * x) + 5 * x \<up> 2 = 0" 
   28.55 +
   28.56 +(* IN THE STEP BELOW ---vvv--- THE SYSTEM HANGS *)
   28.57  val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f = "-6 * x + 5 * x \<up> 2 = 0";
   28.58  
   28.59  if p = ([4, 3], Res) andalso f2str f = "-6 * x + 5 * x \<up> 2 = 0"
   28.60 @@ -203,8 +215,8 @@
   28.61  
   28.62  (*     *)if eq_set op = ((Ctree.get_assumptions pt p |> map UnparseC.term), [
   28.63  (*0.pre*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
   28.64 -(*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"
   28.65 -(*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",
   28.66 +(*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"
   28.67 +(*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",
   28.68  (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x", 
   28.69  (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) has_degree_in x = 2",
   28.70  (*0.asm*)  "x \<noteq> 0", 
   28.71 @@ -249,8 +261,8 @@
   28.72  
   28.73  (*     *)if eq_set op = (map UnparseC.term (get_assumptions ctxt_parent), [
   28.74  (*0.pre*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
   28.75 -(*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"
   28.76 -(*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",
   28.77 +(*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"
   28.78 +(*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",
   28.79  (*0.asm*)  "x \<noteq> 0", 
   28.80  (*0.asm*)  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0"
   28.81  (*     *)])
   28.82 @@ -260,8 +272,8 @@
   28.83    ContextC.subpbl_to_caller sub_ctxt prog_res ctxt_parent;
   28.84  (*     *)if eq_set op = (map UnparseC.term (get_assumptions ctxt'), [
   28.85  (*0.pre*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
   28.86 -(*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"
   28.87 -(*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",
   28.88 +(*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"
   28.89 +(*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",
   28.90  (*0.asm*)  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0",
   28.91  (*0.asm*)  "x \<noteq> 0",             (* <----------------------- "x \<noteq> 0" contradiction resoved ---\*)
   28.92  (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x", 
   28.93 @@ -308,7 +320,9 @@
   28.94  if f2str f = "[x = 6 / 5]" andalso map UnparseC.term (Ctree.get_assumptions pt p) =
   28.95   ["x = 6 / 5", "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x",
   28.96    "lhs (-6 * x + 5 * x \<up> 2 = 0) has_degree_in x = 2",
   28.97 -  "\<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",
   28.98 +  "\<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",
   28.99    "x \<noteq> 0", "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0",
  28.100    "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x"]
  28.101  then () else error "test CHANGED";
  28.102 +(**) TOODOO make_ratpoly: "- 6 * x + 5 * x \<up> 2 = 0"  \<longrightarrow>  "- (6 * x) + 5 * x \<up> 2 = 0" --------//*)
  28.103 +
    29.1 --- a/test/Tools/isac/BaseDefinitions/rewrite-order.sml	Mon Jun 21 22:08:01 2021 +0200
    29.2 +++ b/test/Tools/isac/BaseDefinitions/rewrite-order.sml	Sun Jul 18 18:15:27 2021 +0200
    29.3 @@ -6,12 +6,172 @@
    29.4  "-----------------------------------------------------------------------------------------------";
    29.5  "table of contents -----------------------------------------------------------------------------";
    29.6  "-----------------------------------------------------------------------------------------------";
    29.7 -"----------- TODO ------------------------------------------------------------------------------";
    29.8 +"-------- identify difference in term-order between isa=NEW, isa2+OLD --------------------------";
    29.9 +"-------- check simple terms -------------------------------------------------------------------";
   29.10 +"-------- check all 'not >' in trace of Test_simplify on: x + 1 + - 1 * 2 = 0 ------------------";
   29.11  "-----------------------------------------------------------------------------------------------";
   29.12  "-----------------------------------------------------------------------------------------------";
   29.13  "-----------------------------------------------------------------------------------------------";
   29.14  
   29.15  
   29.16 -"----------- TODO ------------------------------------------------------------------------------";
   29.17 -"----------- TODO ------------------------------------------------------------------------------";
   29.18 -"----------- TODO ------------------------------------------------------------------------------";
   29.19 +"-------- identify difference in term-order between isa=NEW, isa2+OLD --------------------------";
   29.20 +"-------- identify difference in term-order between isa=NEW, isa2+OLD --------------------------";
   29.21 +"-------- identify difference in term-order between isa=NEW, isa2+OLD --------------------------";
   29.22 +val form = TermC.str2term "x + -2 ::real"
   29.23 +val Repeat {rew_ord = ("sqrt_right", rew_ord_), erls, ...} = Test_simplify;
   29.24 +Rewrite.trace_on := false; (*true false*)
   29.25 +(** )val NONE =                                         ( *isa*)
   29.26 +(**)val SOME (form', _) =                             (*isa2*)
   29.27 +      rewrite_ @{theory Test} rew_ord_ erls true @{thm radd_commute} form;
   29.28 +(*
   29.29 +-------------------- code in rew_sub -------------------------------------------------------
   29.30 +(
   29.31 +@{print}{a = "@@@rew_sub.ord.rew: ", perm = TermC.perm lhs rhs, tless = not (tless bdv (t', t))};
   29.32 +    if TermC.perm lhs rhs andalso not (tless bdv (t', t))                     (*ordered rewriting*)
   29.33 +    then (trace_eq2 i "not >" thy t t'; raise NO_REWRITE)
   29.34 +    else (t'', p'', [], true)
   29.35 +)
   29.36 +-------------------- output with Rewrite.trace_on := true; ---------------------------------
   29.37 +##  eval asms: "x + -2 = -2 + x" 
   29.38 +{a = "@@@rew_sub.ord.rew: ", b = true, c = false}
   29.39 +*)
   29.40 +"~~~~~ fun rewrite_ , args:"; val (thy, rew_ord, erls, bool, thm, term) =
   29.41 +  (@{theory Test}, rew_ord_, erls, true, @{thm radd_commute}, form);
   29.42 +
   29.43 +"~~~~~ fun rewrite__ , args:"; val (thy, i, bdv, tless, rls, put_asm, thm, ct) =
   29.44 +  (thy, 1, []: (term * term) list, rew_ord, erls, bool, thm, term);
   29.45 +
   29.46 +    val (t', asms, _(*lrd*), rew) =
   29.47 +           rew_sub thy i bdv tless rls put_asm ([(*root of the term*)]: TermC.path)
   29.48 +		         (TermC.inst_bdv bdv (Eval.norm (Thm.prop_of thm))) ct;
   29.49 +"~~~~~ fun rew_sub , args:"; val (thy, i, bdv, tless, rls, put_asm, lrd, r, t) =
   29.50 +(thy, i, bdv, tless, rls, put_asm, ([(*root of the term*)]: TermC.path),
   29.51 +		         (TermC.inst_bdv bdv (Eval.norm (Thm.prop_of thm))), ct);
   29.52 +    val (lhs, rhs) = (HOLogic.dest_eq o HOLogic.dest_Trueprop o Logic.strip_imp_concl) r
   29.53 +    val r' = (Envir.subst_term (Pattern.match thy (lhs, t) (Vartab.empty, Vartab.empty)) r)
   29.54 +      handle Pattern.MATCH => raise NO_REWRITE
   29.55 +    val p' = map HOLogic.dest_Trueprop ((fst o Logic.strip_prems) (Logic.count_prems r', [], r'))
   29.56 +    val t' = (snd o HOLogic.dest_eq o HOLogic.dest_Trueprop o Logic.strip_imp_concl) r'
   29.57 +    val _ = trace_in2 i "eval asms" thy r';
   29.58 +    val (t'', p'') =                                                      (*conditional rewriting*)
   29.59 +      let val (simpl_p', nofalse) = Rewrite.eval__true thy (i + 1) p' bdv rls 	     
   29.60 +	    in
   29.61 +	      if nofalse
   29.62 +        then (trace_in4 i "asms accepted" thy p' simpl_p'; (t',simpl_p'))(* uncond.rew.from above*)
   29.63 +        else (trace_in5 i "asms false" thy p'; raise NO_REWRITE)   (* don't go into subtm.of cond*)
   29.64 +	    end;
   29.65 +    (*if*) TermC.perm lhs rhs andalso not (tless bdv (t', t));                     (*ordered rewriting*)
   29.66 +                                      not (tless bdv (t', t)); (*isa = true , isa2 = false*)
   29.67 +                                          (tless bdv (t', t)); (*isa = false, isa2 = true*)
   29.68 +(*WHAT IS ..:
   29.69 +tless <-- Repeat {rew_ord = ("sqrt_right", rew_ord_), erls, ...} = Test_simplify; ..in Test_Some.thy
   29.70 +rew_ord_ <-- sqrt_right false @{theory "Pure"}                                    ..in Test.thy
   29.71 +sqrt_right                                                                        ..in Root.thy
   29.72 +CHECK THIS ...(same error as with ^^^^^^^^^tless
   29.73 +CHECK THIS ...(same error as with code copied into Test_Some.thy
   29.74 +*)
   29.75 +if        (sqrt_right false @{theory "Pure"} bdv (t', t)) (*isa = false, isa2 = true*)
   29.76 +(** )then error "sqrt_right: special case NOT ok" else ();     ( *isa*)
   29.77 +(**)then () else error "sqrt_right: special case OK";                      (*isa2*)
   29.78 +"~~~~~ fun sqrt_right , args:"; val ((pr:bool), thy, (_: subst), tu) =
   29.79 +  (false, @{theory "Pure"}, bdv, (t', t));
   29.80 +
   29.81 +"~~~~~ fun term_ord' , args:"; val (pr, _(*thy*), (t, u)) = (pr, thy(***), tu);
   29.82 +(*//----------------------------- open local ------------------------------------------------\\* )
   29.83 +val EQUAL =
   29.84 +    (*case*) int_ord (size_of_term' t, size_of_term' u) (*of*);
   29.85 +      val (f, ts) = strip_comb t and (g, us) = strip_comb u
   29.86 +val EQUAL =
   29.87 +        (*case*) hd_ord (f, g) (*of*);
   29.88 +
   29.89 +(**)val GREATER =                                             (*isa*)
   29.90 +(** )val LESS =                                               ( *isa2*)
   29.91 +           terms_ord str pr (ts, us)
   29.92 +"~~~~~ and terms_ord , args:"; val (_(*str*), pr, (ts, us)) = (str, pr, (ts, us));
   29.93 +
   29.94 +           list_ord (term_ord' pr (ThyC.get_theory "Isac_Knowledge")) (ts, us);
   29.95 +(*+*)list_ord: ('a * 'b -> order) -> 'a list * 'b list -> order;
   29.96 +(*+*)term_ord' pr (ThyC.get_theory "Isac_Knowledge"): term * term -> order;
   29.97 +"~~~~~ fun list_ord , args:"; val (elem_ord, (xs, ys)) =
   29.98 +  ((term_ord' pr (ThyC.get_theory "Isac_Knowledge")), (ts, us));
   29.99 +(*+*)UnparseC.terms xs = "[\"- 2\", \"x\"]";                  (*isa == ?*)
  29.100 +(*+*)UnparseC.terms ys = "[\"x\", \"- 2\"]";                  (*isa == ?*)
  29.101 +val EQUAL =
  29.102 +      (*case*) int_ord (length xs, length ys) (*of*);
  29.103 +
  29.104 +val GREATER =
  29.105 +           dict_ord elem_ord (xs, ys);
  29.106 +"~~~~~ fun dict_ord , args:"; val ( elem_ord, (x :: xs, y :: ys)) = (elem_ord, (xs, ys))
  29.107 +val GREATER =
  29.108 +    (*case*) elem_ord (x, y) (*of*);
  29.109 +val return = GREATER;
  29.110 +( *\\----------------------------- open local ------------------------------------------------//*)
  29.111 +
  29.112 +
  29.113 +"-------- check simple terms -------------------------------------------------------------------";
  29.114 +"-------- check simple terms -------------------------------------------------------------------";
  29.115 +"-------- check simple terms -------------------------------------------------------------------";
  29.116 +val rew_ord_ = sqrt_right false @{theory "Pure"};
  29.117 +
  29.118 +if rew_ord_ [] (@{term "1::real"}, @{term "2::real"}) =    true then () else error "";
  29.119 +if rew_ord_ [] (@{term "3::real"}, @{term "2::real"}) =   false then () else error "";
  29.120 +
  29.121 +if rew_ord_ [] (@{term "-1::real"}, @{term "-2::real"}) =  true then () else error "";
  29.122 +if rew_ord_ [] (@{term "-3::real"}, @{term "-2::real"}) = false then () else error "";
  29.123 +
  29.124 +if rew_ord_ [] (@{term "1::real"}, @{term "-1::real"}) =  false then () else error "";
  29.125 +if rew_ord_ [] (@{term "-1::real"}, @{term "1::real"}) =   true then () else error "";
  29.126 +
  29.127 +if rew_ord_ [] (@{term "x::real"}, @{term "2::real"}) =   false then () else error "";
  29.128 +if rew_ord_ [] (@{term "3::real"}, @{term "x::real"}) =    true then () else error "";
  29.129 +
  29.130 +
  29.131 +"-------- check all 'not >' in trace of Test_simplify on: x + 1 + - 1 * 2 = 0 ------------------";
  29.132 +"-------- check all 'not >' in trace of Test_simplify on: x + 1 + - 1 * 2 = 0 ------------------";
  29.133 +"-------- check all 'not >' in trace of Test_simplify on: x + 1 + - 1 * 2 = 0 ------------------";
  29.134 +(* the rewrite-order for rewriting single theorems in a Rule_Set is taken from 
  29.135 +*)
  29.136 +val Repeat {rew_ord = ("sqrt_right", rew_ord_), erls, ...} = Test_simplify;
  29.137 +(*#  rls: Test_simplify on: x + 1 + - 1 * 2 = 0   ..selected "not >:" from trace:*)
  29.138 +
  29.139 +(*##  not >:           "x + 1 + - 1 * 2" >              "x + 1 + - 1 * 2" *)
  29.140 +if rew_ord_ [] (@{term "x + 1 + - 1 * 2::real"}, @{term "x + 1 + - 1 * 2::real"}) = false
  29.141 +then () else error "term_ord' 1";
  29.142 +
  29.143 +(*##  not >:           "1 + x + - 1 * 2" >              "- 1 * 2 + (1 + x)" *)
  29.144 +if rew_ord_ [] (@{term "1 + x + - 1 * 2::real"}, @{term "- 1 * 2 + (1 + x)::real"}) = true
  29.145 +then () else error "term_ord' 2";
  29.146 +
  29.147 +(*##  not >:           "1 + x" >              "x + 1" *)
  29.148 +if rew_ord_ [] (@{term "1 + x::real"}, @{term "x + 1::real"}) = true
  29.149 +then () else error "term_ord' 3";
  29.150 +
  29.151 +(*##  not >:           "- 1 * 2" >              "2 * - 1" *)
  29.152 +if rew_ord_ [] (@{term "- 1 * 2::real"}, @{term "2 * - 1::real"}) = true
  29.153 +then () else error "term_ord' 4";
  29.154 +
  29.155 +(*##  not >:           "1 + (x + - 2)" >              "x + - 2 + 1" *)
  29.156 +if rew_ord_ [] (@{term "1 + (x + - 2)::real"}, @{term "x + - 2 + 1::real"}) = true
  29.157 +then () else error "term_ord' 5";
  29.158 +
  29.159 +(*##  not >:           "x + - 2" >              "- 2 + x"*)
  29.160 +if rew_ord_ [] (@{term "x + - 2::real"}, @{term "- 2 + x  ::real"}) = false
  29.161 +then () else error "term_ord' 5a";  (*<<<<<<<<<<<<<<----------------- false in trace isa2*)
  29.162 +
  29.163 +(*--------------------------------- ordered rew. (NOT) inhibited*)
  29.164 +
  29.165 +(*##  not >:           "1 + (-2 + x)" >              "-2 + x + 1" *)
  29.166 +if rew_ord_ [] (@{term "1 + (-2 + x)::real"}, @{term "-2 + x + 1::real"}) = true
  29.167 +then () else error "term_ord' 6";
  29.168 +
  29.169 +(*##  not >:           "- 2 + x" >              "x + - 2" *)
  29.170 +if rew_ord_ [] (@{term "- 2 + x::real"}, @{term "x + - 2::real"}) = true
  29.171 +then () else error "term_ord' 7";
  29.172 +
  29.173 +(*##  not >:           "- 2 + (1 + x)" >              "1 + (- 2 + x)" *)
  29.174 +if rew_ord_ [] (@{term "- 2 + (1 + x)::real"}, @{term "1 + (- 2 + x)::real"}) = true
  29.175 +then () else error "term_ord' 8";
  29.176 +
  29.177 +(*##  not >            "- 1 + x" >              "x + - 1" *)
  29.178 +if rew_ord_ [] (@{term "- 1 + x::real"}, @{term "x + - 1::real"}) = true
  29.179 +then () else error "term_ord' 9";
    30.1 --- a/test/Tools/isac/BaseDefinitions/substitution.sml	Mon Jun 21 22:08:01 2021 +0200
    30.2 +++ b/test/Tools/isac/BaseDefinitions/substitution.sml	Sun Jul 18 18:15:27 2021 +0200
    30.3 @@ -73,8 +73,11 @@
    30.4  case Subst.T_from_string_eqs @{theory} string_eqs of
    30.5    [(Free ("bdv_1", _), Free ("x", _)),
    30.6     (Free ("bdv_2", _), Free ("y", _)),
    30.7 -   (Free ("xxx", _), Const (\<^const_name>\<open>plus\<close>, _) $ Free ("aaa", _) $ Free ("111", _))] => ()
    30.8 -| _ => error "";
    30.9 +    (Free ("xxx", _),
   30.10 +     Const ("Groups.plus_class.plus", _) $ Free ("aaa", _) $
   30.11 +       (Const ("Num.numeral_class.numeral", _) $
   30.12 +         (Const ("Num.num.Bit1", _) $ _ )))] => ()
   30.13 +| _ => error "fun T_from_string_eqs";
   30.14  
   30.15  "-------- fun input_to_terms -------------------------------------------------";
   30.16  "-------- fun input_to_terms -------------------------------------------------";
    31.1 --- a/test/Tools/isac/BaseDefinitions/termC.sml	Mon Jun 21 22:08:01 2021 +0200
    31.2 +++ b/test/Tools/isac/BaseDefinitions/termC.sml	Sun Jul 18 18:15:27 2021 +0200
    31.3 @@ -3,16 +3,17 @@
    31.4     (c) due to copyright terms
    31.5  *)
    31.6  
    31.7 -"--------------------------------------------------------";
    31.8 -"table of contents --------------------------------------";
    31.9 -"--------------------------------------------------------";
   31.10 +"-----------------------------------------------------------------------------------------------";
   31.11 +"table of contents -----------------------------------------------------------------------------";
   31.12 +"-----------------------------------------------------------------------------------------------";
   31.13  "----------- numerals in Isabelle2011/12/13 -------------";
   31.14  "----------- inst_bdv -----------------------------------";
   31.15  "----------- subst_atomic_all ---------------------------";
   31.16  "----------- Pattern.match ------------------------------";
   31.17  "----------- fun TermC.matches --------------------------------";
   31.18  "----------- fun TermC.parse, fun TermC.parse_patt, fun T_a2real -------------------------------------------";
   31.19 -"----------- fun TermC.vars_of -----------------------------------------------------------------------";
   31.20 +"----------- fun TermC.vars_of -----------------------------------------------------------------";
   31.21 +"----------- fun TermC.vars --------------------------------------------------------------------";
   31.22  "----------- uminus_to_string ---------------------------";
   31.23  "----------- *** Problem.prep_input: syntax error in '#Where' of [v";
   31.24  "----------- check writeln, tracing for string markup ---";
   31.25 @@ -20,7 +21,7 @@
   31.26  "----------- fun str_of_int --------------------------------------------------------------------";
   31.27  "----------- fun TermC.scala_of_term -----------------------------------------------------------------";
   31.28  "----------- fun TermC.contains_Var ------------------------------------------------------------------";
   31.29 -"----------- fun ThmC_Def.int_opt_of_string, fun TermC.is_num ----------------------------------------------------";
   31.30 +"----------- fun int_opt_of_string, fun is_num -------------------------------------------------";
   31.31  "----------- fun TermC.is_f_x ------------------------------------------------------------------------";
   31.32  "----------- fun list2isalist, fun isalist2list ------------------------------------------------";
   31.33  "----------- fun TermC.strip_imp_prems' --------------------------------------------------------------";
   31.34 @@ -184,18 +185,18 @@
   31.35  "----------- inst_bdv -----------------------------------";
   31.36  "----------- inst_bdv -----------------------------------";
   31.37   if (UnparseC.term o Thm.prop_of o ThmC.numerals_to_Free) @{thm d1_isolate_add2} = 
   31.38 -     "\<not> ?bdv occurs_in ?a \<Longrightarrow>\n(?a + ?bdv = 0) = (?bdv = -1 * ?a)"
   31.39 +     "\<not> ?bdv occurs_in ?a \<Longrightarrow>\n(?a + ?bdv = 0) = (?bdv = - 1 * ?a)"
   31.40     then ()
   31.41     else error "termC.sml d1_isolate_add2";
   31.42   val subst = [(TermC.str2term "bdv", TermC.str2term "x")];
   31.43   val t = (Eval.norm o Thm.prop_of) (ThmC.numerals_to_Free @{thm d1_isolate_add2});
   31.44   val t' = TermC.inst_bdv subst t;
   31.45 - if UnparseC.term t' = "\<not> x occurs_in ?a \<Longrightarrow> (?a + x = 0) = (x = -1 * ?a)"
   31.46 + if UnparseC.term t' = "\<not> x occurs_in ?a \<Longrightarrow> (?a + x = 0) = (x = - 1 * ?a)"
   31.47     then ()
   31.48     else error "termC.sml inst_bdv 1";
   31.49  if (UnparseC.term o Thm.prop_of o ThmC.numerals_to_Free) @{thm separate_bdvs_add} = 
   31.50 -  "[] from [?bdv_1.0, ?bdv_2.0, ?bdv_3.0,\n         "
   31.51 -  ^ "?bdv_4.0] occur_exactly_in ?a \<Longrightarrow>\n(?a + ?b = ?c) = (?b = ?c + -1 * ?a)"
   31.52 +  "[] from [?bdv_1.0, ?bdv_2.0, ?bdv_3.0,\n         " ^
   31.53 +  "?bdv_4.0] occur_exactly_in ?a \<Longrightarrow>\n(?a + ?b = ?c) = (?b = ?c + - (1::?'a) * ?a)"
   31.54  then () else error "termC.sml separate_bdvs_add";
   31.55  (*default_print_depth 5;*)
   31.56  
   31.57 @@ -207,8 +208,8 @@
   31.58  val t = (Eval.norm o Thm.prop_of) (ThmC.numerals_to_Free @{thm separate_bdvs_add});
   31.59  val t' = TermC.inst_bdv subst t;
   31.60  
   31.61 -if UnparseC.term t' = "[] from [c, c_2, c_3, c_4] occur_exactly_in ?a \<Longrightarrow>\n"
   31.62 -  ^ "(?a + ?b = ?c) = (?b = ?c + -1 * ?a)"
   31.63 +if UnparseC.term t' = "[] from [c, c_2, c_3, c_4] occur_exactly_in ?a \<Longrightarrow>\n" ^
   31.64 +  "(?a + ?b = ?c) = (?b = ?c + - (1::?'a) * ?a)"
   31.65  then () else error "termC.sml inst_bdv 2";
   31.66  
   31.67  "----------- subst_atomic_all ---------------------------";
   31.68 @@ -232,8 +233,8 @@
   31.69  "----------- Pattern.match ------------------------------";
   31.70  "----------- Pattern.match ------------------------------";
   31.71  "----------- Pattern.match ------------------------------";
   31.72 - val t = (Thm.term_of o the o (TermC.parse \<^theory>)) "3 * x\<up>2 = (1::real)";
   31.73 - val pat = (TermC.free2var o Thm.term_of o the o (TermC.parse \<^theory>)) "a * b\<up>2 = (c::real)";
   31.74 + val t = TermC.str2term "3 * x\<up>2 = (1::real)";
   31.75 + val pat = (TermC.free2var o TermC.str2term) "a * b\<up>2 = (c::real)";
   31.76   (*        ! \<up>  \<up> ^^!... necessary for Pattern.match, see Logic.varify_global below*)
   31.77   val insts = Pattern.match @{theory "Isac_Knowledge"} (pat, t) (Vartab.empty, Vartab.empty);
   31.78  (*default_print_depth 3; 999*) insts; 
   31.79 @@ -297,8 +298,8 @@
   31.80     else error "termC.sml diff.behav. in TermC.matches true 2";
   31.81  "----- test 2b false";
   31.82   val tm = TermC.str2term "-8 - 2 * x + x ^ 2 = (3::real)";     (*<<<<<<<-------------*)
   31.83 - if TermC.matches thy tm pa then () 
   31.84 -   else error "termC.sml diff.behav. in TermC.matches false 2";
   31.85 + if TermC.matches thy tm pa then error "termC.sml diff.behav. in TermC.matches false 2"
   31.86 +   else ();
   31.87  (* i.e. !!!!!!!!!!!!!!!!! THIS KIND OF PATTERN IS NOT RELIABLE !!!!!!!!!!!!!!!!!
   31.88  if TermC.matches thy tm pa then error "termC.sml diff.behav. in TermC.matches false 2"
   31.89    else ();*)
   31.90 @@ -400,9 +401,9 @@
   31.91    |> writeln
   31.92  end *)
   31.93  
   31.94 -"----------- fun TermC.vars_of -----------------------------------------------------------------------";
   31.95 -"----------- fun TermC.vars_of -----------------------------------------------------------------------";
   31.96 -"----------- fun TermC.vars_of -----------------------------------------------------------------------";
   31.97 +"----------- fun TermC.vars_of -----------------------------------------------------------------";
   31.98 +"----------- fun TermC.vars_of -----------------------------------------------------------------";
   31.99 +"----------- fun TermC.vars_of -----------------------------------------------------------------";
  31.100  val thy = @{theory Partial_Fractions};
  31.101  val ctxt = Proof_Context.init_global @{theory}
  31.102  
  31.103 @@ -581,9 +582,9 @@
  31.104  val t = TermC.parse_patt @{theory} "z = 3";
  31.105  if TermC.contains_Var t = false then () else error "TermC.contains_Var  ?z = 3";
  31.106  
  31.107 -"----------- fun ThmC_Def.int_opt_of_string, fun TermC.is_num ----------------------------------------------------";
  31.108 -"----------- fun ThmC_Def.int_opt_of_string, fun TermC.is_num ----------------------------------------------------";
  31.109 -"----------- fun ThmC_Def.int_opt_of_string, fun TermC.is_num ----------------------------------------------------";
  31.110 +"----------- fun int_opt_of_string, fun is_num -------------------------------------------------";
  31.111 +"----------- fun int_opt_of_string, fun is_num -------------------------------------------------";
  31.112 +"----------- fun int_opt_of_string, fun is_num -------------------------------------------------";
  31.113  case ThmC_Def.int_opt_of_string "123" of
  31.114    SOME 123 => () | _ => raise error "ThmC_Def.int_opt_of_string  123  changed";
  31.115  case ThmC_Def.int_opt_of_string "(-123)" of
  31.116 @@ -687,9 +688,50 @@
  31.117  "----------- fun ThmC_Def.num_to_Free -------------------------------------------------------------";
  31.118  "----------- fun ThmC_Def.num_to_Free -------------------------------------------------------------";
  31.119  "----------- fun ThmC_Def.num_to_Free -------------------------------------------------------------";
  31.120 -if ThmC_Def.num_to_Free @{term "123::real"} = Free ("123", HOLogic.realT)
  31.121 -then () else error "ThmC_Def.num_to_Free '123' changed";
  31.122 -if ThmC_Def.num_to_Free @{term "1::real"} = Free ("1", HOLogic.realT)
  31.123 -then () else error "ThmC_Def.num_to_Free '1' changed";
  31.124 -if ThmC_Def.num_to_Free @{term "0::real"} = Free ("0", HOLogic.realT)
  31.125 -then () else error "ThmC_Def.num_to_Free '0' changed";
  31.126 +case ThmC_Def.num_to_Free @{term "123::real"} of 
  31.127 +  Const ("Num.numeral_class.numeral", _) $
  31.128 +     (Const ("Num.num.Bit1", _) $
  31.129 +       (Const ("Num.num.Bit1", _) $
  31.130 +         (Const ("Num.num.Bit0", _) $ (Const ("Num.num.Bit1", _) $ (Const ("Num.num.Bit1", _) $ (Const ("Num.num.Bit1", _) $ Const ("Num.num.One", _))))))) => ()
  31.131 +| _ => error "ThmC_Def.num_to_Free '123' changed";
  31.132 +
  31.133 +case ThmC_Def.num_to_Free @{term "1::real"} of 
  31.134 +  Const ("Groups.one_class.one", _) => ()
  31.135 +| _ => error "ThmC_Def.num_to_Free '1' changed";
  31.136 +
  31.137 +case ThmC_Def.num_to_Free @{term "0::real"} of 
  31.138 +  Const ("Groups.zero_class.zero", _) => ()
  31.139 +| _ => error "ThmC_Def.num_to_Free '0' changed";
  31.140 +
  31.141 +"----------- fun mk_frac, proper term with uminus ----------------------------------------------";
  31.142 +"----------- fun mk_frac, proper term with uminus ----------------------------------------------";
  31.143 +"----------- fun mk_frac, proper term with uminus ----------------------------------------------";
  31.144 +     TermC.mk_frac: typ -> int * (int * int) -> term;
  31.145 +     TermC.mk_frac HOLogic.realT (~1, (6, 8));
  31.146 +"~~~~~ fun mk_frac , args:"; val (T, (sg, (i1, i2))) = (HOLogic.realT, (~1, (6, 8)));
  31.147 +val xxx = (*return value*) Const ("Rings.divide_class.divide", T --> T) $
  31.148 +      mk_negative T (HOLogic.mk_number T i1) $ HOLogic.mk_number T i2;
  31.149 +
  31.150 +val (T_div, T_uminus) =
  31.151 +case xxx of
  31.152 +  Const ("Rings.divide_class.divide", T_div) $                                  (* divide *)
  31.153 +    (Const ("Groups.uminus_class.uminus", T_uminus) $                           (* uminus *)
  31.154 +      (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ _ ))) $
  31.155 +    (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ _ )) 
  31.156 +    => (T_div, T_uminus)
  31.157 +| _ => error "mk_frac 6 / - 8 \<longrightarrow> - 3 / 4 CHANGED";
  31.158 +
  31.159 +case T_div of
  31.160 +  Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]) => ()
  31.161 +| _ => error "T_div CHANGED in fun mk_frac";
  31.162 +case T_uminus of
  31.163 +  Type ("fun", [Type ("Real.real", []), Type ("Real.real", [])]) => ()
  31.164 +| _ => error "T_uminus CHANGED in fun mk_frac";
  31.165 +
  31.166 +(* IMproper term for "6 / - 8 = - 3 / (4::real)"
  31.167 +
  31.168 +  (Const ("Groups.uminus_class.uminus", _) $                                    (* uminus *)
  31.169 +    (Const ("Rings.divide_class.divide", _) $                                   (* divide *)
  31.170 +      (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ _ ))) $
  31.171 +      (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ _ ) ))))
  31.172 +*)
    32.1 --- a/test/Tools/isac/BridgeLibisabelle/thy-hierarchy.sml	Mon Jun 21 22:08:01 2021 +0200
    32.2 +++ b/test/Tools/isac/BridgeLibisabelle/thy-hierarchy.sml	Sun Jul 18 18:15:27 2021 +0200
    32.3 @@ -33,20 +33,20 @@
    32.4  
    32.5  val [_, (thmID, term)] = Thy_Hierarchy.thms_of_rlss thy rlss;
    32.6  
    32.7 -if thmID = "Poly.real_mult_minus1" (* WAS "??.unknown" from Pure/more_thm.ML *)
    32.8 +if thmID = "Poly.real_mult_minus1_sym"
    32.9  then () else error "thms_of_rlss changed";
   32.10  
   32.11  "~~~~~ fun thms_of_rlss, args:"; val (thy, rlss) = (@{theory Isac_Knowledge}, rlss);
   32.12  val rlss' = (rlss : (Rule_Set.id * (ThyC.id * Rule_Set.T)) list)
   32.13    |> map (Thy_Hierarchy.thms_of_rls o #2 o #2)
   32.14 -    (* = [[], [Thm ("real_diff_minus", "?a - ?b = ?a + -1 * ?b"), 
   32.15 -      \<^rule_thm_sym>\<open>real_mult_minus1\<close>, "- ?z1 = -1 * ?z1")]]*)
   32.16 +    (* = [[], [Thm ("real_diff_minus", "?a - ?b = ?a + - 1 * ?b"), 
   32.17 +      Thm ("sym_real_mult_minus1", "- ?z1 = - 1 * ?z1")]]*)
   32.18    |> flat
   32.19 -    (* = [Thm ("real_diff_minus", "?a - ?b = ?a + -1 * ?b"), 
   32.20 -      \<^rule_thm_sym>\<open>real_mult_minus1\<close>, "- ?z1 = -1 * ?z1")]*)
   32.21 +    (* = [Thm ("real_diff_minus", "?a - ?b = ?a + - 1 * ?b"), 
   32.22 +      Thm ("sym_real_mult_minus1", "- ?z1 = - 1 * ?z1")]*)
   32.23    |> map (ThmC.revert_sym_rule thy)
   32.24 -    (* = [Thm ("Poly.real_diff_minus", "?a - ?b = ?a + -1 * ?b"), 
   32.25 -      Thm ("Delete.real_mult_minus1", "-1 * ?z = - ?z")] : rule list*)
   32.26 +    (* = [Thm ("Poly.real_diff_minus", "?a - ?b = ?a + - 1 * ?b"), 
   32.27 +      Thm ("Delete.real_mult_minus1", "- 1 * ?z = - ?z")] : rule list*)
   32.28    |> map (fn Thm (thmID, thm) => (thmID, Thm.prop_of thm))
   32.29      (* = [("Poly.real_diff_minus", Const ("HOL.Trueprop", "bool \<Rightarrow> prop") $ ...,
   32.30        ("Delete.real_mult_minus1", Const ("HOL.Trueprop", ...)] : (string * term) list*)
    33.1 --- a/test/Tools/isac/BridgeLibisabelle/thy-present.sml	Mon Jun 21 22:08:01 2021 +0200
    33.2 +++ b/test/Tools/isac/BridgeLibisabelle/thy-present.sml	Sun Jul 18 18:15:27 2021 +0200
    33.3 @@ -81,7 +81,7 @@
    33.4  "----- initContext -----";
    33.5  reset_states ();
    33.6  CalcTree 
    33.7 -    [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
    33.8 +    [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
    33.9        ("Test",
   33.10         ["LINEAR", "univariate", "equation", "test"],
   33.11         ["Test", "solve_linear"]))];
   33.12 @@ -105,7 +105,7 @@
   33.13  "----- checkContext -----";
   33.14  reset_states ();
   33.15  CalcTree 
   33.16 -    [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
   33.17 +    [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
   33.18        ("Test",
   33.19         ["LINEAR", "univariate", "equation", "test"],
   33.20         ["Test", "solve_linear"]))];
    34.1 --- a/test/Tools/isac/BridgeLibisabelle/use-cases.sml	Mon Jun 21 22:08:01 2021 +0200
    34.2 +++ b/test/Tools/isac/BridgeLibisabelle/use-cases.sml	Sun Jul 18 18:15:27 2021 +0200
    34.3 @@ -3,6 +3,10 @@
    34.4     Author: Walther Neuper
    34.5     (c) copyright due to lincense terms.
    34.6  
    34.7 +Tests the interface of isac's SML-kernel in accordance to java-tests/isac.bridge.
    34.8 +Some tests are outcommented since "eliminate ThmC.numerals_to_Free";
    34.9 +these are considered irrelevant for Isabelle/Isac.
   34.10 +
   34.11  WN050707 ... if true, the test ist marked with a \label referring
   34.12  to the same UC in isac-docu.tex as the JUnit testcase.
   34.13  WN120210?not ME: added some labels, which are not among the above,
   34.14 @@ -90,7 +94,7 @@
   34.15  reset_states ();
   34.16  
   34.17   CalcTree      (*start of calculation, return No.1*)
   34.18 -     [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
   34.19 +     [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
   34.20         ("Test", 
   34.21  	["LINEAR", "univariate", "equation", "test"],
   34.22  	["Test", "solve_linear"]))];
   34.23 @@ -107,7 +111,7 @@
   34.24   autoCalculate 1 (Steps 1);
   34.25  (*-----since Model_Problem + complete_mod_ in case cas of SOME-----*
   34.26  (*2*)  fetchProposedTactic 1;
   34.27 - setNextTactic 1 (Add_Given "equality (1 + -1 * 2 + x = 0)");
   34.28 + setNextTactic 1 (Add_Given "equality (1 + - 1 * 2 + x = 0)");
   34.29   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1); (*equality added*);
   34.30  
   34.31  (*3*)  fetchProposedTactic 1;
   34.32 @@ -149,10 +153,10 @@
   34.33  (*8*)  autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1); (*<---------------------- orig. test code*)
   34.34  
   34.35   val (ptp as (pt,p), tacis) = get_calc 1; get_pos 1 1; (*<---------------------- orig. test code*)
   34.36 -(*+isa=REP*) if p = ([1], Frm) andalso UnparseC.term (get_obj g_form pt [1]) = "1 + -1 * 2 + x = 0"
   34.37 +(*+isa=REP*) if p = ([1], Frm) andalso UnparseC.term (get_obj g_form pt [1]) = "1 + - 1 * 2 + x = 0"
   34.38  andalso Istate.string_of (get_istate_LI pt p)
   34.39 -  = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\", \"\n(v_v, x)\"], [], empty, NONE, \n??.empty, ORundef, false, true)"
   34.40 -then () else error "refFormula =   1 + -1 * 2 + x = 0   changed";
   34.41 +  = "Pstate ([\"\n(e_e, 1 + - 1 * 2 + x = 0)\", \"\n(v_v, x)\"], [], empty, NONE, \n??.empty, ORundef, false, true)"
   34.42 +then () else error "refFormula =   1 + - 1 * 2 + x = 0   changed";
   34.43  (*-------------------------------------------------------------------------*)
   34.44  
   34.45  (*9*) fetchProposedTactic 1; (*<----------------------------------------------------- orig. test code*)
   34.46 @@ -171,11 +175,11 @@
   34.47  (*//******************* Step.by_tactic returns tac_ + istate + cstate *****************************\\*)
   34.48  Step.by_tactic : Tactic.input -> state -> string * (State_Steps.T * pos' list * state);
   34.49  if Istate.string_of istate
   34.50 - = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
   34.51 + = "Pstate ([\"\n(e_e, 1 + - 1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + - 1 * (1 + - 1 * 2), ORundef, true, true)"
   34.52  then () else error "from Step.by_tactic return --- changed 1";
   34.53  
   34.54  if Istate.string_of (get_istate_LI (fst cstate) (snd cstate))
   34.55 - = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
   34.56 + = "Pstate ([\"\n(e_e, 1 + - 1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + - 1 * (1 + - 1 * 2), ORundef, true, true)"
   34.57  then () else error "from Step.by_tactic return --- changed 2";
   34.58  (*\\******************* Step.by_tactic returns tac_ + istate + cstate *****************************//*)
   34.59  
   34.60 @@ -194,7 +198,7 @@
   34.61  (*+*)Safe_Step: Istate.T * Proof.context * Tactic.T -> input_tactic_result;
   34.62  (********************* locate_input_tactic returns cstate * istate * Proof.context  *************)
   34.63  (*+*)if Istate.string_of istate
   34.64 -(*+isa*) = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
   34.65 +(*+isa*) = "Pstate ([\"\n(e_e, 1 + - 1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + - 1 * (1 + - 1 * 2), ORundef, true, true)"
   34.66  then case m of Rewrite_Set_Inst' _ => ()
   34.67  else error "from locate_input_tactic return --- changed";
   34.68  
   34.69 @@ -220,8 +224,8 @@
   34.70  (*+isa==REP*)val [(Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"),
   34.71       Rewrite_Set_Inst' _, (pos', (istate, ctxt)))] = tacis;
   34.72  (*+*)if pos' = ([1], Res) andalso Istate.string_of istate
   34.73 - = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
   34.74 -then () else error "init. step 1 + -1 * 2 + x = 0 changed";
   34.75 + = "Pstate ([\"\n(e_e, 1 + - 1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + - 1 * (1 + - 1 * 2), ORundef, true, true)"
   34.76 +then () else error "init. step 1 + - 1 * 2 + x = 0 changed";
   34.77  
   34.78         val pIopt = get_pblID (pt,ip);
   34.79         (*if*) ip = ([], Pos.Res);(*else*)
   34.80 @@ -232,8 +236,8 @@
   34.81  val ("ok", [], ptp as (pt, p)) = xxxx;
   34.82                                           
   34.83  if Istate.string_of (get_istate_LI pt p) (*                <>                 <>                 <>                 <>                     \<up> \<up> \<up> \<up> ^*)
   34.84 -(*REP*) = "Pstate ([\"\n(e_e, 1 + -1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + -1 * (1 + -1 * 2), ORundef, true, true)"
   34.85 -then () else error "REP autoCalculate on (e_e, 1 + -1 * 2 + x = 0) changed"
   34.86 +(*REP*) = "Pstate ([\"\n(e_e, 1 + - 1 * 2 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + - 1 * (1 + - 1 * 2), ORundef, true, true)"
   34.87 +then () else error "REP autoCalculate on (e_e, 1 + - 1 * 2 + x = 0) changed"
   34.88  
   34.89  "~~~~~ from TOPLEVEL to states return:";  upd_calc cI (ptp, []); upd_ipos cI 1 p;
   34.90  (*\\=========================================== isa <> REP (2) ===============================//*)
   34.91 @@ -346,7 +350,7 @@
   34.92   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
   34.93  
   34.94   fetchProposedTactic 1;
   34.95 - setNextTactic 1 (Add_Given "equality (-1 + x = 0)");
   34.96 + setNextTactic 1 (Add_Given "equality (- 1 + x = 0)");
   34.97   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);
   34.98  
   34.99   fetchProposedTactic 1;
  34.100 @@ -463,7 +467,7 @@
  34.101  "--------- solve_linear as rootpbl AUTO CompleteCalc ----";
  34.102  (*WN120210?not ME:\label{SPECIFY:START:auto} UC 30.2.4.2 p.174*)
  34.103   CalcTree
  34.104 -     [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
  34.105 +     [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
  34.106         ("Test", 
  34.107  	["LINEAR", "univariate", "equation", "test"],
  34.108  	["Test", "solve_linear"]))];
  34.109 @@ -487,7 +491,7 @@
  34.110  "--------- solve_linear as rootpbl AUTO CompleteHead/Eval ";
  34.111  (* ERROR: error in kernel ?? *)
  34.112   CalcTree
  34.113 -     [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
  34.114 +     [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
  34.115         ("Test", 
  34.116  	["LINEAR", "univariate", "equation", "test"],
  34.117  	["Test", "solve_linear"]))];
  34.118 @@ -543,11 +547,11 @@
  34.119   moveActiveRoot 1;
  34.120   autoCalculate 1 CompleteCalcHead;
  34.121  
  34.122 -val ((Nd (PblObj {fmz = (fm, ("Test", pblID, metID)), loc = (SOME (env, ctxt1), NONE), 
  34.123 -      ctxt = ctxt2, meth,
  34.124 +val ((Nd (PblObj {fmz = (fm, ("Test", pblID, metID)), loc = (SOME (env, ctxt1), NONE),
  34.125 +      meth, probl,
  34.126        spec = ("Test", ["sqroot-test", "univariate", "equation", "test"], 
  34.127          ["Test", "squ-equ-test-subpbl1"]), 
  34.128 -      probl, branch = TransitiveB, origin, ostate = Incomplete, result}, []),
  34.129 +      branch = TransitiveB, ostate = Incomplete (*!?\<forall>*), ...}, []), 
  34.130     ([], Met)), []) = get_calc 1;
  34.131  if length meth = 3 andalso length probl = 3 (*just some items tested*) then () 
  34.132  else error "--- mini-subpbl AUTO CompleteCalcHead ---";
  34.133 @@ -558,7 +562,7 @@
  34.134  "--------- solve_linear as rootpbl AUTO CompleteModel ---";
  34.135  reset_states ();
  34.136   CalcTree
  34.137 -     [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
  34.138 +     [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
  34.139         ("Test", 
  34.140  	["LINEAR", "univariate", "equation", "test"],
  34.141  	["Test", "solve_linear"]))];
  34.142 @@ -619,7 +623,7 @@
  34.143  (*setContext 1 p "thy_isac_Test-rls-Test_simplify";*)
  34.144   val (((pt,_),_), p) = (get_calc 1, get_pos 1 1);
  34.145   val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.146 - if p = ([1], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "x + 1 + -1 * 2 = 0"
  34.147 + if p = ([1], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "x + 1 + - 1 * 2 = 0"
  34.148   then () else error "--- setContext..Thy --- autoCalculate 1 (Steps 1) #1";
  34.149  
  34.150   autoCalculate 1 CompleteCalc;
  34.151 @@ -639,13 +643,13 @@
  34.152      ["Test", "squ-equ-test-subpbl1"]))];
  34.153   Iterator 1; moveActiveRoot 1;
  34.154   autoCalculate 1 CompleteToSubpbl;
  34.155 - refFormula 1 (get_pos 1 1); (*<ISA> -1 + x = 0 </ISA>*);
  34.156 + refFormula 1 (get_pos 1 1); (*<ISA> - 1 + x = 0 </ISA>*);
  34.157   val ((pt,_),_) = get_calc 1;
  34.158   val str = pr_ctree pr_short pt;
  34.159   writeln str;
  34.160 - if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n"
  34.161 + if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + - 1 * 2 = 0\n"
  34.162   then () else 
  34.163 - error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl-1";
  34.164 + error "FE-interface.sml: diff.behav. in mini-subpbl CompleteToSubpbl- 1";
  34.165  
  34.166   autoCalculate 1 (Steps 1); (*proceeds only, if NOT 1 step before subplb*)
  34.167   autoCalculate 1 CompleteToSubpbl;
  34.168 @@ -728,6 +732,8 @@
  34.169   setNextTactic 1 (Apply_Method ["PolyEq", "solve_d1_polyeq_equation"]);
  34.170   autoCalculate 1 (Steps 1); fetchProposedTactic 1;
  34.171   setNextTactic 1 (Rewrite_Set_Inst (["(''bdv'',x)"], "d1_polyeq_simplify"));
  34.172 +(*SINCE eliminate ThmC.numerals_to_Free: 
  34.173 +    rewrite_set_, rewrite_ "- 4 / 3 = - 4 / 3" x = - 4 / 3 = NONE---------------------------\\* )
  34.174   autoCalculate 1 (Steps 1); fetchProposedTactic 1;
  34.175   setNextTactic 1 (Rewrite_Set "polyeq_simplify");
  34.176   autoCalculate 1 (Steps 1); fetchProposedTactic 1;
  34.177 @@ -747,6 +753,8 @@
  34.178   if get_pos 1 1 = ([], Res) andalso UnparseC.term t = "[x = -4 / 3]" then ()
  34.179   else writeln "FE-inteface.sml: diff.behav. in rat-eq + subpbl: no_met, NO ..";
  34.180   DEconstrCalcTree 1;
  34.181 +( *SINCE eliminate ThmC.numerals_to_Free: 
  34.182 +    rewrite_set_, rewrite_ "- 4 / 3 = - 4 / 3" x = - 4 / 3 = NONE---------------------------//*)
  34.183  
  34.184  
  34.185  "--------- tryMatchProblem, tryRefineProblem ------------";
  34.186 @@ -844,7 +852,7 @@
  34.187   Test_Tool.show_pt pt;
  34.188   val p = get_pos 1 1;
  34.189   val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.190 - if UnparseC.term f = "[x = -1, x = -3]" andalso p = ([], Res) then () else 
  34.191 + if UnparseC.term f = "[x = - 1, x = -3]" andalso p = ([], Res) then () else 
  34.192   error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
  34.193  
  34.194  (*------------ \<up> -inserted-----------------------------------------------*)
  34.195 @@ -867,7 +875,7 @@
  34.196   Test_Tool.show_pt pt;
  34.197   val p = get_pos 1 1;
  34.198   val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.199 - if UnparseC.term f = "[x = -1, x = -3]" andalso p = ([], Res) then () else 
  34.200 + if UnparseC.term f = "[x = - 1, x = -3]" andalso p = ([], Res) then () else 
  34.201   error "FE-interface.sml: diff.behav. in tryMatchProblem, tryRefine";
  34.202   DEconstrCalcTree 1;
  34.203  ( *\-----ERROR INTRODUCED BY CHILD OF 33913fe24685 --------------------------------------------/*)
  34.204 @@ -1029,8 +1037,8 @@
  34.205   CalcTree [(fmz, sp)];
  34.206   Iterator 1; moveActiveRoot 1;
  34.207   refFormula 1 (get_pos 1 1);
  34.208 - modifyCalcHead 1 (([],Pbl),"solve (1+-1*2+x=(0::real))",
  34.209 -		  [P_Spec.Given ["equality (1+-1*2+x=(0::real))", "solveFor x"],
  34.210 + modifyCalcHead 1 (([],Pbl),"solve (1+- 1*2+x=(0::real))",
  34.211 +		  [P_Spec.Given ["equality (1+- 1*2+x=(0::real))", "solveFor x"],
  34.212  		   P_Spec.Find ["solutions L"]],
  34.213  		  Pbl, 
  34.214  		  ("Test", ["LINEAR", "univariate", "equation", "test"],
  34.215 @@ -1052,7 +1060,7 @@
  34.216   val (fmz, sp) = ([], ("", [], []));
  34.217   CalcTree [(fmz, sp)];
  34.218   Iterator 1; moveActiveRoot 1;
  34.219 - modifyCalcHead 1 (([],Pbl),"solveTest (1+-1*2+x=0,x)", [], Pbl, ("", [], []));
  34.220 + modifyCalcHead 1 (([],Pbl),"solveTest (1+- 1*2+x=0,x)", [], Pbl, ("", [], []));
  34.221   autoCalculate 1 CompleteCalc;
  34.222   refFormula 1 (get_pos 1 1);
  34.223   val ((pt,_),_) = get_calc 1;
  34.224 @@ -1129,9 +1137,11 @@
  34.225   fetchApplicableTactics 1 99999 ([],Res);
  34.226  DEconstrCalcTree 1;
  34.227  
  34.228 +(*SINCE eliminate ThmC.numerals_to_Free: loops ---------------------------------------------\\* )
  34.229  "--------- getAssumptions, getAccumulatedAsms -----------";
  34.230  "--------- getAssumptions, getAccumulatedAsms -----------";
  34.231  "--------- getAssumptions, getAccumulatedAsms -----------";
  34.232 +reset_states ();
  34.233  CalcTree
  34.234  [(["equality (x/(x \<up> 2 - 6*x+9) - 1/(x \<up> 2 - 3*x) =1/x)",
  34.235  	   "solveFor x", "solutions L"], 
  34.236 @@ -1141,16 +1151,16 @@
  34.237  val ((pt,_),_) = get_calc 1;
  34.238  val p = get_pos 1 1;
  34.239  val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.240 -(*============ inhibit exn WN120316 compare 2002--2011 ===========================
  34.241 +(*============ inhibit exn WN120316 compare 2002-- 2011 ===========================
  34.242  if map UnparseC.term asms = 
  34.243 - ["True |\n~ lhs ((3 + -1 * x + x \<up> 2) * x =\n" ^
  34.244 + ["True |\n~ lhs ((3 + - 1 * x + x \<up> 2) * x =\n" ^
  34.245    "       1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)) is_poly_in x", "-6 * x + 5 * x \<up>\<up> 2 = 0", 
  34.246    "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x",
  34.247    "lhs (-6 * x + 5 * x \<up>\<up> 2 = 0) has_degree_in x = 2", 
  34.248    "9 * x + -6 * x \<up> 2 + x \<up> 3 ~= 0"] 
  34.249  andalso UnparseC.term f = "[-6 * x + 5 * x \<up> 2 = 0]" andalso p = ([], Res) then ()
  34.250 -else error "TODO compare 2002--2011"; (*...data during test --- x / (x  \<up>  2 - 6 * x + 9) - 1...*)
  34.251 -============ inhibit exn WN120316 compare 2002--2011 ===========================*)
  34.252 +else error "TODO compare 2002-- 2011"; (*...data during test --- x / (x  \<up>  2 - 6 * x + 9) - 1...*)
  34.253 +============ inhibit exn WN120316 compare 2002-- 2011 ===========================*)
  34.254  
  34.255  if p = ([], Res) andalso UnparseC.term f = "[x = 6 / 5]"
  34.256  andalso map UnparseC.term asms = []
  34.257 @@ -1164,12 +1174,13 @@
  34.258  getAccumulatedAsms 1 ([3], Res);
  34.259  getAccumulatedAsms 1 ([5], Res);
  34.260  DEconstrCalcTree 1;
  34.261 +( *SINCE eliminate ThmC.numerals_to_Free: loops ---------------------------------------------//*)
  34.262  
  34.263  "--------- arbitrary combinations of steps --------------";
  34.264  "--------- arbitrary combinations of steps --------------";
  34.265  "--------- arbitrary combinations of steps --------------";
  34.266   CalcTree      (*start of calculation, return No.1*)
  34.267 -     [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
  34.268 +     [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
  34.269         ("Test", 
  34.270  	["LINEAR", "univariate", "equation", "test"],
  34.271  	["Test", "solve_linear"]))];
  34.272 @@ -1225,7 +1236,7 @@
  34.273   autoCalculate 1 CompleteCalcHead;
  34.274   autoCalculate 1 (Steps 1);
  34.275   autoCalculate 1 (Steps 1);
  34.276 - appendFormula 1 "-1 + x = 0" (*|> Future.join*);
  34.277 + appendFormula 1 "- 1 + x = 0" (*|> Future.join*);
  34.278   (*... returns calcChangedEvent with*)
  34.279   val (unc, del, gen) = (([1],Res), ([1],Res), ([2],Res));
  34.280   getFormulaeFromTo 1 unc gen 99999 (*all levels*) false;
  34.281 @@ -1233,7 +1244,7 @@
  34.282   val ((pt,_),_) = get_calc 1;
  34.283   val p = get_pos 1 1;
  34.284   val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.285 - if UnparseC.term f = "-1 + x = 0" andalso p = ([2], Res) then () else 
  34.286 + if UnparseC.term f = "- 1 + x = 0" andalso p = ([2], Res) then () else 
  34.287   error "FE-interface.sml: diff.behav. in FORMULA:enter} right";
  34.288  DEconstrCalcTree 1;
  34.289  
  34.290 @@ -1301,7 +1312,7 @@
  34.291   val ((pt,_),_) = get_calc 1;
  34.292   val p = get_pos 1 1;
  34.293   val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.294 - if UnparseC.term f = "x + 1 + -1 * 2 = 0" andalso p = ([1], Res) then () else 
  34.295 + if UnparseC.term f = "x + 1 + - 1 * 2 = 0" andalso p = ([1], Res) then () else 
  34.296   error "FE-interface.sml: diff.behav. in FORMULA:enter} NOTok";
  34.297  DEconstrCalcTree 1;
  34.298  
  34.299 @@ -1316,13 +1327,13 @@
  34.300   moveActiveRoot 1;
  34.301   autoCalculate 1 CompleteCalc;
  34.302   moveActiveFormula 1 ([2],Res);
  34.303 - replaceFormula 1 "-1 + x = 0" (*i.e. repeats input*);
  34.304 + replaceFormula 1 "- 1 + x = 0" (*i.e. repeats input*);
  34.305   (*... returns <ERROR> formula not changed </ERROR>*)
  34.306  
  34.307   val ((pt,_),_) = get_calc 1;
  34.308   val p = get_pos 1 1;
  34.309   val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.310 - if UnparseC.term f = "-1 + x = 0" andalso p = ([2], Res) then () else 
  34.311 + if UnparseC.term f = "- 1 + x = 0" andalso p = ([2], Res) then () else 
  34.312   error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
  34.313   if map fst3 (ME_Misc.get_interval ([2],Res) ([],Res) 9999 pt) = 
  34.314      [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
  34.315 @@ -1333,17 +1344,17 @@
  34.316   CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
  34.317     ("Test", ["sqroot-test", "univariate", "equation", "test"],
  34.318      ["Test", "squ-equ-test-subpbl1"]))];
  34.319 - Iterator 2;
  34.320 + Iterator 2; (*! ! ! 1 CalcTree inbetween reset_states (); *)
  34.321   moveActiveRoot 2;
  34.322   autoCalculate 2 CompleteCalc;
  34.323   moveActiveFormula 2 ([2],Res);
  34.324 - replaceFormula 2 "-1 + x = 0" (*i.e. repeats input*);
  34.325 + replaceFormula 2 "- 1 + x = 0" (*i.e. repeats input*);
  34.326   (*... returns <ERROR> formula not changed </ERROR>*)
  34.327  
  34.328   val ((pt,_),_) = get_calc 2;
  34.329   val p = get_pos 2 1;
  34.330   val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.331 - if UnparseC.term f = "-1 + x = 0" andalso p = ([2], Res) then () else 
  34.332 + if UnparseC.term f = "- 1 + x = 0" andalso p = ([2], Res) then () else 
  34.333   error "FE-interface.sml: diff.behav. in FORMULA:replace} right 1";
  34.334   if map fst3 (ME_Misc.get_interval ([2],Res) ([],Res) 9999 pt) = 
  34.335      [([2], Res), ([3], Pbl), ([3, 1], Frm), ([3, 1], Res), ([3, 2], Res),
  34.336 @@ -1361,7 +1372,7 @@
  34.337   Iterator 1;
  34.338   moveActiveRoot 1;
  34.339   autoCalculate 1 CompleteCalc;
  34.340 - moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
  34.341 + moveActiveFormula 1 ([2],Res); (*there is "- 1 + x = 0"*)
  34.342   replaceFormula 1 "x - 1 = 0"; (*<-------------------------------------*)
  34.343   (*... returns calcChangedEvent with*)
  34.344   val (unc, del, gen) = (([1],Res), ([4],Res), ([2],Res));
  34.345 @@ -1393,7 +1404,7 @@
  34.346   Iterator 1;
  34.347   moveActiveRoot 1;
  34.348   autoCalculate 1 CompleteCalc;
  34.349 - moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
  34.350 + moveActiveFormula 1 ([2],Res); (*there is "- 1 + x = 0"*)
  34.351   replaceFormula 1 "x = 1"; (*<-------------------------------------*)
  34.352   (*... returns calcChangedEvent with ...*)
  34.353   val (unc, del, gen) = (([1],Res), ([4],Res), ([3,2],Res));
  34.354 @@ -1425,7 +1436,7 @@
  34.355   Iterator 1;
  34.356   moveActiveRoot 1;
  34.357   autoCalculate 1 CompleteCalc;
  34.358 - moveActiveFormula 1 ([2],Res); (*there is "-1 + x = 0"*)
  34.359 + moveActiveFormula 1 ([2],Res); (*there is "- 1 + x = 0"*)
  34.360   replaceFormula 1 "x - 4711 = 0"; 
  34.361   (*... returns <ERROR> no derivation found </ERROR>*)
  34.362  
  34.363 @@ -1433,7 +1444,7 @@
  34.364   Test_Tool.show_pt pt;
  34.365   val p = get_pos 1 1;
  34.366   val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  34.367 - if UnparseC.term f = "-1 + x = 0" andalso p = ([2], Res) then () else 
  34.368 + if UnparseC.term f = "- 1 + x = 0" andalso p = ([2], Res) then () else 
  34.369   error "FE-interface.sml: diff.behav. in FORMULA:replace} NOTok";
  34.370   DEconstrCalcTree 1;
  34.371  
    35.1 --- a/test/Tools/isac/Interpret/error-pattern.sml	Mon Jun 21 22:08:01 2021 +0200
    35.2 +++ b/test/Tools/isac/Interpret/error-pattern.sml	Sun Jul 18 18:15:27 2021 +0200
    35.3 @@ -59,25 +59,25 @@
    35.4   Iterator 1; moveActiveRoot 1;
    35.5   autoCalculate 1 CompleteCalcHead;
    35.6   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
    35.7 - autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
    35.8 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
    35.9  
   35.10 - appendFormula 1 "-2 * 1 + (1 + x) = 0" (*|> Future.join*); refFormula 1 (get_pos 1 1);
   35.11 + appendFormula 1 "- 2 * 1 + (1 + x) = 0" (*|> Future.join*); refFormula 1 (get_pos 1 1);
   35.12   val ((pt,_),_) = get_calc 1;
   35.13   val str = pr_ctree pr_short pt;
   35.14  if str =
   35.15  (".    ----- pblobj -----\n" ^
   35.16  "1.   x + 1 = 2\n" ^
   35.17 -"2.   x + 1 + -1 * 2 = 0\n" ^
   35.18 -"2.1.   x + 1 + -1 * 2 = 0\n" ^
   35.19 -"2.2.   1 + x + -1 * 2 = 0\n" ^
   35.20 -"2.3.   1 + (x + -1 * 2) = 0\n" ^
   35.21 -"2.4.   1 + (x + -2) = 0\n" ^
   35.22 -"2.5.   1 + (x + -2 * 1) = 0\n" ^
   35.23 -"2.6.   1 + x + -2 * 1 = 0\n" ) then ()
   35.24 +"2.   x + 1 + - 1 * 2 = 0\n" ^
   35.25 +"2.1.   x + 1 + - 1 * 2 = 0\n" ^
   35.26 +"2.2.   1 + x + - 1 * 2 = 0\n" ^
   35.27 +"2.3.   1 + (x + - 1 * 2) = 0\n" ^
   35.28 +"2.4.   1 + (x + - 2) = 0\n" ^
   35.29 +"2.5.   1 + (x + - 2 * 1) = 0\n" ^
   35.30 +"2.6.   1 + x + - 2 * 1 = 0\n" ) then ()
   35.31  else error "inform.sml: diff.behav.appendFormula: on Res + equ 1";
   35.32  
   35.33   moveDown 1 ([ ],Pbl); refFormula 1 ([1],Frm); (*x + 1 = 2*)
   35.34 - moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + -1 * 2 = 0*)
   35.35 + moveDown 1 ([1],Frm); refFormula 1 ([1],Res); (*x + 1 + - 1 * 2 = 0*)
   35.36  
   35.37   (*the seven steps of detailed derivation*)
   35.38   moveDown 1 ([1  ],Res); refFormula 1 ([2,1],Frm); 
   35.39 @@ -88,7 +88,7 @@
   35.40   moveDown 1 ([2,4],Res); refFormula 1 ([2,5],Res);
   35.41   moveDown 1 ([2,5],Res); refFormula 1 ([2,6],Res);
   35.42   val ((pt,_),_) = get_calc 1;
   35.43 - if "-2 * 1 + (1 + x) = 0" = UnparseC.term (fst (get_obj g_result pt [2,6])) then()
   35.44 + if "- 2 * 1 + (1 + x) = 0" = UnparseC.term (fst (get_obj g_result pt [2,6])) then()
   35.45   else error "inform.sml: diff.behav.appendFormula: on Res + equ 2";
   35.46  
   35.47   fetchProposedTactic 1; (*takes Iterator 1 _1_*)
   35.48 @@ -119,13 +119,13 @@
   35.49   val fod = Derive.do_one (@{theory "Isac_Knowledge"}) Atools_erls 
   35.50  		       ((#rules o Rule_Set.rep) Test_simplify)
   35.51  		       (sqrt_right false (@{theory "Pure"})) NONE 
   35.52 -		       (TermC.str2term "x + 1 + -1 * 2 = 0");
   35.53 +		       (TermC.str2term "x + 1 + - 1 * 2 = 0");
   35.54   (writeln o Derive.trtas2str) fod;
   35.55  
   35.56   val ifod = Derive.do_one (@{theory "Isac_Knowledge"}) Atools_erls 
   35.57  		       ((#rules o Rule_Set.rep) Test_simplify)
   35.58  		       (sqrt_right false (@{theory "Pure"})) NONE 
   35.59 -		       (TermC.str2term "-2 * 1 + (1 + x) = 0");
   35.60 +		       (TermC.str2term "- 2 * 1 + (1 + x) = 0");
   35.61   (writeln o Derive.trtas2str) ifod;
   35.62   fun equal (_,_,(t1, _)) (_,_,(t2, _)) = t1 = t2;
   35.63   val (fod', rifod') = dropwhile' equal (rev fod) (rev ifod);
   35.64 @@ -144,7 +144,7 @@
   35.65   Iterator 1; moveActiveRoot 1;
   35.66   autoCalculate 1 CompleteCalcHead;
   35.67   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1) (*x + 1 = 2*);
   35.68 - appendFormula 1 "2+ -1 + x = 2" (*|> Future.join*); refFormula 1 (get_pos 1 1);
   35.69 + appendFormula 1 "2+ - 1 + x = 2" (*|> Future.join*); refFormula 1 (get_pos 1 1);
   35.70  
   35.71   moveDown 1 ([],Pbl); refFormula 1 ([1],Frm) (*x + 1 = 2*);
   35.72  
   35.73 @@ -156,7 +156,7 @@
   35.74   moveDown 1 ([1,4],Res); refFormula 1 ([1,5],Res); 
   35.75   moveDown 1 ([1,5],Res); refFormula 1 ([1,6],Res); 
   35.76   val ((pt,_),_) = get_calc 1;
   35.77 - if "2 + -1 + x = 2" = UnparseC.term (fst (get_obj g_result pt [1,6])) then()
   35.78 + if "2 + - 1 + x = 2" = UnparseC.term (fst (get_obj g_result pt [1,6])) then()
   35.79   else error "inform.sml: diff.behav.appendFormula: on Frm + equ 1";
   35.80  
   35.81   fetchProposedTactic 1; (*takes Iterator 1 _1_*)
   35.82 @@ -179,7 +179,7 @@
   35.83   Iterator 1; moveActiveRoot 1;
   35.84   autoCalculate 1 CompleteCalcHead;
   35.85   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   35.86 - autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   35.87 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
   35.88  
   35.89   appendFormula 1 "x = 2" (*|> Future.join*);
   35.90   val ((pt,p),_) = get_calc 1;
   35.91 @@ -212,13 +212,13 @@
   35.92   Iterator 1; moveActiveRoot 1;
   35.93   autoCalculate 1 CompleteCalcHead;
   35.94   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
   35.95 - autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
   35.96 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
   35.97  
   35.98   appendFormula 1 "x = 1" (*|> Future.join*);
   35.99   val ((pt,p),_) = get_calc 1;
  35.100   val str = pr_ctree pr_short pt;
  35.101   writeln str;
  35.102 - if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n3.2.   x = 0 + -1 * -1\n3.2.1.   x = 0 + -1 * -1\n3.2.2.   x = 0 + 1\n" andalso p = ([3,2], Res)
  35.103 + if str = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + - 1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   - 1 + x = 0\n3.2.   x = 0 + - 1 * - 1\n3.2.1.   x = 0 + - 1 * - 1\n3.2.2.   x = 0 + 1\n" andalso p = ([3,2], Res)
  35.104   then () (*finds 1 step too early: ([3,2], Res) "x = 1" also by script !!!*)
  35.105   else error "inform.sml: diff.behav.appendFormula: Res + late d 1";
  35.106  
  35.107 @@ -232,9 +232,9 @@
  35.108   else error "inform.sml: diff.behav.appendFormula: Res + late d 3";
  35.109  DEconstrCalcTree 1;
  35.110  
  35.111 -"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
  35.112 -"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
  35.113 -"--------- appendFormula: on Res + late deriv [x = 3 + -2]---///--";
  35.114 +"--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
  35.115 +"--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
  35.116 +"--------- appendFormula: on Res + late deriv [x = 3 + - 2]---///--";
  35.117   reset_states ();
  35.118   CalcTree [(["equality (x+1=(2::real))", "solveFor x", "solutions L"], 
  35.119  	    ("Test", ["sqroot-test", "univariate", "equation", "test"],
  35.120 @@ -242,16 +242,16 @@
  35.121   Iterator 1; moveActiveRoot 1;
  35.122   autoCalculate 1 CompleteCalcHead;
  35.123   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
  35.124 - autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
  35.125 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
  35.126   appendFormula 1 "[x = 3 + -2*1]" (*|> Future.join*);
  35.127   val ((pt,p),_) = get_calc 1;
  35.128   val str = pr_ctree pr_short pt;
  35.129   writeln str;
  35.130 - if str=".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n3.2.   x = 0 + -1 * -1\n4.   [x = 1]\n4.1.   [x = 1]\n4.2.   [x = -2 + 3]\n4.3.   [x = 3 + -2]\n" then ()
  35.131 + if str=".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + - 1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   - 1 + x = 0\n3.2.   x = 0 + - 1 * - 1\n4.   [x = 1]\n4.1.   [x = 1]\n4.2.   [x = - 2 + 3]\n4.3.   [x = 3 + - 2]\n" then ()
  35.132   else error "inform.sml: diff.behav.appendFormula: Res + latEE 1";
  35.133   autoCalculate 1 CompleteCalc;
  35.134   val ((pt,p),_) = get_calc 1;
  35.135 - if "[x = 3 + -2 * 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
  35.136 + if "[x = 3 + - 2 * 1]" = UnparseC.term (fst (get_obj g_result pt [])) then ()
  35.137   (*       ~~~~~~~~~~ simplify as last step in any script ?!*)
  35.138   else error "inform.sml: diff.behav.appendFormula: Res + latEE 2";
  35.139  DEconstrCalcTree 1;
  35.140 @@ -266,8 +266,8 @@
  35.141   Iterator 1; moveActiveRoot 1;
  35.142   autoCalculate 1 CompleteCalcHead;
  35.143   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
  35.144 - autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
  35.145 - autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*-1 + x*);
  35.146 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
  35.147 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*- 1 + x*);
  35.148  
  35.149   replaceFormula 1 "-2 * 1 + (1 + x) = 0"; refFormula 1 (get_pos 1 1);
  35.150   val ((pt,_),_) = get_calc 1;
  35.151 @@ -276,10 +276,10 @@
  35.152  (* before AK110725 this was
  35.153  ".    ----- pblobj -----\n
  35.154  1.   x + 1 = 2\n
  35.155 -2.   x + 1 + -1 * 2 = 0\n
  35.156 -2.1.   x + 1 + -1 * 2 = 0\n
  35.157 -2.2.   1 + x + -1 * 2 = 0\n
  35.158 -2.3.   1 + (x + -1 * 2) = 0\n
  35.159 +2.   x + 1 + - 1 * 2 = 0\n
  35.160 +2.1.   x + 1 + - 1 * 2 = 0\n
  35.161 +2.2.   1 + x + - 1 * 2 = 0\n
  35.162 +2.3.   1 + (x + - 1 * 2) = 0\n
  35.163  2.4.   1 + (x + -2) = 0\n
  35.164  2.5.   1 + (x + -2 * 1) = 0\n
  35.165  2.6.   1 + x + -2 * 1 = 0\n";
  35.166 @@ -287,13 +287,13 @@
  35.167  if str = 
  35.168  ".    ----- pblobj -----\n"^
  35.169  "1.   x + 1 = 2\n"^
  35.170 -"2.   x + 1 + -1 * 2 = 0\n"^
  35.171 -"2.1.   x + 1 + -1 * 2 = 0\n"^
  35.172 -"2.2.   1 + x + -1 * 2 = 0\n"^
  35.173 -"2.3.   1 + (x + -1 * 2) = 0\n"^
  35.174 -"2.4.   1 + (x + -2) = 0\n"^
  35.175 -"2.5.   1 + (x + -2 * 1) = 0\n"^
  35.176 -"2.6.   1 + x + -2 * 1 = 0\n" then()
  35.177 +"2.   x + 1 + - 1 * 2 = 0\n"^
  35.178 +"2.1.   x + 1 + - 1 * 2 = 0\n"^
  35.179 +"2.2.   1 + x + - 1 * 2 = 0\n"^
  35.180 +"2.3.   1 + (x + - 1 * 2) = 0\n"^
  35.181 +"2.4.   1 + (x + - 2) = 0\n"^
  35.182 +"2.5.   1 + (x + - 2 * 1) = 0\n"^
  35.183 +"2.6.   1 + x + - 2 * 1 = 0\n" then()
  35.184  else error "inform.sml: diff.behav.replaceFormula: on Res += 1";
  35.185  
  35.186   autoCalculate 1 CompleteCalc;
  35.187 @@ -312,13 +312,13 @@
  35.188   Iterator 1; moveActiveRoot 1;
  35.189   autoCalculate 1 CompleteCalcHead;
  35.190   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
  35.191 - autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
  35.192 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
  35.193  
  35.194   replaceFormula 1 "x + 1 = 4 + -2"; refFormula 1 (get_pos 1 1);
  35.195   val ((pt,_),_) = get_calc 1;
  35.196   val str = pr_ctree pr_short pt;
  35.197   writeln str;
  35.198 - if str= ".    ----- pblobj -----\n1.   x + 1 = 2\n1.1.   x + 1 = 2\n1.2.   1 + x = 2\n1.3.   1 + x = -2 + 4\n1.4.   x + 1 = -2 + 4\n" then ()
  35.199 + if str= ".    ----- pblobj -----\n1.   x + 1 = 2\n1.1.   x + 1 = 2\n1.2.   1 + x = 2\n1.3.   1 + x = - 2 + 4\n1.4.   x + 1 = - 2 + 4\n" then ()
  35.200   else error "inform.sml: diff.behav.replaceFormula: on Res 1 + = 1";
  35.201   autoCalculate 1 CompleteCalc;
  35.202   val ((pt,pos as (p,_)),_) = get_calc 1;
  35.203 @@ -341,7 +341,7 @@
  35.204   val ((pt,_),_) = get_calc 1;
  35.205   val str = pr_ctree pr_short pt;
  35.206   writeln str;
  35.207 - if str= ".    ----- pblobj -----\n1.   x + 1 = 2\n1.1.   x + 1 = 2\n1.2.   1 + x = 2\n1.3.   1 + x = -2 + 4\n1.4.   x + 1 = -2 + 4\n" then ()
  35.208 + if str= ".    ----- pblobj -----\n1.   x + 1 = 2\n1.1.   x + 1 = 2\n1.2.   1 + x = 2\n1.3.   1 + x = - 2 + 4\n1.4.   x + 1 = - 2 + 4\n" then ()
  35.209   else error "inform.sml: diff.behav.replaceFormula: on Frm 1 + = 1";
  35.210   autoCalculate 1 CompleteCalc;
  35.211   val ((pt,pos as (p,_)),_) = get_calc 1;
  35.212 @@ -456,7 +456,7 @@
  35.213   Iterator 1; moveActiveRoot 1;
  35.214   autoCalculate 1 CompleteCalcHead;
  35.215   autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 = 2*)
  35.216 - autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + -1 * 2 = 0*);
  35.217 + autoCalculate 1 (Steps 1); refFormula 1 (get_pos 1 1);(*x + 1 + - 1 * 2 = 0*);
  35.218  
  35.219   appendFormula 1 " x - "; (*<ERROR> syntax error in ' x - ' </ERROR>*)
  35.220   val ((pt,_),_) = get_calc 1;
  35.221 @@ -512,7 +512,7 @@
  35.222  Iterator 1; moveActiveRoot 1;
  35.223  autoCalculate 1 CompleteCalcHead;
  35.224  
  35.225 -"--- (-1) give a preview on the calculation without any input";
  35.226 +"--- (- 1) give a preview on the calculation without any input";
  35.227  (*
  35.228  autoCalculate 1 CompleteCalc;
  35.229  val ((pt, p), _) = get_calc 1;
  35.230 @@ -1277,13 +1277,13 @@
  35.231  "--------- fun concat_deriv --------------------------------------";
  35.232  (*
  35.233   val ({rew_ord, erls, rules,...}, fo, ifo) = 
  35.234 -     (Rule_Set.rep Test_simplify, TermC.str2term "x+1+ -1*2=0", TermC.str2term "-2*1+(x+1)=0");
  35.235 +     (Rule_Set.rep Test_simplify, TermC.str2term "x+1+ - 1*2=0", TermC.str2term "-2*1+(x+1)=0");
  35.236   (tracing o Derive.trtas2str) fod';
  35.237  > ["
  35.238 -(x + 1 + -1 * 2 = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (-1 * 2 + (x + 1) = 0, []))", "
  35.239 -(-1 * 2 + (x + 1) = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (-1 * 2 + (1 + x) = 0, []))", "
  35.240 -(-1 * 2 + (1 + x) = 0, Thm ("radd_left_commute", "?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (-1 * 2 + x) = 0, []))", "
  35.241 -(1 + (-1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))", "-1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
  35.242 +(x + 1 + - 1 * 2 = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (x + 1) = 0, []))", "
  35.243 +(- 1 * 2 + (x + 1) = 0, Thm ("radd_commute", "?m + ?n = ?n + ?m"), (- 1 * 2 + (1 + x) = 0, []))", "
  35.244 +(- 1 * 2 + (1 + x) = 0, Thm ("radd_left_commute", "?x + (?y + ?z) = ?y + (?x + ?z)"), (1 + (- 1 * 2 + x) = 0, []))", "
  35.245 +(1 + (- 1 * 2 + x) = 0, Thm ("#mult_Float ((~1,0), (0,0)) __ ((2,0), (0,0))", "- 1 * 2 = -2"), (1 + (-2 + x) = 0, []))"]
  35.246  val it = () : unit
  35.247   (tracing o Derive.trtas2str) (map Derive.rev_deriv' rifod');
  35.248  > ["
  35.249 @@ -1327,7 +1327,7 @@
  35.250  ------------------------------------------------------------------------------
  35.251  1. "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) = 1 / x"
  35.252  ...
  35.253 -4. "(3 + (-1 * x + x \<up> 2)) * x = 1 * (9 * x + (x \<up> 3 + -6 * x \<up> 2))"
  35.254 +4. "(3 + (- 1 * x + x \<up> 2)) * x = 1 * (9 * x + (x \<up> 3 + -6 * x \<up> 2))"
  35.255                           Subproblem["normalise", "polynomial", "univariate"..
  35.256  ...
  35.257  4.4. "-6 * x + 5 * x \<up> 2 = 0", Subproblem["bdv_only", "degree_2", "poly"..
    36.1 --- a/test/Tools/isac/Interpret/lucas-interpreter.sml	Mon Jun 21 22:08:01 2021 +0200
    36.2 +++ b/test/Tools/isac/Interpret/lucas-interpreter.sml	Sun Jul 18 18:15:27 2021 +0200
    36.3 @@ -210,7 +210,7 @@
    36.4  
    36.5  (*[3], Res*)val (p,_,f,nxt,_,pt) = me nxt'''''_''' p'''''_''' [] pt'''''_'''; (*nxt = Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
    36.6  (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Model_Problem*)
    36.7 -(*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "equality (-1 + x = 0)"*)
    36.8 +(*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "equality (- 1 + x = 0)"*)
    36.9  (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "solveFor x"*)
   36.10  (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Find "solutions x_i"*)
   36.11  (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Theory "Test"*)
   36.12 @@ -228,10 +228,10 @@
   36.13  if p = ([], Res) andalso f2str f = "[x = 1]" andalso pr_ctree pr_short pt =
   36.14    ".    ----- pblobj -----\n" ^
   36.15    "1.   x + 1 = 2\n" ^
   36.16 -  "2.   x + 1 + -1 * 2 = 0\n" ^
   36.17 +  "2.   x + 1 + - 1 * 2 = 0\n" ^
   36.18    "3.    ----- pblobj -----\n" ^
   36.19 -  "3.1.   -1 + x = 0\n" ^
   36.20 -  "3.2.   x = 0 + -1 * -1\n" ^
   36.21 +  "3.1.   - 1 + x = 0\n" ^
   36.22 +  "3.2.   x = 0 + - 1 * - 1\n" ^
   36.23    "4.   [x = 1]\n"
   36.24  then case nxt of End_Proof' => () | _ => error "re-build: fun locate_input_tactic changed 1"
   36.25  else error "re-build: fun locate_input_tactic changed 2";
   36.26 @@ -249,28 +249,40 @@
   36.27  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   36.28  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   36.29  (*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "ordne_alphabetisch"*)
   36.30 +
   36.31 +(*+*)val Test_Out.FormKF "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12" = f
   36.32 +
   36.33  (*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "fasse_zusammen"*)
   36.34  
   36.35 +(*+*)val Test_Out.FormKF "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g" = f;
   36.36 +
   36.37  (*+*)if map Tactic.input_to_string (specific_from_prog pt p) =
   36.38     ["Rewrite (\"subtrahiere_x_plus_minus\", \"\<lbrakk>?l is_const; ?m is_const\<rbrakk>\n\<Longrightarrow> ?x + ?m * ?v - ?l * ?v = ?x + (?m - ?l) * ?v\")",
   36.39 -    "Rewrite (\"subtrahiere_x_minus_plus\", \"\<lbrakk>?l is_const; ?m is_const\<rbrakk>\n\<Longrightarrow> ?x - ?m * ?v + ?l * ?v = ?x + (- ?m + ?l) * ?v\")"]
   36.40 -  then () else error "specific_from_prog ([1], Res) CHANGED";
   36.41 +    "Rewrite (\"subtrahiere_x_minus_plus\", \"\<lbrakk>?l is_const; ?m is_const\<rbrakk>\n\<Longrightarrow> ?x - ?m * ?v + ?l * ?v = ?x + (- ?m + ?l) * ?v\")",
   36.42 +(*this is new since ThmC.numerals_to_Free..*)
   36.43 +    "Calculate PLUS"]
   36.44 +  then () else error "specific_from_prog ([1], Res) CHANGED";  (*GOON*)
   36.45  (*[2], Res*)val ("ok", (_, _, ptp as (pt, p))) = Step.by_tactic (hd (specific_from_prog pt p)) (pt, p);
   36.46  
   36.47  (*+*)if map Tactic.input_to_string (specific_from_prog pt p) =
   36.48 -   ["Rewrite (\"tausche_minus\", \"\<lbrakk>?b ist_monom; ?a kleiner ?b\<rbrakk>\n\<Longrightarrow> ?b - ?a = - ?a + ?b\")", "Rewrite (\"tausche_plus_minus\", \"?b kleiner ?c \<Longrightarrow> ?a + ?c - ?b = ?a - ?b + ?c\")",
   36.49 +   ["Rewrite (\"tausche_minus\", \"\<lbrakk>?b ist_monom; ?a kleiner ?b\<rbrakk>\n\<Longrightarrow> ?b - ?a = - ?a + ?b\")",
   36.50 +    "Rewrite (\"tausche_plus_minus\", \"?b kleiner ?c \<Longrightarrow> ?a + ?c - ?b = ?a - ?b + ?c\")",
   36.51      "Rewrite (\"subtrahiere_x_plus_minus\", \"\<lbrakk>?l is_const; ?m is_const\<rbrakk>\n\<Longrightarrow> ?x + ?m * ?v - ?l * ?v = ?x + (?m - ?l) * ?v\")",
   36.52 -    "Rewrite (\"subtrahiere_x_minus_plus\", \"\<lbrakk>?l is_const; ?m is_const\<rbrakk>\n\<Longrightarrow> ?x - ?m * ?v + ?l * ?v = ?x + (- ?m + ?l) * ?v\")", "Calculate MINUS"]
   36.53 +    "Rewrite (\"subtrahiere_x_minus_plus\", \"\<lbrakk>?l is_const; ?m is_const\<rbrakk>\n\<Longrightarrow> ?x - ?m * ?v + ?l * ?v = ?x + (- ?m + ?l) * ?v\")",
   36.54 +    "Calculate PLUS",  (*..this is new since ThmC.numerals_to_Free*)
   36.55 +    "Calculate MINUS"]
   36.56    then () else error "specific_from_prog ([1], Res) CHANGED";
   36.57 +
   36.58  (* = ([3], Res)*)val ("ok", (_, _, ptp as (pt, p))) = Step.by_tactic (hd (specific_from_prog pt p)) (pt, p);
   36.59  
   36.60  (*//----------------- exception PTREE "get_obj f EmptyPtree" raised --------------------------\\*)
   36.61 -(** )val ("ok", (_, _, ptp as (pt, p))) =( **)
   36.62 +(** )val ("ok", ([(Rewrite ("tausche_minus_plus", _), _, _)], _, _)) = ( *isa*)
   36.63        Step.by_tactic (hd (specific_from_prog pt p)) (pt, p);
   36.64  "~~~~~ fun by_tactic , args:"; val (tac, (ptp as (pt, p))) = (hd (specific_from_prog pt p), (pt, p));
   36.65        val Applicable.Yes m = (*case*) Solve_Step.check tac (pt, p) (*of*);
   36.66        (*if*) Tactic.for_specify' m; (*false*)
   36.67  
   36.68 +(** )val ("ok", ([(Rewrite ("tausche_minus_plus", _), _, _)], _, _)) = ( *isa*)
   36.69  Step_Solve.by_tactic m (pt, p);
   36.70  "~~~~~ fun by_tactic , args:"; val (m, (pt, po as (p, p_))) = (m, (pt, p));
   36.71      (*if*) MethodC.id_empty = get_obj g_metID pt (par_pblobj pt p) (*else*);
   36.72 @@ -329,6 +341,9 @@
   36.73  val LItool.Not_Associated = (*case*)
   36.74    LItool.associate pt ctxt (tac, prog_tac) (*of*);
   36.75       val _(*ORundef*) = (*case*) or (*of*);
   36.76 +
   36.77 +(*+*)Solve_Step.check (LItool.tac_from_prog pt (ThyC.get_theory "Isac_Knowledge") prog_tac) (pt, p);
   36.78 +
   36.79       val Applicable.Yes m' =
   36.80            (*case*) Solve_Step.check (LItool.tac_from_prog pt (ThyC.get_theory "Isac_Knowledge") prog_tac) (pt, p) (*of*);
   36.81  
   36.82 @@ -361,6 +376,8 @@
   36.83  then () else error "locate_input_tactic Helpless, but applicable CHANGED";
   36.84  ( *\----- original before child of 7e314dd233fd -------------------------------------------------/*)
   36.85  
   36.86 +(*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt''''' p''''' [] pt'''''; (*nxt = Rewrite_Set "fasse_zusammen"*)
   36.87 +
   36.88  
   36.89  "----------- re-build: fun find_next_step, mini ------------------------------------------------";
   36.90  "----------- re-build: fun find_next_step, mini ------------------------------------------------";
   36.91 @@ -524,14 +541,14 @@
   36.92  (*+*)if f2str f = "x + 1 = 2" then () else error "locate_input_term at ([1], Frm) CHANGED";
   36.93  
   36.94  (*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Rewrite_Set "Test_simplify"*)
   36.95 -(*+*)if f2str f = "x + 1 + -1 * 2 = 0" then () else error "locate_input_term at ([1], Frm) CHANGED";
   36.96 +(*+*)if f2str f = "x + 1 + - 1 * 2 = 0" then () else error "locate_input_term at ([1], Frm) CHANGED";
   36.97  
   36.98  Test_Tool.show_pt_tac pt; (*[
   36.99  ([], Frm), solve (x + 1 = 2, x)
  36.100  . . . . . . . . . . Apply_Method ["Test", "squ-equ-test-subpbl1"],
  36.101  ([1], Frm), x + 1 = 2
  36.102  . . . . . . . . . . Rewrite_Set "norm_equation",
  36.103 -([1], Res), x + 1 + -1 * 2 = 0             ///Check_Postcond..ERROR*)
  36.104 +([1], Res), x + 1 + - 1 * 2 = 0             ///Check_Postcond..ERROR*)
  36.105  
  36.106  (*//---------- appendFormula 1 "x = 1" \<longrightarrow> Step_Solve.inform \<longrightarrow> LI.locate_input_term ----------\\*)
  36.107  "~~~~~ fun appendFormula , args:"; val ((*cI, *) ifo: TermC.as_string) = ((**) "x = 1");
  36.108 @@ -545,7 +562,7 @@
  36.109  (*+*). . . . . . . . . . Apply_Method ["Test", "squ-equ-test-subpbl1"],
  36.110  (*+*)([1], Frm), x + 1 = 2
  36.111  (*+*). . . . . . . . . . Rewrite_Set "norm_equation",
  36.112 -(*+*)([1], Res), x + 1 + -1 * 2 = 0      ///Check_Postcond*)
  36.113 +(*+*)([1], Res), x + 1 + - 1 * 2 = 0      ///Check_Postcond*)
  36.114  
  36.115    val ("ok", cs' as (_, _, ptp')) =
  36.116      (*case*) Step.do_next pos cs (*of*);
  36.117 @@ -602,7 +619,7 @@
  36.118  (*//----- REPLACED BY appendFormula 1 "x = 1" \<longrightarrow> Step_Solve.inform \<longrightarrow> LI.locate_input_term -----\\* )
  36.119   (*[2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
  36.120   (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Model_Problem*)
  36.121 - (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "equality (-1 + x = 0)"*)
  36.122 + (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "equality (- 1 + x = 0)"*)
  36.123   (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "solveFor x"*)
  36.124   (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Find "solutions x_i"*)
  36.125   (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Theory "Test"*)
  36.126 @@ -622,11 +639,11 @@
  36.127  if p = ([], Res) andalso f2str f = "[x = 1]" andalso pr_ctree pr_short pt =
  36.128     ".    ----- pblobj -----\n" ^
  36.129     "1.   x + 1 = 2\n" ^
  36.130 -   "2.   x + 1 + -1 * 2 = 0\n" ^
  36.131 +   "2.   x + 1 + - 1 * 2 = 0\n" ^
  36.132     "3.    ----- pblobj -----\n" ^
  36.133 -   "3.1.   -1 + x = 0\n" ^
  36.134 -   "3.2.   x = 0 + -1 * -1\n" ^
  36.135 -   "3.2.1.   x = 0 + -1 * -1\n" ^
  36.136 +   "3.1.   - 1 + x = 0\n" ^
  36.137 +   "3.2.   x = 0 + - 1 * - 1\n" ^
  36.138 +   "3.2.1.   x = 0 + - 1 * - 1\n" ^
  36.139     "3.2.2.   x = 0 + 1\n" (*ATTENTION: see complete Calc below*)
  36.140  then case nxt of End_Proof' => () | _ => error "re-build: fun locate_input_term CHANGED 1"
  36.141  else error "re-build: fun locate_input_term CHANGED 2";
  36.142 @@ -636,18 +653,18 @@
  36.143  . . . . . . . . . . Apply_Method ["Test", "squ-equ-test-subpbl1"],
  36.144  ([1], Frm), x + 1 = 2
  36.145  . . . . . . . . . . Rewrite_Set "norm_equation",
  36.146 -([1], Res), x + 1 + -1 * 2 = 0
  36.147 +([1], Res), x + 1 + - 1 * 2 = 0
  36.148  . . . . . . . . . . Rewrite_Set "Test_simplify",
  36.149 -([2], Res), -1 + x = 0
  36.150 +([2], Res), - 1 + x = 0
  36.151  . . . . . . . . . . Subproblem (Test, ["LINEAR", "univariate", "equation", "test"]),
  36.152 -([3], Pbl), solve (-1 + x = 0, x)
  36.153 +([3], Pbl), solve (- 1 + x = 0, x)
  36.154  . . . . . . . . . . Apply_Method ["Test", "solve_linear"],
  36.155 -([3,1], Frm), -1 + x = 0
  36.156 +([3,1], Frm), - 1 + x = 0
  36.157  . . . . . . . . . . Rewrite_Set_Inst ([(''bdv'', x)], "isolate_bdv"),
  36.158 -([3,1], Res), x = 0 + -1 * -1
  36.159 +([3,1], Res), x = 0 + - 1 * - 1
  36.160  . . . . . . . . . . Derive Test_simplify,
  36.161 -([3,2,1], Frm), x = 0 + -1 * -1
  36.162 -. . . . . . . . . . Rewrite ("#: -1 * -1 = 1", "-1 * -1 = 1"),
  36.163 +([3,2,1], Frm), x = 0 + - 1 * - 1
  36.164 +. . . . . . . . . . Rewrite ("#: - 1 * - 1 = 1", "- 1 * - 1 = 1"),
  36.165  ([3,2,1], Res), x = 0 + 1
  36.166  . . . . . . . . . . Rewrite ("radd_0", "0 + ?k = ?k"),
  36.167  ([3,2,2], Res), x = 1
    37.1 --- a/test/Tools/isac/Knowledge/biegelinie-1.sml	Mon Jun 21 22:08:01 2021 +0200
    37.2 +++ b/test/Tools/isac/Knowledge/biegelinie-1.sml	Sun Jul 18 18:15:27 2021 +0200
    37.3 @@ -57,13 +57,13 @@
    37.4  		rew_ord = ("termlessI",termlessI), 
    37.5  		erls = Rule_Set.append_rules "erls_in_srls_IntegrierenUnd.." Rule_Set.empty
    37.6  				  [(*for asm in NTH_CONS ...*)
    37.7 -				   Eval (\<^const_name>\<open>less\<close>,eval_equ "#less_"),
    37.8 -				   (*2nd NTH_CONS pushes n+-1 into asms*)
    37.9 -				   Eval(\<^const_name>\<open>plus\<close>, eval_binop "#add_")
   37.10 +				   Eval ("Orderings.ord_class.less",eval_equ "#less_"),
   37.11 +				   (*2nd NTH_CONS pushes n+- 1 into asms*)
   37.12 +				   Eval("Groups.plus_class.plus", eval_binop "#add_")
   37.13  				   ], 
   37.14  		srls = Rule_Set.Empty, calc = [], errpatts = [],
   37.15  		rules = [Thm ("NTH_CONS",ThmC.numerals_to_Free @{thm NTH_CONS}),
   37.16 -			 Eval(\<^const_name>\<open>plus\<close>, eval_binop "#add_"),
   37.17 +			 Eval("Groups.plus_class.plus", eval_binop "#add_"),
   37.18  			 Thm ("NTH_NIL",ThmC.numerals_to_Free @{thm NTH_NIL}),
   37.19  			 Eval("Prog_Expr.lhs", eval_lhs "eval_lhs_"),
   37.20  			 Eval("Prog_Expr.rhs", eval_rhs "eval_rhs_"),
   37.21 @@ -71,7 +71,7 @@
   37.22  			 ],
   37.23  		scr = Empty_Prog};
   37.24  val rm_ = TermC.str2term"[M_b 0 = 0, M_b L = 0]";
   37.25 -val M__ = TermC.str2term"M_b x = -1 * x \<up> 2 / 2 + x * c + c_2";
   37.26 +val M__ = TermC.str2term"M_b x = - 1 * x \<up> 2 / 2 + x * c + c_2";
   37.27  val SOME (e1__,_) = rewrite_set_ thy false srls 
   37.28    (TermC.str2term "(NTH::[real,bool list]=>bool) 1 " $ rm_);
   37.29  if UnparseC.term e1__ = "M_b 0 = 0" then () else error "biegelinie.sml simplify NTH 1 rm_";
   37.30 @@ -82,13 +82,12 @@
   37.31  if UnparseC.term x1__ = "0" then ()
   37.32  else error "biegelinie.sml simplify argument_in (lhs (M_b 0 = 0)";
   37.33  
   37.34 -(*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
   37.35 -Rewrite.trace_on:=false;
   37.36 +Rewrite.trace_on := false; (*true false*)
   37.37  
   37.38  "----------- SubProblem (_,[setzeRandbedingungen,Biegelinien] ----";
   37.39  "----------- SubProblem (_,[setzeRandbedingungen,Biegelinien] ----";
   37.40  "----------- SubProblem (_,[setzeRandbedingungen,Biegelinien] ----";
   37.41 -val fmz = ["functionEq (M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2)", 
   37.42 +val fmz = ["functionEq (M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2)", 
   37.43  	   "substitution (M_b L = 0)", 
   37.44  	   "equality equ_equ"];
   37.45  val (dI',pI',mI') = ("Biegelinie", ["makeFunctionTo", "equation"],
   37.46 @@ -101,15 +100,15 @@
   37.47  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   37.48  
   37.49  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = 
   37.50 -			"M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2";
   37.51 +			"M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2";
   37.52  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = 
   37.53 -                        "M_b L = c_2 + c * L + -1 * q_0 / 2 * L \<up> 2";
   37.54 +                        "M_b L = c_2 + c * L + - 1 * q_0 / 2 * L \<up> 2";
   37.55  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = 
   37.56 -			"0 = c_2 + c * L + -1 * q_0 / 2 * L \<up> 2";
   37.57 +			"0 = c_2 + c * L + - 1 * q_0 / 2 * L \<up> 2";
   37.58  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   37.59  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   37.60 -if (* f2str f = "0 = c_2 + L * c + -1 * q_0 / 2 * L \<up> 2" CHANGE NOT considered, already on leave*)
   37.61 -   f2str f = "0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2"
   37.62 +if (* f2str f = "0 = c_2 + L * c + - 1 * q_0 / 2 * L \<up> 2" CHANGE NOT considered, already on leave*)
   37.63 +   f2str f = "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2"
   37.64  then case nxt of End_Proof' => ()
   37.65    | _ => error "biegelinie.sml: SubProblem (_,[setzeRandbed 1"
   37.66  else error "biegelinie.sml: SubProblem (_,[setzeRandbed 2";
   37.67 @@ -118,8 +117,8 @@
   37.68  "----------- investigate normalforms in biegelinien --------------";
   37.69  "----------- investigate normalforms in biegelinien --------------";
   37.70  "----- coming from integration, kept for later improvements:";
   37.71 -val Q = TermC.str2term "Q x = c + -1 * q_0 * x";
   37.72 -val M_b = TermC.str2term "M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2";
   37.73 -val y' = TermC.str2term "y' x = c_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3)";
   37.74 -val y = TermC.str2term "y x = c_4 + c_3 * x +\n1 / (-1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)";
   37.75 -(* \<up>   1 / (-1 * EI) NOT distributed - ok! \<up> \<up> \<up> \<up> \<up> \<up>  \<up> ^^*)
   37.76 +val Q = TermC.str2term "Q x = c + - 1 * q_0 * x";
   37.77 +val M_b = TermC.str2term "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2";
   37.78 +val y' = TermC.str2term "y' x = c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)";
   37.79 +val y = TermC.str2term "y x = c_4 + c_3 * x +\n1 / (- 1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)";
   37.80 +(* \<up>   1 / (- 1 * EI) NOT distributed - ok! \<up> \<up> \<up> \<up> \<up> \<up>  \<up> ^^*)
    38.1 --- a/test/Tools/isac/Knowledge/biegelinie-2.sml	Mon Jun 21 22:08:01 2021 +0200
    38.2 +++ b/test/Tools/isac/Knowledge/biegelinie-2.sml	Sun Jul 18 18:15:27 2021 +0200
    38.3 @@ -16,10 +16,10 @@
    38.4  "----------- auto SubProblem (_,[vonBelastungZu,Biegelinien] -----";
    38.5  val fmz = 
    38.6      ["Streckenlast q_0", "FunktionsVariable x",
    38.7 -     "Funktionen [Q x = c + -1 * q_0 * x, \
    38.8 -     \M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2,\
    38.9 -     \ y' x = c_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3),\
   38.10 -     \ y x = c_4 + c_3 * x + 1 / (-1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)]",
   38.11 +     "Funktionen [Q x = c + - 1 * q_0 * x, \
   38.12 +     \M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2,\
   38.13 +     \ y' x = c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3),\
   38.14 +     \ y x = c_4 + c_3 * x + 1 / (- 1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)]",
   38.15      "AbleitungBiegelinie dy"];
   38.16  val (dI',pI',mI') = ("Biegelinie", ["vonBelastungZu", "Biegelinien"],
   38.17  		     ["Biegelinien", "ausBelastung"]);
   38.18 @@ -32,7 +32,7 @@
   38.19  
   38.20  val ((pt, p),_) = get_calc 1;
   38.21  if p = ([], Res) andalso (get_obj g_res pt (fst p) |> UnparseC.term) =
   38.22 -   "[Q x = c + -1 * q_0 * x, M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2,\n dy x =\n c_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3),\n y x =\n c_4 + c_3 * x +\n 1 / (-1 * EI) *\n (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)]"
   38.23 +   "[Q x = c + - 1 * q_0 * x, M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2,\n dy x =\n c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3),\n y x =\n c_4 + c_3 * x +\n 1 / (- 1 * EI) *\n (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)]"
   38.24  then () else error "auto SubProblem (_,[vonBelastungZu,Biegelinien] changed";
   38.25  
   38.26  
   38.27 @@ -41,10 +41,10 @@
   38.28  "----------- me SubProblem (_,[vonBelastungZu,Biegelinien] -------";
   38.29  val fmz = 
   38.30      ["Streckenlast q_0", "FunktionsVariable x",
   38.31 -     "Funktionen [Q x = c + -1 * q_0 * x, \
   38.32 -     \M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2,\
   38.33 -     \ y' x = c_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3),\
   38.34 -     \ y x = c_4 + c_3 * x + 1 / (-1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)]",
   38.35 +     "Funktionen [Q x = c + - 1 * q_0 * x, \
   38.36 +     \M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2,\
   38.37 +     \ y' x = c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3),\
   38.38 +     \ y x = c_4 + c_3 * x + 1 / (- 1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)]",
   38.39      "AbleitungBiegelinie dy"];
   38.40  val (dI',pI',mI') = ("Biegelinie", ["vonBelastungZu", "Biegelinien"],
   38.41  		     ["Biegelinien", "ausBelastung"]);
   38.42 @@ -70,9 +70,9 @@
   38.43  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.44  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.45  
   38.46 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "Q x = c + -1 * q_0 * x";
   38.47 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "Q x = c + -1 * q_0 * x";
   38.48 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "M_b' x = c + -1 * q_0 * x";
   38.49 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "Q x = c + - 1 * q_0 * x";
   38.50 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "Q x = c + - 1 * q_0 * x";
   38.51 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "M_b' x = c + - 1 * q_0 * x";
   38.52  case nxt of (_,Subproblem (_, ["named", "integrate", "function"])) => ()
   38.53  | _ => error "biegelinie.sml met2 d";
   38.54  
   38.55 @@ -81,40 +81,40 @@
   38.56  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.57  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.58  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = 
   38.59 -		   "M_b x = Integral c + -1 * q_0 * x D x";
   38.60 +		   "M_b x = Integral c + - 1 * q_0 * x D x";
   38.61  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = 
   38.62 -		   "M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2";
   38.63 +		   "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2";
   38.64  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.65 -		   "M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2";
   38.66 +		   "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2";
   38.67  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.68 -		   "- EI * y'' x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2";
   38.69 +		   "- EI * y'' x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2";
   38.70  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.71 -		   "y'' x = 1 / - EI * (c_2 + c * x + -1 * q_0 / 2 * x \<up> 2)";
   38.72 +		   "y'' x = 1 / - EI * (c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2)";
   38.73  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.74  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.75  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.76  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.77  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.78 -    "y' x = Integral 1 / - EI * (c_2 + c * x + -1 * q_0 / 2 * x \<up> 2) D x";
   38.79 +    "y' x = Integral 1 / - EI * (c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2) D x";
   38.80  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.81 -"y' x = Integral 1 / (-1 * EI) * (c_2 + c * x + -1 * q_0 / 2 * x \<up> 2) D x";
   38.82 +"y' x = Integral 1 / (- 1 * EI) * (c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2) D x";
   38.83  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.84 -"y' x =\nc_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3)";
   38.85 +"y' x =\nc_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)";
   38.86  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.87 -"y' x =\nc_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3)";
   38.88 +"y' x =\nc_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)";
   38.89  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.90  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.91  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.92  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   38.93  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.94 -"y x =\nIntegral c_3 +\n         1 / (-1 * EI) *\n         (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3) D x";
   38.95 +"y x =\nIntegral c_3 +\n         1 / (- 1 * EI) *\n         (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3) D x";
   38.96  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   38.97 -"y x =\nc_4 + c_3 * x +\n1 / (-1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)";
   38.98 +"y x =\nc_4 + c_3 * x +\n1 / (- 1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)";
   38.99  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
  38.100 -   "y x =\nc_4 + c_3 * x +\n1 / (-1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)";
  38.101 +   "y x =\nc_4 + c_3 * x +\n1 / (- 1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)";
  38.102  val (p,_,f,nxt,_,pt) = me nxt p c pt; 
  38.103  if f2str f =
  38.104 -   "[Q x = c + -1 * q_0 * x, M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2,\n dy x =\n c_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3),\n y x =\n c_4 + c_3 * x +\n 1 / (-1 * EI) *\n (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)]"
  38.105 +   "[Q x = c + - 1 * q_0 * x, M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2,\n dy x =\n c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3),\n y x =\n c_4 + c_3 * x +\n 1 / (- 1 * EI) *\n (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)]"
  38.106  then case nxt of ("End_Proof'", End_Proof') => ()
  38.107    | _ => error "biegelinie.sml met2 e 1"
  38.108  else error "biegelinie.sml met2 e 2";
    39.1 --- a/test/Tools/isac/Knowledge/biegelinie-3.sml	Mon Jun 21 22:08:01 2021 +0200
    39.2 +++ b/test/Tools/isac/Knowledge/biegelinie-3.sml	Sun Jul 18 18:15:27 2021 +0200
    39.3 @@ -15,10 +15,10 @@
    39.4  "----------- auto method [Biegelinien,setzeRandbedingungenEin]--------------------------------";
    39.5  "----------- auto method [Biegelinien,setzeRandbedingungenEin]--------------------------------";
    39.6  "----------- auto method [Biegelinien,setzeRandbedingungenEin]--------------------------------";
    39.7 -val fmz = ["Funktionen [Q x = c + -1 * q_0 * x," ^
    39.8 -    "M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2," ^
    39.9 -    "y' x = c_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3)," ^
   39.10 -    "y x = c_4 + c_3 * x + 1 / (-1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)]",
   39.11 +val fmz = ["Funktionen [Q x = c + - 1 * q_0 * x," ^
   39.12 +    "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2," ^
   39.13 +    "y' x = c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)," ^
   39.14 +    "y x = c_4 + c_3 * x + 1 / (- 1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)]",
   39.15  	   "Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]",
   39.16  	   "Gleichungen equ_s"];
   39.17  val (dI',pI',mI') = ("Biegelinie", ["setzeRandbedingungen", "Biegelinien"],
   39.18 @@ -32,17 +32,17 @@
   39.19  
   39.20  val ((pt, p),_) = get_calc 1;
   39.21  if p = ([], Res) andalso (get_obj g_res pt (fst p) |> UnparseC.term) =
   39.22 -  "[0 = -1 * c_4 / -1,\n 0 =\n (-24 * c_4 * EI + -24 * L * c_3 * EI + 12 * L \<up> 2 * c_2 +\n  4 * L \<up> 3 * c +\n  -1 * L \<up> 4 * q_0) /\n (-24 * EI),\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2]"
   39.23 +  "[0 = - 1 * c_4 / - 1,\n 0 =\n (- 24 * c_4 * EI + - 24 * L * c_3 * EI + 12 * L \<up> 2 * c_2 +\n  4 * L \<up> 3 * c +\n  - 1 * L \<up> 4 * q_0) /\n (- 24 * EI),\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]"
   39.24  then () else error "auto method [Biegelinien,setzeRandbedingungenEin] changed";
   39.25  
   39.26  
   39.27  "----------- me method [Biegelinien,setzeRandbedingungenEin]----------------------------------";
   39.28  "----------- me method [Biegelinien,setzeRandbedingungenEin]----------------------------------";
   39.29  "----------- me method [Biegelinien,setzeRandbedingungenEin]----------------------------------";
   39.30 -val fmz = ["Funktionen [Q x = c + -1 * q_0 * x," ^
   39.31 -    "M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2," ^
   39.32 -    "y' x = c_3 + 1 / (-1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3)," ^
   39.33 -    "y x = c_4 + c_3 * x + 1 / (-1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)]",
   39.34 +val fmz = ["Funktionen [Q x = c + - 1 * q_0 * x," ^
   39.35 +    "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2," ^
   39.36 +    "y' x = c_3 + 1 / (- 1 * EI) * (c_2 * x + c / 2 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)," ^
   39.37 +    "y x = c_4 + c_3 * x + 1 / (- 1 * EI) * (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)]",
   39.38  	   "Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]",
   39.39  	   "Gleichungen equ_s"];
   39.40  val (dI',pI',mI') = ("Biegelinie", ["setzeRandbedingungen", "Biegelinien"],
   39.41 @@ -61,8 +61,8 @@
   39.42  "----- Randbedingung y 0 = 0 in SUBpbl with met [Equation, fromFunction]";
   39.43  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   39.44  if (#1 o (get_obj g_fmz pt)) (fst p) =
   39.45 -   ["functionEq\n (y x =\n  c_4 + c_3 * x +\n  1 / (-1 * EI) *" ^
   39.46 -     "\n  (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4))",
   39.47 +   ["functionEq\n (y x =\n  c_4 + c_3 * x +\n  1 / (- 1 * EI) *" ^
   39.48 +     "\n  (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4))",
   39.49       "substitution (y 0 = 0)", "equality equ'''"] then ()
   39.50  else error "biegelinie.sml met setzeRandbed*Ein bb";
   39.51  (writeln o Istate.string_of) (get_istate_LI pt p);
   39.52 @@ -75,21 +75,21 @@
   39.53  case nxt of (_, Apply_Method["Equation", "fromFunction"]) => ()
   39.54  | _ => error "biegelinie.sml met2 ff";
   39.55  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f =
   39.56 -   "y x =\nc_4 + c_3 * x +\n1 / (-1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)";
   39.57 +   "y x =\nc_4 + c_3 * x +\n1 / (- 1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)";
   39.58  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   39.59  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   39.60  case nxt of (_, Check_Postcond ["makeFunctionTo", "equation"]) => ()
   39.61  | _ => error "biegelinie.sml met2 gg";
   39.62  
   39.63  "--- before 2.subpbl [Equation, fromFunction]";
   39.64 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = c_4 + 0 / (-1 * EI)" ;
   39.65 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = c_4 + 0 / (- 1 * EI)" ;
   39.66  case nxt of (_,Subproblem (_, ["makeFunctionTo", "equation"])) => ()
   39.67  | _ => error "biegelinie.sml met2 hh";
   39.68  "--- after 1st arrival at 2.subpbl [Equation, fromFunction]";
   39.69  
   39.70  val (p,_,f,nxt,_,pt) = me nxt p c pt; 
   39.71  if (#1 o (get_obj g_fmz pt)) (fst p) =
   39.72 -    ["functionEq\n (y x =\n  c_4 + c_3 * x +\n  1 / (-1 * EI) *\n  (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4))",
   39.73 +    ["functionEq\n (y x =\n  c_4 + c_3 * x +\n  1 / (- 1 * EI) *\n  (c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4))",
   39.74        "substitution (y L = 0)", "equality equ'''"] then ()
   39.75  else error "biegelinie.sml metsetzeRandbed*Ein bb ";
   39.76  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   39.77 @@ -98,11 +98,11 @@
   39.78  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   39.79  case nxt of (_, Apply_Method["Equation", "fromFunction"]) => ()
   39.80  | _ => error "biegelinie.sml met2 ii";
   39.81 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "y x =\nc_4 + c_3 * x +\n1 / (-1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)";
   39.82 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "y L =\nc_4 + c_3 * L +\n1 / (-1 * EI) *\n(c_2 / 2 * L \<up> 2 + c / 6 * L \<up> 3 + -1 * q_0 / 24 * L \<up> 4)";
   39.83 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 =\nc_4 + c_3 * L +\n1 / (-1 * EI) *\n(c_2 / 2 * L \<up> 2 + c / 6 * L \<up> 3 + -1 * q_0 / 24 * L \<up> 4)";
   39.84 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 =\nc_4 + L * c_3 +\n(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) / (-24 * EI)" ;
   39.85 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 =\nc_4 + L * c_3 +\n(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) / (-24 * EI)";
   39.86 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "y x =\nc_4 + c_3 * x +\n1 / (- 1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)";
   39.87 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "y L =\nc_4 + c_3 * L +\n1 / (- 1 * EI) *\n(c_2 / 2 * L \<up> 2 + c / 6 * L \<up> 3 + - 1 * q_0 / 24 * L \<up> 4)";
   39.88 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 =\nc_4 + c_3 * L +\n1 / (- 1 * EI) *\n(c_2 / 2 * L \<up> 2 + c / 6 * L \<up> 3 + - 1 * q_0 / 24 * L \<up> 4)";
   39.89 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 =\nc_4 + L * c_3 +\n(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI)" ;
   39.90 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 =\nc_4 + L * c_3 +\n(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI)";
   39.91  case nxt of (_,Subproblem (_, ["makeFunctionTo", "equation"])) => ()
   39.92  | _ => error "biegelinie.sml met2 jj";
   39.93  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   39.94 @@ -112,8 +112,8 @@
   39.95  case nxt of (_, Apply_Method ["Equation", "fromFunction"])=>()
   39.96  | _ => error "biegelinie.sml met2 kk";
   39.97  
   39.98 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2"(*true*);
   39.99 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = c_2 + c * 0 + -1 * q_0 / 2 * 0 \<up> 2";
  39.100 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2"(*true*);
  39.101 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = c_2 + c * 0 + - 1 * q_0 / 2 * 0 \<up> 2";
  39.102  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = c_2";
  39.103  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = c_2";
  39.104  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  39.105 @@ -129,17 +129,17 @@
  39.106  case nxt of (_, Apply_Method ["Equation", "fromFunction"])=>()
  39.107  | _ => error "biegelinie.sml met2 mm";
  39.108  
  39.109 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "M_b x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2";
  39.110 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "M_b L = c_2 + c * L + -1 * q_0 / 2 * L \<up> 2";
  39.111 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = c_2 + c * L + -1 * q_0 / 2 * L \<up> 2";
  39.112 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2";
  39.113 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2";
  39.114 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "M_b x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2";
  39.115 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "M_b L = c_2 + c * L + - 1 * q_0 / 2 * L \<up> 2";
  39.116 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = c_2 + c * L + - 1 * q_0 / 2 * L \<up> 2";
  39.117 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2";
  39.118 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f = "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2";
  39.119  case nxt of (_, Check_Postcond ["setzeRandbedingungen", "Biegelinien"]) => ()
  39.120  | _ => error "biegelinie.sml met2 nn";
  39.121  val (p,_,f,nxt,_,pt) = me nxt p c pt; 
  39.122  if nxt = ("End_Proof'", End_Proof') andalso f2str f =
  39.123 -(* "[0 = c_4,\n 0 =\n c_4 + L * c_3 +\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) / (-24 * EI),\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2]" *)
  39.124 -"[0 = c_4,\n 0 =\n c_4 + L * c_3 +\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) /\n (-1 * EI * 24),\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2]"
  39.125 +(* "[0 = c_4,\n 0 =\n c_4 + L * c_3 +\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI),\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]" *)
  39.126 +"[0 = c_4,\n 0 =\n c_4 + L * c_3 +\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) /\n (- 1 * EI * 24),\n 0 = c_2, 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]"
  39.127  then () else error "biegelinie.sml met2 oo";
  39.128  ============ inhibit exn WN1130722 Isabelle2012-->13 thehier? works in Test_Some=*)
  39.129  
    40.1 --- a/test/Tools/isac/Knowledge/biegelinie-4.sml	Mon Jun 21 22:08:01 2021 +0200
    40.2 +++ b/test/Tools/isac/Knowledge/biegelinie-4.sml	Sun Jul 18 18:15:27 2021 +0200
    40.3 @@ -63,7 +63,7 @@
    40.4  val (Form f, tac, asms) = ME_Misc.pt_extract (pt, ip);
    40.5  
    40.6  if ip = ([3, 8, 1], Res) andalso 
    40.7 -UnparseC.term f = "[-1 * c_4 / -1 = 0,\n (6 * c_4 * EI + 6 * L * c_3 * EI + -3 * L \<up> 2 * c_2 + -1 * L \<up> 3 * c) /\n (6 * EI) =\n L \<up> 4 * q_0 / (-24 * EI),\n c_2 = 0, c_2 + L * c = L \<up> 2 * q_0 / 2]"
    40.8 +UnparseC.term f = "[- 1 * c_4 / - 1 = 0,\n (6 * c_4 * EI + 6 * L * c_3 * EI + -3 * L \<up> 2 * c_2 + - 1 * L \<up> 3 * c) /\n (6 * EI) =\n L \<up> 4 * q_0 / (- 24 * EI),\n c_2 = 0, c_2 + L * c = L \<up> 2 * q_0 / 2]"
    40.9  then 
   40.10    case tac of
   40.11      SOME (Check_Postcond ["normalise", "4x4", "LINEAR", "system"]) => ()
   40.12 @@ -124,5 +124,5 @@
   40.13        (tac, (pt, p)) |> me' |> me' |> me' |> me' |> me' |> me' |> me' |> me';
   40.14  
   40.15  if p = ([2, 1, 1], Frm) andalso (Calc.current_formula (pt, p) |> UnparseC.term) =
   40.16 -  "y x =\nc_4 + c_3 * x +\n1 / (-1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)"
   40.17 +  "y x =\nc_4 + c_3 * x +\n1 / (- 1 * EI) *\n(c_2 / 2 * x \<up> 2 + c / 6 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)"
   40.18  then () else error "";
    41.1 --- a/test/Tools/isac/Knowledge/diff.sml	Mon Jun 21 22:08:01 2021 +0200
    41.2 +++ b/test/Tools/isac/Knowledge/diff.sml	Sun Jul 18 18:15:27 2021 +0200
    41.3 @@ -1,13 +1,11 @@
    41.4 -(* 
    41.5 -
    41.6 -use"../smltest/IsacKnowledge/diff.sml";
    41.7 -use"diff.sml";
    41.8 +(* Title: test/Tools/isac/Knowledge/diff.sml
    41.9 +   Author: Walther Neuper
   41.10 +   Use is subject to license terms.
   41.11  *)
   41.12 -
   41.13 -"--------------------------------------------------------";
   41.14 -"--------------------------------------------------------";
   41.15 -"table of contents --------------------------------------";
   41.16 -"--------------------------------------------------------";
   41.17 +"-----------------------------------------------------------------------------------------------";
   41.18 +"-----------------------------------------------------------------------------------------------";
   41.19 +"table of contents -----------------------------------------------------------------------------";
   41.20 +"-----------------------------------------------------------------------------------------------";
   41.21  "----------- problemtype --------------------------------";
   41.22  "----------- for correction of diff_const ---------------";
   41.23  "----------- for correction of diff_quot ----------------";
   41.24 @@ -184,7 +182,7 @@
   41.25  "----------- 1.5.02 me from script ----------------------";
   41.26  "----------- 1.5.02 me from script ----------------------";
   41.27  "----------- 1.5.02 me from script ----------------------";
   41.28 -(*exp_Diff_No-1.xml*)
   41.29 +(*exp_Diff_No- 1.xml*)
   41.30  val fmz = ["functionTerm (x \<up> 2 + 3 * x + 4)", 
   41.31  	   "differentiateFor x", "derivative f_f'"];
   41.32  val (dI',pI',mI') =
   41.33 @@ -270,7 +268,7 @@
   41.34  
   41.35  val t = TermC.str2term "2/x \<up> 2"; 
   41.36  val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
   41.37 -if UnparseC.term t = "2 * x \<up> -2" then () else error "diff.sml 1/x";
   41.38 +if UnparseC.term t = "2 * x \<up> - 2" then () else error "diff.sml 1/x";
   41.39  
   41.40  val t = TermC.str2term "sqrt (x \<up> 3)";
   41.41  val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
   41.42 @@ -278,10 +276,10 @@
   41.43  
   41.44  val t = TermC.str2term "2 / sqrt x \<up> 3";
   41.45  val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
   41.46 -if UnparseC.term t = "2 * x \<up> (-3 / 2)" then () else error"diff.sml x \<up> -1/2";
   41.47 +if UnparseC.term t = "2 * x \<up> (-3 / 2)" then () else error"diff.sml x \<up> - 1/2";
   41.48  val rls = diff_sym_conv; 
   41.49  
   41.50 -val t = TermC.str2term "2 * x \<up> -2";
   41.51 +val t = TermC.str2term "2 * x \<up> - 2";
   41.52  val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
   41.53  if UnparseC.term t = "2 / x \<up> 2" then () else error "diff.sml sym 1/x";
   41.54  
   41.55 @@ -292,7 +290,7 @@
   41.56  
   41.57  val t = TermC.str2term "2 * x \<up> (-3 / 2)";
   41.58  val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
   41.59 -if UnparseC.term t ="2 / sqrt (x \<up> 3)"then()else error"diff.sml sym x \<up> -1/x";
   41.60 +if UnparseC.term t ="2 / sqrt (x \<up> 3)"then()else error"diff.sml sym x \<up> - 1/x";
   41.61  
   41.62  
   41.63  "----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
   41.64 @@ -310,7 +308,7 @@
   41.65  autoCalculate 1 CompleteCalc;
   41.66  val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
   41.67  if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = 
   41.68 -			  "1 + 2 * x + -1 / x \<up> 2 + -4 / x \<up> 3" then ()
   41.69 +			  "1 + 2 * x + - 1 / x \<up> 2 + -4 / x \<up> 3" then ()
   41.70  else error "diff.sml: differentiate_on_R 2/x \<up> 2 changed";
   41.71  
   41.72  "---------------------------------------------------------";
   41.73 @@ -323,7 +321,7 @@
   41.74  Iterator 1;
   41.75  moveActiveRoot 1;
   41.76  autoCalculate 1 CompleteCalc;
   41.77 -(* Rewrite.trace_on := true;
   41.78 +(* Rewrite.trace_on := false; (*true false*)
   41.79     LItool.trace_on := false;
   41.80     *)
   41.81  val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
   41.82 @@ -343,11 +341,11 @@
   41.83    ["diff", "after_simplification"]))];
   41.84  Iterator 1;
   41.85  moveActiveRoot 1;
   41.86 -(* Rewrite.trace_on := true;
   41.87 +(* Rewrite.trace_on := false; (*true false*)
   41.88     LItool.trace_on := true;
   41.89     *)
   41.90  autoCalculate 1 CompleteCalc;
   41.91 -(* Rewrite.trace_on := false;
   41.92 +(* Rewrite.trace_on := false; Rewrite.trace_on := false; (*true false*)
   41.93     LItool.trace_on := false;
   41.94     *)
   41.95  val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
    42.1 --- a/test/Tools/isac/Knowledge/diffapp.sml	Mon Jun 21 22:08:01 2021 +0200
    42.2 +++ b/test/Tools/isac/Knowledge/diffapp.sml	Sun Jul 18 18:15:27 2021 +0200
    42.3 @@ -6,7 +6,7 @@
    42.4     use"diffapp.sml";
    42.5  *)
    42.6  
    42.7 -Rewrite.trace_on := false;
    42.8 +Rewrite.trace_on := false; (*true false*)
    42.9  "Contents----------------------------------------------";
   42.10  "              Specify_Problem (match_itms_oris)       ";
   42.11  "              test specify, fmz <> []                  ";
   42.12 @@ -668,9 +668,9 @@
   42.13  UnparseC.term s;
   42.14  val t = TermC.str2term 
   42.15  "(hd o filterVar A) [A = a * b, a / 2 = r * sin alpha, b / 2 = r * cos alpha]";
   42.16 -Rewrite.trace_on := false;
   42.17 +Rewrite.trace_on := false; (*true false*)
   42.18  val SOME (t',_) = rewrite_set_ thy false prog_expr t;
   42.19 -Rewrite.trace_on:=false;
   42.20 +Rewrite.trace_on:=false; (*true false*)
   42.21  val s' = UnparseC.term t';
   42.22  (*=== inhibit exn 110726=============================================================
   42.23  if s' = "A = a * b" then() else error "new behaviour with prog_expr 3.1.";
    43.1 --- a/test/Tools/isac/Knowledge/diophanteq.sml	Mon Jun 21 22:08:01 2021 +0200
    43.2 +++ b/test/Tools/isac/Knowledge/diophanteq.sml	Sun Jul 18 18:15:27 2021 +0200
    43.3 @@ -67,7 +67,7 @@
    43.4  val thy = @{theory "Test"};
    43.5  "----------- rewriting for usecase2 ---------------------";
    43.6  
    43.7 -val t = case parseNEW ctxt "xxx + abc + -1 * 111 + (123::int)" of
    43.8 +val t = case parseNEW ctxt "xxx + abc + - 1 * 111 + (123::int)" of
    43.9        SOME t' => t'
   43.10      | NONE => error "diophanteq.sml: syntax error in rewriting for usecase2";
   43.11  
   43.12 @@ -83,12 +83,12 @@
   43.13  "----------- mathengine with usecase2 -------------------";
   43.14  val p = e_pos'; val c = [];
   43.15  val (fmz, (thy, pbl, met)) = 
   43.16 -  (["intTestGiven (xxx + abc + -1 * 111 + (123::int))", "intTestFind sss"],
   43.17 +  (["intTestGiven (xxx + abc + - 1 * 111 + (123::int))", "intTestFind sss"],
   43.18     (Context.theory_name thy, ["inttype", "test"], ["Test", "intsimp"]));
   43.19  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (thy, pbl, met))];
   43.20  (*nxt = ("Model_Problem", ...)*)
   43.21  val (p,_,f,nxt,_,pt) = me nxt p c pt; 
   43.22 -(*nxt = ("Add_Given", Add_Given "intTestGiven (xxx + abc + -1 * 111 + 123)")*)
   43.23 +(*nxt = ("Add_Given", Add_Given "intTestGiven (xxx + abc + - 1 * 111 + 123)")*)
   43.24  val (p,_,f,nxt,_,pt) = me nxt p c pt; 
   43.25  (* Add_Find ###########################################*)
   43.26  val (p,_,f,nxt,_,pt) = me nxt p c pt; 
    44.1 --- a/test/Tools/isac/Knowledge/eqsystem.sml	Mon Jun 21 22:08:01 2021 +0200
    44.2 +++ b/test/Tools/isac/Knowledge/eqsystem.sml	Sun Jul 18 18:15:27 2021 +0200
    44.3 @@ -3,7 +3,7 @@
    44.4     (c) due to copyright terms
    44.5  *)
    44.6  
    44.7 -Rewrite.trace_on := false;
    44.8 +Rewrite.trace_on := false; (*true false*)
    44.9  "-----------------------------------------------------------------";
   44.10  "table of contents -----------------------------------------------";
   44.11  "-----------------------------------------------------------------";
   44.12 @@ -32,7 +32,7 @@
   44.13  "----------- occur_exactly_in ------------------------------------";
   44.14  "----------- occur_exactly_in ------------------------------------";
   44.15  val all = [TermC.str2term"c", TermC.str2term"c_2", TermC.str2term"c_3"];
   44.16 -val t = TermC.str2term"0 = -1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
   44.17 +val t = TermC.str2term"0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
   44.18  
   44.19  if occur_exactly_in [TermC.str2term"c", TermC.str2term"c_2"] all t
   44.20  then () else error "eqsystem.sml occur_exactly_in 1";
   44.21 @@ -43,25 +43,25 @@
   44.22  if not (occur_exactly_in [TermC.str2term"c_2"] all t)
   44.23  then () else error "eqsystem.sml occur_exactly_in 3";
   44.24  
   44.25 -val t = TermC.str2term"[c,c_2] from [c,c_2,c_3] occur_exactly_in -1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
   44.26 +val t = TermC.str2term"[c,c_2] from [c,c_2,c_3] occur_exactly_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
   44.27  eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
   44.28  val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
   44.29  if str = "[c, c_2] from [c, c_2,\n" ^
   44.30 -  "               c_3] occur_exactly_in -1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = True"
   44.31 +  "               c_3] occur_exactly_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = True"
   44.32  then () else error "eval_occur_exactly_in [c, c_2]";
   44.33  
   44.34  val t = TermC.str2term ("[c,c_2,c_3] from [c,c_2,c_3] occur_exactly_in " ^
   44.35 -		  "-1 * q_0 * L \<up> 2 / 2 + L * c + c_2");
   44.36 +		  "- 1 * q_0 * L \<up> 2 / 2 + L * c + c_2");
   44.37  val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
   44.38  if str = "[c, c_2,\n c_3] from [c, c_2,\n" ^
   44.39 -"            c_3] occur_exactly_in -1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = False"
   44.40 +"            c_3] occur_exactly_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = False"
   44.41  then () else error "eval_occur_exactly_in [c, c_2, c_3]";
   44.42  
   44.43  val t = TermC.str2term"[c_2] from [c,c_2,c_3] occur_exactly_in \
   44.44 -		\-1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
   44.45 +		\- 1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
   44.46  val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
   44.47  if str = "[c_2] from [c, c_2,\n" ^
   44.48 -  "            c_3] occur_exactly_in -1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = False"
   44.49 +  "            c_3] occur_exactly_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = False"
   44.50  then () else error "eval_occur_exactly_in [c, c_2, c_3]";
   44.51  
   44.52  val t = TermC.str2term"[] from [c,c_2,c_3] occur_exactly_in 0";
   44.53 @@ -71,10 +71,10 @@
   44.54  
   44.55  val t = 
   44.56      TermC.str2term
   44.57 -	"[] from [c, c_2, c_3, c_4] occur_exactly_in -1 * (q_0 * L \<up> 2) /2";
   44.58 +	"[] from [c, c_2, c_3, c_4] occur_exactly_in - 1 * (q_0 * L \<up> 2) /2";
   44.59  val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
   44.60  if str = "[] from [c, c_2, c_3, c_4] occur_exactly_in \
   44.61 -	 \-1 * (q_0 * L \<up> 2) / 2 = True" then ()
   44.62 +	 \- 1 * (q_0 * L \<up> 2) / 2 = True" then ()
   44.63  else error "eval_occur_exactly_in [c, c_2, c_3, c_4]";
   44.64  
   44.65  "----------- problems --------------------------------------------";
   44.66 @@ -122,15 +122,15 @@
   44.67  "----------- rewrite-order ord_simplify_System -------------------";
   44.68  "----------- rewrite-order ord_simplify_System -------------------";
   44.69  "----------- rewrite-order ord_simplify_System -------------------";
   44.70 -"M_b x = c * x + -1 * q_0 * (x \<up> 2 / 2) + c_2";
   44.71 +"M_b x = c * x + - 1 * q_0 * (x \<up> 2 / 2) + c_2";
   44.72  "--- add.commute ---"; (* ... add.commute cf. b42e334c97ee *)
   44.73 -if ord_simplify_System false thy [] (TermC.str2term"-1 * q_0 * (x \<up> 2 / 2)", 
   44.74 +if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \<up> 2 / 2)", 
   44.75  				       TermC.str2term"c * x") then ()
   44.76 -else error "integrate.sml, (-1 * q_0 * (x \<up> 2 / 2)) < (c * x) not#1";
   44.77 +else error "integrate.sml, (- 1 * q_0 * (x \<up> 2 / 2)) < (c * x) not#1";
   44.78  
   44.79 -if ord_simplify_System false thy [] (TermC.str2term"-1 * q_0 * (x \<up> 2 / 2)", 
   44.80 +if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \<up> 2 / 2)", 
   44.81  				       TermC.str2term"c_2") then ()
   44.82 -else error "integrate.sml, (-1 * q_0 * (x \<up> 2 / 2)) < (c_2) not#2";
   44.83 +else error "integrate.sml, (- 1 * q_0 * (x \<up> 2 / 2)) < (c_2) not#2";
   44.84  
   44.85  if ord_simplify_System false thy [] (TermC.str2term"c * x", 
   44.86  				       TermC.str2term"c_2") then ()
   44.87 @@ -141,28 +141,28 @@
   44.88  				       TermC.str2term"c * x") then ()
   44.89  else error "integrate.sml, (x * c) < (c * x) not#4";
   44.90  
   44.91 -if ord_simplify_System false thy [] (TermC.str2term"-1 * q_0 * (x \<up> 2 / 2) * c", 
   44.92 -				       TermC.str2term"-1 * q_0 * c * (x \<up> 2 / 2)") 
   44.93 +if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \<up> 2 / 2) * c", 
   44.94 +				       TermC.str2term"- 1 * q_0 * c * (x \<up> 2 / 2)") 
   44.95  then () else error "integrate.sml, (. * .) < (. * .) not#5";
   44.96  
   44.97 -if ord_simplify_System false thy [] (TermC.str2term"-1 * q_0 * (x \<up> 2 / 2) * c", 
   44.98 -				       TermC.str2term"c * -1 * q_0 * (x \<up> 2 / 2)") 
   44.99 +if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \<up> 2 / 2) * c", 
  44.100 +				       TermC.str2term"c * - 1 * q_0 * (x \<up> 2 / 2)") 
  44.101  then () else error "integrate.sml, (. * .) < (. * .) not#6";
  44.102  
  44.103  
  44.104  "----------- rewrite in [EqSystem,normalise,2x2] -----------------";
  44.105  "----------- rewrite in [EqSystem,normalise,2x2] -----------------";
  44.106  "----------- rewrite in [EqSystem,normalise,2x2] -----------------";
  44.107 -val t = TermC.str2term"[0 = -1 * q_0 * L \<up> 2 / 2 + L * c + c_2,\
  44.108 -	        \0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2]";
  44.109 +val t = TermC.str2term"[0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2,\
  44.110 +	        \0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2]";
  44.111  val bdvs = [(TermC.str2term"bdv_1",TermC.str2term"c"),
  44.112  	    (TermC.str2term"bdv_2",TermC.str2term"c_2")];
  44.113  val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
  44.114 -if UnparseC.term t = "[0 = -1 * q_0 * L \<up> 2 / 2 + (L * c + c_2), 0 = c_2]"
  44.115 +if UnparseC.term t = "[0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2), 0 = c_2]"
  44.116  then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.1";
  44.117  
  44.118  val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
  44.119 -if UnparseC.term t = "[L * c + c_2 = 0 + -1 * (-1 * q_0 * L \<up> 2 / 2), c_2 = 0]"then () else error "eqsystem.sml rewrite in 2x2 isolate_bdvs";
  44.120 +if UnparseC.term t = "[L * c + c_2 = 0 + - 1 * (- 1 * q_0 * L \<up> 2 / 2), c_2 = 0]"then () else error "eqsystem.sml rewrite in 2x2 isolate_bdvs";
  44.121  
  44.122  val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System t;
  44.123  if UnparseC.term t = "[L * c + c_2 = q_0 * L \<up> 2 / 2, c_2 = 0]"
  44.124 @@ -180,9 +180,9 @@
  44.125  val thy = @{theory "Isac_Knowledge"} (*because of Undeclared constant "Biegelinie.EI*);
  44.126  val t = 
  44.127      TermC.str2term"[0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 \<up> 3 +         \
  44.128 -	    \                                     -1 * q_0 / 24 * 0 \<up> 4),\
  44.129 +	    \                                     - 1 * q_0 / 24 * 0 \<up> 4),\
  44.130  	    \ 0 = c_2 + c * L + 1 / EI * (L * q_0 / 12 * L \<up> 3 +         \
  44.131 -	    \                                     -1 * q_0 / 24 * L \<up> 4)]";
  44.132 +	    \                                     - 1 * q_0 / 24 * L \<up> 4)]";
  44.133  val SOME (t,_) = rewrite_set_ thy true norm_Rational t;
  44.134  if UnparseC.term t =
  44.135      "[0 = c_2,\n 0 = (24 * c_2 * EI + 24 * L * c * EI + L \<up> 4 * q_0) / (24 * EI)]"
  44.136 @@ -194,13 +194,13 @@
  44.137  then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.1b";
  44.138  
  44.139  val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
  44.140 -if UnparseC.term t = (*"[c_2 = 0 + -1 * (0 / EI),\n L * c + c_2 = 0 + -1 * (q_0 * L \<up> 4 / (24 * EI))]"*)
  44.141 -                                    "[c_2 = 0, L * c + c_2 = 0 + -1 * (q_0 * L \<up> 4 / (24 * EI))]"
  44.142 +if UnparseC.term t = (*"[c_2 = 0 + - 1 * (0 / EI),\n L * c + c_2 = 0 + - 1 * (q_0 * L \<up> 4 / (24 * EI))]"*)
  44.143 +                                    "[c_2 = 0, L * c + c_2 = 0 + - 1 * (q_0 * L \<up> 4 / (24 * EI))]"
  44.144  then () else error "eqsystem.sml rewrite in 2x2 isolate_bdvs b";
  44.145  
  44.146  val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System t;
  44.147 -if UnparseC.term t = (*"[c_2 = 0 / EI, L * c + c_2 = -1 * q_0 * L \<up> 4 / (24 * EI)]"*)
  44.148 -                       "[c_2 = 0, L * c + c_2 = -1 * q_0 * L \<up> 4 / (24 * EI)]"
  44.149 +if UnparseC.term t = (*"[c_2 = 0 / EI, L * c + c_2 = - 1 * q_0 * L \<up> 4 / (24 * EI)]"*)
  44.150 +                       "[c_2 = 0, L * c + c_2 = - 1 * q_0 * L \<up> 4 / (24 * EI)]"
  44.151  then () else error "eqsystem.sml rewrite in 2x2 simplify_System.2b";
  44.152  
  44.153  val xxx = rewrite_set_ thy true order_system t;
  44.154 @@ -225,18 +225,18 @@
  44.155  else error "eqsystem.sml top_down_substitution,2x2] simpl_par";
  44.156  
  44.157  val SOME (e2__,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs e2__;
  44.158 -if UnparseC.term e2__ = "c = (q_0 * L \<up> 2 / 2 + -1 * 77) / L" then ()
  44.159 +if UnparseC.term e2__ = "c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L" then ()
  44.160  else error "eqsystem.sml top_down_substitution,2x2] isolate";
  44.161  
  44.162 -val t = TermC.str2term "[c_2 = 77, c = (q_0 * L \<up> 2 / 2 + -1 * 77) / L]";
  44.163 +val t = TermC.str2term "[c_2 = 77, c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L]";
  44.164  val SOME (t,_) = rewrite_set_ thy true order_system t;
  44.165 -if UnparseC.term t = "[c = (q_0 * L \<up> 2 / 2 + -1 * 77) / L, c_2 = 77]" then ()
  44.166 +if UnparseC.term t = "[c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L, c_2 = 77]" then ()
  44.167  else error "eqsystem.sml top_down_substitution,2x2] order_system";
  44.168  
  44.169  if not (ord_simplify_System
  44.170  	    false thy [] 
  44.171 -	    (TermC.str2term"[c_2 = 77, c = (q_0 * L \<up> 2 / 2 + -1 * 77) / L]", 
  44.172 -	     TermC.str2term"[c = (q_0 * L \<up> 2 / 2 + -1 * 77) / L, c_2 = 77]")) 
  44.173 +	    (TermC.str2term"[c_2 = 77, c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L]", 
  44.174 +	     TermC.str2term"[c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L, c_2 = 77]")) 
  44.175  then () else error "eqsystem.sml, order_result rew_ord";
  44.176  
  44.177  
  44.178 @@ -244,8 +244,8 @@
  44.179  "----------- rewrite in [EqSystem,normalise,4x4] -----------------";
  44.180  "----------- rewrite in [EqSystem,normalise,4x4] -----------------";
  44.181  (*STOPPED.WN06?: revise rewrite in [EqSystem,normalise,4x4] from before 0609*)
  44.182 -val t = TermC.str2term"[0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c_3 + c_4,\
  44.183 -	        \0 = -1 * q_0 * L \<up> 2 / 2 + L * c_3 + c_4,\
  44.184 +val t = TermC.str2term"[0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c_3 + c_4,\
  44.185 +	        \0 = - 1 * q_0 * L \<up> 2 / 2 + L * c_3 + c_4,\
  44.186  		\c + c_2 + c_3 + c_4 = 0,\
  44.187  		\c_2 + c_3 + c_4 = 0]";
  44.188  val bdvs = [(TermC.str2term"bdv_1",TermC.str2term"c"),
  44.189 @@ -254,13 +254,13 @@
  44.190  	    (TermC.str2term"bdv_4",TermC.str2term"c_4")];
  44.191  val SOME (t,_) = 
  44.192      rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
  44.193 -if UnparseC.term t = "[0 = c_4, 0 = -1 * q_0 * L \<up> 2 / 2 + (L * c_3 + c_4),\n\
  44.194 +if UnparseC.term t = "[0 = c_4, 0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c_3 + c_4),\n\
  44.195  	        \ c + (c_2 + (c_3 + c_4)) = 0, c_2 + (c_3 + c_4) = 0]"
  44.196  then () else error "eqsystem.sml rewrite in 4x4 simplify_System_paren";
  44.197  
  44.198  val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
  44.199  if UnparseC.term t = "[c_4 = 0, \
  44.200 -	        \L * c_3 + c_4 = 0 + -1 * (-1 * q_0 * L \<up> 2 / 2),\n \
  44.201 +	        \L * c_3 + c_4 = 0 + - 1 * (- 1 * q_0 * L \<up> 2 / 2),\n \
  44.202  		\c + (c_2 + (c_3 + c_4)) = 0, c_2 + (c_3 + c_4) = 0]"
  44.203  then () else error "eqsystem.sml rewrite in 4x4 isolate_bdvs";
  44.204  
  44.205 @@ -282,8 +282,8 @@
  44.206  "----------- refine [linear,system]-------------------------------";
  44.207  "----------- refine [linear,system]-------------------------------";
  44.208  val fmz =
  44.209 -  ["equalities [0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2," ^
  44.210 -               "0 = -1 * q_0 * L \<up> 2 / 2 + L * c + (c_2::real)]", 
  44.211 +  ["equalities [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2," ^
  44.212 +               "0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + (c_2::real)]", 
  44.213  	   "solveForVars [c, c_2]", "solution LL"];
  44.214  
  44.215  (*WN120313 in "solution L" above "Refine.refine fmz ["LINEAR", "system"]" caused an error...*)
  44.216 @@ -329,7 +329,7 @@
  44.217  			     With = [],
  44.218  			     Given =
  44.219  			       [Correct
  44.220 -				"equalities\n [0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\n  0 = -1 * q_0 * L \<up> 2 / 2 + L * c + c_2]",
  44.221 +				"equalities\n [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\n  0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2]",
  44.222  				        Correct "solveForVars [c, c_2]"],
  44.223  				     Where = [],
  44.224  				     Relate = []})] => ()
  44.225 @@ -365,7 +365,7 @@
  44.226            [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]"]*)
  44.227  val t = TermC.str2term ("[c, c_2] from [c, c_2] occur_exactly_in NTH 2" ^   
  44.228  		  "[c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]");
  44.229 -Rewrite.trace_on := false;
  44.230 +Rewrite.trace_on := false; (*true false*)
  44.231  val SOME (t',_) = rewrite_set_ thy false prls_triangular t;
  44.232  (*found:...
  44.233  ##  try thm: NTH_CONS
  44.234 @@ -374,14 +374,15 @@
  44.235      nth_ (2 + - 1 + - 1) []
  44.236  ####  rls: erls_prls_triangular on: 1 < 2 + - 1
  44.237  #####  try calc: op <'
  44.238 -###  asms accepted: ["1 < 2 + - 1"]   stored: ["1 < 2 + -1"]
  44.239 +###  asms accepted: ["1 < 2 + - 1"]   stored: ["1 < 2 + - 1"]
  44.240  
  44.241  ... i.e Eval (\<^const_name>\<open>plus\<close>, eval_binop "#add_") was missing in erls_prls_triangular*)
  44.242 -Rewrite.trace_on:=false;
  44.243 +
  44.244 +Rewrite.trace_on:=false; (*true false*)
  44.245  
  44.246  "===== case 3: relaxed preconditions for triangular system =====";
  44.247  val fmz = ["equalities [L * q_0 = c,                               \
  44.248 -	   \            0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2,\
  44.249 +	   \            0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2,\
  44.250  	   \            0 = c_4,                                           \
  44.251  	   \            0 = c_3]", 
  44.252  	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
  44.253 @@ -407,7 +408,7 @@
  44.254  
  44.255  "===== case 4 =====";
  44.256  val fmz = ["equalities [L * q_0 = c,                                       \
  44.257 -	   \            0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2,\
  44.258 +	   \            0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2,\
  44.259  	   \            0 = c_3,                           \
  44.260  	   \            0 = c_4]", 
  44.261  	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
  44.262 @@ -423,12 +424,12 @@
  44.263  "----------- Refine.refine [2x2,linear,system] search error--------------";
  44.264  (*didn't go into ["2x2", "LINEAR", "system"]; 
  44.265    we investigated in these steps:*)
  44.266 -val fmz = ["equalities [0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\
  44.267 -	               \0 = -1 * q_0 * L \<up> 2 / 2 + L * c + c_2]", 
  44.268 +val fmz = ["equalities [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\
  44.269 +	               \0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2]", 
  44.270  	   "solveForVars [c, c_2]", "solution LL"];
  44.271 -Rewrite.trace_on := false;
  44.272 +Rewrite.trace_on := false; (*true false*)
  44.273  val matches = Refine.refine fmz ["2x2", "LINEAR", "system"];
  44.274 -Rewrite.trace_on:=false;
  44.275 +Rewrite.trace_on:=false; (*true false*)
  44.276  (*default_print_depth 11;*) TermC.matches; (*default_print_depth 3;*)
  44.277  (*brought: 'False "length_ es_ = 2"'*)
  44.278  
  44.279 @@ -468,9 +469,9 @@
  44.280  > (writeln o (I_Model.to_string (ThyC.to_ctxt @{theory Isac_Knowledge}))) itms;
  44.281  [
  44.282  (1 ,[1] ,true ,#Given ,Cor equalities
  44.283 - [0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
  44.284 -  0 = -1 * q_0 * L \<up> 2 / 2 + L * c + c_2] ,(es_, [[0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
  44.285 - 0 = -1 * q_0 * L \<up> 2 / 2 + L * c + c_2]])),
  44.286 + [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
  44.287 +  0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2] ,(es_, [[0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
  44.288 + 0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2]])),
  44.289  (2 ,[1] ,true ,#Given ,Cor solveForVars [c, c_2] ,(v_s, [[c, c_2]])),
  44.290  (3 ,[1] ,true ,#Find ,Cor solution L ,(ss___, [L]))]
  44.291  
  44.292 @@ -487,8 +488,8 @@
  44.293  ----- fun check in Pre_Conds.
  44.294  > (writeln o env2str) env;
  44.295  ["
  44.296 -(es_, [0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
  44.297 - 0 = -1 * q_0 * L \<up> 2 / 2 + L * c + c_2])", "
  44.298 +(es_, [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
  44.299 + 0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2])", "
  44.300  (v_s, [c, c_2])", "
  44.301  (ss___, L)"]
  44.302  
  44.303 @@ -512,8 +513,8 @@
  44.304  "----------- me [EqSystem,normalise,2x2] -------------------------";
  44.305  "----------- me [EqSystem,normalise,2x2] -------------------------";
  44.306  "----------- me [EqSystem,normalise,2x2] -------------------------";
  44.307 -val fmz = ["equalities [0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\
  44.308 -	               \0 = -1 * q_0 * L \<up> 2 / 2 + L * c + c_2]", 
  44.309 +val fmz = ["equalities [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\
  44.310 +	               \0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2]", 
  44.311  	   "solveForVars [c, c_2]", "solution LL"];
  44.312  val (dI',pI',mI') =
  44.313    ("Biegelinie",["normalise", "2x2", "LINEAR", "system"],
  44.314 @@ -578,9 +579,9 @@
  44.315  val fmz = 
  44.316      ["equalities\
  44.317       \[0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 \<up> 3 +                \
  44.318 -     \                                            -1 * q_0 / 24 * 0 \<up> 4),\
  44.319 +     \                                            - 1 * q_0 / 24 * 0 \<up> 4),\
  44.320       \ 0 = c_2 + c * L + 1 / EI * (L * q_0 / 12 * L \<up> 3 +                \
  44.321 -     \                                            -1 * q_0 / 24 * L \<up> 4)]",
  44.322 +     \                                            - 1 * q_0 / 24 * L \<up> 4)]",
  44.323       "solveForVars [c, c_2]", "solution LL"];
  44.324  val (dI',pI',mI') =
  44.325    ("Biegelinie",["LINEAR", "system"], ["no_met"]);
  44.326 @@ -599,7 +600,7 @@
  44.327  val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
  44.328  val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
  44.329  if f2str f = 
  44.330 -"[c_2 = 0, L * c + c_2 = -1 * q_0 * L \<up> 4 / (24 * EI)]"
  44.331 +"[c_2 = 0, L * c + c_2 = - 1 * q_0 * L \<up> 4 / (24 * EI)]"
  44.332  then () else error "eqsystem.sml me simpl. before SubProblem b";
  44.333  case nxt of
  44.334      (Subproblem ("Biegelinie", ["triangular", "2x2", "LINEAR",_])) => ()
  44.335 @@ -635,7 +636,7 @@
  44.336  val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
  44.337  val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
  44.338  
  44.339 -if f2str f = "[c = -1 * q_0 * L \<up> 3 / (24 * EI), c_2 = 0]"
  44.340 +if f2str f = "[c = - 1 * q_0 * L \<up> 3 / (24 * EI), c_2 = 0]"
  44.341  then () else error "eqsystem.sml me [EqSys...2x2] finished f2str f b";
  44.342  case nxt of
  44.343      (End_Proof') => ()
  44.344 @@ -666,20 +667,20 @@
  44.345  c c_2             c c_2 c_3 c_4     [2':c, 1:c_2, 3:c_4] -> 4:c_3*)
  44.346  val t = TermC.str2term
  44.347    ("[0 = c_4, " ^
  44.348 -  "0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) / (-24 * EI), " ^
  44.349 +  "0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI), " ^
  44.350    "0 = c_2, " ^
  44.351 -  "0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2]");
  44.352 +  "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]");
  44.353  val SOME (t, _) = rewrite_set_ thy false isolate_bdvs_4x4 t;
  44.354  if UnparseC.term t =
  44.355 -"[c_4 = 0,\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) /\n (-24 * EI) =\n -1 * (c_4 + L * c_3) + 0,\n c_2 = 0, (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2 = 0]"
  44.356 +"[c_4 = 0,\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) /\n (- 24 * EI) =\n - 1 * (c_4 + L * c_3) + 0,\n c_2 = 0, (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2 = 0]"
  44.357  then () else error "Bsp 7.27";
  44.358  
  44.359  "----- Bsp 7.27 go through the rewrites in met_eqsys_norm_4x4";
  44.360 -val t = TermC.str2term "0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2";
  44.361 +val t = TermC.str2term "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2";
  44.362  val NONE = rewrite_set_ thy false norm_Rational t;
  44.363  val SOME (t,_) = 
  44.364      rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
  44.365 -if UnparseC.term t = "0 = -1 * q_0 * L \<up> 2 / 2 + (L * c + c_2)"
  44.366 +if UnparseC.term t = "0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2)"
  44.367  then () else error "Bsp 7.27 go through the rewrites in met_eqsys_norm_4x4";
  44.368  
  44.369  "--- isolate_bdvs_4x4";
  44.370 @@ -721,10 +722,10 @@
  44.371        c_3                   c_4	 			   
  44.372  c c_2 c_3         c c_2 c_3 c_4     3:c_4 -> 4:c c_2 c_3    1:c_3 -> 4:c c_2*)
  44.373  val t = TermC.str2term 
  44.374 -  ("[0 = c_4 + 0 / (-1 * EI), " ^
  44.375 -  "0 = c_4 + L * c_3 + (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) / (-24 * EI), " ^
  44.376 -  "0 = c_3 + 0 / (-1 * EI), " ^
  44.377 -  "0 = c_3 + (6 * L * c_2 + 3 * L \<up> 2 * c + -1 * L \<up> 3 * q_0) / (-6 * EI)]");
  44.378 +  ("[0 = c_4 + 0 / (- 1 * EI), " ^
  44.379 +  "0 = c_4 + L * c_3 + (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI), " ^
  44.380 +  "0 = c_3 + 0 / (- 1 * EI), " ^
  44.381 +  "0 = c_3 + (6 * L * c_2 + 3 * L \<up> 2 * c + - 1 * L \<up> 3 * q_0) / (-6 * EI)]");
  44.382  
  44.383  "------- Bsp 7.70";
  44.384  reset_states ();
  44.385 @@ -744,38 +745,38 @@
  44.386  "----- 7.70 go through the rewrites in met_eqsys_norm_4x4";
  44.387  val t = TermC.str2term
  44.388    ("[L * q_0 = c, " ^
  44.389 -  "0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2, " ^
  44.390 +  "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2, " ^
  44.391    "0 = c_4, " ^
  44.392    "0 = c_3]");
  44.393  val SOME (t,_) = rewrite_ thy e_rew_ord Rule_Set.empty false (ThmC.numerals_to_Free @{thm commute_0_equality}) t;
  44.394  val SOME (t,_) = rewrite_ thy e_rew_ord Rule_Set.empty false (ThmC.numerals_to_Free @{thm commute_0_equality}) t;
  44.395  val SOME (t,_) = rewrite_ thy e_rew_ord Rule_Set.empty false (ThmC.numerals_to_Free @{thm commute_0_equality}) t;
  44.396  if UnparseC.term t = 
  44.397 -  "[L * q_0 = c, (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2 = 0, c_4 = 0,\n c_3 = 0]"
  44.398 +  "[L * q_0 = c, (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2 = 0, c_4 = 0,\n c_3 = 0]"
  44.399  then () else error "7.70 go through the rewrites in met_eqsys_norm_4x4, 1";
  44.400  
  44.401  val SOME (t,_) = rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
  44.402 -if UnparseC.term t = "[L * q_0 = c, -1 * q_0 * L \<up> 2 / 2 + (L * c + c_2) = 0, c_4 = 0,\n c_3 = 0]"
  44.403 +if UnparseC.term t = "[L * q_0 = c, - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2) = 0, c_4 = 0,\n c_3 = 0]"
  44.404  then () else error "7.70 go through the rewrites in met_eqsys_norm_4x4, 2";
  44.405  
  44.406  val SOME (t,_) = rewrite_set_inst_ thy false subst isolate_bdvs_4x4 t;
  44.407  if UnparseC.term t =
  44.408 -   "[c = (-1 * (L * q_0) + 0) / -1,\n" ^ 
  44.409 -   " L * c + c_2 = -1 * (-1 * q_0 * L \<up> 2 / 2) + 0, c_4 = 0, c_3 = 0]"
  44.410 +   "[c = (- 1 * (L * q_0) + 0) / - 1,\n" ^ 
  44.411 +   " L * c + c_2 = - 1 * (- 1 * q_0 * L \<up> 2 / 2) + 0, c_4 = 0, c_3 = 0]"
  44.412  then () else error "7.70 go through the rewrites in met_eqsys_norm_4x4, 3";
  44.413  
  44.414  val SOME (t,_) = rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
  44.415 -if UnparseC.term t = "[c = -1 * L * q_0 / -1, L * c + c_2 = q_0 * L \<up> 2 / 2, c_4 = 0, c_3 = 0]"
  44.416 +if UnparseC.term t = "[c = - 1 * L * q_0 / - 1, L * c + c_2 = q_0 * L \<up> 2 / 2, c_4 = 0, c_3 = 0]"
  44.417  then () else error "7.70 go through the rewrites in met_eqsys_norm_4x4, 4";
  44.418  
  44.419  val SOME (t, _) = rewrite_set_ thy false order_system t;
  44.420 -if UnparseC.term t = "[c = -1 * L * q_0 / -1, L * c + c_2 = q_0 * L \<up> 2 / 2, c_3 = 0, c_4 = 0]"
  44.421 +if UnparseC.term t = "[c = - 1 * L * q_0 / - 1, L * c + c_2 = q_0 * L \<up> 2 / 2, c_3 = 0, c_4 = 0]"
  44.422  then () else error "eqsystem.sml: exp 7.70 normalise 4x4 by rewrite changed";
  44.423  
  44.424  "----- 7.70 with met normalise: ";
  44.425  val fmz = ["equalities" ^
  44.426    "[L * q_0 = c, " ^
  44.427 -  "0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2, " ^
  44.428 +  "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2, " ^
  44.429    "0 = c_4, " ^
  44.430    "0 = c_3]", "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
  44.431  val (dI',pI',mI') = ("Biegelinie",["LINEAR", "system"], ["no_met"]);
  44.432 @@ -817,9 +818,9 @@
  44.433  --------------------------------------------------------------------------*)
  44.434  
  44.435  "----- 7.70 with met top_down_: me";
  44.436 -val fmz = ["equalities                                         \
  44.437 -	    \[c = L * q_0, L * c + c_2 = q_0 * L \<up> 2 / 2, c_3 = 0, c_4 = 0]",
  44.438 -	    "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
  44.439 +val fmz = [
  44.440 +  "equalities [(c::real) = L * q_0, L * c + (c_2::real) = q_0 * L \<up> 2 / 2, (c_3::real) = 0, (c_4::real) = 0]",
  44.441 +	"solveForVars [(c::real), (c_2::real), (c_3::real), (c_4::real)]", "solution LL"];
  44.442  val (dI',pI',mI') =
  44.443    ("Biegelinie",["LINEAR", "system"],["no_met"]);
  44.444  val p = e_pos'; val c = []; 
  44.445 @@ -837,9 +838,8 @@
  44.446  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
  44.447  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
  44.448  if nxt = ("End_Proof'", End_Proof') andalso
  44.449 -   f2str f = "[c = L * q_0, c_2 = -1 * L \<up> 2 * q_0 / 2, c_3 = 0, c_4 = 0]"
  44.450 +   f2str f = "[c = L * q_0, c_2 = - 1 * L \<up> 2 * q_0 / 2, c_3 = 0, c_4 = 0]"
  44.451  then () else error "eqsystem.sml: 7.70 with met top_down_: me";
  44.452 -============ inhibit exn WN120314 ==============================================*)
  44.453  
  44.454  "------- Bsp 7.71";
  44.455  reset_states ();
  44.456 @@ -857,10 +857,10 @@
  44.457            c_4  |      c_3     |2:c_3 -> 4' :c c_2 c_4 |	         |
  44.458  c c_2 c_3 c_4  |          c_4 |3'                     |	         |
  44.459        c_3      |c c_2 c_3 c_4 |3:c_4 -> 4'':c c_2     |4'':c c_2 |      *)
  44.460 -val t = TermC.str2term"[0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2, \
  44.461 -\ 0 = c_4 + 0 / (-1 * EI),                            \
  44.462 -\ 0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) /(-24 * EI),\
  44.463 -\ 0 = c_3 + 0 / (-1 * EI)]";
  44.464 +val t = TermC.str2term"[0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2, \
  44.465 +\ 0 = c_4 + 0 / (- 1 * EI),                            \
  44.466 +\ 0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) /(- 24 * EI),\
  44.467 +\ 0 = c_3 + 0 / (- 1 * EI)]";
  44.468  
  44.469  "------- Bsp 7.72a ---------------vvvvvvvvvvvvv Momentenlinie postponed";
  44.470  reset_states ();
  44.471 @@ -893,9 +893,9 @@
  44.472            c_4  |     |			    |
  44.473  c c_2 c_3 c_4  |     |3:c_4 -> 4':c c_2 c_3 |c_2 c c_3*)
  44.474  val t = TermC.str2term"[0 = c_2,                                            \
  44.475 -\ 0 = (6 * c_2 + 6 * L * c + -1 * L \<up> 2 * q_0) / 6, \
  44.476 -\ 0 = c_4 + 0 / (-1 * EI),                            \
  44.477 -\ 0 = c_4 + L * c_3 + (60 * L \<up> 2 * c_2 + 20 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) / (-120 * EI)]";
  44.478 +\ 0 = (6 * c_2 + 6 * L * c + - 1 * L \<up> 2 * q_0) / 6, \
  44.479 +\ 0 = c_4 + 0 / (- 1 * EI),                            \
  44.480 +\ 0 = c_4 + L * c_3 + (60 * L \<up> 2 * c_2 + 20 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 120 * EI)]";
  44.481  
  44.482  "------- Bsp 7.73 ---------------vvvvvvvvvvvvv Momentenlinie postponed";
  44.483  reset_states ();
  44.484 @@ -917,9 +917,9 @@
  44.485  "----- Bsp 7.27";
  44.486  val fmz = ["equalities \
  44.487  	   \[0 = c_4,                           \
  44.488 -	   \ 0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) / (-24 * EI),                                       \
  44.489 +	   \ 0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI),                                       \
  44.490  	   \ 0 = c_2,                                           \
  44.491 -	   \ 0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2]", 
  44.492 +	   \ 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]", 
  44.493  	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
  44.494  val (dI',pI',mI') =
  44.495    ("Biegelinie",["normalise", "4x4", "LINEAR", "system"],
  44.496 @@ -933,27 +933,27 @@
  44.497  "------------------------------------------- Apply_Method...";
  44.498  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
  44.499  "[0 = c_4,                                          \
  44.500 -\ 0 = c_4 + L * c_3 +\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + -1 * L \<up> 4 * q_0) / (-24 * EI),                                   \
  44.501 +\ 0 = c_4 + L * c_3 +\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI),                                   \
  44.502  \ 0 = c_2,                                          \
  44.503 -\ 0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2]";
  44.504 +\ 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]";
  44.505  (*vvvWN080102 Exception- Match raised 
  44.506    since associate Rewrite .. Rewrite_Set
  44.507  "------------------------------------------- simplify_System_parenthesized...";
  44.508  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
  44.509  "[0 = c_4,                                  \
  44.510 -\ 0 = -1 * q_0 * L \<up> 4 / (-24 * EI) +     \
  44.511 -\     (4 * L \<up> 3 * c / (-24 * EI) +       \
  44.512 -\     (12 * L \<up> 2 * c_2 / (-24 * EI) +    \
  44.513 +\ 0 = - 1 * q_0 * L \<up> 4 / (- 24 * EI) +     \
  44.514 +\     (4 * L \<up> 3 * c / (- 24 * EI) +       \
  44.515 +\     (12 * L \<up> 2 * c_2 / (- 24 * EI) +    \
  44.516  \     (L * c_3 + c_4))),                    \
  44.517  \ 0 = c_2,                                  \
  44.518 -\ 0 = -1 * q_0 * L \<up> 2 / 2 + (L * c + c_2)]";
  44.519 -(*? "(4 * L \<up> 3 / (-24 * EI) * c" statt "(4 * L \<up> 3 * c / (-24 * EI)" ?*)
  44.520 +\ 0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2)]";
  44.521 +(*? "(4 * L \<up> 3 / (- 24 * EI) * c" statt "(4 * L \<up> 3 * c / (- 24 * EI)" ?*)
  44.522  "------------------------------------------- isolate_bdvs...";
  44.523  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
  44.524  "[c_4 = 0,\
  44.525 -\ c_4 = 0 + -1 * (-1 * q_0 * L \<up> 4 / (-24 * EI)) + -1 * (4 * L \<up> 3 * c / (-24 * EI)) + -1 * (12 * L \<up> 2 * c_2 / (-24 * EI)) + -1 * (L * c_3),\
  44.526 +\ c_4 = 0 + - 1 * (- 1 * q_0 * L \<up> 4 / (- 24 * EI)) + - 1 * (4 * L \<up> 3 * c / (- 24 * EI)) + - 1 * (12 * L \<up> 2 * c_2 / (- 24 * EI)) + - 1 * (L * c_3),\
  44.527  \ c_2 = 0, \
  44.528 -\ c_2 = 0 + -1 * (-1 * q_0 * L \<up> 2 / 2) + -1 * (L * c)]";
  44.529 +\ c_2 = 0 + - 1 * (- 1 * q_0 * L \<up> 2 / 2) + - 1 * (L * c)]";
  44.530  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
  44.531  
  44.532  ---------------------------------------------------------------------*)
    45.1 --- a/test/Tools/isac/Knowledge/gcd_poly_ml.sml	Mon Jun 21 22:08:01 2021 +0200
    45.2 +++ b/test/Tools/isac/Knowledge/gcd_poly_ml.sml	Sun Jul 18 18:15:27 2021 +0200
    45.3 @@ -1,13 +1,11 @@
    45.4 -(* Title: test/../rational2
    45.5 +(* Title: test/Knowledge/gec_poly_ml.sml
    45.6     Author: Diana Meindl
    45.7     Copyright (c) Diana Meindl 2011
    45.8 -12345678901234567890123456789012345678901234567890123456789012345678901234567890
    45.9 -        10        20        30        40        50        60        70        80
   45.10  *)
   45.11  
   45.12  (*fun nth _ []      = error "nth _ []" (*Isabelle2002, still saved the hours of update*)
   45.13      | nth 1 (x::_) = x
   45.14 -    | nth n (_::xs) = nth (n-1) xs;*)
   45.15 +    | nth n (_::xs) = nth (n- 1) xs;*)
   45.16    fun nth xs i = List.nth (xs, i);     (*recent Isabelle: TODO update all isac code   *)
   45.17  
   45.18  "--------------------------------------------------------";
   45.19 @@ -493,7 +491,7 @@
   45.20  "----------- fun add_monoms -----------------------------";
   45.21  "----------- fun add_monoms -----------------------------";
   45.22  "----------- fun add_monoms -----------------------------";
   45.23 -if add_monoms [(~3,[0,0]),(4,[0,0]),(3,[1,1]),(~3,[1,1]),(2,[1,2]),(~3,[1,2])] = 
   45.24 +if add_monoms [(~3,[0,0]), (4,[0,0]), (3,[1,1]), (~3,[1,1]), (2,[1,2]), (~3,[1,2])] = 
   45.25    [(1, [0, 0]), (~1, [1, 2])] 
   45.26  then () else error ("add_monoms [(~3,[0,0]),(4,[0,0]),(3,[1,1]),(~3,[1,1]),(2,[1,2]),(~3,[1,2])] " ^
   45.27    "= [(1, [0, 0]), (~1, [1, 2])] changed")
   45.28 @@ -688,20 +686,20 @@
   45.29  
   45.30  "~~~~~ fun NEWTON, args:"; val (x,f,steps,t,p,ord) = ([1, 2, 3, 4],[[(9, [0]), (5, [1])], [(16, [0]), (7, [1])]], [[(5, [0]), (2, [1])], [(1, [0])]], [2, ~3, 1], [(1, [2, 0]), (~1, [0, 1]), (2, [1, 1])], 0  );
   45.31  length x = 2; (* false *)
   45.32 -val new_value_poly = multi_to_uni((uni_to_multi t)  %%*%% (uni_to_multi [(nth x (length x -2) )* ~1, 1]));
   45.33 -val new_steps = [((nth f (length f -1)) %%/ ((nth x (length x - 1)) - (nth x (length x - 2)))) %%-%% ((nth f (length f -2)))];
   45.34 +val new_value_poly = multi_to_uni((uni_to_multi t)  %%*%% (uni_to_multi [(nth x (length x - 2) )* ~1, 1]));
   45.35 +val new_steps = [((nth f (length f - 1)) %%/ ((nth x (length x - 1)) - (nth x (length x - 2)))) %%-%% ((nth f (length f - 2)))];
   45.36  
   45.37  "~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (steps, new_steps, x);
   45.38  steps = []; (*false*)
   45.39  
   45.40 -"~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (nth_drop 0 steps, new_steps @ [(((nth new_steps (length new_steps -1)) %%-%%(nth steps 0))) %%/
   45.41 -                                  ((nth x' (length x' - 1)) - (nth x' (length x' - 3)))], nth_drop (length x' -2) x');steps = []; (*false*)
   45.42 +"~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (nth_drop 0 steps, new_steps @ [(((nth new_steps (length new_steps - 1)) %%-%%(nth steps 0))) %%/
   45.43 +                                  ((nth x' (length x' - 1)) - (nth x' (length x' - 3)))], nth_drop (length x' - 2) x');steps = []; (*false*)
   45.44  
   45.45 -"~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (nth_drop 0 steps, new_steps @ [(((nth new_steps (length new_steps -1)) %%-%%(nth steps 0))) %%/
   45.46 -                                  ((nth x' (length x' - 1)) - (nth x' (length x' - 3)))], nth_drop (length x' -2) x');
   45.47 +"~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (nth_drop 0 steps, new_steps @ [(((nth new_steps (length new_steps - 1)) %%-%%(nth steps 0))) %%/
   45.48 +                                  ((nth x' (length x' - 1)) - (nth x' (length x' - 3)))], nth_drop (length x' - 2) x');
   45.49  steps = []; (*true*)
   45.50  val steps = new_steps;
   45.51 -val polynom' =  p %%+%% (mult_with_new_var (nth steps (length steps -1)) new_value_poly ord);
   45.52 +val polynom' =  p %%+%% (mult_with_new_var (nth steps (length steps - 1)) new_value_poly ord);
   45.53  
   45.54  "----------- fun all_geq  -------------------------------";
   45.55  "----------- fun all_geq  -------------------------------";
   45.56 @@ -747,7 +745,7 @@
   45.57  "gcd_poly' [(~3,[2,0]),(1,[5,0]),(3,[0,1]),(~6,[1,1]),(~1,[3,1]),(2,[4,1]),(1,[3,2]),(~1,[1,3]),(2,[2,3])]"
   45.58  "[(2,[2,0]),(~2,[0,1]),(4,[1,1]),(~1,[3,1]),(1,[1,2]),(~1,[2,2]),(~1,[0,3]),(2,[1,3])] 2 0 "
   45.59  "= [(1, [2, 0]), (~1, [0, 1]), (2, [1, 1])] changed";
   45.60 -(* -xy +xy^2z+yz - 1*)(* xy +1*) (*=*) (*xy -1*)
   45.61 +(* -xy +xy^2z+yz - 1*)(* xy +1*) (*=*) (*xy - 1*)
   45.62  if gcd_poly' [(~1,[0,0,0]),(1,[0,1,1]),(1,[1,2,1]),(~1,[1,1,0])] [(1,[0,0,0]),(1,[1,1,0])] 3 0 
   45.63   = (*[(~1, [0, 0, 0]), (~1, [1, 1, 0])] ..ok for isabisac15; ?!? unchecked for Isabelle2017..*)   
   45.64       [(1, [0, 0, 0]), (1, [1, 1, 0])] then () else error
   45.65 @@ -1063,8 +1061,8 @@
   45.66  "----------- fun EUCLID_naive_up ------------------------";
   45.67  "----------- fun EUCLID_naive_up ------------------------";
   45.68  "----------- fun EUCLID_naive_up ------------------------";
   45.69 -  val a = [0,~1,1]; (* -x + x^2 =  x   *(-1 + x) *)
   45.70 -  val b = [~1,0,1]; (* -1 + x^2 = (1+x)*(-1 + x) *)
   45.71 +  val a = [0,~1,1]; (* -x + x^2 =  x   *(- 1 + x) *)
   45.72 +  val b = [~1,0,1]; (* - 1 + x^2 = (1+x)*(- 1 + x) *)
   45.73  (*EUCLID_naive_up a b; (* = [1, ~1]*) (*( 1 - x) *)
   45.74  ERROR: invariant 2 does not hold: [~1, 0, 1] * ~1 = [~1, ~1] ** [1, ~1] ++ [0, 0, 0, 0]*)
   45.75  ;
   45.76 @@ -1115,13 +1113,13 @@
   45.77  then () else error "div_int_up: invariant 2 does not hold in ~~~~~ fun Euclid_naive";
   45.78  
   45.79  
   45.80 -val a = [~1,0,0,1]; (* -1 + x^3 = (1+x+x^2)*(-1 + x) *)
   45.81 -val b = [0,~1,1];   (* -x + x^2 = x        *(-1 + x) *)
   45.82 -if EUCLID_naive_up a b = [~1, 1]             (*(-1 + x) *)
   45.83 +val a = [~1,0,0,1]; (* - 1 + x^3 = (1+x+x^2)*(- 1 + x) *)
   45.84 +val b = [0,~1,1];   (* -x + x^2 = x        *(- 1 + x) *)
   45.85 +if EUCLID_naive_up a b = [~1, 1]             (*(- 1 + x) *)
   45.86   then () else error "fun EUCLID_naive_up changed 1";
   45.87  
   45.88 -val a = [0,~1,0,0,1]; (* -x + x^4 = x*(1+x+x^2)*(-1 + x) *)
   45.89 -val b = [~2,2];       (* -x + x^2 =  2         *(-1 + x) *)
   45.90 +val a = [0,~1,0,0,1]; (* -x + x^4 = x*(1+x+x^2)*(- 1 + x) *)
   45.91 +val b = [~2,2];       (* -x + x^2 =  2         *(- 1 + x) *)
   45.92  if EUCLID_naive_up a b = [~1, 1] then () else error "fun EUCLID_naive_up changed 2";
   45.93  
   45.94  val a = [~5,2,8,~3,~3,0,1,0,1];
   45.95 @@ -1178,6 +1176,6 @@
   45.96  " ========== END ======================================= ";
   45.97    fun nth _ []      = error "nth _ []" (*Isabelle2002, still saved the hours of update*)
   45.98      | nth 1 (x::_) = x
   45.99 -    | nth n (_::xs) = nth (n-1) xs;
  45.100 +    | nth n (_::xs) = nth (n- 1) xs;
  45.101  (*fun nth xs i = List.nth (xs, i);       recent Isabelle: TODO update all isac code   *)
  45.102  
    46.1 --- a/test/Tools/isac/Knowledge/gcd_poly_winkler.sml	Mon Jun 21 22:08:01 2021 +0200
    46.2 +++ b/test/Tools/isac/Knowledge/gcd_poly_winkler.sml	Sun Jul 18 18:15:27 2021 +0200
    46.3 @@ -15,7 +15,7 @@
    46.4  
    46.5  (*fun nth _ []      = error "nth _ []" (*Isabelle2002, still saved the hours of update*)
    46.6      | nth 1 (x::_) = x
    46.7 -    | nth n (_::xs) = nth (n-1) xs;*)
    46.8 +    | nth n (_::xs) = nth (n- 1) xs;*)
    46.9    fun nth xs i = List.nth (xs, i);     (*recent Isabelle: TODO update all isac code   *)
   46.10  "--------------------------------------------------------";
   46.11  "table of contents --------------------------------------";
   46.12 @@ -138,7 +138,7 @@
   46.13    fun primeList number =
   46.14      let 
   46.15      fun make_primelist list last number =
   46.16 -      if (nth list (length list -1)) < number
   46.17 +      if (nth list (length list - 1)) < number
   46.18        then
   46.19          if ( is_prime list (last + 2)) 
   46.20          then make_primelist (list @ [(last + 2)]) (last + 2) number
   46.21 @@ -162,19 +162,19 @@
   46.22  (*subsection {* calculations for univariate polynomials *}*)
   46.23  
   46.24    fun lc (uvp: unipoly) =
   46.25 -    if nth uvp (length uvp-1) <>0
   46.26 -    then nth uvp (length uvp-1)
   46.27 -    else lc (nth_drop (length uvp-1) uvp);
   46.28 +    if nth uvp (length uvp- 1) <>0
   46.29 +    then nth uvp (length uvp- 1)
   46.30 +    else lc (nth_drop (length uvp- 1) uvp);
   46.31    
   46.32    fun deg (uvp: unipoly) = 
   46.33 -    if nth uvp (length uvp-1) <>0
   46.34 +    if nth uvp (length uvp- 1) <>0
   46.35      then length uvp - 1
   46.36 -    else deg (nth_drop (length uvp-1) uvp)
   46.37 +    else deg (nth_drop (length uvp- 1) uvp)
   46.38  
   46.39    fun lc_of_unipoly_not_0 [] = [](* and delete lc=0*)
   46.40      | lc_of_unipoly_not_0 (uvp: unipoly) = 
   46.41 -      if nth uvp (length uvp -1) =0
   46.42 -      then lc_of_unipoly_not_0 (nth_drop (length uvp-1) uvp)
   46.43 +      if nth uvp (length uvp - 1) =0
   46.44 +      then lc_of_unipoly_not_0 (nth_drop (length uvp- 1) uvp)
   46.45        else  uvp;
   46.46  
   46.47    fun normirt_polynom (poly1: unipoly) (m: int) =
   46.48 @@ -184,11 +184,11 @@
   46.49        fun normirt poly1 b m lc_a i =
   46.50          if i=0
   46.51          then [mod_div (nth poly1 i) lc_a m]@b
   46.52 -        else normirt poly1 ( [mod_div(nth poly1 i) lc_a m]@b) m lc_a (i-1) ;
   46.53 +        else normirt poly1 ( [mod_div(nth poly1 i) lc_a m]@b) m lc_a (i- 1) ;
   46.54      in 
   46.55        if length(poly1)=0
   46.56        then poly1
   46.57 -      else normirt poly1  [] m lc_a (length(poly1)-1)
   46.58 +      else normirt poly1  [] m lc_a (length(poly1)- 1)
   46.59    end
   46.60  
   46.61     infix %*
   46.62 @@ -420,7 +420,7 @@
   46.63  
   46.64    fun cero_multipoly 1 = [(0,[0])]
   46.65      | cero_multipoly (diferent_var: int) = 
   46.66 -      add_var_to_multipoly (cero_multipoly (diferent_var-1)) 0;
   46.67 +      add_var_to_multipoly (cero_multipoly (diferent_var- 1)) 0;
   46.68  
   46.69    fun short_mv (mvp: multipoly) = 
   46.70      let fun short (mvp: multipoly) (new: multipoly) =
   46.71 @@ -439,9 +439,9 @@
   46.72    fun greater_var [a: int] [b: int] = 
   46.73      a > b 
   46.74      | greater_var (a: int list) (b: int list) =
   46.75 -    if  (nth a (length a -1))= (nth b (length b -1))
   46.76 -      then greater_var (nth_drop (length a-1) a) (nth_drop (length b-1) b)
   46.77 -      else (nth a (length a -1)) > (nth b (length b -1))
   46.78 +    if  (nth a (length a - 1))= (nth b (length b - 1))
   46.79 +      then greater_var (nth_drop (length a- 1) a) (nth_drop (length b- 1) b)
   46.80 +      else (nth a (length a - 1)) > (nth b (length b - 1))
   46.81  
   46.82    fun order_multipoly (a: multipoly)=
   46.83      let 
   46.84 @@ -449,18 +449,18 @@
   46.85        fun order_mp [] [] = cero_multipoly (length (get_varlist a 0))
   46.86          | order_mp [] (ordered: multipoly) = short_mv ordered
   46.87          | order_mp a (ordered: multipoly) =
   46.88 -        if  greater_var (get_varlist a 0) (get_varlist ordered (length ordered -1))
   46.89 +        if  greater_var (get_varlist a 0) (get_varlist ordered (length ordered - 1))
   46.90            then order_mp (nth_drop 0 a)(ordered @ [nth a 0])
   46.91            else let 
   46.92 -            val rest = [nth ordered (length ordered -1)];
   46.93 +            val rest = [nth ordered (length ordered - 1)];
   46.94              fun order_mp' [] (new: multipoly) (rest: multipoly) = new @ rest
   46.95                | order_mp' (ordered': multipoly) (new: multipoly) (rest: multipoly) =
   46.96 -                if greater_var (get_varlist new 0) (get_varlist ordered' (length ordered' -1))
   46.97 +                if greater_var (get_varlist new 0) (get_varlist ordered' (length ordered' - 1))
   46.98                    then ordered' @ new @ rest
   46.99 -                  else order_mp' (nth_drop (length ordered' -1) ordered') new 
  46.100 -                                 ([nth ordered' (length ordered' -1)]@ rest)
  46.101 +                  else order_mp' (nth_drop (length ordered' - 1) ordered') new 
  46.102 +                                 ([nth ordered' (length ordered' - 1)]@ rest)
  46.103              in order_mp (nth_drop 0 a) 
  46.104 -                        (order_mp' (nth_drop (length ordered -1) ordered) [nth a 0] rest)
  46.105 +                        (order_mp' (nth_drop (length ordered - 1) ordered) [nth a 0] rest)
  46.106            end
  46.107      in order_mp (nth_drop 0 a) ordered
  46.108      end
  46.109 @@ -470,7 +470,7 @@
  46.110  
  46.111   (* greatest variablegroup  *)
  46.112    fun deg_multipoly (mvp: multipoly) = 
  46.113 -    get_varlist (order_multipoly mvp) (length (order_multipoly mvp) -1)
  46.114 +    get_varlist (order_multipoly mvp) (length (order_multipoly mvp) - 1)
  46.115   
  46.116    fun  max_deg_var [m: monom] (x: int) = nth (get_varlist [m] 0) x |
  46.117     max_deg_var (mvp: multipoly) (x: int) =
  46.118 @@ -482,11 +482,11 @@
  46.119      end  
  46.120  
  46.121    fun greater_deg (monom1: monom) (monom2: monom)=
  46.122 -    if (max_deg_var [monom1] (length(get_varlist [monom1] 0) -1)) > 
  46.123 -       (max_deg_var [monom2] (length (get_varlist [monom2] 0) -1))
  46.124 +    if (max_deg_var [monom1] (length(get_varlist [monom1] 0) - 1)) > 
  46.125 +       (max_deg_var [monom2] (length (get_varlist [monom2] 0) - 1))
  46.126        then 1
  46.127 -      else if (max_deg_var [monom1] (length(get_varlist [monom1] 0) -1)) < 
  46.128 -              (max_deg_var [monom2] (length (get_varlist [monom2] 0) -1))
  46.129 +      else if (max_deg_var [monom1] (length(get_varlist [monom1] 0) - 1)) < 
  46.130 +              (max_deg_var [monom2] (length (get_varlist [monom2] 0) - 1))
  46.131          then 2
  46.132          else if length (get_varlist [monom1] 0) >1
  46.133            then
  46.134 @@ -551,9 +551,9 @@
  46.135    
  46.136    fun greater_deg_multipoly (var1: int list) (var2: int list) =
  46.137      if var1 = [] andalso var2 =[] then 0
  46.138 -    else if (nth var1 (length var1 -1)) = (nth var2 (length var1 -1) ) 
  46.139 -         then greater_deg_multipoly (nth_drop (length var1 -1) var1) (nth_drop (length var1 -1) var2)
  46.140 -         else if (nth var1 (length var1 -1)) > (nth var2 (length var1 -1)) 
  46.141 +    else if (nth var1 (length var1 - 1)) = (nth var2 (length var1 - 1) ) 
  46.142 +         then greater_deg_multipoly (nth_drop (length var1 - 1) var1) (nth_drop (length var1 - 1) var2)
  46.143 +         else if (nth var1 (length var1 - 1)) > (nth var2 (length var1 - 1)) 
  46.144                then 1 else 2 ;
  46.145  
  46.146    infix %%+%%
  46.147 @@ -594,10 +594,10 @@
  46.148          andalso (coef1 mod coef2) = 0)
  46.149      | (_: multipoly) %%|%% [(0,_)]=  true
  46.150      | (poly2: multipoly)  %%|%% (poly1: multipoly) =
  46.151 -    if [nth poly2 (length poly2 -1)]   %%|%% [nth poly1 (length poly1 -1)]
  46.152 +    if [nth poly2 (length poly2 - 1)]   %%|%% [nth poly1 (length poly1 - 1)]
  46.153      then poly2 %%|%% (poly1 %%-%%
  46.154 -      ([((get_coef poly1 (length poly1 -1)) div (get_coef poly2 (length poly2 -1)),
  46.155 -      (get_varlist poly1 (length poly1 -1)) %-%(get_varlist poly2 (length poly2 -1)))] %%*%%
  46.156 +      ([((get_coef poly1 (length poly1 - 1)) div (get_coef poly2 (length poly2 - 1)),
  46.157 +      (get_varlist poly1 (length poly1 - 1)) %-%(get_varlist poly2 (length poly2 - 1)))] %%*%%
  46.158        poly2)) 
  46.159      else false
  46.160  
  46.161 @@ -615,16 +615,16 @@
  46.162      if length x = 2
  46.163      then let val (polynom, new_value_poly, steps) =  newton_first x [(nth f 0), (nth f 1)] order
  46.164           in (polynom, new_value_poly, steps) end
  46.165 -    else let val new_value_poly = multi_to_uni((uni_to_multi t)  %%*%% (uni_to_multi [(nth x (length x -2) )* ~1, 1]));
  46.166 -             val new_steps = [((nth f (length f -1))  %%-%% (nth f (length f -2)))  %%/ ((nth x (length x - 1)) - (nth x (length x - 2)))];
  46.167 +    else let val new_value_poly = multi_to_uni((uni_to_multi t)  %%*%% (uni_to_multi [(nth x (length x - 2) )* ~1, 1]));
  46.168 +             val new_steps = [((nth f (length f - 1))  %%-%% (nth f (length f - 2)))  %%/ ((nth x (length x - 1)) - (nth x (length x - 2)))];
  46.169               fun next_step ([]: multipoly list) (new_steps: multipoly list) (_: int list) = new_steps
  46.170                 | next_step (steps: multipoly list) (new_steps: multipoly list) (x': int list) =  
  46.171                   next_step (nth_drop 0 steps)
  46.172 -                           (new_steps @ [(((nth new_steps (length new_steps -1)) %%-%%(nth steps 0)) %%/
  46.173 +                           (new_steps @ [(((nth new_steps (length new_steps - 1)) %%-%%(nth steps 0)) %%/
  46.174                                      ((nth x' (length x' - 1)) - (nth x' (length x' - 3))))])
  46.175 -                           ( nth_drop (length x' -2) x')
  46.176 +                           ( nth_drop (length x' - 2) x')
  46.177               val steps = next_step steps new_steps x;
  46.178 -             val polynom' =  (p %%+%% (mult_with_new_var (nth steps (length steps -1)) new_value_poly order));
  46.179 +             val polynom' =  (p %%+%% (mult_with_new_var (nth steps (length steps - 1)) new_value_poly order));
  46.180         in (order_multipoly(polynom'), new_value_poly, steps) end;
  46.181  
  46.182  "=========== code for [1] p.95: multivariate ============";
  46.183 @@ -639,12 +639,12 @@
  46.184            (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))))
  46.185        else 
  46.186        let 
  46.187 -(*1*)   val M = 1 + Int.min (max_deg_var a (length(get_varlist a 0)-2), max_deg_var b (length(get_varlist b 0)-2)); 
  46.188 +(*1*)   val M = 1 + Int.min (max_deg_var a (length(get_varlist a 0)- 2), max_deg_var b (length(get_varlist b 0)- 2)); 
  46.189  (*2*)     fun GOTO2 a b n s M r_list steps =  (*==============================*)
  46.190                let 
  46.191                  val r = find_new_r a b r;
  46.192                  val r_list = r_list @ [r];
  46.193 -                val g_r = GCD_MODm (order_multipoly (evaluate_mv a (s-1) r)) ( order_multipoly (evaluate_mv b (s-1) r)) (n-1) (s-1) 0
  46.194 +                val g_r = GCD_MODm (order_multipoly (evaluate_mv a (s- 1) r)) ( order_multipoly (evaluate_mv b (s- 1) r)) (n- 1) (s- 1) 0
  46.195                  val steps = steps @ [g_r];
  46.196  (*3*)           fun GOTO3 a b n s M g_r r r_list steps = (* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *)
  46.197                    let  
  46.198 @@ -659,16 +659,16 @@
  46.199                          let 
  46.200                          val r = find_new_r a b r; 
  46.201                          val r_list = r_list @ [r];
  46.202 -                        val g_r = GCD_MODm (order_multipoly  (evaluate_mv a (s-1) r))
  46.203 -                                            (order_multipoly  (evaluate_mv b (s-1) r)) (n-1) (s-1) 0
  46.204 +                        val g_r = GCD_MODm (order_multipoly  (evaluate_mv a (s- 1) r))
  46.205 +                                            (order_multipoly  (evaluate_mv b (s- 1) r)) (n- 1) (s- 1) 0
  46.206                          in  
  46.207                            if greater_var  (deg_multipoly g) (deg_multipoly g_r)
  46.208                              then GOTO3 a b n s M g_r r r_list steps
  46.209                              else if (deg_multipoly g)= (deg_multipoly g_r)
  46.210                                then
  46.211                                  let 
  46.212 -                                  val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s-1)
  46.213 -                                in if (nth steps (length steps -1)) = (cero_multipoly s)
  46.214 +                                  val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s- 1)
  46.215 +                                in if (nth steps (length steps - 1)) = (cero_multipoly s)
  46.216                                     then WHILE a b n s M (M+1) r r_list steps g_r g_n new
  46.217                                     else WHILE a b n s M (m+1) r r_list steps g_r g_n new 
  46.218                                  end
  46.219 @@ -1243,20 +1243,20 @@
  46.220  
  46.221  "~~~~~ fun newton_mv, args:"; val (x,f,steps,t,p,order) = ([1, 2, 3, 4],[[(9, [0]), (5, [1])], [(16, [0]), (7, [1])]], [[(5, [0]), (2, [1])], [(1, [0])]], [2, ~3, 1], [(1, [2, 0]), (~1, [0, 1]), (2, [1, 1])], 0  );
  46.222  length x = 2; (* false *)
  46.223 -val new_value_poly = multi_to_uni((uni_to_multi t)  %%*%% (uni_to_multi [(nth x (length x -2) )* ~1, 1]));
  46.224 -val new_steps = [((nth f (length f -1)) %%/ ((nth x (length x - 1)) - (nth x (length x - 2)))) %%-%% ((nth f (length f -2)))];
  46.225 +val new_value_poly = multi_to_uni((uni_to_multi t)  %%*%% (uni_to_multi [(nth x (length x - 2) )* ~1, 1]));
  46.226 +val new_steps = [((nth f (length f - 1)) %%/ ((nth x (length x - 1)) - (nth x (length x - 2)))) %%-%% ((nth f (length f - 2)))];
  46.227  
  46.228  "~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (steps, new_steps, x);
  46.229  steps = []; (*false*)
  46.230  
  46.231 -"~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (nth_drop 0 steps, new_steps @ [(((nth new_steps (length new_steps -1)) %%-%%(nth steps 0))) %%/
  46.232 -                                  ((nth x' (length x' - 1)) - (nth x' (length x' - 3)))], nth_drop (length x' -2) x');steps = []; (*false*)
  46.233 +"~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (nth_drop 0 steps, new_steps @ [(((nth new_steps (length new_steps - 1)) %%-%%(nth steps 0))) %%/
  46.234 +                                  ((nth x' (length x' - 1)) - (nth x' (length x' - 3)))], nth_drop (length x' - 2) x');steps = []; (*false*)
  46.235  
  46.236 -"~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (nth_drop 0 steps, new_steps @ [(((nth new_steps (length new_steps -1)) %%-%%(nth steps 0))) %%/
  46.237 -                                  ((nth x' (length x' - 1)) - (nth x' (length x' - 3)))], nth_drop (length x' -2) x');
  46.238 +"~~~~~ fun next_step, args:"; val (steps,new_steps, x') = (nth_drop 0 steps, new_steps @ [(((nth new_steps (length new_steps - 1)) %%-%%(nth steps 0))) %%/
  46.239 +                                  ((nth x' (length x' - 1)) - (nth x' (length x' - 3)))], nth_drop (length x' - 2) x');
  46.240  steps = []; (*true*)
  46.241  val steps = new_steps;
  46.242 -val polynom' =  p %%+%% (mult_with_new_var (nth steps (length steps -1)) new_value_poly order);
  46.243 +val polynom' =  p %%+%% (mult_with_new_var (nth steps (length steps - 1)) new_value_poly order);
  46.244  
  46.245  "----------- fun listgreater  ---------------------------";
  46.246  "----------- fun listgreater  ---------------------------";
  46.247 @@ -1299,7 +1299,7 @@
  46.248  "GCD_MODm [(~3,[2,0]),(1,[5,0]),(3,[0,1]),(~6,[1,1]),(~1,[3,1]),(2,[4,1]),(1,[3,2]),(~1,[1,3]),(2,[2,3])]"
  46.249  "[(2,[2,0]),(~2,[0,1]),(4,[1,1]),(~1,[3,1]),(1,[1,2]),(~1,[2,2]),(~1,[0,3]),(2,[1,3])] 2 1 0 "
  46.250  "= [(1, [2, 0]), (~1, [0, 1]), (2, [1, 1])] changed";
  46.251 -(* -xy +xy^2z+yz - 1*)(* xy +1*) (*=*) (*xy -1*)
  46.252 +(* -xy +xy^2z+yz - 1*)(* xy +1*) (*=*) (*xy - 1*)
  46.253  if GCD_MODm [(~1,[0,0,0]),(1,[0,1,1]),(1,[1,2,1]),(~1,[1,1,0])] [(1,[0,0,0]),(1,[1,1,0])] 3 2 0 
  46.254  = [(1, [0, 0, 0]), (1, [1, 1, 0])] then () else error
  46.255  "GCD_MODm [(~1,[0,0,0]),(1,[0,1,1]),(1,[1,2,1]),(~1,[1,1,0])] [(1,[0,0,0]),(1,[1,1,0])] 3 2 0 "
  46.256 @@ -1308,7 +1308,7 @@
  46.257  " ~~~ 1 ~~~";
  46.258  "~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ([(1,[1,2,1])], [(1,[1,2,1])], 3, 2, 0);
  46.259  s = 0; (*false*)
  46.260 -val M = 1 +  Int.min (max_deg_var a (length(get_varlist a 0)-2), max_deg_var b (length(get_varlist b 0)-2)); 
  46.261 +val M = 1 +  Int.min (max_deg_var a (length(get_varlist a 0)- 2), max_deg_var b (length(get_varlist b 0)- 2)); 
  46.262   " ~~~ 1 ~~~";
  46.263  "~~~~~ fun GOTO2 , args:"; val(a, b, n, s, M, r_list, steps ) =(a, b, n, s, M, [], []);
  46.264  val r = find_new_r a b r;
  46.265 @@ -1316,10 +1316,10 @@
  46.266  val (a',b',n',s',r',r_list',steps',M') = ( a,b,n,s,r,r_list,steps,M);
  46.267  (*g_1=*)
  46.268   " ~~~ 1.1 ~~~";
  46.269 -"~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ((order_multipoly (evaluate_mv a (s-1) r)), ( order_multipoly (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.270 +"~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ((order_multipoly (evaluate_mv a (s- 1) r)), ( order_multipoly (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.271  s = 0; (*false*)
  46.272  
  46.273 -val M = 1 +  Int.min (max_deg_var a (length(get_varlist a 0)-2), max_deg_var b (length(get_varlist b 0)-2)); 
  46.274 +val M = 1 +  Int.min (max_deg_var a (length(get_varlist a 0)- 2), max_deg_var b (length(get_varlist b 0)- 2)); 
  46.275   " ~~~ 1.1 ~~~";
  46.276  "~~~~~ fun GOTO2 , args:"; val(a, b, n, s, M, r_list, steps ) =(a, b, n, s, M, [], []);
  46.277  val r = find_new_r a b r;
  46.278 @@ -1327,7 +1327,7 @@
  46.279  val (a'',b'',n'',s'',r'',r_list'') = ( a,b,n,s,r,r_list);
  46.280  (*g_2=*)
  46.281   " ~~~ 1.1.1 ~~~";
  46.282 -"~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ((order_multipoly (evaluate_mv a (s-1) r)), ( order_multipoly (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.283 +"~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ((order_multipoly (evaluate_mv a (s- 1) r)), ( order_multipoly (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.284  s = 0; (*true*)
  46.285  val g_2 =uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))))
  46.286  val ( a,b,n,s,r,r_list) = (a'',b'',n'',s'',r'',r_list'');
  46.287 @@ -1346,7 +1346,7 @@
  46.288  val (a'',b'',n'',s'',r'',r_list'') = ( a,b,n,s,r,r_list);
  46.289  (*g_3=*)
  46.290   " ~~~ 1.1.W1.1 ~~~";
  46.291 -"~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ((order_multipoly (evaluate_mv a (s-1) r)), ( order_multipoly (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.292 +"~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ((order_multipoly (evaluate_mv a (s- 1) r)), ( order_multipoly (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.293  s = 0; (*true*)
  46.294  val g_3 =uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))));
  46.295   " ~~~ 1.1.W1 ~~~";
  46.296 @@ -1354,9 +1354,9 @@
  46.297  val g_r = g_3;
  46.298  greater_var  (deg_multipoly g) (deg_multipoly g_r) (*false*);
  46.299  (deg_multipoly g)= (deg_multipoly g_r) (*true*);
  46.300 -val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s-1);
  46.301 +val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s- 1);
  46.302  if g_n = [(1,[1,1])] then () else error "g_n is false" ;
  46.303 -(nth steps (length steps -1)) = (cero_multipoly s) (* false*);
  46.304 +(nth steps (length steps - 1)) = (cero_multipoly s) (* false*);
  46.305   " ~~~ 1.1.W2 ~~~";
  46.306  "~~~~~ fun WHILE , args:"; val (a ,b ,n ,s, M, m, r, r_list, steps, g, g_n ,mult) =
  46.307  (a, b, n, s, M, (m+1), r, r_list, steps, g_r, g_n, new);
  46.308 @@ -1366,16 +1366,16 @@
  46.309  val (a'',b'',n'',s'',r'',r_list'') = ( a,b,n,s,r,r_list);
  46.310  (*g_4=*)
  46.311  " ~~~ 1.1.W2.1 ~~~";
  46.312 -"~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ((order_multipoly (evaluate_mv a (s-1) r)), ( order_multipoly (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.313 +"~~~~~ fun GCD_MODm , args:"; val (a,b,n,s,r) = ((order_multipoly (evaluate_mv a (s- 1) r)), ( order_multipoly (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.314  s = 0; (*true*)
  46.315  val g_r =uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))));
  46.316  val ( a,b,n,s,r,r_list) = (a'',b'',n'',s'',r'',r_list'');
  46.317  " ~~~ 1.1.W2 ~~~";
  46.318  greater_var  (deg_multipoly g) (deg_multipoly g_r) (*false*);
  46.319  (deg_multipoly g)= (deg_multipoly g_r) (*true*);
  46.320 -val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s-1);
  46.321 +val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s- 1);
  46.322  if g_n = [(1,[1,1])] then () else error "g_n is false" ;
  46.323 -(nth steps (length steps -1)) = (cero_multipoly s) (* true*);
  46.324 +(nth steps (length steps - 1)) = (cero_multipoly s) (* true*);
  46.325   " ~~~ 1.1.W3 ~~~";
  46.326  "~~~~~ fun WHILE , args:"; val (a ,b ,n ,s, M, m, r, r_list, steps, g, g_n ,mult) =
  46.327  (a, b, n, s, M, (M+1), r, r_list, steps, g_r, g_n, new);
  46.328 @@ -1401,9 +1401,9 @@
  46.329  (* g_2 = GCD_MODm *)
  46.330   " ~~~ 1.W1.1 ~~~";
  46.331  "~~~~~ fun GCD_MODm, args:"; val  (a,b,n,s,r) = 
  46.332 -((order_multipoly  (evaluate_mv a (s-1) r)),(order_multipoly  (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.333 +((order_multipoly  (evaluate_mv a (s- 1) r)),(order_multipoly  (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.334  s = 0; (*false*)
  46.335 -val M = 1 +  Int.min(max_deg_var a (length(get_varlist a 0)-2), max_deg_var b (length(get_varlist b 0)-2)); 
  46.336 +val M = 1 +  Int.min(max_deg_var a (length(get_varlist a 0)- 2), max_deg_var b (length(get_varlist b 0)- 2)); 
  46.337   " ~~~ 1.W1.1 ~~~";
  46.338  "~~~~~ fun GOTO2, args:"; val (a,b,n,s,M,r_list,steps) =
  46.339  (a, b, n, s, M, [], []);
  46.340 @@ -1413,7 +1413,7 @@
  46.341   " ~~~ 1.W1.1.1 ~~~";
  46.342   (*g_r=*)
  46.343  "~~~~~ fun GCD_MODm, args:"; val  (a,b,n,s,r) = 
  46.344 -((order_multipoly  (evaluate_mv a (s-1) r)),(order_multipoly  (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.345 +((order_multipoly  (evaluate_mv a (s- 1) r)),(order_multipoly  (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.346  s = 0; (*true*)
  46.347  val g_r = uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))));
  46.348   " ~~~ 1.W1.1 ~~~";
  46.349 @@ -1436,15 +1436,15 @@
  46.350   " ~~~ 1.W1.1.W1.1 ~~~";
  46.351   (*g_r=*)
  46.352  "~~~~~ fun GCD_MODm, args:"; val  (a,b,n,s,r) = 
  46.353 -((order_multipoly  (evaluate_mv a (s-1) r)),(order_multipoly  (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.354 +((order_multipoly  (evaluate_mv a (s- 1) r)),(order_multipoly  (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.355  s = 0; (*true*)
  46.356  val g_r = uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))));
  46.357   " ~~~ 1.W1.1.W1 ~~~";
  46.358  val ( a,b,n,s,r,r_list) = (a'',b'',n'',s'',r'',r_list'');
  46.359  greater_var  (deg_multipoly g) (deg_multipoly g_r); (*false*)
  46.360  (deg_multipoly g)= (deg_multipoly g_r); (*true*)
  46.361 -val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s-1);
  46.362 -(nth steps (length steps -1)) = (cero_multipoly s); (*false*)
  46.363 +val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s- 1);
  46.364 +(nth steps (length steps - 1)) = (cero_multipoly s); (*false*)
  46.365   " ~~~ 1.W1.1.W2 ~~~";
  46.366  "~~~~~ fun WHILE, args:"; val (a, b, n, s, M, m, r, r_list, steps ,g, g_n, mult) = 
  46.367  (a, b, n, s, M, m+1, r, r_list, steps ,g_r, g_n,new);
  46.368 @@ -1456,15 +1456,15 @@
  46.369   " ~~~ 1.W1.1.W2.1 ~~~";
  46.370   (*g_r=*)
  46.371  "~~~~~ fun GCD_MODm, args:"; val  (a,b,n,s,r) = 
  46.372 -((order_multipoly  (evaluate_mv a (s-1) r)),(order_multipoly  (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.373 +((order_multipoly  (evaluate_mv a (s- 1) r)),(order_multipoly  (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.374  s = 0; (*true*)
  46.375  val g_r = uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))));
  46.376   " ~~~ 1.W1.1.W2 ~~~";
  46.377  val ( a,b,n,s,r,r_list) = (a'',b'',n'',s'',r'',r_list'');
  46.378  greater_var  (deg_multipoly g) (deg_multipoly g_r); (*false*)
  46.379  (deg_multipoly g)= (deg_multipoly g_r); (*true*)
  46.380 -val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s-1);
  46.381 -(nth steps (length steps -1)) = (cero_multipoly s); (*true*)
  46.382 +val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s- 1);
  46.383 +(nth steps (length steps - 1)) = (cero_multipoly s); (*true*)
  46.384   " ~~~ 1.W1.1.W3 ~~~";
  46.385  "~~~~~ fun WHILE, args:"; val (a, b, n, s, M, m, r, r_list, steps ,g, g_n, mult) = 
  46.386  (a, b, n, s, M, M+1, r, r_list, steps ,g_r, g_n,new);
  46.387 @@ -1477,8 +1477,8 @@
  46.388  (deg_multipoly g)= (deg_multipoly g_r); (*true*)
  46.389  val (g_n,steps,m,new) = (g_n'',steps',m'',new'');
  46.390   " ~~~ 1.W2 ~~~";
  46.391 -val (g_n, new, steps) = newton_mv r_list [g, g_r] steps new g_n (s-1);
  46.392 -(nth steps (length steps -1)) = (cero_multipoly s); (*false*)
  46.393 +val (g_n, new, steps) = newton_mv r_list [g, g_r] steps new g_n (s- 1);
  46.394 +(nth steps (length steps - 1)) = (cero_multipoly s); (*false*)
  46.395  "~~~~~ fun WHILE, args:"; val (a, b, n, s, M, m, r, r_list, steps ,g, g_n, mult) = 
  46.396  (a, b, n, s, M, m+1, r, r_list, steps ,g_r, g_n,new); 
  46.397  m > M; (*false*)
  46.398 @@ -1488,9 +1488,9 @@
  46.399  (* g_2 = GCD_MODm *)
  46.400   " ~~~ 1.W2.1 ~~~";
  46.401  "~~~~~ fun GCD_MODm, args:"; val  (a,b,n,s,r) = 
  46.402 -((order_multipoly  (evaluate_mv a (s-1) r)),(order_multipoly  (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.403 +((order_multipoly  (evaluate_mv a (s- 1) r)),(order_multipoly  (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.404  s = 0; (*false*)
  46.405 -val M = 1 +  Int.min(max_deg_var a (length(get_varlist a 0)-2), max_deg_var b (length(get_varlist b 0)-2)); 
  46.406 +val M = 1 +  Int.min(max_deg_var a (length(get_varlist a 0)- 2), max_deg_var b (length(get_varlist b 0)- 2)); 
  46.407   " ~~~ 1.W2.1 ~~~";
  46.408  "~~~~~ fun GOTO2, args:"; val (a,b,n,s,M,r_list,steps) =
  46.409  (a, b, n, s, M, [], []);
  46.410 @@ -1500,7 +1500,7 @@
  46.411   " ~~~ 1.W2.1.1 ~~~";
  46.412   (*g_r=*)
  46.413  "~~~~~ fun GCD_MODm, args:"; val  (a,b,n,s,r) = 
  46.414 -((order_multipoly  (evaluate_mv a (s-1) r)),(order_multipoly  (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.415 +((order_multipoly  (evaluate_mv a (s- 1) r)),(order_multipoly  (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.416  s = 0; (*true*)
  46.417  val g_r = uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))));
  46.418   " ~~~ 1.W2.1 ~~~";
  46.419 @@ -1522,15 +1522,15 @@
  46.420   " ~~~ 1.W2.1.W1.1 ~~~";
  46.421   (*g_r=*)
  46.422  "~~~~~ fun GCD_MODm, args:"; val  (a,b,n,s,r) = 
  46.423 -((order_multipoly  (evaluate_mv a (s-1) r)),(order_multipoly  (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.424 +((order_multipoly  (evaluate_mv a (s- 1) r)),(order_multipoly  (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.425  s = 0; (*true*)
  46.426  val g_r = uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))));
  46.427   " ~~~ 1.W2.1.W1 ~~~";
  46.428  val ( a,b,n,s,r,r_list) = (a'',b'',n'',s'',r'',r_list'');
  46.429  greater_var  (deg_multipoly g) (deg_multipoly g_r); (*false*)
  46.430  (deg_multipoly g)= (deg_multipoly g_r); (*true*)
  46.431 -val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s-1);
  46.432 -(nth steps (length steps -1)) = (cero_multipoly s); (*false*)
  46.433 +val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s- 1);
  46.434 +(nth steps (length steps - 1)) = (cero_multipoly s); (*false*)
  46.435   " ~~~ 1.W2.1.W2 ~~~";
  46.436  "~~~~~ fun WHILE, args:"; val (a, b, n, s, M, m, r, r_list, steps ,g, g_n, mult) = 
  46.437  (a, b, n, s, M, m+1, r, r_list, steps ,g_r, g_n,new);
  46.438 @@ -1542,15 +1542,15 @@
  46.439   " ~~~ 1.W2.1.W2.1 ~~~";
  46.440   (*g_r=*)
  46.441  "~~~~~ fun GCD_MODm, args:"; val  (a,b,n,s,r) = 
  46.442 -((order_multipoly  (evaluate_mv a (s-1) r)),(order_multipoly  (evaluate_mv b (s-1) r)), (n-1), (s-1), 0);
  46.443 +((order_multipoly  (evaluate_mv a (s- 1) r)),(order_multipoly  (evaluate_mv b (s- 1) r)), (n- 1), (s- 1), 0);
  46.444  s = 0; (*true*)
  46.445  val g_r = uni_to_multi((GCD_MOD (pp(multi_to_uni a)) (pp(multi_to_uni b))) %* (abs (Integer.gcd (cont (multi_to_uni a)) (cont( multi_to_uni b)))));
  46.446   " ~~~ 1.W2.1.W2 ~~~";
  46.447  val ( a,b,n,s,r,r_list) = (a'',b'',n'',s'',r'',r_list'');
  46.448  greater_var  (deg_multipoly g) (deg_multipoly g_r); (*false*)
  46.449  (deg_multipoly g)= (deg_multipoly g_r); (*true*)
  46.450 -val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s-1);
  46.451 -(nth steps (length steps -1)) = (cero_multipoly s); (*true*)
  46.452 +val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s- 1);
  46.453 +(nth steps (length steps - 1)) = (cero_multipoly s); (*true*)
  46.454   " ~~~ 1.W2.1.W3 ~~~";
  46.455  "~~~~~ fun WHILE, args:"; val (a, b, n, s, M, m, r, r_list, steps ,g, g_n, mult) = 
  46.456  (a, b, n, s, M, M+1, r, r_list, steps ,g_r, g_n,new);
  46.457 @@ -1563,7 +1563,7 @@
  46.458  (deg_multipoly g)= (deg_multipoly g_r); (*true*)
  46.459  val (g_n,steps,m,mult) = (g_n'',steps',m'',new'');
  46.460   " ~~~ 1.W2 ~~~";
  46.461 - val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s-1);
  46.462 + val (g_n, new, steps) = newton_mv r_list [g, g_r] steps mult g_n (s- 1);
  46.463  "~~~~~ to  return val:"; val (g) = (g_n);
  46.464  
  46.465  
  46.466 @@ -1573,6 +1573,6 @@
  46.467  " ==========================  END  ========================== ";
  46.468    fun nth _ []      = error "nth _ []" (*Isabelle2002, still saved the hours of update*)
  46.469      | nth 1 (x::_) = x
  46.470 -    | nth n (_::xs) = nth (n-1) xs;
  46.471 +    | nth n (_::xs) = nth (n- 1) xs;
  46.472  (*fun nth xs i = List.nth (xs, i);       recent Isabelle: TODO update all isac code   *)
  46.473  
    47.1 --- a/test/Tools/isac/Knowledge/integrate.sml	Mon Jun 21 22:08:01 2021 +0200
    47.2 +++ b/test/Tools/isac/Knowledge/integrate.sml	Sun Jul 18 18:15:27 2021 +0200
    47.3 @@ -1,5 +1,5 @@
    47.4 -(* tests on integration over the reals
    47.5 -   author: Walther Neuper 2005
    47.6 +(* Title:  test/Tools/isac/Knowledge/integrate.sml
    47.7 +   Author: Walther Neuper 050826
    47.8     (c) due to copyright terms
    47.9  *)
   47.10  "--------------------------------------------------------";
   47.11 @@ -173,7 +173,7 @@
   47.12  "----------- simplify by ruleset reducing make_ratpoly_in";
   47.13  val thy = @{theory "Isac_Knowledge"};
   47.14  "===== test 1";
   47.15 -val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + -1 * q_0 * x \<up> 2 / 2)";
   47.16 +val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)";
   47.17  
   47.18  "----- stepwise from the rulesets in simplify_Integral and below-----";
   47.19  val rls = norm_Rational_noadd_fractions;
   47.20 @@ -187,7 +187,7 @@
   47.21          assume flawed test setup hidden by "handle _ => ..."
   47.22          ERROR ord_make_polynomial_in called with subst = []
   47.23  val SOME (t,[]) = rewrite_set_ thy true rls t;
   47.24 -if UnparseC.term t = "1 / EI * (L * (q_0 * x) / 2 + -1 * (q_0 * x \<up> 2) / 2)" then()
   47.25 +if UnparseC.term t = "1 / EI * (L * (q_0 * x) / 2 + - 1 * (q_0 * x \<up> 2) / 2)" then()
   47.26  else error "integrate.sml simplify by ruleset order_add_mult_in #2";
   47.27    \\--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----//*)
   47.28  
   47.29 @@ -197,7 +197,7 @@
   47.30          assume flawed test setup hidden by "handle _ => ..."
   47.31          ERROR ord_make_polynomial_in called with subst = []
   47.32  val SOME (t,[]) = rewrite_set_ thy true rls t;
   47.33 -if UnparseC.term t = "1 / EI * (L * q_0 * x / 2 + -1 * q_0 * x \<up> 2 / 2)" then ()
   47.34 +if UnparseC.term t = "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" then ()
   47.35  else error "integrate.sml simplify by ruleset discard_parenth.. #3";
   47.36    \\--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----//*)
   47.37  
   47.38 @@ -223,33 +223,33 @@
   47.39  (*show_types := false; --- do we need type-constraint in thms? YES ?!?!?!*)
   47.40  
   47.41  val SOME (t, []) = rewrite_set_inst_ thy true subs rls t;
   47.42 -if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x \<up> 2)" then ()
   47.43 +if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then ()
   47.44  else error "integrate.sml simplify by ruleset separate_bdv.. #4";
   47.45  
   47.46  "===== test 5";
   47.47 -val t = str2t "1/EI * (L * q_0 * x / 2 + -1 * q_0 * x \<up> 2 / 2)";
   47.48 +val t = str2t "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)";
   47.49  val rls = simplify_Integral;
   47.50  val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t;
   47.51 -(* given was:   "1 / EI * (L * q_0 * x / 2 + -1 * q_0 * x \<up> 2 / 2)" *)
   47.52 -if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x \<up> 2)" then ()
   47.53 +(* given was:   "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" *)
   47.54 +if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then ()
   47.55  else error "integrate.sml, simplify_Integral #99";
   47.56  
   47.57  "........... 2nd integral ........................................";
   47.58  "........... 2nd integral ........................................";
   47.59  "........... 2nd integral ........................................";
   47.60  val t = str2t 
   47.61 -"Integral 1 / EI * (L * q_0 / 2 * (x \<up> 2 / 2) + -1 * q_0 / 2 * (x \<up> 3 / 3)) D x";
   47.62 +"Integral 1 / EI * (L * q_0 / 2 * (x \<up> 2 / 2) + - 1 * q_0 / 2 * (x \<up> 3 / 3)) D x";
   47.63  val rls = simplify_Integral;
   47.64  val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t;
   47.65  if UnparseC.term t =
   47.66 -   "Integral 1 / EI * (L * q_0 / 4 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3) D x"
   47.67 +   "Integral 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3) D x"
   47.68  then () else raise error "integrate.sml, simplify_Integral #198";
   47.69  
   47.70  val rls = integration_rules;
   47.71  val SOME (t,[]) = rewrite_set_ thy true rls t;
   47.72  UnparseC.term t;
   47.73  if UnparseC.term t = 
   47.74 -   "1 / EI * (L * q_0 / 4 * (x \<up> 3 / 3) + -1 * q_0 / 6 * (x \<up> 4 / 4))"
   47.75 +   "1 / EI * (L * q_0 / 4 * (x \<up> 3 / 3) + - 1 * q_0 / 6 * (x \<up> 4 / 4))"
   47.76  then () else error "integrate.sml, simplify_Integral #199";
   47.77  
   47.78  
   47.79 @@ -282,9 +282,9 @@
   47.80  
   47.81  val rls = simplify_Integral;
   47.82  (*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
   47.83 -val t = (Thm.term_of o the o (TermC.parse thy)) "ff x = c * x + -1 * q_0 * (x \<up> 2 / 2) + c_2";
   47.84 +val t = (Thm.term_of o the o (TermC.parse thy)) "ff x = c * x + - 1 * q_0 * (x \<up> 2 / 2) + c_2";
   47.85  val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
   47.86 -if UnparseC.term res = "ff x = c_2 + c * x + -1 * q_0 / 2 * x \<up> 2"
   47.87 +if UnparseC.term res = "ff x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2"
   47.88  then () else error "integrate.sml: diff.behav. in simplify_I #1";
   47.89  
   47.90  val rls = integration;
   47.91 @@ -300,31 +300,31 @@
   47.92  else error "integrate.sml: diff.behav. in integration #2";
   47.93  
   47.94  val t = (Thm.term_of o the o (TermC.parse thy))
   47.95 -  "Integral 1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x \<up> 2) D x";
   47.96 +  "Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x";
   47.97  val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
   47.98 -"Integral 1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x \<up> 2) D x";
   47.99 -if UnparseC.term res = "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3)"
  47.100 +"Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x";
  47.101 +if UnparseC.term res = "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)"
  47.102  then () else error "integrate.sml: diff.behav. in integration #3";
  47.103  
  47.104  val t = (Thm.term_of o the o (TermC.parse thy)) ("Integral " ^ UnparseC.term res ^ " D x");
  47.105  val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
  47.106 -if UnparseC.term res = "c_2 + c * x +\n1 / EI * (L * q_0 / 12 * x \<up> 3 + -1 * q_0 / 24 * x \<up> 4)"
  47.107 +if UnparseC.term res = "c_2 + c * x +\n1 / EI * (L * q_0 / 12 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)"
  47.108  then () else error "integrate.sml: diff.behav. in integration #4";
  47.109  
  47.110  "----------- rewrite 3rd integration in 7.27 ------------";
  47.111  "----------- rewrite 3rd integration in 7.27 ------------";
  47.112  "----------- rewrite 3rd integration in 7.27 ------------";
  47.113  val thy = @{theory "Isac_Knowledge"} (*because of Undeclared constant "Biegelinie.EI*);
  47.114 -val t = str2t "Integral 1 / EI * ((L * q_0 * x + -1 * q_0 * x \<up> 2) / 2) D x";
  47.115 +val t = str2t "Integral 1 / EI * ((L * q_0 * x + - 1 * q_0 * x \<up> 2) / 2) D x";
  47.116  val SOME(t,_)= rewrite_set_inst_ thy true subs simplify_Integral t;
  47.117  if UnparseC.term t = 
  47.118 -  "Integral 1 / EI * (L * q_0 / 2 * x + -1 * q_0 / 2 * x \<up> 2) D x"
  47.119 +  "Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x"
  47.120  then () else error "integrate.sml 3rd integration in 7.27, simplify_Integral";
  47.121  
  47.122  val SOME(t,_)= rewrite_set_inst_ thy true subs integration t;
  47.123  UnparseC.term t;
  47.124  if UnparseC.term t = 
  47.125 -  "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + -1 * q_0 / 6 * x \<up> 3)"
  47.126 +  "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)"
  47.127  then () else error "integrate.sml 3rd integration in 7.27, integration";
  47.128  
  47.129  
  47.130 @@ -378,7 +378,7 @@
  47.131  "----------- me method [diff,integration] ---------------";
  47.132  "----------- me method [diff,integration] ---------------";
  47.133  "----------- me method [diff,integration] ---------------";
  47.134 -(*exp_CalcInt_No-1.xml*)
  47.135 +(*exp_CalcInt_No- 1.xml*)
  47.136  val p = e_pos'; val c = []; 
  47.137  "----- step 0: returns nxt = Model_Problem ---";
  47.138  val (p,_,f,nxt,_,pt) = 
  47.139 @@ -428,7 +428,7 @@
  47.140  "----------- me method [diff,integration,named] ---------";
  47.141  "----------- me method [diff,integration,named] ---------";
  47.142  "----------- me method [diff,integration,named] ---------";
  47.143 -(*exp_CalcInt_No-2.xml*)
  47.144 +(*exp_CalcInt_No- 2.xml*)
  47.145  val fmz = ["functionTerm (x \<up> 2 + (1::real))", 
  47.146  	   "integrateBy x", "antiDerivativeName F"];
  47.147  val (dI',pI',mI') =
  47.148 @@ -473,7 +473,7 @@
  47.149  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  47.150  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
  47.151  
  47.152 -if f2str f = "Q x = c + -1 * q_0 * x" then() 
  47.153 +if f2str f = "Q x = c + - 1 * q_0 * x" then() 
  47.154  else error "integrate.sml: method [diff,integration,named] .Q";
  47.155  
  47.156  
    48.1 --- a/test/Tools/isac/Knowledge/inverse_z_transform.sml	Mon Jun 21 22:08:01 2021 +0200
    48.2 +++ b/test/Tools/isac/Knowledge/inverse_z_transform.sml	Sun Jul 18 18:15:27 2021 +0200
    48.3 @@ -22,7 +22,7 @@
    48.4  "----------- test [SignalProcessing,Z_Transform,Inverse_sub] me = ";
    48.5  "----------- test [SignalProcessing,Z_Transform,Inverse_sub] me = ";
    48.6  (* the ONLY Test_Isac, which uses Rewrite !!! *)
    48.7 -val fmz = ["filterExpression (X z = 3 / (z - 1/4 + -1/8 * (1/(z::real))))",
    48.8 +val fmz = ["filterExpression (X z = 3 / (z - 1/4 + - 1/8 * (1/(z::real))))",
    48.9    "functionName X_z", "stepResponse (x[n::real]::bool)"];
   48.10  val (dI, pI, mI) = ("Isac_Knowledge", ["Inverse", "Z_Transform", "SignalProcessing"], 
   48.11     ["SignalProcessing", "Z_Transform", "Inverse_sub"]);
   48.12 @@ -46,7 +46,7 @@
   48.13  (*[2], Pbl*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Apply_Method ["simplification", "of_rationals", "to_partial_fraction"]*)
   48.14  
   48.15  (*[2,1], Frm*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt;
   48.16 -if p = ([2, 1], Frm) andalso f2str fb = "3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))"
   48.17 +if p = ([2, 1], Frm) andalso f2str fb = "3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z)))"
   48.18  then () else error "Z_Transform,inverse_sub] me 1"; (*Rewrite_Set "norm_Rational"*)
   48.19  
   48.20  (*[2,1], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Subproblem ("Isac_Knowledge", ["abcFormula", "degree_2", "po...a*)
   48.21 @@ -59,21 +59,21 @@
   48.22  (*[2,2], Pbl*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.23  (*[2,2], Met*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Apply_Method ["PolyEq", "solve_d2_polyeq_abc_equation"*)
   48.24  (*[2,2,1], Frm*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.25 -if p = ([2, 2, 1], Frm) andalso f2str fb = "-1 + -2 * z + 8 * z \<up> 2 = 0"
   48.26 +if p = ([2, 2, 1], Frm) andalso f2str fb = "- 1 + - 2 * z + 8 * z \<up> 2 = 0"
   48.27  then () else error "Z_Transform,inverse_sub] me 2";
   48.28  
   48.29  (*[2,2,1], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.30  (*[2,2,2], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.31  (*[2,2,3], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.32  (*[2,2,4], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Check_Postcond ["abcFormula", "degree_2", "polynomial", "univariate", "equation"]*)
   48.33 -(*[2,2], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Take "3 / ((z - 1 / 2) * (z - -1 / 4))"*)
   48.34 +(*[2,2], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Take "3 / ((z - 1 / 2) * (z - - 1 / 4))"*)
   48.35  (*[2,3], Frm*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Rewrite_Set "ansatz_rls"*)
   48.36 -(*[2,3], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Take "3 / ((z - 1 / 2) * (z - -1 / 4)) = AA / (z - 1 / 2) + BB / (z - -1 / 4)*)
   48.37 +(*[2,3], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Take "3 / ((z - 1 / 2) * (z - - 1 / 4)) = AA / (z - 1 / 2) + BB / (z - - 1 / 4)*)
   48.38  (*[2,4], Frm*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Rewrite_Set "equival_trans"*)
   48.39 -(*[2,4], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Take "3 = A * (z - -1 / 4) + B * (z - 1 / 2)"*)
   48.40 +(*[2,4], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Take "3 = A * (z - - 1 / 4) + B * (z - 1 / 2)"*)
   48.41  (*[2,5], Frm*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*"Substitute ["z = 1 / 2"]*)
   48.42  (*[2,5], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt;
   48.43 -if p = ([2, 5], Res) andalso f2str fb = "3 = AA * (1 / 2 - -1 / 4) + BB * (1 / 2 - 1 / 2)"
   48.44 +if p = ([2, 5], Res) andalso f2str fb = "3 = AA * (1 / 2 - - 1 / 4) + BB * (1 / 2 - 1 / 2)"
   48.45  then () else error "Z_Transform,inverse_sub] me 3";   (*Rewrite_Set "norm_Rational"*)
   48.46  
   48.47  (*[2, 6], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Subproblem (Isac, ["normalise", "polynomial", "univariate", "equation"]*)
   48.48 @@ -113,7 +113,7 @@
   48.49  (*[2,7], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.50  (*[2,8], Frm*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.51  (*[2,8], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.52 -if p = ([2, 8], Res) andalso f2str fb = "3 = AA * (-1 / 4 - -1 / 4) + BB * (-1 / 4 - 1 / 2)"
   48.53 +if p = ([2, 8], Res) andalso f2str fb = "3 = AA * (- 1 / 4 - - 1 / 4) + BB * (- 1 / 4 - 1 / 2)"
   48.54  then () else error "Z_Transform,inverse_sub] me 7";
   48.55  
   48.56  (*[2,9], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Subproblem*)
   48.57 @@ -158,13 +158,13 @@
   48.58  (*[2,11], Frm*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (**)
   48.59  (*[2,11], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt; (*Check_Postcond ["partial_fraction", "rational", "simplification"]*)
   48.60  (*[2], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt;
   48.61 -f2str fb = "X_z = 4 * (z / (z - 1 / 2)) + -4 * (z / (z - -1 / 4))"; (*Take "?X' z = 4 / (z - 1 / 2) + -4 / (z - -1 / 4)"*)
   48.62 +f2str fb = "X_z = 4 * (z / (z - 1 / 2)) + -4 * (z / (z - - 1 / 4))"; (*Take "?X' z = 4 / (z - 1 / 2) + -4 / (z - - 1 / 4)"*)
   48.63  
   48.64  (*[3], Frm*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt;
   48.65 -f2str fb = "?X' z = 4 / (z - 1 / 2) + -4 / (z - -1 / 4)"; (*Rewrite ("ruleYZ", "?a / ?b + ?c / ?d = ?a * (?z / ?b) + ?c * (?z / ?d)")*)
   48.66 +f2str fb = "?X' z = 4 / (z - 1 / 2) + -4 / (z - - 1 / 4)"; (*Rewrite ("ruleYZ", "?a / ?b + ?c / ?d = ?a * (?z / ?b) + ?c * (?z / ?d)")*)
   48.67  
   48.68  (*[3], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt;
   48.69 -f2str fb = "?X' z = 4 * (z / (z - 1 / 2)) + -4 * (z / (z - -1 / 4))";(*Take "X_z = 4 * (?z / (z - 1 / 2)) + -4 * (?z / (z - -1 / 4))"*)
   48.70 +f2str fb = "?X' z = 4 * (z / (z - 1 / 2)) + -4 * (z / (z - - 1 / 4))";(*Take "X_z = 4 * (?z / (z - 1 / 2)) + -4 * (?z / (z - - 1 / 4))"*)
   48.71  
   48.72  (*[4], Frm)*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt;
   48.73  (*[4], Res*)val (p,_,fb,nxt,_,pt) = me nxt p [] pt;
   48.74 @@ -172,7 +172,7 @@
   48.75  
   48.76  case nxt of (_, End_Proof') =>
   48.77    if p = ([], Res) andalso
   48.78 -    f2str fb = "X_z = 4 * (1 / 2) \<up> ?n * ?u [?n] + -4 * (-1 / 4) \<up> ?n * ?u [?n]"
   48.79 +    f2str fb = "X_z = 4 * (1 / 2) \<up> ?n * ?u [?n] + -4 * (- 1 / 4) \<up> ?n * ?u [?n]"
   48.80    then () else error "[SignalProcessing,Z_Transform,Inverse_sub] changed 1"
   48.81  | _ => error "[SignalProcessing,Z_Transform,Inverse_sub] changed 2";
   48.82  
   48.83 @@ -181,7 +181,7 @@
   48.84  "----------- test [SignalProcessing,Z_Transform,Inverse_sub] auto-";
   48.85  "----------- test [SignalProcessing,Z_Transform,Inverse_sub] auto-";
   48.86  reset_states ();
   48.87 -val fmz = ["filterExpression (X z = 3 / (z - 1/4 + -1/8 * (1/(z::real))))",
   48.88 +val fmz = ["filterExpression (X z = 3 / (z - 1/4 + - 1/8 * (1/(z::real))))",
   48.89    "functionName X_z", "stepResponse (x[n::real]::bool)"];
   48.90  val (dI, pI, mI) = ("Isac_Knowledge", ["Inverse", "Z_Transform", "SignalProcessing"], 
   48.91     ["SignalProcessing", "Z_Transform", "Inverse_sub"]);
   48.92 @@ -192,6 +192,6 @@
   48.93  
   48.94  val ((pt,_),_) = get_calc 1; val p = get_pos 1 1;
   48.95  val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
   48.96 -if UnparseC.term f = "X_z = 4 * (1 / 2) \<up> ?n * ?u [?n] + -4 * (-1 / 4) \<up> ?n * ?u [?n]"
   48.97 +if UnparseC.term f = "X_z = 4 * (1 / 2) \<up> ?n * ?u [?n] + -4 * (- 1 / 4) \<up> ?n * ?u [?n]"
   48.98    andalso p = ([], Res) then ()
   48.99    else error "inv Z, exp 1 autoCalculate changed";
    49.1 --- a/test/Tools/isac/Knowledge/partial_fractions.sml	Mon Jun 21 22:08:01 2021 +0200
    49.2 +++ b/test/Tools/isac/Knowledge/partial_fractions.sml	Sun Jul 18 18:15:27 2021 +0200
    49.3 @@ -26,7 +26,7 @@
    49.4  "----------- why helpless here ? ------------------------";
    49.5  "----------- why helpless here ? ------------------------";
    49.6  "----------- why helpless here ? ------------------------";
    49.7 -val fmz = ["filterExpression (X z = 3 / (z - 1/4 + -1/8 * (1/(z::real))))", 
    49.8 +val fmz = ["filterExpression (X z = 3 / (z - 1/4 + - 1/8 * (1/(z::real))))", 
    49.9    "functionName X_z", "stepResponse (x[n::real]::bool)"];
   49.10  val (dI,pI,mI) = ("Isac_Knowledge", ["Inverse", "Z_Transform", "SignalProcessing"], 
   49.11    ["SignalProcessing", "Z_Transform", "Inverse"]);
   49.12 @@ -37,8 +37,8 @@
   49.13  val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Specify_Problem";
   49.14  val (p,_,f,nxt,_,pt) = me nxt p [] pt; "Specify_Method";
   49.15  val (p,_,f,nxt,_,pt) = me nxt p [] pt; "nxt = Apply_Method";
   49.16 -val (p,_,f,nxt,_,pt) = me nxt p [] pt; "nxt = Rewrite (ruleZY, Inverse_Z_Transform.ruleZY) --> X z = 3 / (z - 1 / 4 + -1 / 8 * (1 / z))";
   49.17 -val (p''',_,f,nxt''',_,pt''') = me nxt p [] pt; "nxt = Rewrite_Set norm_Rational --> X' z = 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)))";
   49.18 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; "nxt = Rewrite (ruleZY, Inverse_Z_Transform.ruleZY) --> X z = 3 / (z - 1 / 4 + - 1 / 8 * (1 / z))";
   49.19 +val (p''',_,f,nxt''',_,pt''') = me nxt p [] pt; "nxt = Rewrite_Set norm_Rational --> X' z = 3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z)))";
   49.20  "~~~~~ fun me, args:"; val (tac, (p:pos'), _, (pt:ctree)) = (nxt, p, [], pt);
   49.21  val ("ok", (_, _, ptp)) = Step.by_tactic tac (pt,p)
   49.22  val (pt, p) = ptp;
   49.23 @@ -78,10 +78,10 @@
   49.24  "----------- fun factors_from_solution ------------------";
   49.25  "----------- fun factors_from_solution ------------------";
   49.26  val ctxt = Proof_Context.init_global @{theory Isac_Knowledge};
   49.27 -val SOME t = parseNEW ctxt "factors_from_solution [(z::real) = 1 / 2, z = -1 / 4]";
   49.28 +val SOME t = parseNEW ctxt "factors_from_solution [(z::real) = 1 / 2, z = - 1 / 4]";
   49.29  val SOME (_, t') = eval_factors_from_solution "" 0 t thy;
   49.30  if UnparseC.term t' =
   49.31 - "factors_from_solution [z = 1 / 2, z = -1 / 4] = (z - 1 / 2) * (z - -1 / 4)"
   49.32 + "factors_from_solution [z = 1 / 2, z = - 1 / 4] = (z - 1 / 2) * (z - - 1 / 4)"
   49.33  then () else error "factors_from_solution broken";
   49.34  
   49.35  "----------- Logic.unvarify_global ----------------------";
   49.36 @@ -90,14 +90,14 @@
   49.37  val A_var = parseNEW ctxt "A::real" |> the |> Logic.varify_global
   49.38  val B_var = parseNEW ctxt "B::real" |> the |> Logic.varify_global
   49.39  
   49.40 -val denom1 = parseNEW ctxt "(z + -1 * (1 / 2))::real" |> the;
   49.41 -val denom2 = parseNEW ctxt "(z + -1 * (-1 / 4))::real" |> the;
   49.42 +val denom1 = parseNEW ctxt "(z + - 1 * (1 / 2))::real" |> the;
   49.43 +val denom2 = parseNEW ctxt "(z + - 1 * (- 1 / 4))::real" |> the;
   49.44  
   49.45  val test = HOLogic.mk_binop \<^const_name>\<open>plus\<close>
   49.46    (HOLogic.mk_binop \<^const_name>\<open>divide\<close> (A_var, denom1),
   49.47     HOLogic.mk_binop \<^const_name>\<open>divide\<close> (B_var, denom2));
   49.48  
   49.49 -if UnparseC.term test = "?A / (z + -1 * (1 / 2)) + ?B / (z + -1 * (-1 / 4))" then ()
   49.50 +if UnparseC.term test = "?A / (z + - 1 * (1 / 2)) + ?B / (z + - 1 * (- 1 / 4))" then ()
   49.51    else error "HOLogic.mk_binop broken ?";
   49.52  
   49.53  (* Logic.unvarify_global test
   49.54 @@ -108,7 +108,7 @@
   49.55  "----------- = me for met_partial_fraction --------------";
   49.56  "----------- = me for met_partial_fraction --------------";
   49.57  val fmz =
   49.58 -  ["functionTerm (3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))))",
   49.59 +  ["functionTerm (3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z))))",
   49.60      "solveFor z", "decomposedFunction p_p"];
   49.61  val (dI',pI',mI') =
   49.62    ("Partial_Fractions", 
   49.63 @@ -116,7 +116,7 @@
   49.64      ["simplification", "of_rationals", "to_partial_fraction"]);
   49.65  (*[ ], Pbl*)val (p,_,f,nxt,_,pt) =
   49.66                CalcTreeTEST [(fmz, (dI',pI',mI'))]; (*nxt = Model_Problem*)
   49.67 -(*[ ], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "functionTerm (3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))))")*)
   49.68 +(*[ ], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "functionTerm (3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z))))")*)
   49.69  (*[ ], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "solveFor z")*)
   49.70  (*[ ], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Find "decomposedFunction p_p")*)
   49.71  (*[ ], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Theory "Partial_Fractions")*)
   49.72 @@ -128,7 +128,7 @@
   49.73  (*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Subproblem ("PolyEq", ["abcFormula", "degree_2", "polynomial", "univariate", "equation"]))*)
   49.74              (*10*)
   49.75  (*[2], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Model_Problem)*)
   49.76 -(*[2], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "equality (-1 + -2 * z + 8 * z \<up> 2 = 0)")*)
   49.77 +(*[2], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "equality (- 1 + - 2 * z + 8 * z \<up> 2 = 0)")*)
   49.78  (*[2], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Given "solveFor z")*)
   49.79  (*[2], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Add_Find "solutions z_i")*)
   49.80  (*[2], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Specify_Theory "PolyEq")*)
   49.81 @@ -142,12 +142,12 @@
   49.82  (*[2, 2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Or_to_List)*)
   49.83  (*[2, 3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_elementwise "Assumptions")*)
   49.84  (*[2, 4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_Postcond ["abcFormula", "degree_2", "polynomial", "univariate", "equation"])*)
   49.85 -(*[2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Take "3 / ((z - 1 / 2) * (z - -1 / 4))")*)
   49.86 +(*[2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Take "3 / ((z - 1 / 2) * (z - - 1 / 4))")*)
   49.87  (*[3], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "ansatz_rls")*)
   49.88              (*25*)
   49.89 -(*[3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Take "3 / ((z - 1 / 2) * (z - -1 / 4)) = ?A / (z - 1 / 2) + ?B / (z - -1 / 4)")*)
   49.90 +(*[3], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Take "3 / ((z - 1 / 2) * (z - - 1 / 4)) = ?A / (z - 1 / 2) + ?B / (z - - 1 / 4)")*)
   49.91  (*[4], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Rewrite_Set "equival_trans")*)
   49.92 -(*[4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Take "3 = AA * (z - -1 / 4) + BB * (z - 1 / 2)"*)
   49.93 +(*[4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Take "3 = AA * (z - - 1 / 4) + BB * (z - 1 / 2)"*)
   49.94  (*[5], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Substitute ["z = 1 / 2"])*)
   49.95  (*[5], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*nxt = Rewrite_Set "norm_Rational"*)
   49.96  (*[6], Res*)val (p''',_,f,nxt''',_,pt''') = me nxt p [] pt;(*nxt = Subproblem ("Isac_Knowledge", ["normalise", "polynomial", "univariate", "equation"]*)
   49.97 @@ -223,14 +223,14 @@
   49.98  (*[10, 4, 5], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_Postcond ["degree_1", "polynomial", "univariate", "equation"*)
   49.99  (*[10, 4], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_Postcond ["normalise", "polynomial", "univariate", "equation"]*)
  49.100  
  49.101 -(*[10], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Take "AA / (z - 1 / 2) + BB / (z - -1 / 4)"*)
  49.102 +(*[10], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Take "AA / (z - 1 / 2) + BB / (z - - 1 / 4)"*)
  49.103      (*90*)
  49.104  (*[11], Frm*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Substitute ["AA = 4", "BB = -4"]*)
  49.105  (*[11], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = Check_Postcond ["partial_fraction", "rational", "simplification"]*)
  49.106  (*[], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt = End_Proof'*) 
  49.107  
  49.108  case nxt of
  49.109 -  (_, End_Proof') => if f2str f = "4 / (z - 1 / 2) + -4 / (z - -1 / 4)" then () 
  49.110 +  (_, End_Proof') => if f2str f = "4 / (z - 1 / 2) + -4 / (z - - 1 / 4)" then () 
  49.111                       else error "= me .. met_partial_fraction f changed"
  49.112  | _ => error "= me .. met_partial_fraction nxt changed";
  49.113  
  49.114 @@ -241,7 +241,7 @@
  49.115  "----------- autoCalculate for met_partial_fraction -----";
  49.116  reset_states ();
  49.117    val fmz =                                             
  49.118 -    ["functionTerm (3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))))", 
  49.119 +    ["functionTerm (3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z))))", 
  49.120        "solveFor z", "decomposedFunction p_p"];
  49.121    val (dI', pI', mI') =
  49.122      ("Partial_Fractions", 
  49.123 @@ -257,11 +257,11 @@
  49.124    else error "autoCalculate for met_partial_fraction changed: final pos'";
  49.125  
  49.126  val (Form f, tac, asms) = ME_Misc.pt_extract (pt, p);
  49.127 -if UnparseC.term f = "4 / (z - 1 / 2) + -4 / (z - -1 / 4)" andalso
  49.128 +if UnparseC.term f = "4 / (z - 1 / 2) + -4 / (z - - 1 / 4)" andalso
  49.129    UnparseC.terms_short asms =
  49.130      "[BB = -4,BB is_polyexp,AA is_polyexp,AA = 4," ^
  49.131 -    "lhs (-1 + -2 * z + 8 * z \<up> 2 = 0) has_degree_in z = 2," ^
  49.132 -    "lhs (-1 + -2 * z + 8 * z \<up> 2 = 0) is_poly_in z,z = 1 / 2,z = -1 / 4,z is_polyexp]"
  49.133 +    "lhs (- 1 + - 2 * z + 8 * z \<up> 2 = 0) has_degree_in z = 2," ^
  49.134 +    "lhs (- 1 + - 2 * z + 8 * z \<up> 2 = 0) is_poly_in z,z = 1 / 2,z = - 1 / 4,z is_polyexp]"
  49.135  then case tac of NONE => ()
  49.136    | _ => error "me for met_partial_fraction changed: final result 1"
  49.137  else error "me for met_partial_fraction changed: final result 2"
  49.138 @@ -272,16 +272,16 @@
  49.139  "----------- progr.vers.2: check erls for multiply_ansatz";
  49.140  "----------- progr.vers.2: check erls for multiply_ansatz";
  49.141  (*test for outcommented 3 lines in script: is norm_Rational strong enough?*)
  49.142 -val t = TermC.str2term "(3 / ((-1 + -2 * z + 8 * z \<up> 2) *3/24)) = (3 / ((z - 1 / 2) * (z - -1 / 4)))";
  49.143 +val t = TermC.str2term "(3 / ((- 1 + - 2 * z + 8 * z \<up> 2) *3/24)) = (3 / ((z - 1 / 2) * (z - - 1 / 4)))";
  49.144  val SOME (t', _) = rewrite_set_ @{theory Isac_Knowledge} true ansatz_rls t;
  49.145 -UnparseC.term t' = "3 / ((-1 + -2 * z + 8 * z \<up> 2) * 3 / 24) =\n?A / (z - 1 / 2) + ?B / (z - -1 / 4)";
  49.146 +UnparseC.term t' = "3 / ((- 1 + - 2 * z + 8 * z \<up> 2) * 3 / 24) =\n?A / (z - 1 / 2) + ?B / (z - - 1 / 4)";
  49.147  
  49.148  val SOME (t'', _) = rewrite_set_ @{theory Isac_Knowledge} true multiply_ansatz t'; (*true*)
  49.149 -UnparseC.term t'' = "(z - 1 / 2) * (z - -1 / 4) * 3 / ((-1 + -2 * z + 8 * z \<up> 2) * 3 / 24) =\n" ^
  49.150 -  "?A * (z - -1 / 4) + ?B * (z - 1 / 2)"; (*true*)
  49.151 +UnparseC.term t'' = "(z - 1 / 2) * (z - - 1 / 4) * 3 / ((- 1 + - 2 * z + 8 * z \<up> 2) * 3 / 24) =\n" ^
  49.152 +  "?A * (z - - 1 / 4) + ?B * (z - 1 / 2)"; (*true*)
  49.153  
  49.154  val SOME (t''', _) = rewrite_set_ @{theory Isac_Knowledge} true norm_Rational t''; 
  49.155 -if UnparseC.term t''' = "3 = (AA + -2 * BB + 4 * z * AA + 4 * z * BB) / 4" then () 
  49.156 +if UnparseC.term t''' = "3 = (AA + - 2 * BB + 4 * z * AA + 4 * z * BB) / 4" then () 
  49.157  else error "ansatz_rls - multiply_ansatz - norm_Rational broken"; 
  49.158  
  49.159  (*test for outcommented 3 lines in script: empower erls for x = a*b ==> ...*)
  49.160 @@ -304,53 +304,53 @@
  49.161  "----------- progr.vers.2: improve program --------------";
  49.162  "----------- progr.vers.2: improve program --------------";
  49.163  (*WN120318 stopped due to much effort with the test above*)
  49.164 -     "Program PartFracScript (f_f::real) (zzz::real) =                    " ^(*f_f: 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z)), zzz: z*)
  49.165 +     "Program PartFracScript (f_f::real) (zzz::real) =                    " ^(*f_f: 3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z)), zzz: z*)
  49.166       " (let f_f = Take f_f;                                       " ^
  49.167       "   (num_orig::real) = get_numerator f_f;                    " ^(*num_orig: 3*)
  49.168 -     "   f_f = (Rewrite_Set norm_Rational False) f_f;             " ^(*f_f: 24 / (-1 + -2 * z + 8 * z \<up> 2)*)
  49.169 +     "   f_f = (Rewrite_Set norm_Rational False) f_f;             " ^(*f_f: 24 / (- 1 + - 2 * z + 8 * z \<up> 2)*)
  49.170       "   (numer::real) = get_numerator f_f;                       " ^(*numer: 24*)
  49.171 -     "   (denom::real) = get_denominator f_f;                     " ^(*denom: -1 + -2 * z + 8 * z \<up> 2*)
  49.172 -     "   (equ::bool) = (denom = (0::real));                       " ^(*equ: -1 + -2 * z + 8 * z \<up> 2 = 0*)
  49.173 +     "   (denom::real) = get_denominator f_f;                     " ^(*denom: - 1 + - 2 * z + 8 * z \<up> 2*)
  49.174 +     "   (equ::bool) = (denom = (0::real));                       " ^(*equ: - 1 + - 2 * z + 8 * z \<up> 2 = 0*)
  49.175       "   (L_L::bool list) = (SubProblem (PolyEqX,                 " ^
  49.176       "     [abcFormula, degree_2, polynomial, univariate, equation], " ^
  49.177 -     "     [no_met]) [BOOL equ, REAL zzz]);                       " ^(*L_L: [z = 1 / 2, z = -1 / 4]*)
  49.178 -     "   (facs::real) = factors_from_solution L_L;                " ^(*facs: (z - 1 / 2) * (z - -1 / 4)*)
  49.179 -     "   (eql::real) = Take (num_orig / facs);                    " ^(*eql: 3 / ((z - 1 / 2) * (z - -1 / 4)) *) 
  49.180 -     "   (eqr::real) = (Try (Rewrite_Set ansatz_rls False)) eql;  " ^(*eqr: ?A / (z - 1 / 2) + ?B / (z - -1 / 4)*)
  49.181 -     "   (eq::bool) = Take (eql = eqr);                           " ^(*eq:  3 / ((z - 1 / 2) * (z - -1 / 4)) = ?A / (z - 1 / 2) + ?B / (z - -1 / 4)*)
  49.182 +     "     [no_met]) [BOOL equ, REAL zzz]);                       " ^(*L_L: [z = 1 / 2, z = - 1 / 4]*)
  49.183 +     "   (facs::real) = factors_from_solution L_L;                " ^(*facs: (z - 1 / 2) * (z - - 1 / 4)*)
  49.184 +     "   (eql::real) = Take (num_orig / facs);                    " ^(*eql: 3 / ((z - 1 / 2) * (z - - 1 / 4)) *) 
  49.185 +     "   (eqr::real) = (Try (Rewrite_Set ansatz_rls False)) eql;  " ^(*eqr: ?A / (z - 1 / 2) + ?B / (z - - 1 / 4)*)
  49.186 +     "   (eq::bool) = Take (eql = eqr);                           " ^(*eq:  3 / ((z - 1 / 2) * (z - - 1 / 4)) = ?A / (z - 1 / 2) + ?B / (z - - 1 / 4)*)
  49.187  (*this has been tested below by rewrite_set_
  49.188       "   (eeeee::bool) = Take ((num_orig / denom * denom / numer) = (num_orig / facs));" ^(**)
  49.189       "   (eeeee::bool) = (Rewrite_Set ansatz_rls False) eeeee;" ^(**)
  49.190 -     "   eq = (Try (Rewrite_Set multiply_ansatz False)) eeeee;         " ^(*eq: 3 = ?A * (z - -1 / 4) + ?B * (z - 1 / 2)*) 
  49.191 +     "   eq = (Try (Rewrite_Set multiply_ansatz False)) eeeee;         " ^(*eq: 3 = ?A * (z - - 1 / 4) + ?B * (z - 1 / 2)*) 
  49.192  NEXT try to outcomment the very next line..*)
  49.193 -     "   eq = (Try (Rewrite_Set equival_trans False)) eeeee;         " ^(*eq: 3 = ?A * (z - -1 / 4) + ?B * (z - 1 / 2)*) 
  49.194 -     "   eq = drop_questionmarks eq;                              " ^(*eq: 3 = A * (z - -1 / 4) + B * (z - 1 / 2)*)
  49.195 +     "   eq = (Try (Rewrite_Set equival_trans False)) eeeee;         " ^(*eq: 3 = ?A * (z - - 1 / 4) + ?B * (z - 1 / 2)*) 
  49.196 +     "   eq = drop_questionmarks eq;                              " ^(*eq: 3 = A * (z - - 1 / 4) + B * (z - 1 / 2)*)
  49.197       "   (z1::real) = (rhs (NTH 1 L_L));                          " ^(*z1: 1 / 2*)
  49.198 -     "   (z2::real) = (rhs (NTH 2 L_L));                          " ^(*z2: -1 / 4*)
  49.199 -     "   (eq_a::bool) = Take eq;                                  " ^(*eq_a: 3 = A * (z - -1 / 4) + B * (z - 1 / 2)*)
  49.200 -     "   eq_a = (Substitute [zzz = z1]) eq;                       " ^(*eq_a: 3 = A * (1 / 2 - -1 / 4) + B * (1 / 2 - 1 / 2)*)
  49.201 +     "   (z2::real) = (rhs (NTH 2 L_L));                          " ^(*z2: - 1 / 4*)
  49.202 +     "   (eq_a::bool) = Take eq;                                  " ^(*eq_a: 3 = A * (z - - 1 / 4) + B * (z - 1 / 2)*)
  49.203 +     "   eq_a = (Substitute [zzz = z1]) eq;                       " ^(*eq_a: 3 = A * (1 / 2 - - 1 / 4) + B * (1 / 2 - 1 / 2)*)
  49.204       "   eq_a = (Rewrite_Set norm_Rational False) eq_a;           " ^(*eq_a: 3 = 3 * A / 4*)
  49.205       "   (sol_a::bool list) =                                     " ^
  49.206       "     (SubProblem (IsacX, [univariate,equation], [no_met])   " ^
  49.207       "     [BOOL eq_a, REAL (A::real)]);                          " ^(*sol_a: [A = 4]*)
  49.208       "   (a::real) = (rhs (NTH 1 sol_a));                         " ^(*a: 4*)
  49.209 -     "   (eq_b::bool) = Take eq;                                  " ^(*eq_b: 3 = A * (z - -1 / 4) + B * (z - 1 / 2)*)
  49.210 +     "   (eq_b::bool) = Take eq;                                  " ^(*eq_b: 3 = A * (z - - 1 / 4) + B * (z - 1 / 2)*)
  49.211       "   eq_b = (Substitute [zzz = z2]) eq_b;                     " ^(*eq_b: *)
  49.212       "   eq_b = (Rewrite_Set norm_Rational False) eq_b;           " ^(*eq_b: *)
  49.213       "   (sol_b::bool list) =                                     " ^
  49.214       "     (SubProblem (IsacX, [univariate,equation], [no_met])   " ^
  49.215       "     [BOOL eq_b, REAL (B::real)]);                          " ^(*sol_b: [B = -4]*)
  49.216       "   (b::real) = (rhs (NTH 1 sol_b));                         " ^(*b: -4*)
  49.217 -     "   eqr = drop_questionmarks eqr;                            " ^(*eqr: A / (z - 1 / 2) + B / (z - -1 / 4)*)
  49.218 -     "   (pbz::real) = Take eqr;                                  " ^(*pbz: A / (z - 1 / 2) + B / (z - -1 / 4)*)
  49.219 -     "   pbz = ((Substitute [A = a, B = b]) pbz)                  " ^(*pbz: 4 / (z - 1 / 2) + -4 / (z - -1 / 4)*)
  49.220 +     "   eqr = drop_questionmarks eqr;                            " ^(*eqr: A / (z - 1 / 2) + B / (z - - 1 / 4)*)
  49.221 +     "   (pbz::real) = Take eqr;                                  " ^(*pbz: A / (z - 1 / 2) + B / (z - - 1 / 4)*)
  49.222 +     "   pbz = ((Substitute [A = a, B = b]) pbz)                  " ^(*pbz: 4 / (z - 1 / 2) + -4 / (z - - 1 / 4)*)
  49.223       " in pbz)";
  49.224  
  49.225  "----------- isolate SubProblem [simplification, of_rationals, to_partial_fraction] me ---------";
  49.226  "----------- isolate SubProblem [simplification, of_rationals, to_partial_fraction] me ---------";
  49.227  "----------- isolate SubProblem [simplification, of_rationals, to_partial_fraction] me ---------";
  49.228  val fmz_from_Subproblem_of_Inverse_sub = (*see --- test [SignalProcessing,Z_Transform,Inverse_s.."*)
  49.229 -     (["functionTerm (3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))))", "solveFor z",
  49.230 +     (["functionTerm (3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z))))", "solveFor z",
  49.231         "decomposedFunction p_p'''"],
  49.232        ("Isac_Knowledge", ["partial_fraction", "rational", "simplification"],
  49.233         ["simplification", "of_rationals", "to_partial_fraction"]))
  49.234 @@ -402,7 +402,7 @@
  49.235  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  49.236  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  49.237  
  49.238 -if fst nxt = "End_Proof'" andalso f2str f = "4 / (z - 1 / 2) + -4 / (z - -1 / 4)" then ()
  49.239 +if fst nxt = "End_Proof'" andalso f2str f = "4 / (z - 1 / 2) + -4 / (z - - 1 / 4)" then ()
  49.240  else error "--- isolate SubProblem [simplification, of_rationals, to_partial_fraction] me ---";
  49.241  
  49.242  
  49.243 @@ -414,7 +414,7 @@
  49.244    see --- test [SignalProcessing,Z_Transform,Inverse_sub] me = ";*)
  49.245  
  49.246  val fmz_from_Subproblem_of_Inverse_sub = (*see --- test [SignalProcessing,Z_Transform,Inverse_s.."*)
  49.247 -     (["functionTerm (3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))))", "solveFor z",
  49.248 +     (["functionTerm (3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z))))", "solveFor z",
  49.249         "decomposedFunction p_p'''"],
  49.250        ("Isac_Knowledge", ["partial_fraction", "rational", "simplification"],
  49.251         ["simplification", "of_rationals", "to_partial_fraction"]));
  49.252 @@ -430,8 +430,8 @@
  49.253  
  49.254  @@@ program ["simplification", "of_rationals", "to_partial_fraction"]
  49.255  @@@ istate ["
  49.256 -(f_f, 3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))))", "
  49.257 +(f_f, 3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z))))", "
  49.258  (zzz, z)"] 
  49.259 -@@@ next   leaf 'Take f_f' ---> Program.Tac 'Take (3 / (z * (z - 1 / 4 + -1 / 8 * (1 / z))))'
  49.260 +@@@ next   leaf 'Take f_f' ---> Program.Tac 'Take (3 / (z * (z - 1 / 4 + - 1 / 8 * (1 / z))))'
  49.261  *)
  49.262  
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/test/Tools/isac/Knowledge/poly-1.sml	Sun Jul 18 18:15:27 2021 +0200
    50.3 @@ -0,0 +1,793 @@
    50.4 +(* Title: test/Tools/isac/Knowledge/poly-1.sml
    50.5 +   Author: Walther Neuper
    50.6 +   Use is subject to license terms.
    50.7 +
    50.8 +Test of basic functions and application to complex examples.
    50.9 +*)
   50.10 +
   50.11 +"-----------------------------------------------------------------------------------------------";
   50.12 +"-----------------------------------------------------------------------------------------------";
   50.13 +"table of contents -----------------------------------------------------------------------------";
   50.14 +"-----------------------------------------------------------------------------------------------";
   50.15 +"-------- fun is_polyexp -----------------------------------------------------------------------";
   50.16 +"-------- fun has_degree_in --------------------------------------------------------------------";
   50.17 +"-------- fun mono_deg_in ----------------------------------------------------------------------";
   50.18 +"-------- fun sort_variables -------------------------------------------------------------------";
   50.19 +"-------- fun is_addUnordered (x \<up> 2 * y \<up> 2 + x \<up> 3 * y) --------------------------------------";
   50.20 +"-------- check make_polynomial with simple terms ----------------------------------------------";
   50.21 +"-------- fun is_multUnordered (x \<up> 2 * x) -----------------------------------------------------";
   50.22 +"-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------";
   50.23 +"-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------";
   50.24 +"-------- fun is_multUnordered  b * a * a ------------------------------------------------------";
   50.25 +"-------- fun is_multUnordered 2*3*a -----------------------------------------------------------";
   50.26 +"-------- norm_Poly with AlgEin ----------------------------------------------------------------";
   50.27 +"-------- complex examples from textbook Schalk I ----------------------------------------------";
   50.28 +"-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------";
   50.29 +"-----------------------------------------------------------------------------------------------";
   50.30 +"-----------------------------------------------------------------------------------------------";
   50.31 +
   50.32 +
   50.33 +"-------- fun is_polyexp -----------------------------------------------------------------------";
   50.34 +"-------- fun is_polyexp -----------------------------------------------------------------------";
   50.35 +"-------- fun is_polyexp -----------------------------------------------------------------------";
   50.36 +val t = TermC.str2term "x / x";
   50.37 +if is_polyexp t then error "NOT is_polyexp (x / x)" else ();
   50.38 +
   50.39 +val t = TermC.str2term "- 1 * A * 3";
   50.40 +if is_polyexp t then () else error "is_polyexp (- 1 * A * 3)";
   50.41 +
   50.42 +val t = TermC.str2term "- 1 * AA * 3";
   50.43 +if is_polyexp t then () else error "is_polyexp (- 1 * AA * 3)";
   50.44 +
   50.45 +val t = TermC.str2term "x * x + x * y + (- 1 * y * x + - 1 * y * y)::real";
   50.46 +if is_polyexp t then () else error "is_polyexp (x * x + x * y + (- 1 * y * x + - 1 * y * y))";
   50.47 +
   50.48 +"-------- fun has_degree_in --------------------------------------------------------------------";
   50.49 +"-------- fun has_degree_in --------------------------------------------------------------------";
   50.50 +"-------- fun has_degree_in --------------------------------------------------------------------";
   50.51 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   50.52 +val t = (Thm.term_of o the o (TermC.parse thy)) "1";
   50.53 +if has_degree_in t v = 0 then () else error "has_degree_in (1) x";
   50.54 +
   50.55 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   50.56 +val t = (Thm.term_of o the o (TermC.parse thy)) "1";
   50.57 +if has_degree_in t v = 0 then () else error "has_degree_in (1) AA";
   50.58 +
   50.59 +(*----------*)
   50.60 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   50.61 +val t = (Thm.term_of o the o (TermC.parse thy)) "a*b+c";
   50.62 +if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) x";
   50.63 +
   50.64 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   50.65 +val t = (Thm.term_of o the o (TermC.parse thy)) "a*b+c";
   50.66 +if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) AA";
   50.67 +
   50.68 +(*----------*)
   50.69 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   50.70 +val t = (Thm.term_of o the o (TermC.parse thy)) "a*x+c";
   50.71 +if has_degree_in t v = ~1 then () else error "has_degree_in (a*x+c) x";
   50.72 +
   50.73 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   50.74 +val t = (Thm.term_of o the o (TermC.parse thy)) "a*AA+c";
   50.75 +if has_degree_in t v = ~1 then () else error "has_degree_in (a*AA+c) AA";
   50.76 +
   50.77 +(*----------*)
   50.78 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   50.79 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x \<up> 7";
   50.80 +if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*x \<up> 7) x";
   50.81 +
   50.82 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   50.83 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA \<up> 7";
   50.84 +if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*AA \<up> 7) AA";
   50.85 +
   50.86 +(*----------*)
   50.87 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   50.88 +val t = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 7";
   50.89 +if has_degree_in t v = 7 then () else error "has_degree_in (x \<up> 7) x";
   50.90 +
   50.91 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   50.92 +val t = (Thm.term_of o the o (TermC.parse thy)) "AA \<up> 7";
   50.93 +if has_degree_in t v = 7 then () else error "has_degree_in (AA \<up> 7) AA";
   50.94 +
   50.95 +(*----------*)
   50.96 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   50.97 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x";
   50.98 +if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*x) x";
   50.99 +
  50.100 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  50.101 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA";
  50.102 +if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*AA) AA";
  50.103 +
  50.104 +(*----------*)
  50.105 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  50.106 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+x)*x";
  50.107 +if has_degree_in t v = ~1 then () else error "has_degree_in (a*b+x)*x() x";
  50.108 +
  50.109 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  50.110 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+AA)*AA";
  50.111 +if has_degree_in t v = ~1 then () else error "has_degree_in ((a*b+AA)*AA) AA";
  50.112 +
  50.113 +(*----------*)
  50.114 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  50.115 +val t = (Thm.term_of o the o (TermC.parse thy)) "x";
  50.116 +if has_degree_in t v = 1 then () else error "has_degree_in (x) x";
  50.117 +
  50.118 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  50.119 +val t = (Thm.term_of o the o (TermC.parse thy)) "AA";
  50.120 +if has_degree_in t v = 1 then () else error "has_degree_in (AA) AA";
  50.121 +
  50.122 +(*----------*)
  50.123 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  50.124 +val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*x";
  50.125 +if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*x) x";
  50.126 +
  50.127 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  50.128 +val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*AA";
  50.129 +if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*AA) AA";
  50.130 +
  50.131 +"-------- fun mono_deg_in ----------------------------------------------------------------------";
  50.132 +"-------- fun mono_deg_in ----------------------------------------------------------------------";
  50.133 +"-------- fun mono_deg_in ----------------------------------------------------------------------";
  50.134 +val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  50.135 +
  50.136 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x \<up> 7";
  50.137 +if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*x \<up> 7) x changed";
  50.138 +
  50.139 +val t = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 7";
  50.140 +if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (x \<up> 7) x changed";
  50.141 +
  50.142 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x";
  50.143 +if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*x) x changed";
  50.144 +
  50.145 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+x)*x";
  50.146 +if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+x)*x) x changed";
  50.147 +
  50.148 +val t = (Thm.term_of o the o (TermC.parse thy)) "x";
  50.149 +if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (x) x changed";
  50.150 +
  50.151 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)";
  50.152 +if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) x changed";
  50.153 +
  50.154 +val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*x";
  50.155 +if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*x) x changed";
  50.156 +
  50.157 +(*. . . . . . . . . . . . the same with Const ("Partial_Functions.AA", _) . . . . . . . . . . . *)
  50.158 +val thy = @{theory Partial_Fractions}
  50.159 +val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  50.160 +
  50.161 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA \<up> 7";
  50.162 +if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*AA \<up> 7) AA changed";
  50.163 +
  50.164 +val t = (Thm.term_of o the o (TermC.parse thy)) "AA \<up> 7";
  50.165 +if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (AA \<up> 7) AA changed";
  50.166 +
  50.167 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA";
  50.168 +if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*AA) AA changed";
  50.169 +
  50.170 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+AA)*AA";
  50.171 +if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+AA)*AA) AA changed";
  50.172 +
  50.173 +val t = (Thm.term_of o the o (TermC.parse thy)) "AA";
  50.174 +if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (AA) AA changed";
  50.175 +
  50.176 +val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)";
  50.177 +if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) AA changed";
  50.178 +
  50.179 +val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*AA";
  50.180 +if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*AA) AA changed";
  50.181 +
  50.182 +
  50.183 +"-------- fun sort_variables -------------------------------------------------------------------";
  50.184 +"-------- fun sort_variables -------------------------------------------------------------------";
  50.185 +"-------- fun sort_variables -------------------------------------------------------------------";
  50.186 +if "---" < "123" andalso "123" < "a" andalso "a" < "cba" then ()
  50.187 +else error "lexicographic order CHANGED";
  50.188 +
  50.189 +(*--------------vvvvvvvvvvvvvvv-----------------------------------------------------------------*)
  50.190 +val t =  @{term "3 * b + a * 2"}; (*------------------------------------------------------------*)
  50.191 +val t' =  sort_variables t;
  50.192 +if UnparseC.term t' = "(3::'a) * b + (2::'a) * a" then ()
  50.193 +else error "sort_variables  3 * b + a * 2  CHANGED";
  50.194 +
  50.195 +"~~~~~~~ fun sort_variables , args:"; val (t) = (t);
  50.196 +  	val ll =  map monom2list (poly2list t);
  50.197 +
  50.198 +(*+*)UnparseC.terms (poly2list t) = "[\"(3::'a) * b\", \"a * (2::'a)\"]";
  50.199 +(*+*)val [ [(Const ("Num.numeral_class.numeral", _) $ _), Free ("b", _)],
  50.200 +(*+*)      [Free ("a", _), (Const ("Num.numeral_class.numeral", _) $ _)]
  50.201 +(*+*)    ] = map monom2list (poly2list t);
  50.202 +
  50.203 +  	val lls = map sort_varList ll;
  50.204 +
  50.205 +(*+*)case map sort_varList ll of
  50.206 +(*+*)  [ [Const ("Num.numeral_class.numeral", _) $ _, Free ("b", _)],
  50.207 +(*+*)    [Const ("Num.numeral_class.numeral", _) $ _, Free ("a", _)]
  50.208 +(*+*)  ] => ()
  50.209 +(*+*)| _ => error "map sort_varList CHANGED";
  50.210 +
  50.211 +  	val T = type_of t;
  50.212 +  	val ls = map (create_monom T) lls;
  50.213 +
  50.214 +(*+*)val [Const ("Groups.times_class.times", _) $ _ $ Free ("b", _),
  50.215 +(*+*)     Const ("Groups.times_class.times", _) $ _ $ Free ("a", _)] = map (create_monom T) lls;
  50.216 +
  50.217 +(*+*)case map (create_monom T) lls of
  50.218 +(*+*)  [Const ("Groups.times_class.times", _) $ (Const ("Num.numeral_class.numeral", _) $ _) $ Free ("b", _),
  50.219 +(*+*)   Const ("Groups.times_class.times", _) $ (Const ("Num.numeral_class.numeral", _) $ _) $ Free ("a", _)
  50.220 +(*+*)  ] => ()
  50.221 +(*+*)| _ => error "map (create_monom T) CHANGED";
  50.222 +
  50.223 +  val xxx = (*in*) create_polynom T ls (*end*);
  50.224 +
  50.225 +(*+*)if UnparseC.term xxx = "(3::'a) * b + (2::'a) * a" then ()
  50.226 +(*+*)else error "create_polynom CHANGED";
  50.227 +(* done by rewriting>              2 * a +       3 * b ? *)
  50.228 +
  50.229 +(*---------------vvvvvvvvvvvvvvvvvvvvvv---------------------------------------------------------*)
  50.230 +val t =  @{term "3 * a + - 2 * a ::real"}; (*---------------------------------------------------*)
  50.231 +val t' =     sort_variables t;
  50.232 +if UnparseC.term t' = "3 * a + - 2 * a" then ()
  50.233 +else error "sort_variables  3 * a + - 2 * a  CHANGED";
  50.234 +
  50.235 +"~~~~~~~ fun sort_variables , args:"; val (t) = (t);
  50.236 +  	val ll =  map monom2list (poly2list t);
  50.237 +
  50.238 +(*+*)val [ [Const ("Num.numeral_class.numeral", _) $ _, Free ("a", _)],
  50.239 +(*+*)      [Const ("Groups.uminus_class.uminus", _) $ _, Free ("a", _)] (*already correct order*)
  50.240 +(*+*)    ] = map monom2list (poly2list t);
  50.241 +
  50.242 +  	val lls = map
  50.243 +           sort_varList ll;
  50.244 +
  50.245 +(*+*)val [ [Const ("Num.numeral_class.numeral", _) $ _, Free ("a", _)],
  50.246 +(*+*)      [Const ("Groups.uminus_class.uminus", _) $ _, Free ("a", _)] (*ERROR: NO swap here*)
  50.247 +(*+*)    ] = map sort_varList ll;
  50.248 +
  50.249 +       map sort_varList ll;
  50.250 +"~~~~~ val sort_varList , args:"; val (ts) = (nth 2 ll);
  50.251 +val sorted = sort var_ord ts;
  50.252 +
  50.253 +(*+*)if UnparseC.terms ts = "[\"- 2\", \"a\"]" andalso UnparseC.terms sorted = "[\"- 2\", \"a\"]"
  50.254 +(*+*)then () else error "sort var_ord  [\"- 2\", \"a\"]  CHANGED";
  50.255 +
  50.256 +
  50.257 +(*+*)if UnparseC.term (nth 1 ts) = "- 2" andalso get_basStr (nth 1 ts) = "-2"
  50.258 +(*+*)then () else error "get_basStr  - 2  CHANGED";
  50.259 +(*+*)if UnparseC.term (nth 2 ts) = "a" andalso get_basStr (nth 2 ts) = "a"
  50.260 +(*+*)then () else error "get_basStr  a  CHANGED";
  50.261 +
  50.262 +
  50.263 +"-------- fun is_addUnordered (x \<up> 2 * y \<up> 2 + x \<up> 3 * y) --------------------------------------";
  50.264 +"-------- fun is_addUnordered (x \<up> 2 * y \<up> 2 + x \<up> 3 * y) --------------------------------------";
  50.265 +"-------- fun is_addUnordered (x \<up> 2 * y \<up> 2 + x \<up> 3 * y) --------------------------------------";
  50.266 +val t = TermC.str2term "x \<up> 2 * y \<up> 2 + x * x \<up> 2 * y";
  50.267 +Rewrite.trace_on := false; (*true false*)
  50.268 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.269 +   UnparseC.term t = "x \<up> 2 * y \<up> 2 + x \<up> 3 * y";
  50.270 +if UnparseC.term t = "x \<up> 3 * y + x \<up> 2 * y \<up> 2" then ()
  50.271 +else error "poly.sml: diff.behav. in make_polynomial 23";
  50.272 +
  50.273 +(** )
  50.274 +##  rls: order_add_rls_ on: x \<up> 2 * y \<up> 2 + x \<up> 3 * y 
  50.275 +###  rls: order_add_ on: x \<up> 2 * y \<up> 2 + x \<up> 3 * y 
  50.276 +######  rls: Rule_Set.empty-is_addUnordered on: x \<up> 2 * y \<up> 2 + x \<up> 3 * y is_addUnordered 
  50.277 +#######  try calc: "Poly.is_addUnordered" 
  50.278 +########  eval asms: "x \<up> 2 * y \<up> 2 + x \<up> 3 * y is_addUnordered = False"  (*isa*)
  50.279 +                                                                              True"   (*isa2*)
  50.280 +#######  calc. to: False  (*isa*)
  50.281 +                   True   (*isa2*)
  50.282 +( **)
  50.283 +        if is_addUnordered (TermC.str2term "x \<up> 2 * y \<up> 2 + x \<up> 3 * y ::real") then ()
  50.284 +else error"is_addUnordered  x \<up> 2 * y \<up> 2 + x \<up> 3 * y"; (*isa == isa2*)
  50.285 +"~~~~~ fun is_addUnordered , args:"; val (t) = (TermC.str2term "x \<up> 2 * y \<up> 2 + x \<up> 3 * y ::real");
  50.286 +      ((is_polyexp t) andalso not (t = sort_monoms t)) = false;  (*isa == isa2*)
  50.287 +
  50.288 +(*+*) if is_polyexp t = true then () else error "is_polyexp  x \<up> 2 * y \<up> 2 + x \<up> 3 * y";
  50.289 +
  50.290 +(*+*) if                           t = sort_monoms t = false then () else error "sort_monoms 123";
  50.291 +"~~~~~~~ fun sort_monoms , args:"; val (t) = (t);
  50.292 +  	val ll =  map monom2list (poly2list t);
  50.293 +  	val lls = sort_monList ll;
  50.294 +
  50.295 +(*+*)map UnparseC.terms lls = ["[\"x \<up> 2\", \"y \<up> 2\"]", "[\"x \<up> 3\", \"y\"]"]; (*isa*)
  50.296 +(*+*)map UnparseC.terms lls = ["[\"x \<up> 3\", \"y\"]", "[\"x \<up> 2\", \"y \<up> 2\"]"]; (*isa2*)
  50.297 +
  50.298 +"~~~~~~~~~~~ fun koeff_degree_ord , args:"; val () = ();
  50.299 +(* we check all elements at once..*)
  50.300 +val eee1 = ll |> nth 1; UnparseC.terms eee1 = "[\"x \<up> 2\", \"y \<up> 2\"]";
  50.301 +val eee2 = ll |> nth 2; UnparseC.terms eee2 = "[\"x \<up> 3\", \"y\"]";    
  50.302 +
  50.303 +(*1*)if koeff_degree_ord (eee1, eee1) = EQUAL   then () else error "(eee1, eee1) CHANGED";
  50.304 +(*2*)if koeff_degree_ord (eee1, eee2) = GREATER then () else error "(eee1, eee2) CHANGED";
  50.305 +(*3*)if koeff_degree_ord (eee2, eee1) = LESS    then () else error "(eee2, eee1) CHANGED"; (*isa*)
  50.306 +(*4*)if koeff_degree_ord (eee2, eee2) = EQUAL   then () else error "(eee2, eee2) CHANGED";
  50.307 +(* isa -- isa2:
  50.308 +(*1*){a = "var_ord_revPow ", at_bt = "(x \<up> 2, x \<up> 2)", sort_args = "(x, 2), (x, 2)"}                                           (*isa == isa2*)
  50.309 +(*1*){a = "var_ord_revPow ", at_bt = "(y \<up> 2, y \<up> 2)", sort_args = "(y, 2), (y, 2)"}                                            (*isa == isa2*)
  50.310 +(*1*){a = "compare_koeff_ord ", ats_bts = "([\"x \<up> 2\", \"y \<up> 2\"], [\"x \<up> 2\", \"y \<up> 2\"])", sort_args = "(---, ---)"} (*isa == isa2*) 
  50.311 +
  50.312 +(*2*){a = "var_ord_revPow ", at_bt = "(x \<up> 2, x \<up> 3)", sort_args = "(x, 2), (x, 3)"}                                           (*isa == isa2*) 
  50.313 +
  50.314 +(*3*)k{a = "var_ord_revPow ", at_bt = "(x \<up> 3, x \<up> 2)", sort_args = "(x, 3), (x, 2)"}                                           (*isa == isa2*) 
  50.315 +
  50.316 +(*4*){a = "var_ord_revPow ", at_bt = "(x \<up> 3, x \<up> 3)", sort_args = "(x, 3), (x, 3)"}                                           (*isa == isa2*)
  50.317 +(*4*){a = "var_ord_revPow ", at_bt = "(y, y)", sort_args = "(y, ---), (y, ---)"}                                                       (*isa == isa2*)
  50.318 +(*4*){a = "compare_koeff_ord ", ats_bts = "([\"x \<up> 3\", \"y\"], [\"x \<up> 3\", \"y\"])", sort_args = "(---, ---)"}                (*isa == isa2*) 
  50.319 +val it = true: bool
  50.320 +val it = true: bool
  50.321 +val it = true: bool
  50.322 +val it = true: bool*)
  50.323 +
  50.324 +"~~~~~~~~~~~~~ fun degree_ord , args:"; val () = ();
  50.325 +(*1*)if degree_ord (eee1, eee1) = EQUAL   then () else error "degree_ord (eee1, eee1) CHANGED";
  50.326 +(*2*)if degree_ord (eee1, eee2) = GREATER    then () else error "degree_ord (eee1, eee2) CHANGED";(*isa*)
  50.327 +(*{a = "int_ord (4, 10003) = ", z = LESS}      isa
  50.328 +  {a = "int_ord (4, 4) = ", z = EQUAL}         isa2*)
  50.329 +(*3*)if degree_ord (eee2, eee1) = LESS then () else error "degree_ord (eee2, eee1) CHANGED";(*isa*)
  50.330 +(*4*)if degree_ord (eee2, eee2) = EQUAL   then () else error "degree_ord (eee2, eee2) CHANGED";
  50.331 +(* isa -- isa2:
  50.332 +(*1*){a = "int_ord (10002, 10002) = ", z = EQUAL}                                                          (*isa*)
  50.333 +     {a = "int_ord (4, 4) = ", z = EQUAL}                                                                    (*isa2*)
  50.334 +(*1*){a = "dict_cond_ord", args = "([\"x \<up> 2\", \"y \<up> 2\"], [\"x \<up> 2\", \"y \<up> 2\"])", is_nums = "(false, false)"}  (*isa*)
  50.335 +(*1*){a = "var_ord_revPow ", at_bt = "(x \<up> 2, x \<up> 2)", sort_args = "(x, 2), (x, 2)"}               (*isa*)
  50.336 +(*1*){a = "dict_cond_ord", args = "([\"y \<up> 2\"], [\"y \<up> 2\"])", is_nums = "(false, false)"}        (*isa*)
  50.337 +(*1*){a = "var_ord_revPow ", at_bt = "(y \<up> 2, y \<up> 2)", sort_args = "(y, 2), (y, 2)"}               (*isa*)
  50.338 +(*1*){a = "dict_cond_ord ([], [])"}                                                                        (*isa*)
  50.339 +
  50.340 +(*2*){a = "int_ord (10002, 10003) = ", z = LESS}                                                           (*isa*)
  50.341 +     {a = "int_ord (4, 4) = ", z = EQUAL}                                                                    (*isa2*)
  50.342 +     {a = "dict_cond_ord", args = "([\"x \<up> 2\", \"y \<up> 2\"], [\"x \<up> 3\", \"y\"])", is_nums = "(false, false)"} (*isa2*)
  50.343 +(*2*){a = "var_ord_revPow ", at_bt = "(x \<up> 2, x \<up> 3)", sort_args = "(x, 2), (x, 3)"}                 (*isa2*)
  50.344 +
  50.345 +(*3*){a = "int_ord (10003, 10002) = ", z = GREATER}                                                       (*isa*)
  50.346 +     {a = "int_ord (4, 4) = ", z = EQUAL}                                                                    (*isa2*)
  50.347 +     {a = "dict_cond_ord", args = "([\"x \<up> 3\", \"y\"], [\"x \<up> 2\", \"y \<up> 2\"])", is_nums = "(false, false)"}
  50.348 +(*3*){a = "var_ord_revPow ", at_bt = "(x \<up> 3, x \<up> 2)", sort_args = "(x, 3), (x, 2)"}                (*isa == isa2*)
  50.349 +
  50.350 +(*4*){a = "int_ord (10003, 10003) = ", z = EQUAL}                                                         (*isa*)
  50.351 +     {a = "int_ord (4, 4) = ", z = EQUAL}                                                                    (*isa2*)
  50.352 +(*4*){a = "dict_cond_ord", args = "([\"x \<up> 3\", \"y\"], [\"x \<up> 3\", \"y\"])", is_nums = "(false, false)"} (*isa == isa2*)
  50.353 +(*4*){a = "var_ord_revPow ", at_bt = "(x \<up> 3, x \<up> 3)", sort_args = "(x, 3), (x, 3)"}              (*isa == isa2*)
  50.354 +(*4*){a = "dict_cond_ord", args = "([\"y\"], [\"y\"])", is_nums = "(false, false)"}                       (*isa == isa2*)
  50.355 +(*4*){a = "var_ord_revPow ", at_bt = "(y, y)", sort_args = "(y, ---), (y, ---)"}                          (*isa == isa2*)
  50.356 +(*4*){a = "dict_cond_ord ([], [])"}                                                                       (*isa == isa2*)
  50.357 +
  50.358 +val it = true: bool
  50.359 +val it = false: bool
  50.360 +val it = false: bool
  50.361 +val it = true: bool
  50.362 +*)
  50.363 +
  50.364 +(*+*) if monom_degree eee1 = 4 then () else error "monom_degree [\"x \<up> 2\", \"y \<up> 2\"] CHANGED";
  50.365 +"~~~~~~~~~~~~~~~ fun monom_degree , args:"; val (l) = (eee1);
  50.366 +"~~~~~ fun counter , args:"; val (n, x :: xs) = (0, l); (*--------------------------OPEN local\* )
  50.367 +	    (*if*) (is_nums x) (*else*);
  50.368 +  val (Const ("Transcendental.powr", _) $ Free _ $ t) =
  50.369 +      (*case*) x (*of*); 
  50.370 +(*+*)UnparseC.term x = "x \<up> 2";
  50.371 +            (*if*) TermC.is_num t (*then*);
  50.372 +
  50.373 +           counter (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
  50.374 +"~~~~~ fun counter , args:"; val (n, x :: xs) = (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
  50.375 +	    (*if*) (is_nums x) (*else*);
  50.376 +  val (Const ("Transcendental.powr", _) $ Free _ $ t) =
  50.377 +      (*case*) x (*of*); 
  50.378 +(*+*)UnparseC.term x = "y \<up> 2";
  50.379 +            (*if*) TermC.is_num t (*then*);
  50.380 +
  50.381 +  val return =
  50.382 +      counter (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
  50.383 +if return = 4 then () else error "monom_degree [\"x \<up> 2\", \"y \<up> 2\"] CHANGED";
  50.384 +( *---------------------------------------------------------------------------------OPEN local/*)
  50.385 +
  50.386 +(*+*)if monom_degree eee2 = 4 andalso monom_degree eee2 = 4 then ()
  50.387 +else error "monom_degree  [\"x \<up> 3\", \"y\"] CHANGED";
  50.388 +"~~~~~~~~~~~~~~~ fun monom_degree , args:"; val (l) = (eee2);
  50.389 +"~~~~~ fun counter , args:"; val (n, x :: xs) = (0, l); (*--------------------------OPEN local\* )
  50.390 +	    (*if*) (is_nums x) (*else*);
  50.391 +val (Const ("Transcendental.powr", _) $ Free _ $ t) =
  50.392 +      (*case*) x (*of*); 
  50.393 +(*+*)UnparseC.term x = "x \<up> 3";
  50.394 +            (*if*) TermC.is_num t (*then*);
  50.395 +
  50.396 +      counter (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
  50.397 +"~~~~~ fun counter , args:"; val (n, x :: xs) = (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
  50.398 +	    (*if*) (is_nums x) (*else*);
  50.399 +val _ = (*the default case*)
  50.400 +      (*case*) x (*of*); 
  50.401 +( *---------------------------------------------------------------------------------OPEN local/*)
  50.402 +
  50.403 +"~~~~~~~~~~~~~~~ fun dict_cond_ord , args:"; val () = ();
  50.404 +val xxx = dict_cond_ord var_ord_revPow is_nums;
  50.405 +(*1*)if xxx (eee1, eee1) = EQUAL   then () else error "dict_cond_ord (eee1, eee1) CHANGED";
  50.406 +(*2*)if xxx (eee1, eee2) = GREATER then () else error "dict_cond_ord (eee1, eee2) CHANGED";
  50.407 +(*3*)if xxx (eee2, eee1) = LESS    then () else error "dict_cond_ord (eee2, eee1) CHANGED";
  50.408 +(*4*)if xxx (eee2, eee2) = EQUAL   then () else error "dict_cond_ord (eee2, eee2) CHANGED";
  50.409 +
  50.410 +
  50.411 +"-------- check make_polynomial with simple terms ----------------------------------------------";
  50.412 +"-------- check make_polynomial with simple terms ----------------------------------------------";
  50.413 +"-------- check make_polynomial with simple terms ----------------------------------------------";
  50.414 +"----- check 1 ---";
  50.415 +val t = TermC.str2term "2*3*a";
  50.416 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  50.417 +if UnparseC.term t = "6 * a" then () else error "check make_polynomial 1";
  50.418 +
  50.419 +"----- check 2 ---";
  50.420 +val t = TermC.str2term "2*a + 3*a";
  50.421 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  50.422 +if UnparseC.term t = "5 * a" then () else error "check make_polynomial 2";
  50.423 +
  50.424 +"----- check 3 ---";
  50.425 +val t = TermC.str2term "2*a + 3*a + 3*a";
  50.426 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  50.427 +if UnparseC.term t = "8 * a" then () else error "check make_polynomial 3";
  50.428 +
  50.429 +"----- check 4 ---";
  50.430 +val t = TermC.str2term "3*a - 2*a";
  50.431 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  50.432 +if UnparseC.term t = "a" then () else error "check make_polynomial 4";
  50.433 +
  50.434 +"----- check 5 ---";
  50.435 +val t = TermC.str2term "4*(3*a - 2*a)";
  50.436 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  50.437 +if UnparseC.term t = "4 * a" then () else error "check make_polynomial 5";
  50.438 +
  50.439 +"----- check 6 ---";
  50.440 +val t = TermC.str2term "4*(3*a \<up> 2 - 2*a \<up> 2)";
  50.441 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  50.442 +if UnparseC.term t = "4 * a \<up> 2" then () else error "check make_polynomial 6";
  50.443 +
  50.444 +"-------- fun is_multUnordered (x \<up> 2 * x) -----------------------------------------------------";
  50.445 +"-------- fun is_multUnordered (x \<up> 2 * x) -----------------------------------------------------";
  50.446 +"-------- fun is_multUnordered (x \<up> 2 * x) -----------------------------------------------------";
  50.447 +val thy = @{theory "Isac_Knowledge"};
  50.448 +"===== works for a simple example, see rewrite.sml -- fun app_rev ===";
  50.449 +val t = TermC.str2term "x \<up> 2 * x";
  50.450 +val SOME (t', _) = rewrite_set_ thy true order_mult_ t;
  50.451 +if UnparseC.term t' = "x * x \<up> 2" then ()
  50.452 +else error "poly.sml Poly.is_multUnordered doesn't work";
  50.453 +
  50.454 +(* 100928 Rewrite.trace_on shows the first occurring difference in 267b:
  50.455 +###  rls: order_mult_ on: 5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) +
  50.456 + (-48 * x \<up> 4 + 8))
  50.457 +######  rls: Rule_Set.empty-is_multUnordered on: p is_multUnordered
  50.458 +#######  try calc: Poly.is_multUnordered'
  50.459 +=======  calc. to: False  !!!!!!!!!!!!! INSTEAD OF TRUE in 2002 !!!!!!!!!!!!!
  50.460 +*)
  50.461 +val t = TermC.str2term "5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) +  (-48 * x \<up> 4 + 8))";
  50.462 +
  50.463 +"----- is_multUnordered ---";
  50.464 +val tsort = sort_variables t;
  50.465 +UnparseC.term tsort = "2 * (5 * (x \<up> 2 * x \<up> 7)) + 3 * (5 * x \<up> 2) + 6 * x \<up> 7 + 9 +\n- 1 * (3 * (6 * (x \<up> 4 * x \<up> 5))) +\n- 1 * (- 1 * (3 * x \<up> 5)) +\n-48 * x \<up> 4 +\n8";
  50.466 +is_polyexp t;
  50.467 +tsort = t;
  50.468 +is_polyexp t andalso not (t = sort_variables t);
  50.469 +if is_multUnordered t then () else error "poly.sml diff. is_multUnordered 1";
  50.470 +
  50.471 +"----- eval_is_multUnordered ---";
  50.472 +val tm = TermC.str2term "(5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) +  (-48 * x \<up> 4 + 8))) is_multUnordered";
  50.473 +case eval_is_multUnordered "testid" "" tm thy of
  50.474 +    SOME (_, Const ("HOL.Trueprop", _) $ 
  50.475 +                   (Const ("HOL.eq", _) $
  50.476 +                          (Const ("Poly.is_multUnordered", _) $ _) $ 
  50.477 +                          Const ("HOL.True", _))) => ()
  50.478 +  | _ => error "poly.sml diff. eval_is_multUnordered";
  50.479 +
  50.480 +"----- rewrite_set_ STILL DIDN'T WORK";
  50.481 +val SOME (t, _) = rewrite_set_ thy true order_mult_ t;
  50.482 +UnparseC.term t;
  50.483 +
  50.484 +
  50.485 +"-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------";
  50.486 +"-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------";
  50.487 +"-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------";
  50.488 +val thy = @{theory "Isac_Knowledge"};
  50.489 +val t as (_ $ arg) = TermC.str2term "(3 * a + - 2 * a) is_multUnordered";
  50.490 +
  50.491 +(*+*)if UnparseC.term (sort_variables arg) = "3 * a + - 2 * a" andalso is_polyexp arg = true
  50.492 +(*+*)  andalso not (is_multUnordered arg)
  50.493 +(*+*)then () else error "sort_variables  3 * a + - 2 * a   CHANGED";
  50.494 +
  50.495 +case eval_is_multUnordered "xxx " "yyy " t thy of
  50.496 +  SOME
  50.497 +    ("xxx 3 * a + - 2 * a_",
  50.498 +      Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $
  50.499 +        Const ("HOL.False", _))) => ()
  50.500 +(*      Const ("HOL.True", _))) => ()   <<<<<--------------------------- this is false*)
  50.501 +| _ => error "eval_is_multUnordered  3 * a + - 2 * a  CHANGED";
  50.502 +
  50.503 +"----- is_multUnordered --- (- 2 * a) is_multUnordered = False";
  50.504 +val t as (_ $ arg) = TermC.str2term "(- 2 * a) is_multUnordered";
  50.505 +
  50.506 +(*+*)if UnparseC.term (sort_variables arg) = "- 2 * a" andalso is_polyexp arg = true
  50.507 +(*+*)  andalso not (is_multUnordered arg)
  50.508 +(*+*)then () else error "sort_variables  - 2 * a   CHANGED";
  50.509 +
  50.510 +case eval_is_multUnordered "xxx " "yyy " t thy of
  50.511 +  SOME
  50.512 +    ("xxx - 2 * a_",
  50.513 +      Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $
  50.514 +        Const ("HOL.False", _))) => ()
  50.515 +| _ => error "eval_is_multUnordered  3 * a + - 2 * a  CHANGED";
  50.516 +
  50.517 +"----- is_multUnordered --- (a) is_multUnordered = False";
  50.518 +val t as (_ $ arg) = TermC.str2term "(a) is_multUnordered";
  50.519 +
  50.520 +(*+*)if UnparseC.term (sort_variables arg) = "a" andalso is_polyexp arg = true
  50.521 +(*+*)  andalso not (is_multUnordered arg)
  50.522 +(*+*)then () else error "sort_variables   a   CHANGED";
  50.523 +
  50.524 +case eval_is_multUnordered "xxx " "yyy " t thy of
  50.525 +  SOME
  50.526 +    ("xxx a_",
  50.527 +      Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $
  50.528 +        Const ("HOL.False", _))) => ()
  50.529 +| _ => error "eval_is_multUnordered  3 * a + - 2 * a  CHANGED";
  50.530 +
  50.531 +"----- is_multUnordered --- (- 2) is_multUnordered = False";
  50.532 +val t as (_ $ arg) = TermC.str2term "(- 2) is_multUnordered";
  50.533 +
  50.534 +(*+*)if UnparseC.term (sort_variables arg) = "- 2" andalso is_polyexp arg = true
  50.535 +(*+*)  andalso not (is_multUnordered arg)
  50.536 +(*+*)then () else error "sort_variables   - 2   CHANGED";
  50.537 +
  50.538 +case eval_is_multUnordered "xxx " "yyy " t thy of
  50.539 +  SOME
  50.540 +    ("xxx - 2_",
  50.541 +      Const ("HOL.Trueprop", _) $ (Const ("HOL.eq", _) $ _ $
  50.542 +        Const ("HOL.False", _))) => ()
  50.543 +| _ => error "eval_is_multUnordered  3 * a + - 2 * a  CHANGED";
  50.544 +
  50.545 +
  50.546 +"-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------";
  50.547 +"-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------";
  50.548 +"-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------";
  50.549 +(*  ca.line 45 of Rewrite.trace_on:
  50.550 +##  rls: order_mult_rls_ on: 
  50.551 +  x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 
  50.552 +###  rls: order_mult_ on:
  50.553 +  x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 
  50.554 +######  rls: Rule_Set.empty-is_multUnordered on: 
  50.555 +  x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 is_multUnordered 
  50.556 +#######  try calc: "Poly.is_multUnordered" 
  50.557 +########  eval asms: 
  50.558 +N:x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 is_multUnordered = True" 
  50.559 +-------------------------------------------------------------------------------------------------==
  50.560 +O:x \<up> 3 + 3 * x \<up> 2 * (- 1 * a)  + 3 * x * (- 1    \<up> 2 * a \<up> 2) + - 1    \<up> 3 * a \<up> 3 is_multUnordered = True" 
  50.561 +#######  calc. to: True 
  50.562 +#######  try calc: "Poly.is_multUnordered" 
  50.563 +#######  try calc: "Poly.is_multUnordered" 
  50.564 +###  rls: order_mult_ on: 
  50.565 +N:x \<up> 3 + - 1 * (3 * (a * x \<up> 2))  +  3 * (a \<up> 2 * (x * (- 1) \<up> 2))  +  a \<up> 3 * (- 1) \<up> 3 
  50.566 +--------+--------------------------+---------------------------------+---------------------------<>
  50.567 +O:x \<up> 3 + - 1  * (3 * (a * x \<up> 2))  +  - 1 \<up> 2 * (3 * (a \<up> 2 * x))     +  - 1 \<up> 3 * a \<up> 3 
  50.568 +-------------------------------------------------------------------------------------------------<>
  50.569 +*)
  50.570 +val t = TermC.str2term "x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3";
  50.571 +(*
  50.572 +"~~~~~ fun is_multUnordered
  50.573 +"~~~~~~~ fun sort_variables
  50.574 +"~~~~~~~~~ val sort_varList
  50.575 +*)
  50.576 +"~~~~~ fun is_multUnordered , args:"; val (t) = (t);
  50.577 +     is_polyexp t = true;
  50.578 +
  50.579 +  val return =
  50.580 +             sort_variables t;
  50.581 +(*+*)if UnparseC.term return =
  50.582 +(*+*)  "x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) +\n(- 1) \<up> 2 * (3 * (a \<up> 2 * x)) +\n(- 1) \<up> 3 * a \<up> 3"
  50.583 +(*+*)then () else error "sort_variables  x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) .. CHANGED";
  50.584 +
  50.585 +"~~~~~~~ fun sort_variables , args:"; val (t) = (t);
  50.586 +  	val ll = map monom2list (poly2list t);
  50.587 +  	val lls = map sort_varList ll; 
  50.588 +
  50.589 +(*+*)val ori3 = nth 3 ll;
  50.590 +(*+*)val mon3 = nth 3 lls;
  50.591 +
  50.592 +(*+*)if UnparseC.terms (nth 1 ll) = "[\"x \<up> 3\"]" then () else error "nth 1 ll";
  50.593 +(*+*)if UnparseC.terms (nth 2 ll) = "[\"3\", \"x \<up> 2\", \"- 1\", \"a\"]" then () else error "nth 3 ll";
  50.594 +(*+*)if UnparseC.terms ori3       = "[\"3\", \"x\", \"(- 1) \<up> 2\", \"a \<up> 2\"]" then () else error "nth 3 ll";
  50.595 +(*+*)if UnparseC.terms (nth 4 ll) = "[\"(- 1) \<up> 3\", \"a \<up> 3\"]" then () else error "nth 4 ll";
  50.596 +
  50.597 +(*+*)if UnparseC.terms (nth 1 lls) = "[\"x \<up> 3\"]" then () else error "nth 1 lls";
  50.598 +(*+*)if UnparseC.terms (nth 2 lls) = "[\"- 1\", \"3\", \"a\", \"x \<up> 2\"]" then () else error "nth 2 lls";
  50.599 +(*+*)if UnparseC.terms mon3 = "[\"(- 1) \<up> 2\", \"3\", \"a \<up> 2\", \"x\"]" then () else error "nth 3 lls";
  50.600 +(*+*)if UnparseC.terms (nth 4 lls) = "[\"(- 1) \<up> 3\", \"a \<up> 3\"]" then () else error "nth 4 lls";
  50.601 +
  50.602 +"~~~~~~~~~ val sort_varList , args:"; val (ori3) = (ori3);
  50.603 +(* Output below with:
  50.604 +val sort_varList = sort var_ord;
  50.605 +fun var_ord (a,b: term) = 
  50.606 +(@{print} {a = "var_ord ", a_b = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")",
  50.607 +   sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"};
  50.608 +  prod_ord string_ord string_ord 
  50.609 +  ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b))
  50.610 +);
  50.611 +*)
  50.612 +(*+*)val xxx = sort_varList ori3;
  50.613 +(*
  50.614 +{a = "sort_varList", args = "[\"3\", \"x\", \"(- 1) \<up> 2\", \"a \<up> 2\"]"} (*isa*)
  50.615 +{a = "sort_varList", args = "[\"3\", \"x\", \"(- 1) \<up> 2\", \"a \<up> 2\"]"} (*isa2*)
  50.616 +      
  50.617 +isa                                            isa2
  50.618 +{a = "var_ord ", a_b = "(3, x)"}               {a = "var_ord ", a_b = "(3, x)"}
  50.619 +  {sort_args = "(|||, ||||||), (x, ---)"}        {sort_args = "(|||, ||||||), (x, ---)"}
  50.620 +{a = "var_ord ", a_b = "(x, (- 1) \<up> 2)"}       {a = "var_ord ", a_b = "(x, (- 1) \<up> 2)"}
  50.621 +  {sort_args = "(x, ---), (|||, ||||||)"}        {sort_args = "(x, ---), (|||, ||||||)"}
  50.622 +{a = "var_ord ", a_b = "((- 1) \<up> 2, a \<up> 2)"}   {a = "var_ord ", a_b = "((- 1) \<up> 2, a \<up> 2)"}
  50.623 +  {sort_args = "(|||, ||||||), (a, 2)"}          {sort_args = "(|||, ||||||), (a, |||)"}
  50.624 +                                  ^^^                                             ^^^
  50.625 +
  50.626 +{a = "var_ord ", a_b = "(x, a \<up> 2)"}           {a = "var_ord ", a_b = "(x, a \<up> 2)"}
  50.627 +  {sort_args = "(x, ---), (a, 2)"}               {sort_args = "(x, ---), (a, |||)"}
  50.628 +                             ^^^                                             ^^^
  50.629 +{a = "var_ord ", a_b = "(x, (- 1) \<up> 2)"}       {a = "var_ord ", a_b = "(x, (- 1) \<up> 2)"}
  50.630 +  {sort_args = "(x, ---), (|||, ||||||)"}        {sort_args = "(x, ---), (|||, ||||||)"}
  50.631 +{a = "var_ord ", a_b = "(3, (- 1) \<up> 2)"}       {a = "var_ord ", a_b = "(3, (- 1) \<up> 2)"}
  50.632 +  {sort_args = "(|||, ||||||), (|||, ||||||)"}   {sort_args = "(|||, ||||||), (|||, ||||||)"}
  50.633 +*)
  50.634 +
  50.635 +
  50.636 +"-------- fun is_multUnordered  b * a * a ------------------------------------------------------";
  50.637 +"-------- fun is_multUnordered  b * a * a ------------------------------------------------------";
  50.638 +"-------- fun is_multUnordered  b * a * a ------------------------------------------------------";
  50.639 +val t = TermC.str2term "b * a * a";
  50.640 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.641 +if UnparseC.term t = "a \<up> 2 * b" then ()
  50.642 +else error "poly.sml: diff.behav. in make_polynomial 21";
  50.643 +
  50.644 +"~~~~~ fun is_multUnordered , args:"; val (t) = (@{term "b * a * a::real"});
  50.645 +    ((is_polyexp t) andalso not (t = sort_variables t)) = true;  (*isa == isa2*)
  50.646 +
  50.647 +(*+*)if    is_polyexp t then () else error "is_polyexp a \<up> 2 * b CHANGED";
  50.648 +"~~~~~ fun is_polyexp , args:"; val (Const ("Groups.times_class.times",_) $ num $ Free _) = (t);
  50.649 +    (*if*) TermC.is_num num (*else*);
  50.650 +
  50.651 +"~~~~~ fun is_polyexp , args:"; val (Const ("Groups.times_class.times",_) $ num $ Free _) = (num);
  50.652 +    (*if*) TermC.is_num num (*else*);
  50.653 +      (*if*) TermC.is_variable num (*then*);
  50.654 +
  50.655 +                           val xxx = sort_variables t;
  50.656 +(*+*)if UnparseC.term xxx = "a * (a * b)" then () else error "sort_variables a \<up> 2 * b CHANGED";
  50.657 +
  50.658 +
  50.659 +"-------- fun is_multUnordered 2*3*a -----------------------------------------------------------";
  50.660 +"-------- fun is_multUnordered 2*3*a -----------------------------------------------------------";
  50.661 +"-------- fun is_multUnordered 2*3*a -----------------------------------------------------------";
  50.662 +val t = TermC.str2term "2*3*a";
  50.663 +val SOME (t', _) = rewrite_set_ thy false make_polynomial t;
  50.664 +(*+*)if UnparseC.term t' = "6 * a" then () else error "rewrite_set_ 2*3*a CHANGED";
  50.665 +(*
  50.666 +##  try calc: "Groups.times_class.times" 
  50.667 +##  rls: order_mult_rls_ on: 6 * a 
  50.668 +###  rls: order_mult_ on: 6 * a 
  50.669 +######  rls: Rule_Set.empty-is_multUnordered on: 6 * a is_multUnordered 
  50.670 +#######  try calc: "Poly.is_multUnordered" 
  50.671 +########  eval asms: "6 * a is_multUnordered = True"    (*isa*)
  50.672 +                                             = False"   (*isa2*)
  50.673 +#######  calc. to: True  (*isa*)
  50.674 +                   False (*isa2*)
  50.675 +*)
  50.676 +val t = TermC.str2term "(6 * a) is_multUnordered"; 
  50.677 +val SOME
  50.678 +    (_, t') =
  50.679 +           eval_is_multUnordered "xxx" () t @{theory};
  50.680 +(*+*)if UnparseC.term t' = "6 * a is_multUnordered = False" then () 
  50.681 +(*+*)else error "6 * a is_multUnordered = False CHANGED";
  50.682 +
  50.683 +"~~~~~ fun eval_is_multUnordered , args:"; val ((thmid:string), _,
  50.684 +		       (t as (Const("Poly.is_multUnordered", _) $ arg)), thy) = ("xxx", (), t, @{theory});
  50.685 +    (*if*) is_multUnordered arg (*else*);
  50.686 +
  50.687 +"~~~~~ fun is_multUnordered , args:"; val (t) = (arg);
  50.688 +  val return =
  50.689 +     ((is_polyexp t) andalso not (t = sort_variables t));
  50.690 +
  50.691 +(*+*)return = false;                                             (*isa*)
  50.692 +(*+*)  is_polyexp t = true;                                      (*isa*)
  50.693 +(*+*)                        not (t = sort_variables t) = false; (*isa*)
  50.694 +
  50.695 +                            val xxx = sort_variables t;
  50.696 +(*+*)if UnparseC.term xxx = "6 * a" then () else error "2*3*a is_multUnordered CHANGED";
  50.697 +
  50.698 +"-------- norm_Poly with AlgEin ----------------------------------------------------------------";
  50.699 +"-------- norm_Poly with AlgEin ----------------------------------------------------------------";
  50.700 +"-------- norm_Poly with AlgEin ----------------------------------------------------------------";
  50.701 +val thy = @{theory AlgEin};
  50.702 +
  50.703 +val SOME (f',_) = rewrite_set_ thy false norm_Poly
  50.704 +(TermC.str2term "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben");
  50.705 +if UnparseC.term f' = "L = 2 * 2 * k + 2 * - 4 * q + senkrecht + oben"
  50.706 +then ((*norm_Poly NOT COMPLETE -- TODO MG*))
  50.707 +else error "norm_Poly changed behavior";
  50.708 +(* isa:
  50.709 +##  rls: order_add_rls_ on: L = k + - 2 * q + k + - 2 * q + k + - 2 * q + k + - 2 * q + senkrecht + oben 
  50.710 +###  rls: order_add_ on: L = k + - 2 * q + k + - 2 * q + k + - 2 * q + k + - 2 * q + senkrecht + oben 
  50.711 +######  rls: Rule_Set.empty-is_addUnordered on: k + - 2 * q + k + - 2 * q + k + - 2 * q + k + - 2 * q + senkrecht +
  50.712 +oben is_addUnordered 
  50.713 +#######  try calc: "Poly.is_addUnordered" 
  50.714 +########  eval asms: "k + - 2 * q + k + - 2 * q + k + - 2 * q + k + - 2 * q + senkrecht +
  50.715 +oben is_addUnordered = True" 
  50.716 +#######  calc. to: True 
  50.717 +#######  try calc: "Poly.is_addUnordered" 
  50.718 +#######  try calc: "Poly.is_addUnordered" 
  50.719 +###  rls: order_add_ on: L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben 
  50.720 +*)
  50.721 +"~~~~~ fun sort_monoms , args:"; val (t) =
  50.722 +  (TermC.str2term "L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben");
  50.723 +(*+*)val t' =
  50.724 +           sort_monoms t;
  50.725 +(*+*)UnparseC.term t' = "L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben"; (*isa*)
  50.726 +
  50.727 +
  50.728 +"-------- complex examples from textbook Schalk I ----------------------------------------------";
  50.729 +"-------- complex examples from textbook Schalk I ----------------------------------------------";
  50.730 +"-------- complex examples from textbook Schalk I ----------------------------------------------";
  50.731 +val t = TermC.str2term "1 + 2 * x \<up> 4 + 2 * - 2 * x \<up> 4 + x \<up> 8";
  50.732 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.733 +if (UnparseC.term t) = "1 + - 2 * x \<up> 4 + x \<up> 8"
  50.734 +then () else error "poly.sml: diff.behav. in make_polynomial 9b";
  50.735 +
  50.736 +"-----SPB Schalk I p.64 No.296a ---";
  50.737 +val t = TermC.str2term "(x - a) \<up> 3";
  50.738 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.739 +if (UnparseC.term t) = "- 1 * a \<up> 3 + 3 * a \<up> 2 * x + - 3 * a * x \<up> 2 + x \<up> 3"
  50.740 +then () else error "poly.sml: diff.behav. in make_polynomial 10";
  50.741 +
  50.742 +"-----SPB Schalk I p.64 No.296c ---";
  50.743 +val t = TermC.str2term "(-3*x - 4*y) \<up> 3";
  50.744 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.745 +if (UnparseC.term t) = "- 27 * x \<up> 3 + - 108 * x \<up> 2 * y + - 144 * x * y \<up> 2 +\n- 64 * y \<up> 3"
  50.746 +then () else error "poly.sml: diff.behav. in make_polynomial 11";
  50.747 +
  50.748 +"-----SPB Schalk I p.62 No.242c ---";
  50.749 +val t = TermC.str2term "x \<up> (- 4)*(x \<up> (- 4)*y \<up> (- 2)) \<up> (- 1)*y \<up> (- 2)";
  50.750 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.751 +if (UnparseC.term t) = "1"
  50.752 +then () else error "poly.sml: diff.behav. in make_polynomial 12";
  50.753 +
  50.754 +"-----SPB Schalk I p.60 No.209a ---";
  50.755 +val t = TermC.str2term "a \<up> (7-x) * a \<up> x";
  50.756 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.757 +if UnparseC.term t = "a \<up> 7"
  50.758 +then () else error "poly.sml: diff.behav. in make_polynomial 13";
  50.759 +
  50.760 +"-----SPB Schalk I p.60 No.209d ---";
  50.761 +val t = TermC.str2term "d \<up> x * d \<up> (x+1) * d \<up> (2 - 2*x)";
  50.762 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.763 +if UnparseC.term t = "d \<up> 3"
  50.764 +then () else error "poly.sml: diff.behav. in make_polynomial 14";
  50.765 +
  50.766 +
  50.767 +"-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------";
  50.768 +"-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------";
  50.769 +"-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------";
  50.770 +"-----SPO ---";
  50.771 +val t = TermC.str2term "a \<up> 2*a \<up> (- 2)";
  50.772 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.773 +if UnparseC.term t = "1" then ()
  50.774 +else error "poly.sml: diff.behav. in make_polynomial 15";
  50.775 +
  50.776 +"-----SPO ---";
  50.777 +val t = TermC.str2term "a \<up> 2*b*b \<up> (- 1)";
  50.778 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.779 +if UnparseC.term t = "a \<up> 2" then ()
  50.780 +else error "poly.sml: diff.behav. in make_polynomial 18";
  50.781 +"-----SPO ---";
  50.782 +val t = TermC.str2term "a \<up> 2*a \<up> (- 2)";
  50.783 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.784 +if (UnparseC.term t) = "1" then ()
  50.785 +else error "poly.sml: diff.behav. in make_polynomial 19";
  50.786 +"-----SPO ---";
  50.787 +val t = TermC.str2term "b + a - b";
  50.788 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  50.789 +if (UnparseC.term t) = "a" then ()
  50.790 +else error "poly.sml: diff.behav. in make_polynomial 20";
  50.791 +
  50.792 +"-----SPO ---";
  50.793 +val t = (Thm.term_of o the o (TermC.parse thy)) "a \<up> 2 * (-a) \<up> 2";
  50.794 +val SOME (t,_) = rewrite_set_ @{theory} false make_polynomial t; UnparseC.term t;
  50.795 +if (UnparseC.term t) = "a \<up> 4" then ()
  50.796 +else error "poly.sml: diff.behav. in make_polynomial 24";
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/test/Tools/isac/Knowledge/poly-2.sml	Sun Jul 18 18:15:27 2021 +0200
    51.3 @@ -0,0 +1,709 @@
    51.4 +(* testexamples for Poly, polynomials
    51.5 +   author: Matthias Goldgruber 2003
    51.6 +   (c) due to copyright terms
    51.7 +
    51.8 +LEGEND:
    51.9 +WN060104: examples marked with 'SPB' came into 'exp_IsacCore_Simp_Poly_Book.xml'
   51.10 +          examples marked with 'SPO' came into 'exp_IsacCore_Simp_Poly_Other.xml'
   51.11 +*)
   51.12 +
   51.13 +"-----------------------------------------------------------------------------------------------";
   51.14 +"-----------------------------------------------------------------------------------------------";
   51.15 +"table of contents -----------------------------------------------------------------------------";
   51.16 +"-----------------------------------------------------------------------------------------------";
   51.17 +"-------- survey on parallel rewrite-breakers AND code with @{print} ---------------------------";
   51.18 +"-------- thm sym_real_mult_minus1 loops with new numerals -------------------------------------";
   51.19 +"-------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) ----------------------------";
   51.20 +"-------- eval_ for is_expanded_in, is_poly_in, has_degree_in ----------------------------------";
   51.21 +"-------- investigate (new 2002) uniary minus --------------------------------------------------";
   51.22 +"-------- rebuild fun is_addUnordered (1 + 2 * x \<up> 4 + - 4 * x \<up> 4 + x \<up> 8) ---------------------";
   51.23 +"-------- examples from textbook Schalk I ------------------------------------------------------";
   51.24 +"-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------";
   51.25 +"-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------";
   51.26 +"-------- check pbl  'polynomial simplification' -----------------------------------------------";
   51.27 +"-------- me 'poly. simpl.' Schalk I p.63 No.267b ----------------------------------------------";
   51.28 +"-------- interSteps for Schalk 299a -----------------------------------------------------------";
   51.29 +"-------- norm_Poly NOT COMPLETE ---------------------------------------------------------------";
   51.30 +"-------- ord_make_polynomial ------------------------------------------------------------------";
   51.31 +"-----------------------------------------------------------------------------------------------";
   51.32 +"-----------------------------------------------------------------------------------------------";
   51.33 +"-----------------------------------------------------------------------------------------------";
   51.34 +
   51.35 +
   51.36 +"-------- survey on parallel rewrite-breakers AND code with @{print} ---------------------------";
   51.37 +"-------- survey on parallel rewrite-breakers AND code with @{print} ---------------------------";
   51.38 +"-------- survey on parallel rewrite-breakers AND code with @{print} ---------------------------";
   51.39 +(* indentation indicates call hierarchy:
   51.40 +"~~~~~ fun is_addUnordered
   51.41 +"~~~~~~~ fun is_polyexp
   51.42 +"~~~~~~~ fun sort_monoms
   51.43 +"~~~~~~~~~ fun sort_monList
   51.44 +"~~~~~~~~~~~ fun koeff_degree_ord    : term list * term list -> order
   51.45 +"~~~~~~~~~~~~~ fun degree_ord        : term list * term list -> order
   51.46 +"~~~~~~~~~~~~~~~ fun dict_cond_ord   : ('a * 'a -> order) -> ('a -> bool) -> 'a list * 'a list -> order
   51.47 +"~~~~~~~~~~~~~~~~~ fun var_ord_revPow: term * term -> order
   51.48 +"~~~~~~~~~~~~~~~~~~~ fun get_basStr  : term -> string                       used twice --vv
   51.49 +"~~~~~~~~~~~~~~~~~~~ fun get_potStr  : term -> string                       used twice --vv
   51.50 +"~~~~~~~~~~~~~~~ fun monom_degree    : term list -> int
   51.51 +"~~~~~~~~~~~~~ fun compare_koeff_ord : term list * term list -> order
   51.52 +"~~~~~~~~~~~~~~~ fun get_koeff_of_mon: term list -> term option
   51.53 +"~~~~~~~~~~~~~~~~~ fun koeff2ordStr  : term option -> string
   51.54 +"~~~~~ fun is_multUnordered
   51.55 +"~~~~~~~ fun sort_variables
   51.56 +"~~~~~~~~~ fun sort_varList
   51.57 +"~~~~~~~~~~~ fun var_ord
   51.58 +"~~~~~~~~~~~~~ fun get_basStr                                               used twice --^^
   51.59 +"~~~~~~~~~~~~~ fun get_potStr                                               used twice --^^
   51.60 +
   51.61 +fun int_ord (i1, i2) =
   51.62 +(@{print} {a = "int_ord (" ^ string_of_int i1 ^ ", " ^ string_of_int i2 ^ ") = ", z = Int.compare (i1, i2)};
   51.63 +  Int.compare (i1, i2)
   51.64 +);
   51.65 +fun var_ord (a, b) = 
   51.66 +(@{print} {a = "var_ord ", a_b = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")",
   51.67 +   sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"};
   51.68 +  prod_ord string_ord string_ord 
   51.69 +  ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b))
   51.70 +);
   51.71 +fun var_ord_revPow (a, b: term) = 
   51.72 +(@{print} {a = "var_ord_revPow ", at_bt = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")",
   51.73 +    sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"};
   51.74 +  prod_ord string_ord string_ord_rev 
   51.75 +    ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b))
   51.76 +);
   51.77 +fun sort_varList ts =
   51.78 +(@{print} {a = "sort_varList", args = UnparseC.terms ts};
   51.79 +  sort var_ord ts
   51.80 +);
   51.81 +fun dict_cond_ord _ _ ([], [])     = (@{print} {a = "dict_cond_ord ([], [])"}; EQUAL)
   51.82 +  | dict_cond_ord _ _ ([], _ :: _) = (@{print} {a = "dict_cond_ord ([], _ :: _)"}; LESS)
   51.83 +  | dict_cond_ord _ _ (_ :: _, []) = (@{print} {a = "dict_cond_ord (_ :: _, [])"}; GREATER)
   51.84 +  | dict_cond_ord elem_ord cond (x :: xs, y :: ys) =
   51.85 +    (@{print} {a = "dict_cond_ord", args = "(" ^ UnparseC.terms (x :: xs) ^ ", " ^ UnparseC.terms (y :: ys) ^ ")", 
   51.86 +      is_nums = "(" ^ LibraryC.bool2str (cond x) ^ ", " ^ LibraryC.bool2str (cond y) ^ ")"};
   51.87 +     case (cond x, cond y) of 
   51.88 +	    (false, false) =>
   51.89 +        (case elem_ord (x, y) of 
   51.90 +				  EQUAL => dict_cond_ord elem_ord cond (xs, ys) 
   51.91 +			  | ord => ord)
   51.92 +    | (false, true)  => dict_cond_ord elem_ord cond (x :: xs, ys)
   51.93 +    | (true, false)  => dict_cond_ord elem_ord cond (xs, y :: ys)
   51.94 +    | (true, true)  =>  dict_cond_ord elem_ord cond (xs, ys)
   51.95 +);
   51.96 +fun compare_koeff_ord (xs, ys) =
   51.97 +(@{print} {a = "compare_koeff_ord ", ats_bts = "(" ^ UnparseC.terms xs ^ ", " ^ UnparseC.terms ys ^ ")",
   51.98 +    sort_args = "(" ^ (koeff2ordStr o get_koeff_of_mon) xs ^ ", " ^ (koeff2ordStr o get_koeff_of_mon) ys ^ ")"};
   51.99 +  string_ord
  51.100 +  ((koeff2ordStr o get_koeff_of_mon) xs,
  51.101 +   (koeff2ordStr o get_koeff_of_mon) ys)
  51.102 +);
  51.103 +fun var_ord (a,b: term) = 
  51.104 +(@{print} {a = "var_ord ", a_b = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")",
  51.105 +   sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"};
  51.106 +  prod_ord string_ord string_ord 
  51.107 +  ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b))
  51.108 +);
  51.109 +*)
  51.110 +
  51.111 +
  51.112 +"-------- thm sym_real_mult_minus1 loops with new numerals -------------------------------------";
  51.113 +"-------- thm sym_real_mult_minus1 loops with new numerals -------------------------------------";
  51.114 +"-------- thm sym_real_mult_minus1 loops with new numerals -------------------------------------";
  51.115 +(* thus   ^^^^^^^^^^^^^^^^^^^^^^^^ excluded from rls.
  51.116 +
  51.117 +  sym_real_mult_minus1                                  =     "- ?z = - 1 * ?z" *)
  51.118 +@{thm real_mult_minus1};                              (* = "- 1 * ?z = - ?z"     *)
  51.119 +val thm_isac = ThmC.sym_thm @{thm real_mult_minus1};  (* =     "- ?z = - 1 * ?z" *)
  51.120 +val SOME t_isac = TermC.parseNEW @{context} "3 * a + - 1 * (2 * a):: real";
  51.121 +
  51.122 +val SOME (t', []) = rewrite_ @{theory} tless_true Rule_Set.empty true thm_isac t_isac;
  51.123 +if UnparseC.term t' = "3 * a + - 1 * 1 * (2 * a)" then ((*thm did NOT apply to Free ("- 1", _)*))
  51.124 +else error "thm  - ?z = - 1 * ?z  loops with new numerals";
  51.125 +
  51.126 +
  51.127 +"-------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) ----------------------------";
  51.128 +"-------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) ----------------------------";
  51.129 +"-------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) ----------------------------";
  51.130 +val thy = @{theory Partial_Fractions}
  51.131 +val expr = (Thm.term_of o the o (TermC.parse thy)) "((-8 - 2*x + x \<up> 2) has_degree_in x) = 2";
  51.132 +val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
  51.133 +
  51.134 +val expr = (Thm.term_of o the o (TermC.parse thy)) "((-8 - 2*AA + AA \<up> 2) has_degree_in AA) = 2";
  51.135 +val SOME (Const ("HOL.True", _), []) = rewrite_set_ thy false PolyEq_prls expr;
  51.136 +
  51.137 +"-------- eval_ for is_expanded_in, is_poly_in, has_degree_in ----------------------------------";
  51.138 +"-------- eval_ for is_expanded_in, is_poly_in, has_degree_in ----------------------------------";
  51.139 +"-------- eval_ for is_expanded_in, is_poly_in, has_degree_in ----------------------------------";
  51.140 +val t = (Thm.term_of o the o (TermC.parse thy)) "(-8 - 2*x + x \<up> 2) is_expanded_in x";
  51.141 +val SOME (id, t') = eval_is_expanded_in 0 0 t 0;
  51.142 +if UnparseC.term t' = "- 8 - 2 * x + x \<up> 2 is_expanded_in x = True"
  51.143 +         andalso id = "- 8 - 2 * x + x \<up> 2 is_expanded_in x = True"
  51.144 +then () else error "eval_is_expanded_in x ..changed";
  51.145 +
  51.146 +val thy = @{theory Partial_Fractions}
  51.147 +val t = (Thm.term_of o the o (TermC.parse thy)) "(-8 - 2*AA + AA \<up> 2) is_expanded_in AA";
  51.148 +val SOME (id, t') = eval_is_expanded_in 0 0 t 0;
  51.149 +if  UnparseC.term t' = "- 8 - 2 * AA + AA \<up> 2 is_expanded_in AA = True"
  51.150 +          andalso id = "- 8 - 2 * AA + AA \<up> 2 is_expanded_in AA = True"
  51.151 +then () else error "eval_is_expanded_in AA ..changed";
  51.152 +
  51.153 +
  51.154 +val t = (Thm.term_of o the o (TermC.parse thy)) "(8 + 2*x + x \<up> 2) is_poly_in x";
  51.155 +val SOME (id, t') = eval_is_poly_in 0 0 t 0;
  51.156 +if  UnparseC.term t' = "8 + 2 * x + x \<up> 2 is_poly_in x = True"
  51.157 +          andalso id = "8 + 2 * x + x \<up> 2 is_poly_in x = True"
  51.158 +then () else error "is_poly_in x ..changed";
  51.159 +
  51.160 +val t = (Thm.term_of o the o (TermC.parse thy)) "(8 + 2*AA + AA \<up> 2) is_poly_in AA";
  51.161 +val SOME (id, t') = eval_is_poly_in 0 0 t 0;
  51.162 +if  UnparseC.term t' = "8 + 2 * AA + AA \<up> 2 is_poly_in AA = True"
  51.163 +          andalso id = "8 + 2 * AA + AA \<up> 2 is_poly_in AA = True"
  51.164 +then () else error "is_poly_in AA ..changed";
  51.165 +
  51.166 +
  51.167 +val thy = @{theory Partial_Fractions}
  51.168 +val expr = (Thm.term_of o the o (TermC.parse thy)) "((-8 - 2*x + x \<up> 2) has_degree_in x) = 2";
  51.169 +val SOME (Const (\<^const_name>\<open>True\<close>, _), []) = rewrite_set_ thy false PolyEq_prls expr;
  51.170 +
  51.171 +val expr = (Thm.term_of o the o (TermC.parse thy)) "((-8 - 2*AA + AA \<up> 2) has_degree_in AA) = 2";
  51.172 +val SOME (Const (\<^const_name>\<open>True\<close>, _), []) = rewrite_set_ thy false PolyEq_prls expr;
  51.173 +
  51.174 +"-------- investigate (new 2002) uniary minus --------------------------------------------------";
  51.175 +"-------- investigate (new 2002) uniary minus --------------------------------------------------";
  51.176 +"-------- investigate (new 2002) uniary minus --------------------------------------------------";
  51.177 +val t = Thm.prop_of @{thm real_diff_0}; (*"0 - ?x = - ?x"*)
  51.178 +TermC.atomty t;
  51.179 +(*
  51.180 +*** Const (HOL.Trueprop, bool => prop)
  51.181 +*** . Const (HOL.eq, real => real => bool)
  51.182 +*** . . Const (Groups.minus_class.minus, real => real => real)
  51.183 +*** . . . Const (Groups.zero_class.zero, real)
  51.184 +*** . . . Var ((x, 0), real)
  51.185 +*** . . Const (Groups.uminus_class.uminus, real => real)
  51.186 +*** . . . Var ((x, 0), real)
  51.187 +*)
  51.188 +case t of
  51.189 +  Const (\<^const_name>\<open>Trueprop\<close>, _) $
  51.190 +    (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ 
  51.191 +      (Const (\<^const_name>\<open>minus\<close>, _) $ Const (\<^const_name>\<open>Groups.zero\<close>, _) $ 
  51.192 +        Var (("x", 0), _)) $
  51.193 +             (Const (\<^const_name>\<open>uminus\<close>, _) $ Var (("x", 0), _))) => ()
  51.194 +| _ => error "internal representation of \"0 - ?x = - ?x\" changed";
  51.195 +
  51.196 +
  51.197 +val t = (Thm.term_of o the o (TermC.parse thy)) "- 1";
  51.198 +TermC.atomty t;
  51.199 +(*
  51.200 +*** 
  51.201 +*** Free (- 1, real)
  51.202 +*** 
  51.203 +*)
  51.204 +case t of
  51.205 + Const ("Groups.uminus_class.uminus", _) $ Const ("Groups.one_class.one", _) => ()
  51.206 +| _ => error "internal representation of \"- 1\" changed";
  51.207 +
  51.208 +"======= these external values all have the same internal representation";
  51.209 +(* "1-x" causes syntyx error --- binary minus detected by blank inbetween !!!*)
  51.210 +(*----------------------------------- vvvvv -------------------------------------------*)
  51.211 +val t = (Thm.term_of o the o (TermC.parse thy)) "-x";
  51.212 +TermC.atomty t;
  51.213 +(**** -------------
  51.214 +*** Free ( -x, real)*)
  51.215 +case t of
  51.216 +  Const (\<^const_name>\<open>uminus\<close>, _) $ Free ("x", _) => ()
  51.217 +| _ => error "internal representation of \"-x\" changed";
  51.218 +(*----------------------------------- vvvvv -------------------------------------------*)
  51.219 +val t = (Thm.term_of o the o (TermC.parse thy)) "- x";
  51.220 +TermC.atomty t;
  51.221 +(**** -------------
  51.222 +*** Free ( -x, real) !!!!!!!!!!!!!!!!!!!!!!!! is the same !!!*)
  51.223 +case t of
  51.224 +  Const (\<^const_name>\<open>uminus\<close>, _) $ Free ("x", _) => ()
  51.225 +| _ => error "internal representation of \"- x\" changed";
  51.226 +(*----------------------------------- vvvvvv ------------------------------------------*)
  51.227 +val t = (Thm.term_of o the o (TermC.parse thy)) "-(x)";
  51.228 +TermC.atomty t;
  51.229 +(**** -------------
  51.230 +*** Free ( -x, real)*)
  51.231 +case t of
  51.232 +  Const (\<^const_name>\<open>uminus\<close>, _) $ Free ("x", _) => ()
  51.233 +| _ => error "internal representation of \"-(x)\" changed";
  51.234 +
  51.235 +
  51.236 +"-------- rebuild fun is_addUnordered (1 + 2 * x \<up> 4 + - 4 * x \<up> 4 + x \<up> 8) ---------------------";
  51.237 +"-------- rebuild fun is_addUnordered (1 + 2 * x \<up> 4 + - 4 * x \<up> 4 + x \<up> 8) ---------------------";
  51.238 +"-------- rebuild fun is_addUnordered (1 + 2 * x \<up> 4 + - 4 * x \<up> 4 + x \<up> 8) ---------------------";
  51.239 +(* indentation partially indicates call hierarchy:
  51.240 +"~~~~~ fun is_addUnordered
  51.241 +"~~~~~~~ fun is_polyexp
  51.242 +"~~~~~~~ fun sort_monoms
  51.243 +"~~~~~~~~~ fun sort_monList
  51.244 +"~~~~~~~~~~~ fun koeff_degree_ord
  51.245 +"~~~~~~~~~~~~~ fun degree_ord
  51.246 +"~~~~~~~~~~~~~~~ fun dict_cond_ord
  51.247 +"~~~~~~~~~~~~~~~~~ fun var_ord_revPow
  51.248 +"~~~~~~~~~~~~~~~~~~~ fun get_basStr         used twice --vv
  51.249 +"~~~~~~~~~~~~~~~~~~~ fun get_potStr         used twice --vv
  51.250 +"~~~~~~~~~~~~~~~ fun monom_degree
  51.251 +"~~~~~~~~~~~~~ fun compare_koeff_ord
  51.252 +"~~~~~~~~~~~~~~~ fun get_koeff_of_mon
  51.253 +"~~~~~~~~~~~~~~~~~ fun koeff2ordStr
  51.254 +"~~~~~ fun is_multUnordered
  51.255 +"~~~~~~~ fun sort_variables
  51.256 +"~~~~~~~~~ fun sort_varList
  51.257 +"~~~~~~~~~~~ fun var_ord
  51.258 +"~~~~~~~~~~~~~ fun get_basStr               used twice --^^
  51.259 +"~~~~~~~~~~~~~ fun get_potStr               used twice --^^
  51.260 +*)
  51.261 +val t = TermC.str2term "(1 + 2 * x \<up> 4 + - 4 * x \<up> 4 + x \<up> 8) is_addUnordered";
  51.262 +
  51.263 +           eval_is_addUnordered "xxx" "yyy" t @{theory};
  51.264 +"~~~~~ fun eval_is_addUnordered , args:"; val ((thmid:string), _, 
  51.265 +		       (t as (Const("Poly.is_addUnordered", _) $ arg)), thy) =
  51.266 +  ("xxx", "yyy", t, @{theory});
  51.267 +
  51.268 +    (*if*) is_addUnordered arg;
  51.269 +"~~~~~ fun is_addUnordered , args:"; val (t) = (arg);
  51.270 +  ((is_polyexp t) andalso not (t = sort_monoms t));
  51.271 +
  51.272 +        (t = sort_monoms t);
  51.273 +"~~~~~~~ fun sort_monoms , args:"; val (t) = (t);
  51.274 +  	val ll =  map monom2list (poly2list t);
  51.275 +  	val lls =
  51.276 +
  51.277 +           sort_monList ll;
  51.278 +"~~~~~~~~~ fun sort_monList , args:"; val (ll) = (ll);
  51.279 +      val xxx = 
  51.280 +
  51.281 +            sort koeff_degree_ord ll(*return value*);
  51.282 +"~~~~~~~~~~~ fun koeff_degree_ord , args:"; val (ll) = (ll);
  51.283 +                 koeff_degree_ord: term list * term list -> order;
  51.284 +(*we check all elements at once..*)
  51.285 +val eee1 = ll |> nth 1;
  51.286 +val eee2 = ll |> nth 2;
  51.287 +val eee3 = ll |> nth 3;
  51.288 +val eee3 = ll |> nth 3;
  51.289 +val eee4 = ll |> nth 4;
  51.290 +
  51.291 +if UnparseC.terms eee1 = "[\"1\"]" then () else error "eee1 CHANGED";
  51.292 +if UnparseC.terms eee2 = "[\"2\", \"x \<up> 4\"]" then () else error "eee2 CHANGED";
  51.293 +if UnparseC.terms eee3 = "[\"- 4\", \"x \<up> 4\"]" then () else error "eee3 CHANGED";
  51.294 +if UnparseC.terms eee4 = "[\"x \<up> 8\"]" then () else error "eee4 CHANGED";
  51.295 +
  51.296 +if koeff_degree_ord (eee1, eee1) = EQUAL   then () else error "(eee1, eee1) CHANGED";
  51.297 +if koeff_degree_ord (eee1, eee2) = LESS    then () else error "(eee1, eee2) CHANGED";
  51.298 +if koeff_degree_ord (eee1, eee3) = LESS    then () else error "(eee1, eee3) CHANGED";
  51.299 +if koeff_degree_ord (eee1, eee4) = LESS    then () else error "(eee1, eee4) CHANGED";
  51.300 +
  51.301 +if koeff_degree_ord (eee2, eee1) = GREATER then () else error "(eee2, eee1) CHANGED";
  51.302 +if koeff_degree_ord (eee2, eee2) = EQUAL   then () else error "(eee2, eee4) CHANGED";
  51.303 +if koeff_degree_ord (eee2, eee3) = LESS    then () else error "(eee2, eee3) CHANGED";
  51.304 +if koeff_degree_ord (eee2, eee4) = LESS    then () else error "(eee2, eee4) CHANGED";
  51.305 +
  51.306 +if koeff_degree_ord (eee3, eee1) = GREATER then () else error "(eee3, eee1) CHANGED";
  51.307 +if koeff_degree_ord (eee3, eee2) = GREATER then () else error "(eee3, eee4) CHANGED";
  51.308 +if koeff_degree_ord (eee3, eee3) = EQUAL   then () else error "(eee3, eee3) CHANGED";
  51.309 +if koeff_degree_ord (eee3, eee4) = LESS    then () else error "(eee3, eee4) CHANGED";
  51.310 +
  51.311 +if koeff_degree_ord (eee4, eee1) = GREATER then () else error "(eee4, eee1) CHANGED";
  51.312 +if koeff_degree_ord (eee4, eee2) = GREATER then () else error "(eee4, eee4) CHANGED";
  51.313 +if koeff_degree_ord (eee4, eee3) = GREATER then () else error "(eee4, eee3) CHANGED";
  51.314 +if koeff_degree_ord (eee4, eee4) = EQUAL   then () else error "(eee4, eee4) CHANGED";
  51.315 +
  51.316 +"~~~~~~~~~~~~~ fun degree_ord , args:"; val () = ();
  51.317 +                   degree_ord: term list * term list -> order;
  51.318 +
  51.319 +if degree_ord (eee1, eee1) = EQUAL   then () else error "degree_ord (eee1, eee1) CHANGED";
  51.320 +if degree_ord (eee1, eee2) = LESS    then () else error "degree_ord (eee1, eee2) CHANGED";
  51.321 +if degree_ord (eee1, eee3) = LESS    then () else error "degree_ord (eee1, eee3) CHANGED";
  51.322 +if degree_ord (eee1, eee4) = LESS    then () else error "degree_ord (eee1, eee4) CHANGED";
  51.323 +
  51.324 +if degree_ord (eee2, eee1) = GREATER then () else error "degree_ord (eee2, eee1) CHANGED";
  51.325 +if degree_ord (eee2, eee2) = EQUAL   then () else error "degree_ord (eee2, eee4) CHANGED";
  51.326 +if degree_ord (eee2, eee3) = EQUAL   then () else error "degree_ord (eee2, eee3) CHANGED";
  51.327 +if degree_ord (eee2, eee4) = LESS    then () else error "degree_ord (eee2, eee4) CHANGED";
  51.328 +
  51.329 +if degree_ord (eee3, eee1) = GREATER then () else error "degree_ord (eee3, eee1) CHANGED";
  51.330 +if degree_ord (eee3, eee2) = EQUAL   then () else error "degree_ord (eee3, eee4) CHANGED";
  51.331 +if degree_ord (eee3, eee3) = EQUAL   then () else error "degree_ord (eee3, eee3) CHANGED";
  51.332 +if degree_ord (eee3, eee4) = LESS    then () else error "degree_ord (eee3, eee4) CHANGED";
  51.333 +
  51.334 +if degree_ord (eee4, eee1) = GREATER then () else error "degree_ord (eee4, eee1) CHANGED";
  51.335 +if degree_ord (eee4, eee2) = GREATER then () else error "degree_ord (eee4, eee4) CHANGED";
  51.336 +if degree_ord (eee4, eee3) = GREATER then () else error "degree_ord (eee4, eee3) CHANGED";
  51.337 +if degree_ord (eee4, eee4) = EQUAL   then () else error "degree_ord (eee4, eee4) CHANGED";
  51.338 +
  51.339 +"~~~~~~~~~~~~~~~ fun dict_cond_ord , args:"; val () = ();
  51.340 +dict_cond_ord: (term * term -> order) -> (term -> bool) -> term list * term list -> order;
  51.341 +dict_cond_ord var_ord_revPow: (term -> bool) -> term list * term list -> order;
  51.342 +dict_cond_ord var_ord_revPow is_nums: term list * term list -> order;
  51.343 +val xxx = dict_cond_ord var_ord_revPow is_nums;
  51.344 +(* output from:
  51.345 +fun var_ord_revPow (a,b: term) =
  51.346 + (@ {print} {a = "var_ord_revPow ", ab = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")"};
  51.347 +  @ {print} {z = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"};
  51.348 +  prod_ord string_ord string_ord_rev 
  51.349 +    ((get_basStr a, get_potStr a), (get_basStr b, get_potStr b)));
  51.350 +*)
  51.351 +if xxx (eee1, eee1) = EQUAL then () else error "dict_cond_ord ..(eee1, eee1) CHANGED";
  51.352 +if xxx (eee1, eee2) = LESS  then () else error "dict_cond_ord ..(eee1, eee2) CHANGED";
  51.353 +if xxx (eee1, eee3) = LESS  then () else error "dict_cond_ord ..(eee1, eee3) CHANGED";
  51.354 +if xxx (eee1, eee4) = LESS  then () else error "dict_cond_ord ..(eee1, eee4) CHANGED";
  51.355 +(*-------------------------------------------------------------------------------------*)
  51.356 +if xxx (eee2, eee1) = GREATER then () else error "dict_cond_ord ..(eee2, eee1) CHANGED";
  51.357 +if xxx (eee2, eee2) = EQUAL   then () else error "dict_cond_ord ..(eee2, eee2) CHANGED";
  51.358 +if xxx (eee2, eee3) = EQUAL   then () else error "dict_cond_ord ..(eee2, eee3) CHANGED";
  51.359 +if xxx (eee2, eee4) = GREATER then () else error "dict_cond_ord ..(eee2, eee4) CHANGED";
  51.360 +(*-------------------------------------------------------------------------------------*)
  51.361 +if xxx (eee3, eee1) = GREATER then () else error "dict_cond_ord ..(eee3, eee1) CHANGED";
  51.362 +if xxx (eee3, eee2) = EQUAL   then () else error "dict_cond_ord ..(eee3, eee2) CHANGED";
  51.363 +if xxx (eee3, eee3) = EQUAL   then () else error "dict_cond_ord ..(eee3, eee3) CHANGED";
  51.364 +if xxx (eee3, eee4) = GREATER then () else error "dict_cond_ord ..(eee3, eee4) CHANGED";
  51.365 +(*-------------------------------------------------------------------------------------*)
  51.366 +if xxx (eee4, eee1) = GREATER then () else error "dict_cond_ord ..(eee4, eee1) CHANGED";
  51.367 +if xxx (eee4, eee2) = LESS    then () else error "dict_cond_ord ..(eee4, eee2) CHANGED";
  51.368 +if xxx (eee4, eee3) = LESS    then () else error "dict_cond_ord ..(eee4, eee3) CHANGED";
  51.369 +if xxx (eee4, eee4) = EQUAL   then () else error "dict_cond_ord ..(eee4, eee4) CHANGED";
  51.370 +(*-------------------------------------------------------------------------------------*)
  51.371 +
  51.372 +"~~~~~~~~~~~~~~~ fun monom_degree , args:"; val () = ();
  51.373 +(* we check all at once//*)
  51.374 +if monom_degree eee1 = 0 then () else error "monom_degree eee1 CHANGED";
  51.375 +if monom_degree eee2 = 4 then () else error "monom_degree eee2 CHANGED";
  51.376 +if monom_degree eee3 = 4 then () else error "monom_degree eee3 CHANGED";
  51.377 +if monom_degree eee4 = 8 then () else error "monom_degree eee4 CHANGED";
  51.378 +
  51.379 +"~~~~~~~~~~~~~ fun compare_koeff_ord , args:"; val () = ();
  51.380 +                   compare_koeff_ord: term list * term list -> order;
  51.381 +(* we check all at once//*)
  51.382 +if compare_koeff_ord (eee1, eee1) = EQUAL   then () else error "_koeff_ord (eee1, eee1) CHANGED";
  51.383 +if compare_koeff_ord (eee1, eee2) = LESS    then () else error "_koeff_ord (eee1, eee2) CHANGED";
  51.384 +if compare_koeff_ord (eee1, eee3) = LESS    then () else error "_koeff_ord (eee1, eee3) CHANGED";
  51.385 +if compare_koeff_ord (eee1, eee4) = GREATER then () else error "_koeff_ord (eee1, eee4) CHANGED";
  51.386 +
  51.387 +if compare_koeff_ord (eee2, eee1) = GREATER then () else error "_koeff_ord (eee2, eee1) CHANGED";
  51.388 +if compare_koeff_ord (eee2, eee2) = EQUAL   then () else error "_koeff_ord (eee2, eee2) CHANGED";
  51.389 +if compare_koeff_ord (eee2, eee3) = LESS    then () else error "_koeff_ord (eee2, eee3) CHANGED";
  51.390 +if compare_koeff_ord (eee2, eee4) = GREATER then () else error "_koeff_ord (eee2, eee4) CHANGED";
  51.391 +
  51.392 +if compare_koeff_ord (eee3, eee1) = GREATER then () else error "_koeff_ord (eee3, eee1) CHANGED";
  51.393 +if compare_koeff_ord (eee3, eee2) = GREATER then () else error "_koeff_ord (eee3, eee2) CHANGED";
  51.394 +if compare_koeff_ord (eee3, eee3) = EQUAL   then () else error "_koeff_ord (eee3, eee3) CHANGED";
  51.395 +if compare_koeff_ord (eee3, eee4) = GREATER then () else error "_koeff_ord (eee3, eee4) CHANGED";
  51.396 +
  51.397 +if compare_koeff_ord (eee4, eee1) = LESS    then () else error "_koeff_ord (eee4, eee1) CHANGED";
  51.398 +if compare_koeff_ord (eee4, eee2) = LESS    then () else error "_koeff_ord (eee4, eee2) CHANGED";
  51.399 +if compare_koeff_ord (eee4, eee3) = LESS    then () else error "_koeff_ord (eee4, eee3) CHANGED";
  51.400 +if compare_koeff_ord (eee4, eee4) = EQUAL   then () else error "_koeff_ord (eee4, eee4) CHANGED";
  51.401 +
  51.402 +"~~~~~~~~~~~~~~~ fun get_koeff_of_mon , args:"; val () = ();
  51.403 +           get_koeff_of_mon: term list -> term option;
  51.404 +
  51.405 +val SOME xxx1 = get_koeff_of_mon eee1;
  51.406 +val SOME xxx2 = get_koeff_of_mon eee2;
  51.407 +val SOME xxx3 = get_koeff_of_mon eee3;
  51.408 +val NONE = get_koeff_of_mon eee4;
  51.409 +
  51.410 +if UnparseC.term xxx1 = "1"   then () else error "get_koeff_of_mon eee1 CHANGED";
  51.411 +if UnparseC.term xxx2 = "2"   then () else error "get_koeff_of_mon eee2 CHANGED";
  51.412 +if UnparseC.term xxx3 = "- 4" then () else error "get_koeff_of_mon eee3 CHANGED";
  51.413 +
  51.414 +"~~~~~~~~~~~~~~~~~ fun koeff2ordStr , args:"; val () = ();
  51.415 +                       koeff2ordStr: term option -> string;
  51.416 +if koeff2ordStr (SOME xxx1) = "1"   then () else error "koeff2ordStr eee1 CHANGED";
  51.417 +if koeff2ordStr (SOME xxx2) = "2"   then () else error "koeff2ordStr eee2 CHANGED";
  51.418 +if koeff2ordStr (SOME xxx3) = "40"  then () else error "koeff2ordStr eee3 CHANGED";
  51.419 +if koeff2ordStr NONE        = "---" then () else error "koeff2ordStr eee4 CHANGED";
  51.420 +
  51.421 +
  51.422 +"-------- examples from textbook Schalk I ------------------------------------------------------";
  51.423 +"-------- examples from textbook Schalk I ------------------------------------------------------";
  51.424 +"-------- examples from textbook Schalk I ------------------------------------------------------";
  51.425 +"-----SPB Schalk I p.63 No.267b ---";
  51.426 +val t = TermC.str2term "(5*x \<up> 2 + 3) * (2*x \<up> 7 + 3) - (3*x \<up> 5 + 8) * (6*x \<up> 4 - 1)";
  51.427 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.428 +if UnparseC.term t = "17 + 15 * x \<up> 2 + - 48 * x \<up> 4 + 3 * x \<up> 5 + 6 * x \<up> 7 +\n- 8 * x \<up> 9"
  51.429 +then () else error "poly.sml: diff.behav. in make_polynomial 1";
  51.430 +
  51.431 +"-----SPB Schalk I p.63 No.275b ---";
  51.432 +val t = TermC.str2term "(3*x \<up> 2 - 2*x*y + y \<up> 2) * (x \<up> 2 - 2*y \<up> 2)";
  51.433 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  51.434 +if UnparseC.term t = 
  51.435 +  "3 * x \<up> 4 + - 2 * x \<up> 3 * y + - 5 * x \<up> 2 * y \<up> 2 +\n4 * x * y \<up> 3 +\n- 2 * y \<up> 4"
  51.436 +then () else error "poly.sml: diff.behav. in make_polynomial 2";
  51.437 +
  51.438 +"-----SPB Schalk I p.63 No.279b ---";
  51.439 +val t = TermC.str2term "(x-a)*(x-b)*(x-c)*(x-d)";
  51.440 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  51.441 +if UnparseC.term t = 
  51.442 +  ("a * b * c * d + - 1 * a * b * c * x + - 1 * a * b * d * x +\na * b * x \<up> 2 +\n" ^
  51.443 +  "- 1 * a * c * d * x +\na * c * x \<up> 2 +\na * d * x \<up> 2 +\n- 1 * a * x \<up> 3 +\n" ^
  51.444 +  "- 1 * b * c * d * x +\nb * c * x \<up> 2 +\nb * d * x \<up> 2 +\n- 1 * b * x \<up> 3 +\nc" ^
  51.445 +  " * d * x \<up> 2 +\n- 1 * c * x \<up> 3 +\n- 1 * d * x \<up> 3 +\nx \<up> 4")
  51.446 +then () else error "poly.sml: diff.behav. in make_polynomial 3";
  51.447 +(*associate poly*)
  51.448 +
  51.449 +"-----SPB Schalk I p.63 No.291 ---";
  51.450 +val t = TermC.str2term "(5+96*x \<up> 3+8*x*(-4+(7- 3*x)*4*x))*(5*(2- 3*x)- (- 15*x*(-8*x- 5)))";
  51.451 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  51.452 +if UnparseC.term t = "50 + - 770 * x + 4520 * x \<up> 2 + - 16320 * x \<up> 3 +\n- 26880 * x \<up> 4"
  51.453 +then () else error "poly.sml: diff.behav. in make_polynomial 4";
  51.454 +
  51.455 +"-----SPB Schalk I p.64 No.295c ---";
  51.456 +val t = TermC.str2term "(13*a \<up> 4*b \<up> 9*c - 12*a \<up> 3*b \<up> 6*c \<up> 9) \<up> 2";
  51.457 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  51.458 +if UnparseC.term t =
  51.459 +  "169 * a \<up> 8 * b \<up> 18 * c \<up> 2 +\n- 312 * a \<up> 7 * b \<up> 15 * c \<up> 10 +\n144 * a \<up> 6 * b \<up> 12 * c \<up> 18"
  51.460 +then ()else error "poly.sml: diff.behav. in make_polynomial 5";
  51.461 +
  51.462 +"-----SPB Schalk I p.64 No.299a ---";
  51.463 +val t = TermC.str2term "(x - y)*(x + y)";
  51.464 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  51.465 +if UnparseC.term t = "x \<up> 2 + - 1 * y \<up> 2"
  51.466 +then () else error "poly.sml: diff.behav. in make_polynomial 6";
  51.467 +
  51.468 +"-----SPB Schalk I p.64 No.300c ---";
  51.469 +val t = TermC.str2term "(3*x \<up> 2*y - 1)*(3*x \<up> 2*y + 1)";
  51.470 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  51.471 +if UnparseC.term t = "- 1 + 9 * x \<up> 4 * y \<up> 2"
  51.472 +then () else error "poly.sml: diff.behav. in make_polynomial 7";
  51.473 +
  51.474 +"-----SPB Schalk I p.64 No.302 ---";
  51.475 +val t = TermC.str2term
  51.476 +  "(13*x \<up> 2 + 5)*(13*x \<up> 2 - 5) - (5*x \<up> 2 + 3)*(5*x \<up> 2 - 3) - (12*x \<up> 2 + 4)*(12*x \<up> 2 - 4)";
  51.477 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  51.478 +if UnparseC.term t = "0"
  51.479 +then () else error "poly.sml: diff.behav. in make_polynomial 8";
  51.480 +(* RL?MG?: Bei Berechnung sollte 3 mal real_plus_minus_binom1_p aus expand_poly verwendet werden *)
  51.481 +
  51.482 +"-----SPB Schalk I p.64 No.306a ---";
  51.483 +val t = TermC.str2term "((x \<up> 2 + 1)*(x \<up> 2 - 1)) \<up> 2";
  51.484 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.485 +if UnparseC.term t = "1 + 2 * x \<up> 4 + 2 * - 2 * x \<up> 4 + x \<up> 8" then ()
  51.486 +else error "poly.sml: diff.behav. in 2 * x \<up> 4 + 2 * - 2 * x \<up> 4 = - 2 * x \<up> 4";
  51.487 +
  51.488 +(*WN071729 when reducing "rls reduce_012_" for Schaerding,
  51.489 +the above resulted in the term below ... but reduces from then correctly*)
  51.490 +val t = TermC.str2term "1 + 2 * x \<up> 4 + 2 * - 2 * x \<up> 4 + x \<up> 8";
  51.491 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.492 +if UnparseC.term t = "1 + - 2 * x \<up> 4 + x \<up> 8"
  51.493 +then () else error "poly.sml: diff.behav. in make_polynomial 9b";
  51.494 +
  51.495 +"-----SPB Schalk I p.64 No.296a ---";
  51.496 +val t = TermC.str2term "(x - a) \<up> 3";
  51.497 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.498 +
  51.499 +val NONE = eval_is_even "aaa" "bbb" (TermC.str2term "3::real") "ccc";
  51.500 +
  51.501 +if UnparseC.term t = "- 1 * a \<up> 3 + 3 * a \<up> 2 * x + - 3 * a * x \<up> 2 + x \<up> 3"
  51.502 +then () else error "poly.sml: diff.behav. in make_polynomial 10";
  51.503 +
  51.504 +"-----SPB Schalk I p.64 No.296c ---";
  51.505 +val t = TermC.str2term "(-3*x - 4*y) \<up> 3";
  51.506 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.507 +if UnparseC.term t = "- 27 * x \<up> 3 + - 108 * x \<up> 2 * y + - 144 * x * y \<up> 2 +\n- 64 * y \<up> 3"
  51.508 +then () else error "poly.sml: diff.behav. in make_polynomial 11";
  51.509 +
  51.510 +"-----SPB Schalk I p.62 No.242c ---";
  51.511 +val t = TermC.str2term "x \<up> (-4)*(x \<up> (-4)*y \<up> (- 2)) \<up> (- 1)*y \<up> (- 2)";
  51.512 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.513 +if UnparseC.term t = "1"
  51.514 +then () else error "poly.sml: diff.behav. in make_polynomial 12";
  51.515 +
  51.516 +"-----SPB Schalk I p.60 No.209a ---";
  51.517 +val t = TermC.str2term "a \<up> (7-x) * a \<up> x";
  51.518 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.519 +if UnparseC.term t = "a \<up> 7"
  51.520 +then () else error "poly.sml: diff.behav. in make_polynomial 13";
  51.521 +
  51.522 +"-----SPB Schalk I p.60 No.209d ---";
  51.523 +val t = TermC.str2term "d \<up> x * d \<up> (x+1) * d \<up> (2 - 2*x)";
  51.524 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.525 +if UnparseC.term t = "d \<up> 3"
  51.526 +then () else error "poly.sml: diff.behav. in make_polynomial 14";
  51.527 +
  51.528 +"-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------";
  51.529 +"-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------";
  51.530 +"-------- ?RL?Bsple bei denen es Probleme gibt--------------------------------------------------";
  51.531 +"-----Schalk I p.64 No.303 ---";
  51.532 +val t = TermC.str2term "(a + 2*b)*(a \<up> 2 + 4*b \<up> 2)*(a - 2*b) - (a - 6*b)*(a \<up> 2 + 36*b \<up> 2)*(a + 6*b)";
  51.533 +(*SOMETIMES LOOPS---------------------------------------------------------------------------\\*)
  51.534 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.535 +if UnparseC.term t = "1280 * b \<up> 4"
  51.536 +then () else error "poly.sml: diff.behav. in make_polynomial 14b";
  51.537 +(* Richtig - aber Binomische Formel wurde nicht verwendet! *)
  51.538 +(*SOMETIMES LOOPS--------------------------------------------------------------------------//*)
  51.539 +
  51.540 +"-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------";
  51.541 +"-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------";
  51.542 +"-------- Eigene Beispiele (Mathias Goldgruber) ------------------------------------------------";
  51.543 +"-----SPO ---";
  51.544 +val t = TermC.str2term "a + a + a";
  51.545 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.546 +if UnparseC.term t = "3 * a" then ()
  51.547 +else error "poly.sml: diff.behav. in make_polynomial 16";
  51.548 +"-----SPO ---";
  51.549 +val t = TermC.str2term "a + b + b + b";
  51.550 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.551 +if UnparseC.term t = "a + 3 * b" then ()
  51.552 +else error "poly.sml: diff.behav. in make_polynomial 17";
  51.553 +"-----SPO ---";
  51.554 +val t = TermC.str2term "b * a * a";
  51.555 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.556 +if UnparseC.term t = "a \<up> 2 * b" then ()
  51.557 +else error "poly.sml: diff.behav. in make_polynomial 21";
  51.558 +"-----SPO ---";
  51.559 +val t = TermC.str2term "(a \<up> 2) \<up> 3";
  51.560 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.561 +if UnparseC.term t = "a \<up> 6" then ()
  51.562 +else error "poly.sml: diff.behav. in make_polynomial 22";
  51.563 +"-----SPO ---";
  51.564 +val t = TermC.str2term "x \<up> 2 * y \<up> 2 + x * x \<up> 2 * y";
  51.565 +val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  51.566 +if UnparseC.term t = "x \<up> 3 * y + x \<up> 2 * y \<up> 2" then ()
  51.567 +else error "poly.sml: diff.behav. in make_polynomial 23";
  51.568 +"-----SPO ---";
  51.569 +val t = TermC.str2term "a * b * b \<up> (- 1) + a";
  51.570 +val SOME (t,_) = rewrite_set_ @{theory} false make_polynomial t; UnparseC.term t;
  51.571 +if UnparseC.term t = "2 * a" then ()
  51.572 +else error "poly.sml: diff.behav. in make_polynomial 25";
  51.573 +"-----SPO ---";
  51.574 +val t = TermC.str2term "a*c*b \<up> (2*n) + 3*a + 5*b \<up> (2*n)*c*b";
  51.575 +val SOME (t,_) = rewrite_set_ @{theory} false make_polynomial t; UnparseC.term t;
  51.576 +if UnparseC.term t = "3 * a + 5 * b \<up> (1 + 2 * n) * c + a * b \<up> (2 * n) * c"
  51.577 +then () else error "poly.sml: diff.behav. in make_polynomial 26";
  51.578 +
  51.579 +(*MG030627 -------------vvv-: Verschachtelte Terme -----------*)
  51.580 +"-----SPO ---";
  51.581 +val t = TermC.str2term "(1 + (x*y*a) + x) \<up> (1 + (x*y*a) + x)";
  51.582 +val SOME (t,_) = rewrite_set_ @{theory} false make_polynomial t;
  51.583 +if UnparseC.term t = "(1 + x + a * x * y) \<up> (1 + x + a * x * y)"
  51.584 +then () else error "poly.sml: diff.behav. in make_polynomial 27";(*SPO*)
  51.585 +
  51.586 +val t = TermC.str2term "(1 + x*(y*z)*zz) \<up> (1 + x*(y*z)*zz)";
  51.587 +val SOME (t,_) = rewrite_set_ @{theory} false make_polynomial t;
  51.588 +if UnparseC.term t = "(1 + x * y * z * zz) \<up> (1 + x * y * z * zz)"
  51.589 +then () else error "poly.sml: diff.behav. in make_polynomial 28";
  51.590 +
  51.591 +"-------- check pbl  'polynomial simplification' -----------------------------------------------";
  51.592 +"-------- check pbl  'polynomial simplification' -----------------------------------------------";
  51.593 +"-------- check pbl  'polynomial simplification' -----------------------------------------------";
  51.594 +val fmz = ["Term ((5*x \<up> 2 + 3) * (2*x \<up> 7 + 3) - (3*x \<up> 5 + 8) * (6*x \<up> 4 - 1))", "normalform N"];
  51.595 +"-----0 ---";
  51.596 +case Refine.refine fmz ["polynomial", "simplification"] of
  51.597 +    [M_Match.Matches (["polynomial", "simplification"], _)] => ()
  51.598 +  | _ => error "poly.sml diff.behav. in check pbl, Refine.refine";
  51.599 +(*...if there is an error, then ...*)
  51.600 +
  51.601 +"----- 1 ---";
  51.602 +(*default_print_depth 7;*)
  51.603 +val pbt = Problem.from_store ["polynomial", "simplification"];
  51.604 +(*default_print_depth 3;*)
  51.605 +(*if there is ...
  51.606 +> val M_Match.NoMatch' {Given=gi, Where=wh, Find=fi,...} = M_Match.match_pbl fmz pbt;
  51.607 +... then Rewrite.trace_on:*)
  51.608 +                           
  51.609 +"----- 2 ---";
  51.610 +Rewrite.trace_on := false; (*true false*)
  51.611 +M_Match.match_pbl fmz pbt;
  51.612 +Rewrite.trace_on := false; (*true false*)
  51.613 +(*... if there is no rewrite, then there is something wrong with prls*)
  51.614 +                              
  51.615 +"-----3 ---";
  51.616 +(*default_print_depth 7;*)
  51.617 +val prls = (#prls o Problem.from_store) ["polynomial", "simplification"];
  51.618 +(*default_print_depth 3;*)
  51.619 +val t = TermC.str2term "((5*x \<up> 2 + 3) * (2*x \<up> 7 + 3) - (3*x \<up> 5 + 8) * (6*x \<up> 4 - 1)) is_polyexp";
  51.620 +val SOME (t',_) = rewrite_set_ thy false prls t;
  51.621 +if t' = @{term True} then () 
  51.622 +else error "poly.sml: diff.behav. in check pbl 'polynomial..";
  51.623 +(*... if this works, but -- 1-- does still NOT work, check types:*)
  51.624 +
  51.625 +"-----4 ---";
  51.626 +(*show_types:=true;*)
  51.627 +(*
  51.628 +> val M_Match.NoMatch' {Given=gi, Where=wh, Find=fi,...} = M_Match.match_pbl fmz pbt;
  51.629 +val wh = [False "(t_::real => real) (is_polyexp::real)"]
  51.630 +...................... \<up> \<up> \<up>  \<up> ............... \<up> ^*)
  51.631 +val M_Match.Matches' _ = M_Match.match_pbl fmz pbt;
  51.632 +(*show_types:=false;*)
  51.633 +
  51.634 +
  51.635 +"-------- me 'poly. simpl.' Schalk I p.63 No.267b ----------------------------------------------";
  51.636 +"-------- me 'poly. simpl.' Schalk I p.63 No.267b ----------------------------------------------";
  51.637 +"-------- me 'poly. simpl.' Schalk I p.63 No.267b ----------------------------------------------";
  51.638 +val fmz = ["Term ((5*x \<up> 2 + 3) * (2*x \<up> 7 + 3) - (3*x \<up> 5 + 8) * (6*x \<up> 4 - 1))", "normalform N"];
  51.639 +val (dI',pI',mI') =
  51.640 +  ("Poly",["polynomial", "simplification"],
  51.641 +   ["simplification", "for_polynomials"]);
  51.642 +val p = e_pos'; val c = []; 
  51.643 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  51.644 +(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Add_Given "Term\n ((5 * x \<up> 2 + 3) * (2 * x \<up> 7 + 3) -\n  (3 * x \<up> 5 + 8) * (6 * x \<up> 4 - 1))"*)
  51.645 +(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Add_Find "normalform N"*)
  51.646 +
  51.647 +(*+* )if I_Model.to_string ctxt (get_obj g_pbl pt (fst p)) =
  51.648 +(*+*)  "[\n(0 ,[] ,false ,#Find ,Inc ??.Simplify.normalform ,(??.empty, [])), \n(1 ,[1] ,true ,#Given ,Cor ??.Simplify.Term\n ((5 * x \<up> 2 + 3) * (2 * x \<up> 7 + 3) -\n  (3 * x \<up> 5 + 8) * (6 * x \<up> 4 - 1)) ,(t_t, [(5 * x \<up> 2 + 3) * (2 * x \<up> 7 + 3) -\n(3 * x \<up> 5 + 8) * (6 * x \<up> 4 - 1)]))]"
  51.649 +(*+*)then () else error "No.267b: I_Model.T CHANGED";
  51.650 +( *+ ...could not be repaired in child of 7e314dd233fd ?!?*)
  51.651 +
  51.652 +(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*nxt = Specify_Theory "Poly"*)
  51.653 +(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Specify_Problem ["polynomial", "simplification"]*)
  51.654 +(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Specify_Method ["simplification", "for_polynomials"]*)
  51.655 +(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Apply_Method ["simplification", "for_polynomials"]*)
  51.656 +(*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Rewrite_Set "norm_Poly"*)
  51.657 +
  51.658 +(*+*)if f2str f = "(5 * x \<up> 2 + 3) * (2 * x \<up> 7 + 3) -\n(3 * x \<up> 5 + 8) * (6 * x \<up> 4 - 1)"
  51.659 +(*+*)then () else error "";
  51.660 +
  51.661 +(*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Empty_Tac: ERROR DETECTED Feb.2020*)
  51.662 +
  51.663 +(*+*)if f2str f = "17 + 15 * x \<up> 2 + - 48 * x \<up> 4 + 3 * x \<up> 5 + 6 * x \<up> 7 +\n- 8 * x \<up> 9"
  51.664 +(*+*)then () else error "poly.sml diff.behav. in me Schalk I p.63 No.267b - 1";
  51.665 +
  51.666 +(*[1], Res* )val (p,_,f,nxt,_,pt) = me nxt p c pt;( *SINCE Feb.2020 LItool.find_next_step without result*)
  51.667 +
  51.668 +
  51.669 +
  51.670 +"-------- interSteps for Schalk 299a -----------------------------------------------------------";
  51.671 +"-------- interSteps for Schalk 299a -----------------------------------------------------------";
  51.672 +"-------- interSteps for Schalk 299a -----------------------------------------------------------";
  51.673 +reset_states ();
  51.674 +CalcTree
  51.675 +[(["Term ((x - y)*(x + (y::real)))", "normalform N"], 
  51.676 +  ("Poly",["polynomial", "simplification"],
  51.677 +  ["simplification", "for_polynomials"]))];
  51.678 +Iterator 1;
  51.679 +moveActiveRoot 1;
  51.680 +autoCalculate 1 CompleteCalc;
  51.681 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  51.682 +
  51.683 +interSteps 1 ([1],Res)(*<ERROR> syserror in Detail_Step.go </ERROR>*);
  51.684 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  51.685 +if existpt' ([1,1], Frm) pt then ()
  51.686 +else error "poly.sml: interSteps doesnt work again 1";
  51.687 +
  51.688 +interSteps 1 ([1,1],Res)(*<ERROR> syserror in Detail_Step.go </ERROR>*);
  51.689 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  51.690 +(*============ inhibit exn WN120316 ==============================================
  51.691 +if existpt' ([1,1,1], Frm) pt then ()
  51.692 +else error "poly.sml: interSteps doesnt work again 2";
  51.693 +============ inhibit exn WN120316 ==============================================*)
  51.694 +
  51.695 +"-------- ord_make_polynomial ------------------------------------------------------------------";
  51.696 +"-------- ord_make_polynomial ------------------------------------------------------------------";
  51.697 +"-------- ord_make_polynomial ------------------------------------------------------------------";
  51.698 +val t1 = TermC.str2term "2 * b + (3 * a + 3 * b)";
  51.699 +val t2 = TermC.str2term "(3 * a + 3 * b) + 2 * b";
  51.700 +
  51.701 +if ord_make_polynomial true thy [] (t1, t2) then ()
  51.702 +else error "poly.sml: diff.behav. in ord_make_polynomial";
  51.703 +(*SO: WHY IS THERE NO REWRITING ...*)
  51.704 +
  51.705 +val term = TermC.str2term "2*b + (3*a + 3*b)";
  51.706 +(*+++*)val NONE = rewrite_set_ @{theory "Isac_Knowledge"} false order_add_mult term;
  51.707 +(* 
  51.708 +WHY IS THERE NO REWRITING ?!?
  51.709 +most likely reason: Poly.thy and Rationa.thy do AC rewriting in ML,
  51.710 +while order_add_mult uses isac's rewriter -- and this is used rarely!
  51.711 +*)
  51.712 +
    52.1 --- a/test/Tools/isac/Knowledge/poly.sml	Mon Jun 21 22:08:01 2021 +0200
    52.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.3 @@ -1,697 +0,0 @@
    52.4 -(* testexamples for Poly, polynomials
    52.5 -   author: Matthias Goldgruber 2003
    52.6 -   (c) due to copyright terms
    52.7 -
    52.8 -12345678901234567890123456789012345678901234567890123456789012345678901234567890
    52.9 -        10        20        30        40        50        60        70        80
   52.10 -LEGEND:
   52.11 -WN060104: examples marked with 'SPB' came into 'exp_IsacCore_Simp_Poly_Book.xml'
   52.12 -          examples marked with 'SPO' came into 'exp_IsacCore_Simp_Poly_Other.xml'
   52.13 -*)
   52.14 -
   52.15 -"--------------------------------------------------------";
   52.16 -"--------------------------------------------------------";
   52.17 -"table of contents --------------------------------------";
   52.18 -"--------------------------------------------------------";
   52.19 -"----------- fun is_polyexp --------------------------------------------------------------------";
   52.20 -"----------- fun has_degree_in -----------------------------------------------------------------";
   52.21 -"----------- fun mono_deg_in -------------------------------------------------------------------";
   52.22 -"----------- fun mono_deg_in -------------------------------------------------------------------";
   52.23 -"----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
   52.24 -"-------- investigate (new 2002) uniary minus -----------";
   52.25 -"-------- check make_polynomial with simple terms -------";
   52.26 -"-------- fun is_multUnordered --------------------------";
   52.27 -"-------- examples from textbook Schalk I ---------------";
   52.28 -"-------- check pbl  'polynomial simplification' --------";
   52.29 -"-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
   52.30 -"-------- interSteps for Schalk 299a --------------------";
   52.31 -"-------- norm_Poly NOT COMPLETE ------------------------";
   52.32 -"-------- ord_make_polynomial ---------------------------";
   52.33 -"--------------------------------------------------------";
   52.34 -"--------------------------------------------------------";
   52.35 -"--------------------------------------------------------";
   52.36 -
   52.37 -
   52.38 -"----------- fun is_polyexp --------------------------------------------------------------------";
   52.39 -"----------- fun is_polyexp --------------------------------------------------------------------";
   52.40 -"----------- fun is_polyexp --------------------------------------------------------------------";
   52.41 -val thy = @{theory Partial_Fractions};
   52.42 -val ctxt = Proof_Context.init_global thy;
   52.43 -
   52.44 -val t = (the o (parseNEW  ctxt)) "x / x";
   52.45 -if is_polyexp t then error "NOT is_polyexp (x / x)" else ();
   52.46 -
   52.47 -val t = (the o (parseNEW  ctxt)) "-1 * A * 3";
   52.48 -if is_polyexp t then () else error "is_polyexp (-1 * A * 3)";
   52.49 -
   52.50 -val t = (the o (parseNEW  ctxt)) "-1 * AA * 3";
   52.51 -if is_polyexp t then () else error "is_polyexp (-1 * AA * 3)";
   52.52 -
   52.53 -"----------- fun has_degree_in -----------------------------------------------------------------";
   52.54 -"----------- fun has_degree_in -----------------------------------------------------------------";
   52.55 -"----------- fun has_degree_in -----------------------------------------------------------------";
   52.56 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   52.57 -val t = (Thm.term_of o the o (TermC.parse thy)) "1";
   52.58 -if has_degree_in t v = 0 then () else error "has_degree_in (1) x";
   52.59 -
   52.60 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   52.61 -val t = (Thm.term_of o the o (TermC.parse thy)) "1";
   52.62 -if has_degree_in t v = 0 then () else error "has_degree_in (1) AA";
   52.63 -
   52.64 -(*----------*)
   52.65 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   52.66 -val t = (Thm.term_of o the o (TermC.parse thy)) "a*b+c";
   52.67 -if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) x";
   52.68 -
   52.69 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   52.70 -val t = (Thm.term_of o the o (TermC.parse thy)) "a*b+c";
   52.71 -if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) AA";
   52.72 -
   52.73 -(*----------*)
   52.74 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   52.75 -val t = (Thm.term_of o the o (TermC.parse thy)) "a*x+c";
   52.76 -if has_degree_in t v = ~1 then () else error "has_degree_in (a*x+c) x";
   52.77 -
   52.78 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   52.79 -val t = (Thm.term_of o the o (TermC.parse thy)) "a*AA+c";
   52.80 -if has_degree_in t v = ~1 then () else error "has_degree_in (a*AA+c) AA";
   52.81 -
   52.82 -(*----------*)
   52.83 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   52.84 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x \<up> 7";
   52.85 -if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*x \<up> 7) x";
   52.86 -
   52.87 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   52.88 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA \<up> 7";
   52.89 -if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*AA \<up> 7) AA";
   52.90 -
   52.91 -(*----------*)
   52.92 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
   52.93 -val t = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 7";
   52.94 -if has_degree_in t v = 7 then () else error "has_degree_in (x \<up> 7) x";
   52.95 -
   52.96 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
   52.97 -val t = (Thm.term_of o the o (TermC.parse thy)) "AA \<up> 7";
   52.98 -if has_degree_in t v = 7 then () else error "has_degree_in (AA \<up> 7) AA";
   52.99 -
  52.100 -(*----------*)
  52.101 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  52.102 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x";
  52.103 -if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*x) x";
  52.104 -
  52.105 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  52.106 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA";
  52.107 -if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*AA) AA";
  52.108 -
  52.109 -(*----------*)
  52.110 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  52.111 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+x)*x";
  52.112 -if has_degree_in t v = ~1 then () else error "has_degree_in (a*b+x)*x() x";
  52.113 -
  52.114 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  52.115 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+AA)*AA";
  52.116 -if has_degree_in t v = ~1 then () else error "has_degree_in ((a*b+AA)*AA) AA";
  52.117 -
  52.118 -(*----------*)
  52.119 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  52.120 -val t = (Thm.term_of o the o (TermC.parse thy)) "x";
  52.121 -if has_degree_in t v = 1 then () else error "has_degree_in (x) x";
  52.122 -
  52.123 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  52.124 -val t = (Thm.term_of o the o (TermC.parse thy)) "AA";
  52.125 -if has_degree_in t v = 1 then () else error "has_degree_in (AA) AA";
  52.126 -
  52.127 -(*----------*)
  52.128 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  52.129 -val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*x";
  52.130 -if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*x) x";
  52.131 -
  52.132 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  52.133 -val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*AA";
  52.134 -if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*AA) AA";
  52.135 -
  52.136 -"----------- fun mono_deg_in -------------------------------------------------------------------";
  52.137 -"----------- fun mono_deg_in -------------------------------------------------------------------";
  52.138 -"----------- fun mono_deg_in -------------------------------------------------------------------";
  52.139 -val v = (Thm.term_of o the o (TermC.parse thy)) "x";
  52.140 -
  52.141 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x \<up> 7";
  52.142 -if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*x \<up> 7) x changed";
  52.143 -
  52.144 -val t = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 7";
  52.145 -if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (x \<up> 7) x changed";
  52.146 -
  52.147 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x";
  52.148 -if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*x) x changed";
  52.149 -
  52.150 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+x)*x";
  52.151 -if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+x)*x) x changed";
  52.152 -
  52.153 -val t = (Thm.term_of o the o (TermC.parse thy)) "x";
  52.154 -if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (x) x changed";
  52.155 -
  52.156 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)";
  52.157 -if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) x changed";
  52.158 -
  52.159 -val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*x";
  52.160 -if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*x) x changed";
  52.161 -
  52.162 -(*. . . . . . . . . . . . the same with Const ("Partial_Functions.AA", _) . . . . . . . . . . . *)
  52.163 -val thy = @{theory Partial_Fractions}
  52.164 -val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
  52.165 -
  52.166 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA \<up> 7";
  52.167 -if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*AA \<up> 7) AA changed";
  52.168 -
  52.169 -val t = (Thm.term_of o the o (TermC.parse thy)) "AA \<up> 7";
  52.170 -if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (AA \<up> 7) AA changed";
  52.171 -
  52.172 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA";
  52.173 -if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*AA) AA changed";
  52.174 -
  52.175 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+AA)*AA";
  52.176 -if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+AA)*AA) AA changed";
  52.177 -
  52.178 -val t = (Thm.term_of o the o (TermC.parse thy)) "AA";
  52.179 -if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (AA) AA changed";
  52.180 -
  52.181 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)";
  52.182 -if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) AA changed";
  52.183 -
  52.184 -val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*AA";
  52.185 -if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*AA) AA changed";
  52.186 -
  52.187 -"----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
  52.188 -"----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
  52.189 -"----------- rewrite_set_ has_degree_in Const ('Partial_Fractions', _) -------------------------";
  52.190 -val thy = @{theory Partial_Fractions}
  52.191 -val expr = (Thm.term_of o the o (TermC.parse thy)) "((-8 - 2*x + x \<up> 2) has_degree_in x) = 2";
  52.192 -val SOME (Const (\<^const_name>\<open>True\<close>, _), []) = rewrite_set_ thy false PolyEq_prls expr;
  52.193 -
  52.194 -val expr = (Thm.term_of o the o (TermC.parse thy)) "((-8 - 2*AA + AA \<up> 2) has_degree_in AA) = 2";
  52.195 -val SOME (Const (\<^const_name>\<open>True\<close>, _), []) = rewrite_set_ thy false PolyEq_prls expr;
  52.196 -
  52.197 -"----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
  52.198 -"----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
  52.199 -"----------- eval_ for is_expanded_in, is_poly_in, has_degree_in -------------------------------";
  52.200 -val t = (Thm.term_of o the o (TermC.parse thy)) "(-8 - 2*x + x \<up> 2) is_expanded_in x";
  52.201 -val SOME (id, t') = eval_is_expanded_in 0 0 t 0;
  52.202 -if UnparseC.term t' = "-8 - 2 * x + x \<up> 2 is_expanded_in x = True"
  52.203 -         andalso id = "-8 - 2 * x + x \<up> 2 is_expanded_in x = True"
  52.204 -then () else error "eval_is_expanded_in x ..changed";
  52.205 -
  52.206 -val thy = @{theory Partial_Fractions}
  52.207 -val t = (Thm.term_of o the o (TermC.parse thy)) "(-8 - 2*AA + AA \<up> 2) is_expanded_in AA";
  52.208 -val SOME (id, t') = eval_is_expanded_in 0 0 t 0;
  52.209 -if  UnparseC.term t' = "-8 - 2 * AA + AA \<up> 2 is_expanded_in AA = True"
  52.210 -          andalso id = "-8 - 2 * AA + AA \<up> 2 is_expanded_in AA = True"
  52.211 -then () else error "eval_is_expanded_in AA ..changed";
  52.212 -
  52.213 -
  52.214 -val t = (Thm.term_of o the o (TermC.parse thy)) "(8 + 2*x + x \<up> 2) is_poly_in x";
  52.215 -val SOME (id, t') = eval_is_poly_in 0 0 t 0;
  52.216 -if  UnparseC.term t' = "8 + 2 * x + x \<up> 2 is_poly_in x = True"
  52.217 -          andalso id = "8 + 2 * x + x \<up> 2 is_poly_in x = True"
  52.218 -then () else error "is_poly_in x ..changed";
  52.219 -
  52.220 -val t = (Thm.term_of o the o (TermC.parse thy)) "(8 + 2*AA + AA \<up> 2) is_poly_in AA";
  52.221 -val SOME (id, t') = eval_is_poly_in 0 0 t 0;
  52.222 -if  UnparseC.term t' = "8 + 2 * AA + AA \<up> 2 is_poly_in AA = True"
  52.223 -          andalso id = "8 + 2 * AA + AA \<up> 2 is_poly_in AA = True"
  52.224 -then () else error "is_poly_in AA ..changed";
  52.225 -
  52.226 -
  52.227 -val thy = @{theory Partial_Fractions}
  52.228 -val expr = (Thm.term_of o the o (TermC.parse thy)) "((-8 - 2*x + x \<up> 2) has_degree_in x) = 2";
  52.229 -val SOME (Const (\<^const_name>\<open>True\<close>, _), []) = rewrite_set_ thy false PolyEq_prls expr;
  52.230 -
  52.231 -val expr = (Thm.term_of o the o (TermC.parse thy)) "((-8 - 2*AA + AA \<up> 2) has_degree_in AA) = 2";
  52.232 -val SOME (Const (\<^const_name>\<open>True\<close>, _), []) = rewrite_set_ thy false PolyEq_prls expr;
  52.233 -
  52.234 -"-------- investigate (new 2002) uniary minus -----------";
  52.235 -"-------- investigate (new 2002) uniary minus -----------";
  52.236 -"-------- investigate (new 2002) uniary minus -----------";
  52.237 -(*---------------------------------------------- vvvvvvvvvvvvvv -----------------------*)
  52.238 -val t = Thm.prop_of @{thm real_diff_0}; (*"0 - ?x = - ?x"*)
  52.239 -TermC.atomty t;
  52.240 -(*
  52.241 -*** Const (HOL.Trueprop, bool => prop)
  52.242 -*** . Const (HOL.eq, real => real => bool)
  52.243 -*** . . Const (Groups.minus_class.minus, real => real => real)
  52.244 -*** . . . Const (Groups.zero_class.zero, real)
  52.245 -*** . . . Var ((x, 0), real)
  52.246 -*** . . Const (Groups.uminus_class.uminus, real => real)
  52.247 -*** . . . Var ((x, 0), real)
  52.248 -*)
  52.249 -case t of
  52.250 -  Const (\<^const_name>\<open>Trueprop\<close>, _) $
  52.251 -    (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ 
  52.252 -      (Const (\<^const_name>\<open>minus\<close>, _) $ Const (\<^const_name>\<open>Groups.zero\<close>, _) $ 
  52.253 -        Var (("x", 0), _)) $
  52.254 -             (Const (\<^const_name>\<open>uminus\<close>, _) $ Var (("x", 0), _))) => ()
  52.255 -| _ => error "internal representation of \"0 - ?x = - ?x\" changed";
  52.256 -
  52.257 -(*----------------------------------- vvvv --------------------------------------------*)
  52.258 -val t = (Thm.term_of o the o (TermC.parse thy)) "-1";
  52.259 -TermC.atomty t;
  52.260 -(*** -------------
  52.261 -*** Free ( -1, real)                      *)
  52.262 -case t of
  52.263 -  Free ("-1", _) => ()
  52.264 -| _ => error "internal representation of \"-1\" changed";
  52.265 -(*----------------------------------- vvvvv -------------------------------------------*)
  52.266 -val t = (Thm.term_of o the o (TermC.parse thy)) "- 1";
  52.267 -TermC.atomty t;
  52.268 -(*
  52.269 -*** 
  52.270 -*** Free (-1, real)
  52.271 -*** 
  52.272 -*)
  52.273 -case t of
  52.274 - Free ("-1", _) => ()
  52.275 -| _ => error "internal representation of \"- 1\" changed";
  52.276 -
  52.277 -"======= these external values all have the same internal representation";
  52.278 -(* "1-x" causes syntyx error --- binary minus detected by blank inbetween !!!*)
  52.279 -(*----------------------------------- vvvvv -------------------------------------------*)
  52.280 -val t = (Thm.term_of o the o (TermC.parse thy)) "-x";
  52.281 -TermC.atomty t;
  52.282 -(**** -------------
  52.283 -*** Free ( -x, real)*)
  52.284 -case t of
  52.285 -  Const (\<^const_name>\<open>uminus\<close>, _) $ Free ("x", _) => ()
  52.286 -| _ => error "internal representation of \"-x\" changed";
  52.287 -(*----------------------------------- vvvvv -------------------------------------------*)
  52.288 -val t = (Thm.term_of o the o (TermC.parse thy)) "- x";
  52.289 -TermC.atomty t;
  52.290 -(**** -------------
  52.291 -*** Free ( -x, real) !!!!!!!!!!!!!!!!!!!!!!!! is the same !!!*)
  52.292 -case t of
  52.293 -  Const (\<^const_name>\<open>uminus\<close>, _) $ Free ("x", _) => ()
  52.294 -| _ => error "internal representation of \"- x\" changed";
  52.295 -(*----------------------------------- vvvvvv ------------------------------------------*)
  52.296 -val t = (Thm.term_of o the o (TermC.parse thy)) "-(x)";
  52.297 -TermC.atomty t;
  52.298 -(**** -------------
  52.299 -*** Free ( -x, real)*)
  52.300 -case t of
  52.301 -  Const (\<^const_name>\<open>uminus\<close>, _) $ Free ("x", _) => ()
  52.302 -| _ => error "internal representation of \"-(x)\" changed";
  52.303 -
  52.304 -"-------- check make_polynomial with simple terms -------";
  52.305 -"-------- check make_polynomial with simple terms -------";
  52.306 -"-------- check make_polynomial with simple terms -------";
  52.307 -"----- check 1 ---";
  52.308 -val t = TermC.str2term "2*3*a";
  52.309 -val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  52.310 -if UnparseC.term t = "6 * a" then () else error "check make_polynomial 1";
  52.311 -
  52.312 -"----- check 2 ---";
  52.313 -val t = TermC.str2term "2*a + 3*a";
  52.314 -val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  52.315 -if UnparseC.term t = "5 * a" then () else error "check make_polynomial 2";
  52.316 -
  52.317 -"----- check 3 ---";
  52.318 -val t = TermC.str2term "2*a + 3*a + 3*a";
  52.319 -val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  52.320 -if UnparseC.term t = "8 * a" then () else error "check make_polynomial 3";
  52.321 -
  52.322 -"----- check 4 ---";
  52.323 -val t = TermC.str2term "3*a - 2*a";
  52.324 -val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  52.325 -if UnparseC.term t = "a" then () else error "check make_polynomial 4";
  52.326 -
  52.327 -"----- check 5 ---";
  52.328 -val t = TermC.str2term "4*(3*a - 2*a)";
  52.329 -val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  52.330 -if UnparseC.term t = "4 * a" then () else error "check make_polynomial 5";
  52.331 -
  52.332 -"----- check 6 ---";
  52.333 -val t = TermC.str2term "4*(3*a \<up> 2 - 2*a \<up> 2)";
  52.334 -val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  52.335 -if UnparseC.term t = "4 * a \<up> 2" then () else error "check make_polynomial 6";
  52.336 -
  52.337 -"-------- fun is_multUnordered --------------------------";
  52.338 -"-------- fun is_multUnordered --------------------------";
  52.339 -"-------- fun is_multUnordered --------------------------";
  52.340 -val thy = @{theory "Isac_Knowledge"};
  52.341 -"===== works for a simple example, see rewrite.sml -- fun app_rev ===";
  52.342 -val t = TermC.str2term "x \<up> 2 * x";
  52.343 -val SOME (t', _) = rewrite_set_ thy true order_mult_ t;
  52.344 -if UnparseC.term t' = "x * x \<up> 2" then ()
  52.345 -else error "poly.sml Poly.is_multUnordered doesn't work";
  52.346 -
  52.347 -(* 100928 Rewrite.trace_on shows the first occurring difference in 267b:
  52.348 -###  rls: order_mult_ on: 5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (-1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + -1 * (3 * x \<up> 5 * -1) +
  52.349 - (-48 * x \<up> 4 + 8))
  52.350 -######  rls: Rule_Set.empty-is_multUnordered on: p is_multUnordered
  52.351 -#######  try calc: Poly.is_multUnordered'
  52.352 -=======  calc. to: False  !!!!!!!!!!!!! INSTEAD OF TRUE in 2002 !!!!!!!!!!!!!
  52.353 -*)
  52.354 -val t = TermC.str2term "5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (-1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + -1 * (3 * x \<up> 5 * -1) +  (-48 * x \<up> 4 + 8))";
  52.355 -
  52.356 -"----- is_multUnordered ---";
  52.357 -val tsort = sort_variables t;
  52.358 -UnparseC.term tsort = "2 * (5 * (x \<up> 2 * x \<up> 7)) + 3 * (5 * x \<up> 2) + 6 * x \<up> 7 + 9 +\n-1 * (3 * (6 * (x \<up> 4 * x \<up> 5))) +\n-1 * (-1 * (3 * x \<up> 5)) +\n-48 * x \<up> 4 +\n8";
  52.359 -is_polyexp t;
  52.360 -tsort = t;
  52.361 -is_polyexp t andalso not (t = sort_variables t);
  52.362 -if is_multUnordered t then () else error "poly.sml diff. is_multUnordered 1";
  52.363 -
  52.364 -"----- eval_is_multUnordered ---";
  52.365 -val tm = TermC.str2term "(5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (-1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + -1 * (3 * x \<up> 5 * -1) +  (-48 * x \<up> 4 + 8))) is_multUnordered";
  52.366 -case eval_is_multUnordered "testid" "" tm thy of
  52.367 -    SOME (_, Const (\<^const_name>\<open>Trueprop\<close>, _) $ 
  52.368 -                   (Const (\<^const_name>\<open>HOL.eq\<close>, _) $
  52.369 -                          (Const ("Poly.is_multUnordered", _) $ _) $ 
  52.370 -                          Const (\<^const_name>\<open>True\<close>, _))) => ()
  52.371 -  | _ => error "poly.sml diff. eval_is_multUnordered";
  52.372 -
  52.373 -"----- rewrite_set_ STILL DIDN'T WORK";
  52.374 -val SOME (t, _) = rewrite_set_ thy true order_mult_ t;
  52.375 -UnparseC.term t;
  52.376 -
  52.377 -"-------- examples from textbook Schalk I ---------------";
  52.378 -"-------- examples from textbook Schalk I ---------------";
  52.379 -"-------- examples from textbook Schalk I ---------------";
  52.380 -"-----SPB Schalk I p.63 No.267b ---";
  52.381 -(*associate poly* )
  52.382 -val t = TermC.str2term "(5*x \<up> 2 + 3) * (2*x \<up> 7 + 3) - (3*x \<up> 5 + 8) * (6*x \<up> 4 - 1)";
  52.383 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.384 -if (UnparseC.term t) = "17 + 15 * x \<up> 2 + -48 * x \<up> 4 + 3 * x \<up> 5 + 6 * x \<up> 7 + -8 * x \<up> 9"
  52.385 -then () else error "poly.sml: diff.behav. in make_polynomial 1";
  52.386 -
  52.387 -"-----SPB Schalk I p.63 No.275b ---";
  52.388 -val t = TermC.str2term "(3*x \<up> 2 - 2*x*y + y \<up> 2) * (x \<up> 2 - 2*y \<up> 2)";
  52.389 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.390 -if (UnparseC.term t) = ("3 * x \<up> 4 + -2 * x \<up> 3 * y + -5 * x \<up> 2 * y \<up> 2 + " ^
  52.391 -  "4 * x * y \<up> 3 +\n-2 * y \<up> 4")
  52.392 -then () else error "poly.sml: diff.behav. in make_polynomial 2";
  52.393 -
  52.394 -"-----SPB Schalk I p.63 No.279b ---";
  52.395 -val t = TermC.str2term "(x-a)*(x-b)*(x-c)*(x-d)";
  52.396 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.397 -if (UnparseC.term t) = 
  52.398 -  ("a * b * c * d + -1 * a * b * c * x + -1 * a * b * d * x + a * b * x \<up> 2 +\n" ^
  52.399 -  "-1 * a * c * d * x +\na * c * x \<up> 2 +\na * d * x \<up> 2 +\n-1 * a * x \<up> 3 +\n" ^
  52.400 -  "-1 * b * c * d * x +\nb * c * x \<up> 2 +\nb * d * x \<up> 2 +\n-1 * b * x \<up> 3 +\n" ^
  52.401 -  "c * d * x \<up> 2 +\n-1 * c * x \<up> 3 +\n-1 * d * x \<up> 3 +\nx \<up> 4")
  52.402 -then () else error "poly.sml: diff.behav. in make_polynomial 3";
  52.403 -( *associate poly*)
  52.404 -
  52.405 -"-----SPB Schalk I p.63 No.291 ---";
  52.406 -val t = TermC.str2term "(5+96*x \<up> 3+8*x*(-4+(7- 3*x)*4*x))*(5*(2- 3*x)- (-15*x*(-8*x- 5)))";
  52.407 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.408 -if (UnparseC.term t) = "50 + -770 * x + 4520 * x \<up> 2 + -16320 * x \<up> 3 + -26880 * x \<up> 4"
  52.409 -then () else error "poly.sml: diff.behav. in make_polynomial 4";
  52.410 -
  52.411 -(*associate poly* )
  52.412 -"-----SPB Schalk I p.64 No.295c ---";
  52.413 -val t = TermC.str2term "(13*a \<up> 4*b \<up> 9*c - 12*a \<up> 3*b \<up> 6*c \<up> 9) \<up> 2";
  52.414 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.415 -if (UnparseC.term t) = ("169 * a \<up> 8 * b \<up> 18 * c \<up> 2 + -312 * a \<up> 7 * b \<up> 15 * c \<up> 10" ^
  52.416 -  " +\n144 * a \<up> 6 * b \<up> 12 * c \<up> 18")
  52.417 -then ()else error "poly.sml: diff.behav. in make_polynomial 5";
  52.418 -( *associate poly*)
  52.419 -
  52.420 -"-----SPB Schalk I p.64 No.299a ---";
  52.421 -val t = TermC.str2term "(x - y)*(x + y)";
  52.422 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.423 -if (UnparseC.term t) = "x \<up> 2 + -1 * y \<up> 2"
  52.424 -then () else error "poly.sml: diff.behav. in make_polynomial 6";
  52.425 -
  52.426 -"-----SPB Schalk I p.64 No.300c ---";
  52.427 -val t = TermC.str2term "(3*x \<up> 2*y - 1)*(3*x \<up> 2*y + 1)";
  52.428 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.429 -if (UnparseC.term t) = "-1 + 9 * x \<up> 4 * y \<up> 2"
  52.430 -then () else error "poly.sml: diff.behav. in make_polynomial 7";
  52.431 -
  52.432 -"-----SPB Schalk I p.64 No.302 ---";
  52.433 -val t = TermC.str2term
  52.434 -  "(13*x \<up> 2 + 5)*(13*x \<up> 2 - 5) - (5*x \<up> 2 + 3)*(5*x \<up> 2 - 3) - (12*x \<up> 2 + 4)*(12*x \<up> 2 - 4)";
  52.435 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.436 -if UnparseC.term t = "0"
  52.437 -then () else error "poly.sml: diff.behav. in make_polynomial 8";
  52.438 -(* RL?MG?: Bei Berechnung sollte 3 mal real_plus_minus_binom1_p aus expand_poly verwendet werden *)
  52.439 -
  52.440 -"-----SPB Schalk I p.64 No.306a ---";
  52.441 -val t = TermC.str2term "((x \<up> 2 + 1)*(x \<up> 2 - 1)) \<up> 2";
  52.442 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.443 -if (UnparseC.term t) = "1 + 2 * x \<up> 4 + 2 * -2 * x \<up> 4 + x \<up> 8" then ()
  52.444 -else error "poly.sml: diff.behav. in 2 * x \<up> 4 + 2 * -2 * x \<up> 4 = -2 * x \<up> 4";
  52.445 -
  52.446 -(*WN071729 when reducing "rls reduce_012_" for Schaerding,
  52.447 -the above resulted in the term below ... but reduces from then correctly*)
  52.448 -val t = TermC.str2term "1 + 2 * x \<up> 4 + 2 * -2 * x \<up> 4 + x \<up> 8";
  52.449 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.450 -if (UnparseC.term t) = "1 + -2 * x \<up> 4 + x \<up> 8"
  52.451 -then () else error "poly.sml: diff.behav. in make_polynomial 9b";
  52.452 -
  52.453 -"-----SPB Schalk I p.64 No.296a ---";
  52.454 -val t = TermC.str2term "(x - a) \<up> 3";
  52.455 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.456 -if (UnparseC.term t) = "-1 * a \<up> 3 + 3 * a \<up> 2 * x + -3 * a * x \<up> 2 + x \<up> 3"
  52.457 -then () else error "poly.sml: diff.behav. in make_polynomial 10";
  52.458 -
  52.459 -"-----SPB Schalk I p.64 No.296c ---";
  52.460 -val t = TermC.str2term "(-3*x - 4*y) \<up> 3";
  52.461 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.462 -if (UnparseC.term t) = "-27 * x \<up> 3 + -108 * x \<up> 2 * y + -144 * x * y \<up> 2 +\n-64 * y \<up> 3"
  52.463 -then () else error "poly.sml: diff.behav. in make_polynomial 11";
  52.464 -
  52.465 -"-----SPB Schalk I p.62 No.242c ---";
  52.466 -val t = TermC.str2term "x \<up> (-4)*(x \<up> (-4)*y \<up> (-2)) \<up> (-1)*y \<up> (-2)";
  52.467 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.468 -if (UnparseC.term t) = "1"
  52.469 -then () else error "poly.sml: diff.behav. in make_polynomial 12";
  52.470 -
  52.471 -"-----SPB Schalk I p.60 No.209a ---";
  52.472 -val t = TermC.str2term "a \<up> (7-x) * a \<up> x";
  52.473 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.474 -if UnparseC.term t = "a \<up> 7"
  52.475 -then () else error "poly.sml: diff.behav. in make_polynomial 13";
  52.476 -
  52.477 -"-----SPB Schalk I p.60 No.209d ---";
  52.478 -val t = TermC.str2term "d \<up> x * d \<up> (x+1) * d \<up> (2 - 2*x)";
  52.479 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.480 -if UnparseC.term t = "d \<up> 3"
  52.481 -then () else error "poly.sml: diff.behav. in make_polynomial 14";
  52.482 -
  52.483 -(*---------------------------------------------------------------------*)
  52.484 -(*---------------- ?RL?Bsple bei denen es Probleme gibt----------------*)
  52.485 -(*---------------------------------------------------------------------*)
  52.486 -"-----Schalk I p.64 No.303 ---";
  52.487 -val t = TermC.str2term "(a + 2*b)*(a \<up> 2 + 4*b \<up> 2)*(a - 2*b) - (a - 6*b)*(a \<up> 2 + 36*b \<up> 2)*(a + 6*b)";
  52.488 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.489 -if UnparseC.term t = "1280 * b \<up> 4"
  52.490 -then () else error "poly.sml: diff.behav. in make_polynomial 14b";
  52.491 -(* Richtig - aber Binomische Formel wurde nicht verwendet! *)
  52.492 -
  52.493 -(*--------------------------------------------------------------------*)
  52.494 -(*----------------------- Eigene Beispiele ---------------------------*)
  52.495 -(*--------------------------------------------------------------------*)
  52.496 -"-----SPO ---";
  52.497 -val t = TermC.str2term "a \<up> 2*a \<up> (-2)";
  52.498 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.499 -if UnparseC.term t = "1" then ()
  52.500 -else error "poly.sml: diff.behav. in make_polynomial 15";
  52.501 -"-----SPO ---";
  52.502 -val t = TermC.str2term "a + a + a";
  52.503 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.504 -if UnparseC.term t = "3 * a" then ()
  52.505 -else error "poly.sml: diff.behav. in make_polynomial 16";
  52.506 -"-----SPO ---";
  52.507 -val t = TermC.str2term "a + b + b + b";
  52.508 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.509 -if UnparseC.term t = "a + 3 * b" then ()
  52.510 -else error "poly.sml: diff.behav. in make_polynomial 17";
  52.511 -"-----SPO ---";
  52.512 -val t = TermC.str2term "a \<up> 2*b*b \<up> (-1)";
  52.513 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.514 -if UnparseC.term t = "a \<up> 2" then ()
  52.515 -else error "poly.sml: diff.behav. in make_polynomial 18";
  52.516 -"-----SPO ---";
  52.517 -val t = TermC.str2term "a \<up> 2*a \<up> (-2)";
  52.518 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.519 -if (UnparseC.term t) = "1" then ()
  52.520 -else error "poly.sml: diff.behav. in make_polynomial 19";
  52.521 -"-----SPO ---";
  52.522 -val t = TermC.str2term "b + a - b";
  52.523 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.524 -if (UnparseC.term t) = "a" then ()
  52.525 -else error "poly.sml: diff.behav. in make_polynomial 20";
  52.526 -"-----SPO ---";
  52.527 -val t = TermC.str2term "b * a * a";
  52.528 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.529 -if UnparseC.term t = "a \<up> 2 * b" then ()
  52.530 -else error "poly.sml: diff.behav. in make_polynomial 21";
  52.531 -"-----SPO ---";
  52.532 -val t = TermC.str2term "(a \<up> 2) \<up> 3";
  52.533 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.534 -if UnparseC.term t = "a \<up> 6" then ()
  52.535 -else error "poly.sml: diff.behav. in make_polynomial 22";
  52.536 -"-----SPO ---";
  52.537 -val t = TermC.str2term "x \<up> 2 * y \<up> 2 + x * x \<up> 2 * y";
  52.538 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.539 -if UnparseC.term t = "x \<up> 3 * y + x \<up> 2 * y \<up> 2" then ()
  52.540 -else error "poly.sml: diff.behav. in make_polynomial 23";
  52.541 -"-----SPO ---";
  52.542 -val t = (Thm.term_of o the o (TermC.parse thy)) "a \<up> 2 * (-a) \<up> 2";
  52.543 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.544 -if (UnparseC.term t) = "a \<up> 4" then ()
  52.545 -else error "poly.sml: diff.behav. in make_polynomial 24";
  52.546 -"-----SPO ---";
  52.547 -val t = TermC.str2term "a * b * b \<up> (-1) + a";
  52.548 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.549 -if (UnparseC.term t) = "2 * a" then ()
  52.550 -else error "poly.sml: diff.behav. in make_polynomial 25";
  52.551 -"-----SPO ---";
  52.552 -val t = TermC.str2term "a*c*b \<up> (2*n) + 3*a + 5*b \<up> (2*n)*c*b";
  52.553 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
  52.554 -if (UnparseC.term t) = "3 * a + 5 * b \<up> (1 + 2 * n) * c + a * b \<up> (2 * n) * c"
  52.555 -then () else error "poly.sml: diff.behav. in make_polynomial 26";
  52.556 -
  52.557 -(*MG030627 -------------vvv-: Verschachtelte Terme -----------*)
  52.558 -"-----SPO ---";
  52.559 -val t = TermC.str2term "(1 + (x*y*a) + x) \<up> (1 + (x*y*a) + x)";
  52.560 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.561 -if UnparseC.term t = "(1 + x + a * x * y) \<up> (1 + x + a * x * y)"
  52.562 -then () else error "poly.sml: diff.behav. in make_polynomial 27";(*SPO*)
  52.563 -
  52.564 -val t = TermC.str2term "(1 + x*(y*z)*zz) \<up> (1 + x*(y*z)*zz)";
  52.565 -val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
  52.566 -if UnparseC.term t = "(1 + x * y * z * zz) \<up> (1 + x * y * z * zz)"
  52.567 -then () else error "poly.sml: diff.behav. in make_polynomial 28";
  52.568 -
  52.569 -"-------- check pbl  'polynomial simplification' --------";
  52.570 -"-------- check pbl  'polynomial simplification' --------";
  52.571 -"-------- check pbl  'polynomial simplification' --------";
  52.572 -val fmz = ["Term ((5*x \<up> 2 + 3) * (2*x \<up> 7 + 3) - (3*x \<up> 5 + 8) * (6*x \<up> 4 - 1))", "normalform N"];
  52.573 -"-----0 ---";
  52.574 -case Refine.refine fmz ["polynomial", "simplification"]of
  52.575 -    [M_Match.Matches (["polynomial", "simplification"], _)] => ()
  52.576 -  | _ => error "poly.sml diff.behav. in check pbl, Refine.refine";
  52.577 -(*...if there is an error, then ...*)
  52.578 -
  52.579 -"-----1 ---";
  52.580 -(*default_print_depth 7;*)
  52.581 -val pbt = Problem.from_store ["polynomial", "simplification"];
  52.582 -(*default_print_depth 3;*)
  52.583 -(*if there is ...
  52.584 -> val M_Match.NoMatch' {Given=gi, Where=wh, Find=fi,...} = M_Match.match_pbl fmz pbt;
  52.585 -... then Rewrite.trace_on:*)
  52.586 -                           
  52.587 -"-----2 ---";
  52.588 -Rewrite.trace_on := false;
  52.589 -M_Match.match_pbl fmz pbt;
  52.590 -Rewrite.trace_on := false;
  52.591 -(*... if there is no rewrite, then there is something wrong with prls*)
  52.592 -                              
  52.593 -"-----3 ---";
  52.594 -(*default_print_depth 7;*)
  52.595 -val prls = (#prls o Problem.from_store) ["polynomial", "simplification"];
  52.596 -(*default_print_depth 3;*)
  52.597 -val t = TermC.str2term "((5*x \<up> 2 + 3) * (2*x \<up> 7 + 3) - (3*x \<up> 5 + 8) * (6*x \<up> 4 - 1)) is_polyexp";
  52.598 -val SOME (t',_) = rewrite_set_ thy false prls t;
  52.599 -if t' = @{term True} then () 
  52.600 -else error "poly.sml: diff.behav. in check pbl 'polynomial..";
  52.601 -(*... if this works, but --1-- does still NOT work, check types:*)
  52.602 -
  52.603 -"-----4 ---";
  52.604 -(*show_types:=true;*)
  52.605 -(*
  52.606 -> val M_Match.NoMatch' {Given=gi, Where=wh, Find=fi,...} = M_Match.match_pbl fmz pbt;
  52.607 -val wh = [False "(t_::real => real) (is_polyexp::real)"]
  52.608 -...................... \<up> \<up> \<up>  \<up> ............... \<up> ^*)
  52.609 -val M_Match.Matches' _ = M_Match.match_pbl fmz pbt;
  52.610 -(*show_types:=false;*)
  52.611 -
  52.612 -
  52.613 -"-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
  52.614 -"-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
  52.615 -"-------- me 'poly. simpl.' Schalk I p.63 No.267b -------";
  52.616 -val fmz = ["Term ((5*x \<up> 2 + 3) * (2*x \<up> 7 + 3) - (3*x \<up> 5 + 8) * (6*x \<up> 4 - 1))", "normalform N"];
  52.617 -val (dI',pI',mI') =
  52.618 -  ("Poly",["polynomial", "simplification"],
  52.619 -   ["simplification", "for_polynomials"]);
  52.620 -val p = e_pos'; val c = []; 
  52.621 -val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  52.622 -(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Add_Given "Term\n ((5 * x \<up> 2 + 3) * (2 * x \<up> 7 + 3) -\n  (3 * x \<up> 5 + 8) * (6 * x \<up> 4 - 1))"*)
  52.623 -(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Add_Find "normalform N"*)
  52.624 -
  52.625 -(*+* )if I_Model.to_string ctxt (get_obj g_pbl pt (fst p)) =
  52.626 -(*+*)  "[\n(0 ,[] ,false ,#Find ,Inc ??.Simplify.normalform ,(??.empty, [])), \n(1 ,[1] ,true ,#Given ,Cor ??.Simplify.Term\n ((5 * x \<up> 2 + 3) * (2 * x \<up> 7 + 3) -\n  (3 * x \<up> 5 + 8) * (6 * x \<up> 4 - 1)) ,(t_t, [(5 * x \<up> 2 + 3) * (2 * x \<up> 7 + 3) -\n(3 * x \<up> 5 + 8) * (6 * x \<up> 4 - 1)]))]"
  52.627 -(*+*)then () else error "No.267b: I_Model.T CHANGED";
  52.628 -( *+ ...could not be repaired in child of 7e314dd233fd ?!?*)
  52.629 -
  52.630 -(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*nxt = Specify_Theory "Poly"*)
  52.631 -(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Specify_Problem ["polynomial", "simplification"]*)
  52.632 -(*[], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Specify_Method ["simplification", "for_polynomials"]*)
  52.633 -(*[], Met*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Apply_Method ["simplification", "for_polynomials"]*)
  52.634 -(*[1], Frm*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Rewrite_Set "norm_Poly"*)
  52.635 -
  52.636 -(*+*)if f2str f = "(5 * x \<up> 2 + 3) * (2 * x \<up> 7 + 3) -\n(3 * x \<up> 5 + 8) * (6 * x \<up> 4 - 1)"
  52.637 -(*+*)then () else error "";
  52.638 -
  52.639 -(*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p c pt;(*Empty_Tac: ERROR DETECTED Feb.2020*)
  52.640 -
  52.641 -(*+*)if f2str f = "17 + 15 * x \<up> 2 + -48 * x \<up> 4 + 3 * x \<up> 5 + 6 * x \<up> 7 +\n-8 * x \<up> 9"
  52.642 -(*+*)then () else error "poly.sml diff.behav. in me Schalk I p.63 No.267b -1";
  52.643 -
  52.644 -(*[1], Res* )val (p,_,f,nxt,_,pt) = me nxt p c pt;( *SINCE Feb.2020 LItool.find_next_step without result*)
  52.645 -
  52.646 -
  52.647 -
  52.648 -"-------- interSteps for Schalk 299a --------------------";
  52.649 -"-------- interSteps for Schalk 299a --------------------";
  52.650 -"-------- interSteps for Schalk 299a --------------------";
  52.651 -reset_states ();
  52.652 -CalcTree
  52.653 -[(["Term ((x - y)*(x + (y::real)))", "normalform N"], 
  52.654 -  ("Poly",["polynomial", "simplification"],
  52.655 -  ["simplification", "for_polynomials"]))];
  52.656 -Iterator 1;
  52.657 -moveActiveRoot 1;
  52.658 -autoCalculate 1 CompleteCalc;
  52.659 -val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  52.660 -
  52.661 -interSteps 1 ([1],Res)(*<ERROR> syserror in Detail_Step.go </ERROR>*);
  52.662 -val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  52.663 -if existpt' ([1,1], Frm) pt then ()
  52.664 -else error "poly.sml: interSteps doesnt work again 1";
  52.665 -
  52.666 -interSteps 1 ([1,1],Res)(*<ERROR> syserror in Detail_Step.go </ERROR>*);
  52.667 -val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  52.668 -(*============ inhibit exn WN120316 ==============================================
  52.669 -if existpt' ([1,1,1], Frm) pt then ()
  52.670 -else error "poly.sml: interSteps doesnt work again 2";
  52.671 -============ inhibit exn WN120316 ==============================================*)
  52.672 -
  52.673 -"-------- norm_Poly NOT COMPLETE ------------------------";
  52.674 -"-------- norm_Poly NOT COMPLETE ------------------------";
  52.675 -"-------- norm_Poly NOT COMPLETE ------------------------";
  52.676 -val thy = @{theory AlgEin};
  52.677 -
  52.678 -val SOME (f',_) = rewrite_set_ thy false norm_Poly
  52.679 -(TermC.str2term "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben");
  52.680 -if UnparseC.term f' = "L = senkrecht + oben + 2 * 2 * k + 2 * -4 * q"
  52.681 -then ((*norm_Poly NOT COMPLETE -- TODO MG*))
  52.682 -else error "norm_Poly changed behavior";
  52.683 -
  52.684 -"-------- ord_make_polynomial ---------------------------";
  52.685 -"-------- ord_make_polynomial ---------------------------";
  52.686 -"-------- ord_make_polynomial ---------------------------";
  52.687 -val t1 = TermC.str2term "2 * b + (3 * a + 3 * b)";
  52.688 -val t2 = TermC.str2term "3 * a + 3 * b + 2 * b";
  52.689 -
  52.690 -if ord_make_polynomial true thy [] (t1, t2) then ()
  52.691 -else error "poly.sml: diff.behav. in ord_make_polynomial";
  52.692 -
  52.693 -(*WN071202: \<up> why then is there no rewriting ...*)
  52.694 -val term = TermC.str2term "2*b + (3*a + 3*b)";
  52.695 -val NONE = rewrite_set_ (@{theory "Isac_Knowledge"}) false order_add_mult term;
  52.696 -
  52.697 -(*or why is there no rewriting this way...*)
  52.698 -val t1 = TermC.str2term "2 * b + (3 * a + 3 * b)";
  52.699 -val t2 = TermC.str2term "3 * a + (2 * b + 3 * b)";
  52.700 -
    53.1 --- a/test/Tools/isac/Knowledge/polyeq-1.sml	Mon Jun 21 22:08:01 2021 +0200
    53.2 +++ b/test/Tools/isac/Knowledge/polyeq-1.sml	Sun Jul 18 18:15:27 2021 +0200
    53.3 @@ -1,4 +1,4 @@
    53.4 -(* Title:  Knowledge/polyeq-1.sml
    53.5 +(* Title:  Knowledge/polyeq- 1.sml
    53.6             testexamples for PolyEq, poynomial equations and equational systems
    53.7     Author: Richard Lang 2003  
    53.8     (c) due to copyright terms
    53.9 @@ -9,36 +9,36 @@
   53.10  "-----------------------------------------------------------------";
   53.11  "table of contents -----------------------------------------------";
   53.12  "-----------------------------------------------------------------";
   53.13 -"------ polyeq-1.sml ---------------------------------------------";
   53.14 +"------ polyeq- 1.sml ---------------------------------------------";
   53.15  "----------- tests on predicates in problems ---------------------";
   53.16  "----------- test matching problems ------------------------------";
   53.17  "----------- prep. for introduction of Matthias Goldgruber 2003 trials on rewrite orders -----";
   53.18  "----------- Matthias Goldgruber 2003 trials on rewrite orders -------------------------------";
   53.19  "----------- lin.eq degree_0 -------------------------------------";
   53.20  "----------- test thm's d2_pq_formulsxx[_neg]---------------------";
   53.21 -"----------- equality (2 +(-1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
   53.22 -"----------- equality (-2 +(-1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
   53.23 -"----------- equality (-2 + x + x \<up> 2 = 0) ---------------------------------------------------";
   53.24 +"----------- equality (2 +(- 1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
   53.25 +"----------- equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
   53.26 +"----------- equality (- 2 + x + x \<up> 2 = 0) ---------------------------------------------------";
   53.27  "----------- equality (2 + x + x \<up> 2 = 0) ----------------------------------------------------";
   53.28 -"----------- equality (-2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
   53.29 +"----------- equality (- 2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
   53.30  "----------- equality (1*x +   x \<up> 2 = 0) ----------------------------------------------------";
   53.31  "----------- equality (1*x + 1*x \<up> 2 = 0) ----------------------------------------------------";
   53.32  "----------- equality (x +   x \<up> 2 = 0) ------------------------------------------------------";
   53.33  "----------- equality (x + 1*x \<up> 2 = 0) ------------------------------------------------------";
   53.34  "----------- equality (-4 + x \<up> 2 = 0) -------------------------------------------------------";
   53.35  "----------- equality (4 + 1*x \<up> 2 = 0) -------------------------------------------------------";
   53.36 -"----------- equality (1 +(-1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
   53.37 -"----------- equality (-1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
   53.38 +"----------- equality (1 +(- 1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
   53.39 +"----------- equality (- 1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
   53.40  "----------- equality (1 + x + 2*x \<up> 2 = 0) --------------------------------------------------";
   53.41  "----------- (-8 - 2*x + x \<up> 2 = 0),  (*Schalk 2, S.67 Nr.31.b----";
   53.42  "----------- (-8 - 2*x + x \<up> 2 = 0),  by rewriting ---------------";
   53.43 -"----------- (-16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
   53.44 +"----------- (- 16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
   53.45  "-----------------------------------------------------------------";
   53.46 -"------ polyeq-2.sml ---------------------------------------------";
   53.47 +"------ polyeq- 2.sml ---------------------------------------------";
   53.48  "----------- (a*b - (a+b)*x + x \<up> 2 = 0), (*Schalk 2,S.68Nr.44.a*)";
   53.49  "----------- (-64 + x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.a~--------*)";
   53.50 -"----------- (-147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   53.51 -"----------- (3*x - 1 - (5*x - (2 - 4*x)) = -11),(*Schalk Is86Bsp5";
   53.52 +"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   53.53 +"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
   53.54  "----------- ((x+1)*(x+2) - (3*x - 2) \<up> 2=.. Schalk II s.68 Bsp 37";
   53.55  "----------- rls make_polynomial_in ------------------------------";
   53.56  "----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
   53.57 @@ -49,9 +49,8 @@
   53.58  "----------- tests on predicates in problems ---------------------";
   53.59  "----------- tests on predicates in problems ---------------------";
   53.60  "----------- tests on predicates in problems ---------------------";
   53.61 -(* Rewrite.trace_on:=true;
   53.62 - Rewrite.trace_on:=false;
   53.63 -*)
   53.64 +Rewrite.trace_on:=true;  (*true false*)
   53.65 +
   53.66   val t1 = (Thm.term_of o the o (TermC.parse thy)) "lhs (-8 - 2*x + x \<up> 2 = 0)";
   53.67   val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t1;
   53.68   if ((UnparseC.term t) = "-8 - 2 * x + x \<up> 2") then ()
   53.69 @@ -67,12 +66,12 @@
   53.70   if (UnparseC.term t) = "False" then ()
   53.71   else  error "polyeq.sml: diff.behav. 2 in is_poly_in";
   53.72  
   53.73 - val t3 = (Thm.term_of o the o (TermC.parse thy)) "(-8 + (-1)*2*x + x \<up> 2) is_poly_in x";
   53.74 + val t3 = (Thm.term_of o the o (TermC.parse thy)) "(-8 + (- 1)*2*x + x \<up> 2) is_poly_in x";
   53.75   val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t3;
   53.76   if (UnparseC.term t) = "True" then ()
   53.77   else  error "polyeq.sml: diff.behav. 3 in is_poly_in";
   53.78  
   53.79 - val t4 = (Thm.term_of o the o (TermC.parse thy)) "(lhs (-8 + (-1)*2*x + x \<up> 2 = 0)) is_expanded_in x";
   53.80 + val t4 = (Thm.term_of o the o (TermC.parse thy)) "(lhs (-8 + (- 1)*2*x + x \<up> 2 = 0)) is_expanded_in x";
   53.81   val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t4;
   53.82   if (UnparseC.term t) = "True" then ()
   53.83   else  error "polyeq.sml: diff.behav. 4 in is_expended_in";
   53.84 @@ -131,44 +130,44 @@
   53.85  "----------- prep. for introduction of Matthias Goldgruber 2003 trials on rewrite orders -----";
   53.86  "----------- prep. for introduction of Matthias Goldgruber 2003 trials on rewrite orders -----";
   53.87  (*##################################################################################
   53.88 ------------28.2.03: war nicht upgedatet und ausgeklammert in ROOT.ML-->Test_Isac.thy
   53.89 +----------- 28.2.03: war nicht upgedatet und ausgeklammert in ROOT.ML-->Test_Isac.thy
   53.90  
   53.91    (*Aufgabe zum Einstieg in die Arbeit...*)
   53.92    val t = (Thm.term_of o the o (TermC.parse thy)) "a*b - (a+b)*x + x \<up> 2 = 0";
   53.93    (*ein 'ruleset' aus Poly.ML wird angewandt...*)
   53.94    val SOME (t,_) = rewrite_set_ thy Poly_erls false make_polynomial t;
   53.95    UnparseC.term t;
   53.96 -  "a * b + (-1 * (a * x) + (-1 * (b * x) + x \<up> 2)) = 0";
   53.97 +  "a * b + (- 1 * (a * x) + (- 1 * (b * x) + x \<up> 2)) = 0";
   53.98    val SOME (t,_) = 
   53.99        rewrite_set_inst_ thy Poly_erls false [("bdv", "a")] make_polynomial_in t;
  53.100    UnparseC.term t;
  53.101 -  "x \<up> 2 + (-1 * (b * x) + (-1 * (x * a) + b * a)) = 0";
  53.102 +  "x \<up> 2 + (- 1 * (b * x) + (- 1 * (x * a) + b * a)) = 0";
  53.103  (* bei Verwendung von "size_of-term" nach MG :*)
  53.104 -(*"x \<up> 2 + (-1 * (b * x) + (b * a + -1 * (x * a))) = 0"  !!! *)
  53.105 +(*"x \<up> 2 + (- 1 * (b * x) + (b * a + - 1 * (x * a))) = 0"  !!! *)
  53.106  
  53.107    (*wir holen 'a' wieder aus der Klammerung heraus...*)
  53.108    val SOME (t,_) = rewrite_set_ thy Poly_erls false discard_parentheses t;
  53.109    UnparseC.term t;
  53.110 -   "x \<up> 2 + -1 * b * x + -1 * x * a + b * a = 0";
  53.111 -(* "x \<up> 2 + -1 * b * x + b * a + -1 * x * a = 0" !!! *)
  53.112 +   "x \<up> 2 + - 1 * b * x + - 1 * x * a + b * a = 0";
  53.113 +(* "x \<up> 2 + - 1 * b * x + b * a + - 1 * x * a = 0" !!! *)
  53.114  
  53.115    val SOME (t,_) =
  53.116        rewrite_set_inst_ thy Poly_erls false [("bdv", "a")] make_polynomial_in t;
  53.117    UnparseC.term t;
  53.118 -  "x \<up> 2 + (-1 * (b * x) + a * (b + -1 * x)) = 0"; 
  53.119 +  "x \<up> 2 + (- 1 * (b * x) + a * (b + - 1 * x)) = 0"; 
  53.120    (*da sind wir fast am Ziel: make_polynomial_in 'a' sollte ergeben
  53.121 -  "x \<up> 2 + (-1 * (b * x)) + (b + -1 * x) * a = 0"*)
  53.122 +  "x \<up> 2 + (- 1 * (b * x)) + (b + - 1 * x) * a = 0"*)
  53.123  
  53.124    (*das rewriting l"asst sich beobachten mit
  53.125 -Rewrite.trace_on := false;
  53.126 +Rewrite.trace_on := false; (*true false*)
  53.127    *)
  53.128  
  53.129 -"------15.11.02 --------------------------";
  53.130 +"------ 15.11.02 --------------------------";
  53.131    val t = (Thm.term_of o the o (TermC.parse thy)) "1 + a * x + b * x";
  53.132    val bdv = (Thm.term_of o the o (TermC.parse thy)) "bdv";
  53.133    val a = (Thm.term_of o the o (TermC.parse thy)) "a";
  53.134   
  53.135 -Rewrite.trace_on := false;
  53.136 +Rewrite.trace_on := false; (*true false*)
  53.137   (* Anwenden einer Regelmenge aus Termorder.ML: *)
  53.138   val SOME (t,_) =
  53.139       rewrite_set_inst_ thy false [(bdv,a)] make_polynomial_in t;
  53.140 @@ -243,12 +242,12 @@
  53.141  if ord_make_polynomial_in true thy substb (x1,x2) = false(*GREATER*) then ()
  53.142  else error "termorder.sml diff.behav ord_make_polynomial_in #3";
  53.143  
  53.144 -  val aa = (Thm.term_of o the o (TermC.parse thy)) "-1 * a * x";
  53.145 +  val aa = (Thm.term_of o the o (TermC.parse thy)) "- 1 * a * x";
  53.146    val bb = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 3";
  53.147    ord_make_polynomial_in true thy substx (aa, bb);
  53.148    true; (* => LESS *) 
  53.149    
  53.150 -  val aa = (Thm.term_of o the o (TermC.parse thy)) "-1 * a * x";
  53.151 +  val aa = (Thm.term_of o the o (TermC.parse thy)) "- 1 * a * x";
  53.152    val bb = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 3";
  53.153    ord_make_polynomial_in true thy substa (aa, bb);
  53.154    false; (* => GREATER *)
  53.155 @@ -269,14 +268,14 @@
  53.156  if UnparseC.term t' = "a + b + x" then ()
  53.157  else error "termorder.sml diff.behav ord_make_polynomial_in #13";
  53.158  
  53.159 -  val ppp' = "-6 + -5*x + x \<up> 3 + -1*x \<up> 2 + -1*x \<up> 3 + -14*x \<up> 2";
  53.160 +  val ppp' = "-6 + -5*x + x \<up> 3 + - 1*x \<up> 2 + - 1*x \<up> 3 + - 14*x \<up> 2";
  53.161    val ppp  = (Thm.term_of o the o (TermC.parse thy)) ppp';
  53.162  val SOME (t',_) = rewrite_set_inst_ thy false [(bdv,x)] make_polynomial_in ppp;
  53.163 -if UnparseC.term t' = "-6 + -5 * x + -15 * x \<up> 2 + 0" then ()
  53.164 +if UnparseC.term t' = "-6 + -5 * x + - 15 * x \<up> 2 + 0" then ()
  53.165  else error "termorder.sml diff.behav ord_make_polynomial_in #14";
  53.166  
  53.167  val SOME (t', _) = rewrite_set_inst_ thy false [(bdv,x)] make_polynomial_in ppp;
  53.168 -if UnparseC.term t' = "-6 + -5 * x + -15 * x \<up> 2 + 0" then ()
  53.169 +if UnparseC.term t' = "-6 + -5 * x + - 15 * x \<up> 2 + 0" then ()
  53.170  else error "termorder.sml diff.behav ord_make_polynomial_in #15";
  53.171  
  53.172    val ttt' = "(3*x + 5)/18";
  53.173 @@ -300,7 +299,7 @@
  53.174  val (dI',pI',mI') = ("PolyEq",["degree_0", "polynomial", "univariate", "equation"],
  53.175                       ["PolyEq", "solve_d0_polyeq_equation"]);
  53.176  (*=== inhibit exn WN110914: declare_constraints doesnt work with ThmC.numerals_to_Free ========
  53.177 -TODO: change to "equality (x + -1*x = (0::real))"
  53.178 +TODO: change to "equality (x + - 1*x = (0::real))"
  53.179        and search for an appropriate problem and method.
  53.180  
  53.181  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.182 @@ -332,7 +331,7 @@
  53.183  "----------- test thm's d2_pq_formulsxx[_neg]---------------------";
  53.184  "----------- test thm's d2_pq_formulsxx[_neg]---------------------";
  53.185  "----- d2_pqformula1 ------!!!!";
  53.186 -val fmz = ["equality (-1/8 + (-1/4)*z + z \<up> 2 = (0::real))", "solveFor z", "solutions L"];
  53.187 +val fmz = ["equality (- 1/8 + (- 1/4)*z + z \<up> 2 = (0::real))", "solveFor z", "solutions L"];
  53.188  val (dI',pI',mI') =
  53.189    ("Isac_Knowledge", ["pqFormula", "degree_2", "polynomial", "univariate", "equation"], ["no_met"]);
  53.190  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.191 @@ -348,21 +347,21 @@
  53.192  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.193  val (p,_,f,nxt,_,pt) = me nxt p [] pt;         
  53.194  
  53.195 -(*[z = 1 / 8 + sqrt (9 / 16) / 2, z = 1 / 8 + -1 * sqrt (9 / 16) / 2] TODO sqrt*)
  53.196 +(*[z = 1 / 8 + sqrt (9 / 16) / 2, z = 1 / 8 + - 1 * sqrt (9 / 16) / 2] TODO sqrt*)
  53.197  val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt =..,Check_elementwise "Assumptions")*)
  53.198  val (p,_,f,nxt,_,pt) = me nxt p [] pt;         
  53.199  val (p,_,f,nxt,_,pt) = me nxt p [] pt;         
  53.200  
  53.201  if p = ([], Res) andalso
  53.202 -  f2str f = "[z = 1 / 8 + sqrt (9 / 16) / 2, z = 1 / 8 + -1 * sqrt (9 / 16) / 2]" then
  53.203 -    case nxt of End_Proof' => () | _ => error "(-1/8 + (-1/4)*z + z \<up> 2 = (0::real)) CHANGED 1"
  53.204 -else error "(-1/8 + (-1/4)*z + z \<up> 2 = (0::real)) CHANGED 2";
  53.205 +  f2str f = "[z = 1 / 8 + sqrt (9 / 16) / 2, z = 1 / 8 + - 1 * sqrt (9 / 16) / 2]" then
  53.206 +    case nxt of End_Proof' => () | _ => error "(- 1/8 + (- 1/4)*z + z \<up> 2 = (0::real)) CHANGED 1"
  53.207 +else error "(- 1/8 + (- 1/4)*z + z \<up> 2 = (0::real)) CHANGED 2";
  53.208  
  53.209 -"----------- equality (2 +(-1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  53.210 -"----------- equality (2 +(-1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  53.211 -"----------- equality (2 +(-1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  53.212 +"----------- equality (2 +(- 1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  53.213 +"----------- equality (2 +(- 1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  53.214 +"----------- equality (2 +(- 1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  53.215  "----- d2_pqformula1_neg ------";
  53.216 -val fmz = ["equality (2 +(-1)*x + x \<up> 2 = (0::real))", "solveFor x", "solutions L"];
  53.217 +val fmz = ["equality (2 +(- 1)*x + x \<up> 2 = (0::real))", "solveFor x", "solutions L"];
  53.218  val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"], ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  53.219  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.220  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.221 @@ -379,15 +378,15 @@
  53.222  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.223  val asm = Ctree.get_assumptions pt p;
  53.224  if f2str f = "[]" andalso 
  53.225 -  UnparseC.terms asm = "[\"lhs (2 + -1 * x + x \<up> 2 = 0) is_poly_in x\", " ^
  53.226 -    "\"lhs (2 + -1 * x + x \<up> 2 = 0) has_degree_in x = 2\"]" then ()
  53.227 -else error "polyeq.sml: diff.behav. in 2 +(-1)*x + x \<up> 2 = 0";
  53.228 +  UnparseC.terms asm = "[\"lhs (2 + - 1 * x + x \<up> 2 = 0) is_poly_in x\", " ^
  53.229 +    "\"lhs (2 + - 1 * x + x \<up> 2 = 0) has_degree_in x = 2\"]" then ()
  53.230 +else error "polyeq.sml: diff.behav. in 2 +(- 1)*x + x \<up> 2 = 0";
  53.231  
  53.232 -"----------- equality (-2 +(-1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  53.233 -"----------- equality (-2 +(-1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  53.234 -"----------- equality (-2 +(-1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  53.235 +"----------- equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  53.236 +"----------- equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  53.237 +"----------- equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  53.238  "----- d2_pqformula2 ------";
  53.239 -val fmz = ["equality (-2 +(-1)*x + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.240 +val fmz = ["equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.241  val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.242                       ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  53.243  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.244 @@ -400,16 +399,16 @@
  53.245  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.246  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.247  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.248 -case f of Test_Out.FormKF "[x = 2, x = -1]" => ()
  53.249 -	 | _ => error "polyeq.sml: diff.behav. in -2 + (-1)*x + x^2 = 0 -> [x = 2, x = -1]";
  53.250 +case f of Test_Out.FormKF "[x = 2, x = - 1]" => ()
  53.251 +	 | _ => error "polyeq.sml: diff.behav. in - 2 + (- 1)*x + x^2 = 0 -> [x = 2, x = - 1]";
  53.252  
  53.253  
  53.254 -"----------- equality (-2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  53.255 -"----------- equality (-2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  53.256 -"----------- equality (-2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  53.257 +"----------- equality (- 2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  53.258 +"----------- equality (- 2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  53.259 +"----------- equality (- 2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  53.260  "----- d2_pqformula3 ------";
  53.261  (*EP-9*)
  53.262 -val fmz = ["equality (-2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.263 +val fmz = ["equality (- 2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.264  val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.265                       ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  53.266  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.267 @@ -422,8 +421,8 @@
  53.268  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.269  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.270  val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  53.271 -case f of Test_Out.FormKF "[x = 1, x = -2]" => ()
  53.272 -	 | _ => error "polyeq.sml: diff.behav. in  -2 + x + x^2 = 0-> [x = 1, x = -2]";
  53.273 +case f of Test_Out.FormKF "[x = 1, x = - 2]" => ()
  53.274 +	 | _ => error "polyeq.sml: diff.behav. in  - 2 + x + x^2 = 0-> [x = 1, x = - 2]";
  53.275  
  53.276  
  53.277  "----------- equality (2 + x + x \<up> 2 = 0) ----------------------------------------------------";
  53.278 @@ -446,11 +445,11 @@
  53.279  "TODO 2 + x + x \<up> 2 = 0";
  53.280  "TODO 2 + x + x \<up> 2 = 0";
  53.281  
  53.282 -"----------- equality (-2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  53.283 -"----------- equality (-2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  53.284 -"----------- equality (-2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  53.285 +"----------- equality (- 2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  53.286 +"----------- equality (- 2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  53.287 +"----------- equality (- 2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  53.288  "----- d2_pqformula4 ------";
  53.289 -val fmz = ["equality (-2 + x + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.290 +val fmz = ["equality (- 2 + x + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.291  val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.292                       ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  53.293  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.294 @@ -462,8 +461,8 @@
  53.295  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.296  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.297  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.298 -case f of Test_Out.FormKF "[x = 1, x = -2]" => ()
  53.299 -	 | _ => error "polyeq.sml: diff.behav. in  -2 + x + 1*x \<up> 2 = 0 -> [x = 1, x = -2]";
  53.300 +case f of Test_Out.FormKF "[x = 1, x = - 2]" => ()
  53.301 +	 | _ => error "polyeq.sml: diff.behav. in  - 2 + x + 1*x \<up> 2 = 0 -> [x = 1, x = - 2]";
  53.302  
  53.303  "----------- equality (1*x +   x \<up> 2 = 0) ----------------------------------------------------";
  53.304  "----------- equality (1*x +   x \<up> 2 = 0) ----------------------------------------------------";
  53.305 @@ -481,8 +480,8 @@
  53.306  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.307  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.308  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.309 -case f of Test_Out.FormKF "[x = 0, x = -1]" => ()
  53.310 -	 | _ => error "polyeq.sml: diff.behav. in  1*x +   x^2 = 0 -> [x = 0, x = -1]";
  53.311 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  53.312 +	 | _ => error "polyeq.sml: diff.behav. in  1*x +   x^2 = 0 -> [x = 0, x = - 1]";
  53.313  
  53.314  "----------- equality (1*x + 1*x \<up> 2 = 0) ----------------------------------------------------";
  53.315  "----------- equality (1*x + 1*x \<up> 2 = 0) ----------------------------------------------------";
  53.316 @@ -500,14 +499,14 @@
  53.317  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.318  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.319  val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  53.320 -case f of Test_Out.FormKF "[x = 0, x = -1]" => ()
  53.321 -	 | _ => error "polyeq.sml: diff.behav. in  1*x + 1*x^2 = 0 -> [x = 0, x = -1]";
  53.322 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  53.323 +	 | _ => error "polyeq.sml: diff.behav. in  1*x + 1*x^2 = 0 -> [x = 0, x = - 1]";
  53.324  
  53.325  "----------- equality (x +   x \<up> 2 = 0) ------------------------------------------------------";
  53.326  "----------- equality (x +   x \<up> 2 = 0) ------------------------------------------------------";
  53.327  "----------- equality (x +   x \<up> 2 = 0) ------------------------------------------------------";
  53.328  "----- d2_pqformula7 ------";
  53.329 -(*EP-10*)
  53.330 +(*EP- 10*)
  53.331  val fmz = ["equality (  x +   x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.332  val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.333                       ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  53.334 @@ -520,8 +519,8 @@
  53.335  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.336  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.337  val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  53.338 -case f of Test_Out.FormKF "[x = 0, x = -1]" => ()
  53.339 -	 | _ => error "polyeq.sml: diff.behav. in  x + x^2 = 0 -> [x = 0, x = -1]";
  53.340 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  53.341 +	 | _ => error "polyeq.sml: diff.behav. in  x + x^2 = 0 -> [x = 0, x = - 1]";
  53.342  
  53.343  "----------- equality (x + 1*x \<up> 2 = 0) ------------------------------------------------------";
  53.344  "----------- equality (x + 1*x \<up> 2 = 0) ------------------------------------------------------";
  53.345 @@ -539,8 +538,8 @@
  53.346  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.347  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.348  val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  53.349 -case f of Test_Out.FormKF "[x = 0, x = -1]" => ()
  53.350 -	 | _ => error "polyeq.sml: diff.behav. in  x + 1*x^2 = 0 -> [x = 0, x = -1]";
  53.351 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  53.352 +	 | _ => error "polyeq.sml: diff.behav. in  x + 1*x^2 = 0 -> [x = 0, x = - 1]";
  53.353  
  53.354  "----------- equality (-4 + x \<up> 2 = 0) -------------------------------------------------------";
  53.355  "----------- equality (-4 + x \<up> 2 = 0) -------------------------------------------------------";
  53.356 @@ -557,8 +556,8 @@
  53.357  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.358  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.359  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.360 -case f of Test_Out.FormKF "[x = 2, x = -2]" => ()
  53.361 -	 | _ => error "polyeq.sml: diff.behav. in -4 + x^2 = 0 -> [x = 2, x = -2]";
  53.362 +case f of Test_Out.FormKF "[x = 2, x = - 2]" => ()
  53.363 +	 | _ => error "polyeq.sml: diff.behav. in -4 + x^2 = 0 -> [x = 2, x = - 2]";
  53.364  
  53.365  
  53.366  "----------- equality (4 + 1*x \<up> 2 = 0) -------------------------------------------------------";
  53.367 @@ -582,7 +581,7 @@
  53.368  "-------------------- test thm's d2_abc_formulsxx[_neg]-----";
  53.369  "-------------------- test thm's d2_abc_formulsxx[_neg]-----";
  53.370  "-------------------- test thm's d2_abc_formulsxx[_neg]-----";
  53.371 -val fmz = ["equality (-1 +(-1)*x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.372 +val fmz = ["equality (- 1 +(- 1)*x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.373  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.374                       ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.375  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.376 @@ -593,13 +592,13 @@
  53.377  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.378  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.379  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.380 -case f of Test_Out.FormKF "[x = 1, x = -1 / 2]" => ()
  53.381 -	 | _ => error "polyeq.sml: diff.behav. in -1 + (-1)*x + 2*x^2 = 0 -> [x = 1, x = -1/2]";
  53.382 +case f of Test_Out.FormKF "[x = 1, x = - 1 / 2]" => ()
  53.383 +	 | _ => error "polyeq.sml: diff.behav. in - 1 + (- 1)*x + 2*x^2 = 0 -> [x = 1, x = - 1/2]";
  53.384  
  53.385 -"----------- equality (1 +(-1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  53.386 -"----------- equality (1 +(-1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  53.387 -"----------- equality (1 +(-1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  53.388 -val fmz = ["equality (1 +(-1)*x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.389 +"----------- equality (1 +(- 1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  53.390 +"----------- equality (1 +(- 1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  53.391 +"----------- equality (1 +(- 1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  53.392 +val fmz = ["equality (1 +(- 1)*x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.393  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.394                       ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.395  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.396 @@ -610,16 +609,16 @@
  53.397  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.398  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.399  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.400 -"TODO 1 +(-1)*x + 2*x \<up> 2 = 0";
  53.401 -"TODO 1 +(-1)*x + 2*x \<up> 2 = 0";
  53.402 -"TODO 1 +(-1)*x + 2*x \<up> 2 = 0";
  53.403 +"TODO 1 +(- 1)*x + 2*x \<up> 2 = 0";
  53.404 +"TODO 1 +(- 1)*x + 2*x \<up> 2 = 0";
  53.405 +"TODO 1 +(- 1)*x + 2*x \<up> 2 = 0";
  53.406  
  53.407  
  53.408 -"----------- equality (-1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  53.409 -"----------- equality (-1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  53.410 -"----------- equality (-1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  53.411 -(*EP-11*)
  53.412 -val fmz = ["equality (-1 + x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.413 +"----------- equality (- 1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  53.414 +"----------- equality (- 1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  53.415 +"----------- equality (- 1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  53.416 +(*EP- 11*)
  53.417 +val fmz = ["equality (- 1 + x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.418  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.419                       ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.420  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.421 @@ -632,8 +631,8 @@
  53.422  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.423  
  53.424  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.425 -case f of Test_Out.FormKF "[x = 1 / 2, x = -1]" => ()
  53.426 -	 | _ => error "polyeq.sml: diff.behav. in -1 + x + 2*x^2 = 0 -> [x = 1/2, x = -1]";
  53.427 +case f of Test_Out.FormKF "[x = 1 / 2, x = - 1]" => ()
  53.428 +	 | _ => error "polyeq.sml: diff.behav. in - 1 + x + 2*x^2 = 0 -> [x = 1/2, x = - 1]";
  53.429  
  53.430  
  53.431  "----------- equality (1 + x + 2*x \<up> 2 = 0) --------------------------------------------------";
  53.432 @@ -656,7 +655,7 @@
  53.433  "TODO 1 + x + 2*x \<up> 2 = 0";
  53.434  
  53.435  
  53.436 -val fmz = ["equality (-2 + 1*x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.437 +val fmz = ["equality (- 2 + 1*x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.438  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.439                       ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.440  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.441 @@ -667,8 +666,8 @@
  53.442  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.443  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.444  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.445 -case f of Test_Out.FormKF "[x = 1, x = -2]" => ()
  53.446 -	 | _ => error "polyeq.sml: diff.behav. in -2 + 1*x + x^2 = 0 -> [x = 1, x = -2]";
  53.447 +case f of Test_Out.FormKF "[x = 1, x = - 2]" => ()
  53.448 +	 | _ => error "polyeq.sml: diff.behav. in - 2 + 1*x + x^2 = 0 -> [x = 1, x = - 2]";
  53.449  
  53.450  val fmz = ["equality ( 2 + 1*x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.451  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.452 @@ -685,8 +684,8 @@
  53.453  "TODO 2 + 1*x + x \<up> 2 = 0";
  53.454  "TODO 2 + 1*x + x \<up> 2 = 0";
  53.455  
  53.456 -(*EP-12*)
  53.457 -val fmz = ["equality (-2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.458 +(*EP- 12*)
  53.459 +val fmz = ["equality (- 2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.460  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.461                       ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.462  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.463 @@ -697,8 +696,8 @@
  53.464  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.465  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.466  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.467 -case f of Test_Out.FormKF "[x = 1, x = -2]" => ()
  53.468 -	 | _ => error "polyeq.sml: diff.behav. in -2 + x + x^2 = 0 -> [x = 1, x = -2]";
  53.469 +case f of Test_Out.FormKF "[x = 1, x = - 2]" => ()
  53.470 +	 | _ => error "polyeq.sml: diff.behav. in - 2 + x + x^2 = 0 -> [x = 1, x = - 2]";
  53.471  
  53.472  val fmz = ["equality ( 2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.473  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.474 @@ -715,7 +714,7 @@
  53.475  "TODO 2 + x + x \<up> 2 = 0";
  53.476  "TODO 2 + x + x \<up> 2 = 0";
  53.477  
  53.478 -(*EP-13*)
  53.479 +(*EP- 13*)
  53.480  val fmz = ["equality (-8 + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.481  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.482                       ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.483 @@ -727,8 +726,8 @@
  53.484  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.485  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.486  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.487 -case f of Test_Out.FormKF "[x = 2, x = -2]" => ()
  53.488 -	 | _ => error "polyeq.sml: diff.behav. in -8 + 2*x^2 = 0 -> [x = 2, x = -2]";
  53.489 +case f of Test_Out.FormKF "[x = 2, x = - 2]" => ()
  53.490 +	 | _ => error "polyeq.sml: diff.behav. in -8 + 2*x^2 = 0 -> [x = 2, x = - 2]";
  53.491  
  53.492  val fmz = ["equality ( 8+ 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.493  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.494 @@ -744,7 +743,7 @@
  53.495  "TODO 8+ 2*x \<up> 2 = 0";
  53.496  "TODO 8+ 2*x \<up> 2 = 0";
  53.497  
  53.498 -(*EP-14*)
  53.499 +(*EP- 14*)
  53.500  val fmz = ["equality (-4 + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.501  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"], ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.502  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  53.503 @@ -755,8 +754,8 @@
  53.504  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.505  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.506  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.507 -case f of Test_Out.FormKF "[x = 2, x = -2]" => ()
  53.508 -	 | _ => error "polyeq.sml: diff.behav. in -4 + x^2 = 0 -> [x = 2, x = -2]";
  53.509 +case f of Test_Out.FormKF "[x = 2, x = - 2]" => ()
  53.510 +	 | _ => error "polyeq.sml: diff.behav. in -4 + x^2 = 0 -> [x = 2, x = - 2]";
  53.511  
  53.512  
  53.513  val fmz = ["equality ( 4+ x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.514 @@ -772,7 +771,7 @@
  53.515  "TODO 4+ x \<up> 2 = 0";
  53.516  "TODO 4+ x \<up> 2 = 0";
  53.517  
  53.518 -(*EP-15*)
  53.519 +(*EP- 15*)
  53.520  val fmz = ["equality (2*x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.521  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.522                       ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.523 @@ -784,8 +783,8 @@
  53.524  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.525  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.526  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.527 -case f of Test_Out.FormKF "[x = 0, x = -1]" => ()
  53.528 -	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = -1]";
  53.529 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  53.530 +	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = - 1]";
  53.531  
  53.532  val fmz = ["equality (1*x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.533  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.534 @@ -798,10 +797,10 @@
  53.535  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.536  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.537  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.538 -case f of Test_Out.FormKF "[x = 0, x = -1]" => ()
  53.539 -	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = -1]";
  53.540 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  53.541 +	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = - 1]";
  53.542  
  53.543 -(*EP-16*)
  53.544 +(*EP- 16*)
  53.545  val fmz = ["equality (x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.546  val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  53.547                       ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  53.548 @@ -813,8 +812,8 @@
  53.549  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.550  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.551  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.552 -case f of Test_Out.FormKF "[x = 0, x = -1 / 2]" => ()
  53.553 -	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = -1 / 2]";
  53.554 +case f of Test_Out.FormKF "[x = 0, x = - 1 / 2]" => ()
  53.555 +	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = - 1 / 2]";
  53.556  
  53.557  (*EP-//*)
  53.558  val fmz = ["equality (x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  53.559 @@ -828,8 +827,8 @@
  53.560  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.561  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.562  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.563 -case f of Test_Out.FormKF "[x = 0, x = -1]" => ()
  53.564 -	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = -1]";
  53.565 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  53.566 +	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = - 1]";
  53.567  
  53.568  
  53.569  "----------- (-8 - 2*x + x \<up> 2 = 0),  (*Schalk 2, S.67 Nr.31.b----";
  53.570 @@ -863,30 +862,30 @@
  53.571     2 / 2 - x = - sqrt ((2 / 2) \<up> 2 - -8)" nxt = Rewr_Inst("bdv_explicit2"*)
  53.572  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.573  (*"2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |
  53.574 -   -1*x = - (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8)"nxt = R_Inst("bdv_explt2"*)
  53.575 +   - 1*x = - (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8)"nxt = R_Inst("bdv_explt2"*)
  53.576  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.577 -(*"-1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |
  53.578 -   -1 * x = (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))"nxt = bdv_explicit3*)
  53.579 +(*"- 1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |
  53.580 +   - 1 * x = (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))"nxt = bdv_explicit3*)
  53.581  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.582 -(*"-1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |
  53.583 -  x = -1 * (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))" nxt = bdv_explicit3*)
  53.584 +(*"- 1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |
  53.585 +  x = - 1 * (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))" nxt = bdv_explicit3*)
  53.586  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.587 -(*"x = -1 * (- (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8)) |
  53.588 -   x = -1 * (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))"nxt = calculate_Rational
  53.589 +(*"x = - 1 * (- (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8)) |
  53.590 +   x = - 1 * (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))"nxt = calculate_Rational
  53.591     NOT IMPLEMENTED SINCE 2002 ------------------------------ \<up> \<up> \<up> \<up> \<up>  \<up> *)
  53.592  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.593 -(*"x = -2 | x = 4" nxt = Or_to_List*)
  53.594 +(*"x = - 2 | x = 4" nxt = Or_to_List*)
  53.595  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  53.596 -(*"[x = -2, x = 4]" nxt = Check_Postcond*)
  53.597 +(*"[x = - 2, x = 4]" nxt = Check_Postcond*)
  53.598  val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f;
  53.599  (* FIXXXME 
  53.600 - case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = -2, x = 4]")) => () TODO
  53.601 -	 | _ => error "polyeq.sml: diff.behav. in [x = -2, x = 4]";
  53.602 + case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = - 2, x = 4]")) => () TODO
  53.603 +	 | _ => error "polyeq.sml: diff.behav. in [x = - 2, x = 4]";
  53.604  *)
  53.605  if f2str f =
  53.606 -"[x = -1 * -1 + -1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8),\n x = -1 * -1 + -1 * (-1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))]"
  53.607 -(*"[x = -1 * -1 + -1 * sqrt (1 \<up> 2 - -8),\n x = -1 * -1 + -1 * (-1 * sqrt (1 \<up> 2 - -8))]"*)
  53.608 -then () else error "polyeq.sml corrected?behav. in [x = -2, x = 4]";
  53.609 +"[x = - 1 * - 1 + - 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8),\n x = - 1 * - 1 + - 1 * (- 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))]"
  53.610 +(*"[x = - 1 * - 1 + - 1 * sqrt (1 \<up> 2 - -8),\n x = - 1 * - 1 + - 1 * (- 1 * sqrt (1 \<up> 2 - -8))]"*)
  53.611 +then () else error "polyeq.sml corrected?behav. in [x = - 2, x = 4]";
  53.612  
  53.613  
  53.614  "----------- (-8 - 2*x + x \<up> 2 = 0),  by rewriting ---------------";
  53.615 @@ -910,31 +909,31 @@
  53.616  val thm = ThmC.numerals_to_Free @{thm root_plus_minus};
  53.617  val SOME (t,asm) = rewrite_ thy dummy_ord PolyEq_erls true thm t;
  53.618  UnparseC.term t = "2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |"^
  53.619 -           "\n2 / 2 - x = -1 * sqrt ((2 / 2) \<up> 2 - -8)";
  53.620 +           "\n2 / 2 - x = - 1 * sqrt ((2 / 2) \<up> 2 - -8)";
  53.621  
  53.622  (*the thm bdv_explicit2* here required to be constrained to ::real*)
  53.623  val thm = ThmC.numerals_to_Free @{thm bdv_explicit2};
  53.624  val SOME (t,asm) = rewrite_inst_ thy dummy_ord Rule_Set.Empty true inst thm t;
  53.625  UnparseC.term t = "2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |"^
  53.626 -              "\n-1 * x = - (2 / 2) + -1 * sqrt ((2 / 2) \<up> 2 - -8)";
  53.627 +              "\n- 1 * x = - (2 / 2) + - 1 * sqrt ((2 / 2) \<up> 2 - -8)";
  53.628  
  53.629  val thm = ThmC.numerals_to_Free @{thm bdv_explicit3};
  53.630  val SOME (t,asm) = rewrite_inst_ thy dummy_ord Rule_Set.Empty true inst thm t;
  53.631  UnparseC.term t = "2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |"^
  53.632 -                   "\nx = -1 * (- (2 / 2) + -1 * sqrt ((2 / 2) \<up> 2 - -8))";
  53.633 +                   "\nx = - 1 * (- (2 / 2) + - 1 * sqrt ((2 / 2) \<up> 2 - -8))";
  53.634  
  53.635  val thm = ThmC.numerals_to_Free @{thm bdv_explicit2};
  53.636  val SOME (t,asm) = rewrite_inst_ thy dummy_ord Rule_Set.Empty true inst thm t;
  53.637 -UnparseC.term t = "-1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |"^
  53.638 -                "\nx = -1 * (- (2 / 2) + -1 * sqrt ((2 / 2) \<up> 2 - -8))";
  53.639 +UnparseC.term t = "- 1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |"^
  53.640 +                "\nx = - 1 * (- (2 / 2) + - 1 * sqrt ((2 / 2) \<up> 2 - -8))";
  53.641  
  53.642  val rls = calculate_RootRat;
  53.643  val SOME (t,asm) = rewrite_set_ thy true rls t;
  53.644  if UnparseC.term t =
  53.645 -  "-1 * x = -1 + sqrt (2 \<up> 2 / 2 \<up> 2 - -8) \<or>\nx = -1 * -1 + -1 * (-1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))"
  53.646 -(*"-1 * x = -1 + sqrt (2 \<up> 2 / 2 \<up> 2 - -8) |\nx = -1 * -1 + -1 * (-1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))"..isabisac15*)
  53.647 +  "- 1 * x = - 1 + sqrt (2 \<up> 2 / 2 \<up> 2 - -8) \<or>\nx = - 1 * - 1 + - 1 * (- 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))"
  53.648 +(*"- 1 * x = - 1 + sqrt (2 \<up> 2 / 2 \<up> 2 - -8) |\nx = - 1 * - 1 + - 1 * (- 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))"..isabisac15*)
  53.649  then () else error "(-8 - 2*x + x \<up> 2 = 0),  by rewriting -- ERROR INDICATES IMPROVEMENT";
  53.650 -(*SHOULD BE: UnparseC.term = "x = -2 | x = 4;*)
  53.651 +(*SHOULD BE: UnparseC.term = "x = - 2 | x = 4;*)
  53.652  
  53.653  
  53.654  "-------------------- (3 - 10*x + 3*x \<up> 2 = 0), ----------------------";
  53.655 @@ -963,10 +962,10 @@
  53.656   (*Apply_Method ("PolyEq", "complete_square")*)
  53.657   val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f;
  53.658  
  53.659 -"----------- (-16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
  53.660 -"----------- (-16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
  53.661 -"----------- (-16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
  53.662 - val fmz = ["equality (-16 + 4*x + 2*x \<up> 2 = 0)",
  53.663 +"----------- (- 16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
  53.664 +"----------- (- 16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
  53.665 +"----------- (- 16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
  53.666 + val fmz = ["equality (- 16 + 4*x + 2*x \<up> 2 = 0)",
  53.667   	    "solveFor x", "solutions L"];
  53.668   val (dI',pI',mI') =
  53.669       ("PolyEq",["degree_2", "expanded", "univariate", "equation"],
    54.1 --- a/test/Tools/isac/Knowledge/polyeq-2.sml	Mon Jun 21 22:08:01 2021 +0200
    54.2 +++ b/test/Tools/isac/Knowledge/polyeq-2.sml	Sun Jul 18 18:15:27 2021 +0200
    54.3 @@ -1,4 +1,4 @@
    54.4 -(* Title:  Knowledge/polyeq-1.sml
    54.5 +(* Title:  Knowledge/polyeq- 1.sml
    54.6             testexamples for PolyEq, poynomial equations and equational systems
    54.7     Author: Richard Lang 2003  
    54.8     (c) due to copyright terms
    54.9 @@ -11,8 +11,8 @@
   54.10  "-----------------------------------------------------------------";
   54.11  "----------- (a*b - (a+b)*x + x \<up> 2 = 0), (*Schalk 2,S.68Nr.44.a*)";
   54.12  "----------- (-64 + x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.a~--------*)";
   54.13 -"----------- (-147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   54.14 -"----------- (3*x - 1 - (5*x - (2 - 4*x)) = -11),(*Schalk Is86Bsp5";
   54.15 +"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   54.16 +"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
   54.17  "----------- ((x+1)*(x+2) - (3*x - 2) \<up> 2=.. Schalk II s.68 Bsp 37";
   54.18  "----------- rls make_polynomial_in ------------------------------";
   54.19  "----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
   54.20 @@ -53,7 +53,7 @@
   54.21       Form' 
   54.22  	 (Test_Out.FormKF 
   54.23  	      (~1,EdUndef,0,Nundef,
   54.24 -	       "[x = (a + b) / 2 + -1 * sqrt ((a + b) \<up> 2 / 2 \<up> 2 - a * b),\n x = (a + b) / 2 + sqrt ((a + b) \<up> 2 / 2 \<up> 2 - a * b)]")) 
   54.25 +	       "[x = (a + b) / 2 + - 1 * sqrt ((a + b) \<up> 2 / 2 \<up> 2 - a * b),\n x = (a + b) / 2 + sqrt ((a + b) \<up> 2 / 2 \<up> 2 - a * b)]")) 
   54.26  	 => ()
   54.27     | _ => error "polyeq.sml: diff.behav. in a*b - (a+b)*x + x \<up> 2 = 0";
   54.28   this will be simplified [x = a, x = b] to by Factor.ML*)
   54.29 @@ -81,15 +81,15 @@
   54.30  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   54.31  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   54.32  val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f;
   54.33 -(*WN.2.5.03 TODO "[x = sqrt (0 - -64), x = -1 * sqrt (0 - -64)]"
   54.34 +(*WN.2.5.03 TODO "[x = sqrt (0 - -64), x = - 1 * sqrt (0 - -64)]"
   54.35   case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 8, x = -8]")) => ()
   54.36  	 | _ => error "polyeq.sml: diff.behav. in [x = 8, x = -8]";
   54.37  *)
   54.38  
   54.39 -"----------- (-147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   54.40 -"----------- (-147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   54.41 -"----------- (-147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   54.42 -val fmz = ["equality (-147 + 3*x \<up> 2 = 0)",(*Schalk 2, S.66 Nr.1.b*)
   54.43 +"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   54.44 +"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   54.45 +"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   54.46 +val fmz = ["equality (- 147 + 3*x \<up> 2 = 0)",(*Schalk 2, S.66 Nr.1.b*)
   54.47   	    "solveFor x", "solutions L"];
   54.48  val (dI',pI',mI') =
   54.49       ("PolyEq",["degree_2", "expanded", "univariate", "equation"],
   54.50 @@ -103,19 +103,19 @@
   54.51  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   54.52  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   54.53  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   54.54 -(*WN.2.5.03 TODO "[x = sqrt (0 - -49), x = -1 * sqrt (0 - -49)]"
   54.55 +(*WN.2.5.03 TODO "[x = sqrt (0 - -49), x = - 1 * sqrt (0 - -49)]"
   54.56   case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 7, x = -7]")) => ()
   54.57  	 | _ => error "polyeq.sml: diff.behav. in [x = 7, x = -7]";
   54.58  *)
   54.59 -if f2str f = "[x = sqrt (0 - -49), x = -1 * sqrt (0 - -49)]" then ()
   54.60 +if f2str f = "[x = sqrt (0 - -49), x = - 1 * sqrt (0 - -49)]" then ()
   54.61  else error "polyeq.sml CORRECTED?behav. in [x = 7, x = -7]";
   54.62  
   54.63  
   54.64 -"----------- (3*x - 1 - (5*x - (2 - 4*x)) = -11),(*Schalk Is86Bsp5";
   54.65 -"----------- (3*x - 1 - (5*x - (2 - 4*x)) = -11),(*Schalk Is86Bsp5";
   54.66 -"----------- (3*x - 1 - (5*x - (2 - 4*x)) = -11),(*Schalk Is86Bsp5";
   54.67 -(*EP-17 Schalk_I_p86_n5*)
   54.68 -val fmz = ["equality ((3::real)*x - 1 - (5*x - (2 - 4*x)) = -11)", "solveFor x", "solutions L"];
   54.69 +"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
   54.70 +"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
   54.71 +"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
   54.72 +(*EP- 17 Schalk_I_p86_n5*)
   54.73 +val fmz = ["equality ((3::real)*x - 1 - (5*x - (2 - 4*x)) = - 11)", "solveFor x", "solutions L"];
   54.74  (* Refine.refine fmz ["univariate", "equation"];
   54.75  *)
   54.76  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
   54.77 @@ -206,8 +206,8 @@
   54.78  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   54.79  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   54.80  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   54.81 -case f of Test_Out.FormKF "[x = 2, x = -2]" => ()
   54.82 -	 | _ => error "polyeq.sml: diff.behav. in [x = 2, x = -2]";
   54.83 +case f of Test_Out.FormKF "[x = 2, x = - 2]" => ()
   54.84 +	 | _ => error "polyeq.sml: diff.behav. in [x = 2, x = - 2]";
   54.85  
   54.86  "----------- rls make_polynomial_in ------------------------------";
   54.87  "----------- rls make_polynomial_in ------------------------------";
   54.88 @@ -215,35 +215,35 @@
   54.89  (*Punkte aus dem TestBericht, die ich in rlang.sml nicht zuordnen konnte:*)
   54.90  (*WN.19.3.03 ---v-*)
   54.91  (*3(b)*)val (bdv,v) = (TermC.str2term "''bdv''", TermC.str2term "R1");
   54.92 -val t = TermC.str2term "-1 * (R * R2) + R2 * R1 + -1 * (R * R1) = 0";
   54.93 +val t = TermC.str2term "- 1 * (R * R2) + R2 * R1 + - 1 * (R * R1) = 0";
   54.94  val SOME (t',_) = rewrite_set_inst_ thy false [(bdv,v)] make_polynomial_in t;
   54.95 -if UnparseC.term t' = "-1 * R * R2 + R2 * R1 + -1 * R * R1 = 0" then ()
   54.96 -else error "make_polynomial_in (-1 * (R * R2) + R2 * R1 + -1 * (R * R1) = 0)";
   54.97 -"-1 * R * R2 + (R2 + -1 * R) * R1 = 0";
   54.98 +if UnparseC.term t' = "- 1 * R * R2 + R2 * R1 + - 1 * R * R1 = 0" then ()
   54.99 +else error "make_polynomial_in (- 1 * (R * R2) + R2 * R1 + - 1 * (R * R1) = 0)";
  54.100 +"- 1 * R * R2 + (R2 + - 1 * R) * R1 = 0";
  54.101  (*WN.19.3.03 ---^-*)
  54.102  
  54.103  (*3(c)*)val (bdv,v) = (TermC.str2term "bdv", TermC.str2term "p");
  54.104 -val t = TermC.str2term "y \<up> 2 + -2 * (x * p) = 0";
  54.105 +val t = TermC.str2term "y \<up> 2 + - 2 * (x * p) = 0";
  54.106  val SOME (t',_) = rewrite_set_inst_ thy false [(bdv,v)] make_polynomial_in t;
  54.107 -if UnparseC.term t' = "y \<up> 2 + -2 * x * p = 0" then ()
  54.108 -else error "make_polynomial_in (y \<up> 2 + -2 * (x * p) = 0)";
  54.109 +if UnparseC.term t' = "y \<up> 2 + - 2 * x * p = 0" then ()
  54.110 +else error "make_polynomial_in (y \<up> 2 + - 2 * (x * p) = 0)";
  54.111  
  54.112  (*3(d)*)val (bdv,v) = (TermC.str2term "''bdv''", TermC.str2term "x2");
  54.113  val t = TermC.str2term 
  54.114 -"A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + -1 * (x1 * (y2 * (1 / 2))) + -1 * (x3 * (y1 * (1 / 2 ))) + y1 * (1 / 2 * x2) + -1 * (y3 * (1 / 2 * x2)) = 0";
  54.115 +"A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + - 1 * (x1 * (y2 * (1 / 2))) + - 1 * (x3 * (y1 * (1 / 2 ))) + y1 * (1 / 2 * x2) + - 1 * (y3 * (1 / 2 * x2)) = 0";
  54.116  val SOME (t',_) = rewrite_set_inst_ thy false [(bdv,v)] make_polynomial_in t;
  54.117  if UnparseC.term t' =
  54.118 -"A + x1 * y3 * (1 / 2) + x3 * y2 * (1 / 2) + -1 * x1 * y2 * (1 / 2) +\n-1 * x3 * y1 * (1 / 2) +\ny1 * (1 / 2) * x2 +\n-1 * y3 * (1 / 2) * x2 =\n0"
  54.119 +"A + x1 * y3 * (1 / 2) + x3 * y2 * (1 / 2) + - 1 * x1 * y2 * (1 / 2) +\n- 1 * x3 * y1 * (1 / 2) +\ny1 * (1 / 2) * x2 +\n- 1 * y3 * (1 / 2) * x2 =\n0"
  54.120  then ()
  54.121 -else error "make_polynomial_in (A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + -1...";
  54.122 +else error "make_polynomial_in (A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + - 1...";
  54.123  "A + x1 * y3 * (1 / 2) + x3 * y2 * (1 / 2) + - x1 * y2 * (1 / 2) + - x3 * y1 * (1 / 2) + (y1 * (1 / 2) + - y3 * (1 / 2)) * x2 = 0";
  54.124  
  54.125  val SOME (t',_) = rewrite_set_inst_ thy false [(bdv,v)] make_ratpoly_in t;
  54.126  if UnparseC.term t' = 
  54.127 -"A / 1 + x1 * y3 / 2 + x3 * y2 / 2 + -1 * x1 * y2 / 2 + -1 * x3 * y1 / 2 +\ny1 * x2 / 2 +\n-1 * y3 * x2 / 2 =\n0"
  54.128 +"A / 1 + x1 * y3 / 2 + x3 * y2 / 2 + - 1 * x1 * y2 / 2 + - 1 * x3 * y1 / 2 +\ny1 * x2 / 2 +\n- 1 * y3 * x2 / 2 =\n0"
  54.129  then ()
  54.130 -else error "make_ratpoly_in (A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + -1...";
  54.131 -"A + x1 * y3 * (1 / 2) + x3 * y2 * (1 / 2) + -1 * x1 * y2 * (1 / 2) + -1 * x3 * y1 * (1 / 2) + (y1 * (1 / 2) + -1 * y3 * (1 / 2)) * x2 = 0";
  54.132 +else error "make_ratpoly_in (A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + - 1...";
  54.133 +"A + x1 * y3 * (1 / 2) + x3 * y2 * (1 / 2) + - 1 * x1 * y2 * (1 / 2) + - 1 * x3 * y1 * (1 / 2) + (y1 * (1 / 2) + - 1 * y3 * (1 / 2)) * x2 = 0";
  54.134  
  54.135  (*3(e)*)val (bdv,v) = (TermC.str2term "bdv", TermC.str2term "a");
  54.136  val t = TermC.str2term 
  54.137 @@ -252,9 +252,9 @@
  54.138  (* the invisible parentheses are as expected *)
  54.139  
  54.140  val t = TermC.str2term "(x + 1) * (x + 2) - (3 * x - 2) \<up> 2 - ((2 * x - 1) \<up> 2 + (3 * x - 1) * (x + 1)) = 0";
  54.141 -Rewrite.trace_on:=(*true*)false;
  54.142 +Rewrite.trace_on:= false; (*true false*)
  54.143  rewrite_set_ thy false expand_binoms t;
  54.144 -Rewrite.trace_on:=false;
  54.145 +Rewrite.trace_on:=false; (*true false*)
  54.146  
  54.147  
  54.148  "----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
  54.149 @@ -262,7 +262,7 @@
  54.150  "----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
  54.151  reset_states ();
  54.152  CalcTree
  54.153 -[(["equality ((3::real)*x - 1 - (5*x - (2 - 4*x)) = -11)", "solveFor x", "solutions L"], 
  54.154 +[(["equality ((3::real)*x - 1 - (5*x - (2 - 4*x)) = - 11)", "solveFor x", "solutions L"], 
  54.155    ("PolyEq",["univariate", "equation"],["no_met"]))];
  54.156  Iterator 1;
  54.157  moveActiveRoot 1;
    55.1 --- a/test/Tools/isac/Knowledge/polyminus.sml	Mon Jun 21 22:08:01 2021 +0200
    55.2 +++ b/test/Tools/isac/Knowledge/polyminus.sml	Sun Jul 18 18:15:27 2021 +0200
    55.3 @@ -7,6 +7,9 @@
    55.4  "--------------------------------------------------------";
    55.5  "table of contents --------------------------------------";
    55.6  "--------------------------------------------------------";
    55.7 +"----------- fun identifier --------------------------------------------------------------------";
    55.8 +"----------- fun eval_kleiner, fun kleiner -----------------------------------------------------";
    55.9 +"----------- fun ist_monom ---------------------------------------------------------------------";
   55.10  "----------- fun eval_ist_monom -------------------------";
   55.11  "----------- watch order_add_mult  ----------------------";
   55.12  "----------- build predicate for +- ordering ------------";
   55.13 @@ -29,10 +32,104 @@
   55.14  
   55.15  val thy = @{theory "PolyMinus"};
   55.16  
   55.17 +"----------- fun identifier --------------------------------------------------------------------";
   55.18 +"----------- fun identifier --------------------------------------------------------------------";
   55.19 +"----------- fun identifier --------------------------------------------------------------------";
   55.20 +if identifier (TermC.str2term "12 ::real") = "12"     then () else error "identifier 1";
   55.21 +if identifier (TermC.str2term "a ::real") = "a"       then () else error "identifier 2";
   55.22 +if identifier (TermC.str2term "3 * a ::real") = "a"   then () else error "identifier 3";
   55.23 +if identifier (TermC.str2term "a \<up> 2 ::real") = "a"   then () else error "identifier 4";
   55.24 +if identifier (TermC.str2term "3*a \<up> 2 ::real") = "a" then () else error "identifier 5";
   55.25 +if identifier (TermC.str2term "a * b ::real") = "b"   then () else error "identifier 5b";
   55.26 +
   55.27 +(*these are strange (see "specific monomials" in comment to fun.def.)..*)
   55.28 +if identifier (TermC.str2term "a*b ::real") = "b"     then () else error "identifier 6";
   55.29 +if identifier (TermC.str2term "(3*a*b) ::real") = "b" then () else error "identifier 7";
   55.30 +
   55.31 +
   55.32 +"----------- fun eval_kleiner, fun kleiner -----------------------------------------------------";
   55.33 +"----------- fun eval_kleiner, fun kleiner -----------------------------------------------------";
   55.34 +"----------- fun eval_kleiner, fun kleiner -----------------------------------------------------";
   55.35 +"a" < "b";
   55.36 +"ba" < "ab";
   55.37 +"123" < "a"; (*unused due to ---vvv*)
   55.38 +"12" < "3"; (*true !!!*)
   55.39 +
   55.40 +" a kleiner b ==> (b + a) = (a + b)";
   55.41 +TermC.str2term "aaa";
   55.42 +TermC.str2term "222 * aaa";
   55.43 +
   55.44 +case eval_kleiner 0 0 (TermC.str2term "123 kleiner 32") 0 of
   55.45 +    SOME ("123 kleiner 32 = False", _) => ()
   55.46 +  | _ => error "polyminus.sml: 12 kleiner 9 = False";
   55.47 +case eval_kleiner 0 0 (TermC.str2term "a kleiner b") 0 of
   55.48 +    SOME ("a kleiner b = True", _) => ()
   55.49 +  | _ => error "polyminus.sml: a kleiner b = True";
   55.50 +case eval_kleiner 0 0 (TermC.str2term "(10*g) kleiner f") 0 of
   55.51 +    SOME ("10 * g kleiner f = False", _) => ()
   55.52 +  | _ => error "polyminus.sml: 10 * g kleiner f = False";
   55.53 +case eval_kleiner 0 0 (TermC.str2term "(a \<up> 2) kleiner b") 0 of
   55.54 +    SOME ("a \<up> 2 kleiner b = True", _) => ()
   55.55 +  | _ => error "polyminus.sml: a \<up> 2 kleiner b = True";
   55.56 +case eval_kleiner 0 0 (TermC.str2term "(3*a \<up> 2) kleiner b") 0 of
   55.57 +    SOME ("3 * a \<up> 2 kleiner b = True", _) => ()
   55.58 +  | _ => error "polyminus.sml: 3 * a \<up> 2 kleiner b = True";
   55.59 +case eval_kleiner 0 0 (TermC.str2term "(a*b) kleiner c") 0 of
   55.60 +    SOME ("a * b kleiner c = True", _) => ()
   55.61 +  | _ => error "polyminus.sml: a * b kleiner b = True";
   55.62 +case eval_kleiner 0 0 (TermC.str2term "(3*a*b) kleiner c") 0 of
   55.63 +    SOME ("3 * a * b kleiner c = True", _) => ()
   55.64 +  | _ => error "polyminus.sml: 3 * a * b kleiner b = True";
   55.65 +
   55.66 +
   55.67 +val t = TermC.str2term "12 kleiner 5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * (g::real)";
   55.68 +val SOME ("12 kleiner 5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g = True", _) =
   55.69 +           eval_kleiner "aaa" "bbb" t "ccc";
   55.70 +"~~~~~ fun eval_kleiner , args:"; val (_, _, (p as (Const ("PolyMinus.kleiner",_) $ a $ b)), _) =
   55.71 +  ("aaa", "bbb", t, "ccc");
   55.72 +    (*if*) TermC.is_num b (*else*);
   55.73 +
   55.74 +   	(*if*) identifier a < identifier b  (*else*);
   55.75 +"~~~~~ fun identifier , args:"; val (t) = (a);
   55.76 +(*+*)case a of
   55.77 +  Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $
   55.78 +    (Const ("Num.num.Bit0", _) $ (Const ("Num.num.Bit1", _) $ Const ("Num.num.One", _)))) => ()
   55.79 +| _ => error "eval_kleiner CHANGED";                                                 (*isa*)
   55.80 +
   55.81 +
   55.82 +"----------- fun ist_monom ---------------------------------------------------------------------";
   55.83 +"----------- fun ist_monom ---------------------------------------------------------------------";
   55.84 +"----------- fun ist_monom ---------------------------------------------------------------------";
   55.85 +val t = TermC.str2term "0 ::real";
   55.86 + if ist_monom t then () else error "ist_monom 1";
   55.87 +
   55.88 +val t = TermC.str2term "a";
   55.89 +if ist_monom t then () else error "ist_monom 2";
   55.90 +
   55.91 +val t = TermC.str2term "2 * a";
   55.92 +if ist_monom t then () else error "ist_monom 3";
   55.93 +
   55.94 +val t = TermC.str2term "2 * a * b";
   55.95 +if ist_monom t then () else error "ist_monom 4";
   55.96 +
   55.97 +val t = TermC.str2term "a * b";
   55.98 +if ist_monom t then () else error "ist_monom 5";
   55.99 +
  55.100 +(*not covered before NEW numerals*)
  55.101 +val t = TermC.str2term "2 * a \<up> 2 * b";
  55.102 +if ist_monom t then () else error "ist_monom 6";
  55.103 +
  55.104 +(*not covered before NEW numerals*)
  55.105 +val t = TermC.str2term "a \<up> 2 * b \<up> 3";
  55.106 +if ist_monom t then () else error "ist_monom 7";
  55.107 +
  55.108 +val t = TermC.str2term "a \<up> 2 * 4 * b \<up> 3 * 5";
  55.109 +if ist_monom t then () else error "ist_monom 8";
  55.110 +
  55.111 +
  55.112  "----------- fun eval_ist_monom ----------------------------------";
  55.113  "----------- fun eval_ist_monom ----------------------------------";
  55.114  "----------- fun eval_ist_monom ----------------------------------";
  55.115 -ist_monom (TermC.str2term "12");
  55.116  case eval_ist_monom 0 0 (TermC.str2term "12 ist_monom") 0 of
  55.117      SOME ("12 ist_monom = True", _) => ()
  55.118    | _ => error "polyminus.sml: 12 ist_monom = True";
  55.119 @@ -67,12 +164,12 @@
  55.120  "----------- watch order_add_mult  -------------------------------";
  55.121  "----- with these simple variables it works...";
  55.122  (*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
  55.123 -Rewrite.trace_on:=false;
  55.124 +Rewrite.trace_on:=false; (*true false*)
  55.125  val t = TermC.str2term "((a + d) + c) + b";
  55.126  val SOME (t,_) = rewrite_set_ thy false order_add_mult t; UnparseC.term t;
  55.127  if UnparseC.term t = "a + (b + (c + d))" then ()
  55.128  else error "polyminus.sml 1 watch order_add_mult";
  55.129 -Rewrite.trace_on:=false;
  55.130 +Rewrite.trace_on:=false; (*true false*)
  55.131  
  55.132  "----- the same stepwise...";
  55.133  val od = ord_make_polynomial true (@{theory "Poly"});
  55.134 @@ -187,7 +284,7 @@
  55.135  else error "polyminus.sml: ordne_alphabetisch a + b + c";
  55.136  
  55.137  "======= rewrite goes into subterms";
  55.138 -val t = TermC.str2term "a + c + b + d";
  55.139 +val t = TermC.str2term "a + c + b + d ::real";
  55.140  val SOME (t,_) = rewrite_ thy od erls false @{thm tausche_plus_plus} t; UnparseC.term t;
  55.141  if UnparseC.term t = "a + b + c + d" then ()
  55.142  else error "polyminus.sml: ordne_alphabetisch1 a + b + c + d";
  55.143 @@ -216,19 +313,19 @@
  55.144  "----------- build fasse_zusammen --------------------------------";
  55.145  val t = TermC.str2term "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g";
  55.146  val SOME (t,_) = rewrite_set_ thy false fasse_zusammen t;
  55.147 -if UnparseC.term t = "3 + -2 * e + 2 * f + 2 * g" then ()
  55.148 +if UnparseC.term t = "3 + - 2 * e + 2 * f + 2 * g" then ()
  55.149  else error "polyminus.sml: fasse_zusammen finished";
  55.150  
  55.151  "----------- build verschoenere ----------------------------------";
  55.152  "----------- build verschoenere ----------------------------------";
  55.153  "----------- build verschoenere ----------------------------------";
  55.154 -val t = TermC.str2term "3 + -2 * e + 2 * f + 2 * g";
  55.155 +val t = TermC.str2term "3 + - 2 * e + 2 * f + 2 * g";
  55.156  val SOME (t,_) = rewrite_set_ thy false verschoenere t;
  55.157  if UnparseC.term t = "3 - 2 * e + 2 * f + 2 * g" then ()
  55.158 -else error "polyminus.sml: verschoenere 3 + -2 * e ...";
  55.159 +else error "polyminus.sml: verschoenere 3 + - 2 * e ...";
  55.160  
  55.161  (*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
  55.162 -Rewrite.trace_on:=false;
  55.163 +Rewrite.trace_on:=false; (*true false*)
  55.164  
  55.165  "----------- met simplification for_polynomials with_minus -------";
  55.166  "----------- met simplification for_polynomials with_minus -------";
  55.167 @@ -259,11 +356,17 @@
  55.168  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  55.169  
  55.170  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  55.171 +   f2str f = "5 * e + 6 * f - 8 * g - 9 - 7 * e - 4 * f + 10 * g + 12";      (*isa == isa2*)
  55.172 +val (p''''',_,f,nxt''''',_,pt''''') = me nxt p c pt;
  55.173 +   val                                 (*^^^*) Rewrite_Set "ordne_alphabetisch" = nxt;
  55.174 +   f2str f = "- 9 + 12 + 5 * e - 7 * e + 6 * f - 4 * f - 8 * g + 10 * g";    (*isa2*)
  55.175 +val (p,_,f,nxt,_,pt) = me nxt''''' p''''' c pt''''';
  55.176 +   f2str f = "3 + - 2 * e + 2 * f + 2 * g";                                  (*isa2*)
  55.177  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  55.178 +   f2str f = "3 - 2 * e + 2 * f + 2 * g";                                    (*isa2*)
  55.179  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  55.180 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
  55.181 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
  55.182 -if f2str f = "3 - 2 * e + 2 * f + 2 * g" 
  55.183 +   f2str f = "3 - 2 * e + 2 * f + 2 * g";                                    (*isa2*)
  55.184 +if f2str f = "3 - 2 * e + 2 * f + 2 * g"                                     (*isa2*)
  55.185  then case nxt of End_Proof' => () | _ =>  error "me simplification.for_polynomials.with_minus 1"
  55.186  else error "polyminus.sml: me simplification.for_polynomials.with_minus 2";
  55.187  
  55.188 @@ -319,7 +422,7 @@
  55.189  autoCalculate 1 CompleteCalc;
  55.190  val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  55.191  if p = ([], Res) andalso 
  55.192 -   UnparseC.term (get_obj g_res pt (fst p)) = "-3 * u - v"
  55.193 +   UnparseC.term (get_obj g_res pt (fst p)) = "- 3 * u - v"
  55.194  then () else error "polyminus.sml: Vereinfache 139 b)";
  55.195  
  55.196  "======= 138 a ---";
  55.197 @@ -332,7 +435,7 @@
  55.198  autoCalculate 1 CompleteCalc;
  55.199  val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  55.200  if p = ([], Res) andalso 
  55.201 -   UnparseC.term (get_obj g_res pt (fst p)) = "-4 * u + 2 * v"
  55.202 +   UnparseC.term (get_obj g_res pt (fst p)) = "- 4 * u + 2 * v"
  55.203  then () else error "polyminus.sml: Vereinfache 138 a)";
  55.204  
  55.205  "----------- met probe fuer_polynom ------------------------------";
  55.206 @@ -435,7 +538,7 @@
  55.207  val SOME (t',_) = 
  55.208      rewrite_set_ (@{theory "Isac_Knowledge"}) false ordne_alphabetisch t;
  55.209  UnparseC.term t';     "- 9 + 12 + 5 * e - 7 * e - 8 * g + 10 * g + (- 4 + 6) * f";
  55.210 -Rewrite.trace_on := false;
  55.211 +Rewrite.trace_on := false; (*true false*)
  55.212  
  55.213  
  55.214  applyTactic 1 p (hd (specific_from_prog pt p)) (*tausche_minus*);
  55.215 @@ -530,8 +633,10 @@
  55.216  moveActiveRoot 1;
  55.217  autoCalculate 1 CompleteCalc;
  55.218  val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
  55.219 -if p = ([], Res) andalso 
  55.220 -   UnparseC.term (get_obj g_res pt (fst p)) = "-2 + 12 * a \<up> 2 + 5 * a"
  55.221 +
  55.222 +if p = ([], Res) andalso
  55.223 +   UnparseC.term (get_obj g_res pt (fst p)) =(*"- 2 + 12 * a \<up> 2 + 5 * a" with OLD numerals*)
  55.224 +                                               "- 2 + 5 * a + 12 * a \<up> 2"
  55.225  then () else error "polyminus.sml: Vereinfache (2*u - 5 - (3 - ...";
  55.226  
  55.227  "----------- pbl binom polynom vereinfachen: cube ----------------";
  55.228 @@ -579,7 +684,7 @@
  55.229  	      (*"(~ False) = True"*)];
  55.230  (*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
  55.231  val SOME (t', _) = rewrite_set_ thy false prls t;
  55.232 -Rewrite.trace_on := false;
  55.233 +Rewrite.trace_on := false; (*true false*)
  55.234  
  55.235  "--- does the respective prls rewrite the whole predicate ?";
  55.236  val t = TermC.str2term 
  55.237 @@ -589,7 +694,7 @@
  55.238  	    \     matchsub ((?b - ?c) * ?a) (8 * (a - q) + a - 2 * q) )";
  55.239  (*Rewrite.trace_on := true; ..stopped Test_Isac.thy*)
  55.240  val SOME (t', _) = rewrite_set_ thy false prls t;
  55.241 -Rewrite.trace_on := false;
  55.242 +Rewrite.trace_on := false; (*true false*)
  55.243  if UnparseC.term t' = "False" then ()
  55.244  else error "polyminus.sml Not (matchsub (?a * (?b + ?c)) (8 ...";
  55.245  
    56.1 --- a/test/Tools/isac/Knowledge/rateq.sml	Mon Jun 21 22:08:01 2021 +0200
    56.2 +++ b/test/Tools/isac/Knowledge/rateq.sml	Sun Jul 18 18:15:27 2021 +0200
    56.3 @@ -30,7 +30,7 @@
    56.4  val result = UnparseC.term t_;
    56.5  if result <>  "False"  then error "rateq.sml: new behaviour 2:" else ();
    56.6  
    56.7 -val t = (Thm.term_of o the o (TermC.parse thy)) "(x=-1) is_ratequation_in x";
    56.8 +val t = (Thm.term_of o the o (TermC.parse thy)) "(x=- 1) is_ratequation_in x";
    56.9  val SOME (t_,_) = rewrite_set_ thy  false RatEq_prls t;
   56.10  val result = UnparseC.term t_;
   56.11  if result <>  "False"  then error "rateq.sml: new behaviour 3:" else ();
   56.12 @@ -98,7 +98,7 @@
   56.13  ("ok", (_, _, ptp)) => ptp | _ => error "--- solve (1/x = 5.. Step.by_tactic";
   56.14  "~~~~~ fun Step.do_next, args:"; val (ip as (_,p_), (ptp as (pt,p), tacis)) = (p, ((pt, e_pos'), []))
   56.15  val pIopt = get_pblID (pt,ip); (*= SOME ["rational", "univariate", "equation"]
   56.16 -                       1-1 associated to metID ["RatEq", "solve_rat_equation"]*)
   56.17 +                       1- 1 associated to metID ["RatEq", "solve_rat_equation"]*)
   56.18  tacis; (*= []*)
   56.19  member op = [Pbl,Met] p_; (*= false*)
   56.20  "~~~~~ fun do_next, args:"; val (ptp as (pt, pos as (p, p_))) = (pt, ip);
   56.21 @@ -200,7 +200,7 @@
   56.22    (case nxt of
   56.23      ("Add_Given", Add_Given "solveFor x") =>
   56.24        (case f of
   56.25 -        Test_Out.PpcKF (Problem [], {Given = [Incompl "solveFor", Correct "equality (320 + 128 * x + -16 * x \<up> 2 = 0)"], ...}) => ()
   56.26 +        Test_Out.PpcKF (Problem [], {Given = [Incompl "solveFor", Correct "equality (320 + 128 * x + - 16 * x \<up> 2 = 0)"], ...}) => ()
   56.27        | _ => error ("S.68, Bsp.: 40 PblObj changed"))
   56.28    | _ => error ("S.68, Bsp.: 40 changed nxt =" ^ Tactic.input_to_string (snd nxt)));
   56.29  
   56.30 @@ -217,7 +217,7 @@
   56.31  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   56.32  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   56.33  if p = ([], Res) andalso f2str f = "[]" then () 
   56.34 -else error "rateq.sml: new behaviour: [x = -2, x = 10]";
   56.35 +else error "rateq.sml: new behaviour: [x = - 2, x = 10]";
   56.36  
   56.37  "----------- remove x = 0 from [x = 0, x = 6 / 5] ----------------------------------------------";
   56.38  "----------- remove x = 0 from [x = 0, x = 6 / 5] ----------------------------------------------";
   56.39 @@ -237,14 +237,14 @@
   56.40  
   56.41  val (p,_,f,nxt,_,pt) = me nxt p [] pt;                                         (* 0. solve-phase*)
   56.42  val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   56.43 -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)";
   56.44 +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)";
   56.45  
   56.46  (*+*)if eq_set op = (Ctree.get_assumptions pt p |> map UnparseC.term,
   56.47  (*+*)  ["x \<noteq> 0", 
   56.48  (*+*)  "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0", 
   56.49  (*+*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x"])
   56.50  (*+*)then () else error "assumptions before 1. Subproblem CHANGED";
   56.51 -(*+*)if p = ([3], Res) andalso f2str f = "(3 + -1 * x + x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)"
   56.52 +(*+*)if p = ([3], Res) andalso f2str f = "(3 + - 1 * x + x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)"
   56.53  (*+*)then
   56.54  (*+*)  ((case nxt of Subproblem ("PolyEq", ["normalise", "polynomial", "univariate", "equation"]) => ()
   56.55  (*+*)  | _ => error ("S.68, Bsp.: 40 nxt =" ^ Tactic.input_to_string nxt)))
   56.56 @@ -286,8 +286,8 @@
   56.57  
   56.58  (*     *)if eq_set op = ((Ctree.get_assumptions pt p |> map UnparseC.term), [
   56.59  (*0.pre*)  "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x",
   56.60 -(*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"
   56.61 -(*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",
   56.62 +(*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"
   56.63 +(*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",
   56.64  (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x", 
   56.65  (*2.pre*)  "lhs (-6 * x + 5 * x \<up> 2 = 0) has_degree_in x = 2",
   56.66  (*0.asm*)  "x \<noteq> 0", 
   56.67 @@ -308,7 +308,7 @@
   56.68  if f2str f = "[x = 6 / 5]" andalso eq_set op = (map UnparseC.term (Ctree.get_assumptions pt p),
   56.69   ["x = 6 / 5", "lhs (-6 * x + 5 * x \<up> 2 = 0) is_poly_in x",
   56.70    "lhs (-6 * x + 5 * x \<up> 2 = 0) has_degree_in x = 2",
   56.71 -  "\<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",
   56.72 +  "\<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",
   56.73    "x \<noteq> 0", "9 * x + -6 * x \<up> 2 + x \<up> 3 \<noteq> 0",
   56.74    "x / (x \<up> 2 - 6 * x + 9) - 1 / (x \<up> 2 - 3 * x) =\n1 / x is_ratequation_in x"])
   56.75  then () else error "test CHANGED";
   56.76 @@ -334,7 +334,7 @@
   56.77  (*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*Rewrite_Set "norm_Rational"*)
   56.78  
   56.79  (*+*)if (get_istate_LI pt p |> Istate.string_of) (* solve-phase: found_accept = true -----------------------------------------------------------------------------------------------> vvvvv*)
   56.80 -(*+*) = "Pstate ([\"\n(e_e, 5 * x / (x - 2) - x / (x + 2) = 4)\",\"\n(v_v, x)\"], [R,L,R,L,L,R,R,R], Rule_Set.empty, SOME e_e, \n5 * x / (x + -1 * 2) + -1 * x / (x + 2) = 4, ORundef, true, true)"
   56.81 +(*+*) = "Pstate ([\"\n(e_e, 5 * x / (x - 2) - x / (x + 2) = 4)\",\"\n(v_v, x)\"], [R,L,R,L,L,R,R,R], Rule_Set.empty, SOME e_e, \n5 * x / (x + - 1 * 2) + - 1 * x / (x + 2) = 4, ORundef, true, true)"
   56.82  (*+*)then () else error "rat-eq + subpbl: istate after found_accept";
   56.83  
   56.84  (*[2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt;(*Rewrite_Set "RatEq_eliminate"*)
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/test/Tools/isac/Knowledge/rational-1.sml	Sun Jul 18 18:15:27 2021 +0200
    57.3 @@ -0,0 +1,151 @@
    57.4 +(* Title: test/Tools/isac/Knowledge/rational-1.sml
    57.5 +   Author: Walther Neuper
    57.6 +   Use is subject to license terms.
    57.7 +
    57.8 +Test of basic functions and application to complex examples.
    57.9 +*)
   57.10 +
   57.11 +"-----------------------------------------------------------------------------------------------";
   57.12 +"-----------------------------------------------------------------------------------------------";
   57.13 +"table of contents -----------------------------------------------------------------------------";
   57.14 +"-----------------------------------------------------------------------------------------------";
   57.15 +"-------- fun poly_of_term ---------------------------------------------------------------------";
   57.16 +"-------- fun is_poly --------------------------------------------------------------------------";
   57.17 +"-------- fun term_of_poly ---------------------------------------------------------------------";
   57.18 +"-------- complex examples: rls norm_Rational --------------------------------------------------";
   57.19 +"-------- complex examples cancellation from: Mathematik 1 Schalk ------------------------------";
   57.20 +"-----------------------------------------------------------------------------------------------";
   57.21 +"-----------------------------------------------------------------------------------------------";
   57.22 +
   57.23 +
   57.24 +"-------- fun poly_of_term ---------------------------------------------------------------------";
   57.25 +"-------- fun poly_of_term ---------------------------------------------------------------------";
   57.26 +"-------- fun poly_of_term ---------------------------------------------------------------------";
   57.27 +val thy = @{theory Partial_Fractions};
   57.28 +val vs = TermC.vars_of (TermC.str2term "12 * x \<up> 3 * y \<up> 4 * z \<up> 6");
   57.29 +
   57.30 +val t = TermC.str2term "-3 + - 2 * x ::real";
   57.31 +if poly_of_term vs t = SOME [(~3, [0, 0, 0]), (~2, [1, 0, 0])]
   57.32 +then () else error "poly_of_term uminus changed";
   57.33 +
   57.34 +if poly_of_term vs (TermC.str2term "12::real") = SOME [(12, [0, 0, 0])]
   57.35 +then () else error "poly_of_term 1 changed";
   57.36 +
   57.37 +if poly_of_term vs (TermC.str2term "x::real") = SOME [(1, [1, 0, 0])]
   57.38 +then () else error "poly_of_term 2 changed";
   57.39 +
   57.40 +if         poly_of_term vs (TermC.str2term "12 * x \<up> 3") = SOME [(12, [3, 0, 0])]
   57.41 +then () else error "poly_of_term 3 changed";
   57.42 +"~~~~~ fun poly_of_term , args:"; val (vs, t) =
   57.43 +  (vs, (TermC.str2term "12 * x \<up> 3"));
   57.44 +
   57.45 +           monom_of_term vs (1, replicate (length vs) 0) t;(*poly malformed 1 with x \<up> 3*)
   57.46 +"~~~~~ fun monom_of_term , args:"; val (vs, (c, es), (Const ("Groups.times_class.times", _) $ m1 $ m2)) =
   57.47 +  (vs, (1, replicate (length vs) 0), t);
   57.48 +    val (c', es') =
   57.49 +
   57.50 +           monom_of_term vs (c, es) m1;
   57.51 +"~~~~~ fun monom_of_term , args:"; val (vs, (c, es), (Const ("Transcendental.powr", _) $ (t as Free _) $ (Const ("Num.numeral_class.numeral", _) $ num)) ) =
   57.52 +  (vs, (c', es'), m2);
   57.53 +(*+*)c = 12;
   57.54 +(*+*)(num |> HOLogic.dest_numeral |> list_update es (find_index (curry op = t) vs)) = [3, 0, 0];
   57.55 +
   57.56 +if (c, num |> HOLogic.dest_numeral |> list_update es (find_index (curry op = t) vs)) = (12, [3, 0, 0])
   57.57 +then () else error "monom_of_term (powr): return value CHANGED";
   57.58 +
   57.59 +if poly_of_term vs (TermC.str2term "12 * x \<up> 3 * y \<up> 4 * z \<up> 6") = SOME [(12, [3, 4, 6])]
   57.60 +then () else error "poly_of_term 4 changed";
   57.61 +
   57.62 +if poly_of_term vs (TermC.str2term "1 + 2 * x \<up> 3 * y \<up> 4 * z \<up> 6 + y") =
   57.63 +  SOME [(1, [0, 0, 0]), (1, [0, 1, 0]), (2, [3, 4, 6])]
   57.64 +then () else error "poly_of_term 5 changed";
   57.65 +
   57.66 +(*poly_of_term is quite liberal:*)
   57.67 +(*the coefficient may be somewhere, the order of variables and the parentheses 
   57.68 +  within a monomial are arbitrary*)
   57.69 +if poly_of_term vs (TermC.str2term "y \<up> 4 * (x \<up> 3 * 12 * z \<up> 6)") = SOME [(12, [3, 4, 6])]
   57.70 +then () else error "poly_of_term 6 changed";
   57.71 +
   57.72 +(*there may even be more than 1 coefficient:*)
   57.73 +if poly_of_term vs (TermC.str2term "2 * y \<up> 4 * (x \<up> 3 * 6 * z \<up> 6)") = SOME [(12, [3, 4, 6])]
   57.74 +then () else error "poly_of_term 7 changed";
   57.75 +
   57.76 +(*the order and the parentheses within monomials are arbitrary:*)
   57.77 +if poly_of_term vs (TermC.str2term "2 * x \<up> 3 * y \<up> 4 * z \<up> 6 + (7 * y \<up> 8 + 1)")
   57.78 +  = SOME [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 6])]
   57.79 +then () else error "poly_of_term 8 changed";
   57.80 +
   57.81 +(*from --- rls norm_Rational downto fun gcd_poly ---*)
   57.82 +val t = TermC.str2term (*copy from above: "::real" is not required due to " \<up> "*)
   57.83 +  ("(- 12 + 4 * y + 3 * x \<up> 2 + - 1 * (x \<up> 2 * y)) /" ^
   57.84 +  "(- 18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)");
   57.85 +"~~~~~ fun cancel_p_, args:"; val (t) = (t);
   57.86 +val opt = check_fraction t;
   57.87 +val SOME (numerator, denominator) = opt;
   57.88 +(*+*)UnparseC.term numerator = "- 12 + 4 * y + 3 * x \<up> 2 + - 1 * (x \<up> 2 * y)"; (*isa -- isa2*);
   57.89 +(*+*)UnparseC.term denominator = "- 18 + - 9 * x + 2 * y \<up> 2 + x * y \<up> 2";     (*isa -- isa2*);
   57.90 +       val vs = TermC.vars_of t;
   57.91 +(*+*)UnparseC.terms vs = "[\"x\", \"y\"]";
   57.92 +       val baseT = type_of numerator
   57.93 +       val expT = HOLogic.realT;
   57.94 +val (SOME _, SOME _) = (poly_of_term vs numerator, poly_of_term vs denominator);  (*isa <> isa2*)
   57.95 +
   57.96 +"-------- fun is_poly --------------------------------------------------------------------------";
   57.97 +"-------- fun is_poly --------------------------------------------------------------------------";
   57.98 +"-------- fun is_poly --------------------------------------------------------------------------";
   57.99 +if is_poly (TermC.str2term "2 * x \<up> 3 * y \<up> 4 * z \<up> 6 + 7 * y \<up> 8 + 1")
  57.100 +then () else error "is_poly 1 changed";
  57.101 +if not (is_poly (TermC.str2term "2 * (x \<up> 3 * y \<up> 4 * z \<up> 6 + 7) * y \<up> 8 + 1"))
  57.102 +then () else error "is_poly 2 changed";
  57.103 +
  57.104 +"-------- fun term_of_poly ---------------------------------------------------------------------";
  57.105 +"-------- fun term_of_poly ---------------------------------------------------------------------";
  57.106 +"-------- fun term_of_poly ---------------------------------------------------------------------";
  57.107 +val expT = HOLogic.realT
  57.108 +val Free (_, baseT) = (hd o vars o TermC.str2term) "12 * x \<up> 3 * y \<up> 4 * z \<up> 6";
  57.109 +val p = [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 5])]
  57.110 +val vs = TermC.vars_of (the (parseNEW ctxt "12 * x \<up> 3 * y \<up> 4 * z \<up> 6"))
  57.111 +(*precondition for [(c, es),...]: legth es = length vs*)
  57.112 +;
  57.113 +if UnparseC.term (term_of_poly baseT expT vs p) = "1 + 7 * y \<up> 8 + 2 * x \<up> 3 * y \<up> 4 * z \<up> 5"
  57.114 +then () else error "term_of_poly 1 changed";
  57.115 +
  57.116 +"-------- complex examples: rls norm_Rational --------------------------------------------------";
  57.117 +"-------- complex examples: rls norm_Rational --------------------------------------------------";
  57.118 +"-------- complex examples: rls norm_Rational --------------------------------------------------";
  57.119 +val t = TermC.str2term "(3*x+5)/18 - x/2  - -(3*x - 2)/9 = 0";
  57.120 +val SOME (t', _) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  57.121 +if UnparseC.term t' = "1 / 18 = 0" then () else error "rational.sml 1";
  57.122 +
  57.123 +val t = TermC.str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
  57.124 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  57.125 +if UnparseC.term t' = "(237 + 65 * x) / 36 = 0" then () 
  57.126 +else error "rational.sml 2";
  57.127 +
  57.128 +val t = TermC.str2term "(1/2 + (5*x)/2) \<up> 2 - ((13*x)/2 - 5/2) \<up> 2 - (6*x) \<up> 2 + 29";
  57.129 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  57.130 +if UnparseC.term t' = "23 + 35 * x + - 72 * x \<up> 2" then ()
  57.131 +else error "rational.sml 3";
  57.132 +
  57.133 +"-------- complex examples cancellation from: Mathematik 1 Schalk ------------------------------";
  57.134 +"-------- complex examples cancellation from: Mathematik 1 Schalk ------------------------------";
  57.135 +"-------- complex examples cancellation from: Mathematik 1 Schalk ------------------------------";
  57.136 +(*Schalk I, p.60 Nr. 215c *)
  57.137 +val t = TermC.str2term "(a + b) \<up> 4 * (x - y)  /  ((x - y) \<up> 3 * (a + b) \<up> 2)";
  57.138 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  57.139 +if UnparseC.term t = "(a \<up> 2 + 2 * a * b + b \<up> 2) / (x \<up> 2 + - 2 * x * y + y \<up> 2)"
  57.140 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 7";
  57.141 +
  57.142 +(*SRC Schalk I, p.66 Nr. 381b *)
  57.143 +val t = TermC.str2term 
  57.144 +"(4*x \<up> 2 - 20*x + 25)/(2*x - 5) \<up> 3";
  57.145 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  57.146 +if UnparseC.term t = "1 / (- 5 + 2 * x)"
  57.147 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 9";
  57.148 +
  57.149 +(*Schalk I, p.60 Nr. 215c *)
  57.150 +val t = TermC.str2term "(a + b) \<up> 4 * (x - y)  /  ((x - y) \<up> 3 * (a + b) \<up> 2)";
  57.151 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  57.152 +if UnparseC.term t = "(a \<up> 2 + 2 * a * b + b \<up> 2) / (x \<up> 2 + - 2 * x * y + y \<up> 2)"
  57.153 +then () else error "Schalk I, p.60 Nr. 215c: with Isabelle2002 cancellation incomplete, changed";
  57.154 +
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/test/Tools/isac/Knowledge/rational-2.sml	Sun Jul 18 18:15:27 2021 +0200
    58.3 @@ -0,0 +1,1792 @@
    58.4 +(* Title: tests for rationals
    58.5 +   Author: Walther Neuper
    58.6 +   Use is subject to license terms.
    58.7 +*)
    58.8 +
    58.9 +"-----------------------------------------------------------------------------";
   58.10 +"-----------------------------------------------------------------------------";
   58.11 +"table of contents -----------------------------------------------------------";
   58.12 +"-----------------------------------------------------------------------------";
   58.13 +"-------- integration lev.1 fun factout_p_ -----------------------------------";
   58.14 +"-------- integration lev.1 fun cancel_p_ ------------------------------------";
   58.15 +"-------- integration lev.1 fun common_nominator_p_ --------------------------";
   58.16 +"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
   58.17 +"Rfuns-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
   58.18 +"Rfuns-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
   58.19 +"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
   58.20 +"Rfuns-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
   58.21 +"----------- rewrite_set_ Partial_Fractions norm_Rational --------------------------------------";
   58.22 +"----------- fun check_frac_sum with Free A and Const AA ---------------------------------------";
   58.23 +"----------- fun cancel_p with Const AA --------------------------------------------------------";
   58.24 +"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
   58.25 +"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
   58.26 +"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
   58.27 +"Rfuns-------- reverse rewrite ----------------------------------------------------";
   58.28 +"Rfuns-------- 'reverse-ruleset' cancel_p -----------------------------------------";
   58.29 +"-------- investigate rls norm_Rational --------------------------------------";
   58.30 +"-------- examples: rls norm_Rational ----------------------------------------";
   58.31 +"-------- rational numerals --------------------------------------------------";
   58.32 +"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
   58.33 +"-------- examples common denominator from: Mathematik 1 Schalk --------------";
   58.34 +"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
   58.35 +"-------- examples common denominator and multiplication from: Schalk --------";
   58.36 +"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
   58.37 +"-------- me Schalk I No.186 -------------------------------------------------";
   58.38 +"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
   58.39 +"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
   58.40 +"-------- investigate rulesets for cancel_p ----------------------------------";
   58.41 +"-------- fun eval_get_denominator -------------------------------------------";
   58.42 +"-------- several errpats in complicated term --------------------------------";
   58.43 +"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
   58.44 +"-----------------------------------------------------------------------------";
   58.45 +"-----------------------------------------------------------------------------";
   58.46 +
   58.47 +
   58.48 +"-------- integration lev.1 fun factout_p_ -----------------------------------";
   58.49 +"-------- integration lev.1 fun factout_p_ -----------------------------------";
   58.50 +"-------- integration lev.1 fun factout_p_ -----------------------------------";
   58.51 +val t = TermC.str2term "(x \<up> 2 + - 1*y \<up> 2) / (x \<up> 2 + - 1*x*y)"
   58.52 +val SOME (t', asm) = factout_p_ thy t;
   58.53 +if UnparseC.term t' = "(x + y) * (x + - 1 * y) / (x * (x + - 1 * y))"
   58.54 +then () else error ("factout_p_ term 1 changed: " ^ UnparseC.term t')
   58.55 +;
   58.56 +if UnparseC.terms asm = "[\"x \<noteq> 0\", \"x + - 1 * y \<noteq> 0\"]"
   58.57 +then () else error "factout_p_ asm 1 changed"
   58.58 +;
   58.59 +val t = TermC.str2term "nothing + to_cancel ::real";
   58.60 +if NONE = factout_p_ thy t then () else error "factout_p_ doesn't report non-applicable";
   58.61 +;
   58.62 +val t = TermC.str2term "((3 * x \<up> 2 + 6 *x + 3) / (2*x + 2))";
   58.63 +val SOME (t', asm) = factout_p_ thy t;
   58.64 +if UnparseC.term t' = "(3 + 3 * x) * (1 + x) / (2 * (1 + x))" andalso 
   58.65 +  UnparseC.terms asm = "[\"1 + x \<noteq> 0\"]"
   58.66 +then () else error "factout_p_ 1 changed";
   58.67 +
   58.68 +"-------- integration lev.1 fun cancel_p_ ------------------------------------";
   58.69 +"-------- integration lev.1 fun cancel_p_ ------------------------------------";
   58.70 +"-------- integration lev.1 fun cancel_p_ ------------------------------------";
   58.71 +val t = TermC.str2term "(x \<up> 2 + - 1*y \<up> 2) / (x \<up> 2 + - 1*x*y)"
   58.72 +val SOME (t', asm) = cancel_p_ thy t;
   58.73 +if (UnparseC.term t', UnparseC.terms asm) = ("(x + y) / x", "[\"x \<noteq> 0\"]")
   58.74 +then () else error ("cancel_p_ (t', asm) 1 changed: " ^ UnparseC.term t')
   58.75 +;
   58.76 +val t = TermC.str2term "nothing + to_cancel ::real";
   58.77 +if NONE = cancel_p_ thy t then () else error "cancel_p_ doesn't report non-applicable";
   58.78 +;
   58.79 +val t = TermC.str2term "((3 * x \<up> 2 + 6 *x + 3) / (2*x + 2))";
   58.80 +val SOME (t', asm) = cancel_p_ thy t;
   58.81 +if UnparseC.term t' = "(3 + 3 * x) / 2" andalso UnparseC.terms asm = "[]"
   58.82 +then () else error "cancel_p_ 1 changed";
   58.83 +
   58.84 +"-------- integration lev.1 fun common_nominator_p_ --------------------------";
   58.85 +"-------- integration lev.1 fun common_nominator_p_ --------------------------";
   58.86 +"-------- integration lev.1 fun common_nominator_p_ --------------------------";
   58.87 +val t = TermC.str2term ("y / (a*x + b*x + c*x) " ^
   58.88 +              (* n1    d1                   *)
   58.89 +                "+ a / (x*y)");
   58.90 +              (* n2    d2                   *)
   58.91 +val SOME (t', asm) = common_nominator_p_ thy t;
   58.92 +if UnparseC.term t' =
   58.93 +      ("y * y / (x * ((a + b + c) * y)) " ^
   58.94 +  (*  n1  *d2'/ (c'* ( d1'        *d2')) *)
   58.95 +     "+ a * (a + b + c) / (x * ((a + b + c) * y))")
   58.96 +   (*  n2 * d1'         / (c'* ( d1'        *d2')) *)
   58.97 +then () else error "common_nominator_p_ term 1 changed";
   58.98 +if UnparseC.terms asm = "[\"a + b + c \<noteq> 0\", \"y \<noteq> 0\", \"x \<noteq> 0\"]"
   58.99 +then () else error "common_nominator_p_ asm 1 changed"
  58.100 +
  58.101 +"-------- example in mail Nipkow";
  58.102 +val t = TermC.str2term "x/(x \<up> 2 + - 1*y \<up> 2) + y/(x \<up> 2 + - 1*x*y)";
  58.103 +val SOME (t', asm) = common_nominator_p_ thy t;
  58.104 +if UnparseC.term t' = 
  58.105 +  "x * x / ((x + - 1 * y) * ((x + y) * x)) +\ny * (x + y) / ((x + - 1 * y) * ((x + y) * x))"
  58.106 +then () else error "common_nominator_p_ term 2 changed"
  58.107 +;
  58.108 +if UnparseC.terms asm = "[\"x + y \<noteq> 0\", \"x \<noteq> 0\", \"x + - 1 * y \<noteq> 0\"]"
  58.109 +then () else error "common_nominator_p_ asm 2 changed"
  58.110 +
  58.111 +"-------- example: applicable tested by SML code";
  58.112 +val t = TermC.str2term "nothing / to_add";
  58.113 +if NONE = common_nominator_p_ thy t then () else error "common_nominator_p_ term 3 changed";
  58.114 +;
  58.115 +val t = TermC.str2term "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))";
  58.116 +val SOME (t', asm) = common_nominator_p_ thy t;
  58.117 +if UnparseC.term t' = 
  58.118 +  "(x + - 1) * (- 1 + x) / ((1 + x) * (- 1 + x)) +\n(x + 1) * (1 + x) / ((1 + x) * (- 1 + x))"
  58.119 +  andalso UnparseC.terms asm = "[\"1 + x \<noteq> 0\", \"- 1 + x \<noteq> 0\"]"
  58.120 +then () else error "common_nominator_p_ 3 changed";
  58.121 +
  58.122 +"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
  58.123 +"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
  58.124 +"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
  58.125 +val t = TermC.str2term "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))";
  58.126 +val SOME (t', asm) = add_fraction_p_ thy t;
  58.127 +if UnparseC.term t' = "(2 + 2 * x \<up> 2) / (- 1 + x \<up> 2)" 
  58.128 +then () else error "add_fraction_p_ 3 changed";
  58.129 +;
  58.130 +if UnparseC.terms asm = "[\"- 1 + x \<up> 2 \<noteq> 0\"]"
  58.131 +then () else error "add_fraction_p_ 3 changed";
  58.132 +;
  58.133 +val t = TermC.str2term "nothing / to_add";
  58.134 +if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ term 3 changed";
  58.135 +;
  58.136 +val t = TermC.str2term "((x + (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))";
  58.137 +val SOME (t', asm) = add_fraction_p_ thy t;
  58.138 +if UnparseC.term t' = "(2 + 2 * x \<up> 2) / (- 1 + x \<up> 2)" andalso
  58.139 +  UnparseC.terms asm = "[\"- 1 + x \<up> 2 \<noteq> 0\"]"
  58.140 +then () else error "add_fraction_p_ 3 changed";
  58.141 +
  58.142 +"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
  58.143 +"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
  58.144 +"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
  58.145 +(* trace down until prepats are evaluated 
  58.146 +  (which does not to work, because substitution is not done -- compare rew_sub!);
  58.147 +  keep this sequence for the case, factout_p, cancel_p, common_nominator_p, add_fraction_p
  58.148 +  (again) get prepat = [] changed to <>[]. *)
  58.149 +val t = TermC.str2term "(x \<up> 2 + - 1*y \<up> 2) / (x \<up> 2 + - 1*x*y)";
  58.150 +
  58.151 +(*rewrite_set_ @{theory Isac_Knowledge} true cancel t = NONE; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  58.152 +"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (thy, false, cancel_p, t);
  58.153 +"~~~~~ fun rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
  58.154 +  (thy, 1, bool, [], rls, term);
  58.155 +(*val (t', asm, rew) = app_rev thy (i+1) rrls t; rew = false!!!!!!!!!!!!!!!!!!!!!*)
  58.156 +"~~~~~ and app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
  58.157 +    fun chk_prepat thy erls [] t = true
  58.158 +      | chk_prepat thy erls prepat t =
  58.159 +        let
  58.160 +          fun chk (pres, pat) =
  58.161 +            (let 
  58.162 +              val subst: Type.tyenv * Envir.tenv =
  58.163 +                Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
  58.164 +             in
  58.165 +              snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
  58.166 +             end) handle Pattern.MATCH => false
  58.167 +           fun scan_ f [] = false (*scan_ NEVER called by []*)
  58.168 +             | scan_ f (pp::pps) =
  58.169 +               if f pp then true else scan_ f pps;
  58.170 +        in scan_ chk prepat end;
  58.171 +    (* apply the normal_form of a rev-set *)
  58.172 +    fun app_rev' thy (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}) t =
  58.173 +      if chk_prepat thy erls prepat t
  58.174 +      then ((*tracing("### app_rev': t = "^UnparseC.term t);*) normal_form t)
  58.175 +      else NONE;
  58.176 +(*  val opt = app_rev' thy rrls t  ..NONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  58.177 +"~~~~~ and app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
  58.178 +  (thy, rrls, t);
  58.179 +(* chk_prepat thy erls prepat t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  58.180 +(* app_sub thy i rrls t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  58.181 +"~~~~~ fun chk_prepat, args:"; val (thy, erls, prepat, t) = (thy, erls, prepat, t);
  58.182 +          fun chk (pres, pat) =
  58.183 +            (let 
  58.184 +              val subst: Type.tyenv * Envir.tenv =
  58.185 +                Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
  58.186 +             in
  58.187 +              snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
  58.188 +             end) handle Pattern.MATCH => false
  58.189 +           fun scan_ f [] = false (*scan_ NEVER called by []*)
  58.190 +             | scan_ f (pp::pps) =
  58.191 +               if f pp then true else scan_ f pps;
  58.192 +
  58.193 +(*========== inhibit exn WN130823: prepat is empty ====================================
  58.194 +(* scan_ chk prepat = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  58.195 +"~~~~~ fun , args:"; val (f, (pp::pps)) = (chk, prepat);
  58.196 +f;
  58.197 +val ([t1, t2], t) = pp;
  58.198 +UnparseC.term t1 = "?r is_expanded";
  58.199 +UnparseC.term t2 = "?s is_expanded";
  58.200 +UnparseC.term t = "?r / ?s";
  58.201 +(* f pp = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  58.202 +"~~~~~ fun chk, args:"; val (pres, pat) = (pp);
  58.203 +              val subst: Type.tyenv * Envir.tenv =
  58.204 +                Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
  58.205 +(*subst = 
  58.206 +  ({}, {(("r", 0), ("real", Var (("r", 0), "real"))), 
  58.207 +        (("s", 0), ("real", Var (("s", 0), "real")))}*)
  58.208 +;
  58.209 +              snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
  58.210 +"~~~~~ fun eval__true, args:"; val (thy, i, asms, bdv, rls) =
  58.211 +  (thy, (i + 1), (map (Envir.subst_term subst) pres), [], erls);
  58.212 +UnparseC.terms asms;                         (* = "[\"?r is_expanded\",\"?s is_expanded\"]"*)
  58.213 +asms = [@{term True}] orelse asms = []; (* = false*)
  58.214 +asms = [@{term False}]                ; (* = false*)
  58.215 +"~~~~~ fun chk, args:"; val (indets, (a::asms)) = ([], asms);
  58.216 +bdv (*= []: _a list*);
  58.217 +val bdv : (term * term) list = [];
  58.218 +rewrite__set_ thy (i+1) false;
  58.219 +UnparseC.term a = "?r is_expanded"; (*hier m"usste doch der Numerator eingesetzt sein ??????????????*)
  58.220 +val SOME (Const (\<^const_name>\<open>False\<close>, _), []) = rewrite__set_ thy (i+1) false bdv rls a
  58.221 +============ inhibit exn WN130823: prepat is empty ===================================*)
  58.222 +
  58.223 +"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
  58.224 +"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
  58.225 +"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
  58.226 +val t = TermC.str2term "(12 * x * y) / (8 * y \<up> 2 )";
  58.227 +(* "-------- example 187a": exception Div raised...
  58.228 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
  58.229 +val t = TermC.str2term "(8 * x \<up> 2 * y * z ) / (18 * x * y \<up> 2 * z )";
  58.230 +(* "-------- example 187b": doesn't terminate...
  58.231 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
  58.232 +val t = TermC.str2term "(9 * x \<up> 5 * y \<up> 2 * z \<up> 4) / (15 * x \<up> 6 * y \<up> 3 * z )";
  58.233 +(* "-------- example 187c": doesn't terminate...
  58.234 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
  58.235 +"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (@{theory Isac_Knowledge}, false, cancel_p, t);
  58.236 +(* WN130827: exception Div raised...
  58.237 +rewrite__set_ thy 1 bool [] rls term
  58.238 +*)
  58.239 +"~~~~~ and rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
  58.240 +  (thy, 1, bool, [], rls, term);
  58.241 +(* WN130827: exception Div raised...
  58.242 +	val (t', asm, rew) = app_rev thy (i+1) rrls t
  58.243 +*)
  58.244 +"~~~~~ fun app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
  58.245 +(* WN130827: exception Div raised...
  58.246 +    val opt = app_rev' thy rrls t
  58.247 +*)
  58.248 +"~~~~~ fun app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
  58.249 +  (thy, rrls, t);
  58.250 +chk_prepat thy erls prepat t    = true;
  58.251 +(* WN130827: exception Div raised...
  58.252 +normal_form t
  58.253 +*)
  58.254 +(* lookup Rational.thy, cancel_p: normal_form = cancel_p_ thy*)
  58.255 +"~~~~~ fun cancel_p_, args:"; val (t) = (t);
  58.256 +val opt = check_fraction t;
  58.257 +val SOME (numerator, denominator) = opt
  58.258 +        val vs = TermC.vars_of t
  58.259 +        val baseT = type_of numerator
  58.260 +        val expT = HOLogic.realT
  58.261 +val (SOME a, SOME b) = (poly_of_term vs numerator, poly_of_term vs denominator);
  58.262 +(*"-------- example 187a": exception Div raised...
  58.263 +val a = [(12, [1, 1])]: poly
  58.264 +val b = [(8, [0, 2])]: poly
  58.265 +              val ((a', b'), c) = gcd_poly a b
  58.266 +*)
  58.267 +(* "-------- example 187b": doesn't terminate...
  58.268 +val a = [(8, [2, 1, 1])]: poly
  58.269 +val b = [(18, [1, 2, 1])]: poly
  58.270 +              val ((a', b'), c) = gcd_poly a b
  58.271 +*)
  58.272 +(* "-------- example 187c": doesn't terminate...
  58.273 +val a = [(9, [5, 2, 4])]: poly
  58.274 +val b = [(15, [6, 3, 1])]: poly
  58.275 +              val ((a', b'), c) = gcd_poly a b
  58.276 +*)
  58.277 +
  58.278 +"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
  58.279 +"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
  58.280 +"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
  58.281 +val t = TermC.str2term "(x \<up> 2 - 4)*(3 - y) / ((y \<up> 2 - 9)*(2+x))";
  58.282 +Rewrite.trace_on := false (*true false*);
  58.283 +(* trace stops with ...: (and then jEdit hangs)..
  58.284 +rewrite_set_ thy false norm_Rational t;
  58.285 +:
  58.286 +###  rls: cancel_p on: (- 12 + 4 * y + 3 * x \<up> 2 + - 1 * (x \<up> 2 * y)) /
  58.287 +(- 18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)
  58.288 +*)
  58.289 +val t = TermC.str2term (*copy from above: "::real" is not required due to " \<up> "*)
  58.290 +  ("(- 12 + 4 * y + 3 * x \<up> 2 + - 1 * (x \<up> 2 * y)) /" ^
  58.291 +  "(- 18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)");
  58.292 +(*cancel_p_ thy t;
  58.293 +exception Div raised*)
  58.294 +
  58.295 +"~~~~~ fun cancel_p_, args:"; val (t) = (t);
  58.296 +val opt = check_fraction t;
  58.297 +val SOME (numerator, denominator) = opt
  58.298 +        val vs = TermC.vars_of t
  58.299 +        val baseT = type_of numerator
  58.300 +        val expT = HOLogic.realT;
  58.301 +(*default_print_depth 3; 999*)
  58.302 +val (SOME a, SOME b) = (poly_of_term vs numerator, poly_of_term vs denominator);
  58.303 +(*default_print_depth 3; 999*)
  58.304 +(* does not terminate instead of returning ?:
  58.305 +        val ((a', b'), c) = gcd_poly a b
  58.306 +val a = [(~12, [0, 0]), (3, [2, 0]), (4, [0, 1]), (~1, [2, 1])]: poly
  58.307 +val b = [(~18, [0, 0]), (~9, [1, 0]), (2, [0, 2]), (1, [1, 2])]: poly
  58.308 +*)
  58.309 +
  58.310 +"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
  58.311 +"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
  58.312 +"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
  58.313 +val thy =  @{theory Isac_Knowledge};
  58.314 +"----- SK060904- 2a non-termination of add_fraction_p_";
  58.315 +val t = TermC.str2term (" (a + b * x) / (a + - 1 * (b * x)) +  " ^
  58.316 +		         " (- 1 * a + b * x) / (a + b * x)      ");
  58.317 +(* rewrite_set_ thy false norm_Rational t
  58.318 +exception Div raised*)
  58.319 +(* rewrite_set_ thy false add_fractions_p t;
  58.320 +exception Div raised*)
  58.321 +"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) =
  58.322 +  (@{theory Isac_Knowledge}, false, add_fractions_p, t);
  58.323 +"~~~~~ and rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
  58.324 +  (thy, 1, bool, [], rls, term);
  58.325 +(* app_rev thy (i+1) rrls t;
  58.326 +exception Div raised*)
  58.327 +"~~~~~ and app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
  58.328 +    fun chk_prepat thy erls [] t = true
  58.329 +      | chk_prepat thy erls prepat t =
  58.330 +        let
  58.331 +          fun chk (pres, pat) =
  58.332 +            (let 
  58.333 +              val subst: Type.tyenv * Envir.tenv =
  58.334 +                Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
  58.335 +             in
  58.336 +              snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
  58.337 +             end) handle Pattern.MATCH => false
  58.338 +           fun scan_ f [] = false (*scan_ NEVER called by []*)
  58.339 +             | scan_ f (pp::pps) =
  58.340 +               if f pp then true else scan_ f pps;
  58.341 +        in scan_ chk prepat end;
  58.342 +    (* apply the normal_form of a rev-set *)
  58.343 +    fun app_rev' thy (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}) t =
  58.344 +      if chk_prepat thy erls prepat t
  58.345 +      then ((*tracing("### app_rev': t = "^UnparseC.term t);*) normal_form t)
  58.346 +      else NONE;
  58.347 +(*  val opt = app_rev' thy rrls t;
  58.348 +exception Div raised*)
  58.349 +(*  val opt = app_rev' thy rrls t;
  58.350 +exception Div raised*)
  58.351 +"~~~~~ and app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
  58.352 +  (thy, rrls, t);
  58.353 +chk_prepat thy erls prepat t = true       = true;
  58.354 +(*normal_form t
  58.355 +exception Div raised*)
  58.356 +(* lookup Rational.thy, val add_fractions_p: normal_form = add_fraction_p_ thy*)
  58.357 +(*add_fraction_p_ thy t
  58.358 +exception Div raised*)
  58.359 +"~~~~~ fun add_fraction_p_, args:"; val ((_: theory), t) = (thy, t);
  58.360 +val SOME ((n1, d1), (n2, d2)) = check_frac_sum t;
  58.361 +UnparseC.term n1; UnparseC.term d1; UnparseC.term n2; UnparseC.term d2;
  58.362 +      val vs = TermC.vars_of t;
  58.363 +(*default_print_depth 3; 999*)
  58.364 +val (SOME _, SOME a, SOME _, SOME b) =
  58.365 +  (poly_of_term vs n1, poly_of_term vs d1, poly_of_term vs n2, poly_of_term vs d2);
  58.366 +(*default_print_depth 3; 999*)
  58.367 +(*
  58.368 +val a = [(1, [1, 0, 0]), (~1, [0, 1, 1])]: poly
  58.369 +val b = [(1, [1, 0, 0]), (1, [0, 1, 1])]: poly
  58.370 +            val ((a', b'), c) = gcd_poly a b
  58.371 +*)
  58.372 +
  58.373 +"----------- fun check_frac_sum with Free A and Const AA ---------------------------------------";
  58.374 +"----------- fun check_frac_sum with Free A and Const AA ---------------------------------------";
  58.375 +"----------- fun check_frac_sum with Free A and Const AA ---------------------------------------";
  58.376 +val thy = @{theory Isac_Knowledge(*Partial_Fractions*)}
  58.377 +val ctxt = Proof_Context.init_global thy;
  58.378 +
  58.379 +(*---------- (1) with Free A, B  ----------------------------------------------------------------*)
  58.380 +val t = (the o (parseNEW  ctxt)) "3 = A / 2 + A / 4 + (B / 2 + - 1 * B / (2::real))";
  58.381 +                                (* required for applying thms in rewriting  \<up> ^*)
  58.382 +(* we get details from here..*)
  58.383 +
  58.384 +Rewrite.trace_on := false; (*true false*)
  58.385 +val SOME (t', _) = Rewrite.rewrite_set_ thy true add_fractions_p t;
  58.386 +Rewrite.trace_on := false; (*true false*)
  58.387 +(* Rewrite.trace_on:
  58.388 +add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + - 1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *)
  58.389 +                     (* |||||||||||||||||||||||||||||||||||| *)
  58.390 +
  58.391 +val t = (the o (parseNEW  ctxt))(* ||||||||||||||||||||||||| GUESS 1 GUESS 1 GUESS 1 GUESS 1 *)
  58.392 +                       "A / 2 + A / 4 + (B / 2 + - 1 * B / (2::real))";
  58.393 +"~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t);
  58.394 +val NONE = (*case*) check_frac_sum t (*of*)
  58.395 +
  58.396 +(* Rewrite.trace_on:
  58.397 +add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + - 1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *)
  58.398 +                     (*         |||||||||||||||||||||||||||| *)
  58.399 +val t = (the o (parseNEW  ctxt))(* ||||||||||||||||||||||||| GUESS 2 GUESS 2 GUESS 2 GUESS 2 *)
  58.400 +                               "A / 4 + (B / 2 + - 1 * B / (2::real))";
  58.401 +"~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t);
  58.402 +val SOME ((n1, d1), (n2, d2)) = (*case*) check_frac_sum t (*of*);
  58.403 +(*+*)if (UnparseC.term n1, UnparseC.term d1) = ("A"                 , "4") andalso
  58.404 +(*+*)   (UnparseC.term n2, UnparseC.term d2) = ("B / 2 + - 1 * B / 2", "1")
  58.405 +(*+*)then () else error "check_frac_sum (A / 4 + (B / 2 + - 1 * B / (2::real))) changed";
  58.406 +
  58.407 +      val vs = TermC.vars_of t;
  58.408 +val (SOME [(1, [1, 0])], SOME [(4, [0, 0])], NONE, SOME [(1, [0, 0])]) =
  58.409 +  (*case*) (poly_of_term vs n1, poly_of_term vs d1, poly_of_term vs n2, poly_of_term vs d2) (*of*);
  58.410 +
  58.411 +"~~~~~ fun poly_of_term , args:"; val (vs, t) = (vs, n1);
  58.412 +val SOME [(1, [xxx, 0])] = SOME [monom_of_term vs (1, replicate (length vs) 0) t];
  58.413 +(*+*)if xxx = 1 then () else error "monom_of_term changed"
  58.414 +
  58.415 +"~~~~~ fun monom_of_term , args:"; val (vs, (c, es), (Free (id, _))) =
  58.416 +  (vs, (1, replicate (length vs) 0), t);
  58.417 +case vs of [Free ("A", _), Free ("B", _)] =>
  58.418 +  if c = 1 andalso id = "A"
  58.419 +  then () else error "monom_of_term Free changed 1"
  58.420 +| _ => error "monom_of_term Free changed 2";
  58.421 +
  58.422 +(*---------- (2) with Const AA, BB --------------------------------------------------------------*)
  58.423 +val t = (the o (parseNEW  ctxt)) "3 = AA / 2 + AA / 4 + (BB / 2 + - 1 * BB / 2)";
  58.424 +                                    (*AA :: real*)
  58.425 +(* we get details from here..*)
  58.426 +
  58.427 +Rewrite.trace_on := false; (*true false*)
  58.428 +val SOME (t', _) = Rewrite.rewrite_set_ thy true add_fractions_p t;
  58.429 +Rewrite.trace_on := false; (*true false*)
  58.430 +(* Rewrite.trace_on:
  58.431 +add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + - 1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *)
  58.432 +                     (* |||||||||||||||||||||||||||||||||||| *)
  58.433 +val t = (the o (parseNEW  ctxt))(* ||||||||||||||||||||||||| *)
  58.434 +                   "AA / 2 + AA / 4 + (BB / 2 + - 1 * BB / 2)";
  58.435 +"~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t);
  58.436 +val NONE = (*case*) check_frac_sum t (*of*)
  58.437 +
  58.438 +(* Rewrite.trace_on:
  58.439 +add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + - 1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *)
  58.440 +                     (*         |||||||||||||||||||||||||||| *)
  58.441 +val t = (the o (parseNEW  ctxt))(* ||||||||||||||||||||||||| *)
  58.442 +                               "AA / 4 + (BB / 2 + - 1 * BB / 2)";
  58.443 +"~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t);
  58.444 +val SOME ((n1, d1), (n2, d2)) = (*case*) check_frac_sum t (*of*);
  58.445 +(*+*)if (UnparseC.term n1, UnparseC.term d1) = ("AA"                 , "4") andalso
  58.446 +(*+*)   (UnparseC.term n2, UnparseC.term d2) = ("BB / 2 + - 1 * BB / 2", "1")
  58.447 +(*+*)then () else error "check_frac_sum (AA / 4 + (BB / 2 + - 1 * BB / 2)) changed";
  58.448 +
  58.449 +      val vs = TermC.vars_of t;
  58.450 +val (SOME [(1, [1, 0])], SOME [(4, [0, 0])], NONE, SOME [(1, [0, 0])]) =
  58.451 +  (*case*) (poly_of_term vs n1, poly_of_term vs d1, poly_of_term vs n2, poly_of_term vs d2) (*of*);
  58.452 +
  58.453 +"~~~~~ fun poly_of_term , args:"; val (vs, t) = (vs, n1);
  58.454 +val SOME [(1, [xxx, 0])] = SOME [monom_of_term vs (1, replicate (length vs) 0) t];
  58.455 +(*+*)if xxx = 1 then () else error "monom_of_term changed"
  58.456 +
  58.457 +"~~~~~ fun monom_of_term , args:"; val (vs, (c, es), (Const (id, _))) =
  58.458 +  (vs, (1, replicate (length vs) 0), t);
  58.459 +case vs of [Const ("Partial_Fractions.AA", _), Const ("Partial_Fractions.BB", _)] =>
  58.460 +  if c = 1 andalso id = "Partial_Fractions.AA"
  58.461 +  then () else error "monom_of_term Const changed 1"
  58.462 +| _ => error "monom_of_term Const changed 2";
  58.463 +
  58.464 +"----------- fun cancel_p with Const AA --------------------------------------------------------";
  58.465 +"----------- fun cancel_p with Const AA --------------------------------------------------------";
  58.466 +"----------- fun cancel_p with Const AA --------------------------------------------------------";
  58.467 +val thy = @{theory Partial_Fractions};
  58.468 +val ctxt = Proof_Context.init_global @{theory}
  58.469 +val SOME t = TermC.parseNEW ctxt "2 * AA / 2"; (* Const ("Free ("AA", "real") *)
  58.470 +
  58.471 +val SOME (t', _) = rewrite_set_ thy true cancel_p t;
  58.472 +case t' of
  58.473 +  Const ("Rings.divide_class.divide", _) $ Const ("Partial_Fractions.AA", _) $
  58.474 +    Const ("Groups.one_class.one", _) => ()
  58.475 +| _ => error "WRONG rewrite_set_ cancel_p (2 * AA / 2) \<longrightarrow> AA changed";
  58.476 +
  58.477 +"~~~~~ fun cancel_p , args:"; val (t) = (t);
  58.478 +val opt = check_fraction t
  58.479 +val SOME (numerator, denominator) = (*case*) opt (*of*);
  58.480 +
  58.481 +if UnparseC.term numerator = "2 * AA" andalso UnparseC.term denominator = "2"
  58.482 +then () else error "check_fraction (2 * AA / 2) changed";
  58.483 +        val vs = TermC.vars_of t;
  58.484 +case vs of
  58.485 +  [Const ("Partial_Fractions.AA", _)] => ()
  58.486 +| _ => error "rewrite_set_ cancel_p (2 * AA / 2) \<longrightarrow> AA/1  changed";
  58.487 +
  58.488 +
  58.489 +"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
  58.490 +"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
  58.491 +"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
  58.492 +val thy  = @{theory "Rational"};
  58.493 +"-------- WN";
  58.494 +val t = TermC.str2term "(2 + -3 * x) / 9";
  58.495 +if NONE = rewrite_set_ thy false cancel_p t then ()
  58.496 +else error "rewrite_set_ cancel_p must return NONE, if the term cannot be cancelled";
  58.497 +
  58.498 +"-------- example 186a";
  58.499 +val t = TermC.str2term "(14 * x * y) / (x * y)";
  58.500 +  is_expanded (TermC.str2term "14 * x * y");
  58.501 +  is_expanded (TermC.str2term "x * y");
  58.502 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.503 +if (UnparseC.term t', UnparseC.terms asm) = ("14 / 1", "[]")
  58.504 +then () else error "rational.sml cancel Schalk 186a";
  58.505 +
  58.506 +"-------- example 186b";
  58.507 +val t = TermC.str2term "(60 * a * b) / ( 15 * a  * b )";
  58.508 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.509 +if (UnparseC.term t', UnparseC.terms asm) = ("4 / 1", "[]")
  58.510 +then () else error "rational.sml cancel Schalk 186b";
  58.511 +
  58.512 +"-------- example 186c";
  58.513 +val t = TermC.str2term "(144 * a \<up> 2 * b * c) / (12 * a * b * c)";
  58.514 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.515 +if (UnparseC.term t', UnparseC.terms asm) = ("12 * a / 1", "[]")
  58.516 +then () else error "rational.sml cancel Schalk 186c";
  58.517 +
  58.518 +(* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! exception Div raised !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  58.519 +  see --- fun rewrite_set_ downto fun gcd_poly ---
  58.520 +"-------- example 187a";
  58.521 +val t = TermC.str2term "(12 * x * y) / (8 * y \<up> 2 )";
  58.522 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.523 +if (UnparseC.term t', UnparseC.terms asm) = ("3 * x / (2 * y)", "[\"4 * y ~= 0\"]")
  58.524 +then () else error "rational.sml cancel Schalk 187a";
  58.525 +*)
  58.526 +
  58.527 +(* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  58.528 +  see --- fun rewrite_set_ downto fun gcd_poly ---
  58.529 +"-------- example 187b";
  58.530 +val t = TermC.str2term "(8 * x \<up> 2 * y * z ) / (18 * x * y \<up> 2 * z )";
  58.531 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.532 +if (UnparseC.term t', UnparseC.terms asm) = ("4 * x / (9 * y)", "[\"2 * (z * (y * x)) ~= 0\"]")
  58.533 +then () else error "rational.sml cancel Schalk 187b";
  58.534 +*)
  58.535 +
  58.536 +(* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  58.537 +  see --- fun rewrite_set_ downto fun gcd_poly ---
  58.538 +"-------- example 187c";
  58.539 +val t = TermC.str2term "(9 * x \<up> 5 * y \<up> 2 * z \<up> 4) / (15 * x \<up> 6 * y \<up> 3 * z )";
  58.540 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.541 +if (UnparseC.term t', UnparseC.terms asm) = 
  58.542 +  ("3 * z \<up> 3 / (5 * (y * x))", "[\"3 * (z * (y \<up> 2 * x \<up> 5)) ~= 0\"]") 
  58.543 +then () else error "rational.sml cancel Schalk 187c";
  58.544 +*)
  58.545 +
  58.546 +"-------- example 188a";
  58.547 +val t = TermC.str2term "(-8 + 8 * x) / (-9 + 9 * x)";
  58.548 +  is_expanded (TermC.str2term "8 * x + -8");
  58.549 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.550 +if (UnparseC.term t', UnparseC.terms asm) = ("8 / 9", "[]")
  58.551 +then () else error "rational.sml cancel Schalk 188a";
  58.552 +
  58.553 +val t = TermC.str2term "(8*((- 1) + x))/(9*((- 1) + x))";
  58.554 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  58.555 +if (UnparseC.term t', UnparseC.terms asm) = ("8 / 9", "[]")
  58.556 +then () else error "rational.sml cancel Schalk make_polynomial 1";
  58.557 +
  58.558 +"-------- example 188b";
  58.559 +val t = TermC.str2term "(- 15 + 5 * x) / (- 18 + 6 * x)";
  58.560 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.561 +if (UnparseC.term t', UnparseC.terms asm) = ("5 / 6", "[]")
  58.562 +then () else error "rational.sml cancel Schalk 188b";
  58.563 +
  58.564 +"-------- example 188c";
  58.565 +val t = TermC.str2term "(a + - 1 * b) / (b + - 1 * a)";
  58.566 +val SOME (t', asm) = rewrite_set_ thy false  cancel_p t;
  58.567 +if (UnparseC.term t', UnparseC.terms asm) = ("- 1 / 1", "[]")
  58.568 +then () else error "rational.sml cancel Schalk 188c";
  58.569 +
  58.570 +is_expanded (TermC.str2term "a + - 1 * b") = true;
  58.571 +val t = TermC.str2term "((- 1)*(b + (- 1) * a))/(1*(b + (- 1) * a))";
  58.572 +val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  58.573 +if (UnparseC.term t', UnparseC.terms asm) = ("(a + - 1 * b) / (- 1 * a + b)", "[]")
  58.574 +then () else error "rational.sml cancel Schalk make_polynomial 2";
  58.575 +
  58.576 +"-------- example 190a";
  58.577 +val t = TermC.str2term "( 27 * a \<up> 3 + 9 * a \<up> 2 + 3 * a + 1 ) / ( 27 * a \<up> 3 + 18 * a \<up> 2 + 3 * a )";
  58.578 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.579 +if (UnparseC.term t', UnparseC.terms asm) = 
  58.580 +  ("(1 + 9 * a \<up> 2) / (3 * a + 9 * a \<up> 2)", "[\"3 * a + 9 * a \<up> 2 \<noteq> 0\"]")
  58.581 +then () else error "rational.sml cancel Schalk 190a";
  58.582 +
  58.583 +"-------- example 190c";
  58.584 +val t = TermC.str2term "((1 + 9 * a \<up> 2)*(1 + 3 * a))/((3 * a + 9 * a \<up> 2)*(1 + 3 * a))";
  58.585 +val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  58.586 +if (UnparseC.term t', UnparseC.terms asm) = 
  58.587 +  ("(1 + 3 * a + 9 * a \<up> 2 + 27 * a \<up> 3) /\n(3 * a + 18 * a \<up> 2 + 27 * a \<up> 3)", "[]")
  58.588 +then () else error "rational.sml make_polynomial Schalk 190c";
  58.589 +
  58.590 +"-------- example 191a";
  58.591 +val t = TermC.str2term "( x \<up> 2 + - 1 * y \<up> 2 ) / ( x + y )";
  58.592 +  is_expanded (TermC.str2term "x \<up> 2 + - 1 * y \<up> 2") = false; (*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  58.593 +  is_expanded (TermC.str2term "x + y") = true;
  58.594 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.595 +if (UnparseC.term t', UnparseC.terms asm) = ("(x + - 1 * y) / 1", "[]")
  58.596 +then () else error "rational.sml make_polynomial Schalk 191a";
  58.597 +
  58.598 +"-------- example 191b";
  58.599 +val t = TermC.str2term "((x + (- 1) * y)*(x + y))/((1)*(x + y))";
  58.600 +val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  58.601 +if (UnparseC.term t', UnparseC.terms asm) = ("(x \<up> 2 + - 1 * y \<up> 2) / (x + y)", "[]")
  58.602 +then () else error "rational.sml make_polynomial Schalk 191b";
  58.603 +
  58.604 +"-------- example 191c";
  58.605 +val t = TermC.str2term "( 9 * x \<up> 2 + -30 * x + 25 ) / ( 9 * x \<up> 2 + - 25 )";
  58.606 +  is_expanded (TermC.str2term "9 * x \<up> 2 + -30 * x + 25") = true;
  58.607 +  is_expanded (TermC.str2term "25 + -30*x + 9*x \<up> 2") = true;
  58.608 +  is_expanded (TermC.str2term "- 25 + 9*x \<up> 2") = true;
  58.609 +
  58.610 +val t = TermC.str2term "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
  58.611 +val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  58.612 +if (UnparseC.term t', UnparseC.terms asm) = ("(25 + - 30 * x + 9 * x \<up> 2) / (- 25 + 9 * x \<up> 2)", "[]")
  58.613 +then () else error "rational.sml make_polynomial Schalk 191c";
  58.614 +
  58.615 +"-------- example 192b";
  58.616 +val t = TermC.str2term "( 7 * x \<up> 3 + - 1 * x \<up> 2 * y ) / ( 7 * x * y \<up> 2 + - 1 *  y \<up> 3 )";
  58.617 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.618 +if (UnparseC.term t', UnparseC.terms asm) = ("x \<up> 2 / y \<up> 2", "[\"y \<up> 2 \<noteq> 0\"]")
  58.619 +then () else error "rational.sml cancel_p Schalk 192b";
  58.620 +
  58.621 +val t = TermC.str2term "((x \<up> 2)*(7 * x + (- 1) * y))/((y \<up> 2)*(7 * x + (- 1) * y))";
  58.622 +val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  58.623 +if (UnparseC.term t', UnparseC.terms asm) = 
  58.624 +  ("(7 * x \<up> 3 + - 1 * x \<up> 2 * y) /\n(7 * x * y \<up> 2 + - 1 * y \<up> 3)", "[]")
  58.625 +then () else error "rational.sml make_polynomial Schalk 192b";
  58.626 +
  58.627 +val t = TermC.str2term "((x \<up> 2)*(7 * x + (- 1) * y))/((y \<up> 2)*(7 * x + (- 1) * y))";
  58.628 +val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  58.629 +if (UnparseC.term t', UnparseC.terms asm) = 
  58.630 +  ("(7 * x \<up> 3 + - 1 * x \<up> 2 * y) /\n(7 * x * y \<up> 2 + - 1 * y \<up> 3)", "[]")
  58.631 +then () else error "rational.sml make_polynomial Schalk WN050929 not working";
  58.632 +
  58.633 +"-------- example 193a";
  58.634 +val t = TermC.str2term "( x \<up> 2 + -6 * x + 9 ) / ( x \<up> 2 + -9 )";
  58.635 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.636 +if (UnparseC.term t', UnparseC.terms asm) = ("(- 3 + x) / (3 + x)", "[\"3 + x \<noteq> 0\"]")
  58.637 +then () else error "rational.sml cancel_p Schalk 193a";
  58.638 +
  58.639 +"-------- example 193b";
  58.640 +val t = TermC.str2term "( x \<up> 2 + -8 * x + 16 ) / ( 2 * x \<up> 2 + -32 )";
  58.641 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.642 +if (UnparseC.term t', UnparseC.terms asm) = ("(- 4 + x) / (8 + 2 * x)", "[\"8 + 2 * x \<noteq> 0\"]")
  58.643 +then () else error "rational.sml cancel_p Schalk 193b";
  58.644 +
  58.645 +"-------- example 193c";
  58.646 +val t = TermC.str2term "( 2 * x + -50 * x \<up> 3 ) / ( 25 * x \<up> 2 + - 10 * x + 1 )";
  58.647 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.648 +if (UnparseC.term t', UnparseC.terms asm) = 
  58.649 +  ("(2 * x + 10 * x \<up> 2) / (1 + - 5 * x)", "[\"1 + - 5 * x \<noteq> 0\"]")
  58.650 +then () else error "rational.sml cancel_p Schalk 193c";
  58.651 +
  58.652 +(*WN: improved with new numerals*)
  58.653 +val t = TermC.str2term "(- 25 + 9*x \<up> 2)/(5 + 3*x)";
  58.654 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.655 +if (UnparseC.term t', UnparseC.terms asm) = ("(- 5 + 3 * x) / 1", "[]")
  58.656 +then () else error "rational.sml cancel WN 1";
  58.657 +
  58.658 +"-------- example heuberger";
  58.659 +val t = TermC.str2term ("(x \<up> 4 + x * y + x \<up> 3 * y + y \<up> 2) / " ^
  58.660 +  "(x + 5 * x \<up> 2 + y + 5 * x * y + x \<up> 2 * y \<up> 3 + x * y \<up> 4)");
  58.661 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.662 +if (UnparseC.term t', UnparseC.terms asm) = 
  58.663 +  ("(x \<up> 3 + y) / (1 + 5 * x + x * y \<up> 3)", "[\"1 + 5 * x + x * y \<up> 3 \<noteq> 0\"]")
  58.664 +then () else error "rational.sml cancel_p heuberger";
  58.665 +
  58.666 +"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
  58.667 +"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
  58.668 +"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
  58.669 +(*deleted example 204 ... 236b at update Isabelle2012-->2013*)
  58.670 +
  58.671 +"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
  58.672 +"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
  58.673 +"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
  58.674 +val t = TermC.str2term ("123 = (a*x)/(b*x) + (c*x)/(d*x) + (e*x)/(f*x::real)");
  58.675 +"-------- gcd_poly integration level 1: works on exact term";
  58.676 +if NONE = cancel_p_ thy t then () else error "cancel_p_ works on exact fraction";
  58.677 +if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ works on exact fraction";
  58.678 +
  58.679 +"-------- gcd_poly integration level 2: picks out ONE appropriate subterm";
  58.680 +val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  58.681 +if UnparseC.term t' = "123 = a * x / (b * x) + c * x / (d * x) + e / f" 
  58.682 +then () else error "level 2, rewrite_set_ cancel_p: changed";
  58.683 +val SOME (t', asm) = rewrite_set_ thy false add_fractions_p t;
  58.684 +if UnparseC.term t' = "123 = (b * c * x + a * d * x) / (b * d * x) + e * x / (f * x)"
  58.685 +then () else error "level 2, rewrite_set_ add_fractions_p: changed";
  58.686 +
  58.687 +"-------- gcd_poly integration level 3: rewrites all appropriate subterms";
  58.688 +val SOME (t', asm) = rewrite_set_ thy false cancel_p_rls t;
  58.689 +if UnparseC.term t' = "123 = a / b + c / d + e / f"
  58.690 +then () else error "level 3, rewrite_set_ cancel_p_rls: changed";
  58.691 +val SOME (t', asm) = rewrite_set_ thy false add_fractions_p_rls t; (*CREATE add_fractions_p_rls*)
  58.692 +if UnparseC.term t' = "123 = (b * d * e * x + b * c * f * x + a * d * f * x) / (b * d * f * x)"
  58.693 +then () else error "level 3, rewrite_set_ add_fractions_p_rls: changed";
  58.694 +
  58.695 +"-------- gcd_poly integration level 4: iteration cancel_p -- add_fraction_p";
  58.696 +(* simpler variant *)
  58.697 +val testrls = Rule_Set.append_rules "testrls" Rule_Set.empty [Rls_ cancel_p, Rls_ add_fractions_p]
  58.698 +val SOME (t', asm) = rewrite_set_ thy false testrls t;
  58.699 +(*Rewrite.trace_on := false; (*true false*)
  58.700 +#  rls: testrls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  58.701 +##  rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  58.702 +##  rls: add_fractions_p on: 123 = a * x / (b * x) + c * x / (d * x) + e / f 
  58.703 +##  rls: cancel_p on: 123 = (b * c * x + a * d * x) / (b * d * x) + e / f 
  58.704 +##  rls: add_fractions_p on: 123 = (b * c + a * d) / (b * d) + e / f 
  58.705 +##  rls: cancel_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  58.706 +##  rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) *)
  58.707 +if UnparseC.term t' = "123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)"
  58.708 +then () else error "level 4, rewrite_set_ *_p: changed";
  58.709 +
  58.710 +(* complicated variant *)
  58.711 +val testrls_rls = Rule_Set.append_rules "testrls_rls" Rule_Set.empty [Rls_ cancel_p_rls, Rls_ add_fractions_p_rls];
  58.712 +val SOME (t', asm) = rewrite_set_ thy false testrls_rls t;
  58.713 +(*#  rls: testrls_rls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  58.714 +##  rls: cancel_p_rls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  58.715 +###  rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  58.716 +###  rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e / f 
  58.717 +###  rls: cancel_p on: 123 = a * x / (b * x) + c / d + e / f 
  58.718 +###  rls: cancel_p on: 123 = a / b + c / d + e / f 
  58.719 +##  rls: add_fractions_p_rls on: 123 = a / b + c / d + e / f 
  58.720 +###  rls: add_fractions_p on: 123 = a / b + c / d + e / f 
  58.721 +###  rls: add_fractions_p on: 123 = (b * c + a * d) / (b * d) + e / f 
  58.722 +###  rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  58.723 +##  rls: cancel_p_rls on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  58.724 +###  rls: cancel_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  58.725 +##  rls: add_fractions_p_rls on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  58.726 +###  rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) *)
  58.727 +if UnparseC.term t' = "123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)"
  58.728 +then () else error "level 4, rewrite_set_ *_p_rls: changed"
  58.729 +
  58.730 +"-------- gcd_poly integration level 5: cancel_p & add_fraction_p within norm_Rational";
  58.731 +val SOME (t', asm) = rewrite_set_ thy false norm_Rational t;
  58.732 +if UnparseC.term t' = "123 = (a * d * f + b * c * f + b * d * e) / (b * d * f)"
  58.733 +then () else error "level 5, rewrite_set_ norm_Rational: changed"
  58.734 +
  58.735 +"-------- reverse rewrite ----------------------------------------------------";
  58.736 +"-------- reverse rewrite ----------------------------------------------------";
  58.737 +"-------- reverse rewrite ----------------------------------------------------";
  58.738 +(** the term for which reverse rewriting is demonstrated **)
  58.739 +val t = TermC.str2term "(9 + - 1 * x \<up> 2) / (9 + 6 * x + x \<up> 2)";
  58.740 +val Rrls {scr = Rfuns {init_state = ini, locate_rule = loc,
  58.741 +  next_rule = nex, normal_form = nor, ...},...} = cancel_p;
  58.742 +
  58.743 +(** normal_form produces the result in ONE step **)
  58.744 +  val SOME (t', _) = nor t;
  58.745 +if UnparseC.term t' = "(3 + - 1 * x) / (3 + x)" then ()
  58.746 +else error "rational.sml normal_form (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2)";
  58.747 +
  58.748 +(** initialize the interpreter state used by the 'me' **)
  58.749 +  val (t, _, revsets, _) = ini t;
  58.750 +
  58.751 +if length (hd revsets) = 11 then () else error "length of revset changed";
  58.752 +(*//----------------------------------TOODOO (*Rfuns revsets \<longrightarrow> broken*)
  58.753 +if (revsets |> nth 1 |> nth 1 |> id_of_thm) = 
  58.754 +  (@{thm realpow_twoI} |> Thm.get_name_hint |> ThmC.cut_id)
  58.755 +then () else error "first element of revset changed";
  58.756 +if
  58.757 +(revsets |> nth 1 |> nth 1 |> Rule.to_string) = "Thm (\"realpow_twoI\",?r1 \<up> 2 = ?r1 * ?r1)" andalso
  58.758 +(revsets |> nth 1 |> nth 2 |> Rule.to_string) = "Thm (\"#: 9 = 3 \<up> 2\",9 = 3 \<up> 2)" andalso
  58.759 +(revsets |> nth 1 |> nth 3 |> Rule.to_string) = "Thm (\"#: 6 * x = 2 * (3 * x)\",6 * x = 2 * (3 * x))" 
  58.760 +andalso
  58.761 +(revsets |> nth 1 |> nth 4 |> Rule.to_string) = "Thm (\"#: -3 * x = - 1 * (3 * x)\",-3 * x = - 1 * (3 * x))" 
  58.762 +andalso
  58.763 +(revsets |> nth 1 |> nth 5 |> Rule.to_string) = "Thm (\"#: 9 = 3 * 3\",9 = 3 * 3)" andalso
  58.764 +(revsets |> nth 1 |> nth 6 |> Rule.to_string) = "Rls_ (\"sym_order_mult_rls_\")" andalso
  58.765 +(revsets |> nth 1 |> nth 7 |> Rule.to_string) = 
  58.766 +  "Thm (\"sym_mult.assoc\",?a * (?b * ?c) = ?a * ?b * ?c)"
  58.767 +then () else error "first 7 elements in revset changed"
  58.768 +  \\----------------------------------TOODOO (*Rfuns revsets \<longrightarrow> broken*)*)
  58.769 +
  58.770 +(** find the rule 'r' to apply to term 't' **)
  58.771 +(*/------- WN1309: since cancel_ (accepted "-" between monomials) has been replaced by cancel_p_ 
  58.772 +  for Isabelle2013, we don't get a working revset, but non-termination:
  58.773 +
  58.774 +  val SOME (r as (Thm (str, thm))) = nex revsets t;
  58.775 +  :
  58.776 +((3 * 3 + - 1 * x * x) / (3 * 3 + 2 * 3 * x + x * x), 
  58.777 +  Rls_ ("sym_order_mult_rls_"), ((3 * 3 + - 1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x), []))", "
  58.778 +((3 * 3 + - 1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x), 
  58.779 +  Thm ("sym_mult.assoc", ""), ((3 * 3 + - 1 * (x * x)) / (3 * 3 + 2 * 3 * x + x * x), []))", "
  58.780 +((3 * 3 + - 1 * (x * x)) / (3 * 3 + 2 * 3 * x + x * x), 
  58.781 +  Thm ("sym_mult.assoc", ""), ((3 * 3 + - 1 * x * x) / (3 * 3 + 2 * 3 * x + x * x), []))", "
  58.782 +((3 * 3 + - 1 * x * x) / (3 * 3 + 2 * 3 * x + x * x), Rls_ ("sym_order_mult_rls_"), ((3 * 3 + - 1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x), []))", "
  58.783 + :
  58.784 +### Isabelle2002:
  58.785 +  Thm ("sym_#mult_2_3", "6 = 2 * 3")
  58.786 +### Isabelle2009- 2 for cancel_ (not cancel_p_):
  58.787 +if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
  58.788 +   andalso ThmC.string_of_thm thm = 
  58.789 +           (string_of_thm (Thm.make_thm @{theory "Isac_Knowledge"}
  58.790 +               (Trueprop $ (Thm.term_of o the o (TermC.parse thy)) "9 = 3 \<up> 2"))) then ()
  58.791 +else error "rational.sml next_rule (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2)";
  58.792 +\---------------------------------------------------------------------------------------/*)
  58.793 +
  58.794 +(** check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
  58.795 +  if the rule is OK, the term resulting from applying the rule is returned,too;
  58.796 +  there might be several rule applications inbetween,
  58.797 +  which are listed after the head in reverse order **)
  58.798 +(*/-------------------------------------------- Isabelle2013: this gives "error id_of_thm";
  58.799 +  we don't repair this, because interaction within "reverse rewriting" never worked properly:
  58.800 +
  58.801 +  val (r, (t, asm))::_ = loc revsets t r;
  58.802 +if UnparseC.term t = "(9 - x \<up> 2) / (3 \<up> 2 + 6 * x + x \<up> 2)" andalso asm = []
  58.803 +then () else error "rational.sml locate_rule (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2)";
  58.804 +
  58.805 +(* find the next rule to apply *)
  58.806 +  val SOME (r as (Thm (str, thm))) = nex revsets t;
  58.807 +if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
  58.808 +   ThmC.string_of_thm thm = (string_of_thm (ThmC_Def.make_thm @{theory "Isac_Knowledge"}
  58.809 +                (Trueprop $ (Thm.term_of o the o (TermC.parse thy)) "9 = 3 \<up> 2"))) then ()
  58.810 +else error "rational.sml next_rule (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2)";
  58.811 +
  58.812 +(*check the next rule*)
  58.813 +  val (r, (t, asm)) :: _ = loc revsets t r;
  58.814 +if UnparseC.term t = "(3 \<up> 2 - x \<up> 2) / (3 \<up> 2 + 6 * x + x \<up> 2)" then ()
  58.815 +else error "rational.sml locate_rule (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2) II";
  58.816 +
  58.817 +(*find and check the next rules, rewrite*)
  58.818 +  val SOME r = nex revsets t;
  58.819 +  val (r,(t,asm))::_ = loc revsets t r;
  58.820 +if UnparseC.term t = "(3 \<up> 2 - x \<up> 2) / (3 \<up> 2 + 2 * 3 * x + x \<up> 2)" then ()
  58.821 +else error "rational.sml locate_rule II";
  58.822 +
  58.823 +  val SOME r = nex revsets t;
  58.824 +  val (r,(t,asm))::_ = loc revsets t r;
  58.825 +if UnparseC.term t = "(3 - x) * (3 + x) / (3 \<up> 2 + 2 * 3 * x + x \<up> 2)" then ()
  58.826 +else error "rational.sml next_rule II";
  58.827 +
  58.828 +  val SOME r = nex revsets t;
  58.829 +  val (r,(t,asm))::_ = loc revsets t r;
  58.830 +if UnparseC.term t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
  58.831 +else error "rational.sml next_rule III";
  58.832 +
  58.833 +  val SOME r = nex revsets t;
  58.834 +  val (r, (t, asm)) :: _ = loc revsets t r;
  58.835 +  val ss = UnparseC.term t;
  58.836 +if ss = "(3 - x) / (3 + x)" andalso UnparseC.terms asm = "[\"3 + x ~= 0\"]" then ()
  58.837 +else error "rational.sml: new behav. in rev-set cancel";
  58.838 +\--------------------------------------------------------------------------------------/*)
  58.839 +
  58.840 +"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
  58.841 +"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
  58.842 +"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
  58.843 +(*WN130909: the example below shows, why "reverse rewriting" only worked for
  58.844 +  special cases.*)
  58.845 +
  58.846 +(*the term for which reverse rewriting is demonstrated*)
  58.847 +val t = TermC.str2term "(9 + (- 1)*x \<up> 2) / (9 + ((-6)*x + x \<up> 2))";
  58.848 +val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
  58.849 +		       next_rule=nex,normal_form=nor,...},...} = cancel_p;
  58.850 +
  58.851 +(*normal_form produces the result in ONE step*)
  58.852 +val SOME (t', _) = nor t; 
  58.853 +if UnparseC.term t' = "(3 + x) / (3 + - 1 * x)"
  58.854 +then () else error "cancel_p normal_form CHANGED";;
  58.855 +
  58.856 +(*initialize the interpreter state used by the 'me'*)
  58.857 +val SOME (t', asm) = cancel_p_ thy t;
  58.858 +if (UnparseC.term t', UnparseC.terms asm) = ("(3 + x) / (3 + - 1 * x)", "[\"3 + - 1 * x \<noteq> 0\"]")
  58.859 +then () else error "cancel_p  CHANGED";;
  58.860 +
  58.861 +val (t,_,revsets,_) = ini t;
  58.862 +
  58.863 +(* WN.10.10.02: dieser Fall terminiert nicht 
  58.864 +           (make_polynomial enth"alt zu viele rules)
  58.865 +WN060823 'init_state' requires rewriting on specified location in the term
  58.866 +default_print_depth 99; Rfuns; default_print_depth 3;
  58.867 +WN060831 cycling "sym_order_mult_rls_" "sym_mult.assoc"
  58.868 +         as was with make_polynomial before ?!?* )
  58.869 +
  58.870 +val SOME r = nex revsets t;
  58.871 +eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))", 
  58.872 +		mk_thm thy "9 = 3 \<up> 2"));
  58.873 +( *WN060831 *** id_of_thm
  58.874 +           Exception- ERROR raised ...
  58.875 +val (r,(t,asm))::_ = loc revsets t r;
  58.876 +UnparseC.term t;
  58.877 +
  58.878 +  val SOME r = nex revsets t;
  58.879 +  val (r,(t,asm))::_ = loc revsets t r;
  58.880 +  UnparseC.term t;
  58.881 +*)                    
  58.882 +
  58.883 +"-------- examples: rls norm_Rational ----------------------------------------";
  58.884 +"-------- examples: rls norm_Rational ----------------------------------------";
  58.885 +"-------- examples: rls norm_Rational ----------------------------------------";
  58.886 +Rewrite.trace_on := false; (*true false*)
  58.887 +
  58.888 +val t = TermC.str2term "Not (6*x is_atom)";
  58.889 +val SOME (t',_) = rewrite_set_ thy false powers_erls t; UnparseC.term t';
  58.890 +"HOL.True";
  58.891 +val t = TermC.str2term "1 < 2";
  58.892 +val SOME (t',_) = rewrite_set_ thy false powers_erls t; UnparseC.term t';
  58.893 +"HOL.True";
  58.894 +
  58.895 +val t = TermC.str2term "(6*x) \<up> 2";
  58.896 +val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false 
  58.897 +			   (ThmC.numerals_to_Free @{thm realpow_def_atom}) t;
  58.898 +if UnparseC.term t' = "6 * x * (6 * x) \<up> (2 + - 1)" then ()
  58.899 +else error "rational.sml powers_erls (6*x) \<up> 2";
  58.900 +
  58.901 +val t = TermC.str2term "- 1 * (- 2 * (5 / 2 * (13 * x / 2)))";
  58.902 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  58.903 +if UnparseC.term t' = "65 * x / 2" then () else error "rational.sml 4";
  58.904 +
  58.905 +val t = TermC.str2term "1 - ((13*x)/2 - 5/2) \<up> 2";
  58.906 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  58.907 +if UnparseC.term t' = "(- 21 + 130 * x + - 169 * x \<up> 2) / 4" then () 
  58.908 +else error "rational.sml 5";
  58.909 +
  58.910 +(*SRAM Schalk I, p.92 Nr. 609a*)
  58.911 +val t = TermC.str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
  58.912 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  58.913 +if UnparseC.term t' = "(- 255 + 112 * x) / 135" then () 
  58.914 +else error "rational.sml 6";
  58.915 +
  58.916 +(*SRAM Schalk I, p.92 Nr. 610c*)
  58.917 +val t = TermC.str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
  58.918 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  58.919 +if UnparseC.term t' = "(3 + x) / - 2" then () else error "rational.sml 7";
  58.920 +
  58.921 +(*SRAM Schalk I, p.92 Nr. 476a*)
  58.922 +val t = TermC.str2term "(x \<up> 2/(1 - x \<up> 2) + 1)/(x/(1 - x) + 1) * (1 + x)";
  58.923 +(*. a/b : c/d translated to a/b * d/c .*)
  58.924 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  58.925 +if UnparseC.term t' = "1" then () else error "rational.sml 8";
  58.926 +
  58.927 +(*Schalk I, p.92 Nr. 472a*)
  58.928 +val t = TermC.str2term "((8*x \<up> 2 - 32*y \<up> 2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
  58.929 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  58.930 +if UnparseC.term t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
  58.931 +
  58.932 +(*Schalk I, p.70 Nr. 480b: SEE rational.sml --- nonterminating rls norm_Rational ---*)
  58.933 +
  58.934 +(*WN130910 add_fractions_p exception Div raised + history:
  58.935 +### WN.2.6.03 from rlang.sml 56a 
  58.936 +val t = TermC.str2term "(a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a \<up> 2 + - 1 * b \<up> 2)";
  58.937 +val NONE = rewrite_set_ thy false add_fractions_p t;
  58.938 +
  58.939 +THE ERROR ALREADY OCCURS IN THIS PART:
  58.940 +val t = TermC.str2term "(a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x)";
  58.941 +val NONE = add_fraction_p_ thy t;
  58.942 +
  58.943 +SEE Test_Some.thy: section {* add_fractions_p downto exception Div raised ===
  58.944 +*)
  58.945 +
  58.946 +"-------- rational numerals --------------------------------------------------";
  58.947 +"-------- rational numerals --------------------------------------------------";
  58.948 +"-------- rational numerals --------------------------------------------------";
  58.949 +(*SRA Schalk I, p.40 Nr. 164b *)
  58.950 +val t = TermC.str2term "(47/6 - 76/9 + 13/4)/(35/12)";
  58.951 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  58.952 +if UnparseC.term t = "19 / 21" then ()
  58.953 +else error "rational.sml: diff.behav. in norm_Rational_mg 1";
  58.954 +
  58.955 +(*SRA Schalk I, p.40 Nr. 166a *)
  58.956 +val t = TermC.str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
  58.957 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  58.958 +if UnparseC.term t = "45 / 2" then ()
  58.959 +else error "rational.sml: diff.behav. in norm_Rational_mg 2";
  58.960 +
  58.961 +"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
  58.962 +"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
  58.963 +"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
  58.964 +(* e190c Stefan K.*)
  58.965 +val t = TermC.str2term "((1 + 9*a \<up> 2) * (1 + 3*a)) / ((3*a + 9*a \<up> 2) * (1 + 3*a))";
  58.966 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  58.967 +if UnparseC.term t = "(1 + 9 * a \<up> 2) / (3 * a + 9 * a \<up> 2)"
  58.968 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 3";
  58.969 +
  58.970 +(* e192b Stefan K.*)
  58.971 +val t = TermC.str2term "(x \<up> 2 * (7*x + (- 1)*y))  /  (y \<up> 2 * (7*x + (- 1)*y))";
  58.972 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  58.973 +if UnparseC.term t = "x \<up> 2 / y \<up> 2"
  58.974 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 4";
  58.975 +
  58.976 +(*SRC Schalk I, p.66 Nr. 379c *)
  58.977 +val t = TermC.str2term "(a - b)/(b - a)";
  58.978 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  58.979 +if UnparseC.term t = "- 1"
  58.980 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 5";
  58.981 +
  58.982 +(*SRC Schalk I, p.66 Nr. 380b *)
  58.983 +val t = TermC.str2term "15*(3*x + 3) * (4*x + 9)  /  (12*(2*x + 7) * (5*x + 5))";
  58.984 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  58.985 +if UnparseC.term t = "(27 + 12 * x) / (28 + 8 * x)"
  58.986 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 6";
  58.987 +
  58.988 +(* e190c Stefan K.*)
  58.989 +val t = TermC.str2term "((1 + 9*a \<up> 2) * (1 + 3*a))  /  ((3*a + 9*a \<up> 2) * (1 + 3 * a))";
  58.990 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  58.991 +if UnparseC.term t =  "(1 + 9 * a \<up> 2) / (3 * a + 9 * a \<up> 2)"
  58.992 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 3";
  58.993 +
  58.994 +(* e192b Stefan K.*)
  58.995 +val t = TermC.str2term "(x \<up> 2 * (7*x + (- 1)*y))  /  (y \<up> 2 * (7*x + (- 1)*y))";
  58.996 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
  58.997 +if UnparseC.term t = "x \<up> 2 / y \<up> 2"
  58.998 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 4";
  58.999 +
 58.1000 +(*SRC Schalk I, p.66 Nr. 379c *)
 58.1001 +val t = TermC.str2term "(a - b) / (b - a)";
 58.1002 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1003 +if UnparseC.term t = "- 1"
 58.1004 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 5";
 58.1005 +
 58.1006 +(*SRC Schalk I, p.66 Nr. 380b *)
 58.1007 +val t = TermC.str2term "15*(3*x + 3) * (4*x + 9)  /  (12*(2*x + 7) * (5*x + 5))";
 58.1008 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1009 +if UnparseC.term t = "(27 + 12 * x) / (28 + 8 * x)"
 58.1010 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 6";
 58.1011 +
 58.1012 +(* extreme example from somewhere *)
 58.1013 +val t = TermC.str2term 
 58.1014 +    ("(a \<up> 4 * x  +  - 1*a \<up> 4 * y  +  4*a \<up> 3 * b * x  +  -4*a \<up> 3 * b * y  + " ^
 58.1015 +      "6*a \<up> 2 * b \<up> 2 * x  +  -6*a \<up> 2 * b \<up> 2 * y  +  4*a * b \<up> 3 * x  +  -4*a * b \<up> 3 * y  + " ^
 58.1016 +      "b \<up> 4 * x  +  - 1*b \<up> 4 * y) " ^
 58.1017 +  " / (a \<up> 2 * x \<up> 3  +  -3*a \<up> 2 * x \<up> 2 * y  +  3*a \<up> 2 * x * y \<up> 2  +  - 1*a \<up> 2 * y \<up> 3 + " ^
 58.1018 +      "2*a * b * x \<up> 3  +  -6*a * b * x \<up> 2 * y  +  6*a * b * x * y \<up> 2  +  - 2*a * b * y \<up> 3 + " ^
 58.1019 +      "b \<up> 2 * x \<up> 3  +  -3*b \<up> 2 * x \<up> 2 * y  +  3*b \<up> 2 * x * y \<up> 2  +  - 1*b \<up> 2 * y \<up> 3)")
 58.1020 +val SOME (t, _) = rewrite_set_ thy false cancel_p t;
 58.1021 +if UnparseC.term t = "(a \<up> 2 + 2 * a * b + b \<up> 2) / (x \<up> 2 + - 2 * x * y + y \<up> 2)"
 58.1022 +then () else error "with Isabelle2002: NONE -- now SOME changed";
 58.1023 +
 58.1024 +(*Schalk I, p.66 Nr. 381a *)
 58.1025 +(* ATTENTION: here the rls is very slow. In Isabelle2002 this required 2 min *)
 58.1026 +val t = TermC.str2term "18*(a + b) \<up> 3 * (a - b) \<up> 2 / (72*(a - b) \<up> 3 * (a + b) \<up> 2)";
 58.1027 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1028 +if UnparseC.term t = "(a + b) / (4 * a + - 4 * b)"
 58.1029 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
 58.1030 +
 58.1031 +(*SRC Schalk I, p.66 Nr. 381b *)
 58.1032 +val t = TermC.str2term "(4*x \<up> 2 - 20*x + 25) / (2*x - 5) \<up> 3";
 58.1033 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1034 +if UnparseC.term t = "1 / (- 5 + 2 * x)"
 58.1035 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 9";
 58.1036 +
 58.1037 +(*SRC Schalk I, p.66 Nr. 381c *)
 58.1038 +val t = TermC.str2term "(27*a \<up> 3 + 9*a \<up> 2+3*a+1) / (27*a \<up> 3 + 18*a \<up> 2+3*a)";
 58.1039 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1040 +if UnparseC.term t = "(1 + 9 * a \<up> 2) / (3 * a + 9 * a \<up> 2)"
 58.1041 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 10";
 58.1042 +
 58.1043 +(*SRC Schalk I, p.66 Nr. 383a *)
 58.1044 +val t = TermC.str2term "(5*a \<up> 2 - 5*a*b) / (a - b) \<up> 2";
 58.1045 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1046 +if UnparseC.term t = "- 5 * a / (- 1 * a + b)"
 58.1047 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 11";
 58.1048 +
 58.1049 +"----- NOT TERMINATING ?: worked before 0707xx";
 58.1050 +val t = TermC.str2term "(a \<up> 2 - 1)*(b + 1) / ((b \<up> 2 - 1)*(a+1))";
 58.1051 +(* WN130911 "exception Div raised" by 
 58.1052 +  cancel_p_ thy (TermC.str2term ("(- 1 + - 1 * b + a \<up> 2 + a \<up> 2 * b) /" ^
 58.1053 +                           "(- 1 + - 1 * a + b \<up> 2 + a * b \<up> 2)"))
 58.1054 +
 58.1055 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1056 +if UnparseC.term t = "(1 + - 1 * a) / (1 + - 1 * b)" then ()
 58.1057 +else error "rational.sml MG tests 3e";
 58.1058 +*)
 58.1059 +
 58.1060 +"-------- examples common denominator from: Mathematik 1 Schalk --------------";
 58.1061 +"-------- examples common denominator from: Mathematik 1 Schalk --------------";
 58.1062 +"-------- examples common denominator from: Mathematik 1 Schalk --------------";
 58.1063 +(*SRA Schalk I, p.67 Nr. 403a *)
 58.1064 +val t = TermC.str2term "4/x - 3/y - 1";
 58.1065 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1066 +if UnparseC.term t = "(- 3 * x + 4 * y + - 1 * x * y) / (x * y)"
 58.1067 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 12";
 58.1068 +
 58.1069 +val t = TermC.str2term "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a \<up> 2+3*b*c)/(a*b*c)";
 58.1070 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1071 +if UnparseC.term t = "4 / c"
 58.1072 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 13";
 58.1073 +
 58.1074 +(*SRA Schalk I, p.67 Nr. 410b *)
 58.1075 +val t = TermC.str2term "1/(x+1) + 1/(x+2) - 2/(x+3)";
 58.1076 +(* WN130911 non-termination due to non-termination of
 58.1077 +  cancel_p_ thy (TermC.str2term "(5 + 3 * x) / (6 + 11 * x + 6 * x \<up> 2 + x \<up> 3)")
 58.1078 +
 58.1079 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1080 +if UnparseC.term t = "(5 + 3 * x) / (6 + 11 * x + 6 * x \<up> 2 + x \<up> 3)"
 58.1081 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 14";
 58.1082 +*)
 58.1083 +
 58.1084 +(*SRA Schalk I, p.67 Nr. 413b *)
 58.1085 +val t = TermC.str2term "(1 + x)/(1 - x)  -  (1 - x)/(1 + x)  +  2*x/(1 - x \<up> 2)";
 58.1086 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1087 +if UnparseC.term t = "6 * x / (1 + - 1 * x \<up> 2)"
 58.1088 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 15";
 58.1089 +
 58.1090 +(*SRA Schalk I, p.68 Nr. 414a *)
 58.1091 +val t = TermC.str2term "(x + 2)/(x - 1)  +  (x - 3)/(x - 2)  -  (x + 1)/((x - 1)*(x - 2))";
 58.1092 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1093 +if UnparseC.term t ="(- 2 + - 5 * x + 2 * x \<up> 2) / (2 + - 3 * x + x \<up> 2)"
 58.1094 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 16";
 58.1095 +
 58.1096 +(*SRA Schalk I, p.68 Nr. 428b *)
 58.1097 +val t = TermC.str2term 
 58.1098 +  "1/(a - b) \<up> 2  +  1/(a + b) \<up> 2  -  2/(a \<up> 2 - b \<up> 2)  -  4*(b \<up> 2 - 1)/(a \<up> 2 - b \<up> 2) \<up> 2";
 58.1099 +(* WN130911 non-termination due to non-termination of
 58.1100 +  cancel_p_ thy (TermC.str2term "(4 + -4 * b \<up> 2) / (a \<up> 4 + - 2 * (a \<up> 2 * b \<up> 2) + b \<up> 4)")
 58.1101 +
 58.1102 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1103 +if UnparseC.term t = "4 / (a \<up> 4 + - 2 * a \<up> 2 * b \<up> 2 + b \<up> 4)"
 58.1104 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 18";
 58.1105 +*)
 58.1106 +
 58.1107 +(*SRA Schalk I, p.68 Nr. 430b *)
 58.1108 +val t = TermC.str2term 
 58.1109 +  "a \<up> 2/(a - 3*b) - 108*a*b \<up> 3/((a+3*b)*(a \<up> 2 - 9*b \<up> 2)) - 9*b \<up> 2*(a - 3*b)/(a+3*b) \<up> 2";
 58.1110 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1111 +if UnparseC.term t = "a + 3 * b"
 58.1112 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 19";
 58.1113 +
 58.1114 +(*SRA Schalk I, p.68 Nr. 432 *)
 58.1115 +val t = TermC.str2term 
 58.1116 +  ("(a \<up> 2 + a*b) / (a \<up> 2 - b \<up> 2)  -  (b \<up> 2 - a*b) / (b \<up> 2 - a \<up> 2)  +  " ^
 58.1117 +  "a \<up> 2*(a - b) / (a \<up> 3 - a \<up> 2*b)  -  2*a*(a \<up> 2 - b \<up> 2) / (a \<up> 3 - a*b \<up> 2)  -  " ^
 58.1118 +  "2*b \<up> 2 / (a \<up> 2 - b \<up> 2)");
 58.1119 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1120 +if UnparseC.term t = (*"0" ..isabisac15 | Isabelle2017..*)  "0 / (a \<up> 2 + - 1 * b \<up> 2)"
 58.1121 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 20";
 58.1122 +
 58.1123 +(* some example *)
 58.1124 +val t = TermC.str2term "3*a / (a*b)  +  x/y";
 58.1125 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1126 +if UnparseC.term t = "(3 * y + b * x) / (b * y)"
 58.1127 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 21";
 58.1128 +
 58.1129 +
 58.1130 +"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
 58.1131 +"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
 58.1132 +"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
 58.1133 +(*------- SRM Schalk I, p.68 Nr. 436a *)
 58.1134 +val t = TermC.str2term "3*(x+y) / (15*(x - y))  *   25*(x - y) \<up> 2 / (18*(x + y) \<up> 2)";
 58.1135 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1136 +if UnparseC.term t = "(- 5 * x + 5 * y) / (- 18 * x + - 18 * y)"
 58.1137 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 22";
 58.1138 +
 58.1139 +(*------- SRM.test Schalk I, p.68 Nr. 436b *)
 58.1140 +val t = TermC.str2term "5*a*(a - b) \<up> 2*(a + b) \<up> 3/(7*b*(a - b) \<up> 3) * 7*b/(a + b) \<up> 3";
 58.1141 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1142 +if UnparseC.term t = "5 * a / (a + - 1 * b)"
 58.1143 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 23";
 58.1144 +
 58.1145 +(*------- Schalk I, p.68 Nr. 437a *)
 58.1146 +val t = TermC.str2term "(3*a - 4*b) / (4*c+3*e)  *  (3*a+4*b)/(9*a \<up> 2 - 16*b \<up> 2)";
 58.1147 +(* raises an exception for unclear reasons:
 58.1148 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1149 +:
 58.1150 +###  rls: cancel_p on: (9 * a \<up> 2 + - 16 * b \<up> 2) / (4 * c + 3 * e) /
 58.1151 +(9 * a \<up> 2 + - 16 * b \<up> 2) 
 58.1152 +exception Div raised
 58.1153 +
 58.1154 +BUT
 58.1155 +val t = TermC.str2term 
 58.1156 +  ("(9 * a \<up> 2 + - 16 * b \<up> 2) / (4 * c + 3 * e) /" ^
 58.1157 +  "(9 * a \<up> 2 + - 16 * b \<up> 2)");
 58.1158 +NONE = cancel_p_ thy t;
 58.1159 +
 58.1160 +if UnparseC.term t = "1 / (4 * c + 3 * e)" then ()
 58.1161 +else error "rational.sml: diff.behav. in norm_Rational_mg 24";
 58.1162 +*)
 58.1163 +
 58.1164 +"----- S.K. corrected non-termination 060904";
 58.1165 +val t = TermC.str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a \<up> 2 - 16*b \<up> 2))";
 58.1166 +val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
 58.1167 +if UnparseC.term t = 
 58.1168 +  "(9 * a \<up> 2 + - 16 * b \<up> 2) /\n(36 * a \<up> 2 * c + 27 * a \<up> 2 * e + - 64 * b \<up> 2 * c +\n - 48 * b \<up> 2 * e)"
 58.1169 +then () else error "rational.sml: S.K.8..corrected 060904-6";
 58.1170 +
 58.1171 +"----- S.K. corrected non-termination of cancel_p_";
 58.1172 +val t'' = TermC.str2term ("(9 * a \<up> 2 + - 16 * b \<up> 2) /" ^
 58.1173 +  "(36 * a \<up> 2 * c + (27 * a \<up> 2 * e + (-64 * b \<up> 2 * c + -48 * b \<up> 2 * e)))");
 58.1174 +(* /--- DOES NOT TERMINATE AT TRANSITION isabisac15 --> Isabelle2017 --------------------------\
 58.1175 +val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
 58.1176 +if UnparseC.term t' = "1 / (4 * c + 3 * e)"
 58.1177 +then () else error "rational.sml: diff.behav. in cancel_p S.K.8";
 58.1178 +   \--- DOES NOT TERMINATE AT TRANSITION isabisac15 --> Isabelle2017 --------------------------/*)
 58.1179 +
 58.1180 +(*------- Schalk I, p.68 Nr. 437b*)
 58.1181 +val t = TermC.str2term "(a + b)/(x \<up> 2 - y \<up> 2) * ((x - y) \<up> 2/(a \<up> 2 - b \<up> 2))";
 58.1182 +(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1183 +:
 58.1184 +####  rls: cancel_p on: (a * x \<up> 2 + - 2 * (a * (x * y)) + a * y \<up> 2 + b * x \<up> 2 +
 58.1185 + - 2 * (b * (x * y)) +
 58.1186 + b * y \<up> 2) /
 58.1187 +(a \<up> 2 * x \<up> 2 + - 1 * (a \<up> 2 * y \<up> 2) + - 1 * (b \<up> 2 * x \<up> 2) +
 58.1188 + b \<up> 2 * y \<up> 2) 
 58.1189 +exception Div raised
 58.1190 +*)
 58.1191 +
 58.1192 +(*------- SRM Schalk I, p.68 Nr. 438a *)
 58.1193 +val t = TermC.str2term "x*y / (x*y - y \<up> 2)  *  (x \<up> 2 - x*y)";
 58.1194 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1195 +if UnparseC.term t = "x \<up> 2"
 58.1196 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 24";
 58.1197 +
 58.1198 +(*------- SRM Schalk I, p.68 Nr. 439b *)
 58.1199 +val t = TermC.str2term "(4*x \<up> 2 + 4*x + 1)  *  ((x \<up> 2 - 2*x \<up> 3) / (4*x \<up> 2 + 2*x))";
 58.1200 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1201 +if UnparseC.term t = "(x + - 4 * x \<up> 3) / 2"
 58.1202 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 25";
 58.1203 +
 58.1204 +(*------- SRM Schalk I, p.68 Nr. 440a *)
 58.1205 +val t = TermC.str2term "(x \<up> 2 - 2*x) / (x \<up> 2 - 3*x)  *  (x - 3) \<up> 2 / (x \<up> 2 - 4)";
 58.1206 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1207 +if UnparseC.term t = "(- 3 + x) / (2 + x)"
 58.1208 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 26";
 58.1209 +
 58.1210 +"----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
 58.1211 +val t = TermC.str2term "(a \<up> 3 - 9*a) / (a \<up> 3*b - a*b \<up> 3)  *  (a \<up> 2*b + a*b \<up> 2) / (a+3)";
 58.1212 +(* WN130911 non-termination for unclear reasons:
 58.1213 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1214 +
 58.1215 +... ENDS WITH THIS TRACE:
 58.1216 +:
 58.1217 +###  rls: cancel_p on: (-9 * (a \<up> 3 * b) + -9 * (a \<up> 2 * b \<up> 2) + a \<up> 5 * b +
 58.1218 + a \<up> 4 * b \<up> 2) /
 58.1219 +(a \<up> 3 * b + - 1 * (a * b \<up> 3)) /
 58.1220 +(3 + a)
 58.1221 +BUT THIS IS CORRECTLY RECOGNISED 
 58.1222 +val t = TermC.str2term 
 58.1223 +  ("(-9 * (a \<up> 3 * b) + -9 * (a \<up> 2 * b \<up> 2) + a \<up> 5 * b + a \<up> 4 * b \<up> 2)  /" ^
 58.1224 +  "(a \<up> 3 * b + - 1 * (a * b \<up> 3))  /  (3 + (a::real))");
 58.1225 +AS
 58.1226 +NONE = cancel_p_ thy t;
 58.1227 +
 58.1228 +if UnparseC.term t = "(-3 * a + a \<up> 2) / (a + - 1 * b)" then ()
 58.1229 +else error "rational.sml: diff.behav. in norm_Rational 27";
 58.1230 +*)
 58.1231 +
 58.1232 +"----- SK12 works since 0707xx";
 58.1233 +val t = TermC.str2term "(a \<up> 3 - 9*a) * (a \<up> 2*b+a*b \<up> 2)  /  ((a \<up> 3*b - a*b \<up> 3) * (a+3))";
 58.1234 +(* WN130911 non-termination due to non-termination of
 58.1235 +  cancel_p_ thy (TermC.str2term "(4 + -4 * b \<up> 2) / (a \<up> 4 + - 2 * (a \<up> 2 * b \<up> 2) + b \<up> 4)")
 58.1236 +
 58.1237 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1238 +if UnparseC.term t' = "(-3 * a + a \<up> 2) / (a + - 1 * b)" then ()
 58.1239 +else error "rational.sml: diff.behav. in norm_Rational 28";
 58.1240 +*)
 58.1241 +
 58.1242 +"-------- examples common denominator and multiplication from: Schalk --------";
 58.1243 +"-------- examples common denominator and multiplication from: Schalk --------";
 58.1244 +"-------- examples common denominator and multiplication from: Schalk --------";
 58.1245 +(*------- SRAM Schalk I, p.69 Nr. 441b *)
 58.1246 +val t = TermC.str2term "(4*a/3 + 3*b \<up> 2/a \<up> 3 + b/(4*a))*(4*b/(3*a))";
 58.1247 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1248 +if UnparseC.term t = "(36 * b \<up> 3 + 3 * a \<up> 2 * b \<up> 2 + 16 * a \<up> 4 * b) /\n(9 * a \<up> 4)"
 58.1249 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
 58.1250 +
 58.1251 +(*------- SRAM Schalk I, p.69 Nr. 442b *)
 58.1252 +val t = TermC.str2term ("(15*a \<up> 2/x \<up> 3 - 5*b \<up> 4/x \<up> 2 + 25*c \<up> 2/x) * " ^
 58.1253 +  "(x \<up> 3/(5*a*b \<up> 3*c \<up> 3)) + 1/c \<up> 3 * (b*x/a - 3*a/b \<up> 3)");
 58.1254 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1255 +if UnparseC.term t = "5 * x \<up> 2 / (a * b \<up> 3 * c)"
 58.1256 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
 58.1257 +
 58.1258 +(*------- SRAM Schalk I, p.69 Nr. 443b *)
 58.1259 +val t = TermC.str2term "(a/2 + b/3) * (b/3 - a/2)";
 58.1260 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1261 +if UnparseC.term t = "(- 9 * a \<up> 2 + 4 * b \<up> 2) / 36"
 58.1262 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
 58.1263 +
 58.1264 +(*------- SRAM Schalk I, p.69 Nr. 445b *)
 58.1265 +val t = TermC.str2term "(a \<up> 2/9 + 2*a/(3*b) + 4/b \<up> 2)*(a/3 - 2/b) + 8/b \<up> 3";
 58.1266 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1267 +if UnparseC.term t = "a \<up> 3 / 27"
 58.1268 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
 58.1269 +
 58.1270 +(*------- SRAM Schalk I, p.69 Nr. 446b *)
 58.1271 +val t = TermC.str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x \<up> 2 - 16*y \<up> 2)";
 58.1272 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1273 +if UnparseC.term t = (*"30 * x \<up> 2 + -9 * x * y + - 20 * y \<up> 2" ..isabisac15 | Isabelle2017..*)
 58.1274 +                  "(- 30 * x \<up> 2 + 9 * x * y + 20 * y \<up> 2) / - 1"
 58.1275 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 32";
 58.1276 +
 58.1277 +(*------- SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
 58.1278 +val t = TermC.str2term 
 58.1279 +"(2*x \<up> 2/(3*y)+x/y \<up> 2)*(4*x \<up> 4/(9*y \<up> 2)+x \<up> 2/y \<up> 4)*(2*x \<up> 2/(3*y) - x/y \<up> 2)";
 58.1280 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1281 +if UnparseC.term t = "(- 81 * x \<up> 4 + 16 * x \<up> 8 * y \<up> 4) / (81 * y \<up> 8)"
 58.1282 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
 58.1283 +
 58.1284 +(*------- SRAM Schalk I, p.69 Nr. 450a *)
 58.1285 +val t = TermC.str2term 
 58.1286 +"(4*x/(3*y)+2*y/(3*x)) \<up> 2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
 58.1287 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1288 +if UnparseC.term t = "(52 * x \<up> 2 + 16 * y \<up> 2) / (9 * y \<up> 2)"
 58.1289 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 34";
 58.1290 +
 58.1291 +(*------- SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
 58.1292 +val t = TermC.str2term 
 58.1293 +  ("(15*a \<up> 4/(a*x \<up> 3)  -  5*a*((b \<up> 4 - 5*c \<up> 2*x) / x \<up> 2))  *  " ^
 58.1294 +  "(x \<up> 3/(5*a*b \<up> 3*c \<up> 3))   +   a/c \<up> 3 * (x*(b/a) - 3*b*(a/b \<up> 4))");
 58.1295 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1296 +if UnparseC.term t = "5 * x \<up> 2 / (b \<up> 3 * c)"
 58.1297 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 53";
 58.1298 +
 58.1299 +
 58.1300 +"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
 58.1301 +"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
 58.1302 +"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
 58.1303 +"----- SRD Schalk I, p.69 Nr. 454b";
 58.1304 +val t = TermC.str2term "((2 - x)/(2*a)) / (2*a/(x - 2))";
 58.1305 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1306 +if UnparseC.term t = "(- 4 + 4 * x + - 1 * x \<up> 2) / (4 * a \<up> 2)"
 58.1307 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 35";
 58.1308 +
 58.1309 +"----- SRD Schalk I, p.69 Nr. 455a";
 58.1310 +val t = TermC.str2term "(a \<up> 2 + 1)/(a \<up> 2 - 1) / ((a+1)/(a - 1))";
 58.1311 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1312 +if UnparseC.term t = "(1 + a \<up> 2) / (1 + 2 * a + a \<up> 2)" then ()
 58.1313 +else error "rational.sml: diff.behav. in norm_Rational_mg 36";
 58.1314 +
 58.1315 +"----- Schalk I, p.69 Nr. 455b";
 58.1316 +val t = TermC.str2term "(x \<up> 2 - 4)/(y \<up> 2 - 9)/((2+x)/(3 - y))";
 58.1317 +(* WN130911 non-termination due to non-termination of
 58.1318 +  cancel_p_ thy (TermC.str2term ("(- 12 + 4 * y + 3 * x \<up> 2 + - 1 * (x \<up> 2 * y)) /" ^
 58.1319 +                           "(- 18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)"))
 58.1320 +
 58.1321 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1322 +if UnparseC.term t = "(2 + - 1 * x) / (3 + y)" then ()
 58.1323 +else error "rational.sml: diff.behav. in norm_Rational_mg 37";
 58.1324 +*)
 58.1325 +
 58.1326 +"----- SK060904- 1a non-termination of cancel_p_ ?: worked before 0707xx";
 58.1327 +val t = TermC.str2term "(x \<up> 2 - 4)*(3 - y) / ((y \<up> 2 - 9)*(2+x))";
 58.1328 +(* WN130911 non-termination due to non-termination of
 58.1329 +  cancel_p_ thy (TermC.str2term ("(- 12 + 4 * y + 3 * x \<up> 2 + - 1 * (x \<up> 2 * y)) /" ^
 58.1330 +                           "(- 18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)"))
 58.1331 +
 58.1332 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1333 +if UnparseC.term t = "(2 + - 1 * x) / (3 + y)" then ()
 58.1334 +else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
 58.1335 +*)
 58.1336 +
 58.1337 +"----- ?: worked before 0707xx";
 58.1338 +val t = TermC.str2term "(3 + - 1 * y) / (-9 + y \<up> 2)";
 58.1339 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1340 +if UnparseC.term t = "- 1 / (3 + y)"
 58.1341 +then () else error "rational.sml: - 1 / (3 + y) norm_Rational";
 58.1342 +
 58.1343 +"----- SRD Schalk I, p.69 Nr. 456b";
 58.1344 +val t = TermC.str2term "(b \<up> 3 - b \<up> 2) / (b \<up> 2+b) / (b \<up> 2 - 1)";
 58.1345 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1346 +if UnparseC.term t = "b / (1 + 2 * b + b \<up> 2)"
 58.1347 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 38";
 58.1348 +
 58.1349 +"----- SRD Schalk I, p.69 Nr. 457b";
 58.1350 +val t = TermC.str2term "(16*a \<up> 2 - 9*b \<up> 2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a \<up> 2 - 9*a \<up> 2*b \<up> 2))";
 58.1351 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1352 +if UnparseC.term t = "8 * a \<up> 2 + - 6 * a * b + - 12 * a \<up> 2 * b + 9 * a * b \<up> 2"
 58.1353 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
 58.1354 +
 58.1355 +"----- Schalk I, p.69 Nr. 458b works since 0707";
 58.1356 +val t = TermC.str2term "(2*a \<up> 2*x - a \<up> 2) / (a*x - b*x) / (b \<up> 2*(2*x - 1) / (x*(a - b)))";
 58.1357 +(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1358 +:
 58.1359 +###  rls: cancel_p on: (- 1 * a \<up> 2 + 2 * (a \<up> 2 * x)) / (a * x + - 1 * (b * x)) /
 58.1360 +((- 1 * b \<up> 2 + 2 * (b \<up> 2 * x)) / (a * x + - 1 * (b * x))) 
 58.1361 +exception Div raised
 58.1362 +
 58.1363 +BUT
 58.1364 +val t = TermC.str2term 
 58.1365 +  ("(- 1 * a \<up> 2 + 2 * (a \<up> 2 * x)) / (a * x + - 1 * (b * x)) /" ^
 58.1366 +  "((- 1 * b \<up> 2 + 2 * (b \<up> 2 * x)) / (a * x + - 1 * (b * x)))");
 58.1367 +NONE = cancel_p_ thy t;
 58.1368 +
 58.1369 +if UnparseC.term t = "a \<up> 2 / b \<up> 2" then ()
 58.1370 +else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
 58.1371 +*)
 58.1372 +
 58.1373 +"----- SRD Schalk I, p.69 Nr. 459b";
 58.1374 +val t = TermC.str2term "(a \<up> 2 - b \<up> 2)/(a*b) / (4*(a+b) \<up> 2/a)";
 58.1375 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1376 +if UnparseC.term t = "(a + - 1 * b) / (4 * a * b + 4 * b \<up> 2)" then ()
 58.1377 +else error "rational.sml: diff.behav. in norm_Rational_mg 41";
 58.1378 +
 58.1379 +"----- Schalk I, p.69 Nr. 460b nonterm.SK";
 58.1380 +val t = TermC.str2term "(9*(x \<up> 2 - 8*x + 16) / (4*(y \<up> 2 - 2*y + 1))) / ((3*x - 12) / (16*y - 16))";
 58.1381 +(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1382 +exception Div raised
 58.1383 +
 58.1384 +BUT
 58.1385 +val t = TermC.str2term 
 58.1386 +  ("(144 + -72 * x + 9 * x \<up> 2) / (4 + -8 * y + 4 * y \<up> 2) /" ^
 58.1387 +  "((- 12 + 3 * x) / (- 16 + 16 * y))");
 58.1388 +NONE = cancel_p_ thy t;
 58.1389 +
 58.1390 +if UnparseC.term t = !!!!!!!!!!!!!!!!!!!!!!!!!
 58.1391 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 42";
 58.1392 +*)
 58.1393 +
 58.1394 +"----- some variant of the above; was non-terminating before";
 58.1395 +val t = TermC.str2term "9*(x \<up> 2 - 8*x+16)*(16*y - 16)/(4*(y \<up> 2 - 2*y+1)*(3*x - 12))";
 58.1396 +val SOME (t , _) = rewrite_set_ thy false norm_Rational t;
 58.1397 +if UnparseC.term t = "(48 + - 12 * x) / (1 + - 1 * y)"
 58.1398 +then () else error "some variant of the above; was non-terminating before";
 58.1399 +
 58.1400 +"----- SRD Schalk I, p.70 Nr. 472a";
 58.1401 +val t = TermC.str2term ("((8*x \<up> 2 - 32*y \<up> 2) / (2*x + 4*y))  /  ((4*x - 8*y) / (x + y))");
 58.1402 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1403 +if UnparseC.term t = "x + y"
 58.1404 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 43";
 58.1405 +
 58.1406 +"----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
 58.1407 +val t = TermC.str2term ("(a - (a*b + b \<up> 2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
 58.1408 +		 "((a - a \<up> 2/(a+b))/(a+(a*b)/(a - b)))");
 58.1409 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1410 +if UnparseC.term t = "(2 * a \<up> 3 + 2 * a \<up> 2 * b) / (a \<up> 2 * b + b \<up> 3)"
 58.1411 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 51";
 58.1412 +
 58.1413 +(*SRD Schalk I, p.69 Nr. 461a *)
 58.1414 +val t = TermC.str2term "(2/(x+3) + 2/(x - 3)) / (8*x/(x \<up> 2 - 9))";
 58.1415 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1416 +if UnparseC.term t = "1 / 2"
 58.1417 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 44";
 58.1418 +
 58.1419 +(*SRD Schalk I, p.69 Nr. 464b *)
 58.1420 +val t = TermC.str2term "(a - a/(a - 2)) / (a + a/(a - 2))";
 58.1421 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1422 +if UnparseC.term t = "(- 3 + a) / (- 1 + a)"
 58.1423 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 45";
 58.1424 +
 58.1425 +(*SRD Schalk I, p.69 Nr. 465b *)
 58.1426 +val t = TermC.str2term "((x+3*y)/9 + (4*y \<up> 2 - 9*z \<up> 2)/(16*x))   /   (x/9 + y/6 + z/4)";
 58.1427 +(* WN130911 non-termination due to non-termination of
 58.1428 +  cancel_p_ thy (TermC.str2term 
 58.1429 +    ("("(576 * x \<up> 2 + 1728 * (x * y) + 1296 * y \<up> 2 + - 2916 * z \<up> 2) /" ^
 58.1430 +      "(576 * x \<up> 2 + 864 * (x * y) + 1296 * (x * z))"))
 58.1431 +
 58.1432 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1433 +if UnparseC.term t = "(4 * x + 6 * y + -9 * z) / (4 * x)"
 58.1434 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 46";
 58.1435 +*)
 58.1436 +
 58.1437 +(*SRD Schalk I, p.69 Nr. 466b *)
 58.1438 +val t = TermC.str2term "((1 - 7*(x - 2)/(x \<up> 2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x \<up> 2 - 25))";
 58.1439 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1440 +if UnparseC.term t = "(25 + - 10 * x + x \<up> 2) / 18"
 58.1441 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 47";
 58.1442 +
 58.1443 +(*SRD Schalk I, p.70 Nr. 469 *)
 58.1444 +val t = TermC.str2term ("3*b \<up> 2 / (4*a \<up> 2 - 8*a*b + 4*b \<up> 2) / " ^
 58.1445 +  "(a / (a \<up> 2*b - b \<up> 3)  +  (a - b) / (4*a*b \<up> 2 + 4*b \<up> 3)  -  1 / (4*b \<up> 2))");
 58.1446 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1447 +if UnparseC.term t = "- 3 * b \<up> 3 / (- 2 * a + 2 * b)"
 58.1448 +then () else error "rational.sml: diff.behav. in norm_Rational_mg 48";
 58.1449 +
 58.1450 +(*//----------------------------------TOODOO (*Rfuns revsets \<longrightarrow> broken*)
 58.1451 +"-------- me Schalk I No.186 -------------------------------------------------";
 58.1452 +"-------- me Schalk I No.186 -------------------------------------------------";
 58.1453 +"-------- me Schalk I No.186 -------------------------------------------------";
 58.1454 +val fmz = ["Term ((14 * x * y) / ( x * y ))", "normalform N"];
 58.1455 +val (dI',pI',mI') =
 58.1456 +  ("Rational",["rational", "simplification"],
 58.1457 +   ["simplification", "of_rationals"]);
 58.1458 +val p = e_pos'; val c = []; 
 58.1459 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 58.1460 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 58.1461 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 58.1462 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 58.1463 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 58.1464 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 58.1465 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 58.1466 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 58.1467 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 58.1468 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 58.1469 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
 58.1470 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
 58.1471 +case (f2str f, nxt) of
 58.1472 +    ("14", ("End_Proof'", _)) => ()
 58.1473 +  | _ => error "rational.sml diff.behav. in me Schalk I No.186";
 58.1474 +  \\----------------------------------TOODOO (*Rfuns revsets \<longrightarrow> broken*)*)
 58.1475 +
 58.1476 +(*//----------------------------------TOODOO (*Rfuns revsets \<longrightarrow> broken*)
 58.1477 +"-------- interSteps ..Simp_Rat_Double_No- 1.xml ------------------------------";
 58.1478 +"-------- interSteps ..Simp_Rat_Double_No- 1.xml ------------------------------";
 58.1479 +"-------- interSteps ..Simp_Rat_Double_No- 1.xml ------------------------------";
 58.1480 +reset_states ();
 58.1481 +CalcTree [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"], 
 58.1482 +  ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
 58.1483 +Iterator 1;
 58.1484 +moveActiveRoot 1;
 58.1485 +autoCalculate 1 CompleteCalc;
 58.1486 +val ((pt, p), _) = get_calc 1; 
 58.1487 +(*
 58.1488 +Test_Tool.show_pt pt;
 58.1489 +[
 58.1490 +(([], Frm), Simplify ((2 - x) / (2 * a) / (2 * a / (x - 2)))),
 58.1491 +(([1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
 58.1492 +(([1], Res), (2 + - 1 * x) / (2 * a) / (2 * a / (x + - 1 * 2))),
 58.1493 +(([2], Res), (2 + - 1 * x) / (2 * a) / (2 * a / (- 2 + x))),
 58.1494 +(([3], Res), (2 + - 1 * x) * (- 2 + x) / (2 * a * (2 * a))),
 58.1495 +(([4], Res), (-4 + 4 * x + - 1 * x \<up> 2) / (4 * a \<up> 2)),
 58.1496 +(([], Res), (-4 + 4 * x + - 1 * x \<up> 2) / (4 * a \<up> 2))] 
 58.1497 +*)
 58.1498 +interSteps 1 ([1], Res);
 58.1499 +val ((pt, p), _) = get_calc 1; 
 58.1500 +(*Test_Tool.show_pt pt;
 58.1501 +[
 58.1502 +(([], Frm), Simplify ((2 - x) / (2 * a) / (2 * a / (x - 2)))),
 58.1503 +(([1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
 58.1504 +(([1,1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
 58.1505 +(([1,1], Res), (2 - x) / (2 * a) / (2 * a / (x + - 1 * 2))),
 58.1506 +(([1,2], Res), (2 + - 1 * x) / (2 * a) / (2 * a / (x + - 1 * 2))),
 58.1507 +(([1], Res), (2 + - 1 * x) / (2 * a) / (2 * a / (x + - 1 * 2))),
 58.1508 +(([2], Res), (2 + - 1 * x) / (2 * a) / (2 * a / (- 2 + x))),
 58.1509 +(([3], Res), (2 + - 1 * x) * (- 2 + x) / (2 * a * (2 * a))),
 58.1510 +(([4], Res), (-4 + 4 * x + - 1 * x \<up> 2) / (4 * a \<up> 2)),
 58.1511 +(([], Res), (-4 + 4 * x + - 1 * x \<up> 2) / (4 * a \<up> 2))] 
 58.1512 +*)
 58.1513 +val (t, asm) = get_obj g_result pt [1, 1];
 58.1514 +if UnparseC.term t = "(2 - x) / (2 * a) / (2 * a / (x + - 1 * 2))" andalso UnparseC.terms asm = "[]"
 58.1515 +then () else error "2nd interSteps ..Simp_Rat_Double_No- 1 changed on [1, 1]";
 58.1516 +val (t, asm) = get_obj g_result pt [1, 2];
 58.1517 +if UnparseC.term t = "(2 + - 1 * x) / (2 * a) / (2 * a / (x + - 1 * 2))" andalso UnparseC.terms asm = "[]"
 58.1518 +then () else error "3rd interSteps ..Simp_Rat_Double_No- 1 changed on [1, 2]";
 58.1519 +  \\----------------------------------TOODOO (*Rfuns revsets \<longrightarrow> broken*)*)
 58.1520 +
 58.1521 +
 58.1522 +(*//----------------------------------TOODOO (*Rfuns revsets \<longrightarrow> broken*)
 58.1523 +"-------- interSteps ..Simp_Rat_Cancel_No- 1.xml ------------------------------";
 58.1524 +"-------- interSteps ..Simp_Rat_Cancel_No- 1.xml ------------------------------";
 58.1525 +"-------- interSteps ..Simp_Rat_Cancel_No- 1.xml ------------------------------";
 58.1526 +reset_states ();
 58.1527 +CalcTree [(["Term ((a^2 + - 1*b^2) / (a^2 + - 2*a*b + b^2))", "normalform N"], 
 58.1528 +  ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
 58.1529 +Iterator 1;
 58.1530 +moveActiveRoot 1;
 58.1531 +autoCalculate 1 CompleteCalc;
 58.1532 +val ((pt, p), _) = get_calc 1;
 58.1533 +(*Test_Tool.show_pt pt;
 58.1534 +[
 58.1535 +(([], Frm), Simplify ((a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * a * b + b \<up> 2))),
 58.1536 +(([1], Frm), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * a * b + b \<up> 2)),
 58.1537 +(([1], Res), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * (a * b) + b \<up> 2)),
 58.1538 +(([2], Res), (a + b) / (a + - 1 * b)),
 58.1539 +(([], Res), (a + b) / (a + - 1 * b))] 
 58.1540 +*)
 58.1541 +interSteps 1 ([2], Res);
 58.1542 +val ((pt, p), _) = get_calc 1;
 58.1543 +(*Test_Tool.show_pt pt;
 58.1544 +[
 58.1545 +(([], Frm), Simplify ((a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * a * b + b \<up> 2))),
 58.1546 +(([1], Frm), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * a * b + b \<up> 2)),
 58.1547 +(([1], Res), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * (a * b) + b \<up> 2)),
 58.1548 +(([2,1], Frm), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * (a * b) + b \<up> 2)),
 58.1549 +(([2,1], Res), (a + b) / (a + - 1 * b)),
 58.1550 +(([2], Res), (a + b) / (a + - 1 * b)),
 58.1551 +(([], Res), (a + b) / (a + - 1 * b))] 
 58.1552 +*)
 58.1553 +interSteps 1 ([2,1],Res);
 58.1554 +val ((pt, p), _) = get_calc 1; 
 58.1555 +(*Test_Tool.show_pt pt;
 58.1556 +[
 58.1557 +(([], Frm), Simplify ((a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * a * b + b \<up> 2))),
 58.1558 +(([1], Frm), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * a * b + b \<up> 2)),
 58.1559 +(([1], Res), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * (a * b) + b \<up> 2)),
 58.1560 +(([2,1], Frm), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * (a * b) + b \<up> 2)),
 58.1561 +(([2,1,1], Frm), (a \<up> 2 + - 1 * b \<up> 2) / (a \<up> 2 + - 2 * (a * b) + b \<up> 2)),
 58.1562 +(([2,1,1], Res), (a \<up> 2 + - 1 * (a * b) + a * b + - 1 * b \<up> 2) /
 58.1563 +(a \<up> 2 + - 2 * (a * b) + 1 * b \<up> 2)),
 58.1564 +(([2,1,2], Res), (a \<up> 2 + - 1 * (a * b) + a * b + - 1 * b \<up> 2) /
 58.1565 +(a \<up> 2 + - 2 * (a * b) + - 1 \<up> 2 * b \<up> 2)),
 58.1566 +(([2,1,3], Res), (a \<up> 2 + - 1 * (a * b) + a * b + - 1 * b \<up> 2) /
 58.1567 +(a \<up> 2 + - 2 * (a * b) + (- 1 * b) \<up> 2)),
 58.1568 +(([2,1,4], Res), (a * a + - 1 * (a * b) + a * b + - 1 * b \<up> 2) /
 58.1569 +(a \<up> 2 + - 2 * (a * b) + (- 1 * b) \<up> 2)),
 58.1570 +(([2,1,5], Res), (a * a + - 1 * (a * b) + a * b + - 1 * (b * b)) /
 58.1571 +(a \<up> 2 + - 2 * (a * b) + (- 1 * b) \<up> 2)),
 58.1572 +(([2,1,6], Res), (a * a + - 1 * (a * b) + a * b + - 1 * (b * b)) /
 58.1573 +(a \<up> 2 + - 1 * (2 * (a * b)) + (- 1 * b) \<up> 2)),
 58.1574 +(([2,1,7], Res), (a * a + a * (- 1 * b) + (b * a + b * (- 1 * b))) /
 58.1575 +(a \<up> 2 + 2 * (a * (- 1 * b)) + (- 1 * b) \<up> 2)),
 58.1576 +(([2,1,8], Res), (a * a + a * (- 1 * b) + (b * a + b * (- 1 * b))) /
 58.1577 +(a \<up> 2 + 2 * a * (- 1 * b) + (- 1 * b) \<up> 2)),
 58.1578 +(([2,1,9], Res), (a * (a + - 1 * b) + (b * a + b * (- 1 * b))) /
 58.1579 +(a \<up> 2 + 2 * a * (- 1 * b) + (- 1 * b) \<up> 2)),
 58.1580 +(([2,1,10], Res), (a * (a + - 1 * b) + b * (a + - 1 * b)) /
 58.1581 +(a \<up> 2 + 2 * a * (- 1 * b) + (- 1 * b) \<up> 2)),
 58.1582 +(([2,1,11], Res), (a + b) * (a + - 1 * b) / (a \<up> 2 + 2 * a * (- 1 * b) + (- 1 * b) \<up> 2)),
 58.1583 +(([2,1,12], Res), (a + b) * (a + - 1 * b) / ((a + - 1 * b) * (a + - 1 * b))),
 58.1584 +(([2,1,13], Res), (a + b) / (a + - 1 * b)),
 58.1585 +(([2,1], Res), (a + b) / (a + - 1 * b)),
 58.1586 +(([2], Res), (a + b) / (a + - 1 * b)),
 58.1587 +(([], Res), (a + b) / (a + - 1 * b))] 
 58.1588 +*)
 58.1589 +val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
 58.1590 +if length newnds = 13 then () else error "rational.sml: interSteps cancel_p rev_rew_p";
 58.1591 +
 58.1592 +val p = ([2,1,9],Res);
 58.1593 +getTactic 1 p;
 58.1594 +val (_, tac, _) = ME_Misc.pt_extract (pt, p);
 58.1595 +case tac of SOME (Rewrite ("sym_distrib_left", _)) => ()
 58.1596 +| _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
 58.1597 +  \\----------------------------------TOODOO (*Rfuns revsets \<longrightarrow> broken*)*)
 58.1598 +
 58.1599 +
 58.1600 +"-------- investigate rulesets for cancel_p ----------------------------------";
 58.1601 +"-------- investigate rulesets for cancel_p ----------------------------------";
 58.1602 +"-------- investigate rulesets for cancel_p ----------------------------------";
 58.1603 +val thy = @{theory "Rational"};
 58.1604 +val t = TermC.str2term "(a \<up> 2 + - 1*b \<up> 2) / (a \<up> 2 + - 2*a*b + b \<up> 2)";
 58.1605 +val tt = TermC.str2term "(1 * a + 1 * b) * (1 * a + - 1 * b)"(*numerator only*);
 58.1606 +
 58.1607 +"----- with rewrite_set_";
 58.1608 +val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
 58.1609 +if UnparseC.term tt'= "a \<up> 2 + - 1 * b \<up> 2" then () else error "rls chancel_p 1";
 58.1610 +val tt = TermC.str2term "((1 * a + - 1 * b) * (1 * a + - 1 * b))"(*denominator only*);
 58.1611 +val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
 58.1612 +if UnparseC.term tt' = "a \<up> 2 + - 2 * a * b + b \<up> 2" then () else error "rls chancel_p 2";
 58.1613 +
 58.1614 +"----- with Derive.do_one; WN1130912 not investigated further, will be discontinued";
 58.1615 +val SOME (tt, _) = factout_p_ thy t; 
 58.1616 +if UnparseC.term tt = "(a + b) * (a + - 1 * b) / ((a + - 1 * b) * (a + - 1 * b))"
 58.1617 +then () else error "rls chancel_p 3";
 58.1618 +
 58.1619 +"--- with simpler ruleset";
 58.1620 +val {rules, rew_ord= (_, ro), ...} = Rule_Set.rep (assoc_rls "rev_rew_p");
 58.1621 +val der = Derive.do_one thy Atools_erls rules ro NONE tt;
 58.1622 +if length der = 12 then () else error "WN1130912 rls chancel_p 4";
 58.1623 +(*default_print_depth 99;*) writeln (Derive.deriv2str der); (*default_print_depth 3;*)
 58.1624 +
 58.1625 +(*default_print_depth 99;*) map (UnparseC.term o #1) der; (*default_print_depth 3;*)
 58.1626 +"...,(- 1 * b \<up> 2 + a \<up> 2) / (- 2 * (a * b) + a \<up> 2 + (- 1 * b) \<up> 2) ]";
 58.1627 +(*default_print_depth 99;*) map (Rule.to_string o #2) der; (*default_print_depth 3;*)
 58.1628 +(*default_print_depth 99;*) map (UnparseC.term o #1 o #3) der; (*default_print_depth 3;*)
 58.1629 +
 58.1630 +val der = Derive.do_one thy Atools_erls rules ro NONE 
 58.1631 +	(TermC.str2term "(1 * a + 1 * b) * (1 * a + - 1 * b)");
 58.1632 +(*default_print_depth 99;*) writeln (Derive.deriv2str der); (*default_print_depth 3;*)
 58.1633 +
 58.1634 +val {rules, rew_ord=(_,ro),...} = Rule_Set.rep (assoc_rls "rev_rew_p");
 58.1635 +val der = Derive.do_one thy Atools_erls rules ro NONE 
 58.1636 +	(TermC.str2term "(1 * a + - 1 * b) * (1 * a + - 1 * b)");
 58.1637 +(*default_print_depth 99;*) writeln (Derive.deriv2str der); (*default_print_depth 3;*)
 58.1638 +(*default_print_depth 99;*) map (UnparseC.term o #1) der; (*default_print_depth 3;*)
 58.1639 +(*WN060829 ...postponed*)
 58.1640 +
 58.1641 +
 58.1642 +"-------- fun eval_get_denominator -------------------------------------------";
 58.1643 +"-------- fun eval_get_denominator -------------------------------------------";
 58.1644 +"-------- fun eval_get_denominator -------------------------------------------";
 58.1645 +val thy = @{theory Isac_Knowledge};
 58.1646 +val t = Thm.term_of (the (TermC.parse thy "get_denominator ((a +x)/b)"));
 58.1647 +val SOME (_, t') = eval_get_denominator "" 0 t thy;
 58.1648 +if UnparseC.term t' = "get_denominator ((a + x) / b) = b"
 58.1649 +then () else error "get_denominator ((a + x) / b) = b"
 58.1650 +
 58.1651 +
 58.1652 +"-------- several errpats in complicated term --------------------------------";
 58.1653 +"-------- several errpats in complicated term --------------------------------";
 58.1654 +"-------- several errpats in complicated term --------------------------------";
 58.1655 +(*WN12xxxx TODO: instead of Gabriella's example here (27.Jul.12) find a simpler one
 58.1656 +  WN130912: kept this test, although not clear what for*)
 58.1657 +reset_states ();
 58.1658 +CalcTree [(["Term ((5*b + 25)/(a^2 - b^2) * (a - b)/(5*b))", "normalform N"], 
 58.1659 +  ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
 58.1660 +Iterator 1;
 58.1661 +moveActiveRoot 1;
 58.1662 +autoCalculate 1 CompleteCalc;
 58.1663 +val ((pt, p), _) = get_calc 1;
 58.1664 +(*Test_Tool.show_pt pt;
 58.1665 +[
 58.1666 +(([], Frm), Simplify ((5 * b + 25) / (a \<up> 2 - b \<up> 2) * (a - b) / (5 * b))),
 58.1667 +(([1], Frm), (5 * b + 25) / (a \<up> 2 - b \<up> 2) * (a - b) / (5 * b)),
 58.1668 +(([1], Res), (5 * b + 25) / (a \<up> 2 + - 1 * b \<up> 2) * (a + - 1 * b) / (5 * b)),
 58.1669 +(([2], Res), (5 * b + 25) * (a + - 1 * b) / (a \<up> 2 + - 1 * b \<up> 2) / (5 * b)),
 58.1670 +(([3], Res), (25 * a + - 25 * b + 5 * (a * b) + -5 * b \<up> 2) / (a \<up> 2 + - 1 * b \<up> 2) /
 58.1671 +(5 * b)),
 58.1672 +(([4], Res), (25 + 5 * b) / (a + b) / (5 * b)),
 58.1673 +(([5], Res), (25 + 5 * b) / ((a + b) * (5 * b))),
 58.1674 +(([6], Res), (25 + 5 * b) / (5 * (a * b) + 5 * b \<up> 2)),
 58.1675 +(([7], Res), (5 + b) / (a * b + b \<up> 2)),
 58.1676 +(([], Res), (5 + b) / (a * b + b \<up> 2))] *)
 58.1677 +
 58.1678 +
 58.1679 +"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
 58.1680 +"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
 58.1681 +"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
 58.1682 +(*------- Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
 58.1683 +val t = TermC.str2term 
 58.1684 +  ("((12*x*y / (9*x \<up> 2 - y \<up> 2))  /  (1 / (3*x - y) \<up> 2 - 1 / (3*x + y) \<up> 2))  *  " ^
 58.1685 +	"((1/(x - 5*y) \<up> 2  -  1/(x + 5*y) \<up> 2)  /  (20*x*y / (x \<up> 2 - 25*y \<up> 2)))");
 58.1686 +
 58.1687 +(*1st factor separately simplified *)
 58.1688 +val t = TermC.str2term "((12*x*y / (9*x \<up> 2 - y \<up> 2))  /  (1 / (3*x - y) \<up> 2 - 1 / (3*x + y) \<up> 2))";
 58.1689 +val SOME (t', _) = rewrite_set_ thy false norm_Rational t; 
 58.1690 +if UnparseC.term t' = "(- 9 * x \<up> 2 + y \<up> 2) / - 1" then () else error "Nr. 480b lhs changed";
 58.1691 +(*2nd factor separately simplified *)
 58.1692 +val t = TermC.str2term "((1/(x - 5*y) \<up> 2  -  1/(x + 5*y) \<up> 2)  /  (20*x*y / (x \<up> 2 - 25*y \<up> 2)))";
 58.1693 +val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
 58.1694 +if UnparseC.term t' = "- 1 / (- 1 * x \<up> 2 + 25 * y \<up> 2)" then () else error "Nr. 480b rhs changed";
 58.1695 +
 58.1696 +"-------- Schalk I, p.70 Nr. 477a: terms are exploding ?!?";
 58.1697 +val t = TermC.str2term ("b*y/(b - 2*y)/((b \<up> 2 - y \<up> 2)/(b+2*y))  /" ^
 58.1698 +		 "(b \<up> 2*y + b*y \<up> 2) * (a+x) \<up> 2  /  ((b \<up> 2 - 4*y \<up> 2) * (a+2*x) \<up> 2)");
 58.1699 +(*val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
 58.1700 +:
 58.1701 +###  rls: cancel_p on: (a \<up> 2 * (b * y) + 2 * (a * (b * (x * y))) + b * (x \<up> 2 * y)) /
 58.1702 +(b + - 2 * y) /
 58.1703 +((b \<up> 2 + - 1 * y \<up> 2) / (b + 2 * y)) /
 58.1704 +(b \<up> 2 * y + b * y \<up> 2) /
 58.1705 +(a \<up> 2 * b \<up> 2 + -4 * (a \<up> 2 * y \<up> 2) + 4 * (a * (b \<up> 2 * x)) +
 58.1706 + - 16 * (a * (x * y \<up> 2)) +
 58.1707 + 4 * (b \<up> 2 * x \<up> 2) +
 58.1708 + - 16 * (x \<up> 2 * y \<up> 2)) 
 58.1709 +exception Div raised
 58.1710 +
 58.1711 +BUT
 58.1712 +val t = TermC.str2term 
 58.1713 +  ("(a \<up> 2 * (b * y) + 2 * (a * (b * (x * y))) + b * (x \<up> 2 * y)) /" ^
 58.1714 +  "(b + - 2 * y) /" ^
 58.1715 +  "((b \<up> 2 + - 1 * y \<up> 2) / (b + 2 * y)) /" ^
 58.1716 +  "(b \<up> 2 * y + b * y \<up> 2) /" ^
 58.1717 +  "(a \<up> 2 * b \<up> 2 + -4 * (a \<up> 2 * y \<up> 2) + 4 * (a * (b \<up> 2 * x)) +" ^
 58.1718 +  "- 16 * (a * (x * y \<up> 2)) +" ^
 58.1719 +  "4 * (b \<up> 2 * x \<up> 2) +" ^
 58.1720 +  "- 16 * (x \<up> 2 * y \<up> 2))");
 58.1721 +NONE = cancel_p_ thy t;
 58.1722 +*)
 58.1723 +
 58.1724 +(*------- Schalk I, p.70 Nr. 476b in 2003 this worked using 10 sec. *)
 58.1725 +val t = TermC.str2term 
 58.1726 +  ("((a \<up> 2 - b \<up> 2)/(2*a*b) + 2*a*b/(a \<up> 2 - b \<up> 2))  /  ((a \<up> 2 + b \<up> 2)/(2*a*b) + 1)    / " ^
 58.1727 +   "((a \<up> 2 + b \<up> 2) \<up> 2  /  (a + b) \<up> 2)");
 58.1728 +(* Rewrite.trace_on := true; (*true false*)
 58.1729 +rewrite_set_ thy false norm_Rational t;
 58.1730 +:
 58.1731 +####  rls: cancel_p on: (2 * (a \<up> 7 * b) + 4 * (a \<up> 6 * b \<up> 2) + 6 * (a \<up> 5 * b \<up> 3) +
 58.1732 + 8 * (a \<up> 4 * b \<up> 4) +
 58.1733 + 6 * (a \<up> 3 * b \<up> 5) +
 58.1734 + 4 * (a \<up> 2 * b \<up> 6) +
 58.1735 + 2 * (a * b \<up> 7)) /
 58.1736 +(2 * (a \<up> 9 * b) + 4 * (a \<up> 8 * b \<up> 2) +
 58.1737 + 2 * (2 * (a \<up> 7 * b \<up> 3)) +
 58.1738 + 4 * (a \<up> 6 * b \<up> 4) +
 58.1739 + -4 * (a \<up> 4 * b \<up> 6) +
 58.1740 + -4 * (a \<up> 3 * b \<up> 7) +
 58.1741 + -4 * (a \<up> 2 * b \<up> 8) +
 58.1742 + - 2 * (a * b \<up> 9))
 58.1743 +
 58.1744 +if UnparseC.term t = "1 / (a \<up> 2 + - 1 * b \<up> 2)" then ()
 58.1745 +else error "rational.sml: diff.behav. in norm_Rational_mg 49";
 58.1746 +*)
 58.1747 +
 58.1748 +"-------- Schalk I, p.70 Nr. 480a: terms are exploding ?!?";
 58.1749 +val t = TermC.str2term ("(1/x + 1/y + 1/z)  /  (1/x - 1/y - 1/z)  /  " ^
 58.1750 +  "(2*x \<up> 2 / (x \<up> 2 - z \<up> 2) / (x / (x + z)  +  x / (x - z)))");
 58.1751 +(* Rewrite.trace_on := true; (*true false*)
 58.1752 +rewrite_set_ thy false norm_Rational t;
 58.1753 +:
 58.1754 +####  rls: cancel_p on: (2 * (x \<up> 6 * (y \<up> 2 * z)) + 2 * (x \<up> 6 * (y * z \<up> 2)) +
 58.1755 + 2 * (x \<up> 5 * (y \<up> 2 * z \<up> 2)) +
 58.1756 + - 2 * (x \<up> 4 * (y \<up> 2 * z \<up> 3)) +
 58.1757 + - 2 * (x \<up> 4 * (y * z \<up> 4)) +
 58.1758 + - 2 * (x \<up> 3 * (y \<up> 2 * z \<up> 4))) /
 58.1759 +(- 2 * (x \<up> 6 * (y \<up> 2 * z)) + - 2 * (x \<up> 6 * (y * z \<up> 2)) +
 58.1760 + 2 * (x \<up> 5 * (y \<up> 2 * z \<up> 2)) +
 58.1761 + 2 * (x \<up> 4 * (y \<up> 2 * z \<up> 3)) +
 58.1762 + 2 * (x \<up> 4 * (y * z \<up> 4)) +
 58.1763 + - 2 * (x \<up> 3 * (y \<up> 2 * z \<up> 4)))
 58.1764 +*)
 58.1765 +
 58.1766 +"-------- Schalk I, p.60 Nr. 215d: terms are exploding, internal loop does not terminate";
 58.1767 +val t = TermC.str2term "(a-b) \<up> 3 * (x+y) \<up> 4 / ((x+y) \<up> 2 * (a-b) \<up> 5)";
 58.1768 +(* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:
 58.1769 +
 58.1770 +val t = TermC.str2term "(a-b) \<up> 3 * (x+y) \<up> 4";
 58.1771 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1772 +UnparseC.term t;
 58.1773 +"a \<up> 3 * x \<up> 4 + 4 * a \<up> 3 * x \<up> 3 * y +6 * a \<up> 3 * x \<up> 2 * y \<up> 2 +4 * a \<up> 3 * x * y \<up> 3 +a \<up> 3 * y \<up> 4 +-3 * a \<up> 2 * b * x \<up> 4 +- 12 * a \<up> 2 * b * x \<up> 3 * y +- 18 * a \<up> 2 * b * x \<up> 2 * y \<up> 2 +- 12 * a \<up> 2 * b * x * y \<up> 3 +-3 * a \<up> 2 * b * y \<up> 4 +3 * a * b \<up> 2 * x \<up> 4 +12 * a * b \<up> 2 * x \<up> 3 * y +18 * a * b \<up> 2 * x \<up> 2 * y \<up> 2 +12 * a * b \<up> 2 * x * y \<up> 3 +3 * a * b \<up> 2 * y \<up> 4 +- 1 * b \<up> 3 * x \<up> 4 +-4 * b \<up> 3 * x \<up> 3 * y +-6 * b \<up> 3 * x \<up> 2 * y \<up> 2 +-4 * b \<up> 3 * x * y \<up> 3 +- 1 * b \<up> 3 * y \<up> 4";
 58.1774 +val t = TermC.str2term "((x+y) \<up> 2 * (a-b) \<up> 5)";
 58.1775 +val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1776 +UnparseC.term t;
 58.1777 +"a \<up> 5 * x \<up> 2 + 2 * a \<up> 5 * x * y + a \<up> 5 * y \<up> 2 +-5 * a \<up> 4 * b * x \<up> 2 +- 10 * a \<up> 4 * b * x * y +-5 * a \<up> 4 * b * y \<up> 2 +10 * a \<up> 3 * b \<up> 2 * x \<up> 2 +20 * a \<up> 3 * b \<up> 2 * x * y +10 * a \<up> 3 * b \<up> 2 * y \<up> 2 +- 10 * a \<up> 2 * b \<up> 3 * x \<up> 2 +- 20 * a \<up> 2 * b \<up> 3 * x * y +- 10 * a \<up> 2 * b \<up> 3 * y \<up> 2 +5 * a * b \<up> 4 * x \<up> 2 +10 * a * b \<up> 4 * x * y +5 * a * b \<up> 4 * y \<up> 2 +- 1 * b \<up> 5 * x \<up> 2 +- 2 * b \<up> 5 * x * y +- 1 * b \<up> 5 * y \<up> 2";
 58.1778 +
 58.1779 +anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
 58.1780 +
 58.1781 +"-------- Schalk I, p.70 Nr. 480b: terms are exploding, Rewrite.trace_on stops at";
 58.1782 +val t = TermC.str2term ("((12*x*y/(9*x \<up> 2 - y \<up> 2))/" ^
 58.1783 +		 "(1/(3*x - y) \<up> 2 - 1/(3*x + y) \<up> 2)) *" ^
 58.1784 +		 "(1/(x - 5*y) \<up> 2 - 1/(x + 5*y) \<up> 2)/" ^
 58.1785 +		 "(20*x*y/(x \<up> 2 - 25*y \<up> 2))");
 58.1786 +(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 58.1787 +:
 58.1788 +####  rls: cancel_p on: (19440 * (x \<up> 8 * y \<up> 2) + -490320 * (x \<up> 6 * y \<up> 4) +
 58.1789 + 108240 * (x \<up> 4 * y \<up> 6) +
 58.1790 + -6000 * (x \<up> 2 * y \<up> 8)) /
 58.1791 +(2160 * (x \<up> 8 * y \<up> 2) + - 108240 * (x \<up> 6 * y \<up> 4) +
 58.1792 + 1362000 * (x \<up> 4 * y \<up> 6) +
 58.1793 + - 150000 * (x \<up> 2 * y \<up> 8))
 58.1794 +*)
 58.1795 +
    59.1 --- a/test/Tools/isac/Knowledge/rational-old.sml	Mon Jun 21 22:08:01 2021 +0200
    59.2 +++ b/test/Tools/isac/Knowledge/rational-old.sml	Sun Jul 18 18:15:27 2021 +0200
    59.3 @@ -6,7 +6,7 @@
    59.4     use"rational.sml";
    59.5  *)
    59.6  
    59.7 -(*--------------------------------15.10.02---
    59.8 +(*-------------------------------- 15.10.02---
    59.9  (* tests*)
   59.10  print("\n\n*********************   tests    *************************\n\n");
   59.11  print("\n\n***** divide tests *****\n");
   59.12 @@ -224,8 +224,8 @@
   59.13  
   59.14  
   59.15  (*val mul1=(Thm.term_of o the o (TermC.parse thy)) "(5*a*b*c+4*a*b+2*a*c)"; 
   59.16 -val mul2=(the (term2poly((Thm.term_of o the o (TermC.parse thy)) "13*a \<up> 2*b*c+7*a*b-19*a*b*c \<up> 2")));
   59.17 -val mul3=(the (term2poly((Thm.term_of o the o (TermC.parse thy)) "6*a*b \<up> 2-13*a \<up> 2*b \<up> 2*c \<up> 2+21*a \<up> 2*b*c")));
   59.18 +val mul2=(the (term2poly((Thm.term_of o the o (TermC.parse thy)) "13*a \<up> 2*b*c+7*a*b- 19*a*b*c \<up> 2")));
   59.19 +val mul3=(the (term2poly((Thm.term_of o the o (TermC.parse thy)) "6*a*b \<up> 2- 13*a \<up> 2*b \<up> 2*c \<up> 2+21*a \<up> 2*b*c")));
   59.20  val t1=mv_mul(mul1,mul2,LEX_);
   59.21  val t2=mv_mul(mul3,mul2,LEX_);
   59.22  val div3=step_cancel t1 t2;
   59.23 @@ -238,15 +238,15 @@
   59.24  val thy = Rational.thy;
   59.25  val rls = Prls {func=cancel};
   59.26  val t = (Thm.term_of o the o (TermC.parse thy)) 
   59.27 -	    "(1 + 1 * a \<up> 1)///(-2 + 2 * a \<up> 2)";
   59.28 +	    "(1 + 1 * a \<up> 1)///(- 2 + 2 * a \<up> 2)";
   59.29  val (t,asm) = the (rewrite_set_ thy eval_rls false rls t);
   59.30  
   59.31  
   59.32  val thy' = "Rational";
   59.33  val rls' = "cancel";
   59.34 -val t' = "(1 + 1 * a \<up> 1)///(-2 + 2 * a \<up> 2)";
   59.35 +val t' = "(1 + 1 * a \<up> 1)///(- 2 + 2 * a \<up> 2)";
   59.36  val (t',asm') = the (rewrite_set thy' "eval_rls" false rls' t');
   59.37 -(*if t' = "1 /// (-2 + 2 * a)" then ()
   59.38 +(*if t' = "1 /// (- 2 + 2 * a)" then ()
   59.39  else error "tests/rationals.sml(1): new behaviour";*)
   59.40  
   59.41  
   59.42 @@ -263,7 +263,7 @@
   59.43  (*
   59.44  val term2 = (Thm.term_of o the o (TermC.parse thy))  "(a \<up> 2 * b  + 2 * a * b +  b ) /// ( a \<up> 2   - 1 )";
   59.45  val div2  = direct_cancel term2;
   59.46 -val t = (Thm.term_of o the o (TermC.parse thy)) "(1 + 1 * a \<up> 1)///(-2 + 2 * a \<up> 2) = 0";*)
   59.47 +val t = (Thm.term_of o the o (TermC.parse thy)) "(1 + 1 * a \<up> 1)///(- 2 + 2 * a \<up> 2) = 0";*)
   59.48  
   59.49  
   59.50  
   59.51 @@ -309,17 +309,17 @@
   59.52  print("a)\n");
   59.53  val e188a'="(8 * x + -8) / (9 * x + -9 )";
   59.54  val e188a = the (rewrite_set thy' "rational_erls" false rls' e188a');
   59.55 -val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "(8*((-1) + x))/(9*((-1) + x))";
   59.56 +val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "(8*((- 1) + x))/(9*((- 1) + x))";
   59.57  if t="((-8) + 8 * x) / ((-9) + 9 * x)"then()
   59.58  else error "rationals.sml: e188a new behaviour";
   59.59  print("b)\n");
   59.60 -val e188b'="(5 * x + -15) / (6 * x + -18 )";
   59.61 +val e188b'="(5 * x + - 15) / (6 * x + - 18 )";
   59.62  val e188b = the (rewrite_set thy' "rational_erls" false rls' e188b');
   59.63  print("c)\n");
   59.64 -val e188c'="( a + -1 * b ) / ( b + -1 * a )";
   59.65 +val e188c'="( a + - 1 * b ) / ( b + - 1 * a )";
   59.66  val e188c = the (rewrite_set thy' "rational_erls" false rls' e188c');
   59.67 -val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
   59.68 -if t="(a + -1 * b) / (b + -1 * a)"then()
   59.69 +val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((- 1)*(b + (- 1) * a))/(1*(b + (- 1) * a))";
   59.70 +if t="(a + - 1 * b) / (b + - 1 * a)"then()
   59.71  else error "rationals.sml: e188c new behaviour";
   59.72  
   59.73  print("\n\nexample 190:\n");
   59.74 @@ -333,24 +333,24 @@
   59.75  
   59.76  print("\n\nexample 191:\n");
   59.77  print("a)\n");
   59.78 -val e191a'="( x \<up> 2 + -1 * y \<up> 2 ) / ( x + y )";
   59.79 +val e191a'="( x \<up> 2 + - 1 * y \<up> 2 ) / ( x + y )";
   59.80  val e191a = the (rewrite_set thy' "rational_erls" false rls' e191a'); 
   59.81 -val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
   59.82 -if t="(x \<up> 2 + -1 * y \<up> 2) / (x + y)"then()
   59.83 +val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((x + (- 1) * y)*(x + y))/((1)*(x + y))";
   59.84 +if t="(x \<up> 2 + - 1 * y \<up> 2) / (x + y)"then()
   59.85  else error "rationals.sml: e191a new behaviour";
   59.86  print("c)\n");
   59.87 -val e191c'="( 9 * x \<up> 2 + -30 * x + 25 ) / ( 9 * x \<up> 2 + -25 )";
   59.88 +val e191c'="( 9 * x \<up> 2 + -30 * x + 25 ) / ( 9 * x \<up> 2 + - 25 )";
   59.89  val e191c = the (rewrite_set thy' "rational_erls" false rls' e191c');
   59.90  val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
   59.91 -if t="(25 + ((-30) * x + 9 * x \<up> 2)) / ((-25) + 9 * x \<up> 2)"then()
   59.92 +if t="(25 + ((-30) * x + 9 * x \<up> 2)) / ((- 25) + 9 * x \<up> 2)"then()
   59.93  else error "rationals.sml: 'e191c' new behaviour";
   59.94  
   59.95  print("\n\nexample 192:\n");
   59.96  print("b)\n");
   59.97 -val e192b'="( 7 * x \<up> 3 + -1 * x \<up> 2 * y ) / ( 7 * x * y \<up> 2 + -1 *  y \<up> 3 )";
   59.98 +val e192b'="( 7 * x \<up> 3 + - 1 * x \<up> 2 * y ) / ( 7 * x * y \<up> 2 + - 1 *  y \<up> 3 )";
   59.99  val e192b = the (rewrite_set thy' "rational_erls" false rls' e192b');
  59.100 -val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((x \<up> 2)*(7 * x + (-1) * y))/((y \<up> 2)*(7 * x + (-1) * y))";
  59.101 -if t="(7 * x \<up> 3 + -1 * (y * x \<up> 2)) / (-1 * y \<up> 3 + 7 * (x * y \<up> 2))"then()
  59.102 +val SOME (t,_) = rewrite_set thy' "rational_erls" false mp "((x \<up> 2)*(7 * x + (- 1) * y))/((y \<up> 2)*(7 * x + (- 1) * y))";
  59.103 +if t="(7 * x \<up> 3 + - 1 * (y * x \<up> 2)) / (- 1 * y \<up> 3 + 7 * (x * y \<up> 2))"then()
  59.104  (*TERMORDER                ~~~~~*)
  59.105  else error "rationals.sml: 'e192b' new behaviour";
  59.106  
  59.107 @@ -362,9 +362,9 @@
  59.108  val e193b'="( x \<up> 2 + -8 * x + 16 ) / ( 2 * x \<up> 2 + -32 )";
  59.109  val e193b = the (rewrite_set thy' "rational_erls" false rls' e193b');
  59.110  print("c)\n");
  59.111 -val e193c'="( 2 * x + -50 * x \<up> 3 ) / ( 25 * x \<up> 2 + -10 * x + 1 )";
  59.112 +val e193c'="( 2 * x + -50 * x \<up> 3 ) / ( 25 * x \<up> 2 + - 10 * x + 1 )";
  59.113  val SOME(t,_) = rewrite_set thy' "rational_erls" false rls' e193c';
  59.114 ---------------------------------15.10.02---*)
  59.115 +-------------------------------- 15.10.02---*)
  59.116  
  59.117  
  59.118  (*---------- WN: 10.9.02:
  59.119 @@ -375,7 +375,7 @@
  59.120  val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
  59.121  val e204a = the (rewrite_set thy' "rational_erls" false rls' e204a');
  59.122  print("b)\n");
  59.123 -val e204b'="5 / x + -3 / x + -1 / x";
  59.124 +val e204b'="5 / x + -3 / x + - 1 / x";
  59.125  val e204b = the (rewrite_set thy' "rational_erls" false rls' e204b');
  59.126  
  59.127  print("\n\nexample 205:\n");
  59.128 @@ -383,44 +383,44 @@
  59.129  val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
  59.130  val e205a = the (rewrite_set thy' "rational_erls" false rls' e205a');
  59.131  print("b)\n");
  59.132 -val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
  59.133 +val e205b'="((5 * x + 2) / 3) + ((- 2 * x + 1) / 3)";
  59.134  val e205b = the (rewrite_set thy' "rational_erls" false rls' e205b');
  59.135  
  59.136  print("\n\nexample 206:\n");
  59.137  print("a)\n");
  59.138 -val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
  59.139 +val e206a'="((5 * x + 4) / (2 * x + - 1)) + ((9 * x + 5) / (2 * x + - 1))";
  59.140  val e206a = the (rewrite_set thy' "rational_erls" false rls' e206a'); 
  59.141  print("b)\n");
  59.142 -val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
  59.143 +val e206b'="((17 * x + - 23) / (5 * x + 4)) + ((- 25 + - 17 * x) / (5 * x + 4))";
  59.144  val e206b = the (rewrite_set thy' "rational_erls" false rls' e206b');
  59.145  
  59.146  print("\n\nexample 207:\n");
  59.147 -val e207'="((3 * x * y + 3 * y) / (x * y)) + ((5 * x * y + 7 * y) / (x * y)) + ((9 * x * y + -2 * y) / (x * y)) + ((x * y + 4 * y) / (x * y)) ";
  59.148 +val e207'="((3 * x * y + 3 * y) / (x * y)) + ((5 * x * y + 7 * y) / (x * y)) + ((9 * x * y + - 2 * y) / (x * y)) + ((x * y + 4 * y) / (x * y)) ";
  59.149  val e207 = the (rewrite_set thy' "rational_erls" false rls' e207'); 
  59.150  
  59.151  print("\n\nexample 208:\n");
  59.152 -val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
  59.153 +val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + - 1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((- 1 * x + -3) / (x + 2)) ";
  59.154  val e208 = the (rewrite_set thy' "rational_erls" false rls' e208'); 
  59.155  
  59.156  print("\n\nexample 209:\n");
  59.157 -val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
  59.158 +val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((- 1 * x + 2 * y + z) / (4)) ";
  59.159  val e209 = the (rewrite_set thy' "rational_erls" false rls' e209'); 
  59.160  
  59.161  print("\n\nexample 210:\n");
  59.162 -val e210'="((2 * x + 3 +  -1 * x \<up> 2) / (5 * x)) + ((5 * x \<up> 2 + -2 * x + 1) / (5 * x)) + ((-3 * x \<up> 2 + -2 * x + 1) / (5 * x)) + ((-1 * x \<up> 2 + -3 * x + -5) / (5 * x)) ";
  59.163 +val e210'="((2 * x + 3 +  - 1 * x \<up> 2) / (5 * x)) + ((5 * x \<up> 2 + - 2 * x + 1) / (5 * x)) + ((-3 * x \<up> 2 + - 2 * x + 1) / (5 * x)) + ((- 1 * x \<up> 2 + -3 * x + -5) / (5 * x)) ";
  59.164  val e210 = the (rewrite_set thy' "rational_erls" false rls' e210'); 
  59.165  
  59.166  print("\n\nexample 211:\n");
  59.167  print("a)\n"); 
  59.168 -val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))"; 
  59.169 +val e211a'="((b) / (a + - 1 * b)) + ((- 1 * a) / (a + - 1 * b))"; 
  59.170  val e211a = the (rewrite_set thy' "rational_erls" false rls' e211a'); 
  59.171  print("b)\n");
  59.172 -val e211b'="((b) / (b \<up> 2 + -1 * a \<up> 2)) + ((-1 * a) / (b \<up> 2 + -1 * a \<up> 2))";
  59.173 +val e211b'="((b) / (b \<up> 2 + - 1 * a \<up> 2)) + ((- 1 * a) / (b \<up> 2 + - 1 * a \<up> 2))";
  59.174  val e211b = the (rewrite_set thy' "rational_erls" false rls' e211b');
  59.175  
  59.176  print("\n\nexample 212:\n");
  59.177  print("a)\n");
  59.178 -val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
  59.179 +val e212a'="((4) / (x)) + ((-3) / (y)) + - 1";
  59.180  val e212a = the (rewrite_set thy' "rational_erls" false rls' e212a'); 
  59.181  print("b)\n");
  59.182  val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
  59.183 @@ -428,7 +428,7 @@
  59.184  
  59.185  print("\n\nexample 213:\n");
  59.186  print("a)\n"); 
  59.187 -val e213a'="((5 * x) / (3 * y \<up> 2)) + ((19 * z) / (6 * x * y)) +  ((-2 * x) / (3 * y \<up> 2)) + ((7 * y \<up> 2) / (6 * x \<up> 2)) ";
  59.188 +val e213a'="((5 * x) / (3 * y \<up> 2)) + ((19 * z) / (6 * x * y)) +  ((- 2 * x) / (3 * y \<up> 2)) + ((7 * y \<up> 2) / (6 * x \<up> 2)) ";
  59.189  val e213a = the (rewrite_set thy' "rational_erls" false rls' e213a'); 
  59.190  print("b)\n"); 
  59.191  val e213b'="((2 * b) / (3 * a \<up> 2)) + ((3 * c) / (7 * a * b)) +  ((4 * b) / (3 * a \<up> 2)) + ((3 * a) / (7 * b \<up> 2))";
  59.192 @@ -436,26 +436,26 @@
  59.193  
  59.194  print("\n\nexample 214:\n");
  59.195  print("a)\n");
  59.196 -val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
  59.197 +val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + - 2 * z) / (2))";
  59.198  val e214a = the (rewrite_set thy' "rational_erls" false rls' e214a'); 
  59.199  print("b)\n");
  59.200 -val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
  59.201 +val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + - 1 * z) / (12))";
  59.202  val e214b = the (rewrite_set thy' "rational_erls" false rls' e214b');
  59.203  
  59.204  print("\n\nexample 216:\n");
  59.205  print("a)\n"); 
  59.206 -val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b \<up> 2 + -3 * a * c) / (a * b * c))";
  59.207 +val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((- 2 * b \<up> 2 + -3 * a * c) / (a * b * c))";
  59.208  val e216a = the (rewrite_set thy' "rational_erls" false rls' e216a');  
  59.209  print("b)\n");
  59.210 -val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a \<up> 2 + -3 * b * c) / (a * b * c))";
  59.211 +val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((- 2 * a \<up> 2 + -3 * b * c) / (a * b * c))";
  59.212  val e216b = the (rewrite_set thy' "rational_erls" false rls' e216b');
  59.213  
  59.214  print("\n\nexample 217:\n");
  59.215 -val e217'="((z + -1) / (z)) + ((3 * z  \<up> 2 + -6 * z + 5) / (z \<up> 2)) + ((-4 * z \<up> 3 + 7 * z \<up> 2 + -5 * z + 5) / (z \<up> 3))";
  59.216 +val e217'="((z + - 1) / (z)) + ((3 * z  \<up> 2 + -6 * z + 5) / (z \<up> 2)) + ((-4 * z \<up> 3 + 7 * z \<up> 2 + -5 * z + 5) / (z \<up> 3))";
  59.217  val e217 = the (rewrite_set thy' "rational_erls" false rls' e217'); 
  59.218  
  59.219  print("\n\nexample 218:\n");
  59.220 -val e218'="((9 * a \<up> 3 - 5 * a \<up> 2 + 2 * a + 8) / (108 * a \<up> 4)) + ((-5 * a + 3 * a \<up> 2 + 4) / (8 * a \<up> 3)) + ((-261 * a \<up> 3 + 19 * a \<up> 2 + -112 * a + 16) / (216 * a \<up> 4))";
  59.221 +val e218'="((9 * a \<up> 3 - 5 * a \<up> 2 + 2 * a + 8) / (108 * a \<up> 4)) + ((-5 * a + 3 * a \<up> 2 + 4) / (8 * a \<up> 3)) + ((- 261 * a \<up> 3 + 19 * a \<up> 2 + - 112 * a + 16) / (216 * a \<up> 4))";
  59.222  val e218 = the (rewrite_set thy' "rational_erls" false rls' e218'); 
  59.223  
  59.224  print("\n\nexample 219:\n");
  59.225 @@ -463,128 +463,128 @@
  59.226  val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
  59.227  val e219a = the (rewrite_set thy' "rational_erls" false rls' e219a');
  59.228  print("b)\n");
  59.229 -val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
  59.230 +val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((- 2) / (x + 3))";
  59.231  val e219b = the (rewrite_set thy' "rational_erls" false rls' e219b'); 
  59.232  
  59.233  print("\n\nexample 220:\n");
  59.234  print("a)\n");
  59.235 -val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
  59.236 +val e220a'="((17) / (5 * r + - 2)) + ((- 13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
  59.237  val e220a = the (rewrite_set thy' "rational_erls" false rls' e220a');
  59.238  print("b)\n");
  59.239 -val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
  59.240 +val e220b'="((20 * a) / (a + -3)) + ((- 19 * a) / (a + -4)) + ((a) / (a + -5))";
  59.241  val e220b = the (rewrite_set thy' "rational_erls" false rls' e220b'); 
  59.242  
  59.243  print("\n\nexample 221:\n");
  59.244  print("a)\n");
  59.245 -val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
  59.246 +val e221a'="((a + b) / (a + - 1 * b)) + ((a + - 1 * b) / (a + b))";
  59.247  val e221a = the (rewrite_set thy' "rational_erls" false rls' e221a');
  59.248  print("b)\n");
  59.249 -val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
  59.250 +val e221b'="((x + - 1 * y) / (x + y)) + ((x + y) / (x + - 1 * y)) ";
  59.251  val e221b = the (rewrite_set thy' "rational_erls" false rls' e221b');
  59.252  
  59.253  print("\n\nexample 222:\n");
  59.254  print("a)\n");
  59.255 -val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x \<up> 2))";
  59.256 +val e222a'="((1 + - 1 * x) / (1 + x)) + ((- 1 + - 1 * x) / (1 + - 1 * x)) + ((4 * x) / (1 + - 1 * x \<up> 2))";
  59.257  val e222a = the (rewrite_set thy' "rational_erls" false rls' e222a');
  59.258  print("b)\n");
  59.259 -val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x \<up> 2))";
  59.260 +val e222b'="((1 + x ) / (1 + - 1 * x)) + ((- 1 + x) / (1 + x)) + ((2 * x) / (1 + - 1 * x \<up> 2))";
  59.261  val e222b = the (rewrite_set thy' "rational_erls" false rls' e222b'); 
  59.262  
  59.263  print("\n\nexample 225:\n");
  59.264  print("a)\n");
  59.265 -val e225a'="((6 * a) / (a \<up> 2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
  59.266 +val e225a'="((6 * a) / (a \<up> 2 + -64)) + ((a + 2) / (2 * a + 16)) + ((- 1) / (2))";
  59.267  val e225a = the (rewrite_set thy' "rational_erls" false rls' e225a');
  59.268  print("b)\n");
  59.269 -val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a \<up> 2 + -36)) + ((-1) / (2))";
  59.270 +val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a \<up> 2 + -36)) + ((- 1) / (2))";
  59.271  val e225b = the (rewrite_set thy' "rational_erls" false rls' e225b'); 
  59.272  
  59.273  print("\n\nexample 226:\n");
  59.274  print("a)\n");
  59.275 -val e226a'="((35 * z) / (49 * z \<up> 2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
  59.276 +val e226a'="((35 * z) / (49 * z \<up> 2 + -4)) + - 1 + ((14 * z + - 1) / (14 * z + 4)) ";
  59.277  val e226a = the (rewrite_set thy' "rational_erls" false rls' e226a');
  59.278  print("b)\n"); 
  59.279 -val e226b'="((45 * a * b) / (25 * a \<up> 2 + -9 * b \<up> 2)) + ((20 * a + 3 * b) / (10 * a + 6 * b))  + -2";
  59.280 +val e226b'="((45 * a * b) / (25 * a \<up> 2 + -9 * b \<up> 2)) + ((20 * a + 3 * b) / (10 * a + 6 * b))  + - 2";
  59.281  val e226b = the (rewrite_set thy' "rational_erls" false rls' e226b');  
  59.282  
  59.283  print("\n\nexample 227:\n");
  59.284  print("a)\n");
  59.285 -val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z \<up> 2 + -49)) + -1 ";
  59.286 +val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z \<up> 2 + -49)) + - 1 ";
  59.287  val e227a = the (rewrite_set thy' "rational_erls" false rls' e227a');
  59.288  print("b)\n");
  59.289 -val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a \<up> 2 + -25 * b \<up> 2)) + -4 ";
  59.290 +val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a \<up> 2 + - 25 * b \<up> 2)) + -4 ";
  59.291  val e227b = the (rewrite_set thy' "rational_erls" false rls' e227b'); 
  59.292  
  59.293  print("\n\nexample 228:\n");
  59.294  print("a)\n");
  59.295 -val e228a'="((7 * a + 11) / (3 * a \<up> 2 + -3)) + ((-2 * a + -1) / (a \<up> 2 + -1 * a)) + ((-1) / (3 * a + 3))";
  59.296 +val e228a'="((7 * a + 11) / (3 * a \<up> 2 + -3)) + ((- 2 * a + - 1) / (a \<up> 2 + - 1 * a)) + ((- 1) / (3 * a + 3))";
  59.297  val e228a = the (rewrite_set thy' "rational_erls" false rls' e228a'); 
  59.298  print("b)\n");
  59.299 -val e228b'="((11 * z + 2 * b) / (4 * b * z + -8 * b \<up> 2)) + ((-8 * z) / (z \<up> 2 + -4 * b \<up> 2)) + ((-9 * z + -2 * b) / (4 * b * z + 8 * b \<up> 2))";
  59.300 +val e228b'="((11 * z + 2 * b) / (4 * b * z + -8 * b \<up> 2)) + ((-8 * z) / (z \<up> 2 + -4 * b \<up> 2)) + ((-9 * z + - 2 * b) / (4 * b * z + 8 * b \<up> 2))";
  59.301  val e228b = the (rewrite_set thy' "rational_erls" false rls' e228b');  
  59.302  
  59.303  
  59.304  print("\n\nexample 229:\n");
  59.305  print("a)\n");
  59.306 -val e229a'="((5 * x \<up> 2 + y) / (x + 2 * y)) + ((-8 * x \<up> 3 + 4 * x \<up> 2 * y + 3 * x * y) / (x \<up> 2 + -4 * y \<up> 2)) + ((3 * x \<up> 2 + -4 * y) / (x + -2 * y))";
  59.307 +val e229a'="((5 * x \<up> 2 + y) / (x + 2 * y)) + ((-8 * x \<up> 3 + 4 * x \<up> 2 * y + 3 * x * y) / (x \<up> 2 + -4 * y \<up> 2)) + ((3 * x \<up> 2 + -4 * y) / (x + - 2 * y))";
  59.308  val e229a = the (rewrite_set thy' "rational_erls" false rls' e229a'); 
  59.309  print("b)\n");
  59.310 -val e229b'="((7 * x \<up> 2 + y) / (x + 3 * y)) + ((-24 * x \<up> 2 * y + 5 * x * y + 21 * y \<up> 2) / (x \<up> 2 + -9 * y \<up> 2)) + ((4 * x \<up> 2 + -6 * y) / (x + -3 * y))"; 
  59.311 +val e229b'="((7 * x \<up> 2 + y) / (x + 3 * y)) + ((- 24 * x \<up> 2 * y + 5 * x * y + 21 * y \<up> 2) / (x \<up> 2 + -9 * y \<up> 2)) + ((4 * x \<up> 2 + -6 * y) / (x + -3 * y))"; 
  59.312  val e229b = the (rewrite_set thy' "rational_erls" false rls' e229b'); 
  59.313   
  59.314  print("\n\nexample 230:\n");
  59.315  print("a)\n"); 
  59.316 -val e230a'="((5 * x \<up> 2 + y) / (2 * x + y)) + ((-16 * x \<up> 3 + 2 * x \<up> 2 * y + 6 * x * y) / (4 * x \<up> 2 + -1 * y \<up> 2)) + ((3 * x \<up> 2 + -4 * y) / (2 * x + -1 * y))";
  59.317 +val e230a'="((5 * x \<up> 2 + y) / (2 * x + y)) + ((- 16 * x \<up> 3 + 2 * x \<up> 2 * y + 6 * x * y) / (4 * x \<up> 2 + - 1 * y \<up> 2)) + ((3 * x \<up> 2 + -4 * y) / (2 * x + - 1 * y))";
  59.318  val e230a = the (rewrite_set thy' "rational_erls" false rls' e230a');
  59.319  print("b)\n");
  59.320 -val e230b'="((7 * x \<up> 2 + y) / (3 * x + y)) + ((-3 * x \<up> 3  + 15 * x * y + -7 * x \<up> 2 * y + 7 * y \<up> 2) / (9 * x \<up> 2 + -1 * y \<up> 2)) + ((4 * x \<up> 2 + -6 * y) / (3 * x + -1 * y))";
  59.321 +val e230b'="((7 * x \<up> 2 + y) / (3 * x + y)) + ((-3 * x \<up> 3  + 15 * x * y + -7 * x \<up> 2 * y + 7 * y \<up> 2) / (9 * x \<up> 2 + - 1 * y \<up> 2)) + ((4 * x \<up> 2 + -6 * y) / (3 * x + - 1 * y))";
  59.322  val e230b = the (rewrite_set thy' "rational_erls" false rls' e230b');
  59.323  
  59.324  print("\n\nexample 231:\n");
  59.325  print("a)\n");
  59.326 -val e231a'="((2 * x + 5 * y) / (x)) + ((2 * x \<up> 3 + -5 * y \<up> 3 + 3 * x * y \<up> 2) / (x \<up> 3 + -2 * x \<up> 2 * y + x * y \<up> 2)) + ((-3 * x + -6 * y) / (x + -1 * y))";
  59.327 +val e231a'="((2 * x + 5 * y) / (x)) + ((2 * x \<up> 3 + -5 * y \<up> 3 + 3 * x * y \<up> 2) / (x \<up> 3 + - 2 * x \<up> 2 * y + x * y \<up> 2)) + ((-3 * x + -6 * y) / (x + - 1 * y))";
  59.328  val e231a = the (rewrite_set thy' "rational_erls" false rls' e231a'); 
  59.329  print("b)\n");
  59.330 -val e231b'="((6 * x + 2 * y) / (x)) + ((6 * x \<up> 2 * y + -4 * x * y \<up> 2 + -2 * y \<up> 3) / (x \<up> 3 + -2 * x \<up> 2 * y + x * y \<up> 2)) + ((-5 * x + -3 * y) / (x + -1 * y))";
  59.331 +val e231b'="((6 * x + 2 * y) / (x)) + ((6 * x \<up> 2 * y + -4 * x * y \<up> 2 + - 2 * y \<up> 3) / (x \<up> 3 + - 2 * x \<up> 2 * y + x * y \<up> 2)) + ((-5 * x + -3 * y) / (x + - 1 * y))";
  59.332  val e231b = the (rewrite_set thy' "rational_erls" false rls' e231b');
  59.333  
  59.334  print("\n\nexample 232:\n");
  59.335  print("a)\n");
  59.336 -val e232a'="((2 * x + 3 * y) / (x)) + ((4 * x \<up> 3 + -1 * x * y \<up> 2 + -3 * y \<up> 3) / (x \<up> 3 + -2 * x \<up> 2 * y + x * y \<up> 2)) + ((-5 * x + -6 * y) / (x + -1 * y))";
  59.337 +val e232a'="((2 * x + 3 * y) / (x)) + ((4 * x \<up> 3 + - 1 * x * y \<up> 2 + -3 * y \<up> 3) / (x \<up> 3 + - 2 * x \<up> 2 * y + x * y \<up> 2)) + ((-5 * x + -6 * y) / (x + - 1 * y))";
  59.338  val e232a = the (rewrite_set thy' "rational_erls" false rls' e232a'); 
  59.339  print("b)\n");
  59.340 -val e232b'="((5 * x + 2 * y) / (x)) + ((2 * x \<up> 3 + -3 * x * y \<up> 2 + 3 * x \<up> 2 * y + -2 * y \<up> 3) / (x \<up> 3 + -2 * x \<up> 2 * y + x * y \<up> 2)) + ((-6 * x + -3 * y) / (x + -1 * y))";
  59.341 +val e232b'="((5 * x + 2 * y) / (x)) + ((2 * x \<up> 3 + -3 * x * y \<up> 2 + 3 * x \<up> 2 * y + - 2 * y \<up> 3) / (x \<up> 3 + - 2 * x \<up> 2 * y + x * y \<up> 2)) + ((-6 * x + -3 * y) / (x + - 1 * y))";
  59.342  val e232b = the (rewrite_set thy' "rational_erls" false rls' e232b');
  59.343  
  59.344  print("\n\nexample 233:\n");
  59.345  print("a)\n");
  59.346 -val e233a'="((5 * x + 6 * y) / (x)) + ((5 * x * y \<up> 2 + -6 * y \<up> 3 + -2 * x \<up> 3 + 3 * x \<up> 2 * y) / (x \<up> 3 + -2 * x \<up> 2 * y + x * y \<up> 2)) + ((-2 * x + -3 * y) / (x + -1 * y))";
  59.347 +val e233a'="((5 * x + 6 * y) / (x)) + ((5 * x * y \<up> 2 + -6 * y \<up> 3 + - 2 * x \<up> 3 + 3 * x \<up> 2 * y) / (x \<up> 3 + - 2 * x \<up> 2 * y + x * y \<up> 2)) + ((- 2 * x + -3 * y) / (x + - 1 * y))";
  59.348  val e233a = the (rewrite_set thy' "rational_erls" false rls' e233a'); 
  59.349  print("b)\n");
  59.350 -val e233b'="((6 * x + 5 * y) / (x)) + ((4 * x \<up> 2 * y + 3 * x * y \<up> 2 + -5 * y \<up> 3 + -2 * x \<up> 3) / (x \<up> 3 + -2 * x \<up> 2 * y + x * y \<up> 2)) + ((-3 * x + -2 * y) / (x + -1 * y))";
  59.351 +val e233b'="((6 * x + 5 * y) / (x)) + ((4 * x \<up> 2 * y + 3 * x * y \<up> 2 + -5 * y \<up> 3 + - 2 * x \<up> 3) / (x \<up> 3 + - 2 * x \<up> 2 * y + x * y \<up> 2)) + ((-3 * x + - 2 * y) / (x + - 1 * y))";
  59.352  val e233b = the (rewrite_set thy' "rational_erls" false rls' e233b');
  59.353  
  59.354  print("\n\nexample 234:\n");
  59.355  print("a)\n");
  59.356 -val e234a'="((5 * a + b) / (2 * a * b + -2 * b \<up> 2)) + ((-3 * a + -1 * b) / (2 * a * b + 2 * b \<up> 2)) + ((-2 * a) / (a \<up> 2 + -1 * b \<up> 2))";
  59.357 +val e234a'="((5 * a + b) / (2 * a * b + - 2 * b \<up> 2)) + ((-3 * a + - 1 * b) / (2 * a * b + 2 * b \<up> 2)) + ((- 2 * a) / (a \<up> 2 + - 1 * b \<up> 2))";
  59.358  val e234a = the (rewrite_set thy' "rational_erls" false rls' e234a'); 
  59.359  print("b)\n"); 
  59.360 -val e234b'="((5 * a + 3 * b) / (6 * a * b + -18 * b \<up> 2)) + ((-3 * a + -3 * b) / (6 * a * b + 18 * b \<up> 2)) + ((-2 * a) / (a \<up> 2 + -9 * b \<up> 2)) ";
  59.361 +val e234b'="((5 * a + 3 * b) / (6 * a * b + - 18 * b \<up> 2)) + ((-3 * a + -3 * b) / (6 * a * b + 18 * b \<up> 2)) + ((- 2 * a) / (a \<up> 2 + -9 * b \<up> 2)) ";
  59.362  val e234b = the (rewrite_set thy' "rational_erls" false rls' e234b');  
  59.363  
  59.364  print("\n\nexample 235:\n");
  59.365  print("a)\n");
  59.366 -val e235a'="((10 * x + 3 * y) / (12 * x * y + -18 * y \<up> 2)) + ((-6 * x + -3 * y) / (12 * x * y + 18 * y \<up> 2)) + ((-4 * x) / (4 * x \<up> 2 + -9 * y \<up> 2))";
  59.367 +val e235a'="((10 * x + 3 * y) / (12 * x * y + - 18 * y \<up> 2)) + ((-6 * x + -3 * y) / (12 * x * y + 18 * y \<up> 2)) + ((-4 * x) / (4 * x \<up> 2 + -9 * y \<up> 2))";
  59.368  val e235a = the (rewrite_set thy' "rational_erls" false rls' e235a'); 
  59.369  print("b)\n"); 
  59.370 -val e235b'="((8 * a + b) / (4 * a * b + -2 * b \<up> 2)) + ((-4 * a + -1 * b) / (4 * a * b + 2 * b \<up> 2)) + ((-2 * a) / (4 * a \<up> 2 + -1 * b \<up> 2)) ";
  59.371 +val e235b'="((8 * a + b) / (4 * a * b + - 2 * b \<up> 2)) + ((-4 * a + - 1 * b) / (4 * a * b + 2 * b \<up> 2)) + ((- 2 * a) / (4 * a \<up> 2 + - 1 * b \<up> 2)) ";
  59.372  val e235b = the (rewrite_set thy' "rational_erls" false rls' e235b');  
  59.373   
  59.374  print("\n\nexample 236:\n");
  59.375  print("a)\n"); 
  59.376 -val e236a'="((8 * a + 5 * b) / (20 * a * b + -50 * b \<up> 2)) + ((-4 * a + -5 * b) / (20 * a * b + 50 * b \<up> 2)) + ((-2 * a) / (4 * a \<up> 2 + -25 * b \<up> 2))";
  59.377 +val e236a'="((8 * a + 5 * b) / (20 * a * b + -50 * b \<up> 2)) + ((-4 * a + -5 * b) / (20 * a * b + 50 * b \<up> 2)) + ((- 2 * a) / (4 * a \<up> 2 + - 25 * b \<up> 2))";
  59.378  val e236a = the (rewrite_set thy' "rational_erls" false rls' e236a');  
  59.379  print("b)\n");   
  59.380 -val e236b'="((24 * x + y) / (6 * x * y + -2 * y \<up> 2)) + ((-18 * x + -1 * y) / (6 * x * y + 2 * y \<up> 2)) + ((-15 * x) / (9 * x \<up> 2 + -1 * y \<up> 2)) ";
  59.381 +val e236b'="((24 * x + y) / (6 * x * y + - 2 * y \<up> 2)) + ((- 18 * x + - 1 * y) / (6 * x * y + 2 * y \<up> 2)) + ((- 15 * x) / (9 * x \<up> 2 + - 1 * y \<up> 2)) ";
  59.382  val e236b = the (rewrite_set thy' "rational_erls" false rls' e236b');  
  59.383  
  59.384  print("\n\nexample heuberger:\n");
  59.385 @@ -592,9 +592,9 @@
  59.386  val eheu = the (rewrite_set thy' "rational_erls" false rls' eheu');
  59.387  
  59.388  print("\n\nexample stiefel:\n");
  59.389 -val est1'="(7) / (-14) + (-2) / (4)";
  59.390 +val est1'="(7) / (- 14) + (- 2) / (4)";
  59.391  val est1 = the (rewrite_set thy' "rational_erls" false rls' est1');
  59.392 -if est1 = ("(-1) / 1",[]) then ()
  59.393 +if est1 = ("(- 1) / 1",[]) then ()
  59.394  else error "new behaviour in rationals.sml: est1'";
  59.395  -------------------------------------------------------------------------*)
  59.396  
  59.397 @@ -678,7 +678,7 @@
  59.398  
  59.399    (*the term for which reverse rewriting is demonstrated*)
  59.400    val t = (Thm.term_of o the o (TermC.parse thy))
  59.401 -	      "(9 + (-1)*x \<up> 2) / (9 + ((-6)*x + x \<up> 2))";
  59.402 +	      "(9 + (- 1)*x \<up> 2) / (9 + ((-6)*x + x \<up> 2))";
  59.403    val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
  59.404    		       next_rule=nex,normal_form=nor,...},...} = cancel;
  59.405    (*normal_form produces the result in ONE step*)
  59.406 @@ -714,8 +714,8 @@
  59.407  OK   Thm ("sym_real_add_left_commute", "?y + (?x + ?z) = ?x + (?y + ?z)"),
  59.408  ///  Thm ("sym_real_mult_1", "?z = 1 * ?z"),
  59.409  !    Thm ("sym_#power_3_2", "9 = 3 \<up> 2"),
  59.410 -!    Thm ("sym_#mult_-1_-1", "1 * x \<up> 2 = -1 * (-1 * x \<up> 2)"),
  59.411 -!    Thm ("sym_#mult_-1_3", "(-3) * x = -1 * (3 * x)"),
  59.412 +!    Thm ("sym_#mult_- 1_- 1", "1 * x \<up> 2 = - 1 * (- 1 * x \<up> 2)"),
  59.413 +!    Thm ("sym_#mult_- 1_3", "(-3) * x = - 1 * (3 * x)"),
  59.414  OK   Thm ("realpow_twoI", "?r1 \<up> 2 = ?r1 * ?r1"  [.]),
  59.415  OK   Thm ("sym_real_add_assoc",
  59.416        "?z1.0 + (?z2.0 + ?z3.0) = ?z1.0 + ?z2.0 + ?z3.0"),
  59.417 @@ -733,7 +733,7 @@
  59.418  
  59.419    val t = (Thm.term_of o the o (TermC.parse thy)) "(-6) * x";
  59.420    val t = (Thm.term_of o the o (TermC.parse thy)) 
  59.421 -	      "(9 + (-1)*x \<up> 2) / (9 + ((-6)*x + x \<up> 2))";
  59.422 +	      "(9 + (- 1)*x \<up> 2) / (9 + ((-6)*x + x \<up> 2))";
  59.423    val thm = (mk_thm thy "(-6) * x = 2 * ((-3) * x)") 
  59.424        handle e => OldGoals.print_exn e;
  59.425    val SOME (t',_) = rewrite_ thy e_rew_ord Rule_Set.empty false thm t;     
  59.426 @@ -756,7 +756,7 @@
  59.427  UnparseC.term t1';
  59.428  UnparseC.term t1'';
  59.429  
  59.430 -val t2 = (Thm.term_of o the o (TermC.parse thy)) "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
  59.431 +val t2 = (Thm.term_of o the o (TermC.parse thy)) "((x+ (- 1)) / (x + 1)) + ((x + 1) / (x + (- 1)))";
  59.432  val SOME (t2',_) = add_fractions_ thy t2;
  59.433  val SOME (t2'',_) = common_nominators_ thy t2; 
  59.434  UnparseC.term t2';
  59.435 @@ -769,7 +769,7 @@
  59.436  UnparseC.term t2'';
  59.437  
  59.438  
  59.439 -val t3 = (Thm.term_of o the o (TermC.parse thy)) "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x \<up> 2 + (-1)))+((1) / (x \<up> 2 + (-2)*x + 1))";
  59.440 +val t3 = (Thm.term_of o the o (TermC.parse thy)) "((1) / (2*x + 2)) + ((1) / (2*x + (- 2))) + ((1) / ( x \<up> 2 + (- 1)))+((1) / (x \<up> 2 + (- 2)*x + 1))";
  59.441  val SOME (t3',_) = common_nominators_ thy t3; 
  59.442  val SOME (t3'',_) = add_fractions_ thy t3; 
  59.443  (UnparseC.term t3');
  59.444 @@ -788,9 +788,9 @@
  59.445  UnparseC.term (hd(t5));*)
  59.446  
  59.447  (*val test1 = (Thm.term_of o the o (TermC.parse thy)) "1 - x \<up> 2 - 5 * x \<up> 5";
  59.448 -val test2 = (Thm.term_of o the o (TermC.parse thy)) "1 + (-1) * x \<up> 2 + (-5) * x \<up> 5";
  59.449 +val test2 = (Thm.term_of o the o (TermC.parse thy)) "1 + (- 1) * x \<up> 2 + (-5) * x \<up> 5";
  59.450  val test2 = (Thm.term_of o the o (TermC.parse thy)) "1 - x";
  59.451 -val test2 = (Thm.term_of o the o (TermC.parse thy)) "1 + (-1) * x";
  59.452 +val test2 = (Thm.term_of o the o (TermC.parse thy)) "1 + (- 1) * x";
  59.453  UnparseC.term(expanded2term(test1));
  59.454  UnparseC.term(term2expanded(test2)); *)
  59.455  
  59.456 @@ -852,9 +852,9 @@
  59.457    val SOME (t'',_) = add_fraction_ thy t;
  59.458    UnparseC.term t';
  59.459    UnparseC.term t'';
  59.460 -  "((-1) * x \<up> 2 + y \<up> 2) / (((-1) * x + y) * ((-1) * x + y)) +\
  59.461 -  \1 * ((-1) * x + y) / (((-1) * x + y) * ((-1) * x + y))";
  59.462 -  "((-1) - x - y) / (x - y)";
  59.463 +  "((- 1) * x \<up> 2 + y \<up> 2) / (((- 1) * x + y) * ((- 1) * x + y)) +\
  59.464 +  \1 * ((- 1) * x + y) / (((- 1) * x + y) * ((- 1) * x + y))";
  59.465 +  "((- 1) - x - y) / (x - y)";
  59.466    (*WN.16.10.02     \<up> \<up> ^ Reihenfolge aus Angabe umgekehrt ?!*)
  59.467  
  59.468    val t=(Thm.term_of o the o (TermC.parse thy)) 
  59.469 @@ -863,9 +863,9 @@
  59.470    val SOME (t'',_) = add_fraction_ thy t;
  59.471    UnparseC.term t';
  59.472    UnparseC.term t'';
  59.473 -  "((-1) * y \<up> 2 + x \<up> 2) / (((-1) * y + x) * ((-1) * y + x)) +\
  59.474 -  \1 * ((-1) * y + x) / (((-1) * y + x) * ((-1) * y + x))";
  59.475 -  "((-1) - y - x) / (y - x)";
  59.476 +  "((- 1) * y \<up> 2 + x \<up> 2) / (((- 1) * y + x) * ((- 1) * y + x)) +\
  59.477 +  \1 * ((- 1) * y + x) / (((- 1) * y + x) * ((- 1) * y + x))";
  59.478 +  "((- 1) - y - x) / (y - x)";
  59.479    (*WN.16.10.02     \<up> \<up> ^ lexicographische Ordnung ?!*)
  59.480  
  59.481    val t=(Thm.term_of o the o (TermC.parse thy)) 
  59.482 @@ -889,13 +889,13 @@
  59.483    WN.16.10.02 ?!*)
  59.484   
  59.485    val t=(Thm.term_of o the o (TermC.parse thy)) 
  59.486 -	    "(9 + (-1)* x \<up> 2)/(9 + (-1)* 6*x + x \<up> 2) + (1)/(3 + x)";
  59.487 +	    "(9 + (- 1)* x \<up> 2)/(9 + (- 1)* 6*x + x \<up> 2) + (1)/(3 + x)";
  59.488    val SOME (t',_) = norm_expanded_rat_ thy t;
  59.489    val SOME (t'',_) = norm_rational_ thy t;
  59.490    UnparseC.term t';
  59.491    UnparseC.term t'';
  59.492    "(12 + 5 * x + x \<up> 2) / (9 - x \<up> 2)";
  59.493 -  "(12 + 5 * x + x \<up> 2) / (9 + (-1) * x \<up> 2)";
  59.494 +  "(12 + 5 * x + x \<up> 2) / (9 + (- 1) * x \<up> 2)";
  59.495  (* WN kopiert 16.10.02 Rational.ML -> rational.sml----- \<up> ---*)
  59.496  
  59.497  
    60.1 --- a/test/Tools/isac/Knowledge/rational.sml	Mon Jun 21 22:08:01 2021 +0200
    60.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.3 @@ -1,1877 +0,0 @@
    60.4 -(* Title: tests for rationals
    60.5 -   Author: Walther Neuper
    60.6 -   Use is subject to license terms.
    60.7 -*)
    60.8 -
    60.9 -"-----------------------------------------------------------------------------";
   60.10 -"-----------------------------------------------------------------------------";
   60.11 -"table of contents -----------------------------------------------------------";
   60.12 -"-----------------------------------------------------------------------------";
   60.13 -"-------- fun poly_of_term ---------------------------------------------------";
   60.14 -"-------- fun is_poly --------------------------------------------------------";
   60.15 -"-------- fun term_of_poly ---------------------------------------------------";
   60.16 -"-------- integration lev.1 fun factout_p_ -----------------------------------";
   60.17 -"-------- integration lev.1 fun cancel_p_ ------------------------------------";
   60.18 -"-------- integration lev.1 fun common_nominator_p_ --------------------------";
   60.19 -"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
   60.20 -"Rfuns-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
   60.21 -"Rfuns-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
   60.22 -"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
   60.23 -"Rfuns-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
   60.24 -"----------- rewrite_set_ Partial_Fractions norm_Rational --------------------------------------";
   60.25 -"----------- fun check_frac_sum with Free A and Const AA ---------------------------------------";
   60.26 -"----------- fun cancel_p with Const AA --------------------------------------------------------";
   60.27 -"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
   60.28 -"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
   60.29 -"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
   60.30 -"Rfuns-------- reverse rewrite ----------------------------------------------------";
   60.31 -"Rfuns-------- 'reverse-ruleset' cancel_p -----------------------------------------";
   60.32 -"-------- investigate rls norm_Rational --------------------------------------";
   60.33 -"-------- examples: rls norm_Rational ----------------------------------------";
   60.34 -"-------- rational numerals --------------------------------------------------";
   60.35 -"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
   60.36 -"-------- examples common denominator from: Mathematik 1 Schalk --------------";
   60.37 -"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
   60.38 -"-------- examples common denominator and multiplication from: Schalk --------";
   60.39 -"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
   60.40 -"-------- me Schalk I No.186 -------------------------------------------------";
   60.41 -"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
   60.42 -"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
   60.43 -"-------- investigate rulesets for cancel_p ----------------------------------";
   60.44 -"-------- fun eval_get_denominator -------------------------------------------";
   60.45 -"-------- several errpats in complicated term --------------------------------";
   60.46 -"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
   60.47 -"-----------------------------------------------------------------------------";
   60.48 -"-----------------------------------------------------------------------------";
   60.49 -
   60.50 -
   60.51 -"-------- fun poly_of_term ---------------------------------------------------";
   60.52 -"-------- fun poly_of_term ---------------------------------------------------";
   60.53 -"-------- fun poly_of_term ---------------------------------------------------";
   60.54 -val thy = @{theory Partial_Fractions};
   60.55 -val ctxt = Proof_Context.init_global @{theory}
   60.56 -val vs = TermC.vars_of (the (parseNEW ctxt "12 * x \<up> 3 * y \<up> 4 * z \<up> 6"));
   60.57 -
   60.58 -if poly_of_term vs (TermC.str2term "12::real") = SOME [(12, [0, 0, 0])]
   60.59 -then () else error "poly_of_term 1 changed";
   60.60 -if poly_of_term vs (TermC.str2term "x::real") = SOME [(1, [1, 0, 0])]
   60.61 -then () else error "poly_of_term 2 changed";
   60.62 -if poly_of_term vs (TermC.str2term "12 * x \<up> 3") = SOME [(12, [3, 0, 0])]
   60.63 -then () else error "poly_of_term 3 changed";
   60.64 -if poly_of_term vs (TermC.str2term "12 * x \<up> 3 * y \<up> 4 * z \<up> 6") = SOME [(12, [3, 4, 6])]
   60.65 -then () else error "poly_of_term 4 changed";
   60.66 -if poly_of_term vs (TermC.str2term "1 + 2 * x \<up> 3 * y \<up> 4 * z \<up> 6 + y") =
   60.67 -  SOME [(1, [0, 0, 0]), (1, [0, 1, 0]), (2, [3, 4, 6])]
   60.68 -then () else error "poly_of_term 5 changed";
   60.69 -
   60.70 -(*poly_of_term is quite liberal:*)
   60.71 -(*the coefficient may be somewhere, the order of variables and the parentheses 
   60.72 -  within a monomial are arbitrary*)
   60.73 -if poly_of_term vs (TermC.str2term "y \<up> 4 * (x \<up> 3 * 12 * z \<up> 6)") = SOME [(12, [3, 4, 6])]
   60.74 -then () else error "poly_of_term 6 changed";
   60.75 -
   60.76 -(*there may even be more than 1 coefficient:*)
   60.77 -if poly_of_term vs (TermC.str2term "2 * y \<up> 4 * (x \<up> 3 * 6 * z \<up> 6)") = SOME [(12, [3, 4, 6])]
   60.78 -then () else error "poly_of_term 7 changed";
   60.79 -
   60.80 -(*the order and the parentheses within monomials are arbitrary:*)
   60.81 -if poly_of_term vs (TermC.str2term "2 * x \<up> 3 * y \<up> 4 * z \<up> 6 + (7 * y \<up> 8 + 1)")
   60.82 -  = SOME [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 6])]
   60.83 -then () else error "poly_of_term 8 changed";
   60.84 -
   60.85 -"-------- fun is_poly --------------------------------------------------------";
   60.86 -"-------- fun is_poly --------------------------------------------------------";
   60.87 -"-------- fun is_poly --------------------------------------------------------";
   60.88 -if is_poly (TermC.str2term "2 * x \<up> 3 * y \<up> 4 * z \<up> 6 + 7 * y \<up> 8 + 1")
   60.89 -then () else error "is_poly 1 changed";
   60.90 -if not (is_poly (TermC.str2term "2 * (x \<up> 3 * y \<up> 4 * z \<up> 6 + 7) * y \<up> 8 + 1"))
   60.91 -then () else error "is_poly 2 changed";
   60.92 -
   60.93 -"-------- fun term_of_poly ---------------------------------------------------";
   60.94 -"-------- fun term_of_poly ---------------------------------------------------";
   60.95 -"-------- fun term_of_poly ---------------------------------------------------";
   60.96 -val expT = HOLogic.realT
   60.97 -val Free (_, baseT) = (hd o vars o TermC.str2term) "12 * x \<up> 3 * y \<up> 4 * z \<up> 6";
   60.98 -val p = [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 5])]
   60.99 -val vs = TermC.vars_of (the (parseNEW ctxt "12 * x \<up> 3 * y \<up> 4 * z \<up> 6"))
  60.100 -(*precondition for [(c, es),...]: legth es = length vs*)
  60.101 -;
  60.102 -if UnparseC.term (term_of_poly baseT expT vs p) = "1 + 7 * y \<up> 8 + 2 * x \<up> 3 * y \<up> 4 * z \<up> 5"
  60.103 -then () else error "term_of_poly 1 changed";
  60.104 -
  60.105 -"-------- integration lev.1 fun factout_p_ -----------------------------------";
  60.106 -"-------- integration lev.1 fun factout_p_ -----------------------------------";
  60.107 -"-------- integration lev.1 fun factout_p_ -----------------------------------";
  60.108 -val t = TermC.str2term "(x \<up> 2 + -1*y \<up> 2) / (x \<up> 2 + -1*x*y)"
  60.109 -val SOME (t', asm) = factout_p_ thy t;
  60.110 -if UnparseC.term t' = "(x + y) * (x + -1 * y) / (x * (x + -1 * y))"
  60.111 -then () else error ("factout_p_ term 1 changed: " ^ UnparseC.term t')
  60.112 -;
  60.113 -if UnparseC.terms asm = "[\"x \<noteq> 0\",\"x + -1 * y \<noteq> 0\"]"
  60.114 -then () else error "factout_p_ asm 1 changed"
  60.115 -;
  60.116 -val t = TermC.str2term "nothing + to_cancel ::real";
  60.117 -if NONE = factout_p_ thy t then () else error "factout_p_ doesn't report non-applicable";
  60.118 -;
  60.119 -val t = TermC.str2term "((3 * x \<up> 2 + 6 *x + 3) / (2*x + 2))";
  60.120 -val SOME (t', asm) = factout_p_ thy t;
  60.121 -if UnparseC.term t' = "(3 + 3 * x) * (1 + x) / (2 * (1 + x))" andalso 
  60.122 -  UnparseC.terms asm = "[\"1 + x \<noteq> 0\"]"
  60.123 -then () else error "factout_p_ 1 changed";
  60.124 -
  60.125 -"-------- integration lev.1 fun cancel_p_ ------------------------------------";
  60.126 -"-------- integration lev.1 fun cancel_p_ ------------------------------------";
  60.127 -"-------- integration lev.1 fun cancel_p_ ------------------------------------";
  60.128 -val t = TermC.str2term "(x \<up> 2 + -1*y \<up> 2) / (x \<up> 2 + -1*x*y)"
  60.129 -val SOME (t', asm) = cancel_p_ thy t;
  60.130 -if (UnparseC.term t', UnparseC.terms asm) = ("(x + y) / x", "[\"x \<noteq> 0\"]")
  60.131 -then () else error ("cancel_p_ (t', asm) 1 changed: " ^ UnparseC.term t')
  60.132 -;
  60.133 -val t = TermC.str2term "nothing + to_cancel ::real";
  60.134 -if NONE = cancel_p_ thy t then () else error "cancel_p_ doesn't report non-applicable";
  60.135 -;
  60.136 -val t = TermC.str2term "((3 * x \<up> 2 + 6 *x + 3) / (2*x + 2))";
  60.137 -val SOME (t', asm) = cancel_p_ thy t;
  60.138 -if UnparseC.term t' = "(3 + 3 * x) / 2" andalso UnparseC.terms asm = "[]"
  60.139 -then () else error "cancel_p_ 1 changed";
  60.140 -
  60.141 -"-------- integration lev.1 fun common_nominator_p_ --------------------------";
  60.142 -"-------- integration lev.1 fun common_nominator_p_ --------------------------";
  60.143 -"-------- integration lev.1 fun common_nominator_p_ --------------------------";
  60.144 -val t = TermC.str2term ("y / (a*x + b*x + c*x) " ^
  60.145 -              (* n1    d1                   *)
  60.146 -                "+ a / (x*y)");
  60.147 -              (* n2    d2                   *)
  60.148 -val SOME (t', asm) = common_nominator_p_ thy t;
  60.149 -if UnparseC.term t' =
  60.150 -      ("y * y / (x * ((a + b + c) * y)) " ^
  60.151 -  (*  n1  *d2'/ (c'* ( d1'        *d2')) *)
  60.152 -     "+ a * (a + b + c) / (x * ((a + b + c) * y))")
  60.153 -   (*  n2 * d1'         / (c'* ( d1'        *d2')) *)
  60.154 -then () else error "common_nominator_p_ term 1 changed";
  60.155 -if UnparseC.terms asm = "[\"a + b + c \<noteq> 0\",\"y \<noteq> 0\",\"x \<noteq> 0\"]"
  60.156 -then () else error "common_nominator_p_ asm 1 changed"
  60.157 -
  60.158 -"-------- example in mail Nipkow";
  60.159 -val t = TermC.str2term "x/(x \<up> 2 + -1*y \<up> 2) + y/(x \<up> 2 + -1*x*y)";
  60.160 -val SOME (t', asm) = common_nominator_p_ thy t;
  60.161 -if UnparseC.term t' = "x * x / " ^ 
  60.162 -                 "((x + -1 * y) * ((x + y) * x))" ^
  60.163 -            " +\n" ^ 
  60.164 -                 "y * (x + y) / " ^ 
  60.165 -                 "((x + -1 * y) * ((x + y) * x))"
  60.166 -then () else error "common_nominator_p_ term 2 changed"
  60.167 -;
  60.168 -if UnparseC.terms asm = "[\"x + y \<noteq> 0\",\"x \<noteq> 0\",\"x + -1 * y \<noteq> 0\"]"
  60.169 -then () else error "common_nominator_p_ asm 2 changed"
  60.170 -
  60.171 -"-------- example: applicable tested by SML code";
  60.172 -val t = TermC.str2term "nothing / to_add";
  60.173 -if NONE = common_nominator_p_ thy t then () else error "common_nominator_p_ term 3 changed";
  60.174 -;
  60.175 -val t = TermC.str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
  60.176 -val SOME (t', asm) = common_nominator_p_ thy t;
  60.177 -if UnparseC.term t' = 
  60.178 -   "(x + -1) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(x + 1) * (1 + x) / ((1 + x) * (-1 + x))"
  60.179 -  andalso UnparseC.terms asm = "[\"1 + x \<noteq> 0\",\"-1 + x \<noteq> 0\"]"
  60.180 -then () else error "common_nominator_p_ 3 changed";
  60.181 -
  60.182 -"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
  60.183 -"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
  60.184 -"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
  60.185 -val t = TermC.str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
  60.186 -val SOME (t', asm) = add_fraction_p_ thy t;
  60.187 -if UnparseC.term t' = "(2 + 2 * x \<up> 2) / (-1 + x \<up> 2)" 
  60.188 -then () else error "add_fraction_p_ 3 changed";
  60.189 -;
  60.190 -if UnparseC.terms asm = "[\"-1 + x \<up> 2 \<noteq> 0\"]"
  60.191 -then () else error "add_fraction_p_ 3 changed";
  60.192 -;
  60.193 -val t = TermC.str2term "nothing / to_add";
  60.194 -if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ term 3 changed";
  60.195 -;
  60.196 -val t = TermC.str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
  60.197 -val SOME (t', asm) = add_fraction_p_ thy t;
  60.198 -if UnparseC.term t' = "(2 + 2 * x \<up> 2) / (-1 + x \<up> 2)" andalso
  60.199 -  UnparseC.terms asm = "[\"-1 + x \<up> 2 \<noteq> 0\"]"
  60.200 -then () else error "add_fraction_p_ 3 changed";
  60.201 -
  60.202 -"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
  60.203 -"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
  60.204 -"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
  60.205 -(* trace down until prepats are evaluated 
  60.206 -  (which does not to work, because substitution is not done -- compare rew_sub!);
  60.207 -  keep this sequence for the case, factout_p, cancel_p, common_nominator_p, add_fraction_p
  60.208 -  (again) get prepat = [] changed to <>[]. *)
  60.209 -val t = TermC.str2term "(x \<up> 2 + -1*y \<up> 2) / (x \<up> 2 + -1*x*y)";
  60.210 -
  60.211 -(*rewrite_set_ @{theory Isac_Knowledge} true cancel t = NONE; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  60.212 -"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (thy, false, cancel_p, t);
  60.213 -"~~~~~ fun rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
  60.214 -  (thy, 1, bool, [], rls, term);
  60.215 -(*val (t', asm, rew) = app_rev thy (i+1) rrls t; rew = false!!!!!!!!!!!!!!!!!!!!!*)
  60.216 -"~~~~~ and app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
  60.217 -    fun chk_prepat thy erls [] t = true
  60.218 -      | chk_prepat thy erls prepat t =
  60.219 -        let
  60.220 -          fun chk (pres, pat) =
  60.221 -            (let 
  60.222 -              val subst: Type.tyenv * Envir.tenv =
  60.223 -                Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
  60.224 -             in
  60.225 -              snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
  60.226 -             end) handle Pattern.MATCH => false
  60.227 -           fun scan_ f [] = false (*scan_ NEVER called by []*)
  60.228 -             | scan_ f (pp::pps) =
  60.229 -               if f pp then true else scan_ f pps;
  60.230 -        in scan_ chk prepat end;
  60.231 -    (* apply the normal_form of a rev-set *)
  60.232 -    fun app_rev' thy (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}) t =
  60.233 -      if chk_prepat thy erls prepat t
  60.234 -      then ((*tracing("### app_rev': t = "^UnparseC.term t);*) normal_form t)
  60.235 -      else NONE;
  60.236 -(*  val opt = app_rev' thy rrls t  ..NONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  60.237 -"~~~~~ and app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
  60.238 -  (thy, rrls, t);
  60.239 -(* chk_prepat thy erls prepat t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  60.240 -(* app_sub thy i rrls t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  60.241 -"~~~~~ fun chk_prepat, args:"; val (thy, erls, prepat, t) = (thy, erls, prepat, t);
  60.242 -          fun chk (pres, pat) =
  60.243 -            (let 
  60.244 -              val subst: Type.tyenv * Envir.tenv =
  60.245 -                Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
  60.246 -             in
  60.247 -              snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
  60.248 -             end) handle Pattern.MATCH => false
  60.249 -           fun scan_ f [] = false (*scan_ NEVER called by []*)
  60.250 -             | scan_ f (pp::pps) =
  60.251 -               if f pp then true else scan_ f pps;
  60.252 -
  60.253 -(*========== inhibit exn WN130823: prepat is empty ====================================
  60.254 -(* scan_ chk prepat = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  60.255 -"~~~~~ fun , args:"; val (f, (pp::pps)) = (chk, prepat);
  60.256 -f;
  60.257 -val ([t1, t2], t) = pp;
  60.258 -UnparseC.term t1 = "?r is_expanded";
  60.259 -UnparseC.term t2 = "?s is_expanded";
  60.260 -UnparseC.term t = "?r / ?s";
  60.261 -(* f pp = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  60.262 -"~~~~~ fun chk, args:"; val (pres, pat) = (pp);
  60.263 -              val subst: Type.tyenv * Envir.tenv =
  60.264 -                Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
  60.265 -(*subst = 
  60.266 -  ({}, {(("r", 0), ("real", Var (("r", 0), "real"))), 
  60.267 -        (("s", 0), ("real", Var (("s", 0), "real")))}*)
  60.268 -;
  60.269 -              snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
  60.270 -"~~~~~ fun eval__true, args:"; val (thy, i, asms, bdv, rls) =
  60.271 -  (thy, (i + 1), (map (Envir.subst_term subst) pres), [], erls);
  60.272 -UnparseC.terms asms;                         (* = "[\"?r is_expanded\",\"?s is_expanded\"]"*)
  60.273 -asms = [@{term True}] orelse asms = []; (* = false*)
  60.274 -asms = [@{term False}]                ; (* = false*)
  60.275 -"~~~~~ fun chk, args:"; val (indets, (a::asms)) = ([], asms);
  60.276 -bdv (*= []: _a list*);
  60.277 -val bdv : (term * term) list = [];
  60.278 -rewrite__set_ thy (i+1) false;
  60.279 -UnparseC.term a = "?r is_expanded"; (*hier m"usste doch der Numerator eingesetzt sein ??????????????*)
  60.280 -val SOME (Const (\<^const_name>\<open>False\<close>, _), []) = rewrite__set_ thy (i+1) false bdv rls a
  60.281 -============ inhibit exn WN130823: prepat is empty ===================================*)
  60.282 -
  60.283 -"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
  60.284 -"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
  60.285 -"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
  60.286 -val t = TermC.str2term "(12 * x * y) / (8 * y \<up> 2 )";
  60.287 -(* "-------- example 187a": exception Div raised...
  60.288 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
  60.289 -val t = TermC.str2term "(8 * x \<up> 2 * y * z ) / (18 * x * y \<up> 2 * z )";
  60.290 -(* "-------- example 187b": doesn't terminate...
  60.291 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
  60.292 -val t = TermC.str2term "(9 * x \<up> 5 * y \<up> 2 * z \<up> 4) / (15 * x \<up> 6 * y \<up> 3 * z )";
  60.293 -(* "-------- example 187c": doesn't terminate...
  60.294 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
  60.295 -"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (@{theory Isac_Knowledge}, false, cancel_p, t);
  60.296 -(* WN130827: exception Div raised...
  60.297 -rewrite__set_ thy 1 bool [] rls term
  60.298 -*)
  60.299 -"~~~~~ and rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
  60.300 -  (thy, 1, bool, [], rls, term);
  60.301 -(* WN130827: exception Div raised...
  60.302 -	val (t', asm, rew) = app_rev thy (i+1) rrls t
  60.303 -*)
  60.304 -"~~~~~ fun app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
  60.305 -(* WN130827: exception Div raised...
  60.306 -    val opt = app_rev' thy rrls t
  60.307 -*)
  60.308 -"~~~~~ fun app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
  60.309 -  (thy, rrls, t);
  60.310 -chk_prepat thy erls prepat t    = true;
  60.311 -(* WN130827: exception Div raised...
  60.312 -normal_form t
  60.313 -*)
  60.314 -(* lookup Rational.thy, cancel_p: normal_form = cancel_p_ thy*)
  60.315 -"~~~~~ fun cancel_p_, args:"; val (t) = (t);
  60.316 -val opt = check_fraction t;
  60.317 -val SOME (numerator, denominator) = opt
  60.318 -        val vs = TermC.vars_of t
  60.319 -        val baseT = type_of numerator
  60.320 -        val expT = HOLogic.realT
  60.321 -val (SOME a, SOME b) = (poly_of_term vs numerator, poly_of_term vs denominator);
  60.322 -(*"-------- example 187a": exception Div raised...
  60.323 -val a = [(12, [1, 1])]: poly
  60.324 -val b = [(8, [0, 2])]: poly
  60.325 -              val ((a', b'), c) = gcd_poly a b
  60.326 -*)
  60.327 -(* "-------- example 187b": doesn't terminate...
  60.328 -val a = [(8, [2, 1, 1])]: poly
  60.329 -val b = [(18, [1, 2, 1])]: poly
  60.330 -              val ((a', b'), c) = gcd_poly a b
  60.331 -*)
  60.332 -(* "-------- example 187c": doesn't terminate...
  60.333 -val a = [(9, [5, 2, 4])]: poly
  60.334 -val b = [(15, [6, 3, 1])]: poly
  60.335 -              val ((a', b'), c) = gcd_poly a b
  60.336 -*)
  60.337 -
  60.338 -"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
  60.339 -"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
  60.340 -"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
  60.341 -val t = TermC.str2term "(x \<up> 2 - 4)*(3 - y) / ((y \<up> 2 - 9)*(2+x))";
  60.342 -Rewrite.trace_on := false (*true false*);
  60.343 -(* trace stops with ...: (and then jEdit hangs)..
  60.344 -rewrite_set_ thy false norm_Rational t;
  60.345 -:
  60.346 -###  rls: cancel_p on: (-12 + 4 * y + 3 * x \<up> 2 + -1 * (x \<up> 2 * y)) /
  60.347 -(-18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)
  60.348 -*)
  60.349 -val t = TermC.str2term (*copy from above: "::real" is not required due to " \<up> "*)
  60.350 -  ("(-12 + 4 * y + 3 * x \<up> 2 + -1 * (x \<up> 2 * y)) /" ^
  60.351 -  "(-18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)");
  60.352 -(*cancel_p_ thy t;
  60.353 -exception Div raised*)
  60.354 -
  60.355 -"~~~~~ fun cancel_p_, args:"; val (t) = (t);
  60.356 -val opt = check_fraction t;
  60.357 -val SOME (numerator, denominator) = opt
  60.358 -        val vs = TermC.vars_of t
  60.359 -        val baseT = type_of numerator
  60.360 -        val expT = HOLogic.realT;
  60.361 -(*default_print_depth 3; 999*)
  60.362 -val (SOME a, SOME b) = (poly_of_term vs numerator, poly_of_term vs denominator);
  60.363 -(*default_print_depth 3; 999*)
  60.364 -(* does not terminate instead of returning ?:
  60.365 -        val ((a', b'), c) = gcd_poly a b
  60.366 -val a = [(~12, [0, 0]), (3, [2, 0]), (4, [0, 1]), (~1, [2, 1])]: poly
  60.367 -val b = [(~18, [0, 0]), (~9, [1, 0]), (2, [0, 2]), (1, [1, 2])]: poly
  60.368 -*)
  60.369 -
  60.370 -"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
  60.371 -"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
  60.372 -"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
  60.373 -val thy =  @{theory Isac_Knowledge};
  60.374 -"----- SK060904-2a non-termination of add_fraction_p_";
  60.375 -val t = TermC.str2term (" (a + b * x) / (a + -1 * (b * x)) +  " ^
  60.376 -		         " (-1 * a + b * x) / (a + b * x)      ");
  60.377 -(* rewrite_set_ thy false norm_Rational t
  60.378 -exception Div raised*)
  60.379 -(* rewrite_set_ thy false add_fractions_p t;
  60.380 -exception Div raised*)
  60.381 -"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) =
  60.382 -  (@{theory Isac_Knowledge}, false, add_fractions_p, t);
  60.383 -"~~~~~ and rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
  60.384 -  (thy, 1, bool, [], rls, term);
  60.385 -(* app_rev thy (i+1) rrls t;
  60.386 -exception Div raised*)
  60.387 -"~~~~~ and app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
  60.388 -    fun chk_prepat thy erls [] t = true
  60.389 -      | chk_prepat thy erls prepat t =
  60.390 -        let
  60.391 -          fun chk (pres, pat) =
  60.392 -            (let 
  60.393 -              val subst: Type.tyenv * Envir.tenv =
  60.394 -                Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
  60.395 -             in
  60.396 -              snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
  60.397 -             end) handle Pattern.MATCH => false
  60.398 -           fun scan_ f [] = false (*scan_ NEVER called by []*)
  60.399 -             | scan_ f (pp::pps) =
  60.400 -               if f pp then true else scan_ f pps;
  60.401 -        in scan_ chk prepat end;
  60.402 -    (* apply the normal_form of a rev-set *)
  60.403 -    fun app_rev' thy (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}) t =
  60.404 -      if chk_prepat thy erls prepat t
  60.405 -      then ((*tracing("### app_rev': t = "^UnparseC.term t);*) normal_form t)
  60.406 -      else NONE;
  60.407 -(*  val opt = app_rev' thy rrls t;
  60.408 -exception Div raised*)
  60.409 -(*  val opt = app_rev' thy rrls t;
  60.410 -exception Div raised*)
  60.411 -"~~~~~ and app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
  60.412 -  (thy, rrls, t);
  60.413 -chk_prepat thy erls prepat t = true       = true;
  60.414 -(*normal_form t
  60.415 -exception Div raised*)
  60.416 -(* lookup Rational.thy, val add_fractions_p: normal_form = add_fraction_p_ thy*)
  60.417 -(*add_fraction_p_ thy t
  60.418 -exception Div raised*)
  60.419 -"~~~~~ fun add_fraction_p_, args:"; val ((_: theory), t) = (thy, t);
  60.420 -val SOME ((n1, d1), (n2, d2)) = check_frac_sum t;
  60.421 -UnparseC.term n1; UnparseC.term d1; UnparseC.term n2; UnparseC.term d2;
  60.422 -      val vs = TermC.vars_of t;
  60.423 -(*default_print_depth 3; 999*)
  60.424 -val (SOME _, SOME a, SOME _, SOME b) =
  60.425 -  (poly_of_term vs n1, poly_of_term vs d1, poly_of_term vs n2, poly_of_term vs d2);
  60.426 -(*default_print_depth 3; 999*)
  60.427 -(*
  60.428 -val a = [(1, [1, 0, 0]), (~1, [0, 1, 1])]: poly
  60.429 -val b = [(1, [1, 0, 0]), (1, [0, 1, 1])]: poly
  60.430 -            val ((a', b'), c) = gcd_poly a b
  60.431 -*)
  60.432 -
  60.433 -"----------- fun check_frac_sum with Free A and Const AA ---------------------------------------";
  60.434 -"----------- fun check_frac_sum with Free A and Const AA ---------------------------------------";
  60.435 -"----------- fun check_frac_sum with Free A and Const AA ---------------------------------------";
  60.436 -val thy = @{theory Isac_Knowledge(*Partial_Fractions*)}
  60.437 -val ctxt = Proof_Context.init_global thy;
  60.438 -
  60.439 -(*---------- (1) with Free A, B  ----------------------------------------------------------------*)
  60.440 -val t = (the o (parseNEW  ctxt)) "3 = A / 2 + A / 4 + (B / 2 + -1 * B / (2::real))";
  60.441 -                                (* required for applying thms in rewriting  \<up> ^*)
  60.442 -(* we get details from here..*)
  60.443 -
  60.444 -Rewrite.trace_on := false;
  60.445 -val SOME (t', _) = Rewrite.rewrite_set_ thy true add_fractions_p t;
  60.446 -Rewrite.trace_on := false;
  60.447 -(* Rewrite.trace_on:
  60.448 -add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + -1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *)
  60.449 -                     (* |||||||||||||||||||||||||||||||||||| *)
  60.450 -
  60.451 -val t = (the o (parseNEW  ctxt))(* ||||||||||||||||||||||||| GUESS 1 GUESS 1 GUESS 1 GUESS 1 *)
  60.452 -                       "A / 2 + A / 4 + (B / 2 + -1 * B / (2::real))";
  60.453 -"~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t);
  60.454 -val NONE = (*case*) check_frac_sum t (*of*)
  60.455 -
  60.456 -(* Rewrite.trace_on:
  60.457 -add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + -1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *)
  60.458 -                     (*         |||||||||||||||||||||||||||| *)
  60.459 -val t = (the o (parseNEW  ctxt))(* ||||||||||||||||||||||||| GUESS 2 GUESS 2 GUESS 2 GUESS 2 *)
  60.460 -                               "A / 4 + (B / 2 + -1 * B / (2::real))";
  60.461 -"~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t);
  60.462 -val SOME ((n1, d1), (n2, d2)) = (*case*) check_frac_sum t (*of*);
  60.463 -(*+*)if (UnparseC.term n1, UnparseC.term d1) = ("A"                 , "4") andalso
  60.464 -(*+*)   (UnparseC.term n2, UnparseC.term d2) = ("B / 2 + -1 * B / 2", "1")
  60.465 -(*+*)then () else error "check_frac_sum (A / 4 + (B / 2 + -1 * B / (2::real))) changed";
  60.466 -
  60.467 -      val vs = TermC.vars_of t;
  60.468 -val (SOME [(1, [1, 0])], SOME [(4, [0, 0])], NONE, SOME [(1, [0, 0])]) =
  60.469 -  (*case*) (poly_of_term vs n1, poly_of_term vs d1, poly_of_term vs n2, poly_of_term vs d2) (*of*);
  60.470 -
  60.471 -"~~~~~ fun poly_of_term , args:"; val (vs, t) = (vs, n1);
  60.472 -val SOME [(1, [xxx, 0])] = SOME [monom_of_term vs (1, replicate (length vs) 0) t];
  60.473 -(*+*)if xxx = 1 then () else error "monom_of_term changed"
  60.474 -
  60.475 -"~~~~~ fun monom_of_term , args:"; val (vs, (c, es), (Free (id, _))) =
  60.476 -  (vs, (1, replicate (length vs) 0), t);
  60.477 -case vs of [Free ("A", _), Free ("B", _)] =>
  60.478 -  if c = 1 andalso id = "A"
  60.479 -  then () else error "monom_of_term Free changed 1"
  60.480 -| _ => error "monom_of_term Free changed 2";
  60.481 -
  60.482 -(*---------- (2) with Const AA, BB --------------------------------------------------------------*)
  60.483 -val t = (the o (parseNEW  ctxt)) "3 = AA / 2 + AA / 4 + (BB / 2 + -1 * BB / 2)";
  60.484 -                                    (*AA :: real*)
  60.485 -(* we get details from here..*)
  60.486 -
  60.487 -Rewrite.trace_on := false;
  60.488 -val SOME (t', _) = Rewrite.rewrite_set_ thy true add_fractions_p t;
  60.489 -Rewrite.trace_on := false;
  60.490 -(* Rewrite.trace_on:
  60.491 -add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + -1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *)
  60.492 -                     (* |||||||||||||||||||||||||||||||||||| *)
  60.493 -val t = (the o (parseNEW  ctxt))(* ||||||||||||||||||||||||| *)
  60.494 -                   "AA / 2 + AA / 4 + (BB / 2 + -1 * BB / 2)";
  60.495 -"~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t);
  60.496 -val NONE = (*case*) check_frac_sum t (*of*)
  60.497 -
  60.498 -(* Rewrite.trace_on:
  60.499 -add_fractions_p on: 3 = A / 2 + A / 4 + (B / 2 + -1 * B / 2) --> 3 = A / 2 + A / 4 + 0 / 2 *)
  60.500 -                     (*         |||||||||||||||||||||||||||| *)
  60.501 -val t = (the o (parseNEW  ctxt))(* ||||||||||||||||||||||||| *)
  60.502 -                               "AA / 4 + (BB / 2 + -1 * BB / 2)";
  60.503 -"~~~~~ fun add_fraction_p_ , ad-hoc args:"; val (t) = (t);
  60.504 -val SOME ((n1, d1), (n2, d2)) = (*case*) check_frac_sum t (*of*);
  60.505 -(*+*)if (UnparseC.term n1, UnparseC.term d1) = ("AA"                 , "4") andalso
  60.506 -(*+*)   (UnparseC.term n2, UnparseC.term d2) = ("BB / 2 + -1 * BB / 2", "1")
  60.507 -(*+*)then () else error "check_frac_sum (AA / 4 + (BB / 2 + -1 * BB / 2)) changed";
  60.508 -
  60.509 -      val vs = TermC.vars_of t;
  60.510 -val (SOME [(1, [1, 0])], SOME [(4, [0, 0])], NONE, SOME [(1, [0, 0])]) =
  60.511 -  (*case*) (poly_of_term vs n1, poly_of_term vs d1, poly_of_term vs n2, poly_of_term vs d2) (*of*);
  60.512 -
  60.513 -"~~~~~ fun poly_of_term , args:"; val (vs, t) = (vs, n1);
  60.514 -val SOME [(1, [xxx, 0])] = SOME [monom_of_term vs (1, replicate (length vs) 0) t];
  60.515 -(*+*)if xxx = 1 then () else error "monom_of_term changed"
  60.516 -
  60.517 -"~~~~~ fun monom_of_term , args:"; val (vs, (c, es), (Const (id, _))) =
  60.518 -  (vs, (1, replicate (length vs) 0), t);
  60.519 -case vs of [Const ("Partial_Fractions.AA", _), Const ("Partial_Fractions.BB", _)] =>
  60.520 -  if c = 1 andalso id = "Partial_Fractions.AA"
  60.521 -  then () else error "monom_of_term Const changed 1"
  60.522 -| _ => error "monom_of_term Const changed 2";
  60.523 -
  60.524 -"----------- fun cancel_p with Const AA --------------------------------------------------------";
  60.525 -"----------- fun cancel_p with Const AA --------------------------------------------------------";
  60.526 -"----------- fun cancel_p with Const AA --------------------------------------------------------";
  60.527 -val thy = @{theory Partial_Fractions};
  60.528 -val ctxt = Proof_Context.init_global @{theory}
  60.529 -val SOME t = TermC.parseNEW ctxt "2 * AA / 2"; (* Const ("Free ("AA", "real") *)
  60.530 -
  60.531 -val SOME (t', _) = rewrite_set_ thy true cancel_p t;
  60.532 -case t' of
  60.533 -  Const (\<^const_name>\<open>divide\<close>, _) $ Const ("Partial_Fractions.AA", _) $ Free ("1", _) => ()
  60.534 -| _ => error "WRONG rewrite_set_ cancel_p (2 * AA / 2) \<longrightarrow> AA changed";
  60.535 -
  60.536 -"~~~~~ fun cancel_p , args:"; val (t) = (t);
  60.537 -val opt = check_fraction t
  60.538 -val SOME (numerator, denominator) = (*case*) opt (*of*);
  60.539 -
  60.540 -if UnparseC.term numerator = "2 * AA" andalso UnparseC.term denominator = "2"
  60.541 -then () else error "check_fraction (2 * AA / 2) changed";
  60.542 -        val vs = TermC.vars_of t;
  60.543 -case vs of
  60.544 -  [Const ("Partial_Fractions.AA", _)] => ()
  60.545 -| _ => error "rewrite_set_ cancel_p (2 * AA / 2) \<longrightarrow> AA/1  changed";
  60.546 -
  60.547 -
  60.548 -"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
  60.549 -"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
  60.550 -"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
  60.551 -val thy  = @{theory "Rational"};
  60.552 -"-------- WN";
  60.553 -val t = TermC.str2term "(2 + -3 * x) / 9";
  60.554 -if NONE = rewrite_set_ thy false cancel_p t then ()
  60.555 -else error "rewrite_set_ cancel_p must return NONE, if the term cannot be cancelled";
  60.556 -
  60.557 -"-------- example 186a";
  60.558 -val t = TermC.str2term "(14 * x * y) / (x * y)";
  60.559 -  is_expanded (TermC.str2term "14 * x * y");
  60.560 -  is_expanded (TermC.str2term "x * y");
  60.561 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.562 -if (UnparseC.term t', UnparseC.terms asm) = ("14 / 1", "[]")
  60.563 -then () else error "rational.sml cancel Schalk 186a";
  60.564 -
  60.565 -"-------- example 186b";
  60.566 -val t = TermC.str2term "(60 * a * b) / ( 15 * a  * b )";
  60.567 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.568 -if (UnparseC.term t', UnparseC.terms asm) = ("4 / 1", "[]")
  60.569 -then () else error "rational.sml cancel Schalk 186b";
  60.570 -
  60.571 -"-------- example 186c";
  60.572 -val t = TermC.str2term "(144 * a \<up> 2 * b * c) / (12 * a * b * c)";
  60.573 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.574 -if (UnparseC.term t', UnparseC.terms asm) = ("12 * a / 1", "[]")
  60.575 -then () else error "rational.sml cancel Schalk 186c";
  60.576 -
  60.577 -(* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! exception Div raised !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  60.578 -  see --- fun rewrite_set_ downto fun gcd_poly ---
  60.579 -"-------- example 187a";
  60.580 -val t = TermC.str2term "(12 * x * y) / (8 * y \<up> 2 )";
  60.581 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.582 -if (UnparseC.term t', UnparseC.terms asm) = ("3 * x / (2 * y)", "[\"4 * y ~= 0\"]")
  60.583 -then () else error "rational.sml cancel Schalk 187a";
  60.584 -*)
  60.585 -
  60.586 -(* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  60.587 -  see --- fun rewrite_set_ downto fun gcd_poly ---
  60.588 -"-------- example 187b";
  60.589 -val t = TermC.str2term "(8 * x \<up> 2 * y * z ) / (18 * x * y \<up> 2 * z )";
  60.590 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.591 -if (UnparseC.term t', UnparseC.terms asm) = ("4 * x / (9 * y)", "[\"2 * (z * (y * x)) ~= 0\"]")
  60.592 -then () else error "rational.sml cancel Schalk 187b";
  60.593 -*)
  60.594 -
  60.595 -(* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  60.596 -  see --- fun rewrite_set_ downto fun gcd_poly ---
  60.597 -"-------- example 187c";
  60.598 -val t = TermC.str2term "(9 * x \<up> 5 * y \<up> 2 * z \<up> 4) / (15 * x \<up> 6 * y \<up> 3 * z )";
  60.599 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.600 -if (UnparseC.term t', UnparseC.terms asm) = 
  60.601 -  ("3 * z \<up> 3 / (5 * (y * x))", "[\"3 * (z * (y \<up> 2 * x \<up> 5)) ~= 0\"]") 
  60.602 -then () else error "rational.sml cancel Schalk 187c";
  60.603 -*)
  60.604 -
  60.605 -"-------- example 188a";
  60.606 -val t = TermC.str2term "(-8 + 8 * x) / (-9 + 9 * x)";
  60.607 -  is_expanded (TermC.str2term "8 * x + -8");
  60.608 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.609 -if (UnparseC.term t', UnparseC.terms asm) = ("8 / 9", "[]")
  60.610 -then () else error "rational.sml cancel Schalk 188a";
  60.611 -
  60.612 -val t = TermC.str2term "(8*((-1) + x))/(9*((-1) + x))";
  60.613 -val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
  60.614 -if (UnparseC.term t', UnparseC.terms asm) = ("8 / 9", "[]")
  60.615 -then () else error "rational.sml cancel Schalk make_polynomial 1";
  60.616 -
  60.617 -"-------- example 188b";
  60.618 -val t = TermC.str2term "(-15 + 5 * x) / (-18 + 6 * x)";
  60.619 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.620 -if (UnparseC.term t', UnparseC.terms asm) = ("5 / 6", "[]")
  60.621 -then () else error "rational.sml cancel Schalk 188b";
  60.622 -
  60.623 -"-------- example 188c";
  60.624 -val t = TermC.str2term "(a + -1 * b) / (b + -1 * a)";
  60.625 -val SOME (t', asm) = rewrite_set_ thy false  cancel_p t;
  60.626 -if (UnparseC.term t', UnparseC.terms asm) = ("-1 / 1", "[]")
  60.627 -then () else error "rational.sml cancel Schalk 188c";
  60.628 -
  60.629 -is_expanded (TermC.str2term "a + -1 * b") = true;
  60.630 -val t = TermC.str2term "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
  60.631 -val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  60.632 -if (UnparseC.term t', UnparseC.terms asm) = ("(a + -1 * b) / (-1 * a + b)", "[]")
  60.633 -then () else error "rational.sml cancel Schalk make_polynomial 2";
  60.634 -
  60.635 -"-------- example 190a";
  60.636 -val t = TermC.str2term "( 27 * a \<up> 3 + 9 * a \<up> 2 + 3 * a + 1 ) / ( 27 * a \<up> 3 + 18 * a \<up> 2 + 3 * a )";
  60.637 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.638 -if (UnparseC.term t', UnparseC.terms asm) = 
  60.639 -  ("(1 + 9 * a \<up> 2) / (3 * a + 9 * a \<up> 2)", "[\"3 * a + 9 * a \<up> 2 \<noteq> 0\"]")
  60.640 -then () else error "rational.sml cancel Schalk 190a";
  60.641 -
  60.642 -"-------- example 190c";
  60.643 -val t = TermC.str2term "((1 + 9 * a \<up> 2)*(1 + 3 * a))/((3 * a + 9 * a \<up> 2)*(1 + 3 * a))";
  60.644 -val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  60.645 -if (UnparseC.term t', UnparseC.terms asm) = 
  60.646 -  ("(1 + 3 * a + 9 * a \<up> 2 + 27 * a \<up> 3) /\n(3 * a + 18 * a \<up> 2 + 27 * a \<up> 3)", "[]")
  60.647 -then () else error "rational.sml make_polynomial Schalk 190c";
  60.648 -
  60.649 -"-------- example 191a";
  60.650 -val t = TermC.str2term "( x \<up> 2 + -1 * y \<up> 2 ) / ( x + y )";
  60.651 -  is_expanded (TermC.str2term "x \<up> 2 + -1 * y \<up> 2") = false; (*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
  60.652 -  is_expanded (TermC.str2term "x + y") = true;
  60.653 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.654 -if (UnparseC.term t', UnparseC.terms asm) = ("(x + -1 * y) / 1", "[]")
  60.655 -then () else error "rational.sml make_polynomial Schalk 191a";
  60.656 -
  60.657 -"-------- example 191b";
  60.658 -val t = TermC.str2term "((x + (-1) * y)*(x + y))/((1)*(x + y))";
  60.659 -val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  60.660 -if (UnparseC.term t', UnparseC.terms asm) = ("(x \<up> 2 + -1 * y \<up> 2) / (x + y)", "[]")
  60.661 -then () else error "rational.sml make_polynomial Schalk 191b";
  60.662 -
  60.663 -"-------- example 191c";
  60.664 -val t = TermC.str2term "( 9 * x \<up> 2 + -30 * x + 25 ) / ( 9 * x \<up> 2 + -25 )";
  60.665 -  is_expanded (TermC.str2term "9 * x \<up> 2 + -30 * x + 25") = true;
  60.666 -  is_expanded (TermC.str2term "25 + -30*x + 9*x \<up> 2") = true;
  60.667 -  is_expanded (TermC.str2term "-25 + 9*x \<up> 2") = true;
  60.668 -
  60.669 -val t = TermC.str2term "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
  60.670 -val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  60.671 -if (UnparseC.term t', UnparseC.terms asm) = ("(25 + -30 * x + 9 * x \<up> 2) / (-25 + 9 * x \<up> 2)", "[]")
  60.672 -then () else error "rational.sml make_polynomial Schalk 191c";
  60.673 -
  60.674 -"-------- example 192b";
  60.675 -val t = TermC.str2term "( 7 * x \<up> 3 + -1 * x \<up> 2 * y ) / ( 7 * x * y \<up> 2 + -1 *  y \<up> 3 )";
  60.676 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.677 -if (UnparseC.term t', UnparseC.terms asm) = ("x \<up> 2 / y \<up> 2", "[\"y \<up> 2 \<noteq> 0\"]")
  60.678 -then () else error "rational.sml cancel_p Schalk 192b";
  60.679 -
  60.680 -val t = TermC.str2term "((x \<up> 2)*(7 * x + (-1) * y))/((y \<up> 2)*(7 * x + (-1) * y))";
  60.681 -val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  60.682 -if (UnparseC.term t', UnparseC.terms asm) = 
  60.683 -  ("(7 * x \<up> 3 + -1 * x \<up> 2 * y) / (7 * x * y \<up> 2 + -1 * y \<up> 3)", "[]")
  60.684 -then () else error "rational.sml make_polynomial Schalk 192b";
  60.685 -
  60.686 -val t = TermC.str2term "((x \<up> 2)*(7 * x + (-1) * y))/((y \<up> 2)*(7 * x + (-1) * y))";
  60.687 -val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
  60.688 -if (UnparseC.term t', UnparseC.terms asm) = 
  60.689 -  ("(7 * x \<up> 3 + -1 * x \<up> 2 * y) / (7 * x * y \<up> 2 + -1 * y \<up> 3)", "[]")
  60.690 -then () else error "rational.sml make_polynomial Schalk WN050929 not working";
  60.691 -
  60.692 -"-------- example 193a";
  60.693 -val t = TermC.str2term "( x \<up> 2 + -6 * x + 9 ) / ( x \<up> 2 + -9 )";
  60.694 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.695 -if (UnparseC.term t', UnparseC.terms asm) = ("(-3 + x) / (3 + x)", "[\"3 + x \<noteq> 0\"]")
  60.696 -then () else error "rational.sml cancel_p Schalk 193a";
  60.697 -
  60.698 -"-------- example 193b";
  60.699 -val t = TermC.str2term "( x \<up> 2 + -8 * x + 16 ) / ( 2 * x \<up> 2 + -32 )";
  60.700 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.701 -if (UnparseC.term t', UnparseC.terms asm) = ("(-4 + x) / (8 + 2 * x)", "[\"8 + 2 * x \<noteq> 0\"]")
  60.702 -then () else error "rational.sml cancel_p Schalk 193b";
  60.703 -
  60.704 -"-------- example 193c";
  60.705 -val t = TermC.str2term "( 2 * x + -50 * x \<up> 3 ) / ( 25 * x \<up> 2 + -10 * x + 1 )";
  60.706 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.707 -if (UnparseC.term t', UnparseC.terms asm) = 
  60.708 -  ("(2 * x + 10 * x \<up> 2) / (1 + -5 * x)", "[\"1 + -5 * x \<noteq> 0\"]")
  60.709 -then () else error "rational.sml cancel_p Schalk 193c";
  60.710 -
  60.711 -(*WN:*)
  60.712 -val t = TermC.str2term "(-25 + 9*x \<up> 2)/(5 + 3*x)";
  60.713 -val SOME (t, asm) = rewrite_set_ thy false cancel_p t;
  60.714 -if (UnparseC.term t', UnparseC.terms asm) = ("(2 * x + 10 * x \<up> 2) / (1 + -5 * x)", "[]")
  60.715 -then () else error "rational.sml cancel WN 1";
  60.716 -
  60.717 -"-------- example heuberger";
  60.718 -val t = TermC.str2term ("(x \<up> 4 + x * y + x \<up> 3 * y + y \<up> 2) / " ^
  60.719 -  "(x + 5 * x \<up> 2 + y + 5 * x * y + x \<up> 2 * y \<up> 3 + x * y \<up> 4)");
  60.720 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.721 -if (UnparseC.term t', UnparseC.terms asm) = 
  60.722 -  ("(x \<up> 3 + y) / (1 + 5 * x + x * y \<up> 3)", "[\"1 + 5 * x + x * y \<up> 3 \<noteq> 0\"]")
  60.723 -then () else error "rational.sml cancel_p heuberger";
  60.724 -
  60.725 -"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
  60.726 -"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
  60.727 -"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
  60.728 -(*deleted example 204 ... 236b at update Isabelle2012-->2013*)
  60.729 -
  60.730 -"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
  60.731 -"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
  60.732 -"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
  60.733 -val t = TermC.str2term ("123 = (a*x)/(b*x) + (c*x)/(d*x) + (e*x)/(f*x::real)");
  60.734 -"-------- gcd_poly integration level 1: works on exact term";
  60.735 -if NONE = cancel_p_ thy t then () else error "cancel_p_ works on exact fraction";
  60.736 -if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ works on exact fraction";
  60.737 -
  60.738 -"-------- gcd_poly integration level 2: picks out ONE appropriate subterm";
  60.739 -val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
  60.740 -if UnparseC.term t' = "123 = a * x / (b * x) + c * x / (d * x) + e / f" 
  60.741 -then () else error "level 2, rewrite_set_ cancel_p: changed";
  60.742 -val SOME (t', asm) = rewrite_set_ thy false add_fractions_p t;
  60.743 -if UnparseC.term t' = "123 = (b * c * x + a * d * x) / (b * d * x) + e * x / (f * x)"
  60.744 -then () else error "level 2, rewrite_set_ add_fractions_p: changed";
  60.745 -
  60.746 -"-------- gcd_poly integration level 3: rewrites all appropriate subterms";
  60.747 -val SOME (t', asm) = rewrite_set_ thy false cancel_p_rls t;
  60.748 -if UnparseC.term t' = "123 = a / b + c / d + e / f"
  60.749 -then () else error "level 3, rewrite_set_ cancel_p_rls: changed";
  60.750 -val SOME (t', asm) = rewrite_set_ thy false add_fractions_p_rls t; (*CREATE add_fractions_p_rls*)
  60.751 -if UnparseC.term t' = "123 = (b * d * e * x + b * c * f * x + a * d * f * x) / (b * d * f * x)"
  60.752 -then () else error "level 3, rewrite_set_ add_fractions_p_rls: changed";
  60.753 -
  60.754 -"-------- gcd_poly integration level 4: iteration cancel_p -- add_fraction_p";
  60.755 -(* simpler variant *)
  60.756 -val testrls = Rule_Set.append_rules "testrls" Rule_Set.empty [Rls_ cancel_p, Rls_ add_fractions_p]
  60.757 -val SOME (t', asm) = rewrite_set_ thy false testrls t;
  60.758 -(*Rewrite.trace_on := false;
  60.759 -#  rls: testrls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  60.760 -##  rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  60.761 -##  rls: add_fractions_p on: 123 = a * x / (b * x) + c * x / (d * x) + e / f 
  60.762 -##  rls: cancel_p on: 123 = (b * c * x + a * d * x) / (b * d * x) + e / f 
  60.763 -##  rls: add_fractions_p on: 123 = (b * c + a * d) / (b * d) + e / f 
  60.764 -##  rls: cancel_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  60.765 -##  rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) *)
  60.766 -if UnparseC.term t' = "123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)"
  60.767 -then () else error "level 4, rewrite_set_ *_p: changed";
  60.768 -
  60.769 -(* complicated variant *)
  60.770 -val testrls_rls = Rule_Set.append_rules "testrls_rls" Rule_Set.empty [Rls_ cancel_p_rls, Rls_ add_fractions_p_rls];
  60.771 -val SOME (t', asm) = rewrite_set_ thy false testrls_rls t;
  60.772 -(*#  rls: testrls_rls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  60.773 -##  rls: cancel_p_rls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  60.774 -###  rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x) 
  60.775 -###  rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e / f 
  60.776 -###  rls: cancel_p on: 123 = a * x / (b * x) + c / d + e / f 
  60.777 -###  rls: cancel_p on: 123 = a / b + c / d + e / f 
  60.778 -##  rls: add_fractions_p_rls on: 123 = a / b + c / d + e / f 
  60.779 -###  rls: add_fractions_p on: 123 = a / b + c / d + e / f 
  60.780 -###  rls: add_fractions_p on: 123 = (b * c + a * d) / (b * d) + e / f 
  60.781 -###  rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  60.782 -##  rls: cancel_p_rls on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  60.783 -###  rls: cancel_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  60.784 -##  rls: add_fractions_p_rls on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) 
  60.785 -###  rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) *)
  60.786 -if UnparseC.term t' = "123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)"
  60.787 -then () else error "level 4, rewrite_set_ *_p_rls: changed"
  60.788 -
  60.789 -"-------- gcd_poly integration level 5: cancel_p & add_fraction_p within norm_Rational";
  60.790 -val SOME (t', asm) = rewrite_set_ thy false norm_Rational t;
  60.791 -if UnparseC.term t' = "123 = (a * d * f + b * c * f + b * d * e) / (b * d * f)"
  60.792 -then () else error "level 5, rewrite_set_ norm_Rational: changed"
  60.793 -
  60.794 -"-------- reverse rewrite ----------------------------------------------------";
  60.795 -"-------- reverse rewrite ----------------------------------------------------";
  60.796 -"-------- reverse rewrite ----------------------------------------------------";
  60.797 -(** the term for which reverse rewriting is demonstrated **)
  60.798 -val t = TermC.str2term "(9 + -1 * x \<up> 2) / (9 + 6 * x + x \<up> 2)";
  60.799 -val Rrls {scr = Rfuns {init_state = ini, locate_rule = loc,
  60.800 -  next_rule = nex, normal_form = nor, ...},...} = cancel_p;
  60.801 -
  60.802 -(** normal_form produces the result in ONE step **)
  60.803 -  val SOME (t',_) = nor t;
  60.804 -if UnparseC.term t' = "(3 + -1 * x) / (3 + x)" then ()
  60.805 -else error "rational.sml normal_form (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2)";
  60.806 -
  60.807 -(** initialize the interpreter state used by the 'me' **)
  60.808 -  val (t, _, revsets, _) = ini t;
  60.809 -
  60.810 -if length (hd revsets) = 11 then () else error "length of revset changed";
  60.811 -if (revsets |> nth 1 |> nth 1 |> id_of_thm) = 
  60.812 -  (@{thm realpow_twoI} |> Thm.get_name_hint |> ThmC.cut_id)
  60.813 -then () else error "first element of revset changed";
  60.814 -if
  60.815 -(revsets |> nth 1 |> nth 1 |> Rule.to_string) = "Thm (\"realpow_twoI\",?r1 \<up> 2 = ?r1 * ?r1)" andalso
  60.816 -(revsets |> nth 1 |> nth 2 |> Rule.to_string) = "Thm (\"#: 9 = 3 \<up> 2\",9 = 3 \<up> 2)" andalso
  60.817 -(revsets |> nth 1 |> nth 3 |> Rule.to_string) = "Thm (\"#: 6 * x = 2 * (3 * x)\",6 * x = 2 * (3 * x))" 
  60.818 -andalso
  60.819 -(revsets |> nth 1 |> nth 4 |> Rule.to_string) = "Thm (\"#: -3 * x = -1 * (3 * x)\",-3 * x = -1 * (3 * x))" 
  60.820 -andalso
  60.821 -(revsets |> nth 1 |> nth 5 |> Rule.to_string) = "Thm (\"#: 9 = 3 * 3\",9 = 3 * 3)" andalso
  60.822 -(revsets |> nth 1 |> nth 6 |> Rule.to_string) = "Rls_ (\"sym_order_mult_rls_\")" andalso
  60.823 -(revsets |> nth 1 |> nth 7 |> Rule.to_string) = 
  60.824 -  "Thm (\"sym_mult.assoc\",?a * (?b * ?c) = ?a * ?b * ?c)"
  60.825 -then () else error "first 7 elements in revset changed"
  60.826 -
  60.827 -(** find the rule 'r' to apply to term 't' **)
  60.828 -(*/------- WN1309: since cancel_ (accepted "-" between monomials) has been replaced by cancel_p_ 
  60.829 -  for Isabelle2013, we don't get a working revset, but non-termination:
  60.830 -
  60.831 -  val SOME (r as (Thm (str, thm))) = nex revsets t;
  60.832 -  :
  60.833 -((3 * 3 + -1 * x * x) / (3 * 3 + 2 * 3 * x + x * x), 
  60.834 -  Rls_ ("sym_order_mult_rls_"), ((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x), []))", "
  60.835 -((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x), 
  60.836 -  Thm ("sym_mult.assoc", ""), ((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * 3 * x + x * x), []))", "
  60.837 -((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * 3 * x + x * x), 
  60.838 -  Thm ("sym_mult.assoc", ""), ((3 * 3 + -1 * x * x) / (3 * 3 + 2 * 3 * x + x * x), []))", "
  60.839 -((3 * 3 + -1 * x * x) / (3 * 3 + 2 * 3 * x + x * x), Rls_ ("sym_order_mult_rls_"), ((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x), []))", "
  60.840 - :
  60.841 -### Isabelle2002:
  60.842 -  Thm ("sym_#mult_2_3", "6 = 2 * 3")
  60.843 -### Isabelle2009-2 for cancel_ (not cancel_p_):
  60.844 -if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
  60.845 -   andalso ThmC.string_of_thm thm = 
  60.846 -           (string_of_thm (Thm.make_thm @{theory "Isac_Knowledge"}
  60.847 -               (Trueprop $ (Thm.term_of o the o (TermC.parse thy)) "9 = 3 \<up> 2"))) then ()
  60.848 -else error "rational.sml next_rule (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2)";
  60.849 -\---------------------------------------------------------------------------------------/*)
  60.850 -
  60.851 -(** check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
  60.852 -  if the rule is OK, the term resulting from applying the rule is returned,too;
  60.853 -  there might be several rule applications inbetween,
  60.854 -  which are listed after the head in reverse order **)
  60.855 -(*/-------------------------------------------- Isabelle2013: this gives "error id_of_thm";
  60.856 -  we don't repair this, because interaction within "reverse rewriting" never worked properly:
  60.857 -
  60.858 -  val (r, (t, asm))::_ = loc revsets t r;
  60.859 -if UnparseC.term t = "(9 - x \<up> 2) / (3 \<up> 2 + 6 * x + x \<up> 2)" andalso asm = []
  60.860 -then () else error "rational.sml locate_rule (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2)";
  60.861 -
  60.862 -(* find the next rule to apply *)
  60.863 -  val SOME (r as (Thm (str, thm))) = nex revsets t;
  60.864 -if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
  60.865 -   ThmC.string_of_thm thm = (string_of_thm (ThmC_Def.make_thm @{theory "Isac_Knowledge"}
  60.866 -                (Trueprop $ (Thm.term_of o the o (TermC.parse thy)) "9 = 3 \<up> 2"))) then ()
  60.867 -else error "rational.sml next_rule (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2)";
  60.868 -
  60.869 -(*check the next rule*)
  60.870 -  val (r, (t, asm)) :: _ = loc revsets t r;
  60.871 -if UnparseC.term t = "(3 \<up> 2 - x \<up> 2) / (3 \<up> 2 + 6 * x + x \<up> 2)" then ()
  60.872 -else error "rational.sml locate_rule (9 - x \<up> 2) / (9 - 6 * x + x \<up> 2) II";
  60.873 -
  60.874 -(*find and check the next rules, rewrite*)
  60.875 -  val SOME r = nex revsets t;
  60.876 -  val (r,(t,asm))::_ = loc revsets t r;
  60.877 -if UnparseC.term t = "(3 \<up> 2 - x \<up> 2) / (3 \<up> 2 + 2 * 3 * x + x \<up> 2)" then ()
  60.878 -else error "rational.sml locate_rule II";
  60.879 -
  60.880 -  val SOME r = nex revsets t;
  60.881 -  val (r,(t,asm))::_ = loc revsets t r;
  60.882 -if UnparseC.term t = "(3 - x) * (3 + x) / (3 \<up> 2 + 2 * 3 * x + x \<up> 2)" then ()
  60.883 -else error "rational.sml next_rule II";
  60.884 -
  60.885 -  val SOME r = nex revsets t;
  60.886 -  val (r,(t,asm))::_ = loc revsets t r;
  60.887 -if UnparseC.term t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
  60.888 -else error "rational.sml next_rule III";
  60.889 -
  60.890 -  val SOME r = nex revsets t;
  60.891 -  val (r, (t, asm)) :: _ = loc revsets t r;
  60.892 -  val ss = UnparseC.term t;
  60.893 -if ss = "(3 - x) / (3 + x)" andalso UnparseC.terms asm = "[\"3 + x ~= 0\"]" then ()
  60.894 -else error "rational.sml: new behav. in rev-set cancel";
  60.895 -\--------------------------------------------------------------------------------------/*)
  60.896 -
  60.897 -"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
  60.898 -"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
  60.899 -"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
  60.900 -(*WN130909: the example below shows, why "reverse rewriting" only worked for
  60.901 -  special cases.*)
  60.902 -
  60.903 -(*the term for which reverse rewriting is demonstrated*)
  60.904 -val t = TermC.str2term "(9 + (-1)*x \<up> 2) / (9 + ((-6)*x + x \<up> 2))";
  60.905 -val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
  60.906 -		       next_rule=nex,normal_form=nor,...},...} = cancel_p;
  60.907 -
  60.908 -(*normal_form produces the result in ONE step*)
  60.909 -val SOME (t',_) = nor t; 
  60.910 -UnparseC.term t' = "(3 + 1 * x) / (3 + -1 * x)";
  60.911 -
  60.912 -(*initialize the interpreter state used by the 'me'*)
  60.913 -val SOME (t', asm) = cancel_p_ thy t;
  60.914 -UnparseC.term t' = "(3 + x) / (3 + -1 * x)" (*true*);
  60.915 -UnparseC.terms asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
  60.916 -val (t,_,revsets,_) = ini t;
  60.917 -
  60.918 -(* WN.10.10.02: dieser Fall terminiert nicht 
  60.919 -           (make_polynomial enth"alt zu viele rules)
  60.920 -WN060823 'init_state' requires rewriting on specified location in the term
  60.921 -default_print_depth 99; Rfuns; default_print_depth 3;
  60.922 -WN060831 cycling "sym_order_mult_rls_" "sym_mult.assoc"
  60.923 -         as was with make_polynomial before ?!?*)
  60.924 -
  60.925 -val SOME r = nex revsets t;
  60.926 -eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))", 
  60.927 -		mk_thm thy "9 = 3 \<up> 2"));
  60.928 -(*WN060831 *** id_of_thm
  60.929 -           Exception- ERROR raised ...
  60.930 -val (r,(t,asm))::_ = loc revsets t r;
  60.931 -UnparseC.term t;
  60.932 -
  60.933 -  val SOME r = nex revsets t;
  60.934 -  val (r,(t,asm))::_ = loc revsets t r;
  60.935 -  UnparseC.term t;
  60.936 -*)                    
  60.937 -
  60.938 -"-------- examples: rls norm_Rational ----------------------------------------";
  60.939 -"-------- examples: rls norm_Rational ----------------------------------------";
  60.940 -"-------- examples: rls norm_Rational ----------------------------------------";
  60.941 -val t = TermC.str2term "(3*x+5)/18 - x/2  - -(3*x - 2)/9 = 0";
  60.942 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.943 -if UnparseC.term t' = "1 / 18 = 0" then () else error "rational.sml 1";
  60.944 -
  60.945 -val t = TermC.str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
  60.946 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.947 -if UnparseC.term t' = "(237 + 65 * x) / 36 = 0" then () 
  60.948 -else error "rational.sml 2";
  60.949 -
  60.950 -val t = TermC.str2term "(1/2 + (5*x)/2) \<up> 2 - ((13*x)/2 - 5/2) \<up> 2 - (6*x) \<up> 2 + 29";
  60.951 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.952 -if UnparseC.term t' = "23 + 35 * x + -72 * x \<up> 2" then ()
  60.953 -else error "rational.sml 3";
  60.954 -
  60.955 -(*Rewrite.trace_on:=true;*)
  60.956 -val t = TermC.str2term "Not (6*x is_atom)";
  60.957 -val SOME (t',_) = rewrite_set_ thy false powers_erls t; UnparseC.term t';
  60.958 -\<^const_name>\<open>True\<close>;
  60.959 -val t = TermC.str2term "1 < 2";
  60.960 -val SOME (t',_) = rewrite_set_ thy false powers_erls t; UnparseC.term t';
  60.961 -\<^const_name>\<open>True\<close>;
  60.962 -
  60.963 -val t = TermC.str2term "(6*x) \<up> 2";
  60.964 -val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false 
  60.965 -			   (ThmC.numerals_to_Free @{thm realpow_def_atom}) t;
  60.966 -if UnparseC.term t' = "6 * x * (6 * x) \<up> (2 + -1)" then ()
  60.967 -else error "rational.sml powers_erls (6*x) \<up> 2";
  60.968 -
  60.969 -val t = TermC.str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
  60.970 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.971 -if UnparseC.term t' = "65 * x / 2" then () else error "rational.sml 4";
  60.972 -
  60.973 -val t = TermC.str2term "1 - ((13*x)/2 - 5/2) \<up> 2";
  60.974 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.975 -if UnparseC.term t' = "(-21 + 130 * x + -169 * x \<up> 2) / 4" then () 
  60.976 -else error "rational.sml 5";
  60.977 -
  60.978 -(*SRAM Schalk I, p.92 Nr. 609a*)
  60.979 -val t = TermC.str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
  60.980 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.981 -if UnparseC.term t' = "(-255 + 112 * x) / 135" then () 
  60.982 -else error "rational.sml 6";
  60.983 -
  60.984 -(*SRAM Schalk I, p.92 Nr. 610c*)
  60.985 -val t = TermC.str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
  60.986 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.987 -if UnparseC.term t' = "(3 + x) / -2" then () else error "rational.sml 7";
  60.988 -
  60.989 -(*SRAM Schalk I, p.92 Nr. 476a*)
  60.990 -val t = TermC.str2term "(x \<up> 2/(1 - x \<up> 2) + 1)/(x/(1 - x) + 1) * (1 + x)";
  60.991 -(*. a/b : c/d translated to a/b * d/c .*)
  60.992 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.993 -if UnparseC.term t' = "1" then () else error "rational.sml 8";
  60.994 -
  60.995 -(*Schalk I, p.92 Nr. 472a*)
  60.996 -val t = TermC.str2term "((8*x \<up> 2 - 32*y \<up> 2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
  60.997 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
  60.998 -if UnparseC.term t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
  60.999 -
 60.1000 -(*Schalk I, p.70 Nr. 480b: SEE rational.sml --- nonterminating rls norm_Rational ---*)
 60.1001 -
 60.1002 -(*WN130910 add_fractions_p exception Div raised + history:
 60.1003 -### WN.2.6.03 from rlang.sml 56a 
 60.1004 -val t = TermC.str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a \<up> 2 + -1 * b \<up> 2)";
 60.1005 -val NONE = rewrite_set_ thy false add_fractions_p t;
 60.1006 -
 60.1007 -THE ERROR ALREADY OCCURS IN THIS PART:
 60.1008 -val t = TermC.str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
 60.1009 -val NONE = add_fraction_p_ thy t;
 60.1010 -
 60.1011 -SEE Test_Some.thy: section {* add_fractions_p downto exception Div raised ===
 60.1012 -*)
 60.1013 -
 60.1014 -"-------- rational numerals --------------------------------------------------";
 60.1015 -"-------- rational numerals --------------------------------------------------";
 60.1016 -"-------- rational numerals --------------------------------------------------";
 60.1017 -(*SRA Schalk I, p.40 Nr. 164b *)
 60.1018 -val t = TermC.str2term "(47/6 - 76/9 + 13/4)/(35/12)";
 60.1019 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1020 -UnparseC.term t;
 60.1021 -if UnparseC.term t = "19 / 21" then ()
 60.1022 -else error "rational.sml: diff.behav. in norm_Rational_mg 1";
 60.1023 -
 60.1024 -(*SRA Schalk I, p.40 Nr. 166a *)
 60.1025 -val t = TermC.str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
 60.1026 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1027 -UnparseC.term t;
 60.1028 -if UnparseC.term t = "45 / 2" then ()
 60.1029 -else error "rational.sml: diff.behav. in norm_Rational_mg 2";
 60.1030 -
 60.1031 -"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
 60.1032 -"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
 60.1033 -"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
 60.1034 -(* e190c Stefan K.*)
 60.1035 -val t = TermC.str2term "((1 + 9*a \<up> 2) * (1 + 3*a)) / ((3*a + 9*a \<up> 2) * (1 + 3*a))";
 60.1036 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1037 -if UnparseC.term t = "(1 + 9 * a \<up> 2) / (3 * a + 9 * a \<up> 2)"
 60.1038 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 3";
 60.1039 -
 60.1040 -(* e192b Stefan K.*)
 60.1041 -val t = TermC.str2term "(x \<up> 2 * (7*x + (-1)*y))  /  (y \<up> 2 * (7*x + (-1)*y))";
 60.1042 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1043 -if UnparseC.term t = "x \<up> 2 / y \<up> 2"
 60.1044 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 4";
 60.1045 -
 60.1046 -(*SRC Schalk I, p.66 Nr. 379c *)
 60.1047 -val t = TermC.str2term "(a - b)/(b - a)";
 60.1048 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1049 -UnparseC.term t;
 60.1050 -if UnparseC.term t = "-1"
 60.1051 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 5";
 60.1052 -
 60.1053 -(*SRC Schalk I, p.66 Nr. 380b *)
 60.1054 -val t = TermC.str2term "15*(3*x + 3) * (4*x + 9)  /  (12*(2*x + 7) * (5*x + 5))";
 60.1055 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1056 -if UnparseC.term t = "(27 + 12 * x) / (28 + 8 * x)"
 60.1057 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 6";
 60.1058 -
 60.1059 -(*Schalk I, p.60 Nr. 215c: was not cancelled with Isabelle2002 *)
 60.1060 -val t = TermC.str2term "(a + b) \<up> 4 * (x - y)  /  ((x - y) \<up> 3 * (a + b) \<up> 2)";
 60.1061 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1062 -if UnparseC.term t = "(a \<up> 2 + 2 * a * b + b \<up> 2) / (x \<up> 2 + -2 * x * y + y \<up> 2)"
 60.1063 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 7";
 60.1064 -
 60.1065 -(*SRC Schalk I, p.66 Nr. 381b *)
 60.1066 -val t = TermC.str2term 
 60.1067 -"(4*x \<up> 2 - 20*x + 25)/(2*x - 5) \<up> 3";
 60.1068 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1069 -if UnparseC.term t = "1 / (-5 + 2 * x)"
 60.1070 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 9";
 60.1071 -
 60.1072 -(* e190c Stefan K.*)
 60.1073 -val t = TermC.str2term "((1 + 9*a \<up> 2) * (1 + 3*a))  /  ((3*a + 9*a \<up> 2) * (1 + 3 * a))";
 60.1074 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1075 -if UnparseC.term t =  "(1 + 9 * a \<up> 2) / (3 * a + 9 * a \<up> 2)"
 60.1076 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 3";
 60.1077 -
 60.1078 -(* e192b Stefan K.*)
 60.1079 -val t = TermC.str2term "(x \<up> 2 * (7*x + (-1)*y))  /  (y \<up> 2 * (7*x + (-1)*y))";
 60.1080 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1081 -if UnparseC.term t = "x \<up> 2 / y \<up> 2"
 60.1082 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 4";
 60.1083 -
 60.1084 -(*SRC Schalk I, p.66 Nr. 379c *)
 60.1085 -val t = TermC.str2term "(a - b) / (b - a)";
 60.1086 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1087 -if UnparseC.term t = "-1"
 60.1088 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 5";
 60.1089 -
 60.1090 -(*SRC Schalk I, p.66 Nr. 380b *)
 60.1091 -val t = TermC.str2term "15*(3*x + 3) * (4*x + 9)  /  (12*(2*x + 7) * (5*x + 5))";
 60.1092 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1093 -if UnparseC.term t = "(27 + 12 * x) / (28 + 8 * x)"
 60.1094 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 6";
 60.1095 -
 60.1096 -(*Schalk I, p.60 Nr. 215c *)
 60.1097 -val t = TermC.str2term "(a + b) \<up> 4 * (x - y)  /  ((x - y) \<up> 3 * (a + b) \<up> 2)";
 60.1098 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1099 -if UnparseC.term t = "(a \<up> 2 + 2 * a * b + b \<up> 2) / (x \<up> 2 + -2 * x * y + y \<up> 2)"
 60.1100 -then () else error "Schalk I, p.60 Nr. 215c: with Isabelle2002 cancellation incomplete, changed";
 60.1101 -
 60.1102 -(* extreme example from somewhere *)
 60.1103 -val t = TermC.str2term 
 60.1104 -    ("(a \<up> 4 * x  +  -1*a \<up> 4 * y  +  4*a \<up> 3 * b * x  +  -4*a \<up> 3 * b * y  + " ^
 60.1105 -      "6*a \<up> 2 * b \<up> 2 * x  +  -6*a \<up> 2 * b \<up> 2 * y  +  4*a * b \<up> 3 * x  +  -4*a * b \<up> 3 * y  + " ^
 60.1106 -      "b \<up> 4 * x  +  -1*b \<up> 4 * y) " ^
 60.1107 -  " / (a \<up> 2 * x \<up> 3  +  -3*a \<up> 2 * x \<up> 2 * y  +  3*a \<up> 2 * x * y \<up> 2  +  -1*a \<up> 2 * y \<up> 3 + " ^
 60.1108 -      "2*a * b * x \<up> 3  +  -6*a * b * x \<up> 2 * y  +  6*a * b * x * y \<up> 2  +  -2*a * b * y \<up> 3 + " ^
 60.1109 -      "b \<up> 2 * x \<up> 3  +  -3*b \<up> 2 * x \<up> 2 * y  +  3*b \<up> 2 * x * y \<up> 2  +  -1*b \<up> 2 * y \<up> 3)")
 60.1110 -val SOME (t, _) = rewrite_set_ thy false cancel_p t;
 60.1111 -if UnparseC.term t = "(a \<up> 2 + 2 * a * b + b \<up> 2) / (x \<up> 2 + -2 * x * y + y \<up> 2)"
 60.1112 -then () else error "with Isabelle2002: NONE -- now SOME changed";
 60.1113 -
 60.1114 -(*Schalk I, p.66 Nr. 381a *)
 60.1115 -(* ATTENTION: here the rls is very slow. In Isabelle2002 this required 2 min *)
 60.1116 -val t = TermC.str2term "18*(a + b) \<up> 3 * (a - b) \<up> 2 / (72*(a - b) \<up> 3 * (a + b) \<up> 2)";
 60.1117 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1118 -if UnparseC.term t = "(a + b) / (4 * a + -4 * b)"
 60.1119 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
 60.1120 -
 60.1121 -(*SRC Schalk I, p.66 Nr. 381b *)
 60.1122 -val t = TermC.str2term "(4*x \<up> 2 - 20*x + 25) / (2*x - 5) \<up> 3";
 60.1123 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1124 -if UnparseC.term t = "1 / (-5 + 2 * x)"
 60.1125 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 9";
 60.1126 -
 60.1127 -(*SRC Schalk I, p.66 Nr. 381c *)
 60.1128 -val t = TermC.str2term "(27*a \<up> 3 + 9*a \<up> 2+3*a+1) / (27*a \<up> 3 + 18*a \<up> 2+3*a)";
 60.1129 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1130 -if UnparseC.term t = "(1 + 9 * a \<up> 2) / (3 * a + 9 * a \<up> 2)"
 60.1131 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 10";
 60.1132 -
 60.1133 -(*SRC Schalk I, p.66 Nr. 383a *)
 60.1134 -val t = TermC.str2term "(5*a \<up> 2 - 5*a*b) / (a - b) \<up> 2";
 60.1135 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1136 -if UnparseC.term t = "-5 * a / (-1 * a + b)"
 60.1137 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 11";
 60.1138 -
 60.1139 -"----- NOT TERMINATING ?: worked before 0707xx";
 60.1140 -val t = TermC.str2term "(a \<up> 2 - 1)*(b + 1) / ((b \<up> 2 - 1)*(a+1))";
 60.1141 -(* WN130911 "exception Div raised" by 
 60.1142 -  cancel_p_ thy (TermC.str2term ("(-1 + -1 * b + a \<up> 2 + a \<up> 2 * b) /" ^
 60.1143 -                           "(-1 + -1 * a + b \<up> 2 + a * b \<up> 2)"))
 60.1144 -
 60.1145 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1146 -if UnparseC.term t = "(1 + -1 * a) / (1 + -1 * b)" then ()
 60.1147 -else error "rational.sml MG tests 3e";
 60.1148 -*)
 60.1149 -
 60.1150 -"-------- examples common denominator from: Mathematik 1 Schalk --------------";
 60.1151 -"-------- examples common denominator from: Mathematik 1 Schalk --------------";
 60.1152 -"-------- examples common denominator from: Mathematik 1 Schalk --------------";
 60.1153 -(*SRA Schalk I, p.67 Nr. 403a *)
 60.1154 -val t = TermC.str2term "4/x - 3/y - 1";
 60.1155 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1156 -if UnparseC.term t = "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
 60.1157 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 12";
 60.1158 -
 60.1159 -val t = TermC.str2term "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a \<up> 2+3*b*c)/(a*b*c)";
 60.1160 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1161 -if UnparseC.term t = "4 / c"
 60.1162 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 13";
 60.1163 -
 60.1164 -(*SRA Schalk I, p.67 Nr. 410b *)
 60.1165 -val t = TermC.str2term "1/(x+1) + 1/(x+2) - 2/(x+3)";
 60.1166 -(* WN130911 non-termination due to non-termination of
 60.1167 -  cancel_p_ thy (TermC.str2term "(5 + 3 * x) / (6 + 11 * x + 6 * x \<up> 2 + x \<up> 3)")
 60.1168 -
 60.1169 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1170 -if UnparseC.term t = "(5 + 3 * x) / (6 + 11 * x + 6 * x \<up> 2 + x \<up> 3)"
 60.1171 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 14";
 60.1172 -*)
 60.1173 -
 60.1174 -(*SRA Schalk I, p.67 Nr. 413b *)
 60.1175 -val t = TermC.str2term "(1 + x)/(1 - x)  -  (1 - x)/(1 + x)  +  2*x/(1 - x \<up> 2)";
 60.1176 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1177 -if UnparseC.term t = "6 * x / (1 + -1 * x \<up> 2)"
 60.1178 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 15";
 60.1179 -
 60.1180 -(*SRA Schalk I, p.68 Nr. 414a *)
 60.1181 -val t = TermC.str2term "(x + 2)/(x - 1)  +  (x - 3)/(x - 2)  -  (x + 1)/((x - 1)*(x - 2))";
 60.1182 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1183 -if UnparseC.term t ="(-2 + -5 * x + 2 * x \<up> 2) / (2 + -3 * x + x \<up> 2)"
 60.1184 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 16";
 60.1185 -
 60.1186 -(*SRA Schalk I, p.68 Nr. 428b *)
 60.1187 -val t = TermC.str2term 
 60.1188 -  "1/(a - b) \<up> 2  +  1/(a + b) \<up> 2  -  2/(a \<up> 2 - b \<up> 2)  -  4*(b \<up> 2 - 1)/(a \<up> 2 - b \<up> 2) \<up> 2";
 60.1189 -(* WN130911 non-termination due to non-termination of
 60.1190 -  cancel_p_ thy (TermC.str2term "(4 + -4 * b \<up> 2) / (a \<up> 4 + -2 * (a \<up> 2 * b \<up> 2) + b \<up> 4)")
 60.1191 -
 60.1192 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1193 -if UnparseC.term t = "4 / (a \<up> 4 + -2 * a \<up> 2 * b \<up> 2 + b \<up> 4)"
 60.1194 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 18";
 60.1195 -*)
 60.1196 -
 60.1197 -(*SRA Schalk I, p.68 Nr. 430b *)
 60.1198 -val t = TermC.str2term 
 60.1199 -  "a \<up> 2/(a - 3*b) - 108*a*b \<up> 3/((a+3*b)*(a \<up> 2 - 9*b \<up> 2)) - 9*b \<up> 2*(a - 3*b)/(a+3*b) \<up> 2";
 60.1200 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1201 -if UnparseC.term t = "a + 3 * b"
 60.1202 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 19";
 60.1203 -
 60.1204 -(*SRA Schalk I, p.68 Nr. 432 *)
 60.1205 -val t = TermC.str2term 
 60.1206 -  ("(a \<up> 2 + a*b) / (a \<up> 2 - b \<up> 2)  -  (b \<up> 2 - a*b) / (b \<up> 2 - a \<up> 2)  +  " ^
 60.1207 -  "a \<up> 2*(a - b) / (a \<up> 3 - a \<up> 2*b)  -  2*a*(a \<up> 2 - b \<up> 2) / (a \<up> 3 - a*b \<up> 2)  -  " ^
 60.1208 -  "2*b \<up> 2 / (a \<up> 2 - b \<up> 2)");
 60.1209 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1210 -if UnparseC.term t = (*"0" ..isabisac15 | Isabelle2017..*)  "0 / (a \<up> 2 + -1 * b \<up> 2)"
 60.1211 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 20";
 60.1212 -
 60.1213 -(* some example *)
 60.1214 -val t = TermC.str2term "3*a / (a*b)  +  x/y";
 60.1215 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1216 -if UnparseC.term t = "(3 * y + b * x) / (b * y)"
 60.1217 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 21";
 60.1218 -
 60.1219 -"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
 60.1220 -"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
 60.1221 -"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
 60.1222 -(*------- SRM Schalk I, p.68 Nr. 436a *)
 60.1223 -val t = TermC.str2term "3*(x+y) / (15*(x - y))  *   25*(x - y) \<up> 2 / (18*(x + y) \<up> 2)";
 60.1224 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1225 -if UnparseC.term t = "(-5 * x + 5 * y) / (-18 * x + -18 * y)"
 60.1226 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 22";
 60.1227 -
 60.1228 -(*------- SRM.test Schalk I, p.68 Nr. 436b *)
 60.1229 -val t = TermC.str2term "5*a*(a - b) \<up> 2*(a + b) \<up> 3/(7*b*(a - b) \<up> 3) * 7*b/(a + b) \<up> 3";
 60.1230 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1231 -if UnparseC.term t = "5 * a / (a + -1 * b)"
 60.1232 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 23";
 60.1233 -
 60.1234 -(*------- Schalk I, p.68 Nr. 437a *)
 60.1235 -val t = TermC.str2term "(3*a - 4*b) / (4*c+3*e)  *  (3*a+4*b)/(9*a \<up> 2 - 16*b \<up> 2)";
 60.1236 -(* raises an exception for unclear reasons:
 60.1237 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1238 -:
 60.1239 -###  rls: cancel_p on: (9 * a \<up> 2 + -16 * b \<up> 2) / (4 * c + 3 * e) /
 60.1240 -(9 * a \<up> 2 + -16 * b \<up> 2) 
 60.1241 -exception Div raised
 60.1242 -
 60.1243 -BUT
 60.1244 -val t = TermC.str2term 
 60.1245 -  ("(9 * a \<up> 2 + -16 * b \<up> 2) / (4 * c + 3 * e) /" ^
 60.1246 -  "(9 * a \<up> 2 + -16 * b \<up> 2)");
 60.1247 -NONE = cancel_p_ thy t;
 60.1248 -
 60.1249 -if UnparseC.term t = "1 / (4 * c + 3 * e)" then ()
 60.1250 -else error "rational.sml: diff.behav. in norm_Rational_mg 24";
 60.1251 -*)
 60.1252 -
 60.1253 -"----- S.K. corrected non-termination 060904";
 60.1254 -val t = TermC.str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a \<up> 2 - 16*b \<up> 2))";
 60.1255 -val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
 60.1256 -if UnparseC.term t = 
 60.1257 -  "(9 * a \<up> 2 + -16 * b \<up> 2) /\n(36 * a \<up> 2 * c + 27 * a \<up> 2 * e + -64 * b \<up> 2 * c +\n -48 * b \<up> 2 * e)"
 60.1258 -(*"(9 * a \<up> 2 + -16 * b \<up> 2) / (36 * a \<up> 2 * c + 27 * a \<up> 2 * e + -64 * b \<up> 2 * c + -48 * b \<up> 2 * e)"*)
 60.1259 -then () else error "rational.sml: S.K.8..corrected 060904-6";
 60.1260 -
 60.1261 -"----- S.K. corrected non-termination of cancel_p_";
 60.1262 -val t'' = TermC.str2term ("(9 * a \<up> 2 + -16 * b \<up> 2) /" ^
 60.1263 -  "(36 * a \<up> 2 * c + (27 * a \<up> 2 * e + (-64 * b \<up> 2 * c + -48 * b \<up> 2 * e)))");
 60.1264 -(* /--- DOES NOT TERMINATE AT TRANSITION isabisac15 --> Isabelle2017 --------------------------\
 60.1265 -val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
 60.1266 -if UnparseC.term t' = "1 / (4 * c + 3 * e)"
 60.1267 -then () else error "rational.sml: diff.behav. in cancel_p S.K.8";
 60.1268 -   \--- DOES NOT TERMINATE AT TRANSITION isabisac15 --> Isabelle2017 --------------------------/*)
 60.1269 -
 60.1270 -(*------- Schalk I, p.68 Nr. 437b*)
 60.1271 -val t = TermC.str2term "(a + b)/(x \<up> 2 - y \<up> 2) * ((x - y) \<up> 2/(a \<up> 2 - b \<up> 2))";
 60.1272 -(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1273 -:
 60.1274 -####  rls: cancel_p on: (a * x \<up> 2 + -2 * (a * (x * y)) + a * y \<up> 2 + b * x \<up> 2 +
 60.1275 - -2 * (b * (x * y)) +
 60.1276 - b * y \<up> 2) /
 60.1277 -(a \<up> 2 * x \<up> 2 + -1 * (a \<up> 2 * y \<up> 2) + -1 * (b \<up> 2 * x \<up> 2) +
 60.1278 - b \<up> 2 * y \<up> 2) 
 60.1279 -exception Div raised
 60.1280 -*)
 60.1281 -
 60.1282 -(*------- SRM Schalk I, p.68 Nr. 438a *)
 60.1283 -val t = TermC.str2term "x*y / (x*y - y \<up> 2)  *  (x \<up> 2 - x*y)";
 60.1284 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1285 -if UnparseC.term t = "x \<up> 2"
 60.1286 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 24";
 60.1287 -
 60.1288 -(*------- SRM Schalk I, p.68 Nr. 439b *)
 60.1289 -val t = TermC.str2term "(4*x \<up> 2 + 4*x + 1)  *  ((x \<up> 2 - 2*x \<up> 3) / (4*x \<up> 2 + 2*x))";
 60.1290 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1291 -if UnparseC.term t = "(x + -4 * x \<up> 3) / 2"
 60.1292 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 25";
 60.1293 -
 60.1294 -(*------- SRM Schalk I, p.68 Nr. 440a *)
 60.1295 -val t = TermC.str2term "(x \<up> 2 - 2*x) / (x \<up> 2 - 3*x)  *  (x - 3) \<up> 2 / (x \<up> 2 - 4)";
 60.1296 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1297 -if UnparseC.term t = "(-3 + x) / (2 + x)"
 60.1298 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 26";
 60.1299 -
 60.1300 -"----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
 60.1301 -val t = TermC.str2term "(a \<up> 3 - 9*a) / (a \<up> 3*b - a*b \<up> 3)  *  (a \<up> 2*b + a*b \<up> 2) / (a+3)";
 60.1302 -(* WN130911 non-termination for unclear reasons:
 60.1303 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1304 -
 60.1305 -... ENDS WITH THIS TRACE:
 60.1306 -:
 60.1307 -###  rls: cancel_p on: (-9 * (a \<up> 3 * b) + -9 * (a \<up> 2 * b \<up> 2) + a \<up> 5 * b +
 60.1308 - a \<up> 4 * b \<up> 2) /
 60.1309 -(a \<up> 3 * b + -1 * (a * b \<up> 3)) /
 60.1310 -(3 + a)
 60.1311 -BUT THIS IS CORRECTLY RECOGNISED 
 60.1312 -val t = TermC.str2term 
 60.1313 -  ("(-9 * (a \<up> 3 * b) + -9 * (a \<up> 2 * b \<up> 2) + a \<up> 5 * b + a \<up> 4 * b \<up> 2)  /" ^
 60.1314 -  "(a \<up> 3 * b + -1 * (a * b \<up> 3))  /  (3 + (a::real))");
 60.1315 -AS
 60.1316 -NONE = cancel_p_ thy t;
 60.1317 -
 60.1318 -if UnparseC.term t = "(-3 * a + a \<up> 2) / (a + -1 * b)" then ()
 60.1319 -else error "rational.sml: diff.behav. in norm_Rational 27";
 60.1320 -*)
 60.1321 -
 60.1322 -"----- SK12 works since 0707xx";
 60.1323 -val t = TermC.str2term "(a \<up> 3 - 9*a) * (a \<up> 2*b+a*b \<up> 2)  /  ((a \<up> 3*b - a*b \<up> 3) * (a+3))";
 60.1324 -(* WN130911 non-termination due to non-termination of
 60.1325 -  cancel_p_ thy (TermC.str2term "(4 + -4 * b \<up> 2) / (a \<up> 4 + -2 * (a \<up> 2 * b \<up> 2) + b \<up> 4)")
 60.1326 -
 60.1327 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1328 -if UnparseC.term t' = "(-3 * a + a \<up> 2) / (a + -1 * b)" then ()
 60.1329 -else error "rational.sml: diff.behav. in norm_Rational 28";
 60.1330 -*)
 60.1331 -
 60.1332 -"-------- examples common denominator and multiplication from: Schalk --------";
 60.1333 -"-------- examples common denominator and multiplication from: Schalk --------";
 60.1334 -"-------- examples common denominator and multiplication from: Schalk --------";
 60.1335 -(*------- SRAM Schalk I, p.69 Nr. 441b *)
 60.1336 -val t = TermC.str2term "(4*a/3 + 3*b \<up> 2/a \<up> 3 + b/(4*a))*(4*b/(3*a))";
 60.1337 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1338 -if UnparseC.term t = "(36 * b \<up> 3 + 3 * a \<up> 2 * b \<up> 2 + 16 * a \<up> 4 * b) / (9 * a \<up> 4)"
 60.1339 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
 60.1340 -
 60.1341 -(*------- SRAM Schalk I, p.69 Nr. 442b *)
 60.1342 -val t = TermC.str2term ("(15*a \<up> 2/x \<up> 3 - 5*b \<up> 4/x \<up> 2 + 25*c \<up> 2/x) * " ^
 60.1343 -  "(x \<up> 3/(5*a*b \<up> 3*c \<up> 3)) + 1/c \<up> 3 * (b*x/a - 3*a/b \<up> 3)");
 60.1344 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1345 -if UnparseC.term t = "5 * x \<up> 2 / (a * b \<up> 3 * c)"
 60.1346 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
 60.1347 -
 60.1348 -(*------- SRAM Schalk I, p.69 Nr. 443b *)
 60.1349 -val t = TermC.str2term "(a/2 + b/3) * (b/3 - a/2)";
 60.1350 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1351 -if UnparseC.term t = "(-9 * a \<up> 2 + 4 * b \<up> 2) / 36"
 60.1352 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
 60.1353 -
 60.1354 -(*------- SRAM Schalk I, p.69 Nr. 445b *)
 60.1355 -val t = TermC.str2term "(a \<up> 2/9 + 2*a/(3*b) + 4/b \<up> 2)*(a/3 - 2/b) + 8/b \<up> 3";
 60.1356 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1357 -if UnparseC.term t = "a \<up> 3 / 27"
 60.1358 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
 60.1359 -
 60.1360 -(*------- SRAM Schalk I, p.69 Nr. 446b *)
 60.1361 -val t = TermC.str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x \<up> 2 - 16*y \<up> 2)";
 60.1362 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1363 -if UnparseC.term t = (*"30 * x \<up> 2 + -9 * x * y + -20 * y \<up> 2" ..isabisac15 | Isabelle2017..*)
 60.1364 -                  "(-30 * x \<up> 2 + 9 * x * y + 20 * y \<up> 2) / -1"
 60.1365 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 32";
 60.1366 -
 60.1367 -(*------- SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
 60.1368 -val t = TermC.str2term 
 60.1369 -"(2*x \<up> 2/(3*y)+x/y \<up> 2)*(4*x \<up> 4/(9*y \<up> 2)+x \<up> 2/y \<up> 4)*(2*x \<up> 2/(3*y) - x/y \<up> 2)";
 60.1370 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1371 -if UnparseC.term t = "(-81 * x \<up> 4 + 16 * x \<up> 8 * y \<up> 4) / (81 * y \<up> 8)"
 60.1372 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
 60.1373 -
 60.1374 -(*------- SRAM Schalk I, p.69 Nr. 450a *)
 60.1375 -val t = TermC.str2term 
 60.1376 -"(4*x/(3*y)+2*y/(3*x)) \<up> 2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
 60.1377 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1378 -if UnparseC.term t = "(52 * x \<up> 2 + 16 * y \<up> 2) / (9 * y \<up> 2)"
 60.1379 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 34";
 60.1380 -
 60.1381 -(*------- SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
 60.1382 -val t = TermC.str2term 
 60.1383 -  ("(15*a \<up> 4/(a*x \<up> 3)  -  5*a*((b \<up> 4 - 5*c \<up> 2*x) / x \<up> 2))  *  " ^
 60.1384 -  "(x \<up> 3/(5*a*b \<up> 3*c \<up> 3))   +   a/c \<up> 3 * (x*(b/a) - 3*b*(a/b \<up> 4))");
 60.1385 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1386 -if UnparseC.term t = "5 * x \<up> 2 / (b \<up> 3 * c)"
 60.1387 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 53";
 60.1388 -
 60.1389 -
 60.1390 -"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
 60.1391 -"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
 60.1392 -"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
 60.1393 -"----- SRD Schalk I, p.69 Nr. 454b";
 60.1394 -val t = TermC.str2term "((2 - x)/(2*a)) / (2*a/(x - 2))";
 60.1395 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1396 -if UnparseC.term t = "(-4 + 4 * x + -1 * x \<up> 2) / (4 * a \<up> 2)"
 60.1397 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 35";
 60.1398 -
 60.1399 -"----- SRD Schalk I, p.69 Nr. 455a";
 60.1400 -val t = TermC.str2term "(a \<up> 2 + 1)/(a \<up> 2 - 1) / ((a+1)/(a - 1))";
 60.1401 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1402 -if UnparseC.term t = "(1 + a \<up> 2) / (1 + 2 * a + a \<up> 2)" then ()
 60.1403 -else error "rational.sml: diff.behav. in norm_Rational_mg 36";
 60.1404 -
 60.1405 -"----- Schalk I, p.69 Nr. 455b";
 60.1406 -val t = TermC.str2term "(x \<up> 2 - 4)/(y \<up> 2 - 9)/((2+x)/(3 - y))";
 60.1407 -(* WN130911 non-termination due to non-termination of
 60.1408 -  cancel_p_ thy (TermC.str2term ("(-12 + 4 * y + 3 * x \<up> 2 + -1 * (x \<up> 2 * y)) /" ^
 60.1409 -                           "(-18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)"))
 60.1410 -
 60.1411 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1412 -if UnparseC.term t = "(2 + -1 * x) / (3 + y)" then ()
 60.1413 -else error "rational.sml: diff.behav. in norm_Rational_mg 37";
 60.1414 -*)
 60.1415 -
 60.1416 -"----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
 60.1417 -val t = TermC.str2term "(x \<up> 2 - 4)*(3 - y) / ((y \<up> 2 - 9)*(2+x))";
 60.1418 -(* WN130911 non-termination due to non-termination of
 60.1419 -  cancel_p_ thy (TermC.str2term ("(-12 + 4 * y + 3 * x \<up> 2 + -1 * (x \<up> 2 * y)) /" ^
 60.1420 -                           "(-18 + -9 * x + 2 * y \<up> 2 + x * y \<up> 2)"))
 60.1421 -
 60.1422 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1423 -if UnparseC.term t = "(2 + -1 * x) / (3 + y)" then ()
 60.1424 -else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
 60.1425 -*)
 60.1426 -
 60.1427 -"----- ?: worked before 0707xx";
 60.1428 -val t = TermC.str2term "(3 + -1 * y) / (-9 + y \<up> 2)";
 60.1429 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1430 -if UnparseC.term t = "-1 / (3 + y)"
 60.1431 -then () else error "rational.sml: -1 / (3 + y) norm_Rational";
 60.1432 -
 60.1433 -"----- SRD Schalk I, p.69 Nr. 456b";
 60.1434 -val t = TermC.str2term "(b \<up> 3 - b \<up> 2) / (b \<up> 2+b) / (b \<up> 2 - 1)";
 60.1435 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1436 -if UnparseC.term t = "b / (1 + 2 * b + b \<up> 2)"
 60.1437 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 38";
 60.1438 -
 60.1439 -"----- SRD Schalk I, p.69 Nr. 457b";
 60.1440 -val t = TermC.str2term "(16*a \<up> 2 - 9*b \<up> 2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a \<up> 2 - 9*a \<up> 2*b \<up> 2))";
 60.1441 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1442 -if UnparseC.term t = "8 * a \<up> 2 + -6 * a * b + -12 * a \<up> 2 * b + 9 * a * b \<up> 2"
 60.1443 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
 60.1444 -
 60.1445 -"----- Schalk I, p.69 Nr. 458b works since 0707";
 60.1446 -val t = TermC.str2term "(2*a \<up> 2*x - a \<up> 2) / (a*x - b*x) / (b \<up> 2*(2*x - 1) / (x*(a - b)))";
 60.1447 -(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1448 -:
 60.1449 -###  rls: cancel_p on: (-1 * a \<up> 2 + 2 * (a \<up> 2 * x)) / (a * x + -1 * (b * x)) /
 60.1450 -((-1 * b \<up> 2 + 2 * (b \<up> 2 * x)) / (a * x + -1 * (b * x))) 
 60.1451 -exception Div raised
 60.1452 -
 60.1453 -BUT
 60.1454 -val t = TermC.str2term 
 60.1455 -  ("(-1 * a \<up> 2 + 2 * (a \<up> 2 * x)) / (a * x + -1 * (b * x)) /" ^
 60.1456 -  "((-1 * b \<up> 2 + 2 * (b \<up> 2 * x)) / (a * x + -1 * (b * x)))");
 60.1457 -NONE = cancel_p_ thy t;
 60.1458 -
 60.1459 -if UnparseC.term t = "a \<up> 2 / b \<up> 2" then ()
 60.1460 -else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
 60.1461 -*)
 60.1462 -
 60.1463 -"----- SRD Schalk I, p.69 Nr. 459b";
 60.1464 -val t = TermC.str2term "(a \<up> 2 - b \<up> 2)/(a*b) / (4*(a+b) \<up> 2/a)";
 60.1465 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1466 -if UnparseC.term t = "(a + -1 * b) / (4 * a * b + 4 * b \<up> 2)" then ()
 60.1467 -else error "rational.sml: diff.behav. in norm_Rational_mg 41";
 60.1468 -
 60.1469 -"----- Schalk I, p.69 Nr. 460b nonterm.SK";
 60.1470 -val t = TermC.str2term "(9*(x \<up> 2 - 8*x + 16) / (4*(y \<up> 2 - 2*y + 1))) / ((3*x - 12) / (16*y - 16))";
 60.1471 -(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1472 -exception Div raised
 60.1473 -
 60.1474 -BUT
 60.1475 -val t = TermC.str2term 
 60.1476 -  ("(144 + -72 * x + 9 * x \<up> 2) / (4 + -8 * y + 4 * y \<up> 2) /" ^
 60.1477 -  "((-12 + 3 * x) / (-16 + 16 * y))");
 60.1478 -NONE = cancel_p_ thy t;
 60.1479 -
 60.1480 -if UnparseC.term t = !!!!!!!!!!!!!!!!!!!!!!!!!
 60.1481 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 42";
 60.1482 -*)
 60.1483 -
 60.1484 -"----- some variant of the above; was non-terminating before";
 60.1485 -val t = TermC.str2term "9*(x \<up> 2 - 8*x+16)*(16*y - 16)/(4*(y \<up> 2 - 2*y+1)*(3*x - 12))";
 60.1486 -val SOME (t , _) = rewrite_set_ thy false norm_Rational t;
 60.1487 -if UnparseC.term t = "(48 + -12 * x) / (1 + -1 * y)"
 60.1488 -then () else error "some variant of the above; was non-terminating before";
 60.1489 -
 60.1490 -"----- SRD Schalk I, p.70 Nr. 472a";
 60.1491 -val t = TermC.str2term ("((8*x \<up> 2 - 32*y \<up> 2) / (2*x + 4*y))  /  ((4*x - 8*y) / (x + y))");
 60.1492 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1493 -if UnparseC.term t = "x + y"
 60.1494 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 43";
 60.1495 -
 60.1496 -"----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
 60.1497 -val t = TermC.str2term ("(a - (a*b + b \<up> 2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
 60.1498 -		 "((a - a \<up> 2/(a+b))/(a+(a*b)/(a - b)))");
 60.1499 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1500 -if UnparseC.term t = "(2 * a \<up> 3 + 2 * a \<up> 2 * b) / (a \<up> 2 * b + b \<up> 3)"
 60.1501 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 51";
 60.1502 -
 60.1503 -(*SRD Schalk I, p.69 Nr. 461a *)
 60.1504 -val t = TermC.str2term "(2/(x+3) + 2/(x - 3)) / (8*x/(x \<up> 2 - 9))";
 60.1505 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1506 -if UnparseC.term t = "1 / 2"
 60.1507 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 44";
 60.1508 -
 60.1509 -(*SRD Schalk I, p.69 Nr. 464b *)
 60.1510 -val t = TermC.str2term "(a - a/(a - 2)) / (a + a/(a - 2))";
 60.1511 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1512 -if UnparseC.term t = "(-3 + a) / (-1 + a)"
 60.1513 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 45";
 60.1514 -
 60.1515 -(*SRD Schalk I, p.69 Nr. 465b *)
 60.1516 -val t = TermC.str2term "((x+3*y)/9 + (4*y \<up> 2 - 9*z \<up> 2)/(16*x))   /   (x/9 + y/6 + z/4)";
 60.1517 -(* WN130911 non-termination due to non-termination of
 60.1518 -  cancel_p_ thy (TermC.str2term 
 60.1519 -    ("("(576 * x \<up> 2 + 1728 * (x * y) + 1296 * y \<up> 2 + -2916 * z \<up> 2) /" ^
 60.1520 -      "(576 * x \<up> 2 + 864 * (x * y) + 1296 * (x * z))"))
 60.1521 -
 60.1522 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1523 -if UnparseC.term t = "(4 * x + 6 * y + -9 * z) / (4 * x)"
 60.1524 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 46";
 60.1525 -*)
 60.1526 -
 60.1527 -(*SRD Schalk I, p.69 Nr. 466b *)
 60.1528 -val t = TermC.str2term "((1 - 7*(x - 2)/(x \<up> 2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x \<up> 2 - 25))";
 60.1529 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1530 -if UnparseC.term t = "(25 + -10 * x + x \<up> 2) / 18"
 60.1531 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 47";
 60.1532 -
 60.1533 -(*SRD Schalk I, p.70 Nr. 469 *)
 60.1534 -val t = TermC.str2term ("3*b \<up> 2 / (4*a \<up> 2 - 8*a*b + 4*b \<up> 2) / " ^
 60.1535 -  "(a / (a \<up> 2*b - b \<up> 3)  +  (a - b) / (4*a*b \<up> 2 + 4*b \<up> 3)  -  1 / (4*b \<up> 2))");
 60.1536 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1537 -if UnparseC.term t = "-3 * b \<up> 3 / (-2 * a + 2 * b)"
 60.1538 -then () else error "rational.sml: diff.behav. in norm_Rational_mg 48";
 60.1539 -
 60.1540 -"-------- me Schalk I No.186 -------------------------------------------------";
 60.1541 -"-------- me Schalk I No.186 -------------------------------------------------";
 60.1542 -"-------- me Schalk I No.186 -------------------------------------------------";
 60.1543 -val fmz = ["Term ((14 * x * y) / ( x * y ))", "normalform N"];
 60.1544 -val (dI',pI',mI') =
 60.1545 -  ("Rational",["rational", "simplification"],
 60.1546 -   ["simplification", "of_rationals"]);
 60.1547 -val p = e_pos'; val c = []; 
 60.1548 -val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 60.1549 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
 60.1550 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
 60.1551 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
 60.1552 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
 60.1553 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
 60.1554 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
 60.1555 -val (p,_,f,nxt,_,pt) = me nxt p c pt;
 60.1556 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 60.1557 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 60.1558 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
 60.1559 -val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
 60.1560 -case (f2str f, nxt) of
 60.1561 -    ("14", ("End_Proof'", _)) => ()
 60.1562 -  | _ => error "rational.sml diff.behav. in me Schalk I No.186";
 60.1563 -
 60.1564 -"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
 60.1565 -"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
 60.1566 -"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
 60.1567 -reset_states ();
 60.1568 -CalcTree [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"], 
 60.1569 -  ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
 60.1570 -Iterator 1;
 60.1571 -moveActiveRoot 1;
 60.1572 -autoCalculate 1 CompleteCalc;
 60.1573 -val ((pt, p), _) = get_calc 1; 
 60.1574 -(*
 60.1575 -Test_Tool.show_pt pt;
 60.1576 -[
 60.1577 -(([], Frm), Simplify ((2 - x) / (2 * a) / (2 * a / (x - 2)))),
 60.1578 -(([1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
 60.1579 -(([1], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))),
 60.1580 -(([2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (-2 + x))),
 60.1581 -(([3], Res), (2 + -1 * x) * (-2 + x) / (2 * a * (2 * a))),
 60.1582 -(([4], Res), (-4 + 4 * x + -1 * x \<up> 2) / (4 * a \<up> 2)),
 60.1583 -(([], Res), (-4 + 4 * x + -1 * x \<up> 2) / (4 * a \<up> 2))] 
 60.1584 -*)
 60.1585 -interSteps 1 ([1], Res);
 60.1586 -val ((pt, p), _) = get_calc 1; 
 60.1587 -(*Test_Tool.show_pt pt;
 60.1588 -[
 60.1589 -(([], Frm), Simplify ((2 - x) / (2 * a) / (2 * a / (x - 2)))),
 60.1590 -(([1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
 60.1591 -(([1,1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
 60.1592 -(([1,1], Res), (2 - x) / (2 * a) / (2 * a / (x + -1 * 2))),
 60.1593 -(([1,2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))),
 60.1594 -(([1], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))),
 60.1595 -(([2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (-2 + x))),
 60.1596 -(([3], Res), (2 + -1 * x) * (-2 + x) / (2 * a * (2 * a))),
 60.1597 -(([4], Res), (-4 + 4 * x + -1 * x \<up> 2) / (4 * a \<up> 2)),
 60.1598 -(([], Res), (-4 + 4 * x + -1 * x \<up> 2) / (4 * a \<up> 2))] 
 60.1599 -*)
 60.1600 -val (t, asm) = get_obj g_result pt [1, 1];
 60.1601 -if UnparseC.term t = "(2 - x) / (2 * a) / (2 * a / (x + -1 * 2))" andalso UnparseC.terms asm = "[]"
 60.1602 -then () else error "2nd interSteps ..Simp_Rat_Double_No-1 changed on [1, 1]";
 60.1603 -val (t, asm) = get_obj g_result pt [1, 2];
 60.1604 -if UnparseC.term t = "(2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))" andalso UnparseC.terms asm = "[]"
 60.1605 -then () else error "3rd interSteps ..Simp_Rat_Double_No-1 changed on [1, 2]";
 60.1606 -
 60.1607 -
 60.1608 -"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
 60.1609 -"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
 60.1610 -"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
 60.1611 -reset_states ();
 60.1612 -CalcTree [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"], 
 60.1613 -  ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
 60.1614 -Iterator 1;
 60.1615 -moveActiveRoot 1;
 60.1616 -autoCalculate 1 CompleteCalc;
 60.1617 -val ((pt, p), _) = get_calc 1;
 60.1618 -(*Test_Tool.show_pt pt;
 60.1619 -[
 60.1620 -(([], Frm), Simplify ((a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * a * b + b \<up> 2))),
 60.1621 -(([1], Frm), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * a * b + b \<up> 2)),
 60.1622 -(([1], Res), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * (a * b) + b \<up> 2)),
 60.1623 -(([2], Res), (a + b) / (a + -1 * b)),
 60.1624 -(([], Res), (a + b) / (a + -1 * b))] 
 60.1625 -*)
 60.1626 -interSteps 1 ([2], Res);
 60.1627 -val ((pt, p), _) = get_calc 1;
 60.1628 -(*Test_Tool.show_pt pt;
 60.1629 -[
 60.1630 -(([], Frm), Simplify ((a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * a * b + b \<up> 2))),
 60.1631 -(([1], Frm), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * a * b + b \<up> 2)),
 60.1632 -(([1], Res), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * (a * b) + b \<up> 2)),
 60.1633 -(([2,1], Frm), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * (a * b) + b \<up> 2)),
 60.1634 -(([2,1], Res), (a + b) / (a + -1 * b)),
 60.1635 -(([2], Res), (a + b) / (a + -1 * b)),
 60.1636 -(([], Res), (a + b) / (a + -1 * b))] 
 60.1637 -*)
 60.1638 -interSteps 1 ([2,1],Res);
 60.1639 -val ((pt, p), _) = get_calc 1; 
 60.1640 -(*Test_Tool.show_pt pt;
 60.1641 -[
 60.1642 -(([], Frm), Simplify ((a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * a * b + b \<up> 2))),
 60.1643 -(([1], Frm), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * a * b + b \<up> 2)),
 60.1644 -(([1], Res), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * (a * b) + b \<up> 2)),
 60.1645 -(([2,1], Frm), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * (a * b) + b \<up> 2)),
 60.1646 -(([2,1,1], Frm), (a \<up> 2 + -1 * b \<up> 2) / (a \<up> 2 + -2 * (a * b) + b \<up> 2)),
 60.1647 -(([2,1,1], Res), (a \<up> 2 + -1 * (a * b) + a * b + -1 * b \<up> 2) /
 60.1648 -(a \<up> 2 + -2 * (a * b) + 1 * b \<up> 2)),
 60.1649 -(([2,1,2], Res), (a \<up> 2 + -1 * (a * b) + a * b + -1 * b \<up> 2) /
 60.1650 -(a \<up> 2 + -2 * (a * b) + -1 \<up> 2 * b \<up> 2)),
 60.1651 -(([2,1,3], Res), (a \<up> 2 + -1 * (a * b) + a * b + -1 * b \<up> 2) /
 60.1652 -(a \<up> 2 + -2 * (a * b) + (-1 * b) \<up> 2)),
 60.1653 -(([2,1,4], Res), (a * a + -1 * (a * b) + a * b + -1 * b \<up> 2) /
 60.1654 -(a \<up> 2 + -2 * (a * b) + (-1 * b) \<up> 2)),
 60.1655 -(([2,1,5], Res), (a * a + -1 * (a * b) + a * b + -1 * (b * b)) /
 60.1656 -(a \<up> 2 + -2 * (a * b) + (-1 * b) \<up> 2)),
 60.1657 -(([2,1,6], Res), (a * a + -1 * (a * b) + a * b + -1 * (b * b)) /
 60.1658 -(a \<up> 2 + -1 * (2 * (a * b)) + (-1 * b) \<up> 2)),
 60.1659 -(([2,1,7], Res), (a * a + a * (-1 * b) + (b * a + b * (-1 * b))) /
 60.1660 -(a \<up> 2 + 2 * (a * (-1 * b)) + (-1 * b) \<up> 2)),
 60.1661 -(([2,1,8], Res), (a * a + a * (-1 * b) + (b * a + b * (-1 * b))) /
 60.1662 -(a \<up> 2 + 2 * a * (-1 * b) + (-1 * b) \<up> 2)),
 60.1663 -(([2,1,9], Res), (a * (a + -1 * b) + (b * a + b * (-1 * b))) /
 60.1664 -(a \<up> 2 + 2 * a * (-1 * b) + (-1 * b) \<up> 2)),
 60.1665 -(([2,1,10], Res), (a * (a + -1 * b) + b * (a + -1 * b)) /
 60.1666 -(a \<up> 2 + 2 * a * (-1 * b) + (-1 * b) \<up> 2)),
 60.1667 -(([2,1,11], Res), (a + b) * (a + -1 * b) / (a \<up> 2 + 2 * a * (-1 * b) + (-1 * b) \<up> 2)),
 60.1668 -(([2,1,12], Res), (a + b) * (a + -1 * b) / ((a + -1 * b) * (a + -1 * b))),
 60.1669 -(([2,1,13], Res), (a + b) / (a + -1 * b)),
 60.1670 -(([2,1], Res), (a + b) / (a + -1 * b)),
 60.1671 -(([2], Res), (a + b) / (a + -1 * b)),
 60.1672 -(([], Res), (a + b) / (a + -1 * b))] 
 60.1673 -*)
 60.1674 -val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
 60.1675 -if length newnds = 13 then () else error "rational.sml: interSteps cancel_p rev_rew_p";
 60.1676 -
 60.1677 -val p = ([2,1,9],Res);
 60.1678 -getTactic 1 p;
 60.1679 -val (_, tac, _) = ME_Misc.pt_extract (pt, p);
 60.1680 -case tac of SOME (Rewrite ("sym_distrib_left", _)) => ()
 60.1681 -| _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
 60.1682 -
 60.1683 -
 60.1684 -"-------- investigate rulesets for cancel_p ----------------------------------";
 60.1685 -"-------- investigate rulesets for cancel_p ----------------------------------";
 60.1686 -"-------- investigate rulesets for cancel_p ----------------------------------";
 60.1687 -val thy = @{theory "Rational"};
 60.1688 -val t = TermC.str2term "(a \<up> 2 + -1*b \<up> 2) / (a \<up> 2 + -2*a*b + b \<up> 2)";
 60.1689 -val tt = TermC.str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
 60.1690 -
 60.1691 -"----- with rewrite_set_";
 60.1692 -val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
 60.1693 -if UnparseC.term tt'= "a \<up> 2 + -1 * b \<up> 2" then () else error "rls chancel_p 1";
 60.1694 -val tt = TermC.str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
 60.1695 -val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
 60.1696 -if UnparseC.term tt' = "a \<up> 2 + -2 * a * b + b \<up> 2" then () else error "rls chancel_p 2";
 60.1697 -
 60.1698 -"----- with .make_deriv; WN1130912 not investigated further, will be discontinued";
 60.1699 -val SOME (tt, _) = factout_p_ thy t; 
 60.1700 -if UnparseC.term tt = "(a + b) * (a + -1 * b) / ((a + -1 * b) * (a + -1 * b))"
 60.1701 -then () else error "rls chancel_p 3";
 60.1702 -UnparseC.term tt = "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
 60.1703 -
 60.1704 -"--- with simpler ruleset";
 60.1705 -val {rules, rew_ord= (_, ro), ...} = Rule_Set.rep (assoc_rls "rev_rew_p");
 60.1706 -val der = .make_deriv thy Atools_erls rules ro NONE tt;
 60.1707 -if length der = 12 then () else error "WN1130912 rls chancel_p 4";
 60.1708 -(*default_print_depth 99;*) writeln (deriv2str der); (*default_print_depth 3;*)
 60.1709 -
 60.1710 -(*default_print_depth 99;*) map (UnparseC.term o #1) der; (*default_print_depth 3;*)
 60.1711 -"...,(-1 * b \<up> 2 + a \<up> 2) / (-2 * (a * b) + a \<up> 2 + (-1 * b) \<up> 2) ]";
 60.1712 -(*default_print_depth 99;*) map (Rule.to_string o #2) der; (*default_print_depth 3;*)
 60.1713 -(*default_print_depth 99;*) map (UnparseC.term o #1 o #3) der; (*default_print_depth 3;*)
 60.1714 -
 60.1715 -val der = .make_deriv thy Atools_erls rules ro NONE 
 60.1716 -	(TermC.str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
 60.1717 -(*default_print_depth 99;*) writeln (deriv2str der); (*default_print_depth 3;*)
 60.1718 -
 60.1719 -val {rules, rew_ord=(_,ro),...} = Rule_Set.rep (assoc_rls "rev_rew_p");
 60.1720 -val der = .make_deriv thy Atools_erls rules ro NONE 
 60.1721 -	(TermC.str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
 60.1722 -(*default_print_depth 99;*) writeln (deriv2str der); (*default_print_depth 3;*)
 60.1723 -(*default_print_depth 99;*) map (UnparseC.term o #1) der; (*default_print_depth 3;*)
 60.1724 -(*WN060829 ...postponed*)
 60.1725 -
 60.1726 -
 60.1727 -"-------- fun eval_get_denominator -------------------------------------------";
 60.1728 -"-------- fun eval_get_denominator -------------------------------------------";
 60.1729 -"-------- fun eval_get_denominator -------------------------------------------";
 60.1730 -val thy = @{theory Isac_Knowledge};
 60.1731 -val t = Thm.term_of (the (TermC.parse thy "get_denominator ((a +x)/b)"));
 60.1732 -val SOME (_, t') = eval_get_denominator "" 0 t thy;
 60.1733 -if UnparseC.term t' = "get_denominator ((a + x) / b) = b"
 60.1734 -then () else error "get_denominator ((a + x) / b) = b"
 60.1735 -
 60.1736 -
 60.1737 -"-------- several errpats in complicated term --------------------------------";
 60.1738 -"-------- several errpats in complicated term --------------------------------";
 60.1739 -"-------- several errpats in complicated term --------------------------------";
 60.1740 -(*WN12xxxx TODO: instead of Gabriella's example here (27.Jul.12) find a simpler one
 60.1741 -  WN130912: kept this test, although not clear what for*)
 60.1742 -reset_states ();
 60.1743 -CalcTree [(["Term ((5*b + 25)/(a^2 - b^2) * (a - b)/(5*b))", "normalform N"], 
 60.1744 -  ("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
 60.1745 -Iterator 1;
 60.1746 -moveActiveRoot 1;
 60.1747 -autoCalculate 1 CompleteCalc;
 60.1748 -val ((pt, p), _) = get_calc 1;
 60.1749 -(*Test_Tool.show_pt pt;
 60.1750 -[
 60.1751 -(([], Frm), Simplify ((5 * b + 25) / (a \<up> 2 - b \<up> 2) * (a - b) / (5 * b))),
 60.1752 -(([1], Frm), (5 * b + 25) / (a \<up> 2 - b \<up> 2) * (a - b) / (5 * b)),
 60.1753 -(([1], Res), (5 * b + 25) / (a \<up> 2 + -1 * b \<up> 2) * (a + -1 * b) / (5 * b)),
 60.1754 -(([2], Res), (5 * b + 25) * (a + -1 * b) / (a \<up> 2 + -1 * b \<up> 2) / (5 * b)),
 60.1755 -(([3], Res), (25 * a + -25 * b + 5 * (a * b) + -5 * b \<up> 2) / (a \<up> 2 + -1 * b \<up> 2) /
 60.1756 -(5 * b)),
 60.1757 -(([4], Res), (25 + 5 * b) / (a + b) / (5 * b)),
 60.1758 -(([5], Res), (25 + 5 * b) / ((a + b) * (5 * b))),
 60.1759 -(([6], Res), (25 + 5 * b) / (5 * (a * b) + 5 * b \<up> 2)),
 60.1760 -(([7], Res), (5 + b) / (a * b + b \<up> 2)),
 60.1761 -(([], Res), (5 + b) / (a * b + b \<up> 2))] *)
 60.1762 -
 60.1763 -
 60.1764 -"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
 60.1765 -"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
 60.1766 -"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
 60.1767 -(*------- Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
 60.1768 -val t = TermC.str2term 
 60.1769 -  ("((12*x*y / (9*x \<up> 2 - y \<up> 2))  /  (1 / (3*x - y) \<up> 2 - 1 / (3*x + y) \<up> 2))  *  " ^
 60.1770 -	"((1/(x - 5*y) \<up> 2  -  1/(x + 5*y) \<up> 2)  /  (20*x*y / (x \<up> 2 - 25*y \<up> 2)))");
 60.1771 -
 60.1772 -(*1st factor separately simplified *)
 60.1773 -val t = TermC.str2term "((12*x*y / (9*x \<up> 2 - y \<up> 2))  /  (1 / (3*x - y) \<up> 2 - 1 / (3*x + y) \<up> 2))";
 60.1774 -val SOME (t', _) = rewrite_set_ thy false norm_Rational t; 
 60.1775 -if UnparseC.term t' = "(-9 * x \<up> 2 + y \<up> 2) / -1" then () else error "Nr. 480b lhs changed";
 60.1776 -(*2nd factor separately simplified *)
 60.1777 -val t = TermC.str2term "((1/(x - 5*y) \<up> 2  -  1/(x + 5*y) \<up> 2)  /  (20*x*y / (x \<up> 2 - 25*y \<up> 2)))";
 60.1778 -val SOME (t',_) = rewrite_set_ thy false norm_Rational t; UnparseC.term t';
 60.1779 -if UnparseC.term t' = "-1 / (-1 * x \<up> 2 + 25 * y \<up> 2)" then () else error "Nr. 480b rhs changed";
 60.1780 -
 60.1781 -"-------- Schalk I, p.70 Nr. 477a: terms are exploding ?!?";
 60.1782 -val t = TermC.str2term ("b*y/(b - 2*y)/((b \<up> 2 - y \<up> 2)/(b+2*y))  /" ^
 60.1783 -		 "(b \<up> 2*y + b*y \<up> 2) * (a+x) \<up> 2  /  ((b \<up> 2 - 4*y \<up> 2) * (a+2*x) \<up> 2)");
 60.1784 -(*val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
 60.1785 -:
 60.1786 -###  rls: cancel_p on: (a \<up> 2 * (b * y) + 2 * (a * (b * (x * y))) + b * (x \<up> 2 * y)) /
 60.1787 -(b + -2 * y) /
 60.1788 -((b \<up> 2 + -1 * y \<up> 2) / (b + 2 * y)) /
 60.1789 -(b \<up> 2 * y + b * y \<up> 2) /
 60.1790 -(a \<up> 2 * b \<up> 2 + -4 * (a \<up> 2 * y \<up> 2) + 4 * (a * (b \<up> 2 * x)) +
 60.1791 - -16 * (a * (x * y \<up> 2)) +
 60.1792 - 4 * (b \<up> 2 * x \<up> 2) +
 60.1793 - -16 * (x \<up> 2 * y \<up> 2)) 
 60.1794 -exception Div raised
 60.1795 -
 60.1796 -BUT
 60.1797 -val t = TermC.str2term 
 60.1798 -  ("(a \<up> 2 * (b * y) + 2 * (a * (b * (x * y))) + b * (x \<up> 2 * y)) /" ^
 60.1799 -  "(b + -2 * y) /" ^
 60.1800 -  "((b \<up> 2 + -1 * y \<up> 2) / (b + 2 * y)) /" ^
 60.1801 -  "(b \<up> 2 * y + b * y \<up> 2) /" ^
 60.1802 -  "(a \<up> 2 * b \<up> 2 + -4 * (a \<up> 2 * y \<up> 2) + 4 * (a * (b \<up> 2 * x)) +" ^
 60.1803 -  "-16 * (a * (x * y \<up> 2)) +" ^
 60.1804 -  "4 * (b \<up> 2 * x \<up> 2) +" ^
 60.1805 -  "-16 * (x \<up> 2 * y \<up> 2))");
 60.1806 -NONE = cancel_p_ thy t;
 60.1807 -*)
 60.1808 -
 60.1809 -(*------- Schalk I, p.70 Nr. 476b in 2003 this worked using 10 sec. *)
 60.1810 -val t = TermC.str2term 
 60.1811 -  ("((a \<up> 2 - b \<up> 2)/(2*a*b) + 2*a*b/(a \<up> 2 - b \<up> 2))  /  ((a \<up> 2 + b \<up> 2)/(2*a*b) + 1)    / " ^
 60.1812 -   "((a \<up> 2 + b \<up> 2) \<up> 2  /  (a + b) \<up> 2)");
 60.1813 -(* Rewrite.trace_on := true;
 60.1814 -rewrite_set_ thy false norm_Rational t;
 60.1815 -:
 60.1816 -####  rls: cancel_p on: (2 * (a \<up> 7 * b) + 4 * (a \<up> 6 * b \<up> 2) + 6 * (a \<up> 5 * b \<up> 3) +
 60.1817 - 8 * (a \<up> 4 * b \<up> 4) +
 60.1818 - 6 * (a \<up> 3 * b \<up> 5) +
 60.1819 - 4 * (a \<up> 2 * b \<up> 6) +
 60.1820 - 2 * (a * b \<up> 7)) /
 60.1821 -(2 * (a \<up> 9 * b) + 4 * (a \<up> 8 * b \<up> 2) +
 60.1822 - 2 * (2 * (a \<up> 7 * b \<up> 3)) +
 60.1823 - 4 * (a \<up> 6 * b \<up> 4) +
 60.1824 - -4 * (a \<up> 4 * b \<up> 6) +
 60.1825 - -4 * (a \<up> 3 * b \<up> 7) +
 60.1826 - -4 * (a \<up> 2 * b \<up> 8) +
 60.1827 - -2 * (a * b \<up> 9))
 60.1828 -
 60.1829 -if UnparseC.term t = "1 / (a \<up> 2 + -1 * b \<up> 2)" then ()
 60.1830 -else error "rational.sml: diff.behav. in norm_Rational_mg 49";
 60.1831 -*)
 60.1832 -
 60.1833 -"-------- Schalk I, p.70 Nr. 480a: terms are exploding ?!?";
 60.1834 -val t = TermC.str2term ("(1/x + 1/y + 1/z)  /  (1/x - 1/y - 1/z)  /  " ^
 60.1835 -  "(2*x \<up> 2 / (x \<up> 2 - z \<up> 2) / (x / (x + z)  +  x / (x - z)))");
 60.1836 -(* Rewrite.trace_on := true;
 60.1837 -rewrite_set_ thy false norm_Rational t;
 60.1838 -:
 60.1839 -####  rls: cancel_p on: (2 * (x \<up> 6 * (y \<up> 2 * z)) + 2 * (x \<up> 6 * (y * z \<up> 2)) +
 60.1840 - 2 * (x \<up> 5 * (y \<up> 2 * z \<up> 2)) +
 60.1841 - -2 * (x \<up> 4 * (y \<up> 2 * z \<up> 3)) +
 60.1842 - -2 * (x \<up> 4 * (y * z \<up> 4)) +
 60.1843 - -2 * (x \<up> 3 * (y \<up> 2 * z \<up> 4))) /
 60.1844 -(-2 * (x \<up> 6 * (y \<up> 2 * z)) + -2 * (x \<up> 6 * (y * z \<up> 2)) +
 60.1845 - 2 * (x \<up> 5 * (y \<up> 2 * z \<up> 2)) +
 60.1846 - 2 * (x \<up> 4 * (y \<up> 2 * z \<up> 3)) +
 60.1847 - 2 * (x \<up> 4 * (y * z \<up> 4)) +
 60.1848 - -2 * (x \<up> 3 * (y \<up> 2 * z \<up> 4)))
 60.1849 -*)
 60.1850 -
 60.1851 -"-------- Schalk I, p.60 Nr. 215d: terms are exploding, internal loop does not terminate";
 60.1852 -val t = TermC.str2term "(a-b) \<up> 3 * (x+y) \<up> 4 / ((x+y) \<up> 2 * (a-b) \<up> 5)";
 60.1853 -(* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:
 60.1854 -
 60.1855 -val t = TermC.str2term "(a-b) \<up> 3 * (x+y) \<up> 4";
 60.1856 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1857 -UnparseC.term t;
 60.1858 -"a \<up> 3 * x \<up> 4 + 4 * a \<up> 3 * x \<up> 3 * y +6 * a \<up> 3 * x \<up> 2 * y \<up> 2 +4 * a \<up> 3 * x * y \<up> 3 +a \<up> 3 * y \<up> 4 +-3 * a \<up> 2 * b * x \<up> 4 +-12 * a \<up> 2 * b * x \<up> 3 * y +-18 * a \<up> 2 * b * x \<up> 2 * y \<up> 2 +-12 * a \<up> 2 * b * x * y \<up> 3 +-3 * a \<up> 2 * b * y \<up> 4 +3 * a * b \<up> 2 * x \<up> 4 +12 * a * b \<up> 2 * x \<up> 3 * y +18 * a * b \<up> 2 * x \<up> 2 * y \<up> 2 +12 * a * b \<up> 2 * x * y \<up> 3 +3 * a * b \<up> 2 * y \<up> 4 +-1 * b \<up> 3 * x \<up> 4 +-4 * b \<up> 3 * x \<up> 3 * y +-6 * b \<up> 3 * x \<up> 2 * y \<up> 2 +-4 * b \<up> 3 * x * y \<up> 3 +-1 * b \<up> 3 * y \<up> 4";
 60.1859 -val t = TermC.str2term "((x+y) \<up> 2 * (a-b) \<up> 5)";
 60.1860 -val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1861 -UnparseC.term t;
 60.1862 -"a \<up> 5 * x \<up> 2 + 2 * a \<up> 5 * x * y + a \<up> 5 * y \<up> 2 +-5 * a \<up> 4 * b * x \<up> 2 +-10 * a \<up> 4 * b * x * y +-5 * a \<up> 4 * b * y \<up> 2 +10 * a \<up> 3 * b \<up> 2 * x \<up> 2 +20 * a \<up> 3 * b \<up> 2 * x * y +10 * a \<up> 3 * b \<up> 2 * y \<up> 2 +-10 * a \<up> 2 * b \<up> 3 * x \<up> 2 +-20 * a \<up> 2 * b \<up> 3 * x * y +-10 * a \<up> 2 * b \<up> 3 * y \<up> 2 +5 * a * b \<up> 4 * x \<up> 2 +10 * a * b \<up> 4 * x * y +5 * a * b \<up> 4 * y \<up> 2 +-1 * b \<up> 5 * x \<up> 2 +-2 * b \<up> 5 * x * y +-1 * b \<up> 5 * y \<up> 2";
 60.1863 -
 60.1864 -anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
 60.1865 -
 60.1866 -"-------- Schalk I, p.70 Nr. 480b: terms are exploding, Rewrite.trace_on stops at";
 60.1867 -val t = TermC.str2term ("((12*x*y/(9*x \<up> 2 - y \<up> 2))/" ^
 60.1868 -		 "(1/(3*x - y) \<up> 2 - 1/(3*x + y) \<up> 2)) *" ^
 60.1869 -		 "(1/(x - 5*y) \<up> 2 - 1/(x + 5*y) \<up> 2)/" ^
 60.1870 -		 "(20*x*y/(x \<up> 2 - 25*y \<up> 2))");
 60.1871 -(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
 60.1872 -:
 60.1873 -####  rls: cancel_p on: (19440 * (x \<up> 8 * y \<up> 2) + -490320 * (x \<up> 6 * y \<up> 4) +
 60.1874 - 108240 * (x \<up> 4 * y \<up> 6) +
 60.1875 - -6000 * (x \<up> 2 * y \<up> 8)) /
 60.1876 -(2160 * (x \<up> 8 * y \<up> 2) + -108240 * (x \<up> 6 * y \<up> 4) +
 60.1877 - 1362000 * (x \<up> 4 * y \<up> 6) +
 60.1878 - -150000 * (x \<up> 2 * y \<up> 8))
 60.1879 -*)
 60.1880 -
    61.1 --- a/test/Tools/isac/Knowledge/rlang.sml	Mon Jun 21 22:08:01 2021 +0200
    61.2 +++ b/test/Tools/isac/Knowledge/rlang.sml	Sun Jul 18 18:15:27 2021 +0200
    61.3 @@ -50,17 +50,17 @@
    61.4  }
    61.5  *)
    61.6  
    61.7 -(* Rewrite.trace_on:=true;
    61.8 - Rewrite.trace_on:=false;
    61.9 +(*
   61.10 + Rewrite.trace_on:=false; (*true false*)
   61.11   Refine.refine fmz ["univariate", "equation"];
   61.12  *)
   61.13  "---- rlang.sml begin-----------------------------------";
   61.14  (*-----------------  Schalk I s.86 Bsp 5 ------------------------*)
   61.15 -"Schalk I s.86 Bsp 5 (3*x - 1 - (5*x - (2 - 4*x)) = -11)";
   61.16 -"Schalk I s.86 Bsp 5 (3*x - 1 - (5*x - (2 - 4*x)) = -11)";
   61.17 -"Schalk I s.86 Bsp 5 (3*x - 1 - (5*x - (2 - 4*x)) = -11)";
   61.18 +"Schalk I s.86 Bsp 5 (3*x - 1 - (5*x - (2 - 4*x)) = - 11)";
   61.19 +"Schalk I s.86 Bsp 5 (3*x - 1 - (5*x - (2 - 4*x)) = - 11)";
   61.20 +"Schalk I s.86 Bsp 5 (3*x - 1 - (5*x - (2 - 4*x)) = - 11)";
   61.21  (*EP*)
   61.22 -val fmz = ["equality (3*x - 1 - (5*x - (2 - 4*x)) = -11)",
   61.23 +val fmz = ["equality (3*x - 1 - (5*x - (2 - 4*x)) = - 11)",
   61.24  	   "solveFor x", "solutions L"];
   61.25  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
   61.26  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   61.27 @@ -164,7 +164,7 @@
   61.28  "Schalk I s.86 Bsp 28b ((3*x+5)/18 - x/2 = -((3*x - 2)/9))";
   61.29  "Schalk I s.86 Bsp 28b ((3*x+5)/18 - x/2 = -((3*x - 2)/9))";
   61.30  "Schalk I s.86 Bsp 28b ((3*x+5)/18 - x/2 = -((3*x - 2)/9))";
   61.31 -(*ER-2*)
   61.32 +(*ER- 2*)
   61.33  val fmz = ["equality ((3*x+5)/18 - x/2 = -((3*x - 2)/9))",
   61.34  	   "solveFor x", "solutions L"];
   61.35  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
   61.36 @@ -203,7 +203,7 @@
   61.37  "Schalk I s.87 Bsp 36b ((17*x - 51)/9 - (-(13*x - 3)/6) + 11 -(9*x- 7)/4 = 0)";
   61.38  "Schalk I s.87 Bsp 36b ((17*x - 51)/9 - (-(13*x - 3)/6) + 11 -(9*x- 7)/4 = 0)";
   61.39  "Schalk I s.87 Bsp 36b ((17*x - 51)/9 - (-(13*x - 3)/6) + 11 -(9*x- 7)/4 = 0)";
   61.40 -(*ER-1*)
   61.41 +(*ER- 1*)
   61.42  val fmz = ["equality ((17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0)",
   61.43  	   "solveFor x", "solutions L"];
   61.44  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
   61.45 @@ -221,8 +221,8 @@
   61.46  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.47  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.48  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.49 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = -237 / 65]")) => ()
   61.50 -	 | _ => error "rlang.sml: diff.behav. in Schalk I s.86 Bsp 36b [x = -237 / 65]";
   61.51 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = - 237 / 65]")) => ()
   61.52 +	 | _ => error "rlang.sml: diff.behav. in Schalk I s.86 Bsp 36b [x = - 237 / 65]";
   61.53  
   61.54  
   61.55  (*WN---v *)
   61.56 @@ -240,7 +240,7 @@
   61.57  "Schalk I s.87 Bsp 38b (-(2/x) + 3/(2*x) - 4/(3*x) + 5/(4*x) + 6/(5*x) =65/8)";
   61.58  "Schalk I s.87 Bsp 38b (-(2/x) + 3/(2*x) - 4/(3*x) + 5/(4*x) + 6/(5*x) =65/8)";
   61.59  (*ER-3*)
   61.60 -val fmz = ["equality (-2/x + 3/(2*x) - 4/(3*x) + 5/(4*x) + 6/(5*x) = 65/8)",
   61.61 +val fmz = ["equality (- 2/x + 3/(2*x) - 4/(3*x) + 5/(4*x) + 6/(5*x) = 65/8)",
   61.62  	   "solveFor x", "solutions L"];
   61.63  val (dI',pI',mI') = ("RatEq",["univariate", "equation"],["no_met"]);
   61.64  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   61.65 @@ -314,12 +314,12 @@
   61.66  "Schalk I s.87 Bsp 44a ((1/2+(5*x)/2) \<up> 2 -((13*x)/2- 5/2) \<up> 2 -(6*x) \<up> 2+29)";
   61.67  "Schalk I s.87 Bsp 44a ((1/2+(5*x)/2) \<up> 2 -((13*x)/2- 5/2) \<up> 2 -(6*x) \<up> 2+29)";
   61.68  (*ER-5*)
   61.69 -val fmz = ["equality ((1/2 + (5*x)/2) \<up> 2 - ((13*x)/2 - 5/2) \<up> 2 = -1*(6*x) \<up> 2 + 29)",
   61.70 +val fmz = ["equality ((1/2 + (5*x)/2) \<up> 2 - ((13*x)/2 - 5/2) \<up> 2 = - 1*(6*x) \<up> 2 + 29)",
   61.71  	   "solveFor x", "solutions L"];
   61.72  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
   61.73  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   61.74 -(*Rewrite.trace_on:=true;
   61.75 -*)
   61.76 +Rewrite.trace_on:=true; (*true false*)
   61.77 +
   61.78  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.79  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.80  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.81 @@ -373,7 +373,7 @@
   61.82  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.83  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.84  val (p,_,f,nxt,_,pt) = me nxt p [1] pt; f2str f;
   61.85 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-3 + -1 * x = 0")) then ()
   61.86 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-3 + - 1 * x = 0")) then ()
   61.87  else error "rlangsml: diff.behav. in Schalk I s.88 Bsp 64c";
   61.88  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.89  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   61.90 @@ -392,7 +392,7 @@
   61.91  "Schalk I s.88 Bsp 79a (2) (m1*v1+m2*v2=0)";
   61.92  "Schalk I s.88 Bsp 79a (2) (m1*v1+m2*v2=0)";
   61.93  "Schalk I s.88 Bsp 79a (2) (m1*v1+m2*v2=0)";
   61.94 -(*ER-10*)
   61.95 +(*ER- 10*)
   61.96  val fmz = ["equality (m1*v1+m2*v2=0)",
   61.97  	   "solveFor m1", "solutions L"];
   61.98  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
   61.99 @@ -411,14 +411,14 @@
  61.100  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.101  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.102  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.103 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[m1 = -1 * m2 * v2 / v1]")) => ()
  61.104 -	 | _ => error "rlang.sml: diff.behav. in  Schalk I s.88 Bsp 79a (2) [m1 = -1 * m2 * v2 / v1]";
  61.105 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[m1 = - 1 * m2 * v2 / v1]")) => ()
  61.106 +	 | _ => error "rlang.sml: diff.behav. in  Schalk I s.88 Bsp 79a (2) [m1 = - 1 * m2 * v2 / v1]";
  61.107  
  61.108  (*-----------------  Schalk I s.89 Bsp 90a(1) ------------------------*)
  61.109  "Schalk I s.89 Bsp 90a (1) (f=((w+u)/(w+v))*v0)";
  61.110  "Schalk I s.89 Bsp 90a (1) (f=((w+u)/(w+v))*v0)";
  61.111  "Schalk I s.89 Bsp 90a (1) (f=((w+u)/(w+v))*v0)";
  61.112 -(*ER-11*)
  61.113 +(*ER- 11*)
  61.114  val fmz = ["equality (f=((w+u)/(w+v))*v0)",
  61.115  	   "solveFor v", "solutions L"];
  61.116  val (dI',pI',mI') = ("RatEq",["univariate", "equation"],["no_met"]);
  61.117 @@ -450,7 +450,7 @@
  61.118              EdUndef,
  61.119              0,
  61.120              Nundef,
  61.121 -            "f * w + -1 * u * v0 + -1 * v0 * w + f * v = 0")) then ()
  61.122 +            "f * w + - 1 * u * v0 + - 1 * v0 * w + f * v = 0")) then ()
  61.123  else error "rlang.sml: diff.behav. in Schalk I s.89 Bsp 90a";
  61.124  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.125  (*val nxt = Model_Problem ["degree_1", "polynomial", "univariate", "equation"])*)
  61.126 @@ -460,19 +460,19 @@
  61.127  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.128  (*val nxt = ("Apply_Method",Apply_Method ["PolyEq", "solve_d1_poly_equation"])*)
  61.129  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.130 -(*val f = "v = -1 * (f * w + -1 * u * v0 + -1 * v0 * w) / f")) : mout
  61.131 +(*val f = "v = - 1 * (f * w + - 1 * u * v0 + - 1 * v0 * w) / f")) : mout
  61.132  val nxt = ("Or_to_List",Or_to_List) : string * tac *)
  61.133  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.134 -(*val f = "[v = -1 * (f * w + -1 * u * v0 + -1 * v0 * w) / f]")) : mout
  61.135 +(*val f = "[v = - 1 * (f * w + - 1 * u * v0 + - 1 * v0 * w) / f]")) : mout
  61.136  val nxt = ("Check_elementwise",Check_elementwise "Assumptions") *)
  61.137  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.138 -(*val f = "[v = -1 * (f * w + -1 * u * v0 + -1 * v0 * w) / f]")) : mout
  61.139 +(*val f = "[v = - 1 * (f * w + - 1 * u * v0 + - 1 * v0 * w) / f]")) : mout
  61.140  val nxt = Check_Postcond ["degree_1", "polynomial", "univariate", "equation"])*)
  61.141  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.142 -(*val f = "[v = -1 * (f * w + -1 * u * v0 + -1 * v0 * w) / f]")) : mout
  61.143 +(*val f = "[v = - 1 * (f * w + - 1 * u * v0 + - 1 * v0 * w) / f]")) : mout
  61.144  val nxt = Check_Postcond ["normalise", "polynomial", "univariate", "equation"])*)
  61.145  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.146 -(*val f = "[v = -1 * (f * w + -1 * u * v0 + -1 * v0 * w) / f]")) : mout
  61.147 +(*val f = "[v = - 1 * (f * w + - 1 * u * v0 + - 1 * v0 * w) / f]")) : mout
  61.148  val nxt = ("Check_elementwise",Check_elementwise "Assumptions")*)
  61.149  
  61.150  Ctree.get_assumptions pt p;
  61.151 @@ -483,10 +483,10 @@
  61.152  val nxt = Check_Postcond ["rational", "univariate", "equation"])        *)
  61.153  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.154  case f of Form'  (Test_Out.FormKF (~1,EdUndef,0,Nundef,
  61.155 -        "[v = (u * v0 + v0 * w + -1 * f * w) / f]")) => ()
  61.156 +        "[v = (u * v0 + v0 * w + - 1 * f * w) / f]")) => ()
  61.157  	 | _ => error "rlang.sml: diff.behav. in  Schalk I s.89 Bsp 90a (1) [v=...]";
  61.158  if Ctree.get_assumptions pt p = 
  61.159 -   [TermC.str2term"(u * v0 + v0 * w + -1 * f * w) / f + w ~= 0"] then () 
  61.160 +   [TermC.str2term"(u * v0 + v0 * w + - 1 * f * w) / f + w ~= 0"] then () 
  61.161  else error "rlang.sml: diff.behav. in I s.89 Bsp 90a (1) [v=...] asm";
  61.162  
  61.163  
  61.164 @@ -494,7 +494,7 @@
  61.165  "Schalk I s.89 Bsp 90a (2) (f=((w+u)/(w+v))*v0)";
  61.166  "Schalk I s.89 Bsp 90a (2) (f=((w+u)/(w+v))*v0)";
  61.167  "Schalk I s.89 Bsp 90a (2) (f=((w+u)/(w+v))*v0)";
  61.168 -(*ER-12*)
  61.169 +(*ER- 12*)
  61.170  val fmz = ["equality (f=((w+u)/(w+v))*v0)",
  61.171  	   "solveFor w", "solutions L"];
  61.172  val (dI',pI',mI') = ("RatEq",["univariate", "equation"],["no_met"]);
  61.173 @@ -516,7 +516,7 @@
  61.174              EdUndef,
  61.175              0,
  61.176              Nundef,
  61.177 -            "f * v + -1 * u * v0 + (f + -1 * v0) * w = 0")) then ()
  61.178 +            "f * v + - 1 * u * v0 + (f + - 1 * v0) * w = 0")) then ()
  61.179  else error "rlang.sml: diff.behav. in Schalk I s.89 Bsp 90a (2)";
  61.180  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.181  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.182 @@ -527,11 +527,11 @@
  61.183  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.184  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.185  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.186 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[w = (u * v0 + -1 * f * v) / (f + -1 * v0)]")) => ()
  61.187 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[w = (u * v0 + - 1 * f * v) / (f + - 1 * v0)]")) => ()
  61.188  	 | _ => error "rlang.sml: diff.behav. in Schalk I Bsp 90a(2)";
  61.189  if Ctree.get_assumptions pt p = 
  61.190 -[TermC.str2term"v + (u * v0 + -1 * f * v) / (f + -1 * v0) ~= 0",
  61.191 - TermC.str2term"f + -1 * v0 ~= 0"]
  61.192 +[TermC.str2term"v + (u * v0 + - 1 * f * v) / (f + - 1 * v0) ~= 0",
  61.193 + TermC.str2term"f + - 1 * v0 ~= 0"]
  61.194  then writeln "asm should be simplified ???" 
  61.195  else error "rlang.sml: diff.behav. in Schalk I Bsp 90a(2) asm";
  61.196  
  61.197 @@ -558,7 +558,7 @@
  61.198  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.199  if f = Form'
  61.200        (Test_Out.FormKF
  61.201 -        (~1, EdUndef, 0, Nundef, "-1 * R * R2 + (R2 + -1 * R) * R1 = 0"))then()
  61.202 +        (~1, EdUndef, 0, Nundef, "- 1 * R * R2 + (R2 + - 1 * R) * R1 = 0"))then()
  61.203  else error "rlang.sml: diff.behav. in Schalk I s.89 Bsp 98a (1)";
  61.204  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.205  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.206 @@ -569,11 +569,11 @@
  61.207  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.208  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.209  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.210 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[R1 = R * R2 / (R2 + -1 * R)]")) => ()
  61.211 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[R1 = R * R2 / (R2 + - 1 * R)]")) => ()
  61.212  	 | _ => error "rlang.sml: diff.behav. in 98a(1) [R1 = ...]";
  61.213 -if Ctree.get_assumptions pt p = [TermC.str2term"R * R2 * R2 ~= (R2 + -1 * R) * 0",
  61.214 -			    TermC.str2term"R2 + -1 * R ~= 0",
  61.215 -			    TermC.str2term"R2 + -1 * R ~= 0"] 
  61.216 +if Ctree.get_assumptions pt p = [TermC.str2term"R * R2 * R2 ~= (R2 + - 1 * R) * 0",
  61.217 +			    TermC.str2term"R2 + - 1 * R ~= 0",
  61.218 +			    TermC.str2term"R2 + - 1 * R ~= 0"] 
  61.219      then writeln "asm should be simplified"
  61.220  else error "rlang.sml: diff.behav. in 98a(1) asm";
  61.221  
  61.222 @@ -581,7 +581,7 @@
  61.223  "Schalk I s.89 Bsp 104a (1) (y \<up> 2=2*p*x)";
  61.224  "Schalk I s.89 Bsp 104a (1) (y \<up> 2=2*p*x)";
  61.225  "Schalk I s.89 Bsp 104a (1) (y \<up> 2=2*p*x)";
  61.226 -(*ER-13 + EO-11 ?!?*)
  61.227 +(*ER- 13 + EO- 11 ?!?*)
  61.228  val fmz = ["equality (y \<up> 2=2*p*x)",
  61.229  	   "solveFor p", "solutions L"];
  61.230  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
  61.231 @@ -602,7 +602,7 @@
  61.232  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.233  case f of Form' (Test_Out.FormKF (_,_,0,_,"[p = y \<up> 2 / (2 * x)]")) => ()
  61.234  	 | _ => error "rlang.sml: diff.behav. in  Schalk I s.89 Bsp 104a (1) [p = y^2/(2*x)]";
  61.235 -if Ctree.get_assumptions pt p = [TermC.str2term"-2 * x ~= 0"] 
  61.236 +if Ctree.get_assumptions pt p = [TermC.str2term"- 2 * x ~= 0"] 
  61.237  then writeln"should be x ~= 0\nshould be x ~= 0\nshould be x ~= 0\n" 
  61.238  else error "rlang.sml: diff.behav. in  I s.89 Bsp 104a(1) asm";
  61.239  
  61.240 @@ -630,10 +630,10 @@
  61.241  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.242  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.243  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.244 -case f of Form' (Test_Out.FormKF (_,_,0,_,"[y = sqrt (2 * p * x), y = -1 * sqrt (2 * p * x)]")) => ()
  61.245 +case f of Form' (Test_Out.FormKF (_,_,0,_,"[y = sqrt (2 * p * x), y = - 1 * sqrt (2 * p * x)]")) => ()
  61.246  | _ => error "rlang.sml: diff.behav. Schalk I s.89 Bsp 104a(2) [x = ]";
  61.247 -if Ctree.get_assumptions pt p = [TermC.str2term"0 <= -1 * (-2 * p * x)",
  61.248 -                            TermC.str2term"0 <= -1 * (-2 * p * x)"] 
  61.249 +if Ctree.get_assumptions pt p = [TermC.str2term"0 <= - 1 * (- 2 * p * x)",
  61.250 +                            TermC.str2term"0 <= - 1 * (- 2 * p * x)"] 
  61.251  then writeln "asm should be simplified\nshould be simplified"
  61.252  else error "rlang.sml: diff.behav. in I s.89 Bsp 104a(2) asm";
  61.253  
  61.254 @@ -674,13 +674,13 @@
  61.255  
  61.256  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;f2str f;Ctree.get_assumptions pt p;
  61.257  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;f2str f;Ctree.get_assumptions pt p;
  61.258 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = sqrt ((a \<up> 2 * b \<up> 2 + -1 * a \<up> 2 * y \<up> 2) / b \<up> 2),\n x = -1 * sqrt ((a \<up> 2 * b \<up> 2 + -1 * a \<up> 2 * y \<up> 2) / b \<up> 2)]")) => writeln"should be simplified MG"
  61.259 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = sqrt ((a \<up> 2 * b \<up> 2 + - 1 * a \<up> 2 * y \<up> 2) / b \<up> 2),\n x = - 1 * sqrt ((a \<up> 2 * b \<up> 2 + - 1 * a \<up> 2 * y \<up> 2) / b \<up> 2)]")) => writeln"should be simplified MG"
  61.260  | _ => error "rlang.sml: diff.behav. in  Schalk I s.89 Bsp 118a(2) [x = ]";
  61.261  val asms = Ctree.get_assumptions pt p;
  61.262  if asms = 
  61.263 -  [TermC.str2term"0 * b \<up> 2 <= -1 * (a \<up> 2 * y \<up> 2 + -1 * a \<up> 2 * b \<up> 2)",
  61.264 +  [TermC.str2term"0 * b \<up> 2 <= - 1 * (a \<up> 2 * y \<up> 2 + - 1 * a \<up> 2 * b \<up> 2)",
  61.265     TermC.str2term"b \<up> 2 ~= 0",
  61.266 -   TermC.str2term"0 * b \<up> 2 <= -1 * (a \<up> 2 * y \<up> 2 + -1 * a \<up> 2 * b \<up> 2)",
  61.267 +   TermC.str2term"0 * b \<up> 2 <= - 1 * (a \<up> 2 * y \<up> 2 + - 1 * a \<up> 2 * b \<up> 2)",
  61.268     TermC.str2term"b \<up> 2 ~= 0"] then writeln"should be simplified MG"
  61.269  else error "rlang.sml: diff.behav. in Schalk I s.89 Bsp 118a(2) asms";
  61.270  
  61.271 @@ -688,7 +688,7 @@
  61.272  "Schalk I s.102 Bsp 268(1) (A = (1/2)*(x1*(y2-y3)+x2*(y3 - y1)+x3*(y1 - y2)))";
  61.273  "Schalk I s.102 Bsp 268(1) (A = (1/2)*(x1*(y2-y3)+x2*(y3 - y1)+x3*(y1 - y2)))";
  61.274  "Schalk I s.102 Bsp 268(1) (A = (1/2)*(x1*(y2-y3)+x2*(y3 - y1)+x3*(y1 - y2)))";
  61.275 -(*ER-14*)
  61.276 +(*ER- 14*)
  61.277  val fmz = ["equality (A = (1/2)*(x1*(y2 - y3)+x2*(y3 - y1)+x3*(y1 - y2)))",
  61.278  	   "solveFor x2", "solutions L"];
  61.279  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
  61.280 @@ -707,9 +707,9 @@
  61.281  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.282  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.283  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.284 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x2 =\n (-2 * A + x1 * y2 + x3 * y1 + -1 * x1 * y3 + -1 * x3 * y2) /\n (y1 + -1 * y3)]")) => ()
  61.285 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x2 =\n (- 2 * A + x1 * y2 + x3 * y1 + - 1 * x1 * y3 + - 1 * x3 * y2) /\n (y1 + - 1 * y3)]")) => ()
  61.286  | _ => error "rlang.sml: diff.behav. Schalk I s.102 Bsp 268(1) [x2=...]";
  61.287 -if Ctree.get_assumptions pt p = [TermC.str2term"y1 / 2 + -1 * y3 / 2 ~= 0"] then ()
  61.288 +if Ctree.get_assumptions pt p = [TermC.str2term"y1 / 2 + - 1 * y3 / 2 ~= 0"] then ()
  61.289  else error "rlang.sml: diff.behav. in I s.102 Bsp 268(1) asm";
  61.290  
  61.291  (*--------------------  Schalk II ----------------------------*)
  61.292 @@ -740,7 +740,7 @@
  61.293  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.294  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.295  val (p,_,f,nxt,_,pt) = me nxt p [1] pt; f2str f;
  61.296 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-2 + x = 0")) then ()
  61.297 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "- 2 + x = 0")) then ()
  61.298  else error "rlang.sml: diff.behav. in Schalk II s.56 Bsp 67b";
  61.299  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.300  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.301 @@ -793,7 +793,7 @@
  61.302  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.303  if f = Form'
  61.304        (Test_Out.FormKF
  61.305 -         (~1, EdUndef, 0, Nundef, "256 + -2368 * x + 576 * x \<up> 2 = 0"))then()
  61.306 +         (~1, EdUndef, 0, Nundef, "256 + - 2368 * x + 576 * x \<up> 2 = 0"))then()
  61.307  else error "rlang.sml: diff.behav. in Schalk II s.56 Bsp 68a";
  61.308  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.309  Ctree.get_assumptions pt p;
  61.310 @@ -815,20 +815,20 @@
  61.311  else error "rlang.sml: diff.behav. in II 68a";
  61.312  val asms = Ctree.get_assumptions pt p;
  61.313  if UnparseC.terms (*WN1104changed*) asms = 
  61.314 -"[0 <= (25 * (1 / 9) + -1 * (16 + 49 * (1 / 9))) * -56,\
  61.315 +"[0 <= (25 * (1 / 9) + - 1 * (16 + 49 * (1 / 9))) * -56,\
  61.316   \0 <= 1 / 9,\
  61.317   \0 <= 1 / 9,\
  61.318   \0 <= (-5 + 7 * sqrt (1 / 9) + 1) * 5,\
  61.319   \0 <= 1 / 9,\
  61.320 - \0 <= (25 * (1 / 9) + -1 * (16 + 49 * (1 / 9))) * -56,\
  61.321 + \0 <= (25 * (1 / 9) + - 1 * (16 + 49 * (1 / 9))) * -56,\
  61.322   \0 <= 1 / 9]"
  61.323  (*WN050916 before correction 'rewrite__set_ called with 'Rule_Set.Empty' for ..'
  61.324    thus: maybe the rls for the asms is Rule_Set.Empty ??:
  61.325 -   [(TermC.str2term"0 <= (25 * (1 / 9) + -1 * (16 + 49 * (1 / 9))) * -56", []),
  61.326 +   [(TermC.str2term"0 <= (25 * (1 / 9) + - 1 * (16 + 49 * (1 / 9))) * -56", []),
  61.327      (TermC.str2term"9 ~= 0", []),
  61.328      (TermC.str2term"0 <= (-5 + 7 * sqrt (1 / 9) + 1) * 5", []),
  61.329      (TermC.str2term"9 ~= 0", []),
  61.330 -    (TermC.str2term"0 <= (25 * (1 / 9) + -1 * (16 + 49 * (1 / 9))) * -56", [])]*)
  61.331 +    (TermC.str2term"0 <= (25 * (1 / 9) + - 1 * (16 + 49 * (1 / 9))) * -56", [])]*)
  61.332      then "should get True * False!!!"
  61.333  else error "rlang.sml: diff.behav. in II 68a asms";
  61.334  
  61.335 @@ -836,7 +836,7 @@
  61.336  "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
  61.337  "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
  61.338  "Schalk II s.56 Bsp 73b (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))";
  61.339 -(*EO-2*)
  61.340 +(*EO- 2*)
  61.341  val fmz = ["equality (sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))",
  61.342  	   "solveFor x", "solutions L"];
  61.343  val (dI',pI',mI') = ("RootEq",["univariate", "equation"],["no_met"]);
  61.344 @@ -849,7 +849,7 @@
  61.345  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.346  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.347  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.348 -(*"13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x" 
  61.349 +(*"13 + 13 * x + - 2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x" 
  61.350  -> Subproblem ("RootEq", ["univariate", ...])*)
  61.351  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.352  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.353 @@ -899,7 +899,7 @@
  61.354  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.355  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.356  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.357 -(*4 + 5 * x + -2 * sqrt (3 + 13 * x + 4 * x \<up> 2) = -2 + x" 
  61.358 +(*4 + 5 * x + - 2 * sqrt (3 + 13 * x + 4 * x \<up> 2) = - 2 + x" 
  61.359  -> Subproblem ("RootEq", ["univariate", ...])*)
  61.360  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.361  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.362 @@ -917,7 +917,7 @@
  61.363  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.364  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.365  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.366 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-24 + 4 * x = 0")) then ()
  61.367 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "- 24 + 4 * x = 0")) then ()
  61.368  else error "rlang.sml: diff.behav. in Schalk II s.56 Bsp 74a";
  61.369  (*-> ubproblem ("PolyEq", ["degree_1", ...]*)
  61.370  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.371 @@ -977,7 +977,7 @@
  61.372  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.373  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.374  (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt; since MGs norm_Rational*)
  61.375 -if f = Form'(Test_Out.FormKF (~1, EdUndef, 0, Nundef, "451584 + -112896 * x = 0"))then()
  61.376 +if f = Form'(Test_Out.FormKF (~1, EdUndef, 0, Nundef, "451584 + - 112896 * x = 0"))then()
  61.377  else error "rlang.sml: diff.behav. in Schalk II s.56 Bsp 77b";
  61.378  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.379  (* val nxt = ("Model_Problem",
  61.380 @@ -1026,7 +1026,7 @@
  61.381  
  61.382  (*-----------------  Schalk II s.66 Bsp 8a ------------------------*)
  61.383  "Schalk II s.66 Bsp 8a ((x - 4)/(x+4) = (1 - x)/(1+x))";
  61.384 -(*ER-15*)
  61.385 +(*ER- 15*)
  61.386  val fmz = ["equality ((x - 4)/(x+4) = (1 - x)/(1+x))",
  61.387  	   "solveFor x", "solutions L"];
  61.388  val (dI',pI',mI') = ("RatEq",["univariate", "equation"],["no_met"]);
  61.389 @@ -1039,7 +1039,7 @@
  61.390  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.391  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.392  val (p,_,f,nxt,_,pt) = me nxt p [1] pt; f2str f;
  61.393 -(*"(-4 + x) * (1 + x) = (1 + -1 * x) * (4 + x)"
  61.394 +(*"(-4 + x) * (1 + x) = (1 + - 1 * x) * (4 + x)"
  61.395  -> Subproblem ("RatEq", ["univariate", ...])*)
  61.396  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.397  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.398 @@ -1063,8 +1063,8 @@
  61.399  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.400  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.401  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.402 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 2, x = -2]")) => ()
  61.403 -	 | _ => error "rlang.sml: diff.behav. in  Schalk II s.66 Bsp 8a [x = 2, x = -2]";
  61.404 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 2, x = - 2]")) => ()
  61.405 +	 | _ => error "rlang.sml: diff.behav. in  Schalk II s.66 Bsp 8a [x = 2, x = - 2]";
  61.406  
  61.407  (*-----------------  Schalk II s.66 Bsp 10b ------------------------*)
  61.408  "Schalk II s.66 Bsp 10b (1/(x \<up> 2 - 9)+(2*x+3)/(x+3)=(3*x+4)/(x - 3))";
  61.409 @@ -1092,7 +1092,7 @@
  61.410              EdUndef,
  61.411              0,
  61.412              Nundef,
  61.413 -            "60 + 28 * x + -13 * x \<up> 2 + -1 * x \<up> 3 = 0")) then ()
  61.414 +            "60 + 28 * x + - 13 * x \<up> 2 + - 1 * x \<up> 3 = 0")) then ()
  61.415  else error "rlang.sml: diff.behav. in Schalk II s.66 Bsp 10b";
  61.416  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.417  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.418 @@ -1100,7 +1100,7 @@
  61.419  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.420  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.421  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.422 -(*60 + 28 * x + -13 * x \<up> 2 + -1 * x \<up> 3 = 0 ... degree 3 not solvable*)
  61.423 +(*60 + 28 * x + - 13 * x \<up> 2 + - 1 * x \<up> 3 = 0 ... degree 3 not solvable*)
  61.424  
  61.425  
  61.426  (*-----------------  Schalk II s.66 Bsp 20a ------------------------*)
  61.427 @@ -1130,7 +1130,7 @@
  61.428  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.429  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.430  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.431 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-25 + x \<up> 2 = 0")) then ()
  61.432 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "- 25 + x \<up> 2 = 0")) then ()
  61.433  else error "rlang.sml: diff.behav. in Schalk II s.66 Bsp 20a";
  61.434  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.435  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.436 @@ -1151,7 +1151,7 @@
  61.437  "Schalk II s.66 Bsp 23b (2*sqrt(261 - x) - sqrt(2+2*x)=sqrt(2)*sqrt(5 - 3*x))";
  61.438  "Schalk II s.66 Bsp 23b (2*sqrt(261 - x) - sqrt(2+2*x)=sqrt(2)*sqrt(5 - 3*x))";
  61.439  (*EO WN060310 something wrong:
  61.440 -([6, 6, 3, 1], Frm) "-1064944 + 32 * x + -48 * x \<up> 2 = 0"
  61.441 +([6, 6, 3, 1], Frm) "- 1064944 + 32 * x + -48 * x \<up> 2 = 0"
  61.442  	### or2list False
  61.443  ([6, 6, 3, 1], Res) "HOL.False"
  61.444  *)
  61.445 @@ -1182,7 +1182,7 @@
  61.446  val (p,_,f,nxt,_,pt) = me nxt p [1] pt; f2str f;
  61.447  if f = Form'
  61.448        (Test_Out.FormKF
  61.449 -       (~1, EdUndef, 0, Nundef, "-1064944 + 32 * x + -48 * x \<up> 2 = 0"))then()
  61.450 +       (~1, EdUndef, 0, Nundef, "- 1064944 + 32 * x + -48 * x \<up> 2 = 0"))then()
  61.451  else error "rlang.sml: diff.behav. in Schalk II s.66 Bsp 23b";
  61.452  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.453  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.454 @@ -1232,7 +1232,7 @@
  61.455  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.456  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.457  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.458 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[a = sqrt ((c \<up> 4 + A \<up> 2 * d \<up> 2) / (4 * c \<up> 2)),\n a = -1 * sqrt ((c \<up> 4 + A \<up> 2 * d \<up> 2) / (4 * c \<up> 2))]")) => ()
  61.459 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[a = sqrt ((c \<up> 4 + A \<up> 2 * d \<up> 2) / (4 * c \<up> 2)),\n a = - 1 * sqrt ((c \<up> 4 + A \<up> 2 * d \<up> 2) / (4 * c \<up> 2))]")) => ()
  61.460  | _ => error "rlang.sml: diff.behav. in  Schalk II s.66 Bsp 28a [a=...]";
  61.461  
  61.462  
  61.463 @@ -1252,7 +1252,7 @@
  61.464  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.465  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.466  (*val p = ([3],Res)
  61.467 -val f="1 * (a * (b * x)) = (a * b + (a * x + -1 * (b * x))) * (b + (x + -1 * a)
  61.468 +val f="1 * (a * (b * x)) = (a * b + (a * x + - 1 * (b * x))) * (b + (x + - 1 * a)
  61.469  val nxt = Subproblem ("RatEq",["univariate", "equation"]))*)
  61.470  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.471  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.472 @@ -1265,7 +1265,7 @@
  61.473  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.474  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.475  (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt; at introducing of MGs norm_Rational*)
  61.476 -(*val p = ([4,5],Res)  val f ="b * a \<up> 2 + -1 * a * b \<up> 2 + (a \<up> 2 + b \<up> 2 + -2 * a * b) * x +\n(b + -1 * a) * x \<up> 2 =\n0"))
  61.477 +(*val p = ([4,5],Res)  val f ="b * a \<up> 2 + - 1 * a * b \<up> 2 + (a \<up> 2 + b \<up> 2 + - 2 * a * b) * x +\n(b + - 1 * a) * x \<up> 2 =\n0"))
  61.478  val nxt = Subproblem ("PolyEq",["polynomial", "univariate", "equation"]))*)
  61.479  if f = Form'
  61.480        (Test_Out.FormKF
  61.481 @@ -1273,7 +1273,7 @@
  61.482              EdUndef,
  61.483              0,
  61.484              Nundef,
  61.485 -            "b * a \<up> 2 + -1 * a * b \<up> 2 + (a \<up> 2 + b \<up> 2 + -2 * a * b) * x +\n(b + -1 * a) * x \<up> 2 =\n0")) then ()
  61.486 +            "b * a \<up> 2 + - 1 * a * b \<up> 2 + (a \<up> 2 + b \<up> 2 + - 2 * a * b) * x +\n(b + - 1 * a) * x \<up> 2 =\n0")) then ()
  61.487  else error "rlang.sml: diff.behav. in chalk I s.87 Bsp 38b";
  61.488  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.489  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.490 @@ -1287,7 +1287,7 @@
  61.491  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.492  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.493  (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt;introducing MGs norm_Rational*)
  61.494 -(*val p = ([4,6,5],Res) val f ="[x =\n (2 * a * b + -1 * a \<up> 2 + -1 * b \<up> 2 +\n  sqrt\n   (a \<up> 4 + b \<up> 4 + -4 * a * a * b \<up> 2 + -4 * a * b * a \<up> 2 +\n    -4 * b * b * a \<up> 2 +\n    4 * a * a * b \<up> 2 +\n    4 * a * b * a \<up> 2 +\n    2 * a \<up> 2 * b \<up> 2)) /\n (-2 * a + 2 * #"
  61.495 +(*val p = ([4,6,5],Res) val f ="[x =\n (2 * a * b + - 1 * a \<up> 2 + - 1 * b \<up> 2 +\n  sqrt\n   (a \<up> 4 + b \<up> 4 + -4 * a * a * b \<up> 2 + -4 * a * b * a \<up> 2 +\n    -4 * b * b * a \<up> 2 +\n    4 * a * a * b \<up> 2 +\n    4 * a * b * a \<up> 2 +\n    2 * a \<up> 2 * b \<up> 2)) /\n (- 2 * a + 2 * #"
  61.496  nx Check_Postcond["abcFormula", "degree_2", "polynomial", "univariate", "equation*)
  61.497  (*9.9.03:   -"-  ["normalise", "polynomial", "univar...*)
  61.498  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.499 @@ -1296,7 +1296,7 @@
  61.500  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.501  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(*1 additional for MGs norm_Rational*)
  61.502  if p = ([],Res) andalso f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,
  61.503 -"[x =\n (2 * a * b + -1 * a \<up> 2 + -1 * b \<up> 2 +\n  sqrt\n   (a \<up> 4 + b \<up> 4 + -4 * a * a * b \<up> 2 + -4 * a * b * a \<up> 2 +\n    -4 * b * b * a \<up> 2 +\n    4 * a * a * b \<up> 2 +\n    4 * a * b * a \<up> 2 +\n    2 * a \<up> 2 * b \<up> 2)) /\n (-2 * a + 2 * b),\n x =\n (2 * a * b + -1 * a \<up> 2 + -1 * b \<up> 2 +\n  -1 *\n  sqrt\n   (a \<up> 4 + b \<up> 4 + -4 * a * a * b \<up> 2 + -4 * a * b * a \<up> 2 +\n    -4 * b * b * a \<up> 2 +\n    4 * a * a * b \<up> 2 +\n    4 * a * b * a \<up> 2 +\n    2 * a \<up> 2 * b \<up> 2)) /\n (-2 * a + 2 * b)]")) andalso nxt = ("End_Proof'",End_Proof') then writeln"simplify MG"
  61.504 +"[x =\n (2 * a * b + - 1 * a \<up> 2 + - 1 * b \<up> 2 +\n  sqrt\n   (a \<up> 4 + b \<up> 4 + -4 * a * a * b \<up> 2 + -4 * a * b * a \<up> 2 +\n    -4 * b * b * a \<up> 2 +\n    4 * a * a * b \<up> 2 +\n    4 * a * b * a \<up> 2 +\n    2 * a \<up> 2 * b \<up> 2)) /\n (- 2 * a + 2 * b),\n x =\n (2 * a * b + - 1 * a \<up> 2 + - 1 * b \<up> 2 +\n  - 1 *\n  sqrt\n   (a \<up> 4 + b \<up> 4 + -4 * a * a * b \<up> 2 + -4 * a * b * a \<up> 2 +\n    -4 * b * b * a \<up> 2 +\n    4 * a * a * b \<up> 2 +\n    4 * a * b * a \<up> 2 +\n    2 * a \<up> 2 * b \<up> 2)) /\n (- 2 * a + 2 * b)]")) andalso nxt = ("End_Proof'",End_Proof') then writeln"simplify MG"
  61.505  else error "rlang.sml: diff.behav. in rational-a-b";
  61.506  
  61.507  (*-----------------  Schalk II s.68 Bsp 56a ------------------------*)
  61.508 @@ -1314,28 +1314,28 @@
  61.509  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.510  
  61.511  ... with sml-nj:
  61.512 - (a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) =
  61.513 -    4 * (a * b) / (a \<up> 2 + -1 * b \<up> 2)
  61.514 + (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x) =
  61.515 +    4 * (a * b) / (a \<up> 2 + - 1 * b \<up> 2)
  61.516  add_fractions_p wird nicht angewendet, weil ...
  61.517  add_fract terminiert nicht: 030603
  61.518  siehe Rational.ML rational.sml
  61.519  *)
  61.520  
  61.521  (*
  61.522 -"(a + b * x) / (a + -1 * (b * x)) + -1 * (a + -1 * (b * x)) / (a + b * x) =\n4 * a * b / (a \<up> 2 + -1 * b \<up> 2)"
  61.523 +"(a + b * x) / (a + - 1 * (b * x)) + - 1 * (a + - 1 * (b * x)) / (a + b * x) =\n4 * a * b / (a \<up> 2 + - 1 * b \<up> 2)"
  61.524  
  61.525  val nxt = ("Rewrite_Set",Rewrite_Set "make_ratpoly") : string * tac           
  61.526 -"(a + b * x) / (a + -1 * b * x) + (-1 * a + b * x) / (a + b * x) =\n4 *
  61.527 -a * b / (a \<up> 2 + -1 * b \<up> 2)"
  61.528 +"(a + b * x) / (a + - 1 * b * x) + (- 1 * a + b * x) / (a + b * x) =\n4 *
  61.529 +a * b / (a \<up> 2 + - 1 * b \<up> 2)"
  61.530  
  61.531  
  61.532 -val t = TermC.str2term"(a + b * x) / (a + -1 * (b * x)) + -1 * (a + -1 * (b * x)) / (a + b * x) =\n4 * a * b / (a \<up> 2 + -1 * b \<up> 2)";
  61.533 -Rewrite.trace_on := false;
  61.534 +val t = TermC.str2term"(a + b * x) / (a + - 1 * (b * x)) + - 1 * (a + - 1 * (b * x)) / (a + b * x) =\n4 * a * b / (a \<up> 2 + - 1 * b \<up> 2)";
  61.535 +Rewrite.trace_on := false; (*true false*)
  61.536  val SOME (t',asm) = rewrite_set_ thy false norm_Rational t;
  61.537  UnparseC.term t';
  61.538 -Rewrite.trace_on:=false;
  61.539 +Rewrite.trace_on:=false; (*true false*)
  61.540  
  61.541 -#  rls: norm_Rational on: (a + b * x) / (a + -1 * (b * x)) + -1 * (a + -1 * (b * x)) / (a + b * x) = 4 * a * b / (a \<up> 2 + -1 * b \<up> 2)
  61.542 +#  rls: norm_Rational on: (a + b * x) / (a + - 1 * (b * x)) + - 1 * (a + - 1 * (b * x)) / (a + b * x) = 4 * a * b / (a \<up> 2 + - 1 * b \<up> 2)
  61.543  
  61.544  ##  rls: discard_minus on: 
  61.545  ##  rls: powers on:
  61.546 @@ -1344,19 +1344,19 @@
  61.547  ##  rls: reduce_0_1_2 on:
  61.548  ##  rls: order_add_mult on:
  61.549  ###  try thm: mult.commute
  61.550 -===  rewrites to: (a + b * x) / (a + -1 * (b * x)) + (-1 * a + -1 * (-1 * (b * x))) / (a + b * x) = b * (4 * a) / (a \<up> 2 + -1 * b \<up> 2)
  61.551 +===  rewrites to: (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + - 1 * (- 1 * (b * x))) / (a + b * x) = b * (4 * a) / (a \<up> 2 + - 1 * b \<up> 2)
  61.552  
  61.553  ###  try thm: real_mult_left_commute
  61.554 -===  rewrites to: (a + b * x) / (a + -1 * (b * x)) + (-1 * a + -1 * (-1 * (b * x))) / (a + b * x) = 4 * (b * a) / (a \<up> 2 + -1 * b \<up> 2)
  61.555 +===  rewrites to: (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + - 1 * (- 1 * (b * x))) / (a + b * x) = 4 * (b * a) / (a \<up> 2 + - 1 * b \<up> 2)
  61.556  
  61.557  ###  try thm: mult.commute
  61.558 -===  rewrites to: (a + b * x) / (a + -1 * (b * x)) + (-1 * a + -1 * (-1 * (b * x))) / (a + b * x) = 4 * (a * b) / (a \<up> 2 + -1 * b \<up> 2)
  61.559 +===  rewrites to: (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + - 1 * (- 1 * (b * x))) / (a + b * x) = 4 * (a * b) / (a \<up> 2 + - 1 * b \<up> 2)
  61.560  
  61.561  ###  try calc: op *'
  61.562 -===  calc. to: (a + b * x) / (a + -1 * (b * x)) + (-1 * a + 1 * (b * x)) / (a +b * x) = 4 * (a * b) / (a \<up> 2 + -1 * b \<up> 2)
  61.563 +===  calc. to: (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + 1 * (b * x)) / (a +b * x) = 4 * (a * b) / (a \<up> 2 + - 1 * b \<up> 2)
  61.564  
  61.565 -##  rls: add_fractions_p on: (a + b * x) / (a + -1 * (b * x)) + (-1 * a + 1 * (b * x)) / (a + b * x) = 
  61.566 -                                                                                                    4 * (a * b) / (a \<up> 2 + -1 * b \<up> 2)
  61.567 +##  rls: add_fractions_p on: (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + 1 * (b * x)) / (a + b * x) = 
  61.568 +                                                                                                    4 * (a * b) / (a \<up> 2 + - 1 * b \<up> 2)
  61.569  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!GC
  61.570  
  61.571  ##  rls: discard_minus on:
  61.572 @@ -1365,12 +1365,12 @@
  61.573  ##  rls: expand on:
  61.574  ##  rls: reduce_0_1_2 on:
  61.575  ###  try thm: real_mult_1
  61.576 -===  rewrites to: (a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a \<up> 2 + -1 * b \<up> 2)
  61.577 +===  rewrites to: (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a \<up> 2 + - 1 * b \<up> 2)
  61.578  
  61.579  ##  rls: order_add_mult on:
  61.580  
  61.581 -##  rls: add_fractions_p on: (a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) =
  61.582 -                                                                                                    4 * (a * b) / (a \<up> 2 + -1 * b \<up> 2)
  61.583 +##  rls: add_fractions_p on: (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x) =
  61.584 +                                                                                                    4 * (a * b) / (a \<up> 2 + - 1 * b \<up> 2)
  61.585  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!GC
  61.586  
  61.587  ##  rls: discard_minus on:
  61.588 @@ -1380,8 +1380,8 @@
  61.589  ##  rls: reduce_0_1_2 on:
  61.590  ##  rls: order_add_mult on:
  61.591  ##  rls: collect_numerals on:
  61.592 -##  rls: add_fractions_p on: (a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) =
  61.593 -4 * (a * b) / (a \<up> 2 + -1 * b \<up> 2)
  61.594 +##  rls: add_fractions_p on: (a + b * x) / (a + - 1 * (b * x)) + (- 1 * a + b * x) / (a + b * x) =
  61.595 +4 * (a * b) / (a \<up> 2 + - 1 * b \<up> 2)
  61.596  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!GC
  61.597  *)
  61.598   
  61.599 @@ -1422,7 +1422,7 @@
  61.600              EdUndef,
  61.601              0,
  61.602              Nundef,
  61.603 -            (*"-4 * b \<up> 2 + -4 * a * b + 4 * b \<up> 2 + 8 * a * b +\n(-2 * a + -4 * a + -4 * b + 2 * a + 8 * b) * x +\n-4 * x \<up> 2 =\n0" before MG*)
  61.604 +            (*"-4 * b \<up> 2 + -4 * a * b + 4 * b \<up> 2 + 8 * a * b +\n(- 2 * a + -4 * a + -4 * b + 2 * a + 8 * b) * x +\n-4 * x \<up> 2 =\n0" before MG*)
  61.605  	    "4 * a * b + (-4 * a + 4 * b) * x + -4 * x \<up> 2 = 0")) then ()
  61.606  else error "rlang.sml: diff.behav. in Schalk II s.68 Bsp 61b";
  61.607  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.608 @@ -1433,7 +1433,7 @@
  61.609  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.610  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.611  (* f= ... "-4 * b \<up> 2 + -4 * a * b + 4 * b \<up> 2 + 8 * a * b + 
  61.612 -           (-2 * a + -4 * a + -4 * b + 2 * a + 8 * b) * x + -4 * x \<up> 2 =0"*)
  61.613 +           (- 2 * a + -4 * a + -4 * b + 2 * a + 8 * b) * x + -4 * x \<up> 2 =0"*)
  61.614  (*val nxt = ("Rewrite_Set_Inst",Rewrite_Set_Inst ([#],"d2_polyeq_abcFormula_simplify"))*)
  61.615  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.616  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.617 @@ -1442,8 +1442,8 @@
  61.618  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.619  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.620  (*if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef, with norm_Rational before MG
  61.621 -"[x =\n (-2 * a + -4 * b + 6 * a +\n  sqrt\n   (32 * a * b + -16 * a \<up> 2 + -48 * b \<up> 2 + 24 * a \<up> 2 +\n    64 * b \<up> 2 +\n    8 * a \<up> 2)) /\n -8,\n x =\n (-2 * a + -4 * b + 6 * a +\n  -1 *\n  sqrt\n   (32 * a * b + -16 * a \<up> 2 + -48 * b \<up> 2 + 24 * a \<up> 2 +\n    64 * b \<up> 2 +\n    8 * a \<up> 2)) /\n -8]")) then writeln"simplify MG"*)
  61.622 -if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x =\n (-4 * b + 4 * a + sqrt (32 * a * b + 16 * a \<up> 2 + 16 * b \<up> 2)) / -8,\n x =\n (-4 * b + 4 * a + -1 * sqrt (32 * a * b + 16 * a \<up> 2 + 16 * b \<up> 2)) /\n -8]")) then ()
  61.623 +"[x =\n (- 2 * a + -4 * b + 6 * a +\n  sqrt\n   (32 * a * b + - 16 * a \<up> 2 + -48 * b \<up> 2 + 24 * a \<up> 2 +\n    64 * b \<up> 2 +\n    8 * a \<up> 2)) /\n -8,\n x =\n (- 2 * a + -4 * b + 6 * a +\n  - 1 *\n  sqrt\n   (32 * a * b + - 16 * a \<up> 2 + -48 * b \<up> 2 + 24 * a \<up> 2 +\n    64 * b \<up> 2 +\n    8 * a \<up> 2)) /\n -8]")) then writeln"simplify MG"*)
  61.624 +if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x =\n (-4 * b + 4 * a + sqrt (32 * a * b + 16 * a \<up> 2 + 16 * b \<up> 2)) / -8,\n x =\n (-4 * b + 4 * a + - 1 * sqrt (32 * a * b + 16 * a \<up> 2 + 16 * b \<up> 2)) /\n -8]")) then ()
  61.625  else error "rlang.sml: diff.behav. Bsp 61b";
  61.626  (*WN.18.12.03: extreme run-time !!!*)
  61.627  
  61.628 @@ -1493,14 +1493,14 @@
  61.629  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.630  (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt;introduc.MGs norm_Rational*)
  61.631  if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,
  61.632 -        "[x = (-2 * a + 4 * b + sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4,\n x =\n (-2 * a + 4 * b + -1 * sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4]")) then writeln "simplify MG"
  61.633 +        "[x = (- 2 * a + 4 * b + sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4,\n x =\n (- 2 * a + 4 * b + - 1 * sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4]")) then writeln "simplify MG"
  61.634  else error "rlang.sml: diff.behav. in II 62b [x=...]";
  61.635  val asms = Ctree.get_assumptions pt p;
  61.636 -if asms = [TermC.str2term"0 <= ((-2 * a + 4 * b + sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4 + a) \<up> 2 + ((-2 * a + 4 * b + sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4 - 2 * b) \<up> 2",
  61.637 +if asms = [TermC.str2term"0 <= ((- 2 * a + 4 * b + sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4 + a) \<up> 2 + ((- 2 * a + 4 * b + sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4 - 2 * b) \<up> 2",
  61.638  	   TermC.str2term"0 <= a + 2 * b",
  61.639  	   TermC.str2term"8 * (-4 * a * b) <= (-4 * b + 2 * a) \<up> 2",
  61.640  	   TermC.str2term"8 * (-4 * a * b) <= (-4 * b + 2 * a) \<up> 2",
  61.641 -	   TermC.str2term"0 <= ((-2 * a + 4 * b + -1 * sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4 + a) \<up> 2 + ((-2 * a + 4 * b + -1 * sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4 - 2 * b) \<up> 2",
  61.642 +	   TermC.str2term"0 <= ((- 2 * a + 4 * b + - 1 * sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4 + a) \<up> 2 + ((- 2 * a + 4 * b + - 1 * sqrt (16 * a * b + 16 * b \<up> 2 + 4 * a \<up> 2)) / 4 - 2 * b) \<up> 2",
  61.643  	   TermC.str2term"0 <= a + 2 * b",
  61.644  	   TermC.str2term"8 * (-4 * a * b) <= (-4 * b + 2 * a) \<up> 2",
  61.645  	   TermC.str2term"8 * (-4 * a * b) <= (-4 * b + 2 * a) \<up> 2"] 
  61.646 @@ -1540,21 +1540,21 @@
  61.647  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.648  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.649  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  61.650 -if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 0, x = 0, x = -1 / 2]")) then()
  61.651 +if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 0, x = 0, x = - 1 / 2]")) then()
  61.652  else error "rlang.sml WN.TEST new behaviour";
  61.653  
  61.654  "------ rlang.sml end---------------------------------";
  61.655  
  61.656  (*------------------------------vvv-Rewrite_Set "rat_eliminate"---------
  61.657 -> Rewrite.trace_on:=true;
  61.658 +> Rewrite.trace_on:=true; (*true false*)
  61.659  > val t = TermC.str2term 
  61.660 -  "(3 + -1 * x + 1 * x \<up> 2) / (9 * x + -6 * x \<up> 2 + 1 * x \<up> 3) = 1 / x";
  61.661 +  "(3 + - 1 * x + 1 * x \<up> 2) / (9 * x + -6 * x \<up> 2 + 1 * x \<up> 3) = 1 / x";
  61.662  > val SOME (t',asm) = 
  61.663        rewrite_ thy dummy_ord rateq_erls true rat_mult_denominator_both t;
  61.664  > UnparseC.term t'; UnparseC.terms asm;
  61.665 -"(3 + -1 * x + 1 * x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + 1 * x \<up> 3)"
  61.666 +"(3 + - 1 * x + 1 * x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + 1 * x \<up> 3)"
  61.667  "[\"9 * x + -6 * x \<up> 2 + 1 * x \<up> 3 ~= 0\",\"x ~= 0\"]"
  61.668 -> Rewrite.trace_on:=false;
  61.669 +> Rewrite.trace_on:=false; (*true false*)
  61.670    ------------------------------ \<up> -Rewrite_Set "rat_eliminate"---------*)
  61.671  
  61.672  
  61.673 @@ -1591,15 +1591,15 @@
  61.674  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  61.675  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  61.676  if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,
  61.677 -"[a = sqrt ((-1 * b \<up> 2 + 4 * r \<up> 2) / 1),\n a = -1 * sqrt ((-1 * b \<up> 2 + 4 * r \<up> 2) / 1)]")) andalso nxt = ("End_Proof'",End_Proof')
  61.678 +"[a = sqrt ((- 1 * b \<up> 2 + 4 * r \<up> 2) / 1),\n a = - 1 * sqrt ((- 1 * b \<up> 2 + 4 * r \<up> 2) / 1)]")) andalso nxt = ("End_Proof'",End_Proof')
  61.679  then writeln"simplify result\nsimplify result\nsimplify result"
  61.680  else error "rlang.sml: diff.behav. in Pythagoras";
  61.681  val asms = Ctree.get_assumptions pt p;
  61.682  (*if asms = [TermC.str2term"0 <= -4 * (b \<up> 2 / 4 + -4 * r \<up> 2 / 4)",
  61.683               TermC.str2term"0 <= -4 * (b \<up> 2 / 4 + -4 * r \<up> 2 / 4)"]*)
  61.684  if UnparseC.terms (*WN1104changed*) asms = 
  61.685 -   "[0 <= -4 * (b \<up> 2 / 4 + -1 * r \<up> 2 / 1),\
  61.686 -   \0 <= -4 * (b \<up> 2 / 4 + -1 * r \<up> 2 / 1)]"
  61.687 +   "[0 <= -4 * (b \<up> 2 / 4 + - 1 * r \<up> 2 / 1),\
  61.688 +   \0 <= -4 * (b \<up> 2 / 4 + - 1 * r \<up> 2 / 1)]"
  61.689  then writeln"simplify result\nsimplify result\nsimplify result"
  61.690  else error "rlang.sml: diff.behav. in Pythagoras asms";
  61.691  
  61.692 @@ -1607,7 +1607,7 @@
  61.693  "-------------------- WN.15.5.03: equation within the maximum example ------";
  61.694  "-------------------- WN.15.5.03: equation within the maximum example ------";
  61.695  "-------------------- WN.15.5.03: equation within the maximum example ------";
  61.696 -(*EO-10*)
  61.697 +(*EO- 10*)
  61.698  val fmz = ["equality (2*sqrt(r \<up> 2 - (u/2) \<up> 2) - u \<up> 2/(2*sqrt(r \<up> 2 - (u/2) \<up> 2))= 0)",
  61.699  	   "solveFor u", "solutions L"];
  61.700  val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
  61.701 @@ -1658,7 +1658,7 @@
  61.702              EdUndef,
  61.703              0,
  61.704              Nundef,
  61.705 -            "-16 * r \<up> 4 + 8 * r \<up> 2 * u \<up> 2 = 0")) then ()
  61.706 +            "- 16 * r \<up> 4 + 8 * r \<up> 2 * u \<up> 2 = 0")) then ()
  61.707  else error "rlang.sml: diff.behav. in Schalk I s.87 Bsp 38b";
  61.708  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  61.709  (*val nxt = Model_Problem ["sq_only", "degree_2", "polynomial", "univariate", "equation"]) *)
  61.710 @@ -1674,5 +1674,5 @@
  61.711  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
  61.712  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
  61.713  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  61.714 -if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[u = sqrt (2 * r \<up> 2 / 1), u = -1 * sqrt (2 * r \<up> 2 / 1)]")) then()
  61.715 +if f = Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[u = sqrt (2 * r \<up> 2 / 1), u = - 1 * sqrt (2 * r \<up> 2 / 1)]")) then()
  61.716  else error "rlang.sml WN.TEST new behaviour in max-rooteq";
    62.1 --- a/test/Tools/isac/Knowledge/root.sml	Mon Jun 21 22:08:01 2021 +0200
    62.2 +++ b/test/Tools/isac/Knowledge/root.sml	Sun Jul 18 18:15:27 2021 +0200
    62.3 @@ -1,4 +1,4 @@
    62.4 -(* Title:  testexamples for Root, radicals
    62.5 +(* Title:  Knowledge/root.sml
    62.6     Author: Walther Neuper
    62.7     (c) due to copyright terms
    62.8   *)
    62.9 @@ -19,7 +19,7 @@
   62.10  val SOME (t',_) = rewrite_set_ thy false Root_erls t;
   62.11  if UnparseC.term t' = "1" then () else error "root.sml: diff.behav. sqrt 1";
   62.12  
   62.13 -val t = TermC.str2term "sqrt (-1)";
   62.14 +val t = TermC.str2term "sqrt (- 1)";
   62.15  val NONE = rewrite_set_ thy false Root_erls t;
   62.16  
   62.17  val t = TermC.str2term "sqrt 0";
    63.1 --- a/test/Tools/isac/Knowledge/rooteq.sml	Mon Jun 21 22:08:01 2021 +0200
    63.2 +++ b/test/Tools/isac/Knowledge/rooteq.sml	Sun Jul 18 18:15:27 2021 +0200
    63.3 @@ -118,7 +118,7 @@
    63.4  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
    63.5  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
    63.6  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
    63.7 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "1 + -25 * x = 0")) then ()
    63.8 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "1 + - 25 * x = 0")) then ()
    63.9  else error "rooteq.sml: diff.behav.poly in (1/sqrt(x)=5)";
   63.10  (*-> Subproblem ("PolyEq", ["polynomial", ...])*)
   63.11  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.12 @@ -160,7 +160,7 @@
   63.13  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.14  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.15  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.16 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-24 + x = 0")) then ()
   63.17 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "- 24 + x = 0")) then ()
   63.18  else error "rooteq.sml: diff.behav.poly in sqrt(x+1)=5";
   63.19  (*-> Subproblem ("PolyEq", ["polynomial", ...])*)
   63.20  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.21 @@ -191,7 +191,7 @@
   63.22  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.23  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.24  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.25 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-184 + 46 * x = 0")) then ()
   63.26 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "- 184 + 46 * x = 0")) then ()
   63.27  else error "rooteq.sml: diff.behav.poly in 4*sqrt(4*x+2)=3*sqrt(2*x+24)";
   63.28  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.29  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.30 @@ -222,7 +222,7 @@
   63.31  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.32  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.33  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.34 -(*"13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"))
   63.35 +(*"13 + 13 * x + - 2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x"))
   63.36  val nxt = ("Subproblem",Subproblem ("RootEq",["univariate", "equation"]))*)
   63.37  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.38  (*val nxt = Model_Problem ["sq", "rootX", "univariate", "equation"]) *)
   63.39 @@ -262,7 +262,7 @@
   63.40  
   63.41  "--------------(sqrt(x+1)+sqrt(4*x+4)=sqrt(9*x+9))---------- SUBPBL.2.------";
   63.42  val fmz = 
   63.43 -    ["equality (13 + 13 * x + -2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x)",
   63.44 +    ["equality (13 + 13 * x + - 2 * sqrt ((4 + 4 * x) * (9 + 9 * x)) = 1 + x)",
   63.45       "solveFor x", "solutions L"];
   63.46  val (dI',pI',mI') = ("RootEq",["sq", "rootX", "univariate", "equation"],
   63.47  		     ["RootEq", "solve_sq_root_equation"]);
   63.48 @@ -332,9 +332,9 @@
   63.49  (*val nxt = ("Specify_Method",Specify_Method ["PolyEq", "normalise_poly"])*)
   63.50  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.51  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.52 -(*val p = ([3,2],Res)val f = Form' (Test_Out.FormKF (~1,EdUndef,2,Nundef,"-1 + x = 0"))
   63.53 +(*val p = ([3,2],Res)val f = Form' (Test_Out.FormKF (~1,EdUndef,2,Nundef,"- 1 + x = 0"))
   63.54  val nxt = Subproblem ("PolyEq",["polynomial", "univariate", "equation"]))*)
   63.55 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-1 + x = 0")) then ()
   63.56 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "- 1 + x = 0")) then ()
   63.57  else error "rooteq.sml: diff.behav.poly in sqrt(x+1)+sqrt(4*x+4)=sqrt..";
   63.58  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.59  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.60 @@ -460,8 +460,8 @@
   63.61  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.62  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   63.63  val (p,_,f,nxt,_,pt) = me nxt p c pt;                                  
   63.64 -case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = -2]")) => ()
   63.65 -	 | _ => error "rooteq.sml: diff.behav. [x = -2]";
   63.66 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = - 2]")) => ()
   63.67 +	 | _ => error "rooteq.sml: diff.behav. [x = - 2]";
   63.68  
   63.69  "----------- rooteq.sml end--------";
   63.70  
   63.71 @@ -500,7 +500,7 @@
   63.72  (*"9 + 4 * x = 5 + 2 * x + 2 * sqrt (x \<up> 2 + 5 * x)"
   63.73  isolate_root*)
   63.74  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.75 -(*"sqrt (x \<up> 2 + 5 * x) = (5 + 2 * x + -1 * (9 + 4 * x)) / (-1 * 2)"
   63.76 +(*"sqrt (x \<up> 2 + 5 * x) = (5 + 2 * x + - 1 * (9 + 4 * x)) / (- 1 * 2)"
   63.77  Test_simplify*)
   63.78  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.79  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.80 @@ -508,7 +508,7 @@
   63.81  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.82  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.83  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.84 -(*"x \<up> 2 + 5 * x + -1 * (4 + (x \<up> 2 + 4 * x)) = 0"*)
   63.85 +(*"x \<up> 2 + 5 * x + - 1 * (4 + (x \<up> 2 + 4 * x)) = 0"*)
   63.86  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.87  (*"-4 + x = 0"
   63.88    val nxt =("Subproblem",Subproblem ("Test",["LINEAR", "univariate"...*)
   63.89 @@ -526,7 +526,7 @@
   63.90  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.91  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.92  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.93 -(*"x = 0 + -1 * -4", nxt Test_simplify*)
   63.94 +(*"x = 0 + - 1 * -4", nxt Test_simplify*)
   63.95  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.96  (*"x = 4", nxt Check_Postcond ["LINEAR", "univariate", "equation", "test"]*)
   63.97  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   63.98 @@ -571,7 +571,7 @@
   63.99  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.100  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.101  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.102 -(*"9 + -1 * x \<up> 2 = 0"
  63.103 +(*"9 + - 1 * x \<up> 2 = 0"
  63.104    Subproblem ("Test",["plain_square", "univariate", "equation"]))*)
  63.105  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.106  (*Model_Problem ["plain_square", "univariate", "equation"]*)
  63.107 @@ -585,13 +585,13 @@
  63.108  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.109  (*Apply_Method ("Test", "solve_plain_square")*)
  63.110  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.111 -(*"9 + -1 * x \<up> 2 = 0", nxt Rewrite_Set "isolate_bdv"*)
  63.112 +(*"9 + - 1 * x \<up> 2 = 0", nxt Rewrite_Set "isolate_bdv"*)
  63.113  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.114 -(*"x \<up> 2 = (0 + -1 * 9) / -1", nxt Rewrite_Set "Test_simplify"*)
  63.115 +(*"x \<up> 2 = (0 + - 1 * 9) / - 1", nxt Rewrite_Set "Test_simplify"*)
  63.116  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.117  (*"x \<up> 2 = 9", nxt Rewrite ("square_equality"*)
  63.118  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.119 -(*"x = sqrt 9 | x = -1 * sqrt 9", nxt Rewrite_Set "tval_rls"*)
  63.120 +(*"x = sqrt 9 | x = - 1 * sqrt 9", nxt Rewrite_Set "tval_rls"*)
  63.121  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
  63.122  (*"x = -3 | x = 3", nxt Or_to_List*)
  63.123  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
    64.1 --- a/test/Tools/isac/Knowledge/rootrat.sml	Mon Jun 21 22:08:01 2021 +0200
    64.2 +++ b/test/Tools/isac/Knowledge/rootrat.sml	Sun Jul 18 18:15:27 2021 +0200
    64.3 @@ -25,8 +25,8 @@
    64.4  
    64.5  val thy = @{theory RootRat};
    64.6  val ctxt = Proof_Context.init_global thy;
    64.7 -val ttt = (the o (parseNEW  ctxt)) ("-1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |"^
    64.8 -                          "\nx = -1 * (- (2 / 2) + -1 * sqrt ((2 / 2) \<up> 2 - -8))");
    64.9 +val ttt = (the o (parseNEW  ctxt)) ("- 1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |"^
   64.10 +                          "\nx = - 1 * (- (2 / 2) + - 1 * sqrt ((2 / 2) \<up> 2 - -8))");
   64.11  TermC.atomty t; (*!real ?by sqrt and  \<up> ?*)
   64.12  
   64.13  "--- val rls = calculate_Poly ---";
   64.14 @@ -48,8 +48,8 @@
   64.15  
   64.16  val SOME (t,asm) = rewrite_set_ thy true rls ttt;
   64.17  if UnparseC.term t =
   64.18 -"-1 * x = -1 + sqrt (2 \<up> 2 / 2 \<up> 2 - -8) \<or>\nx = -1 * (-1 + -1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))"
   64.19 -(*"-1 * x = -1 + sqrt (1 \<up> 2 - -8) | x = -1 * (-1 + -1 * sqrt (1 \<up> 2 - -8))"*)
   64.20 +"- 1 * x = - 1 + sqrt (2 \<up> 2 / 2 \<up> 2 - -8) \<or>\nx = - 1 * (- 1 + - 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))"
   64.21 +(*"- 1 * x = - 1 + sqrt (1 \<up> 2 - -8) | x = - 1 * (- 1 + - 1 * sqrt (1 \<up> 2 - -8))"*)
   64.22  then () else error "val rls = calculate_Rational goon";
   64.23  
   64.24  "--- val rls = calculate_RootRat ---";
    65.1 --- a/test/Tools/isac/Knowledge/rootrateq.sml	Mon Jun 21 22:08:01 2021 +0200
    65.2 +++ b/test/Tools/isac/Knowledge/rootrateq.sml	Sun Jul 18 18:15:27 2021 +0200
    65.3 @@ -66,7 +66,7 @@
    65.4  "------------ test thm rootrat_equation_left_1 -------------------";
    65.5  "------------ test thm rootrat_equation_left_1 -------------------";
    65.6  val c = [];
    65.7 -val fmz = ["equality ( -2 + 1/(1 - sqrt(x))= (0::real))", "solveFor x", "solutions L"];
    65.8 +val fmz = ["equality ( - 2 + 1/(1 - sqrt(x))= (0::real))", "solveFor x", "solutions L"];
    65.9  val (dI',pI',mI') = ("RootRatEq",["univariate", "equation"],["no_met"]);
   65.10  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   65.11  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   65.12 @@ -82,7 +82,7 @@
   65.13  
   65.14  which we did not investigate further due to the decision to drop the whole type of equation.
   65.15  *)
   65.16 -if f2str f = "1 = (0 - -2) * (1 + -1 * sqrt x)" then ()
   65.17 +if f2str f = "1 = (0 - - 2) * (1 + - 1 * sqrt x)" then ()
   65.18  else error "rootrateq.sml: diff.behav. in rootrat_equation_left_1 a";
   65.19  (*-> Subproblem ("RootRatEq", ["sq", "rootX", "univariate", "equation"])*)
   65.20  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   65.21 @@ -92,12 +92,12 @@
   65.22  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p''',_,f,nxt,_,pt''') = me nxt p c pt;
   65.23  
   65.24  (*we investigate, why the next step results in Empty_Tac*)
   65.25 -f2str f = "1 = 2 * (1 + -1 * sqrt x)";
   65.26 +f2str f = "1 = 2 * (1 + - 1 * sqrt x)";
   65.27  nxt = ("Rewrite_Set", Rewrite_Set "make_rooteq");
   65.28  (*... these ar the step's arguments; from these we do directly ...*)
   65.29 -val SOME t = parseNEW ctxt "1 = 2 * (1 + -1 * sqrt x)"
   65.30 +val SOME t = parseNEW ctxt "1 = 2 * (1 + - 1 * sqrt x)"
   65.31  val SOME (t, _) = rewrite_set_ thy true make_rooteq t;
   65.32 -UnparseC.term t = "1 = 2 + -2 * sqrt x";
   65.33 +UnparseC.term t = "1 = 2 + - 2 * sqrt x";
   65.34  (*... which works; thus error must be in script interpretation*)
   65.35  
   65.36  "~~~~~ fun me, args:"; val (tac, (p:pos'), _, (pt:ctree)) = (nxt, p, c, pt);
   65.37 @@ -110,30 +110,30 @@
   65.38  pIopt; (*= SOME ["sq", "rootX", "univariate", "equation"]*)
   65.39  member op = [Pbl,Met] p_; (*= false*)
   65.40  "~~~~~ fun do_next, args:"; (*stopped due to strange exn
   65.41 -  "check_elementwise: no set 1 = 2 + -2 * sqrt x"*)
   65.42 +  "check_elementwise: no set 1 = 2 + - 2 * sqrt x"*)
   65.43  
   65.44  (*---- 2nd try: we investigate the script ["RootEq", "solve_sq_root_equation"] found via pbl*)
   65.45  val t = TermC.str2term "((lhs e_e) is_sqrtTerm_in v_v) | ((rhs e_e) is_sqrtTerm_in v_v)";
   65.46 -val t = TermC.str2term ("((lhs (1 = 2 * (1 + -1 * sqrt x))) is_sqrtTerm_in x) |" ^
   65.47 -                 " ((rhs (1 = 2 * (1 + -1 * sqrt x))) is_sqrtTerm_in x)");
   65.48 +val t = TermC.str2term ("((lhs (1 = 2 * (1 + - 1 * sqrt x))) is_sqrtTerm_in x) |" ^
   65.49 +                 " ((rhs (1 = 2 * (1 + - 1 * sqrt x))) is_sqrtTerm_in x)");
   65.50  val SOME (t, _) = rewrite_set_ thy true rooteq_srls t;
   65.51  UnparseC.term t = "True | True"; (*...was same in 2002 (NOT "True"); so program seems to take 
   65.52    [univariate,equation] and to refine to ["sq", "rootX", "univariate", "equation"] in 2002*)
   65.53  
   65.54  (*(*these are the errors during stepping into the code:*)
   65.55 -Step_Solve.do_next (pt,ip); (*check_elementwise: no set 1 = 2 + -2 * sqrt x: fun mk_set raises
   65.56 +Step_Solve.do_next (pt,ip); (*check_elementwise: no set 1 = 2 + - 2 * sqrt x: fun mk_set raises
   65.57    this exn in Check_elementwise ONLY ?!?*)
   65.58  Step.do_next p ((pt, e_pos'),[]); (* = ("helpless",*)
   65.59  *)
   65.60  
   65.61  val (p,_,f,nxt,_,pt) = me nxt p''' c pt''';
   65.62 -f2str f = "1 = 2 + -2 * sqrt x)"; (* <<<-------------- this should be*)
   65.63 +f2str f = "1 = 2 + - 2 * sqrt x)"; (* <<<-------------- this should be*)
   65.64  fst nxt = "Empty_Tac"; (* <<<-------------- this we have*)
   65.65  (*============ inhibit exn WN120314: stopped due to effort; continue with equ-solver
   65.66  The equation is strange: it calls script ["RootEq", "solve_sq_root_equation"] twice
   65.67  and works differently due to an "if" in that script.
   65.68  
   65.69 -if f2str f = "1 = 2 + -2 * sqrt x" then ()
   65.70 +if f2str f = "1 = 2 + - 2 * sqrt x" then ()
   65.71  else error "rootrateq.sml: diff.behav. in rootrat_equation_left_1 b";
   65.72  (*-> Subproblem ("RootRatEq", ["sq", "rootX", "univariate", "equation"]) ?!? the SAME as above*)
   65.73  val (p,_,f,nxt,_,pt) = me nxt p c pt; 
   65.74 @@ -170,7 +170,7 @@
   65.75  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   65.76  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   65.77  case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 1 / 4]")) => ()
   65.78 -	 | _ => error "rootrateq.sml: diff.behav. in  -2 + 1/(1 - sqrt(x))= 0 -> [x = 1/4]";
   65.79 +	 | _ => error "rootrateq.sml: diff.behav. in  - 2 + 1/(1 - sqrt(x))= 0 -> [x = 1/4]";
   65.80  ============ inhibit exn WN120314 ==============================================*)
   65.81  ============ inhibit exn WN120319 ==============================================*)
   65.82  
   65.83 @@ -216,7 +216,7 @@
   65.84  ( *\\------------------ ERROR check_elementwise: no set 1 + sqrt x = 3 -----------------------//*)
   65.85  
   65.86  (*============ inhibit exn WN120314 ==============================================
   65.87 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "4 + -1 * x = 0")) then ()
   65.88 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "4 + - 1 * x = 0")) then ()
   65.89  else error "rootrateq.sml: diff.behav. in rootrat_equation_left_2";
   65.90  (*-> Subproblem ("PolyEq", ["polynomial", ...])*)
   65.91  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
   65.92 @@ -236,7 +236,7 @@
   65.93  "------------ test thm rootrat_equation_right_1 ------------------";
   65.94  "------------ test thm rootrat_equation_right_1 ------------------";
   65.95  "------------ test thm rootrat_equation_right_1 ------------------";
   65.96 -val fmz = ["equality ( 0= -2 + 1/(1 - sqrt(x)))", "solveFor x", "solutions L"];
   65.97 +val fmz = ["equality ( 0= - 2 + 1/(1 - sqrt(x)))", "solveFor x", "solutions L"];
   65.98  val (dI',pI',mI') = ("RootRatEq",["univariate", "equation"],["no_met"]);
   65.99  
  65.100  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  65.101 @@ -271,7 +271,7 @@
  65.102  ( *\\------------------ ERROR check_elementwise: no set 1 + sqrt x = 3 -----------------------//*)
  65.103  
  65.104  (*============ inhibit exn WN120314: similar complicated equation, dropped.
  65.105 -if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "-1 + 4 * x = 0")) then ()
  65.106 +if f = Form' (Test_Out.FormKF (~1, EdUndef, 0, Nundef, "- 1 + 4 * x = 0")) then ()
  65.107  else error "rootrateq.sml: diff.behav.ppoly in rootrat_equation_right_1";
  65.108  val (p,_,f,nxt,_,pt) = me nxt p c pt;
  65.109  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
  65.110 @@ -285,7 +285,7 @@
  65.111  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
  65.112  val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
  65.113  case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 1 / 4]")) => ()
  65.114 -	 | _ => error "rootrateq.sml: diff.behav. in  -2 + 1/(1 - sqrt(x))= 0 -> [x = 1/4]";
  65.115 +	 | _ => error "rootrateq.sml: diff.behav. in  - 2 + 1/(1 - sqrt(x))= 0 -> [x = 1/4]";
  65.116  ============ inhibit exn WN120314 ==============================================*)
  65.117  
  65.118  "------------ test thm rootrat_equation_right_2 ------------------";
    66.1 --- a/test/Tools/isac/Knowledge/simplify.sml	Mon Jun 21 22:08:01 2021 +0200
    66.2 +++ b/test/Tools/isac/Knowledge/simplify.sml	Sun Jul 18 18:15:27 2021 +0200
    66.3 @@ -1,10 +1,6 @@
    66.4  (* tests on simplification
    66.5 -   author: Walther Neuper
    66.6 -   061019
    66.7 +   author: Walther Neuper 061019
    66.8     (c) due to copyright terms
    66.9 -
   66.10 -use"../smltest/IsacKnowledge/simplify.sml";
   66.11 -use"simplify.sml";
   66.12  *)
   66.13  
   66.14  "--------------------------------------------------------";
   66.15 @@ -77,6 +73,10 @@
   66.16  (([1], Res), 14),
   66.17  (([], Res), 14)] *)
   66.18  val Form res = (#1 o ME_Misc.pt_extract) (pt, ([],Res));
   66.19 +p;
   66.20 +UnparseC.term res = "??.empty"; (*TOODOO*)
   66.21 +(** )
   66.22  if p = ([], Res) andalso UnparseC.term res = "14" then ()
   66.23  else error "simplify.sml: append inform with final result changed";
   66.24 +( **)
   66.25  
    67.1 --- a/test/Tools/isac/Knowledge/system.sml	Mon Jun 21 22:08:01 2021 +0200
    67.2 +++ b/test/Tools/isac/Knowledge/system.sml	Sun Jul 18 18:15:27 2021 +0200
    67.3 @@ -19,32 +19,32 @@
    67.4  "----------- normalise system ------------------------------------";
    67.5  "----------- normalise system ------------------------------------";
    67.6  "----------- normalise system ------------------------------------";
    67.7 -val t = TermC.str2term "[0 = c*0 + -1*q_0*(0 \<up> 2 / 2) + c_2,\
    67.8 -		 \ 0 = c*L + -1*q_0*(L \<up> 2 / 2) + c_2]";
    67.9 +val t = TermC.str2term "[0 = c*0 + - 1*q_0*(0 \<up> 2 / 2) + c_2,\
   67.10 +		 \ 0 = c*L + - 1*q_0*(L \<up> 2 / 2) + c_2]";
   67.11  val SOME (t,_) = rewrite_set_ thy false norm_Poly t;
   67.12  if UnparseC.term t = 
   67.13 -"[0 = -1 * q_0 * (0 / 2) + c_2, 0 = L * c + -1 * q_0 * (L \<up> 2 / 2) + c_2]"
   67.14 +"[0 = - 1 * q_0 * (0 / 2) + c_2, 0 = L * c + - 1 * q_0 * (L \<up> 2 / 2) + c_2]"
   67.15  then () else error "system.sml, diff.behav. in norm_Poly";
   67.16  
   67.17 -val t = TermC.str2term "[0 = c*0 + -1*q_0*(0 \<up> 2 / 2) + c_2,\
   67.18 -		 \ 0 = c*L + -1*q_0*(L \<up> 2 / 2) + c_2]";
   67.19 +val t = TermC.str2term "[0 = c*0 + - 1*q_0*(0 \<up> 2 / 2) + c_2,\
   67.20 +		 \ 0 = c*L + - 1*q_0*(L \<up> 2 / 2) + c_2]";
   67.21  val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
   67.22  if UnparseC.term t = 
   67.23 -"[0 = c_2, 0 = (2 * c_2 + 2 * L * c + -1 * L \<up> 2 * q_0) / 2]"
   67.24 +"[0 = c_2, 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]"
   67.25  then () else error "system.sml, diff.behav. in norm_Rational";
   67.26  
   67.27  
   67.28 -val t = TermC.str2term "nth_ 1 [0 = c*0 + -1*q_0*(0 \<up> 2 / 2) + c_2,\
   67.29 -		 \ 0 = c*L + -1*q_0*(L \<up> 2 / 2) + c_2]";
   67.30 +val t = TermC.str2term "nth_ 1 [0 = c*0 + - 1*q_0*(0 \<up> 2 / 2) + c_2,\
   67.31 +		 \ 0 = c*L + - 1*q_0*(L \<up> 2 / 2) + c_2]";
   67.32  val SOME (t,_) = rewrite_set_ thy false prog_expr t;
   67.33 -if UnparseC.term t = "0 = c * 0 + -1 * q_0 * (0 \<up> 2 / 2) + c_2"
   67.34 +if UnparseC.term t = "0 = c * 0 + - 1 * q_0 * (0 \<up> 2 / 2) + c_2"
   67.35  then () else error "system.sml, prog_expr";
   67.36  
   67.37  
   67.38  "----------- me --------------------------------------------------";
   67.39  "----------- me --------------------------------------------------";
   67.40  "----------- me --------------------------------------------------";
   67.41 -val fmz = ["equalities [0 = c_2 + c * 0 + -1 * q_0 / 2 * 0 \<up> 2, 0 = c_2 + c * L + -1 * q_0 / 2 * L \<up> 2]",
   67.42 +val fmz = ["equalities [0 = c_2 + c * 0 + - 1 * q_0 / 2 * 0 \<up> 2, 0 = c_2 + c * L + - 1 * q_0 / 2 * L \<up> 2]",
   67.43  	   "solveForVars [c, c_2]", "solution ss___"];
   67.44  val (dI',pI',mI') =
   67.45    ("Biegelinie",["normalise", "2x2", "LINEAR", "system"],
   67.46 @@ -55,12 +55,12 @@
   67.47  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.48  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.49  case nxt of (_, Specify_Theory "Biegelinie") => ()
   67.50 -	  | _ => error "system.sml diff.behav.in me --1";
   67.51 +	  | _ => error "system.sml diff.behav.in me -- 1";
   67.52  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.53  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.54  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.55  case nxt of (_, Apply_Method ["EqSystem", "normalise", "2x2"]) => ()
   67.56 -	  | _ => error "system.sml diff.behav.in me --2";
   67.57 +	  | _ => error "system.sml diff.behav.in me -- 2";
   67.58  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   67.59  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   67.60  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   67.61 @@ -75,12 +75,12 @@
   67.62  val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.63  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.64  case nxt of (_, Specify_Theory "Biegelinie") => ()
   67.65 -	  | _ => error "system.sml diff.behav.in me --1";
   67.66 +	  | _ => error "system.sml diff.behav.in me -- 1";
   67.67  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.68  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.69  val (p,_,f,nxt,_,pt) = me nxt p c pt;
   67.70  case nxt of (_, Apply_Method ["EqSystem", "normalise", "2x2"]) => ()
   67.71 -	  | _ => error "system.sml diff.behav.in me --2";
   67.72 +	  | _ => error "system.sml diff.behav.in me -- 2";
   67.73  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   67.74  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   67.75  val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
   67.76 @@ -89,7 +89,7 @@
   67.77  
   67.78  
   67.79  (*---
   67.80 -WN060421 stopped as soon as exp_IsacCore_Equ_Sys_Lin_No-1.xml worked ...
   67.81 +WN060421 stopped as soon as exp_IsacCore_Equ_Sys_Lin_No- 1.xml worked ...
   67.82  
   67.83  if f2str f = "" then ()
   67.84  else error  "system.sml diff.behav.in me --99";
    68.1 --- a/test/Tools/isac/MathEngBasic/ctree.sml	Mon Jun 21 22:08:01 2021 +0200
    68.2 +++ b/test/Tools/isac/MathEngBasic/ctree.sml	Sun Jul 18 18:15:27 2021 +0200
    68.3 @@ -113,7 +113,7 @@
    68.4  
    68.5  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
    68.6  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
    68.7 -(*val nxt = ("Add_Given", Add_Given "equality (-1 + x = 0)").....*)
    68.8 +(*val nxt = ("Add_Given", Add_Given "equality (- 1 + x = 0)").....*)
    68.9  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   68.10  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   68.11  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   68.12 @@ -247,19 +247,19 @@
   68.13  	   ([4], Res)]
   68.14  then () else error "ctree.sml: diff:behav. in cut_level 2a";
   68.15  
   68.16 -if pr_ctree pr_short pt' = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n"
   68.17 +if pr_ctree pr_short pt' = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + - 1 * 2 = 0\n"
   68.18  then () else error "ctree.sml: diff:behav. in cut_level 2b";
   68.19  
   68.20  val (pt',cuts) = cut_level [] [3] pt ([3,1],Frm);
   68.21  if cuts = [([3, 1], Res), ([3, 2], Res)]
   68.22  then () else error "ctree.sml: diff:behav. in cut_level 3a";
   68.23 -if pr_ctree pr_short pt' = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n4.   [x = 1]\n"
   68.24 +if pr_ctree pr_short pt' = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + - 1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   - 1 + x = 0\n4.   [x = 1]\n"
   68.25  then () else error "ctree.sml: diff:behav. in cut_level 3b";
   68.26  
   68.27  val (pt',cuts) = cut_level [] [3] pt ([3,1],Res);
   68.28  if cuts = [([3, 2], Res)]
   68.29  then () else error "ctree.sml: diff:behav. in cut_level 4a";
   68.30 -if pr_ctree pr_short pt' = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n4.   [x = 1]\n"
   68.31 +if pr_ctree pr_short pt' = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + - 1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   - 1 + x = 0\n4.   [x = 1]\n"
   68.32  then () else error "ctree.sml: diff:behav. in cut_level 4b";
   68.33  
   68.34  
   68.35 @@ -287,7 +287,7 @@
   68.36  
   68.37  (*============ inhibit exn AK110726 ==============================================
   68.38  val form = get_obj g_form pt' [2];
   68.39 -if UnparseC.term form = "x + 1 + -1 * 2 = 0" (*remained !!!*) then () else
   68.40 +if UnparseC.term form = "x + 1 + - 1 * 2 = 0" (*remained !!!*) then () else
   68.41  error "ctree.sml: diff:behav. in cut_tree 1ab";
   68.42  ============ inhibit exn AK110726 ==============================================*)
   68.43  (* AK110727 Debuging
   68.44 @@ -483,10 +483,10 @@
   68.45  val p = ([1], Res);
   68.46  val (pt,cuts) = 
   68.47      cappend_atomic pt (fst p) Istate.empty (TermC.str2term "x + 1 = 2")
   68.48 -		   Empty_Tac (TermC.str2term "x + 1 + -1 * 2 = 0",[]) Incomplete;
   68.49 +		   Empty_Tac (TermC.str2term "x + 1 + - 1 * 2 = 0",[]) Incomplete;
   68.50  val form = get_obj g_form pt (fst p);
   68.51  val (res,_) = get_obj g_result pt (fst p);
   68.52 -if UnparseC.term form = "x + 1 = 2" andalso UnparseC.term res = "x + 1 + -1 * 2 = 0" 
   68.53 +if UnparseC.term form = "x + 1 = 2" andalso UnparseC.term res = "x + 1 + - 1 * 2 = 0" 
   68.54  then () else error "ctree.sml, diff.behav. cappend minisubpbl ([1],Res)";
   68.55  if not (existpt ((lev_on o fst) p) pt) then () else
   68.56  error "ctree.sml, diff.behav. cappend minisubpbl ([1],Res) nxt";
   68.57 @@ -494,11 +494,11 @@
   68.58  (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt(**)cappend_atomic: pos =[2]*);
   68.59  val p = ([2], Res);
   68.60  val (pt,cuts) = 
   68.61 -    cappend_atomic pt (fst p) Istate.empty (TermC.str2term "x + 1 + -1 * 2 = 0")
   68.62 -		   Empty_Tac (TermC.str2term "-1 + x = 0",[]) Incomplete;
   68.63 +    cappend_atomic pt (fst p) Istate.empty (TermC.str2term "x + 1 + - 1 * 2 = 0")
   68.64 +		   Empty_Tac (TermC.str2term "- 1 + x = 0",[]) Incomplete;
   68.65  val form = get_obj g_form pt (fst p);
   68.66  val (res,_) = get_obj g_result pt (fst p);
   68.67 -if UnparseC.term form = "x + 1 + -1 * 2 = 0" andalso UnparseC.term res = "-1 + x = 0"
   68.68 +if UnparseC.term form = "x + 1 + - 1 * 2 = 0" andalso UnparseC.term res = "- 1 + x = 0"
   68.69  then () else error "ctree.sml, diff.behav. cappend minisubpbl ([2],Res)";
   68.70  if not (existpt ((lev_on o fst) p) pt) then () else
   68.71  error "ctree.sml, diff.behav. cappend minisubpbl ([2],Res) nxt";
   68.72 @@ -516,10 +516,10 @@
   68.73  
   68.74  (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt(**)cappend_form: pos =[3,1]*);
   68.75  val p = ([3, 1], Frm);
   68.76 -val (pt,cuts) = cappend_form pt (fst p) Istate.empty (TermC.str2term "-1 + x = 0");
   68.77 +val (pt,cuts) = cappend_form pt (fst p) Istate.empty (TermC.str2term "- 1 + x = 0");
   68.78  val form = get_obj g_form pt (fst p);
   68.79  val (res,_) = get_obj g_result pt (fst p);
   68.80 -if UnparseC.term form = "-1 + x = 0" andalso res = TermC.empty then () else
   68.81 +if UnparseC.term form = "- 1 + x = 0" andalso res = TermC.empty then () else
   68.82  error "ctree.sml, diff.behav. cappend minisubpbl ([3,1],Frm)";
   68.83  if not (existpt ((lev_on o fst) p) pt) then () else
   68.84  error "ctree.sml, diff.behav. cappend minisubpbl ([3,1],Frm) nxt";
   68.85 @@ -527,11 +527,11 @@
   68.86  (*val (p,_,f,nxt,_,pt) = me nxt p [1] pt;(**)cappend_atomic: pos =[3,1]*)
   68.87  val p = ([3, 1], Res);
   68.88  val (pt,cuts) = 
   68.89 -    cappend_atomic pt (fst p) Istate.empty (TermC.str2term "-1 + x = 0")
   68.90 -		   Empty_Tac (TermC.str2term "x = 0 + -1 * -1",[]) Incomplete;
   68.91 +    cappend_atomic pt (fst p) Istate.empty (TermC.str2term "- 1 + x = 0")
   68.92 +		   Empty_Tac (TermC.str2term "x = 0 + - 1 * - 1",[]) Incomplete;
   68.93  val form = get_obj g_form pt (fst p);
   68.94  val (res,_) = get_obj g_result pt (fst p);
   68.95 -if UnparseC.term form = "-1 + x = 0" andalso UnparseC.term res = "x = 0 + -1 * -1" then()
   68.96 +if UnparseC.term form = "- 1 + x = 0" andalso UnparseC.term res = "x = 0 + - 1 * - 1" then()
   68.97  else error "ctree.sml, diff.behav. cappend minisubpbl ([3,1],Res)";
   68.98  if not (existpt ((lev_on o fst) p) pt) then () else
   68.99  error "ctree.sml, diff.behav. cappend minisubpbl ([3,1],Res) nxt";
  68.100 @@ -586,7 +586,7 @@
  68.101  "-------------- move_dn: Frm -> Res ------------------------------";
  68.102   reset_states ();
  68.103   CalcTree      (*start of calculation, return No.1*)
  68.104 -     [(["equality (1+-1*2+x=(0::real))", "solveFor x", "solutions L"],
  68.105 +     [(["equality (1+- 1*2+x=(0::real))", "solveFor x", "solutions L"],
  68.106         ("Test", 
  68.107  	["LINEAR", "univariate", "equation", "test"],
  68.108  	["Test", "solve_linear"]))];
  68.109 @@ -641,7 +641,7 @@
  68.110   moveActiveDown 1;
  68.111   moveActiveDown 1;
  68.112   moveActiveDown 1; 
  68.113 - refFormula 1 (get_pos 1 1) (* 2 Res, <ISA> -1 + x = 0 </ISA> *);
  68.114 + refFormula 1 (get_pos 1 1) (* 2 Res, <ISA> - 1 + x = 0 </ISA> *);
  68.115  
  68.116   interSteps 1 ([2],Res);
  68.117  
  68.118 @@ -788,7 +788,7 @@
  68.119      @ (writeln("getnd  : b="^(ints2str' b)^", p="^
  68.120  	       (ints2str' p)^", q="^(ints2str' q));
  68.121  
  68.122 -       getnds (i-1) true (b@[hdp p], tlp p) (tlq q)
  68.123 +       getnds (i- 1) true (b@[hdp p], tlp p) (tlq q)
  68.124  	       (take_fromto (hdp p) (hdq q) nds))
  68.125  
  68.126  and getnds _ _ _ _ [] = []                         (*no children*)
  68.127 @@ -822,7 +822,7 @@
  68.128  (2b) inifinity, if 't' < the respective element of 'to (internal node)'
  68.129  the 'f' and 't' are set by hdp,... *)
  68.130  fun get_trace pt p q =
  68.131 -    (flat o (getnds ((length p) -1) true ([hdp p], tlp p) (tlq q))) 
  68.132 +    (flat o (getnds ((length p) - 1) true ([hdp p], tlp p) (tlq q))) 
  68.133  	(take_fromto (hdp p) (hdq q) (children pt));
  68.134  end;
  68.135  
  68.136 @@ -888,7 +888,7 @@
  68.137  "-------------- ME_Misc.pt_extract form, tac, asm<>[] --------------------";
  68.138  val (Form form, SOME tac, asm) = ME_Misc.pt_extract (pt, ([3], Res));
  68.139  case (UnparseC.term form, tac, UnparseC.terms_to_strings asm) of
  68.140 -    ("(3 + -1 * x + x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)",
  68.141 +    ("(3 + - 1 * x + x \<up> 2) * x = 1 * (9 * x + -6 * x \<up> 2 + x \<up> 3)",
  68.142       Subproblem
  68.143           ("PolyEq",
  68.144            ["normalise", "polynomial", "univariate", "equation"]),
  68.145 @@ -898,7 +898,7 @@
  68.146       completing knowl. for thes2file...
  68.147  
  68.148    case (UnparseC.term form, tac, UnparseC.terms_to_strings asm) of
  68.149 -    ((*"(3 + (-1 * x + x \<up> 2)) * x = 1 * (9 * x + (x \<up> 3 + -6 * x \<up> 2))",
  68.150 +    ((*"(3 + (- 1 * x + x \<up> 2)) * x = 1 * (9 * x + (x \<up> 3 + -6 * x \<up> 2))",
  68.151       *)Subproblem
  68.152           ("PolyEq",
  68.153            ["normalise", "polynomial", "univariate", "equation"]),
  68.154 @@ -938,29 +938,29 @@
  68.155  
  68.156  val (Form form, SOME tac, asm) = ME_Misc.pt_extract (pt, ([1], Res));
  68.157  case (UnparseC.term form, tac, UnparseC.terms_to_strings asm) of
  68.158 -    ("x + 1 + -1 * 2 = 0", Rewrite_Set "Test_simplify", []) => ()
  68.159 +    ("x + 1 + - 1 * 2 = 0", Rewrite_Set "Test_simplify", []) => ()
  68.160    | _ => error "diff.behav.in ctree.sml: ME_Misc.pt_extract ([1], Res)";
  68.161  
  68.162  val (Form form, SOME tac, asm) = ME_Misc.pt_extract (pt, ([2], Res));
  68.163  case (UnparseC.term form, tac, UnparseC.terms_to_strings asm) of
  68.164 -    ("-1 + x = 0",
  68.165 +    ("- 1 + x = 0",
  68.166       Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"]),
  68.167       []) => ()
  68.168    | _ => error "diff.behav.in ctree.sml: ME_Misc.pt_extract ([2], Res)";
  68.169  
  68.170  val (ModSpec (_,_,form,_,_,_), SOME tac, asm) = ME_Misc.pt_extract (pt, ([3], Pbl));
  68.171  case (UnparseC.term form, tac, UnparseC.terms_to_strings asm) of
  68.172 -    ("solve (-1 + x = 0, x)", Apply_Method ["Test", "solve_linear"], []) => ()
  68.173 +    ("solve (- 1 + x = 0, x)", Apply_Method ["Test", "solve_linear"], []) => ()
  68.174    | _ => error "diff.behav.in ctree.sml: ME_Misc.pt_extract ([3], Pbl)";
  68.175  
  68.176  val (Form form, SOME tac, asm) = ME_Misc.pt_extract (pt, ([3,1], Frm));
  68.177  case (UnparseC.term form, tac, UnparseC.terms_to_strings asm) of
  68.178 -    ("-1 + x = 0", Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"), []) => ()
  68.179 +    ("- 1 + x = 0", Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv"), []) => ()
  68.180    | _ => error "diff.behav.in ctree.sml: ME_Misc.pt_extract ([3,1], Frm)";
  68.181  
  68.182  val (Form form, SOME tac, asm) = ME_Misc.pt_extract (pt, ([3,1], Res));
  68.183  case (UnparseC.term form, tac, UnparseC.terms_to_strings asm) of
  68.184 -    ("x = 0 + -1 * -1", Rewrite_Set "Test_simplify", []) => ()
  68.185 +    ("x = 0 + - 1 * - 1", Rewrite_Set "Test_simplify", []) => ()
  68.186    | _ => error "diff.behav.in ctree.sml: ME_Misc.pt_extract ([3,1], Res)";
  68.187  
  68.188  val (Form form, SOME tac, asm) = ME_Misc.pt_extract (pt, ([3,2], Res));
  68.189 @@ -1244,7 +1244,7 @@
  68.190     use"ctree.sml";
  68.191     *)
  68.192  
  68.193 -"---(6-1) on S(606)..S(608)--------";
  68.194 +"---(6- 1) on S(606)..S(608)--------";
  68.195  val (pt', cuts) = cappend_atomic pt [3,1] Istate.empty (TermC.str2term "Inform[3,1]")
  68.196      (Tac "test") (TermC.str2term "Inres[3,1]",[]) Complete;
  68.197  (*default_print_depth 99;*)
    69.1 --- a/test/Tools/isac/MathEngBasic/rewrite.sml	Mon Jun 21 22:08:01 2021 +0200
    69.2 +++ b/test/Tools/isac/MathEngBasic/rewrite.sml	Sun Jul 18 18:15:27 2021 +0200
    69.3 @@ -1,4 +1,4 @@
    69.4 -(* Title: "ProgLang/rewrite.sml"
    69.5 +(* Title: "MathEngBasic/rewrite.sml"
    69.6     Author: Walther Neuper 050908
    69.7     (c) copyright due to lincense terms.
    69.8  *)
    69.9 @@ -256,21 +256,21 @@
   69.10  
   69.11  val SOME (t', _) = rewrite_terms_ thy dummy_ord Rule_Set.Empty equs t;
   69.12  writeln "---------- rewrite_terms_  1---------------------------";
   69.13 -if UnparseC.term t' = "M_b 0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2" then ()
   69.14 +if UnparseC.term t' = "M_b 0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2" then ()
   69.15  else error "rewrite.sml rewrite_terms_ [x = 0]";
   69.16  
   69.17  val equs = [TermC.str2term "M_b 0 = 0"];
   69.18 -val t = TermC.str2term "M_b 0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2";
   69.19 +val t = TermC.str2term "M_b 0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2";
   69.20  val SOME (t', _) = rewrite_terms_ thy dummy_ord Rule_Set.Empty equs t;
   69.21  writeln "---------- rewrite_terms_  2---------------------------";
   69.22 -if UnparseC.term t' = "0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2" then ()
   69.23 +if UnparseC.term t' = "0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2" then ()
   69.24  else error "rewrite.sml rewrite_terms_ [M_b 0 = 0]";
   69.25  
   69.26  val equs = [TermC.str2term "x = 0", TermC.str2term"M_b 0 = 0"];
   69.27 -val t = TermC.str2term "M_b x = -1 * q_0 * x \<up> 2 / 2 + x * c + c_2";
   69.28 +val t = TermC.str2term "M_b x = - 1 * q_0 * x \<up> 2 / 2 + x * c + c_2";
   69.29  val SOME (t', _) = rewrite_terms_ thy dummy_ord Rule_Set.Empty equs t;
   69.30  writeln "---------- rewrite_terms_  3---------------------------";
   69.31 -if UnparseC.term t' = "0 = -1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2" then ()
   69.32 +if UnparseC.term t' = "0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2" then ()
   69.33  else error "rewrite.sml rewrite_terms_ [x = 0, M_b 0 = 0]";
   69.34  
   69.35  
   69.36 @@ -295,7 +295,7 @@
   69.37  (writeln o UnparseC.term) t;
   69.38  if UnparseC.term t = "L * c_3 + c_4 = 0 + -1 * (-1 * (q_0 * L \<up> 2) / 2)"
   69.39  then () else error "rewrite.sml rewrite_inst_ bdvs";
   69.40 -> Rewrite.trace_on:=true;
   69.41 +> Rewrite.trace_on:=true;false
   69.42  Rewrite.trace_on:=false;--------------------------------------------*)
   69.43  
   69.44  
   69.45 @@ -328,6 +328,7 @@
   69.46  val asms = map (Envir.subst_term subst) pres;
   69.47  if UnparseC.terms asms = "[\"a + b is_expanded\", \"c is_expanded\"]"
   69.48  then () else error "rewrite.sml: prepat cancel subst";
   69.49 +
   69.50  if ([], true) = eval__true thy 0 asms [] erls
   69.51  then () else error "rewrite.sml: prepat cancel eval__true";
   69.52  
   69.53 @@ -360,6 +361,7 @@
   69.54  val asms = map (Envir.subst_term subst) pres;
   69.55  if UnparseC.terms asms = "[\"x \<up> 2 * x is_multUnordered\"]"
   69.56  then () else error "rewrite.sml: prepat order_mult_ subst";
   69.57 +
   69.58  if ([], true) = eval__true thy 0 asms [] erls
   69.59  then () else error "rewrite.sml: prepat order_mult_ eval__true";
   69.60  
   69.61 @@ -371,7 +373,21 @@
   69.62  
   69.63  if is_multUnordered t then () else error "rewrite.sml diff. is_multUnordered 2";
   69.64  val tm = TermC.str2term "(x \<up> 2 * x) is_multUnordered";
   69.65 -eval_is_multUnordered "testid" "" tm thy;
   69.66 +
   69.67 +(*+*)case eval_is_multUnordered "testid" "" tm thy of
   69.68 +(*+*)  SOME
   69.69 +(*+*)    ("testidx \<up> 2 * x_",
   69.70 +(*+*)     Const ("HOL.Trueprop", _) $
   69.71 +(*+*)       (Const ("HOL.eq", _) $
   69.72 +(*+*)         (Const ("Poly.is_multUnordered", _) $
   69.73 +(*+*)           (Const ("Groups.times_class.times", _) $
   69.74 +(*+*)             (Const ("Transcendental.powr", _) $ Free ("x", _) $ _ ) $ Free ("x", _))) $
   69.75 +(*+*)         Const ("HOL.True", _))) => ()
   69.76 +(*+*)(*                   ^^^^^^             compare ---vvv *)
   69.77 +(*+*)| _ => error "rewrite.sml diff. eval_is_multUnordered 2b CHANGED";
   69.78 +
   69.79 +
   69.80 +     eval_is_multUnordered "testid" "" tm thy;
   69.81  
   69.82  case eval_is_multUnordered "testid" "" tm thy of
   69.83      SOME (_, Const (\<^const_name>\<open>Trueprop\<close>, _) $ 
   69.84 @@ -380,9 +396,9 @@
   69.85                            Const (\<^const_name>\<open>True\<close>, _))) => ()
   69.86    | _ => error "rewrite.sml diff. eval_is_multUnordered 2b";
   69.87  
   69.88 -tracing "----- begin rewrite x \<up> 2 * x ---"; Rewrite.trace_on := false;
   69.89 +tracing "----- begin rewrite x \<up> 2 * x ---"; Rewrite.trace_on := false; (*true false*)
   69.90  val SOME (t', _) = rewrite_set_ thy true order_mult_ t;
   69.91 -tracing "----- end rewrite x \<up> 2 * x ---"; Rewrite.trace_on := false;
   69.92 +tracing "----- end rewrite x \<up> 2 * x ---"; Rewrite.trace_on := false; (*true false*)
   69.93  if UnparseC.term t' = "x * x \<up> 2" then ()
   69.94  else error "rewrite.sml Poly.is_multUnordered doesn't work";
   69.95  
   69.96 @@ -613,7 +629,7 @@
   69.97  
   69.98             rewrite__set_ thy (i + 1) false bdv rls a (*of*);
   69.99  
  69.100 -(*+*)Rewrite.trace_on := true;
  69.101 +(*+*)Rewrite.trace_on := false; (*true false*)
  69.102  
  69.103          (*this was False; vvvv--- means: indeterminate*)
  69.104      val (* SOME (t, a') *)NONE = (*case*)
  69.105 @@ -634,7 +650,7 @@
  69.106   :                             
  69.107   ###  asms accepted: [x \<noteq> 0]   stored: []
  69.108   : *)
  69.109 -Rewrite.trace_on := false;
  69.110 +Rewrite.trace_on := false; (*true false*)
  69.111  ( *\------- outcomment this code: otherwise the re-definition could infect tests lateron ------/*)
  69.112  
  69.113  
  69.114 @@ -671,7 +687,7 @@
  69.115  exception TERM raised (line 271 of "~~/src/HOL/Tools/hologic.ML"):
  69.116    dest_eq
  69.117    0 \<le> ?a \<Longrightarrow> (0 \<le> sqrt ?a) = True( **)
  69.118 -if UnparseC.term t = "x + 1 + -1 * 2 = 0" then () else error "rewrite_set_ norm_equation CHANGED";
  69.119 +if UnparseC.term t = "x + 1 + - 1 * 2 = 0" then () else error "rewrite_set_ norm_equation CHANGED";
  69.120  
  69.121  "~~~~~ fun rewrite_set_ , args:"; val (thy, bool, rls, term) = (thy, false, rls, term);
  69.122  "~~~~~ and rewrite__set_ , args:"; val (thy, i, put_asm, bdv, rls, ct) =
    70.1 --- a/test/Tools/isac/MathEngBasic/thmC.sml	Mon Jun 21 22:08:01 2021 +0200
    70.2 +++ b/test/Tools/isac/MathEngBasic/thmC.sml	Sun Jul 18 18:15:27 2021 +0200
    70.3 @@ -48,7 +48,7 @@
    70.4  "~~~~~ fun revert_sym_rule , args:"; val (thy, (Rule.Thm (id, thm))) =
    70.5    (@{theory Isac_Knowledge}, \<^rule_thm_sym>\<open>real_mult_minus1\<close>);
    70.6  
    70.7 -if id = "sym_real_mult_minus1" andalso ThmC.string_of_thm thm = "- ?z1 = -1 * ?z1" then ()
    70.8 +if id = "sym_real_mult_minus1" andalso ThmC.string_of_thm thm = "- ?z1 = - 1 * ?z1" then ()
    70.9  else error "input to revert_sym_rule CHANGED";
   70.10  
   70.11        (*if*) is_sym (cut_id id) (*then*);
   70.12 @@ -59,11 +59,11 @@
   70.13  val thy = @{theory Isac_Knowledge}
   70.14  val (Thm (thmID, thm)) = ThmC.revert_sym_rule thy (\<^rule_thm_sym>\<open>real_mult_minus1\<close>)
   70.15  ;
   70.16 -if thmID = "Poly.real_mult_minus1" andalso ThmC.string_of_thm thm = "-1 * ?z = - ?z"
   70.17 +if thmID = "Poly.real_mult_minus1" andalso ThmC.string_of_thm thm = "- 1 * ?z = - ?z"
   70.18  then () else error "fun revert_sym_rule changed 1";
   70.19  
   70.20  val (Thm (thmID, thm)) = ThmC.revert_sym_rule thy
   70.21    (Thm ("real_diff_minus", ThmC.numerals_to_Free @{thm real_diff_minus}))
   70.22  ;
   70.23 -if thmID = "Root.real_diff_minus" andalso ThmC.string_of_thm thm = "?a - ?b = ?a + -1 * ?b"
   70.24 +if thmID = "Root.real_diff_minus" andalso ThmC.string_of_thm thm = "?a - ?b = ?a + - 1 * ?b"
   70.25  then () else error "fun revert_sym_rule changed 2"
    71.1 --- a/test/Tools/isac/MathEngine/mathengine-stateless.sml	Mon Jun 21 22:08:01 2021 +0200
    71.2 +++ b/test/Tools/isac/MathEngine/mathengine-stateless.sml	Sun Jul 18 18:15:27 2021 +0200
    71.3 @@ -27,7 +27,7 @@
    71.4  val fmz = ["realTestGiven (((1+2)*4/3) \<up> 2)", "realTestFind s"];
    71.5  val (thyID, pblID, metID) =
    71.6    ("Test", ["calculate", "test"], ["Test", "test_calculate"]);
    71.7 -(*======= Isabelle2013-2 --> Isabelle2014: unclear, why this test ever run =====================*)
    71.8 +(*======= Isabelle2013- 2 --> Isabelle2014: unclear, why this test ever run =====================*)
    71.9  
   71.10  
   71.11  "----------- tryrefine ----------------------------------";
   71.12 @@ -71,9 +71,17 @@
   71.13  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   71.14  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   71.15  val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   71.16 -val (p,_,f,nxt,_,pt) = me nxt p [] pt;
   71.17 +(** )
   71.18 +val (p''''',_,f,nxt''''',_,pt''''') = me nxt p [] pt;
   71.19 +( **)
   71.20 +(*//---------------- adhoc inserted ------------------------------------------------\\* )
   71.21 +     see TOODOO.1 in test/../evaluate.sml
   71.22 +( *\\---------------- adhoc inserted ------------------------------------------------//*)
   71.23 +
   71.24 +(*//---------------- continue AFTER previous step "me" -----------------------------\\* )
   71.25 +"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue AFTER previous step "me" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
   71.26  "~~~~~ fun me, args:"; val (tac, (p:pos'), (_:NEW(*remove*)), (pt:ctree)) = 
   71.27 -                            (nxt, p, [], pt);
   71.28 +                            (nxt''''', p''''', [], pt''''');
   71.29  val ("ok", (_, _, ptp))  = Step.by_tactic tac (pt,p)
   71.30  val (pt, p) = ptp;
   71.31  "~~~~~ fun Step.do_next, args:"; val (((ip as (_,p_)):pos'), ((ptp as (pt,p), tacis):Calc.state_pre)) =
   71.32 @@ -90,6 +98,7 @@
   71.33  val Next_Step (istate, ctxt, tac) = LI.find_next_step sc (pt,pos) ist ctxt; (*WAS Empty_Tac_: tac_*)
   71.34  case tac of Or_to_List' _ => ()
   71.35  | _ => error "Or_to_List broken ?"
   71.36 +( *\\---------------- continue AFTER previous step "me" -----------------------------//*)
   71.37  
   71.38  
   71.39  "----------- check thy in CalcTreeTEST ------------------";
   71.40 @@ -100,10 +109,10 @@
   71.41  "Below there are the steps which found out the reason: \n" ^
   71.42  "store_pbt mistakenly stored that theory.";
   71.43  val ctxt = Proof_Context.init_global @{theory Isac_Knowledge};
   71.44 -val SOME t = parseNEW ctxt "filterExpression (X  = 3 / (z - 1/4 + -1/8 * (1/(z::real))))";
   71.45 +val SOME t = parseNEW ctxt "filterExpression (X  = 3 / (z - 1/4 + - 1/8 * (1/(z::real))))";
   71.46  val SOME t = parseNEW ctxt "stepResponse (x[n::real]::bool)";
   71.47  
   71.48 -val fmz = ["filterExpression (X  = 3 / (z - 1/4 + -1/8 * (1/(z::real))))", "boundVariable z",
   71.49 +val fmz = ["filterExpression (X  = 3 / (z - 1/4 + - 1/8 * (1/(z::real))))", "boundVariable z",
   71.50    "stepResponse (x[n::real]::bool)"];
   71.51  val (dI,pI,mI) = ("Isac_Knowledge", ["Inverse", "Z_Transform", "SignalProcessing"], 
   71.52    ["SignalProcessing", "Z_Transform", "Inverse"]);
   71.53 @@ -243,8 +252,8 @@
   71.54  "~~~~~ fun thm'2xml, args:"; val (j, ((ID, form) : thm'')) = ((j+i), thm');
   71.55  ID = "rnorm_equation_add";
   71.56  @{thm rnorm_equation_add};
   71.57 -(UnparseC.term o Thm.prop_of) form = "~ ?b =!= 0 ==> (?a = ?b) = (?a + -1 * ?b = 0)"
   71.58 -  (*?!? should be "\<not> ?b =!= 0 \<Longrightarrow> (?a = ?b) = (?a + -1 * ?b = 0)"*)
   71.59 +(UnparseC.term o Thm.prop_of) form = "~ ?b =!= 0 ==> (?a = ?b) = (?a + - 1 * ?b = 0)"
   71.60 +  (*?!? should be "\<not> ?b =!= 0 \<Longrightarrow> (?a = ?b) = (?a + - 1 * ?b = 0)"*)
   71.61  (*thmstr2xml (j+i) form;
   71.62  ERROR Undeclared constant: "Test.rnorm_equation_add" \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> \<up> ^*)
   71.63  ;
   71.64 @@ -253,9 +262,9 @@
   71.65  (([], Frm), solve (x + 1 = 2, x)),
   71.66  (([1], Frm), x + 1 = 2),
   71.67  (([1,1], Frm), x + 1 = 2),
   71.68 -(([1,1], Res), x + 1 + -1 * 2 = 0),
   71.69 -(([1], Res), x + 1 + -1 * 2 = 0),
   71.70 -(([2], Res), -1 + x = 0)]
   71.71 +(([1,1], Res), x + 1 + - 1 * 2 = 0),
   71.72 +(([1], Res), x + 1 + - 1 * 2 = 0),
   71.73 +(([2], Res), - 1 + x = 0)]
   71.74  
   71.75  pt;   --> tac = Rewrite ("rnorm_equation_add", "Test.rnorm_equation_add")*)
   71.76  ( *----- outcommented during cleanup of args in lucas-interpreter.sml ------------------------//*)
    72.1 --- a/test/Tools/isac/Minisubpbl/100-init-rootpbl.sml	Mon Jun 21 22:08:01 2021 +0200
    72.2 +++ b/test/Tools/isac/Minisubpbl/100-init-rootpbl.sml	Sun Jul 18 18:15:27 2021 +0200
    72.3 @@ -35,8 +35,11 @@
    72.4  (* ERROR Specify.item_to_add: types or dsc DO NOT MATCH BETWEEN fmz --- pbt
    72.5     IN Minimsubpbl/150-add-given.sml IS CAUSED HEREBY:*)
    72.6  case oris of
    72.7 -  ((1, [1], "#Given", Const ("Input_Descript.equality", _),
    72.8 -    [Const (\<^const_name>\<open>HOL.eq\<close>, _) $ _ $ Free ("2", _)]) :: _) => ()
    72.9 +  [(1, [1], "#Given", Const ("Input_Descript.equality", _),
   72.10 +     [Const ("HOL.eq", _) $ (Const ("Groups.plus_class.plus", _) $ Const ("Partial_Fractions.AA", _) $ Const ("Groups.one_class.one", _)) $
   72.11 +        (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ Const ("Num.num.One", _)))]),
   72.12 +    (2, [1], "#Given", Const ("Input_Descript.solveFor", _), [Const ("Partial_Fractions.AA", _)]),
   72.13 +    (3, [1], "#Find", Const ("Input_Descript.solutions", _), [Free ("L", _)])] => ()
   72.14  | ((1, [1], "#undef", Const ("empty", _), _) :: _) => error "START specify: oris are not properly initialised"
   72.15  | _ => error ""
   72.16  
   72.17 @@ -48,8 +51,11 @@
   72.18  val oris = O_Model.init fmz thy yyy
   72.19  ;
   72.20  case oris of
   72.21 -  ((1, [1], "#Given", Const ("Input_Descript.equality", _),
   72.22 -    [Const (\<^const_name>\<open>HOL.eq\<close>, _) $ _ $ Free ("2", _)]) :: _) => ()
   72.23 +  [(1, [1], "#Given", Const ("Input_Descript.equality", _),
   72.24 +     [Const ("HOL.eq", _) $ (Const ("Groups.plus_class.plus", _) $ Const ("Partial_Fractions.AA", _) $ Const ("Groups.one_class.one", _)) $
   72.25 +        (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ Const ("Num.num.One", _)))]),
   72.26 +    (2, [1], "#Given", Const ("Input_Descript.solveFor", _), [Const ("Partial_Fractions.AA", _)]),
   72.27 +    (3, [1], "#Find", Const ("Input_Descript.solutions", _), [Free ("L", _)])] => ()
   72.28  | ((1, [1], "#undef", Const ("empty", _), _) :: _) => error "START specify: oris are not properly initialised"
   72.29  | _ => error ""
   72.30  
   72.31 @@ -57,12 +63,13 @@
   72.32        val ctxt = ContextC.initialise' thy fmz;
   72.33  (*ADD check*) 
   72.34  case TermC.parseNEW ctxt "equality (x+1=(2::real))" of
   72.35 -  SOME (Const ("Input_Descript.equality", _) (* <<< ---------------- this needs to be recognised *) $
   72.36 -    (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (Const (\<^const_name>\<open>plus\<close>, _) $
   72.37 -      Free ("x", _) $ Free ("1", _)) $ Free ("2", _))) => ()
   72.38 +  SOME (Const ("Input_Descript.equality", _) $
   72.39 +    (Const ("HOL.eq", _) $ (Const ("Groups.plus_class.plus", _) $ Free ("x", _) $ Const ("Groups.one_class.one", _)) $
   72.40 +      (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ Const ("Num.num.One", _))))
   72.41 +  ) => ()
   72.42  | SOME (Free ("equality", _) $
   72.43 -    (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (Const (\<^const_name>\<open>plus\<close>, _) $
   72.44 -      Free ("x", _) $ Free ("1", _)) $ Free ("2", _))) => error ""
   72.45 +    (Const ("HOL.eq", _) $ (Const ("Groups.plus_class.plus", _) $
   72.46 +      Free ("x", _) $ Free ("1", _)) $ Free ("2", _))) => error "xxx"
   72.47  | _ => error "something is wrong with initialising Minisubpnl";
   72.48  
   72.49  val [(fmz, (dI',pI',mI'))] = [(fmz''''', spec''''')];
    73.1 --- a/test/Tools/isac/Minisubpbl/200-start-method-NEXT_STEP.sml	Mon Jun 21 22:08:01 2021 +0200
    73.2 +++ b/test/Tools/isac/Minisubpbl/200-start-method-NEXT_STEP.sml	Sun Jul 18 18:15:27 2021 +0200
    73.3 @@ -60,10 +60,29 @@
    73.4  (*[], Met*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Method ["Test", "squ-equ-test-subpbl1"]*)
    73.5  (*[1], Frm*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Apply_Method ["Test", "squ-equ-test-subpbl1"]*)
    73.6  (*[1], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set "norm_equation"*)
    73.7 -(*[2], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set "Test_simplify"*)
    73.8 -(*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(* Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
    73.9 +(*[2], Res*)val (_, ([(tac, _, _)], _, (pt''''', p'''''))) = Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set "Test_simplify"*)
   73.10 +
   73.11 +(*/--------- investigate Rewrite_Set "Test_simplify" -----------------------------------------\*)
   73.12 +(*+*)val form = get_obj g_res pt (fst p);
   73.13 +(*+*)UnparseC.term form = "x + 1 + - 1 * 2 = 0"; (*isa*)
   73.14 +(*+*)UnparseC.term form = "x + 1 + -1 * 2 = 0"; (*isa2*)
   73.15 +
   73.16 +val Rewrite_Set "Test_simplify" = tac;
   73.17 +
   73.18 +val res = get_obj g_res pt''''' (fst p''''');
   73.19 +(*+* )UnparseC.term res = "1 + (x + - 2) = 0"; ( *isa*)
   73.20 +(*+*)if UnparseC.term res = "- 1 + x = 0" (*isa2*) then () else error "Test_simplify CHANGED";
   73.21 +
   73.22 +Rewrite.trace_on := false; (*true false*)
   73.23 +val SOME (form', _) = rewrite_set_ @{theory Test} true Test_simplify form;
   73.24 +
   73.25 +(*+* )UnparseC.term form' = "1 + (x + - 2) = 0"; ( *isa*)
   73.26 +(*+*)if UnparseC.term form' = "- 1 + x = 0" (*isa2*) then () else error "Test_simplify CHANGED";
   73.27 +(*\--------- investigate Rewrite_Set "Test_simplify" -----------------------------------------/*)
   73.28 +(*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p''''' ((pt''''', e_pos'), []);(* Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
   73.29  (*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Model_Problem*)
   73.30  (*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Theory "Test"*)
   73.31 +
   73.32  (*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Problem ["LINEAR", "univariate", "equation", "test"]*)
   73.33  (*[3], Met*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Method ["Test", "solve_linear"]*)
   73.34  (*[3, 1], Frm*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Apply_Method ["Test", "solve_linear"]*)
   73.35 @@ -71,7 +90,7 @@
   73.36  
   73.37  val  Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv") = tac;
   73.38  
   73.39 -if p = ([3, 1], Res) andalso (get_obj g_res pt (fst p) |> UnparseC.term) = "x = 0 + -1 * -1"
   73.40 +if p = ([3, 1], Res) andalso (get_obj g_res pt (fst p) |> UnparseC.term) = "x = 0 + - 1 * - 1"
   73.41  then case tac of Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv") => ()
   73.42    | _ => error "Minisubplb/200-start-method-NEXT_STEP.sml CHANGED 1"
   73.43  else error "Minisubplb/200-start-method-NEXT_STEP.sml CHANGED 2"
    74.1 --- a/test/Tools/isac/Minisubpbl/250-Rewrite_Set-from-method.sml	Mon Jun 21 22:08:01 2021 +0200
    74.2 +++ b/test/Tools/isac/Minisubpbl/250-Rewrite_Set-from-method.sml	Sun Jul 18 18:15:27 2021 +0200
    74.3 @@ -229,7 +229,7 @@
    74.4  
    74.5  val p = p'''''_''; (*kept from before stepping into detail*)
    74.6  
    74.7 -if p = ([2], Res) andalso f2str f = "-1 + x = 0" then
    74.8 +if p = ([2], Res) andalso f2str f = "- 1 + x = 0" then
    74.9    case nxt of
   74.10      (Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])) => ()
   74.11    | _ => error "Minisubpbl/250-Rewrite_Set-from-method changed 1"
    75.1 --- a/test/Tools/isac/Minisubpbl/400-start-meth-subpbl.sml	Mon Jun 21 22:08:01 2021 +0200
    75.2 +++ b/test/Tools/isac/Minisubpbl/400-start-meth-subpbl.sml	Sun Jul 18 18:15:27 2021 +0200
    75.3 @@ -81,6 +81,6 @@
    75.4  
    75.5  val (p,_,f,nxt,_,pt) = me nxt''' p''' [] pt'''; (*nxt = Rewrite_Set_Inst isolate_bdv*);
    75.6  
    75.7 -if p = ([3, 1], Frm) andalso f2str f = "-1 + x = 0" andalso
    75.8 +if p = ([3, 1], Frm) andalso f2str f = "- 1 + x = 0" andalso
    75.9    Tactic.input_to_string nxt = "Rewrite_Set_Inst ([(''bdv'', x)], \"isolate_bdv\")"
   75.10  then () else error "Minisubpbl/400-start-meth-subpbl changed";
    76.1 --- a/test/Tools/isac/Minisubpbl/470-Check_elementwise-NEXT_STEP.sml	Mon Jun 21 22:08:01 2021 +0200
    76.2 +++ b/test/Tools/isac/Minisubpbl/470-Check_elementwise-NEXT_STEP.sml	Sun Jul 18 18:15:27 2021 +0200
    76.3 @@ -33,7 +33,7 @@
    76.4  
    76.5  (*+*)case tac of Rewrite_Set "Test_simplify" => (
    76.6  (*+*)  if p = ([3, 2], Res) then (
    76.7 -(*+*)    if pr_ctree pr_short pt = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + -1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   -1 + x = 0\n3.2.   x = 0 + -1 * -1\n"
    76.8 +(*+*)    if pr_ctree pr_short pt = ".    ----- pblobj -----\n1.   x + 1 = 2\n2.   x + 1 + - 1 * 2 = 0\n3.    ----- pblobj -----\n3.1.   - 1 + x = 0\n3.2.   x = 0 + - 1 * - 1\n"
    76.9  (*+*)    then () else error "470-Check_elementwise-NEXT_STEP: Rewrite_Set changed pt"
   76.10  (*+*)  ) else error "470-Check_elementwise-NEXT_STEP: Rewrite_Set changed p") 
   76.11  (*+*)| _ => error "470-Check_elementwise-NEXT_STEP: Rewrite_Set changed tac";
    77.1 --- a/test/Tools/isac/Minisubpbl/600-postcond-NEXT_STEP.sml	Mon Jun 21 22:08:01 2021 +0200
    77.2 +++ b/test/Tools/isac/Minisubpbl/600-postcond-NEXT_STEP.sml	Sun Jul 18 18:15:27 2021 +0200
    77.3 @@ -29,19 +29,19 @@
    77.4  (*[1], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p''''' ((pt''''', e_pos'), []);(*Rewrite_Set "norm_equation"*)
    77.5  
    77.6  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
    77.7 -  = "([\"\n(e_e, x + 1 = 2)\", \"\n(v_v, x)\"], [R, L, R, L, L, R, R], empty, SOME e_e, \nx + 1 + -1 * 2 = 0, ORundef, true, false)"
    77.8 +  = "([\"\n(e_e, x + 1 = 2)\", \"\n(v_v, x)\"], [R, L, R, L, L, R, R], empty, SOME e_e, \nx + 1 + - 1 * 2 = 0, ORundef, true, false)"
    77.9  then () else error "pstate changed after ([1], Res)"; (*this shall be corrected ............................. \<up> \<up> \<up> *)
   77.10  
   77.11  (*[2], Res*)val (_, ([(tac, _, _)], _, (pt, p))) =(**) Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set "Test_simplify"*)
   77.12  
   77.13  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.14 -  = "([\"\n(e_e, x + 1 = 2)\", \"\n(v_v, x)\"], [R, L, R, L, R, R], empty, SOME e_e, \n-1 + x = 0, ORundef, true, false)"
   77.15 +  = "([\"\n(e_e, x + 1 = 2)\", \"\n(v_v, x)\"], [R, L, R, L, R, R], empty, SOME e_e, \n- 1 + x = 0, ORundef, true, false)"
   77.16  then () else error "pstate changed after ([2], Res)"; (*this shall be corrected ................... \<up> \<up> \<up> *)
   77.17  
   77.18  (*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
   77.19  
   77.20  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.21 -  = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\"], [R, R, D, L, R], empty, NONE, \nSubproblem\n (''Test'',\n  ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n   ''test''), ORundef, true, false)"
   77.22 +  = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\"], [R, R, D, L, R], empty, NONE, \nSubproblem\n (''Test'',\n  ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n   ''test''), ORundef, true, false)"
   77.23  then () else error "pstate changed after ([3], Pbl)";
   77.24  
   77.25  (*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Model_Problem*)
   77.26 @@ -50,43 +50,43 @@
   77.27  (*[3], Pbl*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Specify_Method ["Test", "solve_linear"]*)
   77.28  
   77.29  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.30 -  = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\"], [R, R, D, L, R], empty, NONE, \nSubproblem\n (''Test'',\n  ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n   ''test''), ORundef, true, false)"
   77.31 +  = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\"], [R, R, D, L, R], empty, NONE, \nSubproblem\n (''Test'',\n  ??.\<^const>String.char.Char ''LINEAR'' ''univariate'' ''equation''\n   ''test''), ORundef, true, false)"
   77.32  then () else error "pstate changed after ([3], Pbl)";
   77.33  
   77.34  (*[3, 1], Frm*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Apply_Method ["Test", "solve_linear"]*)
   77.35  
   77.36  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.37 - = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\"], [], empty, NONE, \n??.empty, ORundef, false, true)"
   77.38 + = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\"], [], empty, NONE, \n??.empty, ORundef, false, true)"
   77.39  then () else error "pstate changed after ([3, 1], Frm)";
   77.40  
   77.41  (*[3, 1], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set_Inst (["(''bdv'', x)"], "isolate_bdv")*)
   77.42  
   77.43  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.44 -  = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + -1 * -1, ORundef, true, false)"
   77.45 +  = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, L, R], empty, SOME e_e, \nx = 0 + - 1 * - 1, ORundef, true, false)"
   77.46  then () else error "pstate changed after ([3, 1], Res)";
   77.47  
   77.48  (*[3, 2], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Rewrite_Set "Test_simplify"*)
   77.49  
   77.50  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.51 -  = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, R], empty, SOME e_e, \nx = 1, ORundef, true, false)"
   77.52 +  = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\"], [R, L, R, L, R, R], empty, SOME e_e, \nx = 1, ORundef, true, false)"
   77.53  then () else error "pstate changed after ([3, 2], Res)";
   77.54  
   77.55  (*[3], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Check_Postcond ["LINEAR", "univariate", "equation", "test"]*)
   77.56  
   77.57  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.58 - = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\"], [R, R, D, L, R], empty, NONE, \n[x = 1], ORundef, true, false)"
   77.59 + = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\"], [R, R, D, L, R], empty, NONE, \n[x = 1], ORundef, true, false)"
   77.60  then () else error "pstate changed after ([3], Res)";
   77.61  
   77.62  (*[4], Res*)val (_, ([(tac, _, _)], _, (pt, p))) = Step.do_next p ((pt, e_pos'), []);(*Check_elementwise "Assumptions"*)
   77.63  
   77.64  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.65 -  = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\", \"\n(L_L, [x = 1])\"], [R, R, D, R, D], empty, NONE, \n[x = 1], ORundef, true, false)"
   77.66 +  = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\", \"\n(L_L, [x = 1])\"], [R, R, D, R, D], empty, NONE, \n[x = 1], ORundef, true, false)"
   77.67  then () else error "pstate changed after ([4], Res)";
   77.68  
   77.69  (*[], Res* )val ("ok", ([(tac, _, _)], _, (pt, p))) =( **) Step.do_next p ((pt, e_pos'), []);(*Check_Postcond ["sqroot-test", "univariate", "equation", "test"]*)
   77.70  
   77.71  (*+*)if (get_istate_LI pt p |> the_pstate |> pstate2str)
   77.72 -  = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\", \"\n(L_L, [x = 1])\"], [R, R, D, R, D], empty, NONE, \n[x = 1], ORundef, true, false)"
   77.73 +  = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\", \"\n(L_L, [x = 1])\"], [R, R, D, R, D], empty, NONE, \n[x = 1], ORundef, true, false)"
   77.74  then () else error "pstate changed after ([], Res)";
   77.75  
   77.76  "~~~~~ fun do_next , args:"; val ((ip as (_, p_)), (ptp as (pt, p), tacis)) = (p, ((pt, e_pos'), []));
   77.77 @@ -103,7 +103,7 @@
   77.78  	      val ((ist, ctxt), sc) = LItool.resume_prog thy' (p,p_) pt;
   77.79  
   77.80  (*+*)Istate.string_of ist
   77.81 - = "Pstate ([\"\n(e_e, -1 + x = 0)\",\"\n(v_v, x)\",\"\n(L_L, [x = 1])\"], [R,R,D,R,D], empty, NONE, \n[x = 1],"
   77.82 + = "Pstate ([\"\n(e_e, - 1 + x = 0)\",\"\n(v_v, x)\",\"\n(L_L, [x = 1])\"], [R,R,D,R,D], empty, NONE, \n[x = 1],"
   77.83    ^ " ORundef, true, false)"; (*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~true ok*)
   77.84  
   77.85    (*case*) LI.find_next_step sc (pt, pos) ist ctxt (*of*);
   77.86 @@ -137,6 +137,6 @@
   77.87  
   77.88  (*/--------------------- final test ---------------------------------------------------------\\*)
   77.89  if pstate2str ist
   77.90 - = "([\"\n(e_e, -1 + x = 0)\", \"\n(v_v, x)\", \"\n(L_L, [x = 1])\"], [R, R, D], empty, NONE, \n[x = 1],"^
   77.91 + = "([\"\n(e_e, - 1 + x = 0)\", \"\n(v_v, x)\", \"\n(L_L, [x = 1])\"], [R, R, D], empty, NONE, \n[x = 1],"^
   77.92    " ORundef, true, false)"
   77.93  then () else error "";
    78.1 --- a/test/Tools/isac/Minisubpbl/700-interSteps.sml	Mon Jun 21 22:08:01 2021 +0200
    78.2 +++ b/test/Tools/isac/Minisubpbl/700-interSteps.sml	Sun Jul 18 18:15:27 2021 +0200
    78.3 @@ -110,9 +110,9 @@
    78.4  (*+*)Test_Tool.show_pt (fst ptp');(*[
    78.5  (([], Frm), solve (x + 1 = 2, x)),
    78.6  (([1], Frm), x + 1 = 2),
    78.7 -(([1], Res), x + 1 + -1 * 2 = 0),
    78.8 -(([2,1], Frm), x + 1 + -1 * 2 = 0),
    78.9 -(([2,1], Res), 1 + x + -1 * 2 = 0)]*)
   78.10 +(([1], Res), x + 1 + - 1 * 2 = 0),
   78.11 +(([2,1], Frm), x + 1 + - 1 * 2 = 0),
   78.12 +(([2,1], Res), 1 + x + - 1 * 2 = 0)]*)
   78.13  
   78.14  (*+*)val (keep_c', keep_ptp') = (c', ptp');
   78.15  "~~~~~ and Step_Solve.do_next , args:"; val () = ();
   78.16 @@ -156,18 +156,18 @@
   78.17  if pr_ctree pr_short pt =
   78.18    ".    ----- pblobj -----\n1" ^
   78.19    ".   x + 1 = 2\n" ^
   78.20 -  "2.   x + 1 + -1 * 2 = 0\n" ^
   78.21 -  "2.1.   x + 1 + -1 * 2 = 0\n" ^
   78.22 -  "2.2.   1 + x + -1 * 2 = 0\n" ^
   78.23 -  "2.3.   1 + (x + -1 * 2) = 0\n" ^
   78.24 -  "2.4.   1 + (x + -2) = 0\n" ^
   78.25 -  "2.5.   1 + (-2 + x) = 0\n" ^
   78.26 -  "2.6.   -2 + (1 + x) = 0\n" ^
   78.27 +  "2.   x + 1 + - 1 * 2 = 0\n" ^
   78.28 +  "2.1.   x + 1 + - 1 * 2 = 0\n" ^
   78.29 +  "2.2.   1 + x + - 1 * 2 = 0\n" ^
   78.30 +  "2.3.   1 + (x + - 1 * 2) = 0\n" ^
   78.31 +  "2.4.   1 + (x + - 2) = 0\n" ^
   78.32 +  "2.5.   1 + (- 2 + x) = 0\n" ^
   78.33 +  "2.6.   - 2 + (1 + x) = 0\n" ^
   78.34    "3.    ----- pblobj -----\n" ^
   78.35 -  "3.1.   -1 + x = 0\n" ^
   78.36 -  "3.1.1.   -1 + x = 0\n" ^
   78.37 -(*([3,1,1], Res), x = 0 + -1 * -1)       only shown by Test_Tool.show_pt*)
   78.38 -  "3.2.   x = 0 + -1 * -1\n" ^(* another difference to Test_Tool.show_pt*)
   78.39 +  "3.1.   - 1 + x = 0\n" ^
   78.40 +  "3.1.1.   - 1 + x = 0\n" ^
   78.41 +(*([3,1,1], Res), x = 0 + - 1 * - 1)       only shown by Test_Tool.show_pt*)
   78.42 +  "3.2.   x = 0 + - 1 * - 1\n" ^(* another difference to Test_Tool.show_pt*)
   78.43    "4.   [x = 1]\n"
   78.44  (*".  [x = 1]"                           only shown by Test_Tool.show_pt*)
   78.45 -then () else error "intermediate steps CHANGED";
   78.46 \ No newline at end of file
   78.47 +then () else error "intermediate steps CHANGED";
    79.1 --- a/test/Tools/isac/Minisubpbl/710-interSteps-short.sml	Mon Jun 21 22:08:01 2021 +0200
    79.2 +++ b/test/Tools/isac/Minisubpbl/710-interSteps-short.sml	Sun Jul 18 18:15:27 2021 +0200
    79.3 @@ -59,20 +59,20 @@
    79.4  if pr_ctree pr_short pt =
    79.5    ".    ----- pblobj -----\n" ^
    79.6    "1.   x + 1 = 2\n" ^
    79.7 -  "2.   x + 1 + -1 * 2 = 0\n" ^
    79.8 -  "2.1.   x + 1 + -1 * 2 = 0\n" ^
    79.9 -  "2.2.   1 + x + -1 * 2 = 0\n" ^
   79.10 -  "2.3.   1 + (x + -1 * 2) = 0\n" ^
   79.11 -  "2.4.   1 + (x + -2) = 0\n" ^
   79.12 -  "2.5.   1 + (-2 + x) = 0\n" ^
   79.13 -  "2.6.   -2 + (1 + x) = 0\n" ^
   79.14 -(*([2,6], Res), -1 + x = 0)              only by Test_Tool.show_pt_tac*)
   79.15 +  "2.   x + 1 + - 1 * 2 = 0\n" ^
   79.16 +  "2.1.   x + 1 + - 1 * 2 = 0\n" ^
   79.17 +  "2.2.   1 + x + - 1 * 2 = 0\n" ^
   79.18 +  "2.3.   1 + (x + - 1 * 2) = 0\n" ^
   79.19 +  "2.4.   1 + (x + - 2) = 0\n" ^
   79.20 +  "2.5.   1 + (- 2 + x) = 0\n" ^
   79.21 +  "2.6.   - 2 + (1 + x) = 0\n" ^
   79.22 +(*([2,6], Res), - 1 + x = 0)              only by Test_Tool.show_pt_tac*)
   79.23    "3.    ----- pblobj -----\n" ^
   79.24 -  "3.1.   -1 + x = 0\n" ^
   79.25 -  "3.1.1.   -1 + x = 0\n" ^
   79.26 -(*([3,1,1], Res), x = 0 + -1 * -1)       only by Test_Tool.show_pt_tac*)
   79.27 -  "3.2.   x = 0 + -1 * -1\n" ^
   79.28 -  "3.2.1.   x = 0 + -1 * -1\n" ^
   79.29 +  "3.1.   - 1 + x = 0\n" ^
   79.30 +  "3.1.1.   - 1 + x = 0\n" ^
   79.31 +(*([3,1,1], Res), x = 0 + - 1 * - 1)       only by Test_Tool.show_pt_tac*)
   79.32 +  "3.2.   x = 0 + - 1 * - 1\n" ^
   79.33 +  "3.2.1.   x = 0 + - 1 * - 1\n" ^
   79.34    "3.2.2.   x = 0 + 1\n" ^
   79.35  (*([3,2,2], Res),  x = 1)                only by Test_Tool.show_pt_tac*)
   79.36    "4.   [x = 1]\n"
    80.1 --- a/test/Tools/isac/Minisubpbl/790-complete.sml	Mon Jun 21 22:08:01 2021 +0200
    80.2 +++ b/test/Tools/isac/Minisubpbl/790-complete.sml	Sun Jul 18 18:15:27 2021 +0200
    80.3 @@ -20,7 +20,7 @@
    80.4  (*[1], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Rewrite_Set "Test_simplify"*)
    80.5  (*[2], Res*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Subproblem ("Test", ["LINEAR", "univariate", "equation", "test"])*)
    80.6  (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Model_Problem*)
    80.7 -(*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Add_Given "equality (-1 + x = 0)"*)
    80.8 +(*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Add_Given "equality (- 1 + x = 0)"*)
    80.9  (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Add_Given "solveFor x"*)
   80.10  (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Add_Find "solutions x_i"*)
   80.11  (*[3], Pbl*)val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*\<rightarrow>Specify_Theory "Test"*)
   80.12 @@ -38,10 +38,10 @@
   80.13  if p = ([], Res) andalso f2str f = "[x = 1]" andalso pr_ctree pr_short pt =
   80.14     ".    ----- pblobj -----\n" ^
   80.15     "1.   x + 1 = 2\n" ^
   80.16 -   "2.   x + 1 + -1 * 2 = 0\n" ^
   80.17 +   "2.   x + 1 + - 1 * 2 = 0\n" ^
   80.18     "3.    ----- pblobj -----\n" ^
   80.19 -   "3.1.   -1 + x = 0\n" ^
   80.20 -   "3.2.   x = 0 + -1 * -1\n" ^
   80.21 +   "3.1.   - 1 + x = 0\n" ^
   80.22 +   "3.2.   x = 0 + - 1 * - 1\n" ^
   80.23     "4.   [x = 1]\n"
   80.24  then case nxt of End_Proof' => () | _ => error "re-build: fun locate_input_tactic changed 1"
   80.25  else error "re-build: fun locate_input_tactic changed";
    81.1 --- a/test/Tools/isac/Minisubpbl/800-append-on-Frm.sml	Mon Jun 21 22:08:01 2021 +0200
    81.2 +++ b/test/Tools/isac/Minisubpbl/800-append-on-Frm.sml	Sun Jul 18 18:15:27 2021 +0200
    81.3 @@ -30,8 +30,8 @@
    81.4  ([1], Frm), x + 1 = 2
    81.5  . . . . . . . . . . Empty_Tac] *)
    81.6  
    81.7 -         (*appendFormula 1 "2+ -1 + x = 2";*)
    81.8 -"~~~~~ fun appendFormula , args:"; val (ifo) = ("2+ -1 + x = 2");
    81.9 +         (*appendFormula 1 "2+ - 1 + x = 2";*)
   81.10 +"~~~~~ fun appendFormula , args:"; val (ifo) = ("2+ - 1 + x = 2");
   81.11      val cs = (*get_calc cI*)  ((pt, p), [])  (*..continue fun me*)
   81.12      val pos = (*get_pos cI 1*)  p            (*..continue fun me*)
   81.13  
   81.14 @@ -138,12 +138,12 @@
   81.15  (*+*)length tacis = 8;
   81.16  (*+*)if State_Steps.to_string tacis = "[\"\n" ^
   81.17    "( End_Trans, End_Trans' xxx, ( ([2, 6], Res), Pstate ([\"\n(e_e, x + 1 = 2)\", \"\n" ^
   81.18 -  "(v_v, x)\"], [], empty, NONE, \n2 + -1 + x = 2, ORundef, false, true) ))\", \"\n" ^
   81.19 +  "(v_v, x)\"], [], empty, NONE, \n2 + - 1 + x = 2, ORundef, false, true) ))\", \"\n" ^
   81.20    "( Rewrite (\"sym_radd_commute\", \"?n + ?m = ?m + ?n\"), Rewrite' , ( ([2, 6], Res), Uistate ))\", \"\n" ^
   81.21    "( Rewrite (\"sym_radd_commute\", \"?n + ?m = ?m + ?n\"), Rewrite' , ( ([2, 5], Res), Uistate ))\", \"\n" ^
   81.22    "( Rewrite (\"sym_radd_left_commute\", \"?y + (?x + ?z) = ?x + (?y + ?z)\"), Rewrite' , ( ([2, 4], Res), Uistate ))\", \"\n" ^
   81.23    "( Rewrite (\"sym_radd_commute\", \"?n + ?m = ?m + ?n\"), Rewrite' , ( ([2, 3], Res), Uistate ))\", \"\n" ^
   81.24 -  "( Rewrite (\"#: 1 + x = -1 + (2 + x)\", \"1 + x = -1 + (2 + x)\"), Rewrite' , ( ([2, 2], Res), Uistate ))\", \"\n" ^
   81.25 +  "( Rewrite (\"#: 1 + x = - 1 + (2 + x)\", \"1 + x = - 1 + (2 + x)\"), Rewrite' , ( ([2, 2], Res), Uistate ))\", \"\n" ^
   81.26    "( Rewrite (\"radd_commute\", \"?m + ?n = ?n + ?m\"), Rewrite' , ( ([2, 1], Res), Uistate ))\", \"\n" ^
   81.27    "( Begin_Trans, Begin_Trans' xxx, ( ([2], Frm), Uistate ))\"]"
   81.28  then () else error "Derive.embed CHANGED";
   81.29 @@ -166,7 +166,7 @@
   81.30    (ctxt_res |> get_assumptions |> UnparseC.terms) = "[\"precond_rootmet x\"]"
   81.31    andalso
   81.32    Istate.string_of ist_res =
   81.33 -    "Pstate ([\"\n(e_e, x + 1 = 2)\", \"\n(v_v, x)\"], [], empty, NONE, \n2 + -1 + x = 2, ORundef, false, true)"
   81.34 +    "Pstate ([\"\n(e_e, x + 1 = 2)\", \"\n(v_v, x)\"], [], empty, NONE, \n2 + - 1 + x = 2, ORundef, false, true)"
   81.35  then () else error "/800-append-on-Frm.sml CHANGED";
   81.36  
   81.37  Test_Tool.show_pt_tac (fst ptp''''');(*[
   81.38 @@ -177,17 +177,17 @@
   81.39  ([1,1], Frm), x + 1 = 2
   81.40  . . . . . . . . . . Rewrite ("radd_commute", "?m + ?n = ?n + ?m"),
   81.41  ([1,1], Res), 1 + x = 2
   81.42 -. . . . . . . . . . Rewrite ("#: 1 + x = -1 + (2 + x)", "1 + x = -1 + (2 + x)"),
   81.43 -([1,2], Res), -1 + (2 + x) = 2
   81.44 +. . . . . . . . . . Rewrite ("#: 1 + x = - 1 + (2 + x)", "1 + x = - 1 + (2 + x)"),
   81.45 +([1,2], Res), - 1 + (2 + x) = 2
   81.46  . . . . . . . . . . Rewrite ("sym_radd_commute", "?n + ?m = ?m + ?n"),
   81.47 -([1,3], Res), -1 + (x + 2) = 2
   81.48 +([1,3], Res), - 1 + (x + 2) = 2
   81.49  . . . . . . . . . . Rewrite ("sym_radd_left_commute", "?y + (?x + ?z) = ?x + (?y + ?z)"),
   81.50 -([1,4], Res), x + (-1 + 2) = 2
   81.51 +([1,4], Res), x + (- 1 + 2) = 2
   81.52  . . . . . . . . . . Rewrite ("sym_radd_commute", "?n + ?m = ?m + ?n"),
   81.53 -([1,5], Res), x + (2 + -1) = 2
   81.54 +([1,5], Res), x + (2 + - 1) = 2
   81.55  . . . . . . . . . . Rewrite ("sym_radd_commute", "?n + ?m = ?m + ?n"),
   81.56 -([1,6], Res), 2 + -1 + x = 2
   81.57 +([1,6], Res), 2 + - 1 + x = 2
   81.58  . . . . . . . . . . Tactic.input_to_string not impl. for ?!,
   81.59 -([1], Res), 2 + -1 + x = 2
   81.60 +([1], Res), 2 + - 1 + x = 2
   81.61  . . . . . . . . . . Check_Postcond ["sqroot-test", "univariate", "equation", "test"]] 
   81.62  *)
    82.1 --- a/test/Tools/isac/OLDTESTS/root-equ.sml	Mon Jun 21 22:08:01 2021 +0200
    82.2 +++ b/test/Tools/isac/OLDTESTS/root-equ.sml	Sun Jul 18 18:15:27 2021 +0200
    82.3 @@ -1,10 +1,9 @@
    82.4 -(* Rewrite.trace_on:= true;
    82.5 -   Rewrite.trace_on:= false;
    82.6 +(* 
    82.7 +   
    82.8  
    82.9     method "sqrt-equ-test", _NOT_ "square-equation" 
   82.10  *)
   82.11  
   82.12 -
   82.13  " ================= equation with x =(-12)/5, but L ={} ======= ";
   82.14  " _________________ rewrite _________________ ";
   82.15  
   82.16 @@ -533,8 +532,7 @@
   82.17   val t = TermC.str2term "sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x)";
   82.18   val SOME (t',asm) = rewrite_set_ thy false rls t;
   82.19   UnparseC.term t';
   82.20 -> Rewrite.trace_on:=true; 
   82.21 - Rewrite.trace_on:=false; 
   82.22 + Rewrite.trace_on:=false; (*true false*)
   82.23  *)
   82.24  
   82.25  (*me------------
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/test/Tools/isac/ProgLang/calculate.sml	Sun Jul 18 18:15:27 2021 +0200
    83.3 @@ -0,0 +1,38 @@
    83.4 +(* Title:  "ProgLang/calculate.sml"
    83.5 +   Author: Walther Neuper 2021
    83.6 +   (c) copyright due to lincense terms.
    83.7 +*)
    83.8 +
    83.9 +"-----------------------------------------------------------------------------------------------";
   83.10 +"table of contents -----------------------------------------------------------------------------";
   83.11 +"-----------------------------------------------------------------------------------------------";
   83.12 +"----------- RE-BUILD fun eval_binop -----------------------------------------------------------";
   83.13 +"-----------------------------------------------------------------------------------------------";
   83.14 +"-----------------------------------------------------------------------------------------------";
   83.15 +"-----------------------------------------------------------------------------------------------";
   83.16 +
   83.17 +"----------- RE-BUILD fun eval_binop -----------------------------------------------------------";
   83.18 +"----------- RE-BUILD fun eval_binop -----------------------------------------------------------";
   83.19 +"----------- RE-BUILD fun eval_binop -----------------------------------------------------------";
   83.20 +val (t1, t2) = (@{term 3}, @{term "2::real"});
   83.21 +val t = HOLogic.mk_binop "Groups.plus_class.plus" (t1, t2);
   83.22 +
   83.23 +           eval_binop "" "" t "";
   83.24 +"~~~~~ fun eval_binop , args:"; val (_, _, (t as (Const (op0, t0) $ t1 $ t2)), _) =(* binary . n1.n2 *)
   83.25 +  ((), (), t, ());
   83.26 +    (*if*) TermC.is_num t1 andalso TermC.is_num t2 (*then*);
   83.27 +        val res = calcul op0 (t1, t2);
   83.28 +        val prop = HOLogic.Trueprop $ (HOLogic.mk_eq (t, res));
   83.29 +      (*in*)
   83.30 +        val xxx = SOME ("#: " ^ UnparseC.term prop, prop);
   83.31 +      (*end*)
   83.32 +
   83.33 +case xxx of
   83.34 +  SOME
   83.35 +    ("#: (3::'a) + 2 = (5::'a)",
   83.36 +     Const ("HOL.Trueprop", _) $
   83.37 +       (Const ("HOL.eq", _) $
   83.38 +         (Const ("Groups.plus_class.plus", _) $ _ $
   83.39 +           (Const ("Num.numeral_class.numeral", _) $ _ )) $
   83.40 +         _ )) => ()
   83.41 +| _ => error "eval_binop #: (3::'a) + 2 = (5::'a) CHANGED"
    84.1 --- a/test/Tools/isac/ProgLang/evaluate.sml	Mon Jun 21 22:08:01 2021 +0200
    84.2 +++ b/test/Tools/isac/ProgLang/evaluate.sml	Sun Jul 18 18:15:27 2021 +0200
    84.3 @@ -14,9 +14,10 @@
    84.4  "----------- calculate from Prog --------------------------------- -----------------------------";
    84.5  "----------- calculate from script --requires 'setup'----";
    84.6  "----------- calculate check test-root-equ --------------";
    84.7 -"----------- check calcul,ate bottom up -----------------";
    84.8 +"----------- check calculate bottom up -----------------";
    84.9  "----------- Prog_Expr.pow Power.power_class.power ---------";
   84.10 -" ================= evaluate.sml: calculate_ 2002 ======";
   84.11 +"----------- fun cancel_int --------------------------------------------------------------------";
   84.12 +"----------- RE-BUILD fun calcul ---------------------------------------------------------------";
   84.13  "----------- get_pair with 3 args -----------------------";
   84.14  "----------- calculate (2 * x is_const) -----------------";
   84.15  "----------- fun get_pair: examples ------------------------------------------------------------";
   84.16 @@ -45,12 +46,12 @@
   84.17  (* fun rewrite__set_ \<longrightarrow> fun rew_once works the same way *)
   84.18  val t = TermC.str2term "((1+2)*4/3) \<up> 2";
   84.19  val thy = @{theory};
   84.20 -val times =  (\<^const_name>\<open>times\<close>, eval_binop "#mult_") : string * Eval_Def.eval_fn;
   84.21 -val plus =   (\<^const_name>\<open>plus\<close>,eval_binop "#add_") : string * Eval_Def.eval_fn;
   84.22 -val divide = (\<^const_name>\<open>divide\<close>  ,eval_cancel "#divide_e") : string * Eval_Def.eval_fn;
   84.23 -val pow =    (\<^const_name>\<open>powr\<close>  ,eval_binop "#power_") : string * Eval_Def.eval_fn;
   84.24 +val times =  ("Groups.times_class.times", eval_binop "#mult_") : string * Eval_Def.eval_fn;
   84.25 +val plus =   ("Groups.plus_class.plus", eval_binop "#add_") : string * Eval_Def.eval_fn;
   84.26 +val divide = ("Rings.divide_class.divide", eval_cancel "#divide_e") : string * Eval_Def.eval_fn;
   84.27 +val pow =    ("Transcendental.powr", eval_binop "#power_") : string * Eval_Def.eval_fn;
   84.28  
   84.29 -"~~~~~ fun calculate_, args:"; val (thy, isa_fn, t) = (thy, plus, t);
   84.30 +"~~~~~ fun calculate_ , args:"; val (thy, isa_fn, t) = (thy, plus, t);
   84.31  val SOME ("#: 1 + 2 = 3", adh_thm) = adhoc_thm @{theory} isa_fn t;
   84.32  val SOME (t', []) = rewrite__ thy 0 [] e_rew_ord Rule_Set.empty true adh_thm t;
   84.33  if UnparseC.term t' = "(3 * 4 / 3) \<up> 2" then () else error "calculate_  1 + 2 = 3  changed";
   84.34 @@ -76,7 +77,7 @@
   84.35  val thy = @{theory "Test"};
   84.36  val fmz = ["realTestGiven (((1+2)*4/3) \<up> 2)", "realTestFind s"];
   84.37  val (dI',pI',mI') =
   84.38 -  ("Test",["calculate", "test"],["Test", "test_calculate"]);
   84.39 +  ("Test", ["calculate", "test"], ["Test", "test_calculate"]);
   84.40  
   84.41  val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
   84.42  val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
   84.43 @@ -107,23 +108,23 @@
   84.44  "----------- calculate check test-root-equ --------------";
   84.45  (*(1): 2nd Test_simplify didn't work:
   84.46  val ct =
   84.47 -  "sqrt (x \<up> 2 + -3 * x) = (-3 + 2 * x + -1 * (9 + 4 * x)) / (-1 * 2)"
   84.48 +  "sqrt (x \<up> 2 + -3 * x) = (-3 + 2 * x + - 1 * (9 + 4 * x)) / (- 1 * 2)"
   84.49  > val rls = ("Test_simplify");
   84.50  > val (ct,_) = the (rewrite_set thy' ("tval_rls") false rls ct);
   84.51  val ct = "sqrt (x \<up> 2 + -3 * x) =
   84.52 -(-9) / (-2) + (-3 / (-2) + (x * ((-4) / (-2)) + x * (2 / (-2))))";
   84.53 +(-9) / (- 2) + (-3 / (- 2) + (x * ((-4) / (- 2)) + x * (2 / (- 2))))";
   84.54  ie. cancel does not work properly
   84.55  *)
   84.56   val thy = @{theory "Test"};
   84.57   val op_ = the (LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "DIVIDE"));
   84.58   val ct = ThmC_Def.num_to_Free @{term
   84.59 -   "sqrt (x \<up> 2 + -3 * x) = (-9) / (-2) + (-3 / (-2) + (x * ((-4) / (-2)) + x * (2 / (-2))))"};
   84.60 +   "sqrt (x \<up> 2 + -3 * x) = (-9) / (- 2) + (-3 / (- 2) + (x * ((-4) / (- 2)) + x * (2 / (- 2))))"};
   84.61  case calculate_ thy op_ ct of
   84.62    SOME _ => ()
   84.63  | NONE => error "calculate_ test-root-equ changed";
   84.64  (*
   84.65             sqrt (x \<up> 2 + -3 * x) =\
   84.66 - \(-9) / (-2) + (-3 / (-2) + (x * ((-4) / (-2)) + x * (2 / (-2))))
   84.67 + \(-9) / (- 2) + (-3 / (- 2) + (x * ((-4) / (- 2)) + x * (2 / (- 2))))
   84.68  ............... does not work *)
   84.69  
   84.70  (*--------------(2): does divide work in Test_simplify ?: ------*)
   84.71 @@ -148,7 +149,7 @@
   84.72  "----------- check calculate bottom up ------------------";
   84.73  "----------- check calculate bottom up ------------------";
   84.74  (*-------------- eval_cancel works: *)
   84.75 - Rewrite.trace_on := false;
   84.76 + Rewrite.trace_on := false; (*true false*)
   84.77   val thy = @{theory Test};
   84.78   val rls = Test_simplify;
   84.79   val t = (Thm.term_of o the o (TermC.parse thy)) "(-4) / 2";
   84.80 @@ -158,22 +159,25 @@
   84.81  (*--------------(5): reproduce (1) with simpler term: ------------*)
   84.82   val t = (Thm.term_of o the o (TermC.parse thy)) "(3+5)/2";
   84.83  case rewrite_set_ thy false rls t of
   84.84 -  SOME (Free ("4", _), []) => ()
   84.85 -| _ => error "rewrite_set_ (3+5)/2 changed";
   84.86 +  SOME (t', []) =>
   84.87 +    if UnparseC.term t' = "4" then ()
   84.88 +    else error "rewrite_set_ (3+5)/2 changed 1"
   84.89 +| _ => error "rewrite_set_ (3+5)/2 changed 2";
   84.90  
   84.91   val t = (Thm.term_of o the o (TermC.parse thy)) "(3+1+2*x)/2";
   84.92  case rewrite_set_ thy false rls t of
   84.93 -  SOME (Const (\<^const_name>\<open>plus\<close>, _) $ Free ("2", _) $ Free ("x", _), []) => ()
   84.94 -| _ => error "rewrite_set_ (3+1+2*x)/2 changed";
   84.95 +  SOME (t', _) =>   (*WAS "x + 2" WITH OLD numerals TOODOO?*)
   84.96 +    if UnparseC.term t' = "2 + x" then () else error "rewrite_set_ (3+1+2*x)/2 changed 1"
   84.97 +| _ => error "rewrite_set_ (3+1+2*x)/2 changed 2";
   84.98  
   84.99 - Rewrite.trace_on:=false; (*=true3.6.03*)
  84.100 + Rewrite.trace_on := false; (*true false*)
  84.101  
  84.102  (*--- Rewrite.trace_on before correction of ... --------------------
  84.103 - val ct = "(-3 + 2 * x + -1) / 2";
  84.104 + val ct = "(-3 + 2 * x + - 1) / 2";
  84.105   val (ct,_) = the (rewrite_set thy'  false rls ct);
  84.106  :
  84.107  ### trying thm 'root_ge0_2'
  84.108 -### rewrite_set_: x + (-1 + -3) / 2
  84.109 +### rewrite_set_: x + (- 1 + -3) / 2
  84.110  ### trying thm 'radd_real_const_eq'
  84.111  ### trying thm 'radd_real_const'
  84.112  ### rewrite_set_: x + (-4) / 2
  84.113 @@ -181,26 +185,27 @@
  84.114  :
  84.115  "x + (-4) / 2"
  84.116  -------------------------------------while before Isabelle20002:
  84.117 - val ct = "(#-3 + #2 * x + #-1) // #2";
  84.118 + val ct = "(#-3 + #2 * x + #- 1) // #2";
  84.119   val (ct,_) = the (rewrite_set thy'  false rls ct);
  84.120  :
  84.121  ### trying thm 'root_ge0_2'
  84.122 -### rewrite_set_: x + (#-1 + #-3) // #2
  84.123 +### rewrite_set_: x + (#- 1 + #-3) // #2
  84.124  ### trying thm 'radd_real_const_eq'
  84.125  ### trying thm 'radd_real_const'
  84.126  ### rewrite_set_: x + #-4 // #2
  84.127 -### rewrite_set_: x + #-2
  84.128 +### rewrite_set_: x + #- 2
  84.129  ### trying thm 'rcollect_right'
  84.130  :
  84.131 -"#-2 + x"
  84.132 +"#- 2 + x"
  84.133  -----------------------------------------------------------------*)
  84.134  
  84.135  
  84.136  (*===================*)
  84.137   Rewrite.trace_on:=false; (*WN130722: =true stopped Test_Isac.thy*)
  84.138 - val t = (Thm.term_of o the o (TermC.parse thy))  "x + (-1 + -3) / 2";
  84.139 + val t = (Thm.term_of o the o (TermC.parse thy))  "x + (- 1 + -3) / 2";
  84.140  val SOME (res, []) = rewrite_set_ thy false rls t;
  84.141 -if UnparseC.term res = "-2 + x" then () else error "rewrite_set_  x + (-1 + -3) / 2  changed";
  84.142 +                 (*WAS "x + - 2" WITH OLD numerals TOODOO?*)
  84.143 +if UnparseC.term res = "- 2 + x" then () else error "rewrite_set_  x + (- 1 + -3) / 2  changed";
  84.144  "x + (-4) / 2";						
  84.145  (*
  84.146  ### trying calc. 'cancel'
  84.147 @@ -217,24 +222,6 @@
  84.148  
  84.149   Rewrite.trace_on:=false; (*WN130722: =true stopped Test_Isac.thy*)
  84.150  
  84.151 -"----------- Prog_Expr.pow Power.power_class.power ---------";
  84.152 -"----------- Prog_Expr.pow Power.power_class.power ---------";
  84.153 -"----------- Prog_Expr.pow Power.power_class.power ---------";
  84.154 -val t = (Thm.term_of o the o (parseold thy)) "1 ^ aaa";
  84.155 -TermC.atomty t;
  84.156 -(*** -------------
  84.157 -*** Const ( Nat.power, ['a, nat] => 'a)
  84.158 -*** . Free ( 1, 'a)
  84.159 -*** . Free ( aaa, nat) *)
  84.160 -
  84.161 -val t = TermC.str2term "1 \<up> aaa";
  84.162 -TermC.atomty t;
  84.163 -(**** 
  84.164 -*** Const (Prog_Expr.pow, real => real => real)
  84.165 -*** . Free (1, real)
  84.166 -*** . Free (aaa, real)
  84.167 -*** *);
  84.168 -
  84.169  " ================= evaluate.sml: calculate_ 2002 =================== ";
  84.170  " ================= evaluate.sml: calculate_ 2002 =================== ";
  84.171  " ================= evaluate.sml: calculate_ 2002 =================== ";
  84.172 @@ -291,10 +278,64 @@
  84.173    val SOME (id,t') = eval_fn op_ t thy;
  84.174  (*** calc: operator = pow not defined*)
  84.175  
  84.176 -  val (thmid, (Const (op0,t0) $ Free (n1,t1) $ Free(n2,t2))) = (op_, t);
  84.177 -  val SOME (id,t') = eval_binop thmid op_ t thy;
  84.178 +case (op_, t) of
  84.179 +  ("Transcendental.powr",
  84.180 +    Const ("Transcendental.powr", _) $ (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit1", _) $ Const ("Num.num.One", _))) $
  84.181 +      (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ Const ("Num.num.One", _)))) => ()
  84.182 +| _ => error "3 \<up> 2 CHANGED";
  84.183 +  val SOME (id, t') = eval_binop thmid op_ t thy;
  84.184  (*** calc: operator = pow not defined*)
  84.185  
  84.186 +if UnparseC.term t' = "3 \<up> 2 = 9" then () else error "eval_binop  3 \<up> 2 = 9  CHANGED";
  84.187 +
  84.188 +
  84.189 +"----------- fun cancel_int --------------------------------------------------------------------";
  84.190 +"----------- fun cancel_int --------------------------------------------------------------------";
  84.191 +"----------- fun cancel_int --------------------------------------------------------------------";
  84.192 +if cancel_int (~4, 2) = (~1, (2, 1)) then () else error "cancel_int (~4, 2) CHANGED";
  84.193 +if cancel_int (4, ~8) = (~1, (1, 2)) then () else error "cancel_int (4, ~8) CHANGED";
  84.194 +if cancel_int (6, 4) = (1, (3, 2)) then () else error "cancel_int (6, 4)CHANGED";
  84.195 +
  84.196 +
  84.197 +"----------- RE-BUILD fun calcul ---------------------------------------------------------------";
  84.198 +"----------- RE-BUILD fun calcul ---------------------------------------------------------------";
  84.199 +"----------- RE-BUILD fun calcul ---------------------------------------------------------------";
  84.200 +val (t1, t2) = (@{term 3}, @{term "2::real"});
  84.201 +
  84.202 +"~~~~~ fun calcul , args:"; val (op_, (t1, t2)) = ("Groups.plus_class.plus", (t1, t2));
  84.203 +    val (Const ("Num.numeral_class.numeral", _) $ n1) = t1;
  84.204 +    val (Const ("Num.numeral_class.numeral", _) $ n2) = t2;
  84.205 +    val (T, _) = HOLogic.dest_number t1
  84.206 +    val (i1, i2) = (HOLogic.dest_numeral n1, HOLogic.dest_numeral n2)
  84.207 +    val result =
  84.208 +      case op_ of
  84.209 +        "Groups.plus_class.plus" => i1 + i2
  84.210 +      | "Groups.minus_class.minus" => i1 - i2
  84.211 +      | "Groups.times_class.times" => i1 * i2
  84.212 +      | "Transcendental.powr" => power i1 i2
  84.213 +      | str => raise ERROR ("calcul not impl.for op_ " ^ str)
  84.214 +  (*in*)
  84.215 +    val xxx = HOLogic.mk_number T result;
  84.216 +  (*end*)
  84.217 +case HOLogic.dest_number xxx of
  84.218 +  (_, 5) => ()
  84.219 +| _ => error "calcul + 2 3 CHANGED";
  84.220 +
  84.221 +case HOLogic.dest_number (calcul "Groups.minus_class.minus" (t1, t2)) of
  84.222 +  (_, 1) => xxx
  84.223 +| _ => error "calcul - 2 3 CHANGED";
  84.224 +
  84.225 +case HOLogic.dest_number (calcul "Groups.times_class.times" (t1, t2)) of
  84.226 +  (_, 6) => xxx
  84.227 +| _ => error "calcul - 2 3 CHANGED";
  84.228 +
  84.229 +(*                       (calcul "Rings.divide_class.divide" (t1, t2)
  84.230 +ERROR: calcul not impl.for op_ Rings.divide_class.divide*)
  84.231 +
  84.232 +case HOLogic.dest_number (calcul "Transcendental.powr" (t1, t2)) of
  84.233 +  (_, 9) => xxx
  84.234 +| _ => error "calcul - 2 3 CHANGED";
  84.235 +
  84.236  
  84.237  "----------- get_pair with 3 args --------------------------------";
  84.238  "----------- get_pair with 3 args --------------------------------";
  84.239 @@ -303,11 +344,11 @@
  84.240      (thy, "EqSystem.occur_exactly_in", 
  84.241       assoc_calc' (@{theory "EqSystem"}) "occur_exactly_in" |> snd |> snd,
  84.242       TermC.str2term
  84.243 -      "[] from [c, c_2, c_3, c_4] occur_exactly_in -1 * (q_0 * L \<up> 2) / 2"
  84.244 +      "[] from [c, c_2, c_3, c_4] occur_exactly_in - 1 * (q_0 * L \<up> 2) / 2"
  84.245        );
  84.246  val SOME (str, simpl) = get_pair thy op_ ef arg;
  84.247  if str = 
  84.248 -"[] from [c, c_2, c_3, c_4] occur_exactly_in -1 * (q_0 * L \<up> 2) / 2 = True"
  84.249 +"[] from [c, c_2, c_3, c_4] occur_exactly_in - 1 * (q_0 * L \<up> 2) / 2 = True"
  84.250  then () else error "evaluate.sml get_pair with 3 args:occur_exactly_in";
  84.251  
  84.252  
  84.253 @@ -316,49 +357,50 @@
  84.254  "----------- calculate (2 * x is_const) -----------------";
  84.255  val t = TermC.str2term "2 * x is_const";
  84.256  val SOME (str, t') = eval_const "" "" t @{theory Test};
  84.257 -UnparseC.term t';
  84.258 -"(2 * x is_const) = False";
  84.259 +if UnparseC.term t' = "(2 * x is_const) = False" then ()
  84.260 +else error "eval_const 2 * x is_const CHANGED";
  84.261  
  84.262  val SOME (t',_) = rewrite_set_ @{theory Test} false tval_rls t;
  84.263 -UnparseC.term t';
  84.264 -\<^const_name>\<open>False\<close>;
  84.265 +if UnparseC.term t' = "False" then ()
  84.266 +else error "rewrite_set_ 2 * x is_const CHANGED";
  84.267  
  84.268  "----------- fun get_pair: examples ------------------------------------------------------------";
  84.269  "----------- fun get_pair: examples ------------------------------------------------------------";
  84.270  "----------- fun get_pair: examples ------------------------------------------------------------";
  84.271  val thy = @{theory};
  84.272  val SOME (isa_str, eval_fn) = LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "PLUS");
  84.273 +if isa_str = "Groups.plus_class.plus" then () else error "eval_fn PLUS changed";
  84.274  
  84.275 -val t = (Thm.term_of o the o (TermC.parse thy)) "3 + 4";
  84.276 +val t = @{term "3 + 4 :: real"};
  84.277  val SOME (str, term) = get_pair thy isa_str eval_fn t;
  84.278 -if str =  "#: 3 + 4 = 7" andalso UnparseC.term term = "3 + 4 = 7"
  84.279 -then () else error "get_pair  3 + 4  changed";
  84.280 +(*+*)if str =  "#: 3 + 4 = 7" andalso UnparseC.term term = "3 + 4 = 7"
  84.281 +(*+*)then () else error "get_pair  3 + 4  changed";
  84.282  
  84.283 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a + 3) + 4";
  84.284 +val t = @{term "(a + 3) + 4 :: real"};
  84.285  val SOME (str, term) = get_pair thy isa_str eval_fn t;
  84.286  if str =  "#: a + 3 + 4 = a + 7" andalso UnparseC.term term = "a + 3 + 4 = a + 7"
  84.287  then () else error "get_pair  (a + 3) + 4  changed";
  84.288  
  84.289 -val t = (Thm.term_of o the o (TermC.parse thy)) "(a + 3) + 4";
  84.290 +val t = @{term "(a + 3) + 4 :: real"};
  84.291  val SOME (str, term) = get_pair thy isa_str eval_fn t;
  84.292  if str =  "#: a + 3 + 4 = a + 7" andalso UnparseC.term term = "a + 3 + 4 = a + 7"
  84.293  then () else error "get_pair  (a + 3) + 4  changed";
  84.294  
  84.295 -val t = (Thm.term_of o the o (TermC.parse thy)) "x = 5 * (3 + (4 + a))";
  84.296 +val t = @{term "x = 5 * (3 + (4 + a) :: real)"};
  84.297  val SOME (str, term) = get_pair thy isa_str eval_fn t;
  84.298  if str =  "#: 3 + (4 + a) = 7 + a" andalso UnparseC.term term = "3 + (4 + a) = 7 + a"
  84.299  then ((* !!! gets subterm !!!*)) else error "get_pair  x = 5 * (3 + (4 + a))  (subterm) changed";
  84.300  
  84.301  val SOME (isa_str, eval_fn) = LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "DIVIDE");
  84.302  
  84.303 -val t = (Thm.term_of o the o (TermC.parse thy)) "-4 / -2";
  84.304 +val t = @{term "-4 / - 2 :: real"};
  84.305  val SOME (str, term) = get_pair thy isa_str eval_fn t;
  84.306 -if str =  "#divide_e-4_-2" andalso UnparseC.term term = "-4 / -2 = 2"
  84.307 -then () else error "get_pair  -4 / -2   changed";
  84.308 +if str = "#divide_e~4_~2" andalso UnparseC.term term = "- 4 / - 2 = 2"
  84.309 +then () else error "get_pair  -4 / - 2   changed";
  84.310  
  84.311  val SOME (isa_str, eval_fn) = LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "POWER");
  84.312  
  84.313 -val t = (Thm.term_of o the o (TermC.parse thy)) "2 \<up> 3";
  84.314 +val t = @{term "2 \<up> 3 :: real"};
  84.315  val SOME (str, term) = get_pair thy isa_str eval_fn t;
  84.316  if str =  "#: 2 \<up> 3 = 8" andalso UnparseC.term term = "2 \<up> 3 = 8"
  84.317  then () else error "get_pair  2 \<up> 3   changed";
  84.318 @@ -368,18 +410,17 @@
  84.319  "----------- fun adhoc_thm: examples -----------------------------------------------------------";
  84.320  (*--------------------------------------------------------------------vvvvvvvvvv*)
  84.321  val SOME (isa_str, eval_fn) = LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "is_const");
  84.322 -val SOME t = parseNEW @{context} "9 is_const";
  84.323 +val t = @{term "9 is_const"};
  84.324  val SOME (str, thm) = adhoc_thm thy (isa_str, eval_fn) t;
  84.325  if str = "#is_const_9_" andalso ThmC_Def.string_of_thm thm = "(9 is_const) = True"
  84.326  then () else error "adhoc_thm  9 is_const  changed";
  84.327  
  84.328 -
  84.329  case assoc_calc thy \<^const_name>\<open>less\<close> of
  84.330    "le" => () | _ => error "Orderings.ord_class.less <-> le changed";
  84.331 -(*--------------------------------------------------------------------vvvvvvvvvv*)
  84.332  val SOME (isa_str, eval_fn) = LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "le");
  84.333 +if isa_str = "Orderings.ord_class.less" then () else error "adhoc_thm (4 < 4) = False CHANGED";
  84.334  
  84.335 -val SOME t = parseNEW @{context} "4 < 4";
  84.336 +val t = @{term "4 < (4 :: real)"};
  84.337  val SOME (str, thm) = adhoc_thm thy (isa_str, eval_fn) t;
  84.338  if str = "#less_4_4" andalso ThmC_Def.string_of_thm thm = "(4 < 4) = False"
  84.339  then () else error "adhoc_thm  4 < 4  changed";
  84.340 @@ -388,37 +429,53 @@
  84.341  case adhoc_thm thy (isa_str, eval_fn) t of
  84.342  NONE => () | _ => error "adhoc_thm  a < 4  does NOT result in NONE";
  84.343  
  84.344 -
  84.345 -(*--------------------------------------------------------------------vvvvvvvvvv*)
  84.346  val SOME (isa_str, eval_fn) = LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "PLUS");
  84.347 -val SOME t = parseNEW @{context} "1 + 2";
  84.348 +val SOME t = parseNEW @{context} "1 + (2::real)";
  84.349  val SOME (str, thm) = adhoc_thm thy (isa_str, eval_fn) t;
  84.350  if str = "#: 1 + 2 = 3" andalso ThmC_Def.string_of_thm thm = "1 + 2 = 3"
  84.351  then () else error "adhoc_thm  1 + 2  changed";
  84.352  
  84.353 -(*--------------------------------------------------------------------vvvvvvvvvv*)
  84.354  val SOME (isa_str, eval_fn) = LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "DIVIDE");
  84.355 -val SOME t = parseNEW @{context} "6 / -8";
  84.356 +val t = @{term "6 / -8 :: real"};
  84.357  val SOME (str, thm) = adhoc_thm thy (isa_str, eval_fn) t;
  84.358 -if str = "#divide_e6_-8" andalso ThmC_Def.string_of_thm thm = "6 / -8 = -3 / 4"
  84.359 -then () else error "adhoc_thm  1 + 2  changed";
  84.360 -
  84.361 +if str = "#divide_e6_~8" andalso ThmC_Def.string_of_thm thm = "6 / - 8 = - 3 / 4"
  84.362 +then () else error "adhoc_thm  6 / -8 = - 3 / 4  changed";
  84.363  
  84.364  case assoc_calc thy "Prog_Expr.ident" of
  84.365    "ident" => () | _ => error "Prog_Expr.ident <-> ident  changed";
  84.366 -(*--------------------------------------------------------------------vvvvvvvvvv*)
  84.367  val SOME (isa_str, eval_fn) = LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "ident");
  84.368  
  84.369 -val SOME t = parseNEW @{context} "3 =!= 3";
  84.370 +val t = @{term "3 =!= (3 :: real)"};
  84.371  val SOME (str, thm) = adhoc_thm thy (isa_str, eval_fn) t;
  84.372  if str = "#ident_(3)_(3)" andalso ThmC_Def.string_of_thm thm = "(3 =!= 3) = True"
  84.373  then () else error "adhoc_thm  (3 =!= 3)  changed";
  84.374  
  84.375 -val SOME t = parseNEW @{context} "\<not> (4 + (4 * x + x ^ 2) =!= 0)";
  84.376 +val t = @{term "\<not> ((4 :: real) + (4 * x + x \<up> 2) =!= 0)"};
  84.377  val SOME (str, thm) = adhoc_thm thy (isa_str, eval_fn) t;
  84.378 -if str = "#ident_(4 + (4 * x + x ^ 2))_(0)" andalso ThmC_Def.string_of_thm thm = "(4 + (4 * x + x ^ 2) =!= 0) = False"
  84.379 +if str = "#ident_(4 + (4 * x + x \<up> 2))_(0)" andalso ThmC_Def.string_of_thm thm = "(4 + (4 * x + x \<up> 2) =!= 0) = False"
  84.380  then () else error "adhoc_thm  (\<not> (4 + (4 * x + x ^ 2) =!= 0))  changed";
  84.381  
  84.382 +"----------- fun adhoc_thm \<longrightarrow> exception TYPE --------------------------------------------------";
  84.383 +"----------- fun adhoc_thm \<longrightarrow> exception TYPE --------------------------------------------------";
  84.384 +"----------- fun adhoc_thm \<longrightarrow> exception TYPE --------------------------------------------------";
  84.385 +val t = TermC.str2term "sqrt 4";
  84.386 +
  84.387 +(* TOODOO.1: exception TYPE raised by Skip_Proof.make_thm * )
  84.388 +  exception TYPE raised (line 169 of "consts.ML"): Illegal type
  84.389 +   for constant "HOL.eq" :: real \<Rightarrow> (num \<Rightarrow> real) \<Rightarrow> bool (**)
  84.390 +      Eval.adhoc_thm (ThyC.get_theory "Isac_Knowledge") ("NthRoot.sqrt", eval_sqrt "#sqrt_") t
  84.391 +( **)
  84.392 +"~~~~~ fun adhoc_thm , args:"; val (thy, (op_, eval_fn), ct) =
  84.393 +  ((ThyC.get_theory "Isac_Knowledge"),
  84.394 +    ("NthRoot.sqrt", eval_sqrt "#sqrt_": string -> term -> theory -> (string * term) option), t);
  84.395 +val SOME (thmid, t) =
  84.396 +  (*case*) get_pair thy op_ eval_fn ct (*of*);
  84.397 +(** )
  84.398 +  exception TYPE raised (line 169 of "consts.ML"): Illegal type
  84.399 +   for constant "HOL.eq" :: real \<Rightarrow> (num \<Rightarrow> real) \<Rightarrow> bool (**)
  84.400 +      Skip_Proof.make_thm thy t
  84.401 +( **)
  84.402 +
  84.403  "----------- fun power -------------------------------------------------------------------------";
  84.404  "----------- fun power -------------------------------------------------------------------------";
  84.405  "----------- fun power -------------------------------------------------------------------------";
    85.1 --- a/test/Tools/isac/ProgLang/listC.sml	Mon Jun 21 22:08:01 2021 +0200
    85.2 +++ b/test/Tools/isac/ProgLang/listC.sml	Sun Jul 18 18:15:27 2021 +0200
    85.3 @@ -7,6 +7,7 @@
    85.4  "-----------------------------------------------------------------------------";
    85.5  "table of contents -----------------------------------------------------------";
    85.6  "-----------------------------------------------------------------------------";
    85.7 +"----------- correct list_erls -----------------------------------------------------------------";
    85.8  "----------- check 'type xlist' {||1, 2, 3||} --------------------------------";
    85.9  "--------------------- NTH ---------------------------------------------------";
   85.10  "--------------------- Length ------------------------------------------------";
   85.11 @@ -14,6 +15,10 @@
   85.12  "-----------------------------------------------------------------------------";
   85.13  "-----------------------------------------------------------------------------";
   85.14  
   85.15 +"----------- correct list_erls -----------------------------------------------------------------";
   85.16 +"----------- correct list_erls -----------------------------------------------------------------";
   85.17 +"----------- correct list_erls -----------------------------------------------------------------";
   85.18 +
   85.19  "----------- check 'type xlist' {||1, 2, 3||} --------------------------------";
   85.20  "----------- check 'type xlist' {||1, 2, 3||} --------------------------------";
   85.21  "----------- check 'type xlist' {||1, 2, 3||} --------------------------------";
   85.22 @@ -50,22 +55,26 @@
   85.23  else error "NTH 1 [a,b,c,d,e] = a ..changed";
   85.24  
   85.25  val t = TermC.str2term "NTH 3 [a,b,c,d,e]";
   85.26 -val Const ("ListC.NTH", _) $ Free ("3", _) $ (Const (\<^const_name>\<open>Cons\<close>, _) $ Free ("a", _) $
   85.27 -  (Const (\<^const_name>\<open>Cons\<close>, _) $ Free ("b", _) $ 
   85.28 -    (Const _ $ Free _ $ (Const _ $ Free _ $ (Const _ $ Free _ $ Const _))))) = t;
   85.29 -TermC.atomty t;
   85.30 +case TermC.str2term "NTH 3 [a,b,c,d,e]" of
   85.31 + Const ("ListC.NTH", _) $ (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit1", _) $ Const ("Num.num.One", _))) $
   85.32 +     (Const ("List.list.Cons", _) $ Free ("a", _) $
   85.33 +       (Const ("List.list.Cons", _) $ Free ("b", _) $
   85.34 +         (Const ("List.list.Cons", _) $ Free ("c", _) $
   85.35 +           (Const ("List.list.Cons", _) $ Free ("d", _) $
   85.36 +             (Const ("List.list.Cons", _) $ Free ("e", _) $ Const ("List.list.Nil", _)))))) => ()
   85.37 +| _ => error "ListC.NTH changed";
   85.38  val thm = (Thm.prop_of o ThmC.numerals_to_Free) @{thm NTH_CONS};
   85.39  TermC.atomty thm;
   85.40  val SOME (t', _) = rewrite_ thy dummy_ord prog_expr false (ThmC.numerals_to_Free @{thm NTH_CONS}) t;
   85.41 -if UnparseC.term t' = "NTH (3 + -1) [b, c, d, e]" then () 
   85.42 +if UnparseC.term t' = "NTH (3 + - 1) [b, c, d, e]" then () 
   85.43  else error "NTH 3 [a,b,c,d,e] = NTH (3 + - 1) [b, c, d, e] ..changed";
   85.44  
   85.45  (* now the argument "(3 + - 1)" etc needs to be evaluated in the assumption of NTH_CONS *)
   85.46  val t = TermC.str2term "NTH 3 [a,b,c,d,e]";
   85.47  TermC.atomty t;
   85.48 -Rewrite.trace_on := false;
   85.49 +Rewrite.trace_on := false; (*true false*)
   85.50  val SOME (t', _) = rewrite_set_ thy false prog_expr t;
   85.51 -Rewrite.trace_on := false;
   85.52 +Rewrite.trace_on := false; (*true false*)
   85.53  if UnparseC.term t' = "c" then () 
   85.54  else error "NTH 3 [a,b,c,d,e] = c ..changed";
   85.55  
   85.56 @@ -95,6 +104,7 @@
   85.57  
   85.58  val t = TermC.str2term "Length [1, 1, 1]";
   85.59  val t = eval_prog_expr thy prog_expr t;
   85.60 -case t of Free ("3", _) => () 
   85.61 +case t of 
   85.62 +  Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit1", _) $ Const ("Num.num.One", _)) => () 
   85.63  | _ => error "Length [1, 1, 1] = 3  ..eval_prog_expr changed";
   85.64  
    86.1 --- a/test/Tools/isac/ProgLang/prog_expr.sml	Mon Jun 21 22:08:01 2021 +0200
    86.2 +++ b/test/Tools/isac/ProgLang/prog_expr.sml	Sun Jul 18 18:15:27 2021 +0200
    86.3 @@ -7,6 +7,11 @@
    86.4  "-----------------------------------------------------------------------------------------------";
    86.5  "table of contents -----------------------------------------------------------------------------";
    86.6  "-----------------------------------------------------------------------------------------------";
    86.7 +"-------- fun eval_is_atom ---------------------------------------------------------------------";
    86.8 +"-------- fun eval_is_even ---------------------------------------------------------------------";
    86.9 +"-------- fun eval_const -----------------------------------------------------------------------";
   86.10 +"-------- fun eval_cancel ----------------------------------------------------------------------";
   86.11 +"-------- fun eval_equ -------------------------------------------------------------------------";
   86.12  "-------- fun eval_equal for x \<noteq> 0: \<rightarrow> indetermined, NOT \<rightarrow> 'True' -----------------------------";
   86.13  "-------- occurs_in ----------------------------------------------------------------------------";
   86.14  "-------- fun eval_occurs_in -------------------------------------------------------------------";
   86.15 @@ -14,7 +19,7 @@
   86.16  "-------- fun eval_sameFunId -------------------------------------------------------------------";
   86.17  "-------- fun eval_filter_sameFunId ------------------------------------------------------------";
   86.18  "-------- fun eval_boollist2sum ----------------------------------------------------------------";
   86.19 -"-------- fun eval_binop -----------------------------------------------------------------------";
   86.20 +"-------- REBUILD fun eval_binop FOR Isabelle's NUMERALS ---------------------------------------";
   86.21  "-------- fun matchsub -------------------------------------------------------------------------";
   86.22  "-------- fun or2list: HOL.disj HOL.eq HOL.True HOL.False etc ----------------------------------";
   86.23  "-----------------------------------------------------------------------------------------------";
   86.24 @@ -22,6 +27,161 @@
   86.25  "-----------------------------------------------------------------------------------------------";
   86.26  
   86.27  
   86.28 +"-------- fun eval_is_atom ---------------------------------------------------------------------";
   86.29 +"-------- fun eval_is_atom ---------------------------------------------------------------------";
   86.30 +"-------- fun eval_is_atom ---------------------------------------------------------------------";
   86.31 +if is_atom   @{term  0} then () else error "is_atom 0 CHANGED";
   86.32 +val eval_t = @{term "0 is_atom"};
   86.33 +case Prog_Expr.eval_is_atom "#is_atom_" "Prog_Expr.is_atom" eval_t () of
   86.34 +  SOME ("#is_atom_0_", _) => ()
   86.35 +| _ => error "eval_is_atom 0 CHANGED";
   86.36 +
   86.37 +if is_atom   @{term  1} then () else error "is_atom 1 CHANGED";
   86.38 +val eval_t = @{term "1 is_atom"};
   86.39 +case Prog_Expr.eval_is_atom "#is_atom_" "Prog_Expr.is_atom" eval_t () of
   86.40 +  SOME ("#is_atom_1_", _) => ()
   86.41 +| _ => error "eval_is_atom 1 CHANGED";
   86.42 +
   86.43 +if is_atom   @{term  123} then () else error "is_atom 123 CHANGED";
   86.44 +val eval_t = @{term "123 is_atom"};
   86.45 +case Prog_Expr.eval_is_atom "#is_atom_" "Prog_Expr.is_atom" eval_t () of
   86.46 +  SOME ("#is_atom_123_", _) => ()
   86.47 +| _ => error "eval_is_atom 123 CHANGED";
   86.48 +
   86.49 +if is_atom   @{term  abc} then () else error "is_atom abc CHANGED";
   86.50 +val eval_t = @{term "abc is_atom"};
   86.51 +case Prog_Expr.eval_is_atom "#is_atom_" "Prog_Expr.is_atom" eval_t () of
   86.52 +  SOME ("#is_atom_abc_", _) => ()
   86.53 +| _ => error "eval_is_atom abc CHANGED";
   86.54 +
   86.55 +
   86.56 +"-------- fun eval_is_even ---------------------------------------------------------------------";
   86.57 +"-------- fun eval_is_even ---------------------------------------------------------------------";
   86.58 +"-------- fun eval_is_even ---------------------------------------------------------------------";
   86.59 +val t = TermC.str2term "2 is_even";
   86.60 +           eval_is_even "aaa" "Prog_Expr.is_even" t "ccc";
   86.61 +"~~~~~ fun eval_is_even , args:"; val ((thmid:string), "Prog_Expr.is_even", (t as (Const _ $ arg)), _) =
   86.62 +  ("aaa", "Prog_Expr.is_even", t, "ccc");
   86.63 +    (*if*) TermC.is_num arg (*then*);
   86.64 +        val i = arg |> HOLogic.dest_number |> snd;
   86.65 +	      (*if*) even i (*then*);
   86.66 +val SOME ("aaa1_", t') =
   86.67 +    SOME (TermC.mk_thmid thmid (string_of_int n) "", 
   86.68 +				  HOLogic.Trueprop $ (TermC.mk_equality (t, @{term True})));
   86.69 +if UnparseC.term t' = "(2 is_even) = True" then () else error "(2 is_even) = True  CHANGED";
   86.70 +
   86.71 +
   86.72 +val t = TermC.str2term "3 is_even";
   86.73 +case eval_is_even "aaa" "Prog_Expr.is_even" t "ccc" of
   86.74 +  SOME (str, t') => 
   86.75 +    if str = "aaa_" andalso UnparseC.term t' = "(3 is_even) = False" then ()
   86.76 +    else error "eval_is_even (3 is_even) CHANGED 1"
   86.77 +| NONE => error "eval_is_even (3 is_even) CHANGED 2";
   86.78 +
   86.79 +val t = TermC.str2term "a ::real";
   86.80 +val NONE =
   86.81 +           eval_is_even "aaa" "Prog_Expr.is_even" t "ccc";
   86.82 +case eval_is_even "aaa" "Prog_Expr.is_even" t "ccc" of
   86.83 +  SOME _ => error "eval_is_even (a is_even) CHANGED"
   86.84 +| NONE => ();
   86.85 +
   86.86 +
   86.87 +"-------- fun eval_const -----------------------------------------------------------------------";
   86.88 +"-------- fun eval_const -----------------------------------------------------------------------";
   86.89 +"-------- fun eval_const -----------------------------------------------------------------------";
   86.90 +val t = (Thm.term_of o the o (TermC.parse @{theory Test})) "2 is_const";
   86.91 +case rewrite_set_ @{theory Test} false tval_rls t of
   86.92 +  SOME (Const ("HOL.True", _), []) => ()
   86.93 +| _ => error "2 is_const CHANGED";
   86.94 +
   86.95 +val t = TermC.str2term "2 * x is_const";
   86.96 +val SOME (str, t') = eval_const "" "" t (@{theory "Isac_Knowledge"});
   86.97 +if UnparseC.term t' = "(2 * x is_const) = False" then ()
   86.98 +else error "(2 * x is_const) = False CHANGED";
   86.99 +
  86.100 +val t = TermC.str2term "- 2 is_const";
  86.101 +val SOME (str, t') = eval_const "" "" t (@{theory "Isac_Knowledge"});
  86.102 +if UnparseC.term t' = "(- 2 is_const) = True" then ()
  86.103 +else error "(- 2 is_const) = False CHANGED";
  86.104 +
  86.105 +val t = TermC.str2term "- 1 is_const";
  86.106 +val SOME (str, t') = eval_const "" "" t (@{theory "Isac_Knowledge"});
  86.107 +if UnparseC.term t' = "(- 1 is_const) = True" then ()
  86.108 +else error "(- 1 is_const) = False CHANGED";
  86.109 +
  86.110 +val t = TermC.str2term "0 is_const";
  86.111 +val SOME (str, t') = eval_const "" "" t (@{theory "Isac_Knowledge"});
  86.112 +if UnparseC.term t' = "(0 is_const) = True" then ()
  86.113 +else error "(0 is_const) = False CHANGED";
  86.114 +
  86.115 +val t = TermC.str2term "AA is_const";
  86.116 +val SOME (str, t') = eval_const "" "" t (@{theory "Isac_Knowledge"});
  86.117 +if UnparseC.term t' = "(AA is_const) = False" then ()
  86.118 +else error "(0 is_const) = False CHANGED";
  86.119 +
  86.120 +
  86.121 +"-------- fun eval_cancel ----------------------------------------------------------------------";
  86.122 +"-------- fun eval_cancel ----------------------------------------------------------------------";
  86.123 +"-------- fun eval_cancel ----------------------------------------------------------------------";
  86.124 +val t = @{term  "3 / 2 :: real"};
  86.125 +val NONE = eval_cancel "cancel_"  "Rings.divide_class.divide" t ""
  86.126 +
  86.127 +val t = @{term  "6 / 4 :: real"};
  86.128 +case eval_cancel "cancel_" "Rings.divide_class.divide" t "" of
  86.129 +  SOME ("cancel_6_4", t') =>
  86.130 +    if UnparseC.term t'  = "6 / 4 = 3 / 2" then ()
  86.131 +    else error "eval_cancel  - 6 / 4 = - 3 / 2  CHANGED 1"
  86.132 +| _ => error "eval_cancel  - 6 / 4 = - 3 / 2  CHANGED 2";
  86.133 +
  86.134 +val t = @{term  "- 6 / 4 :: real"};
  86.135 +case eval_cancel "cancel_"  "Rings.divide_class.divide" t "" of
  86.136 +  SOME ("cancel_~6_4", t') =>
  86.137 +    if UnparseC.term t'  = "- 6 / 4 = - 3 / 2" then ()
  86.138 +    else error "eval_cancel  - 6 / 4 = - 3 / 2  CHANGED 1"
  86.139 +| _ => error "eval_cancel  - 6 / 4 = - 3 / 2  CHANGED 2";
  86.140 +
  86.141 +val t = @{term  "6 / - 4 :: real"};
  86.142 +case eval_cancel "cancel_"  "Rings.divide_class.divide" t "" of
  86.143 +  SOME ("cancel_6_~4", t') =>
  86.144 +    if UnparseC.term t' = "6 / - 4 = - 3 / 2" then ()
  86.145 +    else error "eval_cancel  6 / - 4 = - 3 / 2  CHANGED 1"
  86.146 +| _ => error "eval_cancel  6 / - 4 = - 3 / 2  CHANGED 2";
  86.147 +
  86.148 +val t = @{term  "- 6 /- 4 :: real"};
  86.149 +case eval_cancel "cancel_"  "Rings.divide_class.divide" t "" of
  86.150 +  SOME ("cancel_~6_~4", t') =>
  86.151 +    if UnparseC.term t' = "- 6 / - 4 = 3 / 2" then ()
  86.152 +    else error "eval_cancel  - 6 / - 4 = 3 / 2  CHANGED 1"
  86.153 +| _ => error "eval_cancel  - 6 / - 4 = 3 / 2  CHANGED 2";
  86.154 +
  86.155 +val t = @{term  "- (6 / 4) :: real"};
  86.156 +val NONE = eval_cancel "adhoc_thm_cancel"  "Rings.divide_class.divide" t "";
  86.157 +
  86.158 +
  86.159 +"-------- fun eval_equ -------------------------------------------------------------------------";
  86.160 +"-------- fun eval_equ -------------------------------------------------------------------------";
  86.161 +"-------- fun eval_equ -------------------------------------------------------------------------";
  86.162 +eval_equ: string -> string -> term -> 'a -> (string * term) option;
  86.163 +
  86.164 +case eval_equ "#less_" "Orderings.ord_class.less" @{term "1 < (2::real)"} "" of
  86.165 +SOME
  86.166 +    ("#less_1_2",
  86.167 +     Const ("HOL.Trueprop", _) $
  86.168 +       (Const ("HOL.eq", _) $
  86.169 +         (Const ("Orderings.ord_class.less", _) $ Const ("Groups.one_class.one", _) $
  86.170 +           (Const ("Num.numeral_class.numeral", _) $ (Const ("Num.num.Bit0", _) $ Const ("Num.num.One", _)))) $
  86.171 +         Const ("HOL.True", _))) => ()
  86.172 +| _ => error "eval_equ   1 < 2   CHANGED";
  86.173 +
  86.174 +case eval_equ "#less_" "Orderings.ord_class.less" @{term "1 < (1::real)"} "" of
  86.175 +SOME
  86.176 +    ("#less_1_1",
  86.177 +     Const ("HOL.Trueprop", _) $
  86.178 +       (Const ("HOL.eq", _) $ (Const ("Orderings.ord_class.less", _) $ Const ("Groups.one_class.one", _) $ Const ("Groups.one_class.one", _)) $
  86.179 +         Const ("HOL.False", _))) => ()
  86.180 +| _ => error "eval_equ   1 < 1   CHANGED";
  86.181 +
  86.182 +
  86.183  "-------- fun eval_equal for x \<noteq> 0: \<rightarrow> indetermined, NOT \<rightarrow> 'True' -----------------------------";
  86.184  "-------- fun eval_equal for x \<noteq> 0: \<rightarrow> indetermined, NOT \<rightarrow> 'True' -----------------------------";
  86.185  "-------- fun eval_equal for x \<noteq> 0: \<rightarrow> indetermined, NOT \<rightarrow> 'True' -----------------------------";
  86.186 @@ -48,12 +208,7 @@
  86.187  "-------- occurs_in ----------------------------------------------------------------------------";
  86.188  "-------- occurs_in ----------------------------------------------------------------------------";
  86.189  "-------- occurs_in ----------------------------------------------------------------------------";
  86.190 -(*=========================================================================*)
  86.191 -fun str2t str = (Thm.term_of o the o (TermC.parse thy)) str;
  86.192 -fun term2s t = UnparseC.term_in_thy thy t;
  86.193 -(*=========================================================================*)
  86.194 -
  86.195 -val t = str2t "x";
  86.196 +val t = @{term "x::real"};
  86.197  if occurs_in t t then "OK" else error "occurs_in x x -> f ..changed";
  86.198  
  86.199  val t = TermC.str2term "x occurs_in x";
  86.200 @@ -62,19 +217,19 @@
  86.201  else error "x occurs_in x = True ..changed";
  86.202  
  86.203  "------- some_occur_in";
  86.204 -some_occur_in [str2t"c",str2t"c_2"] (str2t"a + b + c");
  86.205 -val t = str2t "some_of [c, c_2, c_3, c_4] occur_in \
  86.206 -		 \-1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
  86.207 +if some_occur_in [@{term "c::real"}, @{term "c_2::real"}] @{term "a + b + c::real"} then ()
  86.208 +else error "";
  86.209 +
  86.210 +val t = @{term "some_of [c, c_2, c_3, c_4] occur_in -1 * q_0 * L \<up> 2 / 2 + L * c + c_2"};
  86.211 +val SOME (str, t') = eval_some_occur_in 0 "Prog_Expr.some_occur_in" t 0;
  86.212 +if UnparseC.term t' =
  86.213 +   "some_of [c, c_2, c_3,\n         c_4] occur_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2 =\nTrue" then ()
  86.214 +else error "atools.sml: some_occur_in true";
  86.215 +
  86.216 +val t = @{term "some_of [c_3, c_4] occur_in -1 * q_0 * L \<up> 2 / 2 + L * c + c_2"};
  86.217  val SOME (str,t') = eval_some_occur_in 0 "Prog_Expr.some_occur_in" t 0;
  86.218  if UnparseC.term t' =
  86.219 -   "some_of [c, c_2, c_3, c_4] occur_in -1 * q_0 * L \<up> 2 / 2 + L * c + c_2 =\nTrue" then ()
  86.220 -else error "atools.sml: some_occur_in true";
  86.221 -
  86.222 -val t = str2t "some_of [c_3, c_4] occur_in \
  86.223 -		 \-1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
  86.224 -val SOME (str,t') = eval_some_occur_in 0 "Prog_Expr.some_occur_in" t 0;
  86.225 -if UnparseC.term t' =
  86.226 -   "some_of [c_3, c_4] occur_in -1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = False" then ()
  86.227 +  "some_of [c_3, c_4] occur_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = False" then ()
  86.228  else error "atools.sml: some_occur_in false";
  86.229  
  86.230  
  86.231 @@ -174,35 +329,34 @@
  86.232  "---------fun eval_sameFunId -------------------------------------------------------------------";
  86.233  "---------fun eval_sameFunId -------------------------------------------------------------------";
  86.234  "---------fun eval_sameFunId -------------------------------------------------------------------";
  86.235 -val t = str2t "M_b L"; TermC.atomty t;
  86.236 -val t as f1 $ _ = str2t "M_b L";
  86.237 -val t as Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (f2 $ _) $ _ = str2t "M_b x = c + L*x";
  86.238 +val t = @{term "M_b L"}; TermC.atomty t;
  86.239 +val t as f1 $ _ = @{term "M_b L"};
  86.240 +val t as Const ("HOL.eq", _) $ (f2 $ _) $ _ = @{term "M_b x = c + L*x"};
  86.241  f1 = f2 (*true*);
  86.242  val (p as Const ("Prog_Expr.sameFunId",_) $ 
  86.243  			(f1 $ _) $ 
  86.244  			(Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (f2 $ _) $ _)) = 
  86.245 -    str2t "sameFunId (M_b L) (M_b x = c + L*x)";
  86.246 +    @{term "sameFunId (M_b L) (M_b x = c + L*x)"};
  86.247  f1 = f2 (*true*);
  86.248  eval_sameFunId "" "Prog_Expr.sameFunId" 
  86.249 -		 (str2t "sameFunId (M_b L) (M_b x = c + L*x)")""(*true*);
  86.250 +		 (@{term "sameFunId (M_b L) (M_b x = c + L*x)"})""(*true*);
  86.251  eval_sameFunId "" "Prog_Expr.sameFunId" 
  86.252 -		 (str2t "sameFunId (M_b L) ( y' x = c + L*x)")""(*false*);
  86.253 +		 (@{term  "sameFunId (M_b L) ( y' x = c + L*x)"})""(*false*);
  86.254  eval_sameFunId "" "Prog_Expr.sameFunId" 
  86.255 -		 (str2t "sameFunId (M_b L) (  y x = c + L*x)")""(*false*);
  86.256 +		 (@{term  "sameFunId (M_b L) (  y x = c + L*x)"})""(*false*);
  86.257  eval_sameFunId "" "Prog_Expr.sameFunId" 
  86.258 -		 (str2t "sameFunId (  y L) (M_b x = c + L*x)")""(*false*);
  86.259 +		 (@{term  "sameFunId (  y L) (M_b x = c + L*x)"})""(*false*);
  86.260  eval_sameFunId "" "Prog_Expr.sameFunId" 
  86.261 -		 (str2t "sameFunId (  y L) (  y x = c + L*x)")""(*true*);
  86.262 +		 (@{term  "sameFunId (  y L) (  y x = c + L*x)"})""(*true*);
  86.263  
  86.264  
  86.265  "---------fun eval_filter_sameFunId ------------------------------------------------------------";
  86.266  "---------fun eval_filter_sameFunId ------------------------------------------------------------";
  86.267  "---------fun eval_filter_sameFunId ------------------------------------------------------------";
  86.268 -val flhs as (fid $ _) = str2t "y' L";
  86.269 -val fs = str2t "[M_b x = c + L*x, y' x = c + L*x, y x = c + L*x]";
  86.270 +val flhs as (fid $ _) = @{term "y' L"};
  86.271 +val fs = @{term "[M_b x = c + L*x, y' x = c + L*x, y x = c + L*x]"};
  86.272  val (p as Const ("Prog_Expr.filter_sameFunId",_) $ (fid $ _) $ fs) = 
  86.273 -    str2t "filter_sameFunId (y' L) \
  86.274 -	     \[M_b x = c + L*x, y' x = c + L*x, y x = c + L*x]";
  86.275 +    @{term "filter_sameFunId (y' L) [M_b x = c + L*x, y' x = c + L*x, y x = c + L*x]"};
  86.276  val SOME (str, es) = eval_filter_sameFunId "" "Prog_Expr.filter_sameFunId" p "";
  86.277  if UnparseC.term es = "(filter_sameFunId y' L [M_b x = c + L * x, y' x = c + L * x,\n                        y x = c + L * x]) =\n[y' x = c + L * x]" then ()
  86.278  else error "atools.slm diff.behav. in filter_sameFunId";
  86.279 @@ -211,54 +365,62 @@
  86.280  "---------fun eval_boollist2sum ----------------------------------------------------------------";
  86.281  "---------fun eval_boollist2sum ----------------------------------------------------------------";
  86.282  "---------fun eval_boollist2sum ----------------------------------------------------------------";
  86.283 -fun lhs (Const (\<^const_name>\<open>HOL.eq\<close>,_) $ l $ _) = l
  86.284 +fun lhs (Const ("HOL.eq",_) $ l $ _) = l
  86.285    | lhs t = error("lhs called with (" ^ UnparseC.term t ^ ")");
  86.286  "----------- \<up> redefined due to overwritten identifier -----------";
  86.287 -val u_ = str2t "[]";
  86.288 -val u_ = str2t "[b1 = k - 2*q]";
  86.289 -val u_ = str2t "[b1 = k - 2*q, b2 = k - 2*q, b3 = k - 2*q, b4 = k - 2*q]";
  86.290 +val u_ = @{term "[]"};
  86.291 +val u_ = @{term "[b1 = k - 2*q]"};
  86.292 +val u_ = @{term "[b1 = k - 2*q, b2 = k - 2*q, b3 = k - 2*q, b4 = k - 2*q]"};
  86.293  val ut_ = isalist2list u_;
  86.294  val sum_ = map lhs ut_;
  86.295  val t = list2sum sum_;
  86.296  UnparseC.term t;
  86.297  
  86.298 -val t = str2t "boollist2sum [b1 = k - 2*q, b2 = k - 2*q, b3 = k - 2*q, b4 = k - 2*q]";
  86.299 -
  86.300 -val p as Const ("Prog_Expr.boollist2sum", _) $ (Const (\<^const_name>\<open>Cons\<close>, _) $ _ $ _) = t;
  86.301 -
  86.302 +val t = @{term "boollist2sum [b1 = k - 2*(q::real), b2 = k - 2*q, b3 = k - 2*q, b4 = k - 2*q]"};
  86.303 +case t of
  86.304 +Const ("Prog_Expr.boollist2sum", _) $
  86.305 +     (Const ("List.list.Cons", _) $
  86.306 +       (Const ("HOL.eq", _) $ Free ("b1", _) $ _ ) $
  86.307 +       (Const ("List.list.Cons", _) $
  86.308 +         (Const ("HOL.eq", _) $ Free ("b2", _) $ _ ) $
  86.309 +         (Const ("List.list.Cons", _) $
  86.310 +           (Const ("HOL.eq", _) $ Free ("b3", _) $ _ ) $
  86.311 +           (Const ("List.list.Cons", _) $
  86.312 +             (Const ("HOL.eq", _) $ Free ("b4", _) $ _ ) $
  86.313 +             Const ("List.list.Nil", _))))) => ()
  86.314 +| _ => error "boollist2sum CHANGED";
  86.315  val SOME (str, pred) = eval_boollist2sum "" "Prog_Expr.boollist2sum" t "";
  86.316  if UnparseC.term pred = "boollist2sum\n [b1 = k - 2 * q, b2 = k - 2 * q, b3 = k - 2 * q, b4 = k - 2 * q] =\nb1 + b2 + b3 + b4" then () 
  86.317  else error "atools.sml diff.behav. in eval_boollist2sum";
  86.318  
  86.319 -Rewrite.trace_on := false;
  86.320 +Rewrite.trace_on := false; (*true false*)
  86.321  val srls_ = Rule_Set.append_rules "srls_..Berechnung-erstSymbolisch" Rule_Set.empty 
  86.322  		      [Eval ("Prog_Expr.boollist2sum", eval_boollist2sum "")];
  86.323 -val t = str2t 
  86.324 -       "boollist2sum [b1 = k - 2*q, b2 = k - 2*q, b3 = k - 2*q, b4 = k - 2*q]";
  86.325 -case rewrite_set_ thy false srls_ t of SOME _ => ()
  86.326 +val t = @{term "boollist2sum [b1 = k - 2*(q::real), b2 = k - 2*q, b3 = k - 2*q, b4 = k - 2*q]"};
  86.327 +case rewrite_set_ @{theory} false srls_ t of SOME _ => ()
  86.328  | _ => error "atools.sml diff.rewrite boollist2sum";
  86.329 -Rewrite.trace_on := false;
  86.330 +Rewrite.trace_on := false; (*true false*)
  86.331  
  86.332  
  86.333 -"---------fun eval_binop -----------------------------------------------------------------------";
  86.334 -"---------fun eval_binop -----------------------------------------------------------------------";
  86.335 -"---------fun eval_binop -----------------------------------------------------------------------";
  86.336 +"-------- REBUILD fun eval_binop FOR Isabelle's NUMERALS ---------------------------------------";
  86.337 +"-------- REBUILD fun eval_binop FOR Isabelle's NUMERALS ---------------------------------------";
  86.338 +"-------- REBUILD fun eval_binop FOR Isabelle's NUMERALS ---------------------------------------";
  86.339  val (op_, ef) = the (LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "TIMES"));
  86.340  val t = (Thm.term_of o the o (TermC.parse thy)) "2 * 3";
  86.341  (*val SOME (thmid,t') = *)get_pair thy op_ ef t;
  86.342  ;
  86.343  "~~~~~ fun get_pair, args:"; val (thy, op_, ef, (t as (Const (op0,_) $ t1 $ t2))) =
  86.344    (thy, op_, ef, t);
  86.345 -op_ = op0 = true;
  86.346 -ef op_ t thy
  86.347 -;
  86.348 -"~~~~~ fun eval_binop, args:"; val ((thmid : string), (op_: string), 
  86.349 -      (t as (Const (op0, t0) $ t1 $ t2)), _) = ("#mult_", op_, t, thy); (* binary . n1.(n2.v) *)
  86.350 -val (SOME n1, SOME n2) = (numeral t1, numeral t2)
  86.351 -          val (_, _, Trange) = TermC.dest_binop_typ t0;
  86.352 -          val res = calcul op0 n1 n2;
  86.353 -          val rhs = term_of_float Trange res;
  86.354 -          val prop = HOLogic.Trueprop $ (mk_equality (t, rhs));
  86.355 +op_ = op0 = true;val (op_, ef) = the (LibraryC.assoc (KEStore_Elems.get_calcs @{theory}, "TIMES"));
  86.356 +val t = (Thm.term_of o the o (TermC.parse thy)) "2 * 3";
  86.357 +
  86.358 +           ef op_ t thy;
  86.359 +"~~~~~ fun eval_binop , args:"; val ((thmid : string), (op_: string), 
  86.360 +      (t as (Const (op0, _) $ t1 $ t2)), _) =
  86.361 +  ("#mult_", op_, t, thy);                                                (* binary . n1.n2 *)
  86.362 +    (*if*) TermC.is_num t1 andalso TermC.is_num t2 (*then*);
  86.363 +        val res = Eval.calcul op0 (t1, t2);
  86.364 +        val prop = HOLogic.Trueprop $ (HOLogic.mk_eq (t, res));
  86.365  val SOME (thmid, tm) = SOME ("#: " ^ UnparseC.term prop, prop)
  86.366  ;
  86.367  if thmid = "#: 2 * 3 = 6" andalso UnparseC.term prop = "2 * 3 = 6" then ()
  86.368 @@ -291,5 +453,5 @@
  86.369  if UnparseC.term (or2list t) = "[x = 3]" then ()
  86.370  else error "or2list changed";
  86.371  val t =  (TermC.str2term "x=3 | x=-3 | x=0");
  86.372 -if UnparseC.term (or2list t) = "[x = 3, x = -3, x = 0]" then ()
  86.373 +if UnparseC.term (or2list t) = "[x = 3, x = - 3, x = 0]" then ()
  86.374  else error "HOL.eq ? HOL.disj ? changed";
    87.1 --- a/test/Tools/isac/Specify/m-match.sml	Mon Jun 21 22:08:01 2021 +0200
    87.2 +++ b/test/Tools/isac/Specify/m-match.sml	Sun Jul 18 18:15:27 2021 +0200
    87.3 @@ -1,4 +1,4 @@
    87.4 -(* Title:  "Specify/model.sml"
    87.5 +(* Title:  "Specify/m-match.sml"
    87.6     Author: Walther Neuper
    87.7     (c) due to copyright terms
    87.8  *)
    87.9 @@ -29,7 +29,7 @@
   87.10      Given = [
   87.11        Correct "equality (sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x))",
   87.12        Correct "solveFor x",
   87.13 -      Superfl "errorBound (eps = 0)"],
   87.14 +      Superfl "errorBound (eps = (0::'a))"],
   87.15      Relate = [],
   87.16      Where = [Correct "matches (?a = ?b) (sqrt (9 + 4 * x) = sqrt x + sqrt (5 + x))"],
   87.17      With = []} => ()
   87.18 @@ -342,10 +342,9 @@
   87.19  
   87.20  case M_Match.arguments thy PATS AGS of
   87.21  [(1, [1], "#Given", Const ("Input_Descript.equality", _),
   87.22 -  [Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (Const (\<^const_name>\<open>plus\<close>, _) $
   87.23 -		Free ("x", _) $ Free ("1", _)) $ Free ("2", _)]),
   87.24 +  [Const ("HOL.eq", _) $ (Const ("Groups.plus_class.plus", _) $
   87.25 +		Free ("x", _) $ _(*1*)) $ _(*1*)]),
   87.26   (2, [1], "#Given", Const ("Input_Descript.solveFor", _), [Free ("x", _)]),
   87.27   (3, [1], "#Find", Const ("Input_Descript.solutions", _), [Free ("x_i", _)])]
   87.28      => ()
   87.29    | _ => error "calchead.sml M_Match.arguments [univariate,equation,test]--";
   87.30 -
    88.1 --- a/test/Tools/isac/Specify/o-model.sml	Mon Jun 21 22:08:01 2021 +0200
    88.2 +++ b/test/Tools/isac/Specify/o-model.sml	Sun Jul 18 18:15:27 2021 +0200
    88.3 @@ -58,14 +58,14 @@
    88.4                   ("#Given", Const ("Biegelinie.Streckenlast", _), [Free ("q_0", _)]),
    88.5                   ("#Find", Const ("Biegelinie.Biegelinie", _), [Free ("y", _)]),
    88.6                   ("#Relate", Const ("Biegelinie.Randbedingungen", _),
    88.7 -                   [Const (\<^const_name>\<open>Cons\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (Free ("y", _) $ Free ("0", _)) $ Free ("0", _)) $
    88.8 -                      Const (\<^const_name>\<open>Nil\<close>, _),
    88.9 -                    Const (\<^const_name>\<open>Cons\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (Free ("y", _) $ Free ("L", _)) $ Free ("0", _)) $
   88.10 -                      Const (\<^const_name>\<open>Nil\<close>, _),
   88.11 -                    Const (\<^const_name>\<open>Cons\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (Const ("Biegelinie.M_b", _) $ Free ("0", _)) $ Free ("0", _)) $
   88.12 -                      Const (\<^const_name>\<open>Nil\<close>, _),
   88.13 -                    Const (\<^const_name>\<open>Cons\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ (Const ("Biegelinie.M_b", _) $ Free ("L", _)) $ Free ("0", _)) $
   88.14 -                      Const (\<^const_name>\<open>Nil\<close>, _)]),
   88.15 +                   [Const ("List.list.Cons", _) $ (Const ("HOL.eq", _) $ (Free ("y", _) $ _(*"0"*)) $ _(*"0"*)) $
   88.16 +                      Const ("List.list.Nil", _),
   88.17 +                    Const ("List.list.Cons", _) $ (Const ("HOL.eq", _) $ (Free ("y", _) $ _(**)) $ _(*"0"*)) $
   88.18 +                      Const ("List.list.Nil", _),
   88.19 +                    Const ("List.list.Cons", _) $ (Const ("HOL.eq", _) $ (Const ("Biegelinie.M_b", _) $ _(*"0"*)) $ _(*"0"*)) $
   88.20 +                      Const ("List.list.Nil", _),
   88.21 +                    Const ("List.list.Cons", _) $ (Const ("HOL.eq", _) $ (Const ("Biegelinie.M_b", _) $ Free ("L", _)) $ _(*"0"*)) $
   88.22 +                      Const ("List.list.Nil", _)]),
   88.23                   ("#undef", Const ("Biegelinie.FunktionsVariable", _), [Free ("x", _)]),
   88.24                    _, _] =
   88.25                 (map (fn str => str
   88.26 @@ -162,7 +162,7 @@
   88.27  [
   88.28    (1, [1, 2, 3], "#Given", Const ("Input_Descript.fixedValues", _), [Const (\<^const_name>\<open>Cons\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ Free ("r", _) $ Const ("Program.Arbfix", _)) $ _]),
   88.29    (2, [1, 2, 3], "#Find", Const ("Input_Descript.maximum", _), [Free ("A", _)]), 
   88.30 -  (3, [1, 2, 3], "#Find", Const ("Input_Descript.valuesFor", _), [_ $ Free ("a", _) $ _, Const (\<^const_name>\<open>Cons\<close>, _) $ Free ("b", _) $ _]),
   88.31 +  (3, [1, 2, 3], "#Find", Const ("Input_Descript.valuesFor", _), [_ $ Free ("a", _) $ _, Const ("List.list.Cons", _) $ Free ("b", _) $ _]),
   88.32    (4, [1, 2], "#Relate",  Const ("Input_Descript.relations", _), _),
   88.33    (5, [3], "#Relate", Const ("Input_Descript.relations", _), _),
   88.34    (6, [1], "#undef", Const ("Input_Descript.boundVariable", _), [Free ("a", _)]),
   88.35 @@ -170,7 +170,7 @@
   88.36    (8, [3], "#undef", Const ("Input_Descript.boundVariable", _), [Free ("alpha", _)]),
   88.37    (9, [1, 2], "#undef", Const ("Input_Descript.interval", _), [Const (\<^const_name>\<open>Collect\<close>, _) $ Abs ("x", _, Const (\<^const_name>\<open>conj\<close>, _) $ _ $ _)]),
   88.38    (10, [3], "#undef", Const ("Input_Descript.interval", _), _),
   88.39 -  (11, [1, 2, 3], "#undef", Const ("Input_Descript.errorBound", _), [Const (\<^const_name>\<open>HOL.eq\<close>, _) $ Free ("eps", _) $ Free ("0", _)])
   88.40 +  (11, [1, 2, 3], "#undef", Const ("Input_Descript.errorBound", _), [Const ("HOL.eq", _) $ Free ("eps", _) $ _(*"0"*)])
   88.41  ] => ()
   88.42  | _ =>  error "fun O_Model.init CHANGED";
   88.43  
   88.44 @@ -189,16 +189,16 @@
   88.45      (3, [1, 2, 3], "#Find", Const ("Input_Descript.valuesFor", _), [_ $ Free ("a", _) $ _, Const (\<^const_name>\<open>Cons\<close>, _) $ Free ("b", _) $ _]),
   88.46      (4, [1, 2], "#Relate",  Const ("Input_Descript.relations", _), _),
   88.47      (6, [1], "#undef", Const ("Input_Descript.boundVariable", _), [Free ("a", _)]),
   88.48 -    (9, [1, 2], "#undef", Const ("Input_Descript.interval", _), [Const (\<^const_name>\<open>Collect\<close>, _) $ Abs ("x", _, Const (\<^const_name>\<open>conj\<close>, _) $ _ $ _)]),
   88.49 -    (11, [1, 2, 3], "#undef", Const ("Input_Descript.errorBound", _), [Const (\<^const_name>\<open>HOL.eq\<close>, _) $ Free ("eps", _) $ Free ("0", _)])
   88.50 +    (9, [1, 2], "#undef", Const ("Input_Descript.interval", _), [Const ("Set.Collect", _) $ Abs ("x", _, Const ("HOL.conj", _) $ _ $ _)]),
   88.51 +    (11, [1, 2, 3], "#undef", Const ("Input_Descript.errorBound", _), [Const ("HOL.eq", _) $ Free ("eps", _) $ _(*"0"*)])
   88.52    ], [
   88.53      (1, [1, 2, 3], "#Given", Const ("Input_Descript.fixedValues", _), [Const (\<^const_name>\<open>Cons\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ Free ("r", _) $ Const ("Program.Arbfix", _)) $ _]),
   88.54      (2, [1, 2, 3], "#Find", Const ("Input_Descript.maximum", _), [Free ("A", _)]), 
   88.55      (3, [1, 2, 3], "#Find", Const ("Input_Descript.valuesFor", _), [_ $ Free ("a", _) $ _, Const (\<^const_name>\<open>Cons\<close>, _) $ Free ("b", _) $ _]),
   88.56      (4, [1, 2], "#Relate",  Const ("Input_Descript.relations", _), _),
   88.57      (7, [2], "#undef", Const ("Input_Descript.boundVariable", _), [Free ("b", _)]),
   88.58 -    (9, [1, 2], "#undef", Const ("Input_Descript.interval", _), [Const (\<^const_name>\<open>Collect\<close>, _) $ Abs ("x", _, Const (\<^const_name>\<open>conj\<close>, _) $ _ $ _)]),
   88.59 -    (11, [1, 2, 3], "#undef", Const ("Input_Descript.errorBound", _), [Const (\<^const_name>\<open>HOL.eq\<close>, _) $ Free ("eps", _) $ Free ("0", _)])
   88.60 +    (9, [1, 2], "#undef", Const ("Input_Descript.interval", _), [Const ("Set.Collect", _) $ Abs ("x", _, Const ("HOL.conj", _) $ _ $ _)]),
   88.61 +    (11, [1, 2, 3], "#undef", Const ("Input_Descript.errorBound", _), [Const ("HOL.eq", _) $ Free ("eps", _) $ _(*"0"*)])
   88.62    ], [
   88.63      (1, [1, 2, 3], "#Given", Const ("Input_Descript.fixedValues", _), [Const (\<^const_name>\<open>Cons\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ Free ("r", _) $ Const ("Program.Arbfix", _)) $ _]),
   88.64      (2, [1, 2, 3], "#Find", Const ("Input_Descript.maximum", _), [Free ("A", _)]), 
   88.65 @@ -206,7 +206,7 @@
   88.66      (5, [3], "#Relate", Const ("Input_Descript.relations", _), _),
   88.67      (8, [3], "#undef", Const ("Input_Descript.boundVariable", _), [Free ("alpha", _)]),
   88.68      (10, [3], "#undef", Const ("Input_Descript.interval", _), _),
   88.69 -    (11, [1, 2, 3], "#undef", Const ("Input_Descript.errorBound", _), [Const (\<^const_name>\<open>HOL.eq\<close>, _) $ Free ("eps", _) $ Free ("0", _)])
   88.70 +    (11, [1, 2, 3], "#undef", Const ("Input_Descript.errorBound", _), [Const ("HOL.eq", _) $ Free ("eps", _) $ _(*"0"*)])
   88.71    ]] => ()
   88.72  | _ => error "fun O_Model.filter_vat CHANGED";
   88.73  
    89.1 --- a/test/Tools/isac/Test_Code/test-code.sml	Mon Jun 21 22:08:01 2021 +0200
    89.2 +++ b/test/Tools/isac/Test_Code/test-code.sml	Sun Jul 18 18:15:27 2021 +0200
    89.3 @@ -47,6 +47,6 @@
    89.4  
    89.5  if p = ([], Res) andalso f2str t = "[x = 1]" andalso
    89.6    eq_set op = (get_ctxt pt p |> get_assumptions |> map UnparseC.term,
    89.7 -    ["precond_rootmet x", "matches (?a = ?b) (-1 + x = 0)", "x = 1"])
    89.8 +    ["precond_rootmet x", "matches (?a = ?b) (- 1 + x = 0)", "x = 1"])
    89.9  then case nxt of End_Proof' => () | _ => error "fun me_trace all Minisubpbl CHANGED 1"
   89.10  else error "fun me_trace all Minisubpbl CHANGED 2";
    90.1 --- a/test/Tools/isac/Test_Isac_Short.thy	Mon Jun 21 22:08:01 2021 +0200
    90.2 +++ b/test/Tools/isac/Test_Isac_Short.thy	Sun Jul 18 18:15:27 2021 +0200
    90.3 @@ -1,4 +1,4 @@
    90.4 -(* Title:  All tests on isac (some outcommented since Isabelle2002-->2009-2)
    90.5 +(* Title:  All tests on isac (some outcommented since Isabelle2002-->2009- 2)
    90.6     Author: Walther Neuper 101001
    90.7     (c) copyright due to license terms.
    90.8  
    90.9 @@ -50,35 +50,37 @@
   90.10       and find out, which ML_file or *.thy causes an error (might be ONLY one).
   90.11       Also backup files (#* ) recognised by jEdit cause this trouble                    *)
   90.12  (*/---------------------- do Minisubpbl before ADDTESTS/All_Ctxt ------------------------------\*)
   90.13 -    "$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/accumulate-val/Thy_All"
   90.14 +(** )"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/accumulate-val/Thy_All"( *TODOO*)
   90.15  (**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/Ctxt"
   90.16  (**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/test-depend/Build_Test"
   90.17  (**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/All_Ctxt"
   90.18  (**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/Test_Units"
   90.19  (**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/course/phst11/T1_Basics"
   90.20 -(**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/course/phst11/T2_Rewriting"
   90.21 +(** )"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/course/phst11/T2_Rewriting"( *TODOO*)
   90.22  (**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/course/phst11/T3_MathEngine"
   90.23  (**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/file-depend/BuildC_Test"
   90.24  (**)"$ISABELLE_ISAC_TEST/Tools/isac/ADDTESTS/session-get_theory/Foo"
   90.25  (*"ADDTESTS/course/SignalProcess/Build_Inverse_Z_Transform"
   90.26     ADDTESTS/------------------------------------------- see end of tests *)
   90.27 -(*/--- these work directly from Pure, but create problems here ..
   90.28 +(*/~~~ these work directly from Pure, but create problems here ..
   90.29    "$ISABELLE_ISAC_TEST/Pure/Isar/Keyword_ISAC.thy"           (* Malformed theory import, "keywords" ?!? *)
   90.30    "$ISABELLE_ISAC_TEST/Pure/Isar/Test_Parse_Isac.thy"        (* Malformed theory import, "keywords" ?!? *)
   90.31    "$ISABELLE_ISAC_TEST/Pure/Isar/Test_Parsers_Cookbook.thy"  (* Malformed theory import             ?!? *)
   90.32    "$ISABELLE_ISAC_TEST/Pure/Isar/Theory_Commands"            (* Duplicate outer syntax command "ISAC"   *)
   90.33    "$ISABELLE_ISAC_TEST/Pure/Isar/Downto_Synchronized"        (* re-defines / breaks structures      !!! *)
   90.34 -  \--- .. these work independently, but create problems here *)
   90.35 +  \~~~ .. these work independently, but create problems here *)
   90.36  (**)"$ISABELLE_ISAC_TEST/Pure/Isar/Test_Parsers"
   90.37  (**)"$ISABELLE_ISAC_TEST/HOL/Tools/Sledgehammer/Try_Sledgehammer"
   90.38  (*/---------------------- do Minisubpbl before ADDTESTS/All_Ctxt ------------------------------\*)
   90.39    "$ISABELLE_ISAC_TEST/Tools/isac/Specify/refine"        (* setup for refine.sml   *)
   90.40    "$ISABELLE_ISAC_TEST/Tools/isac/ProgLang/calculate"    (* setup for evaluate.sml *)
   90.41    "$ISABELLE_ISAC_TEST/Tools/isac/Knowledge/integrate"   (* setup for integrate.sml*)
   90.42 +(** )
   90.43  (*\---------------------- do Minisubpbl before ADDTESTS/All_Ctxt ------------------------------/*)
   90.44  (*"$ISABELLE_ISAC/Knowledge/GCD_Poly_OLD" (*not imported by Isac.thy*)        Test_Isac_Short*)
   90.45  (*"$ISABELLE_ISAC/Knowledge/GCD_Poly_FP"  (*not imported by Isac.thy*)        Test_Isac_Short*)
   90.46  (*\---------------------- do Minisubpbl before ADDTESTS/All_Ctxt ------------------------------/*)
   90.47 +( **)
   90.48  
   90.49  begin
   90.50  
   90.51 @@ -137,8 +139,11 @@
   90.52  "~~~~~ from fun xxx \<longrightarrow>fun yyy \<longrightarrow>fun zzz , return:"; val () = ();
   90.53  (*if*) (*then*); (*else*);   (*case*) (*of*);  (*return value*); (*in*) (*end*);
   90.54  "xx"
   90.55 -^ "xxx"   (*+*) (*!for return!*) (*isa*) (*REP*) (**)
   90.56 +^ "xxx"   (*+*) (*+++*) (*!for return!*) (*isa*) (*REP*) (**)
   90.57 +\<close> ML \<open> (*//---------------- adhoc inserted ------------------------------------------------\\*)
   90.58  \<close> ML \<open>
   90.59 +\<close> ML \<open> (*\\---------------- adhoc inserted ------------------------------------------------//*)
   90.60 +Rewrite.trace_on := false;
   90.61  \<close>
   90.62  ML \<open>
   90.63  \<close> ML \<open>
   90.64 @@ -158,8 +163,8 @@
   90.65    (*fun autoCalculate' cI auto = autoCalculate cI auto (*|> Future.join*)*);
   90.66  \<close>
   90.67  
   90.68 -(*---------------------- check test file by testfile -------------------------------------------
   90.69 -  ---------------------- check test file by testfile -------------------------------------------*)
   90.70 +(*----- comments on tests with TOODOO after changeset "eliminate ThmC.numerals_to_Free" 
   90.71 +  -------------------------------------------------------------------------ARE AT THE RIGHT MARGIN*)
   90.72  section \<open>trials with Isabelle's functions\<close>
   90.73    ML \<open>"%%%%%%%%%%%%%%%%% start Isabelle %%%%%%%%%%%%%%%%%%%%%%%";\<close>
   90.74    ML_file "$ISABELLE_ISAC_TEST/Pure/General/alist.ML"
   90.75 @@ -185,12 +190,13 @@
   90.76    ML_file "BaseDefinitions/calcelems.sml"
   90.77    ML_file "BaseDefinitions/termC.sml"
   90.78    ML_file "BaseDefinitions/substitution.sml"
   90.79 -  ML_file "BaseDefinitions/contextC.sml"
   90.80 +  ML_file "BaseDefinitions/contextC.sml"        (*TOODOO make_ratpoly: "- 6 * x"  \<longrightarrow>  "- (6 * x)"*)
   90.81    ML_file "BaseDefinitions/environment.sml"
   90.82 -  ML_file "BaseDefinitions/kestore.sml" (* setup in ADDTEST/accumulate-val/lucas_interpreter.sml*)
   90.83 +(** )ML_file "BaseDefinitions/kestore.sml" ( * setup in ADDTEST/accumulate-val/lucas_interpreter.sml*)
   90.84  (*---------------------- do Minisubpbl before ADDTESTS/All_Ctxt --------------------------------
   90.85    ---------------------- do Minisubpbl before ADDTESTS/All_Ctxt --------------------------------*)
   90.86  
   90.87 +  ML_file "ProgLang/calculate.sml"
   90.88    ML_file "ProgLang/evaluate.sml"       (* requires setup from calculate.thy                    *)
   90.89    ML_file "ProgLang/listC.sml"
   90.90    ML_file "ProgLang/prog_expr.sml"
   90.91 @@ -228,7 +234,7 @@
   90.92    ML_file "MathEngBasic/thmC.sml"
   90.93    ML_file "MathEngBasic/rewrite.sml"
   90.94    ML_file "MathEngBasic/tactic.sml"
   90.95 -  ML_file "MathEngBasic/ctree.sml"
   90.96 +(** )ML_file "MathEngBasic/ctree.sml"            ( ** )loops with eliminate ThmC.numerals_to_Free*)
   90.97    ML_file "MathEngBasic/calculation.sml"
   90.98  
   90.99    ML_file "Specify/formalise.sml"
  90.100 @@ -265,46 +271,47 @@
  90.101    ML_file "BridgeLibisabelle/mathml.sml"           (*part.*)
  90.102    ML_file "BridgeLibisabelle/pbl-met-hierarchy.sml"
  90.103    ML_file "BridgeLibisabelle/thy-hierarchy.sml"
  90.104 -  ML_file "BridgeLibisabelle/interface-xml.sml"     (*TODO after 2009-2*)
  90.105 -  ML_file "BridgeLibisabelle/interface.sml"
  90.106 -(*WITHOUT inhibit exn WN1130621 Isabelle2012-->13 !thehier! THIS ERROR OCCURS:
  90.107 -  ... SAME ERROR HERE ON ISABELLE2012 AS IN ISAC ON ISABELLE2011*)
  90.108 -
  90.109 +  ML_file "BridgeLibisabelle/interface-xml.sml"     (*TODO after 2009- 2*)
  90.110 +(** )ML_file "BridgeLibisabelle/interface.sml"( *loops with eliminate ThmC.numerals_to_Free
  90.111 +                                                 but is deprecated after ^^^^^^^^^^^^^^^( **)
  90.112    ML_file "BridgeJEdit/parseC.sml"
  90.113    ML_file "BridgeJEdit/preliminary.sml"
  90.114  
  90.115    ML_file "Knowledge/delete.sml"
  90.116    ML_file "Knowledge/descript.sml"
  90.117    ML_file "Knowledge/simplify.sml"
  90.118 -  ML_file "Knowledge/poly.sml"
  90.119 +  ML_file "Knowledge/poly-1.sml"
  90.120 +(*ML_file "Knowledge/poly-2.sml"                                                Test_Isac_Short*)
  90.121    ML_file "Knowledge/gcd_poly_ml.sml"
  90.122    ML_file "Knowledge/gcd_poly_winkler.sml" (*must be after gcd_poly_ml.sml: redefines functions*)
  90.123 -(*ML_file "Knowledge/rational.sml"                                              Test_Isac_Short*)
  90.124 +  ML_file "Knowledge/rational-1.sml"
  90.125 +(*ML_file "Knowledge/rational-2.sml"                                            Test_Isac_Short*)
  90.126    ML_file "Knowledge/equation.sml"
  90.127 -  ML_file "Knowledge/root.sml"
  90.128 +(*ML_file "Knowledge/root.sml"                                    see TOODOO.1*)
  90.129    ML_file "Knowledge/lineq.sml"
  90.130 +
  90.131  (*ML_file "Knowledge/rooteq.sml"    some complicated equations not recovered from 2002 *)
  90.132  (*ML_file "Knowledge/rateq.sml"     some complicated equations not recovered----Test_Isac_Short*)
  90.133 -  ML_file "Knowledge/rootrat.sml"
  90.134 +(*ML_file "Knowledge/rootrat.sml"                                    error inherited from root.sml*)
  90.135    ML_file "Knowledge/rootrateq.sml"(*ome complicated equations not recovered from 2002 *)
  90.136  (*ML_file "Knowledge/partial_fractions.sml"  hangs with ML_system_64 = "true"---Test_Isac_Short*)
  90.137 -  ML_file "Knowledge/polyeq-1.sml"
  90.138 +(*ML_file "Knowledge/polyeq-1.sml"                error inherited from root.sml | in Test_Some.thy*)
  90.139  (*ML_file "Knowledge/polyeq-2.sml"                                              Test_Isac_Short*)
  90.140  (*ML_file "Knowledge/rlang.sml"     much to clean up, similar tests in other files     *)
  90.141    ML_file "Knowledge/calculus.sml"
  90.142    ML_file "Knowledge/trig.sml"
  90.143  (*ML_file "Knowledge/logexp.sml"    not included as stuff for presentation of authoring*) 
  90.144 -  ML_file "Knowledge/diff.sml"
  90.145 -  ML_file "Knowledge/integrate.sml"
  90.146 -  ML_file "Knowledge/eqsystem.sml"
  90.147 +(*ML_file "Knowledge/diff.sml"     incomplete repair 2 * x \<up> - 2" --> 2 / x \<up> 2 | in Test_Some.thy*)
  90.148 +(*ML_file "Knowledge/integrate.sml"                rls simplify_Integral broken | in Test_Some.thy*)
  90.149 +(*ML_file "Knowledge/eqsystem.sml"  simplify_System_parenthesized \<longrightarrow> - 0 + c_4 | in Test_Some.thy*)
  90.150    ML_file "Knowledge/test.sml"
  90.151    ML_file "Knowledge/polyminus.sml"
  90.152    ML_file "Knowledge/vect.sml"
  90.153    ML_file "Knowledge/diffapp.sml"        (* postponed to dev. specification | TP-prog. *)
  90.154 -  ML_file "Knowledge/biegelinie-1.sml"
  90.155 +(*ML_file "Knowledge/biegelinie-1.sml"                   (**) requires integrate.sml, eqsystem.sml*)
  90.156  (*ML_file "Knowledge/biegelinie-2.sml"                                          Test_Isac_Short*)
  90.157  (*ML_file "Knowledge/biegelinie-3.sml"                                          Test_Isac_Short*)
  90.158 -  ML_file "Knowledge/biegelinie-4.sml"
  90.159 +(*ML_file "Knowledge/biegelinie-4.sml"                   (**) requires integrate.sml, eqsystem.sml*)
  90.160    ML_file "Knowledge/algein.sml"
  90.161    ML_file "Knowledge/diophanteq.sml"
  90.162  (*ML_file "Knowledge/inverse_z_transform.sml"hangs with ML_system_64 = "true"---Test_Isac_Short*)
  90.163 @@ -315,7 +322,7 @@
  90.164    ML_file "Test_Code/test-code.sml"
  90.165  
  90.166  section \<open>further tests additional to src/.. files\<close>
  90.167 -  ML_file "BridgeLibisabelle/use-cases.sml"
  90.168 + ML_file "BridgeLibisabelle/use-cases.sml"
  90.169  
  90.170    ML \<open>"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";\<close>
  90.171    ML \<open>"%%%%%%%%%%%%%%%%% end Test_Isac %%%%%%%%%%%%%%%%%%%%%%%%";\<close>
  90.172 @@ -383,7 +390,7 @@
  90.173    migration from "isabelle tty" --> libisabelle
  90.174  \<close>
  90.175  
  90.176 -subsection \<open>isac on Isabelle2013-2\<close>
  90.177 +subsection \<open>isac on Isabelle2013- 2\<close>
  90.178  subsubsection \<open>Summary of development\<close>
  90.179  text \<open>
  90.180    reactivated context_thy
  90.181 @@ -396,17 +403,17 @@
  90.182  text \<open>
  90.183    TODO
  90.184    :
  90.185 -  : isac on Isablle2013-2
  90.186 +  : isac on Isablle2013- 2
  90.187    :
  90.188    Changeset: 55318 (03826ceb24da) merged
  90.189    User: Walther Neuper <neuper@ist.tugraz.at>
  90.190 -  Date: 2013-12-12 14:27:37 +0100 (7 minutes)
  90.191 +  Date: 2013- 12- 12 14:27:37 +0100 (7 minutes)
  90.192  \<close>
  90.193  
  90.194 -subsection \<open>isac on Isabelle2013-1\<close>
  90.195 +subsection \<open>isac on Isabelle2013- 1\<close>
  90.196  subsubsection \<open>Summary of development\<close>
  90.197  text \<open>
  90.198 -  Isabelle2013-1 was replaced within a few weeks due to problems with the document model;
  90.199 +  Isabelle2013- 1 was replaced within a few weeks due to problems with the document model;
  90.200    no significant development steps for ISAC.
  90.201  \<close>
  90.202  subsubsection \<open>State of tests\<close>
  90.203 @@ -417,13 +424,13 @@
  90.204  text \<open>
  90.205    Changeset: 55283 (d6e9a34e7142) notes for resuming work on Polynomial.thy
  90.206    User: Walther Neuper <neuper@ist.tugraz.at>
  90.207 -  Date: 2013-12-03 18:13:31 +0100 (8 days)
  90.208 +  Date: 2013- 12-03 18:13:31 +0100 (8 days)
  90.209    :
  90.210 -  : isac on Isablle2013-1
  90.211 +  : isac on Isablle2013- 1
  90.212    :
  90.213 -  Changeset: 55279 (130688f277ba) Isabelle2013 --> 2013-1: Test_Isac perfect
  90.214 +  Changeset: 55279 (130688f277ba) Isabelle2013 --> 2013- 1: Test_Isac perfect
  90.215    User: Walther Neuper <neuper@ist.tugraz.at>
  90.216 -  Date: 2013-11-21 18:12:17 +0100 (2 weeks)
  90.217 +  Date: 2013- 11- 21 18:12:17 +0100 (2 weeks)
  90.218  
  90.219  \<close>
  90.220  
  90.221 @@ -437,7 +444,7 @@
  90.222  \<close>
  90.223  subsubsection \<open>Run tests\<close>
  90.224  text \<open>
  90.225 -  Is standard now; this subsection will be discontinued under Isabelle2013-1
  90.226 +  Is standard now; this subsection will be discontinued under Isabelle2013- 1
  90.227  \<close>
  90.228  subsubsection \<open>State of tests\<close>
  90.229  text \<open>
  90.230 @@ -454,7 +461,7 @@
  90.231    :
  90.232    Changeset: 52061 (4ecea2fcdc2c) --- Build_Isac.thy runs on Isabelle2013
  90.233    User: Walther Neuper <neuper@ist.tugraz.at>
  90.234 -  Date: 2013-07-15 08:28:50 +0200 (4 weeks)
  90.235 +  Date: 2013-07- 15 08:28:50 +0200 (4 weeks)
  90.236  \<close>
  90.237  
  90.238  subsection \<open>isac on Isabelle2012\<close>
  90.239 @@ -478,13 +485,13 @@
  90.240    in parallel with evaluation.
  90.241  
  90.242    Counting "error in kernel" for Frontend/interface.sml (the tests considered most significant)
  90.243 -  yields 69 hits, some of which were already present before Isabelle2002-->2009-2
  90.244 +  yields 69 hits, some of which were already present before Isabelle2002-->2009- 2
  90.245    (i.e. on the old notebook from 2002).
  90.246  
  90.247    Now many tests with (*...=== inhibit exn ...*) give a reason or at least the origin:
  90.248    # === inhibit exn WN1130621 Isabelle2012-->13 !thehier! === ...see Build_Thydata.thy
  90.249    # === inhibit exn AK110726 === ...reliable work by Alexander Kargl, most likely go back to 2002
  90.250 -  # === inhibit exn WN1130701 broken at Isabelle2002 --> 2009-2 === , most likely go back to 2002
  90.251 +  # === inhibit exn WN1130701 broken at Isabelle2002 --> 2009- 2 === , most likely go back to 2002
  90.252    Reasons for outcommented tests are also found in Test_Isac.thy near the respective file.sml.
  90.253  
  90.254    Some tests have been re-activated (e.g. error patterns, fill patterns).
  90.255 @@ -493,17 +500,17 @@
  90.256  text \<open>
  90.257    Changeset: 52051 (35751d90365e) end of improving tests for isac on Isabelle2012
  90.258    User: Walther Neuper <neuper@ist.tugraz.at>
  90.259 -  Date: 2013-07-11 16:58:31 +0200 (4 weeks)
  90.260 +  Date: 2013-07- 11 16:58:31 +0200 (4 weeks)
  90.261    :
  90.262    : isac on Isablle2012 
  90.263    :
  90.264    Changeset: 48757 (74eb3dfc33cc) updated src from Isabelle2011 to Isabelle2012
  90.265    User: Walther Neuper <neuper@ist.tugraz.at>
  90.266 -  Date: 2012-09-24 18:35:13 +0200 (8 months)
  90.267 +  Date: 2012-09- 24 18:35:13 +0200 (8 months)
  90.268    ------------------------------------------------------------------------------
  90.269    Changeset: 48756 (7443906996a8) merged
  90.270    User: Walther Neuper <neuper@ist.tugraz.at>
  90.271 -  Date: 2012-09-24 18:15:49 +0200 (8 months)
  90.272 +  Date: 2012-09- 24 18:15:49 +0200 (8 months)
  90.273  \<close>
  90.274  
  90.275  subsection \<open>isac on Isabelle2011\<close>
  90.276 @@ -541,7 +548,7 @@
  90.277  
  90.278    The list below records TODOs while producing an ISAC kernel for 
  90.279    gdaroczy and jrocnik, wich could NOT be done before all tests are RUNNING
  90.280 -  (so to be resumed with Isabelle2013-1):
  90.281 +  (so to be resumed with Isabelle2013- 1):
  90.282    ############## WNxxxxxx.TODO can be found in sources ##############
  90.283    --------------------------------------------------------------------------------
  90.284    WN111013.TODO: lots of cleanup/removal in test/../Test.thy
  90.285 @@ -577,7 +584,7 @@
  90.286    --------------------------------------------------------------------------------
  90.287    WN120320.TODO check-improve rlsthmsNOTisac:
  90.288    DONE make test --- old compute rlsthmsNOTisac by eq_thmI'
  90.289 -  DONE compare rlsthmsNOTisac in thms-survey-Isa02-Isa09-2.sml .. Isac.thy 
  90.290 +  DONE compare rlsthmsNOTisac in thms-survey-Isa02-Isa09- 2.sml .. Isac.thy 
  90.291    FOUND 120321: Theory.axioms_of doesnt find LENGTH_CONS etc, thus are in Isab
  90.292    # mark twice thms (in isac + (later) in Isabelle) in Isac.thy
  90.293    --------------------------------------------------------------------------------
  90.294 @@ -686,18 +693,18 @@
  90.295    ------------------------------------------------------------------------------
  90.296    Changeset: 42519 (1f3b4270363e) meeting dmeindl: added missing files
  90.297    User: Walther Neuper <neuper@ist.tugraz.at>
  90.298 -  Date: 2012-09-24 16:39:30 +0200 (8 months)
  90.299 +  Date: 2012-09- 24 16:39:30 +0200 (8 months)
  90.300    :
  90.301    : isac on Isablle2011
  90.302    :
  90.303    Changeset:41897 (355be7f60389) merged isabisac with Isabelle2011
  90.304    Branch: decompose-isar 
  90.305    User: Walther Neuper <neuper@ist.tugraz.at>
  90.306 -  Date: 2011-02-25 13:04:56 +0100 (2011-02-25)
  90.307 +  Date: 2011-02- 25 13:04:56 +0100 (2011-02- 25)
  90.308    ------------------------------------------------------------------------------
  90.309  \<close>
  90.310  
  90.311 -subsection \<open>isac on Isabelle2009-2\<close>
  90.312 +subsection \<open>isac on Isabelle2009- 2\<close>
  90.313  subsubsection \<open>Summary of development\<close>
  90.314  text \<open>
  90.315    In 2009 the update of isac from Isabelle2002 started with switching from CVS to hg.
  90.316 @@ -710,14 +717,14 @@
  90.317    WN131021 this is broken by installation of Isabelle2011/12/13,
  90.318    because all these write their binaries to ~/.isabelle/heaps/..
  90.319  
  90.320 -  $ cd /usr/local/isabisac09-2/
  90.321 +  $ cd /usr/local/isabisac09- 2/
  90.322    $ ./bin/isabelle emacs -l HOL src/Tools/isac/Build_Isac.thy
  90.323    $ ./bin/isabelle emacs -l Isac src/Tools/isac/Test_Isac.thy
  90.324    NOT THE RIGHT VERSION.....    test/Tools/isac/Test_Isac.thy !!!
  90.325  \<close>
  90.326  subsubsection \<open>State of tests\<close>
  90.327  text \<open>
  90.328 -  Most tests are broken by the update from Isabelle2002 to Isabelle2009-2.
  90.329 +  Most tests are broken by the update from Isabelle2002 to Isabelle2009- 2.
  90.330  \<close>
  90.331  subsubsection \<open>Changesets of begin and end\<close>
  90.332  text \<open>
  90.333 @@ -728,12 +735,12 @@
  90.334    User: Marco Steger <m.steger@student.tugraz.at>
  90.335    Date: 2011-02-06 18:30:28 +0100 (2011-02-06)
  90.336    :
  90.337 -  : isac on Isablle2009-2
  90.338 +  : isac on Isablle2009- 2
  90.339    :
  90.340 -  Changeset: 37870 (5100a9c3abf8) created branch isac-from-Isabelle2009-2
  90.341 -  Branch: isac-from-Isabelle2009-2 
  90.342 +  Changeset: 37870 (5100a9c3abf8) created branch isac-from-Isabelle2009- 2
  90.343 +  Branch: isac-from-Isabelle2009- 2 
  90.344    User: Walther Neuper <neuper@ist.tugraz.at>
  90.345 -  Date: 2010-07-21 09:59:35 +0200 (2010-07-21)
  90.346 +  Date: 2010-07- 21 09:59:35 +0200 (2010-07- 21)
  90.347    ------------------------------------------------------------------------------
  90.348  \<close>
  90.349  
    91.1 --- a/test/Tools/isac/Test_Some.thy	Mon Jun 21 22:08:01 2021 +0200
    91.2 +++ b/test/Tools/isac/Test_Some.thy	Sun Jul 18 18:15:27 2021 +0200
    91.3 @@ -48,7 +48,7 @@
    91.4    open Rewrite_Ord
    91.5    open UnparseC
    91.6  \<close>
    91.7 -ML_file "BridgeJEdit/parseC.sml"
    91.8 +(*ML_file "BridgeJEdit/parseC.sml"*)
    91.9  
   91.10  section \<open>code for copy & paste ===============================================================\<close>
   91.11  ML \<open>
   91.12 @@ -57,7 +57,10 @@
   91.13  "~~~~~ from fun xxx \<longrightarrow>fun yyy \<longrightarrow>fun zzz , return:"; val () = ();
   91.14  (*if*) (*then*); (*else*);   (*case*) (*of*);  (*return value*); (*in*) (*end*);
   91.15  "xx"
   91.16 -^ "xxx"   (*+*) (*!for return!*) (*isa*) (*REP*) (**)
   91.17 +^ "xxx"   (*+*) (*+++*) (*!for return!*) (*isa*) (*REP*) (**)
   91.18 +\<close> ML \<open> (*//---------------- adhoc inserted ------------------------------------------------\\*)
   91.19 +\<close> ML \<open>
   91.20 +\<close> ML \<open> (*\\---------------- adhoc inserted ------------------------------------------------//*)
   91.21  (*/------------------- step into XXXXX -----------------------------------------------------\*)
   91.22  (*-------------------- stop step into XXXXX -------------------------------------------------*)
   91.23  (*\------------------- step into XXXXX -----------------------------------------------------/*)
   91.24 @@ -105,6 +108,3032 @@
   91.25  \<close> ML \<open>
   91.26  \<close>
   91.27  
   91.28 +section \<open>======== check Knowledge/polyeq-1.sml =============================================\<close>
   91.29 +ML \<open>
   91.30 +\<close> ML \<open>
   91.31 +(* Title:  Knowledge/polyeq-1.sml
   91.32 +           testexamples for PolyEq, poynomial equations and equational systems
   91.33 +   Author: Richard Lang 2003  
   91.34 +   (c) due to copyright terms
   91.35 +WN030609: some expls dont work due to unfinished handling of 'expanded terms';
   91.36 +          others marked with TODO have to be checked, too.
   91.37 +*)
   91.38 +
   91.39 +"-----------------------------------------------------------------";
   91.40 +"table of contents -----------------------------------------------";
   91.41 +"-----------------------------------------------------------------";
   91.42 +"------ polyeq- 1.sml ---------------------------------------------";
   91.43 +"----------- tests on predicates in problems ---------------------";
   91.44 +"----------- test matching problems ------------------------------";
   91.45 +"----------- prep. for introduction of Matthias Goldgruber 2003 trials on rewrite orders -----";
   91.46 +"----------- Matthias Goldgruber 2003 trials on rewrite orders -------------------------------";
   91.47 +"----------- lin.eq degree_0 -------------------------------------";
   91.48 +"----------- test thm's d2_pq_formulsxx[_neg]---------------------";
   91.49 +"----------- equality (2 +(- 1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
   91.50 +"----------- equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
   91.51 +"----------- equality (- 2 + x + x \<up> 2 = 0) ---------------------------------------------------";
   91.52 +"----------- equality (2 + x + x \<up> 2 = 0) ----------------------------------------------------";
   91.53 +"----------- equality (- 2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
   91.54 +"----------- equality (1*x +   x \<up> 2 = 0) ----------------------------------------------------";
   91.55 +"----------- equality (1*x + 1*x \<up> 2 = 0) ----------------------------------------------------";
   91.56 +"----------- equality (x +   x \<up> 2 = 0) ------------------------------------------------------";
   91.57 +"----------- equality (x + 1*x \<up> 2 = 0) ------------------------------------------------------";
   91.58 +"----------- equality (-4 + x \<up> 2 = 0) -------------------------------------------------------";
   91.59 +"----------- equality (4 + 1*x \<up> 2 = 0) -------------------------------------------------------";
   91.60 +"----------- equality (1 +(- 1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
   91.61 +"----------- equality (- 1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
   91.62 +"----------- equality (1 + x + 2*x \<up> 2 = 0) --------------------------------------------------";
   91.63 +"----------- (-8 - 2*x + x \<up> 2 = 0),  (*Schalk 2, S.67 Nr.31.b----";
   91.64 +"----------- (-8 - 2*x + x \<up> 2 = 0),  by rewriting ---------------";
   91.65 +"----------- (- 16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
   91.66 +"-----------------------------------------------------------------";
   91.67 +"------ polyeq- 2.sml ---------------------------------------------";
   91.68 +"----------- (a*b - (a+b)*x + x \<up> 2 = 0), (*Schalk 2,S.68Nr.44.a*)";
   91.69 +"----------- (-64 + x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.a~--------*)";
   91.70 +"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
   91.71 +"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
   91.72 +"----------- ((x+1)*(x+2) - (3*x - 2) \<up> 2=.. Schalk II s.68 Bsp 37";
   91.73 +"----------- rls make_polynomial_in ------------------------------";
   91.74 +"----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
   91.75 +"----------- rls d2_polyeq_bdv_only_simplify ---------------------";
   91.76 +"-----------------------------------------------------------------";
   91.77 +"-----------------------------------------------------------------";
   91.78 +
   91.79 +\<close> ML \<open>
   91.80 +"----------- tests on predicates in problems ---------------------";
   91.81 +"----------- tests on predicates in problems ---------------------";
   91.82 +"----------- tests on predicates in problems ---------------------";
   91.83 + val t1 = (Thm.term_of o the o (TermC.parse thy)) "lhs (-8 - 2*x + x \<up> 2 = 0)";
   91.84 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t1;
   91.85 + if ((UnparseC.term t) = "- 8 - 2 * x + x \<up> 2") then ()
   91.86 + else  error "polyeq.sml: diff.behav. in lhs";
   91.87 +
   91.88 + val t2 = (Thm.term_of o the o (TermC.parse thy)) "(-8 - 2*x + x \<up> 2) is_expanded_in x";
   91.89 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t2;
   91.90 + if (UnparseC.term t) = "True" then ()
   91.91 + else  error "polyeq.sml: diff.behav. 1 in is_expended_in";
   91.92 +
   91.93 + val t0 = (Thm.term_of o the o (TermC.parse thy)) "(sqrt(x)) is_poly_in x";
   91.94 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t0;
   91.95 + if (UnparseC.term t) = "False" then ()
   91.96 + else  error "polyeq.sml: diff.behav. 2 in is_poly_in";
   91.97 +
   91.98 + val t3 = (Thm.term_of o the o (TermC.parse thy)) "(-8 + (- 1)*2*x + x \<up> 2) is_poly_in x";
   91.99 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t3;
  91.100 + if (UnparseC.term t) = "True" then ()
  91.101 + else  error "polyeq.sml: diff.behav. 3 in is_poly_in";
  91.102 +
  91.103 + val t4 = (Thm.term_of o the o (TermC.parse thy)) "(lhs (-8 + (- 1)*2*x + x \<up> 2 = 0)) is_expanded_in x";
  91.104 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t4;
  91.105 + if (UnparseC.term t) = "True" then ()
  91.106 + else  error "polyeq.sml: diff.behav. 4 in is_expended_in";
  91.107 +
  91.108 + val t6 = (Thm.term_of o the o (TermC.parse thy)) "(lhs (-8 - 2*x + x \<up> 2 = 0)) is_expanded_in x";
  91.109 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t6;
  91.110 + if (UnparseC.term t) = "True" then ()
  91.111 + else  error "polyeq.sml: diff.behav. 5 in is_expended_in";
  91.112 + 
  91.113 + val t3 = (Thm.term_of o the o (TermC.parse thy))"((-8 - 2*x + x \<up> 2) has_degree_in x) = 2";
  91.114 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t3;
  91.115 + if (UnparseC.term t) = "True" then ()
  91.116 + else  error "polyeq.sml: diff.behav. in has_degree_in_in";
  91.117 +
  91.118 +\<close> ML \<open>
  91.119 + val t3 = (Thm.term_of o the o (TermC.parse thy)) "((sqrt(x)) has_degree_in x) = 2";
  91.120 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t3;
  91.121 +\<close> ML \<open>
  91.122 +UnparseC.term t = "- 1 = 2";
  91.123 +\<close> text \<open> (*"((sqrt(x)) has_degree_in x) = 2" ---  = "- 1 = 2"  START HERE*)
  91.124 + if (UnparseC.term t) = "False" then ()
  91.125 + else  error "polyeq.sml: diff.behav. 6 in has_degree_in_in";
  91.126 +
  91.127 +\<close> ML \<open>
  91.128 + val t4 = (Thm.term_of o the o (TermC.parse thy)) 
  91.129 +	      "((-8 - 2*x + x \<up> 2) has_degree_in x) = 1";
  91.130 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t4;
  91.131 + if (UnparseC.term t) = "False" then ()
  91.132 + else  error "polyeq.sml: diff.behav. 7 in has_degree_in_in";
  91.133 +
  91.134 +val t5 = (Thm.term_of o the o (TermC.parse thy)) 
  91.135 +	      "((-8 - 2*x + x \<up> 2) has_degree_in x) = 2";
  91.136 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_prls t5;
  91.137 + if (UnparseC.term t) = "True" then ()
  91.138 + else  error "polyeq.sml: diff.behav. 8 in has_degree_in_in";
  91.139 +
  91.140 +\<close> text \<open> (* M_Match.match_pbl [expanded,univariate,equation] *)
  91.141 +"----------- test matching problems --------------------------0---";
  91.142 +"----------- test matching problems --------------------------0---";
  91.143 +"----------- test matching problems --------------------------0---";
  91.144 +val fmz = ["equality (-8 - 2*x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.145 +if M_Match.match_pbl fmz (Problem.from_store ["expanded", "univariate", "equation"]) =
  91.146 +  M_Match.Matches' {Find = [Correct "solutions L"], 
  91.147 +            With = [], 
  91.148 +            Given = [Correct "equality (-8 - 2 * x + x \<up> 2 = 0)", Correct "solveFor x"], 
  91.149 +            Where = [Correct "matches (?a = 0) (-8 - 2 * x + x \<up> 2 = 0)", 
  91.150 +                     Correct "lhs (-8 - 2 * x + x \<up> 2 = 0) is_expanded_in x"], 
  91.151 +            Relate = []}
  91.152 +then () else error "M_Match.match_pbl [expanded,univariate,equation]";
  91.153 +
  91.154 +if M_Match.match_pbl fmz (Problem.from_store ["degree_2", "expanded", "univariate", "equation"]) =
  91.155 +  M_Match.Matches' {Find = [Correct "solutions L"], 
  91.156 +            With = [], 
  91.157 +            Given = [Correct "equality (-8 - 2 * x + x \<up> 2 = 0)", Correct "solveFor x"], 
  91.158 +            Where = [Correct "lhs (-8 - 2 * x + x \<up> 2 = 0) has_degree_in x = 2"], 
  91.159 +            Relate = []}              (*before WN110906 was: has_degree_in x =!= 2"]*)
  91.160 +then () else error "M_Match.match_pbl [degree_2,expanded,univariate,equation]";
  91.161 +
  91.162 +
  91.163 +"----------- prep. for introduction of Matthias Goldgruber 2003 trials on rewrite orders -----";
  91.164 +"----------- prep. for introduction of Matthias Goldgruber 2003 trials on rewrite orders -----";
  91.165 +"----------- prep. for introduction of Matthias Goldgruber 2003 trials on rewrite orders -----";
  91.166 +(*##################################################################################
  91.167 +----------- 28.2.03: war nicht upgedatet und ausgeklammert in ROOT.ML-->Test_Isac.thy
  91.168 +
  91.169 +  (*Aufgabe zum Einstieg in die Arbeit...*)
  91.170 +  val t = (Thm.term_of o the o (TermC.parse thy)) "a*b - (a+b)*x + x \<up> 2 = 0";
  91.171 +  (*ein 'ruleset' aus Poly.ML wird angewandt...*)
  91.172 +  val SOME (t,_) = rewrite_set_ thy Poly_erls false make_polynomial t;
  91.173 +  UnparseC.term t;
  91.174 +  "a * b + (- 1 * (a * x) + (- 1 * (b * x) + x \<up> 2)) = 0";
  91.175 +  val SOME (t,_) = 
  91.176 +      rewrite_set_inst_ thy Poly_erls false [("bdv", "a")] make_polynomial_in t;
  91.177 +  UnparseC.term t;
  91.178 +  "x \<up> 2 + (- 1 * (b * x) + (- 1 * (x * a) + b * a)) = 0";
  91.179 +(* bei Verwendung von "size_of-term" nach MG :*)
  91.180 +(*"x \<up> 2 + (- 1 * (b * x) + (b * a + - 1 * (x * a))) = 0"  !!! *)
  91.181 +
  91.182 +  (*wir holen 'a' wieder aus der Klammerung heraus...*)
  91.183 +  val SOME (t,_) = rewrite_set_ thy Poly_erls false discard_parentheses t;
  91.184 +  UnparseC.term t;
  91.185 +   "x \<up> 2 + - 1 * b * x + - 1 * x * a + b * a = 0";
  91.186 +(* "x \<up> 2 + - 1 * b * x + b * a + - 1 * x * a = 0" !!! *)
  91.187 +
  91.188 +  val SOME (t,_) =
  91.189 +      rewrite_set_inst_ thy Poly_erls false [("bdv", "a")] make_polynomial_in t;
  91.190 +  UnparseC.term t;
  91.191 +  "x \<up> 2 + (- 1 * (b * x) + a * (b + - 1 * x)) = 0"; 
  91.192 +  (*da sind wir fast am Ziel: make_polynomial_in 'a' sollte ergeben
  91.193 +  "x \<up> 2 + (- 1 * (b * x)) + (b + - 1 * x) * a = 0"*)
  91.194 +
  91.195 +  (*das rewriting l"asst sich beobachten mit
  91.196 +Rewrite.trace_on := false;  (*true false*)
  91.197 +  *)
  91.198 +
  91.199 +"------ 15.11.02 --------------------------";
  91.200 +  val t = (Thm.term_of o the o (TermC.parse thy)) "1 + a * x + b * x";
  91.201 +  val bdv = (Thm.term_of o the o (TermC.parse thy)) "bdv";
  91.202 +  val a = (Thm.term_of o the o (TermC.parse thy)) "a";
  91.203 + 
  91.204 +Rewrite.trace_on := false;  (*true false*)
  91.205 + (* Anwenden einer Regelmenge aus Termorder.ML: *)
  91.206 + val SOME (t,_) =
  91.207 +     rewrite_set_inst_ thy false [(bdv,a)] make_polynomial_in t;
  91.208 + UnparseC.term t;
  91.209 + val SOME (t,_) =
  91.210 +     rewrite_set_ thy false discard_parentheses t;
  91.211 + UnparseC.term t;
  91.212 +"1 + b * x + x * a";
  91.213 +
  91.214 + val t = (Thm.term_of o the o (TermC.parse thy)) "1 + a * (x + b * x) + a \<up> 2";
  91.215 + val SOME (t,_) =
  91.216 +     rewrite_set_inst_ thy false [(bdv,a)] make_polynomial_in t;
  91.217 + UnparseC.term t;
  91.218 + val SOME (t,_) =
  91.219 +     rewrite_set_ thy false discard_parentheses t;
  91.220 + UnparseC.term t;
  91.221 +"1 + (x + b * x) * a + a \<up> 2";
  91.222 +
  91.223 + val t = (Thm.term_of o the o (TermC.parse thy)) "1 + a  \<up> 2 * x + b * a + 7*a \<up> 2";
  91.224 + val SOME (t,_) =
  91.225 +     rewrite_set_inst_ thy false [(bdv,a)] make_polynomial_in t;
  91.226 + UnparseC.term t;
  91.227 + val SOME (t,_) =
  91.228 +     rewrite_set_ thy false discard_parentheses t;
  91.229 + UnparseC.term t;
  91.230 +"1 + b * a + (7 + x) * a \<up> 2";
  91.231 +
  91.232 +(* MG2003
  91.233 + Prog_Expr.thy       grundlegende Algebra
  91.234 + Poly.thy         Polynome
  91.235 + Rational.thy     Br"uche
  91.236 + Root.thy         Wurzeln
  91.237 + RootRat.thy      Wurzen + Br"uche
  91.238 + Termorder.thy    BITTE NUR HIERHER SCHREIBEN (...WN03)
  91.239 +
  91.240 + get_thm Termorder.thy "bdv_n_collect";
  91.241 + get_thm (theory "Isac_Knowledge") "bdv_n_collect";
  91.242 +*)
  91.243 + val t = (Thm.term_of o the o (TermC.parse thy)) "a  \<up> 2 * x + 7 * a \<up> 2";
  91.244 + val SOME (t,_) =
  91.245 +     rewrite_set_inst_ thy false [(bdv,a)] make_polynomial_in t;
  91.246 + UnparseC.term t;
  91.247 + val SOME (t,_) =
  91.248 +     rewrite_set_ thy false discard_parentheses t;
  91.249 + UnparseC.term t;
  91.250 +"(7 + x) * a \<up> 2";
  91.251 +
  91.252 + val t = (Thm.term_of o the o (TermC.parse Termorder.thy)) "Pi";
  91.253 +
  91.254 + val t = (Thm.term_of o the o (parseold thy)) "7";
  91.255 +##################################################################################*)
  91.256 +
  91.257 +
  91.258 +\<close> ML \<open>
  91.259 +"----------- Matthias Goldgruber 2003 trials on rewrite orders -------------------------------";
  91.260 +"----------- Matthias Goldgruber 2003 trials on rewrite orders -------------------------------";
  91.261 +"----------- Matthias Goldgruber 2003 trials on rewrite orders -------------------------------";
  91.262 +  val substa = [(TermC.empty, (Thm.term_of o the o (TermC.parse thy)) "a")];
  91.263 +  val substb = [(TermC.empty, (Thm.term_of o the o (TermC.parse thy)) "b")];
  91.264 +  val substx = [(TermC.empty, (Thm.term_of o the o (TermC.parse thy)) "x")];
  91.265 +
  91.266 +  val x1 = (Thm.term_of o the o (TermC.parse thy)) "a + b + x";
  91.267 +  val x2 = (Thm.term_of o the o (TermC.parse thy)) "a + x + b";
  91.268 +  val x3 = (Thm.term_of o the o (TermC.parse thy)) "a + x + b";
  91.269 +  val x4 = (Thm.term_of o the o (TermC.parse thy)) "x + a + b";
  91.270 +
  91.271 +if ord_make_polynomial_in true thy substx (x1,x2) = true(*LESS *) then ()
  91.272 +else error "termorder.sml diff.behav ord_make_polynomial_in #1";
  91.273 + 
  91.274 +if ord_make_polynomial_in true thy substa (x1,x2) = true(*LESS *) then ()
  91.275 +else error "termorder.sml diff.behav ord_make_polynomial_in #2";
  91.276 +
  91.277 +if ord_make_polynomial_in true thy substb (x1,x2) = false(*GREATER*) then ()
  91.278 +else error "termorder.sml diff.behav ord_make_polynomial_in #3";
  91.279 +
  91.280 +  val aa = (Thm.term_of o the o (TermC.parse thy)) "- 1 * a * x";
  91.281 +  val bb = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 3";
  91.282 +  ord_make_polynomial_in true thy substx (aa, bb);
  91.283 +  true; (* => LESS *) 
  91.284 +  
  91.285 +  val aa = (Thm.term_of o the o (TermC.parse thy)) "- 1 * a * x";
  91.286 +  val bb = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 3";
  91.287 +  ord_make_polynomial_in true thy substa (aa, bb);
  91.288 +  false; (* => GREATER *)
  91.289 +
  91.290 +(* und nach dem Re-engineering der Termorders in den 'rulesets' 
  91.291 +   kannst Du die 'gr"osste' Variable frei w"ahlen: *)
  91.292 +  val bdv= (Thm.term_of o the o (TermC.parse thy)) "''bdv''";
  91.293 +  val x  = (Thm.term_of o the o (TermC.parse thy)) "x";
  91.294 +  val a  = (Thm.term_of o the o (TermC.parse thy)) "a";
  91.295 +  val b  = (Thm.term_of o the o (TermC.parse thy)) "b";
  91.296 +val SOME (t',_) = rewrite_set_inst_ thy false [(bdv,a)] make_polynomial_in x2;
  91.297 +if UnparseC.term t' = "b + x + a" then ()
  91.298 +else error "termorder.sml diff.behav ord_make_polynomial_in #11";
  91.299 +
  91.300 +val NONE = rewrite_set_inst_ thy false [(bdv,b)] make_polynomial_in x2;
  91.301 +
  91.302 +val SOME (t',_) = rewrite_set_inst_ thy false [(bdv,x)] make_polynomial_in x2;
  91.303 +if UnparseC.term t' = "a + b + x" then ()
  91.304 +else error "termorder.sml diff.behav ord_make_polynomial_in #13";
  91.305 +
  91.306 +  val ppp' = "-6 + -5*x + x \<up> 3 + - 1*x \<up> 2 + - 1*x \<up> 3 + - 14*x \<up> 2";
  91.307 +  val ppp  = (Thm.term_of o the o (TermC.parse thy)) ppp';
  91.308 +val SOME (t',_) = rewrite_set_inst_ thy false [(bdv,x)] make_polynomial_in ppp;
  91.309 +
  91.310 +UnparseC.term t' = "- 6 + - (5 * x) + x \<up> 3 + - (x \<up> 2) + - (x \<up> 3) +\n- (14 * x \<up> 2)"
  91.311 +\<close> text \<open> (* TODO.ThmC.numerals_to_Free termorder.sml diff.behav ord_make_polynomial_in*)
  91.312 +if UnparseC.term t' = "- 6 + -5 * x + - 15 * x \<up> 2 + 0" then ()
  91.313 +else error "termorder.sml diff.behav ord_make_polynomial_in #14";
  91.314 +
  91.315 +val SOME (t', _) = rewrite_set_inst_ thy false [(bdv,x)] make_polynomial_in ppp;
  91.316 +if UnparseC.term t' = "- 6 + - 5 * x + - 15 * x \<up> 2 + 0" then ()
  91.317 +else error "termorder.sml diff.behav ord_make_polynomial_in #15";
  91.318 +
  91.319 +  val ttt' = "(3*x + 5)/18";
  91.320 +  val ttt = (Thm.term_of o the o (TermC.parse thy)) ttt';
  91.321 +val SOME (uuu,_) = rewrite_set_inst_ thy false [(bdv,x)] make_polynomial_in ttt;
  91.322 +if UnparseC.term uuu = "(5 + 3 * x) / 18" then ()
  91.323 +else error "termorder.sml diff.behav ord_make_polynomial_in #16a";
  91.324 +
  91.325 +(*============ inhibit exn WN120316 ==============================================
  91.326 +val SOME (uuu,_) = rewrite_set_ thy false make_polynomial ttt;
  91.327 +if UnparseC.term uuu = "(5 + 3 * x) / 18" then ()
  91.328 +else error "termorder.sml diff.behav ord_make_polynomial_in #16b";
  91.329 +============ inhibit exn WN120316 ==============================================*)
  91.330 +
  91.331 +
  91.332 +\<close> ML \<open>
  91.333 +"----------- lin.eq degree_0 -------------------------------------";
  91.334 +"----------- lin.eq degree_0 -------------------------------------";
  91.335 +"----------- lin.eq degree_0 -------------------------------------";
  91.336 +"----- d0_false ------";
  91.337 +val fmz = ["equality (1 = (0::real))", "solveFor x", "solutions L"];
  91.338 +val (dI',pI',mI') = ("PolyEq",["degree_0", "polynomial", "univariate", "equation"],
  91.339 +                     ["PolyEq", "solve_d0_polyeq_equation"]);
  91.340 +(*=== inhibit exn WN110914: declare_constraints doesnt work with ThmC.numerals_to_Free ========
  91.341 +TODO: change to "equality (x + - 1*x = (0::real))"
  91.342 +      and search for an appropriate problem and method.
  91.343 +
  91.344 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.345 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.346 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.347 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.348 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.349 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.350 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.351 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[]")) => ()
  91.352 +	 | _ => error "polyeq.sml: diff.behav. in 1 = 0 -> []";
  91.353 +
  91.354 +"----- d0_true ------";
  91.355 +val fmz = ["equality (0 = (0::real))", "solveFor x", "solutions L"];
  91.356 +val (dI',pI',mI') = ("PolyEq",["degree_0", "polynomial", "univariate", "equation"],
  91.357 +                     ["PolyEq", "solve_d0_polyeq_equation"]);
  91.358 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.359 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.360 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.361 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.362 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.363 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.364 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.365 +case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"UniversalList")) => ()
  91.366 +	 | _ => error "polyeq.sml: diff.behav. in 0 = 0 -> UniversalList";
  91.367 +============ inhibit exn WN110914 ============================================*)
  91.368 +
  91.369 +\<close> text \<open> (*rewrite_set_, rewrite_ "- 1 / 4 = - 1 / 4" z =
  91.370 +- 1 * (- 1 / 4 / 2) + sqrt ((- 1 / 4) \<up> 2 + - 4 * (- 1 / 8)) / 2 \<or>
  91.371 +z =
  91.372 +- 1 * (- 1 / 4 / 2) + - 1 * (sqrt ((- 1 / 4) \<up> 2 + - 4 * (- 1 / 8)) / 2) = NONE*)
  91.373 +"----------- test thm's d2_pq_formulsxx[_neg]---------------------";
  91.374 +"----------- test thm's d2_pq_formulsxx[_neg]---------------------";
  91.375 +"----------- test thm's d2_pq_formulsxx[_neg]---------------------";
  91.376 +"----- d2_pqformula1 ------!!!!";
  91.377 +val fmz = ["equality (- 1/8 + (- 1/4)*z + z \<up> 2 = (0::real))", "solveFor z", "solutions L"];
  91.378 +val (dI',pI',mI') =
  91.379 +  ("Isac_Knowledge", ["pqFormula", "degree_2", "polynomial", "univariate", "equation"], ["no_met"]);
  91.380 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.381 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.382 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.383 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.384 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.385 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.386 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.387 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*Apply_Method ["PolyEq", "solve_d2_polyeq_pq_equation"]*)
  91.388 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.389 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.390 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.391 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;         
  91.392 +
  91.393 +(*[z = 1 / 8 + sqrt (9 / 16) / 2, z = 1 / 8 + - 1 * sqrt (9 / 16) / 2] TODO sqrt*)
  91.394 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; (*nxt =..,Check_elementwise "Assumptions")*)
  91.395 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;         
  91.396 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;         
  91.397 +
  91.398 +if p = ([], Res) andalso
  91.399 +  f2str f = "[z = 1 / 8 + sqrt (9 / 16) / 2, z = 1 / 8 + - 1 * sqrt (9 / 16) / 2]" then
  91.400 +    case nxt of End_Proof' => () | _ => error "(- 1/8 + (- 1/4)*z + z \<up> 2 = (0::real)) CHANGED 1"
  91.401 +else error "(- 1/8 + (- 1/4)*z + z \<up> 2 = (0::real)) CHANGED 2";
  91.402 +
  91.403 +\<close> ML \<open>
  91.404 +"----------- equality (2 +(- 1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  91.405 +"----------- equality (2 +(- 1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  91.406 +"----------- equality (2 +(- 1)*x + x \<up> 2 = (0::real)) ----------------------------------------";
  91.407 +"----- d2_pqformula1_neg ------";
  91.408 +val fmz = ["equality (2 +(- 1)*x + x \<up> 2 = (0::real))", "solveFor x", "solutions L"];
  91.409 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"], ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.410 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.411 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.412 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.413 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.414 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.415 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.416 +(*### or2list False
  91.417 +  ([1],Res)  False   Or_to_List)*)
  91.418 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  91.419 +(*### or2list False                           
  91.420 +  ([2],Res)  []      Check_elementwise "Assumptions"*)
  91.421 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.422 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.423 +val asm = Ctree.get_assumptions pt p;
  91.424 +if f2str f = "[]" andalso 
  91.425 +  UnparseC.terms asm = "[\"lhs (2 + - 1 * x + x \<up> 2 = 0) is_poly_in x\", " ^
  91.426 +    "\"lhs (2 + - 1 * x + x \<up> 2 = 0) has_degree_in x = 2\"]" then ()
  91.427 +else error "polyeq.sml: diff.behav. in 2 +(- 1)*x + x \<up> 2 = 0";
  91.428 +
  91.429 +\<close> text \<open> (*TOODOO rewrite_set_, rewrite_ "- 1 / 2 = - 1 / 2" x = - 1 * (- 1 / 2) + sqrt ((- 1) \<up> 2 + 8) / 2 \<or>
  91.430 +x = - 1 * (- 1 / 2) + - 1 * (sqrt ((- 1) \<up> 2 + 8) / 2) = NONE*)
  91.431 +"----------- equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  91.432 +"----------- equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  91.433 +"----------- equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0) ---------------------------------------------";
  91.434 +"----- d2_pqformula2 ------";
  91.435 +val fmz = ["equality (- 2 +(- 1)*x + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.436 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.437 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.438 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.439 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.440 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.441 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.442 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.443 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.444 +
  91.445 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.446 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.447 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.448 +case f of Test_Out.FormKF "[x = 2, x = - 1]" => ()
  91.449 +	 | _ => error "polyeq.sml: diff.behav. in - 2 + (- 1)*x + x^2 = 0 -> [x = 2, x = - 1]";
  91.450 +
  91.451 +
  91.452 +\<close> text \<open> (*see TOODOO.1*)
  91.453 +"----------- equality (- 2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  91.454 +"----------- equality (- 2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  91.455 +"----------- equality (- 2 + x + x \<up> 2 = 0) ---------------------------------------------------";
  91.456 +"----- d2_pqformula3 ------";
  91.457 +(*EP-9*)
  91.458 +val fmz = ["equality (- 2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.459 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.460 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.461 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.462 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.463 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.464 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.465 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.466 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.467 +
  91.468 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.469 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.470 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  91.471 +case f of Test_Out.FormKF "[x = 1, x = - 2]" => ()
  91.472 +	 | _ => error "polyeq.sml: diff.behav. in  - 2 + x + x^2 = 0-> [x = 1, x = - 2]";
  91.473 +
  91.474 +
  91.475 +\<close> ML \<open>
  91.476 +"----------- equality (2 + x + x \<up> 2 = 0) ----------------------------------------------------";
  91.477 +"----------- equality (2 + x + x \<up> 2 = 0) ----------------------------------------------------";
  91.478 +"----------- equality (2 + x + x \<up> 2 = 0) ----------------------------------------------------";
  91.479 +"----- d2_pqformula3_neg ------";
  91.480 +val fmz = ["equality (2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.481 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.482 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.483 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.484 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.485 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.486 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.487 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.488 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.489 +
  91.490 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.491 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.492 +"TODO 2 + x + x \<up> 2 = 0";
  91.493 +"TODO 2 + x + x \<up> 2 = 0";
  91.494 +"TODO 2 + x + x \<up> 2 = 0";
  91.495 +
  91.496 +\<close> text \<open> (*see TOODOO.1*)
  91.497 +"----------- equality (- 2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  91.498 +"----------- equality (- 2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  91.499 +"----------- equality (- 2 + x + 1*x \<up> 2 = 0)) ------------------------------------------------";
  91.500 +"----- d2_pqformula4 ------";
  91.501 +val fmz = ["equality (- 2 + x + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.502 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.503 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.504 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.505 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.506 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.507 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.508 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.509 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.510 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.511 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.512 +case f of Test_Out.FormKF "[x = 1, x = - 2]" => ()
  91.513 +	 | _ => error "polyeq.sml: diff.behav. in  - 2 + x + 1*x \<up> 2 = 0 -> [x = 1, x = - 2]";
  91.514 +
  91.515 +\<close> text \<open> (* loops*)
  91.516 +"----------- equality (1*x +   x \<up> 2 = 0) ----------------------------------------------------";
  91.517 +"----------- equality (1*x +   x \<up> 2 = 0) ----------------------------------------------------";
  91.518 +"----------- equality (1*x +   x \<up> 2 = 0) ----------------------------------------------------";
  91.519 +"----- d2_pqformula5 ------";
  91.520 +val fmz = ["equality (1*x +   x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.521 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.522 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.523 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.524 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.525 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.526 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.527 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.528 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.529 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.530 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.531 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.532 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  91.533 +	 | _ => error "polyeq.sml: diff.behav. in  1*x +   x^2 = 0 -> [x = 0, x = - 1]";
  91.534 +
  91.535 +\<close> text \<open> (* loops*)
  91.536 +"----------- equality (1*x + 1*x \<up> 2 = 0) ----------------------------------------------------";
  91.537 +"----------- equality (1*x + 1*x \<up> 2 = 0) ----------------------------------------------------";
  91.538 +"----------- equality (1*x + 1*x \<up> 2 = 0) ----------------------------------------------------";
  91.539 +"----- d2_pqformula6 ------";
  91.540 +val fmz = ["equality (1*x + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.541 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.542 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.543 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.544 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.545 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.546 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.547 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.548 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.549 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.550 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.551 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  91.552 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  91.553 +	 | _ => error "polyeq.sml: diff.behav. in  1*x + 1*x^2 = 0 -> [x = 0, x = - 1]";
  91.554 +
  91.555 +\<close> text \<open> (* loops*)
  91.556 +"----------- equality (x +   x \<up> 2 = 0) ------------------------------------------------------";
  91.557 +"----------- equality (x +   x \<up> 2 = 0) ------------------------------------------------------";
  91.558 +"----------- equality (x +   x \<up> 2 = 0) ------------------------------------------------------";
  91.559 +"----- d2_pqformula7 ------";
  91.560 +(*EP- 10*)
  91.561 +val fmz = ["equality (  x +   x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.562 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.563 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.564 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.565 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.566 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.567 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.568 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.569 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.570 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.571 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.572 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  91.573 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  91.574 +	 | _ => error "polyeq.sml: diff.behav. in  x + x^2 = 0 -> [x = 0, x = - 1]";
  91.575 +
  91.576 +\<close> text \<open> (* loops*)
  91.577 +"----------- equality (x + 1*x \<up> 2 = 0) ------------------------------------------------------";
  91.578 +"----------- equality (x + 1*x \<up> 2 = 0) ------------------------------------------------------";
  91.579 +"----------- equality (x + 1*x \<up> 2 = 0) ------------------------------------------------------";
  91.580 +"----- d2_pqformula8 ------";
  91.581 +val fmz = ["equality (x + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.582 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.583 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.584 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.585 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.586 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.587 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.588 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.589 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.590 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.591 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.592 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  91.593 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  91.594 +	 | _ => error "polyeq.sml: diff.behav. in  x + 1*x^2 = 0 -> [x = 0, x = - 1]";
  91.595 +
  91.596 +\<close> text \<open> (*see TOODOO.1*)
  91.597 +"----------- equality (-4 + x \<up> 2 = 0) -------------------------------------------------------";
  91.598 +"----------- equality (-4 + x \<up> 2 = 0) -------------------------------------------------------";
  91.599 +"----------- equality (-4 + x \<up> 2 = 0) -------------------------------------------------------";
  91.600 +"----- d2_pqformula9 ------";
  91.601 +val fmz = ["equality (-4 + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.602 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.603 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.604 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.605 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.606 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.607 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.608 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.609 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.610 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.611 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.612 +case f of Test_Out.FormKF "[x = 2, x = - 2]" => ()
  91.613 +	 | _ => error "polyeq.sml: diff.behav. in -4 + x^2 = 0 -> [x = 2, x = - 2]";
  91.614 +
  91.615 +
  91.616 +\<close> ML \<open>
  91.617 +"----------- equality (4 + 1*x \<up> 2 = 0) -------------------------------------------------------";
  91.618 +"----------- equality (4 + 1*x \<up> 2 = 0) -------------------------------------------------------";
  91.619 +"----------- equality (4 + 1*x \<up> 2 = 0) -------------------------------------------------------";
  91.620 +"----- d2_pqformula9_neg ------";
  91.621 +val fmz = ["equality (4 + 1*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.622 +val (dI',pI',mI') = ("PolyEq",["pqFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.623 +                     ["PolyEq", "solve_d2_polyeq_pq_equation"]);
  91.624 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.625 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.626 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.627 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.628 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.629 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.630 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.631 +"TODO 4 + 1*x \<up> 2 = 0";
  91.632 +"TODO 4 + 1*x \<up> 2 = 0";
  91.633 +"TODO 4 + 1*x \<up> 2 = 0";
  91.634 +
  91.635 +\<close> text \<open> (*see TOODOO.1*)
  91.636 +"-------------------- test thm's d2_abc_formulsxx[_neg]-----";
  91.637 +"-------------------- test thm's d2_abc_formulsxx[_neg]-----";
  91.638 +"-------------------- test thm's d2_abc_formulsxx[_neg]-----";
  91.639 +val fmz = ["equality (- 1 +(- 1)*x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.640 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.641 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.642 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.643 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.644 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.645 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.646 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.647 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.648 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.649 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.650 +case f of Test_Out.FormKF "[x = 1, x = - 1 / 2]" => ()
  91.651 +	 | _ => error "polyeq.sml: diff.behav. in - 1 + (- 1)*x + 2*x^2 = 0 -> [x = 1, x = - 1/2]";
  91.652 +
  91.653 +\<close> ML \<open>
  91.654 +"----------- equality (1 +(- 1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  91.655 +"----------- equality (1 +(- 1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  91.656 +"----------- equality (1 +(- 1)*x + 2*x \<up> 2 = 0) ----------------------------------------------";
  91.657 +val fmz = ["equality (1 +(- 1)*x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.658 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.659 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.660 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.661 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.662 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.663 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.664 +
  91.665 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.666 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.667 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.668 +"TODO 1 +(- 1)*x + 2*x \<up> 2 = 0";
  91.669 +"TODO 1 +(- 1)*x + 2*x \<up> 2 = 0";
  91.670 +"TODO 1 +(- 1)*x + 2*x \<up> 2 = 0";
  91.671 +
  91.672 +
  91.673 +\<close> text \<open> (*see TOODOO.1*)
  91.674 +"----------- equality (- 1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  91.675 +"----------- equality (- 1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  91.676 +"----------- equality (- 1 + x + 2*x \<up> 2 = 0) -------------------------------------------------";
  91.677 +(*EP- 11*)
  91.678 +val fmz = ["equality (- 1 + x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.679 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.680 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.681 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.682 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.683 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.684 +
  91.685 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.686 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.687 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.688 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.689 +
  91.690 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.691 +case f of Test_Out.FormKF "[x = 1 / 2, x = - 1]" => ()
  91.692 +	 | _ => error "polyeq.sml: diff.behav. in - 1 + x + 2*x^2 = 0 -> [x = 1/2, x = - 1]";
  91.693 +
  91.694 +
  91.695 +\<close> ML \<open>
  91.696 +"----------- equality (1 + x + 2*x \<up> 2 = 0) --------------------------------------------------";
  91.697 +"----------- equality (1 + x + 2*x \<up> 2 = 0) --------------------------------------------------";
  91.698 +"----------- equality (1 + x + 2*x \<up> 2 = 0) --------------------------------------------------";
  91.699 +val fmz = ["equality (1 + x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.700 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.701 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.702 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.703 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.704 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.705 +
  91.706 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.707 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.708 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.709 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.710 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  91.711 +"TODO 1 + x + 2*x \<up> 2 = 0";
  91.712 +"TODO 1 + x + 2*x \<up> 2 = 0";
  91.713 +"TODO 1 + x + 2*x \<up> 2 = 0";
  91.714 +
  91.715 +
  91.716 +\<close> text \<open> (*f = Test_Out.FormKF "[]" *)
  91.717 +val fmz = ["equality (- 2 + 1*x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.718 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.719 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.720 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.721 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.722 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.723 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.724 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.725 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.726 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.727 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.728 +case f of Test_Out.FormKF "[x = 1, x = - 2]" => ()
  91.729 +	 | _ => error "polyeq.sml: diff.behav. in - 2 + 1*x + x^2 = 0 -> [x = 1, x = - 2]";
  91.730 +
  91.731 +\<close> ML \<open>
  91.732 +val fmz = ["equality ( 2 + 1*x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.733 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.734 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.735 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.736 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.737 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.738 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.739 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.740 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.741 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.742 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  91.743 +"TODO 2 + 1*x + x \<up> 2 = 0";
  91.744 +"TODO 2 + 1*x + x \<up> 2 = 0";
  91.745 +"TODO 2 + 1*x + x \<up> 2 = 0";
  91.746 +
  91.747 +\<close> text \<open> (*f = Test_Out.FormKF "[]" *)
  91.748 +(*EP- 12*)
  91.749 +val fmz = ["equality (- 2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.750 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.751 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.752 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.753 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.754 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.755 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.756 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.757 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.758 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.759 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.760 +case f of Test_Out.FormKF "[x = 1, x = - 2]" => ()
  91.761 +	 | _ => error "polyeq.sml: diff.behav. in - 2 + x + x^2 = 0 -> [x = 1, x = - 2]";
  91.762 +
  91.763 +\<close> ML \<open>
  91.764 +val fmz = ["equality ( 2 + x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.765 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.766 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.767 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.768 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.769 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.770 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.771 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.772 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.773 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.774 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; 
  91.775 +"TODO 2 + x + x \<up> 2 = 0";
  91.776 +"TODO 2 + x + x \<up> 2 = 0";
  91.777 +"TODO 2 + x + x \<up> 2 = 0";
  91.778 +
  91.779 +\<close> text \<open> (*f = Test_Out.FormKF "[]" *)
  91.780 +(*EP- 13*)
  91.781 +val fmz = ["equality (-8 + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.782 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.783 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.784 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.785 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.786 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.787 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.788 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.789 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.790 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.791 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.792 +case f of Test_Out.FormKF "[x = 2, x = - 2]" => ()
  91.793 +	 | _ => error "polyeq.sml: diff.behav. in -8 + 2*x^2 = 0 -> [x = 2, x = - 2]";
  91.794 +
  91.795 +\<close> ML \<open>
  91.796 +val fmz = ["equality ( 8+ 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.797 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.798 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.799 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.800 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.801 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.802 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.803 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.804 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.805 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.806 +"TODO 8+ 2*x \<up> 2 = 0";
  91.807 +"TODO 8+ 2*x \<up> 2 = 0";
  91.808 +"TODO 8+ 2*x \<up> 2 = 0";
  91.809 +
  91.810 +\<close> text \<open> (*f = Test_Out.FormKF "[]" *)
  91.811 +(*EP- 14*)
  91.812 +val fmz = ["equality (-4 + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.813 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"], ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.814 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.815 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.816 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.817 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.818 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.819 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.820 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.821 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.822 +case f of Test_Out.FormKF "[x = 2, x = - 2]" => ()
  91.823 +	 | _ => error "polyeq.sml: diff.behav. in -4 + x^2 = 0 -> [x = 2, x = - 2]";
  91.824 +
  91.825 +
  91.826 +\<close> ML \<open>
  91.827 +val fmz = ["equality ( 4+ x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.828 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"], ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.829 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.830 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.831 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.832 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.833 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.834 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.835 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.836 +"TODO 4+ x \<up> 2 = 0";
  91.837 +"TODO 4+ x \<up> 2 = 0";
  91.838 +"TODO 4+ x \<up> 2 = 0";
  91.839 +
  91.840 +\<close> text \<open> (*f = Test_Out.FormKF "[]"*)
  91.841 +(*EP- 15*)
  91.842 +val fmz = ["equality (2*x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.843 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.844 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.845 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.846 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.847 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.848 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.849 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.850 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.851 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.852 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.853 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  91.854 +	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = - 1]";
  91.855 +
  91.856 +\<close> text \<open> (* loops*)
  91.857 +val fmz = ["equality (1*x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.858 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.859 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.860 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.861 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.862 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.863 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.864 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.865 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.866 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.867 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.868 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  91.869 +	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = - 1]";
  91.870 +
  91.871 +\<close> text \<open> (* loops*)
  91.872 +(*EP- 16*)
  91.873 +val fmz = ["equality (x + 2*x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.874 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.875 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.876 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.877 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.878 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.879 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.880 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.881 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.882 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.883 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.884 +case f of Test_Out.FormKF "[x = 0, x = - 1 / 2]" => ()
  91.885 +	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = - 1 / 2]";
  91.886 +
  91.887 +\<close> text \<open> (* loops*)
  91.888 +(*EP-//*)
  91.889 +val fmz = ["equality (x + x \<up> 2 = 0)", "solveFor x", "solutions L"];
  91.890 +val (dI',pI',mI') = ("PolyEq",["abcFormula", "degree_2", "polynomial", "univariate", "equation"],
  91.891 +                     ["PolyEq", "solve_d2_polyeq_abc_equation"]);
  91.892 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.893 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.894 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.895 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.896 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.897 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.898 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.899 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.900 +case f of Test_Out.FormKF "[x = 0, x = - 1]" => ()
  91.901 +	 | _ => error "polyeq.sml: diff.behav. in x + x^2 = 0 -> [x = 0, x = - 1]";
  91.902 +
  91.903 +
  91.904 +\<close> text \<open> (* loops*)
  91.905 +"----------- (-8 - 2*x + x \<up> 2 = 0),  (*Schalk 2, S.67 Nr.31.b----";
  91.906 +"----------- (-8 - 2*x + x \<up> 2 = 0),  (*Schalk 2, S.67 Nr.31.b----";
  91.907 +"----------- (-8 - 2*x + x \<up> 2 = 0),  (*Schalk 2, S.67 Nr.31.b----";
  91.908 +(*stopped du to TODO.txt WN111014.TODO calculate_Poly < calculate_Rational < calculate_RootRat
  91.909 +see --- val rls = calculate_RootRat > calculate_Rational ---
  91.910 +calculate_RootRat was a TODO with 2002, requires re-design.
  91.911 +see also --- (-8 - 2*x + x \<up> 2 = 0),  by rewriting --- below
  91.912 +*)
  91.913 + val fmz = ["equality (-8 - 2*x + x \<up> 2 = 0)", (*Schalk 2, S.67 Nr.31.b*)
  91.914 + 	    "solveFor x", "solutions L"];
  91.915 + val (dI',pI',mI') =
  91.916 +     ("PolyEq",["degree_2", "expanded", "univariate", "equation"],
  91.917 +      ["PolyEq", "complete_square"]);
  91.918 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
  91.919 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.920 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.921 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.922 +
  91.923 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.924 +(*Apply_Method ("PolyEq", "complete_square")*)
  91.925 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.926 +(*"-8 - 2 * x + x \<up> 2 = 0", nxt = Rewrite_Set_Inst ... "complete_square*)
  91.927 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.928 +(*"-8 + (2 / 2 - x) \<up> 2 = (2 / 2) \<up> 2", nxt = Rewrite("square_explicit1"*)
  91.929 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.930 +(*"(2 / 2 - x) \<up> 2 = (2 / 2) \<up> 2 - -8" nxt = Rewrite("root_plus_minus*)
  91.931 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.932 +(*"2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |
  91.933 +   2 / 2 - x = - sqrt ((2 / 2) \<up> 2 - -8)" nxt = Rewr_Inst("bdv_explicit2"*)
  91.934 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.935 +(*"2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |
  91.936 +   - 1*x = - (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8)"nxt = R_Inst("bdv_explt2"*)
  91.937 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.938 +(*"- 1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |
  91.939 +   - 1 * x = (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))"nxt = bdv_explicit3*)
  91.940 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.941 +(*"- 1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |
  91.942 +  x = - 1 * (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))" nxt = bdv_explicit3*)
  91.943 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.944 +(*"x = - 1 * (- (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8)) |
  91.945 +   x = - 1 * (- (2 / 2) + - sqrt ((2 / 2) \<up> 2 - -8))"nxt = calculate_Rational
  91.946 +   NOT IMPLEMENTED SINCE 2002 ------------------------------ \<up> \<up> \<up> \<up> \<up>  \<up> *)
  91.947 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.948 +(*"x = - 2 | x = 4" nxt = Or_to_List*)
  91.949 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
  91.950 +(*"[x = - 2, x = 4]" nxt = Check_Postcond*)
  91.951 +val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f;
  91.952 +(* FIXXXME 
  91.953 + case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = - 2, x = 4]")) => () TODO
  91.954 +	 | _ => error "polyeq.sml: diff.behav. in [x = - 2, x = 4]";
  91.955 +*)
  91.956 +if f2str f =
  91.957 +"[x = - 1 * - 1 + - 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8),\n x = - 1 * - 1 + - 1 * (- 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))]"
  91.958 +(*"[x = - 1 * - 1 + - 1 * sqrt (1 \<up> 2 - -8),\n x = - 1 * - 1 + - 1 * (- 1 * sqrt (1 \<up> 2 - -8))]"*)
  91.959 +then () else error "polyeq.sml corrected?behav. in [x = - 2, x = 4]";
  91.960 +
  91.961 +
  91.962 +\<close> text \<open> (* loops*)
  91.963 +"----------- (-8 - 2*x + x \<up> 2 = 0),  by rewriting ---------------";
  91.964 +"----------- (-8 - 2*x + x \<up> 2 = 0),  by rewriting ---------------";
  91.965 +"----------- (-8 - 2*x + x \<up> 2 = 0),  by rewriting ---------------";
  91.966 +(*stopped du to TODO.txt WN111014.TODO calculate_Poly < calculate_Rational < calculate_RootRat
  91.967 +see --- val rls = calculate_RootRat > calculate_Rational ---*)
  91.968 +val thy = @ {theory PolyEq};
  91.969 +val ctxt = Proof_Context.init_global thy;
  91.970 +val inst = [((the o (parseNEW  ctxt)) "bdv::real", (the o (parseNEW  ctxt)) "x::real")];
  91.971 +val t = (the o (parseNEW  ctxt)) "-8 - 2*x + x \<up> 2 = (0::real)";
  91.972 +
  91.973 +val rls = complete_square;
  91.974 +val SOME (t,asm) = rewrite_set_inst_ thy true inst rls t;
  91.975 +UnparseC.term t = "-8 + (2 / 2 - x) \<up> 2 = (2 / 2) \<up> 2";
  91.976 +
  91.977 +val thm = ThmC.numerals_to_Free @{thm square_explicit1};
  91.978 +val SOME (t,asm) = rewrite_ thy dummy_ord Rule_Set.Empty true thm t;
  91.979 +UnparseC.term t = "(2 / 2 - x) \<up> 2 = (2 / 2) \<up> 2 - -8";
  91.980 +
  91.981 +val thm = ThmC.numerals_to_Free @{thm root_plus_minus};
  91.982 +val SOME (t,asm) = rewrite_ thy dummy_ord PolyEq_erls true thm t;
  91.983 +UnparseC.term t = "2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |"^
  91.984 +           "\n2 / 2 - x = - 1 * sqrt ((2 / 2) \<up> 2 - -8)";
  91.985 +
  91.986 +(*the thm bdv_explicit2* here required to be constrained to ::real*)
  91.987 +val thm = ThmC.numerals_to_Free @{thm bdv_explicit2};
  91.988 +val SOME (t,asm) = rewrite_inst_ thy dummy_ord Rule_Set.Empty true inst thm t;
  91.989 +UnparseC.term t = "2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |"^
  91.990 +              "\n- 1 * x = - (2 / 2) + - 1 * sqrt ((2 / 2) \<up> 2 - -8)";
  91.991 +
  91.992 +val thm = ThmC.numerals_to_Free @{thm bdv_explicit3};
  91.993 +val SOME (t,asm) = rewrite_inst_ thy dummy_ord Rule_Set.Empty true inst thm t;
  91.994 +UnparseC.term t = "2 / 2 - x = sqrt ((2 / 2) \<up> 2 - -8) |"^
  91.995 +                   "\nx = - 1 * (- (2 / 2) + - 1 * sqrt ((2 / 2) \<up> 2 - -8))";
  91.996 +
  91.997 +val thm = ThmC.numerals_to_Free @{thm bdv_explicit2};
  91.998 +val SOME (t,asm) = rewrite_inst_ thy dummy_ord Rule_Set.Empty true inst thm t;
  91.999 +UnparseC.term t = "- 1 * x = - (2 / 2) + sqrt ((2 / 2) \<up> 2 - -8) |"^
 91.1000 +                "\nx = - 1 * (- (2 / 2) + - 1 * sqrt ((2 / 2) \<up> 2 - -8))";
 91.1001 +
 91.1002 +val rls = calculate_RootRat;
 91.1003 +val SOME (t,asm) = rewrite_set_ thy true rls t;
 91.1004 +if UnparseC.term t =
 91.1005 +  "- 1 * x = - 1 + sqrt (2 \<up> 2 / 2 \<up> 2 - -8) \<or>\nx = - 1 * - 1 + - 1 * (- 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))"
 91.1006 +(*"- 1 * x = - 1 + sqrt (2 \<up> 2 / 2 \<up> 2 - -8) |\nx = - 1 * - 1 + - 1 * (- 1 * sqrt (2 \<up> 2 / 2 \<up> 2 - -8))"..isabisac15*)
 91.1007 +then () else error "(-8 - 2*x + x \<up> 2 = 0),  by rewriting -- ERROR INDICATES IMPROVEMENT";
 91.1008 +(*SHOULD BE: UnparseC.term = "x = - 2 | x = 4;*)
 91.1009 +
 91.1010 +
 91.1011 +\<close> ML \<open>
 91.1012 +"-------------------- (3 - 10*x + 3*x \<up> 2 = 0), ----------------------";
 91.1013 +"-------------------- (3 - 10*x + 3*x \<up> 2 = 0), ----------------------";
 91.1014 +"-------------------- (3 - 10*x + 3*x \<up> 2 = 0), ----------------------";
 91.1015 +"---- test the erls ----";
 91.1016 + val t1 = (Thm.term_of o the o (TermC.parse thy)) "0 <= (10/3/2) \<up> 2 - 1";
 91.1017 + val SOME (t,_) = rewrite_set_ @{theory PolyEq} false PolyEq_erls t1;
 91.1018 + val t' = UnparseC.term t;
 91.1019 + (*if t'= "HOL.True" then ()
 91.1020 + else error "polyeq.sml: diff.behav. in 'rewrite_set_.. PolyEq_erls";*)
 91.1021 +(* *)
 91.1022 + val fmz = ["equality (3 - 10*x + 3*x \<up> 2 = 0)",
 91.1023 + 	    "solveFor x", "solutions L"];
 91.1024 + val (dI',pI',mI') =
 91.1025 +     ("PolyEq",["degree_2", "expanded", "univariate", "equation"],
 91.1026 +      ["PolyEq", "complete_square"]);
 91.1027 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.1028 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1029 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1030 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1031 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1032 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1033 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1034 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1035 + (*Apply_Method ("PolyEq", "complete_square")*)
 91.1036 + val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f;
 91.1037 +
 91.1038 +\<close> text \<open> (* loops*)
 91.1039 +\<close> text \<open> (*f = Test_Out.FormKF "[]" *)
 91.1040 +\<close> text \<open> (*see TOODOO.1*)
 91.1041 +\<close> ML \<open>
 91.1042 +\<close> text \<open> (* loops*)
 91.1043 +"----------- (- 16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
 91.1044 +"----------- (- 16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
 91.1045 +"----------- (- 16 + 4*x + 2*x \<up> 2 = 0), --------------------------";
 91.1046 + val fmz = ["equality (- 16 + 4*x + 2*x \<up> 2 = 0)",
 91.1047 + 	    "solveFor x", "solutions L"];
 91.1048 + val (dI',pI',mI') =
 91.1049 +     ("PolyEq",["degree_2", "expanded", "univariate", "equation"],
 91.1050 +      ["PolyEq", "complete_square"]);
 91.1051 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.1052 +val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1053 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1054 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1055 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1056 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1057 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1058 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1059 + (*Apply_Method ("PolyEq", "complete_square")*)
 91.1060 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1061 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1062 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1063 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1064 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1065 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1066 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1067 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1068 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1069 + val (p,_,f,nxt,_,pt) = me nxt p [] pt;
 91.1070 +(* FIXXXXME n1.,
 91.1071 + case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 2, x = -4]")) => () TODO
 91.1072 +	 | _ => error "polyeq.sml: diff.behav. in [x = 2, x = -4]";
 91.1073 +*)
 91.1074 +
 91.1075 +\<close> ML \<open>
 91.1076 +\<close> text \<open> (*-------^^^^^ polyeq-1.sml------------vvv diff.sml-------TOODOO----------------*)
 91.1077 +\<close>
 91.1078 +
 91.1079 +section \<open>======== check Knowledge/diff.sml =================================================\<close>
 91.1080 +ML \<open>
 91.1081 +\<close> ML \<open>
 91.1082 +(* Title: test/Tools/isac/Knowledge/diff.sml
 91.1083 +   Author: Walther Neuper
 91.1084 +   Use is subject to license terms.
 91.1085 +*)
 91.1086 +"-----------------------------------------------------------------------------------------------";
 91.1087 +"-----------------------------------------------------------------------------------------------";
 91.1088 +"table of contents -----------------------------------------------------------------------------";
 91.1089 +"-----------------------------------------------------------------------------------------------";
 91.1090 +"----------- problemtype --------------------------------";
 91.1091 +"----------- for correction of diff_const ---------------";
 91.1092 +"----------- for correction of diff_quot ----------------";
 91.1093 +"----------- differentiate by rewrite -------------------";
 91.1094 +"----------- differentiate: me (*+ tacs input*) ---------";
 91.1095 +"----------- 1.5.02 me from script ----------------------";
 91.1096 +"----------- primed id ----------------------------------";
 91.1097 +"----------- diff_conv, sym_diff_conv -------------------";
 91.1098 +"----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
 91.1099 +"----------- autoCalculate diff after_simplification ----";
 91.1100 +"----------- autoCalculate differentiate_equality -------";
 91.1101 +"----------- tests for examples -------------------------";
 91.1102 +"------------inform for x \<up> 2+x+1 -------------------------";
 91.1103 +"--------------------------------------------------------";
 91.1104 +"--------------------------------------------------------";
 91.1105 +"--------------------------------------------------------";
 91.1106 +
 91.1107 +
 91.1108 +val thy = @{theory "Diff"};
 91.1109 +
 91.1110 +"----------- problemtype --------------------------------";
 91.1111 +"----------- problemtype --------------------------------";
 91.1112 +"----------- problemtype --------------------------------";
 91.1113 +val pbt = {Given =["functionTerm f_f", "differentiateFor v_v"],
 91.1114 +	   Where =[],
 91.1115 +	   Find  =["derivative f_f'"],
 91.1116 +	   With  =[],
 91.1117 +	   Relate=[]}:string ppc;
 91.1118 +val chkpbt = ((map (the o (TermC.parse thy))) o P_Model.to_list) pbt;
 91.1119 +
 91.1120 +val org = ["functionTerm (d_d x (x \<up> 2 + 3 * x + 4))", 
 91.1121 +	   "differentiateFor x", "derivative f_f'"];
 91.1122 +val chkorg = map (the o (TermC.parse thy)) org;
 91.1123 +
 91.1124 +Problem.from_store ["derivative_of", "function"];
 91.1125 +MethodC.from_store ["diff", "differentiate_on_R"];
 91.1126 +
 91.1127 +"----------- for correction of diff_const ---------------";
 91.1128 +"----------- for correction of diff_const ---------------";
 91.1129 +"----------- for correction of diff_const ---------------";
 91.1130 +(*re-evaluate this file, otherwise > *** ME_Isa: 'erls' not known*)
 91.1131 +val t = (Thm.term_of o the o (TermC.parse thy)) "Not (x =!= a)";
 91.1132 +case rewrite_set_ thy false erls_diff t of
 91.1133 +  SOME (Const ("HOL.True", _), []) => ()
 91.1134 +| _ => error "rewrite_set_  Not (x =!= a)  changed";
 91.1135 +
 91.1136 +val t =(Thm.term_of o the o (TermC.parse thy)) "2 is_const";
 91.1137 +case rewrite_set_ thy false erls_diff t of
 91.1138 +  SOME (Const ("HOL.True", _), []) => ()
 91.1139 +| _ => error "rewrite_set_   2 is_const   changed";
 91.1140 +
 91.1141 +val thm = @{thm diff_const};
 91.1142 +val ct = (Thm.term_of o the o (TermC.parse thy)) "d_d x x";
 91.1143 +val subst = [(@{term "bdv::real"}, @{term "x::real"})];
 91.1144 +val NONE = (rewrite_inst_ thy tless_true erls_diff false subst thm ct);
 91.1145 +
 91.1146 +"----------- for correction of diff_quot ----------------";
 91.1147 +"----------- for correction of diff_quot ----------------";
 91.1148 +"----------- for correction of diff_quot ----------------";
 91.1149 +val thy = @{theory "Diff"};
 91.1150 +val ct = (Thm.term_of o the o (TermC.parse thy)) "Not (x = 0)";
 91.1151 +rewrite_set_ thy false erls_diff ct;
 91.1152 +
 91.1153 +val ct = (Thm.term_of o the o (TermC.parse thy)) "d_d x ((x+1) / (x - 1))";
 91.1154 +val thm = @{thm diff_quot};
 91.1155 +val SOME (ctt,_) =
 91.1156 +    (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
 91.1157 +
 91.1158 +"----------- differentiate by rewrite -------------------";
 91.1159 +"----------- differentiate by rewrite -------------------";
 91.1160 +"----------- differentiate by rewrite -------------------";
 91.1161 +val thy = @{theory "Diff"};
 91.1162 +val ct = (Thm.term_of o the o (TermC.parse thy)) "d_d x (x \<up> 2 + 3 * x + 4)";
 91.1163 +"--- 1 ---";
 91.1164 +val thm = @{thm "diff_sum"};
 91.1165 +val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
 91.1166 +"--- 2 ---";
 91.1167 +val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
 91.1168 +"--- 3 ---";
 91.1169 +val thm = @{thm "diff_prod_const"};
 91.1170 +val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
 91.1171 +"--- 4 ---";
 91.1172 +val thm = @{thm "diff_pow"};
 91.1173 +val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
 91.1174 +"--- 5 ---";
 91.1175 +val thm = @{thm "diff_const"};
 91.1176 +val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
 91.1177 +"--- 6 ---";
 91.1178 +val thm = @{thm "diff_var"};
 91.1179 +val (ct, _) = the (rewrite_inst_ thy tless_true erls_diff true subst thm ct);
 91.1180 +if UnparseC.term ct = "2 * x \<up> (2 - 1) + 3 * 1 + 0" then ()
 91.1181 +else error "diff.sml diff.behav. in rewrite 1";
 91.1182 +"--- 7 ---";
 91.1183 +"--- 7 ---";
 91.1184 +val rls = Test_simplify;
 91.1185 +val ct = (Thm.term_of o the o (TermC.parse thy)) "2 * x \<up> (2 - 1) + 3 * 1 + 0";
 91.1186 +val (ct, _) = the (rewrite_set_ thy true rls ct);
 91.1187 +if UnparseC.term ct = "3 + 2 * x" then () else error "rewrite_set_ Test_simplify 2 changed";
 91.1188 +
 91.1189 +"----------- differentiate: me (*+ tacs input*) ---------";
 91.1190 +"----------- differentiate: me (*+ tacs input*) ---------";
 91.1191 +"----------- differentiate: me (*+ tacs input*) ---------";
 91.1192 +val fmz = ["functionTerm (x \<up> 2 + 3 * x + 4)", 
 91.1193 +	   "differentiateFor x", "derivative f_f'"];
 91.1194 +val (dI',pI',mI') =
 91.1195 +  ("Diff",["derivative_of", "function"],
 91.1196 +   ["diff", "diff_simpl"]);
 91.1197 +val p = e_pos'; val c = []; 
 91.1198 +"--- s1 ---";
 91.1199 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.1200 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1201 +"--- s2 ---";
 91.1202 +(*val nxt = ("Add_Given",
 91.1203 +Add_Given "functionTerm (d_d x (x \<up> #2 + #3 * x + #4))");*)
 91.1204 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1205 +"--- s3 ---";
 91.1206 +(*val nxt = ("Add_Given",Add_Given "differentiateFor x");*)
 91.1207 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1208 +"--- s4 ---";
 91.1209 +(*val nxt = ("Add_Find",Add_Find "derivative f_f'");*)
 91.1210 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1211 +"--- s5 ---";
 91.1212 +(*val nxt = ("Specify_Theory",Specify_Theory dI');*)
 91.1213 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1214 +"--- s6 ---";
 91.1215 +(*val nxt = ("Specify_Problem",Specify_Problem pI');*)
 91.1216 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1217 +"--- s7 ---";
 91.1218 +(*val nxt = ("Specify_Method",Specify_Method mI');*)
 91.1219 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1220 +"--- s8 ---";
 91.1221 +(*val nxt = ("Apply_Method",Apply_Method mI');*)
 91.1222 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1223 +"--- 1 ---";
 91.1224 +(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_sum", "")));*)
 91.1225 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1226 +"--- 2 ---";
 91.1227 +(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_sum", "")));*)
 91.1228 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1229 +(*val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1230 +val (p,_,f,nxt,_,pt) = me nxt p c pt;*)
 91.1231 +"--- 3 ---";
 91.1232 +(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_prod_const",...;*)
 91.1233 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1234 +(*val (p,_,f,nxt,_,pt) = me nxt p c pt;*)
 91.1235 +"--- 4 ---";
 91.1236 +(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_pow", "")));*)
 91.1237 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1238 +(*val (p,_,f,nxt,_,pt) = me nxt p c pt;*)
 91.1239 +"--- 5 ---";
 91.1240 +(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_prod_const",...;*)
 91.1241 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1242 +(*val (p,_,f,nxt,_,pt) = me nxt p c pt;*)
 91.1243 +"--- 6 ---";
 91.1244 +(*val nxt = ("Rewrite_Inst",Rewrite_Inst (["(''bdv'',x)"],("diff_var", "")));*)
 91.1245 +val (p,_,f,nxt,_,pt) = me nxt p c pt; 
 91.1246 +if f2str f =  "2 * x \<up> (2 - 1) + 3 * 1 + 0" then () 
 91.1247 +else error "diff.sml: diff.behav. in d_d x \<up> 2 + 3 * x + 4";
 91.1248 +"--- 7 ---";
 91.1249 +(*val nxt = ("Rewrite_Set",Rewrite_Set "make_polynomial");*)
 91.1250 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1251 +"--- 8 ---";
 91.1252 +(*val nxt = ("Check_Postcond",Check_Postcond ("Diff", "differentiate_on_R"));*)
 91.1253 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1254 +"--- 9 ---";
 91.1255 +(*val nxt = ("End_Proof'",End_Proof');*)
 91.1256 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.1257 +if f2str f = "3 + 2 * x"
 91.1258 +  then case nxt of End_Proof' => ()
 91.1259 +  | _ => error "diff.sml: new.behav. in me (*+ tacs input*) 1"
 91.1260 +else error "diff.sml: new.behav. in me (*+ tacs input*) 2";
 91.1261 +(*if f = EmptyMout then () else error "new behaviour in + tacs input"*)
 91.1262 +
 91.1263 +"----------- 1.5.02 me from script ----------------------";
 91.1264 +"----------- 1.5.02 me from script ----------------------";
 91.1265 +"----------- 1.5.02 me from script ----------------------";
 91.1266 +(*exp_Diff_No- 1.xml*)
 91.1267 +val fmz = ["functionTerm (x \<up> 2 + 3 * x + 4)", 
 91.1268 +	   "differentiateFor x", "derivative f_f'"];
 91.1269 +val (dI',pI',mI') =
 91.1270 +  ("Diff",["derivative_of", "function"],
 91.1271 +   ["diff", "diff_simpl"]);
 91.1272 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.1273 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1274 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1275 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1276 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1277 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1278 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1279 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1280 +(*nxt = ("Apply_Method",Apply_Method ("Diff", "differentiate_on_R*)
 91.1281 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1282 +
 91.1283 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1284 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1285 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1286 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1287 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1288 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1289 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1290 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1291 +case nxt of End_Proof' => ()
 91.1292 +| _ => error "new behaviour in tests/differentiate, 1.5.02 me from script";
 91.1293 +
 91.1294 +"----------- primed id ----------------------------------";
 91.1295 +"----------- primed id ----------------------------------";
 91.1296 +"----------- primed id ----------------------------------";
 91.1297 +val f_ = TermC.str2term "f_f::bool";
 91.1298 +val f  = TermC.str2term "A = s * (a - s)";
 91.1299 +val v_ = TermC.str2term "v_v";
 91.1300 +val v  = TermC.str2term "s";
 91.1301 +val screxp0 = TermC.str2term "Take ((primed (lhs f_f)) = d_d v_v (rhs f_f))";
 91.1302 +TermC.atomty screxp0;
 91.1303 +
 91.1304 +val screxp1 = subst_atomic [(f_, f), (v_, v)] screxp0;
 91.1305 +UnparseC.term screxp1;
 91.1306 +TermC.atomty screxp1;
 91.1307 +
 91.1308 +val SOME (f'_,_) = rewrite_set_ (@{theory "Isac_Knowledge"}) false srls_diff screxp1; 
 91.1309 +if UnparseC.term f'_= "Take (A' = d_d s (s * (a - s)))" then ()
 91.1310 +else error "diff.sml: diff.behav. in 'primed'";
 91.1311 +TermC.atomty f'_;
 91.1312 +
 91.1313 +val str = "Program DiffEqScr (f_f::bool) (v_v::real) =                         \
 91.1314 +\ (let f_f' = Take ((primed (lhs f_f)) = d_d v_v (rhs f_f))           \
 91.1315 +\ in (((Try (Repeat (Rewrite frac_conv))) #>              \
 91.1316 + \ (Try (Repeat (Rewrite root_conv))) #>                  \
 91.1317 + \ (Try (Repeat (Rewrite realpow_pow))) #>                  \
 91.1318 + \ (Repeat                                                        \
 91.1319 + \   ((Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sum        )) Or \
 91.1320 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_prod_const )) Or \
 91.1321 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_prod       )) Or \
 91.1322 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_quot       )) Or \
 91.1323 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sin        )) Or \
 91.1324 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sin_chain  )) Or \
 91.1325 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_cos        )) Or \
 91.1326 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_cos_chain  )) Or \
 91.1327 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_pow        )) Or \
 91.1328 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_pow_chain  )) Or \
 91.1329 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_ln         )) Or \
 91.1330 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_ln_chain   )) Or \
 91.1331 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_exp        )) Or \
 91.1332 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_exp_chain  )) Or \
 91.1333 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sqrt       )) Or \
 91.1334 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_sqrt_chain )) Or \
 91.1335 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_const      )) Or \
 91.1336 + \    (Repeat (Rewrite_Inst [(''bdv'',v_v)] diff_var        )) Or \
 91.1337 + \    (Repeat (Rewrite_Set             make_polynomial)))) #> \
 91.1338 + \ (Try (Repeat (Rewrite sym_frac_conv))) #>              \
 91.1339 + \ (Try (Repeat (Rewrite sym_root_conv))))) f_f')"
 91.1340 +;
 91.1341 +val sc = (inst_abs o Thm.term_of o the o (TermC.parse thy)) str;
 91.1342 +
 91.1343 +
 91.1344 +\<close> ML \<open>
 91.1345 +"----------- diff_conv, sym_diff_conv -------------------";
 91.1346 +"----------- diff_conv, sym_diff_conv -------------------";
 91.1347 +"----------- diff_conv, sym_diff_conv -------------------";
 91.1348 +val subs = [(TermC.str2term "bdv", TermC.str2term "x")];
 91.1349 +val rls = diff_conv;
 91.1350 +
 91.1351 +val t = TermC.str2term "2/x \<up> 2"; 
 91.1352 +val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
 91.1353 +if UnparseC.term t = "2 * x \<up> - 2" then () else error "diff.sml 1/x";
 91.1354 +
 91.1355 +val t = TermC.str2term "sqrt (x \<up> 3)";
 91.1356 +val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
 91.1357 +if UnparseC.term t = "x \<up> (3 / 2)" then () else error "diff.sml x \<up> 1/2";
 91.1358 +
 91.1359 +val t = TermC.str2term "2 / sqrt x \<up> 3";
 91.1360 +val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
 91.1361 +if UnparseC.term t = "2 * x \<up> (- 3 / 2)" then () else error "diff.sml x \<up> - 1/2";
 91.1362 +val rls = diff_sym_conv; 
 91.1363 +
 91.1364 +val t = TermC.str2term "2 * x \<up> - 2";
 91.1365 +val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
 91.1366 +if UnparseC.term t = "2 / x \<up> 2" then () else error "diff.sml sym 1/x";
 91.1367 +
 91.1368 +val t = TermC.str2term "x \<up> (3 / 2)";
 91.1369 +val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
 91.1370 +if UnparseC.term t = "sqrt (x \<up> 3)" then ((*..wrong rewrite*)) else error"diff.sml sym x \<up> 1/x";
 91.1371 +
 91.1372 +val t = TermC.str2term "2 * x \<up> (-3 / 2)";
 91.1373 +val SOME (t,_) = rewrite_set_inst_ thy false subs rls t; UnparseC.term t;
 91.1374 +if UnparseC.term t ="2 / sqrt (x \<up> 3)"then()else error"diff.sml sym x \<up> - 1/x";
 91.1375 +
 91.1376 +
 91.1377 +\<close> text \<open> (*loops  autoCalculate (x \<up> 2 + x+ 1/x + 2/x \<up> 2)"*)
 91.1378 +"----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
 91.1379 +"----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
 91.1380 +"----------- autoCalculate differentiate_on_R 2/x \<up> 2 -----";
 91.1381 +reset_states ();
 91.1382 +CalcTree
 91.1383 +[(["functionTerm (x \<up> 2 + x+ 1/x + 2/x \<up> 2)",
 91.1384 +   (*"functionTerm ((x \<up> 3) \<up> 5)",*)
 91.1385 +   "differentiateFor x", "derivative f_f'"], 
 91.1386 +  ("Isac_Knowledge", ["derivative_of", "function"],
 91.1387 +  ["diff", "differentiate_on_R"]))];
 91.1388 +Iterator 1;
 91.1389 +moveActiveRoot 1;
 91.1390 +autoCalculate 1 CompleteCalc;
 91.1391 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
 91.1392 +if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = 
 91.1393 +			  "1 + 2 * x + - 1 / x \<up> 2 + -4 / x \<up> 3" then ()
 91.1394 +else error "diff.sml: differentiate_on_R 2/x \<up> 2 changed";
 91.1395 +
 91.1396 +\<close> text \<open> (*loops after repair of error "diff.sml sym 1/x": 2 * x \<up> - 2" --> 2 / x \<up> 2*)
 91.1397 +"---------------------------------------------------------";
 91.1398 +reset_states ();
 91.1399 +CalcTree
 91.1400 +[(["functionTerm (x \<up> 3 * x  \<up>  5)",
 91.1401 +   "differentiateFor x", "derivative f_f'"], 
 91.1402 +  ("Isac_Knowledge", ["derivative_of", "function"],
 91.1403 +  ["diff", "differentiate_on_R"]))];
 91.1404 +Iterator 1;
 91.1405 +moveActiveRoot 1;
 91.1406 +autoCalculate 1 CompleteCalc;
 91.1407 +(* Rewrite.trace_on := false;  (*true false*)
 91.1408 +   LItool.trace_on := false;
 91.1409 +   *)
 91.1410 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
 91.1411 +
 91.1412 +if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = 
 91.1413 +			 "8 * x \<up> 7" then () 
 91.1414 +else error "diff.sml: differentiate_on_R (x \<up> 3 * x \<up> 5) changed";
 91.1415 +
 91.1416 +\<close> text \<open> (*loops after repair of error "diff.sml sym 1/x": 2 * x \<up> - 2" --> 2 / x \<up> 2*)
 91.1417 +"----------- autoCalculate diff after_simplification ----";
 91.1418 +"----------- autoCalculate diff after_simplification ----";
 91.1419 +"----------- autoCalculate diff after_simplification ----";
 91.1420 +reset_states ();
 91.1421 +CalcTree
 91.1422 +[(["functionTerm (x \<up> 3 * x \<up> 5)",
 91.1423 +   "differentiateFor x", "derivative f_f'"], 
 91.1424 +  ("Isac_Knowledge", ["derivative_of", "function"],
 91.1425 +  ["diff", "after_simplification"]))];
 91.1426 +Iterator 1;
 91.1427 +moveActiveRoot 1;
 91.1428 +(* Rewrite.trace_on := true; (*true false*)
 91.1429 +   LItool.trace_on := true;
 91.1430 +   *)
 91.1431 +autoCalculate 1 CompleteCalc;
 91.1432 +(* Rewrite.trace_on := false; (*true false*)
 91.1433 +   LItool.trace_on := false;
 91.1434 +   *)
 91.1435 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
 91.1436 +if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) =  "8 * x \<up> 7"
 91.1437 +then () else error "biegelinie.sml: 1st biegelin.7.27 changed";
 91.1438 +
 91.1439 +\<close> text \<open> (*loops after repair of error "diff.sml sym 1/x": 2 * x \<up> - 2" --> 2 / x \<up> 2*)
 91.1440 +"--------------------------------------------------------";
 91.1441 +reset_states ();
 91.1442 +CalcTree
 91.1443 +[(["functionTerm ((x \<up> 3) \<up> 5)",
 91.1444 +   "differentiateFor x", "derivative f_f'"], 
 91.1445 +  ("Isac_Knowledge", ["derivative_of", "function"],
 91.1446 +  ["diff", "after_simplification"]))];
 91.1447 +Iterator 1;
 91.1448 +moveActiveRoot 1;
 91.1449 +autoCalculate 1 CompleteCalc;
 91.1450 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
 91.1451 +if p = ([], Res) andalso UnparseC.term (get_obj g_res pt (fst p)) = "15 * x \<up> 14"
 91.1452 +then () else error "biegelinie.sml: 1st biegelin.7.27 changed";
 91.1453 +
 91.1454 +\<close> text \<open> (*loops autoCalculate (A = s * (a - (s::real))*)
 91.1455 +"----------- autoCalculate differentiate_equality -------";
 91.1456 +"----------- autoCalculate differentiate_equality -------";
 91.1457 +"----------- autoCalculate differentiate_equality -------";
 91.1458 +reset_states ();
 91.1459 +CalcTree
 91.1460 +[(["functionEq (A = s * (a - (s::real)))", "differentiateFor s", "derivativeEq f_f'"], 
 91.1461 +  ("Isac_Knowledge", ["named", "derivative_of", "function"],
 91.1462 +  ["diff", "differentiate_equality"]))];
 91.1463 +Iterator 1;
 91.1464 +moveActiveRoot 1;
 91.1465 +autoCalculate 1 CompleteCalc;
 91.1466 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
 91.1467 +
 91.1468 +\<close> ML \<open>
 91.1469 +"----------- tests for examples -------------------------";
 91.1470 +"----------- tests for examples -------------------------";
 91.1471 +"----------- tests for examples -------------------------";
 91.1472 +"----- TermC.parse errors";
 91.1473 +(*TermC.str2term "F  =  sqrt( y \<up> 2 - O) * (z + O \<up> 2)";
 91.1474 +TermC.str2term "O";
 91.1475 +TermC.str2term "OO"; ---errors*)
 91.1476 +TermC.str2term "OOO";
 91.1477 +
 91.1478 +"----- thm 'diff_prod_const'";
 91.1479 +val subs = [(TermC.str2term "bdv", TermC.str2term "l")];
 91.1480 +val f = TermC.str2term "G' = d_d l (l * sqrt (7 * s \<up> 2 - l \<up> 2))";
 91.1481 +
 91.1482 +\<close> text \<open> (*loops after repair of error "diff.sml sym 1/x": 2 * x \<up> - 2" --> 2 / x \<up> 2*)
 91.1483 +"------------inform for x \<up> 2+x+1 -------------------------";
 91.1484 +"------------inform for x \<up> 2+x+1 -------------------------";
 91.1485 +"------------inform for x \<up> 2+x+1 -------------------------";
 91.1486 +reset_states ();
 91.1487 +CalcTree
 91.1488 +[(["functionTerm (x \<up> 2 + x + 1)",
 91.1489 +   "differentiateFor x", "derivative f_f'"], 
 91.1490 +  ("Isac_Knowledge", ["derivative_of", "function"],
 91.1491 +  ["diff", "differentiate_on_R"]))];
 91.1492 +Iterator 1;
 91.1493 +moveActiveRoot 1;
 91.1494 +autoCalculate 1 CompleteCalcHead;
 91.1495 +autoCalculate 1 (Steps 1);
 91.1496 +autoCalculate 1 (Steps 1);
 91.1497 +autoCalculate 1 (Steps 1);
 91.1498 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
 91.1499 +appendFormula 1 "2*x + d_d x x + d_d x 1" (*|> Future.join*);
 91.1500 +val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
 91.1501 +if existpt' ([3], Res) pt then ()
 91.1502 +else error  "diff.sml: inform d_d x (x \<up> 2 + x + 1) doesnt work";
 91.1503 +
 91.1504 +\<close> ML \<open>
 91.1505 +\<close> text \<open> (*-------^^^^^ diff.sml------------vvv integrate.sml-----------TOODOO------------*)
 91.1506 +\<close>
 91.1507 +
 91.1508 +section \<open>======== check Knowledge/integrate.sml ============================================\<close>
 91.1509 +ML \<open>
 91.1510 +\<close> ML \<open>
 91.1511 +(* Title:  test/Tools/isac/Knowledge/integrate.sml
 91.1512 +   Author: Walther Neuper 050826
 91.1513 +   (c) due to copyright terms
 91.1514 +*)
 91.1515 +"--------------------------------------------------------";
 91.1516 +"table of contents --------------------------------------";
 91.1517 +"--------------------------------------------------------";
 91.1518 +"----------- parsing ------------------------------------";
 91.1519 +"----------- integrate by rewriting ---------------------";
 91.1520 +"----------- test add_new_c, TermC.is_f_x ---------------------";
 91.1521 +"----------- simplify by ruleset reducing make_ratpoly_in";
 91.1522 +"----------- integrate by ruleset -----------------------";
 91.1523 +"----------- rewrite 3rd integration in 7.27 ------------";
 91.1524 +"----------- check probem type --------------------------";
 91.1525 +"----------- me method [diff,integration] ---------------";
 91.1526 +"----------- autoCalculate [diff,integration] -----------";
 91.1527 +"----------- me method [diff,integration,named] ---------";
 91.1528 +"----------- me met [diff,integration,named] Biegelinie.Q";
 91.1529 +"----------- method analog to rls 'integration' ---------";
 91.1530 +"--------------------------------------------------------";
 91.1531 +"--------------------------------------------------------";
 91.1532 +"--------------------------------------------------------";
 91.1533 +
 91.1534 +(*these val/fun provide for exact parsing in Integrate.thy, not Isac.thy;
 91.1535 +they are used several times below; TODO remove duplicates*)
 91.1536 +val thy = @{theory "Integrate"};
 91.1537 +val ctxt = ThyC.to_ctxt thy;
 91.1538 +
 91.1539 +fun str2t str = parseNEW ctxt str |> the;
 91.1540 +fun term2s t = UnparseC.term_in_ctxt ctxt t;
 91.1541 +    
 91.1542 +val conditions_in_integration_rules =
 91.1543 +  Rule_Set.Repeat {id="conditions_in_integration_rules", 
 91.1544 +    preconds = [], 
 91.1545 +    rew_ord = ("termlessI",termlessI), 
 91.1546 +    erls = Rule_Set.Empty, 
 91.1547 +    srls = Rule_Set.Empty, calc = [], errpatts = [],
 91.1548 +    rules = [(*for rewriting conditions in Thm's*)
 91.1549 +	    Eval ("Prog_Expr.occurs_in", 
 91.1550 +		  eval_occurs_in "#occurs_in_"),
 91.1551 +	    Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
 91.1552 +	    Thm ("not_false",ThmC.numerals_to_Free @{thm not_false})],
 91.1553 +    scr = Empty_Prog};
 91.1554 +val subs = [(str2t "bdv::real", str2t "x::real")];
 91.1555 +\<close> ML \<open>
 91.1556 +fun rewrit thm str = 
 91.1557 +    fst (the (rewrite_inst_ thy tless_true 
 91.1558 +			   conditions_in_integration_rules 
 91.1559 +			   true subs thm str));
 91.1560 +
 91.1561 +
 91.1562 +\<close> ML \<open>
 91.1563 +"----------- parsing ------------------------------------";
 91.1564 +"----------- parsing ------------------------------------";
 91.1565 +"----------- parsing ------------------------------------";
 91.1566 +val t = TermC.str2term "Integral x D x";
 91.1567 +val t = TermC.str2term "Integral x \<up> 2 D x";
 91.1568 +case t of 
 91.1569 +    Const ("Integrate.Integral", _) $
 91.1570 +     (Const ("Transcendental.powr", _) $ Free _ $ _) $ Free ("x", _) => ()
 91.1571 +  | _ => error "integrate.sml: parsing: Integral x \<up> 2 D x";
 91.1572 +
 91.1573 +val t = TermC.str2term "ff x is_f_x";
 91.1574 +case t of Const ("Integrate.is_f_x", _) $ _ => ()
 91.1575 +	| _ => error "integrate.sml: parsing: ff x is_f_x";
 91.1576 +
 91.1577 +
 91.1578 +\<close> ML \<open>
 91.1579 +"----------- integrate by rewriting ---------------------";
 91.1580 +"----------- integrate by rewriting ---------------------";
 91.1581 +"----------- integrate by rewriting ---------------------";
 91.1582 +val str = rewrit @{thm "integral_const"} (TermC.str2term "Integral 1 D x");
 91.1583 +if term2s str = "1 * x" then () else error "integrate.sml Integral 1 D x";
 91.1584 +
 91.1585 +val str = rewrit @{thm "integral_const"} (TermC.str2term  "Integral M'/EJ D x");
 91.1586 +if term2s str = "M' / EJ * x" then ()
 91.1587 +else error "Integral M'/EJ D x   BY integral_const";
 91.1588 +
 91.1589 +val str = rewrit @{thm "integral_var"} (TermC.str2term "Integral x D x");
 91.1590 +if term2s str = "x \<up> 2 / 2" then ()
 91.1591 +else error "Integral x D x   BY integral_var";
 91.1592 +
 91.1593 +val str = rewrit @{thm "integral_add"} (TermC.str2term "Integral x + 1 D x");
 91.1594 +if term2s str = "Integral x D x + Integral 1 D x" then ()
 91.1595 +else error "Integral x + 1 D x   BY integral_add";
 91.1596 +
 91.1597 +val str = rewrit @{thm "integral_mult"} (TermC.str2term "Integral M'/EJ * x \<up> 3 D x");
 91.1598 +if term2s str = "M' / EJ * Integral x \<up> 3 D x" then ()
 91.1599 +else error "Integral M'/EJ * x \<up> 3 D x   BY integral_mult";
 91.1600 +
 91.1601 +val str = rewrit @{thm "integral_pow"} (TermC.str2term "Integral x \<up> 3 D x");
 91.1602 +if term2s str = "x \<up> (3 + 1) / (3 + 1)" then ()
 91.1603 +else error "integrate.sml Integral x \<up> 3 D x";
 91.1604 +
 91.1605 +
 91.1606 +\<close> ML \<open>
 91.1607 +"----------- test add_new_c, TermC.is_f_x ---------------------";
 91.1608 +"----------- test add_new_c, TermC.is_f_x ---------------------";
 91.1609 +"----------- test add_new_c, TermC.is_f_x ---------------------";
 91.1610 +val term = TermC.str2term "x \<up> 2 * c + c_2";
 91.1611 +val cc = new_c term;
 91.1612 +if UnparseC.term cc = "c_3" then () else error "integrate.sml: new_c ???";
 91.1613 +
 91.1614 +val SOME (id,t') = eval_add_new_c "" "Integrate.add_new_c" term thy;
 91.1615 +if UnparseC.term t' = "x \<up> 2 * c + c_2 = x \<up> 2 * c + c_2 + c_3" then ()
 91.1616 +else error "intergrate.sml: diff. eval_add_new_c";
 91.1617 +
 91.1618 +val cc = ("Integrate.add_new_c", eval_add_new_c "add_new_c_");
 91.1619 +val SOME (thmstr, thm) = adhoc_thm1_ thy cc term;
 91.1620 +
 91.1621 +val SOME (t',_) = rewrite_set_ thy true add_new_c term;
 91.1622 +if UnparseC.term t' = "x \<up> 2 * c + c_2 + c_3" then ()
 91.1623 +else error "intergrate.sml: diff. rewrite_set add_new_c 1";
 91.1624 +
 91.1625 +val term = TermC.str2term "ff x = x \<up> 2*c + c_2";
 91.1626 +val SOME (t',_) = rewrite_set_ thy true add_new_c term;
 91.1627 +if UnparseC.term t' = "ff x = x \<up> 2 * c + c_2 + c_3" then ()
 91.1628 +else error "intergrate.sml: diff. rewrite_set add_new_c 2";
 91.1629 +
 91.1630 +
 91.1631 +(*WN080222 replace call_new_c with add_new_c----------------------
 91.1632 +val term = str2t "new_c (c * x \<up> 2 + c_2)";
 91.1633 +val SOME (_,t') = eval_new_c 0 0 term 0;
 91.1634 +if term2s t' = "new_c c * x \<up> 2 + c_2 = c_3" then ()
 91.1635 +else error "integrate.sml: eval_new_c ???";
 91.1636 +
 91.1637 +val t = str2t "matches (?u + new_c ?v) (x \<up> 2 / 2)";
 91.1638 +val SOME (_,t') = eval_matches "" "Prog_Expr.matches" t thy; term2s t';
 91.1639 +if term2s t' = "matches (?u + new_c ?v) (x \<up> 2 / 2) = False" then ()
 91.1640 +else error "integrate.sml: matches new_c = False";
 91.1641 +
 91.1642 +val t = str2t "matches (?u + new_c ?v) (x \<up> 2 / 2 + new_c x \<up> 2 / 2)";
 91.1643 +val SOME (_,t') = eval_matches "" "Prog_Expr.matches" t thy; term2s t';
 91.1644 +if term2s t'="matches (?u + new_c ?v) (x \<up> 2 / 2 + new_c x \<up> 2 / 2) = True"
 91.1645 +then () else error "integrate.sml: matches new_c = True";
 91.1646 +
 91.1647 +val t = str2t "ff x TermC.is_f_x";
 91.1648 +val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t';
 91.1649 +if term2s t' = "(ff x TermC.is_f_x) = True" then ()
 91.1650 +else error "integrate.sml: eval_is_f_x --> true";
 91.1651 +
 91.1652 +val t = str2t "q_0/2 * L * x TermC.is_f_x";
 91.1653 +val SOME (_,t') = eval_is_f_x "" "" t thy; term2s t';
 91.1654 +if term2s t' = "(q_0 / 2 * L * x TermC.is_f_x) = False" then ()
 91.1655 +else error "integrate.sml: eval_is_f_x --> false";
 91.1656 +
 91.1657 +val conditions_in_integration =
 91.1658 +Rule_Set.Repeat {id="conditions_in_integration", 
 91.1659 +     preconds = [], 
 91.1660 +     rew_ord = ("termlessI",termlessI), 
 91.1661 +     erls = Rule_Set.Empty, 
 91.1662 +     srls = Rule_Set.Empty, calc = [], errpatts = [],
 91.1663 +     rules = [Eval ("Prog_Expr.matches",eval_matches ""),
 91.1664 +      	Eval ("Integrate.is_f_x", 
 91.1665 +      	      eval_is_f_x "is_f_x_"),
 91.1666 +      	Thm ("not_true",ThmC.numerals_to_Free @{thm not_true}),
 91.1667 +      	Thm ("not_false",ThmC.numerals_to_Free @{thm not_false})
 91.1668 +      	],
 91.1669 +     scr = Empty_Prog};
 91.1670 +fun rewrit thm t = 
 91.1671 +    fst (the (rewrite_inst_ thy tless_true 
 91.1672 +			    conditions_in_integration true subs thm t));
 91.1673 +val t = rewrit call_for_new_c (str2t "x \<up> 2 / 2"); term2s t;
 91.1674 +val t = (rewrit call_for_new_c t)
 91.1675 +    handle OPTION =>  str2t "no_rewrite";
 91.1676 +
 91.1677 +val t = rewrit call_for_new_c 
 91.1678 +	       (str2t "ff x = q_0/2 *L*x"); term2s t;
 91.1679 +val t = (rewrit call_for_new_c 
 91.1680 +	       (str2t "ff x = q_0 / 2 * L * x + new_c q_0 / 2 * L * x"))
 91.1681 +    handle OPTION => (*NOT:  + new_c ..=..!!*)str2t "no_rewrite";
 91.1682 +--------------------------------------------------------------------*)
 91.1683 +
 91.1684 +
 91.1685 +\<close> ML \<open>
 91.1686 +"----------- simplify by ruleset reducing make_ratpoly_in";
 91.1687 +"----------- simplify by ruleset reducing make_ratpoly_in";
 91.1688 +"----------- simplify by ruleset reducing make_ratpoly_in";
 91.1689 +val thy = @{theory "Isac_Knowledge"};
 91.1690 +"===== test 1";
 91.1691 +val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)";
 91.1692 +
 91.1693 +"----- stepwise from the rulesets in simplify_Integral and below-----";
 91.1694 +val rls = norm_Rational_noadd_fractions;
 91.1695 +case rewrite_set_inst_ thy true subs rls t of
 91.1696 +    SOME _ => error "integrate.sml simplify by ruleset norm_Rational_.#2"
 91.1697 +  | NONE => ();
 91.1698 +
 91.1699 +"===== test 2";
 91.1700 +val rls = order_add_mult_in;
 91.1701 +(*//--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----\\
 91.1702 +        assume flawed test setup hidden by "handle _ => ..."
 91.1703 +        ERROR ord_make_polynomial_in called with subst = []
 91.1704 +val SOME (t,[]) = rewrite_set_ thy true rls t;
 91.1705 +if UnparseC.term t = "1 / EI * (L * (q_0 * x) / 2 + - 1 * (q_0 * x \<up> 2) / 2)" then()
 91.1706 +else error "integrate.sml simplify by ruleset order_add_mult_in #2";
 91.1707 +  \\--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----//*)
 91.1708 +
 91.1709 +"===== test 3";
 91.1710 +val rls = discard_parentheses;
 91.1711 +(*//--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----\\
 91.1712 +        assume flawed test setup hidden by "handle _ => ..."
 91.1713 +        ERROR ord_make_polynomial_in called with subst = []
 91.1714 +val SOME (t,[]) = rewrite_set_ thy true rls t;
 91.1715 +if UnparseC.term t = "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" then ()
 91.1716 +else error "integrate.sml simplify by ruleset discard_parenth.. #3";
 91.1717 +  \\--- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----//*)
 91.1718 +
 91.1719 +"===== test 4";
 91.1720 +val subs = [(TermC.str2term "bdv::real", TermC.str2term "x::real")];
 91.1721 +val rls = 
 91.1722 +  (Rule_Set.append_rules "separate_bdv" collect_bdv
 91.1723 + 	  [Thm ("separate_bdv", ThmC.numerals_to_Free @{thm separate_bdv}),
 91.1724 + 		  (*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
 91.1725 + 		 Thm ("separate_bdv_n", ThmC.numerals_to_Free @{thm separate_bdv_n}),
 91.1726 +      (*"?a * ?bdv \<up> ?n / ?b = ?a / ?b * ?bdv \<up> ?n"*)
 91.1727 + 		Thm ("separate_1_bdv", ThmC.numerals_to_Free @{thm separate_1_bdv}),
 91.1728 + 		  (*"?bdv / ?b = (1 / ?b) * ?bdv"*)
 91.1729 + 		Thm ("separate_1_bdv_n", ThmC.numerals_to_Free @{thm separate_1_bdv_n})
 91.1730 +       (*"?bdv \<up> ?n / ?b = 1 / ?b * ?bdv \<up> ?n"*)
 91.1731 +    ]);
 91.1732 +(*show_types := true;  --- do we need type-constraint in thms? *)
 91.1733 +@{thm separate_bdv};     (*::?'a does NOT rewrite here WITHOUT type constraint*)
 91.1734 +@{thm separate_bdv_n};   (*::real ..because of  \<up> , rewrites*)
 91.1735 +@{thm separate_1_bdv};   (*::?'a*)
 91.1736 +val xxx = ThmC.numerals_to_Free @{thm separate_1_bdv}; (*::?'a*)
 91.1737 +@{thm separate_1_bdv_n}; (*::real ..because of  \<up> *)
 91.1738 +(*show_types := false; --- do we need type-constraint in thms? YES ?!?!?!*)
 91.1739 +
 91.1740 +val SOME (t, []) = rewrite_set_inst_ thy true subs rls t;
 91.1741 +if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then ()
 91.1742 +else error "integrate.sml simplify by ruleset separate_bdv.. #4";
 91.1743 +
 91.1744 +"===== test 5";
 91.1745 +val t = TermC.str2term "1/EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)";
 91.1746 +val rls = simplify_Integral;
 91.1747 +val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t;
 91.1748 +(* given was:   "1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2)" *)
 91.1749 +if UnparseC.term t = "1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2)" then ()
 91.1750 +else error "integrate.sml, simplify_Integral #99";
 91.1751 +
 91.1752 +\<close> ML \<open>
 91.1753 +"........... 2nd integral ........................................";
 91.1754 +"........... 2nd integral ........................................";
 91.1755 +"........... 2nd integral ........................................";
 91.1756 +val thy = @{theory Biegelinie};
 91.1757 +val t = TermC.str2term 
 91.1758 +  "Integral 1 / EI * (L * q_0 / 2 * (x \<up> 2 / 2) + - 1 * q_0 / 2 * (x \<up> 3 / 3)) D x";
 91.1759 +
 91.1760 +val rls = simplify_Integral;
 91.1761 +(*TOODOO simplify_Integral broken (required for Biegelinie) ---------------------------------\\ 
 91.1762 +  "Integral 1 / EI * (L * q_0 / 2 * (x \<up> 2 / 2) + - 1 * q_0 / 2 * (x \<up> 3 / 3)) D x";
 91.1763 +\<down> "Integral 1 / EI * ((L * q_0 / 4) * x \<up> 2 + (- 1 * q_0 / 6) * x \<up> 3) D x"         broken
 91.1764 +(**)
 91.1765 +val SOME (t,[]) = rewrite_set_inst_ thy true subs rls t;
 91.1766 +if UnparseC.term t =
 91.1767 +   "Integral 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3) D x"
 91.1768 +then () else raise error "integrate.sml, simplify_Integral #198";
 91.1769 +
 91.1770 +val rls = integration_rules;
 91.1771 +val SOME (t,[]) = rewrite_set_ thy true rls t;
 91.1772 +UnparseC.term t;
 91.1773 +if UnparseC.term t = 
 91.1774 +   "1 / EI * (L * q_0 / 4 * (x \<up> 3 / 3) + - 1 * q_0 / 6 * (x \<up> 4 / 4))"
 91.1775 +then () else error "integrate.sml, simplify_Integral #199";
 91.1776 +-------------------------------------------------------------------------------------------//*)
 91.1777 +
 91.1778 +
 91.1779 +\<close> ML \<open>
 91.1780 +"----------- integrate by ruleset -----------------------";
 91.1781 +"----------- integrate by ruleset -----------------------";
 91.1782 +"----------- integrate by ruleset -----------------------";
 91.1783 +val thy = @{theory "Integrate"};
 91.1784 +val rls = integration_rules;
 91.1785 +val subs = [(@{term "bdv::real"}, @{term "x::real"})];
 91.1786 +(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
 91.1787 +
 91.1788 +\<close> ML \<open>
 91.1789 +val t = (Thm.term_of o the o (TermC.parse thy)) "Integral x D x";
 91.1790 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1791 +if UnparseC.term res = "x \<up> 2 / 2" then () else error "Integral x D x changed";
 91.1792 +
 91.1793 +val t = (Thm.term_of o the o (TermC.parse thy)) "Integral c * x \<up> 2 + c_2 D x";
 91.1794 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1795 +if UnparseC.term res = "c * (x \<up> 3 / 3) + c_2 * x" then () else error "Integral c * x \<up> 2 + c_2 D x";
 91.1796 +
 91.1797 +\<close> ML \<open>
 91.1798 +val rls = add_new_c;
 91.1799 +val t = (Thm.term_of o the o (TermC.parse thy)) "c * (x \<up> 3 / 3) + c_2 * x";
 91.1800 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1801 +if UnparseC.term res = "c * (x \<up> 3 / 3) + c_2 * x + c_3" then () 
 91.1802 +else error "integrate.sml: diff.behav. in add_new_c simpl.";
 91.1803 +
 91.1804 +\<close> ML \<open>
 91.1805 +val t = (Thm.term_of o the o (TermC.parse thy)) "F x = x \<up> 3 / 3 + x";
 91.1806 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1807 +if UnparseC.term res = "F x = x \<up> 3 / 3 + x + c"(*not "F x + c =..."*) then () 
 91.1808 +else error "integrate.sml: diff.behav. in add_new_c equation";
 91.1809 +
 91.1810 +\<close> ML \<open>
 91.1811 +val rls = simplify_Integral;
 91.1812 +(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
 91.1813 +val t = (Thm.term_of o the o (TermC.parse thy)) "ff x = c * x + - 1 * q_0 * (x \<up> 2 / 2) + c_2";
 91.1814 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1815 +if UnparseC.term res = "ff x = c_2 + c * x + - 1 * q_0 / 2 * x \<up> 2"
 91.1816 +then () else error "integrate.sml: diff.behav. in simplify_I #1";
 91.1817 +
 91.1818 +\<close> ML \<open>
 91.1819 +val rls = integration;
 91.1820 +(*~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
 91.1821 +val t = (Thm.term_of o the o (TermC.parse thy)) "Integral c * x \<up> 2 + c_2 D x";
 91.1822 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1823 +if UnparseC.term res = "c_3 + c_2 * x + c / 3 * x \<up> 3"
 91.1824 +then () else error "integrate.sml: diff.behav. in integration #1";
 91.1825 +
 91.1826 +\<close> ML \<open>
 91.1827 +val t = (Thm.term_of o the o (TermC.parse thy)) "Integral 3*x \<up> 2 + 2*x + 1 D x";
 91.1828 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1829 +if UnparseC.term res = "c + x + x \<up> 2 + x \<up> 3" then () 
 91.1830 +else error "integrate.sml: diff.behav. in integration #2";
 91.1831 +
 91.1832 +\<close> text \<open> (*TOODOO  rls "integration" does NOT work anymore *)
 91.1833 +val t = (Thm.term_of o the o (TermC.parse thy))
 91.1834 +  "Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x";
 91.1835 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1836 +"Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x";
 91.1837 +if UnparseC.term res = "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)"
 91.1838 +then () else error "integrate.sml: diff.behav. in integration #3";
 91.1839 +
 91.1840 +\<close> text \<open> (*TOODOO  rls "integration" does NOT work anymore *)
 91.1841 +val t = (Thm.term_of o the o (TermC.parse thy)) ("Integral " ^ UnparseC.term res ^ " D x");
 91.1842 +val SOME (res, _) = rewrite_set_inst_ thy true subs rls t;
 91.1843 +if UnparseC.term res = "c_2 + c * x +\n1 / EI * (L * q_0 / 12 * x \<up> 3 + - 1 * q_0 / 24 * x \<up> 4)"
 91.1844 +then () else error "integrate.sml: diff.behav. in integration #4";
 91.1845 +
 91.1846 +\<close> ML \<open>
 91.1847 +"----------- rewrite 3rd integration in 7.27 ------------";
 91.1848 +"----------- rewrite 3rd integration in 7.27 ------------";
 91.1849 +"----------- rewrite 3rd integration in 7.27 ------------";
 91.1850 +val thy = @{theory "Isac_Knowledge"} (*because of Undeclared constant "Biegelinie.EI*);
 91.1851 +val t = TermC.str2term "Integral 1 / EI * ((L * q_0 * x + - 1 * q_0 * x \<up> 2) / 2) D x";
 91.1852 +val SOME(t, _)= rewrite_set_inst_ thy true subs simplify_Integral t;
 91.1853 +\<close> ML \<open>
 91.1854 +UnparseC.term t = 
 91.1855 +  "Integral 1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2) D x";
 91.1856 +(*TOODOO simplify_Integral NOW weaker *)
 91.1857 +\<close> text \<open> (* TOODOO rls simplify_Integral <------------------------------ START HERE *)
 91.1858 +if UnparseC.term t = 
 91.1859 +  "Integral 1 / EI * (L * q_0 / 2 * x + - 1 * q_0 / 2 * x \<up> 2) D x"
 91.1860 +then () else error "integrate.sml 3rd integration in 7.27, simplify_Integral";
 91.1861 +
 91.1862 +\<close> ML \<open>
 91.1863 +val SOME(t,_)= rewrite_set_inst_ thy true subs integration t;
 91.1864 +\<close> ML \<open>
 91.1865 +UnparseC.term t = 
 91.1866 +  "c + Integral 1 / EI * (L * q_0 * x / 2 + - 1 * q_0 * x \<up> 2 / 2) D x";
 91.1867 +\<close> text \<open> (*TOODOO thus rls "integration" does NOT work anymore *)
 91.1868 +if UnparseC.term t = 
 91.1869 +  "c + 1 / EI * (L * q_0 / 4 * x \<up> 2 + - 1 * q_0 / 6 * x \<up> 3)"
 91.1870 +then () else error "integrate.sml 3rd integration in 7.27, integration";
 91.1871 +
 91.1872 +
 91.1873 +\<close> ML \<open>
 91.1874 +"----------- check probem type --------------------------";
 91.1875 +"----------- check probem type --------------------------";
 91.1876 +"----------- check probem type --------------------------";
 91.1877 +val thy = @{theory Integrate};
 91.1878 +val model = {Given =["functionTerm f_f", "integrateBy v_v"],
 91.1879 +	     Where =[],
 91.1880 +	     Find  =["antiDerivative F_F"],
 91.1881 +	     With  =[],
 91.1882 +	     Relate=[]}:string ppc;
 91.1883 +val chkmodel = ((map (the o (TermC.parse thy))) o P_Model.to_list) model;
 91.1884 +val t1 = (Thm.term_of o hd) chkmodel;
 91.1885 +val t2 = (Thm.term_of o hd o tl) chkmodel;
 91.1886 +val t3 = (Thm.term_of o hd o tl o tl) chkmodel;
 91.1887 +case t3 of Const ("Integrate.antiDerivative", _) $ _ => ()
 91.1888 +	 | _ => error "integrate.sml: Integrate.antiDerivative ???";
 91.1889 +
 91.1890 +\<close> ML \<open>
 91.1891 +val model = {Given =["functionTerm f_f", "integrateBy v_v"],
 91.1892 +	     Where =[],
 91.1893 +	     Find  =["antiDerivativeName F_F"],
 91.1894 +	     With  =[],
 91.1895 +	     Relate=[]}:string ppc;
 91.1896 +val chkmodel = ((map (the o (TermC.parse thy))) o P_Model.to_list) model;
 91.1897 +val t1 = (Thm.term_of o hd) chkmodel;
 91.1898 +val t2 = (Thm.term_of o hd o tl) chkmodel;
 91.1899 +val t3 = (Thm.term_of o hd o tl o tl) chkmodel;
 91.1900 +case t3 of Const ("Integrate.antiDerivativeName", _) $ _ => ()
 91.1901 +	 | _ => error "integrate.sml: Integrate.antiDerivativeName";
 91.1902 +
 91.1903 +\<close> ML \<open>
 91.1904 +"----- compare 'Find's from problem, script, formalization -------";
 91.1905 +val {ppc,...} = Problem.from_store ["named", "integrate", "function"];
 91.1906 +val ("#Find", (Const ("Integrate.antiDerivativeName", _),
 91.1907 +	       F1_ as Free ("F_F", F1_type))) = last_elem ppc;
 91.1908 +val {scr = Prog sc,... } = MethodC.from_store ["diff", "integration", "named"];
 91.1909 +val [_,_, F2_] = formal_args sc;
 91.1910 +if F1_ = F2_ then () else error "integrate.sml: unequal find's";
 91.1911 +
 91.1912 +val ((dsc as Const ("Integrate.antiDerivativeName", _)) 
 91.1913 +	 $ Free ("ff", F3_type)) = TermC.str2term "antiDerivativeName ff";
 91.1914 +if Input_Descript.is_a dsc then () else error "integrate.sml: no description";
 91.1915 +if F1_type = F3_type then () 
 91.1916 +else error "integrate.sml: unequal types in find's";
 91.1917 +
 91.1918 +Test_Tool.show_ptyps();
 91.1919 +val pbl = Problem.from_store ["integrate", "function"];
 91.1920 +case #cas pbl of SOME (Const ("Integrate.Integrate",_) $ _) => ()
 91.1921 +	 | _ => error "integrate.sml: Integrate.Integrate ???";
 91.1922 +
 91.1923 +
 91.1924 +\<close> ML \<open>
 91.1925 +"----------- me method [diff,integration] ---------------";
 91.1926 +"----------- me method [diff,integration] ---------------";
 91.1927 +"----------- me method [diff,integration] ---------------";
 91.1928 +(*exp_CalcInt_No- 1.xml*)
 91.1929 +val p = e_pos'; val c = []; 
 91.1930 +"----- step 0: returns nxt = Model_Problem ---";
 91.1931 +val (p,_,f,nxt,_,pt) = 
 91.1932 +    CalcTreeTEST 
 91.1933 +        [(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"],
 91.1934 +          ("Integrate", ["integrate", "function"], ["diff", "integration"]))];
 91.1935 +"----- step 1: returns nxt = Add_Given \"functionTerm (x \<up> 2 + 1)\" ---";
 91.1936 +val (p,_,f,nxt,_,pt) = me nxt p c pt; (*nxt = ("Tac ", ...) --> Add_Given...*)
 91.1937 +"----- step 2: returns nxt = Add_Given \"integrateBy x\" ---";
 91.1938 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1939 +"----- step 3: returns nxt = Add_Find \"Integrate.antiDerivative FF\" ---";
 91.1940 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1941 +"----- step 4: returns nxt = Specify_Theory \"Integrate\" ---";
 91.1942 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1943 +"----- step 5: returns nxt = Specify_Problem [\"integrate\", \"function\"] ---";
 91.1944 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1945 +"----- step 6: returns nxt = Specify_Method [\"diff\", \"integration\"] ---";
 91.1946 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1947 +"----- step 7: returns nxt = Apply_Method [\"diff\", \"integration\"] ---";
 91.1948 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1949 +case nxt of (Apply_Method ["diff", "integration"]) => ()
 91.1950 +          | _ => error "integrate.sml -- me method [diff,integration] -- spec";
 91.1951 +"----- step 8: returns nxt = Rewrite_Set_Inst ([\"(''bdv'', x)\"],\"integration\")";
 91.1952 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.1953 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.1954 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.1955 +if f2str f = "c + x + 1 / 3 * x \<up> 3" then ()
 91.1956 +else error "integrate.sml -- me method [diff,integration] -- end";
 91.1957 +
 91.1958 +
 91.1959 +\<close> ML \<open>
 91.1960 +"----------- autoCalculate [diff,integration] -----------";
 91.1961 +"----------- autoCalculate [diff,integration] -----------";
 91.1962 +"----------- autoCalculate [diff,integration] -----------";
 91.1963 +reset_states ();
 91.1964 +CalcTree
 91.1965 +    [(["functionTerm (x \<up> 2 + 1)", "integrateBy x", "antiDerivative FF"], 
 91.1966 +      ("Integrate", ["integrate", "function"], ["diff", "integration"]))];
 91.1967 +Iterator 1;
 91.1968 +moveActiveRoot 1;
 91.1969 +autoCalculate 1 CompleteCalc;
 91.1970 +val ((pt,p),_) = get_calc 1; @{make_string} p; Test_Tool.show_pt pt;
 91.1971 +val (Form t,_,_) = ME_Misc.pt_extract (pt, p); 
 91.1972 +if UnparseC.term t = "c + x + 1 / 3 * x \<up> 3" then ()
 91.1973 +else error "integrate.sml -- interSteps [diff,integration] -- result";
 91.1974 +
 91.1975 +
 91.1976 +\<close> ML \<open>
 91.1977 +"----------- me method [diff,integration,named] ---------";
 91.1978 +"----------- me method [diff,integration,named] ---------";
 91.1979 +"----------- me method [diff,integration,named] ---------";
 91.1980 +(*exp_CalcInt_No- 2.xml*)
 91.1981 +val fmz = ["functionTerm (x \<up> 2 + (1::real))", 
 91.1982 +	   "integrateBy x", "antiDerivativeName F"];
 91.1983 +val (dI',pI',mI') =
 91.1984 +  ("Integrate",["named", "integrate", "function"],
 91.1985 +   ["diff", "integration", "named"]);
 91.1986 +val p = e_pos'; val c = []; 
 91.1987 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.1988 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1989 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1990 +val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Add_Find *);
 91.1991 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1992 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1993 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1994 +val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
 91.1995 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1996 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.1997 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.1998 +if f2str f = "F x = c + x + 1 / 3 * x \<up> 3" then() 
 91.1999 +else error "integrate.sml: method [diff,integration,named]";
 91.2000 +
 91.2001 +
 91.2002 +\<close> ML \<open>
 91.2003 +"----------- me met [diff,integration,named] Biegelinie.Q";
 91.2004 +"----------- me met [diff,integration,named] Biegelinie.Q";
 91.2005 +"----------- me met [diff,integration,named] Biegelinie.Q";
 91.2006 +(*exp_CalcInt_No-3.xml*)
 91.2007 +val fmz = ["functionTerm (- q_0)", 
 91.2008 +	   "integrateBy x", "antiDerivativeName Q"];
 91.2009 +val (dI',pI',mI') =
 91.2010 +  ("Biegelinie",["named", "integrate", "function"],
 91.2011 +   ["diff", "integration", "named"]);
 91.2012 +val p = e_pos'; val c = [];
 91.2013 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.2014 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2015 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2016 +(*Error Tac Q not in ...*)
 91.2017 +val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Add_Find *);
 91.2018 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2019 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2020 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2021 +val (p,_,f,nxt,_,pt) = me nxt p c pt(*nxt <- Apply_Method*);
 91.2022 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2023 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2024 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2025 +if f2str f = "Q x = c + - q_0 * x" then() 
 91.2026 +else error "integrate.sml: method [diff,integration,named] .Q";
 91.2027 +
 91.2028 +
 91.2029 +\<close> ML \<open>
 91.2030 +\<close> text \<open> (*-------^^^^^ integrate.sml------------vvv eqsystem.sml--------TOODOO-----------*)
 91.2031 +\<close>
 91.2032 +
 91.2033 +section \<open>======== check Knowledge/eqsystem.sml =============================================\<close>
 91.2034 +ML \<open>
 91.2035 +\<close> ML \<open>
 91.2036 +(* Title:  Knowledge/eqsystem.sml
 91.2037 +   Author: Walther Neuper 050826
 91.2038 +   (c) due to copyright terms
 91.2039 +*)
 91.2040 +
 91.2041 +"-----------------------------------------------------------------";
 91.2042 +"table of contents -----------------------------------------------";
 91.2043 +"-----------------------------------------------------------------";
 91.2044 +"----------- occur_exactly_in ------------------------------------";
 91.2045 +"----------- problems --------------------------------------------";
 91.2046 +"----------- rewrite-order ord_simplify_System -------------------";
 91.2047 +"----------- rewrite in [EqSystem,normalise,2x2] -----------------";
 91.2048 +"----------- rewrite example from 2nd [EqSystem,normalise,2x2] ---";
 91.2049 +"----------- rewrite in [EqSystem,top_down_substitution,2x2] -----";
 91.2050 +"----------- rewrite in [EqSystem,normalise,4x4] -----------------";
 91.2051 +"----------- script [EqSystem,top_down_substitution,2x2] Vers.1 --";
 91.2052 +"----------- refine [linear,system]-------------------------------";
 91.2053 +"----------- refine [2x2,linear,system] search error--------------";
 91.2054 +"----------- me [EqSystem,normalise,2x2] -------------------------";
 91.2055 +"----------- me [linear,system] ..normalise..top_down_sub..-------";
 91.2056 +"----------- all systems from Biegelinie -------------------------";
 91.2057 +"----------- 4x4 systems from Biegelinie -------------------------";
 91.2058 +"-----------------------------------------------------------------";
 91.2059 +"-----------------------------------------------------------------";
 91.2060 +"-----------------------------------------------------------------";
 91.2061 +
 91.2062 +val thy = @{theory "EqSystem"};
 91.2063 +val ctxt = Proof_Context.init_global thy;
 91.2064 +
 91.2065 +"----------- occur_exactly_in ------------------------------------";
 91.2066 +"----------- occur_exactly_in ------------------------------------";
 91.2067 +"----------- occur_exactly_in ------------------------------------";
 91.2068 +val all = [TermC.str2term"c", TermC.str2term"c_2", TermC.str2term"c_3"];
 91.2069 +val t = TermC.str2term"0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
 91.2070 +
 91.2071 +if occur_exactly_in [TermC.str2term"c", TermC.str2term"c_2"] all t
 91.2072 +then () else error "eqsystem.sml occur_exactly_in 1";
 91.2073 +
 91.2074 +if not (occur_exactly_in [TermC.str2term"c", TermC.str2term"c_2", TermC.str2term"c_3"] all t)
 91.2075 +then () else error "eqsystem.sml occur_exactly_in 2";
 91.2076 +
 91.2077 +if not (occur_exactly_in [TermC.str2term"c_2"] all t)
 91.2078 +then () else error "eqsystem.sml occur_exactly_in 3";
 91.2079 +
 91.2080 +val t = TermC.str2term"[c,c_2] from [c,c_2,c_3] occur_exactly_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
 91.2081 +eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
 91.2082 +val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
 91.2083 +if str = "[c, c_2] from [c, c_2,\n" ^
 91.2084 +  "               c_3] occur_exactly_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = True"
 91.2085 +then () else error "eval_occur_exactly_in [c, c_2]";
 91.2086 +
 91.2087 +val t = TermC.str2term ("[c,c_2,c_3] from [c,c_2,c_3] occur_exactly_in " ^
 91.2088 +		  "- 1 * q_0 * L \<up> 2 / 2 + L * c + c_2");
 91.2089 +val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
 91.2090 +if str = "[c, c_2,\n c_3] from [c, c_2,\n" ^
 91.2091 +"            c_3] occur_exactly_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = False"
 91.2092 +then () else error "eval_occur_exactly_in [c, c_2, c_3]";
 91.2093 +
 91.2094 +val t = TermC.str2term"[c_2] from [c,c_2,c_3] occur_exactly_in \
 91.2095 +		\- 1 * q_0 * L \<up> 2 / 2 + L * c + c_2";
 91.2096 +val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
 91.2097 +if str = "[c_2] from [c, c_2,\n" ^
 91.2098 +  "            c_3] occur_exactly_in - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2 = False"
 91.2099 +then () else error "eval_occur_exactly_in [c, c_2, c_3]";
 91.2100 +
 91.2101 +val t = TermC.str2term"[] from [c,c_2,c_3] occur_exactly_in 0";
 91.2102 +val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
 91.2103 +if str = "[] from [c, c_2, c_3] occur_exactly_in 0 = True" then ()
 91.2104 +else error "eval_occur_exactly_in [c, c_2, c_3]";
 91.2105 +
 91.2106 +val t = 
 91.2107 +    TermC.str2term
 91.2108 +	"[] from [c, c_2, c_3, c_4] occur_exactly_in - 1 * (q_0 * L \<up> 2) /2";
 91.2109 +val SOME (str, t') = eval_occur_exactly_in 0 "EqSystem.occur_exactly_in" t 0;
 91.2110 +if str = "[] from [c, c_2, c_3, c_4] occur_exactly_in \
 91.2111 +	 \- 1 * (q_0 * L \<up> 2) / 2 = True" then ()
 91.2112 +else error "eval_occur_exactly_in [c, c_2, c_3, c_4]";
 91.2113 +
 91.2114 +"----------- problems --------------------------------------------";
 91.2115 +"----------- problems --------------------------------------------";
 91.2116 +"----------- problems --------------------------------------------";
 91.2117 +val t = TermC.str2term "Length [x+y=1,y=2] = 2";
 91.2118 +TermC.atomty t;
 91.2119 +val testrls = Rule_Set.append_rules "testrls" Rule_Set.empty 
 91.2120 +			 [(Thm ("LENGTH_NIL",ThmC.numerals_to_Free @{thm LENGTH_NIL})),
 91.2121 +			  (Thm ("LENGTH_CONS",ThmC.numerals_to_Free @{thm LENGTH_CONS})),
 91.2122 +			  Eval ("Groups.plus_class.plus", eval_binop "#add_"),
 91.2123 +			  Eval ("HOL.eq",eval_equal "#equal_")
 91.2124 +			  ];
 91.2125 +val SOME (t',_) = rewrite_set_ thy false testrls t;
 91.2126 +if UnparseC.term t' = "True" then () 
 91.2127 +else error "eqsystem.sml: length_ [x+y=1,y=2] = 2";
 91.2128 +
 91.2129 +val SOME t = TermC.parse thy "solution LL";
 91.2130 +TermC.atomty (Thm.term_of t);
 91.2131 +val SOME t = TermC.parse thy "solution LL";
 91.2132 +TermC.atomty (Thm.term_of t);
 91.2133 +
 91.2134 +val t = TermC.str2term 
 91.2135 +"(tl (tl (tl v_s))) from v_s occur_exactly_in (NTH 1 (e_s::bool list))";
 91.2136 +TermC.atomty t;
 91.2137 +val t = TermC.str2term ("(tl (tl (tl [c, c_2, c_3, c_4]))) from [c, c_2, c_3, c_4] occur_exactly_in " ^
 91.2138 +  "(NTH 1 [c_4 = 1, 2 = 2, 3 = 3, 4 = 4])");
 91.2139 +(*----- broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite -----\\
 91.2140 +        assume flawed test setup hidden by "handle _ => ..."
 91.2141 +        ERROR rewrite__set_ called with 'Erls' for '1 < 1'
 91.2142 +val SOME (t,_) = 
 91.2143 +    rewrite_set_ thy true 
 91.2144 +		 (Rule_Set.append_rules "prls_" Rule_Set.empty 
 91.2145 +			     [Thm ("NTH_CONS",ThmC.numerals_to_Free @{thm NTH_CONS}),
 91.2146 +			      Thm ("NTH_NIL",ThmC.numerals_to_Free @{thm NTH_NIL}),
 91.2147 +			      Thm ("TL_CONS",ThmC.numerals_to_Free @{thm tl_Cons}),
 91.2148 +			      Thm ("TL_NIL",ThmC.numerals_to_Free @{thm tl_Nil}),
 91.2149 +			      Eval ("EqSystem.occur_exactly_in", eval_occur_exactly_in "#eval_occur_exactly_in_")
 91.2150 +			      ]) t;
 91.2151 +if t = @{term True} then () 
 91.2152 +else error "eqsystem.sml ..occur_exactly_in (nth_ 1 [c_4..";
 91.2153 +        broken in child of.1790e1073acc : eliminate "handle _ => ..." from Rewrite.rewrite ---//*)
 91.2154 +
 91.2155 +
 91.2156 +"----------- rewrite-order ord_simplify_System -------------------";
 91.2157 +"----------- rewrite-order ord_simplify_System -------------------";
 91.2158 +"----------- rewrite-order ord_simplify_System -------------------";
 91.2159 +"M_b x = c * x + - 1 * q_0 * (x \<up> 2 / 2) + c_2";
 91.2160 +"--- add.commute ---"; (* ... add.commute cf. b42e334c97ee *)
 91.2161 +if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \<up> 2 / 2)", 
 91.2162 +				       TermC.str2term"c * x") then ()
 91.2163 +else error "integrate.sml, (- 1 * q_0 * (x \<up> 2 / 2)) < (c * x) not#1";
 91.2164 +
 91.2165 +if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \<up> 2 / 2)", 
 91.2166 +				       TermC.str2term"c_2") then ()
 91.2167 +else error "integrate.sml, (- 1 * q_0 * (x \<up> 2 / 2)) < (c_2) not#2";
 91.2168 +
 91.2169 +if ord_simplify_System false thy [] (TermC.str2term"c * x", 
 91.2170 +				       TermC.str2term"c_2") then ()
 91.2171 +else error "integrate.sml, (c * x) < (c_2) not#3";
 91.2172 +
 91.2173 +"--- mult.commute ---";
 91.2174 +if ord_simplify_System false thy [] (TermC.str2term"x * c", 
 91.2175 +				       TermC.str2term"c * x") then ()
 91.2176 +else error "integrate.sml, (x * c) < (c * x) not#4";
 91.2177 +
 91.2178 +if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \<up> 2 / 2) * c", 
 91.2179 +				       TermC.str2term"- 1 * q_0 * c * (x \<up> 2 / 2)") 
 91.2180 +then () else error "integrate.sml, (. * .) < (. * .) not#5";
 91.2181 +
 91.2182 +if ord_simplify_System false thy [] (TermC.str2term"- 1 * q_0 * (x \<up> 2 / 2) * c", 
 91.2183 +				       TermC.str2term"c * - 1 * q_0 * (x \<up> 2 / 2)") 
 91.2184 +then () else error "integrate.sml, (. * .) < (. * .) not#6";
 91.2185 +
 91.2186 +
 91.2187 +\<close> ML \<open>
 91.2188 +"----------- rewrite in [EqSystem,normalise,2x2] -----------------";
 91.2189 +"----------- rewrite in [EqSystem,normalise,2x2] -----------------";
 91.2190 +"----------- rewrite in [EqSystem,normalise,2x2] -----------------";
 91.2191 +val t = TermC.str2term"[0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2,\
 91.2192 +	        \0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2]";
 91.2193 +val bdvs = [(TermC.str2term"bdv_1",TermC.str2term"c"),
 91.2194 +	    (TermC.str2term"bdv_2",TermC.str2term"c_2")];
 91.2195 +val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
 91.2196 +\<close> ML \<open>
 91.2197 +UnparseC.term t =    "[0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2), 0 = - 0 + c_2]"
 91.2198 +\<close> text \<open>(* TOODOO: simplify_System_parenthesized \<longrightarrow> - 0 + c_4       ^^^^^^^^^^*)
 91.2199 +(* inhertited errors -----------------------------------------------------------------------\\* )
 91.2200 +if UnparseC.term t = "[0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2), 0 = c_2]"
 91.2201 +then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.1";
 91.2202 +
 91.2203 +val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
 91.2204 +if UnparseC.term t = "[L * c + c_2 = 0 + - 1 * (- 1 * q_0 * L \<up> 2 / 2), c_2 = 0]"
 91.2205 +then () else error "eqsystem.sml rewrite in 2x2 isolate_bdvs";
 91.2206 +
 91.2207 +val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System t;
 91.2208 +if UnparseC.term t = "[L * c + c_2 = q_0 * L \<up> 2 / 2, c_2 = 0]"
 91.2209 +then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.2";
 91.2210 +
 91.2211 +"--- 3--- see EqSystem.thy (*..if replaced by 'and' ...*)";
 91.2212 +val SOME (t,_) = rewrite_set_ thy true order_system t;
 91.2213 +if UnparseC.term t = "[c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]"
 91.2214 +then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.3";
 91.2215 +( * inhertited errors -----------------------------------------------------------------------//*)
 91.2216 +
 91.2217 +\<close> ML \<open>
 91.2218 +"----------- rewrite example from 2nd [EqSystem,normalise,2x2] ---";
 91.2219 +"----------- rewrite example from 2nd [EqSystem,normalise,2x2] ---";
 91.2220 +"----------- rewrite example from 2nd [EqSystem,normalise,2x2] ---";
 91.2221 +val thy = @{theory "Isac_Knowledge"} (*because of Undeclared constant "Biegelinie.EI*);
 91.2222 +val t = 
 91.2223 +    TermC.str2term"[0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 \<up> 3 +         \
 91.2224 +	    \                                     - 1 * q_0 / 24 * 0 \<up> 4),\
 91.2225 +	    \ 0 = c_2 + c * L + 1 / EI * (L * q_0 / 12 * L \<up> 3 +         \
 91.2226 +	    \                                     - 1 * q_0 / 24 * L \<up> 4)]";
 91.2227 +val SOME (t,_) = rewrite_set_ thy true norm_Rational t;
 91.2228 +if UnparseC.term t =
 91.2229 +    "[0 = c_2,\n 0 = (24 * c_2 * EI + 24 * L * c * EI + L \<up> 4 * q_0) / (24 * EI)]"
 91.2230 +then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.0b";
 91.2231 +
 91.2232 +val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
 91.2233 +if UnparseC.term t = (*"[0 = 0 / EI + c_2, 0 = q_0 * L \<up> 4 / (24 * EI) + (L * c + c_2)]"*)
 91.2234 +                           "[0 = c_2, 0 = q_0 * L \<up> 4 / (24 * EI) + (L * c + c_2)]"
 91.2235 +then () else error "eqsystem.sml rewrite in 2x2 simplify_System_par.1b";
 91.2236 +
 91.2237 +val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
 91.2238 +if UnparseC.term t = (*"[c_2 = 0 + - 1 * (0 / EI),\n L * c + c_2 = 0 + - 1 * (q_0 * L \<up> 4 / (24 * EI))]"*)
 91.2239 +                                    "[c_2 = 0, L * c + c_2 = 0 + - 1 * (q_0 * L \<up> 4 / (24 * EI))]"
 91.2240 +then () else error "eqsystem.sml rewrite in 2x2 isolate_bdvs b";
 91.2241 +
 91.2242 +val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System t;
 91.2243 +if UnparseC.term t = (*"[c_2 = 0 / EI, L * c + c_2 = - 1 * q_0 * L \<up> 4 / (24 * EI)]"*)
 91.2244 +                       "[c_2 = 0, L * c + c_2 = - 1 * q_0 * L \<up> 4 / (24 * EI)]"
 91.2245 +then () else error "eqsystem.sml rewrite in 2x2 simplify_System.2b";
 91.2246 +
 91.2247 +val xxx = rewrite_set_ thy true order_system t;
 91.2248 +if is_none xxx
 91.2249 +then () else error "eqsystem.sml rewrite in 2x2 simplify_System.3b";
 91.2250 +
 91.2251 +
 91.2252 +\<close> ML \<open>
 91.2253 +"----------- rewrite in [EqSystem,top_down_substitution,2x2] -----";
 91.2254 +"----------- rewrite in [EqSystem,top_down_substitution,2x2] -----";
 91.2255 +"----------- rewrite in [EqSystem,top_down_substitution,2x2] -----";
 91.2256 +val e1__ = TermC.str2term "c_2 = 77";
 91.2257 +val e2__ = TermC.str2term "L * c + c_2 = q_0 * L \<up> 2 / 2";
 91.2258 +val bdvs = [(TermC.str2term"bdv_1",TermC.str2term"c"),
 91.2259 +	    (TermC.str2term"bdv_2",TermC.str2term"c_2")];
 91.2260 +val SOME (e2__,_) = rewrite_terms_ thy dummy_ord Rule_Set.Empty [e1__] e2__;
 91.2261 +if UnparseC.term e2__ = "L * c + 77 = q_0 * L \<up> 2 / 2" then ()
 91.2262 +else error "eqsystem.sml top_down_substitution,2x2] subst";
 91.2263 +
 91.2264 +\<close> ML \<open>
 91.2265 +val SOME (e2__,_) = 
 91.2266 +    rewrite_set_inst_ thy true bdvs simplify_System_parenthesized e2__;
 91.2267 +if UnparseC.term e2__ = "77 + L * c = q_0 * L \<up> 2 / 2" then ()
 91.2268 +else error "eqsystem.sml top_down_substitution,2x2] simpl_par";
 91.2269 +
 91.2270 +\<close> ML \<open>
 91.2271 +val SOME (e2__,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs e2__;
 91.2272 +if UnparseC.term e2__ = "c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L" then ()
 91.2273 +else error "eqsystem.sml top_down_substitution,2x2] isolate";
 91.2274 +
 91.2275 +\<close> ML \<open>
 91.2276 +val t = TermC.str2term "[c_2 = 77, c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L]";
 91.2277 +val SOME (t,_) = rewrite_set_ thy true order_system t;
 91.2278 +if UnparseC.term t = "[c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L, c_2 = 77]" then ()
 91.2279 +else error "eqsystem.sml top_down_substitution,2x2] order_system";
 91.2280 +
 91.2281 +\<close> ML \<open>
 91.2282 +if not (ord_simplify_System
 91.2283 +	    false thy [] 
 91.2284 +	    (TermC.str2term"[c_2 = 77, c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L]", 
 91.2285 +	     TermC.str2term"[c = (q_0 * L \<up> 2 / 2 + - 1 * 77) / L, c_2 = 77]")) 
 91.2286 +then () else error "eqsystem.sml, order_result rew_ord";
 91.2287 +
 91.2288 +
 91.2289 +\<close> ML \<open>
 91.2290 +"----------- rewrite in [EqSystem,normalise,4x4] -----------------";
 91.2291 +"----------- rewrite in [EqSystem,normalise,4x4] -----------------";
 91.2292 +"----------- rewrite in [EqSystem,normalise,4x4] -----------------";
 91.2293 +(*STOPPED.WN06?: revise rewrite in [EqSystem,normalise,4x4] from before 0609*)
 91.2294 +val t = TermC.str2term (
 91.2295 +  "[(0::real) = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c_3 + c_4, " ^ 
 91.2296 +  "(0::real) = - 1 * q_0 * L \<up> 2 / 2 + L * c_3 + c_4, " ^ 
 91.2297 +  "c + c_2 + c_3 + c_4 = 0, " ^ 
 91.2298 +  "c_2 + c_3 + c_4 = 0]");
 91.2299 +\<close> ML \<open>
 91.2300 +val bdvs = [(TermC.str2term"bdv_1::real",TermC.str2term"c::real"),
 91.2301 +	    (TermC.str2term"bdv_2::real",TermC.str2term"c_2::real"),
 91.2302 +	    (TermC.str2term"bdv_3::real",TermC.str2term"c_3::real"),
 91.2303 +	    (TermC.str2term"bdv_4::real",TermC.str2term"c_4::real")];
 91.2304 +val SOME (t, _) = 
 91.2305 +    rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
 91.2306 +\<close> ML \<open>
 91.2307 +UnparseC.term t =
 91.2308 +              "[0 = - 0 + c_4, 0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c_3 + c_4),\n c + (c_2 + (c_3 + c_4)) = 0, c_2 + (c_3 + c_4) = 0]"
 91.2309 +\<close> text \<open> (*         ^^^^^^- TOODOO: simplify_System_parenthesized \<longrightarrow> - 0 + c_4*)
 91.2310 +(* inhertited errors -----------------------------------------------------------------------\\* )
 91.2311 +if UnparseC.term t = "[0 = c_4, 0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c_3 + c_4), c + (c_2 + (c_3 + c_4)) = 0, c_2 + (c_3 + c_4) = 0]"
 91.2312 +then () else error "eqsystem.sml rewrite in 4x4 simplify_System_paren";
 91.2313 +
 91.2314 +val SOME (t,_) = rewrite_set_inst_ thy true bdvs isolate_bdvs t;
 91.2315 +if UnparseC.term t = "[c_4 = 0, \
 91.2316 +	        \L * c_3 + c_4 = 0 + - 1 * (- 1 * q_0 * L \<up> 2 / 2),\n \
 91.2317 +		\c + (c_2 + (c_3 + c_4)) = 0, c_2 + (c_3 + c_4) = 0]"
 91.2318 +then () else error "eqsystem.sml rewrite in 4x4 isolate_bdvs";
 91.2319 +
 91.2320 +val SOME(t,_)= rewrite_set_inst_ thy true bdvs simplify_System_parenthesized t;
 91.2321 +if UnparseC.term t = "[c_4 = 0,\
 91.2322 +		\ L * c_3 + c_4 = q_0 * L \<up> 2 / 2,\
 91.2323 +		\ c + (c_2 + (c_3 + c_4)) = 0,\n\
 91.2324 +		\ c_2 + (c_3 + c_4) = 0]"
 91.2325 +then () else error "eqsystem.sml rewrite in 4x4 simplify_System_p..2";
 91.2326 +
 91.2327 +val SOME (t,_) = rewrite_set_ thy true order_system t;
 91.2328 +if UnparseC.term t = "[c_4 = 0,\
 91.2329 +		\ L * c_3 + c_4 = q_0 * L \<up> 2 / 2,\
 91.2330 +		\ c_2 + (c_3 + c_4) = 0,\n\
 91.2331 +		\ c + (c_2 + (c_3 + c_4)) = 0]"
 91.2332 +then () else error "eqsystem.sml rewrite in 4x4 order_system";
 91.2333 +( * inhertited errors -----------------------------------------------------------------------//*)
 91.2334 +
 91.2335 +\<close> ML \<open>
 91.2336 +"----------- refine [linear,system]-------------------------------";
 91.2337 +"----------- refine [linear,system]-------------------------------";
 91.2338 +"----------- refine [linear,system]-------------------------------";
 91.2339 +val fmz =
 91.2340 +  ["equalities [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2," ^
 91.2341 +               "0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + (c_2::real)]", 
 91.2342 +	   "solveForVars [c, c_2]", "solution LL"];
 91.2343 +
 91.2344 +(*WN120313 in "solution L" above "Refine.refine fmz ["LINEAR", "system"]" caused an error...*)
 91.2345 +"~~~~~ fun Refine.refine, args:"; val ((fmz: Formalise.model), (pblID:Problem.id)) = (fmz, ["LINEAR", "system"]);
 91.2346 +"~~~~~ fun refin', args:"; val ((pblRD: Problem.id_reverse), fmz, pbls, ((Store.Node (pI, [py], [])): Problem.T Store.node)) =
 91.2347 +   ((rev o tl) pblID, fmz, [(*match list*)],
 91.2348 +     ((Store.Node ("LINEAR", [Problem.from_store ["LINEAR", "system"]], [])): Problem.T Store.node));
 91.2349 +      val {thy, ppc, where_, prls, ...} = py ;
 91.2350 +"~~~~~ fun O_Model.init, args:"; val (fmz, thy, pbt) = (fmz, thy, ppc);
 91.2351 +        val ctxt = Proof_Context.init_global thy;
 91.2352 +"~~~~~ fun declare_constraints, args:"; val (t, ctxt) = (nth 1 fmz, ctxt);
 91.2353 +      fun get_vars ((v,T)::vs) = (case raw_explode v |> Library.read_int of
 91.2354 +              (_, _::_) => (Free (v,T)::get_vars vs)
 91.2355 +            | (_, []  ) => get_vars vs) (*filter out nums as long as 
 91.2356 +                                          we have Free ("123",_)*)
 91.2357 +        | get_vars [] = [];
 91.2358 +                                        t = "equalities [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,"^
 91.2359 +                                            "0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + (c_2::real)]";
 91.2360 +      val ts = Term.add_frees (Syntax.read_term ctxt t) [] |> get_vars;
 91.2361 +val ctxt = Variable.declare_constraints (nth 1 ts) ctxt;
 91.2362 +val ctxt = Variable.declare_constraints (nth 2 ts) ctxt;
 91.2363 +val ctxt = Variable.declare_constraints (nth 3 ts) ctxt;
 91.2364 +val ctxt = Variable.declare_constraints (nth 4 ts) ctxt;
 91.2365 +                                        val t = nth 2 fmz; t = "solveForVars [c, c_2]";
 91.2366 +      val ts = Term.add_frees (Syntax.read_term ctxt t) [] |> get_vars;
 91.2367 +val ctxt = Variable.declare_constraints (nth 1 ts) ctxt;
 91.2368 +                                        val t = nth 3 fmz; t = "solution LL";
 91.2369 +      (*(Syntax.read_term ctxt t); 
 91.2370 +Type unification failed: Clash of types "real" and "_ list"
 91.2371 +Type error in application: incompatible operand type
 91.2372 +
 91.2373 +Operator:  solution :: bool list \<Rightarrow> toreall
 91.2374 +Operand:   L :: real                 ========== L was already present in equalities ========== *)
 91.2375 +
 91.2376 +\<close> ML \<open>
 91.2377 +"===== case 1 =====";
 91.2378 +val matches = Refine.refine fmz ["LINEAR", "system"];
 91.2379 +case matches of 
 91.2380 + [M_Match.Matches (["LINEAR", "system"], _),
 91.2381 +  M_Match.Matches (["2x2", "LINEAR", "system"], _),
 91.2382 +  M_Match.NoMatch (["triangular", "2x2", "LINEAR", "system"], _),
 91.2383 +		  M_Match.Matches (["normalise", "2x2", "LINEAR", "system"],
 91.2384 +			    {Find = [Correct "solution LL"],
 91.2385 +			     With = [],
 91.2386 +			     Given =
 91.2387 +			       [Correct
 91.2388 +				"equalities\n [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\n  0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2]",
 91.2389 +				        Correct "solveForVars [c, c_2]"],
 91.2390 +				     Where = [],
 91.2391 +				     Relate = []})] => ()
 91.2392 +| _ => error "eqsystem.sml Refine.refine ['normalise','2x2'...]";
 91.2393 +
 91.2394 +\<close> ML \<open>
 91.2395 +"===== case 2 =====";
 91.2396 +val fmz = ["equalities [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]", 
 91.2397 +	   "solveForVars [c, c_2]", "solution LL"];
 91.2398 +val matches = Refine.refine fmz ["LINEAR", "system"];
 91.2399 +case matches of [_,_,
 91.2400 +		  M_Match.Matches
 91.2401 +		    (["triangular", "2x2", "LINEAR", "system"],
 91.2402 +		      {Find = [Correct "solution LL"],
 91.2403 +		       With = [],
 91.2404 +		       Given =
 91.2405 +		        [Correct "equalities [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]",
 91.2406 +		         Correct "solveForVars [c, c_2]"],
 91.2407 +		       Where = [Correct
 91.2408 +			"tl [c, c_2] from [c, c_2] occur_exactly_in NTH 1\n      [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]",
 91.2409 +			                Correct
 91.2410 +				"[c, c_2] from [c, c_2] occur_exactly_in NTH 2\n   [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]"],
 91.2411 +		       Relate = []})] => ()
 91.2412 +| _ => error "eqsystem.sml Refine.refine ['triangular','2x2'...]";
 91.2413 +
 91.2414 +\<close> ML \<open>
 91.2415 +(*WN051014-----------------------------------------------------------------------------------\\
 91.2416 +  the above 'val matches = Refine.refine fmz ["LINEAR", "system"]'
 91.2417 +  didn't work anymore; we investigated in these steps:(**)
 91.2418 +val fmz = ["equalities [(c_2::real) = 0, L * (c::real) + c_2 = q_0 * L \<up> 2 / 2]", 
 91.2419 +	  "solveForVars [(c::real), (c_2::real)]", "solution LL"];
 91.2420 +val matches = Refine.refine fmz ["triangular", "2x2", "LINEAR", "system"];
 91.2421 +(*... resulted in 
 91.2422 +   False "[c, c_2] from_ [c, c_2] occur_exactly_in nth_ 2\n    
 91.2423 +          [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]"]*)
 91.2424 +val t = TermC.str2term ("[(c::real), (c_2::real)] from [(c::real), (c_2::real)] occur_exactly_in NTH 2" ^   
 91.2425 +		  "[(c_2::real) = 0, L * (c::real) + c_2 = q_0 * L \<up> 2 / 2]");
 91.2426 +Rewrite.trace_on := false; (*true false*)
 91.2427 +val SOME (t', _) = rewrite_set_ thy false prls_triangular t;
 91.2428 +(*found:...
 91.2429 +##  try thm: NTH_CONS
 91.2430 +###  eval asms: 1 < 2 + - 1
 91.2431 +==> nth_ (2 + - 1) [L * c + c_2 = q_0 * L \<up> 2 / 2] =
 91.2432 +    nth_ (2 + - 1 + - 1) []
 91.2433 +####  rls: erls_prls_triangular on: 1 < 2 + - 1
 91.2434 +#####  try calc: op <'
 91.2435 +###  asms accepted: ["1 < 2 + - 1"]   stored: ["1 < 2 + - 1"]
 91.2436 +
 91.2437 +... i.e Eval ("Groups.plus_class.plus", eval_binop "#add_") was missing in erls_prls_triangular*)
 91.2438 +--------------------------------------------------------------------------------------------//*)
 91.2439 +
 91.2440 +\<close> ML \<open>
 91.2441 +"===== case 3: relaxed preconditions for triangular system =====";
 91.2442 +val fmz = ["equalities [L * q_0 = c,                               \
 91.2443 +	   \            0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2,\
 91.2444 +	   \            0 = c_4,                                           \
 91.2445 +	   \            0 = c_3]", 
 91.2446 +	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
 91.2447 +(*============ inhibit exn WN120314 TODO: investigate type error (same) in these 2 cases:
 91.2448 +probably exn thrown by fun declare_constraints
 91.2449 +/-------------------------------------------------------\
 91.2450 +Type unification failed
 91.2451 +Type error in application: incompatible operand type
 91.2452 +
 91.2453 +Operator:  op # c_3 :: 'a list \<Rightarrow> 'a list
 91.2454 +Operand:   [c_4] :: 'b list
 91.2455 +\-------------------------------------------------------/
 91.2456 +val TermC.matches = Refine.refine fmz ["LINEAR", "system"];
 91.2457 +case TermC.matches of 
 91.2458 +    [M_Match.Matches (["LINEAR", "system"], _),
 91.2459 +     M_Match.NoMatch (["2x2", "LINEAR", "system"], _),
 91.2460 +     M_Match.NoMatch (["3x3", "LINEAR", "system"], _),
 91.2461 +     M_Match.Matches (["4x4", "LINEAR", "system"], _),
 91.2462 +     M_Match.NoMatch (["triangular", "4x4", "LINEAR", "system"], _),
 91.2463 +     M_Match.Matches (["normalise", "4x4", "LINEAR", "system"], _)] => ()
 91.2464 +  | _ => error "eqsystem.sml: Refine.refine relaxed triangular sys M_Match.NoMatch";
 91.2465 +(*WN060914 does NOT match, because 3rd and 4th equ are not ordered*)
 91.2466 +
 91.2467 +"===== case 4 =====";
 91.2468 +val fmz = ["equalities [L * q_0 = c,                                       \
 91.2469 +	   \            0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2,\
 91.2470 +	   \            0 = c_3,                           \
 91.2471 +	   \            0 = c_4]", 
 91.2472 +	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
 91.2473 +val TermC.matches = Refine.refine fmz ["triangular", "4x4", "LINEAR", "system"];
 91.2474 +case TermC.matches of 
 91.2475 +    [M_Match.Matches (["triangular", "4x4", "LINEAR", "system"], _)] => ()
 91.2476 +  | _ => error "eqsystem.sml: Refine.refine relaxed triangular sys M_Match.NoMatch";
 91.2477 +val TermC.matches = Refine.refine fmz ["LINEAR", "system"];
 91.2478 +============ inhibit exn WN120314 ==============================================*)
 91.2479 +
 91.2480 +\<close> ML \<open>
 91.2481 +"----------- Refine.refine [2x2,linear,system] search error--------------";
 91.2482 +"----------- Refine.refine [2x2,linear,system] search error--------------";
 91.2483 +"----------- Refine.refine [2x2,linear,system] search error--------------";
 91.2484 +(*didn't go into ["2x2", "LINEAR", "system"]; 
 91.2485 +  we investigated in these steps:*)
 91.2486 +val fmz = ["equalities [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\
 91.2487 +	               \0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2]", 
 91.2488 +	   "solveForVars [c, c_2]", "solution LL"];
 91.2489 +Rewrite.trace_on := false; (*true false*)
 91.2490 +val matches = Refine.refine fmz ["2x2", "LINEAR", "system"];
 91.2491 +Rewrite.trace_on := false; (*true false*)
 91.2492 +(*default_print_depth 11;*) TermC.matches; (*default_print_depth 3;*)
 91.2493 +(*brought: 'False "length_ es_ = 2"'*)
 91.2494 +
 91.2495 +(*-----fun refin' (pblRD:Problem.id_reverse) fmz pbls ((Store.Node (pI,[py],[])):pbt Store.store) =
 91.2496 +(* val ((pblRD:Problem.id_reverse), fmz, pbls, ((Store.Node (pI,[py],[])):pbt Store.store)) =
 91.2497 +       (rev ["LINEAR", "system"], fmz, [(*match list*)],
 91.2498 +	((Store.Node ("2x2",[Problem.from_store ["2x2", "LINEAR", "system"]],[])):pbt Store.store));
 91.2499 +   *)
 91.2500 +> show_types:=true; UnparseC.term (hd where_); show_types:=false;
 91.2501 +val it = "length_ (es_::real list) = (2::real)" : string
 91.2502 +
 91.2503 +=========================================================================\
 91.2504 +-------fun Problem.prep_input
 91.2505 +(* val (thy, (pblID, dsc_dats: (string * (string list)) list, 
 91.2506 +		  ev:rls, ca: string option, metIDs:metID list)) =
 91.2507 +       (EqSystem.thy, (["system"],
 91.2508 +		       [("#Given" ,["equalities es_", "solveForVars v_s"]),
 91.2509 +			("#Find"  ,["solution ss___"](*___ is copy-named*))
 91.2510 +			],
 91.2511 +		       Rule_Set.append_rules "empty" Rule_Set.empty [(*for preds in where_*)], 
 91.2512 +		       SOME "solveSystem es_ v_s", 
 91.2513 +		       []));
 91.2514 +   *)
 91.2515 +> val [("#Given", [equalities_es_, "solveForVars v_s"])] = gi;
 91.2516 +val equalities_es_ = "equalities es_" : string
 91.2517 +> val (dd, ii) = (split_did o Thm.term_of o the o (TermC.parse thy)) equalities_es_;
 91.2518 +> show_types:=true; UnparseC.term ii; show_types:=false;
 91.2519 +val it = "es_::bool list" : string
 91.2520 +~~~~~~~~~~~~~~~ \<up> \<up> \<up>  OK~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 91.2521 +
 91.2522 +> val {where_,...} = Problem.from_store ["2x2", "LINEAR", "system"];
 91.2523 +> show_types:=true; UnparseC.term (hd where_); show_types:=false;
 91.2524 +
 91.2525 +=========================================================================/
 91.2526 +
 91.2527 +-----fun refin' ff:
 91.2528 +> (writeln o (I_Model.to_string (ThyC.to_ctxt @{theory Isac_Knowledge}))) itms;
 91.2529 +[
 91.2530 +(1 ,[1] ,true ,#Given ,Cor equalities
 91.2531 + [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
 91.2532 +  0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2] ,(es_, [[0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
 91.2533 + 0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2]])),
 91.2534 +(2 ,[1] ,true ,#Given ,Cor solveForVars [c, c_2] ,(v_s, [[c, c_2]])),
 91.2535 +(3 ,[1] ,true ,#Find ,Cor solution L ,(ss___, [L]))]
 91.2536 +
 91.2537 +> (writeln o pres2str) pre';
 91.2538 +[
 91.2539 +(false, length_ es_ = 2),
 91.2540 +(true, length_ [c, c_2] = 2)]
 91.2541 +
 91.2542 +----- fun match_oris':
 91.2543 +> (writeln o (I_Model.to_string (ThyC.to_ctxt @{theory Isac_Knowledge}))) itms;
 91.2544 +> (writeln o pres2str) pre';
 91.2545 +..as in refin'
 91.2546 +
 91.2547 +----- fun check in Pre_Conds.
 91.2548 +> (writeln o env2str) env;
 91.2549 +["
 91.2550 +(es_, [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,
 91.2551 + 0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2])", "
 91.2552 +(v_s, [c, c_2])", "
 91.2553 +(ss___, L)"]
 91.2554 +
 91.2555 +> val es_ = (fst o hd) env;
 91.2556 +val es_ = Free ("es_", "bool List.list") : Term.term
 91.2557 +
 91.2558 +> val pre1 = hd pres;
 91.2559 +TermC.atomty pre1;
 91.2560 +***
 91.2561 +*** Const (op =, [real, real] => bool)
 91.2562 +*** . Const (ListG.length_, real list => real)
 91.2563 +*** . . Free (es_, real list)
 91.2564 +~~~~~~~~~~~~~~~~~~~ \<up> \<up> \<up>  should be bool list~~~~~~~~~~~~~~~~~~~
 91.2565 +*** . Free (2, real)
 91.2566 +***
 91.2567 +
 91.2568 +THE REASON WAS A non-type-constrained variable IN #WHERE OF PROBLEM
 91.2569 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 91.2570 +*)
 91.2571 +
 91.2572 +"----------- me [EqSystem,normalise,2x2] -------------------------";
 91.2573 +"----------- me [EqSystem,normalise,2x2] -------------------------";
 91.2574 +"----------- me [EqSystem,normalise,2x2] -------------------------";
 91.2575 +val fmz = ["equalities [0 = - 1 * q_0 * 0 \<up> 2 / 2 + 0 * c + c_2,\
 91.2576 +	               \0 = - 1 * q_0 * L \<up> 2 / 2 + L * c + c_2]", 
 91.2577 +	   "solveForVars [c, c_2]", "solution LL"];
 91.2578 +val (dI',pI',mI') =
 91.2579 +  ("Biegelinie",["normalise", "2x2", "LINEAR", "system"],
 91.2580 +   ["EqSystem", "normalise", "2x2"]);
 91.2581 +val p = e_pos'; val c = []; 
 91.2582 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.2583 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2584 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2585 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2586 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2587 +case nxt of Specify_Method ["EqSystem", "normalise", "2x2"] => ()
 91.2588 +	  | _ => error "eqsystem.sml [EqSystem,normalise,2x2] specify";
 91.2589 +
 91.2590 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2591 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2592 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f(*["(bdv_1, c)", "(bdv_2, hd (tl [c, c_2] ... corrected srls; ran only AFTER use"RCODE-root.sml", store_met was NOT SUFFICIENT*);
 91.2593 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2594 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2595 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2596 +case nxt of
 91.2597 +    (Subproblem ("Biegelinie", ["triangular", "2x2", "LINEAR",_])) => ()
 91.2598 +  | _ => error "eqsystem.sml me [EqSystem,normalise,2x2] SubProblem";
 91.2599 +
 91.2600 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2601 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2602 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2603 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2604 +case nxt of
 91.2605 +    (Specify_Method ["EqSystem", "top_down_substitution", "2x2"]) => ()
 91.2606 +  | _ => error "eqsystem.sml me [EqSys...2x2] top_down_substitution";
 91.2607 +
 91.2608 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2609 +val PblObj {probl,...} = get_obj I pt [5];
 91.2610 +    (writeln o (I_Model.to_string (ThyC.to_ctxt @{theory Isac_Knowledge}))) probl;
 91.2611 +(*[
 91.2612 +(1 ,[1] ,true ,#Given ,Cor equalities [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2] ,(es_, [[c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]])),
 91.2613 +(2 ,[1] ,true ,#Given ,Cor solveForVars [c, c_2] ,(v_s, [[c, c_2]])),
 91.2614 +(3 ,[1] ,true ,#Find ,Cor solution ss___ ,(ss___, [ss___]))]
 91.2615 +*)
 91.2616 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2617 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2618 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2619 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2620 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2621 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2622 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2623 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2624 +case nxt of
 91.2625 +    (Check_Postcond ["triangular", "2x2", "LINEAR", "system"]) => ()
 91.2626 +  | _ => error "eqsystem.sml me Subpbl .[EqSys...2x2] finished";
 91.2627 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2628 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2629 +if f2str f = "[c = L * q_0 / 2, c_2 = 0]" then ()
 91.2630 +else error "eqsystem.sml me [EqSys...2x2] finished f2str f";
 91.2631 +case nxt of
 91.2632 +    (End_Proof') => ()
 91.2633 +  | _ => error "eqsystem.sml me [EqSys...2x2] finished End_Proof'";
 91.2634 +
 91.2635 +\<close> ML \<open>
 91.2636 +"----------- me [linear,system] ..normalise..top_down_sub..-------";
 91.2637 +"----------- me [linear,system] ..normalise..top_down_sub..-------";
 91.2638 +"----------- me [linear,system] ..normalise..top_down_sub..-------";
 91.2639 +val fmz = 
 91.2640 +    ["equalities\
 91.2641 +     \[0 = c_2 + c * 0 + 1 / EI * (L * q_0 / 12 * 0 \<up> 3 +                \
 91.2642 +     \                                            - 1 * q_0 / 24 * 0 \<up> 4),\
 91.2643 +     \ 0 = c_2 + c * L + 1 / EI * (L * q_0 / 12 * L \<up> 3 +                \
 91.2644 +     \                                            - 1 * q_0 / 24 * L \<up> 4)]",
 91.2645 +     "solveForVars [c, c_2]", "solution LL"];
 91.2646 +val (dI',pI',mI') =
 91.2647 +  ("Biegelinie",["LINEAR", "system"], ["no_met"]);
 91.2648 +val p = e_pos'; val c = []; 
 91.2649 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.2650 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2651 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2652 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2653 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2654 +case nxt of (Specify_Method ["EqSystem", "normalise", "2x2"]) => ()
 91.2655 +	  | _ => error "eqsystem.sml [linear,system] specify b";
 91.2656 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2657 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2658 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2659 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2660 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2661 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2662 +if f2str f = 
 91.2663 +"[c_2 = 0, L * c + c_2 = - 1 * q_0 * L \<up> 4 / (24 * EI)]"
 91.2664 +then () else error "eqsystem.sml me simpl. before SubProblem b";
 91.2665 +case nxt of
 91.2666 +    (Subproblem ("Biegelinie", ["triangular", "2x2", "LINEAR",_])) => ()
 91.2667 +  | _ => error "eqsystem.sml me [linear,system] SubProblem b";
 91.2668 +
 91.2669 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2670 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2671 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2672 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2673 +case nxt of
 91.2674 +    (Specify_Method ["EqSystem", "top_down_substitution", "2x2"]) => ()
 91.2675 +  | _ => error "eqsystem.sml me [EqSys...2x2] top_down_substitution b";
 91.2676 +
 91.2677 +val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2678 +val PblObj {probl,...} = get_obj I pt [5];
 91.2679 +    (writeln o (I_Model.to_string (ThyC.to_ctxt @{theory Isac_Knowledge}))) probl;
 91.2680 +(*[
 91.2681 +(1 ,[1] ,true ,#Given ,Cor equalities [c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2] ,(es_, [[c_2 = 0, L * c + c_2 = q_0 * L \<up> 2 / 2]])),
 91.2682 +(2 ,[1] ,true ,#Given ,Cor solveForVars [c, c_2] ,(v_s, [[c, c_2]])),
 91.2683 +(3 ,[1] ,true ,#Find ,Cor solution ss___ ,(ss___, [ss___]))]
 91.2684 +*)
 91.2685 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2686 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2687 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2688 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2689 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2690 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2691 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2692 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2693 +case nxt of
 91.2694 +    (Check_Postcond ["triangular", "2x2", "LINEAR", "system"]) => ()
 91.2695 +  | _ => error "eqsystem.sml me Subpbl .[EqSys...2x2] finished b";
 91.2696 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2697 +val (p,_,f,nxt,_,pt) = me nxt p c pt;f2str f;
 91.2698 +
 91.2699 +if f2str f = "[c = - 1 * q_0 * L \<up> 3 / (24 * EI), c_2 = 0]"
 91.2700 +then () else error "eqsystem.sml me [EqSys...2x2] finished f2str f b";
 91.2701 +case nxt of
 91.2702 +    (End_Proof') => ()
 91.2703 +  | _ => error "eqsystem.sml me [EqSys...2x2] finished End_Proof'";
 91.2704 +
 91.2705 +
 91.2706 +\<close> ML \<open>
 91.2707 +"----------- all systems from Biegelinie -------------------------";
 91.2708 +"----------- all systems from Biegelinie -------------------------";
 91.2709 +"----------- all systems from Biegelinie -------------------------";
 91.2710 +val thy = @{theory Isac_Knowledge}
 91.2711 +val subst = 
 91.2712 +  [(TermC.str2term "bdv_1", TermC.str2term "c"), (TermC.str2term "bdv_2", TermC.str2term "c_2"),
 91.2713 +	(TermC.str2term "bdv_3", TermC.str2term "c_3"), (TermC.str2term "bdv_4", TermC.str2term "c_4")]; 
 91.2714 +
 91.2715 +"------- Bsp 7.27";
 91.2716 +reset_states ();
 91.2717 +CalcTree [(
 91.2718 +  ["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
 91.2719 +	  "Randbedingungen [y 0 = (0::real), y L = 0, M_b 0 = 0, M_b L = 0]", "FunktionsVariable x"],
 91.2720 +	("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]))];
 91.2721 +moveActiveRoot 1;
 91.2722 +(*
 91.2723 +LItool.trace_on := true; autoCalculate 1 CompleteCalc; LItool.trace_on := false;
 91.2724 +##7.27##          ordered           substs
 91.2725 +          c_4       c_2           
 91.2726 +c c_2 c_3 c_4     c c_2             1->2: c
 91.2727 +  c_2                       c_4	  
 91.2728 +c c_2             c c_2 c_3 c_4     [2':c, 1:c_2, 3:c_4] -> 4:c_3*)
 91.2729 +val t = TermC.str2term
 91.2730 +  ("[0 = c_4, " ^
 91.2731 +  "0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI), " ^
 91.2732 +  "0 = c_2, " ^
 91.2733 +  "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]");
 91.2734 +val SOME (t, _) = rewrite_set_ thy false isolate_bdvs_4x4 t;
 91.2735 +if UnparseC.term t =
 91.2736 +"[c_4 = 0,\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) /\n (- 24 * EI) =\n - 1 * (c_4 + L * c_3) + 0,\n c_2 = 0, (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2 = 0]"
 91.2737 +then () else error "Bsp 7.27";
 91.2738 +
 91.2739 +"----- Bsp 7.27 go through the rewrites in met_eqsys_norm_4x4";
 91.2740 +val t = TermC.str2term "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2";
 91.2741 +val NONE = rewrite_set_ thy false norm_Rational t;
 91.2742 +val SOME (t,_) = 
 91.2743 +    rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
 91.2744 +if UnparseC.term t = "0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2)"
 91.2745 +then () else error "Bsp 7.27 go through the rewrites in met_eqsys_norm_4x4";
 91.2746 +
 91.2747 +"--- isolate_bdvs_4x4";
 91.2748 +(*
 91.2749 +val SOME (t,_) = rewrite_set_inst_ thy false subst isolate_bdvs_4x4 t;
 91.2750 +UnparseC.term t;
 91.2751 +val SOME (t,_) = rewrite_set_inst_ thy false subst simplify_System t;
 91.2752 +UnparseC.term t;
 91.2753 +val SOME (t,_) = rewrite_set_ thy false order_system t;
 91.2754 +UnparseC.term t;
 91.2755 +*)
 91.2756 +
 91.2757 +"------- Bsp 7.28 ---------------vvvvvvvvvvvvv Momentenlinie postponed";
 91.2758 +reset_states ();
 91.2759 +CalcTree [((*WN130908  <ERROR> error in kernel </ERROR>*)
 91.2760 +  ["Traegerlaenge L", "Momentenlinie (-q_0 / L * x \<up> 3 / 6)",
 91.2761 +	    "Biegelinie y",
 91.2762 +	    "Randbedingungen [y L = 0, y' L = 0]",
 91.2763 +	    "FunktionsVariable x"],
 91.2764 +	   ("Biegelinie", ["vonMomentenlinieZu", "Biegelinien"],
 91.2765 +	    ["Biegelinien", "AusMomentenlinie"]))];
 91.2766 +(*
 91.2767 +moveActiveRoot 1;
 91.2768 +LItool.trace_on := true; autoCalculate 1 CompleteCalc; LItool.trace_on := false;
 91.2769 +*)
 91.2770 +
 91.2771 +"------- Bsp 7.69";
 91.2772 +reset_states ();
 91.2773 +CalcTree [(
 91.2774 +  ["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
 91.2775 +	  "Randbedingungen [y 0 = (0::real), y L = 0, y' 0 = 0, y' L = 0]", "FunktionsVariable x"],
 91.2776 +	("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"]))];
 91.2777 +moveActiveRoot 1;
 91.2778 +(*
 91.2779 +LItool.trace_on := true; autoCalculate 1 CompleteCalc; LItool.trace_on := false;
 91.2780 +##7.69##          ordered           subst                   2x2
 91.2781 +          c_4           c_3         
 91.2782 +c c_2 c_3 c_4     c c_2 c_3	    1:c_3 -> 2:c c_2        2:         c c_2
 91.2783 +      c_3                   c_4	 			   
 91.2784 +c c_2 c_3         c c_2 c_3 c_4     3:c_4 -> 4:c c_2 c_3    1:c_3 -> 4:c c_2*)
 91.2785 +val t = TermC.str2term 
 91.2786 +  ("[0 = c_4 + 0 / (- 1 * EI), " ^
 91.2787 +  "0 = c_4 + L * c_3 + (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI), " ^
 91.2788 +  "0 = c_3 + 0 / (- 1 * EI), " ^
 91.2789 +  "0 = c_3 + (6 * L * c_2 + 3 * L \<up> 2 * c + - 1 * L \<up> 3 * q_0) / (-6 * EI)]");
 91.2790 +
 91.2791 +"------- Bsp 7.70";
 91.2792 +reset_states ();
 91.2793 +CalcTree [(
 91.2794 +  ["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
 91.2795 +	  "Randbedingungen [Q 0 = q_0 * L, M_b L = 0, y 0 = (0::real), y' 0 = 0]", "FunktionsVariable x"],
 91.2796 +	("Biegelinie", ["Biegelinien"], ["IntegrierenUndKonstanteBestimmen2"] ))];
 91.2797 +moveActiveRoot 1;
 91.2798 +(*
 91.2799 +LItool.trace_on := true; autoCalculate 1 CompleteCalc; LItool.trace_on := false;
 91.2800 +##7.70##        |subst
 91.2801 +c		|
 91.2802 +c c_2           |1:c -> 2:c_2
 91.2803 +      c_3	|
 91.2804 +          c_4   |            STOPPED.WN06? test methods @@@@@@@@@@@@@@@@@@@@@@@*)
 91.2805 +
 91.2806 +\<close> ML \<open>
 91.2807 +"----- 7.70 go through the rewrites in met_eqsys_norm_4x4";
 91.2808 +val t = TermC.str2term
 91.2809 +  ("[L * q_0 = c, " ^
 91.2810 +  "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2, " ^
 91.2811 +  "0 = c_4, " ^
 91.2812 +  "0 = c_3]");
 91.2813 +val SOME (t,_) = rewrite_ thy e_rew_ord Rule_Set.empty false (ThmC.numerals_to_Free @{thm commute_0_equality}) t;
 91.2814 +val SOME (t,_) = rewrite_ thy e_rew_ord Rule_Set.empty false (ThmC.numerals_to_Free @{thm commute_0_equality}) t;
 91.2815 +val SOME (t,_) = rewrite_ thy e_rew_ord Rule_Set.empty false (ThmC.numerals_to_Free @{thm commute_0_equality}) t;
 91.2816 +if UnparseC.term t = 
 91.2817 +  "[L * q_0 = c, (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2 = 0,\n c_4 = 0, c_3 = 0]"
 91.2818 +then () else error "7.70 go through the rewrites in met_eqsys_norm_4x4, 1";
 91.2819 +
 91.2820 +\<close> ML \<open>
 91.2821 +val SOME (t,_) = rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
 91.2822 +if UnparseC.term t = "[L * q_0 = c, - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2) = 0, c_4 = 0,\n c_3 = 0]"
 91.2823 +then () else error "7.70 go through the rewrites in met_eqsys_norm_4x4, 2";
 91.2824 +
 91.2825 +val SOME (t,_) = rewrite_set_inst_ thy false subst isolate_bdvs_4x4 t;
 91.2826 +if UnparseC.term t =
 91.2827 +   "[c = (- 1 * (L * q_0) + 0) / - 1,\n" ^ 
 91.2828 +   " L * c + c_2 = - 1 * (- 1 * q_0 * L \<up> 2 / 2) + 0, c_4 = 0, c_3 = 0]"
 91.2829 +then () else error "7.70 go through the rewrites in met_eqsys_norm_4x4, 3";
 91.2830 +
 91.2831 +val SOME (t,_) = rewrite_set_inst_ thy false subst simplify_System_parenthesized t;
 91.2832 +\<close> ML \<open>
 91.2833 +UnparseC.term t =    "[c = - 0 + - 1 * L * q_0 / - 1, " ^ 
 91.2834 +                         (*^^^^^^*)            "L * c + c_2 = q_0 * L \<up> 2 / 2, c_4 = 0, c_3 = 0]"
 91.2835 +\<close> text \<open> (*TOODOO simplify_System_parenthesized: \<longrightarrow> - 0 + - 1 * L * q_0 / - 1 *)
 91.2836 +(** )
 91.2837 +if UnparseC.term t = "[c = - 1 * L * q_0 / - 1, L * c + c_2 = q_0 * L \<up> 2 / 2, c_4 = 0, c_3 = 0]"
 91.2838 +then () else error "7.70 go through the rewrites in met_eqsys_norm_4x4, 4";
 91.2839 +( **)
 91.2840 +
 91.2841 +val SOME (t, _) = rewrite_set_ thy false order_system t;
 91.2842 +\<close> ML \<open>
 91.2843 +UnparseC.term t = 
 91.2844 +                     "[L * q_0 = c, (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2 = 0,\n c_4 = 0, c_3 = 0]"
 91.2845 +\<close> ML \<open> (*TOODOO order_system: \<longrightarrow> c_4 = 0, c_3 = 0 *)
 91.2846 +(** )
 91.2847 +if UnparseC.term t = "[c = - 1 * L * q_0 / - 1, L * c + c_2 = q_0 * L \<up> 2 / 2, c_3 = 0, c_4 = 0]"
 91.2848 +then () else error "eqsystem.sml: exp 7.70 normalise 4x4 by rewrite changed";
 91.2849 +( **)
 91.2850 +
 91.2851 +\<close> ML \<open>
 91.2852 +"----- 7.70 with met normalise: ";
 91.2853 +val fmz = ["equalities" ^
 91.2854 +  "[L * q_0 = c, " ^
 91.2855 +  "0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2, " ^
 91.2856 +  "0 = c_4, " ^
 91.2857 +  "0 = c_3]", "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
 91.2858 +val (dI',pI',mI') = ("Biegelinie",["LINEAR", "system"], ["no_met"]);
 91.2859 +val p = e_pos'; val c = [];
 91.2860 +
 91.2861 +\<close> ML \<open>
 91.2862 +(*============ inhibit exn WN120314 TODO: investigate type error (same as above)==
 91.2863 +  in next but one test below the same type error.
 91.2864 +/-------------------------------------------------------\
 91.2865 +Type unification failed
 91.2866 +Type error in application: incompatible operand type
 91.2867 +
 91.2868 +Operator:  op # c_3 :: 'a list \<Rightarrow> 'a list
 91.2869 +Operand:   [c_4] :: 'b list
 91.2870 +\-------------------------------------------------------/
 91.2871 +
 91.2872 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.2873 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2874 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2875 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2876 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2877 +case nxt of (_,Apply_Method ["EqSystem", "normalise", "4x4"]) => ()
 91.2878 +	  | _ => error "eqsystem.sml [EqSystem,normalise,4x4] specify";
 91.2879 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2880 +
 91.2881 +"----- outcommented before Isabelle2002 --> 2011 -------------------------";
 91.2882 +(*-----------------------------------vvvWN080102 Exception- Match raised 
 91.2883 +  since associate Rewrite .. Rewrite_Set
 91.2884 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2885 +
 91.2886 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2887 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2888 +
 91.2889 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2890 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2891 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2892 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2893 +if f2str f ="[c = L * q_0, L * c + c_2 = q_0 * L \<up> 2 / 2, c_3 = 0, c_4 = 0]" 
 91.2894 +then () else error "eqsystem.sml: exp 7.70 normalise 4x4 by met changed";
 91.2895 +--------------------------------------------------------------------------*)
 91.2896 +============ inhibit exn WN120314 ==============================================*)
 91.2897 +
 91.2898 +\<close> ML \<open>
 91.2899 +"----- 7.70 with met top_down_: me";
 91.2900 +val fmz = [
 91.2901 +  "equalities [(c::real) = L * q_0, L * c + (c_2::real) = q_0 * L \<up> 2 / 2, (c_3::real) = 0, (c_4::real) = 0]",
 91.2902 +	"solveForVars [(c::real), (c_2::real), (c_3::real), (c_4::real)]", "solution LL"];
 91.2903 +val (dI',pI',mI') =
 91.2904 +  ("Biegelinie",["LINEAR", "system"],["no_met"]);
 91.2905 +val p = e_pos'; val c = []; 
 91.2906 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.2907 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2908 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2909 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2910 +val (p,_,f,nxt,_,pt) = me nxt p c pt;val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.2911 +case nxt of Apply_Method ["EqSystem", "top_down_substitution", "4x4"] => ()
 91.2912 +	  | _ => error "eqsystem.sml [EqSystem,top_down_,4x4] specify";
 91.2913 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2914 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2915 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2916 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2917 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2918 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.2919 +if p = ([], Res) andalso
 91.2920 +(*           "[c = L * q_0, c_2 = - 1 * L \<up> 2 * q_0 / 2, c_3 = 0, c_4 = 0]"*)
 91.2921 +   f2str f = "[c = L * q_0, c_2 = - 1 * L \<up> 2 * q_0 / 2, c_3 = 0, c_4 = 0]"
 91.2922 +then () else error "eqsystem.sml: 7.70 with met top_down_: me";
 91.2923 +
 91.2924 +\<close> ML \<open>
 91.2925 +"------- Bsp 7.71";
 91.2926 +reset_states ();
 91.2927 +CalcTree [(["Traegerlaenge L", "Streckenlast q_0", "Biegelinie y",
 91.2928 +	     "Randbedingungen [M_b L = 0, y 0 = (0::real), y L = 0, y' 0 = 0]",
 91.2929 +	     "FunktionsVariable x", "GleichungsVariablen [c, c_2, c_3, c_4]",
 91.2930 +	     "AbleitungBiegelinie dy"],
 91.2931 +	    ("Biegelinie", ["Biegelinien"],
 91.2932 +	     ["IntegrierenUndKonstanteBestimmen2"] ))];
 91.2933 +moveActiveRoot 1;
 91.2934 +(*
 91.2935 +LItool.trace_on := true; autoCalculate 1 CompleteCalc; LItool.trace_on := false;
 91.2936 +##7.71##       |ordered       |subst.singles (recurs) |2x2       |diagonal
 91.2937 +c c_2          |c c_2	      |1'		      |1': c c_2 |
 91.2938 +          c_4  |      c_3     |2:c_3 -> 4' :c c_2 c_4 |	         |
 91.2939 +c c_2 c_3 c_4  |          c_4 |3'                     |	         |
 91.2940 +      c_3      |c c_2 c_3 c_4 |3:c_4 -> 4'':c c_2     |4'':c c_2 |      *)
 91.2941 +val t = TermC.str2term"[0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2, \
 91.2942 +\ 0 = c_4 + 0 / (- 1 * EI),                            \
 91.2943 +\ 0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) /(- 24 * EI),\
 91.2944 +\ 0 = c_3 + 0 / (- 1 * EI)]";
 91.2945 +
 91.2946 +"------- Bsp 7.72a ---------------vvvvvvvvvvvvv Momentenlinie postponed";
 91.2947 +reset_states ();
 91.2948 +CalcTree [(["Traegerlaenge L",
 91.2949 +	    "Momentenlinie ((q_0 * L)/ 6 * x - q_0 /(6 * L) * x \<up> ^3)",
 91.2950 +	    "Biegelinie y",
 91.2951 +	    "Randbedingungen [y 0 = (0::real), y L = 0]",
 91.2952 +	    "FunktionsVariable x"],
 91.2953 +	   ("Biegelinie", ["vonMomentenlinieZu", "Biegelinien"],
 91.2954 +	    ["Biegelinien", "AusMomentenlinie"]))];
 91.2955 +moveActiveRoot 1;
 91.2956 +(*
 91.2957 +LItool.trace_on := true; autoCalculate 1 CompleteCalc; LItool.trace_on := false;
 91.2958 +*)
 91.2959 +
 91.2960 +\<close> ML \<open>
 91.2961 +"------- Bsp 7.72b";
 91.2962 +reset_states ();
 91.2963 +CalcTree [(["Traegerlaenge L", "Streckenlast (q_0 / L * x)", "Biegelinie y",
 91.2964 +	    "Randbedingungen [M_b 0 = 0, M_b L = 0, y 0 = (0::real), y L = 0]",
 91.2965 +	    "FunktionsVariable x", "GleichungsVariablen [c, c_2, c_3, c_4]",
 91.2966 +	    "AbleitungBiegelinie dy"],
 91.2967 +	   ("Biegelinie", ["Biegelinien"],
 91.2968 +	    ["IntegrierenUndKonstanteBestimmen2"] ))];
 91.2969 +moveActiveRoot 1;
 91.2970 +(*
 91.2971 +LItool.trace_on := true; autoCalculate 1 CompleteCalc; LItool.trace_on := false;
 91.2972 +##7.72b##      |ord. |subst.singles         |ord.triang.
 91.2973 +  c_2          |     |			    |c_2  
 91.2974 +c c_2	       |     |1:c_2 -> 2':c	    |c_2 c
 91.2975 +          c_4  |     |			    |
 91.2976 +c c_2 c_3 c_4  |     |3:c_4 -> 4':c c_2 c_3 |c_2 c c_3*)
 91.2977 +val t = TermC.str2term"[0 = c_2,                                            \
 91.2978 +\ 0 = (6 * c_2 + 6 * L * c + - 1 * L \<up> 2 * q_0) / 6, \
 91.2979 +\ 0 = c_4 + 0 / (- 1 * EI),                            \
 91.2980 +\ 0 = c_4 + L * c_3 + (60 * L \<up> 2 * c_2 + 20 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 120 * EI)]";
 91.2981 +
 91.2982 +"------- Bsp 7.73 ---------------vvvvvvvvvvvvv Momentenlinie postponed";
 91.2983 +reset_states ();
 91.2984 +CalcTree [(["Traegerlaenge L", "Momentenlinie ???",(*description unclear*)
 91.2985 +	    "Biegelinie y",
 91.2986 +	    "Randbedingungen [y L = 0, y' L = 0]",
 91.2987 +	    "FunktionsVariable x"],
 91.2988 +	   ("Biegelinie", ["vonMomentenlinieZu", "Biegelinien"],
 91.2989 +	    ["Biegelinien", "AusMomentenlinie"]))];
 91.2990 +moveActiveRoot 1;
 91.2991 +(*
 91.2992 +LItool.trace_on := true; autoCalculate 1 CompleteCalc; LItool.trace_on := false;
 91.2993 +*)
 91.2994 +
 91.2995 +\<close> ML \<open>
 91.2996 +"----------- 4x4 systems from Biegelinie -------------------------";
 91.2997 +"----------- 4x4 systems from Biegelinie -------------------------";
 91.2998 +"----------- 4x4 systems from Biegelinie -------------------------";
 91.2999 +(*STOPPED.WN08?? replace this test with 7.70 *)
 91.3000 +"----- Bsp 7.27";
 91.3001 +val fmz = ["equalities \
 91.3002 +	   \[0 = c_4,                           \
 91.3003 +	   \ 0 = c_4 + L * c_3 +(12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI),                                       \
 91.3004 +	   \ 0 = c_2,                                           \
 91.3005 +	   \ 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]", 
 91.3006 +	   "solveForVars [c, c_2, c_3, c_4]", "solution LL"];
 91.3007 +val (dI',pI',mI') =
 91.3008 +  ("Biegelinie",["normalise", "4x4", "LINEAR", "system"],
 91.3009 +   ["EqSystem", "normalise", "4x4"]);
 91.3010 +val p = e_pos'; val c = []; 
 91.3011 +val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
 91.3012 +val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.3013 +val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.3014 +val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.3015 +val (p,_,f,nxt,_,pt) = me nxt p c pt; val (p,_,f,nxt,_,pt) = me nxt p c pt;
 91.3016 +"------------------------------------------- Apply_Method...";
 91.3017 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.3018 +"[0 = c_4,                                          \
 91.3019 +\ 0 = c_4 + L * c_3 +\n (12 * L \<up> 2 * c_2 + 4 * L \<up> 3 * c + - 1 * L \<up> 4 * q_0) / (- 24 * EI),                                   \
 91.3020 +\ 0 = c_2,                                          \
 91.3021 +\ 0 = (2 * c_2 + 2 * L * c + - 1 * L \<up> 2 * q_0) / 2]";
 91.3022 +(*vvvWN080102 Exception- Match raised 
 91.3023 +  since associate Rewrite .. Rewrite_Set
 91.3024 +"------------------------------------------- simplify_System_parenthesized...";
 91.3025 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.3026 +"[0 = c_4,                                  \
 91.3027 +\ 0 = - 1 * q_0 * L \<up> 4 / (- 24 * EI) +     \
 91.3028 +\     (4 * L \<up> 3 * c / (- 24 * EI) +       \
 91.3029 +\     (12 * L \<up> 2 * c_2 / (- 24 * EI) +    \
 91.3030 +\     (L * c_3 + c_4))),                    \
 91.3031 +\ 0 = c_2,                                  \
 91.3032 +\ 0 = - 1 * q_0 * L \<up> 2 / 2 + (L * c + c_2)]";
 91.3033 +(*? "(4 * L \<up> 3 / (- 24 * EI) * c" statt "(4 * L \<up> 3 * c / (- 24 * EI)" ?*)
 91.3034 +"------------------------------------------- isolate_bdvs...";
 91.3035 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.3036 +"[c_4 = 0,\
 91.3037 +\ c_4 = 0 + - 1 * (- 1 * q_0 * L \<up> 4 / (- 24 * EI)) + - 1 * (4 * L \<up> 3 * c / (- 24 * EI)) + - 1 * (12 * L \<up> 2 * c_2 / (- 24 * EI)) + - 1 * (L * c_3),\
 91.3038 +\ c_2 = 0, \
 91.3039 +\ c_2 = 0 + - 1 * (- 1 * q_0 * L \<up> 2 / 2) + - 1 * (L * c)]";
 91.3040 +val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
 91.3041 +
 91.3042 +---------------------------------------------------------------------*)
 91.3043 +\<close> ML \<open>
 91.3044 +\<close> ML \<open>
 91.3045 +\<close>
 91.3046 +
 91.3047 +section \<open>===================================================================================\<close>
 91.3048 +ML \<open>
 91.3049 +\<close> ML \<open>
 91.3050 +\<close> ML \<open>
 91.3051 +\<close> ML \<open>
 91.3052 +\<close>
 91.3053 +
 91.3054  section \<open>===================================================================================\<close>
 91.3055  ML \<open>
 91.3056  \<close> ML \<open>