prep. extend "type met" with errpaty
1 (*.(c) by Richard Lang, 2003 .*)
2 (* collecting all knowledge for Root Equations
10 theory RootEq imports Root begin
12 text {* univariate equations containing real square roots:
13 This type of equations has been used to bootstrap Lucas-Interpretation.
14 In 2003 this type has been extended and integrated into ISAC's equation solver
15 by Richard Lang in 2003.
16 The assumptions (all containing "<") didn't pass the xml-parsers at the
17 interface between math-engine and front-end.
18 The migration Isabelle2002 --> 2011 dropped this type of equation, see
19 test/../rooteq.sml, rootrateq.sml.
24 is'_rootTerm'_in :: "[real, real] => bool" ("_ is'_rootTerm'_in _")
25 is'_sqrtTerm'_in :: "[real, real] => bool" ("_ is'_sqrtTerm'_in _")
26 is'_normSqrtTerm'_in :: "[real, real] => bool" ("_ is'_normSqrtTerm'_in _")
28 (*----------------------scripts-----------------------*)
29 Norm'_sq'_root'_equation
31 bool list] => bool list"
32 ("((Script Norm'_sq'_root'_equation (_ _ =))//
34 Solve'_sq'_root'_equation
36 bool list] => bool list"
37 ("((Script Solve'_sq'_root'_equation (_ _ =))//
39 Solve'_left'_sq'_root'_equation
41 bool list] => bool list"
42 ("((Script Solve'_left'_sq'_root'_equation (_ _ =))//
44 Solve'_right'_sq'_root'_equation
46 bool list] => bool list"
47 ("((Script Solve'_right'_sq'_root'_equation (_ _ =))//
50 axioms(*axiomatization where*)
53 makex1_x: "a^^^1 = a" (*and*)
54 real_assoc_1: "a+(b+c) = a+b+c" (*and*)
55 real_assoc_2: "a*(b*c) = a*b*c" (*and*)
57 (* simplification of root*)
58 sqrt_square_1: "[|0 <= a|] ==> (sqrt a)^^^2 = a" (*and*)
59 sqrt_square_2: "sqrt (a ^^^ 2) = a" (*and*)
60 sqrt_times_root_1: "sqrt a * sqrt b = sqrt(a*b)" (*and*)
61 sqrt_times_root_2: "a * sqrt b * sqrt c = a * sqrt(b*c)" (*and*)
63 (* isolate one root on the LEFT or RIGHT hand side of the equation *)
64 sqrt_isolate_l_add1: "[|bdv occurs_in c|] ==>
65 (a + b*sqrt(c) = d) = (b * sqrt(c) = d+ (-1) * a)" (*and*)
66 sqrt_isolate_l_add2: "[|bdv occurs_in c|] ==>
67 (a + sqrt(c) = d) = ((sqrt(c) = d+ (-1) * a))" (*and*)
68 sqrt_isolate_l_add3: "[|bdv occurs_in c|] ==>
69 (a + b*(e/sqrt(c)) = d) = (b * (e/sqrt(c)) = d + (-1) * a)" (*and*)
70 sqrt_isolate_l_add4: "[|bdv occurs_in c|] ==>
71 (a + b/(f*sqrt(c)) = d) = (b / (f*sqrt(c)) = d + (-1) * a)" (*and*)
72 sqrt_isolate_l_add5: "[|bdv occurs_in c|] ==>
73 (a + b*(e/(f*sqrt(c))) = d) = (b * (e/(f*sqrt(c))) = d+ (-1) * a)" (*and*)
74 sqrt_isolate_l_add6: "[|bdv occurs_in c|] ==>
75 (a + b/sqrt(c) = d) = (b / sqrt(c) = d+ (-1) * a)" (*and*)
76 sqrt_isolate_r_add1: "[|bdv occurs_in f|] ==>
77 (a = d + e*sqrt(f)) = (a + (-1) * d = e*sqrt(f))" (*and*)
78 sqrt_isolate_r_add2: "[|bdv occurs_in f|] ==>
79 (a = d + sqrt(f)) = (a + (-1) * d = sqrt(f))" (*and*)
80 (* small hack: thm 3,5,6 are not needed if rootnormalize is well done*)
81 sqrt_isolate_r_add3: "[|bdv occurs_in f|] ==>
82 (a = d + e*(g/sqrt(f))) = (a + (-1) * d = e*(g/sqrt(f)))" (*and*)
83 sqrt_isolate_r_add4: "[|bdv occurs_in f|] ==>
84 (a = d + g/sqrt(f)) = (a + (-1) * d = g/sqrt(f))" (*and*)
85 sqrt_isolate_r_add5: "[|bdv occurs_in f|] ==>
86 (a = d + e*(g/(h*sqrt(f)))) = (a + (-1) * d = e*(g/(h*sqrt(f))))" (*and*)
87 sqrt_isolate_r_add6: "[|bdv occurs_in f|] ==>
88 (a = d + g/(h*sqrt(f))) = (a + (-1) * d = g/(h*sqrt(f)))" (*and*)
90 (* eliminate isolates sqrt *)
91 sqrt_square_equation_both_1: "[|bdv occurs_in b; bdv occurs_in d|] ==>
92 ( (sqrt a + sqrt b = sqrt c + sqrt d) =
93 (a+2*sqrt(a)*sqrt(b)+b = c+2*sqrt(c)*sqrt(d)+d))" (*and*)
94 sqrt_square_equation_both_2: "[|bdv occurs_in b; bdv occurs_in d|] ==>
95 ( (sqrt a - sqrt b = sqrt c + sqrt d) =
96 (a - 2*sqrt(a)*sqrt(b)+b = c+2*sqrt(c)*sqrt(d)+d))" (*and*)
97 sqrt_square_equation_both_3: "[|bdv occurs_in b; bdv occurs_in d|] ==>
98 ( (sqrt a + sqrt b = sqrt c - sqrt d) =
99 (a + 2*sqrt(a)*sqrt(b)+b = c - 2*sqrt(c)*sqrt(d)+d))" (*and*)
100 sqrt_square_equation_both_4: "[|bdv occurs_in b; bdv occurs_in d|] ==>
101 ( (sqrt a - sqrt b = sqrt c - sqrt d) =
102 (a - 2*sqrt(a)*sqrt(b)+b = c - 2*sqrt(c)*sqrt(d)+d))" (*and*)
103 sqrt_square_equation_left_1: "[|bdv occurs_in a; 0 <= a; 0 <= b|] ==>
104 ( (sqrt (a) = b) = (a = (b^^^2)))" (*and*)
105 sqrt_square_equation_left_2: "[|bdv occurs_in a; 0 <= a; 0 <= b*c|] ==>
106 ( (c*sqrt(a) = b) = (c^^^2*a = b^^^2))" (*and*)
107 sqrt_square_equation_left_3: "[|bdv occurs_in a; 0 <= a; 0 <= b*c|] ==>
108 ( c/sqrt(a) = b) = (c^^^2 / a = b^^^2)" (*and*)
109 (* small hack: thm 4-6 are not needed if rootnormalize is well done*)
110 sqrt_square_equation_left_4: "[|bdv occurs_in a; 0 <= a; 0 <= b*c*d|] ==>
111 ( (c*(d/sqrt (a)) = b) = (c^^^2*(d^^^2/a) = b^^^2))" (*and*)
112 sqrt_square_equation_left_5: "[|bdv occurs_in a; 0 <= a; 0 <= b*c*d|] ==>
113 ( c/(d*sqrt(a)) = b) = (c^^^2 / (d^^^2*a) = b^^^2)" (*and*)
114 sqrt_square_equation_left_6: "[|bdv occurs_in a; 0 <= a; 0 <= b*c*d*e|] ==>
115 ( (c*(d/(e*sqrt (a))) = b) = (c^^^2*(d^^^2/(e^^^2*a)) = b^^^2))" (*and*)
116 sqrt_square_equation_right_1: "[|bdv occurs_in b; 0 <= a; 0 <= b|] ==>
117 ( (a = sqrt (b)) = (a^^^2 = b))" (*and*)
118 sqrt_square_equation_right_2: "[|bdv occurs_in b; 0 <= a*c; 0 <= b|] ==>
119 ( (a = c*sqrt (b)) = ((a^^^2) = c^^^2*b))" (*and*)
120 sqrt_square_equation_right_3: "[|bdv occurs_in b; 0 <= a*c; 0 <= b|] ==>
121 ( (a = c/sqrt (b)) = (a^^^2 = c^^^2/b))" (*and*)
122 (* small hack: thm 4-6 are not needed if rootnormalize is well done*)
123 sqrt_square_equation_right_4: "[|bdv occurs_in b; 0 <= a*c*d; 0 <= b|] ==>
124 ( (a = c*(d/sqrt (b))) = ((a^^^2) = c^^^2*(d^^^2/b)))" (*and*)
125 sqrt_square_equation_right_5: "[|bdv occurs_in b; 0 <= a*c*d; 0 <= b|] ==>
126 ( (a = c/(d*sqrt (b))) = (a^^^2 = c^^^2/(d^^^2*b)))" (*and*)
127 sqrt_square_equation_right_6: "[|bdv occurs_in b; 0 <= a*c*d*e; 0 <= b|] ==>
128 ( (a = c*(d/(e*sqrt (b)))) = ((a^^^2) = c^^^2*(d^^^2/(e^^^2*b))))"
133 (*-------------------------functions---------------------*)
134 (* true if bdv is under sqrt of a Equation*)
135 fun is_rootTerm_in t v =
137 fun coeff_in c v = member op = (vars c) v;
138 fun findroot (_ $ _ $ _ $ _) v = error("is_rootTerm_in:")
139 (* at the moment there is no term like this, but ....*)
140 | findroot (t as (Const ("Root.nroot",_) $ _ $ t3)) v = coeff_in t3 v
141 | findroot (_ $ t2 $ t3) v = (findroot t2 v) orelse (findroot t3 v)
142 | findroot (t as (Const ("NthRoot.sqrt",_) $ t2)) v = coeff_in t2 v
143 | findroot (_ $ t2) v = (findroot t2 v)
144 | findroot _ _ = false;
149 fun is_sqrtTerm_in t v =
151 fun coeff_in c v = member op = (vars c) v;
152 fun findsqrt (_ $ _ $ _ $ _) v = error("is_sqrteqation_in:")
153 (* at the moment there is no term like this, but ....*)
154 | findsqrt (_ $ t1 $ t2) v = (findsqrt t1 v) orelse (findsqrt t2 v)
155 | findsqrt (t as (Const ("NthRoot.sqrt",_) $ a)) v = coeff_in a v
156 | findsqrt (_ $ t1) v = (findsqrt t1 v)
157 | findsqrt _ _ = false;
162 (* RL: 030518: Is in the rightest subterm of a term a sqrt with bdv,
163 and the subterm ist connected with + or * --> is normalized*)
164 fun is_normSqrtTerm_in t v =
166 fun coeff_in c v = member op = (vars c) v;
167 fun isnorm (_ $ _ $ _ $ _) v = error("is_normSqrtTerm_in:")
168 (* at the moment there is no term like this, but ....*)
169 | isnorm (Const ("Groups.plus_class.plus",_) $ _ $ t2) v = is_sqrtTerm_in t2 v
170 | isnorm (Const ("Groups.times_class.times",_) $ _ $ t2) v = is_sqrtTerm_in t2 v
171 | isnorm (Const ("Groups.minus_class.minus",_) $ _ $ _) v = false
172 | isnorm (Const ("Rings.inverse_class.divide",_) $ t1 $ t2) v = (is_sqrtTerm_in t1 v) orelse
173 (is_sqrtTerm_in t2 v)
174 | isnorm (Const ("NthRoot.sqrt",_) $ t1) v = coeff_in t1 v
175 | isnorm (_ $ t1) v = is_sqrtTerm_in t1 v
176 | isnorm _ _ = false;
181 fun eval_is_rootTerm_in _ _
182 (p as (Const ("RootEq.is'_rootTerm'_in",_) $ t $ v)) _ =
183 if is_rootTerm_in t v then
184 SOME ((term2str p) ^ " = True",
185 Trueprop $ (mk_equality (p, HOLogic.true_const)))
186 else SOME ((term2str p) ^ " = True",
187 Trueprop $ (mk_equality (p, HOLogic.false_const)))
188 | eval_is_rootTerm_in _ _ _ _ = ((*tracing"### nichts matcht";*) NONE);
190 fun eval_is_sqrtTerm_in _ _
191 (p as (Const ("RootEq.is'_sqrtTerm'_in",_) $ t $ v)) _ =
192 if is_sqrtTerm_in t v then
193 SOME ((term2str p) ^ " = True",
194 Trueprop $ (mk_equality (p, HOLogic.true_const)))
195 else SOME ((term2str p) ^ " = True",
196 Trueprop $ (mk_equality (p, HOLogic.false_const)))
197 | eval_is_sqrtTerm_in _ _ _ _ = ((*tracing"### nichts matcht";*) NONE);
199 fun eval_is_normSqrtTerm_in _ _
200 (p as (Const ("RootEq.is'_normSqrtTerm'_in",_) $ t $ v)) _ =
201 if is_normSqrtTerm_in t v then
202 SOME ((term2str p) ^ " = True",
203 Trueprop $ (mk_equality (p, HOLogic.true_const)))
204 else SOME ((term2str p) ^ " = True",
205 Trueprop $ (mk_equality (p, HOLogic.false_const)))
206 | eval_is_normSqrtTerm_in _ _ _ _ = ((*tracing"### nichts matcht";*) NONE);
208 (*-------------------------rulse-------------------------*)
209 val RootEq_prls =(*15.10.02:just the following order due to subterm evaluation*)
210 append_rls "RootEq_prls" e_rls
211 [Calc ("Atools.ident",eval_ident "#ident_"),
212 Calc ("Tools.matches",eval_matches ""),
213 Calc ("Tools.lhs" ,eval_lhs ""),
214 Calc ("Tools.rhs" ,eval_rhs ""),
215 Calc ("RootEq.is'_sqrtTerm'_in",eval_is_sqrtTerm_in ""),
216 Calc ("RootEq.is'_rootTerm'_in",eval_is_rootTerm_in ""),
217 Calc ("RootEq.is'_normSqrtTerm'_in",eval_is_normSqrtTerm_in ""),
218 Calc ("HOL.eq",eval_equal "#equal_"),
219 Thm ("not_true",num_str @{thm not_true}),
220 Thm ("not_false",num_str @{thm not_false}),
221 Thm ("and_true",num_str @{thm and_true}),
222 Thm ("and_false",num_str @{thm and_false}),
223 Thm ("or_true",num_str @{thm or_true}),
224 Thm ("or_false",num_str @{thm or_false})
228 append_rls "RootEq_erls" Root_erls
229 [Thm ("divide_divide_eq_left",num_str @{thm divide_divide_eq_left})
233 append_rls "RootEq_crls" Root_crls
234 [Thm ("divide_divide_eq_left",num_str @{thm divide_divide_eq_left})
238 append_rls "rooteq_srls" e_rls
239 [Calc ("RootEq.is'_sqrtTerm'_in",eval_is_sqrtTerm_in ""),
240 Calc ("RootEq.is'_normSqrtTerm'_in",eval_is_normSqrtTerm_in""),
241 Calc ("RootEq.is'_rootTerm'_in",eval_is_rootTerm_in "")
244 ruleset' := overwritelthy @{theory} (!ruleset',
245 [("RootEq_erls",RootEq_erls),
246 (*FIXXXME:del with rls.rls'*)
247 ("rooteq_srls",rooteq_srls)
250 (*isolate the bound variable in an sqrt equation; 'bdv' is a meta-constant*)
251 val sqrt_isolate = prep_rls(
252 Rls {id = "sqrt_isolate", preconds = [], rew_ord = ("termlessI",termlessI),
253 erls = RootEq_erls, srls = Erls, calc = [],
255 Thm("sqrt_square_1",num_str @{thm sqrt_square_1}),
256 (* (sqrt a)^^^2 -> a *)
257 Thm("sqrt_square_2",num_str @{thm sqrt_square_2}),
258 (* sqrt (a^^^2) -> a *)
259 Thm("sqrt_times_root_1",num_str @{thm sqrt_times_root_1}),
260 (* sqrt a sqrt b -> sqrt(ab) *)
261 Thm("sqrt_times_root_2",num_str @{thm sqrt_times_root_2}),
262 (* a sqrt b sqrt c -> a sqrt(bc) *)
263 Thm("sqrt_square_equation_both_1",
264 num_str @{thm sqrt_square_equation_both_1}),
265 (* (sqrt a + sqrt b = sqrt c + sqrt d) ->
266 (a+2*sqrt(a)*sqrt(b)+b) = c+2*sqrt(c)*sqrt(d)+d) *)
267 Thm("sqrt_square_equation_both_2",
268 num_str @{thm sqrt_square_equation_both_2}),
269 (* (sqrt a - sqrt b = sqrt c + sqrt d) ->
270 (a-2*sqrt(a)*sqrt(b)+b) = c+2*sqrt(c)*sqrt(d)+d) *)
271 Thm("sqrt_square_equation_both_3",
272 num_str @{thm sqrt_square_equation_both_3}),
273 (* (sqrt a + sqrt b = sqrt c - sqrt d) ->
274 (a+2*sqrt(a)*sqrt(b)+b) = c-2*sqrt(c)*sqrt(d)+d) *)
275 Thm("sqrt_square_equation_both_4",
276 num_str @{thm sqrt_square_equation_both_4}),
277 (* (sqrt a - sqrt b = sqrt c - sqrt d) ->
278 (a-2*sqrt(a)*sqrt(b)+b) = c-2*sqrt(c)*sqrt(d)+d) *)
279 Thm("sqrt_isolate_l_add1",
280 num_str @{thm sqrt_isolate_l_add1}),
281 (* a+b*sqrt(x)=d -> b*sqrt(x) = d-a *)
282 Thm("sqrt_isolate_l_add2",
283 num_str @{thm sqrt_isolate_l_add2}),
284 (* a+ sqrt(x)=d -> sqrt(x) = d-a *)
285 Thm("sqrt_isolate_l_add3",
286 num_str @{thm sqrt_isolate_l_add3}),
287 (* a+b*c/sqrt(x)=d->b*c/sqrt(x)=d-a *)
288 Thm("sqrt_isolate_l_add4",
289 num_str @{thm sqrt_isolate_l_add4}),
290 (* a+c/sqrt(x)=d -> c/sqrt(x) = d-a *)
291 Thm("sqrt_isolate_l_add5",
292 num_str @{thm sqrt_isolate_l_add5}),
293 (* a+b*c/f*sqrt(x)=d->b*c/f*sqrt(x)=d-a *)
294 Thm("sqrt_isolate_l_add6",
295 num_str @{thm sqrt_isolate_l_add6}),
296 (* a+c/f*sqrt(x)=d -> c/f*sqrt(x) = d-a *)
297 (*Thm("sqrt_isolate_l_div",num_str @{thm sqrt_isolate_l_div}),*)
298 (* b*sqrt(x) = d sqrt(x) d/b *)
299 Thm("sqrt_isolate_r_add1",
300 num_str @{thm sqrt_isolate_r_add1}),
301 (* a= d+e*sqrt(x) -> a-d=e*sqrt(x) *)
302 Thm("sqrt_isolate_r_add2",
303 num_str @{thm sqrt_isolate_r_add2}),
304 (* a= d+ sqrt(x) -> a-d= sqrt(x) *)
305 Thm("sqrt_isolate_r_add3",
306 num_str @{thm sqrt_isolate_r_add3}),
307 (* a=d+e*g/sqrt(x)->a-d=e*g/sqrt(x)*)
308 Thm("sqrt_isolate_r_add4",
309 num_str @{thm sqrt_isolate_r_add4}),
310 (* a= d+g/sqrt(x) -> a-d=g/sqrt(x) *)
311 Thm("sqrt_isolate_r_add5",
312 num_str @{thm sqrt_isolate_r_add5}),
313 (* a=d+e*g/h*sqrt(x)->a-d=e*g/h*sqrt(x)*)
314 Thm("sqrt_isolate_r_add6",
315 num_str @{thm sqrt_isolate_r_add6}),
316 (* a= d+g/h*sqrt(x) -> a-d=g/h*sqrt(x) *)
317 (*Thm("sqrt_isolate_r_div",num_str @{thm sqrt_isolate_r_div}),*)
318 (* a=e*sqrt(x) -> a/e = sqrt(x) *)
319 Thm("sqrt_square_equation_left_1",
320 num_str @{thm sqrt_square_equation_left_1}),
321 (* sqrt(x)=b -> x=b^2 *)
322 Thm("sqrt_square_equation_left_2",
323 num_str @{thm sqrt_square_equation_left_2}),
324 (* c*sqrt(x)=b -> c^2*x=b^2 *)
325 Thm("sqrt_square_equation_left_3",num_str @{thm sqrt_square_equation_left_3}),
326 (* c/sqrt(x)=b -> c^2/x=b^2 *)
327 Thm("sqrt_square_equation_left_4",num_str @{thm sqrt_square_equation_left_4}),
328 (* c*d/sqrt(x)=b -> c^2*d^2/x=b^2 *)
329 Thm("sqrt_square_equation_left_5",num_str @{thm sqrt_square_equation_left_5}),
330 (* c/d*sqrt(x)=b -> c^2/d^2x=b^2 *)
331 Thm("sqrt_square_equation_left_6",num_str @{thm sqrt_square_equation_left_6}),
332 (* c*d/g*sqrt(x)=b -> c^2*d^2/g^2x=b^2 *)
333 Thm("sqrt_square_equation_right_1",num_str @{thm sqrt_square_equation_right_1}),
334 (* a=sqrt(x) ->a^2=x *)
335 Thm("sqrt_square_equation_right_2",num_str @{thm sqrt_square_equation_right_2}),
336 (* a=c*sqrt(x) ->a^2=c^2*x *)
337 Thm("sqrt_square_equation_right_3",num_str @{thm sqrt_square_equation_right_3}),
338 (* a=c/sqrt(x) ->a^2=c^2/x *)
339 Thm("sqrt_square_equation_right_4",num_str @{thm sqrt_square_equation_right_4}),
340 (* a=c*d/sqrt(x) ->a^2=c^2*d^2/x *)
341 Thm("sqrt_square_equation_right_5",num_str @{thm sqrt_square_equation_right_5}),
342 (* a=c/e*sqrt(x) ->a^2=c^2/e^2x *)
343 Thm("sqrt_square_equation_right_6",num_str @{thm sqrt_square_equation_right_6})
344 (* a=c*d/g*sqrt(x) ->a^2=c^2*d^2/g^2*x *)
345 ],scr = Script ((term_of o the o (parse thy)) "empty_script")
348 ruleset' := overwritelthy @{theory} (!ruleset',
349 [("sqrt_isolate",sqrt_isolate)
351 (* -- left 28.08.02--*)
352 (*isolate the bound variable in an sqrt left equation; 'bdv' is a meta-constant*)
353 val l_sqrt_isolate = prep_rls(
354 Rls {id = "l_sqrt_isolate", preconds = [],
355 rew_ord = ("termlessI",termlessI),
356 erls = RootEq_erls, srls = Erls, calc = [],
358 Thm("sqrt_square_1",num_str @{thm sqrt_square_1}),
359 (* (sqrt a)^^^2 -> a *)
360 Thm("sqrt_square_2",num_str @{thm sqrt_square_2}),
361 (* sqrt (a^^^2) -> a *)
362 Thm("sqrt_times_root_1",num_str @{thm sqrt_times_root_1}),
363 (* sqrt a sqrt b -> sqrt(ab) *)
364 Thm("sqrt_times_root_2",num_str @{thm sqrt_times_root_2}),
365 (* a sqrt b sqrt c -> a sqrt(bc) *)
366 Thm("sqrt_isolate_l_add1",num_str @{thm sqrt_isolate_l_add1}),
367 (* a+b*sqrt(x)=d -> b*sqrt(x) = d-a *)
368 Thm("sqrt_isolate_l_add2",num_str @{thm sqrt_isolate_l_add2}),
369 (* a+ sqrt(x)=d -> sqrt(x) = d-a *)
370 Thm("sqrt_isolate_l_add3",num_str @{thm sqrt_isolate_l_add3}),
371 (* a+b*c/sqrt(x)=d->b*c/sqrt(x)=d-a *)
372 Thm("sqrt_isolate_l_add4",num_str @{thm sqrt_isolate_l_add4}),
373 (* a+c/sqrt(x)=d -> c/sqrt(x) = d-a *)
374 Thm("sqrt_isolate_l_add5",num_str @{thm sqrt_isolate_l_add5}),
375 (* a+b*c/f*sqrt(x)=d->b*c/f*sqrt(x)=d-a *)
376 Thm("sqrt_isolate_l_add6",num_str @{thm sqrt_isolate_l_add6}),
377 (* a+c/f*sqrt(x)=d -> c/f*sqrt(x) = d-a *)
378 (*Thm("sqrt_isolate_l_div",num_str @{thm sqrt_isolate_l_div}),*)
379 (* b*sqrt(x) = d sqrt(x) d/b *)
380 Thm("sqrt_square_equation_left_1",num_str @{thm sqrt_square_equation_left_1}),
381 (* sqrt(x)=b -> x=b^2 *)
382 Thm("sqrt_square_equation_left_2",num_str @{thm sqrt_square_equation_left_2}),
383 (* a*sqrt(x)=b -> a^2*x=b^2*)
384 Thm("sqrt_square_equation_left_3",num_str @{thm sqrt_square_equation_left_3}),
385 (* c/sqrt(x)=b -> c^2/x=b^2 *)
386 Thm("sqrt_square_equation_left_4",num_str @{thm sqrt_square_equation_left_4}),
387 (* c*d/sqrt(x)=b -> c^2*d^2/x=b^2 *)
388 Thm("sqrt_square_equation_left_5",num_str @{thm sqrt_square_equation_left_5}),
389 (* c/d*sqrt(x)=b -> c^2/d^2x=b^2 *)
390 Thm("sqrt_square_equation_left_6",num_str @{thm sqrt_square_equation_left_6})
391 (* c*d/g*sqrt(x)=b -> c^2*d^2/g^2x=b^2 *)
393 scr = Script ((term_of o the o (parse thy)) "empty_script")
396 ruleset' := overwritelthy @{theory} (!ruleset',
397 [("l_sqrt_isolate",l_sqrt_isolate)
400 (* -- right 28.8.02--*)
401 (*isolate the bound variable in an sqrt right equation; 'bdv' is a meta-constant*)
402 val r_sqrt_isolate = prep_rls(
403 Rls {id = "r_sqrt_isolate", preconds = [],
404 rew_ord = ("termlessI",termlessI),
405 erls = RootEq_erls, srls = Erls, calc = [],
407 Thm("sqrt_square_1",num_str @{thm sqrt_square_1}),
408 (* (sqrt a)^^^2 -> a *)
409 Thm("sqrt_square_2",num_str @{thm sqrt_square_2}),
410 (* sqrt (a^^^2) -> a *)
411 Thm("sqrt_times_root_1",num_str @{thm sqrt_times_root_1}),
412 (* sqrt a sqrt b -> sqrt(ab) *)
413 Thm("sqrt_times_root_2",num_str @{thm sqrt_times_root_2}),
414 (* a sqrt b sqrt c -> a sqrt(bc) *)
415 Thm("sqrt_isolate_r_add1",num_str @{thm sqrt_isolate_r_add1}),
416 (* a= d+e*sqrt(x) -> a-d=e*sqrt(x) *)
417 Thm("sqrt_isolate_r_add2",num_str @{thm sqrt_isolate_r_add2}),
418 (* a= d+ sqrt(x) -> a-d= sqrt(x) *)
419 Thm("sqrt_isolate_r_add3",num_str @{thm sqrt_isolate_r_add3}),
420 (* a=d+e*g/sqrt(x)->a-d=e*g/sqrt(x)*)
421 Thm("sqrt_isolate_r_add4",num_str @{thm sqrt_isolate_r_add4}),
422 (* a= d+g/sqrt(x) -> a-d=g/sqrt(x) *)
423 Thm("sqrt_isolate_r_add5",num_str @{thm sqrt_isolate_r_add5}),
424 (* a=d+e*g/h*sqrt(x)->a-d=e*g/h*sqrt(x)*)
425 Thm("sqrt_isolate_r_add6",num_str @{thm sqrt_isolate_r_add6}),
426 (* a= d+g/h*sqrt(x) -> a-d=g/h*sqrt(x) *)
427 (*Thm("sqrt_isolate_r_div",num_str @{thm sqrt_isolate_r_div}),*)
428 (* a=e*sqrt(x) -> a/e = sqrt(x) *)
429 Thm("sqrt_square_equation_right_1",num_str @{thm sqrt_square_equation_right_1}),
430 (* a=sqrt(x) ->a^2=x *)
431 Thm("sqrt_square_equation_right_2",num_str @{thm sqrt_square_equation_right_2}),
432 (* a=c*sqrt(x) ->a^2=c^2*x *)
433 Thm("sqrt_square_equation_right_3",num_str @{thm sqrt_square_equation_right_3}),
434 (* a=c/sqrt(x) ->a^2=c^2/x *)
435 Thm("sqrt_square_equation_right_4",num_str @{thm sqrt_square_equation_right_4}),
436 (* a=c*d/sqrt(x) ->a^2=c^2*d^2/x *)
437 Thm("sqrt_square_equation_right_5",num_str @{thm sqrt_square_equation_right_5}),
438 (* a=c/e*sqrt(x) ->a^2=c^2/e^2x *)
439 Thm("sqrt_square_equation_right_6",num_str @{thm sqrt_square_equation_right_6})
440 (* a=c*d/g*sqrt(x) ->a^2=c^2*d^2/g^2*x *)
442 scr = Script ((term_of o the o (parse thy)) "empty_script")
445 ruleset' := overwritelthy @{theory} (!ruleset',
446 [("r_sqrt_isolate",r_sqrt_isolate)
449 val rooteq_simplify = prep_rls(
450 Rls {id = "rooteq_simplify",
451 preconds = [], rew_ord = ("termlessI",termlessI),
452 erls = RootEq_erls, srls = Erls, calc = [],
453 (*asm_thm = [("sqrt_square_1","")],*)
454 rules = [Thm ("real_assoc_1",num_str @{thm real_assoc_1}),
455 (* a+(b+c) = a+b+c *)
456 Thm ("real_assoc_2",num_str @{thm real_assoc_2}),
457 (* a*(b*c) = a*b*c *)
458 Calc ("Groups.plus_class.plus",eval_binop "#add_"),
459 Calc ("Groups.minus_class.minus",eval_binop "#sub_"),
460 Calc ("Groups.times_class.times",eval_binop "#mult_"),
461 Calc ("Rings.inverse_class.divide", eval_cancel "#divide_e"),
462 Calc ("NthRoot.sqrt",eval_sqrt "#sqrt_"),
463 Calc ("Atools.pow" ,eval_binop "#power_"),
464 Thm("real_plus_binom_pow2",num_str @{thm real_plus_binom_pow2}),
465 Thm("real_minus_binom_pow2",num_str @{thm real_minus_binom_pow2}),
466 Thm("realpow_mul",num_str @{thm realpow_mul}),
467 (* (a * b)^n = a^n * b^n*)
468 Thm("sqrt_times_root_1",num_str @{thm sqrt_times_root_1}),
469 (* sqrt b * sqrt c = sqrt(b*c) *)
470 Thm("sqrt_times_root_2",num_str @{thm sqrt_times_root_2}),
471 (* a * sqrt a * sqrt b = a * sqrt(a*b) *)
472 Thm("sqrt_square_2",num_str @{thm sqrt_square_2}),
473 (* sqrt (a^^^2) = a *)
474 Thm("sqrt_square_1",num_str @{thm sqrt_square_1})
475 (* sqrt a ^^^ 2 = a *)
477 scr = Script ((term_of o the o (parse thy)) "empty_script")
479 ruleset' := overwritelthy @{theory} (!ruleset',
480 [("rooteq_simplify",rooteq_simplify)
483 (*-------------------------Problem-----------------------*)
485 (get_pbt ["root'","univariate","equation"]);
488 (* ---------root----------- *)
490 (prep_pbt thy "pbl_equ_univ_root" [] e_pblID
491 (["root'","univariate","equation"],
492 [("#Given" ,["equality e_e","solveFor v_v"]),
493 ("#Where" ,["(lhs e_e) is_rootTerm_in (v_v::real) | " ^
494 "(rhs e_e) is_rootTerm_in (v_v::real)"]),
495 ("#Find" ,["solutions v_v'i'"])
497 RootEq_prls, SOME "solve (e_e::bool, v_v)",
499 (* ---------sqrt----------- *)
501 (prep_pbt thy "pbl_equ_univ_root_sq" [] e_pblID
502 (["sq","root'","univariate","equation"],
503 [("#Given" ,["equality e_e","solveFor v_v"]),
504 ("#Where" ,["( ((lhs e_e) is_sqrtTerm_in (v_v::real)) &" ^
505 " ((lhs e_e) is_normSqrtTerm_in (v_v::real)) ) |" ^
506 "( ((rhs e_e) is_sqrtTerm_in (v_v::real)) &" ^
507 " ((rhs e_e) is_normSqrtTerm_in (v_v::real)) )"]),
508 ("#Find" ,["solutions v_v'i'"])
510 RootEq_prls, SOME "solve (e_e::bool, v_v)",
511 [["RootEq","solve_sq_root_equation"]]));
512 (* ---------normalize----------- *)
514 (prep_pbt thy "pbl_equ_univ_root_norm" [] e_pblID
515 (["normalize","root'","univariate","equation"],
516 [("#Given" ,["equality e_e","solveFor v_v"]),
517 ("#Where" ,["( ((lhs e_e) is_sqrtTerm_in (v_v::real)) &" ^
518 " Not((lhs e_e) is_normSqrtTerm_in (v_v::real))) | " ^
519 "( ((rhs e_e) is_sqrtTerm_in (v_v::real)) &" ^
520 " Not((rhs e_e) is_normSqrtTerm_in (v_v::real)))"]),
521 ("#Find" ,["solutions v_v'i'"])
523 RootEq_prls, SOME "solve (e_e::bool, v_v)",
524 [["RootEq","norm_sq_root_equation"]]));
526 (*-------------------------methods-----------------------*)
527 (* ---- root 20.8.02 ---*)
529 (prep_met thy "met_rooteq" [] e_metID
532 {rew_ord'="tless_true",rls'=Atools_erls,calc = [], srls = e_rls, prls=e_rls,
533 crls=RootEq_crls, nrls = norm_Poly}, "empty_script"));
535 (*-- normalize 20.10.02 --*)
537 (prep_met thy "met_rooteq_norm" [] e_metID
538 (["RootEq","norm_sq_root_equation"],
539 [("#Given" ,["equality e_e","solveFor v_v"]),
540 ("#Where" ,["( ((lhs e_e) is_sqrtTerm_in (v_v::real)) &" ^
541 " Not((lhs e_e) is_normSqrtTerm_in (v_v::real))) | " ^
542 "( ((rhs e_e) is_sqrtTerm_in (v_v::real)) &" ^
543 " Not((rhs e_e) is_normSqrtTerm_in (v_v::real)))"]),
544 ("#Find" ,["solutions v_v'i'"])
546 {rew_ord'="termlessI", rls'=RootEq_erls, srls=e_rls, prls=RootEq_prls,
547 calc=[], crls=RootEq_crls, nrls = norm_Poly},
548 "Script Norm_sq_root_equation (e_e::bool) (v_v::real) = " ^
549 "(let e_e = ((Repeat(Try (Rewrite makex1_x False))) @@ " ^
550 " (Try (Repeat (Rewrite_Set expand_rootbinoms False))) @@ " ^
551 " (Try (Rewrite_Set rooteq_simplify True)) @@ " ^
552 " (Try (Repeat (Rewrite_Set make_rooteq False))) @@ " ^
553 " (Try (Rewrite_Set rooteq_simplify True))) e_e " ^
554 " in ((SubProblem (RootEq',[univariate,equation], " ^
555 " [no_met]) [BOOL e_e, REAL v_v])))"
561 val -------------------------------------------------- = "00000";
563 (prep_met thy "met_rooteq_sq" [] e_metID
564 (["RootEq","solve_sq_root_equation"],
565 [("#Given" ,["equality e_e", "solveFor v_v"]),
566 ("#Where" ,["(((lhs e_e) is_sqrtTerm_in (v_v::real)) & " ^
567 " ((lhs e_e) is_normSqrtTerm_in (v_v::real))) |" ^
568 "(((rhs e_e) is_sqrtTerm_in (v_v::real)) & " ^
569 " ((rhs e_e) is_normSqrtTerm_in (v_v::real)))"]),
570 ("#Find" ,["solutions v_v'i'"])
572 {rew_ord'="termlessI", rls'=RootEq_erls, srls = rooteq_srls,
573 prls = RootEq_prls, calc = [], crls=RootEq_crls, nrls = norm_Poly},
574 "Script Solve_sq_root_equation (e_e::bool) (v_v::real) = " ^
576 " ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] sqrt_isolate True)) @@ " ^
577 " (Try (Rewrite_Set rooteq_simplify True)) @@ " ^
578 " (Try (Repeat (Rewrite_Set expand_rootbinoms False))) @@ " ^
579 " (Try (Repeat (Rewrite_Set make_rooteq False))) @@ " ^
580 " (Try (Rewrite_Set rooteq_simplify True)) ) e_e; " ^
581 " (L_L::bool list) = " ^
582 " (if (((lhs e_e) is_sqrtTerm_in v_v) | ((rhs e_e) is_sqrtTerm_in v_v))" ^
583 " then (SubProblem (RootEq',[normalize,root',univariate,equation], " ^
584 " [no_met]) [BOOL e_e, REAL v_v]) " ^
585 " else (SubProblem (RootEq',[univariate,equation], [no_met]) " ^
586 " [BOOL e_e, REAL v_v])) " ^
587 "in Check_elementwise L_L {(v_v::real). Assumptions})"
592 (*-- right 28.08.02 --*)
594 (prep_met thy "met_rooteq_sq_right" [] e_metID
595 (["RootEq","solve_right_sq_root_equation"],
596 [("#Given" ,["equality e_e","solveFor v_v"]),
597 ("#Where" ,["(rhs e_e) is_sqrtTerm_in v_v"]),
598 ("#Find" ,["solutions v_v'i'"])
600 {rew_ord' = "termlessI", rls' = RootEq_erls, srls = e_rls,
601 prls = RootEq_prls, calc = [], crls = RootEq_crls, nrls = norm_Poly},
602 "Script Solve_right_sq_root_equation (e_e::bool) (v_v::real) = " ^
604 " ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] r_sqrt_isolate False)) @@ " ^
605 " (Try (Rewrite_Set rooteq_simplify False)) @@ " ^
606 " (Try (Repeat (Rewrite_Set expand_rootbinoms False))) @@ " ^
607 " (Try (Repeat (Rewrite_Set make_rooteq False))) @@ " ^
608 " (Try (Rewrite_Set rooteq_simplify False))) e_e " ^
609 " in if ((rhs e_e) is_sqrtTerm_in v_v) " ^
610 " then (SubProblem (RootEq',[normalize,root',univariate,equation], " ^
611 " [no_met]) [BOOL e_e, REAL v_v]) " ^
612 " else ((SubProblem (RootEq',[univariate,equation], " ^
613 " [no_met]) [BOOL e_e, REAL v_v])))"
615 val --------------------------------------------------+++ = "33333";
617 (*-- left 28.08.02 --*)
619 (prep_met thy "met_rooteq_sq_left" [] e_metID
620 (["RootEq","solve_left_sq_root_equation"],
621 [("#Given" ,["equality e_e","solveFor v_v"]),
622 ("#Where" ,["(lhs e_e) is_sqrtTerm_in v_v"]),
623 ("#Find" ,["solutions v_v'i'"])
625 {rew_ord'="termlessI",
630 crls=RootEq_crls, nrls = norm_Poly},
631 "Script Solve_left_sq_root_equation (e_e::bool) (v_v::real) = " ^
633 " ((Try (Rewrite_Set_Inst [(bdv,v_v::real)] l_sqrt_isolate False)) @@ " ^
634 " (Try (Rewrite_Set rooteq_simplify False)) @@ " ^
635 " (Try (Repeat (Rewrite_Set expand_rootbinoms False))) @@ " ^
636 " (Try (Repeat (Rewrite_Set make_rooteq False))) @@ " ^
637 " (Try (Rewrite_Set rooteq_simplify False))) e_e " ^
638 " in if ((lhs e_e) is_sqrtTerm_in v_v) " ^
639 " then (SubProblem (RootEq',[normalize,root',univariate,equation], " ^
640 " [no_met]) [BOOL e_e, REAL v_v]) " ^
641 " else ((SubProblem (RootEq',[univariate,equation], " ^
642 " [no_met]) [BOOL e_e, REAL v_v])))"
644 val --------------------------------------------------++++ = "44444";
646 calclist':= overwritel (!calclist',
647 [("is_rootTerm_in", ("RootEq.is'_rootTerm'_in",
648 eval_is_rootTerm_in"")),
649 ("is_sqrtTerm_in", ("RootEq.is'_sqrtTerm'_in",
650 eval_is_sqrtTerm_in"")),
651 ("is_normSqrtTerm_in", ("RootEq.is_normSqrtTerm_in",
652 eval_is_normSqrtTerm_in""))
653 ]);(*("", ("", "")),*)