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