neuper@38041
|
1 |
(* Title: tests for rationals
|
neuper@52101
|
2 |
Author: Walther Neuper
|
neuper@37906
|
3 |
Use is subject to license terms.
|
neuper@42395
|
4 |
*)
|
neuper@37906
|
5 |
|
neuper@52092
|
6 |
"-----------------------------------------------------------------------------";
|
neuper@52092
|
7 |
"-----------------------------------------------------------------------------";
|
neuper@52092
|
8 |
"table of contents -----------------------------------------------------------";
|
neuper@52092
|
9 |
"-----------------------------------------------------------------------------";
|
neuper@52087
|
10 |
"-------- fun poly_of_term ---------------------------------------------------";
|
neuper@52087
|
11 |
"-------- fun is_poly --------------------------------------------------------";
|
neuper@52087
|
12 |
"-------- fun term_of_poly ---------------------------------------------------";
|
neuper@52101
|
13 |
"-------- integration lev.1 fun factout_p_ -----------------------------------";
|
neuper@52101
|
14 |
"-------- integration lev.1 fun cancel_p_ ------------------------------------";
|
neuper@52101
|
15 |
"-------- integration lev.1 fun common_nominator_p_ --------------------------";
|
neuper@52101
|
16 |
"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
|
neuper@52101
|
17 |
"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
|
neuper@52101
|
18 |
"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
|
neuper@52104
|
19 |
"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
|
neuper@52105
|
20 |
"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
|
neuper@52101
|
21 |
"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
|
neuper@52105
|
22 |
"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
|
neuper@52105
|
23 |
"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
|
neuper@52101
|
24 |
"-------- reverse rewrite ----------------------------------------------------";
|
neuper@52101
|
25 |
"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
|
neuper@52101
|
26 |
"-------- investigate rls norm_Rational --------------------------------------";
|
neuper@52101
|
27 |
"-------- examples: rls norm_Rational ----------------------------------------";
|
neuper@52105
|
28 |
"-------- rational numerals --------------------------------------------------";
|
neuper@52105
|
29 |
"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
|
neuper@52105
|
30 |
"-------- examples common denominator from: Mathematik 1 Schalk --------------";
|
neuper@52105
|
31 |
"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
|
neuper@52105
|
32 |
"-------- examples common denominator and multiplication from: Schalk --------";
|
neuper@52105
|
33 |
"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
|
neuper@52105
|
34 |
"-------- me Schalk I No.186 -------------------------------------------------";
|
neuper@52105
|
35 |
"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
|
neuper@52105
|
36 |
"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
|
neuper@52105
|
37 |
"-------- investigate rulesets for cancel_p ----------------------------------";
|
neuper@52105
|
38 |
"-------- fun eval_get_denominator -------------------------------------------";
|
neuper@52105
|
39 |
"-------- several errpats in complicated term --------------------------------";
|
neuper@52106
|
40 |
"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
|
neuper@52105
|
41 |
"-----------------------------------------------------------------------------";
|
neuper@52105
|
42 |
"-----------------------------------------------------------------------------";
|
neuper@37906
|
43 |
|
neuper@37906
|
44 |
|
neuper@52087
|
45 |
"-------- fun poly_of_term ---------------------------------------------------";
|
neuper@52087
|
46 |
"-------- fun poly_of_term ---------------------------------------------------";
|
neuper@52087
|
47 |
"-------- fun poly_of_term ---------------------------------------------------";
|
neuper@52087
|
48 |
val vs = "12 * x^^^3 * y^^^4 * z^^^6" |> str2term |> vars |> map free2str |> sort string_ord;
|
neuper@52087
|
49 |
|
neuper@52087
|
50 |
if poly_of_term vs (str2term "12::real") = SOME [(12, [0, 0, 0])]
|
neuper@52087
|
51 |
then () else error "poly_of_term 1 changed";
|
neuper@52087
|
52 |
if poly_of_term vs (str2term "x::real") = SOME [(1, [1, 0, 0])]
|
neuper@52087
|
53 |
then () else error "poly_of_term 2 changed";
|
neuper@52087
|
54 |
if poly_of_term vs (str2term "12 * x^^^3") = SOME [(12, [3, 0, 0])]
|
neuper@52087
|
55 |
then () else error "poly_of_term 3 changed";
|
neuper@52087
|
56 |
if poly_of_term vs (str2term "12 * x^^^3 * y^^^4 * z^^^6") = SOME [(12, [3, 4, 6])]
|
neuper@52087
|
57 |
then () else error "poly_of_term 4 changed";
|
neuper@52087
|
58 |
if poly_of_term vs (str2term "1 + 2 * x^^^3 * y^^^4 * z^^^6 + y") =
|
neuper@52087
|
59 |
SOME [(1, [0, 0, 0]), (1, [0, 1, 0]), (2, [3, 4, 6])]
|
neuper@52087
|
60 |
then () else error "poly_of_term 5 changed";
|
neuper@52087
|
61 |
|
neuper@52087
|
62 |
(*poly_of_term is quite liberal:*)
|
neuper@52087
|
63 |
(*the coefficient may be somewhere, the order of variables and the parentheses
|
neuper@52087
|
64 |
within a monomial are arbitrary*)
|
neuper@52087
|
65 |
if poly_of_term vs (str2term "y^^^4 * (x^^^3 * 12 * z^^^6)") = SOME [(12, [3, 4, 6])]
|
neuper@52087
|
66 |
then () else error "poly_of_term 6 changed";
|
neuper@52087
|
67 |
|
neuper@52087
|
68 |
(*there may even be more than 1 coefficient:*)
|
neuper@52087
|
69 |
if poly_of_term vs (str2term "2 * y^^^4 * (x^^^3 * 6 * z^^^6)") = SOME [(12, [3, 4, 6])]
|
neuper@52087
|
70 |
then () else error "poly_of_term 7 changed";
|
neuper@52087
|
71 |
|
neuper@52087
|
72 |
(*the order and the parentheses within monomials are arbitrary:*)
|
neuper@52087
|
73 |
if poly_of_term vs (str2term "2 * x^^^3 * y^^^4 * z^^^6 + (7 * y^^^8 + 1)")
|
neuper@52087
|
74 |
= SOME [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 6])]
|
neuper@52087
|
75 |
then () else error "poly_of_term 8 changed";
|
neuper@52087
|
76 |
|
neuper@52087
|
77 |
"-------- fun is_poly --------------------------------------------------------";
|
neuper@52087
|
78 |
"-------- fun is_poly --------------------------------------------------------";
|
neuper@52087
|
79 |
"-------- fun is_poly --------------------------------------------------------";
|
neuper@52087
|
80 |
if is_poly (str2term "2 * x^^^3 * y^^^4 * z^^^6 + 7 * y^^^8 + 1")
|
neuper@52087
|
81 |
then () else error "is_poly 1 changed";
|
neuper@52087
|
82 |
if not (is_poly (str2term "2 * (x^^^3 * y^^^4 * z^^^6 + 7) * y^^^8 + 1"))
|
neuper@52087
|
83 |
then () else error "is_poly 2 changed";
|
neuper@52087
|
84 |
|
neuper@52087
|
85 |
"-------- fun term_of_poly ---------------------------------------------------";
|
neuper@52087
|
86 |
"-------- fun term_of_poly ---------------------------------------------------";
|
neuper@52087
|
87 |
"-------- fun term_of_poly ---------------------------------------------------";
|
neuper@52087
|
88 |
val expT = HOLogic.realT
|
neuper@52087
|
89 |
val Free (_, baseT) = (hd o vars o str2term) "12 * x^^^3 * y^^^4 * z^^^6";
|
neuper@52087
|
90 |
val p = [(1, [0, 0, 0]), (7, [0, 8, 0]), (2, [3, 4, 5])]
|
neuper@52087
|
91 |
val vs = ["x","y","z"]
|
neuper@52087
|
92 |
(*precondition for [(c, es),...]: legth es = length vs*)
|
neuper@52087
|
93 |
;
|
neuper@52087
|
94 |
if term2str (term_of_poly baseT expT vs p) = "1 + 7 * y ^^^ 8 + 2 * x ^^^ 3 * y ^^^ 4 * z ^^^ 5"
|
neuper@52087
|
95 |
then () else error "term_of_poly 1 changed";
|
neuper@52087
|
96 |
|
neuper@52101
|
97 |
"-------- integration lev.1 fun factout_p_ -----------------------------------";
|
neuper@52101
|
98 |
"-------- integration lev.1 fun factout_p_ -----------------------------------";
|
neuper@52101
|
99 |
"-------- integration lev.1 fun factout_p_ -----------------------------------";
|
neuper@52092
|
100 |
val t = str2term "(x^^^2 + -1*y^^^2) / (x^^^2 + -1*x*y)"
|
neuper@52092
|
101 |
val SOME (t', asm) = factout_p_ thy t;
|
neuper@52092
|
102 |
if term2str t' = "(x + y) * (x + -1 * y) / (x * (x + -1 * y))"
|
neuper@52092
|
103 |
then () else error ("factout_p_ term 1 changed: " ^ term2str t')
|
neuper@52092
|
104 |
;
|
neuper@52093
|
105 |
if terms2str asm = "[\"x ~= 0\",\"x + -1 * y ~= 0\"]"
|
neuper@52092
|
106 |
then () else error "factout_p_ asm 1 changed"
|
neuper@52092
|
107 |
;
|
neuper@52092
|
108 |
val t = str2term "nothing + to_cancel ::real";
|
neuper@52092
|
109 |
if NONE = factout_p_ thy t then () else error "factout_p_ doesn't report non-applicable";
|
neuper@52093
|
110 |
;
|
neuper@52093
|
111 |
val t = str2term "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
|
neuper@52093
|
112 |
val SOME (t', asm) = factout_p_ thy t;
|
neuper@52093
|
113 |
if term2str t' = "(3 + 3 * x) * (1 + x) / (2 * (1 + x))" andalso
|
neuper@52094
|
114 |
terms2str asm = "[\"1 + x ~= 0\"]"
|
neuper@52093
|
115 |
then () else error "factout_p_ 1 changed";
|
neuper@52093
|
116 |
|
neuper@52101
|
117 |
"-------- integration lev.1 fun cancel_p_ ------------------------------------";
|
neuper@52101
|
118 |
"-------- integration lev.1 fun cancel_p_ ------------------------------------";
|
neuper@52101
|
119 |
"-------- integration lev.1 fun cancel_p_ ------------------------------------";
|
neuper@52093
|
120 |
val t = str2term "(x^^^2 + -1*y^^^2) / (x^^^2 + -1*x*y)"
|
neuper@52093
|
121 |
val SOME (t', asm) = cancel_p_ thy t;
|
neuper@52094
|
122 |
if (term2str t', terms2str asm) = ("(x + y) / x", "[\"x ~= 0\"]")
|
neuper@52093
|
123 |
then () else error ("cancel_p_ (t', asm) 1 changed: " ^ term2str t')
|
neuper@52093
|
124 |
;
|
neuper@52093
|
125 |
val t = str2term "nothing + to_cancel ::real";
|
neuper@52093
|
126 |
if NONE = cancel_p_ thy t then () else error "cancel_p_ doesn't report non-applicable";
|
neuper@52093
|
127 |
;
|
neuper@52093
|
128 |
val t = str2term "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
|
neuper@52093
|
129 |
val SOME (t', asm) = cancel_p_ thy t;
|
neuper@52094
|
130 |
if term2str t' = "(3 + 3 * x) / 2" andalso terms2str asm = "[]"
|
neuper@52093
|
131 |
then () else error "cancel_p_ 1 changed";
|
neuper@52092
|
132 |
|
neuper@52101
|
133 |
"-------- integration lev.1 fun common_nominator_p_ --------------------------";
|
neuper@52101
|
134 |
"-------- integration lev.1 fun common_nominator_p_ --------------------------";
|
neuper@52101
|
135 |
"-------- integration lev.1 fun common_nominator_p_ --------------------------";
|
neuper@52092
|
136 |
val t = str2term ("y / (a*x + b*x + c*x) " ^
|
neuper@52092
|
137 |
(* n1 d1 *)
|
neuper@52092
|
138 |
"+ a / (x*y)");
|
neuper@52092
|
139 |
(* n2 d2 *)
|
neuper@52092
|
140 |
val SOME (t', asm) = common_nominator_p_ thy t;
|
neuper@52092
|
141 |
if term2str t' =
|
neuper@52092
|
142 |
("y * y / (x * ((a + b + c) * y)) " ^
|
neuper@52092
|
143 |
(* n1 *d2'/ (c'* ( d1' *d2')) *)
|
neuper@52092
|
144 |
"+ a * (a + b + c) / (x * ((a + b + c) * y))")
|
neuper@52092
|
145 |
(* n2 * d1' / (c'* ( d1' *d2')) *)
|
neuper@52092
|
146 |
then () else error "common_nominator_p_ term 1 changed";
|
neuper@52093
|
147 |
if terms2str asm = "[\"a + b + c ~= 0\",\"y ~= 0\",\"x ~= 0\"]"
|
neuper@52092
|
148 |
then () else error "common_nominator_p_ asm 1 changed"
|
neuper@52092
|
149 |
|
neuper@52092
|
150 |
"-------- example in mail Nipkow";
|
neuper@52092
|
151 |
val t = str2term "x/(x^^^2 + -1*y^^^2) + y/(x^^^2 + -1*x*y)";
|
neuper@52092
|
152 |
val SOME (t', asm) = common_nominator_p_ thy t;
|
neuper@52092
|
153 |
if term2str t' = "x * x / " ^
|
neuper@52092
|
154 |
"((x + -1 * y) * ((x + y) * x))" ^
|
neuper@52092
|
155 |
" +\n" ^
|
neuper@52092
|
156 |
"y * (x + y) / " ^
|
neuper@52092
|
157 |
"((x + -1 * y) * ((x + y) * x))"
|
neuper@52092
|
158 |
then () else error "common_nominator_p_ term 2 changed"
|
neuper@52092
|
159 |
;
|
neuper@52093
|
160 |
if terms2str asm = "[\"x + y ~= 0\",\"x ~= 0\",\"x + -1 * y ~= 0\"]"
|
neuper@52092
|
161 |
then () else error "common_nominator_p_ asm 2 changed"
|
neuper@52092
|
162 |
|
neuper@52092
|
163 |
"-------- example: applicable tested by SML code";
|
neuper@52092
|
164 |
val t = str2term "nothing / to_add";
|
neuper@52092
|
165 |
if NONE = common_nominator_p_ thy t then () else error "common_nominator_p_ term 3 changed";
|
neuper@52093
|
166 |
;
|
neuper@52093
|
167 |
val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
|
neuper@52093
|
168 |
val SOME (t', asm) = common_nominator_p_ thy t;
|
neuper@52093
|
169 |
if term2str t' =
|
neuper@52101
|
170 |
"(x + -1) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(x + 1) * (1 + x) / ((1 + x) * (-1 + x))"
|
neuper@52094
|
171 |
andalso terms2str asm = "[\"1 + x ~= 0\",\"-1 + x ~= 0\"]"
|
neuper@52093
|
172 |
then () else error "common_nominator_p_ 3 changed";
|
neuper@52092
|
173 |
|
neuper@52101
|
174 |
"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
|
neuper@52101
|
175 |
"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
|
neuper@52101
|
176 |
"-------- integration lev.1 fun add_fraction_p_ ------------------------------";
|
neuper@52092
|
177 |
val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
|
neuper@52092
|
178 |
val SOME (t', asm) = add_fraction_p_ thy t;
|
neuper@52092
|
179 |
if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)"
|
neuper@52092
|
180 |
then () else error "add_fraction_p_ 3 changed";
|
neuper@52093
|
181 |
;
|
neuper@52093
|
182 |
if terms2str asm = "[\"-1 + x ^^^ 2 ~= 0\"]"
|
neuper@52092
|
183 |
then () else error "add_fraction_p_ 3 changed";
|
neuper@52093
|
184 |
;
|
neuper@52093
|
185 |
val t = str2term "nothing / to_add";
|
neuper@52093
|
186 |
if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ term 3 changed";
|
neuper@52093
|
187 |
;
|
neuper@52093
|
188 |
val t = str2term "((x + (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
|
neuper@52093
|
189 |
val SOME (t', asm) = add_fraction_p_ thy t;
|
neuper@52093
|
190 |
if term2str t' = "(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)" andalso
|
neuper@52093
|
191 |
terms2str asm = "[\"-1 + x ^^^ 2 ~= 0\"]"
|
neuper@52093
|
192 |
then () else error "add_fraction_p_ 3 changed";
|
neuper@52092
|
193 |
|
neuper@52101
|
194 |
"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
|
neuper@52101
|
195 |
"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
|
neuper@52101
|
196 |
"-------- and app_rev ...traced down from rewrite_set_ until prepats ---------";
|
neuper@52085
|
197 |
(* trace down until prepats are evaluated
|
neuper@52085
|
198 |
(which does not to work, because substitution is not done -- compare rew_sub!);
|
neuper@52085
|
199 |
keep this sequence for the case, factout_p, cancel_p, common_nominator_p, add_fraction_p
|
neuper@52085
|
200 |
(again) get prepat = [] changed to <>[]. *)
|
neuper@52085
|
201 |
val t = str2term "(x^^^2 + -1*y^^^2) / (x^^^2 + -1*x*y)";
|
neuper@52085
|
202 |
|
neuper@52085
|
203 |
(*rewrite_set_ @{theory Isac} true cancel t = NONE; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
204 |
"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (thy, false, cancel_p, t);
|
neuper@52085
|
205 |
"~~~~~ fun rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
|
neuper@52085
|
206 |
(thy, 1, bool, [], rls, term);
|
neuper@52085
|
207 |
(*val (t', asm, rew) = app_rev thy (i+1) rrls t; rew = false!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52092
|
208 |
"~~~~~ and app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
|
neuper@52085
|
209 |
fun chk_prepat thy erls [] t = true
|
neuper@52085
|
210 |
| chk_prepat thy erls prepat t =
|
neuper@52085
|
211 |
let
|
neuper@52085
|
212 |
fun chk (pres, pat) =
|
neuper@52085
|
213 |
(let
|
neuper@52085
|
214 |
val subst: Type.tyenv * Envir.tenv =
|
neuper@52085
|
215 |
Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
|
neuper@52085
|
216 |
in
|
neuper@52085
|
217 |
snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
|
neuper@52085
|
218 |
end) handle _ => false
|
neuper@52085
|
219 |
fun scan_ f [] = false (*scan_ NEVER called by []*)
|
neuper@52085
|
220 |
| scan_ f (pp::pps) =
|
neuper@52085
|
221 |
if f pp then true else scan_ f pps;
|
neuper@52085
|
222 |
in scan_ chk prepat end;
|
neuper@52085
|
223 |
(* apply the normal_form of a rev-set *)
|
neuper@52085
|
224 |
fun app_rev' thy (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}) t =
|
neuper@52085
|
225 |
if chk_prepat thy erls prepat t
|
neuper@52105
|
226 |
then ((*tracing("### app_rev': t = "^term2str t);*) normal_form t)
|
neuper@52085
|
227 |
else NONE;
|
neuper@52085
|
228 |
(* val opt = app_rev' thy rrls t ..NONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
229 |
"~~~~~ and app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
|
neuper@52085
|
230 |
(thy, rrls, t);
|
neuper@52085
|
231 |
(* chk_prepat thy erls prepat t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
232 |
(* app_sub thy i rrls t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
233 |
"~~~~~ fun chk_prepat, args:"; val (thy, erls, prepat, t) = (thy, erls, prepat, t);
|
neuper@52085
|
234 |
fun chk (pres, pat) =
|
neuper@52085
|
235 |
(let
|
neuper@52085
|
236 |
val subst: Type.tyenv * Envir.tenv =
|
neuper@52085
|
237 |
Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
|
neuper@52085
|
238 |
in
|
neuper@52085
|
239 |
snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
|
neuper@52085
|
240 |
end) handle _ => false
|
neuper@52085
|
241 |
fun scan_ f [] = false (*scan_ NEVER called by []*)
|
neuper@52085
|
242 |
| scan_ f (pp::pps) =
|
neuper@52085
|
243 |
if f pp then true else scan_ f pps;
|
neuper@52085
|
244 |
|
neuper@52088
|
245 |
(*========== inhibit exn WN130823: prepat is empty ====================================
|
neuper@52085
|
246 |
(* scan_ chk prepat = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
247 |
"~~~~~ fun , args:"; val (f, (pp::pps)) = (chk, prepat);
|
neuper@52085
|
248 |
f;
|
neuper@52085
|
249 |
val ([t1, t2], t) = pp;
|
neuper@52085
|
250 |
term2str t1 = "?r is_expanded";
|
neuper@52085
|
251 |
term2str t2 = "?s is_expanded";
|
neuper@52085
|
252 |
term2str t = "?r / ?s";
|
neuper@52085
|
253 |
(* f pp = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
254 |
"~~~~~ fun chk, args:"; val (pres, pat) = (pp);
|
neuper@52085
|
255 |
val subst: Type.tyenv * Envir.tenv =
|
neuper@52085
|
256 |
Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
|
neuper@52085
|
257 |
(*subst =
|
neuper@52085
|
258 |
({}, {(("r", 0), ("real", Var (("r", 0), "real"))),
|
neuper@52085
|
259 |
(("s", 0), ("real", Var (("s", 0), "real")))}*)
|
neuper@52085
|
260 |
;
|
neuper@52085
|
261 |
snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
|
neuper@52085
|
262 |
"~~~~~ fun eval__true, args:"; val (thy, i, asms, bdv, rls) =
|
neuper@52085
|
263 |
(thy, (i + 1), (map (Envir.subst_term subst) pres), [], erls);
|
neuper@52085
|
264 |
terms2str asms; (* = "[\"?r is_expanded\",\"?s is_expanded\"]"*)
|
neuper@52085
|
265 |
asms = [@{term True}] orelse asms = []; (* = false*)
|
neuper@52085
|
266 |
asms = [@{term False}] ; (* = false*)
|
neuper@52085
|
267 |
"~~~~~ fun chk, args:"; val (indets, (a::asms)) = ([], asms);
|
neuper@52085
|
268 |
bdv (*= []: _a list*);
|
neuper@52085
|
269 |
val bdv : (term * term) list = [];
|
neuper@52085
|
270 |
rewrite__set_ thy (i+1) false;
|
neuper@52085
|
271 |
term2str a = "?r is_expanded"; (*hier m"usste doch der Numerator eingesetzt sein ??????????????*)
|
neuper@52085
|
272 |
val SOME (Const ("HOL.False", _), []) = rewrite__set_ thy (i+1) false bdv rls a
|
neuper@52088
|
273 |
============ inhibit exn WN130823: prepat is empty ===================================*)
|
neuper@37906
|
274 |
|
neuper@52101
|
275 |
"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
|
neuper@52101
|
276 |
"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
|
neuper@52101
|
277 |
"-------- fun rewrite_set_ cancel_p downto fun gcd_poly ----------------------";
|
neuper@52101
|
278 |
val t = str2term "(12 * x * y) / (8 * y^^^2 )";
|
neuper@52101
|
279 |
(* "-------- example 187a": exception Div raised...
|
neuper@52101
|
280 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
|
neuper@52101
|
281 |
val t = str2term "(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
|
neuper@52101
|
282 |
(* "-------- example 187b": doesn't terminate...
|
neuper@52101
|
283 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
|
neuper@52101
|
284 |
val t = str2term "(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";
|
neuper@52101
|
285 |
(* "-------- example 187c": doesn't terminate...
|
neuper@52101
|
286 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;*)
|
neuper@52101
|
287 |
"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (@{theory Isac}, false, cancel_p, t);
|
neuper@52101
|
288 |
(* WN130827: exception Div raised...
|
neuper@52101
|
289 |
rewrite__set_ thy 1 bool [] rls term
|
neuper@52101
|
290 |
*)
|
neuper@52101
|
291 |
"~~~~~ and rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
|
neuper@52101
|
292 |
(thy, 1, bool, [], rls, term);
|
neuper@52101
|
293 |
(* WN130827: exception Div raised...
|
neuper@52101
|
294 |
val (t', asm, rew) = app_rev thy (i+1) rrls t
|
neuper@52101
|
295 |
*)
|
neuper@52101
|
296 |
"~~~~~ fun app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
|
neuper@52101
|
297 |
(* WN130827: exception Div raised...
|
neuper@52101
|
298 |
val opt = app_rev' thy rrls t
|
neuper@52101
|
299 |
*)
|
neuper@52101
|
300 |
"~~~~~ fun app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
|
neuper@52101
|
301 |
(thy, rrls, t);
|
neuper@52101
|
302 |
chk_prepat thy erls prepat t = true;
|
neuper@52101
|
303 |
(* WN130827: exception Div raised...
|
neuper@52101
|
304 |
normal_form t
|
neuper@52101
|
305 |
*)
|
neuper@52101
|
306 |
(* lookup Rational.thy, cancel_p: normal_form = cancel_p_ thy*)
|
neuper@52101
|
307 |
"~~~~~ fun cancel_p_, args:"; val (t) = (t);
|
neuper@52101
|
308 |
val opt = check_fraction t;
|
neuper@52101
|
309 |
val SOME (numerator, denominator) = opt
|
neuper@52101
|
310 |
val vs = t |> vars |> map free2str |> sort string_ord
|
neuper@52101
|
311 |
val baseT = type_of numerator
|
neuper@52101
|
312 |
val expT = HOLogic.realT
|
neuper@52101
|
313 |
val (SOME a, SOME b) = (poly_of_term vs numerator, poly_of_term vs denominator);
|
neuper@52101
|
314 |
(*"-------- example 187a": exception Div raised...
|
neuper@52101
|
315 |
val a = [(12, [1, 1])]: poly
|
neuper@52101
|
316 |
val b = [(8, [0, 2])]: poly
|
neuper@52101
|
317 |
val ((a', b'), c) = gcd_poly a b
|
neuper@52101
|
318 |
*)
|
neuper@52101
|
319 |
(* "-------- example 187b": doesn't terminate...
|
neuper@52101
|
320 |
val a = [(8, [2, 1, 1])]: poly
|
neuper@52101
|
321 |
val b = [(18, [1, 2, 1])]: poly
|
neuper@52101
|
322 |
val ((a', b'), c) = gcd_poly a b
|
neuper@52101
|
323 |
*)
|
neuper@52101
|
324 |
(* "-------- example 187c": doesn't terminate...
|
neuper@52101
|
325 |
val a = [(9, [5, 2, 4])]: poly
|
neuper@52101
|
326 |
val b = [(15, [6, 3, 1])]: poly
|
neuper@52101
|
327 |
val ((a', b'), c) = gcd_poly a b
|
neuper@52101
|
328 |
*)
|
neuper@37906
|
329 |
|
neuper@52104
|
330 |
"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
|
neuper@52104
|
331 |
"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
|
neuper@52104
|
332 |
"-------- rls norm_Rational downto fun gcd_poly ------------------------------";
|
neuper@52104
|
333 |
val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
|
neuper@52104
|
334 |
trace_rewrite := false (*true false*);
|
neuper@52104
|
335 |
(* trace stops with ...: (and then jEdit hangs)..
|
neuper@52104
|
336 |
rewrite_set_ thy false norm_Rational t;
|
neuper@52104
|
337 |
:
|
neuper@52104
|
338 |
### rls: cancel_p on: (-12 + 4 * y + 3 * x ^^^ 2 + -1 * (x ^^^ 2 * y)) /
|
neuper@52104
|
339 |
(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)
|
neuper@52104
|
340 |
*)
|
neuper@52104
|
341 |
val t = str2term (*copy from above: "::real" is not required due to "^^^"*)
|
neuper@52104
|
342 |
("(-12 + 4 * y + 3 * x ^^^ 2 + -1 * (x ^^^ 2 * y)) /" ^
|
neuper@52104
|
343 |
"(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)");
|
neuper@52104
|
344 |
(*cancel_p_ thy t;
|
neuper@52104
|
345 |
exception Div raised*)
|
neuper@52104
|
346 |
|
neuper@52104
|
347 |
"~~~~~ fun cancel_p_, args:"; val (t) = (t);
|
neuper@52104
|
348 |
val opt = check_fraction t;
|
neuper@52104
|
349 |
val SOME (numerator, denominator) = opt
|
neuper@52104
|
350 |
val vs = t |> vars |> map free2str |> sort string_ord
|
neuper@52104
|
351 |
val baseT = type_of numerator
|
neuper@52104
|
352 |
val expT = HOLogic.realT;
|
neuper@52104
|
353 |
print_depth 3; (*999*)
|
neuper@52104
|
354 |
val (SOME a, SOME b) = (poly_of_term vs numerator, poly_of_term vs denominator);
|
neuper@52104
|
355 |
print_depth 3; (*999*)
|
neuper@52104
|
356 |
(* does not terminate instead of returning ?:
|
neuper@52104
|
357 |
val ((a', b'), c) = gcd_poly a b
|
neuper@52104
|
358 |
val a = [(~12, [0, 0]), (3, [2, 0]), (4, [0, 1]), (~1, [2, 1])]: poly
|
neuper@52104
|
359 |
val b = [(~18, [0, 0]), (~9, [1, 0]), (2, [0, 2]), (1, [1, 2])]: poly
|
neuper@52104
|
360 |
*)
|
neuper@52104
|
361 |
|
neuper@52105
|
362 |
"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
|
neuper@52105
|
363 |
"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
|
neuper@52105
|
364 |
"-------- rls norm_Rational downto fun add_fraction_p_ -----------------------";
|
neuper@52105
|
365 |
val thy = @{theory Isac};
|
neuper@52105
|
366 |
"----- SK060904-2a non-termination of add_fraction_p_";
|
neuper@52105
|
367 |
val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
|
neuper@52105
|
368 |
" (-1 * a + b * x) / (a + b * x) ");
|
neuper@52105
|
369 |
(* rewrite_set_ thy false norm_Rational t
|
neuper@52105
|
370 |
exception Div raised*)
|
neuper@52105
|
371 |
(* rewrite_set_ thy false add_fractions_p t;
|
neuper@52105
|
372 |
exception Div raised*)
|
neuper@52105
|
373 |
"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) =
|
neuper@52105
|
374 |
(@{theory Isac}, false, add_fractions_p, t);
|
neuper@52105
|
375 |
"~~~~~ and rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
|
neuper@52105
|
376 |
(thy, 1, bool, [], rls, term);
|
neuper@52105
|
377 |
(* app_rev thy (i+1) rrls t;
|
neuper@52105
|
378 |
exception Div raised*)
|
neuper@52105
|
379 |
"~~~~~ and app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
|
neuper@52105
|
380 |
fun chk_prepat thy erls [] t = true
|
neuper@52105
|
381 |
| chk_prepat thy erls prepat t =
|
neuper@52105
|
382 |
let
|
neuper@52105
|
383 |
fun chk (pres, pat) =
|
neuper@52105
|
384 |
(let
|
neuper@52105
|
385 |
val subst: Type.tyenv * Envir.tenv =
|
neuper@52105
|
386 |
Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
|
neuper@52105
|
387 |
in
|
neuper@52105
|
388 |
snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
|
neuper@52105
|
389 |
end) handle _ => false
|
neuper@52105
|
390 |
fun scan_ f [] = false (*scan_ NEVER called by []*)
|
neuper@52105
|
391 |
| scan_ f (pp::pps) =
|
neuper@52105
|
392 |
if f pp then true else scan_ f pps;
|
neuper@52105
|
393 |
in scan_ chk prepat end;
|
neuper@52105
|
394 |
(* apply the normal_form of a rev-set *)
|
neuper@52105
|
395 |
fun app_rev' thy (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}) t =
|
neuper@52105
|
396 |
if chk_prepat thy erls prepat t
|
neuper@52105
|
397 |
then ((*tracing("### app_rev': t = "^term2str t);*) normal_form t)
|
neuper@52105
|
398 |
else NONE;
|
neuper@52105
|
399 |
(* val opt = app_rev' thy rrls t;
|
neuper@52105
|
400 |
exception Div raised*)
|
neuper@52105
|
401 |
(* val opt = app_rev' thy rrls t;
|
neuper@52105
|
402 |
exception Div raised*)
|
neuper@52105
|
403 |
"~~~~~ and app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
|
neuper@52105
|
404 |
(thy, rrls, t);
|
neuper@52105
|
405 |
chk_prepat thy erls prepat t = true = true;
|
neuper@52105
|
406 |
(*normal_form t
|
neuper@52105
|
407 |
exception Div raised*)
|
neuper@52105
|
408 |
(* lookup Rational.thy, val add_fractions_p: normal_form = add_fraction_p_ thy*)
|
neuper@52105
|
409 |
(*add_fraction_p_ thy t
|
neuper@52105
|
410 |
exception Div raised*)
|
neuper@52105
|
411 |
"~~~~~ fun add_fraction_p_, args:"; val ((_: theory), t) = (thy, t);
|
neuper@52105
|
412 |
val SOME ((n1, d1), (n2, d2)) = check_frac_sum t;
|
neuper@52105
|
413 |
term2str n1; term2str d1; term2str n2; term2str d2;
|
neuper@52105
|
414 |
val vs = t |> vars |> map str_of_free_opt (* tolerate Var in simplification *)
|
neuper@52105
|
415 |
|> filter is_some |> map the |> sort string_ord;
|
neuper@52105
|
416 |
print_depth 3; (*999*)
|
neuper@52105
|
417 |
val (SOME _, SOME a, SOME _, SOME b) =
|
neuper@52105
|
418 |
(poly_of_term vs n1, poly_of_term vs d1, poly_of_term vs n2, poly_of_term vs d2);
|
neuper@52105
|
419 |
print_depth 3; (*999*)
|
neuper@52105
|
420 |
(*
|
neuper@52105
|
421 |
val a = [(1, [1, 0, 0]), (~1, [0, 1, 1])]: poly
|
neuper@52105
|
422 |
val b = [(1, [1, 0, 0]), (1, [0, 1, 1])]: poly
|
neuper@52105
|
423 |
val ((a', b'), c) = gcd_poly a b
|
neuper@52105
|
424 |
*)
|
neuper@52105
|
425 |
|
neuper@52101
|
426 |
"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
|
neuper@52101
|
427 |
"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
|
neuper@52101
|
428 |
"-------- rewrite_set_ cancel_p from: Mathematik 1 Schalk Reniets Verlag -----";
|
neuper@52092
|
429 |
val thy = @{theory "Rational"};
|
neuper@52096
|
430 |
"-------- WN";
|
neuper@52096
|
431 |
val t = str2term "(2 + -3 * x) / 9";
|
neuper@52096
|
432 |
if NONE = rewrite_set_ thy false cancel_p t then ()
|
neuper@52096
|
433 |
else error "rewrite_set_ cancel_p must return NONE, if the term cannot be cancelled";
|
neuper@52096
|
434 |
|
neuper@52092
|
435 |
"-------- example 186a";
|
neuper@52092
|
436 |
val t = str2term "(14 * x * y) / (x * y)";
|
neuper@52092
|
437 |
is_expanded (str2term "14 * x * y");
|
neuper@52092
|
438 |
is_expanded (str2term "x * y");
|
neuper@52095
|
439 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
440 |
if (term2str t', terms2str asm) = ("14 / 1", "[]")
|
neuper@52092
|
441 |
then () else error "rational.sml cancel Schalk 186a";
|
neuper@52092
|
442 |
|
neuper@52092
|
443 |
"-------- example 186b";
|
neuper@52092
|
444 |
val t = str2term "(60 * a * b) / ( 15 * a * b )";
|
neuper@52095
|
445 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
446 |
if (term2str t', terms2str asm) = ("4 / 1", "[]")
|
neuper@52092
|
447 |
then () else error "rational.sml cancel Schalk 186b";
|
neuper@52092
|
448 |
|
neuper@52092
|
449 |
"-------- example 186c";
|
neuper@52092
|
450 |
val t = str2term "(144 * a^^^2 * b * c) / (12 * a * b * c)";
|
neuper@52095
|
451 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
452 |
if (term2str t', terms2str asm) = ("12 * a / 1", "[]")
|
neuper@52092
|
453 |
then () else error "rational.sml cancel Schalk 186c";
|
neuper@52092
|
454 |
|
neuper@52095
|
455 |
(* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! exception Div raised !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
neuper@52095
|
456 |
see --- fun rewrite_set_ downto fun gcd_poly ---
|
neuper@52092
|
457 |
"-------- example 187a";
|
neuper@52092
|
458 |
val t = str2term "(12 * x * y) / (8 * y^^^2 )";
|
neuper@52095
|
459 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52092
|
460 |
if (term2str t', terms2str asm) = ("3 * x / (2 * y)", "[\"4 * y ~= 0\"]")
|
neuper@52092
|
461 |
then () else error "rational.sml cancel Schalk 187a";
|
neuper@52095
|
462 |
*)
|
neuper@52092
|
463 |
|
neuper@52095
|
464 |
(* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
neuper@52095
|
465 |
see --- fun rewrite_set_ downto fun gcd_poly ---
|
neuper@52092
|
466 |
"-------- example 187b";
|
neuper@52092
|
467 |
val t = str2term "(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
|
neuper@52095
|
468 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52092
|
469 |
if (term2str t', terms2str asm) = ("4 * x / (9 * y)", "[\"2 * (z * (y * x)) ~= 0\"]")
|
neuper@52092
|
470 |
then () else error "rational.sml cancel Schalk 187b";
|
neuper@52095
|
471 |
*)
|
neuper@52092
|
472 |
|
neuper@52095
|
473 |
(* doesn't terminate !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
neuper@52095
|
474 |
see --- fun rewrite_set_ downto fun gcd_poly ---
|
neuper@52092
|
475 |
"-------- example 187c";
|
neuper@52092
|
476 |
val t = str2term "(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";
|
neuper@52095
|
477 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52092
|
478 |
if (term2str t', terms2str asm) =
|
neuper@52092
|
479 |
("3 * z ^^^ 3 / (5 * (y * x))", "[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]")
|
neuper@52092
|
480 |
then () else error "rational.sml cancel Schalk 187c";
|
neuper@52095
|
481 |
*)
|
neuper@52092
|
482 |
|
neuper@52092
|
483 |
"-------- example 188a";
|
neuper@52092
|
484 |
val t = str2term "(-8 + 8 * x) / (-9 + 9 * x)";
|
neuper@52092
|
485 |
is_expanded (str2term "8 * x + -8");
|
neuper@52095
|
486 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
487 |
if (term2str t', terms2str asm) = ("8 / 9", "[]")
|
neuper@52092
|
488 |
then () else error "rational.sml cancel Schalk 188a";
|
neuper@52092
|
489 |
|
neuper@52092
|
490 |
val t = str2term "(8*((-1) + x))/(9*((-1) + x))";
|
neuper@52105
|
491 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
|
neuper@52095
|
492 |
if (term2str t', terms2str asm) = ("8 / 9", "[]")
|
neuper@52092
|
493 |
then () else error "rational.sml cancel Schalk make_polynomial 1";
|
neuper@52092
|
494 |
|
neuper@52092
|
495 |
"-------- example 188b";
|
neuper@52092
|
496 |
val t = str2term "(-15 + 5 * x) / (-18 + 6 * x)";
|
neuper@52095
|
497 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
498 |
if (term2str t', terms2str asm) = ("5 / 6", "[]")
|
neuper@52092
|
499 |
then () else error "rational.sml cancel Schalk 188b";
|
neuper@52092
|
500 |
|
neuper@52092
|
501 |
"-------- example 188c";
|
neuper@52092
|
502 |
val t = str2term "(a + -1 * b) / (b + -1 * a)";
|
neuper@52095
|
503 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
504 |
if (term2str t', terms2str asm) = ("-1 / 1", "[]")
|
neuper@52092
|
505 |
then () else error "rational.sml cancel Schalk 188c";
|
neuper@52092
|
506 |
|
neuper@52095
|
507 |
is_expanded (str2term "a + -1 * b") = true;
|
neuper@52092
|
508 |
val t = str2term "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
|
neuper@52092
|
509 |
val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
|
neuper@52092
|
510 |
if (term2str t', terms2str asm) = ("(a + -1 * b) / (-1 * a + b)", "[]")
|
neuper@52092
|
511 |
then () else error "rational.sml cancel Schalk make_polynomial 2";
|
neuper@52092
|
512 |
|
neuper@52092
|
513 |
"-------- example 190a";
|
neuper@52092
|
514 |
val t = str2term "( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
|
neuper@52095
|
515 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52092
|
516 |
if (term2str t', terms2str asm) =
|
neuper@52095
|
517 |
("(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)", "[\"3 * a + 9 * a ^^^ 2 ~= 0\"]")
|
neuper@52092
|
518 |
then () else error "rational.sml cancel Schalk 190a";
|
neuper@52092
|
519 |
|
neuper@52092
|
520 |
"-------- example 190c";
|
neuper@52092
|
521 |
val t = str2term "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
|
neuper@52092
|
522 |
val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
|
neuper@52092
|
523 |
if (term2str t', terms2str asm) =
|
neuper@52092
|
524 |
("(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)", "[]")
|
neuper@52092
|
525 |
then () else error "rational.sml make_polynomial Schalk 190c";
|
neuper@52092
|
526 |
|
neuper@52092
|
527 |
"-------- example 191a";
|
neuper@52092
|
528 |
val t = str2term "( x^^^2 + -1 * y^^^2 ) / ( x + y )";
|
neuper@52092
|
529 |
is_expanded (str2term "x^^^2 + -1 * y^^^2") = false; (*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52092
|
530 |
is_expanded (str2term "x + y") = true;
|
neuper@52095
|
531 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
532 |
if (term2str t', terms2str asm) = ("(x + -1 * y) / 1", "[]")
|
neuper@52095
|
533 |
then () else error "rational.sml make_polynomial Schalk 191a";
|
neuper@52092
|
534 |
|
neuper@52092
|
535 |
"-------- example 191b";
|
neuper@52092
|
536 |
val t = str2term "((x + (-1) * y)*(x + y))/((1)*(x + y))";
|
neuper@52092
|
537 |
val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
|
neuper@52092
|
538 |
if (term2str t', terms2str asm) = ("(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)", "[]")
|
neuper@52092
|
539 |
then () else error "rational.sml make_polynomial Schalk 191b";
|
neuper@52092
|
540 |
|
neuper@52092
|
541 |
"-------- example 191c";
|
neuper@52092
|
542 |
val t = str2term "( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
|
neuper@52095
|
543 |
is_expanded (str2term "9 * x^^^2 + -30 * x + 25") = true;
|
neuper@52095
|
544 |
is_expanded (str2term "25 + -30*x + 9*x^^^2") = true;
|
neuper@52092
|
545 |
is_expanded (str2term "-25 + 9*x^^^2") = true;
|
neuper@52092
|
546 |
|
neuper@52092
|
547 |
val t = str2term "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
|
neuper@52092
|
548 |
val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
|
neuper@52092
|
549 |
if (term2str t', terms2str asm) = ("(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)", "[]")
|
neuper@52092
|
550 |
then () else error "rational.sml make_polynomial Schalk 191c";
|
neuper@52092
|
551 |
|
neuper@52092
|
552 |
"-------- example 192b";
|
neuper@52092
|
553 |
val t = str2term "( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
|
neuper@52095
|
554 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
555 |
if (term2str t', terms2str asm) = ("x ^^^ 2 / y ^^^ 2", "[\"y ^^^ 2 ~= 0\"]")
|
neuper@52095
|
556 |
then () else error "rational.sml cancel_p Schalk 192b";
|
neuper@52092
|
557 |
|
neuper@52092
|
558 |
val t = str2term "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
|
neuper@52092
|
559 |
val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
|
neuper@52092
|
560 |
if (term2str t', terms2str asm) =
|
neuper@52092
|
561 |
("(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)", "[]")
|
neuper@52092
|
562 |
then () else error "rational.sml make_polynomial Schalk 192b";
|
neuper@52092
|
563 |
|
neuper@52092
|
564 |
val t = str2term "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
|
neuper@52092
|
565 |
val SOME (t', asm) = rewrite_set_ thy false make_polynomial t;
|
neuper@52092
|
566 |
if (term2str t', terms2str asm) =
|
neuper@52092
|
567 |
("(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)", "[]")
|
neuper@52095
|
568 |
then () else error "rational.sml make_polynomial Schalk WN050929 not working";
|
neuper@52092
|
569 |
|
neuper@52092
|
570 |
"-------- example 193a";
|
neuper@52092
|
571 |
val t = str2term "( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
|
neuper@52095
|
572 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
573 |
if (term2str t', terms2str asm) = ("(-3 + x) / (3 + x)", "[\"3 + x ~= 0\"]")
|
neuper@52095
|
574 |
then () else error "rational.sml cancel_p Schalk 193a";
|
neuper@52092
|
575 |
|
neuper@52092
|
576 |
"-------- example 193b";
|
neuper@52092
|
577 |
val t = str2term "( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
|
neuper@52095
|
578 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
579 |
if (term2str t', terms2str asm) = ("(-4 + x) / (8 + 2 * x)", "[\"8 + 2 * x ~= 0\"]")
|
neuper@52095
|
580 |
then () else error "rational.sml cancel_p Schalk 193b";
|
neuper@52092
|
581 |
|
neuper@52092
|
582 |
"-------- example 193c";
|
neuper@52092
|
583 |
val t = str2term "( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
|
neuper@52095
|
584 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
585 |
if (term2str t', terms2str asm) =
|
neuper@52095
|
586 |
("(2 * x + 10 * x ^^^ 2) / (1 + -5 * x)", "[\"1 + -5 * x ~= 0\"]")
|
neuper@52095
|
587 |
then () else error "rational.sml cancel_p Schalk 193c";
|
neuper@52092
|
588 |
|
neuper@52092
|
589 |
(*WN:*)
|
neuper@52092
|
590 |
val t = str2term "(-25 + 9*x^^^2)/(5 + 3*x)";
|
neuper@52095
|
591 |
val SOME (t, asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52095
|
592 |
if (term2str t', terms2str asm) = ("(2 * x + 10 * x ^^^ 2) / (1 + -5 * x)", "[]")
|
neuper@52092
|
593 |
then () else error "rational.sml cancel WN 1";
|
neuper@52092
|
594 |
|
neuper@52101
|
595 |
"-------- example heuberger";
|
neuper@52101
|
596 |
val t = str2term ("(x^^^4 + x * y + x^^^3 * y + y^^^2) / " ^
|
neuper@52101
|
597 |
"(x + 5 * x^^^2 + y + 5 * x * y + x^^^2 * y^^^3 + x * y^^^4)");
|
neuper@52101
|
598 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52101
|
599 |
if (term2str t', terms2str asm) =
|
neuper@52101
|
600 |
("(x ^^^ 3 + y) / (1 + 5 * x + x * y ^^^ 3)", "[\"1 + 5 * x + x * y ^^^ 3 ~= 0\"]")
|
neuper@52101
|
601 |
then () else error "rational.sml cancel_p heuberger";
|
neuper@52092
|
602 |
|
neuper@52105
|
603 |
"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
|
neuper@52105
|
604 |
"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
|
neuper@52105
|
605 |
"-------- rewrite_set_ add_fractions_p from: Mathematik 1 Schalk -------------";
|
neuper@52101
|
606 |
(*deleted example 204 ... 236b at update Isabelle2012-->2013*)
|
neuper@52092
|
607 |
|
neuper@52105
|
608 |
"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
|
neuper@52105
|
609 |
"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
|
neuper@52105
|
610 |
"-------- integration lev.1 -- lev.5: cancel_p_ & add_fractions_p_ -----------";
|
neuper@52100
|
611 |
val t = str2term ("123 = (a*x)/(b*x) + (c*x)/(d*x) + (e*x)/(f*x::real)");
|
neuper@52100
|
612 |
"-------- gcd_poly integration level 1: works on exact term";
|
neuper@52100
|
613 |
if NONE = cancel_p_ thy t then () else error "cancel_p_ works on exact fraction";
|
neuper@52100
|
614 |
if NONE = add_fraction_p_ thy t then () else error "add_fraction_p_ works on exact fraction";
|
neuper@52100
|
615 |
|
neuper@52100
|
616 |
"-------- gcd_poly integration level 2: picks out ONE appropriate subterm";
|
neuper@52100
|
617 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p t;
|
neuper@52100
|
618 |
if term2str t' = "123 = a * x / (b * x) + c * x / (d * x) + e / f"
|
neuper@52100
|
619 |
then () else error "level 2, rewrite_set_ cancel_p: changed";
|
neuper@52100
|
620 |
val SOME (t', asm) = rewrite_set_ thy false add_fractions_p t;
|
neuper@52100
|
621 |
if term2str t' = "123 = (b * c * x + a * d * x) / (b * d * x) + e * x / (f * x)"
|
neuper@52100
|
622 |
then () else error "level 2, rewrite_set_ add_fractions_p: changed";
|
neuper@52100
|
623 |
|
neuper@52100
|
624 |
"-------- gcd_poly integration level 3: rewrites all appropriate subterms";
|
neuper@52100
|
625 |
val SOME (t', asm) = rewrite_set_ thy false cancel_p_rls t;
|
neuper@52100
|
626 |
if term2str t' = "123 = a / b + c / d + e / f"
|
neuper@52100
|
627 |
then () else error "level 3, rewrite_set_ cancel_p_rls: changed";
|
neuper@52105
|
628 |
val SOME (t', asm) = rewrite_set_ thy false add_fractions_p_rls t; (*CREATE add_fractions_p_rls*)
|
neuper@52100
|
629 |
if term2str t' = "123 = (b * d * e * x + b * c * f * x + a * d * f * x) / (b * d * f * x)"
|
neuper@52100
|
630 |
then () else error "level 3, rewrite_set_ add_fractions_p_rls: changed";
|
neuper@52100
|
631 |
|
neuper@52100
|
632 |
"-------- gcd_poly integration level 4: iteration cancel_p -- add_fraction_p";
|
neuper@52100
|
633 |
(* simpler variant *)
|
neuper@52100
|
634 |
val testrls = append_rls "testrls" e_rls [Rls_ cancel_p, Rls_ add_fractions_p]
|
neuper@52100
|
635 |
val SOME (t', asm) = rewrite_set_ thy false testrls t;
|
neuper@52100
|
636 |
(*trace_rewrite := false;
|
neuper@52100
|
637 |
# rls: testrls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x)
|
neuper@52100
|
638 |
## rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x)
|
neuper@52105
|
639 |
## rls: add_fractions_p on: 123 = a * x / (b * x) + c * x / (d * x) + e / f
|
neuper@52100
|
640 |
## rls: cancel_p on: 123 = (b * c * x + a * d * x) / (b * d * x) + e / f
|
neuper@52105
|
641 |
## rls: add_fractions_p on: 123 = (b * c + a * d) / (b * d) + e / f
|
neuper@52100
|
642 |
## rls: cancel_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)
|
neuper@52105
|
643 |
## rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) *)
|
neuper@52100
|
644 |
if term2str t' = "123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)"
|
neuper@52100
|
645 |
then () else error "level 4, rewrite_set_ *_p: changed";
|
neuper@52100
|
646 |
|
neuper@52100
|
647 |
(* complicated variant *)
|
neuper@52105
|
648 |
val testrls_rls = append_rls "testrls_rls" e_rls [Rls_ cancel_p_rls, Rls_ add_fractions_p_rls];
|
neuper@52100
|
649 |
val SOME (t', asm) = rewrite_set_ thy false testrls_rls t;
|
neuper@52100
|
650 |
(*# rls: testrls_rls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x)
|
neuper@52100
|
651 |
## rls: cancel_p_rls on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x)
|
neuper@52100
|
652 |
### rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e * x / (f * x)
|
neuper@52100
|
653 |
### rls: cancel_p on: 123 = a * x / (b * x) + c * x / (d * x) + e / f
|
neuper@52100
|
654 |
### rls: cancel_p on: 123 = a * x / (b * x) + c / d + e / f
|
neuper@52100
|
655 |
### rls: cancel_p on: 123 = a / b + c / d + e / f
|
neuper@52105
|
656 |
## rls: add_fractions_p_rls on: 123 = a / b + c / d + e / f
|
neuper@52105
|
657 |
### rls: add_fractions_p on: 123 = a / b + c / d + e / f
|
neuper@52105
|
658 |
### rls: add_fractions_p on: 123 = (b * c + a * d) / (b * d) + e / f
|
neuper@52105
|
659 |
### rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)
|
neuper@52100
|
660 |
## rls: cancel_p_rls on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)
|
neuper@52100
|
661 |
### rls: cancel_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)
|
neuper@52105
|
662 |
## rls: add_fractions_p_rls on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)
|
neuper@52105
|
663 |
### rls: add_fractions_p on: 123 = (b * d * e + b * c * f + a * d * f) / (b * d * f) *)
|
neuper@52100
|
664 |
if term2str t' = "123 = (b * d * e + b * c * f + a * d * f) / (b * d * f)"
|
neuper@52100
|
665 |
then () else error "level 4, rewrite_set_ *_p_rls: changed"
|
neuper@52100
|
666 |
|
neuper@52100
|
667 |
"-------- gcd_poly integration level 5: cancel_p & add_fraction_p within norm_Rational";
|
neuper@52100
|
668 |
val SOME (t', asm) = rewrite_set_ thy false norm_Rational t;
|
neuper@52100
|
669 |
if term2str t' = "123 = (a * d * f + b * c * f + b * d * e) / (b * d * f)"
|
neuper@52100
|
670 |
then () else error "level 5, rewrite_set_ norm_Rational: changed"
|
neuper@37906
|
671 |
|
neuper@52101
|
672 |
"-------- reverse rewrite ----------------------------------------------------";
|
neuper@52101
|
673 |
"-------- reverse rewrite ----------------------------------------------------";
|
neuper@52101
|
674 |
"-------- reverse rewrite ----------------------------------------------------";
|
neuper@52101
|
675 |
(** the term for which reverse rewriting is demonstrated **)
|
neuper@52101
|
676 |
val t = str2term "(9 + -1 * x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
|
neuper@52101
|
677 |
val Rrls {scr = Rfuns {init_state = ini, locate_rule = loc,
|
neuper@52101
|
678 |
next_rule = nex, normal_form = nor, ...},...} = cancel_p;
|
neuper@37906
|
679 |
|
neuper@52101
|
680 |
(** normal_form produces the result in ONE step **)
|
neuper@37926
|
681 |
val SOME (t',_) = nor t;
|
neuper@52101
|
682 |
if term2str t' = "(3 + -1 * x) / (3 + x)" then ()
|
neuper@38044
|
683 |
else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@37906
|
684 |
|
neuper@52101
|
685 |
(** initialize the interpreter state used by the 'me' **)
|
neuper@52101
|
686 |
val (t, _, revsets, _) = ini t;
|
neuper@37906
|
687 |
|
neuper@52101
|
688 |
if length (hd revsets) = 11 then () else error "length of revset changed";
|
neuper@52101
|
689 |
if (revsets |> nth 1 |> nth 1 |> id_of_thm) =
|
neuper@52101
|
690 |
(@{thm realpow_twoI} |> string_of_thm |> thmID_of_derivation_name)
|
neuper@52101
|
691 |
then () else error "first element of revset changed";
|
neuper@52101
|
692 |
if
|
neuper@52101
|
693 |
(revsets |> nth 1 |> nth 1 |> rule2str) = "Thm (\"realpow_twoI\",??.unknown)" andalso
|
neuper@52101
|
694 |
(revsets |> nth 1 |> nth 2 |> rule2str) =
|
neuper@52101
|
695 |
"Thm (\"sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))\",??.unknown)" andalso
|
neuper@52101
|
696 |
(revsets |> nth 1 |> nth 3 |> rule2str) =
|
neuper@52101
|
697 |
"Thm (\"sym_#mult_Float ((2,0), (0,0)) __ ((3,0), (0,0))\",??.unknown)" andalso
|
neuper@52101
|
698 |
(revsets |> nth 1 |> nth 4 |> rule2str) =
|
neuper@52101
|
699 |
"Thm (\"sym_#mult_Float ((~1,0), (0,0)) __ ((3,0), (0,0))\",??.unknown)" andalso
|
neuper@52101
|
700 |
(revsets |> nth 1 |> nth 5 |> rule2str) =
|
neuper@52101
|
701 |
"Thm (\"sym_#mult_Float ((3,0), (0,0)) __ ((3,0), (0,0))\",??.unknown)" andalso
|
neuper@52101
|
702 |
(revsets |> nth 1 |> nth 6 |> rule2str) = "Rls_ (\"sym_order_mult_rls_\")" andalso
|
neuper@52101
|
703 |
(revsets |> nth 1 |> nth 7 |> rule2str) =
|
neuper@52101
|
704 |
"Thm (\"sym_mult_assoc\",Groups.semigroup_mult_class.mult_assoc)"
|
neuper@52101
|
705 |
then () else error "first 7 elements in revset changed"
|
neuper@52101
|
706 |
|
neuper@52101
|
707 |
(** find the rule 'r' to apply to term 't' **)
|
neuper@52105
|
708 |
(*/------- WN1309: since cancel_ (accepted "-" between monomials) has been replaced by cancel_p_
|
neuper@52101
|
709 |
for Isabelle2013, we don't get a working revset, but non-termination:
|
neuper@52101
|
710 |
|
neuper@38044
|
711 |
val SOME (r as (Thm (str, thm))) = nex revsets t;
|
neuper@52101
|
712 |
:
|
neuper@52101
|
713 |
((3 * 3 + -1 * x * x) / (3 * 3 + 2 * 3 * x + x * x),
|
neuper@52101
|
714 |
Rls_ ("sym_order_mult_rls_"), ((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x), []))","
|
neuper@52101
|
715 |
((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x),
|
neuper@52101
|
716 |
Thm ("sym_mult_assoc",""), ((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * 3 * x + x * x), []))","
|
neuper@52101
|
717 |
((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * 3 * x + x * x),
|
neuper@52101
|
718 |
Thm ("sym_mult_assoc",""), ((3 * 3 + -1 * x * x) / (3 * 3 + 2 * 3 * x + x * x), []))","
|
neuper@52101
|
719 |
((3 * 3 + -1 * x * x) / (3 * 3 + 2 * 3 * x + x * x), Rls_ ("sym_order_mult_rls_"), ((3 * 3 + -1 * (x * x)) / (3 * 3 + 2 * (3 * x) + x * x), []))","
|
neuper@52101
|
720 |
:
|
neuper@52101
|
721 |
### Isabelle2002:
|
neuper@52101
|
722 |
Thm ("sym_#mult_2_3", "6 = 2 * 3")
|
neuper@52101
|
723 |
### Isabelle2009-2 for cancel_ (not cancel_p_):
|
neuper@38044
|
724 |
if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
|
neuper@38044
|
725 |
andalso string_of_thm thm =
|
neuper@41929
|
726 |
(string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
|
neuper@38044
|
727 |
(Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
|
neuper@38044
|
728 |
else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@52101
|
729 |
\---------------------------------------------------------------------------------------/*)
|
neuper@37906
|
730 |
|
neuper@52101
|
731 |
(** check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
|
neuper@37906
|
732 |
if the rule is OK, the term resulting from applying the rule is returned,too;
|
neuper@37906
|
733 |
there might be several rule applications inbetween,
|
neuper@52101
|
734 |
which are listed after the head in reverse order **)
|
neuper@52101
|
735 |
(*/-------------------------------------------- Isabelle2013: this gives "error id_of_thm";
|
neuper@52101
|
736 |
we don't repair this, because interaction within "reverse rewriting" never worked properly:
|
neuper@52101
|
737 |
|
neuper@38044
|
738 |
val (r, (t, asm))::_ = loc revsets t r;
|
neuper@38044
|
739 |
if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
|
neuper@52101
|
740 |
then () else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@37906
|
741 |
|
neuper@38044
|
742 |
(* find the next rule to apply *)
|
neuper@38044
|
743 |
val SOME (r as (Thm (str, thm))) = nex revsets t;
|
neuper@38044
|
744 |
if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
|
neuper@41929
|
745 |
string_of_thm thm = (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
|
neuper@38044
|
746 |
(Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
|
neuper@38044
|
747 |
else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@37906
|
748 |
|
neuper@37906
|
749 |
(*check the next rule*)
|
neuper@38044
|
750 |
val (r, (t, asm)) :: _ = loc revsets t r;
|
neuper@38044
|
751 |
if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
|
neuper@38044
|
752 |
else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
|
neuper@37906
|
753 |
|
neuper@37906
|
754 |
(*find and check the next rules, rewrite*)
|
neuper@37926
|
755 |
val SOME r = nex revsets t;
|
neuper@37906
|
756 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@38044
|
757 |
if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
|
neuper@38044
|
758 |
else error "rational.sml locate_rule II";
|
neuper@37906
|
759 |
|
neuper@37926
|
760 |
val SOME r = nex revsets t;
|
neuper@37906
|
761 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@38044
|
762 |
if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
|
neuper@38044
|
763 |
else error "rational.sml next_rule II";
|
neuper@37906
|
764 |
|
neuper@37926
|
765 |
val SOME r = nex revsets t;
|
neuper@37906
|
766 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@38044
|
767 |
if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
|
neuper@38044
|
768 |
else error "rational.sml next_rule III";
|
neuper@37906
|
769 |
|
neuper@37926
|
770 |
val SOME r = nex revsets t;
|
neuper@38044
|
771 |
val (r, (t, asm)) :: _ = loc revsets t r;
|
neuper@37906
|
772 |
val ss = term2str t;
|
neuper@38044
|
773 |
if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
|
neuper@38044
|
774 |
else error "rational.sml: new behav. in rev-set cancel";
|
neuper@52101
|
775 |
\--------------------------------------------------------------------------------------/*)
|
neuper@37906
|
776 |
|
neuper@52101
|
777 |
"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
|
neuper@52101
|
778 |
"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
|
neuper@52101
|
779 |
"-------- 'reverse-ruleset' cancel_p -----------------------------------------";
|
neuper@52105
|
780 |
(*WN130909: the example below shows, why "reverse rewriting" only worked for
|
neuper@52101
|
781 |
special cases.*)
|
neuper@37906
|
782 |
|
neuper@37906
|
783 |
(*the term for which reverse rewriting is demonstrated*)
|
neuper@37906
|
784 |
val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
|
neuper@37906
|
785 |
val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
|
neuper@37906
|
786 |
next_rule=nex,normal_form=nor,...},...} = cancel_p;
|
neuper@37906
|
787 |
|
neuper@37906
|
788 |
(*normal_form produces the result in ONE step*)
|
neuper@37926
|
789 |
val SOME (t',_) = nor t;
|
neuper@37906
|
790 |
term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
|
neuper@37906
|
791 |
|
neuper@37906
|
792 |
(*initialize the interpreter state used by the 'me'*)
|
neuper@37926
|
793 |
val SOME (t', asm) = cancel_p_ thy t;
|
neuper@37906
|
794 |
term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
|
neuper@37906
|
795 |
terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
|
neuper@37906
|
796 |
val (t,_,revsets,_) = ini t;
|
neuper@37906
|
797 |
|
neuper@37906
|
798 |
(* WN.10.10.02: dieser Fall terminiert nicht
|
neuper@37906
|
799 |
(make_polynomial enth"alt zu viele rules)
|
neuper@37906
|
800 |
WN060823 'init_state' requires rewriting on specified location in the term
|
neuper@37906
|
801 |
print_depth 99; Rfuns; print_depth 3;
|
neuper@48763
|
802 |
WN060831 cycling "sym_order_mult_rls_" "sym_mult_assoc"
|
neuper@37906
|
803 |
as was with make_polynomial before ?!?*)
|
neuper@37906
|
804 |
|
neuper@37926
|
805 |
val SOME r = nex revsets t;
|
neuper@37906
|
806 |
eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
|
neuper@38041
|
807 |
mk_thm thy "9 = 3 ^^^ 2"));
|
neuper@37906
|
808 |
(*WN060831 *** id_of_thm
|
neuper@37906
|
809 |
Exception- ERROR raised ...
|
neuper@37906
|
810 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@37906
|
811 |
term2str t;
|
neuper@37906
|
812 |
|
neuper@37926
|
813 |
val SOME r = nex revsets t;
|
neuper@37906
|
814 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@37906
|
815 |
term2str t;
|
neuper@52101
|
816 |
*)
|
neuper@37906
|
817 |
|
neuper@52101
|
818 |
"-------- examples: rls norm_Rational ----------------------------------------";
|
neuper@52101
|
819 |
"-------- examples: rls norm_Rational ----------------------------------------";
|
neuper@52101
|
820 |
"-------- examples: rls norm_Rational ----------------------------------------";
|
neuper@37906
|
821 |
val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
|
neuper@37926
|
822 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
823 |
if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
|
neuper@37906
|
824 |
|
neuper@37906
|
825 |
val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
|
neuper@37926
|
826 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
827 |
if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
|
neuper@38031
|
828 |
else error "rational.sml 2";
|
neuper@37906
|
829 |
|
neuper@37906
|
830 |
val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
|
neuper@37926
|
831 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
832 |
if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
|
neuper@38031
|
833 |
else error "rational.sml 3";
|
neuper@38046
|
834 |
|
neuper@37906
|
835 |
(*trace_rewrite:=true;*)
|
neuper@37906
|
836 |
val t = str2term "Not (6*x is_atom)";
|
neuper@37926
|
837 |
val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
|
neuper@41928
|
838 |
"HOL.True";
|
neuper@37906
|
839 |
val t = str2term "1 < 2";
|
neuper@37926
|
840 |
val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
|
neuper@41928
|
841 |
"HOL.True";
|
neuper@38046
|
842 |
|
neuper@37906
|
843 |
val t = str2term "(6*x)^^^2";
|
neuper@37926
|
844 |
val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
|
neuper@38041
|
845 |
(num_str @{thm realpow_def_atom}) t;
|
neuper@38046
|
846 |
if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
|
neuper@38046
|
847 |
else error "rational.sml powers_erls (6*x)^^^2";
|
neuper@37906
|
848 |
|
neuper@37906
|
849 |
val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
|
neuper@37926
|
850 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
851 |
if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
|
neuper@37906
|
852 |
|
neuper@37906
|
853 |
val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
|
neuper@37926
|
854 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
855 |
if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
|
neuper@38031
|
856 |
else error "rational.sml 5";
|
neuper@37906
|
857 |
|
neuper@37906
|
858 |
(*SRAM Schalk I, p.92 Nr. 609a*)
|
neuper@37906
|
859 |
val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
|
neuper@37926
|
860 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
861 |
if term2str t' = "(-255 + 112 * x) / 135" then ()
|
neuper@38031
|
862 |
else error "rational.sml 6";
|
neuper@37906
|
863 |
|
neuper@37906
|
864 |
(*SRAM Schalk I, p.92 Nr. 610c*)
|
neuper@37906
|
865 |
val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
|
neuper@37926
|
866 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
867 |
if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
|
neuper@37906
|
868 |
|
neuper@37906
|
869 |
(*SRAM Schalk I, p.92 Nr. 476a*)
|
neuper@38046
|
870 |
val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
|
neuper@38046
|
871 |
(*. a/b : c/d translated to a/b * d/c .*)
|
neuper@37926
|
872 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
873 |
if term2str t' = "1" then () else error "rational.sml 8";
|
neuper@37906
|
874 |
|
neuper@37906
|
875 |
(*Schalk I, p.92 Nr. 472a*)
|
neuper@37906
|
876 |
val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
|
neuper@37926
|
877 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
878 |
if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
|
neuper@37906
|
879 |
|
neuper@52105
|
880 |
(*Schalk I, p.70 Nr. 480b: SEE rational.sml --- nonterminating rls norm_Rational ---*)
|
neuper@37906
|
881 |
|
neuper@52105
|
882 |
(*WN130910 add_fractions_p exception Div raised + history:
|
neuper@52105
|
883 |
### WN.2.6.03 from rlang.sml 56a
|
neuper@37906
|
884 |
val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x) = 4 * (a * b) / (a ^^^ 2 + -1 * b ^^^ 2)";
|
neuper@52105
|
885 |
val NONE = rewrite_set_ thy false add_fractions_p t;
|
neuper@37906
|
886 |
|
neuper@52105
|
887 |
THE ERROR ALREADY OCCURS IN THIS PART:
|
neuper@37906
|
888 |
val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
|
neuper@52105
|
889 |
val NONE = add_fraction_p_ thy t;
|
neuper@52105
|
890 |
|
neuper@52105
|
891 |
SEE Test_Some.thy: section {* add_fractions_p downto exception Div raised ===
|
neuper@37906
|
892 |
*)
|
neuper@37906
|
893 |
|
neuper@52105
|
894 |
"-------- rational numerals --------------------------------------------------";
|
neuper@52105
|
895 |
"-------- rational numerals --------------------------------------------------";
|
neuper@52105
|
896 |
"-------- rational numerals --------------------------------------------------";
|
neuper@37906
|
897 |
(*SRA Schalk I, p.40 Nr. 164b *)
|
neuper@37906
|
898 |
val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
|
neuper@52105
|
899 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
900 |
term2str t;
|
neuper@52105
|
901 |
if term2str t = "19 / 21" then ()
|
neuper@38046
|
902 |
else error "rational.sml: diff.behav. in norm_Rational_mg 1";
|
neuper@37906
|
903 |
|
neuper@37906
|
904 |
(*SRA Schalk I, p.40 Nr. 166a *)
|
neuper@37906
|
905 |
val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
|
neuper@52105
|
906 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
907 |
term2str t;
|
neuper@52105
|
908 |
if term2str t = "45 / 2" then ()
|
neuper@38046
|
909 |
else error "rational.sml: diff.behav. in norm_Rational_mg 2";
|
neuper@37906
|
910 |
|
neuper@52105
|
911 |
"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
|
neuper@52105
|
912 |
"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
|
neuper@52105
|
913 |
"-------- examples cancellation from: Mathematik 1 Schalk --------------------";
|
neuper@37906
|
914 |
(* e190c Stefan K.*)
|
neuper@52105
|
915 |
val t = str2term "((1 + 9*a^^^2) * (1 + 3*a)) / ((3*a + 9*a^^^2) * (1 + 3*a))";
|
neuper@52105
|
916 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
917 |
if term2str t = "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
|
neuper@52105
|
918 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 3";
|
neuper@37906
|
919 |
|
neuper@37906
|
920 |
(* e192b Stefan K.*)
|
neuper@52105
|
921 |
val t = str2term "(x^^^2 * (7*x + (-1)*y)) / (y^^^2 * (7*x + (-1)*y))";
|
neuper@52105
|
922 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
923 |
if term2str t = "x ^^^ 2 / y ^^^ 2"
|
neuper@52105
|
924 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 4";
|
neuper@37906
|
925 |
|
neuper@37906
|
926 |
(*SRC Schalk I, p.66 Nr. 379c *)
|
neuper@52105
|
927 |
val t = str2term "(a - b)/(b - a)";
|
neuper@52105
|
928 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
929 |
term2str t;
|
neuper@52105
|
930 |
if term2str t = "-1"
|
neuper@52105
|
931 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 5";
|
neuper@37906
|
932 |
|
neuper@37906
|
933 |
(*SRC Schalk I, p.66 Nr. 380b *)
|
neuper@52105
|
934 |
val t = str2term "15*(3*x + 3) * (4*x + 9) / (12*(2*x + 7) * (5*x + 5))";
|
neuper@52105
|
935 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
936 |
if term2str t = "(27 + 12 * x) / (28 + 8 * x)"
|
neuper@52105
|
937 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 6";
|
neuper@37906
|
938 |
|
neuper@52105
|
939 |
(*Schalk I, p.60 Nr. 215c: was not cancelled with Isabelle2002 *)
|
neuper@52105
|
940 |
val t = str2term "(a + b)^^^4 * (x - y) / ((x - y)^^^3 * (a + b)^^^2)";
|
neuper@52105
|
941 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
942 |
if term2str t = "(a ^^^ 2 + 2 * a * b + b ^^^ 2) / (x ^^^ 2 + -2 * x * y + y ^^^ 2)"
|
neuper@52105
|
943 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 7";
|
neuper@37906
|
944 |
|
neuper@37906
|
945 |
(*SRC Schalk I, p.66 Nr. 381b *)
|
neuper@37906
|
946 |
val t = str2term
|
neuper@37906
|
947 |
"(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
|
neuper@52105
|
948 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
949 |
if term2str t = "1 / (-5 + 2 * x)"
|
neuper@52105
|
950 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 9";
|
neuper@52105
|
951 |
|
neuper@52105
|
952 |
(* e190c Stefan K.*)
|
neuper@52105
|
953 |
val t = str2term "((1 + 9*a^^^2) * (1 + 3*a)) / ((3*a + 9*a^^^2) * (1 + 3 * a))";
|
neuper@52105
|
954 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
955 |
if term2str t = "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
|
neuper@52105
|
956 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 3";
|
neuper@52105
|
957 |
|
neuper@52105
|
958 |
(* e192b Stefan K.*)
|
neuper@52105
|
959 |
val t = str2term "(x^^^2 * (7*x + (-1)*y)) / (y^^^2 * (7*x + (-1)*y))";
|
neuper@52105
|
960 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
961 |
if term2str t = "x ^^^ 2 / y ^^^ 2"
|
neuper@52105
|
962 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 4";
|
neuper@52105
|
963 |
|
neuper@52105
|
964 |
(*SRC Schalk I, p.66 Nr. 379c *)
|
neuper@52105
|
965 |
val t = str2term "(a - b) / (b - a)";
|
neuper@52105
|
966 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
967 |
if term2str t = "-1"
|
neuper@52105
|
968 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 5";
|
neuper@52105
|
969 |
|
neuper@52105
|
970 |
(*SRC Schalk I, p.66 Nr. 380b *)
|
neuper@52105
|
971 |
val t = str2term "15*(3*x + 3) * (4*x + 9) / (12*(2*x + 7) * (5*x + 5))";
|
neuper@52105
|
972 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
973 |
if term2str t = "(27 + 12 * x) / (28 + 8 * x)"
|
neuper@52105
|
974 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 6";
|
neuper@52105
|
975 |
|
neuper@52105
|
976 |
(*Schalk I, p.60 Nr. 215c *)
|
neuper@52105
|
977 |
val t = str2term "(a + b)^^^4 * (x - y) / ((x - y)^^^3 * (a + b)^^^2)";
|
neuper@52105
|
978 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
979 |
if term2str t = "(a ^^^ 2 + 2 * a * b + b ^^^ 2) / (x ^^^ 2 + -2 * x * y + y ^^^ 2)"
|
neuper@52105
|
980 |
then () else error "Schalk I, p.60 Nr. 215c: with Isabelle2002 cancellation incomplete, changed";
|
neuper@52105
|
981 |
|
neuper@52105
|
982 |
(* extreme example from somewhere *)
|
neuper@52105
|
983 |
val t = str2term
|
neuper@52105
|
984 |
("(a^^^4 * x + -1*a^^^4 * y + 4*a^^^3 * b * x + -4*a^^^3 * b * y + " ^
|
neuper@52105
|
985 |
"6*a^^^2 * b^^^2 * x + -6*a^^^2 * b^^^2 * y + 4*a * b^^^3 * x + -4*a * b^^^3 * y + " ^
|
neuper@52105
|
986 |
"b^^^4 * x + -1*b^^^4 * y) " ^
|
neuper@52105
|
987 |
" / (a^^^2 * x^^^3 + -3*a^^^2 * x^^^2 * y + 3*a^^^2 * x * y^^^2 + -1*a^^^2 * y^^^3 + " ^
|
neuper@52105
|
988 |
"2*a * b * x^^^3 + -6*a * b * x^^^2 * y + 6*a * b * x * y^^^2 + -2*a * b * y^^^3 + " ^
|
neuper@52105
|
989 |
"b^^^2 * x^^^3 + -3*b^^^2 * x^^^2 * y + 3*b^^^2 * x * y^^^2 + -1*b ^^^ 2 * y ^^^ 3)")
|
neuper@52105
|
990 |
val SOME (t, _) = rewrite_set_ thy false cancel_p t;
|
neuper@52105
|
991 |
if term2str t = "(a ^^^ 2 + 2 * a * b + b ^^^ 2) / (x ^^^ 2 + -2 * x * y + y ^^^ 2)"
|
neuper@52105
|
992 |
then () else error "with Isabelle2002: NONE -- now SOME changed";
|
neuper@52105
|
993 |
|
neuper@52105
|
994 |
(*Schalk I, p.66 Nr. 381a *)
|
neuper@52105
|
995 |
(* ATTENTION: here the rls is very slow. In Isabelle2002 this required 2 min *)
|
neuper@52105
|
996 |
val t = str2term "18*(a + b)^^^3 * (a - b)^^^2 / (72*(a - b)^^^3 * (a + b)^^^2)";
|
neuper@52105
|
997 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
998 |
if term2str t = "(a + b) / (4 * a + -4 * b)"
|
neuper@52105
|
999 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
|
neuper@52105
|
1000 |
|
neuper@52105
|
1001 |
(*SRC Schalk I, p.66 Nr. 381b *)
|
neuper@52105
|
1002 |
val t = str2term "(4*x^^^2 - 20*x + 25) / (2*x - 5)^^^3";
|
neuper@52105
|
1003 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1004 |
if term2str t = "1 / (-5 + 2 * x)"
|
neuper@52105
|
1005 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 9";
|
neuper@37906
|
1006 |
|
neuper@37906
|
1007 |
(*SRC Schalk I, p.66 Nr. 381c *)
|
neuper@52105
|
1008 |
val t = str2term "(27*a^^^3 + 9*a^^^2+3*a+1) / (27*a^^^3 + 18*a^^^2+3*a)";
|
neuper@52105
|
1009 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1010 |
if term2str t = "(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
|
neuper@52105
|
1011 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 10";
|
neuper@37906
|
1012 |
|
neuper@37906
|
1013 |
(*SRC Schalk I, p.66 Nr. 383a *)
|
neuper@52105
|
1014 |
val t = str2term "(5*a^^^2 - 5*a*b) / (a - b)^^^2";
|
neuper@52105
|
1015 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1016 |
if term2str t = "-5 * a / (-1 * a + b)"
|
neuper@52105
|
1017 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 11";
|
neuper@37906
|
1018 |
|
neuper@52105
|
1019 |
"----- NOT TERMINATING ?: worked before 0707xx";
|
neuper@52105
|
1020 |
val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
|
neuper@52105
|
1021 |
(* WN130911 "exception Div raised" by
|
neuper@52105
|
1022 |
cancel_p_ thy (str2term ("(-1 + -1 * b + a ^^^ 2 + a ^^^ 2 * b) /" ^
|
neuper@52105
|
1023 |
"(-1 + -1 * a + b ^^^ 2 + a * b ^^^ 2)"))
|
neuper@37906
|
1024 |
|
neuper@52105
|
1025 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1026 |
if term2str t = "(1 + -1 * a) / (1 + -1 * b)" then ()
|
neuper@52105
|
1027 |
else error "rational.sml MG tests 3e";
|
neuper@52105
|
1028 |
*)
|
neuper@52105
|
1029 |
|
neuper@52105
|
1030 |
"-------- examples common denominator from: Mathematik 1 Schalk --------------";
|
neuper@52105
|
1031 |
"-------- examples common denominator from: Mathematik 1 Schalk --------------";
|
neuper@52105
|
1032 |
"-------- examples common denominator from: Mathematik 1 Schalk --------------";
|
neuper@37906
|
1033 |
(*SRA Schalk I, p.67 Nr. 403a *)
|
neuper@52105
|
1034 |
val t = str2term "4/x - 3/y - 1";
|
neuper@52105
|
1035 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1036 |
if term2str t = "(-3 * x + 4 * y + -1 * x * y) / (x * y)"
|
neuper@52105
|
1037 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 12";
|
neuper@37906
|
1038 |
|
neuper@52105
|
1039 |
val t = str2term "(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
|
neuper@52105
|
1040 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1041 |
if term2str t = "4 / c"
|
neuper@52105
|
1042 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 13";
|
neuper@37906
|
1043 |
|
neuper@37906
|
1044 |
(*SRA Schalk I, p.67 Nr. 410b *)
|
neuper@52105
|
1045 |
val t = str2term "1/(x+1) + 1/(x+2) - 2/(x+3)";
|
neuper@52105
|
1046 |
(* WN130911 non-termination due to non-termination of
|
neuper@52105
|
1047 |
cancel_p_ thy (str2term "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)")
|
neuper@52105
|
1048 |
|
neuper@52105
|
1049 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1050 |
if term2str t = "(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
|
neuper@52105
|
1051 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 14";
|
neuper@52105
|
1052 |
*)
|
neuper@37906
|
1053 |
|
neuper@37906
|
1054 |
(*SRA Schalk I, p.67 Nr. 413b *)
|
neuper@52105
|
1055 |
val t = str2term "(1 + x)/(1 - x) - (1 - x)/(1 + x) + 2*x/(1 - x^^^2)";
|
neuper@52105
|
1056 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1057 |
if term2str t = "6 * x / (1 + -1 * x ^^^ 2)"
|
neuper@52105
|
1058 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 15";
|
neuper@37906
|
1059 |
|
neuper@37906
|
1060 |
(*SRA Schalk I, p.68 Nr. 414a *)
|
neuper@52105
|
1061 |
val t = str2term "(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
|
neuper@52105
|
1062 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1063 |
if term2str t ="(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
|
neuper@52105
|
1064 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 16";
|
neuper@37906
|
1065 |
|
neuper@37906
|
1066 |
(*SRA Schalk I, p.68 Nr. 428b *)
|
neuper@37906
|
1067 |
val t = str2term
|
neuper@52105
|
1068 |
"1/(a - b)^^^2 + 1/(a + b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
|
neuper@52105
|
1069 |
(* WN130911 non-termination due to non-termination of
|
neuper@52105
|
1070 |
cancel_p_ thy (str2term "(4 + -4 * b ^^^ 2) / (a ^^^ 4 + -2 * (a ^^^ 2 * b ^^^ 2) + b ^^^ 4)")
|
neuper@52105
|
1071 |
|
neuper@52105
|
1072 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1073 |
if term2str t = "4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
|
neuper@52105
|
1074 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 18";
|
neuper@52105
|
1075 |
*)
|
neuper@37906
|
1076 |
|
neuper@37906
|
1077 |
(*SRA Schalk I, p.68 Nr. 430b *)
|
neuper@37906
|
1078 |
val t = str2term
|
neuper@52105
|
1079 |
"a^^^2/(a - 3*b) - 108*a*b^^^3/((a+3*b)*(a^^^2 - 9*b^^^2)) - 9*b^^^2*(a - 3*b)/(a+3*b)^^^2";
|
neuper@52105
|
1080 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1081 |
if term2str t = "a + 3 * b"
|
neuper@52105
|
1082 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 19";
|
neuper@37906
|
1083 |
|
neuper@37906
|
1084 |
(*SRA Schalk I, p.68 Nr. 432 *)
|
neuper@37906
|
1085 |
val t = str2term
|
neuper@52105
|
1086 |
("(a^^^2 + a*b) / (a^^^2 - b^^^2) - (b^^^2 - a*b) / (b^^^2 - a^^^2) + " ^
|
neuper@52105
|
1087 |
"a^^^2*(a - b) / (a^^^3 - a^^^2*b) - 2*a*(a^^^2 - b^^^2) / (a^^^3 - a*b^^^2) - " ^
|
neuper@52105
|
1088 |
"2*b^^^2 / (a^^^2 - b^^^2)");
|
neuper@52105
|
1089 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1090 |
term2str t;
|
neuper@52105
|
1091 |
if term2str t = "0"
|
neuper@52105
|
1092 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 20";
|
neuper@37906
|
1093 |
|
neuper@52105
|
1094 |
(* some example *)
|
neuper@52105
|
1095 |
val t = str2term "3*a / (a*b) + x/y";
|
neuper@52105
|
1096 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1097 |
if term2str t = "(3 * y + b * x) / (b * y)"
|
neuper@52105
|
1098 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 21";
|
neuper@52105
|
1099 |
|
neuper@52105
|
1100 |
"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
|
neuper@52105
|
1101 |
"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
|
neuper@52105
|
1102 |
"-------- examples multiply and cancel from: Mathematik 1 Schalk -------------";
|
neuper@52105
|
1103 |
(*------- SRM Schalk I, p.68 Nr. 436a *)
|
neuper@52105
|
1104 |
val t = str2term "3*(x+y) / (15*(x - y)) * 25*(x - y)^^^2 / (18*(x + y)^^^2)";
|
neuper@52105
|
1105 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1106 |
if term2str t = "(-5 * x + 5 * y) / (-18 * x + -18 * y)"
|
neuper@52105
|
1107 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 22";
|
neuper@52105
|
1108 |
|
neuper@52105
|
1109 |
(*------- SRM.test Schalk I, p.68 Nr. 436b *)
|
neuper@52105
|
1110 |
val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
|
neuper@52105
|
1111 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1112 |
if term2str t = "5 * a / (a + -1 * b)"
|
neuper@52105
|
1113 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 23";
|
neuper@52105
|
1114 |
|
neuper@52105
|
1115 |
(*------- Schalk I, p.68 Nr. 437a *)
|
neuper@52105
|
1116 |
val t = str2term "(3*a - 4*b) / (4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
|
neuper@52105
|
1117 |
(* raises an exception for unclear reasons:
|
neuper@52105
|
1118 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1119 |
:
|
neuper@52105
|
1120 |
### rls: cancel_p on: (9 * a ^^^ 2 + -16 * b ^^^ 2) / (4 * c + 3 * e) /
|
neuper@52105
|
1121 |
(9 * a ^^^ 2 + -16 * b ^^^ 2)
|
neuper@52105
|
1122 |
exception Div raised
|
neuper@52105
|
1123 |
|
neuper@52105
|
1124 |
BUT
|
neuper@37906
|
1125 |
val t = str2term
|
neuper@52105
|
1126 |
("(9 * a ^^^ 2 + -16 * b ^^^ 2) / (4 * c + 3 * e) /" ^
|
neuper@52105
|
1127 |
"(9 * a ^^^ 2 + -16 * b ^^^ 2)");
|
neuper@52105
|
1128 |
NONE = cancel_p_ thy t;
|
neuper@37906
|
1129 |
|
neuper@52105
|
1130 |
if term2str t = "1 / (4 * c + 3 * e)" then ()
|
neuper@38046
|
1131 |
else error "rational.sml: diff.behav. in norm_Rational_mg 24";
|
neuper@52105
|
1132 |
*)
|
neuper@37906
|
1133 |
|
neuper@37906
|
1134 |
"----- S.K. corrected non-termination 060904";
|
neuper@37906
|
1135 |
val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
|
neuper@52105
|
1136 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
|
neuper@52105
|
1137 |
if term2str t =
|
neuper@41933
|
1138 |
"(9 * a ^^^ 2 + -16 * b ^^^ 2) /\n(36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c +\n -48 * b ^^^ 2 * e)"
|
neuper@41932
|
1139 |
(*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*)
|
neuper@41932
|
1140 |
then () else error "rational.sml: S.K.8..corrected 060904-6";
|
neuper@37906
|
1141 |
|
neuper@37906
|
1142 |
"----- S.K. corrected non-termination of cancel_p_";
|
neuper@38046
|
1143 |
val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
|
neuper@52105
|
1144 |
"(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
|
neuper@37926
|
1145 |
val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
|
neuper@52105
|
1146 |
if term2str t' = "1 / (4 * c + 3 * e)"
|
neuper@52105
|
1147 |
then () else error "rational.sml: diff.behav. in cancel_p S.K.8";
|
neuper@37906
|
1148 |
|
neuper@52105
|
1149 |
(*------- Schalk I, p.68 Nr. 437b*)
|
neuper@52105
|
1150 |
val t = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
|
neuper@52105
|
1151 |
(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1152 |
:
|
neuper@52105
|
1153 |
#### rls: cancel_p on: (a * x ^^^ 2 + -2 * (a * (x * y)) + a * y ^^^ 2 + b * x ^^^ 2 +
|
neuper@52105
|
1154 |
-2 * (b * (x * y)) +
|
neuper@52105
|
1155 |
b * y ^^^ 2) /
|
neuper@52105
|
1156 |
(a ^^^ 2 * x ^^^ 2 + -1 * (a ^^^ 2 * y ^^^ 2) + -1 * (b ^^^ 2 * x ^^^ 2) +
|
neuper@52105
|
1157 |
b ^^^ 2 * y ^^^ 2)
|
neuper@52105
|
1158 |
exception Div raised
|
neuper@37906
|
1159 |
*)
|
neuper@37906
|
1160 |
|
neuper@52105
|
1161 |
(*------- SRM Schalk I, p.68 Nr. 438a *)
|
neuper@52105
|
1162 |
val t = str2term "x*y / (x*y - y^^^2) * (x^^^2 - x*y)";
|
neuper@52105
|
1163 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1164 |
if term2str t = "x ^^^ 2"
|
neuper@52105
|
1165 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 24";
|
neuper@37906
|
1166 |
|
neuper@52105
|
1167 |
(*------- SRM Schalk I, p.68 Nr. 439b *)
|
neuper@52105
|
1168 |
val t = str2term "(4*x^^^2 + 4*x + 1) * ((x^^^2 - 2*x^^^3) / (4*x^^^2 + 2*x))";
|
neuper@52105
|
1169 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1170 |
if term2str t = "(x + -4 * x ^^^ 3) / 2"
|
neuper@52105
|
1171 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 25";
|
neuper@37906
|
1172 |
|
neuper@52105
|
1173 |
(*------- SRM Schalk I, p.68 Nr. 440a *)
|
neuper@52105
|
1174 |
val t = str2term "(x^^^2 - 2*x) / (x^^^2 - 3*x) * (x - 3)^^^2 / (x^^^2 - 4)";
|
neuper@52105
|
1175 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1176 |
if term2str t = "(-3 + x) / (2 + x)"
|
neuper@52105
|
1177 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 26";
|
neuper@37906
|
1178 |
|
neuper@37906
|
1179 |
"----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
|
neuper@52105
|
1180 |
val t = str2term "(a^^^3 - 9*a) / (a^^^3*b - a*b^^^3) * (a^^^2*b + a*b^^^2) / (a+3)";
|
neuper@52105
|
1181 |
(* WN130911 non-termination for unclear reasons:
|
neuper@52105
|
1182 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1183 |
|
neuper@52105
|
1184 |
... ENDS WITH THIS TRACE:
|
neuper@52105
|
1185 |
:
|
neuper@52105
|
1186 |
### rls: cancel_p on: (-9 * (a ^^^ 3 * b) + -9 * (a ^^^ 2 * b ^^^ 2) + a ^^^ 5 * b +
|
neuper@52105
|
1187 |
a ^^^ 4 * b ^^^ 2) /
|
neuper@52105
|
1188 |
(a ^^^ 3 * b + -1 * (a * b ^^^ 3)) /
|
neuper@52105
|
1189 |
(3 + a)
|
neuper@52105
|
1190 |
BUT THIS IS CORRECTLY RECOGNISED
|
neuper@37906
|
1191 |
val t = str2term
|
neuper@52105
|
1192 |
("(-9 * (a^^^3 * b) + -9 * (a^^^2 * b^^^2) + a^^^5 * b + a^^^4 * b^^^2) /" ^
|
neuper@52105
|
1193 |
"(a^^^3 * b + -1 * (a * b^^^3)) / (3 + (a::real))");
|
neuper@52105
|
1194 |
AS
|
neuper@52105
|
1195 |
NONE = cancel_p_ thy t;
|
neuper@52105
|
1196 |
|
neuper@37906
|
1197 |
if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
|
neuper@38046
|
1198 |
else error "rational.sml: diff.behav. in norm_Rational 27";
|
neuper@52105
|
1199 |
*)
|
neuper@37906
|
1200 |
|
neuper@37906
|
1201 |
"----- SK12 works since 0707xx";
|
neuper@52105
|
1202 |
val t = str2term "(a^^^3 - 9*a) * (a^^^2*b+a*b^^^2) / ((a^^^3*b - a*b^^^3) * (a+3))";
|
neuper@52105
|
1203 |
(* WN130911 non-termination due to non-termination of
|
neuper@52105
|
1204 |
cancel_p_ thy (str2term "(4 + -4 * b ^^^ 2) / (a ^^^ 4 + -2 * (a ^^^ 2 * b ^^^ 2) + b ^^^ 4)")
|
neuper@52105
|
1205 |
|
neuper@52105
|
1206 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1207 |
if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
|
neuper@38046
|
1208 |
else error "rational.sml: diff.behav. in norm_Rational 28";
|
neuper@52105
|
1209 |
*)
|
neuper@37906
|
1210 |
|
neuper@52105
|
1211 |
"-------- examples common denominator and multiplication from: Schalk --------";
|
neuper@52105
|
1212 |
"-------- examples common denominator and multiplication from: Schalk --------";
|
neuper@52105
|
1213 |
"-------- examples common denominator and multiplication from: Schalk --------";
|
neuper@52105
|
1214 |
(*------- SRAM Schalk I, p.69 Nr. 441b *)
|
neuper@37906
|
1215 |
val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
|
neuper@52105
|
1216 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1217 |
if term2str t = "(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
|
neuper@38046
|
1218 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
|
neuper@37906
|
1219 |
|
neuper@52105
|
1220 |
(*------- SRAM Schalk I, p.69 Nr. 442b *)
|
neuper@52105
|
1221 |
val t = str2term ("(15*a^^^2/x^^^3 - 5*b^^^4/x^^^2 + 25*c^^^2/x) * " ^
|
neuper@52105
|
1222 |
"(x^^^3/(5*a*b^^^3*c^^^3)) + 1/c^^^3 * (b*x/a - 3*a/b^^^3)");
|
neuper@52105
|
1223 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1224 |
if term2str t = "5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
|
neuper@38046
|
1225 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
|
neuper@37906
|
1226 |
|
neuper@52105
|
1227 |
(*------- SRAM Schalk I, p.69 Nr. 443b *)
|
neuper@52105
|
1228 |
val t = str2term "(a/2 + b/3) * (b/3 - a/2)";
|
neuper@52105
|
1229 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1230 |
if term2str t = "(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
|
neuper@38046
|
1231 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
|
neuper@37906
|
1232 |
|
neuper@52105
|
1233 |
(*------- SRAM Schalk I, p.69 Nr. 445b *)
|
neuper@37906
|
1234 |
val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
|
neuper@52105
|
1235 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1236 |
if term2str t = "a ^^^ 3 / 27"
|
neuper@38046
|
1237 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
|
neuper@37906
|
1238 |
|
neuper@52105
|
1239 |
(*------- SRAM Schalk I, p.69 Nr. 446b *)
|
neuper@37906
|
1240 |
val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
|
neuper@52105
|
1241 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1242 |
if term2str t = "30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
|
neuper@52105
|
1243 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 32";
|
neuper@37906
|
1244 |
|
neuper@52105
|
1245 |
(*------- SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
|
neuper@37906
|
1246 |
val t = str2term
|
neuper@37906
|
1247 |
"(2*x^^^2/(3*y)+x/y^^^2)*(4*x^^^4/(9*y^^^2)+x^^^2/y^^^4)*(2*x^^^2/(3*y) - x/y^^^2)";
|
neuper@52105
|
1248 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1249 |
if term2str t = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
|
neuper@38046
|
1250 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
|
neuper@38046
|
1251 |
|
neuper@52105
|
1252 |
(*------- SRAM Schalk I, p.69 Nr. 450a *)
|
neuper@37906
|
1253 |
val t = str2term
|
neuper@37906
|
1254 |
"(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
|
neuper@52105
|
1255 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1256 |
if term2str t = "(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
|
neuper@52105
|
1257 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 34";
|
neuper@37906
|
1258 |
|
neuper@52105
|
1259 |
(*------- SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
|
neuper@52105
|
1260 |
val t = str2term
|
neuper@52105
|
1261 |
("(15*a^^^4/(a*x^^^3) - 5*a*((b^^^4 - 5*c^^^2*x) / x^^^2)) * " ^
|
neuper@52105
|
1262 |
"(x^^^3/(5*a*b^^^3*c^^^3)) + a/c^^^3 * (x*(b/a) - 3*b*(a/b^^^4))");
|
neuper@52105
|
1263 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1264 |
if term2str t = "5 * x ^^^ 2 / (b ^^^ 3 * c)"
|
neuper@52105
|
1265 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 53";
|
neuper@37906
|
1266 |
|
neuper@37906
|
1267 |
|
neuper@52105
|
1268 |
"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
|
neuper@52105
|
1269 |
"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
|
neuper@52105
|
1270 |
"-------- examples double fractions from: Mathematik 1 Schalk ----------------";
|
neuper@52105
|
1271 |
"----- SRD Schalk I, p.69 Nr. 454b";
|
neuper@52105
|
1272 |
val t = str2term "((2 - x)/(2*a)) / (2*a/(x - 2))";
|
neuper@52105
|
1273 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1274 |
if term2str t = "(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
|
neuper@52105
|
1275 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 35";
|
neuper@52105
|
1276 |
|
neuper@52105
|
1277 |
"----- SRD Schalk I, p.69 Nr. 455a";
|
neuper@52105
|
1278 |
val t = str2term "(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
|
neuper@52105
|
1279 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1280 |
if term2str t = "(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
|
neuper@38046
|
1281 |
else error "rational.sml: diff.behav. in norm_Rational_mg 36";
|
neuper@37906
|
1282 |
|
neuper@37906
|
1283 |
"----- Schalk I, p.69 Nr. 455b";
|
neuper@37906
|
1284 |
val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
|
neuper@52105
|
1285 |
(* WN130911 non-termination due to non-termination of
|
neuper@52105
|
1286 |
cancel_p_ thy (str2term ("(-12 + 4 * y + 3 * x ^^^ 2 + -1 * (x ^^^ 2 * y)) /" ^
|
neuper@52105
|
1287 |
"(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)"))
|
neuper@52105
|
1288 |
|
neuper@52105
|
1289 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1290 |
if term2str t = "(2 + -1 * x) / (3 + y)" then ()
|
neuper@38046
|
1291 |
else error "rational.sml: diff.behav. in norm_Rational_mg 37";
|
neuper@52105
|
1292 |
*)
|
neuper@37906
|
1293 |
|
neuper@37906
|
1294 |
"----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
|
neuper@52105
|
1295 |
val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
|
neuper@52105
|
1296 |
(* WN130911 non-termination due to non-termination of
|
neuper@52105
|
1297 |
cancel_p_ thy (str2term ("(-12 + 4 * y + 3 * x ^^^ 2 + -1 * (x ^^^ 2 * y)) /" ^
|
neuper@52105
|
1298 |
"(-18 + -9 * x + 2 * y ^^^ 2 + x * y ^^^ 2)"))
|
neuper@52105
|
1299 |
|
neuper@52105
|
1300 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1301 |
if term2str t = "(2 + -1 * x) / (3 + y)" then ()
|
neuper@38046
|
1302 |
else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
|
neuper@52105
|
1303 |
*)
|
neuper@37906
|
1304 |
|
neuper@37906
|
1305 |
"----- ?: worked before 0707xx";
|
neuper@37906
|
1306 |
val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
|
neuper@52105
|
1307 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1308 |
if term2str t = "-1 / (3 + y)"
|
neuper@52105
|
1309 |
then () else error "rational.sml: -1 / (3 + y) norm_Rational";
|
neuper@37906
|
1310 |
|
neuper@52105
|
1311 |
"----- SRD Schalk I, p.69 Nr. 456b";
|
neuper@52105
|
1312 |
val t = str2term "(b^^^3 - b^^^2) / (b^^^2+b) / (b^^^2 - 1)";
|
neuper@52105
|
1313 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1314 |
if term2str t = "b / (1 + 2 * b + b ^^^ 2)"
|
neuper@52105
|
1315 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 38";
|
neuper@37906
|
1316 |
|
neuper@52105
|
1317 |
"----- SRD Schalk I, p.69 Nr. 457b";
|
neuper@52105
|
1318 |
val t = str2term "(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
|
neuper@52105
|
1319 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1320 |
if term2str t = "8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
|
neuper@41932
|
1321 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
|
neuper@37906
|
1322 |
|
neuper@37906
|
1323 |
"----- Schalk I, p.69 Nr. 458b works since 0707";
|
neuper@52105
|
1324 |
val t = str2term "(2*a^^^2*x - a^^^2) / (a*x - b*x) / (b^^^2*(2*x - 1) / (x*(a - b)))";
|
neuper@52105
|
1325 |
(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1326 |
:
|
neuper@52105
|
1327 |
### rls: cancel_p on: (-1 * a ^^^ 2 + 2 * (a ^^^ 2 * x)) / (a * x + -1 * (b * x)) /
|
neuper@52105
|
1328 |
((-1 * b ^^^ 2 + 2 * (b ^^^ 2 * x)) / (a * x + -1 * (b * x)))
|
neuper@52105
|
1329 |
exception Div raised
|
neuper@52105
|
1330 |
|
neuper@52105
|
1331 |
BUT
|
neuper@37906
|
1332 |
val t = str2term
|
neuper@52105
|
1333 |
("(-1 * a ^^^ 2 + 2 * (a ^^^ 2 * x)) / (a * x + -1 * (b * x)) /" ^
|
neuper@52105
|
1334 |
"((-1 * b ^^^ 2 + 2 * (b ^^^ 2 * x)) / (a * x + -1 * (b * x)))");
|
neuper@52105
|
1335 |
NONE = cancel_p_ thy t;
|
neuper@52105
|
1336 |
|
neuper@37906
|
1337 |
if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
|
neuper@38046
|
1338 |
else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
|
neuper@52105
|
1339 |
*)
|
neuper@37906
|
1340 |
|
neuper@52105
|
1341 |
"----- SRD Schalk I, p.69 Nr. 459b";
|
neuper@37906
|
1342 |
val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
|
neuper@52105
|
1343 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1344 |
if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
|
neuper@38046
|
1345 |
else error "rational.sml: diff.behav. in norm_Rational_mg 41";
|
neuper@37906
|
1346 |
|
neuper@52105
|
1347 |
"----- Schalk I, p.69 Nr. 460b nonterm.SK";
|
neuper@52105
|
1348 |
val t = str2term "(9*(x^^^2 - 8*x + 16) / (4*(y^^^2 - 2*y + 1))) / ((3*x - 12) / (16*y - 16))";
|
neuper@52105
|
1349 |
(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1350 |
exception Div raised
|
neuper@37906
|
1351 |
|
neuper@52105
|
1352 |
BUT
|
neuper@37906
|
1353 |
val t = str2term
|
neuper@52105
|
1354 |
("(144 + -72 * x + 9 * x ^^^ 2) / (4 + -8 * y + 4 * y ^^^ 2) /" ^
|
neuper@52105
|
1355 |
"((-12 + 3 * x) / (-16 + 16 * y))");
|
neuper@52105
|
1356 |
NONE = cancel_p_ thy t;
|
neuper@37906
|
1357 |
|
neuper@52105
|
1358 |
if term2str t = !!!!!!!!!!!!!!!!!!!!!!!!!
|
neuper@52105
|
1359 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 42";
|
neuper@52105
|
1360 |
*)
|
neuper@37906
|
1361 |
|
neuper@52105
|
1362 |
"----- some variant of the above; was non-terminating before";
|
neuper@52105
|
1363 |
val t = str2term "9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
|
neuper@52105
|
1364 |
val SOME (t , _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1365 |
if term2str t = "(48 + -12 * x) / (1 + -1 * y)"
|
neuper@52105
|
1366 |
then () else error "some variant of the above; was non-terminating before";
|
neuper@37906
|
1367 |
|
neuper@52105
|
1368 |
"----- SRD Schalk I, p.70 Nr. 472a";
|
neuper@52105
|
1369 |
val t = str2term ("((8*x^^^2 - 32*y^^^2) / (2*x + 4*y)) / ((4*x - 8*y) / (x + y))");
|
neuper@52105
|
1370 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1371 |
if term2str t = "x + y"
|
neuper@52105
|
1372 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 43";
|
neuper@37906
|
1373 |
|
neuper@52105
|
1374 |
"----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
|
neuper@52105
|
1375 |
val t = str2term ("(a - (a*b + b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
|
neuper@52105
|
1376 |
"((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))");
|
neuper@52105
|
1377 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1378 |
if term2str t = "(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
|
neuper@52105
|
1379 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 51";
|
neuper@37906
|
1380 |
|
neuper@37906
|
1381 |
(*SRD Schalk I, p.69 Nr. 461a *)
|
neuper@52105
|
1382 |
val t = str2term "(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
|
neuper@52105
|
1383 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1384 |
if term2str t = "1 / 2"
|
neuper@52105
|
1385 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 44";
|
neuper@37906
|
1386 |
|
neuper@37906
|
1387 |
(*SRD Schalk I, p.69 Nr. 464b *)
|
neuper@52105
|
1388 |
val t = str2term "(a - a/(a - 2)) / (a + a/(a - 2))";
|
neuper@52105
|
1389 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1390 |
if term2str t = "(-3 + a) / (-1 + a)"
|
neuper@52105
|
1391 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 45";
|
neuper@37906
|
1392 |
|
neuper@37906
|
1393 |
(*SRD Schalk I, p.69 Nr. 465b *)
|
neuper@52105
|
1394 |
val t = str2term "((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) / (x/9 + y/6 + z/4)";
|
neuper@52105
|
1395 |
(* WN130911 non-termination due to non-termination of
|
neuper@52105
|
1396 |
cancel_p_ thy (str2term
|
neuper@52105
|
1397 |
("("(576 * x ^^^ 2 + 1728 * (x * y) + 1296 * y ^^^ 2 + -2916 * z ^^^ 2) /" ^
|
neuper@52105
|
1398 |
"(576 * x ^^^ 2 + 864 * (x * y) + 1296 * (x * z))"))
|
neuper@52105
|
1399 |
|
neuper@52105
|
1400 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1401 |
if term2str t = "(4 * x + 6 * y + -9 * z) / (4 * x)"
|
neuper@52105
|
1402 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 46";
|
neuper@52105
|
1403 |
*)
|
neuper@37906
|
1404 |
|
neuper@37906
|
1405 |
(*SRD Schalk I, p.69 Nr. 466b *)
|
neuper@52105
|
1406 |
val t = str2term "((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
|
neuper@52105
|
1407 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1408 |
if term2str t = "(25 + -10 * x + x ^^^ 2) / 18"
|
neuper@52105
|
1409 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 47";
|
neuper@37906
|
1410 |
|
neuper@37906
|
1411 |
(*SRD Schalk I, p.70 Nr. 469 *)
|
neuper@52105
|
1412 |
val t = str2term ("3*b^^^2 / (4*a^^^2 - 8*a*b + 4*b^^^2) / " ^
|
neuper@52105
|
1413 |
"(a / (a^^^2*b - b^^^3) + (a - b) / (4*a*b^^^2 + 4*b^^^3) - 1 / (4*b^^^2))");
|
neuper@52105
|
1414 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52105
|
1415 |
if term2str t = "-3 * b ^^^ 3 / (-2 * a + 2 * b)"
|
neuper@52105
|
1416 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 48";
|
neuper@37906
|
1417 |
|
neuper@52105
|
1418 |
"-------- me Schalk I No.186 -------------------------------------------------";
|
neuper@52105
|
1419 |
"-------- me Schalk I No.186 -------------------------------------------------";
|
neuper@52105
|
1420 |
"-------- me Schalk I No.186 -------------------------------------------------";
|
neuper@52105
|
1421 |
val fmz = ["Term ((14 * x * y) / ( x * y ))", "normalform N"];
|
neuper@37906
|
1422 |
val (dI',pI',mI') =
|
neuper@37991
|
1423 |
("Rational",["rational","simplification"],
|
neuper@37906
|
1424 |
["simplification","of_rationals"]);
|
neuper@37906
|
1425 |
val p = e_pos'; val c = [];
|
neuper@37906
|
1426 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@37906
|
1427 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1428 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1429 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1430 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1431 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1432 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1433 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1434 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
1435 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
1436 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
|
neuper@37906
|
1437 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
|
neuper@37906
|
1438 |
case (f2str f, nxt) of
|
neuper@37906
|
1439 |
("14", ("End_Proof'", _)) => ()
|
neuper@38031
|
1440 |
| _ => error "rational.sml diff.behav. in me Schalk I No.186";
|
neuper@37906
|
1441 |
|
neuper@52105
|
1442 |
"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
|
neuper@52105
|
1443 |
"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
|
neuper@52105
|
1444 |
"-------- interSteps ..Simp_Rat_Double_No-1.xml ------------------------------";
|
neuper@37906
|
1445 |
states:=[];
|
neuper@52105
|
1446 |
CalcTree [(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
|
neuper@52105
|
1447 |
("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
|
neuper@37906
|
1448 |
Iterator 1;
|
neuper@37906
|
1449 |
moveActiveRoot 1;
|
neuper@37906
|
1450 |
autoCalculate 1 CompleteCalc;
|
neuper@52105
|
1451 |
val ((pt, p), _) = get_calc 1;
|
neuper@52105
|
1452 |
(*
|
neuper@52105
|
1453 |
show_pt pt;
|
neuper@52105
|
1454 |
[
|
neuper@52105
|
1455 |
(([], Frm), Simplify ((2 - x) / (2 * a) / (2 * a / (x - 2)))),
|
neuper@52105
|
1456 |
(([1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
|
neuper@52105
|
1457 |
(([1], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))),
|
neuper@52105
|
1458 |
(([2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (-2 + x))),
|
neuper@52105
|
1459 |
(([3], Res), (2 + -1 * x) * (-2 + x) / (2 * a * (2 * a))),
|
neuper@52105
|
1460 |
(([4], Res), (-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)),
|
neuper@52105
|
1461 |
(([], Res), (-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2))]
|
neuper@52105
|
1462 |
*)
|
neuper@52105
|
1463 |
interSteps 1 ([1], Res);
|
neuper@52105
|
1464 |
val ((pt, p), _) = get_calc 1;
|
neuper@52105
|
1465 |
(*show_pt pt;
|
neuper@52105
|
1466 |
[
|
neuper@52105
|
1467 |
(([], Frm), Simplify ((2 - x) / (2 * a) / (2 * a / (x - 2)))),
|
neuper@52105
|
1468 |
(([1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
|
neuper@52105
|
1469 |
(([1,1], Frm), (2 - x) / (2 * a) / (2 * a / (x - 2))),
|
neuper@52105
|
1470 |
(([1,1], Res), (2 - x) / (2 * a) / (2 * a / (x + -1 * 2))),
|
neuper@52105
|
1471 |
(([1,2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))),
|
neuper@52105
|
1472 |
(([1], Res), (2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))),
|
neuper@52105
|
1473 |
(([2], Res), (2 + -1 * x) / (2 * a) / (2 * a / (-2 + x))),
|
neuper@52105
|
1474 |
(([3], Res), (2 + -1 * x) * (-2 + x) / (2 * a * (2 * a))),
|
neuper@52105
|
1475 |
(([4], Res), (-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)),
|
neuper@52105
|
1476 |
(([], Res), (-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2))]
|
neuper@52105
|
1477 |
*)
|
neuper@52105
|
1478 |
val (t, asm) = get_obj g_result pt [1, 1];
|
neuper@52105
|
1479 |
if term2str t = "(2 - x) / (2 * a) / (2 * a / (x + -1 * 2))" andalso terms2str asm = "[]"
|
neuper@52105
|
1480 |
then () else error "2nd interSteps ..Simp_Rat_Double_No-1 changed on [1, 1]";
|
neuper@52105
|
1481 |
val (t, asm) = get_obj g_result pt [1, 2];
|
neuper@52105
|
1482 |
if term2str t = "(2 + -1 * x) / (2 * a) / (2 * a / (x + -1 * 2))" andalso terms2str asm = "[]"
|
neuper@52105
|
1483 |
then () else error "3rd interSteps ..Simp_Rat_Double_No-1 changed on [1, 2]";
|
neuper@37906
|
1484 |
|
neuper@37906
|
1485 |
|
neuper@52105
|
1486 |
"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
|
neuper@52105
|
1487 |
"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
|
neuper@52105
|
1488 |
"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ------------------------------";
|
neuper@37906
|
1489 |
states:=[];
|
neuper@52105
|
1490 |
CalcTree [(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
|
neuper@52105
|
1491 |
("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
|
neuper@37906
|
1492 |
Iterator 1;
|
neuper@37906
|
1493 |
moveActiveRoot 1;
|
neuper@37906
|
1494 |
autoCalculate 1 CompleteCalc;
|
neuper@52105
|
1495 |
val ((pt, p), _) = get_calc 1;
|
neuper@52105
|
1496 |
(*show_pt pt;
|
neuper@52105
|
1497 |
[
|
neuper@52105
|
1498 |
(([], Frm), Simplify ((a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2))),
|
neuper@52105
|
1499 |
(([1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2)),
|
neuper@52105
|
1500 |
(([1], Res), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)),
|
neuper@52105
|
1501 |
(([2], Res), (a + b) / (a + -1 * b)),
|
neuper@52105
|
1502 |
(([], Res), (a + b) / (a + -1 * b))]
|
neuper@37906
|
1503 |
*)
|
neuper@52105
|
1504 |
interSteps 1 ([2], Res);
|
neuper@52105
|
1505 |
val ((pt, p), _) = get_calc 1;
|
neuper@52105
|
1506 |
(*show_pt pt;
|
neuper@52105
|
1507 |
[
|
neuper@52105
|
1508 |
(([], Frm), Simplify ((a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2))),
|
neuper@52105
|
1509 |
(([1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2)),
|
neuper@52105
|
1510 |
(([1], Res), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)),
|
neuper@52105
|
1511 |
(([2,1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)),
|
neuper@52105
|
1512 |
(([2,1], Res), (a + b) / (a + -1 * b)),
|
neuper@52105
|
1513 |
(([2], Res), (a + b) / (a + -1 * b)),
|
neuper@52105
|
1514 |
(([], Res), (a + b) / (a + -1 * b))]
|
neuper@52105
|
1515 |
*)
|
neuper@37906
|
1516 |
interSteps 1 ([2,1],Res);
|
neuper@52105
|
1517 |
val ((pt, p), _) = get_calc 1;
|
neuper@52105
|
1518 |
(*show_pt pt;
|
neuper@52105
|
1519 |
[
|
neuper@52105
|
1520 |
(([], Frm), Simplify ((a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2))),
|
neuper@52105
|
1521 |
(([1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * a * b + b ^^^ 2)),
|
neuper@52105
|
1522 |
(([1], Res), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)),
|
neuper@52105
|
1523 |
(([2,1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)),
|
neuper@52105
|
1524 |
(([2,1,1], Frm), (a ^^^ 2 + -1 * b ^^^ 2) / (a ^^^ 2 + -2 * (a * b) + b ^^^ 2)),
|
neuper@52105
|
1525 |
(([2,1,1], Res), (a ^^^ 2 + -1 * (a * b) + a * b + -1 * b ^^^ 2) /
|
neuper@52105
|
1526 |
(a ^^^ 2 + -2 * (a * b) + 1 * b ^^^ 2)),
|
neuper@52105
|
1527 |
(([2,1,2], Res), (a ^^^ 2 + -1 * (a * b) + a * b + -1 * b ^^^ 2) /
|
neuper@52105
|
1528 |
(a ^^^ 2 + -2 * (a * b) + -1 ^^^ 2 * b ^^^ 2)),
|
neuper@52105
|
1529 |
(([2,1,3], Res), (a ^^^ 2 + -1 * (a * b) + a * b + -1 * b ^^^ 2) /
|
neuper@52105
|
1530 |
(a ^^^ 2 + -2 * (a * b) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1531 |
(([2,1,4], Res), (a * a + -1 * (a * b) + a * b + -1 * b ^^^ 2) /
|
neuper@52105
|
1532 |
(a ^^^ 2 + -2 * (a * b) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1533 |
(([2,1,5], Res), (a * a + -1 * (a * b) + a * b + -1 * (b * b)) /
|
neuper@52105
|
1534 |
(a ^^^ 2 + -2 * (a * b) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1535 |
(([2,1,6], Res), (a * a + -1 * (a * b) + a * b + -1 * (b * b)) /
|
neuper@52105
|
1536 |
(a ^^^ 2 + -1 * (2 * (a * b)) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1537 |
(([2,1,7], Res), (a * a + a * (-1 * b) + (b * a + b * (-1 * b))) /
|
neuper@52105
|
1538 |
(a ^^^ 2 + 2 * (a * (-1 * b)) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1539 |
(([2,1,8], Res), (a * a + a * (-1 * b) + (b * a + b * (-1 * b))) /
|
neuper@52105
|
1540 |
(a ^^^ 2 + 2 * a * (-1 * b) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1541 |
(([2,1,9], Res), (a * (a + -1 * b) + (b * a + b * (-1 * b))) /
|
neuper@52105
|
1542 |
(a ^^^ 2 + 2 * a * (-1 * b) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1543 |
(([2,1,10], Res), (a * (a + -1 * b) + b * (a + -1 * b)) /
|
neuper@52105
|
1544 |
(a ^^^ 2 + 2 * a * (-1 * b) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1545 |
(([2,1,11], Res), (a + b) * (a + -1 * b) / (a ^^^ 2 + 2 * a * (-1 * b) + (-1 * b) ^^^ 2)),
|
neuper@52105
|
1546 |
(([2,1,12], Res), (a + b) * (a + -1 * b) / ((a + -1 * b) * (a + -1 * b))),
|
neuper@52105
|
1547 |
(([2,1,13], Res), (a + b) / (a + -1 * b)),
|
neuper@52105
|
1548 |
(([2,1], Res), (a + b) / (a + -1 * b)),
|
neuper@52105
|
1549 |
(([2], Res), (a + b) / (a + -1 * b)),
|
neuper@52105
|
1550 |
(([], Res), (a + b) / (a + -1 * b))]
|
neuper@52105
|
1551 |
*)
|
neuper@37906
|
1552 |
val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
|
neuper@52105
|
1553 |
if length newnds = 13 then () else error "rational.sml: interSteps cancel_p rev_rew_p";
|
neuper@37906
|
1554 |
|
neuper@37906
|
1555 |
val p = ([2,1,9],Res);
|
neuper@37906
|
1556 |
getTactic 1 p;
|
neuper@37906
|
1557 |
val (_, tac, _) = pt_extract (pt, p);
|
neuper@52105
|
1558 |
case tac of SOME (Rewrite ("sym_distrib_left", _)) => ()
|
neuper@38031
|
1559 |
| _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
|
neuper@37906
|
1560 |
|
neuper@37906
|
1561 |
|
neuper@52105
|
1562 |
"-------- investigate rulesets for cancel_p ----------------------------------";
|
neuper@52105
|
1563 |
"-------- investigate rulesets for cancel_p ----------------------------------";
|
neuper@52105
|
1564 |
"-------- investigate rulesets for cancel_p ----------------------------------";
|
neuper@41930
|
1565 |
val thy = @{theory "Rational"};
|
neuper@37906
|
1566 |
val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
|
neuper@37906
|
1567 |
val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
|
neuper@52105
|
1568 |
|
neuper@37906
|
1569 |
"----- with rewrite_set_";
|
neuper@37926
|
1570 |
val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
|
neuper@52105
|
1571 |
if term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" then () else error "rls chancel_p 1";
|
neuper@37906
|
1572 |
val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
|
neuper@37926
|
1573 |
val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
|
neuper@52105
|
1574 |
if term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" then () else error "rls chancel_p 2";
|
neuper@37906
|
1575 |
|
neuper@52105
|
1576 |
"----- with make_deriv; WN1130912 not investigated further, will be discontinued";
|
neuper@52105
|
1577 |
val SOME (tt, _) = factout_p_ thy t;
|
neuper@52105
|
1578 |
if term2str tt = "(a + b) * (a + -1 * b) / ((a + -1 * b) * (a + -1 * b))"
|
neuper@52105
|
1579 |
then () else error "rls chancel_p 3";
|
neuper@52105
|
1580 |
term2str tt = "(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
|
neuper@52105
|
1581 |
|
neuper@52105
|
1582 |
"--- with simpler ruleset";
|
neuper@52105
|
1583 |
val {rules, rew_ord= (_, ro), ...} = rep_rls (assoc_rls "rev_rew_p");
|
neuper@37926
|
1584 |
val der = make_deriv thy Atools_erls rules ro NONE tt;
|
neuper@52105
|
1585 |
if length der = 12 then () else error "WN1130912 rls chancel_p 4";
|
neuper@37906
|
1586 |
print_depth 99; writeln (deriv2str der); print_depth 3;
|
neuper@37906
|
1587 |
|
neuper@37906
|
1588 |
print_depth 99; map (term2str o #1) der; print_depth 3;
|
neuper@37906
|
1589 |
"...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
|
neuper@37906
|
1590 |
print_depth 99; map (rule2str o #2) der; print_depth 3;
|
neuper@37906
|
1591 |
print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
|
neuper@37906
|
1592 |
|
neuper@37926
|
1593 |
val der = make_deriv thy Atools_erls rules ro NONE
|
neuper@52105
|
1594 |
(str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
|
neuper@37906
|
1595 |
print_depth 99; writeln (deriv2str der); print_depth 3;
|
neuper@37906
|
1596 |
|
neuper@52105
|
1597 |
val {rules, rew_ord=(_,ro),...} = rep_rls (assoc_rls "rev_rew_p");
|
neuper@37926
|
1598 |
val der = make_deriv thy Atools_erls rules ro NONE
|
neuper@52105
|
1599 |
(str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
|
neuper@37906
|
1600 |
print_depth 99; writeln (deriv2str der); print_depth 3;
|
neuper@37906
|
1601 |
print_depth 99; map (term2str o #1) der; print_depth 3;
|
neuper@37906
|
1602 |
(*WN060829 ...postponed*)
|
neuper@37906
|
1603 |
|
neuper@37906
|
1604 |
|
neuper@52105
|
1605 |
"-------- fun eval_get_denominator -------------------------------------------";
|
neuper@52105
|
1606 |
"-------- fun eval_get_denominator -------------------------------------------";
|
neuper@52105
|
1607 |
"-------- fun eval_get_denominator -------------------------------------------";
|
neuper@42301
|
1608 |
val thy = @{theory Isac};
|
neuper@42301
|
1609 |
val t = term_of (the (parse thy "get_denominator ((a +x)/b)"));
|
neuper@42301
|
1610 |
val SOME (_, t') = eval_get_denominator "" 0 t thy;
|
neuper@52105
|
1611 |
if term2str t' = "get_denominator ((a + x) / b) = b"
|
neuper@52105
|
1612 |
then () else error "get_denominator ((a + x) / b) = b"
|
neuper@42301
|
1613 |
|
neuper@42439
|
1614 |
|
neuper@52105
|
1615 |
"-------- several errpats in complicated term --------------------------------";
|
neuper@52105
|
1616 |
"-------- several errpats in complicated term --------------------------------";
|
neuper@52105
|
1617 |
"-------- several errpats in complicated term --------------------------------";
|
neuper@52105
|
1618 |
(*WN12xxxx TODO: instead of Gabriella's example here (27.Jul.12) find a simpler one
|
neuper@52105
|
1619 |
WN130912: kept this test, although not clear what for*)
|
neuper@52105
|
1620 |
states := [];
|
neuper@52105
|
1621 |
CalcTree [(["Term ((5*b + 25)/(a^2 - b^2) * (a - b)/(5*b))", "normalform N"],
|
neuper@52105
|
1622 |
("Rational", ["rational", "simplification"], ["simplification", "of_rationals"]))];
|
neuper@42449
|
1623 |
Iterator 1;
|
neuper@42449
|
1624 |
moveActiveRoot 1;
|
neuper@42449
|
1625 |
autoCalculate 1 CompleteCalc;
|
neuper@52105
|
1626 |
val ((pt, p), _) = get_calc 1;
|
neuper@52105
|
1627 |
(*show_pt pt;
|
neuper@52105
|
1628 |
[
|
neuper@52105
|
1629 |
(([], Frm), Simplify ((5 * b + 25) / (a ^^^ 2 - b ^^^ 2) * (a - b) / (5 * b))),
|
neuper@52105
|
1630 |
(([1], Frm), (5 * b + 25) / (a ^^^ 2 - b ^^^ 2) * (a - b) / (5 * b)),
|
neuper@52105
|
1631 |
(([1], Res), (5 * b + 25) / (a ^^^ 2 + -1 * b ^^^ 2) * (a + -1 * b) / (5 * b)),
|
neuper@52105
|
1632 |
(([2], Res), (5 * b + 25) * (a + -1 * b) / (a ^^^ 2 + -1 * b ^^^ 2) / (5 * b)),
|
neuper@52105
|
1633 |
(([3], Res), (25 * a + -25 * b + 5 * (a * b) + -5 * b ^^^ 2) / (a ^^^ 2 + -1 * b ^^^ 2) /
|
neuper@52105
|
1634 |
(5 * b)),
|
neuper@52105
|
1635 |
(([4], Res), (25 + 5 * b) / (a + b) / (5 * b)),
|
neuper@52105
|
1636 |
(([5], Res), (25 + 5 * b) / ((a + b) * (5 * b))),
|
neuper@52105
|
1637 |
(([6], Res), (25 + 5 * b) / (5 * (a * b) + 5 * b ^^^ 2)),
|
neuper@52105
|
1638 |
(([7], Res), (5 + b) / (a * b + b ^^^ 2)),
|
neuper@52105
|
1639 |
(([], Res), (5 + b) / (a * b + b ^^^ 2))] *)
|
neuper@42449
|
1640 |
|
neuper@48788
|
1641 |
|
neuper@52106
|
1642 |
"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
|
neuper@52106
|
1643 |
"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
|
neuper@52106
|
1644 |
"-------- WN1309xx non-terminating rls norm_Rational -------------------------";
|
neuper@52106
|
1645 |
(*------- Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
|
neuper@52106
|
1646 |
val t = str2term
|
neuper@52106
|
1647 |
("((12*x*y / (9*x^^^2 - y^^^2)) / (1 / (3*x - y)^^^2 - 1 / (3*x + y)^^^2)) * " ^
|
neuper@52106
|
1648 |
"((1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2) / (20*x*y / (x^^^2 - 25*y^^^2)))");
|
neuper@48788
|
1649 |
|
neuper@52106
|
1650 |
(*1st factor separately simplified *)
|
neuper@52106
|
1651 |
val t = str2term "((12*x*y / (9*x^^^2 - y^^^2)) / (1 / (3*x - y)^^^2 - 1 / (3*x + y)^^^2))";
|
neuper@52106
|
1652 |
val SOME (t', _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52106
|
1653 |
if term2str t' = "(-9 * x ^^^ 2 + y ^^^ 2) / -1" then () else error "Nr. 480b lhs changed";
|
neuper@52106
|
1654 |
(*2nd factor separately simplified *)
|
neuper@52106
|
1655 |
val t = str2term "((1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2) / (20*x*y / (x^^^2 - 25*y^^^2)))";
|
neuper@52106
|
1656 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@52106
|
1657 |
if term2str t' = "-1 / (-1 * x ^^^ 2 + 25 * y ^^^ 2)" then () else error "Nr. 480b rhs changed";
|
neuper@52106
|
1658 |
|
neuper@52106
|
1659 |
"-------- Schalk I, p.70 Nr. 477a: terms are exploding ?!?";
|
neuper@52106
|
1660 |
val t = str2term ("b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^
|
neuper@52106
|
1661 |
"(b^^^2*y + b*y^^^2) * (a+x)^^^2 / ((b^^^2 - 4*y^^^2) * (a+2*x)^^^2)");
|
neuper@52106
|
1662 |
(*val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
|
neuper@52106
|
1663 |
:
|
neuper@52106
|
1664 |
### rls: cancel_p on: (a ^^^ 2 * (b * y) + 2 * (a * (b * (x * y))) + b * (x ^^^ 2 * y)) /
|
neuper@52106
|
1665 |
(b + -2 * y) /
|
neuper@52106
|
1666 |
((b ^^^ 2 + -1 * y ^^^ 2) / (b + 2 * y)) /
|
neuper@52106
|
1667 |
(b ^^^ 2 * y + b * y ^^^ 2) /
|
neuper@52106
|
1668 |
(a ^^^ 2 * b ^^^ 2 + -4 * (a ^^^ 2 * y ^^^ 2) + 4 * (a * (b ^^^ 2 * x)) +
|
neuper@52106
|
1669 |
-16 * (a * (x * y ^^^ 2)) +
|
neuper@52106
|
1670 |
4 * (b ^^^ 2 * x ^^^ 2) +
|
neuper@52106
|
1671 |
-16 * (x ^^^ 2 * y ^^^ 2))
|
neuper@52106
|
1672 |
exception Div raised
|
neuper@52106
|
1673 |
|
neuper@52106
|
1674 |
BUT
|
neuper@52106
|
1675 |
val t = str2term
|
neuper@52106
|
1676 |
("(a ^^^ 2 * (b * y) + 2 * (a * (b * (x * y))) + b * (x ^^^ 2 * y)) /" ^
|
neuper@52106
|
1677 |
"(b + -2 * y) /" ^
|
neuper@52106
|
1678 |
"((b ^^^ 2 + -1 * y ^^^ 2) / (b + 2 * y)) /" ^
|
neuper@52106
|
1679 |
"(b ^^^ 2 * y + b * y ^^^ 2) /" ^
|
neuper@52106
|
1680 |
"(a ^^^ 2 * b ^^^ 2 + -4 * (a ^^^ 2 * y ^^^ 2) + 4 * (a * (b ^^^ 2 * x)) +" ^
|
neuper@52106
|
1681 |
"-16 * (a * (x * y ^^^ 2)) +" ^
|
neuper@52106
|
1682 |
"4 * (b ^^^ 2 * x ^^^ 2) +" ^
|
neuper@52106
|
1683 |
"-16 * (x ^^^ 2 * y ^^^ 2))");
|
neuper@52106
|
1684 |
NONE = cancel_p_ thy t;
|
neuper@52106
|
1685 |
*)
|
neuper@52106
|
1686 |
|
neuper@52106
|
1687 |
(*------- Schalk I, p.70 Nr. 476b in 2003 this worked using 10 sec. *)
|
neuper@52106
|
1688 |
val t = str2term
|
neuper@52106
|
1689 |
("((a^^^2 - b^^^2)/(2*a*b) + 2*a*b/(a^^^2 - b^^^2)) / ((a^^^2 + b^^^2)/(2*a*b) + 1) / " ^
|
neuper@52106
|
1690 |
"((a^^^2 + b^^^2)^^^2 / (a + b)^^^2)");
|
neuper@52106
|
1691 |
(*
|
neuper@52106
|
1692 |
trace_rewrite := true;
|
neuper@52106
|
1693 |
rewrite_set_ thy false norm_Rational t;
|
neuper@52106
|
1694 |
:
|
neuper@52106
|
1695 |
#### rls: cancel_p on: (2 * (a ^^^ 7 * b) + 4 * (a ^^^ 6 * b ^^^ 2) + 6 * (a ^^^ 5 * b ^^^ 3) +
|
neuper@52106
|
1696 |
8 * (a ^^^ 4 * b ^^^ 4) +
|
neuper@52106
|
1697 |
6 * (a ^^^ 3 * b ^^^ 5) +
|
neuper@52106
|
1698 |
4 * (a ^^^ 2 * b ^^^ 6) +
|
neuper@52106
|
1699 |
2 * (a * b ^^^ 7)) /
|
neuper@52106
|
1700 |
(2 * (a ^^^ 9 * b) + 4 * (a ^^^ 8 * b ^^^ 2) +
|
neuper@52106
|
1701 |
2 * (2 * (a ^^^ 7 * b ^^^ 3)) +
|
neuper@52106
|
1702 |
4 * (a ^^^ 6 * b ^^^ 4) +
|
neuper@52106
|
1703 |
-4 * (a ^^^ 4 * b ^^^ 6) +
|
neuper@52106
|
1704 |
-4 * (a ^^^ 3 * b ^^^ 7) +
|
neuper@52106
|
1705 |
-4 * (a ^^^ 2 * b ^^^ 8) +
|
neuper@52106
|
1706 |
-2 * (a * b ^^^ 9))
|
neuper@52106
|
1707 |
|
neuper@52106
|
1708 |
if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
|
neuper@52106
|
1709 |
else error "rational.sml: diff.behav. in norm_Rational_mg 49";
|
neuper@52106
|
1710 |
*)
|
neuper@52106
|
1711 |
|
neuper@52106
|
1712 |
"-------- Schalk I, p.70 Nr. 480a: terms are exploding ?!?";
|
neuper@52106
|
1713 |
val t = str2term ("(1/x + 1/y + 1/z) / (1/x - 1/y - 1/z) / " ^
|
neuper@52106
|
1714 |
"(2*x^^^2 / (x^^^2 - z^^^2) / (x / (x + z) + x / (x - z)))");
|
neuper@52106
|
1715 |
(*
|
neuper@52106
|
1716 |
trace_rewrite := true;
|
neuper@52106
|
1717 |
rewrite_set_ thy false norm_Rational t;
|
neuper@52106
|
1718 |
:
|
neuper@52106
|
1719 |
#### rls: cancel_p on: (2 * (x ^^^ 6 * (y ^^^ 2 * z)) + 2 * (x ^^^ 6 * (y * z ^^^ 2)) +
|
neuper@52106
|
1720 |
2 * (x ^^^ 5 * (y ^^^ 2 * z ^^^ 2)) +
|
neuper@52106
|
1721 |
-2 * (x ^^^ 4 * (y ^^^ 2 * z ^^^ 3)) +
|
neuper@52106
|
1722 |
-2 * (x ^^^ 4 * (y * z ^^^ 4)) +
|
neuper@52106
|
1723 |
-2 * (x ^^^ 3 * (y ^^^ 2 * z ^^^ 4))) /
|
neuper@52106
|
1724 |
(-2 * (x ^^^ 6 * (y ^^^ 2 * z)) + -2 * (x ^^^ 6 * (y * z ^^^ 2)) +
|
neuper@52106
|
1725 |
2 * (x ^^^ 5 * (y ^^^ 2 * z ^^^ 2)) +
|
neuper@52106
|
1726 |
2 * (x ^^^ 4 * (y ^^^ 2 * z ^^^ 3)) +
|
neuper@52106
|
1727 |
2 * (x ^^^ 4 * (y * z ^^^ 4)) +
|
neuper@52106
|
1728 |
-2 * (x ^^^ 3 * (y ^^^ 2 * z ^^^ 4)))
|
neuper@52106
|
1729 |
*)
|
neuper@52106
|
1730 |
|
neuper@52106
|
1731 |
"-------- Schalk I, p.60 Nr. 215d: terms are exploding, internal loop does not terminate";
|
neuper@52106
|
1732 |
val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
|
neuper@52106
|
1733 |
(* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:
|
neuper@52106
|
1734 |
|
neuper@52106
|
1735 |
val t = str2term "(a-b)^^^3 * (x+y)^^^4";
|
neuper@52106
|
1736 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52106
|
1737 |
term2str t;
|
neuper@52106
|
1738 |
"a^^^3 * x^^^4 + 4 * a^^^3 * x^^^3 * y +6 * a^^^3 * x^^^2 * y^^^2 +4 * a^^^3 * x * y^^^3 +a^^^3 * y^^^4 +-3 * a^^^2 * b * x^^^4 +-12 * a^^^2 * b * x^^^3 * y +-18 * a^^^2 * b * x^^^2 * y^^^2 +-12 * a^^^2 * b * x * y^^^3 +-3 * a^^^2 * b * y^^^4 +3 * a * b^^^2 * x^^^4 +12 * a * b^^^2 * x^^^3 * y +18 * a * b^^^2 * x^^^2 * y^^^2 +12 * a * b^^^2 * x * y^^^3 +3 * a * b^^^2 * y^^^4 +-1 * b^^^3 * x^^^4 +-4 * b^^^3 * x^^^3 * y +-6 * b^^^3 * x^^^2 * y^^^2 +-4 * b^^^3 * x * y^^^3 +-1 * b^^^3 * y^^^4";
|
neuper@52106
|
1739 |
val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
|
neuper@52106
|
1740 |
val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52106
|
1741 |
term2str t;
|
neuper@52106
|
1742 |
"a^^^5 * x^^^2 + 2 * a^^^5 * x * y + a^^^5 * y^^^2 +-5 * a^^^4 * b * x^^^2 +-10 * a^^^4 * b * x * y +-5 * a^^^4 * b * y^^^2 +10 * a^^^3 * b^^^2 * x^^^2 +20 * a^^^3 * b^^^2 * x * y +10 * a^^^3 * b^^^2 * y^^^2 +-10 * a^^^2 * b^^^3 * x^^^2 +-20 * a^^^2 * b^^^3 * x * y +-10 * a^^^2 * b^^^3 * y^^^2 +5 * a * b^^^4 * x^^^2 +10 * a * b^^^4 * x * y +5 * a * b^^^4 * y^^^2 +-1 * b^^^5 * x^^^2 +-2 * b^^^5 * x * y +-1 * b^^^5 * y^^^2";
|
neuper@52106
|
1743 |
|
neuper@52106
|
1744 |
anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
|
neuper@52106
|
1745 |
|
neuper@52106
|
1746 |
"-------- Schalk I, p.70 Nr. 480b: terms are exploding, trace_rewrite stops at";
|
neuper@52106
|
1747 |
val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
|
neuper@52106
|
1748 |
"(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
|
neuper@52106
|
1749 |
"(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
|
neuper@52106
|
1750 |
"(20*x*y/(x^^^2 - 25*y^^^2))");
|
neuper@52106
|
1751 |
(*val SOME (t, _) = rewrite_set_ thy false norm_Rational t;
|
neuper@52106
|
1752 |
:
|
neuper@52106
|
1753 |
#### rls: cancel_p on: (19440 * (x ^^^ 8 * y ^^^ 2) + -490320 * (x ^^^ 6 * y ^^^ 4) +
|
neuper@52106
|
1754 |
108240 * (x ^^^ 4 * y ^^^ 6) +
|
neuper@52106
|
1755 |
-6000 * (x ^^^ 2 * y ^^^ 8)) /
|
neuper@52106
|
1756 |
(2160 * (x ^^^ 8 * y ^^^ 2) + -108240 * (x ^^^ 6 * y ^^^ 4) +
|
neuper@52106
|
1757 |
1362000 * (x ^^^ 4 * y ^^^ 6) +
|
neuper@52106
|
1758 |
-150000 * (x ^^^ 2 * y ^^^ 8))
|
neuper@52106
|
1759 |
*)
|
neuper@52106
|
1760 |
|