test/Tools/isac/Knowledge/polyeq-2.sml
author wneuper <Walther.Neuper@jku.at>
Sat, 30 Jul 2022 16:47:45 +0200
changeset 60500 59a3af532717
parent 60394 41cdbf7d5e6e
child 60509 2e0b7ca391dc
permissions -rw-r--r--
eliminate global flag Rewrite.trace_on
walther@60329
     1
(* Title:  Knowledge/polyeq- 1.sml
walther@59627
     2
           testexamples for PolyEq, poynomial equations and equational systems
walther@59627
     3
   Author: Richard Lang 2003  
walther@59627
     4
   (c) due to copyright terms
walther@59627
     5
WN030609: some expls dont work due to unfinished handling of 'expanded terms';
walther@59627
     6
          others marked with TODO have to be checked, too.
walther@59627
     7
*)
walther@59627
     8
walther@59627
     9
"-----------------------------------------------------------------";
walther@59627
    10
"table of contents -----------------------------------------------";
walther@59627
    11
"-----------------------------------------------------------------";
walther@60394
    12
"------ polyeq-2.sml ---------------------------------------------";
walther@60394
    13
"------ polyeq-1.sml ---------------------------------------------";
walther@60242
    14
"----------- (a*b - (a+b)*x + x \<up> 2 = 0), (*Schalk 2,S.68Nr.44.a*)";
walther@60242
    15
"----------- (-64 + x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.a~--------*)";
walther@60329
    16
"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
walther@60329
    17
"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
walther@60242
    18
"----------- ((x+1)*(x+2) - (3*x - 2) \<up> 2=.. Schalk II s.68 Bsp 37";
walther@59627
    19
"----------- rls make_polynomial_in ------------------------------";
walther@59627
    20
"----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
walther@59627
    21
"----------- rls d2_polyeq_bdv_only_simplify ---------------------";
walther@59627
    22
"-----------------------------------------------------------------";
walther@59627
    23
"-----------------------------------------------------------------";
walther@59627
    24
walther@59627
    25
walther@60242
    26
"----------- (a*b - (a+b)*x + x \<up> 2 = 0), (*Schalk 2,S.68Nr.44.a*)";
walther@60242
    27
"----------- (a*b - (a+b)*x + x \<up> 2 = 0), (*Schalk 2,S.68Nr.44.a*)";
walther@60242
    28
"----------- (a*b - (a+b)*x + x \<up> 2 = 0), (*Schalk 2,S.68Nr.44.a*)";
walther@60242
    29
 val fmz = ["equality (a*b - (a+b)*x + x \<up> 2 = 0)",
walther@59997
    30
 	    "solveFor x", "solutions L"];
