neuper@37906
|
1 |
(*.(c) by Richard Lang, 2003 .*)
|
neuper@37906
|
2 |
(* collecting all knowledge for Root Equations
|
neuper@37906
|
3 |
created by: rlang
|
neuper@37906
|
4 |
date: 02.08
|
neuper@37906
|
5 |
changed by: rlang
|
neuper@37906
|
6 |
last change by: rlang
|
neuper@37906
|
7 |
date: 02.11.14
|
neuper@37906
|
8 |
*)
|
neuper@37906
|
9 |
|
s1210629013@55339
|
10 |
theory RootEq imports Root Equation begin
|
neuper@37906
|
11 |
|
wneuper@59472
|
12 |
text \<open>univariate equations containing real square roots:
|
neuper@42398
|
13 |
This type of equations has been used to bootstrap Lucas-Interpretation.
|
neuper@42398
|
14 |
In 2003 this type has been extended and integrated into ISAC's equation solver
|
neuper@42398
|
15 |
by Richard Lang in 2003.
|
neuper@42398
|
16 |
The assumptions (all containing "<") didn't pass the xml-parsers at the
|
neuper@42398
|
17 |
interface between math-engine and front-end.
|
neuper@42398
|
18 |
The migration Isabelle2002 --> 2011 dropped this type of equation, see
|
neuper@42398
|
19 |
test/../rooteq.sml, rootrateq.sml.
|
wneuper@59472
|
20 |
\<close>
|
neuper@42398
|
21 |
|
wneuper@59526
|
22 |
subsection \<open>consts definition for predicates\<close>
|
neuper@37906
|
23 |
consts
|
walther@60278
|
24 |
is_rootTerm_in :: "[real, real] => bool" ("_ is'_rootTerm'_in _")
|
walther@60278
|
25 |
is_sqrtTerm_in :: "[real, real] => bool" ("_ is'_sqrtTerm'_in _")
|
walther@60278
|
26 |
is_normSqrtTerm_in :: "[real, real] => bool" ("_ is'_normSqrtTerm'_in _")
|
neuper@37906
|
27 |
|
wneuper@59526
|
28 |
subsection \<open>theorems not yet adopted from Isabelle\<close>
|
neuper@52148
|
29 |
axiomatization where
|
wneuper@59370
|
30 |
(* normalise *)
|
walther@60242
|
31 |
makex1_x: "a \<up> 1 = a" and
|
neuper@52148
|
32 |
real_assoc_1: "a+(b+c) = a+b+c" and
|
neuper@52148
|
33 |
real_assoc_2: "a*(b*c) = a*b*c" and
|
neuper@37906
|
34 |
|
neuper@37906
|
35 |
(* simplification of root*)
|
walther@60242
|
36 |
sqrt_square_1: "[|0 <= a|] ==> (sqrt a) \<up> 2 = a" and
|
walther@60242
|
37 |
sqrt_square_2: "sqrt (a \<up> 2) = a" and
|
neuper@52148
|
38 |
sqrt_times_root_1: "sqrt a * sqrt b = sqrt(a*b)" and
|
neuper@52148
|
39 |
sqrt_times_root_2: "a * sqrt b * sqrt c = a * sqrt(b*c)" and
|
neuper@37906
|
40 |
|
neuper@37906
|
41 |
(* isolate one root on the LEFT or RIGHT hand side of the equation *)
|
neuper@37983
|
42 |
sqrt_isolate_l_add1: "[|bdv occurs_in c|] ==>
|
neuper@52148
|
43 |
(a + b*sqrt(c) = d) = (b * sqrt(c) = d+ (-1) * a)" and
|
neuper@37983
|
44 |
sqrt_isolate_l_add2: "[|bdv occurs_in c|] ==>
|
neuper@52148
|
45 |
(a + sqrt(c) = d) = ((sqrt(c) = d+ (-1) * a))" and
|
neuper@37983
|
46 |
sqrt_isolate_l_add3: "[|bdv occurs_in c|] ==>
|
neuper@52148
|
47 |
(a + b*(e/sqrt(c)) = d) = (b * (e/sqrt(c)) = d + (-1) * a)" and
|
neuper@37983
|
48 |
sqrt_isolate_l_add4: "[|bdv occurs_in c|] ==>
|
neuper@52148
|
49 |
(a + b/(f*sqrt(c)) = d) = (b / (f*sqrt(c)) = d + (-1) * a)" and
|
neuper@37983
|
50 |
sqrt_isolate_l_add5: "[|bdv occurs_in c|] ==>
|
neuper@52148
|
51 |
(a + b*(e/(f*sqrt(c))) = d) = (b * (e/(f*sqrt(c))) = d+ (-1) * a)" and
|
neuper@37983
|
52 |
sqrt_isolate_l_add6: "[|bdv occurs_in c|] ==>
|
neuper@52148
|
53 |
(a + b/sqrt(c) = d) = (b / sqrt(c) = d+ (-1) * a)" and
|
neuper@37983
|
54 |
sqrt_isolate_r_add1: "[|bdv occurs_in f|] ==>
|
neuper@52148
|
55 |
(a = d + e*sqrt(f)) = (a + (-1) * d = e*sqrt(f))" and
|
neuper@37983
|
56 |
sqrt_isolate_r_add2: "[|bdv occurs_in f|] ==>
|
neuper@52148
|
57 |
(a = d + sqrt(f)) = (a + (-1) * d = sqrt(f))" and
|
wneuper@59370
|
58 |
(* small hack: thm 3,5,6 are not needed if rootnormalise is well done*)
|
neuper@37983
|
59 |
sqrt_isolate_r_add3: "[|bdv occurs_in f|] ==>
|
neuper@52148
|
60 |
(a = d + e*(g/sqrt(f))) = (a + (-1) * d = e*(g/sqrt(f)))" and
|
neuper@37983
|
61 |
sqrt_isolate_r_add4: "[|bdv occurs_in f|] ==>
|
neuper@52148
|
62 |
(a = d + g/sqrt(f)) = (a + (-1) * d = g/sqrt(f))" and
|
neuper@37983
|
63 |
sqrt_isolate_r_add5: "[|bdv occurs_in f|] ==>
|
neuper@52148
|
64 |
(a = d + e*(g/(h*sqrt(f)))) = (a + (-1) * d = e*(g/(h*sqrt(f))))" and
|
neuper@37983
|
65 |
sqrt_isolate_r_add6: "[|bdv occurs_in f|] ==>
|
neuper@52148
|
66 |
(a = d + g/(h*sqrt(f))) = (a + (-1) * d = g/(h*sqrt(f)))" and
|
neuper@37906
|
67 |
|
neuper@37906
|
68 |
(* eliminate isolates sqrt *)
|
neuper@37983
|
69 |
sqrt_square_equation_both_1: "[|bdv occurs_in b; bdv occurs_in d|] ==>
|
neuper@37950
|
70 |
( (sqrt a + sqrt b = sqrt c + sqrt d) =
|
neuper@52148
|
71 |
(a+2*sqrt(a)*sqrt(b)+b = c+2*sqrt(c)*sqrt(d)+d))" and
|
neuper@37983
|
72 |
sqrt_square_equation_both_2: "[|bdv occurs_in b; bdv occurs_in d|] ==>
|
neuper@37950
|
73 |
( (sqrt a - sqrt b = sqrt c + sqrt d) =
|
neuper@52148
|
74 |
(a - 2*sqrt(a)*sqrt(b)+b = c+2*sqrt(c)*sqrt(d)+d))" and
|
neuper@37983
|
75 |
sqrt_square_equation_both_3: "[|bdv occurs_in b; bdv occurs_in d|] ==>
|
neuper@37950
|
76 |
( (sqrt a + sqrt b = sqrt c - sqrt d) =
|
neuper@52148
|
77 |
(a + 2*sqrt(a)*sqrt(b)+b = c - 2*sqrt(c)*sqrt(d)+d))" and
|
neuper@37983
|
78 |
sqrt_square_equation_both_4: "[|bdv occurs_in b; bdv occurs_in d|] ==>
|
neuper@37950
|
79 |
( (sqrt a - sqrt b = sqrt c - sqrt d) =
|
neuper@52148
|
80 |
(a - 2*sqrt(a)*sqrt(b)+b = c - 2*sqrt(c)*sqrt(d)+d))" and
|
neuper@37983
|
81 |
sqrt_square_equation_left_1: "[|bdv occurs_in a; 0 <= a; 0 <= b|] ==>
|
walther@60242
|
82 |
( (sqrt (a) = b) = (a = (b \<up> 2)))" and
|
neuper@37983
|
83 |
sqrt_square_equation_left_2: "[|bdv occurs_in a; 0 <= a; 0 <= b*c|] ==>
|
walther@60242
|
84 |
( (c*sqrt(a) = b) = (c \<up> 2*a = b \<up> 2))" and
|
neuper@37983
|
85 |
sqrt_square_equation_left_3: "[|bdv occurs_in a; 0 <= a; 0 <= b*c|] ==>
|
walther@60242
|
86 |
( c/sqrt(a) = b) = (c \<up> 2 / a = b \<up> 2)" and
|
wneuper@59370
|
87 |
(* small hack: thm 4-6 are not needed if rootnormalise is well done*)
|
neuper@37983
|
88 |
sqrt_square_equation_left_4: "[|bdv occurs_in a; 0 <= a; 0 <= b*c*d|] ==>
|
walther@60242
|
89 |
( (c*(d/sqrt (a)) = b) = (c \<up> 2*(d \<up> 2/a) = b \<up> 2))" and
|
neuper@37983
|
90 |
sqrt_square_equation_left_5: "[|bdv occurs_in a; 0 <= a; 0 <= b*c*d|] ==>
|
walther@60242
|
91 |
( c/(d*sqrt(a)) = b) = (c \<up> 2 / (d \<up> 2*a) = b \<up> 2)" and
|
neuper@37983
|
92 |
sqrt_square_equation_left_6: "[|bdv occurs_in a; 0 <= a; 0 <= b*c*d*e|] ==>
|
walther@60242
|
93 |
( (c*(d/(e*sqrt (a))) = b) = (c \<up> 2*(d \<up> 2/(e \<up> 2*a)) = b \<up> 2))" and
|
neuper@37983
|
94 |
sqrt_square_equation_right_1: "[|bdv occurs_in b; 0 <= a; 0 <= b|] ==>
|
walther@60242
|
95 |
( (a = sqrt (b)) = (a \<up> 2 = b))" and
|
neuper@37983
|
96 |
sqrt_square_equation_right_2: "[|bdv occurs_in b; 0 <= a*c; 0 <= b|] ==>
|
walther@60242
|
97 |
( (a = c*sqrt (b)) = ((a \<up> 2) = c \<up> 2*b))" and
|
neuper@37983
|
98 |
sqrt_square_equation_right_3: "[|bdv occurs_in b; 0 <= a*c; 0 <= b|] ==>
|
walther@60242
|
99 |
( (a = c/sqrt (b)) = (a \<up> 2 = c \<up> 2/b))" and
|
wneuper@59370
|
100 |
(* small hack: thm 4-6 are not needed if rootnormalise is well done*)
|
neuper@37983
|
101 |
sqrt_square_equation_right_4: "[|bdv occurs_in b; 0 <= a*c*d; 0 <= b|] ==>
|
walther@60242
|
102 |
( (a = c*(d/sqrt (b))) = ((a \<up> 2) = c \<up> 2*(d \<up> 2/b)))" and
|
neuper@37983
|
103 |
sqrt_square_equation_right_5: "[|bdv occurs_in b; 0 <= a*c*d; 0 <= b|] ==>
|
walther@60242
|
104 |
( (a = c/(d*sqrt (b))) = (a \<up> 2 = c \<up> 2/(d \<up> 2*b)))" and
|
neuper@37983
|
105 |
sqrt_square_equation_right_6: "[|bdv occurs_in b; 0 <= a*c*d*e; 0 <= b|] ==>
|
walther@60242
|
106 |
( (a = c*(d/(e*sqrt (b)))) = ((a \<up> 2) = c \<up> 2*(d \<up> 2/(e \<up> 2*b))))"
|
neuper@37950
|
107 |
|
wneuper@59526
|
108 |
subsection \<open>predicates\<close>
|
wneuper@59472
|
109 |
ML \<open>
|
neuper@37950
|
110 |
(* true if bdv is under sqrt of a Equation*)
|
neuper@37950
|
111 |
fun is_rootTerm_in t v =
|
wneuper@59525
|
112 |
let
|
wneuper@59526
|
113 |
fun findroot (t as (_ $ _ $ _ $ _)) _ = raise TERM ( "is_rootTerm_in", [t])
|
neuper@37950
|
114 |
(* at the moment there is no term like this, but ....*)
|
walther@60335
|
115 |
| findroot (Const (\<^const_name>\<open>nroot\<close>, _) $ _ $ t3) v = Prog_Expr.occurs_in v t3
|
wneuper@59526
|
116 |
| findroot (_ $ t2 $ t3) v = findroot t2 v orelse findroot t3 v
|
wenzelm@60309
|
117 |
| findroot (Const (\<^const_name>\<open>sqrt\<close>, _) $ t2) v = Prog_Expr.occurs_in v t2
|
wneuper@59526
|
118 |
| findroot (_ $ t2) v = findroot t2 v
|
neuper@37950
|
119 |
| findroot _ _ = false;
|
wneuper@59526
|
120 |
in
|
wneuper@59526
|
121 |
findroot t v
|
wneuper@59526
|
122 |
end;
|
neuper@37950
|
123 |
|
wneuper@59526
|
124 |
fun is_sqrtTerm_in t v =
|
wneuper@59526
|
125 |
let
|
wneuper@59526
|
126 |
fun findsqrt (t as (_ $ _ $ _ $ _)) _ = raise TERM ("is_sqrteqation_in", [t])
|
wneuper@59526
|
127 |
(* at the moment there is no term like this, but ....*)
|
wneuper@59526
|
128 |
| findsqrt (_ $ t1 $ t2) v = (findsqrt t1 v) orelse (findsqrt t2 v)
|
wenzelm@60309
|
129 |
| findsqrt (Const (\<^const_name>\<open>sqrt\<close>, _) $ a) v = Prog_Expr.occurs_in v a
|
wneuper@59526
|
130 |
| findsqrt (_ $ t1) v = findsqrt t1 v
|
wneuper@59526
|
131 |
| findsqrt _ _ = false;
|
wneuper@59526
|
132 |
in
|
wneuper@59526
|
133 |
findsqrt t v
|
wneuper@59526
|
134 |
end;
|
neuper@37950
|
135 |
|
neuper@37950
|
136 |
(* RL: 030518: Is in the rightest subterm of a term a sqrt with bdv,
|
wneuper@59370
|
137 |
and the subterm ist connected with + or * --> is normalised*)
|
wneuper@59526
|
138 |
fun is_normSqrtTerm_in t v =
|
wneuper@59526
|
139 |
let
|
wneuper@59526
|
140 |
fun isnorm (t as (_ $ _ $ _ $ _)) _ = raise TERM ("is_normSqrtTerm_in", [t])
|
wneuper@59526
|
141 |
(* at the moment there is no term like this, but ....*)
|
wenzelm@60309
|
142 |
| isnorm (Const (\<^const_name>\<open>plus\<close>,_) $ _ $ t2) v = is_sqrtTerm_in t2 v
|
wenzelm@60309
|
143 |
| isnorm (Const (\<^const_name>\<open>times\<close>,_) $ _ $ t2) v = is_sqrtTerm_in t2 v
|
wenzelm@60309
|
144 |
| isnorm (Const (\<^const_name>\<open>minus\<close>,_) $ _ $ _) _ = false
|
wenzelm@60309
|
145 |
| isnorm (Const (\<^const_name>\<open>divide\<close>,_) $ t1 $ t2) v =
|
wneuper@59526
|
146 |
is_sqrtTerm_in t1 v orelse is_sqrtTerm_in t2 v
|
wenzelm@60309
|
147 |
| isnorm (Const (\<^const_name>\<open>sqrt\<close>, _) $ t1) v = Prog_Expr.occurs_in v t1
|
wneuper@59526
|
148 |
| isnorm (_ $ t1) v = is_sqrtTerm_in t1 v
|
wneuper@59526
|
149 |
| isnorm _ _ = false;
|
wneuper@59526
|
150 |
in
|
wneuper@59526
|
151 |
isnorm t v
|
wneuper@59526
|
152 |
end;
|
neuper@37950
|
153 |
|
walther@60335
|
154 |
fun eval_is_rootTerm_in _ _ (p as (Const (\<^const_name>\<open>RootEq.is_rootTerm_in\<close>,_) $ t $ v)) _ =
|
wneuper@59526
|
155 |
if is_rootTerm_in t v
|
walther@59868
|
156 |
then SOME ((UnparseC.term p) ^ " = True", HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
|
walther@59868
|
157 |
else SOME ((UnparseC.term p) ^ " = True", HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
|
neuper@38015
|
158 |
| eval_is_rootTerm_in _ _ _ _ = ((*tracing"### nichts matcht";*) NONE);
|
neuper@37950
|
159 |
|
walther@60335
|
160 |
fun eval_is_sqrtTerm_in _ _ (p as (Const (\<^const_name>\<open>is_sqrtTerm_in\<close>,_) $ t $ v)) _ =
|
wneuper@59526
|
161 |
if is_sqrtTerm_in t v
|
walther@59868
|
162 |
then SOME ((UnparseC.term p) ^ " = True", HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
|
walther@59868
|
163 |
else SOME ((UnparseC.term p) ^ " = True", HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
|
neuper@38015
|
164 |
| eval_is_sqrtTerm_in _ _ _ _ = ((*tracing"### nichts matcht";*) NONE);
|
neuper@37950
|
165 |
|
walther@60335
|
166 |
fun eval_is_normSqrtTerm_in _ _ (p as (Const (\<^const_name>\<open>is_normSqrtTerm_in\<close>,_) $ t $ v)) _ =
|
wneuper@59526
|
167 |
if is_normSqrtTerm_in t v
|
walther@59868
|
168 |
then SOME ((UnparseC.term p) ^ " = True", HOLogic.Trueprop $ (TermC.mk_equality (p, @{term True})))
|
walther@59868
|
169 |
else SOME ((UnparseC.term p) ^ " = True", HOLogic.Trueprop $ (TermC.mk_equality (p, @{term False})))
|
neuper@38015
|
170 |
| eval_is_normSqrtTerm_in _ _ _ _ = ((*tracing"### nichts matcht";*) NONE);
|
wneuper@59526
|
171 |
\<close>
|
wenzelm@60313
|
172 |
calculation is_rootTerm_in = \<open>eval_is_rootTerm_in ""\<close>
|
wenzelm@60313
|
173 |
calculation is_sqrtTerm_in = \<open>eval_is_sqrtTerm_in ""\<close>
|
wenzelm@60313
|
174 |
calculation is_normSqrtTerm_in = \<open>eval_is_normSqrtTerm_in ""\<close>
|
neuper@37950
|
175 |
|
wneuper@59526
|
176 |
subsection \<open>rule-sets\<close>
|
wneuper@59526
|
177 |
ML \<open>
|
neuper@37950
|
178 |
val RootEq_prls =(*15.10.02:just the following order due to subterm evaluation*)
|
walther@60358
|
179 |
Rule_Set.append_rules "RootEq_prls" Rule_Set.empty [
|
walther@60358
|
180 |
\<^rule_eval>\<open>Prog_Expr.ident\<close> (Prog_Expr.eval_ident "#ident_"),
|
walther@60358
|
181 |
\<^rule_eval>\<open>Prog_Expr.matches\<close> (Prog_Expr.eval_matches ""),
|
walther@60358
|
182 |
\<^rule_eval>\<open>Prog_Expr.lhs\<close> (Prog_Expr.eval_lhs ""),
|
walther@60358
|
183 |
\<^rule_eval>\<open>Prog_Expr.rhs\<close> (Prog_Expr.eval_rhs ""),
|
walther@60358
|
184 |
\<^rule_eval>\<open>is_sqrtTerm_in\<close> (eval_is_sqrtTerm_in ""),
|
walther@60358
|
185 |
\<^rule_eval>\<open>is_rootTerm_in\<close> (eval_is_rootTerm_in ""),
|
walther@60358
|
186 |
\<^rule_eval>\<open>is_normSqrtTerm_in\<close> (eval_is_normSqrtTerm_in ""),
|
walther@60358
|
187 |
\<^rule_eval>\<open>HOL.eq\<close> (Prog_Expr.eval_equal "#equal_"),
|
walther@60358
|
188 |
\<^rule_thm>\<open>not_true\<close>,
|
walther@60358
|
189 |
\<^rule_thm>\<open>not_false\<close>,
|
walther@60358
|
190 |
\<^rule_thm>\<open>and_true\<close>,
|
walther@60358
|
191 |
\<^rule_thm>\<open>and_false\<close>,
|
walther@60358
|
192 |
\<^rule_thm>\<open>or_true\<close>,
|
walther@60358
|
193 |
\<^rule_thm>\<open>or_false\<close>];
|
neuper@37950
|
194 |
|
neuper@37950
|
195 |
val RootEq_erls =
|
walther@59852
|
196 |
Rule_Set.append_rules "RootEq_erls" Root_erls
|
wenzelm@60297
|
197 |
[\<^rule_thm>\<open>divide_divide_eq_left\<close>];
|
neuper@37950
|
198 |
|
neuper@37950
|
199 |
val RootEq_crls =
|
walther@59852
|
200 |
Rule_Set.append_rules "RootEq_crls" Root_crls
|
wenzelm@60297
|
201 |
[\<^rule_thm>\<open>divide_divide_eq_left\<close>];
|
neuper@37950
|
202 |
|
neuper@37950
|
203 |
val rooteq_srls =
|
walther@60358
|
204 |
Rule_Set.append_rules "rooteq_srls" Rule_Set.empty [
|
walther@60358
|
205 |
\<^rule_eval>\<open>is_sqrtTerm_in\<close> (eval_is_sqrtTerm_in ""),
|
wenzelm@60294
|
206 |
\<^rule_eval>\<open>is_normSqrtTerm_in\<close> (eval_is_normSqrtTerm_in""),
|
wenzelm@60294
|
207 |
\<^rule_eval>\<open>is_rootTerm_in\<close> (eval_is_rootTerm_in "")];
|
wneuper@59472
|
208 |
\<close>
|
wneuper@59472
|
209 |
ML \<open>
|
neuper@37950
|
210 |
|
neuper@37950
|
211 |
(*isolate the bound variable in an sqrt equation; 'bdv' is a meta-constant*)
|
s1210629013@55444
|
212 |
val sqrt_isolate = prep_rls'(
|
walther@60358
|
213 |
Rule_Def.Repeat {
|
walther@60358
|
214 |
id = "sqrt_isolate", preconds = [], rew_ord = ("termlessI",termlessI),
|
Walther@60586
|
215 |
asm_rls = RootEq_erls, prog_rls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@60358
|
216 |
rules = [
|
walther@60358
|
217 |
\<^rule_thm>\<open>sqrt_square_1\<close>, (* (sqrt a) \<up> 2 -> a *)
|
walther@60358
|
218 |
\<^rule_thm>\<open>sqrt_square_2\<close>, (* sqrt (a \<up> 2) -> a *)
|
walther@60358
|
219 |
\<^rule_thm>\<open>sqrt_times_root_1\<close>, (* sqrt a sqrt b -> sqrt(ab) *)
|
walther@60358
|
220 |
\<^rule_thm>\<open>sqrt_times_root_2\<close>, (* a sqrt b sqrt c -> a sqrt(bc) *)
|
walther@60358
|
221 |
\<^rule_thm>\<open>sqrt_square_equation_both_1\<close>, (* (sqrt a + sqrt b = sqrt c + sqrt d) ->
|
walther@60358
|
222 |
(a+2*sqrt(a)*sqrt(b)+b) = c+2*sqrt(c)*sqrt(d)+d) *)
|
walther@60358
|
223 |
\<^rule_thm>\<open>sqrt_square_equation_both_2\<close>, (* (sqrt a - sqrt b = sqrt c + sqrt d) ->
|
walther@60358
|
224 |
(a-2*sqrt(a)*sqrt(b)+b) = c+2*sqrt(c)*sqrt(d)+d) *)
|
walther@60358
|
225 |
\<^rule_thm>\<open>sqrt_square_equation_both_3\<close>, (* (sqrt a + sqrt b = sqrt c - sqrt d) ->
|
walther@60358
|
226 |
(a+2*sqrt(a)*sqrt(b)+b) = c-2*sqrt(c)*sqrt(d)+d) *)
|
walther@60358
|
227 |
\<^rule_thm>\<open>sqrt_square_equation_both_4\<close>, (* (sqrt a - sqrt b = sqrt c - sqrt d) ->
|
walther@60358
|
228 |
(a-2*sqrt(a)*sqrt(b)+b) = c-2*sqrt(c)*sqrt(d)+d) *)
|
walther@60358
|
229 |
\<^rule_thm>\<open>sqrt_isolate_l_add1\<close>, (* a+b*sqrt(x)=d -> b*sqrt(x) = d-a *)
|
walther@60358
|
230 |
\<^rule_thm>\<open>sqrt_isolate_l_add2\<close>, (* a+ sqrt(x)=d -> sqrt(x) = d-a *)
|
walther@60358
|
231 |
\<^rule_thm>\<open>sqrt_isolate_l_add3\<close>, (* a+b*c/sqrt(x)=d->b*c/sqrt(x)=d-a *)
|
walther@60358
|
232 |
\<^rule_thm>\<open>sqrt_isolate_l_add4\<close>, (* a+c/sqrt(x)=d -> c/sqrt(x) = d-a *)
|
walther@60358
|
233 |
\<^rule_thm>\<open>sqrt_isolate_l_add5\<close>, (* a+b*c/f*sqrt(x)=d->b*c/f*sqrt(x)=d-a *)
|
walther@60358
|
234 |
\<^rule_thm>\<open>sqrt_isolate_l_add6\<close>, (* a+c/f*sqrt(x)=d -> c/f*sqrt(x) = d-a *)
|
walther@60358
|
235 |
(*
|
walther@60358
|
236 |
\<^rule_thm>\<open>sqrt_isolate_l_div\<close>, (* b*sqrt(x) = d sqrt(x) d/b *)*)
|
walther@60358
|
237 |
\<^rule_thm>\<open>sqrt_isolate_r_add1\<close>, (* a= d+e*sqrt(x) -> a-d=e*sqrt(x) *)
|
walther@60358
|
238 |
\<^rule_thm>\<open>sqrt_isolate_r_add2\<close>, (* a= d+ sqrt(x) -> a-d= sqrt(x) *)
|
walther@60358
|
239 |
\<^rule_thm>\<open>sqrt_isolate_r_add3\<close>, (* a=d+e*g/sqrt(x)->a-d=e*g/sqrt(x)*)
|
walther@60358
|
240 |
\<^rule_thm>\<open>sqrt_isolate_r_add4\<close>, (* a= d+g/sqrt(x) -> a-d=g/sqrt(x) *)
|
walther@60358
|
241 |
\<^rule_thm>\<open>sqrt_isolate_r_add5\<close>, (* a=d+e*g/h*sqrt(x)->a-d=e*g/h*sqrt(x)*)
|
walther@60358
|
242 |
\<^rule_thm>\<open>sqrt_isolate_r_add6\<close>, (* a= d+g/h*sqrt(x) -> a-d=g/h*sqrt(x) *)
|
walther@60358
|
243 |
(*
|
walther@60358
|
244 |
\<^rule_thm>\<open>sqrt_isolate_r_div\<close>, (* a=e*sqrt(x) -> a/e = sqrt(x) *)*)
|
walther@60358
|
245 |
\<^rule_thm>\<open>sqrt_square_equation_left_1\<close>, (* sqrt(x)=b -> x=b^2 *)
|
walther@60358
|
246 |
\<^rule_thm>\<open>sqrt_square_equation_left_2\<close>, (* c*sqrt(x)=b -> c^2*x=b^2 *)
|
walther@60358
|
247 |
\<^rule_thm>\<open>sqrt_square_equation_left_3\<close>, (* c/sqrt(x)=b -> c^2/x=b^2 *)
|
walther@60358
|
248 |
\<^rule_thm>\<open>sqrt_square_equation_left_4\<close>, (* c*d/sqrt(x)=b -> c^2*d^2/x=b^2 *)
|
walther@60358
|
249 |
\<^rule_thm>\<open>sqrt_square_equation_left_5\<close>, (* c/d*sqrt(x)=b -> c^2/d^2x=b^2 *)
|
walther@60358
|
250 |
\<^rule_thm>\<open>sqrt_square_equation_left_6\<close>, (* c*d/g*sqrt(x)=b -> c^2*d^2/g^2x=b^2 *)
|
walther@60358
|
251 |
\<^rule_thm>\<open>sqrt_square_equation_right_1\<close>, (* a=sqrt(x) ->a^2=x *)
|
walther@60358
|
252 |
\<^rule_thm>\<open>sqrt_square_equation_right_2\<close>, (* a=c*sqrt(x) ->a^2=c^2*x *)
|
walther@60358
|
253 |
\<^rule_thm>\<open>sqrt_square_equation_right_3\<close>, (* a=c/sqrt(x) ->a^2=c^2/x *)
|
walther@60358
|
254 |
\<^rule_thm>\<open>sqrt_square_equation_right_4\<close>, (* a=c*d/sqrt(x) ->a^2=c^2*d^2/x *)
|
walther@60358
|
255 |
\<^rule_thm>\<open>sqrt_square_equation_right_5\<close>, (* a=c/e*sqrt(x) ->a^2=c^2/e^2x *)
|
walther@60358
|
256 |
\<^rule_thm>\<open>sqrt_square_equation_right_6\<close>], (* a=c*d/g*sqrt(x) ->a^2=c^2*d^2/g^2*x *)
|
Walther@60586
|
257 |
program = Rule.Empty_Prog});
|
neuper@52125
|
258 |
|
wneuper@59526
|
259 |
\<close> ML \<open>
|
neuper@37950
|
260 |
(*isolate the bound variable in an sqrt left equation; 'bdv' is a meta-constant*)
|
walther@60358
|
261 |
val l_sqrt_isolate = prep_rls'(
|
walther@60358
|
262 |
Rule_Def.Repeat {
|
walther@60358
|
263 |
id = "l_sqrt_isolate", preconds = [], rew_ord = ("termlessI",termlessI),
|
Walther@60586
|
264 |
asm_rls = RootEq_erls, prog_rls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@60358
|
265 |
rules = [
|
walther@60358
|
266 |
\<^rule_thm>\<open>sqrt_square_1\<close>, (* (sqrt a) \<up> 2 -> a *)
|
walther@60358
|
267 |
\<^rule_thm>\<open>sqrt_square_2\<close>, (* sqrt (a \<up> 2) -> a *)
|
walther@60358
|
268 |
\<^rule_thm>\<open>sqrt_times_root_1\<close>, (* sqrt a sqrt b -> sqrt(ab) *)
|
walther@60358
|
269 |
\<^rule_thm>\<open>sqrt_times_root_2\<close>, (* a sqrt b sqrt c -> a sqrt(bc) *)
|
walther@60358
|
270 |
\<^rule_thm>\<open>sqrt_isolate_l_add1\<close>, (* a+b*sqrt(x)=d -> b*sqrt(x) = d-a *)
|
walther@60358
|
271 |
\<^rule_thm>\<open>sqrt_isolate_l_add2\<close>, (* a+ sqrt(x)=d -> sqrt(x) = d-a *)
|
walther@60358
|
272 |
\<^rule_thm>\<open>sqrt_isolate_l_add3\<close>, (* a+b*c/sqrt(x)=d->b*c/sqrt(x)=d-a *)
|
walther@60358
|
273 |
\<^rule_thm>\<open>sqrt_isolate_l_add4\<close>, (* a+c/sqrt(x)=d -> c/sqrt(x) = d-a *)
|
walther@60358
|
274 |
\<^rule_thm>\<open>sqrt_isolate_l_add5\<close>, (* a+b*c/f*sqrt(x)=d->b*c/f*sqrt(x)=d-a *)
|
walther@60358
|
275 |
\<^rule_thm>\<open>sqrt_isolate_l_add6\<close>, (* a+c/f*sqrt(x)=d -> c/f*sqrt(x) = d-a *)
|
walther@60358
|
276 |
(*
|
walther@60358
|
277 |
\<^rule_thm>\<open>sqrt_isolate_l_div\<close>, (* b*sqrt(x) = d sqrt(x) d/b *)*)
|
walther@60358
|
278 |
\<^rule_thm>\<open>sqrt_square_equation_left_1\<close>, (* sqrt(x)=b -> x=b^2 *)
|
walther@60358
|
279 |
\<^rule_thm>\<open>sqrt_square_equation_left_2\<close>, (* a*sqrt(x)=b -> a^2*x=b^2*)
|
walther@60358
|
280 |
\<^rule_thm>\<open>sqrt_square_equation_left_3\<close>, (* c/sqrt(x)=b -> c^2/x=b^2 *)
|
walther@60358
|
281 |
\<^rule_thm>\<open>sqrt_square_equation_left_4\<close>, (* c*d/sqrt(x)=b -> c^2*d^2/x=b^2 *)
|
walther@60358
|
282 |
\<^rule_thm>\<open>sqrt_square_equation_left_5\<close>, (* c/d*sqrt(x)=b -> c^2/d^2x=b^2 *)
|
walther@60358
|
283 |
\<^rule_thm>\<open>sqrt_square_equation_left_6\<close>], (* c*d/g*sqrt(x)=b -> c^2*d^2/g^2x=b^2 *)
|
Walther@60586
|
284 |
program = Rule.Empty_Prog});
|
neuper@37950
|
285 |
|
wneuper@59526
|
286 |
\<close> ML \<open>
|
neuper@37950
|
287 |
(* -- right 28.8.02--*)
|
neuper@37950
|
288 |
(*isolate the bound variable in an sqrt right equation; 'bdv' is a meta-constant*)
|
walther@60358
|
289 |
val r_sqrt_isolate = prep_rls'(
|
walther@60358
|
290 |
Rule_Def.Repeat {id = "r_sqrt_isolate", preconds = [], rew_ord = ("termlessI",termlessI),
|
Walther@60586
|
291 |
asm_rls = RootEq_erls, prog_rls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@60358
|
292 |
rules = [
|
walther@60358
|
293 |
\<^rule_thm>\<open>sqrt_square_1\<close>, (* (sqrt a) \<up> 2 -> a *)
|
walther@60358
|
294 |
\<^rule_thm>\<open>sqrt_square_2\<close>, (* sqrt (a \<up> 2) -> a *)
|
walther@60358
|
295 |
\<^rule_thm>\<open>sqrt_times_root_1\<close>, (* sqrt a sqrt b -> sqrt(ab) *)
|
walther@60358
|
296 |
\<^rule_thm>\<open>sqrt_times_root_2\<close>, (* a sqrt b sqrt c -> a sqrt(bc) *)
|
walther@60358
|
297 |
\<^rule_thm>\<open>sqrt_isolate_r_add1\<close>, (* a= d+e*sqrt(x) -> a-d=e*sqrt(x) *)
|
walther@60358
|
298 |
\<^rule_thm>\<open>sqrt_isolate_r_add2\<close>, (* a= d+ sqrt(x) -> a-d= sqrt(x) *)
|
walther@60358
|
299 |
\<^rule_thm>\<open>sqrt_isolate_r_add3\<close>, (* a=d+e*g/sqrt(x)->a-d=e*g/sqrt(x)*)
|
walther@60358
|
300 |
\<^rule_thm>\<open>sqrt_isolate_r_add4\<close>, (* a= d+g/sqrt(x) -> a-d=g/sqrt(x) *)
|
walther@60358
|
301 |
\<^rule_thm>\<open>sqrt_isolate_r_add5\<close>, (* a=d+e*g/h*sqrt(x)->a-d=e*g/h*sqrt(x)*)
|
walther@60358
|
302 |
\<^rule_thm>\<open>sqrt_isolate_r_add6\<close>, (* a= d+g/h*sqrt(x) -> a-d=g/h*sqrt(x) *)
|
walther@60358
|
303 |
(*
|
walther@60358
|
304 |
\<^rule_thm>\<open>sqrt_isolate_r_div\<close>, (* a=e*sqrt(x) -> a/e = sqrt(x) *)*)
|
walther@60358
|
305 |
\<^rule_thm>\<open>sqrt_square_equation_right_1\<close>, (* a=sqrt(x) ->a^2=x *)
|
walther@60358
|
306 |
\<^rule_thm>\<open>sqrt_square_equation_right_2\<close>, (* a=c*sqrt(x) ->a^2=c^2*x *)
|
walther@60358
|
307 |
\<^rule_thm>\<open>sqrt_square_equation_right_3\<close>, (* a=c/sqrt(x) ->a^2=c^2/x *)
|
walther@60358
|
308 |
\<^rule_thm>\<open>sqrt_square_equation_right_4\<close>, (* a=c*d/sqrt(x) ->a^2=c^2*d^2/x *)
|
walther@60358
|
309 |
\<^rule_thm>\<open>sqrt_square_equation_right_5\<close>, (* a=c/e*sqrt(x) ->a^2=c^2/e^2x *)
|
walther@60358
|
310 |
\<^rule_thm>\<open>sqrt_square_equation_right_6\<close>], (* a=c*d/g*sqrt(x) ->a^2=c^2*d^2/g^2*x *)
|
Walther@60586
|
311 |
program = Rule.Empty_Prog});
|
neuper@37950
|
312 |
|
wneuper@59526
|
313 |
\<close> ML \<open>
|
s1210629013@55444
|
314 |
val rooteq_simplify = prep_rls'(
|
walther@60358
|
315 |
Rule_Def.Repeat {
|
walther@60358
|
316 |
id = "rooteq_simplify", preconds = [], rew_ord = ("termlessI",termlessI),
|
Walther@60586
|
317 |
asm_rls = RootEq_erls, prog_rls = Rule_Set.Empty, calc = [], errpatts = [],
|
walther@60358
|
318 |
rules = [
|
walther@60358
|
319 |
\<^rule_thm>\<open>real_assoc_1\<close>, (* a+(b+c) = a+b+c *)
|
walther@60358
|
320 |
\<^rule_thm>\<open>real_assoc_2\<close>, (* a*(b*c) = a*b*c *)
|
Walther@60515
|
321 |
\<^rule_eval>\<open>plus\<close> (**)(Calc_Binop.numeric "#add_"),
|
Walther@60515
|
322 |
\<^rule_eval>\<open>minus\<close> (**)(Calc_Binop.numeric "#sub_"),
|
Walther@60515
|
323 |
\<^rule_eval>\<open>times\<close> (**)(Calc_Binop.numeric "#mult_"),
|
walther@60358
|
324 |
\<^rule_eval>\<open>divide\<close> (Prog_Expr.eval_cancel "#divide_e"),
|
walther@60358
|
325 |
\<^rule_eval>\<open>sqrt\<close> (eval_sqrt "#sqrt_"),
|
Walther@60515
|
326 |
\<^rule_eval>\<open>realpow\<close> (**)(Calc_Binop.numeric "#power_"),
|
walther@60358
|
327 |
\<^rule_thm>\<open>real_plus_binom_pow2\<close>,
|
walther@60358
|
328 |
\<^rule_thm>\<open>real_minus_binom_pow2\<close>,
|
walther@60358
|
329 |
\<^rule_thm>\<open>realpow_mul\<close>, (* (a * b)^n = a^n * b^n*)
|
walther@60358
|
330 |
\<^rule_thm>\<open>sqrt_times_root_1\<close>, (* sqrt b * sqrt c = sqrt(b*c) *)
|
walther@60358
|
331 |
\<^rule_thm>\<open>sqrt_times_root_2\<close>, (* a * sqrt a * sqrt b = a * sqrt(a*b) *)
|
walther@60358
|
332 |
\<^rule_thm>\<open>sqrt_square_2\<close>, (* sqrt (a \<up> 2) = a *)
|
walther@60358
|
333 |
\<^rule_thm>\<open>sqrt_square_1\<close>], (* sqrt a \<up> 2 = a *)
|
Walther@60586
|
334 |
program = Rule.Empty_Prog});
|
wneuper@59472
|
335 |
\<close>
|
wenzelm@60289
|
336 |
rule_set_knowledge
|
wenzelm@60286
|
337 |
RootEq_erls = RootEq_erls and
|
wenzelm@60286
|
338 |
rooteq_srls = rooteq_srls and
|
wenzelm@60286
|
339 |
sqrt_isolate = sqrt_isolate and
|
wenzelm@60286
|
340 |
l_sqrt_isolate = l_sqrt_isolate and
|
wenzelm@60286
|
341 |
r_sqrt_isolate = r_sqrt_isolate and
|
wenzelm@60286
|
342 |
rooteq_simplify = rooteq_simplify
|
wneuper@59526
|
343 |
|
wneuper@59526
|
344 |
subsection \<open>problems\<close>
|
wenzelm@60306
|
345 |
|
wenzelm@60306
|
346 |
problem pbl_equ_univ_root : "rootX/univariate/equation" =
|
wenzelm@60306
|
347 |
\<open>RootEq_prls\<close>
|
wenzelm@60306
|
348 |
CAS: "solve (e_e::bool, v_v)"
|
wenzelm@60306
|
349 |
Given: "equality e_e" "solveFor v_v"
|
wenzelm@60306
|
350 |
Where:
|
wenzelm@60306
|
351 |
(*Ambiguous input produces 5 parse trees -----------------------------------------------------\\*)
|
wenzelm@60306
|
352 |
"(lhs e_e) is_rootTerm_in (v_v::real) |
|
wenzelm@60306
|
353 |
(rhs e_e) is_rootTerm_in (v_v::real)"
|
wenzelm@60306
|
354 |
Find: "solutions v_v'i'"
|
wenzelm@60306
|
355 |
|
wenzelm@60306
|
356 |
problem pbl_equ_univ_root_sq : "sq/rootX/univariate/equation" =
|
wenzelm@60306
|
357 |
\<open>RootEq_prls\<close>
|
Walther@60449
|
358 |
Method_Ref: "RootEq/solve_sq_root_equation"
|
wenzelm@60306
|
359 |
CAS: "solve (e_e::bool, v_v)"
|
wenzelm@60306
|
360 |
Given: "equality e_e" "solveFor v_v"
|
wenzelm@60306
|
361 |
Where:
|
wenzelm@60306
|
362 |
"( ((lhs e_e) is_sqrtTerm_in (v_v::real)) &
|
wenzelm@60306
|
363 |
((lhs e_e) is_normSqrtTerm_in (v_v::real)) ) |
|
wenzelm@60306
|
364 |
( ((rhs e_e) is_sqrtTerm_in (v_v::real)) &
|
wenzelm@60306
|
365 |
((rhs e_e) is_normSqrtTerm_in (v_v::real)) )"
|
wenzelm@60306
|
366 |
Find: "solutions v_v'i'"
|
wenzelm@60306
|
367 |
|
wenzelm@60306
|
368 |
(* ---------normalise----------- *)
|
wenzelm@60306
|
369 |
problem pbl_equ_univ_root_norm : "normalise/rootX/univariate/equation" =
|
wenzelm@60306
|
370 |
\<open>RootEq_prls\<close>
|
Walther@60449
|
371 |
Method_Ref: "RootEq/norm_sq_root_equation"
|
wenzelm@60306
|
372 |
CAS: "solve (e_e::bool, v_v)"
|
wenzelm@60306
|
373 |
Given: "equality e_e" "solveFor v_v"
|
wenzelm@60306
|
374 |
Where:
|
wenzelm@60306
|
375 |
"( ((lhs e_e) is_sqrtTerm_in (v_v::real)) &
|
wenzelm@60306
|
376 |
Not((lhs e_e) is_normSqrtTerm_in (v_v::real))) |
|
wenzelm@60306
|
377 |
( ((rhs e_e) is_sqrtTerm_in (v_v::real)) &
|
wenzelm@60306
|
378 |
Not((rhs e_e) is_normSqrtTerm_in (v_v::real)))"
|
wenzelm@60306
|
379 |
Find: "solutions v_v'i'"
|
neuper@37950
|
380 |
|
wneuper@59526
|
381 |
subsection \<open>methods\<close>
|
wenzelm@60303
|
382 |
|
wenzelm@60303
|
383 |
method met_rooteq : "RootEq" =
|
Walther@60586
|
384 |
\<open>{rew_ord="tless_true",rls'=Atools_erls,calc = [], prog_rls = Rule_Set.empty, where_rls=Rule_Set.empty,
|
Walther@60587
|
385 |
errpats = [], rew_rls = norm_Poly}\<close>
|
wenzelm@60303
|
386 |
|
wneuper@59370
|
387 |
(*-- normalise 20.10.02 --*)
|
wneuper@59504
|
388 |
partial_function (tailrec) norm_sqrt_equ :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
wneuper@59504
|
389 |
where
|
walther@59635
|
390 |
"norm_sqrt_equ e_e v_v = (
|
walther@59635
|
391 |
let
|
walther@59635
|
392 |
e_e = (
|
walther@59637
|
393 |
(Repeat(Try (Rewrite ''makex1_x''))) #>
|
walther@59637
|
394 |
(Try (Repeat (Rewrite_Set ''expand_rootbinoms''))) #>
|
walther@59637
|
395 |
(Try (Rewrite_Set ''rooteq_simplify'')) #>
|
walther@59637
|
396 |
(Try (Repeat (Rewrite_Set ''make_rooteq''))) #>
|
walther@59635
|
397 |
(Try (Rewrite_Set ''rooteq_simplify''))
|
walther@59635
|
398 |
) e_e
|
walther@59635
|
399 |
in
|
walther@59635
|
400 |
SubProblem (''RootEq'', [''univariate'', ''equation''], [''no_met''])
|
walther@59635
|
401 |
[BOOL e_e, REAL v_v])"
|
wenzelm@60303
|
402 |
|
wenzelm@60303
|
403 |
method met_rooteq_norm : "RootEq/norm_sq_root_equation" =
|
Walther@60587
|
404 |
\<open>{rew_ord="termlessI", rls'=RootEq_erls, prog_rls=Rule_Set.empty, where_rls=RootEq_prls, calc =[],
|
Walther@60587
|
405 |
errpats = [], rew_rls = norm_Poly}\<close>
|
wenzelm@60303
|
406 |
Program: norm_sqrt_equ.simps
|
wenzelm@60303
|
407 |
Given: "equality e_e" "solveFor v_v"
|
wenzelm@60303
|
408 |
Where: "( ((lhs e_e) is_sqrtTerm_in (v_v::real)) &
|
wenzelm@60303
|
409 |
Not((lhs e_e) is_normSqrtTerm_in (v_v::real))) |
|
wenzelm@60303
|
410 |
( ((rhs e_e) is_sqrtTerm_in (v_v::real)) &
|
wenzelm@60303
|
411 |
Not((rhs e_e) is_normSqrtTerm_in (v_v::real)))"
|
wenzelm@60303
|
412 |
Find: "solutions v_v'i'"
|
wneuper@59545
|
413 |
|
wneuper@59504
|
414 |
partial_function (tailrec) solve_sqrt_equ :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
wneuper@59504
|
415 |
where
|
wneuper@59504
|
416 |
"solve_sqrt_equ e_e v_v =
|
wneuper@59504
|
417 |
(let
|
walther@59635
|
418 |
e_e = (
|
walther@59637
|
419 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''sqrt_isolate'')) #>
|
walther@59637
|
420 |
(Try (Rewrite_Set ''rooteq_simplify'')) #>
|
walther@59637
|
421 |
(Try (Repeat (Rewrite_Set ''expand_rootbinoms''))) #>
|
walther@59803
|
422 |
(Try (Repeat (Rewrite_Set ''make_rooteq''))) #>
|
walther@59635
|
423 |
(Try (Rewrite_Set ''rooteq_simplify'')) ) e_e;
|
wneuper@59504
|
424 |
L_L =
|
wneuper@59504
|
425 |
(if (((lhs e_e) is_sqrtTerm_in v_v) | ((rhs e_e) is_sqrtTerm_in v_v))
|
walther@59635
|
426 |
then
|
walther@59635
|
427 |
SubProblem (''RootEq'', [''normalise'', ''rootX'', ''univariate'', ''equation''], [''no_met''])
|
walther@59635
|
428 |
[BOOL e_e, REAL v_v]
|
walther@59635
|
429 |
else
|
walther@59635
|
430 |
SubProblem (''RootEq'',[''univariate'',''equation''], [''no_met''])
|
walther@59635
|
431 |
[BOOL e_e, REAL v_v])
|
wneuper@59504
|
432 |
in Check_elementwise L_L {(v_v::real). Assumptions})"
|
wenzelm@60303
|
433 |
|
wenzelm@60303
|
434 |
method met_rooteq_sq : "RootEq/solve_sq_root_equation" =
|
Walther@60586
|
435 |
\<open>{rew_ord="termlessI", rls'=RootEq_erls, prog_rls = rooteq_srls, where_rls = RootEq_prls, calc = [],
|
Walther@60587
|
436 |
errpats = [], rew_rls = norm_Poly}\<close>
|
wenzelm@60303
|
437 |
Program: solve_sqrt_equ.simps
|
wenzelm@60303
|
438 |
Given: "equality e_e" "solveFor v_v"
|
wenzelm@60303
|
439 |
Where: "(((lhs e_e) is_sqrtTerm_in (v_v::real)) &
|
wenzelm@60303
|
440 |
((lhs e_e) is_normSqrtTerm_in (v_v::real))) |
|
wenzelm@60303
|
441 |
(((rhs e_e) is_sqrtTerm_in (v_v::real)) &
|
wenzelm@60303
|
442 |
((rhs e_e) is_normSqrtTerm_in (v_v::real)))"
|
wenzelm@60303
|
443 |
Find: "solutions v_v'i'"
|
wenzelm@60303
|
444 |
|
s1210629013@55373
|
445 |
(*-- right 28.08.02 --*)
|
wneuper@59504
|
446 |
partial_function (tailrec) solve_sqrt_equ_right :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
walther@59635
|
447 |
where
|
walther@59635
|
448 |
"solve_sqrt_equ_right e_e v_v =
|
walther@59635
|
449 |
(let
|
walther@59635
|
450 |
e_e = (
|
walther@59637
|
451 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''r_sqrt_isolate'')) #>
|
walther@59637
|
452 |
(Try (Rewrite_Set ''rooteq_simplify'')) #>
|
walther@59637
|
453 |
(Try (Repeat (Rewrite_Set ''expand_rootbinoms''))) #>
|
walther@59637
|
454 |
(Try (Repeat (Rewrite_Set ''make_rooteq''))) #>
|
walther@59635
|
455 |
(Try (Rewrite_Set ''rooteq_simplify'')) ) e_e
|
walther@59635
|
456 |
in
|
walther@59635
|
457 |
if (rhs e_e) is_sqrtTerm_in v_v
|
walther@59635
|
458 |
then
|
walther@59635
|
459 |
SubProblem (''RootEq'',[''normalise'',''rootX'',''univariate'',''equation''], [''no_met''])
|
walther@59635
|
460 |
[BOOL e_e, REAL v_v]
|
walther@59635
|
461 |
else
|
walther@59635
|
462 |
SubProblem (''RootEq'',[''univariate'', ''equation''], [''no_met''])
|
walther@59635
|
463 |
[BOOL e_e, REAL v_v])"
|
wenzelm@60303
|
464 |
|
wenzelm@60303
|
465 |
method met_rooteq_sq_right : "RootEq/solve_right_sq_root_equation" =
|
Walther@60586
|
466 |
\<open>{rew_ord = "termlessI", rls' = RootEq_erls, prog_rls = Rule_Set.empty, where_rls = RootEq_prls, calc = [],
|
Walther@60587
|
467 |
errpats = [], rew_rls = norm_Poly}\<close>
|
wenzelm@60303
|
468 |
Program: solve_sqrt_equ_right.simps
|
wenzelm@60303
|
469 |
Given: "equality e_e" "solveFor v_v"
|
wenzelm@60303
|
470 |
Where: "(rhs e_e) is_sqrtTerm_in v_v"
|
wenzelm@60303
|
471 |
Find: "solutions v_v'i'"
|
wenzelm@60303
|
472 |
|
s1210629013@55373
|
473 |
(*-- left 28.08.02 --*)
|
wneuper@59504
|
474 |
partial_function (tailrec) solve_sqrt_equ_left :: "bool \<Rightarrow> real \<Rightarrow> bool list"
|
wneuper@59504
|
475 |
where
|
wneuper@59504
|
476 |
"solve_sqrt_equ_left e_e v_v =
|
walther@59635
|
477 |
(let
|
walther@59635
|
478 |
e_e = (
|
walther@59637
|
479 |
(Try (Rewrite_Set_Inst [(''bdv'', v_v)] ''l_sqrt_isolate'')) #>
|
walther@59637
|
480 |
(Try (Rewrite_Set ''rooteq_simplify'')) #>
|
walther@59637
|
481 |
(Try (Repeat (Rewrite_Set ''expand_rootbinoms''))) #>
|
walther@59637
|
482 |
(Try (Repeat (Rewrite_Set ''make_rooteq''))) #>
|
walther@59635
|
483 |
(Try (Rewrite_Set ''rooteq_simplify'')) ) e_e
|
walther@59635
|
484 |
in
|
walther@59635
|
485 |
if (lhs e_e) is_sqrtTerm_in v_v
|
walther@59635
|
486 |
then
|
walther@59635
|
487 |
SubProblem (''RootEq'', [''normalise'',''rootX'',''univariate'',''equation''], [''no_met''])
|
walther@59635
|
488 |
[BOOL e_e, REAL v_v]
|
walther@59635
|
489 |
else
|
walther@59635
|
490 |
SubProblem (''RootEq'',[''univariate'',''equation''], [''no_met''])
|
walther@59635
|
491 |
[BOOL e_e, REAL v_v])"
|
wenzelm@60303
|
492 |
|
wenzelm@60303
|
493 |
method met_rooteq_sq_left : "RootEq/solve_left_sq_root_equation" =
|
Walther@60587
|
494 |
\<open>{rew_ord="termlessI", rls'=RootEq_erls, prog_rls=Rule_Set.empty, where_rls=RootEq_prls, calc =[],
|
Walther@60587
|
495 |
errpats = [], rew_rls = norm_Poly}\<close>
|
wenzelm@60303
|
496 |
Program: solve_sqrt_equ_left.simps
|
wenzelm@60303
|
497 |
Given: "equality e_e" "solveFor v_v"
|
wenzelm@60303
|
498 |
Where: "(lhs e_e) is_sqrtTerm_in v_v"
|
wenzelm@60303
|
499 |
Find: "solutions v_v'i'"
|
wenzelm@60303
|
500 |
|
wneuper@59526
|
501 |
ML \<open>
|
wneuper@59526
|
502 |
\<close> ML \<open>
|
wneuper@59526
|
503 |
\<close>
|
neuper@37906
|
504 |
end
|