assist.tex 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. \documentstyle[11pt,reduce]{article}
  2. \newcommand{\nl}{\hfill\newline}
  3. \newcommand{\bq}{\begin{quotation}}
  4. \newcommand{\eq}{\end{quotation}}
  5. \newcommand{\bi}{\begin{itemize}}
  6. \newcommand{\ei}{\end{itemize}}
  7. \date{}
  8. \title{{\bf ASSIST}\ :\\[2pt]
  9. A General Purpose Facility~for~\REDUCE \\[5pt]
  10. \mbox{\hfill Version 2.0\hfil}}
  11. \author{Hubert Caprasse \\
  12. D\'epartement d'Astronomie et d'Astrophysique \\
  13. Institut de Physique, B--5, Sart Tilman \\
  14. B--4000 LIEGE 1 \\[3pt]
  15. E--mail: caprasse@vm1.ulg.ac.be}
  16. \begin{document}
  17. \maketitle
  18. \index{ASSIST package}
  19. \section{Introduction}
  20. ASSIST contains
  21. an appreciable number of additional general purpose functions which allow
  22. to better adapt \REDUCE\ to various calculational strategies,
  23. to make the programming task more straightforward and more efficient.
  24. Contrary to all other packages, ASSIST does not aim to provide neither a new
  25. facility to compute a definite class of mathematical objects nor to extend
  26. the base of mathematical knowledge of \REDUCE\ .
  27. The functions it contains should be
  28. useful independently of the nature of the application which is considered.
  29. They were initially written while doing specific applications of
  30. \REDUCE\ to problems in theoretical physics. Most them were designed
  31. in such a way that their applicability range is broad. Though it was not
  32. the primary goal, efficiency has been sought whenever possible.
  33. The source code in ASSIST contains many comments concerning
  34. the meaaning and the use of the supplementary functions available
  35. in the algebraic mode. These comments, hopefully, makes the code transparent
  36. and allow a thorough exploitation of the package. The present documentation
  37. contains a non--technical description of it and describes the
  38. various new facilities it provides.
  39. \section{ Survey of the Available New Facilities}
  40. The package contains several modules. Their content reflects closely
  41. the various categories of facilities quoted below. Some functions do
  42. already exist inside the KERNEL of \REDUCE\ . However, their range
  43. of applicability is {\em extended}.
  44. \begin{itemize}
  45. \item{Control of Switches:}
  46. \begin{quotation}
  47. \noindent
  48. \f{SWITCHES SWITCHORG}
  49. \end{quotation}
  50. \item{Operations on Lists and Bags:}
  51. \begin{quotation}
  52. \noindent
  53. \f{MKLIST KERNLIST FREQUENCY SEQUENCES \nl
  54. INSERT INSERT\_KEEP\_ORDER MERGE\_LIST \nl
  55. REMOVE DELETE DELETE\_ALL DELPAIR \nl
  56. FIRST SECOND THIRD REST REVERSE LAST \nl
  57. BELAST CONS ( . ) APPEND APPENDN \nl
  58. LENGTH REMOVE DELETE DELPAIR \nl
  59. MEMBER ELMULT PAIR DEPTH POSITION \nl
  60. REPFIRST REPREST ASFIRST ASLAST ASREST \nl
  61. ASFLIST ASSLIST RESTASLIST SUBSTITUTE \nl
  62. BAGPROP PUTBAG CLEARBAG BAGP BAGLISTP \nl
  63. ALISTP ABAGLISTP LISTBAG }
  64. \end{quotation}
  65. \item{Operations on Sets:}
  66. \begin{quotation}
  67. \noindent
  68. \f{MKSET SETP UNION INTERSECT DIFFSET SYMDIFF}
  69. \end{quotation}
  70. \item{General Purpose Utility Functions:}
  71. \begin{quotation}
  72. \noindent
  73. \f{LIST\_TO\_IDS MKIDN MKIDNEW DELLASTDIGIT DETIDNUM \\
  74. ODDP FOLLOWLINE == RANDOMLIST \\
  75. PERMUTATIONS CYCLICPERMLIST COMBNUM COMBINATIONS \\
  76. SYMMETRIZE REMSYM SORTNUMLIST SORTLIST EXTREMUM \\
  77. DEPATOM FUNCVAR IMPLICIT EXPLICIT KORDERLIST \\
  78. SIMPLIFY CHECKPROPLIST EXTRACTLIST}
  79. \end{quotation}
  80. \item{ Properties and Flags:}
  81. \begin{quotation}
  82. \noindent
  83. \f{PUTFLAG PUTPROP DISPLAYPROP DISPLAYFLAG \\
  84. CLEARFLAG CLEARPROP }
  85. \end{quotation}
  86. \item{ Control Statements, Control of Environment:}
  87. \begin{quotation}
  88. \noindent
  89. \f{NORDP DEPVARP ALATOMP ALKERNP PRECP \\
  90. SHOW SUPPRESS CLEAROP CLEARFUNCTIONS }
  91. \end{quotation}
  92. \item{Handling of Polynomials:}
  93. \begin{quotation}
  94. \noindent
  95. \f{ALG\_TO\_SYMB SYMB\_TO\_ALG \\
  96. DISTRIBUTE LEADTERM REDEXPR MONOM\\
  97. LOWESTDEG DIVPOL SPLITTERMS SPLITPLUSMINUS}
  98. \end{quotation}
  99. % \vfill\pagebreak
  100. \item{Handling of Transcendental Functions:}
  101. \begin{quotation}
  102. \noindent
  103. \f{TRIGEXPAND HYPEXPAND TRIGREDUCE HYPREDUCE \\
  104. PLUSLOG CONCSUMLOG}
  105. \end{quotation}
  106. \item{Handling of n-dimensional Vectors:}
  107. \begin{quotation}
  108. \noindent
  109. \f{SUMVECT MINVECT SCALVECT CROSSVECT MPVECT }
  110. \end{quotation}
  111. {\item Handling of Grassmann Operators:}
  112. \begin{quotation}
  113. \noindent
  114. \f{PUTGRASS REMGRASS GRASSP GRASSPARITY GHOSTFACTOR }
  115. \end{quotation}
  116. \item{Handling of Matrices:}
  117. \begin{quotation}
  118. \noindent
  119. \f{UNITMAT MKIDM BAGLMAT COERCEMAT \\
  120. SUBMAT MATSUBR MATSUBC RMATEXTR RMATEXTC \\
  121. HCONCMAT VCONCMAT TPMAT HERMAT \\
  122. SETELTMAT GETELTMAT}
  123. \end{quotation}
  124. \end{itemize}
  125. In the following each group of functions is, successively, described.
  126. \section{Control of Switches}
  127. The two available functions i.e. \f{SWITCHES, SWITCHORG} have
  128. no argument and are called as if they were mere identifiers.
  129. \f{SWITCHES} displays the actual status of the most often used switches
  130. when manipulating rational functions. The chosen switches are
  131. \begin{quotation}
  132. \noindent
  133. {\tt EXP, DIV, MCD, GCD, ALLFAC, INTSTR,\\ RAT, RATIONAL, FACTOR }
  134. \end{quotation}
  135. The switch {\tt DISTRIBUTE} which controls the handling
  136. of distributed polynomials is added to them (see below the description of
  137. the new functions for manipulating polynomials ).
  138. The selection is somewhat arbitrary but it may be changed in a trivial
  139. fashion by the user.
  140. Most of the symbolic variables {\tt !*EXP, !*DIV, $\ldots$}
  141. which have either the value T or the value NIL are made available in the
  142. algebraic mode so that it becomes possible to write conditional
  143. statements of the kind
  144. \begin{verbatim}
  145. IF !*EXP THEN DO ......
  146. IF !*GCD THEN OFF GCD;
  147. \end{verbatim}
  148. \f{SWITCHORG} resets (almost) {\em all} switches in the status
  149. they have when {\bf entering} into \REDUCE\ .
  150. The new switch {\tt DISTRIBUTE} allows to put polynomials in a
  151. distributed form.
  152. \section{Manipulation of the List Structure}
  153. Additional functions for list manipulations are provided and some already
  154. defined functions in the kernel of \REDUCE\ are modified to properly
  155. generalize them to the available new structure {\tt BAG}.
  156. \begin{itemize}
  157. \item[i.]
  158. Generation of a list of length n with all its elements initialized to 0
  159. and possibility to append to a list $l$ a certain number of zero's to
  160. make it of length $n$:
  161. \begin{verbatim}
  162. MKLIST n ; n is an INTEGER
  163. MKLIST(l,n); l is List-like, n is an INTEGER
  164. \end{verbatim}
  165. \item[ii.]
  166. Generation of a list of sublists of length n containing p elements
  167. equal to 0 and q elements equal to 1 such that $$p+q=n .$$
  168. The function \f{SEQUENCES} works both in the algebraic and
  169. symbolic modes. Here is an example:
  170. \begin{verbatim}
  171. SEQUENCES 2 ; ==> {{0,0},{0,1},{1,0},{1,1}}
  172. \end{verbatim}
  173. The function \f{KERNLIST} transforms any prefix of a kernel into the
  174. {\bf \verb+list+} prefix. The output list is a copy:
  175. \begin{verbatim}
  176. KERNLIST (<kernel>); ==> {<kernel arguments>}
  177. \end{verbatim}
  178. Four functions to delete elements are \f{DELETE, REMOVE, DELETE\_ALL} and
  179. \f{DELPAIR}. The first two act as in symbolic mode, the third
  180. eliminates from a given list {\em all}
  181. elements equal to its first argument. The fourth act on list of pairs
  182. and eliminates from it the {\em first} pair whose first element is equal to
  183. its first argument :
  184. \begin{verbatim}
  185. DELETE(x,{a,b,x,f,x}); ==> {a,b,f,x}
  186. REMOVE({a,b,x,f,x},3); ==> {a,b,f,x}
  187. DELETE_ALL(x,{a,b,x,f,x}); ==> {a,b,f}
  188. DELPAIR(a,{{a,1},{b,2},{c,3}}; ==> {{b,2},{c,3}}
  189. \end{verbatim}
  190. \item[iv.]
  191. The function \f{ELMULT} returns an {\em integer} which is the
  192. {\em multiplicity} of its first argument inside the list which is its
  193. second argument.
  194. The function \f{FREQUENCY} gives a list of pairs
  195. whose second element indicates the number of times the first element
  196. appears inside the original list:
  197. \begin{verbatim}
  198. ELMULT(x,{a,b,x,f,x}) ==> 2
  199. FREQUENCY({a,b,c,a}); ==> {{a,2},{b,1},{c,1}}
  200. \end{verbatim}
  201. \item[v.]
  202. The function \f{INSERT} allows to insert a given object into a list
  203. at the wanted position.
  204. The functions \f{INSERT\_KEEP\_ORDER} and \f{MERGE\_LIST} allow to
  205. keep a given ordering when inserting one element inside a list or
  206. when merging two lists. Both have 3 arguments. The last one is
  207. the name of a binary boolean ordering function:
  208. \begin{verbatim}
  209. ll:={1,2,3}$
  210. INSERT(x,ll,3); ==> {1,2,x,3}
  211. INSERT_KEEP_ORDER(5,ll,lessp); ==> {1,2,3,5}
  212. MERGE_LIST(ll,ll,lessp); ==> {1,1,2,2,3,3}
  213. \end{verbatim}
  214. \item[vi.]
  215. Algebraic lists can be read from right to left or left to right.
  216. They {\em look} symmetrical. One would like to dispose of manipulation
  217. functions which reflect this.
  218. So, to the already defined functions \f{FIRST} and \f{REST} are
  219. added the functions \f{LAST} and \f{BELAST}. \f{LAST} gives the last
  220. element of the list while \f{BELAST} gives the list {\em without} its
  221. last element. \\
  222. Various additional functions are provided. They are:
  223. \bq
  224. \f{ CONS (.), POSITION, DEPTH, PAIR, \\
  225. APPENDN, REPFIRST, REPLAST}
  226. \eq
  227. The token ``dot'' needs a special comment. It corresponds to
  228. several different operations.
  229. \begin{enumerate}
  230. \item If one applies it on the left of a list, it acts as the \f{CONS}
  231. function. Be careful, blank spaces are required around the dot:
  232. \begin{verbatim}
  233. 4 . {a,b}; ==> {4,a,b}
  234. \end{verbatim}
  235. \item If one applies it on the right of a list, it has the same
  236. effect as the \f{PART} operator:
  237. \begin{verbatim}
  238. {a,b,c}.2; ==> b
  239. \end{verbatim}
  240. \item If one applies it on 4--dimensional vectors, it acts as in the
  241. HEPHYS packge.
  242. \end{enumerate}
  243. \f{POSITION} returns the POSITION of the first occurrence of x in
  244. a list or a message if x is not present in it.
  245. \f{DEPTH} returns an {\em integer} equal to the number of levels where a
  246. list is found if and only if this number is the {\em same} for each
  247. element of the list otherwise it returns a message telling the user
  248. that list is of {\em unequal depth}.
  249. \f{PAIR} has two arguments which must be lists. It returns a list
  250. whose elements are {\em lists of two elements.}
  251. The $n^{th}$ sublist contains the $n^{th}$ element of the first list
  252. and the $n^{th}$ element of the second list. These types of lists are called
  253. {\em association lists} or ALISTS in the following.
  254. To test for these type of lists a boolean function \f{ABAGLISTP}
  255. is provided. It will be discussed below.\\
  256. \f{APPENDN} has {\em any} fixed number of lists as arguments. It
  257. generalizes the already existing function \f{APPEND} which accepts
  258. only two lists as arguments. \\
  259. \f{REPFIRST} has two arguments. The first one is any object, the second one
  260. is a list. It replaces the first element of the list by tho object. It
  261. works like the symbolic function \f{REPLACA} except that the
  262. original list is not destroyed.\\
  263. \f{REPREST} has also two arguments. It replaces the rest of the list by
  264. its first argument and returns the new list without destroying the
  265. original list. It is analogous to the symbolic function \f{REPLACD}.
  266. Here are examples:
  267. \begin{verbatim}
  268. ll:={{a,b}}$
  269. ll1:=ll.1; ==> {a,b}
  270. ll.0; ==> list
  271. 0 . ll; ==> {0,{a,b}}
  272. DEPTH ll; ==> 2
  273. PAIR(ll1,ll1); ==> {{a,a},{b,b}}
  274. REPFIRST{new,ll); ==> {new}
  275. ll3:=APPENDN(ll1,ll1,ll1); ==> {a,b,a,b,a,b}
  276. POSITION(b,ll3); ==> 2
  277. REPREST(new,ll3); ==> {a,new}
  278. \end{verbatim}
  279. \item[vii.]
  280. The functions \f{ASFIRST, ASLAST, ASREST, ASFLIST, ASSLIST, \\RESTASLIST}
  281. act on ALISTS or on list of lists of well defined depths
  282. and have two arguments. The first is the key object
  283. which one seeks to associate in some way to an element of the association
  284. list which is the second argument.\\
  285. \f{ASFIRST} returns the pair whose first element is equal to the
  286. first argument.\\
  287. \f{ASLAST} returns the pair whose last element is equal to the first
  288. argument.\\
  289. \f{ASREST} needs a {\em list} as its first argument. The function
  290. seeks the first sublist of a list of lists (which is its second argument)
  291. equal to its first argument and returns it.\\
  292. \f{RESTASLIST} has a {\em list of keys} as its first arguments. It
  293. returns the collection of pairs which meet the criterium of \f{ASREST}.\\
  294. \f{ASFLIST} returns a list containing {\em all pairs} which
  295. satisfy to the criteria of the function \f{ASFIRST}. So the output
  296. is also an ALIST or a list of lists.\\
  297. \f{ASSLIST} returns a list which contains {\em all pairs} which have
  298. their second element equal to the first argument.\\
  299. Here are a few examples:
  300. \begin{verbatim}
  301. lp:={{a,1},{b,2},{c,3}}$
  302. ASFIRST(a,lp); ==> {a,1}
  303. ASLAST(1,lp); ==> {a,1}
  304. ASREST({1},lp); ==> {a,1}
  305. RESTASLIST({a,b},lp); ==> {{1},{2}}
  306. lpp:=APPEND(lp,lp)$
  307. ASFLIST(a,lpp); ==> {{a,1},{a,1}}
  308. ASSLIST(1,lpp); ==> {{a,1},{a,1}}
  309. \end{verbatim}
  310. \item[vii.] The function \f{SUBSTITUTE} has three arguments. The first
  311. is the object to substitute, the second is the object which must be
  312. replaced by the first, the third is a list. Substitution is made to
  313. all levels. It is a more elementary function than \f{SUB} but its
  314. capabilities are less. When dealing with algebraic quantities, it is
  315. important to make sure that {\em all} objects involved in the function
  316. have either the prefix lisp or the standard quotient representation
  317. otherwise it will not properly work.
  318. \end{itemize}
  319. \section{ The Bag Structure and its Associated Functions}
  320. The LIST structure of \REDUCE\ is very convenient to manipulate
  321. groups of objects which are, a priori, unknown. This structure is
  322. endowed with other properties such as ``mapping'' i.e. the fact that
  323. if \verb+OP+ is an operator one gets, by default,
  324. \begin{verbatim}
  325. OP({x,y}); ==> {OP(x),OP(y)}
  326. \end{verbatim}
  327. It is not permitted to submit lists to the operations valid on rings
  328. so that lists cannot be indeterminates of polynomials.\\
  329. Very frequently too, procedure arguments cannot be lists.
  330. At the other extreme, so to say, one has the \verb+KERNEL+
  331. structure associated
  332. to the algebraic declaration \verb+operator+ . This structure behaves as
  333. an ``unbrokable'' one and, for that reason, behaves
  334. like an ordinary identifier.
  335. It may generally be bound to all non-numeric procedure parameters
  336. and it may appear
  337. as an ordinary indeterminate inside polynomials. \\
  338. The \verb+BAG+ structure is intermediate between a list and an operator.
  339. From the operator it borrows the property to be a \verb+KERNEL+ and,
  340. therefore, may be an indeterminate of a polynomial. From the list structure
  341. it borrows the property to be a {\em composite} object.\\[5pt]
  342. \mbox{\underline{{\bf Definition}:\hfill}}\\[4pt]
  343. A bag is an object endowed with the following properties:
  344. \begin{enumerate}
  345. \item It is a \verb+KERNEL+ composed of an atomic prefix (its
  346. envelope) and
  347. its content (miscellaneous objects).
  348. \item Its content may be changed in an analogous way as the content of a
  349. list. During these manipulations the name of the bag is {\em conserved}.
  350. \item Properties may be given to the envelope. For instance, one may
  351. declare it \verb+NONCOM+ or \verb+SYMMETRIC+ etc.\ $\ldots$
  352. \end{enumerate}
  353. \vspace{5pt}
  354. \mbox{\underline{{\bf Available Functions}:\hfill}}
  355. \bi
  356. \item[i.] A default bag envelope \verb+BAG+ is defined.
  357. It is a reserved identifier.
  358. An identifier other than \verb+LIST+ or one which is already associated
  359. with a boolean function may be defined as a bag envelope through the
  360. command \f{PUTBAG}. In particular, any operator may also be declared
  361. to be a bag. {\bf When and only when} the identifier is not an already defined
  362. function does \f{PUTBAG} puts on it the property of an OPERATOR PREFIX.
  363. The command:
  364. \begin{verbatim}
  365. PUTBAG id1,id2,....idn;
  366. \end{verbatim}
  367. declares \verb+id1,.....,idn+ as bag envelopes.
  368. Analoguously, the command
  369. \begin{verbatim}
  370. CLEARBAG id1,...idn;
  371. \end{verbatim}
  372. eliminates the bag property on \verb+id1,...,idn+.
  373. \item[ii.] The boolean function \f{BAGP} detects the bag property.
  374. Here is an example:
  375. \begin{verbatim}
  376. aa:=bag(x,y,z)$
  377. if BAGP aa then "ok"; ==> ok
  378. \end{verbatim}
  379. \item[iii.] Almost all functions defined above for lists
  380. do also work for bags.
  381. Moreover, functions subsequently defined for SETS do also work.
  382. Here is a list of the main ones:
  383. \begin{quotation}
  384. \f{FIRST, SECOND, LAST, REST, BELAST, DEPTH,\\
  385. LENGTH, APPEND, CONS (.), REPFIRST, REPREST} $\ldots$
  386. \end{quotation}
  387. However, because of the conservation of the envelope, they act
  388. somewhat differently. Here are a few examples (more examples are
  389. given inside the test file):
  390. \begin{verbatim}
  391. PUTBAG op; ==> T
  392. aa:=op(x,y,z)$
  393. FIRST op(x,y,z); ==> op(x)
  394. REST op(x,y,z); ==> op(y,z)
  395. BELAST op(x,y,z); ==> op(x,y)
  396. APPEND(aa,aa); ==> op(x,y,z,x,y,z)
  397. LENGTH aa; ==> 3
  398. DEPTH aa; ==> 1
  399. \end{verbatim}
  400. When ``appending'' two bags with {\em different} envelopes, the resulting bag
  401. gets the name of the one bound to the first parameter of \f{APPEND}.\\
  402. The function \f{LENGTH} gives the actual number of variables on which
  403. the operator (or the function) depends.
  404. \vspace{5pt}
  405. \begin{center}
  406. The NAME of the ENVELOPE is KEPT by the functions \\[3pt]
  407. \f{FIRST, SECOND, LAST, BELAST }.
  408. \end{center}
  409. \vspace{5pt}
  410. \item[iv.]
  411. The connection between the list and the bag structures is made easy
  412. thanks to \f{KERNLIST} which transforms a bag into a list and thanks to
  413. the coercion function \f{LISTBAG}. This function has 2 arguments
  414. and is used as follows:
  415. \begin{verbatim}
  416. LISTBAG(<list>,<id>); ==> <id>(<arg_list>)
  417. \end{verbatim}
  418. The identifier \verb+<id>+, if allowed, is automatically declared as a bag
  419. envelope or an error message is generated. \\[3pt]
  420. Finally, two boolean functions which work both for bags and lists are
  421. provided. They are \f{BAGLISTP} and \f{ABAGLISTP}.
  422. They return t or nil (in a conditional statement) if their argument
  423. is a bag or a list for the first one, if their argument is a list of
  424. sublists or a bag containing bags for the second one .
  425. \end{itemize}
  426. \section{Sets and their Manipulation Functions}
  427. Functions for sets do exist on the level of the symbolic mode. The
  428. package make them available in the algebraic mode but also {\em generalizes}
  429. them so that they can be applied on bag--like objects as well.
  430. \bi
  431. \item[i.]
  432. The constructor \f{MKSET} transforms a list or bag into a set by eliminating
  433. duplicates.
  434. \begin{verbatim}
  435. MKSET({1,a,a1}); ==> {1,a}
  436. MKSET bag(1,a,a1); ==> bag(1,a)
  437. \end{verbatim}
  438. \f{SETP} is a boolean function which recognizes set--like objects.
  439. \begin{verbatim}
  440. if SETP {1,2,3} then ... ;
  441. \end{verbatim}
  442. \item[ii.]
  443. The available functions are
  444. \begin{center}
  445. \f{UNION, INTERSECT, DIFFSET, SYMDIFF}.
  446. \end{center}
  447. They have two arguments which must be sets otherwise an error message
  448. is issued.
  449. Their meaning is transparent from their name. They respectively give the
  450. union, the intersection, the difference and the symmetric difference of two
  451. sets.
  452. \ei
  453. \section{General Purpose Utility Functions}
  454. Functions in this sections have various purposes. They have all been used
  455. many times in applications under some form or another. The form given
  456. to them in this package is adjusted to maximize their range of applications.
  457. \bi
  458. \item[i.]
  459. The functions \f{MKIDNEW DELLASTDIGIT DETIDNUM LIST\_TO\_IDS}
  460. handle identifiers. \f{MKIDNEW} is a variant of \f{MKID}.
  461. \f{MKIDNEW} has either 0 or 1 argument. It generates an identifier which
  462. has not yet been used before.
  463. \begin{verbatim}
  464. MKIDNEW(); ==> g0001
  465. MKIDNEW(a); ==> ag0002
  466. \end{verbatim}
  467. \f{DELLASTDIGIT} takes an integer as argument, it strips it from its last
  468. digit.
  469. \begin{verbatim}
  470. DELLASTDIGIT 45; ==> 4
  471. \end{verbatim}
  472. \f{DETIDNUM}, deletes the last digit from an
  473. identifier. It is a very convenient when one wants to make a do loop
  474. starting from a set of indices $ a_1, \ldots , a_{n} $.
  475. \begin{verbatim}
  476. DETIDNUM a23; ==> 23
  477. \end{verbatim}
  478. \f{LIST\_to\_IDS} generalizes the function \f{MKID} to a list of
  479. atoms. It creates and intern an identifier from the concatenation of
  480. the atoms. The first atom cannot be an integer.
  481. \begin{verbatim}
  482. LIST_TO_IDS {a,1,id,10}; ==> a1id10
  483. \end{verbatim}
  484. The function \f{ODDP} detects odd integers.
  485. The function \f{FOLLOWLINE} is convenient when using the function \f{PRIN2}.
  486. It allows to format an output text in a much more flexible way than with
  487. the function \f{WRITE}. \\
  488. Try the following examples :
  489. \begin{verbatim}
  490. <<prin2 2; prin2 5>>$ ==> ?
  491. <<prin2 2; followline(5); prin2 5;>>; ==> ?
  492. \end{verbatim}
  493. The function \f{==} is a short and convenient notation for the \f{SET}
  494. function. In fact it is a {\em generalization} of it to allow to
  495. deal also with KERNELS:
  496. \begin{verbatim}
  497. operator op;
  498. op(x):=abs(x)$
  499. op(x) == x; ==> x
  500. op(x); ==> x
  501. abs(x); ==> x
  502. \end{verbatim}
  503. The function \f{RANDOMLIST} generates a list of random numbers. It takes
  504. two arguments which are both integers. The first one indicates the range
  505. inside which the random numbers are chosen. The second one indicates how
  506. many numbers are to be generated. It is also the length of the list which
  507. is generated.
  508. \begin{verbatim}
  509. RANDOMLIST(10,5); ==> {2,1,3,9,6}
  510. \end{verbatim}
  511. \f{COMBNUM} gives the number of combinations of $n$ objects
  512. taken $p$ to $p$. It has the two integer arguments $n$ and $p$.
  513. \f{PERMUTATIONS} gives the list of permutations on $n$ objects.
  514. Each permutation is itself a list. \f{CYCLICPERMLIST} gives the list of
  515. {\em cyclic} permutations. For both functions, the argument may
  516. also be a {\tt bag}.
  517. \begin{verbatim}
  518. PERMUTATIONS {1,2} ==> {{1,2},{2,1}}
  519. CYCLICPERMLIST {1,2,3} ==>
  520. {{1,2,3},{2,3,1},{3,1,2}}
  521. \end{verbatim}
  522. \f{COMBINATIONS} gives a list of combinations on $n$ objects taken $p$
  523. to $p$. It has two arguments. The first one is a list (or a bag) and
  524. the second one is the integer $p$.
  525. \begin{verbatim}
  526. COMBINATIONS({1,2,3},2) ==> {{2,3},{1,3},{1,2}}
  527. \end{verbatim}
  528. \f{REMSYM} is a command that erases the \REDUCE\ commands
  529. \verb+symmetric+ or \verb+antisymmetric+ .
  530. \f{SYMMETRIZE} is a powerful function which generate a symmetric expression.
  531. It has 3 arguments. The first is a list (or a list of list) containing
  532. the expressions which will appear as variables for a kernel. The second
  533. argument is the kernel-name and the third is a permutation function
  534. which either exist in the algebraic or in the symbolic mode. This
  535. function may have been constructed by the user. Within this package
  536. the two functions \f{PERMUTATIONS} and \f{CYCLICPERMLIST} may be used.
  537. Here are two examples:
  538. \begin{verbatim}
  539. ll:={a,b,c}$
  540. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  541. OP(A,B,C) + OP(B,C,A) + OP(C,A,B)
  542. SYMMETRIZE(list ll,op,cyclicpermlist); ==>
  543. OP({A,B,C}) + OP({B,C,A}) + OP({C,A,B})
  544. \end{verbatim}
  545. Notice that, taking for the first argument a list of list gives rise to
  546. an expression where each kernel has a {\em list as argument}. Another
  547. peculiarity of this function is the fact that, unless a pattern maching is
  548. made on the operator \verb+OP+, it needs to be reevaluated. This peculiarity
  549. is induced by the need to maximize efficiency when \verb+OP+ is an abstract
  550. operator. Here is an illustration:
  551. \begin{verbatim}
  552. op(a,b,c):=a*b*c$
  553. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  554. OP(A,B,C) + OP(B,C,A) + OP(C,A,B)
  555. for all x let op(x,a,b)=sin(x*a*b);
  556. SYMMETRIZE(ll,op,cyclicpermlist); ==>
  557. OP(B,C,A) + SIN(A*B*C) + OP(A,B,C)
  558. \end{verbatim}
  559. The functions \f{SORTNUMLIST} and \f{SORTLIST} are functions which sort
  560. lists. They use {\em bubblesort} and {\em quicksort} algorithms.
  561. \f{SORTNUMLIST} takes as argument a list of numbers. It sorts it in
  562. increasing order.
  563. \f{SORTLIST} is a generalization of the above function.
  564. It sorts the list according
  565. to any well defined ordering. Its first argument is the list and its
  566. second argument is the ordering function. The content of the list
  567. is not necessary numbers but must be such that the ordering function has
  568. a meaning.
  569. \begin{verbatim}
  570. l:={1,3,4,0}$ SORTNUMLIST l; ==> {0,1,3,4}
  571. ll:={1,a,tt,z}$ SORTLIST(ll,ordp); ==> {a,z,tt,1}
  572. \end{verbatim}
  573. One must know that using these functions for kernels or bags may be
  574. dangerous since they are destructive. If it is needed, it is recommended
  575. to first apply \f{KERNLIST} on them.
  576. The function \f{EXTREMUM} is a generalization of the already defined functions
  577. \f{MIN, MAX} to include general orderings. It is a 2 arguments function.
  578. The first is the list and the second is the ordering function.
  579. With the list \verb+ll+ defined in the last example, one gets
  580. \begin{verbatim}
  581. EXTREMUM(ll,ordp); ==> 1
  582. \end{verbatim}
  583. \item[iii.] There are four functions to identify dependencies.
  584. \f{FUNCVAR} takes any expression as argument and returns the set of
  585. variables of which it depends. Constants are eliminated.
  586. \begin{verbatim}
  587. FUNCVAR(e+pi+sin(log(y)); ==> {y}
  588. \end{verbatim}
  589. \f{DEPATOM} has an {\bf atom} as argument. It returns it if it is
  590. a number or if no dependency has previously been declared. Otherwise,
  591. it returns the list of variables which the various depend declarations
  592. imply.
  593. \begin{verbatim}
  594. depend a,x,y;
  595. DEPATOM a; ==> {x,y}
  596. \end{verbatim}
  597. The functions \f{EXPLICIT} and \f{IMPLICIT} make explicit or
  598. implicit the dependencies. This example show how they work:
  599. \begin{verbatim}
  600. depend a,x; depend x,y,z;
  601. EXPLICIT a; ==> a(x(y,z))
  602. IMPLICIT ws; ==> a
  603. \end{verbatim}
  604. These are useful when one does not know the names of the variables
  605. and (or) the nature of the dependencies.
  606. \f{KORDERLIST} is a zero argument function which display the actual
  607. ordering.
  608. \begin{verbatim}
  609. korder x,y,z;
  610. KORDERLIST; ==> (x,y,z)
  611. \end{verbatim}
  612. \item[iv.] A function \f{SIMPLIFY} which takes an arbitrary expression
  613. is available which {\em forces} down-to-the-botttom simplification of
  614. an expression. It is usefull with \f{SYMMETRIZE}. It has also proved
  615. usefull to simplify some output expressions of the package
  616. EXCALC\ (E. Schruefer). Here is an example:
  617. \begin{verbatim}
  618. l:=op(x,y,z)$
  619. op(x,y,z):=x*y*z$
  620. SYMMETRIZE(l,op,cyclicpermlist); ==>
  621. op(x,y,z)+op(y,z,x)+op(z,x,y)
  622. SIMPLIFY ws; ==> op(y,z,x)+op(z,x,y)+x*y*z
  623. \end{verbatim}
  624. \item[v.] Filtering functions for lists.
  625. \f{CHECKPROLIST} is a boolean function which checks if the
  626. elements of a list have a definite property. Its first argument
  627. is the list, its second argument is a boolean function
  628. (\f{FIXP NUMBERP $\ldots$}) or an ordering function (as \f{ORDP}).
  629. \f{EXTRACTLIST} extracts from the list given as its first argument
  630. the elements which satisfy the boolean function given as its second
  631. argument. For example:
  632. \begin{verbatim}
  633. l:={1,a,b,"st")$
  634. EXTRACTLIST(l,fixp); ==> {1}
  635. EXTRACTLIST(l,stringp); ==> {st}
  636. \end{verbatim}
  637. \ei
  638. \section{Properties and Flags}
  639. In spite of the fact that many facets of the handling of
  640. property lists is easily accessible in the algebraic mode, it is useful to
  641. provide analogous functions {\em genuine} to the algebraic mode. The reason is
  642. that, altering property lists of objects, may easily destroy the integrity
  643. of the system. The functions, which are here described, {\bf do ignore}
  644. the property list and flags already defined by the system itself. They
  645. generate and track the {\em addtional properties and flags} that the user
  646. issues using them. They offer him
  647. the possibility to work on property lists so
  648. that he can design a programming style of the ``conceptual'' type.
  649. \bi
  650. \item[i.] We first consider ``flags''. \\
  651. To a given identifier, one may
  652. associates another one linked to it ``in the background''. The three
  653. functions \f{PUTFLAG, DISPLAYFLAG} and \f{CLEARFLAG} handle them.
  654. \f{PUTFLAG} has 3 arguments. The first is the identifier or a list
  655. of identifiers, the second is the name of the flag,
  656. the third is T (true) or 0 (zero).
  657. When the third argument is T, it creates the flag, when it is 0 it
  658. destroys it.
  659. \begin{verbatim}
  660. PUTFLAG(z1,flag_name,t); ==> flag_name
  661. PUTFLAG({z1,z2},flag1_name,t); ==> t
  662. PUTFLAG(z2,flag1_name,0) ==>
  663. \end{verbatim}
  664. \f{DISPLAYFLAG} allows to extract flags. The previous actions give:
  665. \begin{verbatim}
  666. DISPLAYFLAG z1; ==>{flag_name,flag1_name}
  667. DISPLAYFLAG z2 ; ==> {}
  668. \end{verbatim}
  669. \f{CLEARFLAG} is a command which clears {\em all} flags associated to
  670. the identifiers $id_1, \ldots , id_n .$
  671. \item[ii.] Properties are handled by similar functions.
  672. \f{PUTPROP} has four arguments. The second argument is, here, the
  673. {\em indicator} of the property. The third argument may be {\em any
  674. valid expression}. The fourth one is also T or 0.
  675. \begin{verbatim}
  676. PUTPROP(z1,property,x^2,t); ==> z1
  677. \end{verbatim}
  678. In general, one enter
  679. \begin{verbatim}
  680. PUTPROP(LIST(idp1,idp2,..),<propname>,<value>,T);
  681. \end{verbatim}
  682. To display a specific property, one uses
  683. \f{DISPLAYPROP} which takes two arguments. The first is the name of the
  684. identifier, the second is the indicator of the property.
  685. \begin{verbatim}
  686. 2
  687. DISPLAYPROP(z1,property); ==> {property,x }
  688. \end{verbatim}
  689. Finally, \f{CLEARPROP} is a nary commmand which clears {\em all}
  690. properties of the identifiers which appear as arguments.
  691. \ei
  692. \section{Control Functions}
  693. Here we describe additional functions which
  694. improve the user control on the environment.
  695. \bi
  696. \item[i.]
  697. The first set of functions is composed of unary and binary boolean functions.
  698. They are:
  699. \begin{verbatim}
  700. ALATOMP x; x is anything.
  701. ALKERNP x; x is anything.
  702. DEPVARP(x,v); x is anything.
  703. (v is an atom or a kernel)
  704. \end{verbatim}
  705. \f{ALATOMP} has the value T iff x is an integer or an identifier
  706. {\em after} it has been evaluated down to the bottom.
  707. \f{ALKERNP} has the value T iff x is a kernel {\em after}
  708. it has been evaluated down to the bottom.
  709. \f{DEPVARP} returns T iff the expression x depends on v at
  710. {\bf any level}.
  711. The above functions together with \f{PRECP} have
  712. been declared operator functions to ease the verification of
  713. their value.
  714. \f{NORDP} is essentially equivalent to \verb+not+\f{ ORDP}
  715. when inside a conditional statement. Otherwise, it can be used
  716. while \verb+not+\f{ ORDP} cannot.
  717. \item[ii.]
  718. The next functions allow one to {\em analyze} and to
  719. {\em clean} the environment
  720. of \REDUCE\ which is created by the user while he is working
  721. {\bf interactively}. To functions are provided:\\
  722. \f{SHOW} allows to get the various identifiers already
  723. assigned and to see their type. \f{SUPPRESS} selectively clears the
  724. used identifiers or clears them all. It is to be stressed that identifiers
  725. assigned from the input of files are {\bf ignored}.
  726. Both functions have one argument and the same options for this
  727. argument:
  728. \begin{verbatim}
  729. SHOW (SUPPRESS) all
  730. SHOW (SUPPRESS) scalars
  731. SHOW (SUPPRESS) lists
  732. SHOW (SUPPRESS) saveids (for saved expressions)
  733. SHOW (SUPPRESS) matrices
  734. SHOW (SUPPRESS) arrays
  735. SHOW (SUPPRESS) vectors
  736. (contains vector, index and tvector)
  737. SHOW (SUPPRESS) forms
  738. \end{verbatim}
  739. The option \verb+all+ is the most convenient for \f{SHOW} but,
  740. with it, it may
  741. takes time to get the answer after one has worked several hours.
  742. When entering \REDUCE\ the option \verb+all+ for \f{SHOW} gives:
  743. \begin{verbatim}
  744. SHOW all; ==>
  745. scalars are: NIL
  746. arrays are: NIL
  747. lists are: NIL
  748. matrices are: NIL
  749. vectors are: NIL
  750. forms are: NIL
  751. \end{verbatim}
  752. It is a convenient way to remember the various options. Here an example
  753. which is valid when one starts from a fresh environment:
  754. \begin{verbatim}
  755. a:=b:=1$
  756. SHOW scalars; ==> scalars are: (A B)
  757. SUPPRESS scalars; ==> t
  758. SHOW scalars; ==> scalars are: NIL
  759. \end{verbatim}
  760. \item[iii.]
  761. The \f{CLEAR} function of the system does not do a complete cleaning of
  762. \verb+OPERATORS+ and \verb+FUNCTIONS+ . The following two functions do a more
  763. complete cleaning and, also, takes automatically into account the
  764. {\em user} flag and properties that the functions
  765. \f{PUTFLAG} and \f{PUTPROP} may have introduced.
  766. Their names are \f{CLEAROP} and \f{CLEARFUNCTIONS}.
  767. \f{CLEAROP} takes one operator as its argument.\\
  768. \f{CLEARFUNCTIONS} is a nary command. If one issues
  769. \begin{verbatim}
  770. CLEARFUNCTIONS a1,a2, ... , an $
  771. \end{verbatim}
  772. The functions with names \verb+ a1,a2, ... ,an+ are cleared.
  773. One should be careful when using this facility since the
  774. only functions which cannot be erased are those which are
  775. protected with the \verb+lose+ flag.
  776. \ei
  777. \section{Handling of Polynomials}
  778. The module contains some utility functions to handle
  779. standard quotients and several new facilities to manipulate polynomials.
  780. \bi
  781. \item[i.] Two functions \f{ALG\_TO\_SYMB} and \f{SYMB\_TO\_ALG}
  782. allow to change an expression which is in the algebraic standard
  783. quotient form into a prefix lisp form and vice-versa. This is made
  784. in such a way that the symbol \verb+list+ which appears in the
  785. algebraic mode desappear in the symbolic form (there it becomes
  786. a parenthesis ``()'' ) and it is reintroduced in the translation
  787. from a symbolic prefix lisp expression to an algebraic one.
  788. Here, is an example, showing how the wellknown lisp function
  789. \f{FLATTENS} can be trivially transposed inside the algebraic mode:
  790. \begin{verbatim}
  791. algebraic procedure ecrase x;
  792. lisp symb_to_alg flattens1 alg_to_symb algebraic x;
  793. symbolic procedure flattens1 x;
  794. % ll; ==> ((A B) ((C D) E))
  795. % flattens1 ll; (A B C D E)
  796. if atom x then list x else
  797. if cdr x then
  798. append(flattens1 car x, flattens1 cdr x)
  799. else flattens1 car x;
  800. \end{verbatim}
  801. gives, for instance,
  802. \begin{verbatim}
  803. ll:={a,{b,{c},d,e},{{{z}}}}$
  804. ECRASE ll; ==> {A, B, C, D, E, Z}
  805. \end{verbatim}
  806. \item[ii.]
  807. \f{LEADTERM} and \f{REDEXPR} are the algebraic equivalent of the
  808. symbolic functions \f{LT} and \f{RED}. They give, respectively, the
  809. {\em leading term} and the {\em reductum} of a polynomial. They also work
  810. for rational functions. Their interest lies in the fact that they do not
  811. require to extract the main variable. They work according to the current
  812. ordering of the system:
  813. \begin{verbatim}
  814. pol:=x++y+z$
  815. LEADTERM pol; ==> x
  816. korder y,x,z;
  817. LEADTERM pol; ==> y
  818. REDEXPR pol; ==> x + z
  819. \end{verbatim}
  820. By default, the representation of multivariate polynomials is recursive.
  821. It is justified since it is the one which takes the least of memory.
  822. With such a representation, the function \f{LEADTERM} does not necessarily
  823. extract a true monom. It extracts a monom in the leading indeterminate
  824. multiplied by a polynomial in the other indeterminates. However, very often,
  825. one needs to handle true monoms separately. In that case, one needs a
  826. polynomial in {\em distributive} form. Such a form is provided by the
  827. package GROEBNER (H. Melenk et al.). The facility there is, however,
  828. much too involved and the necessity to load the package makes interesting
  829. an elementary facility to write polynomials in a distributive form. So,
  830. a new switch is created to handle {\em distributed} polynomials. It is
  831. called {\tt DISTRIBUTE} and a new function \f{DISTRIBUTE} puts a
  832. polynomial in distributive form. With the switch put to {\bf on},
  833. \f{LEADTERM} gives {\bf true} monoms.
  834. \f{MONOM} transforms a polynomial into a list of monoms. It works
  835. {\em whatever the position of the switch} {\tt DISTRIBUTE}.
  836. \f{SPLITTERMS} is analoguous to \f{MONOM} except that it gives
  837. a list of two lists. The first sublist contains the positive terms
  838. while the second sublist contains the negative terms.
  839. \f{SPLITPLUSMINUS} gives a list whose first element is the positive
  840. part of the polynomial and its second element is its negative part.
  841. \item[iii.]
  842. Two complementary functions \f{LOWESTDEG} and \f{DIVPOL} are provided.
  843. The first takes a polynomial as its first argument and the name of an
  844. indeterminate as its second argument. It returns the {\em lowest degree}
  845. in that indeterminate. The second function takes two polynomials and
  846. returns both the quotient and its remainder.
  847. \ei
  848. \section{Handling of Transcendental Functions}
  849. \bi
  850. \item[i.]
  851. The functions \f{TRIGREDUCE} and \f{TRIGEXPAND} and the equivalent
  852. one for hyperbolic functions \f{HYPREDUCE} and \f{HYPEXPAND}
  853. make the transformations to multiple arguments and from
  854. multiple arguments to elementary arguments. Here, a simple example:
  855. \begin{verbatim}
  856. aa:=sin(x+y)$
  857. TRIGEXPAND aa; ==> SIN(X)*COS(Y) + SIN(Y)*COS(X)
  858. TRIGREDUCE ws; ==> SIN(Y + X)
  859. \end{verbatim}
  860. When a trigonometric or hyperbolic expression is symmetric with
  861. respect to the interchange of {\tt SIN (SINH)} and {\tt COS (COSH)},
  862. the application of \f{TRIG-(HYP)-REDUCE} may often lead to great
  863. simplifications. However, if it is highly assymetric, the repeated
  864. application of \f{TRIG-(HYP)-REDUCE} followed by the use of
  865. \f{TRIG-(HYP)-EXPAND} will lead to {\em more} complicated
  866. but more symmetric expressions:
  867. \begin{verbatim}
  868. aa:=(sin(x)^2+cos(x)^2)^3$
  869. TRIGREDUCE aa; ==> 1
  870. \end{verbatim}
  871. \pagebreak
  872. \begin{verbatim}
  873. bb:=1+sin(x)^3$
  874. TRIGREDUCE bb; ==>
  875. - SIN(3*X) + 3*SIN(X) + 4
  876. ---------------------------
  877. 4
  878. TRIGEXPAND ws; ==>
  879. 3 2
  880. SIN(X) - 3*SIN(X)*COS(X) + 3*SIN(X) + 4
  881. -------------------------------------------
  882. 4
  883. \end{verbatim}
  884. \item[ii.]
  885. Two functions for the manipulation of logarithmic expression are
  886. available. They are \f{PLUSLOG} and \f{CONCSUMLOG}.
  887. Both function take an arbitrary expression as argument. The first one
  888. transforms products, ratios and exponentiations which appear under a
  889. \verb+log+ respectively into sums, differnces of log's and products
  890. of exponents with log's. The second one does the opposite job.
  891. \ei
  892. \section{Handling of n--dimensional Vectors}
  893. Explicit vectors in {\tt EUCLIDEAN} space may be represented by
  894. list-like or bag-like objects of depth 1.
  895. The components may be bags but may {\bf not} be lists.
  896. Functions are provided to do the sum, the difference and the
  897. scalar product. When, space-dimension is three, there are also functions
  898. for the cross and mixed products.
  899. \f{SUMVECT, MINVECT, SCALVECT, CROSSVECT} have two arguments.
  900. \f{MPVECT} has three arguments. The following example
  901. is sufficient to explain how they work:
  902. \begin{verbatim}
  903. l:={1,2,3}$
  904. ll:=list(a,b,c)$
  905. SUMVECT(l,ll); ==> {A + 1,B + 2,C + 3}
  906. MINVECT(l,ll); ==> { - A + 1, - B + 2, - C + 3}
  907. SCALVECT(l,ll); ==> A + 2*B + 3*C
  908. CROSSVECT(l,ll); ==> { - 3*B + 2*C,3*A - C, - 2*A + B}
  909. MPVECT(l,ll,l); ==> 0
  910. \end{verbatim}
  911. \section{Handling of Grassmann Operators}
  912. Grassman variables are often used in physics. For them the multiplication
  913. operation is associative, distributive but anticommutative. The
  914. {\tt KERNEL} of \REDUCE\ does not provide it. However, implementing
  915. it in full generality would almost
  916. certainly decrease the overall efficiency of the system. This small
  917. module together with the declaration of antisymmetry for operators is
  918. enough to deal with most calculations. The reason is, that a
  919. product of similar anticommuting kernels can easily be transformed
  920. into an antisymmetric operator with as many indices as the number of
  921. these kernels. Moreover, one may also issue pattern matching rules
  922. to implement the anticommutativity of the product.
  923. The functions in this module represent the minimum functionality
  924. required to identify them and to handle their specific features.
  925. \f{PUTGRASS} is a (nary) command which give identifiers the property
  926. to be the names of Grassmann kernels. \f{REMGRASS} removes this property.
  927. \f{GRASSP} is a boolean function which detects grassmann kernels.
  928. \f{GRASSPARITY} takes a {\bf monom} as argument and gives its parity.
  929. If the monom is a simple grassmann kernel it returns 1.
  930. \f{GHOSTFACTOR} has two arguments. Each one is a monom. It is equal to
  931. \begin{verbatim}
  932. (-1)**(GRASSPARITY u * GRASSPARITY v)
  933. \end{verbatim}
  934. Here is an illustration to show how the above functions work:
  935. \begin{verbatim}
  936. PUTGRASS eta; ==> t
  937. if GRASSP eta(1) then "grassmann kernel"; ==>
  938. grassmann kernel
  939. aa:=eta(1)*eta(2)-eta(2)*eta(1); ==>
  940. AA := - ETA(2)*ETA(1) + ETA(1)*ETA(2)
  941. GRASSPARITY eta(1); ==> 1
  942. GRASSPARITY (eta(1)*eta(2)); ==> 0
  943. GHOSTFACTOR(eta(1),eta(2)); ==> -1
  944. grasskernel:=
  945. {eta(~x)*eta(~y) => -eta y * eta x when nordp(x,y),
  946. (~x)*(~x) => 0 when grassp x};
  947. exp:=eta(1)^2$
  948. exp where grasskernel; ==> 0
  949. aa where grasskernel; ==> - 2*ETA(2)*ETA(1)
  950. \end{verbatim}
  951. \section{Handling of Matrices}
  952. This module provides functions for handling matrices more comfortably.
  953. \bi
  954. \item[i.]
  955. Often, one needs to construct some {\tt UNIT} matrix of
  956. a given dimension. This construction is done by the system thanks
  957. to the function \f{UNITMAT}. it is a nary function. The command is
  958. \begin{verbatim}
  959. UNITMAT M1(n1), M2(n2), .....Mi(ni) ;
  960. \end{verbatim}
  961. where \verb+M1,...Mi+ are names of matrices and
  962. \verb+ n1, n2, ..., ni+ are integers .
  963. \f{MKIDM} is a generalization of \f{MKID}. It allows to connect
  964. two or several matrices. If \verb+u+ and \verb+u1+ are two matrices,
  965. one can go from one to the other:
  966. \begin{verbatim}
  967. matrix u(2,2);$ unitmat u1(2)$
  968. u1; ==>
  969. [1 0]
  970. [ ]
  971. [0 1]
  972. mkidm(u,1); ==>
  973. [1 0]
  974. [ ]
  975. [0 1]
  976. \end{verbatim}
  977. This function allows to make loops on matrices like in the following
  978. illustration. If \verb+U, U1, U2,.., U5+ are matrices:
  979. \begin{verbatim}
  980. FOR I:=1:5 DO U:=U-MKIDM(U,I);
  981. \end{verbatim}
  982. can be issued.
  983. \item[ii.]
  984. The next functions map matrices on bag-like or list-like objects
  985. and conversely they generate matrices from bags or lists.
  986. \f{COERCEMAT} transforms the matrix \verb+U+ into a list of lists.
  987. The entry is
  988. \begin{verbatim}
  989. COERCEMAT(U,id)
  990. \end{verbatim}
  991. where \verb+id+ is equal to \verb+list+ othewise it transforms it into
  992. a bag of bags whose envelope is equal to \verb+id+.
  993. \f{BAGLMAT} does the opposite job. The {\bf first} argument is the
  994. bag-like or list-like object while the second argument is the matrix
  995. identifier. The entry is
  996. \begin{verbatim}
  997. BAGLMAT(bgl,U)
  998. \end{verbatim}
  999. \verb+bgl+ becomes the matrix \verb+U+ . The transformation is
  1000. {\bf not} done if \verb+U+ is {\em already} the name of a
  1001. previously defined matrix. This is to avoid ACCIDENTAL redefinition
  1002. of that matrix.
  1003. \item[ii.]
  1004. The functions \f{SUBMAT, MATEXTR, MATEXTC} take parts of a given matrix.
  1005. \f{SUBMAT} has three arguments. The entry is
  1006. \begin{verbatim}
  1007. SUBMAT(U,nr,nc)
  1008. \end{verbatim}
  1009. The first is the matrix name, and the other two are the row and column
  1010. numbers . It gives the
  1011. submatrix obtained from \verb+U+ deleting the row \verb+nr+ and
  1012. the column \verb+nc+.
  1013. When one of them is equal to zero only column \verb+nc+
  1014. or row \verb+nr+ is deleted.
  1015. \f{MATEXTR} and \f{MATEXTC} extract a row or a column and place it into
  1016. a list-like or bag-like object.
  1017. The entry are
  1018. \begin{verbatim}
  1019. MATEXTR(U,VN,nr)
  1020. MATEXTC(U,VN,nc)
  1021. \end{verbatim}
  1022. where \verb+U+ is the matrix, \verb+VN+ is the ``vector name'',
  1023. \verb+nr+ and \verb+nc+ are integers. If \verb+VN+ is equal
  1024. to {\tt list} the vector is given as a list otherwise it is
  1025. given as a bag.
  1026. \item[iii.]
  1027. Functions which manipulate matrices. They are
  1028. \f{MATSUBR, MATSUBC, HCONCMAT, VCONCMAT, TPMAT, HERMAT}
  1029. \f{MATSUBR MATSUBC} substitute rows and columns. They have three arguments.
  1030. Entries are:
  1031. \begin{verbatim}
  1032. MATSUBR(U,bgl,nr)
  1033. MATSUBC(U,bgl,nc)
  1034. \end{verbatim}
  1035. The meaning of the variables \verb+U, nr, nc+ is the same as above
  1036. while \verb+bgl+ is a list-like or bag-like vector.
  1037. Its length should be compatible with the dimensions of the matrix.
  1038. \f{HCONCMAT VCONCMAT} concatenate two matrices. The entries are
  1039. \begin{verbatim}
  1040. HCONCMAT(U,V)
  1041. VCONCMAT(U,V)
  1042. \end{verbatim}
  1043. The first function concatenates horizontally, the second one
  1044. concatenates vertically. The dimensions must match.
  1045. \f{TPMAT} makes the tensor product of two matrices. It is also an
  1046. {\em infix} function. The entry is
  1047. \begin{verbatim}
  1048. TPMAT(U,V) or U TPMAT V
  1049. \end{verbatim}
  1050. \f{HERMAT} takes the hermitian conjuguate of a matrix
  1051. The entry is
  1052. \begin{verbatim}
  1053. HERMAT(U,HU)
  1054. \end{verbatim}
  1055. where \verb+HU+ is the identifier for the hermitian matrix of \verb+U+.
  1056. It should {\bf unassigned} for this function to work successfully.
  1057. This is done on purpose to prevent accidental redefinition of an already
  1058. used identifier .
  1059. \item[iv.]
  1060. \f{SETELMAT GETELMAT} are functions of two integers. The first one
  1061. reset the element \verb+(i,j)+ while the second one extract an
  1062. element identified by \verb+(i,j)+. They may be useful when
  1063. dealing with matrices {\em inside procedures}.
  1064. \ei
  1065. %\input assist1
  1066. %\input assist2
  1067. %\input assist3
  1068. %\input assist4
  1069. %\input assist5
  1070. %\input assist6
  1071. %\input assist7
  1072. %\input assist8
  1073. \end{document}