neuper@38041
|
1 |
(* Title: tests for rationals
|
neuper@38041
|
2 |
Author: Stefan Karnel
|
neuper@37906
|
3 |
Copyright (c) Stefan Karnel 2002
|
neuper@37906
|
4 |
Use is subject to license terms.
|
neuper@37906
|
5 |
|
neuper@38080
|
6 |
12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
neuper@38080
|
7 |
10 20 30 40 50 60 70 80
|
neuper@42395
|
8 |
LEGEND
|
neuper@42395
|
9 |
WN120317.TODO postponed test/../ratinal,ratinal2.sml to joint work with dmeind
|
neuper@42395
|
10 |
WN070906
|
neuper@37906
|
11 |
nonterm.SK marks non-terminating examples
|
neuper@37906
|
12 |
ord.SK PARTIALLY marks crucial ordering examples
|
neuper@37906
|
13 |
*SK* of some (secondary) interest (on 070906)
|
neuper@42395
|
14 |
WN060104 transfer examples marked with (*SR..*) to the exp-collection
|
neuper@42395
|
15 |
*)
|
neuper@37906
|
16 |
|
neuper@38041
|
17 |
"--------------------------------------------------------";
|
neuper@38041
|
18 |
"--------------------------------------------------------";
|
neuper@38041
|
19 |
"table of contents --------------------------------------";
|
neuper@38041
|
20 |
"--------------------------------------------------------";
|
neuper@38041
|
21 |
"~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
|
neuper@38041
|
22 |
"-------- ... missing WN060103 --------------------------";
|
neuper@38041
|
23 |
"-------- fun monom2term, fun poly2term' ---------------";
|
neuper@38041
|
24 |
"~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
|
neuper@52085
|
25 |
"-------- and app_rev --------------------------------------------------------";
|
neuper@38041
|
26 |
"-------- external calculating functions test -----------";
|
neuper@38041
|
27 |
"-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
|
neuper@38041
|
28 |
"-------- common_nominator_p ----------------------------";
|
neuper@38041
|
29 |
"-------- reverse rewrite -------------------------------";
|
neuper@38041
|
30 |
"-------- 'reverse-ruleset' cancel_p --------------------";
|
neuper@38041
|
31 |
"-------- norm_Rational ---------------------------------";
|
neuper@38041
|
32 |
"-------- numeral rationals -----------------------------";
|
neuper@38041
|
33 |
"-------- cancellation ----------------------------------";
|
neuper@38041
|
34 |
"-------- common denominator ----------------------------";
|
neuper@38041
|
35 |
"-------- multiply and cancel ---------------------------";
|
neuper@38041
|
36 |
"-------- common denominator and multiplication ---------";
|
neuper@38041
|
37 |
"-------- double fractions ------------------------------";
|
neuper@38041
|
38 |
"-------- crucial examples ------------------------------";
|
neuper@38041
|
39 |
"-------- examples for Stefan Karnels thesis ------------";
|
neuper@38041
|
40 |
"-------- me Schalk I No.186 ----------------------------";
|
neuper@38041
|
41 |
"-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
|
neuper@38041
|
42 |
"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
|
neuper@38041
|
43 |
"-------- investigate rulesets for cancel_p -------------";
|
neuper@38041
|
44 |
"-------- investigate format of factout_ and factout_p_ -";
|
neuper@38041
|
45 |
"-------- how to stepwise construct Scripts -------------";
|
neuper@42301
|
46 |
"----------- get_denominator ----------------------------";
|
neuper@42449
|
47 |
"--------- several errpats in complicated term -------------------";
|
neuper@38041
|
48 |
"--------------------------------------------------------";
|
neuper@48788
|
49 |
"-------- nonterminating cancel_p, norm_Rational 2002 ---";
|
neuper@38041
|
50 |
"--------------------------------------------------------";
|
neuper@38041
|
51 |
"--------------------------------------------------------";
|
neuper@37906
|
52 |
|
neuper@37906
|
53 |
|
neuper@38041
|
54 |
"~~~~~BEGIN: decomment structure RationalI : RATIONALI ~~";
|
neuper@37906
|
55 |
(*.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
neuper@37906
|
56 |
tests of internal functions: to make them work,
|
neuper@37906
|
57 |
out-comment (*!!!*) in knowledge/Rational.ML:
|
neuper@37906
|
58 |
(*##!!!
|
neuper@37906
|
59 |
structure RationalI : RATIONALI =
|
neuper@37906
|
60 |
struct
|
neuper@37906
|
61 |
!!!##*)
|
neuper@37906
|
62 |
|
neuper@37906
|
63 |
(*##!!!
|
neuper@37906
|
64 |
end;(*struct*)
|
neuper@37906
|
65 |
open RationalI;
|
neuper@37906
|
66 |
!!!##*)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.*)
|
neuper@37906
|
67 |
|
neuper@38041
|
68 |
"-------- ... missing WN060103 --------------------------";
|
neuper@38041
|
69 |
"-------- ... missing WN060103 --------------------------";
|
neuper@38041
|
70 |
"-------- ... missing WN060103 --------------------------";
|
neuper@37906
|
71 |
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
neuper@38041
|
72 |
writeln ("********************* rational.sml - TESTS *************************");
|
neuper@38041
|
73 |
writeln ("***** divide tests *****");
|
neuper@37906
|
74 |
val mv_pquot1 = (#1(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_)));
|
neuper@37906
|
75 |
(* result: [(1,[0,0,1]),(1,[0,0,0])] *)
|
neuper@38031
|
76 |
if mv_pquot1=[(1,[0,0,1]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
77 |
|
neuper@37906
|
78 |
val mv_prest1 = (#2(mv_division([(1,[1,1,1]),(1,[1,1,0]),(1,[1,0,1]),(1,[0,0,0])],[(1,[1,1,0]),(1,[0,0,0])],LEX_)));
|
neuper@37906
|
79 |
(* result: [(1,[1,0,1]),(~1,[0,0,1])] *)
|
neuper@38031
|
80 |
if mv_prest1=[(1,[1,0,1]),(~1,[0,0,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
81 |
|
neuper@37906
|
82 |
val mv_pquot2 = (#1(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
|
neuper@37906
|
83 |
(* result: [(4,[1]),(4,[0])] *)
|
neuper@38031
|
84 |
if mv_pquot2=[(4,[1]),(4,[0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
85 |
|
neuper@37906
|
86 |
val mv_prest2 = (#2(mv_division([(4,[2]),(8,[1]),(16,[0])],[(1,[1]),(1,[0])],LEX_)));
|
neuper@37906
|
87 |
(* result: [(12,[0]] *)
|
neuper@38031
|
88 |
if mv_prest2=[(12,[0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
89 |
|
neuper@37906
|
90 |
val mv_pquot3 = (#1(mv_division([(4,[2]),(~4,[0])],[(2,[1]),(2,[0])],LEX_)));
|
neuper@37906
|
91 |
(* [(2,[1]),(~2,[0])] *)
|
neuper@38031
|
92 |
if mv_pquot3=[(2,[1]),(~2,[0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
93 |
|
neuper@37906
|
94 |
val mv_prest3 = (#2(mv_division([(1,[2]),(~1,[0])],[(2,[1]),(2,[0])],LEX_)));
|
neuper@37906
|
95 |
(* [(1,[2]),(~1,[0])] *)
|
neuper@38031
|
96 |
if mv_prest3=[(1,[2]),(~1,[0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
97 |
|
neuper@37906
|
98 |
val mv_pquot4 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],LEX_)));
|
neuper@37906
|
99 |
(* [(1,[0,1,1])] *)
|
neuper@38031
|
100 |
if mv_pquot4=[(1,[0,1,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
101 |
|
neuper@37906
|
102 |
val mv_prest4 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1])],[(2,[1,0,0]),(4,[0,0,1])],GGO_)));
|
neuper@37906
|
103 |
(* [(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] *)
|
neuper@38031
|
104 |
if mv_prest4 =[(1,[1,1,1]),(~4,[0,1,2]),(4,[1,0,1]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
105 |
|
neuper@37906
|
106 |
val mv_pquot5 = (#1(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_)));
|
neuper@37906
|
107 |
(* [(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])]*)
|
neuper@38031
|
108 |
if mv_pquot5=[(1,[2,2,0]),(6,[2,1,2]),(3,[1,1,0]),(4,[1,0,0]),(4,[0,4,0]),(3,[0,0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
109 |
|
neuper@37906
|
110 |
val mv_prest5 = (#2(mv_division([(3,[1,1,1]),(4,[1,0,1]),(3,[0,0,1]),(6,[2,1,3]),(4,[0,4,1]),(1,[2,2,1])],[(1,[0,0,1])],LEX_)));
|
neuper@37906
|
111 |
(* [] *)
|
neuper@38031
|
112 |
if mv_prest5=[] then () else error ("rational.sml: example failed");
|
neuper@37906
|
113 |
|
neuper@37906
|
114 |
(* (x^2 + 2(a+1)x + (a^2+2a+1)) / (x+a+1) = x+a+1 *)
|
neuper@37906
|
115 |
val mv_pquot6 = (#1(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_)));
|
neuper@38031
|
116 |
if mv_pquot6=[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
117 |
|
neuper@37906
|
118 |
val mv_prest6 = (#2(mv_division([(1,[2,0,0]),(2,[1,1,0]),(2,[1,0,0]),(1,[0,2,0]),(2,[0,1,0]),(1,[0,0,0])],[(1,[1,0,0]),(1,[0,1,0]),(1,[0,0,0])],LEX_)));
|
neuper@38031
|
119 |
if mv_prest6=[] then () else error ("rational.sml: example failed");
|
neuper@37906
|
120 |
|
neuper@37906
|
121 |
|
neuper@38041
|
122 |
writeln ("***** MV_CONTENT-TESTS *****");
|
neuper@37906
|
123 |
val mv_cont1=mv_content([(1,[2,1]),(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
|
neuper@37906
|
124 |
(* [(1,[0,1]),(1,[0,0])] *)
|
neuper@38031
|
125 |
if mv_cont1=[(1,[0,1]),(1,[0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
126 |
|
neuper@37906
|
127 |
val mv_pp1=mv_pp([(1,[1,1]),(1,[1,0]),(1,[0,1]),(1,[0,0])]);
|
neuper@37906
|
128 |
(*[(1,[1,0]),(1,[0,0])]*)
|
neuper@38031
|
129 |
if mv_pp1=[(1,[1,0]),(1,[0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
130 |
|
neuper@37906
|
131 |
val mv_cont2=mv_content([(2,[1]),(4,[0])]);
|
neuper@37906
|
132 |
(* [(2,[0])] *)
|
neuper@38031
|
133 |
if mv_cont2=[(2,[0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
134 |
|
neuper@37906
|
135 |
val mv_pp2=mv_pp([(2,[1]),(4,[0])]);
|
neuper@37906
|
136 |
(* [(1,[1]),(2,[0])] *)
|
neuper@38031
|
137 |
if mv_pp2=[(1,[1]),(2,[0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
138 |
|
neuper@37906
|
139 |
val mv_cont3=mv_content[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
|
neuper@37906
|
140 |
(* [(2,[0,0,0])] *)
|
neuper@38031
|
141 |
if mv_cont3=[(2,[0,0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
142 |
|
neuper@37906
|
143 |
val mv_pp3=mv_pp[(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(16,[1,1,1])];
|
neuper@37906
|
144 |
(* [(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] *)
|
neuper@38031
|
145 |
if mv_pp3=[(5,[2,2,0]),(4,[2,1,1]),(8,[1,1,1]),(6,[1,0,2])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
146 |
|
neuper@37906
|
147 |
val mv_cont4=mv_content[(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
|
neuper@37906
|
148 |
(* [(1,[0,0,0])] *)
|
neuper@38031
|
149 |
if mv_cont4=[(1,[0,0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
150 |
|
neuper@37906
|
151 |
val mv_pp4=mv_pp [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
|
neuper@37906
|
152 |
(* [(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] *)
|
neuper@38031
|
153 |
if mv_pp4=[(2,[2,1,0]),(2,[1,1,0]),(3,[1,0,1]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
154 |
|
neuper@37906
|
155 |
val con1=mv_content([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
|
neuper@37906
|
156 |
(* [(3,[0,0])] *)
|
neuper@38031
|
157 |
if con1=[(3,[0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
158 |
|
neuper@37906
|
159 |
val pp1=mv_pp([(9,[2,0]),(15,[1,1]),(12,[1,0]),(6,[0,2]),(12,[0,1])]);
|
neuper@37906
|
160 |
(* [(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] *)
|
neuper@38031
|
161 |
if pp1=[(3,[2,0]),(5,[1,1]),(4,[1,0]),(2,[0,2]),(4,[0,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
162 |
|
neuper@37906
|
163 |
val con2=mv_content([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
|
neuper@37906
|
164 |
(* [(1,[0,0])] *)
|
neuper@38031
|
165 |
if con2=[(1,[0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
166 |
|
neuper@37906
|
167 |
val pp2 =mv_pp([(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])]);
|
neuper@37906
|
168 |
(* [(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] *)
|
neuper@38031
|
169 |
if pp2=[(1,[2,0]),(1,[1,1]),(1,[1,0]),(1,[0,2]),(1,[0,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
170 |
|
neuper@37906
|
171 |
val cont1 = mv_content [(1,[2,1,0]),(2,[2,1,0])];
|
neuper@37906
|
172 |
(* [(3,[0,1,0])] *)
|
neuper@38031
|
173 |
if cont1=[(3,[0,1,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
174 |
|
neuper@37906
|
175 |
val pp1 = mv_pp [(1,[2,1,0]),(2,[2,1,0])];
|
neuper@37906
|
176 |
(* [(1,[2,0,0])] *)
|
neuper@38031
|
177 |
if pp1=[(1,[2,0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
178 |
|
neuper@37906
|
179 |
val cont2 = mv_content [(4,[1,2,0]),(2,[2,1,0])];
|
neuper@37906
|
180 |
(* [(2,[0,1,0])] *)
|
neuper@38031
|
181 |
if cont2=[(2,[0,1,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
182 |
|
neuper@37906
|
183 |
val pp2 = mv_pp [(4,[1,2,0]),(2,[2,1,0])];
|
neuper@37906
|
184 |
(* [(1,[2,0,0]),(2,[1,1,0])] *)
|
neuper@38031
|
185 |
if pp2=[(1,[2,0,0]),(2,[1,1,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
186 |
|
neuper@38041
|
187 |
writeln ("********************************************************");
|
neuper@37906
|
188 |
val cont3=mv_content [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])];
|
neuper@38031
|
189 |
if cont3=[(5,[0,2,1]),(4,[0,2,0]),(2,[0,1,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
190 |
val pp3=mv_pp [(65,[3,2,2]),(52,[3,2,1]),(26,[3,1,2]),(~95,[2,2,3]),(~76,[2,2,2]),(35,[2,2,1]),(28,[2,2,0]),(~38,[2,1,3]),(14,[2,1,1])];
|
neuper@37906
|
191 |
|
neuper@37906
|
192 |
|
neuper@38041
|
193 |
"-------- fun monom2term, fun poly2term' ---------------";
|
neuper@38041
|
194 |
"-------- fun monom2term, fun poly2term' ---------------";
|
neuper@38041
|
195 |
"-------- fun monom2term, fun poly2term' ---------------";
|
neuper@37906
|
196 |
val t = monom2term ((3,[2,1,0]), ["c","b","a"](*reverse ???SK-*));
|
neuper@37906
|
197 |
term2str t = "3 * (c ^^^ 2 * b)" (*true*);
|
neuper@37906
|
198 |
|
neuper@37906
|
199 |
val t = monom2term ((1,[1,0]), ["b","a"]);
|
neuper@37906
|
200 |
term2str t = "b" (*true*);
|
neuper@37906
|
201 |
|
neuper@37906
|
202 |
val t = poly2term ([(1,[0,0,0]),(2,[1,0,0]),(3,[2,1,0]),(4,[3,2,1])],
|
neuper@37906
|
203 |
["c","b","a"]);
|
neuper@37906
|
204 |
term2str t = "1 + 2 * c + 3 * (c ^^^ 2 * b) + 4 * (c ^^^ 3 * (b ^^^ 2 * a))";
|
neuper@37906
|
205 |
|
neuper@37906
|
206 |
val t = poly2term ([(1,[1,0]),(1,[0,1])], ["b","a"]);
|
neuper@37906
|
207 |
term2str t = "a + b" (*true*);
|
neuper@37906
|
208 |
|
neuper@37906
|
209 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
|
neuper@38041
|
210 |
"~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
|
neuper@38041
|
211 |
"~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
|
neuper@38041
|
212 |
"~~~~~END: decomment structure RationalI : RATIONALI ~~~~";
|
neuper@37906
|
213 |
|
neuper@37906
|
214 |
|
neuper@37906
|
215 |
fun parse_rat str = (term_of o the o (parse thy)) str;
|
neuper@37906
|
216 |
|
neuper@38041
|
217 |
writeln ("***** mv_gcd-tests *****");
|
neuper@37906
|
218 |
val ggt1 = mv_gcd [(4,[2,2]),(8,[1,1]),(4,[0,0])] [(2,[1,1]),(2,[0,0])];
|
neuper@37906
|
219 |
(* [(2,[1,1]),(2,[0,0])] *)
|
neuper@38031
|
220 |
if ggt1=[(2,[1,1]),(2,[0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
221 |
|
neuper@37906
|
222 |
val ggt2 = mv_gcd [(8,[2,1,1]),(12,[1,0,2]),(10,[2,2,0]),(15,[1,1,1])] [(2,[2,1,0]),(3,[1,0,1]),(2,[1,1,0]),(3,[0,0,1])];
|
neuper@37906
|
223 |
(* [(2,[1,1,0]),(3,[0,0,1])] *)
|
neuper@38031
|
224 |
if ggt2=[(2,[1,1,0]),(3,[0,0,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
225 |
|
neuper@37906
|
226 |
|
neuper@37906
|
227 |
val ggt3 = mv_gcd [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
|
neuper@37906
|
228 |
(* [(1,[1,0]),(~1,[0,1])] *)
|
neuper@38031
|
229 |
if ggt3=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
230 |
|
neuper@37906
|
231 |
|
neuper@37906
|
232 |
val ggt4 = mv_gcd [(1,[2,1,0]),(2,[2,1,0])] [(5,[1,0,0])];
|
neuper@37906
|
233 |
(* [(1,[1,0,0])] *)
|
neuper@38031
|
234 |
if ggt4=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
235 |
|
neuper@37906
|
236 |
|
neuper@37906
|
237 |
val ggt5 = mv_gcd [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
|
neuper@37906
|
238 |
(* [(1,[1,0]),(~1,[0,1])] *)
|
neuper@38031
|
239 |
if ggt5=[(1,[1,0]),(~1,[0,1])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
240 |
|
neuper@37906
|
241 |
|
neuper@37906
|
242 |
val ggt6 = mv_gcd [(10,[2,1,1]),(14,[1,1,0]),(3,[1,0,1]),(20,[1,2,1])] [(5,[1,1,1]),(7,[2,1,1])];
|
neuper@37906
|
243 |
(* [(1,[0,0,0])] *)
|
neuper@38031
|
244 |
if ggt6=[(1,[1,0,0])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
245 |
|
neuper@38041
|
246 |
writeln ("***** kgv-tests *****");
|
neuper@37906
|
247 |
val kgv1=mv_lcm [(10,[])] [(15,[])];
|
neuper@37906
|
248 |
(* [(30,[])] *)
|
neuper@38031
|
249 |
if kgv1=[(30,[])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
250 |
|
neuper@37906
|
251 |
val kgv2=mv_lcm [(1,[2,0]),(~2,[1,1]),(1,[0,2])] [(1,[1,0]),(~1,[0,1])];
|
neuper@37906
|
252 |
(* [(1,[2,0]),(~2,[1,1]),(1,[0,2])] *)
|
neuper@38031
|
253 |
if kgv2=[(1,[2,0]),(~2,[1,1]),(1,[0,2])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
254 |
|
neuper@37906
|
255 |
val kgv3=mv_lcm [(4,[2,0]),(~8,[1,1]),(4,[0,2])] [(1,[2,0]),(~1,[0,2])];
|
neuper@37906
|
256 |
(* [(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] *)
|
neuper@38031
|
257 |
if kgv3=[(4,[3,0]),(~4,[2,1]),(~4,[1,2]),(4,[0,3])] then () else error ("rational.sml: example failed");
|
neuper@37906
|
258 |
|
neuper@37906
|
259 |
(*!!!--------
|
neuper@38041
|
260 |
writeln ("***** STEP_CANCEL_TESTS: *****");
|
neuper@37906
|
261 |
|
neuper@37906
|
262 |
val term2 = (term_of o the o (parse thy)) " (9 * a^^^2 * b) / (6 * a * c)";
|
neuper@37906
|
263 |
val div2 = term2str (step_cancel term2);
|
neuper@38031
|
264 |
if div2 = "3 * (a * b) * (3 * a) / (2 * c * (3 * a))" then () else error ("rational.sml: example failed");
|
neuper@37906
|
265 |
|
neuper@37906
|
266 |
|
neuper@37906
|
267 |
val term1 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c + 14 * a * b + 3 * a * c + 20 * a * b^^^2 * c) / a";
|
neuper@37906
|
268 |
val div1 = term2str(step_cancel term1);
|
neuper@38031
|
269 |
if div1 = "(3 * c + 14 * b + 20 * (b ^^^ 2 * c) + 10 * (a * (b * c))) * a / (1 * a)" then () else error ("rational.sml: example failed");
|
neuper@37906
|
270 |
|
neuper@37906
|
271 |
val term3 = (term_of o the o (parse thy)) "(10 * a^^^2 * b * c) / (1 * x * y * z) ";
|
neuper@37906
|
272 |
val div3 = term2str(step_cancel term3);
|
neuper@38031
|
273 |
if div3="10 * a ^^^ 2 * b * c / (1 * x * y * z)" then () else error ("rational.sml: example failed");
|
neuper@37906
|
274 |
|
neuper@37906
|
275 |
--------------------------------------------------------------------------!!!*)
|
neuper@37906
|
276 |
|
neuper@37906
|
277 |
(*-----versuche 13.3.03-----
|
neuper@37906
|
278 |
val t = str2term "1 - x^^^2 - 5 * x^^^5";
|
neuper@37906
|
279 |
val vs=(((map free2str) o vars) t);
|
neuper@37926
|
280 |
val SOME ml = expanded2poly t vs;
|
neuper@37906
|
281 |
poly2term (ml, vs);
|
neuper@37906
|
282 |
poly2term'(rev(sort (mv_geq LEX_) (ml)),vs);
|
neuper@37906
|
283 |
poly2term'([(~5,[5]),(~1,[2]),(1,[0])], vs);
|
neuper@37906
|
284 |
monom2term((~5,[5]),vs);
|
neuper@37906
|
285 |
monom2term((~1,[2]),vs);
|
neuper@37906
|
286 |
val t' = monom2term((1,[0]),vs);(*uncaught exception LIST*)
|
neuper@37906
|
287 |
|
neuper@37906
|
288 |
val (i,is) = (~1,[2]);
|
neuper@38034
|
289 |
val ttt = Const ("Groups.times_class.times", [HOLogic.realT,HOLogic.realT]---> HOLogic.realT) $
|
neuper@37906
|
290 |
(Const ("uminus", HOLogic.realT --> HOLogic.realT) $
|
neuper@37906
|
291 |
Free ((str_of_int o abs) i, HOLogic.realT)) $
|
neuper@37906
|
292 |
powerproduct2term(is, vs);
|
neuper@37906
|
293 |
term2str ttt;
|
neuper@37906
|
294 |
-------versuche 13.3.03-----*)
|
neuper@37906
|
295 |
|
neuper@37906
|
296 |
val t = str2term "1 - x^^^2 - 5 * x^^^5";
|
neuper@37926
|
297 |
val SOME t' = expanded2polynomial t; term2str t';
|
neuper@37906
|
298 |
"1 + - 1 * x ^^^ 2 + - 5 * x ^^^ 5";
|
neuper@37906
|
299 |
val t = str2term "1 - x";
|
neuper@37926
|
300 |
val SOME t' = expanded2polynomial t; term2str t';
|
neuper@37906
|
301 |
"1 + - 1 * x";
|
neuper@37906
|
302 |
val t = str2term "1 + (-1) * x";
|
neuper@37926
|
303 |
val SOME t' = expanded2polynomial t; term2str t';
|
neuper@37906
|
304 |
"1 + - 1 * x";
|
neuper@37906
|
305 |
val t = (term_of o the o (parse thy)) "1 + (-1) * x ^^^ 2 + (-5) * x ^^^5";
|
neuper@37926
|
306 |
val SOME t' = polynomial2expanded t; term2str t';
|
neuper@37906
|
307 |
"1 - x ^^^ 2 - 5 * x ^^^ 5";
|
neuper@37906
|
308 |
|
neuper@52085
|
309 |
"-------- and app_rev --------------------------------------------------------";
|
neuper@52085
|
310 |
"-------- and app_rev --------------------------------------------------------";
|
neuper@52085
|
311 |
"-------- and app_rev --------------------------------------------------------";
|
neuper@52085
|
312 |
(* trace down until prepats are evaluated
|
neuper@52085
|
313 |
(which does not to work, because substitution is not done -- compare rew_sub!);
|
neuper@52085
|
314 |
keep this sequence for the case, factout_p, cancel_p, common_nominator_p, add_fraction_p
|
neuper@52085
|
315 |
(again) get prepat = [] changed to <>[]. *)
|
neuper@52085
|
316 |
val t = str2term "(x^^^2 + -1*y^^^2) / (x^^^2 + -1*x*y)";
|
neuper@52085
|
317 |
|
neuper@52085
|
318 |
(*rewrite_set_ @{theory Isac} true cancel t = NONE; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
319 |
"~~~~~ fun rewrite_set_, args:"; val (thy, bool, rls, term) = (thy, false, cancel_p, t);
|
neuper@52085
|
320 |
"~~~~~ fun rewrite__set_, args:"; val (thy, i, _, _, (rrls as Rrls _), t) =
|
neuper@52085
|
321 |
(thy, 1, bool, [], rls, term);
|
neuper@52085
|
322 |
(*val (t', asm, rew) = app_rev thy (i+1) rrls t; rew = false!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
323 |
"~~~~~ fun app_rev, args:"; val (thy, i, rrls, t) = (thy, (i+1), rrls, t);
|
neuper@52085
|
324 |
fun chk_prepat thy erls [] t = true
|
neuper@52085
|
325 |
| chk_prepat thy erls prepat t =
|
neuper@52085
|
326 |
let
|
neuper@52085
|
327 |
fun chk (pres, pat) =
|
neuper@52085
|
328 |
(let
|
neuper@52085
|
329 |
val subst: Type.tyenv * Envir.tenv =
|
neuper@52085
|
330 |
Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
|
neuper@52085
|
331 |
in
|
neuper@52085
|
332 |
snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
|
neuper@52085
|
333 |
end) handle _ => false
|
neuper@52085
|
334 |
fun scan_ f [] = false (*scan_ NEVER called by []*)
|
neuper@52085
|
335 |
| scan_ f (pp::pps) =
|
neuper@52085
|
336 |
if f pp then true else scan_ f pps;
|
neuper@52085
|
337 |
in scan_ chk prepat end;
|
neuper@52085
|
338 |
(* apply the normal_form of a rev-set *)
|
neuper@52085
|
339 |
fun app_rev' thy (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}) t =
|
neuper@52085
|
340 |
if chk_prepat thy erls prepat t
|
neuper@52085
|
341 |
then ((*tracing("### app_rev': t = "^(term2str t));*) normal_form t)
|
neuper@52085
|
342 |
else NONE;
|
neuper@52085
|
343 |
(* val opt = app_rev' thy rrls t ..NONE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
344 |
"~~~~~ and app_rev', args:"; val (thy, (Rrls{erls,prepat,scr=Rfuns{normal_form,...},...}), t) =
|
neuper@52085
|
345 |
(thy, rrls, t);
|
neuper@52085
|
346 |
(* chk_prepat thy erls prepat t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
347 |
(* app_sub thy i rrls t = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
348 |
"~~~~~ fun chk_prepat, args:"; val (thy, erls, prepat, t) = (thy, erls, prepat, t);
|
neuper@52085
|
349 |
fun chk (pres, pat) =
|
neuper@52085
|
350 |
(let
|
neuper@52085
|
351 |
val subst: Type.tyenv * Envir.tenv =
|
neuper@52085
|
352 |
Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
|
neuper@52085
|
353 |
in
|
neuper@52085
|
354 |
snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
|
neuper@52085
|
355 |
end) handle _ => false
|
neuper@52085
|
356 |
fun scan_ f [] = false (*scan_ NEVER called by []*)
|
neuper@52085
|
357 |
| scan_ f (pp::pps) =
|
neuper@52085
|
358 |
if f pp then true else scan_ f pps;
|
neuper@52085
|
359 |
|
neuper@52085
|
360 |
(*========== inhibit exn WN130823: (pp::pps) = [(*prepat*)] ====================================
|
neuper@52085
|
361 |
(* scan_ chk prepat = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
362 |
"~~~~~ fun , args:"; val (f, (pp::pps)) = (chk, prepat);
|
neuper@52085
|
363 |
f;
|
neuper@52085
|
364 |
val ([t1, t2], t) = pp;
|
neuper@52085
|
365 |
term2str t1 = "?r is_expanded";
|
neuper@52085
|
366 |
term2str t2 = "?s is_expanded";
|
neuper@52085
|
367 |
term2str t = "?r / ?s";
|
neuper@52085
|
368 |
(* f pp = false!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*)
|
neuper@52085
|
369 |
"~~~~~ fun chk, args:"; val (pres, pat) = (pp);
|
neuper@52085
|
370 |
val subst: Type.tyenv * Envir.tenv =
|
neuper@52085
|
371 |
Pattern.match thy (pat, t) (Vartab.empty, Vartab.empty)
|
neuper@52085
|
372 |
(*subst =
|
neuper@52085
|
373 |
({}, {(("r", 0), ("real", Var (("r", 0), "real"))),
|
neuper@52085
|
374 |
(("s", 0), ("real", Var (("s", 0), "real")))}*)
|
neuper@52085
|
375 |
;
|
neuper@52085
|
376 |
snd (eval__true thy (i + 1) (map (Envir.subst_term subst) pres) [] erls)
|
neuper@52085
|
377 |
"~~~~~ fun eval__true, args:"; val (thy, i, asms, bdv, rls) =
|
neuper@52085
|
378 |
(thy, (i + 1), (map (Envir.subst_term subst) pres), [], erls);
|
neuper@52085
|
379 |
terms2str asms; (* = "[\"?r is_expanded\",\"?s is_expanded\"]"*)
|
neuper@52085
|
380 |
asms = [@{term True}] orelse asms = []; (* = false*)
|
neuper@52085
|
381 |
asms = [@{term False}] ; (* = false*)
|
neuper@52085
|
382 |
"~~~~~ fun chk, args:"; val (indets, (a::asms)) = ([], asms);
|
neuper@52085
|
383 |
bdv (*= []: _a list*);
|
neuper@52085
|
384 |
val bdv : (term * term) list = [];
|
neuper@52085
|
385 |
rewrite__set_ thy (i+1) false;
|
neuper@52085
|
386 |
term2str a = "?r is_expanded"; (*hier m"usste doch der Numerator eingesetzt sein ??????????????*)
|
neuper@52085
|
387 |
val SOME (Const ("HOL.False", _), []) = rewrite__set_ thy (i+1) false bdv rls a
|
neuper@52085
|
388 |
============ inhibit exn WN130823: (pp::pps) = [(*prepat*)] ===================================*)
|
neuper@37906
|
389 |
|
neuper@38041
|
390 |
"-------- external calculating functions test -----------";
|
neuper@38041
|
391 |
"-------- external calculating functions test -----------";
|
neuper@38041
|
392 |
"-------- external calculating functions test -----------";
|
neuper@37906
|
393 |
val t1 = (term_of o the o (parse thy)) "((3 * x^^^2 + 6 *x + 3) / (2*x + 2))";
|
neuper@37926
|
394 |
val SOME (t1',asm)= factout_p_ thy t1;
|
neuper@37906
|
395 |
term2str t1'; terms2str asm;
|
neuper@37906
|
396 |
"(3 + 3 * x) * (1 + 1 * x) / (2 * (1 + 1 * x))";
|
neuper@37906
|
397 |
"[]";
|
neuper@37926
|
398 |
val SOME (t1',asm)= cancel_p_ thy t1;
|
neuper@37906
|
399 |
term2str t1'; terms2str asm;
|
neuper@37906
|
400 |
"(3 + 3 * x) / 2";
|
neuper@37906
|
401 |
"[\"1 + 1 * x ~= 0\"]";
|
neuper@37906
|
402 |
|
neuper@37906
|
403 |
val t = (term_of o the o (parse thy)) "((-3 * x^^^2 + 6 *x - 3) / (2*x - 2))";
|
neuper@37926
|
404 |
val SOME (t',asm)= cancel_ thy t;
|
neuper@37906
|
405 |
term2str t'; terms2str asm;
|
neuper@37906
|
406 |
"(3 - 3 * x) / 2";
|
neuper@37906
|
407 |
"[\"-1 + x ~= 0\"]";
|
neuper@37926
|
408 |
val SOME (t',asm)= factout_ thy t;
|
neuper@37906
|
409 |
term2str t'; terms2str asm;
|
neuper@37906
|
410 |
"(3 - 3 * x) * (-1 + x) / (2 * (-1 + x))";
|
neuper@37906
|
411 |
"[]";
|
neuper@37906
|
412 |
|
neuper@37906
|
413 |
val t = str2term "((x+ (-1)) / (x + 1)) + ((x + 1) / (x + (-1)))";
|
neuper@37926
|
414 |
val SOME (t',asm) = add_fraction_p_ thy t;
|
neuper@37906
|
415 |
term2str t'; terms2str asm;
|
neuper@37906
|
416 |
"(2 + 2 * x ^^^ 2) / (-1 + 1 * x ^^^ 2)";
|
neuper@37906
|
417 |
"[]";
|
neuper@37926
|
418 |
val SOME (t',asm) = common_nominator_p_ thy t;
|
neuper@37906
|
419 |
term2str t'; terms2str asm;
|
neuper@37906
|
420 |
"(-1 + 1 * x) * (-1 + 1 * x) / ((1 + 1 * x) * (-1 + 1 * x)) +\n(1 + 1 * x) * (1 + 1 * x) / ((1 + 1 * x) * (-1 + 1 * x))";
|
neuper@37906
|
421 |
"[]";
|
neuper@37906
|
422 |
|
neuper@37906
|
423 |
val t = str2term "((x - 1) / (x + 1)) + ((x + 1) / (x - 1))";
|
neuper@37926
|
424 |
val SOME (t',asm) = add_fraction_ thy t;
|
neuper@37906
|
425 |
term2str t'; terms2str asm;
|
neuper@37906
|
426 |
"(2 + 2 * x ^^^ 2) / (-1 + x ^^^ 2)";
|
neuper@37906
|
427 |
"[]";
|
neuper@37926
|
428 |
val SOME (t',asm) = common_nominator_ thy t;
|
neuper@37906
|
429 |
term2str t'; terms2str asm;
|
neuper@37906
|
430 |
"(-1 + x) * (-1 + x) / ((1 + x) * (-1 + x)) +\n(1 + x) * (1 + x) / ((1 + x) * (-1 + x))";
|
neuper@37906
|
431 |
"[]";
|
neuper@37906
|
432 |
|
neuper@37906
|
433 |
val t = str2term "((1) / (2*x + 2)) + ((1) / (2*x + (-2))) + ((1) / ( x^^^2 + (-1)))+((1) / (x^^^2 + (-2)*x + 1))";
|
neuper@37926
|
434 |
val SOME (t',asm) = common_nominator_p_ thy t;
|
neuper@37906
|
435 |
term2str t'; terms2str asm;
|
neuper@37906
|
436 |
"1 * (1 + -2 * x + 1 * x ^^^ 2) /\n((-1 + 1 * x) * (2 * ((-1 + 1 * x) * (1 + 1 * x)))) +\n(1 * (-1 + 1 * x ^^^ 2) /\n ((-1 + 1 * x) * (2 * ((-1 + 1 * x) * (1 + 1 * x)))) +\n (1 * (-2 + 2 * x) / ((-1 + 1 * x) * (2 * ((-1 + 1 * x) * (1 + 1 * x)))) +\n 1 * (#";
|
neuper@37906
|
437 |
"[]";
|
neuper@37926
|
438 |
val SOME (t',asm) = add_fraction_p_ thy t;
|
neuper@37906
|
439 |
term2str t'; terms2str asm;
|
neuper@37906
|
440 |
"1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
|
neuper@37906
|
441 |
"[\"1 + 1 * x ~= 0\"]";
|
neuper@37926
|
442 |
val SOME(t',asm) = norm_rational_ thy t;
|
neuper@37906
|
443 |
term2str t'; terms2str asm;
|
neuper@37906
|
444 |
"1 * x / (1 + -2 * x + 1 * x ^^^ 2)";
|
neuper@37906
|
445 |
"[\"1 + 1 * x ~= 0\"]";
|
neuper@37906
|
446 |
|
neuper@37906
|
447 |
val t3 = (term_of o the o (parse thy)) "((1) / (2*x + 2)) + ((1) / (2*x - 2)) + ((1) / ( x^^^2 - 1))+((1) / (x^^^2 - 2 * x + 1))";
|
neuper@37926
|
448 |
val SOME (t3',_) = common_nominator_ thy t3;
|
neuper@37926
|
449 |
val SOME (t3'',_) = add_fraction_ thy t3;
|
neuper@37906
|
450 |
(term2str t3');
|
neuper@37906
|
451 |
(term2str t3'');
|
neuper@37906
|
452 |
|
neuper@37926
|
453 |
val SOME(t4,t5) = norm_expanded_rat_ thy t3;
|
neuper@37906
|
454 |
term2str t4;
|
neuper@37906
|
455 |
term2str (hd(t5));
|
neuper@37906
|
456 |
|
neuper@37906
|
457 |
|
neuper@37906
|
458 |
|
neuper@37906
|
459 |
val t=(term_of o the o (parse thy)) "(9 - x^^^2)/(9 - 6*x + x^^^2)";
|
neuper@37926
|
460 |
val SOME (t',_) = factout_ thy t;
|
neuper@37926
|
461 |
val SOME (t'',_) = cancel_ thy t;
|
neuper@37906
|
462 |
term2str t';
|
neuper@37906
|
463 |
term2str t'';
|
neuper@37906
|
464 |
"(3 + x) * (3 - x) / ((3 - x) * (3 - x))";
|
neuper@37906
|
465 |
"(3 + x) / (3 - x)";
|
neuper@37906
|
466 |
|
neuper@37906
|
467 |
val t=(term_of o the o (parse thy))
|
neuper@37906
|
468 |
"(9 - x^^^2) / (9 - 6*x + x^^^2) + 1 / (3 - x)";
|
neuper@37926
|
469 |
val SOME (t',_) = common_nominator_ thy t;
|
neuper@37926
|
470 |
val SOME (t'',_) = add_fraction_ thy t;
|
neuper@37906
|
471 |
term2str t';
|
neuper@37906
|
472 |
term2str t'';
|
neuper@37906
|
473 |
"(9 - x ^^^ 2) / ((3 - x) * (3 - x)) + 1 * (3 - x) / ((3 - x) * (3 - x))";
|
neuper@37906
|
474 |
"(4 + x) / (3 - x)";
|
neuper@37906
|
475 |
|
neuper@37906
|
476 |
(*WN021016 added -----vv---*)
|
neuper@37906
|
477 |
val t = str2term "(9 - x^^^2) / (9 - 6*x + x^^^2) + 1";
|
neuper@37926
|
478 |
val SOME (t',_) = common_nominator_ thy t;
|
neuper@37926
|
479 |
val SOME (t'',_) = add_fraction_ thy t;
|
neuper@38041
|
480 |
term2str t' = "(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n1" ^
|
neuper@38041
|
481 |
" * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
|
neuper@37906
|
482 |
term2str t'' = "6 / (3 - x)" (*true*);
|
neuper@37906
|
483 |
|
neuper@37906
|
484 |
val t = str2term "1 + (9 - x^^^2) / (9 - 6*x + x^^^2)";
|
neuper@37926
|
485 |
val SOME (t',_) = common_nominator_ thy t;
|
neuper@37926
|
486 |
val SOME (t'',_) = add_fraction_ thy t;
|
neuper@38041
|
487 |
term2str t' = "1 * (9 - 6 * x + x ^^^ 2) / (9 - 6 * x + x ^^^ 2) +\n" ^
|
neuper@38041
|
488 |
"(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)" (*true*);
|
neuper@37906
|
489 |
term2str t'' = "6 / (3 - x)" (*true*);
|
neuper@37906
|
490 |
(*WN021016 added -----^^---*)
|
neuper@37926
|
491 |
(*WN030602 added -----vv--- no rewrite -> NONE !*)
|
neuper@37906
|
492 |
val t = str2term "1 / a";
|
neuper@37926
|
493 |
val NONE = cancel_p_ thy t;
|
neuper@37926
|
494 |
val NONE = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
495 |
(*WN.2.6.03 added -------^^---*)
|
neuper@37906
|
496 |
|
neuper@37906
|
497 |
val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2)";
|
neuper@37926
|
498 |
val SOME (t',_) = factout_ thy t;
|
neuper@37926
|
499 |
val SOME (t'',_) = cancel_ thy t;
|
neuper@37906
|
500 |
term2str t' = "(y + x) * (y - x) / ((y - x) * (y - x))"(*true*);
|
neuper@37906
|
501 |
term2str t'' = "(y + x) / (y - x)";
|
neuper@37906
|
502 |
|
neuper@37906
|
503 |
val t = str2term "(y^^^2 - x^^^2)/(y^^^2 - 2*y*x + x^^^2) + 1 / (y - x)";
|
neuper@37926
|
504 |
val SOME (t',_) = common_nominator_ thy t;
|
neuper@37926
|
505 |
val SOME (t'',_) = add_fraction_ thy t;
|
neuper@37906
|
506 |
term2str t' =
|
neuper@38041
|
507 |
"(-1 * x ^^^ 2 + y ^^^ 2) / ((-1 * x + y) * (-1 * x + y)) +\n1" ^
|
neuper@38041
|
508 |
" * (-1 * x + y) / ((-1 * x + y) * (-1 * x + y))" (*true*);
|
neuper@37906
|
509 |
term2str t'' = "(-1 - x - y) / (x - y)" (*true*);
|
neuper@37906
|
510 |
|
neuper@37906
|
511 |
val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2) + 1 / (x - y)";
|
neuper@37926
|
512 |
val SOME (t',_) = common_nominator_ thy t;
|
neuper@37926
|
513 |
val SOME (t'',_) = add_fraction_ thy t;
|
neuper@38041
|
514 |
if term2str t' = "(-1 * y ^^^ 2 + x ^^^ 2) / ((-1 * y + x) * (-1 * y + x))" ^
|
neuper@38041
|
515 |
" +\n1 * (-1 * y + x) / ((-1 * y + x) * (-1 * y + x))" then ()
|
neuper@38031
|
516 |
else error "rational.sml lex-ord 1";
|
neuper@37906
|
517 |
if term2str t'' = "(-1 - y - x) / (y - x)" then ()
|
neuper@38031
|
518 |
else error "rational.sml lex-ord 2";
|
neuper@37906
|
519 |
(*WN.16.10.02 WN070905 lexicographische Ordnung erhalten ! SK.ord*)
|
neuper@37906
|
520 |
|
neuper@37906
|
521 |
|
neuper@37906
|
522 |
val t = str2term "(x^^^2 - y^^^2)/(x^^^2 - 2*x*y + y^^^2)";
|
neuper@37926
|
523 |
val SOME (t',_) = norm_expanded_rat_ thy t;
|
neuper@37906
|
524 |
if term2str t' = "(x + y) / (x - y)" then ()
|
neuper@38041
|
525 |
else error "rational.sml term2poly: invalid x ^^^ 2 - y ^^^ 2 No.1";
|
neuper@37926
|
526 |
(*val SOME (t'',_) = norm_rational_ thy t;
|
neuper@37906
|
527 |
*** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial
|
neuper@37906
|
528 |
WN.16.10.02 ?! + WN060831???SK4
|
neuper@37906
|
529 |
WN070905 *** term2poly: invalid = x ^^^ 2 - y ^^^ 2*)
|
neuper@37906
|
530 |
|
neuper@37906
|
531 |
|
neuper@37906
|
532 |
val t = str2term "(9 - x^^^2)/(9 - 6*x + x^^^2) + (1)/(3 + x)";
|
neuper@37926
|
533 |
val SOME (t',_) = norm_expanded_rat_ thy t;
|
neuper@37906
|
534 |
if term2str t' = "(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)" then ()
|
neuper@38031
|
535 |
else error "rational.sml (9 - x^^^2)/(9 - 6*x + x^^^2) +...";
|
neuper@37926
|
536 |
(*val SOME (t'',_) = norm_rational_ thy t;
|
neuper@37906
|
537 |
*** RATIONALS_TERM2POLY_EXCEPTION: Invalid Polynomial WN.16.10.02 ?!
|
neuper@37906
|
538 |
WN070906 *** term2poly: invalid = 9 - x ^^^ 2 SK.term2poly*)
|
neuper@37906
|
539 |
|
neuper@37906
|
540 |
val t=(term_of o the o (parse thy))
|
neuper@37906
|
541 |
"(9 + (-1)* x^^^2)/(9 + (-1)* 6*x + x^^^2) + (1)/(3 + x)";
|
neuper@37926
|
542 |
val SOME (t',_) = norm_expanded_rat_ thy t;
|
neuper@37926
|
543 |
val SOME (t'',_) = norm_rational_ thy t;
|
neuper@37906
|
544 |
term2str t';
|
neuper@37906
|
545 |
term2str t'';
|
neuper@37906
|
546 |
"(12 + 5 * x + x ^^^ 2) / (9 - x ^^^ 2)";
|
neuper@37906
|
547 |
"(12 + 5 * x + x ^^^ 2) / (9 + (-1) * x ^^^ 2)";
|
neuper@37906
|
548 |
|
neuper@37906
|
549 |
|
neuper@38041
|
550 |
"-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
|
neuper@38041
|
551 |
"-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
|
neuper@38041
|
552 |
"-------- cancel from: Mathematik 1 Schalk Reniets Verlag";
|
neuper@41929
|
553 |
val thy = @{theory "Rational"};
|
neuper@37991
|
554 |
val thy' = "Rational";
|
neuper@37906
|
555 |
val rls' = "cancel";
|
neuper@37906
|
556 |
val mp = "make_polynomial";
|
neuper@37906
|
557 |
|
neuper@38041
|
558 |
writeln ("example 186:");
|
neuper@38041
|
559 |
writeln("a)");
|
neuper@37906
|
560 |
val e186a'="(14 * x * y) / ( x * y )";(*SRC*)
|
neuper@38041
|
561 |
rewrite_set_ thy false cancel (str2term e186a');
|
neuper@38041
|
562 |
"@@@@@@@@@@@@@@";
|
neuper@37906
|
563 |
val e186a = the (rewrite_set thy' false "cancel" e186a');
|
neuper@37906
|
564 |
is_expanded (parse_rat "14 * x * y");
|
neuper@37906
|
565 |
is_expanded (parse_rat "x * y");
|
neuper@38044
|
566 |
if e186a = ("14 / 1", "[\"y * x ~= 0\"]") then ()
|
neuper@38044
|
567 |
else error "rational.sml cancel Schalk e186a";
|
neuper@37906
|
568 |
|
neuper@38041
|
569 |
writeln("b)");
|
neuper@37906
|
570 |
val e186b'="(60 * a * b) / ( 15 * a * b )";
|
neuper@37906
|
571 |
val e186b = the (rewrite_set thy' false "cancel" e186b');
|
neuper@38041
|
572 |
writeln("c)");
|
neuper@37906
|
573 |
val e186c'="(144 * a^^^2 * b * c) / (12 * a * b * c )";
|
neuper@37906
|
574 |
val e186c = (the (rewrite_set thy' false "cancel" e186c'))
|
neuper@41930
|
575 |
handle e => print_exn_G e;
|
neuper@37906
|
576 |
val t = (term_of o the o (parse thy)) e186c';
|
neuper@38044
|
577 |
if e186c = ("12 * a / 1", "[\"12 * (c * (b * a)) ~= 0\"]") then ()
|
neuper@38044
|
578 |
else error "rational.sml cancel Schalk e186c";
|
neuper@37906
|
579 |
|
neuper@38041
|
580 |
writeln ("example 187:");
|
neuper@38041
|
581 |
writeln("a)");
|
neuper@37906
|
582 |
val e187a'="(12 * x * y) / (8 * y^^^2 )";(*SRC*)
|
neuper@37906
|
583 |
val e187a = the (rewrite_set thy' false "cancel" e187a');
|
neuper@38041
|
584 |
writeln("b)");
|
neuper@37906
|
585 |
val e187b'="(8 * x^^^2 * y * z ) / (18 * x * y^^^2 * z )";
|
neuper@37906
|
586 |
val e187b = the (rewrite_set thy' false "cancel" e187b');
|
neuper@38041
|
587 |
writeln("c)");
|
neuper@38044
|
588 |
val e187d'="(9 * x^^^5 * y^^^2 * z^^^4) / (15 * x^^^6 * y^^^3 * z )";(*SRC*)
|
neuper@38044
|
589 |
val e187d = the (rewrite_set thy' false "cancel" e187d');
|
neuper@38044
|
590 |
if e187d = ("3 * z ^^^ 3 / (5 * (y * x))",
|
neuper@38044
|
591 |
"[\"3 * (z * (y ^^^ 2 * x ^^^ 5)) ~= 0\"]") then ()
|
neuper@38044
|
592 |
else error "rational.sml cancel Schalk e186d";
|
neuper@37906
|
593 |
|
neuper@38044
|
594 |
writeln "example 188:";
|
neuper@37906
|
595 |
val e188a'="(-8 + 8 * x) / (-9 + 9 * x)";(*SRC*)
|
neuper@37906
|
596 |
val e188a = the (rewrite_set thy' false "cancel" e188a');
|
neuper@37906
|
597 |
is_expanded (parse_rat "8 * x + -8");
|
neuper@37906
|
598 |
(* e188a = ("8 / 9",["not ((-1) + x = 0)"]) then () 13.3.03*)
|
neuper@38044
|
599 |
if e188a = ("8 / 9", "[\"-1 + x ~= 0\"]") then ()
|
neuper@38031
|
600 |
else error "rational.sml: e188a new behaviour";
|
neuper@38044
|
601 |
|
neuper@38044
|
602 |
val SOME (t,_) = rewrite_set thy' false mp "(8*((-1) + x))/(9*((-1) + x))";
|
neuper@38041
|
603 |
writeln("b)");
|
neuper@37906
|
604 |
val e188b'="(-15 + 5 * x) / (-18 + 6 * x)";(*SRC*)
|
neuper@38044
|
605 |
val SOME (t, asm) = rewrite_set thy' false "cancel" e188b';
|
neuper@37906
|
606 |
t = "5 / 6" (*true*);
|
neuper@38041
|
607 |
writeln("c)");
|
neuper@37906
|
608 |
|
neuper@37906
|
609 |
val e188c'="( a + -1 * b ) / ( b + -1 * a )";
|
neuper@37906
|
610 |
val e188c = the (rewrite_set thy' false "cancel_p" e188c');
|
neuper@37906
|
611 |
(*is_expanded (parse_rat "a + -1 * b");*)
|
neuper@37926
|
612 |
val SOME (t,_) =
|
neuper@37906
|
613 |
rewrite_set thy' false mp "((-1)*(b + (-1) * a))/(1*(b + (-1) * a))";
|
neuper@37906
|
614 |
if t= "(a + -1 * b) / (-1 * a + b)" then()
|
neuper@38031
|
615 |
else error "rational.sml: e188c new behaviour";
|
neuper@37906
|
616 |
|
neuper@38041
|
617 |
writeln ("example 190:");
|
neuper@38041
|
618 |
writeln("c)");
|
neuper@37906
|
619 |
val e190c'="( 27 * a^^^3 + 9 * a^^^2 + 3 * a + 1 ) / ( 27 * a^^^3 + 18 * a^^^2 + 3 * a )";
|
neuper@37906
|
620 |
val e190c = the (rewrite_set thy' false "cancel" e190c');
|
neuper@37926
|
621 |
val SOME (t,_) = rewrite_set thy' false mp "((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
|
neuper@37906
|
622 |
if t = "(1 + 3 * a + 9 * a ^^^ 2 + 27 * a ^^^ 3) /\n(3 * a + 18 * a ^^^ 2 + 27 * a ^^^ 3)" then ()
|
neuper@38031
|
623 |
else error "rational.sml: e190c new behaviour";
|
neuper@37906
|
624 |
|
neuper@38041
|
625 |
writeln ("example 191:");
|
neuper@38041
|
626 |
writeln("a)");
|
neuper@37906
|
627 |
val e191a'="( x^^^2 + -1 * y^^^2 ) / ( x + y )";
|
neuper@37906
|
628 |
(*WN.23.10.02-------
|
neuper@37906
|
629 |
val e191a = the (rewrite_set thy' false "cancel" e191a');
|
neuper@37906
|
630 |
is_expanded (parse_rat "x^^^2 + -1 * y^^^2");
|
neuper@37906
|
631 |
false;
|
neuper@37906
|
632 |
is_expanded (parse_rat "x + y");
|
neuper@37906
|
633 |
true; -----------*)
|
neuper@37926
|
634 |
val SOME (t,_) = rewrite_set thy' false mp "((x + (-1) * y)*(x + y))/((1)*(x + y))";
|
neuper@37906
|
635 |
(* t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then() WN.13.3.03*)
|
neuper@37906
|
636 |
if t="(x ^^^ 2 + -1 * y ^^^ 2) / (x + y)" then()
|
neuper@38031
|
637 |
else error "rational.sml: e191a new behaviour";
|
neuper@37906
|
638 |
|
neuper@38041
|
639 |
writeln("c)");
|
neuper@37906
|
640 |
val e191c'="( 9 * x^^^2 + -30 * x + 25 ) / ( 9 * x^^^2 + -25 )";
|
neuper@37906
|
641 |
(*WN.23.10.02-------
|
neuper@37906
|
642 |
val e191c = the (rewrite_set thy' false "cancel" e191c');
|
neuper@37906
|
643 |
is_expanded (parse_rat "9 * x^^^2 + -30 * x + 25");
|
neuper@37906
|
644 |
false;
|
neuper@37906
|
645 |
is_expanded (parse_rat "25 + -30*x + 9*x^^^2");
|
neuper@37906
|
646 |
false;
|
neuper@37906
|
647 |
is_expanded (parse_rat "-25 + 9*x^^^2");
|
neuper@37906
|
648 |
true;------------*)
|
neuper@37926
|
649 |
val SOME (t,_) = rewrite_set thy' false mp "(((-5) + 3 * x)*((-5) + 3 * x))/((5 + 3 * x)*((-5) + 3 * x))";
|
neuper@37906
|
650 |
(* t="(25 + ((-30) * x + 9 * x ^^^ 2)) / ((-25) + 9 * x ^^^ 2)"then() 13.3.03*)
|
neuper@37906
|
651 |
if t= "(25 + -30 * x + 9 * x ^^^ 2) / (-25 + 9 * x ^^^ 2)" then()
|
neuper@38031
|
652 |
else error "rational.sml: 'e191c' new behaviour";
|
neuper@37906
|
653 |
|
neuper@37906
|
654 |
|
neuper@38041
|
655 |
writeln ("example 192:");
|
neuper@38041
|
656 |
writeln("b)");
|
neuper@37906
|
657 |
val e192b'="( 7 * x^^^3 + -1 * x^^^2 * y ) / ( 7 * x * y^^^2 + -1 * y^^^3 )";
|
neuper@37906
|
658 |
(*WN.23.10.02-------
|
neuper@37906
|
659 |
val e192b = the (rewrite_set thy' false "cancel" e192b');
|
neuper@37906
|
660 |
-------------------*)
|
neuper@37926
|
661 |
val SOME (t',_) = rewrite_set thy' false mp "((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
|
neuper@41931
|
662 |
(*========== inhibit exn 110317 ================================================
|
neuper@37906
|
663 |
if t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)"
|
neuper@37906
|
664 |
(*"(-1 * y * x ^^^ 2 + 7 * x ^^^ 3) / (-1 * y ^^^ 3 + 7 * x * y ^^^ 2)"WN050929*)
|
neuper@38031
|
665 |
then () else error "rational.sml: 'e192b' new behaviour";
|
neuper@37906
|
666 |
(*^^^ works with MG's simplifier vvv*)
|
neuper@37906
|
667 |
val t =str2term"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
|
neuper@38044
|
668 |
val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
|
neuper@38031
|
669 |
if term2str t' = "(7 * x ^^^ 3 + -1 * x ^^^ 2 * y) / (7 * x * y ^^^ 2 + -1 * y ^^^ 3)" then () else error "rational.sml: 'e192b'MG new behaviour";
|
neuper@41931
|
670 |
============ inhibit exn 110317 ==============================================*)
|
neuper@37906
|
671 |
|
neuper@38041
|
672 |
writeln ("example 193:");
|
neuper@38041
|
673 |
writeln("a)");
|
neuper@37906
|
674 |
val e193a'="( x^^^2 + -6 * x + 9 ) / ( x^^^2 + -9 )";
|
neuper@37906
|
675 |
(*WN.23.10.02-------
|
neuper@37906
|
676 |
val e193a = the (rewrite_set thy' false "cancel" e193a');
|
neuper@37906
|
677 |
-------------------*)
|
neuper@38041
|
678 |
writeln("b)");
|
neuper@37906
|
679 |
val e193b'="( x^^^2 + -8 * x + 16 ) / ( 2 * x^^^2 + -32 )";
|
neuper@37906
|
680 |
(*WN.23.10.02-------
|
neuper@37906
|
681 |
val e193b = the (rewrite_set thy' false "cancel" e193b');
|
neuper@38041
|
682 |
writeln("c)");
|
neuper@37906
|
683 |
val e193c'="( 2 * x + -50 * x^^^3 ) / ( 25 * x^^^2 + -10 * x + 1 )";
|
neuper@37926
|
684 |
val SOME(t,_) = rewrite_set thy' false "cancel" e193c';
|
neuper@37906
|
685 |
-------------------*)
|
neuper@37906
|
686 |
|
neuper@37906
|
687 |
val wn01 = "(-25 + 9*x^^^2)/(5 + 3*x)";
|
neuper@38044
|
688 |
val SOME (t, asm) = rewrite_set thy' false "cancel" wn01;
|
neuper@37906
|
689 |
(* t = "((-5) + 3 * x) / 1" then () WN.13.3.03*)
|
neuper@38044
|
690 |
if t = "(-5 + 3 * x) / 1" andalso asm = "[\"5 + 3 * x ~= 0\"]" then ()
|
neuper@38031
|
691 |
else error "rational.sml: new behav. in cancel wn01";
|
neuper@37906
|
692 |
|
neuper@38041
|
693 |
"-------- common_nominator_p ----------------------------";
|
neuper@38041
|
694 |
"-------- common_nominator_p ----------------------------";
|
neuper@38041
|
695 |
"-------- common_nominator_p ----------------------------";
|
neuper@37906
|
696 |
val rls' = "common_nominator_p";
|
neuper@37906
|
697 |
|
neuper@38041
|
698 |
writeln ("example 204:");
|
neuper@38041
|
699 |
writeln("a)");
|
neuper@37906
|
700 |
val e204a'="((5 * x) / 9) + ((3 * x) / 9) + (x / 9)";
|
neuper@37906
|
701 |
val e204a = the (rewrite_set thy' false "common_nominator_p" e204a');
|
neuper@38041
|
702 |
writeln("b)");
|
neuper@37906
|
703 |
val e204b'="5 / x + -3 / x + -1 / x";
|
neuper@37906
|
704 |
val e204b = the (rewrite_set thy' false "common_nominator_p" e204b');
|
neuper@38044
|
705 |
if e204b = ("1 / x", "[]") then ()
|
neuper@38044
|
706 |
else error "rational.sml common_nominator_p example e204b";
|
neuper@37906
|
707 |
|
neuper@38041
|
708 |
writeln ("example 205:");
|
neuper@38041
|
709 |
writeln("a)");
|
neuper@37906
|
710 |
val e205a'="((4 * x + 7) / 8) + ((4 * x + 3) / 8)";
|
neuper@37906
|
711 |
val e205a = the (rewrite_set thy' false "common_nominator_p" e205a');
|
neuper@38041
|
712 |
writeln("b)");
|
neuper@37906
|
713 |
val e205b'="((5 * x + 2) / 3) + ((-2 * x + 1) / 3)";
|
neuper@37906
|
714 |
val e205b = the (rewrite_set thy' false "common_nominator_p" e205b');
|
neuper@38044
|
715 |
if e205b = ("(1 + x) / 1", "[]") then ()
|
neuper@38044
|
716 |
else error "rational.sml common_nominator_p example e204b";
|
neuper@37906
|
717 |
|
neuper@38041
|
718 |
writeln ("example 206:");
|
neuper@38041
|
719 |
writeln("a)");
|
neuper@37906
|
720 |
val e206a'="((5 * x + 4) / (2 * x + -1)) + ((9 * x + 5) / (2 * x + -1))";
|
neuper@37906
|
721 |
val e206a = the (rewrite_set thy' false "common_nominator_p" e206a');
|
neuper@38041
|
722 |
writeln("b)");
|
neuper@37906
|
723 |
val e206b'="((17 * x + -23) / (5 * x + 4)) + ((-25 + -17 * x) / (5 * x + 4))";
|
neuper@37906
|
724 |
val e206b = the (rewrite_set thy' false "common_nominator_p" e206b');
|
neuper@37906
|
725 |
|
neuper@38041
|
726 |
writeln ("example 207:");
|
neuper@37906
|
727 |
val e207'="((3 * x * y + 3 * y) / (x * y)) + ((5 * x * y + 7 * y) / (x * y)) + ((9 * x * y + -2 * y) / (x * y)) + ((x * y + 4 * y) / (x * y)) ";
|
neuper@37906
|
728 |
val e207 = the (rewrite_set thy' false "common_nominator_p" e207');
|
neuper@37906
|
729 |
|
neuper@38041
|
730 |
writeln ("example 208:");
|
neuper@37906
|
731 |
val e208'="((3 * x + 2) / (x + 2)) + ((5 * x + -1) / (x + 2)) + ((-7 * x + -3) / (x + 2)) + ((-1 * x + -3) / (x + 2)) ";
|
neuper@37906
|
732 |
val e208 = the (rewrite_set thy' false "common_nominator_p" e208');
|
neuper@37906
|
733 |
|
neuper@38041
|
734 |
writeln ("example 209:");
|
neuper@37906
|
735 |
val e209'="((3 * x + -7 * y + 3 * z) / (4)) + ((2 * x + 17 * y + 10 * z) / (4)) + ((-1 * x + 2 * y + z) / (4)) ";
|
neuper@37906
|
736 |
val e209 = the (rewrite_set thy' false "common_nominator_p" e209');
|
neuper@37906
|
737 |
|
neuper@38041
|
738 |
writeln ("example 210:");
|
neuper@37906
|
739 |
val e210'="((2 * x + 3 + -1 * x^^^2) / (5 * x)) + ((5 * x^^^2 + -2 * x + 1) / (5 * x)) + ((-3 * x^^^2 + -2 * x + 1) / (5 * x)) + ((-1 * x^^^2 + -3 * x + -5) / (5 * x)) ";
|
neuper@37906
|
740 |
val e210 = the (rewrite_set thy' false "common_nominator_p" e210');
|
neuper@37906
|
741 |
|
neuper@38041
|
742 |
writeln ("example 211:");
|
neuper@38041
|
743 |
writeln("a)");
|
neuper@37906
|
744 |
val e211a'="((b) / (a + -1 * b)) + ((-1 * a) / (a + -1 * b))";
|
neuper@37906
|
745 |
val e211a = the (rewrite_set thy' false "common_nominator_p" e211a');
|
neuper@38041
|
746 |
writeln("b)");
|
neuper@37906
|
747 |
val e211b'="((b) / (b^^^2 + -1 * a^^^2)) + ((-1 * a) / (b^^^2 + -1 * a^^^2))";
|
neuper@37906
|
748 |
val e211b = the (rewrite_set thy' false "common_nominator_p" e211b');
|
neuper@37906
|
749 |
|
neuper@38041
|
750 |
writeln ("example 212:");
|
neuper@38041
|
751 |
writeln("a)");
|
neuper@37906
|
752 |
val e212a'="((4) / (x)) + ((-3) / (y)) + -1";
|
neuper@37906
|
753 |
val e212a = the (rewrite_set thy' false "common_nominator_p" e212a');
|
neuper@38041
|
754 |
writeln("b)");
|
neuper@37906
|
755 |
val e212b'="((4) / (x)) + ((-5) / (y)) + ((6) / (x*y))";
|
neuper@37906
|
756 |
val e212b = the (rewrite_set thy' false "common_nominator_p" e212b');
|
neuper@37906
|
757 |
|
neuper@38041
|
758 |
writeln ("example 213:");
|
neuper@38041
|
759 |
writeln("a)");
|
neuper@37906
|
760 |
val e213a'="((5 * x) / (3 * y^^^2)) + ((19 * z) / (6 * x * y)) + ((-2 * x) / (3 * y^^^2)) + ((7 * y^^^2) / (6 * x^^^2)) ";
|
neuper@37906
|
761 |
val e213a = the (rewrite_set thy' false "common_nominator_p" e213a');
|
neuper@38041
|
762 |
writeln("b)");
|
neuper@37906
|
763 |
val e213b'="((2 * b) / (3 * a^^^2)) + ((3 * c) / (7 * a * b)) + ((4 * b) / (3 * a^^^2)) + ((3 * a) / (7 * b^^^2))";
|
neuper@37906
|
764 |
val e213b = the (rewrite_set thy' false "common_nominator_p" e213b');
|
neuper@37906
|
765 |
|
neuper@38041
|
766 |
writeln ("example 214:");
|
neuper@38041
|
767 |
writeln("a)");
|
neuper@37906
|
768 |
val e214a'="((3 * x + 2 * y + 2 * z) / (4)) + ((-5 * x + -3 * y) / (3)) + ((x + y + -2 * z) / (2))";
|
neuper@37906
|
769 |
val e214a = the (rewrite_set thy' false "common_nominator_p" e214a');
|
neuper@38041
|
770 |
writeln("b)");
|
neuper@37906
|
771 |
val e214b'="((5 * x + 2 * y + z) / (2)) + ((-7 * x + -3 * y) / (3)) + ((3 * x + 6 * y + -1 * z) / (12))";
|
neuper@37906
|
772 |
val e214b = the (rewrite_set thy' false "common_nominator_p" e214b');
|
neuper@37906
|
773 |
|
neuper@38041
|
774 |
writeln ("example 216:");
|
neuper@38041
|
775 |
writeln("a)");
|
neuper@37906
|
776 |
val e216a'="((2 * b + 3 * c) / (a * c)) + ((3 * a + b) / (a * b)) + ((-2 * b^^^2 + -3 * a * c) / (a * b * c))";
|
neuper@37906
|
777 |
val e216a = the (rewrite_set thy' false "common_nominator_p" e216a');
|
neuper@38041
|
778 |
writeln("b)");
|
neuper@37906
|
779 |
val e216b'="((2 * a + 3 * b) / (b * c)) + ((3 * c + a) / (a * c)) + ((-2 * a^^^2 + -3 * b * c) / (a * b * c))";
|
neuper@37906
|
780 |
val e216b = the (rewrite_set thy' false "common_nominator_p" e216b');
|
neuper@37906
|
781 |
|
neuper@38041
|
782 |
writeln ("example 217:");
|
neuper@37906
|
783 |
val e217'="((z + -1) / (z)) + ((3 * z ^^^2 + -6 * z + 5) / (z^^^2)) + ((-4 * z^^^3 + 7 * z^^^2 + -5 * z + 5) / (z^^^3))";
|
neuper@37906
|
784 |
val e217 = the (rewrite_set thy' false "common_nominator_p" e217');
|
neuper@37906
|
785 |
|
neuper@37906
|
786 |
|
neuper@37906
|
787 |
val rls' = "common_nominator";
|
neuper@38041
|
788 |
writeln ("example 218:");
|
neuper@37906
|
789 |
val e218'="((9 * a^^^3 - 5 * a^^^2 + 2 * a + 8) / (108 * a^^^4)) + ((-5 * a + 3 * a^^^2 + 4) / (8 * a^^^3)) + ((-261 * a^^^3 + 19 * a^^^2 + -112 * a + 16) / (216 * a^^^4))";
|
neuper@37906
|
790 |
val e218 = the (rewrite_set thy' false "common_nominator" e218');
|
neuper@38044
|
791 |
if e218 = ("(16 - 63 * a ^^^ 2 - 81 * a ^^^ 3) / (108 * a ^^^ 4)", "[]") then ()
|
neuper@38044
|
792 |
else error "rationa.sml common_nominator example e218";
|
neuper@37906
|
793 |
|
neuper@38041
|
794 |
writeln ("example 219:");
|
neuper@38041
|
795 |
writeln("a)");
|
neuper@37906
|
796 |
val e219a'="((1) / (y + 1)) + ((1) / (y + 2)) + ((1) / (y + 3))";
|
neuper@37906
|
797 |
val e219a = the (rewrite_set thy' false "common_nominator" e219a');
|
neuper@38041
|
798 |
writeln("b)");
|
neuper@37906
|
799 |
val e219b'="((1) / (x + 1)) + ((1) / (x + 2)) + ((-2) / (x + 3))";
|
neuper@37906
|
800 |
val e219b = the (rewrite_set thy' false "common_nominator" e219b');
|
neuper@38044
|
801 |
if e219b = ("(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)", "[]") then ()
|
neuper@38044
|
802 |
else error "rationa.sml common_nominator example e219b";
|
neuper@37906
|
803 |
|
neuper@38041
|
804 |
writeln ("example 220:");
|
neuper@38041
|
805 |
writeln("a)");
|
neuper@37906
|
806 |
val e220a'="((17) / (5 * r + -2)) + ((-13) / (2 * r + 3)) + ((4) / (3 * r + -5))";
|
neuper@37906
|
807 |
val e220a = the (rewrite_set thy' false "common_nominator" e220a');
|
neuper@38041
|
808 |
writeln("b)");
|
neuper@37906
|
809 |
val e220b'="((20 * a) / (a + -3)) + ((-19 * a) / (a + -4)) + ((a) / (a + -5))";
|
neuper@37906
|
810 |
val e220b = the (rewrite_set thy' false "common_nominator" e220b');
|
neuper@37906
|
811 |
|
neuper@38041
|
812 |
writeln ("example 221:");
|
neuper@38041
|
813 |
writeln("a)");
|
neuper@37906
|
814 |
val e221a'="((a + b) / (a + -1 * b)) + ((a + -1 * b) / (a + b))";
|
neuper@37906
|
815 |
val e221a = the (rewrite_set thy' false "common_nominator" e221a');
|
neuper@38041
|
816 |
writeln("b)");
|
neuper@37906
|
817 |
val e221b'="((x + -1 * y) / (x + y)) + ((x + y) / (x + -1 * y)) ";
|
neuper@37906
|
818 |
val e221b = the (rewrite_set thy' false "common_nominator" e221b');
|
neuper@37906
|
819 |
|
neuper@38041
|
820 |
writeln ("example 222:");
|
neuper@38041
|
821 |
writeln("a)");
|
neuper@37906
|
822 |
val e222a'="((1 + -1 * x) / (1 + x)) + ((-1 + -1 * x) / (1 + -1 * x)) + ((4 * x) / (1 + -1 * x^^^2))";
|
neuper@37906
|
823 |
val e222a = the (rewrite_set thy' false "common_nominator" e222a');
|
neuper@38041
|
824 |
writeln("b)");
|
neuper@37906
|
825 |
val e222b'="((1 + x ) / (1 + -1 * x)) + ((-1 + x) / (1 + x)) + ((2 * x) / (1 + -1 * x^^^2))";
|
neuper@37906
|
826 |
val e222b = the (rewrite_set thy' false "common_nominator" e222b');
|
neuper@37906
|
827 |
|
neuper@38041
|
828 |
writeln ("example 225:");
|
neuper@38041
|
829 |
writeln("a)");
|
neuper@37906
|
830 |
val e225a'="((6 * a) / (a^^^2 + -64)) + ((a + 2) / (2 * a + 16)) + ((-1) / (2))";
|
neuper@37906
|
831 |
val e225a = the (rewrite_set thy' false "common_nominator" e225a');
|
neuper@38041
|
832 |
writeln("b)");
|
neuper@37906
|
833 |
val e225b'="((a + 2 ) / (2 * a + 12)) + ((4 * a) / (a^^^2 + -36)) + ((-1) / (2))";
|
neuper@37906
|
834 |
val e225b = the (rewrite_set thy' false "common_nominator" e225b');
|
neuper@37906
|
835 |
|
neuper@38041
|
836 |
writeln ("example 226:");
|
neuper@38041
|
837 |
writeln("a)");
|
neuper@37906
|
838 |
val e226a'="((35 * z) / (49 * z^^^2 + -4)) + -1 + ((14 * z + -1) / (14 * z + 4)) ";
|
neuper@37906
|
839 |
val e226a = the (rewrite_set thy' false "common_nominator" e226a');
|
neuper@38041
|
840 |
writeln("b)");
|
neuper@37906
|
841 |
val e226b'="((45 * a * b) / (25 * a^^^2 + -9 * b^^^2)) + ((20 * a + 3 * b) / (10 * a + 6 * b)) + -2";
|
neuper@37906
|
842 |
val e226b = the (rewrite_set thy' false "common_nominator" e226b');
|
neuper@37906
|
843 |
|
neuper@38041
|
844 |
writeln ("example 227:");
|
neuper@38041
|
845 |
writeln("a)");
|
neuper@37906
|
846 |
val e227a'="((6 * z + 11) / (6 * z + 14)) + ((9 * z ) / (9 * z^^^2 + -49)) + -1 ";
|
neuper@37906
|
847 |
val e227a = the (rewrite_set thy' false "common_nominator" e227a');
|
neuper@38041
|
848 |
writeln("b)");
|
neuper@37906
|
849 |
val e227b'="((16 * a + 37 * b) / (4 * a + 10 * b)) + ((6 * a * b) / (4 * a^^^2 + -25 * b^^^2)) + -4 ";
|
neuper@37906
|
850 |
val e227b = the (rewrite_set thy' false "common_nominator" e227b');
|
neuper@37906
|
851 |
|
neuper@38041
|
852 |
writeln ("example 228:");
|
neuper@38041
|
853 |
writeln("a)");
|
neuper@37906
|
854 |
val e228a'="((7 * a + 11) / (3 * a^^^2 + -3)) + ((-2 * a + -1) / (a^^^2 + -1 * a)) + ((-1) / (3 * a + 3))";
|
neuper@37906
|
855 |
val e228a = the (rewrite_set thy' false "common_nominator" e228a');
|
neuper@38041
|
856 |
writeln("b)");
|
neuper@37906
|
857 |
val e228b'="((11 * z + 2 * b) / (4 * b * z + -8 * b^^^2)) + ((-8 * z) / (z^^^2 + -4 * b^^^2)) + ((-9 * z + -2 * b) / (4 * b * z + 8 * b^^^2))";
|
neuper@37906
|
858 |
val e228b = the (rewrite_set thy' false "common_nominator" e228b');
|
neuper@37906
|
859 |
|
neuper@37906
|
860 |
|
neuper@38041
|
861 |
writeln ("example 229:");
|
neuper@38041
|
862 |
writeln("a)");
|
neuper@37906
|
863 |
val e229a'="((5 * x^^^2 + y) / (x + 2 * y)) + ((-8 * x^^^3 + 4 * x^^^2 * y + 3 * x * y) / (x^^^2 + -4 * y^^^2)) + ((3 * x^^^2 + -4 * y) / (x + -2 * y))";
|
neuper@37906
|
864 |
val e229a = the (rewrite_set thy' false "common_nominator" e229a');
|
neuper@38041
|
865 |
writeln("b)");
|
neuper@37906
|
866 |
val e229b'="((7 * x^^^2 + y) / (x + 3 * y)) + ((-24 * x^^^2 * y + 5 * x * y + 21 * y^^^2) / (x^^^2 + -9 * y^^^2)) + ((4 * x^^^2 + -6 * y) / (x + -3 * y))";
|
neuper@37906
|
867 |
val e229b = the (rewrite_set thy' false "common_nominator" e229b');
|
neuper@37906
|
868 |
|
neuper@38041
|
869 |
writeln ("example 230:");
|
neuper@38041
|
870 |
writeln("a)");
|
neuper@37906
|
871 |
val e230a'="((5 * x^^^2 + y) / (2 * x + y)) + ((-16 * x^^^3 + 2 * x^^^2 * y + 6 * x * y) / (4 * x^^^2 + -1 * y^^^2)) + ((3 * x^^^2 + -4 * y) / (2 * x + -1 * y))";
|
neuper@37906
|
872 |
val e230a = the (rewrite_set thy' false "common_nominator" e230a');
|
neuper@38041
|
873 |
writeln("b)");
|
neuper@37906
|
874 |
val e230b'="((7 * x^^^2 + y) / (3 * x + y)) + ((-3 * x^^^3 + 15 * x * y + -7 * x^^^2 * y + 7 * y^^^2) / (9 * x^^^2 + -1 * y^^^2)) + ((4 * x^^^2 + -6 * y) / (3 * x + -1 * y))";
|
neuper@37906
|
875 |
val e230b = the (rewrite_set thy' false "common_nominator" e230b');
|
neuper@37906
|
876 |
|
neuper@38041
|
877 |
writeln ("example 231:");
|
neuper@38041
|
878 |
writeln("a)");
|
neuper@37906
|
879 |
val e231a'="((2 * x + 5 * y) / (x)) + ((2 * x^^^3 + -5 * y^^^3 + 3 * x * y^^^2) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-3 * x + -6 * y) / (x + -1 * y))";
|
neuper@37906
|
880 |
val e231a = the (rewrite_set thy' false "common_nominator" e231a');
|
neuper@38041
|
881 |
writeln("b)");
|
neuper@37906
|
882 |
val e231b'="((6 * x + 2 * y) / (x)) + ((6 * x^^^2 * y + -4 * x * y^^^2 + -2 * y^^^3) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-5 * x + -3 * y) / (x + -1 * y))";
|
neuper@37906
|
883 |
val e231b = the (rewrite_set thy' false "common_nominator" e231b');
|
neuper@37906
|
884 |
|
neuper@38041
|
885 |
writeln ("example 232:");
|
neuper@38041
|
886 |
writeln("a)");
|
neuper@37906
|
887 |
val e232a'="((2 * x + 3 * y) / (x)) + ((4 * x^^^3 + -1 * x * y^^^2 + -3 * y^^^3) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-5 * x + -6 * y) / (x + -1 * y))";
|
neuper@37906
|
888 |
val e232a = the (rewrite_set thy' false "common_nominator" e232a');
|
neuper@38041
|
889 |
writeln("b)");
|
neuper@37906
|
890 |
val e232b'="((5 * x + 2 * y) / (x)) + ((2 * x^^^3 + -3 * x * y^^^2 + 3 * x^^^2 * y + -2 * y^^^3) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-6 * x + -3 * y) / (x + -1 * y))";
|
neuper@37906
|
891 |
val e232b = the (rewrite_set thy' false "common_nominator" e232b');
|
neuper@37906
|
892 |
|
neuper@38041
|
893 |
writeln ("example 233:");
|
neuper@38041
|
894 |
writeln("a)");
|
neuper@37906
|
895 |
val e233a'="((5 * x + 6 * y) / (x)) + ((5 * x * y^^^2 + -6 * y^^^3 + -2 * x^^^3 + 3 * x^^^2 * y) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-2 * x + -3 * y) / (x + -1 * y))";
|
neuper@37906
|
896 |
val e233a = the (rewrite_set thy' false "common_nominator" e233a');
|
neuper@38041
|
897 |
writeln("b)");
|
neuper@37906
|
898 |
val e233b'="((6 * x + 5 * y) / (x)) + ((4 * x^^^2 * y + 3 * x * y^^^2 + -5 * y^^^3 + -2 * x^^^3) / (x^^^3 + -2 * x^^^2 * y + x * y^^^2)) + ((-3 * x + -2 * y) / (x + -1 * y))";
|
neuper@37906
|
899 |
val e233b = the (rewrite_set thy' false "common_nominator" e233b');
|
neuper@37906
|
900 |
|
neuper@38041
|
901 |
writeln ("example 234:");
|
neuper@38041
|
902 |
writeln("a)");
|
neuper@37906
|
903 |
val e234a'="((5 * a + b) / (2 * a * b + -2 * b^^^2)) + ((-3 * a + -1 * b) / (2 * a * b + 2 * b^^^2)) + ((-2 * a) / (a^^^2 + -1 * b^^^2))";
|
neuper@37906
|
904 |
val e234a = the (rewrite_set thy' false "common_nominator" e234a');
|
neuper@38041
|
905 |
writeln("b)");
|
neuper@37906
|
906 |
val e234b'="((5 * a + 3 * b) / (6 * a * b + -18 * b^^^2)) + ((-3 * a + -3 * b) / (6 * a * b + 18 * b^^^2)) + ((-2 * a) / (a^^^2 + -9 * b^^^2)) ";
|
neuper@37906
|
907 |
val e234b = the (rewrite_set thy' false "common_nominator" e234b');
|
neuper@37906
|
908 |
|
neuper@38041
|
909 |
writeln ("example 235:");
|
neuper@38041
|
910 |
writeln("a)");
|
neuper@37906
|
911 |
val e235a'="((10 * x + 3 * y) / (12 * x * y + -18 * y^^^2)) + ((-6 * x + -3 * y) / (12 * x * y + 18 * y^^^2)) + ((-4 * x) / (4 * x^^^2 + -9 * y^^^2))";
|
neuper@37906
|
912 |
val e235a = the (rewrite_set thy' false "common_nominator" e235a');
|
neuper@38041
|
913 |
writeln("b)");
|
neuper@37906
|
914 |
val e235b'="((8 * a + b) / (4 * a * b + -2 * b^^^2)) + ((-4 * a + -1 * b) / (4 * a * b + 2 * b^^^2)) + ((-2 * a) / (4 * a^^^2 + -1 * b^^^2)) ";
|
neuper@37906
|
915 |
val e235b = the (rewrite_set thy' false "common_nominator" e235b');
|
neuper@37906
|
916 |
|
neuper@38041
|
917 |
writeln ("example 236:");
|
neuper@38041
|
918 |
writeln("a)");
|
neuper@37906
|
919 |
val e236a'="((8 * a + 5 * b) / (20 * a * b + -50 * b^^^2)) + ((-4 * a + -5 * b) / (20 * a * b + 50 * b^^^2)) + ((-2 * a) / (4 * a^^^2 + -25 * b^^^2))";
|
neuper@37906
|
920 |
val e236a = the (rewrite_set thy' false "common_nominator" e236a');
|
neuper@38041
|
921 |
writeln("b)");
|
neuper@37906
|
922 |
val e236b'="((24 * x + y) / (6 * x * y + -2 * y^^^2)) + ((-18 * x + -1 * y) / (6 * x * y + 2 * y^^^2)) + ((-15 * x) / (9 * x^^^2 + -1 * y^^^2)) ";
|
neuper@37906
|
923 |
val e236b = the (rewrite_set thy' false "common_nominator" e236b');
|
neuper@37906
|
924 |
|
neuper@37906
|
925 |
|
neuper@37906
|
926 |
val rls' = "cancel";
|
neuper@38041
|
927 |
writeln ("example heuberger:");
|
neuper@37906
|
928 |
val eheu'="(x^^^4 + x * y + x^^^3 * y + y^^^2) / (x + 5 * x^^^2 + y + 5 * x * y + x^^^2 * y^^^3 + x * y^^^4)";
|
neuper@37906
|
929 |
val eheu = the (rewrite_set thy' false "cancel" eheu');
|
neuper@37906
|
930 |
|
neuper@37906
|
931 |
val rls' = "common_nominator_p";
|
neuper@38041
|
932 |
writeln ("example stiefel:");
|
neuper@37906
|
933 |
val est1'="(7) / (-14) + (-2) / (4)";
|
neuper@37906
|
934 |
val est1 = the (rewrite_set thy' false "common_nominator_p" est1');
|
neuper@38044
|
935 |
if est1 = ("-1 / 1", "[]") then ()
|
neuper@38031
|
936 |
else error "new behaviour in rational.sml: est1'";
|
neuper@37906
|
937 |
|
neuper@37906
|
938 |
val t = (term_of o the o (parse thy))
|
neuper@37906
|
939 |
"(9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@37926
|
940 |
val SOME (t',_) = factout_ thy t;
|
neuper@38044
|
941 |
if term2str t' = "(3 + x) * (3 - x) / ((3 - x) * (3 - x))" then ()
|
neuper@38044
|
942 |
else error "rational.sml factout_ (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@37906
|
943 |
|
neuper@37906
|
944 |
|
neuper@38041
|
945 |
"-------- reverse rewrite -------------------------------";
|
neuper@38041
|
946 |
"-------- reverse rewrite -------------------------------";
|
neuper@38041
|
947 |
"-------- reverse rewrite -------------------------------";
|
neuper@37906
|
948 |
(*WN.28.8.02: tests for the 'reverse-rewrite' functions:
|
neuper@37906
|
949 |
these are defined in Rationals.ML and stored in
|
neuper@37906
|
950 |
the 'reverse-ruleset' cancel*)
|
neuper@37906
|
951 |
|
neuper@37906
|
952 |
(*the term for which reverse rewriting is demonstrated*)
|
neuper@37906
|
953 |
val t = (term_of o the o (parse thy))
|
neuper@37906
|
954 |
"(9 - x ^^^ 2) / (9 + 6 * x + x ^^^ 2)";
|
neuper@37906
|
955 |
val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
|
neuper@37906
|
956 |
next_rule=nex,normal_form=nor,...},...} = cancel;
|
neuper@37906
|
957 |
|
neuper@37906
|
958 |
(*normal_form produces the result in ONE step*)
|
neuper@37926
|
959 |
val SOME (t',_) = nor t;
|
neuper@38044
|
960 |
if term2str t' = "(3 - x) / (3 + x)" then ()
|
neuper@38044
|
961 |
else error "rational.sml normal_form (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@37906
|
962 |
|
neuper@37906
|
963 |
(*initialize the interpreter state used by the 'me'*)
|
neuper@37906
|
964 |
val (t,_,revsets,_) = ini t;
|
neuper@37906
|
965 |
|
neuper@37906
|
966 |
(*find the rule 'r' to apply to term 't'*)
|
neuper@38044
|
967 |
val SOME (r as (Thm (str, thm))) = nex revsets t;
|
neuper@38044
|
968 |
if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))"
|
neuper@38044
|
969 |
andalso string_of_thm thm =
|
neuper@41929
|
970 |
(string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
|
neuper@38044
|
971 |
(Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
|
neuper@38044
|
972 |
else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@38044
|
973 |
(* before Isa02->09-2 was not checked automatically, ?was different?:
|
neuper@38044
|
974 |
val SOME r = nex revsets t;
|
neuper@38044
|
975 |
val r = Thm ("sym_#mult_2_3","6 = 2 * 3") : rule*)
|
neuper@37906
|
976 |
|
neuper@38044
|
977 |
(* check, if the rule 'r' applied by the user to 't' belongs to the ruleset;
|
neuper@37906
|
978 |
if the rule is OK, the term resulting from applying the rule is returned,too;
|
neuper@37906
|
979 |
there might be several rule applications inbetween,
|
neuper@38044
|
980 |
which are listed after the head in reverse order *)
|
neuper@38044
|
981 |
val (r, (t, asm))::_ = loc revsets t r;
|
neuper@38044
|
982 |
if term2str t = "(9 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" andalso asm = []
|
neuper@38044
|
983 |
then ()
|
neuper@38044
|
984 |
else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@37906
|
985 |
|
neuper@38044
|
986 |
(* find the next rule to apply *)
|
neuper@38044
|
987 |
val SOME (r as (Thm (str, thm))) = nex revsets t;
|
neuper@38044
|
988 |
if str = "sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))" andalso
|
neuper@41929
|
989 |
string_of_thm thm = (string_of_thm o make_thm o (cterm_of (@{theory "Isac"})))
|
neuper@38044
|
990 |
(Trueprop $ (term_of o the o (parse thy)) "9 = 3 ^^^ 2") then ()
|
neuper@38044
|
991 |
else error "rational.sml next_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2)";
|
neuper@37906
|
992 |
|
neuper@37906
|
993 |
(*check the next rule*)
|
neuper@38044
|
994 |
val (r, (t, asm)) :: _ = loc revsets t r;
|
neuper@38044
|
995 |
if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 6 * x + x ^^^ 2)" then ()
|
neuper@38044
|
996 |
else error "rational.sml locate_rule (9 - x ^^^ 2) / (9 - 6 * x + x ^^^ 2) II";
|
neuper@37906
|
997 |
|
neuper@37906
|
998 |
(*find and check the next rules, rewrite*)
|
neuper@37926
|
999 |
val SOME r = nex revsets t;
|
neuper@37906
|
1000 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@38044
|
1001 |
if term2str t = "(3 ^^^ 2 - x ^^^ 2) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
|
neuper@38044
|
1002 |
else error "rational.sml locate_rule II";
|
neuper@37906
|
1003 |
|
neuper@37926
|
1004 |
val SOME r = nex revsets t;
|
neuper@37906
|
1005 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@38044
|
1006 |
if term2str t = "(3 - x) * (3 + x) / (3 ^^^ 2 + 2 * 3 * x + x ^^^ 2)" then ()
|
neuper@38044
|
1007 |
else error "rational.sml next_rule II";
|
neuper@37906
|
1008 |
|
neuper@37926
|
1009 |
val SOME r = nex revsets t;
|
neuper@37906
|
1010 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@38044
|
1011 |
if term2str t = "(3 - x) * (3 + x) / ((3 + x) * (3 + x))" then ()
|
neuper@38044
|
1012 |
else error "rational.sml next_rule III";
|
neuper@37906
|
1013 |
|
neuper@37926
|
1014 |
val SOME r = nex revsets t;
|
neuper@38044
|
1015 |
val (r, (t, asm)) :: _ = loc revsets t r;
|
neuper@37906
|
1016 |
val ss = term2str t;
|
neuper@38044
|
1017 |
if ss = "(3 - x) / (3 + x)" andalso terms2str asm = "[\"3 + x ~= 0\"]" then ()
|
neuper@38044
|
1018 |
else error "rational.sml: new behav. in rev-set cancel";
|
neuper@37906
|
1019 |
|
neuper@38041
|
1020 |
"-------- 'reverse-ruleset' cancel_p --------------------";
|
neuper@38041
|
1021 |
"-------- 'reverse-ruleset' cancel_p --------------------";
|
neuper@38041
|
1022 |
"-------- 'reverse-ruleset' cancel_p --------------------";
|
neuper@37906
|
1023 |
(*WN.11.9.02: the 'reverse-ruleset' cancel_p*)
|
neuper@37906
|
1024 |
|
neuper@37906
|
1025 |
(*the term for which reverse rewriting is demonstrated*)
|
neuper@37906
|
1026 |
val t = str2term "(9 + (-1)*x^^^2) / (9 + ((-6)*x + x^^^2))";
|
neuper@37906
|
1027 |
val Rrls {scr=Rfuns {init_state=ini,locate_rule=loc,
|
neuper@37906
|
1028 |
next_rule=nex,normal_form=nor,...},...} = cancel_p;
|
neuper@37906
|
1029 |
|
neuper@37906
|
1030 |
(*normal_form produces the result in ONE step*)
|
neuper@37926
|
1031 |
val SOME (t',_) = nor t;
|
neuper@37906
|
1032 |
term2str t' = "(3 + 1 * x) / (3 + -1 * x)";
|
neuper@37906
|
1033 |
|
neuper@37906
|
1034 |
(*initialize the interpreter state used by the 'me'*)
|
neuper@37926
|
1035 |
val SOME (t', asm) = cancel_p_ thy t;
|
neuper@37906
|
1036 |
term2str t' = "(3 + x) / (3 + -1 * x)" (*true*);
|
neuper@37906
|
1037 |
terms2str asm = "[\"3 + -1 * x ~= 0\"]" (*true*);
|
neuper@37906
|
1038 |
val (t,_,revsets,_) = ini t;
|
neuper@37906
|
1039 |
|
neuper@37906
|
1040 |
(* WN.10.10.02: dieser Fall terminiert nicht
|
neuper@37906
|
1041 |
(make_polynomial enth"alt zu viele rules)
|
neuper@37906
|
1042 |
WN060823 'init_state' requires rewriting on specified location in the term
|
neuper@37906
|
1043 |
print_depth 99; Rfuns; print_depth 3;
|
neuper@48763
|
1044 |
WN060831 cycling "sym_order_mult_rls_" "sym_mult_assoc"
|
neuper@37906
|
1045 |
as was with make_polynomial before ?!?*)
|
neuper@37906
|
1046 |
|
neuper@37926
|
1047 |
val SOME r = nex revsets t;
|
neuper@37906
|
1048 |
eq_Thm (r, Thm ("sym_#power_Float ((3,0), (0,0)) __ ((2,0), (0,0))",
|
neuper@38041
|
1049 |
mk_thm thy "9 = 3 ^^^ 2"));
|
neuper@37906
|
1050 |
(*WN060831 *** id_of_thm
|
neuper@37906
|
1051 |
Exception- ERROR raised ...
|
neuper@37906
|
1052 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@37906
|
1053 |
term2str t;
|
neuper@37906
|
1054 |
|
neuper@37926
|
1055 |
val SOME r = nex revsets t;
|
neuper@37906
|
1056 |
val (r,(t,asm))::_ = loc revsets t r;
|
neuper@37906
|
1057 |
term2str t;
|
neuper@37906
|
1058 |
*)
|
neuper@37906
|
1059 |
|
neuper@38041
|
1060 |
writeln "****************** all tests successfull *************************";
|
neuper@37906
|
1061 |
|
neuper@37906
|
1062 |
|
neuper@37906
|
1063 |
|
neuper@37906
|
1064 |
(*WN.17.3.03 =========================================================vvv---*)
|
neuper@38041
|
1065 |
"-------- norm_Rational ---------------------------------";
|
neuper@38041
|
1066 |
"-------- norm_Rational ---------------------------------";
|
neuper@38041
|
1067 |
"-------- norm_Rational ---------------------------------";
|
neuper@37906
|
1068 |
val t = str2term "(3*x+5)/18 - x/2 - -(3*x - 2)/9 = 0";
|
neuper@37926
|
1069 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
1070 |
if term2str t' = "1 / 18 = 0" then () else error "rational.sml 1";
|
neuper@37906
|
1071 |
|
neuper@37906
|
1072 |
val t = str2term "(17*x - 51)/9 - (-(13*x - 3)/6) + 11 - (9*x - 7)/4 = 0";
|
neuper@37926
|
1073 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
1074 |
if term2str t' = "(237 + 65 * x) / 36 = 0" then ()
|
neuper@38031
|
1075 |
else error "rational.sml 2";
|
neuper@37906
|
1076 |
|
neuper@37906
|
1077 |
val t = str2term "(1/2 + (5*x)/2)^^^2 - ((13*x)/2 - 5/2)^^^2 - (6*x)^^^2 + 29";
|
neuper@37926
|
1078 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
1079 |
if term2str t' = "23 + 35 * x + -72 * x ^^^ 2" then ()
|
neuper@38031
|
1080 |
else error "rational.sml 3";
|
neuper@38046
|
1081 |
|
neuper@37906
|
1082 |
(*trace_rewrite:=true;*)
|
neuper@37906
|
1083 |
val t = str2term "Not (6*x is_atom)";
|
neuper@37926
|
1084 |
val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
|
neuper@41928
|
1085 |
"HOL.True";
|
neuper@37906
|
1086 |
val t = str2term "1 < 2";
|
neuper@37926
|
1087 |
val SOME (t',_) = rewrite_set_ thy false powers_erls t; term2str t';
|
neuper@41928
|
1088 |
"HOL.True";
|
neuper@38046
|
1089 |
|
neuper@37906
|
1090 |
val t = str2term "(6*x)^^^2";
|
neuper@37926
|
1091 |
val SOME (t',_) = rewrite_ thy dummy_ord powers_erls false
|
neuper@38041
|
1092 |
(num_str @{thm realpow_def_atom}) t;
|
neuper@38046
|
1093 |
if term2str t' = "6 * x * (6 * x) ^^^ (2 + -1)" then ()
|
neuper@38046
|
1094 |
else error "rational.sml powers_erls (6*x)^^^2";
|
neuper@37906
|
1095 |
|
neuper@37906
|
1096 |
val t = str2term "-1 * (-2 * (5 / 2 * (13 * x / 2)))";
|
neuper@37926
|
1097 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
1098 |
if term2str t' = "65 * x / 2" then () else error "rational.sml 4";
|
neuper@37906
|
1099 |
|
neuper@37906
|
1100 |
val t = str2term "1 - ((13*x)/2 - 5/2)^^^2";
|
neuper@37926
|
1101 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
1102 |
(*bef.040209: if term2str t' = "(-21 + (130 * x + -169 * x ^^^ 2)) / 4"then()*)
|
neuper@37906
|
1103 |
if term2str t' = "(-21 + 130 * x + -169 * x ^^^ 2) / 4" then ()
|
neuper@38031
|
1104 |
else error "rational.sml 5";
|
neuper@37906
|
1105 |
|
neuper@37906
|
1106 |
(*SRAM Schalk I, p.92 Nr. 609a*)
|
neuper@37906
|
1107 |
val t = str2term "2*(3 - x/5)/3 - 4*(1 - x/3) - x/3 - 2*(x/2 - 1/4)/27 +5/54";
|
neuper@37926
|
1108 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
1109 |
if term2str t' = "(-255 + 112 * x) / 135" then ()
|
neuper@38031
|
1110 |
else error "rational.sml 6";
|
neuper@37906
|
1111 |
|
neuper@37906
|
1112 |
(*SRAM Schalk I, p.92 Nr. 610c*)
|
neuper@37906
|
1113 |
val t = str2term "((x- 1)/(x+1) + 1) / ((x- 1)/(x+1) - (x+1)/(x- 1)) - 2";
|
neuper@37926
|
1114 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
1115 |
if term2str t' = "(-3 + -1 * x) / 2" then () else error "rational.sml 7";
|
neuper@37906
|
1116 |
|
neuper@37906
|
1117 |
(*SRAM Schalk I, p.92 Nr. 476a*)
|
neuper@38046
|
1118 |
val t = str2term "(x^^^2/(1 - x^^^2) + 1)/(x/(1 - x) + 1) * (1 + x)";
|
neuper@38046
|
1119 |
(*. a/b : c/d translated to a/b * d/c .*)
|
neuper@37926
|
1120 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
1121 |
(*if term2str t' = "1 / 1" then () else error "rational.sml 8";3.6.03*)
|
neuper@38031
|
1122 |
if term2str t' = "1" then () else error "rational.sml 8";
|
neuper@37906
|
1123 |
|
neuper@37906
|
1124 |
(*............................vvv---TODO: sollte gehen mit poly_order *)
|
neuper@37906
|
1125 |
(*Schalk I, p.92 Nr. 472a*)
|
neuper@37906
|
1126 |
val t = str2term "((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/((4*x - 8*y)/(x + y))";
|
neuper@37926
|
1127 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38031
|
1128 |
if term2str t' = "x + y" then () else error "rational.sml p.92 Nr. 472a";
|
neuper@37906
|
1129 |
|
neuper@37906
|
1130 |
(*Schalk I, p.70 Nr. 480b; a/b : c/d translated to a/b * d/c*)
|
neuper@38046
|
1131 |
val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
|
neuper@38041
|
1132 |
"(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
|
neuper@38041
|
1133 |
"(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
|
neuper@38046
|
1134 |
"(20*x*y/(x^^^2 - 25*y^^^2))");
|
neuper@37906
|
1135 |
(*... nicht simpl, zerlegt ...*)
|
neuper@38046
|
1136 |
val t = str2term ("((12*x*y/(9*x^^^2 - y^^^2))/" ^
|
neuper@38046
|
1137 |
"(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2))");
|
neuper@37926
|
1138 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
1139 |
"(-12 * (x * y ^^^ 3) + 108 * (x * (y * x ^^^ 2))) / (12 * (x * y))";
|
neuper@37906
|
1140 |
(* ~~~~~~~~~~ poly_order notwendig!*)
|
neuper@38046
|
1141 |
val t = str2term ("(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
|
neuper@38046
|
1142 |
"(20*x*y/(x^^^2 - 25*y^^^2))");
|
neuper@37926
|
1143 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@38046
|
1144 |
if term2str t' = "1 / (x ^^^ 2 + -25 * y ^^^ 2)" then ()
|
neuper@38046
|
1145 |
else error "rational.sml norm_Rational 1 / (x ^^^ 2 + -25 * y ^^^ 2)";
|
neuper@37906
|
1146 |
|
neuper@37906
|
1147 |
"nonterm.SK6 ----- SK060904-2a non-termination of add_fraction_p_";
|
neuper@37906
|
1148 |
(*WN.2.6.03 from rlang.sml 56a
|
neuper@37906
|
1149 |
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@37926
|
1150 |
val NONE = rewrite_set_ thy false common_nominator_p t;
|
neuper@37906
|
1151 |
|
neuper@37906
|
1152 |
WN060831 nonterm.SK7
|
neuper@37906
|
1153 |
val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
|
neuper@37926
|
1154 |
val NONE = add_fraction_p_ thy t;
|
neuper@37906
|
1155 |
*)
|
neuper@37906
|
1156 |
|
neuper@37906
|
1157 |
|
neuper@37906
|
1158 |
(* ------------------------------------------------------------------- *)
|
neuper@37906
|
1159 |
(*---------vvv------------ MG: ab 1.7.03 ----------------vvv-----------*)
|
neuper@37906
|
1160 |
(* Simplifier fuer beliebige Buchterme *)
|
neuper@37906
|
1161 |
(* ------------------------------------------------------------------- *)
|
neuper@37906
|
1162 |
(*----------------------- norm_Rational_mg ----------------------------*)
|
neuper@37906
|
1163 |
(* ------------------------------------------------------------------- *)
|
neuper@37906
|
1164 |
|
neuper@38041
|
1165 |
"-------- numeral rationals -----------------------------";
|
neuper@38041
|
1166 |
"-------- numeral rationals -----------------------------";
|
neuper@38041
|
1167 |
"-------- numeral rationals -----------------------------";
|
neuper@37906
|
1168 |
(*SRA Schalk I, p.40 Nr. 164b *)
|
neuper@37906
|
1169 |
val t = str2term "(47/6 - 76/9 + 13/4)/(35/12)";
|
neuper@37926
|
1170 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1171 |
term2str t;
|
neuper@37906
|
1172 |
if (term2str t) = "19 / 21" then ()
|
neuper@38046
|
1173 |
else error "rational.sml: diff.behav. in norm_Rational_mg 1";
|
neuper@37906
|
1174 |
|
neuper@37906
|
1175 |
(*SRA Schalk I, p.40 Nr. 166a *)
|
neuper@37906
|
1176 |
val t = str2term "((5/4)/(4+22/7) + 37/20)*(110/3 - 110/9 * 23/11)";
|
neuper@37926
|
1177 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1178 |
term2str t;
|
neuper@37906
|
1179 |
if (term2str t) = "45 / 2" then ()
|
neuper@38046
|
1180 |
else error "rational.sml: diff.behav. in norm_Rational_mg 2";
|
neuper@37906
|
1181 |
|
neuper@37906
|
1182 |
|
neuper@38041
|
1183 |
"-------- cancellation ----------------------------------";
|
neuper@38041
|
1184 |
"-------- cancellation ----------------------------------";
|
neuper@38041
|
1185 |
"-------- cancellation ----------------------------------";
|
neuper@37906
|
1186 |
(* e190c Stefan K.*)
|
neuper@37906
|
1187 |
val t = str2term
|
neuper@37906
|
1188 |
"((1 + 9 * a ^^^ 2)*(1 + 3 * a))/((3 * a + 9 * a ^^^ 2)*(1 + 3 * a))";
|
neuper@37926
|
1189 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1190 |
term2str t;
|
neuper@37906
|
1191 |
if (term2str t) =
|
neuper@37906
|
1192 |
"(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
|
neuper@37906
|
1193 |
then ()
|
neuper@38046
|
1194 |
else error "rational.sml: diff.behav. in norm_Rational_mg 3";
|
neuper@37906
|
1195 |
|
neuper@37906
|
1196 |
(* e192b Stefan K.*)
|
neuper@37906
|
1197 |
val t = str2term
|
neuper@37906
|
1198 |
"((x ^^^ 2)*(7 * x + (-1) * y))/((y ^^^ 2)*(7 * x + (-1) * y))";
|
neuper@37926
|
1199 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1200 |
term2str t;
|
neuper@37906
|
1201 |
if (term2str t) =
|
neuper@37906
|
1202 |
"x ^^^ 2 / y ^^^ 2"
|
neuper@37906
|
1203 |
then ()
|
neuper@38046
|
1204 |
else error "rational.sml: diff.behav. in norm_Rational_mg 4";
|
neuper@37906
|
1205 |
|
neuper@37906
|
1206 |
(*SRC Schalk I, p.66 Nr. 379c *)
|
neuper@37906
|
1207 |
val t = str2term
|
neuper@37906
|
1208 |
"(a - b)/(b - a)";
|
neuper@37926
|
1209 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1210 |
term2str t;
|
neuper@37906
|
1211 |
if (term2str t) =
|
neuper@37906
|
1212 |
"-1"
|
neuper@37906
|
1213 |
then ()
|
neuper@38046
|
1214 |
else error "rational.sml: diff.behav. in norm_Rational_mg 5";
|
neuper@37906
|
1215 |
|
neuper@37906
|
1216 |
(*SRC Schalk I, p.66 Nr. 380b *)
|
neuper@37906
|
1217 |
val t = str2term
|
neuper@37906
|
1218 |
"15*(3*x+3)*(4*x+9)/(12*(2*x+7)*(5*x+5))";
|
neuper@37926
|
1219 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1220 |
term2str t;
|
neuper@37906
|
1221 |
if (term2str t) =
|
neuper@37906
|
1222 |
"(27 + 12 * x) / (28 + 8 * x)"
|
neuper@37906
|
1223 |
then ()
|
neuper@38046
|
1224 |
else error "rational.sml: diff.behav. in norm_Rational_mg 6";
|
neuper@37906
|
1225 |
|
neuper@37906
|
1226 |
(*Schalk I, p.60 Nr. 215c *)
|
neuper@37906
|
1227 |
(* Falsches Ergebnis: rechnet lange und cancel_p kann nicht weiter krzen!!!*)
|
neuper@37906
|
1228 |
(* WN060831????MG1
|
neuper@37906
|
1229 |
val t = str2term "(a+b)^^^4*(x - y)/((x - y)^^^3*(a+b)^^^2)";
|
neuper@37926
|
1230 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1231 |
term2str t;
|
neuper@37906
|
1232 |
if (term2str t) =
|
neuper@37906
|
1233 |
"(a ^^^ 4 * x + -1 * a ^^^ 4 * y + 4 * a ^^^ 3 * b * x + -4 * a ^^^ 3 * b * y + 6 * a ^^^ 2 * b ^^^ 2 * x + -6 * a ^^^ 2 * b ^^^ 2 * y + 4 * a * b ^^^ 3 * x + -4 * a * b ^^^ 3 * y + b ^^^ 4 * x + -1 * b ^^^ 4 * y) /(a ^^^ 2 * x ^^^ 3 + -3 * a ^^^ 2 * x ^^^ 2 * y + 3 * a ^^^ 2 * x * y ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 3 + 2 * a * b * x ^^^ 3 + -6 * a * b * x ^^^ 2 * y + 6 * a * b * x * y ^^^ 2 + -2 * a * b * y ^^^ 3 + b ^^^ 2 * x ^^^ 3 + -3 * b ^^^ 2 * x ^^^ 2 * y + 3 * b ^^^ 2 * x * y ^^^ 2 + -1 * b ^^^ 2 * y ^^^ 3)"
|
neuper@37906
|
1234 |
then ()
|
neuper@38046
|
1235 |
else error "rational.sml: diff.behav. in norm_Rational_mg 7";
|
neuper@37906
|
1236 |
*)
|
neuper@37906
|
1237 |
(*val t = str2term
|
neuper@37906
|
1238 |
"(a ^^^ 4 * x + -1 * a ^^^ 4 * y + 4 * a ^^^ 3 * b * x + -4 * a ^^^ 3 * b * y + 6 * a ^^^ 2 * b ^^^ 2 * x + -6 * a ^^^ 2 * b ^^^ 2 * y + 4 * a * b ^^^ 3 * x + -4 * a * b ^^^ 3 * y + b ^^^ 4 * x + -1 * b ^^^ 4 * y) /(a ^^^ 2 * x ^^^ 3 + -3 * a ^^^ 2 * x ^^^ 2 * y + 3 * a ^^^ 2 * x * y ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 3 + 2 * a * b * x ^^^ 3 + -6 * a * b * x ^^^ 2 * y + 6 * a * b * x * y ^^^ 2 + -2 * a * b * y ^^^ 3 + b ^^^ 2 * x ^^^ 3 + -3 * b ^^^ 2 * x ^^^ 2 * y + 3 * b ^^^ 2 * x * y ^^^ 2 + -1 * b ^^^ 2 * y ^^^ 3)"
|
neuper@37926
|
1239 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
1240 |
term2str t;*)
|
neuper@37906
|
1241 |
(* uncaught exception nonexhaustive binding failure
|
neuper@37906
|
1242 |
raised at: stdIn:93.1-93.51 *)
|
neuper@37906
|
1243 |
|
neuper@37906
|
1244 |
(*Schalk I, p.66 Nr. 381a *)
|
neuper@37906
|
1245 |
(* ACHTUNG: rechnet ca. 2 Minuten !!! *)
|
neuper@37906
|
1246 |
(* WN060831???MG2
|
neuper@37906
|
1247 |
val t = str2term "18*(a+b)^^^3*(a - b)^^^2/(72*(a - b)^^^3*(a+b)^^^2)";
|
neuper@37926
|
1248 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1249 |
term2str t;
|
neuper@37906
|
1250 |
if (term2str t) =
|
neuper@37906
|
1251 |
"(a + b) / (4 * a + -4 * b)"
|
neuper@38046
|
1252 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 8";
|
neuper@37906
|
1253 |
*)
|
neuper@37906
|
1254 |
|
neuper@37906
|
1255 |
(*SRC Schalk I, p.66 Nr. 381b *)
|
neuper@37906
|
1256 |
val t = str2term
|
neuper@37906
|
1257 |
"(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
|
neuper@37926
|
1258 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1259 |
term2str t;
|
neuper@37906
|
1260 |
if (term2str t) =
|
neuper@37906
|
1261 |
"-1 / (5 + -2 * x)"
|
neuper@37906
|
1262 |
then ()
|
neuper@38046
|
1263 |
else error "rational.sml: diff.behav. in norm_Rational_mg 9";
|
neuper@37906
|
1264 |
|
neuper@37906
|
1265 |
(*SRC Schalk I, p.66 Nr. 381c *)
|
neuper@37906
|
1266 |
val t = str2term
|
neuper@37906
|
1267 |
"(27*a^^^3+9*a^^^2+3*a+1)/(27*a^^^3+18*a^^^2+3*a)";
|
neuper@37926
|
1268 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1269 |
term2str t;
|
neuper@37906
|
1270 |
if (term2str t) =
|
neuper@37906
|
1271 |
"(1 + 9 * a ^^^ 2) / (3 * a + 9 * a ^^^ 2)"
|
neuper@37906
|
1272 |
then ()
|
neuper@38046
|
1273 |
else error "rational.sml: diff.behav. in norm_Rational_mg 10";
|
neuper@37906
|
1274 |
|
neuper@37906
|
1275 |
(*SRC Schalk I, p.66 Nr. 383a *)
|
neuper@37906
|
1276 |
val t = str2term
|
neuper@37906
|
1277 |
"(5*a^^^2 - 5*a*b)/(a - b)^^^2";
|
neuper@37926
|
1278 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1279 |
term2str t;
|
neuper@37906
|
1280 |
if (term2str t) =
|
neuper@37906
|
1281 |
"5 * a / (a + -1 * b)"
|
neuper@37906
|
1282 |
then ()
|
neuper@38046
|
1283 |
else error "rational.sml: diff.behav. in norm_Rational_mg 11";
|
neuper@37906
|
1284 |
|
neuper@37906
|
1285 |
|
neuper@38041
|
1286 |
"-------- common denominator ----------------------------";
|
neuper@38041
|
1287 |
"-------- common denominator ----------------------------";
|
neuper@38041
|
1288 |
"-------- common denominator ----------------------------";
|
neuper@37906
|
1289 |
(*SRA Schalk I, p.67 Nr. 403a *)
|
neuper@37906
|
1290 |
val t = str2term
|
neuper@37906
|
1291 |
"4/x - 3/y - 1";
|
neuper@37926
|
1292 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1293 |
term2str t;
|
neuper@37906
|
1294 |
if (term2str t) =
|
neuper@37906
|
1295 |
"(-3 * x + 4 * y + -1 * x * y) / (x * y)"
|
neuper@37906
|
1296 |
then ()
|
neuper@38046
|
1297 |
else error "rational.sml: diff.behav. in norm_Rational_mg 12";
|
neuper@37906
|
1298 |
|
neuper@37906
|
1299 |
(*SRA Schalk I, p.67 Nr. 407b *)
|
neuper@37906
|
1300 |
val t = str2term
|
neuper@37906
|
1301 |
"(2*a+3*b)/(b*c) + (3*c+a)/(a*c) - (2*a^^^2+3*b*c)/(a*b*c)";
|
neuper@37926
|
1302 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1303 |
term2str t;
|
neuper@37906
|
1304 |
if (term2str t) =
|
neuper@37906
|
1305 |
"4 / c"
|
neuper@37906
|
1306 |
then ()
|
neuper@38046
|
1307 |
else error "rational.sml: diff.behav. in norm_Rational_mg 13";
|
neuper@37906
|
1308 |
|
neuper@37906
|
1309 |
(*SRA Schalk I, p.67 Nr. 410b *)
|
neuper@37906
|
1310 |
val t = str2term
|
neuper@37906
|
1311 |
"1/(x+1) + 1/(x+2) - 2/(x+3)";
|
neuper@37926
|
1312 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1313 |
term2str t;
|
neuper@37906
|
1314 |
if (term2str t) =
|
neuper@37906
|
1315 |
"(5 + 3 * x) / (6 + 11 * x + 6 * x ^^^ 2 + x ^^^ 3)"
|
neuper@37906
|
1316 |
then ()
|
neuper@38046
|
1317 |
else error "rational.sml: diff.behav. in norm_Rational_mg 14";
|
neuper@37906
|
1318 |
|
neuper@37906
|
1319 |
(*SRA Schalk I, p.67 Nr. 413b *)
|
neuper@37906
|
1320 |
val t = str2term
|
neuper@37906
|
1321 |
"(1+x)/(1 - x) - (1 - x)/(1+x) + 2*x/(1 - x^^^2)";
|
neuper@37926
|
1322 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1323 |
term2str t;
|
neuper@37906
|
1324 |
if (term2str t) =
|
neuper@37906
|
1325 |
"6 * x / (1 + -1 * x ^^^ 2)"
|
neuper@37906
|
1326 |
then ()
|
neuper@38046
|
1327 |
else error "rational.sml: diff.behav. in norm_Rational_mg 15";
|
neuper@37906
|
1328 |
|
neuper@37906
|
1329 |
(*SRA Schalk I, p.68 Nr. 414a *)
|
neuper@37906
|
1330 |
val t = str2term
|
neuper@37906
|
1331 |
"(x + 2)/(x - 1) + (x - 3)/(x - 2) - (x + 1)/((x - 1)*(x - 2))";
|
neuper@37926
|
1332 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1333 |
term2str t;
|
neuper@37906
|
1334 |
if (term2str t) =
|
neuper@37906
|
1335 |
"(-2 + -5 * x + 2 * x ^^^ 2) / (2 + -3 * x + x ^^^ 2)"
|
neuper@37906
|
1336 |
then ()
|
neuper@38046
|
1337 |
else error "rational.sml: diff.behav. in norm_Rational_mg 16";
|
neuper@37906
|
1338 |
|
neuper@37906
|
1339 |
(*SRA Schalk I, p.68 Nr. 423a *)
|
neuper@37906
|
1340 |
val t = str2term
|
neuper@37906
|
1341 |
"(2*x+3*y)/x + (4*x^^^3 - x*y^^^2 - 3*y^^^3)/(x^^^3 - 2*x^^^2*y+x*y^^^2) - (5*x+6*y)/(x - y)";
|
neuper@37926
|
1342 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1343 |
term2str t;
|
neuper@37906
|
1344 |
if (term2str t) =
|
neuper@37906
|
1345 |
"1"
|
neuper@37906
|
1346 |
then ()
|
neuper@38046
|
1347 |
else error "rational.sml: diff.behav. in norm_Rational_mg 17";
|
neuper@37906
|
1348 |
|
neuper@37906
|
1349 |
(*SRA Schalk I, p.68 Nr. 428b *)
|
neuper@37906
|
1350 |
val t = str2term
|
neuper@37906
|
1351 |
"1/(a - b)^^^2 + 1/(a+b)^^^2 - 2/(a^^^2 - b^^^2) - 4*(b^^^2 - 1)/(a^^^2 - b^^^2)^^^2";
|
neuper@37926
|
1352 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1353 |
term2str t;
|
neuper@37906
|
1354 |
if (term2str t) =
|
neuper@37906
|
1355 |
"4 / (a ^^^ 4 + -2 * a ^^^ 2 * b ^^^ 2 + b ^^^ 4)"
|
neuper@37906
|
1356 |
then ()
|
neuper@38046
|
1357 |
else error "rational.sml: diff.behav. in norm_Rational_mg 18";
|
neuper@37906
|
1358 |
|
neuper@37906
|
1359 |
(*SRA Schalk I, p.68 Nr. 430b *)
|
neuper@37906
|
1360 |
val t = str2term
|
neuper@37906
|
1361 |
"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@37926
|
1362 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1363 |
term2str t;
|
neuper@37906
|
1364 |
if (term2str t) =
|
neuper@37906
|
1365 |
"a + 3 * b"
|
neuper@37906
|
1366 |
then ()
|
neuper@38046
|
1367 |
else error "rational.sml: diff.behav. in norm_Rational_mg 19";
|
neuper@37906
|
1368 |
|
neuper@37906
|
1369 |
|
neuper@37906
|
1370 |
(*SRA Schalk I, p.68 Nr. 432 *)
|
neuper@37906
|
1371 |
val t = str2term
|
neuper@37906
|
1372 |
"(a^^^2+a*b)/(a^^^2 - b^^^2) - (b^^^2 - a*b)/(b^^^2 - a^^^2) + a^^^2*(a - b)/(a^^^3 - a^^^2*b) - 2*a*(a^^^2 - b^^^2)/(a^^^3 - a*b^^^2) - 2*b^^^2/(a^^^2 - b^^^2)";
|
neuper@37926
|
1373 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1374 |
term2str t;
|
neuper@37906
|
1375 |
if (term2str t) =
|
neuper@37906
|
1376 |
"0"
|
neuper@37906
|
1377 |
then ()
|
neuper@38046
|
1378 |
else error "rational.sml: diff.behav. in norm_Rational_mg 20";
|
neuper@37906
|
1379 |
|
neuper@37906
|
1380 |
(*Eigenes*)
|
neuper@37906
|
1381 |
val t = str2term
|
neuper@37906
|
1382 |
"3*a/(a*b) + x/y";
|
neuper@37926
|
1383 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1384 |
term2str t;
|
neuper@37906
|
1385 |
if (term2str t) =
|
neuper@37906
|
1386 |
"(3 * y + b * x) / (b * y)"
|
neuper@37906
|
1387 |
then ()
|
neuper@38046
|
1388 |
else error "rational.sml: diff.behav. in norm_Rational_mg 21";
|
neuper@37906
|
1389 |
|
neuper@37906
|
1390 |
|
neuper@38041
|
1391 |
"-------- multiply and cancel ---------------------------";
|
neuper@38041
|
1392 |
"-------- multiply and cancel ---------------------------";
|
neuper@38041
|
1393 |
"-------- multiply and cancel ---------------------------";
|
neuper@37906
|
1394 |
(*SRM Schalk I, p.68 Nr. 436a *)
|
neuper@37906
|
1395 |
val t = str2term
|
neuper@37906
|
1396 |
"3*(x+y)/(15*(x - y)) * 25*(x - y)^^^2/(18*(x+y)^^^2)";
|
neuper@37926
|
1397 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1398 |
term2str t;
|
neuper@37906
|
1399 |
if (term2str t) =
|
neuper@37906
|
1400 |
"(5 * x + -5 * y) / (18 * x + 18 * y)"
|
neuper@37906
|
1401 |
then ()
|
neuper@38046
|
1402 |
else error "rational.sml: diff.behav. in norm_Rational_mg 22";
|
neuper@37906
|
1403 |
|
neuper@37906
|
1404 |
(*SRM.test Schalk I, p.68 Nr. 436b *)
|
neuper@37906
|
1405 |
(*WN060420???MG3 crashes with method 'simplify' in
|
neuper@37906
|
1406 |
IsacCore > Simplification > Rational Terms > Multiplication > No.2*)
|
neuper@37906
|
1407 |
val t = str2term "5*a*(a - b)^^^2*(a + b)^^^3/(7*b*(a - b)^^^3) * 7*b/(a + b)^^^3";
|
neuper@37926
|
1408 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1409 |
term2str t;
|
neuper@37906
|
1410 |
if (term2str t) =
|
neuper@37906
|
1411 |
"5 * a / (a + -1 * b)"
|
neuper@37906
|
1412 |
then ()
|
neuper@38046
|
1413 |
else error "rational.sml: diff.behav. in norm_Rational_mg 23";
|
neuper@37906
|
1414 |
|
neuper@37906
|
1415 |
(*Schalk I, p.68 Nr. 437a *)
|
neuper@37906
|
1416 |
val t = str2term "(3*a - 4*b)/(4*c+3*e) * (3*a+4*b)/(9*a^^^2 - 16*b^^^2)";
|
neuper@37926
|
1417 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1418 |
if (term2str t) = "1 / (4 * c + 3 * e)" then ()
|
neuper@38046
|
1419 |
else error "rational.sml: diff.behav. in norm_Rational_mg 24";
|
neuper@37906
|
1420 |
|
neuper@37906
|
1421 |
"----- S.K. corrected non-termination 060904";
|
neuper@37906
|
1422 |
val t = str2term "(3*a - 4*b) * (3*a+4*b)/((4*c+3*e)*(9*a^^^2 - 16*b^^^2))";
|
neuper@37926
|
1423 |
val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
|
neuper@41932
|
1424 |
term2str t';
|
neuper@41932
|
1425 |
if term2str t' =
|
neuper@41933
|
1426 |
"(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
|
1427 |
(*"(9 * a ^^^ 2 + -16 * b ^^^ 2) / (36 * a ^^^ 2 * c + 27 * a ^^^ 2 * e + -64 * b ^^^ 2 * c + -48 * b ^^^ 2 * e)"*)
|
neuper@41932
|
1428 |
then () else error "rational.sml: S.K.8..corrected 060904-6";
|
neuper@37906
|
1429 |
|
neuper@37906
|
1430 |
"----- S.K. corrected non-termination of cancel_p_";
|
neuper@38046
|
1431 |
val t'' = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
|
neuper@38046
|
1432 |
"(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
|
neuper@37926
|
1433 |
val SOME (t',_) = rewrite_set_ thy false cancel_p t'';
|
neuper@37906
|
1434 |
if term2str t' = "1 / (4 * c + 3 * e)" then ()
|
neuper@38046
|
1435 |
else error "rational.sml: diff.behav. in cancel_p S.K.8";
|
neuper@37906
|
1436 |
|
neuper@37906
|
1437 |
(*Schalk I, p.68 Nr. 437b *)
|
neuper@37906
|
1438 |
(* nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
|
neuper@37906
|
1439 |
val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
|
neuper@37926
|
1440 |
(* val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
|
neuper@37906
|
1441 |
*)
|
neuper@37906
|
1442 |
|
neuper@38046
|
1443 |
"================delete===";
|
neuper@37906
|
1444 |
(*a casual output from above*)
|
neuper@37906
|
1445 |
val t = str2term
|
neuper@37906
|
1446 |
"(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)";
|
neuper@37906
|
1447 |
(* WN060831 nonterm.SK10
|
neuper@37926
|
1448 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
1449 |
term2str t;
|
neuper@37906
|
1450 |
*)
|
neuper@37906
|
1451 |
|
neuper@37906
|
1452 |
(*SRM Schalk I, p.68 Nr. 438a *)
|
neuper@37906
|
1453 |
val t = str2term
|
neuper@37906
|
1454 |
"x*y/(x*y - y^^^2)*(x^^^2 - x*y)";
|
neuper@37926
|
1455 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1456 |
term2str t;
|
neuper@37906
|
1457 |
if (term2str t) =
|
neuper@37906
|
1458 |
"x ^^^ 2"
|
neuper@37906
|
1459 |
then ()
|
neuper@38046
|
1460 |
else error "rational.sml: diff.behav. in norm_Rational_mg 24";
|
neuper@37906
|
1461 |
|
neuper@37906
|
1462 |
(*SRM Schalk I, p.68 Nr. 439b *)
|
neuper@37906
|
1463 |
val t = str2term
|
neuper@37906
|
1464 |
"(4*x^^^2+4*x+1)*((x^^^2 - 2*x^^^3)/(4*x^^^2+2*x))";
|
neuper@37926
|
1465 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1466 |
term2str t;
|
neuper@37906
|
1467 |
if (term2str t) =
|
neuper@37906
|
1468 |
"(x + -4 * x ^^^ 3) / 2"
|
neuper@37906
|
1469 |
then ()
|
neuper@38046
|
1470 |
else error "rational.sml: diff.behav. in norm_Rational_mg 25";
|
neuper@37906
|
1471 |
|
neuper@37906
|
1472 |
(*SRM Schalk I, p.68 Nr. 440a *)
|
neuper@37906
|
1473 |
val t = str2term
|
neuper@37906
|
1474 |
"(x^^^2 - 2*x)/(x^^^2 - 3*x) * (x - 3)^^^2/(x^^^2 - 4)";
|
neuper@37926
|
1475 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1476 |
term2str t;
|
neuper@37906
|
1477 |
if (term2str t) =
|
neuper@37906
|
1478 |
"(-3 + x) / (2 + x)"
|
neuper@37906
|
1479 |
then ()
|
neuper@38046
|
1480 |
else error "rational.sml: diff.behav. in norm_Rational_mg 26";
|
neuper@37906
|
1481 |
|
neuper@37906
|
1482 |
"----- Schalk I, p.68 Nr. 440b SK11 works since 0707xx";
|
neuper@37906
|
1483 |
val t = str2term
|
neuper@37906
|
1484 |
"(a^^^3 - 9*a)/(a^^^3*b - a*b^^^3)*(a^^^2*b+a*b^^^2)/(a+3)";
|
neuper@37926
|
1485 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1486 |
if term2str t = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
|
neuper@38046
|
1487 |
else error "rational.sml: diff.behav. in norm_Rational 27";
|
neuper@37906
|
1488 |
|
neuper@37906
|
1489 |
"----- SK12 works since 0707xx";
|
neuper@37906
|
1490 |
val t = str2term "(a^^^3 - 9*a)*(a^^^2*b+a*b^^^2)/((a^^^3*b - a*b^^^3)*(a+3))";
|
neuper@37926
|
1491 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t; term2str t';
|
neuper@37906
|
1492 |
if term2str t' = "(-3 * a + a ^^^ 2) / (a + -1 * b)" then ()
|
neuper@38046
|
1493 |
else error "rational.sml: diff.behav. in norm_Rational 28";
|
neuper@37906
|
1494 |
|
neuper@37906
|
1495 |
|
neuper@38041
|
1496 |
"-------- common denominator and multiplication ---------";
|
neuper@38041
|
1497 |
"-------- common denominator and multiplication ---------";
|
neuper@38041
|
1498 |
"-------- common denominator and multiplication ---------";
|
neuper@37906
|
1499 |
(*SRAM Schalk I, p.69 Nr. 441b *)
|
neuper@37906
|
1500 |
val t = str2term "(4*a/3 + 3*b^^^2/a^^^3 + b/(4*a))*(4*b/(3*a))";
|
neuper@37926
|
1501 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1502 |
term2str t;
|
neuper@37906
|
1503 |
if (term2str t) =
|
neuper@41932
|
1504 |
"(36 * b ^^^ 3 + 3 * a ^^^ 2 * b ^^^ 2 + 16 * a ^^^ 4 * b) / (9 * a ^^^ 4)"
|
neuper@38046
|
1505 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 28";
|
neuper@37906
|
1506 |
|
neuper@37906
|
1507 |
(*SRAM Schalk I, p.69 Nr. 442b *)
|
neuper@37906
|
1508 |
val t = str2term "(15*a^^^2/x^^^3 - 5*b^^^4/x^^^2 + 25*c^^^2/x)*(x^^^3/(5*a*b^^^3*c^^^3)) + 1/c^^^3 * (b*x/a - 3*a/b^^^3)";
|
neuper@37926
|
1509 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1510 |
term2str t;
|
neuper@37906
|
1511 |
if (term2str t) =
|
neuper@37906
|
1512 |
"5 * x ^^^ 2 / (a * b ^^^ 3 * c)"
|
neuper@38046
|
1513 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 29";
|
neuper@37906
|
1514 |
|
neuper@37906
|
1515 |
(*SRAM Schalk I, p.69 Nr. 443b *)
|
neuper@37906
|
1516 |
val t = str2term "(a/2 + b/3)*(b/3 - a/2)";
|
neuper@37926
|
1517 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1518 |
term2str t;
|
neuper@37906
|
1519 |
if (term2str t) =
|
neuper@37906
|
1520 |
"(-9 * a ^^^ 2 + 4 * b ^^^ 2) / 36"
|
neuper@38046
|
1521 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 30";
|
neuper@37906
|
1522 |
|
neuper@37906
|
1523 |
(*SRAM Schalk I, p.69 Nr. 445b *)
|
neuper@37906
|
1524 |
val t = str2term "(a^^^2/9 + 2*a/(3*b) + 4/b^^^2)*(a/3 - 2/b) + 8/b^^^3";
|
neuper@37926
|
1525 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1526 |
term2str t;
|
neuper@37906
|
1527 |
if (term2str t) =
|
neuper@37906
|
1528 |
"a ^^^ 3 / 27"
|
neuper@38046
|
1529 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 31";
|
neuper@37906
|
1530 |
|
neuper@37906
|
1531 |
(*SRAM Schalk I, p.69 Nr. 446b *)
|
neuper@37906
|
1532 |
val t = str2term "(x/(5*x + 4*y) - y/(5*x - 4*y) + 1)*(25*x^^^2 - 16*y^^^2)";
|
neuper@37926
|
1533 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1534 |
term2str t;
|
neuper@37906
|
1535 |
if (term2str t) =
|
neuper@37906
|
1536 |
"30 * x ^^^ 2 + -9 * x * y + -20 * y ^^^ 2"
|
neuper@37906
|
1537 |
then ()
|
neuper@38046
|
1538 |
else error "rational.sml: diff.behav. in norm_Rational_mg 32";
|
neuper@37906
|
1539 |
|
neuper@37906
|
1540 |
(*SRAM Schalk I, p.69 Nr. 449a *)(*Achtung: rechnet ca 8 Sekunden*)
|
neuper@37906
|
1541 |
val t = str2term
|
neuper@37906
|
1542 |
"(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@37926
|
1543 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1544 |
term2str t;
|
neuper@38046
|
1545 |
if (term2str t) = "(-81 * x ^^^ 4 + 16 * x ^^^ 8 * y ^^^ 4) / (81 * y ^^^ 8)"
|
neuper@38046
|
1546 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 33";
|
neuper@38046
|
1547 |
|
neuper@37906
|
1548 |
|
neuper@37906
|
1549 |
(*SRAM Schalk I, p.69 Nr. 450a *)
|
neuper@37906
|
1550 |
val t = str2term
|
neuper@37906
|
1551 |
"(4*x/(3*y)+2*y/(3*x))^^^2 - (2*y/(3*x) - 2*x/y)*(2*y/(3*x)+2*x/y)";
|
neuper@37926
|
1552 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1553 |
term2str t;
|
neuper@37906
|
1554 |
if (term2str t) =
|
neuper@37906
|
1555 |
"(52 * x ^^^ 2 + 16 * y ^^^ 2) / (9 * y ^^^ 2)"
|
neuper@37906
|
1556 |
then ()
|
neuper@38046
|
1557 |
else error "rational.sml: diff.behav. in norm_Rational_mg 34";
|
neuper@37906
|
1558 |
|
neuper@37906
|
1559 |
|
neuper@38041
|
1560 |
"-------- double fractions ------------------------------";
|
neuper@38041
|
1561 |
"-------- double fractions ------------------------------";
|
neuper@38041
|
1562 |
"-------- double fractions ------------------------------";
|
neuper@37906
|
1563 |
(*SRD Schalk I, p.69 Nr. 454b *)
|
neuper@37906
|
1564 |
val t = str2term
|
neuper@37906
|
1565 |
"((2 - x)/(2*a)) / (2*a/(x - 2))";
|
neuper@37926
|
1566 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1567 |
term2str t;
|
neuper@37906
|
1568 |
if (term2str t) =
|
neuper@37906
|
1569 |
"(-4 + 4 * x + -1 * x ^^^ 2) / (4 * a ^^^ 2)"
|
neuper@37906
|
1570 |
then ()
|
neuper@38046
|
1571 |
else error "rational.sml: diff.behav. in norm_Rational_mg 35";
|
neuper@37906
|
1572 |
|
neuper@37906
|
1573 |
(*SRD Schalk I, p.69 Nr. 455a *)
|
neuper@37906
|
1574 |
val t = str2term
|
neuper@37906
|
1575 |
"(a^^^2 + 1)/(a^^^2 - 1) / ((a+1)/(a - 1))";
|
neuper@37926
|
1576 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1577 |
term2str t;
|
neuper@37906
|
1578 |
if (term2str t) =
|
neuper@37906
|
1579 |
"(1 + a ^^^ 2) / (1 + 2 * a + a ^^^ 2)" then ()
|
neuper@38046
|
1580 |
else error "rational.sml: diff.behav. in norm_Rational_mg 36";
|
neuper@37906
|
1581 |
|
neuper@37906
|
1582 |
|
neuper@37906
|
1583 |
"----- Schalk I, p.69 Nr. 455b";
|
neuper@37906
|
1584 |
val t = str2term "(x^^^2 - 4)/(y^^^2 - 9)/((2+x)/(3 - y))";
|
neuper@37926
|
1585 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1586 |
if term2str t = "(2 + -1 * x) / (3 + y)" then ()
|
neuper@38046
|
1587 |
else error "rational.sml: diff.behav. in norm_Rational_mg 37";
|
neuper@37906
|
1588 |
|
neuper@37906
|
1589 |
"----- SK060904-1a non-termination of cancel_p_ ?: worked before 0707xx";
|
neuper@37906
|
1590 |
val t = str2term "(x^^^2 - 4)*(3 - y)/((y^^^2 - 9)*(2+x))";
|
neuper@37926
|
1591 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1592 |
if term2str t = "(2 + -1 * x) / (3 + y)" then ()
|
neuper@38046
|
1593 |
else error "rational.sml: diff.behav. in norm_Rational_mg 37b";
|
neuper@37906
|
1594 |
|
neuper@37906
|
1595 |
"----- ?: worked before 0707xx";
|
neuper@37906
|
1596 |
val t = str2term "(3 + -1 * y) / (-9 + y ^^^ 2)";
|
neuper@37926
|
1597 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1598 |
if term2str t = "-1 / (3 + y)" then ()
|
neuper@38031
|
1599 |
else error "rational.sml: -1 / (3 + y) norm_Rational";
|
neuper@37906
|
1600 |
|
neuper@37906
|
1601 |
(*SRD Schalk I, p.69 Nr. 456b *)
|
neuper@37906
|
1602 |
val t = str2term
|
neuper@37906
|
1603 |
"(b^^^3 - b^^^2)/(b^^^2+b)/(b^^^2 - 1)";
|
neuper@37926
|
1604 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1605 |
term2str t;
|
neuper@37906
|
1606 |
if (term2str t) = "b / (1 + 2 * b + b ^^^ 2)" then ()
|
neuper@38046
|
1607 |
else error "rational.sml: diff.behav. in norm_Rational_mg 38";
|
neuper@37906
|
1608 |
|
neuper@37906
|
1609 |
(*SRD Schalk I, p.69 Nr. 457b *)
|
neuper@37906
|
1610 |
val t = str2term
|
neuper@37906
|
1611 |
"(16*a^^^2 - 9*b^^^2)/(2*a+3*a*b) / ((4*a+3*b)/(4*a^^^2 - 9*a^^^2*b^^^2))";
|
neuper@37926
|
1612 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1613 |
term2str t;
|
neuper@37906
|
1614 |
if (term2str t) =
|
neuper@41932
|
1615 |
"8 * a ^^^ 2 + -6 * a * b + -12 * a ^^^ 2 * b + 9 * a * b ^^^ 2"
|
neuper@41932
|
1616 |
then () else error "rational.sml: diff.behav. in norm_Rational_mg 39";
|
neuper@37906
|
1617 |
|
neuper@37906
|
1618 |
"----- Schalk I, p.69 Nr. 458b works since 0707";
|
neuper@37906
|
1619 |
val t = str2term
|
neuper@37906
|
1620 |
"(2*a^^^2*x - a^^^2)/(a*x - b*x) / (b^^^2*(2*x - 1)/(x*(a - b)))";
|
neuper@37926
|
1621 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1622 |
if term2str t = "a ^^^ 2 / b ^^^ 2" then ()
|
neuper@38046
|
1623 |
else error "rational.sml: diff.behav. in norm_Rational_mg 39b";
|
neuper@37906
|
1624 |
|
neuper@37906
|
1625 |
(*SRD Schalk I, p.69 Nr. 459b *)
|
neuper@37906
|
1626 |
val t = str2term "(a^^^2 - b^^^2)/(a*b) / (4*(a+b)^^^2/a)";
|
neuper@37926
|
1627 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1628 |
if term2str t = "(a + -1 * b) / (4 * a * b + 4 * b ^^^ 2)" then ()
|
neuper@38046
|
1629 |
else error "rational.sml: diff.behav. in norm_Rational_mg 41";
|
neuper@37906
|
1630 |
|
neuper@37906
|
1631 |
|
neuper@37906
|
1632 |
(*Schalk I, p.69 Nr. 460b nonterm.SK
|
neuper@37906
|
1633 |
val t = str2term
|
neuper@37906
|
1634 |
"(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
|
neuper@37926
|
1635 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1636 |
if term2str t =
|
neuper@37906
|
1637 |
then ()
|
neuper@38046
|
1638 |
else error "rational.sml: diff.behav. in norm_Rational_mg 42";
|
neuper@37906
|
1639 |
|
neuper@37906
|
1640 |
val t = str2term
|
neuper@37906
|
1641 |
"9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
|
neuper@37926
|
1642 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1643 |
... non terminating.
|
neuper@37926
|
1644 |
val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
|
neuper@37906
|
1645 |
"(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)";
|
neuper@37926
|
1646 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t';
|
neuper@37906
|
1647 |
... non terminating.*)
|
neuper@37906
|
1648 |
|
neuper@37906
|
1649 |
(*SRD Schalk I, p.70 Nr. 472a *)
|
neuper@38046
|
1650 |
val t = str2term ("((8*x^^^2 - 32*y^^^2)/(2*x + 4*y))/" ^
|
neuper@38046
|
1651 |
"((4*x - 8*y)/(x + y))");
|
neuper@37926
|
1652 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1653 |
term2str t;
|
neuper@37906
|
1654 |
if (term2str t) =
|
neuper@37906
|
1655 |
"x + y"
|
neuper@37906
|
1656 |
then ()
|
neuper@38046
|
1657 |
else error "rational.sml: diff.behav. in norm_Rational_mg 43";
|
neuper@37906
|
1658 |
|
neuper@37906
|
1659 |
|
neuper@37906
|
1660 |
(*----------------------------------------------------------------------*)
|
neuper@37906
|
1661 |
(*---------------------- Einfache Dppelbrche --------------------------*)
|
neuper@37906
|
1662 |
(*----------------------------------------------------------------------*)
|
neuper@37906
|
1663 |
|
neuper@37906
|
1664 |
(*SRD Schalk I, p.69 Nr. 461a *)
|
neuper@37906
|
1665 |
val t = str2term
|
neuper@37906
|
1666 |
"(2/(x+3) + 2/(x - 3)) / (8*x/(x^^^2 - 9))";
|
neuper@37926
|
1667 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1668 |
term2str t;
|
neuper@37906
|
1669 |
if (term2str t) =
|
neuper@37906
|
1670 |
"1 / 2"
|
neuper@37906
|
1671 |
then ()
|
neuper@38046
|
1672 |
else error "rational.sml: diff.behav. in norm_Rational_mg 44";
|
neuper@37906
|
1673 |
|
neuper@37906
|
1674 |
(*SRD Schalk I, p.69 Nr. 464b *)
|
neuper@37906
|
1675 |
val t = str2term
|
neuper@37906
|
1676 |
"(a - a/(a - 2)) / (a + a/(a - 2))";
|
neuper@37926
|
1677 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1678 |
term2str t;
|
neuper@37906
|
1679 |
if (term2str t) =
|
neuper@37906
|
1680 |
"(3 + -1 * a) / (1 + -1 * a)"
|
neuper@37906
|
1681 |
then ()
|
neuper@38046
|
1682 |
else error "rational.sml: diff.behav. in norm_Rational_mg 45";
|
neuper@37906
|
1683 |
|
neuper@37906
|
1684 |
(*SRD Schalk I, p.69 Nr. 465b *)
|
neuper@37906
|
1685 |
val t = str2term
|
neuper@37906
|
1686 |
"((x+3*y)/9 + (4*y^^^2 - 9*z^^^2)/(16*x)) /(x/9+y/6+z/4)";
|
neuper@37926
|
1687 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1688 |
term2str t;
|
neuper@37906
|
1689 |
if (term2str t) =
|
neuper@37906
|
1690 |
"(4 * x + 6 * y + -9 * z) / (4 * x)"
|
neuper@37906
|
1691 |
then ()
|
neuper@38046
|
1692 |
else error "rational.sml: diff.behav. in norm_Rational_mg 46";
|
neuper@37906
|
1693 |
|
neuper@37906
|
1694 |
(*SRD Schalk I, p.69 Nr. 466b *)
|
neuper@37906
|
1695 |
val t = str2term
|
neuper@37906
|
1696 |
"((1 - 7*(x - 2)/(x^^^2 - 4)) / (6/(x+2))) / (3/(x+5)+30/(x^^^2 - 25))";
|
neuper@37926
|
1697 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1698 |
term2str t;
|
neuper@37906
|
1699 |
if (term2str t) =
|
neuper@37906
|
1700 |
"(25 + -10 * x + x ^^^ 2) / 18"
|
neuper@37906
|
1701 |
then ()
|
neuper@38046
|
1702 |
else error "rational.sml: diff.behav. in norm_Rational_mg 47";
|
neuper@37906
|
1703 |
|
neuper@37906
|
1704 |
(*SRD Schalk I, p.70 Nr. 469 *)
|
neuper@37906
|
1705 |
val t = str2term
|
neuper@37906
|
1706 |
"3*b^^^2/(4*a^^^2 - 8*a*b + 4*b^^^2)/(a/(a^^^2*b - b^^^3) + (a - b)/(4*a*b^^^2+4*b^^^3) - 1/(4*b^^^2))";
|
neuper@37926
|
1707 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1708 |
term2str t;
|
neuper@37906
|
1709 |
if (term2str t) =
|
neuper@37906
|
1710 |
"3 * b ^^^ 3 / (2 * a + -2 * b)"
|
neuper@37906
|
1711 |
then ()
|
neuper@38046
|
1712 |
else error "rational.sml: diff.behav. in norm_Rational_mg 48";
|
neuper@37906
|
1713 |
|
neuper@37906
|
1714 |
(*----------------------------------------------------------------------*)
|
neuper@37906
|
1715 |
(*---------------------- Mehrfache Dppelbrueche ------------------------*)
|
neuper@37906
|
1716 |
(*----------------------------------------------------------------------*)
|
neuper@37906
|
1717 |
|
neuper@37906
|
1718 |
(*SRD.test Schalk I, p.70 Nr. 476b *) (* Rechenzeit: 10 sec *)
|
neuper@37906
|
1719 |
(*WN060419 crashes with method 'simplify' ????SK*)
|
neuper@37906
|
1720 |
val t = str2term
|
neuper@37906
|
1721 |
"((a^^^2 - b^^^2)/(2*a*b)+2*a*b/(a^^^2 - b^^^2))/((a^^^2+b^^^2)/(2*a*b)+1) / ((a^^^2+b^^^2)^^^2/(a+b)^^^2)";
|
neuper@37926
|
1722 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1723 |
if term2str t = "1 / (a ^^^ 2 + -1 * b ^^^ 2)" then ()
|
neuper@38046
|
1724 |
else error "rational.sml: diff.behav. in norm_Rational_mg 49";
|
neuper@37906
|
1725 |
|
neuper@37906
|
1726 |
"----- Schalk I, p.70 Nr. 477a";
|
neuper@37906
|
1727 |
(* MG Achtung: terme explodieren; Bsp zu komplex;
|
neuper@37906
|
1728 |
L???ung sollte (ziemlich grosser) Faktorisierter Ausdruck sein
|
neuper@38041
|
1729 |
val t = str2term "b*y/(b - 2*y)/((b^^^2 - y^^^2)/(b+2*y)) /" ^
|
neuper@38041
|
1730 |
"(b^^^2*y+b*y^^^2)*(a+x)^^^2/((b^^^2 - 4*y^^^2)*(a+2*x)^^^2)";
|
neuper@37926
|
1731 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1732 |
|
neuper@37906
|
1733 |
|
neuper@38041
|
1734 |
val t = str2term "b*y*(b+2*y)*(b^^^2 - 4*y^^^2)*(a+2*x)^^^2 / " ^
|
neuper@38041
|
1735 |
"((b - 2*y)*(b^^^2 - y^^^2)*(b^^^2*y+b*y^^^2)*(a+x)^^^2)";
|
neuper@37926
|
1736 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t;
|
neuper@37906
|
1737 |
????SK ???MG*)
|
neuper@37906
|
1738 |
|
neuper@37906
|
1739 |
|
neuper@37906
|
1740 |
"----- Schalk I, p.70 Nr. 478b ----- Rechenzeit: 5 sec";
|
neuper@38046
|
1741 |
val t = str2term ("(a - (a*b+b^^^2)/(a+b))/(b+(a - b)/(1+(a+b)/(a - b))) / " ^
|
neuper@38046
|
1742 |
"((a - a^^^2/(a+b))/(a+(a*b)/(a - b)))");
|
neuper@37926
|
1743 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1744 |
if term2str t' =
|
neuper@37906
|
1745 |
"(2 * a ^^^ 3 + 2 * a ^^^ 2 * b) / (a ^^^ 2 * b + b ^^^ 3)"
|
neuper@37906
|
1746 |
then ()
|
neuper@38046
|
1747 |
else error "rational.sml: diff.behav. in norm_Rational_mg 51";
|
neuper@37906
|
1748 |
|
neuper@37906
|
1749 |
(* TODO.new_c:WN050820 STOP_REW_SUB introduced gave ...
|
neuper@38041
|
1750 |
if term2str t' = "(a ^^^ 4 + -1 * a ^^^ 2 * b ^^^ 2) /(a * b * (b + (a * (a + -1 * b) + -1 * b * (a + -1 * b)) / (2 * a)) * (a + -1 * b))" then ()
|
neuper@38031
|
1751 |
else error "rational.sml: works again";
|
neuper@37906
|
1752 |
re-outcommented with TODO.new_c: cvs before 071227, 11:50*)
|
neuper@37906
|
1753 |
|
neuper@37906
|
1754 |
|
neuper@37906
|
1755 |
|
neuper@37906
|
1756 |
(*Schalk I, p.70 Nr. 480a *)
|
neuper@37906
|
1757 |
(* Achtung: rechnet ewig; cancel_p kann nicht krzen: WN060831 nonterm.SK00
|
neuper@37906
|
1758 |
val t = str2term
|
neuper@37906
|
1759 |
"(1/x+1/y+1/z)/(1/x - 1/y - 1/z) / (2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z)))";
|
neuper@37926
|
1760 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1761 |
term2str t;
|
neuper@37906
|
1762 |
if (term2str t) =
|
neuper@37906
|
1763 |
|
neuper@37906
|
1764 |
then ()
|
neuper@38046
|
1765 |
else error "rational.sml: diff.behav. in norm_Rational_mg 52";
|
neuper@37906
|
1766 |
|
neuper@37906
|
1767 |
(*MG Berechne Zwischenergebnisse: WN060831 nonterm.SK00*)
|
neuper@37906
|
1768 |
val t = str2term
|
neuper@37906
|
1769 |
"(1/x+1/y+1/z)/(1/x - 1/y - 1/z)";
|
neuper@37926
|
1770 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1771 |
term2str t;
|
neuper@37906
|
1772 |
"(x ^^^ 2 * y ^^^ 2 * z + x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2) /
|
neuper@37906
|
1773 |
(-1 * x ^^^ 2 * y ^^^ 2 * z + -1 * x ^^^ 2 * y * z ^^^ 2 + x * y ^^^ 2 * z ^^^ 2)";
|
neuper@37906
|
1774 |
val t = str2term
|
neuper@37906
|
1775 |
"2*x^^^2/(x^^^2 - z^^^2)/(x/(x+z)+x/(x - z))";
|
neuper@37926
|
1776 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1777 |
term2str t;
|
neuper@37906
|
1778 |
"1"
|
neuper@37906
|
1779 |
|
neuper@37906
|
1780 |
(* SK 1. Ausdruck kann nicht weiter gekrzt werden; cancel_p !!!*)
|
neuper@37906
|
1781 |
### rls: cancel_p on:
|
neuper@37906
|
1782 |
(x ^^^ 2 * (y ^^^ 2 * z) + x ^^^ 2 * (y * z ^^^ 2) + x * (y ^^^ 2 * z ^^^ 2)) /
|
neuper@37906
|
1783 |
(-1 * (x ^^^ 2 * (y ^^^ 2 * z)) + -1 * (x ^^^ 2 * (y * z ^^^ 2)) + x * (y ^^^ 2 * z ^^^ 2))
|
neuper@37906
|
1784 |
GC #3.61.81.101.197.17503: (0 ms)
|
neuper@37906
|
1785 |
*** RATIONALS_DIRECT_CANCEL_EXCEPTION: Invalid fraction
|
neuper@37906
|
1786 |
|
neuper@37906
|
1787 |
val t = str2term
|
neuper@37906
|
1788 |
"(x^^^2 * (y^^^2 * z) + x^^^2 * (y * z^^^2) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y^^^2 * z)) + -1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
|
neuper@37926
|
1789 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
1790 |
term2str t;
|
neuper@37906
|
1791 |
(*uncaught exception nonexhaustive binding failure*)
|
neuper@37906
|
1792 |
|
neuper@37906
|
1793 |
(* Das kann er aber krzen !!????: *)
|
neuper@37906
|
1794 |
val t = str2term
|
neuper@37906
|
1795 |
"(x^^^2 * (y^^^2 * z) + x * (y^^^2 * z^^^2)) / (-1 * (x^^^2 * (y * z^^^2)) + x * (y^^^2 * z^^^2))";
|
neuper@37926
|
1796 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
1797 |
term2str t;
|
neuper@37906
|
1798 |
"(-1 * (y * x) + -1 * (z * y)) / (1 * (z * x) + -1 * (z * y))";
|
neuper@37906
|
1799 |
*)
|
neuper@37906
|
1800 |
|
neuper@37906
|
1801 |
|
neuper@38041
|
1802 |
"-------- crucial examples ------------------------------";
|
neuper@38041
|
1803 |
"-------- crucial examples ------------------------------";
|
neuper@38041
|
1804 |
"-------- crucial examples ------------------------------";
|
neuper@37906
|
1805 |
(*Schalk I, p.60 Nr. 215d *)
|
neuper@37906
|
1806 |
(* Achtung: rechnet ewig ...
|
neuper@37906
|
1807 |
val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
|
neuper@37926
|
1808 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1809 |
term2str t; noterm.SK
|
neuper@37906
|
1810 |
*)
|
neuper@37906
|
1811 |
|
neuper@37906
|
1812 |
(* Kein Wunder, denn Z???ler und Nenner extra als Polynom dargestellt ergibt:*)
|
neuper@37906
|
1813 |
(*
|
neuper@37906
|
1814 |
val t = str2term "(a-b)^^^3 * (x+y)^^^4";
|
neuper@37926
|
1815 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1816 |
term2str t;
|
neuper@38041
|
1817 |
"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@37906
|
1818 |
val t = str2term "((x+y)^^^2 * (a-b)^^^5)";
|
neuper@37926
|
1819 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1820 |
term2str t;
|
neuper@38041
|
1821 |
"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@37906
|
1822 |
*)
|
neuper@37906
|
1823 |
(*anscheinend macht dem Rechner das Krzen diese Bruches keinen Spass mehr ...*)
|
neuper@37906
|
1824 |
|
neuper@37906
|
1825 |
(*--------------------------------------------------------------------*)
|
neuper@37906
|
1826 |
(*Schalk I, p.70 Nr. 480b
|
neuper@38041
|
1827 |
val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
|
neuper@38041
|
1828 |
"(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
|
neuper@38041
|
1829 |
"(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
|
neuper@38041
|
1830 |
"(20*x*y/(x^^^2 - 25*y^^^2))";
|
neuper@37926
|
1831 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1832 |
SK.nonterm
|
neuper@37906
|
1833 |
Kann nicht weiter vereinfacht werden !!!!?? *)
|
neuper@37906
|
1834 |
|
neuper@37906
|
1835 |
(*--------------------------------------------------------------------*)
|
neuper@37906
|
1836 |
"---- MGs test set";
|
neuper@37906
|
1837 |
val t = str2term " (1 + x^^^5) / (y + x) + x^^^3 / x ";
|
neuper@37926
|
1838 |
val SOME (t,_) = rewrite_set_ thy false common_nominator_p t;
|
neuper@37906
|
1839 |
if term2str t = "(1 + x ^^^ 3 + x ^^^ 5 + y * x ^^^ 2) / (x + y)" then()
|
neuper@38031
|
1840 |
else error "";
|
neuper@37906
|
1841 |
|
neuper@37906
|
1842 |
(*--------------------------------------------------------------------*)
|
neuper@37906
|
1843 |
(* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3b
|
neuper@37906
|
1844 |
---> Sortierung FALSCH !! *)
|
neuper@37906
|
1845 |
val t = str2term "b^^^3 * a^^^5/a ";
|
neuper@37926
|
1846 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
1847 |
term2str t;
|
neuper@37906
|
1848 |
"1 * (a^^^4 * b^^^3) / 1"; (*OK*)
|
neuper@37906
|
1849 |
|
neuper@37906
|
1850 |
val t = str2term "b^^^3 * a^^^5/b ";
|
neuper@37926
|
1851 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
1852 |
term2str t;
|
neuper@37906
|
1853 |
"1 * (b^^^2 * a^^^5) / 1"; (*cancel_p sortiert hier falsch um!*)
|
neuper@37906
|
1854 |
|
neuper@37906
|
1855 |
(* Problem liegt NICHT bei ord_make_polynomial! (siehe folgende Bsple) *)
|
neuper@37906
|
1856 |
(*
|
neuper@37906
|
1857 |
val x = str2term "x"; val bdv = str2term "bdv";
|
neuper@37906
|
1858 |
val t1 = str2term "b^^^2 * a^^^5";
|
neuper@37906
|
1859 |
val t2 = str2term "a^^^5 * b^^^2 ";
|
neuper@37906
|
1860 |
ord_make_polynomial false Rational.thy [(x,bdv)] (t1,t2); (*false*)
|
neuper@37906
|
1861 |
*)
|
neuper@37906
|
1862 |
(* ==> "b^^^2 * a^^^5" > "a^^^5 * b^^^2 " ... OK!*)
|
neuper@37906
|
1863 |
|
neuper@37906
|
1864 |
(*--------------------------------------------------------------------*)
|
neuper@37906
|
1865 |
(* cancel_p liefert nicht immer Polynomnormalform (2): WN060831???SK3c
|
neuper@37906
|
1866 |
---> erzeugt berflssige "1 * ..."
|
neuper@37906
|
1867 |
|
neuper@37906
|
1868 |
val t = str2term "-1 / (3 + y)";
|
neuper@37906
|
1869 |
(*~~ *)
|
neuper@37926
|
1870 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
1871 |
term2str t;
|
neuper@37906
|
1872 |
"-1 / (3 + 1 * y)";
|
neuper@37906
|
1873 |
(********* Das ist das PROBLEM !!!!!!!??? *******************)
|
neuper@37906
|
1874 |
(* -1 im Z???ler der Angabe verursacht das Problem !*)
|
neuper@37906
|
1875 |
*)
|
neuper@37906
|
1876 |
|
neuper@37906
|
1877 |
(* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *)
|
neuper@37906
|
1878 |
"----- MGs test set";
|
neuper@37906
|
1879 |
val t = str2term "(a^^^2 + -1)/(a+1)";
|
neuper@37926
|
1880 |
val SOME (t',_) = rewrite_set_ thy false cancel_p t;
|
neuper@37906
|
1881 |
if term2str t' = "(-1 + a) / 1" then ()
|
neuper@38031
|
1882 |
else error "rational.sml MG tests 3d";
|
neuper@37906
|
1883 |
|
neuper@37906
|
1884 |
"----- NOT TERMINATING ?: worked before 0707xx";
|
neuper@37906
|
1885 |
val t = str2term "(a^^^2 - 1)*(b + 1) / ((b^^^2 - 1)*(a+1))";
|
neuper@37926
|
1886 |
val SOME (t'',_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
1887 |
if term2str t'' = "(1 + -1 * a) / (1 + -1 * b)" then ()
|
neuper@38031
|
1888 |
else error "rational.sml MG tests 3e";
|
neuper@37906
|
1889 |
|
neuper@37906
|
1890 |
"----- corrected SK060905";
|
neuper@37906
|
1891 |
val t = str2term "(4*x^^^2 - 20*x + 25)/(2*x - 5)^^^3";
|
neuper@37926
|
1892 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1893 |
if term2str t' = "-1 / (5 + -2 * x)" then ()
|
neuper@38031
|
1894 |
else error "rational.sml corrected SK060905";
|
neuper@37906
|
1895 |
|
neuper@37906
|
1896 |
|
neuper@38041
|
1897 |
"-------- examples for Stefan Karnels thesis ------------";
|
neuper@38041
|
1898 |
"-------- examples for Stefan Karnels thesis ------------";
|
neuper@38041
|
1899 |
"-------- examples for Stefan Karnels thesis ------------";
|
neuper@37906
|
1900 |
(*SRAM Schalk I, p.69 Nr. 442b --- abgewandelt*)
|
neuper@37906
|
1901 |
val t = str2term
|
neuper@37906
|
1902 |
"(15*a^^^4/(a*x^^^3) - 5*a*((b^^^4 - 5*c^^^2*x)/x^^^2))*(x^^^3/(5*a*b^^^3*c^^^3)) + a/c^^^3 * (x*(b/a) - 3*b*(a/b^^^4))";
|
neuper@37926
|
1903 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@37906
|
1904 |
term2str t;
|
neuper@37906
|
1905 |
if (term2str t) =
|
neuper@37906
|
1906 |
"5 * x ^^^ 2 / (b ^^^ 3 * c)"
|
neuper@37906
|
1907 |
then ()
|
neuper@38046
|
1908 |
else error "rational.sml: diff.behav. in norm_Rational_mg 53";
|
neuper@38046
|
1909 |
|
neuper@37906
|
1910 |
|
neuper@38041
|
1911 |
"-------- me Schalk I No.186 ----------------------------";
|
neuper@38041
|
1912 |
"-------- me Schalk I No.186 ----------------------------";
|
neuper@38041
|
1913 |
"-------- me Schalk I No.186 ----------------------------";
|
neuper@38083
|
1914 |
val fmz = ["Term ((14 * x * y) / ( x * y ))",
|
neuper@37906
|
1915 |
"normalform N"];
|
neuper@37906
|
1916 |
val (dI',pI',mI') =
|
neuper@37991
|
1917 |
("Rational",["rational","simplification"],
|
neuper@37906
|
1918 |
["simplification","of_rationals"]);
|
neuper@37906
|
1919 |
val p = e_pos'; val c = [];
|
neuper@37906
|
1920 |
val (p,_,f,nxt,_,pt) = CalcTreeTEST [(fmz, (dI',pI',mI'))];
|
neuper@37906
|
1921 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1922 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1923 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1924 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1925 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1926 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1927 |
val (p,_,f,nxt,_,pt) = me nxt p c pt;
|
neuper@37906
|
1928 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
1929 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;
|
neuper@37906
|
1930 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
|
neuper@37906
|
1931 |
val (p,_,f,nxt,_,pt) = me nxt p c pt; f2str f;(*++ for explicit script*)
|
neuper@37906
|
1932 |
case (f2str f, nxt) of
|
neuper@37906
|
1933 |
("14", ("End_Proof'", _)) => ()
|
neuper@38031
|
1934 |
| _ => error "rational.sml diff.behav. in me Schalk I No.186";
|
neuper@37906
|
1935 |
|
neuper@37906
|
1936 |
|
neuper@38041
|
1937 |
"-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
|
neuper@38041
|
1938 |
"-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
|
neuper@38041
|
1939 |
"-------- interSteps ..Simp_Rat_Double_No-1.xml ---------";
|
neuper@37906
|
1940 |
states:=[];
|
neuper@37906
|
1941 |
CalcTree
|
neuper@38083
|
1942 |
[(["Term (((2 - x)/(2*a)) / (2*a/(x - 2)))", "normalform N"],
|
neuper@37991
|
1943 |
("Rational",["rational","simplification"],
|
neuper@37906
|
1944 |
["simplification","of_rationals"]))];
|
neuper@37906
|
1945 |
Iterator 1;
|
neuper@37906
|
1946 |
moveActiveRoot 1;
|
neuper@37906
|
1947 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
1948 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
1949 |
|
neuper@37906
|
1950 |
interSteps 1 ([1],Res);
|
neuper@37906
|
1951 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
1952 |
|
neuper@37906
|
1953 |
|
neuper@38041
|
1954 |
"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
|
neuper@38041
|
1955 |
"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
|
neuper@38041
|
1956 |
"-------- interSteps ..Simp_Rat_Cancel_No-1.xml ---------";
|
neuper@37906
|
1957 |
states:=[];
|
neuper@37906
|
1958 |
CalcTree
|
neuper@38083
|
1959 |
[(["Term ((a^2 + -1*b^2) / (a^2 + -2*a*b + b^2))", "normalform N"],
|
neuper@37991
|
1960 |
("Rational",["rational","simplification"],
|
neuper@37906
|
1961 |
["simplification","of_rationals"]))];
|
neuper@37906
|
1962 |
Iterator 1;
|
neuper@37906
|
1963 |
moveActiveRoot 1;
|
neuper@37906
|
1964 |
autoCalculate 1 CompleteCalc;
|
neuper@37906
|
1965 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@41930
|
1966 |
(*========== inhibit exn 110314 ================================================
|
neuper@37906
|
1967 |
(*with explicit script done already... and removed [1,..] at below...
|
neuper@37906
|
1968 |
interSteps 1 ([1],Res);
|
neuper@37906
|
1969 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
1970 |
*)
|
neuper@37906
|
1971 |
interSteps 1 ([2],Res);
|
neuper@37906
|
1972 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
1973 |
|
neuper@37906
|
1974 |
interSteps 1 ([2,1],Res);
|
neuper@37906
|
1975 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@37906
|
1976 |
val newnds = children (get_nd pt [2,1]) (*see "fun detailrls"*);
|
neuper@37906
|
1977 |
(*if length newnds = 12 then () WN060905*)
|
neuper@37906
|
1978 |
if length newnds = 13 then ()
|
neuper@38031
|
1979 |
else error "rational.sml: interSteps cancel_p rev_rew_p";
|
neuper@37906
|
1980 |
|
neuper@37906
|
1981 |
val p = ([2,1,9],Res);
|
neuper@37906
|
1982 |
getTactic 1 p;
|
neuper@37906
|
1983 |
val (_, tac, _) = pt_extract (pt, p);
|
neuper@37926
|
1984 |
(*case tac of SOME (Rewrite ("sym_real_plus_binom_times1", _)) => ()
|
neuper@37906
|
1985 |
WN060905*)
|
neuper@37926
|
1986 |
case tac of SOME (Rewrite ("sym_real_add_mult_distrib2", _)) => ()
|
neuper@38031
|
1987 |
| _ => error "rational.sml: getTactic, sym_real_plus_binom_times1";
|
neuper@41930
|
1988 |
============ inhibit exn 110314 ==============================================*)
|
neuper@37906
|
1989 |
|
neuper@37906
|
1990 |
|
neuper@38041
|
1991 |
"-------- investigate rulesets for cancel_p -------------";
|
neuper@38041
|
1992 |
"-------- investigate rulesets for cancel_p -------------";
|
neuper@38041
|
1993 |
"-------- investigate rulesets for cancel_p -------------";
|
neuper@41930
|
1994 |
val thy = @{theory "Rational"};
|
neuper@37906
|
1995 |
"---------------- (a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
|
neuper@37906
|
1996 |
val t = str2term "(a^^^2 + -1*b^^^2) / (a^^^2 + -2*a*b + b^^^2)";
|
neuper@37906
|
1997 |
val tt = str2term "(1 * a + 1 * b) * (1 * a + -1 * b)"(*numerator only*);
|
neuper@37906
|
1998 |
"----- with rewrite_set_";
|
neuper@37926
|
1999 |
val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
|
neuper@37906
|
2000 |
term2str tt'= "a ^^^ 2 + -1 * b ^^^ 2" (*true*);
|
neuper@37906
|
2001 |
val tt = str2term "((1 * a + -1 * b) * (1 * a + -1 * b))"(*denominator only*);
|
neuper@37926
|
2002 |
val SOME (tt',asm) = rewrite_set_ thy false make_polynomial tt;
|
neuper@37906
|
2003 |
term2str tt' = "a ^^^ 2 + -2 * a * b + b ^^^ 2" (*true*);
|
neuper@37906
|
2004 |
|
neuper@37906
|
2005 |
"----- with make_deriv";
|
neuper@38046
|
2006 |
val SOME (tt, _) = factout_p_ thy t; term2str tt =
|
neuper@37906
|
2007 |
"(1 * a + 1 * b) * (1 * a + -1 * b) / ((1 * a + -1 * b) * (1 * a + -1 * b))";
|
neuper@37906
|
2008 |
(*
|
neuper@37906
|
2009 |
"--- with ruleset as before 060829";
|
neuper@37906
|
2010 |
val {rules, rew_ord=(_,ro),...} =
|
neuper@37906
|
2011 |
rep_rls (assoc_rls "make_polynomial");
|
neuper@37926
|
2012 |
val der = make_deriv thy Atools_erls rules ro NONE tt;
|
neuper@37906
|
2013 |
print_depth 99; map (term2str o #1) der; print_depth 3;
|
neuper@37906
|
2014 |
print_depth 99; map (rule2str o #2) der; print_depth 3;
|
neuper@38041
|
2015 |
... did not terminate*)
|
neuper@37906
|
2016 |
"--- with simpler ruleset";
|
neuper@37906
|
2017 |
val {rules, rew_ord=(_,ro),...} =
|
neuper@37906
|
2018 |
rep_rls (assoc_rls "rev_rew_p");
|
neuper@37926
|
2019 |
val der = make_deriv thy Atools_erls rules ro NONE tt;
|
neuper@37906
|
2020 |
print_depth 99; writeln (deriv2str der); print_depth 3;
|
neuper@37906
|
2021 |
|
neuper@37906
|
2022 |
print_depth 99; map (term2str o #1) der; print_depth 3;
|
neuper@37906
|
2023 |
"...,(-1 * b ^^^ 2 + a ^^^ 2) / (-2 * (a * b) + a ^^^ 2 + (-1 * b) ^^^ 2) ]";
|
neuper@37906
|
2024 |
print_depth 99; map (rule2str o #2) der; print_depth 3;
|
neuper@37906
|
2025 |
print_depth 99; map (term2str o #1 o #3) der; print_depth 3;
|
neuper@37906
|
2026 |
|
neuper@37926
|
2027 |
val der = make_deriv thy Atools_erls rules ro NONE
|
neuper@37906
|
2028 |
(str2term "(1 * a + 1 * b) * (1 * a + -1 * b)");
|
neuper@37906
|
2029 |
print_depth 99; writeln (deriv2str der); print_depth 3;
|
neuper@37906
|
2030 |
|
neuper@37906
|
2031 |
val {rules, rew_ord=(_,ro),...} =
|
neuper@37906
|
2032 |
rep_rls (assoc_rls "rev_rew_p");
|
neuper@37926
|
2033 |
val der = make_deriv thy Atools_erls rules ro NONE
|
neuper@37906
|
2034 |
(str2term "(1 * a + -1 * b) * (1 * a + -1 * b)");
|
neuper@37906
|
2035 |
print_depth 99; writeln (deriv2str der); print_depth 3;
|
neuper@37906
|
2036 |
print_depth 99; map (term2str o #1) der; print_depth 3;
|
neuper@37906
|
2037 |
(*WN060829 ...postponed*)
|
neuper@37906
|
2038 |
|
neuper@37906
|
2039 |
|
neuper@38041
|
2040 |
"-------- investigate format of factout_ and factout_p_ -";
|
neuper@38041
|
2041 |
"-------- investigate format of factout_ and factout_p_ -";
|
neuper@38041
|
2042 |
"-------- investigate format of factout_ and factout_p_ -";
|
neuper@37906
|
2043 |
val {rules, rew_ord = (_,ro),...} = rep_rls (assoc_rls "make_polynomial");
|
neuper@41930
|
2044 |
val (thy, eval_rls) = (@{theory "Rational"}, Atools_erls)(*see 'fun init_state'*);
|
neuper@37906
|
2045 |
val Rrls {scr = Rfuns {init_state,...},...} = assoc_rls "cancel_p";
|
neuper@37906
|
2046 |
|
neuper@38041
|
2047 |
"----- see Rational.ML, local cancel_p, fun init_state";
|
neuper@37906
|
2048 |
val t = str2term "(a^^^2 + (-1)*b^^^2) / (a^^^2 + (-2)*a*b + b^^^2)";
|
neuper@37926
|
2049 |
val SOME (t',_) = factout_p_ thy t; term2str t';
|
neuper@37906
|
2050 |
(*
|
neuper@37926
|
2051 |
val rtas = reverse_deriv thy eval_rls rules ro NONE t';
|
neuper@37906
|
2052 |
writeln(trtas2str rst);
|
neuper@37906
|
2053 |
*)
|
neuper@37906
|
2054 |
|
neuper@37906
|
2055 |
|
neuper@38041
|
2056 |
"----- see Rational.ML, local cancel_p, fun init_state";
|
neuper@37906
|
2057 |
val t = str2term "a^^^2 / a";
|
neuper@37926
|
2058 |
val SOME (t',_) = factout_p_ thy t;
|
neuper@37906
|
2059 |
term2str t' = "a * a / (1 * a)" (*true*);
|
neuper@37906
|
2060 |
(*... can be canceled with
|
neuper@37906
|
2061 |
real_mult_div_cancel2 ?k ~= 0 ==> ?m * ?k / (?n * ?k) = ?m / ?n"*)
|
neuper@37906
|
2062 |
(* sml/ME/rewtools.sml:
|
neuper@37926
|
2063 |
val rtas = reverse_deriv thy Atools_erls rules ro NONE t';
|
neuper@37906
|
2064 |
writeln (deri2str rtas);
|
neuper@37906
|
2065 |
*)
|
neuper@37906
|
2066 |
|
neuper@37906
|
2067 |
|
neuper@37906
|
2068 |
"-------- SK 060904 ----------------------------------------------";
|
neuper@37906
|
2069 |
"----- order on polynomials -- input + output";
|
neuper@41929
|
2070 |
val thy = @{theory "Isac"};
|
neuper@37906
|
2071 |
val t = str2term "(a + -1 * b) / (-1 * a + b)";
|
neuper@37926
|
2072 |
val SOME (t', _) = factout_p_ thy t; term2str t';
|
neuper@37926
|
2073 |
val SOME (t', _) = cancel_p_ thy t; term2str t';
|
neuper@37906
|
2074 |
|
neuper@37906
|
2075 |
val t = str2term "a*b*c*d / (d*e*f*g)";
|
neuper@37926
|
2076 |
val SOME (t', _) = cancel_p_ thy t; term2str t';
|
neuper@37906
|
2077 |
|
neuper@37906
|
2078 |
val t = str2term "a*(b*(c*d)) / (b*(e*(f*g)))";
|
neuper@37926
|
2079 |
val SOME (t', _) = cancel_p_ thy t; term2str t';
|
neuper@37906
|
2080 |
(*???order.SK ???*)
|
neuper@37906
|
2081 |
|
neuper@37906
|
2082 |
"----- SK060904-1a non-termination of cancel_p_ ? worked before 0707xx";
|
neuper@37906
|
2083 |
val t = str2term "(x^^^2 - 4)*(3 - y) / ((y^^^2 - 9)*(2+x))";
|
neuper@37926
|
2084 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
|
neuper@37906
|
2085 |
if term2str t' = "(2 + -1 * x) / (3 + y)" then ()
|
neuper@38031
|
2086 |
else error "rational.sml SK060904-1a worked since 0707xx";
|
neuper@37906
|
2087 |
|
neuper@37906
|
2088 |
"----- SK060904-1b non-termination of cancel_p_ ... worked before 0707xx";
|
neuper@41930
|
2089 |
val t = str2term ("(9 * a ^^^ 2 + -16 * b ^^^ 2) /" ^
|
neuper@41930
|
2090 |
"(36 * a^^^2 * c + (27 * a^^^2 * e + (-64 * b^^^2 * c + -48 * b^^^2 * e)))");
|
neuper@37926
|
2091 |
val SOME (t',_) = cancel_p_ thy t;
|
neuper@37906
|
2092 |
if term2str t' = "1 / (4 * c + 3 * e)" then ()
|
neuper@38031
|
2093 |
else error "rational.sml SK060904-1b";
|
neuper@37906
|
2094 |
|
neuper@37906
|
2095 |
|
neuper@37906
|
2096 |
"----- SK060904-2a non-termination of add_fraction_p_";
|
neuper@41930
|
2097 |
val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
|
neuper@41930
|
2098 |
" (-1 * a + b * x) / (a + b * x) ");
|
neuper@37906
|
2099 |
(* nonterm.SK
|
neuper@37926
|
2100 |
val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
|
neuper@37906
|
2101 |
|
neuper@37906
|
2102 |
common_nominator_p_ thy t;
|
neuper@38041
|
2103 |
" (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
|
neuper@38041
|
2104 |
" (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
|
neuper@37906
|
2105 |
|
neuper@37906
|
2106 |
add_fraction_p_ thy t;
|
neuper@38041
|
2107 |
" ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
|
neuper@38041
|
2108 |
" ((a + b * x)*(-1 * a + b * x)) ";
|
neuper@37979
|
2109 |
*)
|
neuper@37979
|
2110 |
|
neuper@37979
|
2111 |
|
neuper@38041
|
2112 |
"-------- how to stepwise construct Scripts -------------";
|
neuper@38041
|
2113 |
"-------- how to stepwise construct Scripts -------------";
|
neuper@38041
|
2114 |
"-------- how to stepwise construct Scripts -------------";
|
neuper@41929
|
2115 |
val thy = @{theory "Rational"};
|
neuper@37979
|
2116 |
(*no trailing _*)
|
neuper@37979
|
2117 |
val p1 = parse thy (
|
neuper@37979
|
2118 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@37980
|
2119 |
" (Rewrite_Set discard_minus False " ^
|
neuper@37979
|
2120 |
" t_t)");
|
neuper@37979
|
2121 |
|
neuper@37979
|
2122 |
(*required (): (Rewrite_Set discard_minus False)*)
|
neuper@37979
|
2123 |
val p2 = parse thy (
|
neuper@37979
|
2124 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@37979
|
2125 |
" (Rewrite_Set discard_minus False " ^
|
neuper@37979
|
2126 |
" t_t)");
|
neuper@37979
|
2127 |
|
neuper@37979
|
2128 |
val p3 = parse thy (
|
neuper@37979
|
2129 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@37979
|
2130 |
" ((Rewrite_Set discard_minus False) " ^
|
neuper@37979
|
2131 |
" t_t)");
|
neuper@37979
|
2132 |
|
neuper@37979
|
2133 |
val p4 = parse thy (
|
neuper@37979
|
2134 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@37979
|
2135 |
" ((Rewrite_Set discard_minus False) " ^
|
neuper@37979
|
2136 |
" t_t)");
|
neuper@37979
|
2137 |
|
neuper@37979
|
2138 |
val p5 = parse thy (
|
neuper@37979
|
2139 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@37979
|
2140 |
" ((Try (Rewrite_Set discard_minus False) " ^
|
neuper@37979
|
2141 |
" Try (Rewrite_Set discard_parentheses False)) " ^
|
neuper@37979
|
2142 |
" t_t)");
|
neuper@37979
|
2143 |
|
neuper@37979
|
2144 |
val p6 = parse thy (
|
neuper@37979
|
2145 |
"Script SimplifyScript (t_t::real) = " ^
|
neuper@37979
|
2146 |
" ((Try (Rewrite_Set discard_minus False) @@ " ^
|
neuper@37979
|
2147 |
" Try (Rewrite_Set rat_mult_poly False) @@ " ^
|
neuper@37979
|
2148 |
" Try (Rewrite_Set make_rat_poly_with_parentheses False) @@ " ^
|
neuper@37979
|
2149 |
" Try (Rewrite_Set cancel_p_rls False) @@ " ^
|
neuper@37979
|
2150 |
" (Repeat " ^
|
neuper@37979
|
2151 |
" ((Try (Rewrite_Set common_nominator_p_rls False) @@ " ^
|
neuper@37979
|
2152 |
" Try (Rewrite_Set rat_mult_div_pow False) @@ " ^
|
neuper@37979
|
2153 |
" Try (Rewrite_Set make_rat_poly_with_parentheses False) @@" ^
|
neuper@37979
|
2154 |
" Try (Rewrite_Set cancel_p_rls False) @@ " ^
|
neuper@37979
|
2155 |
" Try (Rewrite_Set rat_reduce_1 False)))) @@ " ^
|
neuper@37979
|
2156 |
" Try (Rewrite_Set discard_parentheses False)) " ^
|
neuper@37979
|
2157 |
" t_t)"
|
neuper@37979
|
2158 |
);
|
neuper@42301
|
2159 |
|
neuper@42301
|
2160 |
"----------- get_denominator ----------------------------";
|
neuper@42301
|
2161 |
"----------- get_denominator ----------------------------";
|
neuper@42301
|
2162 |
"----------- get_denominator ----------------------------";
|
neuper@42301
|
2163 |
val thy = @{theory Isac};
|
neuper@42301
|
2164 |
val t = term_of (the (parse thy "get_denominator ((a +x)/b)"));
|
neuper@42301
|
2165 |
val SOME (_, t') = eval_get_denominator "" 0 t thy;
|
neuper@42301
|
2166 |
if term2str t' = "get_denominator ((a + x) / b) = b" then ()
|
neuper@42301
|
2167 |
else error "get_denominator ((a + x) / b) = b"
|
neuper@42301
|
2168 |
|
neuper@42439
|
2169 |
|
neuper@42449
|
2170 |
"--------- several errpats in complicated term -------------------";
|
neuper@42449
|
2171 |
"--------- several errpats in complicated term -------------------";
|
neuper@42449
|
2172 |
"--------- several errpats in complicated term -------------------";
|
neuper@42449
|
2173 |
(*TODO: instead of Gabriella's example here (27.Jul.12) find a simpler one*)
|
neuper@42449
|
2174 |
states:=[];
|
neuper@42449
|
2175 |
CalcTree
|
neuper@42449
|
2176 |
[(["Term ((5*b + 25)/(a^2 - b^2) * (a - b)/(5*b))", "normalform N"],
|
neuper@42449
|
2177 |
("Rational",["rational","simplification"], ["simplification","of_rationals"]))];
|
neuper@42449
|
2178 |
Iterator 1;
|
neuper@42449
|
2179 |
moveActiveRoot 1;
|
neuper@42449
|
2180 |
autoCalculate 1 CompleteCalc;
|
neuper@42449
|
2181 |
val ((pt,p),_) = get_calc 1; show_pt pt;
|
neuper@42449
|
2182 |
|
neuper@48788
|
2183 |
"-------- nonterminating cancel_p, norm_Rational 2002 ---";
|
neuper@48788
|
2184 |
"-------- nonterminating cancel_p, norm_Rational 2002 ---";
|
neuper@48788
|
2185 |
"-------- nonterminating cancel_p, norm_Rational 2002 ---";
|
neuper@48788
|
2186 |
(*------------------------------------------------------------------------------------\
|
neuper@48788
|
2187 |
"--- WN121204: searched rational.sml for "nonterm", added new numbering" ^
|
neuper@48788
|
2188 |
" and thoroughly tested with this numbering subsequently";
|
neuper@48788
|
2189 |
"--- 1 ---";
|
neuper@48788
|
2190 |
WN.2.6.03 from rlang.sml 56a
|
neuper@48788
|
2191 |
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@48788
|
2192 |
val NONE = rewrite_set_ thy false common_nominator_p t;
|
neuper@48788
|
2193 |
"--- 2 ---";
|
neuper@48788
|
2194 |
WN060831 nonterm.SK7
|
neuper@48788
|
2195 |
val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
|
neuper@48788
|
2196 |
val NONE = add_fraction_p_ thy t;
|
neuper@48788
|
2197 |
"--- 3 ---";
|
neuper@48788
|
2198 |
nonterm.SK9 loops: cancel_p kann nicht weiter kuerzen!!! *)
|
neuper@48788
|
2199 |
val t'' = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
|
neuper@48788
|
2200 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t'';
|
neuper@48788
|
2201 |
"--- 4 ---";
|
neuper@48788
|
2202 |
val t = str2term
|
neuper@48788
|
2203 |
"(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)";
|
neuper@48788
|
2204 |
WN060831 nonterm.SK10
|
neuper@48788
|
2205 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t;
|
neuper@48788
|
2206 |
term2str t;
|
neuper@48788
|
2207 |
"--- 5 ---";
|
neuper@48788
|
2208 |
val t = str2term
|
neuper@48788
|
2209 |
"(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
|
neuper@48788
|
2210 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@48788
|
2211 |
if term2str t =
|
neuper@48788
|
2212 |
then ()
|
neuper@48788
|
2213 |
else error "rational.sml: diff.behav. in norm_Rational_mg 42";
|
neuper@48788
|
2214 |
"--- 6 ---";
|
neuper@48788
|
2215 |
val t = str2term
|
neuper@48788
|
2216 |
"9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
|
neuper@48788
|
2217 |
val SOME (t',_) = rewrite_set_ thy false norm_Rational t;
|
neuper@48788
|
2218 |
... non terminating.
|
neuper@48788
|
2219 |
"--- 7 ---";
|
neuper@48788
|
2220 |
val SOME (t',_) = rewrite_set_ thy false make_polynomial t;
|
neuper@48788
|
2221 |
"(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)";
|
neuper@48788
|
2222 |
val SOME (t,_) = rewrite_set_ thy false cancel_p t';
|
neuper@48788
|
2223 |
"--- 8 ---";
|
neuper@48788
|
2224 |
val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
|
neuper@48788
|
2225 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@48788
|
2226 |
"--- 9 ---";
|
neuper@48788
|
2227 |
val t = str2term "((12*x*y/(9*x^^^2 - y^^^2))/" ^
|
neuper@48788
|
2228 |
"(1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
|
neuper@48788
|
2229 |
"(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2)/" ^
|
neuper@48788
|
2230 |
"(20*x*y/(x^^^2 - 25*y^^^2))";
|
neuper@48788
|
2231 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational(*_mg*) t;
|
neuper@48788
|
2232 |
"--- 10 ---";
|
neuper@48788
|
2233 |
SK060904-2a non-termination of add_fraction_p_";
|
neuper@48788
|
2234 |
val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + " ^
|
neuper@48788
|
2235 |
" (-1 * a + b * x) / (a + b * x) ");
|
neuper@48788
|
2236 |
(* nonterm.SK
|
neuper@48788
|
2237 |
val SOME (t',_) = rewrite_set_ thy false common_nominator_p t;
|
neuper@48788
|
2238 |
"--- 11 ---";
|
neuper@48788
|
2239 |
common_nominator_p_ thy t;
|
neuper@48788
|
2240 |
" (a + b * x)*(a + b * x) / ((a + -1 * (b * x))*(a + -1 * (b * x))) + " ^
|
neuper@48788
|
2241 |
" (-1 * a + b * x)*(a + -1 * (b * x)) / ((a + b * x)*(-1 * a + b * x)) ";
|
neuper@48788
|
2242 |
"--- 12 ---";
|
neuper@48788
|
2243 |
add_fraction_p_ thy t;
|
neuper@48788
|
2244 |
" ((a + b * x)*(a + b * x) + (-1 * a + b * x)*(a + -1 * (b * x))) /" ^
|
neuper@48788
|
2245 |
" ((a + b * x)*(-1 * a + b * x)) ";
|
neuper@48788
|
2246 |
--------------------------------------------------------------------------------------/*)
|
neuper@48788
|
2247 |
|
neuper@48788
|
2248 |
(*------------------------------------------------------------------------------------\
|
neuper@48788
|
2249 |
"WN121205: thoroughly tested with the above numbering.";
|
neuper@48788
|
2250 |
" errors in cancel_p: --- 4,5,6,7.";
|
neuper@48788
|
2251 |
" error in common_nominator_p, common_nominator_p_: --- 10; 1,2?.";
|
neuper@48788
|
2252 |
" errors caused by ruleset norm_Rational: --- 8,9.";
|
neuper@48788
|
2253 |
trace_rewrite := true;
|
neuper@48788
|
2254 |
|
neuper@48788
|
2255 |
"--- 1 ---: non-terminating with ### add_fract: done t22 ";
|
neuper@48788
|
2256 |
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@48788
|
2257 |
trace_rewrite:= true;
|
neuper@48788
|
2258 |
rewrite_set_ thy false common_nominator_p t;
|
neuper@48788
|
2259 |
|
neuper@48788
|
2260 |
"--- 2 ---: non-terminating with ### add_fract: done t22 ";
|
neuper@48788
|
2261 |
val t = str2term "(a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)";
|
neuper@48788
|
2262 |
add_fraction_p_ thy t;
|
neuper@48788
|
2263 |
|
neuper@48788
|
2264 |
"--- 3 ---: norm_Rational calls Rrls cancel_p with non-normalised polys";
|
neuper@48788
|
2265 |
val t = str2term "(a + b)/(x^^^2 - y^^^2) * ((x - y)^^^2/(a^^^2 - b^^^2))";
|
neuper@48788
|
2266 |
rewrite_set_ thy false norm_Rational t;
|
neuper@48788
|
2267 |
(*tracing end...#### rls: cancel_p on:
|
neuper@48788
|
2268 |
(a * x ^^^ 2 + -2 * (a * (x * y)) + a * y ^^^ 2 + b * x ^^^ 2 + -2 * (b * (x * y)) + b * y ^^^ 2) /
|
neuper@48788
|
2269 |
(a ^^^ 2 * x ^^^ 2 + -1 * (a ^^^ 2 * y ^^^ 2) + -1 * (b ^^^ 2 * x ^^^ 2) + b ^^^ 2 * y ^^^ 2) *)
|
neuper@48788
|
2270 |
|
neuper@48788
|
2271 |
"--- 4 ---: non-terminating with Rrls cancel_p on plausible input";
|
neuper@48788
|
2272 |
val t = str2term (
|
neuper@48788
|
2273 |
"(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /"^
|
neuper@48788
|
2274 |
"(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2)");
|
neuper@48788
|
2275 |
rewrite_set_ thy false cancel_p t;
|
neuper@48788
|
2276 |
(*# rls: cancel_p on:
|
neuper@48788
|
2277 |
(a * x ^^^ 2 + -2 * a * x * y + a * y ^^^ 2 + b * x ^^^ 2 + -2 * b * x * y + b * y ^^^ 2) /
|
neuper@48788
|
2278 |
(a ^^^ 2 * x ^^^ 2 + -1 * a ^^^ 2 * y ^^^ 2 + -1 * b ^^^ 2 * x ^^^ 2 + b ^^^ 2 * y ^^^ 2) *)
|
neuper@48788
|
2279 |
|
neuper@48788
|
2280 |
"--- 5 ---: non-terminating with Rrls cancel_p on plausible input";
|
neuper@48788
|
2281 |
val t = str2term "(9*(x^^^2 - 8*x+16)/(4*(y^^^2 - 2*y+1)))/((3*x - 12)/(16*y - 16))";
|
neuper@48788
|
2282 |
rewrite_set_ thy false norm_Rational t;
|
neuper@48788
|
2283 |
(*#### rls: cancel_p on:
|
neuper@48788
|
2284 |
(2304 + -1152 * x + -2304 * y + 144 * x ^^^ 2 + 1152 * (x * y) + -144 * (x ^^^ 2 * y)) /
|
neuper@48788
|
2285 |
(48 + -12 * x + -96 * y + 24 * (x * y) + 48 * y ^^^ 2 + -12 * (x * y ^^^ 2)) *)
|
neuper@48788
|
2286 |
|
neuper@48788
|
2287 |
"--- 6 ---: non-terminating with Rrls cancel_p on plausible input";
|
neuper@48788
|
2288 |
val t = str2term
|
neuper@48788
|
2289 |
"9*(x^^^2 - 8*x+16)*(16*y - 16)/(4*(y^^^2 - 2*y+1)*(3*x - 12))";
|
neuper@48788
|
2290 |
rewrite_set_ thy false norm_Rational t;
|
neuper@48788
|
2291 |
(*### rls: cancel_p on: (-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * (x * y) +
|
neuper@48788
|
2292 |
144 * (x ^^^ 2 * y)) /
|
neuper@48788
|
2293 |
(-48 + 12 * x + 96 * y + -24 * (x * y) + -48 * y ^^^ 2 + 12 * (x * y ^^^ 2)) *)
|
neuper@48788
|
2294 |
|
neuper@48788
|
2295 |
"--- 7 ---: non-terminating with Rrls cancel_p on plausible input";
|
neuper@48788
|
2296 |
val t' = str2term (
|
neuper@48788
|
2297 |
"(-2304 + 1152 * x + 2304 * y + -144 * x ^^^ 2 + -1152 * x * y + 144 * x ^^^ 2 * y) /"^
|
neuper@48788
|
2298 |
"(-48 + 12 * x + 96 * y + -24 * x * y + -48 * y ^^^ 2 + 12 * x * y ^^^ 2)");
|
neuper@48788
|
2299 |
rewrite_set_ thy false cancel_p t';
|
neuper@48788
|
2300 |
|
neuper@48788
|
2301 |
"--- 8 ---: bottom of output cannot be looked ad (due to looping?)";
|
neuper@48788
|
2302 |
val t = str2term "(a-b)^^^3 * (x+y)^^^4 / ((x+y)^^^2 * (a-b)^^^5)";
|
neuper@48788
|
2303 |
val SOME (t,_) = rewrite_set_ thy false norm_Rational t;
|
neuper@48788
|
2304 |
|
neuper@48788
|
2305 |
"--- 9 ---: probably error in norm_Rational";
|
neuper@48788
|
2306 |
val t = str2term (
|
neuper@48788
|
2307 |
"((12*x*y / (9*x^^^2 - y^^^2)) / (1/(3*x - y)^^^2 - 1/(3*x + y)^^^2)) *" ^
|
neuper@48788
|
2308 |
"(1/(x - 5*y)^^^2 - 1/(x + 5*y)^^^2) / (20*x*y/(x^^^2 - 25*y^^^2))");
|
neuper@48788
|
2309 |
rewrite_set_ thy false norm_Rational t;
|
neuper@48788
|
2310 |
(*#### rls: cancel_p on: (19440 * (x ^^^ 8 * y ^^^ 2) + -490320 * (x ^^^ 6 * y ^^^ 4) +
|
neuper@48788
|
2311 |
108240 * (x ^^^ 4 * y ^^^ 6) +
|
neuper@48788
|
2312 |
-6000 * (x ^^^ 2 * y ^^^ 8)) /
|
neuper@48788
|
2313 |
(2160 * (x ^^^ 8 * y ^^^ 2) + -108240 * (x ^^^ 6 * y ^^^ 4) +
|
neuper@48788
|
2314 |
1362000 * (x ^^^ 4 * y ^^^ 6) +
|
neuper@48788
|
2315 |
-150000 * (x ^^^ 2 * y ^^^ 8)) *)
|
neuper@48788
|
2316 |
|
neuper@48788
|
2317 |
"--- 10 ---: non-terminating with ### add_fract: done t22: error in common_nominator_p ";
|
neuper@48788
|
2318 |
val t = str2term (" (a + b * x) / (a + -1 * (b * x)) + (-1 * a + b * x) / (a + b * x)");
|
neuper@48788
|
2319 |
rewrite_set_ thy false common_nominator_p t; (*### add_fract: done t22 *)
|
neuper@48788
|
2320 |
common_nominator_p_ thy t; (*loops without output*)
|
neuper@48788
|
2321 |
"--- reformulated 10:";
|
neuper@48788
|
2322 |
val t = str2term "(a + -1 * (b * x)) / (a + b * x)";
|
neuper@48788
|
2323 |
rewrite_set_ thy false cancel_p t = NONE;
|
neuper@48788
|
2324 |
"--- 11 ---";
|
neuper@48788
|
2325 |
"--- 12 ---";
|
neuper@48788
|
2326 |
"...both are to be considered after common_nominator_p_ is improved";
|
neuper@48788
|
2327 |
--------------------------------------------------------------------------------------/*)
|
neuper@48788
|
2328 |
|