Index: Singular/LIB/multigrading.lib
===================================================================
--- Singular/LIB/multigrading.lib	(revision 086a962ad11bef0e873f25f43c9633ad85216bdb)
+++ Singular/LIB/multigrading.lib	(revision b840b19c135b83494f50c51413afda4d052cb150)
@@ -12,13 +12,15 @@
 @*        Simon Keicher, keicher@mail.mathematik.uni-tuebingen.de
 @*        Oleksandr Motsak, U@D, where U={motsak}, D={mathematik.uni-kl.de}
-
-
-OVERVIEW: This library allows one to virtually add multigradings to Singular.
+@*        Anna-Lena Winz, anna-lena.winz@math.fu-berlin.de
+
+OVERVIEW: This library allows one to virtually add multigradings to Singular:
+grade multivariate polynomial rings with arbitrary (fin. gen. Abelian) groups. 
 For more see http://code.google.com/p/convex-singular/wiki/Multigrading
 For theoretical references see:
-E. Miller, B. Sturmfels: 'Combinatorial Commutative Algebra' and
-M. Kreuzer, L. Robbiano: 'Computational Commutative Algebra'.
-
-NOTE: 'mDegBasis' relies on 4ti2 for computing Hilbert Bases.
+@* E. Miller, B. Sturmfels: 'Combinatorial Commutative Algebra'
+and
+@* M. Kreuzer, L. Robbiano: 'Computational Commutative Algebra'.
+
+NOTE: 'multiDegBasis' relies on 4ti2 for computing Hilbert Bases.
 All groups are finitely generated Abelian
 
@@ -51,5 +53,5 @@
 latticeBasis(B);          computes an integral basis of the lattice B
 preimageLattice(P,L);     computes an integral basis for the preimage of the lattice L under the linear map P.
-projectLattices(B);       computes a linear map of lattices having the primitive span of B as its kernel.
+projectLattice(B);        computes a linear map of lattices having the primitive span of B as its kernel.
 intersectLattices(A,B);   computes an integral basis for the intersection of the lattices A and B.
 isIntegralSurjective(P);  test whether the map P of lattices is surjective.
@@ -63,7 +65,7 @@
 productgroup(G,H);        create the group G x H
 
-mDeg(A);                  compute the multidegree of A
-mDegBasis(d);             compute all monomials of multidegree d
-mDegPartition(p);         compute the multigraded-homogeneous components of p
+multiDeg(A);                  compute the multidegree of A
+multiDegBasis(d);             compute all monomials of multidegree d
+multiDegPartition(p);         compute the multigraded-homogeneous components of p
 
 isTorsionFree();          test whether the current multigrading is  free
@@ -73,12 +75,12 @@
 isHomogeneous(a);         test whether 'a' is multigraded-homogeneous
 
-equalMDeg(e1,e2[,V]);     test whether e1==e2 in the current multigrading
-
-mDegGroebner(M);          compute the multigraded GB/SB of M
-mDegSyzygy(M);            compute the multigraded syzygies of M
-mDegModulo(I,J);          compute the multigraded 'modulo' module of I and J
-mDegResolution(M,l[,m]);  compute the multigraded resolution of M
-mDegTensor(m,n);          compute the tensor product of multigraded modules m,n
-mDegTor(i,m,n);           compute the Tor_i(m,n) for multigraded modules m,n
+equalMultiDeg(e1,e2[,V]);     test whether e1==e2 in the current multigrading
+
+multiDegGroebner(M);          compute the multigraded GB/SB of M
+multiDegSyzygy(M);            compute the multigraded syzygies of M
+multiDegModulo(I,J);          compute the multigraded 'modulo' module of I and J
+multiDegResolution(M,l[,m]);  compute the multigraded resolution of M
+multiDegTensor(m,n);          compute the tensor product of multigraded modules m,n
+multiDegTor(i,m,n);           compute the Tor_i(m,n) for multigraded modules m,n
 
 defineHomogeneous(p);     get a grading group wrt which p becomes homogeneous
@@ -104,5 +106,5 @@
 LIB "standard.lib"; // for groebner
 LIB "lll.lib"; // for lll_matrix
-LIB "matrix.lib"; // for mDegTor
+LIB "matrix.lib"; // for multiDegTor
 
 /******************************************************/
@@ -174,17 +176,17 @@
   def dst = basering;
 
-  intmat result_degs = mDeg(Im);
-  print(result_degs);
+  intmat result_degs = multiDeg(Im);
+//  print(result_degs);
 
   setring src;
 
-  intmat input_degs = mDeg(maxideal(1));
-  print(input_degs);
+  intmat input_degs = multiDeg(maxideal(1));
+//  print(input_degs);
 
   def image_degs = A * input_degs;
-  print( image_degs );
+//  print( image_degs );
 
   def df = image_degs - result_degs;
-  print(df);
+//  print(df);
 
   setring dst;
@@ -245,8 +247,8 @@
   print(B);
 
