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
10 (c) by Richard Lang, 2003
13 theory PolyEq imports LinEq RootRatEq begin
17 (*---------scripts--------------------------*)
20 bool list] => bool list"
21 ("((Script Complete'_square (_ _ =))//
26 bool list] => bool list"
27 ("((Script Normalize'_poly (_ _=))//
29 Solve'_d0'_polyeq'_equation
31 bool list] => bool list"
32 ("((Script Solve'_d0'_polyeq'_equation (_ _ =))//
34 Solve'_d1'_polyeq'_equation
36 bool list] => bool list"
37 ("((Script Solve'_d1'_polyeq'_equation (_ _ =))//
39 Solve'_d2'_polyeq'_equation
41 bool list] => bool list"
42 ("((Script Solve'_d2'_polyeq'_equation (_ _ =))//
44 Solve'_d2'_polyeq'_sqonly'_equation
46 bool list] => bool list"
47 ("((Script Solve'_d2'_polyeq'_sqonly'_equation (_ _ =))//
49 Solve'_d2'_polyeq'_bdvonly'_equation
51 bool list] => bool list"
52 ("((Script Solve'_d2'_polyeq'_bdvonly'_equation (_ _ =))//
54 Solve'_d2'_polyeq'_pq'_equation
56 bool list] => bool list"
57 ("((Script Solve'_d2'_polyeq'_pq'_equation (_ _ =))//
59 Solve'_d2'_polyeq'_abc'_equation
61 bool list] => bool list"
62 ("((Script Solve'_d2'_polyeq'_abc'_equation (_ _ =))//
64 Solve'_d3'_polyeq'_equation
66 bool list] => bool list"
67 ("((Script Solve'_d3'_polyeq'_equation (_ _ =))//
69 Solve'_d4'_polyeq'_equation
71 bool list] => bool list"
72 ("((Script Solve'_d4'_polyeq'_equation (_ _ =))//
76 bool list] => bool list"
77 ("((Script Biquadrat'_poly (_ _=))//
80 (*-------------------- rules -------------------------------------------------*)
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)"
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)"
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)"
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)"
107 cancel_leading_coeff11:"Not (c =!= 0) ==> (a + b*bdv^^^2 = 0) =
109 cancel_leading_coeff12:"Not (c =!= 0) ==> (a - b*bdv^^^2 = 0) =
111 cancel_leading_coeff13:"Not (c =!= 0) ==> ( b*bdv^^^2 = 0) =
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)"
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)"
126 square_explicit1: "(a + b^^^2 = c) = ( b^^^2 = c - a)"
127 square_explicit2: "(a - b^^^2 = c) = (-(b^^^2) = c - a)"
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)"
133 plus_leq: "(0 <= a + b) = ((-1)*b <= a)"(*Isa?*)
134 minus_leq: "(0 <= a - b) = ( b <= a)"(*Isa?*)
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"
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 ----*)
148 "[|Not(bdv occurs_in a)|] ==> (a + b*bdv = 0) = (b*bdv = (-1)*a)"
150 "[|Not(bdv occurs_in a)|] ==> (a + bdv = 0) = ( bdv = (-1)*a)"
152 "[|Not(b=0);Not(bdv occurs_in c)|] ==> (b*bdv = c) = (bdv = c/b)"
153 (* ---- degree 2 ----*)
155 "[|Not(bdv occurs_in a)|] ==> (a + b*bdv^^^2=0) = (b*bdv^^^2= (-1)*a)"
157 "[|Not(bdv occurs_in a)|] ==> (a + bdv^^^2=0) = ( bdv^^^2= (-1)*a)"
159 "[|Not(b=0);Not(bdv occurs_in c)|] ==> (b*bdv^^^2=c) = (bdv^^^2=c/b)"
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))"
211 "[|Not(bdv occurs_in q); (-1)*4*q<0|] ==> (q+ 1*bdv^^^2=0) = False"
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))"
217 "[|Not(bdv occurs_in q); (-1)*4*q<0|] ==> (q+ bdv^^^2=0) = False"
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)))"
223 "[|b^^^2 - 4*a*c<0|] ==> (c + b*bdv+a*bdv^^^2=0) = False"
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)))"
229 "[|1 - 4*a*c<0|] ==> (c+ bdv+a*bdv^^^2=0) = False"
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)))"
235 "[|b^^^2 - 4*1*c<0|] ==> (c + b*bdv+ bdv^^^2=0) = False"
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)))"
241 "[|1 - 4*1*c<0|] ==> (c + bdv+ bdv^^^2=0) = False"
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)))"
247 "[|Not(bdv occurs_in c); 0 - 4*a*c<0|] ==> (c + a*bdv^^^2=0) = False"
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)))"
253 "[|Not(bdv occurs_in c); 0 - 4*1*c<0|] ==> (c+ bdv^^^2=0) = False"
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 *)
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 *)
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*)
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*)
275 (* ---- degree 3 ----*)
277 "(a*bdv + b*bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (a + b*bdv + c*bdv^^^2=0))"
279 "( bdv + b*bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (1 + b*bdv + c*bdv^^^2=0))"
281 "(a*bdv + bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (a + bdv + c*bdv^^^2=0))"
283 "( bdv + bdv^^^2 + c*bdv^^^3=0) = (bdv=0 | (1 + bdv + c*bdv^^^2=0))"
285 "(a*bdv + b*bdv^^^2 + bdv^^^3=0) = (bdv=0 | (a + b*bdv + bdv^^^2=0))"
287 "( bdv + b*bdv^^^2 + bdv^^^3=0) = (bdv=0 | (1 + b*bdv + bdv^^^2=0))"
289 "(a*bdv + bdv^^^2 + bdv^^^3=0) = (bdv=0 | (1 + bdv + bdv^^^2=0))"
291 "( bdv + bdv^^^2 + bdv^^^3=0) = (bdv=0 | (1 + bdv + bdv^^^2=0))"
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))"
309 "[|Not(bdv occurs_in a)|] ==> (a + b*bdv^^^3=0) = (b*bdv^^^3= (-1)*a)"
311 "[|Not(bdv occurs_in a)|] ==> (a + bdv^^^3=0) = ( bdv^^^3= (-1)*a)"
313 "[|Not(b=0);Not(bdv occurs_in a)|] ==> (b*bdv^^^3=c) = (bdv^^^3=c/b)"
315 "(bdv^^^3=0) = (bdv=0)"
317 "(bdv^^^3=c) = (bdv = nroot 3 c)"
319 (* ---- degree 4 ----*)
320 (* RL03.FIXME es wir nicht getestet ob u>0 *)
322 "(c+b*bdv^^^2+a*bdv^^^4=0) =
323 ((a*u^^^2+b*u+c=0) & (bdv^^^2=u))"
325 (* ---- 7.3.02 von Termorder ---- *)
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"
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"
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"
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"
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!*)
348 bdv_n_collect_assoc1_1:
349 "l * bdv^^^n + (m * bdv^^^n + k) = (l + m) * bdv^^^n + k"
350 bdv_n_collect_assoc1_2: "bdv^^^n + (m * bdv^^^n + k) = (1 + m) * bdv^^^n + k"
351 bdv_n_collect_assoc1_3: "l * bdv^^^n + (bdv^^^n + k) = (l + 1) * bdv^^^n + k"
353 bdv_n_collect_assoc2_1: "k + l * bdv^^^n + m * bdv^^^n = k +(l + m) * bdv^^^n"
354 bdv_n_collect_assoc2_2: "k + bdv^^^n + m * bdv^^^n = k + (1 + m) * bdv^^^n"
355 bdv_n_collect_assoc2_3: "k + l * bdv^^^n + bdv^^^n = k + (l + 1) * bdv^^^n"
358 real_minus_div: "- (a / b) = (-1 * a) / b"
360 separate_bdv: "(a * bdv) / b = (a / b) * (bdv::real)"
361 separate_bdv_n: "(a * bdv ^^^ n) / b = (a / b) * bdv ^^^ n"
362 separate_1_bdv: "bdv / b = (1 / b) * (bdv::real)"
363 separate_1_bdv_n: "bdv ^^^ n / b = (1 / b) * bdv ^^^ n"
368 (*-------------------------rulse-------------------------*)
369 val PolyEq_prls = (*3.10.02:just the following order due to subterm evaluation*)
370 append_rls "PolyEq_prls" e_rls
371 [Calc ("Atools.ident",eval_ident "#ident_"),
372 Calc ("Tools.matches",eval_matches ""),
373 Calc ("Tools.lhs" ,eval_lhs ""),
374 Calc ("Tools.rhs" ,eval_rhs ""),
375 Calc ("Poly.is'_expanded'_in",eval_is_expanded_in ""),
376 Calc ("Poly.is'_poly'_in",eval_is_poly_in ""),
377 Calc ("Poly.has'_degree'_in",eval_has_degree_in ""),
378 Calc ("Poly.is'_polyrat'_in",eval_is_polyrat_in ""),
379 (*Calc ("Atools.occurs'_in",eval_occurs_in ""), *)
380 (*Calc ("Atools.is'_const",eval_const "#is_const_"),*)
381 Calc ("op =",eval_equal "#equal_"),
382 Calc ("RootEq.is'_rootTerm'_in",eval_is_rootTerm_in ""),
383 Calc ("RatEq.is'_ratequation'_in",eval_is_ratequation_in ""),
384 Thm ("not_true",num_str @{thm not_true}),
385 Thm ("not_false",num_str @{thm not_false}),
386 Thm ("and_true",num_str @{thm and_true}),
387 Thm ("and_false",num_str @{thm and_false}),
388 Thm ("or_true",num_str @{thm or_true}),
389 Thm ("or_false",num_str @{thm or_false})
393 merge_rls "PolyEq_erls" LinEq_erls
394 (append_rls "ops_preds" calculate_Rational
395 [Calc ("op =",eval_equal "#equal_"),
396 Thm ("plus_leq", num_str @{thm plus_leq}),
397 Thm ("minus_leq", num_str @{thm minus_leq}),
398 Thm ("rat_leq1", num_str @{thm rat_leq1}),
399 Thm ("rat_leq2", num_str @{thm rat_leq2}),
400 Thm ("rat_leq3", num_str @{thm rat_leq3})
404 merge_rls "PolyEq_crls" LinEq_crls
405 (append_rls "ops_preds" calculate_Rational
406 [Calc ("op =",eval_equal "#equal_"),
407 Thm ("plus_leq", num_str @{thm plus_leq}),
408 Thm ("minus_leq", num_str @{thm minus_leq}),
409 Thm ("rat_leq1", num_str @{thm rat_leq1}),
410 Thm ("rat_leq2", num_str @{thm rat_leq2}),
411 Thm ("rat_leq3", num_str @{thm rat_leq3})
414 val cancel_leading_coeff = prep_rls(
415 Rls {id = "cancel_leading_coeff", preconds = [],
416 rew_ord = ("e_rew_ord",e_rew_ord),
417 erls = PolyEq_erls, srls = Erls, calc = [], (*asm_thm = [],*)
419 [Thm ("cancel_leading_coeff1",num_str @{thm cancel_leading_coeff1}),
420 Thm ("cancel_leading_coeff2",num_str @{thm cancel_leading_coeff2}),
421 Thm ("cancel_leading_coeff3",num_str @{thm cancel_leading_coeff3}),
422 Thm ("cancel_leading_coeff4",num_str @{thm cancel_leading_coeff4}),
423 Thm ("cancel_leading_coeff5",num_str @{thm cancel_leading_coeff5}),
424 Thm ("cancel_leading_coeff6",num_str @{thm cancel_leading_coeff6}),
425 Thm ("cancel_leading_coeff7",num_str @{thm cancel_leading_coeff7}),
426 Thm ("cancel_leading_coeff8",num_str @{thm cancel_leading_coeff8}),
427 Thm ("cancel_leading_coeff9",num_str @{thm cancel_leading_coeff9}),
428 Thm ("cancel_leading_coeff10",num_str @{thm cancel_leading_coeff10}),
429 Thm ("cancel_leading_coeff11",num_str @{thm cancel_leading_coeff11}),
430 Thm ("cancel_leading_coeff12",num_str @{thm cancel_leading_coeff12}),
431 Thm ("cancel_leading_coeff13",num_str @{thm cancel_leading_coeff13})
432 ],scr = Script ((term_of o the o (parse thy)) "empty_script")}:rls);
435 val complete_square = prep_rls(
436 Rls {id = "complete_square", preconds = [],
437 rew_ord = ("e_rew_ord",e_rew_ord),
438 erls = PolyEq_erls, srls = Erls, calc = [], (*asm_thm = [],*)
439 rules = [Thm ("complete_square1",num_str @{thm complete_square1}),
440 Thm ("complete_square2",num_str @{thm complete_square2}),
441 Thm ("complete_square3",num_str @{thm complete_square3}),
442 Thm ("complete_square4",num_str @{thm complete_square4}),
443 Thm ("complete_square5",num_str @{thm complete_square5})
445 scr = Script ((term_of o the o (parse thy))
449 val polyeq_simplify = prep_rls(
450 Rls {id = "polyeq_simplify", preconds = [],
451 rew_ord = ("termlessI",termlessI),
456 rules = [Thm ("real_assoc_1",num_str @{thm real_assoc_1}),
457 Thm ("real_assoc_2",num_str @{thm real_assoc_2}),
458 Thm ("real_diff_minus",num_str @{thm real_diff_minus}),
459 Thm ("real_unari_minus",num_str @{thm real_unari_minus}),
460 Thm ("realpow_multI",num_str @{thm realpow_multI}),
461 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
462 Calc ("Groups.minus_class.minus",eval_binop "#sub_"),
463 Calc ("Groups.times_class.times",eval_binop "#mult_"),
464 Calc ("Rings.inverse_class.divide", eval_cancel "#divide_e"),
465 Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
466 Calc ("Atools.pow" ,eval_binop "#power_"),
469 scr = Script ((term_of o the o (parse thy)) "empty_script")
472 ruleset' := overwritelthy @{theory} (!ruleset',
473 [("cancel_leading_coeff",cancel_leading_coeff),
474 ("complete_square",complete_square),
475 ("PolyEq_erls",PolyEq_erls),(*FIXXXME:del with rls.rls'*)
476 ("polyeq_simplify",polyeq_simplify)]);
481 (* ------------- polySolve ------------------ *)
483 (*isolate the bound variable in an d0 equation; 'bdv' is a meta-constant*)
484 val d0_polyeq_simplify = prep_rls(
485 Rls {id = "d0_polyeq_simplify", preconds = [],
486 rew_ord = ("e_rew_ord",e_rew_ord),
491 rules = [Thm("d0_true",num_str @{thm d0_true}),
492 Thm("d0_false",num_str @{thm d0_false})
494 scr = Script ((term_of o the o (parse thy)) "empty_script")
498 (*isolate the bound variable in an d1 equation; 'bdv' is a meta-constant*)
499 val d1_polyeq_simplify = prep_rls(
500 Rls {id = "d1_polyeq_simplify", preconds = [],
501 rew_ord = ("e_rew_ord",e_rew_ord),
505 (*asm_thm = [("d1_isolate_div","")],*)
507 Thm("d1_isolate_add1",num_str @{thm d1_isolate_add1}),
508 (* a+bx=0 -> bx=-a *)
509 Thm("d1_isolate_add2",num_str @{thm d1_isolate_add2}),
511 Thm("d1_isolate_div",num_str @{thm d1_isolate_div})
514 scr = Script ((term_of o the o (parse thy)) "empty_script")
520 (* isolate the bound variable in an d2 equation with bdv only;
521 'bdv' is a meta-constant*)
522 val d2_polyeq_bdv_only_simplify = prep_rls(
523 Rls {id = "d2_polyeq_bdv_only_simplify", preconds = [],
524 rew_ord = ("e_rew_ord",e_rew_ord),
528 (*asm_thm = [("d2_sqrt_equation1",""),("d2_sqrt_equation1_neg",""),
529 ("d2_isolate_div","")],*)
530 rules = [Thm("d2_prescind1",num_str @{thm d2_prescind1}),
531 (* ax+bx^2=0 -> x(a+bx)=0 *)
532 Thm("d2_prescind2",num_str @{thm d2_prescind2}),
533 (* ax+ x^2=0 -> x(a+ x)=0 *)
534 Thm("d2_prescind3",num_str @{thm d2_prescind3}),
535 (* x+bx^2=0 -> x(1+bx)=0 *)
536 Thm("d2_prescind4",num_str @{thm d2_prescind4}),
537 (* x+ x^2=0 -> x(1+ x)=0 *)
538 Thm("d2_sqrt_equation1",num_str @{thm d2_sqrt_equation1}),
539 (* x^2=c -> x=+-sqrt(c)*)
540 Thm("d2_sqrt_equation1_neg",num_str @{thm d2_sqrt_equation1_neg}),
541 (* [0<c] x^2=c -> [] *)
542 Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
544 Thm("d2_reduce_equation1",num_str @{thm d2_reduce_equation1}),
545 (* x(a+bx)=0 -> x=0 | a+bx=0*)
546 Thm("d2_reduce_equation2",num_str @{thm d2_reduce_equation2}),
547 (* x(a+ x)=0 -> x=0 | a+ x=0*)
548 Thm("d2_isolate_div",num_str @{thm d2_isolate_div})
549 (* bx^2=c -> x^2=c/b*)
551 scr = Script ((term_of o the o (parse thy)) "empty_script")
555 (* isolate the bound variable in an d2 equation with sqrt only;
556 'bdv' is a meta-constant*)
557 val d2_polyeq_sq_only_simplify = prep_rls(
558 Rls {id = "d2_polyeq_sq_only_simplify", preconds = [],
559 rew_ord = ("e_rew_ord",e_rew_ord),
563 (*asm_thm = [("d2_sqrt_equation1",""),("d2_sqrt_equation1_neg",""),
564 ("d2_isolate_div","")],*)
565 rules = [Thm("d2_isolate_add1",num_str @{thm d2_isolate_add1}),
566 (* a+ bx^2=0 -> bx^2=(-1)a*)
567 Thm("d2_isolate_add2",num_str @{thm d2_isolate_add2}),
568 (* a+ x^2=0 -> x^2=(-1)a*)
569 Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
571 Thm("d2_sqrt_equation1",num_str @{thm d2_sqrt_equation1}),
572 (* x^2=c -> x=+-sqrt(c)*)
573 Thm("d2_sqrt_equation1_neg",num_str @{thm d2_sqrt_equation1_neg}),
574 (* [c<0] x^2=c -> x=[] *)
575 Thm("d2_isolate_div",num_str @{thm d2_isolate_div})
576 (* bx^2=c -> x^2=c/b*)
578 scr = Script ((term_of o the o (parse thy)) "empty_script")
582 (* isolate the bound variable in an d2 equation with pqFormula;
583 'bdv' is a meta-constant*)
584 val d2_polyeq_pqFormula_simplify = prep_rls(
585 Rls {id = "d2_polyeq_pqFormula_simplify", preconds = [],
586 rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
587 srls = Erls, calc = [],
588 rules = [Thm("d2_pqformula1",num_str @{thm d2_pqformula1}),
590 Thm("d2_pqformula1_neg",num_str @{thm d2_pqformula1_neg}),
592 Thm("d2_pqformula2",num_str @{thm d2_pqformula2}),
594 Thm("d2_pqformula2_neg",num_str @{thm d2_pqformula2_neg}),
596 Thm("d2_pqformula3",num_str @{thm d2_pqformula3}),
598 Thm("d2_pqformula3_neg",num_str @{thm d2_pqformula3_neg}),
600 Thm("d2_pqformula4",num_str @{thm d2_pqformula4}),
602 Thm("d2_pqformula4_neg",num_str @{thm d2_pqformula4_neg}),
604 Thm("d2_pqformula5",num_str @{thm d2_pqformula5}),
606 Thm("d2_pqformula6",num_str @{thm d2_pqformula6}),
608 Thm("d2_pqformula7",num_str @{thm d2_pqformula7}),
610 Thm("d2_pqformula8",num_str @{thm d2_pqformula8}),
612 Thm("d2_pqformula9",num_str @{thm d2_pqformula9}),
614 Thm("d2_pqformula9_neg",num_str @{thm d2_pqformula9_neg}),
616 Thm("d2_pqformula10",num_str @{thm d2_pqformula10}),
618 Thm("d2_pqformula10_neg",num_str @{thm d2_pqformula10_neg}),
620 Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
622 Thm("d2_sqrt_equation3",num_str @{thm d2_sqrt_equation3})
624 ],scr = Script ((term_of o the o (parse thy)) "empty_script")
628 (* isolate the bound variable in an d2 equation with abcFormula;
629 'bdv' is a meta-constant*)
630 val d2_polyeq_abcFormula_simplify = prep_rls(
631 Rls {id = "d2_polyeq_abcFormula_simplify", preconds = [],
632 rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
633 srls = Erls, calc = [],
634 rules = [Thm("d2_abcformula1",num_str @{thm d2_abcformula1}),
636 Thm("d2_abcformula1_neg",num_str @{thm d2_abcformula1_neg}),
638 Thm("d2_abcformula2",num_str @{thm d2_abcformula2}),
640 Thm("d2_abcformula2_neg",num_str @{thm d2_abcformula2_neg}),
642 Thm("d2_abcformula3",num_str @{thm d2_abcformula3}),
644 Thm("d2_abcformula3_neg",num_str @{thm d2_abcformula3_neg}),
646 Thm("d2_abcformula4",num_str @{thm d2_abcformula4}),
648 Thm("d2_abcformula4_neg",num_str @{thm d2_abcformula4_neg}),
650 Thm("d2_abcformula5",num_str @{thm d2_abcformula5}),
652 Thm("d2_abcformula5_neg",num_str @{thm d2_abcformula5_neg}),
654 Thm("d2_abcformula6",num_str @{thm d2_abcformula6}),
656 Thm("d2_abcformula6_neg",num_str @{thm d2_abcformula6_neg}),
658 Thm("d2_abcformula7",num_str @{thm d2_abcformula7}),
660 Thm("d2_abcformula8",num_str @{thm d2_abcformula8}),
662 Thm("d2_abcformula9",num_str @{thm d2_abcformula9}),
664 Thm("d2_abcformula10",num_str @{thm d2_abcformula10}),
666 Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
668 Thm("d2_sqrt_equation3",num_str @{thm d2_sqrt_equation3})
671 scr = Script ((term_of o the o (parse thy)) "empty_script")
676 (* isolate the bound variable in an d2 equation;
677 'bdv' is a meta-constant*)
678 val d2_polyeq_simplify = prep_rls(
679 Rls {id = "d2_polyeq_simplify", preconds = [],
680 rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
681 srls = Erls, calc = [],
682 rules = [Thm("d2_pqformula1",num_str @{thm d2_pqformula1}),
684 Thm("d2_pqformula1_neg",num_str @{thm d2_pqformula1_neg}),
686 Thm("d2_pqformula2",num_str @{thm d2_pqformula2}),
688 Thm("d2_pqformula2_neg",num_str @{thm d2_pqformula2_neg}),
690 Thm("d2_pqformula3",num_str @{thm d2_pqformula3}),
692 Thm("d2_pqformula3_neg",num_str @{thm d2_pqformula3_neg}),
694 Thm("d2_pqformula4",num_str @{thm d2_pqformula4}),
696 Thm("d2_pqformula4_neg",num_str @{thm d2_pqformula4_neg}),
698 Thm("d2_abcformula1",num_str @{thm d2_abcformula1}),
700 Thm("d2_abcformula1_neg",num_str @{thm d2_abcformula1_neg}),
702 Thm("d2_abcformula2",num_str @{thm d2_abcformula2}),
704 Thm("d2_abcformula2_neg",num_str @{thm d2_abcformula2_neg}),
706 Thm("d2_prescind1",num_str @{thm d2_prescind1}),
707 (* ax+bx^2=0 -> x(a+bx)=0 *)
708 Thm("d2_prescind2",num_str @{thm d2_prescind2}),
709 (* ax+ x^2=0 -> x(a+ x)=0 *)
710 Thm("d2_prescind3",num_str @{thm d2_prescind3}),
711 (* x+bx^2=0 -> x(1+bx)=0 *)
712 Thm("d2_prescind4",num_str @{thm d2_prescind4}),
713 (* x+ x^2=0 -> x(1+ x)=0 *)
714 Thm("d2_isolate_add1",num_str @{thm d2_isolate_add1}),
715 (* a+ bx^2=0 -> bx^2=(-1)a*)
716 Thm("d2_isolate_add2",num_str @{thm d2_isolate_add2}),
717 (* a+ x^2=0 -> x^2=(-1)a*)
718 Thm("d2_sqrt_equation1",num_str @{thm d2_sqrt_equation1}),
719 (* x^2=c -> x=+-sqrt(c)*)
720 Thm("d2_sqrt_equation1_neg",num_str @{thm d2_sqrt_equation1_neg}),
721 (* [c<0] x^2=c -> x=[]*)
722 Thm("d2_sqrt_equation2",num_str @{thm d2_sqrt_equation2}),
724 Thm("d2_reduce_equation1",num_str @{thm d2_reduce_equation1}),
725 (* x(a+bx)=0 -> x=0 | a+bx=0*)
726 Thm("d2_reduce_equation2",num_str @{thm d2_reduce_equation2}),
727 (* x(a+ x)=0 -> x=0 | a+ x=0*)
728 Thm("d2_isolate_div",num_str @{thm d2_isolate_div})
729 (* bx^2=c -> x^2=c/b*)
731 scr = Script ((term_of o the o (parse thy)) "empty_script")
737 (* isolate the bound variable in an d3 equation; 'bdv' is a meta-constant *)
738 val d3_polyeq_simplify = prep_rls(
739 Rls {id = "d3_polyeq_simplify", preconds = [],
740 rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
741 srls = Erls, calc = [],
743 [Thm("d3_reduce_equation1",num_str @{thm d3_reduce_equation1}),
744 (*a*bdv + b*bdv^^^2 + c*bdv^^^3=0) =
745 (bdv=0 | (a + b*bdv + c*bdv^^^2=0)*)
746 Thm("d3_reduce_equation2",num_str @{thm d3_reduce_equation2}),
747 (* bdv + b*bdv^^^2 + c*bdv^^^3=0) =
748 (bdv=0 | (1 + b*bdv + c*bdv^^^2=0)*)
749 Thm("d3_reduce_equation3",num_str @{thm d3_reduce_equation3}),
750 (*a*bdv + bdv^^^2 + c*bdv^^^3=0) =
751 (bdv=0 | (a + bdv + c*bdv^^^2=0)*)
752 Thm("d3_reduce_equation4",num_str @{thm d3_reduce_equation4}),
753 (* bdv + bdv^^^2 + c*bdv^^^3=0) =
754 (bdv=0 | (1 + bdv + c*bdv^^^2=0)*)
755 Thm("d3_reduce_equation5",num_str @{thm d3_reduce_equation5}),
756 (*a*bdv + b*bdv^^^2 + bdv^^^3=0) =
757 (bdv=0 | (a + b*bdv + bdv^^^2=0)*)
758 Thm("d3_reduce_equation6",num_str @{thm d3_reduce_equation6}),
759 (* bdv + b*bdv^^^2 + bdv^^^3=0) =
760 (bdv=0 | (1 + b*bdv + bdv^^^2=0)*)
761 Thm("d3_reduce_equation7",num_str @{thm d3_reduce_equation7}),
762 (*a*bdv + bdv^^^2 + bdv^^^3=0) =
763 (bdv=0 | (1 + bdv + bdv^^^2=0)*)
764 Thm("d3_reduce_equation8",num_str @{thm d3_reduce_equation8}),
765 (* bdv + bdv^^^2 + bdv^^^3=0) =
766 (bdv=0 | (1 + bdv + bdv^^^2=0)*)
767 Thm("d3_reduce_equation9",num_str @{thm d3_reduce_equation9}),
768 (*a*bdv + c*bdv^^^3=0) =
769 (bdv=0 | (a + c*bdv^^^2=0)*)
770 Thm("d3_reduce_equation10",num_str @{thm d3_reduce_equation10}),
771 (* bdv + c*bdv^^^3=0) =
772 (bdv=0 | (1 + c*bdv^^^2=0)*)
773 Thm("d3_reduce_equation11",num_str @{thm d3_reduce_equation11}),
774 (*a*bdv + bdv^^^3=0) =
775 (bdv=0 | (a + bdv^^^2=0)*)
776 Thm("d3_reduce_equation12",num_str @{thm d3_reduce_equation12}),
777 (* bdv + bdv^^^3=0) =
778 (bdv=0 | (1 + bdv^^^2=0)*)
779 Thm("d3_reduce_equation13",num_str @{thm d3_reduce_equation13}),
780 (* b*bdv^^^2 + c*bdv^^^3=0) =
781 (bdv=0 | ( b*bdv + c*bdv^^^2=0)*)
782 Thm("d3_reduce_equation14",num_str @{thm d3_reduce_equation14}),
783 (* bdv^^^2 + c*bdv^^^3=0) =
784 (bdv=0 | ( bdv + c*bdv^^^2=0)*)
785 Thm("d3_reduce_equation15",num_str @{thm d3_reduce_equation15}),
786 (* b*bdv^^^2 + bdv^^^3=0) =
787 (bdv=0 | ( b*bdv + bdv^^^2=0)*)
788 Thm("d3_reduce_equation16",num_str @{thm d3_reduce_equation16}),
789 (* bdv^^^2 + bdv^^^3=0) =
790 (bdv=0 | ( bdv + bdv^^^2=0)*)
791 Thm("d3_isolate_add1",num_str @{thm d3_isolate_add1}),
792 (*[|Not(bdv occurs_in a)|] ==> (a + b*bdv^^^3=0) =
793 (bdv=0 | (b*bdv^^^3=a)*)
794 Thm("d3_isolate_add2",num_str @{thm d3_isolate_add2}),
795 (*[|Not(bdv occurs_in a)|] ==> (a + bdv^^^3=0) =
796 (bdv=0 | ( bdv^^^3=a)*)
797 Thm("d3_isolate_div",num_str @{thm d3_isolate_div}),
798 (*[|Not(b=0)|] ==> (b*bdv^^^3=c) = (bdv^^^3=c/b*)
799 Thm("d3_root_equation2",num_str @{thm d3_root_equation2}),
800 (*(bdv^^^3=0) = (bdv=0) *)
801 Thm("d3_root_equation1",num_str @{thm d3_root_equation1})
802 (*bdv^^^3=c) = (bdv = nroot 3 c*)
804 scr = Script ((term_of o the o (parse thy)) "empty_script")
810 (*isolate the bound variable in an d4 equation; 'bdv' is a meta-constant*)
811 val d4_polyeq_simplify = prep_rls(
812 Rls {id = "d4_polyeq_simplify", preconds = [],
813 rew_ord = ("e_rew_ord",e_rew_ord), erls = PolyEq_erls,
814 srls = Erls, calc = [],
816 [Thm("d4_sub_u1",num_str @{thm d4_sub_u1})
817 (* ax^4+bx^2+c=0 -> x=+-sqrt(ax^2+bx^+c) *)
819 scr = Script ((term_of o the o (parse thy)) "empty_script")
823 overwritelthy @{theory}
825 [("d0_polyeq_simplify", d0_polyeq_simplify),
826 ("d1_polyeq_simplify", d1_polyeq_simplify),
827 ("d2_polyeq_simplify", d2_polyeq_simplify),
828 ("d2_polyeq_bdv_only_simplify", d2_polyeq_bdv_only_simplify),
829 ("d2_polyeq_sq_only_simplify", d2_polyeq_sq_only_simplify),
830 ("d2_polyeq_pqFormula_simplify", d2_polyeq_pqFormula_simplify),
831 ("d2_polyeq_abcFormula_simplify",
832 d2_polyeq_abcFormula_simplify),
833 ("d3_polyeq_simplify", d3_polyeq_simplify),
834 ("d4_polyeq_simplify", d4_polyeq_simplify)
839 (*------------------------problems------------------------*)
841 (get_pbt ["degree_2","polynomial","univariate","equation"]);
845 (*-------------------------poly-----------------------*)
847 (prep_pbt thy "pbl_equ_univ_poly" [] e_pblID
848 (["polynomial","univariate","equation"],
849 [("#Given" ,["equality e_e","solveFor v_v"]),
850 ("#Where" ,["~((e_e::bool) is_ratequation_in (v_v::real))",
851 "~((lhs e_e) is_rootTerm_in (v_v::real))",
852 "~((rhs e_e) is_rootTerm_in (v_v::real))"]),
853 ("#Find" ,["solutions v_v'i'"])
855 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
859 (prep_pbt thy "pbl_equ_univ_poly_deg0" [] e_pblID
860 (["degree_0","polynomial","univariate","equation"],
861 [("#Given" ,["equality e_e","solveFor v_v"]),
862 ("#Where" ,["matches (?a = 0) e_e",
863 "(lhs e_e) is_poly_in v_v",
864 "((lhs e_e) has_degree_in v_v ) = 0"
866 ("#Find" ,["solutions v_v'i'"])
868 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
869 [["PolyEq","solve_d0_polyeq_equation"]]));
873 (prep_pbt thy "pbl_equ_univ_poly_deg1" [] e_pblID
874 (["degree_1","polynomial","univariate","equation"],
875 [("#Given" ,["equality e_e","solveFor v_v"]),
876 ("#Where" ,["matches (?a = 0) e_e",
877 "(lhs e_e) is_poly_in v_v",
878 "((lhs e_e) has_degree_in v_v ) = 1"
880 ("#Find" ,["solutions v_v'i'"])
882 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
883 [["PolyEq","solve_d1_polyeq_equation"]]));
888 (prep_pbt thy "pbl_equ_univ_poly_deg2" [] e_pblID
889 (["degree_2","polynomial","univariate","equation"],
890 [("#Given" ,["equality e_e","solveFor v_v"]),
891 ("#Where" ,["matches (?a = 0) e_e",
892 "(lhs e_e) is_poly_in v_v ",
893 "((lhs e_e) has_degree_in v_v ) = 2"]),
894 ("#Find" ,["solutions v_v'i'"])
896 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
897 [["PolyEq","solve_d2_polyeq_equation"]]));
900 (prep_pbt thy "pbl_equ_univ_poly_deg2_sqonly" [] e_pblID
901 (["sq_only","degree_2","polynomial","univariate","equation"],
902 [("#Given" ,["equality e_e","solveFor v_v"]),
903 ("#Where" ,["matches ( ?a + ?v_^^^2 = 0) e_e | " ^
904 "matches ( ?a + ?b*?v_^^^2 = 0) e_e | " ^
905 "matches ( ?v_^^^2 = 0) e_e | " ^
906 "matches ( ?b*?v_^^^2 = 0) e_e" ,
907 "Not (matches (?a + ?v_ + ?v_^^^2 = 0) e_e) &" ^
908 "Not (matches (?a + ?b*?v_ + ?v_^^^2 = 0) e_e) &" ^
909 "Not (matches (?a + ?v_ + ?c*?v_^^^2 = 0) e_e) &" ^
910 "Not (matches (?a + ?b*?v_ + ?c*?v_^^^2 = 0) e_e) &" ^
911 "Not (matches ( ?v_ + ?v_^^^2 = 0) e_e) &" ^
912 "Not (matches ( ?b*?v_ + ?v_^^^2 = 0) e_e) &" ^
913 "Not (matches ( ?v_ + ?c*?v_^^^2 = 0) e_e) &" ^
914 "Not (matches ( ?b*?v_ + ?c*?v_^^^2 = 0) e_e)"]),
915 ("#Find" ,["solutions v_v'i'"])
917 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
918 [["PolyEq","solve_d2_polyeq_sqonly_equation"]]));
921 (prep_pbt thy "pbl_equ_univ_poly_deg2_bdvonly" [] e_pblID
922 (["bdv_only","degree_2","polynomial","univariate","equation"],
923 [("#Given" ,["equality e_e","solveFor v_v"]),
924 ("#Where" ,["matches (?a*?v_ + ?v_^^^2 = 0) e_e | " ^
925 "matches ( ?v_ + ?v_^^^2 = 0) e_e | " ^
926 "matches ( ?v_ + ?b*?v_^^^2 = 0) e_e | " ^
927 "matches (?a*?v_ + ?b*?v_^^^2 = 0) e_e | " ^
928 "matches ( ?v_^^^2 = 0) e_e | " ^
929 "matches ( ?b*?v_^^^2 = 0) e_e "]),
930 ("#Find" ,["solutions v_v'i'"])
932 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
933 [["PolyEq","solve_d2_polyeq_bdvonly_equation"]]));
936 (prep_pbt thy "pbl_equ_univ_poly_deg2_pq" [] e_pblID
937 (["pqFormula","degree_2","polynomial","univariate","equation"],
938 [("#Given" ,["equality e_e","solveFor v_v"]),
939 ("#Where" ,["matches (?a + 1*?v_^^^2 = 0) e_e | " ^
940 "matches (?a + ?v_^^^2 = 0) e_e"]),
941 ("#Find" ,["solutions v_v'i'"])
943 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
944 [["PolyEq","solve_d2_polyeq_pq_equation"]]));
947 (prep_pbt thy "pbl_equ_univ_poly_deg2_abc" [] e_pblID
948 (["abcFormula","degree_2","polynomial","univariate","equation"],
949 [("#Given" ,["equality e_e","solveFor v_v"]),
950 ("#Where" ,["matches (?a + ?v_^^^2 = 0) e_e | " ^
951 "matches (?a + ?b*?v_^^^2 = 0) e_e"]),
952 ("#Find" ,["solutions v_v'i'"])
954 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
955 [["PolyEq","solve_d2_polyeq_abc_equation"]]));
960 (prep_pbt thy "pbl_equ_univ_poly_deg3" [] e_pblID
961 (["degree_3","polynomial","univariate","equation"],
962 [("#Given" ,["equality e_e","solveFor v_v"]),
963 ("#Where" ,["matches (?a = 0) e_e",
964 "(lhs e_e) is_poly_in v_v ",
965 "((lhs e_e) has_degree_in v_v) = 3"]),
966 ("#Find" ,["solutions v_v'i'"])
968 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
969 [["PolyEq","solve_d3_polyeq_equation"]]));
973 (prep_pbt thy "pbl_equ_univ_poly_deg4" [] e_pblID
974 (["degree_4","polynomial","univariate","equation"],
975 [("#Given" ,["equality e_e","solveFor v_v"]),
976 ("#Where" ,["matches (?a = 0) e_e",
977 "(lhs e_e) is_poly_in v_v ",
978 "((lhs e_e) has_degree_in v_v) = 4"]),
979 ("#Find" ,["solutions v_v'i'"])
981 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
982 [(*["PolyEq","solve_d4_polyeq_equation"]*)]));
984 (*--- normalize ---*)
986 (prep_pbt thy "pbl_equ_univ_poly_norm" [] e_pblID
987 (["normalize","polynomial","univariate","equation"],
988 [("#Given" ,["equality e_e","solveFor v_v"]),
989 ("#Where" ,["(Not((matches (?a = 0 ) e_e ))) |" ^
990 "(Not(((lhs e_e) is_poly_in v_v)))"]),
991 ("#Find" ,["solutions v_v'i'"])
993 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
994 [["PolyEq","normalize_poly"]]));
995 (*-------------------------expanded-----------------------*)
997 (prep_pbt thy "pbl_equ_univ_expand" [] e_pblID
998 (["expanded","univariate","equation"],
999 [("#Given" ,["equality e_e","solveFor v_v"]),
1000 ("#Where" ,["matches (?a = 0) e_e",
1001 "(lhs e_e) is_expanded_in v_v "]),
1002 ("#Find" ,["solutions v_v'i'"])
1004 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
1009 (prep_pbt thy "pbl_equ_univ_expand_deg2" [] e_pblID
1010 (["degree_2","expanded","univariate","equation"],
1011 [("#Given" ,["equality e_e","solveFor v_v"]),
1012 ("#Where" ,["((lhs e_e) has_degree_in v_v) = 2"]),
1013 ("#Find" ,["solutions v_v'i'"])
1015 PolyEq_prls, SOME "solve (e_e::bool, v_v)",
1016 [["PolyEq","complete_square"]]));
1021 "Script Normalize_poly (e_e::bool) (v_v::real) = " ^
1022 "(let e_e =((Try (Rewrite all_left False)) @@ " ^
1023 " (Try (Repeat (Rewrite makex1_x False))) @@ " ^
1024 " (Try (Repeat (Rewrite_Set expand_binoms False))) @@ " ^
1025 " (Try (Repeat (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1026 " make_ratpoly_in False))) @@ " ^
1027 " (Try (Repeat (Rewrite_Set polyeq_simplify False)))) e_e " ^
1028 " in (SubProblem (PolyEq',[polynomial,univariate,equation], [no_met]) " ^
1029 " [BOOL e_e, REAL v_v]))";
1033 "-------------------------methods-----------------------";
1035 (prep_met thy "met_polyeq" [] e_metID
1038 {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
1039 crls=PolyEq_crls, nrls=norm_Rational}, "empty_script"));
1042 (prep_met thy "met_polyeq_norm" [] e_metID
1043 (["PolyEq","normalize_poly"],
1044 [("#Given" ,["equality e_e","solveFor v_v"]),
1045 ("#Where" ,["(Not((matches (?a = 0 ) e_e ))) |" ^
1046 "(Not(((lhs e_e) is_poly_in v_v)))"]),
1047 ("#Find" ,["solutions v_v'i'"])
1049 {rew_ord'="termlessI",
1054 crls=PolyEq_crls, nrls=norm_Rational},
1055 "Script Normalize_poly (e_e::bool) (v_v::real) = " ^
1056 "(let e_e =((Try (Rewrite all_left False)) @@ " ^
1057 " (Try (Repeat (Rewrite makex1_x False))) @@ " ^
1058 " (Try (Repeat (Rewrite_Set expand_binoms False))) @@ " ^
1059 " (Try (Repeat (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1060 " make_ratpoly_in False))) @@ " ^
1061 " (Try (Repeat (Rewrite_Set polyeq_simplify False)))) e_e " ^
1062 " in (SubProblem (PolyEq',[polynomial,univariate,equation], [no_met]) " ^
1063 " [BOOL e_e, REAL v_v]))"
1069 (prep_met thy "met_polyeq_d0" [] e_metID
1070 (["PolyEq","solve_d0_polyeq_equation"],
1071 [("#Given" ,["equality e_e","solveFor v_v"]),
1072 ("#Where" ,["(lhs e_e) is_poly_in v_v ",
1073 "((lhs e_e) has_degree_in v_v) = 0"]),
1074 ("#Find" ,["solutions v_v'i'"])
1076 {rew_ord'="termlessI",
1080 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1081 crls=PolyEq_crls, nrls=norm_Rational},
1082 "Script Solve_d0_polyeq_equation (e_e::bool) (v_v::real) = " ^
1083 "(let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1084 " d0_polyeq_simplify False))) e_e " ^
1085 " in ((Or_to_List e_e)::bool list))"
1090 (prep_met thy "met_polyeq_d1" [] e_metID
1091 (["PolyEq","solve_d1_polyeq_equation"],
1092 [("#Given" ,["equality e_e","solveFor v_v"]),
1093 ("#Where" ,["(lhs e_e) is_poly_in v_v ",
1094 "((lhs e_e) has_degree_in v_v) = 1"]),
1095 ("#Find" ,["solutions v_v'i'"])
1097 {rew_ord'="termlessI", rls'=PolyEq_erls, srls=e_rls, prls=PolyEq_prls,
1098 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1099 crls=PolyEq_crls, nrls=norm_Rational},
1100 "Script Solve_d1_polyeq_equation (e_e::bool) (v_v::real) = " ^
1101 "(let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1102 " d1_polyeq_simplify True)) @@ " ^
1103 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1104 " (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
1105 " (L_L::bool list) = ((Or_to_List e_e)::bool list) " ^
1106 " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
1111 (prep_met thy "met_polyeq_d22" [] e_metID
1112 (["PolyEq","solve_d2_polyeq_equation"],
1113 [("#Given" ,["equality e_e","solveFor v_v"]),
1114 ("#Where" ,["(lhs e_e) is_poly_in v_v ",
1115 "((lhs e_e) has_degree_in v_v) = 2"]),
1116 ("#Find" ,["solutions v_v'i'"])
1118 {rew_ord'="termlessI",
1122 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1123 crls=PolyEq_crls, nrls=norm_Rational},
1124 "Script Solve_d2_polyeq_equation (e_e::bool) (v_v::real) = " ^
1125 " (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1126 " d2_polyeq_simplify True)) @@ " ^
1127 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1128 " (Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1129 " d1_polyeq_simplify True)) @@ " ^
1130 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1131 " (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
1132 " (L_L::bool list) = ((Or_to_List e_e)::bool list) " ^
1133 " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
1138 (prep_met thy "met_polyeq_d2_bdvonly" [] e_metID
1139 (["PolyEq","solve_d2_polyeq_bdvonly_equation"],
1140 [("#Given" ,["equality e_e","solveFor v_v"]),
1141 ("#Where" ,["(lhs e_e) is_poly_in v_v ",
1142 "((lhs e_e) has_degree_in v_v) = 2"]),
1143 ("#Find" ,["solutions v_v'i'"])
1145 {rew_ord'="termlessI",
1149 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1150 crls=PolyEq_crls, nrls=norm_Rational},
1151 "Script Solve_d2_polyeq_bdvonly_equation (e_e::bool) (v_v::real) =" ^
1152 " (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1153 " d2_polyeq_bdv_only_simplify True)) @@ " ^
1154 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1155 " (Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1156 " d1_polyeq_simplify True)) @@ " ^
1157 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1158 " (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
1159 " (L_L::bool list) = ((Or_to_List e_e)::bool list) " ^
1160 " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
1165 (prep_met thy "met_polyeq_d2_sqonly" [] e_metID
1166 (["PolyEq","solve_d2_polyeq_sqonly_equation"],
1167 [("#Given" ,["equality e_e","solveFor v_v"]),
1168 ("#Where" ,["(lhs e_e) is_poly_in v_v ",
1169 "((lhs e_e) has_degree_in v_v) = 2"]),
1170 ("#Find" ,["solutions v_v'i'"])
1172 {rew_ord'="termlessI",
1176 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1177 crls=PolyEq_crls, nrls=norm_Rational},
1178 "Script Solve_d2_polyeq_sqonly_equation (e_e::bool) (v_v::real) =" ^
1179 " (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1180 " d2_polyeq_sq_only_simplify True)) @@ " ^
1181 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1182 " (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e; " ^
1183 " (L_L::bool list) = ((Or_to_List e_e)::bool list) " ^
1184 " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
1189 (prep_met thy "met_polyeq_d2_pq" [] e_metID
1190 (["PolyEq","solve_d2_polyeq_pq_equation"],
1191 [("#Given" ,["equality e_e","solveFor v_v"]),
1192 ("#Where" ,["(lhs e_e) is_poly_in v_v ",
1193 "((lhs e_e) has_degree_in v_v) = 2"]),
1194 ("#Find" ,["solutions v_v'i'"])
1196 {rew_ord'="termlessI",
1200 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1201 crls=PolyEq_crls, nrls=norm_Rational},
1202 "Script Solve_d2_polyeq_pq_equation (e_e::bool) (v_v::real) = " ^
1203 " (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1204 " d2_polyeq_pqFormula_simplify True)) @@ " ^
1205 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1206 " (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
1207 " (L_L::bool list) = ((Or_to_List e_e)::bool list) " ^
1208 " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
1213 (prep_met thy "met_polyeq_d2_abc" [] e_metID
1214 (["PolyEq","solve_d2_polyeq_abc_equation"],
1215 [("#Given" ,["equality e_e","solveFor v_v"]),
1216 ("#Where" ,["(lhs e_e) is_poly_in v_v ",
1217 "((lhs e_e) has_degree_in v_v) = 2"]),
1218 ("#Find" ,["solutions v_v'i'"])
1220 {rew_ord'="termlessI",
1224 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1225 crls=PolyEq_crls, nrls=norm_Rational},
1226 "Script Solve_d2_polyeq_abc_equation (e_e::bool) (v_v::real) = " ^
1227 " (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1228 " d2_polyeq_abcFormula_simplify True)) @@ " ^
1229 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1230 " (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
1231 " (L_L::bool list) = ((Or_to_List e_e)::bool list) " ^
1232 " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
1237 (prep_met thy "met_polyeq_d3" [] e_metID
1238 (["PolyEq","solve_d3_polyeq_equation"],
1239 [("#Given" ,["equality e_e","solveFor v_v"]),
1240 ("#Where" ,["(lhs e_e) is_poly_in v_v ",
1241 "((lhs e_e) has_degree_in v_v) = 3"]),
1242 ("#Find" ,["solutions v_v'i'"])
1244 {rew_ord'="termlessI",
1248 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1249 crls=PolyEq_crls, nrls=norm_Rational},
1250 "Script Solve_d3_polyeq_equation (e_e::bool) (v_v::real) = " ^
1251 " (let e_e = ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1252 " d3_polyeq_simplify True)) @@ " ^
1253 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1254 " (Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1255 " d2_polyeq_simplify True)) @@ " ^
1256 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1257 " (Try (Rewrite_Set_Inst [(bdv,v_v::real)] " ^
1258 " d1_polyeq_simplify True)) @@ " ^
1259 " (Try (Rewrite_Set polyeq_simplify False)) @@ " ^
1260 " (Try (Rewrite_Set norm_Rational_parenthesized False))) e_e;" ^
1261 " (L_L::bool list) = ((Or_to_List e_e)::bool list) " ^
1262 " in Check_elementwise L_LL {(v_v::real). Assumptions} )"
1266 (*.solves all expanded (ie. normalized) terms of degree 2.*)
1267 (*Oct.02 restriction: 'eval_true 0 =< discriminant' ony for integer values
1268 by 'PolyEq_erls'; restricted until Float.thy is implemented*)
1270 (prep_met thy "met_polyeq_complsq" [] e_metID
1271 (["PolyEq","complete_square"],
1272 [("#Given" ,["equality e_e","solveFor v_v"]),
1273 ("#Where" ,["matches (?a = 0) e_e",
1274 "((lhs e_e) has_degree_in v_v) = 2"]),
1275 ("#Find" ,["solutions v_v'i'"])
1277 {rew_ord'="termlessI",rls'=PolyEq_erls,srls=e_rls,prls=PolyEq_prls,
1278 calc=[("sqrt", ("NthRoot.sqrt", eval_sqrt "#sqrt_"))],
1279 crls=PolyEq_crls, nrls=norm_Rational},
1280 "Script Complete_square (e_e::bool) (v_v::real) = " ^
1282 " ((Try (Rewrite_Set_Inst [(bdv,v_v)] cancel_leading_coeff True)) " ^
1283 " @@ (Try (Rewrite_Set_Inst [(bdv,v_v)] complete_square True)) " ^
1284 " @@ (Try (Rewrite square_explicit1 False)) " ^
1285 " @@ (Try (Rewrite square_explicit2 False)) " ^
1286 " @@ (Rewrite root_plus_minus True) " ^
1287 " @@ (Try (Repeat (Rewrite_Inst [(bdv,v_v)] bdv_explicit1 False))) " ^
1288 " @@ (Try (Repeat (Rewrite_Inst [(bdv,v_v)] bdv_explicit2 False))) " ^
1289 " @@ (Try (Repeat " ^
1290 " (Rewrite_Inst [(bdv,v_v)] bdv_explicit3 False))) " ^
1291 " @@ (Try (Rewrite_Set calculate_RootRat False)) " ^
1292 " @@ (Try (Repeat (Calculate SQRT)))) e_e " ^
1293 " in ((Or_to_List e_e)::bool list))"
1298 (* termorder hacked by MG *)
1299 local (*. for make_polynomial_in .*)
1301 open Term; (* for type order = EQUAL | LESS | GREATER *)
1303 fun pr_ord EQUAL = "EQUAL"
1304 | pr_ord LESS = "LESS"
1305 | pr_ord GREATER = "GREATER";
1307 fun dest_hd' x (Const (a, T)) = (((a, 0), T), 0)
1308 | dest_hd' x (t as Free (a, T)) =
1309 if x = t then ((("|||||||||||||", 0), T), 0) (*WN*)
1310 else (((a, 0), T), 1)
1311 | dest_hd' x (Var v) = (v, 2)
1312 | dest_hd' x (Bound i) = ((("", i), dummyT), 3)
1313 | dest_hd' x (Abs (_, T, _)) = ((("", 0), T), 4);
1315 fun size_of_term' x (Const ("Atools.pow",_) $ Free (var,_) $ Free (pot,_)) =
1318 (if xstr = var then 1000*(the (int_of_str pot)) else 3)
1319 | _ => error ("size_of_term' called with subst = "^
1321 | size_of_term' x (Free (subst,_)) =
1323 (Free (xstr,_)) => (if xstr = subst then 1000 else 1)
1324 | _ => error ("size_of_term' called with subst = "^
1326 | size_of_term' x (Abs (_,_,body)) = 1 + size_of_term' x body
1327 | size_of_term' x (f$t) = size_of_term' x f + size_of_term' x t
1328 | size_of_term' x _ = 1;
1331 fun term_ord' x pr thy (Abs (_, T, t), Abs(_, U, u)) = (* ~ term.ML *)
1332 (case term_ord' x pr thy (t, u) of EQUAL => Term_Ord.typ_ord (T, U) | ord => ord)
1333 | term_ord' x pr thy (t, u) =
1336 val (f, ts) = strip_comb t and (g, us) = strip_comb u;
1337 val _=tracing("t= f@ts= \""^
1338 ((Syntax.string_of_term (thy2ctxt thy)) f)^"\" @ \"["^
1339 (commas(map (Syntax.string_of_term (thy2ctxt thy)) ts))^"]\"");
1340 val _=tracing("u= g@us= \""^
1341 ((Syntax.string_of_term (thy2ctxt thy)) g)^"\" @ \"["^
1342 (commas(map (Syntax.string_of_term (thy2ctxt thy)) us))^"]\"");
1343 val _=tracing("size_of_term(t,u)= ("^
1344 (string_of_int(size_of_term' x t))^", "^
1345 (string_of_int(size_of_term' x u))^")");
1346 val _=tracing("hd_ord(f,g) = "^((pr_ord o (hd_ord x))(f,g)));
1347 val _=tracing("terms_ord(ts,us) = "^
1348 ((pr_ord o (terms_ord x) str false)(ts, us)));
1349 val _=tracing("-------");
1352 case int_ord (size_of_term' x t, size_of_term' x u) of
1354 let val (f, ts) = strip_comb t and (g, us) = strip_comb u in
1355 (case hd_ord x (f, g) of EQUAL => (terms_ord x str pr) (ts, us)
1359 and hd_ord x (f, g) = (* ~ term.ML *)
1360 prod_ord (prod_ord Term_Ord.indexname_ord Term_Ord.typ_ord)
1361 int_ord (dest_hd' x f, dest_hd' x g)
1362 and terms_ord x str pr (ts, us) =
1363 list_ord (term_ord' x pr (assoc_thy "Isac"))(ts, us);
1366 fun ord_make_polynomial_in (pr:bool) thy subst tu =
1368 (* val _=tracing("*** subs variable is: "^(subst2str subst)); *)
1371 (_,x)::_ => (term_ord' x pr thy tu = LESS)
1372 | _ => error ("ord_make_polynomial_in called with subst = "^
1379 val order_add_mult_in = prep_rls(
1380 Rls{id = "order_add_mult_in", preconds = [],
1381 rew_ord = ("ord_make_polynomial_in",
1382 ord_make_polynomial_in false (theory "Poly")),
1383 erls = e_rls,srls = Erls,
1386 rules = [Thm ("real_mult_commute",num_str @{thm real_mult_commute}),
1388 Thm ("real_mult_left_commute",num_str @{thm real_mult_left_commute}),
1389 (*z1.0 * (z2.0 * z3.0) = z2.0 * (z1.0 * z3.0)*)
1390 Thm ("real_mult_assoc",num_str @{thm real_mult_assoc}),
1391 (*z1.0 * z2.0 * z3.0 = z1.0 * (z2.0 * z3.0)*)
1392 Thm ("add_commute",num_str @{thm add_commute}),
1394 Thm ("add_left_commute",num_str @{thm add_left_commute}),
1395 (*x + (y + z) = y + (x + z)*)
1396 Thm ("add_assoc",num_str @{thm add_assoc})
1397 (*z1.0 + z2.0 + z3.0 = z1.0 + (z2.0 + z3.0)*)
1398 ], scr = EmptyScr}:rls);
1402 val collect_bdv = prep_rls(
1403 Rls{id = "collect_bdv", preconds = [],
1404 rew_ord = ("dummy_ord", dummy_ord),
1405 erls = e_rls,srls = Erls,
1408 rules = [Thm ("bdv_collect_1",num_str @{thm bdv_collect_1}),
1409 Thm ("bdv_collect_2",num_str @{thm bdv_collect_2}),
1410 Thm ("bdv_collect_3",num_str @{thm bdv_collect_3}),
1412 Thm ("bdv_collect_assoc1_1",num_str @{thm bdv_collect_assoc1_1}),
1413 Thm ("bdv_collect_assoc1_2",num_str @{thm bdv_collect_assoc1_2}),
1414 Thm ("bdv_collect_assoc1_3",num_str @{thm bdv_collect_assoc1_3}),
1416 Thm ("bdv_collect_assoc2_1",num_str @{thm bdv_collect_assoc2_1}),
1417 Thm ("bdv_collect_assoc2_2",num_str @{thm bdv_collect_assoc2_2}),
1418 Thm ("bdv_collect_assoc2_3",num_str @{thm bdv_collect_assoc2_3}),
1421 Thm ("bdv_n_collect_1",num_str @{thm bdv_n_collect_1}),
1422 Thm ("bdv_n_collect_2",num_str @{thm bdv_n_collect_2}),
1423 Thm ("bdv_n_collect_3",num_str @{thm bdv_n_collect_3}),
1425 Thm ("bdv_n_collect_assoc1_1",num_str @{thm bdv_n_collect_assoc1_1}),
1426 Thm ("bdv_n_collect_assoc1_2",num_str @{thm bdv_n_collect_assoc1_2}),
1427 Thm ("bdv_n_collect_assoc1_3",num_str @{thm bdv_n_collect_assoc1_3}),
1429 Thm ("bdv_n_collect_assoc2_1",num_str @{thm bdv_n_collect_assoc2_1}),
1430 Thm ("bdv_n_collect_assoc2_2",num_str @{thm bdv_n_collect_assoc2_2}),
1431 Thm ("bdv_n_collect_assoc2_3",num_str @{thm bdv_n_collect_assoc2_3})
1432 ], scr = EmptyScr}:rls);
1436 (*.transforms an arbitrary term without roots to a polynomial [4]
1437 according to knowledge/Poly.sml.*)
1438 val make_polynomial_in = prep_rls(
1439 Seq {id = "make_polynomial_in", preconds = []:term list,
1440 rew_ord = ("dummy_ord", dummy_ord),
1441 erls = Atools_erls, srls = Erls,
1442 calc = [], (*asm_thm = [],*)
1443 rules = [Rls_ expand_poly,
1444 Rls_ order_add_mult_in,
1445 Rls_ simplify_power,
1446 Rls_ collect_numerals,
1448 Thm ("realpow_oneI",num_str @{thm realpow_oneI}),
1449 Rls_ discard_parentheses,
1458 append_rls "separate_bdvs"
1460 [Thm ("separate_bdv", num_str @{thm separate_bdv}),
1461 (*"?a * ?bdv / ?b = ?a / ?b * ?bdv"*)
1462 Thm ("separate_bdv_n", num_str @{thm separate_bdv_n}),
1463 Thm ("separate_1_bdv", num_str @{thm separate_1_bdv}),
1464 (*"?bdv / ?b = (1 / ?b) * ?bdv"*)
1465 Thm ("separate_1_bdv_n", num_str @{thm separate_1_bdv_n}),
1466 (*"?bdv ^^^ ?n / ?b = 1 / ?b * ?bdv ^^^ ?n"*)
1467 Thm ("add_divide_distrib",
1468 num_str @{thm add_divide_distrib})
1469 (*"(?x + ?y) / ?z = ?x / ?z + ?y / ?z"
1470 WN051031 DOES NOT BELONG TO HERE*)
1474 val make_ratpoly_in = prep_rls(
1475 Seq {id = "make_ratpoly_in", preconds = []:term list,
1476 rew_ord = ("dummy_ord", dummy_ord),
1477 erls = Atools_erls, srls = Erls,
1478 calc = [], (*asm_thm = [],*)
1479 rules = [Rls_ norm_Rational,
1480 Rls_ order_add_mult_in,
1481 Rls_ discard_parentheses,
1483 (* Rls_ rearrange_assoc, WN060916 why does cancel_p not work?*)
1485 (*Calc ("Rings.inverse_class.divide" ,eval_cancel "#divide_e") too weak!*)
1487 scr = EmptyScr}:rls);
1490 ruleset' := overwritelthy @{theory} (!ruleset',
1491 [("order_add_mult_in", order_add_mult_in),
1492 ("collect_bdv", collect_bdv),
1493 ("make_polynomial_in", make_polynomial_in),
1494 ("make_ratpoly_in", make_ratpoly_in),
1495 ("separate_bdvs", separate_bdvs)