walther@59627
    31
 val (dI',pI',mI') =
walther@59997
    32
     ("PolyEq",["degree_2", "expanded", "univariate", "equation"],
walther@59997
    33
      ["PolyEq", "complete_square"]);
walther@59627
    34
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59627
    35
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    36
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    37
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    38
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    39
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    40
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    41
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    42
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    43
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    44
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    45
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    46
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    47
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    48
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    49
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    50
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    51
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    52
val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f;
walther@59627
    53
(*WN.2.5.03 TODO FIXME Matthias ?
walther@59627
    54
 case f of 
walther@59627
    55
     Form' 
walther@59959
    56
	 (Test_Out.FormKF 
walther@59627
    57
	      (~1,EdUndef,0,Nundef,
walther@60329
    58
	       "[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)]")) 
walther@59627
    59
	 => ()
walther@60242
    60
   | _ => error "polyeq.sml: diff.behav. in a*b - (a+b)*x + x \<up> 2 = 0";
walther@59627
    61
 this will be simplified [x = a, x = b] to by Factor.ML*)
walther@59627
    62
walther@59627
    63
walther@60242
    64
"----------- (-64 + x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.a~--------*)";
walther@60242
    65
"----------- (-64 + x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.a~--------*)";
walther@60242
    66
"----------- (-64 + x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.a~--------*)";
walther@60242
    67
 val fmz = ["equality (-64 + x \<up> 2 = 0)",(*Schalk 2, S.66 Nr.1.a~*)
walther@59997
    68
 	    "solveFor x", "solutions L"];
walther@59627
    69
 val (dI',pI',mI') =
walther@59997
    70
     ("PolyEq",["degree_2", "expanded", "univariate", "equation"],
walther@59997
    71
      ["PolyEq", "complete_square"]);
walther@59627
    72
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59627
    73
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    74
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    75
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    76
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    77
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    78
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    79
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    80
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    81
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    82
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    83
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    84
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
    85
val (p,_,f,nxt,_,pt) = me nxt p [] pt; f2str f;
walther@60329
    86
(*WN.2.5.03 TODO "[x = sqrt (0 - -64), x = - 1 * sqrt (0 - -64)]"
walther@59959
    87
 case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 8, x = -8]")) => ()
walther@59627
    88
	 | _ => error "polyeq.sml: diff.behav. in [x = 8, x = -8]";
walther@59627
    89
*)
walther@59627
    90
walther@60329
    91
"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
walther@60329
    92
"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
walther@60329
    93
"----------- (- 147 + 3*x \<up> 2 = 0), (*Schalk 2, S.66 Nr.1.b------*)";
walther@60329
    94
val fmz = ["equality (- 147 + 3*x \<up> 2 = 0)",(*Schalk 2, S.66 Nr.1.b*)
walther@59997
    95
 	    "solveFor x", "solutions L"];
walther@59627
    96
val (dI',pI',mI') =
walther@59997
    97
     ("PolyEq",["degree_2", "expanded", "univariate", "equation"],
walther@59997
    98
      ["PolyEq", "complete_square"]);
walther@59627
    99
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59627
   100
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
   101
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
   102
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
   103
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
   104
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
   105
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
   106
val (p,_,f,nxt,_,pt) = me nxt p [] pt; val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@59627
   107
val (p,_,f,nxt,_,pt) = me nxt p [] pt;
walther@60329
   108
(*WN.2.5.03 TODO "[x = sqrt (0 - -49), x = - 1 * sqrt (0 - -49)]"
walther@59959
   109
 case f of Form' (Test_Out.FormKF (~1,EdUndef,0,Nundef,"[x = 7, x = -7]")) => ()
walther@59627
   110
	 | _ => error "polyeq.sml: diff.behav. in [x = 7, x = -7]";
walther@59627
   111
*)
walther@60393
   112
if f2str f = "[x = sqrt (0 - - 49), x = - 1 * sqrt (0 - - 49)]" then ()
walther@59627
   113
else error "polyeq.sml CORRECTED?behav. in [x = 7, x = -7]";
walther@59627
   114
walther@59627
   115
walther@60329
   116
"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
walther@60329
   117
"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
walther@60329
   118
"----------- (3*x - 1 - (5*x - (2 - 4*x)) = - 11),(*Schalk Is86Bsp5";
walther@60329
   119
(*EP- 17 Schalk_I_p86_n5*)
walther@60329
   120
val fmz = ["equality ((3::real)*x - 1 - (5*x - (2 - 4*x)) = - 11)", "solveFor x", "solutions L"];
walther@59997
   121
(* Refine.refine fmz ["univariate", "equation"];
walther@59627
   122
*)
walther@59997
   123
val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
walther@59627
   124
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59627
   125
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   126
(* val nxt =
walther@59627
   127
  ("Model_Problem",
walther@59997
   128
   Model_Problem ["normalise", "polynomial", "univariate", "equation"])
walther@59627
   129
  : string * tac*)
walther@59627
   130
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   131
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   132
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   133
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   134
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   135
(* val nxt =
walther@59627
   136
  ("Subproblem",
walther@59997
   137
   Subproblem ("PolyEq",["polynomial", "univariate", "equation"]))
walther@59627
   138
  : string * tac *)
walther@59627
   139
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   140
(*val nxt =
walther@59627
   141
  ("Model_Problem",
walther@59997
   142
   Model_Problem ["degree_1", "polynomial", "univariate", "equation"])
walther@59627
   143
  : string * tac *)
walther@59627
   144
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   145
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   146
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   147
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   148
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   149
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   150
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59959
   151
case f of Test_Out.FormKF "[x = 2]" => ()
walther@59627
   152
	 | _ => error "polyeq.sml: diff.behav. in [x = 2]";
walther@59627
   153
walther@59627
   154
walther@60242
   155
"----------- ((x+1)*(x+2) - (3*x - 2) \<up> 2=.. Schalk II s.68 Bsp 37";
walther@60242
   156
"----------- ((x+1)*(x+2) - (3*x - 2) \<up> 2=.. Schalk II s.68 Bsp 37";
walther@60242
   157
"----------- ((x+1)*(x+2) - (3*x - 2) \<up> 2=.. Schalk II s.68 Bsp 37";
walther@59627
   158
(*is in rlang.sml, too*)
walther@60242
   159
val fmz = ["equality ((x+1)*(x+2) - (3*x - 2) \<up> 2=(2*x - 1) \<up> 2+(3*x - 1)*(x+1))",
walther@59997
   160
	   "solveFor x", "solutions L"];
walther@59997
   161
val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
walther@59627
   162
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59997
   163
(*val nxt = ("Refine_Tacitly",Refine_Tacitly ["univariate", "equation"])*)
walther@59627
   164
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   165
(* val nxt =
walther@59627
   166
  ("Model_Problem",
walther@59997
   167
   Model_Problem ["normalise", "polynomial", "univariate", "equation"])
walther@59627
   168
  : string * tac *)
walther@59627
   169
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   170
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   171
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   172
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   173
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   174
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   175
(* val nxt =
walther@59627
   176
  ("Subproblem",
walther@59997
   177
   Subproblem ("PolyEq",["polynomial", "univariate", "equation"]))
walther@59627
   178
  : string * tac*)
walther@59627
   179
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   180
(*val nxt =
walther@59627
   181
  ("Model_Problem",
walther@59997
   182
   Model_Problem ["abcFormula", "degree_2", "polynomial", "univariate", "equation"])
walther@59627
   183
  : string * tac*)
walther@59627
   184
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   185
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   186
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   187
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   188
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   189
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   190
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59959
   191
case f of Test_Out.FormKF "[x = 2 / 15, x = 1]" => ()
walther@59627
   192
	 | _ => error "polyeq.sml: diff.behav. in [x = 2 / 15, x = 1]";
walther@59627
   193
walther@59627
   194
walther@60242
   195
"    -4 + x \<up> 2 =0     ";
walther@60242
   196
"    -4 + x \<up> 2 =0     ";
walther@60242
   197
"    -4 + x \<up> 2 =0     ";
walther@60242
   198
val fmz = ["equality ( -4 + x \<up> 2 =0)", "solveFor x", "solutions L"];
walther@60242
   199
(* val fmz = ["equality (1 + x \<up> 2 =0)", "solveFor x", "solutions L"];*)
walther@59997
   200
(*val fmz = ["equality (0 =0)", "solveFor x", "solutions L"];*)
walther@59997
   201
val (dI',pI',mI') = ("PolyEq",["univariate", "equation"],["no_met"]);
walther@59627
   202
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
walther@59627
   203
walther@59627
   204
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   205
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   206
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   207
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   208
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   209
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@59627
   210
val (p,_,f,nxt,_,pt) = me nxt p [1] pt;val (p,_,f,nxt,_,pt) = me nxt p [1] pt;
walther@60329
   211
case f of Test_Out.FormKF "[x = 2, x = - 2]" => ()
walther@60329
   212
	 | _ => error "polyeq.sml: diff.behav. in [x = 2, x = - 2]";
walther@59627
   213
walther@59627
   214
"----------- rls make_polynomial_in ------------------------------";
walther@59627
   215
"----------- rls make_polynomial_in ------------------------------";
walther@59627
   216
"----------- rls make_polynomial_in ------------------------------";
walther@60393
   217
val thy = @{theory};
Walther@60500
   218
val ctxt = @{context};
walther@59627
   219
(*Punkte aus dem TestBericht, die ich in rlang.sml nicht zuordnen konnte:*)
walther@59627
   220
(*WN.19.3.03 ---v-*)
walther@60230
   221
(*3(b)*)val (bdv,v) = (TermC.str2term "''bdv''", TermC.str2term "R1");
walther@60329
   222
val t = TermC.str2term "- 1 * (R * R2) + R2 * R1 + - 1 * (R * R1) = 0";
Walther@60500
   223
val SOME (t',_) = rewrite_set_inst_ ctxt false [(bdv,v)] make_polynomial_in t;
walther@60329
   224
if UnparseC.term t' = "- 1 * R * R2 + R2 * R1 + - 1 * R * R1 = 0" then ()
walther@60329
   225
else error "make_polynomial_in (- 1 * (R * R2) + R2 * R1 + - 1 * (R * R1) = 0)";
walther@60329
   226
"- 1 * R * R2 + (R2 + - 1 * R) * R1 = 0";
walther@59627
   227
(*WN.19.3.03 ---^-*)
walther@59627
   228
walther@60230
   229
(*3(c)*)val (bdv,v) = (TermC.str2term "bdv", TermC.str2term "p");
walther@60329
   230
val t = TermC.str2term "y \<up> 2 + - 2 * (x * p) = 0";
Walther@60500
   231
val SOME (t',_) = rewrite_set_inst_ ctxt false [(bdv,v)] make_polynomial_in t;
walther@60329
   232
if UnparseC.term t' = "y \<up> 2 + - 2 * x * p = 0" then ()
walther@60329
   233
else error "make_polynomial_in (y \<up> 2 + - 2 * (x * p) = 0)";
walther@59627
   234
walther@60230
   235
(*3(d)*)val (bdv,v) = (TermC.str2term "''bdv''", TermC.str2term "x2");
walther@60230
   236
val t = TermC.str2term 
walther@60329
   237
"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";
Walther@60500
   238
val SOME (t',_) = rewrite_set_inst_ ctxt false [(bdv,v)] make_polynomial_in t;
walther@59868
   239
if UnparseC.term t' =
walther@60329
   240
"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"
walther@59627
   241
then ()
walther@60329
   242
else error "make_polynomial_in (A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + - 1...";
walther@59627
   243
"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";
walther@59627
   244
Walther@60500
   245
val SOME (t',_) = rewrite_set_inst_ ctxt false [(bdv,v)] make_ratpoly_in t;
walther@59868
   246
if UnparseC.term t' = 
walther@60329
   247
"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"
walther@59627
   248
then ()
walther@60329
   249
else error "make_ratpoly_in (A + x1 * (y3 * (1 / 2)) + x3 * (y2 * (1 / 2)) + - 1...";
walther@60329
   250
"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";
walther@59627
   251
walther@60230
   252
(*3(e)*)val (bdv,v) = (TermC.str2term "bdv", TermC.str2term "a");
walther@60230
   253
val t = TermC.str2term 
walther@60242
   254
"A \<up> 2 + c \<up> 2 * (c / d) \<up> 2 + (-4 * (c / d) \<up> 2) * a \<up> 2 = 0";
Walther@60500
   255
val NONE = rewrite_set_inst_ ctxt false [(bdv,v)] make_polynomial_in t;
walther@59627
   256
(* the invisible parentheses are as expected *)
walther@59627
   257
walther@60242
   258
val t = TermC.str2term "(x + 1) * (x + 2) - (3 * x - 2) \<up> 2 - ((2 * x - 1) \<up> 2 + (3 * x - 1) * (x + 1)) = 0";
Walther@60500
   259
rewrite_set_ ctxt false expand_binoms t;
walther@59627
   260
walther@59627
   261
walther@59627
   262
"----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
walther@59627
   263
"----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
walther@59627
   264
"----------- interSteps ([1],Res); on Schalk Is86Bsp5-------------";
walther@59627
   265
reset_states ();
walther@59627
   266
CalcTree
walther@60329
   267
[(["equality ((3::real)*x - 1 - (5*x - (2 - 4*x)) = - 11)", "solveFor x", "solutions L"], 
walther@59997
   268
  ("PolyEq",["univariate", "equation"],["no_met"]))];
walther@59627
   269
Iterator 1;
walther@59627
   270
moveActiveRoot 1;
walther@59627
   271
walther@59627
   272
autoCalculate 1 CompleteCalc;
walther@59983
   273
val ((pt,p),_) = get_calc 1; Test_Tool.show_pt pt;
walther@59627
   274
interSteps 1 ([1],Res)
walther@59627
   275
(*BEFORE Isabelle2002 --> 2011: <ERROR> no Rewrite_Set... </ERROR> ?see fun prep_rls?*);
walther@59627
   276
walther@59627
   277
walther@59627
   278
"----------- rls d2_polyeq_bdv_only_simplify ---------------------";
walther@59627
   279
"----------- rls d2_polyeq_bdv_only_simplify ---------------------";
walther@59627
   280
"----------- rls d2_polyeq_bdv_only_simplify ---------------------";
walther@60242
   281
val t = TermC.str2term "-6 * x + 5 * x \<up> 2 = (0::real)";
walther@60230
   282
val subst = [(TermC.str2term "(bdv::real)", TermC.str2term "(x::real)")];
Walther@60500
   283
val SOME (t''''', _) = rewrite_set_inst_ ctxt true subst d2_polyeq_bdv_only_simplify t;
walther@59627
   284
(* steps in rls d2_polyeq_bdv_only_simplify:*)
walther@59627
   285
walther@59997
   286
(*-6 * x + 5 * x ^ 2 = 0 : Rewrite_Inst (["(''bdv'',x)"],("d2_prescind1", "")) --> x * (-6 + 5 * x) = 0*)
walther@60230
   287
t |> UnparseC.term; t |> TermC.atomty;
walther@60393
   288
val thm = @{thm d2_prescind1};
walther@60230
   289
thm |> Thm.prop_of |> UnparseC.term; thm |> Thm.prop_of |> TermC.atomty;
Walther@60500
   290
val SOME (t', _) = rewrite_inst_ ctxt e_rew_ord Rule_Set.empty true subst thm t; UnparseC.term t';
walther@59627
   291
walther@59997
   292
(*x * (-6 + 5 * x) = 0   : Rewrite_Inst (["(''bdv'',x)"],("d2_reduce_equation1", "")) 
walther@59627
   293
                                                                        --> x = 0 | -6 + 5 * x = 0*)
walther@60230
   294
t' |> UnparseC.term; t' |> TermC.atomty;
walther@60393
   295
val thm = @{thm d2_reduce_equation1};
walther@60230
   296
thm |> Thm.prop_of |> UnparseC.term; thm |> Thm.prop_of |> TermC.atomty;
Walther@60500
   297
val SOME (t'', _) = rewrite_inst_ ctxt e_rew_ord Rule_Set.empty true subst thm t'; UnparseC.term t'';
walther@59627
   298
(* NONE with d2_reduce_equation1:   "(bdv*(a +b*bdv)=0) = ((bdv=0)|(a+b*bdv=0))"
walther@59627
   299
   instead   d2_reduce_equation1:   "(bdv*(a +b*bdv)=0) = ((bdv=0)|(a+b*bdv=(0::real)))"
walther@59627
   300
*)
walther@60393
   301
if UnparseC.term t'' = "x = 0 \<or> - 6 + 5 * x = 0" then ()
walther@59627
   302
else error "rls d2_polyeq_bdv_only_simplify broken";