-  isGradedRingHomomorphism(r, ideal(F), B);
-  def hh = createGradedRingHomomorphism(r, ideal(F), B);
-
-  if( defined(hh) ) { ERROR("That input was not valid"); }
+  isGradedRingHomomorphism(r, ideal(F), B); // FALSE: there is no such homomorphism!
+  // Therefore: the following command should return an error
+  // createGradedRingHomomorphism(r, ideal(F), B);
+
 }
 
@@ -458,5 +460,5 @@
 /******************************************************/
 proc setBaseMultigrading(intmat M, list #)
-"USAGE: setBaseMultigrading(M[, G]); M is an intege matrix, G is a group (or lattice)
+"USAGE: setBaseMultigrading(M[, G]); M is an integer matrix, G is a group (or lattice)
 PURPOSE: attaches weights of variables and grading group to the basering.
 NOTE: M encodes the weights of variables column-wise.
@@ -492,6 +494,4 @@
   if( !defined(L) ){ ERROR("Wrong arguments: no group given?"); }
 
-
-
   attrib(basering, attrMgrad, M);
   attrib(basering, attrGradingGroup, L);
@@ -502,7 +502,4 @@
     "Warning: your quotient ideal is not homogenous (multigrading was set anyway)!";
   }
-
-
-
 
 }
@@ -1009,5 +1006,5 @@
    isHomogeneous(I);
 
-   intmat V = mDeg(I); print(V);
+   intmat V = multiDeg(I); print(V);
 
    module S = syz(I); print(S);
@@ -1020,8 +1017,8 @@
    getModuleGrading(v) == V;
    isHomogeneous(v);
-   print( mDeg(v) );
+   print( multiDeg(v) );
 
    isHomogeneous(S);
-   print( mDeg(S) );
+   print( multiDeg(S) );
 }
 
@@ -1060,5 +1057,5 @@
 
    ideal I = x, y, xy^5;
-   intmat V = mDeg(I);
+   intmat V = multiDeg(I);
 
    // V == M; modulo T
@@ -1075,13 +1072,13 @@
    getModuleGrading(v) == V;
 
-   print( mDeg(v) );
+   print( multiDeg(v) );
 
    isHomogeneous(S);
 
-   print( mDeg(S) );
-}
-
-
-proc mDegTensor(module m, module n){
+   print( multiDeg(S) );
+}
+
+
+proc multiDegTensor(module m, module n){
   matrix M = m;
   matrix N = n;
@@ -1140,5 +1137,5 @@
 mm = setModuleGrading(mm, gm);
 nn = setModuleGrading(nn, gn);
-module mmtnn = mDegTensor(mm, nn);
+module mmtnn = multiDegTensor(mm, nn);
 print(mmtnn);
 getModuleGrading(mmtnn);
@@ -1159,5 +1156,5 @@
 mm = setModuleGrading(mm, gm);
 nn = setModuleGrading(nn, gn);
-module mmtnn = mDegTensor(mm, nn);
+module mmtnn = multiDegTensor(mm, nn);
 print(mmtnn);
 getModuleGrading(mmtnn);
@@ -1168,7 +1165,7 @@
 }
 
-proc mDegTor(int i, module m, module n)
-{
-  def res = mDegResolution(n, 0, 1);
+proc multiDegTor(int i, module m, module n)
+{
+  def res = multiDegResolution(n, 0, 1);
   //print(res);
   list l = res;
@@ -1189,12 +1186,12 @@
     freedim3 = setModuleGrading(freedim3, getModuleGrading(l[i]));
 
-    module mimag = mDegTensor(freedim3, m);
+    module mimag = multiDegTensor(freedim3, m);
     //"mimag ok.";
-    module mf = mDegTensor(l[i], freedim);
+    module mf = multiDegTensor(l[i], freedim);
     //"mf ok.";
-    module mim1 = mDegTensor(freedim2 ,m);
-    module mim2 = mDegTensor(l[i+1],freedim);
+    module mim1 = multiDegTensor(freedim2 ,m);
+    module mim2 = multiDegTensor(l[i+1],freedim);
     //"mim1+2 ok.";
-    module mker = mDegModulo(mf,mimag);
+    module mker = multiDegModulo(mf,mimag);
     //"mker ok.";
     module mim = mim1,mim2;
@@ -1206,5 +1203,5 @@
     //matrix mimmat1[16][4]=mimmat[1..16,25..28];
     //print(mimmat1-matrix(mim2));
-    return(mDegModulo(mker,mim));
+    return(multiDegModulo(mker,mim));
     //return(0);
   }
@@ -1219,8 +1216,8 @@
 setBaseMultigrading(g);
 ideal i = maxideal(1);
-module m = mDegSyzygy(i);
+module m = multiDegSyzygy(i);
 module rt = Tor(2,m,m);
-module mDegT = mDegTor(2,m,m);
-print(matrix(rt)-matrix(mDegT));
+module multiDegT = multiDegTor(2,m,m);
+print(matrix(rt)-matrix(multiDegT));
 /*
 ring r = 0,(x),dp;
@@ -1237,5 +1234,5 @@
 isHomogeneous(mm,"checkGens");
 isHomogeneous(nn,"checkGens");
-mDegTor(1,mm, nn);
+multiDegTor(1,mm, nn);
 
 kill m, mm, n, nn, gm, gn;
@@ -1251,5 +1248,5 @@
 mm = setModuleGrading(mm, gm);
 nn = setModuleGrading(nn, gn);
-module mmtnn = mDegTensor(mm, nn);
+module mmtnn = multiDegTensor(mm, nn);
 */
 }
