1 | ////////////////////////////////////////////////////////////////////// |
---|
2 | version="version ncloc.lib 4.0.0.0 Dec_2017 "; // $Id$ |
---|
3 | category="Noncommutative"; |
---|
4 | info=" |
---|
5 | LIBRARY: ncloc.lib Ore-localization in G-Algebras |
---|
6 | AUTHOR: Johannes Hoffmann, email: johannes.hoffmann at math.rwth-aachen.de |
---|
7 | |
---|
8 | OVERVIEW: |
---|
9 | This library introduces a new type: ncloc. |
---|
10 | This type wraps the localization data defined as in olga.lib. |
---|
11 | An element of type ncloc has two members: |
---|
12 | - int locType |
---|
13 | - def locData |
---|
14 | |
---|
15 | OPERATIONS: |
---|
16 | string(ncloc); |
---|
17 | give a string representation of the data describing the localization |
---|
18 | print(ncloc); |
---|
19 | prints the string representation of the localization |
---|
20 | status(ncloc); |
---|
21 | report on the status/validity of the localization |
---|
22 | test(ncloc); |
---|
23 | check if the localization is valid |
---|
24 | |
---|
25 | INFIX OPERATIONS: |
---|
26 | ncloc == ncloc; |
---|
27 | compare two localizations |
---|
28 | ncloc != ncloc; |
---|
29 | compare two localizations |
---|
30 | ncloc = list/poly |
---|
31 | create a monoidal localization from the given data |
---|
32 | ncloc = ideal |
---|
33 | create a geometric localization from the given data |
---|
34 | ncloc = intvec |
---|
35 | create a rational localization from the given data |
---|
36 | |
---|
37 | PROCEDURES: |
---|
38 | isDenom(poly, ncloc); |
---|
39 | determine if a polynomial is in the denominator set of the localization |
---|
40 | testNcloc(); |
---|
41 | execute a series of internal testing procedures |
---|
42 | testNclocExamples(); |
---|
43 | execute the examples of all procedures in this library |
---|
44 | "; |
---|
45 | ////////////////////////////////////////////////////////////////////// |
---|
46 | proc testNclocExamples() |
---|
47 | "USAGE: testNclocExamples() |
---|
48 | PURPOSE: execute the examples of all procedures in this library |
---|
49 | RETURN: nothing |
---|
50 | NOTE: |
---|
51 | EXAMPLE: " |
---|
52 | { |
---|
53 | example isDenom; |
---|
54 | } |
---|
55 | ////////////////////////////////////////////////////////////////////// |
---|
56 | proc testNcloc() |
---|
57 | "USAGE: testNcloc() |
---|
58 | PURPOSE: execute a series of internal testing procedures |
---|
59 | RETURN: nothing |
---|
60 | NOTE: |
---|
61 | EXAMPLE: " |
---|
62 | { |
---|
63 | print("testing ncloc.lib..."); |
---|
64 | testNclocCreation(); |
---|
65 | testNclocComparison(); |
---|
66 | testDenominatorDetection(); |
---|
67 | print("testing complete - ncloc.lib OK"); |
---|
68 | } |
---|
69 | ////////////////////////////////////////////////////////////////////// |
---|
70 | static proc mod_init() { |
---|
71 | LIB "olga.lib"; |
---|
72 | /* new type: ncloc (non-commutative localization) */ |
---|
73 | newstruct("ncloc", "def locData, int locType"); |
---|
74 | // types: 0 - monoidal, 1 - geometric, 2 - rational |
---|
75 | system("install", "ncloc", "string", nclocToString, 1); |
---|
76 | system("install", "ncloc", "print", printNcloc, 1); |
---|
77 | system("install", "ncloc", "=", createNcloc, 1); |
---|
78 | system("install", "ncloc", "==", compareNclocs, 2); |
---|
79 | system("install", "ncloc", "!=", invertedCompareNclocs, 2); |
---|
80 | system("install", "ncloc", "test", testNcloc, 4); |
---|
81 | system("install", "ncloc", "status", statusNcloc, 4); |
---|
82 | } |
---|
83 | ////////// status and printing /////////////////////////////////////// |
---|
84 | static proc statusNcloc(ncloc loc) { |
---|
85 | return(locStatus(loc.locType, loc.locData)); // locStatus from olga.lib |
---|
86 | } |
---|
87 | ////////////////////////////////////////////////////////////////////// |
---|
88 | static proc testNcloc(ncloc loc) { |
---|
89 | list stat = status(loc); |
---|
90 | if(!stat[1]) { |
---|
91 | ERROR(stat[2]); |
---|
92 | } else { |
---|
93 | return(); |
---|
94 | } |
---|
95 | } |
---|
96 | ////////////////////////////////////////////////////////////////////// |
---|
97 | static proc nclocToString(ncloc loc) { |
---|
98 | list stat = status(loc); |
---|
99 | if (!stat[1]) { |
---|
100 | return(stat[2]); |
---|
101 | } |
---|
102 | string result; |
---|
103 | int locT = loc.locType; |
---|
104 | int i; |
---|
105 | if (locT == 0) { |
---|
106 | list data = loc.locData; |
---|
107 | result = result + "monoidal localization generated by:" + newline; |
---|
108 | result = result + string(data[1]); |
---|
109 | for (i = 2; i <= size(data); i++) { |
---|
110 | result = result + ", " + string(data[i]); |
---|
111 | } |
---|
112 | } |
---|
113 | if (locT == 1) { |
---|
114 | ideal data = loc.locData; |
---|
115 | result = result + "geometric localization at prime ideal:" + newline; |
---|
116 | result = result + data; |
---|
117 | } |
---|
118 | if (locT == 2) { |
---|
119 | intvec data = loc.locData; |
---|
120 | result = result + "rational localization generated by:" + newline; |
---|
121 | result = result + string(var(data[1])); |
---|
122 | for (i = 2; i <= size(data); i++) { |
---|
123 | result = result + ", " + string(var(data[i])); |
---|
124 | } |
---|
125 | } |
---|
126 | if (result == "") { |
---|
127 | result = "invalid localization"; |
---|
128 | } |
---|
129 | return(result); |
---|
130 | } |
---|
131 | ////////////////////////////////////////////////////////////////////// |
---|
132 | static proc printNcloc(ncloc loc) { |
---|
133 | print(string(loc)); |
---|
134 | } |
---|
135 | ////////// initialization, comparison and declaration //////////////// |
---|
136 | static proc createNcloc(def input) { |
---|
137 | string inputType = typeof(input); |
---|
138 | ncloc result; |
---|
139 | if (inputType == "list") { |
---|
140 | result.locType = 0; |
---|
141 | result.locData = normalizeMonoidal(input); |
---|
142 | } |
---|
143 | if (inputType == "poly") { |
---|
144 | result.locType = 0; |
---|
145 | result.locData = normalizeMonoidal(list(input)); |
---|
146 | } |
---|
147 | if (inputType == "ideal") { |
---|
148 | result.locType = 1; |
---|
149 | result.locData = std(input); |
---|
150 | } |
---|
151 | if (inputType == "intvec") { |
---|
152 | result.locType = 2; |
---|
153 | result.locData = normalizeRational(input); |
---|
154 | } |
---|
155 | test(result); |
---|
156 | return(result); |
---|
157 | } |
---|
158 | ////////////////////////////////////////////////////////////////////// |
---|
159 | static proc compareNclocs(ncloc loc1, ncloc loc2) { |
---|
160 | // only detects "naturally" isomorphic localizations |
---|
161 | test(loc1); |
---|
162 | test(loc2); |
---|
163 | int locT = loc1.locType; |
---|
164 | if (locT != loc2.locType) { |
---|
165 | return(0); // different types of localizations |
---|
166 | } |
---|
167 | if (locT == 0) { |
---|
168 | int i, j, found; |
---|
169 | list L1 = loc1.locData; |
---|
170 | list L2 = loc2.locData; |
---|
171 | for (i = 1; i <= size(L1); i++) { // test if L1 subset of L2 |
---|
172 | found = 0; |
---|
173 | for (j = 1; j <= size(L2); j++) { |
---|
174 | if (L1[i] == L2[j]) { |
---|
175 | found = 1; |
---|
176 | break; |
---|
177 | } |
---|
178 | } |
---|
179 | if (!found) { |
---|
180 | return(0); |
---|
181 | } |
---|
182 | } |
---|
183 | for (j = 1; j <= size(L2); j++) { // test if L2 subset of L1 |
---|
184 | found = 0; |
---|
185 | for (i = 1; i <= size(L1); i++) { |
---|
186 | if (L1[i] == L2[j]) { |
---|
187 | found = 1; |
---|
188 | break; |
---|
189 | } |
---|
190 | } |
---|
191 | if (!found) { |
---|
192 | return(0); |
---|
193 | } |
---|
194 | } |
---|
195 | return(1); |
---|
196 | } |
---|
197 | if (locT == 1) { |
---|
198 | ideal I1 = std(loc1.locData); |
---|
199 | ideal I2 = std(loc2.locData); |
---|
200 | if (size(NF(I1,I2)) != 0) { // test if I1 subset of I2 |
---|
201 | return(0); |
---|
202 | } |
---|
203 | if (size(NF(I2,I1)) != 0) { // test if I2 subset of I1 |
---|
204 | return(0); |
---|
205 | } |
---|
206 | return(1); |
---|
207 | } |
---|
208 | if (locT == 2) { |
---|
209 | return(loc1.locData == loc2.locData); // direct comparison of intvec |
---|
210 | } |
---|
211 | ERROR("unreachable state reached"); // enforced by testNcloc |
---|
212 | } |
---|
213 | ////////////////////////////////////////////////////////////////////// |
---|
214 | static proc invertedCompareNclocs(ncloc loc1, ncloc loc2) { |
---|
215 | return(!(compareNclocs(loc1, loc2))); |
---|
216 | } |
---|
217 | ////////////////////////////////////////////////////////////////////// |
---|
218 | proc isDenom(poly p, ncloc loc) |
---|
219 | "USAGE: isDenom(p, loc), poly a, ncloc loc |
---|
220 | PURPOSE: check if p is a valid denominator in the localization loc |
---|
221 | RETURN: int |
---|
222 | NOTE: returns 1 or 0, depending whether p is a valid denominator |
---|
223 | EXAMPLE: example isDenom; shows examples" |
---|
224 | { |
---|
225 | return(isInS(p, loc.locType, loc.locData, 1)); // isInS from olga.lib |
---|
226 | } |
---|
227 | example |
---|
228 | { |
---|
229 | "EXAMPLE:"; echo = 2; |
---|
230 | ring R = 0,(x,y,Dx,Dy),dp; |
---|
231 | def S = Weyl(); |
---|
232 | setring S; S; |
---|
233 | // monoidal localization |
---|
234 | ncloc loc; |
---|
235 | poly g1 = x^2*y+x+2; |
---|
236 | poly g2 = y^3+x*y; |
---|
237 | list L = g1,g2; |
---|
238 | loc = L; |
---|
239 | poly g = g1^2*g2; |
---|
240 | poly f = g - 1; |
---|
241 | isDenom(g, loc); |
---|
242 | isDenom(f, loc); |
---|
243 | // geometrical localization |
---|
244 | loc = ideal(x-1,y-3); |
---|
245 | g = x^2+y-3; |
---|
246 | f = (x-1)*g; |
---|
247 | isDenom(g, loc); |
---|
248 | isDenom(f, loc); |
---|
249 | // rational localization |
---|
250 | intvec v = 2; |
---|
251 | loc = v; |
---|
252 | g = y^5+17*y^2-4; |
---|
253 | f = x*y; |
---|
254 | isDenom(g, loc); |
---|
255 | isDenom(f, loc); |
---|
256 | } |
---|
257 | ////////////////////////////////////////////////////////////////////// |
---|
258 | ////////// internal testing procedures /////////////////////////////// |
---|
259 | static proc testNclocCreation() |
---|
260 | { |
---|
261 | print(" testing ncloc creation..."); |
---|
262 | ring r = 0,(x,y,Dx,Dy),dp; |
---|
263 | def R = Weyl(); |
---|
264 | setring R; |
---|
265 | ncloc loc1 = list(x*y,4*x); // create from list |
---|
266 | ncloc loc2 = 3*Dx*Dy+2; // create from poly |
---|
267 | ncloc loc3 = ideal(x-3,y2+y+1); // create from ideal |
---|
268 | ncloc loc4 = intvec(1,2); // create from intvec |
---|
269 | ncloc loc5 = intvec(3); |
---|
270 | print(" ncloc creation OK"); |
---|
271 | } |
---|
272 | ////////////////////////////////////////////////////////////////////// |
---|
273 | static proc testNclocComparison() |
---|
274 | { |
---|
275 | print(" testing ncloc comparison..."); |
---|
276 | ring r = 0,(x,y,Dx,Dy),dp; |
---|
277 | def R = Weyl(); |
---|
278 | setring R; |
---|
279 | // monoidal localization |
---|
280 | ncloc monloc1 = list(x,y-3); |
---|
281 | ncloc monloc2 = list(x*(y-3)^2); |
---|
282 | ncloc monloc3 = list(y-3); |
---|
283 | if (!(monloc1 == monloc2)) { |
---|
284 | ERROR("monoidal comparison failed"); |
---|
285 | } |
---|
286 | if (!(monloc1 != monloc3)) { |
---|
287 | ERROR("monoidal inverted comparison failed"); |
---|
288 | } |
---|
289 | // geometric localization |
---|
290 | ncloc geoloc1 = ideal(x*y-y+2, y^2-x-2); |
---|
291 | ncloc geoloc2 = ideal(x*y-y+2, y^2-x-2, x^2+x+2*y-2); |
---|
292 | ncloc geoloc3 = ideal(x*y-y+1, y^2-x-2); |
---|
293 | if (!(geoloc1 == geoloc2)) { |
---|
294 | ERROR("geometric comparison failed"); |
---|
295 | } |
---|
296 | if (!(geoloc1 != geoloc3)) { |
---|
297 | ERROR("geometric inverted comparison failed"); |
---|
298 | } |
---|
299 | // rational localization |
---|
300 | ncloc ratloc1 = intvec(1); |
---|
301 | ncloc ratloc2 = intvec(1,1); |
---|
302 | ncloc ratloc3 = intvec(2); |
---|
303 | if (!(ratloc1 == ratloc2)) { |
---|
304 | ERROR("rational comparison failed"); |
---|
305 | } |
---|
306 | if (!(ratloc1 != ratloc3)) { |
---|
307 | ERROR("rational inverted comparison failed"); |
---|
308 | } |
---|
309 | print(" ncloc comparison OK"); |
---|
310 | } |
---|
311 | ////////////////////////////////////////////////////////////////////// |
---|
312 | static proc testDenominatorDetection() { |
---|
313 | print(" testing ncloc denominator detection..."); |
---|
314 | ring R = 0,(x,y,Dx,Dy),dp; |
---|
315 | def S = Weyl(); |
---|
316 | setring S; |
---|
317 | // monoidal localization |
---|
318 | ncloc loc; |
---|
319 | poly g1 = x^2*y+x+2; |
---|
320 | poly g2 = y^3+x*y; |
---|
321 | loc = list(g1,g2); |
---|
322 | poly g = g1^2*g2; |
---|
323 | poly f = g - 1; |
---|
324 | if (!isDenom(g, loc)) { |
---|
325 | ERROR("monoidal positive denominator detection error"); |
---|
326 | } |
---|
327 | if (isDenom(f, loc)) { |
---|
328 | ERROR("monoidal negative denominator detection error"); |
---|
329 | } |
---|
330 | // geometric localization |
---|
331 | loc = ideal(x-1,y-3); |
---|
332 | g = x^2+y-3; |
---|
333 | f = (x-1)*g; |
---|
334 | if (!isDenom(g, loc)) { |
---|
335 | ERROR("geometric maximal positive denominator detection error"); |
---|
336 | } |
---|
337 | if (isDenom(f, loc)) { |
---|
338 | ERROR("geometric maximal negative denominator detection error"); |
---|
339 | } |
---|
340 | loc = ideal(x); |
---|
341 | g = x*y^2-7*y+3; |
---|
342 | f = x^2-3*x; |
---|
343 | if (!isDenom(g, loc)) { |
---|
344 | ERROR("geometric prime positive denominator detection error"); |
---|
345 | } |
---|
346 | if (isDenom(f, loc)) { |
---|
347 | ERROR("geometric prime negative denominator detection error"); |
---|
348 | } |
---|
349 | // rational localization |
---|
350 | loc = intvec(2); |
---|
351 | g = y^5+17*y^2-4; |
---|
352 | f = x*y; |
---|
353 | if (!isDenom(g, loc)) { |
---|
354 | ERROR("rational positive denominator detection error"); |
---|
355 | } |
---|
356 | if (isDenom(f, loc)) { |
---|
357 | ERROR("rational negative denominator detection error"); |
---|
358 | } |
---|
359 | print(" ncloc denominator detection OK"); |
---|
360 | } |
---|
361 | ////////////////////////////////////////////////////////////////////// |
---|