source: git/Singular/LIB/deform.lib @ 3686937

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