walther@60328
|
1 |
(* Title: test/Tools/isac/Knowledge/poly-1.sml
|
walther@60328
|
2 |
Author: Walther Neuper
|
walther@60328
|
3 |
Use is subject to license terms.
|
walther@60328
|
4 |
|
walther@60328
|
5 |
Test of basic functions and application to complex examples.
|
walther@60328
|
6 |
*)
|
walther@60328
|
7 |
|
walther@60328
|
8 |
"-----------------------------------------------------------------------------------------------";
|
walther@60328
|
9 |
"-----------------------------------------------------------------------------------------------";
|
walther@60328
|
10 |
"table of contents -----------------------------------------------------------------------------";
|
walther@60328
|
11 |
"-----------------------------------------------------------------------------------------------";
|
walther@60328
|
12 |
"-------- fun is_polyexp -----------------------------------------------------------------------";
|
walther@60328
|
13 |
"-------- fun has_degree_in --------------------------------------------------------------------";
|
walther@60328
|
14 |
"-------- fun mono_deg_in ----------------------------------------------------------------------";
|
walther@60328
|
15 |
"-------- fun sort_variables -------------------------------------------------------------------";
|
walther@60328
|
16 |
"-------- fun is_addUnordered (x \<up> 2 * y \<up> 2 + x \<up> 3 * y) --------------------------------------";
|
walther@60328
|
17 |
"-------- check make_polynomial with simple terms ----------------------------------------------";
|
walther@60328
|
18 |
"-------- fun is_multUnordered (x \<up> 2 * x) -----------------------------------------------------";
|
walther@60328
|
19 |
"-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------";
|
walther@60328
|
20 |
"-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------";
|
walther@60328
|
21 |
"-------- fun is_multUnordered b * a * a ------------------------------------------------------";
|
walther@60328
|
22 |
"-------- fun is_multUnordered 2*3*a -----------------------------------------------------------";
|
walther@60328
|
23 |
"-------- norm_Poly with AlgEin ----------------------------------------------------------------";
|
walther@60328
|
24 |
"-------- complex examples from textbook Schalk I ----------------------------------------------";
|
walther@60328
|
25 |
"-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------";
|
walther@60328
|
26 |
"-----------------------------------------------------------------------------------------------";
|
walther@60328
|
27 |
"-----------------------------------------------------------------------------------------------";
|
walther@60328
|
28 |
|
walther@60328
|
29 |
|
walther@60328
|
30 |
"-------- fun is_polyexp -----------------------------------------------------------------------";
|
walther@60328
|
31 |
"-------- fun is_polyexp -----------------------------------------------------------------------";
|
walther@60328
|
32 |
"-------- fun is_polyexp -----------------------------------------------------------------------";
|
walther@60328
|
33 |
val t = TermC.str2term "x / x";
|
walther@60328
|
34 |
if is_polyexp t then error "NOT is_polyexp (x / x)" else ();
|
walther@60328
|
35 |
|
walther@60329
|
36 |
val t = TermC.str2term "- 1 * A * 3";
|
walther@60329
|
37 |
if is_polyexp t then () else error "is_polyexp (- 1 * A * 3)";
|
walther@60328
|
38 |
|
walther@60329
|
39 |
val t = TermC.str2term "- 1 * AA * 3";
|
walther@60329
|
40 |
if is_polyexp t then () else error "is_polyexp (- 1 * AA * 3)";
|
walther@60328
|
41 |
|
walther@60328
|
42 |
val t = TermC.str2term "x * x + x * y + (- 1 * y * x + - 1 * y * y)::real";
|
walther@60328
|
43 |
if is_polyexp t then () else error "is_polyexp (x * x + x * y + (- 1 * y * x + - 1 * y * y))";
|
walther@60328
|
44 |
|
walther@60328
|
45 |
"-------- fun has_degree_in --------------------------------------------------------------------";
|
walther@60328
|
46 |
"-------- fun has_degree_in --------------------------------------------------------------------";
|
walther@60328
|
47 |
"-------- fun has_degree_in --------------------------------------------------------------------";
|
walther@60340
|
48 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
49 |
val t = (Thm.term_of o the o (TermC.parse thy)) "1";
|
walther@60328
|
50 |
if has_degree_in t v = 0 then () else error "has_degree_in (1) x";
|
walther@60328
|
51 |
|
walther@60340
|
52 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
53 |
val t = (Thm.term_of o the o (TermC.parse thy)) "1";
|
walther@60328
|
54 |
if has_degree_in t v = 0 then () else error "has_degree_in (1) AA";
|
walther@60328
|
55 |
|
walther@60328
|
56 |
(*----------*)
|
walther@60340
|
57 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
58 |
val t = (Thm.term_of o the o (TermC.parse thy)) "a*b+c";
|
walther@60328
|
59 |
if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) x";
|
walther@60328
|
60 |
|
walther@60340
|
61 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
62 |
val t = (Thm.term_of o the o (TermC.parse thy)) "a*b+c";
|
walther@60328
|
63 |
if has_degree_in t v = 0 then () else error "has_degree_in (a*b+c) AA";
|
walther@60328
|
64 |
|
walther@60328
|
65 |
(*----------*)
|
walther@60340
|
66 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
67 |
val t = (Thm.term_of o the o (TermC.parse thy)) "a*x+c";
|
walther@60328
|
68 |
if has_degree_in t v = ~1 then () else error "has_degree_in (a*x+c) x";
|
walther@60328
|
69 |
|
walther@60340
|
70 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
71 |
val t = (Thm.term_of o the o (TermC.parse thy)) "a*AA+c";
|
walther@60328
|
72 |
if has_degree_in t v = ~1 then () else error "has_degree_in (a*AA+c) AA";
|
walther@60328
|
73 |
|
walther@60328
|
74 |
(*----------*)
|
walther@60340
|
75 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
76 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x \<up> 7";
|
walther@60328
|
77 |
if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*x \<up> 7) x";
|
walther@60328
|
78 |
|
walther@60340
|
79 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
80 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA \<up> 7";
|
walther@60328
|
81 |
if has_degree_in t v = 7 then () else error "has_degree_in ((a*b+c)*AA \<up> 7) AA";
|
walther@60328
|
82 |
|
walther@60328
|
83 |
(*----------*)
|
walther@60340
|
84 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
85 |
val t = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 7";
|
walther@60328
|
86 |
if has_degree_in t v = 7 then () else error "has_degree_in (x \<up> 7) x";
|
walther@60328
|
87 |
|
walther@60340
|
88 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
89 |
val t = (Thm.term_of o the o (TermC.parse thy)) "AA \<up> 7";
|
walther@60328
|
90 |
if has_degree_in t v = 7 then () else error "has_degree_in (AA \<up> 7) AA";
|
walther@60328
|
91 |
|
walther@60328
|
92 |
(*----------*)
|
walther@60340
|
93 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
94 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x";
|
walther@60328
|
95 |
if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*x) x";
|
walther@60328
|
96 |
|
walther@60340
|
97 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
98 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA";
|
walther@60328
|
99 |
if has_degree_in t v = 1 then () else error "has_degree_in ((a*b+c)*AA) AA";
|
walther@60328
|
100 |
|
walther@60328
|
101 |
(*----------*)
|
walther@60340
|
102 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
103 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+x)*x";
|
walther@60328
|
104 |
if has_degree_in t v = ~1 then () else error "has_degree_in (a*b+x)*x() x";
|
walther@60328
|
105 |
|
walther@60340
|
106 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
107 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+AA)*AA";
|
walther@60328
|
108 |
if has_degree_in t v = ~1 then () else error "has_degree_in ((a*b+AA)*AA) AA";
|
walther@60328
|
109 |
|
walther@60328
|
110 |
(*----------*)
|
walther@60340
|
111 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
112 |
val t = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60328
|
113 |
if has_degree_in t v = 1 then () else error "has_degree_in (x) x";
|
walther@60328
|
114 |
|
walther@60340
|
115 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
116 |
val t = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60328
|
117 |
if has_degree_in t v = 1 then () else error "has_degree_in (AA) AA";
|
walther@60328
|
118 |
|
walther@60328
|
119 |
(*----------*)
|
walther@60340
|
120 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60340
|
121 |
val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*x";
|
walther@60328
|
122 |
if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*x) x";
|
walther@60328
|
123 |
|
walther@60340
|
124 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60340
|
125 |
val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*AA";
|
walther@60328
|
126 |
if has_degree_in t v = 1 then () else error "has_degree_in (ab - (a*b)*AA) AA";
|
walther@60328
|
127 |
|
walther@60328
|
128 |
"-------- fun mono_deg_in ----------------------------------------------------------------------";
|
walther@60328
|
129 |
"-------- fun mono_deg_in ----------------------------------------------------------------------";
|
walther@60328
|
130 |
"-------- fun mono_deg_in ----------------------------------------------------------------------";
|
walther@60340
|
131 |
val v = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60328
|
132 |
|
walther@60340
|
133 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x \<up> 7";
|
walther@60328
|
134 |
if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*x \<up> 7) x changed";
|
walther@60328
|
135 |
|
walther@60340
|
136 |
val t = (Thm.term_of o the o (TermC.parse thy)) "x \<up> 7";
|
walther@60328
|
137 |
if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (x \<up> 7) x changed";
|
walther@60328
|
138 |
|
walther@60340
|
139 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*x";
|
walther@60328
|
140 |
if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*x) x changed";
|
walther@60328
|
141 |
|
walther@60340
|
142 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+x)*x";
|
walther@60328
|
143 |
if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+x)*x) x changed";
|
walther@60328
|
144 |
|
walther@60340
|
145 |
val t = (Thm.term_of o the o (TermC.parse thy)) "x";
|
walther@60328
|
146 |
if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (x) x changed";
|
walther@60328
|
147 |
|
walther@60340
|
148 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)";
|
walther@60328
|
149 |
if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) x changed";
|
walther@60328
|
150 |
|
walther@60340
|
151 |
val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*x";
|
walther@60328
|
152 |
if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*x) x changed";
|
walther@60328
|
153 |
|
walther@60336
|
154 |
(*. . . . . . . . . . . . the same with Const (\<^const_name>\<open>AA\<close>, _) . . . . . . . . . . . *)
|
walther@60328
|
155 |
val thy = @{theory Partial_Fractions}
|
walther@60340
|
156 |
val v = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60328
|
157 |
|
walther@60340
|
158 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA \<up> 7";
|
walther@60328
|
159 |
if mono_deg_in t v = SOME 7 then () else error "mono_deg_in ((a*b+c)*AA \<up> 7) AA changed";
|
walther@60328
|
160 |
|
walther@60340
|
161 |
val t = (Thm.term_of o the o (TermC.parse thy)) "AA \<up> 7";
|
walther@60328
|
162 |
if mono_deg_in t v = SOME 7 then () else error "mono_deg_in (AA \<up> 7) AA changed";
|
walther@60328
|
163 |
|
walther@60340
|
164 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)*AA";
|
walther@60328
|
165 |
if mono_deg_in t v = SOME 1 then () else error "mono_deg_in ((a*b+c)*AA) AA changed";
|
walther@60328
|
166 |
|
walther@60340
|
167 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+AA)*AA";
|
walther@60328
|
168 |
if mono_deg_in t v = NONE then () else error "mono_deg_in ((a*b+AA)*AA) AA changed";
|
walther@60328
|
169 |
|
walther@60340
|
170 |
val t = (Thm.term_of o the o (TermC.parse thy)) "AA";
|
walther@60328
|
171 |
if mono_deg_in t v = SOME 1 then () else error "mono_deg_in (AA) AA changed";
|
walther@60328
|
172 |
|
walther@60340
|
173 |
val t = (Thm.term_of o the o (TermC.parse thy)) "(a*b+c)";
|
walther@60328
|
174 |
if mono_deg_in t v = SOME 0 then () else error "mono_deg_in ((a*b+c)) AA changed";
|
walther@60328
|
175 |
|
walther@60340
|
176 |
val t = (Thm.term_of o the o (TermC.parse thy)) "ab - (a*b)*AA";
|
walther@60328
|
177 |
if mono_deg_in t v = NONE then () else error "mono_deg_in (ab - (a*b)*AA) AA changed";
|
walther@60328
|
178 |
|
walther@60328
|
179 |
|
walther@60328
|
180 |
"-------- fun sort_variables -------------------------------------------------------------------";
|
walther@60328
|
181 |
"-------- fun sort_variables -------------------------------------------------------------------";
|
walther@60328
|
182 |
"-------- fun sort_variables -------------------------------------------------------------------";
|
walther@60328
|
183 |
if "---" < "123" andalso "123" < "a" andalso "a" < "cba" then ()
|
walther@60328
|
184 |
else error "lexicographic order CHANGED";
|
walther@60328
|
185 |
|
walther@60328
|
186 |
(*--------------vvvvvvvvvvvvvvv-----------------------------------------------------------------*)
|
walther@60328
|
187 |
val t = @{term "3 * b + a * 2"}; (*------------------------------------------------------------*)
|
walther@60328
|
188 |
val t' = sort_variables t;
|
walther@60328
|
189 |
if UnparseC.term t' = "(3::'a) * b + (2::'a) * a" then ()
|
walther@60328
|
190 |
else error "sort_variables 3 * b + a * 2 CHANGED";
|
walther@60328
|
191 |
|
walther@60328
|
192 |
"~~~~~~~ fun sort_variables , args:"; val (t) = (t);
|
walther@60328
|
193 |
val ll = map monom2list (poly2list t);
|
walther@60328
|
194 |
|
walther@60328
|
195 |
(*+*)UnparseC.terms (poly2list t) = "[\"(3::'a) * b\", \"a * (2::'a)\"]";
|
walther@60336
|
196 |
(*+*)val [ [(Const (\<^const_name>\<open>numeral\<close>, _) $ _), Free ("b", _)],
|
walther@60336
|
197 |
(*+*) [Free ("a", _), (Const (\<^const_name>\<open>numeral\<close>, _) $ _)]
|
walther@60328
|
198 |
(*+*) ] = map monom2list (poly2list t);
|
walther@60328
|
199 |
|
walther@60328
|
200 |
val lls = map sort_varList ll;
|
walther@60328
|
201 |
|
walther@60328
|
202 |
(*+*)case map sort_varList ll of
|
walther@60336
|
203 |
(*+*) [ [Const (\<^const_name>\<open>numeral\<close>, _) $ _, Free ("b", _)],
|
walther@60336
|
204 |
(*+*) [Const (\<^const_name>\<open>numeral\<close>, _) $ _, Free ("a", _)]
|
walther@60328
|
205 |
(*+*) ] => ()
|
walther@60328
|
206 |
(*+*)| _ => error "map sort_varList CHANGED";
|
walther@60328
|
207 |
|
walther@60328
|
208 |
val T = type_of t;
|
walther@60328
|
209 |
val ls = map (create_monom T) lls;
|
walther@60328
|
210 |
|
walther@60336
|
211 |
(*+*)val [Const (\<^const_name>\<open>times\<close>, _) $ _ $ Free ("b", _),
|
walther@60336
|
212 |
(*+*) Const (\<^const_name>\<open>times\<close>, _) $ _ $ Free ("a", _)] = map (create_monom T) lls;
|
walther@60328
|
213 |
|
walther@60328
|
214 |
(*+*)case map (create_monom T) lls of
|
walther@60336
|
215 |
(*+*) [Const (\<^const_name>\<open>times\<close>, _) $ (Const (\<^const_name>\<open>numeral\<close>, _) $ _) $ Free ("b", _),
|
walther@60336
|
216 |
(*+*) Const (\<^const_name>\<open>times\<close>, _) $ (Const (\<^const_name>\<open>numeral\<close>, _) $ _) $ Free ("a", _)
|
walther@60328
|
217 |
(*+*) ] => ()
|
walther@60328
|
218 |
(*+*)| _ => error "map (create_monom T) CHANGED";
|
walther@60328
|
219 |
|
walther@60328
|
220 |
val xxx = (*in*) create_polynom T ls (*end*);
|
walther@60328
|
221 |
|
walther@60328
|
222 |
(*+*)if UnparseC.term xxx = "(3::'a) * b + (2::'a) * a" then ()
|
walther@60328
|
223 |
(*+*)else error "create_polynom CHANGED";
|
walther@60328
|
224 |
(* done by rewriting> 2 * a + 3 * b ? *)
|
walther@60328
|
225 |
|
walther@60328
|
226 |
(*---------------vvvvvvvvvvvvvvvvvvvvvv---------------------------------------------------------*)
|
walther@60328
|
227 |
val t = @{term "3 * a + - 2 * a ::real"}; (*---------------------------------------------------*)
|
walther@60328
|
228 |
val t' = sort_variables t;
|
walther@60328
|
229 |
if UnparseC.term t' = "3 * a + - 2 * a" then ()
|
walther@60328
|
230 |
else error "sort_variables 3 * a + - 2 * a CHANGED";
|
walther@60328
|
231 |
|
walther@60328
|
232 |
"~~~~~~~ fun sort_variables , args:"; val (t) = (t);
|
walther@60328
|
233 |
val ll = map monom2list (poly2list t);
|
walther@60328
|
234 |
|
walther@60336
|
235 |
(*+*)val [ [Const (\<^const_name>\<open>numeral\<close>, _) $ _, Free ("a", _)],
|
walther@60336
|
236 |
(*+*) [Const (\<^const_name>\<open>uminus\<close>, _) $ _, Free ("a", _)] (*already correct order*)
|
walther@60328
|
237 |
(*+*) ] = map monom2list (poly2list t);
|
walther@60328
|
238 |
|
walther@60328
|
239 |
val lls = map
|
walther@60328
|
240 |
sort_varList ll;
|
walther@60328
|
241 |
|
walther@60336
|
242 |
(*+*)val [ [Const (\<^const_name>\<open>numeral\<close>, _) $ _, Free ("a", _)],
|
walther@60336
|
243 |
(*+*) [Const (\<^const_name>\<open>uminus\<close>, _) $ _, Free ("a", _)] (*ERROR: NO swap here*)
|
walther@60328
|
244 |
(*+*) ] = map sort_varList ll;
|
walther@60328
|
245 |
|
walther@60328
|
246 |
map sort_varList ll;
|
walther@60328
|
247 |
"~~~~~ val sort_varList , args:"; val (ts) = (nth 2 ll);
|
walther@60328
|
248 |
val sorted = sort var_ord ts;
|
walther@60328
|
249 |
|
walther@60328
|
250 |
(*+*)if UnparseC.terms ts = "[\"- 2\", \"a\"]" andalso UnparseC.terms sorted = "[\"- 2\", \"a\"]"
|
walther@60328
|
251 |
(*+*)then () else error "sort var_ord [\"- 2\", \"a\"] CHANGED";
|
walther@60328
|
252 |
|
walther@60328
|
253 |
|
walther@60328
|
254 |
(*+*)if UnparseC.term (nth 1 ts) = "- 2" andalso get_basStr (nth 1 ts) = "-2"
|
walther@60328
|
255 |
(*+*)then () else error "get_basStr - 2 CHANGED";
|
walther@60328
|
256 |
(*+*)if UnparseC.term (nth 2 ts) = "a" andalso get_basStr (nth 2 ts) = "a"
|
walther@60328
|
257 |
(*+*)then () else error "get_basStr a CHANGED";
|
walther@60328
|
258 |
|
walther@60328
|
259 |
|
walther@60328
|
260 |
"-------- fun is_addUnordered (x \<up> 2 * y \<up> 2 + x \<up> 3 * y) --------------------------------------";
|
walther@60328
|
261 |
"-------- fun is_addUnordered (x \<up> 2 * y \<up> 2 + x \<up> 3 * y) --------------------------------------";
|
walther@60328
|
262 |
"-------- fun is_addUnordered (x \<up> 2 * y \<up> 2 + x \<up> 3 * y) --------------------------------------";
|
walther@60328
|
263 |
val t = TermC.str2term "x \<up> 2 * y \<up> 2 + x * x \<up> 2 * y";
|
walther@60330
|
264 |
Rewrite.trace_on := false; (*true false*)
|
walther@60328
|
265 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
266 |
UnparseC.term t = "x \<up> 2 * y \<up> 2 + x \<up> 3 * y";
|
walther@60328
|
267 |
if UnparseC.term t = "x \<up> 3 * y + x \<up> 2 * y \<up> 2" then ()
|
walther@60328
|
268 |
else error "poly.sml: diff.behav. in make_polynomial 23";
|
walther@60328
|
269 |
|
walther@60328
|
270 |
(** )
|
walther@60328
|
271 |
## rls: order_add_rls_ on: x \<up> 2 * y \<up> 2 + x \<up> 3 * y
|
walther@60328
|
272 |
### rls: order_add_ on: x \<up> 2 * y \<up> 2 + x \<up> 3 * y
|
walther@60328
|
273 |
###### rls: Rule_Set.empty-is_addUnordered on: x \<up> 2 * y \<up> 2 + x \<up> 3 * y is_addUnordered
|
walther@60328
|
274 |
####### try calc: "Poly.is_addUnordered"
|
walther@60328
|
275 |
######## eval asms: "x \<up> 2 * y \<up> 2 + x \<up> 3 * y is_addUnordered = False" (*isa*)
|
walther@60328
|
276 |
True" (*isa2*)
|
walther@60328
|
277 |
####### calc. to: False (*isa*)
|
walther@60328
|
278 |
True (*isa2*)
|
walther@60328
|
279 |
( **)
|
walther@60328
|
280 |
if is_addUnordered (TermC.str2term "x \<up> 2 * y \<up> 2 + x \<up> 3 * y ::real") then ()
|
walther@60328
|
281 |
else error"is_addUnordered x \<up> 2 * y \<up> 2 + x \<up> 3 * y"; (*isa == isa2*)
|
walther@60328
|
282 |
"~~~~~ fun is_addUnordered , args:"; val (t) = (TermC.str2term "x \<up> 2 * y \<up> 2 + x \<up> 3 * y ::real");
|
walther@60328
|
283 |
((is_polyexp t) andalso not (t = sort_monoms t)) = false; (*isa == isa2*)
|
walther@60328
|
284 |
|
walther@60328
|
285 |
(*+*) if is_polyexp t = true then () else error "is_polyexp x \<up> 2 * y \<up> 2 + x \<up> 3 * y";
|
walther@60328
|
286 |
|
walther@60328
|
287 |
(*+*) if t = sort_monoms t = false then () else error "sort_monoms 123";
|
walther@60328
|
288 |
"~~~~~~~ fun sort_monoms , args:"; val (t) = (t);
|
walther@60328
|
289 |
val ll = map monom2list (poly2list t);
|
walther@60328
|
290 |
val lls = sort_monList ll;
|
walther@60328
|
291 |
|
walther@60328
|
292 |
(*+*)map UnparseC.terms lls = ["[\"x \<up> 2\", \"y \<up> 2\"]", "[\"x \<up> 3\", \"y\"]"]; (*isa*)
|
walther@60328
|
293 |
(*+*)map UnparseC.terms lls = ["[\"x \<up> 3\", \"y\"]", "[\"x \<up> 2\", \"y \<up> 2\"]"]; (*isa2*)
|
walther@60328
|
294 |
|
walther@60328
|
295 |
"~~~~~~~~~~~ fun koeff_degree_ord , args:"; val () = ();
|
walther@60328
|
296 |
(* we check all elements at once..*)
|
walther@60328
|
297 |
val eee1 = ll |> nth 1; UnparseC.terms eee1 = "[\"x \<up> 2\", \"y \<up> 2\"]";
|
walther@60328
|
298 |
val eee2 = ll |> nth 2; UnparseC.terms eee2 = "[\"x \<up> 3\", \"y\"]";
|
walther@60328
|
299 |
|
walther@60328
|
300 |
(*1*)if koeff_degree_ord (eee1, eee1) = EQUAL then () else error "(eee1, eee1) CHANGED";
|
walther@60328
|
301 |
(*2*)if koeff_degree_ord (eee1, eee2) = GREATER then () else error "(eee1, eee2) CHANGED";
|
walther@60328
|
302 |
(*3*)if koeff_degree_ord (eee2, eee1) = LESS then () else error "(eee2, eee1) CHANGED"; (*isa*)
|
walther@60328
|
303 |
(*4*)if koeff_degree_ord (eee2, eee2) = EQUAL then () else error "(eee2, eee2) CHANGED";
|
walther@60328
|
304 |
(* isa -- isa2:
|
walther@60328
|
305 |
(*1*){a = "var_ord_revPow ", at_bt = "(x \<up> 2, x \<up> 2)", sort_args = "(x, 2), (x, 2)"} (*isa == isa2*)
|
walther@60328
|
306 |
(*1*){a = "var_ord_revPow ", at_bt = "(y \<up> 2, y \<up> 2)", sort_args = "(y, 2), (y, 2)"} (*isa == isa2*)
|
walther@60328
|
307 |
(*1*){a = "compare_koeff_ord ", ats_bts = "([\"x \<up> 2\", \"y \<up> 2\"], [\"x \<up> 2\", \"y \<up> 2\"])", sort_args = "(---, ---)"} (*isa == isa2*)
|
walther@60328
|
308 |
|
walther@60328
|
309 |
(*2*){a = "var_ord_revPow ", at_bt = "(x \<up> 2, x \<up> 3)", sort_args = "(x, 2), (x, 3)"} (*isa == isa2*)
|
walther@60328
|
310 |
|
walther@60328
|
311 |
(*3*)k{a = "var_ord_revPow ", at_bt = "(x \<up> 3, x \<up> 2)", sort_args = "(x, 3), (x, 2)"} (*isa == isa2*)
|
walther@60328
|
312 |
|
walther@60328
|
313 |
(*4*){a = "var_ord_revPow ", at_bt = "(x \<up> 3, x \<up> 3)", sort_args = "(x, 3), (x, 3)"} (*isa == isa2*)
|
walther@60328
|
314 |
(*4*){a = "var_ord_revPow ", at_bt = "(y, y)", sort_args = "(y, ---), (y, ---)"} (*isa == isa2*)
|
walther@60328
|
315 |
(*4*){a = "compare_koeff_ord ", ats_bts = "([\"x \<up> 3\", \"y\"], [\"x \<up> 3\", \"y\"])", sort_args = "(---, ---)"} (*isa == isa2*)
|
walther@60328
|
316 |
val it = true: bool
|
walther@60328
|
317 |
val it = true: bool
|
walther@60328
|
318 |
val it = true: bool
|
walther@60328
|
319 |
val it = true: bool*)
|
walther@60328
|
320 |
|
walther@60328
|
321 |
"~~~~~~~~~~~~~ fun degree_ord , args:"; val () = ();
|
walther@60328
|
322 |
(*1*)if degree_ord (eee1, eee1) = EQUAL then () else error "degree_ord (eee1, eee1) CHANGED";
|
walther@60328
|
323 |
(*2*)if degree_ord (eee1, eee2) = GREATER then () else error "degree_ord (eee1, eee2) CHANGED";(*isa*)
|
walther@60328
|
324 |
(*{a = "int_ord (4, 10003) = ", z = LESS} isa
|
walther@60328
|
325 |
{a = "int_ord (4, 4) = ", z = EQUAL} isa2*)
|
walther@60328
|
326 |
(*3*)if degree_ord (eee2, eee1) = LESS then () else error "degree_ord (eee2, eee1) CHANGED";(*isa*)
|
walther@60328
|
327 |
(*4*)if degree_ord (eee2, eee2) = EQUAL then () else error "degree_ord (eee2, eee2) CHANGED";
|
walther@60328
|
328 |
(* isa -- isa2:
|
walther@60328
|
329 |
(*1*){a = "int_ord (10002, 10002) = ", z = EQUAL} (*isa*)
|
walther@60328
|
330 |
{a = "int_ord (4, 4) = ", z = EQUAL} (*isa2*)
|
walther@60328
|
331 |
(*1*){a = "dict_cond_ord", args = "([\"x \<up> 2\", \"y \<up> 2\"], [\"x \<up> 2\", \"y \<up> 2\"])", is_nums = "(false, false)"} (*isa*)
|
walther@60328
|
332 |
(*1*){a = "var_ord_revPow ", at_bt = "(x \<up> 2, x \<up> 2)", sort_args = "(x, 2), (x, 2)"} (*isa*)
|
walther@60328
|
333 |
(*1*){a = "dict_cond_ord", args = "([\"y \<up> 2\"], [\"y \<up> 2\"])", is_nums = "(false, false)"} (*isa*)
|
walther@60328
|
334 |
(*1*){a = "var_ord_revPow ", at_bt = "(y \<up> 2, y \<up> 2)", sort_args = "(y, 2), (y, 2)"} (*isa*)
|
walther@60328
|
335 |
(*1*){a = "dict_cond_ord ([], [])"} (*isa*)
|
walther@60328
|
336 |
|
walther@60328
|
337 |
(*2*){a = "int_ord (10002, 10003) = ", z = LESS} (*isa*)
|
walther@60328
|
338 |
{a = "int_ord (4, 4) = ", z = EQUAL} (*isa2*)
|
walther@60328
|
339 |
{a = "dict_cond_ord", args = "([\"x \<up> 2\", \"y \<up> 2\"], [\"x \<up> 3\", \"y\"])", is_nums = "(false, false)"} (*isa2*)
|
walther@60328
|
340 |
(*2*){a = "var_ord_revPow ", at_bt = "(x \<up> 2, x \<up> 3)", sort_args = "(x, 2), (x, 3)"} (*isa2*)
|
walther@60328
|
341 |
|
walther@60328
|
342 |
(*3*){a = "int_ord (10003, 10002) = ", z = GREATER} (*isa*)
|
walther@60328
|
343 |
{a = "int_ord (4, 4) = ", z = EQUAL} (*isa2*)
|
walther@60328
|
344 |
{a = "dict_cond_ord", args = "([\"x \<up> 3\", \"y\"], [\"x \<up> 2\", \"y \<up> 2\"])", is_nums = "(false, false)"}
|
walther@60328
|
345 |
(*3*){a = "var_ord_revPow ", at_bt = "(x \<up> 3, x \<up> 2)", sort_args = "(x, 3), (x, 2)"} (*isa == isa2*)
|
walther@60328
|
346 |
|
walther@60328
|
347 |
(*4*){a = "int_ord (10003, 10003) = ", z = EQUAL} (*isa*)
|
walther@60328
|
348 |
{a = "int_ord (4, 4) = ", z = EQUAL} (*isa2*)
|
walther@60328
|
349 |
(*4*){a = "dict_cond_ord", args = "([\"x \<up> 3\", \"y\"], [\"x \<up> 3\", \"y\"])", is_nums = "(false, false)"} (*isa == isa2*)
|
walther@60328
|
350 |
(*4*){a = "var_ord_revPow ", at_bt = "(x \<up> 3, x \<up> 3)", sort_args = "(x, 3), (x, 3)"} (*isa == isa2*)
|
walther@60328
|
351 |
(*4*){a = "dict_cond_ord", args = "([\"y\"], [\"y\"])", is_nums = "(false, false)"} (*isa == isa2*)
|
walther@60328
|
352 |
(*4*){a = "var_ord_revPow ", at_bt = "(y, y)", sort_args = "(y, ---), (y, ---)"} (*isa == isa2*)
|
walther@60328
|
353 |
(*4*){a = "dict_cond_ord ([], [])"} (*isa == isa2*)
|
walther@60328
|
354 |
|
walther@60328
|
355 |
val it = true: bool
|
walther@60328
|
356 |
val it = false: bool
|
walther@60328
|
357 |
val it = false: bool
|
walther@60328
|
358 |
val it = true: bool
|
walther@60328
|
359 |
*)
|
walther@60328
|
360 |
|
walther@60328
|
361 |
(*+*) if monom_degree eee1 = 4 then () else error "monom_degree [\"x \<up> 2\", \"y \<up> 2\"] CHANGED";
|
walther@60328
|
362 |
"~~~~~~~~~~~~~~~ fun monom_degree , args:"; val (l) = (eee1);
|
walther@60328
|
363 |
"~~~~~ fun counter , args:"; val (n, x :: xs) = (0, l); (*--------------------------OPEN local\* )
|
walther@60328
|
364 |
(*if*) (is_nums x) (*else*);
|
walther@60336
|
365 |
val (Const (\<^const_name>\<open>powr\<close>, _) $ Free _ $ t) =
|
walther@60328
|
366 |
(*case*) x (*of*);
|
walther@60328
|
367 |
(*+*)UnparseC.term x = "x \<up> 2";
|
walther@60328
|
368 |
(*if*) TermC.is_num t (*then*);
|
walther@60328
|
369 |
|
walther@60328
|
370 |
counter (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
|
walther@60328
|
371 |
"~~~~~ fun counter , args:"; val (n, x :: xs) = (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
|
walther@60328
|
372 |
(*if*) (is_nums x) (*else*);
|
walther@60336
|
373 |
val (Const (\<^const_name>\<open>powr\<close>, _) $ Free _ $ t) =
|
walther@60328
|
374 |
(*case*) x (*of*);
|
walther@60328
|
375 |
(*+*)UnparseC.term x = "y \<up> 2";
|
walther@60328
|
376 |
(*if*) TermC.is_num t (*then*);
|
walther@60328
|
377 |
|
walther@60328
|
378 |
val return =
|
walther@60328
|
379 |
counter (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
|
walther@60328
|
380 |
if return = 4 then () else error "monom_degree [\"x \<up> 2\", \"y \<up> 2\"] CHANGED";
|
walther@60328
|
381 |
( *---------------------------------------------------------------------------------OPEN local/*)
|
walther@60328
|
382 |
|
walther@60328
|
383 |
(*+*)if monom_degree eee2 = 4 andalso monom_degree eee2 = 4 then ()
|
walther@60328
|
384 |
else error "monom_degree [\"x \<up> 3\", \"y\"] CHANGED";
|
walther@60328
|
385 |
"~~~~~~~~~~~~~~~ fun monom_degree , args:"; val (l) = (eee2);
|
walther@60328
|
386 |
"~~~~~ fun counter , args:"; val (n, x :: xs) = (0, l); (*--------------------------OPEN local\* )
|
walther@60328
|
387 |
(*if*) (is_nums x) (*else*);
|
walther@60336
|
388 |
val (Const (\<^const_name>\<open>powr\<close>, _) $ Free _ $ t) =
|
walther@60328
|
389 |
(*case*) x (*of*);
|
walther@60328
|
390 |
(*+*)UnparseC.term x = "x \<up> 3";
|
walther@60328
|
391 |
(*if*) TermC.is_num t (*then*);
|
walther@60328
|
392 |
|
walther@60328
|
393 |
counter (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
|
walther@60328
|
394 |
"~~~~~ fun counter , args:"; val (n, x :: xs) = (t |> HOLogic.dest_number |> snd |> curry op + n, xs);
|
walther@60328
|
395 |
(*if*) (is_nums x) (*else*);
|
walther@60328
|
396 |
val _ = (*the default case*)
|
walther@60328
|
397 |
(*case*) x (*of*);
|
walther@60328
|
398 |
( *---------------------------------------------------------------------------------OPEN local/*)
|
walther@60328
|
399 |
|
walther@60328
|
400 |
"~~~~~~~~~~~~~~~ fun dict_cond_ord , args:"; val () = ();
|
walther@60328
|
401 |
val xxx = dict_cond_ord var_ord_revPow is_nums;
|
walther@60328
|
402 |
(*1*)if xxx (eee1, eee1) = EQUAL then () else error "dict_cond_ord (eee1, eee1) CHANGED";
|
walther@60328
|
403 |
(*2*)if xxx (eee1, eee2) = GREATER then () else error "dict_cond_ord (eee1, eee2) CHANGED";
|
walther@60328
|
404 |
(*3*)if xxx (eee2, eee1) = LESS then () else error "dict_cond_ord (eee2, eee1) CHANGED";
|
walther@60328
|
405 |
(*4*)if xxx (eee2, eee2) = EQUAL then () else error "dict_cond_ord (eee2, eee2) CHANGED";
|
walther@60328
|
406 |
|
walther@60328
|
407 |
|
walther@60328
|
408 |
"-------- check make_polynomial with simple terms ----------------------------------------------";
|
walther@60328
|
409 |
"-------- check make_polynomial with simple terms ----------------------------------------------";
|
walther@60328
|
410 |
"-------- check make_polynomial with simple terms ----------------------------------------------";
|
walther@60328
|
411 |
"----- check 1 ---";
|
walther@60328
|
412 |
val t = TermC.str2term "2*3*a";
|
walther@60328
|
413 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
|
walther@60328
|
414 |
if UnparseC.term t = "6 * a" then () else error "check make_polynomial 1";
|
walther@60328
|
415 |
|
walther@60328
|
416 |
"----- check 2 ---";
|
walther@60328
|
417 |
val t = TermC.str2term "2*a + 3*a";
|
walther@60328
|
418 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
|
walther@60328
|
419 |
if UnparseC.term t = "5 * a" then () else error "check make_polynomial 2";
|
walther@60328
|
420 |
|
walther@60328
|
421 |
"----- check 3 ---";
|
walther@60328
|
422 |
val t = TermC.str2term "2*a + 3*a + 3*a";
|
walther@60328
|
423 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
|
walther@60328
|
424 |
if UnparseC.term t = "8 * a" then () else error "check make_polynomial 3";
|
walther@60328
|
425 |
|
walther@60328
|
426 |
"----- check 4 ---";
|
walther@60328
|
427 |
val t = TermC.str2term "3*a - 2*a";
|
walther@60328
|
428 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
|
walther@60328
|
429 |
if UnparseC.term t = "a" then () else error "check make_polynomial 4";
|
walther@60328
|
430 |
|
walther@60328
|
431 |
"----- check 5 ---";
|
walther@60328
|
432 |
val t = TermC.str2term "4*(3*a - 2*a)";
|
walther@60328
|
433 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
|
walther@60328
|
434 |
if UnparseC.term t = "4 * a" then () else error "check make_polynomial 5";
|
walther@60328
|
435 |
|
walther@60328
|
436 |
"----- check 6 ---";
|
walther@60328
|
437 |
val t = TermC.str2term "4*(3*a \<up> 2 - 2*a \<up> 2)";
|
walther@60328
|
438 |
val SOME (t, _) = rewrite_set_ thy false make_polynomial t;
|
walther@60328
|
439 |
if UnparseC.term t = "4 * a \<up> 2" then () else error "check make_polynomial 6";
|
walther@60328
|
440 |
|
walther@60328
|
441 |
"-------- fun is_multUnordered (x \<up> 2 * x) -----------------------------------------------------";
|
walther@60328
|
442 |
"-------- fun is_multUnordered (x \<up> 2 * x) -----------------------------------------------------";
|
walther@60328
|
443 |
"-------- fun is_multUnordered (x \<up> 2 * x) -----------------------------------------------------";
|
walther@60328
|
444 |
val thy = @{theory "Isac_Knowledge"};
|
walther@60328
|
445 |
"===== works for a simple example, see rewrite.sml -- fun app_rev ===";
|
walther@60328
|
446 |
val t = TermC.str2term "x \<up> 2 * x";
|
walther@60328
|
447 |
val SOME (t', _) = rewrite_set_ thy true order_mult_ t;
|
walther@60328
|
448 |
if UnparseC.term t' = "x * x \<up> 2" then ()
|
walther@60328
|
449 |
else error "poly.sml Poly.is_multUnordered doesn't work";
|
walther@60328
|
450 |
|
walther@60328
|
451 |
(* 100928 Rewrite.trace_on shows the first occurring difference in 267b:
|
walther@60329
|
452 |
### rls: order_mult_ on: 5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) +
|
walther@60328
|
453 |
(-48 * x \<up> 4 + 8))
|
walther@60328
|
454 |
###### rls: Rule_Set.empty-is_multUnordered on: p is_multUnordered
|
walther@60328
|
455 |
####### try calc: Poly.is_multUnordered'
|
walther@60328
|
456 |
======= calc. to: False !!!!!!!!!!!!! INSTEAD OF TRUE in 2002 !!!!!!!!!!!!!
|
walther@60328
|
457 |
*)
|
walther@60329
|
458 |
val t = TermC.str2term "5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) + (-48 * x \<up> 4 + 8))";
|
walther@60328
|
459 |
|
walther@60328
|
460 |
"----- is_multUnordered ---";
|
walther@60328
|
461 |
val tsort = sort_variables t;
|
walther@60329
|
462 |
UnparseC.term tsort = "2 * (5 * (x \<up> 2 * x \<up> 7)) + 3 * (5 * x \<up> 2) + 6 * x \<up> 7 + 9 +\n- 1 * (3 * (6 * (x \<up> 4 * x \<up> 5))) +\n- 1 * (- 1 * (3 * x \<up> 5)) +\n-48 * x \<up> 4 +\n8";
|
walther@60328
|
463 |
is_polyexp t;
|
walther@60328
|
464 |
tsort = t;
|
walther@60328
|
465 |
is_polyexp t andalso not (t = sort_variables t);
|
walther@60328
|
466 |
if is_multUnordered t then () else error "poly.sml diff. is_multUnordered 1";
|
walther@60328
|
467 |
|
walther@60328
|
468 |
"----- eval_is_multUnordered ---";
|
walther@60329
|
469 |
val tm = TermC.str2term "(5 * x \<up> 2 * (2 * x \<up> 7) + 5 * x \<up> 2 * 3 + (6 * x \<up> 7 + 9) + (- 1 * (3 * x \<up> 5 * (6 * x \<up> 4)) + - 1 * (3 * x \<up> 5 * - 1) + (-48 * x \<up> 4 + 8))) is_multUnordered";
|
walther@60328
|
470 |
case eval_is_multUnordered "testid" "" tm thy of
|
walther@60336
|
471 |
SOME (_, Const (\<^const_name>\<open>Trueprop\<close>, _) $
|
walther@60336
|
472 |
(Const (\<^const_name>\<open>HOL.eq\<close>, _) $
|
walther@60336
|
473 |
(Const (\<^const_name>\<open>is_multUnordered\<close>, _) $ _) $
|
walther@60336
|
474 |
Const (\<^const_name>\<open>True\<close>, _))) => ()
|
walther@60328
|
475 |
| _ => error "poly.sml diff. eval_is_multUnordered";
|
walther@60328
|
476 |
|
walther@60328
|
477 |
"----- rewrite_set_ STILL DIDN'T WORK";
|
walther@60328
|
478 |
val SOME (t, _) = rewrite_set_ thy true order_mult_ t;
|
walther@60328
|
479 |
UnparseC.term t;
|
walther@60328
|
480 |
|
walther@60328
|
481 |
|
walther@60328
|
482 |
"-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------";
|
walther@60328
|
483 |
"-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------";
|
walther@60328
|
484 |
"-------- fun is_multUnordered (3 * a + - 2 * a) -----------------------------------------------";
|
walther@60328
|
485 |
val thy = @{theory "Isac_Knowledge"};
|
walther@60328
|
486 |
val t as (_ $ arg) = TermC.str2term "(3 * a + - 2 * a) is_multUnordered";
|
walther@60328
|
487 |
|
walther@60328
|
488 |
(*+*)if UnparseC.term (sort_variables arg) = "3 * a + - 2 * a" andalso is_polyexp arg = true
|
walther@60328
|
489 |
(*+*) andalso not (is_multUnordered arg)
|
walther@60328
|
490 |
(*+*)then () else error "sort_variables 3 * a + - 2 * a CHANGED";
|
walther@60328
|
491 |
|
walther@60328
|
492 |
case eval_is_multUnordered "xxx " "yyy " t thy of
|
walther@60328
|
493 |
SOME
|
walther@60328
|
494 |
("xxx 3 * a + - 2 * a_",
|
walther@60336
|
495 |
Const (\<^const_name>\<open>Trueprop\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ _ $
|
walther@60336
|
496 |
Const (\<^const_name>\<open>False\<close>, _))) => ()
|
walther@60336
|
497 |
(* Const (\<^const_name>\<open>True\<close>, _))) => () <<<<<--------------------------- this is false*)
|
walther@60329
|
498 |
| _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED";
|
walther@60328
|
499 |
|
walther@60328
|
500 |
"----- is_multUnordered --- (- 2 * a) is_multUnordered = False";
|
walther@60328
|
501 |
val t as (_ $ arg) = TermC.str2term "(- 2 * a) is_multUnordered";
|
walther@60328
|
502 |
|
walther@60328
|
503 |
(*+*)if UnparseC.term (sort_variables arg) = "- 2 * a" andalso is_polyexp arg = true
|
walther@60328
|
504 |
(*+*) andalso not (is_multUnordered arg)
|
walther@60328
|
505 |
(*+*)then () else error "sort_variables - 2 * a CHANGED";
|
walther@60328
|
506 |
|
walther@60328
|
507 |
case eval_is_multUnordered "xxx " "yyy " t thy of
|
walther@60328
|
508 |
SOME
|
walther@60328
|
509 |
("xxx - 2 * a_",
|
walther@60336
|
510 |
Const (\<^const_name>\<open>Trueprop\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ _ $
|
walther@60336
|
511 |
Const (\<^const_name>\<open>False\<close>, _))) => ()
|
walther@60329
|
512 |
| _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED";
|
walther@60328
|
513 |
|
walther@60328
|
514 |
"----- is_multUnordered --- (a) is_multUnordered = False";
|
walther@60328
|
515 |
val t as (_ $ arg) = TermC.str2term "(a) is_multUnordered";
|
walther@60328
|
516 |
|
walther@60328
|
517 |
(*+*)if UnparseC.term (sort_variables arg) = "a" andalso is_polyexp arg = true
|
walther@60328
|
518 |
(*+*) andalso not (is_multUnordered arg)
|
walther@60328
|
519 |
(*+*)then () else error "sort_variables a CHANGED";
|
walther@60328
|
520 |
|
walther@60328
|
521 |
case eval_is_multUnordered "xxx " "yyy " t thy of
|
walther@60328
|
522 |
SOME
|
walther@60328
|
523 |
("xxx a_",
|
walther@60336
|
524 |
Const (\<^const_name>\<open>Trueprop\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ _ $
|
walther@60336
|
525 |
Const (\<^const_name>\<open>False\<close>, _))) => ()
|
walther@60329
|
526 |
| _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED";
|
walther@60328
|
527 |
|
walther@60328
|
528 |
"----- is_multUnordered --- (- 2) is_multUnordered = False";
|
walther@60328
|
529 |
val t as (_ $ arg) = TermC.str2term "(- 2) is_multUnordered";
|
walther@60328
|
530 |
|
walther@60328
|
531 |
(*+*)if UnparseC.term (sort_variables arg) = "- 2" andalso is_polyexp arg = true
|
walther@60328
|
532 |
(*+*) andalso not (is_multUnordered arg)
|
walther@60328
|
533 |
(*+*)then () else error "sort_variables - 2 CHANGED";
|
walther@60328
|
534 |
|
walther@60328
|
535 |
case eval_is_multUnordered "xxx " "yyy " t thy of
|
walther@60328
|
536 |
SOME
|
walther@60328
|
537 |
("xxx - 2_",
|
walther@60336
|
538 |
Const (\<^const_name>\<open>Trueprop\<close>, _) $ (Const (\<^const_name>\<open>HOL.eq\<close>, _) $ _ $
|
walther@60336
|
539 |
Const (\<^const_name>\<open>False\<close>, _))) => ()
|
walther@60329
|
540 |
| _ => error "eval_is_multUnordered 3 * a + - 2 * a CHANGED";
|
walther@60328
|
541 |
|
walther@60328
|
542 |
|
walther@60328
|
543 |
"-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------";
|
walther@60328
|
544 |
"-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------";
|
walther@60328
|
545 |
"-------- fun is_multUnordered (x - a) \<up> 3 -----------------------------------------------------";
|
walther@60328
|
546 |
(* ca.line 45 of Rewrite.trace_on:
|
walther@60328
|
547 |
## rls: order_mult_rls_ on:
|
walther@60328
|
548 |
x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3
|
walther@60328
|
549 |
### rls: order_mult_ on:
|
walther@60328
|
550 |
x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3
|
walther@60328
|
551 |
###### rls: Rule_Set.empty-is_multUnordered on:
|
walther@60328
|
552 |
x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 is_multUnordered
|
walther@60328
|
553 |
####### try calc: "Poly.is_multUnordered"
|
walther@60328
|
554 |
######## eval asms:
|
walther@60328
|
555 |
N:x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3 is_multUnordered = True"
|
walther@60328
|
556 |
-------------------------------------------------------------------------------------------------==
|
walther@60329
|
557 |
O:x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * (- 1 \<up> 2 * a \<up> 2) + - 1 \<up> 3 * a \<up> 3 is_multUnordered = True"
|
walther@60328
|
558 |
####### calc. to: True
|
walther@60328
|
559 |
####### try calc: "Poly.is_multUnordered"
|
walther@60328
|
560 |
####### try calc: "Poly.is_multUnordered"
|
walther@60328
|
561 |
### rls: order_mult_ on:
|
walther@60328
|
562 |
N:x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) + 3 * (a \<up> 2 * (x * (- 1) \<up> 2)) + a \<up> 3 * (- 1) \<up> 3
|
walther@60328
|
563 |
--------+--------------------------+---------------------------------+---------------------------<>
|
walther@60329
|
564 |
O:x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) + - 1 \<up> 2 * (3 * (a \<up> 2 * x)) + - 1 \<up> 3 * a \<up> 3
|
walther@60328
|
565 |
-------------------------------------------------------------------------------------------------<>
|
walther@60328
|
566 |
*)
|
walther@60328
|
567 |
val t = TermC.str2term "x \<up> 3 + 3 * x \<up> 2 * (- 1 * a) + 3 * x * ((- 1) \<up> 2 * a \<up> 2) + (- 1) \<up> 3 * a \<up> 3";
|
walther@60328
|
568 |
(*
|
walther@60328
|
569 |
"~~~~~ fun is_multUnordered
|
walther@60328
|
570 |
"~~~~~~~ fun sort_variables
|
walther@60328
|
571 |
"~~~~~~~~~ val sort_varList
|
walther@60328
|
572 |
*)
|
walther@60328
|
573 |
"~~~~~ fun is_multUnordered , args:"; val (t) = (t);
|
walther@60328
|
574 |
is_polyexp t = true;
|
walther@60328
|
575 |
|
walther@60328
|
576 |
val return =
|
walther@60328
|
577 |
sort_variables t;
|
walther@60328
|
578 |
(*+*)if UnparseC.term return =
|
walther@60328
|
579 |
(*+*) "x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) +\n(- 1) \<up> 2 * (3 * (a \<up> 2 * x)) +\n(- 1) \<up> 3 * a \<up> 3"
|
walther@60328
|
580 |
(*+*)then () else error "sort_variables x \<up> 3 + - 1 * (3 * (a * x \<up> 2)) .. CHANGED";
|
walther@60328
|
581 |
|
walther@60328
|
582 |
"~~~~~~~ fun sort_variables , args:"; val (t) = (t);
|
walther@60328
|
583 |
val ll = map monom2list (poly2list t);
|
walther@60328
|
584 |
val lls = map sort_varList ll;
|
walther@60328
|
585 |
|
walther@60328
|
586 |
(*+*)val ori3 = nth 3 ll;
|
walther@60328
|
587 |
(*+*)val mon3 = nth 3 lls;
|
walther@60328
|
588 |
|
walther@60328
|
589 |
(*+*)if UnparseC.terms (nth 1 ll) = "[\"x \<up> 3\"]" then () else error "nth 1 ll";
|
walther@60328
|
590 |
(*+*)if UnparseC.terms (nth 2 ll) = "[\"3\", \"x \<up> 2\", \"- 1\", \"a\"]" then () else error "nth 3 ll";
|
walther@60328
|
591 |
(*+*)if UnparseC.terms ori3 = "[\"3\", \"x\", \"(- 1) \<up> 2\", \"a \<up> 2\"]" then () else error "nth 3 ll";
|
walther@60328
|
592 |
(*+*)if UnparseC.terms (nth 4 ll) = "[\"(- 1) \<up> 3\", \"a \<up> 3\"]" then () else error "nth 4 ll";
|
walther@60328
|
593 |
|
walther@60328
|
594 |
(*+*)if UnparseC.terms (nth 1 lls) = "[\"x \<up> 3\"]" then () else error "nth 1 lls";
|
walther@60328
|
595 |
(*+*)if UnparseC.terms (nth 2 lls) = "[\"- 1\", \"3\", \"a\", \"x \<up> 2\"]" then () else error "nth 2 lls";
|
walther@60328
|
596 |
(*+*)if UnparseC.terms mon3 = "[\"(- 1) \<up> 2\", \"3\", \"a \<up> 2\", \"x\"]" then () else error "nth 3 lls";
|
walther@60328
|
597 |
(*+*)if UnparseC.terms (nth 4 lls) = "[\"(- 1) \<up> 3\", \"a \<up> 3\"]" then () else error "nth 4 lls";
|
walther@60328
|
598 |
|
walther@60328
|
599 |
"~~~~~~~~~ val sort_varList , args:"; val (ori3) = (ori3);
|
walther@60328
|
600 |
(* Output below with:
|
walther@60328
|
601 |
val sort_varList = sort var_ord;
|
walther@60328
|
602 |
fun var_ord (a,b: term) =
|
walther@60328
|
603 |
(@{print} {a = "var_ord ", a_b = "(" ^ UnparseC.term a ^ ", " ^ UnparseC.term b ^ ")",
|
walther@60328
|
604 |
sort_args = "(" ^ get_basStr a ^ ", " ^ get_potStr a ^ "), (" ^ get_basStr b ^ ", " ^ get_potStr b ^ ")"};
|
walther@60328
|
605 |
prod_ord string_ord string_ord
|
walther@60328
|
606 |
((get_basStr a, get_potStr a), (get_basStr b, get_potStr b))
|
walther@60328
|
607 |
);
|
walther@60328
|
608 |
*)
|
walther@60328
|
609 |
(*+*)val xxx = sort_varList ori3;
|
walther@60328
|
610 |
(*
|
walther@60328
|
611 |
{a = "sort_varList", args = "[\"3\", \"x\", \"(- 1) \<up> 2\", \"a \<up> 2\"]"} (*isa*)
|
walther@60328
|
612 |
{a = "sort_varList", args = "[\"3\", \"x\", \"(- 1) \<up> 2\", \"a \<up> 2\"]"} (*isa2*)
|
walther@60328
|
613 |
|
walther@60328
|
614 |
isa isa2
|
walther@60328
|
615 |
{a = "var_ord ", a_b = "(3, x)"} {a = "var_ord ", a_b = "(3, x)"}
|
walther@60328
|
616 |
{sort_args = "(|||, ||||||), (x, ---)"} {sort_args = "(|||, ||||||), (x, ---)"}
|
walther@60328
|
617 |
{a = "var_ord ", a_b = "(x, (- 1) \<up> 2)"} {a = "var_ord ", a_b = "(x, (- 1) \<up> 2)"}
|
walther@60328
|
618 |
{sort_args = "(x, ---), (|||, ||||||)"} {sort_args = "(x, ---), (|||, ||||||)"}
|
walther@60328
|
619 |
{a = "var_ord ", a_b = "((- 1) \<up> 2, a \<up> 2)"} {a = "var_ord ", a_b = "((- 1) \<up> 2, a \<up> 2)"}
|
walther@60328
|
620 |
{sort_args = "(|||, ||||||), (a, 2)"} {sort_args = "(|||, ||||||), (a, |||)"}
|
walther@60328
|
621 |
^^^ ^^^
|
walther@60328
|
622 |
|
walther@60328
|
623 |
{a = "var_ord ", a_b = "(x, a \<up> 2)"} {a = "var_ord ", a_b = "(x, a \<up> 2)"}
|
walther@60328
|
624 |
{sort_args = "(x, ---), (a, 2)"} {sort_args = "(x, ---), (a, |||)"}
|
walther@60328
|
625 |
^^^ ^^^
|
walther@60328
|
626 |
{a = "var_ord ", a_b = "(x, (- 1) \<up> 2)"} {a = "var_ord ", a_b = "(x, (- 1) \<up> 2)"}
|
walther@60328
|
627 |
{sort_args = "(x, ---), (|||, ||||||)"} {sort_args = "(x, ---), (|||, ||||||)"}
|
walther@60328
|
628 |
{a = "var_ord ", a_b = "(3, (- 1) \<up> 2)"} {a = "var_ord ", a_b = "(3, (- 1) \<up> 2)"}
|
walther@60328
|
629 |
{sort_args = "(|||, ||||||), (|||, ||||||)"} {sort_args = "(|||, ||||||), (|||, ||||||)"}
|
walther@60328
|
630 |
*)
|
walther@60328
|
631 |
|
walther@60328
|
632 |
|
walther@60328
|
633 |
"-------- fun is_multUnordered b * a * a ------------------------------------------------------";
|
walther@60328
|
634 |
"-------- fun is_multUnordered b * a * a ------------------------------------------------------";
|
walther@60328
|
635 |
"-------- fun is_multUnordered b * a * a ------------------------------------------------------";
|
walther@60328
|
636 |
val t = TermC.str2term "b * a * a";
|
walther@60328
|
637 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
638 |
if UnparseC.term t = "a \<up> 2 * b" then ()
|
walther@60328
|
639 |
else error "poly.sml: diff.behav. in make_polynomial 21";
|
walther@60328
|
640 |
|
walther@60328
|
641 |
"~~~~~ fun is_multUnordered , args:"; val (t) = (@{term "b * a * a::real"});
|
walther@60328
|
642 |
((is_polyexp t) andalso not (t = sort_variables t)) = true; (*isa == isa2*)
|
walther@60328
|
643 |
|
walther@60328
|
644 |
(*+*)if is_polyexp t then () else error "is_polyexp a \<up> 2 * b CHANGED";
|
walther@60336
|
645 |
"~~~~~ fun is_polyexp , args:"; val (Const (\<^const_name>\<open>times\<close>,_) $ num $ Free _) = (t);
|
walther@60328
|
646 |
(*if*) TermC.is_num num (*else*);
|
walther@60328
|
647 |
|
walther@60336
|
648 |
"~~~~~ fun is_polyexp , args:"; val (Const (\<^const_name>\<open>times\<close>,_) $ num $ Free _) = (num);
|
walther@60328
|
649 |
(*if*) TermC.is_num num (*else*);
|
walther@60328
|
650 |
(*if*) TermC.is_variable num (*then*);
|
walther@60328
|
651 |
|
walther@60328
|
652 |
val xxx = sort_variables t;
|
walther@60328
|
653 |
(*+*)if UnparseC.term xxx = "a * (a * b)" then () else error "sort_variables a \<up> 2 * b CHANGED";
|
walther@60328
|
654 |
|
walther@60328
|
655 |
|
walther@60328
|
656 |
"-------- fun is_multUnordered 2*3*a -----------------------------------------------------------";
|
walther@60328
|
657 |
"-------- fun is_multUnordered 2*3*a -----------------------------------------------------------";
|
walther@60328
|
658 |
"-------- fun is_multUnordered 2*3*a -----------------------------------------------------------";
|
walther@60328
|
659 |
val t = TermC.str2term "2*3*a";
|
walther@60328
|
660 |
val SOME (t', _) = rewrite_set_ thy false make_polynomial t;
|
walther@60328
|
661 |
(*+*)if UnparseC.term t' = "6 * a" then () else error "rewrite_set_ 2*3*a CHANGED";
|
walther@60328
|
662 |
(*
|
walther@60328
|
663 |
## try calc: "Groups.times_class.times"
|
walther@60328
|
664 |
## rls: order_mult_rls_ on: 6 * a
|
walther@60328
|
665 |
### rls: order_mult_ on: 6 * a
|
walther@60328
|
666 |
###### rls: Rule_Set.empty-is_multUnordered on: 6 * a is_multUnordered
|
walther@60328
|
667 |
####### try calc: "Poly.is_multUnordered"
|
walther@60328
|
668 |
######## eval asms: "6 * a is_multUnordered = True" (*isa*)
|
walther@60328
|
669 |
= False" (*isa2*)
|
walther@60328
|
670 |
####### calc. to: True (*isa*)
|
walther@60328
|
671 |
False (*isa2*)
|
walther@60328
|
672 |
*)
|
walther@60328
|
673 |
val t = TermC.str2term "(6 * a) is_multUnordered";
|
walther@60328
|
674 |
val SOME
|
walther@60328
|
675 |
(_, t') =
|
walther@60328
|
676 |
eval_is_multUnordered "xxx" () t @{theory};
|
walther@60328
|
677 |
(*+*)if UnparseC.term t' = "6 * a is_multUnordered = False" then ()
|
walther@60328
|
678 |
(*+*)else error "6 * a is_multUnordered = False CHANGED";
|
walther@60328
|
679 |
|
walther@60328
|
680 |
"~~~~~ fun eval_is_multUnordered , args:"; val ((thmid:string), _,
|
walther@60336
|
681 |
(t as (Const (\<^const_name>\<open>is_multUnordered\<close>, _) $ arg)), thy) = ("xxx", (), t, @{theory});
|
walther@60328
|
682 |
(*if*) is_multUnordered arg (*else*);
|
walther@60328
|
683 |
|
walther@60328
|
684 |
"~~~~~ fun is_multUnordered , args:"; val (t) = (arg);
|
walther@60328
|
685 |
val return =
|
walther@60328
|
686 |
((is_polyexp t) andalso not (t = sort_variables t));
|
walther@60328
|
687 |
|
walther@60328
|
688 |
(*+*)return = false; (*isa*)
|
walther@60328
|
689 |
(*+*) is_polyexp t = true; (*isa*)
|
walther@60328
|
690 |
(*+*) not (t = sort_variables t) = false; (*isa*)
|
walther@60328
|
691 |
|
walther@60328
|
692 |
val xxx = sort_variables t;
|
walther@60328
|
693 |
(*+*)if UnparseC.term xxx = "6 * a" then () else error "2*3*a is_multUnordered CHANGED";
|
walther@60328
|
694 |
|
walther@60328
|
695 |
"-------- norm_Poly with AlgEin ----------------------------------------------------------------";
|
walther@60328
|
696 |
"-------- norm_Poly with AlgEin ----------------------------------------------------------------";
|
walther@60328
|
697 |
"-------- norm_Poly with AlgEin ----------------------------------------------------------------";
|
walther@60328
|
698 |
val thy = @{theory AlgEin};
|
walther@60328
|
699 |
|
walther@60328
|
700 |
val SOME (f',_) = rewrite_set_ thy false norm_Poly
|
walther@60328
|
701 |
(TermC.str2term "L = k - 2 * q + (k - 2 * q) + (k - 2 * q) + (k - 2 * q) + senkrecht + oben");
|
walther@60328
|
702 |
if UnparseC.term f' = "L = 2 * 2 * k + 2 * - 4 * q + senkrecht + oben"
|
walther@60328
|
703 |
then ((*norm_Poly NOT COMPLETE -- TODO MG*))
|
walther@60328
|
704 |
else error "norm_Poly changed behavior";
|
walther@60328
|
705 |
(* isa:
|
walther@60328
|
706 |
## rls: order_add_rls_ on: L = k + - 2 * q + k + - 2 * q + k + - 2 * q + k + - 2 * q + senkrecht + oben
|
walther@60328
|
707 |
### rls: order_add_ on: L = k + - 2 * q + k + - 2 * q + k + - 2 * q + k + - 2 * q + senkrecht + oben
|
walther@60328
|
708 |
###### rls: Rule_Set.empty-is_addUnordered on: k + - 2 * q + k + - 2 * q + k + - 2 * q + k + - 2 * q + senkrecht +
|
walther@60328
|
709 |
oben is_addUnordered
|
walther@60328
|
710 |
####### try calc: "Poly.is_addUnordered"
|
walther@60328
|
711 |
######## eval asms: "k + - 2 * q + k + - 2 * q + k + - 2 * q + k + - 2 * q + senkrecht +
|
walther@60328
|
712 |
oben is_addUnordered = True"
|
walther@60328
|
713 |
####### calc. to: True
|
walther@60328
|
714 |
####### try calc: "Poly.is_addUnordered"
|
walther@60328
|
715 |
####### try calc: "Poly.is_addUnordered"
|
walther@60328
|
716 |
### rls: order_add_ on: L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben
|
walther@60328
|
717 |
*)
|
walther@60328
|
718 |
"~~~~~ fun sort_monoms , args:"; val (t) =
|
walther@60328
|
719 |
(TermC.str2term "L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben");
|
walther@60328
|
720 |
(*+*)val t' =
|
walther@60328
|
721 |
sort_monoms t;
|
walther@60328
|
722 |
(*+*)UnparseC.term t' = "L = k + k + k + k + - 2 * q + - 2 * q + - 2 * q + - 2 * q + senkrecht + oben"; (*isa*)
|
walther@60328
|
723 |
|
walther@60328
|
724 |
|
walther@60328
|
725 |
"-------- complex examples from textbook Schalk I ----------------------------------------------";
|
walther@60328
|
726 |
"-------- complex examples from textbook Schalk I ----------------------------------------------";
|
walther@60328
|
727 |
"-------- complex examples from textbook Schalk I ----------------------------------------------";
|
walther@60329
|
728 |
val t = TermC.str2term "1 + 2 * x \<up> 4 + 2 * - 2 * x \<up> 4 + x \<up> 8";
|
walther@60328
|
729 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60329
|
730 |
if (UnparseC.term t) = "1 + - 2 * x \<up> 4 + x \<up> 8"
|
walther@60328
|
731 |
then () else error "poly.sml: diff.behav. in make_polynomial 9b";
|
walther@60328
|
732 |
|
walther@60328
|
733 |
"-----SPB Schalk I p.64 No.296a ---";
|
walther@60328
|
734 |
val t = TermC.str2term "(x - a) \<up> 3";
|
walther@60328
|
735 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60329
|
736 |
if (UnparseC.term t) = "- 1 * a \<up> 3 + 3 * a \<up> 2 * x + - 3 * a * x \<up> 2 + x \<up> 3"
|
walther@60328
|
737 |
then () else error "poly.sml: diff.behav. in make_polynomial 10";
|
walther@60328
|
738 |
|
walther@60328
|
739 |
"-----SPB Schalk I p.64 No.296c ---";
|
walther@60328
|
740 |
val t = TermC.str2term "(-3*x - 4*y) \<up> 3";
|
walther@60328
|
741 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60329
|
742 |
if (UnparseC.term t) = "- 27 * x \<up> 3 + - 108 * x \<up> 2 * y + - 144 * x * y \<up> 2 +\n- 64 * y \<up> 3"
|
walther@60328
|
743 |
then () else error "poly.sml: diff.behav. in make_polynomial 11";
|
walther@60328
|
744 |
|
walther@60328
|
745 |
"-----SPB Schalk I p.62 No.242c ---";
|
walther@60329
|
746 |
val t = TermC.str2term "x \<up> (- 4)*(x \<up> (- 4)*y \<up> (- 2)) \<up> (- 1)*y \<up> (- 2)";
|
walther@60328
|
747 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
748 |
if (UnparseC.term t) = "1"
|
walther@60328
|
749 |
then () else error "poly.sml: diff.behav. in make_polynomial 12";
|
walther@60328
|
750 |
|
walther@60328
|
751 |
"-----SPB Schalk I p.60 No.209a ---";
|
walther@60328
|
752 |
val t = TermC.str2term "a \<up> (7-x) * a \<up> x";
|
walther@60328
|
753 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
754 |
if UnparseC.term t = "a \<up> 7"
|
walther@60328
|
755 |
then () else error "poly.sml: diff.behav. in make_polynomial 13";
|
walther@60328
|
756 |
|
walther@60328
|
757 |
"-----SPB Schalk I p.60 No.209d ---";
|
walther@60328
|
758 |
val t = TermC.str2term "d \<up> x * d \<up> (x+1) * d \<up> (2 - 2*x)";
|
walther@60328
|
759 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
760 |
if UnparseC.term t = "d \<up> 3"
|
walther@60328
|
761 |
then () else error "poly.sml: diff.behav. in make_polynomial 14";
|
walther@60328
|
762 |
|
walther@60328
|
763 |
|
walther@60328
|
764 |
"-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------";
|
walther@60328
|
765 |
"-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------";
|
walther@60328
|
766 |
"-------- complex Eigene Beispiele (Mathias Goldgruber) ----------------------------------------";
|
walther@60328
|
767 |
"-----SPO ---";
|
walther@60329
|
768 |
val t = TermC.str2term "a \<up> 2*a \<up> (- 2)";
|
walther@60328
|
769 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
770 |
if UnparseC.term t = "1" then ()
|
walther@60328
|
771 |
else error "poly.sml: diff.behav. in make_polynomial 15";
|
walther@60328
|
772 |
|
walther@60328
|
773 |
"-----SPO ---";
|
walther@60329
|
774 |
val t = TermC.str2term "a \<up> 2*b*b \<up> (- 1)";
|
walther@60328
|
775 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
776 |
if UnparseC.term t = "a \<up> 2" then ()
|
walther@60328
|
777 |
else error "poly.sml: diff.behav. in make_polynomial 18";
|
walther@60328
|
778 |
"-----SPO ---";
|
walther@60329
|
779 |
val t = TermC.str2term "a \<up> 2*a \<up> (- 2)";
|
walther@60328
|
780 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
781 |
if (UnparseC.term t) = "1" then ()
|
walther@60328
|
782 |
else error "poly.sml: diff.behav. in make_polynomial 19";
|
walther@60328
|
783 |
"-----SPO ---";
|
walther@60328
|
784 |
val t = TermC.str2term "b + a - b";
|
walther@60328
|
785 |
val SOME (t,_) = rewrite_set_ thy false make_polynomial t; UnparseC.term t;
|
walther@60328
|
786 |
if (UnparseC.term t) = "a" then ()
|
walther@60328
|
787 |
else error "poly.sml: diff.behav. in make_polynomial 20";
|
walther@60328
|
788 |
|
walther@60328
|
789 |
"-----SPO ---";
|
walther@60340
|
790 |
val t = (Thm.term_of o the o (TermC.parse thy)) "a \<up> 2 * (-a) \<up> 2";
|
walther@60328
|
791 |
val SOME (t,_) = rewrite_set_ @{theory} false make_polynomial t; UnparseC.term t;
|
walther@60328
|
792 |
if (UnparseC.term t) = "a \<up> 4" then ()
|
walther@60328
|
793 |
else error "poly.sml: diff.behav. in make_polynomial 24";
|