source: git/Singular/LIB/deform.lib @ 7de8e4

spielwiese
Last change on this file since 7de8e4 was dc062fe, checked in by Hans Schönemann <hannes@…>, 18 years ago
*hannes: Thomas changes git-svn-id: file:///usr/local/Singular/svn/trunk@9370 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 31.7 KB
Line 
1// $Id: deform.lib,v 1.37 2006-07-31 09:11:10 Singular Exp $
2// author: Bernd Martin email: martin@math.tu-cottbus.de
3//(bm, last modified 4/98)
4///////////////////////////////////////////////////////////////////////////////
5version="$Id: deform.lib,v 1.37 2006-07-31 09:11:10 Singular Exp $";
6category="Singularities";
7info="
8LIBRARY:  deform.lib    Miniversal Deformation of Singularities and Modules
9AUTHOR:   Bernd Martin, email: martin@math.tu-cottbus.de
10
11PROCEDURES:
12 versal(Fo[,d,any])        miniversal deformation of isolated singularity Fo
13 mod_versal(Mo,I,[,d,any]) miniversal deformation of module Mo modulo ideal I
14 lift_kbase(N,M);          lifting N into standard kbase of M
15 lift_rel_kb(N,M[,kbM,p])  relative lifting N into a kbase of M
16";
17
18LIB "inout.lib";
19LIB "general.lib";
20LIB "matrix.lib";
21LIB "homolog.lib";
22LIB "sing.lib";
23///////////////////////////////////////////////////////////////////////////////
24
25proc versal (ideal Fo,list #)
26"USAGE:   versal(Fo[,d,any]); Fo=ideal, d=int, any=list
27COMPUTE: miniversal deformation of Fo up to degree d (default d=100),
28RETURN: list L of 4 rings:
29         L[1] extending the basering Po by new variables given by
30          \"A,B,..\" (deformation parameters); the new variables precede
31         the old ones, the ordering is the product of \"ls\" and \"ord(Po)\" @*
32         L[2] = L[1]/Fo extending Qo=Po/Fo, @*
33         L[3] = the embedding ring of the versal base space, @*
34         L[4] = L[1]/Js extending L[3]/Js. @*
35      In the ring L[1] the following matrices are stored:
36         @*Js  = giving the versal base space (obstructions),
37         @*Fs  = giving the versal family of Fo,
38         @*Rs  = giving the lifting of Ro=syz(Fo).
39
40      If d is defined (!=0), it computes up to degree d.
41      @*If 'any' is defined and any[1] is no string, interactive version.
42      @*Otherwise 'any' is interpreted as a list of predefined strings:
43      \"my\",\"param\",\"order\",\"out\": @*
44      (\"my\" internal prefix, \"param\" is a letter (e.g. \"A\") for the
45      name of the first parameter or (e.g. \"A(\") for index parameter
46      variables, \"order\" ordering string for ring extension), \"out\" name
47      of output file).
48NOTE:   printlevel < 0        no additional output,
49        printlevel >=0,1,2,.. informs you, what is going on;
50        this proc uses 'execute'.
51EXAMPLE:example versal; shows an example
52"
53{
54//------- prepare -------------------------------------------------------------
55  string str,@param,@order,@my,@out,@degrees;
56  int @d,d_max,@t1,t1',@t2,@colR,ok_ann,@smooth,@noObstr,@size,@j;
57  int p    = printlevel-voice+3;
58  int time = timer;
59  intvec @iv,@jv,@is_qh,@degr;
60  d_max    = 100;
61  @my = ""; @param="A"; @order="ds"; @out="no";
62  @size    = size(#);
63  if( @size>0 ) { if (#[1]>0) { d_max = #[1];} }
64  if( @size>1 )
65  { if(typeof(#[2])!="string")
66    { string @active;
67      @my,@param,@order,@out = interact1();
68    }
69    else
70    { @my = #[2];
71      if (@size>2) {@param = #[3];}
72      if (@size>3) {@order = #[4];}
73      if (@size>4) {@out   = #[5];}
74    }
75  }
76  string myPx = @my+"Px";
77  string myQx = @my+"Qx";
78  string myOx = @my+"Ox";
79  string mySo = @my+"So";
80         Fo   = simplify(Fo,10);
81  @is_qh      = qhweight(Fo);
82  int    @rowR= size(Fo);
83  def    Po   = basering;
84setring  Po;
85  poly   X_s  = product(maxideal(1));
86//-------  reproduce T_12 -----------------------------------------------------
87  list   Ls   = T_12(Fo,1);
88  matrix Ro   = Ls[6];                         // syz(i)
89  matrix InfD = Ls[5];                         // matrix of inf. deformations
90  matrix PreO = Ls[7];                         // representation of (Syz/Kos)*
91  module PreO'= std(PreO);
92  module PreT = Ls[2];                         // representation of modT_2 (sb)
93  if(dim(PreT)==0)
94  {
95    matrix kbT_2 = kbase(PreT);                 // kbase of T_2
96  }
97  else
98  {
99    matrix kbT_2 ;                              // kbase of T_2 : empty
100  }
101  @t1 = Ls[3];                                 // vdim of T_1
102  @t2 = Ls[4];                                 // vdim of T_2
103  kill Ls;
104  t1' = @t1;
105  if( @t1==0) { dbprint(p,"// rigid!"); return(list());}
106  if( @t2==0) { @smooth=1; dbprint(p,"// smooth base space");}
107  dbprint(p,"// ready: T_1 and T_2");
108  @colR = ncols(Ro);
109//-----  test: quasi-homogeneous, choice of inf. def.--------------------------
110  @degrees = homog_test(@is_qh,matrix(Fo),InfD);
111  @jv = 1..@t1;
112  if (@degrees!="")
113  { dbprint(p-1,"// T_1 is quasi-homogeneous represented with weight-vector",
114    @degrees);
115  }
116  if (defined(@active))
117  { "// matrix of infinitesimal deformations:";print(InfD);
118    "// weights of infinitesimal deformations (  empty ='not qhomog'):";
119     @degrees;
120     matrix dummy;
121     InfD,dummy,t1' = interact2(InfD,@jv);kill dummy;
122  }
123 //---- create new rings and objects ------------------------------------------
124  list list_of_rings=get_rings(Fo,t1',1,@order,@param);
125  def `myPx`= list_of_rings[1];
126  def `myQx`= list_of_rings[2];
127  def `myOx`= list_of_rings[3];
128  def `mySo`= list_of_rings[4];
129  kill list_of_rings;
130  setring `myPx`;
131  @jv=0; @jv[t1']=0; @jv=@jv+1; @jv[nvars(basering)]=0;
132                                               //weight-vector for calculating
133                                               //rel-jet with resp to def-para
134  ideal  Io   = imap(Po,Fo);
135  ideal  J,m_J,tid;     attrib(J,"isSB",1);
136  matrix Fo   = matrix(Io);                   //initial equations
137  matrix homF = kohom(Fo,@colR);
138  matrix Ro   = imap(Po,Ro);
139  matrix homR = transpose(Ro);
140  matrix homFR= concat(homR,homF);
141  module hom' = std(homFR);
142  matrix Js[1][@t2];
143  matrix F_R,Fs,Rs,Fn,Rn;
144  export Js,Fs,Rs;
145  matrix Mon[t1'][1]=maxideal(1);
146  Fn  = transpose(imap(Po,InfD)*Mon);         //infinitesimal deformations
147  Fs  = Fo + Fn;
148  dbprint(p-1,"// infinitesimal deformation: Fs: ",Fs);
149  Rn  = (-1)*lift(Fo,Fs*Ro);                  //infinit. relations
150  Rs  = Ro + Rn;
151  F_R = Fs*Rs;
152  tid = 0 + ideal(F_R);
153  if (tid[1]==0) {d_max=1;}                   //finished ?
154 setring `myOx`;
155  matrix Fs,Rs,Cup,Cup',F_R,homFR,New,Rn,Fn;
156  module hom';
157  ideal  null,tid;  attrib(null,"isSB",1);
158 setring `myQx`;
159  poly X_s = imap(Po,X_s);
160  matrix Cup,Cup',MASS;
161  ideal  tid,null;               attrib(null,"isSB",1);
162  ideal  J,m_J;                  attrib(J,"isSB",1);
163                                 attrib(m_J,"isSB",1);
164  matrix PreO = imap(Po,PreO);
165  module PreO'= imap(Po,PreO');  attrib(PreO',"isSB",1);
166  module PreT = imap(Po,PreT);   attrib(PreT,"isSB",1);
167  matrix kbT_2 = imap(Po,kbT_2);
168  matrix Mon  = fetch(`myPx`,Mon);
169  matrix F_R  = fetch(`myPx`,F_R);
170  matrix Js[1][@t2];
171//------- start the loop ------------------------------------------------------
172   for (@d=2;@d<=d_max;@d=@d+1)
173   {
174     if( @t1==0) {break};
175     dbprint(p,"// start computation in degree "+string(@d)+".");
176     dbprint(p-3,">>> TIME = "+string(timer-time));
177     dbprint(p-3,"==> memory = "+string(kmemory())+"k");
178//------- compute obstruction-vector  -----------------------------------------
179     if (@smooth) { @noObstr=1;}
180     else
181     { Cup = jet(F_R,@d,@jv);
182       Cup = matrix(reduce(ideal(Cup),m_J),@colR,1);
183       Cup = jet(Cup,@d,@jv);
184     }
185//------- express obstructions in kbase of T_2  -------------------------------
186     if ( @noObstr==0 )
187     {  Cup' = reduce(Cup,PreO');
188        tid  = simplify(ideal(Cup'),10);
189        if(tid[1]!=0)
190        {  dbprint(p-4,"// *");
191           Cup=Cup-Cup';
192        }
193        Cup   = lift(PreO,Cup);
194        MASS  = lift_rel_kb(Cup,PreT,kbT_2,X_s);
195        dbprint(p-3,"// next MASSEY-products:",MASS-jet(MASS,@d-1,@jv));
196        if    (MASS==transpose(Js))
197              { @noObstr=1;dbprint(p-1,"// no obstruction"); }
198         else { @noObstr=0; }
199      }
200//------- obtain equations of base space --------------------------------------
201      if ( @noObstr==0 )
202      { Js = transpose(MASS);
203        dbprint(p-2,"// next equation of base space:",
204        simplify(ideal(Js),10));
205 setring `myPx`;
206        Js   = imap(`myQx`,Js);
207      degBound = @d+1;
208        J    = std(ideal(Js));
209        m_J  = std(J*ideal(Mon));
210      degBound = 0;
211//--------------- obtain new base-ring ----------------------------------------
212        if(defined(`myOx`)) {kill `myOx`;}
213  qring `myOx` = J;
214        matrix Fs,Rs,F_R,Cup,Cup',homFR,New,Rn,Fn;
215        module hom';
216        ideal  null,tid;  attrib(null,"isSB",1);
217      }
218//---------------- lift equations F and relations R ---------------------------
219 setring `myOx`;
220      Fs    = fetch(`myPx`,Fs);
221      Rs    = fetch(`myPx`,Rs);
222      F_R   = Fs*Rs;
223      F_R   = matrix(reduce(ideal(F_R),null));
224      tid   = 0 + ideal(F_R);
225      if (tid[1]==0) { dbprint(p-1,"// finished"); break;}
226      Cup   = (-1)*transpose(jet(F_R,@d,@jv));
227      homFR = fetch(`myPx`,homFR);
228      hom'  = fetch(`myPx`,hom');  attrib(hom',"isSB",1);
229      Cup'  = simplify(reduce(Cup,hom'),10);
230      tid   = simplify(ideal(Cup'),10);
231      if (tid[1]!=0)
232      {  dbprint(p-4,"// #");
233         Cup=Cup-Cup';
234      }
235      New   = lift(homFR,Cup);
236      Rn    = matrix(ideal(New[1+@rowR..nrows(New),1]),@rowR,@colR);
237      Fn    = matrix(ideal(New[1..@rowR,1]),1,@rowR);
238      Fs    = Fs+Fn;
239      Rs    = Rs+Rn;
240      F_R   = Fs*Rs;
241      tid   = 0+reduce(ideal(F_R),null);
242//---------------- fetch results into other rings -----------------------------
243  setring `myPx`;
244      Fs    = fetch(`myOx`,Fs);
245      Rs    = fetch(`myOx`,Rs);
246      F_R   = Fs*Rs;
247  setring `myQx`;
248      F_R = fetch(`myPx`,F_R);
249      m_J = fetch(`myPx`,m_J);  attrib(m_J,"isSB",1);
250      J   = fetch(`myPx`,J);    attrib(J,"isSB",1);
251      Js  = fetch(`myPx`,Js);
252      tid = fetch(`myOx`,tid);
253      if (tid[1]==0) { dbprint(p-1,"// finished");break;}
254   }
255//---------  end loop and final output ----------------------------------------
256  setring `myPx`;
257   if (@out!="no")
258   {  string out = @out+"_"+string(@d);
259      "// writing file "+out+" with matrix Js, matrix Fs, matrix Rs ready
260      for reading in rings "+myPx+" or "+myQx;
261      write(out,"matrix Js[1][",@t2,"]=",Js,";matrix Fs[1][",@rowR,"]=",Fs,
262      ";matrix Rs[",@rowR,"][",@colR,"]=",Rs,";");
263   }
264   dbprint(p-3,">>> TIME = "+string(timer-time));
265   if (@is_qh != 0)
266   { @degr = qhweight(ideal(Js));
267     @degr = @degr[1..t1'];
268     dbprint(p-1,"// quasi-homogeneous weights of miniversal base",@degr);
269   }
270   dbprint(p-1,
271   "// ___ Equations of miniversal base space ___",Js,
272   "// ___ Equations of miniversal total space ___",Fs);
273   dbprint(p,"","
274// 'versal' returned a list, say L, of four rings. In L[1] are stored:
275//   as matrix Fs: Equations of total space of the miniversal deformation,
276//   as matrix Js: Equations of miniversal base space,
277//   as matrix Rs: syzygies of Fs mod Js.
278// To access these data, type
279     def Px=L[1]; setring Px; print(Fs); print(Js); print(Rs);
280
281// L[2] = L[1]/Fo extending Qo=Po/Fo,
282// L[3] = the embedding ring of the versal base space,
283// L[4] = L[1]/Js extending L[3]/Js.
284");
285   return(list(`myPx`,`myQx`,`mySo`,`myOx`));
286}
287example
288{ "EXAMPLE:"; echo = 2;
289   int p          = printlevel;
290   printlevel     = 0;
291   ring r1        = 0,(x,y,z,u,v),ds;
292   matrix m[2][4] = x,y,z,u,y,z,u,v;
293   ideal Fo       = minor(m,2);
294                    // cone over rational normal curve of degree 4
295   list L=versal(Fo);
296   L;
297   def Px=L[1];
298   setring Px;
299   // ___ Equations of miniversal base space ___:
300   Js;"";
301   // ___ Equations of miniversal total space ___:
302   Fs;"";
303}
304///////////////////////////////////////////////////////////////////////////////
305
306proc mod_versal(matrix Mo, ideal I, list #)
307"USAGE:   mod_versal(Mo,Io[,d,any]); Io=ideal, Mo=module, d=int, any =list
308COMPUTE: miniversal deformation of coker(Mo) over Qo=Po/Io, Po=basering;
309RETURN:  list L of 4 rings:
310         L[1] extending the basering Po by new variables given by
311          \"A,B,..\" (deformation parameters); the new variables precede
312         the old ones, the ordering is the product of \"ls\" and \"ord(Po)\" @*
313         L[2] = L[1]/Io extending Qo, @*
314         L[3] = the embedding ring of the versal base space, @*
315         L[4] = L[1]/(Io+Js) ring of the versal deformation of coker(Ms). @*
316      In the ring L[1] the following matrices are stored:
317         @*Js  = giving the versal base space (obstructions),
318         @*Fs  = giving the versal family of Mo,
319         @*Rs  = giving the lifting of syzygies Lo=syz(Mo).
320      If d is defined (!=0), it computes up to degree d.
321      @*If 'any' is defined and any[1] is no string, interactive version.
322      @*Otherwise 'any' is interpreted as a list of predefined strings:
323      \"my\",\"param\",\"order\",\"out\": @*
324      (\"my\" internal prefix, \"param\" is a letter (e.g. \"A\") for the
325      name of the first parameter or (e.g. \"A(\") for index parameter
326      variables, \"order\" ordering string for ring extension), \"out\" name
327      of output file).
328NOTE:   printlevel < 0        no additional output,
329        printlevel >=0,1,2,.. informs you, what is going on,
330        this proc uses 'execute'.
331EXAMPLE:example mod_versal; shows an example
332"
333{
334//------- prepare -------------------------------------------------------------
335  intvec save_opt=option(get);
336  option(cancelunit);
337  string str,@param,@order,@my,@out,@degrees;
338  int @d,d_max,f0,f1,f2,e1,e1',e2,ok_ann,@smooth,@noObstr,@size,@j;
339  int p    = printlevel-voice+3;
340  int time = timer;
341  intvec @iv,@jv,@is_qh,@degr;
342  d_max    = 100;
343  @my = ""; @param="A"; @order="ds"; @out="no";
344  @size = size(#);
345  if( @size>0 ) { d_max = #[1]; }
346  if( @size>1 )
347  { if(typeof(#[2])!="string")
348    { string @active;
349      @my,@param,@order,@out = interact1();
350    }
351    else
352    { @my = #[2];
353      if (@size>2) {@param = #[3];}
354      if (@size>3) {@order = #[4];}
355      if (@size>4) {@out   = #[5];}
356    }
357  }
358  string myPx = @my+"Px";
359  string myQx = @my+"Qx";
360  string myOx = @my+"Ox";
361  string mySo = @my+"So";
362  @is_qh      = qhweight(I);
363  def    Po   = basering;
364 setring Po;
365  poly   X_s = product(maxideal(1));
366//-------- compute Ext's ------------------------------------------------------
367         I   = std(I);
368 qring   Qo  = I;
369  matrix Mo  = fetch(Po,Mo);
370  list   Lo  = compute_ext(Mo,p);
371         f0,f1,f2,e1,e2,ok_ann=Lo[1];
372  matrix Ls,kb1,lift1 = Lo[2],Lo[3],Lo[4];
373  matrix kb2,C',D' = Lo[5][2],Lo[5][3],Lo[5][5];
374  module ex2,Co,Do = Lo[5][1],Lo[5][4],Lo[5][6];
375  kill Lo;
376  dbprint(p,"// ready: Ext1 and Ext2");
377//-----  test: quasi-homogeneous, choice of inf. def.--------------------------
378  @degrees = homog_test(@is_qh,Mo,kb1);
379  e1' = e1;  @jv = 1..e1;
380  if (@degrees != "")
381  { dbprint(p-1,"// Ext1 is quasi-homogeneous represented: "+@degrees);
382  }
383  if (defined(@active))
384  { "// kbase of Ext1:";
385    print(kb1);
386    "// weights of kbase of Ext1 ( empty = 'not qhomog')";@degrees;
387    kb1,lift1,e1' = interact2(kb1,@jv,lift1);
388  }
389//-------- get new rings and objects ------------------------------------------
390 setring Po;
391  list list_of_rings=get_rings(I,e1',0,@order,@param);
392  def `myPx`= list_of_rings[1];
393  def `myQx`= list_of_rings[2];
394  def `myOx`= list_of_rings[3];
395  def `mySo`= list_of_rings[4];
396  kill list_of_rings;
397 setring `myPx`;
398  ideal  J,m_J;
399  ideal  I_J  = imap(Po,I);
400  ideal  Io   = I_J;
401  matrix Mon[e1'][1] = maxideal(1);
402  matrix Ms   = imap(Qo,Mo);
403  matrix Ls   = imap(Qo,Ls);
404  matrix Js[1][e2];
405 setring `myQx`;
406  ideal  J,I_J,tet,null;              attrib(null,"isSB",1);
407  ideal  m_J  = fetch(`myPx`,m_J);   attrib(m_J,"isSB",1);
408  @jv=0;  @jv[e1] = 0; @jv = @jv+1;   @jv[nvars(`myPx`)] = 0;
409  matrix Ms   = imap(Qo,Mo);          export(Ms);
410  matrix Ls   = imap(Qo,Ls);          export(Ls);
411  matrix Js[e2][1];                   export(Js);
412  matrix MASS;
413  matrix Mon  = fetch(`myPx`,Mon);
414  matrix Mn,Ln,ML,Cup,Cup',Lift;
415  matrix C'   = imap(Qo,C');
416  module Co   = imap(Qo,Co);          attrib(Co,"isSB",1);
417  module ex2  = imap(Qo,ex2);         attrib(ex2,"isSB",1);
418  matrix D'   = imap(Qo,D');
419  module Do   = imap(Qo,Do);          attrib(Do,"isSB",1);
420  matrix kb2  = imap(Qo,kb2);
421  matrix kb1  = imap(Qo,kb1);
422  matrix lift1= imap(Qo,lift1);
423  poly   X_s  = imap(Po,X_s);
424  intvec intv = e1',e1,f0,f1,f2;
425         Ms,Ls= get_inf_def(Ms,Ls,kb1,lift1,X_s);
426  kill   kb1,lift1;
427  dbprint(p-1,"// infinitesimal extension",Ms);
428//----------- start the loop --------------------------------------------------
429  for (@d=2;@d<=d_max;@d=@d+1)
430  {
431    dbprint(p-3,">>> time = "+string(timer-time));
432    dbprint(p-3,"==> memory = "+string(memory(0)/1000)+
433                ",  allocated = "+string(memory(1)/1000));
434    dbprint(p,"// start deg = "+string(@d));
435//-------- get obstruction ----------------------------------------------------
436    Cup  = matrix(ideal(Ms*Ls),f0*f2,1);
437    Cup  = jet(Cup,@d,@jv);
438    Cup  = reduce(ideal(Cup),m_J);
439    Cup  = jet(Cup,@d,@jv);
440//-------- express obstruction in kbase ---------------------------------------
441    Cup' = reduce(Cup,Do);
442    tet  = simplify(ideal(Cup'),10);
443    if (tet[1]!=0)
444    { dbprint(p-4,"// *");
445      Cup = Cup-Cup';
446    }
447    Cup  = lift(D',Cup);
448    if (ok_ann)
449    { MASS = lift_rel_kb(Cup,ex2,kb2,X_s);}
450    else
451    { MASS = reduce(Cup,ex2);}
452    dbprint(p-3,"// next MATRIC-MASSEY-products",
453    MASS-jet(MASS,@d-1,@jv));
454    if   ( MASS==transpose(Js))
455         { @noObstr = 1;dbprint(p-1,"//no obstruction"); }
456    else { @noObstr = 0; }
457//-------- obtain equations of base space -------------------------------------
458    if (@noObstr == 0)
459    { Js = MASS;
460      dbprint(p-2,"// next equation of base space:",simplify(ideal(Js),10));
461 setring `myPx`;
462      Js = imap(`myQx`,Js);
463     degBound=@d+1;
464      J   = std(ideal(Js));
465      m_J = std(ideal(Mon)*J);
466     degBound=0;
467      I_J = Io,J;                attrib(I_J,"isSB",1);
468//-------- obtain new base ring -----------------------------------------------
469      if (defined(`myOx`)) {kill `myOx`;}
470 qring `myOx` = I_J;
471      ideal null,tet;            attrib(null,"isSB",1);
472      matrix Ms  = imap(`myQx`,Ms);
473      matrix Ls  = imap(`myQx`,Ls);
474      matrix Mn,Ln,ML,Cup,Cup',Lift;
475      matrix C'  = imap(Qo,C');
476      module Co  = imap(Qo,Co);   attrib(Co,"isSB",1);
477      module ex2 = imap(Qo,ex2);  attrib(ex2,"isSB",1);
478      matrix kb2 = imap(Qo,kb2);
479      poly   X_s = imap(Po,X_s);
480    }
481//-------- get lifts ----------------------------------------------------------
482   setring `myOx`;
483    ML  = matrix(reduce(ideal(Ms*Ls),null),f0,f2);
484    Cup = matrix(ideal(ML),f0*f2,1);
485    Cup = jet(Cup,@d,@jv);
486    Cup'= reduce(Cup,Co);
487    tet = simplify(ideal(Cup'),10);
488    if (tet[1]!=0)
489    { dbprint(p-4,"// #");
490     Cup = Cup-Cup';
491    }
492    Lift = lift(C',Cup);
493    Mn   = matrix(ideal(Lift),f0,f1);
494    Ln   = matrix(ideal(Lift[f0*f1+1..nrows(Lift),1]),f1,f2);
495    Ms   = Ms-Mn;
496    Ls   = Ls-Ln;
497    dbprint(p-3,"// next extension of Mo",Mn);
498    dbprint(p-3,"// next extension of syz(Mo)",Ln);
499    ML   = reduce(ideal(Ms*Ls),null);
500//--------- test: finished ----------------------------------------------------
501    tet  = simplify(ideal(ML),10);
502    if (tet[1]==0) { dbprint(p-1,"// finished in degree ",@d);}
503//---------fetch results into Qx and Px ---------------------------------------
504   setring `myPx`;
505    Ms   = fetch(`myOx`,Ms);
506    Ls   = fetch(`myOx`,Ls);
507   setring `myQx`;
508    Ms   = fetch(`myOx`,Ms);
509    Ls   = fetch(`myOx`,Ls);
510    ML   = Ms*Ls;
511    ML   = matrix(reduce(ideal(ML),null),f0,f2);
512    tet  = imap(`myOx`,tet);
513    if (tet[1]==0) { break;}
514  }
515//------- end of loop, final output -------------------------------------------
516  if (@out != "no")
517  { string out = @out+"_"+string(@d);
518    "// writing file '"+out+"' with matrix Js, matrix Ms, matrix Ls
519    ready for reading in rings "+myPx+" or "+myQx;
520    write(out,"matrix Js[1][",e2,"]=",Js,";matrix Ms[",f0,"][",f1,"]=",Ms,
521    ";matrix Ls[",f1,"][",f2,"]=",Ls,";");
522  }
523  dbprint(p-3,">>> TIME = "+string(timer-time));
524  if (@is_qh != 0)
525  { @degr = qhweight(ideal(Js));
526    @degr = @degr[1..e1'];
527    dbprint(p-1,"// quasi-homogeneous weights of miniversal base",@degr);
528  }
529  dbprint(p,"
530// 'mod_versal' returned a list, say L, of four rings. In L[2] are stored:
531//   as matrix Ms: presentation matrix of the deformed module,
532//   as matrix Ls: lifted syzygies,
533//   as matrix Js:  Equations of total space of miniversal deformation
534// To access these data, type
535     def Qx=L[2]; setring Qx; print(Ms); print(Ls); print(Js);
536");
537  option(set,save_opt);
538  return(list(`myPx`,`myQx`,`mySo`,`myOx`));
539}
540example
541{ "EXAMPLE:"; echo = 2;
542  int p = printlevel;
543  printlevel = 1;
544  ring  Ro = 0,(x,y),wp(3,4);
545  ideal Io = x4+y3;
546  matrix Mo[2][2] = x2,y,-y2,x2;
547  list L = mod_versal(Mo,Io);
548  def Qx=L[2]; setring Qx;
549  print(Ms);
550  print(Ls);
551  print(Js);
552  printlevel = p;
553  if (defined(Px)) {kill Px,Qx,So;}
554}
555///////////////////////////////////////////////////////////////////////////////
556proc kill_rings(list #)
557"USAGE: kill_rings([string]);
558RETURN: nothing, but kills exported rings generated by procedures
559        'versal' and 'mod_versal' with optional prefix 'string'
560NOTE: obsolete
561"
562{
563  string my,br;
564  if (size(#)>0)     { my = #[1];}
565  string na=nameof(basering);
566  br = my+"Qx";
567  if (defined(`br`)) { kill `br`;}
568  br = my+"Px";
569  if (defined(`br`)) { kill `br`;}
570  br = my+"So";
571  if (defined(`br`)) { kill `br`;}
572  br = my+"Ox";
573  if (defined(`br`)) { kill `br`;}
574  br = my+"Sx";
575  if (defined(`br`)) { kill `br`}
576  if(system("with","Namespaces"))
577  {
578    br = my+"Qx";
579    if (defined(Top::`br`)) { kill Top::`br`;}
580    br = my+"Ox";
581    if (defined(Top::`br`)) { kill Top::`br`;}
582    br = my+"Px";
583    if (defined(Ring::`br`)) { kill Ring::`br`;}
584    br = my+"So";
585    if (defined(Ring::`br`)) { kill Ring::`br`;}
586  }
587  if (defined(basering)==0)
588  { "// choose new basering?";
589    if(system("with","Namespaces")) { listvar(Top,ring); }
590    else { listvar(ring); }
591  }
592  return();
593}
594///////////////////////////////////////////////////////////////////////////////
595proc compute_ext(matrix Mo,int p)
596"
597Sub-procedure: obtain Ext1 and Ext2 and other objects used by mod_versal
598"
599{
600   int    l,f0,f1,f2,f3,e1,e2,ok_ann;
601   module Co,Do,ima,ex1,ex2;
602   matrix M0,M1,M2,ker,kb1,lift1,kb2,A,B,C,D;
603//------- resM ---------------------------------------------------------------
604   list resM = nres(Mo,3);
605   M0 = resM[1];
606   M1 = resM[2];
607   M2 = resM[3];   kill resM;
608   f0 = nrows(M0);
609   f1 = ncols(M0);
610   f2 = ncols(M1);
611   f3 = ncols(M2);
612//------ compute Ext^2  ------------------------------------------------------
613   B    = kohom(M0,f3);
614   A    = kontrahom(M2,f0);
615   D    = modulo(A,B);
616   Do   = std(D);
617   ima  = kohom(M0,f2),kontrahom(M1,f0);
618   ex2  = modulo(D,ima);
619   ex2  = std(ex2);
620   e2   = vdim(ex2);
621   kb2  = kbase(ex2);
622      dbprint(p,"// vdim (Ext^2) = "+string(e2));
623//------ test: max = Ann(Ext2) -----------------------------------------------
624   for (l=1;l<=e2;l=l+1)
625   { ok_ann = ok_ann+ord(kb2[l]);
626   }
627   if (ok_ann==0)
628   {  e2 =nrows(ex2);
629      dbprint(p,"// Ann(Ext2) is maximal");
630   }
631//------ compute Ext^1 -------------------------------------------------------
632   B     = kohom(M0,f2);
633   A     = kontrahom(M1,f0);
634   ker   = modulo(A,B);
635   ima   = kohom(M0,f1),kontrahom(M0,f0);
636   ex1   = modulo(ker,ima);
637   ex1   = std(ex1);
638   e1    = vdim(ex1);
639      dbprint(p,"// vdim (Ext^1) = "+string(e1));
640   kb1   = kbase(ex1);
641   kb1   = ker*kb1;
642   C     = concat(A,B);
643   Co    = std(C);
644//------ compute the liftings of Ext^1 ---------------------------------------
645   lift1 = A*kb1;
646   lift1 = lift(B,lift1);
647   intvec iv = f0,f1,f2,e1,e2,ok_ann;
648   list   L' = ex2,kb2,C,Co,D,Do;
649   return(iv,M1,kb1,lift1,L');
650}
651///////////////////////////////////////////////////////////////////////////////
652static proc get_rings(ideal Io,int e1,int switch, list #)
653"
654Sub-procedure: creating ring-extensions, returned as a list of 4 rings
655"
656{
657   def Po = basering;
658   string my;
659   string my_ord = "ds";
660   string my_var = "A";
661   if (size(#)>1)
662   {
663     my_ord = #[1];
664     my_var = #[2];
665   }
666   def my_Px=extendring(e1,my_var,my_ord);
667   setring my_Px;
668   ideal Io  = imap(Po,Io);
669   attrib(Io,"isSB",1);
670   qring my_Qx = Io;
671   if (switch)
672   {
673     setring my_Px;
674     qring my_Ox = std(ideal(0));
675   }
676   else
677   {
678     def my_Ox = my_Qx;
679   }
680   def my_So=defring(charstr(Po),e1,my_var,my_ord);
681   setring my_So;
682   list erg=list(my_Px,my_Qx,my_Ox,my_So);
683   return(erg);
684}
685///////////////////////////////////////////////////////////////////////////////
686proc get_inf_def(list #)
687"
688Sub-procedure: compute infinitesimal family of a module and its syzygies
689               from a kbase of Ext1 and its lifts
690"
691{
692  matrix Ms  = #[1];
693  matrix Ls  = #[2];
694  matrix kb1 = #[3];
695  matrix li1 = #[4];
696  int   e1,f0,f1,f2;
697  poly X_s     = #[5];
698  e1 = ncols(kb1);
699  f0 = nrows(Ms);
700  f1 = nrows(Ls);
701  f2 = ncols(Ls);
702  int  l;
703  for (l=1;l<=e1;l=l+1)
704  {
705     Ms = Ms + var(l)*matrix(ideal(kb1[l]),f0,f1);
706     Ls = Ls - var(l)*matrix(ideal(li1[l]),f1,f2);
707  }
708  return(Ms,Ls);
709}
710//////////////////////////////////////////////////////////////////////////////
711proc lift_rel_kb (module N, module M, list #)
712"USAGE:   lift_rel_kb(N,M[,kbaseM,p]);
713ASSUME:  [p a monomial ] or the product of all variables
714         N, M modules of same rank, M depending only on variables not in p
715         and vdim(M) is finite in this ring,
716         [ kbaseM the kbase of M in the subring given by variables not in p ] @*
717         warning: these assumptions are not checked by the procedure
718RETURN:  matrix A, whose j-th columns present the coeff's of N[j] in kbaseM,
719         i.e. kbaseM*A = reduce(N,std(M))
720EXAMPLE: example lift_rel_kb;  shows examples
721"
722{
723  poly p = product(maxideal(1));
724       M = std(M);
725  matrix A;
726  if (size(#)>0) { p=#[2]; module kbaseM=#[1];}
727  else
728  { if (vdim(M)<=0) { "// vdim(M) not finite";return(A);}
729    module kbaseM = kbase(M);
730  }
731  N = reduce(N,M);
732  if (simplify(N,10)[1]==[0]) {return(A);}
733  A = coeffs(N,kbaseM,p);
734  return(A);
735}
736example
737{
738  "EXAMPLE:"; echo=2;
739  ring r=0,(A,B,x,y),dp;
740  module M      = [x2,xy],[xy,y3],[y2],[0,x];
741  module kbaseM = [1],[x],[xy],[y],[0,1],[0,y],[0,y2];
742  poly f=xy;
743  module N = [AB,BBy],[A3xy+x4,AB*(1+y2)];
744  matrix A = lift_rel_kb(N,M,kbaseM,f);
745  print(A);
746  "TEST:";
747  print(matrix(kbaseM)*A-matrix(reduce(N,std(M))));
748}
749///////////////////////////////////////////////////////////////////////////////
750proc lift_kbase (N, M)
751"USAGE:   lift_kbase(N,M); N,M=poly/ideal/vector/module
752RETURN:  matrix A, coefficient matrix expressing N as linear combination of
753         k-basis of M. Let the k-basis have k elements and size(N)=c columns.
754         Then A satisfies:
755             matrix(reduce(N,std(M)),k,c) = matrix(kbase(std(M)))*A
756ASSUME:  dim(M)=0 and the monomial ordering is a well ordering or the last
757         block of the ordering is c or C
758EXAMPLE: example lift_kbase; shows an example
759"
760{
761  return(lift_rel_kb(N,M));
762}
763example
764{"EXAMPLE:";     echo=2;
765  ring R=0,(x,y),ds;
766  module M=[x2,xy],[y2,xy],[0,xx],[0,yy];
767  module N=[x3+xy,x],[x,x+y2];
768  print(M);
769  module kb=kbase(std(M));
770  print(kb);
771  print(N);
772  matrix A=lift_kbase(N,M);
773  print(A);
774  matrix(reduce(N,std(M)),nrows(kb),ncols(A)) - matrix(kbase(std(M)))*A;
775}
776
777
778///////////////////////////////////////////////////////////////////////////////
779proc interact1 ()
780"
781Sub_procedure: asking for and reading your input-strings
782"
783{
784 string my = "@";
785 string str,out,my_ord,my_var;
786 my_ord = "ds";
787 my_var = "A";
788 "INPUT: name of output-file (ENTER = no output, do not use \"my\"!)";
789   str = read("");
790   if (size(str)>1)
791   { out = str[1..size(str)-1];}
792   else
793   { out = "no";}
794 "INPUT: prefix-string of ring-extension (ENTER = '@')";
795   str = read("");
796   if ( size(str) > 1 )
797   { my = str[1..size(str)-1]; }
798 "INPUT:parameter-string
799   (give a letter corresponding to first new variable followed by the next letters,
800   or 'T('       - a letter + '('  - getting a string of indexed variables)
801   (ENTER = A) :";
802   str = read("");
803   if (size(str)>1) { my_var=str[1..size(str)-1]; }
804 "INPUT:order-string (local or weighted!) (ENTER = ds) :";
805   str = read("");
806   if (size(str)>1) { my_ord=str[1..size(str)-1]; }
807   if( find(my_ord,"s")+find(my_ord,"w") == 0 )
808   { "// ordering must be an local! changed into 'ds'";
809     my_ord = "ds";
810   }
811   return(my,my_var,my_ord,out);
812}
813///////////////////////////////////////////////////////////////////////////////
814proc interact2 (matrix A, intvec col_vec, list #)
815"
816Sub-procedure: asking for and reading your input
817"
818{
819  module B,C;
820  matrix D;
821  int flag;
822  if (size(#)>0) { D=#[1];flag=1;}
823  int t1 = ncols(A);
824  ">>Do you want all deformations? (ENTER=yes)";
825  string str = read("");
826  if ((size(str)>1) and (str<>"yes"))
827  { ">> Choose columns of the matrix";
828    ">> (Enter = all columns)";
829    "INPUT (number of columns to use as integer-list 'i_1,i_2,.. ,i_t' ):";
830    string columnes = read("");
831
832// improved: CL
833// ==========================================================
834// old:   if (size(columnes)<2) {columnes=string(col_vec);}
835//        t1 = size(columnes)/2;
836// new:
837    if (columnes=="")
838    {
839      intvec vvvv=1..ncols(A);
840    }
841    else
842    {
843      execute("intvec vvvv="+columnes);
844    }
845    t1=size(vvvv);
846// ==========================================================
847
848    int l,l1;
849    for (l=1;l<=t1;l=l+1)
850    {
851// old:   execute("l1= "+columnes[2*l-1]+";");
852      l1=vvvv[l];
853      B[l] = A[l1];
854      if(flag) { C[l]=D[l1];}
855    }
856    A = matrix(B,nrows(A),size(B));
857    D = matrix(C,nrows(D),size(C));
858  }
859  return(A,D,t1);
860}
861///////////////////////////////////////////////////////////////////////////////
862proc negative_part(intvec iv)
863"
864RETURNS intvec of indices of jv having negative entries (or iv, if non)
865"
866{
867   intvec jv;
868   int    l,k;
869   for (l=1;l<=size(iv);l=l+1)
870   { if (iv[l]<0)
871     {  k = k+1;
872        jv[k]=l;
873     }
874   }
875   if (jv==0) {jv=1; dbprint(printlevel-1,"// empty negative part, return all ");}
876   return(jv);
877}
878///////////////////////////////////////////////////////////////////////////////
879proc find_ord(matrix A, intvec w_vec)
880"
881Sub-proc: return martix ord(a_ij) with respect to weight_vec, or
882          0 if A non-qh
883"
884{
885  int @r = nrows(A);
886  int @c = ncols(A);
887  int i,j;
888  string ord_str = "wp("+string(w_vec)+")";
889  def br = basering;
890  def nr=changeord(ord_str);
891  setring nr;
892  matrix A    = imap(br,A);
893  intmat degA[@r][@c];
894  if (homog(ideal(A)))
895  { for (i=1;i<=@r;i=i+1)
896    { for(j=1;j<=@c;j=j+1)
897      {  degA[i,j]=ord(A[i,j]); }
898    }
899  }
900  setring br;
901  if (defined(nr)) { kill nr; }
902  return(degA);
903}
904///////////////////////////////////////////////////////////////////////////////
905proc homog_test(intvec w_vec, matrix Mo, matrix A)
906"
907Sub proc: return relative weight string of columns of A with respect
908          to the given w_vec and to Mo, or \"\" if not qh
909    NOTE: * means weight is not determined
910"
911{
912  int k,l;
913  intvec tv;
914  string @nv;
915  int @r = nrows(A);
916  int @c = ncols(A);
917  A = concat(matrix(ideal(Mo),@r,1),A);
918  intmat a = find_ord(A,w_vec);
919  intmat b[@r][@c];
920  for (l=1;l<=@c;l=l+1)
921  {
922    for (k=1;k<=@r;k=k+1)
923    {  if (A[k,l+1]!=0)
924       { b[k,l] = a[k,l+1]-a[k,1];}
925    }
926    tv = 0;
927    for (k=1;k<=@r;k=k+1)
928    {  if (A[k,l+1]*A[k,1]!=0)
929       {tv = tv,b[k,l];}
930    }
931    if (size(tv)>1)
932    { k = tv[2];
933      tv = tv[2..size(tv)];
934      tv = tv -k;
935      if (tv==0) { @nv = @nv+string(-k)+",";}
936      else {return("");}
937    }
938    else { @nv = @nv+"*,";}
939  }
940  @nv = @nv[1..size(@nv)-1];
941  return(@nv);
942}
943///////////////////////////////////////////////////////////////////////////////
944proc homog_t(intvec d_vec, matrix Fo, matrix A)
945"
946Sub-procedure: Computing relative (with respect to flatten(Fo)) weight_vec
947               of columns of A (return zero if Fo or A not qh)
948"
949{
950   Fo = matrix(Fo,nrows(A),1);
951   A  = concat(Fo,A);
952   A  = transpose(A);
953   def br = basering;
954   string o_str = "wp("+string(d_vec)+")";
955   def nr=changeord(o_str);
956   setring nr;
957   module A = fetch(br,A);
958   intvec dv;
959   int l = homog(A) ;
960   if (l==0) {
961     setring br;
962     if(system("with","Namespaces")) { kill Top::nr; }
963     if (defined(nr)) { kill nr; }
964     return(l);
965   }
966   dv = attrib(A,"isHomog");
967   l  = dv[1];
968   dv = dv[2..size(dv)];
969   dv = dv-l;
970 setring br;
971   if(system("with","Namespaces")) { kill Top::nr; }
972   if (defined(nr)) { kill nr; }
973   return(dv);
974}
975///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.