cali.tst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. % Author H.-G. Graebe | Univ. Leipzig | Version 20.10.93
  2. % graebe@informatik.uni-leipzig.d400.de
  3. COMMENT
  4. This is an example session demonstrating and testing the facilities
  5. offered by the commutative algebra package CALI.
  6. END COMMENT;
  7. algebraic;
  8. on echo;
  9. % Example 1 : Generating ideals of affine and projective points.
  10. vars:={t,x,y,z};
  11. setring(vars,degreeorder vars,revlex);
  12. mm:=mat((1,1,1,1),(1,2,3,4),(2,1,4,3));
  13. % The ideal with zero set at the point in A^4 with coordinates
  14. % equal to the row vectors of mm :
  15. setideal(m1,affine_points mm);
  16. % All parameters are as they should be :
  17. gbasis m1$
  18. dim m1;
  19. degree m1;
  20. groebfactor m1;
  21. resolve m1$
  22. bettinumbers m1;
  23. % The ideal with zero set at the point in P^3 with homogeneous
  24. % coordinates equal to the row vectors of mm :
  25. setideal(m2,proj_points mm);
  26. % All parameters as they should be ?
  27. gbasis m2$
  28. dim m2;
  29. degree m2;
  30. groebfactor m2;
  31. % It seems to be prime ?
  32. isprime m2;
  33. % Not, of course, but it is known to be unmixed. Hence we can use
  34. easyprimarydecomposition m2;
  35. % Example 2 :
  36. % An affine monomial curve with generic point (t^7,t^9,t^10).
  37. setideal(m,affine_monomial_curve({7,9,10},{x,y,z}));
  38. % The base ring was changed as side effect :
  39. getring();
  40. vars:=first getring m;
  41. % Some advanced commutative algebra .
  42. % The analytic spread of m.
  43. analytic_spread m;
  44. % The Rees ring Rees_R(vars) over R=S/m.
  45. blowup(m,vars,{u,v,w});
  46. % gr_R(vars), the associated graded ring of the irrelevant ideal
  47. % over R. The short way.
  48. interreduce sub(x=0,y=0,z=0,ws);
  49. % The long (and more general) way. Gives the result in another
  50. % embedding.
  51. % Reste the base ring, since it was changed by blowup as a side
  52. % effect.
  53. setring getring m$
  54. assgrad(m,vars,{u,v,w});
  55. % Comparing the Rees algebra and the symmetric algebra of M :
  56. setring getring m$
  57. setideal(rees,blowup({},m,{a,b,c}));
  58. setring getring m$
  59. setideal(sym,sym(m,{a,b,c}));
  60. gbasis rees$ gbasis sym$
  61. modequalp(rees,sym);
  62. % Symbolic powers :
  63. setring getring m$
  64. setideal(m2,idealpower(m,2));
  65. % Let's compute a second symbolic power :
  66. setideal(m3,symbolic_power(m,2));
  67. % It is different from the ordinary second power.
  68. % Hence m2 has a trivial component.
  69. gbasis m2$ gbasis m3$
  70. modequalp(m2,m3);
  71. % Here is the primary decomposition :
  72. pd:=primarydecomposition m2;
  73. % Compare the result with m2 :
  74. setideal(m4,matintersect(first first pd, first second pd));
  75. gbasis m4$
  76. modequalp(m2,m4);
  77. % Compare the result with m3 :
  78. setideal(m4,first first pd)$
  79. gbasis m4$
  80. modequalp(m3,m4);
  81. % The trivial component can also be removed with a
  82. % stable quotient computation :
  83. setideal(m5,matstabquot(m2,vars))$
  84. gbasis m5$
  85. modequalp(m3,m5);
  86. % Example 3 : The Macaulay curve.
  87. setideal(m,proj_monomial_curve({0,1,3,4},{w,x,y,z}));
  88. vars:=first getring();
  89. gbasis m;
  90. % Test whether m is prime :
  91. isprime m;
  92. % A resolution of m :
  93. resolve m;
  94. % m has depth = 1 as can be seen from the
  95. gradedbettinumbers m;
  96. % Another way to see the non perfectness of m :
  97. hilbseries m;
  98. % Just a third approach. Divide out a parameter system :
  99. ps:=for i:=1:2 collect random_linear_form(vars,1000);
  100. setideal(m1,matsum(m,ps))$ gbasis m1$
  101. % dim should be zero and degree > degree m = 4.
  102. dim m1;
  103. degree m1;
  104. % The projections of m on the coord. hyperplanes.
  105. for each x in vars collect eliminate(m,{x});
  106. % Example 4 : Two submodules of S^4.
  107. % Get the stored result of the earlier computation.
  108. r:=resolve m$
  109. % See whether cali!=degrees contains a relict from earlier
  110. % computations.
  111. getdegrees();
  112. % Introduce the 2nd and 3rd syzygy module as new modules.
  113. % Both are submodules in S^4.
  114. setmodule(m1,second r)$ setmodule(m2,third r)$
  115. gbasis m1;
  116. % The second is already a gbasis.
  117. setgbasis m2;
  118. getleadterms m1; getleadterms m2;
  119. % Since rk(F/M)=rk(F/in(M)), they have ranks 1 resp. 3.
  120. dim m1;
  121. indepvarsets m1;
  122. % Its intersection is zero :
  123. matintersect(m1,m2);
  124. % Its sum :
  125. setmodule(m3,matsum(m1,m2));
  126. gbasis m3;
  127. dim m3;
  128. % Hence it has a nontrivial annihilator :
  129. annihilator m3;
  130. % To get a meaningful Hilbert series make m1 homogeneous :
  131. setdegrees {1,x,x,x};
  132. % Reevaluate m1 with the new column degrees.
  133. setmodule(m1,m1)$
  134. gbasis m1;
  135. hilbseries m1;
  136. % Example 5 : From the MACAULAY manual (D.Bayer, M.Stillman).
  137. % An elliptic curve on the Veronese in P^5.
  138. rvars:={x,y,z}$ svars:={a,b,c,d,e,f}$
  139. r:=setring(rvars,degreeorder rvars,revlex)$
  140. s:=setring(svars,{for each x in svars collect 2},revlex)$
  141. map:={s,r,{a=x^2,b=x*y,c=x*z,d=y^2,e=y*z,f=z^2}};
  142. preimage({y^2z-x^3-x*z^2},map);
  143. % Example 6 : The preimage under a rational map.
  144. r:=setring({x,y},{},lex)$ s:=setring({t},{},lex)$
  145. map:={r,s,{x=2t/(t^2+1),y=(t^2-1)/(t^2+1)}};
  146. % The preimage of (0) is the equation of the circle :
  147. ratpreimage({},map);
  148. % The preimage of the point (t=3/2) :
  149. ratpreimage({2t-3},map);
  150. % Example 7 : A zerodimensional ideal.
  151. setring({x,y,z},{},lex)$
  152. setideal(n,{x**2 + y + z - 3,x + y**2 + z - 3,x + y + z**2 - 3});
  153. % The groebner algorithm with factorization :
  154. groebfactor n;
  155. % Change the term order and reevaluate n :
  156. setring({x,y,z},{{1,1,1}},revlex)$
  157. setideal(n,n);
  158. gbasis n;
  159. % its primes :
  160. zeroprimes n;
  161. % a vector space basis of S/n :
  162. getkbase n;
  163. % Example 8 : A modular computation.
  164. on modular$
  165. setmod 181; setideal(n1,n); zeroprimes n1;
  166. setmod 7; setideal(n1,n); zeroprimes n1;
  167. % Hence some of the primes glue together mod 7.
  168. zeroprimarydecomposition n1;
  169. off modular$
  170. % Example 9 : Independent sets once more.
  171. n:=10$
  172. vars:=for i:=1:(2*n) collect mkid(x,i)$
  173. setring(vars,{},lex)$
  174. setideal(m,for j:=0:n collect
  175. for i:=(j+1):(j+n) product mkid(x,i));
  176. setgbasis m$
  177. indepvarsets m;
  178. dim m;
  179. degree m;
  180. % Example 10 : An example from [ Alonso, Mora, Raimondo ]
  181. vars := {z,x,y}$
  182. r:=setring(vars,{},lex)$
  183. setideal(m,{x^3+(x^2-y^2)*z+z^4,y^3+(x^2-y^2)*z-z^4});
  184. gbasis m$
  185. dim m;
  186. degree m;
  187. % 2 = codim m is the codimension of the curve m. The defining
  188. % equations of the singular locus with their nilpotent structure.
  189. singular_locus(m,2);
  190. groebfactor ws;
  191. % Hence this curve has two singular points :
  192. % (x=y=z=0) and (y=-x=256/81,z=64/27)
  193. % Let's find the brances of the curve through the origin.
  194. % The first critical tropism is (-1,-1,-1).
  195. off noetherian$
  196. setring(vars,{{-1,-1,-1}},lex)$
  197. setideal(m,m);
  198. % Let's test Lazard's approach.
  199. off lazy$
  200. gbasis m;
  201. dim m;
  202. degree m;
  203. % Find the tangent directions not in z-direction :
  204. tangentcone m;
  205. setideal(n,sub(z=1,ws));
  206. setring r$ on noetherian$ setideal(n,n)$
  207. gbasis n;
  208. degree n;
  209. % The points of n outside the origin.
  210. matstabquot(n,{x,y});
  211. % Hence there are two branches x=z'*(a-3+x'),y=z'*(a+y'),z=z'
  212. % with the algebraic number a : a^2-3a+3=0
  213. % and the new equations for (z',x',y') :
  214. setrules {a^2=>3a-3};
  215. sub(x=z*(a-3+x),y=z*(a+y),m);
  216. setideal(m1,matqquot(ws,z));
  217. % This defines a loc. smooth system at the origin, since the
  218. % jacobian at the origin of the gbasis is nonsingular :
  219. off noetherian$
  220. % Test Mora's approach.
  221. on lazy$
  222. setring getring m;
  223. setideal(m1,m1);
  224. gbasis m1;
  225. % clear the rules previously set.
  226. setrules {};
  227. % Example 11 : The standard basis of another example.
  228. % Comparing Mora's and Lazard's approaches.
  229. vars:={x,y}$
  230. setring(vars,localorder vars,lex);
  231. ff:=x^5+y^11+(x+x^3)*y^9;
  232. setideal(p,flatten matjac({ff},vars));
  233. % Mora's approach : Only top reduction allowed.
  234. gbasis p;
  235. % Lazard's approach : Total normal forms of homogenized polynomials
  236. % allowed. Hence the computation produces other normal forms.
  237. off lazy;
  238. setideal(p,p)$
  239. gbasis p;
  240. dim p;
  241. degree p;
  242. % Example 12 : A local intersection.
  243. setring({x,y,z},{},revlex);
  244. on lazy;
  245. m1:=matintersect({x-y^2,y-x^2},{x-z^2,z-x^2},{y-z^2,z-y^2});
  246. % Delete polynomial units post factum :
  247. deleteunits ws;
  248. interreduce ws;
  249. % Detecting polynomial units early :
  250. on detectunits;
  251. m1:=matintersect({x-y^2,y-x^2},{x-z^2,z-x^2},{y-z^2,z-y^2});
  252. off detectunits;
  253. % Return to a noetherian term order:
  254. vars:={x,y,z}$
  255. setring(vars,degreeorder vars,revlex);
  256. on noetherian;
  257. % Example 13 : Use of "mod".
  258. % Polynomials modulo ideals :
  259. setideal(m,{2x^2+y+5,3y^2+z+7,7z^2+x+1});
  260. x^2*y^2*z^2 mod m;
  261. % Lists of polynomials modulo ideals :
  262. {x^3,y^3,z^3} mod gbasis m;
  263. % Matrices modulo modules :
  264. mm:=mat((x^4,y^4,z^4));
  265. mm1:=tp<< ideal2mat m>>;
  266. mm mod mm1;
  267. % Example 14 : Powersums through elementary symmetric functions.
  268. vars:={a,b,c,d,e1,e2,e3,e4}$
  269. setring(vars,{},lex)$
  270. m:=interreduce {a+b+c+d-e1,
  271. a*b+a*c+a*d+b*c+b*d+c*d-e2,
  272. a*b*c+a*b*d+a*c*d+b*c*d-e3,
  273. a*b*c*d-e4};
  274. for n:=1:5 collect a^n+b^n+c^n+d^n mod m;
  275. % Example 15 : The setrules mechanism.
  276. setring({x,y,z},{},lex)$
  277. setrules {aa^3=>aa+1};
  278. setideal(m,{x^2+y+z-aa,x+y^2+z-aa,x+y+z^2-aa});
  279. gbasis m;
  280. % Clear the rules previously set.
  281. setrules {};
  282. % Example 16 : The same example with advanced coefficient domains.
  283. load arnum;
  284. defpoly aa^3-aa-1;
  285. setideal(m,{x^2+y+z-aa,x+y^2+z-aa,x+y+z^2-aa});
  286. gbasis m;
  287. % The following needs some more time since factorization of arnum's
  288. % is not so easy :
  289. groebfactor m;
  290. off arnum;
  291. off rational;
  292. % Example 17 : The square of the 2-minors of a symmetric 3x3-matrix.
  293. vars:=for i:=1:6 collect mkid(x,i);
  294. setring(vars,degreeorder vars,revlex);
  295. % Generating the ideal :
  296. mm:=mat((x1,x2,x3),(x2,x4,x5),(x3,x5,x6));
  297. m:=minors(mm,2);
  298. setideal(n,idealpower(m,2));
  299. % The ideal itself :
  300. gbasis n;
  301. length n;
  302. dim n;
  303. degree n;
  304. % Its unmixed radical.
  305. unmixedradical n;
  306. % Its equidimensional hull. This needs some more time :
  307. n1:=eqhull n;
  308. length n1;
  309. setideal(n1,n1)$ gbasis n1$
  310. submodulep(n,n1);
  311. submodulep(n1,n);
  312. % Hence there is an embedded component. Let's find it making an
  313. % excursion to symbolic mode. Of course, this can be done also
  314. % algebraically.
  315. symbolic;
  316. n:=get('n,'basis);
  317. % This needs even more time than the eqhull, of course.
  318. u:=primarydecomposition!* n;
  319. for each x in u collect easydim!* second x;
  320. for each x in u collect degree!* first x;
  321. % Hence the embedded component is a trivial one. Let's divide it
  322. % out by a stable ideal quotient calculation :
  323. algebraic;
  324. setideal(n2,matstabquot(n,vars));
  325. gbasis n2$
  326. modequalp(n1,n2);
  327. end;