1 | /////////////////////////////////////////////////////// |
---|
2 | version="$Id: fpadim.lib,v beta 2010/09/27 13:14:51 studzins Exp $"; |
---|
3 | category="Noncommutative"; |
---|
4 | info=" |
---|
5 | LIBRARY: fpadim.lib Algorithms for quotient algebras |
---|
6 | AUTHORS: Grischa Studzinski, grischa.studzinski@rwth-aachen.de |
---|
7 | |
---|
8 | SUPPORT: Projects LE 2697/2-1; KR 1907/3-1 of the Priority Programme SPP 1489: |
---|
9 | @* 'Algorithmische und Experimentelle Methoden in Algebra, Geometrie und Zahlentheorie' |
---|
10 | @* of the German DFG |
---|
11 | |
---|
12 | OVERVIEW: Given the free algebra A = K<x_1,...,x_n> and a (finite) Groebner basis |
---|
13 | @* GB = {g_1,..,g_w}, one is interested in the K-dimension and in the |
---|
14 | @* explicit K-basis of A/<GB>. |
---|
15 | @* Therefore one is interested in the following data: |
---|
16 | @* - the Ufnarovskij graph induced by GB |
---|
17 | @* - the mistletoes of A/<GB> |
---|
18 | @* - the K-dimension of A/<GB> |
---|
19 | @* - the Hilbert series of A/<GB> |
---|
20 | @* |
---|
21 | @* The Ufnarovskij graph is used to determine whether A/<GB> has finite |
---|
22 | @* K-dimension. One has to check if the graph contains cycles. |
---|
23 | @* For the whole theory we refer to [ufna]. Given a |
---|
24 | @* reduced set of monomials GB one can define the basis tree, which vertex |
---|
25 | @* set V consists of all normal monomials w.r.t. GB. For every two |
---|
26 | @* monomials m_1, m_2 in V there is a direct edge from m_1 to m_2, if and |
---|
27 | @* only if there exists x_k in {x_1,..,x_n}, such that m_1*x_k = m_2. The |
---|
28 | @* set M = {m in V | there is no edge from m to another monomial in V} is |
---|
29 | @* called the set of mistletoes. As one can easily see it consists of |
---|
30 | @* the endpoints of the graph. Since there is a unique path to every |
---|
31 | @* monomial in V the whole graph can be described only from the knowledge |
---|
32 | @* of the mistletoes. Note that V corresponds to a basis of A/<GB>, so |
---|
33 | @* knowing the mistletoes we know a K-basis. For more details see |
---|
34 | @* [studzins]. This package uses the Letterplace format introduced by |
---|
35 | @* [lls]. The algebra can either be represented as a Letterplace ring or |
---|
36 | @* via integer vectors: Every variable will only be represented by its |
---|
37 | @* number, so variable one is represented as 1, variable two as 2 and so |
---|
38 | @* on. The monomial x_1*x_3*x_2 for example will be stored as (1,3,2). |
---|
39 | @* Multiplication is concatenation. Note that there is no algorithm for |
---|
40 | @* computing the normalform yet, but for our case it is not needed. |
---|
41 | @* |
---|
42 | |
---|
43 | REFERENCES: |
---|
44 | |
---|
45 | @* [ufna] Ufnarovskij: Combinatorical and asymptotic methods in algebra, |
---|
46 | @* 1990 |
---|
47 | @* [lls] Levandovskyy, La Scala: Letterplace ideals and non-commutative |
---|
48 | @* Groebner bases, 2009 |
---|
49 | @* [studzins] Studzinski: Dimension computations in non-commutative, |
---|
50 | @* associative algebras, Diploma thesis, RWTH Aachen, 2010 |
---|
51 | |
---|
52 | ASSUMPTIONS: |
---|
53 | @* - basering is always a Letterplace ring |
---|
54 | @* - all intvecs correspond to Letterplace monomials |
---|
55 | @* - if you specify a different degree bound d, |
---|
56 | @* d <= attrib(basering,uptodeg) holds |
---|
57 | @* |
---|
58 | @* In the procedures below, 'iv' stands for intvec representation |
---|
59 | @* and 'lp' for the letterplace representation of monomials |
---|
60 | |
---|
61 | PROCEDURES: |
---|
62 | |
---|
63 | ivDHilbert(L,n[,d]); computes the K-dimension and the Hilbert series |
---|
64 | ivDHilbertSickle(L,n[,d]); computes mistletoes, K-dimension and Hilbert series |
---|
65 | ivDimCheck(L,n); checks if the K-dimension of A/<L> is infinite |
---|
66 | ivHilbert(L,n[,d]); computes the Hilbert series of A/<L> in intvec format |
---|
67 | ivKDim(L,n[,d]); computes the K-dimension of A/<L> in intvec format |
---|
68 | ivMis2Dim(M); computes the K-dimension of the factor algebra |
---|
69 | ivOrdMisLex(M); orders a list of intvecs lexicographically |
---|
70 | ivSickle(L,n[,d]); computes the mistletoes of A/<L> in intvec format |
---|
71 | ivSickleHil(L,n[,d]); computes the mistletoes and Hilbert series of A/<L> |
---|
72 | ivSickleDim(L,n[,d]); computes the mistletoes and the K-dimension of A/<L> |
---|
73 | lpDHilbert(G[,d,n]); computes the K-dimension and Hilbert series of A/<G> |
---|
74 | lpDHilbertSickle(G[,d,n]); computes mistletoes, K-dimension and Hilbert series |
---|
75 | lpHilbert(G[,d,n]); computes the Hilbert series of A/<G> in lp format |
---|
76 | lpDimCheck(G); checks if the K-dimension of A/<G> is infinite |
---|
77 | lpKDim(G[,d,n]); computes the K-dimension of A/<G> in lp format |
---|
78 | lpMis2Dim(M); computes the K-dimension of the factor algebra |
---|
79 | lpOrdMisLex(M); orders an ideal of lp-monomials lexicographically |
---|
80 | lpSickle(G[,d,n]); computes the mistletoes of A/<G> in lp format |
---|
81 | lpSickleHil(G[,d,n]); computes the mistletoes and Hilbert series of A/<G> |
---|
82 | lpSickleDim(G[,d,n]); computes the mistletoes and the K-dimension of A/<G> |
---|
83 | sickle(G[,m,d,h]); can be used to access all lp main procedures |
---|
84 | |
---|
85 | |
---|
86 | ivL2lpI(L); transforms a list of intvecs into an ideal of lp monomials |
---|
87 | iv2lp(I); transforms an intvec into the corresponding monomial |
---|
88 | iv2lpList(L); transforms a list of intmats into an ideal of lp monomials |
---|
89 | iv2lpMat(M); transforms an intmat into an ideal of lp monomials |
---|
90 | lp2iv(p); transforms a polynomial into the corresponding intvec |
---|
91 | lp2ivId(G); transforms an ideal into the corresponding list of intmats |
---|
92 | lpId2ivLi(G); transforms a lp-ideal into the corresponding list of intvecs |
---|
93 | |
---|
94 | SEE ALSO: freegb_lib |
---|
95 | "; |
---|
96 | |
---|
97 | LIB "freegb.lib"; //for letterplace rings |
---|
98 | LIB "general.lib";//for sorting mistletoes |
---|
99 | |
---|
100 | ///////////////////////////////////////////////////////// |
---|
101 | |
---|
102 | |
---|
103 | //--------------- auxiliary procedures ------------------ |
---|
104 | |
---|
105 | static proc allVars(list L, intvec P, int n) |
---|
106 | "USAGE: allVars(L,P,n); L a list of intmats, P an intvec, n an integer |
---|
107 | RETURN: 0, if all variables are contained in the quotient algebra, 1 otherwise |
---|
108 | " |
---|
109 | {int i,j,r; |
---|
110 | intvec V; |
---|
111 | for (i = 1; i <= size(P); i++) {if (P[i] == 1){ j = i; break;}} |
---|
112 | V = L[j][1..nrows(L[j]),1]; |
---|
113 | for (i = 1; i <= n; i++) {if (isInVec(i,V) == 0) {r = 1; break;}} |
---|
114 | if (r == 0) {return(1);} |
---|
115 | else {return(0);} |
---|
116 | } |
---|
117 | |
---|
118 | static proc checkAssumptions(int d, list L) |
---|
119 | "PURPOSE: Checks, if all the Assumptions are holding |
---|
120 | " |
---|
121 | {if (typeof(attrib(basering,"isLetterplaceRing"))=="string") {ERROR("Basering is not a Letterplace ring!");} |
---|
122 | if (d > attrib(basering,"uptodeg")) {ERROR("Specified degree bound exceeds ring parameter!");} |
---|
123 | int i; |
---|
124 | for (i = 1; i <= size(L); i++) |
---|
125 | {if (entryViolation(L[i], attrib(basering,"lV"))) |
---|
126 | {ERROR("Not allowed monomial/intvec found!");} |
---|
127 | } |
---|
128 | return(); |
---|
129 | } |
---|
130 | |
---|
131 | static proc createStartMat(int d, int n) |
---|
132 | "USAGE: createStartMat(d,n); d, n integers |
---|
133 | RETURN: An intmat |
---|
134 | PURPOSE:Creating the intmat with all normal monomials in n variables and of degree d to start with |
---|
135 | NOTE: d has to be > 0 |
---|
136 | " |
---|
137 | {intmat M[(n^d)][d]; |
---|
138 | int i1,i2,i3,i4; |
---|
139 | for (i1 = 1; i1 <= d; i1++) //Spalten |
---|
140 | {i2 = 1; //durchlaeuft Zeilen |
---|
141 | while (i2 <= (n^d)) |
---|
142 | {for (i3 = 1; i3 <= n; i3++) |
---|
143 | {for (i4 = 1; i4 <= (n^(i1-1)); i4++) |
---|
144 | {M[i2,i1] = i3; |
---|
145 | i2 = i2 + 1; |
---|
146 | } |
---|
147 | } |
---|
148 | } |
---|
149 | } |
---|
150 | return(M); |
---|
151 | } |
---|
152 | |
---|
153 | static proc createStartMat1(int n, intmat M) |
---|
154 | "USAGE: createStartMat1(n,M); n an integer, M an intmat |
---|
155 | RETURN: An intmat with all variables except those in M |
---|
156 | " |
---|
157 | {int i; |
---|
158 | intvec V,Vt; |
---|
159 | V = M[(1..nrows(M)),1]; |
---|
160 | for (i = 1; i <= size(V); i++) {if (isInVec(i,V) == 0) {Vt = Vt,i;}} |
---|
161 | if (Vt == 0) {intmat S; return(S);} |
---|
162 | else {Vt = Vt[2..size(Vt)]; intmat S [size(Vt)][1]; S[1..size(Vt),1] = Vt; return(S);} |
---|
163 | } |
---|
164 | |
---|
165 | static proc entryViolation(intmat M, int n) |
---|
166 | "PURPOSE:checks, if all entries in M are variable-related |
---|
167 | " |
---|
168 | {int i,j; |
---|
169 | for (i = 1; i <= nrows(M); i++) |
---|
170 | {for (j = 1; j <= ncols(M); j++) |
---|
171 | {if(!((1<=M[i,j])&&(M[i,j]<=n))) {return(1);}} |
---|
172 | } |
---|
173 | return(0); |
---|
174 | } |
---|
175 | |
---|
176 | static proc findDimen(intvec V, int n, list L, intvec P, list #) |
---|
177 | "USAGE: findDimen(V,n,L,P,degbound); V,P intvecs, n, an integer, L a list, |
---|
178 | @* degbound an optional integer |
---|
179 | RETURN: An integer |
---|
180 | PURPOSE:Computing the K-dimension of the quotient algebra |
---|
181 | " |
---|
182 | {int degbound = 0; |
---|
183 | if (size(#) > 0) {if (#[1] > 0) {degbound = #[1];}} |
---|
184 | int dimen,i,j,w,it; |
---|
185 | intvec Vt,Vt2; |
---|
186 | module M; |
---|
187 | if (degbound == 0) |
---|
188 | {for (i = 1; i <= n; i++) |
---|
189 | {Vt = V, i; w = 0; |
---|
190 | for (j = 1; j<= size(P); j++) |
---|
191 | {if (P[j] <= size(Vt)) |
---|
192 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
193 | if (isInMat(Vt2,L[j]) > 0) {w = 1; break;} |
---|
194 | } |
---|
195 | } |
---|
196 | if (w == 0) |
---|
197 | {vector Vtt; |
---|
198 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
199 | M = M,Vtt; |
---|
200 | kill Vtt; |
---|
201 | } |
---|
202 | } |
---|
203 | if (size(M) == 0) {return(0);} |
---|
204 | else |
---|
205 | {M = simplify(M,2); |
---|
206 | for (i = 1; i <= size(M); i++) |
---|
207 | {kill Vt; intvec Vt; |
---|
208 | for (j =1; j <= size(M[i]); j++){Vt[j] = int(leadcoef(M[i][j]));} |
---|
209 | dimen = dimen + 1 + findDimen(Vt,n,L,P); |
---|
210 | } |
---|
211 | return(dimen); |
---|
212 | } |
---|
213 | } |
---|
214 | else |
---|
215 | {if (size(V) > degbound) {ERROR("monomial exceeds degreebound");} |
---|
216 | if (size(V) == degbound) {return(0);} |
---|
217 | for (i = 1; i <= n; i++) |
---|
218 | {Vt = V, i; w = 0; |
---|
219 | for (j = 1; j<= size(P); j++) |
---|
220 | {if (P[j] <= size(Vt)) |
---|
221 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
222 | if (isInMat(Vt2,L[j]) > 0) {w = 1; break;} |
---|
223 | } |
---|
224 | } |
---|
225 | if (w == 0) {vector Vtt; |
---|
226 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
227 | M = M,Vtt; |
---|
228 | kill Vtt; |
---|
229 | } |
---|
230 | } |
---|
231 | if (size(M) == 0) {return(0);} |
---|
232 | else |
---|
233 | {M = simplify(M,2); |
---|
234 | for (i = 1; i <= size(M); i++) |
---|
235 | {kill Vt; intvec Vt; |
---|
236 | for (j =1; j <= size(M[i]); j++){Vt[j] = int(leadcoef(M[i][j]));} |
---|
237 | dimen = dimen + 1 + findDimen(Vt,n,L,P,degbound); |
---|
238 | } |
---|
239 | return(dimen); |
---|
240 | } |
---|
241 | } |
---|
242 | } |
---|
243 | |
---|
244 | static proc findCycle(intvec V, list L, intvec P, int n, int ld, module M) |
---|
245 | "USAGE: |
---|
246 | RETURN: 1, if Ufn-graph contains a cycle, or 0 otherwise |
---|
247 | PURPOSE:Searching the Ufnarovskij graph for cycles |
---|
248 | " |
---|
249 | {int i,j,w,r;intvec Vt,Vt2; |
---|
250 | int it, it2; |
---|
251 | if (size(V) < ld) |
---|
252 | {for (i = 1; i <= n; i++) |
---|
253 | {Vt = V,i; w = 0; |
---|
254 | for (j = 1; j <= size(P); j++) |
---|
255 | {if (P[j] <= size(Vt)) |
---|
256 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
257 | if (isInMat(Vt2,L[j]) > 0) |
---|
258 | {w = 1; break;} |
---|
259 | } |
---|
260 | } |
---|
261 | if (w == 0) {r = findCycle(Vt,L,P,n,ld,M);} |
---|
262 | if (r == 1) {break;} |
---|
263 | } |
---|
264 | return(r); |
---|
265 | } |
---|
266 | else |
---|
267 | {j = size(M); |
---|
268 | if (j > 0) |
---|
269 | { |
---|
270 | intmat Mt[j][nrows(M)]; |
---|
271 | for (it = 1; it <= j; it++) |
---|
272 | { for(it2 = 1; it2 <= nrows(M);it2++) |
---|
273 | {Mt[it,it2] = int(leadcoef(M[it2,it]));} |
---|
274 | } |
---|
275 | Vt = V[(size(V)-ld+1)..size(V)]; |
---|
276 | //Mt; type(Mt);Vt;type(Vt); |
---|
277 | if (isInMat(Vt,Mt) > 0) {return(1);} |
---|
278 | else |
---|
279 | {vector Vtt; |
---|
280 | for (it =1; it <= size(Vt); it++) |
---|
281 | {Vtt = Vtt + Vt[it]*gen(it);} |
---|
282 | M = M,Vtt; |
---|
283 | kill Vtt; |
---|
284 | for (i = 1; i <= n; i++) |
---|
285 | {Vt = V,i; w = 0; |
---|
286 | for (j = 1; j <= size(P); j++) |
---|
287 | {if (P[j] <= size(Vt)) |
---|
288 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
289 | //L[j]; type(L[j]);Vt2;type(Vt2); |
---|
290 | if (isInMat(Vt2,L[j]) > 0) |
---|
291 | {w = 1; break;} |
---|
292 | } |
---|
293 | } |
---|
294 | if (w == 0) {r = findCycle(Vt,L,P,n,ld,M);} |
---|
295 | if (r == 1) {break;} |
---|
296 | } |
---|
297 | return(r); |
---|
298 | } |
---|
299 | } |
---|
300 | else |
---|
301 | { Vt = V[(size(V)-ld+1)..size(V)]; |
---|
302 | vector Vtt; |
---|
303 | for (it = 1; it <= size(Vt); it++) |
---|
304 | {Vtt = Vtt + Vt[it]*gen(it);} |
---|
305 | M = Vtt; |
---|
306 | kill Vtt; |
---|
307 | for (i = 1; i <= n; i++) |
---|
308 | {Vt = V,i; w = 0; |
---|
309 | for (j = 1; j <= size(P); j++) |
---|
310 | {if (P[j] <= size(Vt)) |
---|
311 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
312 | //L[j]; type(L[j]);Vt2;type(Vt2); |
---|
313 | if (isInMat(Vt2,L[j]) > 0) |
---|
314 | {w = 1; break;} |
---|
315 | } |
---|
316 | } |
---|
317 | if (w == 0) {r = findCycle(Vt,L,P,n,ld,M);} |
---|
318 | if (r == 1) {break;} |
---|
319 | } |
---|
320 | return(r); |
---|
321 | } |
---|
322 | } |
---|
323 | } |
---|
324 | |
---|
325 | static proc findHCoeff(intvec V,int n,list L,intvec P,intvec H,list #) |
---|
326 | "USAGE: findHCoeff(V,n,L,P,H,degbound); L a list of intmats, degbound an integer |
---|
327 | RETURN: An intvec |
---|
328 | PURPOSE:Computing the coefficient of the Hilbert series (upto degree degbound) |
---|
329 | NOTE: Starting with a part of the Hilbert series we change the coefficient |
---|
330 | @* depending on how many baseelements we found on the actual branch |
---|
331 | " |
---|
332 | {int degbound = 0; |
---|
333 | if (size(#) > 0){if (#[1] > 0){degbound = #[1];}} |
---|
334 | int i,w,j,it; |
---|
335 | int h1 = 0; |
---|
336 | intvec Vt,Vt2,H1; |
---|
337 | module M; |
---|
338 | if (degbound == 0) |
---|
339 | {for (i = 1; i <= n; i++) |
---|
340 | {Vt = V, i; w = 0; |
---|
341 | for (j = 1; j<= size(P); j++) |
---|
342 | {if (P[j] <= size(Vt)) |
---|
343 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
344 | if (isInMat(Vt2,L[j]) > 0) {w = 1; break;} |
---|
345 | } |
---|
346 | } |
---|
347 | if (w == 0) |
---|
348 | {vector Vtt; |
---|
349 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
350 | M = M,Vtt; |
---|
351 | kill Vtt; |
---|
352 | } |
---|
353 | } |
---|
354 | if (size(M) == 0) {return(H);} |
---|
355 | else |
---|
356 | {M = simplify(M,2); |
---|
357 | for (i = 1; i <= size(M); i++) |
---|
358 | {kill Vt; intvec Vt; |
---|
359 | for (j =1; j <= size(M[i]); j++) {Vt[j] = int(leadcoef(M[i][j]));} |
---|
360 | h1 = h1 + 1; H1 = findHCoeff(Vt,n,L,P,H1); |
---|
361 | } |
---|
362 | if (size(H1) < (size(V)+2)) {H1[(size(V)+2)] = h1;} |
---|
363 | else {H1[(size(V)+2)] = H1[(size(V)+2)] + h1;} |
---|
364 | H1 = H1 + H; |
---|
365 | return(H1); |
---|
366 | } |
---|
367 | } |
---|
368 | else |
---|
369 | {if (size(V) > degbound) {ERROR("monomial exceeds degreebound");} |
---|
370 | if (size(V) == degbound) {return(H);} |
---|
371 | for (i = 1; i <= n; i++) |
---|
372 | {Vt = V, i; w = 0; |
---|
373 | for (j = 1; j<= size(P); j++) |
---|
374 | {if (P[j] <= size(Vt)) |
---|
375 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
376 | if (isInMat(Vt2,L[j]) > 0) {w = 1; break;} |
---|
377 | } |
---|
378 | } |
---|
379 | if (w == 0) |
---|
380 | {vector Vtt; |
---|
381 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
382 | M = M,Vtt; |
---|
383 | kill Vtt; |
---|
384 | } |
---|
385 | } |
---|
386 | if (size(M) == 0) {return(H);} |
---|
387 | else |
---|
388 | {M = simplify(M,2); |
---|
389 | for (i = 1; i <= size(M); i++) |
---|
390 | {kill Vt; intvec Vt; |
---|
391 | for (j =1; j <= size(M[i]); j++) |
---|
392 | {Vt[j] = int(leadcoef(M[i][j]));} |
---|
393 | h1 = h1 + 1; H1 = findHCoeff(Vt,n,L,P,H1,degbound); |
---|
394 | } |
---|
395 | if (size(H1) < (size(V)+2)) { H1[(size(V)+2)] = h1;} |
---|
396 | else {H1[(size(V)+2)] = H1[(size(V)+2)] + h1;} |
---|
397 | H1 = H1 + H; |
---|
398 | return(H1); |
---|
399 | } |
---|
400 | } |
---|
401 | } |
---|
402 | |
---|
403 | static proc findHCoeffMis(intvec V, int n, list L, intvec P, list R,list #) |
---|
404 | "USAGE: findHCoeffMis(V,n,L,P,R,degbound); degbound an optional integer, L a |
---|
405 | @* list of Intmats, R |
---|
406 | RETURN: A list |
---|
407 | PURPOSE:Computing the coefficients of the Hilbert series and the Mistletoes all |
---|
408 | @* at once |
---|
409 | " |
---|
410 | {int degbound = 0; |
---|
411 | if (size(#) > 0) {if (#[1] > 0) {degbound = #[1];}} |
---|
412 | int i,w,j,h1; |
---|
413 | intvec Vt,Vt2,H1; int it; |
---|
414 | module M; |
---|
415 | if (degbound == 0) |
---|
416 | {for (i = 1; i <= n; i++) |
---|
417 | {Vt = V, i; w = 0; |
---|
418 | for (j = 1; j<= size(P); j++) |
---|
419 | {if (P[j] <= size(Vt)) |
---|
420 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
421 | if (isInMat(Vt2,L[j]) > 0) {w = 1; break;} |
---|
422 | } |
---|
423 | } |
---|
424 | if (w == 0) |
---|
425 | {vector Vtt; |
---|
426 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
427 | M = M,Vtt; |
---|
428 | kill Vtt; |
---|
429 | } |
---|
430 | } |
---|
431 | if (size(M) == 0) {if (size(R) < 2){R[2] = list(V);} else {R[2] = R[2] + list(V);} return(R);} |
---|
432 | else |
---|
433 | {M = simplify(M,2); |
---|
434 | for (i = 1; i <= size(M); i++) |
---|
435 | {kill Vt; intvec Vt; |
---|
436 | for (j =1; j <= size(M[i]); j++) |
---|
437 | {Vt[j] = int(leadcoef(M[i][j]));} |
---|
438 | if (size(R[1]) < (size(V)+2)) { R[1][(size(V)+2)] = 1;} |
---|
439 | else |
---|
440 | {R[1][(size(V)+2)] = R[1][(size(V)+2)] + 1;} |
---|
441 | R = findHCoeffMis(Vt,n,L,P,R); |
---|
442 | } |
---|
443 | return(R); |
---|
444 | } |
---|
445 | } |
---|
446 | else |
---|
447 | {if (size(V) > degbound) {ERROR("monomial exceeds degreebound");} |
---|
448 | if (size(V) == degbound) |
---|
449 | {if (size(R) < 2){R[2] = list (V);} |
---|
450 | else{R[2] = R[2] + list (V);} |
---|
451 | return(R); |
---|
452 | } |
---|
453 | for (i = 1; i <= n; i++) |
---|
454 | {Vt = V, i; w = 0; |
---|
455 | for (j = 1; j<= size(P); j++) |
---|
456 | {if (P[j] <= size(Vt)) |
---|
457 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
458 | if (isInMat(Vt2,L[j]) > 0) {w = 1; break;} |
---|
459 | } |
---|
460 | } |
---|
461 | if (w == 0) |
---|
462 | {vector Vtt; |
---|
463 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
464 | M = M,Vtt; |
---|
465 | kill Vtt; |
---|
466 | } |
---|
467 | } |
---|
468 | if (size(M) == 0) {if (size(R) < 2){R[2] = list(V);} else {R[2] = R[2] + list(V);} return(R);} |
---|
469 | else |
---|
470 | {M = simplify(M,2); |
---|
471 | for (i = 1; i <= ncols(M); i++) |
---|
472 | {kill Vt; intvec Vt; |
---|
473 | for (j =1; j <= size(M[i]); j++) |
---|
474 | {Vt[j] = int(leadcoef(M[i][j]));} |
---|
475 | if (size(R[1]) < (size(V)+2)) { R[1][(size(V)+2)] = 1;} |
---|
476 | else |
---|
477 | {R[1][(size(V)+2)] = R[1][(size(V)+2)] + 1;} |
---|
478 | R = findHCoeffMis(Vt,n,L,P,R,degbound); |
---|
479 | } |
---|
480 | return(R); |
---|
481 | } |
---|
482 | } |
---|
483 | } |
---|
484 | |
---|
485 | |
---|
486 | static proc findMisDim(intvec V,int n,list L,intvec P,list R,list #) |
---|
487 | "USAGE: |
---|
488 | RETURN: A list |
---|
489 | PURPOSE:Computing the K-dimension and the Mistletoes all at once |
---|
490 | " |
---|
491 | {int degbound = 0; |
---|
492 | if (size(#) > 0) {if (#[1] > 0) {degbound = #[1];}} |
---|
493 | int dimen,i,j,w; |
---|
494 | intvec Vt,Vt2; int it; |
---|
495 | module M; |
---|
496 | if (degbound == 0) |
---|
497 | {for (i = 1; i <= n; i++) |
---|
498 | {Vt = V, i; w = 0; |
---|
499 | for (j = 1; j<= size(P); j++) |
---|
500 | {if (P[j] <= size(Vt)) |
---|
501 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
502 | if (isInMat(Vt2,L[j]) > 0) {w = 1; break;} |
---|
503 | } |
---|
504 | } |
---|
505 | if (w == 0) |
---|
506 | {vector Vtt; |
---|
507 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
508 | M = M,Vtt; |
---|
509 | kill Vtt; |
---|
510 | } |
---|
511 | } |
---|
512 | if (size(M) == 0) |
---|
513 | {if (size(R) < 2){R[2] = list (V);} |
---|
514 | else{R[2] = R[2] + list(V);} |
---|
515 | return(R); |
---|
516 | } |
---|
517 | else |
---|
518 | {M = simplify(M,2); |
---|
519 | for (i = 1; i <= size(M); i++) |
---|
520 | {kill Vt; intvec Vt; |
---|
521 | for (j =1; j <= size(M[i]); j++){Vt[j] = int(leadcoef(M[i][j]));} |
---|
522 | R[1] = R[1] + 1; R = findMisDim(Vt,n,L,P,R); |
---|
523 | } |
---|
524 | return(R); |
---|
525 | } |
---|
526 | } |
---|
527 | else |
---|
528 | {if (size(V) > degbound) {ERROR("monomial exceeds degreebound");} |
---|
529 | if (size(V) == degbound) |
---|
530 | {if (size(R) < 2){R[2] = list (V);} |
---|
531 | else{R[2] = R[2] + list (V);} |
---|
532 | return(R); |
---|
533 | } |
---|
534 | for (i = 1; i <= n; i++) |
---|
535 | {Vt = V, i; w = 0; |
---|
536 | for (j = 1; j<= size(P); j++) |
---|
537 | {if (P[j] <= size(Vt)) |
---|
538 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
539 | if (isInMat(Vt2,L[j]) > 0) {w = 1; break;} |
---|
540 | } |
---|
541 | } |
---|
542 | if (w == 0) |
---|
543 | {vector Vtt; |
---|
544 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
545 | M = M,Vtt; |
---|
546 | kill Vtt; |
---|
547 | } |
---|
548 | } |
---|
549 | if (size(M) == 0) |
---|
550 | {if (size(R) < 2){R[2] = list (V);} |
---|
551 | else{R[2] = R[2] + list(V);} |
---|
552 | return(R); |
---|
553 | } |
---|
554 | else |
---|
555 | {M = simplify(M,2); |
---|
556 | for (i = 1; i <= size(M); i++) |
---|
557 | {kill Vt; intvec Vt; |
---|
558 | for (j =1; j <= size(M[i]); j++){Vt[j] = int(leadcoef(M[i][j]));} |
---|
559 | R[1] = R[1] + 1; R = findMisDim(Vt,n,L,P,R,degbound); |
---|
560 | } |
---|
561 | return(R); |
---|
562 | |
---|
563 | } |
---|
564 | } |
---|
565 | } |
---|
566 | |
---|
567 | |
---|
568 | static proc findmistletoes(intvec V, int n, list L, intvec P, list #) |
---|
569 | "USAGE: findmistletoes(V,n,L,P,degbound); V a normal word, n the number of |
---|
570 | @* variables, L the GB, P the occuring degrees, |
---|
571 | @* and degbound the (optional) degreebound |
---|
572 | RETURN: A list |
---|
573 | PURPOSE:Computing mistletoes starting in V |
---|
574 | NOTE: V has to be normal w.r.t. L, it will not be checked for being so |
---|
575 | " |
---|
576 | {int degbound = 0; |
---|
577 | if (size(#) > 0) {if (#[1] > 0) {degbound = #[1];}} |
---|
578 | list R; intvec Vt,Vt2; int it; |
---|
579 | int i,j; |
---|
580 | module M; |
---|
581 | if (degbound == 0) |
---|
582 | {int w; |
---|
583 | for (i = 1; i <= n; i++) |
---|
584 | {Vt = V,i; w = 0; |
---|
585 | for (j = 1; j <= size(P); j++) |
---|
586 | {if (P[j] <= size(Vt)) |
---|
587 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
588 | if (isInMat(Vt2,L[j]) > 0) |
---|
589 | {w = 1; break;} |
---|
590 | } |
---|
591 | } |
---|
592 | if (w == 0) |
---|
593 | {vector Vtt; |
---|
594 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
595 | M = M,Vtt; |
---|
596 | kill Vtt; |
---|
597 | } |
---|
598 | } |
---|
599 | if (size(M)==0) {R = V; return(R);} |
---|
600 | else |
---|
601 | {M = simplify(M,2); |
---|
602 | for (i = 1; i <= size(M); i++) |
---|
603 | {kill Vt; intvec Vt; |
---|
604 | for (j =1; j <= size(M[i]); j++){Vt[j] = int(leadcoef(M[i][j]));} |
---|
605 | R = R + findmistletoes(Vt,n,L,P); |
---|
606 | } |
---|
607 | return(R); |
---|
608 | } |
---|
609 | } |
---|
610 | else |
---|
611 | {if (size(V) > degbound) {ERROR("monomial exceeds degreebound");} |
---|
612 | if (size(V) == degbound) {R = V; return(R);} |
---|
613 | int w; |
---|
614 | for (i = 1; i <= n; i++) |
---|
615 | {Vt = V,i; w = 0; |
---|
616 | for (j = 1; j <= size(P); j++) |
---|
617 | {if (P[j] <= size(Vt)) |
---|
618 | {Vt2 = Vt[(size(Vt)-P[j]+1)..size(Vt)]; |
---|
619 | if (isInMat(Vt2,L[j]) > 0){w = 1; break;} |
---|
620 | } |
---|
621 | } |
---|
622 | if (w == 0) |
---|
623 | {vector Vtt; |
---|
624 | for (it = 1; it <= size(Vt); it++){Vtt = Vtt + Vt[it]*gen(it);} |
---|
625 | M = M,Vtt; |
---|
626 | kill Vtt; |
---|
627 | } |
---|
628 | } |
---|
629 | if (size(M) == 0) {R = V; return(R);} |
---|
630 | else |
---|
631 | {M = simplify(M,2); |
---|
632 | for (i = 1; i <= ncols(M); i++) |
---|
633 | {kill Vt; intvec Vt; |
---|
634 | for (j =1; j <= size(M[i]); j++) |
---|
635 | {Vt[j] = int(leadcoef(M[i][j]));} |
---|
636 | //Vt; typeof(Vt); size(Vt); |
---|
637 | R = R + findmistletoes(Vt,n,L,P,degbound); |
---|
638 | } |
---|
639 | return(R); |
---|
640 | } |
---|
641 | } |
---|
642 | } |
---|
643 | |
---|
644 | static proc isInList(intvec V, list L) |
---|
645 | "USAGE: isInList(V,L); V an intvec, L a list of intvecs |
---|
646 | RETURN: An integer |
---|
647 | PURPOSE:Finding the position of V in L, returns 0, if V is not in M |
---|
648 | " |
---|
649 | {int i,n; |
---|
650 | n = 0; |
---|
651 | for (i = 1; i <= size(L); i++) {if (L[i] == V) {n = i; break;}} |
---|
652 | return(n); |
---|
653 | } |
---|
654 | |
---|
655 | static proc isInMat(intvec V, intmat M) |
---|
656 | "USAGE: isInMat(V,M);V an intvec, M an intmat |
---|
657 | RETURN: An integer |
---|
658 | PURPOSE:Finding the position of V in M, returns 0, if V is not in M |
---|
659 | " |
---|
660 | {if (size(V) <> ncols(M)) {return(0);} |
---|
661 | int i; |
---|
662 | intvec Vt; |
---|
663 | for (i = 1; i <= nrows(M); i++) |
---|
664 | {Vt = M[i,1..ncols(M)]; |
---|
665 | if ((V-Vt) == 0){return(i);} |
---|
666 | } |
---|
667 | return(0); |
---|
668 | } |
---|
669 | |
---|
670 | static proc isInVec(int v,intvec V) |
---|
671 | "USAGE: isInVec(v,V); v an integer,V an intvec |
---|
672 | RETURN: An integer |
---|
673 | PURPOSE:Finding the position of v in V, returns 0, if v is not in V |
---|
674 | " |
---|
675 | {int i,n; |
---|
676 | n = 0; |
---|
677 | for (i = 1; i <= size(V); i++) {if (V[i] == v) {n = i; break;}} |
---|
678 | return(n); |
---|
679 | } |
---|
680 | |
---|
681 | proc ivL2lpI(list L) |
---|
682 | "USAGE: ivL2lpI(L); L a list of intvecs |
---|
683 | RETURN: ideal |
---|
684 | PURPOSE:Transforming a list of intvecs into an ideal of Letterplace monomials |
---|
685 | ASSUME: - Intvec corresponds to a Letterplace monomial |
---|
686 | @* - basering has to be a Letterplace ring |
---|
687 | EXAMPLE: example ivL2lpI; shows examples |
---|
688 | " |
---|
689 | {checkAssumptions(0,L); |
---|
690 | int i; ideal G; |
---|
691 | poly p; |
---|
692 | for (i = 1; i <= size(L); i++) |
---|
693 | {p = iv2lp(L[i]); |
---|
694 | G[(size(G) + 1)] = p; |
---|
695 | } |
---|
696 | return(G); |
---|
697 | } |
---|
698 | example |
---|
699 | { |
---|
700 | "EXAMPLE:"; echo = 2; |
---|
701 | ring r = 0,(x,y,z),dp; |
---|
702 | def R = makeLetterplaceRing(5);// constructs a Letterplace ring |
---|
703 | setring R; //sets basering to Letterplace ring |
---|
704 | intvec u = 1,1,2; intvec v = 2,1,3; intvec w = 3,1,1; |
---|
705 | // u = x^2y, v = yxz, w = zx^2 in intvec representation |
---|
706 | list L = u,v,w; |
---|
707 | ivL2lpI(L);// invokes the procedure, returns the ideal containing u,v,w |
---|
708 | } |
---|
709 | |
---|
710 | proc iv2lp(intvec I) |
---|
711 | "USAGE: iv2lp(I); I an intvec |
---|
712 | RETURN: poly |
---|
713 | PURPOSE:Transforming an intvec into the corresponding Letterplace polynomial |
---|
714 | ASSUME: - Intvec corresponds to a Letterplace monomial |
---|
715 | @* - basering has to be a Letterplace ring |
---|
716 | NOTE: - Assumptions will not be checked! |
---|
717 | EXAMPLE: example iv2lp; shows examples |
---|
718 | " |
---|
719 | {if (I[1] == 0) {return(1);} |
---|
720 | int i = size(I); |
---|
721 | if (i > attrib(basering,"uptodeg")) {ERROR("polynomial exceeds degreebound");} |
---|
722 | int j; poly p = 1; |
---|
723 | for (j = 1; j <= i; j++) {if (I[j] > 0) { p = lpMult(p,var(I[j]));}} //ignore zeroes, because they correspond to 1 |
---|
724 | return(p); |
---|
725 | } |
---|
726 | example |
---|
727 | { |
---|
728 | "EXAMPLE:"; echo = 2; |
---|
729 | ring r = 0,(x,y,z),dp; |
---|
730 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
731 | setring R; //sets basering to Letterplace ring |
---|
732 | intvec u = 1,1,2; intvec v = 2,1,3; intvec w = 3,1,1; |
---|
733 | // u = x^2y, v = yxz, w = zx^2 in intvec representation |
---|
734 | iv2lp(u); // invokes the procedure and returns the corresponding poly |
---|
735 | iv2lp(v); |
---|
736 | iv2lp(w); |
---|
737 | } |
---|
738 | |
---|
739 | proc iv2lpList(list L) |
---|
740 | "USAGE: iv2lpList(L); L a list of intmats |
---|
741 | RETURN: ideal |
---|
742 | PURPOSE:Converting a list of intmats into an ideal of corresponding monomials |
---|
743 | ASSUME: - The rows of each intmat in L must correspond to a Letterplace monomial |
---|
744 | @* - basering has to be a Letterplace ring |
---|
745 | EXAMPLE: example iv2lpList; shows examples |
---|
746 | " |
---|
747 | {checkAssumptions(0,L); |
---|
748 | ideal G; |
---|
749 | int i; |
---|
750 | for (i = 1; i <= size(L); i++){G = G + iv2lpMat(L[i]);} |
---|
751 | return(G); |
---|
752 | } |
---|
753 | example |
---|
754 | { |
---|
755 | "EXAMPLE:"; echo = 2; |
---|
756 | ring r = 0,(x,y,z),dp; |
---|
757 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
758 | setring R; // sets basering to Letterplace ring |
---|
759 | intmat u[3][1] = 1,1,2; intmat v[1][3] = 2,1,3; intmat w[2][3] = 3,1,1,2,3,1; |
---|
760 | // defines intmats of different size containing intvec representations of |
---|
761 | // monomials as rows |
---|
762 | list L = u,v,w; |
---|
763 | print(u); print(v); print(w); // shows the intmats contained in L |
---|
764 | iv2lpList(L); // returns the corresponding monomials as an ideal |
---|
765 | } |
---|
766 | |
---|
767 | |
---|
768 | proc iv2lpMat(intmat M) |
---|
769 | "USAGE: iv2lpMat(M); M an intmat |
---|
770 | RETURN: ideal |
---|
771 | PURPOSE:Converting an intmat into an ideal of the corresponding monomials |
---|
772 | ASSUME: - The rows of M must correspond to Letterplace monomials |
---|
773 | @* - basering has to be a Letterplace ring |
---|
774 | EXAMPLE: example iv2lpMat; shows examples |
---|
775 | " |
---|
776 | {list L = M; |
---|
777 | checkAssumptions(0,L); |
---|
778 | kill L; |
---|
779 | ideal G; poly p; |
---|
780 | int i; intvec I; |
---|
781 | for (i = 1; i <= nrows(M); i++) |
---|
782 | { I = M[i,1..ncols(M)]; |
---|
783 | p = iv2lp(I); |
---|
784 | G[size(G)+1] = p; |
---|
785 | } |
---|
786 | return(G); |
---|
787 | } |
---|
788 | example |
---|
789 | { |
---|
790 | "EXAMPLE:"; echo = 2; |
---|
791 | ring r = 0,(x,y,z),dp; |
---|
792 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
793 | setring R; // sets basering to Letterplace ring |
---|
794 | intmat u[3][1] = 1,1,2; intmat v[1][3] = 2,1,3; intmat w[2][3] = 3,1,1,2,3,1; |
---|
795 | // defines intmats of different size containing intvec representations of |
---|
796 | // monomials as rows |
---|
797 | iv2lpMat(u); // returns the monomials contained in u |
---|
798 | iv2lpMat(v); // returns the monomials contained in v |
---|
799 | iv2lpMat(w); // returns the monomials contained in w |
---|
800 | } |
---|
801 | |
---|
802 | proc lpId2ivLi(ideal G) |
---|
803 | "USAGE: lpId2ivLi(G); G an ideal |
---|
804 | RETURN: list |
---|
805 | PURPOSE:Transforming an ideal into the corresponding list of intvecs |
---|
806 | ASSUME: - basering has to be a Letterplace ring |
---|
807 | EXAMPLE: example lpId2ivLi; shows examples |
---|
808 | " |
---|
809 | {int i,j,k; |
---|
810 | list M; |
---|
811 | checkAssumptions(0,M); |
---|
812 | for (i = 1; i <= size(G); i++) {M[i] = lp2iv(G[i]);} |
---|
813 | return(M); |
---|
814 | } |
---|
815 | example |
---|
816 | { |
---|
817 | "EXAMPLE:"; echo = 2; |
---|
818 | ring r = 0,(x,y),dp; |
---|
819 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
820 | setring R; // sets basering to Letterplace ring |
---|
821 | ideal L = x(1)*x(2),y(1)*y(2),x(1)*y(2)*x(3); |
---|
822 | lpId2ivLi(L); // returns the corresponding intvecs as a list |
---|
823 | } |
---|
824 | |
---|
825 | proc lp2iv(poly p) |
---|
826 | "USAGE: lp2iv(p); p a poly |
---|
827 | RETURN: intvec |
---|
828 | PURPOSE:Transforming a monomial into the corresponding intvec |
---|
829 | ASSUME: - basering has to be a Letterplace ring |
---|
830 | NOTE: - Assumptions will not be checked! |
---|
831 | EXAMPLE: example lp2iv; shows examples |
---|
832 | " |
---|
833 | {p = normalize(lead(p)); |
---|
834 | intvec I; |
---|
835 | int i,j; |
---|
836 | if (deg(p) > attrib(basering,"uptodeg")) {ERROR("Monomial exceeds degreebound");} |
---|
837 | if (p == 1) {return(I);} |
---|
838 | if (p == 0) {ERROR("Monomial is not allowed to equal zero");} |
---|
839 | intvec lep = leadexp(p); |
---|
840 | for ( i = 1; i <= attrib(basering,"lV"); i++) {if (lep[i] == 1) {I = i; break;}} |
---|
841 | for (i = (attrib(basering,"lV")+1); i <= size(lep); i++) |
---|
842 | {if (lep[i] == 1) |
---|
843 | { j = (i mod attrib(basering,"lV")); |
---|
844 | if (j == 0) {I = I,attrib(basering,"lV");} |
---|
845 | else {I = I,j;} |
---|
846 | } |
---|
847 | else { if (lep[i] > 1) {ERROR("monomial has a not allowed multidegree");}} |
---|
848 | } |
---|
849 | if (I[1] == 0) {ERROR("monomial has a not allowed multidegree");} |
---|
850 | |
---|
851 | return(I); |
---|
852 | } |
---|
853 | example |
---|
854 | { |
---|
855 | "EXAMPLE:"; echo = 2; |
---|
856 | ring r = 0,(x,y,z),dp; |
---|
857 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
858 | setring R; // sets basering to Letterplace ring |
---|
859 | poly p = x(1)*x(2)*z(3); poly q = y(1)*y(2)*x(3)*x(4); |
---|
860 | poly w= z(1)*y(2)*x(3)*z(4)*z(5); |
---|
861 | // p,q,w are some polynomials we want to transform into their |
---|
862 | // intvec representation |
---|
863 | lp2iv(p); lp2iv(q); lp2iv(w); |
---|
864 | } |
---|
865 | |
---|
866 | proc lp2ivId(ideal G) |
---|
867 | "USAGE: lp2ivId(G); G an ideal |
---|
868 | RETURN: list |
---|
869 | PURPOSE:Converting an ideal into an list of intmats, |
---|
870 | @* the corresponding intvecs forming the rows |
---|
871 | ASSUME: - basering has to be a Letterplace ring |
---|
872 | EXAMPLE: example lp2ivId; shows examples |
---|
873 | " |
---|
874 | {G = normalize(lead(G)); |
---|
875 | intvec I; list L; |
---|
876 | checkAssumptions(0,L); |
---|
877 | int i,md; |
---|
878 | for (i = 1; i <= size(G); i++) { if (md <= deg(G[i])) {md = deg(G[i]);}} |
---|
879 | while (size(G) > 0) |
---|
880 | {ideal Gt; |
---|
881 | for (i = 1; i <= ncols(G); i++) {if (md == deg(G[i])) {Gt = Gt + G[i]; G[i] = 0;}} |
---|
882 | if (size(Gt) > 0) |
---|
883 | {G = simplify(G,2); |
---|
884 | intmat M [size(Gt)][md]; |
---|
885 | for (i = 1; i <= size(Gt); i++) {M[i,1..md] = lp2iv(Gt[i]);} |
---|
886 | L = insert(L,M); |
---|
887 | kill M; kill Gt; |
---|
888 | md = md - 1; |
---|
889 | } |
---|
890 | else {kill Gt; md = md - 1;} |
---|
891 | } |
---|
892 | return(L); |
---|
893 | } |
---|
894 | example |
---|
895 | { |
---|
896 | "EXAMPLE:"; echo = 2; |
---|
897 | ring r = 0,(x,y,z),dp; |
---|
898 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
899 | setring R; // sets basering to Letterplace ring |
---|
900 | poly p = x(1)*x(2)*z(3); poly q = y(1)*y(2)*x(3)*x(4); |
---|
901 | poly w = z(1)*y(2)*x(3)*z(4); |
---|
902 | // p,q,w are some polynomials we want to transform into their |
---|
903 | // intvec representation |
---|
904 | ideal G = p,q,w; |
---|
905 | // define the ideal containing p,q and w |
---|
906 | lp2ivId(G); // and return the list of intmats for this ideal |
---|
907 | } |
---|
908 | |
---|
909 | // -----------------main procedures---------------------- |
---|
910 | |
---|
911 | proc ivDHilbert(list L, int n, list #) |
---|
912 | "USAGE: ivDHilbert(L,n[,degbound]); L a list of intmats, n an integer, |
---|
913 | @* degbound an optional integer |
---|
914 | RETURN: list |
---|
915 | PURPOSE:Computing the K-dimension and the Hilbert series |
---|
916 | ASSUME: - basering is a Letterplace ring |
---|
917 | @* - all rows of each intmat correspond to a Letterplace monomial |
---|
918 | @* - if you specify a different degree bound degbound, |
---|
919 | @* degbound <= attrib(basering,uptodeg) holds |
---|
920 | NOTE: - If L is the list returned, then L[1] is an integer corresponding to the |
---|
921 | @* dimension, L[2] is an intvec which contains the coefficients of the |
---|
922 | @* Hilbert series |
---|
923 | @* - If degbound is set, there will be a degree bound added. By default there |
---|
924 | @* is no degree bound |
---|
925 | @* - n is the number of variables |
---|
926 | @* - If I = L[2] is the intvec returned, then I[k] is the (k-1)-th coefficient of |
---|
927 | @* the Hilbert series. |
---|
928 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
929 | EXAMPLE: example ivDHilbert; shows examples |
---|
930 | " |
---|
931 | {int degbound = 0; |
---|
932 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] > 0){degbound = #[1];}}} |
---|
933 | checkAssumptions(degbound,L); |
---|
934 | intvec H; int i,dimen; |
---|
935 | H = ivHilbert(L,n,degbound); |
---|
936 | for (i = 1; i <= size(H); i++){dimen = dimen + H[i];} |
---|
937 | L = dimen,H; |
---|
938 | return(L); |
---|
939 | } |
---|
940 | example |
---|
941 | { |
---|
942 | "EXAMPLE:"; echo = 2; |
---|
943 | ring r = 0,(x,y),dp; |
---|
944 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
945 | R; |
---|
946 | setring R; // sets basering to Letterplace ring |
---|
947 | //some intmats, which contain monomials in intvec representation as rows |
---|
948 | intmat I1 [2][2] = 1,1,2,2; intmat I2 [1][3] = 1,2,1; |
---|
949 | intmat J1 [1][2] = 1,1; intmat J2 [2][3] = 2,1,2,1,2,1; |
---|
950 | print(I1); |
---|
951 | print(I2); |
---|
952 | print(J1); |
---|
953 | print(J2); |
---|
954 | list G = I1,I2; // ideal, which is already a Groebner basis |
---|
955 | list I = J1,J2; // ideal, which is already a Groebner basis |
---|
956 | //the procedure without a degree bound |
---|
957 | ivDHilbert(G,2); |
---|
958 | // the procedure with degree bound 5 |
---|
959 | ivDHilbert(I,2,5); |
---|
960 | } |
---|
961 | |
---|
962 | proc ivDHilbertSickle(list L, int n, list #) |
---|
963 | "USAGE: ivDHilbertSickle(L,n[,degbound]); L a list of intmats, n an integer, |
---|
964 | @* degbound an optional integer |
---|
965 | RETURN: list |
---|
966 | PURPOSE:Computing K-dimension, Hilbert series and mistletoes |
---|
967 | ASSUME: - basering is a Letterplace ring. |
---|
968 | @* - All rows of each intmat correspond to a Letterplace monomial. |
---|
969 | @* - If you specify a different degree bound degbound, |
---|
970 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
971 | NOTE: - If L is the list returned, then L[1] is an intvec which contains the |
---|
972 | @* coefficients of the Hilbert series, L[2] is an integer and L[3] |
---|
973 | @* is a list, containing the mistletoes as intvecs. |
---|
974 | @* - If degbound is set, a degree bound will be added. By default there |
---|
975 | @* is no degree bound. |
---|
976 | @* - n is the number of variables. |
---|
977 | @* - If I = L[1] is the intvec returned, then I[k] is the (k-1)-th |
---|
978 | @* coefficient of the Hilbert series. |
---|
979 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
980 | EXAMPLE: example ivDHilbertSickle; shows examples |
---|
981 | " |
---|
982 | {int degbound = 0; |
---|
983 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] > 0){degbound = #[1];}}} |
---|
984 | checkAssumptions(degbound,L); |
---|
985 | int i,dimen; list R; |
---|
986 | R = ivSickleHil(L,n,degbound); |
---|
987 | for (i = 1; i <= size(R[1]); i++){dimen = dimen + R[1][i];} |
---|
988 | R[3] = R[2]; R[2] = dimen; |
---|
989 | return(R); |
---|
990 | } |
---|
991 | example |
---|
992 | { |
---|
993 | "EXAMPLE:"; echo = 2; |
---|
994 | ring r = 0,(x,y),dp; |
---|
995 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
996 | R; |
---|
997 | setring R; // sets basering to Letterplace ring |
---|
998 | //some intmats, which contain monomials in intvec representation as rows |
---|
999 | intmat I1 [2][2] = 1,1,2,2; intmat I2 [1][3] = 1,2,1; |
---|
1000 | intmat J1 [1][2] = 1,1; intmat J2 [2][3] = 2,1,2,1,2,1; |
---|
1001 | print(I1); |
---|
1002 | print(I2); |
---|
1003 | print(J1); |
---|
1004 | print(J2); |
---|
1005 | list G = I1,I2;// ideal, which is already a Groebner basis |
---|
1006 | list I = J1,J2; // ideal, which is already a Groebner basis |
---|
1007 | ivDHilbertSickle(G,2); // invokes the procedure without a degree bound |
---|
1008 | ivDHilbertSickle(I,2,3); // invokes the procedure with degree bound 3 |
---|
1009 | } |
---|
1010 | |
---|
1011 | proc ivDimCheck(list L, int n) |
---|
1012 | "USAGE: ivDimCheck(L,n); L a list of intmats, n an integer |
---|
1013 | RETURN: int, 0 if the dimension is finite, or 1 otherwise |
---|
1014 | PURPOSE:Decides, whether the K-dimension is finite or not |
---|
1015 | ASSUME: - basering is a Letterplace ring. |
---|
1016 | @* - All rows of each intmat correspond to a Letterplace monomial. |
---|
1017 | NOTE: - n is the number of variables. |
---|
1018 | EXAMPLE: example ivDimCheck; shows examples |
---|
1019 | " |
---|
1020 | {checkAssumptions(0,L); |
---|
1021 | int i,r; |
---|
1022 | intvec P,H; |
---|
1023 | for (i = 1; i <= size(L); i++) |
---|
1024 | {P[i] = ncols(L[i]); |
---|
1025 | if (P[i] == 1) {if (isInMat(H,L[i]) > 0) {ERROR("Quotient algebra is trivial");}} |
---|
1026 | } |
---|
1027 | if (size(L) == 0) {ERROR("GB is empty, quotient algebra corresponds to free algebra");} |
---|
1028 | kill H; |
---|
1029 | intmat S; int sd,ld; intvec V; |
---|
1030 | sd = P[1]; ld = P[1]; |
---|
1031 | for (i = 2; i <= size(P); i++) |
---|
1032 | {if (P[i] < sd) {sd = P[i];} |
---|
1033 | if (P[i] > ld) {ld = P[i];} |
---|
1034 | } |
---|
1035 | sd = (sd - 1); ld = ld - 1; |
---|
1036 | if (ld == 0) { return(allVars(L,P,n));} |
---|
1037 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1038 | else {S = createStartMat(sd,n);} |
---|
1039 | module M; |
---|
1040 | for (i = 1; i <= nrows(S); i++) |
---|
1041 | {V = S[i,1..ncols(S)]; |
---|
1042 | if (findCycle(V,L,P,n,ld,M)) {r = 1; break;} |
---|
1043 | } |
---|
1044 | return(r); |
---|
1045 | } |
---|
1046 | example |
---|
1047 | { |
---|
1048 | "EXAMPLE:"; echo = 2; |
---|
1049 | ring r = 0,(x,y),dp; |
---|
1050 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1051 | R; |
---|
1052 | setring R; // sets basering to Letterplace ring |
---|
1053 | //some intmats, which contain monomials in intvec representation as rows |
---|
1054 | intmat I1 [2][2] = 1,1,2,2; intmat I2 [1][3] = 1,2,1; |
---|
1055 | intmat J1 [1][2] = 1,1; intmat J2 [2][3] = 2,1,2,1,2,1; |
---|
1056 | print(I1); |
---|
1057 | print(I2); |
---|
1058 | print(J1); |
---|
1059 | print(J2); |
---|
1060 | list G = I1,I2;// ideal, which is already a Groebner basis |
---|
1061 | list I = J1,J2; // ideal, which is already a Groebner basis and which |
---|
1062 | ivDimCheck(G,2); // invokes the procedure, factor is of finite K-dimension |
---|
1063 | ivDimCheck(I,2); // invokes the procedure, factor is not of finite K-dimension |
---|
1064 | } |
---|
1065 | |
---|
1066 | proc ivHilbert(list L, int n, list #) |
---|
1067 | "USAGE: ivHilbert(L,n[,degbound]); L a list of intmats, n an integer, |
---|
1068 | @* degbound an optional integer |
---|
1069 | RETURN: An intvec, containing the coefficients of the Hilbert series |
---|
1070 | PURPOSE:Computing the Hilbert series |
---|
1071 | ASSUME: - basering is a Letterplace ring. |
---|
1072 | @* - all rows of each intmat correspond to a Letterplace monomial |
---|
1073 | @* - if you specify a different degree bound degbound, |
---|
1074 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1075 | NOTE: - If degbound is set, a degree bound will be added. By default there |
---|
1076 | @* is no degree bound. |
---|
1077 | @* - n is the number of variables. |
---|
1078 | @* - If I is returned, then I[k] is the (k-1)-th coefficient of the Hilbert |
---|
1079 | @* series. |
---|
1080 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1081 | EXAMPLE: example ivHilbert; shows examples |
---|
1082 | " |
---|
1083 | {int degbound = 0; |
---|
1084 | if (size(#) > 0) {if (typeof(#[1])=="int"){if (#[1] > 0) {degbound = #[1];}}} |
---|
1085 | intvec P,H; int i; |
---|
1086 | for (i = 1; i <= size(L); i++) |
---|
1087 | {P[i] = ncols(L[i]); |
---|
1088 | if (P[i] == 1) {if ( isInMat(H,L[i]) > 0) {ERROR("Quotient algebra is trivial");}} |
---|
1089 | } |
---|
1090 | if (size(L) == 0) {ERROR("GB is empty, quotient algebra corresponds to free algebra");} |
---|
1091 | H[1] = 1; |
---|
1092 | checkAssumptions(degbound,L); |
---|
1093 | if (degbound == 0) |
---|
1094 | {int sd; |
---|
1095 | intmat S; |
---|
1096 | sd = P[1]; |
---|
1097 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1098 | sd = (sd - 1); |
---|
1099 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1100 | else {S = createStartMat(sd,n);} |
---|
1101 | if (intvec(S) == 0) {return(H);} |
---|
1102 | for (i = 1; i <= sd; i++) {H = H,(n^i);} |
---|
1103 | for (i = 1; i <= nrows(S); i++) |
---|
1104 | {intvec St = S[i,1..ncols(S)]; |
---|
1105 | H = findHCoeff(St,n,L,P,H); |
---|
1106 | kill St; |
---|
1107 | } |
---|
1108 | return(H); |
---|
1109 | } |
---|
1110 | else |
---|
1111 | {for (i = 1; i <= size(P); i++) |
---|
1112 | {if (P[i] > degbound) {ERROR("degreebound is too small, GB contains elements of higher degree");}} |
---|
1113 | int sd; |
---|
1114 | intmat S; |
---|
1115 | sd = P[1]; |
---|
1116 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1117 | sd = (sd - 1); |
---|
1118 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1119 | else {S = createStartMat(sd,n);} |
---|
1120 | if (intvec(S) == 0) {return(H);} |
---|
1121 | for (i = 1; i <= sd; i++) {H = H,(n^i);} |
---|
1122 | for (i = 1; i <= nrows(S); i++) |
---|
1123 | {intvec St = S[i,1..ncols(S)]; |
---|
1124 | H = findHCoeff(St,n,L,P,H,degbound); |
---|
1125 | kill St; |
---|
1126 | } |
---|
1127 | return(H); |
---|
1128 | } |
---|
1129 | } |
---|
1130 | example |
---|
1131 | { |
---|
1132 | "EXAMPLE:"; echo = 2; |
---|
1133 | ring r = 0,(x,y),dp; |
---|
1134 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1135 | R; |
---|
1136 | setring R; // sets basering to Letterplace ring |
---|
1137 | //some intmats, which contain monomials in intvec representation as rows |
---|
1138 | intmat I1 [2][2] = 1,1,2,2; intmat I2 [1][3] = 1,2,1; |
---|
1139 | intmat J1 [1][2] = 1,1; intmat J2 [2][3] = 2,1,2,1,2,1; |
---|
1140 | print(I1); |
---|
1141 | print(I2); |
---|
1142 | print(J1); |
---|
1143 | print(J2); |
---|
1144 | list G = I1,I2; // ideal, which is already a Groebner basis |
---|
1145 | list I = J1,J2; // ideal, which is already a Groebner basis |
---|
1146 | ivHilbert(G,2); // invokes the procedure without any degree bound |
---|
1147 | ivHilbert(I,2,5); // invokes the procedure with degree bound 5 |
---|
1148 | } |
---|
1149 | |
---|
1150 | |
---|
1151 | proc ivKDim(list L, int n, list #) |
---|
1152 | "USAGE: ivKDim(L,n[,degbound]); L a list of intmats, |
---|
1153 | @* n an integer, degbound an optional integer |
---|
1154 | RETURN: An integer, the K-dimension of A/<L> |
---|
1155 | PURPOSE:Computing the K-dimension of A/<L> |
---|
1156 | ASSUME: - basering is a Letterplace ring. |
---|
1157 | @* - all rows of each intmat correspond to a Letterplace monomial |
---|
1158 | @* - if you specify a different degree bound degbound, |
---|
1159 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1160 | NOTE: - If degbound is set, a degree bound will be added. By default there |
---|
1161 | @* is no degree bound. |
---|
1162 | @* - n is the number of variables. |
---|
1163 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1164 | EXAMPLE: example ivKDim; shows examples |
---|
1165 | " |
---|
1166 | {int degbound = 0; |
---|
1167 | if (size(#) > 0) {if (typeof(#[1])=="int"){if (#[1] > 0) {degbound = #[1];}}} |
---|
1168 | intvec P,H; int i; |
---|
1169 | for (i = 1; i <= size(L); i++) |
---|
1170 | {P[i] = ncols(L[i]); |
---|
1171 | if (P[i] == 1) {if ( isInMat(H,L[i]) > 0) {ERROR("Quotient algebra is trivial");}} |
---|
1172 | } |
---|
1173 | if (size(L) == 0) {ERROR("GB is empty, quotient algebra corresponds to free algebra");} |
---|
1174 | kill H; |
---|
1175 | checkAssumptions(degbound,L); |
---|
1176 | if (degbound == 0) |
---|
1177 | {int sd; int dimen = 1; |
---|
1178 | intmat S; |
---|
1179 | sd = P[1]; |
---|
1180 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1181 | sd = (sd - 1); |
---|
1182 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1183 | else {S = createStartMat(sd,n);} |
---|
1184 | if (intvec(S) == 0) {return(dimen);} |
---|
1185 | for (i = 1; i <= sd; i++) {dimen = dimen +(n^i);} |
---|
1186 | for (i = 1; i <= nrows(S); i++) |
---|
1187 | {intvec St = S[i,1..ncols(S)]; |
---|
1188 | dimen = dimen + findDimen(St,n,L,P); |
---|
1189 | kill St; |
---|
1190 | } |
---|
1191 | return(dimen); |
---|
1192 | } |
---|
1193 | else |
---|
1194 | {for (i = 1; i <= size(P); i++) |
---|
1195 | {if (P[i] > degbound) {ERROR("degreebound is too small, GB contains elements of higher degree");}} |
---|
1196 | int sd; int dimen = 1; |
---|
1197 | intmat S; |
---|
1198 | sd = P[1]; |
---|
1199 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1200 | sd = (sd - 1); |
---|
1201 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1202 | else {S = createStartMat(sd,n);} |
---|
1203 | if (intvec(S) == 0) {return(dimen);} |
---|
1204 | for (i = 1; i <= sd; i++) {dimen = dimen +(n^i);} |
---|
1205 | for (i = 1; i <= nrows(S); i++) |
---|
1206 | {intvec St = S[i,1..ncols(S)]; |
---|
1207 | dimen = dimen + findDimen(St,n,L,P, degbound); |
---|
1208 | kill St; |
---|
1209 | } |
---|
1210 | return(dimen); |
---|
1211 | } |
---|
1212 | } |
---|
1213 | example |
---|
1214 | { |
---|
1215 | "EXAMPLE:"; echo = 2; |
---|
1216 | ring r = 0,(x,y),dp; |
---|
1217 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1218 | R; |
---|
1219 | setring R; // sets basering to Letterplace ring |
---|
1220 | //some intmats, which contain monomials in intvec representation as rows |
---|
1221 | intmat I1 [2][2] = 1,1,2,2; intmat I2 [1][3] = 1,2,1; |
---|
1222 | intmat J1 [1][2] = 1,1; intmat J2 [2][3] = 2,1,2,1,2,1; |
---|
1223 | print(I1); |
---|
1224 | print(I2); |
---|
1225 | print(J1); |
---|
1226 | print(J2); |
---|
1227 | list G = I1,I2; // ideal, which is already a Groebner basis |
---|
1228 | list I = J1,J2; // ideal, which is already a Groebner basis |
---|
1229 | ivKDim(G,2); // invokes the procedure without any degree bound |
---|
1230 | ivKDim(I,2,5); // invokes the procedure with degree bound 5 |
---|
1231 | } |
---|
1232 | |
---|
1233 | proc ivMis2Dim(list M) |
---|
1234 | "USAGE: ivMis2Dim(M); M a list of intvecs |
---|
1235 | RETURN: An integer, the K-dimension of the given algebra |
---|
1236 | PURPOSE:Computing the K-dimension out of given mistletoes |
---|
1237 | ASSUME: - The mistletoes have to be ordered lexicographically -> OrdMisLex. |
---|
1238 | @* Otherwise the returned value may differ from the K-dimension. |
---|
1239 | @* - basering is a Letterplace ring. |
---|
1240 | EXAMPLE: example ivMis2Dim; shows examples |
---|
1241 | " |
---|
1242 | {checkAssumptions(0,M); |
---|
1243 | intvec L; |
---|
1244 | if (size(M) == 0){ERROR("There are no mistletoes, so it appears your dimension is infinite!");} |
---|
1245 | if (isInList(L,M) > 0) {print("1 is a mistletoe, therefore dim = 1"); return(1);} |
---|
1246 | int i,j,d,s; |
---|
1247 | j = 1; |
---|
1248 | d = 1 + size(M[1]); |
---|
1249 | for (i = 1; i < size(M); i++) |
---|
1250 | {s = size(M[i]); if (s > size(M[i+1])){s = size(M[i+1]);} |
---|
1251 | while ((M[i][j] == M[i+1][j]) && (j <= s)){j = j + 1;} |
---|
1252 | d = d + size(M[i+1])- j + 1; |
---|
1253 | } |
---|
1254 | return(d); |
---|
1255 | } |
---|
1256 | example |
---|
1257 | { |
---|
1258 | "EXAMPLE:"; echo = 2; |
---|
1259 | ring r = 0,(x,y),dp; |
---|
1260 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1261 | R; |
---|
1262 | setring R; // sets basering to Letterplace ring |
---|
1263 | intvec i1 = 1,2; intvec i2 = 2,1,2; |
---|
1264 | // the mistletoes are xy and yxy, which are already ordered lexicographically |
---|
1265 | list L = i1,i2; |
---|
1266 | ivMis2Dim(L); // returns the dimension of the factor algebra |
---|
1267 | } |
---|
1268 | |
---|
1269 | proc ivOrdMisLex(list M) |
---|
1270 | "USAGE: ivOrdMisLex(M); M a list of intvecs |
---|
1271 | RETURN: A list, containing the ordered intvecs of M |
---|
1272 | PURPOSE:Orders a given set of mistletoes lexicographically |
---|
1273 | ASSUME: - basering is a Letterplace ring. |
---|
1274 | - intvecs correspond to monomials |
---|
1275 | NOTE: - This is preprocessing, it's not needed if the mistletoes are returned |
---|
1276 | @* from the sickle algorithm. |
---|
1277 | @* - Each entry of the list returned is an intvec. |
---|
1278 | EXAMPLE: example ivOrdMisLex; shows examples |
---|
1279 | " |
---|
1280 | {checkAssumptions(0,M); |
---|
1281 | return(sort(M)[1]); |
---|
1282 | } |
---|
1283 | example |
---|
1284 | { |
---|
1285 | "EXAMPLE:"; echo = 2; |
---|
1286 | ring r = 0,(x,y),dp; |
---|
1287 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1288 | setring R; // sets basering to Letterplace ring |
---|
1289 | intvec i1 = 1,2,1; intvec i2 = 2,2,1; intvec i3 = 1,1; intvec i4 = 2,1,1,1; |
---|
1290 | // the corresponding monomials are xyx,y^2x,x^2,yx^3 |
---|
1291 | list M = i1,i2,i3,i4; |
---|
1292 | M; |
---|
1293 | ivOrdMisLex(M);// orders the list of monomials |
---|
1294 | } |
---|
1295 | |
---|
1296 | proc ivSickle(list L, int n, list #) |
---|
1297 | "USAGE: ivSickle(L,n,[degbound]); L a list of intmats, n an int, degbound an |
---|
1298 | @* optional integer |
---|
1299 | RETURN: A list, containing intvecs, the mistletoes of A/<L> |
---|
1300 | PURPOSE:Computing the mistletoes for a given Groebner basis L |
---|
1301 | ASSUME: - basering is a Letterplace ring. |
---|
1302 | @* - all rows of each intmat correspond to a Letterplace monomial |
---|
1303 | @* - if you specify a different degree bound degbound, |
---|
1304 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1305 | NOTE: - If degbound is set, a degree bound will be added. By default there |
---|
1306 | @* is no degree bound. |
---|
1307 | @* - n is the number of variables. |
---|
1308 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1309 | EXAMPLE: example ivSickle; shows examples |
---|
1310 | " |
---|
1311 | {list M; |
---|
1312 | int degbound = 0; |
---|
1313 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] > 0){degbound = #[1];}}} |
---|
1314 | int i; |
---|
1315 | intvec P,H; |
---|
1316 | for (i = 1; i <= size(L); i++) |
---|
1317 | {P[i] = ncols(L[i]); |
---|
1318 | if (P[i] == 1) {if (isInMat(H,L[i]) > 0) {ERROR("Quotient algebra is trivial");}} |
---|
1319 | } |
---|
1320 | if (size(L) == 0) {ERROR("GB is empty, quotient algebra corresponds to free algebra");} |
---|
1321 | kill H; |
---|
1322 | checkAssumptions(degbound,L); |
---|
1323 | if (degbound == 0) |
---|
1324 | {intmat S; int sd; |
---|
1325 | sd = P[1]; |
---|
1326 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1327 | sd = (sd - 1); |
---|
1328 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1329 | else {S = createStartMat(sd,n);} |
---|
1330 | if (intvec(S) == 0) {return(list (intvec(0)));} |
---|
1331 | for (i = 1; i <= nrows(S); i++) |
---|
1332 | {intvec St = S[i,1..ncols(S)]; |
---|
1333 | M = M + findmistletoes(St,n,L,P); |
---|
1334 | kill St; |
---|
1335 | } |
---|
1336 | return(M); |
---|
1337 | } |
---|
1338 | else |
---|
1339 | {for (i = 1; i <= size(P); i++) |
---|
1340 | {if (P[i] > degbound) {ERROR("degreebound is too small, GB contains elements of higher degree");}} |
---|
1341 | intmat S; int sd; |
---|
1342 | sd = P[1]; |
---|
1343 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1344 | sd = (sd - 1); |
---|
1345 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1346 | else {S = createStartMat(sd,n);} |
---|
1347 | if (intvec(S) == 0) {return(list (intvec(0)));} |
---|
1348 | for (i = 1; i <= nrows(S); i++) |
---|
1349 | {intvec St = S[i,1..ncols(S)]; |
---|
1350 | M = M + findmistletoes(St,n,L,P,degbound); |
---|
1351 | kill St; |
---|
1352 | } |
---|
1353 | return(M); |
---|
1354 | } |
---|
1355 | } |
---|
1356 | example |
---|
1357 | { |
---|
1358 | "EXAMPLE:"; echo = 2; |
---|
1359 | ring r = 0,(x,y),dp; |
---|
1360 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1361 | setring R; // sets basering to Letterplace ring |
---|
1362 | //some intmats, which contain monomials in intvec representation as rows |
---|
1363 | intmat I1 [2][2] = 1,1,2,2; intmat I2 [1][3] = 1,2,1; |
---|
1364 | intmat J1 [1][2] = 1,1; intmat J2 [2][3] = 2,1,2,1,2,1; |
---|
1365 | print(I1); |
---|
1366 | print(I2); |
---|
1367 | print(J1); |
---|
1368 | print(J2); |
---|
1369 | list G = I1,I2; // ideal, which is already a Groebner basis |
---|
1370 | list I = J1,J2; // ideal, which is already a Groebner basis |
---|
1371 | ivSickle(G,2); // invokes the procedure without any degree bound |
---|
1372 | ivSickle(I,2,5); // invokes the procedure with degree bound 5 |
---|
1373 | } |
---|
1374 | |
---|
1375 | proc ivSickleDim(list L, int n, list #) |
---|
1376 | "USAGE: ivSickleDim(L,n[,degbound]); L a list of intmats, n an integer, degbound |
---|
1377 | @* an optional integer |
---|
1378 | RETURN: A list |
---|
1379 | PURPOSE:Computing mistletoes and the K-dimension |
---|
1380 | ASSUME: - basering is a Letterplace ring. |
---|
1381 | @* - all rows of each intmat correspond to a Letterplace monomial |
---|
1382 | @* - if you specify a different degree bound degbound, |
---|
1383 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1384 | NOTE: - If L is the list returned, then L[1] is an integer, L[2] is a list, |
---|
1385 | @* containing the mistletoes as intvecs. |
---|
1386 | @* - If degbound is set, a degree bound will be added. By default there |
---|
1387 | @* is no degree bound. |
---|
1388 | @* - n is the number of variables. |
---|
1389 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1390 | EXAMPLE: example ivSickleDim; shows examples |
---|
1391 | " |
---|
1392 | {list M; |
---|
1393 | int degbound = 0; |
---|
1394 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] > 0){degbound = #[1];}}} |
---|
1395 | int i,dimen; list R; |
---|
1396 | intvec P,H; |
---|
1397 | for (i = 1; i <= size(L); i++) |
---|
1398 | {P[i] = ncols(L[i]); |
---|
1399 | if (P[i] == 1) {if (isInMat(H,L[i]) > 0) {ERROR("Quotient algebra is trivial, dimension equals zero");}} |
---|
1400 | } |
---|
1401 | if (size(L) == 0) {ERROR("GB is empty, quotient algebra corresponds to free algebra");} |
---|
1402 | kill H; |
---|
1403 | checkAssumptions(degbound,L); |
---|
1404 | if (degbound == 0) |
---|
1405 | {int sd; dimen = 1; |
---|
1406 | intmat S; |
---|
1407 | sd = P[1]; |
---|
1408 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1409 | sd = (sd - 1); |
---|
1410 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1411 | else {S = createStartMat(sd,n);} |
---|
1412 | if (intvec(S) == 0) {return(list(dimen,list(intvec(0))));} |
---|
1413 | for (i = 1; i <= sd; i++) {dimen = dimen +(n^i);} |
---|
1414 | R[1] = dimen; |
---|
1415 | for (i = 1; i <= nrows(S); i++) |
---|
1416 | {intvec St = S[i,1..ncols(S)]; |
---|
1417 | R = findMisDim(St,n,L,P,R); |
---|
1418 | kill St; |
---|
1419 | } |
---|
1420 | return(R); |
---|
1421 | } |
---|
1422 | else |
---|
1423 | {for (i = 1; i <= size(P); i++) |
---|
1424 | {if (P[i] > degbound) {ERROR("degreebound is too small, GB contains elements of higher degree");}} |
---|
1425 | int sd; dimen = 1; |
---|
1426 | intmat S; |
---|
1427 | sd = P[1]; |
---|
1428 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1429 | sd = (sd - 1); |
---|
1430 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1431 | else {S = createStartMat(sd,n);} |
---|
1432 | if (intvec(S) == 0) {return(list(dimen,list(intvec(0))));} |
---|
1433 | for (i = 1; i <= sd; i++) {dimen = dimen +(n^i);} |
---|
1434 | R[1] = dimen; |
---|
1435 | for (i = 1; i <= nrows(S); i++) |
---|
1436 | {intvec St = S[i,1..ncols(S)]; |
---|
1437 | R = findMisDim(St,n,L,P,R,degbound); |
---|
1438 | kill St; |
---|
1439 | } |
---|
1440 | return(R); |
---|
1441 | } |
---|
1442 | } |
---|
1443 | example |
---|
1444 | { |
---|
1445 | "EXAMPLE:"; echo = 2; |
---|
1446 | ring r = 0,(x,y),dp; |
---|
1447 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1448 | setring R; // sets basering to Letterplace ring |
---|
1449 | //some intmats, which contain monomials in intvec representation as rows |
---|
1450 | intmat I1 [2][2] = 1,1,2,2; intmat I2 [1][3] = 1,2,1; |
---|
1451 | intmat J1 [1][2] = 1,1; intmat J2 [2][3] = 2,1,2,1,2,1; |
---|
1452 | print(I1); |
---|
1453 | print(I2); |
---|
1454 | print(J1); |
---|
1455 | print(J2); |
---|
1456 | list G = I1,I2;// ideal, which is already a Groebner basis |
---|
1457 | list I = J1,J2; // ideal, which is already a Groebner basis |
---|
1458 | ivSickleDim(G,2); // invokes the procedure without any degree bound |
---|
1459 | ivSickleDim(I,2,5); // invokes the procedure with degree bound 5 |
---|
1460 | } |
---|
1461 | |
---|
1462 | proc ivSickleHil(list L, int n, list #) |
---|
1463 | "USAGE:ivSickleHil(L,n[,degbound]); L a list of intmats, n an integer, |
---|
1464 | @* degbound an optional integer |
---|
1465 | RETURN: A list |
---|
1466 | PURPOSE:Computing the mistletoes and the Hilbert series |
---|
1467 | ASSUME: - basering is a Letterplace ring. |
---|
1468 | @* - all rows of each intmat correspond to a Letterplace monomial |
---|
1469 | @* - if you specify a different degree bound degbound, |
---|
1470 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1471 | NOTE: - If L is the list returned, then L[1] is an intvec, L[2] is a list, |
---|
1472 | @* containing the mistletoes as intvecs. |
---|
1473 | @* - If degbound is set, a degree bound will be added. By default there |
---|
1474 | @* is no degree bound. |
---|
1475 | @* - n is the number of variables. |
---|
1476 | @* - If I = L[1] is the intvec returned, then I[k] is the (k-1)-th |
---|
1477 | @* coefficient of the Hilbert series. |
---|
1478 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1479 | EXAMPLE: example ivSickleHil; shows examples |
---|
1480 | " |
---|
1481 | {int degbound = 0; |
---|
1482 | if (size(#) > 0) {if (typeof(#[1])=="int"){if (#[1] > 0) {degbound = #[1];}}} |
---|
1483 | intvec P,H; int i; list R; |
---|
1484 | for (i = 1; i <= size(L); i++) |
---|
1485 | {P[i] = ncols(L[i]); |
---|
1486 | if (P[i] == 1) {if ( isInMat(H,L[i]) > 0) {ERROR("Quotient algebra is trivial");}} |
---|
1487 | } |
---|
1488 | if (size(L) == 0) {ERROR("GB is empty, quotient algebra corresponds to free algebra");} |
---|
1489 | H[1] = 1; |
---|
1490 | checkAssumptions(degbound,L); |
---|
1491 | if (degbound == 0) |
---|
1492 | {int sd; |
---|
1493 | intmat S; |
---|
1494 | sd = P[1]; |
---|
1495 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1496 | sd = (sd - 1); |
---|
1497 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1498 | else {S = createStartMat(sd,n);} |
---|
1499 | if (intvec(S) == 0) {return(list(H,list(intvec (0))));} |
---|
1500 | for (i = 1; i <= sd; i++) {H = H,(n^i);} |
---|
1501 | R[1] = H; kill H; |
---|
1502 | for (i = 1; i <= nrows(S); i++) |
---|
1503 | {intvec St = S[i,1..ncols(S)]; |
---|
1504 | R = findHCoeffMis(St,n,L,P,R); |
---|
1505 | kill St; |
---|
1506 | } |
---|
1507 | return(R); |
---|
1508 | } |
---|
1509 | else |
---|
1510 | {for (i = 1; i <= size(P); i++) |
---|
1511 | {if (P[i] > degbound) {ERROR("degreebound is too small, GB contains elements of higher degree");}} |
---|
1512 | int sd; |
---|
1513 | intmat S; |
---|
1514 | sd = P[1]; |
---|
1515 | for (i = 2; i <= size(P); i++) {if (P[i] < sd) {sd = P[i];}} |
---|
1516 | sd = (sd - 1); |
---|
1517 | if (sd == 0) { for (i = 1; i <= size(L); i++){if (ncols(L[i]) == 1){S = createStartMat1(n,L[i]); break;}}} |
---|
1518 | else {S = createStartMat(sd,n);} |
---|
1519 | if (intvec(S) == 0) {return(list(H,list(intvec(0))));} |
---|
1520 | for (i = 1; i <= sd; i++) {H = H,(n^i);} |
---|
1521 | R[1] = H; kill H; |
---|
1522 | for (i = 1; i <= nrows(S); i++) |
---|
1523 | {intvec St = S[i,1..ncols(S)]; |
---|
1524 | R = findHCoeffMis(St,n,L,P,R,degbound); |
---|
1525 | kill St; |
---|
1526 | } |
---|
1527 | return(R); |
---|
1528 | } |
---|
1529 | } |
---|
1530 | example |
---|
1531 | { |
---|
1532 | "EXAMPLE:"; echo = 2; |
---|
1533 | ring r = 0,(x,y),dp; |
---|
1534 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1535 | setring R; // sets basering to Letterplace ring |
---|
1536 | //some intmats, which contain monomials in intvec representation as rows |
---|
1537 | intmat I1[2][2] = 1,1,2,2; intmat I2[1][3] = 1,2,1; |
---|
1538 | intmat J1[1][2] = 1,1; intmat J2[2][3] = 2,1,2,1,2,1; |
---|
1539 | print(I1); |
---|
1540 | print(I2); |
---|
1541 | print(J1); |
---|
1542 | print(J2); |
---|
1543 | list G = I1,I2;// ideal, which is already a Groebner basis |
---|
1544 | list I = J1,J2; // ideal, which is already a Groebner basis |
---|
1545 | ivSickleHil(G,2); // invokes the procedure without any degree bound |
---|
1546 | ivSickleHil(I,2,5); // invokes the procedure with degree bound 5 |
---|
1547 | } |
---|
1548 | |
---|
1549 | proc lpDHilbert(ideal G, list #) |
---|
1550 | "USAGE: lpDHilbert(G[,degbound,n]); G an ideal, degbound, n optional integers |
---|
1551 | RETURN: A list |
---|
1552 | PURPOSE:Computing K-dimension and Hilbert series, starting with a lp-ideal |
---|
1553 | ASSUME: - basering is a Letterplace ring. |
---|
1554 | @* - if you specify a different degree bound degbound, |
---|
1555 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1556 | NOTE: - If L is the list returned, then L[1] is an integer, L[2] is an intvec. |
---|
1557 | @* - If degbound is set, there will be a degree bound added. 0 means no |
---|
1558 | @* degree bound. Default: attrib(basering,uptodeg). |
---|
1559 | @* - n can be set to a different number of variables. |
---|
1560 | @* Default: n = attrib(basering, lV). |
---|
1561 | @* - If I = L[2] is the intvec returned, then I[k] is the (k-1)-th |
---|
1562 | @* coefficient of the Hilbert series. |
---|
1563 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1564 | EXAMPLE: example lpDHilbert; shows examples |
---|
1565 | " |
---|
1566 | {int degbound = attrib(basering,"uptodeg");int n = attrib(basering, "lV"); |
---|
1567 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] >= 0){degbound = #[1];}}} |
---|
1568 | if (size(#) > 1){if (typeof(#[1])=="int"){if (#[2] > 0){n = #[2];}}} |
---|
1569 | list L; |
---|
1570 | L = lp2ivId(normalize(lead(G))); |
---|
1571 | return(ivDHilbert(L,n,degbound)); |
---|
1572 | } |
---|
1573 | example |
---|
1574 | { |
---|
1575 | "EXAMPLE:"; echo = 2; |
---|
1576 | ring r = 0,(x,y),dp; |
---|
1577 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1578 | setring R; // sets basering to Letterplace ring |
---|
1579 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); // ideal G contains a |
---|
1580 | //Groebner basis |
---|
1581 | lpDHilbert(G,5,2); // invokes procedure with degree bound 5 and 2 variables |
---|
1582 | // note that the optional parameters are not necessary, due to the finiteness |
---|
1583 | // of the K-dimension of the factor algebra |
---|
1584 | lpDHilbert(G); // procedure with ring parameters |
---|
1585 | lpDHilbert(G,0); // procedure without degreebound |
---|
1586 | } |
---|
1587 | |
---|
1588 | proc lpDHilbertSickle(ideal G, list #) |
---|
1589 | "USAGE: lpDHilbertSickle(G[,degbound,n]); G an ideal, degbound, n optional |
---|
1590 | @* integers |
---|
1591 | RETURN: A list |
---|
1592 | PURPOSE:Computing K-dimension, Hilbert series and mistletoes at once |
---|
1593 | ASSUME: - basering is a Letterplace ring. |
---|
1594 | @* - if you specify a different degree bound degbound, |
---|
1595 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1596 | NOTE: - If L is the list returned, then L[1] is an intvec, the Hilbert series, |
---|
1597 | @* L[2] is an integer, the K-dimension and L[3] is an ideal, the mistletoes |
---|
1598 | @* - If degbound is set, there will be a degree bound added. 0 means no |
---|
1599 | @* degree bound. Default: attrib(basering,uptodeg). |
---|
1600 | @* - n can be set to a different number of variables. |
---|
1601 | @* Default: n = attrib(basering, lV). |
---|
1602 | @* - If I = L[1] is the intvec returned, then I[k] is the (k-1)-th |
---|
1603 | @* coefficient of the Hilbert series. |
---|
1604 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1605 | EXAMPLE: example lpDHilbertSickle; shows examples |
---|
1606 | " |
---|
1607 | {int degbound = attrib(basering,"uptodeg");int n = attrib(basering, "lV"); |
---|
1608 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] >= 0){degbound = #[1];}}} |
---|
1609 | if (size(#) > 1){if (typeof(#[1])=="int"){if (#[2] > 0){n = #[2];}}} |
---|
1610 | list L; |
---|
1611 | L = lp2ivId(normalize(lead(G))); |
---|
1612 | L = ivDHilbertSickle(L,n,degbound); |
---|
1613 | L[3] = ivL2lpI(L[3]); |
---|
1614 | return(L); |
---|
1615 | } |
---|
1616 | example |
---|
1617 | { |
---|
1618 | "EXAMPLE:"; echo = 2; |
---|
1619 | ring r = 0,(x,y),dp; |
---|
1620 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1621 | setring R; // sets basering to Letterplace ring |
---|
1622 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); // ideal G contains a |
---|
1623 | //Groebner basis |
---|
1624 | lpDHilbertSickle(G,5,2); //invokes procedure with degree bound 5 and 2 variables |
---|
1625 | // note that the optional parameters are not necessary, due to the finiteness |
---|
1626 | // of the K-dimension of the factor algebra |
---|
1627 | lpDHilbert(G); // procedure with ring parameters |
---|
1628 | lpDHilbert(G,0); // procedure without degreebound |
---|
1629 | } |
---|
1630 | |
---|
1631 | proc lpHilbert(ideal G, list #) |
---|
1632 | "USAGE: lpHilbert(G[,degbound,n]); G an ideal, degbound, n optional integers |
---|
1633 | RETURN: An intvec, containing the coefficients of the Hilbert series |
---|
1634 | PURPOSE:Computing the Hilbert series |
---|
1635 | ASSUME: - basering is a Letterplace ring. |
---|
1636 | @* - if you specify a different degree bound degbound, |
---|
1637 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1638 | NOTE: - If degbound is set, there will be a degree bound added. 0 means no |
---|
1639 | @* degree bound. Default: attrib(basering,uptodeg). |
---|
1640 | @* - n is the number of variables, which can be set to a different number. |
---|
1641 | @* Default: attrib(basering, lV). |
---|
1642 | @* - If I is returned, then I[k] is the (k-1)-th coefficient of the Hilbert |
---|
1643 | @* series. |
---|
1644 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1645 | EXAMPLE: example lpHilbert; shows examples |
---|
1646 | " |
---|
1647 | {int degbound = attrib(basering,"uptodeg");int n = attrib(basering, "lV"); |
---|
1648 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] >= 0){degbound = #[1];}}} |
---|
1649 | if (size(#) > 1){if (typeof(#[1])=="int"){if (#[2] > 0){n = #[2];}}} |
---|
1650 | list L; |
---|
1651 | L = lp2ivId(normalize(lead(G))); |
---|
1652 | return(ivHilbert(L,n,degbound)); |
---|
1653 | } |
---|
1654 | example |
---|
1655 | { |
---|
1656 | "EXAMPLE:"; echo = 2; |
---|
1657 | ring r = 0,(x,y),dp; |
---|
1658 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1659 | setring R; // sets basering to Letterplace ring |
---|
1660 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); // ideal G contains a |
---|
1661 | //Groebner basis |
---|
1662 | lpHilbert(G,5,2); // invokes procedure with degree bound 5 and 2 variables |
---|
1663 | // note that the optional parameters are not necessary, due to the finiteness |
---|
1664 | // of the K-dimension of the factor algebra |
---|
1665 | lpDHilbert(G); // procedure with ring parameters |
---|
1666 | lpDHilbert(G,0); // procedure without degreebound |
---|
1667 | } |
---|
1668 | |
---|
1669 | proc lpDimCheck(ideal G) |
---|
1670 | "USAGE: lpDimCheck(G); |
---|
1671 | RETURN: 1, if K-dimension of the factor algebra is infinite, 0 otherwise |
---|
1672 | PURPOSE:Checking a factor algebra for finiteness of the K-dimension |
---|
1673 | ASSUME: - basering is a Letterplace ring. |
---|
1674 | EXAMPLE: example lpDimCheck; shows examples |
---|
1675 | " |
---|
1676 | {int n = attrib(basering,"lV"); |
---|
1677 | list L; |
---|
1678 | ideal R; |
---|
1679 | R = normalize(lead(G)); |
---|
1680 | L = lp2ivId(R); |
---|
1681 | return(ivDimCheck(L,n)); |
---|
1682 | } |
---|
1683 | example |
---|
1684 | { |
---|
1685 | "EXAMPLE:"; echo = 2; |
---|
1686 | ring r = 0,(x,y),dp; |
---|
1687 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1688 | setring R; // sets basering to Letterplace ring |
---|
1689 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); |
---|
1690 | // Groebner basis |
---|
1691 | ideal I = x(1)*x(2), y(1)*x(2)*y(3), x(1)*y(2)*x(3); |
---|
1692 | // Groebner basis |
---|
1693 | lpDimCheck(G); // invokes procedure, factor algebra is of finite K-dimension |
---|
1694 | lpDimCheck(I); // invokes procedure, factor algebra is of infinite Kdimension |
---|
1695 | } |
---|
1696 | |
---|
1697 | proc lpKDim(ideal G, list #) |
---|
1698 | "USAGE: lpKDim(G[,degbound, n]); G an ideal, degbound, n optional integers |
---|
1699 | RETURN: An integer, the K-dimension of the factor algebra |
---|
1700 | PURPOSE:Computing the K-dimension of a factor algebra, given via an ideal |
---|
1701 | ASSUME: - basering is a Letterplace ring |
---|
1702 | @* - if you specify a different degree bound degbound, |
---|
1703 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1704 | NOTE: - If degbound is set, there will be a degree bound added. 0 means no |
---|
1705 | @* degree bound. Default: attrib(basering, uptodeg). |
---|
1706 | @* - n is the number of variables, which can be set to a different number. |
---|
1707 | @* Default: attrib(basering, lV). |
---|
1708 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1709 | EXAMPLE: example lpKDim; shows examples |
---|
1710 | " |
---|
1711 | {int degbound = attrib(basering, "uptodeg");int n = attrib(basering, "lV"); |
---|
1712 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] >= 0){degbound = #[1];}}} |
---|
1713 | if (size(#) > 1){if (typeof(#[1])=="int"){if (#[2] > 0){n = #[2];}}} |
---|
1714 | list L; |
---|
1715 | L = lp2ivId(normalize(lead(G))); |
---|
1716 | return(ivKDim(L,n,degbound)); |
---|
1717 | } |
---|
1718 | example |
---|
1719 | { |
---|
1720 | "EXAMPLE:"; echo = 2; |
---|
1721 | ring r = 0,(x,y),dp; |
---|
1722 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1723 | setring R; // sets basering to Letterplace ring |
---|
1724 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); |
---|
1725 | // ideal G contains a Groebner basis |
---|
1726 | lpKDim(G); //procedure invoked with ring parameters |
---|
1727 | // the factor algebra is finite, so the degree bound given by the Letterplace |
---|
1728 | // ring is not necessary |
---|
1729 | lpKDim(G,0); // procedure without any degree bound |
---|
1730 | } |
---|
1731 | |
---|
1732 | proc lpMis2Dim(ideal M) |
---|
1733 | "USAGE: lpMis2Dim(M); M an ideal |
---|
1734 | RETURN: An integer, the K-dimension of the factor algebra |
---|
1735 | PURPOSE:Computing the K-dimension out of given mistletoes |
---|
1736 | ASSUME: - basering is a Letterplace ring. |
---|
1737 | @* - M contains only monomials |
---|
1738 | NOTE: - The mistletoes have to be ordered lexicographically -> OrdMisLex. |
---|
1739 | EXAMPLE: example lpMis2Dim; shows examples |
---|
1740 | " |
---|
1741 | {list L; |
---|
1742 | L = lpId2ivLi(M); |
---|
1743 | return(ivMis2Dim(L)); |
---|
1744 | } |
---|
1745 | example |
---|
1746 | { |
---|
1747 | "EXAMPLE:"; echo = 2; |
---|
1748 | ring r = 0,(x,y),dp; |
---|
1749 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1750 | setring R; // sets basering to Letterplace ring |
---|
1751 | ideal L = x(1)*y(2),y(1)*x(2)*y(3); |
---|
1752 | // ideal containing the mistletoes |
---|
1753 | lpMis2Dim(L); // returns the K-dimension of the factor algebra |
---|
1754 | } |
---|
1755 | |
---|
1756 | proc lpOrdMisLex(ideal M) |
---|
1757 | "USAGE: lpOrdMisLex(M); M an ideal of mistletoes |
---|
1758 | RETURN: An ideal, containing the mistletoes, ordered lexicographically |
---|
1759 | PURPOSE:A given set of mistletoes is ordered lexicographically |
---|
1760 | ASSUME: - basering is a Letterplace ring. |
---|
1761 | NOTE: This is preprocessing, it is not needed if the mistletoes are returned |
---|
1762 | @* from the sickle algorithm. |
---|
1763 | EXAMPLE: example lpOrdMisLex; shows examples |
---|
1764 | " |
---|
1765 | {return(ivL2lpI(sort(lpId2ivLi(M))[1]));} |
---|
1766 | example |
---|
1767 | { |
---|
1768 | "EXAMPLE:"; echo = 2; |
---|
1769 | ring r = 0,(x,y),dp; |
---|
1770 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1771 | setring R; // sets basering to Letterplace ring |
---|
1772 | ideal M = x(1)*y(2)*x(3), y(1)*y(2)*x(3), x(1)*x(2), y(1)*x(2)*x(3)*x(4); |
---|
1773 | // some monomials |
---|
1774 | lpOrdMisLex(M); // orders the monomials lexicographically |
---|
1775 | } |
---|
1776 | |
---|
1777 | proc lpSickle(ideal G, list #) |
---|
1778 | "USAGE: lpSickle(G[,degbound,n]); G an ideal, degbound, n optional integers |
---|
1779 | RETURN: An ideal |
---|
1780 | PURPOSE:Computing the mistletoes of K[X]/<G> |
---|
1781 | ASSUME: - basering is a Letterplace ring. |
---|
1782 | @* - if you specify a different degree bound degbound, |
---|
1783 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1784 | NOTE: - If degbound is set, there will be a degree bound added. 0 means no |
---|
1785 | @* degree bound. Default: attrib(basering,uptodeg). |
---|
1786 | @* - n is the number of variables, which can be set to a different number. |
---|
1787 | @* Default: attrib(basering, lV). |
---|
1788 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1789 | EXAMPLE: example lpSickle; shows examples |
---|
1790 | " |
---|
1791 | {int degbound = attrib(basering,"uptodeg"); int n = attrib(basering, "lV"); |
---|
1792 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] >= 0){degbound = #[1];}}} |
---|
1793 | if (size(#) > 1){if (typeof(#[1])=="int"){if (#[2] > 0){n = #[2];}}} |
---|
1794 | list L; ideal R; |
---|
1795 | R = normalize(lead(G)); |
---|
1796 | L = lp2ivId(R); |
---|
1797 | L = ivSickle(L,n,degbound); |
---|
1798 | R = ivL2lpI(L); |
---|
1799 | return(R); |
---|
1800 | } |
---|
1801 | example |
---|
1802 | { |
---|
1803 | "EXAMPLE:"; echo = 2; |
---|
1804 | ring r = 0,(x,y),dp; |
---|
1805 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1806 | setring R; // sets basering to Letterplace ring |
---|
1807 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); // ideal G contains a |
---|
1808 | //Groebner basis |
---|
1809 | lpSickle(G); //invokes the procedure with ring parameters |
---|
1810 | // the factor algebra is finite, so the degree bound given by the Letterplace |
---|
1811 | // ring is not necessary |
---|
1812 | lpSickle(G,0); // procedure without any degree bound |
---|
1813 | } |
---|
1814 | |
---|
1815 | proc lpSickleDim(ideal G, list #) |
---|
1816 | "USAGE: lpSickleDim(G[,degbound,n]); G an ideal, degbound, n optional integers |
---|
1817 | RETURN: A list |
---|
1818 | PURPOSE:Computing the K-dimension and the mistletoes |
---|
1819 | ASSUME: - basering is a Letterplace ring. |
---|
1820 | @* - if you specify a different degree bound degbound, |
---|
1821 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1822 | NOTE: - If L is the list returned, then L[1] is an integer, the K-dimension, |
---|
1823 | @* L[2] is an ideal, the mistletoes. |
---|
1824 | @* - If degbound is set, there will be a degree bound added. 0 means no |
---|
1825 | @* degree bound. Default: attrib(basering,uptodeg). |
---|
1826 | @* - n is the number of variables, which can be set to a different number. |
---|
1827 | @* Default: attrib(basering, lV). |
---|
1828 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1829 | EXAMPLE: example lpSickleDim; shows examples |
---|
1830 | " |
---|
1831 | {int degbound = attrib(basering,"uptodeg");int n = attrib(basering, "lV"); |
---|
1832 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] >= 0){degbound = #[1];}}} |
---|
1833 | if (size(#) > 1){if (typeof(#[1])=="int"){if (#[2] > 0){n = #[2];}}} |
---|
1834 | list L; |
---|
1835 | L = lp2ivId(normalize(lead(G))); |
---|
1836 | L = ivSickleDim(L,n,degbound); |
---|
1837 | L[2] = ivL2lpI(L[2]); |
---|
1838 | return(L); |
---|
1839 | } |
---|
1840 | example |
---|
1841 | { |
---|
1842 | "EXAMPLE:"; echo = 2; |
---|
1843 | ring r = 0,(x,y),dp; |
---|
1844 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1845 | setring R; // sets basering to Letterplace ring |
---|
1846 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); // ideal G contains a |
---|
1847 | //Groebner basis |
---|
1848 | lpSickleDim(G); // invokes the procedure with ring parameters |
---|
1849 | // the factor algebra is finite, so the degree bound given by the Letterplace |
---|
1850 | // ring is not necessary |
---|
1851 | lpSickleDim(G,0); // procedure without any degree bound |
---|
1852 | } |
---|
1853 | |
---|
1854 | proc lpSickleHil(ideal G, list #) |
---|
1855 | "USAGE: lpSickleHil(G); |
---|
1856 | RETURN: A list |
---|
1857 | PURPOSE:Computing the Hilbert series and the mistletoes |
---|
1858 | ASSUME: - basering is a Letterplace ring. |
---|
1859 | @* - if you specify a different degree bound degbound, |
---|
1860 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1861 | NOTE: - If L is the list returned, then L[1] is an intvec, corresponding to the |
---|
1862 | @* Hilbert series, L[2] is an ideal, the mistletoes. |
---|
1863 | @* - If degbound is set, there will be a degree bound added. 0 means no |
---|
1864 | @* degree bound. Default: attrib(basering,uptodeg). |
---|
1865 | @* - n is the number of variables, which can be set to a different number. |
---|
1866 | @* Default: attrib(basering, lV). |
---|
1867 | @* - If I = L[1] is the intvec returned, then I[k] is the (k-1)-th |
---|
1868 | @* coefficient of the Hilbert series. |
---|
1869 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1870 | EXAMPLE: example lpSickleHil; shows examples |
---|
1871 | " |
---|
1872 | {int degbound = attrib(basering,"uptodeg");int n = attrib(basering, "lV"); |
---|
1873 | if (size(#) > 0){if (typeof(#[1])=="int"){if (#[1] >= 0){degbound = #[1];}}} |
---|
1874 | if (size(#) > 1){if (typeof(#[1])=="int"){if (#[2] > 0){n = #[2];}}} |
---|
1875 | list L; |
---|
1876 | L = lp2ivId(normalize(lead(G))); |
---|
1877 | L = ivSickleHil(L,n,degbound); |
---|
1878 | L[2] = ivL2lpI(L[2]); |
---|
1879 | return(L); |
---|
1880 | } |
---|
1881 | example |
---|
1882 | { |
---|
1883 | "EXAMPLE:"; echo = 2; |
---|
1884 | ring r = 0,(x,y),dp; |
---|
1885 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1886 | setring R; // sets basering to Letterplace ring |
---|
1887 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); // ideal G contains a |
---|
1888 | //Groebner basis |
---|
1889 | lpSickleHil(G); // invokes the procedure with ring parameters |
---|
1890 | // the factor algebra is finite, so the degree bound given by the Letterplace |
---|
1891 | // ring is not necessary |
---|
1892 | lpSickleHil(G,0); // procedure without any degree bound |
---|
1893 | } |
---|
1894 | |
---|
1895 | proc sickle(ideal G, list #) |
---|
1896 | "USAGE: sickle(G[,m, d, h, degbound]); G an ideal; m,d,h,degbound optional |
---|
1897 | @* integers |
---|
1898 | RETURN: A list |
---|
1899 | PURPOSE:Allowing the user to access all procs with one command |
---|
1900 | ASSUME: - basering is a Letterplace ring. |
---|
1901 | @* - if you specify a different degree bound degbound, |
---|
1902 | @* degbound <= attrib(basering,uptodeg) holds. |
---|
1903 | NOTE: The returned object will always be a list, but the entries of the |
---|
1904 | @* returned list may be very different |
---|
1905 | @* case m=1,d=1,h=1: see lpDHilbertSickle |
---|
1906 | @* case m=1,d=1,h=0: see lpSickleDim |
---|
1907 | @* case m=1,d=0,h=1: see lpSickleHil |
---|
1908 | @* case m=1,d=0,h=0: see lpSickle (this is the default case) |
---|
1909 | @* case m=0,d=1,h=1: see lpDHilbert |
---|
1910 | @* case m=0,d=1,h=0: see lpKDim |
---|
1911 | @* case m=0,d=0,h=1: see lpHilbert |
---|
1912 | @* case m=0,d=0,h=0: returns an error |
---|
1913 | @* - If degbound is set, there will be a degree bound added. 0 means no |
---|
1914 | @* degree bound. Default: attrib(basering,uptodeg). |
---|
1915 | @* - If the K-dimension is known to be infinite, a degree bound is needed |
---|
1916 | EXAMPLE: example sickle; shows examples |
---|
1917 | " |
---|
1918 | {int m,d,h,degbound; |
---|
1919 | m = 1; d = 0; h = 0; degbound = attrib(basering,"uptodeg"); |
---|
1920 | if (size(#) > 0) {if (typeof(#[1])=="int"){if (#[1] < 1) {m = 0;}}} |
---|
1921 | if (size(#) > 1) {if (typeof(#[1])=="int"){if (#[2] > 0) {d = 1;}}} |
---|
1922 | if (size(#) > 2) {if (typeof(#[1])=="int"){if (#[3] > 0) {h = 1;}}} |
---|
1923 | if (size(#) > 3) {if (typeof(#[1])=="int"){if (#[4] >= 0) {degbound = #[4];}}} |
---|
1924 | if (m == 1) |
---|
1925 | {if (d == 0) |
---|
1926 | {if (h == 0) {return(lpSickle(G,degbound,attrib(basering,"lV")));} |
---|
1927 | else {return(lpSickleHil(G,degbound,attrib(basering,"lV")));} |
---|
1928 | } |
---|
1929 | else |
---|
1930 | {if (h == 0) {return(lpSickleDim(G,degbound,attrib(basering,"lV")));} |
---|
1931 | else {return(lpDHilbertSickle(G,degbound,attrib(basering,"lV")));} |
---|
1932 | } |
---|
1933 | } |
---|
1934 | else |
---|
1935 | {if (d == 0) |
---|
1936 | {if (h == 0) {ERROR("You request to do nothing, so relax and do so");} |
---|
1937 | else {return(lpHilbert(G,degbound,attrib(basering,"lV")));} |
---|
1938 | } |
---|
1939 | else |
---|
1940 | {if (h == 0) {return(lpKDim(G,degbound,attrib(basering,"lV")));} |
---|
1941 | else {return(lpDHilbert(G,degbound,attrib(basering,"lV")));} |
---|
1942 | } |
---|
1943 | } |
---|
1944 | } |
---|
1945 | example |
---|
1946 | { |
---|
1947 | "EXAMPLE:"; echo = 2; |
---|
1948 | ring r = 0,(x,y),dp; |
---|
1949 | def R = makeLetterplaceRing(5); // constructs a Letterplace ring |
---|
1950 | setring R; // sets basering to Letterplace ring |
---|
1951 | ideal G = x(1)*x(2), y(1)*y(2),x(1)*y(2)*x(3); |
---|
1952 | // G contains a Groebner basis |
---|
1953 | sickle(G,1,1,1); // computes mistletoes, K-dimension and the Hilbert series |
---|
1954 | sickle(G,1,0,0); // computes mistletoes only |
---|
1955 | sickle(G,0,1,0); // computes K-dimension only |
---|
1956 | sickle(G,0,0,1); // computes Hilbert series only |
---|
1957 | } |
---|
1958 | |
---|
1959 | /////////////////////////////////////////////////////////////////////////////// |
---|
1960 | |
---|
1961 | |
---|
1962 | proc tst_fpadim() |
---|
1963 | { |
---|
1964 | example ivDHilbert; |
---|
1965 | example ivDHilbertSickle; |
---|
1966 | example ivDimCheck; |
---|
1967 | example ivHilbert; |
---|
1968 | example ivKDim; |
---|
1969 | example ivMis2Dim; |
---|
1970 | example ivOrdMisLex; |
---|
1971 | example ivSickle; |
---|
1972 | example ivSickleHil; |
---|
1973 | example ivSickleDim; |
---|
1974 | example lpDHilbert; |
---|
1975 | example lpDHilbertSickle; |
---|
1976 | example lpHilbert; |
---|
1977 | example lpDimCheck; |
---|
1978 | example lpKDim; |
---|
1979 | example lpMis2Dim; |
---|
1980 | example lpOrdMisLex; |
---|
1981 | example lpSickle; |
---|
1982 | example lpSickleHil; |
---|
1983 | example lpSickleDim; |
---|
1984 | example sickle; |
---|
1985 | example ivL2lpI; |
---|
1986 | example iv2lp; |
---|
1987 | example iv2lpList; |
---|
1988 | example iv2lpMat; |
---|
1989 | example lp2iv; |
---|
1990 | example lp2ivId; |
---|
1991 | example lpId2ivLi; |
---|
1992 | } |
---|
1993 | |
---|
1994 | |
---|
1995 | |
---|
1996 | |
---|
1997 | |
---|
1998 | /* |
---|
1999 | Here are some examples one may try. Just copy them into your console. |
---|
2000 | These are relations for braid groups, up to degree d: |
---|
2001 | |
---|
2002 | |
---|
2003 | LIB "fpadim.lib"; |
---|
2004 | ring r = 0,(x,y,z),dp; |
---|
2005 | int d =10; // degree |
---|
2006 | def R = makeLetterplaceRing(d); |
---|
2007 | setring R; |
---|
2008 | ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*x(3) - z(1)*x(2)*y(3), |
---|
2009 | z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) + y(1)*y(2)*y(3) + |
---|
2010 | z(1)*z(2)*z(3) + x(1)*y(2)*z(3); |
---|
2011 | option(prot); |
---|
2012 | option(redSB);option(redTail);option(mem); |
---|
2013 | ideal J = system("freegb",I,d,3); |
---|
2014 | lpDimCheck(J); |
---|
2015 | sickle(J,1,1,1,d);//Computes mistletoes, K-dimension and the Hilbert series |
---|
2016 | |
---|
2017 | |
---|
2018 | |
---|
2019 | LIB "fpadim.lib"; |
---|
2020 | ring r = 0,(x,y,z),dp; |
---|
2021 | int d =11; // degree |
---|
2022 | def R = makeLetterplaceRing(d); |
---|
2023 | setring R; |
---|
2024 | ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*z(3) - z(1)*x(2)*y(3), |
---|
2025 | z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) + y(1)*y(2)*y(3) + |
---|
2026 | z(1)*z(2)*z(3) + x(1)*y(2)*z(3); |
---|
2027 | option(prot); |
---|
2028 | option(redSB);option(redTail);option(mem); |
---|
2029 | ideal J = system("freegb",I,d,3); |
---|
2030 | lpDimCheck(J); |
---|
2031 | sickle(J,1,1,1,d); |
---|
2032 | |
---|
2033 | |
---|
2034 | |
---|
2035 | LIB "fpadim.lib"; |
---|
2036 | ring r = 0,(x,y,z),dp; |
---|
2037 | int d = 6; // degree |
---|
2038 | def R = makeLetterplaceRing(d); |
---|
2039 | setring R; |
---|
2040 | ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*x(3) - z(1)*x(2)*y(3), |
---|
2041 | z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) -2*y(1)*y(2)*y(3) + 3*z(1)*z(2)*z(3) -4*x(1)*y(2)*z(3) + 5*x(1)*z(2)*z(3)- 6*x(1)*y(2)*y(3) +7*x(1)*x(2)*z(3) - 8*x(1)*x(2)*y(3); |
---|
2042 | option(prot); |
---|
2043 | option(redSB);option(redTail);option(mem); |
---|
2044 | ideal J = system("freegb",I,d,3); |
---|
2045 | lpDimCheck(J); |
---|
2046 | sickle(J,1,1,1,d); |
---|
2047 | */ |
---|
2048 | |
---|
2049 | /* |
---|
2050 | Here are some examples, which can also be found in [studzins]: |
---|
2051 | |
---|
2052 | // takes up to 880Mb of memory |
---|
2053 | LIB "fpadim.lib"; |
---|
2054 | ring r = 0,(x,y,z),dp; |
---|
2055 | int d =10; // degree |
---|
2056 | def R = makeLetterplaceRing(d); |
---|
2057 | setring R; |
---|
2058 | ideal I = |
---|
2059 | z(1)*z(2)*z(3)*z(4) + y(1)*x(2)*y(3)*x(4) - x(1)*y(2)*y(3)*x(4) - 3*z(1)*y(2)*x(3)*z(4), x(1)*x(2)*x(3) + y(1)*x(2)*y(3) - x(1)*y(2)*x(3), z(1)*y(2)*x(3)-x(1)*y(2)*z(3) + z(1)*x(2)*z(3); |
---|
2060 | option(prot); |
---|
2061 | option(redSB);option(redTail);option(mem); |
---|
2062 | ideal J = system("freegb",I,d,nvars(r)); |
---|
2063 | lpDimCheck(J); |
---|
2064 | sickle(J,1,1,1,d); // dimension is 24872 |
---|
2065 | |
---|
2066 | |
---|
2067 | LIB "fpadim.lib"; |
---|
2068 | ring r = 0,(x,y,z),dp; |
---|
2069 | int d =10; // degree |
---|
2070 | def R = makeLetterplaceRing(d); |
---|
2071 | setring R; |
---|
2072 | ideal I = x(1)*y(2) + y(1)*z(2), x(1)*x(2) + x(1)*y(2) - y(1)*x(2) - y(1)*y(2); |
---|
2073 | option(prot); |
---|
2074 | option(redSB);option(redTail);option(mem); |
---|
2075 | ideal J = system("freegb",I,d,3); |
---|
2076 | lpDimCheck(J); |
---|
2077 | sickle(J,1,1,1,d); |
---|
2078 | */ |
---|