start.tex 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  1. @comment -*-texinfo-*-
  2. @comment This file was generated by doc2tex.pl from start.doc
  3. @comment DO NOT EDIT DIRECTLY, BUT EDIT start.doc INSTEAD
  4. @comment Id: start.tex,v 1.1 2003/08/08 14:27:06 pertusus Exp $
  5. @comment this file contains the "Introduction" chapter.
  6. @c * wichmann: + added changes by GMG.
  7. @c The following directives are necessary for proper compilation
  8. @c with emacs (C-c C-e C-r). Please keep it as it is. Since it
  9. @c is wrapped in `@ignore' and `@end ignore' it does not harm `tex' or
  10. @c `makeinfo' but is a great help in editing this file (emacs
  11. @c ignores the `@ignore').
  12. @ignore
  13. %**start
  14. \input texinfo.tex
  15. @setfilename start.hlp
  16. @node Top, Introduction
  17. @menu
  18. * Introduction::
  19. @end menu
  20. @node Introduction, General concepts, Preface, Top
  21. @chapter Introduction
  22. %**end
  23. @end ignore
  24. @ifset singularmanual
  25. @menu
  26. * Background::
  27. * How to use this manual::
  28. * Getting started::
  29. @end menu
  30. @end ifset
  31. @ifclear singularmanual
  32. @menu
  33. * Background::
  34. * How to use this tutorial::
  35. * Getting started::
  36. @end menu
  37. @end ifclear
  38. @c ------------------------------------------------------------------
  39. @ifset singularmanual
  40. @node Background, How to use this manual, Introduction, Introduction
  41. @end ifset
  42. @ifclear singularmanual
  43. @node Background, How to use this tutorial, Introduction, Introduction
  44. @end ifclear
  45. @section Background
  46. @cindex Background
  47. @sc{Singular} is a Computer Algebra system for polynomial
  48. computations with emphasis on the special needs of commutative
  49. algebra, algebraic geometry, and singularity theory.
  50. @sc{Singular}'s main computational objects are ideals and
  51. modules over a large variety of baserings. The baserings are polynomial
  52. rings or localizations thereof over a field (e.g., finite fields, the
  53. rationals, floats, algebraic extensions, transcendental extensions) or
  54. quotient rings with respect to an ideal.
  55. @sc{Singular} features one of the fastest and most general
  56. implementations of various algorithms for computing Groebner
  57. resp.@: standard bases. The implementation includes Buchberger's algorithm
  58. (if the ordering is a well ordering) and Mora's algorithm (if the
  59. ordering is a tangent cone ordering) as special cases. Furthermore, it
  60. provides polynomial factorizations, resultant, characteristic set and
  61. gcd computations, syzygy and free-resolution computations, and many more
  62. related functionalities.
  63. Based on an easy-to-use interactive shell and a C-like programming
  64. language, @sc{Singular}'s internal functionality is augmented and
  65. user-extendible by libraries written in the @sc{Singular} programming
  66. language. A general and efficient implementation of communication links
  67. allows @sc{Singular} to make its functionality available to other
  68. programs.
  69. @sc{Singular}'s development started in 1984 with an implementation of
  70. Mora's Tangent Cone algorithm in Modula-2 on an Atari computer (K.P.
  71. Neuendorf, G. Pfister,
  72. @ifinfo
  73. H.@: Schoenemann; Humboldt-Universitaet
  74. @end ifinfo
  75. @tex
  76. H.\ Sch\"onemann; Humboldt-Universit\"at
  77. @end tex
  78. zu Berlin). The need for a new system arose from the investigation of
  79. mathematical problems coming from singularity theory which none of the
  80. existing systems was able to compute.
  81. In the early 1990s @sc{Singular}'s "home-town" moved to
  82. Kaiserslautern, a general standard basis algorithm was implemented in C
  83. and @sc{Singular} was ported to Unix, MS-DOS, Windows NT, and MacOS.
  84. Continuous extensions (like polynomial factorization, gcd computations,
  85. links) and refinements led in 1997 to the release of @sc{Singular}
  86. version 1.0 and in 1998 to the release of version 1.2
  87. (much faster standard and Groebner bases computations based on Hilbert series
  88. and on improved implementations of the algorithms,
  89. libraries for primary decomposition, ring normalization, etc.)
  90. For the highlights of the new @sc{Singular} version @value{VERSION} see @ref{News and changes}.
  91. @c Thus, we hope to offer a useful system
  92. @c for dealing with local and global computational aspects
  93. @c of systems of polynomial equations.
  94. @c ------------------------------------------------------------------
  95. @ifset singularmanual
  96. @node How to use this manual, Getting started, Background, Introduction
  97. @section How to use this manual
  98. @cindex How to use this manual
  99. @end ifset
  100. @ifclear singularmanual
  101. @node How to use this tutorial, Getting started, Background, Introduction
  102. @section How to use this tutorial
  103. @cindex How to use this tutorial
  104. @end ifclear
  105. @ifset singularmanual
  106. @subsubheading For the impatient user
  107. @end ifset
  108. In @ref{Getting started}, some simple examples explain how to use
  109. @sc{Singular} in a step-by-step manner.
  110. @ref{Examples} should come next for real learning-by-doing or to quickly
  111. solve some given mathematical problems without dwelling too deeply into
  112. @sc{Singular}.
  113. @ifset singularmanual
  114. This chapter contains a lot of real-life examples and
  115. detailed instructions and explanations on how to solve mathematical
  116. problems using @sc{Singular}.
  117. @end ifset
  118. @c ------------------------------------------------------------------------
  119. @ifset singularmanual
  120. @subsubheading For the systematic user
  121. In @ref{General concepts}, all basic concepts which are important to use
  122. and to understand @sc{Singular} are developed. But even for users
  123. preferring the systematic approach it will be helpful to have a look at
  124. the examples in @ref{Getting started}, every now and then. The topics in
  125. the chapter are organized more or less in the order the novice user has
  126. to deal with them.
  127. @itemize @bullet
  128. @item
  129. In @ref{Interactive use}, and its subsections there are some words on
  130. entering and exiting @sc{Singular}, followed by a number of other
  131. aspects concerning the interactive user-interface.
  132. @item
  133. To do anything more than trivial integer computations, one needs to
  134. define a basering in @sc{Singular}. This is explained in detail in
  135. @ref{Rings and orderings}.
  136. @item
  137. An overview of the algorithms implemented in the kernel of @sc{Singular}
  138. is given in @ref{Implemented algorithms}.
  139. @item
  140. In @ref{The SINGULAR language}, language specific concepts are
  141. introduced such as the notions of names and objects, data types and
  142. conversion between them, etc.
  143. @item
  144. In @ref{Input and output}, @sc{Singular}'s mechanisms to store and
  145. retrieve data are discussed.
  146. @item
  147. The more complex concepts of procedures and libraries as
  148. well as tools to debug them are considered in the following sections:
  149. @ref{Procedures}, @ref{Libraries}, and @ref{Debugging tools}.
  150. @end itemize
  151. @ref{Data types}, is a complete treatment for @sc{Singular}'s data types
  152. where each section corresponds to one data type, alphabetically sorted.
  153. For each data type, its purpose is explained, the syntax of its
  154. declaration is given, and related operations and functions are
  155. listed. Examples illustrate its usage.
  156. @ref{Functions and system variables}, is an alphabetically ordered
  157. reference list of all of @sc{Singular}'s functions, control structures,
  158. and system variables. Each entry includes a description of the syntax
  159. and semantics of the item being explained as well as one or more
  160. examples on how to use it.
  161. @subsubheading Miscellaneous
  162. @ref{Tricks and pitfalls}, is a loose collection of limitations and
  163. features which may be unexpected by those who expect the
  164. @sc{Singular} language to be an exact copy of the C programming language or of
  165. some Computer Algebra system's languages. But some mathematical hints are
  166. collected there, as well.
  167. @ref{Mathematical background}, introduces some of the mathematical
  168. notions and definitions used throughout this manual. For example, if in
  169. doubt what exactly @sc{Singular} means by a ``negative degree reverse
  170. lexicographical ordering'' one should refer to this chapter.
  171. @ref{SINGULAR libraries}, lists the
  172. libraries which come with @sc{Singular} and the functions contained in
  173. them, respectively.
  174. @end ifset
  175. @c ------------------------------------------------------------------------
  176. @subsubheading Typographical conventions
  177. Throughout this manual, the following typographical conventions are
  178. adopted:
  179. @itemize @bullet
  180. @item
  181. text in @code{typewriter} denotes @sc{Singular} input and output as well
  182. as reserved names:
  183. @itemize @asis
  184. @item The basering can be set using the command @code{setring}.
  185. @end itemize
  186. @item
  187. the arrow @expansion{} denotes @sc{Singular} output:
  188. @itemize @asis
  189. @item @code{poly p=x+y+z;}
  190. @item @code{p*p;}
  191. @item @code{@expansion{} x2+2xy+y2+2xz+2yz+z2}
  192. @end itemize
  193. @item
  194. square brackets are used to denote parts of syntax descriptions which
  195. are optional:
  196. @itemize @asis
  197. [optional_text] required_text
  198. @end itemize
  199. @item
  200. keys are denoted using typewriter, for example:
  201. @itemize @asis
  202. @item @code{N} (press the key @code{N} to get to the next node in help
  203. mode)
  204. @item @code{RETURN} (press @code{RETURN} to finish an input line)
  205. @item @code{CTRL-P} (press control key together with the key @code{P} to
  206. get the previous input line)
  207. @end itemize
  208. @end itemize
  209. @c ------------------------------------------------------------------
  210. @ifset singularmanual
  211. @node Getting started, , How to use this manual, Introduction
  212. @section Getting started
  213. @end ifset
  214. @ifclear singularmanual
  215. @node Getting started, , How to use this tutorial, Introduction
  216. @chapter Getting started
  217. @end ifclear
  218. @cindex Getting started
  219. @sc{Singular} is a special purpose system for polynomial
  220. computations. Hence, most of the powerful computations in @sc{Singular}
  221. require the prior definition of a ring. Most important rings are
  222. polynomial rings over a field, localizations hereof, or quotient rings of
  223. such rings modulo an ideal. However, some simple computations with
  224. integers (machine integers of limited size) and manipulations of strings
  225. are available without a ring.
  226. @menu
  227. * First steps::
  228. * Rings and standard bases::
  229. * Procedures and libraries::
  230. * Change of rings::
  231. * Modules and their annihilator::
  232. * Resolution::
  233. @end menu
  234. @c ------------------------------------------------------------------
  235. @node First steps, Rings and standard bases, Getting started, Getting started
  236. @ifset singularmanual
  237. @subsection First steps
  238. @end ifset
  239. @ifclear singularmanual
  240. @section First steps
  241. @end ifclear
  242. @cindex First steps
  243. Once @sc{Singular} is started, it awaits an input after the prompt
  244. @code{>}. Every statement has to be terminated by @code{;} .
  245. @smallexample
  246. 37+5;
  247. @expansion{} 42
  248. @end smallexample
  249. All objects have a type, e.g., integer variables are defined by
  250. the word @code{int}. An assignment is done by the symbol @code{=} .
  251. @smallexample
  252. int k = 2;
  253. @end smallexample
  254. @noindent Test for equality resp.@: inequality is done using @code{==}
  255. resp.@: @code{!=} (or @code{<>}), where @code{0} represents the boolean
  256. value FALSE, any other value represents TRUE.
  257. @smallexample
  258. k == 2;
  259. @expansion{} 1
  260. k != 2;
  261. @expansion{} 0
  262. @end smallexample
  263. @noindent The value of an object is displayed by simply typing its name.
  264. @smallexample
  265. k;
  266. @expansion{} 2
  267. @end smallexample
  268. @noindent On the other hand the output is suppressed if an assignment
  269. is made.
  270. @smallexample
  271. int j;
  272. j = k+1;
  273. @end smallexample
  274. @noindent The last displayed (!) result is always available
  275. with the special symbol @code{_} .
  276. @smallexample
  277. 2*_; // the value from k displayed above
  278. @expansion{} 4
  279. @end smallexample
  280. Text starting with @code{//} denotes a comment and is ignored in
  281. calculations, as seen in the previous example. Furthermore @sc{Singular}
  282. maintains a history of the previous lines of input, which may be accessed by
  283. @code{CTRL-P} (previous) and @code{CTRL-N} (next) or the arrows on the
  284. keyboard. Note that the history is not available on Macintosh systems.
  285. The whole manual is available online by typing the command @code{help;} .
  286. Explanation on single topics, e.g., on @code{intmat}, which defines a
  287. matrix of integers, are obtained by
  288. @smallexample
  289. help intmat;
  290. @end smallexample
  291. @ifset singularmanual
  292. @noindent This shows the text of @ref{intmat}, in the printed manual.
  293. @end ifset
  294. @ifclear singularmanual
  295. @noindent This shows the text from node @code{intmat}, in the printed manual.
  296. @end ifclear
  297. Next, we define a
  298. @tex
  299. $3 \times 3$
  300. @end tex
  301. @ifinfo
  302. 3 x 3
  303. @end ifinfo
  304. matrix of integers and initialize it with some values, row by row
  305. from left to right:
  306. @smallexample
  307. intmat m[3][3] = 1,2,3,4,5,6,7,8,9;
  308. @end smallexample
  309. @noindent A single matrix entry may be selected and changed using
  310. square brackets @code{[} and @code{]}.
  311. @smallexample
  312. m[1,2]=0;
  313. m;
  314. @expansion{} 1,0,3,
  315. @expansion{} 4,5,6,
  316. @expansion{} 7,8,9
  317. @end smallexample
  318. To calculate the trace of this matrix, we use a @code{for} loop. The
  319. curly brackets @code{@{} and @code{@}} denote the beginning resp.@:
  320. end of a block. If you define a variable without giving an initial
  321. value, as the variable @code{tr} in the example below, @sc{Singular}
  322. assigns a default value for the specific type. In this case, the default
  323. value for integers is @code{0}. Note that the integer variable @code{j}
  324. has already been defined above.
  325. @smallexample
  326. int tr;
  327. for ( j=1; j <= 3; j++ ) @{ tr=tr + m[j,j]; @}
  328. tr;
  329. @expansion{} 15
  330. @end smallexample
  331. Variables of type string can also be defined and used without a ring
  332. being active. Strings are delimited by @code{"} (double quotes). They
  333. may be used to comment the output of a computation or to give it a nice
  334. format. If a string contains valid @sc{Singular} commands, it can be
  335. executed using the function @code{execute}. The result is the same as if
  336. the commands would have been written on the command line. This feature
  337. is especially useful to define new rings inside procedures.
  338. @smallexample
  339. "example for strings:";
  340. @expansion{} example for strings:
  341. string s="The element of m ";
  342. s = s + "at position [2,3] is:"; // concatenation of strings by +
  343. s , m[2,3] , ".";
  344. @expansion{} The element of m at position [2,3] is: 6 .
  345. s="m[2,1]=0; m;";
  346. execute(s);
  347. @expansion{} 1,0,3,
  348. @expansion{} 0,5,6,
  349. @expansion{} 7,8,9
  350. @end smallexample
  351. This example shows that expressions can be separated by @code{,} (comma)
  352. giving a list of expressions. @sc{Singular} evaluates each expression in
  353. this list and prints all results separated by spaces.
  354. @c ------------------------------------------------------------------
  355. @node Rings and standard bases, Procedures and libraries, First steps, Getting started
  356. @ifset singularmanual
  357. @subsection Rings and standard bases
  358. @end ifset
  359. @ifclear singularmanual
  360. @section Rings and standard bases
  361. @end ifclear
  362. @cindex Rings and standard bases
  363. To calculate with objects as ideals, matrices, modules, and polynomial
  364. vectors, a ring has to be defined first.
  365. @smallexample
  366. ring r = 0,(x,y,z),dp;
  367. @end smallexample
  368. The definition of a ring consists of three parts: the first part
  369. determines the ground field, the second part determines the names of the
  370. ring variables, and the third part determines the monomial ordering to
  371. be used. So the example above declares a polynomial ring called @code{r}
  372. with a ground field of characteristic
  373. @ifinfo
  374. @math{0}
  375. @end ifinfo
  376. @tex
  377. $0$
  378. @end tex
  379. (i.e., the rational
  380. numbers) and ring variables called @code{x}, @code{y}, and @code{z}. The
  381. @code{dp} at the end means that the degree reverse lexicographical
  382. ordering should be used.
  383. Other ring declarations:
  384. @table @code
  385. @item ring r1=32003,(x,y,z),dp;
  386. characteristic 32003, variables @code{x}, @code{y}, and @code{z} and
  387. ordering @code{dp}.
  388. @item ring r2=32003,(a,b,c,d),lp;
  389. characteristic 32003, variable names @code{a}, @code{b}, @code{c},
  390. @code{d} and lexicographical ordering.
  391. @item ring r3=7,(x(1..10)),ds;
  392. characteristic 7, variable names @code{x(1)},@dots{},@code{x(10)}, negative
  393. degree reverse lexicographical ordering (@code{ds}).
  394. @item ring r4=(0,a),(mu,nu),lp;
  395. transcendental extension of
  396. @ifinfo
  397. @math{Q}
  398. @end ifinfo
  399. @tex
  400. $Q$
  401. @end tex
  402. by
  403. @ifinfo
  404. @math{a}
  405. @end ifinfo
  406. @tex
  407. $a$
  408. @end tex
  409. , variable names
  410. @code{mu} and @code{nu}.
  411. @item ring r5=real,(a,b),lp;
  412. floating point numbers (single machine precision),
  413. variable names @code{a} and @code{b}.
  414. @item ring r6=(real,50),(a,b),lp;
  415. floating point numbers with extended precision of 50 digits,
  416. variable names @code{a} and @code{b}.
  417. @item ring r7=(complex,50,i),(a,b),lp;
  418. complex floating point numbers with extended precision of 50 digits
  419. and imaginary unit @code{i},
  420. variable names @code{a} and @code{b}.
  421. @end table
  422. @c Another valid characteristic would be, for example, a prime number less
  423. @c or equal to 32003. The name of the ring variables may be any
  424. @c valid @sc{Singular} name. Even indexed names are allowed, so
  425. @c @code{x(1..10)} specifies the ring variables @code{x(1)}, @dots{},
  426. @c @code{x(10)}. @sc{Singular} offers the possibility to calculate with any
  427. @c monomial ordering, some orderings are predefined with special names like
  428. @c @code{dp} in the example above. Another important example is the
  429. @c lexicographical ordering called @code{lp}.
  430. @c
  431. Typing the name of a ring prints its definition. The example below
  432. shows that the default ring in @sc{Singular} is
  433. @ifinfo
  434. @math{Z/32003[x,y,z]}
  435. @end ifinfo
  436. @tex
  437. $Z/32003[x,y,z]$
  438. @end tex
  439. with degree reverse lexicographical ordering:
  440. @smallexample
  441. @c computed example Rings_and_standard_bases start.doc:494
  442. ring r8;
  443. r8;
  444. @expansion{} // characteristic : 32003
  445. @expansion{} // number of vars : 3
  446. @expansion{} // block 1 : ordering dp
  447. @expansion{} // : names x y z
  448. @expansion{} // block 2 : ordering C
  449. @c end example Rings_and_standard_bases start.doc:494
  450. @end smallexample
  451. Defining a ring makes this ring the current active basering, so each
  452. ring definition above switches to a new basering. The concept of rings
  453. in @sc{Singular} is discussed in detail in
  454. @ifset singularmanual
  455. @ref{Rings and orderings}.
  456. @end ifset
  457. @ifclear singularmanual
  458. the chapter "Rings and orderings" of the @sc{Singular} manual.
  459. @end ifclear
  460. The basering is now @code{r8}. Since we want to calculate in the ring
  461. @code{r}, which we defined first, we have to switch back to it. This can
  462. be done using the function @code{setring}:
  463. @smallexample
  464. setring r;
  465. @end smallexample
  466. Once a ring is active, we can define polynomials. A monomial, say
  467. @tex
  468. $x^3$
  469. @end tex
  470. @ifinfo
  471. x^3
  472. @end ifinfo
  473. may be entered in two ways: either using the power operator @code{^},
  474. saying @code{x^3}, or in short-hand notation without operator, saying
  475. @code{x3}. Note that the short-hand notation is forbidden if the name
  476. of the ring variable consists of more than one character. Note, that
  477. @sc{Singular} always expands brackets and automatically sorts the terms
  478. with respect to the monomial ordering of the basering.
  479. @smallexample
  480. poly f = x3+y3+(x-y)*x2y2+z2;
  481. f;
  482. @expansion{} x3y2-x2y3+x3+y3+z2
  483. @end smallexample
  484. The command @code{size} determines in general the number of ''single
  485. entries`` in an object. In particular, for polynomials, @code{size}
  486. determines the number of monomials.
  487. @smallexample
  488. size(f);
  489. @expansion{} 5
  490. @end smallexample
  491. A natural question is to ask if a point, e.g., @code{(x,y,z)=(1,2,0)}, lies
  492. on the variety defined by the polynomials @code{f} and @code{g}. For
  493. this we define an ideal generated by both polynomials, substitute the
  494. coordinates of the point for the ring variables, and check if the result
  495. is zero:
  496. @smallexample
  497. poly g = f^2 *(2x-y);
  498. ideal I = f,g;
  499. ideal J = subst(I,var(1),1);
  500. J = subst(J,var(2),2);
  501. J = subst(J,var(3),0);
  502. J;
  503. @expansion{} J[1]=5
  504. @expansion{} J[2]=0
  505. @end smallexample
  506. @noindent Since the result is not zero, the point @code{(1,2,0)} does
  507. not lie on the variety @code{V(f,g)}.
  508. Another question is to decide whether some function vanishes on a
  509. variety, or in algebraic terms if a polynomial is contained in a given
  510. ideal. For this we calculate a standard basis using the command
  511. @code{groebner} and afterwards reduce the polynomial with respect to
  512. this standard basis.
  513. @smallexample
  514. ideal sI = groebner(f);
  515. reduce(g,sI);
  516. @expansion{} 0
  517. @end smallexample
  518. @noindent As the result is @code{0} the polynomial @code{g} belongs to the
  519. ideal defined by @code{f}.
  520. The function @code{groebner}, like many other functions in
  521. @sc{Singular}, prints a protocol during calculations, if desired. The
  522. command @code{option(prot);} enables protocolling whereas
  523. @code{option(noprot);} turns it off.
  524. @ifset singularmanual
  525. @ref{option}, explains the meaning
  526. of the different symbols printed during calculations.
  527. @end ifset
  528. The command @code{kbase} calculates a basis of the polynomial ring
  529. modulo an ideal, if the quotient ring is finite dimensional.
  530. As an example we calculate the Milnor number of a
  531. hypersurface singularity in the global and local case. This is the
  532. vector space dimension of the polynomial ring modulo the Jacobian ideal
  533. in the global case resp.@: of the power series ring modulo the Jacobian
  534. ideal in the local case. @xref{Critical points}, for a detailed
  535. explanation.
  536. The Jacobian ideal is obtained with the command @code{jacob}.
  537. @smallexample
  538. ideal J = jacob(f);
  539. @expansion{} // ** redefining J **
  540. J;
  541. @expansion{} J[1]=3x2y2-2xy3+3x2
  542. @expansion{} J[2]=2x3y-3x2y2+3y2
  543. @expansion{} J[3]=2z
  544. @end smallexample
  545. @noindent @sc{Singular} prints the line @code{// ** redefining J
  546. **}. This indicates that we have previously defined a variable with name
  547. @code{J} of type ideal (see above).
  548. To obtain a representing set of the quotient vector space we first
  549. calculate a standard basis, then we apply the function @code{kbase} to
  550. this standard basis.
  551. @smallexample
  552. J = groebner(J);
  553. ideal K = kbase(J);
  554. K;
  555. @expansion{} K[1]=y4
  556. @expansion{} K[2]=xy3
  557. @expansion{} K[3]=y3
  558. @expansion{} K[4]=xy2
  559. @expansion{} K[5]=y2
  560. @expansion{} K[6]=x2y
  561. @expansion{} K[7]=xy
  562. @expansion{} K[8]=y
  563. @expansion{} K[9]=x3
  564. @expansion{} K[10]=x2
  565. @expansion{} K[11]=x
  566. @expansion{} K[12]=1
  567. @end smallexample
  568. @noindent Then
  569. @smallexample
  570. size(K);
  571. @expansion{} 12
  572. @end smallexample
  573. @noindent gives the desired vector space dimension
  574. @tex
  575. $K[x,y,z]/\hbox{\rm jacob}(f)$.
  576. @end tex
  577. @ifinfo
  578. K[x,y,z]/jacob(f).
  579. @end ifinfo
  580. As in @sc{Singular} the functions may take the input directly from
  581. earlier calculations, the whole sequence of commands may be written
  582. in one single statement.
  583. @smallexample
  584. size(kbase(groebner(jacob(f))));
  585. @expansion{} 12
  586. @end smallexample
  587. When we are not interested in a basis of the quotient vector space, but
  588. only in the resulting dimension we may even use the command @code{vdim}
  589. and write:
  590. @smallexample
  591. vdim(groebner(jacob(f)));
  592. @expansion{} 12
  593. @end smallexample
  594. @c ------------------------------------------------------------------
  595. @node Procedures and libraries, Change of rings, Rings and standard bases, Getting started
  596. @ifset singularmanual
  597. @subsection Procedures and libraries
  598. @end ifset
  599. @ifclear singularmanual
  600. @section Procedures and libraries
  601. @end ifclear
  602. @cindex Procedures and libraries
  603. @sc{Singular} offers a comfortable programming language, with a syntax
  604. close to C. So it is possible to define procedures which collect several
  605. commands to a new one. Procedures are defined with the keyword
  606. @code{proc} followed by a name and an optional parameter list with
  607. specified types. Finally, a procedure may return values using the
  608. command @code{return}.
  609. Define the following procedure called @code{Milnor}:
  610. @smallexample
  611. proc Milnor (poly h)
  612. @{
  613. return(vdim(groebner(jacob(h))));
  614. @}
  615. @end smallexample
  616. Note: if you have entered the first line of the procedure and pressed
  617. @code{RETURN}, @sc{Singular} prints the prompt @code{.} (dot) instead of
  618. the usual prompt @code{>} . This shows that the input is incomplete and
  619. @sc{Singular} expects more lines. After typing the closing curly
  620. bracket, @sc{Singular} prints the usual prompt indicating that the input
  621. is now complete.
  622. @noindent Then call the procedure:
  623. @smallexample
  624. Milnor(f);
  625. @expansion{} 12
  626. @end smallexample
  627. @noindent Note that the result may depend on the basering as we will
  628. see in the next chapter.
  629. The distribution of @sc{Singular} contains several libraries, each of
  630. which is a collection of useful
  631. procedures based on the kernel commands, which extend the functionality
  632. of @sc{Singular}. The command @code{help "all.lib";} lists all libraries
  633. together with a one-line explanation.
  634. @c The command @code{help}
  635. @c library_name@code{;} lists all procedures of the library, @code{help}
  636. @c proc_name@code{;} shows an explanation of the procedure after the
  637. @c library has been loaded. The command @code{LIB "all.lib";} loads all
  638. @c libraries.
  639. One of these libraries is @code{sing.lib} which already contains a
  640. procedure called @code{milnor} to calculate the Milnor number not only
  641. for hypersurfaces but more generally for complete intersection
  642. singularities.
  643. Libraries are loaded with the command @code{LIB}. Some additional
  644. information during the process of loading is displayed on the screen,
  645. which we omit here.
  646. @smallexample
  647. LIB "sing.lib";
  648. @end smallexample
  649. As all input in @sc{Singular} is case sensitive, there is no conflict with
  650. the previously defined procedure @code{Milnor}, but the result is the same.
  651. @smallexample
  652. milnor(f);
  653. @expansion{} 12
  654. @end smallexample
  655. The procedures in a library have a help part
  656. which is displayed by typing
  657. @smallexample
  658. help milnor;
  659. @c @expansion{} // proc milnor from lib sing.lib
  660. @c @expansion{} proc milnor (ideal i)
  661. @c @expansion{} USAGE: milnor(i); i ideal or poly
  662. @c @expansion{} RETURN: Milnor number of i, if i is ICIS (isolated complete intersection
  663. @c @expansion{} singularity) in generic form, resp. -1 if not
  664. @c @expansion{} NOTE: use proc nf_icis to put generators in generic form
  665. @c @expansion{} printlevel >=0: display comments (default)
  666. @c @expansion{} EXAMPLE: example milnor; shows an example
  667. @c @expansion{}
  668. @end smallexample
  669. @noindent as well as some examples, which are executed by
  670. @smallexample
  671. example milnor;
  672. @c @expansion{} // proc milnor from lib sing.lib
  673. @c @expansion{} EXAMPLE:
  674. @c @expansion{} int p = printlevel;
  675. @c @expansion{} printlevel = 1;
  676. @c @expansion{} ring r = 32003,(x,y,z),ds;
  677. @c @expansion{} ideal j = x5+y6+z6,x2+2y2+3z2,xyz+yx;
  678. @c @expansion{} milnor(j);
  679. @c @expansion{} //sequence of discriminant numbers: 100,149,70
  680. @c @expansion{} 21
  681. @c @expansion{} poly f = x7+y7+(x-y)^2*x2y2+z2;
  682. @c @expansion{} milnor(f);
  683. @c @expansion{} 28
  684. @c @expansion{} printlevel = p;
  685. @c @expansion{}
  686. @end smallexample
  687. @noindent Likewise, the library itself has a help part, to show a list of
  688. all the functions
  689. available for the user which are contained in the library.
  690. @smallexample
  691. help sing.lib;
  692. @end smallexample
  693. @noindent The output of the help commands is omitted here.
  694. @c ------------------------------------------------------------------
  695. @node Change of rings, Modules and their annihilator, Procedures and libraries, Getting started
  696. @ifset singularmanual
  697. @subsection Change of rings
  698. @end ifset
  699. @ifclear singularmanual
  700. @section Change of rings
  701. @end ifclear
  702. @cindex Change of rings
  703. To calculate the local Milnor number we have to do the calculation with the
  704. same commands in a ring with local ordering.
  705. @ifset singularmanual
  706. Define the localization of the polynomial ring at the origin
  707. (@pxref{Polynomial data}, and @ref{Mathematical background}).
  708. @end ifset
  709. @ifclear singularmanual
  710. Define the localization of the polynomial ring at the origin.
  711. @end ifclear
  712. @smallexample
  713. ring rl = 0,(x,y,z),ds;
  714. @end smallexample
  715. This ordering determines the standard basis which will be calculated.
  716. Fetch the polynomial defined in the ring @code{r} into this new ring,
  717. thus avoiding retyping the input.
  718. @smallexample
  719. poly f = fetch(r,f);
  720. f;
  721. @expansion{} z2+x3+y3+x3y2-x2y3
  722. @end smallexample
  723. @noindent Instead of @code{fetch} we can use the function @code{imap}
  724. which is more general but less efficient.
  725. @ifset singularmanual
  726. The most general way to fetch data from one ring to another is to use maps,
  727. this will be explained in @ref{map}.
  728. @end ifset
  729. @ifclear singularmanual
  730. The most general way to fetch data from one ring to another is to use maps.
  731. @end ifclear
  732. In this ring the terms are ordered by increasing exponents. The local Milnor
  733. number is now
  734. @smallexample
  735. Milnor(f);
  736. @expansion{} 4
  737. @end smallexample
  738. This shows that @code{f} has outside the origin in affine 3-space
  739. singularities with local Milnor number adding up to
  740. @tex
  741. $12-4=8$.
  742. @end tex
  743. @ifinfo
  744. 12-4=8.
  745. @end ifinfo
  746. Using global and local orderings as above is a convenient way to check
  747. whether a variety has singularities outside the origin.
  748. The command @code{jacob} applied twice gives the Hessian of @code{f}, a
  749. 3x3 - matrix.
  750. @smallexample
  751. matrix H = jacob(jacob(f));
  752. H;
  753. @expansion{} H[1,1]=6x+6xy2-2y3
  754. @expansion{} H[1,2]=6x2y-6xy2
  755. @expansion{} H[1,3]=0
  756. @expansion{} H[2,1]=6x2y-6xy2
  757. @expansion{} H[2,2]=6y+2x3-6x2y
  758. @expansion{} H[2,3]=0
  759. @expansion{} H[3,1]=0
  760. @expansion{} H[3,2]=0
  761. @expansion{} H[3,3]=2
  762. @end smallexample
  763. The @code{print} command displays the matrix in a nicer form.
  764. @smallexample
  765. print(H);
  766. @expansion{} 6x+6xy2-2y3,6x2y-6xy2, 0,
  767. @expansion{} 6x2y-6xy2, 6y+2x3-6x2y,0,
  768. @expansion{} 0, 0, 2
  769. @end smallexample
  770. We may calculate the determinant and (the ideal generated by all) minors of
  771. a given size.
  772. @smallexample
  773. det(H);
  774. @expansion{} 72xy+24x4-72x3y+72xy3-24y4-48x4y2+64x3y3-48x2y4
  775. minor(H,1); // the 1x1 - minors
  776. @expansion{} _[1]=2
  777. @expansion{} _[2]=6y+2x3-6x2y
  778. @expansion{} _[3]=6x2y-6xy2
  779. @expansion{} _[4]=6x2y-6xy2
  780. @expansion{} _[5]=6x+6xy2-2y3
  781. @end smallexample
  782. The algorithm of the standard basis computations may be
  783. affected by the command @code{option}. For example, a reduced standard
  784. basis of the ideal generated by the
  785. @tex
  786. $1 \times 1$-minors
  787. @end tex
  788. @ifinfo
  789. 1 x 1 - minors
  790. @end ifinfo
  791. of H is obtained in the following way:
  792. @smallexample
  793. option(redSB);
  794. groebner(minor(H,1));
  795. @expansion{} _[1]=1
  796. @end smallexample
  797. This shows that 1 is contained in the ideal of the
  798. @tex
  799. $1 \times 1$-minors,
  800. @end tex
  801. @ifinfo
  802. 1 x 1 - minors,
  803. @end ifinfo
  804. hence the corresponding variety is empty.
  805. @c Coming back to some mathematical considerations, we study the problem how
  806. @c to calculate some ....
  807. @c ------------------------------------------------------------------
  808. @c REMEMBER TO EDIT NEXT AND PREVIOUS NODE IF YOU UNCOMMENT THIS NODE!
  809. @c @node Maps and elimination, Modules and their annihilator, Change of rings, Getting started
  810. @c @subsection Maps and elimination
  811. @c @cindex Maps and elimination
  812. @c ------------------------------------------------------------------
  813. @node Modules and their annihilator, Resolution, Change of rings, Getting started
  814. @ifset singularmanual
  815. @subsection Modules and their annihilator
  816. @end ifset
  817. @ifclear singularmanual
  818. @section Modules and their annihilator
  819. @end ifclear
  820. @cindex Modules and and their annihilator
  821. Now we shall give three more advanced examples.
  822. @sc{Singular} is able to handle modules over all the rings,
  823. which can be defined as a basering. A free module of rank @code{n}
  824. is defined as follows:
  825. @smallexample
  826. ring rr;
  827. int n = 4;
  828. freemodule(4);
  829. @expansion{} _[1]=gen(1)
  830. @expansion{} _[2]=gen(2)
  831. @expansion{} _[3]=gen(3)
  832. @expansion{} _[4]=gen(4)
  833. typeof(_);
  834. @expansion{} module
  835. print(freemodule(4));
  836. @expansion{} 1,0,0,0,
  837. @expansion{} 0,1,0,0,
  838. @expansion{} 0,0,1,0,
  839. @expansion{} 0,0,0,1
  840. @end smallexample
  841. To define a module, we give a list of vectors generating a submodule of
  842. a free module. Then this set of vectors may be identified with the
  843. columns of a matrix. For that reason in @sc{Singular} matrices and
  844. modules may be interchanged. However, the representation is different
  845. (modules may be considered as sparse represented matrices).
  846. @smallexample
  847. ring r =0,(x,y,z),dp;
  848. module MD = [x,0,x],[y,z,-y],[0,z,-2y];
  849. matrix MM = MD;
  850. print(MM);
  851. @expansion{} x,y,0,
  852. @expansion{} 0,z,z,
  853. @expansion{} x,-y,-2y
  854. @end smallexample
  855. However the submodule
  856. @ifinfo
  857. @math{MD}
  858. @end ifinfo
  859. @tex
  860. $MD$
  861. @end tex
  862. may also be considered as the module
  863. of relations of the factor module
  864. @tex
  865. $r^3/MD$.
  866. @end tex
  867. @ifinfo
  868. r^3/MD.
  869. @end ifinfo
  870. In this way, @sc{Singular} can treat arbitrary finitely generated modules
  871. over the
  872. @ifset singularmanual
  873. basering (@pxref{Representation of mathematical objects}).
  874. @end ifset
  875. @ifclear singularmanual
  876. basering.
  877. @end ifclear
  878. In order to get the module of relations of
  879. @ifinfo
  880. @math{MD}
  881. @end ifinfo
  882. @tex
  883. $MD$
  884. @end tex
  885. ,
  886. we use the command @code{syz}.
  887. @smallexample
  888. syz(MD);
  889. @expansion{} _[1]=x*gen(3)-x*gen(2)+y*gen(1)
  890. @end smallexample
  891. We want to calculate, as an application, the annihilator of a given module.
  892. Let
  893. @tex
  894. $M = r^3/U$,
  895. @end tex
  896. @ifinfo
  897. M = r^3/U,
  898. @end ifinfo
  899. where U is our defining module of relations for the module
  900. @tex
  901. $M$.
  902. @end tex
  903. @ifinfo
  904. M.
  905. @end ifinfo
  906. @smallexample
  907. module U = [z3,xy2,x3],[yz2,1,xy5z+z3],[y2z,0,x3],[xyz+x2,y2,0],[xyz,x2y,1];
  908. @end smallexample
  909. Then, by definition, the annihilator of M is the ideal
  910. @tex
  911. $\hbox{ann}(M) = \{a \mid aM = 0 \}$
  912. @end tex
  913. @ifinfo
  914. ann(M) = @{a | aM = 0 @}
  915. @end ifinfo
  916. which is by the description of M the same as
  917. @tex
  918. $\{ a \mid ar^3 \in U \}$.
  919. @end tex
  920. @ifinfo
  921. @{ a | ar^3 contained in U@}.
  922. @end ifinfo
  923. Hence we have to calculate the quotient
  924. @tex
  925. $U \colon r^3 $.
  926. @end tex
  927. @ifinfo
  928. U:r^3.
  929. @end ifinfo
  930. The rank of the free module is determined by the choice of U and is the
  931. number of rows of the corresponding matrix. This may be determined by
  932. the function @code{nrows}. All we have to do now is the following:
  933. @smallexample
  934. quotient(U,freemodule(nrows(U)));
  935. @end smallexample
  936. @noindent The result is too big to be shown here.
  937. @c ------------------------------------------------------------------
  938. @node Resolution, , Modules and their annihilator, Getting started
  939. @ifset singularmanual
  940. @subsection Resolution
  941. @end ifset
  942. @ifclear singularmanual
  943. @section Resolution
  944. @end ifclear
  945. @cindex Resolution
  946. There are several commands in @sc{Singular} for computing free resolutions.
  947. The most general command is @code{res(... ,n)} which determines heuristically
  948. what method to use for the given problem. It computes the free resolution
  949. up to the length
  950. @ifinfo
  951. @math{n}
  952. @end ifinfo
  953. @tex
  954. $n$
  955. @end tex
  956. , where
  957. @ifinfo
  958. @math{n=0}
  959. @end ifinfo
  960. @tex
  961. $n=0$
  962. @end tex
  963. corresponds to the full resolution.
  964. Here we use the possibility to inspect the calculation process using the
  965. option @code{prot}.
  966. @smallexample
  967. ring R; // the default ring in char 32003
  968. R;
  969. @expansion{} // characteristic : 32003
  970. @expansion{} // number of vars : 3
  971. @expansion{} // block 1 : ordering dp
  972. @expansion{} // : names x y z
  973. @expansion{} // block 2 : ordering C
  974. ideal I = x4+x3y+x2yz,x2y2+xy2z+y2z2,x2z2+2xz3,2x2z2+xyz2;
  975. option(prot);
  976. resolution rs = res(I,0);
  977. @expansion{} using lres
  978. @expansion{} 4(m0)4(m1).5(m1)g.g6(m1)...6(m2)..
  979. @end smallexample
  980. @noindent Disable this protocol with
  981. @smallexample
  982. option(noprot);
  983. @end smallexample
  984. When we enter the name of the calculated resolution, we get a pictorial
  985. description of the minimized resolution where the exponents denote the rank of the
  986. free modules. Note that the calculated resolution itself may not yet be minimal.
  987. @smallexample
  988. rs;
  989. @expansion{} 1 4 5 2 0
  990. @expansion{}R <-- R <-- R <-- R <-- R
  991. @expansion{}
  992. @expansion{}0 1 2 3 4
  993. print(betti(rs),"betti");
  994. @expansion{} 0 1 2 3
  995. @expansion{} ------------------------------
  996. @expansion{} 0: 1 - - -
  997. @expansion{} 1: - - - -
  998. @expansion{} 2: - - - -
  999. @expansion{} 3: - 4 1 -
  1000. @expansion{} 4: - - 1 -
  1001. @expansion{} 5: - - 3 2
  1002. @expansion{} ------------------------------
  1003. @expansion{} total: 1 4 5 2
  1004. @end smallexample
  1005. In order to minimize the resolution, that is to calculate the maps of the minimal
  1006. free resolution, we use the command @code{minres}:
  1007. @smallexample
  1008. rs=minres(rs);
  1009. @end smallexample
  1010. A single module in this resolution is obtained (as usual) with the
  1011. brackets @code{[} and @code{]}. The @code{print} command can be used to
  1012. display a module in a more readable format:
  1013. @smallexample
  1014. print(rs[3]);
  1015. @expansion{} z3, -xyz-y2z-4xz2+16z3,
  1016. @expansion{} 0, -y2,
  1017. @expansion{} -y+4z,48z,
  1018. @expansion{} x+2z, 48z,
  1019. @expansion{} 0, x+y-z
  1020. @end smallexample
  1021. In this case, the output is to be interpreted as follows: the 3rd syzygy
  1022. module of R/I, @code{rs[3]}, is the rank-2-submodule of
  1023. @tex
  1024. $R^5$
  1025. @end tex
  1026. @ifinfo
  1027. R^5
  1028. @end ifinfo
  1029. generated by the vectors
  1030. @tex
  1031. $(z^3,0,-y+4z,x+2z,0)$ and $(-xyz-y^2z-4xz^2+16z^3,-y^2,48z,48z,x+y-z)$.
  1032. @end tex
  1033. @ifinfo
  1034. (z^3,0,-y+4z,x+2z,0) and (-xyz-y^2z-4xz^2+16z^3,-y^2,48z,48z,x+y-z).
  1035. @end ifinfo