@@ -1440,12 +1437,9 @@
     m= system ("LLL", m);
     list result= list();
+    intvec buf;
 
     for (i= 1; i <= sizeA; i++)
     {
-      intvec buf= intvec (m[i , 1]);
-      for (j= 2; j <= columns; j++)
-      {
-        buf= buf,intvec (m [i, j]);
-      }
+      buf = intvec (m[i , 1..columns]);
       result= result+ list (buf);
 
@@ -1726,5 +1720,5 @@
   poly f = z2;
 
- intmat m[5][2]=mDeg(a)-mDeg(b),mDeg(b)-mDeg(c),mDeg(c)-mDeg(d),mDeg(d)-mDeg(e),mDeg(e)-mDeg(f);
+ intmat m[5][2]=multiDeg(a)-multiDeg(b),multiDeg(b)-multiDeg(c),multiDeg(c)-multiDeg(d),multiDeg(d)-multiDeg(e),multiDeg(e)-multiDeg(f);
  m=transpose(m);
  areZeroElements(m);
@@ -1816,20 +1810,20 @@
   poly f = z2;
 
-  intvec v1 = mDeg(a) - mDeg(b);
+  intvec v1 = multiDeg(a) - multiDeg(b);
   v1;
   isZeroElement(v1);
   isZeroElement(v1, tt);
 
-  intvec v2 = mDeg(a) - mDeg(c);
+  intvec v2 = multiDeg(a) - multiDeg(c);
   v2;
   isZeroElement(v2);
   isZeroElement(v2, tt);
 
-  intvec v3 = mDeg(e) - mDeg(f);
+  intvec v3 = multiDeg(e) - multiDeg(f);
   v3;
   isZeroElement(v3);
   isZeroElement(v3, tt);
 
-  intvec v4 = mDeg(c) - mDeg(d);
+  intvec v4 = multiDeg(c) - multiDeg(d);
   v4;
   isZeroElement(v4);
@@ -2099,11 +2093,11 @@
 
 /******************************************************/
-proc equalMDeg(intvec exp1, intvec exp2, list #)
-"USAGE: equalMDeg(exp1, exp2[, V]); intvec exp1, exp2, intmat V
+proc equalMultiDeg(intvec exp1, intvec exp2, list #)
+"USAGE: equalMultiDeg(exp1, exp2[, V]); intvec exp1, exp2, intmat V
 PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2)
 represent the same multidegree.
 NOTE: the integer matrix V encodes multidegrees of module components,
 if module component is present in exp1 and exp2
-EXAMPLE: example equalMDeg; shows an example
+EXAMPLE: example equalMultiDeg; shows an example
 "
 {
@@ -2176,23 +2170,23 @@
 
 
-  equalMDeg(leadexp(a), leadexp(b));
-  equalMDeg(leadexp(a), leadexp(c));
-  equalMDeg(leadexp(a), leadexp(d));
-  equalMDeg(leadexp(a), leadexp(e));
-  equalMDeg(leadexp(a), leadexp(f));
-
-  equalMDeg(leadexp(b), leadexp(c));
-  equalMDeg(leadexp(b), leadexp(d));
-  equalMDeg(leadexp(b), leadexp(e));
-  equalMDeg(leadexp(b), leadexp(f));
-
-  equalMDeg(leadexp(c), leadexp(d));
-  equalMDeg(leadexp(c), leadexp(e));
-  equalMDeg(leadexp(c), leadexp(f));
-
-  equalMDeg(leadexp(d), leadexp(e));
-  equalMDeg(leadexp(d), leadexp(f));
-
-  equalMDeg(leadexp(e), leadexp(f));
+  equalMultiDeg(leadexp(a), leadexp(b));
+  equalMultiDeg(leadexp(a), leadexp(c));
+  equalMultiDeg(leadexp(a), leadexp(d));
+  equalMultiDeg(leadexp(a), leadexp(e));
+  equalMultiDeg(leadexp(a), leadexp(f));
+
+  equalMultiDeg(leadexp(b), leadexp(c));
+  equalMultiDeg(leadexp(b), leadexp(d));
+  equalMultiDeg(leadexp(b), leadexp(e));
+  equalMultiDeg(leadexp(b), leadexp(f));
+
+  equalMultiDeg(leadexp(c), leadexp(d));
+  equalMultiDeg(leadexp(c), leadexp(e));
+  equalMultiDeg(leadexp(c), leadexp(f));
+
+  equalMultiDeg(leadexp(d), leadexp(e));
+  equalMultiDeg(leadexp(d), leadexp(f));
+
+  equalMultiDeg(leadexp(e), leadexp(f));
 
 }
@@ -2222,5 +2216,5 @@
   if( (typeof(a) == "poly") or (typeof(a) == "vector") )
   {
-    return ( size(mDegPartition(a)) <= 1 )
+    return ( size(multiDegPartition(a)) <= 1 )
   }
 
@@ -2252,5 +2246,5 @@
       aa = getGradedGenerator(a, i);
 
-      b = mDegPartition(aa);
+      b = multiDegPartition(aa);
       for( j = ncols(b); j > 0; j-- )
       {
@@ -2285,6 +2279,6 @@
   poly f = x-yz;
 
-  mDegPartition(f);
-  print(mDeg(_));
+  multiDegPartition(f);
+  print(multiDeg(_));
 
   isHomogeneous(f);   // f: is not homogeneous
@@ -2292,5 +2286,5 @@
   poly g = 1-xy2z3;
   isHomogeneous(g); // g: is homogeneous
-  mDegPartition(g);
+  multiDegPartition(g);
 
   kill T;
@@ -2306,10 +2300,10 @@
   f;
   isHomogeneous(f);
-  mDegPartition(f);
+  multiDegPartition(f);
 
   // ---------------------
   g;
   isHomogeneous(g);
-  mDegPartition(g);
+  multiDegPartition(g);
 
   kill r, T, M;
@@ -2330,6 +2324,6 @@
 
   // Degree partition:
-  mDegPartition(x2 - y3 -xy +z);
-  mDegPartition(x3 -y2z + x2 -y3 + z + 1);
+  multiDegPartition(x2 - y3 -xy +z);
+  multiDegPartition(x3 -y2z + x2 -y3 + z + 1);
 
 
@@ -2341,14 +2335,14 @@
 
   v1 = setModuleGrading(N[1], V); v1;
-  mDegPartition(v1);
-  print( mDeg(_) );
+  multiDegPartition(v1);
+  print( multiDeg(_) );
 
   v2 = setModuleGrading(N[2], V); v2;
-  mDegPartition(v2);
-  print( mDeg(_) );
+  multiDegPartition(v2);
+  print( multiDeg(_) );
 
   N = setModuleGrading(N, V);
   isHomogeneous(N);
-  print( mDeg(N) );
+  print( multiDeg(N) );
 
   ///////////////////////////////////////
@@ -2359,14 +2353,14 @@
 
   v1 = setModuleGrading(N[1], V); v1;
-  mDegPartition(v1);
-  print( mDeg(_) );
+  multiDegPartition(v1);
+  print( multiDeg(_) );
 
   v2 = setModuleGrading(N[2], V); v2;
-  mDegPartition(v2);
-  print( mDeg(_) );
+  multiDegPartition(v2);
+  print( multiDeg(_) );
 
   N = setModuleGrading(N, V);
   isHomogeneous(N);
-  print( mDeg(N) );
+  print( multiDeg(N) );
 
   ///////////////////////////////////////
@@ -2379,18 +2373,18 @@
   N = setModuleGrading(N, V); print(N);
   isHomogeneous(N);
-  print( mDeg(N) );
+  print( multiDeg(N) );
   v1 = getGradedGenerator(N,1); print(v1);
-  mDegPartition(v1);
-  print( mDeg(_) );
+  multiDegPartition(v1);
+  print( multiDeg(_) );
   N = setModuleGrading(N, V); print(N);
   isHomogeneous(N);
-  print( mDeg(N) );
+  print( multiDeg(N) );
 }
 
 /******************************************************/
-proc mDeg(def A)
-"USAGE: mDeg(A); polynomial/vector/ideal/module A
+proc multiDeg(def A)
+"USAGE: multiDeg(A); polynomial/vector/ideal/module A
 PURPOSE: compute multidegree
-EXAMPLE: example mDeg; shows an example
+EXAMPLE: example multiDeg; shows an example
 "
 {
@@ -2479,5 +2473,5 @@
     for( i = ncols(A); i > 0; i-- )
     {
-      d = mDeg( A[i] );
+      d = multiDeg( A[i] );
 
       for( j = 1; j <= r; j++ ) // see ticket: 253
@@ -2499,5 +2493,5 @@
 
       // G[1..r, i]
-      d = mDeg(v);
+      d = multiDeg(v);
 
       for( j = 1; j <= r; j++ ) // see ticket: 253
@@ -2530,28 +2524,28 @@
 
 
-  mDeg( x*x, A );
-  mDeg( y*y*y, A );
+  multiDeg( x*x, A );
+  multiDeg( y*y*y, A );
 
   setBaseMultigrading(A, Ta);
 
-  mDeg( x*x*y );
-
-  mDeg( y*y*y*x );
-
-  mDeg( x*y + x + 1 );
-
-  mDegPartition(x*y + x + 1);
-
-  print ( mDeg(0) );
+  multiDeg( x*x*y );
+
+  multiDeg( y*y*y*x );
+
+  multiDeg( x*y + x + 1 );
+
+  multiDegPartition(x*y + x + 1);
+
+  print ( multiDeg(0) );
   poly zero = 0;
-  print ( mDeg(zero) );
+  print ( multiDeg(zero) );
 
 //  "ideal:";
 
   ideal I = y*x*x, x*y*y*y;
-  print( mDeg(I) );
-
-  print ( mDeg(ideal(0)) );
-  print ( mDeg(ideal(0,0,0)) );
+  print( multiDeg(I) );
+
+  print ( multiDeg(ideal(0)) );
+  print ( multiDeg(ideal(0,0,0)) );
 
 //  "vectors:";
@@ -2560,17 +2554,17 @@
   print(B);
 
-  mDeg( setModuleGrading(y*y*y*gen(2), B ));
-  mDeg( setModuleGrading(x*x*gen(1), B ));
+  multiDeg( setModuleGrading(y*y*y*gen(2), B ));
+  multiDeg( setModuleGrading(x*x*gen(1), B ));
 
 
   vector V = x*gen(1) + y*gen(2);
   V = setModuleGrading(V, B);
-  mDeg( V );
+  multiDeg( V );
 
   vector v1 = setModuleGrading([0, 0, 0], B);
-  print( mDeg( v1 ) );
+  print( multiDeg( v1 ) );
 
   vector v2 = setModuleGrading([0], B);
-  print( mDeg( v2 ) );
+  print( multiDeg( v2 ) );
 
 //  "module:";
@@ -2579,14 +2573,14 @@
   D;
   D = setModuleGrading(D, B);
-  print( mDeg( D ) );
+  print( multiDeg( D ) );
 
 
   module DD = [0, 0],[0, 0, 0];
   DD = setModuleGrading(DD, B);
-  print( mDeg( DD ) );
+  print( multiDeg( DD ) );
 
   module DDD = [0, 0];
   DDD = setModuleGrading(DDD, B);
-  print( mDeg( DDD ) );
+  print( multiDeg( DDD ) );
 
 };
@@ -2597,8 +2591,8 @@
 
 /******************************************************/
-proc mDegPartition(def p)
-"USAGE: mDegPartition(def p), p polynomial/vector
+proc multiDegPartition(def p)
+"USAGE: multiDegPartition(def p), p polynomial/vector
 RETURNS: an ideal/module consisting of multigraded-homogeneous parts of p
-EXAMPLE: example mDegPartition; shows an example
+EXAMPLE: example multiDegPartition; shows an example
 "
 { // TODO: What about an ideal or module???
@@ -2646,5 +2640,5 @@
         // TODO: we do not cache matrices (M,T,H,V), which remain the same :(
         // TODO: we need some low-level procedure with all these arguments...!
-        if( equalMDeg( leadexp(tt), m, V  ) )
+        if( equalMultiDeg( leadexp(tt), m, V  ) )
         {
           mp = mp + lead(tt); // "mp", mp;
@@ -2692,5 +2686,5 @@
   poly f = x10yz+x8y2z-x4z2+y5+x2y2-z2+x17z3-y6;
 
-  mDegPartition(f);
+  multiDegPartition(f);
 
   vector v = xy*gen(1)-x3y2*gen(2)+x4y*gen(3);
@@ -2699,5 +2693,5 @@
   getModuleGrading(v);
 
-  mDegPartition(v, B);
+  multiDegPartition(v, B);
 }
 
@@ -3054,10 +3048,10 @@
 
 /******************************************************/
-proc mDegBasis(intvec d)
+proc multiDegBasis(intvec d)
 "
 USAGE: multidegree d
 ASSUME: current ring is multigraded, monomial ordering is global
 PURPOSE: compute all monomials of multidegree d
-EXAMPLE: example mDegBasis; shows an example
+EXAMPLE: example multiDegBasis; shows an example
 "
 {
@@ -3189,10 +3183,10 @@
   intvec v3=4:1;
   v3;
-  mDegBasis(v3);
+  multiDegBasis(v3);
 
   setBaseMultigrading(g1,l);
-  mDegBasis(v1);
+  multiDegBasis(v1);
   setBaseMultigrading(g2);
-  mDegBasis(v2);
+  multiDegBasis(v2);
 
   intmat M[2][2] = 1, -1, -1, 1;
@@ -3201,8 +3195,8 @@
   setBaseMultigrading(M);
 
-  mDegBasis(d);
+  multiDegBasis(d);
   attrib(_, "ZeroPart");
 
-  kill R;
+  kill R, M, d;
   ring R = 0, (x, y, z), dp;
 
@@ -3215,9 +3209,9 @@
   setBaseMultigrading(M, L);
 
-  mDegBasis(d);
+  multiDegBasis(d);
   attrib(_, "ZeroPart");
 
 
-  kill R;
+  kill R, M, d;
 
   ring R = 0, (x, y, z), dp;
@@ -3228,13 +3222,13 @@
   //  intmat T[2][1] = 0, 2;
 
-  setBaseMultigrading(M);
+  setBaseMultigrading(M); // BUG????
 
   intvec d = 6, 6;
-  mDegBasis(d);
+  multiDegBasis(d);
   attrib(_, "ZeroPart");
 
 
 
-  kill R;
+  kill R, Q, M, d;
   ring R = 0, (x, y, z), dp;
   qring Q = std(ideal( x*z^3 - y *z^6, x*y*z  - x^4*y^2 ));
@@ -3246,17 +3240,17 @@
   intvec d = 4, 1;
 
-  setBaseMultigrading(M, T);
-
-  mDegBasis(d);
+  setBaseMultigrading(M, T); // BUG????
+
+  multiDegBasis(d);
   attrib(_, "ZeroPart");
 }
 
 
-proc mDegSyzygy(def I)
-"USAGE: mDegSyzygy(I); I is a ideal or a module
+proc multiDegSyzygy(def I)
+"USAGE: multiDegSyzygy(I); I is a ideal or a module
 PURPOSE: computes the multigraded syzygy module of I
 RETURNS: module, the syzygy module of I
 NOTE: generators of I must be multigraded homogeneous
-EXAMPLE: example mDegSyzygy; shows an example
+EXAMPLE: example multiDegSyzygy; shows an example
 "
 {
@@ -3266,5 +3260,5 @@
   }
   module S = syz(I);
-  S = setModuleGrading(S, mDeg(I));
+  S = setModuleGrading(S, multiDeg(I));
   return (S);
 }
@@ -3289,9 +3283,9 @@
 
   isHomogeneous(M);
-  "Multidegrees: "; print(mDeg(M));
+  "Multidegrees: "; print(multiDeg(M));
   // Let's compute syzygies!
-  def S = mDegSyzygy(M); S;
+  def S = multiDegSyzygy(M); S;
   "Module Units Multigrading: "; print( getModuleGrading(S) );
-  "Multidegrees: "; print(mDeg(S));
+  "Multidegrees: "; print(multiDeg(S));
 
   isHomogeneous(S);
@@ -3300,11 +3294,11 @@
 
 
-proc mDegModulo(def I, def J)
-"USAGE: mDegModulo(I); I, J are ideals or modules
+proc multiDegModulo(def I, def J)
+"USAGE: multiDegModulo(I); I, J are ideals or modules
 PURPOSE: computes the multigraded 'modulo' module of I and J
 RETURNS: module, see 'modulo' command
 NOTE: I and J should have the same multigrading, and their
 generators must be multigraded homogeneous
-EXAMPLE: example mDegModulo; shows an example
+EXAMPLE: example multiDegModulo; shows an example
 "
 {
@@ -3314,5 +3308,5 @@
   }
   module K = modulo(I, J);
-  K = setModuleGrading(K, mDeg(I));
+  K = setModuleGrading(K, multiDeg(I));
   return (K);
 }
@@ -3330,11 +3324,11 @@
   ideal h2 = x;
 
-  "Multidegrees: "; print(mDeg(h1));
+  "Multidegrees: "; print(multiDeg(h1));
 
   // Let's compute modulo(h1, h2):
-  def K = mDegModulo(h1, h2); K;
+  def K = multiDegModulo(h1, h2); K;
 
   "Module Units Multigrading: "; print( getModuleGrading(K) );
-  "Multidegrees: "; print(mDeg(K));
+  "Multidegrees: "; print(multiDeg(K));
 
   isHomogeneous(K);
@@ -3342,10 +3336,10 @@
 
 
-proc mDegGroebner(def I)
-"USAGE: mDegGroebner(I); I is a poly/vector/ideal/module
+proc multiDegGroebner(def I)
+"USAGE: multiDegGroebner(I); I is a poly/vector/ideal/module
 PURPOSE: computes the multigraded standard/groebner basis of I
 NOTE: I must be multigraded homogeneous
 RETURNS: ideal/module, the computed basis
-EXAMPLE: example mDegGroebner; shows an example
+EXAMPLE: example multiDegGroebner; shows an example
 "
 {
@@ -3389,7 +3383,7 @@
   /////////////////////////////////////////////////////////////////////////////
   // GB:
-  M = mDegGroebner(M); M;
+  M = multiDegGroebner(M); M;
   "Module Units Multigrading: "; print( getModuleGrading(M) );
-  "Multidegrees: "; print(mDeg(M));
+  "Multidegrees: "; print(multiDeg(M));
 
   isHomogeneous(M);
@@ -3397,7 +3391,7 @@
   /////////////////////////////////////////////////////////////////////////////
   // Let's compute Syzygy!
-  def S = mDegSyzygy(M); S;
+  def S = multiDegSyzygy(M); S;
   "Module Units Multigrading: "; print( getModuleGrading(S) );
-  "Multidegrees: "; print(mDeg(S));
+  "Multidegrees: "; print(multiDeg(S));
 
   isHomogeneous(S);
@@ -3405,7 +3399,7 @@
   /////////////////////////////////////////////////////////////////////////////
   // GB:
-  S = mDegGroebner(S); S;
+  S = multiDegGroebner(S); S;
   "Module Units Multigrading: "; print( getModuleGrading(S) );
-  "Multidegrees: "; print(mDeg(S));
+  "Multidegrees: "; print(multiDeg(S));
 
   isHomogeneous(S);
@@ -3414,6 +3408,6 @@
 
 /******************************************************/
-proc mDegResolution(def I, int ll, list #)
-"USAGE: mDegResolution(I,l,[f]); I is poly/vector/ideal/module; l,f are integers
+proc multiDegResolution(def I, int ll, list #)
+"USAGE: multiDegResolution(I,l,[f]); I is poly/vector/ideal/module; l,f are integers
 PURPOSE: computes the multigraded resolution of I of the length l,
 or the whole resolution if l is zero. Returns minimal resolution if an optional
@@ -3422,5 +3416,5 @@
 The returned list is truncated beginning with the first zero differential.
 RETURNS: list, the computed resolution
-EXAMPLE: example mDegResolution; shows an example
+EXAMPLE: example multiDegResolution; shows an example
 "
 {
@@ -3442,5 +3436,5 @@
     if( size(L[i]) > 0 )
     {
-      L[i] = setModuleGrading( L[i], mDeg(L[i-1]) );
+      L[i] = setModuleGrading( L[i], multiDeg(L[i-1]) );
     } else
     {
@@ -3476,5 +3470,5 @@
   for(j=1; j<=ncols(A); j++)
   {
-    mDegPartition(A[j]);
+    multiDegPartition(A[j]);
   }
 
@@ -3486,17 +3480,17 @@
 
   // Let's compute Syzygy!
-  def S = mDegSyzygy(m); S;
+  def S = multiDegSyzygy(m); S;
   "Module Units Multigrading: "; print( getModuleGrading(S) );
-  "Multidegrees: "; print(mDeg(S));
+  "Multidegrees: "; print(multiDeg(S));
 
   /////////////////////////////////////////////////////////////////////////////
 
-  S = mDegGroebner(S); S;
+  S = multiDegGroebner(S); S;
   "Module Units Multigrading: "; print( getModuleGrading(S) );
-  "Multidegrees: "; print(mDeg(S));
+  "Multidegrees: "; print(multiDeg(S));
 
   /////////////////////////////////////////////////////////////////////////////
 
-  def L = mDegResolution(m, 0, 1);
+  def L = multiDegResolution(m, 0, 1);
 
   for( j =1; j<=size(L); j++)
@@ -3505,10 +3499,10 @@
     L[j];
     "Module Multigrading: "; print( getModuleGrading(L[j]) );
-    "Multigrading: "; print(mDeg(L[j]));
+    "Multigrading: "; print(multiDeg(L[j]));
   }
 
   /////////////////////////////////////////////////////////////////////////////
 
-  L = mDegResolution(maxideal(1), 0, 1);
+  L = multiDegResolution(maxideal(1), 0, 1);
 
   for( j =1; j<=size(L); j++)
@@ -3517,5 +3511,5 @@
     L[j];
     "Module Multigrading: "; print( getModuleGrading(L[j]) );
-    "Multigrading: "; print(mDeg(L[j]));
+    "Multigrading: "; print(multiDeg(L[j]));
   }
 
@@ -3542,9 +3536,9 @@
 proc hilbertSeries(def I)
 "USAGE: hilbertSeries(I); I is poly/vector/ideal/module
-PURPOSE: computes the multigraded Hilbert Series of M
+PURPOSE: computes the multigraded Hilbert Series of I
 NOTE: input must have multigraded-homogeneous generators.
 Multigrading should be positive.
 RETURNS: a ring in variables t_(i), s_(i), with polynomials
-numerator1 and denominator1 and muturally prime numerator2
+numerator1 and denominator1 and mutually prime numerator2
 and denominator2, quotients of which give the series.
 EXAMPLE: example hilbertSeries; shows an example
@@ -3570,5 +3564,5 @@
   }
 
-  list RES = mDegResolution(I,0,1);
+  list RES = multiDegResolution(I,0,1);
 
   int l = size(RES);
@@ -3588,5 +3582,5 @@
   for( j = 1; j <= l; j++)
   {
-    L[j + 1] = mDeg(RES[j]);
+    L[j + 1] = multiDeg(RES[j]);
   }
 
@@ -3735,5 +3729,5 @@
   ideal I = x^2, y, z^3;
   I = std(I);
-  def L = mDegResolution(I, 0, 1);
+  def L = multiDegResolution(I, 0, 1);
 
   for( int j = 1; j<=size(L); j++)
@@ -3742,8 +3736,8 @@
     L[j];
     "Module Multigrading: "; print( getModuleGrading(L[j]) );
-    "Multigrading: "; print(mDeg(L[j]));
-  }
-
-  mDeg(I);
+    "Multigrading: "; print(multiDeg(L[j]));
+  }
+
+  multiDeg(I);
   def h = hilbertSeries(I); setring h;
 
@@ -4097,5 +4091,5 @@
 "
 {
-ideal I = mDegBasis(0);
+ideal I = multiDegBasis(0);
 ideal J = attrib(I,"ZeroPart");
 /*
@@ -4114,7 +4108,7 @@
   isPositive();
 
-  intmat A[1][2]=1,1;
-  setBaseMultigrading(A);
-  isPositive(A);
+  intmat B[1][2]=1,1;
+  setBaseMultigrading(B);
+  isPositive(B);
 }
 
@@ -4132,6 +4126,6 @@
 
 
-  example mDeg;
-  example mDegPartition;
+  example multiDeg;
+  example multiDegPartition;
 
 
@@ -4142,8 +4136,8 @@
   example defineHomogeneous;
 
-  example equalMDeg;
+  example equalMultiDeg;
   example isZeroElement;
 
-  example mDegResolution;
+  example multiDegResolution;
 
   "// ******************* example hilbertSeries ************************//";
@@ -4151,5 +4145,5 @@
 
 
-// example mDegBasis; // needs 4ti2!
+// example multiDegBasis; // needs 4ti2!
 
   "The End!";
@@ -4157,5 +4151,5 @@
 
 
-proc mDegTruncate(def M, intvec md)
+static proc multiDegTruncate(def M, intvec md)
 {
   "d: ";
@@ -4165,5 +4159,5 @@
   module LL = M; // + L for d+1
   LL;
-  print(mDeg(LL));
+  print(multiDeg(LL));
 
 
@@ -4180,5 +4174,5 @@
     "v[i]: "; vi;
 
-    B = mDegBasis(md - vi); // ZeroPart is always the same...
+    B = multiDegBasis(md - vi); // ZeroPart is always the same...
     "B: "; B;
 
@@ -4189,13 +4183,13 @@
 
   "L: "; L;
-  print(mDeg(L));
-
-  L = mDegModulo(L, LL);
-  L = mDegGroebner(L);
+  print(multiDeg(L));
+
+  L = multiDegModulo(L, LL);
+  L = multiDegGroebner(L);
 //  L = minbase(prune(L));
 
   "??????????";
   print(L);
-  print(mDeg(L));
+  print(multiDeg(L));
 
   V = getModuleGrading(L);
@@ -4204,5 +4198,5 @@
   for(i = ncols(L); i > 0; i-- )
   {
-    if( !equalMDeg( mDeg(getGradedGenerator(L, i)), md ) )
+    if( !equalMultiDeg( multiDeg(getGradedGenerator(L, i)), md ) )
     {
       L[i] = 0;
@@ -4213,5 +4207,5 @@
   L = setModuleGrading(L, V);
   print(L);
-  print(mDeg(L));
+  print(multiDeg(L));
 
   return(L);
@@ -4237,13 +4231,13 @@
   module h1 = x;
   h1 = setModuleGrading(h1, V);
-  mDegTruncate(h1, mDeg(x));
-  mDegTruncate(h1, mDeg(y));
+  multiDegTruncate(h1, multiDeg(x));
+  multiDegTruncate(h1, multiDeg(y));
 
   "XY:";
   module h2 = ideal(x, y);
   h2 = setModuleGrading(h2, V);
-  mDegTruncate(h2, mDeg(x));
-  mDegTruncate(h2, mDeg(y));
-  mDegTruncate(h2, mDeg(xy));
+  multiDegTruncate(h2, multiDeg(x));
+  multiDegTruncate(h2, multiDeg(y));
+  multiDegTruncate(h2, multiDeg(xy));
 }
 
@@ -4267,7 +4261,7 @@
 {
   intmat Mul = Q*L;
-  intmat L = latticeBasis(Mul);
-
-  return(L);
+  intmat LL = latticeBasis(Mul);
+
+  return(LL);
 }
 example
@@ -4532,5 +4526,6 @@
     3,6,12;
 
-  intmat B = latticeBasis(B); // should be a matrix with columns [1,2,3] and [0,3,6]
+  intmat B = latticeBasis(B); 
+  print(B); // should be a matrix with columns [1,2,3] and [0,3,6]
 
   kill B,L;
@@ -4641,12 +4636,12 @@
 
 
-  print(Con);
+//  print(Con);
 
   intmat L = kernelLattice(Con);
-
+/*
   print(L);
   print(ncols(P));
   print(ncols(L));
-
+*/
   // delete rows ncols(P)+1 to nrows(L) out of L
   intmat Del[ncols(P)][ncols(L)];
@@ -4679,8 +4674,8 @@
     0;
 
-  // should be a 2x2 matrix with columns
-  // [1,1,-1] and [-2,1,0]
   intmat L = preimageLattice(P,B);
 
+  print(L); // should be a 2x2? matrix with columns [1,1,-1] and [-2,1,0]?
+  
   kill B, P, L;
 
@@ -4723,4 +4718,7 @@
   // should be 0
   int b = isPrimitiveSublattice(A);
+  b;
+
+  if( b != 0 ){ ERROR("Sorry, something went wrong..."); }
 
   kill A,b;
@@ -4916,8 +4914,9 @@
     8,11;
 
+  intmat U = intersectLattices(A,B);
+
   // should result in a (2x4)-matrix with columns
   // [3, 3, 3], [0, 3, 6]
-  intmat U = intersectLattices(A,B);
-
+  print(U);
 }
 
@@ -5242,5 +5241,5 @@
     intmat P = intInverse(L[1]);
 
-    print(L);
+//    print(L);
 
     if ( r < m )
