source: git/Singular/LIB/pointid.lib @ 393c47

fieker-DuValspielwiese
Last change on this file since 393c47 was 341696, checked in by Hans Schönemann <hannes@…>, 15 years ago
Adding Id property to all files git-svn-id: file:///usr/local/Singular/svn/trunk@12231 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 15.9 KB
Line 
1////////////////////////////////////////////////////////////////////////////////
2version="$Id$";
3category="Commutative algebra";
4info="
5LIBRARY:  pointid.lib     Procedures for computing a factorized lex GB of
6                          the vanishing ideal of a set of points via the
7                          Axis-of-Evil Theorem (M.G. Marinari, T. Mora)
8
9AUTHOR:   Stefan Steidel, steidel@mathematik.uni-kl.de
10
11OVERVIEW:
12    The algorithm of Cerlienco-Mureddu [Marinari M.G., Mora T., A remark on a
13    remark by Macaulay or Enhancing Lazard Structural Theorem. Bull. of the
14    Iranian Math. Soc., 29 (2003), 103-145] associates to each ordered set of
15    points A:={a1,...,as} in K^n, ai:=(ai1,...,ain)@*
16          - a set of monomials N and@*
17          - a bijection phi: A --> N.
18    Here I(A):={f in K[x(1),...,x(n)] | f(ai)=0, for all 1<=i<=s} denotes the
19    vanishing ideal of A and N = Mon(x(1),...,x(n)) \ {LM(f)|f in I(A)} is the
20    set of monomials which do not lie in the leading ideal of I(A) (w.r.t. the
21    lexicographical ordering with x(n)>...>x(1)). N is also called the set of
22    non-monomials of I(A). NOTE: #A = #N and N is a monomial basis of
23    K[x(1..n)]/I(A). In particular, this allows to deduce the set of
24    corner-monomials, i.e. the minimal basis M:={m1,...,mr}, m1<...<mr, of its
25    associated monomial ideal M(I(A)), such that@*
26    M(I(A))= {k*mi | k in Mon(x(1),...,x(n)), mi in M},@*
27    and (by interpolation) the unique reduced lexicographical Groebner basis
28    G := {f1,...,fr} such that LM(fi)=mi for each i, that is, I(A)=<G>.
29    Moreover, a variation of this algorithm allows to deduce a canonical linear
30    factorization of each element of such a Groebner basis in the sense ot the
31    Axis-of-Evil Theorem by M.G. Marinari and T. Mora. More precisely, a
32    combinatorial algorithm and interpolation allow to deduce polynomials
33@*
34@*                y_mdi = x(m) - g_mdi(x(1),...,x(m-1)),
35@*
36    i=1,...,r; m=1,...,n; d in a finite index-set F, satisfying
37@*
38@*                 fi = (product of y_mdi) modulo (f1,...,f(i-1))
39@*
40    where the product runs over all m=1,...,n; and all d in F.
41
42PROCEDURES:
43 nonMonomials(id);   non-monomials of the vanishing ideal id of a set of points
44 cornerMonomials(N); corner-monomials of the set of non-monomials N
45 facGBIdeal(id);     GB G of id and linear factors of each element of G
46";
47
48LIB "poly.lib";
49
50////////////////////////////////////////////////////////////////////////////////
51
52static proc subst1(id, int m)
53{
54//id = poly/ideal/list, substitute the first m variables occuring in id by 1
55
56  int i,j;
57  def I = id;
58  if(typeof(I) == "list")
59  {
60    for(j = 1; j <= size(I); j++)
61    {
62      for(i = 1; i <= m; i++)
63      {
64        I[j] = subst(I[j],var(i),1);
65      }
66    }
67    return(I);
68  }
69  else
70  {
71    for(i = 1; i <= m; i++)
72    {
73      I = subst(I,var(i),1);
74    }
75    return(I);
76  }
77}
78
79////////////////////////////////////////////////////////////////////////////////
80
81proc nonMonomials(id)
82"USAGE:  nonMonomials(id); id = <list of vectors> or <list of lists> or <module>
83         or <matrix>.@*
84         Let A= {a1,...,as} be a set of points in K^n, ai:=(ai1,...,ain), then
85         A can be given as@*
86          - a list of vectors (the ai are vectors) or@*
87          - a list of lists (the ai are lists of numbers) or@*
88          - a module s.t. the ai are generators or@*
89          - a matrix s.t. the ai are columns
90ASSUME:  basering must have ordering rp, i.e., be of the form 0,x(1..n),rp;
91         (the first entry of a point belongs to the lex-smallest variable, etc.)
92RETURN:  ideal, the non-monomials of the vanishing ideal I(A) of A
93PURPOSE: compute the set of non-monomials Mon(x(1),...,x(n)) \ {LM(f)|f in I(A)}
94         of the vanishing ideal I(A) of the given set of points A in K^n, where
95         K[x(1),...,x(n)] is equipped with the lexicographical ordering induced
96         by x(1)<...<x(n) by using the algorithm of Cerlienco-Mureddu
97EXAMPLE: example nonMonomials; shows an example
98"
99{
100  list A;
101  int i,j;
102  if(typeof(id) == "list")
103  {
104    for(i = 1; i <= size(id); i++)
105    {
106      if(typeof(id[i]) == "list")
107      {
108        vector a;
109        for(j = 1; j <= size(id[i]); j++)
110        {
111          a = a+id[i][j]*gen(j);
112        }
113        A[size(A)+1] = a;
114        kill a;
115      }
116      if(typeof(id[i]) == "vector")
117      {
118        A[size(A)+1] = id[i];
119      }
120    }
121  }
122  else
123  {
124    if(typeof(id) == "module")
125    {
126      for(i = 1; i <= size(id); i++)
127      {
128        A[size(A)+1] = id[i];
129      }
130    }
131    else
132    {
133      if(typeof(id) == "matrix")
134      {
135        for(i = 1; i <= ncols(id); i++)
136        {
137          A[size(A)+1] = id[i];
138        }
139      }
140      else
141      {
142        ERROR("Wrong type of input!!");
143      }
144    }
145  }
146
147  int n = nvars(basering);
148  int s;
149  int m,d;
150  ideal N = 1;
151  ideal N1,N2;
152  list Y,D,W,Z;
153  poly my,t;
154  for(s = 2; s <= size(A); s++)
155  {
156
157//-- compute m = max{ j | ex. i<s: pr_j(a_i) = pr_j(a_s)} ---------------------
158//-- compute d = |{ a_i | i<s: pr_m(a_i) = pr_m(a_s), phi(a_i) in T[1,m+1]}| --
159    m = 0;
160    Y = A[1..s-1];
161    N2 = N[1..s-1];
162    while(size(Y) > 0)      //assume all points different (m <= size(basering))
163    {
164      D = Y;
165      N1 = N2;
166      Y = list();
167      N2 = ideal();
168      m++;
169      for(i = 1; i <= size(D); i++)
170      {
171        if(A[s][m] == D[i][m])
172        {
173          Y[size(Y)+1] = D[i];
174          N2[size(N2)+1] = N1[i];
175        }
176      }
177    }
178    m = m - 1;
179    d = size(D);
180    if(m < n-1)
181    {
182      for(i = 1; i <= size(N1); i++)
183      {
184        if(N1[i] >= var(m+2))
185        {
186          d = d - 1;
187        }
188      }
189    }
190
191//------- compute t = my * x(m+1)^d where my is obtained recursively --------
192    if(m == 0)
193    {
194      my = 1;
195    }
196    else
197    {
198      W = list();
199      Z = list();
200      for(i = 2; i <= s-1; i++)
201      {
202        if((leadexp(N[i])[m+1] == d) && (coeffs(N[i],var(m+1))[nrows(coeffs(N[i],var(m+1))),1] < var(m+1)))
203        {
204          W[size(W)+1] = A[i];
205          Z[size(Z)+1] = A[i][1..m];
206        }
207      }
208      W[size(W)+1] = A[s];
209      Z[size(Z)+1] = A[s][1..m];
210
211      my = nonMonomials(Z)[size(Z)];
212    }
213
214    t = my * var(m+1)^d;
215
216//---------------------------- t is added to N --------------------------------
217    N[size(N)+1] = t;
218  }
219  return(N);
220}
221example
222{ "EXAMPLE:"; echo = 2;
223   ring R1 = 0,x(1..3),rp;
224   vector a1 = [4,0,0];
225   vector a2 = [2,1,4];
226   vector a3 = [2,4,0];
227   vector a4 = [3,0,1];
228   vector a5 = [2,1,3];
229   vector a6 = [1,3,4];
230   vector a7 = [2,4,3];
231   vector a8 = [2,4,2];
232   vector a9 = [1,0,2];
233   list A = a1,a2,a3,a4,a5,a6,a7,a8,a9;
234   nonMonomials(A);
235
236   matrix MAT[9][3] = 4,0,0,2,1,4,2,4,0,3,0,1,2,1,3,1,3,4,2,4,3,2,4,2,1,0,2;
237   MAT = transpose(MAT);
238   print(MAT);
239   nonMonomials(MAT);
240
241   module MOD = gen(3),gen(2)-2*gen(3),2*gen(1)+2*gen(3),2*gen(2)-2*gen(3),gen(1)+3*gen(3),gen(1)+gen(2)+3*gen(3),gen(1)+gen(2)+gen(3);
242   print(MOD);
243   nonMonomials(MOD);
244
245   ring R2 = 0,x(1..2),rp;
246   list l1 = 0,0;
247   list l2 = 0,1;
248   list l3 = 2,0;
249   list l4 = 0,2;
250   list l5 = 1,0;
251   list l6 = 1,1;
252   list L = l1,l2,l3,l4,l5,l6;
253   nonMonomials(L);
254}
255
256////////////////////////////////////////////////////////////////////////////////
257
258proc cornerMonomials(ideal N)
259"USAGE:  cornerMonomials(N); N ideal
260ASSUME:  N is given by monomials satisfying the condition that if a monomial is
261         in N then any of its factors is in N (N is then called an order ideal)
262RETURN:  ideal, the corner-monomials of the order ideal N @*
263         The corner-monomials are the leading monomials of an ideal I s.t. N is
264         a basis of basering/I.
265NOTE:    In our applications, I is the vanishing ideal of a finte set of points.
266EXAMPLE: example cornerMonomials; shows an example
267"
268{
269  int n = nvars(basering);
270  int i,j,h;
271  list C;
272  poly m,p;
273  int Z;
274  int vars;
275  intvec v;
276  ideal M;
277
278//-------------------- Test: Is 1 in N ?, if no, return <1> ----------------------
279  for(i = 1; i <= size(N); i++)
280  {
281    if(1 == N[i])
282    {
283      h = 1;
284      break;
285    }
286  }
287  if(h == 0)
288  {
289    return(ideal(1));
290  }
291
292//----------------------------- compute the set M -----------------------------
293  for(i = 1; i <= n; i++)
294  {
295    C[size(C)+1] = list(var(i),1);
296  }
297  while(size(C) > 0)
298  {
299    m = C[1][1];
300    Z = C[1][2];
301    C = delete(C,1);
302    vars = 0;
303    v = leadexp(m);
304    for(i = 1; i <= n; i++)
305    {
306      vars = vars + (v[i] != 0);
307    }
308
309    if(vars == Z)
310    {
311      h = 0;
312      for(i = 1; i <= size(N); i++)
313      {
314        if(m == N[i])
315        {
316          h = 1;
317          break;
318        }
319      }
320
321      if(h == 0)
322      {
323        M[size(M)+1] = m;
324      }
325      else
326      {
327        for(i = 1; i <= n; i++)
328        {
329          p = m * var(i);
330          for(j = 1; j <= size(C); j++)
331          {
332            if(p <= C[j][1] || j == size(C))
333            {
334              if(p == C[j][1])
335              {
336                C[j][2] = C[j][2] + 1;
337              }
338              else
339              {
340                if(p < C[j][1])
341                {
342                  C = insert(C,list(p,1),j-1);
343                }
344                else
345                {
346                  C[size(C)+1] = list(p,1);
347                }
348              }
349              break;
350            }
351          }
352        }
353      }
354    }
355  }
356  return(M);
357}
358example
359{ "EXAMPLE:"; echo = 2;
360   ring R = 0,x(1..3),rp;
361   poly n1 = 1;
362   poly n2 = x(1);
363   poly n3 = x(2);
364   poly n4 = x(1)^2;
365   poly n5 = x(3);
366   poly n6 = x(1)^3;
367   poly n7 = x(2)*x(3);
368   poly n8 = x(3)^2;
369   poly n9 = x(1)*x(2);
370   ideal N = n1,n2,n3,n4,n5,n6,n7,n8,n9;
371   cornerMonomials(N);
372}
373
374////////////////////////////////////////////////////////////////////////////////
375
376proc facGBIdeal(id)
377"USAGE:  facGBIdeal(id); id = <list of vectors> or <list of lists> or <module>
378         or <matrix>.@*
379         Let A= {a1,...,as} be a set of points in K^n, ai:=(ai1,...,ain), then
380         A can be given as@*
381          - a list of vectors (the ai are vectors) or@*
382          - a list of lists (the ai are lists of numbers) or@*
383          - a module s.t. the ai are generators or@*
384          - a matrix s.t. the ai are columns
385ASSUME:  basering must have ordering rp, i.e., be of the form 0,x(1..n),rp;
386         (the first entry of a point belongs to the lex-smallest variable, etc.)
387RETURN:  a list where the first entry contains the Groebner basis G of I(A)
388         and the second entry contains the linear factors of each element of G
389NOTE:    combinatorial algorithm due to the Axis-of-Evil Theorem of M.G.
390         Marinari, T. Mora
391EXAMPLE: example facGBIdeal; shows an example
392"
393{
394  list A;
395  int i,j;
396  if(typeof(id) == "list")
397  {
398    for(i = 1; i <= size(id); i++)
399    {
400      if(typeof(id[i]) == "list")
401      {
402        vector a;
403        for(j = 1; j <= size(id[i]); j++)
404        {
405          a = a+id[i][j]*gen(j);
406        }
407        A[size(A)+1] = a;
408        kill a;
409      }
410      if(typeof(id[i]) == "vector")
411      {
412        A[size(A)+1] = id[i];
413      }
414    }
415  }
416  else
417  {
418    if(typeof(id) == "module")
419    {
420      for(i = 1; i <= size(id); i++)
421      {
422        A[size(A)+1] = id[i];
423      }
424    }
425    else
426    {
427      if(typeof(id) == "matrix")
428      {
429        for(i = 1; i <= ncols(id); i++)
430        {
431          A[size(A)+1] = id[i];
432        }
433      }
434      else
435      {
436        ERROR("Wrong type of input!!");
437      }
438    }
439  }
440
441  int n = nvars(basering);
442  def S = basering;
443  def R;
444
445  ideal N = nonMonomials(A);
446  ideal eN;
447  ideal M = cornerMonomials(N);
448  poly my, emy;
449
450  int d,k,l,m;
451
452  int d1;
453  poly y(1);
454
455  list N2,D,H;
456  poly z,h;
457
458  int dm;
459  list Am,Z;
460  ideal E;
461  list V,eV;
462  poly p;
463  poly y(2..n),y;
464  poly xi;
465
466  poly f;
467  ideal G1;          // stores the elements of G, i.e. G1 = G the GB of I(A)
468  ideal Y;           // stores the linear factors of GB-elements in each loop
469  list G2;           // contains the linear factors of each element of G
470
471  for(j = 1; j <= size(M); j++)
472  {
473    my = M[j];
474    emy = subst(my,var(1),1);         // auxiliary polynomial
475    eN = subst(N,var(1),1);           // auxiliary monomial ideal
476    Y = ideal();
477
478    d1 = leadexp(my)[1];
479    y(1) = 1;
480    i = 0;
481    k = 1;
482    while(i < d1)
483    {
484//---------- searching for phi^{-1}(x_1^i*x_2^d_2*...*x_n^d_n) ----------------
485      while(my*var(1)^i/var(1)^d1 != N[k])
486      {
487        k++;
488      }
489      y(1) = y(1)*(var(1)-A[k][1]);
490      Y[size(Y)+1] = cleardenom(var(1)-A[k][1]);
491      i++;
492    }
493    f = y(1);                             // gamma_1my
494
495//--------------- Recursion over number of variables --------------------------
496    z = 1;                                // zeta_mmy
497    for(m = 2; m <= n; m++)
498    {
499      z = z * y(m-1);
500
501      D = list();
502      H = list();
503      for(i = 1; i <= size(A); i++)
504      {
505        h = z;
506        for(k = 1; k <= n; k++)
507        {
508          h = subst(h,var(k),A[i][k]);
509        }
510        if(h != 0)
511        {
512          D[size(D)+1] = A[i];
513          H[size(H)+1] = i;
514        }
515      }
516
517      if(size(D) == 0)
518      {
519        break;
520      }
521
522      dm = leadexp(my)[m];
523      while(dm == 0)
524      {
525        m = m + 1;
526        dm = leadexp(my)[m];
527      }
528
529      N2 = list();                        // N2 = N_m
530      emy = subst(emy,var(m),1);
531      eN = subst(eN,var(m),1);
532      for(i = 1; i <= size(N); i++)
533      {
534        if((emy == eN[i]) && (my > N[i]))
535        {
536          N2[size(N2)+1] = N[i];
537        }
538      }
539
540      y(m) = 1;
541      xi = z;
542      for(d = 1; d <= dm; d++)
543      {
544        Am = list();
545        Z = list();                       // Z = pr_m(Am)
546
547//------- V contains all ny*x_m^{d_m-d}*x_m+1^d_m+1*...+x_n^d_n in N_m --------
548        eV = subst1(N2,m-1);
549        V = list();
550        for(i = 1; i <= size(eV); i++)
551        {
552          if(eV[i] == subst1(my,m-1)/var(m)^d)
553          {
554            V[size(V)+1] = eV[i];
555          }
556        }
557
558//------- A_m = phi^{-1}(V) intersect D_md-1 ----------------------------------
559        for(i = 1; i <= size(D); i++)
560        {
561          p = N[H[i]];
562          p = subst1(p,m-1);
563          for(l = 1; l <= size(V); l++)
564          {
565            if(p == V[l])
566            {
567              Am[size(Am)+1] = D[i];
568              Z[size(Z)+1] = D[i][1..m];
569              break;
570            }
571          }
572        }
573
574        E = nonMonomials(Z);
575
576        R = extendring(size(E), "c(", "lp");
577        setring R;
578        ideal E = imap(S,E);
579        list Am = imap(S,Am);
580        poly g = var(size(E)+m);
581        for(i = 1; i <= size(E); i++)
582        {
583          g = g + c(i)*E[i];
584        }
585
586        ideal I = ideal();
587        poly h;
588        for (i = 1; i <= size(Am); i++)
589        {
590          h = g;
591          for(k = 1; k <= n; k++)
592          {
593            h = subst(h,var(size(E)+k),Am[i][k]);
594          }
595          I[size(I)+1] = h;
596        }
597
598        ideal sI = std(I);
599        g = reduce(g,sI);
600
601        setring S;
602        y = imap(R,g);
603        Y[size(Y)+1] = cleardenom(y);
604        xi = xi * y;
605
606        D = list();
607        H = list();
608        for(i = 1; i <= size(A); i++)
609        {
610          h = xi;
611          for(k = 1; k <= n; k++)
612          {
613            h = subst(h,var(k),A[i][k]);
614          }
615          if(h != 0)
616          {
617            D[size(D)+1] = A[i];
618            H[size(H)+1] = i;
619          }
620        }
621
622        y(m) = y(m) * y;
623
624        if(size(D) == 0)
625        {
626          break;
627        }
628      }
629
630      f = f * y(m);
631    }
632    G1[size(G1)+1] = f;
633    G2[size(G2)+1] = Y;
634  }
635  return(list(G1,G2));
636}
637example
638{ "EXAMPLE:"; echo = 2;
639   ring R = 0,x(1..3),rp;
640   vector a1 = [4,0,0];
641   vector a2 = [2,1,4];
642   vector a3 = [2,4,0];
643   vector a4 = [3,0,1];
644   vector a5 = [2,1,3];
645   vector a6 = [1,3,4];
646   vector a7 = [2,4,3];
647   vector a8 = [2,4,2];
648   vector a9 = [1,0,2];
649   list A = a1,a2,a3,a4,a5,a6,a7,a8,a9;
650   facGBIdeal(A);
651
652   matrix MAT[9][3] = 4,0,0,2,1,4,2,4,0,3,0,1,2,1,3,1,3,4,2,4,3,2,4,2,1,0,2;
653   MAT = transpose(MAT);
654   print(MAT);
655   facGBIdeal(MAT);
656
657   module MOD = gen(3),gen(2)-2*gen(3),2*gen(1)+2*gen(3),2*gen(2)-2*gen(3),gen(1)+3*gen(3),gen(1)+gen(2)+3*gen(3),gen(1)+gen(2)+gen(3);
658   print(MOD);
659   facGBIdeal(MOD);
660
661   list l1 = 0,0,1;
662   list l2 = 0,1,-2;
663   list l3 = 2,0,2;
664   list l4 = 0,2,-2;
665   list l5 = 1,0,3;
666   list l6 = 1,1,3;
667   list L = l1,l2,l3,l4,l5,l6;
668   facGBIdeal(L);
669}
Note: See TracBrowser for help on using the repository browser.