src/Tools/isac/Knowledge/PolyEq.thy
author Walther Neuper <neuper@ist.tugraz.at>
Wed, 08 Sep 2010 16:47:22 +0200
branchisac-update-Isa09-2
changeset 37991 028442673981
parent 37990 24609758d219
child 38009 b49723351533
permissions -rw-r--r--
tuned src + test

find . -type f -exec sed -i s/nadd_divide_distrib/add_divide_distrib/g {} \;
find . -type f -exec sed -i s/"\.thy\""/"\""/g {} \;
find . -type f -exec sed -i s/" indexname_ord"/" Term_Ord.indexname_ord"/g {} \;
find . -type f -exec sed -i s/"(string_of_cterm o cterm_of(sign_of thy))"/"(Syntax.string_of_term (thy2ctxt thy))"/g {} \;
find . -type f -exec sed -i s/" L_"/" L_L"/g {} \;
find . -type f -exec sed -i s/" L_:"/" L_L:"/g {} \;
find . -type f -exec sed -i s/"e_;"/"e_e;"/g {} \;
find . -type f -exec sed -i s/"v_)"/"v_v)"/g {} \;
find . -type f -exec sed -i s/"v_:"/"v_v:"/g {} \;
     1 (* theory collecting all knowledge 
     2    (predicates 'is_rootEq_in', 'is_sqrt_in', 'is_ratEq_in')
     3    for PolynomialEquations.
     4    alternative dependencies see Isac.thy
     5    created by: rlang 
     6          date: 02.07
     7    changed by: rlang
     8    last change by: rlang
     9              date: 03.06.03
    10    (c) by Richard Lang, 2003
    11 *)
    12 
    13 theory PolyEq imports LinEq RootRatEq begin 
    14 
    15 consts
    16 
    17 (*---------scripts--------------------------*)
    18   Complete'_square
    19              :: "[bool,real, 
    20 		   bool list] => bool list"
    21                ("((Script Complete'_square (_ _ =))// 
    22                   (_))" 9)
    23  (*----- poly ----- *)	 
    24   Normalize'_poly
    25              :: "[bool,real, 
    26 		   bool list] => bool list"
    27                ("((Script Normalize'_poly (_ _=))// 
    28                   (_))" 9)
    29   Solve'_d0'_polyeq'_equation
    30              :: "[bool,real, 
    31 		   bool list] => bool list"
    32                ("((Script Solve'_d0'_polyeq'_equation (_ _ =))// 
    33                   (_))" 9)
    34   Solve'_d1'_polyeq'_equation
    35              :: "[bool,real, 
    36 		   bool list] => bool list"
    37                ("((Script Solve'_d1'_polyeq'_equation (_ _ =))// 
    38                   (_))" 9)
    39   Solve'_d2'_polyeq'_equation
    40              :: "[bool,real, 
    41 		   bool list] => bool list"
    42                ("((Script Solve'_d2'_polyeq'_equation (_ _ =))// 
    43                   (_))" 9)
    44   Solve'_d2'_polyeq'_sqonly'_equation
    45              :: "[bool,real, 
    46 		   bool list] => bool list"
    47                ("((Script Solve'_d2'_polyeq'_sqonly'_equation (_ _ =))// 
    48                   (_))" 9)
    49   Solve'_d2'_polyeq'_bdvonly'_equation
    50              :: "[bool,real, 
    51 		   bool list] => bool list"
    52                ("((Script Solve'_d2'_polyeq'_bdvonly'_equation (_ _ =))// 
    53                   (_))" 9)
    54   Solve'_d2'_polyeq'_pq'_equation
    55              :: "[bool,real, 
    56 		   bool list] => bool list"
    57                ("((Script Solve'_d2'_polyeq'_pq'_equation (_ _ =))// 
    58                   (_))" 9)
    59   Solve'_d2'_polyeq'_abc'_equation
    60              :: "[bool,real, 
    61 		   bool list] => bool list"
    62                ("((Script Solve'_d2'_polyeq'_abc'_equation (_ _ =))// 
    63                   (_))" 9)
    64   Solve'_d3'_polyeq'_equation
    65              :: "[bool,real, 
    66 		   bool list] => bool list"
    67                ("((Script Solve'_d3'_polyeq'_equation (_ _ =))// 
    68                   (_))" 9)
    69   Solve'_d4'_polyeq'_equation
    70              :: "[bool,real, 
    71 		   bool list] => bool list"
    72                ("((Script Solve'_d4'_polyeq'_equation (_ _ =))// 
    73                   (_))" 9)
    74   Biquadrat'_poly
    75              :: "[bool,real, 
    76 		   bool list] => bool list"
    77                ("((Script Biquadrat'_poly (_ _=))// 
    78                   (_))" 9)
    79 
    80 (*-------------------- rules -------------------------------------------------*)
    81 axioms 
    82 
    83   cancel_leading_coeff1: "Not (c =!= 0) ==> (a + b*bdv + c*bdv^^^2 = 0) = 
    84 			                   (a/c + b/c*bdv + bdv^^^2 = 0)"
    85   cancel_leading_coeff2: "Not (c =!= 0) ==> (a - b*bdv + c*bdv^^^2 = 0) = 
    86 			                   (a/c - b/c*bdv + bdv^^^2 = 0)"
    87   cancel_leading_coeff3: "Not (c =!= 0) ==> (a + b*bdv - c*bdv^^^2 = 0) = 
    88 			                   (a/c + b/c*bdv - bdv^^^2 = 0)"
    89 
    90   cancel_leading_coeff4: "Not (c =!= 0) ==> (a +   bdv + c*bdv^^^2 = 0) = 
    91 			                   (a/c + 1/c*bdv + bdv^^^2 = 0)"
    92   cancel_leading_coeff5: "Not (c =!= 0) ==> (a -   bdv + c*bdv^^^2 = 0) = 
    93 			                   (a/c - 1/c*bdv + bdv^^^2 = 0)"
    94   cancel_leading_coeff6: "Not (c =!= 0) ==> (a +   bdv - c*bdv^^^2 = 0) = 
    95 			                   (a/c + 1/c*bdv - bdv^^^2 = 0)"
    96 
    97   cancel_leading_coeff7: "Not (c =!= 0) ==> (    b*bdv + c*bdv^^^2 = 0) = 
    98 			                   (    b/c*bdv + bdv^^^2 = 0)"
    99   cancel_leading_coeff8: "Not (c =!= 0) ==> (    b*bdv - c*bdv^^^2 = 0) = 
   100 			                   (    b/c*bdv - bdv^^^2 = 0)"
   101 
   102   cancel_leading_coeff9: "Not (c =!= 0) ==> (      bdv + c*bdv^^^2 = 0) = 
   103 			                   (      1/c*bdv + bdv^^^2 = 0)"
   104   cancel_leading_coeff10:"Not (c =!= 0) ==> (      bdv - c*bdv^^^2 = 0) = 
   105 			                   (      1/c*bdv - bdv^^^2 = 0)"
   106 
   107   cancel_leading_coeff11:"Not (c =!= 0) ==> (a +      b*bdv^^^2 = 0) = 
   108 			                   (a/b +      bdv^^^2 = 0)"
   109   cancel_leading_coeff12:"Not (c =!= 0) ==> (a -      b*bdv^^^2 = 0) = 
   110 			                   (a/b -      bdv^^^2 = 0)"
   111   cancel_leading_coeff13:"Not (c =!= 0) ==> (         b*bdv^^^2 = 0) = 
   112 			                   (           bdv^^^2 = 0/b)"
   113 
   114   complete_square1:      "(q + p*bdv + bdv^^^2 = 0) = 
   115 		         (q + (p/2 + bdv)^^^2 = (p/2)^^^2)"
   116   complete_square2:      "(    p*bdv + bdv^^^2 = 0) = 
   117 		         (    (p/2 + bdv)^^^2 = (p/2)^^^2)"
   118   complete_square3:      "(      bdv + bdv^^^2 = 0) = 
   119 		         (    (1/2 + bdv)^^^2 = (1/2)^^^2)"
   120 		        
   121   complete_square4:      "(q - p*bdv + bdv^^^2 = 0) = 
   122 		         (q + (p/2 - bdv)^^^2 = (p/2)^^^2)"
   123   complete_square5:      "(q + p*bdv - bdv^^^2 = 0) = 
   124 		         (q + (p/2 - bdv)^^^2 = (p/2)^^^2)"
   125 
   126   square_explicit1:      "(a + b^^^2 = c) = ( b^^^2 = c - a)"
   127   square_explicit2:      "(a - b^^^2 = c) = (-(b^^^2) = c - a)"
   128 
   129   bdv_explicit1:         "(a + bdv = b) = (bdv = - a + b)"
   130   bdv_explicit2:         "(a - bdv = b) = ((-1)*bdv = - a + b)"
   131   bdv_explicit3:         "((-1)*bdv = b) = (bdv = (-1)*b)"
   132 
   133   plus_leq:              "(0 <= a + b) = ((-1)*b <= a)"(*Isa?*)
   134   minus_leq:             "(0 <= a - b) = (     b <= a)"(*Isa?*)
   135 
   136 (*-- normalize --*)
   137   (*WN0509 compare LinEq.all_left "[|Not(b=!=0)|] ==> (a=b) = (a+(-1)*b=0)"*)
   138   all_left:              "[|Not(b=!=0)|] ==> (a = b) = (a - b = 0)"
   139   makex1_x:              "a^^^1  = a"  
   140   real_assoc_1:          "a+(b+c) = a+b+c"
   141   real_assoc_2:          "a*(b*c) = a*b*c"
   142 
   143 (* ---- degree 0 ----*)
   144   d0_true:               "(0=0) = True"
   145   d0_false:              "[|Not(bdv occurs_in a);Not(a=0)|] ==> (a=0) = False"
   146 (* ---- degree 1 ----*)
   147   d1_isolate_add1:
   148    "[|Not(bdv occurs_in a)|] ==> (a + b*bdv = 0) = (b*bdv = (-1)*a)"
   149   d1_isolate_add2:
   150    "[|Not(bdv occurs_in a)|] ==> (a +   bdv = 0) = (  bdv = (-1)*a)"
   151   d1_isolate_div:
   152    "[|Not(b=0);Not(bdv occurs_in c)|] ==> (b*bdv = c) = (bdv = c/b)"
   153 (* ---- degree 2 ----*)
   154   d2_isolate_add1:
   155    "[|Not(bdv occurs_in a)|] ==> (a + b*bdv^^^2=0) = (b*bdv^^^2= (-1)*a)"
   156   d2_isolate_add2:
   157    "[|Not(bdv occurs_in a)|] ==> (a +   bdv^^^2=0) = (  bdv^^^2= (-1)*a)"
   158   d2_isolate_div:
   159    "[|Not(b=0);Not(bdv occurs_in c)|] ==> (b*bdv^^^2=c) = (bdv^^^2=c/b)"
   160 
   161   d2_prescind1:          "(a*bdv + b*bdv^^^2 = 0) = (bdv*(a +b*bdv)=0)"
   162   d2_prescind2:          "(a*bdv +   bdv^^^2 = 0) = (bdv*(a +  bdv)=0)"
   163   d2_prescind3:          "(  bdv + b*bdv^^^2 = 0) = (bdv*(1+b*bdv)=0)"
   164   d2_prescind4:          "(  bdv +   bdv^^^2 = 0) = (bdv*(1+  bdv)=0)"
   165   (* eliminate degree 2 *)
   166   (* thm for neg arguments in sqroot have postfix _neg *)
   167   d2_sqrt_equation1:     "[|(0<=c);Not(bdv occurs_in c)|] ==> 
   168                          (bdv^^^2=c) = ((bdv=sqrt c) | (bdv=(-1)*sqrt c ))"
   169   d2_sqrt_equation1_neg:
   170   "[|(c<0);Not(bdv occurs_in c)|] ==> (bdv^^^2=c) = False"
   171   d2_sqrt_equation2:     "(bdv^^^2=0) = (bdv=0)"
   172   d2_sqrt_equation3:     "(b*bdv^^^2=0) = (bdv=0)"
   173   d2_reduce_equation1:   "(bdv*(a +b*bdv)=0) = ((bdv=0)|(a+b*bdv=0))"
   174   d2_reduce_equation2:   "(bdv*(a +  bdv)=0) = ((bdv=0)|(a+  bdv=0))"
   175   d2_pqformula1:         "[|0<=p^^^2 - 4*q|] ==> (q+p*bdv+   bdv^^^2=0) =
   176                            ((bdv= (-1)*(p/2) + sqrt(p^^^2 - 4*q)/2) 
   177                           | (bdv= (-1)*(p/2) - sqrt(p^^^2 - 4*q)/2))"
   178   d2_pqformula1_neg:     "[|p^^^2 - 4*q<0|] ==> (q+p*bdv+   bdv^^^2=0) = False"
   179   d2_pqformula2:         "[|0<=p^^^2 - 4*q|] ==> (q+p*bdv+1*bdv^^^2=0) = 
   180                            ((bdv= (-1)*(p/2) + sqrt(p^^^2 - 4*q)/2) 
   181                           | (bdv= (-1)*(p/2) - sqrt(p^^^2 - 4*q)/2))"
   182   d2_pqformula2_neg:     "[|p^^^2 - 4*q<0|] ==> (q+p*bdv+1*bdv^^^2=0) = False"
   183   d2_pqformula3:         "[|0<=1 - 4*q|] ==> (q+  bdv+   bdv^^^2=0) = 
   184                            ((bdv= (-1)*(1/2) + sqrt(1 - 4*q)/2) 
   185                           | (bdv= (-1)*(1/2) - sqrt(1 - 4*q)/2))"
   186   d2_pqformula3_neg:     "[|1 - 4*q<0|] ==> (q+  bdv+   bdv^^^2=0) = False"
   187   d2_pqformula4:         "[|0<=1 - 4*q|] ==> (q+  bdv+1*bdv^^^2=0) = 
   188                            ((bdv= (-1)*(1/2) + sqrt(1 - 4*q)/2) 
   189                           | (bdv= (-1)*(1/2) - sqrt(1 - 4*q)/2))"
   190   d2_pqformula4_neg:     "[|1 - 4*q<0|] ==> (q+  bdv+1*bdv^^^2=0) = False"
   191   d2_pqformula5:         "[|0<=p^^^2 - 0|] ==> (  p*bdv+   bdv^^^2=0) =
   192                            ((bdv= (-1)*(p/2) + sqrt(p^^^2 - 0)/2) 
   193                           | (bdv= (-1)*(p/2) - sqrt(p^^^2 - 0)/2))"
   194   (* d2_pqformula5_neg not need p^2 never less zero in R *)
   195   d2_pqformula6:         "[|0<=p^^^2 - 0|] ==> (  p*bdv+1*bdv^^^2=0) = 
   196                            ((bdv= (-1)*(p/2) + sqrt(p^^^2 - 0)/2) 
   197                           | (bdv= (-1)*(p/2) - sqrt(p^^^2 - 0)/2))"
   198   (* d2_pqformula6_neg not need p^2 never less zero in R *)
   199   d2_pqformula7:        "[|0<=1 - 0|] ==> (    bdv+   bdv^^^2=0) = 
   200                            ((bdv= (-1)*(1/2) + sqrt(1 - 0)/2) 
   201                           | (bdv= (-1)*(1/2) - sqrt(1 - 0)/2))"
   202   (* d2_pqformula7_neg not need, because 1<0 ==> False*)
   203   d2_pqformula8:        "[|0<=1 - 0|] ==> (    bdv+1*bdv^^^2=0) = 
   204                            ((bdv= (-1)*(1/2) + sqrt(1 - 0)/2) 
   205                           | (bdv= (-1)*(1/2) - sqrt(1 - 0)/2))"
   206   (* d2_pqformula8_neg not need, because 1<0 ==> False*)
   207   d2_pqformula9:        "[|Not(bdv occurs_in q); 0<= (-1)*4*q|] ==> 
   208                            (q+    1*bdv^^^2=0) = ((bdv= 0 + sqrt(0 - 4*q)/2) 
   209                                                 | (bdv= 0 - sqrt(0 - 4*q)/2))"
   210   d2_pqformula9_neg:
   211    "[|Not(bdv occurs_in q); (-1)*4*q<0|] ==> (q+    1*bdv^^^2=0) = False"
   212   d2_pqformula10:
   213    "[|Not(bdv occurs_in q); 0<= (-1)*4*q|] ==> (q+     bdv^^^2=0) = 
   214            ((bdv= 0 + sqrt(0 - 4*q)/2) 
   215           | (bdv= 0 - sqrt(0 - 4*q)/2))"
   216   d2_pqformula10_neg:
   217    "[|Not(bdv occurs_in q); (-1)*4*q<0|] ==> (q+     bdv^^^2=0) = False"
   218   d2_abcformula1:
   219    "[|0<=b^^^2 - 4*a*c|] ==> (c + b*bdv+a*bdv^^^2=0) =
   220            ((bdv=( -b + sqrt(b^^^2 - 4*a*c))/(2*a)) 
   221           | (bdv=( -b - sqrt(b^^^2 - 4*a*c))/(2*a)))"
   222   d2_abcformula1_neg:
   223    "[|b^^^2 - 4*a*c<0|] ==> (c + b*bdv+a*bdv^^^2=0) = False"
   224   d2_abcformula2:
   225    "[|0<=1 - 4*a*c|]     ==> (c+    bdv+a*bdv^^^2=0) = 
   226            ((bdv=( -1 + sqrt(1 - 4*a*c))/(2*a)) 
   227           | (bdv=( -1 - sqrt(1 - 4*a*c))/(2*a)))"
   228   d2_abcformula2_neg:
   229    "[|1 - 4*a*c<0|]     ==> (c+    bdv+a*bdv^^^2=0) = False"
   230   d2_abcformula3:
   231    "[|0<=b^^^2 - 4*1*c|] ==> (c + b*bdv+  bdv^^^2=0) =
   232            ((bdv=( -b + sqrt(b^^^2 - 4*1*c))/(2*1)) 
   233           | (bdv=( -b - sqrt(b^^^2 - 4*1*c))/(2*1)))"
   234   d2_abcformula3_neg:
   235    "[|b^^^2 - 4*1*c<0|] ==> (c + b*bdv+  bdv^^^2=0) = False"
   236   d2_abcformula4:
   237    "[|0<=1 - 4*1*c|] ==> (c +   bdv+  bdv^^^2=0) =
   238            ((bdv=( -1 + sqrt(1 - 4*1*c))/(2*1)) 
   239           | (bdv=( -1 - sqrt(1 - 4*1*c))/(2*1)))"
   240   d2_abcformula4_neg:
   241    "[|1 - 4*1*c<0|] ==> (c +   bdv+  bdv^^^2=0) = False"
   242   d2_abcformula5:
   243    "[|Not(bdv occurs_in c); 0<=0 - 4*a*c|] ==> (c +  a*bdv^^^2=0) =
   244            ((bdv=( 0 + sqrt(0 - 4*a*c))/(2*a)) 
   245           | (bdv=( 0 - sqrt(0 - 4*a*c))/(2*a)))"
   246   d2_abcformula5_neg:
   247    "[|Not(bdv occurs_in c); 0 - 4*a*c<0|] ==> (c +  a*bdv^^^2=0) = False"
   248   d2_abcformula6:
   249    "[|Not(bdv occurs_in c); 0<=0 - 4*1*c|]     ==> (c+    bdv^^^2=0) = 
   250            ((bdv=( 0 + sqrt(0 - 4*1*c))/(2*1)) 
   251           | (bdv=( 0 - sqrt(0 - 4*1*c))/(2*1)))"
   252   d2_abcformula6_neg:
   253    "[|Not(bdv occurs_in c); 0 - 4*1*c<0|]     ==> (c+    bdv^^^2=0) = False"
   254   d2_abcformula7:
   255    "[|0<=b^^^2 - 0|]     ==> (    b*bdv+a*bdv^^^2=0) = 
   256            ((bdv=( -b + sqrt(b^^^2 - 0))/(2*a)) 
   257           | (bdv=( -b - sqrt(b^^^2 - 0))/(2*a)))"
   258   (* d2_abcformula7_neg not need b^2 never less zero in R *)
   259   d2_abcformula8:
   260    "[|0<=b^^^2 - 0|] ==> (    b*bdv+  bdv^^^2=0) =
   261            ((bdv=( -b + sqrt(b^^^2 - 0))/(2*1)) 
   262           | (bdv=( -b - sqrt(b^^^2 - 0))/(2*1)))"
   263   (* d2_abcformula8_neg not need b^2 never less zero in R *)
   264   d2_abcformula9:
   265    "[|0<=1 - 0|]     ==> (      bdv+a*bdv^^^2=0) = 
   266            ((bdv=( -1 + sqrt(1 - 0))/(2*a)) 
   267           | (bdv=( -1 - sqrt(1 - 0))/(2*a)))"
   268   (* d2_abcformula9_neg not need, because 1<0 ==> False*)
   269   d2_abcformula10:
   270    "[|0<=1 - 0|] ==> (      bdv+  bdv^^^2=0) =
   271            ((bdv=( -1 + sqrt(1 - 0))/(2*1)) 
   272           | (bdv=( -1 - sqrt(1 - 0))/(2*1)))"
   273   (* d2_abcformula10_neg not need, because 1<0 ==> False*)
   274 
   275 (* ---- degree 3 ----*)
   276   d3_reduce_equation1:
   277   "(a*bdv + b*bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (a + b*bdv + c*bdv^^^2=0))"
   278   d3_reduce_equation2:
   279   "(  bdv + b*bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (1 + b*bdv + c*bdv^^^2=0))"
   280   d3_reduce_equation3:
   281   "(a*bdv +   bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (a +   bdv + c*bdv^^^2=0))"
   282   d3_reduce_equation4:
   283   "(  bdv +   bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (1 +   bdv + c*bdv^^^2=0))"
   284   d3_reduce_equation5:
   285   "(a*bdv + b*bdv^^^2 +   bdv^^^3=0) = (bdv=0 | (a + b*bdv +   bdv^^^2=0))"
   286   d3_reduce_equation6:
   287   "(  bdv + b*bdv^^^2 +   bdv^^^3=0) = (bdv=0 | (1 + b*bdv +   bdv^^^2=0))"
   288   d3_reduce_equation7:
   289   "(a*bdv +   bdv^^^2 +   bdv^^^3=0) = (bdv=0 | (1 +   bdv +   bdv^^^2=0))"
   290   d3_reduce_equation8:
   291   "(  bdv +   bdv^^^2 +   bdv^^^3=0) = (bdv=0 | (1 +   bdv +   bdv^^^2=0))"
   292   d3_reduce_equation9:
   293   "(a*bdv             + c*bdv^^^3=0) = (bdv=0 | (a         + c*bdv^^^2=0))"
   294   d3_reduce_equation10:
   295   "(  bdv             + c*bdv^^^3=0) = (bdv=0 | (1         + c*bdv^^^2=0))"
   296   d3_reduce_equation11:
   297   "(a*bdv             +   bdv^^^3=0) = (bdv=0 | (a         +   bdv^^^2=0))"
   298   d3_reduce_equation12:
   299   "(  bdv             +   bdv^^^3=0) = (bdv=0 | (1         +   bdv^^^2=0))"
   300   d3_reduce_equation13:
   301   "(        b*bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (    b*bdv + c*bdv^^^2=0))"
   302   d3_reduce_equation14:
   303   "(          bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (      bdv + c*bdv^^^2=0))"
   304   d3_reduce_equation15:
   305   "(        b*bdv^^^2 +   bdv^^^3=0) = (bdv=0 | (    b*bdv +   bdv^^^2=0))"
   306   d3_reduce_equation16:
   307   "(          bdv^^^2 +   bdv^^^3=0) = (bdv=0 | (      bdv +   bdv^^^2=0))"
   308   d3_isolate_add1:
   309   "[|Not(bdv occurs_in a)|] ==> (a + b*bdv^^^3=0) = (b*bdv^^^3= (-1)*a)"
   310   d3_isolate_add2:
   311   "[|Not(bdv occurs_in a)|] ==> (a +   bdv^^^3=0) = (  bdv^^^3= (-1)*a)"
   312   d3_isolate_div:
   313    "[|Not(b=0);Not(bdv occurs_in a)|] ==> (b*bdv^^^3=c) = (bdv^^^3=c/b)"
   314   d3_root_equation2:
   315   "(bdv^^^3=0) = (bdv=0)"
   316   d3_root_equation1:
   317   "(bdv^^^3=c) = (bdv = nroot 3 c)"
   318 
   319 (* ---- degree 4 ----*)
   320  (* RL03.FIXME es wir nicht getestet ob u>0 *)
   321  d4_sub_u1:
   322  "(c+b*bdv^^^2+a*bdv^^^4=0) =
   323    ((a*u^^^2+b*u+c=0) & (bdv^^^2=u))"
   324 
   325 (* ---- 7.3.02 von Termorder ---- *)
   326 
   327   bdv_collect_1:      "l * bdv + m * bdv = (l + m) * bdv"
   328   bdv_collect_2:      "bdv + m * bdv = (1 + m) * bdv"
   329   bdv_collect_3:      "l * bdv + bdv = (l + 1) * bdv"
   330 
   331 (*  bdv_collect_assoc0_1 "l * bdv + m * bdv + k = (l + m) * bdv + k"
   332     bdv_collect_assoc0_2 "bdv + m * bdv + k = (1 + m) * bdv + k"
   333     bdv_collect_assoc0_3 "l * bdv + bdv + k = (l + 1) * bdv + k"
   334 *)
   335   bdv_collect_assoc1_1:"l * bdv + (m * bdv + k) = (l + m) * bdv + k"
   336   bdv_collect_assoc1_2:"bdv + (m * bdv + k) = (1 + m) * bdv + k"
   337   bdv_collect_assoc1_3:"l * bdv + (bdv + k) = (l + 1) * bdv + k"
   338 
   339   bdv_collect_assoc2_1:"k + l * bdv + m * bdv = k + (l + m) * bdv"
   340   bdv_collect_assoc2_2:"k + bdv + m * bdv = k + (1 + m) * bdv"
   341   bdv_collect_assoc2_3:"k + l * bdv + bdv = k + (l + 1) * bdv"
   342 
   343 
   344   bdv_n_collect_1:     "l * bdv^^^n + m * bdv^^^n = (l + m) * bdv^^^n"
   345   bdv_n_collect_2:     " bdv^^^n + m * bdv^^^n = (1 + m) * bdv^^^n"
   346   bdv_n_collect_3:     "l * bdv^^^n + bdv^^^n = (l + 1) * bdv^^^n"   (*order!*)
   347 
   348   bdv_n_collect_assoc1_1:"l * bdv^^^n + (m * bdv^^^n + k) = (l + m) * bdv^^^n + k"
   349   bdv_n_collect_assoc1_2:"bdv^^^n + (m * bdv^^^n + k) = (1 + m) * bdv^^^n + k"
   350   bdv_n_collect_assoc1_3:"l * bdv^^^n + (bdv^^^n + k) = (l + 1) * bdv^^^n + k"
   351 
   352   bdv_n_collect_assoc2_1:"k + l * bdv^^^n + m * bdv^^^n = k + (l + m) * bdv^^^n"
   353   bdv_n_collect_assoc2_2:"k + bdv^^^n + m * bdv^^^n = k + (1 + m) * bdv^^^n"
   354   bdv_n_collect_assoc2_3:"k + l * bdv^^^n + bdv^^^n = k + (l + 1) * bdv^^^n"
   355 
   356 (*WN.14.3.03*)
   357   real_minus_div:        "- (a / b) = (-1 * a) / b"
   358 
   359   separate_bdv:          "(a * bdv) / b = (a / b) * bdv"
   360   separate_bdv_n:        "(a * bdv ^^^ n) / b = (a / b) * bdv ^^^ n"
   361   separate_1_bdv:        "bdv / b = (1 / b) * bdv"
   362   separate_1_bdv_n:      "bdv ^^^ n / b = (1 / b) * bdv ^^^ n"
   363 
   364 ML {*
   365 val thy = @{theory};
   366 
   367 (*-------------------------rulse-------------------------*)
   368 val PolyEq_prls = (*3.10.02:just the following order due to subterm evaluation*)
   369   append_rls "PolyEq_prls" e_rls 
   370 	     [Calc ("Atools.ident",eval_ident "#ident_"),
   371 	      Calc ("Tools.matches",eval_matches ""),
   372 	      Calc ("Tools.lhs"    ,eval_lhs ""),
   373 	      Calc ("Tools.rhs"    ,eval_rhs ""),
   374 	      Calc ("Poly.is'_expanded'_in",eval_is_expanded_in ""),
   375 	      Calc ("Poly.is'_poly'_in",eval_is_poly_in ""),
   376 	      Calc ("Poly.has'_degree'_in",eval_has_degree_in ""),    
   377               Calc ("Poly.is'_polyrat'_in",eval_is_polyrat_in ""),
   378 	      (*Calc ("Atools.occurs'_in",eval_occurs_in ""),   *) 
   379 	      (*Calc ("Atools.is'_const",eval_const "#is_const_"),*)
   380 	      Calc ("op =",eval_equal "#equal_"),
   381               Calc ("RootEq.is'_rootTerm'_in",eval_is_rootTerm_in ""),
   382 	      Calc ("RatEq.is'_ratequation'_in",eval_is_ratequation_in ""),
   383 	      Thm ("not_true",num_str @{thm not_true}),
   384 	      Thm ("not_false",num_str @{thm not_false}),
   385 	      Thm ("and_true",num_str @{thm and_true}),
   386 	      Thm ("and_false",num_str @{thm and_false}),
   387 	      Thm ("or_true",num_str @{thm or_true}),
   388 	      Thm ("or_false",num_str @{thm or_false})
   389 	       ];
   390 
   391 val PolyEq_erls = 
   392     merge_rls "PolyEq_erls" LinEq_erls
   393     (append_rls "ops_preds" calculate_Rational
   394 		[Calc ("op =",eval_equal "#equal_"),
   395 		 Thm ("plus_leq", num_str @{thm plus_leq}),
   396 		 Thm ("minus_leq", num_str @{thm minus_leq}),
   397 		 Thm ("rat_leq1", num_str @{thm rat_leq1}),
   398 		 Thm ("rat_leq2", num_str @{thm rat_leq2}),
   399 		 Thm ("rat_leq3", num_str @{thm rat_leq3})
   400 		 ]);
   401 
   402 val PolyEq_crls = 
   403     merge_rls "PolyEq_crls" LinEq_crls
   404     (append_rls "ops_preds" calculate_Rational
   405 		[Calc ("op =",eval_equal "#equal_"),
   406 		 Thm ("plus_leq", num_str @{thm plus_leq}),
   407 		 Thm ("minus_leq", num_str @{thm minus_leq}),
   408 		 Thm ("rat_leq1", num_str @{thm rat_leq1}),
   409 		 Thm ("rat_leq2", num_str @{thm rat_leq2}),
   410 		 Thm ("rat_leq3", num_str @{thm rat_leq3})
   411 		 ]);
   412 
   413 val cancel_leading_coeff = prep_rls(
   414   Rls {id = "cancel_leading_coeff", preconds = [], 
   415        rew_ord = ("e_rew_ord",e_rew_ord),
   416       erls = PolyEq_erls, srls = Erls, calc = [], (*asm_thm = [],*)
   417       rules = 
   418       [Thm ("cancel_leading_coeff1",num_str @{thm cancel_leading_coeff1}),
   419        Thm ("cancel_leading_coeff2",num_str @{thm cancel_leading_coeff2}),
   420        Thm ("cancel_leading_coeff3",num_str @{thm cancel_leading_coeff3}),
   421        Thm ("cancel_leading_coeff4",num_str @{thm cancel_leading_coeff4}),
   422        Thm ("cancel_leading_coeff5",num_str @{thm cancel_leading_coeff5}),
   423        Thm ("cancel_leading_coeff6",num_str @{thm cancel_leading_coeff6}),
   424        Thm ("cancel_leading_coeff7",num_str @{thm cancel_leading_coeff7}),
   425        Thm ("cancel_leading_coeff8",num_str @{thm cancel_leading_coeff8}),
   426        Thm ("cancel_leading_coeff9",num_str @{thm cancel_leading_coeff9}),
   427        Thm ("cancel_leading_coeff10",num_str @{thm cancel_leading_coeff10}),
   428        Thm ("cancel_leading_coeff11",num_str @{thm cancel_leading_coeff11}),
   429        Thm ("cancel_leading_coeff12",num_str @{thm cancel_leading_coeff12}),
   430        Thm ("cancel_leading_coeff13",num_str @{thm cancel_leading_coeff13})
   431        ],scr = Script ((term_of o the o (parse thy)) "empty_script")}:rls);
   432 *}
   433 ML{*
   434 val complete_square = prep_rls(
   435   Rls {id = "complete_square", preconds = [], 
   436        rew_ord = ("e_rew_ord",e_rew_ord),
   437       erls = PolyEq_erls, srls = Erls, calc = [], (*asm_thm = [],*)
   438       rules = [Thm ("complete_square1",num_str @{thm complete_square1}),
   439 	       Thm ("complete_square2",num_str @{thm complete_square2}),
   440 	       Thm ("complete_square3",num_str @{thm complete_square3}),
   441 	       Thm ("complete_square4",num_str @{thm complete_square4}),
   442 	       Thm ("complete_square5",num_str @{thm complete_square5})
   443 	       ],
   444       scr = Script ((term_of o the o (parse thy)) 
   445       "empty_script")
   446       }:rls);
   447 
   448 val polyeq_simplify = prep_rls(
   449   Rls {id = "polyeq_simplify", preconds = [], 
   450        rew_ord = ("termlessI",termlessI), 
   451        erls = PolyEq_erls, 
   452        srls = Erls, 
   453        calc = [], 
   454        (*asm_thm = [],*)
   455        rules = [Thm  ("real_assoc_1",num_str @{thm real_assoc_1}),
   456 		Thm  ("real_assoc_2",num_str @{thm real_assoc_2}),
   457 		Thm  ("real_diff_minus",num_str @{thm real_diff_minus}),
   458 		Thm  ("real_unari_minus",num_str @{thm real_unari_minus}),
   459 		Thm  ("realpow_multI",num_str @{thm realpow_multI}),
   460 		Calc ("op +",eval_binop "#add_"),
   461 		Calc ("op -",eval_binop "#sub_"),
   462 		Calc ("op *",eval_binop "#mult_"),
   463 		Calc ("HOL.divide", eval_cancel "#divide_e"),
   464 		Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
   465 		Calc ("Atools.pow" ,eval_binop "#power_"),
   466                 Rls_ reduce_012
   467                 ],
   468        scr = Script ((term_of o the o (parse thy)) "empty_script")
   469        }:rls);
   470 
   471 ruleset' := overwritelthy @{theory} (!ruleset',
   472 		[("cancel_leading_coeff",cancel_leading_coeff),
   473 		 ("complete_square",complete_square),
   474 		 ("PolyEq_erls",PolyEq_erls),(*FIXXXME:del with rls.rls'*)
   475 		 ("polyeq_simplify",polyeq_simplify)]);
   476 
   477 *}
   478 ML{*
   479 
   480 (* ------------- polySolve ------------------ *)
   481 (* -- d0 -- *)
   482 (*isolate the bound variable in an d0 equation; 'bdv' is a meta-constant*)
   483 val d0_polyeq_simplify = prep_rls(
   484   Rls {id = "d0_polyeq_simplify", preconds = [],
   485        rew_ord = ("e_rew_ord",e_rew_ord),
   486        erls = PolyEq_erls,
   487        srls = Erls, 
   488        calc = [], 
   489        (*asm_thm = [],*)
   490        rules = [Thm("d0_true",num_str @{thm d0_true}),
   491 		Thm("d0_false",num_str @{thm  d0_false})
   492 		],
   493        scr = Script ((term_of o the o (parse thy)) "empty_script")
   494        }:rls);
   495 
   496 (* -- d1 -- *)
   497 (*isolate the bound variable in an d1 equation; 'bdv' is a meta-constant*)
   498 val d1_polyeq_simplify = prep_rls(
   499   Rls {id = "d1_polyeq_simplify", preconds = [],
   500        rew_ord = ("e_rew_ord",e_rew_ord),
   501        erls = PolyEq_erls,
   502        srls = Erls, 
   503        calc = [], 
   504        (*asm_thm = [("d1_isolate_div","")],*)
   505        rules = [
   506 		Thm("d1_isolate_add1",num_str @{thm d1_isolate_add1}), 
   507 		(* a+bx=0 -> bx=-a *)
   508 		Thm("d1_isolate_add2",num_str @{thm d1_isolate_add2}), 
   509 		(* a+ x=0 ->  x=-a *)
   510 		Thm("d1_isolate_div",num_str @{thm d1_isolate_div})    
   511 		(*   bx=c -> x=c/b *)  
   512 		],
   513        scr = Script ((term_of o the o (parse thy)) "empty_script")
   514        }:rls);
   515 
   516 *}
   517 ML{*
   518 (* -- d2 -- *)
   519 (* isolate the bound variable in an d2 equation with bdv only; 
   520    'bdv' is a meta-constant*)
   521 val d2_polyeq_bdv_only_simplify = prep_rls(
   522   Rls {id = "d2_polyeq_bdv_only_simplify", preconds = [],
   523        rew_ord = ("e_rew_ord",e_rew_ord),
   524        erls = PolyEq_erls,
   525        srls = Erls, 
   526        calc = [], 
   527        (*asm_thm = [("d2_sqrt_equation1",""),("d2_sqrt_equation1_neg",""),
   528                   ("d2_isolate_div","")],*)
   529        rules = [Thm("d2_prescind1",num_str @{thm d2_prescind1}),
   530                 (*   ax+bx^2=0 -> x(a+bx)=0 *)
   531 		Thm("d2_prescind2",num_str @{thm d2_prescind2}),
   532                 (*   ax+ x^2=0 -> x(a+ x)=0 *)
   533 		Thm("d2_prescind3",num_str @{thm d2_prescind3}),
   534                 (*    x+bx^2=0 -> x(1+bx)=0 *)
   535 		Thm("d2_prescind4",num_str @{thm d2_prescind4}),
   536                 (*    x+ x^2=0 -> x(1+ x)=0 *)
   537 		Thm("d2_sqrt_equation1",num_str @{thm d2_sqrt_equation1}),
   538                 (* x^2=c   -> x=+-sqrt(c)*)
   539 		Thm("d2_sqrt_equation1_neg",num_str @{thm d2_sqrt_equation1_neg}),
   540                 (* [0<c] x^2=c  -> [] *)
   541 		Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
   542                 (*  x^2=0 ->    x=0    *)
   543 		Thm("d2_reduce_equation1",num_str @{thm d2_reduce_equation1}),
   544                 (* x(a+bx)=0 -> x=0 | a+bx=0*)
   545 		Thm("d2_reduce_equation2",num_str @{thm d2_reduce_equation2}),
   546                 (* x(a+ x)=0 -> x=0 | a+ x=0*)
   547 		Thm("d2_isolate_div",num_str @{thm d2_isolate_div})
   548                 (* bx^2=c -> x^2=c/b*)
   549 		],
   550        scr = Script ((term_of o the o (parse thy)) "empty_script")
   551        }:rls);
   552 *}
   553 ML{*
   554 (* isolate the bound variable in an d2 equation with sqrt only; 
   555    'bdv' is a meta-constant*)
   556 val d2_polyeq_sq_only_simplify = prep_rls(
   557   Rls {id = "d2_polyeq_sq_only_simplify", preconds = [],
   558        rew_ord = ("e_rew_ord",e_rew_ord),
   559        erls = PolyEq_erls,
   560        srls = Erls, 
   561        calc = [], 
   562        (*asm_thm = [("d2_sqrt_equation1",""),("d2_sqrt_equation1_neg",""),
   563                   ("d2_isolate_div","")],*)
   564        rules = [Thm("d2_isolate_add1",num_str @{thm d2_isolate_add1}),
   565                 (* a+   bx^2=0 -> bx^2=(-1)a*)
   566 		Thm("d2_isolate_add2",num_str @{thm d2_isolate_add2}),
   567                 (* a+    x^2=0 ->  x^2=(-1)a*)
   568 		Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
   569                 (*  x^2=0 ->    x=0    *)
   570 		Thm("d2_sqrt_equation1",num_str @{thm d2_sqrt_equation1}),
   571                 (* x^2=c   -> x=+-sqrt(c)*)
   572 		Thm("d2_sqrt_equation1_neg",num_str @{thm d2_sqrt_equation1_neg}),
   573                 (* [c<0] x^2=c  -> x=[] *)
   574 		Thm("d2_isolate_div",num_str @{thm d2_isolate_div})
   575                  (* bx^2=c -> x^2=c/b*)
   576 		],
   577        scr = Script ((term_of o the o (parse thy)) "empty_script")
   578        }:rls);
   579 *}
   580 ML{*
   581 (* isolate the bound variable in an d2 equation with pqFormula;
   582    'bdv' is a meta-constant*)
   583 val d2_polyeq_pqFormula_simplify = prep_rls(
   584   Rls {id = "d2_polyeq_pqFormula_simplify", preconds = [],
   585        rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
   586        srls = Erls, calc = [], 
   587        rules = [Thm("d2_pqformula1",num_str @{thm d2_pqformula1}),
   588                 (* q+px+ x^2=0 *)
   589 		Thm("d2_pqformula1_neg",num_str @{thm d2_pqformula1_neg}),
   590                 (* q+px+ x^2=0 *)
   591 		Thm("d2_pqformula2",num_str @{thm d2_pqformula2}), 
   592                 (* q+px+1x^2=0 *)
   593 		Thm("d2_pqformula2_neg",num_str @{thm d2_pqformula2_neg}),
   594                 (* q+px+1x^2=0 *)
   595 		Thm("d2_pqformula3",num_str @{thm d2_pqformula3}),
   596                 (* q+ x+ x^2=0 *)
   597 		Thm("d2_pqformula3_neg",num_str @{thm d2_pqformula3_neg}), 
   598                 (* q+ x+ x^2=0 *)
   599 		Thm("d2_pqformula4",num_str @{thm d2_pqformula4}),
   600                 (* q+ x+1x^2=0 *)
   601 		Thm("d2_pqformula4_neg",num_str @{thm d2_pqformula4_neg}),
   602                 (* q+ x+1x^2=0 *)
   603 		Thm("d2_pqformula5",num_str @{thm d2_pqformula5}),
   604                 (*   qx+ x^2=0 *)
   605 		Thm("d2_pqformula6",num_str @{thm d2_pqformula6}),
   606                 (*   qx+1x^2=0 *)
   607 		Thm("d2_pqformula7",num_str @{thm d2_pqformula7}),
   608                 (*    x+ x^2=0 *)
   609 		Thm("d2_pqformula8",num_str @{thm d2_pqformula8}),
   610                 (*    x+1x^2=0 *)
   611 		Thm("d2_pqformula9",num_str @{thm d2_pqformula9}),
   612                 (* q   +1x^2=0 *)
   613 		Thm("d2_pqformula9_neg",num_str @{thm d2_pqformula9_neg}),
   614                 (* q   +1x^2=0 *)
   615 		Thm("d2_pqformula10",num_str @{thm d2_pqformula10}),
   616                 (* q   + x^2=0 *)
   617 		Thm("d2_pqformula10_neg",num_str @{thm d2_pqformula10_neg}),
   618                 (* q   + x^2=0 *)
   619 		Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
   620                 (*       x^2=0 *)
   621 		Thm("d2_sqrt_equation3",num_str @{thm d2_sqrt_equation3})
   622                (*      1x^2=0 *)
   623 	       ],scr = Script ((term_of o the o (parse thy)) "empty_script")
   624        }:rls);
   625 *}
   626 ML{*
   627 (* isolate the bound variable in an d2 equation with abcFormula; 
   628    'bdv' is a meta-constant*)
   629 val d2_polyeq_abcFormula_simplify = prep_rls(
   630   Rls {id = "d2_polyeq_abcFormula_simplify", preconds = [],
   631        rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
   632        srls = Erls, calc = [], 
   633        rules = [Thm("d2_abcformula1",num_str @{thm d2_abcformula1}),
   634                 (*c+bx+cx^2=0 *)
   635 		Thm("d2_abcformula1_neg",num_str @{thm d2_abcformula1_neg}),
   636                 (*c+bx+cx^2=0 *)
   637 		Thm("d2_abcformula2",num_str @{thm d2_abcformula2}),
   638                 (*c+ x+cx^2=0 *)
   639 		Thm("d2_abcformula2_neg",num_str @{thm d2_abcformula2_neg}),
   640                 (*c+ x+cx^2=0 *)
   641 		Thm("d2_abcformula3",num_str @{thm d2_abcformula3}), 
   642                 (*c+bx+ x^2=0 *)
   643 		Thm("d2_abcformula3_neg",num_str @{thm d2_abcformula3_neg}),
   644                 (*c+bx+ x^2=0 *)
   645 		Thm("d2_abcformula4",num_str @{thm d2_abcformula4}),
   646                 (*c+ x+ x^2=0 *)
   647 		Thm("d2_abcformula4_neg",num_str @{thm d2_abcformula4_neg}),
   648                 (*c+ x+ x^2=0 *)
   649 		Thm("d2_abcformula5",num_str @{thm d2_abcformula5}),
   650                 (*c+   cx^2=0 *)
   651 		Thm("d2_abcformula5_neg",num_str @{thm d2_abcformula5_neg}),
   652                 (*c+   cx^2=0 *)
   653 		Thm("d2_abcformula6",num_str @{thm d2_abcformula6}),
   654                 (*c+    x^2=0 *)
   655 		Thm("d2_abcformula6_neg",num_str @{thm d2_abcformula6_neg}),
   656                 (*c+    x^2=0 *)
   657 		Thm("d2_abcformula7",num_str @{thm d2_abcformula7}),
   658                 (*  bx+ax^2=0 *)
   659 		Thm("d2_abcformula8",num_str @{thm d2_abcformula8}),
   660                 (*  bx+ x^2=0 *)
   661 		Thm("d2_abcformula9",num_str @{thm d2_abcformula9}),
   662                 (*   x+ax^2=0 *)
   663 		Thm("d2_abcformula10",num_str @{thm d2_abcformula10}),
   664                 (*   x+ x^2=0 *)
   665 		Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
   666                 (*      x^2=0 *)  
   667 		Thm("d2_sqrt_equation3",num_str @{thm d2_sqrt_equation3})
   668                (*     bx^2=0 *)  
   669 	       ],
   670        scr = Script ((term_of o the o (parse thy)) "empty_script")
   671        }:rls);
   672 *}
   673 ML{*
   674 
   675 (* isolate the bound variable in an d2 equation; 
   676    'bdv' is a meta-constant*)
   677 val d2_polyeq_simplify = prep_rls(
   678   Rls {id = "d2_polyeq_simplify", preconds = [],
   679        rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
   680        srls = Erls, calc = [], 
   681        rules = [Thm("d2_pqformula1",num_str @{thm d2_pqformula1}),
   682                 (* p+qx+ x^2=0 *)
   683 		Thm("d2_pqformula1_neg",num_str @{thm d2_pqformula1_neg}),
   684                 (* p+qx+ x^2=0 *)
   685 		Thm("d2_pqformula2",num_str @{thm d2_pqformula2}),
   686                 (* p+qx+1x^2=0 *)
   687 		Thm("d2_pqformula2_neg",num_str @{thm d2_pqformula2_neg}),
   688                 (* p+qx+1x^2=0 *)
   689 		Thm("d2_pqformula3",num_str @{thm d2_pqformula3}),
   690                 (* p+ x+ x^2=0 *)
   691 		Thm("d2_pqformula3_neg",num_str @{thm d2_pqformula3_neg}),
   692                 (* p+ x+ x^2=0 *)
   693 		Thm("d2_pqformula4",num_str @{thm d2_pqformula4}), 
   694                 (* p+ x+1x^2=0 *)
   695 		Thm("d2_pqformula4_neg",num_str @{thm d2_pqformula4_neg}),
   696                 (* p+ x+1x^2=0 *)
   697 		Thm("d2_abcformula1",num_str @{thm d2_abcformula1}),
   698                 (* c+bx+cx^2=0 *)
   699 		Thm("d2_abcformula1_neg",num_str @{thm d2_abcformula1_neg}),
   700                 (* c+bx+cx^2=0 *)
   701 		Thm("d2_abcformula2",num_str @{thm d2_abcformula2}),
   702                 (* c+ x+cx^2=0 *)
   703 		Thm("d2_abcformula2_neg",num_str @{thm d2_abcformula2_neg}),
   704                 (* c+ x+cx^2=0 *)
   705 		Thm("d2_prescind1",num_str @{thm d2_prescind1}),
   706                 (*   ax+bx^2=0 -> x(a+bx)=0 *)
   707 		Thm("d2_prescind2",num_str @{thm d2_prescind2}),
   708                 (*   ax+ x^2=0 -> x(a+ x)=0 *)
   709 		Thm("d2_prescind3",num_str @{thm d2_prescind3}),
   710                 (*    x+bx^2=0 -> x(1+bx)=0 *)
   711 		Thm("d2_prescind4",num_str @{thm d2_prescind4}),
   712                 (*    x+ x^2=0 -> x(1+ x)=0 *)
   713 		Thm("d2_isolate_add1",num_str @{thm d2_isolate_add1}),
   714                 (* a+   bx^2=0 -> bx^2=(-1)a*)
   715 		Thm("d2_isolate_add2",num_str @{thm d2_isolate_add2}),
   716                 (* a+    x^2=0 ->  x^2=(-1)a*)
   717 		Thm("d2_sqrt_equation1",num_str @{thm d2_sqrt_equation1}),
   718                 (* x^2=c   -> x=+-sqrt(c)*)
   719 		Thm("d2_sqrt_equation1_neg",num_str @{thm d2_sqrt_equation1_neg}),
   720                 (* [c<0] x^2=c   -> x=[]*)
   721 		Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
   722                 (*  x^2=0 ->    x=0    *)
   723 		Thm("d2_reduce_equation1",num_str @{thm d2_reduce_equation1}),
   724                 (* x(a+bx)=0 -> x=0 | a+bx=0*)
   725 		Thm("d2_reduce_equation2",num_str @{thm d2_reduce_equation2}),
   726                 (* x(a+ x)=0 -> x=0 | a+ x=0*)
   727 		Thm("d2_isolate_div",num_str @{thm d2_isolate_div})
   728                (* bx^2=c -> x^2=c/b*)
   729 	       ],
   730        scr = Script ((term_of o the o (parse thy)) "empty_script")
   731       }:rls);
   732 *}
   733 ML{*
   734 
   735 (* -- d3 -- *)
   736 (* isolate the bound variable in an d3 equation; 'bdv' is a meta-constant *)
   737 val d3_polyeq_simplify = prep_rls(
   738   Rls {id = "d3_polyeq_simplify", preconds = [],
   739        rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
   740        srls = Erls, calc = [], 
   741        rules = 
   742        [Thm("d3_reduce_equation1",num_str @{thm d3_reduce_equation1}),
   743 	(*a*bdv + b*bdv^^^2 + c*bdv^^^3=0) = 
   744         (bdv=0 | (a + b*bdv + c*bdv^^^2=0)*)
   745 	Thm("d3_reduce_equation2",num_str @{thm d3_reduce_equation2}),
   746 	(*  bdv + b*bdv^^^2 + c*bdv^^^3=0) = 
   747         (bdv=0 | (1 + b*bdv + c*bdv^^^2=0)*)
   748 	Thm("d3_reduce_equation3",num_str @{thm d3_reduce_equation3}),
   749 	(*a*bdv +   bdv^^^2 + c*bdv^^^3=0) = 
   750         (bdv=0 | (a +   bdv + c*bdv^^^2=0)*)
   751 	Thm("d3_reduce_equation4",num_str @{thm d3_reduce_equation4}),
   752 	(*  bdv +   bdv^^^2 + c*bdv^^^3=0) = 
   753         (bdv=0 | (1 +   bdv + c*bdv^^^2=0)*)
   754 	Thm("d3_reduce_equation5",num_str @{thm d3_reduce_equation5}),
   755 	(*a*bdv + b*bdv^^^2 +   bdv^^^3=0) = 
   756         (bdv=0 | (a + b*bdv +   bdv^^^2=0)*)
   757 	Thm("d3_reduce_equation6",num_str @{thm d3_reduce_equation6}),
   758 	(*  bdv + b*bdv^^^2 +   bdv^^^3=0) = 
   759         (bdv=0 | (1 + b*bdv +   bdv^^^2=0)*)
   760 	Thm("d3_reduce_equation7",num_str @{thm d3_reduce_equation7}),
   761 	     (*a*bdv +   bdv^^^2 +   bdv^^^3=0) = 
   762              (bdv=0 | (1 +   bdv +   bdv^^^2=0)*)
   763 	Thm("d3_reduce_equation8",num_str @{thm d3_reduce_equation8}),
   764 	     (*  bdv +   bdv^^^2 +   bdv^^^3=0) = 
   765              (bdv=0 | (1 +   bdv +   bdv^^^2=0)*)
   766 	Thm("d3_reduce_equation9",num_str @{thm d3_reduce_equation9}),
   767 	     (*a*bdv             + c*bdv^^^3=0) = 
   768              (bdv=0 | (a         + c*bdv^^^2=0)*)
   769 	Thm("d3_reduce_equation10",num_str @{thm d3_reduce_equation10}),
   770 	     (*  bdv             + c*bdv^^^3=0) = 
   771              (bdv=0 | (1         + c*bdv^^^2=0)*)
   772 	Thm("d3_reduce_equation11",num_str @{thm d3_reduce_equation11}),
   773 	     (*a*bdv             +   bdv^^^3=0) = 
   774              (bdv=0 | (a         +   bdv^^^2=0)*)
   775 	Thm("d3_reduce_equation12",num_str @{thm d3_reduce_equation12}),
   776 	     (*  bdv             +   bdv^^^3=0) = 
   777              (bdv=0 | (1         +   bdv^^^2=0)*)
   778 	Thm("d3_reduce_equation13",num_str @{thm d3_reduce_equation13}),
   779 	     (*        b*bdv^^^2 + c*bdv^^^3=0) = 
   780              (bdv=0 | (    b*bdv + c*bdv^^^2=0)*)
   781 	Thm("d3_reduce_equation14",num_str @{thm d3_reduce_equation14}),
   782 	     (*          bdv^^^2 + c*bdv^^^3=0) = 
   783              (bdv=0 | (      bdv + c*bdv^^^2=0)*)
   784 	Thm("d3_reduce_equation15",num_str @{thm d3_reduce_equation15}),
   785 	     (*        b*bdv^^^2 +   bdv^^^3=0) = 
   786              (bdv=0 | (    b*bdv +   bdv^^^2=0)*)
   787 	Thm("d3_reduce_equation16",num_str @{thm d3_reduce_equation16}),
   788 	     (*          bdv^^^2 +   bdv^^^3=0) = 
   789              (bdv=0 | (      bdv +   bdv^^^2=0)*)
   790 	Thm("d3_isolate_add1",num_str @{thm d3_isolate_add1}),
   791 	     (*[|Not(bdv occurs_in a)|] ==> (a + b*bdv^^^3=0) = 
   792               (bdv=0 | (b*bdv^^^3=a)*)
   793 	Thm("d3_isolate_add2",num_str @{thm d3_isolate_add2}),
   794              (*[|Not(bdv occurs_in a)|] ==> (a +   bdv^^^3=0) = 
   795               (bdv=0 | (  bdv^^^3=a)*)
   796 	Thm("d3_isolate_div",num_str @{thm d3_isolate_div}),
   797         (*[|Not(b=0)|] ==> (b*bdv^^^3=c) = (bdv^^^3=c/b*)
   798         Thm("d3_root_equation2",num_str @{thm d3_root_equation2}),
   799         (*(bdv^^^3=0) = (bdv=0) *)
   800 	Thm("d3_root_equation1",num_str @{thm d3_root_equation1})
   801        (*bdv^^^3=c) = (bdv = nroot 3 c*)
   802        ],
   803        scr = Script ((term_of o the o (parse thy)) "empty_script")
   804       }:rls);
   805 *}
   806 ML{*
   807 
   808 (* -- d4 -- *)
   809 (*isolate the bound variable in an d4 equation; 'bdv' is a meta-constant*)
   810 val d4_polyeq_simplify = prep_rls(
   811   Rls {id = "d4_polyeq_simplify", preconds = [],
   812        rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
   813        srls = Erls, calc = [], 
   814        rules = 
   815        [Thm("d4_sub_u1",num_str @{thm d4_sub_u1})  
   816        (* ax^4+bx^2+c=0 -> x=+-sqrt(ax^2+bx^+c) *)
   817        ],
   818        scr = Script ((term_of o the o (parse thy)) "empty_script")
   819       }:rls);
   820   
   821 ruleset' := 
   822 overwritelthy @{theory} 
   823               (!ruleset',
   824                [("d0_polyeq_simplify", d0_polyeq_simplify),
   825                 ("d1_polyeq_simplify", d1_polyeq_simplify),
   826                 ("d2_polyeq_simplify", d2_polyeq_simplify),
   827                 ("d2_polyeq_bdv_only_simplify", d2_polyeq_bdv_only_simplify),
   828                 ("d2_polyeq_sq_only_simplify", d2_polyeq_sq_only_simplify),
   829                 ("d2_polyeq_pqFormula_simplify", d2_polyeq_pqFormula_simplify),
   830                 ("d2_polyeq_abcFormula_simplify", 
   831                  d2_polyeq_abcFormula_simplify),
   832                 ("d3_polyeq_simplify", d3_polyeq_simplify),
   833 		("d4_polyeq_simplify", d4_polyeq_simplify)
   834 	      ]);
   835 *}
   836 ML{*
   837     
   838 (*------------------------problems------------------------*)
   839 (*
   840 (get_pbt ["degree_2","polynomial","univariate","equation"]);
   841 show_ptyps(); 
   842 *)
   843 
   844 (*-------------------------poly-----------------------*)
   845 store_pbt
   846  (prep_pbt thy "pbl_equ_univ_poly" [] e_pblID
   847  (["polynomial","univariate","equation"],
   848   [("#Given" ,["equality e_e","solveFor v_v"]),
   849    ("#Where" ,["~((e_e::bool) is_ratequation_in (v_v::real))",
   850 	       "~((lhs e_e) is_rootTerm_in (v_v::real))",
   851 	       "~((rhs e_e) is_rootTerm_in (v_v::real))"]),
   852    ("#Find"  ,["solutions v_i"])
   853    ],
   854   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   855   []));
   856 (*--- d0 ---*)
   857 store_pbt
   858  (prep_pbt thy "pbl_equ_univ_poly_deg0" [] e_pblID
   859  (["degree_0","polynomial","univariate","equation"],
   860   [("#Given" ,["equality e_e","solveFor v_v"]),
   861    ("#Where" ,["matches (?a = 0) e_e",
   862 	       "(lhs e_e) is_poly_in v_v",
   863 	       "((lhs e_e) has_degree_in v_v ) = 0"
   864 	      ]),
   865    ("#Find"  ,["solutions v_i"])
   866   ],
   867   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   868   [["PolyEq","solve_d0_polyeq_equation"]]));
   869 
   870 (*--- d1 ---*)
   871 store_pbt
   872  (prep_pbt thy "pbl_equ_univ_poly_deg1" [] e_pblID
   873  (["degree_1","polynomial","univariate","equation"],
   874   [("#Given" ,["equality e_e","solveFor v_v"]),
   875    ("#Where" ,["matches (?a = 0) e_e",
   876 	       "(lhs e_e) is_poly_in v_v",
   877 	       "((lhs e_e) has_degree_in v_v ) = 1"
   878 	      ]),
   879    ("#Find"  ,["solutions v_i"])
   880   ],
   881   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   882   [["PolyEq","solve_d1_polyeq_equation"]]));
   883 *}
   884 ML{*
   885 (*--- d2 ---*)
   886 store_pbt
   887  (prep_pbt thy "pbl_equ_univ_poly_deg2" [] e_pblID
   888  (["degree_2","polynomial","univariate","equation"],
   889   [("#Given" ,["equality e_e","solveFor v_v"]),
   890    ("#Where" ,["matches (?a = 0) e_e",
   891 	       "(lhs e_e) is_poly_in v_v ",
   892 	       "((lhs e_e) has_degree_in v_v ) = 2"]),
   893    ("#Find"  ,["solutions v_i"])
   894   ],
   895   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   896   [["PolyEq","solve_d2_polyeq_equation"]]));
   897 
   898  store_pbt
   899  (prep_pbt thy "pbl_equ_univ_poly_deg2_sqonly" [] e_pblID
   900  (["sq_only","degree_2","polynomial","univariate","equation"],
   901   [("#Given" ,["equality e_e","solveFor v_v"]),
   902    ("#Where" ,["matches ( ?a +    ?v_^^^2 = 0) e_e | " ^
   903 	       "matches ( ?a + ?b*?v_^^^2 = 0) e_e | " ^
   904 	       "matches (         ?v_^^^2 = 0) e_e | " ^
   905 	       "matches (      ?b*?v_^^^2 = 0) e_e" ,
   906 	       "Not (matches (?a +    ?v_ +    ?v_^^^2 = 0) e_e) &" ^
   907 	       "Not (matches (?a + ?b*?v_ +    ?v_^^^2 = 0) e_e) &" ^
   908 	       "Not (matches (?a +    ?v_ + ?c*?v_^^^2 = 0) e_e) &" ^
   909 	       "Not (matches (?a + ?b*?v_ + ?c*?v_^^^2 = 0) e_e) &" ^
   910 	       "Not (matches (        ?v_ +    ?v_^^^2 = 0) e_e) &" ^
   911 	       "Not (matches (     ?b*?v_ +    ?v_^^^2 = 0) e_e) &" ^
   912 	       "Not (matches (        ?v_ + ?c*?v_^^^2 = 0) e_e) &" ^
   913 	       "Not (matches (     ?b*?v_ + ?c*?v_^^^2 = 0) e_e)"]),
   914    ("#Find"  ,["solutions v_i"])
   915   ],
   916   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   917   [["PolyEq","solve_d2_polyeq_sqonly_equation"]]));
   918 
   919 store_pbt
   920  (prep_pbt thy "pbl_equ_univ_poly_deg2_bdvonly" [] e_pblID
   921  (["bdv_only","degree_2","polynomial","univariate","equation"],
   922   [("#Given" ,["equality e_e","solveFor v_v"]),
   923    ("#Where" ,["matches (?a*?v_ +    ?v_^^^2 = 0) e_e | " ^
   924 	       "matches (   ?v_ +    ?v_^^^2 = 0) e_e | " ^
   925 	       "matches (   ?v_ + ?b*?v_^^^2 = 0) e_e | " ^
   926 	       "matches (?a*?v_ + ?b*?v_^^^2 = 0) e_e | " ^
   927 	       "matches (            ?v_^^^2 = 0) e_e | " ^
   928 	       "matches (         ?b*?v_^^^2 = 0) e_e "]),
   929    ("#Find"  ,["solutions v_i"])
   930   ],
   931   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   932   [["PolyEq","solve_d2_polyeq_bdvonly_equation"]]));
   933 
   934 store_pbt
   935  (prep_pbt thy "pbl_equ_univ_poly_deg2_pq" [] e_pblID
   936  (["pqFormula","degree_2","polynomial","univariate","equation"],
   937   [("#Given" ,["equality e_e","solveFor v_v"]),
   938    ("#Where" ,["matches (?a + 1*?v_^^^2 = 0) e_e | " ^
   939 	       "matches (?a +   ?v_^^^2 = 0) e_e"]),
   940    ("#Find"  ,["solutions v_i"])
   941   ],
   942   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   943   [["PolyEq","solve_d2_polyeq_pq_equation"]]));
   944 
   945 store_pbt
   946  (prep_pbt thy "pbl_equ_univ_poly_deg2_abc" [] e_pblID
   947  (["abcFormula","degree_2","polynomial","univariate","equation"],
   948   [("#Given" ,["equality e_e","solveFor v_v"]),
   949    ("#Where" ,["matches (?a +    ?v_^^^2 = 0) e_e | " ^
   950 	       "matches (?a + ?b*?v_^^^2 = 0) e_e"]),
   951    ("#Find"  ,["solutions v_i"])
   952   ],
   953   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   954   [["PolyEq","solve_d2_polyeq_abc_equation"]]));
   955 *}
   956 ML{*
   957 (*--- d3 ---*)
   958 store_pbt
   959  (prep_pbt thy "pbl_equ_univ_poly_deg3" [] e_pblID
   960  (["degree_3","polynomial","univariate","equation"],
   961   [("#Given" ,["equality e_e","solveFor v_v"]),
   962    ("#Where" ,["matches (?a = 0) e_e",
   963 	       "(lhs e_e) is_poly_in v_v ",
   964 	       "((lhs e_e) has_degree_in v_v) = 3"]),
   965    ("#Find"  ,["solutions v_i"])
   966   ],
   967   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   968   [["PolyEq","solve_d3_polyeq_equation"]]));
   969 
   970 (*--- d4 ---*)
   971 store_pbt
   972  (prep_pbt thy "pbl_equ_univ_poly_deg4" [] e_pblID
   973  (["degree_4","polynomial","univariate","equation"],
   974   [("#Given" ,["equality e_e","solveFor v_v"]),
   975    ("#Where" ,["matches (?a = 0) e_e",
   976 	       "(lhs e_e) is_poly_in v_v ",
   977 	       "((lhs e_e) has_degree_in v_v) = 4"]),
   978    ("#Find"  ,["solutions v_i"])
   979   ],
   980   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   981   [(*["PolyEq","solve_d4_polyeq_equation"]*)]));
   982 
   983 (*--- normalize ---*)
   984 store_pbt
   985  (prep_pbt thy "pbl_equ_univ_poly_norm" [] e_pblID
   986  (["normalize","polynomial","univariate","equation"],
   987   [("#Given" ,["equality e_e","solveFor v_v"]),
   988    ("#Where" ,["(Not((matches (?a = 0 ) e_e ))) |" ^
   989 	       "(Not(((lhs e_e) is_poly_in v_v)))"]),
   990    ("#Find"  ,["solutions v_i"])
   991   ],
   992   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
   993   [["PolyEq","normalize_poly"]]));
   994 (*-------------------------expanded-----------------------*)
   995 store_pbt
   996  (prep_pbt thy "pbl_equ_univ_expand" [] e_pblID
   997  (["expanded","univariate","equation"],
   998   [("#Given" ,["equality e_e","solveFor v_v"]),
   999    ("#Where" ,["matches (?a = 0) e_e",
  1000 	       "(lhs e_e) is_expanded_in v_v "]),
  1001    ("#Find"  ,["solutions v_i"])
  1002    ],
  1003   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
  1004   []));
  1005 
  1006 (*--- d2 ---*)
  1007 store_pbt
  1008  (prep_pbt thy "pbl_equ_univ_expand_deg2" [] e_pblID
  1009  (["degree_2","expanded","univariate","equation"],
  1010   [("#Given" ,["equality e_e","solveFor v_v"]),
  1011    ("#Where" ,["((lhs e_e) has_degree_in v_v) = 2"]),
  1012    ("#Find"  ,["solutions v_i"])
  1013   ],
  1014   PolyEq_prls, SOME "solve (e_e::bool, v_v)",
  1015   [["PolyEq","complete_square"]]));
  1016 
  1017 *}
  1018 ML{*
  1019 val scr =     
  1020     "Script Normalize_poly (e_e::bool) (v_v::real) =                     " ^
  1021     "(let e_e =((Try         (Rewrite     all_left          False)) @@  " ^ 
  1022     "          (Try (Repeat (Rewrite     makex1_x         False))) @@  " ^ 
  1023     "          (Try (Repeat (Rewrite_Set expand_binoms    False))) @@  " ^ 
  1024     "          (Try (Repeat (Rewrite_Set_Inst [(bdv,v_v::real)]         " ^
  1025     "                                 make_ratpoly_in     False))) @@  " ^
  1026     "          (Try (Repeat (Rewrite_Set polyeq_simplify  False)))) e_e " ^
  1027     " in (SubProblem (PolyEq',[polynomial,univariate,equation], [no_met])   " ^
  1028     "                 [BOOL e_e, REAL v_v]))";
  1029 parse thy scr;
  1030 *}
  1031 ML{*
  1032 "-------------------------methods-----------------------";
  1033 store_met
  1034  (prep_met thy "met_polyeq" [] e_metID
  1035  (["PolyEq"],
  1036    [],
  1037    {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
  1038     crls=PolyEq_crls, nrls=norm_Rational}, "empty_script"));
  1039 
  1040 store_met
  1041  (prep_met thy "met_polyeq_norm" [] e_metID
  1042  (["PolyEq","normalize_poly"],
  1043    [("#Given" ,["equality e_e","solveFor v_v"]),
  1044    ("#Where" ,["(Not((matches (?a = 0 ) e_e ))) |" ^
  1045 	       "(Not(((lhs e_e) is_poly_in v_v)))"]),
  1046    ("#Find"  ,["solutions v_i"])
  1047   ],
  1048    {rew_ord'="termlessI",
  1049     rls'=PolyEq_erls,
  1050     srls=e_rls,
  1051     prls=PolyEq_prls,
  1052     calc=[],
  1053     crls=PolyEq_crls, nrls=norm_Rational},
  1054     "Script Normalize_poly (e_e::bool) (v_v::real) =                     " ^
  1055     "(let e_e =((Try         (Rewrite     all_left          False)) @@  " ^ 
  1056     "          (Try (Repeat (Rewrite     makex1_x         False))) @@  " ^ 
  1057     "          (Try (Repeat (Rewrite_Set expand_binoms    False))) @@  " ^ 
  1058     "          (Try (Repeat (Rewrite_Set_Inst [(bdv,v_v::real)]         " ^
  1059     "                                 make_ratpoly_in     False))) @@  " ^
  1060     "          (Try (Repeat (Rewrite_Set polyeq_simplify  False)))) e_e " ^
  1061     " in (SubProblem (PolyEq',[polynomial,univariate,equation], [no_met])   " ^
  1062     "                 [BOOL e_e, REAL v_v]))"
  1063    ));
  1064 
  1065 *}
  1066 ML{*
  1067 store_met
  1068  (prep_met thy "met_polyeq_d0" [] e_metID
  1069  (["PolyEq","solve_d0_polyeq_equation"],
  1070    [("#Given" ,["equality e_e","solveFor v_v"]),
  1071    ("#Where" ,["(lhs e_e) is_poly_in v_v ",
  1072 	       "((lhs e_e) has_degree_in v_v) = 0"]),
  1073    ("#Find"  ,["solutions v_i"])
  1074   ],
  1075    {rew_ord'="termlessI",
  1076     rls'=PolyEq_erls,
  1077     srls=e_rls,
  1078     prls=PolyEq_prls,
  1079     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1080     crls=PolyEq_crls, nrls=norm_Rational},
  1081    "Script Solve_d0_polyeq_equation  (e_e::bool) (v_v::real)  = " ^
  1082     "(let e_e =  ((Try (Rewrite_Set_Inst [(bdv,v_v::real)]      " ^
  1083     "                  d0_polyeq_simplify  False))) e_e        " ^
  1084     " in ((Or_to_List e_e)::bool list))"
  1085  ));
  1086 *}
  1087 ML{*
  1088 store_met
  1089  (prep_met thy "met_polyeq_d1" [] e_metID
  1090  (["PolyEq","solve_d1_polyeq_equation"],
  1091    [("#Given" ,["equality e_e","solveFor v_v"]),
  1092    ("#Where" ,["(lhs e_e) is_poly_in v_v ",
  1093 	       "((lhs e_e) has_degree_in v_v) = 1"]),
  1094    ("#Find"  ,["solutions v_i"])
  1095   ],
  1096    {rew_ord'="termlessI", rls'=PolyEq_erls, srls=e_rls, prls=PolyEq_prls,
  1097     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1098     crls=PolyEq_crls, nrls=norm_Rational},
  1099    "Script Solve_d1_polyeq_equation  (e_e::bool) (v_v::real)  =   " ^
  1100     "(let e_e =  ((Try (Rewrite_Set_Inst [(bdv,v_v::real)]        " ^
  1101     "                  d1_polyeq_simplify   True))          @@  " ^
  1102     "            (Try (Rewrite_Set polyeq_simplify  False)) @@  " ^
  1103     "            (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
  1104     " (L_L::bool list) = ((Or_to_List e_e)::bool list)            " ^
  1105     " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
  1106  ));
  1107 *}
  1108 ML{*
  1109 store_met
  1110  (prep_met thy "met_polyeq_d22" [] e_metID
  1111  (["PolyEq","solve_d2_polyeq_equation"],
  1112    [("#Given" ,["equality e_e","solveFor v_v"]),
  1113    ("#Where" ,["(lhs e_e) is_poly_in v_v ",
  1114 	       "((lhs e_e) has_degree_in v_v) = 2"]),
  1115    ("#Find"  ,["solutions v_i"])
  1116   ],
  1117    {rew_ord'="termlessI",
  1118     rls'=PolyEq_erls,
  1119     srls=e_rls,
  1120     prls=PolyEq_prls,
  1121     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1122     crls=PolyEq_crls, nrls=norm_Rational},
  1123    "Script Solve_d2_polyeq_equation  (e_e::bool) (v_v::real) =      " ^
  1124     "  (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)]         " ^
  1125     "                    d2_polyeq_simplify           True)) @@   " ^
  1126     "             (Try (Rewrite_Set polyeq_simplify   False)) @@  " ^
  1127     "             (Try (Rewrite_Set_Inst [(bdv,v_v::real)]         " ^
  1128     "                    d1_polyeq_simplify            True)) @@  " ^
  1129     "            (Try (Rewrite_Set polyeq_simplify    False)) @@  " ^
  1130     "            (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
  1131     " (L_L::bool list) = ((Or_to_List e_e)::bool list)              " ^
  1132     " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
  1133  ));
  1134 *}
  1135 ML{*
  1136 store_met
  1137  (prep_met thy "met_polyeq_d2_bdvonly" [] e_metID
  1138  (["PolyEq","solve_d2_polyeq_bdvonly_equation"],
  1139    [("#Given" ,["equality e_e","solveFor v_v"]),
  1140    ("#Where" ,["(lhs e_e) is_poly_in v_v ",
  1141 	       "((lhs e_e) has_degree_in v_v) = 2"]),
  1142    ("#Find"  ,["solutions v_i"])
  1143   ],
  1144    {rew_ord'="termlessI",
  1145     rls'=PolyEq_erls,
  1146     srls=e_rls,
  1147     prls=PolyEq_prls,
  1148     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1149     crls=PolyEq_crls, nrls=norm_Rational},
  1150    "Script Solve_d2_polyeq_bdvonly_equation  (e_e::bool) (v_v::real) =" ^
  1151     "  (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)]         " ^
  1152     "                   d2_polyeq_bdv_only_simplify    True)) @@  " ^
  1153     "             (Try (Rewrite_Set polyeq_simplify   False)) @@  " ^
  1154     "             (Try (Rewrite_Set_Inst [(bdv,v_v::real)]         " ^
  1155     "                   d1_polyeq_simplify             True)) @@  " ^
  1156     "            (Try (Rewrite_Set polyeq_simplify    False)) @@  " ^
  1157     "            (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
  1158     " (L_L::bool list) = ((Or_to_List e_e)::bool list)              " ^
  1159     " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
  1160  ));
  1161 *}
  1162 ML{*
  1163 store_met
  1164  (prep_met thy "met_polyeq_d2_sqonly" [] e_metID
  1165  (["PolyEq","solve_d2_polyeq_sqonly_equation"],
  1166    [("#Given" ,["equality e_e","solveFor v_v"]),
  1167    ("#Where" ,["(lhs e_e) is_poly_in v_v ",
  1168 	       "((lhs e_e) has_degree_in v_v) = 2"]),
  1169    ("#Find"  ,["solutions v_i"])
  1170   ],
  1171    {rew_ord'="termlessI",
  1172     rls'=PolyEq_erls,
  1173     srls=e_rls,
  1174     prls=PolyEq_prls,
  1175     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1176     crls=PolyEq_crls, nrls=norm_Rational},
  1177    "Script Solve_d2_polyeq_sqonly_equation  (e_e::bool) (v_v::real) =" ^
  1178     "  (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)]          " ^
  1179     "                   d2_polyeq_sq_only_simplify     True)) @@   " ^
  1180     "            (Try (Rewrite_Set polyeq_simplify    False)) @@   " ^
  1181     "            (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e; " ^
  1182     " (L_L::bool list) = ((Or_to_List e_e)::bool list)               " ^
  1183     " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
  1184  ));
  1185 *}
  1186 ML{*
  1187 store_met
  1188  (prep_met thy "met_polyeq_d2_pq" [] e_metID
  1189  (["PolyEq","solve_d2_polyeq_pq_equation"],
  1190    [("#Given" ,["equality e_e","solveFor v_v"]),
  1191    ("#Where" ,["(lhs e_e) is_poly_in v_v ",
  1192 	       "((lhs e_e) has_degree_in v_v) = 2"]),
  1193    ("#Find"  ,["solutions v_i"])
  1194   ],
  1195    {rew_ord'="termlessI",
  1196     rls'=PolyEq_erls,
  1197     srls=e_rls,
  1198     prls=PolyEq_prls,
  1199     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1200     crls=PolyEq_crls, nrls=norm_Rational},
  1201    "Script Solve_d2_polyeq_pq_equation  (e_e::bool) (v_v::real) =   " ^
  1202     "  (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)]         " ^
  1203     "                   d2_polyeq_pqFormula_simplify   True)) @@  " ^
  1204     "            (Try (Rewrite_Set polyeq_simplify    False)) @@  " ^
  1205     "            (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
  1206     " (L_L::bool list) = ((Or_to_List e_e)::bool list)              " ^
  1207     " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
  1208  ));
  1209 *}
  1210 ML{*
  1211 store_met
  1212  (prep_met thy "met_polyeq_d2_abc" [] e_metID
  1213  (["PolyEq","solve_d2_polyeq_abc_equation"],
  1214    [("#Given" ,["equality e_e","solveFor v_v"]),
  1215    ("#Where" ,["(lhs e_e) is_poly_in v_v ",
  1216 	       "((lhs e_e) has_degree_in v_v) = 2"]),
  1217    ("#Find"  ,["solutions v_i"])
  1218   ],
  1219    {rew_ord'="termlessI",
  1220     rls'=PolyEq_erls,
  1221     srls=e_rls,
  1222     prls=PolyEq_prls,
  1223     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1224     crls=PolyEq_crls, nrls=norm_Rational},
  1225    "Script Solve_d2_polyeq_abc_equation  (e_e::bool) (v_v::real) =   " ^
  1226     "  (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)]          " ^
  1227     "                   d2_polyeq_abcFormula_simplify   True)) @@  " ^
  1228     "            (Try (Rewrite_Set polyeq_simplify     False)) @@  " ^
  1229     "            (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
  1230     " (L_L::bool list) = ((Or_to_List e_e)::bool list)               " ^
  1231     " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
  1232  ));
  1233 *}
  1234 ML{*
  1235 store_met
  1236  (prep_met thy "met_polyeq_d3" [] e_metID
  1237  (["PolyEq","solve_d3_polyeq_equation"],
  1238    [("#Given" ,["equality e_e","solveFor v_v"]),
  1239    ("#Where" ,["(lhs e_e) is_poly_in v_v ",
  1240 	       "((lhs e_e) has_degree_in v_v) = 3"]),
  1241    ("#Find"  ,["solutions v_i"])
  1242   ],
  1243    {rew_ord'="termlessI",
  1244     rls'=PolyEq_erls,
  1245     srls=e_rls,
  1246     prls=PolyEq_prls,
  1247     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1248     crls=PolyEq_crls, nrls=norm_Rational},
  1249    "Script Solve_d3_polyeq_equation  (e_e::bool) (v_v::real) =     " ^
  1250     "  (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)]        " ^
  1251     "                    d3_polyeq_simplify           True)) @@  " ^
  1252     "             (Try (Rewrite_Set polyeq_simplify  False)) @@  " ^
  1253     "             (Try (Rewrite_Set_Inst [(bdv,v_v::real)]        " ^
  1254     "                    d2_polyeq_simplify           True)) @@  " ^
  1255     "             (Try (Rewrite_Set polyeq_simplify  False)) @@  " ^
  1256     "             (Try (Rewrite_Set_Inst [(bdv,v_v::real)]        " ^   
  1257     "                    d1_polyeq_simplify           True)) @@  " ^
  1258     "             (Try (Rewrite_Set polyeq_simplify  False)) @@  " ^
  1259     "             (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
  1260     " (L_L::bool list) = ((Or_to_List e_e)::bool list)             " ^
  1261     " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
  1262    ));
  1263 *}
  1264 ML{*
  1265  (*.solves all expanded (ie. normalized) terms of degree 2.*) 
  1266  (*Oct.02 restriction: 'eval_true 0 =< discriminant' ony for integer values
  1267    by 'PolyEq_erls'; restricted until Float.thy is implemented*)
  1268 store_met
  1269  (prep_met thy "met_polyeq_complsq" [] e_metID
  1270  (["PolyEq","complete_square"],
  1271    [("#Given" ,["equality e_e","solveFor v_v"]),
  1272    ("#Where" ,["matches (?a = 0) e_e", 
  1273 	       "((lhs e_e) has_degree_in v_v) = 2"]),
  1274    ("#Find"  ,["solutions v_i"])
  1275   ],
  1276    {rew_ord'="termlessI",rls'=PolyEq_erls,srls=e_rls,prls=PolyEq_prls,
  1277     calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
  1278     crls=PolyEq_crls, nrls=norm_Rational},
  1279    "Script Complete_square (e_e::bool) (v_v::real) =                         " ^
  1280    "(let e_e = " ^ 
  1281    "    ((Try (Rewrite_Set_Inst [(bdv,v_v)] cancel_leading_coeff True)) " ^
  1282    "        @@ (Try (Rewrite_Set_Inst [(bdv,v_v)] complete_square True))     " ^
  1283    "        @@ (Try (Rewrite square_explicit1 False))                       " ^
  1284    "        @@ (Try (Rewrite square_explicit2 False))                       " ^
  1285    "        @@ (Rewrite root_plus_minus True)                               " ^
  1286    "        @@ (Try (Repeat (Rewrite_Inst [(bdv,v_v)] bdv_explicit1 False))) " ^
  1287    "        @@ (Try (Repeat (Rewrite_Inst [(bdv,v_v)] bdv_explicit2 False))) " ^
  1288    "        @@ (Try (Repeat                                                 " ^
  1289    "                  (Rewrite_Inst [(bdv,v_v)] bdv_explicit3 False)))       " ^
  1290    "        @@ (Try (Rewrite_Set calculate_RootRat False))                  " ^
  1291    "        @@ (Try (Repeat (Calculate SQRT)))) e_e                         " ^
  1292    " in ((Or_to_List e_e)::bool list))"
  1293    ));
  1294 *}
  1295 ML{*
  1296 
  1297 (* termorder hacked by MG *)
  1298 local (*. for make_polynomial_in .*)
  1299 
  1300 open Term;  (* for type order = EQUAL | LESS | GREATER *)
  1301 
  1302 fun pr_ord EQUAL = "EQUAL"
  1303   | pr_ord LESS  = "LESS"
  1304   | pr_ord GREATER = "GREATER";
  1305 
  1306 fun dest_hd' x (Const (a, T)) = (((a, 0), T), 0)
  1307   | dest_hd' x (t as Free (a, T)) =
  1308     if x = t then ((("|||||||||||||", 0), T), 0)                        (*WN*)
  1309     else (((a, 0), T), 1)
  1310   | dest_hd' x (Var v) = (v, 2)
  1311   | dest_hd' x (Bound i) = ((("", i), dummyT), 3)
  1312   | dest_hd' x (Abs (_, T, _)) = ((("", 0), T), 4);
  1313 
  1314 fun size_of_term' x (Const ("Atools.pow",_) $ Free (var,_) $ Free (pot,_)) =
  1315     (case x of                                                          (*WN*)
  1316 	    (Free (xstr,_)) => 
  1317 		(if xstr = var then 1000*(the (int_of_str pot)) else 3)
  1318 	  | _ => raise error ("size_of_term' called with subst = "^
  1319 			      (term2str x)))
  1320   | size_of_term' x (Free (subst,_)) =
  1321     (case x of
  1322 	    (Free (xstr,_)) => (if xstr = subst then 1000 else 1)
  1323 	  | _ => raise error ("size_of_term' called with subst = "^
  1324 			  (term2str x)))
  1325   | size_of_term' x (Abs (_,_,body)) = 1 + size_of_term' x body
  1326   | size_of_term' x (f$t) = size_of_term' x f  +  size_of_term' x t
  1327   | size_of_term' x _ = 1;
  1328 
  1329 
  1330 fun term_ord' x pr thy (Abs (_, T, t), Abs(_, U, u)) =       (* ~ term.ML *)
  1331       (case term_ord' x pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U) | ord => ord)
  1332   | term_ord' x pr thy (t, u) =
  1333       (if pr then 
  1334 	 let
  1335 	   val (f, ts) = strip_comb t and (g, us) = strip_comb u;
  1336 	   val _=writeln("t= f@ts= \""^
  1337 	      ((Syntax.string_of_term (thy2ctxt thy)) f)^"\" @ \"["^
  1338 	      (commas(map (Syntax.string_of_term (thy2ctxt thy)) ts))^"]\"");
  1339 	   val _=writeln("u= g@us= \""^
  1340 	      ((Syntax.string_of_term (thy2ctxt thy)) g)^"\" @ \"["^
  1341 	      (commas(map (Syntax.string_of_term (thy2ctxt thy)) us))^"]\"");
  1342 	   val _=writeln("size_of_term(t,u)= ("^
  1343 	      (string_of_int(size_of_term' x t))^", "^
  1344 	      (string_of_int(size_of_term' x u))^")");
  1345 	   val _=writeln("hd_ord(f,g)      = "^((pr_ord o (hd_ord x))(f,g)));
  1346 	   val _=writeln("terms_ord(ts,us) = "^
  1347 			   ((pr_ord o (terms_ord x) str false)(ts, us)));
  1348 	   val _=writeln("-------");
  1349 	 in () end
  1350        else ();
  1351 	 case int_ord (size_of_term' x t, size_of_term' x u) of
  1352 	   EQUAL =>
  1353 	     let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
  1354 	       (case hd_ord x (f, g) of EQUAL => (terms_ord x str pr) (ts, us) 
  1355 	     | ord => ord)
  1356 	     end
  1357 	 | ord => ord)
  1358 and hd_ord x (f, g) =                                        (* ~ term.ML *)
  1359   prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord) 
  1360             int_ord (dest_hd' x f, dest_hd' x g)
  1361 and terms_ord x str pr (ts, us) = 
  1362     list_ord (term_ord' x pr (assoc_thy "Isac"))(ts, us);
  1363 in
  1364 
  1365 fun ord_make_polynomial_in (pr:bool) thy subst tu = 
  1366     let
  1367 	(* val _=writeln("*** subs variable is: "^(subst2str subst)); *)
  1368     in
  1369 	case subst of
  1370 	    (_,x)::_ => (term_ord' x pr thy tu = LESS)
  1371 	  | _ => raise error ("ord_make_polynomial_in called with subst = "^
  1372 			  (subst2str subst))
  1373     end;
  1374 end;(*local*)
  1375 
  1376 *}
  1377 ML{*
  1378 val order_add_mult_in = prep_rls(
  1379   Rls{id = "order_add_mult_in", preconds = [], 
  1380       rew_ord = ("ord_make_polynomial_in",
  1381 		 ord_make_polynomial_in false (theory "Poly")),
  1382       erls = e_rls,srls = Erls,
  1383       calc = [],
  1384       (*asm_thm = [],*)
  1385       rules = [Thm ("real_mult_commute",num_str @{thm real_mult_commute}),
  1386 	       (* z * w = w * z *)
  1387 	       Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
  1388 	       (*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
  1389 	       Thm ("real_mult_assoc",num_str @{thm real_mult_assoc}),		
  1390 	       (*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
  1391 	       Thm ("add_commute",num_str @{thm add_commute}),	
  1392 	       (*z + w = w + z*)
  1393 	       Thm ("add_left_commute",num_str @{thm add_left_commute}),
  1394 	       (*x + (y + z) = y + (x + z)*)
  1395 	       Thm ("add_assoc",num_str @{thm add_assoc})	               
  1396 	       (*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
  1397 	       ], scr = EmptyScr}:rls);
  1398 
  1399 *}
  1400 ML{*
  1401 val collect_bdv = prep_rls(
  1402   Rls{id = "collect_bdv", preconds = [], 
  1403       rew_ord = ("dummy_ord", dummy_ord),
  1404       erls = e_rls,srls = Erls,
  1405       calc = [],
  1406       (*asm_thm = [],*)
  1407       rules = [Thm ("bdv_collect_1",num_str @{thm bdv_collect_1}),
  1408 	       Thm ("bdv_collect_2",num_str @{thm bdv_collect_2}),
  1409 	       Thm ("bdv_collect_3",num_str @{thm bdv_collect_3}),
  1410 
  1411 	       Thm ("bdv_collect_assoc1_1",num_str @{thm bdv_collect_assoc1_1}),
  1412 	       Thm ("bdv_collect_assoc1_2",num_str @{thm bdv_collect_assoc1_2}),
  1413 	       Thm ("bdv_collect_assoc1_3",num_str @{thm bdv_collect_assoc1_3}),
  1414 
  1415 	       Thm ("bdv_collect_assoc2_1",num_str @{thm bdv_collect_assoc2_1}),
  1416 	       Thm ("bdv_collect_assoc2_2",num_str @{thm bdv_collect_assoc2_2}),
  1417 	       Thm ("bdv_collect_assoc2_3",num_str @{thm bdv_collect_assoc2_3}),
  1418 
  1419 
  1420 	       Thm ("bdv_n_collect_1",num_str @{thm bdv_n_collect_1}),
  1421 	       Thm ("bdv_n_collect_2",num_str @{thm bdv_n_collect_2}),
  1422 	       Thm ("bdv_n_collect_3",num_str @{thm bdv_n_collect_3}),
  1423 
  1424 	       Thm ("bdv_n_collect_assoc1_1",num_str @{thm bdv_n_collect_assoc1_1}),
  1425 	       Thm ("bdv_n_collect_assoc1_2",num_str @{thm bdv_n_collect_assoc1_2}),
  1426 	       Thm ("bdv_n_collect_assoc1_3",num_str @{thm bdv_n_collect_assoc1_3}),
  1427 
  1428 	       Thm ("bdv_n_collect_assoc2_1",num_str @{thm bdv_n_collect_assoc2_1}),
  1429 	       Thm ("bdv_n_collect_assoc2_2",num_str @{thm bdv_n_collect_assoc2_2}),
  1430 	       Thm ("bdv_n_collect_assoc2_3",num_str @{thm bdv_n_collect_assoc2_3})
  1431 	       ], scr = EmptyScr}:rls);
  1432 
  1433 *}
  1434 ML{*
  1435 (*.transforms an arbitrary term without roots to a polynomial [4] 
  1436    according to knowledge/Poly.sml.*) 
  1437 val make_polynomial_in = prep_rls(
  1438   Seq {id = "make_polynomial_in", preconds = []:term list, 
  1439        rew_ord = ("dummy_ord", dummy_ord),
  1440       erls = Atools_erls, srls = Erls,
  1441       calc = [], (*asm_thm = [],*)
  1442       rules = [Rls_ expand_poly,
  1443 	       Rls_ order_add_mult_in,
  1444 	       Rls_ simplify_power,
  1445 	       Rls_ collect_numerals,
  1446 	       Rls_ reduce_012,
  1447 	       Thm ("realpow_oneI",num_str @{thm realpow_oneI}),
  1448 	       Rls_ discard_parentheses,
  1449 	       Rls_ collect_bdv
  1450 	       ],
  1451       scr = EmptyScr
  1452       }:rls);     
  1453 
  1454 *}
  1455 ML{*
  1456 val separate_bdvs = 
  1457     append_rls "separate_bdvs"
  1458 	       collect_bdv
  1459 	       [Thm ("separate_bdv", num_str @{thm separate_bdv}),
  1460 		(*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
  1461 		Thm ("separate_bdv_n", num_str @{thm separate_bdv_n}),
  1462 		Thm ("separate_1_bdv", num_str @{thm separate_1_bdv}),
  1463 		(*"?bdv / ?b = (1 / ?b) * ?bdv"*)
  1464 		Thm ("separate_1_bdv_n", num_str @{thm separate_1_bdv_n}),
  1465 		(*"?bdv ^^^ ?n / ?b = 1 / ?b * ?bdv ^^^ ?n"*)
  1466 		Thm ("add_divide_distrib", 
  1467 		     num_str @{thm add_divide_distrib})
  1468 		(*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"
  1469 		      WN051031 DOES NOT BELONG TO HERE*)
  1470 		];
  1471 *}
  1472 ML{*
  1473 val make_ratpoly_in = prep_rls(
  1474   Seq {id = "make_ratpoly_in", preconds = []:term list, 
  1475        rew_ord = ("dummy_ord", dummy_ord),
  1476       erls = Atools_erls, srls = Erls,
  1477       calc = [], (*asm_thm = [],*)
  1478       rules = [Rls_ norm_Rational,
  1479 	       Rls_ order_add_mult_in,
  1480 	       Rls_ discard_parentheses,
  1481 	       Rls_ separate_bdvs,
  1482 	       (* Rls_ rearrange_assoc, WN060916 why does cancel_p not work?*)
  1483 	       Rls_ cancel_p
  1484 	       (*Calc ("HOL.divide"  ,eval_cancel "#divide_e") too weak!*)
  1485 	       ],
  1486       scr = EmptyScr}:rls);      
  1487 
  1488 
  1489 ruleset' := overwritelthy @{theory} (!ruleset',
  1490   [("order_add_mult_in", order_add_mult_in),
  1491    ("collect_bdv", collect_bdv),
  1492    ("make_polynomial_in", make_polynomial_in),
  1493    ("make_ratpoly_in", make_ratpoly_in),
  1494    ("separate_bdvs", separate_bdvs)
  1495    ]);
  1496 *}
  1497 
  1498 end
  1499 
  1500 
  1501 
  1502 
  1503 
  1504